xref: /original-bsd/sys/sys/termios.h (revision baf24c0d)
1 /*
2  * Copyright (c) 1988, 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)termios.h	7.19 (Berkeley) 12/16/90
8  */
9 
10 /*
11  *  termios structure
12  */
13 #ifndef _TERMIOS_
14 #define _TERMIOS_
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 #define	NCCS		20
55 #endif
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 
154 struct termios {
155 	tcflag_t	c_iflag;	/* input flags */
156 	tcflag_t	c_oflag;	/* output flags */
157 	tcflag_t	c_cflag;	/* control flags */
158 	tcflag_t	c_lflag;	/* local flags */
159 	cc_t		c_cc[NCCS];	/* control chars */
160 	long		c_ispeed;	/* input speed */
161 	long		c_ospeed;	/* output speed */
162 };
163 
164 /*
165  * Commands passed to tcsetattr() for setting the termios structure.
166  */
167 #define	TCSANOW		0		/* make change immediate */
168 #define	TCSADRAIN	1		/* drain output, then change */
169 #define	TCSAFLUSH	2		/* drain output, flush input */
170 #ifndef _POSIX_SOURCE
171 #define TCSASOFT	0x10		/* flag - don't alter h.w. state */
172 #endif
173 
174 /*
175  * Standard speeds
176  */
177 #define B0	0
178 #define B50	50
179 #define B75	75
180 #define B110	110
181 #define B134	134
182 #define B150	150
183 #define B200	200
184 #define B300	300
185 #define B600	600
186 #define B1200	1200
187 #define	B1800	1800
188 #define B2400	2400
189 #define B4800	4800
190 #define B9600	9600
191 #define B19200	19200
192 #define B38400	38400
193 #ifndef _POSIX_SOURCE
194 #define EXTA	19200
195 #define EXTB	38400
196 #endif  /*_POSIX_SOURCE */
197 /*
198  * END OF PROTECTED INCLUDE.
199  */
200 #endif /* _TERMIOS_ */
201 
202 #ifndef _POSIX_SOURCE
203 #ifdef KERNEL
204 #include "ttydefaults.h"
205 #else
206 #include <sys/ttydefaults.h>
207 #endif
208 #endif  /*_POSIX_SOURCE */
209