aboutsummaryrefslogtreecommitdiff
path: root/src/include/platform_interface.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/platform_interface.h')
-rw-r--r--src/include/platform_interface.h80
1 files changed, 1 insertions, 79 deletions
diff --git a/src/include/platform_interface.h b/src/include/platform_interface.h
index c2aee64b..fa84bcd5 100644
--- a/src/include/platform_interface.h
+++ b/src/include/platform_interface.h
@@ -27,6 +27,7 @@
27#define MHD_PLATFORM_INTERFACE_H 27#define MHD_PLATFORM_INTERFACE_H
28 28
29#include "platform.h" 29#include "platform.h"
30#include "../microhttpd/mhd_sockets.h"
30#if defined(_WIN32) && !defined(__CYGWIN__) 31#if defined(_WIN32) && !defined(__CYGWIN__)
31#include "w32functions.h" 32#include "w32functions.h"
32#endif 33#endif
@@ -46,85 +47,6 @@
46#endif /* ! _WIN32*/ 47#endif /* ! _WIN32*/
47#endif /* ! HAVE_SNPRINTF */ 48#endif /* ! HAVE_SNPRINTF */
48 49
49
50/**
51 * _MHD_socket_funcs_size is type used to specify size for send and recv
52 * functions
53 */
54#if !defined(MHD_WINSOCK_SOCKETS)
55typedef size_t _MHD_socket_funcs_size;
56#else
57typedef int _MHD_socket_funcs_size;
58#endif
59
60/**
61 * MHD_socket_close_(fd) close any FDs (non-W32) / close only socket
62 * FDs (W32). Note that on HP-UNIX, this function may leak the FD if
63 * errno is set to EINTR. Do not use HP-UNIX.
64 *
65 * @param fd descriptor to close
66 * @return 0 on success (error codes like EINTR and EIO are counted as success,
67 * only EBADF counts as an error!)
68 */
69#if !defined(MHD_WINSOCK_SOCKETS)
70#define MHD_socket_close_(fd) (((0 != close(fd)) && (EBADF == errno)) ? -1 : 0)
71#else
72#define MHD_socket_close_(fd) closesocket((fd))
73#endif
74
75/**
76 * MHD_socket_errno_ is errno of last function (non-W32) / errno of
77 * last socket function (W32)
78 */
79#if !defined(MHD_WINSOCK_SOCKETS)
80#define MHD_socket_errno_ errno
81#else
82#define MHD_socket_errno_ MHD_W32_errno_from_winsock_()
83#endif
84
85/* MHD_socket_last_strerr_ is description string of last errno (non-W32) /
86 * description string of last socket error (W32) */
87#if !defined(MHD_WINSOCK_SOCKETS)
88#define MHD_socket_last_strerr_() strerror(errno)
89#else
90#define MHD_socket_last_strerr_() MHD_W32_strerror_last_winsock_()
91#endif
92
93/* MHD_strerror_ is strerror (both non-W32/W32) */
94#if !defined(MHD_WINSOCK_SOCKETS)
95#define MHD_strerror_(errnum) strerror((errnum))
96#else
97#define MHD_strerror_(errnum) MHD_W32_strerror_((errnum))
98#endif
99
100/* MHD_set_socket_errno_ set errno to errnum (non-W32) / set socket last error to errnum (W32) */
101#if !defined(MHD_WINSOCK_SOCKETS)
102#define MHD_set_socket_errno_(errnum) errno=(errnum)
103#else
104#define MHD_set_socket_errno_(errnum) MHD_W32_set_last_winsock_error_((errnum))
105#endif
106
107/* MHD_SYS_select_ is wrapper macro for system select() function */
108#if !defined(MHD_WINSOCK_SOCKETS)
109#define MHD_SYS_select_(n,r,w,e,t) select((n),(r),(w),(e),(t))
110#else
111#define MHD_SYS_select_(n,r,w,e,t) \
112 ( (!(r) || ((fd_set*)(r))->fd_count == 0) && \
113 (!(w) || ((fd_set*)(w))->fd_count == 0) && \
114 (!(e) || ((fd_set*)(e))->fd_count == 0) ) ? \
115 ( (t) ? (Sleep((t)->tv_sec * 1000 + (t)->tv_usec / 1000), 0) : 0 ) : \
116 (select((int)0,(r),(w),(e),(t)))
117#endif
118
119#if defined(HAVE_POLL)
120/* MHD_sys_poll_ is wrapper macro for system poll() function */
121#if !defined(MHD_WINSOCK_SOCKETS)
122#define MHD_sys_poll_ poll
123#else /* MHD_WINSOCK_SOCKETS */
124#define MHD_sys_poll_ WSAPoll
125#endif /* MHD_WINSOCK_SOCKETS */
126#endif /* HAVE_POLL */
127
128/* MHD_pipe_ create pipe (!MHD_DONT_USE_PIPES) / 50/* MHD_pipe_ create pipe (!MHD_DONT_USE_PIPES) /
129 * create two connected sockets (MHD_DONT_USE_PIPES) */ 51 * create two connected sockets (MHD_DONT_USE_PIPES) */
130#ifndef MHD_DONT_USE_PIPES 52#ifndef MHD_DONT_USE_PIPES