1 #define _XOPEN_SOURCE 500
11 int main(int argc
, char **argv
) {
12 struct isds_ctx
*ctx
= NULL
;
15 setlocale(LC_ALL
, "");
19 printf("isds_init() failed: %s\n", isds_strerror(err
));
23 isds_set_logging(ILF_ALL
& ~ILF_HTTP
, ILL_ALL
);
25 ctx
= isds_ctx_create();
27 printf("isds_ctx_create() failed");
30 err
= isds_set_timeout(ctx
, 10000);
32 printf("isds_set_timeout() failed: %s\n", isds_strerror(err
));
35 /* err = isds_set_tls(ctx, ITLS_VERIFY_SERVER, 0);
37 printf("isds_set_tls(ITLS_VERIFY_SERVER) failed: %s\n",
41 err = isds_set_tls(ctx, ITLS_CA_FILE, "/etc/ssl/certs/ca-certificates.crt");
43 printf("isds_set_tls(ITLS_CA_FILE) failed: %s\n",
47 err
= isds_login(ctx
, url
, username
, password
, NULL
, NULL
);
49 printf("isds_login() failed: %s: %s\n", isds_strerror(err
),
50 isds_long_message(ctx
));
52 printf("Logged in :)\n");
57 /* Get list of sent messages */
59 struct tm from_time_tm
= {
60 .tm_year
= 2000 - 1900,
68 time_t from_time_t
= mktime(&from_time_tm
);
69 struct timeval from_time
= {
70 .tv_sec
= from_time_t
,
73 unsigned long int number
= 0;
74 struct isds_list
*messages
= NULL
, *item
;
76 /* TODO: Try different criteria */
77 printf("Getting list of sent messages\n");
78 err
= isds_get_list_of_sent_messages(ctx
, &from_time
, NULL
, NULL
,
79 MESSAGESTATE_ANY
, 0, &number
, &messages
);
81 printf("isds_get_list_of_sent_messages() failed: %s: %s\n",
82 isds_strerror(err
), isds_long_message(ctx
));
84 printf("isds_get_list_of_sent_messages() succeeded: "
85 "number of messages = %lu:\n", number
);
86 for(item
= messages
; item
; item
= item
->next
) {
87 printf("List item:\n");
88 print_message(item
->data
);
92 isds_list_free(&messages
);
96 err
= isds_logout(ctx
);
98 printf("isds_logout() failed: %s\n", isds_strerror(err
));
102 err
= isds_ctx_free(&ctx
);
104 printf("isds_ctx_free() failed: %s\n", isds_strerror(err
));
108 err
= isds_cleanup();
110 printf("isds_cleanup() failed: %s\n", isds_strerror(err
));