[Asterisk-code-review] main/cdr: Use ast cli completion add for CDR channel complet... (asterisk[15])

Corey Farrell asteriskteam at digium.com
Thu Mar 15 12:55:51 CDT 2018


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


Change subject: main/cdr: Use ast_cli_completion_add for CDR channel completion.
......................................................................

main/cdr: Use ast_cli_completion_add for CDR channel completion.

Change-Id: Ie81830647a23aad61c1162583b6d50adbe6e7822
---
M main/cdr.c
1 file changed, 4 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/42/8542/1

diff --git a/main/cdr.c b/main/cdr.c
index 4acadf9..b0a48e1 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -3950,18 +3950,14 @@
 /*! \brief Complete user input for 'cdr show' */
 static char *cli_complete_show(struct ast_cli_args *a)
 {
-	char *result = NULL;
 	int wordlen = strlen(a->word);
-	int which = 0;
 	struct ao2_iterator it_cdrs;
 	struct cdr_object *cdr;
 
 	it_cdrs = ao2_iterator_init(active_cdrs_master, 0);
 	while ((cdr = ao2_iterator_next(&it_cdrs))) {
-		if (!strncasecmp(a->word, cdr->party_a.snapshot->name, wordlen) &&
-			(++which > a->n)) {
-			result = ast_strdup(cdr->party_a.snapshot->name);
-			if (result) {
+		if (!strncasecmp(a->word, cdr->party_a.snapshot->name, wordlen)) {
+			if (ast_cli_completion_add(ast_strdup(cdr->party_a.snapshot->name))) {
 				ao2_ref(cdr, -1);
 				break;
 			}
@@ -3969,7 +3965,8 @@
 		ao2_ref(cdr, -1);
 	}
 	ao2_iterator_destroy(&it_cdrs);
-	return result;
+
+	return NULL;
 }
 
 static void cli_show_channels(struct ast_cli_args *a)

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

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie81830647a23aad61c1162583b6d50adbe6e7822
Gerrit-Change-Number: 8542
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/20180315/cf0aa0be/attachment-0001.html>


More information about the asterisk-code-review mailing list