]> git.ipfire.org Git - thirdparty/json-c.git/commitdiff
Issue #488: use JSON_EXPORT on functions so they are properly exported on Windows.
authorEric Haszlakiewicz <erh+git@nimenees.com>
Mon, 9 Sep 2019 02:42:36 +0000 (22:42 -0400)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Mon, 9 Sep 2019 02:42:36 +0000 (22:42 -0400)
json_c_version.h
json_object.h
json_object_iterator.h
json_pointer.h
json_tokener.h
json_util.h
json_visit.h
printbuf.h

index a623f384802d187f70df14ad3de6e9cb86a290fa..21e79be49b0a21e8ca67b85da0b3bdd26cdeccfe 100644 (file)
                             JSON_C_MICRO_VERSION)
 #define JSON_C_VERSION "0.13.99"
 
+#ifndef JSON_EXPORT
+#if defined(_MSC_VER) 
+#define JSON_EXPORT __declspec(dllexport)
+#else
+#define JSON_EXPORT extern
+#endif
+#endif
+
 /**
  * @see JSON_C_VERSION
  * @return the version of the json-c library as a string
  */
-const char *json_c_version(void); /* Returns JSON_C_VERSION */
+JSON_EXPORT const char *json_c_version(void); /* Returns JSON_C_VERSION */
 
 /**
  * The json-c version encoded into an int, with the low order 8 bits
@@ -35,6 +43,6 @@ const char *json_c_version(void); /* Returns JSON_C_VERSION */
  * @see JSON_C_VERSION_NUM
  * @return the version of the json-c library as an int
  */
-int json_c_version_num(void);     /* Returns JSON_C_VERSION_NUM */
+JSON_EXPORT int json_c_version_num(void);     /* Returns JSON_C_VERSION_NUM */
 
 #endif
index c4a9cb23e94bb25b9d8faf9c40ac1b336cab3629..b0633cc140d5e48717ed98e3cf6ecea72b780077 100644 (file)
 #define JSON_C_CONST_FUNCTION(func) func
 #endif
 
+#ifndef JSON_EXPORT
 #if defined(_MSC_VER) 
 #define JSON_EXPORT __declspec(dllexport)
 #else
 #define JSON_EXPORT extern
 #endif
+#endif
 
 #include <stddef.h>
 #include "json_inttypes.h"
index f226cbd524a3673544e81e60a1cf7b296996f55c..78a1e791e34cf0139483823b5fea52adc3281163 100644 (file)
 
 #include <stddef.h>
 
+#ifndef JSON_EXPORT
+#if defined(_MSC_VER) 
+#define JSON_EXPORT __declspec(dllexport)
+#else
+#define JSON_EXPORT extern
+#endif
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -72,7 +80,7 @@ struct json_object;
  *
  * @return json_object_iterator
  */
-struct json_object_iterator
+JSON_EXPORT struct json_object_iterator
 json_object_iter_init_default(void);
 
 /** Retrieves an iterator to the first pair of the JSON Object.
@@ -106,7 +114,7 @@ json_object_iter_init_default(void);
  *
  * @endcode
  */
-struct json_object_iterator
+JSON_EXPORT struct json_object_iterator
 json_object_iter_begin(struct json_object* obj);
 
 /** Retrieves the iterator that represents the position beyond the
@@ -137,7 +145,7 @@ json_object_iter_begin(struct json_object* obj);
  *              (i.e., NOT the last pair, but "beyond the last
  *              pair" value)
  */
-struct json_object_iterator
+JSON_EXPORT struct json_object_iterator
 json_object_iter_end(const struct json_object* obj);
 
 /** Returns an iterator to the next pair, if any
@@ -155,7 +163,7 @@ json_object_iter_end(const struct json_object* obj);
  *         of json_object_iter_end() for the same JSON Object
  *         instance.
  */
-void
+JSON_EXPORT void
 json_object_iter_next(struct json_object_iterator* iter);
 
 
@@ -174,7 +182,7 @@ json_object_iter_next(struct json_object_iterator* iter);
  *         deleted or modified, and MUST NOT be modified or
  *         freed by the user.
  */
-const char*
+JSON_EXPORT const char*
 json_object_iter_peek_name(const struct json_object_iterator* iter);
 
 
@@ -197,7 +205,7 @@ json_object_iter_peek_name(const struct json_object_iterator* iter);
  *         the JSON Null value as a NULL json_object instance
  *         pointer.
  */
-struct json_object*
+JSON_EXPORT struct json_object*
 json_object_iter_peek_value(const struct json_object_iterator* iter);
 
 
