Static Value-Flow Analysis
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions | Variables
cJSON.h File Reference
#include <stddef.h>

Go to the source code of this file.

Classes

struct  cJSON
 
struct  cJSON_Hooks
 

Macros

#define CJSON_CDECL
 
#define CJSON_STDCALL
 
#define CJSON_PUBLIC(type)   type
 
#define CJSON_VERSION_MAJOR   1
 
#define CJSON_VERSION_MINOR   7
 
#define CJSON_VERSION_PATCH   15
 
#define cJSON_Invalid   (0)
 
#define cJSON_False   (1 << 0)
 
#define cJSON_True   (1 << 1)
 
#define cJSON_NULL   (1 << 2)
 
#define cJSON_Number   (1 << 3)
 
#define cJSON_String   (1 << 4)
 
#define cJSON_Array   (1 << 5)
 
#define cJSON_Object   (1 << 6)
 
#define cJSON_Raw   (1 << 7) /* raw json */
 
#define cJSON_IsReference   256
 
#define cJSON_StringIsConst   512
 
#define CJSON_NESTING_LIMIT   1000
 
#define cJSON_SetIntValue(object, number)   ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))
 
#define cJSON_SetNumberValue(object, number)   ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))
 
#define cJSON_SetBoolValue(object, boolValue)
 
#define cJSON_ArrayForEach(element, array)   for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)
 

Typedefs

typedef struct cJSON cJSON
 
typedef struct cJSON_Hooks cJSON_Hooks
 
typedef int cJSON_bool
 

Functions

 CJSON_PUBLIC (const char *) cJSON_Version(void)
 
 CJSON_PUBLIC (void) cJSON_InitHooks(cJSON_Hooks *hooks)
 
 CJSON_PUBLIC (cJSON *) cJSON_Parse(const char *value)
 
 CJSON_PUBLIC (char *) cJSON_Print(const cJSON *item)
 
 CJSON_PUBLIC (cJSON_bool) cJSON_PrintPreallocated(cJSON *item
 
 CJSON_PUBLIC (double) cJSON_GetNumberValue(const cJSON *const item)
 
 CJSON_PUBLIC (void *) cJSON_malloc(size_t size)
 

Variables

size_t buffer_length
 
const char ** return_parse_end
 
const char cJSON_bool require_null_terminated
 
int prebuffer
 
int cJSON_bool fmt
 
char * buffer = (unsigned char*)buffer
 
char const int length = (size_t)prebuffer
 
char const int const cJSON_bool format
 
int index
 
const char *const string
 
int count
 
cJSONitem
 
int which
 
int cJSONnewitem
 
cJSON *const cJSONreplacement
 
cJSON_bool recurse
 
const cJSON *const b
 
const cJSON *const const cJSON_bool case_sensitive
 
const char *const name
 
const char *const const cJSON_bool boolean
 
const char *const const double number
 
const char *const const char *const raw
 
const char * valuestring = copy
 

Macro Definition Documentation

◆ cJSON_Array

#define cJSON_Array   (1 << 5)

Definition at line 95 of file cJSON.h.

◆ cJSON_ArrayForEach

#define cJSON_ArrayForEach (   element,
  array 
)    for(element = (array != NULL) ? (array)->child : NULL; element != NULL; element = element->next)

Definition at line 290 of file cJSON.h.

◆ CJSON_CDECL

#define CJSON_CDECL

Definition at line 71 of file cJSON.h.

◆ cJSON_False

#define cJSON_False   (1 << 0)

Definition at line 90 of file cJSON.h.

◆ cJSON_Invalid

#define cJSON_Invalid   (0)

Definition at line 89 of file cJSON.h.

◆ cJSON_IsReference

#define cJSON_IsReference   256

Definition at line 99 of file cJSON.h.

◆ CJSON_NESTING_LIMIT

#define CJSON_NESTING_LIMIT   1000

Definition at line 137 of file cJSON.h.

◆ cJSON_NULL

#define cJSON_NULL   (1 << 2)

Definition at line 92 of file cJSON.h.

◆ cJSON_Number

#define cJSON_Number   (1 << 3)

Definition at line 93 of file cJSON.h.

◆ cJSON_Object

#define cJSON_Object   (1 << 6)

Definition at line 96 of file cJSON.h.

◆ CJSON_PUBLIC

#define CJSON_PUBLIC (   type)    type

Definition at line 77 of file cJSON.h.

◆ cJSON_Raw

#define cJSON_Raw   (1 << 7) /* raw json */

