115 #define MAXRESULT 1024
130 static const char app_tryexec[] =
"TryExec";
131 static const char app_execif[] =
"ExecIf";
136 char *s, *appname, *endargs;
140 if (ast_strlen_zero(data))
144 appname = strsep(&s,
"(");
146 endargs = strrchr(s,
')');
158 ast_log(LOG_WARNING,
"Could not find application (%s)\n", appname);
167 static int tryexec_exec(
struct ast_channel *chan,
const char *data)
170 char *s, *appname, *endargs;
174 if (ast_strlen_zero(data))
178 appname = strsep(&s,
"(");
180 endargs = strrchr(s,
')');
193 ast_log(LOG_WARNING,
"Could not find application (%s)\n", appname);
202 static int execif_exec(
struct ast_channel *chan,
const char *data)
205 char *truedata = NULL, *falsedata = NULL, *end, *firstcomma, *firstquestion;
217 firstcomma = strchr(parse,
',');
218 firstquestion = strchr(parse,
'?');
220 if ((firstcomma != NULL && firstquestion != NULL && firstcomma < firstquestion) || (firstquestion == NULL)) {
229 ast_log(LOG_WARNING,
"Deprecated syntax found. Please upgrade to using ExecIf(<expr>?%s(%s))\n", depr.appname, depr.appargs);
232 expr.expr = depr.expr;
233 apps.t = depr.appname;
235 truedata = depr.appargs;
239 AST_NONSTANDARD_RAW_ARGS(expr, parse,
'?');
240 if (ast_strlen_zero(expr.remainder)) {
241 ast_log(LOG_ERROR,
"Usage: ExecIf(<expr>?<appiftrue>(<args>)[:<appiffalse>(<args)])\n");
245 AST_NONSTANDARD_RAW_ARGS(
apps, expr.remainder,
':');
247 if (
apps.t && (truedata = strchr(
apps.t,
'('))) {
249 if ((end = strrchr(truedata,
')'))) {
254 if (
apps.f && (falsedata = strchr(
apps.f,
'('))) {
256 if ((end = strrchr(falsedata,
')'))) {
266 ast_log(LOG_WARNING,
"Could not find application! (%s)\n",
apps.t);
269 }
else if (!ast_strlen_zero(
apps.f)) {
273 ast_log(LOG_WARNING,
"Could not find application! (%s)\n",
apps.f);
281 static int unload_module(
void)
292 static int load_module(
void)
300 AST_MODULE_INFO_STANDARD(
ASTERISK_GPL_KEY,
"Executes dialplan applications");
Main Channel structure associated with a channel.
Asterisk main include file. File version handling, generic pbx functions.
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
Registered applications container.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
int pbx_checkcondition(const char *condition)
Evaluate a condition.
void ast_str_substitute_variables(struct ast_str **buf, ssize_t maxlen, struct ast_channel *chan, const char *templ)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_unregister_application(const char *app)
Unregister an application.
static const char app_exec[]
General Asterisk PBX channel definitions.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Core PBX routines and definitions.
Support for dynamic strings.
union ast_frame::@224 data
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 S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
ast_app: A registered application
struct ast_app * pbx_findapp(const char *app)
Look up an application.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
#define AST_APP_ARG(name)
Define an application argument.