@@ -227,7 +235,7 @@ json_object_iter_peek_value(const struct json_object_iterator* iter);
  *         reference the same name/value pair or are both at
  *         "end"); zero if they are not equal.
  */
-json_bool
+JSON_EXPORT json_bool
 json_object_iter_equal(const struct json_object_iterator* iter1,
                        const struct json_object_iterator* iter2);
 
index daad977331169566953a7d72ebd3d50ff919d48a..75c5c1c57f1898e243dd45789fe668220328e27b 100644 (file)
@@ -44,7 +44,7 @@ extern "C" {
  *
  * @return negative if an error (or not found), or 0 if succeeded
  */
-int json_pointer_get(struct json_object *obj, const char *path, struct json_object **res);
+JSON_EXPORT int json_pointer_get(struct json_object *obj, const char *path, struct json_object **res);
 
 /**
  * This is a variant of 'json_pointer_get()' that supports printf() style arguments.
@@ -62,7 +62,7 @@ int json_pointer_get(struct json_object *obj, const char *path, struct json_obje
  *
  * @return negative if an error (or not found), or 0 if succeeded
  */
-int json_pointer_getf(struct json_object *obj, struct json_object **res, const char *path_fmt, ...);
+JSON_EXPORT int json_pointer_getf(struct json_object *obj, struct json_object **res, const char *path_fmt, ...);
 
 /**
  * Sets JSON object 'value' in the 'obj' tree at the location specified
@@ -93,7 +93,7 @@ int json_pointer_getf(struct json_object *obj, struct json_object **res, const c
  *
  * @return negative if an error (or not found), or 0 if succeeded
  */
-int json_pointer_set(struct json_object **obj, const char *path, struct json_object *value);
+JSON_EXPORT int json_pointer_set(struct json_object **obj, const char *path, struct json_object *value);
 
 /**
  * This is a variant of 'json_pointer_set()' that supports printf() style arguments.
@@ -110,7 +110,7 @@ int json_pointer_set(struct json_object **obj, const char *path, struct json_obj
  *
  * @return negative if an error (or not found), or 0 if succeeded
  */
-int json_pointer_setf(struct json_object **obj, struct json_object *value, const char *path_fmt, ...);
+JSON_EXPORT int json_pointer_setf(struct json_object **obj, struct json_object *value, const char *path_fmt, ...);
 
 
 #ifdef __cplusplus
index 34deda8a02211eba992135fb0d6d201b426c72e9..da2b24c161ca421887566ef2c683d29e6e9a87fc 100644 (file)
@@ -116,7 +116,7 @@ struct json_tokener
  *
  * See json_tokener_parse_ex() for an example of how to use this.
  */
-size_t json_tokener_get_parse_end(struct json_tokener *tok);
+JSON_EXPORT size_t json_tokener_get_parse_end(struct json_tokener *tok);
 
 
 /**
@@ -142,7 +142,7 @@ typedef struct json_tokener json_tokener;
  *
  * @return a generic error message is returned if an invalid error value is provided.
  */
-const char *json_tokener_error_desc(enum json_tokener_error jerr);
+JSON_EXPORT const char *json_tokener_error_desc(enum json_tokener_error jerr);
 
 /**
  * Retrieve the error caused by the last call to json_tokener_parse_ex(),
index 3e1b29478bd875b1d5475c25bd21aa3fc72ef6a1..70a7d56c0fde1e758e90c65c8ee6aec37c617856 100644 (file)
@@ -40,7 +40,7 @@ extern "C" {
  *
  * Returns NULL on failure.  See json_util_get_last_err() for details.
  */
-extern struct json_object* json_object_from_file(const char *filename);
+JSON_EXPORT struct json_object* json_object_from_file(const char *filename);
 
 /**
  * Create a JSON object from already opened file descriptor.
@@ -52,7 +52,7 @@ extern struct json_object* json_object_from_file(const char *filename);
  *
  * Returns NULL on failure.  See json_util_get_last_err() for details.
  */
-extern struct json_object* json_object_from_fd(int fd);
+JSON_EXPORT struct json_object* json_object_from_fd(int fd);
 
 /**
  * Equivalent to:
@@ -60,7 +60,7 @@ extern struct json_object* json_object_from_fd(int fd);
  *
  * Returns -1 if something fails.  See json_util_get_last_err() for details.
  */
-extern int json_object_to_file(const char *filename, struct json_object *obj);
+JSON_EXPORT int json_object_to_file(const char *filename, struct json_object *obj);
 
 /**
  * Open and truncate the given file, creating it if necessary, then
@@ -68,7 +68,7 @@ extern int json_object_to_file(const char *filename, struct json_object *obj);
  *
  * Returns -1 if something fails.  See json_util_get_last_err() for details.
  */
-extern int json_object_to_file_ext(const char *filename, struct json_object *obj, int flags);
+JSON_EXPORT int json_object_to_file_ext(const char *filename, struct json_object *obj, int flags);
 
 /**
  * Convert the json_object to a string and write it to the file descriptor.
@@ -80,24 +80,24 @@ extern int json_object_to_file_ext(const char *filename, struct json_object *obj
  * @param flags flags to pass to json_object_to_json_string_ext()
  * @return -1 if something fails.  See json_util_get_last_err() for details.
  */
-extern int json_object_to_fd(int fd, struct json_object *obj, int flags);
+JSON_EXPORT int json_object_to_fd(int fd, struct json_object *obj, int flags);
 
 /**
  * Return the last error from various json-c functions, including:
  * json_object_to_file{,_ext}, json_object_to_fd() or
  * json_object_from_{file,fd}, or NULL if there is none.
  */
-const char *json_util_get_last_err(void);
+JSON_EXPORT const char *json_util_get_last_err(void);
 
 
-extern int json_parse_int64(const char *buf, int64_t *retval);
-extern int json_parse_double(const char *buf, double *retval);
+JSON_EXPORT int json_parse_int64(const char *buf, int64_t *retval);
+JSON_EXPORT int json_parse_double(const char *buf, double *retval);
 
 /**
  * Return a string describing the type of the object.
  * e.g. "int", or "object", etc...
  */
-extern const char *json_type_to_name(enum json_type o_type);
+JSON_EXPORT const char *json_type_to_name(enum json_type o_type);
 
 #ifdef __cplusplus
 }
