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
/* 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;
* @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.
* @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__
/* } */
*
* @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);
*
* @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.
#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>
*/
/* Used by tests to get consistent output */
-extern int _json_c_strerror_enable;
+JSON_EXPORT int _json_c_strerror_enable;
#endif
"'foo': ['bar', 'baz'], "
"'': 0, "
"'a/b': 1, "
- "'c\%d': 2, "
+ "'c%d': 2, "
"'e^f': 3, "
"'g|h': 4, "
"'i\\\\j': 5, "
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);
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;
{
int before_resize = 0;
- mc_set_debug(1);
+ MC_SET_DEBUG(1);
test_basic_printbuf_memset();
printf("========================================\n");
#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>