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