From ab959d7b4194715870128e616b8e29d4a101e488 Mon Sep 17 00:00:00 2001 From: etobi Date: Tue, 3 Sep 2013 09:48:41 +0200 Subject: Imported Upstream version 1.1.1+rev1207 --- lib/libesg/encapsulation/Makefile | 28 +++ lib/libesg/encapsulation/auxiliary_data.h | 62 +++++++ lib/libesg/encapsulation/container.c | 206 +++++++++++++++++++++ lib/libesg/encapsulation/container.h | 94 ++++++++++ lib/libesg/encapsulation/data_repository.c | 53 ++++++ lib/libesg/encapsulation/data_repository.h | 59 ++++++ .../fragment_management_information.c | 118 ++++++++++++ .../fragment_management_information.h | 96 ++++++++++ lib/libesg/encapsulation/string_repository.c | 54 ++++++ lib/libesg/encapsulation/string_repository.h | 60 ++++++ 10 files changed, 830 insertions(+) create mode 100644 lib/libesg/encapsulation/Makefile create mode 100644 lib/libesg/encapsulation/auxiliary_data.h create mode 100644 lib/libesg/encapsulation/container.c create mode 100644 lib/libesg/encapsulation/container.h create mode 100644 lib/libesg/encapsulation/data_repository.c create mode 100644 lib/libesg/encapsulation/data_repository.h create mode 100644 lib/libesg/encapsulation/fragment_management_information.c create mode 100644 lib/libesg/encapsulation/fragment_management_information.h create mode 100644 lib/libesg/encapsulation/string_repository.c create mode 100644 lib/libesg/encapsulation/string_repository.h (limited to 'lib/libesg/encapsulation') diff --git a/lib/libesg/encapsulation/Makefile b/lib/libesg/encapsulation/Makefile new file mode 100644 index 0000000..2f222ed --- /dev/null +++ b/lib/libesg/encapsulation/Makefile @@ -0,0 +1,28 @@ +# Makefile for linuxtv.org dvb-apps/lib/libesg/encapsulation + +.PHONY: sub-error-encapsulation + +sub-error-encapsulation: + $(error You can't use this makefile directly.) + +ifneq ($(lib_name),) + +objects += encapsulation/container.o \ + encapsulation/fragment_management_information.o \ + encapsulation/data_repository.o \ + encapsulation/string_repository.o + +sub-install += encapsulation + +else + +includes = container.h \ + fragment_management_information.h \ + data_repository.h \ + string_repository.h + +include ../../../Make.rules + +lib_name = libesg/encapsulation + +endif diff --git a/lib/libesg/encapsulation/auxiliary_data.h b/lib/libesg/encapsulation/auxiliary_data.h new file mode 100644 index 0000000..e05b241 --- /dev/null +++ b/lib/libesg/encapsulation/auxiliary_data.h @@ -0,0 +1,62 @@ +/* + * ESG parser + * + * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _ESG_ENCAPSULATION_AUXILIARY_DATA_H +#define _ESG_ENCAPSULATION_AUXILIARY_DATA_H 1 + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +/** + * esg_any_attribute structure. + */ +struct esg_any_attribute { + uint8_t version_id; + uint8_t *extension; + + struct esg_any_attribure *_next; +}; + +/** + * esg_binary_header structure. + */ +struct esg_binary_header { + uint16_t encoding_metadatauri_mimetype; + struct esg_any_attribute *any_attribute_list; +}; + +/** + * esg_encapsulated_aux_data struct. + */ +struct esg_encapsulated_aux_data { + struct esg_binary_header *binary_header; + uint32_t aux_data_length; + uint8_t aux_data; +}; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/libesg/encapsulation/container.c b/lib/libesg/encapsulation/container.c new file mode 100644 index 0000000..15b17bf --- /dev/null +++ b/lib/libesg/encapsulation/container.c @@ -0,0 +1,206 @@ +/* + * ESG parser + * + * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + +#include +#include +#include +#include +#include +#include + +struct esg_container *esg_container_decode(uint8_t *buffer, uint32_t size) { + uint32_t pos; + struct esg_container *container; + struct esg_container_structure *structure; + struct esg_container_structure *last_structure; + uint8_t structure_index; + + if ((buffer == NULL) || (size <= 1)) { + return NULL; + } + + pos = 0; + + container = (struct esg_container *) malloc(sizeof(struct esg_container)); + memset(container, 0, sizeof(struct esg_container)); + + // Container header + container->header = (struct esg_container_header *) malloc(sizeof(struct esg_container_header)); + memset(container->header, 0, sizeof(struct esg_container_header)); + + container->header->num_structures = buffer[pos]; + pos += 1; + + if (size < pos + (container->header->num_structures * 8)) { + esg_container_free(container); + return NULL; + } + + last_structure = NULL; + for (structure_index = 0; structure_index < container->header->num_structures; structure_index++) { + structure = (struct esg_container_structure *) malloc(sizeof(struct esg_container_structure)); + memset(structure, 0, sizeof(struct esg_container_structure)); + structure->_next = NULL; + + if (last_structure == NULL) { + container->header->structure_list = structure; + } else { + last_structure->_next = structure; + } + last_structure = structure; + + structure->type = buffer[pos]; + pos += 1; + + structure->id = buffer[pos]; + pos += 1; + + structure->ptr = (buffer[pos] << 16) | (buffer[pos+1] << 8) | buffer[pos+2]; + pos += 3; + + structure->length = (buffer[pos] << 16) | (buffer[pos+1] << 8) | buffer[pos+2]; + pos += 3; + + if (size < (structure->ptr + structure->length)) { + esg_container_free(container); + return NULL; + } + + // Decode structure + switch (structure->type) { + case 0x01: { + switch (structure->id) { + case 0x00: { + structure->data = (void *) esg_encapsulation_structure_decode(buffer + structure->ptr, structure->length); + break; + } + default: { + esg_container_free(container); + return NULL; + } + } + break; + } + case 0x02: { + switch (structure->id) { + case 0x00: { + structure->data = (void *) esg_string_repository_decode(buffer + structure->ptr, structure->length); + break; + } + default: { + esg_container_free(container); + return NULL; + } + } + break; + } + case 0x03: { + //TODO + break; + } + case 0x04: { + //TODO + break; + } + case 0x05: { + //TODO + break; + } + case 0xE0: { + switch (structure->id) { + case 0x00: { + structure->data = (void *) esg_data_repository_decode(buffer + structure->ptr, structure->length); + break; + } + default: { + esg_container_free(container); + return NULL; + } + } + break; + } + case 0xE1: { + switch (structure->id) { + case 0xFF: { + structure->data = (void *) esg_session_partition_declaration_decode(buffer + structure->ptr, structure->length); + break; + } + default: { + esg_container_free(container); + return NULL; + } + } + break; + } + case 0xE2: { + switch (structure->id) { + case 0x00: { + structure->data = (void *) esg_init_message_decode(buffer + structure->ptr, structure->length); + break; + } + default: { + esg_container_free(container); + return NULL; + } + } + break; + } + default: { + esg_container_free(container); + return NULL; + } + } + } + + // Container structure body + container->structure_body_ptr = pos; + container->structure_body_length = size - pos; + container->structure_body = (uint8_t *) malloc(size - pos); + memcpy(container->structure_body, buffer + pos, size - pos); + + return container; +} + +void esg_container_free(struct esg_container *container) { + struct esg_container_structure *structure; + struct esg_container_structure *next_structure; + + if (container == NULL) { + return; + } + + if (container->header) { + for(structure = container->header->structure_list; structure; structure = next_structure) { + next_structure = structure->_next; + free(structure); + } + + free(container->header); + } + + if (container->structure_body) { + free(container->structure_body); + } + + free(container); +} diff --git a/lib/libesg/encapsulation/container.h b/lib/libesg/encapsulation/container.h new file mode 100644 index 0000000..dc54ef2 --- /dev/null +++ b/lib/libesg/encapsulation/container.h @@ -0,0 +1,94 @@ +/* + * ESG parser + * + * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _ESG_ENCAPSULATION_CONTAINER_H +#define _ESG_ENCAPSULATION_CONTAINER_H 1 + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +/** + * esg_container_structure structure. + */ +struct esg_container_structure { + uint8_t type; + uint8_t id; + uint32_t ptr; + uint32_t length; + + void *data; + + struct esg_container_structure *_next; +}; + +/** + * esg_container_header structure. + */ +struct esg_container_header { + uint8_t num_structures; + struct esg_container_structure *structure_list; +}; + +/** + * esg_container structure + */ +struct esg_container { + struct esg_container_header *header; + uint32_t structure_body_ptr; + uint32_t structure_body_length; + uint8_t *structure_body; +}; + +/** + * Process an esg_container. + * + * @param buffer Binary buffer to decode. + * @param size Binary buffer size. + * @return Pointer to an esg_container structure, or NULL on error. + */ +extern struct esg_container *esg_container_decode(uint8_t *buffer, uint32_t size); + +/** + * Free an esg_container. + * + * @param container Pointer to an esg_container structure. + */ +extern void esg_container_free(struct esg_container *container); + +/** + * Convenience iterator for structure_list field of an esg_container_header. + * + * @param container The esg_container_header pointer. + * @param structure Variable holding a pointer to the current esg_container_structure. + */ +#define esg_container_header_structure_list_for_each(header, structure) \ + for ((structure) = (header)->structure_list; \ + (structure); \ + (structure) = (structure)->_next) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/libesg/encapsulation/data_repository.c b/lib/libesg/encapsulation/data_repository.c new file mode 100644 index 0000000..629e5ea --- /dev/null +++ b/lib/libesg/encapsulation/data_repository.c @@ -0,0 +1,53 @@ +/* + * ESG parser + * + * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + +#include + +struct esg_data_repository *esg_data_repository_decode(uint8_t *buffer, uint32_t size) { + struct esg_data_repository *data_repository; + + if ((buffer == NULL) || (size <= 0)) { + return NULL; + } + + data_repository = (struct esg_data_repository *) malloc(sizeof(struct esg_data_repository)); + memset(data_repository, 0, sizeof(struct esg_data_repository)); + + data_repository->length = size; + data_repository->data = (uint8_t *) malloc(size); + memcpy(data_repository->data, buffer, size); + + return data_repository; +} + +void esg_data_repository_free(struct esg_data_repository *data_repository) { + if (data_repository == NULL) { + return; + } + + if (data_repository->data) { + free(data_repository->data); + } + + free(data_repository); +} diff --git a/lib/libesg/encapsulation/data_repository.h b/lib/libesg/encapsulation/data_repository.h new file mode 100644 index 0000000..4c691cf --- /dev/null +++ b/lib/libesg/encapsulation/data_repository.h @@ -0,0 +1,59 @@ +/* + * ESG parser + * + * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _ESG_ENCAPSULATION_DATA_REPOSITORY_H +#define _ESG_ENCAPSULATION_DATA_REPOSITORY_H 1 + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +/** + * esg_data_repository structure. + */ +struct esg_data_repository { + uint32_t length; + uint8_t *data; +}; + +/** + * Process an esg_data_repository. + * + * @param buffer Binary buffer to decode. + * @param size Binary buffer size. + * @return Pointer to an esg_data_repository structure, or NULL on error. + */ +extern struct esg_data_repository *esg_data_repository_decode(uint8_t *buffer, uint32_t size); + +/** + * Free an esg_data_repository. + * + * @param data_repository Pointer to an esg_data_repository structure. + */ +extern void esg_data_repository_free(struct esg_data_repository *data_repository); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/libesg/encapsulation/fragment_management_information.c b/lib/libesg/encapsulation/fragment_management_information.c new file mode 100644 index 0000000..b08265d --- /dev/null +++ b/lib/libesg/encapsulation/fragment_management_information.c @@ -0,0 +1,118 @@ +/* + * ESG parser + * + * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + +#include + +struct esg_encapsulation_structure *esg_encapsulation_structure_decode(uint8_t *buffer, uint32_t size) { + uint32_t pos; + struct esg_encapsulation_structure *structure; + struct esg_encapsulation_entry *entry; + struct esg_encapsulation_entry *last_entry; + + if ((buffer == NULL) || (size <= 2)) { + return NULL; + } + + pos = 0; + + structure = (struct esg_encapsulation_structure *) malloc(sizeof(struct esg_encapsulation_structure)); + memset(structure, 0, sizeof(struct esg_encapsulation_structure)); + structure->entry_list = NULL; + + // Encapsulation header + structure->header = (struct esg_encapsulation_header *) malloc(sizeof(struct esg_encapsulation_header)); + // buffer[pos] reserved + structure->header->fragment_reference_format = buffer[pos+1]; + pos += 2; + + // Encapsulation entry list + last_entry = NULL; + while (size > pos) { + entry = (struct esg_encapsulation_entry *) malloc(sizeof(struct esg_encapsulation_entry)); + memset(entry, 0, sizeof(struct esg_encapsulation_entry)); + entry->_next = NULL; + + if (last_entry == NULL) { + structure->entry_list = entry; + } else { + last_entry->_next = entry; + } + last_entry = entry; + + // Fragment reference + switch (structure->header->fragment_reference_format) { + case 0x21: { + entry->fragment_reference = (struct esg_fragment_reference *) malloc(sizeof(struct esg_fragment_reference)); + memset(entry->fragment_reference, 0, sizeof(struct esg_fragment_reference)); + + entry->fragment_reference->fragment_type = buffer[pos]; + pos += 1; + + entry->fragment_reference->data_repository_offset = (buffer[pos] << 16) | (buffer[pos+1] << 8) | buffer[pos+2]; + pos += 3; + + break; + } + default: { + esg_encapsulation_structure_free(structure); + return NULL; + } + } + + // Fragment version & id + entry->fragment_version = buffer[pos]; + pos += 1; + + entry->fragment_id = (buffer[pos] << 16) | (buffer[pos+1] << 8) | buffer[pos+2]; + pos += 3; + } + + return structure; +} + +void esg_encapsulation_structure_free(struct esg_encapsulation_structure *structure) { + struct esg_encapsulation_entry *entry; + struct esg_encapsulation_entry *next_entry; + + if (structure == NULL) { + return; + } + + if (structure->header) { + free(structure->header); + } + + if (structure->entry_list) { + for(entry = structure->entry_list; entry; entry = next_entry) { + next_entry = entry->_next; + if (entry->fragment_reference) { + free(entry->fragment_reference); + } + free(entry); + } + + free(structure->entry_list); + } + + free(structure); +} diff --git a/lib/libesg/encapsulation/fragment_management_information.h b/lib/libesg/encapsulation/fragment_management_information.h new file mode 100644 index 0000000..04050b5 --- /dev/null +++ b/lib/libesg/encapsulation/fragment_management_information.h @@ -0,0 +1,96 @@ +/* + * ESG parser + * + * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _ESG_ENCAPSULATION_FRAGMENT_MANAGEMENT_INFORMATION_H +#define _ESG_ENCAPSULATION_FRAGMENT_MANAGEMENT_INFORMATION_H 1 + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +/** + * esg_encapsulation_header structure. + */ +struct esg_encapsulation_header { + uint8_t fragment_reference_format; +}; + +/** + * esg_fragment_reference structure. + */ +struct esg_fragment_reference { + uint8_t fragment_type; + uint32_t data_repository_offset; +}; + +/** + * esg_encapsulation_entry structure. + */ +struct esg_encapsulation_entry { + struct esg_fragment_reference *fragment_reference; + uint8_t fragment_version; + uint32_t fragment_id; + + struct esg_encapsulation_entry *_next; +}; + +/** + * esg_encapsulation_structure structure. + */ +struct esg_encapsulation_structure { + struct esg_encapsulation_header *header; + struct esg_encapsulation_entry *entry_list; +}; + +/** + * Process an esg_encapsulation_structure. + * + * @param buffer Binary buffer to decode. + * @param size Binary buffer size. + * @return Pointer to an esg_encapsulation_structure structure, or NULL on error. + */ +extern struct esg_encapsulation_structure *esg_encapsulation_structure_decode(uint8_t *buffer, uint32_t size); + +/** + * Free an esg_encapsulation_structure. + * + * @param container Pointer to an esg_container structure. + */ +extern void esg_encapsulation_structure_free(struct esg_encapsulation_structure *structure); + +/** + * Convenience iterator for entry_list field of an esg_encapsulation_structure. + * + * @param structure The esg_encapsulation_structure pointer. + * @param entry Variable holding a pointer to the current esg_encapsulation_entry. + */ +#define esg_encapsulation_structure_entry_list_for_each(structure, entry) \ + for ((entry) = (structure)->entry_list; \ + (entry); \ + (entry) = (entry)->_next) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lib/libesg/encapsulation/string_repository.c b/lib/libesg/encapsulation/string_repository.c new file mode 100644 index 0000000..3b88742 --- /dev/null +++ b/lib/libesg/encapsulation/string_repository.c @@ -0,0 +1,54 @@ +/* + * ESG parser + * + * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include + +#include + +struct esg_string_repository *esg_string_repository_decode(uint8_t *buffer, uint32_t size) { + struct esg_string_repository *string_repository; + + if ((buffer == NULL) || (size <= 1)) { + return NULL; + } + + string_repository = (struct esg_string_repository *) malloc(sizeof(struct esg_string_repository)); + memset(string_repository, 0, sizeof(struct esg_string_repository)); + + string_repository->encoding_type = buffer[0]; + string_repository->length = size-1; + string_repository->data = (uint8_t *) malloc(size-1); + memcpy(string_repository->data, buffer+1, size-1); + + return string_repository; +} + +void esg_string_repository_free(struct esg_string_repository *string_repository) { + if (string_repository == NULL) { + return; + } + + if (string_repository->data) { + free(string_repository->data); + } + + free(string_repository); +} diff --git a/lib/libesg/encapsulation/string_repository.h b/lib/libesg/encapsulation/string_repository.h new file mode 100644 index 0000000..0cf64c2 --- /dev/null +++ b/lib/libesg/encapsulation/string_repository.h @@ -0,0 +1,60 @@ +/* + * ESG parser + * + * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef _ESG_ENCAPSULATION_STRING_REPOSITORY_H +#define _ESG_ENCAPSULATION_STRING_REPOSITORY_H 1 + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include + +/** + * esg_string_repository structure. + */ +struct esg_string_repository { + uint8_t encoding_type; + uint32_t length; + uint8_t *data; +}; + +/** + * Process an esg_string_repository. + * + * @param buffer Binary buffer to decode. + * @param size Binary buffer size. + * @return Pointer to an esg_string_repository structure, or NULL on error. + */ +extern struct esg_string_repository *esg_string_repository_decode(uint8_t *buffer, uint32_t size); + +/** + * Free an esg_string_repository. + * + * @param data_repository Pointer to an esg_string_repository structure. + */ +extern void esg_string_repository_free(struct esg_string_repository *string_repository); + +#ifdef __cplusplus +} +#endif + +#endif -- cgit v1.2.3