[Asterisk-cvs] asterisk/pbx pbx_realtime.c,1.5,1.6

markster at lists.digium.com markster at lists.digium.com
Mon Dec 6 12:23:53 CST 2004


Update of /usr/cvsroot/asterisk/pbx
In directory mongoose.digium.com:/tmp/cvs-serv21970/pbx

Modified Files:
	pbx_realtime.c 
Log Message:
Merge bkw's formatting and variable substitition (bug #2984)


Index: pbx_realtime.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx/pbx_realtime.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- pbx_realtime.c	24 Nov 2004 03:07:08 -0000	1.5
+++ pbx_realtime.c	6 Dec 2004 17:21:44 -0000	1.6
@@ -18,6 +18,8 @@
 #include <asterisk/pbx.h>
 #include <asterisk/module.h>
 #include <asterisk/frame.h>
+#include <asterisk/term.h>
+#include <asterisk/manager.h>
 #include <asterisk/file.h>
 #include <asterisk/cli.h>
 #include <asterisk/lock.h>
@@ -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_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 @@
 			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);




More information about the svn-commits mailing list