2 #define _XOPEN_SOURCE XOPEN_SOURCE_LEVEL_FOR_STRDUP
13 struct isds_ctx
*ctx
= NULL
, *request_ctx
= NULL
;
15 struct isds_DbOwnerInfo
*db_owner_info
= NULL
;
16 struct isds_list
*users
= NULL
;
18 setlocale(LC_ALL
, "");
22 printf("isds_init() failed: %s\n", isds_strerror(err
));
26 isds_set_logging(ILF_ALL
& ~ILF_HTTP
, ILL_ALL
);
28 ctx
= isds_ctx_create();
30 printf("isds_ctx_create() failed");
33 err
= isds_set_timeout(ctx
, 10000);
35 printf("isds_set_timeout() failed: %s\n", isds_strerror(err
));
38 err
= isds_login(ctx
, url
, username(), password(), NULL
, NULL
);
40 printf("isds_login() failed: %s: %s\n", isds_strerror(err
),
41 isds_long_message(ctx
));
43 printf("Logged in :)\n");
48 printf("Getting info about my box:\n");
49 err
= isds_GetOwnerInfoFromLogin(ctx
, &db_owner_info
);
51 printf("isds_GetOwnerInfoFromLogin() failed: %s: %s\n",
52 isds_strerror(err
), isds_long_message(ctx
));
54 printf("isds_GetOwnerInfoFromLogin() succeeded\n");
56 print_DbOwnerInfo(db_owner_info
);
60 /* Get info all users of this box */
62 struct isds_list
*item
;
63 printf("Getting users of my box with ID `%s':\n", db_owner_info
->dbID
);
64 err
= isds_GetDataBoxUsers(ctx
, db_owner_info
->dbID
, &users
);
66 printf("isds_GetDataBoxUsers() failed: %s: %s\n",
67 isds_strerror(err
), isds_long_message(ctx
));
69 printf("isds_GetDataBoxUsers() succeeded\n");
70 for(item
= users
; item
; item
= item
->next
) {
71 printf("List item:\n");
72 print_DbUserInfo(item
->data
);
78 /* Request for creating the same box */
80 char *refnumber
= NULL
;
81 const struct isds_approval approval
= {
82 .approved
= 1, .refference
= "Me"
85 free(db_owner_info
->email
);
86 db_owner_info
->email
= strdup("franta@example.com");
88 request_ctx
= isds_ctx_create();
90 printf("isds_ctx_create() failed");
93 printf("Requesting to create already existing box\n");
94 isds_set_logging(ILF_ALL
, ILL_ALL
);
95 err
= isds_request_new_testing_box(request_ctx
, db_owner_info
, users
,
96 "Former Names", &approval
, &refnumber
);
97 isds_set_logging(ILF_ALL
& ~ILF_HTTP
, ILL_ALL
);
99 printf("isds_request_new_testing_box() failed: %s: %s\n",
100 isds_strerror(err
), isds_long_message(request_ctx
));
102 printf("isds_request_new_testing_box() succeeded as request #%s: "
104 refnumber
, db_owner_info
->dbID
);
107 err
= isds_ctx_free(&request_ctx
);
109 printf("isds_ctx_free() failed: %s\n", isds_strerror(err
));
113 isds_DbOwnerInfo_free(&db_owner_info
);
114 isds_list_free(&users
);
117 err
= isds_logout(ctx
);
119 printf("isds_logout() failed: %s\n", isds_strerror(err
));
123 err
= isds_ctx_free(&ctx
);
125 printf("isds_ctx_free() failed: %s\n", isds_strerror(err
));
129 err
= isds_cleanup();
131 printf("isds_cleanup() failed: %s\n", isds_strerror(err
));