1 #define _XOPEN_SOURCE 500
10 void logger(isds_log_facility facility
, isds_log_level level
,
11 const char *message
, int length
, void *data
) {
12 /* Silent warning about unused argument.
13 * It's a libisds' protopype isds_log_callback. */
16 printf("\033[32mLOG(%02d,%02d): ", facility
, level
);
17 printf("%.*s", length
, message
);
23 struct isds_ctx
*ctx
= NULL
;
26 setlocale(LC_ALL
, "");
30 printf("isds_init() failed: %s\n", isds_strerror(err
));
33 printf("isds_init() succeeded\n");
36 isds_set_log_callback(logger
, NULL
);
37 isds_set_logging(ILF_ALL
, ILL_ALL
);
39 ctx
= isds_ctx_create();
41 printf("isds_ctx_create() failed");
43 printf("isds_ctx_create() succeeded\n");
47 err
= isds_set_timeout(ctx
, 10000);
49 printf("isds_set_timeout() failed: %s\n", isds_strerror(err
));
51 printf("isds_set_timeout() succeeded\n");
55 err
= isds_login(ctx
, url
, username(), password(), NULL
, NULL
);
57 printf("isds_login() failed: %s: %s\n", isds_strerror(err
),
58 isds_long_message(ctx
));
60 printf("Logged in :)\n");
64 err
= isds_logout(ctx
);
66 printf("isds_logout() failed: %s\n", isds_strerror(err
));
68 printf("isds_logout() succeeded\n");
73 err
= isds_ctx_free(&ctx
);
75 printf("isds_ctx_free() failed: %s\n", isds_strerror(err
));
77 printf("isds_ctx_free() succeeded\n");
84 printf("isds_cleanup() failed: %s\n", isds_strerror(err
));
86 printf("isds_ctx_cleanup() succeeded\n");