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:
josch
2014-09-20 10:59:54 +02:00
parent d8e00119b4
commit 097a855751
43 changed files with 1325 additions and 1278 deletions

View File

@@ -17,7 +17,6 @@
*
*/
#ifndef _MFAPI_APICALLS_H_
#define _MFAPI_APICALLS_H_
@@ -27,20 +26,29 @@
#include "folder.h"
#include "mfconn.h"
int mfconn_api_file_get_info(mfconn *conn, mffile *file, char *quickkey);
int mfconn_api_file_get_info(mfconn * conn, mffile * file,
char *quickkey);
int mfconn_api_file_get_links(mfconn *conn, mffile *file, char *quickkey);
int mfconn_api_file_get_links(mfconn * conn, mffile * file,
char *quickkey);
int mfconn_api_folder_create(mfconn *conn, char *parent, char *name);
int mfconn_api_folder_create(mfconn * conn, char *parent,
char *name);
long mfconn_api_folder_get_content(mfconn *conn, int mode, mffolder *folder_curr);
long mfconn_api_folder_get_content(mfconn * conn, int mode,
mffolder * folder_curr);
int mfconn_api_folder_get_info(mfconn *conn, mffolder *folder, char *folderkey);
int mfconn_api_folder_get_info(mfconn * conn, mffolder * folder,
char *folderkey);
int mfconn_api_user_get_info(mfconn *conn);
int mfconn_api_user_get_info(mfconn * conn);
int mfconn_api_user_get_session_token(mfconn *conn, char *server,
char *username, char *password, int app_id, char *app_key,
uint32_t *secret_key, char **secret_time, char **session_token);
int mfconn_api_user_get_session_token(mfconn * conn, char *server,
char *username,
char *password, int app_id,
char *app_key,
uint32_t * secret_key,
char **secret_time,
char **session_token);
#endif

View File

