termios.h revision 139825
1139825Simp/*-
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 * 4. Neither the name of the University nor the names of its contributors
141541Srgrimes *    may be used to endorse or promote products derived from this software
151541Srgrimes *    without specific prior written permission.
161541Srgrimes *
171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271541Srgrimes * SUCH DAMAGE.
281541Srgrimes *
291541Srgrimes *	@(#)termios.h	8.3 (Berkeley) 3/28/94
3050477Speter * $FreeBSD: head/sys/sys/termios.h 139825 2005-01-07 02:29:27Z imp $
311541Srgrimes */
321541Srgrimes
331541Srgrimes#ifndef _SYS_TERMIOS_H_
341541Srgrimes#define _SYS_TERMIOS_H_
351541Srgrimes
368876Srgrimes/*
378876Srgrimes * Special Control Characters
381541Srgrimes *
391541Srgrimes * Index into c_cc[] character array.
401541Srgrimes *
418876Srgrimes *	Name	     Subscript	Enabled by
421541Srgrimes */
431541Srgrimes#define	VEOF		0	/* ICANON */
441541Srgrimes#define	VEOL		1	/* ICANON */
451541Srgrimes#ifndef _POSIX_SOURCE
4620020Sbde#define	VEOL2		2	/* ICANON together with IEXTEN */
471541Srgrimes#endif
481541Srgrimes#define	VERASE		3	/* ICANON */
491541Srgrimes#ifndef _POSIX_SOURCE
5020020Sbde#define VWERASE 	4	/* ICANON together with IEXTEN */
518876Srgrimes#endif
521541Srgrimes#define VKILL		5	/* ICANON */
531541Srgrimes#ifndef _POSIX_SOURCE
5420020Sbde#define	VREPRINT 	6	/* ICANON together with IEXTEN */
5569322Sjkh#define VERASE2 	7	/* ICANON */
561541Srgrimes#endif
5769322Sjkh/*			7	   ex-spare 1 */
581541Srgrimes#define VINTR		8	/* ISIG */
591541Srgrimes#define VQUIT		9	/* ISIG */
601541Srgrimes#define VSUSP		10	/* ISIG */
611541Srgrimes#ifndef _POSIX_SOURCE
6220020Sbde#define VDSUSP		11	/* ISIG together with IEXTEN */
631541Srgrimes#endif
641541Srgrimes#define VSTART		12	/* IXON, IXOFF */
651541Srgrimes#define VSTOP		13	/* IXON, IXOFF */
661541Srgrimes#ifndef _POSIX_SOURCE
671541Srgrimes#define	VLNEXT		14	/* IEXTEN */
681541Srgrimes#define	VDISCARD	15	/* IEXTEN */
691541Srgrimes#endif
701541Srgrimes#define VMIN		16	/* !ICANON */
711541Srgrimes#define VTIME		17	/* !ICANON */
721541Srgrimes#ifndef _POSIX_SOURCE
7320020Sbde#define VSTATUS		18	/* ICANON together with IEXTEN */
741541Srgrimes/*			19	   spare 2 */
751541Srgrimes#endif
761541Srgrimes#define	NCCS		20
771541Srgrimes
788449Sbde#define	_POSIX_VDISABLE	0xff
791541Srgrimes
801541Srgrimes#ifndef _POSIX_SOURCE
818449Sbde#define	CCEQ(val, c)	((c) == (val) ? (val) != _POSIX_VDISABLE : 0)
821541Srgrimes#endif
831541Srgrimes
841541Srgrimes/*
851541Srgrimes * Input flags - software input processing
861541Srgrimes */
871541Srgrimes#define	IGNBRK		0x00000001	/* ignore BREAK condition */
881541Srgrimes#define	BRKINT		0x00000002	/* map BREAK to SIGINTR */
891541Srgrimes#define	IGNPAR		0x00000004	/* ignore (discard) parity errors */
901541Srgrimes#define	PARMRK		0x00000008	/* mark parity and framing errors */
911541Srgrimes#define	INPCK		0x00000010	/* enable checking of parity errors */
921541Srgrimes#define	ISTRIP		0x00000020	/* strip 8th bit off chars */
931541Srgrimes#define	INLCR		0x00000040	/* map NL into CR */
941541Srgrimes#define	IGNCR		0x00000080	/* ignore CR */
951541Srgrimes#define	ICRNL		0x00000100	/* map CR to NL (ala CRMOD) */
961541Srgrimes#define	IXON		0x00000200	/* enable output flow control */
971541Srgrimes#define	IXOFF		0x00000400	/* enable input flow control */
981541Srgrimes#ifndef _POSIX_SOURCE
991541Srgrimes#define	IXANY		0x00000800	/* any char will restart after stop */
1001541Srgrimes#define IMAXBEL		0x00002000	/* ring bell on input queue full */
1011541Srgrimes#endif  /*_POSIX_SOURCE */
1021541Srgrimes
1031541Srgrimes/*
1041541Srgrimes * Output flags - software output processing
1051541Srgrimes */
1061541Srgrimes#define	OPOST		0x00000001	/* enable following output processing */
1071541Srgrimes#ifndef _POSIX_SOURCE
1081541Srgrimes#define ONLCR		0x00000002	/* map NL to CR-NL (ala CRMOD) */
1091541Srgrimes#define OXTABS		0x00000004	/* expand tabs to spaces */
1101541Srgrimes#define ONOEOT		0x00000008	/* discard EOT's (^D) on output) */
11173421Sassar#define OCRNL		0x00000010	/* map CR to NL on output */
11273421Sassar#define ONOCR		0x00000020	/* no CR output at column 0 */
11373421Sassar#define ONLRET		0x00000040	/* NL performs CR function */
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
22977400Sache#define B460800	460800
23078485Sache#define B921600	921600
2311541Srgrimes#define EXTA	19200
2321541Srgrimes#define EXTB	38400
2331541Srgrimes#endif  /* !_POSIX_SOURCE */
2341541Srgrimes
23555205Speter#ifndef _KERNEL
2361541Srgrimes
2371541Srgrimes#define	TCIFLUSH	1
2381541Srgrimes#define	TCOFLUSH	2
2391541Srgrimes#define TCIOFLUSH	3
2401541Srgrimes#define	TCOOFF		1
2411541Srgrimes#define	TCOON		2
2421541Srgrimes#define TCIOFF		3
2431541Srgrimes#define TCION		4
2441541Srgrimes
2451541Srgrimes#include <sys/cdefs.h>
2461541Srgrimes
2471541Srgrimes__BEGIN_DECLS
24892719Salfredspeed_t	cfgetispeed(const struct termios *);
24992719Salfredspeed_t	cfgetospeed(const struct termios *);
25092719Salfredint	cfsetispeed(struct termios *, speed_t);
25192719Salfredint	cfsetospeed(struct termios *, speed_t);
25292719Salfredint	tcgetattr(int, struct termios *);
25392719Salfredint	tcsetattr(int, int, const struct termios *);
25492719Salfredint	tcdrain(int);
25592719Salfredint	tcflow(int, int);
25692719Salfredint	tcflush(int, int);
25792719Salfredint	tcsendbreak(int, int);
2581541Srgrimes
2591541Srgrimes#ifndef _POSIX_SOURCE
26092719Salfredvoid	cfmakeraw(struct termios *);
26192719Salfredint	cfsetspeed(struct termios *, speed_t);
2621541Srgrimes#endif /* !_POSIX_SOURCE */
2631541Srgrimes__END_DECLS
2641541Srgrimes
26555205Speter#endif /* !_KERNEL */
2661541Srgrimes
2671541Srgrimes#ifndef _POSIX_SOURCE
2681541Srgrimes
2691541Srgrimes/*
2701541Srgrimes * Include tty ioctl's that aren't just for backwards compatibility
2711541Srgrimes * with the old tty driver.  These ioctl definitions were previously
2721541Srgrimes * in <sys/ioctl.h>.
2731541Srgrimes */
2741541Srgrimes#include <sys/ttycom.h>
2751541Srgrimes#endif
2761541Srgrimes
2771541Srgrimes/*
2781541Srgrimes * END OF PROTECTED INCLUDE.
2791541Srgrimes */
2801541Srgrimes#endif /* !_SYS_TERMIOS_H_ */
2811541Srgrimes
2821541Srgrimes#ifndef _POSIX_SOURCE
2831541Srgrimes#include <sys/ttydefaults.h>
2841541Srgrimes#endif
285