checkpoint. automake changes for reentrant functions.
This commit is contained in:
parent
9c7e863d77
commit
8a103ce63c
|
@ -45,6 +45,8 @@ dnl AC_TYPE_SIGNAL
|
||||||
dnl AC_FUNC_FORK
|
dnl AC_FUNC_FORK
|
||||||
AC_FUNC_MEMCMP
|
AC_FUNC_MEMCMP
|
||||||
AC_FUNC_STRFTIME
|
AC_FUNC_STRFTIME
|
||||||
|
AC_CHECK_FUNCS(gmtime_r)
|
||||||
|
AC_CHECK_FUNCS(getpwuid_r)
|
||||||
dnl use AC_REPLACE_FUNCS() for stuff in string.h
|
dnl use AC_REPLACE_FUNCS() for stuff in string.h
|
||||||
dnl AC_HEADER_SYS_WAIT
|
dnl AC_HEADER_SYS_WAIT
|
||||||
|
|
||||||
|
|
|
@ -273,14 +273,18 @@ CHTTPProtocol::reply(IOutputStream* stream, CHTTPReply& reply)
|
||||||
// get date
|
// get date
|
||||||
// FIXME -- should use C++ locale stuff but VC++ time_put is broken.
|
// FIXME -- should use C++ locale stuff but VC++ time_put is broken.
|
||||||
// FIXME -- double check that VC++ is broken
|
// FIXME -- double check that VC++ is broken
|
||||||
// FIXME -- should mutex gmtime() since the return value may not
|
|
||||||
// be thread safe
|
|
||||||
char date[30];
|
char date[30];
|
||||||
{
|
{
|
||||||
const char* oldLocale = setlocale(LC_TIME, "C");
|
const char* oldLocale = setlocale(LC_TIME, "C");
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
struct tm* tm = gmtime(&t);
|
#if HAVE_GMTIME_R
|
||||||
strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S GMT", tm);
|
struct tm tm;
|
||||||
|
struct tm* tmp = &tm;
|
||||||
|
gmtime_r(&t, tmp);
|
||||||
|
#else
|
||||||
|
struct tm* tmp = gmtime(&t);
|
||||||
|
#endif
|
||||||
|
strftime(date, sizeof(date), "%a, %d %b %Y %H:%M:%S GMT", tmp);
|
||||||
setlocale(LC_TIME, oldLocale);
|
setlocale(LC_TIME, oldLocale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,10 +161,18 @@ CUnixPlatform::getBasename(const char* pathname) const
|
||||||
CString
|
CString
|
||||||
CUnixPlatform::getUserDirectory() const
|
CUnixPlatform::getUserDirectory() const
|
||||||
{
|
{
|
||||||
// FIXME -- use geteuid? shouldn't run this setuid anyway.
|
#if HAVE_GETPWUID_R
|
||||||
struct passwd* pwent = getpwuid(getuid());
|
struct passwd pwent;
|
||||||
if (pwent != NULL && pwent->pw_dir != NULL) {
|
struct passwd* pwentp;
|
||||||
return pwent->pw_dir;
|
long size = sysconf(_SC_GETPW_R_SIZE_MAX);
|
||||||
|
char* buffer = new char[size];
|
||||||
|
getpwuid_r(getuid(), &pwent, buffer, size, &pwentp);
|
||||||
|
delete[] buffer;
|
||||||
|
#else
|
||||||
|
struct passwd* pwentp = getpwuid(getuid());
|
||||||
|
#endif
|
||||||
|
if (pwentp != NULL && pwentp->pw_dir != NULL) {
|
||||||
|
return pwentp->pw_dir;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return CString();
|
return CString();
|
||||||
|
|
Loading…
Reference in New Issue