termios.h revision 1542
11539Srgrimes/*
21539Srgrimes * Copyright (c) 1988, 1989, 1993, 1994
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes *
51539Srgrimes * Redistribution and use in source and binary forms, with or without
61539Srgrimes * modification, are permitted provided that the following conditions
71539Srgrimes * are met:
81539Srgrimes * 1. Redistributions of source code must retain the above copyright
91539Srgrimes *    notice, this list of conditions and the following disclaimer.
101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111539Srgrimes *    notice, this list of conditions and the following disclaimer in the
121539Srgrimes *    documentation and/or other materials provided with the distribution.
13203964Simp * 3. All advertising materials mentioning features or use of this software
141539Srgrimes *    must display the following acknowledgement:
151539Srgrimes *	This product includes software developed by the University of
161539Srgrimes *	California, Berkeley and its contributors.
171539Srgrimes * 4. Neither the name of the University nor the names of its contributors
181539Srgrimes *    may be used to endorse or promote products derived from this software
191539Srgrimes *    without specific prior written permission.
201539Srgrimes *
211539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
318858Srgrimes * SUCH DAMAGE.
321539Srgrimes *
331539Srgrimes *	@(#)termios.h	8.3 (Berkeley) 3/28/94
341539Srgrimes */
351539Srgrimes
361539Srgrimes#ifndef _SYS_TERMIOS_H_
371539Srgrimes#define _SYS_TERMIOS_H_
388858Srgrimes
391539Srgrimes/*
401539Srgrimes * Special Control Characters
411539Srgrimes *
421539Srgrimes * Index into c_cc[] character array.
431539Srgrimes *
441539Srgrimes *	Name	     Subscript	Enabled by
451539Srgrimes */
461539Srgrimes#define	VEOF		0	/* ICANON */
471539Srgrimes#define	VEOL		1	/* ICANON */
481539Srgrimes#ifndef _POSIX_SOURCE
491539Srgrimes#define	VEOL2		2	/* ICANON */
501539Srgrimes#endif
5136888Speter#define	VERASE		3	/* ICANON */
5236888Speter#ifndef _POSIX_SOURCE
5336888Speter#define VWERASE 	4	/* ICANON */
5450473Speter#endif
5536888Speter#define VKILL		5	/* ICANON */
5636888Speter#ifndef _POSIX_SOURCE
571539Srgrimes#define	VREPRINT 	6	/* ICANON */
581539Srgrimes#endif
591539Srgrimes/*			7	   spare 1 */
6084463Sbde#define VINTR		8	/* ISIG */
61102227Smike#define VQUIT		9	/* ISIG */
6221055Speter#define VSUSP		10	/* ISIG */
63102227Smike#ifndef _POSIX_SOURCE
64102227Smike#define VDSUSP		11	/* ISIG */
65102227Smike#endif
6672510Sume#define VSTART		12	/* IXON, IXOFF */
6772510Sume#define VSTOP		13	/* IXON, IXOFF */
68102227Smike#ifndef _POSIX_SOURCE
69102227Smike#define	VLNEXT		14	/* IEXTEN */
70102227Smike#define	VDISCARD	15	/* IEXTEN */
7184463Sbde#endif
7284463Sbde#define VMIN		16	/* !ICANON */
73146244Sume#define VTIME		17	/* !ICANON */
74146244Sume#ifndef _POSIX_SOURCE
75146244Sume#define VSTATUS		18	/* ICANON */
76146244Sume/*			19	   spare 2 */
77146244Sume#endif
7836888Speter#define	NCCS		20
7936888Speter
8036888Speter#define _POSIX_VDISABLE	((unsigned char)'\377')
811539Srgrimes
821539Srgrimes#ifndef _POSIX_SOURCE
831539Srgrimes#define CCEQ(val, c)	(c == val ? val != _POSIX_VDISABLE : 0)
841539Srgrimes#endif
85206155Sume
861539Srgrimes/*
87156960Sume * Input flags - software input processing
8810132Speter */
891539Srgrimes#define	IGNBRK		0x00000001	/* ignore BREAK condition */
901539Srgrimes#define	BRKINT		0x00000002	/* map BREAK to SIGINTR */
911539Srgrimes#define	IGNPAR		0x00000004	/* ignore (discard) parity errors */
921539Srgrimes#define	PARMRK		0x00000008	/* mark parity and framing errors */
931539Srgrimes#define	INPCK		0x00000010	/* enable checking of parity errors */
9483047Sobrien#define	ISTRIP		0x00000020	/* strip 8th bit off chars */
951539Srgrimes#define	INLCR		0x00000040	/* map NL into CR */
961539Srgrimes#define	IGNCR		0x00000080	/* ignore CR */
971539Srgrimes#define	ICRNL		0x00000100	/* map CR to NL (ala CRMOD) */
981539Srgrimes#define	IXON		0x00000200	/* enable output flow control */
991539Srgrimes#define	IXOFF		0x00000400	/* enable input flow control */
10013771Smpp#ifndef _POSIX_SOURCE
1011539Srgrimes#define	IXANY		0x00000800	/* any char will restart after stop */
1021539Srgrimes#define IMAXBEL		0x00002000	/* ring bell on input queue full */
10383047Sobrien#endif  /*_POSIX_SOURCE */
1041539Srgrimes
1051539Srgrimes/*
1061539Srgrimes * Output flags - software output processing
107146244Sume */
1081539Srgrimes#define	OPOST		0x00000001	/* enable following output processing */
1091539Srgrimes#ifndef _POSIX_SOURCE
11083047Sobrien#define ONLCR		0x00000002	/* map NL to CR-NL (ala CRMOD) */
1111539Srgrimes#define OXTABS		0x00000004	/* expand tabs to spaces */
1121539Srgrimes#define ONOEOT		0x00000008	/* discard EOT's (^D) on output) */
1131539Srgrimes#endif  /*_POSIX_SOURCE */
1141539Srgrimes
1151539Srgrimes/*
1161539Srgrimes * Control flags - hardware control of terminal
11783047Sobrien */
1181539Srgrimes#ifndef _POSIX_SOURCE
1191539Srgrimes#define	CIGNORE		0x00000001	/* ignore control flags */
1201539Srgrimes#endif
1211539Srgrimes#define CSIZE		0x00000300	/* character size mask */
1221539Srgrimes#define     CS5		    0x00000000	    /* 5 bits (pseudo) */
12355163Sshin#define     CS6		    0x00000100	    /* 6 bits */
12455163Sshin#define     CS7		    0x00000200	    /* 7 bits */
12555163Sshin#define     CS8		    0x00000300	    /* 8 bits */
12655163Sshin#define CSTOPB		0x00000400	/* send 2 stop bits */
12755163Sshin#define CREAD		0x00000800	/* enable receiver */
128146244Sume#define PARENB		0x00001000	/* parity enable */
12955163Sshin#define PARODD		0x00002000	/* odd parity, else even */
13055163Sshin#define HUPCL		0x00004000	/* hang up on last close */
13155163Sshin#define CLOCAL		0x00008000	/* ignore modem status lines */
13255163Sshin#ifndef _POSIX_SOURCE
13355163Sshin#define CCTS_OFLOW	0x00010000	/* CTS flow control of output */
1341539Srgrimes#define CRTSCTS		CCTS_OFLOW	/* ??? */
1351539Srgrimes#define CRTS_IFLOW	0x00020000	/* RTS flow control of input */
136126243Sgreen#define	MDMBUF		0x00100000	/* flow control output via Carrier */
1371539Srgrimes#endif
1381539Srgrimes
13910132Speter
14010132Speter/*
1411539Srgrimes * "Local" flags - dumping ground for other state
14213771Smpp *
1431539Srgrimes * Warning: some flags in this structure begin with
1441539Srgrimes * the letter "I" and look like they belong in the
1451539Srgrimes * input flag.
1461539Srgrimes */
14755163Sshin
14855163Sshin#ifndef _POSIX_SOURCE
14955163Sshin#define	ECHOKE		0x00000001	/* visual erase for line kill */
150121430Sume#endif  /*_POSIX_SOURCE */
151121430Sume#define	ECHOE		0x00000002	/* visually erase chars */
15255163Sshin#define	ECHOK		0x00000004	/* echo NL after line kill */
153121430Sume#define ECHO		0x00000008	/* enable echoing */
15455163Sshin#define	ECHONL		0x00000010	/* echo NL even if ECHO is off */
15555163Sshin#ifndef _POSIX_SOURCE
15655163Sshin#define	ECHOPRT		0x00000020	/* visual erase mode for hardcopy */
15755163Sshin#define ECHOCTL  	0x00000040	/* echo control chars as ^(Char) */
15855163Sshin#endif  /*_POSIX_SOURCE */
159121430Sume#define	ISIG		0x00000080	/* enable signals INTR, QUIT, [D]SUSP */
160121430Sume#define	ICANON		0x00000100	/* canonicalize input lines */
16155163Sshin#ifndef _POSIX_SOURCE
162121430Sume#define ALTWERASE	0x00000200	/* use alternate WERASE algorithm */
16355163Sshin#endif  /*_POSIX_SOURCE */
16455163Sshin#define	IEXTEN		0x00000400	/* enable DISCARD and LNEXT */
16555163Sshin#define EXTPROC         0x00000800      /* external processing */
16655163Sshin#define TOSTOP		0x00400000	/* stop background jobs from output */
167158790Sume#ifndef _POSIX_SOURCE
168158790Sume#define FLUSHO		0x00800000	/* output being flushed (state) */
169158790Sume#define	NOKERNINFO	0x02000000	/* no kernel output from VSTATUS */
170158790Sume#define PENDIN		0x20000000	/* XXX retype pending input (state) */
17155163Sshin#endif  /*_POSIX_SOURCE */
17255163Sshin#define	NOFLSH		0x80000000	/* don't flush after interrupt */
17355163Sshin
17455163Sshintypedef unsigned long	tcflag_t;
17555163Sshintypedef unsigned char	cc_t;
17655163Sshintypedef long		speed_t;
177140908Sume
178140908Sumestruct termios {
179140908Sume	tcflag_t	c_iflag;	/* input flags */
18072693Sume	tcflag_t	c_oflag;	/* output flags */
181140908Sume	tcflag_t	c_cflag;	/* control flags */
182140908Sume	tcflag_t	c_lflag;	/* local flags */
18355163Sshin	cc_t		c_cc[NCCS];	/* control chars */
18455163Sshin	long		c_ispeed;	/* input speed */
18555163Sshin	long		c_ospeed;	/* output speed */
18655163Sshin};
18755163Sshin
18855163Sshin/*
18955163Sshin * Commands passed to tcsetattr() for setting the termios structure.
19055163Sshin */
19155163Sshin#define	TCSANOW		0		/* make change immediate */
19255163Sshin#define	TCSADRAIN	1		/* drain output, then change */
19355163Sshin#define	TCSAFLUSH	2		/* drain output, flush input */
19455163Sshin#ifndef _POSIX_SOURCE
19555163Sshin#define TCSASOFT	0x10		/* flag - don't alter h.w. state */
19655163Sshin#endif
19755163Sshin
19855163Sshin/*
19955163Sshin * Standard speeds
20055163Sshin */
20155163Sshin#define B0	0
20255163Sshin#define B50	50
20355163Sshin#define B75	75
20455163Sshin#define B110	110
205146690Sume#define B134	134
20655163Sshin#define B150	150
207121316Sume#define B200	200
20855163Sshin#define B300	300
20955163Sshin#define B600	600
21055163Sshin#define B1200	1200
21155163Sshin#define	B1800	1800
21257033Sshin#define B2400	2400
21355163Sshin#define B4800	4800
2141539Srgrimes#define B9600	9600
21593032Simp#define B19200	19200
21693032Simp#define B38400	38400
21793032Simp#ifndef _POSIX_SOURCE
21893032Simp#define B7200	7200
219189826Sdas#define B14400	14400
220189826Sdas#define B28800	28800
221189826Sdas#define B57600	57600
222189826Sdas#define B76800	76800
223189826Sdas#define B115200	115200
224189826Sdas#define B230400	230400
225189826Sdas#define EXTA	19200
226189826Sdas#define EXTB	38400
227189826Sdas#endif  /* !_POSIX_SOURCE */
228189826Sdas
229189826Sdas#ifndef KERNEL
230189826Sdas
231189826Sdas#define	TCIFLUSH	1
232189826Sdas#define	TCOFLUSH	2
233189826Sdas#define TCIOFLUSH	3
234189826Sdas#define	TCOOFF		1
235189826Sdas#define	TCOON		2
236189826Sdas#define TCIOFF		3
237189826Sdas#define TCION		4
238189826Sdas
239189826Sdas#include <sys/cdefs.h>
240189826Sdas
241189826Sdas__BEGIN_DECLS
242189826Sdasspeed_t	cfgetispeed __P((const struct termios *));
243189826Sdasspeed_t	cfgetospeed __P((const struct termios *));
244189826Sdasint	cfsetispeed __P((struct termios *, speed_t));
245189826Sdasint	cfsetospeed __P((struct termios *, speed_t));
246189826Sdasint	tcgetattr __P((int, struct termios *));
24793032Simpint	tcsetattr __P((int, int, const struct termios *));
248158477Sumeint	tcdrain __P((int));
249158477Sumeint	tcflow __P((int, int));
250157779Sumeint	tcflush __P((int, int));
251157779Sumeint	tcsendbreak __P((int, int));
25293032Simp
253157779Sume#ifndef _POSIX_SOURCE
254157779Sumevoid	cfmakeraw __P((struct termios *));
255157779Sumeint	cfsetspeed __P((struct termios *, speed_t));
256157779Sume#endif /* !_POSIX_SOURCE */
25793032Simp__END_DECLS
25893032Simp
259157779Sume#endif /* !KERNEL */
260157779Sume
261157779Sume#ifndef _POSIX_SOURCE
262157779Sume
263157779Sume/*
264157779Sume * Include tty ioctl's that aren't just for backwards compatibility
26593032Simp * with the old tty driver.  These ioctl definitions were previously
266157779Sume * in <sys/ioctl.h>.
267157779Sume */
268157779Sume#include <sys/ttycom.h>
269157779Sume#endif
270157779Sume
271157779Sume/*
272157779Sume * END OF PROTECTED INCLUDE.
273157779Sume */
274157779Sume#endif /* !_SYS_TERMIOS_H_ */
275157779Sume
276157779Sume#ifndef _POSIX_SOURCE
277157779Sume#include <sys/ttydefaults.h>
27893032Simp#endif
27993032Simp