Преглед изворни кода

Remove PlibC wrappers and macros

Evgeny Grin (Karlson2k) пре 12 година
родитељ
комит
41ea8b14cd

+ 10 - 0
src/include/platform.h

@@ -124,6 +124,16 @@
 #define usleep(useconds) (void)SleepEx((useconds)/1000, 1)
 #endif
 
+#if !defined(SHUT_WR) && defined(SD_SEND)
+#define SHUT_WR SD_SEND
+#endif
+#if !defined(SHUT_RD) && defined(SD_RECEIVE)
+#define SHUT_RD SD_RECEIVE
+#endif
+#if !defined(SHUT_RDWR) && defined(SD_BOTH)
+#define SHUT_RDWR SD_BOTH
+#endif
+
 #ifndef MHD_SOCKET_DEFINED
 /**
  * MHD_socket is type for socket FDs

+ 7 - 7
src/microhttpd/connection.c

@@ -265,7 +265,7 @@ MHD_connection_close (struct MHD_Connection *connection,
 
   daemon = connection->daemon;
   if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO))
-    SHUTDOWN (connection->socket_fd,
+    shutdown (connection->socket_fd,
 	      (MHD_YES == connection->read_closed) ? SHUT_WR : SHUT_RDWR);
   connection->state = MHD_CONNECTION_CLOSED;
   connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP;
@@ -625,7 +625,7 @@ add_extra_headers (struct MHD_Connection *connection)
 	     Note that the change from 'SHOULD NOT' to 'MUST NOT' is
 	     a recent development of the HTTP 1.1 specification.
 	  */
