gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r26977 - libmicrohttpd/doc/examples


From: gnunet
Subject: [GNUnet-SVN] r26977 - libmicrohttpd/doc/examples
Date: Tue, 23 Apr 2013 13:38:09 +0200

Author: LRN
Date: 2013-04-23 13:38:09 +0200 (Tue, 23 Apr 2013)
New Revision: 26977

Modified:
   libmicrohttpd/doc/examples/basicauthentication.c
   libmicrohttpd/doc/examples/hellobrowser.c
   libmicrohttpd/doc/examples/largepost.c
   libmicrohttpd/doc/examples/logging.c
   libmicrohttpd/doc/examples/responseheaders.c
   libmicrohttpd/doc/examples/sessions.c
   libmicrohttpd/doc/examples/simplepost.c
   libmicrohttpd/doc/examples/tlsauthentication.c
Log:
W32 compatibility, also use ISO C instead of POSIX


Modified: libmicrohttpd/doc/examples/basicauthentication.c
===================================================================
--- libmicrohttpd/doc/examples/basicauthentication.c    2013-04-23 11:11:07 UTC 
(rev 26976)
+++ libmicrohttpd/doc/examples/basicauthentication.c    2013-04-23 11:38:09 UTC 
(rev 26977)
@@ -2,8 +2,12 @@
    you see fit (Public Domain) */
 
 #include <sys/types.h>
+#ifndef _WIN32
 #include <sys/select.h>
 #include <sys/socket.h>
+#else
+#include <winsock2.h>
+#endif
 #include <microhttpd.h>
 #include <time.h>
 #include <string.h>

Modified: libmicrohttpd/doc/examples/hellobrowser.c
===================================================================
--- libmicrohttpd/doc/examples/hellobrowser.c   2013-04-23 11:11:07 UTC (rev 
26976)
+++ libmicrohttpd/doc/examples/hellobrowser.c   2013-04-23 11:38:09 UTC (rev 
26977)
@@ -2,8 +2,12 @@
    you see fit (Public Domain) */
 
 #include <sys/types.h>
+#ifndef _WIN32
 #include <sys/select.h>
 #include <sys/socket.h>
+#else
+#include <winsock2.h>
+#endif
 #include <string.h>
 #include <microhttpd.h>
 #include <stdio.h>

Modified: libmicrohttpd/doc/examples/largepost.c
===================================================================
--- libmicrohttpd/doc/examples/largepost.c      2013-04-23 11:11:07 UTC (rev 
26976)
+++ libmicrohttpd/doc/examples/largepost.c      2013-04-23 11:38:09 UTC (rev 
26977)
@@ -2,8 +2,12 @@
    you see fit (Public Domain) */
 
 #include <sys/types.h>
+#ifndef _WIN32
 #include <sys/select.h>
 #include <sys/socket.h>
+#else
+#include <winsock2.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

Modified: libmicrohttpd/doc/examples/logging.c
===================================================================
--- libmicrohttpd/doc/examples/logging.c        2013-04-23 11:11:07 UTC (rev 
26976)
+++ libmicrohttpd/doc/examples/logging.c        2013-04-23 11:38:09 UTC (rev 
26977)
@@ -2,8 +2,12 @@
    you see fit (Public Domain) */
 
 #include <sys/types.h>
+#ifndef _WIN32
 #include <sys/select.h>
 #include <sys/socket.h>
+#else
+#include <winsock2.h>
+#endif
 #include <microhttpd.h>
 #include <stdio.h>
 

Modified: libmicrohttpd/doc/examples/responseheaders.c
===================================================================
--- libmicrohttpd/doc/examples/responseheaders.c        2013-04-23 11:11:07 UTC 
(rev 26976)
+++ libmicrohttpd/doc/examples/responseheaders.c        2013-04-23 11:38:09 UTC 
(rev 26977)
@@ -2,8 +2,12 @@
    you see fit (Public Domain) */
 
 #include <sys/types.h>
