[Freeswitch-svn] [commit] r8418 - in freeswitch/trunk: conf/autoload_configs src src/include src/mod/xml_int/mod_xml_curl

Freeswitch SVN anthm at freeswitch.org
Thu May 15 16:29:09 EDT 2008


Author: anthm
Date: Thu May 15 16:29:08 2008
New Revision: 8418

Modified:
   freeswitch/trunk/conf/autoload_configs/xml_rpc.conf.xml
   freeswitch/trunk/src/include/switch_event.h
   freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c
   freeswitch/trunk/src/switch_event.c

Log:
add patch from MDXMLINT-27

Modified: freeswitch/trunk/conf/autoload_configs/xml_rpc.conf.xml
==============================================================================
--- freeswitch/trunk/conf/autoload_configs/xml_rpc.conf.xml	(original)
+++ freeswitch/trunk/conf/autoload_configs/xml_rpc.conf.xml	Thu May 15 16:29:08 2008
@@ -6,5 +6,7 @@
     <param name="auth-realm" value="freeswitch"/>
     <param name="auth-user" value="freeswitch"/>
     <param name="auth-pass" value="works"/>
+    <!-- one or more of these imply you want to pick the exact variables that are transmitted -->
+    <!--<param name="enable-post-var" value="Unique-ID"/>-->
   </settings>
 </configuration>

Modified: freeswitch/trunk/src/include/switch_event.h
==============================================================================
--- freeswitch/trunk/src/include/switch_event.h	(original)
+++ freeswitch/trunk/src/include/switch_event.h	Thu May 15 16:29:08 2008
@@ -339,7 +339,7 @@
 */
 #define switch_event_fire_data(event, data) switch_event_fire_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, event, data)
 
-SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, const char *prefix);
+SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, const char *prefix,switch_hash_t* vars_map);
 
 ///\}
 

Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c
==============================================================================
--- freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c	(original)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c	Thu May 15 16:29:08 2008
@@ -43,6 +43,8 @@
 	char *cred;
 	int disable100continue;
 	uint32_t ignore_cacert_check;
+	switch_hash_t* vars_map;
+	switch_memory_pool_t* vars_map_pool;
 };
 
 static int keep_files_around = 0;
@@ -110,7 +112,7 @@
 	struct curl_slist *headers = NULL;
 	char hostname[256] = "";
 	char basic_data[512];
-	
+
 	gethostname(hostname, sizeof(hostname));
 
 	if (!binding) {
@@ -134,7 +136,7 @@
 					switch_str_nil(key_name),
 					switch_str_nil(key_value));
 
-	data = switch_event_build_param_string(params, basic_data);
+	data = switch_event_build_param_string(params, basic_data,binding->vars_map);
 	switch_assert(data);
 
 	switch_uuid_get(&uuid);
@@ -204,14 +206,17 @@
 
 	return xml;
 }
-
+#define ENABLE_PARAM_VALUE "enabled"
 static switch_status_t do_config(void)
 {
 	char *cf = "xml_curl.conf";
 	switch_xml_t cfg, xml, bindings_tag, binding_tag, param;
 	xml_binding_t *binding = NULL;
 	int x = 0;
-
+	int need_vars_map = 0;
+	switch_hash_t* vars_map = NULL;
+	switch_memory_pool_t* vars_map_pool = NULL;
+	
 	if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
 		return SWITCH_STATUS_TERM;
@@ -244,7 +249,29 @@
 				disable100continue = 1;
 			} else if (!strcasecmp(var, "ignore-cacert-check") && switch_true(val)) {
 				ignore_cacert_check = 1;
-			}
+			} else if(!strcasecmp(var, "enable-post-var")) {
+				if (!vars_map && need_vars_map == 0) {
+				    if (switch_core_new_memory_pool(&vars_map_pool) != SWITCH_STATUS_SUCCESS) {
+					need_vars_map = -1;
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cant create memory pool!\n");
+					continue;
+				    }
+	
+				    if (switch_core_hash_init(&vars_map,vars_map_pool) != SWITCH_STATUS_SUCCESS) {
+					need_vars_map = -1;
+					switch_core_destroy_memory_pool(&vars_map_pool);
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cant init params hash!\n");
+					continue;
+				    }
+				    need_vars_map = 1;
+				}
+				
+				if(vars_map)
+				    if (switch_core_hash_insert(vars_map,val,ENABLE_PARAM_VALUE) != SWITCH_STATUS_SUCCESS) {
+					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cant add %s to params hash!\n",val);
+				    }
+				
+		        }	
 		}
 
 		if (!url) {
@@ -269,6 +296,9 @@
 
 		binding->disable100continue = disable100continue;
 		binding->ignore_cacert_check = ignore_cacert_check;
+		
+		binding->vars_map = vars_map;
+		binding->vars_map_pool = vars_map_pool;
 
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML Fetch Function [%s] [%s]\n",
 						  switch_strlen_zero(bname) ? "N/A" : bname, binding->url, binding->bindings ? binding->bindings : "all");

Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c	(original)
+++ freeswitch/trunk/src/switch_event.c	Thu May 15 16:29:08 2008
@@ -1275,7 +1275,7 @@
 	return data;
 }
 
-SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, const char *prefix)
+SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, const char *prefix, switch_hash_t* vars_map)
 {
 	switch_stream_handle_t stream = { 0 };
 	switch_size_t encode_len = 1024, new_len = 0;
@@ -1284,6 +1284,7 @@
 	char *e = NULL;
 	switch_event_header_t *hi;
 	uint32_t x = 0;
+	void* data = NULL;
 
 	SWITCH_STANDARD_STREAM(stream);
 
@@ -1318,10 +1319,18 @@
 
 	if (event) {
 		if ((hi = event->headers)) {
+		
 			for (; hi; hi = hi->next) {
 				char *var = hi->name;
 				char *val = hi->value;
-			
+				
+				if (vars_map != NULL)
+				{
+				    if ((data = switch_core_hash_find(vars_map,var)) == NULL || strcasecmp(((char*)data),"enabled"))
+					continue;
+				    
+				}
+				
 				new_len = (strlen((char *) var) * 3) + 1;
 				if (encode_len < new_len) {
 					char *tmp;
@@ -1339,6 +1348,7 @@
 			}
 		}
 	}
+	
 	e = (char *) stream.data + (strlen((char *) stream.data) - 1);
 
 	if (e && *e == '&') {



More information about the Freeswitch-svn mailing list