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

@@ -166,14 +166,12 @@ static int predial_disable(void *data)
static void answer_exec_run(struct ast_dial *dial, struct ast_dial_channel *dial_channel, char *app, char *args)
{
struct ast_channel *chan = dial_channel->owner;
struct ast_app *ast_app = pbx_findapp(app);
/* If the application was not found, return immediately */
if (!ast_app)
/* Execute the application, if available */
if (ast_pbx_exec_application(chan, app, args)) {
/* If the application was not found, return immediately */
return;
/* All is well... execute the application */
pbx_exec(chan, ast_app, args);
}
/* If another thread is not taking over hang up the channel */
ast_mutex_lock(&dial->lock);