| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
#ifndef cJSON__h |
| 31 |
#define cJSON__h |
| 32 |
|
| 33 |
#ifdef __cplusplus |
| 34 |
extern "C" |
| 35 |
{ |
| 36 |
#endif |
| 37 |
|
| 38 |
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)) |
| 39 |
#define __WINDOWS__ |
| 40 |
#endif |
| 41 |
|
| 42 |
#ifdef __WINDOWS__ |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
#define CJSON_CDECL __cdecl |
| 63 |
#define CJSON_STDCALL __stdcall |
| 64 |
|
| 65 |
|
| 66 |
#if !defined(CJSON_HIDE_SYMBOLS) && !defined(CJSON_IMPORT_SYMBOLS) && !defined(CJSON_EXPORT_SYMBOLS) |
| 67 |
#define CJSON_EXPORT_SYMBOLS |
| 68 |
#endif |
| 69 |
|
| 70 |
#if defined(CJSON_HIDE_SYMBOLS) |
| 71 |
#define CJSON_PUBLIC(type) type CJSON_STDCALL |
| 72 |
#elif defined(CJSON_EXPORT_SYMBOLS) |
| 73 |
#define CJSON_PUBLIC(type) __declspec(dllexport) type CJSON_STDCALL |
| 74 |
#elif defined(CJSON_IMPORT_SYMBOLS) |
| 75 |
#define CJSON_PUBLIC(type) __declspec(dllimport) type CJSON_STDCALL |
| 76 |
#endif |
| 77 |
#else |
| 78 |
#define CJSON_CDECL |
| 79 |
#define CJSON_STDCALL |
| 80 |
|
| 81 |
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(CJSON_API_VISIBILITY) |
| 82 |
#define CJSON_PUBLIC(type) __attribute__((visibility("default"))) type |
| 83 |
#else |
| 84 |
#define CJSON_PUBLIC(type) type |
| 85 |
#endif |
| 86 |
#endif |
| 87 |
|
| 88 |
|
| 89 |
#define CJSON_VERSION_MAJOR 1 |
| 90 |
#define CJSON_VERSION_MINOR 7 |
| 91 |
#define CJSON_VERSION_PATCH 19 |
| 92 |
|
| 93 |
#include <stddef.h> |
| 94 |
|
| 95 |
|
| 96 |
#define cJSON_Invalid (0) |
| 97 |
#define cJSON_False (1 << 0) |
| 98 |
#define cJSON_True (1 << 1) |
| 99 |
#define cJSON_NULL (1 << 2) |
| 100 |
#define cJSON_Number (1 << 3) |
| 101 |
#define cJSON_String (1 << 4) |
| 102 |
#define cJSON_Array (1 << 5) |
| 103 |
#define cJSON_Object (1 << 6) |
| 104 |
#define cJSON_Raw (1 << 7) |
| 105 |
|
| 106 |
#define cJSON_IsReference 256 |
| 107 |
#define cJSON_StringIsConst 512 |
| 108 |
|
| 109 |
|
| 110 |
typedef struct cJSON |
| 111 |
{ |
| 112 |
|
| 113 |
struct cJSON *next; |
| 114 |
struct cJSON *prev; |
| 115 |
|
| 116 |
struct cJSON *child; |
| 117 |
|
| 118 |
|
| 119 |
int type; |
| 120 |
|
| 121 |
|
| 122 |
char *valuestring; |
| 123 |
|
| 124 |
int valueint; |
| 125 |
|
| 126 |
double valuedouble; |
| 127 |
|
| 128 |
|
| 129 |
char *string; |
| 130 |
} cJSON; |
| 131 |
|
| 132 |
typedef struct cJSON_Hooks |
| 133 |
{ |
| 134 |
|
| 135 |
void *(CJSON_CDECL *malloc_fn)(size_t sz); |
| 136 |
void (CJSON_CDECL *free_fn)(void *ptr); |
| 137 |
} cJSON_Hooks; |
| 138 |
|
| 139 |
typedef int cJSON_bool; |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
#ifndef CJSON_NESTING_LIMIT |
| 144 |
#define CJSON_NESTING_LIMIT 1000 |
| 145 |
#endif |
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
#ifndef CJSON_CIRCULAR_LIMIT |
| 150 |
#define CJSON_CIRCULAR_LIMIT 10000 |
| 151 |
#endif |
| 152 |
|
| 153 |
|
| 154 |
CJSON_PUBLIC(const char*) cJSON_Version(void); |
| 155 |
|
| 156 |
|
| 157 |
CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks); |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value); |
| 162 |
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLength(const char *value, size_t buffer_length); |
| 163 |
|
| 164 |
|
| 165 |
CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated); |
| 166 |
CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const char *value, size_t buffer_length, const char **return_parse_end, cJSON_bool require_null_terminated); |
| 167 |
|
| 168 |
|
| 169 |
CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item); |
| 170 |
|
| 171 |
CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item); |
| 172 |
|
| 173 |
CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt); |
| 174 |
|
| 175 |
|
| 176 |
CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buffer, const int length, const cJSON_bool format); |
| 177 |
|
| 178 |
CJSON_PUBLIC(void) cJSON_Delete(cJSON *item); |
| 179 |
|
| 180 |
|
| 181 |
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array); |
| 182 |
|
| 183 |
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index); |
| 184 |
|
| 185 |
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string); |
| 186 |
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string); |
| 187 |
CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string); |
| 188 |
#if 0 |
| 189 |
|
| 190 |
CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void); |
| 191 |
#endif |
| 192 |
|
| 193 |
|
| 194 |
CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item); |
| 195 |
CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item); |
| 196 |
|
| 197 |
|
| 198 |
CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item); |
| 199 |
CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item); |
| 200 |
CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item); |
| 201 |
CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item); |
| 202 |
CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item); |
| 203 |
CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item); |
| 204 |
CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item); |
| 205 |
CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item); |
| 206 |
CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item); |
| 207 |
CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item); |
| 208 |
|
| 209 |
|
| 210 |
CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void); |
| 211 |
CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void); |
| 212 |
CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void); |
| 213 |
CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool boolean); |
| 214 |
CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num); |
| 215 |
CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string); |
| 216 |
|
| 217 |
CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw); |
| 218 |
CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void); |
| 219 |
CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void); |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string); |
| 224 |
|
| 225 |
|
| 226 |
CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child); |
| 227 |
CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child); |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count); |
| 232 |
CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count); |
| 233 |
CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count); |
| 234 |
CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char *const *strings, int count); |
| 235 |
|
| 236 |
|
| 237 |
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToArray(cJSON *array, cJSON *item); |
| 238 |
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item); |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item); |
| 243 |
|
| 244 |
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); |
| 245 |
CJSON_PUBLIC(cJSON_bool) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item); |
| 246 |
|
| 247 |
|
| 248 |
CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item); |
| 249 |
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which); |
| 250 |
CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which); |
| 251 |
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string); |
| 252 |
CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string); |
| 253 |
CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string); |
| 254 |
CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string); |
| 255 |
|
| 256 |
|
| 257 |
CJSON_PUBLIC(cJSON_bool) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem); |
| 258 |
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement); |
| 259 |
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem); |
| 260 |
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); |
| 261 |
CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object,const char *string,cJSON *newitem); |
| 262 |
|
| 263 |
|
| 264 |
CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse); |
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive); |
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
CJSON_PUBLIC(void) cJSON_Minify(char *json); |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name); |
| 280 |
CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name); |
| 281 |
CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name); |
| 282 |
CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean); |
| 283 |
CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number); |
| 284 |
CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string); |
| 285 |
CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw); |
| 286 |
CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name); |
| 287 |
CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name); |
| 288 |
|
| 289 |
|
| 290 |
#define cJSON_SetIntValue(object, number) ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number)) |
| 291 |
|
| 292 |
CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number); |
| 293 |
#define cJSON_SetNumberValue(object, number) ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number)) |
| 294 |
|
| 295 |
CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring); |
| 296 |
|
| 297 |
|
| 298 |
#define cJSON_SetBoolValue(object, boolValue) ( \ |
| 299 |
(object != NULL && ((object)->type & (cJSON_False|cJSON_True))) ? \ |
| 300 |
(object)->type=((object)->type &(~(cJSON_False|cJSON_True)))|((boolValue)?cJSON_True:cJSON_False) : \ |
| 301 |
cJSON_Invalid\ |
| 302 |
) |
| 303 |
|
| 304 |
|
| 305 |
#define cJSON_ArrayForEach(element, array) for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next) |
| 306 |
|
| 307 |
|
| 308 |
CJSON_PUBLIC(void *) cJSON_malloc(size_t size); |
| 309 |
CJSON_PUBLIC(void) cJSON_free(void *object); |
| 310 |
|
| 311 |
#ifdef __cplusplus |
| 312 |
} |
| 313 |
#endif |
| 314 |
|
| 315 |
|
| 316 |
#endif |