1f14ad5faSEd Schouten /*- 2*51369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 3*51369649SPedro F. Giffuni * 4f14ad5faSEd Schouten * Copyright (c) 1988, 1989, 1993, 1994 5f14ad5faSEd Schouten * The Regents of the University of California. All rights reserved. 6f14ad5faSEd Schouten * 7f14ad5faSEd Schouten * Redistribution and use in source and binary forms, with or without 8f14ad5faSEd Schouten * modification, are permitted provided that the following conditions 9f14ad5faSEd Schouten * are met: 10f14ad5faSEd Schouten * 1. Redistributions of source code must retain the above copyright 11f14ad5faSEd Schouten * notice, this list of conditions and the following disclaimer. 12f14ad5faSEd Schouten * 2. Redistributions in binary form must reproduce the above copyright 13f14ad5faSEd Schouten * notice, this list of conditions and the following disclaimer in the 14f14ad5faSEd Schouten * documentation and/or other materials provided with the distribution. 15fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors 16f14ad5faSEd Schouten * may be used to endorse or promote products derived from this software 17f14ad5faSEd Schouten * without specific prior written permission. 18f14ad5faSEd Schouten * 19f14ad5faSEd Schouten * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20f14ad5faSEd Schouten * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21f14ad5faSEd Schouten * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22f14ad5faSEd Schouten * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23f14ad5faSEd Schouten * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24f14ad5faSEd Schouten * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25f14ad5faSEd Schouten * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26f14ad5faSEd Schouten * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27f14ad5faSEd Schouten * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28f14ad5faSEd Schouten * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29f14ad5faSEd Schouten * SUCH DAMAGE. 30f14ad5faSEd Schouten * 31f14ad5faSEd Schouten * @(#)termios.h 8.3 (Berkeley) 3/28/94 32f14ad5faSEd Schouten * $FreeBSD$ 33f14ad5faSEd Schouten */ 34f14ad5faSEd Schouten 35f14ad5faSEd Schouten #ifndef _SYS__TERMIOS_H_ 36f14ad5faSEd Schouten #define _SYS__TERMIOS_H_ 37f14ad5faSEd Schouten 38f14ad5faSEd Schouten /* 39f14ad5faSEd Schouten * Special Control Characters 40f14ad5faSEd Schouten * 41f14ad5faSEd Schouten * Index into c_cc[] character array. 42f14ad5faSEd Schouten * 43f14ad5faSEd Schouten * Name Subscript Enabled by 44f14ad5faSEd Schouten */ 45f14ad5faSEd Schouten #define VEOF 0 /* ICANON */ 46f14ad5faSEd Schouten #define VEOL 1 /* ICANON */ 47a07c3aebSKonstantin Belousov #if __BSD_VISIBLE 48f14ad5faSEd Schouten #define VEOL2 2 /* ICANON together with IEXTEN */ 49f14ad5faSEd Schouten #endif 50f14ad5faSEd Schouten #define VERASE 3 /* ICANON */ 51a07c3aebSKonstantin Belousov #if __BSD_VISIBLE 52f14ad5faSEd Schouten #define VWERASE 4 /* ICANON together with IEXTEN */ 53f14ad5faSEd Schouten #endif 54f14ad5faSEd Schouten #define VKILL 5 /* ICANON */ 55a07c3aebSKonstantin Belousov #if __BSD_VISIBLE 56f14ad5faSEd Schouten #define VREPRINT 6 /* ICANON together with IEXTEN */ 57f14ad5faSEd Schouten #define VERASE2 7 /* ICANON */ 58f14ad5faSEd Schouten #endif 59f14ad5faSEd Schouten /* 7 ex-spare 1 */ 60f14ad5faSEd Schouten #define VINTR 8 /* ISIG */ 61f14ad5faSEd Schouten #define VQUIT 9 /* ISIG */ 62f14ad5faSEd Schouten #define VSUSP 10 /* ISIG */ 63a07c3aebSKonstantin Belousov #if __BSD_VISIBLE 64f14ad5faSEd Schouten #define VDSUSP 11 /* ISIG together with IEXTEN */ 65f14ad5faSEd Schouten #endif 66f14ad5faSEd Schouten #define VSTART 12 /* IXON, IXOFF */ 67f14ad5faSEd Schouten #define VSTOP 13 /* IXON, IXOFF */ 68a07c3aebSKonstantin Belousov #if __BSD_VISIBLE 69f14ad5faSEd Schouten #define VLNEXT 14 /* IEXTEN */ 70f14ad5faSEd Schouten #define VDISCARD 15 /* IEXTEN */ 71f14ad5faSEd Schouten #endif 72f14ad5faSEd Schouten #define VMIN 16 /* !ICANON */ 73f14ad5faSEd Schouten #define VTIME 17 /* !ICANON */ 74a07c3aebSKonstantin Belousov #if __BSD_VISIBLE 75f14ad5faSEd Schouten #define VSTATUS 18 /* ICANON together with IEXTEN */ 76f14ad5faSEd Schouten /* 19 spare 2 */ 77f14ad5faSEd Schouten #endif 78f14ad5faSEd Schouten #define NCCS 20 79f14ad5faSEd Schouten 80f14ad5faSEd Schouten #define _POSIX_VDISABLE 0xff 81f14ad5faSEd Schouten 82f14ad5faSEd Schouten /* 83f14ad5faSEd Schouten * Input flags - software input processing 84f14ad5faSEd Schouten */ 85f14ad5faSEd Schouten #define IGNBRK 0x00000001 /* ignore BREAK condition */ 86f14ad5faSEd Schouten #define BRKINT 0x00000002 /* map BREAK to SIGINTR */ 87f14ad5faSEd Schouten #define IGNPAR 0x00000004 /* ignore (discard) parity errors */ 88f14ad5faSEd Schouten #define PARMRK 0x00000008 /* mark parity and framing errors */ 89f14ad5faSEd Schouten #define INPCK 0x00000010 /* enable checking of parity errors */ 90f14ad5faSEd Schouten #define ISTRIP 0x00000020 /* strip 8th bit off chars */ 91f14ad5faSEd Schouten #define INLCR 0x00000040 /* map NL into CR */ 92f14ad5faSEd Schouten #define IGNCR 0x00000080 /* ignore CR */ 93f14ad5faSEd Schouten #define ICRNL 0x00000100 /* map CR to NL (ala CRMOD) */ 94f14ad5faSEd Schouten #define IXON 0x00000200 /* enable output flow control */ 95f14ad5faSEd Schouten #define IXOFF 0x00000400 /* enable input flow control */ 964e93dbdfSKonstantin Belousov #if __XSI_VISIBLE || __POSIX_VISIBLE >= 200809 97f14ad5faSEd Schouten #define IXANY 0x00000800 /* any char will restart after stop */ 984e93dbdfSKonstantin Belousov #endif 994e93dbdfSKonstantin Belousov #if __BSD_VISIBLE 100f14ad5faSEd Schouten #define IMAXBEL 0x00002000 /* ring bell on input queue full */ 101a07c3aebSKonstantin Belousov #endif 102f14ad5faSEd Schouten 103f14ad5faSEd Schouten /* 104f14ad5faSEd Schouten * Output flags - software output processing 105f14ad5faSEd Schouten */ 106f14ad5faSEd Schouten #define OPOST 0x00000001 /* enable following output processing */ 1074e93dbdfSKonstantin Belousov #if __XSI_VISIBLE 108f14ad5faSEd Schouten #define ONLCR 0x00000002 /* map NL to CR-NL (ala CRMOD) */ 1094e93dbdfSKonstantin Belousov #endif 1104e93dbdfSKonstantin Belousov #if __BSD_VISIBLE 111f14ad5faSEd Schouten #define TABDLY 0x00000004 /* tab delay mask */ 112f14ad5faSEd Schouten #define TAB0 0x00000000 /* no tab delay and expansion */ 113f14ad5faSEd Schouten #define TAB3 0x00000004 /* expand tabs to spaces */ 114f14ad5faSEd Schouten #define ONOEOT 0x00000008 /* discard EOT's (^D) on output) */ 1154e93dbdfSKonstantin Belousov #endif 1164e93dbdfSKonstantin Belousov #if __XSI_VISIBLE 117f14ad5faSEd Schouten #define OCRNL 0x00000010 /* map CR to NL on output */ 118f14ad5faSEd Schouten #define ONOCR 0x00000020 /* no CR output at column 0 */ 119f14ad5faSEd Schouten #define ONLRET 0x00000040 /* NL performs CR function */ 120a07c3aebSKonstantin Belousov #endif 121f14ad5faSEd Schouten 122f14ad5faSEd Schouten /* 123f14ad5faSEd Schouten * Control flags - hardware control of terminal 124f14ad5faSEd Schouten */ 125a07c3aebSKonstantin Belousov #if __BSD_VISIBLE 126f14ad5faSEd Schouten #define CIGNORE 0x00000001 /* ignore control flags */ 127f14ad5faSEd Schouten #endif 128f14ad5faSEd Schouten #define CSIZE 0x00000300 /* character size mask */ 129f14ad5faSEd Schouten #define CS5 0x00000000 /* 5 bits (pseudo) */ 130f14ad5faSEd Schouten #define CS6 0x00000100 /* 6 bits */ 131f14ad5faSEd Schouten #define CS7 0x00000200 /* 7 bits */ 132f14ad5faSEd Schouten #define CS8 0x00000300 /* 8 bits */ 133f14ad5faSEd Schouten #define CSTOPB 0x00000400 /* send 2 stop bits */ 134f14ad5faSEd Schouten #define CREAD 0x00000800 /* enable receiver */ 135f14ad5faSEd Schouten #define PARENB 0x00001000 /* parity enable */ 136f14ad5faSEd Schouten #define PARODD 0x00002000 /* odd parity, else even */ 137f14ad5faSEd Schouten #define HUPCL 0x00004000 /* hang up on last close */ 138f14ad5faSEd Schouten #define CLOCAL 0x00008000 /* ignore modem status lines */ 139a07c3aebSKonstantin Belousov #if __BSD_VISIBLE 140f14ad5faSEd Schouten #define CCTS_OFLOW 0x00010000 /* CTS flow control of output */ 141f14ad5faSEd Schouten #define CRTSCTS (CCTS_OFLOW | CRTS_IFLOW) 142f14ad5faSEd Schouten #define CRTS_IFLOW 0x00020000 /* RTS flow control of input */ 143f14ad5faSEd Schouten #define CDTR_IFLOW 0x00040000 /* DTR flow control of input */ 144f14ad5faSEd Schouten #define CDSR_OFLOW 0x00080000 /* DSR flow control of output */ 145f14ad5faSEd Schouten #define CCAR_OFLOW 0x00100000 /* DCD flow control of output */ 146f14ad5faSEd Schouten #endif 147f14ad5faSEd Schouten 148f14ad5faSEd Schouten 149f14ad5faSEd Schouten /* 150f14ad5faSEd Schouten * "Local" flags - dumping ground for other state 151f14ad5faSEd Schouten * 152f14ad5faSEd Schouten * Warning: some flags in this structure begin with 153f14ad5faSEd Schouten * the letter "I" and look like they belong in the 154f14ad5faSEd Schouten * input flag. 155f14ad5faSEd Schouten */ 156f14ad5faSEd Schouten 157a07c3aebSKonstantin Belousov #if __BSD_VISIBLE 158f14ad5faSEd Schouten #define ECHOKE 0x00000001 /* visual erase for line kill */ 159a07c3aebSKonstantin Belousov #endif 160f14ad5faSEd Schouten #define ECHOE 0x00000002 /* visually erase chars */ 161f14ad5faSEd Schouten #define ECHOK 0x00000004 /* echo NL after line kill */ 162f14ad5faSEd Schouten #define ECHO 0x00000008 /* enable echoing */ 163f14ad5faSEd Schouten #define ECHONL 0x00000010 /* echo NL even if ECHO is off */ 164a07c3aebSKonstantin Belousov #if __BSD_VISIBLE 165f14ad5faSEd Schouten #define ECHOPRT 0x00000020 /* visual erase mode for hardcopy */ 166f14ad5faSEd Schouten #define ECHOCTL 0x00000040 /* echo control chars as ^(Char) */ 167a07c3aebSKonstantin Belousov #endif 168f14ad5faSEd Schouten #define ISIG 0x00000080 /* enable signals INTR, QUIT, [D]SUSP */ 169f14ad5faSEd Schouten #define ICANON 0x00000100 /* canonicalize input lines */ 170a07c3aebSKonstantin Belousov #if __BSD_VISIBLE 171f14ad5faSEd Schouten #define ALTWERASE 0x00000200 /* use alternate WERASE algorithm */ 172a07c3aebSKonstantin Belousov #endif 173f14ad5faSEd Schouten #define IEXTEN 0x00000400 /* enable DISCARD and LNEXT */ 174f14ad5faSEd Schouten #define EXTPROC 0x00000800 /* external processing */ 175f14ad5faSEd Schouten #define TOSTOP 0x00400000 /* stop background jobs from output */ 176a07c3aebSKonstantin Belousov #if __BSD_VISIBLE 177f14ad5faSEd Schouten #define FLUSHO 0x00800000 /* output being flushed (state) */ 178f14ad5faSEd Schouten #define NOKERNINFO 0x02000000 /* no kernel output from VSTATUS */ 179f14ad5faSEd Schouten #define PENDIN 0x20000000 /* XXX retype pending input (state) */ 180a07c3aebSKonstantin Belousov #endif 181f14ad5faSEd Schouten #define NOFLSH 0x80000000 /* don't flush after interrupt */ 182f14ad5faSEd Schouten 183f14ad5faSEd Schouten /* 184f14ad5faSEd Schouten * Standard speeds 185f14ad5faSEd Schouten */ 186f14ad5faSEd Schouten #define B0 0 187f14ad5faSEd Schouten #define B50 50 188f14ad5faSEd Schouten #define B75 75 189f14ad5faSEd Schouten #define B110 110 190f14ad5faSEd Schouten #define B134 134 191f14ad5faSEd Schouten #define B150 150 192f14ad5faSEd Schouten #define B200 200 193f14ad5faSEd Schouten #define B300 300 194f14ad5faSEd Schouten #define B600 600 195f14ad5faSEd Schouten #define B1200 1200 196f14ad5faSEd Schouten #define B1800 1800 197f14ad5faSEd Schouten #define B2400 2400 198f14ad5faSEd Schouten #define B4800 4800 199f14ad5faSEd Schouten #define B9600 9600 200f14ad5faSEd Schouten #define B19200 19200 201f14ad5faSEd Schouten #define B38400 38400 202a07c3aebSKonstantin Belousov #if __BSD_VISIBLE 203f14ad5faSEd Schouten #define B7200 7200 204f14ad5faSEd Schouten #define B14400 14400 205f14ad5faSEd Schouten #define B28800 28800 206f14ad5faSEd Schouten #define B57600 57600 207f14ad5faSEd Schouten #define B76800 76800 208f14ad5faSEd Schouten #define B115200 115200 209f14ad5faSEd Schouten #define B230400 230400 210f14ad5faSEd Schouten #define B460800 460800 211f14ad5faSEd Schouten #define B921600 921600 212f14ad5faSEd Schouten #define EXTA 19200 213f14ad5faSEd Schouten #define EXTB 38400 214a07c3aebSKonstantin Belousov #endif 215f14ad5faSEd Schouten 216f14ad5faSEd Schouten typedef unsigned int tcflag_t; 217f14ad5faSEd Schouten typedef unsigned char cc_t; 218f14ad5faSEd Schouten typedef unsigned int speed_t; 219f14ad5faSEd Schouten 220f14ad5faSEd Schouten struct termios { 221f14ad5faSEd Schouten tcflag_t c_iflag; /* input flags */ 222f14ad5faSEd Schouten tcflag_t c_oflag; /* output flags */ 223f14ad5faSEd Schouten tcflag_t c_cflag; /* control flags */ 224f14ad5faSEd Schouten tcflag_t c_lflag; /* local flags */ 225f14ad5faSEd Schouten cc_t c_cc[NCCS]; /* control chars */ 226f14ad5faSEd Schouten speed_t c_ispeed; /* input speed */ 227f14ad5faSEd Schouten speed_t c_ospeed; /* output speed */ 228f14ad5faSEd Schouten }; 229f14ad5faSEd Schouten 230f14ad5faSEd Schouten #endif /* !_SYS__TERMIOS_H_ */ 231