FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
cJSON.c File Reference
+ Include dependency graph for cJSON.c:

Go to the source code of this file.

Data Structures

struct  error
 
struct  internal_hooks
 
struct  parse_buffer
 
struct  printbuffer
 

Macros

#define true   ((cJSON_bool)1)
 
#define false   ((cJSON_bool)0)
 
#define NAN   0.0/0.0
 
#define internal_malloc   malloc
 
#define internal_free   free
 
#define internal_realloc   realloc
 
#define static_strlen(string_literal)   (sizeof(string_literal) - sizeof(""))
 
#define can_read(buffer, size)   ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))
 
#define can_access_at_index(buffer, index)   ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))
 
#define cannot_access_at_index(buffer, index)   (!can_access_at_index(buffer, index))
 
#define buffer_at_offset(buffer)   ((buffer)->content + (buffer)->offset)
 
#define cjson_min(a, b)   (((a) < (b)) ? (a) : (b))
 

Typedefs

typedef struct internal_hooks internal_hooks
 

Functions

 CJSON_PUBLIC (const char *)
 
 CJSON_PUBLIC (char *)
 
 CJSON_PUBLIC (double)
 
static int case_insensitive_strcmp (const unsigned char *string1, const unsigned char *string2)
 
static unsigned char * cJSON_strdup (const unsigned char *string, const internal_hooks *const hooks)
 
 CJSON_PUBLIC (void)
 
static cJSONcJSON_New_Item (const internal_hooks *const hooks)
 
static unsigned char get_decimal_point (void)
 
static cJSON_bool parse_number (cJSON *const item, parse_buffer *const input_buffer)
 
static unsigned char * ensure (printbuffer *const p, size_t needed)
 
static void update_offset (printbuffer *const buffer)
 
static cJSON_bool compare_double (double a, double b)
 
static cJSON_bool print_number (const cJSON *const item, printbuffer *const output_buffer)
 
static unsigned parse_hex4 (const unsigned char *const input)
 
static unsigned char utf16_literal_to_utf8 (const unsigned char *const input_pointer, const unsigned char *const input_end, unsigned char **output_pointer)
 
static cJSON_bool parse_string (cJSON *const item, parse_buffer *const input_buffer)
 
static cJSON_bool print_string_ptr (const unsigned char *const input, printbuffer *const output_buffer)
 
static cJSON_bool print_string (const cJSON *const item, printbuffer *const p)
 
static cJSON_bool parse_value (cJSON *const item, parse_buffer *const input_buffer)
 
static cJSON_bool print_value (const cJSON *const item, printbuffer *const output_buffer)
 
static cJSON_bool parse_array (cJSON *const item, parse_buffer *const input_buffer)
 
static cJSON_bool print_array (const cJSON *const item, printbuffer *const output_buffer)
 
static cJSON_bool parse_object (cJSON *const item, parse_buffer *const input_buffer)
 
static cJSON_bool print_object (const cJSON *const item, printbuffer *const output_buffer)
 
static parse_bufferbuffer_skip_whitespace (parse_buffer *const buffer)
 
static parse_bufferskip_utf8_bom (parse_buffer *const buffer)
 
 CJSON_PUBLIC (cJSON *)
 
static unsigned char * print (const cJSON *const item, cJSON_bool format, const internal_hooks *const hooks)
 
 CJSON_PUBLIC (cJSON_bool)
 
static cJSONget_array_item (const cJSON *array, size_t index)
 
static cJSONget_object_item (const cJSON *const object, const char *const name, const cJSON_bool case_sensitive)
 
static void suffix_object (cJSON *prev, cJSON *item)
 
static cJSONcreate_reference (const cJSON *item, const internal_hooks *const hooks)
 
static cJSON_bool add_item_to_array (cJSON *array, cJSON *item)
 
static void * cast_away_const (const void *string)
 
static cJSON_bool add_item_to_object (cJSON *const object, const char *const string, cJSON *const item, const internal_hooks *const hooks, const cJSON_bool constant_key)
 
static cJSON_bool replace_item_in_object (cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive)
 
static void skip_oneline_comment (char **input)
 
static void skip_multiline_comment (char **input)
 
static void minify_string (char **input, char **output)
 
 CJSON_PUBLIC (void *)
 

Variables

static error global_error = { NULL, 0 }
 
static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc }
 

Macro Definition Documentation

