34 #if !defined(LWS_ARRAY_SIZE)
35 #define LWS_ARRAY_SIZE(_x) (sizeof(_x) / sizeof(_x[0]))
37 #define LEJP_FLAG_WS_KEEP 64
38 #define LEJP_FLAG_WS_COMMENTLINE 32
44 LEJP_MP_STRING = LEJP_FLAG_WS_KEEP | 3,
45 LEJP_MP_STRING_ESC = LEJP_FLAG_WS_KEEP | 4,
46 LEJP_MP_STRING_ESC_U1 = LEJP_FLAG_WS_KEEP | 5,
47 LEJP_MP_STRING_ESC_U2 = LEJP_FLAG_WS_KEEP | 6,
48 LEJP_MP_STRING_ESC_U3 = LEJP_FLAG_WS_KEEP | 7,
49 LEJP_MP_STRING_ESC_U4 = LEJP_FLAG_WS_KEEP | 8,
52 LEJP_MP_VALUE_NUM_INT = LEJP_FLAG_WS_KEEP | 11,
53 LEJP_MP_VALUE_NUM_EXP = LEJP_FLAG_WS_KEEP | 12,
54 LEJP_MP_VALUE_TOK = LEJP_FLAG_WS_KEEP | 13,
55 LEJP_MP_COMMA_OR_END = 14,
56 LEJP_MP_ARRAY_END = 15,
61 LEJP_REJECT_IDLE_NO_BRACE = -2,
62 LEJP_REJECT_MEMBERS_NO_CLOSE = -3,
63 LEJP_REJECT_MP_NO_OPEN_QUOTE = -4,
64 LEJP_REJECT_MP_STRING_UNDERRUN = -5,
65 LEJP_REJECT_MP_ILLEGAL_CTRL = -6,
66 LEJP_REJECT_MP_STRING_ESC_ILLEGAL_ESC = -7,
67 LEJP_REJECT_ILLEGAL_HEX = -8,
68 LEJP_REJECT_MP_DELIM_MISSING_COLON = -9,
69 LEJP_REJECT_MP_DELIM_BAD_VALUE_START = -10,
70 LEJP_REJECT_MP_VAL_NUM_INT_NO_FRAC = -11,
71 LEJP_REJECT_MP_VAL_NUM_FORMAT = -12,
72 LEJP_REJECT_MP_VAL_NUM_EXP_BAD_EXP = -13,
73 LEJP_REJECT_MP_VAL_TOK_UNKNOWN = -14,
74 LEJP_REJECT_MP_C_OR_E_UNDERF = -15,
75 LEJP_REJECT_MP_C_OR_E_NOTARRAY = -16,
76 LEJP_REJECT_MP_ARRAY_END_MISSING = -17,
77 LEJP_REJECT_STACK_OVERFLOW = -18,
78 LEJP_REJECT_MP_DELIM_ISTACK = -19,
79 LEJP_REJECT_NUM_TOO_LONG = -20,
80 LEJP_REJECT_MP_C_OR_E_NEITHER = -21,
81 LEJP_REJECT_UNKNOWN = -22,
82 LEJP_REJECT_CALLBACK = -23
85 #define LEJP_FLAG_CB_IS_VALUE 64
88 LEJPCB_CONSTRUCTED = 0,
89 LEJPCB_DESTRUCTED = 1,
97 LEJPCB_VAL_TRUE = LEJP_FLAG_CB_IS_VALUE | 6,
98 LEJPCB_VAL_FALSE = LEJP_FLAG_CB_IS_VALUE | 7,
99 LEJPCB_VAL_NULL = LEJP_FLAG_CB_IS_VALUE | 8,
100 LEJPCB_VAL_NUM_INT = LEJP_FLAG_CB_IS_VALUE | 9,
101 LEJPCB_VAL_NUM_FLOAT = LEJP_FLAG_CB_IS_VALUE | 10,
102 LEJPCB_VAL_STR_START = 11,
103 LEJPCB_VAL_STR_CHUNK = LEJP_FLAG_CB_IS_VALUE | 12,
104 LEJPCB_VAL_STR_END = LEJP_FLAG_CB_IS_VALUE | 13,
106 LEJPCB_ARRAY_START = 14,
107 LEJPCB_ARRAY_END = 15,
109 LEJPCB_OBJECT_START = 16,
110 LEJPCB_OBJECT_END = 17,
174 LWS_EXTERN
signed char _lejp_callback(
struct lejp_ctx *ctx,
char reason);
176 typedef signed char (*lejp_callback)(
struct lejp_ctx *ctx,
char reason);
178 #ifndef LEJP_MAX_PARSING_STACK_DEPTH
179 #define LEJP_MAX_PARSING_STACK_DEPTH 5
181 #ifndef LEJP_MAX_DEPTH
182 #define LEJP_MAX_DEPTH 12
184 #ifndef LEJP_MAX_INDEX_DEPTH
185 #define LEJP_MAX_INDEX_DEPTH 8
187 #ifndef LEJP_MAX_PATH
188 #define LEJP_MAX_PATH 128
190 #ifndef LEJP_STRING_CHUNK
192 #define LEJP_STRING_CHUNK 254
196 LEJP_SEEN_MINUS = (1 << 0),
197 LEJP_SEEN_POINT = (1 << 1),
198 LEJP_SEEN_POST_POINT = (1 << 2),
199 LEJP_SEEN_EXP = (1 << 3)
211 signed char (*callback)(
struct lejp_ctx *ctx,
char reason);
212 const char *
const *paths;
230 uint16_t i[LEJP_MAX_INDEX_DEPTH];
231 uint16_t wild[LEJP_MAX_INDEX_DEPTH];
232 char path[LEJP_MAX_PATH];
233 char buf[LEJP_STRING_CHUNK + 1];
256 uint8_t path_match_len;
262 LWS_VISIBLE LWS_EXTERN
void
263 lejp_construct(
struct lejp_ctx *ctx,
264 signed char (*callback)(
struct lejp_ctx *ctx,
char reason),
265 void *user,
const char *
const *paths,
unsigned char paths_count);
267 LWS_VISIBLE LWS_EXTERN
void
268 lejp_destruct(
struct lejp_ctx *ctx);
270 LWS_VISIBLE LWS_EXTERN
int
271 lejp_parse(
struct lejp_ctx *ctx,
const unsigned char *json,
int len);
273 LWS_VISIBLE LWS_EXTERN
void
274 lejp_change_callback(
struct lejp_ctx *ctx,
275 signed char (*callback)(
struct lejp_ctx *ctx,
char reason));
281 LWS_VISIBLE LWS_EXTERN
int
282 lejp_parser_push(
struct lejp_ctx *ctx,
void *user,
const char *
const *paths,
283 unsigned char paths_count, lejp_callback lejp_cb);
289 LWS_VISIBLE LWS_EXTERN
int
290 lejp_parser_pop(
struct lejp_ctx *ctx);
293 LWS_VISIBLE LWS_EXTERN
void
294 lejp_check_path_match(
struct lejp_ctx *ctx);
296 LWS_VISIBLE LWS_EXTERN
int
297 lejp_get_wildcard(
struct lejp_ctx *ctx,
int wildcard,
char *dest,
int len);
299 LWS_VISIBLE LWS_EXTERN
const char *
300 lejp_error_to_string(
int e);
Definition: lws-lejp.h:209
Definition: lws-lejp.h:202
Definition: lws-lejp.h:218