#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "asterisk.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 | |
char * | description (void) |
Provides a description of the module. | |
char * | key () |
Returns the ASTERISK_GPL_KEY. | |
int | load_module (void) |
Initialize the module. | |
static int | lookupblacklist_exec (struct ast_channel *chan, void *data) |
int | unload_module (void) |
Cleanup all module structures, sockets, etc. | |
int | usecount (void) |
Provides a usecount. | |
Variables | |
static char * | app = "LookupBlacklist" |
static char * | descrip |
LOCAL_USER_DECL | |
STANDARD_LOCAL_USER | |
static char * | synopsis = "Look up Caller*ID name/number from blacklist database" |
static char * | tdesc = "Look up Caller*ID name/number from blacklist database" |
Definition in file app_lookupblacklist.c.
char* description | ( | void | ) |
Provides a description of the module.
Definition at line 126 of file app_lookupblacklist.c.
00127 { 00128 return tdesc; 00129 }
char* key | ( | void | ) |
Returns the ASTERISK_GPL_KEY.
This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does not return the EXACT message:
char *key(void) { return ASTERISK_GPL_KEY; }
Definition at line 138 of file app_lookupblacklist.c.
References ASTERISK_GPL_KEY.
00139 { 00140 return ASTERISK_GPL_KEY; 00141 }
int load_module | ( | void | ) |
Initialize the module.
Initialize the Agents module. This function is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.
Definition at line 121 of file app_lookupblacklist.c.
References ast_register_application(), and lookupblacklist_exec().
00122 { 00123 return ast_register_application (app, lookupblacklist_exec, synopsis,descrip); 00124 }
static int lookupblacklist_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 69 of file app_lookupblacklist.c.
References ast_db_get(), ast_goto_if_exists(), ast_log(), ast_strlen_zero(), localuser::chan, ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ast_channel::context, LOCAL_USER_ADD, LOCAL_USER_REMOVE, LOG_NOTICE, option_priority_jumping, option_verbose, and pbx_builtin_setvar_helper().
Referenced by load_module().
00070 { 00071 char blacklist[1]; 00072 struct localuser *u; 00073 int bl = 0; 00074 int priority_jump = 0; 00075 00076 LOCAL_USER_ADD(u); 00077 00078 if (!ast_strlen_zero(data)) { 00079 if (strchr(data, 'j')) 00080 priority_jump = 1; 00081 } 00082 00083 if (chan->cid.cid_num) { 00084 if (!ast_db_get("blacklist", chan->cid.cid_num, blacklist, sizeof (blacklist))) { 00085 if (option_verbose > 2) 00086 ast_log(LOG_NOTICE, "Blacklisted number %s found\n",chan->cid.cid_num); 00087 bl = 1; 00088 } 00089 } 00090 if (chan->cid.cid_name) { 00091 if (!ast_db_get("blacklist", chan->cid.cid_name, blacklist, sizeof (blacklist))) { 00092 if (option_verbose > 2) 00093 ast_log (LOG_NOTICE,"Blacklisted name \"%s\" found\n",chan->cid.cid_name); 00094 bl = 1; 00095 } 00096 } 00097 00098 if (bl) { 00099 if (priority_jump || option_priority_jumping) 00100 ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); 00101 pbx_builtin_setvar_helper(chan, "LOOKUPBLSTATUS", "FOUND"); 00102 } else 00103 pbx_builtin_setvar_helper(chan, "LOOKUPBLSTATUS", "NOTFOUND"); 00104 00105 LOCAL_USER_REMOVE(u); 00106 00107 return 0; 00108 }
int unload_module | ( | void | ) |
Cleanup all module structures, sockets, etc.
This is called at exit. Any registrations and memory allocations need to be unregistered and free'd here. Nothing else will do these for you (until exit).
Definition at line 110 of file app_lookupblacklist.c.
References ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS.
00111 { 00112 int res; 00113 00114 res = ast_unregister_application(app); 00115 00116 STANDARD_HANGUP_LOCALUSERS; 00117 00118 return res; 00119 }
int usecount | ( | void | ) |
Provides a usecount.
This function will be called by various parts of asterisk. Basically, all it has to do is to return a usecount when called. You will need to maintain your usecount within the module somewhere. The usecount should be how many channels provided by this module are in use.
Definition at line 131 of file app_lookupblacklist.c.
References STANDARD_USECOUNT.
00132 { 00133 int res; 00134 STANDARD_USECOUNT (res); 00135 return res; 00136 }
char* app = "LookupBlacklist" [static] |
Definition at line 50 of file app_lookupblacklist.c.
char* descrip [static] |
Definition at line 54 of file app_lookupblacklist.c.
Definition at line 66 of file app_lookupblacklist.c.
Definition at line 64 of file app_lookupblacklist.c.
Definition at line 52 of file app_lookupblacklist.c.
Definition at line 48 of file app_lookupblacklist.c.