Asterisk - The Open Source Telephony Project  GIT-master-1f78ee9
Enumerations | Functions | Variables
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_CHEAT = (1 << 0), OPTION_NUMGAMES = (1 << 1), OPTION_WAIT = (1 << 0), OPTION_PATTERNS_DISABLED = (1 << 0) }
 

Functions

 AST_MODULE_INFO_STANDARD_DEPRECATED (ASTERISK_GPL_KEY, "Send URL Applications")
 
static int load_module (void)
 
static int sendurl_exec (struct ast_channel *chan, const char *data)
 
static int unload_module (void)
 

Variables

static char * app = "SendURL"
 
static const struct ast_app_option app_opts [128] = { [ 'w' ] = { .flag = OPTION_WAIT }, }
 

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

◆ option_flags

Enumerator
OPTION_CHEAT 
OPTION_NUMGAMES 
OPTION_WAIT 
OPTION_PATTERNS_DISABLED 

Definition at line 87 of file app_url.c.

87  {
88  OPTION_WAIT = (1 << 0),
89 };

Function Documentation

◆ AST_MODULE_INFO_STANDARD_DEPRECATED()

AST_MODULE_INFO_STANDARD_DEPRECATED ( ASTERISK_GPL_KEY  ,
"Send URL Applications"   
)

Referenced by load_module().

◆ load_module()

static int load_module ( void  )
static

Definition at line 175 of file app_url.c.

References app, AST_MODULE_INFO_STANDARD_DEPRECATED(), ast_register_application_xml, ASTERISK_GPL_KEY, and sendurl_exec().

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

◆ sendurl_exec()

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

Definition at line 95 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(), ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, OPTION_WAIT, options, out, pbx_builtin_setvar_helper(), status, ast_frame::subclass, tmp(), and url.

Referenced by load_module().

96 {
97  int res = 0;
98  char *tmp;
99  struct ast_frame *f;
100  char *status = "FAILURE";
101  char *opts[0];
102  struct ast_flags flags = { 0 };
104  AST_APP_ARG(url);
106  );
107 
108  if (ast_strlen_zero(data)) {
109  ast_log(LOG_WARNING, "SendURL requires an argument (URL)\n");
110  pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status);
111  return -1;
112  }
113 
114  tmp = ast_strdupa(data);
115 
117  if (args.argc == 2)
118  ast_app_parse_options(app_opts, &flags, opts, args.options);
119 
120  if (!ast_channel_supports_html(chan)) {
121  /* Does not support transport */
122  pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "UNSUPPORTED");
123  return 0;
124  }
125  res = ast_channel_sendurl(chan, args.url);
126  if (res == -1) {
127  pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "FAILURE");
128  return res;
129  }
130  status = "SUCCESS";
131  if (ast_test_flag(&flags, OPTION_WAIT)) {
132  for(;;) {
133  /* Wait for an event */
134  res = ast_waitfor(chan, -1);
135  if (res < 0)
136  break;
137  f = ast_read(chan);
138  if (!f) {
139  res = -1;
140  status = "FAILURE";
141  break;
142  }
143  if (f->frametype == AST_FRAME_HTML) {
144  switch (f->subclass.integer) {
145  case AST_HTML_LDCOMPLETE:
146  res = 0;
147  ast_frfree(f);
148  status = "NOLOAD";
149  goto out;
150  break;
151  case AST_HTML_NOSUPPORT:
152  /* Does not support transport */
153  status = "UNSUPPORTED";
154  res = 0;
155  ast_frfree(f);
156  goto out;
157  break;
158  default:
159  ast_log(LOG_WARNING, "Don't know what to do with HTML subclass %d\n", f->subclass.integer);
160  };
161  }
162  ast_frfree(f);
163  }
164  }
165 out:
166  pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status);
167  return res;
168 }
#define AST_HTML_NOSUPPORT
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define AST_HTML_LDCOMPLETE
int ast_channel_supports_html(struct ast_channel *channel)
Checks for HTML support on a channel.
Definition: channel.c:6559
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
#define LOG_WARNING
Definition: logger.h:274
static int tmp()
Definition: bt_open.c:389
unsigned int flags
Definition: utils.h:200
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4251
const char * args
struct ast_frame_subclass subclass
static const struct ast_app_option app_opts[128]
Definition: app_url.c:93
#define ast_log
Definition: astobj2.c:42
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
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: main/app.c:2829
#define ast_strlen_zero(a)
Definition: muted.c:73
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:6571
Structure used to handle boolean flags.
Definition: utils.h:199
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...
FILE * out
Definition: utils/frame.c:33
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3137
#define ast_frfree(fr)
Data structure associated with a single frame of data.
enum ast_frame_type frametype
static struct test_options options
static char url[512]
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
jack_status_t status
Definition: app_jack.c:146
#define AST_APP_ARG(name)
Define an application argument.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 170 of file app_url.c.

References app, and ast_unregister_application().

171 {
173 }
static char * app
Definition: app_url.c:85
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

Variable Documentation

◆ app

char* app = "SendURL"
static

Definition at line 85 of file app_url.c.

Referenced by load_module(), and unload_module().

◆ app_opts

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

Definition at line 93 of file app_url.c.

Referenced by sendurl_exec().