_termios.h revision 73421
119370Spst/*
219370Spst * Copyright (c) 1988, 1989, 1993, 1994
3130803Smarcel *	The Regents of the University of California.  All rights reserved.
4130803Smarcel *
5130803Smarcel * Redistribution and use in source and binary forms, with or without
698944Sobrien * modification, are permitted provided that the following conditions
719370Spst * are met:
898944Sobrien * 1. Redistributions of source code must retain the above copyright
998944Sobrien *    notice, this list of conditions and the following disclaimer.
1098944Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1198944Sobrien *    notice, this list of conditions and the following disclaimer in the
1219370Spst *    documentation and/or other materials provided with the distribution.
1398944Sobrien * 3. All advertising materials mentioning features or use of this software
1498944Sobrien *    must display the following acknowledgement:
1598944Sobrien *	This product includes software developed by the University of
1698944Sobrien *	California, Berkeley and its contributors.
1719370Spst * 4. Neither the name of the University nor the names of its contributors
1898944Sobrien *    may be used to endorse or promote products derived from this software
1998944Sobrien *    without specific prior written permission.
2098944Sobrien *
2198944Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2219370Spst * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2319370Spst * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24130803Smarcel * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25130803Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2619370Spst * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27130803Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2819370Spst * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2919370Spst * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30130803Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3198944Sobrien * SUCH DAMAGE.
32130803Smarcel *
3398944Sobrien *	@(#)termios.h	8.3 (Berkeley) 3/28/94
34130803Smarcel * $FreeBSD: head/sys/sys/termios.h 73421 2001-03-04 06:04:50Z assar $
3519370Spst */
3698944Sobrien
37130803Smarcel#ifndef _SYS_TERMIOS_H_
3846283Sdfr#define _SYS_TERMIOS_H_
3998944Sobrien
4098944Sobrien/*
4198944Sobrien * Special Control Characters
4298944Sobrien *
43130803Smarcel * Index into c_cc[] character array.
4498944Sobrien *
45130803Smarcel *	Name	     Subscript	Enabled by
4698944Sobrien */
4798944Sobrien#define	VEOF		0	/* ICANON */
4898944Sobrien#define	VEOL		1	/* ICANON */
4998944Sobrien#ifndef _POSIX_SOURCE
5098944Sobrien#define	VEOL2		2	/* ICANON together with IEXTEN */
5198944Sobrien#endif
5298944Sobrien#define	VERASE		3	/* ICANON */
5398944Sobrien#ifndef _POSIX_SOURCE
5498944Sobrien#define VWERASE 	4	/* ICANON together with IEXTEN */
5598944Sobrien#endif
5698944Sobrien#define VKILL		5	/* ICANON */
5798944Sobrien#ifndef _POSIX_SOURCE
5898944Sobrien#define	VREPRINT 	6	/* ICANON together with IEXTEN */
5998944Sobrien#define VERASE2 	7	/* ICANON */
60130803Smarcel#endif
6198944Sobrien/*			7	   ex-spare 1 */
62130803Smarcel#define VINTR		8	/* ISIG */
6398944Sobrien#define VQUIT		9	/* ISIG */
6498944Sobrien#define VSUSP		10	/* ISIG */
6598944Sobrien#ifndef _POSIX_SOURCE
6698944Sobrien#define VDSUSP		11	/* ISIG together with IEXTEN */
67130803Smarcel#endif
6898944Sobrien#define VSTART		12	/* IXON, IXOFF */
69130803Smarcel#define VSTOP		13	/* IXON, IXOFF */
7098944Sobrien#ifndef _POSIX_SOURCE
7198944Sobrien#define	VLNEXT		14	/* IEXTEN */
7298944Sobrien#define	VDISCARD	15	/* IEXTEN */
7398944Sobrien#endif
7498944Sobrien#define VMIN		16	/* !ICANON */
7598944Sobrien#define VTIME		17	/* !ICANON */
7698944Sobrien#ifndef _POSIX_SOURCE
7798944Sobrien#define VSTATUS		18	/* ICANON together with IEXTEN */
7898944Sobrien/*			19	   spare 2 */
7998944Sobrien#endif
8098944Sobrien#define	NCCS		20
8198944Sobrien
8298944Sobrien#define	_POSIX_VDISABLE	0xff
8398944Sobrien
8498944Sobrien#ifndef _POSIX_SOURCE
8598944Sobrien#define	CCEQ(val, c)	((c) == (val) ? (val) != _POSIX_VDISABLE : 0)
8698944Sobrien#endif
87130803Smarcel
8898944Sobrien/*
8998944Sobrien * Input flags - software input processing
90130803Smarcel */
9198944Sobrien#define	IGNBRK		0x00000001	/* ignore BREAK condition */
9298944Sobrien#define	BRKINT		0x00000002	/* map BREAK to SIGINTR */
93130803Smarcel#define	IGNPAR		0x00000004	/* ignore (discard) parity errors */
9498944Sobrien#define	PARMRK		0x00000008	/* mark parity and framing errors */
9598944Sobrien#define	INPCK		0x00000010	/* enable checking of parity errors */
96130803Smarcel#define	ISTRIP		0x00000020	/* strip 8th bit off chars */
9798944Sobrien#define	INLCR		0x00000040	/* map NL into CR */
9898944Sobrien#define	IGNCR		0x00000080	/* ignore CR */
9998944Sobrien#define	ICRNL		0x00000100	/* map CR to NL (ala CRMOD) */
100130803Smarcel#define	IXON		0x00000200	/* enable output flow control */
10198944Sobrien#define	IXOFF		0x00000400	/* enable input flow control */
10298944Sobrien#ifndef _POSIX_SOURCE
10398944Sobrien#define	IXANY		0x00000800	/* any char will restart after stop */
104130803Smarcel#define IMAXBEL		0x00002000	/* ring bell on input queue full */
10598944Sobrien#endif  /*_POSIX_SOURCE */
10698944Sobrien
10798944Sobrien/*
108130803Smarcel * Output flags - software output processing
10998944Sobrien */
11098944Sobrien#define	OPOST		0x00000001	/* enable following output processing */
111130803Smarcel#ifndef _POSIX_SOURCE
11298944Sobrien#define ONLCR		0x00000002	/* map NL to CR-NL (ala CRMOD) */
11398944Sobrien#define OXTABS		0x00000004	/* expand tabs to spaces */
11498944Sobrien#define ONOEOT		0x00000008	/* discard EOT's (^D) on output) */
115130803Smarcel#define OCRNL		0x00000010	/* map CR to NL on output */
11698944Sobrien#define ONOCR		0x00000020	/* no CR output at column 0 */
11798944Sobrien#define ONLRET		0x00000040	/* NL performs CR function */
11898944Sobrien#endif  /*_POSIX_SOURCE */
119130803Smarcel
12098944Sobrien/*
121130803Smarcel * Control flags - hardware control of terminal
12298944Sobrien */
123130803Smarcel#ifndef _POSIX_SOURCE
12498944Sobrien#define	CIGNORE		0x00000001	/* ignore control flags */
125130803Smarcel#endif
126130803Smarcel#define CSIZE		0x00000300	/* character size mask */
127130803Smarcel#define     CS5		    0x00000000	    /* 5 bits (pseudo) */
128130803Smarcel#define     CS6		    0x00000100	    /* 6 bits */
129130803Smarcel#define     CS7		    0x00000200	    /* 7 bits */
130130803Smarcel#define     CS8		    0x00000300	    /* 8 bits */
131130803Smarcel#define CSTOPB		0x00000400	/* send 2 stop bits */
132130803Smarcel#define CREAD		0x00000800	/* enable receiver */
133130803Smarcel#define PARENB		0x00001000	/* parity enable */
134130803Smarcel#define PARODD		0x00002000	/* odd parity, else even */
135130803Smarcel#define HUPCL		0x00004000	/* hang up on last close */
136130803Smarcel#define CLOCAL		0x00008000	/* ignore modem status lines */
137130803Smarcel#ifndef _POSIX_SOURCE
138130803Smarcel#define CCTS_OFLOW	0x00010000	/* CTS flow control of output */
139130803Smarcel#define CRTSCTS		(CCTS_OFLOW | CRTS_IFLOW)
140130803Smarcel#define CRTS_IFLOW	0x00020000	/* RTS flow control of input */
14198944Sobrien#define	CDTR_IFLOW	0x00040000	/* DTR flow control of input */
142130803Smarcel#define CDSR_OFLOW	0x00080000	/* DSR flow control of output */
14398944Sobrien#define	CCAR_OFLOW	0x00100000	/* DCD flow control of output */
144130803Smarcel#define	MDMBUF		0x00100000	/* old name for CCAR_OFLOW */
145130803Smarcel#endif
14698944Sobrien
14798944Sobrien
14898944Sobrien/*
149130803Smarcel * "Local" flags - dumping ground for other state
15098944Sobrien *
151130803Smarcel * Warning: some flags in this structure begin with
15298944Sobrien * the letter "I" and look like they belong in the
153130803Smarcel * input flag.
15498944Sobrien */
155130803Smarcel
156130803Smarcel#ifndef _POSIX_SOURCE
157130803Smarcel#define	ECHOKE		0x00000001	/* visual erase for line kill */
158130803Smarcel#endif  /*_POSIX_SOURCE */
159130803Smarcel#define	ECHOE		0x00000002	/* visually erase chars */
160130803Smarcel#define	ECHOK		0x00000004	/* echo NL after line kill */
161130803Smarcel#define ECHO		0x00000008	/* enable echoing */
16298944Sobrien#define	ECHONL		0x00000010	/* echo NL even if ECHO is off */
163130803Smarcel#ifndef _POSIX_SOURCE
16498944Sobrien#define	ECHOPRT		0x00000020	/* visual erase mode for hardcopy */
165130803Smarcel#define ECHOCTL  	0x00000040	/* echo control chars as ^(Char) */
16698944Sobrien#endif  /*_POSIX_SOURCE */
16798944Sobrien#define	ISIG		0x00000080	/* enable signals INTR, QUIT, [D]SUSP */
16898944Sobrien#define	ICANON		0x00000100	/* canonicalize input lines */
169130803Smarcel#ifndef _POSIX_SOURCE
17098944Sobrien#define ALTWERASE	0x00000200	/* use alternate WERASE algorithm */
17198944Sobrien#endif  /*_POSIX_SOURCE */
172130803Smarcel#define	IEXTEN		0x00000400	/* enable DISCARD and LNEXT */
17398944Sobrien#define EXTPROC         0x00000800      /* external processing */
17498944Sobrien#define TOSTOP		0x00400000	/* stop background jobs from output */
175130803Smarcel#ifndef _POSIX_SOURCE
17698944Sobrien#define FLUSHO		0x00800000	/* output being flushed (state) */
17798944Sobrien#define	NOKERNINFO	0x02000000	/* no kernel output from VSTATUS */
178130803Smarcel#define PENDIN		0x20000000	/* XXX retype pending input (state) */
17998944Sobrien#endif  /*_POSIX_SOURCE */
18098944Sobrien#define	NOFLSH		0x80000000	/* don't flush after interrupt */
18198944Sobrien
182130803Smarceltypedef unsigned int	tcflag_t;
18398944Sobrientypedef unsigned char	cc_t;
18498944Sobrientypedef unsigned int	speed_t;
18598944Sobrien
186130803Smarcelstruct termios {
18798944Sobrien	tcflag_t	c_iflag;	/* input flags */
18898944Sobrien	tcflag_t	c_oflag;	/* output flags */
189130803Smarcel	tcflag_t	c_cflag;	/* control flags */
19098944Sobrien	tcflag_t	c_lflag;	/* local flags */
19198944Sobrien	cc_t		c_cc[NCCS];	/* control chars */
192130803Smarcel	speed_t		c_ispeed;	/* input speed */
19398944Sobrien	speed_t		c_ospeed;	/* output speed */
19498944Sobrien};
195130803Smarcel
19698944Sobrien/*
19798944Sobrien * Commands passed to tcsetattr() for setting the termios structure.
19898944Sobrien */
19998944Sobrien#define	TCSANOW		0		/* make change immediate */
200130803Smarcel#define	TCSADRAIN	1		/* drain output, then change */
201130803Smarcel#define	TCSAFLUSH	2		/* drain output, flush input */
202130803Smarcel#ifndef _POSIX_SOURCE
203130803Smarcel#define TCSASOFT	0x10		/* flag - don't alter h.w. state */
20498944Sobrien#endif
205130803Smarcel
206130803Smarcel/*
20798944Sobrien * Standard speeds
208130803Smarcel */
209130803Smarcel#define B0	0
210130803Smarcel#define B50	50
211130803Smarcel#define B75	75
212130803Smarcel#define B110	110
213130803Smarcel#define B134	134
214130803Smarcel#define B150	150
215130803Smarcel#define B200	200
216130803Smarcel#define B300	300
217130803Smarcel#define B600	600
21898944Sobrien#define B1200	1200
21998944Sobrien#define	B1800	1800
22098944Sobrien#define B2400	2400
221130803Smarcel#define B4800	4800
222130803Smarcel#define B9600	9600
223130803Smarcel#define B19200	19200
224130803Smarcel#define B38400	38400
225130803Smarcel#ifndef _POSIX_SOURCE
226130803Smarcel#define B7200	7200
227130803Smarcel#define B14400	14400
228130803Smarcel#define B28800	28800
229130803Smarcel#define B57600	57600
230130803Smarcel#define B76800	76800
231130803Smarcel#define B115200	115200
232130803Smarcel#define B230400	230400
233130803Smarcel#define EXTA	19200
234130803Smarcel#define EXTB	38400
235130803Smarcel#endif  /* !_POSIX_SOURCE */
23698944Sobrien
23798944Sobrien#ifndef _KERNEL
23898944Sobrien
23998944Sobrien#define	TCIFLUSH	1
240130803Smarcel#define	TCOFLUSH	2
24198944Sobrien#define TCIOFLUSH	3
24298944Sobrien#define	TCOOFF		1
24398944Sobrien#define	TCOON		2
244130803Smarcel#define TCIOFF		3
24598944Sobrien#define TCION		4
24698944Sobrien
24798944Sobrien#include <sys/cdefs.h>
24898944Sobrien
249130803Smarcel__BEGIN_DECLS
25098944Sobrienspeed_t	cfgetispeed __P((const struct termios *));
25198944Sobrienspeed_t	cfgetospeed __P((const struct termios *));
252130803Smarcelint	cfsetispeed __P((struct termios *, speed_t));
25398944Sobrienint	cfsetospeed __P((struct termios *, speed_t));
25498944Sobrienint	tcgetattr __P((int, struct termios *));
255130803Smarcelint	tcsetattr __P((int, int, const struct termios *));
25698944Sobrienint	tcdrain __P((int));
25798944Sobrienint	tcflow __P((int, int));
258130803Smarcelint	tcflush __P((int, int));
25998944Sobrienint	tcsendbreak __P((int, int));
26098944Sobrien
26198944Sobrien#ifndef _POSIX_SOURCE
262130803Smarcelvoid	cfmakeraw __P((struct termios *));
26398944Sobrienint	cfsetspeed __P((struct termios *, speed_t));
264130803Smarcel#endif /* !_POSIX_SOURCE */
26598944Sobrien__END_DECLS
266130803Smarcel
26798944Sobrien#endif /* !_KERNEL */
26898944Sobrien
269130803Smarcel#ifndef _POSIX_SOURCE
27098944Sobrien
271130803Smarcel/*
27298944Sobrien * Include tty ioctl's that aren't just for backwards compatibility
27398944Sobrien * with the old tty driver.  These ioctl definitions were previously
274130803Smarcel * in <sys/ioctl.h>.
27598944Sobrien */
276130803Smarcel#include <sys/ttycom.h>
277130803Smarcel#endif
278130803Smarcel
279130803Smarcel/*
280130803Smarcel * END OF PROTECTED INCLUDE.
281130803Smarcel */
282130803Smarcel#endif /* !_SYS_TERMIOS_H_ */
283130803Smarcel
284130803Smarcel#ifndef _POSIX_SOURCE
285130803Smarcel#include <sys/ttydefaults.h>
286130803Smarcel#endif
287130803Smarcel