[Asterisk-cvs] asterisk/apps app_enumlookup.c,1.26,1.27

russell russell
Sun Nov 6 13:45:24 CST 2005


Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv4024/apps

Modified Files:
	app_enumlookup.c 
Log Message:
issue #5614


Index: app_enumlookup.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_enumlookup.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- app_enumlookup.c	6 Nov 2005 15:09:46 -0000	1.26
+++ app_enumlookup.c	6 Nov 2005 18:36:37 -0000	1.27
@@ -43,6 +43,7 @@
 #include "asterisk/module.h"
 #include "asterisk/enum.h"
 #include "asterisk/utils.h"
+#include "asterisk/options.h"
 
 static char *tdesc = "ENUM Lookup";
 
@@ -51,7 +52,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"
@@ -60,11 +61,9 @@
 "    ERROR	Failed to do a lookup\n"
 "    <tech>	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"
 
@@ -78,11 +77,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;
 
@@ -100,11 +99,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;
@@ -159,8 +171,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);




More information about the svn-commits mailing list