MODLANG-113

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14158 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Brian West 2009-07-08 15:20:55 +00:00
parent 8c286ba428
commit b75a25ee5f
1 changed files with 11 additions and 5 deletions

View File

@ -213,7 +213,8 @@ static switch_xml_t lua_fetch(const char *section,
if (!switch_strlen_zero(globals.xml_handler)) {
lua_State *L = lua_init();
char *mycmd = strdup(globals.xml_handler);
char *str;
const char *str;
int error;
switch_assert(mycmd);
@ -237,22 +238,27 @@ static switch_xml_t lua_fetch(const char *section,
mod_lua_conjure_event(L, params, "params", 1);
}
lua_parse_and_execute(L, mycmd);
if( error = lua_parse_and_execute(L, mycmd) ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "LUA script parse/execute error!\n");
return NULL;
}
lua_getfield(L, LUA_GLOBALSINDEX, "XML_STRING");
str = strdup( lua_tostring(L, 1) );
str = lua_tostring(L, 1);
if (str) {
if (switch_strlen_zero(str)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Result\n");
} else if (!(xml = switch_xml_parse_str((char *) str, strlen(str)))) {
} else if (!(xml = switch_xml_parse_str_dynamic((char *)str, SWITCH_TRUE))) {
/* const char -> char conversion was OK because switch_xml_parse_str_dynamic makes a duplicate of str
and saves this duplcate as root->m which is freed when switch_xml_free is issued
*/
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing XML Result!\n");
}
}
lua_uninit(L);
free(mycmd);
free(str);
}
return xml;