mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 11:42:27 +00:00
main/indications: Use ast_cli_completion_add for all completions.
Change-Id: I371be01f178fb542a9fbe8d97e7ae21aa4d82c36
This commit is contained in:
@@ -632,9 +632,7 @@ static struct ast_tone_zone *ast_tone_zone_alloc(void)
|
|||||||
|
|
||||||
static char *complete_country(struct ast_cli_args *a)
|
static char *complete_country(struct ast_cli_args *a)
|
||||||
{
|
{
|
||||||
char *res = NULL;
|
|
||||||
struct ao2_iterator i;
|
struct ao2_iterator i;
|
||||||
int which = 0;
|
|
||||||
size_t wordlen;
|
size_t wordlen;
|
||||||
struct ast_tone_zone *tz;
|
struct ast_tone_zone *tz;
|
||||||
|
|
||||||
@@ -642,17 +640,17 @@ static char *complete_country(struct ast_cli_args *a)
|
|||||||
|
|
||||||
i = ao2_iterator_init(ast_tone_zones, 0);
|
i = ao2_iterator_init(ast_tone_zones, 0);
|
||||||
while ((tz = ao2_iterator_next(&i))) {
|
while ((tz = ao2_iterator_next(&i))) {
|
||||||
if (!strncasecmp(a->word, tz->country, wordlen) && ++which > a->n) {
|
if (!strncasecmp(a->word, tz->country, wordlen)) {
|
||||||
res = ast_strdup(tz->country);
|
if (ast_cli_completion_add(ast_strdup(tz->country))) {
|
||||||
}
|
ast_tone_zone_unref(tz);
|
||||||
tz = ast_tone_zone_unref(tz);
|
break;
|
||||||
if (res) {
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
ast_tone_zone_unref(tz);
|
||||||
}
|
}
|
||||||
ao2_iterator_destroy(&i);
|
ao2_iterator_destroy(&i);
|
||||||
|
|
||||||
return res;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *handle_cli_indication_add(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
static char *handle_cli_indication_add(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
||||||
@@ -718,17 +716,17 @@ static char *handle_cli_indication_add(struct ast_cli_entry *e, int cmd, struct
|
|||||||
|
|
||||||
static char *complete_indications(struct ast_cli_args *a)
|
static char *complete_indications(struct ast_cli_args *a)
|
||||||
{
|
{
|
||||||
char *res = NULL;
|
|
||||||
int which = 0;
|
|
||||||
size_t wordlen;
|
size_t wordlen;
|
||||||
struct ast_tone_zone_sound *ts;
|
struct ast_tone_zone_sound *ts;
|
||||||
struct ast_tone_zone *tz, tmp_tz = {
|
struct ast_tone_zone *tz;
|
||||||
|
struct ast_tone_zone tmp_tz = {
|
||||||
.nrringcadence = 0,
|
.nrringcadence = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
ast_copy_string(tmp_tz.country, a->argv[a->pos - 1], sizeof(tmp_tz.country));
|
ast_copy_string(tmp_tz.country, a->argv[a->pos - 1], sizeof(tmp_tz.country));
|
||||||
|
|
||||||
if (!(tz = ao2_find(ast_tone_zones, &tmp_tz, OBJ_POINTER))) {
|
tz = ao2_find(ast_tone_zones, &tmp_tz, OBJ_POINTER);
|
||||||
|
if (!tz) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -736,16 +734,17 @@ static char *complete_indications(struct ast_cli_args *a)
|
|||||||
|
|
||||||
ast_tone_zone_lock(tz);
|
ast_tone_zone_lock(tz);
|
||||||
AST_LIST_TRAVERSE(&tz->tones, ts, entry) {
|
AST_LIST_TRAVERSE(&tz->tones, ts, entry) {
|
||||||
if (!strncasecmp(a->word, ts->name, wordlen) && ++which > a->n) {
|
if (!strncasecmp(a->word, ts->name, wordlen)) {
|
||||||
res = ast_strdup(ts->name);
|
if (ast_cli_completion_add(ast_strdup(ts->name))) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast_tone_zone_unlock(tz);
|
ast_tone_zone_unlock(tz);
|
||||||
|
|
||||||
tz = ast_tone_zone_unref(tz);
|
tz = ast_tone_zone_unref(tz);
|
||||||
|
|
||||||
return res;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *handle_cli_indication_remove(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
static char *handle_cli_indication_remove(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
||||||
|
Reference in New Issue
Block a user