version 1.39, 2020/04/13 15:55:51 |
version 1.40, 2020/04/13 18:59:41 |
|
|
mode_tree_run_command(struct client *c, struct cmd_find_state *fs, |
mode_tree_run_command(struct client *c, struct cmd_find_state *fs, |
const char *template, const char *name) |
const char *template, const char *name) |
{ |
{ |
struct cmdq_item *new_item; |
struct cmdq_state *state; |
struct cmdq_state *new_state; |
char *command, *error; |
char *command; |
enum cmd_parse_status status; |
struct cmd_parse_result *pr; |
|
|
|
command = cmd_template_replace(template, name, 1); |
command = cmd_template_replace(template, name, 1); |
if (command == NULL || *command == '\0') { |
if (command != NULL && *command != '\0') { |
free(command); |
state = cmdq_new_state(fs, NULL, 0); |
return; |
status = cmd_parse_and_append(command, NULL, c, state, &error); |
} |
if (status == CMD_PARSE_ERROR) { |
|
if (c != NULL) { |
pr = cmd_parse_from_string(command, NULL); |
*error = toupper((u_char)*error); |
switch (pr->status) { |
status_message_set(c, "%s", error); |
case CMD_PARSE_EMPTY: |
} |
break; |
free(error); |
case CMD_PARSE_ERROR: |
|
if (c != NULL) { |
|
*pr->error = toupper((u_char)*pr->error); |
|
status_message_set(c, "%s", pr->error); |
|
} |
} |
free(pr->error); |
cmdq_free_state(state); |
break; |
|
case CMD_PARSE_SUCCESS: |
|
new_state = cmdq_new_state(fs, NULL, 0); |
|
new_item = cmdq_get_command(pr->cmdlist, new_state); |
|
cmdq_free_state(new_state); |
|
cmdq_append(c, new_item); |
|
cmd_list_free(pr->cmdlist); |
|
break; |
|
} |
} |
|
|
free(command); |
free(command); |
} |
} |