[asterisk-commits] file: trunk r68663 - /trunk/main/manager.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jun 11 04:59:53 MST 2007


Author: file
Date: Mon Jun 11 06:59:53 2007
New Revision: 68663

URL: http://svn.digium.com/view/asterisk?view=rev&rev=68663
Log:
Add username completion for manager show user CLI command. (issue #9929 reported by eliel)

Modified:
    trunk/main/manager.c

Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?view=diff&rev=68663&r1=68662&r2=68663
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Mon Jun 11 06:59:53 2007
@@ -423,6 +423,27 @@
 	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 @@
 
 	{ { "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",



More information about the asterisk-commits mailing list