xref: /freebsd/contrib/ncurses/include/nc_termios.h (revision 13ea0450a9c8742119d36f3bf8f47accdce46e54)
1 /****************************************************************************
2  * Copyright (c) 2011 Free Software Foundation, Inc.                        *
3  *                                                                          *
4  * Permission is hereby granted, free of charge, to any person obtaining a  *
5  * copy of this software and associated documentation files (the            *
6  * "Software"), to deal in the Software without restriction, including      *
7  * without limitation the rights to use, copy, modify, merge, publish,      *
8  * distribute, distribute with modifications, sublicense, and/or sell       *
9  * copies of the Software, and to permit persons to whom the Software is    *
10  * furnished to do so, subject to the following conditions:                 *
11  *                                                                          *
12  * The above copyright notice and this permission notice shall be included  *
13  * in all copies or substantial portions of the Software.                   *
14  *                                                                          *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22  *                                                                          *
23  * Except as contained in this notice, the name(s) of the above copyright   *
24  * holders shall not be used in advertising or otherwise to promote the     *
25  * sale, use or other dealings in this Software without prior written       *
26  * authorization.                                                           *
27  ****************************************************************************/
28 
29 /****************************************************************************
30  *  Author: Thomas E. Dickey                        2011                    *
31  ****************************************************************************/
32 
33 /* $Id: nc_termios.h,v 1.2 2011/06/25 20:44:05 tom Exp $ */
34 
35 #ifndef NC_TERMIOS_included
36 #define NC_TERMIOS_included 1
37 
38 #if HAVE_TERMIOS_H && HAVE_TCGETATTR
39 
40 #else /* !HAVE_TERMIOS_H */
41 
42 #if HAVE_TERMIO_H
43 
44 /* Add definitions to make termio look like termios.
45  * But ifdef it, since there are some implementations
46  * that try to do this for us in a fake <termio.h>.
47  */
48 #ifndef TCSADRAIN
49 #define TCSADRAIN TCSETAW
50 #endif
51 #ifndef TCSAFLUSH
52 #define TCSAFLUSH TCSETAF
53 #endif
54 #ifndef tcsetattr
55 #define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)
56 #endif
57 #ifndef tcgetattr
58 #define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg)
59 #endif
60 #ifndef cfgetospeed
61 #define cfgetospeed(t) ((t)->c_cflag & CBAUD)
62 #endif
63 #ifndef TCIFLUSH
64 #define TCIFLUSH 0
65 #endif
66 #ifndef tcflush
67 #define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)
68 #endif
69 
70 #else /* !HAVE_TERMIO_H */
71 
72 #if __MINGW32__
73 
74 /* c_cc chars */
75 #define VINTR     0
76 #define VQUIT     1
77 #define VERASE    2
78 #define VKILL     3
79 #define VEOF      4
80 #define VTIME     5
81 #define VMIN      6
82 
83 /* c_iflag bits */
84 #define ISTRIP	0000040
85 #define INLCR	0000100
86 #define IGNCR	0000200
87 #define ICRNL	0000400
88 #define BRKINT	0000002
89 #define PARMRK	0000010
90 #define IXON	0002000
91 #define IGNBRK	0000001
92 #define IGNPAR	0000004
93 #define INPCK	0000020
94 #define IXOFF	0010000
95 
96 /* c_oflag bits */
97 #define OPOST	0000001
98 
99 /* c_cflag bit meaning */
100 #define CBAUD	   0010017
101 #define CSIZE	   0000060
102 #define CS8	   0000060
103 #define B0	   0000000
104 #define B50	   0000001
105 #define B75	   0000002
106 #define B110	   0000003
107 #define B134	   0000004
108 #define B150	   0000005
109 #define B200	   0000006
110 #define B300	   0000007
111 #define B600	   0000010
112 #define B1200	   0000011
113 #define B1800	   0000012
114 #define B2400	   0000013
115 #define B4800	   0000014
116 #define B9600	   0000015
117 #define CLOCAL	   0004000
118 #define CREAD	   0000200
119 #define CSTOPB	   0000100
120 #define HUPCL	   0002000
121 #define PARENB	   0000400
122 #define PARODD	   0001000
123 
124 /* c_lflag bits */
125 #define ECHO	0000010
126 #define ECHONL	0000100
127 #define ISIG	0000001
128 #define IEXTEN	0100000
129 #define ICANON	0000002
130 #define NOFLSH	0000200
131 #define ECHOE	0000020
132 #define ECHOK	0000040
133 
134 /* tcflush() */
135 #define	TCIFLUSH	0
136 
137 /* tcsetattr uses these */
138 #define	TCSADRAIN	1
139 
140 /* ioctls */
141 #define TCGETA		0x5405
142 #define TCFLSH		0x540B
143 #define TIOCGWINSZ	0x5413
144 
145 #ifndef cfgetospeed
146 #define cfgetospeed(t) ((t)->c_cflag & CBAUD)
147 #endif
148 
149 #ifndef tcsetattr
150 #define tcsetattr(fd, cmd, arg) _nc_mingw_ioctl(fd, cmd, arg)
151 #endif
152 
153 #ifndef tcgetattr
154 #define tcgetattr(fd, arg) _nc_mingw_ioctl(fd, TCGETA, arg)
155 #endif
156 
157 #ifndef tcflush
158 #define tcflush(fd, arg) _nc_mingw_ioctl(fd, TCFLSH, arg)
159 #endif
160 
161 #undef  ttyname
162 #define ttyname(fd) NULL
163 
164 #else
165 
166 #endif /* __MINGW32__ */
167 #endif /* HAVE_TERMIO_H */
168 
169 #endif /* HAVE_TERMIOS_H */
170 
171 #endif /* NC_TERMIOS_included */
172