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 @@
*
*/
#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;
}