remove json_object_by_path

This commit is contained in:
josch
2014-12-05 14:27:31 +01:00
parent 8300fcd4c8
commit c04151f2e1
16 changed files with 26 additions and 172 deletions

View File

@@ -22,7 +22,6 @@
#include <stdlib.h>
#include "../utils/http.h"
#include "../utils/json.h"
int mfapi_check_response(json_t * response, const char *apicall)
{
@@ -90,7 +89,7 @@ int mfapi_decode_common(mfhttp * conn, void *user_ptr)
return -1;
}
node = json_object_by_path(root, "response");
node = json_object_get(root, "response");
retval = mfapi_check_response(node, apicall);
if (retval != 0) {

View File

@@ -26,7 +26,6 @@
#include <stdio.h>
#include "../../utils/http.h"
#include "../../utils/json.h"
#include "../mfconn.h"
#include "../apicalls.h" // IWYU pragma: keep
@@ -97,6 +96,7 @@ static int _decode_device_get_changes(mfhttp * conn, void *user_ptr)
json_error_t error;
json_t *root;
json_t *node;
json_t *response;
json_t *data;
json_t *obj_array;
@@ -124,16 +124,16 @@ static int _decode_device_get_changes(mfhttp * conn, void *user_ptr)
return -1;
}
node = json_object_by_path(root, "response");
response = json_object_get(root, "response");
retval = mfapi_check_response(node, "device/get_changes");
retval = mfapi_check_response(response, "device/get_changes");
if (retval != 0) {
fprintf(stderr, "invalid response\n");
json_decref(root);
return retval;
}
device_revision = json_object_get(node, "device_revision");
device_revision = json_object_get(response, "device_revision");
if (device_revision == NULL) {
fprintf(stderr,
"response/device_revision is not part of the result\n");
@@ -143,7 +143,7 @@ static int _decode_device_get_changes(mfhttp * conn, void *user_ptr)
len_changes = 0;
node = json_object_by_path(root, "response/updated");
node = json_object_get(response, "updated");
obj_array = json_object_get(node, "files");
if (json_is_array(obj_array)) {
@@ -175,7 +175,7 @@ static int _decode_device_get_changes(mfhttp * conn, void *user_ptr)
}
}
node = json_object_by_path(root, "response/deleted");
node = json_object_get(response, "deleted");
obj_array = json_object_get(node, "files");
if (json_is_array(obj_array)) {

View File

@@ -24,7 +24,6 @@
#include <stdio.h>
#include "../../utils/http.h"
#include "../../utils/json.h"
#include "../mfconn.h"
#include "../patch.h"
#include "../apicalls.h" // IWYU pragma: keep
@@ -94,7 +93,7 @@ static int _decode_device_get_patch(mfhttp * conn, void *data)
return -1;
}
node = json_object_by_path(root, "response");
node = json_object_get(root, "response");
retval = mfapi_check_response(node, "device/get_patch");
if (retval != 0) {

View File

@@ -23,7 +23,6 @@
#include <stdint.h>
#include "../../utils/http.h"
#include "../../utils/json.h"
#include "../mfconn.h"
#include "../apicalls.h" // IWYU pragma: keep
@@ -76,7 +75,7 @@ static int _decode_device_get_status(mfhttp * conn, void *data)
return -1;
}
node = json_object_by_path(root, "response");
node = json_object_get(root, "response");
retval = mfapi_check_response(node, "device/get_status");
if (retval != 0) {

View File

@@ -25,7 +25,6 @@
#include <stdlib.h>
#include "../../utils/http.h"
#include "../../utils/json.h"
#include "../patch.h"
#include "../mfconn.h"
#include "../apicalls.h" // IWYU pragma: keep
@@ -115,7 +114,7 @@ static int _decode_device_get_updates(mfhttp * conn, void *user_ptr)
return -1;
}
node = json_object_by_path(root, "response");
node = json_object_get(root, "response");
retval = mfapi_check_response(node, "device/get_updates");
if (retval != 0) {

View File

@@ -25,7 +25,6 @@
#include <time.h>
#include "../../utils/http.h"
#include "../../utils/json.h"
#include "../mfconn.h"
#include "../file.h"
#include "../apicalls.h" // IWYU pragma: keep
@@ -93,7 +92,7 @@ static int _decode_file_get_info(mfhttp * conn, void *data)
return -1;
}
node = json_object_by_path(root, "response");
node = json_object_get(root, "response");
retval = mfapi_check_response(node, "file/get_info");
if (retval != 0) {
@@ -102,7 +101,7 @@ static int _decode_file_get_info(mfhttp * conn, void *data)
return retval;
}
node = json_object_by_path(root, "response/file_info");
node = json_object_get(node, "file_info");
quickkey = json_object_get(node, "quickkey");
if (quickkey != NULL)

View File

