libwebsockets
Lightweight C library for HTML5 websockets
|
Go to the source code of this file.
Data Structures | |
struct | _lejp_stack |
struct | _lejp_parsing_stack |
struct | lejp_ctx |
Macros | |
#define | LWS_ARRAY_SIZE(_x) (sizeof(_x) / sizeof(_x[0])) |
#define | LEJP_FLAG_WS_KEEP 64 |
#define | LEJP_FLAG_WS_COMMENTLINE 32 |
#define | LEJP_FLAG_CB_IS_VALUE 64 |
#define | LEJP_MAX_PARSING_STACK_DEPTH 8 |
#define | LEJP_MAX_DEPTH 16 |
#define | LEJP_MAX_INDEX_DEPTH 12 |
#define | LEJP_MAX_PATH 192 |
#define | LEJP_STRING_CHUNK 254 |
#define | LEJP_FLAG_FEAT_OBJECT_INDEXES (1 << 0) |
#define | LEJP_FLAG_FEAT_LEADING_WC (1 << 1) |
#define | LEJP_FLAG_LATEST |
Typedefs | |
typedef signed char(* | lejp_callback) (struct lejp_ctx *ctx, char reason) |
Functions | |
LWS_EXTERN signed char | _lejp_callback (struct lejp_ctx *ctx, char reason) |
LWS_VISIBLE LWS_EXTERN void | lejp_construct (struct lejp_ctx *ctx, signed char(*callback)(struct lejp_ctx *ctx, char reason), void *user, const char *const *paths, unsigned char paths_count) |
LWS_VISIBLE LWS_EXTERN void | lejp_destruct (struct lejp_ctx *ctx) |
LWS_VISIBLE LWS_EXTERN int | lejp_parse (struct lejp_ctx *ctx, const unsigned char *json, int len) |
LWS_VISIBLE LWS_EXTERN void | lejp_change_callback (struct lejp_ctx *ctx, signed char(*callback)(struct lejp_ctx *ctx, char reason)) |
LWS_VISIBLE LWS_EXTERN int | lejp_parser_push (struct lejp_ctx *ctx, void *user, const char *const *paths, unsigned char paths_count, lejp_callback lejp_cb) |
LWS_VISIBLE LWS_EXTERN int | lejp_parser_pop (struct lejp_ctx *ctx) |
LWS_VISIBLE LWS_EXTERN void | lejp_check_path_match (struct lejp_ctx *ctx) |
LWS_VISIBLE LWS_EXTERN int | lejp_get_wildcard (struct lejp_ctx *ctx, int wildcard, char *dest, int len) |
LWS_VISIBLE LWS_EXTERN const char * | lejp_error_to_string (int e) |
struct _lejp_stack |
Definition at line 204 of file lws-lejp.h.
Data Fields | ||
---|---|---|
char | s | |
char | p | |
char | i | |
char | b |
struct lejp_ctx |
Definition at line 220 of file lws-lejp.h.
Data Fields | ||
---|---|---|
void * | user | |
struct _lejp_parsing_stack | pst[LEJP_MAX_PARSING_STACK_DEPTH] | |
struct _lejp_stack | st[LEJP_MAX_DEPTH] | |
uint16_t | i[LEJP_MAX_INDEX_DEPTH] | |
uint16_t | wild[LEJP_MAX_INDEX_DEPTH] | |
char | path[LEJP_MAX_PATH] | |
char | buf[LEJP_STRING_CHUNK+1] | |
size_t | path_stride | |
uint32_t | line | |
uint16_t | uni | |
uint16_t | flags | |
uint8_t | npos | |
uint8_t | dcount | |
uint8_t | f | |
uint8_t | sp | |
uint8_t | ipos | |
uint8_t | count_paths | |
uint8_t | path_match | |
uint8_t | path_match_len | |
uint8_t | wildcount | |
uint8_t | pst_sp | |
uint8_t | outer_array |
#define LWS_ARRAY_SIZE | ( | _x | ) | (sizeof(_x) / sizeof(_x[0])) |
Definition at line 35 of file lws-lejp.h.
#define LEJP_FLAG_WS_KEEP 64 |
Definition at line 37 of file lws-lejp.h.
#define LEJP_FLAG_WS_COMMENTLINE 32 |
Definition at line 38 of file lws-lejp.h.
#define LEJP_FLAG_CB_IS_VALUE 64 |
Definition at line 85 of file lws-lejp.h.
#define LEJP_MAX_PARSING_STACK_DEPTH 8 |
Definition at line 181 of file lws-lejp.h.
#define LEJP_MAX_DEPTH 16 |
Definition at line 184 of file lws-lejp.h.
#define LEJP_MAX_INDEX_DEPTH 12 |
Definition at line 187 of file lws-lejp.h.
#define LEJP_MAX_PATH 192 |
Definition at line 190 of file lws-lejp.h.
#define LEJP_STRING_CHUNK 254 |
Definition at line 194 of file lws-lejp.h.
#define LEJP_FLAG_FEAT_OBJECT_INDEXES (1 << 0) |
Definition at line 248 of file lws-lejp.h.
#define LEJP_FLAG_FEAT_LEADING_WC (1 << 1) |
Definition at line 249 of file lws-lejp.h.
#define LEJP_FLAG_LATEST |
Definition at line 250 of file lws-lejp.h.
typedef signed char(* lejp_callback) (struct lejp_ctx *ctx, char reason) |
Definition at line 178 of file lws-lejp.h.
enum lejp_states |
Definition at line 40 of file lws-lejp.h.
enum lejp_reasons |
Definition at line 59 of file lws-lejp.h.
enum lejp_callbacks |
Definition at line 87 of file lws-lejp.h.
enum num_flags |
Enumerator | |
---|---|
LEJP_SEEN_MINUS | |
LEJP_SEEN_POINT | |
LEJP_SEEN_POST_POINT | |
LEJP_SEEN_EXP |
Definition at line 197 of file lws-lejp.h.
LWS_EXTERN signed char _lejp_callback | ( | struct lejp_ctx * | ctx, |
char | reason | ||
) |
_lejp_callback() - User parser actions
ctx | LEJP context |
reason | Callback reason Your user callback is associated with the context at construction time, and receives calls as the parsing progresses. All of the callbacks may be ignored and just return 0. The reasons it might get called, found in @reason, are:LEJPCB_CONSTRUCTED: The context was just constructed... you might want to perform one-time allocation for the life of the context. |
LEJPCB_DESTRUCTED: The context is being destructed... if you made any allocations at construction-time, you can free them now
LEJPCB_START: Parsing is beginning at the first byte of input
LEJPCB_COMPLETE: Parsing has completed successfully. You'll get a 0 or positive return code from lejp_parse indicating the amount of unused bytes left in the input buffer
LEJPCB_FAILED: Parsing failed. You'll get a negative error code returned from lejp_parse
LEJPCB_PAIR_NAME: When a "name":"value" pair has had the name parsed, this callback occurs. You can find the new name at the end of ctx->path[]
LEJPCB_VAL_TRUE: The "true" value appeared
LEJPCB_VAL_FALSE: The "false" value appeared
LEJPCB_VAL_NULL: The "null" value appeared
LEJPCB_VAL_NUM_INT: A string representing an integer is in ctx->buf
LEJPCB_VAL_NUM_FLOAT: A string representing a float is in ctx->buf
LEJPCB_VAL_STR_START: We are starting to parse a string, no data yet
LEJPCB_VAL_STR_CHUNK: We filled the string buffer in the ctx, but it's not the end of the string. We produce this to spill the intermediate buffer to the user code, so we can handle huge JSON strings using only the small buffer in the ctx. If the whole JSON string fits in the ctx buffer, you won't get these callbacks.
LEJPCB_VAL_STR_END: String parsing has completed, the last chunk of the string is in ctx->buf.
LEJPCB_ARRAY_START: An array started
LEJPCB_ARRAY_END: An array ended
LEJPCB_OBJECT_START: An object started
LEJPCB_OBJECT_END: An object ended
LWS_VISIBLE LWS_EXTERN void lejp_construct | ( | struct lejp_ctx * | ctx, |
signed char(*)(struct lejp_ctx *ctx, char reason) | callback, | ||
void * | user, | ||
const char *const * | paths, | ||
unsigned char | paths_count | ||
) |
LWS_VISIBLE LWS_EXTERN void lejp_destruct | ( | struct lejp_ctx * | ctx | ) |
LWS_VISIBLE LWS_EXTERN int lejp_parse | ( | struct lejp_ctx * | ctx, |
const unsigned char * | json, | ||
int | len | ||
) |
LWS_VISIBLE LWS_EXTERN void lejp_change_callback | ( | struct lejp_ctx * | ctx, |
signed char(*)(struct lejp_ctx *ctx, char reason) | callback | ||
) |
LWS_VISIBLE LWS_EXTERN int lejp_parser_push | ( | struct lejp_ctx * | ctx, |
void * | user, | ||
const char *const * | paths, | ||
unsigned char | paths_count, | ||
lejp_callback | lejp_cb | ||
) |
LWS_VISIBLE LWS_EXTERN int lejp_parser_pop | ( | struct lejp_ctx * | ctx | ) |
LWS_VISIBLE LWS_EXTERN void lejp_check_path_match | ( | struct lejp_ctx * | ctx | ) |
LWS_VISIBLE LWS_EXTERN int lejp_get_wildcard | ( | struct lejp_ctx * | ctx, |
int | wildcard, | ||
char * | dest, | ||
int | len | ||
) |
LWS_VISIBLE LWS_EXTERN const char* lejp_error_to_string | ( | int | e | ) |