mirror of
https://github.com/xorgy/mediafire-fuse
synced 2026-01-13 13:14:29 -08:00
fix indentation
This commit is contained in:
@@ -37,8 +37,8 @@ int mfconn_api_folder_create(mfconn * conn, const char *parent,
|
|||||||
|
|
||||||
long mfconn_api_folder_get_content(mfconn * conn, int mode,
|
long mfconn_api_folder_get_content(mfconn * conn, int mode,
|
||||||
mffolder * folder_curr,
|
mffolder * folder_curr,
|
||||||
mffolder ***folder_result,
|
mffolder *** folder_result,
|
||||||
mffile ***file_result);
|
mffile *** file_result);
|
||||||
|
|
||||||
int mfconn_api_folder_get_info(mfconn * conn, mffolder * folder,
|
int mfconn_api_folder_get_info(mfconn * conn, mffolder * folder,
|
||||||
const char *folderkey);
|
const char *folderkey);
|
||||||
@@ -57,7 +57,8 @@ int mfconn_api_user_get_session_token(mfconn * conn,
|
|||||||
|
|
||||||
int mfconn_api_folder_delete(mfconn * conn, const char *folderkey);
|
int mfconn_api_folder_delete(mfconn * conn, const char *folderkey);
|
||||||
|
|
||||||
int mfconn_api_device_get_status(mfconn * conn, uint64_t *revision);
|
int mfconn_api_device_get_status(mfconn * conn,
|
||||||
|
uint64_t * revision);
|
||||||
|
|
||||||
int mfconn_api_device_get_changes(mfconn * conn, uint64_t revision);
|
int mfconn_api_device_get_changes(mfconn * conn, uint64_t revision);
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ static int _decode_device_get_changes(mfhttp * conn, void *user_ptr)
|
|||||||
revision = json_object_get(data, "revision");
|
revision = json_object_get(data, "revision");
|
||||||
|
|
||||||
printf(" %s %s %s\n\r", json_string_value(key),
|
printf(" %s %s %s\n\r", json_string_value(key),
|
||||||
json_string_value(parent), json_string_value(revision));
|
json_string_value(parent), json_string_value(revision));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@@ -109,7 +109,7 @@ static int _decode_device_get_changes(mfhttp * conn, void *user_ptr)
|
|||||||
revision = json_object_get(data, "revision");
|
revision = json_object_get(data, "revision");
|
||||||
|
|
||||||
printf(" %s %s %s\n\r", json_string_value(key),
|
printf(" %s %s %s\n\r", json_string_value(key),
|
||||||
json_string_value(parent), json_string_value(revision));
|
json_string_value(parent), json_string_value(revision));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@@ -130,7 +130,7 @@ static int _decode_device_get_changes(mfhttp * conn, void *user_ptr)
|
|||||||
revision = json_object_get(data, "revision");
|
revision = json_object_get(data, "revision");
|
||||||
|
|
||||||
printf(" %s %s %s\n\r", json_string_value(key),
|
printf(" %s %s %s\n\r", json_string_value(key),
|
||||||
json_string_value(parent), json_string_value(revision));
|
json_string_value(parent), json_string_value(revision));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@@ -151,7 +151,7 @@ static int _decode_device_get_changes(mfhttp * conn, void *user_ptr)
|
|||||||
revision = json_object_get(data, "revision");
|
revision = json_object_get(data, "revision");
|
||||||
|
|
||||||
printf(" %s %s %s\n\r", json_string_value(key),
|
printf(" %s %s %s\n\r", json_string_value(key),
|
||||||
json_string_value(parent), json_string_value(revision));
|
json_string_value(parent), json_string_value(revision));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
static int _decode_device_get_status(mfhttp * conn, void *data);
|
static int _decode_device_get_status(mfhttp * conn, void *data);
|
||||||
|
|
||||||
int mfconn_api_device_get_status(mfconn * conn, uint64_t *revision)
|
int mfconn_api_device_get_status(mfconn * conn, uint64_t * revision)
|
||||||
{
|
{
|
||||||
const char *api_call;
|
const char *api_call;
|
||||||
int retval;
|
int retval;
|
||||||
@@ -43,7 +43,9 @@ int mfconn_api_device_get_status(mfconn * conn, uint64_t *revision)
|
|||||||
"?response_format=json");
|
"?response_format=json");
|
||||||
|
|
||||||
http = http_create();
|
http = http_create();
|
||||||
retval = http_get_buf(http, api_call, _decode_device_get_status, (void *)revision);
|
retval =
|
||||||
|
http_get_buf(http, api_call, _decode_device_get_status,
|
||||||
|
(void *)revision);
|
||||||
http_destroy(http);
|
http_destroy(http);
|
||||||
|
|
||||||
free((void *)api_call);
|
free((void *)api_call);
|
||||||
@@ -59,7 +61,7 @@ static int _decode_device_get_status(mfhttp * conn, void *data)
|
|||||||
json_t *device_revision;
|
json_t *device_revision;
|
||||||
uint64_t *revision;
|
uint64_t *revision;
|
||||||
|
|
||||||
revision = (uint64_t*)data;
|
revision = (uint64_t *) data;
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -69,7 +71,8 @@ static int _decode_device_get_status(mfhttp * conn, void *data)
|
|||||||
|
|
||||||
device_revision = json_object_get(node, "device_revision");
|
device_revision = json_object_get(node, "device_revision");
|
||||||
if (device_revision != NULL) {
|
if (device_revision != NULL) {
|
||||||
fprintf(stderr, "device_revision: %s\n", json_string_value(device_revision));
|
fprintf(stderr, "device_revision: %s\n",
|
||||||
|
json_string_value(device_revision));
|
||||||
*revision = atoll(json_string_value(device_revision));
|
*revision = atoll(json_string_value(device_revision));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ static int _decode_folder_get_content_files(mfhttp * conn, void *data);
|
|||||||
* values.
|
* values.
|
||||||
*/
|
*/
|
||||||
long
|
long
|
||||||
mfconn_api_folder_get_content(mfconn * conn, int mode, mffolder * folder_curr, mffolder ***mffolder_result, mffile ***mffile_result)
|
mfconn_api_folder_get_content(mfconn * conn, int mode, mffolder * folder_curr,
|
||||||
|
mffolder *** mffolder_result,
|
||||||
|
mffile *** mffile_result)
|
||||||
{
|
{
|
||||||
const char *api_call;
|
const char *api_call;
|
||||||
int retval;
|
int retval;
|
||||||
@@ -76,11 +78,13 @@ mfconn_api_folder_get_content(mfconn * conn, int mode, mffolder * folder_curr, m
|
|||||||
if (mode == 0)
|
if (mode == 0)
|
||||||
retval =
|
retval =
|
||||||
http_get_buf(http, api_call,
|
http_get_buf(http, api_call,
|
||||||
_decode_folder_get_content_folders, (void *)mffolder_result);
|
_decode_folder_get_content_folders,
|
||||||
|
(void *)mffolder_result);
|
||||||
else
|
else
|
||||||
retval =
|
retval =
|
||||||
http_get_buf(http, api_call,
|
http_get_buf(http, api_call,
|
||||||
_decode_folder_get_content_files, (void *)mffile_result);
|
_decode_folder_get_content_files,
|
||||||
|
(void *)mffile_result);
|
||||||
http_destroy(http);
|
http_destroy(http);
|
||||||
|
|
||||||
free((void *)api_call);
|
free((void *)api_call);
|
||||||
@@ -110,7 +114,7 @@ static int _decode_folder_get_content_folders(mfhttp * conn, void *user_ptr)
|
|||||||
mffolder *tmp_folder;
|
mffolder *tmp_folder;
|
||||||
size_t len_mffolder_result;
|
size_t len_mffolder_result;
|
||||||
|
|
||||||
mffolder_result = (mffolder ***)user_ptr;
|
mffolder_result = (mffolder ***) user_ptr;
|
||||||
if (mffolder_result == NULL)
|
if (mffolder_result == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -145,7 +149,8 @@ static int _decode_folder_get_content_folders(mfhttp * conn, void *user_ptr)
|
|||||||
|
|
||||||
j_obj = json_object_get(data, "revision");
|
j_obj = json_object_get(data, "revision");
|
||||||
if (j_obj != NULL) {
|
if (j_obj != NULL) {
|
||||||
folder_set_revision(tmp_folder, atoll(json_string_value(j_obj)));
|
folder_set_revision(tmp_folder,
|
||||||
|
atoll(json_string_value(j_obj)));
|
||||||
}
|
}
|
||||||
|
|
||||||
j_obj = json_object_get(data, "parent");
|
j_obj = json_object_get(data, "parent");
|
||||||
@@ -164,8 +169,9 @@ static int _decode_folder_get_content_folders(mfhttp * conn, void *user_ptr)
|
|||||||
|
|
||||||
len_mffolder_result++;
|
len_mffolder_result++;
|
||||||
*mffolder_result =
|
*mffolder_result =
|
||||||
(mffolder**)realloc(*mffolder_result,
|
(mffolder **) realloc(*mffolder_result,
|
||||||
len_mffolder_result*sizeof(mffolder*));
|
len_mffolder_result *
|
||||||
|
sizeof(mffolder *));
|
||||||
(*mffolder_result)[len_mffolder_result - 1] = tmp_folder;
|
(*mffolder_result)[len_mffolder_result - 1] = tmp_folder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,9 +179,11 @@ static int _decode_folder_get_content_folders(mfhttp * conn, void *user_ptr)
|
|||||||
|
|
||||||
// append an terminating empty mffolder
|
// append an terminating empty mffolder
|
||||||
len_mffolder_result++;
|
len_mffolder_result++;
|
||||||
*mffolder_result = (mffolder**)realloc(*mffolder_result, len_mffolder_result*sizeof(mffolder*));
|
*mffolder_result =
|
||||||
|
(mffolder **) realloc(*mffolder_result,
|
||||||
|
len_mffolder_result * sizeof(mffolder *));
|
||||||
// write an empty last element
|
// write an empty last element
|
||||||
(*mffolder_result)[len_mffolder_result-1] = NULL;
|
(*mffolder_result)[len_mffolder_result - 1] = NULL;
|
||||||
|
|
||||||
if (root != NULL)
|
if (root != NULL)
|
||||||
json_decref(root);
|
json_decref(root);
|
||||||
@@ -205,7 +213,7 @@ static int _decode_folder_get_content_files(mfhttp * conn, void *user_ptr)
|
|||||||
mffile *tmp_file;
|
mffile *tmp_file;
|
||||||
size_t len_mffile_result;
|
size_t len_mffile_result;
|
||||||
|
|
||||||
mffile_result = (mffile ***)user_ptr;
|
mffile_result = (mffile ***) user_ptr;
|
||||||
if (mffile_result == NULL)
|
if (mffile_result == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -241,7 +249,7 @@ static int _decode_folder_get_content_files(mfhttp * conn, void *user_ptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
j_obj = json_object_get(data, "created");
|
j_obj = json_object_get(data, "created");
|
||||||
if (j_obj != NULL ) {
|
if (j_obj != NULL) {
|
||||||
memset(&tm, 0, sizeof(struct tm));
|
memset(&tm, 0, sizeof(struct tm));
|
||||||
ret = strptime(json_string_value(j_obj), "%F %T", &tm);
|
ret = strptime(json_string_value(j_obj), "%F %T", &tm);
|
||||||
if (ret[0] == '\0') {
|
if (ret[0] == '\0') {
|
||||||
@@ -251,9 +259,9 @@ static int _decode_folder_get_content_files(mfhttp * conn, void *user_ptr)
|
|||||||
|
|
||||||
j_obj = json_object_get(data, "revision");
|
j_obj = json_object_get(data, "revision");
|
||||||
if (j_obj != NULL) {
|
if (j_obj != NULL) {
|
||||||
file_set_revision(tmp_file, atoll(json_string_value(j_obj)));
|
file_set_revision(tmp_file,
|
||||||
|
atoll(json_string_value(j_obj)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME don't save hex ascii string but binary chars instead
|
// FIXME don't save hex ascii string but binary chars instead
|
||||||
j_obj = json_object_get(data, "hash");
|
j_obj = json_object_get(data, "hash");
|
||||||
if (j_obj != NULL) {
|
if (j_obj != NULL) {
|
||||||
@@ -262,8 +270,8 @@ static int _decode_folder_get_content_files(mfhttp * conn, void *user_ptr)
|
|||||||
|
|
||||||
len_mffile_result++;
|
len_mffile_result++;
|
||||||
*mffile_result =
|
*mffile_result =
|
||||||
(mffile**)realloc(*mffile_result,
|
(mffile **) realloc(*mffile_result,
|
||||||
len_mffile_result*sizeof(mffile*));
|
len_mffile_result * sizeof(mffile *));
|
||||||
(*mffile_result)[len_mffile_result - 1] = tmp_file;
|
(*mffile_result)[len_mffile_result - 1] = tmp_file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -271,7 +279,9 @@ static int _decode_folder_get_content_files(mfhttp * conn, void *user_ptr)
|
|||||||
|
|
||||||
// append a terminating empty file
|
// append a terminating empty file
|
||||||
len_mffile_result++;
|
len_mffile_result++;
|
||||||
*mffile_result = (mffile**)realloc(*mffile_result, len_mffile_result*sizeof(mffile*));
|
*mffile_result =
|
||||||
|
(mffile **) realloc(*mffile_result,
|
||||||
|
len_mffile_result * sizeof(mffile *));
|
||||||
// write an empty last element
|
// write an empty last element
|
||||||
(*mffile_result)[len_mffile_result - 1] = NULL;
|
(*mffile_result)[len_mffile_result - 1] = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -42,15 +42,16 @@ int mfshell_cmd_list(mfshell * mfshell, int argc, char *const argv[])
|
|||||||
fprintf(stderr, "Invalid number of arguments\n");
|
fprintf(stderr, "Invalid number of arguments\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// first folders
|
// first folders
|
||||||
folder_result = NULL;
|
folder_result = NULL;
|
||||||
retval =
|
retval =
|
||||||
mfconn_api_folder_get_content(mfshell->conn, 0, mfshell->folder_curr, &folder_result, NULL);
|
mfconn_api_folder_get_content(mfshell->conn, 0, mfshell->folder_curr,
|
||||||
|
&folder_result, NULL);
|
||||||
mfconn_update_secret_key(mfshell->conn);
|
mfconn_update_secret_key(mfshell->conn);
|
||||||
|
|
||||||
for (i = 0; folder_result[i] != NULL; i++) {
|
for (i = 0; folder_result[i] != NULL; i++) {
|
||||||
printf("%s %s\n", folder_get_name(folder_result[i]), folder_get_key(folder_result[i]));
|
printf("%s %s\n", folder_get_name(folder_result[i]),
|
||||||
|
folder_get_key(folder_result[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; folder_result[i] != NULL; i++) {
|
for (i = 0; folder_result[i] != NULL; i++) {
|
||||||
@@ -61,11 +62,13 @@ int mfshell_cmd_list(mfshell * mfshell, int argc, char *const argv[])
|
|||||||
// then files
|
// then files
|
||||||
file_result = NULL;
|
file_result = NULL;
|
||||||
retval =
|
retval =
|
||||||
mfconn_api_folder_get_content(mfshell->conn, 1, mfshell->folder_curr, NULL, &file_result);
|
mfconn_api_folder_get_content(mfshell->conn, 1, mfshell->folder_curr,
|
||||||
|
NULL, &file_result);
|
||||||
mfconn_update_secret_key(mfshell->conn);
|
mfconn_update_secret_key(mfshell->conn);
|
||||||
|
|
||||||
for (i = 0; file_result[i] != NULL; i++) {
|
for (i = 0; file_result[i] != NULL; i++) {
|
||||||
printf("%s %s\n", file_get_name(file_result[i]), file_get_key(file_result[i]));
|
printf("%s %s\n", file_get_name(file_result[i]),
|
||||||
|
file_get_key(file_result[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; file_result[i] != NULL; i++) {
|
for (i = 0; file_result[i] != NULL; i++) {
|
||||||
|
|||||||
@@ -51,7 +51,8 @@ struct mfcmd commands[] = {
|
|||||||
{"get", "[quickkey]", "download a file", mfshell_cmd_get},
|
{"get", "[quickkey]", "download a file", mfshell_cmd_get},
|
||||||
{"rmdir", "[folderkey]", "remove directory", mfshell_cmd_rmdir},
|
{"rmdir", "[folderkey]", "remove directory", mfshell_cmd_rmdir},
|
||||||
{"status", "", "device status", mfshell_cmd_status},
|
{"status", "", "device status", mfshell_cmd_status},
|
||||||
{"changes", "<revision>", "device changes (default: 0)", mfshell_cmd_changes},
|
{"changes", "<revision>", "device changes (default: 0)",
|
||||||
|
mfshell_cmd_changes},
|
||||||
{NULL, NULL, NULL, NULL}
|
{NULL, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user