mirror of
https://github.com/xorgy/mediafire-fuse
synced 2026-01-13 21:24:28 -08:00
use gnu indent to enforce coding style and adapt source
- indent options are listed in ./.indent.pro - use test case to run indent
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <jansson.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -27,67 +26,69 @@
|
||||
#include "../../utils/strings.h"
|
||||
#include "../folder.h"
|
||||
#include "../mfconn.h"
|
||||
#include "../apicalls.h" // IWYU pragma: keep
|
||||
#include "../apicalls.h" // IWYU pragma: keep
|
||||
|
||||
static int
|
||||
_decode_folder_get_content_folders(mfhttp *conn, void *data);
|
||||
static int _decode_folder_get_content_folders(mfhttp * conn, void *data);
|
||||
|
||||
static int
|
||||
_decode_folder_get_content_files(mfhttp *conn, void *data);
|
||||
static int _decode_folder_get_content_files(mfhttp * conn, void *data);
|
||||
|
||||
long
|
||||
mfconn_api_folder_get_content(mfconn *conn, int mode, mffolder *folder_curr)
|
||||
mfconn_api_folder_get_content(mfconn * conn, int mode, mffolder * folder_curr)
|
||||
{
|
||||
char *api_call;
|
||||
int retval;
|
||||
char *content_type;
|
||||
char *api_call;
|
||||
int retval;
|
||||
char *content_type;
|
||||
mfhttp *http;
|
||||
const char *folderkey;
|
||||
|
||||
if(conn == NULL) return -1;
|
||||
if (conn == NULL)
|
||||
return -1;
|
||||
|
||||
if(mode == 0)
|
||||
if (mode == 0)
|
||||
content_type = "folders";
|
||||
else
|
||||
content_type = "files";
|
||||
|
||||
const char *folderkey = folder_get_key(folder_curr);
|
||||
folderkey = folder_get_key(folder_curr);
|
||||
if (folderkey == NULL) {
|
||||
fprintf(stderr, "folder_get_key NULL\n");
|
||||
return 0;
|
||||
}
|
||||
/*if (folderkey[0] == '\0') {
|
||||
fprintf(stderr, "folder_get_key '\\0'\n");
|
||||
return 0;
|
||||
}*/
|
||||
api_call = mfconn_create_signed_get(conn,0,"folder/get_content.php",
|
||||
"?folder_key=%s"
|
||||
"&content_type=%s"
|
||||
"&response_format=json",
|
||||
folderkey,
|
||||
content_type);
|
||||
fprintf(stderr, "folder_get_key '\\0'\n");
|
||||
return 0;
|
||||
} */
|
||||
api_call = mfconn_create_signed_get(conn, 0, "folder/get_content.php",
|
||||
"?folder_key=%s"
|
||||
"&content_type=%s"
|
||||
"&response_format=json",
|
||||
folderkey, content_type);
|
||||
|
||||
mfhttp* http = http_create();
|
||||
|
||||
if(mode == 0)
|
||||
retval = http_get_buf(http, api_call, _decode_folder_get_content_folders, NULL);
|
||||
http = http_create();
|
||||
if (mode == 0)
|
||||
retval =
|
||||
http_get_buf(http, api_call,
|
||||
_decode_folder_get_content_folders, NULL);
|
||||
else
|
||||
retval = http_get_buf(http, api_call, _decode_folder_get_content_files, NULL);
|
||||
retval =
|
||||
http_get_buf(http, api_call,
|
||||
_decode_folder_get_content_files, NULL);
|
||||
http_destroy(http);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int
|
||||
_decode_folder_get_content_folders(mfhttp *conn, void *user_ptr)
|
||||
static int _decode_folder_get_content_folders(mfhttp * conn, void *user_ptr)
|
||||
{
|
||||
json_error_t error;
|
||||
json_t *root;
|
||||
json_t *node;
|
||||
json_t *data;
|
||||
json_t *root;
|
||||
json_t *node;
|
||||
json_t *data;
|
||||
|
||||
json_t *folders_array;
|
||||
json_t *folderkey;
|
||||
json_t *folder_name;
|
||||
char *folder_name_tmp;
|
||||
json_t *folders_array;
|
||||
json_t *folderkey;
|
||||
json_t *folder_name;
|
||||
char *folder_name_tmp;
|
||||
|
||||
int array_sz;
|
||||
int i = 0;
|
||||
@@ -98,58 +99,53 @@ _decode_folder_get_content_folders(mfhttp *conn, void *user_ptr)
|
||||
root = http_parse_buf_json(conn, 0, &error);
|
||||
|
||||
/*json_t *result = json_object_by_path(root, "response/action");
|
||||
fprintf(stderr, "response/action: %s\n", (char*)json_string_value(result));*/
|
||||
fprintf(stderr, "response/action: %s\n", (char*)json_string_value(result)); */
|
||||
|
||||
node = json_object_by_path(root,"response/folder_content");
|
||||
node = json_object_by_path(root, "response/folder_content");
|
||||
|
||||
folders_array = json_object_get(node,"folders");
|
||||
if(!json_is_array(folders_array))
|
||||
{
|
||||
folders_array = json_object_get(node, "folders");
|
||||
if (!json_is_array(folders_array)) {
|
||||
json_decref(root);
|
||||
return -1;
|
||||
}
|
||||
|
||||
array_sz = json_array_size(folders_array);
|
||||
for(i = 0;i < array_sz;i++)
|
||||
{
|
||||
data = json_array_get(folders_array,i);
|
||||
for (i = 0; i < array_sz; i++) {
|
||||
data = json_array_get(folders_array, i);
|
||||
|
||||
if(json_is_object(data))
|
||||
{
|
||||
folderkey = json_object_get(data,"folderkey");
|
||||
if (json_is_object(data)) {
|
||||
folderkey = json_object_get(data, "folderkey");
|
||||
|
||||
folder_name = json_object_get(data,"name");
|
||||
folder_name = json_object_get(data, "name");
|
||||
|
||||
if(folderkey != NULL && folder_name != NULL)
|
||||
{
|
||||
if (folderkey != NULL && folder_name != NULL) {
|
||||
folder_name_tmp = strdup_printf("< %s >",
|
||||
json_string_value(folder_name));
|
||||
json_string_value(folder_name));
|
||||
|
||||
printf(" %-15.13s %s\n\r",
|
||||
json_string_value(folderkey),
|
||||
folder_name_tmp);
|
||||
json_string_value(folderkey), folder_name_tmp);
|
||||
|
||||
free(folder_name_tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(root != NULL) json_decref(root);
|
||||
if (root != NULL)
|
||||
json_decref(root);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
_decode_folder_get_content_files(mfhttp *conn, void *user_ptr)
|
||||
static int _decode_folder_get_content_files(mfhttp * conn, void *user_ptr)
|
||||
{
|
||||
json_error_t error;
|
||||
json_t *root;
|
||||
json_t *node;
|
||||
json_t *data;
|
||||
json_t *root;
|
||||
json_t *node;
|
||||
json_t *data;
|
||||
|
||||
json_t *files_array;
|
||||
json_t *quickkey;
|
||||
json_t *file_name;
|
||||
json_t *files_array;
|
||||
json_t *quickkey;
|
||||
json_t *file_name;
|
||||
int array_sz;
|
||||
int i = 0;
|
||||
|
||||
@@ -158,36 +154,33 @@ _decode_folder_get_content_files(mfhttp *conn, void *user_ptr)
|
||||
|
||||
root = http_parse_buf_json(conn, 0, &error);
|
||||
|
||||
node = json_object_by_path(root,"response/folder_content");
|
||||
node = json_object_by_path(root, "response/folder_content");
|
||||
|
||||
files_array = json_object_get(node,"files");
|
||||
if(!json_is_array(files_array))
|
||||
{
|
||||
files_array = json_object_get(node, "files");
|
||||
if (!json_is_array(files_array)) {
|
||||
json_decref(root);
|
||||
return -1;
|
||||
}
|
||||
|
||||
array_sz = json_array_size(files_array);
|
||||
for(i = 0;i < array_sz;i++)
|
||||
{
|
||||
data = json_array_get(files_array,i);
|
||||
for (i = 0; i < array_sz; i++) {
|
||||
data = json_array_get(files_array, i);
|
||||
|
||||
if(json_is_object(data))
|
||||
{
|
||||
quickkey = json_object_get(data,"quickkey");
|
||||
if (json_is_object(data)) {
|
||||
quickkey = json_object_get(data, "quickkey");
|
||||
|
||||
file_name = json_object_get(data,"filename");
|
||||
file_name = json_object_get(data, "filename");
|
||||
|
||||
if(quickkey != NULL && file_name != NULL)
|
||||
{
|
||||
if (quickkey != NULL && file_name != NULL) {
|
||||
printf(" %-15.15s %s\n\r",
|
||||
json_string_value(quickkey),
|
||||
json_string_value(file_name));
|
||||
json_string_value(quickkey),
|
||||
json_string_value(file_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(root != NULL) json_decref(root);
|
||||
if (root != NULL)
|
||||
json_decref(root);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user