[svn-commits] pabelanger: branch pabelanger/issue16343 r259663 - in /team/pabelanger/issue1...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Apr 28 10:41:17 CDT 2010


Author: pabelanger
Date: Wed Apr 28 10:41:14 2010
New Revision: 259663

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=259663
Log:
A few changes based on Mark Michelson comments.  Moved AST_CLI_YESNO into cli.h, plugged memeory leak and moved some code around to fix gcc warnings.
Also some white-space cleanup.

Modified:
    team/pabelanger/issue16343/include/asterisk/cli.h
    team/pabelanger/issue16343/include/asterisk/manager.h
    team/pabelanger/issue16343/main/manager.c

Modified: team/pabelanger/issue16343/include/asterisk/cli.h
URL: http://svnview.digium.com/svn/asterisk/team/pabelanger/issue16343/include/asterisk/cli.h?view=diff&rev=259663&r1=259662&r2=259663
==============================================================================
--- team/pabelanger/issue16343/include/asterisk/cli.h (original)
+++ team/pabelanger/issue16343/include/asterisk/cli.h Wed Apr 28 10:41:14 2010
@@ -56,6 +56,13 @@
  *     printf("we have %d object%s", n, ESS(n));
  */
 #define ESS(x) ((x) == 1 ? "" : "s")
+
+/*! \brief return Yes or No depending on the argument.
+ * This is used in many places in CLI command, having a function to generate
+ * this helps maintaining a consistent output (and possibly emitting the
+ * output in other languages, at some point).
+ */
+#define AST_CLI_YESNO(x) (x) ? "Yes" : "No"
 
 /*! \page CLI_command_API CLI command API
 

Modified: team/pabelanger/issue16343/include/asterisk/manager.h
URL: http://svnview.digium.com/svn/asterisk/team/pabelanger/issue16343/include/asterisk/manager.h?view=diff&rev=259663&r1=259662&r2=259663
==============================================================================
--- team/pabelanger/issue16343/include/asterisk/manager.h (original)
+++ team/pabelanger/issue16343/include/asterisk/manager.h Wed Apr 28 10:41:14 2010
@@ -91,13 +91,6 @@
 /*! \brief Manager Helper Function */
 typedef int (*manager_hook_t)(int, const char *, char *);
 
-/*! \brief return Yes or No depending on the argument.
- * This is used in many places in CLI command, having a function to generate
- * this helps maintaining a consistent output (and possibly emitting the
- * output in other languages, at some point).
- */
-#define AST_CLI_YESNO(x) x ? "Yes" : "No"
-
 struct manager_custom_hook {
 	/*! Identifier */
 	char *file;

Modified: team/pabelanger/issue16343/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/pabelanger/issue16343/main/manager.c?view=diff&rev=259663&r1=259662&r2=259663
==============================================================================
--- team/pabelanger/issue16343/main/manager.c (original)
+++ team/pabelanger/issue16343/main/manager.c Wed Apr 28 10:41:14 2010
@@ -740,10 +740,6 @@
 
 static AST_LIST_HEAD_STATIC(all_events, eventqent);
 
-static struct ast_tls_config ami_tls_cfg;
-static struct ast_tcptls_session_args ami_desc;
-static struct ast_tcptls_session_args amis_desc;
-
 static int displayconnects = 1;
 static int allowmultiplelogin = 1;
 static int timestampevents;
@@ -751,7 +747,7 @@
 static int broken_events_action = 0;
 static int manager_enabled = 0;
 static int webmanager_enabled = 0;
-static char* manager_channelvars = "";
+static char* manager_channelvars = NULL;
 
 #define DEFAULT_REALM		"asterisk"
 static char global_realm[MAXHOSTNAMELEN];	/*!< Default realm */
@@ -1362,7 +1358,6 @@
 	return CLI_SUCCESS;
 }
 
-
 static char *handle_showmanagers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct ast_manager_user *user = NULL;
@@ -1405,7 +1400,6 @@
 	return CLI_SUCCESS;
 }
 
-
 /*! \brief  CLI command  manager list commands */
 static char *handle_showmancmds(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
@@ -1518,61 +1512,6 @@
 	reload_manager();
 	return CLI_SUCCESS;
 }
