Commit 4927a110 authored by Philipp Schafft's avatar Philipp Schafft 🦁

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

svn path=/icecast/trunk/icecast/; revision=18642
parent 8e0777a4
......@@ -34,8 +34,9 @@ AC_HEADER_STDC
AC_HEADER_TIME
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(unistd.h, AC_DEFINE(CHROOT, 1, [Define if you have unistd.h]),,)
AC_CHECK_HEADERS([pwd.h, unistd.h, grp.h, sys/types.h])
AC_CHECK_FUNC([chuid])
AC_CHECK_FUNC([chown])
dnl Checks for typedefs, structures, and compiler characteristics.
XIPH_C__FUNC__
......
......@@ -54,7 +54,15 @@ int get_clf_time (char *buffer, unsigned len, struct tm *t)
struct tm *thetime;
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;
......
......@@ -41,9 +41,13 @@
#include "net/resolver.h"
#include "httpp/httpp.h"
#ifdef CHUID
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_GRP_H
#include <grp.h>
#endif
#if HAVE_PWD_H
#include <pwd.h>
#endif
......@@ -362,7 +366,7 @@ static void _ch_root_uid_setup(void)
}
#endif
#ifdef CHROOT
#if HAVE_CHROOT
if (conf->chroot)
{
if(getuid()) /* root check */
......@@ -380,7 +384,7 @@ static void _ch_root_uid_setup(void)
}
#endif
#ifdef CHUID
#if HAVE_CHUID
if(conf->chuid)
{
......
......@@ -494,7 +494,8 @@ ssize_t util_http_build_header(char * out, size_t len, ssize_t offset,
ice_config_t *config;
time_t now;
struct tm result;
char currenttime_buffer[50];
struct tm *gmtime_result;
char currenttime_buffer[80];
char status_buffer[80];
char contenttype_buffer[80];
ssize_t ret;
......@@ -546,10 +547,22 @@ ssize_t util_http_build_header(char * out, size_t len, ssize_t offset,
}
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();
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,
config->server_id,
currenttime_buffer,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment