xref: /titanic_41/usr/src/ucbcmd/stty/sttytable.c (revision 6185db853e024a486ff8837e6784dd290d866112)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1995 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 
33 #include <stdio.h>
34 #include <sys/types.h>
35 #include <termio.h>
36 #include <sys/stermio.h>
37 #include <sys/termiox.h>
38 #include "stty.h"
39 
40 const struct	speeds speeds[] = {
41 	"0",	B0,
42 	"50",	B50,
43 	"75",	B75,
44 	"110",	B110,
45 	"134",	B134,
46 	"134.5",B134,
47 	"150",	B150,
48 	"200",	B200,
49 	"300",	B300,
50 	"600",	B600,
51 	"1200",	B1200,
52 	"1800",	B1800,
53 	"2400",	B2400,
54 	"4800",	B4800,
55 	"9600",	B9600,
56 	"19200",	B19200,
57 	"19.2",		B19200,
58 	"exta",		EXTA,
59 	"38400",	B38400,
60 	"38.4",		B38400,
61 	"extb",		EXTB,
62 	"57600",	B57600,
63 	"76800",	B76800,
64 	"115200",	B115200,
65 	"153600",	B153600,
66 	"230400",	B230400,
67 	"307200",	B307200,
68 	"460800",	B460800,
69 	0,
70 };
71 						/* Control Modes */
72 const struct mds cmodes[] = {
73 	"-parity", CS8, PARENB|CSIZE,
74 	"-evenp", CS8, PARENB|CSIZE,
75 	"-even", CS8, PARENB|CSIZE,
76 	"-oddp", CS8, PARENB|PARODD|CSIZE,
77 	"-odd", CS8, PARENB|PARODD|CSIZE,
78 	"parity", PARENB|CS7, PARODD|CSIZE,
79 	"evenp", PARENB|CS7, PARODD|CSIZE,
80 	"even", PARENB|CS7, PARODD|CSIZE,
81 	"oddp", PARENB|PARODD|CS7, CSIZE,
82 	"odd", PARENB|PARODD|CS7, CSIZE,
83 	"parenb", PARENB, 0,
84 	"-parenb", 0, PARENB,
85 	"parodd", PARODD, 0,
86 	"-parodd", 0, PARODD,
87 	"cs8", CS8, CSIZE,
88 	"cs7", CS7, CSIZE,
89 	"cs6", CS6, CSIZE,
90 	"cs5", CS5, CSIZE,
91 	"cstopb", CSTOPB, 0,
92 	"-cstopb", 0, CSTOPB,
93 	"hupcl", HUPCL, 0,
94 	"hup", HUPCL, 0,
95 	"-hupcl", 0, HUPCL,
96 	"-hup", 0, HUPCL,
97 	"clocal", CLOCAL, 0,
98 	"-clocal", 0, CLOCAL,
99 	"loblk", LOBLK, 0,
100 	"-loblk", 0, LOBLK,
101 	"cread", CREAD, 0,
102 	"-cread", 0, CREAD,
103 	"litout", CS8, (CSIZE|PARENB),
104 	"-litout", (CS7|PARENB), CSIZE,
105 	"pass8", CS8, (CSIZE|PARENB),
106 	"-pass8", (CS7|PARENB), CSIZE,
107 	"raw", CS8, (CSIZE|PARENB),
108 	"-raw", (CS7|PARENB), CSIZE,
109 	"cooked", (CS7|PARENB), CSIZE,
110 	"sane", (CS7|PARENB|CREAD), (CSIZE|PARODD|CLOCAL),
111 	0
112 };
113 
114 const struct mds ncmodes[] = {
115 	"parext", PAREXT, 0,
116 	"-parext", 0, PAREXT,
117 	"markp", (PARENB|PARODD|CS7|PAREXT), CSIZE,
118 	"-markp", CS8, (PARENB|PARODD|CSIZE|PAREXT),
119 	"spacep", (PARENB|CS7|PAREXT), PARODD|CSIZE,
120 	"-spacep", CS8, (PARENB|CSIZE|PAREXT),
121 	0
122 };
123 						/* Input Modes */
124 const struct mds imodes[] = {
125 	"ignbrk", IGNBRK, 0,
126 	"-ignbrk", 0, IGNBRK,
127 	"brkint", BRKINT, 0,
128 	"-brkint", 0, BRKINT,
129 	"ignpar", IGNPAR, 0,
130 	"-ignpar", 0, IGNPAR,
131 	"parmrk", PARMRK, 0,
132 	"-parmrk", 0, PARMRK,
133 	"inpck", INPCK, 0,
134 	"-inpck", 0,INPCK,
135 	"istrip", ISTRIP, 0,
136 	"-istrip", 0, ISTRIP,
137 	"inlcr", INLCR, 0,
138 	"-inlcr", 0, INLCR,
139 	"igncr", IGNCR, 0,
140 	"-igncr", 0, IGNCR,
141 	"icrnl", ICRNL, 0,
142 	"-icrnl", 0, ICRNL,
143 	"-nl", ICRNL, (INLCR|IGNCR),
144 	"nl", 0, ICRNL,
145 	"iuclc", IUCLC, 0,
146 	"-iuclc", 0, IUCLC,
147 	"lcase", IUCLC, 0,
148 	"-lcase", 0, IUCLC,
149 	"LCASE", IUCLC, 0,
150 	"-LCASE", 0, IUCLC,
151 	"ixon", IXON, 0,
152 	"-ixon", 0, IXON,
153 	"ixany", IXANY, 0,
154 	"-ixany", 0, IXANY,
155 	"decctlq", 0, IXANY,
156 	"-decctlq", IXANY, 0,
157 	"ixoff", IXOFF, 0,
158 	"-ixoff", 0, IXOFF,
159 	"tandem", IXOFF, 0,
160 	"-tandem", 0, IXOFF,
161 	"pass8", 0, ISTRIP,
162 	"-pass8", ISTRIP, 0,
163 	"raw", 0, -1,
164 	"-raw", (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON|IMAXBEL), 0,
165 	"cooked", (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON), 0,
166 	"sane", (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON|IMAXBEL),
167 		(IGNBRK|PARMRK|INPCK|INLCR|IGNCR|IUCLC|IXOFF),
168 	0
169 };
170 
171 const struct mds nimodes[] = {
172 	"imaxbel", IMAXBEL, 0,
173 	"-imaxbel", 0, IMAXBEL,
174 	0
175 };
176 						/* Local Modes */
177 const struct mds lmodes[] = {
178 	"isig", ISIG, 0,
179 	"-isig", 0, ISIG,
180 	"icanon", ICANON, 0,
181 	"-icanon", 0, ICANON,
182 	"cbreak", 0, ICANON,
183 	"-cbreak", ICANON, 0,
184 	"xcase", XCASE, 0,
185 	"-xcase", 0, XCASE,
186 	"lcase", XCASE, 0,
187 	"-lcase", 0, XCASE,
188 	"LCASE", XCASE, 0,
189 	"-LCASE", 0, XCASE,
190 	"echo", ECHO, 0,
191 	"-echo", 0, ECHO,
192 	"echoe", ECHOE, 0,
193 	"-echoe", 0, ECHOE,
194 	"crterase", ECHOE, 0,
195 	"-crterase", 0, ECHOE,
196 	"echok", ECHOK, 0,
197 	"-echok", 0, ECHOK,
198 	"lfkc", ECHOK, 0,
199 	"-lfkc", 0, ECHOK,
200 	"echonl", ECHONL, 0,
201 	"-echonl", 0, ECHONL,
202 	"noflsh", NOFLSH, 0,
203 	"-noflsh", 0, NOFLSH,
204 	"raw", 0, (ISIG|ICANON|XCASE|IEXTEN),
205 	"-raw", (ISIG|ICANON|IEXTEN), 0,
206 	"cooked", (ISIG|ICANON), 0,
207 	"sane", (ISIG|ICANON|IEXTEN|ECHO|ECHOK|ECHOE|ECHOCTL|ECHOKE),
208 		(XCASE|ECHONL|NOFLSH|STFLUSH|STWRAP|STAPPL),
209 	"stflush", STFLUSH, 0,
210 	"-stflush", 0, STFLUSH,
211 	"stwrap", STWRAP, 0,
212 	"-stwrap", 0, STWRAP,
213 	"stappl", STAPPL, 0,
214 	"-stappl", 0, STAPPL,
215 	0,
216 };
217 
218 const struct mds nlmodes[] = {
219 	"tostop", TOSTOP, 0,
220 	"-tostop", 0, TOSTOP,
221 	"echoctl", ECHOCTL, 0,
222 	"-echoctl", 0, ECHOCTL,
223 	"ctlecho", ECHOCTL, 0,
224 	"-ctlecho", 0, ECHOCTL,
225 	"echoprt", ECHOPRT, 0,
226 	"-echoprt", 0, ECHOPRT,
227 	"prterase", ECHOPRT, 0,
228 	"-prterase", 0, ECHOPRT,
229 	"echoke", ECHOKE, 0,
230 	"-echoke", 0, ECHOKE,
231 	"crtkill", ECHOKE, 0,
232 	"-crtkill", 0, ECHOKE,
233 	"defecho", DEFECHO, 0,
234 	"-defecho", 0, DEFECHO,
235 	"flusho", FLUSHO, 0,
236 	"-flusho", 0, FLUSHO,
237 	"pendin", PENDIN, 0,
238 	"-pendin", 0, PENDIN,
239 	"iexten", IEXTEN, 0,
240 	"-iexten", 0, IEXTEN,
241 	0
242 };
243 						/* Output Modes */
244 const struct mds omodes[] = {
245 	"opost", OPOST, 0,
246 	"-opost", 0, OPOST,
247 	"olcuc", OLCUC, 0,
248 	"-olcuc", 0, OLCUC,
249 	"lcase", OLCUC, 0,
250 	"-lcase", 0, OLCUC,
251 	"LCASE", OLCUC, 0,
252 	"-LCASE", 0, OLCUC,
253 	"onlcr", ONLCR, 0,
254 	"-onlcr", 0, ONLCR,
255 	"-nl", ONLCR, (OCRNL|ONLRET),
256 	"nl", 0, ONLCR,
257 	"ocrnl", OCRNL, 0,
258 	"-ocrnl",0, OCRNL,
259 	"onocr", ONOCR, 0,
260 	"-onocr", 0, ONOCR,
261 	"onlret", ONLRET, 0,
262 	"-onlret", 0, ONLRET,
263 	"fill", OFILL, OFDEL,
264 	"-fill", 0, OFILL|OFDEL,
265 	"nul-fill", OFILL, OFDEL,
266 	"del-fill", OFILL|OFDEL, 0,
267 	"ofill", OFILL, 0,
268 	"-ofill", 0, OFILL,
269 	"ofdel", OFDEL, 0,
270 	"-ofdel", 0, OFDEL,
271 	"cr0", CR0, CRDLY,
272 	"cr1", CR1, CRDLY,
273 	"cr2", CR2, CRDLY,
274 	"cr3", CR3, CRDLY,
275 	"tab0", TAB0, TABDLY,
276 	"tabs", TAB0, TABDLY,
277 	"tab1", TAB1, TABDLY,
278 	"tab2", TAB2, TABDLY,
279 	"tab3", TAB3, TABDLY,
280 	"-tabs", TAB3, TABDLY,
281 	"nl0", NL0, NLDLY,
282 	"nl1", NL1, NLDLY,
283 	"ff0", FF0, FFDLY,
284 	"ff1", FF1, FFDLY,
285 	"vt0", VT0, VTDLY,
286 	"vt1", VT1, VTDLY,
287 	"bs0", BS0, BSDLY,
288 	"bs1", BS1, BSDLY,
289 	"litout", 0, OPOST,
290 	"-litout", OPOST, 0,
291 	"raw", 0, OPOST,
292 	"-raw", OPOST, 0,
293 	"cooked", OPOST, 0,
294 	"tty33", CR1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
295 	"tn300", CR1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
296 	"ti700", CR2, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
297 	"vt05", NL1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
298 	"tek", FF1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
299 	"tty37", (FF1|VT1|CR2|TAB1|NL1), (NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY),
300 	"sane", (OPOST|ONLCR), (OLCUC|OCRNL|ONOCR|ONLRET|OFILL|OFDEL|
301 			NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY),
302 	0,
303 };
304 
305 const struct mds hmodes[] = {
306 	"-rtsxoff", 0, RTSXOFF,
307 	"rtsxoff", RTSXOFF, 0,
308 	"-ctsxon", 0, CTSXON,
309 	"ctsxon", CTSXON, 0,
310 	"-dterxoff", 0, DTRXOFF,
311 	"dterxoff", DTRXOFF, 0,
312 	"-rlsdxon", 0, CDXON,
313 	"rlsdxon", CDXON, 0,
314 	"-isxoff", 0, ISXOFF,
315 	"isxoff", ISXOFF, 0,
316 	0,
317 };
318 
319 const struct mds clkmodes[] = {
320 	"xcibrg", XCIBRG, XMTCLK,
321 	"xctset", XCTSET, XMTCLK,
322 	"xcrset", XCRSET, XMTCLK,
323 	"rcibrg", RCIBRG, RCVCLK,
324 	"rctset", RCTSET, RCVCLK,
325 	"rcrset", RCRSET, RCVCLK,
326 	"tsetcoff", TSETCOFF, TSETCLK,
327 	"tsetcrc", TSETCRBRG, TSETCLK,
328 	"tsetcxc", TSETCTBRG, TSETCLK,
329 	"rsetcoff", RSETCOFF, RSETCLK,
330 	"rsetcrc", RSETCRBRG, RSETCLK,
331 	"rsetcxc", RSETCTBRG, RSETCLK,
332 	"async", XCIBRG|RCIBRG|TSETCOFF|RSETCOFF, XMTCLK|RCVCLK|TSETCLK|RSETCLK,
333 	0,
334 };
335