]>
Commit | Line | Data |
---|---|---|
1 | /* termios type and macro definitions. 4.4 BSD/generic GNU version. | |
2 | Copyright (C) 1993-2025 Free Software Foundation, Inc. | |
3 | This file is part of the GNU C Library. | |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with the GNU C Library; if not, see | |
17 | <https://www.gnu.org/licenses/>. */ | |
18 | ||
19 | #ifndef _TERMIOS_H | |
20 | # error "Never include <bits/termios.h> directly; use <termios.h> instead." | |
21 | #endif | |
22 | ||
23 | #include <bits/termios-baud.h> | |
24 | ||
25 | /* These macros are also defined in some <bits/ioctls.h> files (with | |
26 | numerically identical values), but this serves to shut up cpp's | |
27 | complaining. */ | |
28 | #if defined __USE_MISC || defined __USE_XOPEN | |
29 | ||
30 | # ifdef NL0 | |
31 | # undef NL0 | |
32 | # endif | |
33 | # ifdef NL1 | |
34 | # undef NL1 | |
35 | # endif | |
36 | # ifdef TAB0 | |
37 | # undef TAB0 | |
38 | # endif | |
39 | # ifdef TAB1 | |
40 | # undef TAB1 | |
41 | # endif | |
42 | # ifdef TAB2 | |
43 | # undef TAB2 | |
44 | # endif | |
45 | # ifdef CR0 | |
46 | # undef CR0 | |
47 | # endif | |
48 | # ifdef CR1 | |
49 | # undef CR1 | |
50 | # endif | |
51 | # ifdef CR2 | |
52 | # undef CR2 | |
53 | # endif | |
54 | # ifdef CR3 | |
55 | # undef CR3 | |
56 | # endif | |
57 | # ifdef FF0 | |
58 | # undef FF0 | |
59 | # endif | |
60 | # ifdef FF1 | |
61 | # undef FF1 | |
62 | # endif | |
63 | # ifdef BS0 | |
64 | # undef BS0 | |
65 | # endif | |
66 | # ifdef BS1 | |
67 | # undef BS1 | |
68 | # endif | |
69 | ||
70 | #endif /* __USE_MISC || __USE_XOPEN */ | |
71 | ||
72 | #ifdef __USE_MISC | |
73 | ||
74 | # ifdef MDMBUF | |
75 | # undef MDMBUF | |
76 | # endif | |
77 | # ifdef FLUSHO | |
78 | # undef FLUSHO | |
79 | # endif | |
80 | # ifdef PENDIN | |
81 | # undef PENDIN | |
82 | # endif | |
83 | ||
84 | #endif /* __USE_MISC */ | |
85 | ||
86 | #ifdef ECHO | |
87 | # undef ECHO | |
88 | #endif | |
89 | #ifdef TOSTOP | |
90 | # undef TOSTOP | |
91 | #endif | |
92 | #ifdef NOFLSH | |
93 | # undef NOFLSH | |
94 | #endif | |
95 | ||
96 | ||
97 | /* These definitions match those used by the 4.4 BSD kernel. | |
98 | If the operating system has termios system calls or ioctls that | |
99 | correctly implement the POSIX.1 behavior, there should be a | |
100 | system-dependent version of this file that defines `struct termios', | |
101 | `tcflag_t', `cc_t', `speed_t' and the `TC*' constants appropriately. */ | |
102 | ||
103 | /* Type of terminal control flag masks. */ | |
104 | typedef unsigned int tcflag_t; | |
105 | ||
106 | /* Type of control characters. */ | |
107 | typedef unsigned char cc_t; | |
108 | ||
109 | /* Type of baud rate specifiers. */ | |
110 | typedef unsigned int speed_t; | |
111 | ||
112 | /* Terminal control structure. */ | |
113 | struct termios | |
114 | { | |
115 | /* Input modes. */ | |
116 | tcflag_t c_iflag; | |
117 | #define IGNBRK (1 << 0) /* Ignore break condition. */ | |
118 | #define BRKINT (1 << 1) /* Signal interrupt on break. */ | |
119 | #define IGNPAR (1 << 2) /* Ignore characters with parity errors. */ | |
120 | #define PARMRK (1 << 3) /* Mark parity and framing errors. */ | |
121 | #define INPCK (1 << 4) /* Enable input parity check. */ | |
122 | #define ISTRIP (1 << 5) /* Strip 8th bit off characters. */ | |
123 | #define INLCR (1 << 6) /* Map NL to CR on input. */ | |
124 | #define IGNCR (1 << 7) /* Ignore CR. */ | |
125 | #define ICRNL (1 << 8) /* Map CR to NL on input. */ | |
126 | #define IXON (1 << 9) /* Enable start/stop output control. */ | |
127 | #define IXOFF (1 << 10) /* Enable start/stop input control. */ | |
128 | #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_XOPEN2K8 | |
129 | # define IXANY (1 << 11) /* Any character will restart after stop. */ | |
130 | #endif | |
131 | #ifdef __USE_MISC | |
132 | # define IMAXBEL (1 << 13) /* Ring bell when input queue is full. */ | |
133 | #endif | |
134 | #if defined __USE_GNU || (defined __USE_XOPEN && !defined __USE_XOPEN2K) | |
135 | # define IUCLC (1 << 14) /* Translate upper case input to lower case. */ | |
136 | #endif | |
137 | ||
138 | /* Output modes. */ | |
139 | tcflag_t c_oflag; | |
140 | #define OPOST (1 << 0) /* Perform output processing. */ | |
141 | #if defined __USE_MISC || defined __USE_XOPEN | |
142 | # define ONLCR (1 << 1) /* Map NL to CR-NL on output. */ | |
143 | #endif | |
144 | #ifdef __USE_MISC | |
145 | # define OXTABS TAB3 /* Expand tabs to spaces. */ | |
146 | # define ONOEOT (1 << 3) /* Discard EOT (^D) on output. */ | |
147 | #endif | |
148 | #if defined __USE_MISC || defined __USE_XOPEN | |
149 | # define OCRNL (1 << 4) /* Map CR to NL. */ | |
150 | # define ONOCR (1 << 5) /* Discard CR's when on column 0. */ | |
151 | # define ONLRET (1 << 6) /* Move to column 0 on NL. */ | |
152 | #endif | |
153 | #if defined __USE_MISC || defined __USE_XOPEN | |
154 | # define NLDLY (3 << 8) /* NL delay. */ | |
155 | # define NL0 (0 << 8) /* NL type 0. */ | |
156 | # define NL1 (1 << 8) /* NL type 1. */ | |
157 | # define TABDLY (3 << 10 | 1 << 2) /* TAB delay. */ | |
158 | # define TAB0 (0 << 10) /* TAB delay type 0. */ | |
159 | # define TAB1 (1 << 10) /* TAB delay type 1. */ | |
160 | # define TAB2 (2 << 10) /* TAB delay type 2. */ | |
161 | # define TAB3 (1 << 2) /* Expand tabs to spaces. */ | |
162 | # define CRDLY (3 << 12) /* CR delay. */ | |
163 | # define CR0 (0 << 12) /* CR delay type 0. */ | |
164 | # define CR1 (1 << 12) /* CR delay type 1. */ | |
165 | # define CR2 (2 << 12) /* CR delay type 2. */ | |
166 | # define CR3 (3 << 12) /* CR delay type 3. */ | |
167 | # define FFDLY (1 << 14) /* FF delay. */ | |
168 | # define FF0 (0 << 14) /* FF delay type 0. */ | |
169 | # define FF1 (1 << 14) /* FF delay type 1. */ | |
170 | # define BSDLY (1 << 15) /* BS delay. */ | |
171 | # define BS0 (0 << 15) /* BS delay type 0. */ | |
172 | # define BS1 (1 << 15) /* BS delay type 1. */ | |
173 | # define VTDLY (1 << 16) /* VT delay. */ | |
174 | # define VT0 (0 << 16) /* VT delay type 0. */ | |
175 | # define VT1 (1 << 16) /* VT delay type 1. */ | |
176 | #endif /* __USE_MISC || __USE_XOPEN */ | |
177 | #if defined __USE_GNU || (defined __USE_XOPEN && !defined __USE_XOPEN2K) | |
178 | # define OLCUC (1 << 17) /* Translate lower case output to upper case */ | |
179 | #endif | |
180 | #ifdef __USE_XOPEN | |
181 | # define OFILL (1 << 18) /* Send fill characters for delays. */ | |
182 | # define OFDEL (1 << 19) /* Fill is DEL. */ | |
183 | #endif | |
184 | ||
185 | /* Control modes. */ | |
186 | tcflag_t c_cflag; | |
187 | #ifdef __USE_MISC | |
188 | # define CIGNORE (1 << 0) /* Ignore these control flags. */ | |
189 | #endif | |
190 | #define CSIZE (CS5|CS6|CS7|CS8) /* Number of bits per byte (mask). */ | |
191 | #define CS5 0 /* 5 bits per byte. */ | |
192 | #define CS6 (1 << 8) /* 6 bits per byte. */ | |
193 | #define CS7 (1 << 9) /* 7 bits per byte. */ | |
194 | #define CS8 (CS6|CS7) /* 8 bits per byte. */ | |
195 | #define CSTOPB (1 << 10) /* Two stop bits instead of one. */ | |
196 | #define CREAD (1 << 11) /* Enable receiver. */ | |
197 | #define PARENB (1 << 12) /* Parity enable. */ | |
198 | #define PARODD (1 << 13) /* Odd parity instead of even. */ | |
199 | #define HUPCL (1 << 14) /* Hang up on last close. */ | |
200 | #define CLOCAL (1 << 15) /* Ignore modem status lines. */ | |
201 | #ifdef __USE_MISC | |
202 | # define CRTSCTS (1 << 16) /* RTS/CTS flow control. */ | |
203 | # define CRTS_IFLOW CRTSCTS /* Compatibility. */ | |
204 | # define CCTS_OFLOW CRTSCTS /* Compatibility. */ | |
205 | # define CDTRCTS (1 << 17) /* DTR/CTS flow control. */ | |
206 | # define MDMBUF (1 << 20) /* DTR/DCD flow control. */ | |
207 | # define CHWFLOW (MDMBUF|CRTSCTS|CDTRCTS) /* All types of flow control. */ | |
208 | #endif | |
209 | ||
210 | /* Local modes. */ | |
211 | tcflag_t c_lflag; | |
212 | #ifdef __USE_MISC | |
213 | # define ECHOKE (1 << 0) /* Visual erase for KILL. */ | |
214 | #endif | |
215 | #define _ECHOE (1 << 1) /* Visual erase for ERASE. */ | |
216 | #define ECHOE _ECHOE | |
217 | #define _ECHOK (1 << 2) /* Echo NL after KILL. */ | |
218 | #define ECHOK _ECHOK | |
219 | #define _ECHO (1 << 3) /* Enable echo. */ | |
220 | #define ECHO _ECHO | |
221 | #define _ECHONL (1 << 4) /* Echo NL even if ECHO is off. */ | |
222 | #define ECHONL _ECHONL | |
223 | #ifdef __USE_MISC | |
224 | # define ECHOPRT (1 << 5) /* Hardcopy visual erase. */ | |
225 | # define ECHOCTL (1 << 6) /* Echo control characters as ^X. */ | |
226 | #endif | |
227 | #define _ISIG (1 << 7) /* Enable signals. */ | |
228 | #define ISIG _ISIG | |
229 | #define _ICANON (1 << 8) /* Do erase and kill processing. */ | |
230 | #define ICANON _ICANON | |
231 | #ifdef __USE_MISC | |
232 | # define ALTWERASE (1 << 9) /* Alternate WERASE algorithm. */ | |
233 | #endif | |
234 | #define _IEXTEN (1 << 10) /* Enable DISCARD and LNEXT. */ | |
235 | #define IEXTEN _IEXTEN | |
236 | #ifdef __USE_MISC | |
237 | # define EXTPROC (1 << 11) /* External processing. */ | |
238 | #endif | |
239 | #define _TOSTOP (1 << 22) /* Send SIGTTOU for background output. */ | |
240 | #define TOSTOP _TOSTOP | |
241 | #ifdef __USE_MISC | |
242 | # define FLUSHO (1 << 23) /* Output being flushed (state). */ | |
243 | #endif | |
244 | #if defined __USE_XOPEN && !defined __USE_XOPEN2K | |
245 | # define XCASE (1 << 24) /* Canonical upper/lower case. */ | |
246 | #endif | |
247 | #ifdef __USE_MISC | |
248 | # define NOKERNINFO (1 << 25) /* Disable VSTATUS. */ | |
249 | # define PENDIN (1 << 29) /* Retype pending input (state). */ | |
250 | #endif | |
251 | #define _NOFLSH (1U << 31) /* Disable flush after interrupt. */ | |
252 | #define NOFLSH _NOFLSH | |
253 | ||
254 | /* Control characters. */ | |
255 | #define VEOF 0 /* End-of-file character [ICANON]. */ | |
256 | #define VEOL 1 /* End-of-line character [ICANON]. */ | |
257 | #ifdef __USE_MISC | |
258 | # define VEOL2 2 /* Second EOL character [ICANON]. */ | |
259 | #endif | |
260 | #define VERASE 3 /* Erase character [ICANON]. */ | |
261 | #ifdef __USE_MISC | |
262 | # define VWERASE 4 /* Word-erase character [ICANON]. */ | |
263 | #endif | |
264 | #define VKILL 5 /* Kill-line character [ICANON]. */ | |
265 | #ifdef __USE_MISC | |
266 | # define VREPRINT 6 /* Reprint-line character [ICANON]. */ | |
267 | #endif | |
268 | #define VINTR 8 /* Interrupt character [ISIG]. */ | |
269 | #define VQUIT 9 /* Quit character [ISIG]. */ | |
270 | #define VSUSP 10 /* Suspend character [ISIG]. */ | |
271 | #ifdef __USE_MISC | |
272 | # define VDSUSP 11 /* Delayed suspend character [ISIG]. */ | |
273 | #endif | |
274 | #define VSTART 12 /* Start (X-ON) character [IXON, IXOFF]. */ | |
275 | #define VSTOP 13 /* Stop (X-OFF) character [IXON, IXOFF]. */ | |
276 | #ifdef __USE_MISC | |
277 | # define VLNEXT 14 /* Literal-next character [IEXTEN]. */ | |
278 | # define VDISCARD 15 /* Discard character [IEXTEN]. */ | |
279 | #endif | |
280 | #define VMIN 16 /* Minimum number of bytes read at once [!ICANON]. */ | |
281 | #define VTIME 17 /* Time-out value (tenths of a second) [!ICANON]. */ | |
282 | #ifdef __USE_MISC | |
283 | # define VSTATUS 18 /* Status character [ICANON]. */ | |
284 | #endif | |
285 | #define NCCS 20 /* Value duplicated in <hurd/tioctl.defs>. */ | |
286 | cc_t c_cc[NCCS]; | |
287 | ||
288 | /* Input and output baud rates. */ | |
289 | __extension__ union { | |
290 | speed_t __ispeed; | |
291 | speed_t c_ispeed; | |
292 | }; | |
293 | #define _HAVE_STRUCT_TERMIOS_C_ISPEED 1 | |
294 | __extension__ union { | |
295 | speed_t __ospeed; | |
296 | speed_t c_ospeed; | |
297 | }; | |
298 | #define _HAVE_STRUCT_TERMIOS_C_OSPEED 1 | |
299 | }; | |
300 | ||
301 | #define _IOT_termios /* Hurd ioctl type field. */ \ | |
302 | _IOT (_IOTS (tcflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2) | |
303 | ||
304 | /* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'. */ | |
305 | #define TCSANOW 0 /* Change immediately. */ | |
306 | #define TCSADRAIN 1 /* Change when pending output is written. */ | |
307 | #define TCSAFLUSH 2 /* Flush pending input before changing. */ | |
308 | #ifdef __USE_MISC | |
309 | # define TCSASOFT 0x10 /* Flag: Don't alter hardware state. */ | |
310 | #endif | |
311 | ||
312 | /* Values for the QUEUE_SELECTOR argument to `tcflush'. */ | |
313 | #define TCIFLUSH 1 /* Discard data received but not yet read. */ | |
314 | #define TCOFLUSH 2 /* Discard data written but not yet sent. */ | |
315 | #define TCIOFLUSH 3 /* Discard all pending data. */ | |
316 | ||
317 | /* Values for the ACTION argument to `tcflow'. */ | |
318 | #define TCOOFF 1 /* Suspend output. */ | |
319 | #define TCOON 2 /* Restart suspended output. */ | |
320 | #define TCIOFF 3 /* Send a STOP character. */ | |
321 | #define TCION 4 /* Send a START character. */ |