1 #define _XOPEN_SOURCE 500
11 int main(int argc
, char **argv
) {
12 struct isds_ctx
*ctx
= NULL
;
14 struct isds_DbOwnerInfo
*db_owner_info
= NULL
;
16 setlocale(LC_ALL
, "");
20 printf("isds_init() failed: %s\n", isds_strerror(err
));
24 isds_set_logging(ILF_ALL
& ~ILF_HTTP
, ILL_ALL
);
26 ctx
= isds_ctx_create();
28 printf("isds_ctx_create() failed");
31 err
= isds_set_timeout(ctx
, 10000);
33 printf("isds_set_timeout() failed: %s\n", isds_strerror(err
));
36 /* err = isds_set_tls(ctx, ITLS_VERIFY_SERVER, 0);
38 printf("isds_set_tls(ITLS_VERIFY_SERVER) failed: %s\n",
42 err = isds_set_tls(ctx, ITLS_CA_FILE, "/etc/ssl/certs/ca-certificates.crt");
44 printf("isds_set_tls(ITLS_CA_FILE) failed: %s\n",
48 err
= isds_login(ctx
, url
, username
, password
, NULL
);
50 printf("isds_login() failed: %s: %s\n", isds_strerror(err
),
51 isds_long_message(ctx
));
53 printf("Logged in :)\n");
58 printf("Getting info about my box:\n");
59 err
= isds_GetOwnerInfoFromLogin(ctx
, &db_owner_info
);
61 printf("isds_GetOwnerInfoFromLogin() failed: %s: %s\n",
62 isds_strerror(err
), isds_long_message(ctx
));
64 printf("isds_GetOwnerInfoFromLogin() succeeded\n");
66 print_DbOwnerInfo(db_owner_info
);
71 /* Current server implementation (2009-11-17) does not allow to find
72 * myself. Previous version allowed it. */
73 struct isds_list
*boxes
= NULL
, *item
;
75 printf("Searching for my own box:\n");
76 err
= isds_FindDataBox(ctx
, db_owner_info
, &boxes
);
77 if (err
== IE_SUCCESS
|| err
== IE_2BIG
) {
79 printf("isds_FindDataBox() results truncated\n");
80 printf("isds_FindDataBox() succeeded:\n");
82 for(item
= boxes
; item
; item
= item
->next
) {
83 printf("List item:\n");
84 print_DbOwnerInfo(item
->data
);
87 printf("isds_FindDataBox() failed: %s: %s\n",
88 isds_strerror(err
), isds_long_message(ctx
));
91 isds_list_free(&boxes
);
95 /* Get box delivery info */
97 long int box_status
= 0;
98 printf("Getting status of my box with ID `%s'\n", db_owner_info
->dbID
);
99 err
= isds_CheckDataBox(ctx
, db_owner_info
->dbID
, &box_status
);
101 printf("isds_CheckDataBox() failed: %s: %s\n",
102 isds_strerror(err
), isds_long_message(ctx
));
104 printf("isds_CheckDataBox() succeeded: status = ");
105 print_DbState(box_status
);
109 /* Get info all users of this box */
111 struct isds_list
*users
= NULL
, *item
;
112 printf("Getting users of my box with ID `%s':\n", db_owner_info
->dbID
);
113 err
= isds_GetDataBoxUsers(ctx
, db_owner_info
->dbID
, &users
);
115 printf("isds_GetDataBoxUsers() failed: %s: %s\n",
116 isds_strerror(err
), isds_long_message(ctx
));
118 printf("isds_GetDataBoxUsers() succeeded\n");
119 for(item
= users
; item
; item
= item
->next
) {
120 printf("List item:\n");
121 print_DbUserInfo(item
->data
);
124 isds_list_free(&users
);
127 isds_DbOwnerInfo_free(&db_owner_info
);
130 /* Get info about my account */
131 struct isds_DbUserInfo
*db_user_info
= NULL
;
132 printf("Getting info about my account:\n");
133 err
= isds_GetUserInfoFromLogin(ctx
, &db_user_info
);
135 printf("isds_GetUserInfoFromLogin() failed: %s: %s\n",
136 isds_strerror(err
), isds_long_message(ctx
));
138 printf("isds_GetUserInfoFromLogin() succeeded\n");
139 print_DbUserInfo(db_user_info
);
141 isds_DbUserInfo_free(&db_user_info
);
145 /* Get password expiration time */
146 struct timeval
*expiration
= NULL
;
147 printf("Getting password expiration time\n");
148 err
= isds_get_password_expiration(ctx
, &expiration
);
150 printf("isds_get_password_expiration() failed: %s: %s\n",
151 isds_strerror(err
), isds_long_message(ctx
));
153 printf("isds_get_password_expiration() succeeded: "
154 "Password expires at: ");
155 print_timeval(expiration
);
161 err
= isds_logout(ctx
);
163 printf("isds_logout() failed: %s\n", isds_strerror(err
));
167 err
= isds_ctx_free(&ctx
);
169 printf("isds_ctx_free() failed: %s\n", isds_strerror(err
));
173 err
= isds_cleanup();
175 printf("isds_cleanup() failed: %s\n", isds_strerror(err
));