Merge "main/config: Use ast_cli_completion_add for reload completion."

16.0
Jenkins2 7 years ago committed by Gerrit Code Review
commit 716e2d46e7

@ -3930,8 +3930,8 @@ static char *handle_cli_core_show_config_mappings(struct ast_cli_entry *e, int c
static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
struct cache_file_mtime *cfmtime; struct cache_file_mtime *cfmtime;
char *prev = "", *completion_value = NULL; char *prev = "";
int wordlen, which = 0; int wordlen;
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
@ -3949,27 +3949,28 @@ static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct a
AST_LIST_LOCK(&cfmtime_head); AST_LIST_LOCK(&cfmtime_head);
AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) { AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) {
/* Skip duplicates - this only works because the list is sorted by filename */ /* Core configs cannot be reloaded */
if (strcmp(cfmtime->filename, prev) == 0) { if (ast_strlen_zero(cfmtime->who_asked)) {
continue; continue;
} }
/* Core configs cannot be reloaded */ /* Skip duplicates - this only works because the list is sorted by filename */
if (ast_strlen_zero(cfmtime->who_asked)) { if (!strcmp(cfmtime->filename, prev)) {
continue; continue;
} }
if (++which > a->n && strncmp(cfmtime->filename, a->word, wordlen) == 0) { if (!strncmp(cfmtime->filename, a->word, wordlen)) {
completion_value = ast_strdup(cfmtime->filename); if (ast_cli_completion_add(ast_strdup(cfmtime->filename))) {
break; break;
} }
}
/* Otherwise save that we've seen this filename */ /* Otherwise save that we've seen this filename */
prev = cfmtime->filename; prev = cfmtime->filename;
} }
AST_LIST_UNLOCK(&cfmtime_head); AST_LIST_UNLOCK(&cfmtime_head);
return completion_value; return NULL;
} }
if (a->argc != 3) { if (a->argc != 3) {

Loading…
Cancel
Save