AC_DEFINE([WINDOWS], 1, [Define if compiling for Windows API])
AC_DEFINE([WIN32_LEAN_AND_MEAN], 1,
[Define to make Windows includes pull in less junk])
+ AC_DEFINE([_WIN32_WINNT], 0x0601,
+ [Request Windows 7])
LIBS_SOCKETS="-lws2_32"
else
LIBS_SOCKETS=
#include <errno.h>
#include <sys/stat.h>
#include <stdio.h>
-#if !defined(_WIN32)
+#ifdef _WIN32
+#include <windows.h>
+#else
#include <strings.h>
#include <dirent.h>
#endif
#ifndef ARPA_INET_H
#define ARPA_INET_H
-#include "sys/socket.h"
-
-extern const char *inet_ntop(int af, const void *src, char *dst,
- socklen_t cnt);
+#include "ws2tcpip.h"
#endif /* ARPA_INET_H */
#include <config.h>
-#include <errno.h>
+#include <windows.h>
#include "sys/resource.h"
int
#ifndef SYS_TIME_H
#define SYS_TIME_H
+#ifdef _MSC_VER
+
/* include winsock2.h thru sys/socket.h to get struct timeval */
#include "sys/socket.h"
extern int gettimeofday(struct timeval *tv, void *tz);
+#else /* !_MSC_VER */
+#include_next <sys/time.h>
+#endif
+
#endif /* SYS_TIME_H */
* here. Major name space pollution, can't be helped.
*/
#include <direct.h>
-#include <getopt.h>
#include <io.h>
#include <process.h>
#include <sys/stat.h>
extern int w32_mkdir(const char *dirname, mode_t perm);
/* Should be in sys/stat.h */
+#ifdef _MSC_VER
#ifndef S_IRUSR
#define S_IRUSR _S_IREAD
#define S_IWUSR _S_IWRITE
#define S_IXOTH 0
#define S_IRWXO S_IROTH | S_IWOTH | S_IXOTH
#endif
+#endif
/* Should be in fcntl.h */
+/* HACK, for use with fcntl() on a socket only, see w32sockets.c */
#define O_NONBLOCK 1
-
#define F_GETFL 1
#define F_SETFL 2
-
extern int fcntl(int fd, int cmd, ...);
/* Stuff that actually belongs here */
#define close(fd) w32_close_function((fd))
extern int (*w32_close_function)(int);
-#define ftruncate(fd, length) _chsize((fd), (length))
#define read(fd, buf, sz) w32_read_function((fd), (buf), (sz))
extern int (*w32_read_function)(int, void *, unsigned);
#define write(fd, buf, sz) w32_write_function((fd), (buf), (sz))
extern int (*w32_write_function)(int, const void *, unsigned);
+#ifdef _MSC_VER
+#define ftruncate(fd, length) _chsize((fd), (length))
+#endif
+
+#ifndef _MSC_VER
+#include_next <unistd.h>
+#endif
#endif /* UNISTD_H */
*
* Known contributors to this file:
* Ron Koenderink, 2007
- * Markus Armbruster, 2007-2013
+ * Markus Armbruster, 2007-2021
*/
/*
#ifdef _MSC_VER
/* integral mismatch, due to misuse of sector short */
#pragma warning (disable : 4761 )
+#endif
/* strings.h */
+#ifdef _MSC_VER
#define strncasecmp(s1, s2, s3) _strnicmp((s1), (s2), (s3))
#endif /* _MSC_VER */
-/* errno.h */
-#ifndef EWOULDBLOCK
-#define EWOULDBLOCK EAGAIN
-#endif
-
/* fcntl.h */
#ifdef _MSC_VER
#define O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR)
return W32_SOCKET_TO_FD(sock);
}
-#ifdef HAVE_GETADDRINFO
-const char *
-inet_ntop(int af, const void *src, char *dst, socklen_t len)
-{
- struct sockaddr *sa;
- struct sockaddr_in sin;
- struct sockaddr_in6 sin6;
- size_t salen;
-
- if (af == AF_INET) {
- memset(&sin, 0, sizeof(sin));
- sin.sin_family = af;
- memcpy(&sin.sin_addr, src, sizeof(sin.sin_addr));
- sa = (struct sockaddr *)&sin;
- salen = sizeof(sin);
- } else if (af == AF_INET6) {
- memset(&sin6, 0, sizeof(sin6));
- sin6.sin6_family = af;
- memcpy(&sin6.sin6_addr, src, sizeof(sin6.sin6_addr));
- sa = (struct sockaddr *)&sin6;
- salen = sizeof(sin6);
- } else {
- WSASetLastError(WSAEAFNOSUPPORT);
- w32_set_winsock_errno();
- return NULL;
- }
-
- if (getnameinfo(sa, salen, dst, len, NULL, 0, NI_NUMERICHOST)) {
- WSASetLastError(WSAEAFNOSUPPORT);
- w32_set_winsock_errno();
- return NULL;
- }
-
- return dst;
-}
-#endif
-
/*
* POSIX equivalent for fcntl().
* Horrible hacks, just good enough support Empire's use of fcntl().