From 7efbd654b7c1ebfbc601b8e277e70f8e300ec0b7 Mon Sep 17 00:00:00 2001 From: Maxim Slipenko Date: Sun, 31 Dec 2023 22:18:50 +0300 Subject: [PATCH] add more fields for yadisk_get_disk_resources --- CMakeLists.txt | 5 +++-- src/yadisk_get_disk_resources.c | 3 +++ src/yadisk_get_disk_resources.h | 34 ++++++++++++++++++++++++++++++++- tests/app.c | 10 +++++++--- 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a7928e..2b283ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.5) project(YaDisk) +set(CMAKE_C_STANDARD 99) + set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) find_package(CURL REQUIRED) find_package(JsonC REQUIRED) @@ -31,11 +33,10 @@ target_link_libraries(yadisk target_include_directories( test-app PRIVATE "${CMAKE_SOURCE_DIR}/src" - ${NEON_INCLUDE_DIR} ${CURL_INCLUDE_DIR} ${JSON_C_INCLUDE_DIR} ) target_link_libraries( test-app yadisk -) \ No newline at end of file +) diff --git a/src/yadisk_get_disk_resources.c b/src/yadisk_get_disk_resources.c index 17829a4..2848e4e 100644 --- a/src/yadisk_get_disk_resources.c +++ b/src/yadisk_get_disk_resources.c @@ -41,6 +41,9 @@ yadisk_get_disk_resources( GET_JSON_STRING(root, "type", &(info->type)); GET_JSON_STRING(root, "created", &(info->created)); GET_JSON_STRING(root, "modified", &(info->modified)); + GET_JSON_STRING(root, "media_type", &(info->media_type)); + GET_JSON_STRING(root, "mime_type", &(info->mime_type)); + GET_JSON_UINT64(root, "size", &(info->size)); json_object_put(root); return YADISK_OK; diff --git a/src/yadisk_get_disk_resources.h b/src/yadisk_get_disk_resources.h index e46f7af..b9538dd 100644 --- a/src/yadisk_get_disk_resources.h +++ b/src/yadisk_get_disk_resources.h @@ -30,16 +30,48 @@ const char* resource_id; \ const char* type; \ const char* created; \ - const char* modified; + const char* modified; \ + const char* mime_type; \ + const char* media_type; \ + unsigned long size; \ + const char* md5; \ + const char* sha256; \ + const char* antivirus_status; \ + unsigned long long revision; \ + yadisk_comment_ids* comment_ids; \ + yadisk_sizes* sizes; \ + unsigned long sizes_count; + +// Структура для комментариев +typedef struct { + const char* private_resource; + const char* public_resource; +} yadisk_comment_ids; + +// Структура для размеров +typedef struct { + const char* url; + const char* name; +} yadisk_size; + +// Массив размеров +typedef struct { + yadisk_size* sizes; + unsigned long count; +} yadisk_sizes; struct yadisk_resource_item { YADISK_RESOURCE_ITEM_PROPERTIES }; typedef struct { + struct yadisk_resource_item* items; // Массив элементов + unsigned long items_count; // Количество элементов unsigned long limit; unsigned long offset; unsigned long total; + const char* sort; + const char* path; } yadisk_resource_embedded; typedef struct { diff --git a/tests/app.c b/tests/app.c index 127e1ba..57e59ab 100644 --- a/tests/app.c +++ b/tests/app.c @@ -30,9 +30,10 @@ int main() yadisk_init(); - yadisk_api_client* client = &(yadisk_api_client) { - .token = token - }; + yadisk_api_client* client = malloc(sizeof(yadisk_api_client)); + if (client != NULL) { + client->token = token; + } yadisk_disk_info info; yadisk_get_disk(client, &info); @@ -81,6 +82,9 @@ int main() printf("Created: %s\n", resource.created); printf("Modified: %s\n", resource.modified); printf("ResourceID: %s\n", resource.resource_id); + printf("Media TYPE: %s\n", resource.media_type); + printf("Mime TYPE: %s\n", resource.mime_type); + printf("Size: %lu\n", resource.size); yadisk_cleanup();