This source file includes following definitions.
- rpl_ioctl
- primary_ioctl
- ioctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <config.h>
21
22 #include <sys/ioctl.h>
23
24 #include <stdarg.h>
25
26 #if HAVE_IOCTL
27
28
29 # undef ioctl
30 int
31 rpl_ioctl (int fd, int request, ... )
32 {
33 void *buf;
34 va_list args;
35
36 va_start (args, request);
37 buf = va_arg (args, void *);
38 va_end (args);
39
40
41
42 return ioctl (fd, (unsigned int) request, buf);
43 }
44
45 #else
46
47 # include <errno.h>
48
49
50 # define WIN32_LEAN_AND_MEAN
51 # include <windows.h>
52
53 # include "fd-hook.h"
54
55 # if GNULIB_MSVC_NOTHROW
56 # include "msvc-nothrow.h"
57 # else
58 # include <io.h>
59 # endif
60
61 static int
62 primary_ioctl (int fd, int request, void *arg)
63 {
64
65
66
67
68 if ((HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE)
69 errno = ENOSYS;
70 else
71 errno = EBADF;
72 return -1;
73 }
74
75 int
76 ioctl (int fd, int request, ... )
77 {
78 void *arg;
79 va_list args;
80
81 va_start (args, request);
82 arg = va_arg (args, void *);
83 va_end (args);
84
85 # if WINDOWS_SOCKETS
86 return execute_all_ioctl_hooks (primary_ioctl, fd, request, arg);
87 # else
88 return primary_ioctl (fd, request, arg);
89 # endif
90 }
91
92 #endif