doc: Update maximum message size
[libisds.git] / client / loadsentmessagewithxmldocuments.c
blobe834759fb1181b55a62f13cc6b017bf6f5ec2d2d
1 #define _XOPEN_SOURCE 500
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <locale.h>
5 #include <time.h>
6 #include <string.h>
7 #include <isds.h>
8 #include <libxml/debugXML.h>
9 #include "common.h"
12 int main(void) {
13 struct isds_ctx *ctx = NULL;
14 isds_error err;
16 setlocale(LC_ALL, "");
18 err = isds_init();
19 if (err) {
20 printf("isds_init() failed: %s\n", isds_strerror(err));
21 exit(EXIT_FAILURE);
24 isds_set_logging(ILF_ALL & ~ILF_HTTP, ILL_ALL);
26 ctx = isds_ctx_create();
27 if (!ctx) {
28 printf("isds_ctx_create() failed");
33 /* Load plain signed sent message with XML documents */
34 struct isds_message *message = NULL;
35 void *buffer;
36 int fd;
37 size_t length;
39 if (mmap_file(SRCDIR
40 "/server/messages/signed_sent_xml_message-376701.xml",
41 &fd, &buffer, &length)) {
42 fprintf(stderr, "Could not map file with message");
43 isds_ctx_free(&ctx);
44 isds_cleanup();
45 exit(EXIT_FAILURE);
48 printf("Loading plain signed sent message\n");
49 err = isds_load_message(ctx, RAWTYPE_PLAIN_SIGNED_OUTGOING_MESSAGE,
50 buffer, length, &message, BUFFER_DONT_STORE);
51 if (err)
52 printf("isds_load_message() failed: %s: %s\n",
53 isds_strerror(err), isds_long_message(ctx));
54 else {
55 printf("isds_load_message() succeeded:\n");
56 print_message(message);
58 /* Dump XML documents */
59 int i = 1;
60 for (struct isds_list *item = message->documents; item;
61 item = item->next, i++) {
62 if (item->data) {
63 struct isds_document *document =
64 (struct isds_document *)item->data;
65 if (document->is_xml) {
66 printf("* XML Document #%d dump:\n", i);
67 xmlDebugDumpNodeList(stdout,
68 document->xml_node_list, 2);
74 isds_message_free(&message);
75 munmap_file(fd, buffer, length);
79 err = isds_ctx_free(&ctx);
80 if (err) {
81 printf("isds_ctx_free() failed: %s\n", isds_strerror(err));
84 err = isds_cleanup();
85 if (err) {
86 printf("isds_cleanup() failed: %s\n", isds_strerror(err));
89 exit (EXIT_SUCCESS);