11111

Dependents:   espyun1

Fork of WIZnetInterface by WIZnet

Committer:
jh_ndm
Date:
Fri Nov 04 07:38:07 2016 +0000
Revision:
31:fc14e4330419
Parent:
30:6feeaebad180
asdfwe

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jh_ndm 30:6feeaebad180 1 /*
jh_ndm 30:6feeaebad180 2 Copyright (c) 2009 Dave Gamble
jh_ndm 30:6feeaebad180 3
jh_ndm 30:6feeaebad180 4 Permission is hereby granted, free of charge, to any person obtaining a copy
jh_ndm 30:6feeaebad180 5 of this software and associated documentation files (the "Software"), to deal
jh_ndm 30:6feeaebad180 6 in the Software without restriction, including without limitation the rights
jh_ndm 30:6feeaebad180 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
jh_ndm 30:6feeaebad180 8 copies of the Software, and to permit persons to whom the Software is
jh_ndm 30:6feeaebad180 9 furnished to do so, subject to the following conditions:
jh_ndm 30:6feeaebad180 10
jh_ndm 30:6feeaebad180 11 The above copyright notice and this permission notice shall be included in
jh_ndm 30:6feeaebad180 12 all copies or substantial portions of the Software.
jh_ndm 30:6feeaebad180 13
jh_ndm 30:6feeaebad180 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
jh_ndm 30:6feeaebad180 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
jh_ndm 30:6feeaebad180 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
jh_ndm 30:6feeaebad180 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
jh_ndm 30:6feeaebad180 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
jh_ndm 30:6feeaebad180 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
jh_ndm 30:6feeaebad180 20 THE SOFTWARE.
jh_ndm 30:6feeaebad180 21 */
jh_ndm 30:6feeaebad180 22
jh_ndm 30:6feeaebad180 23 #ifndef cJSON__h
jh_ndm 30:6feeaebad180 24 #define cJSON__h
jh_ndm 30:6feeaebad180 25
jh_ndm 30:6feeaebad180 26 #ifdef __cplusplus
jh_ndm 30:6feeaebad180 27 extern "C"
jh_ndm 30:6feeaebad180 28 {
jh_ndm 30:6feeaebad180 29 #endif
jh_ndm 30:6feeaebad180 30
jh_ndm 30:6feeaebad180 31 /* cJSON Types: */
jh_ndm 30:6feeaebad180 32 #define cJSON_False 0
jh_ndm 30:6feeaebad180 33 #define cJSON_True 1
jh_ndm 30:6feeaebad180 34 #define cJSON_NULL 2
jh_ndm 30:6feeaebad180 35 #define cJSON_Number 3
jh_ndm 30:6feeaebad180 36 #define cJSON_String 4
jh_ndm 30:6feeaebad180 37 #define cJSON_Array 5
jh_ndm 30:6feeaebad180 38 #define cJSON_Object 6
jh_ndm 30:6feeaebad180 39
jh_ndm 30:6feeaebad180 40 #define cJSON_IsReference 256
jh_ndm 30:6feeaebad180 41 #define cJSON_StringIsConst 512
jh_ndm 30:6feeaebad180 42
jh_ndm 30:6feeaebad180 43 /* The cJSON structure: */
jh_ndm 30:6feeaebad180 44 typedef struct cJSON {
jh_ndm 30:6feeaebad180 45 struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
jh_ndm 30:6feeaebad180 46 struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
jh_ndm 30:6feeaebad180 47
jh_ndm 30:6feeaebad180 48 int type; /* The type of the item, as above. */
jh_ndm 30:6feeaebad180 49
jh_ndm 30:6feeaebad180 50 char *valuestring; /* The item's string, if type==cJSON_String */
jh_ndm 30:6feeaebad180 51 int valueint; /* The item's number, if type==cJSON_Number */
jh_ndm 30:6feeaebad180 52 double valuedouble; /* The item's number, if type==cJSON_Number */
jh_ndm 30:6feeaebad180 53
jh_ndm 30:6feeaebad180 54 char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
jh_ndm 30:6feeaebad180 55 } cJSON;
jh_ndm 30:6feeaebad180 56
jh_ndm 30:6feeaebad180 57 typedef struct cJSON_Hooks {
jh_ndm 30:6feeaebad180 58 void *(*malloc_fn)(size_t sz);
jh_ndm 30:6feeaebad180 59 void (*free_fn)(void *ptr);
jh_ndm 30:6feeaebad180 60 } cJSON_Hooks;
jh_ndm 30:6feeaebad180 61
jh_ndm 30:6feeaebad180 62 /* Supply malloc, realloc and free functions to cJSON */
jh_ndm 30:6feeaebad180 63 extern void cJSON_InitHooks(cJSON_Hooks* hooks);
jh_ndm 30:6feeaebad180 64
jh_ndm 30:6feeaebad180 65
jh_ndm 30:6feeaebad180 66 /* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
jh_ndm 30:6feeaebad180 67 extern cJSON *cJSON_Parse(const char *value);
jh_ndm 30:6feeaebad180 68 /* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
jh_ndm 30:6feeaebad180 69 extern char *cJSON_Print(cJSON *item);
jh_ndm 30:6feeaebad180 70 /* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
jh_ndm 30:6feeaebad180 71 extern char *cJSON_PrintUnformatted(cJSON *item);
jh_ndm 30:6feeaebad180 72 /* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */
jh_ndm 30:6feeaebad180 73 extern char *cJSON_PrintBuffered(cJSON *item,int prebuffer,int fmt);
jh_ndm 30:6feeaebad180 74 /* Delete a cJSON entity and all subentities. */
jh_ndm 30:6feeaebad180 75 extern void cJSON_Delete(cJSON *c);
jh_ndm 30:6feeaebad180 76
jh_ndm 30:6feeaebad180 77 /* Returns the number of items in an array (or object). */
jh_ndm 30:6feeaebad180 78 extern int cJSON_GetArraySize(cJSON *array);
jh_ndm 30:6feeaebad180 79 /* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
jh_ndm 30:6feeaebad180 80 extern cJSON *cJSON_GetArrayItem(cJSON *array,int item);
jh_ndm 30:6feeaebad180 81 /* Get item "string" from object. Case insensitive. */
jh_ndm 30:6feeaebad180 82 extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string);
jh_ndm 30:6feeaebad180 83
jh_ndm 30:6feeaebad180 84 /* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
jh_ndm 30:6feeaebad180 85 extern const char *cJSON_GetErrorPtr(void);
jh_ndm 30:6feeaebad180 86
jh_ndm 30:6feeaebad180 87 /* These calls create a cJSON item of the appropriate type. */
jh_ndm 30:6feeaebad180 88 extern cJSON *cJSON_CreateNull(void);
jh_ndm 30:6feeaebad180 89 extern cJSON *cJSON_CreateTrue(void);
jh_ndm 30:6feeaebad180 90 extern cJSON *cJSON_CreateFalse(void);
jh_ndm 30:6feeaebad180 91 extern cJSON *cJSON_CreateBool(int b);
jh_ndm 30:6feeaebad180 92 extern cJSON *cJSON_CreateNumber(double num);
jh_ndm 30:6feeaebad180 93 extern cJSON *cJSON_CreateString(const char *string);
jh_ndm 30:6feeaebad180 94 extern cJSON *cJSON_CreateArray(void);
jh_ndm 30:6feeaebad180 95 extern cJSON *cJSON_CreateObject(void);
jh_ndm 30:6feeaebad180 96
jh_ndm 30:6feeaebad180 97 /* These utilities create an Array of count items. */
jh_ndm 30:6feeaebad180 98 extern cJSON *cJSON_CreateIntArray(const int *numbers,int count);
jh_ndm 30:6feeaebad180 99 extern cJSON *cJSON_CreateFloatArray(const float *numbers,int count);
jh_ndm 30:6feeaebad180 100 extern cJSON *cJSON_CreateDoubleArray(const double *numbers,int count);
jh_ndm 30:6feeaebad180 101 extern cJSON *cJSON_CreateStringArray(const char **strings,int count);
jh_ndm 30:6feeaebad180 102
jh_ndm 30:6feeaebad180 103 /* Append item to the specified array/object. */
jh_ndm 30:6feeaebad180 104 extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
jh_ndm 30:6feeaebad180 105 extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item);
jh_ndm 30:6feeaebad180 106 extern void cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item); /* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object */
jh_ndm 30:6feeaebad180 107 /* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
jh_ndm 30:6feeaebad180 108 extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
jh_ndm 30:6feeaebad180 109 extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item);
jh_ndm 30:6feeaebad180 110
jh_ndm 30:6feeaebad180 111 /* Remove/Detatch items from Arrays/Objects. */
jh_ndm 30:6feeaebad180 112 extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which);
jh_ndm 30:6feeaebad180 113 extern void cJSON_DeleteItemFromArray(cJSON *array,int which);
jh_ndm 30:6feeaebad180 114 extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string);
jh_ndm 30:6feeaebad180 115 extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string);
jh_ndm 30:6feeaebad180 116
jh_ndm 30:6feeaebad180 117 /* Update array items. */
jh_ndm 30:6feeaebad180 118 extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem);
jh_ndm 30:6feeaebad180 119 extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem);
jh_ndm 30:6feeaebad180 120
jh_ndm 30:6feeaebad180 121 /* Duplicate a cJSON item */
jh_ndm 30:6feeaebad180 122 extern cJSON *cJSON_Duplicate(cJSON *item,int recurse);
jh_ndm 30:6feeaebad180 123 /* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will
jh_ndm 30:6feeaebad180 124 need to be released. With recurse!=0, it will duplicate any children connected to the item.
jh_ndm 30:6feeaebad180 125 The item->next and ->prev pointers are always zero on return from Duplicate. */
jh_ndm 30:6feeaebad180 126
jh_ndm 30:6feeaebad180 127 /* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */
jh_ndm 30:6feeaebad180 128 extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated);
jh_ndm 30:6feeaebad180 129
jh_ndm 30:6feeaebad180 130 extern void cJSON_Minify(char *json);
jh_ndm 30:6feeaebad180 131
jh_ndm 30:6feeaebad180 132 /* Macros for creating things quickly. */
jh_ndm 30:6feeaebad180 133 #define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
jh_ndm 30:6feeaebad180 134 #define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
jh_ndm 30:6feeaebad180 135 #define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
jh_ndm 30:6feeaebad180 136 #define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b))
jh_ndm 30:6feeaebad180 137 #define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
jh_ndm 30:6feeaebad180 138 #define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
jh_ndm 30:6feeaebad180 139
jh_ndm 30:6feeaebad180 140 /* When assigning an integer value, it needs to be propagated to valuedouble too. */
jh_ndm 30:6feeaebad180 141 #define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val))
jh_ndm 30:6feeaebad180 142
jh_ndm 30:6feeaebad180 143 #ifdef __cplusplus
jh_ndm 30:6feeaebad180 144 }
jh_ndm 30:6feeaebad180 145 #endif
jh_ndm 30:6feeaebad180 146
jh_ndm 30:6feeaebad180 147 #endif