[Asterisk-code-review] main/config: Use ast cli completion add for reload completion. (asterisk[13])
Jenkins2
asteriskteam at digium.com
Tue Mar 20 07:54:14 CDT 2018
Jenkins2 has submitted this change and it was merged. ( 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(-)
Approvals:
George Joseph: Looks good to me, but someone else must approve
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved
Jenkins2: Approved for Submit
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: merged
Gerrit-Change-Id: Ia3fa4c03f2285a1ec8814bbe7f4624ead9111ad1
Gerrit-Change-Number: 8586
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180320/1d34bc58/attachment.html>
More information about the asterisk-code-review
mailing list