提交 eca5c0ad authored 作者: Stefan Knoblich's avatar Stefan Knoblich

FreeSWITCH: Add WIN32 strerror_s() variant to custom switch_strerror_r() helper…

FreeSWITCH: Add WIN32 strerror_s() variant to custom switch_strerror_r() helper function and fix more strerror_r() users.

Convert mod_xml_cdr, mod_json_cdr and mod_conference to the new function.
Signed-off-by: 's avatarStefan Knoblich <stkn@openisdn.net>
上级 8bcf3b4f
......@@ -1029,12 +1029,8 @@ static void conference_cdr_render(conference_obj_t *conference)
fd = -1;
} else {
char ebuf[512] = { 0 };
#ifdef WIN32
strerror_s(ebuf, sizeof(ebuf), errno);
#else
strerror_r(errno, ebuf, sizeof(ebuf));
#endif
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", path, ebuf);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n",
path, switch_strerror_r(errno, ebuf, sizeof(ebuf)));
}
......
......@@ -253,12 +253,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
}
} else {
char ebuf[512] = { 0 };
#ifdef WIN32
strerror_s(ebuf, sizeof(ebuf), errno);
#else
strerror_r(errno, ebuf, sizeof(ebuf));
#endif
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", path, ebuf);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n",
path, switch_strerror_r(errno, ebuf, sizeof(ebuf)));
}
switch_safe_free(path);
}
......@@ -412,12 +408,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
break;
} else {
char ebuf[512] = { 0 };
#ifdef WIN32
strerror_s(ebuf, sizeof(ebuf), errno);
#else
strerror_r(errno, ebuf, sizeof(ebuf));
#endif
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open %s! [%s]\n", path, ebuf);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open %s! [%s]\n",
path, switch_strerror_r(errno, ebuf, sizeof(ebuf)));
}
......
......@@ -244,12 +244,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
fd = -1;
} else {
char ebuf[512] = { 0 };
#ifdef WIN32
strerror_s(ebuf, sizeof(ebuf), errno);
#else
strerror_r(errno, ebuf, sizeof(ebuf));
#endif
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n", path, ebuf);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error writing [%s][%s]\n",
path, switch_strerror_r(errno, ebuf, sizeof(ebuf)));
}
switch_safe_free(path);
}
......@@ -400,12 +396,8 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
fd = -1;
} else {
char ebuf[512] = { 0 };
#ifdef WIN32
strerror_s(ebuf, sizeof(ebuf), errno);
#else
strerror_r(errno, ebuf, sizeof(ebuf));
#endif
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error![%s]\n", ebuf);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error![%s]\n",
switch_strerror_r(errno, ebuf, sizeof(ebuf)));
}
}
}
......
......@@ -2985,6 +2985,12 @@ SWITCH_DECLARE(char *) switch_strerror_r(int errnum, char *buf, switch_size_t bu
}
return buf;
#endif /* STRERROR_R_CHAR_P */
#elif defined(WIN32)
/* WIN32 variant */
if (strerror_s(buf, buflen, errnum)) {
switch_snprintf(buf, buflen, "Unknown error %d", errnum);
}
return buf;
#else
/* Fallback, copy string into private buffer */
switch_copy_string(buf, strerror(errnum), buflen);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论