add more fields for yadisk_get_disk_resources

This commit is contained in:
Maxim Slipenko 2023-12-31 22:18:50 +03:00
parent db89e0e129
commit 7efbd654b7
4 changed files with 46 additions and 6 deletions

View File

@ -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,7 +33,6 @@ target_link_libraries(yadisk
target_include_directories(
test-app PRIVATE
"${CMAKE_SOURCE_DIR}/src"
${NEON_INCLUDE_DIR}
${CURL_INCLUDE_DIR}
${JSON_C_INCLUDE_DIR}
)

View File

@ -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;

View File

@ -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 {

View File

@ -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();