libwebsockets
Lightweight C library for HTML5 websockets
lws-lecp.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lecp_item
 
struct  _lecp_stack
 
struct  _lecp_parsing_stack
 
struct  lecp_ctx
 
struct  lws_lec_pctx
 
union  lecp_item.u
 

Macros

#define LECP_MAX_PARSING_STACK_DEPTH   5
 
#define LECP_MAX_DEPTH   12
 
#define LECP_MAX_INDEX_DEPTH   8
 
#define LECP_MAX_PATH   128
 
#define LECP_STRING_CHUNK   254
 
#define LECP_FLAG_CB_IS_VALUE   64
 

Typedefs

typedef signed char(* lecp_callback) (struct lecp_ctx *ctx, char reason)
 
typedef struct lws_lec_pctx lws_lec_pctx_t
 

Enumerations

enum  {
  LWS_CBOR_MAJTYP_UINT = 0 << 5 , LWS_CBOR_MAJTYP_INT_NEG = 1 << 5 , LWS_CBOR_MAJTYP_BSTR = 2 << 5 , LWS_CBOR_MAJTYP_TSTR = 3 << 5 ,
  LWS_CBOR_MAJTYP_ARRAY = 4 << 5 , LWS_CBOR_MAJTYP_MAP = 5 << 5 , LWS_CBOR_MAJTYP_TAG = 6 << 5 , LWS_CBOR_MAJTYP_FLOAT = 7 << 5 ,
  LWS_CBOR_MAJTYP_MASK = 7 << 5 , LWS_CBOR_1 = 24 , LWS_CBOR_2 = 25 , LWS_CBOR_4 = 26 ,
  LWS_CBOR_8 = 27 , LWS_CBOR_RESERVED = 28 , LWS_CBOR_SUBMASK = 0x1f , LWS_CBOR_SWK_FALSE = 20 ,
  LWS_CBOR_SWK_TRUE = 21 , LWS_CBOR_SWK_NULL = 22 , LWS_CBOR_SWK_UNDEFINED = 23 , LWS_CBOR_M7_SUBTYP_SIMPLE_X8 = 24 ,
  LWS_CBOR_M7_SUBTYP_FLOAT16 = 25 , LWS_CBOR_M7_SUBTYP_FLOAT32 = 26 , LWS_CBOR_M7_SUBTYP_FLOAT64 = 27 , LWS_CBOR_M7_BREAK = 31 ,
  LWS_CBOR_INDETERMINITE = 31 , LWS_CBOR_WKTAG_DATETIME_STD = 0 , LWS_CBOR_WKTAG_DATETIME_EPOCH = 1 , LWS_CBOR_WKTAG_BIGNUM_UNSIGNED = 2 ,
  LWS_CBOR_WKTAG_BIGNUM_NEGATIVE = 3 , LWS_CBOR_WKTAG_DECIMAL_FRAC = 4 , LWS_CBOR_WKTAG_BIGFLOAT = 5 , LWS_CBOR_WKTAG_COSE_ENC0 = 16 ,
  LWS_CBOR_WKTAG_COSE_MAC0 = 17 , LWS_CBOR_WKTAG_COSE_SIGN1 = 18 , LWS_CBOR_WKTAG_TO_B64U = 21 , LWS_CBOR_WKTAG_TO_B64 = 22 ,
  LWS_CBOR_WKTAG_TO_B16 = 23 , LWS_CBOR_WKTAG_CBOR = 24 , LWS_CBOR_WKTAG_URI = 32 , LWS_CBOR_WKTAG_B64U = 33 ,
  LWS_CBOR_WKTAG_B64 = 34 , LWS_CBOR_WKTAG_MIME = 36 , LWS_CBOR_WKTAG_COSE_ENC = 96 , LWS_CBOR_WKTAG_COSE_MAC = 97 ,
  LWS_CBOR_WKTAG_COSE_SIGN = 98 , LWS_CBOR_WKTAG_SELFDESCCBOR = 55799
}
 
