0
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2025-06-30 22:18:19 -04:00

fixes for win32 (ported 2.3.99.0 patches). Thanks to LRN (from Mailing list).

svn path=/icecast/trunk/icecast/; revision=18642
This commit is contained in:
Philipp Schafft 2012-10-10 22:41:30 +00:00
parent 8e0777a4bd
commit 4927a1109d
4 changed files with 35 additions and 9 deletions

View File

@ -34,8 +34,9 @@ AC_HEADER_STDC
AC_HEADER_TIME AC_HEADER_TIME
AC_CHECK_HEADERS([alloca.h sys/timeb.h]) AC_CHECK_HEADERS([alloca.h sys/timeb.h])
AC_CHECK_HEADERS(pwd.h, AC_DEFINE(CHUID, 1, [Define if you have pwd.h]),,) AC_CHECK_HEADERS([pwd.h, unistd.h, grp.h, sys/types.h])
AC_CHECK_HEADERS(unistd.h, AC_DEFINE(CHROOT, 1, [Define if you have unistd.h]),,) AC_CHECK_FUNC([chuid])
AC_CHECK_FUNC([chown])
dnl Checks for typedefs, structures, and compiler characteristics. dnl Checks for typedefs, structures, and compiler characteristics.
XIPH_C__FUNC__ XIPH_C__FUNC__

View File

@ -54,7 +54,15 @@ int get_clf_time (char *buffer, unsigned len, struct tm *t)
struct tm *thetime; struct tm *thetime;
time_t now; time_t now;
gmtime_r(&time1, &gmt); #if !defined(_WIN32)
thetime = gmtime_r(&time1, &gmt)
#else
/* gmtime() on W32 breaks POSIX and IS thread-safe (uses TLS) */
thetime = gmtime (&time1);
if (thetime)
memcpy (&gmt, thetime, sizeof (gmt));
#endif
/* FIXME: bail out if gmtime* returns NULL */
time_days = t->tm_yday - gmt.tm_yday; time_days = t->tm_yday - gmt.tm_yday;

View File

@ -41,9 +41,13 @@
#include "net/resolver.h" #include "net/resolver.h"
#include "httpp/httpp.h" #include "httpp/httpp.h"
#ifdef CHUID #if HAVE_SYS_TYPES_H
#include <sys/types.h> #include <sys/types.h>
#endif
#if HAVE_GRP_H
#include <grp.h> #include <grp.h>
#endif
#if HAVE_PWD_H
#include <pwd.h> #include <pwd.h>
#endif #endif
@ -362,7 +366,7 @@ static void _ch_root_uid_setup(void)
} }
#endif #endif
#ifdef CHROOT #if HAVE_CHROOT
if (conf->chroot) if (conf->chroot)
{ {
if(getuid()) /* root check */ if(getuid()) /* root check */
@ -380,7 +384,7 @@ static void _ch_root_uid_setup(void)
} }
#endif #endif
#ifdef CHUID #if HAVE_CHUID
if(conf->chuid) if(conf->chuid)
{ {

View File

@ -494,7 +494,8 @@ ssize_t util_http_build_header(char * out, size_t len, ssize_t offset,
ice_config_t *config; ice_config_t *config;
time_t now; time_t now;
struct tm result; struct tm result;
char currenttime_buffer[50]; struct tm *gmtime_result;
char currenttime_buffer[80];
char status_buffer[80]; char status_buffer[80];
char contenttype_buffer[80]; char contenttype_buffer[80];
ssize_t ret; ssize_t ret;
@ -546,10 +547,22 @@ ssize_t util_http_build_header(char * out, size_t len, ssize_t offset,
} }
time(&now); time(&now);
strftime(currenttime_buffer, 50, "%a, %d-%b-%Y %X GMT", gmtime_r(&now, &result)); #ifndef _WIN32
gmtime_result = gmtime_r(&now, &result);
#else
/* gmtime() on W32 breaks POSIX and IS thread-safe (uses TLS) */
gmtime_result = gmtime (&now);
if (gmtime_result)
memcpy (&result, gmtime_result, sizeof (result));
#endif
if (gmtime_result)
strftime(currenttime_buffer, sizeof(currenttime_buffer), "Date: %a, %d-%b-%Y %X GMT\r\n", gmtime_result);
else
currenttime_buffer[0] = '\0';
config = config_get_config(); config = config_get_config();
ret = snprintf (out, len, "%sServer: %s\r\nDate: %s\r\n%s%s%s%s%s", ret = snprintf (out, len, "%sServer: %s\r\n%s%s%s%s%s%s",
status_buffer, status_buffer,
config->server_id, config->server_id,
currenttime_buffer, currenttime_buffer,