test: guess_raw_type: unsigned delivery info
[libisds.git] / client / getsignedsentbyid.c
blob14c75d9318954960553f0bad1780fde8438c6b9e
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;
14 char *last_message_id = NULL;
16 setlocale(LC_ALL, "");
18 if (argc < 2) {
19 fprintf(stderr, "Usage: program SENT_MESSAGE_ID\n");
20 exit(EXIT_FAILURE);
23 err = isds_init();
24 if (err) {
25 printf("isds_init() failed: %s\n", isds_strerror(err));
26 exit(EXIT_FAILURE);
29 isds_set_logging(ILF_ALL & ~ILF_HTTP, ILL_ALL);
31 ctx = isds_ctx_create();
32 if (!ctx) {
33 printf("isds_ctx_create() failed");
36 err = isds_set_timeout(ctx, 10000);
37 if (err) {
38 printf("isds_set_timeout() failed: %s\n", isds_strerror(err));
41 /* err = isds_set_tls(ctx, ITLS_VERIFY_SERVER, 0);
42 if (err) {
43 printf("isds_set_tls(ITLS_VERIFY_SERVER) failed: %s\n",
44 isds_strerror(err));
47 err = isds_set_tls(ctx, ITLS_CA_FILE, "/etc/ssl/certs/ca-certificates.crt");
48 if (err) {
49 printf("isds_set_tls(ITLS_CA_FILE) failed: %s\n",
50 isds_strerror(err));
51 }*/
53 err = isds_login(ctx, url, username, password, NULL);
54 if (err) {
55 printf("isds_login() failed: %s: %s\n", isds_strerror(err),
56 isds_long_message(ctx));
57 } else {
58 printf("Logged in :)\n");
64 /* Download signed message selected by message ID */
65 if (argv[1]) {
66 struct isds_message *message = NULL;
68 printf("Getting signed sent message with ID: %s\n",
69 argv[1]);
70 err = isds_get_signed_sent_message(ctx, argv[1], &message);
71 if (err)
72 printf("isds_get_signed_sent_message() failed: %s: %s\n",
73 isds_strerror(err), isds_long_message(ctx));
74 else {
75 printf("isds_get_signed_sent_message() succeeded:\n");
76 print_message(message);
77 save_data("Saving signed message",
78 message->raw, message->raw_length);
81 isds_message_free(&message);
82 free(last_message_id);
87 err = isds_logout(ctx);
88 if (err) {
89 printf("isds_logout() failed: %s\n", isds_strerror(err));
93 err = isds_ctx_free(&ctx);
94 if (err) {
95 printf("isds_ctx_free() failed: %s\n", isds_strerror(err));
99 err = isds_cleanup();
100 if (err) {
101 printf("isds_cleanup() failed: %s\n", isds_strerror(err));
104 exit (EXIT_SUCCESS);