[asterisk-commits] anthonyl: branch anthonyl/5240-testing r43211 - /team/anthonyl/5240-testing/m...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Sep 18 12:51:12 MST 2006


Author: anthonyl
Date: Mon Sep 18 14:51:12 2006
New Revision: 43211

URL: http://svn.digium.com/view/asterisk?rev=43211&view=rev
Log:
update

Modified:
    team/anthonyl/5240-testing/main/manager.c

Modified: team/anthonyl/5240-testing/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/5240-testing/main/manager.c?rev=43211&r1=43210&r2=43211&view=diff
==============================================================================
--- team/anthonyl/5240-testing/main/manager.c (original)
+++ team/anthonyl/5240-testing/main/manager.c Mon Sep 18 14:51:12 2006
@@ -383,6 +383,36 @@
 	return out;
 }
 
+
+
+struct ast_manager_user *ast_get_manager_by_name_locked(const char *name)
+{
+	struct ast_manager_user *tmp = NULL;
+	tmp=amus;
+	while (tmp) {
+		if (!strcasecmp(tmp->username, name))
+			break;
+		tmp = tmp->next;
+	}
+	if ( tmp)
+		return tmp;
+	return NULL;
+}
+
+
+
+int *ast_manager_user_add(struct ast_manager_user *amu) {
+	if (!amu) {
+		ast_log(LOG_DEBUG, "You cant pass NULL to that function");
+		return NULL;
+	}
+	ast_mutex_lock(&amulock);
+	amu->next = amus;
+	amus = amu;
+	ast_mutex_unlock(&amulock);
+	return NULL;
+}
+
 void astman_append(struct mansession *s, const char *fmt, ...)
 {
 	va_list ap;
@@ -426,6 +456,79 @@
 
 	return RESULT_SUCCESS;
 }
+
+static int handle_showmanager(int fd, int argc, char *argv[])
+{
+	struct ast_manager_user *tmp;
+	if (argc != 4 )
+		return RESULT_SHOWUSAGE;
+
+	/* try to lock manager_user list ... */
+	if (ast_mutex_lock(&amulock)) {
+		ast_log(LOG_ERROR, "Unable to lock manager_user list\n");
+		return -1;
+	}
+
+	tmp = ast_get_manager_by_name_locked(argv[3]);
+
+	if (!tmp) {
+		ast_cli(fd, "There are no manager called %s\n",argv[3]);
+		ast_mutex_unlock(&amulock);
+		return -1;
+	}
+	ast_cli(fd,"\n");
+	ast_cli(fd,
+		"       username: %s\n"
+		"         secret: %s\n"
+		"           deny: %s\n"
+		"         permit: %s\n"
+		"           read: %s\n"
+		"          write: %s\n"
+		"displayconnects: %s\n",
+		(tmp->username ? tmp->username : "(N/A)"),
+		(tmp->secret ? tmp->secret : "(N/A)"),
+		(tmp->deny ? tmp->deny : "(N/A)"),
+		(tmp->permit ? tmp->permit : "(N/A)"),
+		(tmp->read ? tmp->read : "(N/A)"),
+		(tmp->write ? tmp->write : "(N/A)"),
+		(tmp->displayconnects ? "yes" : "no"));
+	ast_mutex_unlock(&amulock);
+
+	return RESULT_SUCCESS;
+}
+
+
+static int handle_showmanagers(int fd, int argc, char *argv[]) {
+	struct ast_manager_user *tmp;
+	int count_amu = 0;
+
+	if ( argc > 4 )
+		return RESULT_SHOWUSAGE;
+
+	/* try to lock manager_user list ... */
+	if (ast_mutex_lock(&amulock)) {
+		ast_log(LOG_ERROR, "Unable to lock manager_user list\n");
+		return -1;
+	}
+
+	tmp=amus;
+	if (!tmp) {
+		ast_cli(fd, "There are no manager user.\n");
+		ast_mutex_unlock(&amulock);
+		return -1;
+	}
+	ast_cli(fd, "\nusername\n--------\n");
+	while (tmp) {
+		ast_cli(fd, "%s\n", tmp->username);
+		tmp = tmp->next;
+		count_amu++;
+	}
+	ast_mutex_unlock(&amulock);
+	ast_cli(fd,"-------------------\n");
+	ast_cli(fd,"%d manager users configured.\n", count_amu);
+	return RESULT_SUCCESS;
+}
+
 
 /*! \brief  CLI command
 	Should change to "manager show commands" */
@@ -2471,7 +2574,6 @@
 {
 	struct ast_config *cfg;
 	char *val,*cat;
-	char *val;
 	int oldportno = portno;
 	static struct sockaddr_in ba;
 	int x = 1;
@@ -2682,130 +2784,3 @@
 	return init_manager();
 }
 
