move ExecIf from app_while.c to app_exec.c (issue #7094, north)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@25013 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
a09110c810
commit
e5b6df5769
|
@ -83,6 +83,14 @@ static char *tryexec_descrip =
|
||||||
" NOAPP if the application was not found or was not specified\n"
|
" NOAPP if the application was not found or was not specified\n"
|
||||||
" NOMEMORY if there was not enough memory to execute.\n";
|
" NOMEMORY if there was not enough memory to execute.\n";
|
||||||
|
|
||||||
|
static char *app_execif = "ExecIf";
|
||||||
|
static char *execif_synopsis = "Executes dialplan application, conditionally";
|
||||||
|
static char *execif_descrip =
|
||||||
|
"Usage: ExecIF (<expr>|<app>|<data>)\n"
|
||||||
|
"If <expr> is true, execute and return the result of <app>(<data>).\n"
|
||||||
|
"If <expr> is true, but <app> is not found, then the application\n"
|
||||||
|
"will return a non-zero value.\n";
|
||||||
|
|
||||||
LOCAL_USER_DECL;
|
LOCAL_USER_DECL;
|
||||||
|
|
||||||
static int exec_exec(struct ast_channel *chan, void *data)
|
static int exec_exec(struct ast_channel *chan, void *data)
|
||||||
|
@ -160,12 +168,54 @@ static int tryexec_exec(struct ast_channel *chan, void *data)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int execif_exec(struct ast_channel *chan, void *data) {
|
||||||
|
int res=0;
|
||||||
|
struct localuser *u;
|
||||||
|
char *myapp = NULL;
|
||||||
|
char *mydata = NULL;
|
||||||
|
char *expr = NULL;
|
||||||
|
struct ast_app *app = NULL;
|
||||||
|
|
||||||
|
LOCAL_USER_ADD(u);
|
||||||
|
|
||||||
|
if (!(expr = ast_strdupa(data))) {
|
||||||
|
LOCAL_USER_REMOVE(u);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((myapp = strchr(expr,'|'))) {
|
||||||
|
*myapp = '\0';
|
||||||
|
myapp++;
|
||||||
|
if ((mydata = strchr(myapp,'|'))) {
|
||||||
|
*mydata = '\0';
|
||||||
|
mydata++;
|
||||||
|
} else
|
||||||
|
mydata = "";
|
||||||
|
|
||||||
|
if (pbx_checkcondition(expr)) {
|
||||||
|
if ((app = pbx_findapp(myapp))) {
|
||||||
|
res = pbx_exec(chan, app, mydata);
|
||||||
|
} else {
|
||||||
|
ast_log(LOG_WARNING, "Count not find application! (%s)\n", myapp);
|
||||||
|
res = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ast_log(LOG_ERROR,"Invalid Syntax.\n");
|
||||||
|
res = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOCAL_USER_REMOVE(u);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static int unload_module(void *mod)
|
static int unload_module(void *mod)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = ast_unregister_application(app_exec);
|
res = ast_unregister_application(app_exec);
|
||||||
res |= ast_unregister_application(app_tryexec);
|
res |= ast_unregister_application(app_tryexec);
|
||||||
|
res |= ast_unregister_application(app_execif);
|
||||||
|
|
||||||
STANDARD_HANGUP_LOCALUSERS;
|
STANDARD_HANGUP_LOCALUSERS;
|
||||||
|
|
||||||
|
@ -176,6 +226,7 @@ static int load_module(void *mod)
|
||||||
{
|
{
|
||||||
int res = ast_register_application(app_exec, exec_exec, exec_synopsis, exec_descrip);
|
int res = ast_register_application(app_exec, exec_exec, exec_synopsis, exec_descrip);
|
||||||
res |= ast_register_application(app_tryexec, tryexec_exec, tryexec_synopsis, tryexec_descrip);
|
res |= ast_register_application(app_tryexec, tryexec_exec, tryexec_synopsis, tryexec_descrip);
|
||||||
|
res |= ast_register_application(app_execif, execif_exec, execif_synopsis, execif_descrip);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
/*! \file
|
/*! \file
|
||||||
*
|
*
|
||||||
* \brief While Loop and ExecIf Implementations
|
* \brief While Loop Implementation
|
||||||
*
|
*
|
||||||
* \author Anthony Minessale <anthmct@yahoo.com>
|
* \author Anthony Minessale <anthmct@yahoo.com>
|
||||||
*
|
*
|
||||||
|
@ -47,14 +47,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
#define ALL_DONE(u,ret) {LOCAL_USER_REMOVE(u); return ret;}
|
#define ALL_DONE(u,ret) {LOCAL_USER_REMOVE(u); return ret;}
|
||||||
|
|
||||||
|
|
||||||
static char *exec_app = "ExecIf";
|
|
||||||
static char *exec_desc =
|
|
||||||
"Usage: ExecIF (<expr>|<app>|<data>)\n"
|
|
||||||
"If <expr> is true, execute and return the result of <app>(<data>).\n"
|
|
||||||
"If <expr> is true, but <app> is not found, then the application\n"
|
|
||||||
"will return a non-zero value.\n";
|
|
||||||
static char *exec_synopsis = "Conditional exec";
|
|
||||||
|
|
||||||
static char *start_app = "While";
|
static char *start_app = "While";
|
||||||
static char *start_desc =
|
static char *start_desc =
|
||||||
"Usage: While(<expr>)\n"
|
"Usage: While(<expr>)\n"
|
||||||
|
@ -87,46 +79,6 @@ static char *tdesc = "While Loops and Conditional Execution";
|
||||||
|
|
||||||
LOCAL_USER_DECL;
|
LOCAL_USER_DECL;
|
||||||
|
|
||||||
static int execif_exec(struct ast_channel *chan, void *data) {
|
|
||||||
int res=0;
|
|
||||||
struct localuser *u;
|
|
||||||
char *myapp = NULL;
|
|
||||||
char *mydata = NULL;
|
|
||||||
char *expr = NULL;
|
|
||||||
struct ast_app *app = NULL;
|
|
||||||
|
|
||||||
LOCAL_USER_ADD(u);
|
|
||||||
|
|
||||||
if (!(expr = ast_strdupa(data))) {
|
|
||||||
LOCAL_USER_REMOVE(u);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((myapp = strchr(expr,'|'))) {
|
|
||||||
*myapp = '\0';
|
|
||||||
myapp++;
|
|
||||||
if ((mydata = strchr(myapp,'|'))) {
|
|
||||||
*mydata = '\0';
|
|
||||||
mydata++;
|
|
||||||
} else
|
|
||||||
mydata = "";
|
|
||||||
|
|
||||||
if (pbx_checkcondition(expr)) {
|
|
||||||
if ((app = pbx_findapp(myapp))) {
|
|
||||||
res = pbx_exec(chan, app, mydata);
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_WARNING, "Count not find application! (%s)\n", myapp);
|
|
||||||
res = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ast_log(LOG_ERROR,"Invalid Syntax.\n");
|
|
||||||
res = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ALL_DONE(u,res);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define VAR_SIZE 64
|
#define VAR_SIZE 64
|
||||||
|
|
||||||
|
|
||||||
|
@ -364,7 +316,6 @@ static int unload_module(void *mod)
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = ast_unregister_application(start_app);
|
res = ast_unregister_application(start_app);
|
||||||
res |= ast_unregister_application(exec_app);
|
|
||||||
res |= ast_unregister_application(stop_app);
|
res |= ast_unregister_application(stop_app);
|
||||||
res |= ast_unregister_application(exit_app);
|
res |= ast_unregister_application(exit_app);
|
||||||
res |= ast_unregister_application(continue_app);
|
res |= ast_unregister_application(continue_app);
|
||||||
|
@ -379,7 +330,6 @@ static int load_module(void *mod)
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = ast_register_application(start_app, while_start_exec, start_synopsis, start_desc);
|
res = ast_register_application(start_app, while_start_exec, start_synopsis, start_desc);
|
||||||
res |= ast_register_application(exec_app, execif_exec, exec_synopsis, exec_desc);
|
|
||||||
res |= ast_register_application(stop_app, while_end_exec, stop_synopsis, stop_desc);
|
res |= ast_register_application(stop_app, while_end_exec, stop_synopsis, stop_desc);
|
||||||
res |= ast_register_application(exit_app, while_exit_exec, exit_synopsis, exit_desc);
|
res |= ast_register_application(exit_app, while_exit_exec, exit_synopsis, exit_desc);
|
||||||
res |= ast_register_application(continue_app, while_continue_exec, continue_synopsis, continue_desc);
|
res |= ast_register_application(continue_app, while_continue_exec, continue_synopsis, continue_desc);
|
||||||
|
|
Loading…
Reference in New Issue