1262639Sdelphij/****************************************************************************
2262639Sdelphij * Copyright (c) 2011 Free Software Foundation, Inc.                        *
3262639Sdelphij *                                                                          *
4262639Sdelphij * Permission is hereby granted, free of charge, to any person obtaining a  *
5262639Sdelphij * copy of this software and associated documentation files (the            *
6262639Sdelphij * "Software"), to deal in the Software without restriction, including      *
7262639Sdelphij * without limitation the rights to use, copy, modify, merge, publish,      *
8262639Sdelphij * distribute, distribute with modifications, sublicense, and/or sell       *
9262639Sdelphij * copies of the Software, and to permit persons to whom the Software is    *
10262639Sdelphij * furnished to do so, subject to the following conditions:                 *
11262639Sdelphij *                                                                          *
12262639Sdelphij * The above copyright notice and this permission notice shall be included  *
13262639Sdelphij * in all copies or substantial portions of the Software.                   *
14262639Sdelphij *                                                                          *
15262639Sdelphij * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16262639Sdelphij * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17262639Sdelphij * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18262639Sdelphij * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19262639Sdelphij * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20262639Sdelphij * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21262639Sdelphij * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22262639Sdelphij *                                                                          *
23262639Sdelphij * Except as contained in this notice, the name(s) of the above copyright   *
24262639Sdelphij * holders shall not be used in advertising or otherwise to promote the     *
25262639Sdelphij * sale, use or other dealings in this Software without prior written       *
26262639Sdelphij * authorization.                                                           *
27262639Sdelphij ****************************************************************************/
28262639Sdelphij
29262639Sdelphij/****************************************************************************
30262639Sdelphij *  Author: Thomas E. Dickey                        2011                    *
31262639Sdelphij ****************************************************************************/
32262639Sdelphij
33262639Sdelphij/* $Id: nc_termios.h,v 1.2 2011/06/25 20:44:05 tom Exp $ */
34262639Sdelphij
35262639Sdelphij#ifndef NC_TERMIOS_included
36262639Sdelphij#define NC_TERMIOS_included 1
37262639Sdelphij
38262639Sdelphij#if HAVE_TERMIOS_H && HAVE_TCGETATTR
39262639Sdelphij
40262639Sdelphij#else /* !HAVE_TERMIOS_H */
41262639Sdelphij
42262639Sdelphij#if HAVE_TERMIO_H
43262639Sdelphij
44262639Sdelphij/* Add definitions to make termio look like termios.
45262639Sdelphij * But ifdef it, since there are some implementations
46262639Sdelphij * that try to do this for us in a fake <termio.h>.
47262639Sdelphij */
48262639Sdelphij#ifndef TCSADRAIN
49262639Sdelphij#define TCSADRAIN TCSETAW
50262639Sdelphij#endif
51262639Sdelphij#ifndef TCSAFLUSH
52262639Sdelphij#define TCSAFLUSH TCSETAF
53262639Sdelphij#endif
54262639Sdelphij#ifndef tcsetattr
55262639Sdelphij#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)
56262639Sdelphij#endif
57262639Sdelphij#ifndef tcgetattr
58262639Sdelphij#define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg)
59262639Sdelphij#endif
60262639Sdelphij#ifndef cfgetospeed
61262639Sdelphij#define cfgetospeed(t) ((t)->c_cflag & CBAUD)
62262639Sdelphij#endif
63262639Sdelphij#ifndef TCIFLUSH
64262639Sdelphij#define TCIFLUSH 0
65262639Sdelphij#endif
66262639Sdelphij#ifndef tcflush
67262639Sdelphij#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)
68262639Sdelphij#endif
69262639Sdelphij
70262639Sdelphij#else /* !HAVE_TERMIO_H */
71262639Sdelphij
72262639Sdelphij#if __MINGW32__
73262639Sdelphij
74262639Sdelphij/* c_cc chars */
75262639Sdelphij#define VINTR     0
76262639Sdelphij#define VQUIT     1
77262639Sdelphij#define VERASE    2
78262639Sdelphij#define VKILL     3
79262639Sdelphij#define VEOF      4
80262639Sdelphij#define VTIME     5
81262639Sdelphij#define VMIN      6
82262639Sdelphij
83262639Sdelphij/* c_iflag bits */
84262639Sdelphij#define ISTRIP	0000040
85262639Sdelphij#define INLCR	0000100
86262639Sdelphij#define IGNCR	0000200
87262639Sdelphij#define ICRNL	0000400
88262639Sdelphij#define BRKINT	0000002
89262639Sdelphij#define PARMRK	0000010
90262639Sdelphij#define IXON	0002000
91262639Sdelphij#define IGNBRK	0000001
92262639Sdelphij#define IGNPAR	0000004
93262639Sdelphij#define INPCK	0000020
94262639Sdelphij#define IXOFF	0010000
95262639Sdelphij
96262639Sdelphij/* c_oflag bits */
97262639Sdelphij#define OPOST	0000001
98262639Sdelphij
99262639Sdelphij/* c_cflag bit meaning */
100262639Sdelphij#define CBAUD	   0010017
101262639Sdelphij#define CSIZE	   0000060
102262639Sdelphij#define CS8	   0000060
103262639Sdelphij#define B0	   0000000
104262639Sdelphij#define B50	   0000001
105262639Sdelphij#define B75	   0000002
106262639Sdelphij#define B110	   0000003
107262639Sdelphij#define B134	   0000004
108262639Sdelphij#define B150	   0000005
109262639Sdelphij#define B200	   0000006
110262639Sdelphij#define B300	   0000007
111262639Sdelphij#define B600	   0000010
112262639Sdelphij#define B1200	   0000011
113262639Sdelphij#define B1800	   0000012
114262639Sdelphij#define B2400	   0000013
115262639Sdelphij#define B4800	   0000014
116262639Sdelphij#define B9600	   0000015
117262639Sdelphij#define CLOCAL	   0004000
118262639Sdelphij#define CREAD	   0000200
119262639Sdelphij#define CSTOPB	   0000100
120262639Sdelphij#define HUPCL	   0002000
121262639Sdelphij#define PARENB	   0000400
122262639Sdelphij#define PARODD	   0001000
123262639Sdelphij
124262639Sdelphij/* c_lflag bits */
125262639Sdelphij#define ECHO	0000010
126262639Sdelphij#define ECHONL	0000100
127262639Sdelphij#define ISIG	0000001
128262639Sdelphij#define IEXTEN	0100000
129262639Sdelphij#define ICANON	0000002
130262639Sdelphij#define NOFLSH	0000200
131262639Sdelphij#define ECHOE	0000020
132262639Sdelphij#define ECHOK	0000040
133262639Sdelphij
134262639Sdelphij/* tcflush() */
135262639Sdelphij#define	TCIFLUSH	0
136262639Sdelphij
137262639Sdelphij/* tcsetattr uses these */
138262639Sdelphij#define	TCSADRAIN	1
139262639Sdelphij
140262639Sdelphij/* ioctls */
141262639Sdelphij#define TCGETA		0x5405
142262639Sdelphij#define TCFLSH		0x540B
143262639Sdelphij#define TIOCGWINSZ	0x5413
144262639Sdelphij
145262639Sdelphij#ifndef cfgetospeed
146262639Sdelphij#define cfgetospeed(t) ((t)->c_cflag & CBAUD)
147262639Sdelphij#endif
148262639Sdelphij
149262639Sdelphij#ifndef tcsetattr
150262639Sdelphij#define tcsetattr(fd, cmd, arg) _nc_mingw_ioctl(fd, cmd, arg)
151262639Sdelphij#endif
152262639Sdelphij
153262639Sdelphij#ifndef tcgetattr
154262639Sdelphij#define tcgetattr(fd, arg) _nc_mingw_ioctl(fd, TCGETA, arg)
155262639Sdelphij#endif
156262639Sdelphij
157262639Sdelphij#ifndef tcflush
158262639Sdelphij#define tcflush(fd, arg) _nc_mingw_ioctl(fd, TCFLSH, arg)
159262639Sdelphij#endif
160262639Sdelphij
161262639Sdelphij#undef  ttyname
162262639Sdelphij#define ttyname(fd) NULL
163262639Sdelphij
164262639Sdelphij#else
165262639Sdelphij
166262639Sdelphij#endif /* __MINGW32__ */
167262639Sdelphij#endif /* HAVE_TERMIO_H */
168262639Sdelphij
169262639Sdelphij#endif /* HAVE_TERMIOS_H */
170262639Sdelphij
171262639Sdelphij#endif /* NC_TERMIOS_included */
172