-
-
-struct ast_manager_user *ast_get_manager_by_name_locked(const char *name)
-{
-	struct ast_manager_user *tmp = NULL;
-	tmp=amus;
-	while (tmp) {
-		if (!strcasecmp(tmp->username, name))
-			break;
-		tmp = tmp->next;
-	}
-	if ( tmp)
-		return tmp;
-	return NULL;
-}
-
-
-static int handle_showmanager(int fd, int argc, char *argv[])
-{
-	struct ast_manager_user *tmp;
-	int command;
-
-	if (argc < 3 || argc > 4 )
-		return RESULT_SHOWUSAGE;
-
-	if ( !strcasecmp(argv[2],"connected") )
-		return handle_showmanconn(fd,argc,argv);
-	else if ( !strcasecmp(argv[2],"commands") )
-		return handle_showmancmds(fd,argc,argv);
-
-	command = (argc > 2 && (!strcasecmp(argv[2],"command")));
-	if (command) {
-		return handle_showmancmd(fd,argc,argv);
-	}
-
-
-	/* try to lock manager_user list ... */
-	if (ast_mutex_lock(&amulock)) {
-		ast_log(LOG_ERROR, "Unable to lock manager_user list\n");
-		return -1;
-	}
-
-	tmp = ast_get_manager_by_name_locked(argv[2]);
-
-	if (!tmp) {
-		ast_cli(fd, "There are no manager called %s\n",argv[2]);
-		ast_mutex_unlock(&amulock);
-		return -1;
-	}
-	ast_cli(fd,"\n");
-	ast_cli(fd,
-		"       username: %s\n"
-		"         secret: %s\n"
-		"           deny: %s\n"
-		"         permit: %s\n"
-		"           read: %s\n"
-		"          write: %s\n"
-		"displayconnects: %s\n",
-		(tmp->username ? tmp->username : "(N/A)"),
-		(tmp->secret ? tmp->secret : "(N/A)"),
-		(tmp->deny ? tmp->deny : "(N/A)"),
-		(tmp->permit ? tmp->permit : "(N/A)"),
-		(tmp->read ? tmp->read : "(N/A)"),
-		(tmp->write ? tmp->write : "(N/A)"),
-		(tmp->displayconnects ? "yes" : "no"));
-	ast_mutex_unlock(&amulock);
-
-	return RESULT_SUCCESS;
-}
-
-static int handle_showmanagers(int fd, int argc, char *argv[]) {
-#define FORMAT  "%-35.35s %-35.35s\n"
-#define CONCISE_FORMAT "%s:%s\n"
-
-	struct ast_manager_user *tmp;
-	int count_amu = 0, concise = 0;
-
-	if ( argc > 3 )
-		return RESULT_SHOWUSAGE;
-
-	concise = (argc == 3 && (!strcasecmp(argv[2],"concise")));
-
-	/* try to lock manager_user list ... */
-	if (ast_mutex_lock(&amulock)) {
-		ast_log(LOG_ERROR, "Unable to lock manager_user list\n");
-		return -1;
-	}
-
-	tmp=amus;
-	if (!tmp) {
-		ast_cli(fd, "There are no manager user.\n");
-		ast_mutex_unlock(&amulock);
-		return -1;
-	}
-	if (concise) {
-		ast_cli(fd,"\n");
-		while (tmp) {
-			ast_cli(fd, CONCISE_FORMAT,tmp->username, (tmp->secret?tmp->secret: "(N/A)"));
-			tmp = tmp->next;
-		}
-		return RESULT_SUCCESS;
-	}
-	ast_cli(fd, FORMAT, "username", "secret");
-	ast_cli(fd, FORMAT, "--------", "------");
-	while (tmp) {
-		ast_cli(fd, FORMAT,tmp->username, (tmp->secret?tmp->secret: "(N/A)"));
-		tmp = tmp->next;
-		count_amu++;
-	}
-	ast_mutex_unlock(&amulock);
-	ast_cli(fd,"-------------------\n");
-	ast_cli(fd,"%d manager users configured.\n", count_amu);
-	return RESULT_SUCCESS;
-}
-
-
-int *ast_manager_user_add(struct ast_manager_user *amu) {
-	if (!amu) {
-		ast_log(LOG_DEBUG, "You cant pass NULL to that function");
-		return NULL;
-	}
-	ast_mutex_lock(&amulock);
-	amu->next = amus;
-	amus = amu;
-	ast_mutex_unlock(&amulock);
-	return NULL;
-}



More information about the asterisk-commits mailing list