diff options
author | thegeorg <thegeorg@yandex-team.ru> | 2022-05-11 12:12:06 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.ru> | 2022-05-11 12:12:06 +0300 |
commit | 62f93da087b2fec0f89979fd11ac4d754ca36253 (patch) | |
tree | 67bf8ceb55e2d079f3575f9a7373584ad407d2a5 /contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/external | |
parent | 8d55620139d4309265409767f873ba83fe046418 (diff) | |
download | ydb-62f93da087b2fec0f89979fd11ac4d754ca36253.tar.gz |
Update aws-c-common and aws-c-io
* Update `contrib/restricted/aws/aws-c-io` to 0.11.0
* Backport cJSON symbol renaming logic from aws-sdk-cpp upstream
ref:396829235a01ed34888651ee38ebd76c95510d6b
Diffstat (limited to 'contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/external')
-rw-r--r-- | contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/external/cjson/cJSON.cpp | 518 |
1 files changed, 259 insertions, 259 deletions
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/external/cjson/cJSON.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/external/cjson/cJSON.cpp index 2525976334..cc5636cbf8 100644 --- a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/external/cjson/cJSON.cpp +++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/external/cjson/cJSON.cpp @@ -58,8 +58,8 @@ #include <aws/core/external/cjson/cJSON.h> /* define our own boolean type */ -// #define true ((cJSON_bool)1) -// #define false ((cJSON_bool)0) +// #define true ((cJSON_AS4CPP_bool)1) +// #define false ((cJSON_AS4CPP_bool)0) typedef struct { const unsigned char *json; @@ -67,13 +67,13 @@ typedef struct { } error; static error global_error = { NULL, 0 }; -CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void) +CJSON_AS4CPP_PUBLIC(const char *) cJSON_AS4CPP_GetErrorPtr(void) { return (const char*) (global_error.json + global_error.position); } -CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item) { - if (!cJSON_IsString(item)) { +CJSON_AS4CPP_PUBLIC(char *) cJSON_AS4CPP_GetStringValue(cJSON *item) { + if (!cJSON_AS4CPP_IsString(item)) { return NULL; } @@ -81,14 +81,14 @@ CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item) { } /* This is a safeguard to prevent copy-pasters from using incompatible C and header files */ -#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 7) +#if (CJSON_AS4CPP_VERSION_MAJOR != 1) || (CJSON_AS4CPP_VERSION_MINOR != 7) || (CJSON_AS4CPP_VERSION_PATCH != 7) #error cJSON.h and cJSON.c have different versions. Make sure that both have the same. #endif -CJSON_PUBLIC(const char*) cJSON_Version(void) +CJSON_AS4CPP_PUBLIC(const char*) cJSON_AS4CPP_Version(void) { static char version[15]; - sprintf(version, "%i.%i.%i", CJSON_VERSION_MAJOR, CJSON_VERSION_MINOR, CJSON_VERSION_PATCH); + sprintf(version, "%i.%i.%i", CJSON_AS4CPP_VERSION_MAJOR, CJSON_AS4CPP_VERSION_MINOR, CJSON_AS4CPP_VERSION_PATCH); return version; } @@ -146,7 +146,7 @@ static void *internal_realloc(void *pointer, size_t size) static internal_hooks global_hooks = { internal_malloc, internal_free, internal_realloc }; -static unsigned char* cJSON_strdup(const unsigned char* string, const internal_hooks * const hooks) +static unsigned char* cJSON_AS4CPP_strdup(const unsigned char* string, const internal_hooks * const hooks) { size_t length = 0; unsigned char *copy = NULL; @@ -167,7 +167,7 @@ static unsigned char* cJSON_strdup(const unsigned char* string, const internal_h return copy; } -CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_InitHooks(cJSON_AS4CPP_Hooks* hooks) { if (hooks == NULL) { @@ -199,7 +199,7 @@ CJSON_PUBLIC(void) cJSON_InitHooks(cJSON_Hooks* hooks) } /* Internal constructor. */ -static cJSON *cJSON_New_Item(const internal_hooks * const hooks) +static cJSON *cJSON_AS4CPP_New_Item(const internal_hooks * const hooks) { cJSON* node = (cJSON*)hooks->allocate(sizeof(cJSON)); if (node) @@ -211,21 +211,21 @@ static cJSON *cJSON_New_Item(const internal_hooks * const hooks) } /* Delete a cJSON structure. */ -CJSON_PUBLIC(void) cJSON_Delete(cJSON *item) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_Delete(cJSON *item) { cJSON *next = NULL; while (item != NULL) { next = item->next; - if (!(item->type & cJSON_IsReference) && (item->child != NULL)) + if (!(item->type & cJSON_AS4CPP_IsReference) && (item->child != NULL)) { - cJSON_Delete(item->child); + cJSON_AS4CPP_Delete(item->child); } - if (!(item->type & cJSON_IsReference) && (item->valuestring != NULL)) + if (!(item->type & cJSON_AS4CPP_IsReference) && (item->valuestring != NULL)) { global_hooks.deallocate(item->valuestring); } - if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) + if (!(item->type & cJSON_AS4CPP_StringIsConst) && (item->string != NULL)) { global_hooks.deallocate(item->string); } @@ -263,7 +263,7 @@ typedef struct #define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset) /* Parse the input text to generate a number, and populate the result into item. */ -static cJSON_bool parse_number(cJSON * const item, parse_buffer * const input_buffer) +static cJSON_AS4CPP_bool parse_number(cJSON * const item, parse_buffer * const input_buffer) { double number = 0; unsigned char *after_end = NULL; @@ -327,7 +327,7 @@ loop_end: // Instead, we keep the integer literal as a string. if (isInteger && (number > INT_MAX || number < INT_MIN)) { - item->valuestring = (char*)cJSON_strdup(number_c_string, &global_hooks); + item->valuestring = (char*)cJSON_AS4CPP_strdup(number_c_string, &global_hooks); } /* use saturation in case of overflow */ @@ -344,14 +344,14 @@ loop_end: item->valueint = (int)number; } - item->type = cJSON_Number; + item->type = cJSON_AS4CPP_Number; input_buffer->offset += (size_t)(after_end - number_c_string); return true; } -/* don't ask me, but the original cJSON_SetNumberValue returns an integer or double */ -CJSON_PUBLIC(double) cJSON_SetNumberHelper(cJSON *object, double number) +/* don't ask me, but the original cJSON_AS4CPP_SetNumberValue returns an integer or double */ +CJSON_AS4CPP_PUBLIC(double) cJSON_AS4CPP_SetNumberHelper(cJSON *object, double number) { if (number >= INT_MAX) { @@ -375,8 +375,8 @@ typedef struct size_t length; size_t offset; size_t depth; /* current nesting depth (for formatted printing) */ - cJSON_bool noalloc; - cJSON_bool format; /* is this print a formatted print */ + cJSON_AS4CPP_bool noalloc; + cJSON_AS4CPP_bool format; /* is this print a formatted print */ internal_hooks hooks; } printbuffer; @@ -482,7 +482,7 @@ static void update_offset(printbuffer * const buffer) } /* Render the number nicely from the given item into a string. */ -static cJSON_bool print_number(const cJSON * const item, printbuffer * const output_buffer) +static cJSON_AS4CPP_bool print_number(const cJSON * const item, printbuffer * const output_buffer) { unsigned char *output_pointer = NULL; double d = item->valuedouble; @@ -711,7 +711,7 @@ fail: } /* Parse the input text into an unescaped cinput, and populate item. */ -static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_buffer) +static cJSON_AS4CPP_bool parse_string(cJSON * const item, parse_buffer * const input_buffer) { const unsigned char *input_pointer = buffer_at_offset(input_buffer) + 1; const unsigned char *input_end = buffer_at_offset(input_buffer) + 1; @@ -817,7 +817,7 @@ static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_bu /* zero terminate the output */ *output_pointer = '\0'; - item->type = cJSON_String; + item->type = cJSON_AS4CPP_String; item->valuestring = (char*)output; input_buffer->offset = (size_t) (input_end - input_buffer->content); @@ -840,7 +840,7 @@ fail: } /* Render the cstring provided to an escaped version that can be printed. */ -static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffer * const output_buffer) +static cJSON_AS4CPP_bool print_string_ptr(const unsigned char * const input, printbuffer * const output_buffer) { const unsigned char *input_pointer = NULL; unsigned char *output = NULL; @@ -962,18 +962,18 @@ static cJSON_bool print_string_ptr(const unsigned char * const input, printbuffe } /* Invoke print_string_ptr (which is useful) on an item. */ -static cJSON_bool print_string(const cJSON * const item, printbuffer * const p) +static cJSON_AS4CPP_bool print_string(const cJSON * const item, printbuffer * const p) { return print_string_ptr((unsigned char*)item->valuestring, p); } /* Predeclare these prototypes. */ -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 cJSON_AS4CPP_bool parse_value(cJSON * const item, parse_buffer * const input_buffer); +static cJSON_AS4CPP_bool print_value(const cJSON * const item, printbuffer * const output_buffer); +static cJSON_AS4CPP_bool parse_array(cJSON * const item, parse_buffer * const input_buffer); +static cJSON_AS4CPP_bool print_array(const cJSON * const item, printbuffer * const output_buffer); +static cJSON_AS4CPP_bool parse_object(cJSON * const item, parse_buffer * const input_buffer); +static cJSON_AS4CPP_bool print_object(const cJSON * const item, printbuffer * const output_buffer); /* Utility to jump whitespace and cr/lf */ static parse_buffer *buffer_skip_whitespace(parse_buffer * const buffer) @@ -1013,7 +1013,7 @@ static parse_buffer *skip_utf8_bom(parse_buffer * const buffer) } /* Parse an object - create a new root, and populate. */ -CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_bool require_null_terminated) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_ParseWithOpts(const char *value, const char **return_parse_end, cJSON_AS4CPP_bool require_null_terminated) { parse_buffer buffer = { 0, 0, 0, 0, { 0, 0, 0 } }; cJSON *item = NULL; @@ -1032,7 +1032,7 @@ CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return buffer.offset = 0; buffer.hooks = global_hooks; - item = cJSON_New_Item(&global_hooks); + item = cJSON_AS4CPP_New_Item(&global_hooks); if (item == NULL) /* memory fail */ { goto fail; @@ -1063,7 +1063,7 @@ CJSON_PUBLIC(cJSON *) cJSON_ParseWithOpts(const char *value, const char **return fail: if (item != NULL) { - cJSON_Delete(item); + cJSON_AS4CPP_Delete(item); } if (value != NULL) @@ -1092,15 +1092,15 @@ fail: return NULL; } -/* Default options for cJSON_Parse */ -CJSON_PUBLIC(cJSON *) cJSON_Parse(const char *value) +/* Default options for cJSON_AS4CPP_Parse */ +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_Parse(const char *value) { - return cJSON_ParseWithOpts(value, 0, 0); + return cJSON_AS4CPP_ParseWithOpts(value, 0, 0); } #define cjson_min(a, b) ((a < b) ? a : b) -static unsigned char *print(const cJSON * const item, cJSON_bool format, const internal_hooks * const hooks) +static unsigned char *print(const cJSON * const item, cJSON_AS4CPP_bool format, const internal_hooks * const hooks) { static const size_t default_buffer_size = 256; printbuffer buffer[1]; @@ -1165,17 +1165,17 @@ fail: } /* Render a cJSON item/entity/structure to text. */ -CJSON_PUBLIC(char *) cJSON_Print(const cJSON *item) +CJSON_AS4CPP_PUBLIC(char *) cJSON_AS4CPP_Print(const cJSON *item) { return (char*)print(item, true, &global_hooks); } -CJSON_PUBLIC(char *) cJSON_PrintUnformatted(const cJSON *item) +CJSON_AS4CPP_PUBLIC(char *) cJSON_AS4CPP_PrintUnformatted(const cJSON *item) { return (char*)print(item, false, &global_hooks); } -CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON_bool fmt) +CJSON_AS4CPP_PUBLIC(char *) cJSON_AS4CPP_PrintBuffered(const cJSON *item, int prebuffer, cJSON_AS4CPP_bool fmt) { printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; @@ -1205,7 +1205,7 @@ CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON return (char*)p.buffer; } -CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const int len, const cJSON_bool fmt) +CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_PrintPreallocated(cJSON *item, char *buf, const int len, const cJSON_AS4CPP_bool fmt) { printbuffer p = { 0, 0, 0, 0, 0, 0, { 0, 0, 0 } }; @@ -1225,7 +1225,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_PrintPreallocated(cJSON *item, char *buf, const i } /* Parser core - when encountering text, process appropriately. */ -static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buffer) +static cJSON_AS4CPP_bool parse_value(cJSON * const item, parse_buffer * const input_buffer) { if ((input_buffer == NULL) || (input_buffer->content == NULL)) { @@ -1236,21 +1236,21 @@ static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buf /* null */ if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "null", 4) == 0)) { - item->type = cJSON_NULL; + item->type = cJSON_AS4CPP_NULL; input_buffer->offset += 4; return true; } /* false */ if (can_read(input_buffer, 5) && (strncmp((const char*)buffer_at_offset(input_buffer), "false", 5) == 0)) { - item->type = cJSON_False; + item->type = cJSON_AS4CPP_False; input_buffer->offset += 5; return true; } /* true */ if (can_read(input_buffer, 4) && (strncmp((const char*)buffer_at_offset(input_buffer), "true", 4) == 0)) { - item->type = cJSON_True; + item->type = cJSON_AS4CPP_True; item->valueint = 1; input_buffer->offset += 4; return true; @@ -1280,7 +1280,7 @@ static cJSON_bool parse_value(cJSON * const item, parse_buffer * const input_buf } /* Render a value to text. */ -static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer) +static cJSON_AS4CPP_bool print_value(const cJSON * const item, printbuffer * const output_buffer) { unsigned char *output = NULL; @@ -1291,7 +1291,7 @@ static cJSON_bool print_value(const cJSON * const item, printbuffer * const outp switch ((item->type) & 0xFF) { - case cJSON_NULL: + case cJSON_AS4CPP_NULL: output = ensure(output_buffer, 5); if (output == NULL) { @@ -1300,7 +1300,7 @@ static cJSON_bool print_value(const cJSON * const item, printbuffer * const outp strcpy((char*)output, "null"); return true; - case cJSON_False: + case cJSON_AS4CPP_False: output = ensure(output_buffer, 6); if (output == NULL) { @@ -1309,7 +1309,7 @@ static cJSON_bool print_value(const cJSON * const item, printbuffer * const outp strcpy((char*)output, "false"); return true; - case cJSON_True: + case cJSON_AS4CPP_True: output = ensure(output_buffer, 5); if (output == NULL) { @@ -1318,10 +1318,10 @@ static cJSON_bool print_value(const cJSON * const item, printbuffer * const outp strcpy((char*)output, "true"); return true; - case cJSON_Number: + case cJSON_AS4CPP_Number: return print_number(item, output_buffer); - case cJSON_Raw: + case cJSON_AS4CPP_Raw: { size_t raw_length = 0; if (item->valuestring == NULL) @@ -1339,13 +1339,13 @@ static cJSON_bool print_value(const cJSON * const item, printbuffer * const outp return true; } - case cJSON_String: + case cJSON_AS4CPP_String: return print_string(item, output_buffer); - case cJSON_Array: + case cJSON_AS4CPP_Array: return print_array(item, output_buffer); - case cJSON_Object: + case cJSON_AS4CPP_Object: return print_object(item, output_buffer); default: @@ -1354,12 +1354,12 @@ static cJSON_bool print_value(const cJSON * const item, printbuffer * const outp } /* Build an array from input text. */ -static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buffer) +static cJSON_AS4CPP_bool parse_array(cJSON * const item, parse_buffer * const input_buffer) { cJSON *head = NULL; /* head of the linked list */ cJSON *current_item = NULL; - if (input_buffer->depth >= CJSON_NESTING_LIMIT) + if (input_buffer->depth >= CJSON_AS4CPP_NESTING_LIMIT) { return false; /* to deeply nested */ } @@ -1392,7 +1392,7 @@ static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buf do { /* allocate next item */ - cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks)); + cJSON *new_item = cJSON_AS4CPP_New_Item(&(input_buffer->hooks)); if (new_item == NULL) { goto fail; /* allocation failure */ @@ -1431,7 +1431,7 @@ static cJSON_bool parse_array(cJSON * const item, parse_buffer * const input_buf success: input_buffer->depth--; - item->type = cJSON_Array; + item->type = cJSON_AS4CPP_Array; item->child = head; input_buffer->offset++; @@ -1441,14 +1441,14 @@ success: fail: if (head != NULL) { - cJSON_Delete(head); + cJSON_AS4CPP_Delete(head); } return false; } /* Render an array to text */ -static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer) +static cJSON_AS4CPP_bool print_array(const cJSON * const item, printbuffer * const output_buffer) { unsigned char *output_pointer = NULL; size_t length = 0; @@ -1510,12 +1510,12 @@ static cJSON_bool print_array(const cJSON * const item, printbuffer * const outp } /* Build an object from the text. */ -static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer) +static cJSON_AS4CPP_bool parse_object(cJSON * const item, parse_buffer * const input_buffer) { cJSON *head = NULL; /* linked list head */ cJSON *current_item = NULL; - if (input_buffer->depth >= CJSON_NESTING_LIMIT) + if (input_buffer->depth >= CJSON_AS4CPP_NESTING_LIMIT) { return false; /* to deeply nested */ } @@ -1546,7 +1546,7 @@ static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_bu do { /* allocate next item */ - cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks)); + cJSON *new_item = cJSON_AS4CPP_New_Item(&(input_buffer->hooks)); if (new_item == NULL) { goto fail; /* allocation failure */ @@ -1603,7 +1603,7 @@ static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_bu success: input_buffer->depth--; - item->type = cJSON_Object; + item->type = cJSON_AS4CPP_Object; item->child = head; input_buffer->offset++; @@ -1612,14 +1612,14 @@ success: fail: if (head != NULL) { - cJSON_Delete(head); + cJSON_AS4CPP_Delete(head); } return false; } /* Render an object to text. */ -static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer) +static cJSON_AS4CPP_bool print_object(const cJSON * const item, printbuffer * const output_buffer) { unsigned char *output_pointer = NULL; size_t length = 0; @@ -1733,7 +1733,7 @@ static cJSON_bool print_object(const cJSON * const item, printbuffer * const out } /* Get Array size/item / object item. */ -CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array) +CJSON_AS4CPP_PUBLIC(int) cJSON_AS4CPP_GetArraySize(const cJSON *array) { cJSON *child = NULL; size_t size = 0; @@ -1775,7 +1775,7 @@ static cJSON* get_array_item(const cJSON *array, size_t index) return current_child; } -CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_GetArrayItem(const cJSON *array, int index) { if (index < 0) { @@ -1785,7 +1785,7 @@ CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index) return get_array_item(array, (size_t)index); } -static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_bool case_sensitive) +static cJSON *get_object_item(const cJSON * const object, const char * const name, const cJSON_AS4CPP_bool case_sensitive) { cJSON *current_element = NULL; @@ -1813,19 +1813,19 @@ static cJSON *get_object_item(const cJSON * const object, const char * const nam return current_element; } -CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_GetObjectItem(const cJSON * const object, const char * const string) { return get_object_item(object, string, false); } -CJSON_PUBLIC(cJSON *) cJSON_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_GetObjectItemCaseSensitive(const cJSON * const object, const char * const string) { return get_object_item(object, string, true); } -CJSON_PUBLIC(cJSON_bool) cJSON_HasObjectItem(const cJSON *object, const char *string) +CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_HasObjectItem(const cJSON *object, const char *string) { - return cJSON_GetObjectItem(object, string) ? 1 : 0; + return cJSON_AS4CPP_GetObjectItem(object, string) ? 1 : 0; } /* Utility for array list handling. */ @@ -1844,7 +1844,7 @@ static cJSON *create_reference(const cJSON *item, const internal_hooks * const h return NULL; } - reference = cJSON_New_Item(hooks); + reference = cJSON_AS4CPP_New_Item(hooks); if (reference == NULL) { return NULL; @@ -1852,12 +1852,12 @@ static cJSON *create_reference(const cJSON *item, const internal_hooks * const h memcpy(reference, item, sizeof(cJSON)); reference->string = NULL; - reference->type |= cJSON_IsReference; + reference->type |= cJSON_AS4CPP_IsReference; reference->next = reference->prev = NULL; return reference; } -static cJSON_bool add_item_to_array(cJSON *array, cJSON *item) +static cJSON_AS4CPP_bool add_item_to_array(cJSON *array, cJSON *item) { cJSON *child = NULL; @@ -1887,7 +1887,7 @@ static cJSON_bool add_item_to_array(cJSON *array, cJSON *item) } /* Add item to array/object. */ -CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_AddItemToArray(cJSON *array, cJSON *item) { add_item_to_array(array, item); } @@ -1908,10 +1908,10 @@ static void* cast_away_const(const void* string) #endif -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_AS4CPP_bool add_item_to_object(cJSON * const object, const char * const string, cJSON * const item, const internal_hooks * const hooks, const cJSON_AS4CPP_bool constant_key) { char *new_key = NULL; - int new_type = cJSON_Invalid; + int new_type = cJSON_AS4CPP_Invalid; if ((object == NULL) || (string == NULL) || (item == NULL)) { @@ -1921,20 +1921,20 @@ static cJSON_bool add_item_to_object(cJSON * const object, const char * const st if (constant_key) { new_key = (char*)cast_away_const(string); - new_type = item->type | cJSON_StringIsConst; + new_type = item->type | cJSON_AS4CPP_StringIsConst; } else { - new_key = (char*)cJSON_strdup((const unsigned char*)string, hooks); + new_key = (char*)cJSON_AS4CPP_strdup((const unsigned char*)string, hooks); if (new_key == NULL) { return false; } - new_type = item->type & ~cJSON_StringIsConst; + new_type = item->type & ~cJSON_AS4CPP_StringIsConst; } - if (!(item->type & cJSON_StringIsConst) && (item->string != NULL)) + if (!(item->type & cJSON_AS4CPP_StringIsConst) && (item->string != NULL)) { hooks->deallocate(item->string); } @@ -1945,18 +1945,18 @@ static cJSON_bool add_item_to_object(cJSON * const object, const char * const st return add_item_to_array(object, item); } -CJSON_PUBLIC(void) cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_AddItemToObject(cJSON *object, const char *string, cJSON *item) { add_item_to_object(object, string, item, &global_hooks, false); } /* Add an item to an object with constant string as key */ -CJSON_PUBLIC(void) cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) { add_item_to_object(object, string, item, &global_hooks, true); } -CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_AddItemReferenceToArray(cJSON *array, cJSON *item) { if (array == NULL) { @@ -1966,7 +1966,7 @@ CJSON_PUBLIC(void) cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) add_item_to_array(array, create_reference(item, &global_hooks)); } -CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_AddItemReferenceToObject(cJSON *object, const char *string, cJSON *item) { if ((object == NULL) || (string == NULL)) { @@ -1976,115 +1976,115 @@ CJSON_PUBLIC(void) cJSON_AddItemReferenceToObject(cJSON *object, const char *str add_item_to_object(object, string, create_reference(item, &global_hooks), &global_hooks, false); } -CJSON_PUBLIC(cJSON*) cJSON_AddNullToObject(cJSON * const object, const char * const name) +CJSON_AS4CPP_PUBLIC(cJSON*) cJSON_AS4CPP_AddNullToObject(cJSON * const object, const char * const name) { - cJSON *null = cJSON_CreateNull(); + cJSON *null = cJSON_AS4CPP_CreateNull(); if (add_item_to_object(object, name, null, &global_hooks, false)) { return null; } - cJSON_Delete(null); + cJSON_AS4CPP_Delete(null); return NULL; } -CJSON_PUBLIC(cJSON*) cJSON_AddTrueToObject(cJSON * const object, const char * const name) +CJSON_AS4CPP_PUBLIC(cJSON*) cJSON_AS4CPP_AddTrueToObject(cJSON * const object, const char * const name) { - cJSON *true_item = cJSON_CreateTrue(); + cJSON *true_item = cJSON_AS4CPP_CreateTrue(); if (add_item_to_object(object, name, true_item, &global_hooks, false)) { return true_item; } - cJSON_Delete(true_item); + cJSON_AS4CPP_Delete(true_item); return NULL; } -CJSON_PUBLIC(cJSON*) cJSON_AddFalseToObject(cJSON * const object, const char * const name) +CJSON_AS4CPP_PUBLIC(cJSON*) cJSON_AS4CPP_AddFalseToObject(cJSON * const object, const char * const name) { - cJSON *false_item = cJSON_CreateFalse(); + cJSON *false_item = cJSON_AS4CPP_CreateFalse(); if (add_item_to_object(object, name, false_item, &global_hooks, false)) { return false_item; } - cJSON_Delete(false_item); + cJSON_AS4CPP_Delete(false_item); return NULL; } -CJSON_PUBLIC(cJSON*) cJSON_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_bool boolean) +CJSON_AS4CPP_PUBLIC(cJSON*) cJSON_AS4CPP_AddBoolToObject(cJSON * const object, const char * const name, const cJSON_AS4CPP_bool boolean) { - cJSON *bool_item = cJSON_CreateBool(boolean); + cJSON *bool_item = cJSON_AS4CPP_CreateBool(boolean); if (add_item_to_object(object, name, bool_item, &global_hooks, false)) { return bool_item; } - cJSON_Delete(bool_item); + cJSON_AS4CPP_Delete(bool_item); return NULL; } -CJSON_PUBLIC(cJSON*) cJSON_AddNumberToObject(cJSON * const object, const char * const name, const double number) +CJSON_AS4CPP_PUBLIC(cJSON*) cJSON_AS4CPP_AddNumberToObject(cJSON * const object, const char * const name, const double number) { - cJSON *number_item = cJSON_CreateNumber(number); + cJSON *number_item = cJSON_AS4CPP_CreateNumber(number); if (add_item_to_object(object, name, number_item, &global_hooks, false)) { return number_item; } - cJSON_Delete(number_item); + cJSON_AS4CPP_Delete(number_item); return NULL; } -CJSON_PUBLIC(cJSON*) cJSON_AddStringToObject(cJSON * const object, const char * const name, const char * const string) +CJSON_AS4CPP_PUBLIC(cJSON*) cJSON_AS4CPP_AddStringToObject(cJSON * const object, const char * const name, const char * const string) { - cJSON *string_item = cJSON_CreateString(string); + cJSON *string_item = cJSON_AS4CPP_CreateString(string); if (add_item_to_object(object, name, string_item, &global_hooks, false)) { return string_item; } - cJSON_Delete(string_item); + cJSON_AS4CPP_Delete(string_item); return NULL; } -CJSON_PUBLIC(cJSON*) cJSON_AddRawToObject(cJSON * const object, const char * const name, const char * const raw) +CJSON_AS4CPP_PUBLIC(cJSON*) cJSON_AS4CPP_AddRawToObject(cJSON * const object, const char * const name, const char * const raw) { - cJSON *raw_item = cJSON_CreateRaw(raw); + cJSON *raw_item = cJSON_AS4CPP_CreateRaw(raw); if (add_item_to_object(object, name, raw_item, &global_hooks, false)) { return raw_item; } - cJSON_Delete(raw_item); + cJSON_AS4CPP_Delete(raw_item); return NULL; } -CJSON_PUBLIC(cJSON*) cJSON_AddObjectToObject(cJSON * const object, const char * const name) +CJSON_AS4CPP_PUBLIC(cJSON*) cJSON_AS4CPP_AddObjectToObject(cJSON * const object, const char * const name) { - cJSON *object_item = cJSON_CreateObject(); + cJSON *object_item = cJSON_AS4CPP_CreateObject(); if (add_item_to_object(object, name, object_item, &global_hooks, false)) { return object_item; } - cJSON_Delete(object_item); + cJSON_AS4CPP_Delete(object_item); return NULL; } -CJSON_PUBLIC(cJSON*) cJSON_AddArrayToObject(cJSON * const object, const char * const name) +CJSON_AS4CPP_PUBLIC(cJSON*) cJSON_AS4CPP_AddArrayToObject(cJSON * const object, const char * const name) { - cJSON *array = cJSON_CreateArray(); + cJSON *array = cJSON_AS4CPP_CreateArray(); if (add_item_to_object(object, name, array, &global_hooks, false)) { return array; } - cJSON_Delete(array); + cJSON_AS4CPP_Delete(array); return NULL; } -CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const item) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_DetachItemViaPointer(cJSON *parent, cJSON * const item) { if ((parent == NULL) || (item == NULL)) { @@ -2114,47 +2114,47 @@ CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON *parent, cJSON * const it return item; } -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromArray(cJSON *array, int which) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_DetachItemFromArray(cJSON *array, int which) { if (which < 0) { return NULL; } - return cJSON_DetachItemViaPointer(array, get_array_item(array, (size_t)which)); + return cJSON_AS4CPP_DetachItemViaPointer(array, get_array_item(array, (size_t)which)); } -CJSON_PUBLIC(void) cJSON_DeleteItemFromArray(cJSON *array, int which) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_DeleteItemFromArray(cJSON *array, int which) { - cJSON_Delete(cJSON_DetachItemFromArray(array, which)); + cJSON_AS4CPP_Delete(cJSON_AS4CPP_DetachItemFromArray(array, which)); } -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObject(cJSON *object, const char *string) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_DetachItemFromObject(cJSON *object, const char *string) { - cJSON *to_detach = cJSON_GetObjectItem(object, string); + cJSON *to_detach = cJSON_AS4CPP_GetObjectItem(object, string); - return cJSON_DetachItemViaPointer(object, to_detach); + return cJSON_AS4CPP_DetachItemViaPointer(object, to_detach); } -CJSON_PUBLIC(cJSON *) cJSON_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_DetachItemFromObjectCaseSensitive(cJSON *object, const char *string) { - cJSON *to_detach = cJSON_GetObjectItemCaseSensitive(object, string); + cJSON *to_detach = cJSON_AS4CPP_GetObjectItemCaseSensitive(object, string); - return cJSON_DetachItemViaPointer(object, to_detach); + return cJSON_AS4CPP_DetachItemViaPointer(object, to_detach); } -CJSON_PUBLIC(void) cJSON_DeleteItemFromObject(cJSON *object, const char *string) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_DeleteItemFromObject(cJSON *object, const char *string) { - cJSON_Delete(cJSON_DetachItemFromObject(object, string)); + cJSON_AS4CPP_Delete(cJSON_AS4CPP_DetachItemFromObject(object, string)); } -CJSON_PUBLIC(void) cJSON_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_DeleteItemFromObjectCaseSensitive(cJSON *object, const char *string) { - cJSON_Delete(cJSON_DetachItemFromObjectCaseSensitive(object, string)); + cJSON_AS4CPP_Delete(cJSON_AS4CPP_DetachItemFromObjectCaseSensitive(object, string)); } /* Replace array/object items with new ones. */ -CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newitem) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_InsertItemInArray(cJSON *array, int which, cJSON *newitem) { cJSON *after_inserted = NULL; @@ -2183,7 +2183,7 @@ CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newit } } -CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement) +CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_ReplaceItemViaPointer(cJSON * const parent, cJSON * const item, cJSON * replacement) { if ((parent == NULL) || (replacement == NULL) || (item == NULL)) { @@ -2213,22 +2213,22 @@ CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(cJSON * const parent, cJSON item->next = NULL; item->prev = NULL; - cJSON_Delete(item); + cJSON_AS4CPP_Delete(item); return true; } -CJSON_PUBLIC(void) cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem) { if (which < 0) { return; } - cJSON_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem); + cJSON_AS4CPP_ReplaceItemViaPointer(array, get_array_item(array, (size_t)which), newitem); } -static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_bool case_sensitive) +static cJSON_AS4CPP_bool replace_item_in_object(cJSON *object, const char *string, cJSON *replacement, cJSON_AS4CPP_bool case_sensitive) { if ((replacement == NULL) || (string == NULL)) { @@ -2236,79 +2236,79 @@ static cJSON_bool replace_item_in_object(cJSON *object, const char *string, cJSO } /* replace the name in the replacement */ - if (!(replacement->type & cJSON_StringIsConst) && (replacement->string != NULL)) + if (!(replacement->type & cJSON_AS4CPP_StringIsConst) && (replacement->string != NULL)) { - cJSON_free(replacement->string); + cJSON_AS4CPP_free(replacement->string); } - replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); - replacement->type &= ~cJSON_StringIsConst; + replacement->string = (char*)cJSON_AS4CPP_strdup((const unsigned char*)string, &global_hooks); + replacement->type &= ~cJSON_AS4CPP_StringIsConst; - cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement); + cJSON_AS4CPP_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement); return true; } -CJSON_PUBLIC(void) cJSON_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_ReplaceItemInObject(cJSON *object, const char *string, cJSON *newitem) { replace_item_in_object(object, string, newitem, false); } -CJSON_PUBLIC(void) cJSON_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_ReplaceItemInObjectCaseSensitive(cJSON *object, const char *string, cJSON *newitem) { replace_item_in_object(object, string, newitem, true); } /* Create basic types: */ -CJSON_PUBLIC(cJSON *) cJSON_CreateNull(void) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateNull(void) { - cJSON *item = cJSON_New_Item(&global_hooks); + cJSON *item = cJSON_AS4CPP_New_Item(&global_hooks); if(item) { - item->type = cJSON_NULL; + item->type = cJSON_AS4CPP_NULL; } return item; } -CJSON_PUBLIC(cJSON *) cJSON_CreateTrue(void) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateTrue(void) { - cJSON *item = cJSON_New_Item(&global_hooks); + cJSON *item = cJSON_AS4CPP_New_Item(&global_hooks); if(item) { - item->type = cJSON_True; + item->type = cJSON_AS4CPP_True; } return item; } -CJSON_PUBLIC(cJSON *) cJSON_CreateFalse(void) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateFalse(void) { - cJSON *item = cJSON_New_Item(&global_hooks); + cJSON *item = cJSON_AS4CPP_New_Item(&global_hooks); if(item) { - item->type = cJSON_False; + item->type = cJSON_AS4CPP_False; } return item; } -CJSON_PUBLIC(cJSON *) cJSON_CreateBool(cJSON_bool b) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateBool(cJSON_AS4CPP_bool b) { - cJSON *item = cJSON_New_Item(&global_hooks); + cJSON *item = cJSON_AS4CPP_New_Item(&global_hooks); if(item) { - item->type = b ? cJSON_True : cJSON_False; + item->type = b ? cJSON_AS4CPP_True : cJSON_AS4CPP_False; } return item; } -CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateNumber(double num) { - cJSON *item = cJSON_New_Item(&global_hooks); + cJSON *item = cJSON_AS4CPP_New_Item(&global_hooks); if(item) { - item->type = cJSON_Number; + item->type = cJSON_AS4CPP_Number; item->valuedouble = num; /* use saturation in case of overflow */ @@ -2329,12 +2329,12 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateNumber(double num) return item; } -CJSON_PUBLIC(cJSON *) cJSON_CreateInt64(long long num) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateInt64(long long num) { - cJSON *item = cJSON_New_Item(&global_hooks); + cJSON *item = cJSON_AS4CPP_New_Item(&global_hooks); if(item) { - item->type = cJSON_Number; + item->type = cJSON_AS4CPP_Number; item->valuedouble = static_cast<double>(num); // For integer which is out of the range of [INT_MIN, INT_MAX], it may lose precision if we cast it to double. @@ -2343,7 +2343,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateInt64(long long num) { char buf[21]; sprintf(buf, "%lld", num); - item->valuestring = (char*)cJSON_strdup((const unsigned char*)buf, &global_hooks); + item->valuestring = (char*)cJSON_AS4CPP_strdup((const unsigned char*)buf, &global_hooks); } /* use saturation in case of overflow */ @@ -2364,16 +2364,16 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateInt64(long long num) return item; } -CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateString(const char *string) { - cJSON *item = cJSON_New_Item(&global_hooks); + cJSON *item = cJSON_AS4CPP_New_Item(&global_hooks); if(item) { - item->type = cJSON_String; - item->valuestring = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); + item->type = cJSON_AS4CPP_String; + item->valuestring = (char*)cJSON_AS4CPP_strdup((const unsigned char*)string, &global_hooks); if(!item->valuestring) { - cJSON_Delete(item); + cJSON_AS4CPP_Delete(item); return NULL; } } @@ -2381,49 +2381,49 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateString(const char *string) return item; } -CJSON_PUBLIC(cJSON *) cJSON_CreateStringReference(const char *string) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateStringReference(const char *string) { - cJSON *item = cJSON_New_Item(&global_hooks); + cJSON *item = cJSON_AS4CPP_New_Item(&global_hooks); if (item != NULL) { - item->type = cJSON_String | cJSON_IsReference; + item->type = cJSON_AS4CPP_String | cJSON_AS4CPP_IsReference; item->valuestring = (char*)cast_away_const(string); } return item; } -CJSON_PUBLIC(cJSON *) cJSON_CreateObjectReference(const cJSON *child) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateObjectReference(const cJSON *child) { - cJSON *item = cJSON_New_Item(&global_hooks); + cJSON *item = cJSON_AS4CPP_New_Item(&global_hooks); if (item != NULL) { - item->type = cJSON_Object | cJSON_IsReference; + item->type = cJSON_AS4CPP_Object | cJSON_AS4CPP_IsReference; item->child = (cJSON*)cast_away_const(child); } return item; } -CJSON_PUBLIC(cJSON *) cJSON_CreateArrayReference(const cJSON *child) { - cJSON *item = cJSON_New_Item(&global_hooks); +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateArrayReference(const cJSON *child) { + cJSON *item = cJSON_AS4CPP_New_Item(&global_hooks); if (item != NULL) { - item->type = cJSON_Array | cJSON_IsReference; + item->type = cJSON_AS4CPP_Array | cJSON_AS4CPP_IsReference; item->child = (cJSON*)cast_away_const(child); } return item; } -CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateRaw(const char *raw) { - cJSON *item = cJSON_New_Item(&global_hooks); + cJSON *item = cJSON_AS4CPP_New_Item(&global_hooks); if(item) { - item->type = cJSON_Raw; - item->valuestring = (char*)cJSON_strdup((const unsigned char*)raw, &global_hooks); + item->type = cJSON_AS4CPP_Raw; + item->valuestring = (char*)cJSON_AS4CPP_strdup((const unsigned char*)raw, &global_hooks); if(!item->valuestring) { - cJSON_Delete(item); + cJSON_AS4CPP_Delete(item); return NULL; } } @@ -2431,30 +2431,30 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateRaw(const char *raw) return item; } -CJSON_PUBLIC(cJSON *) cJSON_CreateArray(void) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateArray(void) { - cJSON *item = cJSON_New_Item(&global_hooks); + cJSON *item = cJSON_AS4CPP_New_Item(&global_hooks); if(item) { - item->type=cJSON_Array; + item->type=cJSON_AS4CPP_Array; } return item; } -CJSON_PUBLIC(cJSON *) cJSON_CreateObject(void) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateObject(void) { - cJSON *item = cJSON_New_Item(&global_hooks); + cJSON *item = cJSON_AS4CPP_New_Item(&global_hooks); if (item) { - item->type = cJSON_Object; + item->type = cJSON_AS4CPP_Object; } return item; } /* Create Arrays: */ -CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateIntArray(const int *numbers, int count) { size_t i = 0; cJSON *n = NULL; @@ -2466,13 +2466,13 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count) return NULL; } - a = cJSON_CreateArray(); + a = cJSON_AS4CPP_CreateArray(); for(i = 0; a && (i < (size_t)count); i++) { - n = cJSON_CreateNumber(numbers[i]); + n = cJSON_AS4CPP_CreateNumber(numbers[i]); if (!n) { - cJSON_Delete(a); + cJSON_AS4CPP_Delete(a); return NULL; } if(!i) @@ -2489,7 +2489,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *numbers, int count) return a; } -CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateFloatArray(const float *numbers, int count) { size_t i = 0; cJSON *n = NULL; @@ -2501,14 +2501,14 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count) return NULL; } - a = cJSON_CreateArray(); + a = cJSON_AS4CPP_CreateArray(); for(i = 0; a && (i < (size_t)count); i++) { - n = cJSON_CreateNumber((double)numbers[i]); + n = cJSON_AS4CPP_CreateNumber((double)numbers[i]); if(!n) { - cJSON_Delete(a); + cJSON_AS4CPP_Delete(a); return NULL; } if(!i) @@ -2525,7 +2525,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const float *numbers, int count) return a; } -CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateDoubleArray(const double *numbers, int count) { size_t i = 0; cJSON *n = NULL; @@ -2537,14 +2537,14 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count) return NULL; } - a = cJSON_CreateArray(); + a = cJSON_AS4CPP_CreateArray(); for(i = 0;a && (i < (size_t)count); i++) { - n = cJSON_CreateNumber(numbers[i]); + n = cJSON_AS4CPP_CreateNumber(numbers[i]); if(!n) { - cJSON_Delete(a); + cJSON_AS4CPP_Delete(a); return NULL; } if(!i) @@ -2561,7 +2561,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const double *numbers, int count) return a; } -CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_CreateStringArray(const char **strings, int count) { size_t i = 0; cJSON *n = NULL; @@ -2573,14 +2573,14 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count) return NULL; } - a = cJSON_CreateArray(); + a = cJSON_AS4CPP_CreateArray(); for (i = 0; a && (i < (size_t)count); i++) { - n = cJSON_CreateString(strings[i]); + n = cJSON_AS4CPP_CreateString(strings[i]); if(!n) { - cJSON_Delete(a); + cJSON_AS4CPP_Delete(a); return NULL; } if(!i) @@ -2598,7 +2598,7 @@ CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const char **strings, int count) } /* Duplication */ -CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse) +CJSON_AS4CPP_PUBLIC(cJSON *) cJSON_AS4CPP_Duplicate(const cJSON *item, cJSON_AS4CPP_bool recurse) { cJSON *newitem = NULL; cJSON *child = NULL; @@ -2611,18 +2611,18 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse) goto fail; } /* Create new item */ - newitem = cJSON_New_Item(&global_hooks); + newitem = cJSON_AS4CPP_New_Item(&global_hooks); if (!newitem) { goto fail; } /* Copy over all vars */ - newitem->type = item->type & (~cJSON_IsReference); + newitem->type = item->type & (~cJSON_AS4CPP_IsReference); newitem->valueint = item->valueint; newitem->valuedouble = item->valuedouble; if (item->valuestring) { - newitem->valuestring = (char*)cJSON_strdup((unsigned char*)item->valuestring, &global_hooks); + newitem->valuestring = (char*)cJSON_AS4CPP_strdup((unsigned char*)item->valuestring, &global_hooks); if (!newitem->valuestring) { goto fail; @@ -2630,7 +2630,7 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse) } if (item->string) { - newitem->string = (item->type&cJSON_StringIsConst) ? item->string : (char*)cJSON_strdup((unsigned char*)item->string, &global_hooks); + newitem->string = (item->type&cJSON_AS4CPP_StringIsConst) ? item->string : (char*)cJSON_AS4CPP_strdup((unsigned char*)item->string, &global_hooks); if (!newitem->string) { goto fail; @@ -2645,7 +2645,7 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse) child = item->child; while (child != NULL) { - newchild = cJSON_Duplicate(child, true); /* Duplicate (with recurse) each item in the ->next chain */ + newchild = cJSON_AS4CPP_Duplicate(child, true); /* Duplicate (with recurse) each item in the ->next chain */ if (!newchild) { goto fail; @@ -2671,13 +2671,13 @@ CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *item, cJSON_bool recurse) fail: if (newitem != NULL) { - cJSON_Delete(newitem); + cJSON_AS4CPP_Delete(newitem); } return NULL; } -CJSON_PUBLIC(void) cJSON_Minify(char *json) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_Minify(char *json) { unsigned char *into = (unsigned char*)json; @@ -2747,109 +2747,109 @@ CJSON_PUBLIC(void) cJSON_Minify(char *json) *into = '\0'; } -CJSON_PUBLIC(cJSON_bool) cJSON_IsInvalid(const cJSON * const item) +CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_IsInvalid(const cJSON * const item) { if (item == NULL) { return false; } - return (item->type & 0xFF) == cJSON_Invalid; + return (item->type & 0xFF) == cJSON_AS4CPP_Invalid; } -CJSON_PUBLIC(cJSON_bool) cJSON_IsFalse(const cJSON * const item) +CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_IsFalse(const cJSON * const item) { if (item == NULL) { return false; } - return (item->type & 0xFF) == cJSON_False; + return (item->type & 0xFF) == cJSON_AS4CPP_False; } -CJSON_PUBLIC(cJSON_bool) cJSON_IsTrue(const cJSON * const item) +CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_IsTrue(const cJSON * const item) { if (item == NULL) { return false; } - return (item->type & 0xff) == cJSON_True; + return (item->type & 0xff) == cJSON_AS4CPP_True; } -CJSON_PUBLIC(cJSON_bool) cJSON_IsBool(const cJSON * const item) +CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_IsBool(const cJSON * const item) { if (item == NULL) { return false; } - return (item->type & (cJSON_True | cJSON_False)) != 0; + return (item->type & (cJSON_AS4CPP_True | cJSON_AS4CPP_False)) != 0; } -CJSON_PUBLIC(cJSON_bool) cJSON_IsNull(const cJSON * const item) +CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_IsNull(const cJSON * const item) { if (item == NULL) { return false; } - return (item->type & 0xFF) == cJSON_NULL; + return (item->type & 0xFF) == cJSON_AS4CPP_NULL; } -CJSON_PUBLIC(cJSON_bool) cJSON_IsNumber(const cJSON * const item) +CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_IsNumber(const cJSON * const item) { if (item == NULL) { return false; } - return (item->type & 0xFF) == cJSON_Number; + return (item->type & 0xFF) == cJSON_AS4CPP_Number; } -CJSON_PUBLIC(cJSON_bool) cJSON_IsString(const cJSON * const item) +CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_IsString(const cJSON * const item) { if (item == NULL) { return false; } - return (item->type & 0xFF) == cJSON_String; + return (item->type & 0xFF) == cJSON_AS4CPP_String; } -CJSON_PUBLIC(cJSON_bool) cJSON_IsArray(const cJSON * const item) +CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_IsArray(const cJSON * const item) { if (item == NULL) { return false; } - return (item->type & 0xFF) == cJSON_Array; + return (item->type & 0xFF) == cJSON_AS4CPP_Array; } -CJSON_PUBLIC(cJSON_bool) cJSON_IsObject(const cJSON * const item) +CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_IsObject(const cJSON * const item) { if (item == NULL) { return false; } - return (item->type & 0xFF) == cJSON_Object; + return (item->type & 0xFF) == cJSON_AS4CPP_Object; } -CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * const item) +CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_IsRaw(const cJSON * const item) { if (item == NULL) { return false; } - return (item->type & 0xFF) == cJSON_Raw; + return (item->type & 0xFF) == cJSON_AS4CPP_Raw; } -CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive) +CJSON_AS4CPP_PUBLIC(cJSON_AS4CPP_bool) cJSON_AS4CPP_Compare(const cJSON * const a, const cJSON * const b, const cJSON_AS4CPP_bool case_sensitive) { - if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)) || cJSON_IsInvalid(a)) + if ((a == NULL) || (b == NULL) || ((a->type & 0xFF) != (b->type & 0xFF)) || cJSON_AS4CPP_IsInvalid(a)) { return false; } @@ -2857,14 +2857,14 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons /* check if type is valid */ switch (a->type & 0xFF) { - case cJSON_False: - case cJSON_True: - case cJSON_NULL: - case cJSON_Number: - case cJSON_String: - case cJSON_Raw: - case cJSON_Array: - case cJSON_Object: + case cJSON_AS4CPP_False: + case cJSON_AS4CPP_True: + case cJSON_AS4CPP_NULL: + case cJSON_AS4CPP_Number: + case cJSON_AS4CPP_String: + case cJSON_AS4CPP_Raw: + case cJSON_AS4CPP_Array: + case cJSON_AS4CPP_Object: break; default: @@ -2880,20 +2880,20 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons switch (a->type & 0xFF) { /* in these cases and equal type is enough */ - case cJSON_False: - case cJSON_True: - case cJSON_NULL: + case cJSON_AS4CPP_False: + case cJSON_AS4CPP_True: + case cJSON_AS4CPP_NULL: return true; - case cJSON_Number: + case cJSON_AS4CPP_Number: if (a->valuedouble == b->valuedouble) { return true; } return false; - case cJSON_String: - case cJSON_Raw: + case cJSON_AS4CPP_String: + case cJSON_AS4CPP_Raw: if ((a->valuestring == NULL) || (b->valuestring == NULL)) { return false; @@ -2905,14 +2905,14 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons return false; - case cJSON_Array: + case cJSON_AS4CPP_Array: { cJSON *a_element = a->child; cJSON *b_element = b->child; for (; (a_element != NULL) && (b_element != NULL);) { - if (!cJSON_Compare(a_element, b_element, case_sensitive)) + if (!cJSON_AS4CPP_Compare(a_element, b_element, case_sensitive)) { return false; } @@ -2929,11 +2929,11 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons return true; } - case cJSON_Object: + case cJSON_AS4CPP_Object: { cJSON *a_element = NULL; cJSON *b_element = NULL; - cJSON_ArrayForEach(a_element, a) + cJSON_AS4CPP_ArrayForEach(a_element, a) { /* TODO This has O(n^2) runtime, which is horrible! */ b_element = get_object_item(b, a_element->string, case_sensitive); @@ -2942,7 +2942,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons return false; } - if (!cJSON_Compare(a_element, b_element, case_sensitive)) + if (!cJSON_AS4CPP_Compare(a_element, b_element, case_sensitive)) { return false; } @@ -2950,7 +2950,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons /* doing this twice, once on a and b to prevent true comparison if a subset of b * TODO: Do this the proper way, this is just a fix for now */ - cJSON_ArrayForEach(b_element, b) + cJSON_AS4CPP_ArrayForEach(b_element, b) { a_element = get_object_item(a, b_element->string, case_sensitive); if (a_element == NULL) @@ -2958,7 +2958,7 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons return false; } - if (!cJSON_Compare(b_element, a_element, case_sensitive)) + if (!cJSON_AS4CPP_Compare(b_element, a_element, case_sensitive)) { return false; } @@ -2972,12 +2972,12 @@ CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * cons } } -CJSON_PUBLIC(void *) cJSON_malloc(size_t size) +CJSON_AS4CPP_PUBLIC(void *) cJSON_AS4CPP_malloc(size_t size) { return global_hooks.allocate(size); } -CJSON_PUBLIC(void) cJSON_free(void *object) +CJSON_AS4CPP_PUBLIC(void) cJSON_AS4CPP_free(void *object) { global_hooks.deallocate(object); } |