@@ -297,9 +297,7 @@ comment "Image downloading support needs libcurl"
config CHANNEL_CURL
bool
depends on HAVE_LIBCURL
- depends on HAVE_JSON_C
select CURL
- select JSON
config HASH_VERIFY
bool "Allow to add sha256 hash to each image"
@@ -6,6 +6,7 @@
*/
#include <stdbool.h>
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
@@ -13,7 +14,6 @@
#include <unistd.h>
#include <math.h>
#include <curl/curl.h>
-#include <json-c/json.h>
#include <generated/autoconf.h>
#include <unistd.h>
#include <network_ipc.h>
@@ -21,6 +21,9 @@
#include "sslapi.h"
#include "channel.h"
#include "channel_curl.h"
+#ifdef CONFIG_JSON
+#include <json-c/json.h>
+#endif
#define SPEED_LOW_BYTES_SEC 8
#define SPEED_LOW_TIME_SEC 300
@@ -979,6 +982,7 @@ channel_op_res_t channel_get(channel_t *this, void *data)
http_response_code);
}
+#ifdef CONFIG_JSON
assert(channel_data->json_reply == NULL);
enum json_tokener_error json_res;
struct json_tokener *json_tokenizer = json_tokener_new();
@@ -999,6 +1003,7 @@ channel_op_res_t channel_get(channel_t *this, void *data)
cleanup_json_tokenizer:
json_tokener_free(json_tokenizer);
+#endif
cleanup_chunk:
chunk.memory != NULL ? free(chunk.memory) : (void)0;
cleanup_header:
@@ -165,6 +165,7 @@ config SWUFORWARDER_HANDLER
depends on HAVE_LIBCURL
depends on HAVE_JSON_C
select CHANNEL_CURL
+ select JSON
default n
help
This allows to build a chain of updater. A
@@ -6,7 +6,9 @@
*/
#pragma once
+#ifdef CONFIG_JSON
#include <json-c/json.h>
+#endif
#include <stdio.h>
#include <stdbool.h>
#include "sslapi.h"
@@ -33,7 +35,9 @@ typedef struct {
char *url;
char *auth;
char *json_string;
+#ifdef CONFIG_JSON
json_object *json_reply;
+#endif
char *cafile;
char *sslkey;
char *sslcert;
@@ -72,6 +72,7 @@ config SURICATTA_HAWKBIT
depends on HAVE_LIBCURL
depends on HAVE_JSON_C
select CHANNEL_CURL
+ select JSON
help
Support for hawkBit server.
https://projects.eclipse.org/projects/iot.hawkbit
Currently, channel_curl relies on CONFIG_JSON. However, this is mostly only required for preparing channel_get()'s return value as proper json_object to be consumed further. If used for, e.g., the dowloader, such preparation is not necessary. Hence, enclose JSON-specifics in #ifdef's. Signed-off-by: Christian Storm <christian.storm@siemens.com> --- Kconfig | 2 -- corelib/channel_curl.c | 7 ++++++- handlers/Config.in | 1 + include/channel_curl.h | 4 ++++ suricatta/Config.in | 1 + 5 files changed, 12 insertions(+), 3 deletions(-)