enum  lecp_callbacks {
  LECPCB_CONSTRUCTED = 0 , LECPCB_DESTRUCTED = 1 , LECPCB_COMPLETE = 3 , LECPCB_FAILED = 4 ,
  LECPCB_PAIR_NAME = 5 , LECPCB_VAL_TRUE = LECP_FLAG_CB_IS_VALUE | 6 , LECPCB_VAL_FALSE = LECP_FLAG_CB_IS_VALUE | 7 , LECPCB_VAL_NULL = LECP_FLAG_CB_IS_VALUE | 8 ,
  LECPCB_VAL_NUM_INT = LECP_FLAG_CB_IS_VALUE | 9 , LECPCB_VAL_RESERVED = LECP_FLAG_CB_IS_VALUE | 10 , LECPCB_VAL_STR_START = 11 , LECPCB_VAL_STR_CHUNK = LECP_FLAG_CB_IS_VALUE | 12 ,
  LECPCB_VAL_STR_END = LECP_FLAG_CB_IS_VALUE | 13 , LECPCB_ARRAY_START = 14 , LECPCB_ARRAY_END = 15 , LECPCB_OBJECT_START = 16 ,
  LECPCB_OBJECT_END = 17 , LECPCB_TAG_START = 18 , LECPCB_TAG_END = 19 , LECPCB_VAL_NUM_UINT = LECP_FLAG_CB_IS_VALUE | 20 ,
  LECPCB_VAL_UNDEFINED = LECP_FLAG_CB_IS_VALUE | 21 , LECPCB_VAL_FLOAT16 = LECP_FLAG_CB_IS_VALUE | 22 , LECPCB_VAL_FLOAT32 = LECP_FLAG_CB_IS_VALUE | 23 , LECPCB_VAL_FLOAT64 = LECP_FLAG_CB_IS_VALUE | 24 ,
  LECPCB_VAL_SIMPLE = LECP_FLAG_CB_IS_VALUE | 25 , LECPCB_VAL_BLOB_START = 26 , LECPCB_VAL_BLOB_CHUNK = LECP_FLAG_CB_IS_VALUE | 27 , LECPCB_VAL_BLOB_END = LECP_FLAG_CB_IS_VALUE | 28 ,
  LECPCB_ARRAY_ITEM_START = 29 , LECPCB_ARRAY_ITEM_END = 30 , LECPCB_LITERAL_CBOR = 31
}
 
enum  lecp_reasons {
  LECP_CONTINUE = -1 , LECP_REJECT_BAD_CODING = -2 , LECP_REJECT_UNKNOWN = -3 , LECP_REJECT_CALLBACK = -4 ,
  LECP_STACK_OVERFLOW = -5
}
 
enum  lws_lec_pctx_ret { LWS_LECPCTX_RET_FINISHED = 0 , LWS_LECPCTX_RET_AGAIN , LWS_LECPCTX_RET_FAIL }
 
enum  cbp_state {
  CBPS_IDLE , CBPS_PC1 , CBPS_PC2 , CBPS_PC3 ,
  CBPS_STRING_BODY , CBPS_NUM_LIT , CBPS_STRING_LIT , CBPS_CONTYPE
}
 

Functions

LWS_VISIBLE LWS_EXTERN void lws_lec_int (lws_lec_pctx_t *ctx, uint8_t opcode, uint8_t indet, uint64_t num)
 
LWS_VISIBLE LWS_EXTERN int lws_lec_scratch (lws_lec_pctx_t *ctx)
 
LWS_VISIBLE LWS_EXTERN void lws_lec_init (lws_lec_pctx_t *ctx, uint8_t *buf, size_t len)
 
LWS_VISIBLE LWS_EXTERN void lws_lec_setbuf (lws_lec_pctx_t *ctx, uint8_t *buf, size_t len)
 
LWS_VISIBLE LWS_EXTERN enum lws_lec_pctx_ret lws_lec_vsprintf (lws_lec_pctx_t *ctx, const char *format, va_list args)
 
LWS_VISIBLE LWS_EXTERN enum lws_lec_pctx_ret lws_lec_printf (lws_lec_pctx_t *ctx, const char *format,...)
 
LWS_VISIBLE LWS_EXTERN void lecp_construct (struct lecp_ctx *ctx, lecp_callback cb, void *user, const char *const *paths, unsigned char paths_count)
 
LWS_VISIBLE LWS_EXTERN void lecp_destruct (struct lecp_ctx *ctx)
 
LWS_VISIBLE LWS_EXTERN int lecp_parse (struct lecp_ctx *ctx, const uint8_t *cbor, size_t len)
 
LWS_VISIBLE LWS_EXTERN void lecp_change_callback (struct lecp_ctx *ctx, lecp_callback cb)
 
LWS_VISIBLE LWS_EXTERN const char * lecp_error_to_string (int e)
 
LWS_VISIBLE LWS_EXTERN void lecp_parse_report_raw (struct lecp_ctx *ctx, int on)
 
LWS_VISIBLE LWS_EXTERN int lecp_parse_map_is_key (struct lecp_ctx *ctx)
 
