pbx: Add helper function to execute applications.

Finding an application and executing it if found is
a common task throughout Asterisk. This adds a helper
function around pbx_exec to do this, to eliminate
redundant code and make it easier for modules to
substitute variables and execute applications by name.

ASTERISK-30061 #close

Change-Id: Ifee4d2825df7545fb515d763d393065675140c84
This commit is contained in:
Naveen Albert
2022-05-15 12:41:06 +00:00
committed by Kevin Harwell
parent 28d8647d4d
commit e23ed9bf06
8 changed files with 51 additions and 49 deletions

View File

@@ -1000,7 +1000,6 @@ static int pbx_builtin_execiftime(struct ast_channel *chan, const char *data)
{
char *s, *appname;
struct ast_timing timing;
struct ast_app *app;
static const char * const usage = "ExecIfTime requires an argument:\n <time range>,<days of week>,<days of month>,<months>[,<timezone>]?<appname>[(<appargs>)]";
if (ast_strlen_zero(data)) {
@@ -1038,13 +1037,7 @@ static int pbx_builtin_execiftime(struct ast_channel *chan, const char *data)
ast_log(LOG_WARNING, "Failed to find closing parenthesis\n");
}
if ((app = pbx_findapp(appname))) {
return pbx_exec(chan, app, S_OR(s, ""));
} else {
ast_log(LOG_WARNING, "Cannot locate application %s\n", appname);
return -1;
}
return ast_pbx_exec_application(chan, appname, S_OR(s, ""));
}
/*!