testesg.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. /*
  2. * ESG parser
  3. *
  4. * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr)
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  19. */
  20. #include <stdio.h>
  21. #include <unistd.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include <fcntl.h>
  25. #include <sys/stat.h>
  26. #include <libesg/bootstrap/access_descriptor.h>
  27. #include <libesg/encapsulation/container.h>
  28. #include <libesg/encapsulation/fragment_management_information.h>
  29. #include <libesg/encapsulation/data_repository.h>
  30. #include <libesg/encapsulation/string_repository.h>
  31. #include <libesg/representation/encapsulated_textual_esg_xml_fragment.h>
  32. #include <libesg/representation/init_message.h>
  33. #include <libesg/representation/textual_decoder_init.h>
  34. #include <libesg/representation/bim_decoder_init.h>
  35. #include <libesg/transport/session_partition_declaration.h>
  36. #define MAX_FILENAME 256
  37. void usage(void) {
  38. static const char *_usage =
  39. "Usage: testesg [-a <ESGAccessDescriptor>]\n"
  40. " [-c <ESGContainer with Textual ESG XML Fragment>]\n"
  41. " [-X XXXX]\n";
  42. fprintf(stderr, "%s", _usage);
  43. exit(1);
  44. }
  45. void read_from_file(const char *filename, char **buffer, int *size) {
  46. int fd;
  47. struct stat fs;
  48. if ((fd = open(filename, O_RDONLY)) <= 0) {
  49. fprintf(stderr, "File not found\n");
  50. exit(1);
  51. }
  52. if (fstat(fd, &fs) < 0) {
  53. fprintf(stderr, "File not readable\n");
  54. exit(1);
  55. }
  56. *size = fs.st_size;
  57. *buffer = (char *) malloc(*size);
  58. if (read(fd, *buffer, *size) != *size) {
  59. fprintf(stderr, "File read error\n");
  60. exit(1);
  61. }
  62. close(fd);
  63. return;
  64. }
  65. int main(int argc, char *argv[]) {
  66. char access_descriptor_filename[MAX_FILENAME] = "";
  67. char container_filename[MAX_FILENAME] = "";
  68. int c;
  69. char *buffer = NULL;
  70. int size;
  71. // Read command line options
  72. while ((c = getopt(argc, argv, "a:c:")) != -1) {
  73. switch (c) {
  74. case 'a':
  75. strncpy(access_descriptor_filename, optarg, MAX_FILENAME);
  76. break;
  77. case 'c':
  78. strncpy(container_filename, optarg, MAX_FILENAME);
  79. break;
  80. default:
  81. usage();
  82. }
  83. }
  84. // ESGAccessDescriptor
  85. if (strncmp(access_descriptor_filename, "", MAX_FILENAME) != 0) {
  86. fprintf(stdout, "**************************************************\n");
  87. fprintf(stdout, "Reading ESG Access Descriptor = %s\n", access_descriptor_filename);
  88. fprintf(stdout, "**************************************************\n\n");
  89. read_from_file(access_descriptor_filename, &buffer, &size);
  90. struct esg_access_descriptor *access_descriptor = esg_access_descriptor_decode((uint8_t *) buffer, size);
  91. free(buffer);
  92. if (access_descriptor == NULL) {
  93. fprintf(stderr, "ESG Access Descriptor decode error\n");
  94. exit(1);
  95. }
  96. fprintf(stdout, "n_o_ESGEntries %d\n\n", access_descriptor->n_o_entries);
  97. struct esg_entry *entry;
  98. esg_access_descriptor_entry_list_for_each(access_descriptor, entry) {
  99. fprintf(stdout, " ESGEntryVersion %d\n", entry->version);
  100. fprintf(stdout, " MultipleStreamTransport %d\n", entry->multiple_stream_transport);
  101. fprintf(stdout, " IPVersion6 %d\n", entry->ip_version_6);
  102. fprintf(stdout, " ProviderID %d\n", entry->provider_id);
  103. if (entry->ip_version_6 == 0) {
  104. fprintf(stdout, " SourceIPAddress %d.%d.%d.%d\n",
  105. entry->source_ip.ipv4[0],
  106. entry->source_ip.ipv4[1],
  107. entry->source_ip.ipv4[2],
  108. entry->source_ip.ipv4[3]);
  109. fprintf(stdout, " DestinationIPAddress %d.%d.%d.%d\n",
  110. entry->destination_ip.ipv4[0],
  111. entry->destination_ip.ipv4[1],
  112. entry->destination_ip.ipv4[2],
  113. entry->destination_ip.ipv4[3]);
  114. } else if (entry->ip_version_6 == 1) {
  115. fprintf(stdout, " SourceIPAddress %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
  116. entry->source_ip.ipv6[0],
  117. entry->source_ip.ipv6[1],
  118. entry->source_ip.ipv6[2],
  119. entry->source_ip.ipv6[3],
  120. entry->source_ip.ipv6[4],
  121. entry->source_ip.ipv6[5],
  122. entry->source_ip.ipv6[6],
  123. entry->source_ip.ipv6[7],
  124. entry->source_ip.ipv6[8],
  125. entry->source_ip.ipv6[9],
  126. entry->source_ip.ipv6[10],
  127. entry->source_ip.ipv6[11],
  128. entry->source_ip.ipv6[12],
  129. entry->source_ip.ipv6[13],
  130. entry->source_ip.ipv6[14],
  131. entry->source_ip.ipv6[15]);
  132. fprintf(stdout, " DestinationIPAddress %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
  133. entry->destination_ip.ipv6[0],
  134. entry->destination_ip.ipv6[1],
  135. entry->destination_ip.ipv6[2],
  136. entry->destination_ip.ipv6[3],
  137. entry->destination_ip.ipv6[4],
  138. entry->destination_ip.ipv6[5],
  139. entry->destination_ip.ipv6[6],
  140. entry->destination_ip.ipv6[7],
  141. entry->destination_ip.ipv6[8],
  142. entry->destination_ip.ipv6[9],
  143. entry->destination_ip.ipv6[10],
  144. entry->destination_ip.ipv6[11],
  145. entry->destination_ip.ipv6[12],
  146. entry->destination_ip.ipv6[13],
  147. entry->destination_ip.ipv6[14],
  148. entry->destination_ip.ipv6[15]);
  149. }
  150. fprintf(stdout, "Port %d\n", entry->port);
  151. fprintf(stdout, "TSI %d\n", entry->tsi);
  152. fprintf(stdout, "\n");
  153. }
  154. }
  155. // ESGContainer
  156. if (strncmp(container_filename, "", MAX_FILENAME) != 0) {
  157. fprintf(stdout, "**************************************************\n");
  158. fprintf(stdout, "Reading ESG Container = %s\n", container_filename);
  159. fprintf(stdout, "**************************************************\n\n");
  160. read_from_file(container_filename, &buffer, &size);
  161. struct esg_container *container = esg_container_decode((uint8_t *) buffer, size);
  162. free(buffer);
  163. if (container == NULL) {
  164. fprintf(stderr, "ESG Container decode error\n");
  165. exit(1);
  166. }
  167. if (container->header == NULL) {
  168. fprintf(stderr, "ESG Container no header found\n");
  169. exit(1);
  170. }
  171. struct esg_encapsulation_structure *fragment_management_information = NULL;
  172. struct esg_data_repository *data_repository = NULL;
  173. struct esg_string_repository *string_repository = NULL;
  174. struct esg_container_structure *structure = NULL;
  175. struct esg_init_message *init_message = NULL;
  176. struct esg_textual_encoding_parameters *textual_encoding_parameters = NULL;
  177. struct esg_textual_decoder_init *textual_decoder_init = NULL;
  178. struct esg_namespace_prefix *namespace_prefix = NULL;
  179. struct esg_xml_fragment_type *xml_fragment_type = NULL;
  180. struct esg_bim_encoding_parameters *bim_encoding_parameters = NULL;
  181. // struct esg_bim_decoder_init *bim_decoder_init = NULL;
  182. struct esg_session_partition_declaration *partition = NULL;
  183. struct esg_session_field *field = NULL;
  184. struct esg_session_ip_stream *ip_stream = NULL;
  185. struct esg_session_ip_stream_field *ip_stream_field = NULL;
  186. esg_container_header_structure_list_for_each(container->header, structure) {
  187. fprintf(stdout, " structure_type %d [0x%02x]\n", structure->type, structure->type);
  188. fprintf(stdout, " structure_id %d [0x%02x]\n", structure->id, structure->id);
  189. fprintf(stdout, " structure_ptr %d\n", structure->ptr);
  190. fprintf(stdout, " structure_length %d\n\n", structure->length);
  191. switch (structure->type) {
  192. case 0x01: {
  193. switch (structure->id) {
  194. case 0x00: {
  195. fprintf(stdout, " ESG Fragment Management Information\n");
  196. fragment_management_information = (struct esg_encapsulation_structure *) structure->data;
  197. if (fragment_management_information == NULL) {
  198. fprintf(stderr, "ESG Fragment Management Information decode error\n");
  199. exit(1);
  200. }
  201. fprintf(stdout, " fragment_reference_format %d [0x%02x]\n\n", fragment_management_information->header->fragment_reference_format, fragment_management_information->header->fragment_reference_format);
  202. struct esg_encapsulation_entry *entry;
  203. esg_encapsulation_structure_entry_list_for_each(fragment_management_information, entry) {
  204. fprintf(stdout, " fragment_type %d [0x%02x]\n", entry->fragment_reference->fragment_type, entry->fragment_reference->fragment_type);
  205. fprintf(stdout, " data_repository_offset %d\n", entry->fragment_reference->data_repository_offset);
  206. fprintf(stdout, " fragment_version %d\n", entry->fragment_version);
  207. fprintf(stdout, " fragment_id %d\n\n", entry->fragment_id);
  208. }
  209. break;
  210. }
  211. default: {
  212. fprintf(stdout, " Unknown structure_id\n");
  213. }
  214. }
  215. break;
  216. }
  217. case 0x02: {
  218. switch (structure->id) {
  219. case 0x00: {
  220. fprintf(stdout, " ESG String Repository / ");
  221. string_repository = (struct esg_string_repository *) structure->data;
  222. if (string_repository == NULL) {
  223. fprintf(stderr, "ESG String Repository decode error\n");
  224. exit(1);
  225. }
  226. fprintf(stdout, "encoding_type %d / length %d\n\n", string_repository->encoding_type, string_repository->length);
  227. break;
  228. }
  229. default: {
  230. fprintf(stdout, " Unknown structure_id\n");
  231. }
  232. }
  233. break;
  234. }
  235. case 0x03: {
  236. //TODO
  237. break;
  238. }
  239. case 0x04: {
  240. //TODO
  241. break;
  242. }
  243. case 0x05: {
  244. //TODO
  245. break;
  246. }
  247. case 0xE0: {
  248. switch (structure->id) {
  249. case 0x00: {
  250. fprintf(stdout, " ESG Data Repository / ");
  251. data_repository = (struct esg_data_repository *) structure->data;
  252. if (data_repository == NULL) {
  253. fprintf(stderr, "ESG Data Repository decode error\n");
  254. exit(1);
  255. }
  256. fprintf(stdout, "length %d\n\n", data_repository->length);
  257. break;
  258. }
  259. default: {
  260. fprintf(stdout, " Unknown structure_id\n");
  261. }
  262. }
  263. break;
  264. }
  265. case 0xE1: {
  266. switch (structure->id) {
  267. case 0xFF: {
  268. fprintf(stdout, " ESG Session Partition Declaration\n");
  269. partition = (struct esg_session_partition_declaration *) structure->data;
  270. fprintf(stdout, " num_fields %d\n", partition->num_fields);
  271. fprintf(stdout, " overlapping %d\n\n", partition->overlapping);
  272. esg_session_partition_declaration_field_list_for_each(partition, field) {
  273. fprintf(stdout, " identifier %d\n", field->identifier);
  274. fprintf(stdout, " encoding %d\n",field->encoding);
  275. fprintf(stdout, " length %d\n\n",field->length);
  276. }
  277. fprintf(stdout, " n_o_IPStreams %d\n", partition->n_o_ip_streams);
  278. fprintf(stdout, " IPVersion6 %d\n\n", partition->ip_version_6);
  279. esg_session_partition_declaration_ip_stream_list_for_each(partition, ip_stream) {
  280. fprintf(stdout, " IPStreamID %d\n", ip_stream->id);
  281. if (partition->ip_version_6 == 0) {
  282. fprintf(stdout, " SourceIPAddress %d.%d.%d.%d\n",
  283. ip_stream->source_ip.ipv4[0],
  284. ip_stream->source_ip.ipv4[1],
  285. ip_stream->source_ip.ipv4[2],
  286. ip_stream->source_ip.ipv4[3]);
  287. fprintf(stdout, " DestinationIPAddress %d.%d.%d.%d\n",
  288. ip_stream->destination_ip.ipv4[0],
  289. ip_stream->destination_ip.ipv4[1],
  290. ip_stream->destination_ip.ipv4[2],
  291. ip_stream->destination_ip.ipv4[3]);
  292. } else if (partition->ip_version_6 == 1) {
  293. fprintf(stdout, " SourceIPAddress %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
  294. ip_stream->source_ip.ipv6[0],
  295. ip_stream->source_ip.ipv6[1],
  296. ip_stream->source_ip.ipv6[2],
  297. ip_stream->source_ip.ipv6[3],
  298. ip_stream->source_ip.ipv6[4],
  299. ip_stream->source_ip.ipv6[5],
  300. ip_stream->source_ip.ipv6[6],
  301. ip_stream->source_ip.ipv6[7],
  302. ip_stream->source_ip.ipv6[8],
  303. ip_stream->source_ip.ipv6[9],
  304. ip_stream->source_ip.ipv6[10],
  305. ip_stream->source_ip.ipv6[11],
  306. ip_stream->source_ip.ipv6[12],
  307. ip_stream->source_ip.ipv6[13],
  308. ip_stream->source_ip.ipv6[14],
  309. ip_stream->source_ip.ipv6[15]);
  310. fprintf(stdout, " DestinationIPAddress %02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x\n",
  311. ip_stream->destination_ip.ipv6[0],
  312. ip_stream->destination_ip.ipv6[1],
  313. ip_stream->destination_ip.ipv6[2],
  314. ip_stream->destination_ip.ipv6[3],
  315. ip_stream->destination_ip.ipv6[4],
  316. ip_stream->destination_ip.ipv6[5],
  317. ip_stream->destination_ip.ipv6[6],
  318. ip_stream->destination_ip.ipv6[7],
  319. ip_stream->destination_ip.ipv6[8],
  320. ip_stream->destination_ip.ipv6[9],
  321. ip_stream->destination_ip.ipv6[10],
  322. ip_stream->destination_ip.ipv6[11],
  323. ip_stream->destination_ip.ipv6[12],
  324. ip_stream->destination_ip.ipv6[13],
  325. ip_stream->destination_ip.ipv6[14],
  326. ip_stream->destination_ip.ipv6[15]);
  327. }
  328. fprintf(stdout, " Port %d\n", ip_stream->port);
  329. fprintf(stdout, " SessionID %d\n", ip_stream->session_id);
  330. field = partition->field_list;
  331. esg_session_ip_stream_field_list_for_each(ip_stream, ip_stream_field) {
  332. switch (field->encoding) {
  333. case 0x0000: {
  334. if (ip_stream_field->start_field_value != NULL) {
  335. fprintf(stdout, " start_field_value %s\n", ip_stream_field->start_field_value->string);
  336. }
  337. fprintf(stdout, " end_field_value %s\n", ip_stream_field->end_field_value->string);
  338. break;
  339. }
  340. case 0x0101: {
  341. if (ip_stream_field->start_field_value != NULL) {
  342. fprintf(stdout, " start_field_value %d\n", ip_stream_field->start_field_value->unsigned_short);
  343. }
  344. fprintf(stdout, " end_field_value %d\n", ip_stream_field->end_field_value->unsigned_short);
  345. break;
  346. }
  347. }
  348. field = field->_next;
  349. }
  350. fprintf(stdout, "\n");
  351. }
  352. break;
  353. }
  354. default: {
  355. fprintf(stdout, " Unknown structure_id\n");
  356. }
  357. }
  358. break;
  359. }
  360. case 0xE2: {
  361. switch (structure->id) {
  362. case 0x00: {
  363. fprintf(stdout, " ESG Init Message\n");
  364. init_message = (struct esg_init_message *) structure->data;
  365. if (init_message == NULL) {
  366. fprintf(stderr, "ESG Init Message decode error\n");
  367. exit(1);
  368. }
  369. fprintf(stdout, " EncodingVersion %d [0x%02x]\n", init_message->encoding_version, init_message->encoding_version);
  370. fprintf(stdout, " IndexingFlag %d\n", init_message->indexing_flag);
  371. fprintf(stdout, " DecoderInitptr %d\n", init_message->decoder_init_ptr);
  372. if (init_message->indexing_flag) {
  373. fprintf(stdout, " IndexingVersion %d\n", init_message->indexing_version);
  374. }
  375. switch (init_message->encoding_version) {
  376. case 0xF1: {
  377. bim_encoding_parameters = (struct esg_bim_encoding_parameters *) init_message->encoding_parameters;
  378. if (bim_encoding_parameters == NULL) {
  379. fprintf(stderr, "ESG Init Message decode error / bim_encoding_parameters\n");
  380. exit(1);
  381. }
  382. fprintf(stdout, " BufferSizeFlag %d\n", bim_encoding_parameters->buffer_size_flag);
  383. fprintf(stdout, " PositionCodeFlag %d\n", bim_encoding_parameters->position_code_flag);
  384. fprintf(stdout, " CharacterEncoding %d\n", bim_encoding_parameters->character_encoding);
  385. if (bim_encoding_parameters->buffer_size_flag) {
  386. fprintf(stdout, " BufferSize %d\n", bim_encoding_parameters->buffer_size);
  387. }
  388. // TODO BimDecoderInit
  389. break;
  390. }
  391. case 0xF2:
  392. case 0xF3: {
  393. textual_encoding_parameters = (struct esg_textual_encoding_parameters *) init_message->encoding_parameters;
  394. if (textual_encoding_parameters == NULL) {
  395. fprintf(stderr, "ESG Init Message decode error / textual_encoding_parameters\n");
  396. exit(1);
  397. }
  398. fprintf(stdout, " CharacterEncoding %d\n\n", textual_encoding_parameters->character_encoding);
  399. // TextualDecoderInit
  400. textual_decoder_init = (struct esg_textual_decoder_init *) init_message->decoder_init;
  401. if (textual_decoder_init == NULL) {
  402. fprintf(stderr, "ESG Init Message decode error / textual_decoder_init\n");
  403. exit(1);
  404. }
  405. fprintf(stdout, " Textual DecoderInit\n");
  406. fprintf(stdout, " num_namespaces_prefixes %d\n\n", textual_decoder_init->num_namespace_prefixes);
  407. esg_textual_decoder_namespace_prefix_list_for_each(textual_decoder_init, namespace_prefix) {
  408. fprintf(stdout, " prefix_string_ptr %d\n", namespace_prefix->prefix_string_ptr);
  409. fprintf(stdout, " namespace_URI_ptr %d\n\n", namespace_prefix->namespace_uri_ptr);
  410. }
  411. fprintf(stdout, " num_fragment_types %d\n\n", textual_decoder_init->num_fragment_types);
  412. esg_textual_decoder_xml_fragment_type_list_for_each(textual_decoder_init, xml_fragment_type) {
  413. fprintf(stdout, " xpath_ptr %d\n", xml_fragment_type->xpath_ptr);
  414. fprintf(stdout, " ESG_XML_fragment_type %d\n\n", xml_fragment_type->xml_fragment_type);
  415. }
  416. break;
  417. }
  418. default: {
  419. fprintf(stdout, " Unknown EncodingVersion\n");
  420. }
  421. }
  422. break;
  423. }
  424. default: {
  425. fprintf(stdout, " Unknown structure_id\n");
  426. }
  427. }
  428. break;
  429. }
  430. default: {
  431. fprintf(stdout, " Unknown structure_type\n");
  432. }
  433. }
  434. }
  435. fprintf(stdout, "\n");
  436. fprintf(stdout, "structure_body_ptr %d\n", container->structure_body_ptr);
  437. fprintf(stdout, "structure_body_length %d\n\n", container->structure_body_length);
  438. // ESG XML Fragment
  439. if (fragment_management_information) {
  440. fprintf(stdout, "**************************************************\n");
  441. fprintf(stdout, "ESG XML Fragment\n");
  442. fprintf(stdout, "**************************************************\n\n");
  443. struct esg_encapsulation_entry *entry;
  444. esg_encapsulation_structure_entry_list_for_each(fragment_management_information, entry) {
  445. switch (entry->fragment_reference->fragment_type) {
  446. case 0x00: {
  447. if (data_repository) {
  448. struct esg_encapsulated_textual_esg_xml_fragment *esg_xml_fragment = esg_encapsulated_textual_esg_xml_fragment_decode(data_repository->data + entry->fragment_reference->data_repository_offset, data_repository->length);
  449. fprintf(stdout, "ESG_XML_fragment_type %d\n", esg_xml_fragment->esg_xml_fragment_type);
  450. fprintf(stdout, "data_length %d\n", esg_xml_fragment->data_length);
  451. fprintf(stdout, "fragment_version %d\n", entry->fragment_version);
  452. fprintf(stdout, "fragment_id %d\n\n", entry->fragment_id);
  453. char *string = (char *) malloc(esg_xml_fragment->data_length + 1);
  454. memcpy(string, esg_xml_fragment->data, esg_xml_fragment->data_length);
  455. string[esg_xml_fragment->data_length] = 0;
  456. fprintf(stdout, "%s\n", string);
  457. } else {
  458. fprintf(stderr, "ESG Data Repository not found");
  459. }
  460. break;
  461. }
  462. case 0x01: {
  463. // TODO
  464. break;
  465. }
  466. case 0x02: {
  467. // TODO
  468. break;
  469. }
  470. default: {
  471. }
  472. }
  473. }
  474. }
  475. // String
  476. if (init_message) {
  477. fprintf(stdout, "**************************************************\n");
  478. fprintf(stdout, "String\n");
  479. fprintf(stdout, "**************************************************\n\n");
  480. switch (init_message->encoding_version) {
  481. case 0xF1: {
  482. // TODO Bim
  483. break;
  484. }
  485. case 0xF2: {
  486. // TODO GZIP
  487. break;
  488. }
  489. case 0xF3: {
  490. // RAW
  491. if (string_repository) {
  492. textual_decoder_init = (struct esg_textual_decoder_init *) init_message->decoder_init;
  493. esg_textual_decoder_namespace_prefix_list_for_each(textual_decoder_init, namespace_prefix) {
  494. fprintf(stdout, "prefix_string_ptr %d\n", namespace_prefix->prefix_string_ptr);
  495. fprintf(stdout, "%s\n", string_repository->data + namespace_prefix->prefix_string_ptr);
  496. fprintf(stdout, "namespace_URI_ptr %d\n", namespace_prefix->namespace_uri_ptr);
  497. fprintf(stdout, "%s\n\n", string_repository->data + namespace_prefix->namespace_uri_ptr - 1); // TODO -1
  498. }
  499. esg_textual_decoder_xml_fragment_type_list_for_each(textual_decoder_init, xml_fragment_type) {
  500. fprintf(stdout, "xpath_ptr %d\n", xml_fragment_type->xpath_ptr);
  501. fprintf(stdout, "ESG_XML_fragment_type %d\n", xml_fragment_type->xml_fragment_type);
  502. fprintf(stdout, "%s\n\n", string_repository->data + xml_fragment_type->xpath_ptr - 1); // TODO -1
  503. }
  504. }
  505. break;
  506. }
  507. default: {
  508. fprintf(stdout, " Unknown EncodingVersion\n");
  509. }
  510. }
  511. }
  512. }
  513. return 0;
  514. }