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

Function handle_percent

common/json_parse.c:181–213  ·  view source on GitHub ↗

talfmt take a ctx pointer and return NULL or a valid pointer. * fmt takes the argument, and returns a bool. * * This function returns NULL on success, or errmsg on failure. */

Source from the content-addressed store, hash-verified

179 * This function returns NULL on success, or errmsg on failure.
180*/
181static const char *handle_percent(const char *buffer,
182 const jsmntok_t *tok,
183 va_list *ap)
184{
185 void *ctx;
186 const char *fmtname;
187
188 /* This is set to (dummy) json_scan if it's a non-tal fmt */
189 ctx = va_arg(*ap, void *);
190 fmtname = va_arg(*ap, const char *);
191 if (ctx != json_scan) {
192 void *(*talfmt)(void *, const char *, const jsmntok_t *);
193 void **p;
194 p = va_arg(*ap, void **);
195 talfmt = va_arg(*ap, void *(*)(void *, const char *, const jsmntok_t *));
196 *p = talfmt(ctx, buffer, tok);
197 if (*p != NULL)
198 return NULL;
199 } else {
200 bool (*fmt)(const char *, const jsmntok_t *, void *);
201 void *p;
202
203 p = va_arg(*ap, void *);
204 fmt = va_arg(*ap, bool (*)(const char *, const jsmntok_t *, void *));
205 if (fmt(buffer, tok, p))
206 return NULL;
207 }
208
209 return tal_fmt(tmpctx, "%s could not parse %.*s",
210 fmtname,
211 json_tok_full_len(tok),
212 json_tok_full(buffer, tok));
213}
214
215/* GUIDE := OBJ | ARRAY | '%'
216 * OBJ := '{' FIELDLIST '}'

Callers 2

parse_guideFunction · 0.85
parse_fieldvalFunction · 0.85

Calls 2

json_tok_full_lenFunction · 0.70
json_tok_fullFunction · 0.70

Tested by

no test coverage detected