Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions | Variables
app_zapateller.c File Reference

Playback the special information tone to get rid of telemarketers. More...

#include "asterisk.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/app.h"
Include dependency graph for app_zapateller.c:

Go to the source code of this file.

Functions

 AST_MODULE_INFO_STANDARD_EXTENDED (ASTERISK_GPL_KEY, "Block Telemarketers with Special Information Tone")
 
static int load_module (void)
 
static int unload_module (void)
 
static int zapateller_exec (struct ast_channel *chan, const char *data)
 

Variables

static char * app = "Zapateller"
 

Detailed Description

Playback the special information tone to get rid of telemarketers.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

Definition in file app_zapateller.c.

Function Documentation

◆ AST_MODULE_INFO_STANDARD_EXTENDED()

AST_MODULE_INFO_STANDARD_EXTENDED ( ASTERISK_GPL_KEY  ,
"Block Telemarketers with Special Information Tone"   
)

◆ load_module()

static int load_module ( void  )
static

Definition at line 133 of file app_zapateller.c.

134{
136}
static int zapateller_exec(struct ast_channel *chan, const char *data)
static char * app
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:640

References app, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, and zapateller_exec().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 128 of file app_zapateller.c.

129{
131}
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

References app, and ast_unregister_application().

◆ zapateller_exec()

static int zapateller_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 79 of file app_zapateller.c.

80{
81 int res = 0;
82 int i, answer = 0, nocallerid = 0;
83 char *parse = ast_strdupa((char *)data);
86 );
87
89
90 for (i = 0; i < args.argc; i++) {
91 if (!strcasecmp(args.options[i], "answer"))
92 answer = 1;
93 else if (!strcasecmp(args.options[i], "nocallerid"))
94 nocallerid = 1;
95 }
96
97 pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "NOTHING");
98 ast_stopstream(chan);
99 if (ast_channel_state(chan) != AST_STATE_UP) {
100 if (answer) {
101 res = ast_answer(chan);
102 pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "ANSWERED");
103 }
104 if (!res)
105 res = ast_safe_sleep(chan, 500);
106 }
107
108 if (nocallerid /* Zap caller if no caller id. */
109 && ast_channel_caller(chan)->id.number.valid
110 && !ast_strlen_zero(ast_channel_caller(chan)->id.number.str)) {
111 /* We have caller id. */
112 return res;
113 }
114
115 if (!res)
116 res = ast_tonepair(chan, 950, 0, 330, 0);
117 if (!res)
118 res = ast_tonepair(chan, 1400, 0, 330, 0);
119 if (!res)
120 res = ast_tonepair(chan, 1800, 0, 330, 0);
121 if (!res)
122 res = ast_tonepair(chan, 0, 0, 1000, 0);
123
124 pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "ZAPPED");
125 return res;
126}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
static int answer(void *data)
Definition: chan_pjsip.c:687
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition: channel.c:7622
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2824
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition: channel.c:1593
ast_channel_state
ast_channel states
Definition: channelstate.h:35
@ AST_STATE_UP
Definition: channelstate.h:42
int ast_stopstream(struct ast_channel *c)
Stops a stream.
Definition: file.c:222
#define AST_APP_ARG(name)
Define an application argument.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Number structure.
Definition: app_followme.c:154
const char * args
static struct test_options options

References answer(), args, ast_answer(), AST_APP_ARG, ast_channel_caller(), AST_DECLARE_APP_ARGS, ast_safe_sleep(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_strdupa, ast_strlen_zero(), ast_tonepair(), options, and pbx_builtin_setvar_helper().

Referenced by load_module().

Variable Documentation

◆ app

char* app = "Zapateller"
static

Definition at line 77 of file app_zapateller.c.

Referenced by load_module(), and unload_module().