1 /* sys/termios.h
2 
3    Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc.
4 
5 This file is part of Cygwin.
6 
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
9 details. */
10 
11 /* sys/termios.h */
12 
13 #ifndef _SYS_TERMIOS_H
14 #define _SYS_TERMIOS_H
15 
16 #define TIOCMGET        0x5415
17 #define TIOCMSET        0x5418
18 #define TIOCINQ         0x541B
19 
20 /* TIOCINQ is utilized instead of FIONREAD which has been
21 accupied for other purposes under CYGWIN.
22 Other UNIX ioctl requests has been omited because
23 effects of their work one can achive by standard
24 POSIX commands */
25 
26 #define TIOCSBRK        0x5427
27 #define TIOCCBRK        0x5428
28 
29 #define TIOCM_LE        0x001
30 #define TIOCM_DTR       0x002
31 #define TIOCM_RTS       0x004
32 #define TIOCM_ST        0x008
33 #define TIOCM_SR        0x010
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 
41 #define TCOOFF          0
42 #define TCOON           1
43 #define TCIOFF          2
44 #define TCION           3
45 
46 #define TCGETA  5
47 #define TCSETA  6
48 #define TCSETAW         7
49 #define TCSETAF         8
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 
71 #define CTRL(ch)        ((ch)&0x1F)
72 
73 #define CNUL    0
74 #define CDEL    0x0007f
75 #define CESC    '\\'
76 #define CINTR   CTRL('C')
77 #define CQUIT   0x0001c
78 #define CERASE  CTRL('H')
79 #define CKILL   CTRL('U')
80 #define CEOT    CTRL('D')
81 #define CEOL    0
82 #define CEOL2   0
83 #define CEOF    CTRL('D')
84 #define CSTART  CTRL('Q')
85 #define CSTOP   CTRL('S')
86 #define CSWTCH  0x0001a
87 #define NSWTCH  0
88 #define CSUSP   CTRL('Z')
89 #define CDSUSP  CTRL('Y')
90 #define CRPRNT  CTRL('R')
91 #define CFLUSH  CTRL('O')
92 #define CWERASE CTRL('W')
93 #define CLNEXT  CTRL('V')
94 
95 /* iflag bits */
96 #define IGNBRK  0x00001
97 #define BRKINT  0x00002
98 #define IGNPAR  0x00004
99 #define IMAXBEL 0x00008
100 #define INPCK   0x00010
101 #define ISTRIP  0x00020
102 #define INLCR   0x00040
103 #define IGNCR   0x00080
104 #define ICRNL   0x00100
105 #define IXON    0x00400
106 #define IXOFF   0x01000
107 #define IUCLC   0x04000
108 #define IXANY   0x08000
109 #define PARMRK  0x10000
110 
111 /* oflag bits */
112 
113 #define OPOST   0x00001
114 #define OLCUC   0x00002
115 #define OCRNL   0x00004
116 #define ONLCR   0x00008
117 #define ONOCR   0x00010
118 #define ONLRET  0x00020
119 #define OFILL   0x00040
120 #define CRDLY   0x00180
121 #define CR0     0x00000
122 #define CR1     0x00080
123 #define CR2     0x00100
124 #define CR3     0x00180
125 #define NLDLY   0x00200
126 #define NL0     0x00000
127 #define NL1     0x00200
128 #define BSDLY   0x00400
129 #define BS0     0x00000
130 #define BS1     0x00400
131 #define TABDLY  0x01800
132 #define TAB0    0x00000
133 #define TAB1    0x00800
134 #define TAB2    0x01000
135 #define TAB3    0x01800
136 #define XTABS   0x01800
137 #define VTDLY   0x02000
138 #define VT0     0x00000
139 #define VT1     0x02000
140 #define FFDLY   0x04000
141 #define FF0     0x00000
142 #define FF1     0x04000
143 #define OFDEL   0x08000
144 
145 /* cflag bits */
146 
147 /* Baud rate values.  These must fit in speed_t, which is unsigned
148    char.  See also the extended baud rates below.  These baud rates
149    set an additional bit. */
150 #define CBAUD    0x0100f
151 #define B0       0x00000
152 #define B50      0x00001
153 #define B75      0x00002
154 #define B110     0x00003
155 #define B134     0x00004
156 #define B150     0x00005
157 #define B200     0x00006
158 #define B300     0x00007
159 #define B600     0x00008
160 #define B1200    0x00009
161 #define B1800    0x0000a
162 #define B2400    0x0000b
163 #define B4800    0x0000c
164 #define B9600    0x0000d
165 #define B19200   0x0000e
166 #define B38400   0x0000f
167 
168 #define CSIZE    0x00030
169 #define CS5      0x00000
170 #define CS6      0x00010
171 #define CS7      0x00020
172 #define CS8      0x00030
173 #define CSTOPB   0x00040
174 #define CREAD    0x00080
175 #define PARENB   0x00100
176 #define PARODD   0x00200
177 #define HUPCL    0x00400
178 #define CLOCAL   0x00800
179 #define CBAUDEX  0x0100f
180 #define B57600   0x01001
181 #define B115200  0x01002
182 #define B128000  0x01003
183 #define B230400  0x01004
184 #define B256000  0x01005
185 #define CRTSXOFF 0x04000
186 #define CRTSCTS  0x08000
187 
188 /* lflag bits */
189 #define ISIG    0x0001
190 #define ICANON  0x0002
191 #define ECHO    0x0004
192 #define ECHOE   0x0008
193 #define ECHOK   0x0010
194 #define ECHONL  0x0020
195 #define NOFLSH  0x0040
196 #define TOSTOP  0x0080
197 #define IEXTEN  0x0100
198 #define FLUSHO  0x0200
199 #define ECHOKE  0x0400
200 #define ECHOCTL 0x0800
201 
202 #define VDISCARD        1
203 #define VEOL            2
204 #define VEOL2           3
205 #define VEOF            4
206 #define VERASE          5
207 #define VINTR           6
208 #define VKILL           7
209 #define VLNEXT          8
210 #define VMIN            9
211 #define VQUIT           10
212 #define VREPRINT        11
213 #define VSTART          12
214 #define VSTOP           13
215 #define VSUSP           14
216 #define VSWTC           15
217 #define VTIME           16
218 #define VWERASE 17
219 
220 #define NCCS            18
221 
222 /* `c_cc' member of 'struct termios' structure can be disabled by
223    using the value _POSIX_VDISABLE.  */
224 #define _POSIX_VDISABLE '\0'
225 
226 /* Compare a character C to a value VAL from the `c_cc' array in a
227    `struct termios'.  If VAL is _POSIX_VDISABLE, no character can match it.  */
228 #define CCEQ(val, c)    ((c) == (val) && (val) != _POSIX_VDISABLE)
229 
230 typedef unsigned char cc_t;
231 typedef unsigned int  tcflag_t;
232 typedef unsigned int  speed_t;
233 typedef unsigned short otcflag_t;
234 typedef unsigned char ospeed_t;
235 
236 struct termios {
237         tcflag_t        c_iflag;
238         tcflag_t        c_oflag;
239         tcflag_t        c_cflag;
240         tcflag_t        c_lflag;
241         char            c_line;
242         cc_t            c_cc[NCCS];
243         speed_t         c_ispeed;
244         speed_t         c_ospeed;
245 };
246 
247 #define termio termios
248 
249 #define cfgetospeed(tp)         ((tp)->c_ospeed)
250 #define cfgetispeed(tp)         ((tp)->c_ispeed)
251 #define cfsetospeed(tp,s)       (((tp)->c_ospeed = (s)), 0)
252 #define cfsetispeed(tp,s)       (((tp)->c_ispeed = (s)), 0)
253 
254 #ifdef __cplusplus
255 extern "C" {
256 #endif
257 
258 int tcgetattr (int, struct termios *);
259 int tcsetattr (int, int, const struct termios *);
260 int tcsendbreak (int, int);
261 int tcdrain (int);
262 int tcflush (int, int);
263 int tcflow (int, int);
264 
265 #ifdef __cplusplus
266 }
267 #endif
268 
269 /* Extra stuff to make porting stuff easier.  */
270 struct winsize
271 {
272   unsigned short ws_row, ws_col;
273   unsigned short ws_xpixel, ws_ypixel;
274 };
275 
276 #define TIOCGWINSZ (('T' << 8) | 1)
277 #define TIOCSWINSZ (('T' << 8) | 2)
278 #define TIOCLINUX  (('T' << 8) | 3)
279 
280 #endif  /* _SYS_TERMIOS_H */
281