doc: Base URL server locator without suffix
[libisds.git] / client / deleteuser.c
blob15af5d78bb3736c1256e2dfb8d34ad5a8bcb3449
1 #define _XOPEN_SOURCE 500
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <locale.h>
5 #include <time.h>
6 #include <string.h>
7 #include <isds.h>
8 #include "common.h"
10 int main(int argc, char **argv) {
11 struct isds_ctx *ctx = NULL;
12 isds_error err;
13 struct isds_DbOwnerInfo *db_owner_info = NULL;
14 struct isds_DbUserInfo *db_user_info = NULL;
16 setlocale(LC_ALL, "");
18 err = isds_init();
19 if (err) {
20 printf("isds_init() failed: %s\n", isds_strerror(err));
21 exit(EXIT_FAILURE);
24 isds_set_logging(ILF_ALL & ~ILF_HTTP, ILL_ALL);
26 ctx = isds_ctx_create();
27 if (!ctx) {
28 printf("isds_ctx_create() failed");
31 err = isds_set_timeout(ctx, 10000);
32 if (err) {
33 printf("isds_set_timeout() failed: %s\n", isds_strerror(err));
36 /* err = isds_set_tls(ctx, ITLS_VERIFY_SERVER, 0);
37 if (err) {
38 printf("isds_set_tls(ITLS_VERIFY_SERVER) failed: %s\n",
39 isds_strerror(err));
42 err = isds_set_tls(ctx, ITLS_CA_FILE, "/etc/ssl/certs/ca-certificates.crt");
43 if (err) {
44 printf("isds_set_tls(ITLS_CA_FILE) failed: %s\n",
45 isds_strerror(err));
46 }*/
48 err = isds_login(ctx, url, username, password, NULL, NULL);
49 if (err) {
50 printf("isds_login() failed: %s: %s\n", isds_strerror(err),
51 isds_long_message(ctx));
52 } else {
53 printf("Logged in :)\n");
58 /* Get info about my box */
59 printf("Getting info about my box:\n");
60 err = isds_GetOwnerInfoFromLogin(ctx, &db_owner_info);
61 if (err) {
62 printf("isds_GetOwnerInfoFromLogin() failed: %s: %s\n",
63 isds_strerror(err), isds_long_message(ctx));
64 } else {
65 printf("isds_GetOwnerInfoFromLogin() succeeded\n");
67 print_DbOwnerInfo(db_owner_info);
71 /* Get info about my account */
72 printf("Getting info about my account:\n");
73 err = isds_GetUserInfoFromLogin(ctx, &db_user_info);
74 if (err) {
75 printf("isds_GetUserInfoFromLogin() failed: %s: %s\n",
76 isds_strerror(err), isds_long_message(ctx));
77 } else {
78 printf("isds_GetUserInfoFromLogin() succeeded\n");
79 print_DbUserInfo(db_user_info);
83 if (db_owner_info && db_user_info) {
84 char *refnumber = NULL;
86 printf("Deleting user\n");
87 isds_error err = isds_delete_user(ctx, db_owner_info, db_user_info,
88 NULL, &refnumber);
89 if (err) {
90 printf("isds_delete_user() failed: %s: %s\n",
91 isds_strerror(err), isds_long_message(ctx));
92 } else {
93 printf("isds_delete_user() succeeded as request #%s.\n"
94 "This should not happen\n", refnumber);
96 free(refnumber);
99 isds_DbOwnerInfo_free(&db_owner_info);
100 isds_DbUserInfo_free(&db_user_info);
103 err = isds_logout(ctx);
104 if (err) {
105 printf("isds_logout() failed: %s\n", isds_strerror(err));
109 err = isds_ctx_free(&ctx);
110 if (err) {
111 printf("isds_ctx_free() failed: %s\n", isds_strerror(err));
115 err = isds_cleanup();
116 if (err) {
117 printf("isds_cleanup() failed: %s\n", isds_strerror(err));
120 exit (EXIT_SUCCESS);