diff options
Diffstat (limited to 'include/compat/win32netcompat.h')
-rw-r--r-- | include/compat/win32netcompat.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/compat/win32netcompat.h b/include/compat/win32netcompat.h new file mode 100644 index 0000000..452cfba --- /dev/null +++ b/include/compat/win32netcompat.h | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * Public domain | ||
3 | * | ||
4 | * BSD socket emulation code for Winsock2 | ||
5 | * Brent Cook <bcook@openbsd.org> | ||
6 | */ | ||
7 | |||
8 | #ifndef LIBCRYPTOCOMPAT_WIN32NETCOMPAT_H | ||
9 | #define LIBCRYPTOCOMPAT_WIN32NETCOMPAT_H | ||
10 | |||
11 | #ifdef _WIN32 | ||
12 | |||
13 | #include <ws2tcpip.h> | ||
14 | |||
15 | #define SHUT_RDWR SD_BOTH | ||
16 | #define SHUT_RD SD_RECEIVE | ||
17 | #define SHUT_WR SD_SEND | ||
18 | |||
19 | #include <errno.h> | ||
20 | #include <unistd.h> | ||
21 | |||
22 | int posix_connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); | ||
23 | |||
24 | int posix_close(int fd); | ||
25 | ssize_t posix_read(int fd, void *buf, size_t count); | ||
26 | |||
27 | ssize_t posix_write(int fd, const void *buf, size_t count); | ||
28 | |||
29 | int posix_getsockopt(int sockfd, int level, int optname, | ||
30 | void *optval, socklen_t *optlen); | ||
31 | |||
32 | int posix_setsockopt(int sockfd, int level, int optname, | ||
33 | const void *optval, socklen_t optlen); | ||
34 | |||
35 | #ifndef NO_REDEF_POSIX_FUNCTIONS | ||
36 | #define connect(sockfd, addr, addrlen) posix_connect(sockfd, addr, addrlen) | ||
37 | #define close(fd) posix_close(fd) | ||
38 | #define read(fd, buf, count) posix_read(fd, buf, count) | ||
39 | #define write(fd, buf, count) posix_write(fd, buf, count) | ||
40 | #define getsockopt(sockfd, level, optname, optval, optlen) \ | ||
41 | posix_getsockopt(sockfd, level, optname, optval, optlen) | ||
42 | #define setsockopt(sockfd, level, optname, optval, optlen) \ | ||
43 | posix_setsockopt(sockfd, level, optname, optval, optlen) | ||
44 | #endif | ||
45 | |||
46 | #endif | ||
47 | |||
48 | #endif | ||