dect
/
asterisk
Archived
13
0
Fork 0

Allow you to use labels with + to be nice to Tilghman.

git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3897 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
markster 2004-10-03 16:15:44 +00:00
parent f60cf13e7f
commit c2b1557a20
4 changed files with 39 additions and 24 deletions

View File

@ -315,9 +315,10 @@ include => demo
;exten => 6245,hint,SIP/Grandstream1&SIP/Xlite1 ; Channel hints for presence
;exten => 6245,1,Dial(SIP/Grandstream1,20,rt) ; permit transfer
;exten => 6245,n,Dial(${HINT},20,rtT) ; Use hint as listed
;exten => 6245,n(dial),Dial(${HINT},20,rtT) ; Use hint as listed
;exten => 6245,n,Voicemail(u6245) ; Voicemail (unavailable)
;exten => 6245,s+100,Voicemail(b6245) ; Voicemail (busy)
;exten => 6245,s+1,Hangup ; s+1, same as n
;exten => 6245,dial+101,Voicemail(b6245) ; Voicemail (busy)
;exten => 6361,1,Dial(IAX2/JaneDoe,,rm) ; ring without time limit
;exten => 6389,1,Dial(MGCP/aaln/1@192.168.0.14)
;exten => 6394,1,Dial(Local/6275/n) ; this will dial ${MARK}

View File

