]> granicus.if.org Git - json-c/commitdiff
Fix some Windows compile issues, add JSON_EXPORT's, fix bogus character escapes,...
authorEric Haszlakiewicz <erh+git@nimenees.com>
Sun, 24 Nov 2019 01:31:14 +0000 (20:31 -0500)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Sun, 24 Nov 2019 01:31:14 +0000 (20:31 -0500)
debug.h
json_object.c
json_object.h
random_seed.c
strerror_override_private.h
tests/test_json_pointer.c
tests/test_printbuf.c
tests/test_util_file.c

diff --git a/debug.h b/debug.h
index 07fcc380b3c671aa60619a7f0b4b02f1ae66860d..2dc08300793c08e9a16db781e3db5731d1c8f396 100644 (file)
--- a/debug.h
+++ b/debug.h
 extern "C" {
 #endif
 
-extern void mc_set_debug(int debug);
-extern int mc_get_debug(void);
+#ifndef JSON_EXPORT
+#if defined(_MSC_VER) 
+#define JSON_EXPORT __declspec(dllexport)
+#else
+#define JSON_EXPORT extern
+#endif
+#endif
+
+JSON_EXPORT void mc_set_debug(int debug);
+JSON_EXPORT int mc_get_debug(void);
 
-extern void mc_set_syslog(int syslog);
+JSON_EXPORT void mc_set_syslog(int syslog);
 
-extern void mc_debug(const char *msg, ...);
-extern void mc_error(const char *msg, ...);
-extern void mc_info(const char *msg, ...);
+JSON_EXPORT void mc_debug(const char *msg, ...);
+JSON_EXPORT void mc_error(const char *msg, ...);
+JSON_EXPORT void mc_info(const char *msg, ...);
 
 #ifndef __STRING
 #define __STRING(x) #x
index 192919f4606553a7e5f16cc8e8987b4c915311d2..74d5266f3b53ac2ed10e009fb87f0f7bc7fa45bd 100644 (file)
@@ -166,7 +166,7 @@ static int json_escape_str(struct printbuf *pb, const char *str, int len, int fl
 
 /* reference counting */
 
-extern struct json_object* json_object_get(struct json_object *jso)
+struct json_object* json_object_get(struct json_object *jso)
 {
        if (!jso) return jso;
 
index b0633cc140d5e48717ed98e3cf6ecea72b780077..25cdd03c735ef72a645b00195bb34457458fe695 100644 (file)
@@ -351,7 +351,7 @@ JSON_EXPORT void json_object_set_serializer(json_object *jso,
  * @param jso unused
  * @param userdata the pointer that is passed to free().
  */
-json_object_delete_fn json_object_free_userdata;
+JSON_EXPORT json_object_delete_fn json_object_free_userdata;
 
 /**
  * Copy the jso->_userdata string over to pb as-is.
@@ -362,7 +362,7 @@ json_object_delete_fn json_object_free_userdata;
  * @param level Ignored.
  * @param flags Ignored.
  */
-json_object_to_json_string_fn json_object_userdata_to_json_string;
+JSON_EXPORT json_object_to_json_string_fn json_object_userdata_to_json_string;
 
 #ifdef __clang__
 /* } */
@@ -825,7 +825,7 @@ JSON_EXPORT struct json_object* json_object_new_double_s(double d, const char *d
  *
  * @return -1 on errors, 0 on success.
  */
-int json_c_set_serialization_double_format(const char *double_format, int global_or_thread);
+JSON_EXPORT int json_c_set_serialization_double_format(const char *double_format, int global_or_thread);
 
 
 
@@ -1013,7 +1013,7 @@ typedef int (json_c_shallow_copy_fn)(json_object *src, json_object *parent, cons
  *
  * @return 1 on success, -1 on errors, but never 2.
  */
-json_c_shallow_copy_fn json_c_shallow_copy_default;
+JSON_EXPORT json_c_shallow_copy_fn json_c_shallow_copy_default;
 
 /**
  * Copy the contents of the JSON object.
index 97d9547ff5b16ed5dd862122d38d19d467bec5c8..797fa945cebb439f1d45a69378de9fa817071ade 100644 (file)
@@ -128,7 +128,9 @@ retry:
 
 #include <string.h>
 #include <fcntl.h>
-#include <unistd.h>
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif /* HAVE_UNISTD_H */
 #include <stdlib.h>
 #include <sys/stat.h>
 
index 5180b4f30764dff5fab0258b6ca603c5ea4867a4..0f847546c64969dd26d913ede34028ffb8c7c0f3 100644 (file)
@@ -7,6 +7,6 @@
  */
 
 /* Used by tests to get consistent output */
-extern int _json_c_strerror_enable;
+JSON_EXPORT int _json_c_strerror_enable;
 
 #endif
index 97566e2635718312c40a3ec4f57fc1a5cefb8bf2..231360a0a3ea049063d0f177ba3051b4216205b4 100644 (file)
@@ -20,7 +20,7 @@ static const char *input_json_str = "{ "
        "'foo': ['bar', 'baz'], "
        "'': 0, "
        "'a/b': 1, "
-       "'c\%d': 2, "
+       "'c%d': 2, "
        "'e^f': 3, "
        "'g|h': 4, "
        "'i\\\\j': 5, "
@@ -238,7 +238,7 @@ static void test_example_set()
        assert(0 == json_pointer_set(&jo1, "/", json_object_new_int(9)));
        printf("PASSED - SET - / == 9\n");
 
-       jo2 = json_tokener_parse("{ 'foo': [ 'bar', 'cod' ], '': 9, 'a/b': 1, 'c\%d': 2, 'e^f': 3, 'g|h': 4, 'i\\\\j': 5, 'k\\\"l': 6, ' ': 7, 'm~n': 8, 'fud': { 'gaw': [ 0, 2, 3, 4 ] } }");
+       jo2 = json_tokener_parse("{ 'foo': [ 'bar', 'cod' ], '': 9, 'a/b': 1, 'c%d': 2, 'e^f': 3, 'g|h': 4, 'i\\\\j': 5, 'k\\\"l': 6, ' ': 7, 'm~n': 8, 'fud': { 'gaw': [ 0, 2, 3, 4 ] } }");
        assert(json_object_equal(jo2, jo1));
        printf("PASSED - SET - Final JSON is: %s\n", json_object_get_string(jo1));
        json_object_put(jo2);
index 0dd2dc9f81d0b5c922a2299f7ff256a589f0d4d7..06dd13d9477085574b0ec3f32e780216f79f3335 100644 (file)
 static void test_basic_printbuf_memset(void);
 static void test_printbuf_memset_length(void);
 
+#ifndef __func__
+/* VC++ compat */
+#define __func__ __FUNCTION__
+#endif
+
 static void test_basic_printbuf_memset()
 {
        struct printbuf *pb;
@@ -158,7 +163,7 @@ int main(int argc, char **argv)
 {
        int before_resize = 0;
 
-       mc_set_debug(1);
+       MC_SET_DEBUG(1);
 
        test_basic_printbuf_memset();
        printf("========================================\n");
index 9aaab238a4ffe68a507524c5e78bd21708d1467d..d4145478642ee97bf33bbc228ea8c916585c9f5f 100644 (file)
@@ -6,7 +6,9 @@
 #include <string.h>
 #include <fcntl.h>
 #include <limits.h>
-#include <unistd.h>
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif /* HAVE_UNISTD_H */
 #include <sys/types.h>
 #include <sys/stat.h>