]> git.meshlink.io Git - catta/commitdiff
add ioctl as a wrapper around ioctlsocket
authorSven M. Hallberg <pesco@khjk.org>
Fri, 29 Aug 2014 16:51:12 +0000 (18:51 +0200)
committerSven M. Hallberg <pesco@khjk.org>
Fri, 29 Aug 2014 16:51:12 +0000 (18:51 +0200)
src/compat/windows/wincompat.c
src/compat/windows/wincompat.h

index 1a05d9f58551a91589472cf95d65211c46db5dca..67cf85364b9047097d82ec6434128c8c31871ecb 100644 (file)
@@ -190,6 +190,24 @@ ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags)
     return bytessent;
 }
 
     return bytessent;
 }
 
+int ioctl(int d, unsigned long request, int *p)
+{
+    u_long arg = 0;
+
+    if(ioctlsocket(d, request, &arg) == SOCKET_ERROR) {
+        errno = wsa_errno();
+        return -1;
+    }
+
+    if(arg > INT_MAX) {
+        errno = EINVAL;
+        return -1;
+    }
+
+    *p = arg;
+    return 0;
+}
+
 int uname(struct utsname *buf)
 {
     SYSTEM_INFO si;
 int uname(struct utsname *buf)
 {
     SYSTEM_INFO si;
index f76dbc4835a1012160d863060f2928dda145ce82..b5020226a8e5465ea406bc56105e3d61a7fdd0c9 100644 (file)
@@ -77,6 +77,12 @@ ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
 #endif
 
 
 #endif
 
 
+// Windows doesn't have ioctl but offers ioctlsocket for some socket-related
+// functions. Unfortunately, argument types differ, so we implement a
+// (restricted) wrapper.
+int ioctl(int d, unsigned long request, int *p);
+
+
 // Windows logically doesn't have uname, so we supply a replacement.
 
 struct utsname {
 // Windows logically doesn't have uname, so we supply a replacement.
 
 struct utsname {