Index: apps/app_enumlookup.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_enumlookup.c,v retrieving revision 1.25 diff -u -r1.25 app_enumlookup.c --- apps/app_enumlookup.c 26 Oct 2005 19:48:14 -0000 1.25 +++ apps/app_enumlookup.c 4 Nov 2005 19:26:20 -0000 @@ -42,6 +42,7 @@ #include "asterisk/module.h" #include "asterisk/enum.h" #include "asterisk/utils.h" +#include "asterisk/options.h" static char *tdesc = "ENUM Lookup"; @@ -50,7 +51,7 @@ static char *synopsis = "Lookup number in ENUM"; 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" "look like 'TECHNOLOGY/URI' with the appropriate technology.\n" "Returns -1 on hangup, or 0 on completion\n" @@ -59,11 +60,9 @@ " ERROR Failed to do a lookup\n" " Technology of the successful lookup: SIP, H323, IAX, IAX2 or TEL\n" " BADURI Got URI Asterisk does not understand.\n" -"\nOld, depreciated, behaviour:\n" -"\nA SIP, H323, IAX or IAX2 entry will result in normal priority handling, \n" -"whereas a TEL entry will increase the priority by 51 (if existing).\n" -"If the lookup was *not* successful and there exists a priority n + 101,\n" -"then that priority will be taken next.\n" ; +" The option string may contain zero or the following character:\n" +" 'j' -- jump to +101 priority if the lookup isn't successful.\n" +" and jump to +51 priority on a TEL entry.\n"; #define ENUM_CONFIG "enum.conf" @@ -77,11 +76,11 @@ /*--- enumlookup_exec: Look up number in ENUM and return result */ static int enumlookup_exec(struct ast_channel *chan, void *data) { - int res=0; + int res=0,priority_jump=0; char tech[80]; char dest[80]; char tmp[256]; - char *c,*t; + char *c,*t,*d,*o = NULL; static int dep_warning=0; struct localuser *u; @@ -99,11 +98,24 @@ 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 */ - /* Look for a "busy" place */ - ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); + if (priority_jump || option_priority_jumping) { + /* Look for a "busy" place */ + ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); + } pbx_builtin_setvar_helper(chan, "ENUMSTATUS", "ERROR"); LOCAL_USER_REMOVE(u); return 0; @@ -158,8 +170,10 @@ *t = 0; pbx_builtin_setvar_helper(chan, "ENUM", 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)) - res = 0; + if (priority_jump || option_priority_jumping) { + if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 51)) + res = 0; + } } } else if (!ast_strlen_zero(tech)) { ast_log(LOG_NOTICE, "Don't know how to handle technology '%s'\n", tech);