1 #define _XOPEN_SOURCE 500
11 int main(int argc
, char **argv
) {
12 struct isds_ctx
*ctx
= NULL
;
14 char *last_message_id
= NULL
;
16 setlocale(LC_ALL
, "");
19 fprintf(stderr
, "Usage: program SENT_MESSAGE_ID\n");
25 printf("isds_init() failed: %s\n", isds_strerror(err
));
29 isds_set_logging(ILF_ALL
& ~ILF_HTTP
, ILL_ALL
);
31 ctx
= isds_ctx_create();
33 printf("isds_ctx_create() failed");
36 err
= isds_set_timeout(ctx
, 10000);
38 printf("isds_set_timeout() failed: %s\n", isds_strerror(err
));
41 /* err = isds_set_tls(ctx, ITLS_VERIFY_SERVER, 0);
43 printf("isds_set_tls(ITLS_VERIFY_SERVER) failed: %s\n",
47 err = isds_set_tls(ctx, ITLS_CA_FILE, "/etc/ssl/certs/ca-certificates.crt");
49 printf("isds_set_tls(ITLS_CA_FILE) failed: %s\n",
53 err
= isds_login(ctx
, url
, username
, password
, NULL
);
55 printf("isds_login() failed: %s: %s\n", isds_strerror(err
),
56 isds_long_message(ctx
));
58 printf("Logged in :)\n");
64 /* Download signed message selected by message ID */
66 struct isds_message
*message
= NULL
;
68 printf("Getting signed sent message with ID: %s\n",
70 err
= isds_get_signed_sent_message(ctx
, argv
[1], &message
);
72 printf("isds_get_signed_sent_message() failed: %s: %s\n",
73 isds_strerror(err
), isds_long_message(ctx
));
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
);
89 printf("isds_logout() failed: %s\n", isds_strerror(err
));
93 err
= isds_ctx_free(&ctx
);
95 printf("isds_ctx_free() failed: %s\n", isds_strerror(err
));
101 printf("isds_cleanup() failed: %s\n", isds_strerror(err
));