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