Asterisk - The Open Source Telephony Project  18.5.0
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"   
)

Referenced by load_module().

◆ load_module()

static int load_module ( void  )
static

Definition at line 133 of file app_zapateller.c.

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

134 {
136 }
static char * app
static int zapateller_exec(struct ast_channel *chan, const char *data)
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:626

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 128 of file app_zapateller.c.

References app, and ast_unregister_application().

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

◆ zapateller_exec()

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

Definition at line 79 of file app_zapateller.c.

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, parse(), and pbx_builtin_setvar_helper().

Referenced by load_module().

80 {
81  int res = 0;
82  int i, answer = 0, nocallerid = 0;
83  char *parse = ast_strdupa((char *)data);
85  AST_APP_ARG(options)[2];
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 }
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition: channel.c:1574
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
ast_channel_state
ast_channel states
Definition: channelstate.h:35
const char * args
#define ast_strlen_zero(foo)
Definition: strings.h:52
Number structure.
Definition: app_followme.c:154
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static int answer(void *data)
Definition: chan_pjsip.c:682
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
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...
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2814
static struct test_options options
int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition: channel.c:7700
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
int ast_stopstream(struct ast_channel *c)
Stops a stream.
Definition: file.c:187
#define AST_APP_ARG(name)
Define an application argument.

Variable Documentation

◆ app

char* app = "Zapateller"
static

Definition at line 77 of file app_zapateller.c.

Referenced by load_module(), and unload_module().