mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
main/ccss: Use ast_cli_completion_add for core id.
Change-Id: I44b25d6d24c7d9bc1bb38a50774b38883162f98f
This commit is contained in:
17
main/ccss.c
17
main/ccss.c
@@ -4547,11 +4547,9 @@ static int kill_cores(void *obj, void *arg, int flags)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *complete_core_id(const char *line, const char *word, int pos, int state)
|
static char *complete_core_id(const char *word)
|
||||||
{
|
{
|
||||||
int which = 0;
|
|
||||||
int wordlen = strlen(word);
|
int wordlen = strlen(word);
|
||||||
char *ret = NULL;
|
|
||||||
struct ao2_iterator core_iter = ao2_iterator_init(cc_core_instances, 0);
|
struct ao2_iterator core_iter = ao2_iterator_init(cc_core_instances, 0);
|
||||||
struct cc_core_instance *core_instance;
|
struct cc_core_instance *core_instance;
|
||||||
|
|
||||||
@@ -4559,15 +4557,16 @@ static char *complete_core_id(const char *line, const char *word, int pos, int s
|
|||||||
cc_unref(core_instance, "CLI tab completion iteration")) {
|
cc_unref(core_instance, "CLI tab completion iteration")) {
|
||||||
char core_id_str[20];
|
char core_id_str[20];
|
||||||
snprintf(core_id_str, sizeof(core_id_str), "%d", core_instance->core_id);
|
snprintf(core_id_str, sizeof(core_id_str), "%d", core_instance->core_id);
|
||||||
if (!strncmp(word, core_id_str, wordlen) && ++which > state) {
|
if (!strncmp(word, core_id_str, wordlen)) {
|
||||||
ret = ast_strdup(core_id_str);
|
if (ast_cli_completion_add(ast_strdup(core_id_str))) {
|
||||||
cc_unref(core_instance, "Found a matching core ID for CLI tab-completion");
|
cc_unref(core_instance, "Found a matching core ID for CLI tab-completion");
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ao2_iterator_destroy(&core_iter);
|
ao2_iterator_destroy(&core_iter);
|
||||||
|
|
||||||
return ret;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *handle_cc_kill(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
static char *handle_cc_kill(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
||||||
@@ -4583,7 +4582,7 @@ static char *handle_cc_kill(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
|
|||||||
return NULL;
|
return NULL;
|
||||||
case CLI_GENERATE:
|
case CLI_GENERATE:
|
||||||
if (a->pos == 3 && !strcasecmp(a->argv[2], "core")) {
|
if (a->pos == 3 && !strcasecmp(a->argv[2], "core")) {
|
||||||
return complete_core_id(a->line, a->word, a->pos, a->n);
|
return complete_core_id(a->word);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user