Definition at line 97 of file cJSON.h.

◆ cJSON_SetBoolValue

#define cJSON_SetBoolValue (   object,
  boolValue 
)
Value:
( \
(object != NULL && ((object)->type & (cJSON_False|cJSON_True))) ? \
(object)->type=((object)->type &(~(cJSON_False|cJSON_True)))|((boolValue)?cJSON_True:cJSON_False) : \
)
newitem type
Definition cJSON.cpp:2739
#define cJSON_False
Definition cJSON.h:90
#define cJSON_Invalid
Definition cJSON.h:89
#define cJSON_True
Definition cJSON.h:91
#define NULL
Definition extapi.c:2

Definition at line 283 of file cJSON.h.

285 :cJSON_False) : \
287)

◆ cJSON_SetIntValue

#define cJSON_SetIntValue (   object,
  number 
)    ((object) ? (object)->valueint = (object)->valuedouble = (number) : (number))

Definition at line 275 of file cJSON.h.

◆ cJSON_SetNumberValue

#define cJSON_SetNumberValue (   object,
  number 
)    ((object != NULL) ? cJSON_SetNumberHelper(object, (double)number) : (number))

Definition at line 278 of file cJSON.h.

◆ CJSON_STDCALL

#define CJSON_STDCALL

Definition at line 72 of file cJSON.h.

◆ cJSON_String

#define cJSON_String   (1 << 4)

Definition at line 94 of file cJSON.h.

◆ cJSON_StringIsConst

#define cJSON_StringIsConst   512

Definition at line 100 of file cJSON.h.

◆ cJSON_True

#define cJSON_True   (1 << 1)

Definition at line 91 of file cJSON.h.

◆ CJSON_VERSION_MAJOR

#define CJSON_VERSION_MAJOR   1

Definition at line 82 of file cJSON.h.

◆ CJSON_VERSION_MINOR

#define CJSON_VERSION_MINOR   7

Definition at line 83 of file cJSON.h.

◆ CJSON_VERSION_PATCH

#define CJSON_VERSION_PATCH   15

Definition at line 84 of file cJSON.h.

Typedef Documentation

◆ cJSON

typedef struct cJSON cJSON

◆ cJSON_bool

typedef int cJSON_bool

Definition at line 132 of file cJSON.h.

◆ cJSON_Hooks

typedef struct cJSON_Hooks cJSON_Hooks

Function Documentation

◆ CJSON_PUBLIC() [1/7]

CJSON_PUBLIC ( char *  ) const

Definition at line 1255 of file cJSON.cpp.

1256{
1257 return (char*)print(item, true, &global_hooks);
1258}
static unsigned char * print(const cJSON *const item, cJSON_bool format, const internal_hooks *const hooks)
Definition cJSON.cpp:1189
static internal_hooks global_hooks
Definition cJSON.cpp:187
cJSON * item
Definition cJSON.cpp:1100

◆ CJSON_PUBLIC() [2/7]

CJSON_PUBLIC ( cJSON ) const

Definition at line 1177 of file cJSON.cpp.

1178{
1179 return cJSON_ParseWithOpts(value, 0, 0);
1180}

◆ CJSON_PUBLIC() [3/7]

CJSON_PUBLIC ( cJSON_bool  )

Definition at line 1833 of file cJSON.cpp.

1834{
1835 cJSON *child = NULL;
1836 size_t size = 0;
1837
1838 if (array == NULL)
1839 {
1840 return 0;
1841 }
1842
1843 child = array->child;
1844
1845 while(child != NULL)
1846 {
1847 size++;
1848 child = child->next;
1849 }
1850
1851 /* FIXME: Can overflow here. Cannot be fixed without breaking the API */
1852
1853 return (int)size;
1854}
return NULL
Definition cJSON.cpp:1173
cJSON * child
Definition cJSON.cpp:2723
Definition cJSON.h:104
struct cJSON * child
Definition cJSON.h:109
struct cJSON * next
Definition cJSON.h:106

◆ CJSON_PUBLIC() [4/7]

CJSON_PUBLIC ( const char *  )

Definition at line 125 of file cJSON.cpp.

