ioctl.c 1.3 KB
Newer Older
J
Jim Meyering 已提交
1 2
/* ioctl.c --- wrappers for Windows ioctl function

3
   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
4 5

   This program is free software: you can redistribute it and/or modify
6 7
   it under the terms of the GNU Lesser General Public License as published by
   the Free Software Foundation; either version 2.1 of the License, or
8 9 10 11 12
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
   GNU Lesser General Public License for more details.
14

15
   You should have received a copy of the GNU Lesser General Public License
16 17
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

J
Jim Meyering 已提交
18 19
/* Written by Paolo Bonzini */

20 21
#include <config.h>

22 23
#include <sys/ioctl.h>

J
Jim Meyering 已提交
24 25 26 27 28
#include <stdarg.h>

#define WIN32_LEAN_AND_MEAN
/* Get winsock2.h. */
#include <sys/socket.h>
29

J
Jim Meyering 已提交
30 31
/* Get set_winsock_errno, FD_TO_SOCKET etc. */
#include "w32sock.h"
32 33

int
J
Jim Meyering 已提交
34
rpl_ioctl (int fd, int req, ...)
35
{
J
Jim Meyering 已提交
36 37 38 39 40 41 42 43 44 45 46 47 48
  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 ();
49

J
Jim Meyering 已提交
50
  return r;
51
}