diff options
author | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-10 20:34:18 +0000 |
---|---|---|
committer | rizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-05-10 20:34:18 +0000 |
commit | 17c63393f04268758837433cea4e5a557d3211c9 (patch) | |
tree | 6ba70a5a4254faec7c583a5a8788d5c285cad1b1 /pbx.c | |
parent | 13dba7e5eebb9ddec240c49213b95bd47b6b8c45 (diff) |
lots of comments trying to document the agreed behaviour of
E_MATCHMORE and '!'.
If the comments are correct, the code must be slightly changed
(simplified).
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@26624 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx.c')
-rw-r--r-- | pbx.c | 31 |
1 files changed, 20 insertions, 11 deletions
@@ -569,6 +569,12 @@ static void pbx_destroy(struct ast_pbx *p) * a pattern. * ! zero or more of anything. Also impacts the result of CANMATCH * and MATCHMORE. Only allowed at the end of a pattern. + * In the core routine, ! causes a match with a return code of 2. + * In turn, depending on the search mode: (XXX check if it is implemented) + * - E_MATCH retuns 1 (does match) + * - E_MATCHMORE returns 0 (no match) + * - E_CANMATCH returns 1 (does match) + * * / should not appear as it is considered the separator of the CID info. * XXX at the moment we may stop on this char. * @@ -939,22 +945,25 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan, } if (q->status < STATUS_NO_EXTENSION) q->status = STATUS_NO_EXTENSION; + + /* scan the list trying to match extension and CID */ for (eroot = tmp->root; eroot; eroot = eroot->next) { - int match; - /* Match extension */ - if ( (match = extension_match_core(eroot->exten, exten, action)) && - (!eroot->matchcid || matchcid(eroot->cidmatch, callerid))) { - - if (action == E_MATCHMORE && match == 2 && !earlymatch) { - /* XXX not sure the logic is correct here. - * we should go in irrespective of earlymatch + int match = extension_match_core(eroot->exten, exten, action); + /* 0 on fail, 1 on match, 2 on earlymatch */ + + if (match && (!eroot->matchcid || matchcid(eroot->cidmatch, callerid))) { + if (match == 2 && action == E_MATCHMORE && !earlymatch) { + /* Match an extension ending in '!'. + * As far as I can tell the decision in this case is final + * and we should just return NULL to mark failure + * (and get rid of the earlymatch variable and the associated + * processing outside the loop). */ - /* It matched an extension ending in a '!' wildcard - So ignore it for now, unless there's a better match */ earlymatch = eroot; } else { if (q->status < STATUS_NO_PRIORITY) q->status = STATUS_NO_PRIORITY; + /* now look for the right priority */ for (e = eroot; e; e = e->peer) { /* Match priority */ if (action == E_FINDLABEL) { @@ -1000,7 +1009,7 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan, aswf = asw->canmatch; else if (action == E_MATCHMORE) aswf = asw->matchmore; - else + else /* action == E_MATCH */ aswf = asw->exists; datap = sw->eval ? sw->tmpdata : sw->data; res = !aswf ? 0 : aswf(chan, context, exten, priority, callerid, datap); |