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

Function parse_by_position

common/json_param.c:99–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99static struct command_result *parse_by_position(struct command *cmd,
100 struct param *params,
101 const char *buffer,
102 const jsmntok_t tokens[],
103 bool allow_extra)
104{
105 struct command_result *res;
106 const jsmntok_t *tok;
107 size_t i;
108
109 json_for_each_arr(i, tok, tokens) {
110 /* check for unexpected trailing params */
111 if (i == tal_count(params)) {
112 if (!allow_extra) {
113 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
114 "too many parameters:"
115 " got %u, expected %zu",
116 tokens->size,
117 tal_count(params));
118 }
119 break;
120 }
121
122 if (!json_tok_is_null(buffer, tok)) {
123 if (params[i].style == PARAM_OPTIONAL_DEV_WITH_DEFAULT
124 && !command_dev_apis(cmd)) {
125 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
126 "Parameter %zu is developer-only", i);
127 }
128 res = make_callback(cmd, params+i, buffer, tok);
129 if (res)
130 return res;
131 }
132 }
133
134 return post_check(cmd, params);
135}
136
137static struct param *find_param(struct command *cmd,
138 struct param *params, const char *start,

Callers 1

param_arrFunction · 0.85

Calls 5

make_callbackFunction · 0.85
post_checkFunction · 0.85
command_failFunction · 0.50
json_tok_is_nullFunction · 0.50
command_dev_apisFunction · 0.50

Tested by

no test coverage detected