gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r5501 - in libmicrohttpd: . src/daemon src/include


From: gnunet
Subject: [GNUnet-SVN] r5501 - in libmicrohttpd: . src/daemon src/include
Date: Wed, 15 Aug 2007 02:59:40 -0600 (MDT)

Author: grothoff
Date: 2007-08-15 02:59:38 -0600 (Wed, 15 Aug 2007)
New Revision: 5501

Modified:
   libmicrohttpd/ChangeLog
   libmicrohttpd/src/daemon/connection.c
   libmicrohttpd/src/daemon/daemon.c
   libmicrohttpd/src/daemon/daemontest_get.c
   libmicrohttpd/src/daemon/daemontest_post.c
   libmicrohttpd/src/daemon/daemontest_put.c
   libmicrohttpd/src/daemon/fileserver_example.c
   libmicrohttpd/src/daemon/memorypool.c
   libmicrohttpd/src/daemon/memorypool.h
   libmicrohttpd/src/daemon/plibc.h
   libmicrohttpd/src/daemon/response.c
   libmicrohttpd/src/include/microhttpd.h
Log:
fix

Modified: libmicrohttpd/ChangeLog
===================================================================
--- libmicrohttpd/ChangeLog     2007-08-15 08:42:54 UTC (rev 5500)
+++ libmicrohttpd/ChangeLog     2007-08-15 08:59:38 UTC (rev 5501)
@@ -1,7 +1,8 @@
 Wed Aug 15 01:46:44 MDT 2007
         Extending API to allow timeout of connections.
         Changed API (MHD_create_response_from_callback) to
-        allow user to specify IO buffer size. - CG
+        allow user to specify IO buffer size.   
+        Improved error handling.  - CG
 
 Tue Aug 14 19:45:49 MDT 2007
         Changed license to LGPL (with consent from all contributors).

Modified: libmicrohttpd/src/daemon/connection.c
===================================================================
--- libmicrohttpd/src/daemon/connection.c       2007-08-15 08:42:54 UTC (rev 
5500)
+++ libmicrohttpd/src/daemon/connection.c       2007-08-15 08:59:38 UTC (rev 
5501)
@@ -1,8 +1,8 @@
 /*
      This file is part of libmicrohttpd
      (C) 2007 Daniel Pittman and Christian Grothoff
-    
-     
+
+
      This library is free software; you can redistribute it and/or
      modify it under the terms of the GNU Lesser General Public
      License as published by the Free Software Foundation; either
@@ -218,7 +218,7 @@
  * We ran out of memory processing the
  * header.  Handle it properly by stopping to read data
  * and sending a HTTP 413 or HTTP 414 response.
- * 
+ *
  * @param status_code the response code to send (413 or 414)
  */
 static void
@@ -383,7 +383,7 @@
 
 /**
  * Parse the cookie header (see RFC 2109).
- * 
+ *
  * @return MHD_YES for success, MHD_NO for failure (malformed, out of memory)
  */
 static int
@@ -597,7 +597,7 @@
                                              MHD_HTTP_HEADER_CONNECTION);
           if ((end != NULL) && (0 == strcasecmp (end, "close")))
             {
-              /* other side explicitly requested 
+              /* other side explicitly requested
                  that we close the connection after
                  this request */
               connection->read_close = MHD_YES;
@@ -662,7 +662,7 @@
  * content encoding of the POST data.  And of course,
  * this requires that the request is actually a
  * POST request.
- * 
+ *
  * @return MHD_YES if so
  */
 static int
@@ -701,12 +701,12 @@
  *
  * Needs to first check POST encoding and then do
  * the right thing (TM).  The POST data is in the
- * connection's post_data buffer between the postPos 
+ * connection's post_data buffer between the postPos
  * and postLoc offsets.  The POST message maybe
  * incomplete.  The existing buffer (allocated from
  * the pool) can be used and modified but must then
  * be properly removed from the struct.
- * 
+ *
  * @return MHD_YES on success, MHD_NO on error (i.e. out of
  *         memory).
  */
@@ -728,7 +728,7 @@
       /* invalidate read buffer for other uses --
          in particular, do not give it to the
          client; if this were to be needed, we would
-         have to make a copy, which would double memory 
+         have to make a copy, which would double memory
          requirements */
       connection->read_buffer_size = 0;
       connection->readLoc = 0;
@@ -932,7 +932,8 @@
     { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
   static const char *mons[] =
     { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
-"Nov", "Dec" };
+    "Nov", "Dec"
+  };
   struct tm now;
   time_t t;
 

Modified: libmicrohttpd/src/daemon/daemon.c
===================================================================
--- libmicrohttpd/src/daemon/daemon.c   2007-08-15 08:42:54 UTC (rev 5500)
+++ libmicrohttpd/src/daemon/daemon.c   2007-08-15 08:59:38 UTC (rev 5501)
@@ -1,7 +1,7 @@
 /*
      This file is part of libmicrohttpd
      (C) 2007 Daniel Pittman and Christian Grothoff
-     
+
      This library is free software; you can redistribute it and/or
      modify it under the terms of the GNU Lesser General Public
      License as published by the Free Software Foundation; either
@@ -64,6 +64,12 @@
       ah = ah->next;
     }
   ah = malloc (sizeof (struct MHD_Access_Handler));
+  if (ah == NULL)
+    {
+      MHD_DLOG (daemon, "Error allocating memory: %s\n", STRERROR (errno));
+      return MHD_NO;
+    }
+
   ah->next = daemon->handlers;
   ah->uri_prefix = strdup (uri_prefix);
   ah->dh = dh;
@@ -133,7 +139,7 @@
       (write_fd_set == NULL) ||
       (except_fd_set == NULL) ||
       (max_fd == NULL) ||
-      (fd == -1) || 
+      (fd == -1) ||
       (daemon->shutdown == MHD_YES) ||
       ((daemon->options & MHD_USE_THREAD_PER_CONNECTION) != 0))
     return MHD_NO;
@@ -174,11 +180,10 @@
   if (con == NULL)
     abort ();
   timeout = con->daemon->connection_timeout;
-  now = time(NULL);
-  while ( (!con->daemon->shutdown) && 
-         (con->socket_fd != -1) &&
-         ( (timeout == 0) ||
-           (now - timeout > con->last_activity) ) )
+  now = time (NULL);
+  while ((!con->daemon->shutdown) &&
+         (con->socket_fd != -1) &&
+         ((timeout == 0) || (now - timeout > con->last_activity)))
     {
       FD_ZERO (&rs);
       FD_ZERO (&ws);
@@ -187,16 +192,15 @@
       MHD_connection_get_fdset (con, &rs, &ws, &es, &max);
       tv.tv_usec = 0;
       tv.tv_sec = timeout - (now - con->last_activity);
-      num_ready = SELECT (max + 1, 
-                         &rs, 
-                         &ws,
-                         &es,
-                         (tv.tv_sec != 0) ? &tv : NULL);
-      now = time(NULL);
+      num_ready = SELECT (max + 1,
+                          &rs, &ws, &es, (timeout != 0) ? &tv : NULL);
+      now = time (NULL);
       if (num_ready < 0)
         {
-          if (errno == EINTR) 
+          if (errno == EINTR)
             continue;
+          MHD_DLOG (con->daemon, "Error during select (%d): `%s'\n",
+                    max, STRERROR (errno));
           break;
         }
       if (((FD_ISSET (con->socket_fd, &rs)) &&
@@ -207,10 +211,10 @@
         break;
       if ((con->headersReceived == 1) && (con->response == NULL))
         MHD_call_connection_handler (con);
-      if ( (con->socket_fd != -1) &&
-          ( (FD_ISSET (con->socket_fd, &rs)) ||
-            (FD_ISSET (con->socket_fd, &ws)) ) )
-       con->last_activity = now;
+      if ((con->socket_fd != -1) &&
+          ((FD_ISSET (con->socket_fd, &rs)) ||
+           (FD_ISSET (con->socket_fd, &ws))))
+        con->last_activity = now;
     }
   if (con->socket_fd != -1)
     {
@@ -251,6 +255,8 @@
   if (daemon->max_connections == 0)
     {
       /* above connection limit - reject */
+      MHD_DLOG (daemon,
+                "Server reached connection limit (closing inbound 
connection)\n");
       CLOSE (s);
       return MHD_NO;
     }
@@ -261,11 +267,18 @@
       return MHD_YES;
     }
   connection = malloc (sizeof (struct MHD_Connection));
+  if (connection == NULL)
+    {
+      MHD_DLOG (daemon, "Error allocating memory: %s\n", STRERROR (errno));
+      CLOSE (s);
+      return MHD_NO;
+    }
   memset (connection, 0, sizeof (struct MHD_Connection));
   connection->pool = NULL;
   connection->addr = malloc (addrlen);
   if (connection->addr == NULL)
     {
+      MHD_DLOG (daemon, "Error allocating memory: %s\n", STRERROR (errno));
       CLOSE (s);
       free (connection);
       return MHD_NO;
@@ -284,7 +297,7 @@
       free (connection);
       return MHD_NO;
     }
-  connection->last_activity = time(NULL);
+  connection->last_activity = time (NULL);
   connection->next = daemon->connections;
   daemon->connections = connection;
   daemon->max_connections--;
@@ -310,7 +323,7 @@
   void *unused;
   time_t timeout;
 
