mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
lightningd: remove gratuitous param_tok from help and config.
They predate json_string! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ec76ba3895
commit
e621b8b24e
3 changed files with 23 additions and 28 deletions
|
@ -354,11 +354,10 @@ static void json_add_help_command(struct command *cmd,
|
|||
}
|
||||
|
||||
static const struct json_command *find_command(struct json_command **commands,
|
||||
const char *buffer,
|
||||
const jsmntok_t *cmdtok)
|
||||
const char *cmdname)
|
||||
{
|
||||
for (size_t i = 0; i < tal_count(commands); i++) {
|
||||
if (json_tok_streq(buffer, cmdtok, commands[i]->name))
|
||||
if (streq(cmdname, commands[i]->name))
|
||||
return commands[i];
|
||||
}
|
||||
return NULL;
|
||||
|
@ -376,28 +375,26 @@ static struct command_result *json_help(struct command *cmd,
|
|||
const jsmntok_t *params)
|
||||
{
|
||||
struct json_stream *response;
|
||||
const jsmntok_t *cmdtok;
|
||||
const char *cmdname;
|
||||
struct json_command **commands;
|
||||
const struct json_command *one_cmd;
|
||||
|
||||
if (!param(cmd, buffer, params,
|
||||
p_opt("command", param_tok, &cmdtok),
|
||||
p_opt("command", param_string, &cmdname),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
commands = cmd->ld->jsonrpc->commands;
|
||||
if (cmdtok) {
|
||||
one_cmd = find_command(commands, buffer, cmdtok);
|
||||
if (cmdname) {
|
||||
one_cmd = find_command(commands, cmdname);
|
||||
if (!one_cmd)
|
||||
return command_fail(cmd, JSONRPC2_METHOD_NOT_FOUND,
|
||||
"Unknown command '%.*s'",
|
||||
cmdtok->end - cmdtok->start,
|
||||
buffer + cmdtok->start);
|
||||
"Unknown command %s",
|
||||
cmdname);
|
||||
if (!deprecated_apis && one_cmd->deprecated)
|
||||
return command_fail(cmd, JSONRPC2_METHOD_NOT_FOUND,
|
||||
"Deprecated command '%.*s'",
|
||||
json_tok_full_len(cmdtok),
|
||||
json_tok_full(buffer, cmdtok));
|
||||
"Deprecated command %s",
|
||||
cmdname);
|
||||
} else
|
||||
one_cmd = NULL;
|
||||
|
||||
|
|
|
@ -1672,14 +1672,14 @@ static struct command_result *json_listconfigs(struct command *cmd,
|
|||
{
|
||||
size_t i;
|
||||
struct json_stream *response = NULL;
|
||||
const jsmntok_t *configtok;
|
||||
const char *configname;
|
||||
|
||||
if (!param(cmd, buffer, params,
|
||||
p_opt("config", param_tok, &configtok),
|
||||
p_opt("config", param_string, &configname),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
if (!configtok) {
|
||||
if (!configname) {
|
||||
response = json_stream_success(cmd);
|
||||
json_add_string(response, "# version", version());
|
||||
}
|
||||
|
@ -1699,9 +1699,8 @@ static struct command_result *json_listconfigs(struct command *cmd,
|
|||
if (name[0] != '-')
|
||||
continue;
|
||||
|
||||
if (configtok
|
||||
&& !memeq(buffer + configtok->start,
|
||||
configtok->end - configtok->start,
|
||||
if (configname
|
||||
&& !memeq(configname, strlen(configname),
|
||||
name + 1, len - 1))
|
||||
continue;
|
||||
|
||||
|
@ -1715,11 +1714,10 @@ static struct command_result *json_listconfigs(struct command *cmd,
|
|||
}
|
||||
}
|
||||
|
||||
if (configtok && !response) {
|
||||
if (configname && !response) {
|
||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"Unknown config option '%.*s'",
|
||||
json_tok_full_len(configtok),
|
||||
json_tok_full(buffer, configtok));
|
||||
"Unknown config option %s",
|
||||
configname);
|
||||
}
|
||||
return command_success(cmd, response);
|
||||
}
|
||||
|
|
|
@ -100,16 +100,16 @@ struct command_result *param_sha256(struct command *cmd UNNEEDED, const char *na
|
|||
const char *buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
||||
struct sha256 **hash UNNEEDED)
|
||||
{ fprintf(stderr, "param_sha256 called!\n"); abort(); }
|
||||
/* Generated stub for param_string */
|
||||
struct command_result *param_string(struct command *cmd UNNEEDED, const char *name UNNEEDED,
|
||||
const char * buffer UNNEEDED, const jsmntok_t *tok UNNEEDED,
|
||||
const char **str UNNEEDED)
|
||||
{ fprintf(stderr, "param_string called!\n"); abort(); }
|
||||
/* Generated stub for param_subcommand */
|
||||
const char *param_subcommand(struct command *cmd UNNEEDED, const char *buffer UNNEEDED,
|
||||
const jsmntok_t tokens[] UNNEEDED,
|
||||
const char *name UNNEEDED, ...)
|
||||
{ fprintf(stderr, "param_subcommand called!\n"); abort(); }
|
||||
/* Generated stub for param_tok */
|
||||
struct command_result *param_tok(struct command *cmd UNNEEDED, const char *name UNNEEDED,
|
||||
const char *buffer UNNEEDED, const jsmntok_t * tok UNNEEDED,
|
||||
const jsmntok_t **out UNNEEDED)
|
||||
{ fprintf(stderr, "param_tok called!\n"); abort(); }
|
||||
/* Generated stub for plugin_hook_call_ */
|
||||
bool plugin_hook_call_(struct lightningd *ld UNNEEDED, const struct plugin_hook *hook UNNEEDED,
|
||||
tal_t *cb_arg STEALS UNNEEDED)
|
||||
|
|
Loading…
Add table
Reference in a new issue