xref: /titanic_41/usr/src/cmd/ttymon/sttytable.c (revision b509e89b2befbaa42939abad9da1d7f5a8c6aaae)
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 /*
28  * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
29  * All Rights Reserved
30  *
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,		0,
42 	"50",		B50,		50,
43 	"75",		B75,		75,
44 	"110",		B110,		110,
45 	"134",		B134,		134,
46 	"134.5", 	B134,		134,
47 	"150",		B150,		150,
48 	"200",		B200,		200,
49 	"300",		B300,		300,
50 	"600",		B600,		600,
51 	"1200",		B1200,		1200,
52 	"1800",		B1800,		1800,
53 	"2400",		B2400,		2400,
54 	"4800",		B4800,		4800,
55 	"9600",		B9600,		9600,
56 	"19200",	B19200,		19200,
57 	"19.2",		B19200,		19200,
58 	"38400",	B38400,		38400,
59 	"38.4",		B38400,		38400,
60 	"57600",	B57600,		57600,
61 	"57.6",		B57600,		57600,
62 	"76800",	B76800,		76800,
63 	"76.8",		B76800,		76800,
64 	"115200",	B115200,	115200,
65 	"115.2",	B115200,	115200,
66 	"153600",	B153600,	153600,
67 	"153.6",	B153600,	153600,
68 	"230400",	B230400,	230400,
69 	"230.4",	B230400,	230400,
70 	"307200",	B307200,	307200,
71 	"307.2",	B307200,	307200,
72 	"460800",	B460800,	460800,
73 	"460.8",	B460800,	460800,
74 	"921600",	B921600,	921600,
75 	"921.6",	B921600,	921600,
76 	0,
77 };
78 
79 const struct mds cmodes[] = {
80 	"-parity", CS8, PARENB|CSIZE,
81 	"-evenp", CS8, PARENB|CSIZE,
82 	"-oddp", CS8, PARENB|PARODD|CSIZE,
83 	"parity", PARENB|CS7, PARODD|CSIZE,
84 	"evenp", PARENB|CS7, PARODD|CSIZE,
85 	"oddp", PARENB|PARODD|CS7, CSIZE,
86 	"parenb", PARENB, 0,
87 	"-parenb", 0, PARENB,
88 	"parodd", PARODD, 0,
89 	"-parodd", 0, PARODD,
90 	"cs8", CS8, CSIZE,
91 	"cs7", CS7, CSIZE,
92 	"cs6", CS6, CSIZE,
93 	"cs5", CS5, CSIZE,
94 	"cstopb", CSTOPB, 0,
95 	"-cstopb", 0, CSTOPB,
96 	"hupcl", HUPCL, 0,
97 	"hup", HUPCL, 0,
98 	"-hupcl", 0, HUPCL,
99 	"-hup", 0, HUPCL,
100 	"clocal", CLOCAL, 0,
101 	"-clocal", 0, CLOCAL,
102 	"loblk", LOBLK, 0,
103 	"-loblk", 0, LOBLK,
104 	"cread", CREAD, 0,
105 	"-cread", 0, CREAD,
106 	"crtscts", (long)CRTSCTS, 0,
107 	"-crtscts", 0, (long)CRTSCTS,
108 	"crtsxoff", CRTSXOFF, 0,
109 	"-crtsxoff", 0, CRTSXOFF,
110 	"raw", CS8, (CSIZE|PARENB),
111 	"-raw", (CS7|PARENB), CSIZE,
112 	"cooked", (CS7|PARENB), CSIZE,
113 	"sane", (CS7|PARENB|CREAD), (CSIZE|PARODD|CLOCAL),
114 	0
115 };
116 
117 const struct mds ncmodes[] = {
118 	"parext", PAREXT, 0,
119 	"-parext", 0, PAREXT,
120 	"markp", (PARENB|PARODD|CS7|PAREXT), CSIZE,
121 	"-markp", CS8, (PARENB|PARODD|CSIZE|PAREXT),
122 	"spacep", (PARENB|CS7|PAREXT), PARODD|CSIZE,
123 	"-spacep", CS8, (PARENB|CSIZE|PAREXT),
124 	0
125 };
126 
127 const struct mds imodes[] = {
128 	"ignbrk", IGNBRK, 0,
129 	"-ignbrk", 0, IGNBRK,
130 	"brkint", BRKINT, 0,
131 	"-brkint", 0, BRKINT,
132 	"ignpar", IGNPAR, 0,
133 	"-ignpar", 0, IGNPAR,
134 	"parmrk", PARMRK, 0,
135 	"-parmrk", 0, PARMRK,
136 	"inpck", INPCK, 0,
137 	"-inpck", 0, INPCK,
138 	"istrip", ISTRIP, 0,
139 	"-istrip", 0, ISTRIP,
140 	"inlcr", INLCR, 0,
141 	"-inlcr", 0, INLCR,
142 	"igncr", IGNCR, 0,
143 	"-igncr", 0, IGNCR,
144 	"icrnl", ICRNL, 0,
145 	"-icrnl", 0, ICRNL,
146 #ifdef XPG4
147 	"-nl", 0, (ICRNL|INLCR|IGNCR),
148 	"nl", ICRNL, 0,
149 #else
150 	"-nl", ICRNL, (INLCR|IGNCR),
151 	"nl", 0, ICRNL,
152 #endif
153 	"iuclc", IUCLC, 0,
154 	"-iuclc", 0, IUCLC,
155 	"lcase", IUCLC, 0,
156 	"-lcase", 0, IUCLC,
157 	"LCASE", IUCLC, 0,
158 	"-LCASE", 0, IUCLC,
159 	"ixon", IXON, 0,
160 	"-ixon", 0, IXON,
161 	"ixany", IXANY, 0,
162 	"-ixany", 0, IXANY,
163 	"ixoff", IXOFF, 0,
164 	"-ixoff", 0, IXOFF,
165 	"raw", 0, -1,
166 	"-raw", (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON), 0,
167 	"cooked", (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON), 0,
168 	"sane", (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON|IMAXBEL),
169 		(IGNBRK|PARMRK|INPCK|INLCR|IGNCR|IUCLC|IXOFF|IXANY),
170 	0
171 };
172 
173 
174 const struct mds nimodes[] = {
175 	"imaxbel", IMAXBEL, 0,
176 	"-imaxbel", 0, IMAXBEL,
177 	0
178 };
179 
180 const struct mds lmodes[] = {
181 	"isig", ISIG, 0,
182 	"-isig", 0, ISIG,
183 	"icanon", ICANON, 0,
184 	"-icanon", 0, ICANON,
185 	"xcase", XCASE, 0,
186 	"-xcase", 0, XCASE,
187 	"lcase", XCASE, 0,
188 	"-lcase", 0, XCASE,
189 	"LCASE", XCASE, 0,
190 	"-LCASE", 0, XCASE,
191 	"echo", ECHO, 0,
192 	"-echo", 0, ECHO,
193 	"echoe", ECHOE, 0,
194 	"-echoe", 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),
204 	"-raw", (ISIG|ICANON), 0,
205 	"cooked", (ISIG|ICANON), 0,
206 	"sane", (ISIG|ICANON|IEXTEN|ECHO|ECHOK|ECHOE|ECHOKE|ECHOCTL),
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 	"echoprt", ECHOPRT, 0,
223 	"-echoprt", 0, ECHOPRT,
224 	"echoke", ECHOKE, 0,
225 	"-echoke", 0, ECHOKE,
226 	"defecho", DEFECHO, 0,
227 	"-defecho", 0, DEFECHO,
228 	"flusho", FLUSHO, 0,
229 	"-flusho", 0, FLUSHO,
230 	"pendin", PENDIN, 0,
231 	"-pendin", 0, PENDIN,
232 	"iexten", IEXTEN, 0,
233 	"-iexten", 0, IEXTEN,
234 	0
235 };
236 
237 const struct mds omodes[] = {
238 	"opost", OPOST, 0,
239 	"-opost", 0, OPOST,
240 	"olcuc", OLCUC, 0,
241 	"-olcuc", 0, OLCUC,
242 	"lcase", OLCUC, 0,
243 	"-lcase", 0, OLCUC,
244 	"LCASE", OLCUC, 0,
245 	"-LCASE", 0, OLCUC,
246 	"onlcr", ONLCR, 0,
247 	"-onlcr", 0, ONLCR,
248 	"-nl", ONLCR, (OCRNL|ONLRET),
249 	"nl", 0, ONLCR,
250 	"ocrnl", OCRNL, 0,
251 	"-ocrnl", 0, OCRNL,
252 	"onocr", ONOCR, 0,
253 	"-onocr", 0, ONOCR,
254 	"onlret", ONLRET, 0,
255 	"-onlret", 0, ONLRET,
256 	"fill", OFILL, OFDEL,
257 	"-fill", 0, OFILL|OFDEL,
258 	"nul-fill", OFILL, OFDEL,
259 	"del-fill", OFILL|OFDEL, 0,
260 	"ofill", OFILL, 0,
261 	"-ofill", 0, OFILL,
262 	"ofdel", OFDEL, 0,
263 	"-ofdel", 0, OFDEL,
264 	"cr0", CR0, CRDLY,
265 	"cr1", CR1, CRDLY,
266 	"cr2", CR2, CRDLY,
267 	"cr3", CR3, CRDLY,
268 	"tab0", TAB0, TABDLY,
269 	"tabs", TAB0, TABDLY,
270 	"tab1", TAB1, TABDLY,
271 	"tab2", TAB2, TABDLY,
272 	"tab3", TAB3, TABDLY,
273 	"-tabs", TAB3, TABDLY,
274 	"tab8", TAB3, TABDLY,
275 	"nl0", NL0, NLDLY,
276 	"nl1", NL1, NLDLY,
277 	"ff0", FF0, FFDLY,
278 	"ff1", FF1, FFDLY,
279 	"vt0", VT0, VTDLY,
280 	"vt1", VT1, VTDLY,
281 	"bs0", BS0, BSDLY,
282 	"bs1", BS1, BSDLY,
283 	"raw", 0, OPOST,
284 	"-raw", OPOST, 0,
285 	"cooked", OPOST, 0,
286 	"tty33", CR1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
287 	"tn300", CR1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
288 	"ti700", CR2, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
289 	"vt05", NL1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
290 	"tek", FF1, (CRDLY|TABDLY|NLDLY|FFDLY|VTDLY|BSDLY),
291 	"tty37", (FF1|VT1|CR2|TAB1|NL1), (NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY),
292 	"sane", (OPOST|ONLCR), (OLCUC|OCRNL|ONOCR|ONLRET|OFILL|OFDEL|
293 			NLDLY|CRDLY|TABDLY|BSDLY|VTDLY|FFDLY),
294 	0,
295 };
296 
297 const struct mds hmodes[] = {
298 	"-rtsxoff", 0, RTSXOFF,
299 	"rtsxoff", RTSXOFF, 0,
300 	"-ctsxon", 0, CTSXON,
301 	"ctsxon", CTSXON, 0,
302 	"-dtrxoff", 0, DTRXOFF,
303 	"dtrxoff", DTRXOFF, 0,
304 	"-cdxon", 0, CDXON,
305 	"cdxon", CDXON, 0,
306 	"-isxoff", 0, ISXOFF,
307 	"isxoff", ISXOFF, 0,
308 	0,
309 };
310 
311 const struct mds clkmodes[] = {
312 	"xcibrg", XCIBRG, XMTCLK,
313 	"xctset", XCTSET, XMTCLK,
314 	"xcrset", XCRSET, XMTCLK,
315 	"rcibrg", RCIBRG, RCVCLK,
316 	"rctset", RCTSET, RCVCLK,
317 	"rcrset", RCRSET, RCVCLK,
318 	"tsetcoff", TSETCOFF, TSETCLK,
319 	"tsetcrbrg", TSETCRBRG, TSETCLK,
320 	"tsetctbrg", TSETCTBRG, TSETCLK,
321 	"tsetctset", TSETCTSET, TSETCLK,
322 	"tsetcrset", TSETCRSET, TSETCLK,
323 	"rsetcoff", RSETCOFF, RSETCLK,
324 	"rsetcrbrg", RSETCRBRG, RSETCLK,
325 	"rsetctbrg", RSETCTBRG, RSETCLK,
326 	"rsetctset", RSETCTSET, RSETCLK,
327 	"rsetcrset", RSETCRSET, RSETCLK,
328 	"async", XCIBRG|RCIBRG|TSETCOFF|RSETCOFF, XMTCLK|RCVCLK|TSETCLK|RSETCLK,
329 	0,
330 };
331 
332 const char *not_supported[] =  {
333 	"rtsxoff",
334 	"ctsxon",
335 	"dtrxoff",
336 	"cdxon",
337 	"isxoff",
338 	"xcibrg",
339 	"xctset",
340 	"scrset",
341 	"rcibrg",
342 	"rctset",
343 	"rcrset",
344 	"tsetcoff",
345 	"tsetcrbrg",
346 	"rsetcbrg",
347 	"rsetctbrg",
348 	"rsetctset",
349 	"rsetcrset",
350 	0,
351 };
352