-  timeout = time(NULL);
+  timeout = time (NULL);
   if (daemon->connection_timeout != 0)
     timeout -= daemon->connection_timeout;
   else
@@ -319,11 +332,11 @@
   prev = NULL;
   while (pos != NULL)
     {
-      if ( (pos->last_activity < timeout) &&
-          (pos->socket_fd != -1) ) {
-       CLOSE(pos->socket_fd);
-       pos->socket_fd = -1;
-      }
+      if ((pos->last_activity < timeout) && (pos->socket_fd != -1))
+        {
+          CLOSE (pos->socket_fd);
+          pos->socket_fd = -1;
+        }
       if (pos->socket_fd == -1)
         {
           if (prev == NULL)
@@ -361,33 +374,33 @@
  * (only needed if connection timeout is used).  The
  * returned value is how long select should at most
  * block, not the timeout value set for connections.
- * 
+ *
  * @param timeout set to the timeout (in milliseconds)
  * @return MHD_YES on success, MHD_NO if timeouts are
  *        not used (or no connections exist that would
  *        necessiate the use of a timeout right now).
  */
-int 
-MHD_get_timeout(struct MHD_Daemon * daemon,
-               unsigned long long * timeout) {
+int
+MHD_get_timeout (struct MHD_Daemon *daemon, unsigned long long *timeout)
+{
   time_t earliest_deadline;
   time_t now;
   struct MHD_Connection *pos;
   unsigned int dto;
-  
+
   dto = daemon->connection_timeout;
   if (0 == dto)
     return MHD_NO;
   pos = daemon->connections;
   if (pos == NULL)
-    return MHD_NO; /* no connections */
-  now = time(NULL);
+    return MHD_NO;              /* no connections */
+  now = time (NULL);
   /* start with conservative estimate */
   earliest_deadline = now + dto;
   while (pos != NULL)
     {
       if (earliest_deadline > pos->last_activity + dto)
-       earliest_deadline = pos->last_activity + dto;
+        earliest_deadline = pos->last_activity + dto;
       pos = pos->next;
     }
   if (earliest_deadline < now)
@@ -419,7 +432,7 @@
 
   timeout.tv_sec = 0;
   timeout.tv_usec = 0;
-  if (daemon == NULL) 
+  if (daemon == NULL)
     abort ();
   if (daemon->shutdown == MHD_YES)
     return MHD_NO;
@@ -439,20 +452,24 @@
       /* accept only, have one thread per connection */
       max = daemon->socket_fd;
       if (max == -1)
-       return MHD_NO;
+        return MHD_NO;
       FD_SET (max, &rs);
     }
-  if (may_block == MHD_NO) {
-    timeout.tv_usec = 0;
-    timeout.tv_sec = 0;
-  } else {
-    /* ltimeout is in ms */
-    if (MHD_YES == MHD_get_timeout(daemon, &ltimeout)) {
-      timeout.tv_usec = (ltimeout % 1000) * 1000 * 1000; 
-      timeout.tv_sec = ltimeout / 1000; 
-      may_block = MHD_NO;  
-    }    
-  }
+  if (may_block == MHD_NO)
+    {
+      timeout.tv_usec = 0;
+      timeout.tv_sec = 0;
+    }
+  else
+    {
+      /* ltimeout is in ms */
+      if (MHD_YES == MHD_get_timeout (daemon, &ltimeout))
+        {
+          timeout.tv_usec = (ltimeout % 1000) * 1000 * 1000;
+          timeout.tv_sec = ltimeout / 1000;
+          may_block = MHD_NO;
+        }
+    }
   num_ready = SELECT (max + 1,
                       &rs, &ws, &es, may_block == MHD_NO ? &timeout : NULL);
   if (daemon->shutdown == MHD_YES)
@@ -472,24 +489,24 @@
   if (0 == (daemon->options & MHD_USE_THREAD_PER_CONNECTION))
     {
       /* do not have a thread per connection, process all connections now */
-      now = time(NULL);
+      now = time (NULL);
       pos = daemon->connections;
       while (pos != NULL)
         {
           ds = pos->socket_fd;
-          if (ds == -1)
+          if (ds != -1)
             {
-              pos = pos->next;
-              continue;
+              if (FD_ISSET (ds, &rs))
+                {
+                  pos->last_activity = now;
+                  MHD_connection_handle_read (pos);
+                }
+              if (FD_ISSET (ds, &ws))
+                {
+                  pos->last_activity = now;
+                  MHD_connection_handle_write (pos);
+                }
             }
-          if (FD_ISSET (ds, &rs)) {
-           pos->last_activity = now;
-            MHD_connection_handle_read (pos);
-         }
-          if (FD_ISSET (ds, &ws)) {
-           pos->last_activity = now;
-            MHD_connection_handle_write (pos);
-         }
           pos = pos->next;
         }
     }
@@ -629,7 +646,7 @@
   retVal->default_handler.next = NULL;
   retVal->max_connections = MHD_MAX_CONNECTIONS_DEFAULT;
   retVal->pool_size = MHD_POOL_SIZE_DEFAULT;
-  retVal->connection_timeout = 0; /* no timeout */
+  retVal->connection_timeout = 0;       /* no timeout */
   va_start (ap, dh_cls);
   while (MHD_OPTION_END != (opt = va_arg (ap, enum MHD_OPTION)))
     {
@@ -641,9 +658,9 @@
         case MHD_OPTION_CONNECTION_LIMIT:
           retVal->max_connections = va_arg (ap, unsigned int);
           break;
-       case MHD_OPTION_CONNECTION_TIMEOUT:
+        case MHD_OPTION_CONNECTION_TIMEOUT:
           retVal->connection_timeout = va_arg (ap, unsigned int);
-         break;
+          break;
         default:
           fprintf (stderr,
                    "Invalid MHD_OPTION argument! (Did you terminate the list 
with MHD_OPTION_END?)\n");
@@ -728,12 +745,12 @@
 #else
 void __attribute__ ((constructor)) MHD_win_ltdl_init ()
 {
-  plibc_init("CRISP", "libmicrohttpd");
+  plibc_init ("CRISP", "libmicrohttpd");
 }
 
 void __attribute__ ((destructor)) MHD_win_ltdl_fini ()
 {
-  plibc_shutdown();
+  plibc_shutdown ();
 }
 #endif
 

Modified: libmicrohttpd/src/daemon/daemontest_get.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest_get.c   2007-08-15 08:42:54 UTC (rev 
5500)
+++ libmicrohttpd/src/daemon/daemontest_get.c   2007-08-15 08:59:38 UTC (rev 
5501)
@@ -112,9 +112,9 @@
   curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1);
   if (CURLE_OK != (errornum = curl_easy_perform (c)))
     {
-      fprintf(stderr, 
-             "curl_easy_perform failed: `%s'\n",
-             curl_easy_strerror(errornum));
+      fprintf (stderr,
+               "curl_easy_perform failed: `%s'\n",
+               curl_easy_strerror (errornum));
       curl_easy_cleanup (c);
       MHD_stop_daemon (d);
       return 2;
@@ -169,9 +169,9 @@
   curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1);
   if (CURLE_OK != (errornum = curl_easy_perform (c)))
     {
-      fprintf(stderr, 
-             "curl_easy_perform failed: `%s'\n",
-             curl_easy_strerror(errornum));
+      fprintf (stderr,
+               "curl_easy_perform failed: `%s'\n",
+               curl_easy_strerror (errornum));
       curl_easy_cleanup (c);
       MHD_stop_daemon (d);
       return 32;
@@ -321,13 +321,11 @@
 main (int argc, char *const *argv)
 {
   unsigned int errorCount = 0;
-  //  int i;
 
   oneone = NULL != strstr (argv[0], "11");
   if (0 != curl_global_init (CURL_GLOBAL_WIN32))
     return 2;
   errorCount += testInternalGet ();
-  //  for (i=0;i<10000;i++) 
   errorCount += testMultithreadedGet ();
   errorCount += testExternalGet ();
   if (errorCount != 0)

Modified: libmicrohttpd/src/daemon/daemontest_post.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest_post.c  2007-08-15 08:42:54 UTC (rev 
5500)
+++ libmicrohttpd/src/daemon/daemontest_post.c  2007-08-15 08:59:38 UTC (rev 
5501)
@@ -134,9 +134,9 @@
   curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1);
   if (CURLE_OK != (errornum = curl_easy_perform (c)))
     {
-      fprintf(stderr, 
-             "curl_easy_perform failed: `%s'\n",
-             curl_easy_strerror(errornum));
+      fprintf (stderr,
+               "curl_easy_perform failed: `%s'\n",
+               curl_easy_strerror (errornum));
       curl_easy_cleanup (c);
       MHD_stop_daemon (d);
       return 2;
@@ -194,9 +194,9 @@
   curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1);
   if (CURLE_OK != (errornum = curl_easy_perform (c)))
     {
-      fprintf(stderr, 
-             "curl_easy_perform failed: `%s'\n",
-             curl_easy_strerror(errornum));
+      fprintf (stderr,
+               "curl_easy_perform failed: `%s'\n",
+               curl_easy_strerror (errornum));
       curl_easy_cleanup (c);
       MHD_stop_daemon (d);
       return 32;

Modified: libmicrohttpd/src/daemon/daemontest_put.c
===================================================================
--- libmicrohttpd/src/daemon/daemontest_put.c   2007-08-15 08:42:54 UTC (rev 
5500)
+++ libmicrohttpd/src/daemon/daemontest_put.c   2007-08-15 08:59:38 UTC (rev 
5501)
@@ -148,9 +148,9 @@
   curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1);
   if (CURLE_OK != (errornum = curl_easy_perform (c)))
     {
-      fprintf(stderr, 
-             "curl_easy_perform failed: `%s'\n",
-             curl_easy_strerror(errornum));
+      fprintf (stderr,
+               "curl_easy_perform failed: `%s'\n",
+               curl_easy_strerror (errornum));
       curl_easy_cleanup (c);
       MHD_stop_daemon (d);
       return 2;
@@ -212,9 +212,9 @@
   curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1);
   if (CURLE_OK != (errornum = curl_easy_perform (c)))
     {
-      fprintf(stderr, 
-             "curl_easy_perform failed: `%s'\n",
-             curl_easy_strerror(errornum));
+      fprintf (stderr,
+               "curl_easy_perform failed: `%s'\n",
+               curl_easy_strerror (errornum));
       curl_easy_cleanup (c);
       MHD_stop_daemon (d);
       return 32;

Modified: libmicrohttpd/src/daemon/fileserver_example.c
===================================================================
--- libmicrohttpd/src/daemon/fileserver_example.c       2007-08-15 08:42:54 UTC 
(rev 5500)
+++ libmicrohttpd/src/daemon/fileserver_example.c       2007-08-15 08:59:38 UTC 
(rev 5501)
@@ -73,8 +73,7 @@
   else
     {
       stat (&url[1], &buf);
-      response = MHD_create_response_from_callback (buf.st_size,
-                                                   32 * 1024, /* 32k page size 
*/                                  
+      response = MHD_create_response_from_callback (buf.st_size, 32 * 1024,    
 /* 32k page size */
                                                     &file_reader,
                                                     file,
                                                     
(MHD_ContentReaderFreeCallback)

Modified: libmicrohttpd/src/daemon/memorypool.c
===================================================================
--- libmicrohttpd/src/daemon/memorypool.c       2007-08-15 08:42:54 UTC (rev 
5500)
+++ libmicrohttpd/src/daemon/memorypool.c       2007-08-15 08:59:38 UTC (rev 
5501)
@@ -56,7 +56,7 @@
 
 /**
  * Create a memory pool.
- * 
+ *
  * @param max maximum size of the pool
  */
 struct MemoryPool *
@@ -133,16 +133,16 @@
  * Reallocate a block of memory obtained from the pool.
  * This is particularly efficient when growing or
  * shrinking the block that was last (re)allocated.
- * If the given block is not the most recenlty 
+ * If the given block is not the most recenlty
  * (re)allocated block, the memory of the previous
- * allocation may be leaked until the pool is 
+ * allocation may be leaked until the pool is
  * destroyed (and copying the data maybe required).
  *
  * @param old the existing block
  * @param old_size the size of the existing block
  * @param new_size the new size of the block
- * @return new address of the block, or 
- *         NULL if the pool cannot support new_size 
+ * @return new address of the block, or
+ *         NULL if the pool cannot support new_size
  *         bytes (old continues to be valid for old_size)
  */
 void *

Modified: libmicrohttpd/src/daemon/memorypool.h
===================================================================
--- libmicrohttpd/src/daemon/memorypool.h       2007-08-15 08:42:54 UTC (rev 
5500)
+++ libmicrohttpd/src/daemon/memorypool.h       2007-08-15 08:59:38 UTC (rev 
5501)
@@ -39,7 +39,7 @@
 
 /**
  * Create a memory pool.
- * 
+ *
  * @param max maximum size of the pool
  */
 struct MemoryPool *MHD_pool_create (unsigned int max);
@@ -65,16 +65,16 @@
  * Reallocate a block of memory obtained from the pool.
  * This is particularly efficient when growing or
  * shrinking the block that was last (re)allocated.
- * If the given block is not the most recenlty 
+ * If the given block is not the most recenlty
  * (re)allocated block, the memory of the previous
- * allocation may be leaked until the pool is 
+ * allocation may be leaked until the pool is
  * destroyed (and copying the data maybe required).
  *
  * @param old the existing block
  * @param old_size the size of the existing block
  * @param new_size the new size of the block
- * @return new address of the block, or 
- *         NULL if the pool cannot support new_size 
+ * @return new address of the block, or
+ *         NULL if the pool cannot support new_size
  *         bytes (old continues to be valid for old_size)
  */
 void *MHD_pool_reallocate (struct MemoryPool *pool,

Modified: libmicrohttpd/src/daemon/plibc.h
===================================================================
--- libmicrohttpd/src/daemon/plibc.h    2007-08-15 08:42:54 UTC (rev 5500)
+++ libmicrohttpd/src/daemon/plibc.h    2007-08-15 08:59:38 UTC (rev 5501)
@@ -29,21 +29,22 @@
 #define _PLIBC_H_
 
 #ifndef SIGALRM
- #define SIGALRM 14
+#define SIGALRM 14
 #endif
 
 #ifdef __cplusplus
-extern "C" {
+extern "C"
+{
 #endif
 
 #ifdef Q_OS_WIN32
- #define WINDOWS 1
+#define WINDOWS 1
 #endif
 
 #ifdef WINDOWS
 
 #if ENABLE_NLS
-  #include "langinfo.h"
+#include "langinfo.h"
 #endif
 
 #include <windows.h>
@@ -75,8 +76,8 @@
 #define int64_t long long
 #define int32_t long
 
-struct stat64
-{
+  struct stat64
+  {
     _dev_t st_dev;
     _ino_t st_ino;
     _mode_t st_mode;
@@ -88,112 +89,112 @@
     __time64_t st_atime;
     __time64_t st_mtime;
     __time64_t st_ctime;
-};
+  };
 
 #ifndef pid_t
-       #define pid_t int
+#define pid_t int
 #endif
 
 #ifndef WEXITSTATUS
-       #define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
+#define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
 #endif
 
 /* Thanks to the Cygwin project */
-#define ENOCSI 43      /* No CSI structure available */
-#define EL2HLT 44      /* Level 2 halted */
+#define ENOCSI 43               /* No CSI structure available */
+#define EL2HLT 44               /* Level 2 halted */
 #ifndef  EDEADLK
-       #define EDEADLK 45      /* Deadlock condition */
+#define EDEADLK 45              /* Deadlock condition */
 #endif
 #ifndef  ENOLCK
-       #define ENOLCK 46       /* No record locks available */
+#define ENOLCK 46               /* No record locks available */
 #endif
-#define EBADE 50       /* Invalid exchange */
-#define EBADR 51       /* Invalid request descriptor */
-#define EXFULL 52      /* Exchange full */
-#define ENOANO 53      /* No anode */
-#define EBADRQC 54     /* Invalid request code */
-#define EBADSLT 55     /* Invalid slot */
+#define EBADE 50                /* Invalid exchange */
+#define EBADR 51                /* Invalid request descriptor */
+#define EXFULL 52               /* Exchange full */
+#define ENOANO 53               /* No anode */
+#define EBADRQC 54              /* Invalid request code */
+#define EBADSLT 55              /* Invalid slot */
 #ifndef  EDEADLOCK
-       #define EDEADLOCK EDEADLK       /* File locking deadlock error */
+#define EDEADLOCK EDEADLK       /* File locking deadlock error */
 #endif
-#define EBFONT 57      /* Bad font file fmt */
-#define ENOSTR 60      /* Device not a stream */
-#define ENODATA 61     /* No data (for no delay io) */
-#define ETIME 62       /* Timer expired */
-#define ENOSR 63       /* Out of streams resources */
-#define ENONET 64      /* Machine is not on the network */
-#define ENOPKG 65      /* Package not installed */
-#define EREMOTE 66     /* The object is remote */
-#define ENOLINK 67     /* The link has been severed */
-#define EADV 68                /* Advertise error */
-#define ESRMNT 69      /* Srmount error */
-#define ECOMM 70       /* Communication error on send */
-#define EPROTO 71      /* Protocol error */
-#define EMULTIHOP 74   /* Multihop attempted */
-#define ELBIN 75       /* Inode is remote (not really error) */
-#define EDOTDOT 76     /* Cross mount point (not really error) */
-#define EBADMSG 77     /* Trying to read unreadable message */
-#define ENOTUNIQ 80    /* Given log. name not unique */
-#define EBADFD 81      /* f.d. invalid for this operation */
-#define EREMCHG 82     /* Remote address changed */
-#define ELIBACC 83     /* Can't access a needed shared lib */
-#define ELIBBAD 84     /* Accessing a corrupted shared lib */
-#define ELIBSCN 85     /* .lib section in a.out corrupted */
-#define ELIBMAX 86     /* Attempting to link in too many libs */
-#define ELIBEXEC 87    /* Attempting to exec a shared library */
+#define EBFONT 57               /* Bad font file fmt */
+#define ENOSTR 60               /* Device not a stream */
+#define ENODATA 61              /* No data (for no delay io) */
+#define ETIME 62                /* Timer expired */
+#define ENOSR 63                /* Out of streams resources */
+#define ENONET 64               /* Machine is not on the network */
+#define ENOPKG 65               /* Package not installed */
+#define EREMOTE 66              /* The object is remote */
+#define ENOLINK 67              /* The link has been severed */
+#define EADV 68                 /* Advertise error */
+#define ESRMNT 69               /* Srmount error */
+#define ECOMM 70                /* Communication error on send */
+#define EPROTO 71               /* Protocol error */
+#define EMULTIHOP 74            /* Multihop attempted */
+#define ELBIN 75                /* Inode is remote (not really error) */
+#define EDOTDOT 76              /* Cross mount point (not really error) */
+#define EBADMSG 77              /* Trying to read unreadable message */
+#define ENOTUNIQ 80             /* Given log. name not unique */
+#define EBADFD 81               /* f.d. invalid for this operation */
+#define EREMCHG 82              /* Remote address changed */
+#define ELIBACC 83              /* Can't access a needed shared lib */
+#define ELIBBAD 84              /* Accessing a corrupted shared lib */
+#define ELIBSCN 85              /* .lib section in a.out corrupted */
+#define ELIBMAX 86              /* Attempting to link in too many libs */
+#define ELIBEXEC 87             /* Attempting to exec a shared library */
 #ifndef  ENOSYS
-       #define ENOSYS 88       /* Function not implemented */
+#define ENOSYS 88               /* Function not implemented */
 #endif
-#define ENMFILE 89      /* No more files */
+#define ENMFILE 89              /* No more files */
 #ifndef  ENOTEMPTY
-       #define ENOTEMPTY 90    /* Directory not empty */
+#define ENOTEMPTY 90            /* Directory not empty */
 #endif
 #ifndef  ENAMETOOLONG
-       #define ENAMETOOLONG 91 /* File or path name too long */
+#define ENAMETOOLONG 91         /* File or path name too long */
 #endif
-#define ELOOP 92       /* Too many symbolic links */
-#define EOPNOTSUPP 95  /* Operation not supported on transport endpoint */
-#define EPFNOSUPPORT 96 /* Protocol family not supported */
-#define ECONNRESET 104  /* Connection reset by peer */
-#define ENOBUFS 105    /* No buffer space available */
-#define EAFNOSUPPORT 106 /* Address family not supported by protocol family */
-#define EPROTOTYPE 107 /* Protocol wrong type for socket */
-#define ENOTSOCK 108   /* Socket operation on non-socket */
-#define ENOPROTOOPT 109        /* Protocol not available */
-#define ESHUTDOWN 110  /* Can't send after socket shutdown */
-#define ECONNREFUSED 111       /* Connection refused */
-#define EADDRINUSE 112         /* Address already in use */
-#define ECONNABORTED 113       /* Connection aborted */
-#define ENETUNREACH 114                /* Network is unreachable */
-#define ENETDOWN 115           /* Network interface is not configured */
+#define ELOOP 92                /* Too many symbolic links */
+#define EOPNOTSUPP 95           /* Operation not supported on transport 
endpoint */
+#define EPFNOSUPPORT 96         /* Protocol family not supported */
+#define ECONNRESET 104          /* Connection reset by peer */
+#define ENOBUFS 105             /* No buffer space available */
+#define EAFNOSUPPORT 106        /* Address family not supported by protocol 
family */
+#define EPROTOTYPE 107          /* Protocol wrong type for socket */
+#define ENOTSOCK 108            /* Socket operation on non-socket */
+#define ENOPROTOOPT 109         /* Protocol not available */
+#define ESHUTDOWN 110           /* Can't send after socket shutdown */
+#define ECONNREFUSED 111        /* Connection refused */
+#define EADDRINUSE 112          /* Address already in use */
+#define ECONNABORTED 113        /* Connection aborted */
+#define ENETUNREACH 114         /* Network is unreachable */
+#define ENETDOWN 115            /* Network interface is not configured */
 #ifndef  ETIMEDOUT
-       #define ETIMEDOUT 116           /* Connection timed out */
+#define ETIMEDOUT 116           /* Connection timed out */
 #endif
-#define EHOSTDOWN 117          /* Host is down */
-#define EHOSTUNREACH 118       /* Host is unreachable */
-#define EINPROGRESS 119                /* Connection already in progress */
-#define EALREADY 120           /* Socket already connected */
-#define EDESTADDRREQ 121       /* Destination address required */
-#define EMSGSIZE 122           /* Message too long */
-#define EPROTONOSUPPORT 123    /* Unknown protocol */
-#define ESOCKTNOSUPPORT 124    /* Socket type not supported */
-#define EADDRNOTAVAIL 125      /* Address not available */
-#define ENETRESET 126          /* Connection aborted by network */
-#define EISCONN 127                /* Socket is already connected */
-#define ENOTCONN 128           /* Socket is not connected */
-#define ETOOMANYREFS 129       /* Too many references: cannot splice */
-#define EPROCLIM 130           /* Too many processes */
-#define EUSERS 131                     /* Too many users */
-#define EDQUOT 132                     /* Disk quota exceeded */
-#define ESTALE 133          /* Unknown error */
+#define EHOSTDOWN 117           /* Host is down */
+#define EHOSTUNREACH 118        /* Host is unreachable */
+#define EINPROGRESS 119         /* Connection already in progress */
+#define EALREADY 120            /* Socket already connected */
+#define EDESTADDRREQ 121        /* Destination address required */
+#define EMSGSIZE 122            /* Message too long */
+#define EPROTONOSUPPORT 123     /* Unknown protocol */
+#define ESOCKTNOSUPPORT 124     /* Socket type not supported */
+#define EADDRNOTAVAIL 125       /* Address not available */
+#define ENETRESET 126           /* Connection aborted by network */
+#define EISCONN 127             /* Socket is already connected */
+#define ENOTCONN 128            /* Socket is not connected */
+#define ETOOMANYREFS 129        /* Too many references: cannot splice */
+#define EPROCLIM 130            /* Too many processes */
+#define EUSERS 131              /* Too many users */
+#define EDQUOT 132              /* Disk quota exceeded */
+#define ESTALE 133              /* Unknown error */
 #ifndef  ENOTSUP
-       #define ENOTSUP 134                 /* Not supported */
+#define ENOTSUP 134             /* Not supported */
 #endif
-#define ENOMEDIUM 135       /* No medium (in tape drive) */
-#define ENOSHARE 136        /* No such host or network path */
-#define ECASECLASH 137      /* Filename exists with different case */
-#define EWOULDBLOCK EAGAIN     /* Operation would block */
-#define EOVERFLOW 139 /* Value too large for defined data type */
+#define ENOMEDIUM 135           /* No medium (in tape drive) */
+#define ENOSHARE 136            /* No such host or network path */
+#define ECASECLASH 137          /* Filename exists with different case */
+#define EWOULDBLOCK EAGAIN      /* Operation would block */
+#define EOVERFLOW 139           /* Value too large for defined data type */
 
 #undef HOST_NOT_FOUND
 #define HOST_NOT_FOUND 1
@@ -207,65 +208,65 @@
 #define PROT_READ   0x1
 #define PROT_WRITE  0x2
 #define MAP_SHARED  0x1
-#define MAP_PRIVATE 0x2 /* unsupported */
+#define MAP_PRIVATE 0x2         /* unsupported */
 #define MAP_FIXED   0x10
 #define MAP_FAILED  ((void *)-1)
 
-struct statfs
-{
-  long f_type;                  /* type of filesystem (see below) */
-  long f_bsize;                 /* optimal transfer block size */
-  long f_blocks;                /* total data blocks in file system */
-  long f_bfree;                 /* free blocks in fs */
-  long f_bavail;                /* free blocks avail to non-superuser */
-  long f_files;                 /* total file nodes in file system */
-  long f_ffree;                 /* free file nodes in fs */
-  long f_fsid;                  /* file system id */
-  long f_namelen;               /* maximum length of filenames */
-  long f_spare[6];              /* spare for later */
-};
+  struct statfs
+  {
+    long f_type;                /* type of filesystem (see below) */
+    long f_bsize;               /* optimal transfer block size */
+    long f_blocks;              /* total data blocks in file system */
+    long f_bfree;               /* free blocks in fs */
+    long f_bavail;              /* free blocks avail to non-superuser */
+    long f_files;               /* total file nodes in file system */
+    long f_ffree;               /* free file nodes in fs */
+    long f_fsid;                /* file system id */
+    long f_namelen;             /* maximum length of filenames */
+    long f_spare[6];            /* spare for later */
+  };
 
 /* Taken from the Wine project <http://www.winehq.org>
     /wine/include/winternl.h */
-enum SYSTEM_INFORMATION_CLASS
-{
-  SystemBasicInformation = 0,
-  Unknown1,
-  SystemPerformanceInformation = 2,
-  SystemTimeOfDayInformation = 3, /* was SystemTimeInformation */
-  Unknown4,
-  SystemProcessInformation = 5,
-  Unknown6,
-  Unknown7,
-  SystemProcessorPerformanceInformation = 8,
-  Unknown9,
-  Unknown10,
-  SystemDriverInformation,
-  Unknown12,
-  Unknown13,
-  Unknown14,
-  Unknown15,
-  SystemHandleList,
-  Unknown17,
-  Unknown18,
-  Unknown19,
-  Unknown20,
-  SystemCacheInformation,
-  Unknown22,
-  SystemInterruptInformation = 23,
-  SystemExceptionInformation = 33,
-  SystemRegistryQuotaInformation = 37,
-  SystemLookasideInformation = 45
-};
+  enum SYSTEM_INFORMATION_CLASS
+  {
+    SystemBasicInformation = 0,
+    Unknown1,
+    SystemPerformanceInformation = 2,
+    SystemTimeOfDayInformation = 3,     /* was SystemTimeInformation */
+    Unknown4,
+    SystemProcessInformation = 5,
+    Unknown6,
+    Unknown7,
+    SystemProcessorPerformanceInformation = 8,
+    Unknown9,
+    Unknown10,
+    SystemDriverInformation,
+    Unknown12,
+    Unknown13,
+    Unknown14,
+    Unknown15,
+    SystemHandleList,
+    Unknown17,
+    Unknown18,
+    Unknown19,
+    Unknown20,
+    SystemCacheInformation,
+    Unknown22,
+    SystemInterruptInformation = 23,
+    SystemExceptionInformation = 33,
+    SystemRegistryQuotaInformation = 37,
+    SystemLookasideInformation = 45
+  };
 
-typedef struct
-{
+  typedef struct
+  {
     LARGE_INTEGER IdleTime;
     LARGE_INTEGER KernelTime;
     LARGE_INTEGER UserTime;
     LARGE_INTEGER Reserved1[2];
     ULONG Reserved2;
-} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
+  } SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
 
 #define sleep(secs) (Sleep(secs * 1000))
 
@@ -282,11 +283,11 @@
 #define SHUT_RDWR SD_BOTH
 
 /* Operations for flock() */
-#define LOCK_SH  1       /* shared lock */
-#define LOCK_EX  2       /* exclusive lock */
-#define LOCK_NB  4       /* or'd with one of the above to prevent
-                            blocking */
-#define LOCK_UN  8       /* remove lock */
+#define LOCK_SH  1              /* shared lock */
+#define LOCK_EX  2              /* exclusive lock */
+#define LOCK_NB  4              /* or'd with one of the above to prevent
+                                   blocking */
+#define LOCK_UN  8              /* remove lock */
 
 /* Not supported under MinGW */
 #define S_IRGRP 0
@@ -312,273 +313,274 @@
  */
 #define index(s, c) strchr(s, c)
 
-BOOL _plibc_CreateShortcut(const char *pszSrc, const char *pszDest);
-BOOL _plibc_DereferenceShortcut(char *pszShortcut);
-char *plibc_ChooseDir(char *pszTitle, unsigned long ulFlags);
-char *plibc_ChooseFile(char *pszTitle, unsigned long ulFlags);
-long QueryRegistry(HKEY hMainKey, char *pszKey, char *pszSubKey,
-              char *pszBuffer, long *pdLength);
+  BOOL _plibc_CreateShortcut (const char *pszSrc, const char *pszDest);
+  BOOL _plibc_DereferenceShortcut (char *pszShortcut);
+  char *plibc_ChooseDir (char *pszTitle, unsigned long ulFlags);
+  char *plibc_ChooseFile (char *pszTitle, unsigned long ulFlags);
+  long QueryRegistry (HKEY hMainKey, char *pszKey, char *pszSubKey,
+                      char *pszBuffer, long *pdLength);
 
-BOOL __win_IsHandleMarkedAsBlocking(SOCKET hHandle);
-void __win_SetHandleBlockingMode(SOCKET s, BOOL bBlocking);
-void __win_DiscardHandleBlockingMode(SOCKET s);
-int _win_isSocketValid(int s);
-int plibc_conv_to_win_path(const char *pszUnix, char *pszWindows);
+  BOOL __win_IsHandleMarkedAsBlocking (SOCKET hHandle);
+  void __win_SetHandleBlockingMode (SOCKET s, BOOL bBlocking);
+  void __win_DiscardHandleBlockingMode (SOCKET s);
+  int _win_isSocketValid (int s);
+  int plibc_conv_to_win_path (const char *pszUnix, char *pszWindows);
 
-typedef void (*TPanicProc) (int, char *);
-void plibc_set_panic_proc(TPanicProc proc);
+  typedef void (*TPanicProc) (int, char *);
+  void plibc_set_panic_proc (TPanicProc proc);
 
-int flock(int fd, int operation);
-int fsync(int fildes);
-int inet_pton(int af, const char *src, void *dst);
-int inet_pton4(const char *src, u_char *dst, int pton);
+  int flock (int fd, int operation);
+  int fsync (int fildes);
+  int inet_pton (int af, const char *src, void *dst);
+  int inet_pton4 (const char *src, u_char * dst, int pton);
 #if USE_IPV6
-int inet_pton6(const char *src, u_char *dst);
+  int inet_pton6 (const char *src, u_char * dst);
 #endif
-int truncate(const char *fname, int distance);
-int statfs(const char *path, struct statfs *buf);
-const char *hstrerror(int err);
-void gettimeofday(struct timeval *tp, void *tzp);
-int mkstemp(char *tmplate);
-char *strptime (const char *buf, const char *format, struct tm *tm);
-char *ctime(const time_t *clock);
-char *ctime_r(const time_t *clock, char *buf);
-const char *inet_ntop(int af, const void *src, char *dst, size_t size);
-int plibc_init(char *pszOrg, char *pszApp);
-void plibc_shutdown();
-int plibc_initialized();
-int plibc_conv_to_win_path_ex(const char *pszUnix, char *pszWindows, int 
derefLinks);
-void _SetErrnoFromWinError(long lWinError, char *pszCaller, int iLine);
-void SetErrnoFromWinsockError(long lWinError);
-void SetHErrnoFromWinError(long lWinError);
-void SetErrnoFromHRESULT(HRESULT hRes);
-FILE *_win_fopen(const char *filename, const char *mode);
-DIR *_win_opendir(const char *dirname);
-int _win_open(const char *filename, int oflag, ...);
+  int truncate (const char *fname, int distance);
+  int statfs (const char *path, struct statfs *buf);
+  const char *hstrerror (int err);
+  void gettimeofday (struct timeval *tp, void *tzp);
+  int mkstemp (char *tmplate);
+  char *strptime (const char *buf, const char *format, struct tm *tm);
+  char *ctime (const time_t * clock);
+  char *ctime_r (const time_t * clock, char *buf);
+  const char *inet_ntop (int af, const void *src, char *dst, size_t size);
+  int plibc_init (char *pszOrg, char *pszApp);
+  void plibc_shutdown ();
+  int plibc_initialized ();
+  int plibc_conv_to_win_path_ex (const char *pszUnix, char *pszWindows,
+                                 int derefLinks);
+  void _SetErrnoFromWinError (long lWinError, char *pszCaller, int iLine);
+  void SetErrnoFromWinsockError (long lWinError);
+  void SetHErrnoFromWinError (long lWinError);
+  void SetErrnoFromHRESULT (HRESULT hRes);
+  FILE *_win_fopen (const char *filename, const char *mode);
+  DIR *_win_opendir (const char *dirname);
+  int _win_open (const char *filename, int oflag, ...);
 #ifdef ENABLE_NLS
-char *_win_bindtextdomain(const char *domainname, const char *dirname);
+  char *_win_bindtextdomain (const char *domainname, const char *dirname);
 #endif
-int _win_chdir(const char *path);
-int _win_close(int fd);
-int _win_creat(const char *path, mode_t mode);
-int _win_fstat(int handle, struct stat *buffer);
-int _win_pipe(int *phandles);
-int _win_rmdir(const char *path);
-int _win_access( const char *path, int mode );
-int _win_chmod(const char *filename, int pmode);
-char *realpath(const char *file_name, char *resolved_name);
-long _win_random(void);
-int _win_remove(const char *path);
-int _win_rename(const char *oldname, const char *newname);
-int _win_stat(const char *path, struct stat *buffer);
-int _win_stat64(const char *path, struct stat64 *buffer);
-int _win_unlink(const char *filename);
-int _win_write(int fildes, const void *buf, size_t nbyte);
-int _win_read(int fildes, void *buf, size_t nbyte);
-size_t _win_fwrite(const void *buffer, size_t size, size_t count, FILE 
*stream);
-size_t _win_fread( void *buffer, size_t size, size_t count, FILE *stream );
-int _win_symlink(const char *path1, const char *path2);
-void *_win_mmap(void *start, size_t len, int access, int flags, int fd,
-                unsigned long long offset);
-int _win_munmap(void *start, size_t length);
-int _win_lstat(const char *path, struct stat *buf);
-int _win_lstat64(const char *path, struct stat64 *buf);
-int _win_readlink(const char *path, char *buf, size_t bufsize);
-int _win_accept(SOCKET s, struct sockaddr *addr, int *addrlen);
-int _win_printf(const char *format,...);
-int _win_fprintf(FILE *f,const char *format,...);
-int _win_vprintf(const char *format, va_list ap);
-int _win_vfprintf(FILE *stream, const char *format, va_list arg_ptr);
-int _win_vsprintf(char *dest,const char *format, va_list arg_ptr);
-int _win_vsnprintf(char* str, size_t size, const char *format, va_list 
arg_ptr);
-int _win_snprintf(char *str,size_t size,const char *format,...);
-int _win_sprintf(char *dest,const char *format,...);
-int _win_vsscanf(const char* str, const char* format, va_list arg_ptr);
-int _win_sscanf(const char *str, const char *format, ...);
-int _win_vfscanf(FILE *stream, const char *format, va_list arg_ptr);
-int _win_vscanf(const char *format, va_list arg_ptr);
-int _win_scanf(const char *format, ...);
-int _win_fscanf(FILE *stream, const char *format, ...);
-pid_t _win_waitpid(pid_t pid, int *stat_loc, int options);
-int _win_bind(SOCKET s, const struct sockaddr *name, int namelen);
-int _win_connect(SOCKET s,const struct sockaddr *name, int namelen);
-int _win_getpeername(SOCKET s, struct sockaddr *name,
-                int *namelen);
-int _win_getsockname(SOCKET s, struct sockaddr *name,
-                int *namelen);
-int _win_getsockopt(SOCKET s, int level, int optname, char *optval,
-                               int *optlen);
-int _win_listen(SOCKET s, int backlog);
-int _win_recv(SOCKET s, char *buf, int len, int flags);
-int _win_recvfrom(SOCKET s, void *buf, int len, int flags,
-             struct sockaddr *from, int *fromlen);
-int _win_select(int max_fd, fd_set * rfds, fd_set * wfds, fd_set * efds,
-                const struct timeval *tv);
-int _win_send(SOCKET s, const char *buf, int len, int flags);
-int _win_sendto(SOCKET s, const char *buf, int len, int flags,
-                const struct sockaddr *to, int tolen);
-int _win_setsockopt(SOCKET s, int level, int optname, const void *optval,
-                    int optlen);
-int _win_shutdown(SOCKET s, int how);
-SOCKET _win_socket(int af, int type, int protocol);
-struct hostent *_win_gethostbyaddr(const char *addr, int len, int type);
-struct hostent *_win_gethostbyname(const char *name);
-char *_win_strerror(int errnum);
-int IsWinNT();
+  int _win_chdir (const char *path);
+  int _win_close (int fd);
+  int _win_creat (const char *path, mode_t mode);
+  int _win_fstat (int handle, struct stat *buffer);
+  int _win_pipe (int *phandles);
+  int _win_rmdir (const char *path);
+  int _win_access (const char *path, int mode);
+  int _win_chmod (const char *filename, int pmode);
+  char *realpath (const char *file_name, char *resolved_name);
+  long _win_random (void);
+  int _win_remove (const char *path);
+  int _win_rename (const char *oldname, const char *newname);
+  int _win_stat (const char *path, struct stat *buffer);
+  int _win_stat64 (const char *path, struct stat64 *buffer);
+  int _win_unlink (const char *filename);
+  int _win_write (int fildes, const void *buf, size_t nbyte);
+  int _win_read (int fildes, void *buf, size_t nbyte);
+  size_t _win_fwrite (const void *buffer, size_t size, size_t count,
+                      FILE * stream);
+  size_t _win_fread (void *buffer, size_t size, size_t count, FILE * stream);
+  int _win_symlink (const char *path1, const char *path2);
+  void *_win_mmap (void *start, size_t len, int access, int flags, int fd,
+                   unsigned long long offset);
+  int _win_munmap (void *start, size_t length);
+  int _win_lstat (const char *path, struct stat *buf);
+  int _win_lstat64 (const char *path, struct stat64 *buf);
+  int _win_readlink (const char *path, char *buf, size_t bufsize);
+  int _win_accept (SOCKET s, struct sockaddr *addr, int *addrlen);
+  int _win_printf (const char *format, ...);
+  int _win_fprintf (FILE * f, const char *format, ...);
+  int _win_vprintf (const char *format, va_list ap);
+  int _win_vfprintf (FILE * stream, const char *format, va_list arg_ptr);
+  int _win_vsprintf (char *dest, const char *format, va_list arg_ptr);
+  int _win_vsnprintf (char *str, size_t size, const char *format,
+                      va_list arg_ptr);
+  int _win_snprintf (char *str, size_t size, const char *format, ...);
+  int _win_sprintf (char *dest, const char *format, ...);
+  int _win_vsscanf (const char *str, const char *format, va_list arg_ptr);
+  int _win_sscanf (const char *str, const char *format, ...);
+  int _win_vfscanf (FILE * stream, const char *format, va_list arg_ptr);
+  int _win_vscanf (const char *format, va_list arg_ptr);
+  int _win_scanf (const char *format, ...);
+  int _win_fscanf (FILE * stream, const char *format, ...);
+  pid_t _win_waitpid (pid_t pid, int *stat_loc, int options);
+  int _win_bind (SOCKET s, const struct sockaddr *name, int namelen);
+  int _win_connect (SOCKET s, const struct sockaddr *name, int namelen);
+  int _win_getpeername (SOCKET s, struct sockaddr *name, int *namelen);
+  int _win_getsockname (SOCKET s, struct sockaddr *name, int *namelen);
+  int _win_getsockopt (SOCKET s, int level, int optname, char *optval,
+                       int *optlen);
+  int _win_listen (SOCKET s, int backlog);
+  int _win_recv (SOCKET s, char *buf, int len, int flags);
+  int _win_recvfrom (SOCKET s, void *buf, int len, int flags,
+                     struct sockaddr *from, int *fromlen);
+  int _win_select (int max_fd, fd_set * rfds, fd_set * wfds, fd_set * efds,
+                   const struct timeval *tv);
+  int _win_send (SOCKET s, const char *buf, int len, int flags);
+  int _win_sendto (SOCKET s, const char *buf, int len, int flags,
+                   const struct sockaddr *to, int tolen);
+  int _win_setsockopt (SOCKET s, int level, int optname, const void *optval,
+                       int optlen);
+  int _win_shutdown (SOCKET s, int how);
+  SOCKET _win_socket (int af, int type, int protocol);
+  struct hostent *_win_gethostbyaddr (const char *addr, int len, int type);
+  struct hostent *_win_gethostbyname (const char *name);
+  char *_win_strerror (int errnum);
+  int IsWinNT ();
 
 #if !HAVE_STRNDUP
-char *strndup (const char *s, size_t n);
+  char *strndup (const char *s, size_t n);
 #endif
 #if !HAVE_STRNLEN
-size_t strnlen (const char *str, size_t maxlen);
+  size_t strnlen (const char *str, size_t maxlen);
 #endif
 
 #define strcasecmp(a, b) stricmp(a, b)
 #define strncasecmp(a, b, c) strnicmp(a, b, c)
 
-#endif /* WINDOWS */
+#endif                          /* WINDOWS */
 
 #ifndef WINDOWS
- #define DIR_SEPARATOR '/'
- #define DIR_SEPARATOR_STR "/"
- #define PATH_SEPARATOR ';'
- #define PATH_SEPARATOR_STR ";"
- #define NEWLINE "\n"
+#define DIR_SEPARATOR '/'
+#define DIR_SEPARATOR_STR "/"
+#define PATH_SEPARATOR ';'
+#define PATH_SEPARATOR_STR ";"
+#define NEWLINE "\n"
 
 #ifdef ENABLE_NLS
- #define BINDTEXTDOMAIN(d, n) bindtextdomain(d, n)
+#define BINDTEXTDOMAIN(d, n) bindtextdomain(d, n)
 #endif
- #define CREAT(p, m) creat(p, m)
- #undef FOPEN
- #define FOPEN(f, m) fopen(f, m)
- #define OPENDIR(d) opendir(d)
- #define OPEN(f) open(f)
- #define CHDIR(d) chdir(d)
- #define CLOSE(f) close(f)
- #define RMDIR(f) rmdir(f)
- #define ACCESS(p, m) access(p, m)
- #define CHMOD(f, p) chmod(f, p)
- #define FSTAT(h, b) fstat(h, b)
- #define PIPE(h) pipe(h)
- #define REMOVE(p) remove(p)
- #define RENAME(o, n) rename(o, n)
- #define STAT(p, b) stat(p, b)
- #define STAT64(p, b) stat64(p, b)
- #define UNLINK(f) unlink(f)
- #define WRITE(f, b, n) write(f, b, n)
- #define READ(f, b, n) read(f, b, n)
- #define GN_FREAD(b, s, c, f) fread(b, s, c, f)
- #define GN_FWRITE(b, s, c, f) fwrite(b, s, c, f)
- #define SYMLINK(a, b) symlink(a, b)
- #define MMAP(s, l, p, f, d, o) mmap(s, l, p, f, d, o)
- #define MUNMAP(s, l) munmap(s, l)
- #define STRERROR(i) strerror(i)
- #define RANDOM() random()
- #define READLINK(p, b, s) readlink(p, b, s)
- #define LSTAT(p, b) lstat(p, b)
- #define LSTAT64(p, b) lstat64(p, b)
- #define PRINTF printf
- #define FPRINTF fprintf
- #define VPRINTF(f, a) vprintf(f, a)
- #define VFPRINTF(s, f, a) vfprintf(s, f, a)
- #define VSPRINTF(d, f, a) vsprintf(d, f, a)
- #define VSNPRINTF(str, size, fmt, a) vsnprintf(str, size, fmt, a)
- #define _REAL_SNPRINTF snprintf
- #define SPRINTF sprintf
- #define VSSCANF(s, f, a) vsscanf(s, f, a)
- #define SSCANF sscanf
- #define VFSCANF(s, f, a) vfscanf(s, f, a)
- #define VSCANF(f, a) vscanf(f, a)
- #define SCANF scanf
- #define FSCANF fscanf
- #define WAITPID(p, s, o) waitpid(p, s, o)
- #define ACCEPT(s, a, l) accept(s, a, l)
- #define BIND(s, n, l) bind(s, n, l)
- #define CONNECT(s, n, l) connect(s, n, l)
- #define GETPEERNAME(s, n, l) getpeername(s, n, l)
- #define GETSOCKNAME(s, n, l) getsockname(s, n, l)
- #define GETSOCKOPT(s, l, o, v, p) getsockopt(s, l, o, v, p)
- #define LISTEN(s, b) listen(s, b)
- #define RECV(s, b, l, f) recv(s, b, l, f)
- #define RECVFROM(s, b, l, f, r, o) recvfrom(s, b, l, f, r, o)
- #define SELECT(n, r, w, e, t) select(n, r, w, e, t)
- #define SEND(s, b, l, f) send(s, b, l, f)
- #define SENDTO(s, b, l, f, o, n) sendto(s, b, l, f, o, n)
- #define SETSOCKOPT(s, l, o, v, n) setsockopt(s, l, o, v, n)
- #define SHUTDOWN(s, h) shutdown(s, h)
- #define SOCKET(a, t, p) socket(a, t, p)
- #define GETHOSTBYADDR(a, l, t) gethostbyname(a, l, t)
- #define GETHOSTBYNAME(n) gethostbyname(n)
+#define CREAT(p, m) creat(p, m)
+#undef FOPEN
+#define FOPEN(f, m) fopen(f, m)
+#define OPENDIR(d) opendir(d)
+#define OPEN(f) open(f)
+#define CHDIR(d) chdir(d)
+#define CLOSE(f) close(f)
+#define RMDIR(f) rmdir(f)
+#define ACCESS(p, m) access(p, m)
+#define CHMOD(f, p) chmod(f, p)
+#define FSTAT(h, b) fstat(h, b)
+#define PIPE(h) pipe(h)
+#define REMOVE(p) remove(p)
+#define RENAME(o, n) rename(o, n)
+#define STAT(p, b) stat(p, b)
+#define STAT64(p, b) stat64(p, b)
+#define UNLINK(f) unlink(f)
+#define WRITE(f, b, n) write(f, b, n)
+#define READ(f, b, n) read(f, b, n)
+#define GN_FREAD(b, s, c, f) fread(b, s, c, f)
+#define GN_FWRITE(b, s, c, f) fwrite(b, s, c, f)
+#define SYMLINK(a, b) symlink(a, b)
+#define MMAP(s, l, p, f, d, o) mmap(s, l, p, f, d, o)
+#define MUNMAP(s, l) munmap(s, l)
+#define STRERROR(i) strerror(i)
+#define RANDOM() random()
+#define READLINK(p, b, s) readlink(p, b, s)
+#define LSTAT(p, b) lstat(p, b)
+#define LSTAT64(p, b) lstat64(p, b)
+#define PRINTF printf
+#define FPRINTF fprintf
+#define VPRINTF(f, a) vprintf(f, a)
+#define VFPRINTF(s, f, a) vfprintf(s, f, a)
+#define VSPRINTF(d, f, a) vsprintf(d, f, a)
+#define VSNPRINTF(str, size, fmt, a) vsnprintf(str, size, fmt, a)
+#define _REAL_SNPRINTF snprintf
+#define SPRINTF sprintf
+#define VSSCANF(s, f, a) vsscanf(s, f, a)
+#define SSCANF sscanf
+#define VFSCANF(s, f, a) vfscanf(s, f, a)
+#define VSCANF(f, a) vscanf(f, a)
+#define SCANF scanf
+#define FSCANF fscanf
+#define WAITPID(p, s, o) waitpid(p, s, o)
+#define ACCEPT(s, a, l) accept(s, a, l)
+#define BIND(s, n, l) bind(s, n, l)
+#define CONNECT(s, n, l) connect(s, n, l)
+#define GETPEERNAME(s, n, l) getpeername(s, n, l)
+#define GETSOCKNAME(s, n, l) getsockname(s, n, l)
+#define GETSOCKOPT(s, l, o, v, p) getsockopt(s, l, o, v, p)
+#define LISTEN(s, b) listen(s, b)
+#define RECV(s, b, l, f) recv(s, b, l, f)
+#define RECVFROM(s, b, l, f, r, o) recvfrom(s, b, l, f, r, o)
+#define SELECT(n, r, w, e, t) select(n, r, w, e, t)
+#define SEND(s, b, l, f) send(s, b, l, f)
+#define SENDTO(s, b, l, f, o, n) sendto(s, b, l, f, o, n)
+#define SETSOCKOPT(s, l, o, v, n) setsockopt(s, l, o, v, n)
+#define SHUTDOWN(s, h) shutdown(s, h)
+#define SOCKET(a, t, p) socket(a, t, p)
+#define GETHOSTBYADDR(a, l, t) gethostbyname(a, l, t)
+#define GETHOSTBYNAME(n) gethostbyname(n)
 #else
- #define DIR_SEPARATOR '\\'
- #define DIR_SEPARATOR_STR "\\"
- #define PATH_SEPARATOR ':'
- #define PATH_SEPARATOR_STR ":"
- #define NEWLINE "\r\n"
+#define DIR_SEPARATOR '\\'
+#define DIR_SEPARATOR_STR "\\"
+#define PATH_SEPARATOR ':'
+#define PATH_SEPARATOR_STR ":"
+#define NEWLINE "\r\n"
 
 #ifdef ENABLE_NLS
- #define BINDTEXTDOMAIN(d, n) _win_bindtextdomain(d, n)
+#define BINDTEXTDOMAIN(d, n) _win_bindtextdomain(d, n)
 #endif
- #define CREAT(p, m) _win_creat(p, m)
- #define FOPEN(f, m) _win_fopen(f, m)
- #define OPENDIR(d) _win_opendir(d)
- #define OPEN(f) _win_open(f)
- #define CHDIR(d) _win_chdir(d)
- #define CLOSE(f) _win_close(f)
- #define FSTAT(h, b) _win_fstat(h, b)
- #define RMDIR(f) _win_rmdir(f)
- #define ACCESS(p, m) _win_access(p, m)
- #define CHMOD(f, p) _win_chmod(f, p)
- #define PIPE(h) _win_pipe(h)
- #define RANDOM() _win_random()
- #define REMOVE(p) _win_remove(p)
- #define RENAME(o, n) _win_rename(o, n)
- #define STAT(p, b) _win_stat(p, b)
- #define STAT64(p, b) _win_stat64(p, b)
- #define UNLINK(f) _win_unlink(f)
- #define WRITE(f, b, n) _win_write(f, b, n)
- #define READ(f, b, n) _win_read(f, b, n)
- #define GN_FREAD(b, s, c, f) _win_fread(b, s, c, f)
- #define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f)
- #define SYMLINK(a, b) _win_symlink(a, b)
- #define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o)
- #define MUNMAP(s, l) _win_munmap(s, l)
- #define STRERROR(i) _win_strerror(i)
- #define READLINK(p, b, s) _win_readlink(p, b, s)
- #define LSTAT(p, b) _win_lstat(p, b)
- #define LSTAT64(p, b) _win_lstat64(p, b)
- #define PRINTF(f, ...) _win_printf(f , __VA_ARGS__)
- #define FPRINTF(fil, fmt, ...) _win_fprintf(fil, fmt, __VA_ARGS__)
- #define VPRINTF(f, a) _win_vprintf(f, a)
- #define VFPRINTF(s, f, a) _win_vfprintf(s, f, a)
- #define VSPRINTF(d, f, a) _win_vsprintf(d, f, a)
- #define VSNPRINTF(str, size, fmt, a) _win_vsnprintf(str, size, fmt, a)
- #define _REAL_SNPRINTF(str, size, fmt, ...) _win_snprintf(str, size, fmt, 
__VA_ARGS__)
- #define SPRINTF(d, f, ...) _win_sprintf(d, f, __VA_ARGS__)
- #define VSSCANF(s, f, a) _win_vsscanf(s, f, a)
- #define SSCANF(s, f, ...) _win_sscanf(s, f, __VA_ARGS__)
- #define VFSCANF(s, f, a) _win_vfscanf(s, f, a)
- #define VSCANF(f, a) _win_vscanf(f, a)
- #define SCANF(f, ...) _win_scanf(f, __VA_ARGS__)
- #define FSCANF(s, f, ...) _win_fscanf(s, f, __VA_ARGS__)
- #define WAITPID(p, s, o) _win_waitpid(p, s, o)
- #define ACCEPT(s, a, l) _win_accept(s, a, l)
- #define BIND(s, n, l) _win_bind(s, n, l)
- #define CONNECT(s, n, l) _win_connect(s, n, l)
- #define GETPEERNAME(s, n, l) _win_getpeername(s, n, l)
- #define GETSOCKNAME(s, n, l) _win_getsockname(s, n, l)
- #define GETSOCKOPT(s, l, o, v, p) _win_getsockopt(s, l, o, v, p)
- #define LISTEN(s, b) _win_listen(s, b)
- #define RECV(s, b, l, f) _win_recv(s, b, l, f)
- #define RECVFROM(s, b, l, f, r, o) _win_recvfrom(s, b, l, f, r, o)
- #define SELECT(n, r, w, e, t) _win_select(n, r, w, e, t)
- #define SEND(s, b, l, f) _win_send(s, b, l, f)
- #define SENDTO(s, b, l, f, o, n) _win_sendto(s, b, l, f, o, n)
- #define SETSOCKOPT(s, l, o, v, n) _win_setsockopt(s, l, o, v, n)
- #define SHUTDOWN(s, h) _win_shutdown(s, h)
- #define SOCKET(a, t, p) _win_socket(a, t, p)
- #define GETHOSTBYADDR(a, l, t) _win_gethostbyname(a, l, t)
- #define GETHOSTBYNAME(n) _win_gethostbyname(n)
+#define CREAT(p, m) _win_creat(p, m)
+#define FOPEN(f, m) _win_fopen(f, m)
+#define OPENDIR(d) _win_opendir(d)
+#define OPEN(f) _win_open(f)
+#define CHDIR(d) _win_chdir(d)
+#define CLOSE(f) _win_close(f)
+#define FSTAT(h, b) _win_fstat(h, b)
+#define RMDIR(f) _win_rmdir(f)
+#define ACCESS(p, m) _win_access(p, m)
+#define CHMOD(f, p) _win_chmod(f, p)
+#define PIPE(h) _win_pipe(h)
+#define RANDOM() _win_random()
+#define REMOVE(p) _win_remove(p)
+#define RENAME(o, n) _win_rename(o, n)
+#define STAT(p, b) _win_stat(p, b)
+#define STAT64(p, b) _win_stat64(p, b)
+#define UNLINK(f) _win_unlink(f)
+#define WRITE(f, b, n) _win_write(f, b, n)
+#define READ(f, b, n) _win_read(f, b, n)
+#define GN_FREAD(b, s, c, f) _win_fread(b, s, c, f)
+#define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f)
+#define SYMLINK(a, b) _win_symlink(a, b)
+#define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o)
+#define MUNMAP(s, l) _win_munmap(s, l)
+#define STRERROR(i) _win_strerror(i)
+#define READLINK(p, b, s) _win_readlink(p, b, s)
+#define LSTAT(p, b) _win_lstat(p, b)
+#define LSTAT64(p, b) _win_lstat64(p, b)
+#define PRINTF(f, ...) _win_printf(f , __VA_ARGS__)
+#define FPRINTF(fil, fmt, ...) _win_fprintf(fil, fmt, __VA_ARGS__)
+#define VPRINTF(f, a) _win_vprintf(f, a)
+#define VFPRINTF(s, f, a) _win_vfprintf(s, f, a)
+#define VSPRINTF(d, f, a) _win_vsprintf(d, f, a)
+#define VSNPRINTF(str, size, fmt, a) _win_vsnprintf(str, size, fmt, a)
+#define _REAL_SNPRINTF(str, size, fmt, ...) _win_snprintf(str, size, fmt, 
__VA_ARGS__)
+#define SPRINTF(d, f, ...) _win_sprintf(d, f, __VA_ARGS__)
+#define VSSCANF(s, f, a) _win_vsscanf(s, f, a)
+#define SSCANF(s, f, ...) _win_sscanf(s, f, __VA_ARGS__)
+#define VFSCANF(s, f, a) _win_vfscanf(s, f, a)
+#define VSCANF(f, a) _win_vscanf(f, a)
+#define SCANF(f, ...) _win_scanf(f, __VA_ARGS__)
+#define FSCANF(s, f, ...) _win_fscanf(s, f, __VA_ARGS__)
+#define WAITPID(p, s, o) _win_waitpid(p, s, o)
+#define ACCEPT(s, a, l) _win_accept(s, a, l)
+#define BIND(s, n, l) _win_bind(s, n, l)
+#define CONNECT(s, n, l) _win_connect(s, n, l)
+#define GETPEERNAME(s, n, l) _win_getpeername(s, n, l)
+#define GETSOCKNAME(s, n, l) _win_getsockname(s, n, l)
+#define GETSOCKOPT(s, l, o, v, p) _win_getsockopt(s, l, o, v, p)
+#define LISTEN(s, b) _win_listen(s, b)
+#define RECV(s, b, l, f) _win_recv(s, b, l, f)
+#define RECVFROM(s, b, l, f, r, o) _win_recvfrom(s, b, l, f, r, o)
+#define SELECT(n, r, w, e, t) _win_select(n, r, w, e, t)
+#define SEND(s, b, l, f) _win_send(s, b, l, f)
+#define SENDTO(s, b, l, f, o, n) _win_sendto(s, b, l, f, o, n)
+#define SETSOCKOPT(s, l, o, v, n) _win_setsockopt(s, l, o, v, n)
+#define SHUTDOWN(s, h) _win_shutdown(s, h)
+#define SOCKET(a, t, p) _win_socket(a, t, p)
+#define GETHOSTBYADDR(a, l, t) _win_gethostbyname(a, l, t)
+#define GETHOSTBYNAME(n) _win_gethostbyname(n)
 #endif
 
 
@@ -587,6 +589,6 @@
 #endif
 
 
-#endif //_PLIBC_H_
+#endif                          //_PLIBC_H_
 
 /* end of plibc.h */

Modified: libmicrohttpd/src/daemon/response.c
===================================================================
--- libmicrohttpd/src/daemon/response.c 2007-08-15 08:42:54 UTC (rev 5500)
+++ libmicrohttpd/src/daemon/response.c 2007-08-15 08:59:38 UTC (rev 5501)
@@ -160,21 +160,20 @@
  */
 struct MHD_Response *
 MHD_create_response_from_callback (size_t size,
-                                  unsigned int block_size,
+                                   unsigned int block_size,
                                    MHD_ContentReaderCallback crc,
                                    void *crc_cls,
                                    MHD_ContentReaderFreeCallback crfc)
 {
   struct MHD_Response *retVal;
 
-  if ( (crc == NULL) ||
-       (block_size == 0) )
+  if ((crc == NULL) || (block_size == 0))
     return NULL;
   retVal = malloc (sizeof (struct MHD_Response) + block_size);
   if (retVal == NULL)
     return NULL;
   memset (retVal, 0, sizeof (struct MHD_Response));
-  retVal->data = (void*) &retVal[1];
+  retVal->data = (void *) &retVal[1];
   retVal->data_buffer_size = MHD_BUF_INC_SIZE;
   if (pthread_mutex_init (&retVal->mutex, NULL) != 0)
     {

Modified: libmicrohttpd/src/include/microhttpd.h
===================================================================
--- libmicrohttpd/src/include/microhttpd.h      2007-08-15 08:42:54 UTC (rev 
5500)
+++ libmicrohttpd/src/include/microhttpd.h      2007-08-15 08:59:38 UTC (rev 
5501)
@@ -27,7 +27,7 @@
  * All symbols defined in this header start with MHD.  MHD is a
  * micro-httpd library.  As such, it does not have any API for logging
  * errors.  Also, it may not support all of the HTTP features directly,
- * where applicable, portions of HTTP may have to be handled by 
+ * where applicable, portions of HTTP may have to be handled by
  * clients of the library (the library is supposed to handle
  * everything that it must handle, such as basic connection
  * management; however, detailed interpretations of headers
@@ -255,7 +255,7 @@
 };
 
 /**
- * MHD options.  Passed in the varargs portion 
+ * MHD options.  Passed in the varargs portion
  * of MHD_start_daemon.
  */
 enum MHD_OPTION
@@ -280,7 +280,7 @@
   MHD_OPTION_CONNECTION_LIMIT = 2,
 
   /**
-   * After how many seconds of inactivity should a 
+   * After how many seconds of inactivity should a
    * connection automatically be timed out? (followed
    * by an unsigned int; use zero for no timeout).
    */
@@ -371,7 +371,7 @@
  * @param upload_data the data being uploaded (excluding HEADERS,
  *        for a POST that fits into memory and that is encoded
  *        with a supported encoding, the POST data will NOT be
- *        given in upload_data and is instead available as 
+ *        given in upload_data and is instead available as
  *        part of MHD_get_connection_values; very large POST
  *        data *will* be made available incrementally in
  *        upload_data)
@@ -490,15 +490,13 @@
  * (only needed if connection timeout is used).  The
  * returned value is how long select should at most
  * block, not the timeout value set for connections.
- * 
+ *
  * @param timeout set to the timeout (in milliseconds)
  * @return MHD_YES on success, MHD_NO if timeouts are
  *        not used (or no connections exist that would
  *        necessiate the use of a timeout right now).
  */
-int 
-MHD_get_timeout(struct MHD_Daemon * daemon,
-               unsigned long long * timeout);
+int MHD_get_timeout (struct MHD_Daemon *daemon, unsigned long long *timeout);
 
 
 /**
@@ -594,7 +592,8 @@
  * @return NULL on error (i.e. invalid arguments, out of memory)
  */
 struct MHD_Response *MHD_create_response_from_callback (size_t size,
-                                                       unsigned int block_size,
+                                                        unsigned int
+                                                        block_size,
                                                         
MHD_ContentReaderCallback
                                                         crc, void *crc_cls,
                                                         
MHD_ContentReaderFreeCallback





reply via email to

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