root/src/json-lib/json_tokener.h

Revision efa9375336eec306ede14a9a1032985a71482810, 2.5 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 4 years ago)

refs #294 resmon no support arbitrary json objects

  • Property mode set to 100644
Line 
1 /*
2  * $Id: json_tokener.h,v 1.10 2006/07/25 03:24:50 mclark Exp $
3  *
4  * Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
5  * Michael Clark <michael@metaparadigm.com>
6  *
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.
9  *
10  */
11
12 #ifndef _json_tokener_h_
13 #define _json_tokener_h_
14
15 #include <stddef.h>
16 #include "json_object.h"
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 enum json_tokener_error {
23   json_tokener_success,
24   json_tokener_continue,
25   json_tokener_error_depth,
26   json_tokener_error_parse_eof,
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,
32   json_tokener_error_parse_object_key_name,
33   json_tokener_error_parse_object_key_sep,
34   json_tokener_error_parse_object_value_sep,
35   json_tokener_error_parse_string,
36   json_tokener_error_parse_comment
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,
54   json_tokener_state_array_add,
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,
60   json_tokener_state_object_value_add,
61   json_tokener_state_object_sep
62 };
63
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
74 struct json_tokener
75 {
76   char *str;
77   struct printbuf *pb;
78   int depth, is_double, st_pos, char_offset;
79   ptrdiff_t err;
80   unsigned int ucs_char;
81   char quote_char;
82   struct json_tokener_srec stack[JSON_TOKENER_MAX_DEPTH];
83 };
84
85 extern const char* json_tokener_errors[];
86
87 extern struct json_tokener* json_tokener_new(void);
88 extern void json_tokener_free(struct json_tokener *tok);
89 extern void json_tokener_reset(struct json_tokener *tok);
90 extern struct json_object* json_tokener_parse(const char *str);
91 extern struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
92                                                  const char *str, int len);
93
94 #ifdef __cplusplus
95 }
96 #endif
97
98 #endif
Note: See TracBrowser for help on using the browser.