termios.h revision 35755
11541Srgrimes/* 21541Srgrimes * Copyright (c) 1988, 1989, 1993, 1994 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * Redistribution and use in source and binary forms, with or without 61541Srgrimes * modification, are permitted provided that the following conditions 71541Srgrimes * are met: 81541Srgrimes * 1. Redistributions of source code must retain the above copyright 91541Srgrimes * notice, this list of conditions and the following disclaimer. 101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111541Srgrimes * notice, this list of conditions and the following disclaimer in the 121541Srgrimes * documentation and/or other materials provided with the distribution. 131541Srgrimes * 3. All advertising materials mentioning features or use of this software 141541Srgrimes * must display the following acknowledgement: 151541Srgrimes * This product includes software developed by the University of 161541Srgrimes * California, Berkeley and its contributors. 171541Srgrimes * 4. Neither the name of the University nor the names of its contributors 181541Srgrimes * may be used to endorse or promote products derived from this software 191541Srgrimes * without specific prior written permission. 201541Srgrimes * 211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311541Srgrimes * SUCH DAMAGE. 321541Srgrimes * 331541Srgrimes * @(#)termios.h 8.3 (Berkeley) 3/28/94 3435755Sjb * $Id: termios.h,v 1.10 1998/03/12 14:09:53 bde Exp $ 351541Srgrimes */ 361541Srgrimes 371541Srgrimes#ifndef _SYS_TERMIOS_H_ 381541Srgrimes#define _SYS_TERMIOS_H_ 391541Srgrimes 408876Srgrimes/* 418876Srgrimes * Special Control Characters 421541Srgrimes * 431541Srgrimes * Index into c_cc[] character array. 441541Srgrimes * 458876Srgrimes * Name Subscript Enabled by 461541Srgrimes */ 471541Srgrimes#define VEOF 0 /* ICANON */ 481541Srgrimes#define VEOL 1 /* ICANON */ 491541Srgrimes#ifndef _POSIX_SOURCE 5020020Sbde#define VEOL2 2 /* ICANON together with IEXTEN */ 511541Srgrimes#endif 521541Srgrimes#define VERASE 3 /* ICANON */ 531541Srgrimes#ifndef _POSIX_SOURCE 5420020Sbde#define VWERASE 4 /* ICANON together with IEXTEN */ 558876Srgrimes#endif 561541Srgrimes#define VKILL 5 /* ICANON */ 571541Srgrimes#ifndef _POSIX_SOURCE 5820020Sbde#define VREPRINT 6 /* ICANON together with IEXTEN */ 591541Srgrimes#endif 601541Srgrimes/* 7 spare 1 */ 611541Srgrimes#define VINTR 8 /* ISIG */ 621541Srgrimes#define VQUIT 9 /* ISIG */ 631541Srgrimes#define VSUSP 10 /* ISIG */ 641541Srgrimes#ifndef _POSIX_SOURCE 6520020Sbde#define VDSUSP 11 /* ISIG together with IEXTEN */ 661541Srgrimes#endif 671541Srgrimes#define VSTART 12 /* IXON, IXOFF */ 681541Srgrimes#define VSTOP 13 /* IXON, IXOFF */ 691541Srgrimes#ifndef _POSIX_SOURCE 701541Srgrimes#define VLNEXT 14 /* IEXTEN */ 711541Srgrimes#define VDISCARD 15 /* IEXTEN */ 721541Srgrimes#endif 731541Srgrimes#define VMIN 16 /* !ICANON */ 741541Srgrimes#define VTIME 17 /* !ICANON */ 751541Srgrimes#ifndef _POSIX_SOURCE 7620020Sbde#define VSTATUS 18 /* ICANON together with IEXTEN */ 771541Srgrimes/* 19 spare 2 */ 781541Srgrimes#endif 791541Srgrimes#define NCCS 20 801541Srgrimes 818449Sbde#define _POSIX_VDISABLE 0xff 821541Srgrimes 831541Srgrimes#ifndef _POSIX_SOURCE 848449Sbde#define CCEQ(val, c) ((c) == (val) ? (val) != _POSIX_VDISABLE : 0) 851541Srgrimes#endif 861541Srgrimes 871541Srgrimes/* 881541Srgrimes * Input flags - software input processing 891541Srgrimes */ 901541Srgrimes#define IGNBRK 0x00000001 /* ignore BREAK condition */ 911541Srgrimes#define BRKINT 0x00000002 /* map BREAK to SIGINTR */ 921541Srgrimes#define IGNPAR 0x00000004 /* ignore (discard) parity errors */ 931541Srgrimes#define PARMRK 0x00000008 /* mark parity and framing errors */ 941541Srgrimes#define INPCK 0x00000010 /* enable checking of parity errors */ 951541Srgrimes#define ISTRIP 0x00000020 /* strip 8th bit off chars */ 961541Srgrimes#define INLCR 0x00000040 /* map NL into CR */ 971541Srgrimes#define IGNCR 0x00000080 /* ignore CR */ 981541Srgrimes#define ICRNL 0x00000100 /* map CR to NL (ala CRMOD) */ 991541Srgrimes#define IXON 0x00000200 /* enable output flow control */ 1001541Srgrimes#define IXOFF 0x00000400 /* enable input flow control */ 1011541Srgrimes#ifndef _POSIX_SOURCE 1021541Srgrimes#define IXANY 0x00000800 /* any char will restart after stop */ 1031541Srgrimes#define IMAXBEL 0x00002000 /* ring bell on input queue full */ 1041541Srgrimes#endif /*_POSIX_SOURCE */ 1051541Srgrimes 1061541Srgrimes/* 1071541Srgrimes * Output flags - software output processing 1081541Srgrimes */ 1091541Srgrimes#define OPOST 0x00000001 /* enable following output processing */ 1101541Srgrimes#ifndef _POSIX_SOURCE 1111541Srgrimes#define ONLCR 0x00000002 /* map NL to CR-NL (ala CRMOD) */ 1121541Srgrimes#define OXTABS 0x00000004 /* expand tabs to spaces */ 1131541Srgrimes#define ONOEOT 0x00000008 /* discard EOT's (^D) on output) */ 1141541Srgrimes#endif /*_POSIX_SOURCE */ 1151541Srgrimes 1161541Srgrimes/* 1171541Srgrimes * Control flags - hardware control of terminal 1181541Srgrimes */ 1191541Srgrimes#ifndef _POSIX_SOURCE 1201541Srgrimes#define CIGNORE 0x00000001 /* ignore control flags */ 1211541Srgrimes#endif 1221541Srgrimes#define CSIZE 0x00000300 /* character size mask */ 1231541Srgrimes#define CS5 0x00000000 /* 5 bits (pseudo) */ 1241541Srgrimes#define CS6 0x00000100 /* 6 bits */ 1251541Srgrimes#define CS7 0x00000200 /* 7 bits */ 1261541Srgrimes#define CS8 0x00000300 /* 8 bits */ 1271541Srgrimes#define CSTOPB 0x00000400 /* send 2 stop bits */ 1281541Srgrimes#define CREAD 0x00000800 /* enable receiver */ 1291541Srgrimes#define PARENB 0x00001000 /* parity enable */ 1301541Srgrimes#define PARODD 0x00002000 /* odd parity, else even */ 1311541Srgrimes#define HUPCL 0x00004000 /* hang up on last close */ 1321541Srgrimes#define CLOCAL 0x00008000 /* ignore modem status lines */ 1331541Srgrimes#ifndef _POSIX_SOURCE 1341541Srgrimes#define CCTS_OFLOW 0x00010000 /* CTS flow control of output */ 1351549Srgrimes#define CRTSCTS (CCTS_OFLOW | CRTS_IFLOW) 1361541Srgrimes#define CRTS_IFLOW 0x00020000 /* RTS flow control of input */ 1378187Sbde#define CDTR_IFLOW 0x00040000 /* DTR flow control of input */ 1381549Srgrimes#define CDSR_OFLOW 0x00080000 /* DSR flow control of output */ 1398187Sbde#define CCAR_OFLOW 0x00100000 /* DCD flow control of output */ 1408187Sbde#define MDMBUF 0x00100000 /* old name for CCAR_OFLOW */ 1411541Srgrimes#endif 1421541Srgrimes 1431541Srgrimes 1448876Srgrimes/* 1451541Srgrimes * "Local" flags - dumping ground for other state 1461541Srgrimes * 1471541Srgrimes * Warning: some flags in this structure begin with 1481541Srgrimes * the letter "I" and look like they belong in the 1491541Srgrimes * input flag. 1501541Srgrimes */ 1511541Srgrimes 1521541Srgrimes#ifndef _POSIX_SOURCE 1531541Srgrimes#define ECHOKE 0x00000001 /* visual erase for line kill */ 1541541Srgrimes#endif /*_POSIX_SOURCE */ 1551541Srgrimes#define ECHOE 0x00000002 /* visually erase chars */ 1561541Srgrimes#define ECHOK 0x00000004 /* echo NL after line kill */ 1571541Srgrimes#define ECHO 0x00000008 /* enable echoing */ 1581541Srgrimes#define ECHONL 0x00000010 /* echo NL even if ECHO is off */ 1591541Srgrimes#ifndef _POSIX_SOURCE 1601541Srgrimes#define ECHOPRT 0x00000020 /* visual erase mode for hardcopy */ 1611541Srgrimes#define ECHOCTL 0x00000040 /* echo control chars as ^(Char) */ 1621541Srgrimes#endif /*_POSIX_SOURCE */ 1631541Srgrimes#define ISIG 0x00000080 /* enable signals INTR, QUIT, [D]SUSP */ 1641541Srgrimes#define ICANON 0x00000100 /* canonicalize input lines */ 1651541Srgrimes#ifndef _POSIX_SOURCE 1661541Srgrimes#define ALTWERASE 0x00000200 /* use alternate WERASE algorithm */ 1671541Srgrimes#endif /*_POSIX_SOURCE */ 1681541Srgrimes#define IEXTEN 0x00000400 /* enable DISCARD and LNEXT */ 1691541Srgrimes#define EXTPROC 0x00000800 /* external processing */ 1701541Srgrimes#define TOSTOP 0x00400000 /* stop background jobs from output */ 1711541Srgrimes#ifndef _POSIX_SOURCE 1721541Srgrimes#define FLUSHO 0x00800000 /* output being flushed (state) */ 1731541Srgrimes#define NOKERNINFO 0x02000000 /* no kernel output from VSTATUS */ 1741541Srgrimes#define PENDIN 0x20000000 /* XXX retype pending input (state) */ 1751541Srgrimes#endif /*_POSIX_SOURCE */ 1761541Srgrimes#define NOFLSH 0x80000000 /* don't flush after interrupt */ 1771541Srgrimes 17835755Sjbtypedef unsigned int tcflag_t; 1791541Srgrimestypedef unsigned char cc_t; 18035755Sjbtypedef unsigned int speed_t; 1811541Srgrimes 1821541Srgrimesstruct termios { 1831541Srgrimes tcflag_t c_iflag; /* input flags */ 1841541Srgrimes tcflag_t c_oflag; /* output flags */ 1851541Srgrimes tcflag_t c_cflag; /* control flags */ 1861541Srgrimes tcflag_t c_lflag; /* local flags */ 1871541Srgrimes cc_t c_cc[NCCS]; /* control chars */ 1888187Sbde speed_t c_ispeed; /* input speed */ 1898187Sbde speed_t c_ospeed; /* output speed */ 1901541Srgrimes}; 1911541Srgrimes 1928876Srgrimes/* 1931541Srgrimes * Commands passed to tcsetattr() for setting the termios structure. 1941541Srgrimes */ 1951541Srgrimes#define TCSANOW 0 /* make change immediate */ 1961541Srgrimes#define TCSADRAIN 1 /* drain output, then change */ 1971541Srgrimes#define TCSAFLUSH 2 /* drain output, flush input */ 1981541Srgrimes#ifndef _POSIX_SOURCE 1991541Srgrimes#define TCSASOFT 0x10 /* flag - don't alter h.w. state */ 2001541Srgrimes#endif 2011541Srgrimes 2021541Srgrimes/* 2031541Srgrimes * Standard speeds 2041541Srgrimes */ 2051541Srgrimes#define B0 0 2061541Srgrimes#define B50 50 2071541Srgrimes#define B75 75 2081541Srgrimes#define B110 110 2091541Srgrimes#define B134 134 2101541Srgrimes#define B150 150 2111541Srgrimes#define B200 200 2121541Srgrimes#define B300 300 2131541Srgrimes#define B600 600 2141541Srgrimes#define B1200 1200 2151541Srgrimes#define B1800 1800 2161541Srgrimes#define B2400 2400 2171541Srgrimes#define B4800 4800 2181541Srgrimes#define B9600 9600 2191541Srgrimes#define B19200 19200 2201541Srgrimes#define B38400 38400 2211541Srgrimes#ifndef _POSIX_SOURCE 2221541Srgrimes#define B7200 7200 2231541Srgrimes#define B14400 14400 2241541Srgrimes#define B28800 28800 2251541Srgrimes#define B57600 57600 2261541Srgrimes#define B76800 76800 2271541Srgrimes#define B115200 115200 2281541Srgrimes#define B230400 230400 2291541Srgrimes#define EXTA 19200 2301541Srgrimes#define EXTB 38400 2311541Srgrimes#endif /* !_POSIX_SOURCE */ 2321541Srgrimes 2331541Srgrimes#ifndef KERNEL 2341541Srgrimes 2351541Srgrimes#define TCIFLUSH 1 2361541Srgrimes#define TCOFLUSH 2 2371541Srgrimes#define TCIOFLUSH 3 2381541Srgrimes#define TCOOFF 1 2391541Srgrimes#define TCOON 2 2401541Srgrimes#define TCIOFF 3 2411541Srgrimes#define TCION 4 2421541Srgrimes 2431541Srgrimes#include <sys/cdefs.h> 2441541Srgrimes 2451541Srgrimes__BEGIN_DECLS 2461541Srgrimesspeed_t cfgetispeed __P((const struct termios *)); 2471541Srgrimesspeed_t cfgetospeed __P((const struct termios *)); 2481541Srgrimesint cfsetispeed __P((struct termios *, speed_t)); 2491541Srgrimesint cfsetospeed __P((struct termios *, speed_t)); 2501541Srgrimesint tcgetattr __P((int, struct termios *)); 2511541Srgrimesint tcsetattr __P((int, int, const struct termios *)); 2521541Srgrimesint tcdrain __P((int)); 2531541Srgrimesint tcflow __P((int, int)); 2541541Srgrimesint tcflush __P((int, int)); 2551541Srgrimesint tcsendbreak __P((int, int)); 2561541Srgrimes 2571541Srgrimes#ifndef _POSIX_SOURCE 2581541Srgrimesvoid cfmakeraw __P((struct termios *)); 2591541Srgrimesint cfsetspeed __P((struct termios *, speed_t)); 2601541Srgrimes#endif /* !_POSIX_SOURCE */ 2611541Srgrimes__END_DECLS 2621541Srgrimes 2631541Srgrimes#endif /* !KERNEL */ 2641541Srgrimes 2651541Srgrimes#ifndef _POSIX_SOURCE 2661541Srgrimes 2671541Srgrimes/* 2681541Srgrimes * Include tty ioctl's that aren't just for backwards compatibility 2691541Srgrimes * with the old tty driver. These ioctl definitions were previously 2701541Srgrimes * in <sys/ioctl.h>. 2711541Srgrimes */ 2721541Srgrimes#include <sys/ttycom.h> 2731541Srgrimes#endif 2741541Srgrimes 2751541Srgrimes/* 2761541Srgrimes * END OF PROTECTED INCLUDE. 2771541Srgrimes */ 2781541Srgrimes#endif /* !_SYS_TERMIOS_H_ */ 2791541Srgrimes 2801541Srgrimes#ifndef _POSIX_SOURCE 2811541Srgrimes#include <sys/ttydefaults.h> 2821541Srgrimes#endif 283