Skip to content
Snippets Groups Projects
Commit b68dae18 authored by Jenkins2's avatar Jenkins2 Committed by Gerrit Code Review
Browse files

Merge "main/sounds: Use ast_cli_completion_add."

parents dc2ce3ce 645203a4
Branches
Tags
No related merge requests found
...@@ -219,6 +219,11 @@ static char *handle_cli_sounds_show(struct ast_cli_entry *e, int cmd, struct ast ...@@ -219,6 +219,11 @@ static char *handle_cli_sounds_show(struct ast_cli_entry *e, int cmd, struct ast
/*! \brief Show details about a sound available in the system */ /*! \brief Show details about a sound available in the system */
static char *handle_cli_sound_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) static char *handle_cli_sound_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{ {
int length;
struct ao2_iterator it_sounds;
char *filename;
struct ao2_container *sound_files;
switch (cmd) { switch (cmd) {
case CLI_INIT: case CLI_INIT:
e->command = "core show sound"; e->command = "core show sound";
...@@ -227,29 +232,30 @@ static char *handle_cli_sound_show(struct ast_cli_entry *e, int cmd, struct ast_ ...@@ -227,29 +232,30 @@ static char *handle_cli_sound_show(struct ast_cli_entry *e, int cmd, struct ast_
" Shows information about the specified sound.\n"; " Shows information about the specified sound.\n";
return NULL; return NULL;
case CLI_GENERATE: case CLI_GENERATE:
{ if (a->pos != 3) {
int length = strlen(a->word); return NULL;
int which = 0; }
struct ao2_iterator it_sounds;
char *match = NULL; sound_files = ast_media_get_media(sounds_index);
char *filename;
RAII_VAR(struct ao2_container *, sound_files, ast_media_get_media(sounds_index), ao2_cleanup);
if (!sound_files) { if (!sound_files) {
return NULL; return NULL;
} }
length = strlen(a->word);
it_sounds = ao2_iterator_init(sound_files, 0); it_sounds = ao2_iterator_init(sound_files, 0);
while ((filename = ao2_iterator_next(&it_sounds))) { while ((filename = ao2_iterator_next(&it_sounds))) {
if (!strncasecmp(a->word, filename, length) && ++which > a->n) { if (!strncasecmp(a->word, filename, length)) {
match = ast_strdup(filename); if (ast_cli_completion_add(ast_strdup(filename))) {
ao2_ref(filename, -1); ao2_ref(filename, -1);
break; break;
}
} }
ao2_ref(filename, -1); ao2_ref(filename, -1);
} }
ao2_iterator_destroy(&it_sounds); ao2_iterator_destroy(&it_sounds);
return match; ao2_ref(sound_files, -1);
}
return NULL;
} }
if (a->argc == 4) { if (a->argc == 4) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment