X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fcompat%2Fwindows%2Fwincompat.c;h=b60eb8f66ccd2f5e4574f2ca53edf60729ef0573;hb=6ce8abeff8a93a7defcad963737eafc1fc7856c2;hp=4e3145e6e672c73bee5d40d9af5bdaf4c6f4f86b;hpb=63561f9937d11b1371a2de2511b903035818b42f;p=catta diff --git a/src/compat/windows/wincompat.c b/src/compat/windows/wincompat.c index 4e3145e..b60eb8f 100644 --- a/src/compat/windows/wincompat.c +++ b/src/compat/windows/wincompat.c @@ -1,4 +1,4 @@ -#include "wincompat.h" +#include "catta/compat/wincompat.h" #include #include #include @@ -46,6 +46,16 @@ void winsock_exit(void) catta_log_warn("WSACleanup() failed: %d", WSAGetLastError()); } +char *errnostrsocket(void) +{ + static char buf[256]; + + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, WSAGetLastError(), 0, buf, sizeof(buf), NULL); + + return buf; +} + ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags) { LPFN_WSARECVMSG WSARecvMsg = NULL; @@ -209,7 +219,7 @@ ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags) int ioctl(int d, unsigned long request, int *p) { - u_long arg = 0; + u_long arg = *p; if(ioctlsocket(d, request, &arg) == SOCKET_ERROR) { errno = wsa_errno(); @@ -227,11 +237,11 @@ int ioctl(int d, unsigned long request, int *p) int pipe(int pipefd[2]) { - int lsock = INVALID_SOCKET; + int lsock = (int)INVALID_SOCKET; struct sockaddr_in laddr; socklen_t laddrlen = sizeof(laddr); - pipefd[0] = pipefd[1] = INVALID_SOCKET; + pipefd[0] = pipefd[1] = (int)INVALID_SOCKET; // bind a listening socket to a TCP port on localhost laddr.sin_family = AF_INET; @@ -284,7 +294,8 @@ int uname(struct utsname *buf) strncpy(buf->version, "unknown", sizeof(buf->sysname)-1); // we don't need it // computer (node) name - if(GetComputerName(buf->nodename, sizeof(buf->nodename)-1) == 0) { + DWORD nodename_size = sizeof(buf->nodename)-1; + if(GetComputerName(buf->nodename, &nodename_size) == 0) { errno = EFAULT; return -1; }