termios.h revision 34522
1344884Scy/*
2275970Scy * Copyright (c) 1988, 1989, 1993, 1994
3344884Scy *	The Regents of the University of California.  All rights reserved.
4285169Scy *
5275970Scy * Redistribution and use in source and binary forms, with or without
6275970Scy * modification, are permitted provided that the following conditions
7275970Scy * are met:
8275970Scy * 1. Redistributions of source code must retain the above copyright
9275970Scy *    notice, this list of conditions and the following disclaimer.
10275970Scy * 2. Redistributions in binary form must reproduce the above copyright
11275970Scy *    notice, this list of conditions and the following disclaimer in the
12275970Scy *    documentation and/or other materials provided with the distribution.
13275970Scy * 3. All advertising materials mentioning features or use of this software
14285169Scy *    must display the following acknowledgement:
15275970Scy *	This product includes software developed by the University of
16275970Scy *	California, Berkeley and its contributors.
17285169Scy * 4. Neither the name of the University nor the names of its contributors
18285169Scy *    may be used to endorse or promote products derived from this software
19275970Scy *    without specific prior written permission.
20275970Scy *
21285169Scy * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22275970Scy * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23344884Scy * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24275970Scy * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25275970Scy * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26275970Scy * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27275970Scy * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28275970Scy * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29275970Scy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30275970Scy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31275970Scy * SUCH DAMAGE.
32275970Scy *
33275970Scy *	@(#)termios.h	8.3 (Berkeley) 3/28/94
34275970Scy * $Id: termios.h,v 1.9 1997/02/22 09:46:07 peter Exp $
35285169Scy */
36275970Scy
37275970Scy#ifndef _SYS_TERMIOS_H_
38344884Scy#define _SYS_TERMIOS_H_
39275970Scy
40275970Scy/*
41275970Scy * Special Control Characters
42275970Scy *
43275970Scy * Index into c_cc[] character array.
44275970Scy *
45275970Scy *	Name	     Subscript	Enabled by
46275970Scy */
47275970Scy#define	VEOF		0	/* ICANON */
48275970Scy#define	VEOL		1	/* ICANON */
49275970Scy#ifndef _POSIX_SOURCE
50275970Scy#define	VEOL2		2	/* ICANON together with IEXTEN */
51275970Scy#endif
52275970Scy#define	VERASE		3	/* ICANON */
53275970Scy#ifndef _POSIX_SOURCE
54344884Scy#define VWERASE 	4	/* ICANON together with IEXTEN */
55275970Scy#endif
56275970Scy#define VKILL		5	/* ICANON */
57275970Scy#ifndef _POSIX_SOURCE
58275970Scy#define	VREPRINT 	6	/* ICANON together with IEXTEN */
59275970Scy#endif
60275970Scy/*			7	   spare 1 */
61344884Scy#define VINTR		8	/* ISIG */
62275970Scy#define VQUIT		9	/* ISIG */
63275970Scy#define VSUSP		10	/* ISIG */
64275970Scy#ifndef _POSIX_SOURCE
65275970Scy#define VDSUSP		11	/* ISIG together with IEXTEN */
66275970Scy#endif
67275970Scy#define VSTART		12	/* IXON, IXOFF */
68285169Scy#define VSTOP		13	/* IXON, IXOFF */
69285169Scy#ifndef _POSIX_SOURCE
70275970Scy#define	VLNEXT		14	/* IEXTEN */
71275970Scy#define	VDISCARD	15	/* IEXTEN */
72275970Scy#endif
73275970Scy#define VMIN		16	/* !ICANON */
74275970Scy#define VTIME		17	/* !ICANON */
75275970Scy#ifndef _POSIX_SOURCE
76275970Scy#define VSTATUS		18	/* ICANON together with IEXTEN */
77275970Scy/*			19	   spare 2 */
78275970Scy#endif
79275970Scy#define	NCCS		20
80275970Scy
81275970Scy#define	_POSIX_VDISABLE	0xff
82275970Scy
83275970Scy#ifndef _POSIX_SOURCE
84275970Scy#define	CCEQ(val, c)	((c) == (val) ? (val) != _POSIX_VDISABLE : 0)
85275970Scy#endif
86275970Scy
87275970Scy/*
88285169Scy * Input flags - software input processing
89275970Scy */
90275970Scy#define	IGNBRK		0x00000001	/* ignore BREAK condition */
91275970Scy#define	BRKINT		0x00000002	/* map BREAK to SIGINTR */
92275970Scy#define	IGNPAR		0x00000004	/* ignore (discard) parity errors */
93275970Scy#define	PARMRK		0x00000008	/* mark parity and framing errors */
94275970Scy#define	INPCK		0x00000010	/* enable checking of parity errors */
95275970Scy#define	ISTRIP		0x00000020	/* strip 8th bit off chars */
96275970Scy#define	INLCR		0x00000040	/* map NL into CR */
97275970Scy#define	IGNCR		0x00000080	/* ignore CR */
98275970Scy#define	ICRNL		0x00000100	/* map CR to NL (ala CRMOD) */
99275970Scy#define	IXON		0x00000200	/* enable output flow control */
100275970Scy#define	IXOFF		0x00000400	/* enable input flow control */
101275970Scy#ifndef _POSIX_SOURCE
102275970Scy#define	IXANY		0x00000800	/* any char will restart after stop */
103275970Scy#define IMAXBEL		0x00002000	/* ring bell on input queue full */
104275970Scy#endif  /*_POSIX_SOURCE */
105275970Scy
106285169Scy/*
107285169Scy * Output flags - software output processing
108285169Scy */
109275970Scy#define	OPOST		0x00000001	/* enable following output processing */
110275970Scy#ifndef _POSIX_SOURCE
111275970Scy#define ONLCR		0x00000002	/* map NL to CR-NL (ala CRMOD) */
112275970Scy#define OXTABS		0x00000004	/* expand tabs to spaces */
113344884Scy#define ONOEOT		0x00000008	/* discard EOT's (^D) on output) */
114275970Scy#endif  /*_POSIX_SOURCE */
115275970Scy
116275970Scy/*
117275970Scy * Control flags - hardware control of terminal
118275970Scy */
119275970Scy#ifndef _POSIX_SOURCE
120275970Scy#define	CIGNORE		0x00000001	/* ignore control flags */
121275970Scy#endif
122275970Scy#define CSIZE		0x00000300	/* character size mask */
123285169Scy#define     CS5		    0x00000000	    /* 5 bits (pseudo) */
124285169Scy#define     CS6		    0x00000100	    /* 6 bits */
125285169Scy#define     CS7		    0x00000200	    /* 7 bits */
126275970Scy#define     CS8		    0x00000300	    /* 8 bits */
127275970Scy#define CSTOPB		0x00000400	/* send 2 stop bits */
128275970Scy#define CREAD		0x00000800	/* enable receiver */
129275970Scy#define PARENB		0x00001000	/* parity enable */
130275970Scy#define PARODD		0x00002000	/* odd parity, else even */
131275970Scy#define HUPCL		0x00004000	/* hang up on last close */
132275970Scy#define CLOCAL		0x00008000	/* ignore modem status lines */
133275970Scy#ifndef _POSIX_SOURCE
134275970Scy#define CCTS_OFLOW	0x00010000	/* CTS flow control of output */
135275970Scy#define CRTSCTS		(CCTS_OFLOW | CRTS_IFLOW)
136275970Scy#define CRTS_IFLOW	0x00020000	/* RTS flow control of input */
137275970Scy#define	CDTR_IFLOW	0x00040000	/* DTR flow control of input */
138275970Scy#define CDSR_OFLOW	0x00080000	/* DSR flow control of output */
139275970Scy#define	CCAR_OFLOW	0x00100000	/* DCD flow control of output */
140275970Scy#define	MDMBUF		0x00100000	/* old name for CCAR_OFLOW */
141275970Scy#endif
142275970Scy
143275970Scy
144344884Scy/*
145275970Scy * "Local" flags - dumping ground for other state
146275970Scy *
147275970Scy * Warning: some flags in this structure begin with
148275970Scy * the letter "I" and look like they belong in the
149275970Scy * input flag.
150275970Scy */
151285169Scy
152275970Scy#ifndef _POSIX_SOURCE
153275970Scy#define	ECHOKE		0x00000001	/* visual erase for line kill */
154275970Scy#endif  /*_POSIX_SOURCE */
155275970Scy#define	ECHOE		0x00000002	/* visually erase chars */
156275970Scy#define	ECHOK		0x00000004	/* echo NL after line kill */
157275970Scy#define ECHO		0x00000008	/* enable echoing */
158275970Scy#define	ECHONL		0x00000010	/* echo NL even if ECHO is off */
159275970Scy#ifndef _POSIX_SOURCE
160275970Scy#define	ECHOPRT		0x00000020	/* visual erase mode for hardcopy */
161285169Scy#define ECHOCTL  	0x00000040	/* echo control chars as ^(Char) */
162275970Scy#endif  /*_POSIX_SOURCE */
163275970Scy#define	ISIG		0x00000080	/* enable signals INTR, QUIT, [D]SUSP */
164275970Scy#define	ICANON		0x00000100	/* canonicalize input lines */
165275970Scy#ifndef _POSIX_SOURCE
166275970Scy#define ALTWERASE	0x00000200	/* use alternate WERASE algorithm */
167275970Scy#endif  /*_POSIX_SOURCE */
168275970Scy#define	IEXTEN		0x00000400	/* enable DISCARD and LNEXT */
169275970Scy#define EXTPROC         0x00000800      /* external processing */
170275970Scy#define TOSTOP		0x00400000	/* stop background jobs from output */
171275970Scy#ifndef _POSIX_SOURCE
172275970Scy#define FLUSHO		0x00800000	/* output being flushed (state) */
173275970Scy#define	NOKERNINFO	0x02000000	/* no kernel output from VSTATUS */
174285169Scy#define PENDIN		0x20000000	/* XXX retype pending input (state) */
175285169Scy#endif  /*_POSIX_SOURCE */
176285169Scy#define	NOFLSH		0x80000000	/* don't flush after interrupt */
177285169Scy
178285169Scytypedef unsigned long	tcflag_t;
179285169Scytypedef unsigned char	cc_t;
180285169Scytypedef unsigned long	speed_t;
181275970Scy
182275970Scystruct termios {
183275970Scy	tcflag_t	c_iflag;	/* input flags */
184275970Scy	tcflag_t	c_oflag;	/* output flags */
185275970Scy	tcflag_t	c_cflag;	/* control flags */
186275970Scy	tcflag_t	c_lflag;	/* local flags */
187275970Scy	cc_t		c_cc[NCCS];	/* control chars */
188285169Scy	speed_t		c_ispeed;	/* input speed */
189285169Scy	speed_t		c_ospeed;	/* output speed */
190285169Scy};
191275970Scy
192275970Scy/*
193275970Scy * Commands passed to tcsetattr() for setting the termios structure.
194275970Scy */
195275970Scy#define	TCSANOW		0		/* make change immediate */
196275970Scy#define	TCSADRAIN	1		/* drain output, then change */
197275970Scy#define	TCSAFLUSH	2		/* drain output, flush input */
198275970Scy#ifndef _POSIX_SOURCE
199275970Scy#define TCSASOFT	0x10		/* flag - don't alter h.w. state */
200275970Scy#endif
201275970Scy
202275970Scy/*
203275970Scy * Standard speeds
204275970Scy */
205275970Scy#define B0	0
206275970Scy#define B50	50
207275970Scy#define B75	75
208275970Scy#define B110	110
209275970Scy#define B134	134
210275970Scy#define B150	150
211275970Scy#define B200	200
212275970Scy#define B300	300
213275970Scy#define B600	600
214275970Scy#define B1200	1200
215275970Scy#define	B1800	1800
216275970Scy#define B2400	2400
217275970Scy#define B4800	4800
218275970Scy#define B9600	9600
219275970Scy#define B19200	19200
220275970Scy#define B38400	38400
221275970Scy#ifndef _POSIX_SOURCE
222275970Scy#define B7200	7200
223275970Scy#define B14400	14400
224275970Scy#define B28800	28800
225275970Scy#define B57600	57600
226275970Scy#define B76800	76800
227275970Scy#define B115200	115200
228275970Scy#define B230400	230400
229285169Scy#define EXTA	19200
230285169Scy#define EXTB	38400
231285169Scy#endif  /* !_POSIX_SOURCE */
232275970Scy
233275970Scy#ifndef KERNEL
234275970Scy
235285169Scy#define	TCIFLUSH	1
236275970Scy#define	TCOFLUSH	2
237285169Scy#define TCIOFLUSH	3
238285169Scy#define	TCOOFF		1
239275970Scy#define	TCOON		2
240275970Scy#define TCIOFF		3
241275970Scy#define TCION		4
242275970Scy
243275970Scy#include <sys/cdefs.h>
244275970Scy
245275970Scy__BEGIN_DECLS
246275970Scyspeed_t	cfgetispeed __P((const struct termios *));
247285169Scyspeed_t	cfgetospeed __P((const struct termios *));
248285169Scyint	cfsetispeed __P((struct termios *, speed_t));
249275970Scyint	cfsetospeed __P((struct termios *, speed_t));
250275970Scyint	tcgetattr __P((int, struct termios *));
251275970Scyint	tcsetattr __P((int, int, const struct termios *));
252275970Scyint	tcdrain __P((int));
253275970Scyint	tcflow __P((int, int));
254275970Scyint	tcflush __P((int, int));
255285169Scyint	tcsendbreak __P((int, int));
256285169Scy
257275970Scy#ifndef _POSIX_SOURCE
258275970Scyvoid	cfmakeraw __P((struct termios *));
259275970Scyint	cfsetspeed __P((struct termios *, speed_t));
260275970Scy#endif /* !_POSIX_SOURCE */
261275970Scy__END_DECLS
262275970Scy
263275970Scy#endif /* !KERNEL */
264275970Scy
265275970Scy#ifndef _POSIX_SOURCE
266275970Scy
267275970Scy/*
268275970Scy * Include tty ioctl's that aren't just for backwards compatibility
269275970Scy * with the old tty driver.  These ioctl definitions were previously
270275970Scy * in <sys/ioctl.h>.
271275970Scy */
272275970Scy#include <sys/ttycom.h>
273275970Scy#endif
274275970Scy
275275970Scy/*
276275970Scy * END OF PROTECTED INCLUDE.
277275970Scy */
278275970Scy#endif /* !_SYS_TERMIOS_H_ */
279275970Scy
280275970Scy#ifndef _POSIX_SOURCE
281275970Scy#include <sys/ttydefaults.h>
282275970Scy#endif
283275970Scy