From d061c979337f526759e2c72ea5e1ebff13e714e5 Mon Sep 17 00:00:00 2001 From: Christof Schulze Date: Sat, 2 Nov 2019 00:14:39 +0100 Subject: [PATCH] gluon-mesh-babel: respondd: support libjson-c-0.12 and libjson-c-0.13 This can be reverted after updating the package feed to something newer than 080ba31eec2ff4c165ce5a1bb9d434ddd91bdb6b from 2019-04-30 and should be in the upcoming openwrt release after 19.07 --- package/gluon-mesh-babel/src/respondd.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/package/gluon-mesh-babel/src/respondd.c b/package/gluon-mesh-babel/src/respondd.c index 153087fa..552b17f8 100644 --- a/package/gluon-mesh-babel/src/respondd.c +++ b/package/gluon-mesh-babel/src/respondd.c @@ -841,11 +841,20 @@ static struct json_object * respondd_provider_neighbours(void) { if (neighbours) { pthread_rwlock_rdlock(&neighbours_lock); - int deepcopy_state = json_object_deep_copy(neighbours, neighbours_copy, NULL); +#if (JSON_C_MINOR_VERSION >= 13) + int deepcopy_state = json_object_deep_copy(neighbours, &neighbours_copy, NULL); +#else + char *serialized_neighbours = json_object_to_json_string(neighbours); +#endif pthread_rwlock_unlock(&neighbours_lock); +#if (JSON_C_MINOR_VERSION >= 13) if (!deepcopy_state) json_object_object_add(ret, "babel", neighbours_copy); +#else + if (serialized_neighbours) + json_object_object_add(ret, "babel", json_tokener_parse(serialized_neighbours)); +#endif } return ret;