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

Function parse_fieldval

common/json_parse.c:296–332  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Tested by

no test coverage detected