-	  SPRINTF (buf,
+	  sprintf (buf,
 		   MHD_UNSIGNED_LONG_LONG_PRINTF,
 		   (MHD_UNSIGNED_LONG_LONG) connection->response->total_size);
 	  MHD_add_response_header (connection->response,
@@ -769,7 +769,7 @@ build_header_response (struct MHD_Connection *connection)
       add_extra_headers (connection);
       rc = connection->responseCode & (~MHD_ICY_FLAG);
       reason_phrase = MHD_get_reason_phrase_for (rc);
-      SPRINTF (code,
+      sprintf (code,
                "%s %u %s\r\n",
 	       (0 != (connection->responseCode & MHD_ICY_FLAG))
 	       ? "ICY"
@@ -835,7 +835,7 @@ build_header_response (struct MHD_Connection *connection)
     }
   for (pos = connection->response->first_header; NULL != pos; pos = pos->next)
     if (pos->kind == kind)
-      off += SPRINTF (&data[off],
+      off += sprintf (&data[off],
 		      "%s: %s\r\n",
 		      pos->header,
 		      pos->value);
@@ -1675,7 +1675,7 @@ do_write (struct MHD_Connection *connection)
       return MHD_YES;
     }
 #if DEBUG_SEND_DATA
-  FPRINTF (stderr,
+  fprintf (stderr,
            "Sent response: `%.*s'\n",
            ret,
            &connection->write_buffer[connection->write_buffer_send_offset]);
@@ -2056,7 +2056,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
               return MHD_YES;
             }
 #if DEBUG_SEND_DATA
-          FPRINTF (stderr,
+          fprintf (stderr,
                    "Sent 100 continue response: `%.*s'\n",
                    (int) ret,
                    &HTTP_100_CONTINUE[connection->continue_message_write_offset]);
@@ -2094,7 +2094,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
 	  const int err = MHD_socket_errno_;
 #if DEBUG_SEND_DATA
           if (ret > 0)
-            FPRINTF (stderr,
+            fprintf (stderr,
                      "Sent DATA response: `%.*s'\n",
                      (int) ret,
                      &response->data[connection->response_write_position -

+ 17 - 17
src/microhttpd/daemon.c

@@ -302,7 +302,7 @@ MHD_ip_limit_add (struct MHD_Daemon *daemon,
   MHD_ip_count_lock (daemon);
 
   /* Search for the IP address */
-  if (NULL == (nodep = TSEARCH (key,
+  if (NULL == (nodep = tsearch (key,
 				&daemon->per_ip_connection_count,
 				&MHD_ip_addr_compare)))
     {
@@ -358,7 +358,7 @@ MHD_ip_limit_del (struct MHD_Daemon *daemon,
   MHD_ip_count_lock (daemon);
 
   /* Search for the IP address */
-  if (NULL == (nodep = TFIND (&search_key,
+  if (NULL == (nodep = tfind (&search_key,
 			      &daemon->per_ip_connection_count,
 			      &MHD_ip_addr_compare)))
     {
@@ -375,7 +375,7 @@ MHD_ip_limit_del (struct MHD_Daemon *daemon,
   /* Remove the node entirely if count reduces to 0 */
   if (0 == --found_key->count)
     {
-      TDELETE (found_key,
+      tdelete (found_key,
 	       &daemon->per_ip_connection_count,
 	       &MHD_ip_addr_compare);
       free (found_key);
@@ -850,7 +850,7 @@ recv_param_adapter (struct MHD_Connection *connection,
       MHD_set_socket_errno_ (ENOTCONN);
       return -1;
     }
-  ret = RECV (connection->socket_fd, other, i, MSG_NOSIGNAL);
+  ret = recv (connection->socket_fd, other, i, MSG_NOSIGNAL);
 #if EPOLL_SUPPORT
   if (ret < (ssize_t) i)
     {
@@ -889,7 +889,7 @@ send_param_adapter (struct MHD_Connection *connection,
       return -1;
     }
   if (0 != (connection->daemon->options & MHD_USE_SSL))
-    return SEND (connection->socket_fd, other, i, MSG_NOSIGNAL);
+    return send (connection->socket_fd, other, i, MSG_NOSIGNAL);
 #if LINUX
   if ( (connection->write_buffer_append_offset ==
 	connection->write_buffer_send_offset) &&
@@ -926,7 +926,7 @@ send_param_adapter (struct MHD_Connection *connection,
 	 http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html */
     }
 #endif
-  ret = SEND (connection->socket_fd, other, i, MSG_NOSIGNAL);
+  ret = send (connection->socket_fd, other, i, MSG_NOSIGNAL);
 #if EPOLL_SUPPORT
   if (ret < (ssize_t) i)
     {
@@ -1707,7 +1707,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
 #if HAVE_ACCEPT4
   s = accept4 (fd, addr, &addrlen, SOCK_CLOEXEC | nonblock);
 #else
-  s = ACCEPT (fd, addr, &addrlen);
+  s = accept (fd, addr, &addrlen);
 #endif
   if ((MHD_INVALID_SOCKET == s) || (addrlen <= 0))
     {
@@ -1814,7 +1814,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
       if (MHD_INVALID_SOCKET != pos->socket_fd)
 	{
 #ifdef WINDOWS
-	  SHUTDOWN (pos->socket_fd, SHUT_WR);
+	  shutdown (pos->socket_fd, SHUT_WR);
 #endif
 	  if (0 != MHD_socket_close_ (pos->socket_fd))
 	    MHD_PANIC ("close failed\n");
@@ -3082,11 +3082,11 @@ create_socket (struct MHD_Daemon *daemon,
 
   /* use SOCK_STREAM rather than ai_socktype: some getaddrinfo
    * implementations do not set ai_socktype, e.g. RHL6.2. */
-  fd = SOCKET (domain, ctype, protocol);
+  fd = socket (domain, ctype, protocol);
   if ( (MHD_INVALID_SOCKET == fd) && (EINVAL == MHD_socket_errno_) && (0 != SOCK_CLOEXEC) )
   {
     ctype = type;
-    fd = SOCKET(domain, type, protocol);
+    fd = socket(domain, type, protocol);
   }
   if (MHD_INVALID_SOCKET == fd)
     return MHD_INVALID_SOCKET;
@@ -3440,10 +3440,10 @@ MHD_start_daemon_va (unsigned int flags,
 #endif
 	  goto free_and_fail;
 	}
-      if ( (0 > SETSOCKOPT (socket_fd,
+      if ( (0 > setsockopt (socket_fd,
 			    SOL_SOCKET,
 			    SO_REUSEADDR,
-			    &on, sizeof (on))) &&
+			    (void*)&on, sizeof (on))) &&
 	   (0 != (flags & MHD_USE_DEBUG)) )
 	{
 #if HAVE_MESSAGES
@@ -3501,7 +3501,7 @@ MHD_start_daemon_va (unsigned int flags,
 	  const char
 #endif
             on = (MHD_USE_DUAL_STACK != (flags & MHD_USE_DUAL_STACK));
-	  if ( (0 > SETSOCKOPT (socket_fd,
+	  if ( (0 > setsockopt (socket_fd,
 				IPPROTO_IPV6, IPV6_V6ONLY,
 				&on, sizeof (on))) &&
 	       (0 != (flags & MHD_USE_DEBUG)) )
@@ -3515,7 +3515,7 @@ MHD_start_daemon_va (unsigned int flags,
 #endif
 #endif
 	}
-      if (-1 == BIND (socket_fd, servaddr, addrlen))
+      if (-1 == bind (socket_fd, servaddr, addrlen))
 	{
 #if HAVE_MESSAGES
 	  if (0 != (flags & MHD_USE_DEBUG))
@@ -3545,7 +3545,7 @@ MHD_start_daemon_va (unsigned int flags,
 	    }
 	}
 #endif
-      if (LISTEN (socket_fd, 32) < 0)
+      if (listen (socket_fd, 32) < 0)
 	{
 #if HAVE_MESSAGES
 	  if (0 != (flags & MHD_USE_DEBUG))
@@ -3860,7 +3860,7 @@ close_all_connections (struct MHD_Daemon *daemon)
        (0 != pthread_mutex_lock (&daemon->cleanup_connection_mutex)) )
     MHD_PANIC ("Failed to acquire cleanup mutex\n");
   for (pos = daemon->connections_head; NULL != pos; pos = pos->nextX)
-    SHUTDOWN (pos->socket_fd,
+    shutdown (pos->socket_fd,
 	      (pos->read_closed == MHD_YES) ? SHUT_WR : SHUT_RDWR);
   if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
        (0 != pthread_mutex_unlock (&daemon->cleanup_connection_mutex)) )
@@ -3956,7 +3956,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
     {
       /* fd might be MHD_INVALID_SOCKET here due to 'MHD_quiesce_daemon' */
       if (MHD_INVALID_SOCKET != fd)
-	(void) SHUTDOWN (fd, SHUT_RDWR);
+	(void) shutdown (fd, SHUT_RDWR);
     }
 #endif
 #if EPOLL_SUPPORT

+ 1 - 1
src/testcurl/perf_get.c

@@ -82,7 +82,7 @@ now ()
 {
   struct timeval tv;
 
-  GETTIMEOFDAY (&tv, NULL);
+  gettimeofday (&tv, NULL);
   return (((unsigned long long) tv.tv_sec * 1000LL) +
 	  ((unsigned long long) tv.tv_usec / 1000LL));
 }

+ 1 - 1
src/testcurl/perf_get_concurrent.c

@@ -78,7 +78,7 @@ now ()
 {
   struct timeval tv;
 
-  GETTIMEOFDAY (&tv, NULL);
+  gettimeofday (&tv, NULL);
   return (((unsigned long long) tv.tv_sec * 1000LL) +
 	  ((unsigned long long) tv.tv_usec / 1000LL));
 }

+ 5 - 5
src/testcurl/test_get.c

@@ -461,10 +461,10 @@ testStopRace (int poll_flag)
     if (d == NULL)
        return 16;
     
-    fd = SOCKET (PF_INET, SOCK_STREAM, 0);
-    if (fd < 0)
+    fd = socket (PF_INET, SOCK_STREAM, 0);
+    if (fd == MHD_INVALID_SOCKET)
     {
-       fprintf(stderr, "socket: %m\n");
+       fprintf(stderr, "socket error\n");
        return 256;
     }
     
@@ -473,9 +473,9 @@ testStopRace (int poll_flag)
     sin.sin_port = htons(1081);
     sin.sin_addr.s_addr = htonl(0x7f000001);
     
-    if (CONNECT (fd, (struct sockaddr *)(&sin), sizeof(sin)) < 0)
+    if (connect (fd, (struct sockaddr *)(&sin), sizeof(sin)) < 0)
     {
-       fprintf(stderr, "connect: %m\n");
+       fprintf(stderr, "connect error\n");
        MHD_socket_close_ (fd);
        return 512;
     }

+ 1 - 1
src/testcurl/test_get_sendfile.c

@@ -486,7 +486,7 @@ main (int argc, char *const *argv)
   if (errorCount != 0)
     fprintf (stderr, "Error (code: %u)\n", errorCount);
   curl_global_cleanup ();
-  UNLINK (sourcefile);
+  unlink (sourcefile);
   free (sourcefile);
   return errorCount != 0;       /* 0 == pass */
 }

+ 1 - 1
src/testcurl/test_post_loop.c

@@ -462,7 +462,7 @@ now ()
 {
   struct timeval tv;
 
-  GETTIMEOFDAY (&tv, NULL);
+  gettimeofday (&tv, NULL);
   return (((unsigned long long) tv.tv_sec * 1000LL) +
 	  ((unsigned long long) tv.tv_usec / 1000LL));
 }