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

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