Adapt to OpenSSL 1.1.0
[libisds.git] / client / disableaccesibilityexternaly.c
blobd9b68fff447633a60a422e010bcc64d58f90ad8e
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"
11 int main(void) {
12 struct isds_ctx *ctx = NULL;
13 isds_error err;
14 struct isds_DbOwnerInfo *db_owner_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_login(ctx, url, username(), password(), NULL, NULL);
37 if (err) {
38 printf("isds_login() failed: %s: %s\n", isds_strerror(err),
39 isds_long_message(ctx));
40 } else {
41 printf("Logged in :)\n");
46 printf("Getting info about my box:\n");
47 err = isds_GetOwnerInfoFromLogin(ctx, &db_owner_info);
48 if (err) {
49 printf("isds_GetOwnerInfoFromLogin() failed: %s: %s\n",
50 isds_strerror(err), isds_long_message(ctx));
51 } else {
52 printf("isds_GetOwnerInfoFromLogin() succeeded\n");
54 print_DbOwnerInfo(db_owner_info);
58 /* Disable access to my box exernally. It should fail. */
59 if (db_owner_info) {
60 struct isds_DbOwnerInfo *new_db_owner_info = NULL;
61 struct tm date = {
62 .tm_year = 103,
63 .tm_mon = 1,
64 .tm_mday = 1
66 char *refnumber = NULL;
68 printf("Disabling access to my box externaly since: ");
69 print_date(&date);
70 err = isds_disable_box_accessibility_externaly(ctx,
71 db_owner_info, &date, NULL, &refnumber);
72 if (err)
73 printf("isds_disable_box_accessibility_externaly() failed: "
74 "%s: %s\n", isds_strerror(err), isds_long_message(ctx));
75 else {
76 printf("isds_disable_box_accessibility_externaly() "
77 "succeeded as request #%s\n", refnumber);
79 free(refnumber);
81 printf("Verifying info about my box:\n");
82 err = isds_GetOwnerInfoFromLogin(ctx, &new_db_owner_info);
83 if (err) {
84 printf("isds_GetOwnerInfoFromLogin() failed: %s: %s\n",
85 isds_strerror(err), isds_long_message(ctx));
86 } else {
87 printf("isds_GetOwnerInfoFromLogin() succeeded\n");
88 printf("New box status is: ");
89 print_longint(new_db_owner_info->dbState);
91 isds_DbOwnerInfo_free(&new_db_owner_info);
94 isds_DbOwnerInfo_free(&db_owner_info);
97 err = isds_logout(ctx);
98 if (err) {
99 printf("isds_logout() failed: %s\n", isds_strerror(err));
103 err = isds_ctx_free(&ctx);
104 if (err) {
105 printf("isds_ctx_free() failed: %s\n", isds_strerror(err));
109 err = isds_cleanup();
110 if (err) {
111 printf("isds_cleanup() failed: %s\n", isds_strerror(err));
114 exit (EXIT_SUCCESS);