LWS_VISIBLE LWS_EXTERN int lecp_parse_subtree (struct lecp_ctx *ctx, const uint8_t *in, size_t len)
 
LWS_VISIBLE LWS_EXTERN void lws_singles2halfp (uint16_t *hp, uint32_t x)
 
LWS_VISIBLE LWS_EXTERN void lws_halfp2singles (uint32_t *xp, uint16_t h)
 

Data Structure Documentation

◆ lecp_item

struct lecp_item

Definition at line 198 of file lws-lecp.h.

+ Collaboration diagram for lecp_item:
Data Fields
union lecp_item u
uint8_t opcode

◆ _lecp_stack

struct _lecp_stack

Definition at line 220 of file lws-lecp.h.

+ Collaboration diagram for _lecp_stack:
Data Fields
char s
uint8_t p
char i
char indet
char intermediate
char pop_iss
uint64_t tag
uint64_t collect_rem
uint32_t ordinal
uint8_t opcode
uint8_t send_new_array_item
uint8_t barrier

◆ _lecp_parsing_stack

struct _lecp_parsing_stack

Definition at line 236 of file lws-lecp.h.

+ Collaboration diagram for _lecp_parsing_stack:
Data Fields
void * user
lecp_callback cb
const char *const * paths
uint8_t count_paths
uint8_t ppos
uint8_t path_match

◆ lecp_ctx

struct lecp_ctx

Definition at line 245 of file lws-lecp.h.

+ Collaboration diagram for lecp_ctx:
Data Fields
void * user
uint8_t * collect_tgt
struct _lecp_parsing_stack pst[LECP_MAX_PARSING_STACK_DEPTH]
struct _lecp_stack st[LECP_MAX_DEPTH]
uint16_t i[LECP_MAX_INDEX_DEPTH]
uint16_t wild[LECP_MAX_INDEX_DEPTH]
char path[LECP_MAX_PATH]
uint8_t cbor[64]
struct lecp_item item
size_t path_stride
size_t used_in
uint16_t uni
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
uint8_t cbor_pos
uint8_t literal_cbor_report
char present
uint8_t be
char buf[LECP_STRING_CHUNK+1]

◆ lws_lec_pctx

struct lws_lec_pctx

Definition at line 324 of file lws-lecp.h.

+ Collaboration diagram for lws_lec_pctx:
Data Fields
uint8_t stack[16]
uint8_t vaa[16]
uint8_t indet[16]
uint8_t scratch[24]
uint8_t * start
uint8_t * buf
uint8_t * end
const uint8_t * ongoing_src
uint64_t ongoing_len
uint64_t ongoing_done
struct lecp_item item
size_t used
int opaque[4]
enum cbp_state state
unsigned int fmt_pos
uint8_t sp
uint8_t scratch_len
uint8_t escflag
uint8_t _long
uint8_t vaa_pos
uint8_t dotstar

◆ lecp_item.u

union lecp_item.u

Definition at line 199 of file lws-lecp.h.

+ Collaboration diagram for lecp_item.u:
Data Fields
uint64_t u64
int64_t i64
uint64_t u32
uint16_t hf
uint32_t f
uint64_t d

Macro Definition Documentation

◆ LECP_MAX_PARSING_STACK_DEPTH

#define LECP_MAX_PARSING_STACK_DEPTH   5

Definition at line 36 of file lws-lecp.h.

◆ LECP_MAX_DEPTH

#define LECP_MAX_DEPTH   12

Definition at line 39 of file lws-lecp.h.

◆ LECP_MAX_INDEX_DEPTH

#define LECP_MAX_INDEX_DEPTH   8

Definition at line 42 of file lws-lecp.h.

◆ LECP_MAX_PATH

#define LECP_MAX_PATH   128

Definition at line 45 of file lws-lecp.h.

◆ LECP_STRING_CHUNK

#define LECP_STRING_CHUNK   254

Definition at line 49 of file lws-lecp.h.

◆ LECP_FLAG_CB_IS_VALUE

#define LECP_FLAG_CB_IS_VALUE   64

Definition at line 52 of file lws-lecp.h.

Typedef Documentation

◆ lecp_callback

typedef signed char(* lecp_callback) (struct lecp_ctx *ctx, char reason)

Definition at line 218 of file lws-lecp.h.

◆ lws_lec_pctx_t

