]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
client: add an option to use pre-0.9.2 json-c format
authorVincent Bernat <vincent@bernat.im>
Thu, 6 Oct 2016 06:38:10 +0000 (08:38 +0200)
committerVincent Bernat <vincent@bernat.im>
Thu, 6 Oct 2016 18:00:27 +0000 (20:00 +0200)
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
configure.ac
src/client/jansson_writer.c
src/client/jsonc_writer.c

diff --git a/NEWS b/NEWS
index d104d7c39b9b584454d6b88bddbac23af2b907cc..f8a2b8b3b18c0c19826b4253f4c5591d450b38a5 100644 (file)
--- 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
index c7eef8db07296987d6000524fb87fb69a5f4aca1..532d0a8d9e297a5309783f13fed8ec1548d5c4a9 100644 (file)
@@ -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],
index 6181518c68e2ca63d867a2cbb0b97d76a5f0735b..15d45393de97588f0bbc6d042e6961f98c211f4d 100644 (file)
@@ -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;
 }
index 2e83f0251f30783b785dafc80ebf2776ce0746dc..6e67aad2304f9176e15fff04e3481091c08633ec 100644 (file)
@@ -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;
 }