diff --git a/src/common/remoteio.c b/src/common/remoteio.c --- a/src/common/remoteio.c +++ b/src/common/remoteio.c @@ -23,15 +23,22 @@ #include "asprintf.h" #include +#ifndef _WIN32 #include +#endif #include #include #include #include +#ifdef _WIN32 +#include +#include +#else #include +#endif #include -#ifndef WINDOWS +#ifndef _WIN32 #include #endif @@ -44,7 +51,7 @@ int _remoteio_ssh_read(struct remoteio * int _remoteio_ssh_write(struct remoteio *rem, void *buf, size_t len, size_t *byteswritten); int _remoteio_ssh_close(struct remoteio *rem); -#ifndef WINDOWS +#ifndef _WIN32 int _remoteio_sock_open(struct remoteio *rem, struct remoteio_server *server); int _remoteio_sock_close(struct remoteio *rem); #endif @@ -64,7 +71,7 @@ struct remoteio_method_funcmap funcmap[] { /* [REMOTEIO_METHOD_SSH] */ {REMOTEIO_METHOD_SSH, &_remoteio_ssh_open, &_remoteio_ssh_read, &_remoteio_ssh_write, &_remoteio_ssh_close, "ssh"}, -#ifndef WINDOWS +#ifndef _WIN32 {REMOTEIO_METHOD_UNIX, &_remoteio_sock_open, &_remoteio_sock_read, &_remoteio_sock_write, &_remoteio_sock_close, "unix"}, #endif {REMOTEIO_METHOD_TCP, &_remoteio_tcp_open, &_remoteio_sock_read, &_remoteio_sock_write, &_remoteio_tcp_close, "tcp"}, @@ -277,7 +284,7 @@ int _remoteio_ssh_close(struct remoteio return rtn; } -#ifndef WINDOWS +#ifndef _WIN32 /* local sockets implementation (``named pipes''), unix-only */ @@ -285,6 +292,7 @@ int _remoteio_sock_open(struct remoteio { int sock; struct sockaddr_un sockaddr; + /* The POSIX docs pretty much say that I can't depend on sockpath being able to be longer than some proprietary length. So, if the compiler specifies a long path for RUNSTATEDIR, it could @@ -436,7 +444,12 @@ int _remoteio_tcp_open(struct remoteio * memset(&addrinfo_hints, '\0', sizeof(struct addrinfo)); addrinfo_hints.ai_family = AF_UNSPEC; +#ifdef _WIN32 + /* windows lacks stuff documented in POSIX, I guess :-( */ + addrinfo_hints.ai_flags = 0; +#else addrinfo_hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG; +#endif addrinfo_hints.ai_socktype = SOCK_STREAM; tmp = getaddrinfo(server->hostname, port, &addrinfo_hints, &addrinfo_res);