1 #define _XOPEN_SOURCE 500
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_login(ctx
, url
, username(), password(), NULL
, NULL
);
38 printf("isds_login() failed: %s: %s\n", isds_strerror(err
),
39 isds_long_message(ctx
));
41 printf("Logged in :)\n");
46 printf("Getting info about my box:\n");
47 err
= isds_GetOwnerInfoFromLogin(ctx
, &db_owner_info
);
49 printf("isds_GetOwnerInfoFromLogin() failed: %s: %s\n",
50 isds_strerror(err
), isds_long_message(ctx
));
52 printf("isds_GetOwnerInfoFromLogin() succeeded\n");
54 print_DbOwnerInfo(db_owner_info
);
59 /* Current server implementation (2009-11-17) does not allow to find
60 * myself. Previous version allowed it. */
61 struct isds_list
*boxes
= NULL
, *item
;
63 printf("Searching for my own box:\n");
64 err
= isds_FindDataBox(ctx
, db_owner_info
, &boxes
);
65 if (err
== IE_SUCCESS
|| err
== IE_2BIG
) {
67 printf("isds_FindDataBox() results truncated\n");
68 printf("isds_FindDataBox() succeeded:\n");
70 for(item
= boxes
; item
; item
= item
->next
) {
71 printf("List item:\n");
72 print_DbOwnerInfo(item
->data
);
75 printf("isds_FindDataBox() failed: %s: %s\n",
76 isds_strerror(err
), isds_long_message(ctx
));
79 isds_list_free(&boxes
);
83 /* Get box delivery info */
85 long int box_status
= 0;
86 printf("Getting status of my box with ID `%s'\n", db_owner_info
->dbID
);
87 err
= isds_CheckDataBox(ctx
, db_owner_info
->dbID
, &box_status
);
89 printf("isds_CheckDataBox() failed: %s: %s\n",
90 isds_strerror(err
), isds_long_message(ctx
));
92 printf("isds_CheckDataBox() succeeded: status = ");
93 print_DbState(box_status
);
97 /* Get info all users of this box */
99 struct isds_list
*users
= NULL
, *item
;
100 printf("Getting users of my box with ID `%s':\n", db_owner_info
->dbID
);
101 err
= isds_GetDataBoxUsers(ctx
, db_owner_info
->dbID
, &users
);
103 printf("isds_GetDataBoxUsers() failed: %s: %s\n",
104 isds_strerror(err
), isds_long_message(ctx
));
106 printf("isds_GetDataBoxUsers() succeeded\n");
107 for(item
= users
; item
; item
= item
->next
) {
108 printf("List item:\n");
109 print_DbUserInfo(item
->data
);
112 isds_list_free(&users
);
115 isds_DbOwnerInfo_free(&db_owner_info
);
118 /* Get info about my account */
119 struct isds_DbUserInfo
*db_user_info
= NULL
;
120 printf("Getting info about my account:\n");
121 err
= isds_GetUserInfoFromLogin(ctx
, &db_user_info
);
123 printf("isds_GetUserInfoFromLogin() failed: %s: %s\n",
124 isds_strerror(err
), isds_long_message(ctx
));
126 printf("isds_GetUserInfoFromLogin() succeeded\n");
127 print_DbUserInfo(db_user_info
);
129 isds_DbUserInfo_free(&db_user_info
);
133 /* Get password expiration time */
134 struct timeval
*expiration
= NULL
;
135 printf("Getting password expiration time\n");
136 err
= isds_get_password_expiration(ctx
, &expiration
);
138 printf("isds_get_password_expiration() failed: %s: %s\n",
139 isds_strerror(err
), isds_long_message(ctx
));
141 printf("isds_get_password_expiration() succeeded: "
142 "Password expires at: ");
144 print_timeval(expiration
);
152 err
= isds_logout(ctx
);
154 printf("isds_logout() failed: %s\n", isds_strerror(err
));
158 err
= isds_ctx_free(&ctx
);
160 printf("isds_ctx_free() failed: %s\n", isds_strerror(err
));
164 err
= isds_cleanup();
166 printf("isds_cleanup() failed: %s\n", isds_strerror(err
));