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_login(ctx
, url
, username(), password(), NULL
, NULL
);
37 printf("isds_login() failed: %s: %s\n", isds_strerror(err
),
38 isds_long_message(ctx
));
40 printf("Logged in :)\n");
45 /* Get list of sent messages */
47 struct tm from_time_tm
= {
48 .tm_year
= 2000 - 1900,
56 time_t from_time_t
= mktime(&from_time_tm
);
57 struct timeval from_time
= {
58 .tv_sec
= from_time_t
,
61 unsigned long int number
= 0;
62 struct isds_list
*messages
= NULL
, *item
;
64 /* TODO: Try different criteria */
65 printf("Getting list of sent messages\n");
66 err
= isds_get_list_of_sent_messages(ctx
, &from_time
, NULL
, NULL
,
67 MESSAGESTATE_ANY
, 0, &number
, &messages
);
69 printf("isds_get_list_of_sent_messages() failed: %s: %s\n",
70 isds_strerror(err
), isds_long_message(ctx
));
72 printf("isds_get_list_of_sent_messages() succeeded: "
73 "number of messages = %lu:\n", number
);
74 for(item
= messages
; item
; item
= item
->next
) {
75 printf("List item:\n");
76 print_message(item
->data
);
80 isds_list_free(&messages
);
84 err
= isds_logout(ctx
);
86 printf("isds_logout() failed: %s\n", isds_strerror(err
));
90 err
= isds_ctx_free(&ctx
);
92 printf("isds_ctx_free() failed: %s\n", isds_strerror(err
));
98 printf("isds_cleanup() failed: %s\n", isds_strerror(err
));