| 83 | } |
| 84 | |
| 85 | static 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 | |
| 118 | static struct param *find_param(struct param *params, const char *start, |
| 119 | size_t n) |
no test coverage detected