xref: /original-bsd/sys/sys/termios.h (revision e66e06db)
1 /*
2  * Copyright (c) 1988, 1989, 1993, 1994
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)termios.h	8.3 (Berkeley) 03/28/94
8  */
9 
10 #ifndef _SYS_TERMIOS_H_
11 #define _SYS_TERMIOS_H_
12 
13 /*
14  * Special Control Characters
15  *
16  * Index into c_cc[] character array.
17  *
18  *	Name	     Subscript	Enabled by
19  */
20 #define	VEOF		0	/* ICANON */
21 #define	VEOL		1	/* ICANON */
22 #ifndef _POSIX_SOURCE
23 #define	VEOL2		2	/* ICANON */
24 #endif
25 #define	VERASE		3	/* ICANON */
26 #ifndef _POSIX_SOURCE
27 #define VWERASE 	4	/* ICANON */
28 #endif
29 #define VKILL		5	/* ICANON */
30 #ifndef _POSIX_SOURCE
31 #define	VREPRINT 	6	/* ICANON */
32 #endif
33 /*			7	   spare 1 */
34 #define VINTR		8	/* ISIG */
35 #define VQUIT		9	/* ISIG */
36 #define VSUSP		10	/* ISIG */
37 #ifndef _POSIX_SOURCE
38 #define VDSUSP		11	/* ISIG */
39 #endif
40 #define VSTART		12	/* IXON, IXOFF */
41 #define VSTOP		13	/* IXON, IXOFF */
42 #ifndef _POSIX_SOURCE
43 #define	VLNEXT		14	/* IEXTEN */
44 #define	VDISCARD	15	/* IEXTEN */
45 #endif
46 #define VMIN		16	/* !ICANON */
47 #define VTIME		17	/* !ICANON */
48 #ifndef _POSIX_SOURCE
49 #define VSTATUS		18	/* ICANON */
50 /*			19	   spare 2 */
51 #endif
52 #define	NCCS		20
53 
54 #define _POSIX_VDISABLE	((unsigned char)'\377')
55 
56 #ifndef _POSIX_SOURCE
57 #define CCEQ(val, c)	(c == val ? val != _POSIX_VDISABLE : 0)
58 #endif
59 
60 /*
61  * Input flags - software input processing
62  */
63 #define	IGNBRK		0x00000001	/* ignore BREAK condition */
64 #define	BRKINT		0x00000002	/* map BREAK to SIGINTR */
65 #define	IGNPAR		0x00000004	/* ignore (discard) parity errors */
66 #define	PARMRK		0x00000008	/* mark parity and framing errors */
67 #define	INPCK		0x00000010	/* enable checking of parity errors */
68 #define	ISTRIP		0x00000020	/* strip 8th bit off chars */
69 #define	INLCR		0x00000040	/* map NL into CR */
70 #define	IGNCR		0x00000080	/* ignore CR */
71 #define	ICRNL		0x00000100	/* map CR to NL (ala CRMOD) */
72 #define	IXON		0x00000200	/* enable output flow control */
73 #define	IXOFF		0x00000400	/* enable input flow control */
74 #ifndef _POSIX_SOURCE
75 #define	IXANY		0x00000800	/* any char will restart after stop */
76 #define IMAXBEL		0x00002000	/* ring bell on input queue full */
77 #endif  /*_POSIX_SOURCE */
78 
79 /*
80  * Output flags - software output processing
81  */
82 #define	OPOST		0x00000001	/* enable following output processing */
83 #ifndef _POSIX_SOURCE
84 #define ONLCR		0x00000002	/* map NL to CR-NL (ala CRMOD) */
85 #define OXTABS		0x00000004	/* expand tabs to spaces */
86 #define ONOEOT		0x00000008	/* discard EOT's (^D) on output) */
87 #endif  /*_POSIX_SOURCE */
88 
89 /*
90  * Control flags - hardware control of terminal
91  */
92 #ifndef _POSIX_SOURCE
93 #define	CIGNORE		0x00000001	/* ignore control flags */
94 #endif
95 #define CSIZE		0x00000300	/* character size mask */
96 #define     CS5		    0x00000000	    /* 5 bits (pseudo) */
97 #define     CS6		    0x00000100	    /* 6 bits */
98 #define     CS7		    0x00000200	    /* 7 bits */
99 #define     CS8		    0x00000300	    /* 8 bits */
100 #define CSTOPB		0x00000400	/* send 2 stop bits */
101 #define CREAD		0x00000800	/* enable receiver */
102 #define PARENB		0x00001000	/* parity enable */
103 #define PARODD		0x00002000	/* odd parity, else even */
104 #define HUPCL		0x00004000	/* hang up on last close */
105 #define CLOCAL		0x00008000	/* ignore modem status lines */
106 #ifndef _POSIX_SOURCE
107 #define CCTS_OFLOW	0x00010000	/* CTS flow control of output */
108 #define CRTSCTS		CCTS_OFLOW	/* ??? */
109 #define CRTS_IFLOW	0x00020000	/* RTS flow control of input */
110 #define	MDMBUF		0x00100000	/* flow control output via Carrier */
111 #endif
112 
113 
114 /*
115  * "Local" flags - dumping ground for other state
116  *
117  * Warning: some flags in this structure begin with
118  * the letter "I" and look like they belong in the
119  * input flag.
120  */
121 
122 #ifndef _POSIX_SOURCE
123 #define	ECHOKE		0x00000001	/* visual erase for line kill */
124 #endif  /*_POSIX_SOURCE */
125 #define	ECHOE		0x00000002	/* visually erase chars */
126 #define	ECHOK		0x00000004	/* echo NL after line kill */
127 #define ECHO		0x00000008	/* enable echoing */
128 #define	ECHONL		0x00000010	/* echo NL even if ECHO is off */
129 #ifndef _POSIX_SOURCE
130 #define	ECHOPRT		0x00000020	/* visual erase mode for hardcopy */
131 #define ECHOCTL  	0x00000040	/* echo control chars as ^(Char) */
132 #endif  /*_POSIX_SOURCE */
133 #define	ISIG		0x00000080	/* enable signals INTR, QUIT, [D]SUSP */
134 #define	ICANON		0x00000100	/* canonicalize input lines */
135 #ifndef _POSIX_SOURCE
136 #define ALTWERASE	0x00000200	/* use alternate WERASE algorithm */
137 #endif  /*_POSIX_SOURCE */
138 #define	IEXTEN		0x00000400	/* enable DISCARD and LNEXT */
139 #define EXTPROC         0x00000800      /* external processing */
140 #define TOSTOP		0x00400000	/* stop background jobs from output */
141 #ifndef _POSIX_SOURCE
142 #define FLUSHO		0x00800000	/* output being flushed (state) */
143 #define	NOKERNINFO	0x02000000	/* no kernel output from VSTATUS */
144 #define PENDIN		0x20000000	/* XXX retype pending input (state) */
145 #endif  /*_POSIX_SOURCE */
146 #define	NOFLSH		0x80000000	/* don't flush after interrupt */
147 
148 typedef unsigned long	tcflag_t;
149 typedef unsigned char	cc_t;
150 typedef long		speed_t;
151 
152 struct termios {
153 	tcflag_t	c_iflag;	/* input flags */
154 	tcflag_t	c_oflag;	/* output flags */
155 	tcflag_t	c_cflag;	/* control flags */
156 	tcflag_t	c_lflag;	/* local flags */
157 	cc_t		c_cc[NCCS];	/* control chars */
158 	long		c_ispeed;	/* input speed */
159 	long		c_ospeed;	/* output speed */
160 };
161 
162 /*
163  * Commands passed to tcsetattr() for setting the termios structure.
164  */
165 #define	TCSANOW		0		/* make change immediate */
166 #define	TCSADRAIN	1		/* drain output, then change */
167 #define	TCSAFLUSH	2		/* drain output, flush input */
168 #ifndef _POSIX_SOURCE
169 #define TCSASOFT	0x10		/* flag - don't alter h.w. state */
170 #endif
171 
172 /*
173  * Standard speeds
174  */
175 #define B0	0
176 #define B50	50
177 #define B75	75
178 #define B110	110
179 #define B134	134
180 #define B150	150
181 #define B200	200
182 #define B300	300
183 #define B600	600
184 #define B1200	1200
185 #define	B1800	1800
186 #define B2400	2400
187 #define B4800	4800
188 #define B9600	9600
189 #define B19200	19200
190 #define B38400	38400
191 #ifndef _POSIX_SOURCE
192 #define B7200	7200
193 #define B14400	14400
194 #define B28800	28800
195 #define B57600	57600
196 #define B76800	76800
197 #define B115200	115200
198 #define B230400	230400
199 #define EXTA	19200
200 #define EXTB	38400
201 #endif  /* !_POSIX_SOURCE */
202 
203 #ifndef KERNEL
204 
205 #define	TCIFLUSH	1
206 #define	TCOFLUSH	2
207 #define TCIOFLUSH	3
208 #define	TCOOFF		1
209 #define	TCOON		2
210 #define TCIOFF		3
211 #define TCION		4
212 
213 #include <sys/cdefs.h>
214 
215 __BEGIN_DECLS
216 speed_t	cfgetispeed __P((const struct termios *));
217 speed_t	cfgetospeed __P((const struct termios *));
218 int	cfsetispeed __P((struct termios *, speed_t));
219 int	cfsetospeed __P((struct termios *, speed_t));
220 int	tcgetattr __P((int, struct termios *));
221 int	tcsetattr __P((int, int, const struct termios *));
222 int	tcdrain __P((int));
223 int	tcflow __P((int, int));
224 int	tcflush __P((int, int));
225 int	tcsendbreak __P((int, int));
226 
227 #ifndef _POSIX_SOURCE
228 void	cfmakeraw __P((struct termios *));
229 int	cfsetspeed __P((struct termios *, speed_t));
230 #endif /* !_POSIX_SOURCE */
231 __END_DECLS
232 
233 #endif /* !KERNEL */
234 
235 #ifndef _POSIX_SOURCE
236 
237 /*
238  * Include tty ioctl's that aren't just for backwards compatibility
239  * with the old tty driver.  These ioctl definitions were previously
240  * in <sys/ioctl.h>.
241  */
242 #include <sys/ttycom.h>
243 #endif
244 
245 /*
246  * END OF PROTECTED INCLUDE.
247  */
248 #endif /* !_SYS_TERMIOS_H_ */
249 
250 #ifndef _POSIX_SOURCE
251 #include <sys/ttydefaults.h>
252 #endif
253