typedef struct lws_lec_pctx lws_lec_pctx_t

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LWS_CBOR_MAJTYP_UINT 
LWS_CBOR_MAJTYP_INT_NEG 
LWS_CBOR_MAJTYP_BSTR 
LWS_CBOR_MAJTYP_TSTR 
LWS_CBOR_MAJTYP_ARRAY 
LWS_CBOR_MAJTYP_MAP 
LWS_CBOR_MAJTYP_TAG 
LWS_CBOR_MAJTYP_FLOAT 
LWS_CBOR_MAJTYP_MASK 
LWS_CBOR_1 
LWS_CBOR_2 
LWS_CBOR_4 
LWS_CBOR_8 
LWS_CBOR_RESERVED 
LWS_CBOR_SUBMASK 
LWS_CBOR_SWK_FALSE 
LWS_CBOR_SWK_TRUE 
LWS_CBOR_SWK_NULL 
LWS_CBOR_SWK_UNDEFINED 
LWS_CBOR_M7_SUBTYP_SIMPLE_X8 
LWS_CBOR_M7_SUBTYP_FLOAT16 
LWS_CBOR_M7_SUBTYP_FLOAT32 
LWS_CBOR_M7_SUBTYP_FLOAT64 
LWS_CBOR_M7_BREAK 
LWS_CBOR_INDETERMINITE 
LWS_CBOR_WKTAG_DATETIME_STD 
LWS_CBOR_WKTAG_DATETIME_EPOCH 
LWS_CBOR_WKTAG_BIGNUM_UNSIGNED 
LWS_CBOR_WKTAG_BIGNUM_NEGATIVE 
LWS_CBOR_WKTAG_DECIMAL_FRAC 
LWS_CBOR_WKTAG_BIGFLOAT 
LWS_CBOR_WKTAG_COSE_ENC0 
LWS_CBOR_WKTAG_COSE_MAC0 
LWS_CBOR_WKTAG_COSE_SIGN1 
LWS_CBOR_WKTAG_TO_B64U 
LWS_CBOR_WKTAG_TO_B64 
LWS_CBOR_WKTAG_TO_B16 
LWS_CBOR_WKTAG_CBOR 
LWS_CBOR_WKTAG_URI 
LWS_CBOR_WKTAG_B64U 
LWS_CBOR_WKTAG_B64 
LWS_CBOR_WKTAG_MIME 
LWS_CBOR_WKTAG_COSE_ENC 
LWS_CBOR_WKTAG_COSE_MAC 
LWS_CBOR_WKTAG_COSE_SIGN 
LWS_CBOR_WKTAG_SELFDESCCBOR 

Definition at line 58 of file lws-lecp.h.