-
-/*! \brief CLI command manager show settings */
-static char *handle_manager_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	switch (cmd) {
-	case CLI_INIT:
-		e->command = "manager show settings";
-		e->usage =
-			"Usage: manager show settings\n"
-			"       Provides detailed list of the configuration of the Manager.\n";
-		return NULL;
-	case CLI_GENERATE:
-		return NULL;
-	}
-#define FORMAT "  %-25.25s  %-15.15s\n"
-#define FORMAT2 "  %-25.25s  %-15d\n"
-	if (a->argc != 3) {
-		return CLI_SHOWUSAGE;
-	}
-	ast_cli(a->fd, "\nGlobal Settings:\n");
-	ast_cli(a->fd, "----------------\n");
-	ast_cli(a->fd, FORMAT, "Manager (AMI):", AST_CLI_YESNO(manager_enabled));
-	ast_cli(a->fd, FORMAT, "Web Manager (AMI/HTTP):", AST_CLI_YESNO(webmanager_enabled));
-	ast_cli(a->fd, FORMAT, "TCP Bindaddress:", ast_inet_ntoa(ami_desc.local_address.sin_addr));
-	ast_cli(a->fd, FORMAT2, "TCP Port:", ntohs(ami_desc.local_address.sin_port));
-	ast_cli(a->fd, FORMAT2, "HTTP Timeout (minutes):", httptimeout);
-	ast_cli(a->fd, FORMAT, "TLS Enable:", AST_CLI_YESNO(ami_tls_cfg.enabled));
-	ast_cli(a->fd, FORMAT, "TLS Bindaddress:", ast_inet_ntoa(amis_desc.local_address.sin_addr));
-	ast_cli(a->fd, FORMAT2, "TLS Port:", ntohs(amis_desc.local_address.sin_port));
-	ast_cli(a->fd, FORMAT, "TLS Certfile:", ami_tls_cfg.certfile);
-	ast_cli(a->fd, FORMAT, "TLS Privatekey:", ami_tls_cfg.pvtfile);
-	ast_cli(a->fd, FORMAT, "TLS Cipher:", ami_tls_cfg.cipher);
-	ast_cli(a->fd, FORMAT, "Allow multiple login:", AST_CLI_YESNO(allowmultiplelogin));
-	ast_cli(a->fd, FORMAT, "Display connects:", AST_CLI_YESNO(displayconnects));
-	ast_cli(a->fd, FORMAT, "Timestamp events:", AST_CLI_YESNO(timestampevents));
-	ast_cli(a->fd, FORMAT, "Channel vars:", manager_channelvars);
-	ast_cli(a->fd, FORMAT, "Debug:", AST_CLI_YESNO(manager_debug));
-	ast_cli(a->fd, FORMAT, "Block sockets:", AST_CLI_YESNO(block_sockets));
-#undef FORMAT
-#undef FORMAT2
-
-	return CLI_SUCCESS;
-}
-
-static struct ast_cli_entry cli_manager[] = {
-	AST_CLI_DEFINE(handle_showmancmd, "Show a manager interface command"),
-	AST_CLI_DEFINE(handle_showmancmds, "List manager interface commands"),
-	AST_CLI_DEFINE(handle_showmanconn, "List connected manager interface users"),
-	AST_CLI_DEFINE(handle_showmaneventq, "List manager interface queued events"),
-	AST_CLI_DEFINE(handle_showmanagers, "List configured manager users"),
-	AST_CLI_DEFINE(handle_showmanager, "Display information on a specific manager user"),
-	AST_CLI_DEFINE(handle_mandebug, "Show, enable, disable debugging of the manager code"),
-	AST_CLI_DEFINE(handle_manager_reload, "Reload manager configurations"),
-	AST_CLI_DEFINE(handle_manager_show_settings, "Show manager global settings"),
-};
 
 static struct eventqent *unref_event(struct eventqent *e)
 {
@@ -5585,6 +5524,7 @@
 	purge_events();
 }
 
