gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r32396 - in libmicrohttpd: . src/microhttpd


From: gnunet
Subject: [GNUnet-SVN] r32396 - in libmicrohttpd: . src/microhttpd
Date: Tue, 18 Feb 2014 19:38:50 +0100

Author: Karlson2k
Date: 2014-02-18 19:38:50 +0100 (Tue, 18 Feb 2014)
New Revision: 32396

Modified:
   libmicrohttpd/configure.ac
   libmicrohttpd/src/microhttpd/connection.c
Log:
gmtime_r() replacement on W32, add error check in get_date_string()

Modified: libmicrohttpd/configure.ac
===================================================================
--- libmicrohttpd/configure.ac  2014-02-18 18:38:41 UTC (rev 32395)
+++ libmicrohttpd/configure.ac  2014-02-18 18:38:50 UTC (rev 32396)
@@ -268,7 +268,19 @@
 
 AC_CHECK_FUNCS_ONCE(memmem)
 AC_CHECK_FUNCS_ONCE(accept4)
+AC_MSG_CHECKING([[for gmtime_s]])
+AC_LINK_IFELSE(
+  [AC_LANG_PROGRAM(
+    [[ #include <time.h>]], [[struct tm now; time_t t; time (&t); gmtime_s 
(&now, &t)]])
+  ],
+  [
+    AC_DEFINE([HAVE_GMTIME_S], [1], [Define to 1 if you have `gmtime_s' 
function (only for W32).])
+    AC_MSG_RESULT([[yes]])
+  ],
+  [AC_MSG_RESULT([[no]])
+  ])
 
+
 AC_COMPILE_IFELSE(
   [AC_LANG_PROGRAM(
                    [

Modified: libmicrohttpd/src/microhttpd/connection.c
===================================================================
--- libmicrohttpd/src/microhttpd/connection.c   2014-02-18 18:38:41 UTC (rev 
32395)
+++ libmicrohttpd/src/microhttpd/connection.c   2014-02-18 18:38:50 UTC (rev 
32396)
@@ -663,18 +663,37 @@
   };
   struct tm now;
   time_t t;
+#if defined(_WIN32) && !defined(HAVE_GMTIME_S) && !defined(__CYGWIN__)
+  struct tm* pNow;
+#endif
 
+  date[0] = 0;
   time (&t);
-  gmtime_r (&t, &now);
-  SPRINTF (date,
-           "Date: %3s, %02u %3s %04u %02u:%02u:%02u GMT\r\n",
-           days[now.tm_wday % 7],
-           (unsigned int) now.tm_mday,
-           mons[now.tm_mon % 12],
-           (unsigned int) (1900 + now.tm_year),
-          (unsigned int) now.tm_hour,
-          (unsigned int) now.tm_min,
-          (unsigned int) now.tm_sec);
+#if !defined(_WIN32)
+  if (NULL != gmtime_r (&t, &now))
+    {
+#elif defined(HAVE_GMTIME_S)
+  if (0 == gmtime_s (&now, &t))
+    {
+#elif defined(__CYGWIN__)
+  if (NULL != gmtime_r (&t, &now))
+    {
+#else
+  pNow = gmtime(&t);
+  if (NULL != pNow)
+    {
+      now = *pNow;
+#endif
+      sprintf (date,
+             "Date: %3s, %02u %3s %04u %02u:%02u:%02u GMT\r\n",
+             days[now.tm_wday % 7],
+             (unsigned int) now.tm_mday,
+             mons[now.tm_mon % 12],
+             (unsigned int) (1900 + now.tm_year),
+             (unsigned int) now.tm_hour,
+             (unsigned int) now.tm_min,
+             (unsigned int) now.tm_sec);
+    }
 }
 
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]