Browse code

Enable use of older json-c libraries

Shawn Webb authored on 2014/06/26 09:29:55
Showing 7 changed files
... ...
@@ -151,6 +151,10 @@
151 151
    you don't. */
152 152
 #undef HAVE_DECL_CYGWIN_CONV_PATH
153 153
 
154
+/* Define to 1 if you have a deprecated version of the 'libjson' library
155
+   (-ljson). */
156
+#undef HAVE_DEPRECATED_JSON
157
+
154 158
 /* Define to 1 if you have the <dirent.h> header file. */
155 159
 #undef HAVE_DIRENT_H
156 160
 
... ...
@@ -17233,9 +17233,72 @@ $as_echo "$ac_cv_search_json_object_object_get_ex" >&6; }
17233 17233
 ac_res=$ac_cv_search_json_object_object_get_ex
17234 17234
 if test "$ac_res" != no; then :
17235 17235
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
17236
-  have_json="yes"
17236
+
17237
+have_json="yes"
17238
+have_deprecated_json="no"
17239
+else
17240
+
17241
+have_json="no"
17242
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing json_object_object_get" >&5
17243
+$as_echo_n "checking for library containing json_object_object_get... " >&6; }
17244
+if ${ac_cv_search_json_object_object_get+:} false; then :
17245
+  $as_echo_n "(cached) " >&6
17237 17246
 else
17238
-  have_json="no"
17247
+  ac_func_search_save_LIBS=$LIBS
17248
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
17249
+/* end confdefs.h.  */
17250
+
17251
+/* Override any GCC internal prototype to avoid an error.
17252
+   Use char because int might match the return type of a GCC
17253
+   builtin and then its argument prototype would still apply.  */
17254
+#ifdef __cplusplus
17255
+extern "C"
17256
+#endif
17257
+char json_object_object_get ();
17258
+int
17259
+main ()
17260
+{
17261
+return json_object_object_get ();
17262
+  ;
17263
+  return 0;
17264
+}
17265
+_ACEOF
17266
+for ac_lib in '' json-c json; do
17267
+  if test -z "$ac_lib"; then
17268
+    ac_res="none required"
17269
+  else
17270
+    ac_res=-l$ac_lib
17271
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
17272
+  fi
17273
+  if ac_fn_c_try_link "$LINENO"; then :
17274
+  ac_cv_search_json_object_object_get=$ac_res
17275
+fi
17276
+rm -f core conftest.err conftest.$ac_objext \
17277
+    conftest$ac_exeext
17278
+  if ${ac_cv_search_json_object_object_get+:} false; then :
17279
+  break
17280
+fi
17281
+done
17282
+if ${ac_cv_search_json_object_object_get+:} false; then :
17283
+
17284
+else
17285
+  ac_cv_search_json_object_object_get=no
17286
+fi
17287
+rm conftest.$ac_ext
17288
+LIBS=$ac_func_search_save_LIBS
17289
+fi
17290
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_json_object_object_get" >&5
17291
+$as_echo "$ac_cv_search_json_object_object_get" >&6; }
17292
+ac_res=$ac_cv_search_json_object_object_get
17293
+if test "$ac_res" != no; then :
17294
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
17295
+
17296
+have_json="yes"
17297
+have_deprecated_json="yes"
17298
+
17299
+fi
17300
+
17301
+
17239 17302
 fi
17240 17303
 
17241 17304
 
... ...
@@ -17247,6 +17310,11 @@ if test "X$have_json" = "Xyes"; then
17247 17247
 
17248 17248
 $as_echo "#define HAVE_JSON 1" >>confdefs.h
17249 17249
 
17250
+  if test "X$have_deprecated_json" = "Xyes"; then
17251
+
17252
+$as_echo "#define HAVE_DEPRECATED_JSON 1" >>confdefs.h
17253
+
17254
+  fi
17250 17255
   JSON_LIBS="$LIBS"
17251 17256
 fi
17252 17257
 
... ...
@@ -3,6 +3,10 @@
3 3
 /* Define if building universal (internal helper macro) */
4 4
 #undef AC_APPLE_UNIVERSAL_BUILD
5 5
 
6
+/* Define to 1 if you have a deprecated version of the 'libjson' library
7
+   (-ljson). */
8
+#undef HAVE_DEPRECATED_JSON
9
+
6 10
 /* Define to 1 if you have the <dlfcn.h> header file. */
7 11
 #undef HAVE_DLFCN_H
8 12
 
... ...
@@ -16020,9 +16020,72 @@ $as_echo "$ac_cv_search_json_object_object_get_ex" >&6; }
16020 16020
 ac_res=$ac_cv_search_json_object_object_get_ex
16021 16021
 if test "$ac_res" != no; then :
16022 16022
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
16023
-  have_json="yes"
16023
+
16024
+have_json="yes"
16025
+have_deprecated_json="no"
16026
+else
16027
+
16028
+have_json="no"
16029
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing json_object_object_get" >&5
16030
+$as_echo_n "checking for library containing json_object_object_get... " >&6; }
16031
+if ${ac_cv_search_json_object_object_get+:} false; then :
16032
+  $as_echo_n "(cached) " >&6
16024 16033
 else
