[Freeswitch-trunk] [commit] r6356 - freeswitch/trunk/src/mod/xml_int/mod_xml_curl

Freeswitch SVN mikej at freeswitch.org
Tue Nov 20 02:53:39 EST 2007


Author: mikej
Date: Tue Nov 20 02:53:38 2007
New Revision: 6356

Modified:
   freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c

Log:
resolves MDXMLINT-17 added api command xml_curl (takes debug_on and debug_off as params) that enables and disables keeping the lookup files around for debug reasons.

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	Tue Nov 20 02:53:38 2007
@@ -45,6 +45,8 @@
 	uint32_t ignore_cacert_check;
 };
 
+static int keep_files_around = 0;
+
 typedef struct xml_binding xml_binding_t;
 
 struct config_data {
@@ -52,6 +54,34 @@
 	int fd;
 };
 
+#define XML_CURL_SYNTAX "[debug_on|debug_off]"
+SWITCH_STANDARD_API(xml_curl_function)
+{
+	if (session) {
+		return SWITCH_STATUS_FALSE;
+	}
+
+	if (switch_strlen_zero(cmd)) {
+		goto usage;
+	}
+
+	if (!strcasecmp(cmd, "debug_on")) {
+		keep_files_around = 1;
+	} else if (!strcasecmp(cmd, "debug_off")) {
+		keep_files_around = 0;
+	} else {
+		goto usage;
+	}
+
+	stream->write_function(stream, "OK\n");
+	return SWITCH_STATUS_SUCCESS;
+
+usage:
+	stream->write_function(stream, "USAGE: %s\n", XML_CURL_SYNTAX);
+	return SWITCH_STATUS_SUCCESS;
+}
+
+
 static size_t file_callback(void *ptr, size_t size, size_t nmemb, void *data)
 {
 	register unsigned int realsize = (unsigned int) (size * nmemb);
@@ -160,7 +190,12 @@
 		xml=NULL;
 	}
 
-	unlink(filename);
+	/* Debug by leaving the file behind for review */
+	if(keep_files_around) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "XML response is in %s\n", filename);
+	} else {
+		unlink(filename);
+	}
 
 	return xml;
 }
@@ -246,9 +281,13 @@
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_xml_curl_load)
 {
+	switch_api_interface_t *xml_curl_api_interface;
+
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 
+	SWITCH_ADD_API(xml_curl_api_interface, "xml_curl", "XML Curl", xml_curl_function, XML_CURL_SYNTAX);
+
 	if (do_config() == SWITCH_STATUS_SUCCESS) {
 		curl_global_init(CURL_GLOBAL_ALL);
 	} else {



More information about the Freeswitch-trunk mailing list