[Freeswitch-svn] [commit] r4965 - in freeswitch/trunk/src: . include mod/dialplans/mod_dialplan_xml
Freeswitch SVN
anthm at freeswitch.org
Tue Apr 17 11:58:53 EDT 2007
Author: anthm
Date: Tue Apr 17 11:58:52 2007
New Revision: 4965
Modified:
freeswitch/trunk/src/include/switch_xml.h
freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
freeswitch/trunk/src/switch_xml.c
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 Tue Apr 17 11:58:52 2007
@@ -117,6 +117,8 @@
///\return a formated xml node or NULL
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file(const char *file);
+SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file_simple(const char *file);
+
///\brief Wrapper for switch_xml_parse_str() that accepts a file stream. Reads the entire
///\ stream into memory and then parses it. For xml files, use switch_xml_parse_file()
///\ or switch_xml_parse_fd()
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 Tue Apr 17 11:58:52 2007
@@ -316,7 +316,7 @@
if (!switch_strlen_zero(alt_path)) {
switch_xml_t conf = NULL, tag = NULL;
- if (!(alt_root = switch_xml_parse_file(alt_path))) {
+ if (!(alt_root = switch_xml_parse_file_simple(alt_path))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of [%s] failed\n", alt_path);
goto done;
}
Modified: freeswitch/trunk/src/switch_xml.c
==============================================================================
--- freeswitch/trunk/src/switch_xml.c (original)
+++ freeswitch/trunk/src/switch_xml.c Tue Apr 17 11:58:52 2007
@@ -1032,7 +1032,26 @@
return write_fd;
}
-// a wrapper for switch_xml_parse_fd that accepts a file name
+SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file_simple(const char *file)
+{
+ int fd = -1;
+ struct stat st;
+ switch_size_t l;
+ void *m;
+ switch_xml_root_t root;
+
+ if ((fd = open(file, O_RDONLY, 0)) > -1) {
+ fstat(fd, &st);
+ l = read(fd, m = malloc(st.st_size), st.st_size);
+ root = (switch_xml_root_t) switch_xml_parse_str(m, l);
+ root->dynamic = 1;
+ close(fd);
+ return &root->xml;
+ }
+
+ return NULL;
+}
+
SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file(const char *file)
{
int fd = -1, write_fd = -1;
@@ -1045,7 +1064,7 @@
} else {
abs = file;
}
-
+
if (!(new_file = switch_mprintf("%s%s%s.fsxml", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, abs))) {
return NULL;
}
More information about the Freeswitch-svn
mailing list