test: guess_raw_type: unsigned delivery info
[libisds.git] / client / loaddelivery.c
blobce03d8a98e591cc081cf158b6eef3488d6d2bad5
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");
33 /* Load signed delivery info */
34 struct isds_message *message = NULL;
35 void *buffer;
36 int fd;
37 size_t length;
39 if (mmap_file("../server/messages/signed_delivered-DD_170272.zfo",
40 &fd, &buffer, &length)) {
41 fprintf(stderr, "Could not open map file with signed delivery info\n");
42 isds_ctx_free(&ctx);
43 isds_cleanup();
44 exit(EXIT_FAILURE);
47 printf("Loading signed delivery info\n");
48 err = isds_load_delivery_info(ctx, RAWTYPE_CMS_SIGNED_DELIVERYINFO,
49 buffer, length, &message, BUFFER_DONT_STORE);
50 if (err)
51 printf("isds_load_delivery_info() failed: %s: %s\n",
52 isds_strerror(err), isds_long_message(ctx));
53 else {
54 printf("isds_load_delivery_info() succeeded:\n");
55 print_envelope(message->envelope);
58 isds_message_free(&message);
59 munmap_file(fd, buffer, length);
64 /* Load plain delivery info */
65 struct isds_message *message = NULL;
66 void *buffer;
67 int fd;
68 size_t length;
70 if (mmap_file("../server/messages/signed_delivered-DD_170272.xml",
71 &fd, &buffer, &length)) {
72 fprintf(stderr, "Could not map file with delivery info");
73 isds_ctx_free(&ctx);
74 isds_cleanup();
75 exit(EXIT_FAILURE);
78 printf("Loading plain signed delivery info\n");
79 err = isds_load_delivery_info(ctx, RAWTYPE_PLAIN_SIGNED_DELIVERYINFO,
80 buffer, length, &message, BUFFER_DONT_STORE);
81 if (err)
82 printf("isds_load_delivery_info() failed: %s: %s\n",
83 isds_strerror(err), isds_long_message(ctx));
84 else {
85 printf("isds_load_delivery_info() succeeded:\n");
86 print_envelope(message->envelope);
89 isds_message_free(&message);
90 munmap_file(fd, buffer, length);
95 err = isds_ctx_free(&ctx);
96 if (err) {
97 printf("isds_ctx_free() failed: %s\n", isds_strerror(err));
101 err = isds_cleanup();
102 if (err) {
103 printf("isds_cleanup() failed: %s\n", isds_strerror(err));
106 exit (EXIT_SUCCESS);