[asterisk-commits] trunk r25683 - /trunk/pbx.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon May 8 13:49:30 MST 2006


Author: rizzo
Date: Mon May  8 15:49:30 2006
New Revision: 25683

URL: http://svn.digium.com/view/asterisk?rev=25683&view=rev
Log:
minor code restructuring in preparation for more work.


Modified:
    trunk/pbx.c

Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=25683&r1=25682&r2=25683&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Mon May  8 15:49:30 2006
@@ -716,7 +716,12 @@
 	return ast_extension_match(cidpattern, callerid);
 }
 
-static struct ast_exten *pbx_find_extension(struct ast_channel *chan, struct ast_context *bypass, const char *context, const char *exten, int priority, const char *label, const char *callerid, int action, char *incstack[], int *stacklen, int *status, struct ast_switch **swo, char **data, const char **foundcontext)
+static struct ast_exten *pbx_find_extension(struct ast_channel *chan,
+	struct ast_context *bypass,
+	const char *context, const char *exten, int priority,
+	const char *label, const char *callerid, int action,
+	char *incstack[], int *stacklen, int *status, struct ast_switch **swo,
+	char **data, const char **foundcontext)
 {
 	int x, res;
 	struct ast_context *tmp;
@@ -725,6 +730,8 @@
 	struct ast_sw *sw;
 	struct ast_switch *asw;
 
+	struct ast_exten *earlymatch = NULL;
+
 	/* Initialize status if appropriate */
 	if (!*stacklen) {
 		*status = STATUS_NO_CONTEXT;
@@ -741,14 +748,17 @@
 		if (!strcasecmp(incstack[x], context))
 			return NULL;
 	}
-	if (bypass)
+	if (bypass)	/* bypass means we only look there */
 		tmp = bypass;
-	else
-		tmp = contexts;
-	for (; tmp; tmp = tmp->next) {
-		/* Match context */
-		if (bypass || !strcmp(tmp->name, context)) {
-			struct ast_exten *earlymatch = NULL;
+	else {	/* look in contexts */
+		for (tmp = contexts; tmp; tmp = tmp->next) {
+			if (!strcmp(tmp->name, context))
+				break;
+		}
+		if (!tmp)
+			return NULL;
+	}
+			/* XXX fix indentation */
 
 			if (*status < STATUS_NO_EXTENSION)
 				*status = STATUS_NO_EXTENSION;
@@ -828,9 +838,7 @@
 						return NULL;
 				}
 			}
-			break;
-		}
-	}
+
 	return NULL;
 }
 
@@ -878,6 +886,7 @@
 
 	ast_copy_string(workspace, value, workspace_len); /* always make a copy */
 
+	/* Quick check if no need to do anything */
 	if (offset == 0 && length < 0)	/* take the whole string */
 		return ret;
 



More information about the asterisk-commits mailing list