FD.io VPP  v21.01.1
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 298 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 295 of file cJSON.c.

◆ can_read

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

Definition at line 293 of file cJSON.c.

◆ cannot_access_at_index

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

Definition at line 296 of file cJSON.c.

◆ cjson_min

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

Definition at line 1179 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 175 of file cJSON.c.

◆ internal_malloc

#define internal_malloc   malloc

Definition at line 174 of file cJSON.c.

◆ internal_realloc

#define internal_realloc   realloc

Definition at line 176 of file cJSON.c.

◆ NAN

#define NAN   0.0/0.0

Definition at line 81 of file cJSON.c.

◆ static_strlen

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

Definition at line 180 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 1950 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 2005 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 1032 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 129 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 1996 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 237 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 ( const char *  )

Definition at line 90 of file cJSON.c.

+ Here is the caller graph for this function:

◆ CJSON_PUBLIC() [2/7]

CJSON_PUBLIC ( char *  )

Definition at line 95 of file cJSON.c.

◆ CJSON_PUBLIC() [3/7]

CJSON_PUBLIC ( double  )

Definition at line 105 of file cJSON.c.

+ Here is the call graph for this function:

◆ CJSON_PUBLIC() [4/7]

CJSON_PUBLIC ( void  )

Definition at line 205 of file cJSON.c.

+ Here is the call graph for this function:

◆ CJSON_PUBLIC() [5/7]

CJSON_PUBLIC ( cJSON )

Definition at line 1073 of file cJSON.c.

+ Here is the call graph for this function:

◆ CJSON_PUBLIC() [6/7]

CJSON_PUBLIC ( cJSON_bool  )

Definition at line 1286 of file cJSON.c.

+ Here is the call graph for this function:

◆ CJSON_PUBLIC() [7/7]

CJSON_PUBLIC ( void *  )

Definition at line 3087 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 184 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 536 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 1929 of file cJSON.c.

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

◆ ensure()

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

Definition at line 435 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 1845 of file cJSON.c.

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

◆ get_decimal_point()

static unsigned char get_decimal_point ( void  )
static

Definition at line 273 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 1874 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 2792 of file cJSON.c.

+ Here is the call graph for this function:

◆ parse_array()

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

Definition at line 1435 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 609 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 301 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 1595 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 767 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 1306 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 1181 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 1533 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 543 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 1708 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 1018 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 896 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 1361 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 2345 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 2778 of file cJSON.c.

+ Here is the caller graph for this function:

◆ skip_oneline_comment()

static void skip_oneline_comment ( char **  input)
static

Definition at line 2765 of file cJSON.c.

+ Here is the caller graph for this function:

◆ skip_utf8_bom()

static parse_buffer* skip_utf8_bom ( parse_buffer *const  buffer)
static

Definition at line 1058 of file cJSON.c.

+ Here is the caller graph for this function:

◆ suffix_object()

static void suffix_object ( cJSON prev,
cJSON item 
)
static

Definition at line 1922 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 523 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 646 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 88 of file cJSON.c.

◆ global_hooks

Definition at line 182 of file cJSON.c.