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"

Include dependency graph for app_url.c:

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_EXTENDED (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 struct ast_app_option app_opts [128] = { [ 'w' ] = { .flag = OPTION_WAIT },}


Detailed Description

App to transmit a URL.

Author:
Mark Spencer <markster@digium.com>

Definition in file app_url.c.


Enumeration Type Documentation

Enumerator:
OPTION_CHEAT 
OPTION_NUMGAMES 
OPTION_WAIT 
OPTION_PATTERNS_DISABLED 

Definition at line 89 of file app_url.c.

00089                   {
00090    OPTION_WAIT = (1 << 0),
00091 };


Function Documentation

AST_MODULE_INFO_STANDARD_EXTENDED ( ASTERISK_GPL_KEY  ,
"Send URL Applications"   
)

static int load_module ( void   )  [static]

Definition at line 177 of file app_url.c.

References ast_register_application_xml, and sendurl_exec().

00178 {
00179    return ast_register_application_xml(app, sendurl_exec);
00180 }

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, out, pbx_builtin_setvar_helper(), status, ast_frame::subclass, tmp(), and url.

Referenced by load_module().

00098 {
00099    int res = 0;
00100    char *tmp;
00101    struct ast_frame *f;
00102    char *status = "FAILURE";
00103    char *opts[0];
00104    struct ast_flags flags = { 0 };
00105    AST_DECLARE_APP_ARGS(args,
00106       AST_APP_ARG(url);
00107       AST_APP_ARG(options);
00108    );
00109    
00110    if (ast_strlen_zero(data)) {
00111       ast_log(LOG_WARNING, "SendURL requires an argument (URL)\n");
00112       pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status);
00113       return -1;
00114    }
00115 
00116    tmp = ast_strdupa(data);
00117 
00118    AST_STANDARD_APP_ARGS(args, tmp);
00119    if (args.argc == 2)
00120       ast_app_parse_options(app_opts, &flags, opts, args.options);
00121    
00122    if (!ast_channel_supports_html(chan)) {
00123       /* Does not support transport */
00124       pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "UNSUPPORTED");
00125       return 0;
00126    }
00127    res = ast_channel_sendurl(chan, args.url);
00128    if (res == -1) {
00129       pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "FAILURE");
00130       return res;
00131    }
00132    status = "SUCCESS";
00133    if (ast_test_flag(&flags, OPTION_WAIT)) {
00134       for(;;) {
00135          /* Wait for an event */
00136          res = ast_waitfor(chan, -1);
00137          if (res < 0) 
00138             break;
00139          f = ast_read(chan);
00140          if (!f) {
00141             res = -1;
00142             status = "FAILURE";
00143             break;
00144          }
00145          if (f->frametype == AST_FRAME_HTML) {
00146             switch (f->subclass.integer) {
00147             case AST_HTML_LDCOMPLETE:
00148                res = 0;
00149                ast_frfree(f);
00150                status = "NOLOAD";
00151                goto out;
00152                break;
00153             case AST_HTML_NOSUPPORT:
00154                /* Does not support transport */
00155                status = "UNSUPPORTED";
00156                res = 0;
00157                ast_frfree(f);
00158                goto out;
00159                break;
00160             default:
00161                ast_log(LOG_WARNING, "Don't know what to do with HTML subclass %d\n", f->subclass.integer);
00162             };
00163          }
00164          ast_frfree(f);
00165       }
00166    } 
00167 out:  
00168    pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status);
00169    return res;
00170 }

static int unload_module ( void   )  [static]

Definition at line 172 of file app_url.c.

References ast_unregister_application().

00173 {
00174    return ast_unregister_application(app);
00175 }


Variable Documentation

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.


Generated on Thu Apr 16 06:28:46 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6