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_login(ctx
, url
, username(), password(), NULL
, NULL
);
43 printf("isds_login() failed: %s: %s\n", isds_strerror(err
),
44 isds_long_message(ctx
));
46 printf("Logged in :)\n");
52 /* Download signed message selected by message ID */
54 struct isds_message
*message
= NULL
;
56 printf("Getting signed sent message with ID: %s\n",
58 err
= isds_get_signed_sent_message(ctx
, argv
[1], &message
);
60 printf("isds_get_signed_sent_message() failed: %s: %s\n",
61 isds_strerror(err
), isds_long_message(ctx
));
63 printf("isds_get_signed_sent_message() succeeded:\n");
64 print_message(message
);
65 save_data("Saving signed message",
66 message
->raw
, message
->raw_length
);
69 isds_message_free(&message
);
70 free(last_message_id
);
75 err
= isds_logout(ctx
);
77 printf("isds_logout() failed: %s\n", isds_strerror(err
));
81 err
= isds_ctx_free(&ctx
);
83 printf("isds_ctx_free() failed: %s\n", isds_strerror(err
));
89 printf("isds_cleanup() failed: %s\n", isds_strerror(err
));