dect
/
asterisk
Archived
13
0
Fork 0
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6982 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
russell 2005-11-06 18:36:37 +00:00
parent 599a1f39fc
commit cc1e66bff3
2 changed files with 28 additions and 13 deletions

View File

@ -7,6 +7,7 @@
* many files: Add doxygen updates to categorize modules into groups. Convert a lot of comments over to doxygen style. Add some text giving a basic overview of channels. * many files: Add doxygen updates to categorize modules into groups. Convert a lot of comments over to doxygen style. Add some text giving a basic overview of channels.
* apps/app_chanisavail.c: Make priority jumping optional * apps/app_chanisavail.c: Make priority jumping optional
* apps/app_db.c: Add an exit status variable and make priority jumping optional * apps/app_db.c: Add an exit status variable and make priority jumping optional
* apps/app_enumlookup.c: Make priority jumping optional
2005-11-05 Kevin P. Fleming <kpfleming@digium.com> 2005-11-05 Kevin P. Fleming <kpfleming@digium.com>

View File

@ -43,6 +43,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/module.h" #include "asterisk/module.h"
#include "asterisk/enum.h" #include "asterisk/enum.h"
#include "asterisk/utils.h" #include "asterisk/utils.h"
#include "asterisk/options.h"
static char *tdesc = "ENUM Lookup"; static char *tdesc = "ENUM Lookup";
@ -51,7 +52,7 @@ static char *app = "EnumLookup";
static char *synopsis = "Lookup number in ENUM"; static char *synopsis = "Lookup number in ENUM";
static char *descrip = static char *descrip =
" EnumLookup(exten): Looks up an extension via ENUM and sets\n" " EnumLookup(exten[|option]): Looks up an extension via ENUM and sets\n"
"the variable 'ENUM'. For VoIP URIs this variable will \n" "the variable 'ENUM'. For VoIP URIs this variable will \n"
"look like 'TECHNOLOGY/URI' with the appropriate technology.\n" "look like 'TECHNOLOGY/URI' with the appropriate technology.\n"
"Returns -1 on hangup, or 0 on completion\n" "Returns -1 on hangup, or 0 on completion\n"
@ -60,11 +61,9 @@ static char *descrip =
" ERROR Failed to do a lookup\n" " ERROR Failed to do a lookup\n"
" <tech> Technology of the successful lookup: SIP, H323, IAX, IAX2 or TEL\n" " <tech> Technology of the successful lookup: SIP, H323, IAX, IAX2 or TEL\n"
" BADURI Got URI Asterisk does not understand.\n" " BADURI Got URI Asterisk does not understand.\n"
"\nOld, depreciated, behaviour:\n" " The option string may contain zero or the following character:\n"
"\nA SIP, H323, IAX or IAX2 entry will result in normal priority handling, \n" " 'j' -- jump to +101 priority if the lookup isn't successful.\n"
"whereas a TEL entry will increase the priority by 51 (if existing).\n" " and jump to +51 priority on a TEL entry.\n";
"If the lookup was *not* successful and there exists a priority n + 101,\n"
"then that priority will be taken next.\n" ;
#define ENUM_CONFIG "enum.conf" #define ENUM_CONFIG "enum.conf"
@ -78,11 +77,11 @@ LOCAL_USER_DECL;
/*--- enumlookup_exec: Look up number in ENUM and return result */ /*--- enumlookup_exec: Look up number in ENUM and return result */
static int enumlookup_exec(struct ast_channel *chan, void *data) static int enumlookup_exec(struct ast_channel *chan, void *data)
{ {
int res=0; int res=0,priority_jump=0;
char tech[80]; char tech[80];
char dest[80]; char dest[80];
char tmp[256]; char tmp[256];
char *c,*t; char *c,*t,*d,*o = NULL;
static int dep_warning=0; static int dep_warning=0;
struct localuser *u; struct localuser *u;
@ -100,11 +99,24 @@ static int enumlookup_exec(struct ast_channel *chan, void *data)
tech[0] = '\0'; tech[0] = '\0';
res = ast_get_enum(chan, data, dest, sizeof(dest), tech, sizeof(tech), NULL, NULL); if (strchr(data, '|')) {
d = strsep(data, "|");
o = strsep(data, "\0");
} else
d = strsep(data, "\0");
if (o) {
if (strchr(o, 'j'))
priority_jump = 1;
}
res = ast_get_enum(chan, d, dest, sizeof(dest), tech, sizeof(tech), NULL, NULL);
if (!res) { /* Failed to do a lookup */ if (!res) { /* Failed to do a lookup */
/* Look for a "busy" place */ if (priority_jump || option_priority_jumping) {
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); /* Look for a "busy" place */
ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
}
pbx_builtin_setvar_helper(chan, "ENUMSTATUS", "ERROR"); pbx_builtin_setvar_helper(chan, "ENUMSTATUS", "ERROR");
LOCAL_USER_REMOVE(u); LOCAL_USER_REMOVE(u);
return 0; return 0;
@ -159,8 +171,10 @@ static int enumlookup_exec(struct ast_channel *chan, void *data)
*t = 0; *t = 0;
pbx_builtin_setvar_helper(chan, "ENUM", tmp); pbx_builtin_setvar_helper(chan, "ENUM", tmp);
ast_log(LOG_NOTICE, "tel: ENUM set to \"%s\"\n", tmp); ast_log(LOG_NOTICE, "tel: ENUM set to \"%s\"\n", tmp);
if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 51)) if (priority_jump || option_priority_jumping) {
res = 0; if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 51))
res = 0;
}
} }
} else if (!ast_strlen_zero(tech)) { } else if (!ast_strlen_zero(tech)) {
ast_log(LOG_NOTICE, "Don't know how to handle technology '%s'\n", tech); ast_log(LOG_NOTICE, "Don't know how to handle technology '%s'\n", tech);