16025
-  have_json="no"
16034
+  ac_func_search_save_LIBS=$LIBS
16035
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16036
+/* end confdefs.h.  */
16037
+
16038
+/* Override any GCC internal prototype to avoid an error.
16039
+   Use char because int might match the return type of a GCC
16040
+   builtin and then its argument prototype would still apply.  */
16041
+#ifdef __cplusplus
16042
+extern "C"
16043
+#endif
16044
+char json_object_object_get ();
16045
+int
16046
+main ()
16047
+{
16048
+return json_object_object_get ();
16049
+  ;
16050
+  return 0;
16051
+}
16052
+_ACEOF
16053
+for ac_lib in '' json-c json; do
16054
+  if test -z "$ac_lib"; then
16055
+    ac_res="none required"
16056
+  else
16057
+    ac_res=-l$ac_lib
16058
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
16059
+  fi
16060
+  if ac_fn_c_try_link "$LINENO"; then :
16061
+  ac_cv_search_json_object_object_get=$ac_res
16062
+fi
16063
+rm -f core conftest.err conftest.$ac_objext \
16064
+    conftest$ac_exeext
16065
+  if ${ac_cv_search_json_object_object_get+:} false; then :
16066
+  break
16067
+fi
16068
+done
16069
+if ${ac_cv_search_json_object_object_get+:} false; then :
16070
+
16071
+else
16072
+  ac_cv_search_json_object_object_get=no
16073
+fi
16074
+rm conftest.$ac_ext
16075
+LIBS=$ac_func_search_save_LIBS
16076
+fi
16077
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_json_object_object_get" >&5
16078
+$as_echo "$ac_cv_search_json_object_object_get" >&6; }
16079
+ac_res=$ac_cv_search_json_object_object_get
16080
+if test "$ac_res" != no; then :
16081
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
16082
+
16083
+have_json="yes"
16084
+have_deprecated_json="yes"
16085
+
16086
+fi
16087
+
16088
+
16026 16089
 fi
16027 16090
 
16028 16091
 
... ...
@@ -16034,6 +16097,11 @@ if test "X$have_json" = "Xyes"; then
16034 16034
 
16035 16035
 $as_echo "#define HAVE_JSON 1" >>confdefs.h
16036 16036
 
16037
+  if test "X$have_deprecated_json" = "Xyes"; then
16038
+
16039
+$as_echo "#define HAVE_DEPRECATED_JSON 1" >>confdefs.h
16040
+
16041
+  fi
16037 16042
   JSON_LIBS="$LIBS"
16038 16043
 fi
16039 16044
 
... ...
@@ -281,6 +281,30 @@ json_object *cli_jsonobj(json_object *obj, const char *key)
281 281
     return newobj;
282 282
 }
283 283
 
284
+#if HAVE_DEPRECATED_JSON
285
+int json_object_object_get_ex(struct json_object *obj, const char *key, struct json_object **value)
286
+{
287
+    struct json_object *res;
288
+
289
+    if (value != NULL)
290
+        *value = NULL;
291
+
292
+    if (obj == NULL)
293
+        return 0;
294
+
295
+    if (json_object_get_type(obj) != json_type_object)
296
+        return 0;
297
+
298
+    res = json_object_object_get(obj, key);
299
+    if (value != NULL) {
300
+        *value = res;
301
+        return (res != NULL);
302
+    }
303
+
304
+    return (res != NULL);
305
+}
306
+#endif
307
+
284 308
 #else
285 309
 
286 310
 int cli_json_nojson()
... ...
@@ -49,6 +49,10 @@ json_object *cli_jsonarray(json_object *obj, const char *key);
49 49
 int cli_jsonint_array(json_object *obj, int32_t val);
50 50
 json_object *cli_jsonobj(json_object *obj, const char *key);
51 51
 
52
+#if HAVE_DEPRECATED_JSON
53
+int json_object_object_get_ex(struct json_object *obj, const char *key, struct json_object **value);
54
+#endif
55
+
52 56
 #define JSON_KEY_FILETYPE   "FileType"
53 57
 #define JSON_KEY_FILESIZE   "FileSize"
54 58
 
... ...
@@ -62,7 +62,15 @@ then
62 62
     CFLAGS="$CFLAGS $JSON_CPPFLAGS"
63 63
   fi
64 64
 
65
-  AC_SEARCH_LIBS([json_object_object_get_ex], [json-c json], [have_json="yes"], [have_json="no"])
65
+  AC_SEARCH_LIBS([json_object_object_get_ex], [json-c json], [
66
+have_json="yes"
67
+have_deprecated_json="no"], [
68
+have_json="no"
69
+AC_SEARCH_LIBS([json_object_object_get], [json-c json], [
70
+have_json="yes"
71
+have_deprecated_json="yes"
72
+])
73
+])
66 74
 
67 75
   CFLAGS="$save_CFLAGS"
68 76
   LDFLAGS="$save_LDFLAGS"
... ...
@@ -70,6 +78,9 @@ fi
70 70
 
71 71
 if test "X$have_json" = "Xyes"; then
72 72
   AC_DEFINE([HAVE_JSON],1,[Define to 1 if you have the 'libjson' library (-ljson).])
73
+  if test "X$have_deprecated_json" = "Xyes"; then
74
+    AC_DEFINE([HAVE_DEPRECATED_JSON],1,[Define to 1 if you have a deprecated version of the 'libjson' library (-ljson).])
75
+  fi
73 76
   JSON_LIBS="$LIBS"
74 77
 fi
75 78