Win32 build fix.
[qemu] / slirp / slirp.h
index 5b9cfde..1ff68cb 100644 (file)
 #include "config.h"
 #include "slirp_config.h"
 
+#ifdef _WIN32
+# include <inttypes.h>
+
+typedef uint8_t u_int8_t;
+typedef uint16_t u_int16_t;
+typedef uint32_t u_int32_t;
+typedef uint64_t u_int64_t;
+typedef char *caddr_t;
+
+# include <windows.h>
+# include <winsock2.h>
+# include <sys/timeb.h>
+# include <iphlpapi.h>
+
+# define EWOULDBLOCK WSAEWOULDBLOCK
+# define EINPROGRESS WSAEINPROGRESS
+# define ENOTCONN WSAENOTCONN
+# define EHOSTUNREACH WSAEHOSTUNREACH
+# define ENETUNREACH WSAENETUNREACH
+# define ECONNREFUSED WSAECONNREFUSED
+#else
+# define ioctlsocket ioctl
+# define closesocket(s) close(s)
+# define O_BINARY 0
+#endif
+
 #include <sys/types.h>
 #ifdef HAVE_SYS_BITYPES_H
 # include <sys/bitypes.h>
@@ -79,7 +105,9 @@ typedef unsigned char u_int8_t;
 # include <strings.h>
 #endif
 
+#ifndef _WIN32
 #include <sys/uio.h>
+#endif
 
 #ifndef _P
 #ifndef NO_PROTOTYPES
@@ -89,8 +117,10 @@ typedef unsigned char u_int8_t;
 #endif
 #endif
 
+#ifndef _WIN32
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#endif
 
 #ifdef GETTIMEOFDAY_ONE_ARG
 #define gettimeofday(x, y) gettimeofday(x)
@@ -119,27 +149,14 @@ int inet_aton _P((const char *cp, struct in_addr *ia));
 #ifdef HAVE_SYS_SIGNAL_H
 # include <sys/signal.h>
 #endif
+#ifndef _WIN32
 #include <sys/socket.h>
-
-#if defined(WANT_SYS_IOCTL_H) && defined(HAVE_SYS_IOCTL_H)
-# include <sys/ioctl.h>
-#else
-# define WANT_SYS_TERMIOS_H
 #endif
 
-#ifdef WANT_SYS_TERMIOS_H
-# ifndef INCLUDED_TERMIOS_H
-#  ifdef HAVE_TERMIOS_H
-#   include <termios.h>
-#  else
-#   include <termio.h>
-#  endif
-#  define INCLUDED_TERMIOS_H
-# endif
+#if defined(HAVE_SYS_IOCTL_H)
+# include <sys/ioctl.h>
 #endif
 
-
-
 #ifdef HAVE_SYS_SELECT_H
 # include <sys/select.h>
 #endif
@@ -195,6 +212,7 @@ int inet_aton _P((const char *cp, struct in_addr *ia));
 #endif
 
 #include "bootp.h"
+#include "tftp.h"
 #include "libslirp.h"
 
 extern struct ttys *ttys_unit[MAX_INTERFACES];
@@ -247,8 +265,9 @@ extern int do_echo;
  inline void remque_32 _P((void *));
 #endif
 
-#include <pwd.h>
+#ifndef _WIN32
 #include <netdb.h>
+#endif
 
 #define DEFAULT_BAUD 115200
 
@@ -307,4 +326,14 @@ struct tcpcb *tcp_drop(struct tcpcb *tp, int err);
 #define MAX_MRU 16384
 #endif
 
+#ifndef _WIN32
+#define min(x,y) ((x) < (y) ? (x) : (y))
+#define max(x,y) ((x) > (y) ? (x) : (y))
+#endif
+
+#ifdef _WIN32
+#undef errno
+#define errno (WSAGetLastError())
+#endif
+
 #endif