Implement Re-signISDSDocument
[libisds.git] / client / activate.c
blobf2667c6d6892267f5c19b22b2f1e2861f6e14280
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(int argc, char **argv) {
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 char *user_id = NULL, *password = NULL;
45 /* Try a call, not our box as we do not know what does it */
46 err = isds_activate(ctx, "kuqcfr6", "token", &user_id, &password);
47 if (err) {
48 printf("isds_activate() failed: %s: %s\n",
49 isds_strerror(err), isds_long_message(ctx));
50 } else {
51 printf("isds_activate() succeeded:\n");
52 printf("user_id = %s\n", user_id);
53 printf("password = %s\n", password);
55 printf("\n");
57 free(user_id);
58 free(password);
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);