+static struct ast_tls_config ami_tls_cfg;
 static struct ast_tcptls_session_args ami_desc = {
 	.accept_fd = -1,
 	.master = AST_PTHREADT_NULL,
@@ -5604,6 +5544,61 @@
 	.name = "AMI TLS server",
 	.accept_fn = ast_tcptls_server_root,	/* thread doing the accept() */
 	.worker_fn = session_do,	/* thread handling the session */
+};
+
+/*! \brief CLI command manager show settings */
+static char *handle_manager_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "manager show settings";
+		e->usage =
+			"Usage: manager show settings\n"
+			"       Provides detailed list of the configuration of the Manager.\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+#define FORMAT "  %-25.25s  %-15.15s\n"
+#define FORMAT2 "  %-25.25s  %-15d\n"
+	if (a->argc != 3) {
+		return CLI_SHOWUSAGE;
+	}
+	ast_cli(a->fd, "\nGlobal Settings:\n");
+	ast_cli(a->fd, "----------------\n");
+	ast_cli(a->fd, FORMAT, "Manager (AMI):", AST_CLI_YESNO(manager_enabled));
+	ast_cli(a->fd, FORMAT, "Web Manager (AMI/HTTP):", AST_CLI_YESNO(webmanager_enabled));
+	ast_cli(a->fd, FORMAT, "TCP Bindaddress:", ast_inet_ntoa(ami_desc.local_address.sin_addr));
+	ast_cli(a->fd, FORMAT2, "TCP Port:", ntohs(ami_desc.local_address.sin_port));
+	ast_cli(a->fd, FORMAT2, "HTTP Timeout (minutes):", httptimeout);
+	ast_cli(a->fd, FORMAT, "TLS Enable:", AST_CLI_YESNO(ami_tls_cfg.enabled));
+	ast_cli(a->fd, FORMAT, "TLS Bindaddress:", ast_inet_ntoa(amis_desc.local_address.sin_addr));
+	ast_cli(a->fd, FORMAT2, "TLS Port:", ntohs(amis_desc.local_address.sin_port));
+	ast_cli(a->fd, FORMAT, "TLS Certfile:", ami_tls_cfg.certfile);
+	ast_cli(a->fd, FORMAT, "TLS Privatekey:", ami_tls_cfg.pvtfile);
+	ast_cli(a->fd, FORMAT, "TLS Cipher:", ami_tls_cfg.cipher);
+	ast_cli(a->fd, FORMAT, "Allow multiple login:", AST_CLI_YESNO(allowmultiplelogin));
+	ast_cli(a->fd, FORMAT, "Display connects:", AST_CLI_YESNO(displayconnects));
+	ast_cli(a->fd, FORMAT, "Timestamp events:", AST_CLI_YESNO(timestampevents));
+	ast_cli(a->fd, FORMAT, "Channel vars:", S_OR(manager_channelvars, ""));
+	ast_cli(a->fd, FORMAT, "Debug:", AST_CLI_YESNO(manager_debug));
+	ast_cli(a->fd, FORMAT, "Block sockets:", AST_CLI_YESNO(block_sockets));
+#undef FORMAT
+#undef FORMAT2
+
+	return CLI_SUCCESS;
+}
+
+static struct ast_cli_entry cli_manager[] = {
+	AST_CLI_DEFINE(handle_showmancmd, "Show a manager interface command"),
+	AST_CLI_DEFINE(handle_showmancmds, "List manager interface commands"),
+	AST_CLI_DEFINE(handle_showmanconn, "List connected manager interface users"),
+	AST_CLI_DEFINE(handle_showmaneventq, "List manager interface queued events"),
+	AST_CLI_DEFINE(handle_showmanagers, "List configured manager users"),
+	AST_CLI_DEFINE(handle_showmanager, "Display information on a specific manager user"),
+	AST_CLI_DEFINE(handle_mandebug, "Show, enable, disable debugging of the manager code"),
+	AST_CLI_DEFINE(handle_manager_reload, "Reload manager configurations"),
+	AST_CLI_DEFINE(handle_manager_show_settings, "Show manager global settings"),
 };
 
 static int __init_manager(int reload)
@@ -5730,6 +5725,7 @@
 		} else if (!strcasecmp(var->name, "channelvars")) {
 			struct manager_channel_variable *mcv;
 			char *remaining = ast_strdupa(val), *next;
+			ast_free(manager_channelvars);
 			manager_channelvars = ast_strdup(val);
 			AST_RWLIST_WRLOCK(&channelvars);
 			while ((next = strsep(&remaining, ",|"))) {




More information about the svn-commits mailing list