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