Wed Jan 8 2020 09:49:55

Asterisk developer's documentation


app_url.c File Reference

App to transmit a URL. More...

#include "asterisk.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/app.h"
#include "asterisk/channel.h"

Go to the source code of this file.

Enumerations

enum  option_flags {
  OPTION_A = (1 << 0), OPTION_B = (1 << 1), OPTION_C = (1 << 2), OPTION_WAIT = (1 << 0),
  OPTION_PATTERNS_DISABLED = (1 << 0)
}
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int load_module (void)
 
static int sendurl_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 URL 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 char * app = "SendURL"
 
static struct ast_app_option app_opts [128] = { [ 'w' ] = { .flag = OPTION_WAIT }, }
 
static struct ast_module_infoast_module_info = &__mod_info
 

Detailed Description

App to transmit a URL.

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

Definition in file app_url.c.

Enumeration Type Documentation

Enumerator
OPTION_A 
OPTION_B 
OPTION_C 
OPTION_WAIT 
OPTION_PATTERNS_DISABLED 

Definition at line 89 of file app_url.c.

89  {
90  OPTION_WAIT = (1 << 0),
91 };

Function Documentation

static void __reg_module ( void  )
static

Definition at line 182 of file app_url.c.

static void __unreg_module ( void  )
static

Definition at line 182 of file app_url.c.

static int load_module ( void  )
static

Definition at line 177 of file app_url.c.

References ast_register_application_xml, and sendurl_exec().

178 {
180 }
static char * app
Definition: app_url.c:87
static int sendurl_exec(struct ast_channel *chan, const char *data)
Definition: app_url.c:97
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:437
static int sendurl_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 97 of file app_url.c.

References app_opts, args, AST_APP_ARG, ast_app_parse_options(), ast_channel_sendurl(), ast_channel_supports_html(), AST_DECLARE_APP_ARGS, AST_FRAME_HTML, ast_frfree, AST_HTML_LDCOMPLETE, AST_HTML_NOSUPPORT, ast_log(), ast_read(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_test_flag, ast_waitfor(), f, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, OPTION_WAIT, pbx_builtin_setvar_helper(), status, ast_frame::subclass, and url.

Referenced by load_module().

98 {
99  int res = 0;
100  char *tmp;
101  struct ast_frame *f;
102  char *status = "FAILURE";
103  char *opts[0];
104  struct ast_flags flags = { 0 };
106  AST_APP_ARG(url);
107  AST_APP_ARG(options);
108  );
109 
110  if (ast_strlen_zero(data)) {
111  ast_log(LOG_WARNING, "SendURL requires an argument (URL)\n");
112  pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status);
113  return -1;
114  }
115 
116  tmp = ast_strdupa(data);
117 
119  if (args.argc == 2)
120  ast_app_parse_options(app_opts, &flags, opts, args.options);
121 
122  if (!ast_channel_supports_html(chan)) {
123  /* Does not support transport */
124  pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "UNSUPPORTED");
125  return 0;
126  }
127  res = ast_channel_sendurl(chan, args.url);
128  if (res == -1) {
129  pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "FAILURE");
130  return res;
131  }
132  status = "SUCCESS";
133  if (ast_test_flag(&flags, OPTION_WAIT)) {
134  for(;;) {
135  /* Wait for an event */
136  res = ast_waitfor(chan, -1);
137  if (res < 0)
138  break;
139  f = ast_read(chan);
140  if (!f) {
141  res = -1;
142  status = "FAILURE";
143  break;
144  }
145  if (f->frametype == AST_FRAME_HTML) {
146  switch (f->subclass.integer) {
147  case AST_HTML_LDCOMPLETE:
148  res = 0;
149  ast_frfree(f);
150  status = "NOLOAD";
151  goto out;
152  break;
153  case AST_HTML_NOSUPPORT:
154  /* Does not support transport */
155  status = "UNSUPPORTED";
156  res = 0;
157  ast_frfree(f);
158  goto out;
159  break;
160  default:
161  ast_log(LOG_WARNING, "Don't know what to do with HTML subclass %d\n", f->subclass.integer);
162  };
163  }
164  ast_frfree(f);
165  }
166  }
167 out:
168  pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status);
169  return res;
170 }
union ast_frame_subclass subclass
Definition: frame.h:146
#define ast_test_flag(p, flag)
Definition: utils.h:63
int ast_channel_supports_html(struct ast_channel *channel)
Checks for HTML support on a channel.
Definition: channel.c:5902
#define LOG_WARNING
Definition: logger.h:144
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
Definition: app.c:2101
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
Definition: app.h:572
unsigned int flags
Definition: utils.h:201
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4383
static struct ast_app_option app_opts[128]
Definition: app_url.c:95
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
#define AST_HTML_LDCOMPLETE
Definition: frame.h:230
static struct @350 args
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
int ast_channel_sendurl(struct ast_channel *channel, const char *url)
Sends a URL on a given link Send URL on link.
Definition: channel.c:5914
#define AST_HTML_NOSUPPORT
Definition: frame.h:232
static struct ast_format f[]
Definition: format_g726.c:181
Structure used to handle boolean flags.
Definition: utils.h:200
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_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3539
Data structure associated with a single frame of data.
Definition: frame.h:142
#define AST_APP_ARG(name)
Define an application argument.
Definition: app.h:555
enum ast_frame_type frametype
Definition: frame.h:144
#define ast_frfree(fr)
Definition: frame.h:583
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
Definition: app.h:604
static char url[512]
jack_status_t status
Definition: app_jack.c:143
static int unload_module ( void  )
static

Definition at line 172 of file app_url.c.

References ast_unregister_application().

173 {
175 }
static char * app
Definition: app_url.c:87
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx.c:7705

Variable Documentation

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Send URL 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 182 of file app_url.c.

char* app = "SendURL"
static

Definition at line 87 of file app_url.c.

struct ast_app_option app_opts[128] = { [ 'w' ] = { .flag = OPTION_WAIT }, }
static

Definition at line 95 of file app_url.c.

Referenced by sendurl_exec().

Definition at line 182 of file app_url.c.