Asterisk - The Open Source Telephony Project  18.5.0
Macros | Functions | Variables
app_stasis.c File Reference

Stasis dialplan application. More...

#include "asterisk.h"
#include "asterisk/app.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_app_impl.h"
Include dependency graph for app_stasis.c:

Go to the source code of this file.

Macros

#define MAX_ARGS   128
 Maximum number of arguments for the Stasis dialplan application. More...
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static int app_exec (struct ast_channel *chan, const char *data)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int load_module (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Stasis dialplan application" , .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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_stasis", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static const char * stasis = "Stasis"
 Dialplan application name. More...
 

Detailed Description

Stasis dialplan application.

Author
David M. Lee, II dlee@.nosp@m.digi.nosp@m.um.co.nosp@m.m

Definition in file app_stasis.c.

Macro Definition Documentation

◆ MAX_ARGS

#define MAX_ARGS   128

Maximum number of arguments for the Stasis dialplan application.

Definition at line 77 of file app_stasis.c.

Referenced by app_exec().

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 141 of file app_stasis.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 141 of file app_stasis.c.

◆ app_exec()

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

/brief Stasis dialplan application callback

Definition at line 83 of file app_stasis.c.

References app_name(), args, AST_APP_ARG, ast_assert, ast_check_hangup(), AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, LOG_WARNING, MAX_ARGS, NULL, parse(), pbx_builtin_setvar_helper(), and stasis_app_exec().

Referenced by load_module().

84 {
85  char *parse = NULL;
86  int ret = -1;
87 
90  AST_APP_ARG(app_argv)[MAX_ARGS];
91  );
92 
93  ast_assert(chan != NULL);
94  ast_assert(data != NULL);
95 
96  pbx_builtin_setvar_helper(chan, "STASISSTATUS", "");
97 
98  /* parse the arguments */
99  parse = ast_strdupa(data);
100  AST_STANDARD_APP_ARGS(args, parse);
101 
102  if (args.argc < 1) {
103  ast_log(LOG_WARNING, "Stasis app_name argument missing\n");
104  } else {
105  ret = stasis_app_exec(chan,
106  args.app_name,
107  args.argc - 1,
108  args.app_argv);
109  }
110 
111  if (ret) {
112  /* set ret to 0 so pbx_core doesnt hangup the channel */
113  if (!ast_check_hangup(chan)) {
114  ret = 0;
115  } else {
116  ret = -1;
117  }
118  pbx_builtin_setvar_helper(chan, "STASISSTATUS", "FAILED");
119  } else {
120  pbx_builtin_setvar_helper(chan, "STASISSTATUS", "SUCCESS");
121  }
122 
123  return ret;
124 }
#define MAX_ARGS
Maximum number of arguments for the Stasis dialplan application.
Definition: app_stasis.c:77
#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
int stasis_app_exec(struct ast_channel *chan, const char *app_name, int argc, char *argv[])
Control a channel using stasis_app.
Definition: res_stasis.c:1324
#define ast_assert(a)
Definition: utils.h:695
const char * args
#define NULL
Definition: resample.c:96
#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_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
Definition: channel.c:445
const char * app_name(struct ast_app *app)
Definition: pbx_app.c:463
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
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...
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
#define AST_APP_ARG(name)
Define an application argument.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 141 of file app_stasis.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 126 of file app_stasis.c.

References app_exec(), ast_register_application_xml, and stasis.

Referenced by unload_module().

127 {
129 }
static const char * stasis
Dialplan application name.
Definition: app_stasis.c:80
static int app_exec(struct ast_channel *chan, const char *data)
Definition: app_stasis.c:83
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 131 of file app_stasis.c.

References AST_MODFLAG_DEFAULT, AST_MODULE_INFO(), AST_MODULE_SUPPORT_CORE, ast_unregister_application(), ASTERISK_GPL_KEY, load_module(), and stasis.

132 {
134 }
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
static const char * stasis
Dialplan application name.
Definition: app_stasis.c:80

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Stasis dialplan application" , .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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_stasis", }
static

Definition at line 141 of file app_stasis.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 141 of file app_stasis.c.

◆ stasis

const char* stasis = "Stasis"
static

Dialplan application name.

Definition at line 80 of file app_stasis.c.

Referenced by ast_bridge_publish_blind_transfer(), load_module(), snoop_stasis_thread(), and unload_module().