Wed Jan 8 2020 09:49:57

Asterisk developer's documentation


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"

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int load_module (void)
 
static int unload_module (void)
 
static int zapateller_exec (struct ast_channel *chan, const char *data)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Block Telemarketers with Special Information Tone" , .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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
 
static char * app = "Zapateller"
 
static struct ast_module_infoast_module_info = &__mod_info
 

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

static void __reg_module ( void  )
static

Definition at line 140 of file app_zapateller.c.

static void __unreg_module ( void  )
static

Definition at line 140 of file app_zapateller.c.

static int load_module ( void  )
static

Definition at line 135 of file app_zapateller.c.

References AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, and zapateller_exec().

136 {
138 }
static char * app
static int zapateller_exec(struct ast_channel *chan, const char *data)
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
static int unload_module ( void  )
static

Definition at line 130 of file app_zapateller.c.

References ast_unregister_application().

131 {
133 }
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705
static char * app
static int zapateller_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 81 of file app_zapateller.c.

References ast_channel::_state, args, ast_answer(), AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_safe_sleep(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_strdupa, ast_strlen_zero(), ast_tonepair(), ast_channel::caller, ast_party_caller::id, ast_party_id::number, parse(), pbx_builtin_setvar_helper(), ast_party_number::str, and ast_party_number::valid.

Referenced by load_module().

82 {
83  int res = 0;
84  int i, answer = 0, nocallerid = 0;
85  char *parse = ast_strdupa((char *)data);
87  AST_APP_ARG(options)[2];
88  );
89 
91 
92  for (i = 0; i < args.argc; i++) {
93  if (!strcasecmp(args.options[i], "answer"))
94  answer = 1;
95  else if (!strcasecmp(args.options[i], "nocallerid"))
96  nocallerid = 1;
97  }
98 
99  pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "NOTHING");
100  ast_stopstream(chan);
101  if (chan->_state != AST_STATE_UP) {
102  if (answer) {
103  res = ast_answer(chan);
104  pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "ANSWERED");
105  }
106  if (!res)
107  res = ast_safe_sleep(chan, 500);
108  }
109 
110  if (nocallerid /* Zap caller if no caller id. */
111  && chan->caller.id.number.valid
112  && !ast_strlen_zero(chan->caller.id.number.str)) {
113  /* We have caller id. */
114  return res;
115  }
116 
117  if (!res)
118  res = ast_tonepair(chan, 950, 0, 330, 0);
119  if (!res)
120  res = ast_tonepair(chan, 1400, 0, 330, 0);
121  if (!res)
122  res = ast_tonepair(chan, 1800, 0, 330, 0);
123  if (!res)
124  res = ast_tonepair(chan, 0, 0, 1000, 0);
125 
126  pbx_builtin_setvar_helper(chan, "ZAPATELLERSTATUS", "ZAPPED");
127  return res;
128 }
int ast_safe_sleep(struct ast_channel *chan, int ms)
Wait for a specified amount of time, looking for hangups.
Definition: channel.c:1916
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:63
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: utils.h:663
static struct @350 args
void * data
Definition: pbx.c:893
enum ast_channel_state _state
Definition: channel.h:839
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1858
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...
Definition: pbx.c:10546
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:3086
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
Definition: channel.c:7969
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
int ast_stopstream(struct ast_channel *c)
Stops a stream.
Definition: file.c:128
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Block Telemarketers with Special Information Tone" , .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 = "ac1f6a56484a8820659555499174e588" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, }
static

Definition at line 140 of file app_zapateller.c.

char* app = "Zapateller"
static

Definition at line 79 of file app_zapateller.c.

Definition at line 140 of file app_zapateller.c.