Add missing user and sender types to example client's dump code
[libisds.git] / client / getboxlist.c
blob7833fbda0c675df7a70bf2c75b467773b4abb081
1 #define _XOPEN_SOURCE 500
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <locale.h>
5 #include <string.h>
6 #include <isds.h>
7 #include "common.h"
10 int main(void) {
11 struct isds_ctx *ctx = NULL;
12 isds_error err;
14 setlocale(LC_ALL, "");
16 err = isds_init();
17 if (err) {
18 printf("isds_init() failed: %s\n", isds_strerror(err));
19 exit(EXIT_FAILURE);
22 isds_set_logging(ILF_ALL & ~ILF_HTTP, ILL_ALL);
24 ctx = isds_ctx_create();
25 if (!ctx) {
26 printf("isds_ctx_create() failed");
29 err = isds_set_timeout(ctx, 10000);
30 if (err) {
31 printf("isds_set_timeout() failed: %s\n", isds_strerror(err));
34 err = isds_login(ctx, url, username(), password(), NULL, NULL);
35 if (err) {
36 printf("isds_login() failed: %s: %s\n", isds_strerror(err),
37 isds_long_message(ctx));
38 } else {
39 printf("Logged in :)\n");
44 void *archive = NULL;
45 size_t length;
47 err = isds_get_box_list_archive(ctx, "UPG", &archive, &length);
48 if (err) {
49 printf("isds_get_box_list_archive() failed: %s: %s\n",
50 isds_strerror(err), isds_long_message(ctx));
51 } else {
52 printf("isds_get_box_list_archive() succeeded:\n");
53 printf("length = %zu B\n", length);
54 save_data("Saving ZIP archive", archive, length);
56 printf("\n");
58 free(archive);
62 err = isds_logout(ctx);
63 if (err) {
64 printf("isds_logout() failed: %s\n", isds_strerror(err));
68 err = isds_ctx_free(&ctx);
69 if (err) {
70 printf("isds_ctx_free() failed: %s\n", isds_strerror(err));
74 err = isds_cleanup();
75 if (err) {
76 printf("isds_cleanup() failed: %s\n", isds_strerror(err));
79 exit (EXIT_SUCCESS);