#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"
Go to the source code of this file.
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
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 struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Look up Caller*ID name/number from blacklist database" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } |
static char * | app = "LookupBlacklist" |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_custom_function | blacklist_function |
static char * | descrip |
static char * | synopsis = "Look up Caller*ID name/number from blacklist database" |
Definition in file app_lookupblacklist.c.
static void __reg_module | ( | void | ) | [static] |
Definition at line 160 of file app_lookupblacklist.c.
static void __unreg_module | ( | void | ) | [static] |
Definition at line 160 of file app_lookupblacklist.c.
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_module_user::chan, 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] |
Definition at line 153 of file app_lookupblacklist.c.
References ast_custom_function_register(), ast_register_application(), blacklist_function, and lookupblacklist_exec().
00154 { 00155 int res = ast_custom_function_register(&blacklist_function); 00156 res |= ast_register_application (app, lookupblacklist_exec, synopsis,descrip); 00157 return res; 00158 }
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_module_user::chan, ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ast_channel::context, LOG_NOTICE, LOG_WARNING, option_verbose, and pbx_builtin_setvar_helper().
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, ast_unregister_application(), and blacklist_function.
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 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT | AST_MODFLAG_BUILDSUM, .description = "Look up Caller*ID name/number from blacklist database" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "361d7bb937402d51e4658efb5b4d76e4" , .load = load_module, .unload = unload_module, } [static] |
Definition at line 160 of file app_lookupblacklist.c.
char* app = "LookupBlacklist" [static] |
Definition at line 50 of file app_lookupblacklist.c.
const struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 160 of file app_lookupblacklist.c.
struct ast_custom_function blacklist_function [static] |
Definition at line 85 of file app_lookupblacklist.c.
Referenced by load_module(), and unload_module().
char* descrip [static] |
Definition at line 54 of file app_lookupblacklist.c.
Definition at line 52 of file app_lookupblacklist.c.