From d54ec2ced4eef8ec18a6689777e04a2f65a1348d Mon Sep 17 00:00:00 2001 From: Luigi Rizzo <rizzo@icir.org> Date: Mon, 8 May 2006 20:49:30 +0000 Subject: [PATCH] minor code restructuring in preparation for more work. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@25683 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- pbx.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/pbx.c b/pbx.c index b563d3f309..dfca8980e3 100644 --- a/pbx.c +++ b/pbx.c @@ -716,7 +716,12 @@ static int matchcid(const char *cidpattern, const char *callerid) 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 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan, struct ast 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 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan, struct ast 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 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan, struct ast return NULL; } } - break; - } - } + return NULL; } @@ -878,6 +886,7 @@ static char *substring(const char *value, int offset, int length, char *workspac 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; -- GitLab