Wed Jan 8 2020 09:49:40

Asterisk developer's documentation


app_setcallerid.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 1999 - 2005, Digium, Inc.
5  *
6  * Mark Spencer <markster@digium.com>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 /*! \file
20  *
21  * \brief App to set callerid presentation
22  *
23  * \author Mark Spencer <markster@digium.com>
24  *
25  * \ingroup applications
26  */
27 
28 /*** MODULEINFO
29  <support_level>deprecated</support_level>
30  <replacement>func_callerid</replacement>
31  ***/
32 
33 #include "asterisk.h"
34 
35 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 328446 $")
36 
37 #include "asterisk/lock.h"
38 #include "asterisk/file.h"
39 #include "asterisk/channel.h"
40 #include "asterisk/pbx.h"
41 #include "asterisk/module.h"
42 #include "asterisk/translate.h"
43 #include "asterisk/image.h"
44 #include "asterisk/callerid.h"
45 
46 /*** DOCUMENTATION
47  <application name="SetCallerPres" language="en_US">
48  <synopsis>
49  Set CallerID Presentation.
50  </synopsis>
51  <syntax>
52  <parameter name="presentation" required="true">
53  <enumlist>
54  <enum name="allowed_not_screened">
55  <para>Presentation Allowed, Not Screened.</para>
56  </enum>
57  <enum name="allowed_passed_screen">
58  <para>Presentation Allowed, Passed Screen.</para>
59  </enum>
60  <enum name="allowed_failed_screen">
61  <para>Presentation Allowed, Failed Screen.</para>
62  </enum>
63  <enum name="allowed">
64  <para>Presentation Allowed, Network Number.</para>
65  </enum>
66  <enum name="prohib_not_screened">
67  <para>Presentation Prohibited, Not Screened.</para>
68  </enum>
69  <enum name="prohib_passed_screen">
70  <para>Presentation Prohibited, Passed Screen.</para>
71  </enum>
72  <enum name="prohib_failed_screen">
73  <para>Presentation Prohibited, Failed Screen.</para>
74  </enum>
75  <enum name="prohib">
76  <para>Presentation Prohibited, Network Number.</para>
77  </enum>
78  <enum name="unavailable">
79  <para>Number Unavailable.</para>
80  </enum>
81  </enumlist>
82  </parameter>
83  </syntax>
84  <description>
85  <para>Set Caller*ID presentation on a call.</para>
86  </description>
87  </application>
88  ***/
89 
90 static char *app2 = "SetCallerPres";
91 
92 static int setcallerid_pres_exec(struct ast_channel *chan, const char *data)
93 {
94  int pres = -1;
95  static int deprecated = 0;
96 
97  if (!deprecated) {
98  deprecated = 1;
99  ast_log(LOG_WARNING, "SetCallerPres is deprecated. Please use Set(CALLERPRES()=%s) instead.\n", (char *)data);
100  }
101 
102  /* For interface consistency, permit the argument to be specified as a number */
103  if (sscanf(data, "%30d", &pres) != 1 || pres < 0 || pres > 255 || (pres & 0x9c)) {
104  pres = ast_parse_caller_presentation(data);
105  }
106 
107  if (pres < 0) {
108  ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n",
109  (char *) data);
110  return 0;
111  }
112 
113  /* Set the combined caller id presentation. */
114  chan->caller.id.name.presentation = pres;
115  chan->caller.id.number.presentation = pres;
116  return 0;
117 }
118 
119 static int unload_module(void)
120 {
121  return ast_unregister_application(app2);
122 }
123 
124 static int load_module(void)
125 {
127 }
128 
129 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Set CallerID Presentation Application");
int presentation
Q.931 encoded presentation-indicator encoded field.
Definition: channel.h:227
Main Channel structure associated with a channel.
Definition: channel.h:742
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Definition: module.h:396
Asterisk main include file. File version handling, generic pbx functions.
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
Definition: channel.h:245
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
Support for translation of data formats. translate.c.
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
#define LOG_WARNING
Definition: logger.h:144
static char * app2
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
static int unload_module(void)
General Asterisk channel definitions for image handling.
General Asterisk PBX channel definitions.
static int load_module(void)
Core PBX routines and definitions.
int ast_parse_caller_presentation(const char *data)
Convert caller ID text code to value (used in config file parsing)
Definition: callerid.c:1144
static int setcallerid_pres_exec(struct ast_channel *chan, const char *data)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
Definition: logger.c:1207
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:38
Asterisk module definitions.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
Definition: asterisk.h:180
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292