@@ -23,7 +23,6 @@
#include <string.h>
#include "../../utils/http.h"
#include "../../utils/json.h"
#include "../mfconn.h"
#include "../file.h"
#include "../apicalls.h" // IWYU pragma: keep
@@ -92,7 +91,7 @@ static int _decode_file_get_links(mfhttp * conn, void *data)
return -1;
}
node = json_object_by_path(root, "response");
node = json_object_get(root, "response");
retval = mfapi_check_response(node, "file/get_links");
if (retval != 0) {

View File

@@ -26,7 +26,6 @@
#include <stdio.h>
#include "../../utils/http.h"
#include "../../utils/json.h"
#include "../folder.h"
#include "../file.h"
#include "../mfconn.h"
@@ -131,7 +130,7 @@ static int _decode_folder_get_content_folders(mfhttp * conn, void *user_ptr)
return -1;
}
node = json_object_by_path(root, "response");
node = json_object_get(root, "response");
retval = mfapi_check_response(node, "folder/get_content");
if (retval != 0) {
@@ -140,10 +139,7 @@ static int _decode_folder_get_content_folders(mfhttp * conn, void *user_ptr)
return retval;
}
/*json_t *result = json_object_by_path(root, "response/action");
fprintf(stderr, "response/action: %s\n", (char*)json_string_value(result)); */
node = json_object_by_path(root, "response/folder_content");
node = json_object_get(node, "folder_content");
folders_array = json_object_get(node, "folders");
if (!json_is_array(folders_array)) {
@@ -247,7 +243,7 @@ static int _decode_folder_get_content_files(mfhttp * conn, void *user_ptr)
return -1;
}
node = json_object_by_path(root, "response");
node = json_object_get(root, "response");
retval = mfapi_check_response(node, "folder/get_content");
if (retval != 0) {
@@ -256,7 +252,7 @@ static int _decode_folder_get_content_files(mfhttp * conn, void *user_ptr)
return retval;
}
node = json_object_by_path(root, "response/folder_content");
node = json_object_get(node, "folder_content");
files_array = json_object_get(node, "files");
if (!json_is_array(files_array)) {

View File

@@ -25,7 +25,6 @@
#include <time.h>
#include "../../utils/http.h"
#include "../../utils/json.h"
#include "../folder.h"
#include "../mfconn.h"
#include "../apicalls.h" // IWYU pragma: keep
@@ -99,7 +98,7 @@ static int _decode_folder_get_info(mfhttp * conn, void *data)
return -1;
}
node = json_object_by_path(root, "response");
node = json_object_get(root, "response");
retval = mfapi_check_response(node, "folder/get_info");
if (retval != 0) {
@@ -108,7 +107,7 @@ static int _decode_folder_get_info(mfhttp * conn, void *data)
return retval;
}
node = json_object_by_path(root, "response/folder_info");
node = json_object_get(node, "folder_info");
folderkey = json_object_get(node, "folderkey");
if (folderkey != NULL)

View File

@@ -24,7 +24,6 @@
#include <stdio.h>
#include "../../utils/http.h"
#include "../../utils/json.h"
#include "../mfconn.h"
#include "../apicalls.h" // IWYU pragma: keep
@@ -94,7 +93,7 @@ static int _decode_upload_poll_upload(mfhttp * conn, void *user_ptr)
return -1;
}
node = json_object_by_path(root, "response");
node = json_object_get(root, "response");
retval = mfapi_check_response(node, "upload/poll_upload");
if (retval != 0) {
@@ -103,7 +102,7 @@ static int _decode_upload_poll_upload(mfhttp * conn, void *user_ptr)
return retval;
}
node = json_object_by_path(root, "response/doupload");
node = json_object_get(node, "doupload");
// make sure that the result code is zero (success)
j_obj = json_object_get(node, "result");

View File

@@ -28,7 +28,6 @@
#include <openssl/sha.h>
#include "../../utils/http.h"
#include "../../utils/json.h"
#include "../../utils/hash.h"
#include "../mfconn.h"
#include "../apicalls.h" // IWYU pragma: keep
@@ -114,7 +113,7 @@ static int _decode_upload_simple(mfhttp * conn, void *user_ptr)
return -1;
}
node = json_object_by_path(root, "response");
node = json_object_get(root, "response");
retval = mfapi_check_response(node, "upload/simple");
if (retval != 0) {
@@ -123,7 +122,7 @@ static int _decode_upload_simple(mfhttp * conn, void *user_ptr)
return retval;
}
node = json_object_by_path(root, "response/doupload");
node = json_object_get(node, "doupload");
j_obj = json_object_get(node, "key");
if (j_obj != NULL) {

View File

@@ -22,7 +22,6 @@
#include <stdlib.h>
#include "../../utils/http.h"
#include "../../utils/json.h"
#include "../mfconn.h"
#include "../apicalls.h" // IWYU pragma: keep
@@ -73,7 +72,7 @@ static int _decode_user_get_info(mfhttp * conn, void *data)
return -1;
}
node = json_object_by_path(root, "response");
node = json_object_get(root, "response");
retval = mfapi_check_response(node, "user/get_info");
if (retval != 0) {
@@ -82,7 +81,7 @@ static int _decode_user_get_info(mfhttp * conn, void *data)
return retval;
}
node = json_object_by_path(root, "response/user_info");
node = json_object_get(node, "user_info");
email = json_object_get(node, "email");
if (email != NULL)

View File

@@ -26,7 +26,6 @@
#include <string.h>
#include "../../utils/http.h"
#include "../../utils/json.h"
#include "../../utils/strings.h"
#include "../mfconn.h"
#include "../apicalls.h" // IWYU pragma: keep
@@ -116,7 +115,7 @@ static int _decode_get_session_token(mfhttp * conn, void *user_ptr)
return -1;
}
node = json_object_by_path(root, "response");
node = json_object_get(root, "response");
retval = mfapi_check_response(node, "user/get_session_token");
if (retval != 0) {