1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved.
24*0Sstevel@tonic-gate * Use is subject to license terms.
25*0Sstevel@tonic-gate */
26*0Sstevel@tonic-gate
27*0Sstevel@tonic-gate /*
28*0Sstevel@tonic-gate * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
29*0Sstevel@tonic-gate * All Rights Reserved
30*0Sstevel@tonic-gate *
31*0Sstevel@tonic-gate */
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gate #include <stdio.h>
36*0Sstevel@tonic-gate #include <ctype.h>
37*0Sstevel@tonic-gate #include <locale.h>
38*0Sstevel@tonic-gate #include <sys/types.h>
39*0Sstevel@tonic-gate #include <termio.h>
40*0Sstevel@tonic-gate #include <sys/stermio.h>
41*0Sstevel@tonic-gate #include <sys/termiox.h>
42*0Sstevel@tonic-gate #include <string.h>
43*0Sstevel@tonic-gate #include <stdlib.h>
44*0Sstevel@tonic-gate #include <limits.h>
45*0Sstevel@tonic-gate #ifdef EUC
46*0Sstevel@tonic-gate #include <sys/stat.h>
47*0Sstevel@tonic-gate #include <fcntl.h>
48*0Sstevel@tonic-gate #include <unistd.h>
49*0Sstevel@tonic-gate #include <sys/param.h>
50*0Sstevel@tonic-gate #include <sys/stropts.h>
51*0Sstevel@tonic-gate #include <sys/eucioctl.h>
52*0Sstevel@tonic-gate #include <sys/csiioctl.h>
53*0Sstevel@tonic-gate #include <sys/stream.h>
54*0Sstevel@tonic-gate #include <sys/termios.h>
55*0Sstevel@tonic-gate #include <sys/ldterm.h>
56*0Sstevel@tonic-gate #include <getwidth.h>
57*0Sstevel@tonic-gate #endif /* EUC */
58*0Sstevel@tonic-gate #include "stty.h"
59*0Sstevel@tonic-gate
60*0Sstevel@tonic-gate extern const char *not_supported[];
61*0Sstevel@tonic-gate
62*0Sstevel@tonic-gate extern char *getenv();
63*0Sstevel@tonic-gate extern void exit();
64*0Sstevel@tonic-gate extern void perror();
65*0Sstevel@tonic-gate extern int get_ttymode();
66*0Sstevel@tonic-gate extern int set_ttymode();
67*0Sstevel@tonic-gate
68*0Sstevel@tonic-gate static char *STTY = "stty: ";
69*0Sstevel@tonic-gate static int pitt = 0;
70*0Sstevel@tonic-gate static struct termios cb;
71*0Sstevel@tonic-gate static struct termio ocb; /* for non-streams devices */
72*0Sstevel@tonic-gate static struct stio stio;
73*0Sstevel@tonic-gate static struct termiox termiox;
74*0Sstevel@tonic-gate static struct winsize winsize, owinsize;
75*0Sstevel@tonic-gate static int term;
76*0Sstevel@tonic-gate #ifdef EUC
77*0Sstevel@tonic-gate static struct eucioc kwp;
78*0Sstevel@tonic-gate static eucwidth_t wp;
79*0Sstevel@tonic-gate static ldterm_cs_data_user_t cswp; /* User side codeset width data */
80*0Sstevel@tonic-gate static ldterm_cs_data_user_t kcswp; /* Kernel side codeset width data */
81*0Sstevel@tonic-gate static int invalid_ldterm_dat_file;
82*0Sstevel@tonic-gate #endif /* EUC */
83*0Sstevel@tonic-gate
84*0Sstevel@tonic-gate static void prmodes();
85*0Sstevel@tonic-gate static void pramodes();
86*0Sstevel@tonic-gate static void pit(unsigned char what, char *itsname, char *sep);
87*0Sstevel@tonic-gate static void delay(int m, char *s);
88*0Sstevel@tonic-gate static void prspeed(char *c, int s);
89*0Sstevel@tonic-gate static void prencode();
90*0Sstevel@tonic-gate
91*0Sstevel@tonic-gate int
main(int argc,char * argv[])92*0Sstevel@tonic-gate main(int argc, char *argv[])
93*0Sstevel@tonic-gate {
94*0Sstevel@tonic-gate int i;
95*0Sstevel@tonic-gate int fd;
96*0Sstevel@tonic-gate char *s_arg, *sttyparse(); /* s_arg: ptr to mode to be set */
97*0Sstevel@tonic-gate #ifdef EUC
98*0Sstevel@tonic-gate char *lc;
99*0Sstevel@tonic-gate char tmps[PATH_MAX];
100*0Sstevel@tonic-gate #endif /* EUC */
101*0Sstevel@tonic-gate
102*0Sstevel@tonic-gate (void) setlocale(LC_ALL, "");
103*0Sstevel@tonic-gate #if !defined(TEXT_DOMAIN)
104*0Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST"
105*0Sstevel@tonic-gate #endif
106*0Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN);
107*0Sstevel@tonic-gate
108*0Sstevel@tonic-gate #ifdef EUC
109*0Sstevel@tonic-gate lc = setlocale(LC_CTYPE, (const char *)NULL);
110*0Sstevel@tonic-gate if (lc) {
111*0Sstevel@tonic-gate sprintf(tmps, _LDTERM_DAT_PATH, lc);
112*0Sstevel@tonic-gate
113*0Sstevel@tonic-gate fd = open(tmps, O_RDONLY, 0);
114*0Sstevel@tonic-gate if (fd != -1) {
115*0Sstevel@tonic-gate if (read(fd, (void *)&cswp, sizeof (cswp)) <
116*0Sstevel@tonic-gate sizeof (cswp)) {
117*0Sstevel@tonic-gate (void) fprintf(stderr, gettext(
118*0Sstevel@tonic-gate "cannot read entier %s file\n"), tmps);
119*0Sstevel@tonic-gate exit(2);
120*0Sstevel@tonic-gate }
121*0Sstevel@tonic-gate
122*0Sstevel@tonic-gate (void) close(fd);
123*0Sstevel@tonic-gate
124*0Sstevel@tonic-gate /*
125*0Sstevel@tonic-gate * If the ldterm.dat contains invalid data or
126*0Sstevel@tonic-gate * the current locale name is too long, we clear
127*0Sstevel@tonic-gate * the 'cswp' and flag the invalid ldterm.dat since
128*0Sstevel@tonic-gate * we are not going to use the data.
129*0Sstevel@tonic-gate */
130*0Sstevel@tonic-gate if (cswp.version > LDTERM_DATA_VERSION ||
131*0Sstevel@tonic-gate cswp.codeset_type < LDTERM_CS_TYPE_MIN ||
132*0Sstevel@tonic-gate cswp.codeset_type > LDTERM_CS_TYPE_MAX ||
133*0Sstevel@tonic-gate strlen(lc) >= MAXNAMELEN ||
134*0Sstevel@tonic-gate (cswp.codeset_type == LDTERM_CS_TYPE_EUC &&
135*0Sstevel@tonic-gate cswp.csinfo_num > LDTERM_CS_TYPE_EUC_MAX_SUBCS) ||
136*0Sstevel@tonic-gate (cswp.codeset_type == LDTERM_CS_TYPE_PCCS &&
137*0Sstevel@tonic-gate (cswp.csinfo_num < LDTERM_CS_TYPE_PCCS_MIN_SUBCS ||
138*0Sstevel@tonic-gate cswp.csinfo_num > LDTERM_CS_TYPE_PCCS_MAX_SUBCS))) {
139*0Sstevel@tonic-gate (void) memset((void *)&cswp, 0, sizeof (cswp));
140*0Sstevel@tonic-gate invalid_ldterm_dat_file = 1;
141*0Sstevel@tonic-gate } else {
142*0Sstevel@tonic-gate (void) strcpy(cswp.locale_name, lc);
143*0Sstevel@tonic-gate }
144*0Sstevel@tonic-gate }
145*0Sstevel@tonic-gate }
146*0Sstevel@tonic-gate
147*0Sstevel@tonic-gate getwidth(&wp);
148*0Sstevel@tonic-gate #endif /* EUC */
149*0Sstevel@tonic-gate
150*0Sstevel@tonic-gate if ((term = get_ttymode(0, &ocb, &cb, &stio, &termiox, &winsize
151*0Sstevel@tonic-gate #ifdef EUC
152*0Sstevel@tonic-gate /* */, &kwp, &kcswp
153*0Sstevel@tonic-gate #endif /* EUC */
154*0Sstevel@tonic-gate /* */)) < 0) {
155*0Sstevel@tonic-gate perror(STTY);
156*0Sstevel@tonic-gate exit(2);
157*0Sstevel@tonic-gate }
158*0Sstevel@tonic-gate owinsize = winsize;
159*0Sstevel@tonic-gate if (argc == 1) {
160*0Sstevel@tonic-gate prmodes();
161*0Sstevel@tonic-gate exit(0);
162*0Sstevel@tonic-gate }
163*0Sstevel@tonic-gate if ((argc == 2) && (argv[1][0] == '-') && (argv[1][2] == '\0'))
164*0Sstevel@tonic-gate switch (argv[1][1]) {
165*0Sstevel@tonic-gate case 'a':
166*0Sstevel@tonic-gate pramodes();
167*0Sstevel@tonic-gate return (0);
168*0Sstevel@tonic-gate case 'g':
169*0Sstevel@tonic-gate prencode();
170*0Sstevel@tonic-gate return (0);
171*0Sstevel@tonic-gate case '-':
172*0Sstevel@tonic-gate prmodes(); /* stty -- */
173*0Sstevel@tonic-gate return (0);
174*0Sstevel@tonic-gate default:
175*0Sstevel@tonic-gate (void) fprintf(stderr, gettext(
176*0Sstevel@tonic-gate "usage: stty [-a| -g]\n"));
177*0Sstevel@tonic-gate (void) fprintf(stderr, gettext(
178*0Sstevel@tonic-gate " stty [modes]\n"));
179*0Sstevel@tonic-gate return (2);
180*0Sstevel@tonic-gate }
181*0Sstevel@tonic-gate
182*0Sstevel@tonic-gate if ((argc == 3) && (argv[1][0] == '-') && (argv[1][2] == '\0') &&
183*0Sstevel@tonic-gate (argv[2][0] == '-') && (argv[2][1] == '-') && (argv[2][2] == '\0'))
184*0Sstevel@tonic-gate switch (argv[1][1]) {
185*0Sstevel@tonic-gate case 'a':
186*0Sstevel@tonic-gate pramodes();
187*0Sstevel@tonic-gate return (0);
188*0Sstevel@tonic-gate case 'g':
189*0Sstevel@tonic-gate prencode();
190*0Sstevel@tonic-gate return (0);
191*0Sstevel@tonic-gate default:
192*0Sstevel@tonic-gate (void) fprintf(stderr, gettext(
193*0Sstevel@tonic-gate "usage: stty [-a| -g]\n"));
194*0Sstevel@tonic-gate (void) fprintf(stderr, gettext(
195*0Sstevel@tonic-gate " stty [modes]\n"));
196*0Sstevel@tonic-gate return (2);
197*0Sstevel@tonic-gate }
198*0Sstevel@tonic-gate if ((argc >= 3) && (argv[1][0] == '-') && (argv[1][1] == '-') &&
199*0Sstevel@tonic-gate (argv[1][2] == '\0')) {
200*0Sstevel@tonic-gate /* ignore -- */
201*0Sstevel@tonic-gate --argc;
202*0Sstevel@tonic-gate ++argv;
203*0Sstevel@tonic-gate }
204*0Sstevel@tonic-gate if (s_arg = sttyparse(argc, argv, term, &ocb, &cb, &termiox, &winsize
205*0Sstevel@tonic-gate #ifdef EUC
206*0Sstevel@tonic-gate /* */, &wp, &kwp, &cswp, &kcswp
207*0Sstevel@tonic-gate #endif /* EUC */
208*0Sstevel@tonic-gate /* */)) {
209*0Sstevel@tonic-gate char *s = s_arg;
210*0Sstevel@tonic-gate if (*s == '-') s++;
211*0Sstevel@tonic-gate for (i = 0; not_supported[i]; i++) {
212*0Sstevel@tonic-gate if (strcmp(not_supported[i], s) == 0) {
213*0Sstevel@tonic-gate (void) fprintf(stderr,
214*0Sstevel@tonic-gate gettext(
215*0Sstevel@tonic-gate "mode not supported on this device: %s\n"), s_arg);
216*0Sstevel@tonic-gate exit(2);
217*0Sstevel@tonic-gate }
218*0Sstevel@tonic-gate }
219*0Sstevel@tonic-gate (void) fprintf(stderr, gettext("unknown mode: %s\n"), s_arg);
220*0Sstevel@tonic-gate return (2);
221*0Sstevel@tonic-gate }
222*0Sstevel@tonic-gate
223*0Sstevel@tonic-gate if (set_ttymode(0, term, &ocb, &cb, &stio, &termiox, &winsize, &owinsize
224*0Sstevel@tonic-gate #ifdef EUC
225*0Sstevel@tonic-gate /* */, &kwp, &kcswp, invalid_ldterm_dat_file
226*0Sstevel@tonic-gate #endif /* EUC */
227*0Sstevel@tonic-gate /* */) == -1) {
228*0Sstevel@tonic-gate perror(STTY);
229*0Sstevel@tonic-gate return (2);
230*0Sstevel@tonic-gate }
231*0Sstevel@tonic-gate return (0);
232*0Sstevel@tonic-gate }
233*0Sstevel@tonic-gate
234*0Sstevel@tonic-gate void
prmodes(void)235*0Sstevel@tonic-gate prmodes(void) /* print modes, no options, argc is 1 */
236*0Sstevel@tonic-gate {
237*0Sstevel@tonic-gate int m;
238*0Sstevel@tonic-gate
239*0Sstevel@tonic-gate if (!(term & ASYNC)) {
240*0Sstevel@tonic-gate m = stio.imode;
241*0Sstevel@tonic-gate if (m & IUCLC)
242*0Sstevel@tonic-gate (void) printf("iuclc ");
243*0Sstevel@tonic-gate else
244*0Sstevel@tonic-gate (void) printf("-iuclc ");
245*0Sstevel@tonic-gate m = stio.omode;
246*0Sstevel@tonic-gate if (m & OLCUC)
247*0Sstevel@tonic-gate (void) printf("olcuc ");
248*0Sstevel@tonic-gate else
249*0Sstevel@tonic-gate (void) printf("-olcuc ");
250*0Sstevel@tonic-gate if (m & TAB3)
251*0Sstevel@tonic-gate (void) printf("tab3 ");
252*0Sstevel@tonic-gate m = stio.lmode;
253*0Sstevel@tonic-gate if (m & XCASE)
254*0Sstevel@tonic-gate (void) printf("xcase ");
255*0Sstevel@tonic-gate else
256*0Sstevel@tonic-gate (void) printf("-xcase ");
257*0Sstevel@tonic-gate if (m & STFLUSH)
258*0Sstevel@tonic-gate (void) printf("stflush ");
259*0Sstevel@tonic-gate else
260*0Sstevel@tonic-gate (void) printf("-stflush ");
261*0Sstevel@tonic-gate if (m & STWRAP)
262*0Sstevel@tonic-gate (void) printf("stwrap ");
263*0Sstevel@tonic-gate else
264*0Sstevel@tonic-gate (void) printf("-stwrap ");
265*0Sstevel@tonic-gate if (m & STAPPL)
266*0Sstevel@tonic-gate (void) printf("stappl ");
267*0Sstevel@tonic-gate else
268*0Sstevel@tonic-gate (void) printf("-stappl ");
269*0Sstevel@tonic-gate (void) printf("\n");
270*0Sstevel@tonic-gate }
271*0Sstevel@tonic-gate if (term & ASYNC) {
272*0Sstevel@tonic-gate m = cb.c_cflag;
273*0Sstevel@tonic-gate if ((term & TERMIOS) && cfgetispeed(&cb) != 0 &&
274*0Sstevel@tonic-gate cfgetispeed(&cb) != cfgetospeed(&cb)) {
275*0Sstevel@tonic-gate prspeed("ispeed ", cfgetispeed(&cb));
276*0Sstevel@tonic-gate prspeed("ospeed ", cfgetospeed(&cb));
277*0Sstevel@tonic-gate } else
278*0Sstevel@tonic-gate prspeed("speed ", cfgetospeed(&cb));
279*0Sstevel@tonic-gate if (m&PARENB) {
280*0Sstevel@tonic-gate if ((m&PAREXT) && (term & TERMIOS)) {
281*0Sstevel@tonic-gate if (m&PARODD)
282*0Sstevel@tonic-gate (void) printf("markp ");
283*0Sstevel@tonic-gate else
284*0Sstevel@tonic-gate (void) printf("spacep ");
285*0Sstevel@tonic-gate } else {
286*0Sstevel@tonic-gate if (m&PARODD)
287*0Sstevel@tonic-gate (void) printf("oddp ");
288*0Sstevel@tonic-gate else
289*0Sstevel@tonic-gate (void) printf("evenp ");
290*0Sstevel@tonic-gate }
291*0Sstevel@tonic-gate } else
292*0Sstevel@tonic-gate (void) printf("-parity ");
293*0Sstevel@tonic-gate if (((m&PARENB) && !(m&CS7)) || (!(m&PARENB) && !(m&CS8)))
294*0Sstevel@tonic-gate (void) printf("cs%c ", '5'+(m&CSIZE)/CS6);
295*0Sstevel@tonic-gate if (m&CSTOPB)
296*0Sstevel@tonic-gate (void) printf("cstopb ");
297*0Sstevel@tonic-gate if (m&HUPCL)
298*0Sstevel@tonic-gate (void) printf("hupcl ");
299*0Sstevel@tonic-gate if (!(m&CREAD))
300*0Sstevel@tonic-gate (void) printf("-cread ");
301*0Sstevel@tonic-gate if (m&CLOCAL)
302*0Sstevel@tonic-gate (void) printf("clocal ");
303*0Sstevel@tonic-gate if (m&LOBLK)
304*0Sstevel@tonic-gate (void) printf("loblk ");
305*0Sstevel@tonic-gate (void) printf("\n");
306*0Sstevel@tonic-gate if (ocb.c_line != 0)
307*0Sstevel@tonic-gate (void) printf(gettext("line = %d; "), ocb.c_line);
308*0Sstevel@tonic-gate if (term & WINDOW) {
309*0Sstevel@tonic-gate (void) printf(gettext(
310*0Sstevel@tonic-gate "rows = %d; columns = %d;"), winsize.ws_row, winsize.ws_col);
311*0Sstevel@tonic-gate (void) printf(gettext(
312*0Sstevel@tonic-gate " ypixels = %d; xpixels = %d;\n"),
313*0Sstevel@tonic-gate winsize.ws_ypixel, winsize.ws_xpixel);
314*0Sstevel@tonic-gate }
315*0Sstevel@tonic-gate if ((cb.c_lflag&ICANON) == 0)
316*0Sstevel@tonic-gate (void) printf(gettext("min = %d; time = %d;\n"),
317*0Sstevel@tonic-gate cb.c_cc[VMIN], cb.c_cc[VTIME]);
318*0Sstevel@tonic-gate if (cb.c_cc[VINTR] != CINTR)
319*0Sstevel@tonic-gate pit(cb.c_cc[VINTR], "intr", "; ");
320*0Sstevel@tonic-gate if (cb.c_cc[VQUIT] != CQUIT)
321*0Sstevel@tonic-gate pit(cb.c_cc[VQUIT], "quit", "; ");
322*0Sstevel@tonic-gate if (cb.c_cc[VERASE] != CERASE)
323*0Sstevel@tonic-gate pit(cb.c_cc[VERASE], "erase", "; ");
324*0Sstevel@tonic-gate if (cb.c_cc[VKILL] != CKILL)
325*0Sstevel@tonic-gate pit(cb.c_cc[VKILL], "kill", "; ");
326*0Sstevel@tonic-gate if (cb.c_cc[VEOF] != CEOF)
327*0Sstevel@tonic-gate pit(cb.c_cc[VEOF], "eof", "; ");
328*0Sstevel@tonic-gate if (cb.c_cc[VEOL] != CNUL)
329*0Sstevel@tonic-gate pit(cb.c_cc[VEOL], "eol", "; ");
330*0Sstevel@tonic-gate if (cb.c_cc[VEOL2] != CNUL)
331*0Sstevel@tonic-gate pit(cb.c_cc[VEOL2], "eol2", "; ");
332*0Sstevel@tonic-gate if (cb.c_cc[VSWTCH] != CSWTCH)
333*0Sstevel@tonic-gate pit(cb.c_cc[VSWTCH], "swtch", "; ");
334*0Sstevel@tonic-gate if (term & TERMIOS) {
335*0Sstevel@tonic-gate if (cb.c_cc[VSTART] != CSTART)
336*0Sstevel@tonic-gate pit(cb.c_cc[VSTART], "start", "; ");
337*0Sstevel@tonic-gate if (cb.c_cc[VSTOP] != CSTOP)
338*0Sstevel@tonic-gate pit(cb.c_cc[VSTOP], "stop", "; ");
339*0Sstevel@tonic-gate if (cb.c_cc[VSUSP] != CSUSP)
340*0Sstevel@tonic-gate pit(cb.c_cc[VSUSP], "susp", "; ");
341*0Sstevel@tonic-gate if (cb.c_cc[VDSUSP] != CDSUSP)
342*0Sstevel@tonic-gate pit(cb.c_cc[VDSUSP], "dsusp", "; ");
343*0Sstevel@tonic-gate if (cb.c_cc[VREPRINT] != CRPRNT)
344*0Sstevel@tonic-gate pit(cb.c_cc[VREPRINT], "rprnt", "; ");
345*0Sstevel@tonic-gate if (cb.c_cc[VDISCARD] != CFLUSH)
346*0Sstevel@tonic-gate pit(cb.c_cc[VDISCARD], "flush", "; ");
347*0Sstevel@tonic-gate if (cb.c_cc[VWERASE] != CWERASE)
348*0Sstevel@tonic-gate pit(cb.c_cc[VWERASE], "werase", "; ");
349*0Sstevel@tonic-gate if (cb.c_cc[VLNEXT] != CLNEXT)
350*0Sstevel@tonic-gate pit(cb.c_cc[VLNEXT], "lnext", "; ");
351*0Sstevel@tonic-gate }
352*0Sstevel@tonic-gate if (pitt) (void) printf("\n");
353*0Sstevel@tonic-gate m = cb.c_iflag;
354*0Sstevel@tonic-gate if (m&IGNBRK)
355*0Sstevel@tonic-gate (void) printf("ignbrk ");
356*0Sstevel@tonic-gate else if (m&BRKINT)
357*0Sstevel@tonic-gate (void) printf("brkint ");
358*0Sstevel@tonic-gate if (!(m&INPCK))
359*0Sstevel@tonic-gate (void) printf("-inpck ");
360*0Sstevel@tonic-gate else if (m&IGNPAR)
361*0Sstevel@tonic-gate (void) printf("ignpar ");
362*0Sstevel@tonic-gate if (m&PARMRK)
363*0Sstevel@tonic-gate (void) printf("parmrk ");
364*0Sstevel@tonic-gate if (!(m&ISTRIP))
365*0Sstevel@tonic-gate (void) printf("-istrip ");
366*0Sstevel@tonic-gate if (m&INLCR)
367*0Sstevel@tonic-gate (void) printf("inlcr ");
368*0Sstevel@tonic-gate if (m&IGNCR)
369*0Sstevel@tonic-gate (void) printf("igncr ");
370*0Sstevel@tonic-gate if (m&ICRNL)
371*0Sstevel@tonic-gate (void) printf("icrnl ");
372*0Sstevel@tonic-gate if (m&IUCLC)
373*0Sstevel@tonic-gate (void) printf("iuclc ");
374*0Sstevel@tonic-gate if (!(m&IXON))
375*0Sstevel@tonic-gate (void) printf("-ixon ");
376*0Sstevel@tonic-gate else if (!(m&IXANY))
377*0Sstevel@tonic-gate (void) printf("-ixany ");
378*0Sstevel@tonic-gate if (m&IXOFF)
379*0Sstevel@tonic-gate (void) printf("ixoff ");
380*0Sstevel@tonic-gate if ((term & TERMIOS) && (m&IMAXBEL))
381*0Sstevel@tonic-gate (void) printf("imaxbel ");
382*0Sstevel@tonic-gate m = cb.c_oflag;
383*0Sstevel@tonic-gate if (!(m&OPOST))
384*0Sstevel@tonic-gate (void) printf("-opost ");
385*0Sstevel@tonic-gate else {
386*0Sstevel@tonic-gate if (m&OLCUC)
387*0Sstevel@tonic-gate (void) printf("olcuc ");
388*0Sstevel@tonic-gate if (m&ONLCR)
389*0Sstevel@tonic-gate (void) printf("onlcr ");
390*0Sstevel@tonic-gate if (m&OCRNL)
391*0Sstevel@tonic-gate (void) printf("ocrnl ");
392*0Sstevel@tonic-gate if (m&ONOCR)
393*0Sstevel@tonic-gate (void) printf("onocr ");
394*0Sstevel@tonic-gate if (m&ONLRET)
395*0Sstevel@tonic-gate (void) printf("onlret ");
396*0Sstevel@tonic-gate if (m&OFILL)
397*0Sstevel@tonic-gate if (m&OFDEL)
398*0Sstevel@tonic-gate (void) printf("del-fill ");
399*0Sstevel@tonic-gate else
400*0Sstevel@tonic-gate (void) printf("nul-fill ");
401*0Sstevel@tonic-gate delay((m&CRDLY)/CR1, "cr");
402*0Sstevel@tonic-gate delay((m&NLDLY)/NL1, "nl");
403*0Sstevel@tonic-gate delay((m&TABDLY)/TAB1, "tab");
404*0Sstevel@tonic-gate delay((m&BSDLY)/BS1, "bs");
405*0Sstevel@tonic-gate delay((m&VTDLY)/VT1, "vt");
406*0Sstevel@tonic-gate delay((m&FFDLY)/FF1, "ff");
407*0Sstevel@tonic-gate }
408*0Sstevel@tonic-gate (void) printf("\n");
409*0Sstevel@tonic-gate m = cb.c_lflag;
410*0Sstevel@tonic-gate if (!(m&ISIG))
411*0Sstevel@tonic-gate (void) printf("-isig ");
412*0Sstevel@tonic-gate if (!(m&ICANON))
413*0Sstevel@tonic-gate (void) printf("-icanon ");
414*0Sstevel@tonic-gate if (m&XCASE)
415*0Sstevel@tonic-gate (void) printf("xcase ");
416*0Sstevel@tonic-gate (void) printf("-echo "+((m&ECHO) != 0));
417*0Sstevel@tonic-gate (void) printf("-echoe "+((m&ECHOE) != 0));
418*0Sstevel@tonic-gate (void) printf("-echok "+((m&ECHOK) != 0));
419*0Sstevel@tonic-gate if (m&ECHONL)
420*0Sstevel@tonic-gate (void) printf("echonl ");
421*0Sstevel@tonic-gate if (m&NOFLSH)
422*0Sstevel@tonic-gate (void) printf("noflsh ");
423*0Sstevel@tonic-gate if (m&TOSTOP)
424*0Sstevel@tonic-gate (void) printf("tostop ");
425*0Sstevel@tonic-gate if (m&ECHOCTL)
426*0Sstevel@tonic-gate (void) printf("echoctl ");
427*0Sstevel@tonic-gate if (m&ECHOPRT)
428*0Sstevel@tonic-gate (void) printf("echoprt ");
429*0Sstevel@tonic-gate if (m&ECHOKE)
430*0Sstevel@tonic-gate (void) printf("echoke ");
431*0Sstevel@tonic-gate if (m&DEFECHO)
432*0Sstevel@tonic-gate (void) printf("defecho ");
433*0Sstevel@tonic-gate if (m&FLUSHO)
434*0Sstevel@tonic-gate (void) printf("flusho ");
435*0Sstevel@tonic-gate if (m&PENDIN)
436*0Sstevel@tonic-gate (void) printf("pendin ");
437*0Sstevel@tonic-gate if (m&IEXTEN)
438*0Sstevel@tonic-gate (void) printf("iexten ");
439*0Sstevel@tonic-gate (void) printf("\n");
440*0Sstevel@tonic-gate }
441*0Sstevel@tonic-gate if (term & FLOW) {
442*0Sstevel@tonic-gate m = termiox.x_hflag;
443*0Sstevel@tonic-gate if (m & RTSXOFF)
444*0Sstevel@tonic-gate (void) printf("rtsxoff ");
445*0Sstevel@tonic-gate if (m & CTSXON)
446*0Sstevel@tonic-gate (void) printf("ctsxon ");
447*0Sstevel@tonic-gate if (m & DTRXOFF)
448*0Sstevel@tonic-gate (void) printf("dtrxoff ");
449*0Sstevel@tonic-gate if (m & CDXON)
450*0Sstevel@tonic-gate (void) printf("cdxon ");
451*0Sstevel@tonic-gate if (m & ISXOFF)
452*0Sstevel@tonic-gate (void) printf("isxoff ");
453*0Sstevel@tonic-gate m = termiox.x_cflag;
454*0Sstevel@tonic-gate switch (m & XMTCLK) {
455*0Sstevel@tonic-gate case XCIBRG: (void)printf("xcibrg ");
456*0Sstevel@tonic-gate break;
457*0Sstevel@tonic-gate case XCTSET: (void)printf("xctset ");
458*0Sstevel@tonic-gate break;
459*0Sstevel@tonic-gate case XCRSET: (void)printf("xcrset ");
460*0Sstevel@tonic-gate }
461*0Sstevel@tonic-gate
462*0Sstevel@tonic-gate switch (m & RCVCLK) {
463*0Sstevel@tonic-gate case RCIBRG: (void)printf("rcibrg ");
464*0Sstevel@tonic-gate break;
465*0Sstevel@tonic-gate case RCTSET: (void)printf("rctset ");
466*0Sstevel@tonic-gate break;
467*0Sstevel@tonic-gate case RCRSET: (void)printf("rcrset ");
468*0Sstevel@tonic-gate }
469*0Sstevel@tonic-gate
470*0Sstevel@tonic-gate switch (m & TSETCLK) {
471*0Sstevel@tonic-gate case TSETCOFF: (void)printf("tsetcoff ");
472*0Sstevel@tonic-gate break;
473*0Sstevel@tonic-gate case TSETCRBRG: (void)printf("tsetcrbrg ");
474*0Sstevel@tonic-gate break;
475*0Sstevel@tonic-gate case TSETCTBRG: (void)printf("tsetctbrg ");
476*0Sstevel@tonic-gate break;
477*0Sstevel@tonic-gate case TSETCTSET: (void)printf("tsetctset ");
478*0Sstevel@tonic-gate break;
479*0Sstevel@tonic-gate case TSETCRSET: (void)printf("tsetcrset ");
480*0Sstevel@tonic-gate }
481*0Sstevel@tonic-gate
482*0Sstevel@tonic-gate switch (m & RSETCLK) {
483*0Sstevel@tonic-gate case RSETCOFF: (void)printf("rsetcoff ");
484*0Sstevel@tonic-gate break;
485*0Sstevel@tonic-gate case RSETCRBRG: (void)printf("rsetcrbrg ");
486*0Sstevel@tonic-gate break;
487*0Sstevel@tonic-gate case RSETCTBRG: (void)printf("rsetctbrg ");
488*0Sstevel@tonic-gate break;
489*0Sstevel@tonic-gate case RSETCTSET: (void)printf("rsetctset ");
490*0Sstevel@tonic-gate break;
491*0Sstevel@tonic-gate case RSETCRSET: (void)printf("rsetcrset ");
492*0Sstevel@tonic-gate }
493*0Sstevel@tonic-gate (void) printf("\n");
494*0Sstevel@tonic-gate }
495*0Sstevel@tonic-gate }
496*0Sstevel@tonic-gate
497*0Sstevel@tonic-gate void
pramodes(void)498*0Sstevel@tonic-gate pramodes(void) /* print all modes, -a option */
499*0Sstevel@tonic-gate {
500*0Sstevel@tonic-gate int m;
501*0Sstevel@tonic-gate
502*0Sstevel@tonic-gate m = cb.c_cflag;
503*0Sstevel@tonic-gate if (term & ASYNC) {
504*0Sstevel@tonic-gate if ((term & TERMIOS) && cfgetispeed(&cb) != 0 &&
505*0Sstevel@tonic-gate cfgetispeed(&cb) != cfgetospeed(&cb)) {
506*0Sstevel@tonic-gate prspeed("ispeed ", cfgetispeed(&cb));
507*0Sstevel@tonic-gate prspeed("ospeed ", cfgetospeed(&cb));
508*0Sstevel@tonic-gate } else
509*0Sstevel@tonic-gate prspeed("speed ", cfgetospeed(&cb));
510*0Sstevel@tonic-gate if (!(term & TERMIOS))
511*0Sstevel@tonic-gate (void) printf(gettext("line = %d; "), ocb.c_line);
512*0Sstevel@tonic-gate (void) printf("\n");
513*0Sstevel@tonic-gate if (term & WINDOW) {
514*0Sstevel@tonic-gate (void) printf(gettext("rows = %d; columns = %d;"),
515*0Sstevel@tonic-gate winsize.ws_row, winsize.ws_col);
516*0Sstevel@tonic-gate (void) printf(gettext(
517*0Sstevel@tonic-gate " ypixels = %d; xpixels = %d;\n"),
518*0Sstevel@tonic-gate winsize.ws_ypixel, winsize.ws_xpixel);
519*0Sstevel@tonic-gate }
520*0Sstevel@tonic-gate #ifdef EUC
521*0Sstevel@tonic-gate if ((term & CSIW) && kcswp.locale_name[0]) {
522*0Sstevel@tonic-gate (void) printf("csdata %s\n", kcswp.locale_name);
523*0Sstevel@tonic-gate } else {
524*0Sstevel@tonic-gate (void) printf("csdata ?\n");
525*0Sstevel@tonic-gate }
526*0Sstevel@tonic-gate /*
527*0Sstevel@tonic-gate * If kwp.eucw[0] is zero, it means the current codeset type
528*0Sstevel@tonic-gate * in the ldterm is not EUC.
529*0Sstevel@tonic-gate */
530*0Sstevel@tonic-gate if ((term & EUCW) && kwp.eucw[0]) {
531*0Sstevel@tonic-gate (void) printf("eucw %d:%d:%d:%d, ", kwp.eucw[0],
532*0Sstevel@tonic-gate kwp.eucw[1], kwp.eucw[2], kwp.eucw[3]);
533*0Sstevel@tonic-gate (void) printf("scrw %d:%d:%d:%d\n", kwp.scrw[0],
534*0Sstevel@tonic-gate kwp.scrw[1], kwp.scrw[2], kwp.scrw[3]);
535*0Sstevel@tonic-gate } else
536*0Sstevel@tonic-gate (void) printf("eucw ?, scrw ?\n");
537*0Sstevel@tonic-gate #endif /* EUC */
538*0Sstevel@tonic-gate if ((cb.c_lflag&ICANON) == 0)
539*0Sstevel@tonic-gate (void) printf(gettext("min = %d; time = %d;\n"),
540*0Sstevel@tonic-gate cb.c_cc[VMIN], cb.c_cc[VTIME]);
541*0Sstevel@tonic-gate pit(cb.c_cc[VINTR], "intr", "; ");
542*0Sstevel@tonic-gate pit(cb.c_cc[VQUIT], "quit", "; ");
543*0Sstevel@tonic-gate pit(cb.c_cc[VERASE], "erase", "; ");
544*0Sstevel@tonic-gate pit(cb.c_cc[VKILL], "kill", ";\n");
545*0Sstevel@tonic-gate pit(cb.c_cc[VEOF], "eof", "; ");
546*0Sstevel@tonic-gate pit(cb.c_cc[VEOL], "eol", "; ");
547*0Sstevel@tonic-gate pit(cb.c_cc[VEOL2], "eol2", "; ");
548*0Sstevel@tonic-gate pit(cb.c_cc[VSWTCH], "swtch", ";\n");
549*0Sstevel@tonic-gate if (term & TERMIOS) {
550*0Sstevel@tonic-gate pit(cb.c_cc[VSTART], "start", "; ");
551*0Sstevel@tonic-gate pit(cb.c_cc[VSTOP], "stop", "; ");
552*0Sstevel@tonic-gate pit(cb.c_cc[VSUSP], "susp", "; ");
553*0Sstevel@tonic-gate pit(cb.c_cc[VDSUSP], "dsusp", ";\n");
554*0Sstevel@tonic-gate pit(cb.c_cc[VREPRINT], "rprnt", "; ");
555*0Sstevel@tonic-gate pit(cb.c_cc[VDISCARD], "flush", "; ");
556*0Sstevel@tonic-gate pit(cb.c_cc[VWERASE], "werase", "; ");
557*0Sstevel@tonic-gate pit(cb.c_cc[VLNEXT], "lnext", ";\n");
558*0Sstevel@tonic-gate }
559*0Sstevel@tonic-gate } else
560*0Sstevel@tonic-gate pit((unsigned)stio.tab, "ctab", "\n");
561*0Sstevel@tonic-gate m = cb.c_cflag;
562*0Sstevel@tonic-gate (void) printf("-parenb "+((m&PARENB) != 0));
563*0Sstevel@tonic-gate (void) printf("-parodd "+((m&PARODD) != 0));
564*0Sstevel@tonic-gate (void) printf("cs%c ", '5'+(m&CSIZE)/CS6);
565*0Sstevel@tonic-gate (void) printf("-cstopb "+((m&CSTOPB) != 0));
566*0Sstevel@tonic-gate (void) printf("-hupcl "+((m&HUPCL) != 0));
567*0Sstevel@tonic-gate (void) printf("-cread "+((m&CREAD) != 0));
568*0Sstevel@tonic-gate (void) printf("-clocal "+((m&CLOCAL) != 0));
569*0Sstevel@tonic-gate
570*0Sstevel@tonic-gate (void) printf("-loblk "+((m&LOBLK) != 0));
571*0Sstevel@tonic-gate (void) printf("-crtscts "+((m&CRTSCTS) != 0));
572*0Sstevel@tonic-gate (void) printf("-crtsxoff "+((m&CRTSXOFF) != 0));
573*0Sstevel@tonic-gate if (term & TERMIOS)
574*0Sstevel@tonic-gate (void) printf("-parext "+((m&PAREXT) != 0));
575*0Sstevel@tonic-gate
576*0Sstevel@tonic-gate (void) printf("\n");
577*0Sstevel@tonic-gate m = cb.c_iflag;
578*0Sstevel@tonic-gate (void) printf("-ignbrk "+((m&IGNBRK) != 0));
579*0Sstevel@tonic-gate (void) printf("-brkint "+((m&BRKINT) != 0));
580*0Sstevel@tonic-gate (void) printf("-ignpar "+((m&IGNPAR) != 0));
581*0Sstevel@tonic-gate (void) printf("-parmrk "+((m&PARMRK) != 0));
582*0Sstevel@tonic-gate (void) printf("-inpck "+((m&INPCK) != 0));
583*0Sstevel@tonic-gate (void) printf("-istrip "+((m&ISTRIP) != 0));
584*0Sstevel@tonic-gate (void) printf("-inlcr "+((m&INLCR) != 0));
585*0Sstevel@tonic-gate (void) printf("-igncr "+((m&IGNCR) != 0));
586*0Sstevel@tonic-gate (void) printf("-icrnl "+((m&ICRNL) != 0));
587*0Sstevel@tonic-gate (void) printf("-iuclc "+((m&IUCLC) != 0));
588*0Sstevel@tonic-gate (void) printf("\n");
589*0Sstevel@tonic-gate (void) printf("-ixon "+((m&IXON) != 0));
590*0Sstevel@tonic-gate (void) printf("-ixany "+((m&IXANY) != 0));
591*0Sstevel@tonic-gate (void) printf("-ixoff "+((m&IXOFF) != 0));
592*0Sstevel@tonic-gate if (term & TERMIOS)
593*0Sstevel@tonic-gate (void) printf("-imaxbel "+((m&IMAXBEL) != 0));
594*0Sstevel@tonic-gate (void) printf("\n");
595*0Sstevel@tonic-gate m = cb.c_lflag;
596*0Sstevel@tonic-gate (void) printf("-isig "+((m&ISIG) != 0));
597*0Sstevel@tonic-gate (void) printf("-icanon "+((m&ICANON) != 0));
598*0Sstevel@tonic-gate (void) printf("-xcase "+((m&XCASE) != 0));
599*0Sstevel@tonic-gate (void) printf("-echo "+((m&ECHO) != 0));
600*0Sstevel@tonic-gate (void) printf("-echoe "+((m&ECHOE) != 0));
601*0Sstevel@tonic-gate (void) printf("-echok "+((m&ECHOK) != 0));
602*0Sstevel@tonic-gate (void) printf("-echonl "+((m&ECHONL) != 0));
603*0Sstevel@tonic-gate (void) printf("-noflsh "+((m&NOFLSH) != 0));
604*0Sstevel@tonic-gate if (term & TERMIOS) {
605*0Sstevel@tonic-gate (void) printf("\n");
606*0Sstevel@tonic-gate (void) printf("-tostop "+((m&TOSTOP) != 0));
607*0Sstevel@tonic-gate (void) printf("-echoctl "+((m&ECHOCTL) != 0));
608*0Sstevel@tonic-gate (void) printf("-echoprt "+((m&ECHOPRT) != 0));
609*0Sstevel@tonic-gate (void) printf("-echoke "+((m&ECHOKE) != 0));
610*0Sstevel@tonic-gate (void) printf("-defecho "+((m&DEFECHO) != 0));
611*0Sstevel@tonic-gate (void) printf("-flusho "+((m&FLUSHO) != 0));
612*0Sstevel@tonic-gate (void) printf("-pendin "+((m&PENDIN) != 0));
613*0Sstevel@tonic-gate (void) printf("-iexten "+((m&IEXTEN) != 0));
614*0Sstevel@tonic-gate }
615*0Sstevel@tonic-gate if (!(term & ASYNC)) {
616*0Sstevel@tonic-gate (void) printf("-stflush "+((m&STFLUSH) != 0));
617*0Sstevel@tonic-gate (void) printf("-stwrap "+((m&STWRAP) != 0));
618*0Sstevel@tonic-gate (void) printf("-stappl "+((m&STAPPL) != 0));
619*0Sstevel@tonic-gate }
620*0Sstevel@tonic-gate (void) printf("\n");
621*0Sstevel@tonic-gate m = cb.c_oflag;
622*0Sstevel@tonic-gate (void) printf("-opost "+((m&OPOST) != 0));
623*0Sstevel@tonic-gate (void) printf("-olcuc "+((m&OLCUC) != 0));
624*0Sstevel@tonic-gate (void) printf("-onlcr "+((m&ONLCR) != 0));
625*0Sstevel@tonic-gate (void) printf("-ocrnl "+((m&OCRNL) != 0));
626*0Sstevel@tonic-gate (void) printf("-onocr "+((m&ONOCR) != 0));
627*0Sstevel@tonic-gate (void) printf("-onlret "+((m&ONLRET) != 0));
628*0Sstevel@tonic-gate (void) printf("-ofill "+((m&OFILL) != 0));
629*0Sstevel@tonic-gate (void) printf("-ofdel "+((m&OFDEL) != 0));
630*0Sstevel@tonic-gate delay((m&CRDLY)/CR1, "cr");
631*0Sstevel@tonic-gate delay((m&NLDLY)/NL1, "nl");
632*0Sstevel@tonic-gate delay((m&TABDLY)/TAB1, "tab");
633*0Sstevel@tonic-gate delay((m&BSDLY)/BS1, "bs");
634*0Sstevel@tonic-gate delay((m&VTDLY)/VT1, "vt");
635*0Sstevel@tonic-gate delay((m&FFDLY)/FF1, "ff");
636*0Sstevel@tonic-gate (void) printf("\n");
637*0Sstevel@tonic-gate if (term & FLOW) {
638*0Sstevel@tonic-gate m = termiox.x_hflag;
639*0Sstevel@tonic-gate (void) printf("-rtsxoff "+((m&RTSXOFF) != 0));
640*0Sstevel@tonic-gate (void) printf("-ctsxon "+((m&CTSXON) != 0));
641*0Sstevel@tonic-gate (void) printf("-dtrxoff "+((m&DTRXOFF) != 0));
642*0Sstevel@tonic-gate (void) printf("-cdxon "+((m&CDXON) != 0));
643*0Sstevel@tonic-gate (void) printf("-isxoff "+((m&ISXOFF) != 0));
644*0Sstevel@tonic-gate m = termiox.x_cflag;
645*0Sstevel@tonic-gate switch (m & XMTCLK) {
646*0Sstevel@tonic-gate case XCIBRG: (void)printf("xcibrg ");
647*0Sstevel@tonic-gate break;
648*0Sstevel@tonic-gate case XCTSET: (void)printf("xctset ");
649*0Sstevel@tonic-gate break;
650*0Sstevel@tonic-gate case XCRSET: (void)printf("xcrset ");
651*0Sstevel@tonic-gate }
652*0Sstevel@tonic-gate
653*0Sstevel@tonic-gate switch (m & RCVCLK) {
654*0Sstevel@tonic-gate case RCIBRG: (void)printf("rcibrg ");
655*0Sstevel@tonic-gate break;
656*0Sstevel@tonic-gate case RCTSET: (void)printf("rctset ");
657*0Sstevel@tonic-gate break;
658*0Sstevel@tonic-gate case RCRSET: (void)printf("rcrset ");
659*0Sstevel@tonic-gate }
660*0Sstevel@tonic-gate
661*0Sstevel@tonic-gate switch (m & TSETCLK) {
662*0Sstevel@tonic-gate case TSETCOFF: (void)printf("tsetcoff ");
663*0Sstevel@tonic-gate break;
664*0Sstevel@tonic-gate case TSETCRBRG: (void)printf("tsetcrbrg ");
665*0Sstevel@tonic-gate break;
666*0Sstevel@tonic-gate case TSETCTBRG: (void)printf("tsetctbrg ");
667*0Sstevel@tonic-gate break;
668*0Sstevel@tonic-gate case TSETCTSET: (void)printf("tsetctset ");
669*0Sstevel@tonic-gate break;
670*0Sstevel@tonic-gate case TSETCRSET: (void)printf("tsetcrset ");
671*0Sstevel@tonic-gate }
672*0Sstevel@tonic-gate
673*0Sstevel@tonic-gate switch (m & RSETCLK) {
674*0Sstevel@tonic-gate case RSETCOFF: (void)printf("rsetcoff ");
675*0Sstevel@tonic-gate break;
676*0Sstevel@tonic-gate case RSETCRBRG: (void)printf("rsetcrbrg ");
677*0Sstevel@tonic-gate break;
678*0Sstevel@tonic-gate case RSETCTBRG: (void)printf("rsetctbrg ");
679*0Sstevel@tonic-gate break;
680*0Sstevel@tonic-gate case RSETCTSET: (void)printf("rsetctset ");
681*0Sstevel@tonic-gate break;
682*0Sstevel@tonic-gate case RSETCRSET: (void)printf("rsetcrset ");
683*0Sstevel@tonic-gate }
684*0Sstevel@tonic-gate (void) printf("\n");
685*0Sstevel@tonic-gate }
686*0Sstevel@tonic-gate }
687*0Sstevel@tonic-gate
688*0Sstevel@tonic-gate /* print function for prmodes() and pramodes() */
689*0Sstevel@tonic-gate void
pit(unsigned char what,char * itsname,char * sep)690*0Sstevel@tonic-gate pit(unsigned char what, char *itsname, char *sep)
691*0Sstevel@tonic-gate {
692*0Sstevel@tonic-gate
693*0Sstevel@tonic-gate pitt++;
694*0Sstevel@tonic-gate (void) printf("%s", itsname);
695*0Sstevel@tonic-gate if ((term & TERMIOS) && what == _POSIX_VDISABLE ||
696*0Sstevel@tonic-gate !(term & TERMIOS) && what == 0200) {
697*0Sstevel@tonic-gate (void) printf(" = <undef>%s", sep);
698*0Sstevel@tonic-gate return;
699*0Sstevel@tonic-gate }
700*0Sstevel@tonic-gate (void) printf(" = ");
701*0Sstevel@tonic-gate if (what & 0200 && !isprint(what)) {
702*0Sstevel@tonic-gate (void) printf("-");
703*0Sstevel@tonic-gate what &= ~ 0200;
704*0Sstevel@tonic-gate }
705*0Sstevel@tonic-gate if (what == 0177) {
706*0Sstevel@tonic-gate (void) printf("^?%s", sep);
707*0Sstevel@tonic-gate return;
708*0Sstevel@tonic-gate } else if (what < ' ') {
709*0Sstevel@tonic-gate (void) printf("^");
710*0Sstevel@tonic-gate what += '`';
711*0Sstevel@tonic-gate if (what > 'z')
712*0Sstevel@tonic-gate what -= 'a' -'A';
713*0Sstevel@tonic-gate }
714*0Sstevel@tonic-gate (void) printf("%c%s", what, sep);
715*0Sstevel@tonic-gate }
716*0Sstevel@tonic-gate
717*0Sstevel@tonic-gate void
delay(int m,char * s)718*0Sstevel@tonic-gate delay(int m, char *s)
719*0Sstevel@tonic-gate {
720*0Sstevel@tonic-gate if (m)
721*0Sstevel@tonic-gate (void) printf("%s%d ", s, m);
722*0Sstevel@tonic-gate }
723*0Sstevel@tonic-gate
724*0Sstevel@tonic-gate void
prspeed(char * c,int scode)725*0Sstevel@tonic-gate prspeed(char *c, int scode)
726*0Sstevel@tonic-gate {
727*0Sstevel@tonic-gate int sval = -1;
728*0Sstevel@tonic-gate int i;
729*0Sstevel@tonic-gate
730*0Sstevel@tonic-gate for (i = 0; speeds[i].string; i++) {
731*0Sstevel@tonic-gate if (speeds[i].code == scode) {
732*0Sstevel@tonic-gate sval = speeds[i].value;
733*0Sstevel@tonic-gate break;
734*0Sstevel@tonic-gate }
735*0Sstevel@tonic-gate }
736*0Sstevel@tonic-gate
737*0Sstevel@tonic-gate (void) printf("%s%d baud; ", c, sval);
738*0Sstevel@tonic-gate }
739*0Sstevel@tonic-gate
740*0Sstevel@tonic-gate /* print current settings for use with */
741*0Sstevel@tonic-gate void
prencode(void)742*0Sstevel@tonic-gate prencode(void) /* another stty cmd, used for -g option */
743*0Sstevel@tonic-gate {
744*0Sstevel@tonic-gate int i, last;
745*0Sstevel@tonic-gate
746*0Sstevel@tonic-gate /*
747*0Sstevel@tonic-gate * Although there are only 16 control chars defined as of April 1995,
748*0Sstevel@tonic-gate * prencode() and encode() will not have to be changed if up to MAX_CC
749*0Sstevel@tonic-gate * control chars are defined in the future. A maximum of MAX_CC rather
750*0Sstevel@tonic-gate * than NCCS control chars are printed because the last control slot
751*0Sstevel@tonic-gate * is unused. "stty -g" prints out a total of NUM_FIELDS fields
752*0Sstevel@tonic-gate * (NUM_MODES modes + MAX_CC control chars). First print the input,
753*0Sstevel@tonic-gate * output, control, and line discipline modes.
754*0Sstevel@tonic-gate */
755*0Sstevel@tonic-gate (void) printf("%x:%x:%x:%x", cb.c_iflag, cb.c_oflag, cb.c_cflag,
756*0Sstevel@tonic-gate cb.c_lflag);
757*0Sstevel@tonic-gate
758*0Sstevel@tonic-gate /* Print the control character fields. */
759*0Sstevel@tonic-gate if (term & TERMIOS)
760*0Sstevel@tonic-gate last = MAX_CC;
761*0Sstevel@tonic-gate else
762*0Sstevel@tonic-gate last = NCC;
763*0Sstevel@tonic-gate #ifdef EUC
764*0Sstevel@tonic-gate if (term & CSIW) {
765*0Sstevel@tonic-gate for (i = 0; i < MAX_CC; i++)
766*0Sstevel@tonic-gate (void) printf(":%x", (i >= last) ? 0 : cb.c_cc[i]);
767*0Sstevel@tonic-gate /*
768*0Sstevel@tonic-gate * Print out ldterm_cs_data_user_t data fields for
769*0Sstevel@tonic-gate * PSARC/1999/140 TCR2. This change introduces additional
770*0Sstevel@tonic-gate * 44 fields that come from the ldterm_cs_data_user_t data
771*0Sstevel@tonic-gate * structure.
772*0Sstevel@tonic-gate */
773*0Sstevel@tonic-gate (void) printf(":%x:%x:%x:", kcswp.version, kcswp.codeset_type,
774*0Sstevel@tonic-gate kcswp.csinfo_num);
775*0Sstevel@tonic-gate if (*kcswp.locale_name == '\0') {
776*0Sstevel@tonic-gate (void) printf("00");
777*0Sstevel@tonic-gate } else {
778*0Sstevel@tonic-gate for (i = 0; kcswp.locale_name[i] && i < MAXNAMELEN; i++)
779*0Sstevel@tonic-gate (void) printf("%02x", kcswp.locale_name[i]);
780*0Sstevel@tonic-gate }
781*0Sstevel@tonic-gate for (i = 0; i < LDTERM_CS_MAX_CODESETS; i++)
782*0Sstevel@tonic-gate (void) printf(":%x:%x:%x:%x",
783*0Sstevel@tonic-gate kcswp.eucpc_data[i].byte_length,
784*0Sstevel@tonic-gate kcswp.eucpc_data[i].screen_width,
785*0Sstevel@tonic-gate kcswp.eucpc_data[i].msb_start,
786*0Sstevel@tonic-gate kcswp.eucpc_data[i].msb_end);
787*0Sstevel@tonic-gate } else {
788*0Sstevel@tonic-gate #endif /* EUC */
789*0Sstevel@tonic-gate for (i = 0; i < last; i++)
790*0Sstevel@tonic-gate (void) printf(":%x", cb.c_cc[i]);
791*0Sstevel@tonic-gate #ifdef EUC
792*0Sstevel@tonic-gate }
793*0Sstevel@tonic-gate #endif /* EUC */
794*0Sstevel@tonic-gate (void) printf("\n");
795*0Sstevel@tonic-gate }
796