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

Function parse_by_name

common/json_param.c:139–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139static struct command_result *parse_by_name(struct command *cmd,
140 struct param *params,
141 const char *buffer,
142 const jsmntok_t tokens[],
143 bool allow_extra)
144{
145 size_t i;
146 const jsmntok_t *t;
147
148 json_for_each_obj(i, t, tokens) {
149 struct param *p = find_param(params, buffer + t->start,
150 t->end - t->start);
151 if (!p) {
152 if (!allow_extra) {
153 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
154 "unknown parameter: %.*s, this may be caused by a failure to autodetect key=value-style parameters. Please try using the -k flag and explicit key=value pairs of parameters.",
155 t->end - t->start,
156 buffer + t->start);
157 }
158 } else {
159 struct command_result *res;
160
161 if (p->is_set) {
162 if (p->style == PARAM_REQUIRED_ALLOW_DUPS)
163 continue;
164 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
165 "duplicate json names: %s",
166 p->name);
167 }
168
169 res = make_callback(cmd, p, buffer, t + 1);
170 if (res)
171 return res;
172 }
173 }
174 return post_check(cmd, params);
175}
176
177#if DEVELOPER
178static int comp_by_name(const struct param *a, const struct param *b,

Callers 1

param_arrFunction · 0.85

Calls 4

find_paramFunction · 0.85
make_callbackFunction · 0.85
post_checkFunction · 0.85
command_failFunction · 0.50

Tested by

no test coverage detected