@ -297,6 +297,8 @@ int ast_exists_extension(struct ast_channel *c, const char *context, const char
\ */
int ast_findlabel_extension(struct ast_channel *c, const char *context, const char *exten, const char *label, const char *callerid);
int ast_findlabel_extension2(struct ast_channel *c, struct ast_context *con, const char *exten, const char *label, const char *callerid);
//! Looks for a valid matching extension
/*!
\param c not really important

36
pbx.c
View File

@ -719,7 +719,7 @@ 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, 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)
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)
{
int x, res;
struct ast_context *tmp;
@ -744,10 +744,13 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan, const char
if (!strcasecmp(incstack[x], context))
return NULL;
}
tmp = contexts;
if (bypass)
tmp = bypass;
else
tmp = contexts;
while(tmp) {
/* Match context */
if (!strcmp(tmp->name, context)) {
if (bypass || !strcmp(tmp->name, context)) {
if (*status < STATUS_NO_EXTENSION)
*status = STATUS_NO_EXTENSION;
eroot = tmp->root;
@ -806,13 +809,14 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan, const char
i = tmp->includes;
while(i) {
if (include_valid(i)) {
if ((e = pbx_find_extension(chan, i->rname, exten, priority, label, callerid, action, incstack, stacklen, status, swo, data)))
if ((e = pbx_find_extension(chan, bypass, i->rname, exten, priority, label, callerid, action, incstack, stacklen, status, swo, data)))
return e;
if (*swo)
return NULL;
}
i = i->next;
}
break;
}
tmp = tmp->next;
}
@ -1227,7 +1231,7 @@ static void pbx_substitute_variables(char *passdata, int datalen, struct ast_cha
pbx_substitute_variables_helper(c, e->data, passdata, datalen - 1);
}
static int pbx_extension_helper(struct ast_channel *c, const char *context, const char *exten, int priority, const char *label, const char *callerid, int action)
static int pbx_extension_helper(struct ast_channel *c, struct ast_context *con, const char *context, const char *exten, int priority, const char *label, const char *callerid, int action)
{
struct ast_exten *e;
struct ast_app *app;
@ -1250,7 +1254,7 @@ static int pbx_extension_helper(struct ast_channel *c, const char *context, cons
else
return -1;
}
e = pbx_find_extension(c, context, exten, priority, label, callerid, action, incstack, &stacklen, &status, &sw, &data);
e = pbx_find_extension(c, con, context, exten, priority, label, callerid, action, incstack, &stacklen, &status, &sw, &data);
if (e) {
switch(action) {
case HELPER_CANMATCH:
@ -1351,7 +1355,8 @@ static int pbx_extension_helper(struct ast_channel *c, const char *context, cons
ast_log(LOG_NOTICE, "No such priority %d in extension '%s' in context '%s'\n", priority, exten, context);
break;
case STATUS_NO_LABEL:
ast_log(LOG_NOTICE, "No such label '%s' in extension '%s' in context '%s'\n", label, exten, context);
if (context)
ast_log(LOG_NOTICE, "No such label '%s' in extension '%s' in context '%s'\n", label, exten, context);
break;
default:
ast_log(LOG_DEBUG, "Shouldn't happen!\n");
@ -1378,7 +1383,7 @@ static struct ast_exten *ast_hint_extension(struct ast_channel *c, const char *c
ast_log(LOG_WARNING, "Unable to obtain lock\n");
return NULL;
}
e = pbx_find_extension(c, context, exten, PRIORITY_HINT, NULL, "", HELPER_EXISTS, incstack, &stacklen, &status, &sw, &data);
e = pbx_find_extension(c, NULL, context, exten, PRIORITY_HINT, NULL, "", HELPER_EXISTS, incstack, &stacklen, &status, &sw, &data);
ast_mutex_unlock(&conlock);
return e;
}
@ -1768,27 +1773,32 @@ int ast_get_hint(char *hint, int hintsize, struct ast_channel *c, const char *co
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
{
return pbx_extension_helper(c, context, exten, priority, NULL, callerid, HELPER_EXISTS);
return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, HELPER_EXISTS);
}
int ast_findlabel_extension(struct ast_channel *c, const char *context, const char *exten, const char *label, const char *callerid)
{
return pbx_extension_helper(c, context, exten, 0, label, callerid, HELPER_FINDLABEL);
return pbx_extension_helper(c, NULL, context, exten, 0, label, callerid, HELPER_FINDLABEL);
}
int ast_findlabel_extension2(struct ast_channel *c, struct ast_context *con, const char *exten, const char *label, const char *callerid)
{
return pbx_extension_helper(c, con, NULL, exten, 0, label, callerid, HELPER_FINDLABEL);
}
int ast_canmatch_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
{
return pbx_extension_helper(c, context, exten, priority, NULL, callerid, HELPER_CANMATCH);
return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, HELPER_CANMATCH);
}
int ast_matchmore_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
{
return pbx_extension_helper(c, context, exten, priority, NULL, callerid, HELPER_MATCHMORE);
return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, HELPER_MATCHMORE);
}
int ast_spawn_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
{
return pbx_extension_helper(c, context, exten, priority, NULL, callerid, HELPER_SPAWN);
return pbx_extension_helper(c, NULL, context, exten, priority, NULL, callerid, HELPER_SPAWN);
}
int ast_pbx_run(struct ast_channel *c)

View File

@ -17,6 +17,7 @@
#include <asterisk/module.h>
#include <asterisk/logger.h>
#include <asterisk/cli.h>
#include <asterisk/callerid.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@ -1656,6 +1657,12 @@ static int pbx_load_module(void)
ext = strsep(&stringp, ",");
if (!ext)
ext="";
cidmatch = strchr(ext, '/');
if (cidmatch) {
*cidmatch = '\0';
cidmatch++;
ast_shrink_phone_number(cidmatch);
}
pri = strsep(&stringp, ",");
if (!pri)
pri="";
@ -1688,8 +1695,10 @@ static int pbx_load_module(void)
ast_log(LOG_WARNING, "Can't use 'same' priority on the first entry!\n");
} else {
if (sscanf(pri, "%i", &ipri) != 1) {
ast_log(LOG_WARNING, "Invalid priority '%s' at line %d\n", pri, v->lineno);
ipri = 0;
if ((ipri = ast_findlabel_extension2(NULL, con, ext, pri, cidmatch)) < 1) {
ast_log(LOG_WARNING, "Invalid priority/label '%s' at line %d\n", pri, v->lineno);
ipri = 0;
}
}
}
appl = stringp;
@ -1715,13 +1724,6 @@ static int pbx_load_module(void)
else
data = "";
}
cidmatch = strchr(ext, '/');
if (cidmatch) {
*cidmatch = '\0';
cidmatch++;
}
stringp=ext;
strsep(&stringp, "/");
if (!data)
data="";