]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 17 Apr 2007 15:58:52 +0000 (15:58 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 17 Apr 2007 15:58:52 +0000 (15:58 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4965 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_xml.h
src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c
src/switch_xml.c

index 89814544ca74ef4cbb4e4b4649248b1e97d09548..a40a2c17c67ad34851803320f4d4d56439a18697 100644 (file)
@@ -117,6 +117,8 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fd(int fd);
 ///\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()
index f4ffc0710eb971c7775624e1bb90a950ded5b649..3ec37baa5dd6ba20327acade6bb28786b3ef051d 100644 (file)
@@ -316,7 +316,7 @@ static switch_caller_extension_t *dialplan_hunt(switch_core_session_t *session,
 
        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;
                }
index 61a0c4cde4fbbe45349d0306570b5c6794fde390..584528c4af60c4ee2431a3ddf2a9be2ee59ed2a7 100644 (file)
@@ -1032,7 +1032,26 @@ static int preprocess(const char *file, int write_fd, int rlevel)
        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 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file(const char *file)
        } else {
                abs = file;
        }
-
+       
        if (!(new_file = switch_mprintf("%s%s%s.fsxml", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, abs))) {
                return NULL;
        }