From dc074b702973191d2a9a193066dea6ad8d0d498d Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Mon, 6 Dec 2004 17:21:44 +0000 Subject: [PATCH] Merge bkw's formatting and variable substitition (bug #2984) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4392 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- pbx/pbx_realtime.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/pbx/pbx_realtime.c b/pbx/pbx_realtime.c index 52de08ba8e..39c2845d5a 100755 --- a/pbx/pbx_realtime.c +++ b/pbx/pbx_realtime.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include #include @@ -39,6 +41,8 @@ #define MODE_MATCHMORE 1 #define MODE_CANMATCH 2 +#define EXT_DATA_SIZE 256 + static char *tdesc = "Realtime Switch"; /* Realtime switch looks up extensions in the supplied realtime table. @@ -159,7 +163,11 @@ static int realtime_canmatch(struct ast_channel *chan, const char *context, cons static int realtime_exec(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, int newstack, const char *data) { char app[256]; - char *appdata=""; + char appdata[512]=""; + char *tmp=""; + char tmp1[80]; + char tmp2[80]; + char tmp3[EXT_DATA_SIZE]; struct ast_app *a; struct ast_variable *v; REALTIME_COMMON(MODE_MATCH); @@ -169,13 +177,30 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch if (!strcasecmp(v->name, "app")) strncpy(app, v->value, sizeof(app) -1 ); else if (!strcasecmp(v->name, "appdata")) - appdata = ast_strdupa(v->value); + tmp = ast_strdupa(v->value); v = v->next; } ast_destroy_realtime(var); if (!ast_strlen_zero(app)) { a = pbx_findapp(app); if (a) { + if(!ast_strlen_zero(tmp)) + pbx_substitute_variables_helper(chan, tmp, appdata, sizeof(appdata) - 1); + if (option_verbose > 2) + ast_verbose( VERBOSE_PREFIX_3 "Executing %s(\"%s\", \"%s\")\n", + term_color(tmp1, app, COLOR_BRCYAN, 0, sizeof(tmp1)), + term_color(tmp2, chan->name, COLOR_BRMAGENTA, 0, sizeof(tmp2)), + term_color(tmp3, (!ast_strlen_zero(appdata) ? (char *)appdata : ""), COLOR_BRMAGENTA, 0, sizeof(tmp3))); + manager_event(EVENT_FLAG_CALL, "Newexten", + "Channel: %s\r\n" + "Context: %s\r\n" + "Extension: %s\r\n" + "Priority: %d\r\n" + "Application: %s\r\n" + "AppData: %s\r\n" + "Uniqueid: %s\r\n", + chan->name, chan->context, chan->exten, chan->priority, app, appdata ? appdata : "(NULL)", chan->uniqueid); + res = pbx_exec(chan, a, appdata, newstack); } else ast_log(LOG_NOTICE, "No such application '%s' for extension '%s' in context '%s'\n", app, exten, context);