index b147d99ebc84662c75d2f878f778e090d7714a7a..7fc21ff2b1423d32c716de9a30688a8ac7ff1ecd 100644 (file)
@@ -31,7 +31,7 @@ typedef int (json_c_visit_userfunc)(json_object *jso, int flags,
  * Returns <0 if an error occurred during iteration, including if
  *  userfunc returned JSON_C_VISIT_RETURN_ERROR.
  */
-int json_c_visit(json_object *jso, int future_flags,
+JSON_EXPORT int json_c_visit(json_object *jso, int future_flags,
                  json_c_visit_userfunc *userfunc, void *userarg);
 
 /**
index 567a6a08bb2d83d737d5487337d03de62f74b14b..8d39f07a8e1b9bf0a83b1d5d1e3dfd553d528ca0 100644 (file)
 #ifndef _printbuf_h_
 #define _printbuf_h_
 
+#ifndef JSON_EXPORT
+#if defined(_MSC_VER) 
+#define JSON_EXPORT __declspec(dllexport)
+#else
+#define JSON_EXPORT extern
+#endif
+#endif
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -34,7 +42,7 @@ struct printbuf {
 };
 typedef struct printbuf printbuf;
 
-extern struct printbuf*
+JSON_EXPORT struct printbuf*
 printbuf_new(void);
 
 /* As an optimization, printbuf_memappend_fast() is defined as a macro
@@ -45,7 +53,7 @@ printbuf_new(void);
  * Your code should not use printbuf_memappend() directly unless it
  * checks the return code. Use printbuf_memappend_fast() instead.
  */
-extern int
+JSON_EXPORT int
 printbuf_memappend(struct printbuf *p, const char *buf, int size);
 
 #define printbuf_memappend_fast(p, bufptr, bufsize)          \
@@ -89,7 +97,7 @@ do {                                                         \
  *
  * If offset is -1, this starts at the end of the current data in the buffer.
  */
-extern int
+JSON_EXPORT int
 printbuf_memset(struct printbuf *pb, int offset, int charvalue, int len);
 
 /**
@@ -106,13 +114,13 @@ printbuf_memset(struct printbuf *pb, int offset, int charvalue, int len);
  *   printbuf_memappend()
  *   printbuf_strappend()
  */
-extern int
+JSON_EXPORT int
 sprintbuf(struct printbuf *p, const char *msg, ...);
 
-extern void
+JSON_EXPORT void
 printbuf_reset(struct printbuf *p);
 
-extern void
+JSON_EXPORT void
 printbuf_free(struct printbuf *p);
 
 #ifdef __cplusplus