| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1 | /* termios type and macro definitions.  4.4 BSD/generic GNU version. | 
|  | 2 | Copyright (C) 1993-2016 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 | <http://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 | /* These macros are also defined in some <bits/ioctls.h> files (with | 
|  | 24 | numerically identical values), but this serves to shut up cpp's | 
|  | 25 | complaining. */ | 
|  | 26 | #if defined __USE_MISC || defined __USE_XOPEN | 
|  | 27 |  | 
|  | 28 | # ifdef NL0 | 
|  | 29 | #  undef NL0 | 
|  | 30 | # endif | 
|  | 31 | # ifdef NL1 | 
|  | 32 | #  undef NL1 | 
|  | 33 | # endif | 
|  | 34 | # ifdef TAB0 | 
|  | 35 | #  undef TAB0 | 
|  | 36 | # endif | 
|  | 37 | # ifdef TAB1 | 
|  | 38 | #  undef TAB1 | 
|  | 39 | # endif | 
|  | 40 | # ifdef TAB2 | 
|  | 41 | #  undef TAB2 | 
|  | 42 | # endif | 
|  | 43 | # ifdef CR0 | 
|  | 44 | #  undef CR0 | 
|  | 45 | # endif | 
|  | 46 | # ifdef CR1 | 
|  | 47 | #  undef CR1 | 
|  | 48 | # endif | 
|  | 49 | # ifdef CR2 | 
|  | 50 | #  undef CR2 | 
|  | 51 | # endif | 
|  | 52 | # ifdef CR3 | 
|  | 53 | #  undef CR3 | 
|  | 54 | # endif | 
|  | 55 | # ifdef FF0 | 
|  | 56 | #  undef FF0 | 
|  | 57 | # endif | 
|  | 58 | # ifdef FF1 | 
|  | 59 | #  undef FF1 | 
|  | 60 | # endif | 
|  | 61 | # ifdef BS0 | 
|  | 62 | #  undef BS0 | 
|  | 63 | # endif | 
|  | 64 | # ifdef BS1 | 
|  | 65 | #  undef BS1 | 
|  | 66 | # endif | 
|  | 67 |  | 
|  | 68 | #endif /* __USE_MISC || __USE_XOPEN */ | 
|  | 69 |  | 
|  | 70 | #ifdef __USE_MISC | 
|  | 71 |  | 
|  | 72 | # ifdef MDMBUF | 
|  | 73 | #  undef MDMBUF | 
|  | 74 | # endif | 
|  | 75 | # ifdef FLUSHO | 
|  | 76 | #  undef FLUSHO | 
|  | 77 | # endif | 
|  | 78 | # ifdef PENDIN | 
|  | 79 | #  undef PENDIN | 
|  | 80 | # endif | 
|  | 81 |  | 
|  | 82 | #endif /* __USE_MISC */ | 
|  | 83 |  | 
|  | 84 | #ifdef ECHO | 
|  | 85 | # undef ECHO | 
|  | 86 | #endif | 
|  | 87 | #ifdef TOSTOP | 
|  | 88 | # undef TOSTOP | 
|  | 89 | #endif | 
|  | 90 | #ifdef NOFLSH | 
|  | 91 | # undef NOFLSH | 
|  | 92 | #endif | 
|  | 93 |  | 
|  | 94 |  | 
|  | 95 | /* These definitions match those used by the 4.4 BSD kernel. | 
|  | 96 | If the operating system has termios system calls or ioctls that | 
|  | 97 | correctly implement the POSIX.1 behavior, there should be a | 
|  | 98 | system-dependent version of this file that defines `struct termios', | 
|  | 99 | `tcflag_t', `cc_t', `speed_t' and the `TC*' constants appropriately.  */ | 
|  | 100 |  | 
|  | 101 | /* Type of terminal control flag masks.  */ | 
|  | 102 | typedef unsigned long int tcflag_t; | 
|  | 103 |  | 
|  | 104 | /* Type of control characters.  */ | 
|  | 105 | typedef unsigned char cc_t; | 
|  | 106 |  | 
|  | 107 | /* Type of baud rate specifiers.  */ | 
|  | 108 | typedef long int speed_t; | 
|  | 109 |  | 
|  | 110 | /* Terminal control structure.  */ | 
|  | 111 | struct termios | 
|  | 112 | { | 
|  | 113 | /* Input modes.  */ | 
|  | 114 | tcflag_t c_iflag; | 
|  | 115 | #define	IGNBRK	(1 << 0)	/* Ignore break condition.  */ | 
|  | 116 | #define	BRKINT	(1 << 1)	/* Signal interrupt on break.  */ | 
|  | 117 | #define	IGNPAR	(1 << 2)	/* Ignore characters with parity errors.  */ | 
|  | 118 | #define	PARMRK	(1 << 3)	/* Mark parity and framing errors.  */ | 
|  | 119 | #define	INPCK	(1 << 4)	/* Enable input parity check.  */ | 
|  | 120 | #define	ISTRIP	(1 << 5)	/* Strip 8th bit off characters.  */ | 
|  | 121 | #define	INLCR	(1 << 6)	/* Map NL to CR on input.  */ | 
|  | 122 | #define	IGNCR	(1 << 7)	/* Ignore CR.  */ | 
|  | 123 | #define	ICRNL	(1 << 8)	/* Map CR to NL on input.  */ | 
|  | 124 | #define	IXON	(1 << 9)	/* Enable start/stop output control.  */ | 
|  | 125 | #define	IXOFF	(1 << 10)	/* Enable start/stop input control.  */ | 
|  | 126 | #if defined __USE_MISC || defined __USE_UNIX98 | 
|  | 127 | # define IXANY	(1 << 11)	/* Any character will restart after stop.  */ | 
|  | 128 | #endif | 
|  | 129 | #ifdef	__USE_MISC | 
|  | 130 | # define IMAXBEL (1 << 13)	/* Ring bell when input queue is full.  */ | 
|  | 131 | #endif | 
|  | 132 | #ifdef __USE_GNU | 
|  | 133 | # define IUCLC	(1 << 14)	/* Translate upper case input to lower case. */ | 
|  | 134 | #endif | 
|  | 135 |  | 
|  | 136 | /* Output modes.  */ | 
|  | 137 | tcflag_t c_oflag; | 
|  | 138 | #define	OPOST	(1 << 0)	/* Perform output processing.  */ | 
|  | 139 | #if defined __USE_MISC || defined __USE_XOPEN | 
|  | 140 | # define ONLCR	(1 << 1)	/* Map NL to CR-NL on output.  */ | 
|  | 141 | #endif | 
|  | 142 | #ifdef	__USE_MISC | 
|  | 143 | # define OXTABS	TAB3		/* Expand tabs to spaces.  */ | 
|  | 144 | # define ONOEOT	(1 << 3)	/* Discard EOT (^D) on output.  */ | 
|  | 145 | #endif | 
|  | 146 | #if defined __USE_MISC || defined __USE_XOPEN | 
|  | 147 | # define OCRNL	(1 << 4)	/* Map CR to NL.  */ | 
|  | 148 | # define ONOCR	(1 << 5)	/* Discard CR's when on column 0.  */ | 
|  | 149 | # define ONLRET	(1 << 6)	/* Move to column 0 on NL.  */ | 
|  | 150 | #endif | 
|  | 151 | #if defined __USE_MISC || defined __USE_XOPEN | 
|  | 152 | # define NLDLY	(3 << 8)	/* NL delay.  */ | 
|  | 153 | # define NL0	(0 << 8)	/* NL type 0.  */ | 
|  | 154 | # define NL1	(1 << 8)	/* NL type 1.  */ | 
|  | 155 | # define TABDLY	(3 << 10)	/* TAB delay.  */ | 
|  | 156 | # define TAB0	(0 << 10)	/* TAB delay type 0.  */ | 
|  | 157 | # define TAB1	(1 << 10)	/* TAB delay type 1.  */ | 
|  | 158 | # define TAB2	(2 << 10)	/* TAB delay type 2.  */ | 
|  | 159 | # define TAB3	(1 << 2)	/* Expand tabs to spaces.  */ | 
|  | 160 | # define CRDLY	(3 << 12)	/* CR delay.  */ | 
|  | 161 | # define CR0	(0 << 12)	/* CR delay type 0.  */ | 
|  | 162 | # define CR1	(1 << 12)	/* CR delay type 1.  */ | 
|  | 163 | # define CR2	(2 << 12)	/* CR delay type 2.  */ | 
|  | 164 | # define CR3	(3 << 12)	/* CR delay type 3.  */ | 
|  | 165 | # define FFDLY	(1 << 14)	/* FF delay.  */ | 
|  | 166 | # define FF0	(0 << 14)	/* FF delay type 0.  */ | 
|  | 167 | # define FF1	(1 << 14)	/* FF delay type 1.  */ | 
|  | 168 | # define BSDLY	(1 << 15)	/* BS delay.  */ | 
|  | 169 | # define BS0	(0 << 15)	/* BS delay type 0.  */ | 
|  | 170 | # define BS1	(1 << 15)	/* BS delay type 1.  */ | 
|  | 171 | # define VTDLY	(1 << 16)	/* VT delay.  */ | 
|  | 172 | # define VT0	(0 << 16)	/* VT delay type 0.  */ | 
|  | 173 | # define VT1	(1 << 16)	/* VT delay type 1.  */ | 
|  | 174 | #endif /* __USE_MISC || __USE_XOPEN */ | 
|  | 175 | #ifdef __USE_GNU | 
|  | 176 | # define OLCUC	(1 << 17)	/* Translate lower case output to upper case */ | 
|  | 177 | #endif | 
|  | 178 | #ifdef __USE_XOPEN | 
|  | 179 | # define OFILL	(1 << 18)	/* Send fill characters for delays.  */ | 
|  | 180 | #endif | 
|  | 181 |  | 
|  | 182 | /* Control modes.  */ | 
|  | 183 | tcflag_t c_cflag; | 
|  | 184 | #ifdef	__USE_MISC | 
|  | 185 | # define CIGNORE	(1 << 0)	/* Ignore these control flags.  */ | 
|  | 186 | #endif | 
|  | 187 | #define	CSIZE	(CS5|CS6|CS7|CS8)	/* Number of bits per byte (mask).  */ | 
|  | 188 | #define	CS5	0		/* 5 bits per byte.  */ | 
|  | 189 | #define	CS6	(1 << 8)	/* 6 bits per byte.  */ | 
|  | 190 | #define	CS7	(1 << 9)	/* 7 bits per byte.  */ | 
|  | 191 | #define	CS8	(CS6|CS7)	/* 8 bits per byte.  */ | 
|  | 192 | #define	CSTOPB	(1 << 10)	/* Two stop bits instead of one.  */ | 
|  | 193 | #define	CREAD	(1 << 11)	/* Enable receiver.  */ | 
|  | 194 | #define	PARENB	(1 << 12)	/* Parity enable.  */ | 
|  | 195 | #define	PARODD	(1 << 13)	/* Odd parity instead of even.  */ | 
|  | 196 | #define	HUPCL	(1 << 14)	/* Hang up on last close.  */ | 
|  | 197 | #define	CLOCAL	(1 << 15)	/* Ignore modem status lines.  */ | 
|  | 198 | #ifdef	__USE_MISC | 
|  | 199 | # define CRTSCTS	(1 << 16)	/* RTS/CTS flow control.  */ | 
|  | 200 | # define CRTS_IFLOW	CRTSCTS		/* Compatibility.  */ | 
|  | 201 | # define CCTS_OFLOW	CRTSCTS		/* Compatibility.  */ | 
|  | 202 | # define CDTRCTS	(1 << 17)	/* DTR/CTS flow control.  */ | 
|  | 203 | # define MDMBUF		(1 << 20)	/* DTR/DCD flow control.  */ | 
|  | 204 | # define CHWFLOW	(MDMBUF|CRTSCTS|CDTRCTS) /* All types of flow control.  */ | 
|  | 205 | #endif | 
|  | 206 |  | 
|  | 207 | /* Local modes.  */ | 
|  | 208 | tcflag_t c_lflag; | 
|  | 209 | #ifdef	__USE_MISC | 
|  | 210 | # define ECHOKE	(1 << 0)	/* Visual erase for KILL.  */ | 
|  | 211 | #endif | 
|  | 212 | #define	_ECHOE	(1 << 1)	/* Visual erase for ERASE.  */ | 
|  | 213 | #define	ECHOE	_ECHOE | 
|  | 214 | #define	_ECHOK	(1 << 2)	/* Echo NL after KILL.  */ | 
|  | 215 | #define	ECHOK	_ECHOK | 
|  | 216 | #define	_ECHO	(1 << 3)	/* Enable echo.  */ | 
|  | 217 | #define	ECHO	_ECHO | 
|  | 218 | #define	_ECHONL	(1 << 4)	/* Echo NL even if ECHO is off.  */ | 
|  | 219 | #define	ECHONL	_ECHONL | 
|  | 220 | #ifdef	__USE_MISC | 
|  | 221 | # define ECHOPRT	(1 << 5)	/* Hardcopy visual erase.  */ | 
|  | 222 | # define ECHOCTL	(1 << 6)	/* Echo control characters as ^X.  */ | 
|  | 223 | #endif | 
|  | 224 | #define	_ISIG	(1 << 7)	/* Enable signals.  */ | 
|  | 225 | #define	ISIG	_ISIG | 
|  | 226 | #define	_ICANON	(1 << 8)	/* Do erase and kill processing.  */ | 
|  | 227 | #define	ICANON	_ICANON | 
|  | 228 | #ifdef	__USE_MISC | 
|  | 229 | # define ALTWERASE (1 << 9)	/* Alternate WERASE algorithm.  */ | 
|  | 230 | #endif | 
|  | 231 | #define	_IEXTEN	(1 << 10)	/* Enable DISCARD and LNEXT.  */ | 
|  | 232 | #define	IEXTEN	_IEXTEN | 
|  | 233 | #ifdef	__USE_MISC | 
|  | 234 | # define EXTPROC	(1 << 11)	/* External processing.  */ | 
|  | 235 | #endif | 
|  | 236 | #define	_TOSTOP	(1 << 22)	/* Send SIGTTOU for background output.  */ | 
|  | 237 | #define	TOSTOP	_TOSTOP | 
|  | 238 | #ifdef	__USE_MISC | 
|  | 239 | # define FLUSHO	(1 << 23)	/* Output being flushed (state).  */ | 
|  | 240 | # define NOKERNINFO (1 << 25)	/* Disable VSTATUS.  */ | 
|  | 241 | # define PENDIN	(1 << 29)	/* Retype pending input (state).  */ | 
|  | 242 | #endif | 
|  | 243 | #define	_NOFLSH	(1 << 31)	/* Disable flush after interrupt.  */ | 
|  | 244 | #define	NOFLSH	_NOFLSH | 
|  | 245 |  | 
|  | 246 | /* Control characters.  */ | 
|  | 247 | #define	VEOF	0		/* End-of-file character [ICANON].  */ | 
|  | 248 | #define	VEOL	1		/* End-of-line character [ICANON].  */ | 
|  | 249 | #ifdef	__USE_MISC | 
|  | 250 | # define VEOL2	2		/* Second EOL character [ICANON].  */ | 
|  | 251 | #endif | 
|  | 252 | #define	VERASE	3		/* Erase character [ICANON].  */ | 
|  | 253 | #ifdef	__USE_MISC | 
|  | 254 | # define VWERASE	4		/* Word-erase character [ICANON].  */ | 
|  | 255 | #endif | 
|  | 256 | #define	VKILL	5		/* Kill-line character [ICANON].  */ | 
|  | 257 | #ifdef	__USE_MISC | 
|  | 258 | # define VREPRINT 6		/* Reprint-line character [ICANON].  */ | 
|  | 259 | #endif | 
|  | 260 | #define	VINTR	8		/* Interrupt character [ISIG].  */ | 
|  | 261 | #define	VQUIT	9		/* Quit character [ISIG].  */ | 
|  | 262 | #define	VSUSP	10		/* Suspend character [ISIG].  */ | 
|  | 263 | #ifdef	__USE_MISC | 
|  | 264 | # define VDSUSP	11		/* Delayed suspend character [ISIG].  */ | 
|  | 265 | #endif | 
|  | 266 | #define	VSTART	12		/* Start (X-ON) character [IXON, IXOFF].  */ | 
|  | 267 | #define	VSTOP	13		/* Stop (X-OFF) character [IXON, IXOFF].  */ | 
|  | 268 | #ifdef	__USE_MISC | 
|  | 269 | # define VLNEXT	14		/* Literal-next character [IEXTEN].  */ | 
|  | 270 | # define VDISCARD 15		/* Discard character [IEXTEN].  */ | 
|  | 271 | #endif | 
|  | 272 | #define	VMIN	16		/* Minimum number of bytes read at once [!ICANON].  */ | 
|  | 273 | #define	VTIME	17		/* Time-out value (tenths of a second) [!ICANON].  */ | 
|  | 274 | #ifdef	__USE_MISC | 
|  | 275 | # define VSTATUS	18		/* Status character [ICANON].  */ | 
|  | 276 | #endif | 
|  | 277 | #define	NCCS	20		/* Value duplicated in <hurd/tioctl.defs>.  */ | 
|  | 278 | cc_t c_cc[NCCS]; | 
|  | 279 |  | 
|  | 280 | /* Input and output baud rates.  */ | 
|  | 281 | speed_t __ispeed, __ospeed; | 
|  | 282 | #define	B0	0		/* Hang up.  */ | 
|  | 283 | #define	B50	50		/* 50 baud.  */ | 
|  | 284 | #define	B75	75		/* 75 baud.  */ | 
|  | 285 | #define	B110	110		/* 110 baud.  */ | 
|  | 286 | #define	B134	134		/* 134.5 baud.  */ | 
|  | 287 | #define	B150	150		/* 150 baud.  */ | 
|  | 288 | #define	B200	200		/* 200 baud.  */ | 
|  | 289 | #define	B300	300		/* 300 baud.  */ | 
|  | 290 | #define	B600	600		/* 600 baud.  */ | 
|  | 291 | #define	B1200	1200		/* 1200 baud.  */ | 
|  | 292 | #define	B1800	1800		/* 1800 baud.  */ | 
|  | 293 | #define	B2400	2400		/* 2400 baud.  */ | 
|  | 294 | #define	B4800	4800		/* 4800 baud.  */ | 
|  | 295 | #define	B9600	9600		/* 9600 baud.  */ | 
|  | 296 | #define	B7200	7200		/* 7200 baud.  */ | 
|  | 297 | #define	B14400	14400		/* 14400 baud.  */ | 
|  | 298 | #define	B19200	19200		/* 19200 baud.  */ | 
|  | 299 | #define	B28800	28800		/* 28800 baud.  */ | 
|  | 300 | #define	B38400	38400		/* 38400 baud.  */ | 
|  | 301 | #ifdef	__USE_MISC | 
|  | 302 | # define EXTA	19200 | 
|  | 303 | # define EXTB	38400 | 
|  | 304 | #endif | 
|  | 305 | #define	B57600	57600 | 
|  | 306 | #define	B76800	76800 | 
|  | 307 | #define	B115200	115200 | 
|  | 308 | #define	B230400	230400 | 
|  | 309 | #define	B460800	460800 | 
|  | 310 | #define	B500000	500000 | 
|  | 311 | #define	B576000	576000 | 
|  | 312 | #define	B921600	921600 | 
|  | 313 | #define	B1000000 1000000 | 
|  | 314 | #define	B1152000 1152000 | 
|  | 315 | #define	B1500000 1500000 | 
|  | 316 | #define	B2000000 2000000 | 
|  | 317 | #define	B2500000 2500000 | 
|  | 318 | #define	B3000000 3000000 | 
|  | 319 | #define	B3500000 3500000 | 
|  | 320 | #define	B4000000 4000000 | 
|  | 321 | }; | 
|  | 322 |  | 
|  | 323 | #define _IOT_termios /* Hurd ioctl type field.  */ \ | 
|  | 324 | _IOT (_IOTS (tcflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2) | 
|  | 325 |  | 
|  | 326 | /* Values for the OPTIONAL_ACTIONS argument to `tcsetattr'.  */ | 
|  | 327 | #define	TCSANOW		0	/* Change immediately.  */ | 
|  | 328 | #define	TCSADRAIN	1	/* Change when pending output is written.  */ | 
|  | 329 | #define	TCSAFLUSH	2	/* Flush pending input before changing.  */ | 
|  | 330 | #ifdef	__USE_MISC | 
|  | 331 | # define TCSASOFT	0x10	/* Flag: Don't alter hardware state.  */ | 
|  | 332 | #endif | 
|  | 333 |  | 
|  | 334 | /* Values for the QUEUE_SELECTOR argument to `tcflush'.  */ | 
|  | 335 | #define	TCIFLUSH	1	/* Discard data received but not yet read.  */ | 
|  | 336 | #define	TCOFLUSH	2	/* Discard data written but not yet sent.  */ | 
|  | 337 | #define	TCIOFLUSH	3	/* Discard all pending data.  */ | 
|  | 338 |  | 
|  | 339 | /* Values for the ACTION argument to `tcflow'.  */ | 
|  | 340 | #define	TCOOFF	1		/* Suspend output.  */ | 
|  | 341 | #define	TCOON	2		/* Restart suspended output.  */ | 
|  | 342 | #define	TCIOFF	3		/* Send a STOP character.  */ | 
|  | 343 | #define	TCION	4		/* Send a START character.  */ |