cleanup, null checks. etc.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6708 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-12-12 22:25:15 +00:00
parent 54ec86f6ce
commit 504f1275db
2 changed files with 114 additions and 110 deletions

View File

@ -74,9 +74,14 @@ static switch_status_t my_on_hangup(switch_core_session_t *session)
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_status_t status = SWITCH_STATUS_FALSE;
if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
if (switch_ivr_generate_xml_cdr(session, &cdr) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Generating Data!\n");
return SWITCH_STATUS_FALSE;
}
/* build the XML */
if (!(xml_text = switch_xml_toxml(cdr, SWITCH_TRUE))) {
xml_text = switch_xml_toxml(cdr, SWITCH_TRUE);
if (!xml_text) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
goto error;
}
@ -117,7 +122,7 @@ static switch_status_t my_on_hangup(switch_core_session_t *session)
switch_size_t need_bytes = strlen(xml_text) * 3;
xml_text_escaped = malloc(need_bytes);
assert(xml_text_escaped);
switch_assert(xml_text_escaped);
memset(xml_text_escaped, 0, sizeof(xml_text_escaped));
if (globals.encode == 1) {
headers = curl_slist_append(headers, "Content-Type: application/x-www-form-urlencoded");
@ -198,9 +203,6 @@ static switch_status_t my_on_hangup(switch_core_session_t *session)
}
}
}
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Generating Data!\n");
}
success:

View File

@ -194,7 +194,9 @@ static switch_xml_t xml_url_fetch(const char *section, const char *tag_name, con
if(keep_files_around) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "XML response is in %s\n", filename);
} else {
unlink(filename);
if (unlink(filename) != 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "XML response file [%s] delete failed\n", filename);
}
}
return xml;