Export isds_PersonName_free(), isds_BirthInfo_free(), isds_Address_free()
[libisds.git] / client / loadreceivedmessage.c
blob803fd9c85a6ee42f2c6e9e6ccb4acc84eebbd9c1
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 "common.h"
11 int main(int argc, char **argv) {
12 struct isds_ctx *ctx = NULL;
13 isds_error err;
15 setlocale(LC_ALL, "");
17 err = isds_init();
18 if (err) {
19 printf("isds_init() failed: %s\n", isds_strerror(err));
20 exit(EXIT_FAILURE);
23 isds_set_logging(ILF_ALL & ~ILF_HTTP, ILL_ALL);
25 ctx = isds_ctx_create();
26 if (!ctx) {
27 printf("isds_ctx_create() failed");
32 #if 0
34 /* Load signed delivery info */
35 struct isds_message *message = NULL;
36 void *buffer;
37 int fd;
38 size_t length;
40 if (mmap_file(SRCDIR "/server/messages/signed_delivered-DD_170272.zfo",
41 &fd, &buffer, &length)) {
42 fprintf(stderr, "Could not open map file with signed delivery info\n");
43 isds_ctx_free(&ctx);
44 isds_cleanup();
45 exit(EXIT_FAILURE);
48 printf("Loading signed delivery info\n");
49 err = isds_load_signed_delivery_info(ctx, buffer, length,
50 &message, BUFFER_DONT_STORE);
51 if (err)
52 printf("isds_load_signed_delivery_info() failed: %s: %s\n",
53 isds_strerror(err), isds_long_message(ctx));
54 else {
55 printf("isds_load_signed_delivery_info() succeeded:\n");
56 print_envelope(message->envelope);
59 isds_message_free(&message);
60 munmap_file(fd, buffer, length);
62 #endif
66 /* Load plain received message */
67 struct isds_message *message = NULL;
68 void *buffer;
69 int fd;
70 size_t length;
72 if (mmap_file(SRCDIR "/server/messages/received_message-151916.xml",
73 &fd, &buffer, &length)) {
74 fprintf(stderr, "Could not map file with message");
75 isds_ctx_free(&ctx);
76 isds_cleanup();
77 exit(EXIT_FAILURE);
80 printf("Loading plain received message\n");
81 err = isds_load_message(ctx, RAWTYPE_INCOMING_MESSAGE, buffer, length,
82 &message, BUFFER_DONT_STORE);
83 if (err)
84 printf("isds_load_message() failed: %s: %s\n",
85 isds_strerror(err), isds_long_message(ctx));
86 else {
87 printf("isds_load_message() succeeded:\n");
88 print_message(message);
91 isds_message_free(&message);
92 munmap_file(fd, buffer, length);
97 err = isds_ctx_free(&ctx);
98 if (err) {
99 printf("isds_ctx_free() failed: %s\n", isds_strerror(err));
103 err = isds_cleanup();
104 if (err) {
105 printf("isds_cleanup() failed: %s\n", isds_strerror(err));
108 exit (EXIT_SUCCESS);