1 #define _XOPEN_SOURCE 500
11 int main(int argc
, char **argv
) {
12 struct isds_ctx
*ctx
= NULL
, *request_ctx
= NULL
;
14 struct isds_DbOwnerInfo
*db_owner_info
= NULL
;
15 struct isds_list
*users
= NULL
;
17 setlocale(LC_ALL
, "");
21 printf("isds_init() failed: %s\n", isds_strerror(err
));
25 isds_set_logging(ILF_ALL
& ~ILF_HTTP
, ILL_ALL
);
27 ctx
= isds_ctx_create();
29 printf("isds_ctx_create() failed");
32 err
= isds_set_timeout(ctx
, 10000);
34 printf("isds_set_timeout() failed: %s\n", isds_strerror(err
));
37 err
= isds_login(ctx
, url
, username(), password(), NULL
, NULL
);
39 printf("isds_login() failed: %s: %s\n", isds_strerror(err
),
40 isds_long_message(ctx
));
42 printf("Logged in :)\n");
47 printf("Getting info about my box:\n");
48 err
= isds_GetOwnerInfoFromLogin(ctx
, &db_owner_info
);
50 printf("isds_GetOwnerInfoFromLogin() failed: %s: %s\n",
51 isds_strerror(err
), isds_long_message(ctx
));
53 printf("isds_GetOwnerInfoFromLogin() succeeded\n");
55 print_DbOwnerInfo(db_owner_info
);
59 /* Get info all users of this box */
61 struct isds_list
*item
;
62 printf("Getting users of my box with ID `%s':\n", db_owner_info
->dbID
);
63 err
= isds_GetDataBoxUsers(ctx
, db_owner_info
->dbID
, &users
);
65 printf("isds_GetDataBoxUsers() failed: %s: %s\n",
66 isds_strerror(err
), isds_long_message(ctx
));
68 printf("isds_GetDataBoxUsers() succeeded\n");
69 for(item
= users
; item
; item
= item
->next
) {
70 printf("List item:\n");
71 print_DbUserInfo(item
->data
);
77 /* Request for creating the same box */
79 char *refnumber
= NULL
;
80 const struct isds_approval approval
= {
81 .approved
= 1, .refference
= "Me"
84 free(db_owner_info
->email
);
85 db_owner_info
->email
= strdup("franta@example.com");
87 request_ctx
= isds_ctx_create();
89 printf("isds_ctx_create() failed");
92 printf("Requesting to create already existing box\n");
93 isds_set_logging(ILF_ALL
, ILL_ALL
);
94 err
= isds_request_new_testing_box(request_ctx
, db_owner_info
, users
,
95 "Former Names", &approval
, &refnumber
);
96 isds_set_logging(ILF_ALL
& ~ILF_HTTP
, ILL_ALL
);
98 printf("isds_request_new_testing_box() failed: %s: %s\n",
99 isds_strerror(err
), isds_long_message(request_ctx
));
101 printf("isds_request_new_testing_box() succeeded as request #%s: "
103 refnumber
, db_owner_info
->dbID
);
106 err
= isds_ctx_free(&request_ctx
);
108 printf("isds_ctx_free() failed: %s\n", isds_strerror(err
));
112 isds_DbOwnerInfo_free(&db_owner_info
);
113 isds_list_free(&users
);
116 err
= isds_logout(ctx
);
118 printf("isds_logout() failed: %s\n", isds_strerror(err
));
122 err
= isds_ctx_free(&ctx
);
124 printf("isds_ctx_free() failed: %s\n", isds_strerror(err
));
128 err
= isds_cleanup();
130 printf("isds_cleanup() failed: %s\n", isds_strerror(err
));