From patchwork Tue Nov 7 13:37:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1861082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=M6d2lS4s; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::237; helo=mail-lj1-x237.google.com; envelope-from=swupdate+bncbaabbd73vcvamgqehr5zdgq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x237.google.com (mail-lj1-x237.google.com [IPv6:2a00:1450:4864:20::237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SPq5l1HySz1yQK for ; Wed, 8 Nov 2023 00:37:29 +1100 (AEDT) Received: by mail-lj1-x237.google.com with SMTP id 38308e7fff4ca-2c6f1937a57sf53001141fa.1 for ; Tue, 07 Nov 2023 05:37:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699364241; cv=pass; d=google.com; s=arc-20160816; b=IqItX+GhT7r37iHc1uYYAvRSltWhDZi8zRpZ/4ZyakfZqRkUnXq6Q3yhBiooE/1Xz0 bLiy1j811JqVHFxP1g6vVBmpiJaCJ6o7KvV9insOomFfeF6s/0PRj8VsI3wEUxLBTqa7 BDXuSTAgwW7UAchkvZ/7WOjOELYQMT3qyfngY3r80iX1FH+Kgw9sCO9tcnGDJpcucftg oeiZ3XoBFtj8PGVjXZAQv9az/SBMKZZKn6QI7/609rOauGaWk0hMaTRp6c/arAEQU996 IoZaosiEolgt31FkQejG6lF8EsEisQ6doqRZt86fRwQkkwwqb1bwqLDuLLVwPop4Mt4p KBtA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=Y4aAEcZNUBM4JlDLKv9MDAE6BmaTlP6nZfQhpCHBUKM=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=lLyZ1v9rHXs/9Hi1oc8Awn0e/luXca3vrUP0Zw0vUctHPesjCi4jZpZvdTp5i8k/mQ BHFWrwaViXIVEh7cq4QZheiiEM10NfPlV8SJmvyd5SooErbz4mz34YmV4AoLz4o6dBaB G9M+AG4No6hr8YKChtIDgSAWZMVPl3sK1s6VkOrsp3xKBL4vj0a9AzWjFzdje1vzMzVP wetQNCUuSRz8ctdOHs51gEfn4Sm3nZnxUYtv+dxs4RlL4b9b0jHJc742FKhB+Fw9ONq8 npxKR/mgfF8reSpy4W+Xg6+7woF+2ZAHa67+aaIHywmgJDUGuSHo2V7Dd+mhY22iVTbe r9FA== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1699364241; x=1699969041; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:message-id:date :subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=Y4aAEcZNUBM4JlDLKv9MDAE6BmaTlP6nZfQhpCHBUKM=; b=M6d2lS4svME6blSm7MgKu/uwG9Mahzd/6ev50RwFw4ofw68f25VfwZ8NaCEAKOkqWJ V0wU7SOX3L5DwTN6Xq9pbkvn9G13MrLlP3PYLb5Wa+gJ0qL7n6/QbNjpXVlaa6751+TC rCenuQxInsNyUJya7WEu6DV82bFurlH4WMc3fYrrDVW/k4xql2HoE/kolaP4P5wlL1g2 bMoOwRIMxqeyym8FGkFgxz+oNdZIosqlEbR+SKZL6q4mRQ8NLkA+K+mxRVcipSl19rmD scOrB2uT5xpuT/Ca016VuaX+qYtNRVB9o08Nuah3W4bCTdTNfEX1aqlibxFE8MI0fzqc qLPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699364241; x=1699969041; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=Y4aAEcZNUBM4JlDLKv9MDAE6BmaTlP6nZfQhpCHBUKM=; b=th9e2r6OK1iNqDz2aA7ZrK94t6mh5dZK7q53q4uKXNeWaewBxpu6/Bfqz7AFarkxQs 4TUi03mZF0/FtWzGnNs3A8D66O4aJOv0QY83kC3WFbZP9TZt3JdkihBPr+NreYrRvzrx QemXrkTKbmRl0yQevAsfiBDi/g28DiBa7G86yubviJyamBklT981R/W3L8pWnx4QI62t MbcdeK5HYiGFQGjSBLZpdE3DLnQx0rdRA+hKnh4wRl0pT+D/+EWpXH+R6SpF1OV3w5o4 G8bR7KtdgTynCATyqbCZtao4a1M2//kLf7VbDbbAcsbxIoptJ2HLEH6pqVRh0rXecaS5 PhPA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOJu0YwLLGbz4VMhyh+9Khotgb8XL1mQb37pK6FMg1rqj56gpqySxhpK 3nECCbY0TqrdVNlvzo+Ycec= X-Google-Smtp-Source: AGHT+IFzMhXE3wzzWIErgn7iHeiIrQ7xITWaFYLh94pppndMPZGSXxVONPPWp9FppUbCxLdsVIWP5A== X-Received: by 2002:a05:651c:1310:b0:2c5:98b:8bdb with SMTP id u16-20020a05651c131000b002c5098b8bdbmr21174274lja.49.1699364239992; Tue, 07 Nov 2023 05:37:19 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:bc07:0:b0:2b9:6182:b0a4 with SMTP id b7-20020a2ebc07000000b002b96182b0a4ls753415ljf.2.-pod-prod-05-eu; Tue, 07 Nov 2023 05:37:18 -0800 (PST) X-Received: by 2002:a05:6512:e83:b0:509:47b9:63d0 with SMTP id bi3-20020a0565120e8300b0050947b963d0mr15182171lfb.61.1699364237990; Tue, 07 Nov 2023 05:37:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699364237; cv=none; d=google.com; s=arc-20160816; b=Fg5ihZ1TOI2shXQAILeWPBUj92ZiFaOOVE0ELeUDin3PG6372qAl1yN1WWsMWbrPAt mU529e/lcoAK2u9Wyg+K5DtucWk98qRuyfcqVlDz6qlMqNdPk5p7lrXKxDuSDWpdS8x9 +5SvTZukRSDKifMypUIu3JbZH4r4kDpAjcWfkq1u7Ah6AIyDi0PpHPRdMgtSlhCYkm8z i7hnYlkqhPyKMx7yIvXBL0Et7gURr6Ml4YfgZJbjmw2QpNcGkV/KjzO0RFtlRbjrdBRX ynn4s9WfVLV8l3S5S9JfktpF78AZGvcp4GvevwTI8Pos2IzESHo+/e5eNuxARFhQrhxT gxIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:message-id :date:subject:cc:to:from; bh=llBam5GRLgQKeJl+wq5tUhpsyaVQB0MApOhZLcDNuXA=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=obWmLfGWWPzyVs/1P8t9ZjVqeA/tVIV7fwmtPsD/KJf+lY3HR0W88NkXVG9zaTqaM3 JNoPt9h0OiJULZPiByWRzVt8jpTkWdRlI5hCUrc/d++Qui8oO4qCZl7+TvShwI5J3h3O zUW8jw+m69TWdl6cqeM0su1tIs/aNE8n7qA51oda98QBSUmqBYSwON++vQWC3kdNoL8p Q9cYSlb/8rF6sogmN2cyQ6RzFZS8I2AEhuR5gAWlVxJ5rPUc5gJWXd0lUmW3opyDhkUf Pj0f6fDF/w95TLjnNtTgbgnA0g07phM9hFbqX3gSPD40aIMI7Iwe+mI2PlfTR78s6rbc b+vQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.134]) by gmr-mx.google.com with ESMTPS id k12-20020a05651210cc00b005090fd18c05si670495lfg.11.2023.11.07.05.37.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 05:37:17 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) client-ip=212.227.126.134; Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MOAFl-1qlHC13Ec5-00OWhP; Tue, 07 Nov 2023 14:37:16 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH] Set json support as mandatory Date: Tue, 7 Nov 2023 14:37:14 +0100 Message-Id: <20231107133714.120001-1-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:1AWbZqc19gjcBVltJnIAFaYt1JkUjGfPbkZs3buGIF0gJWUz3W7 24tn/8/buNCrLxL74f0GJL0lTEr+TnpWLiJoPdE4Jon42/WNFJ4w74mMQqmYH4wo9FedHIA jclGOBnUp+I7jlBaajirrWR9pZUvBVhoXnMglGBXFCmOwzSsKW3lEKeJOzFCefZ1Cvp3ZRk Y5cxoYFAYHQoS8ery8PYQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:cfoqbzb4wBI=;tHm/8MHzddKlfoySDi87H4Fbtkk sIbkULlDjx3aFKB7EAVVyUZeSqNlqe5u9gPsXNg6k9AxflbN2sTUrdIPy4kIE4aTxZ1wTOFfA b3UZVoQxFUahZf2SFUbJPsxWZwCycazTw7j5+lL9MN8VpXNbMslM2cFhnbiLSgjuIX1nj1puK g8vDsSJ0neh1Ap9mrArqpEjaYnTb6fDUk/+CuRTtxJnBpEPtji07xbi78qDSlYNuYKzJ6OLcz zE2FXwJOal4Hypmmo3S2epdNIyqsS/MkEbw7zZo8nLe6XVkZpT5OBrThEoyl2j1Ka3ODNKTwE wHv/sKuw4OjmRRmgPsBOJ91YCsyJn5Bkn9EOZAcALWR+cKsSamRLUAKjTTt/cfUXhDWiFEtJM wra2MCicprGyE+UYFkqMS0H2Q02Ca2SzRnpRUuKNhdvB+qBPHor0ANqwfgGzaFUQrSkN0j8uQ vZ2B55KZ3ri7vybQvFeG9QseDtXrbgdgci5yrQtfGYc1SfdDkz2RqLQU2QmvRc+kkz/3jP4wW fN9Qq8HkSbAtejoJcsLuaWDBaULxvT3+yLCfGPaEeIwNRmr/5/VteHGwzI45jGuua8njvDnQn l93YkQyU23d/ck8DhqYuP6eJ804LsEgIagT9G+nVFTIDtLcEF/FZE67zMFM06yD+mlgd8g6ff Y+ah0ppmcoIEMGeW/HNS80OP1lfmc3uT6Rqb+pc7cwz3sU43vK+ZE/AIdmP3QVf2qVuwcGoIR R7EOS4TwlQY1pY5Z+8M1p5A+UVkSwzrIdbXqS8E36zzj2Ujj4bAB98SVnh/6yY5pgkVPj2btA o8Ka6JtIvbaLsngPO0mm3I3qOTL/jU292xjWCL1xLtB3pVGLuUQ3igARCMvOeBSsFR5pIp1/i z/Inr6ZH0fglQaQ== X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , JSON is used in a lto of part of code, and it is quite always set. Make it mandatory and always link SWUpdate to libjson. Cleanup code to remove superseded CONFIG_JSON. Signed-off-by: Stefano Babic --- Kconfig | 4 ---- Makefile.deps | 4 ---- Makefile.flags | 7 +------ corelib/Makefile | 5 +++-- corelib/channel_curl.c | 5 +---- handlers/Config.in | 6 ++---- include/channel_curl.h | 4 ---- include/parselib.h | 15 --------------- parser/Config.in | 12 ------------ parser/parser.c | 12 ------------ suricatta/Config.in | 17 +---------------- suricatta/server_lua.c | 18 +----------------- tools/swupdate-ipc.c | 11 +---------- 13 files changed, 10 insertions(+), 110 deletions(-) diff --git a/Kconfig b/Kconfig index bd4ce049..2ae2e4bc 100644 --- a/Kconfig +++ b/Kconfig @@ -109,10 +109,6 @@ config HAVE_P11KIT bool option env="HAVE_P11KIT" -config HAVE_JSON_C - bool - option env="HAVE_JSON_C" - config HAVE_LIBWEBSOCKETS bool option env="HAVE_LIBWEBSOCKETS" diff --git a/Makefile.deps b/Makefile.deps index 397e08c4..30e4d92a 100644 --- a/Makefile.deps +++ b/Makefile.deps @@ -102,10 +102,6 @@ ifeq ($(HAVE_P11KIT),) export HAVE_P11KIT = y endif -ifeq ($(HAVE_JSON_C),) -export HAVE_JSON_C = y -endif - ifeq ($(HAVE_LIBWEBSOCKETS),) export HAVE_LIBWEBSOCKETS = y endif diff --git a/Makefile.flags b/Makefile.flags index accdd6a2..a2bb2e7f 100644 --- a/Makefile.flags +++ b/Makefile.flags @@ -106,7 +106,7 @@ export SYSROOT=$(CONFIG_SYSROOT) endif # Links always pthread -LDLIBS += pthread ubootenv +LDLIBS += pthread ubootenv json-c # lua ifneq ($(CONFIG_LUA),) LDFLAGS_swupdate += -Wl,-E @@ -144,11 +144,6 @@ ifeq ($(CONFIG_ARCHIVE),y) LDLIBS += archive endif -# json-c -ifeq ($(CONFIG_JSON),y) -LDLIBS += json-c -endif - ifeq ($(CONFIG_SSL_IMPL_OPENSSL),y) LDLIBS += crypto ssl endif diff --git a/corelib/Makefile b/corelib/Makefile index 0566f888..c9ca4aa6 100644 --- a/corelib/Makefile +++ b/corelib/Makefile @@ -2,7 +2,9 @@ # # SPDX-License-Identifier: GPL-2.0-only -lib-y += multipart_parser.o +lib-y += multipart_parser.o \ + parsing_library_libjson.o \ + server_utils.o lib-$(CONFIG_DOWNLOAD) += downloader.o lib-$(CONFIG_MTD) += mtd-interface.o lib-$(CONFIG_LUA) += lua_interface.o lua_compat.o @@ -35,5 +37,4 @@ endif lib-$(CONFIG_SIGALG_GPG) += swupdate_gpg_verify.o lib-$(CONFIG_LIBCONFIG) += swupdate_settings.o \ parsing_library_libconfig.o -lib-$(CONFIG_JSON) += parsing_library_libjson.o server_utils.o lib-$(CONFIG_CHANNEL_CURL) += channel_curl.o diff --git a/corelib/channel_curl.c b/corelib/channel_curl.c index 90ab3ea5..c411aa8a 100644 --- a/corelib/channel_curl.c +++ b/corelib/channel_curl.c @@ -27,9 +27,7 @@ #include "channel.h" #include "channel_curl.h" #include "progress.h" -#ifdef CONFIG_JSON #include -#endif #define SPEED_LOW_BYTES_SEC 8 #define SPEED_LOW_TIME_SEC 300 @@ -945,7 +943,6 @@ static channel_op_res_t parse_reply(channel_data_t *channel_data, output_data_t return CHANNEL_ENOMEM; } -#ifdef CONFIG_JSON if (channel_data->format == CHANNEL_PARSE_JSON) { assert(channel_data->json_reply == NULL); enum json_tokener_error json_res; @@ -963,7 +960,7 @@ static channel_op_res_t parse_reply(channel_data_t *channel_data, output_data_t return CHANNEL_EBADMSG; } } -#endif + if (channel_data->format == CHANNEL_PARSE_RAW) { /* strndup is strnlen + malloc + memcpy, seems more appropriate than just malloc + memcpy. */ if ((channel_data->raw_reply = strndup(chunk->memory, chunk->size)) == NULL) { diff --git a/handlers/Config.in b/handlers/Config.in index 107ffebf..1029e582 100644 --- a/handlers/Config.in +++ b/handlers/Config.in @@ -204,11 +204,9 @@ config SHELLSCRIPTHANDLER config SWUFORWARDER_HANDLER bool "SWU forwarder" depends on HAVE_LIBCURL - depends on HAVE_JSON_C depends on HAVE_LIBWEBSOCKETS depends on HAVE_URIPARSER select CHANNEL_CURL - select JSON default n help This allows one to build a chain of updater. A @@ -217,8 +215,8 @@ config SWUFORWARDER_HANDLER embedded SWU to the other devices using the webserver REST API. -comment "swuforward handler needs json-c and libcurl" - depends on !HAVE_JSON_C || !HAVE_LIBCURL +comment "swuforward handler needs libcurl" + depends on !HAVE_LIBCURL comment "swuforward handler needs websockets and uriparser" depends on !HAVE_LIBWEBSOCKETS || !HAVE_URIPARSER diff --git a/include/channel_curl.h b/include/channel_curl.h index 4409dca8..643082b1 100644 --- a/include/channel_curl.h +++ b/include/channel_curl.h @@ -7,9 +7,7 @@ #pragma once #include "util.h" -#ifdef CONFIG_JSON #include -#endif #include #include #include "swupdate_status.h" @@ -42,9 +40,7 @@ typedef struct { char *auth; char *request_body; char *iface; -#ifdef CONFIG_JSON json_object *json_reply; -#endif char *raw_reply; bool dry_run; char *cafile; diff --git a/include/parselib.h b/include/parselib.h index 7baf555d..b1674709 100644 --- a/include/parselib.h +++ b/include/parselib.h @@ -56,7 +56,6 @@ void *get_node_libconfig(config_t *cfg, const char **nodes); #define is_field_numeric_cfg(e, path) (false) #endif -#ifdef CONFIG_JSON #include bool is_field_numeric_json(json_object *e, const char *path); @@ -74,20 +73,6 @@ char *json_get_data_url(json_object *json_root, const char *key); void *find_root_json(json_object *root, const char **nodes, unsigned int depth); void *get_node_json(json_object *root, const char **nodes); -#else -#define find_node_json(a, b, c) (NULL) -#define get_field_string_json(e, path) (NULL) -#define get_child_json(e, name) (NULL) -#define iterate_field_json(e, cb, data) { } -#define get_field_json(e, path, dest) -#define json_object_object_get_ex(a,b,c) (0) -#define json_object_array_get_idx(a, b) (0) -#define json_object_array_length(a) (0) -#define find_root_json(root, nodes, depth) (NULL) -#define get_node_json(root, nodes) (NULL) -#define is_field_numeric_json(e, path) (false) -#endif - bool is_field_numeric(parsertype p, void *e, const char *path); const char *get_field_string(parsertype p, void *e, const char *path); void get_field_string_with_size(parsertype p, void *e, const char *path, diff --git a/parser/Config.in b/parser/Config.in index 454e9cdb..e97734da 100644 --- a/parser/Config.in +++ b/parser/Config.in @@ -17,23 +17,11 @@ comment "Default config parser support needs libconfig" config PARSERROOT string "Name of root node" - depends on LIBCONFIG || JSON help For compatibility reasons, the root node can be set to something else as "software". In most case you do not need to set it. -config JSON - bool "libjson" - default n - depends on HAVE_JSON_C - help - Use json-c to parse the configuration file. - Also required for suricatta server support. - -comment "JSON config parser support needs json-c" - depends on !HAVE_JSON_C - config LUAEXTERNAL bool "lua" depends on LUA diff --git a/parser/parser.c b/parser/parser.c index 46642a4d..60f979af 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -31,8 +31,6 @@ #define NODEROOT (!strlen(CONFIG_PARSERROOT) ? \ "software" : CONFIG_PARSERROOT) -#if defined(CONFIG_LIBCONFIG) || defined(CONFIG_JSON) - typedef int (*parse_element)(parsertype p, void *cfg, void *start, const char **nodes, struct swupdate_cfg *swcfg, lua_State *L); @@ -1056,7 +1054,6 @@ static int parser(parsertype p, void *cfg, struct swupdate_cfg *swcfg) return ret; } -#endif #ifdef CONFIG_LIBCONFIG int parse_cfg (struct swupdate_cfg *swcfg, const char *filename) @@ -1094,8 +1091,6 @@ int parse_cfg (struct swupdate_cfg __attribute__ ((__unused__)) *swcfg, } #endif -#ifdef CONFIG_JSON - #define JSON_OBJECT_FREED 1 int parse_json(struct swupdate_cfg *swcfg, const char *filename) @@ -1159,10 +1154,3 @@ int parse_json(struct swupdate_cfg *swcfg, const char *filename) return ret; } -#else -int parse_json(struct swupdate_cfg __attribute__ ((__unused__)) *swcfg, - const char __attribute__ ((__unused__)) *filename) -{ - return -1; -} -#endif diff --git a/suricatta/Config.in b/suricatta/Config.in index 08362482..f6efa28a 100644 --- a/suricatta/Config.in +++ b/suricatta/Config.in @@ -38,26 +38,19 @@ menu "Server" config SURICATTA_HAWKBIT bool "hawkBit support" default y - depends on HAVE_JSON_C - select JSON help Support for hawkBit server. https://projects.eclipse.org/projects/iot.hawkbit -comment "hawkBit support needs json-c" - depends on !HAVE_JSON_C - config SURICATTA_LUA bool "Suricatta Lua module" - depends on HAVE_JSON_C depends on HAVE_LUA select CHANNEL_CURL - select JSON select LUA help Support for Suricatta modules in Lua. - The optional JSON support for Suricatta Lua modules + The JSON support for Suricatta Lua modules provides JSON as Lua Tables to the Lua realm and enables channel result parsing to JSON per default. To enable, select 'libjson' in 'Parser Features'. @@ -96,21 +89,13 @@ config EMBEDDED_SURICATTA_LUA_SOURCE config SURICATTA_GENERAL bool "General HTTP support" - depends on HAVE_JSON_C - select JSON help Support for Simple HTTP coded server The server uses HTTP return codes to detect if an update is available. See documentation for more details. -comment "General HTTP support needs json-c" - depends on !HAVE_JSON_C - endmenu -comment "hawkBit & Suricatta Lua module support needs json-c" - depends on !HAVE_JSON_C - comment "Suricatta Lua module support needs Lua" depends on !HAVE_LUA diff --git a/suricatta/server_lua.c b/suricatta/server_lua.c index 0244bf2e..62bc35be 100644 --- a/suricatta/server_lua.c +++ b/suricatta/server_lua.c @@ -18,9 +18,7 @@ #include #include -#ifdef CONFIG_JSON #include -#endif #include #include @@ -62,11 +60,7 @@ static channel_data_t channel_data_defaults = { .retry_sleep = CHANNEL_DEFAULT_RESUME_DELAY, .retries = CHANNEL_DEFAULT_RESUME_TRIES, .low_speed_timeout = 300, -#ifdef CONFIG_JSON - .format = CHANNEL_PARSE_JSON, -#else - .format = CHANNEL_PARSE_RAW, -#endif + .format = CHANNEL_PARSE_JSON, /* just default, it can be overwritten */ .debug = false, #ifdef CONFIG_SURICATTA_SSL .usessl = true, @@ -273,8 +267,6 @@ typedef struct { get_from_table_3(__VA_ARGS__) \ ) - -#ifdef CONFIG_JSON /** * @brief Push the Lua equivalent of a JSON type to Table on stack top. * @@ -378,8 +370,6 @@ static bool json_to_table(lua_State *L, json_object *json_root) } return true; } -#endif - /** * @brief Push true or nil to Lua stack according to result argument. @@ -720,7 +710,6 @@ static int channel_do_operation(lua_State *L, channel_method_t op) lua_newtable(L); push_to_table(L, "http_response_code", channel_data.http_response_code); push_to_table(L, "format", channel_data.format); - #ifdef CONFIG_JSON if (channel_data.format == CHANNEL_PARSE_JSON) { lua_pushstring(L, "json_reply"); if (!channel_data.json_reply || @@ -734,7 +723,6 @@ static int channel_do_operation(lua_State *L, channel_method_t op) ERROR("JSON object should be freed but was not."); } } - #endif if (channel_data.format == CHANNEL_PARSE_RAW) { lua_pushstring(L, "raw_reply"); if (!channel_data.raw_reply) { @@ -913,7 +901,6 @@ static void *progress_offloader_thread(void *data) push_to_table(thread_data->L, "hnd_name", (char*)message->hnd_name); push_to_table(thread_data->L, "source", message->source); push_to_table(thread_data->L, "info", (char*)message->info); - #ifdef CONFIG_JSON if (message->infolen > 0) { lua_pushstring(thread_data->L, "jsoninfo"); struct json_object *json_root = json_tokener_parse( @@ -927,7 +914,6 @@ static void *progress_offloader_thread(void *data) } lua_settable(thread_data->L, -3); } - #endif STAILQ_REMOVE_HEAD(&thread_data->progress_msgq, entries); free(qitem); (void)pthread_mutex_unlock(thread_data->progress_msgq_lock); @@ -1985,7 +1971,6 @@ static server_op_res_t server_ipc(ipc_message *msg) lua_pushstring(gL, "msg"); lua_pushlstring(gL, (char *)msg->data.procmsg.buf, msg->data.procmsg.len); lua_settable(gL, -3); - #ifdef CONFIG_JSON if (msg->data.procmsg.len > 0) { lua_pushstring(gL, "json"); struct json_object *json_root = json_tokener_parse(msg->data.procmsg.buf); @@ -1998,7 +1983,6 @@ static server_op_res_t server_ipc(ipc_message *msg) ERROR("JSON object should be freed but was not."); } } - #endif server_op_res_t result = map_lua_result(call_lua_func(gL, SURICATTA_FUNC_IPC, 1)); msg->type = result == SERVER_OK ? ACK : NACK; msg->data.procmsg.len = 0; diff --git a/tools/swupdate-ipc.c b/tools/swupdate-ipc.c index d070b18d..2fd759c5 100644 --- a/tools/swupdate-ipc.c +++ b/tools/swupdate-ipc.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "network_ipc.h" #include @@ -351,8 +352,6 @@ static int sendtohawkbit(cmd_t *cmd, int argc, char *argv[]) { return 0; } -#if defined(CONFIG_JSON) -#include static int gethawkbitstatus(cmd_t __attribute__((__unused__)) *cmd, int __attribute__((__unused__)) argc, char __attribute__((__unused__)) *argv[]) { @@ -388,14 +387,6 @@ static int gethawkbitstatus(cmd_t __attribute__((__unused__)) *cmd, } } -#else -static int gethawkbitstatus(cmd_t __attribute__((__unused__)) *cmd, - int __attribute__((__unused__)) argc, - char **argv) { - fprintf(stderr, "%s: JSON not available, exiting..\n", argv[1]); - return 1; -} -#endif static int sendaes(cmd_t *cmd, int argc, char *argv[]) { char *key, *ivt;