28 #if !HAVE_STRNCASECMP && defined(_MSC_VER) 30 # define strncasecmp _strnicmp 31 #elif !HAVE_STRNCASECMP 44 "unexpected end of data",
45 "unexpected character",
49 "array value separator ',' expected",
50 "quoted object property name expected",
51 "object property name separator ':' expected",
52 "object value separator ',' expected",
53 "invalid string sequence",
86 for(i = tok->
depth; i >= 0; i--)
111 size_t len = strlen(str);
112 size_t nn =
min(len,n);
113 char* s = (
char*)malloc(
sizeof(
char) * (nn + 1));
128 #define state tok->stack[tok->depth].state 129 #define saved_state tok->stack[tok->depth].saved_state 130 #define current tok->stack[tok->depth].current 131 #define obj_field_name tok->stack[tok->depth].obj_field_name 134 const char *str,
int len)
159 }
else if(c ==
'/') {
227 if(tok->
depth == 0)
goto out;
253 }
else if(c ==
'/') {
291 }
else if(c ==
'\\') {
332 unsigned char utf_out[3];
337 utf_out[0] = 0xc0 | (tok->
ucs_char >> 6);
338 utf_out[1] = 0x80 | (tok->
ucs_char & 0x3f);
341 utf_out[0] = 0xe0 | (tok->
ucs_char >> 12);
342 utf_out[1] = 0x80 | ((tok->
ucs_char >> 6) & 0x3f);
343 utf_out[2] = 0x80 | (tok->
ucs_char & 0x3f);
382 if(c ==
'.' || c ==
'e') tok->
is_double = 1;
388 }
else if(tok->
is_double && sscanf(tok->
pb->
buf,
"%lf", &numd) == 1) {
426 }
else if(c ==
',') {
439 }
else if (c ==
'"' || c ==
'\'') {
454 }
else if(c ==
'\\') {
494 }
else if(c ==
',') {
514 mc_debug(
"json_tokener_parse_ex: error %s at offset %d\n",
void json_object_put(struct json_object *this)
struct json_tokener_srec stack[JSON_TOKENER_MAX_DEPTH]
static const char * json_null_str
enum json_tokener_error err
struct json_object * json_object_new_boolean(boolean b)
struct json_object * json_object_new_double(double d)
void mc_debug(const char *msg,...)
char * json_c_strndup(const char *str, size_t n)
struct printbuf * printbuf_new()
struct json_object * json_object_new_string(const char *s)
void json_tokener_free(struct json_tokener *tok)
#define JSON_TOKENER_MAX_DEPTH
void json_tokener_reset(struct json_tokener *tok)
int json_object_array_add(struct json_object *this, struct json_object *val)
struct json_object * current
struct json_object * json_object_new_array()
struct json_object * json_object_get(struct json_object *this)
struct json_object * json_object_new_object()
const char * json_tokener_errors[]
struct json_object * json_tokener_parse_ex(struct json_tokener *tok, const char *str, int len)
struct json_object * json_object_new_int(int i)
void json_object_object_add(struct json_object *this, const char *key, struct json_object *val)
void printbuf_free(struct printbuf *p)
const char * json_hex_chars
static const char * json_true_str
const char * json_number_chars
enum json_tokener_state state saved_state
static const char * json_false_str
struct json_tokener * json_tokener_new()
int printbuf_memappend(struct printbuf *p, const char *buf, int size)
void printbuf_reset(struct printbuf *p)
struct json_object * json_tokener_parse(const char *str)
static void json_tokener_reset_level(struct json_tokener *tok, int depth)