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

Function param_list_or_string

lightningd/datastore.c:61–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61static struct command_result *param_list_or_string(struct command *cmd,
62 const char *name,
63 const char *buffer,
64 const jsmntok_t *tok,
65 const char ***str)
66{
67 if (tok->type == JSMN_ARRAY && tok->size <= 0) {
68 return command_fail_badparam(cmd, name,
69 buffer, tok,
70 "should not be empty");
71 } else if (tok->type == JSMN_ARRAY) {
72 size_t i;
73 const jsmntok_t *t;
74 *str = tal_arr(cmd, const char *, tok->size);
75 json_for_each_arr(i, t, tok) {
76 if (t->type != JSMN_STRING && t->type != JSMN_PRIMITIVE)
77 return command_fail_badparam(cmd, name,
78 buffer, t,
79 "should be string");
80 (*str)[i] = json_strdup(*str, buffer, t);
81 }
82 } else if (tok->type == JSMN_STRING || tok->type == JSMN_PRIMITIVE) {
83 *str = tal_arr(cmd, const char *, 1);
84 (*str)[0] = json_strdup(*str, buffer, tok);
85 } else
86 return command_fail_badparam(cmd, name,
87 buffer, tok,
88 "should be string or array");
89 return NULL;
90}
91
92static char *datastore_key_fmt(const tal_t *ctx, const char **key)
93{

Callers

nothing calls this directly

Calls 2

command_fail_badparamFunction · 0.50
json_strdupFunction · 0.50

Tested by

no test coverage detected