MCPcopy Create free account
hub / github.com/ElementsProject/lightning / parse_fieldval

Function parse_fieldval

common/json_parse.c:302–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300}
301
302static const char *parse_fieldval(const char *buffer,
303 const jsmntok_t *tok,
304 const char **guide,
305 va_list *ap)
306{
307 const char *errmsg;
308
309 if (**guide == '{') {
310 errmsg = parse_obj(buffer, tok, guide, ap);
311 if (errmsg)
312 return errmsg;
313 } else if (**guide == '[') {
314 errmsg = parse_arr(buffer, tok, guide, ap);
315 if (errmsg)
316 return errmsg;
317 } else if (**guide == '%') {
318 guide_consume_one(guide);
319 errmsg = handle_percent(buffer, tok, ap);
320 if (errmsg)
321 return errmsg;
322 } else {
323 const char *literal;
324 size_t len;
325
326 /* Literal must match exactly (modulo quotes for strings) */
327 parse_literal(guide, &literal, &len);
328 if (!memeq(buffer + tok->start, tok->end - tok->start,
329 literal, len)) {
330 return tal_fmt(tmpctx,
331 "%.*s does not match expected %.*s",
332 json_tok_full_len(tok),
333 json_tok_full(buffer, tok),
334 (int)len, literal);
335 }
336 }
337 return NULL;
338}
339
340static const char *parse_field(const char *buffer,
341 const jsmntok_t *tok,

Callers 2

parse_fieldFunction · 0.85
parse_arrelemFunction · 0.85

Calls 8

parse_objFunction · 0.85
parse_arrFunction · 0.85
guide_consume_oneFunction · 0.85
handle_percentFunction · 0.85
parse_literalFunction · 0.85
memeqFunction · 0.85
json_tok_full_lenFunction · 0.70
json_tok_fullFunction · 0.70

Tested by

no test coverage detected