+#ifndef _WIN32
 #include <sys/select.h>
 #include <sys/socket.h>
+#else
+#include <winsock2.h>
+#endif
 #include <microhttpd.h>
 #include <time.h>
 #include <sys/stat.h>

Modified: libmicrohttpd/doc/examples/sessions.c
===================================================================
--- libmicrohttpd/doc/examples/sessions.c       2013-04-23 11:11:07 UTC (rev 
26976)
+++ libmicrohttpd/doc/examples/sessions.c       2013-04-23 11:38:09 UTC (rev 
26977)
@@ -4,7 +4,6 @@
 /* needed for asprintf */
 #define _GNU_SOURCE
 
-
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
@@ -12,6 +11,46 @@
 #include <time.h>
 #include <microhttpd.h>
 
+#ifdef _WIN32
+int
+asprintf (char **resultp, const char *format, ...)
+{
+  va_list argptr;
+  char *result = NULL;
+  int len = 0;
+
+  if (format == NULL)
+    return -1;
+
+  va_start (argptr, format);
+
+  len = _vscprintf ((char *) format, argptr);
+  if (len >= 0)
+  {
+    len += 1;
+    result = (char *) malloc (sizeof (char *) * len);
+    if (result != NULL)
+    {
+      int len2 = _vscprintf ((char *) format, argptr);
+      if (len2 != len - 1 || len2 <= 0)
+      {
+        free (result);
+        result = NULL;
+        len = -1;
+      }
+      else
+      {
+        len = len2;
+        if (resultp)
+          *resultp = result;
+      }
+    }
+  }
+  va_end (argptr);
+  return len;
+}
+#endif
+
 /**
  * Invalid method page.
  */
@@ -163,10 +202,10 @@
   snprintf (ret->sid,
            sizeof (ret->sid),
            "%X%X%X%X",
-           (unsigned int) random (),
-           (unsigned int) random (),
-           (unsigned int) random (),
-           (unsigned int) random ());
+           (unsigned int) rand (),
+           (unsigned int) rand (),
+           (unsigned int) rand (),
+           (unsigned int) rand ());
   ret->rc++;  
   ret->start = time (NULL);
   ret->next = sessions;
@@ -691,7 +730,7 @@
       return 1;
     }
   /* initialize PRNG */
-  srandom ((unsigned int) time (NULL));
+  srand ((unsigned int) time (NULL));
   d = MHD_start_daemon (MHD_USE_DEBUG,
                         atoi (argv[1]),
                         NULL, NULL, 

Modified: libmicrohttpd/doc/examples/simplepost.c
===================================================================
--- libmicrohttpd/doc/examples/simplepost.c     2013-04-23 11:11:07 UTC (rev 
26976)
+++ libmicrohttpd/doc/examples/simplepost.c     2013-04-23 11:38:09 UTC (rev 
26977)
@@ -2,8 +2,12 @@
    you see fit (Public Domain) */
 
 #include <sys/types.h>
+#ifndef _WIN32
 #include <sys/select.h>
 #include <sys/socket.h>
+#else
+#include <winsock2.h>
+#endif
 #include <microhttpd.h>
 #include <stdio.h>
 #include <string.h>

Modified: libmicrohttpd/doc/examples/tlsauthentication.c
===================================================================
--- libmicrohttpd/doc/examples/tlsauthentication.c      2013-04-23 11:11:07 UTC 
(rev 26976)
+++ libmicrohttpd/doc/examples/tlsauthentication.c      2013-04-23 11:38:09 UTC 
(rev 26977)
@@ -2,8 +2,12 @@
    you see fit (Public Domain) */
 
 #include <sys/types.h>
+#ifndef _WIN32
 #include <sys/select.h>
 #include <sys/socket.h>
+#else
+#include <winsock2.h>
+#endif
 #include <microhttpd.h>
 #include <string.h>
 #include <stdio.h>




reply via email to

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