xref: /illumos-gate/usr/src/ucbcmd/stty/sttytable.c (revision d9c3e05c)
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 	"1000000",	B1000000,
69 	"1152000",	B1152000,
70 	"1500000",	B1500000,
71 	"2000000",	B2000000,
72 	"2500000",	B2500000,
73 	"3000000",	B3000000,
74 	"3500000",	B3500000,
75 	"4000000",	B4000000,
76 	0,
77 };
78 						/* Control Modes */
79 const struct mds cmodes[] = {
80 	"-parity", CS8, PARENB|CSIZE,
81 	"-evenp", CS8, PARENB|CSIZE,
82 	"-even", CS8, PARENB|CSIZE,
83 	"-oddp", CS8, PARENB|PARODD|CSIZE,
84 	"-odd", CS8, PARENB|PARODD|CSIZE,
85 	"parity", PARENB|CS7, PARODD|CSIZE,
86 	"evenp", PARENB|CS7, PARODD|CSIZE,
87 	"even", PARENB|CS7, PARODD|CSIZE,
88 	"oddp", PARENB|PARODD|CS7, CSIZE,
89 	"odd", PARENB|PARODD|CS7, CSIZE,
90 	"parenb", PARENB, 0,
91 	"-parenb", 0, PARENB,
92 	"parodd", PARODD, 0,
93 	"-parodd", 0, PARODD,
94 	"cs8", CS8, CSIZE,
95 	"cs7", CS7, CSIZE,
96 	"cs6", CS6, CSIZE,
97 	"cs5", CS5, CSIZE,
98 	"cstopb", CSTOPB, 0,
99 	"-cstopb", 0, CSTOPB,
100 	"hupcl", HUPCL, 0,
101 	"hup", HUPCL, 0,
102 	"-hupcl", 0, HUPCL,
103 	"-hup", 0, HUPCL,
104 	"clocal", CLOCAL, 0,
105 	"-clocal", 0, CLOCAL,
106 	"loblk", LOBLK, 0,
107 	"-loblk", 0, LOBLK,
108 	"cread", CREAD, 0,
109 	"-cread", 0, CREAD,
110 	"litout", CS8, (CSIZE|PARENB),
111 	"-litout", (CS7|PARENB), CSIZE,
112 	"pass8", CS8, (CSIZE|PARENB),
113 	"-pass8", (CS7|PARENB), CSIZE,
114 	"raw", CS8, (CSIZE|PARENB),
115 	"-raw", (CS7|PARENB), CSIZE,
116 	"cooked", (CS7|PARENB), CSIZE,
117 	"sane", (CS7|PARENB|CREAD), (CSIZE|PARODD|CLOCAL),
118 	0
119 };
120 
121 const struct mds ncmodes[] = {
122 	"parext", PAREXT, 0,
123 	"-parext", 0, PAREXT,
124 	"markp", (PARENB|PARODD|CS7|PAREXT), CSIZE,
125 	"-markp", CS8, (PARENB|PARODD|CSIZE|PAREXT),
126 	"spacep", (PARENB|CS7|PAREXT), PARODD|CSIZE,
127 	"-spacep", CS8, (PARENB|CSIZE|PAREXT),
128 	0
129 };
130 						/* Input Modes */
131 const struct mds imodes[] = {
132 	"ignbrk", IGNBRK, 0,
133 	"-ignbrk", 0, IGNBRK,
134 	"brkint", BRKINT, 0,
135 	"-brkint", 0, BRKINT,
136 	"ignpar", IGNPAR, 0,
137 	"-ignpar", 0, IGNPAR,
138 	"parmrk", PARMRK, 0,
139 	"-parmrk", 0, PARMRK,
140 	"inpck", INPCK, 0,
141 	"-inpck", 0, INPCK,
142 	"istrip", ISTRIP, 0,
143 	"-istrip", 0, ISTRIP,
144 	"inlcr", INLCR, 0,
145 	"-inlcr", 0, INLCR,
146 	"igncr", IGNCR, 0,
147 	"-igncr", 0, IGNCR,
148 	"icrnl", ICRNL, 0,
149 	"-icrnl", 0, ICRNL,
150 	"-nl", ICRNL, (INLCR|IGNCR),
151 	"nl", 0, ICRNL,
152 	"iuclc", IUCLC, 0,
153 	"-iuclc", 0, IUCLC,
154 	"lcase", IUCLC, 0,
155 	"-lcase", 0, IUCLC,
156 	"LCASE", IUCLC, 0,
157 	"-LCASE", 0, IUCLC,
158 	"ixon", IXON, 0,
159 	"-ixon", 0, IXON,
160 	"ixany", IXANY, 0,
161 	"-ixany", 0, IXANY,
162 	"decctlq", 0, IXANY,
163 	"-decctlq", IXANY, 0,
164 	"ixoff", IXOFF, 0,
165 	"-ixoff", 0, IXOFF,
166 	"tandem", IXOFF, 0,
167 	"-tandem", 0, IXOFF,
168 	"pass8", 0, ISTRIP,
169 	"-pass8", ISTRIP, 0,
170 	"raw", 0, -1,
171 	"-raw", (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON|IMAXBEL), 0,
172 	"cooked", (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON), 0,
173 	"sane", (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON|IMAXBEL),
174 		(IGNBRK|PARMRK|INPCK|INLCR|IGNCR|IUCLC|IXOFF),
175 	0
176 };
177 
178 const struct mds nimodes[] = {
179 	"imaxbel", IMAXBEL, 0,
180 	"-imaxbel", 0, IMAXBEL,
181 	0
182 };
183 						/* Local Modes */
184 const struct mds lmodes[] = {
185 	"isig", ISIG, 0,
186 	"-isig", 0, ISIG,
187 	"icanon", ICANON, 0,
188 	"-icanon", 0, ICANON,
189 	"cbreak", 0, ICANON,
190 	"-cbreak", ICANON, 0,
191 	"xcase", XCASE, 0,
192 	"-xcase", 0, XCASE,
193 	"lcase", XCASE, 0,
194 	"-lcase", 0, XCASE,
195 	"LCASE", XCASE, 0,
196 	"-LCASE", 0, XCASE,
197 	"echo", ECHO, 0,
198 	"-echo", 0, ECHO,
199 	"echoe", ECHOE, 0,
200 	"-echoe", 0, ECHOE,
201 	"crterase", ECHOE, 0,
202 	"-crterase", 0, ECHOE,
203 	"echok", ECHOK, 0,
204 	"-echok", 0, ECHOK,
205 	"lfkc", ECHOK, 0,
206 	"-lfkc", 0, ECHOK,
207 	"echonl", ECHONL, 0,
208 	"-echonl", 0, ECHONL,
209 	"noflsh", NOFLSH, 0,
210 	"-noflsh", 0, NOFLSH,
211 	"raw", 0, (ISIG|ICANON|XCASE|IEXTEN),
212 	"-raw", (ISIG|ICANON|IEXTEN), 0,
213 	"cooked", (ISIG|ICANON), 0,
214 	"sane", (ISIG|ICANON|IEXTEN|ECHO|ECHOK|ECHOE|ECHOCTL|ECHOKE),
215 		(XCASE|ECHONL|NOFLSH|STFLUSH|STWRAP|STAPPL),
216 	"stflush", STFLUSH, 0,
217 	"-stflush", 0, STFLUSH,
218 	"stwrap", STWRAP, 0,
219 	"-stwrap", 0, STWRAP,
220 	"stappl", STAPPL, 0,
221 	"-stappl", 0, STAPPL,
222 	0,
223 };
224 
225 const struct mds nlmodes[] = {
226 	"tostop", TOSTOP, 0,
227 	"-tostop", 0, TOSTOP,
228 	"echoctl", ECHOCTL, 0,
229 	"-echoctl", 0, ECHOCTL,
230 	"ctlecho", ECHOCTL, 0,
231 	"-ctlecho", 0, ECHOCTL,
232 	"echoprt", ECHOPRT, 0,
233 	"-echoprt", 0, ECHOPRT,
234 	"prterase", ECHOPRT, 0,
235 	"-prterase", 0, ECHOPRT,
236 	"echoke", ECHOKE, 0,
237 	"-echoke", 0, ECHOKE,
238 	"crtkill", ECHOKE, 0,
239 	"-crtkill", 0, ECHOKE,
240 	"defecho", DEFECHO, 0,
241 	"-defecho", 0, DEFECHO,
242 	"flusho", FLUSHO, 0,
243 	"-flusho", 0, FLUSHO,
244 	"pendin", PENDIN, 0,
245 	"-pendin", 0, PENDIN,
246 	"iexten", IEXTEN, 0,
247 	"-iexten", 0, IEXTEN,
248 	0
249 };
250 						/* Output Modes */
251 const struct mds omodes[] = {
252 	"opost", OPOST, 0,
253 	"-opost", 0, OPOST,
254 	"olcuc", OLCUC, 0,
255 	"-olcuc", 0, OLCUC,
256 	"lcase", OLCUC, 0,
257 	"-lcase", 0, OLCUC,
258 	"LCASE", OLCUC, 0,
259 	"-LCASE", 0, OLCUC,
260 	"onlcr", ONLCR, 0,
261 	"-onlcr", 0, ONLCR,
262 	"-nl", ONLCR, (OCRNL|ONLRET),
263 	"nl", 0, ONLCR,
264 	"ocrnl", OCRNL, 0,
265 	"-ocrnl", 0, OCRNL,
266 	"onocr", ONOCR, 0,
267 	"-onocr", 0, ONOCR,
268 	"onlret", ONLRET, 0,
269 	"-onlret", 0, ONLRET,
270 	"fill", OFILL, OFDEL,
271 	"-fill", 0, OFILL|OFDEL,
272 	"nul-fill", OFILL, OFDEL,
273 	"del-fill", OFILL|OFDEL, 0,
274 	"ofill", OFILL, 0,
275 	"-ofill", 0, OFILL,
276 	"ofdel", OFDEL, 0,
277 	"-ofdel", 0, OFDEL,
278 	"cr0", CR0, CRDLY,
279 	"cr1", CR1, CRDLY,
280 	"cr2", CR2, CRDLY,
281 	"cr3", CR3, CRDLY,
282 	"tab0", TAB0, TABDLY,
283 	"tabs", TAB0, TABDLY,
284 	"tab1", TAB1, TABDLY,
285 	"tab2", TAB2, TABDLY,
286 	"tab3", TAB3, TABDLY,
287 	"-tabs", TAB3, TABDLY,
288 	"nl0", NL0, NLDLY,
289 	"nl1", NL1, NLDLY,
290 	"ff0", FF0, FFDLY,
291 	"ff1", FF1, FFDLY,
292 	"vt0", VT0, VTDLY,
293 	"vt1", VT1, VTDLY,
294 	"bs0", BS0, BSDLY,
295 	"bs1", BS1, BSDLY,
296 	"litout", 0, OPOST,
297 	"-litout", OPOST, 0,
298 	"raw", 0, OPOST,
299 	"-raw", OPOST, 0,
300 	"cooked", OPOST, 0,
301 	"tty33", CR1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
302 	"tn300", CR1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
303 	"ti700", CR2, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
304 	"vt05", NL1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
305 	"tek", FF1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
306 	"tty37", (FF1|VT1|CR2|TAB1|NL1), (NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY),
307 	"sane", (OPOST|ONLCR), (OLCUC|OCRNL|ONOCR|ONLRET|OFILL|OFDEL|
308 			NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY),
309 	0,
310 };
311 
312 const struct mds hmodes[] = {
313 	"-rtsxoff", 0, RTSXOFF,
314 	"rtsxoff", RTSXOFF, 0,
315 	"-ctsxon", 0, CTSXON,
316 	"ctsxon", CTSXON, 0,
317 	"-dterxoff", 0, DTRXOFF,
318 	"dterxoff", DTRXOFF, 0,
319 	"-rlsdxon", 0, CDXON,
320 	"rlsdxon", CDXON, 0,
321 	"-isxoff", 0, ISXOFF,
322 	"isxoff", ISXOFF, 0,
323 	0,
324 };
325 
326 const struct mds clkmodes[] = {
327 	"xcibrg", XCIBRG, XMTCLK,
328 	"xctset", XCTSET, XMTCLK,
329 	"xcrset", XCRSET, XMTCLK,
330 	"rcibrg", RCIBRG, RCVCLK,
331 	"rctset", RCTSET, RCVCLK,
332 	"rcrset", RCRSET, RCVCLK,
333 	"tsetcoff", TSETCOFF, TSETCLK,
334 	"tsetcrc", TSETCRBRG, TSETCLK,
335 	"tsetcxc", TSETCTBRG, TSETCLK,
336 	"rsetcoff", RSETCOFF, RSETCLK,
337 	"rsetcrc", RSETCRBRG, RSETCLK,
338 	"rsetcxc", RSETCTBRG, RSETCLK,
339 	"async",
340 		XCIBRG|RCIBRG|TSETCOFF|RSETCOFF, XMTCLK|RCVCLK|TSETCLK|RSETCLK,
341 	0,
342 };
343