From 1aa2197fd4b021ec5b9e7ffc477ceb89cca54d1f Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 6 Oct 2016 08:38:10 +0200 Subject: [PATCH] client: add an option to use pre-0.9.2 json-c format The format has been changed in c8b8b858bbba to match the JSON format used when compiled with Jansson. Some users may want to revert this change. Add `--enable-json0` option for that. --- NEWS | 5 +++++ configure.ac | 1 + src/client/jansson_writer.c | 4 +++- src/client/jsonc_writer.c | 4 +++- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index d104d7c3..f8a2b8b3 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +lldpd (0.9.6) + * Change: + + Add a compile-time option to restore pre-0.9.2 JSON format (when + using json-c). Use `--enable-json0` to enable this option. + lldpd (0.9.5) * Change: + More Ethernet media supported. However, RFC4836 is quite diff --git a/configure.ac b/configure.ac index c7eef8db..532d0a8d 100644 --- a/configure.ac +++ b/configure.ac @@ -291,6 +291,7 @@ else lldp_CHECK_JANSSON lldp_CHECK_JSONC fi +lldp_ARG_ENABLE([json0], [use of pre-0.9.2 JSON/json-c format], [no]) # Seccomp AC_ARG_WITH([seccomp], diff --git a/src/client/jansson_writer.c b/src/client/jansson_writer.c index 6181518c..15d45393 100644 --- a/src/client/jansson_writer.c +++ b/src/client/jansson_writer.c @@ -96,8 +96,9 @@ jansson_data(struct writer *w, const char *data) static json_t* jansson_cleanup(json_t *el) { - json_t *new; if (el == NULL) return NULL; +#ifndef ENABLE_JSON0 + json_t *new; if (json_is_array(el) && json_array_size(el) == 1) { new = json_array_get(el, 0); return jansson_cleanup(new); @@ -144,6 +145,7 @@ jansson_cleanup(json_t *el) } return new; } +#endif json_incref(el); return el; } diff --git a/src/client/jsonc_writer.c b/src/client/jsonc_writer.c index 2e83f0251..6e67aad2 100644 --- a/src/client/jsonc_writer.c +++ b/src/client/jsonc_writer.c @@ -95,8 +95,9 @@ jsonc_data(struct writer *w, const char *data) static json_object* jsonc_cleanup(json_object *el) { - json_object *new; if (el == NULL) return NULL; +#ifndef ENABLE_JSON0 + json_object *new; if (json_object_get_type(el) == json_type_array) { size_t len = json_object_array_length(el); if (len == 1) { @@ -140,6 +141,7 @@ jsonc_cleanup(json_object *el) } return new; } +#endif json_object_get(el); return el; } -- 2.39.5