Lines Matching refs:ctx
55 lecp_construct(struct lecp_ctx *ctx, lecp_callback cb, void *user, in lecp_construct() argument
60 memset(ctx, 0, sizeof(*ctx) - sizeof(ctx->buf)); in lecp_construct()
62 ctx->user = user; in lecp_construct()
63 ctx->pst[0].cb = cb; in lecp_construct()
64 ctx->pst[0].paths = paths; in lecp_construct()
65 ctx->pst[0].count_paths = count_paths; in lecp_construct()
66 ctx->be = *((uint8_t *)&x) == 0x12; in lecp_construct()
68 ctx->st[0].s = LECP_OPC; in lecp_construct()
70 ctx->pst[0].cb(ctx, LECPCB_CONSTRUCTED); in lecp_construct()
74 lecp_destruct(struct lecp_ctx *ctx) in lecp_destruct() argument
77 if (ctx->pst[0].cb) in lecp_destruct()
78 ctx->pst[0].cb(ctx, LECPCB_DESTRUCTED); in lecp_destruct()
82 lecp_change_callback(struct lecp_ctx *ctx, lecp_callback cb) in lecp_change_callback() argument
84 ctx->pst[0].cb(ctx, LECPCB_DESTRUCTED); in lecp_change_callback()
85 ctx->pst[0].cb = cb; in lecp_change_callback()
86 ctx->pst[0].cb(ctx, LECPCB_CONSTRUCTED); in lecp_change_callback()
105 ex(struct lecp_ctx *ctx, void *_start, size_t len) in ex() argument
107 struct _lecp_stack *st = &ctx->st[ctx->sp]; in ex()
113 if (ctx->be) in ex()
114 ctx->collect_tgt = start; in ex()
116 ctx->collect_tgt = start + len - 1; in ex()
120 lecp_check_path_match(struct lecp_ctx *ctx) in lecp_check_path_match() argument
126 if (ctx->path_stride) in lecp_check_path_match()
127 s = ctx->path_stride; in lecp_check_path_match()
130 for (n = 0; !ctx->path_match && in lecp_check_path_match()
131 n < ctx->pst[ctx->pst_sp].count_paths; n++) { in lecp_check_path_match()
132 ctx->wildcount = 0; in lecp_check_path_match()
133 p = ctx->path; in lecp_check_path_match()
135 q = *((char **)(((char *)ctx->pst[ctx->pst_sp].paths) + in lecp_check_path_match()
146 ctx->wild[ctx->wildcount++] = in lecp_check_path_match()
147 (uint16_t)lws_ptr_diff_size_t(p, ctx->path); in lecp_check_path_match()
163 ctx->path_match = (uint8_t)(n + 1); in lecp_check_path_match()
164 ctx->path_match_len = ctx->pst[ctx->pst_sp].ppos; in lecp_check_path_match()
168 if (!ctx->path_match) in lecp_check_path_match()
169 ctx->wildcount = 0; in lecp_check_path_match()
173 lecp_push(struct lecp_ctx *ctx, char s_start, char s_end, char state) in lecp_push() argument
175 struct _lecp_stack *st = &ctx->st[ctx->sp]; in lecp_push()
177 if (ctx->sp + 1 == LWS_ARRAY_SIZE(ctx->st)) in lecp_push()
180 if (s_start && ctx->pst[ctx->pst_sp].cb(ctx, s_start)) in lecp_push()
185 __func__, ctx->sp, st->opcode >> 5, st->indet, in lecp_push()
190 ctx->st[ctx->sp + 1] = *st; in lecp_push()
191 ctx->sp++; in lecp_push()
206 lecp_pop(struct lecp_ctx *ctx) in lecp_pop() argument
210 assert(ctx->sp); in lecp_pop()
211 ctx->sp--; in lecp_pop()
213 st = &ctx->st[ctx->sp]; in lecp_pop()
216 assert(ctx->ipos); in lecp_pop()
217 ctx->ipos--; in lecp_pop()
220 ctx->pst[ctx->pst_sp].ppos = st->p; in lecp_pop()
221 ctx->path[st->p] = '\0'; in lecp_pop()
222 lecp_check_path_match(ctx); in lecp_pop()
226 __func__, ctx->sp, st->opcode >> 5, st->indet, in lecp_pop()
229 if (st->pop_iss && ctx->pst[ctx->pst_sp].cb(ctx, st->pop_iss)) in lecp_pop()
236 lwcp_st_parent(struct lecp_ctx *ctx) in lwcp_st_parent() argument
238 assert(ctx->sp); in lwcp_st_parent()
240 return &ctx->st[ctx->sp - 1]; in lwcp_st_parent()
244 lwcp_completed(struct lecp_ctx *ctx, char indet) in lwcp_completed() argument
246 int r, il = ctx->ipos; in lwcp_completed()
248 ctx->st[ctx->sp].s = LECP_OPC; in lwcp_completed()
250 while (ctx->sp && !ctx->st[ctx->sp].barrier) { in lwcp_completed()
251 struct _lecp_stack *parent = lwcp_st_parent(ctx); in lwcp_completed()
255 __func__, ctx->sp, parent->opcode >> 5, parent->indet, in lwcp_completed()
262 ctx->i[il]++; in lwcp_completed()
264 if (ctx->pst[ctx->pst_sp].cb(ctx, in lwcp_completed()
279 __func__, ctx->sp, parent->opcode >> 5, parent->indet, (int)parent->collect_rem); in lwcp_completed()
291 ctx->st[ctx->sp - 1].s = LECP_OPC; in lwcp_completed()
292 r = lecp_pop(ctx); in lwcp_completed()
302 lwcp_is_indet_string(struct lecp_ctx *ctx) in lwcp_is_indet_string() argument
304 if (ctx->st[ctx->sp].indet) in lwcp_is_indet_string()
307 if (!ctx->sp) in lwcp_is_indet_string()
310 if (lwcp_st_parent(ctx)->opcode != LWS_CBOR_MAJTYP_BSTR && in lwcp_is_indet_string()
311 lwcp_st_parent(ctx)->opcode != LWS_CBOR_MAJTYP_TSTR) in lwcp_is_indet_string()
314 if (ctx->st[ctx->sp - 1].indet) in lwcp_is_indet_string()
321 report_raw_cbor(struct lecp_ctx *ctx) in report_raw_cbor() argument
323 struct _lecp_parsing_stack *pst = &ctx->pst[ctx->pst_sp]; in report_raw_cbor()
325 if (!ctx->cbor_pos) in report_raw_cbor()
328 if (pst->cb(ctx, LECPCB_LITERAL_CBOR)) in report_raw_cbor()
331 ctx->cbor_pos = 0; in report_raw_cbor()
337 lecp_parse_report_raw(struct lecp_ctx *ctx, int on) in lecp_parse_report_raw() argument
339 ctx->literal_cbor_report = (uint8_t)on; in lecp_parse_report_raw()
340 report_raw_cbor(ctx); in lecp_parse_report_raw()
344 lecp_parse_map_is_key(struct lecp_ctx *ctx) in lecp_parse_map_is_key() argument
346 return lwcp_st_parent(ctx)->opcode == LWS_CBOR_MAJTYP_MAP && in lecp_parse_map_is_key()
347 !(lwcp_st_parent(ctx)->ordinal & 1); in lecp_parse_map_is_key()
351 lecp_parse_subtree(struct lecp_ctx *ctx, const uint8_t *in, size_t len) in lecp_parse_subtree() argument
353 struct _lecp_stack *st = &ctx->st[++ctx->sp]; in lecp_parse_subtree()
364 n = lecp_parse(ctx, in, len); in lecp_parse_subtree()
365 ctx->sp--; in lecp_parse_subtree()
371 lecp_parse(struct lecp_ctx *ctx, const uint8_t *cbor, size_t len) in lecp_parse() argument
377 struct _lecp_parsing_stack *pst = &ctx->pst[ctx->pst_sp]; in lecp_parse()
378 struct _lecp_stack *st = &ctx->st[ctx->sp]; in lecp_parse()
390 if (ctx->literal_cbor_report) { in lecp_parse()
391 ctx->cbor[ctx->cbor_pos++] = c; in lecp_parse()
392 if (ctx->cbor_pos == sizeof(ctx->cbor) && in lecp_parse()
393 report_raw_cbor(ctx)) in lecp_parse()
402 st->opcode = ctx->item.opcode = c & LWS_CBOR_MAJTYP_MASK; in lecp_parse()
406 lwsl_lecp("%s: %d: OPC %d|%d\n", __func__, ctx->sp, in lecp_parse()
409 if (c != 0xff && ctx->sp && in lecp_parse()
410 ctx->st[ctx->sp - 1].send_new_array_item) { in lecp_parse()
411 ctx->st[ctx->sp - 1].send_new_array_item = 0; in lecp_parse()
412 if (ctx->pst[ctx->pst_sp].cb(ctx, in lecp_parse()
419 ctx->present = LECPCB_VAL_NUM_UINT; in lecp_parse()
421 ctx->item.u.i64 = (int64_t)sm; in lecp_parse()
427 ctx->present = LECPCB_VAL_NUM_INT; in lecp_parse()
429 ctx->item.u.i64 = (-1ll) - (int64_t)sm; in lecp_parse()
435 ctx->item.u.u64 = 0; in lecp_parse()
437 ex(ctx, (uint8_t *)&ctx->item.u.u64, o); in lecp_parse()
454 ctx->npos = 0; in lecp_parse()
455 ctx->buf[0] = '\0'; in lecp_parse()
458 if ((!ctx->sp || (ctx->sp && in lecp_parse()
459 !ctx->st[ctx->sp - 1].intermediate)) && in lecp_parse()
460 pst->cb(ctx, (char)(LECPCB_VAL_STR_START + to))) in lecp_parse()
463 if (pst->cb(ctx, (char)(LECPCB_VAL_STR_END + to))) in lecp_parse()
465 lwcp_completed(ctx, 0); in lecp_parse()
470 ctx->item.u.u64 = (uint64_t)sm; in lecp_parse()
471 if ((!ctx->sp || (ctx->sp && in lecp_parse()
472 !ctx->st[ctx->sp - 1].intermediate)) && in lecp_parse()
473 pst->cb(ctx, (char)(LECPCB_VAL_STR_START + to))) in lecp_parse()
488 if ((!ctx->sp || (ctx->sp && in lecp_parse()
489 !ctx->st[ctx->sp - 1].intermediate)) && in lecp_parse()
490 pst->cb(ctx, (char)(LECPCB_VAL_STR_START + to))) in lecp_parse()
496 lecp_push(ctx, 0, (char)(LECPCB_VAL_STR_END + to), in lecp_parse()
501 ctx->npos = 0; in lecp_parse()
502 ctx->buf[0] = '\0'; in lecp_parse()
504 if (pst->ppos + 3u >= sizeof(ctx->path)) in lecp_parse()
508 ctx->path[pst->ppos++] = '['; in lecp_parse()
509 ctx->path[pst->ppos++] = ']'; in lecp_parse()
510 ctx->path[pst->ppos] = '\0'; in lecp_parse()
512 lecp_check_path_match(ctx); in lecp_parse()
514 if (ctx->ipos + 1u >= LWS_ARRAY_SIZE(ctx->i)) in lecp_parse()
517 ctx->i[ctx->ipos++] = 0; in lecp_parse()
519 if (pst->cb(ctx, LECPCB_ARRAY_START)) in lecp_parse()
523 if (pst->cb(ctx, LECPCB_ARRAY_END)) in lecp_parse()
526 ctx->path[pst->ppos] = '\0'; in lecp_parse()
527 ctx->ipos--; in lecp_parse()
528 lecp_check_path_match(ctx); in lecp_parse()
529 lwcp_completed(ctx, 0); in lecp_parse()
533 ctx->st[ctx->sp].send_new_array_item = 1; in lecp_parse()
549 lecp_push(ctx, 0, LECPCB_ARRAY_END, LECP_OPC); in lecp_parse()
553 ctx->npos = 0; in lecp_parse()
554 ctx->buf[0] = '\0'; in lecp_parse()
556 if (pst->ppos + 1u >= sizeof(ctx->path)) in lecp_parse()
560 ctx->path[pst->ppos++] = '.'; in lecp_parse()
561 ctx->path[pst->ppos] = '\0'; in lecp_parse()
563 lecp_check_path_match(ctx); in lecp_parse()
565 if (pst->cb(ctx, LECPCB_OBJECT_START)) in lecp_parse()
569 if (pst->cb(ctx, LECPCB_OBJECT_END)) in lecp_parse()
572 ctx->path[pst->ppos] = '\0'; in lecp_parse()
573 lecp_check_path_match(ctx); in lecp_parse()
574 lwcp_completed(ctx, 0); in lecp_parse()
591 lecp_push(ctx, 0, LECPCB_OBJECT_END, LECP_OPC); in lecp_parse()
601 ctx->item.u.u64 = st->tag = (uint64_t)sm; in lecp_parse()
619 ctx->present = LECPCB_VAL_FALSE; in lecp_parse()
623 ctx->present = LECPCB_VAL_TRUE; in lecp_parse()
627 ctx->present = LECPCB_VAL_NULL; in lecp_parse()
631 ctx->present = LECPCB_VAL_UNDEFINED; in lecp_parse()
639 ctx->present = LECPCB_VAL_FLOAT16; in lecp_parse()
640 ex(ctx, &ctx->item.u.hf, 2); in lecp_parse()
644 ctx->present = LECPCB_VAL_FLOAT32; in lecp_parse()
645 ex(ctx, &ctx->item.u.f, 4); in lecp_parse()
649 ctx->present = LECPCB_VAL_FLOAT64; in lecp_parse()
650 ex(ctx, &ctx->item.u.d, 8); in lecp_parse()
654 if (!ctx->sp || in lecp_parse()
655 !ctx->st[ctx->sp - 1].indet) in lecp_parse()
658 lwcp_completed(ctx, 1); in lecp_parse()
663 ctx->item.u.u64 = (uint64_t)sm; in lecp_parse()
664 if (pst->cb(ctx, LECPCB_VAL_SIMPLE)) in lecp_parse()
676 if (ctx->be) in lecp_parse()
677 *ctx->collect_tgt++ = c; in lecp_parse()
679 *ctx->collect_tgt-- = c; in lecp_parse()
688 ctx->npos = 0; in lecp_parse()
689 ctx->buf[0] = '\0'; in lecp_parse()
694 st->collect_rem = ctx->item.u.u64; in lecp_parse()
695 if ((!ctx->sp || (ctx->sp && in lecp_parse()
696 !ctx->st[ctx->sp - 1].intermediate)) && in lecp_parse()
697 pst->cb(ctx, (char)((st->opcode == in lecp_parse()
706 st->collect_rem = ctx->item.u.u64; in lecp_parse()
707 lecp_push(ctx, 0, LECPCB_ARRAY_END, LECP_OPC); in lecp_parse()
711 st->collect_rem = ctx->item.u.u64 * 2; in lecp_parse()
712 lecp_push(ctx, 0, LECPCB_OBJECT_END, LECP_OPC); in lecp_parse()
716 st->tag = ctx->item.u.u64; in lecp_parse()
726 ctx->item.u.i64 = (-1ll) - ctx->item.u.i64; in lecp_parse()
744 ctx->item.u.u64 = (uint64_t)c; in lecp_parse()
745 if (pst->cb(ctx, LECPCB_VAL_SIMPLE)) in lecp_parse()
748 lwcp_completed(ctx, 0); in lecp_parse()
757 ctx->buf[ctx->npos++] = (char)c; in lecp_parse()
762 if (ctx->npos != sizeof(ctx->buf) - 1 && in lecp_parse()
767 ctx->buf[ctx->npos] = '\0'; in lecp_parse()
770 if (ctx->sp && lecp_parse_map_is_key(ctx)) { in lecp_parse()
771 if (lwcp_st_parent(ctx)->ordinal) in lecp_parse()
774 if (pst->ppos + ctx->npos > sizeof(ctx->path)) in lecp_parse()
776 memcpy(&ctx->path[pst->ppos], ctx->buf, in lecp_parse()
777 (size_t)(ctx->npos + 1)); in lecp_parse()
778 pst->ppos = (uint8_t)(pst->ppos + ctx->npos); in lecp_parse()
779 lecp_check_path_match(ctx); in lecp_parse()
783 if (ctx->item.opcode == LWS_CBOR_MAJTYP_BSTR) in lecp_parse()
789 lwcp_is_indet_string(ctx)); in lecp_parse()
791 if (ctx->sp) in lecp_parse()
792 ctx->st[ctx->sp - 1].intermediate = !!c; in lecp_parse()
796 if (pst->cb(ctx, (char)o)) in lecp_parse()
798 ctx->npos = 0; in lecp_parse()
799 ctx->buf[0] = '\0'; in lecp_parse()
801 if (ctx->sp && lwcp_st_parent(ctx)->indet) in lecp_parse()
804 lwcp_completed(ctx, 0); in lecp_parse()
816 if (!ctx->sp) { in lecp_parse()
826 if (!ctx->sp || !ctx->st[ctx->sp - 1].indet) in lecp_parse()
833 if (lwcp_completed(ctx, 1)) in lecp_parse()
838 if (st->opcode != lwcp_st_parent(ctx)->opcode) in lecp_parse()
872 ret = lecp_push(ctx, LECPCB_TAG_START, LECPCB_TAG_END, LECP_OPC); in lecp_parse()
879 if (ctx->item.opcode == LWS_CBOR_MAJTYP_TAG) { in lecp_parse()
880 st->tag = ctx->item.u.u64; in lecp_parse()
886 if (pst->cb(ctx, ctx->present)) in lecp_parse()
889 lwcp_completed(ctx, 0); in lecp_parse()
893 ctx->used_in = olen - len; in lecp_parse()
895 if (!ctx->sp && ctx->st[0].s == LECP_OPC) in lecp_parse()
912 ctx->pst[ctx->pst_sp].cb(ctx, LECPCB_FAILED); in lecp_parse()
920 lws_lec_init(lws_lec_pctx_t *ctx, uint8_t *buf, size_t len) in lws_lec_init() argument
922 memset(ctx, 0, sizeof(*ctx)); in lws_lec_init()
923 ctx->start = ctx->buf = buf; in lws_lec_init()
924 ctx->end = ctx->start + len; in lws_lec_init()
925 ctx->fmt_pos = 0; in lws_lec_init()
929 lws_lec_setbuf(lws_lec_pctx_t *ctx, uint8_t *buf, size_t len) in lws_lec_setbuf() argument
931 ctx->start = ctx->buf = buf; in lws_lec_setbuf()
932 ctx->end = ctx->start + len; in lws_lec_setbuf()
933 ctx->used = 0; in lws_lec_setbuf()
934 ctx->vaa_pos = 0; in lws_lec_setbuf()
938 lws_lec_printf(lws_lec_pctx_t *ctx, const char *format, ...) in lws_lec_printf() argument
944 r = lws_lec_vsprintf(ctx, format, ap); in lws_lec_printf()
1152 lws_lec_signed(lws_lec_pctx_t *ctx, int64_t num) in lws_lec_signed() argument
1155 lws_lec_int(ctx, LWS_CBOR_MAJTYP_INT_NEG, 0, in lws_lec_signed()
1158 lws_lec_int(ctx, LWS_CBOR_MAJTYP_UINT, 0, (uint64_t)num); in lws_lec_signed()
1162 lws_lec_int(lws_lec_pctx_t *ctx, uint8_t opcode, uint8_t indet, uint64_t num) in lws_lec_int() argument
1168 ctx->scratch[ctx->scratch_len++] = (uint8_t)(opcode | in lws_lec_int()
1186 ctx->scratch[ctx->scratch_len++] = (uint8_t)(opcode | num); in lws_lec_int()
1206 ctx->scratch[ctx->scratch_len++] = (uint8_t)(opcode | hint); in lws_lec_int()
1209 ctx->scratch[ctx->scratch_len++] = (uint8_t)(num >> 56); in lws_lec_int()
1223 lws_lec_scratch(lws_lec_pctx_t *ctx) in lws_lec_scratch() argument
1227 if (!ctx->scratch_len) in lws_lec_scratch()
1230 s = lws_ptr_diff_size_t(ctx->end, ctx->buf); in lws_lec_scratch()
1231 if (s > (size_t)ctx->scratch_len) in lws_lec_scratch()
1232 s = (size_t)ctx->scratch_len; in lws_lec_scratch()
1234 memcpy(ctx->buf, ctx->scratch, s); in lws_lec_scratch()
1235 ctx->buf += s; in lws_lec_scratch()
1236 ctx->scratch_len = (uint8_t)(ctx->scratch_len - (uint8_t)s); in lws_lec_scratch()
1238 return ctx->buf == ctx->end; in lws_lec_scratch()
1242 lws_lec_vsprintf(lws_lec_pctx_t *ctx, const char *fmt, va_list args) in lws_lec_vsprintf() argument
1261 for (n = 0; n < ctx->vaa_pos; n++) { in lws_lec_vsprintf()
1263 switch (ctx->vaa[n]) { in lws_lec_vsprintf()
1280 if (ctx->state == CBPS_STRING_BODY) in lws_lec_vsprintf()
1288 ctx->ongoing_src = va_arg(args, uint8_t *); in lws_lec_vsprintf()
1291 while (ctx->buf != ctx->end) { in lws_lec_vsprintf()
1304 if (lws_lec_scratch(ctx)) in lws_lec_vsprintf()
1307 if (ctx->fmt_pos >= fl) { in lws_lec_vsprintf()
1308 if (ctx->state == CBPS_IDLE) in lws_lec_vsprintf()
1312 c = fmt[ctx->fmt_pos]; in lws_lec_vsprintf()
1316 switch (ctx->state) { in lws_lec_vsprintf()
1318 ctx->scratch_len = 0; in lws_lec_vsprintf()
1321 n = format_scan(&fmt[ctx->fmt_pos]); in lws_lec_vsprintf()
1324 lws_lec_int(ctx, LWS_CBOR_MAJTYP_ARRAY, n == -1, in lws_lec_vsprintf()
1328 n = format_scan(&fmt[ctx->fmt_pos]); in lws_lec_vsprintf()
1331 lws_lec_int(ctx, LWS_CBOR_MAJTYP_MAP, n == -1, in lws_lec_vsprintf()
1339 ctx->state = CBPS_CONTYPE; in lws_lec_vsprintf()
1343 if (!ctx->sp || ctx->stack[ctx->sp - 1] != '[') in lws_lec_vsprintf()
1345 ctx->sp--; in lws_lec_vsprintf()
1348 if (!ctx->sp || ctx->stack[ctx->sp - 1] != '{') in lws_lec_vsprintf()
1350 ctx->sp--; in lws_lec_vsprintf()
1353 if (!ctx->sp || ctx->stack[ctx->sp - 1] != '(') { in lws_lec_vsprintf()
1355 ctx->sp, ctx->stack[ctx->sp - 1]); in lws_lec_vsprintf()
1358 ctx->sp--; in lws_lec_vsprintf()
1361 if (!ctx->sp || ctx->stack[ctx->sp - 1] != '<') in lws_lec_vsprintf()
1363 ctx->scratch[ctx->scratch_len++] = in lws_lec_vsprintf()
1366 ctx->sp--; in lws_lec_vsprintf()
1369 n = format_scan(&fmt[ctx->fmt_pos]); in lws_lec_vsprintf()
1373 lws_lec_int(ctx, LWS_CBOR_MAJTYP_TSTR, 0, in lws_lec_vsprintf()
1375 ctx->state = CBPS_STRING_LIT; in lws_lec_vsprintf()
1378 if (ctx->vaa_pos >= sizeof(ctx->vaa) - 1) { in lws_lec_vsprintf()
1382 ctx->_long = 0; in lws_lec_vsprintf()
1383 ctx->dotstar = 0; in lws_lec_vsprintf()
1384 ctx->state = CBPS_PC1; in lws_lec_vsprintf()
1391 ctx->item.opcode = LWS_CBOR_MAJTYP_INT_NEG; in lws_lec_vsprintf()
1392 ctx->item.u.i64 = 0; in lws_lec_vsprintf()
1393 ctx->state = CBPS_NUM_LIT; in lws_lec_vsprintf()
1405 ctx->item.opcode = LWS_CBOR_MAJTYP_UINT; in lws_lec_vsprintf()
1406 ctx->item.u.u64 = (uint64_t)(c - '0'); in lws_lec_vsprintf()
1407 ctx->state = CBPS_NUM_LIT; in lws_lec_vsprintf()
1413 ctx->_long++; in lws_lec_vsprintf()
1414 ctx->state = CBPS_PC2; in lws_lec_vsprintf()
1418 ctx->dotstar++; in lws_lec_vsprintf()
1419 ctx->state = CBPS_PC2; in lws_lec_vsprintf()
1426 ctx->_long++; in lws_lec_vsprintf()
1427 ctx->state = CBPS_PC3; in lws_lec_vsprintf()
1431 ctx->dotstar++; in lws_lec_vsprintf()
1432 ctx->state = CBPS_PC3; in lws_lec_vsprintf()
1440 switch (ctx->_long) { in lws_lec_vsprintf()
1443 ctx->vaa[ctx->vaa_pos++] = NATTYPE_INT; in lws_lec_vsprintf()
1447 ctx->vaa[ctx->vaa_pos++] = NATTYPE_LONG; in lws_lec_vsprintf()
1451 ctx->vaa[ctx->vaa_pos++] = NATTYPE_LONG_LONG; in lws_lec_vsprintf()
1455 lws_lec_int(ctx, in lws_lec_vsprintf()
1459 lws_lec_int(ctx, in lws_lec_vsprintf()
1464 switch (ctx->_long) { in lws_lec_vsprintf()
1467 ctx->vaa[ctx->vaa_pos++] = NATTYPE_INT; in lws_lec_vsprintf()
1471 ctx->vaa[ctx->vaa_pos++] = NATTYPE_LONG; in lws_lec_vsprintf()
1475 ctx->vaa[ctx->vaa_pos++] = NATTYPE_LONG_LONG; in lws_lec_vsprintf()
1478 lws_lec_int(ctx, LWS_CBOR_MAJTYP_UINT, 0, u64); in lws_lec_vsprintf()
1481 ctx->ongoing_done = 0; in lws_lec_vsprintf()
1482 if (ctx->dotstar == 2) { in lws_lec_vsprintf()
1483 ctx->ongoing_len = (uint64_t)va_arg(args, int); in lws_lec_vsprintf()
1484 ctx->vaa[ctx->vaa_pos++] = NATTYPE_INT; in lws_lec_vsprintf()
1487 ctx->ongoing_src = va_arg(args, uint8_t *); in lws_lec_vsprintf()
1488 if (ctx->dotstar != 2) in lws_lec_vsprintf()
1489 ctx->ongoing_len = (uint64_t)strlen( in lws_lec_vsprintf()
1490 (const char *)ctx->ongoing_src); in lws_lec_vsprintf()
1491 lws_lec_int(ctx, LWS_CBOR_MAJTYP_TSTR, 0, ctx->ongoing_len); in lws_lec_vsprintf()
1492 ctx->state = CBPS_STRING_BODY; in lws_lec_vsprintf()
1493 ctx->fmt_pos++; in lws_lec_vsprintf()
1496 if (ctx->dotstar != 2) in lws_lec_vsprintf()
1498 ctx->vaa[ctx->vaa_pos++] = NATTYPE_INT; in lws_lec_vsprintf()
1499 ctx->ongoing_done = 0; in lws_lec_vsprintf()
1500 ctx->ongoing_len = (uint64_t)va_arg(args, int); in lws_lec_vsprintf()
1502 ctx->ongoing_src = va_arg(args, uint8_t *); in lws_lec_vsprintf()
1503 lws_lec_int(ctx, LWS_CBOR_MAJTYP_BSTR, 0, ctx->ongoing_len); in lws_lec_vsprintf()
1504 ctx->state = CBPS_STRING_BODY; in lws_lec_vsprintf()
1505 ctx->fmt_pos++; in lws_lec_vsprintf()
1508 switch (ctx->_long) { in lws_lec_vsprintf()
1510 ctx->item.u.u64 = (uint64_t)va_arg(args, int); in lws_lec_vsprintf()
1511 ctx->vaa[ctx->vaa_pos++] = NATTYPE_INT; in lws_lec_vsprintf()
1514 ctx->item.u.u64 = (uint64_t)va_arg(args, long); in lws_lec_vsprintf()
1515 ctx->vaa[ctx->vaa_pos++] = NATTYPE_LONG; in lws_lec_vsprintf()
1518 ctx->item.u.u64 = (uint64_t)va_arg(args, long long); in lws_lec_vsprintf()
1519 ctx->vaa[ctx->vaa_pos++] = NATTYPE_LONG_LONG; in lws_lec_vsprintf()
1522 ctx->item.opcode = LWS_CBOR_MAJTYP_UINT; in lws_lec_vsprintf()
1523 ctx->fmt_pos++; in lws_lec_vsprintf()
1524 if (ctx->fmt_pos >= fl) in lws_lec_vsprintf()
1526 c = fmt[ctx->fmt_pos]; in lws_lec_vsprintf()
1548 lws_lec_int(ctx, in lws_lec_vsprintf()
1555 lws_lec_int(ctx, in lws_lec_vsprintf()
1571 lws_lec_int(ctx, in lws_lec_vsprintf()
1583 ctx->state = CBPS_IDLE; in lws_lec_vsprintf()
1587 s = lws_ptr_diff_size_t(ctx->end, ctx->buf); in lws_lec_vsprintf()
1588 if (s > (size_t)(ctx->ongoing_len - ctx->ongoing_done)) in lws_lec_vsprintf()
1589 s = (size_t)(ctx->ongoing_len - ctx->ongoing_done); in lws_lec_vsprintf()
1590 memcpy(ctx->buf, ctx->ongoing_src + ctx->ongoing_done, s); in lws_lec_vsprintf()
1591 ctx->buf += s; in lws_lec_vsprintf()
1592 ctx->ongoing_done += s; in lws_lec_vsprintf()
1593 if (ctx->ongoing_len == ctx->ongoing_done) { in lws_lec_vsprintf()
1595 ctx->vaa[ctx->vaa_pos++] = NATTYPE_PTR; in lws_lec_vsprintf()
1596 ctx->state = CBPS_IDLE; in lws_lec_vsprintf()
1602 ctx->item.u.u64 = (ctx->item.u.u64 * 10) + in lws_lec_vsprintf()
1607 if (ctx->item.opcode == LWS_CBOR_MAJTYP_INT_NEG) in lws_lec_vsprintf()
1608 ctx->item.u.i64--; in lws_lec_vsprintf()
1612 n = format_scan(&fmt[ctx->fmt_pos]); in lws_lec_vsprintf()
1621 lws_lec_int(ctx, LWS_CBOR_MAJTYP_TAG, 0, in lws_lec_vsprintf()
1622 ctx->item.u.u64); in lws_lec_vsprintf()
1625 if (ctx->sp >= sizeof(ctx->stack)) in lws_lec_vsprintf()
1627 ctx->stack[ctx->sp] = (uint8_t)c; in lws_lec_vsprintf()
1628 ctx->indet[ctx->sp++] = (uint8_t)(n == -1); in lws_lec_vsprintf()
1630 ctx->state = CBPS_IDLE; in lws_lec_vsprintf()
1634 lws_lec_int(ctx, ctx->item.opcode, 0, ctx->item.u.u64); in lws_lec_vsprintf()
1636 ctx->state = CBPS_IDLE; in lws_lec_vsprintf()
1641 if (!ctx->escflag && c == '\\') { in lws_lec_vsprintf()
1642 ctx->escflag = 1; in lws_lec_vsprintf()
1645 if (!ctx->escflag && c == '\'') { in lws_lec_vsprintf()
1646 ctx->state = CBPS_IDLE; in lws_lec_vsprintf()
1650 *ctx->buf++ = (uint8_t)c; in lws_lec_vsprintf()
1651 ctx->escflag = 0; in lws_lec_vsprintf()
1659 lws_lec_int(ctx, c == 't' ? LWS_CBOR_MAJTYP_TSTR : in lws_lec_vsprintf()
1666 ctx->fmt_pos++; in lws_lec_vsprintf()
1669 ctx->used = lws_ptr_diff_size_t(ctx->buf, ctx->start); in lws_lec_vsprintf()
1672 if (ctx->buf == ctx->end || ctx->scratch_len) in lws_lec_vsprintf()
1675 ctx->fmt_pos = 0; in lws_lec_vsprintf()
1676 ctx->vaa_pos = 0; in lws_lec_vsprintf()
1683 ctx->fmt_pos = 0; in lws_lec_vsprintf()