[svn-commits] tilghman: branch 1.6.0 r121281 - in /branches/1.6.0: ./ main/pbx.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Jun 9 11:36:25 CDT 2008
Author: tilghman
Date: Mon Jun 9 11:36:24 2008
New Revision: 121281
URL: http://svn.digium.com/view/asterisk?view=rev&rev=121281
Log:
Merged revisions 121279 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r121279 | tilghman | 2008-06-09 11:35:06 -0500 (Mon, 09 Jun 2008) | 6 lines
Implement FINDLABEL matching for the new extension matching engine.
(closes issue #12800)
Reported by: chris-mac
Patches:
20080608__bug12800.diff.txt uploaded by Corydon76 (license 14)
........
Modified:
branches/1.6.0/ (props changed)
branches/1.6.0/main/pbx.c
Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.
Modified: branches/1.6.0/main/pbx.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/main/pbx.c?view=diff&rev=121281&r1=121280&r2=121281
==============================================================================
--- branches/1.6.0/main/pbx.c (original)
+++ branches/1.6.0/main/pbx.c Mon Jun 9 11:36:24 2008
@@ -321,7 +321,7 @@
int pbx_builtin_setvar_multiple(struct ast_channel *, void *);
static int pbx_builtin_importvar(struct ast_channel *, void *);
static void set_ext_pri(struct ast_channel *c, const char *exten, int pri);
-static void new_find_extension(const char *str, struct scoreboard *score, struct match_char *tree, int length, int spec, const char *callerid, enum ext_match_t action);
+static void new_find_extension(const char *str, struct scoreboard *score, struct match_char *tree, int length, int spec, const char *callerid, const char *label, enum ext_match_t action);
static struct match_char *already_in_tree(struct match_char *current, char *pat);
static struct match_char *add_exten_to_pattern_tree(struct ast_context *con, struct ast_exten *e1, int findonly);
static struct match_char *add_pattern_node(struct ast_context *con, struct match_char *current, char *pattern, int is_pattern, int already, int specificity, struct match_char **parent);
@@ -1018,9 +1018,10 @@
#endif
-static void new_find_extension(const char *str, struct scoreboard *score, struct match_char *tree, int length, int spec, const char *callerid, enum ext_match_t action)
+static void new_find_extension(const char *str, struct scoreboard *score, struct match_char *tree, int length, int spec, const char *label, const char *callerid, enum ext_match_t action)
{
struct match_char *p; /* note minimal stack storage requirements */
+ struct ast_exten pattern = { .label = label };
#ifdef DEBUG_THIS
if (tree)
ast_log(LOG_NOTICE,"new_find_extension called with %s on (sub)tree %s action=%s\n", str, tree->x, action2str(action));
@@ -1032,11 +1033,18 @@
if (p->x[1] == 0 && *str >= '2' && *str <= '9' ) {
#define NEW_MATCHER_CHK_MATCH \
if (p->exten && !(*(str+1))) { /* if a shorter pattern matches along the way, might as well report it */ \
- if (action == E_MATCH || action == E_SPAWN) { /* if in CANMATCH/MATCHMORE, don't let matches get in the way */ \
+ if (action == E_MATCH || action == E_SPAWN || action == E_FINDLABEL) { /* if in CANMATCH/MATCHMORE, don't let matches get in the way */ \
update_scoreboard(score, length+1, spec+p->specificity, p->exten,0,callerid, p->deleted, p); \
if (!p->deleted) { \
- ast_debug(4,"returning an exact match-- first found-- %s\n", p->exten->exten); \
- return; /* the first match, by definition, will be the best, because of the sorted tree */ \
+ if (action == E_FINDLABEL) { \
+ if (ast_hashtab_lookup(score->exten->peer_label_tree, &pattern)) { \
+ ast_debug(4, "Found label in preferred extension\n"); \
+ return; \
+ } \
+ } else { \
+ ast_debug(4,"returning an exact match-- first found-- %s\n", p->exten->exten); \
+ return; /* the first match, by definition, will be the best, because of the sorted tree */ \
+ } \
} \
} \
}
@@ -1045,13 +1053,13 @@
if (p->next_char && ( *(str+1) || (p->next_char->x[0] == '/' && p->next_char->x[1] == 0) \
|| p->next_char->x[0] == '!')) { \
if (*(str+1) || p->next_char->x[0] == '!') { \
- new_find_extension(str+1, score, p->next_char, length+1, spec+p->specificity, callerid, action); \
+ new_find_extension(str+1, score, p->next_char, length+1, spec+p->specificity, callerid, label, action); \
if (score->exten) { \
ast_debug(4,"returning an exact match-- %s\n", score->exten->exten); \
return; /* the first match is all we need */ \
} \
} else { \
- new_find_extension("/", score, p->next_char, length+1, spec+p->specificity, callerid, action); \
+ new_find_extension("/", score, p->next_char, length+1, spec+p->specificity, callerid, label, action); \
if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) { \
ast_debug(4,"returning a (can/more) match--- %s\n", score->exten ? score->exten->exten : \
"NULL"); \
@@ -1096,7 +1104,7 @@
}
}
if (p->next_char && p->next_char->x[0] == '/' && p->next_char->x[1] == 0) {
- new_find_extension("/", score, p->next_char, length+i, spec+(p->specificity*i), callerid, action);
+ new_find_extension("/", score, p->next_char, length+i, spec+(p->specificity*i), callerid, label, action);
if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) {
ast_debug(4,"return because scoreboard has exact match OR CANMATCH/MATCHMORE & canmatch set--- %s\n", score->exten ? score->exten->exten : "NULL");
return; /* the first match is all we need */
@@ -1118,7 +1126,7 @@
}
}
if (p->next_char && p->next_char->x[0] == '/' && p->next_char->x[1] == 0) {
- new_find_extension("/", score, p->next_char, length+i, spec+(p->specificity*i), callerid, action);
+ new_find_extension("/", score, p->next_char, length+i, spec+(p->specificity*i), callerid, label, action);
if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) {
ast_debug(4,"return because scoreboard has exact match OR CANMATCH/MATCHMORE & canmatch set with '/' and '!'--- %s\n", score->exten ? score->exten->exten : "NULL");
return; /* the first match is all we need */
@@ -1127,13 +1135,14 @@
} else if (p->x[0] == '/' && p->x[1] == 0) {
/* the pattern in the tree includes the cid match! */
if (p->next_char && callerid && *callerid) {
- new_find_extension(callerid, score, p->next_char, length+1, spec, callerid, action);
+ new_find_extension(callerid, score, p->next_char, length+1, spec, callerid, label, action);
if (score->exten || ((action == E_CANMATCH || action == E_MATCHMORE) && score->canmatch)) {
ast_debug(4,"return because scoreboard has exact match OR CANMATCH/MATCHMORE & canmatch set with '/'--- %s\n", score->exten ? score->exten->exten : "NULL");
return; /* the first match is all we need */
}
}
} else if (index(p->x, *str)) {
+ ast_debug(4, "Nothing strange about this match\n");
NEW_MATCHER_CHK_MATCH;
NEW_MATCHER_RECURSE;
}
@@ -1894,7 +1903,7 @@
#endif
if (extenpatternmatchnew) {
- new_find_extension(exten, &score, tmp->pattern_tree, 0, 0, callerid, action);
+ new_find_extension(exten, &score, tmp->pattern_tree, 0, 0, callerid, label, action);
eroot = score.exten;
if (score.last_char == '!' && action == E_MATCHMORE) {
More information about the svn-commits
mailing list