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

Function parse_by_position

common/json_param.c:85–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85static struct command_result *parse_by_position(struct command *cmd,
86 struct param *params,
87 const char *buffer,
88 const jsmntok_t tokens[],
89 bool allow_extra)
90{
91 struct command_result *res;
92 const jsmntok_t *tok;
93 size_t i;
94
95 json_for_each_arr(i, tok, tokens) {
96 /* check for unexpected trailing params */
97 if (i == tal_count(params)) {
98 if (!allow_extra) {
99 return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
100 "too many parameters:"
101 " got %u, expected %zu",
102 tokens->size,
103 tal_count(params));
104 }
105 break;
106 }
107
108 if (!json_tok_is_null(buffer, tok)) {
109 res = make_callback(cmd, params+i, buffer, tok);
110 if (res)
111 return res;
112 }
113 }
114
115 return post_check(cmd, params);
116}
117
118static struct param *find_param(struct param *params, const char *start,
119 size_t n)

Callers 1

param_arrFunction · 0.85

Calls 4

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

Tested by

no test coverage detected