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

Corey Farrell asteriskteam at digium.com
Sun Mar 18 19:09:48 CDT 2018


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


Change subject: main/config: Use ast_cli_completion_add for reload completion.
......................................................................

main/config: Use ast_cli_completion_add for reload completion.

Change-Id: Ia3fa4c03f2285a1ec8814bbe7f4624ead9111ad1
---
M main/config.c
1 file changed, 12 insertions(+), 11 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/86/8586/1

diff --git a/main/config.c b/main/config.c
index 6bc1eda..1cb5bbe 100644
--- a/main/config.c
+++ b/main/config.c
@@ -3934,8 +3934,8 @@
 static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct cache_file_mtime *cfmtime;
-	char *prev = "", *completion_value = NULL;
-	int wordlen, which = 0;
+	char *prev = "";
+	int wordlen;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -3953,19 +3953,20 @@
 
 		AST_LIST_LOCK(&cfmtime_head);
 		AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) {
-			/* Skip duplicates - this only works because the list is sorted by filename */
-			if (strcmp(cfmtime->filename, prev) == 0) {
-				continue;
-			}
-
 			/* Core configs cannot be reloaded */
 			if (ast_strlen_zero(cfmtime->who_asked)) {
 				continue;
 			}
 
-			if (++which > a->n && strncmp(cfmtime->filename, a->word, wordlen) == 0) {
-				completion_value = ast_strdup(cfmtime->filename);
-				break;
+			/* Skip duplicates - this only works because the list is sorted by filename */
+			if (!strcmp(cfmtime->filename, prev)) {
+				continue;
+			}
+
+			if (!strncmp(cfmtime->filename, a->word, wordlen)) {
+				if (ast_cli_completion_add(ast_strdup(cfmtime->filename))) {
+					break;
+				}
 			}
 
 			/* Otherwise save that we've seen this filename */
@@ -3973,7 +3974,7 @@
 		}
 		AST_LIST_UNLOCK(&cfmtime_head);
 
-		return completion_value;
+		return NULL;
 	}
 
 	if (a->argc != 3) {

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

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia3fa4c03f2285a1ec8814bbe7f4624ead9111ad1
Gerrit-Change-Number: 8586
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/84d50e22/attachment-0001.html>


More information about the asterisk-code-review mailing list