termios.h revision 20020
1139749Simp/*
2196008Smjacob * Copyright (c) 1988, 1989, 1993, 1994
3167403Smjacob *	The Regents of the University of California.  All rights reserved.
4196008Smjacob *
5167403Smjacob * Redistribution and use in source and binary forms, with or without
6167403Smjacob * modification, are permitted provided that the following conditions
7167403Smjacob * are met:
8196008Smjacob * 1. Redistributions of source code must retain the above copyright
9167403Smjacob *    notice, this list of conditions and the following disclaimer.
10167403Smjacob * 2. Redistributions in binary form must reproduce the above copyright
11167403Smjacob *    notice, this list of conditions and the following disclaimer in the
12167403Smjacob *    documentation and/or other materials provided with the distribution.
13167403Smjacob * 3. All advertising materials mentioning features or use of this software
14196008Smjacob *    must display the following acknowledgement:
15167403Smjacob *	This product includes software developed by the University of
16167403Smjacob *	California, Berkeley and its contributors.
17167403Smjacob * 4. Neither the name of the University nor the names of its contributors
18167403Smjacob *    may be used to endorse or promote products derived from this software
19167403Smjacob *    without specific prior written permission.
20167403Smjacob *
21167403Smjacob * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22167403Smjacob * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23167403Smjacob * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24167403Smjacob * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25167403Smjacob * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26196008Smjacob * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27167403Smjacob * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28167403Smjacob * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2955373Smjacob * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3055373Smjacob * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3155373Smjacob * SUCH DAMAGE.
3290224Smjacob *
3390224Smjacob *	@(#)termios.h	8.3 (Berkeley) 3/28/94
3490224Smjacob * $Id: termios.h,v 1.6 1995/05/30 08:14:40 rgrimes Exp $
3590224Smjacob */
3655373Smjacob
3755373Smjacob#ifndef _SYS_TERMIOS_H_
3855373Smjacob#define _SYS_TERMIOS_H_
3955373Smjacob
4055373Smjacob/*
4155373Smjacob * Special Control Characters
4255373Smjacob *
43160410Smjacob * Index into c_cc[] character array.
44160410Smjacob *
4555373Smjacob *	Name	     Subscript	Enabled by
4655373Smjacob */
4755373Smjacob#define	VEOF		0	/* ICANON */
4855373Smjacob#define	VEOL		1	/* ICANON */
4955373Smjacob#ifndef _POSIX_SOURCE
5055373Smjacob#define	VEOL2		2	/* ICANON together with IEXTEN */
5155373Smjacob#endif
5255373Smjacob#define	VERASE		3	/* ICANON */
5355373Smjacob#ifndef _POSIX_SOURCE
5455373Smjacob#define VWERASE 	4	/* ICANON together with IEXTEN */
55196008Smjacob#endif
56196008Smjacob#define VKILL		5	/* ICANON */
57196008Smjacob#ifndef _POSIX_SOURCE
5855373Smjacob#define	VREPRINT 	6	/* ICANON together with IEXTEN */
59157943Smjacob#endif
60157943Smjacob/*			7	   spare 1 */
61163899Smjacob#define VINTR		8	/* ISIG */
62157943Smjacob#define VQUIT		9	/* ISIG */
63157943Smjacob#define VSUSP		10	/* ISIG */
64157943Smjacob#ifndef _POSIX_SOURCE
65157943Smjacob#define VDSUSP		11	/* ISIG together with IEXTEN */
66163899Smjacob#endif
67196008Smjacob#define VSTART		12	/* IXON, IXOFF */
6855373Smjacob#define VSTOP		13	/* IXON, IXOFF */
6955373Smjacob#ifndef _POSIX_SOURCE
7055373Smjacob#define	VLNEXT		14	/* IEXTEN */
7155373Smjacob#define	VDISCARD	15	/* IEXTEN */
7255373Smjacob#endif
7355373Smjacob#define VMIN		16	/* !ICANON */
7455373Smjacob#define VTIME		17	/* !ICANON */
7555373Smjacob#ifndef _POSIX_SOURCE
7655373Smjacob#define VSTATUS		18	/* ICANON together with IEXTEN */
7755373Smjacob/*			19	   spare 2 */
7855373Smjacob#endif
7955373Smjacob#define	NCCS		20
8055373Smjacob
8155373Smjacob#define	_POSIX_VDISABLE	0xff
8255373Smjacob
8355373Smjacob#ifndef _POSIX_SOURCE
8455373Smjacob#define	CCEQ(val, c)	((c) == (val) ? (val) != _POSIX_VDISABLE : 0)
8555373Smjacob#endif
8655373Smjacob
8755373Smjacob/*
8855373Smjacob * Input flags - software input processing
8955373Smjacob */
9055373Smjacob#define	IGNBRK		0x00000001	/* ignore BREAK condition */
9155373Smjacob#define	BRKINT		0x00000002	/* map BREAK to SIGINTR */
9255373Smjacob#define	IGNPAR		0x00000004	/* ignore (discard) parity errors */
9355373Smjacob#define	PARMRK		0x00000008	/* mark parity and framing errors */
9455373Smjacob#define	INPCK		0x00000010	/* enable checking of parity errors */
9555373Smjacob#define	ISTRIP		0x00000020	/* strip 8th bit off chars */
9655373Smjacob#define	INLCR		0x00000040	/* map NL into CR */
9772082Sasmodai#define	IGNCR		0x00000080	/* ignore CR */
9855373Smjacob#define	ICRNL		0x00000100	/* map CR to NL (ala CRMOD) */
9955373Smjacob#define	IXON		0x00000200	/* enable output flow control */
10055373Smjacob#define	IXOFF		0x00000400	/* enable input flow control */
10155373Smjacob#ifndef _POSIX_SOURCE
10255373Smjacob#define	IXANY		0x00000800	/* any char will restart after stop */
10355373Smjacob#define IMAXBEL		0x00002000	/* ring bell on input queue full */
10455373Smjacob#endif  /*_POSIX_SOURCE */
10555373Smjacob
10655373Smjacob/*
10755373Smjacob * Output flags - software output processing
10855373Smjacob */
10955373Smjacob#define	OPOST		0x00000001	/* enable following output processing */
11055373Smjacob#ifndef _POSIX_SOURCE
11155373Smjacob#define ONLCR		0x00000002	/* map NL to CR-NL (ala CRMOD) */
11255373Smjacob#define OXTABS		0x00000004	/* expand tabs to spaces */
11355373Smjacob#define ONOEOT		0x00000008	/* discard EOT's (^D) on output) */
11455373Smjacob#endif  /*_POSIX_SOURCE */
11555373Smjacob
116163899Smjacob/*
11755373Smjacob * Control flags - hardware control of terminal
118163899Smjacob */
119163899Smjacob#ifndef _POSIX_SOURCE
12055373Smjacob#define	CIGNORE		0x00000001	/* ignore control flags */
12155373Smjacob#endif
12255373Smjacob#define CSIZE		0x00000300	/* character size mask */
123154704Smjacob#define     CS5		    0x00000000	    /* 5 bits (pseudo) */
124163899Smjacob#define     CS6		    0x00000100	    /* 6 bits */
12555373Smjacob#define     CS7		    0x00000200	    /* 7 bits */
12655373Smjacob#define     CS8		    0x00000300	    /* 8 bits */
127154704Smjacob#define CSTOPB		0x00000400	/* send 2 stop bits */
128163899Smjacob#define CREAD		0x00000800	/* enable receiver */
12955373Smjacob#define PARENB		0x00001000	/* parity enable */
13055373Smjacob#define PARODD		0x00002000	/* odd parity, else even */
13155373Smjacob#define HUPCL		0x00004000	/* hang up on last close */
132154704Smjacob#define CLOCAL		0x00008000	/* ignore modem status lines */
133163899Smjacob#ifndef _POSIX_SOURCE
13455373Smjacob#define CCTS_OFLOW	0x00010000	/* CTS flow control of output */
13555373Smjacob#define CRTSCTS		(CCTS_OFLOW | CRTS_IFLOW)
136154704Smjacob#define CRTS_IFLOW	0x00020000	/* RTS flow control of input */
137163899Smjacob#define	CDTR_IFLOW	0x00040000	/* DTR flow control of input */
13855373Smjacob#define CDSR_OFLOW	0x00080000	/* DSR flow control of output */
139163899Smjacob#define	CCAR_OFLOW	0x00100000	/* DCD flow control of output */
140163899Smjacob#define	MDMBUF		0x00100000	/* old name for CCAR_OFLOW */
141163899Smjacob#endif
14255373Smjacob
14355373Smjacob
14455373Smjacob/*
145154704Smjacob * "Local" flags - dumping ground for other state
146163899Smjacob *
14755373Smjacob * Warning: some flags in this structure begin with
14855373Smjacob * the letter "I" and look like they belong in the
149154704Smjacob * input flag.
150163899Smjacob */
15155373Smjacob
15255373Smjacob#ifndef _POSIX_SOURCE
15355373Smjacob#define	ECHOKE		0x00000001	/* visual erase for line kill */
154154704Smjacob#endif  /*_POSIX_SOURCE */
155163899Smjacob#define	ECHOE		0x00000002	/* visually erase chars */
15655373Smjacob#define	ECHOK		0x00000004	/* echo NL after line kill */
15755373Smjacob#define ECHO		0x00000008	/* enable echoing */
158154704Smjacob#define	ECHONL		0x00000010	/* echo NL even if ECHO is off */
159163899Smjacob#ifndef _POSIX_SOURCE
160163899Smjacob#define	ECHOPRT		0x00000020	/* visual erase mode for hardcopy */
161163899Smjacob#define ECHOCTL  	0x00000040	/* echo control chars as ^(Char) */
162163899Smjacob#endif  /*_POSIX_SOURCE */
16355373Smjacob#define	ISIG		0x00000080	/* enable signals INTR, QUIT, [D]SUSP */
16455373Smjacob#define	ICANON		0x00000100	/* canonicalize input lines */
165155704Smjacob#ifndef _POSIX_SOURCE
166196008Smjacob#define ALTWERASE	0x00000200	/* use alternate WERASE algorithm */
167163899Smjacob#endif  /*_POSIX_SOURCE */
168196008Smjacob#define	IEXTEN		0x00000400	/* enable DISCARD and LNEXT */
16955373Smjacob#define EXTPROC         0x00000800      /* external processing */
17087635Smjacob#define TOSTOP		0x00400000	/* stop background jobs from output */
17155373Smjacob#ifndef _POSIX_SOURCE
17255373Smjacob#define FLUSHO		0x00800000	/* output being flushed (state) */
17355373Smjacob#define	NOKERNINFO	0x02000000	/* no kernel output from VSTATUS */
17455373Smjacob#define PENDIN		0x20000000	/* XXX retype pending input (state) */
175196008Smjacob#endif  /*_POSIX_SOURCE */
17655373Smjacob#define	NOFLSH		0x80000000	/* don't flush after interrupt */
177163899Smjacob
178163899Smjacobtypedef unsigned long	tcflag_t;
179163899Smjacobtypedef unsigned char	cc_t;
180163899Smjacobtypedef long		speed_t;	/* XXX should be unsigned long */
181163899Smjacob
182163899Smjacobstruct termios {
183196008Smjacob	tcflag_t	c_iflag;	/* input flags */
184196008Smjacob	tcflag_t	c_oflag;	/* output flags */
185163899Smjacob	tcflag_t	c_cflag;	/* control flags */
186163899Smjacob	tcflag_t	c_lflag;	/* local flags */
187163899Smjacob	cc_t		c_cc[NCCS];	/* control chars */
188163899Smjacob	speed_t		c_ispeed;	/* input speed */
189196008Smjacob	speed_t		c_ospeed;	/* output speed */
190163899Smjacob};
191196008Smjacob
192163899Smjacob/*
193163899Smjacob * Commands passed to tcsetattr() for setting the termios structure.
194163899Smjacob */
195163899Smjacob#define	TCSANOW		0		/* make change immediate */
196163899Smjacob#define	TCSADRAIN	1		/* drain output, then change */
197163899Smjacob#define	TCSAFLUSH	2		/* drain output, flush input */
198163899Smjacob#ifndef _POSIX_SOURCE
199163899Smjacob#define TCSASOFT	0x10		/* flag - don't alter h.w. state */
200163899Smjacob#endif
201163899Smjacob
202163899Smjacob/*
203163899Smjacob * Standard speeds
204163899Smjacob */
205196008Smjacob#define B0	0
206163899Smjacob#define B50	50
207163899Smjacob#define B75	75
208163899Smjacob#define B110	110
209163899Smjacob#define B134	134
21055373Smjacob#define B150	150
211163899Smjacob#define B200	200
21255373Smjacob#define B300	300
21387635Smjacob#define B600	600
21487635Smjacob#define B1200	1200
21555373Smjacob#define	B1800	1800
216163899Smjacob#define B2400	2400
21755373Smjacob#define B4800	4800
218196008Smjacob#define B9600	9600
219154704Smjacob#define B19200	19200
220160251Smjacob#define B38400	38400
221154704Smjacob#ifndef _POSIX_SOURCE
222163899Smjacob#define B7200	7200
22387635Smjacob#define B14400	14400
22455373Smjacob#define B28800	28800
225163899Smjacob#define B57600	57600
226125187Smjacob#define B76800	76800
22755373Smjacob#define B115200	115200
228196008Smjacob#define B230400	230400
229154704Smjacob#define EXTA	19200
230160251Smjacob#define EXTB	38400
231154704Smjacob#endif  /* !_POSIX_SOURCE */
232163899Smjacob
23387635Smjacob#ifndef KERNEL
23455373Smjacob
235163899Smjacob#define	TCIFLUSH	1
236163899Smjacob#define	TCOFLUSH	2
237163899Smjacob#define TCIOFLUSH	3
238163899Smjacob#define	TCOOFF		1
239163899Smjacob#define	TCOON		2
240163899Smjacob#define TCIOFF		3
24155373Smjacob#define TCION		4
24255373Smjacob
24387635Smjacob#include <sys/cdefs.h>
244196008Smjacob
24555373Smjacob__BEGIN_DECLS
24655373Smjacobspeed_t	cfgetispeed __P((const struct termios *));
24755373Smjacobspeed_t	cfgetospeed __P((const struct termios *));
24857216Smjacobint	cfsetispeed __P((struct termios *, speed_t));
249163899Smjacobint	cfsetospeed __P((struct termios *, speed_t));
250196008Smjacobint	tcgetattr __P((int, struct termios *));
251163899Smjacobint	tcsetattr __P((int, int, const struct termios *));
252196008Smjacobint	tcdrain __P((int));
253163899Smjacobint	tcflow __P((int, int));
254196008Smjacobint	tcflush __P((int, int));
255196008Smjacobint	tcsendbreak __P((int, int));
256196008Smjacob
257196008Smjacob#ifndef _POSIX_SOURCE
258196008Smjacobvoid	cfmakeraw __P((struct termios *));
259196008Smjacobint	cfsetspeed __P((struct termios *, speed_t));
260196008Smjacob#endif /* !_POSIX_SOURCE */
261196008Smjacob__END_DECLS
262160978Smjacob
263196008Smjacob#endif /* !KERNEL */
264196008Smjacob
265196008Smjacob#ifndef _POSIX_SOURCE
266196008Smjacob
267196008Smjacob/*
268160978Smjacob * Include tty ioctl's that aren't just for backwards compatibility
26955373Smjacob * with the old tty driver.  These ioctl definitions were previously
270196008Smjacob * in <sys/ioctl.h>.
271196008Smjacob */
272196008Smjacob#include <sys/ttycom.h>
273196008Smjacob#endif
274196008Smjacob
27557216Smjacob/*
276196008Smjacob * END OF PROTECTED INCLUDE.
277196008Smjacob */
27857216Smjacob#endif /* !_SYS_TERMIOS_H_ */
27955373Smjacob
280160978Smjacob#ifndef _POSIX_SOURCE
281196008Smjacob#include <sys/ttydefaults.h>
28283027Smjacob#endif
28355373Smjacob