@@ -17,7 +17,6 @@
*
*/
#include <jansson.h>
#include <stdio.h>
#include <string.h>
@@ -26,76 +25,80 @@
#include "../../utils/json.h"
#include "../mfconn.h"
#include "../file.h"
#include "../apicalls.h" // IWYU pragma: keep
#include "../apicalls.h" // IWYU pragma: keep
static int
_decode_file_get_info(mfhttp *conn, void *data);
static int _decode_file_get_info(mfhttp * conn, void *data);
int
mfconn_api_file_get_info(mfconn *conn,mffile *file,char *quickkey)
int mfconn_api_file_get_info(mfconn * conn, mffile * file, char *quickkey)
{
char *api_call;
int retval;
int len;
char *api_call;
int retval;
int len;
mfhttp *http;
if(conn == NULL) return -1;
if (conn == NULL)
return -1;
if(file == NULL) return -1;
if(quickkey == NULL) return -1;
if (file == NULL)
return -1;
if (quickkey == NULL)
return -1;
len = strlen(quickkey);
// key must either be 11 or 15 chars
if(len != 11 && len != 15) return -1;
if (len != 11 && len != 15)
return -1;
api_call = mfconn_create_signed_get(conn, 1, "file/get_info.php",
"?quick_key=%s&response_format=json", quickkey);
"?quick_key=%s&response_format=json",
quickkey);
mfhttp *http = http_create();
http = http_create();
retval = http_get_buf(http, api_call, _decode_file_get_info, file);
http_destroy(http);
return retval;
}
static int
_decode_file_get_info(mfhttp *conn, void *data)
static int _decode_file_get_info(mfhttp * conn, void *data)
{
json_error_t error;
json_t *root;
json_t *node;
json_t *quickkey;
json_t *file_hash;
json_t *file_name;
json_t *root;
json_t *node;
json_t *quickkey;
json_t *file_hash;
json_t *file_name;
int retval = 0;
mffile *file;
if(data == NULL) return -1;
if (data == NULL)
return -1;
file = (mffile *)data;
file = (mffile *) data;
root = http_parse_buf_json(conn, 0, &error);
node = json_object_by_path(root,"response/file_info");
node = json_object_by_path(root, "response/file_info");
quickkey = json_object_get(node,"quickkey");
if(quickkey != NULL)
file_set_key(file,(char*)json_string_value(quickkey));
quickkey = json_object_get(node, "quickkey");
if (quickkey != NULL)
file_set_key(file, (char *)json_string_value(quickkey));
file_name = json_object_get(node,"filename");
if(file_name != NULL)
file_set_name(file,(char*)json_string_value(file_name));
file_name = json_object_get(node, "filename");
if (file_name != NULL)
file_set_name(file, (char *)json_string_value(file_name));
file_hash = json_object_get(node,"hash");
if(file_hash != NULL)
{
file_set_hash(file,(char*)json_string_value(file_hash));
file_hash = json_object_get(node, "hash");
if (file_hash != NULL) {
file_set_hash(file, (char *)json_string_value(file_hash));
}
if(quickkey == NULL) retval = -1;
if (quickkey == NULL)
retval = -1;
if(root != NULL) json_decref(root);
if (root != NULL)
json_decref(root);
return retval;
}

View File

@@ -17,7 +17,6 @@
*
*/
#include <jansson.h>
#include <stdio.h>
#include <string.h>
@@ -26,95 +25,95 @@
#include "../../utils/json.h"
#include "../mfconn.h"
#include "../file.h"
#include "../apicalls.h" // IWYU pragma: keep
#include "../apicalls.h" // IWYU pragma: keep
static int
_decode_file_get_links(mfhttp *conn, void *data);
static int _decode_file_get_links(mfhttp * conn, void *data);
int
mfconn_api_file_get_links(mfconn *conn,mffile *file,char *quickkey)
int mfconn_api_file_get_links(mfconn * conn, mffile * file, char *quickkey)
{
char *api_call;
int retval;
int len;
char *api_call;
int retval;
int len;
mfhttp *http;
if(conn == NULL) return -1;
if (conn == NULL)
return -1;
if(file == NULL) return -1;
if(quickkey == NULL) return -1;
if (file == NULL)
return -1;
if (quickkey == NULL)
return -1;
len = strlen(quickkey);
// key must either be 11 or 15 chars
if(len != 11 && len != 15) return -1;
if (len != 11 && len != 15)
return -1;
api_call = mfconn_create_signed_get(conn,0,"file/get_links.php",
"?quick_key=%s&response_format=json", quickkey);
api_call = mfconn_create_signed_get(conn, 0, "file/get_links.php",
"?quick_key=%s&response_format=json",
quickkey);
mfhttp *http = http_create();
http = http_create();
retval = http_get_buf(http, api_call, _decode_file_get_links, file);
http_destroy(http);
return retval;
}
static int
_decode_file_get_links(mfhttp *conn, void *data)
static int _decode_file_get_links(mfhttp * conn, void *data)
{
json_error_t error;
json_t *root;
json_t *node;
json_t *quickkey;
json_t *share_link;
json_t *direct_link;
json_t *onetime_link;
json_t *links_array;
json_t *root;
json_t *node;
json_t *quickkey;
json_t *share_link;
json_t *direct_link;
json_t *onetime_link;
json_t *links_array;
int retval = 0;
mffile *file;
if(data == NULL) return -1;
if (data == NULL)
return -1;
file = (mffile *)data;
file = (mffile *) data;
root = http_parse_buf_json(conn, 0, &error);
node = json_object_by_path(root,"response");
node = json_object_by_path(root, "response");
links_array = json_object_get(node,"links");
if(!json_is_array(links_array))
{
links_array = json_object_get(node, "links");
if (!json_is_array(links_array)) {
json_decref(root);
return -1;
}
// just get the first one. maybe later support multi-quickkey
node = json_array_get(links_array,0);
node = json_array_get(links_array, 0);
quickkey = json_object_get(node,"quickkey");
if(quickkey != NULL)
file_set_key(file,(char*)json_string_value(quickkey));
quickkey = json_object_get(node, "quickkey");
if (quickkey != NULL)
file_set_key(file, (char *)json_string_value(quickkey));
share_link = json_object_get(node,"normal_download");
if(share_link != NULL)
file_set_share_link(file,(char*)json_string_value(share_link));
share_link = json_object_get(node, "normal_download");
if (share_link != NULL)
file_set_share_link(file, (char *)json_string_value(share_link));
direct_link = json_object_get(node,"direct_download");
if(direct_link != NULL)
{
file_set_direct_link(file,(char*)json_string_value(direct_link));
direct_link = json_object_get(node, "direct_download");
if (direct_link != NULL) {
file_set_direct_link(file, (char *)json_string_value(direct_link));
}
onetime_link = json_object_get(node,"one_time_download");
if(onetime_link != NULL)
{
file_set_onetime_link(file,(char*)json_string_value(onetime_link));
onetime_link = json_object_get(node, "one_time_download");
if (onetime_link != NULL) {
file_set_onetime_link(file, (char *)json_string_value(onetime_link));
}
// if this is false something went horribly wrong
if(share_link == NULL) retval = -1;
if (share_link == NULL)
retval = -1;
if(root != NULL) json_decref(root);
if (root != NULL)
json_decref(root);
return retval;
}

View File

@@ -17,53 +17,51 @@
*
*/
#include <stdio.h>
#include <string.h>
#include "../../utils/http.h"
#include "../mfconn.h"
#include "../apicalls.h" // IWYU pragma: keep
#include "../apicalls.h" // IWYU pragma: keep
int
mfconn_api_folder_create(mfconn *conn,char *parent,char *name)
int mfconn_api_folder_create(mfconn * conn, char *parent, char *name)
{
char *api_call;
int retval;
char *api_call;
int retval;
mfhttp *http;
if(conn == NULL) return -1;
if (conn == NULL)
return -1;
if(name == NULL) return -1;
if(strlen(name) < 1) return -1;
if (name == NULL)
return -1;
if (strlen(name) < 1)
return -1;
// key must either be 11 chars or "myfiles"
if(parent != NULL)
{
if(strlen(parent) != 13)
{
if (parent != NULL) {
if (strlen(parent) != 13) {
// if it is myfiles, set paret to NULL
if(strcmp(parent,"myfiles") == 0) parent = NULL;
if (strcmp(parent, "myfiles") == 0)
parent = NULL;
}
}
if(parent != NULL)
{
api_call = mfconn_create_signed_get(conn,0,"folder/create.php",
"?parent_key=%s"
"&foldername=%s"
"&response_format=json",
parent,name);
}
else
{
api_call = mfconn_create_signed_get(conn,0,"folder/create.php",
"?foldername=%s&response_format=json", name);
if (parent != NULL) {
api_call =
mfconn_create_signed_get(conn, 0, "folder/create.php",
"?parent_key=%s" "&foldername=%s"
"&response_format=json", parent, name);
} else {
api_call =
mfconn_create_signed_get(conn, 0, "folder/create.php",
"?foldername=%s&response_format=json",
name);
}
mfhttp *http = http_create();
http = http_create();
retval = http_get_buf(http, api_call, NULL, NULL);
http_destroy(http);
return retval;
}

View File

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

View File

@@ -17,7 +17,6 @@
*
*/
#include <jansson.h>
#include <stdio.h>
#include <string.h>
@@ -26,79 +25,83 @@
#include "../../utils/json.h"
#include "../folder.h"
#include "../mfconn.h"
#include "../apicalls.h" // IWYU pragma: keep
#include "../apicalls.h" // IWYU pragma: keep
static int
_decode_folder_get_info(mfhttp *conn, void *data);
static int _decode_folder_get_info(mfhttp * conn, void *data);
int
mfconn_api_folder_get_info(mfconn *conn,mffolder *folder,char *folderkey)
mfconn_api_folder_get_info(mfconn * conn, mffolder * folder, char *folderkey)
{
char *api_call;
int retval;
char *api_call;
int retval;
mfhttp *http;
if(conn == NULL) return -1;
if (conn == NULL)
return -1;
if(folder == NULL) return -1;
if(folderkey == NULL) return -1;
if (folder == NULL)
return -1;
if (folderkey == NULL)
return -1;
// key must either be 11 chars or "myfiles"
if(strlen(folderkey) != 13)
{
if(strcmp(folderkey,"myfiles") == 0) return -1;
if (strlen(folderkey) != 13) {
if (strcmp(folderkey, "myfiles") == 0)
return -1;
}
api_call = mfconn_create_signed_get(conn,0,"folder/get_info.php",
"?folder_key=%s&response_format=json", folderkey);
api_call = mfconn_create_signed_get(conn, 0, "folder/get_info.php",
"?folder_key=%s&response_format=json",
folderkey);
mfhttp *http = http_create();
http = http_create();
retval = http_get_buf(http, api_call, _decode_folder_get_info, folder);
http_destroy(http);
return retval;
}
static int
_decode_folder_get_info(mfhttp *conn, void *data)
static int _decode_folder_get_info(mfhttp * conn, void *data)
{
json_error_t error;
json_t *root;
json_t *node;
json_t *folderkey;
json_t *folder_name;
json_t *parent_folder;
json_t *root;
json_t *node;
json_t *folderkey;
json_t *folder_name;
json_t *parent_folder;
int retval = 0;
mffolder *folder;
if(data == NULL) return -1;
if (data == NULL)
return -1;
folder = (mffolder *)data;
folder = (mffolder *) data;
root = http_parse_buf_json(conn, 0, &error);
node = json_object_by_path(root,"response/folder_info");
node = json_object_by_path(root, "response/folder_info");
folderkey = json_object_get(node,"folderkey");
if(folderkey != NULL)
folder_set_key(folder,(char*)json_string_value(folderkey));
folderkey = json_object_get(node, "folderkey");
if (folderkey != NULL)
folder_set_key(folder, (char *)json_string_value(folderkey));
folder_name = json_object_get(node,"name");
if(folder_name != NULL)
folder_set_name(folder,(char*)json_string_value(folder_name));
folder_name = json_object_get(node, "name");
if (folder_name != NULL)
folder_set_name(folder, (char *)json_string_value(folder_name));
parent_folder = json_object_get(node,"parent_folderkey");
if(parent_folder != NULL)
{
folder_set_parent(folder,(char*)json_string_value(parent_folder));
parent_folder = json_object_get(node, "parent_folderkey");
if (parent_folder != NULL) {
folder_set_parent(folder, (char *)json_string_value(parent_folder));
}
// infer that the parent folder must be "myfiles" root
if(parent_folder == NULL && folderkey != NULL)
folder_set_parent(folder,"myfiles");
if (parent_folder == NULL && folderkey != NULL)
folder_set_parent(folder, "myfiles");
if(folderkey == NULL) retval = -1;
if (folderkey == NULL)
retval = -1;
if(root != NULL) json_decref(root);
if (root != NULL)
json_decref(root);
return retval;
}

View File

@@ -17,69 +17,69 @@
*
*/
#include <jansson.h>
#include <stdio.h>
#include "../../utils/http.h"
#include "../../utils/json.h"
#include "../mfconn.h"
#include "../apicalls.h" // IWYU pragma: keep
#include "../apicalls.h" // IWYU pragma: keep
static int
_decode_user_get_info(mfhttp *conn, void *data);
static int _decode_user_get_info(mfhttp * conn, void *data);
int
mfconn_api_user_get_info(mfconn *conn)
int mfconn_api_user_get_info(mfconn * conn)
{
char *api_call;
int retval;
char *api_call;
int retval;
mfhttp *http;
// char *rx_buffer;
if(conn == NULL) return -1;
if (conn == NULL)
return -1;
api_call = mfconn_create_signed_get(conn,0,"user/get_info.php",
"&response_format=json");
api_call = mfconn_create_signed_get(conn, 0, "user/get_info.php",
"&response_format=json");
mfhttp* http = http_create();
http = http_create();
retval = http_get_buf(http, api_call, _decode_user_get_info, NULL);
http_destroy(http);
return retval;
}
static int
_decode_user_get_info(mfhttp *conn, void *data)
static int _decode_user_get_info(mfhttp * conn, void *data)
{
json_error_t error;
json_t *root;
json_t *node;
json_t *email;
json_t *first_name;
json_t *last_name;
json_t *root;
json_t *node;
json_t *email;
json_t *first_name;
json_t *last_name;
if (data != NULL)
return -1;
root = http_parse_buf_json(conn, 0, &error);
node = json_object_by_path(root,"response/user_info");
node = json_object_by_path(root, "response/user_info");
email = json_object_get(node,"email");
if(email != NULL)
printf("Email: %s\n\r",(char*)json_string_value(email));
email = json_object_get(node, "email");
if (email != NULL)
printf("Email: %s\n\r", (char *)json_string_value(email));
first_name = json_object_get(node,"first_name");
if(first_name != NULL)
printf("Name: %s ",(char*)json_string_value(first_name));
first_name = json_object_get(node, "first_name");
if (first_name != NULL)
printf("Name: %s ", (char *)json_string_value(first_name));
last_name = json_object_get(node,"last_name");
if(node != NULL)
printf("%s",(char*)json_string_value(last_name));
last_name = json_object_get(node, "last_name");
if (node != NULL)
printf("%s", (char *)json_string_value(last_name));
printf("\n\r");
if(root != NULL) json_decref(root);
if (root != NULL)
json_decref(root);
return 0;
}

View File

@@ -17,7 +17,6 @@
*
*/
#include <jansson.h>
#include <stdint.h>
#include <stdio.h>
@@ -28,49 +27,53 @@
#include "../../utils/json.h"
#include "../../utils/strings.h"
#include "../mfconn.h"
#include "../apicalls.h" // IWYU pragma: keep
#include "../apicalls.h" // IWYU pragma: keep
static int
_decode_get_session_token(mfhttp *conn, void *data);
static int _decode_get_session_token(mfhttp * conn, void *data);
struct user_get_session_token_response
{
uint32_t secret_key;
char *secret_time;
char *session_token;
struct user_get_session_token_response {
uint32_t secret_key;
char *secret_time;
char *session_token;
};
int
mfconn_api_user_get_session_token(mfconn *conn, char *server,
char *username, char *password, int app_id, char *app_key,
uint32_t *secret_key, char **secret_time, char **session_token)
mfconn_api_user_get_session_token(mfconn * conn, char *server,
char *username, char *password,
int app_id, char *app_key,
uint32_t * secret_key,
char **secret_time, char **session_token)
{
char *login_url;
char *post_args;
char *user_signature;
int retval;
char *login_url;
char *post_args;
char *user_signature;
int retval;
struct user_get_session_token_response response;
mfhttp *http;
if(conn == NULL) return -1;
if (conn == NULL)
return -1;
// configure url for operation
login_url = strdup_printf("https://%s/api/user/get_session_token.php",
server);
server);
// create user signature
user_signature = mfconn_create_user_signature(conn, username, password, app_id, app_key);
user_signature =
mfconn_create_user_signature(conn, username, password, app_id, app_key);
post_args = strdup_printf(
"email=%s"
"&password=%s"
"&application_id=35860"
"&signature=%s"
"&token_version=2"
"&response_format=json",
username, password, user_signature);
post_args = strdup_printf("email=%s"
"&password=%s"
"&application_id=35860"
"&signature=%s"
"&token_version=2"
"&response_format=json",
username, password, user_signature);
mfhttp *http = http_create();
retval = http_post_buf(http, login_url, post_args, _decode_get_session_token, (void *)(&response));
http = http_create();
retval =
http_post_buf(http, login_url, post_args,
_decode_get_session_token, (void *)(&response));
http_destroy(http);
free(login_url);
@@ -83,48 +86,49 @@ mfconn_api_user_get_session_token(mfconn *conn, char *server,
return retval;
}
static int
_decode_get_session_token(mfhttp *conn, void *user_ptr)
static int _decode_get_session_token(mfhttp * conn, void *user_ptr)
{
json_error_t error;
json_t *root = NULL;
json_t *data;
json_t *session_token;
json_t *secret_key;
json_t *secret_time;
json_t *root = NULL;
json_t *data;
json_t *session_token;
json_t *secret_key;
json_t *secret_time;
struct user_get_session_token_response *response;
if(user_ptr == NULL) return -1;
if (user_ptr == NULL)
return -1;
response = (struct user_get_session_token_response *)user_ptr;
root = http_parse_buf_json(conn, 0, &error);
data = json_object_by_path(root,"response");
if(data == NULL) return -1;
data = json_object_by_path(root, "response");
if (data == NULL)
return -1;
session_token = json_object_get(data,"session_token");
if(session_token == NULL)
{
session_token = json_object_get(data, "session_token");
if (session_token == NULL) {
json_decref(root);
return -1;
}
response->session_token = strdup(json_string_value(session_token));
secret_key = json_object_get(data,"secret_key");
if(secret_key != NULL)
secret_key = json_object_get(data, "secret_key");
if (secret_key != NULL)
response->secret_key = atoll(json_string_value(secret_key));
/*
time looks like a float but we must store it as a string to
remain congruent with the server on decimal place presentation.
*/
secret_time = json_object_get(data,"time");
if(secret_time != NULL)
response->secret_time = strdup(json_string_value(secret_time));
time looks like a float but we must store it as a string to
remain congruent with the server on decimal place presentation.
*/
secret_time = json_object_get(data, "time");
if (secret_time != NULL)
response->secret_time = strdup(json_string_value(secret_time));
if(root != NULL) json_decref(root);
if (root != NULL)
json_decref(root);
return 0;
}

View File

@@ -17,7 +17,6 @@
*
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -29,122 +28,128 @@
#include "../utils/strings.h"
#include "file.h"
struct mffile {
char quickkey[18];
char hash[65];
char name[256];
char mtime[16];
uint64_t revision;
struct mffile
{
char quickkey[18];
char hash[65];
char name[256];
char mtime[16];
uint64_t revision;
char *share_link;
char *direct_link;
char *onetime_link;
char *share_link;
char *direct_link;
char *onetime_link;
};
mffile*
file_alloc(void)
mffile *file_alloc(void)
{
mffile *file;
mffile *file;
file = (mffile*)calloc(1,sizeof(mffile));
file = (mffile *) calloc(1, sizeof(mffile));
return file;
}
void
file_free(mffile *file)
void file_free(mffile * file)
{
if(file == NULL) return;
if (file == NULL)
return;
if(file->share_link != NULL) free(file->share_link);
if(file->direct_link != NULL) free(file->direct_link);
if(file->onetime_link != NULL) free(file->onetime_link);
if (file->share_link != NULL)
free(file->share_link);
if (file->direct_link != NULL)
free(file->direct_link);
if (file->onetime_link != NULL)
free(file->onetime_link);
free(file);
return;
}
int
file_set_key(mffile *file,const char *key)
int file_set_key(mffile * file, const char *key)
{
int len;
int len;
if(file == NULL) return -1;
if(key == NULL) return -1;
if (file == NULL)
return -1;
if (key == NULL)
return -1;
len = strlen(key);
if(len != 11 && len != 15) return -1;
if (len != 11 && len != 15)
return -1;
memset(file->quickkey,0,sizeof(file->quickkey));
strncpy(file->quickkey,key,sizeof(file->quickkey) - 1);
memset(file->quickkey, 0, sizeof(file->quickkey));
strncpy(file->quickkey, key, sizeof(file->quickkey) - 1);
return 0;
}
const char*
file_get_key(mffile *file)
const char *file_get_key(mffile * file)
{
if(file == NULL) return NULL;
if (file == NULL)
return NULL;
return file->quickkey;
}
int
file_set_hash(mffile *file,const char *hash)
int file_set_hash(mffile * file, const char *hash)
{
if(file == NULL) return -1;
if(hash == NULL) return -1;
if (file == NULL)
return -1;
if (hash == NULL)
return -1;
// system supports SHA256 (current) and MD5 (legacy)
if(strlen(hash) < 32) return -1;
if (strlen(hash) < 32)
return -1;
memset(file->hash,0,sizeof(file->hash));
strncpy(file->hash,hash,sizeof(file->hash) - 1);
memset(file->hash, 0, sizeof(file->hash));
strncpy(file->hash, hash, sizeof(file->hash) - 1);
return 0;
}
const char*
file_get_hash(mffile *file)
const char *file_get_hash(mffile * file)
{
if(file == NULL) return NULL;
if (file == NULL)
return NULL;
return file->hash;
}
int
file_set_name(mffile *file,const char *name)
int file_set_name(mffile * file, const char *name)
{
if(file == NULL) return -1;
if(name == NULL) return -1;
if (file == NULL)
return -1;
if (name == NULL)
return -1;
if(strlen(name) > 255) return -1;
if (strlen(name) > 255)
return -1;
memset(file->name,0,sizeof(file->name));
strncpy(file->name,name,sizeof(file->name) - 1);
memset(file->name, 0, sizeof(file->name));
strncpy(file->name, name, sizeof(file->name) - 1);
return 0;
}
const char*
file_get_name(mffile *file)
const char *file_get_name(mffile * file)
{
if(file == NULL) return NULL;
if (file == NULL)
return NULL;
return file->name;
}
int
file_set_share_link(mffile *file,const char *share_link)
int file_set_share_link(mffile * file, const char *share_link)
{
if(file == NULL) return -1;
if(share_link == NULL) return -1;
if (file == NULL)
return -1;
if (share_link == NULL)
return -1;
if(file->share_link != NULL)
{
if (file->share_link != NULL) {
free(file->share_link);
file->share_link = NULL;
}
@@ -154,22 +159,22 @@ file_set_share_link(mffile *file,const char *share_link)
return 0;
}
const char*
file_get_share_link(mffile *file)
const char *file_get_share_link(mffile * file)
{
if(file == NULL) return NULL;
if (file == NULL)
return NULL;
return file->share_link;
}
int
file_set_direct_link(mffile *file,const char *direct_link)
int file_set_direct_link(mffile * file, const char *direct_link)
{
if(file == NULL) return -1;
if(direct_link == NULL) return -1;
if (file == NULL)
return -1;
if (direct_link == NULL)
return -1;
if(file->direct_link != NULL)
{
if (file->direct_link != NULL) {
free(file->direct_link);
file->direct_link = NULL;
}
@@ -179,22 +184,22 @@ file_set_direct_link(mffile *file,const char *direct_link)
return 0;
}
const char*
file_get_direct_link(mffile *file)
const char *file_get_direct_link(mffile * file)
{
if(file == NULL) return NULL;
if (file == NULL)
return NULL;
return file->direct_link;
}
int
file_set_onetime_link(mffile *file,const char *onetime_link)
int file_set_onetime_link(mffile * file, const char *onetime_link)
{
if(file == NULL) return -1;
if(onetime_link == NULL) return -1;
if (file == NULL)
return -1;
if (onetime_link == NULL)
return -1;
if(file->onetime_link != NULL)
{
if (file->onetime_link != NULL) {
free(file->onetime_link);
file->onetime_link = NULL;
}
@@ -204,53 +209,59 @@ file_set_onetime_link(mffile *file,const char *onetime_link)
return 0;
}
const char*
file_get_onetime_link(mffile *file)
const char *file_get_onetime_link(mffile * file)
{
if(file == NULL) return NULL;
if (file == NULL)
return NULL;
return file->onetime_link;
}
ssize_t
file_download_direct(mffile *file, char *local_dir)
ssize_t file_download_direct(mffile * file, char *local_dir)
{
const char *url;
const char *file_name;
char *file_path;
const char *url;
const char *file_name;
char *file_path;
struct stat file_info;
ssize_t bytes_read = 0;
int retval;
mfhttp *conn;
if(file == NULL) return -1;
if(local_dir == NULL) return -1;
if (file == NULL)
return -1;
if (local_dir == NULL)
return -1;
url = file_get_direct_link(file);
if(url == NULL) return -1;
if (url == NULL)
return -1;
file_name = file_get_name(file);
if(file_name == NULL) return -1;
if(strlen(file_name) < 1) return -1;
if (file_name == NULL)
return -1;
if (strlen(file_name) < 1)
return -1;
if(local_dir[strlen(local_dir) - 1] == '/')
file_path = strdup_printf("%s%s",local_dir,file_name);
if (local_dir[strlen(local_dir) - 1] == '/')
file_path = strdup_printf("%s%s", local_dir, file_name);
else
file_path = strdup_printf("%s/%s",local_dir,file_name);
file_path = strdup_printf("%s/%s", local_dir, file_name);
mfhttp *conn = http_create();
conn = http_create();
retval = http_get_file(conn, url, file_path);
http_destroy(conn);
/*
it is preferable to have the vfs tell us how many bytes the
transfer actually is. it's really all that matters.
*/
memset(&file_info,0,sizeof(file_info));
retval = stat(file_path,&file_info);
it is preferable to have the vfs tell us how many bytes the
transfer actually is. it's really all that matters.
*/
memset(&file_info, 0, sizeof(file_info));
retval = stat(file_path, &file_info);
free(file_path);
if(retval != 0) return -1;
if (retval != 0)
return -1;
bytes_read = file_info.st_size;

View File

@@ -24,34 +24,34 @@
typedef struct mffile mffile;
mffile* file_alloc(void);
mffile *file_alloc(void);
void file_free(mffile *file);
void file_free(mffile * file);
int file_set_key(mffile *file,const char *quickkey);
int file_set_key(mffile * file, const char *quickkey);
const char* file_get_key(mffile *file);
const char *file_get_key(mffile * file);
int file_set_hash(mffile *file,const char *hash);
int file_set_hash(mffile * file, const char *hash);
const char* file_get_hash(mffile *file);
const char *file_get_hash(mffile * file);
int file_set_name(mffile *file,const char *name);
int file_set_name(mffile * file, const char *name);
const char* file_get_name(mffile *file);
const char *file_get_name(mffile * file);
int file_set_share_link(mffile *file,const char *share_link);
int file_set_share_link(mffile * file, const char *share_link);
const char* file_get_share_link(mffile *file);
const char *file_get_share_link(mffile * file);
int file_set_direct_link(mffile *file,const char *direct_link);
int file_set_direct_link(mffile * file, const char *direct_link);
const char* file_get_direct_link(mffile *file);
const char *file_get_direct_link(mffile * file);
int file_set_onetime_link(mffile *file,const char *onetime_link);
int file_set_onetime_link(mffile * file, const char *onetime_link);
const char* file_get_onetime_link(mffile *file);
const char *file_get_onetime_link(mffile * file);
ssize_t file_download_direct(mffile *file, char *local_dir);
ssize_t file_download_direct(mffile * file, char *local_dir);
#endif

View File

@@ -17,110 +17,110 @@
*
*/
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "folder.h"
struct mffolder
{
char folderkey[20];
char name[41];
char parent[20];
uint64_t revision;
uint32_t folder_count;
uint32_t file_count;
struct mffolder {
char folderkey[20];
char name[41];
char parent[20];
uint64_t revision;
uint32_t folder_count;
uint32_t file_count;
};
mffolder*
folder_alloc(void)
mffolder *folder_alloc(void)
{
mffolder *folder;
mffolder *folder;
folder = (mffolder*)calloc(1,sizeof(mffolder));
folder = (mffolder *) calloc(1, sizeof(mffolder));
return folder;
}
void
folder_free(mffolder *folder)
void folder_free(mffolder * folder)
{
if(folder == NULL) return;
if (folder == NULL)
return;
free(folder);
return;
}
int
folder_set_key(mffolder *folder,const char *key)
int folder_set_key(mffolder * folder, const char *key)
{
if(folder == NULL) return -1;
if(key == NULL) return -1;
if (folder == NULL)
return -1;
if (key == NULL)
return -1;
if(strlen(key) != 13) return -1;
if (strlen(key) != 13)
return -1;
memset(folder->folderkey,0,sizeof(folder->folderkey));
strncpy(folder->folderkey,key,sizeof(folder->folderkey) - 1);
memset(folder->folderkey, 0, sizeof(folder->folderkey));
strncpy(folder->folderkey, key, sizeof(folder->folderkey) - 1);
return 0;
}
const char*
folder_get_key(mffolder *folder)
const char *folder_get_key(mffolder * folder)
{
if(folder == NULL) return NULL;
if (folder == NULL)
return NULL;
return folder->folderkey;
}
int
folder_set_parent(mffolder *folder,const char *parent_key)
int folder_set_parent(mffolder * folder, const char *parent_key)
{
if(folder == NULL) return -1;
if(parent_key == NULL) return -1;
if (folder == NULL)
return -1;
if (parent_key == NULL)
return -1;
if(strlen(parent_key) != 13)
{
if(strcmp(parent_key,"myfiles") != 0) return -1;
if (strlen(parent_key) != 13) {
if (strcmp(parent_key, "myfiles") != 0)
return -1;
}
memset(folder->parent,0,sizeof(folder->parent));
strncpy(folder->parent,parent_key,sizeof(folder->parent) -1);
memset(folder->parent, 0, sizeof(folder->parent));
strncpy(folder->parent, parent_key, sizeof(folder->parent) - 1);
return 0;
}
const char*
folder_get_parent(mffolder *folder)
const char *folder_get_parent(mffolder * folder)
{
if(folder == NULL) return NULL;
if (folder == NULL)
return NULL;
return folder->parent;
}
int
folder_set_name(mffolder *folder,const char *name)
int folder_set_name(mffolder * folder, const char *name)
{
if(folder == NULL) return -1;
if(name == NULL) return -1;
if (folder == NULL)
return -1;
if (name == NULL)
return -1;
if(strlen(name) > 40) return -1;
if (strlen(name) > 40)
return -1;
memset(folder->name,0,sizeof(folder->name));
strncpy(folder->name,name,sizeof(folder->name) - 1);
memset(folder->name, 0, sizeof(folder->name));
strncpy(folder->name, name, sizeof(folder->name) - 1);
return 0;
}
const char*
folder_get_name(mffolder *folder)
const char *folder_get_name(mffolder * folder)
{
if(folder == NULL) return NULL;
if (folder == NULL)
return NULL;
return folder->name;
}

View File

@@ -22,20 +22,20 @@
typedef struct mffolder mffolder;
mffolder* folder_alloc(void);
mffolder *folder_alloc(void);
void folder_free(mffolder *folder);
void folder_free(mffolder * folder);
int folder_set_key(mffolder *folder,const char *folderkey);
int folder_set_key(mffolder * folder, const char *folderkey);
const char* folder_get_key(mffolder *folder);
const char *folder_get_key(mffolder * folder);
int folder_set_parent(mffolder *folder,const char *folderkey);
int folder_set_parent(mffolder * folder, const char *folderkey);
const char* folder_get_parent(mffolder *folder);
const char *folder_get_parent(mffolder * folder);
int folder_set_name(mffolder *folder,const char *name);
int folder_set_name(mffolder * folder, const char *name);
const char* folder_get_name(mffolder *folder);
const char *folder_get_name(mffolder * folder);
#endif

View File

@@ -28,26 +28,28 @@
#include "apicalls.h"
#include "mfconn.h"
struct mfconn
{
char *server;
uint32_t secret_key;
char *secret_time;
char *session_token;
struct mfconn {
char *server;
uint32_t secret_key;
char *secret_time;
char *session_token;
};
mfconn*
mfconn_create(char *server, char *username, char *password, int app_id, char *app_key)
mfconn *mfconn_create(char *server, char *username, char *password,
int app_id, char *app_key)
{
mfconn *conn;
int retval;
mfconn *conn;
int retval;
conn = (mfconn *)calloc(1,sizeof(mfconn));
conn = (mfconn *) calloc(1, sizeof(mfconn));
conn->server = strdup(server);
retval = mfconn_api_user_get_session_token(conn, conn->server,
username, password, app_id, app_key, &(conn->secret_key),
&(conn->secret_time), &(conn->session_token));
username, password, app_id,
app_key,
&(conn->secret_key),
&(conn->secret_time),
&(conn->session_token));
if (retval == 0)
return conn;
@@ -55,8 +57,7 @@ mfconn_create(char *server, char *username, char *password, int app_id, char *ap
return NULL;
}
void
mfconn_destroy(mfconn *conn)
void mfconn_destroy(mfconn * conn)
{
free(conn->server);
free(conn->secret_time);
@@ -64,14 +65,14 @@ mfconn_destroy(mfconn *conn)
free(conn);
}
void
mfconn_update_secret_key(mfconn *conn)
void mfconn_update_secret_key(mfconn * conn)
{
uint64_t new_val;
uint64_t new_val;
if(conn == NULL) return;
if (conn == NULL)
return;
new_val = ((uint64_t)conn->secret_key) * 16807;
new_val = ((uint64_t) conn->secret_key) * 16807;
new_val %= 0x7FFFFFFF;
conn->secret_key = new_val;
@@ -79,98 +80,106 @@ mfconn_update_secret_key(mfconn *conn)
return;
}
char*
mfconn_create_user_signature(mfconn *conn, char *username, char *password,
int app_id, char *app_key)
char *mfconn_create_user_signature(mfconn * conn, char *username,
char *password, int app_id,
char *app_key)
{
char *signature_raw;
unsigned char signature_enc[20]; // sha1 is 160 bits
char *signature_raw;
unsigned char signature_enc[20]; // sha1 is 160 bits
char signature_hex[41];
int i;
if(conn == NULL) return NULL;
if (conn == NULL)
return NULL;
signature_raw = strdup_printf("%s%s%d%s",
username, password, app_id, app_key);
username, password, app_id, app_key);
SHA1((const unsigned char *)signature_raw,
strlen(signature_raw),signature_enc);
strlen(signature_raw), signature_enc);
free(signature_raw);
for(i = 0;i < 20;i++)
{
sprintf(&signature_hex[i*2],"%02x",signature_enc[i]);
for (i = 0; i < 20; i++) {
sprintf(&signature_hex[i * 2], "%02x", signature_enc[i]);
}
signature_hex[40] = '\0';
return strdup((const char *)signature_hex);
}
char*
mfconn_create_call_signature(mfconn *conn,char *url,char *args)
char *mfconn_create_call_signature(mfconn * conn, char *url,
char *args)
{
char *signature_raw;
unsigned char signature_enc[16]; // md5 is 128 bits
char *signature_raw;
unsigned char signature_enc[16]; // md5 is 128 bits
char signature_hex[33];
char *api;
char *api;
int i;
if(conn == NULL) return NULL;
if(url == NULL) return NULL;
if(args == NULL) return NULL;
if (conn == NULL)
return NULL;
if (url == NULL)
return NULL;
if (args == NULL)
return NULL;
// printf("url: %s\n\rargs: %s\n\r",url,args);
api = strstr(url,"/api/");
api = strstr(url, "/api/");
if(api == NULL) return NULL;
if (api == NULL)
return NULL;
signature_raw = strdup_printf("%d%s%s%s",
(conn->secret_key % 256),
conn->secret_time,
api,args);
(conn->secret_key % 256),
conn->secret_time, api, args);
MD5((const unsigned char *)signature_raw,
strlen(signature_raw),signature_enc);
strlen(signature_raw), signature_enc);
free(signature_raw);
for(i = 0;i < 16;i++)
{
sprintf(&signature_hex[i*2],"%02x",signature_enc[i]);
for (i = 0; i < 16; i++) {
sprintf(&signature_hex[i * 2], "%02x", signature_enc[i]);
}
signature_hex[32] = '\0';
return strdup((const char *)signature_hex);
}
char*
mfconn_create_signed_get(mfconn *conn,int ssl,char *api,char *fmt,...)
char *mfconn_create_signed_get(mfconn * conn, int ssl, char *api,
char *fmt, ...)
{
char *api_request = NULL;
char *api_args = NULL;
char *signature;
char *call_hash;
char *session_token;
int bytes_to_alloc;
int api_args_len;
int api_len;
va_list ap;
char *api_request = NULL;
char *api_args = NULL;
char *signature;
char *call_hash;
char *session_token;
int bytes_to_alloc;
int api_args_len;
int api_len;
va_list ap;
if(conn == NULL) return NULL;
if(conn->server == NULL) return NULL;
if(conn->secret_time == NULL) return NULL;
if(conn->session_token == NULL) return NULL;
if (conn == NULL)
return NULL;
if (conn->server == NULL)
return NULL;
if (conn->secret_time == NULL)
return NULL;
if (conn->session_token == NULL)
return NULL;
// make sure the api (ex: user/get_info.php) is sane
if(api == NULL) return NULL;
if (api == NULL)
return NULL;
api_len = strlen(api);
if(api_len < 3) return NULL;
if (api_len < 3)
return NULL;
// calculate how big of a buffer we need
va_start(ap, fmt);
api_args_len = (vsnprintf(NULL, 0, fmt, ap) + 1); // + 1 for NULL
api_args_len = (vsnprintf(NULL, 0, fmt, ap) + 1); // + 1 for NULL
va_end(ap);
session_token = strdup_printf("&session_token=%s", conn->session_token);
@@ -178,7 +187,7 @@ mfconn_create_signed_get(mfconn *conn,int ssl,char *api,char *fmt,...)
api_args_len += strlen(session_token);
// create the correctly sized buffer and process the args
api_args = (char*)calloc(api_args_len,sizeof(char));
api_args = (char *)calloc(api_args_len, sizeof(char));
// printf("\n\r%d\n\r",api_args_len);
@@ -190,25 +199,26 @@ mfconn_create_signed_get(mfconn *conn,int ssl,char *api,char *fmt,...)
free(session_token);
// correct user error of trailing slash
if(api[api_len - 1] == '/') api[api_len - 1] = '\0';
if (api[api_len - 1] == '/')
api[api_len - 1] = '\0';
api_request = strdup_printf("%s//%s/api/%s",
(ssl ? "https:" : "http:"), conn->server,api);
(ssl ? "https:" : "http:"), conn->server, api);
call_hash = mfconn_create_call_signature(conn,api_request,api_args);
signature = strdup_printf("&signature=%s",call_hash);
call_hash = mfconn_create_call_signature(conn, api_request, api_args);
signature = strdup_printf("&signature=%s", call_hash);
free(call_hash);
// compute the amount of space requred to realloc() the request
bytes_to_alloc = api_args_len;
bytes_to_alloc += strlen(api_request);
bytes_to_alloc += strlen(signature);
bytes_to_alloc += 1; // null termination
bytes_to_alloc += 1; // null termination
// append api GET args to api request
api_request = (char*)realloc(api_request,bytes_to_alloc);
strncat(api_request,api_args,api_args_len);
strcat(api_request,signature);
api_request = (char *)realloc(api_request, bytes_to_alloc);
strncat(api_request, api_args, api_args_len);
strcat(api_request, signature);
free(signature);
free(api_args);
@@ -216,20 +226,17 @@ mfconn_create_signed_get(mfconn *conn,int ssl,char *api,char *fmt,...)
return api_request;
}
const char*
mfconn_get_session_token(mfconn *conn)
const char *mfconn_get_session_token(mfconn * conn)
{
return conn->session_token;
}
const char*
mfconn_get_secret_time(mfconn *conn)
const char *mfconn_get_secret_time(mfconn * conn)
{
return conn->secret_time;
}
uint32_t
mfconn_get_secret_key(mfconn *conn)
uint32_t mfconn_get_secret_key(mfconn * conn)
{
return conn->secret_key;
}

View File

@@ -26,22 +26,25 @@
typedef struct mfconn mfconn;
mfconn* mfconn_create(char *server, char *username, char *password, int app_id, char *app_key);
mfconn *mfconn_create(char *server, char *username, char *password,
int app_id, char *app_key);
void mfconn_destroy(mfconn *conn);
void mfconn_destroy(mfconn * conn);
ssize_t mfconn_download_direct(mffile *file,char *local_dir);
ssize_t mfconn_download_direct(mffile * file, char *local_dir);
char* mfconn_create_signed_get(mfconn *conn,int ssl,char *api,char *fmt,...);
char *mfconn_create_signed_get(mfconn * conn, int ssl, char *api,
char *fmt, ...);
char* mfconn_create_user_signature(mfconn *conn, char *username,
char *password, int app_id, char *app_key);
char *mfconn_create_user_signature(mfconn * conn, char *username,
char *password, int app_id,
char *app_key);
void mfconn_update_secret_key(mfconn *conn);
void mfconn_update_secret_key(mfconn * conn);
const char* mfconn_get_session_token(mfconn *conn);
const char *mfconn_get_session_token(mfconn * conn);
const char* mfconn_get_secret_time(mfconn *conn);
const char *mfconn_get_secret_time(mfconn * conn);
uint32_t mfconn_get_secret_key(mfconn *conn);
uint32_t mfconn_get_secret_key(mfconn * conn);
#endif