Tue Sep 30 01:19:41 2008

Asterisk developer's documentation


app_lookupblacklist.c File Reference

App to lookup the callerid number, and see if it is blacklisted. More...

#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/options.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/image.h"
#include "asterisk/callerid.h"
#include "asterisk/astdb.h"

Include dependency graph for app_lookupblacklist.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD (ASTERISK_GPL_KEY,"Look up Caller*ID name/number from blacklist database")
static int blacklist_read (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
static int load_module (void)
static int lookupblacklist_exec (struct ast_channel *chan, void *data)
static int unload_module (void)

Variables

static char * app = "LookupBlacklist"
static struct ast_custom_function blacklist_function
static char * descrip
static char * synopsis = "Look up Caller*ID name/number from blacklist database"


Detailed Description

App to lookup the callerid number, and see if it is blacklisted.

Author:
Mark Spencer <markster@digium.com>

Definition in file app_lookupblacklist.c.


Function Documentation

AST_MODULE_INFO_STANDARD ( ASTERISK_GPL_KEY  ,
"Look up Caller*ID name/number from blacklist database"   
)

static int blacklist_read ( struct ast_channel chan,
char *  cmd,
char *  data,
char *  buf,
size_t  len 
) [static]

Definition at line 67 of file app_lookupblacklist.c.

References ast_db_get(), ast_channel::cid, ast_callerid::cid_name, and ast_callerid::cid_num.

00068 {
00069    char blacklist[1];
00070    int bl = 0;
00071 
00072    if (chan->cid.cid_num) {
00073       if (!ast_db_get("blacklist", chan->cid.cid_num, blacklist, sizeof (blacklist)))
00074          bl = 1;
00075    }
00076    if (chan->cid.cid_name) {
00077       if (!ast_db_get("blacklist", chan->cid.cid_name, blacklist, sizeof (blacklist)))
00078          bl = 1;
00079    }
00080 
00081    snprintf(buf, len, "%d", bl);
00082    return 0;
00083 }

static int load_module ( void   )  [static]

static int lookupblacklist_exec ( struct ast_channel chan,
void *  data 
) [static]

Definition at line 94 of file app_lookupblacklist.c.

References ast_db_get(), ast_goto_if_exists(), ast_log(), ast_module_user_add, ast_module_user_remove, ast_opt_priority_jumping, ast_strlen_zero(), ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ast_channel::context, ast_channel::exten, LOG_NOTICE, LOG_WARNING, option_verbose, pbx_builtin_setvar_helper(), and ast_channel::priority.

Referenced by load_module().

00095 {
00096    char blacklist[1];
00097    struct ast_module_user *u;
00098    int bl = 0;
00099    int priority_jump = 0;
00100    static int dep_warning = 0;
00101 
00102    u = ast_module_user_add(chan);
00103 
00104    if (!dep_warning) {
00105       dep_warning = 1;
00106       ast_log(LOG_WARNING, "LookupBlacklist is deprecated.  Please use ${BLACKLIST()} instead.\n");
00107    }
00108 
00109    if (!ast_strlen_zero(data)) {
00110       if (strchr(data, 'j'))
00111          priority_jump = 1;
00112    }
00113 
00114    if (chan->cid.cid_num) {
00115       if (!ast_db_get("blacklist", chan->cid.cid_num, blacklist, sizeof (blacklist))) {
00116          if (option_verbose > 2)
00117             ast_log(LOG_NOTICE, "Blacklisted number %s found\n",chan->cid.cid_num);
00118          bl = 1;
00119       }
00120    }
00121    if (chan->cid.cid_name) {
00122       if (!ast_db_get("blacklist", chan->cid.cid_name, blacklist, sizeof (blacklist))) {
00123          if (option_verbose > 2)
00124             ast_log (LOG_NOTICE,"Blacklisted name \"%s\" found\n",chan->cid.cid_name);
00125          bl = 1;
00126       }
00127    }
00128 
00129    if (bl) {
00130       if (priority_jump || ast_opt_priority_jumping) 
00131          ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
00132       pbx_builtin_setvar_helper(chan, "LOOKUPBLSTATUS", "FOUND");
00133    } else
00134       pbx_builtin_setvar_helper(chan, "LOOKUPBLSTATUS", "NOTFOUND"); 
00135 
00136    ast_module_user_remove(u);
00137 
00138    return 0;
00139 }

static int unload_module ( void   )  [static]

Definition at line 141 of file app_lookupblacklist.c.

References ast_custom_function_unregister(), ast_module_user_hangup_all, and ast_unregister_application().

00142 {
00143    int res;
00144 
00145    res = ast_unregister_application(app);
00146    res |= ast_custom_function_unregister(&blacklist_function);
00147 
00148    ast_module_user_hangup_all();
00149 
00150    return res; 
00151 }


Variable Documentation

char* app = "LookupBlacklist" [static]

Definition at line 50 of file app_lookupblacklist.c.

Definition at line 85 of file app_lookupblacklist.c.

char* descrip [static]

Definition at line 54 of file app_lookupblacklist.c.

char* synopsis = "Look up Caller*ID name/number from blacklist database" [static]

Definition at line 52 of file app_lookupblacklist.c.


Generated on Tue Sep 30 01:19:41 2008 for Asterisk - the Open Source PBX by  doxygen 1.5.6