fix indentation of a large block.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@25715 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Luigi Rizzo
2006-05-08 21:09:03 +00:00
parent 92fb3ef889
commit 8a0476c335

143
pbx.c
View File

@@ -758,86 +758,85 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan,
if (!tmp) if (!tmp)
return NULL; return NULL;
} }
/* XXX fix indentation */
if (*status < STATUS_NO_EXTENSION) if (*status < STATUS_NO_EXTENSION)
*status = STATUS_NO_EXTENSION; *status = STATUS_NO_EXTENSION;
for (eroot = tmp->root; eroot; eroot = eroot->next) { for (eroot = tmp->root; eroot; eroot = eroot->next) {
int match = 0; int match = 0;
/* Match extension */ /* Match extension */
if ((((action != HELPER_MATCHMORE) && ast_extension_match(eroot->exten, exten)) || if ((((action != HELPER_MATCHMORE) && ast_extension_match(eroot->exten, exten)) ||
((action == HELPER_CANMATCH) && (ast_extension_close(eroot->exten, exten, 0))) || ((action == HELPER_CANMATCH) && (ast_extension_close(eroot->exten, exten, 0))) ||
((action == HELPER_MATCHMORE) && (match = ast_extension_close(eroot->exten, exten, 1)))) && ((action == HELPER_MATCHMORE) && (match = ast_extension_close(eroot->exten, exten, 1)))) &&
(!eroot->matchcid || matchcid(eroot->cidmatch, callerid))) { (!eroot->matchcid || matchcid(eroot->cidmatch, callerid))) {
if (action == HELPER_MATCHMORE && match == 2 && !earlymatch) { if (action == HELPER_MATCHMORE && match == 2 && !earlymatch) {
/* It matched an extension ending in a '!' wildcard /* It matched an extension ending in a '!' wildcard
So ignore it for now, unless there's a better match */ So ignore it for now, unless there's a better match */
earlymatch = eroot; earlymatch = eroot;
} else { } else {
if (*status < STATUS_NO_PRIORITY) if (*status < STATUS_NO_PRIORITY)
*status = STATUS_NO_PRIORITY; *status = STATUS_NO_PRIORITY;
for (e = eroot; e; e = e->peer) { for (e = eroot; e; e = e->peer) {
/* Match priority */ /* Match priority */
if (action == HELPER_FINDLABEL) { if (action == HELPER_FINDLABEL) {
if (*status < STATUS_NO_LABEL) if (*status < STATUS_NO_LABEL)
*status = STATUS_NO_LABEL; *status = STATUS_NO_LABEL;
if (label && e->label && !strcmp(label, e->label)) { if (label && e->label && !strcmp(label, e->label)) {
*status = STATUS_SUCCESS; *status = STATUS_SUCCESS;
*foundcontext = context; *foundcontext = context;
return e; return e;
}
} else if (e->priority == priority) {
*status = STATUS_SUCCESS;
*foundcontext = context;
return e;
}
} }
} else if (e->priority == priority) {
*status = STATUS_SUCCESS;
*foundcontext = context;
return e;
} }
} }
} }
if (earlymatch) { }
/* Bizarre logic for HELPER_MATCHMORE. We return zero to break out }
of the loop waiting for more digits, and _then_ match (normally) if (earlymatch) {
the extension we ended up with. We got an early-matching wildcard /* Bizarre logic for HELPER_MATCHMORE. We return zero to break out
pattern, so return NULL to break out of the loop. */ of the loop waiting for more digits, and _then_ match (normally)
the extension we ended up with. We got an early-matching wildcard
pattern, so return NULL to break out of the loop. */
return NULL;
}
/* Check alternative switches */
AST_LIST_TRAVERSE(&tmp->alts, sw, list) {
if ((asw = pbx_findswitch(sw->name))) {
/* Substitute variables now */
if (sw->eval)
pbx_substitute_variables_helper(chan, sw->data, sw->tmpdata, SWITCH_DATA_LENGTH - 1);
if (action == HELPER_CANMATCH)
res = asw->canmatch ? asw->canmatch(chan, context, exten, priority, callerid, sw->eval ? sw->tmpdata : sw->data) : 0;
else if (action == HELPER_MATCHMORE)
res = asw->matchmore ? asw->matchmore(chan, context, exten, priority, callerid, sw->eval ? sw->tmpdata : sw->data) : 0;
else
res = asw->exists ? asw->exists(chan, context, exten, priority, callerid, sw->eval ? sw->tmpdata : sw->data) : 0;
if (res) {
/* Got a match */
*swo = asw;
*data = sw->eval ? sw->tmpdata : sw->data;
*foundcontext = context;
return NULL; return NULL;
} }
/* Check alternative switches */ } else {
AST_LIST_TRAVERSE(&tmp->alts, sw, list) { ast_log(LOG_WARNING, "No such switch '%s'\n", sw->name);
if ((asw = pbx_findswitch(sw->name))) { }
/* Substitute variables now */ }
if (sw->eval) /* Setup the stack */
pbx_substitute_variables_helper(chan, sw->data, sw->tmpdata, SWITCH_DATA_LENGTH - 1); incstack[*stacklen] = tmp->name;
if (action == HELPER_CANMATCH) (*stacklen)++;
res = asw->canmatch ? asw->canmatch(chan, context, exten, priority, callerid, sw->eval ? sw->tmpdata : sw->data) : 0; /* Now try any includes we have in this context */
else if (action == HELPER_MATCHMORE) for (i = tmp->includes; i; i = i->next) {
res = asw->matchmore ? asw->matchmore(chan, context, exten, priority, callerid, sw->eval ? sw->tmpdata : sw->data) : 0; if (include_valid(i)) {
else if ((e = pbx_find_extension(chan, bypass, i->rname, exten, priority, label, callerid, action, incstack, stacklen, status, swo, data, foundcontext)))
res = asw->exists ? asw->exists(chan, context, exten, priority, callerid, sw->eval ? sw->tmpdata : sw->data) : 0; return e;
if (res) { if (*swo)
/* Got a match */ return NULL;
*swo = asw; }
*data = sw->eval ? sw->tmpdata : sw->data; }
*foundcontext = context;
return NULL;
}
} else {
ast_log(LOG_WARNING, "No such switch '%s'\n", sw->name);
}
}
/* Setup the stack */
incstack[*stacklen] = tmp->name;
(*stacklen)++;
/* Now try any includes we have in this context */
for (i = tmp->includes; i; i = i->next) {
if (include_valid(i)) {
if ((e = pbx_find_extension(chan, bypass, i->rname, exten, priority, label, callerid, action, incstack, stacklen, status, swo, data, foundcontext)))
return e;
if (*swo)
return NULL;
}
}
return NULL; return NULL;
} }