aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2014-02-18 18:39:59 +0000
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2014-02-18 18:39:59 +0000
commit41ea8b14cd9a69d2c1b2be6e08d37282fdadd0b3 (patch)
tree24c8aa6efdc7cce07b8dd20859efc7d2298c63b4
parent93ed5e5d6665a8f7c5a442b21cc057b89fa26128 (diff)
downloadlibmicrohttpd-41ea8b14cd9a69d2c1b2be6e08d37282fdadd0b3.tar.gz
libmicrohttpd-41ea8b14cd9a69d2c1b2be6e08d37282fdadd0b3.zip
Remove PlibC wrappers and macros
-rw-r--r--src/include/platform.h10
-rw-r--r--src/microhttpd/connection.c14
-rw-r--r--src/microhttpd/daemon.c34
-rw-r--r--src/testcurl/perf_get.c2
-rw-r--r--src/testcurl/perf_get_concurrent.c2
-rw-r--r--src/testcurl/test_get.c10
-rw-r--r--src/testcurl/test_get_sendfile.c2
-rw-r--r--src/testcurl/test_post_loop.c2
8 files changed, 43 insertions, 33 deletions
diff --git a/src/include/platform.h b/src/include/platform.h
index 84c381d7..88c68934 100644
--- a/src/include/platform.h
+++ b/src/include/platform.h
@@ -124,6 +124,16 @@
124#define usleep(useconds) (void)SleepEx((useconds)/1000, 1) 124#define usleep(useconds) (void)SleepEx((useconds)/1000, 1)
125#endif 125#endif
126 126
127#if !defined(SHUT_WR) && defined(SD_SEND)
128#define SHUT_WR SD_SEND
129#endif
130#if !defined(SHUT_RD) && defined(SD_RECEIVE)
131#define SHUT_RD SD_RECEIVE
132#endif
133#if !defined(SHUT_RDWR) && defined(SD_BOTH)
134#define SHUT_RDWR SD_BOTH
135#endif
136
127#ifndef MHD_SOCKET_DEFINED 137#ifndef MHD_SOCKET_DEFINED
128/** 138/**
129 * MHD_socket is type for socket FDs 139 * MHD_socket is type for socket FDs
diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c
index fd19e112..dae28a41 100644
--- a/src/microhttpd/connection.c
+++ b/src/microhttpd/connection.c
@@ -265,7 +265,7 @@ MHD_connection_close (struct MHD_Connection *connection,
265 265
266 daemon = connection->daemon; 266 daemon = connection->daemon;
267 if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO)) 267 if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO))
268 SHUTDOWN (connection->socket_fd, 268 shutdown (connection->socket_fd,
269 (MHD_YES == connection->read_closed) ? SHUT_WR : SHUT_RDWR); 269 (MHD_YES == connection->read_closed) ? SHUT_WR : SHUT_RDWR);
270 connection->state = MHD_CONNECTION_CLOSED; 270 connection->state = MHD_CONNECTION_CLOSED;
271 connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP; 271 connection->event_loop_info = MHD_EVENT_LOOP_INFO_CLEANUP;
@@ -625,7 +625,7 @@ add_extra_headers (struct MHD_Connection *connection)
625 Note that the change from 'SHOULD NOT' to 'MUST NOT' is 625 Note that the change from 'SHOULD NOT' to 'MUST NOT' is
626 a recent development of the HTTP 1.1 specification. 626 a recent development of the HTTP 1.1 specification.
627 */ 627 */
628 SPRINTF (buf, 628 sprintf (buf,
629 MHD_UNSIGNED_LONG_LONG_PRINTF, 629 MHD_UNSIGNED_LONG_LONG_PRINTF,
630 (MHD_UNSIGNED_LONG_LONG) connection->response->total_size); 630 (MHD_UNSIGNED_LONG_LONG) connection->response->total_size);
631 MHD_add_response_header (connection->response, 631 MHD_add_response_header (connection->response,
@@ -769,7 +769,7 @@ build_header_response (struct MHD_Connection *connection)
769 add_extra_headers (connection); 769 add_extra_headers (connection);
770 rc = connection->responseCode & (~MHD_ICY_FLAG); 770 rc = connection->responseCode & (~MHD_ICY_FLAG);
771 reason_phrase = MHD_get_reason_phrase_for (rc); 771 reason_phrase = MHD_get_reason_phrase_for (rc);
772 SPRINTF (code, 772 sprintf (code,
773 "%s %u %s\r\n", 773 "%s %u %s\r\n",
774 (0 != (connection->responseCode & MHD_ICY_FLAG)) 774 (0 != (connection->responseCode & MHD_ICY_FLAG))
775 ? "ICY" 775 ? "ICY"
@@ -835,7 +835,7 @@ build_header_response (struct MHD_Connection *connection)
835 } 835 }
836 for (pos = connection->response->first_header; NULL != pos; pos = pos->next) 836 for (pos = connection->response->first_header; NULL != pos; pos = pos->next)
837 if (pos->kind == kind) 837 if (pos->kind == kind)
838 off += SPRINTF (&data[off], 838 off += sprintf (&data[off],
839 "%s: %s\r\n", 839 "%s: %s\r\n",
840 pos->header, 840 pos->header,
841 pos->value); 841 pos->value);
@@ -1675,7 +1675,7 @@ do_write (struct MHD_Connection *connection)
1675 return MHD_YES; 1675 return MHD_YES;
1676 } 1676 }
1677#if DEBUG_SEND_DATA 1677#if DEBUG_SEND_DATA
1678 FPRINTF (stderr, 1678 fprintf (stderr,
1679 "Sent response: `%.*s'\n", 1679 "Sent response: `%.*s'\n",
1680 ret, 1680 ret,
1681 &connection->write_buffer[connection->write_buffer_send_offset]); 1681 &connection->write_buffer[connection->write_buffer_send_offset]);
@@ -2056,7 +2056,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
2056 return MHD_YES; 2056 return MHD_YES;
2057 } 2057 }
2058#if DEBUG_SEND_DATA 2058#if DEBUG_SEND_DATA
2059 FPRINTF (stderr, 2059 fprintf (stderr,
2060 "Sent 100 continue response: `%.*s'\n", 2060 "Sent 100 continue response: `%.*s'\n",
2061 (int) ret, 2061 (int) ret,
2062 &HTTP_100_CONTINUE[connection->continue_message_write_offset]); 2062 &HTTP_100_CONTINUE[connection->continue_message_write_offset]);
@@ -2094,7 +2094,7 @@ MHD_connection_handle_write (struct MHD_Connection *connection)
2094 const int err = MHD_socket_errno_; 2094 const int err = MHD_socket_errno_;
2095#if DEBUG_SEND_DATA 2095#if DEBUG_SEND_DATA
2096 if (ret > 0) 2096 if (ret > 0)
2097 FPRINTF (stderr, 2097 fprintf (stderr,
2098 "Sent DATA response: `%.*s'\n", 2098 "Sent DATA response: `%.*s'\n",
2099 (int) ret, 2099 (int) ret,
2100 &response->data[connection->response_write_position - 2100 &response->data[connection->response_write_position -
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index 2bbb7b2a..fae617a1 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -302,7 +302,7 @@ MHD_ip_limit_add (struct MHD_Daemon *daemon,
302 MHD_ip_count_lock (daemon); 302 MHD_ip_count_lock (daemon);
303 303
304 /* Search for the IP address */ 304 /* Search for the IP address */
305 if (NULL == (nodep = TSEARCH (key, 305 if (NULL == (nodep = tsearch (key,
306 &daemon->per_ip_connection_count, 306 &daemon->per_ip_connection_count,
307 &MHD_ip_addr_compare))) 307 &MHD_ip_addr_compare)))
308 { 308 {
@@ -358,7 +358,7 @@ MHD_ip_limit_del (struct MHD_Daemon *daemon,
358 MHD_ip_count_lock (daemon); 358 MHD_ip_count_lock (daemon);
359 359
360 /* Search for the IP address */ 360 /* Search for the IP address */
361 if (NULL == (nodep = TFIND (&search_key, 361 if (NULL == (nodep = tfind (&search_key,
362 &daemon->per_ip_connection_count, 362 &daemon->per_ip_connection_count,
363 &MHD_ip_addr_compare))) 363 &MHD_ip_addr_compare)))
364 { 364 {
@@ -375,7 +375,7 @@ MHD_ip_limit_del (struct MHD_Daemon *daemon,
375 /* Remove the node entirely if count reduces to 0 */ 375 /* Remove the node entirely if count reduces to 0 */
376 if (0 == --found_key->count) 376 if (0 == --found_key->count)
377 { 377 {
378 TDELETE (found_key, 378 tdelete (found_key,
379 &daemon->per_ip_connection_count, 379 &daemon->per_ip_connection_count,
380 &MHD_ip_addr_compare); 380 &MHD_ip_addr_compare);
381 free (found_key); 381 free (found_key);
@@ -850,7 +850,7 @@ recv_param_adapter (struct MHD_Connection *connection,
850 MHD_set_socket_errno_ (ENOTCONN); 850 MHD_set_socket_errno_ (ENOTCONN);
851 return -1; 851 return -1;
852 } 852 }
853 ret = RECV (connection->socket_fd, other, i, MSG_NOSIGNAL); 853 ret = recv (connection->socket_fd, other, i, MSG_NOSIGNAL);
854#if EPOLL_SUPPORT 854#if EPOLL_SUPPORT
855 if (ret < (ssize_t) i) 855 if (ret < (ssize_t) i)
856 { 856 {
@@ -889,7 +889,7 @@ send_param_adapter (struct MHD_Connection *connection,
889 return -1; 889 return -1;
890 } 890 }
891 if (0 != (connection->daemon->options & MHD_USE_SSL)) 891 if (0 != (connection->daemon->options & MHD_USE_SSL))
892 return SEND (connection->socket_fd, other, i, MSG_NOSIGNAL); 892 return send (connection->socket_fd, other, i, MSG_NOSIGNAL);
893#if LINUX 893#if LINUX
894 if ( (connection->write_buffer_append_offset == 894 if ( (connection->write_buffer_append_offset ==
895 connection->write_buffer_send_offset) && 895 connection->write_buffer_send_offset) &&
@@ -926,7 +926,7 @@ send_param_adapter (struct MHD_Connection *connection,
926 http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html */ 926 http://lists.gnu.org/archive/html/libmicrohttpd/2011-02/msg00015.html */
927 } 927 }
928#endif 928#endif
929 ret = SEND (connection->socket_fd, other, i, MSG_NOSIGNAL); 929 ret = send (connection->socket_fd, other, i, MSG_NOSIGNAL);
930#if EPOLL_SUPPORT 930#if EPOLL_SUPPORT
931 if (ret < (ssize_t) i) 931 if (ret < (ssize_t) i)
932 { 932 {
@@ -1707,7 +1707,7 @@ MHD_accept_connection (struct MHD_Daemon *daemon)
1707#if HAVE_ACCEPT4 1707#if HAVE_ACCEPT4
1708 s = accept4 (fd, addr, &addrlen, SOCK_CLOEXEC | nonblock); 1708 s = accept4 (fd, addr, &addrlen, SOCK_CLOEXEC | nonblock);
1709#else 1709#else
1710 s = ACCEPT (fd, addr, &addrlen); 1710 s = accept (fd, addr, &addrlen);
1711#endif 1711#endif
1712 if ((MHD_INVALID_SOCKET == s) || (addrlen <= 0)) 1712 if ((MHD_INVALID_SOCKET == s) || (addrlen <= 0))
1713 { 1713 {
@@ -1814,7 +1814,7 @@ MHD_cleanup_connections (struct MHD_Daemon *daemon)
1814 if (MHD_INVALID_SOCKET != pos->socket_fd) 1814 if (MHD_INVALID_SOCKET != pos->socket_fd)
1815 { 1815 {
1816#ifdef WINDOWS 1816#ifdef WINDOWS
1817 SHUTDOWN (pos->socket_fd, SHUT_WR); 1817 shutdown (pos->socket_fd, SHUT_WR);
1818#endif 1818#endif
1819 if (0 != MHD_socket_close_ (pos->socket_fd)) 1819 if (0 != MHD_socket_close_ (pos->socket_fd))
1820 MHD_PANIC ("close failed\n"); 1820 MHD_PANIC ("close failed\n");
@@ -3082,11 +3082,11 @@ create_socket (struct MHD_Daemon *daemon,
3082 3082
3083 /* use SOCK_STREAM rather than ai_socktype: some getaddrinfo 3083 /* use SOCK_STREAM rather than ai_socktype: some getaddrinfo
3084 * implementations do not set ai_socktype, e.g. RHL6.2. */ 3084 * implementations do not set ai_socktype, e.g. RHL6.2. */
3085 fd = SOCKET (domain, ctype, protocol); 3085 fd = socket (domain, ctype, protocol);
3086 if ( (MHD_INVALID_SOCKET == fd) && (EINVAL == MHD_socket_errno_) && (0 != SOCK_CLOEXEC) ) 3086 if ( (MHD_INVALID_SOCKET == fd) && (EINVAL == MHD_socket_errno_) && (0 != SOCK_CLOEXEC) )
3087 { 3087 {
3088 ctype = type; 3088 ctype = type;
3089 fd = SOCKET(domain, type, protocol); 3089 fd = socket(domain, type, protocol);
3090 } 3090 }
3091 if (MHD_INVALID_SOCKET == fd) 3091 if (MHD_INVALID_SOCKET == fd)
3092 return MHD_INVALID_SOCKET; 3092 return MHD_INVALID_SOCKET;
@@ -3440,10 +3440,10 @@ MHD_start_daemon_va (unsigned int flags,
3440#endif 3440#endif
3441 goto free_and_fail; 3441 goto free_and_fail;
3442 } 3442 }
3443 if ( (0 > SETSOCKOPT (socket_fd, 3443 if ( (0 > setsockopt (socket_fd,
3444 SOL_SOCKET, 3444 SOL_SOCKET,
3445 SO_REUSEADDR, 3445 SO_REUSEADDR,
3446 &on, sizeof (on))) && 3446 (void*)&on, sizeof (on))) &&
3447 (0 != (flags & MHD_USE_DEBUG)) ) 3447 (0 != (flags & MHD_USE_DEBUG)) )
3448 { 3448 {
3449#if HAVE_MESSAGES 3449#if HAVE_MESSAGES
@@ -3501,7 +3501,7 @@ MHD_start_daemon_va (unsigned int flags,
3501 const char 3501 const char
3502#endif 3502#endif
3503 on = (MHD_USE_DUAL_STACK != (flags & MHD_USE_DUAL_STACK)); 3503 on = (MHD_USE_DUAL_STACK != (flags & MHD_USE_DUAL_STACK));
3504 if ( (0 > SETSOCKOPT (socket_fd, 3504 if ( (0 > setsockopt (socket_fd,
3505 IPPROTO_IPV6, IPV6_V6ONLY, 3505 IPPROTO_IPV6, IPV6_V6ONLY,
3506 &on, sizeof (on))) && 3506 &on, sizeof (on))) &&
3507 (0 != (flags & MHD_USE_DEBUG)) ) 3507 (0 != (flags & MHD_USE_DEBUG)) )
@@ -3515,7 +3515,7 @@ MHD_start_daemon_va (unsigned int flags,
3515#endif 3515#endif
3516#endif 3516#endif
3517 } 3517 }
3518 if (-1 == BIND (socket_fd, servaddr, addrlen)) 3518 if (-1 == bind (socket_fd, servaddr, addrlen))
3519 { 3519 {
3520#if HAVE_MESSAGES 3520#if HAVE_MESSAGES
3521 if (0 != (flags & MHD_USE_DEBUG)) 3521 if (0 != (flags & MHD_USE_DEBUG))
@@ -3545,7 +3545,7 @@ MHD_start_daemon_va (unsigned int flags,
3545 } 3545 }
3546 } 3546 }
3547#endif 3547#endif
3548 if (LISTEN (socket_fd, 32) < 0) 3548 if (listen (socket_fd, 32) < 0)
3549 { 3549 {
3550#if HAVE_MESSAGES 3550#if HAVE_MESSAGES
3551 if (0 != (flags & MHD_USE_DEBUG)) 3551 if (0 != (flags & MHD_USE_DEBUG))
@@ -3860,7 +3860,7 @@ close_all_connections (struct MHD_Daemon *daemon)
3860 (0 != pthread_mutex_lock (&daemon->cleanup_connection_mutex)) ) 3860 (0 != pthread_mutex_lock (&daemon->cleanup_connection_mutex)) )
3861 MHD_PANIC ("Failed to acquire cleanup mutex\n"); 3861 MHD_PANIC ("Failed to acquire cleanup mutex\n");
3862 for (pos = daemon->connections_head; NULL != pos; pos = pos->nextX) 3862 for (pos = daemon->connections_head; NULL != pos; pos = pos->nextX)
3863 SHUTDOWN (pos->socket_fd, 3863 shutdown (pos->socket_fd,
3864 (pos->read_closed == MHD_YES) ? SHUT_WR : SHUT_RDWR); 3864 (pos->read_closed == MHD_YES) ? SHUT_WR : SHUT_RDWR);
3865 if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) && 3865 if ( (0 != (daemon->options & MHD_USE_THREAD_PER_CONNECTION)) &&
3866 (0 != pthread_mutex_unlock (&daemon->cleanup_connection_mutex)) ) 3866 (0 != pthread_mutex_unlock (&daemon->cleanup_connection_mutex)) )
@@ -3956,7 +3956,7 @@ MHD_stop_daemon (struct MHD_Daemon *daemon)
3956 { 3956 {
3957 /* fd might be MHD_INVALID_SOCKET here due to 'MHD_quiesce_daemon' */ 3957 /* fd might be MHD_INVALID_SOCKET here due to 'MHD_quiesce_daemon' */
3958 if (MHD_INVALID_SOCKET != fd) 3958 if (MHD_INVALID_SOCKET != fd)
3959 (void) SHUTDOWN (fd, SHUT_RDWR); 3959 (void) shutdown (fd, SHUT_RDWR);
3960 } 3960 }
3961#endif 3961#endif
3962#if EPOLL_SUPPORT 3962#if EPOLL_SUPPORT
diff --git a/src/testcurl/perf_get.c b/src/testcurl/perf_get.c
index d400a371..835db66e 100644
--- a/src/testcurl/perf_get.c
+++ b/src/testcurl/perf_get.c
@@ -82,7 +82,7 @@ now ()
82{ 82{
83 struct timeval tv; 83 struct timeval tv;
84 84
85 GETTIMEOFDAY (&tv, NULL); 85 gettimeofday (&tv, NULL);
86 return (((unsigned long long) tv.tv_sec * 1000LL) + 86 return (((unsigned long long) tv.tv_sec * 1000LL) +
87 ((unsigned long long) tv.tv_usec / 1000LL)); 87 ((unsigned long long) tv.tv_usec / 1000LL));
88} 88}
diff --git a/src/testcurl/perf_get_concurrent.c b/src/testcurl/perf_get_concurrent.c
index 333763b4..cec87a99 100644
--- a/src/testcurl/perf_get_concurrent.c
+++ b/src/testcurl/perf_get_concurrent.c
@@ -78,7 +78,7 @@ now ()
78{ 78{
79 struct timeval tv; 79 struct timeval tv;
80 80
81 GETTIMEOFDAY (&tv, NULL); 81 gettimeofday (&tv, NULL);
82 return (((unsigned long long) tv.tv_sec * 1000LL) + 82 return (((unsigned long long) tv.tv_sec * 1000LL) +
83 ((unsigned long long) tv.tv_usec / 1000LL)); 83 ((unsigned long long) tv.tv_usec / 1000LL));
84} 84}
diff --git a/src/testcurl/test_get.c b/src/testcurl/test_get.c
index 6043fe3c..95050855 100644
--- a/src/testcurl/test_get.c
+++ b/src/testcurl/test_get.c
@@ -461,10 +461,10 @@ testStopRace (int poll_flag)
461 if (d == NULL) 461 if (d == NULL)
462 return 16; 462 return 16;
463 463
464 fd = SOCKET (PF_INET, SOCK_STREAM, 0); 464 fd = socket (PF_INET, SOCK_STREAM, 0);
465 if (fd < 0) 465 if (fd == MHD_INVALID_SOCKET)
466 { 466 {
467 fprintf(stderr, "socket: %m\n"); 467 fprintf(stderr, "socket error\n");
468 return 256; 468 return 256;
469 } 469 }
470 470
@@ -473,9 +473,9 @@ testStopRace (int poll_flag)
473 sin.sin_port = htons(1081); 473 sin.sin_port = htons(1081);
474 sin.sin_addr.s_addr = htonl(0x7f000001); 474 sin.sin_addr.s_addr = htonl(0x7f000001);
475 475
476 if (CONNECT (fd, (struct sockaddr *)(&sin), sizeof(sin)) < 0) 476 if (connect (fd, (struct sockaddr *)(&sin), sizeof(sin)) < 0)
477 { 477 {
478 fprintf(stderr, "connect: %m\n"); 478 fprintf(stderr, "connect error\n");
479 MHD_socket_close_ (fd); 479 MHD_socket_close_ (fd);
480 return 512; 480 return 512;
481 } 481 }
diff --git a/src/testcurl/test_get_sendfile.c b/src/testcurl/test_get_sendfile.c
index f78b6d4e..5fdc9b4c 100644
--- a/src/testcurl/test_get_sendfile.c
+++ b/src/testcurl/test_get_sendfile.c
@@ -486,7 +486,7 @@ main (int argc, char *const *argv)
486 if (errorCount != 0) 486 if (errorCount != 0)
487 fprintf (stderr, "Error (code: %u)\n", errorCount); 487 fprintf (stderr, "Error (code: %u)\n", errorCount);
488 curl_global_cleanup (); 488 curl_global_cleanup ();
489 UNLINK (sourcefile); 489 unlink (sourcefile);
490 free (sourcefile); 490 free (sourcefile);
491 return errorCount != 0; /* 0 == pass */ 491 return errorCount != 0; /* 0 == pass */
492} 492}
diff --git a/src/testcurl/test_post_loop.c b/src/testcurl/test_post_loop.c
index 4fce55be..c9a1283e 100644
--- a/src/testcurl/test_post_loop.c
+++ b/src/testcurl/test_post_loop.c
@@ -462,7 +462,7 @@ now ()
462{ 462{
463 struct timeval tv; 463 struct timeval tv;
464 464
465 GETTIMEOFDAY (&tv, NULL); 465 gettimeofday (&tv, NULL);
466 return (((unsigned long long) tv.tv_sec * 1000LL) + 466 return (((unsigned long long) tv.tv_sec * 1000LL) +
467 ((unsigned long long) tv.tv_usec / 1000LL)); 467 ((unsigned long long) tv.tv_usec / 1000LL));
468} 468}