1 #define _XOPEN_SOURCE 500
10 /* Get info about my account */
11 isds_error
get_my_box(struct isds_ctx
*ctx
,
12 struct isds_DbOwnerInfo
**db_owner_info
) {
13 isds_error err
= IE_SUCCESS
;
14 printf("Getting info about my box:\n");
15 err
= isds_GetOwnerInfoFromLogin(ctx
, db_owner_info
);
17 printf("isds_GetOwnerInfoFromLogin() failed: %s: %s\n",
18 isds_strerror(err
), isds_long_message(ctx
));
20 printf("isds_GetOwnerInfoFromLogin() succeeded\n");
22 print_DbOwnerInfo(*db_owner_info
);
27 int main(int argc
, char **argv
) {
28 struct isds_ctx
*ctx
= NULL
;
30 struct isds_DbOwnerInfo
*db_owner_info
= NULL
;
32 setlocale(LC_ALL
, "");
36 printf("isds_init() failed: %s\n", isds_strerror(err
));
40 isds_set_logging(ILF_ALL
& ~ILF_HTTP
, ILL_ALL
);
42 ctx
= isds_ctx_create();
44 printf("isds_ctx_create() failed");
47 err
= isds_set_timeout(ctx
, 10000);
49 printf("isds_set_timeout() failed: %s\n", isds_strerror(err
));
52 /* err = isds_set_tls(ctx, ITLS_VERIFY_SERVER, 0);
54 printf("isds_set_tls(ITLS_VERIFY_SERVER) failed: %s\n",
58 err = isds_set_tls(ctx, ITLS_CA_FILE, "/etc/ssl/certs/ca-certificates.crt");
60 printf("isds_set_tls(ITLS_CA_FILE) failed: %s\n",
64 err
= isds_login(ctx
, url
, username
, password
, NULL
);
66 printf("isds_login() failed: %s: %s\n", isds_strerror(err
),
67 isds_long_message(ctx
));
69 printf("Logged in :)\n");
74 printf("Get current box info\n");
75 get_my_box(ctx
, &db_owner_info
);
81 struct isds_DbOwnerInfo
*old_owner_info
= NULL
;
82 char *refnumber
= NULL
;
84 old_owner_info
= isds_DbOwnerInfo_duplicate(db_owner_info
);
85 if (!old_owner_info
) {
86 fprintf(stderr
, "No enough memory\n");
90 printf("Updating info about my box: with no change\n");
91 err
= isds_UpdateDataBoxDescr(ctx
, old_owner_info
, db_owner_info
,
94 printf("isds_UpdateDataBoxDescr() failed: %s: %s\n",
95 isds_strerror(err
), isds_long_message(ctx
));
97 printf("isds_UpdateDataBoxDescr() succeeded as request #%s\n",
99 printf("Get new box info\n");
100 get_my_box(ctx
, &db_owner_info
);
104 isds_DbOwnerInfo_free(&old_owner_info
);
107 isds_DbOwnerInfo_free(&db_owner_info
);
111 err
= isds_logout(ctx
);
113 printf("isds_logout() failed: %s\n", isds_strerror(err
));
117 err
= isds_ctx_free(&ctx
);
119 printf("isds_ctx_free() failed: %s\n", isds_strerror(err
));
123 err
= isds_cleanup();
125 printf("isds_cleanup() failed: %s\n", isds_strerror(err
));