xref: /original-bsd/sys/sys/termios.h (revision abd50c55)
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.7 (Berkeley) 04/04/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  /*_POSIX_SOURCE */
38 #define	VERASE		3	/* ICANON */
39 #ifndef _POSIX_SOURCE
40 #define VWERASE 	4	/* ICANON */
41 #endif  /*_POSIX_SOURCE */
42 #define VKILL		5	/* ICANON */
43 #ifndef _POSIX_SOURCE
44 #define	VREPRINT 	6	/* ICANON */
45 #endif  /*_POSIX_SOURCE */
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  /*_POSIX_SOURCE */
53 #define VSTART		12	/* IXON, IXOFF */
54 #define VSTOP		13	/* IXON, IXOFF */
55 #ifndef _POSIX_SOURCE
56 #define	VLNEXT		14	/* IEXTEN */
57 #define	VFLUSHO		15	/* IEXTEN */
58 #define	VFLUSH		VFLUSHO	/* for sun */
59 #endif  /*_POSIX_SOURCE */
60 #define VMIN		16	/* !ICANON */
61 #define VTIME		17	/* !ICANON */
62 #ifndef _POSIX_SOURCE
63 #define VINFO		18	/* ISIG */
64 /*			19	   spare 2 */
65 #define	NCC		20
66 #endif  /*_POSIX_SOURCE */
67 
68 #define _POSIX_VDISABLE	((unsigned char)'\377')
69 
70 #ifndef _POSIX_SOURCE
71 #define CCEQ(val, c)	(c == val ? val != _POSIX_VDISABLE : 0)
72 #endif
73 
74 /*
75  * Input flags - software input processing
76  */
77 #define	IGNBRK		0x00000001	/* ignore BREAK condition */
78 #define	BRKINT		0x00000002	/* map BREAK to SIGINTR */
79 #define	IGNPAR		0x00000004	/* ignore (discard) parity errors */
80 #define	PARMRK		0x00000008	/* mark parity and framing errors */
81 #define	INPCK		0x00000010	/* enable checking of parity errors */
82 #define	ISTRIP		0x00000020	/* strip 8th bit off chars */
83 #define	INLCR		0x00000040	/* map NL into CR */
84 #define	IGNCR		0x00000080	/* ignore CR */
85 #define	ICRNL		0x00000100	/* map CR to NL (ala CRMOD) */
86 #define	IXON		0x00000200	/* enable output flow control */
87 #define	IXOFF		0x00000400	/* enable input flow control */
88 #ifndef _POSIX_SOURCE
89 #define	IFLOW		IXON		/* enable output flow control */
90 #define	ITANDEM		IXOFF		/* enable input flow control */
91 #define	IXANY		0x00000800	/* any char will restart after stop */
92 #define IMAXBEL		0x00002000	/* ring bell on input queue full */
93 #endif  /*_POSIX_SOURCE */
94 
95 /*
96  * Output flags - software output processing
97  */
98 #define	OPOST		0x00000001	/* enable following output processing */
99 #ifndef _POSIX_SOURCE
100 #define ONLCR		0x00000002	/* map NL to CR-NL (ala CRMOD) */
101 #define ONLCRNL		ONLCR
102 #define OXTABS		0x00000004	/* expand tabs to spaces */
103 #define ONOEOT		0x00000008	/* discard EOT's (^D) on output) */
104 #endif  /*_POSIX_SOURCE */
105 
106 /*
107  * Control flags - hardware control of terminal
108  */
109 #ifndef _POSIX_SOURCE
110 #define	CIGNORE		0x00000001	/* ignore control flags */
111 #endif  /*_POSIX_SOURCE */
112 #define CSIZE		0x00000300	/* character size mask */
113 #define     CS5		    0x00000000	    /* 5 bits (pseudo) */
114 #define     CS6		    0x00000100	    /* 6 bits */
115 #define     CS7		    0x00000200	    /* 7 bits */
116 #define     CS8		    0x00000300	    /* 8 bits */
117 #define CSTOPB		0x00000400	/* send 2 stop bits */
118 #define CREAD		0x00000800	/* enable receiver */
119 #define PARENB		0x00001000	/* parity enable */
120 #define PARODD		0x00002000	/* odd parity, else even */
121 #ifndef _POSIX_SOURCE
122 #define HUPCL		0x00004000	/* hang up on last close */
123 #endif  /*_POSIX_SOURCE */
124 #define CLOCAL		0x00008000	/* ignore modem status lines */
125 #ifndef _POSIX_SOURCE
126 #define CCTS_OFLOW	0x00010000	/* CTS flow control of output */
127 #define CRTSCTS		CCTS_OFLOW	/* ??? */
128 #define CRTS_IFLOW	0x00020000	/* RTS flow control of input */
129 #define	MDMBUF		0x00100000	/* flow control output via Carrier */
130 #endif  /*_POSIX_SOURCE */
131 
132 
133 /*
134  * "Local" flags - dumping ground for other state
135  *
136  * Warning: some flags in this structure begin with
137  * the letter "I" and look like they belong in the
138  * input flag.
139  */
140 
141 #ifndef _POSIX_SOURCE
142 #define	ECHOKE		0x00000001	/* visual erase for line kill */
143 #endif  /*_POSIX_SOURCE */
144 #define	ECHOE		0x00000002	/* visually erase chars */
145 #define	ECHOK		0x00000004	/* echo NL after line kill */
146 #define ECHO		0x00000008	/* enable echoing */
147 #define	ECHONL		0x00000010	/* echo NL even if ECHO is off */
148 #ifndef _POSIX_SOURCE
149 #define	ECHOPRT		0x00000020	/* visual erase mode for hardcopy */
150 #define ECHOCTL  	0x00000040	/* echo control chars as ^(Char) */
151 #endif  /*_POSIX_SOURCE */
152 #define	ISIG		0x00000080	/* enable signals INTR, QUIT, [D]SUSP */
153 #define	ICANON		0x00000100	/* canonicalize input lines */
154 #ifndef _POSIX_SOURCE
155 #define ALTWERASE	0x00000200	/* use alternate WERASE algorithm */
156 #endif  /*_POSIX_SOURCE */
157 #define	IEXTEN		0x00000400	/* enable FLUSHO and LNEXT */
158 #define TOSTOP		0x00400000	/* stop background jobs from output */
159 #ifndef _POSIX_SOURCE
160 #define FLUSHO		0x00800000	/* output being flushed (state) */
161 #define	NOHANG		0x01000000	/* XXX this should go away */
162 #define	NOKERNINFO	0x02000000	/* no kernel output from VINFO */
163 #define PENDIN		0x20000000	/* XXX retype pending input (state) */
164 #endif  /*_POSIX_SOURCE */
165 #define	NOFLSH		0x80000000	/* don't flush after interrupt */
166 
167 typedef unsigned long	tcflag_t;
168 typedef unsigned char	cc_t;
169 
170 struct termios {
171 	tcflag_t	c_iflag;	/* input flags */
172 	tcflag_t	c_oflag;	/* output flags */
173 	tcflag_t	c_cflag;	/* control flags */
174 	tcflag_t	c_lflag;	/* local flags */
175 	cc_t		c_cc[NCC];	/* control chars */
176 	long		c_ispeed;	/* input speed */
177 	long		c_ospeed;	/* output speed */
178 };
179 
180 /*
181  * Commands passed to tcsetattr() for setting the termios structure.
182  */
183 #define	TCSANOW		0		/* make change immediate */
184 #define	TCSADRAIN	1		/* drain output, then change */
185 #define	TCSADFLUSH	2		/* drain output, flush input */
186 
187 /*
188  * Standard speeds
189  */
190 #define B0	0
191 #define B50	50
192 #define B75	75
193 #define B110	110
194 #define B134	134
195 #define B150	150
196 #define B200	200
197 #define B300	300
198 #define B600	600
199 #define B1200	1200
200 #define	B1800	1800
201 #define B2400	2400
202 #define B4800	4800
203 #define B9600	9600
204 #define B19200	19200
205 #define B38400	38400
206 #ifndef _POSIX_SOURCE
207 #define EXTA	19200
208 #define EXTB	38400
209 #endif  /*_POSIX_SOURCE */
210 /*
211  * END OF PROTECTED INCLUDE.
212  */
213 #endif /* _TERMIOS_ */
214 
215 #ifndef _POSIX_SOURCE
216 #ifdef KERNEL
217 #include "ttydefaults.h"
218 #else
219 #include <sys/ttydefaults.h>
220 #endif
221 #endif  /*_POSIX_SOURCE */
222