aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libesg/representation
diff options
context:
space:
mode:
authoretobi <git@e-tobi.net>2013-09-03 09:48:41 +0200
committeretobi <git@e-tobi.net>2013-09-03 09:48:41 +0200
commitab959d7b4194715870128e616b8e29d4a101e488 (patch)
tree61a746231d30817be73416a7d67763fd677a1042 /lib/libesg/representation
parent6b350466c4902c5b137e0efaf1d189128a7f18f5 (diff)
downloadlinux-dvb-apps-upstream/1.1.1+rev1207.tar.gz
Imported Upstream version 1.1.1+rev1207upstream/1.1.1+rev1207
Diffstat (limited to '')
-rw-r--r--lib/libesg/representation/Makefile26
-rw-r--r--lib/libesg/representation/bim_decoder_init.h40
-rw-r--r--lib/libesg/representation/encapsulated_bim_esg_xml_fragment.h40
-rw-r--r--lib/libesg/representation/encapsulated_textual_esg_xml_fragment.c70
-rw-r--r--lib/libesg/representation/encapsulated_textual_esg_xml_fragment.h60
-rw-r--r--lib/libesg/representation/init_message.c112
-rw-r--r--lib/libesg/representation/init_message.h80
-rw-r--r--lib/libesg/representation/textual_decoder_init.c128
-rw-r--r--lib/libesg/representation/textual_decoder_init.h104
9 files changed, 660 insertions, 0 deletions
diff --git a/lib/libesg/representation/Makefile b/lib/libesg/representation/Makefile
new file mode 100644
index 0000000..059f8bd
--- /dev/null
+++ b/lib/libesg/representation/Makefile
@@ -0,0 +1,26 @@
+# Makefile for linuxtv.org dvb-apps/lib/libesg/representation
+
+.PHONY: sub-error-representation
+
+sub-error-representation:
+ $(error You can't use this makefile directly.)
+
+ifneq ($(lib_name),)
+
+objects += representation/encapsulated_textual_esg_xml_fragment.o \
+ representation/init_message.o \
+ representation/textual_decoder_init.o
+
+sub-install += representation
+
+else
+
+includes = encapsulated_textual_esg_xml_fragment.h \
+ init_message.h \
+ textual_decoder_init.h
+
+include ../../../Make.rules
+
+lib_name = libesg/representation
+
+endif
diff --git a/lib/libesg/representation/bim_decoder_init.h b/lib/libesg/representation/bim_decoder_init.h
new file mode 100644
index 0000000..4860da9
--- /dev/null
+++ b/lib/libesg/representation/bim_decoder_init.h
@@ -0,0 +1,40 @@
+/*
+ * 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_REPRESENTATION_BIM_DECODER_INIT_H
+#define _ESG_REPRESENTATION_BIM_DECODER_INIT_H 1
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * esg_bim_decoder_init structure.
+ */
+struct esg_bim_decoder_init {
+// TODO
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/libesg/representation/encapsulated_bim_esg_xml_fragment.h b/lib/libesg/representation/encapsulated_bim_esg_xml_fragment.h
new file mode 100644
index 0000000..8ab39dd
--- /dev/null
+++ b/lib/libesg/representation/encapsulated_bim_esg_xml_fragment.h
@@ -0,0 +1,40 @@
+/*
+ * 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_REPRESENTATION_ENCAPSULATED_BIM_ESG_XML_FRAGMENT_H
+#define _ESG_REPRESENTATION_ENCAPSULATED_BIM_ESG_XML_FRAGMENT_H 1
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * esg_encapsulated_bim_esg_xml_fragment structure.
+ */
+struct esg_encapsulated_bim_esg_xml_fragment {
+ //TODO
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/libesg/representation/encapsulated_textual_esg_xml_fragment.c b/lib/libesg/representation/encapsulated_textual_esg_xml_fragment.c
new file mode 100644
index 0000000..199c857
--- /dev/null
+++ b/lib/libesg/representation/encapsulated_textual_esg_xml_fragment.c
@@ -0,0 +1,70 @@
+/*
+ * 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 <stdlib.h>
+#include <string.h>
+
+#include <libesg/types.h>
+#include <libesg/representation/encapsulated_textual_esg_xml_fragment.h>
+
+struct esg_encapsulated_textual_esg_xml_fragment *esg_encapsulated_textual_esg_xml_fragment_decode(uint8_t *buffer, uint32_t size) {
+ struct esg_encapsulated_textual_esg_xml_fragment *esg_xml_fragment;
+ uint32_t pos;
+ uint32_t length;
+ uint8_t offset_pos;
+
+ if ((buffer == NULL) || (size <= 0)) {
+ return NULL;
+ }
+
+ pos = 0;
+
+ esg_xml_fragment = (struct esg_encapsulated_textual_esg_xml_fragment *) malloc(sizeof(struct esg_encapsulated_textual_esg_xml_fragment));
+ memset(esg_xml_fragment, 0, sizeof(struct esg_encapsulated_textual_esg_xml_fragment));
+
+ offset_pos = vluimsbf8(buffer+pos+2, size-pos-2, &length);
+
+ if (size-pos-2 < offset_pos+length) {
+ esg_encapsulated_textual_esg_xml_fragment_free(esg_xml_fragment);
+ return NULL;
+ }
+
+ esg_xml_fragment->esg_xml_fragment_type = (buffer[pos] << 8) | buffer[pos+1];
+ pos += 2+offset_pos;
+
+ esg_xml_fragment->data_length = length;
+ esg_xml_fragment->data = (uint8_t *) malloc(length);
+ memcpy(esg_xml_fragment->data, buffer+pos, length);
+ pos += length;
+
+ return esg_xml_fragment;
+}
+
+void esg_encapsulated_textual_esg_xml_fragment_free(struct esg_encapsulated_textual_esg_xml_fragment *esg_xml_fragment) {
+ if (esg_xml_fragment == NULL) {
+ return;
+ }
+
+ if (esg_xml_fragment->data) {
+ free(esg_xml_fragment->data);
+ }
+
+ free(esg_xml_fragment);
+}
diff --git a/lib/libesg/representation/encapsulated_textual_esg_xml_fragment.h b/lib/libesg/representation/encapsulated_textual_esg_xml_fragment.h
new file mode 100644
index 0000000..ee8aba1
--- /dev/null
+++ b/lib/libesg/representation/encapsulated_textual_esg_xml_fragment.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_REPRESENTATION_ENCAPSULATED_TEXTUAL_ESG_XML_FRAGMENT_H
+#define _ESG_REPRESENTATION_ENCAPSULATED_TEXTUAL_ESG_XML_FRAGMENT_H 1
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <stdint.h>
+
+/**
+ * esg_encapsulated_textual_esg_xml_fragment structure.
+ */
+struct esg_encapsulated_textual_esg_xml_fragment {
+ uint16_t esg_xml_fragment_type;
+ uint32_t data_length;
+ uint8_t *data;
+};
+
+/**
+ * Process an esg_encapsulated_textual_esg_xml_fragment.
+ *
+ * @param buffer Binary buffer to decode.
+ * @param size Binary buffer size.
+ * @return Pointer to an esg_encapsulated_textual_esg_xml_fragment structure, or NULL on error.
+ */
+extern struct esg_encapsulated_textual_esg_xml_fragment *esg_encapsulated_textual_esg_xml_fragment_decode(uint8_t *buffer, uint32_t size);
+
+/**
+ * Free an esg_encapsulated_textual_esg_xml_fragment.
+ *
+ * @param data_repository Pointer to an esg_encapsulated_textual_esg_xml_fragment structure.
+ */
+extern void esg_encapsulated_textual_esg_xml_fragment_free(struct esg_encapsulated_textual_esg_xml_fragment *esg_xml_fragment);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/libesg/representation/init_message.c b/lib/libesg/representation/init_message.c
new file mode 100644
index 0000000..0038607
--- /dev/null
+++ b/lib/libesg/representation/init_message.c
@@ -0,0 +1,112 @@
+/*
+ * 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 <stdlib.h>
+#include <string.h>
+
+#include <libesg/representation/init_message.h>
+#include <libesg/representation/textual_decoder_init.h>
+#include <libesg/representation/bim_decoder_init.h>
+
+struct esg_init_message *esg_init_message_decode(uint8_t *buffer, uint32_t size) {
+ uint32_t pos;
+ struct esg_init_message *init_message;
+
+ if ((buffer == NULL) || (size <= 3)) {
+ return NULL;
+ }
+
+ pos = 0;
+
+ init_message = (struct esg_init_message *) malloc(sizeof(struct esg_init_message));
+ memset(init_message, 0, sizeof(struct esg_init_message));
+
+ init_message->encoding_version = buffer[pos];
+ pos += 1;
+
+ init_message->indexing_flag = (buffer[pos] & 0x80) >> 7;
+ pos += 1;
+
+ init_message->decoder_init_ptr = buffer[pos];
+ pos += 1;
+
+ if (init_message->indexing_flag) {
+ init_message->indexing_version = buffer[pos];
+ pos += 1;
+ }
+
+ switch (init_message->encoding_version) {
+ case 0xF1: {
+ struct esg_bim_encoding_parameters *encoding_parameters = (struct esg_bim_encoding_parameters *) malloc(sizeof(struct esg_bim_encoding_parameters));
+ memset(encoding_parameters, 0, sizeof(struct esg_bim_encoding_parameters));
+ init_message->encoding_parameters = (void *) encoding_parameters;
+
+ encoding_parameters->buffer_size_flag = (buffer[pos] & 0x80) >> 7;
+ encoding_parameters->position_code_flag = (buffer[pos] & 0x40) >> 6;
+ pos += 1;
+
+ encoding_parameters->character_encoding = buffer[pos];
+ pos += 1;
+
+ if (encoding_parameters->buffer_size_flag) {
+ encoding_parameters->buffer_size = (buffer[pos] << 16) | (buffer[pos+1] << 8) | buffer[pos+2];
+ pos += 3;
+ }
+
+// TODO
+// init_message->decoder_init = (void *) esg_bim_decoder_init_decode(buffer + init_message->decoder_init_ptr, size - init_message->decoder_init_ptr);
+ break;
+ }
+ case 0xF2:
+ case 0xF3: {
+ struct esg_textual_encoding_parameters *encoding_parameters = (struct esg_textual_encoding_parameters *) malloc(sizeof(struct esg_textual_encoding_parameters));
+ memset(encoding_parameters, 0, sizeof(struct esg_textual_encoding_parameters));
+ init_message->encoding_parameters = (void *) encoding_parameters;
+
+ encoding_parameters->character_encoding = buffer[pos];
+ pos += 1;
+
+ init_message->decoder_init = (void *) esg_textual_decoder_init_decode(buffer + init_message->decoder_init_ptr, size - init_message->decoder_init_ptr);
+ break;
+ }
+ default: {
+ esg_init_message_free(init_message);
+ return NULL;
+ }
+ }
+
+ return init_message;
+}
+
+void esg_init_message_free(struct esg_init_message *init_message) {
+ if (init_message == NULL) {
+ return;
+ }
+
+ if (init_message->encoding_parameters) {
+ free(init_message->encoding_parameters);
+ }
+
+ if (init_message->decoder_init) {
+ free(init_message->decoder_init);
+ }
+
+ free(init_message);
+}
diff --git a/lib/libesg/representation/init_message.h b/lib/libesg/representation/init_message.h
new file mode 100644
index 0000000..a525495
--- /dev/null
+++ b/lib/libesg/representation/init_message.h
@@ -0,0 +1,80 @@
+/*
+ * 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_REPRESENTATION_INIT_MESSAGE_H
+#define _ESG_REPRESENTATION_INIT_MESSAGE_H 1
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <stdint.h>
+
+/**
+ * esg_textual_encoding_parameters structure.
+ */
+struct esg_textual_encoding_parameters {
+ uint8_t character_encoding;
+};
+
+/**
+ * esg_bim_encoding_parameters structure.
+ */
+struct esg_bim_encoding_parameters {
+ uint8_t buffer_size_flag;
+ uint8_t position_code_flag;
+ uint8_t character_encoding;
+ uint32_t buffer_size; // if buffer_size_flag
+};
+
+/**
+ * esg_init_message structure.
+ */
+struct esg_init_message {
+ uint8_t encoding_version;
+ uint8_t indexing_flag;
+ uint8_t decoder_init_ptr;
+ uint8_t indexing_version; // if indexing_flag
+ void *encoding_parameters;
+ void *decoder_init;
+};
+
+/**
+ * Process an esg_init_message.
+ *
+ * @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_init_message *esg_init_message_decode(uint8_t *buffer, uint32_t size);
+
+/**
+ * Free an esg_init_message.
+ *
+ * @param init_message Pointer to an esg_init_message structure.
+ */
+extern void esg_init_message_free(struct esg_init_message *init_message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/lib/libesg/representation/textual_decoder_init.c b/lib/libesg/representation/textual_decoder_init.c
new file mode 100644
index 0000000..c797d0e
--- /dev/null
+++ b/lib/libesg/representation/textual_decoder_init.c
@@ -0,0 +1,128 @@
+/*
+ * 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 <stdlib.h>
+#include <string.h>
+
+#include <libesg/types.h>
+#include <libesg/representation/textual_decoder_init.h>
+
+struct esg_textual_decoder_init *esg_textual_decoder_init_decode(uint8_t *buffer, uint32_t size) {
+ uint32_t pos;
+ struct esg_textual_decoder_init *decoder_init;
+ struct esg_namespace_prefix *namespace_prefix;
+ struct esg_namespace_prefix *last_namespace_prefix;
+ struct esg_xml_fragment_type *xml_fragment_type;
+ struct esg_xml_fragment_type *last_xml_fragment_type;
+ uint32_t decoder_init_length;
+ uint8_t num_index;
+
+ if ((buffer == NULL) || (size <= 1)) {
+ return NULL;
+ }
+
+ pos = 0;
+
+ decoder_init = (struct esg_textual_decoder_init *) malloc(sizeof(struct esg_textual_decoder_init));
+ memset(decoder_init, 0, sizeof(struct esg_textual_decoder_init));
+ decoder_init->namespace_prefix_list = NULL;
+ decoder_init->xml_fragment_type_list = NULL;
+
+ decoder_init->version = buffer[pos];
+ pos += 1;
+
+ pos += vluimsbf8(buffer+pos, size-pos, &decoder_init_length);
+
+ if (size < pos + decoder_init_length) {
+ esg_textual_decoder_init_free(decoder_init);
+ return NULL;
+ }
+
+ decoder_init->num_namespace_prefixes = buffer[pos];
+ pos += 1;
+
+ last_namespace_prefix = NULL;
+ for (num_index = 0; num_index < decoder_init->num_namespace_prefixes; num_index++) {
+ namespace_prefix = (struct esg_namespace_prefix *) malloc(sizeof(struct esg_namespace_prefix));
+ memset(namespace_prefix, 0, sizeof(struct esg_namespace_prefix));
+ namespace_prefix->_next = NULL;
+
+ if (last_namespace_prefix == NULL) {
+ decoder_init->namespace_prefix_list = namespace_prefix;
+ } else {
+ last_namespace_prefix->_next = namespace_prefix;
+ }
+ last_namespace_prefix = namespace_prefix;
+
+ namespace_prefix->prefix_string_ptr = (buffer[pos] << 8) | buffer[pos+1];
+ pos += 2;
+
+ namespace_prefix->namespace_uri_ptr = (buffer[pos] << 8) | buffer[pos+1];
+ pos += 2;
+ }
+
+ decoder_init->num_fragment_types = buffer[pos];
+ pos += 1;
+
+ last_xml_fragment_type = NULL;
+ for (num_index = 0; num_index < decoder_init->num_fragment_types; num_index++) {
+ xml_fragment_type = (struct esg_xml_fragment_type *) malloc(sizeof(struct esg_xml_fragment_type));
+ memset(xml_fragment_type, 0, sizeof(struct esg_xml_fragment_type));
+ xml_fragment_type->_next = NULL;
+
+ if (last_xml_fragment_type == NULL) {
+ decoder_init->xml_fragment_type_list = xml_fragment_type;
+ } else {
+ last_xml_fragment_type->_next = xml_fragment_type;
+ }
+ last_xml_fragment_type = xml_fragment_type;
+
+ xml_fragment_type->xpath_ptr = (buffer[pos] << 8) | buffer[pos+1];
+ pos += 2;
+
+ xml_fragment_type->xml_fragment_type = (buffer[pos] << 8) | buffer[pos+1];
+ pos += 2;
+ }
+
+ return decoder_init;
+}
+
+void esg_textual_decoder_init_free(struct esg_textual_decoder_init *decoder_init) {
+ struct esg_namespace_prefix *namespace_prefix;
+ struct esg_namespace_prefix *next_namespace_prefix;
+ struct esg_xml_fragment_type *xml_fragment_type;
+ struct esg_xml_fragment_type *next_xml_fragment_type;
+
+ if (decoder_init == NULL) {
+ return;
+ }
+
+ for(namespace_prefix = decoder_init->namespace_prefix_list; namespace_prefix; namespace_prefix = next_namespace_prefix) {
+ next_namespace_prefix = namespace_prefix->_next;
+ free(namespace_prefix);
+ }
+
+ for(xml_fragment_type = decoder_init->xml_fragment_type_list; xml_fragment_type; xml_fragment_type = next_xml_fragment_type) {
+ next_xml_fragment_type = xml_fragment_type->_next;
+ free(xml_fragment_type);
+ }
+
+ free(decoder_init);
+}
diff --git a/lib/libesg/representation/textual_decoder_init.h b/lib/libesg/representation/textual_decoder_init.h
new file mode 100644
index 0000000..c1352cc
--- /dev/null
+++ b/lib/libesg/representation/textual_decoder_init.h
@@ -0,0 +1,104 @@
+/*
+ * 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_REPRESENTATION_TEXTUAL_DECODER_INIT_H
+#define _ESG_REPRESENTATION_TEXTUAL_DECODER_INIT_H 1
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <stdint.h>
+
+/**
+ * esg_namespace_prefix structure.
+ */
+struct esg_namespace_prefix {
+ uint16_t prefix_string_ptr;
+ uint16_t namespace_uri_ptr;
+
+ struct esg_namespace_prefix *_next;
+};
+
+/**
+ * esg_fragment_type structure.
+ */
+struct esg_xml_fragment_type {
+ uint16_t xpath_ptr;
+ uint16_t xml_fragment_type;
+
+ struct esg_xml_fragment_type *_next;
+};
+
+/**
+ * esg_textual_decoder_init structure.
+ */
+struct esg_textual_decoder_init {
+ uint8_t version;
+ uint8_t num_namespace_prefixes;
+ struct esg_namespace_prefix *namespace_prefix_list;
+ uint8_t num_fragment_types;
+ struct esg_xml_fragment_type *xml_fragment_type_list;
+};
+
+/**
+ * Process an esg_textual_decoder_init.
+ *
+ * @param buffer Binary buffer to decode.
+ * @param size Binary buffer size.
+ * @return Pointer to an esg_textual_decoder_init structure, or NULL on error.
+ */
+extern struct esg_textual_decoder_init *esg_textual_decoder_init_decode(uint8_t *buffer, uint32_t size);
+
+/**
+ * Free an esg_textual_decoder_init.
+ *
+ * @param decoder_init Pointer to an esg_textual_decoder_init structure.
+ */
+extern void esg_textual_decoder_init_free(struct esg_textual_decoder_init *decoder_init);
+
+/**
+ * Convenience iterator for namespace_prefix_list field of an esg_textual_decoder_init.
+ *
+ * @param decoder_init The esg_textual_decoder_init pointer.
+ * @param namespace_prefix Variable holding a pointer to the current esg_namespace_prefix.
+ */
+#define esg_textual_decoder_namespace_prefix_list_for_each(decoder_init, namespace_prefix) \
+ for ((namespace_prefix) = (decoder_init)->namespace_prefix_list; \
+ (namespace_prefix); \
+ (namespace_prefix) = (namespace_prefix)->_next)
+
+/**
+ * Convenience iterator for xml_fragment_type_list field of an esg_textual_decoder_init.
+ *
+ * @param decoder_init The esg_textual_decoder_init pointer.
+ * @param xml_fragment_type Variable holding a pointer to the current esg_xml_fragment_type.
+ */
+#define esg_textual_decoder_xml_fragment_type_list_for_each(decoder_init, xml_fragment_type) \
+ for ((xml_fragment_type) = (decoder_init)->xml_fragment_type_list; \
+ (xml_fragment_type); \
+ (xml_fragment_type) = (xml_fragment_type)->_next)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif