Add @approval argument to almost all DB_MANIPULATION functions
[libisds.git] / client / disableaccesibilityexternaly.c
blobb65ec7e734ca54c8a56add01fa63cab76988cba8
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(int argc, char **argv) {
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_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 printf("Getting info about my box:\n");
59 err = isds_GetOwnerInfoFromLogin(ctx, &db_owner_info);
60 if (err) {
61 printf("isds_GetOwnerInfoFromLogin() failed: %s: %s\n",
62 isds_strerror(err), isds_long_message(ctx));
63 } else {
64 printf("isds_GetOwnerInfoFromLogin() succeeded\n");
66 print_DbOwnerInfo(db_owner_info);
70 /* Disable access to my box exernally. It should fail. */
71 if (db_owner_info) {
72 struct isds_DbOwnerInfo *new_db_owner_info = NULL;
73 struct tm date = {
74 .tm_year = 103,
75 .tm_mon = 1,
76 .tm_mday = 1
78 char *refnumber = NULL;
80 printf("Disabling access to my box externaly since: ");
81 print_date(&date);
82 err = isds_disable_box_accessibility_externaly(ctx,
83 db_owner_info, &date, NULL, &refnumber);
84 if (err)
85 printf("isds_disable_box_accessibility_externaly() failed: "
86 "%s: %s\n", isds_strerror(err), isds_long_message(ctx));
87 else {
88 printf("isds_disable_box_accessibility_externaly() "
89 "succeeded as request #%s\n", refnumber);
91 free(refnumber);
93 printf("Verifying info about my box:\n");
94 err = isds_GetOwnerInfoFromLogin(ctx, &new_db_owner_info);
95 if (err) {
96 printf("isds_GetOwnerInfoFromLogin() failed: %s: %s\n",
97 isds_strerror(err), isds_long_message(ctx));
98 } else {
99 printf("isds_GetOwnerInfoFromLogin() succeeded\n");
100 printf("New box status is: ");
101 print_longint(new_db_owner_info->dbState);
103 isds_DbOwnerInfo_free(&new_db_owner_info);
106 isds_DbOwnerInfo_free(&db_owner_info);
109 err = isds_logout(ctx);
110 if (err) {
111 printf("isds_logout() failed: %s\n", isds_strerror(err));
115 err = isds_ctx_free(&ctx);
116 if (err) {
117 printf("isds_ctx_free() failed: %s\n", isds_strerror(err));
121 err = isds_cleanup();
122 if (err) {
123 printf("isds_cleanup() failed: %s\n", isds_strerror(err));
126 exit (EXIT_SUCCESS);