[Asterisk-cvs] asterisk/apps app_lookupblacklist.c,1.14,1.15

russell russell
Sun Nov 6 14:53:26 CST 2005


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

Modified Files:
	app_lookupblacklist.c 
Log Message:
issue #5627, with mods


Index: app_lookupblacklist.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_lookupblacklist.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- app_lookupblacklist.c	6 Nov 2005 15:09:46 -0000	1.14
+++ app_lookupblacklist.c	6 Nov 2005 19:44:39 -0000	1.15
@@ -42,6 +42,7 @@
 #include "asterisk/image.h"
 #include "asterisk/callerid.h"
 #include "asterisk/astdb.h"
+#include "asterisk/options.h"
 
 static char *tdesc = "Look up Caller*ID name/number from blacklist database";
 
@@ -50,13 +51,15 @@
 static char *synopsis = "Look up Caller*ID name/number from blacklist database";
 
 static char *descrip =
-  "  LookupBlacklist: Looks up the Caller*ID number on the active\n"
-  "channel in the Asterisk database (family 'blacklist').  If the\n"
-  "number is found, and if there exists a priority n + 101,\n"
-  "where 'n' is the priority of the current instance, then  the\n"
-  "channel  will  be  setup  to continue at that priority level.\n"
-  "Otherwise, it returns 0.  Does nothing if no Caller*ID was received on the\n"
+  "  LookupBlacklist(options): Looks up the Caller*ID number on the active\n"
+  "channel in the Asterisk database (family 'blacklist').  \n"
+  "Returns 0.  Does nothing if no Caller*ID was received on the\n"
   "channel.\n"
+  "The option string may contain zero or the following character:\n"
+  "	'j' -- jump to n+101 priority if the number/name is found in the blacklist\n"
+  "This application sets the following channel variable upon completion:\n"
+  "	LOOKUPBLSTATUS		The status of the Blacklist lookup as a text string, one of\n"
+  "		FOUND | NOTFOUND\n"
   "Example: database put blacklist <name/number> 1\n";
 
 STANDARD_LOCAL_USER;
@@ -69,30 +72,39 @@
 	char blacklist[1];
 	struct localuser *u;
 	int bl = 0;
+	int priority_jump = 0;
 
-	LOCAL_USER_ADD (u);
-	if (chan->cid.cid_num)
-	{
-		if (!ast_db_get ("blacklist", chan->cid.cid_num, blacklist, sizeof (blacklist)))
-		{
+	LOCAL_USER_ADD(u);
+
+	if (!ast_strlen_zero(data)) {
+		if (strchr(data, 'j'))
+			priority_jump = 1;
+	}
+
+	if (chan->cid.cid_num) {
+		if (!ast_db_get("blacklist", chan->cid.cid_num, blacklist, sizeof (blacklist))) {
 			if (option_verbose > 2)
 				ast_log(LOG_NOTICE, "Blacklisted number %s found\n",chan->cid.cid_num);
 			bl = 1;
 		}
 	}
 	if (chan->cid.cid_name) {
-		if (!ast_db_get ("blacklist", chan->cid.cid_name, blacklist, sizeof (blacklist))) 
-		{
+		if (!ast_db_get("blacklist", chan->cid.cid_name, blacklist, sizeof (blacklist))) {
 			if (option_verbose > 2)
 				ast_log (LOG_NOTICE,"Blacklisted name \"%s\" found\n",chan->cid.cid_name);
 			bl = 1;
 		}
 	}
-	
-	if (bl)
-		ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
 
-	LOCAL_USER_REMOVE (u);
+	if (bl) {
+		if (priority_jump || option_priority_jumping) 
+			ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
+		pbx_builtin_setvar_helper(chan, "LOOKUPBLSTATUS", "FOUND");
+	} else
+		pbx_builtin_setvar_helper(chan, "LOOKUPBLSTATUS", "NOTFOUND");	
+
+	LOCAL_USER_REMOVE(u);
+
 	return 0;
 }
 




More information about the svn-commits mailing list