1 #define _XOPEN_SOURCE 500
10 /* Get info about my account */
11 isds_error
get_my_account(struct isds_ctx
*ctx
,
12 struct isds_DbUserInfo
**db_user_info
) {
13 isds_error err
= IE_SUCCESS
;
14 printf("Getting info about my account:\n");
15 err
= isds_GetUserInfoFromLogin(ctx
, db_user_info
);
17 printf("isds_GetUserInfoFromLogin() failed: %s: %s\n",
18 isds_strerror(err
), isds_long_message(ctx
));
20 printf("isds_GetUserInfoFromLogin() succeeded\n");
21 print_DbUserInfo(*db_user_info
);
27 int main(int argc
, char **argv
) {
28 struct isds_ctx
*ctx
= NULL
;
30 struct isds_DbOwnerInfo
*db_owner_info
= NULL
;
31 struct isds_DbUserInfo
*db_user_info
= NULL
;
33 setlocale(LC_ALL
, "");
37 printf("isds_init() failed: %s\n", isds_strerror(err
));
41 isds_set_logging(ILF_ALL
& ~ILF_HTTP
, ILL_ALL
);
43 ctx
= isds_ctx_create();
45 printf("isds_ctx_create() failed");
48 err
= isds_set_timeout(ctx
, 10000);
50 printf("isds_set_timeout() failed: %s\n", isds_strerror(err
));
53 err
= isds_login(ctx
, url
, username(), password(), NULL
, NULL
);
55 printf("isds_login() failed: %s: %s\n", isds_strerror(err
),
56 isds_long_message(ctx
));
58 printf("Logged in :)\n");
63 printf("Getting info about my box:\n");
64 err
= isds_GetOwnerInfoFromLogin(ctx
, &db_owner_info
);
66 printf("isds_GetOwnerInfoFromLogin() failed: %s: %s\n",
67 isds_strerror(err
), isds_long_message(ctx
));
69 printf("isds_GetOwnerInfoFromLogin() succeeded\n");
71 print_DbOwnerInfo(db_owner_info
);
77 /* Get info about my account */
78 err
= get_my_account(ctx
, &db_user_info
);
81 if (db_user_info
&& db_owner_info
) {
82 /* Update user info */
83 struct isds_DbUserInfo
*old_user_info
= NULL
;
84 char *refnumber
= NULL
;
86 old_user_info
= isds_DbUserInfo_duplicate(db_user_info
);
88 fprintf(stderr
, "No enough memory\n");
92 printf("Updating info about my account: with no change\n");
93 err
= isds_UpdateDataBoxUser(ctx
, db_owner_info
,
94 old_user_info
, db_user_info
, &refnumber
);
96 printf("isds_UpdateDataBoxUser() failed: %s: %s\n",
97 isds_strerror(err
), isds_long_message(ctx
));
99 printf("isds_UpdateDataBoxUser() succeeded as request #%s\n",
102 /* Verify info about my account */
103 get_my_account(ctx
, &db_user_info
);
107 isds_DbUserInfo_free(&old_user_info
);
110 isds_DbUserInfo_free(&db_user_info
);
111 isds_DbOwnerInfo_free(&db_owner_info
);
115 err
= isds_logout(ctx
);
117 printf("isds_logout() failed: %s\n", isds_strerror(err
));
121 err
= isds_ctx_free(&ctx
);
123 printf("isds_ctx_free() failed: %s\n", isds_strerror(err
));
127 err
= isds_cleanup();
129 printf("isds_cleanup() failed: %s\n", isds_strerror(err
));