mirror of
https://github.com/json-c/json-c.git
synced 2026-03-23 23:19:06 +08:00
Issue #488: use JSON_EXPORT on functions so they are properly exported on Windows.
This commit is contained in:
@@ -20,11 +20,19 @@
|
||||
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
|
||||
|
||||
@@ -33,11 +33,13 @@
|
||||
#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"
|
||||
|
||||
@@ -26,6 +26,14 @@
|
||||
|
||||
#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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(),
|
||||
|
||||
18
json_util.h
18
json_util.h
@@ -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
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
/**
|
||||
|
||||
20
printbuf.h
20
printbuf.h
@@ -23,6 +23,14 @@
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user