Skip to content
Newer
Older
100644 100 lines (87 sloc) 2.61 KB
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
1 /*
a850f8e @michaeljclark * Add escaping of backslash to json output
michaeljclark authored Mar 13, 2007
2 * $Id: json_tokener.h,v 1.10 2006/07/25 03:24:50 mclark Exp $
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
3 *
f6a6e48 @michaeljclark * Make headers C++ compatible by change *this to *obj
michaeljclark authored Mar 13, 2007
4 * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
5 * Michael Clark <michael@metaparadigm.com>
6 *
f6a6e48 @michaeljclark * Make headers C++ compatible by change *this to *obj
michaeljclark authored Mar 13, 2007
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the MIT license. See COPYING for details.
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
9 *
10 */
11
12 #ifndef _json_tokener_h_
13 #define _json_tokener_h_
14
a327254 @michaeljclark fix to allow compile with -Werror
michaeljclark authored Jan 26, 2008
15 #include <stddef.h>
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
16 #include "json_object.h"
17
aaec1ef @michaeljclark * Don't use this as a variable, so we can compile with a C++ compiler
michaeljclark authored Feb 25, 2009
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
22 enum json_tokener_error {
23 json_tokener_success,
a850f8e @michaeljclark * Add escaping of backslash to json output
michaeljclark authored Mar 13, 2007
24 json_tokener_continue,
25 json_tokener_error_depth,
26 json_tokener_error_parse_eof,
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
27 json_tokener_error_parse_unexpected,
28 json_tokener_error_parse_null,
29 json_tokener_error_parse_boolean,
30 json_tokener_error_parse_number,
31 json_tokener_error_parse_array,
a850f8e @michaeljclark * Add escaping of backslash to json output
michaeljclark authored Mar 13, 2007
32 json_tokener_error_parse_object_key_name,
33 json_tokener_error_parse_object_key_sep,
34 json_tokener_error_parse_object_value_sep,
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
35 json_tokener_error_parse_string,
a850f8e @michaeljclark * Add escaping of backslash to json output
michaeljclark authored Mar 13, 2007
36 json_tokener_error_parse_comment
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
37 };
38
39 enum json_tokener_state {
40 json_tokener_state_eatws,
41 json_tokener_state_start,
42 json_tokener_state_finish,
43 json_tokener_state_null,
44 json_tokener_state_comment_start,
45 json_tokener_state_comment,
46 json_tokener_state_comment_eol,
47 json_tokener_state_comment_end,
48 json_tokener_state_string,
49 json_tokener_state_string_escape,
50 json_tokener_state_escape_unicode,
51 json_tokener_state_boolean,
52 json_tokener_state_number,
53 json_tokener_state_array,
a850f8e @michaeljclark * Add escaping of backslash to json output
michaeljclark authored Mar 13, 2007
54 json_tokener_state_array_add,
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
55 json_tokener_state_array_sep,
56 json_tokener_state_object_field_start,
57 json_tokener_state_object_field,
58 json_tokener_state_object_field_end,
59 json_tokener_state_object_value,
a850f8e @michaeljclark * Add escaping of backslash to json output
michaeljclark authored Mar 13, 2007
60 json_tokener_state_object_value_add,
f6a6e48 @michaeljclark * Make headers C++ compatible by change *this to *obj
michaeljclark authored Mar 13, 2007
61 json_tokener_state_object_sep
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
62 };
63
a850f8e @michaeljclark * Add escaping of backslash to json output
michaeljclark authored Mar 13, 2007
64 struct json_tokener_srec
65 {
66 enum json_tokener_state state, saved_state;
67 struct json_object *obj;
68 struct json_object *current;
69 char *obj_field_name;
70 };
71
72 #define JSON_TOKENER_MAX_DEPTH 32
73
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
74 struct json_tokener
75 {
a850f8e @michaeljclark * Add escaping of backslash to json output
michaeljclark authored Mar 13, 2007
76 char *str;
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
77 struct printbuf *pb;
a850f8e @michaeljclark * Add escaping of backslash to json output
michaeljclark authored Mar 13, 2007
78 int depth, is_double, st_pos, char_offset;
a503ee8 @jehiah add json_tokener_parse_verbose, and return NULL on parser errors
authored Dec 8, 2010
79 enum json_tokener_error err;
a850f8e @michaeljclark * Add escaping of backslash to json output
michaeljclark authored Mar 13, 2007
80 unsigned int ucs_char;
81 char quote_char;
82 struct json_tokener_srec stack[JSON_TOKENER_MAX_DEPTH];
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
83 };
84
a850f8e @michaeljclark * Add escaping of backslash to json output
michaeljclark authored Mar 13, 2007
85 extern const char* json_tokener_errors[];
86
14862b1 @michaeljclark Patch allows for json-c compile with -Werror and not fail due to
michaeljclark authored Dec 7, 2007
87 extern struct json_tokener* json_tokener_new(void);
a850f8e @michaeljclark * Add escaping of backslash to json output
michaeljclark authored Mar 13, 2007
88 extern void json_tokener_free(struct json_tokener *tok);
89 extern void json_tokener_reset(struct json_tokener *tok);
b1a22ac @sixlettervariables Add const qualifier to the json_tokener_parse functions
sixlettervariables authored Jul 8, 2009
90 extern struct json_object* json_tokener_parse(const char *str);
a503ee8 @jehiah add json_tokener_parse_verbose, and return NULL on parser errors
authored Dec 8, 2010
91 extern struct json_object* json_tokener_parse_verbose(const char *str, enum json_tokener_error *error);
a850f8e @michaeljclark * Add escaping of backslash to json output
michaeljclark authored Mar 13, 2007
92 extern struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
b1a22ac @sixlettervariables Add const qualifier to the json_tokener_parse functions
sixlettervariables authored Jul 8, 2009
93 const char *str, int len);
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
94
aaec1ef @michaeljclark * Don't use this as a variable, so we can compile with a C++ compiler
michaeljclark authored Feb 25, 2009
95 #ifdef __cplusplus
96 }
97 #endif
98
f0d0888 @michaeljclark import of version 0.1
michaeljclark authored Mar 13, 2007
99 #endif
Something went wrong with that request. Please try again.