git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4965 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2007-04-17 15:58:52 +00:00
parent 4a88a732ef
commit 79651ff819
3 changed files with 24 additions and 3 deletions

View 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()

View 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;
}

View 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;
}