]> git.meshlink.io Git - catta/blobdiff - src/compat/windows/wincompat.h
use WSAGetlastError/FormatMessage in place of strerror(errno) on Windows
[catta] / src / compat / windows / wincompat.h
index b5020226a8e5465ea406bc56105e3d61a7fdd0c9..8f62240c68be2e3cc9f9c57bfc1b98f283d503a2 100644 (file)
 #include <mswsock.h>
 
 
+// wrappers around WSAStartup/WSACleanup to avoid clutter
+void winsock_init(void);
+void winsock_exit(void);
+
+
+// the equivalent of strerror(errno) for Windows sockets
+char *errnostrsocket(void);
+
+
 // Winsock doesn't have recvmsg/sendmsg but offers the same functionality
 // with WSARecvMsg/WSASendMsg, so we implement the former in terms of the
 // latter.
@@ -83,6 +92,14 @@ ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
 int ioctl(int d, unsigned long request, int *p);
 
 
+// Windows lacks poll, but WSAPoll is good enough for us.
+#define poll(fds, nfds, timeout) WSAPoll(fds, nfds, timeout)
+
+// Windows lacks pipe. It has an equivalent CreatePipe but we really need
+// something to give to WSAPoll, so we fake it with a local TCP socket. (ugh)
+int pipe(int pipefd[2]);
+
+
 // Windows logically doesn't have uname, so we supply a replacement.
 
 struct utsname {