]> granicus.if.org Git - json-c/commitdiff
Add includes and split off json_types.h to help ensure that headers can be included...
authorEric Haszlakiewicz <erh+git@nimenees.com>
Mon, 6 Apr 2020 13:55:27 +0000 (13:55 +0000)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Mon, 6 Apr 2020 13:55:27 +0000 (13:55 +0000)
CMakeLists.txt
arraylist.h
json_object.h
json_object_iterator.h
json_object_private.h
json_types.h [new file with mode: 0644]
strerror_override_private.h
vasprintf_compat.h

index 7ed71eec093d2ea0f36d651b1592ca309dde59df..898974dbedd4eb06db83eed637e036bbb815a5eb 100644 (file)
@@ -298,6 +298,7 @@ set(JSON_C_PUBLIC_HEADERS
     ${PROJECT_SOURCE_DIR}/json_object_iterator.h
     ${PROJECT_SOURCE_DIR}/json_pointer.h
     ${PROJECT_SOURCE_DIR}/json_tokener.h
+    ${PROJECT_SOURCE_DIR}/json_types.h
     ${PROJECT_SOURCE_DIR}/json_util.h
     ${PROJECT_SOURCE_DIR}/json_visit.h
     ${PROJECT_SOURCE_DIR}/linkhash.h
index 9e12ae0a68faddf2fb94879fd98c9d6ee7da92dc..3c4b1b2944e4bf0db1c3c423e567b3ec03ffcf70 100644 (file)
@@ -22,6 +22,8 @@
 extern "C" {
 #endif
 
+#include <stddef.h>
+
 #define ARRAY_LIST_DEFAULT_SIZE 32
 
 typedef void(array_list_free_fn)(void *data);
index 02af93098fc6d1dca3c17775f763ae6ec4051548..53f2944cbfc9934ec1067202b70bc725c783d8fc 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 "json_inttypes.h"
+#include "json_types.h"
 #include "printbuf.h"
+
 #include <stddef.h>
 
 #ifdef __cplusplus
@@ -136,50 +130,6 @@ extern "C" {
  */
 #define JSON_C_OPTION_THREAD (1)
 
-/**
- * A structure to use with json_object_object_foreachC() loops.
- * Contains key, val and entry members.
- */
-struct json_object_iter
-{
-       char *key;
-       struct json_object *val;
-       struct lh_entry *entry;
-};
-typedef struct json_object_iter json_object_iter;
-
-typedef int json_bool;
-
-/**
- * @brief The core type for all type of JSON objects handled by json-c
- */
-typedef struct json_object json_object;
-
-/**
- * Type of custom user delete functions.  See json_object_set_serializer.
- */
-typedef void(json_object_delete_fn)(struct json_object *jso, void *userdata);
-
-/**
- * Type of a custom serialization function.  See json_object_set_serializer.
- */
-typedef int(json_object_to_json_string_fn)(struct json_object *jso, struct printbuf *pb, int level,
-                                           int flags);
-
-/* supported object types */
-
-typedef enum json_type
-{
-       /* If you change this, be sure to update json_type_to_name() too */
-       json_type_null,
-       json_type_boolean,
-       json_type_double,
-       json_type_int,
-       json_type_object,
-       json_type_array,
-       json_type_string
-} json_type;
-
 /* reference counting functions */
 
 /**
index 6713fc9149d09b950728d4ba3ed458ad2a79de0d..a9b1433c74e98a6262ecc69d9d7a262fbbf97fed 100644 (file)
 #ifndef JSON_OBJECT_ITERATOR_H
 #define JSON_OBJECT_ITERATOR_H
 
+#include "json_types.h"
 #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
index 3db0bba3f5278b2ee8e1b358451527c15a61c72f..1c7737a79262b6eca70d347db80b495ba729001a 100644 (file)
@@ -23,6 +23,10 @@ extern "C" {
 /**< how many bytes are directly stored in json_object for strings? */
 #define LEN_DIRECT_STRING_DATA 32
 
+struct json_object;
+#include "json_inttypes.h"
+#include "json_types.h"
+
 typedef void(json_object_private_delete_fn)(struct json_object *o);
 
 /* json object int type, support extension*/
diff --git a/json_types.h b/json_types.h
new file mode 100644 (file)
index 0000000..67f4497
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2020 Eric Hawicz
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the MIT license. See COPYING for details.
+ */
+
+#ifndef _json_types_h_
+#define _json_types_h_
+
+/**
+ * @file
+ * @brief Basic types used in a few places in json-c, but you should include "json_object.h" instead.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef JSON_EXPORT
+#if defined(_MSC_VER)
+#define JSON_EXPORT __declspec(dllexport)
+#else
+#define JSON_EXPORT extern
+#endif
+#endif
+
+struct printbuf;
+
+/**
+ * A structure to use with json_object_object_foreachC() loops.
+ * Contains key, val and entry members.
+ */
+struct json_object_iter
+{
+       char *key;
+       struct json_object *val;
+       struct lh_entry *entry;
+};
+typedef struct json_object_iter json_object_iter;
+
+typedef int json_bool;
+
+/**
+ * @brief The core type for all type of JSON objects handled by json-c
+ */
+typedef struct json_object json_object;
+
+/**
+ * Type of custom user delete functions.  See json_object_set_serializer.
+ */
+typedef void(json_object_delete_fn)(struct json_object *jso, void *userdata);
+
+/**
+ * Type of a custom serialization function.  See json_object_set_serializer.
+ */
+typedef int(json_object_to_json_string_fn)(struct json_object *jso, struct printbuf *pb, int level,
+                                           int flags);
+
+/* supported object types */
+
+typedef enum json_type
+{
+       /* If you change this, be sure to update json_type_to_name() too */
+       json_type_null,
+       json_type_boolean,
+       json_type_double,
+       json_type_int,
+       json_type_object,
+       json_type_array,
+       json_type_string
+} json_type;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index 0f847546c64969dd26d913ede34028ffb8c7c0f3..8726e59fc312a727e41ed456119083d3c597197f 100644 (file)
@@ -6,6 +6,8 @@
  * @brief Do not use, json-c internal, may be changed or removed at any time.
  */
 
+#include "json_types.h"
+
 /* Used by tests to get consistent output */
 JSON_EXPORT int _json_c_strerror_enable;
 
index 0720971435e6b1c9da86f5815f4b867d7510fd51..7b8e8fb56b2423d55b067bea2aec1e7db4c41701 100644 (file)
@@ -8,6 +8,8 @@
 
 #include "snprintf_compat.h"
 
+#include <malloc.h>
+
 #if !defined(HAVE_VASPRINTF)
 /* CAW: compliant version of vasprintf */
 static int vasprintf(char **buf, const char *fmt, va_list ap)