[asterisk-commits] jrose: trunk r312680 - /trunk/pbx/pbx_config.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Apr 4 12:37:51 CDT 2011


Author: jrose
Date: Mon Apr  4 12:37:47 2011
New Revision: 312680

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=312680
Log:
In handle_cli_dialplan_add_extension, const char pointer *into_context is used instead of a->argv[5] to improve readability.

Modified:
    trunk/pbx/pbx_config.c

Modified: trunk/pbx/pbx_config.c
URL: http://svnview.digium.com/svn/asterisk/trunk/pbx/pbx_config.c?view=diff&rev=312680&r1=312679&r2=312680
==============================================================================
--- trunk/pbx/pbx_config.c (original)
+++ trunk/pbx/pbx_config.c Mon Apr  4 12:37:47 2011
@@ -905,6 +905,7 @@
 	int iprior = -2;
 	char *cidmatch, *app, *app_data;
 	char *start, *end;
+	const char *into_context;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -968,20 +969,22 @@
 
 	if (!exten || !prior || !app || (!app_data && iprior != PRIORITY_HINT))
 		return CLI_SHOWUSAGE;
-
-	if (!ast_context_find(a->argv[5])) {
-		ast_cli(a->fd, "Context '%s' did not exist prior to add extension - the context will be created.\n", a->argv[5]);
-	}
-
-	if (!ast_context_find_or_create(NULL, NULL, a->argv[5], registrar)) {
+	
+	into_context = a->argv[5];
+
+	if (!ast_context_find(into_context)) {
+		ast_cli(a->fd, "Context '%s' did not exist prior to add extension - the context will be created.\n", into_context);
+	}
+
+	if (!ast_context_find_or_create(NULL, NULL, into_context, registrar)) {
 		ast_cli(a->fd, "ast_context_find_or_create() failed\n");
-		ast_cli(a->fd, "Failed to add '%s,%s,%s,%s' extension into '%s' context\n", exten, prior, app, app_data, a->argv[5]);
+		ast_cli(a->fd, "Failed to add '%s,%s,%s,%s' extension into '%s' context\n", exten, prior, app, app_data, into_context);
 		return CLI_FAILURE;
 	}
 
 	if (!app_data)
 		app_data="";
-	if (ast_add_extension(a->argv[5], a->argc == 7 ? 1 : 0, exten, iprior, NULL, cidmatch, app,
+	if (ast_add_extension(into_context, a->argc == 7 ? 1 : 0, exten, iprior, NULL, cidmatch, app,
 		(void *)strdup(app_data), ast_free_ptr, registrar)) {
 		switch (errno) {
 		case ENOMEM:
@@ -993,17 +996,17 @@
 			break;
 
 		case ENOENT:
-			ast_cli(a->fd, "No existence of '%s' context\n", a->argv[5]);
+			ast_cli(a->fd, "No existence of '%s' context\n", into_context);
 			break;
 
 		case EEXIST:
 			ast_cli(a->fd, "Extension %s@%s with priority %s already exists\n",
-				exten, a->argv[5], prior);
+				exten, into_context, prior);
 			break;
 
 		default:
 			ast_cli(a->fd, "Failed to add '%s,%s,%s,%s' extension into '%s' context\n",
-					exten, prior, app, app_data, a->argv[5]);
+					exten, prior, app, app_data, into_context);
 			break;
 		}
 		return CLI_FAILURE;
@@ -1011,10 +1014,10 @@
 
 	if (a->argc == 7)
 		ast_cli(a->fd, "Extension %s@%s (%s) replace by '%s,%s,%s,%s'\n",
-			exten, a->argv[5], prior, exten, prior, app, app_data);
+			exten, into_context, prior, exten, prior, app, app_data);
 	else
 		ast_cli(a->fd, "Extension '%s,%s,%s,%s' added into '%s' context\n",
-			exten, prior, app, app_data, a->argv[5]);
+			exten, prior, app, app_data, into_context);
 
 	return CLI_SUCCESS;
 }




More information about the asterisk-commits mailing list