58  {
59  LWS_CBOR_MAJTYP_UINT = 0 << 5,
60  LWS_CBOR_MAJTYP_INT_NEG = 1 << 5,
61  LWS_CBOR_MAJTYP_BSTR = 2 << 5,
62  LWS_CBOR_MAJTYP_TSTR = 3 << 5,
63  LWS_CBOR_MAJTYP_ARRAY = 4 << 5,
64  LWS_CBOR_MAJTYP_MAP = 5 << 5,
65  LWS_CBOR_MAJTYP_TAG = 6 << 5,
66  LWS_CBOR_MAJTYP_FLOAT = 7 << 5, /* also BREAK */
67 
68  LWS_CBOR_MAJTYP_MASK = 7 << 5,
69 
70  /*
71  * For the low 5 bits of the opcode, 0-23 are literals, unless it's
72  * FLOAT.
73  *
74  * 24 = 1 byte; 25 = 2..., 26 = 4... and 27 = 8 bytes following literal.
75  */
76  LWS_CBOR_1 = 24,
77  LWS_CBOR_2 = 25,
78  LWS_CBOR_4 = 26,
79  LWS_CBOR_8 = 27,
80 
81  LWS_CBOR_RESERVED = 28,
82 
83  LWS_CBOR_SUBMASK = 0x1f,
84 
85  /*
86  * Major type 7 discriminators in low 5 bits
87  * 0 - 23 is SIMPLE implicit value (like, eg, LWS_CBOR_SWK_TRUE)
88  */
89  LWS_CBOR_SWK_FALSE = 20,
90  LWS_CBOR_SWK_TRUE = 21,
91  LWS_CBOR_SWK_NULL = 22,
93 
94  LWS_CBOR_M7_SUBTYP_SIMPLE_X8 = 24, /* simple with additional byte */
98  LWS_CBOR_M7_BREAK = 31,
99 
100 /* 28, 29, 30 are illegal.
101  *
102  * 31 is illegal for UINT, INT_NEG, and TAG;
103  * for BSTR, TSTR, ARRAY and MAP it means "indefinite length", ie,
104  * it's made up of an endless amount of determinite-length
105  * fragments terminated with a BREAK (FLOAT | 31) instead of the
106  * next determinite-length fragment. The second framing level
107  * means no need for escapes for BREAK in the data.
108  */
109 
111 
112 /*
113  * Well-known tags
114  */
115 
116  LWS_CBOR_WKTAG_DATETIME_STD = 0, /* text */
117  LWS_CBOR_WKTAG_DATETIME_EPOCH = 1, /* int or float */
118  LWS_CBOR_WKTAG_BIGNUM_UNSIGNED = 2, /* byte string */
119  LWS_CBOR_WKTAG_BIGNUM_NEGATIVE = 3, /* byte string */
120  LWS_CBOR_WKTAG_DECIMAL_FRAC = 4, /* array */
121  LWS_CBOR_WKTAG_BIGFLOAT = 5, /* array */
122 
126 
127  LWS_CBOR_WKTAG_TO_B64U = 21, /* any */
128  LWS_CBOR_WKTAG_TO_B64 = 22, /* any */
129  LWS_CBOR_WKTAG_TO_B16 = 23, /* any */
130  LWS_CBOR_WKTAG_CBOR = 24, /* byte string */
131 
132  LWS_CBOR_WKTAG_URI = 32, /* text string */
133  LWS_CBOR_WKTAG_B64U = 33, /* text string */
134  LWS_CBOR_WKTAG_B64 = 34, /* text string */
135  LWS_CBOR_WKTAG_MIME = 36, /* text string */
136 
140 
142 };
@ LWS_CBOR_WKTAG_COSE_SIGN
Definition: lws-lecp.h:139
@ LWS_CBOR_MAJTYP_BSTR
Definition: lws-lecp.h:61
@ LWS_CBOR_MAJTYP_MASK
Definition: lws-lecp.h:68
@ LWS_CBOR_1
Definition: lws-lecp.h:76
@ LWS_CBOR_SWK_FALSE
Definition: lws-lecp.h:89
@ LWS_CBOR_WKTAG_COSE_MAC0
Definition: lws-lecp.h:124
@ LWS_CBOR_2
Definition: lws-lecp.h:77
@ LWS_CBOR_RESERVED
Definition: lws-lecp.h:81
@ LWS_CBOR_WKTAG_MIME
Definition: lws-lecp.h:135
@ LWS_CBOR_SWK_UNDEFINED
Definition: lws-lecp.h:92
@ LWS_CBOR_MAJTYP_TAG
Definition: lws-lecp.h:65
@ LWS_CBOR_M7_SUBTYP_SIMPLE_X8
Definition: lws-lecp.h:94
@ LWS_CBOR_WKTAG_BIGNUM_NEGATIVE
Definition: lws-lecp.h:119
@ LWS_CBOR_INDETERMINITE
Definition: lws-lecp.h:110
@ LWS_CBOR_M7_SUBTYP_FLOAT32
Definition: lws-lecp.h:96
@ LWS_CBOR_MAJTYP_UINT
Definition: lws-lecp.h:59
@ LWS_CBOR_8
Definition: lws-lecp.h:79
@ LWS_CBOR_SWK_TRUE
Definition: lws-lecp.h:90
@ LWS_CBOR_WKTAG_SELFDESCCBOR
Definition: lws-lecp.h:141
@ LWS_CBOR_M7_SUBTYP_FLOAT16
Definition: lws-lecp.h:95
@ LWS_CBOR_MAJTYP_ARRAY
Definition: lws-lecp.h:63
@ LWS_CBOR_WKTAG_COSE_MAC
Definition: lws-lecp.h:138
@ LWS_CBOR_WKTAG_DATETIME_STD
Definition: lws-lecp.h:116
@ LWS_CBOR_WKTAG_CBOR
Definition: lws-lecp.h:130
@ LWS_CBOR_MAJTYP_TSTR
Definition: lws-lecp.h:62
@ LWS_CBOR_WKTAG_TO_B64
Definition: lws-lecp.h:128
@ LWS_CBOR_WKTAG_COSE_ENC0
Definition: lws-lecp.h:123
@ LWS_CBOR_WKTAG_B64
Definition: lws-lecp.h:134
@ LWS_CBOR_WKTAG_TO_B64U
Definition: lws-lecp.h:127
@ LWS_CBOR_WKTAG_DECIMAL_FRAC
Definition: lws-lecp.h:120
@ LWS_CBOR_MAJTYP_INT_NEG
Definition: lws-lecp.h:60
@ LWS_CBOR_WKTAG_DATETIME_EPOCH
Definition: lws-lecp.h:117
@ LWS_CBOR_MAJTYP_MAP
Definition: lws-lecp.h:64
@ LWS_CBOR_SWK_NULL
Definition: lws-lecp.h:91
@ LWS_CBOR_4
Definition: lws-lecp.h:78
@ LWS_CBOR_WKTAG_BIGNUM_UNSIGNED
Definition: lws-lecp.h:118
@ LWS_CBOR_WKTAG_COSE_SIGN1
Definition: lws-lecp.h:125
@ LWS_CBOR_WKTAG_TO_B16
Definition: lws-lecp.h:129
@ LWS_CBOR_MAJTYP_FLOAT
Definition: lws-lecp.h:66
@ LWS_CBOR_SUBMASK
Definition: lws-lecp.h:83
@ LWS_CBOR_WKTAG_B64U
Definition: lws-lecp.h:133
@ LWS_CBOR_WKTAG_BIGFLOAT
Definition: lws-lecp.h:121
@ LWS_CBOR_M7_SUBTYP_FLOAT64
Definition: lws-lecp.h:97
@ LWS_CBOR_WKTAG_COSE_ENC
Definition: lws-lecp.h:137
@ LWS_CBOR_WKTAG_URI
Definition: lws-lecp.h:132
@ LWS_CBOR_M7_BREAK
Definition: lws-lecp.h:98

