diff options
author | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-11 11:59:53 +0000 |
---|---|---|
committer | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-06-11 11:59:53 +0000 |
commit | 06d778dd1dcbcd4163ddb9f70dd3d75d85ab7413 (patch) | |
tree | b95061f2e060e681c8bda178a9bd9af502fd5e09 /main/manager.c | |
parent | 0d36c161da355d1e08c2dcd8fe286ac51b486161 (diff) |
Add username completion for manager show user CLI command. (issue #9929 reported by eliel)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@68663 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/manager.c')
-rw-r--r-- | main/manager.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/main/manager.c b/main/manager.c index eb469fbd9..dcd115f99 100644 --- a/main/manager.c +++ b/main/manager.c @@ -423,6 +423,27 @@ static char *complete_show_mancmd(const char *line, const char *word, int pos, i return ret; } +static char *complete_show_manuser(const char *line, const char *word, int pos, int state) +{ + struct ast_manager_user *user = NULL; + int l = strlen(word), which = 0; + char *ret = NULL; + + if (pos != 3) + return NULL; + + AST_LIST_LOCK(&users); + AST_LIST_TRAVERSE(&users, user, list) { + if (!strncasecmp(word, user->username, l) && ++which > state) { + ret = ast_strdup(user->username); + break; + } + } + AST_LIST_UNLOCK(&users); + + return ret; +} + static int check_manager_session_inuse(const char *name) { struct mansession *session = NULL; @@ -663,7 +684,7 @@ static struct ast_cli_entry cli_manager[] = { { { "manager", "show", "user", NULL }, handle_showmanager, "Display information on a specific manager user", - showmanager_help, NULL, NULL }, + showmanager_help, complete_show_manuser, NULL }, { { "manager", "debug", NULL }, handle_mandebug, "Show, enable, disable debugging of the manager code", |