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