#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/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.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. | |
int | unload_module (void) |
Cleanup all module structures, sockets, etc. | |
int | usecount (void) |
Provides a usecount. | |
static int | zapateller_exec (struct ast_channel *chan, void *data) |
Variables | |
static char * | app = "Zapateller" |
static char * | descrip |
LOCAL_USER_DECL | |
STANDARD_LOCAL_USER | |
static char * | synopsis = "Block telemarketers with SIT" |
static char * | tdesc = "Block Telemarketers with Special Information Tone" |
Definition in file app_zapateller.c.
char* description | ( | void | ) |
Provides a description of the module.
Definition at line 123 of file app_zapateller.c.
00124 { 00125 return tdesc; 00126 }
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 135 of file app_zapateller.c.
References ASTERISK_GPL_KEY.
00136 { 00137 return ASTERISK_GPL_KEY; 00138 }
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 118 of file app_zapateller.c.
References ast_register_application(), and zapateller_exec().
00119 { 00120 return ast_register_application(app, zapateller_exec, synopsis, descrip); 00121 }
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 107 of file app_zapateller.c.
References ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS.
00108 { 00109 int res; 00110 00111 res = ast_unregister_application(app); 00112 00113 STANDARD_HANGUP_LOCALUSERS; 00114 00115 return res; 00116 }
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 128 of file app_zapateller.c.
References STANDARD_USECOUNT.
00129 { 00130 int res; 00131 STANDARD_USECOUNT(res); 00132 return res; 00133 }
static int zapateller_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 61 of file app_zapateller.c.
References ast_channel::_state, answer, ast_answer(), ast_safe_sleep(), AST_STATE_UP, ast_stopstream(), ast_strlen_zero(), ast_tonepair(), localuser::chan, ast_channel::cid, ast_callerid::cid_num, LOCAL_USER_ADD, LOCAL_USER_REMOVE, and strsep().
Referenced by load_module().
00062 { 00063 int res = 0; 00064 struct localuser *u; 00065 int answer = 0, nocallerid = 0; 00066 char *c; 00067 char *stringp=NULL; 00068 00069 LOCAL_USER_ADD(u); 00070 00071 stringp=data; 00072 c = strsep(&stringp, "|"); 00073 while(!ast_strlen_zero(c)) { 00074 if (!strcasecmp(c, "answer")) 00075 answer = 1; 00076 else if (!strcasecmp(c, "nocallerid")) 00077 nocallerid = 1; 00078 00079 c = strsep(&stringp, "|"); 00080 } 00081 00082 ast_stopstream(chan); 00083 if (chan->_state != AST_STATE_UP) { 00084 00085 if (answer) 00086 res = ast_answer(chan); 00087 if (!res) { 00088 res = ast_safe_sleep(chan, 500); 00089 } 00090 } 00091 if (chan->cid.cid_num && nocallerid) { 00092 LOCAL_USER_REMOVE(u); 00093 return res; 00094 } 00095 if (!res) 00096 res = ast_tonepair(chan, 950, 0, 330, 0); 00097 if (!res) 00098 res = ast_tonepair(chan, 1400, 0, 330, 0); 00099 if (!res) 00100 res = ast_tonepair(chan, 1800, 0, 330, 0); 00101 if (!res) 00102 res = ast_tonepair(chan, 0, 0, 1000, 0); 00103 LOCAL_USER_REMOVE(u); 00104 return res; 00105 }
char* app = "Zapateller" [static] |
Definition at line 44 of file app_zapateller.c.
char* descrip [static] |
Definition at line 48 of file app_zapateller.c.
Definition at line 59 of file app_zapateller.c.
Definition at line 57 of file app_zapateller.c.
char* synopsis = "Block telemarketers with SIT" [static] |
Definition at line 46 of file app_zapateller.c.
char* tdesc = "Block Telemarketers with Special Information Tone" [static] |
Definition at line 42 of file app_zapateller.c.