]> sourceware.org Git - newlib-cygwin.git/blame - winsup/cygwin/ioctl.cc
Remove unneeded header files from source files throughout.
[newlib-cygwin.git] / winsup / cygwin / ioctl.cc
CommitLineData
1fd5e000
CF
1/* ioctl.cc: ioctl routines.
2
c0ac34fd 3 Copyright 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2006 Red Hat, Inc.
1fd5e000
CF
4
5 Written by Doug Evans of Cygnus Support
6 dje@cygnus.com
7
8This file is part of Cygwin.
9
10This software is a copyrighted work licensed under the terms of the
11Cygwin license. Please consult the file "CYGWIN_LICENSE" for
12details. */
13
4c8d72de 14#include "winsup.h"
9e2baf8d 15#include "cygerrno.h"
6b91b8d5 16#include "security.h"
47063f00 17#include "path.h"
7ac61736 18#include "fhandler.h"
bccd5e0d 19#include "dtable.h"
0381fec6 20#include "cygheap.h"
1fd5e000 21
bccd5e0d 22extern "C" int
d6154fb7 23ioctl (int fd, int cmd, ...)
1fd5e000 24{
0a642325 25
df63bd49
CF
26 cygheap_fdget cfd (fd);
27 if (cfd < 0)
28 return -1;
1fd5e000 29
d6154fb7
CV
30 /* check for optional mode argument */
31 va_list ap;
32 va_start (ap, cmd);
33 char *argp = va_arg (ap, char *);
34 va_end (ap);
35
f70389b5 36 debug_printf ("fd %d, cmd %x", fd, cmd);
a2dea5c3 37 int res;
c0ac34fd
CF
38 /* FIXME: This stinks. There are collisions between cmd types
39 depending on whether fd is associated with a pty master or not.
40 Something to fix for Cygwin2. CGF 2006-06-04 */
41 if (cfd->is_tty () && cfd->get_major () != DEV_TTYM_MAJOR)
1fd5e000
CF
42 switch (cmd)
43 {
44 case TCGETA:
a2dea5c3
CF
45 res = tcgetattr (fd, (struct termios *) argp);
46 goto out;
1fd5e000 47 case TCSETA:
a2dea5c3
CF
48 res = tcsetattr (fd, TCSANOW, (struct termios *) argp);
49 goto out;
1fd5e000 50 case TCSETAW:
a2dea5c3
CF
51 res = tcsetattr (fd, TCSADRAIN, (struct termios *) argp);
52 goto out;
1fd5e000 53 case TCSETAF:
a2dea5c3
CF
54 res = tcsetattr (fd, TCSAFLUSH, (struct termios *) argp);
55 goto out;
1fd5e000
CF
56 }
57
a2dea5c3
CF
58 res = cfd->ioctl (cmd, argp);
59
60out:
b6183403
CF
61 debug_printf ("returning %d", res);
62 return res;
1fd5e000 63}
This page took 0.291026 seconds and 5 git commands to generate.