[Freeswitch-svn] [commit] r3794 - in freeswitch/trunk/src: . mod/dialplans/mod_dialplan_xml

Freeswitch SVN anthm at freeswitch.org
Fri Dec 22 09:50:48 EST 2006


Author: anthm
Date: Fri Dec 22 09:50:48 2006
New Revision: 3794

Modified:
   freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
   freeswitch/trunk/src/switch_ivr.c

Log:
make substitution dynamic

Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
==============================================================================
--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c	(original)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c	Fri Dec 22 09:50:48 2006
@@ -150,11 +150,19 @@
 		for (xaction = switch_xml_child(xcond, "action"); xaction; xaction = xaction->next) {
 			char *application = (char*) switch_xml_attr_soft(xaction, "application");
 			char *data = (char *) switch_xml_attr_soft(xaction, "data");
-			char substituted[1024] = "";
+			char *substituted = NULL;
+            switch_size_t len = 0;
 			char *app_data = NULL;
 
 			if (field && strchr(expression, '(')) {
-				switch_perform_substitution(re, proceed, data, field_data, substituted, sizeof(substituted), ovector);
+                len = strlen(data) + strlen(field_data) + 10;
+                if (!(substituted = malloc(len))) {
+                    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n");
+                    proceed = 0;
+                    goto done;
+                }
+                memset(substituted, 0, len);
+				switch_perform_substitution(re, proceed, data, field_data, substituted, len, ovector);
 				app_data = substituted;
 			} else {
 				app_data = data;
@@ -170,6 +178,7 @@
 			}
 
 			switch_caller_extension_add_application(session, *extension, application, app_data);
+            switch_safe_free(substituted);
 		}
         
 		switch_clean_re(re);

Modified: freeswitch/trunk/src/switch_ivr.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr.c	(original)
+++ freeswitch/trunk/src/switch_ivr.c	Fri Dec 22 09:50:48 2006
@@ -4487,17 +4487,26 @@
         if (pattern) {
             pcre *re = NULL;
             int proceed = 0, ovector[30];
-            char substituted[1024] = "";
+            char *substituted = NULL;
+            switch_size_t len = 0;
             char *odata = NULL;
             char *expanded = NULL;
-
+            
             if ((proceed = switch_perform_regex(data, pattern, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
                 for (action = switch_xml_child(input, "action"); action; action = action->next) {
                     char *adata = (char *) switch_xml_attr_soft(action, "data");
                     char *func = (char *) switch_xml_attr_soft(action, "function");
 
                     if (strchr(pattern, '(') && strchr(adata, '$')) {
-                        switch_perform_substitution(re, proceed, adata, data, substituted, sizeof(substituted), ovector);
+                        len = strlen(data) + strlen(adata) + 10;
+                        if (!(substituted = malloc(len))) {
+                            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
+                            switch_clean_re(re);
+                            switch_safe_free(expanded);
+                            goto done;
+                        }
+                        memset(substituted, 0, len);
+                        switch_perform_substitution(re, proceed, adata, data, substituted, len, ovector);
                         odata = substituted;
                     } else {
                         odata = adata;
@@ -4566,6 +4575,7 @@
 
             switch_clean_re(re);
             switch_safe_free(expanded);
+            switch_safe_free(substituted);
         }
 
         input = input->next;



More information about the Freeswitch-svn mailing list