mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 02:26:23 +00:00
Allow you to use labels with + to be nice to Tilghman.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3897 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -315,9 +315,10 @@ include => demo
|
|||||||
|
|
||||||
;exten => 6245,hint,SIP/Grandstream1&SIP/Xlite1 ; Channel hints for presence
|
;exten => 6245,hint,SIP/Grandstream1&SIP/Xlite1 ; Channel hints for presence
|
||||||
;exten => 6245,1,Dial(SIP/Grandstream1,20,rt) ; permit transfer
|
;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,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 => 6361,1,Dial(IAX2/JaneDoe,,rm) ; ring without time limit
|
||||||
;exten => 6389,1,Dial(MGCP/aaln/1@192.168.0.14)
|
;exten => 6389,1,Dial(MGCP/aaln/1@192.168.0.14)
|
||||||
;exten => 6394,1,Dial(Local/6275/n) ; this will dial ${MARK}
|
;exten => 6394,1,Dial(Local/6275/n) ; this will dial ${MARK}
|
||||||
|
@@ -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_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
|
//! Looks for a valid matching extension
|
||||||
/*!
|
/*!
|
||||||
\param c not really important
|
\param c not really important
|
||||||
|
32
pbx.c
32
pbx.c
@@ -719,7 +719,7 @@ static int matchcid(const char *cidpattern, const char *callerid)
|
|||||||
return ast_extension_match(cidpattern, 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;
|
int x, res;
|
||||||
struct ast_context *tmp;
|
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))
|
if (!strcasecmp(incstack[x], context))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if (bypass)
|
||||||
|
tmp = bypass;
|
||||||
|
else
|
||||||
tmp = contexts;
|
tmp = contexts;
|
||||||
while(tmp) {
|
while(tmp) {
|
||||||
/* Match context */
|
/* Match context */
|
||||||
if (!strcmp(tmp->name, context)) {
|
if (bypass || !strcmp(tmp->name, context)) {
|
||||||
if (*status < STATUS_NO_EXTENSION)
|
if (*status < STATUS_NO_EXTENSION)
|
||||||
*status = STATUS_NO_EXTENSION;
|
*status = STATUS_NO_EXTENSION;
|
||||||
eroot = tmp->root;
|
eroot = tmp->root;
|
||||||
@@ -806,13 +809,14 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan, const char
|
|||||||
i = tmp->includes;
|
i = tmp->includes;
|
||||||
while(i) {
|
while(i) {
|
||||||
if (include_valid(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;
|
return e;
|
||||||
if (*swo)
|
if (*swo)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
i = i->next;
|
i = i->next;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
tmp = tmp->next;
|
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);
|
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_exten *e;
|
||||||
struct ast_app *app;
|
struct ast_app *app;
|
||||||
@@ -1250,7 +1254,7 @@ static int pbx_extension_helper(struct ast_channel *c, const char *context, cons
|
|||||||
else
|
else
|
||||||
return -1;
|
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) {
|
if (e) {
|
||||||
switch(action) {
|
switch(action) {
|
||||||
case HELPER_CANMATCH:
|
case HELPER_CANMATCH:
|
||||||
@@ -1351,6 +1355,7 @@ 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);
|
ast_log(LOG_NOTICE, "No such priority %d in extension '%s' in context '%s'\n", priority, exten, context);
|
||||||
break;
|
break;
|
||||||
case STATUS_NO_LABEL:
|
case STATUS_NO_LABEL:
|
||||||
|
if (context)
|
||||||
ast_log(LOG_NOTICE, "No such label '%s' in extension '%s' in context '%s'\n", label, exten, context);
|
ast_log(LOG_NOTICE, "No such label '%s' in extension '%s' in context '%s'\n", label, exten, context);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -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");
|
ast_log(LOG_WARNING, "Unable to obtain lock\n");
|
||||||
return NULL;
|
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);
|
ast_mutex_unlock(&conlock);
|
||||||
return e;
|
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)
|
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)
|
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)
|
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)
|
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)
|
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)
|
int ast_pbx_run(struct ast_channel *c)
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include <asterisk/module.h>
|
#include <asterisk/module.h>
|
||||||
#include <asterisk/logger.h>
|
#include <asterisk/logger.h>
|
||||||
#include <asterisk/cli.h>
|
#include <asterisk/cli.h>
|
||||||
|
#include <asterisk/callerid.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -1656,6 +1657,12 @@ static int pbx_load_module(void)
|
|||||||
ext = strsep(&stringp, ",");
|
ext = strsep(&stringp, ",");
|
||||||
if (!ext)
|
if (!ext)
|
||||||
ext="";
|
ext="";
|
||||||
|
cidmatch = strchr(ext, '/');
|
||||||
|
if (cidmatch) {
|
||||||
|
*cidmatch = '\0';
|
||||||
|
cidmatch++;
|
||||||
|
ast_shrink_phone_number(cidmatch);
|
||||||
|
}
|
||||||
pri = strsep(&stringp, ",");
|
pri = strsep(&stringp, ",");
|
||||||
if (!pri)
|
if (!pri)
|
||||||
pri="";
|
pri="";
|
||||||
@@ -1688,10 +1695,12 @@ static int pbx_load_module(void)
|
|||||||
ast_log(LOG_WARNING, "Can't use 'same' priority on the first entry!\n");
|
ast_log(LOG_WARNING, "Can't use 'same' priority on the first entry!\n");
|
||||||
} else {
|
} else {
|
||||||
if (sscanf(pri, "%i", &ipri) != 1) {
|
if (sscanf(pri, "%i", &ipri) != 1) {
|
||||||
ast_log(LOG_WARNING, "Invalid priority '%s' at line %d\n", pri, v->lineno);
|
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;
|
ipri = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
appl = stringp;
|
appl = stringp;
|
||||||
if (!appl)
|
if (!appl)
|
||||||
appl="";
|
appl="";
|
||||||
@@ -1715,13 +1724,6 @@ static int pbx_load_module(void)
|
|||||||
else
|
else
|
||||||
data = "";
|
data = "";
|
||||||
}
|
}
|
||||||
cidmatch = strchr(ext, '/');
|
|
||||||
if (cidmatch) {
|
|
||||||
*cidmatch = '\0';
|
|
||||||
cidmatch++;
|
|
||||||
}
|
|
||||||
stringp=ext;
|
|
||||||
strsep(&stringp, "/");
|
|
||||||
|
|
||||||
if (!data)
|
if (!data)
|
||||||
data="";
|
data="";
|
||||||
|
Reference in New Issue
Block a user