126{
127 static char version[15];
128 snprintf(version, sizeof(version), "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH);
129
130 return version;
131}
#define CJSON_VERSION_MINOR
Definition cJSON.h:83
#define CJSON_VERSION_PATCH
Definition cJSON.h:84
#define CJSON_VERSION_MAJOR
Definition cJSON.h:82

◆ CJSON_PUBLIC() [5/7]

CJSON_PUBLIC ( double  ) const

◆ CJSON_PUBLIC() [6/7]

CJSON_PUBLIC ( void *  )

◆ CJSON_PUBLIC() [7/7]

CJSON_PUBLIC ( void  )

Definition at line 254 of file cJSON.cpp.

255{
256 cJSON *next = NULL;
257 while (item != NULL)
258 {
259 next = item->next;
260 if (!(item->type & cJSON_IsReference) && (item->child != NULL))
261 {
263 }
264 if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL))
265 {
266 global_hooks.deallocate(item->valuestring);
267 }
268 if (!(item->type & cJSON_StringIsConst) && (item->string != NULL))
269 {
270 global_hooks.deallocate(item->string);
271 }
272 global_hooks.deallocate(item);
273 item = next;
274 }
275}
item next
Definition cJSON.cpp:2224
cJSON_Delete(null)
#define cJSON_StringIsConst
Definition cJSON.h:100
#define cJSON_IsReference
Definition cJSON.h:99
char * string
Definition cJSON.h:122
int type
Definition cJSON.h:112
char * valuestring
Definition cJSON.h:115

Variable Documentation

◆ b

const cJSON* const b

Definition at line 255 of file cJSON.h.

◆ boolean

const char* const const cJSON_bool boolean

Definition at line 267 of file cJSON.h.

◆ buffer

p buffer = (unsigned char*)buffer

Definition at line 163 of file cJSON.h.

◆ buffer_length

size_t buffer_length
Initial value:
{
return cJSON_ParseWithLengthOpts(value, buffer_length, return_parse_end, require_null_terminated)
size_t buffer_length
Definition cJSON.h:149

Definition at line 149 of file cJSON.h.

◆ case_sensitive

const cJSON* const const cJSON_bool case_sensitive

Definition at line 255 of file cJSON.h.

◆ count

int count
Initial value:
{
size_t i = 0

Definition at line 216 of file cJSON.h.

◆ fmt

int cJSON_bool fmt

Definition at line 160 of file cJSON.h.

◆ format

p format
Initial value:
{
printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }
cJSON * p
Definition cJSON.cpp:2559

Definition at line 163 of file cJSON.h.

◆ index

int index

Definition at line 170 of file cJSON.h.

◆ item

cJSON *const item
Initial value:
{
return add_item_to_array(array, item)
static cJSON_bool add_item_to_array(cJSON *array, cJSON *item)
Definition cJSON.cpp:1962
cJSON * item
Definition cJSON.h:222

Definition at line 222 of file cJSON.h.

◆ length

p length = (size_t)prebuffer

Definition at line 163 of file cJSON.h.

◆ name

const char *const name
Initial value:
{
cJSON *true_item = cJSON_CreateTrue()

Definition at line 264 of file cJSON.h.

◆ newitem

return newitem
Initial value:
{
if (which < 0)
{
return false;
}
return cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem)
static cJSON * get_array_item(const cJSON *array, size_t index)
Definition cJSON.cpp:1856
int cJSON * newitem
Definition cJSON.h:242
int which
Definition cJSON.h:234

Definition at line 242 of file cJSON.h.

◆ number

const char *const const double number
Initial value:
{
cJSON *number_item = cJSON_CreateNumber(number)
const char *const const double number
Definition cJSON.h:268

Definition at line 268 of file cJSON.h.

◆ prebuffer

int prebuffer

Definition at line 160 of file cJSON.h.

◆ raw

const char* const const char* const raw

Definition at line 270 of file cJSON.h.

◆ recurse

cJSON_bool recurse

Definition at line 249 of file cJSON.h.

◆ replacement

cJSON* const cJSON* replacement

Definition at line 243 of file cJSON.h.

◆ require_null_terminated

size_t const char cJSON_bool require_null_terminated
Initial value:
{
parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } }
char * buffer
Definition cJSON.h:163

Definition at line 152 of file cJSON.h.

◆ return_parse_end

size_t const char ** return_parse_end

Definition at line 152 of file cJSON.h.

◆ string

const char * string
Initial value:
{
return get_object_item(object, string, true)
static cJSON * get_object_item(const cJSON *const object, const char *const name, const cJSON_bool case_sensitive)
Definition cJSON.cpp:1885

Definition at line 172 of file cJSON.h.

◆ valuestring

object valuestring = copy

Definition at line 280 of file cJSON.h.

◆ which

int which
Initial value:
{
cJSON_Delete(cJSON_DetachItemFromArray(array, which))

Definition at line 234 of file cJSON.h.