Wed Jan 8 2020 09:49:55

Asterisk developer's documentation


app_sendtext.c File Reference

App to transmit a text message. More...

#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.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 sendtext_exec (struct ast_channel *chan, const char *data)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Send Text Applications" , .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 const char *const app = "SendText"
 
static struct ast_module_infoast_module_info = &__mod_info
 

Detailed Description

App to transmit a text message.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m
Note
Requires support of sending text messages from channel driver

Definition in file app_sendtext.c.

Function Documentation

static void __reg_module ( void  )
static

Definition at line 123 of file app_sendtext.c.

static void __unreg_module ( void  )
static

Definition at line 123 of file app_sendtext.c.

static int load_module ( void  )
static

Definition at line 118 of file app_sendtext.c.

References ast_register_application_xml, and sendtext_exec().

119 {
121 }
static int sendtext_exec(struct ast_channel *chan, const char *data)
Definition: app_sendtext.c:79
static const char *const app
Definition: app_sendtext.c:77
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
static int sendtext_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 79 of file app_sendtext.c.

References ast_channel_lock, ast_channel_unlock, ast_log(), ast_sendtext(), ast_str_alloca, ast_str_buffer(), ast_str_get_encoded_str(), LOG_WARNING, pbx_builtin_setvar_helper(), ast_channel_tech::send_text, status, str, and ast_channel::tech.

Referenced by load_module().

80 {
81  char *status = "UNSUPPORTED";
82  struct ast_str *str;
83 
84  /* NOT ast_strlen_zero, because some protocols (e.g. SIP) MUST be able to
85  * send a zero-length message. */
86  if (!data) {
87  ast_log(LOG_WARNING, "SendText requires an argument (text)\n");
88  return -1;
89  }
90 
91  if (!(str = ast_str_alloca(strlen(data) + 1))) {
92  return -1;
93  }
94 
95  ast_str_get_encoded_str(&str, -1, data);
96 
97  ast_channel_lock(chan);
98  if (!chan->tech->send_text) {
99  ast_channel_unlock(chan);
100  /* Does not support transport */
101  pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
102  return 0;
103  }
104  status = "FAILURE";
105  if (!ast_sendtext(chan, ast_str_buffer(str))) {
106  status = "SUCCESS";
107  }
108  ast_channel_unlock(chan);
109  pbx_builtin_setvar_helper(chan, "SENDTEXTSTATUS", status);
110  return 0;
111 }
#define ast_channel_lock(chan)
Definition: channel.h:2466
#define LOG_WARNING
Definition: logger.h:144
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:497
int ast_str_get_encoded_str(struct ast_str **str, int maxlen, const char *stream)
Decode a stream of encoded control or extended ASCII characters.
Definition: app.c:2210
#define ast_str_alloca(init_len)
Definition: strings.h:608
const char * str
Definition: app_jack.c:144
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:364
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 ast_channel_unlock(chan)
Definition: channel.h:2467
int(*const send_text)(struct ast_channel *chan, const char *text)
Display or transmit text.
Definition: channel.h:557
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
struct ast_channel_tech * tech
Definition: channel.h:743
jack_status_t status
Definition: app_jack.c:143
int ast_sendtext(struct ast_channel *chan, const char *text)
Sends text to a channel.
Definition: channel.c:4687
static int unload_module ( void  )
static

Definition at line 113 of file app_sendtext.c.

References ast_unregister_application().

114 {
116 }
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705
static const char *const app
Definition: app_sendtext.c:77

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Send Text Applications" , .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 123 of file app_sendtext.c.

const char* const app = "SendText"
static

Definition at line 77 of file app_sendtext.c.

Definition at line 123 of file app_sendtext.c.