termios.h revision 180561
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 180561 2008-07-16 12:36:39Z ed $
311541Srgrimes */
321541Srgrimes
331541Srgrimes#ifndef _SYS_TERMIOS_H_
341541Srgrimes#define _SYS_TERMIOS_H_
351541Srgrimes
36178295Sdavidxu#include <sys/_types.h>
37178295Sdavidxu#ifndef _PID_T_DECLARED
38178295Sdavidxutypedef	__pid_t		pid_t;
39178295Sdavidxu#define	_PID_T_DECLARED
40178295Sdavidxu#endif
41178295Sdavidxu
428876Srgrimes/*
438876Srgrimes * Special Control Characters
441541Srgrimes *
451541Srgrimes * Index into c_cc[] character array.
461541Srgrimes *
478876Srgrimes *	Name	     Subscript	Enabled by
481541Srgrimes */
491541Srgrimes#define	VEOF		0	/* ICANON */
501541Srgrimes#define	VEOL		1	/* ICANON */
511541Srgrimes#ifndef _POSIX_SOURCE
5220020Sbde#define	VEOL2		2	/* ICANON together with IEXTEN */
531541Srgrimes#endif
541541Srgrimes#define	VERASE		3	/* ICANON */
551541Srgrimes#ifndef _POSIX_SOURCE
5620020Sbde#define VWERASE 	4	/* ICANON together with IEXTEN */
578876Srgrimes#endif
581541Srgrimes#define VKILL		5	/* ICANON */
591541Srgrimes#ifndef _POSIX_SOURCE
6020020Sbde#define	VREPRINT 	6	/* ICANON together with IEXTEN */
6169322Sjkh#define VERASE2 	7	/* ICANON */
621541Srgrimes#endif
6369322Sjkh/*			7	   ex-spare 1 */
641541Srgrimes#define VINTR		8	/* ISIG */
651541Srgrimes#define VQUIT		9	/* ISIG */
661541Srgrimes#define VSUSP		10	/* ISIG */
671541Srgrimes#ifndef _POSIX_SOURCE
6820020Sbde#define VDSUSP		11	/* ISIG together with IEXTEN */
691541Srgrimes#endif
701541Srgrimes#define VSTART		12	/* IXON, IXOFF */
711541Srgrimes#define VSTOP		13	/* IXON, IXOFF */
721541Srgrimes#ifndef _POSIX_SOURCE
731541Srgrimes#define	VLNEXT		14	/* IEXTEN */
741541Srgrimes#define	VDISCARD	15	/* IEXTEN */
751541Srgrimes#endif
761541Srgrimes#define VMIN		16	/* !ICANON */
771541Srgrimes#define VTIME		17	/* !ICANON */
781541Srgrimes#ifndef _POSIX_SOURCE
7920020Sbde#define VSTATUS		18	/* ICANON together with IEXTEN */
801541Srgrimes/*			19	   spare 2 */
811541Srgrimes#endif
821541Srgrimes#define	NCCS		20
831541Srgrimes
848449Sbde#define	_POSIX_VDISABLE	0xff
851541Srgrimes
861541Srgrimes#ifndef _POSIX_SOURCE
878449Sbde#define	CCEQ(val, c)	((c) == (val) ? (val) != _POSIX_VDISABLE : 0)
881541Srgrimes#endif
891541Srgrimes
901541Srgrimes/*
911541Srgrimes * Input flags - software input processing
921541Srgrimes */
931541Srgrimes#define	IGNBRK		0x00000001	/* ignore BREAK condition */
941541Srgrimes#define	BRKINT		0x00000002	/* map BREAK to SIGINTR */
951541Srgrimes#define	IGNPAR		0x00000004	/* ignore (discard) parity errors */
961541Srgrimes#define	PARMRK		0x00000008	/* mark parity and framing errors */
971541Srgrimes#define	INPCK		0x00000010	/* enable checking of parity errors */
981541Srgrimes#define	ISTRIP		0x00000020	/* strip 8th bit off chars */
991541Srgrimes#define	INLCR		0x00000040	/* map NL into CR */
1001541Srgrimes#define	IGNCR		0x00000080	/* ignore CR */
1011541Srgrimes#define	ICRNL		0x00000100	/* map CR to NL (ala CRMOD) */
1021541Srgrimes#define	IXON		0x00000200	/* enable output flow control */
1031541Srgrimes#define	IXOFF		0x00000400	/* enable input flow control */
1041541Srgrimes#ifndef _POSIX_SOURCE
1051541Srgrimes#define	IXANY		0x00000800	/* any char will restart after stop */
1061541Srgrimes#define IMAXBEL		0x00002000	/* ring bell on input queue full */
1071541Srgrimes#endif  /*_POSIX_SOURCE */
1081541Srgrimes
1091541Srgrimes/*
1101541Srgrimes * Output flags - software output processing
1111541Srgrimes */
1121541Srgrimes#define	OPOST		0x00000001	/* enable following output processing */
1131541Srgrimes#ifndef _POSIX_SOURCE
1141541Srgrimes#define ONLCR		0x00000002	/* map NL to CR-NL (ala CRMOD) */
1151541Srgrimes#define OXTABS		0x00000004	/* expand tabs to spaces */
1161541Srgrimes#define ONOEOT		0x00000008	/* discard EOT's (^D) on output) */
11773421Sassar#define OCRNL		0x00000010	/* map CR to NL on output */
11873421Sassar#define ONOCR		0x00000020	/* no CR output at column 0 */
11973421Sassar#define ONLRET		0x00000040	/* NL performs CR function */
1201541Srgrimes#endif  /*_POSIX_SOURCE */
1211541Srgrimes
1221541Srgrimes/*
1231541Srgrimes * Control flags - hardware control of terminal
1241541Srgrimes */
1251541Srgrimes#ifndef _POSIX_SOURCE
1261541Srgrimes#define	CIGNORE		0x00000001	/* ignore control flags */
1271541Srgrimes#endif
1281541Srgrimes#define CSIZE		0x00000300	/* character size mask */
1291541Srgrimes#define     CS5		    0x00000000	    /* 5 bits (pseudo) */
1301541Srgrimes#define     CS6		    0x00000100	    /* 6 bits */
1311541Srgrimes#define     CS7		    0x00000200	    /* 7 bits */
1321541Srgrimes#define     CS8		    0x00000300	    /* 8 bits */
1331541Srgrimes#define CSTOPB		0x00000400	/* send 2 stop bits */
1341541Srgrimes#define CREAD		0x00000800	/* enable receiver */
1351541Srgrimes#define PARENB		0x00001000	/* parity enable */
1361541Srgrimes#define PARODD		0x00002000	/* odd parity, else even */
1371541Srgrimes#define HUPCL		0x00004000	/* hang up on last close */
1381541Srgrimes#define CLOCAL		0x00008000	/* ignore modem status lines */
1391541Srgrimes#ifndef _POSIX_SOURCE
1401541Srgrimes#define CCTS_OFLOW	0x00010000	/* CTS flow control of output */
1411549Srgrimes#define CRTSCTS		(CCTS_OFLOW | CRTS_IFLOW)
1421541Srgrimes#define CRTS_IFLOW	0x00020000	/* RTS flow control of input */
1438187Sbde#define	CDTR_IFLOW	0x00040000	/* DTR flow control of input */
1441549Srgrimes#define CDSR_OFLOW	0x00080000	/* DSR flow control of output */
1458187Sbde#define	CCAR_OFLOW	0x00100000	/* DCD flow control of output */
1468187Sbde#define	MDMBUF		0x00100000	/* old name for CCAR_OFLOW */
1471541Srgrimes#endif
1481541Srgrimes
1491541Srgrimes
1508876Srgrimes/*
1511541Srgrimes * "Local" flags - dumping ground for other state
1521541Srgrimes *
1531541Srgrimes * Warning: some flags in this structure begin with
1541541Srgrimes * the letter "I" and look like they belong in the
1551541Srgrimes * input flag.
1561541Srgrimes */
1571541Srgrimes
1581541Srgrimes#ifndef _POSIX_SOURCE
1591541Srgrimes#define	ECHOKE		0x00000001	/* visual erase for line kill */
1601541Srgrimes#endif  /*_POSIX_SOURCE */
1611541Srgrimes#define	ECHOE		0x00000002	/* visually erase chars */
1621541Srgrimes#define	ECHOK		0x00000004	/* echo NL after line kill */
1631541Srgrimes#define ECHO		0x00000008	/* enable echoing */
1641541Srgrimes#define	ECHONL		0x00000010	/* echo NL even if ECHO is off */
1651541Srgrimes#ifndef _POSIX_SOURCE
1661541Srgrimes#define	ECHOPRT		0x00000020	/* visual erase mode for hardcopy */
1671541Srgrimes#define ECHOCTL  	0x00000040	/* echo control chars as ^(Char) */
1681541Srgrimes#endif  /*_POSIX_SOURCE */
1691541Srgrimes#define	ISIG		0x00000080	/* enable signals INTR, QUIT, [D]SUSP */
1701541Srgrimes#define	ICANON		0x00000100	/* canonicalize input lines */
1711541Srgrimes#ifndef _POSIX_SOURCE
1721541Srgrimes#define ALTWERASE	0x00000200	/* use alternate WERASE algorithm */
1731541Srgrimes#endif  /*_POSIX_SOURCE */
1741541Srgrimes#define	IEXTEN		0x00000400	/* enable DISCARD and LNEXT */
1751541Srgrimes#define EXTPROC         0x00000800      /* external processing */
1761541Srgrimes#define TOSTOP		0x00400000	/* stop background jobs from output */
1771541Srgrimes#ifndef _POSIX_SOURCE
1781541Srgrimes#define FLUSHO		0x00800000	/* output being flushed (state) */
1791541Srgrimes#define	NOKERNINFO	0x02000000	/* no kernel output from VSTATUS */
1801541Srgrimes#define PENDIN		0x20000000	/* XXX retype pending input (state) */
1811541Srgrimes#endif  /*_POSIX_SOURCE */
1821541Srgrimes#define	NOFLSH		0x80000000	/* don't flush after interrupt */
1831541Srgrimes
18435755Sjbtypedef unsigned int	tcflag_t;
1851541Srgrimestypedef unsigned char	cc_t;
18635755Sjbtypedef unsigned int	speed_t;
1871541Srgrimes
1881541Srgrimesstruct termios {
1891541Srgrimes	tcflag_t	c_iflag;	/* input flags */
1901541Srgrimes	tcflag_t	c_oflag;	/* output flags */
1911541Srgrimes	tcflag_t	c_cflag;	/* control flags */
1921541Srgrimes	tcflag_t	c_lflag;	/* local flags */
1931541Srgrimes	cc_t		c_cc[NCCS];	/* control chars */
1948187Sbde	speed_t		c_ispeed;	/* input speed */
1958187Sbde	speed_t		c_ospeed;	/* output speed */
1961541Srgrimes};
1971541Srgrimes
1988876Srgrimes/*
1991541Srgrimes * Standard speeds
2001541Srgrimes */
2011541Srgrimes#define B0	0
2021541Srgrimes#define B50	50
2031541Srgrimes#define B75	75
2041541Srgrimes#define B110	110
2051541Srgrimes#define B134	134
2061541Srgrimes#define B150	150
2071541Srgrimes#define B200	200
2081541Srgrimes#define B300	300
2091541Srgrimes#define B600	600
2101541Srgrimes#define B1200	1200
2111541Srgrimes#define	B1800	1800
2121541Srgrimes#define B2400	2400
2131541Srgrimes#define B4800	4800
2141541Srgrimes#define B9600	9600
2151541Srgrimes#define B19200	19200
2161541Srgrimes#define B38400	38400
2171541Srgrimes#ifndef _POSIX_SOURCE
2181541Srgrimes#define B7200	7200
2191541Srgrimes#define B14400	14400
2201541Srgrimes#define B28800	28800
2211541Srgrimes#define B57600	57600
2221541Srgrimes#define B76800	76800
2231541Srgrimes#define B115200	115200
2241541Srgrimes#define B230400	230400
22577400Sache#define B460800	460800
22678485Sache#define B921600	921600
2271541Srgrimes#define EXTA	19200
2281541Srgrimes#define EXTB	38400
2291541Srgrimes#endif  /* !_POSIX_SOURCE */
2301541Srgrimes
23155205Speter#ifndef _KERNEL
2321541Srgrimes
233180561Sed/*
234180561Sed * Commands passed to tcsetattr() for setting the termios structure.
235180561Sed */
236180561Sed#define	TCSANOW		0		/* make change immediate */
237180561Sed#define	TCSADRAIN	1		/* drain output, then change */
238180561Sed#define	TCSAFLUSH	2		/* drain output, flush input */
239180561Sed#ifndef _POSIX_SOURCE
240180561Sed#define TCSASOFT	0x10		/* flag - don't alter h.w. state */
241180561Sed#endif
242180561Sed
2431541Srgrimes#define	TCIFLUSH	1
2441541Srgrimes#define	TCOFLUSH	2
2451541Srgrimes#define TCIOFLUSH	3
2461541Srgrimes#define	TCOOFF		1
2471541Srgrimes#define	TCOON		2
2481541Srgrimes#define TCIOFF		3
2491541Srgrimes#define TCION		4
2501541Srgrimes
2511541Srgrimes#include <sys/cdefs.h>
2521541Srgrimes
2531541Srgrimes__BEGIN_DECLS
25492719Salfredspeed_t	cfgetispeed(const struct termios *);
25592719Salfredspeed_t	cfgetospeed(const struct termios *);
25692719Salfredint	cfsetispeed(struct termios *, speed_t);
25792719Salfredint	cfsetospeed(struct termios *, speed_t);
25892719Salfredint	tcgetattr(int, struct termios *);
25992719Salfredint	tcsetattr(int, int, const struct termios *);
26092719Salfredint	tcdrain(int);
26192719Salfredint	tcflow(int, int);
26292719Salfredint	tcflush(int, int);
26392719Salfredint	tcsendbreak(int, int);
2641541Srgrimes
265178295Sdavidxu#if __POSIX_VISIBLE >= 200112 || __BSD_VISIBLE
266178295Sdavidxupid_t	tcgetsid(int);
267178295Sdavidxu#endif
268178295Sdavidxu
2691541Srgrimes#ifndef _POSIX_SOURCE
27092719Salfredvoid	cfmakeraw(struct termios *);
27192719Salfredint	cfsetspeed(struct termios *, speed_t);
2721541Srgrimes#endif /* !_POSIX_SOURCE */
2731541Srgrimes__END_DECLS
2741541Srgrimes
27555205Speter#endif /* !_KERNEL */
2761541Srgrimes
2771541Srgrimes#ifndef _POSIX_SOURCE
2781541Srgrimes
2791541Srgrimes/*
2801541Srgrimes * Include tty ioctl's that aren't just for backwards compatibility
2811541Srgrimes * with the old tty driver.  These ioctl definitions were previously
2821541Srgrimes * in <sys/ioctl.h>.
2831541Srgrimes */
2841541Srgrimes#include <sys/ttycom.h>
2851541Srgrimes#endif
2861541Srgrimes
2871541Srgrimes/*
2881541Srgrimes * END OF PROTECTED INCLUDE.
2891541Srgrimes */
2901541Srgrimes#endif /* !_SYS_TERMIOS_H_ */
2911541Srgrimes
2921541Srgrimes#ifndef _POSIX_SOURCE
2931541Srgrimes#include <sys/ttydefaults.h>
2941541Srgrimes#endif
295