add test-app target

This commit is contained in:
2023-11-27 09:03:47 +03:00
parent 6c4949f31c
commit ae53f5042c
4 changed files with 39 additions and 9 deletions

View File

@@ -17,21 +17,23 @@ static int api_http_request(
void yadisk_get_disk(yadisk_api_client *client, yadisk_disk_info* info) {
char* output = NULL;
int result = api_http_request(client, "GET", "/v1/disk", &output);
int error = api_http_request(client, "GET", "/v1/disk", &output);
json_object* root = json_tokener_parse(output);
free(output);
if (!result) {
if (error) {
json_object_put(root);
return;
}
json_object* total_space = NULL;
json_object_object_get_ex(root, "total_space", &total_space);
info->total_space = json_object_get_int64(total_space);
if (!json_object_object_get_ex(root, "total_space", &total_space)) {
printf("Key total_space doesn't exists!");
}
info->total_space = json_object_get_uint64(total_space);
json_object_put(total_space);
json_object_put(root);
free(output);
}
void yadisk_delete_disk_resources(yadisk_api_client *client) {

View File

@@ -17,7 +17,7 @@ typedef struct yadisk_api_client
typedef struct yadisk_disk_info
{
long total_space;
unsigned long total_space;
} yadisk_disk_info;
void yadisk_get_disk(yadisk_api_client* client, yadisk_disk_info* info);