◆ lecp_callbacks

Enumerator
LECPCB_CONSTRUCTED 
LECPCB_DESTRUCTED 
LECPCB_COMPLETE 
LECPCB_FAILED 
LECPCB_PAIR_NAME 
LECPCB_VAL_TRUE 
LECPCB_VAL_FALSE 
LECPCB_VAL_NULL 
LECPCB_VAL_NUM_INT 
LECPCB_VAL_RESERVED 
LECPCB_VAL_STR_START 
LECPCB_VAL_STR_CHUNK 
LECPCB_VAL_STR_END 
LECPCB_ARRAY_START 
LECPCB_ARRAY_END 
LECPCB_OBJECT_START 
LECPCB_OBJECT_END 
LECPCB_TAG_START 
LECPCB_TAG_END 
LECPCB_VAL_NUM_UINT 
LECPCB_VAL_UNDEFINED 
LECPCB_VAL_FLOAT16 
LECPCB_VAL_FLOAT32 
LECPCB_VAL_FLOAT64 
LECPCB_VAL_SIMPLE 
LECPCB_VAL_BLOB_START 
LECPCB_VAL_BLOB_CHUNK 
LECPCB_VAL_BLOB_END 
LECPCB_ARRAY_ITEM_START 
LECPCB_ARRAY_ITEM_END 
LECPCB_LITERAL_CBOR 

Definition at line 144 of file lws-lecp.h.

144  {
145  LECPCB_CONSTRUCTED = 0,
146  LECPCB_DESTRUCTED = 1,
147 
148  LECPCB_COMPLETE = 3,
149  LECPCB_FAILED = 4,
150 
151  LECPCB_PAIR_NAME = 5,
152 
158  LECPCB_VAL_STR_START = 11, /* notice handle separately */
161 
162  LECPCB_ARRAY_START = 14,
163  LECPCB_ARRAY_END = 15,
164 
165  LECPCB_OBJECT_START = 16,
166  LECPCB_OBJECT_END = 17,
167 
168  LECPCB_TAG_START = 18,
169  LECPCB_TAG_END = 19,
170 
176 
178 
179  LECPCB_VAL_BLOB_START = 26, /* notice handle separately */
182 
185 
186  LECPCB_LITERAL_CBOR = 31,
187 };
@ LECPCB_VAL_BLOB_CHUNK
Definition: lws-lecp.h:180
@ LECPCB_VAL_BLOB_END
Definition: lws-lecp.h:181
@ LECPCB_VAL_NUM_INT
Definition: lws-lecp.h:156
@ LECPCB_TAG_START
Definition: lws-lecp.h:168
@ LECPCB_VAL_FLOAT32
Definition: lws-lecp.h:174
@ LECPCB_CONSTRUCTED
Definition: lws-lecp.h:145
@ LECPCB_COMPLETE
Definition: lws-lecp.h:148
@ LECPCB_ARRAY_ITEM_START
Definition: lws-lecp.h:183
@ LECPCB_VAL_STR_CHUNK
Definition: lws-lecp.h:159
@ LECPCB_VAL_TRUE
Definition: lws-lecp.h:153
@ LECPCB_VAL_RESERVED
Definition: lws-lecp.h:157
@ LECPCB_VAL_BLOB_START
Definition: lws-lecp.h:179
@ LECPCB_OBJECT_START
Definition: lws-lecp.h:165
@ LECPCB_VAL_STR_START
Definition: lws-lecp.h:158
@ LECPCB_VAL_STR_END
Definition: lws-lecp.h:160
@ LECPCB_ARRAY_START
Definition: lws-lecp.h:162
@ LECPCB_VAL_NUM_UINT
Definition: lws-lecp.h:171
@ LECPCB_VAL_FLOAT16
Definition: lws-lecp.h:173
@ LECPCB_DESTRUCTED
Definition: lws-lecp.h:146
@ LECPCB_VAL_UNDEFINED
Definition: lws-lecp.h:172
@ LECPCB_ARRAY_ITEM_END
Definition: lws-lecp.h:184
@ LECPCB_VAL_FLOAT64
Definition: lws-lecp.h:175
@ LECPCB_FAILED
Definition: lws-lecp.h:149
@ LECPCB_LITERAL_CBOR
Definition: lws-lecp.h:186
@ LECPCB_PAIR_NAME
Definition: lws-lecp.h:151
@ LECPCB_OBJECT_END
Definition: lws-lecp.h:166
@ LECPCB_VAL_FALSE
Definition: lws-lecp.h:154
@ LECPCB_ARRAY_END
Definition: lws-lecp.h:163
@ LECPCB_VAL_NULL
Definition: lws-lecp.h:155
@ LECPCB_VAL_SIMPLE
Definition: lws-lecp.h:177
@ LECPCB_TAG_END
Definition: lws-lecp.h:169
#define LECP_FLAG_CB_IS_VALUE
Definition: lws-lecp.h:52

