[Asterisk-code-review] main/sounds: Use ast cli completion add. (asterisk[13])

Corey Farrell asteriskteam at digium.com
Sun Mar 18 17:49:39 CDT 2018


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/8583


Change subject: main/sounds: Use ast_cli_completion_add.
......................................................................

main/sounds: Use ast_cli_completion_add.

Change-Id: I140e1137906bbfcdb61c0c6304159be459ad873e
---
M main/sounds.c
1 file changed, 9 insertions(+), 8 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/83/8583/1

diff --git a/main/sounds.c b/main/sounds.c
index c792c1b..d0e5ff8 100644
--- a/main/sounds.c
+++ b/main/sounds.c
@@ -229,26 +229,27 @@
 	case CLI_GENERATE:
 	{
 		int length = strlen(a->word);
-		int which = 0;
 		struct ao2_iterator it_sounds;
-		char *match = NULL;
 		char *filename;
-		RAII_VAR(struct ao2_container *, sound_files, ast_media_get_media(sounds_index), ao2_cleanup);
+		struct ao2_container *sound_files = ast_media_get_media(sounds_index);
+
 		if (!sound_files) {
 			return NULL;
 		}
 
 		it_sounds = ao2_iterator_init(sound_files, 0);
 		while ((filename = ao2_iterator_next(&it_sounds))) {
-			if (!strncasecmp(a->word, filename, length) && ++which > a->n) {
-				match = ast_strdup(filename);
-				ao2_ref(filename, -1);
-				break;
+			if (!strncasecmp(a->word, filename, length)) {
+				if (ast_cli_completion_add(ast_strdup(filename))) {
+					ao2_ref(filename, -1);
+					break;
+				}
 			}
 			ao2_ref(filename, -1);
 		}
 		ao2_iterator_destroy(&it_sounds);
-		return match;
+
+		return NULL;
 	}
 	}
 

-- 
To view, visit https://gerrit.asterisk.org/8583
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I140e1137906bbfcdb61c0c6304159be459ad873e
Gerrit-Change-Number: 8583
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180318/4d8a9add/attachment.html>


More information about the asterisk-code-review mailing list