version 1.1.1.2, 2021/03/17 00:36:46
|
version 1.1.1.3, 2023/09/27 11:14:54
|
Line 37
|
Line 37
|
#pragma warning (disable : 4001) |
#pragma warning (disable : 4001) |
#endif |
#endif |
|
|
|
#include "iperf_config.h" |
#include <string.h> |
#include <string.h> |
#include <stdio.h> |
#include <stdio.h> |
#include <math.h> |
#include <math.h> |
Line 82
|
Line 83
|
#endif |
#endif |
|
|
#ifndef NAN |
#ifndef NAN |
|
#ifdef _WIN32 |
|
#define NAN sqrt(-1.0) |
|
#else |
#define NAN 0.0/0.0 |
#define NAN 0.0/0.0 |
#endif |
#endif |
|
#endif |
|
|
|
#if defined(HAVE_INTTYPES_H) |
|
# include <inttypes.h> |
|
#else |
|
# ifndef PRIu64 |
|
# if sizeof(long) == 8 |
|
# define PRIu64 "lu" |
|
# else |
|
# define PRIu64 "llu" |
|
# endif |
|
# ifndef PRId64 |
|
# if sizeof(long) == 8 |
|
# define PRId64 "ld" |
|
# else |
|
# define PRId64 "lld" |
|
# endif |
|
# endif |
|
# endif |
|
#endif |
|
|
typedef struct { |
typedef struct { |
const unsigned char *json; |
const unsigned char *json; |
size_t position; |
size_t position; |
Line 103 CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)
|
Line 127 CJSON_PUBLIC(const char *) cJSON_GetErrorPtr(void)
|
return (const char*) (global_error.json + global_error.position); |
return (const char*) (global_error.json + global_error.position); |
} |
} |
|
|
CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item) | CJSON_PUBLIC(char *) cJSON_GetStringValue(const cJSON * const item) |
{ |
{ |
if (!cJSON_IsString(item)) | if (!cJSON_IsString(item)) |
{ |
{ |
return NULL; |
return NULL; |
} |
} |
Line 113 CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item)
|
Line 137 CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item)
|
return item->valuestring; |
return item->valuestring; |
} |
} |
|
|
CJSON_PUBLIC(double) cJSON_GetNumberValue(cJSON *item) | CJSON_PUBLIC(double) cJSON_GetNumberValue(const cJSON * const item) |
{ |
{ |
if (!cJSON_IsNumber(item)) | if (!cJSON_IsNumber(item)) |
{ |
{ |
return NAN; | return (double) NAN; // cppcheck-suppress invalidFunctionArg |
} |
} |
|
|
return item->valuedouble; |
return item->valuedouble; |
} |
} |
|
|
/* This is a safeguard to prevent copy-pasters from using incompatible C and header files */ |
/* 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 != 13) | #if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 15) |
#error cJSON.h and cJSON.c have different versions. Make sure that both have the same. |
#error cJSON.h and cJSON.c have different versions. Make sure that both have the same. |
#endif |
#endif |
|
|
Line 518 static unsigned char* ensure(printbuffer * const p, si
|
Line 542 static unsigned char* ensure(printbuffer * const p, si
|
|
|
return NULL; |
return NULL; |
} |
} |
if (newbuffer) | |
{ | memcpy(newbuffer, p->buffer, p->offset + 1); |
memcpy(newbuffer, p->buffer, p->offset + 1); | |
} | |
p->hooks.deallocate(p->buffer); |
p->hooks.deallocate(p->buffer); |
} |
} |
p->length = newsize; |
p->length = newsize; |
Line 571 static cJSON_bool print_number(const cJSON * const ite
|
Line 593 static cJSON_bool print_number(const cJSON * const ite
|
{ |
{ |
length = sprintf((char*)number_buffer, "null"); |
length = sprintf((char*)number_buffer, "null"); |
} |
} |
|
else if(d == (double)item->valueint) |
|
{ |
|
length = sprintf((char*)number_buffer, "%" PRId64, item->valueint); |
|
} |
else |
else |
{ |
{ |
/* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */ |
/* Try 15 decimal places of precision to avoid nonsignificant nonzero digits */ |
Line 1112 CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const
|
Line 1138 CJSON_PUBLIC(cJSON *) cJSON_ParseWithLengthOpts(const
|
} |
} |
|
|
buffer.content = (const unsigned char*)value; |
buffer.content = (const unsigned char*)value; |
buffer.length = buffer_length; | buffer.length = buffer_length; |
buffer.offset = 0; |
buffer.offset = 0; |
buffer.hooks = global_hooks; |
buffer.hooks = global_hooks; |
|
|
Line 1520 static cJSON_bool parse_array(cJSON * const item, pars
|
Line 1546 static cJSON_bool parse_array(cJSON * const item, pars
|
success: |
success: |
input_buffer->depth--; |
input_buffer->depth--; |
|
|
|
if (head != NULL) { |
|
head->prev = current_item; |
|
} |
|
|
item->type = cJSON_Array; |
item->type = cJSON_Array; |
item->child = head; |
item->child = head; |
|
|
Line 1692 static cJSON_bool parse_object(cJSON * const item, par
|
Line 1722 static cJSON_bool parse_object(cJSON * const item, par
|
success: |
success: |
input_buffer->depth--; |
input_buffer->depth--; |
|
|
|
if (head != NULL) { |
|
head->prev = current_item; |
|
} |
|
|
item->type = cJSON_Object; |
item->type = cJSON_Object; |
item->child = head; |
item->child = head; |
|
|
Line 1978 static cJSON_bool add_item_to_array(cJSON *array, cJSO
|
Line 2012 static cJSON_bool add_item_to_array(cJSON *array, cJSO
|
suffix_object(child->prev, item); |
suffix_object(child->prev, item); |
array->child->prev = item; |
array->child->prev = item; |
} |
} |
else |
|
{ |
|
while (child->next) |
|
{ |
|
child = child->next; |
|
} |
|
suffix_object(child, item); |
|
array->child->prev = item; |
|
} |
|
} |
} |
|
|
return true; |
return true; |
Line 2213 CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON
|
Line 2238 CJSON_PUBLIC(cJSON *) cJSON_DetachItemViaPointer(cJSON
|
/* first element */ |
/* first element */ |
parent->child = item->next; |
parent->child = item->next; |
} |
} |
|
else if (item->next == NULL) |
|
{ |
|
/* last element */ |
|
parent->child->prev = item->prev; |
|
} |
|
|
/* make sure the detached item doesn't point anywhere anymore */ |
/* make sure the detached item doesn't point anywhere anymore */ |
item->prev = NULL; |
item->prev = NULL; |
item->next = NULL; |
item->next = NULL; |
Line 2310 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(c
|
Line 2341 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(c
|
} |
} |
if (parent->child == item) |
if (parent->child == item) |
{ |
{ |
|
if (parent->child->prev == parent->child) |
|
{ |
|
replacement->prev = replacement; |
|
} |
parent->child = replacement; |
parent->child = replacement; |
} |
} |
else |
else |
Line 2321 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(c
|
Line 2356 CJSON_PUBLIC(cJSON_bool) cJSON_ReplaceItemViaPointer(c
|
{ |
{ |
replacement->prev->next = replacement; |
replacement->prev->next = replacement; |
} |
} |
|
if (replacement->next == NULL) |
|
{ |
|
parent->child->prev = replacement; |
|
} |
} |
} |
|
|
item->next = NULL; |
item->next = NULL; |
Line 2353 static cJSON_bool replace_item_in_object(cJSON *object
|
Line 2392 static cJSON_bool replace_item_in_object(cJSON *object
|
cJSON_free(replacement->string); |
cJSON_free(replacement->string); |
} |
} |
replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); |
replacement->string = (char*)cJSON_strdup((const unsigned char*)string, &global_hooks); |
|
if (replacement->string == NULL) |
|
{ |
|
return false; |
|
} |
|
|
replacement->type &= ~cJSON_StringIsConst; |
replacement->type &= ~cJSON_StringIsConst; |
|
|
return cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement); |
return cJSON_ReplaceItemViaPointer(object, get_object_item(object, string, case_sensitive), replacement); |
Line 2542 CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *
|
Line 2586 CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *
|
} |
} |
|
|
a = cJSON_CreateArray(); |
a = cJSON_CreateArray(); |
|
|
for(i = 0; a && (i < (size_t)count); i++) |
for(i = 0; a && (i < (size_t)count); i++) |
{ |
{ |
n = cJSON_CreateNumber(numbers[i]); |
n = cJSON_CreateNumber(numbers[i]); |
Line 2561 CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *
|
Line 2606 CJSON_PUBLIC(cJSON *) cJSON_CreateIntArray(const int *
|
p = n; |
p = n; |
} |
} |
|
|
|
if (a && a->child) { |
|
a->child->prev = n; |
|
} |
|
|
return a; |
return a; |
} |
} |
|
|
Line 2597 CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const flo
|
Line 2646 CJSON_PUBLIC(cJSON *) cJSON_CreateFloatArray(const flo
|
p = n; |
p = n; |
} |
} |
|
|
|
if (a && a->child) { |
|
a->child->prev = n; |
|
} |
|
|
return a; |
return a; |
} |
} |
|
|
Line 2614 CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const do
|
Line 2667 CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const do
|
|
|
a = cJSON_CreateArray(); |
a = cJSON_CreateArray(); |
|
|
for(i = 0;a && (i < (size_t)count); i++) | for(i = 0; a && (i < (size_t)count); i++) |
{ |
{ |
n = cJSON_CreateNumber(numbers[i]); |
n = cJSON_CreateNumber(numbers[i]); |
if(!n) |
if(!n) |
Line 2633 CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const do
|
Line 2686 CJSON_PUBLIC(cJSON *) cJSON_CreateDoubleArray(const do
|
p = n; |
p = n; |
} |
} |
|
|
|
if (a && a->child) { |
|
a->child->prev = n; |
|
} |
|
|
return a; |
return a; |
} |
} |
|
|
Line 2669 CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const ch
|
Line 2726 CJSON_PUBLIC(cJSON *) cJSON_CreateStringArray(const ch
|
p = n; |
p = n; |
} |
} |
|
|
|
if (a && a->child) { |
|
a->child->prev = n; |
|
} |
|
|
return a; |
return a; |
} |
} |
|
|
Line 2740 CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *ite
|
Line 2801 CJSON_PUBLIC(cJSON *) cJSON_Duplicate(const cJSON *ite
|
} |
} |
child = child->next; |
child = child->next; |
} |
} |
|
if (newitem && newitem->child) |
|
{ |
|
newitem->child->prev = newchild; |
|
} |
|
|
return newitem; |
return newitem; |
|
|
Line 2951 CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * con
|
Line 3016 CJSON_PUBLIC(cJSON_bool) cJSON_IsRaw(const cJSON * con
|
|
|
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_bool case_sensitive) |
CJSON_PUBLIC(cJSON_bool) cJSON_Compare(const cJSON * const a, const cJSON * const b, const cJSON_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))) |
{ |
{ |
return false; |
return false; |
} |
} |