◆ lecp_reasons

Enumerator
LECP_CONTINUE 
LECP_REJECT_BAD_CODING 
LECP_REJECT_UNKNOWN 
LECP_REJECT_CALLBACK 
LECP_STACK_OVERFLOW 

Definition at line 189 of file lws-lecp.h.

189  {
190  LECP_CONTINUE = -1,
192  LECP_REJECT_UNKNOWN = -3,
194  LECP_STACK_OVERFLOW = -5,
195 };
@ LECP_REJECT_UNKNOWN
Definition: lws-lecp.h:192
@ LECP_CONTINUE
Definition: lws-lecp.h:190
@ LECP_REJECT_BAD_CODING
Definition: lws-lecp.h:191
@ LECP_STACK_OVERFLOW
Definition: lws-lecp.h:194
@ LECP_REJECT_CALLBACK
Definition: lws-lecp.h:193

◆ lws_lec_pctx_ret

Enumerator
LWS_LECPCTX_RET_FINISHED 
LWS_LECPCTX_RET_AGAIN 
LWS_LECPCTX_RET_FAIL 

Definition at line 303 of file lws-lecp.h.

303  {
305  LWS_LECPCTX_RET_AGAIN, /* call again to continue writing buffer */
306  LWS_LECPCTX_RET_FAIL /* something broken, eg, format string */
307 };
@ LWS_LECPCTX_RET_AGAIN
Definition: lws-lecp.h:305
@ LWS_LECPCTX_RET_FAIL
Definition: lws-lecp.h:306
@ LWS_LECPCTX_RET_FINISHED
Definition: lws-lecp.h:304

◆ cbp_state

enum cbp_state
Enumerator
CBPS_IDLE 
CBPS_PC1 
CBPS_PC2 
CBPS_PC3 
CBPS_STRING_BODY 
CBPS_NUM_LIT 
CBPS_STRING_LIT 
CBPS_CONTYPE 

Definition at line 309 of file lws-lecp.h.

309  {
310  CBPS_IDLE,
311  CBPS_PC1,
312  CBPS_PC2,
313  CBPS_PC3,
314 
316 
317  CBPS_NUM_LIT,
318 
320 
321  CBPS_CONTYPE,
322 };
@ CBPS_PC2
Definition: lws-lecp.h:312
@ CBPS_CONTYPE
Definition: lws-lecp.h:321
@ CBPS_STRING_BODY
Definition: lws-lecp.h:315
@ CBPS_NUM_LIT
Definition: lws-lecp.h:317
@ CBPS_STRING_LIT
Definition: lws-lecp.h:319
@ CBPS_PC3
Definition: lws-lecp.h:313
@ CBPS_PC1
Definition: lws-lecp.h:311
@ CBPS_IDLE
Definition: lws-lecp.h:310

Function Documentation

◆ lws_lec_int()

