changeset 30305:9d17cce91cb9

Make the ioctl() signature POSIX compliant.
author Bruno Haible <bruno@clisp.org>
date Fri, 10 Oct 2008 04:17:02 +0200
parents dde085ea438b
children b72336ea6096
files ChangeLog lib/sys_socket.in.h lib/winsock.c
diffstat 3 files changed, 20 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Oct 10 03:57:05 2008 +0200
+++ b/ChangeLog	Fri Oct 10 04:17:02 2008 +0200
@@ -1,3 +1,9 @@
+2008-10-09  Bruno Haible  <bruno@clisp.org>
+
+	* lib/sys_socket.in.h (ioctl): Make signature POSIX compliant.
+	* lib/winsock.c: Include <stdarg.h>.
+	(rpl_ioctl): Change to second argument 'int' and then varargs.
+
 2008-10-09  Bruno Haible  <bruno@clisp.org>
 
 	* m4/close.m4 (gl_FUNC_CLOSE): Arrange to replace the close() function when
--- a/lib/sys_socket.in.h	Fri Oct 10 03:57:05 2008 +0200
+++ b/lib/sys_socket.in.h	Fri Oct 10 04:17:02 2008 +0200
@@ -282,7 +282,7 @@
 # if @HAVE_WINSOCK2_H@
 #  undef ioctl
 #  define ioctl			rpl_ioctl
-extern int rpl_ioctl (int, unsigned long, char *);
+extern int rpl_ioctl (int, int, ...);
 # endif
 
 # if @GNULIB_RECV@
--- a/lib/winsock.c	Fri Oct 10 03:57:05 2008 +0200
+++ b/lib/winsock.c	Fri Oct 10 04:17:02 2008 +0200
@@ -18,6 +18,7 @@
 /* Written by Paolo Bonzini */
 
 #include <config.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
@@ -224,10 +225,19 @@
 #endif
 
 int
-rpl_ioctl (int fd, unsigned long req, char *buf)
+rpl_ioctl (int fd, int req, ...)
 {
-  SOCKET sock = FD_TO_SOCKET (fd);
-  int r = ioctlsocket (sock, req, (void *) buf);
+  void *buf;
+  va_list args;
+  SOCKET sock;
+  int r;
+
+  va_start (args, req);
+  buf = va_arg (args, void *);
+  va_end (args);
+
+  sock = FD_TO_SOCKET (fd);
+  r = ioctlsocket (sock, req, buf);
   if (r < 0)
     set_winsock_errno ();