libyadisk/tests/app.c

61 lines
1.9 KiB
C
Raw Normal View History

2023-11-29 20:39:27 +03:00
/*
* libyadisk - A C library for interacting with Yandex.Disk API
*
* This file is part of libyadisk.
*
* Copyright (C) 2023 Maxim Slipenko
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/
#include <yadisk.h>
2023-11-27 09:03:47 +03:00
#include <stdio.h>
2023-11-29 14:00:52 +03:00
int main()
{
2023-11-27 09:03:47 +03:00
char token[1024];
printf("Enter OAuth token: ");
fgets(token, sizeof(token), stdin);
2023-11-29 13:57:30 +03:00
yadisk_init();
2023-11-29 14:00:52 +03:00
yadisk_api_client* client = &(yadisk_api_client) {
.token = token
2023-11-27 09:03:47 +03:00
};
yadisk_disk_info yadisk_disk_info;
yadisk_get_disk(client, &yadisk_disk_info);
2023-11-29 13:57:30 +03:00
printf("Total disk size: %lu\n", yadisk_disk_info.total_space);
printf("Trash size: %lu\n", yadisk_disk_info.trash_size);
printf("Used space: %lu\n", yadisk_disk_info.used_space);
printf("Registration time: %s\n", yadisk_disk_info.reg_time);
printf("Is paid: %s\n", yadisk_disk_info.is_paid ? "Yes" : "No");
printf("=================\n");
yadisk_resource_info resource;
yadisk_get_disk_resources(client, "/", &resource);
printf("Path: %s\n", resource.path);
printf("Name: %s\n", resource.name);
printf("Type: %s\n", resource.type);
printf("Created: %s\n", resource.created);
printf("Modified: %s\n", resource.modified);
printf("ResourceID: %s\n", resource.resource_id);
yadisk_cleanup();
2023-11-27 09:03:47 +03:00
return 0;
2023-11-29 13:57:30 +03:00
}