[Freeswitch-svn] [commit] r6455 - in freeswitch/trunk/src: . include mod/applications/mod_commands mod/applications/mod_fifo mod/applications/mod_voicemail mod/endpoints/mod_dingaling mod/event_handlers/mod_event_socket mod/event_handlers/mod_event_test mod/languages/mod_spidermonkey mod/xml_int/mod_xml_cdr
Freeswitch SVN
anthm at freeswitch.org
Fri Nov 30 18:45:27 EST 2007
Author: anthm
Date: Fri Nov 30 18:45:27 2007
New Revision: 6455
Modified:
freeswitch/trunk/src/include/switch_xml.h
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
freeswitch/trunk/src/mod/event_handlers/mod_event_test/mod_event_test.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
freeswitch/trunk/src/switch_xml.cpp
Log:
update
Modified: freeswitch/trunk/src/include/switch_xml.h
==============================================================================
--- freeswitch/trunk/src/include/switch_xml.h (original)
+++ freeswitch/trunk/src/include/switch_xml.h Fri Nov 30 18:45:27 2007
@@ -190,8 +190,8 @@
///\ must be freed.
///\param xml the xml node
///\return the xml text string
-SWITCH_DECLARE(char *) switch_xml_toxml(switch_xml_t xml);
-SWITCH_DECLARE(char *) switch_xml_toxml_buf(switch_xml_t xml, char *buf, switch_size_t buflen, switch_size_t offset);
+SWITCH_DECLARE(char *) switch_xml_toxml(switch_xml_t xml, switch_bool_t prn_header);
+SWITCH_DECLARE(char *) switch_xml_toxml_buf(switch_xml_t xml, char *buf, switch_size_t buflen, switch_size_t offset, switch_bool_t prn_header);
///\brief returns a NULL terminated array of processing instructions for the given
///\ target
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Fri Nov 30 18:45:27 2007
@@ -47,7 +47,7 @@
int argc;
char *mydata = NULL, *argv[3];
char *key, *user, *domain;
- char *xmlstr, *xs;
+ char *xmlstr;
if (!cmd) {
stream->write_function(stream, "bad args\n");
@@ -82,14 +82,10 @@
end:
if (xml && x_user) {
- xmlstr = switch_xml_toxml(x_user);
+ xmlstr = switch_xml_toxml(x_user, SWITCH_FALSE);
assert(xmlstr);
- if ((xs = strstr(xmlstr, "?>"))) {
- xs += 2;
- } else {
- xs = xmlstr;
- }
- stream->write_function(stream, "%s", xs);
+
+ stream->write_function(stream, "%s", xmlstr);
free(xmlstr);
switch_xml_free(xml);
@@ -1607,7 +1603,7 @@
snprintf(count, sizeof(count), "%d", holder.count);
switch_xml_set_attr(switch_xml_set_flag(holder.xml, SWITCH_XML_DUP), strdup("row_count"), strdup(count));
- xmlstr = switch_xml_toxml(holder.xml);
+ xmlstr = switch_xml_toxml(holder.xml, SWITCH_FALSE);
if (xmlstr) {
holder.stream->write_function(holder.stream, "%s", xmlstr);
Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c Fri Nov 30 18:45:27 2007
@@ -527,7 +527,7 @@
switch_mutex_unlock(node->mutex);
}
}
- xml_text = switch_xml_toxml(x_report);
+ xml_text = switch_xml_toxml(x_report, SWITCH_FALSE);
assert(xml_text);
stream->write_function(stream, "%s\n", xml_text);
switch_xml_free(x_report);
Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c Fri Nov 30 18:45:27 2007
@@ -2595,7 +2595,7 @@
sql = switch_mprintf("select * from voicemail_data where user='%s' and domain='%s' order by read_flags", user, domain);
vm_execute_sql_callback(profile, profile->mutex, sql, rss_callback, &holder);
- xmlstr = switch_xml_toxml(holder.xml);
+ xmlstr = switch_xml_toxml(holder.xml, SWITCH_TRUE);
stream->write_function(stream, "%s", xmlstr);
Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c Fri Nov 30 18:45:27 2007
@@ -731,7 +731,7 @@
*xmltxt++ = '\0';
if (strlen(xmltxt) > 2) {
xml = switch_xml_parse_str(xmltxt, strlen(xmltxt));
- form = switch_xml_toxml(xml);
+ form = switch_xml_toxml(xml, SWITCH_FALSE);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, level,
"%s:\n-------------------------------------------------------------------------------\n"
"%s\n", ll, form);
@@ -2301,7 +2301,7 @@
switch_xml_set_attr(vcard, "xmlns", "vcard-tmp");
- if ((xmlstr = switch_xml_toxml(vcard))) {
+ if ((xmlstr = switch_xml_toxml(vcard, SWITCH_FALSE))) {
ldl_handle_send_vcard(handle, to, from, id, xmlstr);
sent = 1;
} else {
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Fri Nov 30 18:45:27 2007
@@ -471,7 +471,7 @@
etype = "xml";
if ((xml = switch_event_xmlize(event, "%s", ""))) {
- listener->ebuf = switch_xml_toxml(xml);
+ listener->ebuf = switch_xml_toxml(xml, SWITCH_FALSE);
switch_xml_free(xml);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XML ERROR!\n");
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_test/mod_event_test.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_test/mod_event_test.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_test/mod_event_test.c Fri Nov 30 18:45:27 2007
@@ -50,7 +50,7 @@
default:
switch_event_serialize(event, &buf);
if ((xml = switch_event_xmlize(event, NULL))) {
- xmlstr = switch_xml_toxml(xml);
+ xmlstr = switch_xml_toxml(xml, SWITCH_FALSE);
dofree++;
}
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Fri Nov 30 18:45:27 2007
@@ -237,7 +237,7 @@
switch_xml_t xml;
char *xmlstr;
if ((xml = switch_event_xmlize(ro->stream->event, SWITCH_VA_NONE))) {
- xmlstr = switch_xml_toxml(xml);
+ xmlstr = switch_xml_toxml(xml, SWITCH_FALSE);
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, xmlstr));
return JS_TRUE;
}
@@ -646,7 +646,7 @@
switch_xml_t xml;
char *xmlstr;
if ((xml = switch_event_xmlize(eo->event, SWITCH_VA_NONE))) {
- xmlstr = switch_xml_toxml(xml);
+ xmlstr = switch_xml_toxml(xml, SWITCH_FALSE);
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, xmlstr));
switch_xml_free(xml);
free(xmlstr);
@@ -1898,7 +1898,7 @@
if (switch_ivr_generate_xml_cdr(jss->session, &cdr) == SWITCH_STATUS_SUCCESS) {
char *xml_text;
- if ((xml_text = switch_xml_toxml(cdr))) {
+ if ((xml_text = switch_xml_toxml(cdr, SWITCH_FALSE))) {
*rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, xml_text));
}
switch_safe_free(xml_text);
Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
==============================================================================
--- freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c (original)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c Fri Nov 30 18:45:27 2007
@@ -76,7 +76,7 @@
if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
/* build the XML */
- if (!(xml_text = switch_xml_toxml(cdr))) {
+ if (!(xml_text = switch_xml_toxml(cdr, SWITCH_TRUE))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
goto error;
}
Modified: freeswitch/trunk/src/switch_xml.cpp
==============================================================================
--- freeswitch/trunk/src/switch_xml.cpp (original)
+++ freeswitch/trunk/src/switch_xml.cpp Fri Nov 30 18:45:27 2007
@@ -1595,16 +1595,16 @@
}
}
-SWITCH_DECLARE(char *) switch_xml_toxml(switch_xml_t xml)
+SWITCH_DECLARE(char *) switch_xml_toxml(switch_xml_t xml, switch_bool_t prn_header)
{
char *s;
s = (char *)malloc(SWITCH_XML_BUFSIZE);
- return switch_xml_toxml_buf(xml, s, SWITCH_XML_BUFSIZE, 0);
+ return switch_xml_toxml_buf(xml, s, SWITCH_XML_BUFSIZE, 0, prn_header);
}
// converts an switch_xml structure back to xml, returning a string of xml date that
// must be freed
-SWITCH_DECLARE(char *) switch_xml_toxml_buf(switch_xml_t xml, char *buf, switch_size_t buflen, switch_size_t offset)
+SWITCH_DECLARE(char *) switch_xml_toxml_buf(switch_xml_t xml, char *buf, switch_size_t buflen, switch_size_t offset, switch_bool_t prn_header)
{
switch_xml_t p = (xml) ? xml->parent : NULL, o = (xml) ? xml->ordered : NULL;
switch_xml_root_t root = (switch_xml_root_t) xml;
@@ -1617,8 +1617,9 @@
assert(s != NULL);
memset(s, 0, max);
len += offset;
- len += sprintf(s + len, "<?xml version=\"1.0\"?>\n");
-
+ if (prn_header) {
+ len += sprintf(s + len, "<?xml version=\"1.0\"?>\n");
+ }
if (!xml || !xml->name) {
if (!(r = (char *)realloc(s, len + 1))) {
More information about the Freeswitch-svn
mailing list