LWS_VISIBLE LWS_EXTERN void lws_lec_int ( lws_lec_pctx_t ctx,
uint8_t  opcode,
uint8_t  indet,
uint64_t  num 
)

◆ lws_lec_scratch()

LWS_VISIBLE LWS_EXTERN int lws_lec_scratch ( lws_lec_pctx_t ctx)

◆ lws_lec_init()

LWS_VISIBLE LWS_EXTERN void lws_lec_init ( lws_lec_pctx_t ctx,
uint8_t buf,
size_t  len 
)

◆ lws_lec_setbuf()

LWS_VISIBLE LWS_EXTERN void lws_lec_setbuf ( lws_lec_pctx_t ctx,
uint8_t buf,
size_t  len 
)

◆ lws_lec_vsprintf()

LWS_VISIBLE LWS_EXTERN enum lws_lec_pctx_ret lws_lec_vsprintf ( lws_lec_pctx_t ctx,
const char *  format,
va_list  args 
)

◆ lws_lec_printf()

LWS_VISIBLE LWS_EXTERN enum lws_lec_pctx_ret lws_lec_printf ( lws_lec_pctx_t ctx,
const char *  format,
  ... 
)

◆ lecp_construct()

LWS_VISIBLE LWS_EXTERN void lecp_construct ( struct lecp_ctx ctx,
lecp_callback  cb,
void *  user,
const char *const *  paths,
unsigned char  paths_count 
)

lecp_construct() - Construct an LECP parser context

Parameters
ctxthe parser context object to be initialized
cbthe user callback to receive the parsing events
useran opaque user pointer available at cb
pathsan optional array of parsing paths
paths_counthow many paths in paths

Prepares an LECP parser context for parsing.

◆ lecp_destruct()

LWS_VISIBLE LWS_EXTERN void lecp_destruct ( struct lecp_ctx ctx)

lecp_destruct() - Destroys an LECP parser context

Parameters
ctxthe parser context object to be destroyed

◆ lecp_parse()

LWS_VISIBLE LWS_EXTERN int lecp_parse ( struct lecp_ctx ctx,
const uint8_t cbor,
size_t  len 
)

lecp_parse() - parses a chunk of input CBOR

ctx: the parsing context cbor: the start of the chunk of CBOR len: the number of bytes of CBOR available at cbor

Returns LECP_CONTINUE if more input needed, one of enum lecp_reasons for a fatal error, else 0 for successful parsing completion.

On success or _CONTINUE, ctx->used_in is set to the number of input bytes consumed.

◆ lecp_change_callback()

LWS_VISIBLE LWS_EXTERN void lecp_change_callback ( struct lecp_ctx ctx,
lecp_callback  cb 
)

◆ lecp_error_to_string()

LWS_VISIBLE LWS_EXTERN const char* lecp_error_to_string ( int  e)

◆ lecp_parse_report_raw()

LWS_VISIBLE LWS_EXTERN void lecp_parse_report_raw ( struct lecp_ctx ctx,
int  on 
)

lecp_parse_report_raw() - turn cbor raw reporting on and off

Parameters
ctxthe lecp context
on0 to disable (defaults disabled), 1 to enable

For cose_sign, it needs access to raw cbor subtrees for the hash input. This api causes LECPCB_LITERAL_CBOR parse callbacks when there are ctx->cbor_pos bytes of raw cbor available in ctx->cbor[]. the callbacks occur when the ctx->cbor[] buffer fills or if it holds anything when this spi is used to stop the reports.

The same CBOR that is being captured continues to be passed for parsing.

◆ lecp_parse_map_is_key()

LWS_VISIBLE LWS_EXTERN int lecp_parse_map_is_key ( struct lecp_ctx ctx)

lecp_parse_map_is_key() - return nonzero if we're in a map and this is a key

Parameters
ctxthe lwcp context

Checks if the current value is a key in a map, ie, that you are on a "key" in a list of "{key: value}" pairs. Zero means you're either not in a map or not on the key part, and nonzero means you are in a map and on a key part.

◆ lecp_parse_subtree()

LWS_VISIBLE LWS_EXTERN int lecp_parse_subtree ( struct lecp_ctx ctx,
const uint8_t in,
size_t  len 
)

◆ lws_singles2halfp()

LWS_VISIBLE LWS_EXTERN void lws_singles2halfp ( uint16_t hp,
uint32_t  x 
)

◆ lws_halfp2singles()

LWS_VISIBLE LWS_EXTERN void lws_halfp2singles ( uint32_t xp,
uint16_t  h 
)