]>
Commit | Line | Data |
---|---|---|
a887211b CV |
1 | /* sys/termios.h |
2 | ||
a887211b CV |
3 | This file is part of Cygwin. |
4 | ||
5 | This software is a copyrighted work licensed under the terms of the | |
6 | Cygwin license. Please consult the file "CYGWIN_LICENSE" for | |
7 | details. */ | |
8 | ||
1fd5e000 CF |
9 | /* sys/termios.h */ |
10 | ||
11 | #ifndef _SYS_TERMIOS_H | |
12 | #define _SYS_TERMIOS_H | |
13 | ||
580df3b6 EB |
14 | #include <sys/types.h> |
15 | ||
780c42b4 | 16 | #define TIOCMGET 0x5415 |
723d64e6 CV |
17 | #define TIOCMBIS 0x5416 |
18 | #define TIOCMBIC 0x5417 | |
780c42b4 | 19 | #define TIOCMSET 0x5418 |
05726ddd | 20 | #define TIOCINQ 0x541B |
4add6f8d | 21 | #define TIOCSCTTY 0x540E |
780c42b4 CV |
22 | |
23 | /* TIOCINQ is utilized instead of FIONREAD which has been | |
24 | accupied for other purposes under CYGWIN. | |
25 | Other UNIX ioctl requests has been omited because | |
26 | effects of their work one can achive by standard | |
27 | POSIX commands */ | |
28 | ||
58e9df0f CF |
29 | #define TIOCSBRK 0x5427 |
30 | #define TIOCCBRK 0x5428 | |
780c42b4 CV |
31 | |
32 | #define TIOCM_DTR 0x002 | |
33 | #define TIOCM_RTS 0x004 | |
34 | #define TIOCM_CTS 0x020 | |
35 | #define TIOCM_CAR 0x040 | |
36 | #define TIOCM_RNG 0x080 | |
37 | #define TIOCM_DSR 0x100 | |
38 | #define TIOCM_CD TIOCM_CAR | |
39 | #define TIOCM_RI TIOCM_RNG | |
40 | ||
1fd5e000 CF |
41 | #define TCOOFF 0 |
42 | #define TCOON 1 | |
43 | #define TCIOFF 2 | |
44 | #define TCION 3 | |
45 | ||
75a57bf0 CF |
46 | #define TCGETA 5 |
47 | #define TCSETA 6 | |
48 | #define TCSETAW 7 | |
49 | #define TCSETAF 8 | |
1fd5e000 CF |
50 | |
51 | #define TCIFLUSH 0 | |
52 | #define TCOFLUSH 1 | |
53 | #define TCIOFLUSH 2 | |
54 | #define TCFLSH 3 | |
55 | ||
56 | #define TCSAFLUSH 1 | |
57 | #define TCSANOW 2 | |
58 | #define TCSADRAIN 3 | |
59 | #define TCSADFLUSH 4 | |
60 | ||
61 | #define TIOCPKT 6 | |
62 | ||
63 | #define TIOCPKT_DATA 0 | |
64 | #define TIOCPKT_FLUSHREAD 1 | |
65 | #define TIOCPKT_FLUSHWRITE 2 | |
66 | #define TIOCPKT_STOP 4 | |
67 | #define TIOCPKT_START 8 | |
68 | #define TIOCPKT_NOSTOP 16 | |
69 | #define TIOCPKT_DOSTOP 32 | |
70 | ||
977912ff CV |
71 | /* Compatible with asm/socket.h */ |
72 | #define FIONBIO 0x8004667e /* set/clear non-blocking i/o */ | |
1fd5e000 CF |
73 | |
74 | #define CTRL(ch) ((ch)&0x1F) | |
75 | ||
76 | #define CNUL 0 | |
77 | #define CDEL 0x0007f | |
78 | #define CESC '\\' | |
79 | #define CINTR CTRL('C') | |
80 | #define CQUIT 0x0001c | |
025e4859 | 81 | #define CERASE CDEL |
1fd5e000 CF |
82 | #define CKILL CTRL('U') |
83 | #define CEOT CTRL('D') | |
84 | #define CEOL 0 | |
85 | #define CEOL2 0 | |
650dc73f | 86 | #define CBRK CEOL |
1fd5e000 CF |
87 | #define CEOF CTRL('D') |
88 | #define CSTART CTRL('Q') | |
89 | #define CSTOP CTRL('S') | |
90 | #define CSWTCH 0x0001a | |
91 | #define NSWTCH 0 | |
92 | #define CSUSP CTRL('Z') | |
93 | #define CDSUSP CTRL('Y') | |
94 | #define CRPRNT CTRL('R') | |
650dc73f | 95 | #define CREPRINT CRPRNT |
1fd5e000 | 96 | #define CFLUSH CTRL('O') |
650dc73f | 97 | #define CDISCARD CFLUSH |
1fd5e000 CF |
98 | #define CWERASE CTRL('W') |
99 | #define CLNEXT CTRL('V') | |
03d5584c CV |
100 | #define CMIN 1 |
101 | #define CTIME 0 | |
1fd5e000 CF |
102 | |
103 | /* iflag bits */ | |
104 | #define IGNBRK 0x00001 | |
105 | #define BRKINT 0x00002 | |
106 | #define IGNPAR 0x00004 | |
107 | #define IMAXBEL 0x00008 | |
108 | #define INPCK 0x00010 | |
109 | #define ISTRIP 0x00020 | |
110 | #define INLCR 0x00040 | |
111 | #define IGNCR 0x00080 | |
112 | #define ICRNL 0x00100 | |
113 | #define IXON 0x00400 | |
114 | #define IXOFF 0x01000 | |
115 | #define IUCLC 0x04000 | |
116 | #define IXANY 0x08000 | |
117 | #define PARMRK 0x10000 | |
095cac4b | 118 | #define IUTF8 0x20000 |
1fd5e000 CF |
119 | |
120 | /* oflag bits */ | |
121 | ||
122 | #define OPOST 0x00001 | |
123 | #define OLCUC 0x00002 | |
124 | #define OCRNL 0x00004 | |
125 | #define ONLCR 0x00008 | |
126 | #define ONOCR 0x00010 | |
127 | #define ONLRET 0x00020 | |
128 | #define OFILL 0x00040 | |
129 | #define CRDLY 0x00180 | |
130 | #define CR0 0x00000 | |
131 | #define CR1 0x00080 | |
132 | #define CR2 0x00100 | |
133 | #define CR3 0x00180 | |
134 | #define NLDLY 0x00200 | |
135 | #define NL0 0x00000 | |
136 | #define NL1 0x00200 | |
137 | #define BSDLY 0x00400 | |
138 | #define BS0 0x00000 | |
139 | #define BS1 0x00400 | |
140 | #define TABDLY 0x01800 | |
141 | #define TAB0 0x00000 | |
142 | #define TAB1 0x00800 | |
143 | #define TAB2 0x01000 | |
144 | #define TAB3 0x01800 | |
145 | #define XTABS 0x01800 | |
146 | #define VTDLY 0x02000 | |
147 | #define VT0 0x00000 | |
148 | #define VT1 0x02000 | |
149 | #define FFDLY 0x04000 | |
150 | #define FF0 0x00000 | |
151 | #define FF1 0x04000 | |
152 | #define OFDEL 0x08000 | |
153 | ||
154 | /* cflag bits */ | |
155 | ||
156 | /* Baud rate values. These must fit in speed_t, which is unsigned | |
157 | char. See also the extended baud rates below. These baud rates | |
158 | set an additional bit. */ | |
159 | #define CBAUD 0x0100f | |
160 | #define B0 0x00000 | |
161 | #define B50 0x00001 | |
162 | #define B75 0x00002 | |
163 | #define B110 0x00003 | |
164 | #define B134 0x00004 | |
165 | #define B150 0x00005 | |
166 | #define B200 0x00006 | |
167 | #define B300 0x00007 | |
168 | #define B600 0x00008 | |
169 | #define B1200 0x00009 | |
170 | #define B1800 0x0000a | |
171 | #define B2400 0x0000b | |
172 | #define B4800 0x0000c | |
173 | #define B9600 0x0000d | |
174 | #define B19200 0x0000e | |
175 | #define B38400 0x0000f | |
176 | ||
177 | #define CSIZE 0x00030 | |
178 | #define CS5 0x00000 | |
179 | #define CS6 0x00010 | |
180 | #define CS7 0x00020 | |
181 | #define CS8 0x00030 | |
182 | #define CSTOPB 0x00040 | |
183 | #define CREAD 0x00080 | |
184 | #define PARENB 0x00100 | |
185 | #define PARODD 0x00200 | |
186 | #define HUPCL 0x00400 | |
187 | #define CLOCAL 0x00800 | |
f82f801c CV |
188 | |
189 | /* Extended baud rates above 37K. */ | |
1fd5e000 CF |
190 | #define CBAUDEX 0x0100f |
191 | #define B57600 0x01001 | |
192 | #define B115200 0x01002 | |
193 | #define B128000 0x01003 | |
85ba109d CF |
194 | #define B230400 0x01004 |
195 | #define B256000 0x01005 | |
f82f801c CV |
196 | #define B460800 0x01006 |
197 | #define B500000 0x01007 | |
198 | #define B576000 0x01008 | |
199 | #define B921600 0x01009 | |
200 | #define B1000000 0x0100a | |
201 | #define B1152000 0x0100b | |
202 | #define B1500000 0x0100c | |
203 | #define B2000000 0x0100d | |
204 | #define B2500000 0x0100e | |
205 | #define B3000000 0x0100f | |
206 | ||
1fd5e000 CF |
207 | #define CRTSXOFF 0x04000 |
208 | #define CRTSCTS 0x08000 | |
d4a756f1 | 209 | #define CMSPAR 0x40000000 /* Mark or space (stick) parity. */ |
1fd5e000 CF |
210 | |
211 | /* lflag bits */ | |
212 | #define ISIG 0x0001 | |
213 | #define ICANON 0x0002 | |
214 | #define ECHO 0x0004 | |
215 | #define ECHOE 0x0008 | |
216 | #define ECHOK 0x0010 | |
217 | #define ECHONL 0x0020 | |
218 | #define NOFLSH 0x0040 | |
219 | #define TOSTOP 0x0080 | |
220 | #define IEXTEN 0x0100 | |
221 | #define FLUSHO 0x0200 | |
222 | #define ECHOKE 0x0400 | |
223 | #define ECHOCTL 0x0800 | |
224 | ||
225 | #define VDISCARD 1 | |
226 | #define VEOL 2 | |
75a57bf0 | 227 | #define VEOL2 3 |
1fd5e000 CF |
228 | #define VEOF 4 |
229 | #define VERASE 5 | |
230 | #define VINTR 6 | |
231 | #define VKILL 7 | |
75a57bf0 | 232 | #define VLNEXT 8 |
1fd5e000 CF |
233 | #define VMIN 9 |
234 | #define VQUIT 10 | |
75a57bf0 | 235 | #define VREPRINT 11 |
1fd5e000 CF |
236 | #define VSTART 12 |
237 | #define VSTOP 13 | |
238 | #define VSUSP 14 | |
75a57bf0 | 239 | #define VSWTC 15 |
1fd5e000 | 240 | #define VTIME 16 |
75a57bf0 | 241 | #define VWERASE 17 |
1fd5e000 | 242 | |
75a57bf0 | 243 | #define NCCS 18 |
1fd5e000 | 244 | |
ad2864f4 CV |
245 | /* Compare a character C to a value VAL from the `c_cc' array in a |
246 | `struct termios'. If VAL is _POSIX_VDISABLE, no character can match it. */ | |
247 | #define CCEQ(val, c) ((c) == (val) && (val) != _POSIX_VDISABLE) | |
248 | ||
650dc73f YS |
249 | #define TTYDEF_IFLAG (BRKINT | ICRNL | IMAXBEL | IXON | IXANY) |
250 | #define TTYDEF_OFLAG (OPOST | ONLCR) | |
251 | #define TTYDEF_LFLAG (ICANON | ISIG | IEXTEN | ECHO | ECHOE | ECHOKE | ECHOCTL) | |
252 | #define TTYDEF_CFLAG (CREAD | CS8 | HUPCL) | |
253 | #define TTYDEF_SPEED (B9600) | |
254 | ||
1fd5e000 CF |
255 | typedef unsigned char cc_t; |
256 | typedef unsigned int tcflag_t; | |
257 | typedef unsigned int speed_t; | |
258 | typedef unsigned short otcflag_t; | |
259 | typedef unsigned char ospeed_t; | |
260 | ||
6a7a2f4b CF |
261 | struct __oldtermios |
262 | { | |
263 | otcflag_t c_iflag; | |
264 | otcflag_t c_oflag; | |
265 | otcflag_t c_cflag; | |
266 | otcflag_t c_lflag; | |
267 | char c_line; | |
268 | cc_t c_cc[NCCS]; | |
269 | ospeed_t c_ispeed; | |
270 | ospeed_t c_ospeed; | |
1fd5e000 CF |
271 | }; |
272 | ||
6a7a2f4b CF |
273 | struct termios |
274 | { | |
275 | tcflag_t c_iflag; | |
276 | tcflag_t c_oflag; | |
277 | tcflag_t c_cflag; | |
278 | tcflag_t c_lflag; | |
279 | char c_line; | |
280 | cc_t c_cc[NCCS]; | |
281 | speed_t c_ispeed; | |
282 | speed_t c_ospeed; | |
1fd5e000 CF |
283 | }; |
284 | ||
1fd5e000 CF |
285 | #define termio termios |
286 | ||
1fd5e000 CF |
287 | #ifdef __cplusplus |
288 | extern "C" { | |
289 | #endif | |
290 | ||
291 | int tcgetattr (int, struct termios *); | |
292 | int tcsetattr (int, int, const struct termios *); | |
293 | int tcsendbreak (int, int); | |
294 | int tcdrain (int); | |
295 | int tcflush (int, int); | |
296 | int tcflow (int, int); | |
580df3b6 | 297 | pid_t tcgetsid (int); |
175742d8 | 298 | void cfmakeraw (struct termios *); |
b7d4651e CV |
299 | speed_t cfgetispeed(const struct termios *); |
300 | speed_t cfgetospeed(const struct termios *); | |
34f5d087 CF |
301 | int cfsetispeed (struct termios *, speed_t); |
302 | int cfsetospeed (struct termios *, speed_t); | |
beaf1df0 | 303 | int cfsetspeed (struct termios *, speed_t); |
1fd5e000 CF |
304 | |
305 | #ifdef __cplusplus | |
306 | } | |
307 | #endif | |
308 | ||
b7d4651e CV |
309 | #ifndef __cplusplus |
310 | #define cfgetispeed(tp) ((tp)->c_ispeed) | |
311 | #define cfgetospeed(tp) ((tp)->c_ospeed) | |
312 | #endif | |
313 | ||
1fd5e000 CF |
314 | /* Extra stuff to make porting stuff easier. */ |
315 | struct winsize | |
316 | { | |
317 | unsigned short ws_row, ws_col; | |
318 | unsigned short ws_xpixel, ws_ypixel; | |
319 | }; | |
320 | ||
321 | #define TIOCGWINSZ (('T' << 8) | 1) | |
322 | #define TIOCSWINSZ (('T' << 8) | 2) | |
63726a5e | 323 | #define TIOCLINUX (('T' << 8) | 3) |
4ce975ef CF |
324 | #define TIOCGPGRP (('T' << 8) | 0xf) |
325 | #define TIOCSPGRP (('T' << 8) | 0x10) | |
1fd5e000 CF |
326 | |
327 | #endif /* _SYS_TERMIOS_H */ |