fix for FSCORE-40

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5566 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-08-03 21:29:01 +00:00
parent d3aa5b433b
commit f1222ba2fd
14 changed files with 48 additions and 30 deletions

View File

@ -1059,7 +1059,8 @@ static int show_as_xml_callback(void *pArg, int argc, char **argv, char **column
}
snprintf(id, sizeof(id), "%d", holder->rows);
switch_xml_set_attr_d(row, "row_id", id);
switch_xml_set_attr(switch_xml_set_flag(row, SWITCH_XML_DUP), strdup("row_id"), strdup(id));
for(x = 0; x < argc; x++) {
char *name = columnNames[x];
@ -1229,7 +1230,8 @@ SWITCH_STANDARD_API(show_function)
char count[50];
char *xmlstr;
snprintf(count, sizeof(count), "%d", holder.count);
switch_xml_set_attr_d(holder.xml, "row_count", count);
switch_xml_set_attr(switch_xml_set_flag(holder.xml, SWITCH_XML_DUP), strdup("row_count"), strdup(count));
xmlstr = switch_xml_toxml(holder.xml);
if (xmlstr) {

View File

@ -724,7 +724,9 @@ SWITCH_STANDARD_APP(fax_detect_session_function)
SWITCH_STANDARD_APP(system_session_function)
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Executing command: %s\n",data);
system(data);
if(!system(data)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Failed to execute command: %s\n",data);
}
}
SWITCH_STANDARD_APP(tone_detect_session_function)

View File

@ -278,8 +278,8 @@ static switch_status_t iax_set_codec(private_t * tech_pvt, struct iax_session *i
char pref_str[256] = "(";
for (x = 0; x < len; x++) {
strncat(pref_str, ast2str(prefs[x]), sizeof(pref_str));
strncat(pref_str, x == len - 1 ? ")" : ",", sizeof(pref_str));
strncat(pref_str, ast2str(prefs[x]), sizeof(pref_str)-1);
strncat(pref_str, x == len - 1 ? ")" : ",", sizeof(pref_str)-1);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Codec Prefs Detected: %s\n", pref_str);

View File

@ -1785,7 +1785,7 @@ void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_
}
switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
if (!switch_strlen_zero(key)) {
if (*key != '\0') {
tech_pvt->key = switch_core_session_strdup(session, key);
}

View File

@ -582,10 +582,10 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
}
nua_invite(tech_pvt->nh,
TAG_IF(!switch_strlen_zero(rpid), SIPTAG_HEADER_STR(rpid)),
TAG_IF(!switch_strlen_zero(alert_info), SIPTAG_HEADER_STR(alert_info)),
TAG_IF(*rpid != '\0', SIPTAG_HEADER_STR(rpid)),
TAG_IF(*alert_info != '\0', SIPTAG_HEADER_STR(alert_info)),
TAG_IF(!switch_strlen_zero(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
TAG_IF(!switch_strlen_zero(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)),
TAG_IF(*max_forwards != '\0', SIPTAG_MAX_FORWARDS_STR(max_forwards)),
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE),
SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), SOATAG_HOLD(holdstr), TAG_END());
@ -600,7 +600,6 @@ switch_status_t sofia_glue_do_invite(switch_core_session_t *session)
void sofia_glue_do_xfer_invite(switch_core_session_t *session)
{
char rpid[1024];
private_object_t *tech_pvt;
switch_channel_t *channel = NULL;
switch_caller_profile_t *caller_profile;
@ -630,7 +629,6 @@ void sofia_glue_do_xfer_invite(switch_core_session_t *session)
nua_handle_bind(tech_pvt->nh2, tech_pvt->sofia_private);
nua_invite(tech_pvt->nh2,
TAG_IF(rpid, SIPTAG_HEADER_STR(rpid)),
SIPTAG_CONTACT_STR(tech_pvt->profile->url),
SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE), SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), TAG_END());
@ -1092,7 +1090,7 @@ uint8_t sofia_glue_negotiate_sdp(switch_core_session_t *session, sdp_session_t *
if (!strcasecmp(a->a_name, "sendonly")) {
sendonly = 1;
} else if (!strcasecmp(a->a_name, "sendrecv")) {
} else if (!strcasecmp(a->a_name, "sendrecv")) {
sendonly = 0;
} else if (!strcasecmp(a->a_name, "ptime")) {
dptime = atoi(a->a_value);

View File

@ -1033,7 +1033,7 @@ void sofia_presence_handle_sip_i_message(int status,
if ((ci = switch_loadable_module_get_chat_interface(proto))) {
ci->chat_send(SOFIA_CHAT_PROTO, from_addr, to_addr, "", msg, full_from);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto ? proto : "(none)");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Chat Interface [%s]!\n", proto);
}
}

View File

@ -1065,7 +1065,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t * thread, void *obj
switch_clear_flag_locked(listener, LFLAG_RUNNING);
goto done;
}
if (!switch_strlen_zero(reply)) {
if (*reply != '\0') {
snprintf(buf, sizeof(buf), "Content-Type: command/reply\nReply-Text: %s\n\n", reply);
len = strlen(buf);
switch_socket_send(listener->sock, buf, &len);
@ -1094,7 +1094,7 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t * thread, void *obj
break;
}
if (!switch_strlen_zero(reply)) {
if (*reply != '\0') {
snprintf(buf, sizeof(buf), "Content-Type: command/reply\nReply-Text: %s\n\n", reply);
len = strlen(buf);
switch_socket_send(listener->sock, buf, &len);

View File

@ -715,7 +715,7 @@ static switch_status_t sm_load_file(char *filename)
}
static switch_status_t sm_load_module(char *dir, char *fname)
static switch_status_t sm_load_module(const char *dir, const char *fname)
{
switch_size_t len = 0;
char *path;
@ -788,7 +788,7 @@ static switch_status_t load_modules(void)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Invalid extension for %s\n", val);
continue;
}
sm_load_module((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val);
sm_load_module(SWITCH_GLOBAL_dirs.mod_dir, val);
count++;
}
}
@ -1964,7 +1964,9 @@ static size_t file_callback(void *ptr, size_t size, size_t nmemb, void *data)
register unsigned int realsize = (unsigned int) (size * nmemb);
struct config_data *config_data = data;
write(config_data->fd, ptr, realsize);
if ((write(config_data->fd, ptr, realsize) != (int)realsize)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to write all bytes!\n");
}
return realsize;
}

View File

@ -180,7 +180,10 @@ static JSBool js_email(JSContext * cx, JSObject * obj, uintN argc, jsval * argv,
close(ifd);
}
snprintf(buf, B64BUFFLEN, "/bin/cat %s | /usr/sbin/sendmail -tf \"%s\" %s", filename, from, to);
system(buf);
if(!system(buf)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to execute command: %s\n",buf);
}
unlink(filename);

View File

@ -327,12 +327,12 @@ static xmlrpc_value *freeswitch_man(xmlrpc_env * const envP, xmlrpc_value * cons
if (action) {
if (switch_core_management_exec(relative_oid, action, buf, sizeof(buf)) == SWITCH_STATUS_SUCCESS) {
if (action == SMA_SET) {
if (switch_strlen_zero(buf)) {
if (*buf != '\0') {
snprintf(buf, sizeof(buf), "OK\n");
}
}
} else {
if (switch_strlen_zero(buf)) {
if (*buf != '\0') {
snprintf(buf, sizeof(buf), "ERROR\n");
}
}

View File

@ -96,7 +96,9 @@ static int freeswitch_kill_background()
}
/* pull the pid from the file */
fscanf(f, "%d", &pid);
if(fscanf(f, "%d", &pid)!=1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"Unable to get the pid!\n");
}
/* if we have a valid pid */
if (pid > 0) {

View File

@ -355,7 +355,9 @@ SWITCH_DECLARE(int32_t) set_high_priority(void)
#ifdef WIN32
SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
#else
nice(-10);
if(nice(-10)!= -10) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not set nice level\n");
}
#endif
#define USE_MLOCKALL

View File

@ -373,7 +373,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
fail_on_single_reject = 1;
}
if ((!switch_strlen_zero(file)) && (!strcmp(file, "undef"))) {
if ((*file != '\0') && (!strcmp(file, "undef"))) {
*file = '\0';
}

View File

@ -966,12 +966,16 @@ static int preprocess(const char *file, int write_fd, int rlevel)
}
}
if ((cmd = strstr(bp, "<!--#"))) {
write(write_fd, bp, (unsigned) (cmd - bp));
if ((cmd = strstr(bp, "<!--#"))) {
if(write(write_fd, bp, (unsigned) (cmd - bp)) != (cmd - bp)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write!\n");
}
if ((e = strstr(cmd, "-->"))) {
*e = '\0';
e += 3;
write(write_fd, e, (unsigned) strlen(e));
e += 3;
if(write(write_fd, e, (unsigned) strlen(e)) != (int) strlen(e)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write!\n");
}
} else {
ml++;
}
@ -1027,8 +1031,11 @@ static int preprocess(const char *file, int write_fd, int rlevel)
continue;
}
write(write_fd, bp, (unsigned) cur);
if(write(write_fd, bp, (unsigned) cur) != (int) cur) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write!\n");
}
}
close(read_fd);