[xiph-commits] r18642 - in icecast/trunk/icecast: . src

ph3-der-loewe at svn.xiph.org ph3-der-loewe at svn.xiph.org
Wed Oct 10 15:41:30 PDT 2012


Author: ph3-der-loewe
Date: 2012-10-10 15:41:30 -0700 (Wed, 10 Oct 2012)
New Revision: 18642

Modified:
   icecast/trunk/icecast/configure.in
   icecast/trunk/icecast/src/logging.c
   icecast/trunk/icecast/src/main.c
   icecast/trunk/icecast/src/util.c
Log:
fixes for win32 (ported 2.3.99.0 patches). Thanks to LRN (from Mailing list).

Modified: icecast/trunk/icecast/configure.in
===================================================================
--- icecast/trunk/icecast/configure.in	2012-10-08 11:09:53 UTC (rev 18641)
+++ icecast/trunk/icecast/configure.in	2012-10-10 22:41:30 UTC (rev 18642)
@@ -34,8 +34,9 @@
 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__

Modified: icecast/trunk/icecast/src/logging.c
===================================================================
--- icecast/trunk/icecast/src/logging.c	2012-10-08 11:09:53 UTC (rev 18641)
+++ icecast/trunk/icecast/src/logging.c	2012-10-10 22:41:30 UTC (rev 18642)
@@ -54,7 +54,15 @@
     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;
 

Modified: icecast/trunk/icecast/src/main.c
===================================================================
--- icecast/trunk/icecast/src/main.c	2012-10-08 11:09:53 UTC (rev 18641)
+++ icecast/trunk/icecast/src/main.c	2012-10-10 22:41:30 UTC (rev 18642)
@@ -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 @@
    }
 #endif
 
-#ifdef CHROOT
+#if HAVE_CHROOT
    if (conf->chroot)
    {
        if(getuid()) /* root check */
@@ -380,7 +384,7 @@
 
    }   
 #endif
-#ifdef CHUID
+#if HAVE_CHUID
 
    if(conf->chuid)
    {

Modified: icecast/trunk/icecast/src/util.c
===================================================================
--- icecast/trunk/icecast/src/util.c	2012-10-08 11:09:53 UTC (rev 18641)
+++ icecast/trunk/icecast/src/util.c	2012-10-10 22:41:30 UTC (rev 18642)
@@ -494,7 +494,8 @@
     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 @@
     }
 
     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,



More information about the commits mailing list