◆ buffer_at_offset

#define buffer_at_offset (   buffer)    ((buffer)->content + (buffer)->offset)

Definition at line 302 of file cJSON.c.

◆ can_access_at_index

#define can_access_at_index (   buffer,
  index 
)    ((buffer != NULL) && (((buffer)->offset + index) < (buffer)->length))

Definition at line 299 of file cJSON.c.

◆ can_read

#define can_read (   buffer,
  size 
)    ((buffer != NULL) && (((buffer)->offset + size) <= (buffer)->length))

Definition at line 297 of file cJSON.c.

◆ cannot_access_at_index

#define cannot_access_at_index (   buffer,
  index 
)    (!can_access_at_index(buffer, index))

Definition at line 300 of file cJSON.c.

◆ cjson_min

#define cjson_min (   a,
  b 
)    (((a) < (b)) ? (a) : (b))

Definition at line 1181 of file cJSON.c.

◆ false

#define false   ((cJSON_bool)0)

Definition at line 70 of file cJSON.c.

◆ internal_free

#define internal_free   free

Definition at line 179 of file cJSON.c.

◆ internal_malloc

#define internal_malloc   malloc

Definition at line 178 of file cJSON.c.

◆ internal_realloc

#define internal_realloc   realloc

Definition at line 180 of file cJSON.c.

◆ NAN

#define NAN   0.0/0.0

Definition at line 84 of file cJSON.c.

◆ static_strlen

#define static_strlen (   string_literal)    (sizeof(string_literal) - sizeof(""))

Definition at line 184 of file cJSON.c.

◆ true

#define true   ((cJSON_bool)1)

Definition at line 65 of file cJSON.c.

Typedef Documentation

◆ internal_hooks

Function Documentation

◆ add_item_to_array()

static cJSON_bool add_item_to_array ( cJSON array,
cJSON item 
)
static

Definition at line 1952 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_item_to_object()

static cJSON_bool add_item_to_object ( cJSON *const  object,
const char *const  string,
cJSON *const  item,
const internal_hooks *const  hooks,
const cJSON_bool  constant_key 
)
static

Definition at line 2007 of file cJSON.c.

+ Here is the call graph for this function:

◆ buffer_skip_whitespace()

static parse_buffer* buffer_skip_whitespace ( parse_buffer *const  buffer)
static

Definition at line 1034 of file cJSON.c.

+ Here is the caller graph for this function:

◆ case_insensitive_strcmp()

static int case_insensitive_strcmp ( const unsigned char *  string1,
const unsigned char *  string2 
)
static

Definition at line 133 of file cJSON.c.

+ Here is the caller graph for this function:

◆ cast_away_const()

static void* cast_away_const ( const void *  string)
static

Definition at line 1998 of file cJSON.c.

+ Here is the caller graph for this function:

◆ cJSON_New_Item()

static cJSON* cJSON_New_Item ( const internal_hooks *const  hooks)
static

Definition at line 241 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CJSON_PUBLIC() [1/7]

CJSON_PUBLIC ( char *  )

Definition at line 99 of file cJSON.c.

◆ CJSON_PUBLIC() [2/7]

CJSON_PUBLIC ( cJSON )

Definition at line 1075 of file cJSON.c.

◆ CJSON_PUBLIC() [3/7]

CJSON_PUBLIC ( cJSON_bool  )

Definition at line 1288 of file cJSON.c.

+ Here is the call graph for this function:

◆ CJSON_PUBLIC() [4/7]

CJSON_PUBLIC ( const char *  )

Definition at line 94 of file cJSON.c.

◆ CJSON_PUBLIC() [5/7]

CJSON_PUBLIC ( double  )

Definition at line 109 of file cJSON.c.

◆ CJSON_PUBLIC() [6/7]

CJSON_PUBLIC ( void *  )

Definition at line 3106 of file cJSON.c.

+ Here is the call graph for this function:

◆ CJSON_PUBLIC() [7/7]

CJSON_PUBLIC ( void  )

Definition at line 209 of file cJSON.c.

+ Here is the call graph for this function:

◆ cJSON_strdup()

static unsigned char* cJSON_strdup ( const unsigned char *  string,
const internal_hooks *const  hooks 
)
static

Definition at line 188 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ compare_double()

static cJSON_bool compare_double ( double  a,
double  b 
)
static

Definition at line 538 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create_reference()

static cJSON* create_reference ( const cJSON item,
const internal_hooks *const  hooks 
)
static

Definition at line 1931 of file cJSON.c.

+ Here is the call graph for this function:

◆ ensure()

static unsigned char* ensure ( printbuffer *const  p,
size_t  needed 
)
static

Definition at line 439 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_array_item()

static cJSON* get_array_item ( const cJSON array,
size_t  index 
)
static

Definition at line 1847 of file cJSON.c.

◆ get_decimal_point()

static unsigned char get_decimal_point ( void  )
static

Definition at line 277 of file cJSON.c.

+ Here is the caller graph for this function:

◆ get_object_item()

static cJSON* get_object_item ( const cJSON *const  object,
const char *const  name,
const cJSON_bool  case_sensitive 
)
static

Definition at line 1876 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ minify_string()

static void minify_string ( char **  input,
char **  output 
)
static

Definition at line 2811 of file cJSON.c.

◆ parse_array()

static cJSON_bool parse_array ( cJSON *const  item,
parse_buffer *const  input_buffer 
)
static

Definition at line 1437 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_hex4()

static unsigned parse_hex4 ( const unsigned char *const  input)
static

Definition at line 611 of file cJSON.c.

+ Here is the caller graph for this function:

◆ parse_number()

static cJSON_bool parse_number ( cJSON *const  item,
parse_buffer *const  input_buffer 
)
static

Definition at line 305 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_object()

static cJSON_bool parse_object ( cJSON *const  item,
parse_buffer *const  input_buffer 
)
static

Definition at line 1597 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_string()

static cJSON_bool parse_string ( cJSON *const  item,
parse_buffer *const  input_buffer 
)
static

Definition at line 769 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parse_value()

static cJSON_bool parse_value ( cJSON *const  item,
parse_buffer *const  input_buffer 
)
static

Definition at line 1308 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print()

static unsigned char* print ( const cJSON *const  item,
cJSON_bool  format,
const internal_hooks *const  hooks 
)
static

Definition at line 1183 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_array()

static cJSON_bool print_array ( const cJSON *const  item,
printbuffer *const  output_buffer 
)
static

Definition at line 1535 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_number()

static cJSON_bool print_number ( const cJSON *const  item,
printbuffer *const  output_buffer 
)
static

Definition at line 545 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_object()

static cJSON_bool print_object ( const cJSON *const  item,
printbuffer *const  output_buffer 
)
static

Definition at line 1710 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_string()

static cJSON_bool print_string ( const cJSON *const  item,
printbuffer *const  p 
)
static

Definition at line 1020 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_string_ptr()

static cJSON_bool print_string_ptr ( const unsigned char *const  input,
printbuffer *const  output_buffer 
)
static

Definition at line 898 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_value()

static cJSON_bool print_value ( const cJSON *const  item,
printbuffer *const  output_buffer 
)
static

Definition at line 1363 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replace_item_in_object()

static cJSON_bool replace_item_in_object ( cJSON object,
const char *  string,
cJSON replacement,
cJSON_bool  case_sensitive 
)
static

Definition at line 2347 of file cJSON.c.

+ Here is the call graph for this function:

◆ skip_multiline_comment()

static void skip_multiline_comment ( char **  input)
static

Definition at line 2797 of file cJSON.c.

◆ skip_oneline_comment()

static void skip_oneline_comment ( char **  input)
static

Definition at line 2784 of file cJSON.c.

◆ skip_utf8_bom()

static parse_buffer* skip_utf8_bom ( parse_buffer *const  buffer)
static

Definition at line 1060 of file cJSON.c.

◆ suffix_object()

static void suffix_object ( cJSON prev,
cJSON item 
)
static

Definition at line 1924 of file cJSON.c.

+ Here is the caller graph for this function:

◆ update_offset()

static void update_offset ( printbuffer *const  buffer)
static

Definition at line 525 of file cJSON.c.

+ Here is the caller graph for this function:

◆ utf16_literal_to_utf8()

static unsigned char utf16_literal_to_utf8 ( const unsigned char *const  input_pointer,
const unsigned char *const  input_end,
unsigned char **  output_pointer 
)
static

Definition at line 648 of file cJSON.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ global_error

error global_error = { NULL, 0 }
static

Definition at line 92 of file cJSON.c.

◆ global_hooks

Definition at line 186 of file cJSON.c.