17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate * Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved.
247c478bd9Sstevel@tonic-gate * Use is subject to license terms.
2519d32b9aSRobert Mustacchi * Copyright (c) 2014, Joyent, Inc. All rights reserved.
267c478bd9Sstevel@tonic-gate */
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate /*
297c478bd9Sstevel@tonic-gate * Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
307c478bd9Sstevel@tonic-gate * All Rights Reserved
317c478bd9Sstevel@tonic-gate *
327c478bd9Sstevel@tonic-gate */
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gate #include <stdio.h>
357c478bd9Sstevel@tonic-gate #include <ctype.h>
367c478bd9Sstevel@tonic-gate #include <locale.h>
377c478bd9Sstevel@tonic-gate #include <sys/types.h>
387c478bd9Sstevel@tonic-gate #include <termio.h>
397c478bd9Sstevel@tonic-gate #include <sys/stermio.h>
407c478bd9Sstevel@tonic-gate #include <sys/termiox.h>
417c478bd9Sstevel@tonic-gate #include <string.h>
427c478bd9Sstevel@tonic-gate #include <stdlib.h>
437c478bd9Sstevel@tonic-gate #include <limits.h>
447c478bd9Sstevel@tonic-gate #ifdef EUC
457c478bd9Sstevel@tonic-gate #include <sys/stat.h>
467c478bd9Sstevel@tonic-gate #include <fcntl.h>
477c478bd9Sstevel@tonic-gate #include <unistd.h>
487c478bd9Sstevel@tonic-gate #include <sys/param.h>
497c478bd9Sstevel@tonic-gate #include <sys/stropts.h>
507c478bd9Sstevel@tonic-gate #include <sys/eucioctl.h>
517c478bd9Sstevel@tonic-gate #include <sys/csiioctl.h>
527c478bd9Sstevel@tonic-gate #include <sys/stream.h>
537c478bd9Sstevel@tonic-gate #include <sys/termios.h>
547c478bd9Sstevel@tonic-gate #include <sys/ldterm.h>
557c478bd9Sstevel@tonic-gate #include <getwidth.h>
567c478bd9Sstevel@tonic-gate #endif /* EUC */
577c478bd9Sstevel@tonic-gate #include "stty.h"
58*3bb2c156SToomas Soome #include "tmextern.h"
597c478bd9Sstevel@tonic-gate
607c478bd9Sstevel@tonic-gate static char *STTY = "stty: ";
617c478bd9Sstevel@tonic-gate static int pitt = 0;
627c478bd9Sstevel@tonic-gate static struct termios cb;
637c478bd9Sstevel@tonic-gate static struct termio ocb; /* for non-streams devices */
647c478bd9Sstevel@tonic-gate static struct stio stio;
657c478bd9Sstevel@tonic-gate static struct termiox termiox;
667c478bd9Sstevel@tonic-gate static struct winsize winsize, owinsize;
677c478bd9Sstevel@tonic-gate static int term;
687c478bd9Sstevel@tonic-gate #ifdef EUC
697c478bd9Sstevel@tonic-gate static struct eucioc kwp;
707c478bd9Sstevel@tonic-gate static eucwidth_t wp;
717c478bd9Sstevel@tonic-gate static ldterm_cs_data_user_t cswp; /* User side codeset width data */
727c478bd9Sstevel@tonic-gate static ldterm_cs_data_user_t kcswp; /* Kernel side codeset width data */
737c478bd9Sstevel@tonic-gate static int invalid_ldterm_dat_file;
747c478bd9Sstevel@tonic-gate #endif /* EUC */
757c478bd9Sstevel@tonic-gate
76*3bb2c156SToomas Soome static void prmodes(void);
77*3bb2c156SToomas Soome static void pramodes(void);
787c478bd9Sstevel@tonic-gate static void pit(unsigned char what, char *itsname, char *sep);
797c478bd9Sstevel@tonic-gate static void delay(int m, char *s);
807c478bd9Sstevel@tonic-gate static void prspeed(char *c, int s);
81*3bb2c156SToomas Soome static void prencode(void);
827c478bd9Sstevel@tonic-gate
837c478bd9Sstevel@tonic-gate int
main(int argc,char * argv[])847c478bd9Sstevel@tonic-gate main(int argc, char *argv[])
857c478bd9Sstevel@tonic-gate {
867c478bd9Sstevel@tonic-gate int i;
877c478bd9Sstevel@tonic-gate int fd;
88*3bb2c156SToomas Soome char *s_arg; /* s_arg: ptr to mode to be set */
897c478bd9Sstevel@tonic-gate #ifdef EUC
907c478bd9Sstevel@tonic-gate char *lc;
917c478bd9Sstevel@tonic-gate char tmps[PATH_MAX];
927c478bd9Sstevel@tonic-gate #endif /* EUC */
937c478bd9Sstevel@tonic-gate
947c478bd9Sstevel@tonic-gate (void) setlocale(LC_ALL, "");
957c478bd9Sstevel@tonic-gate #if !defined(TEXT_DOMAIN)
967c478bd9Sstevel@tonic-gate #define TEXT_DOMAIN "SYS_TEST"
977c478bd9Sstevel@tonic-gate #endif
987c478bd9Sstevel@tonic-gate (void) textdomain(TEXT_DOMAIN);
997c478bd9Sstevel@tonic-gate
1007c478bd9Sstevel@tonic-gate #ifdef EUC
1017c478bd9Sstevel@tonic-gate lc = setlocale(LC_CTYPE, (const char *)NULL);
1027c478bd9Sstevel@tonic-gate if (lc) {
103*3bb2c156SToomas Soome (void) sprintf(tmps, _LDTERM_DAT_PATH, lc);
1047c478bd9Sstevel@tonic-gate
1057c478bd9Sstevel@tonic-gate fd = open(tmps, O_RDONLY, 0);
1067c478bd9Sstevel@tonic-gate if (fd != -1) {
1077c478bd9Sstevel@tonic-gate if (read(fd, (void *)&cswp, sizeof (cswp)) <
1087c478bd9Sstevel@tonic-gate sizeof (cswp)) {
1097c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext(
11019d32b9aSRobert Mustacchi "cannot read entire %s file\n"), tmps);
1117c478bd9Sstevel@tonic-gate exit(2);
1127c478bd9Sstevel@tonic-gate }
1137c478bd9Sstevel@tonic-gate
1147c478bd9Sstevel@tonic-gate (void) close(fd);
1157c478bd9Sstevel@tonic-gate
1167c478bd9Sstevel@tonic-gate /*
1177c478bd9Sstevel@tonic-gate * If the ldterm.dat contains invalid data or
1187c478bd9Sstevel@tonic-gate * the current locale name is too long, we clear
1197c478bd9Sstevel@tonic-gate * the 'cswp' and flag the invalid ldterm.dat since
1207c478bd9Sstevel@tonic-gate * we are not going to use the data.
1217c478bd9Sstevel@tonic-gate */
1227c478bd9Sstevel@tonic-gate if (cswp.version > LDTERM_DATA_VERSION ||
1237c478bd9Sstevel@tonic-gate cswp.codeset_type < LDTERM_CS_TYPE_MIN ||
1247c478bd9Sstevel@tonic-gate cswp.codeset_type > LDTERM_CS_TYPE_MAX ||
1257c478bd9Sstevel@tonic-gate strlen(lc) >= MAXNAMELEN ||
1267c478bd9Sstevel@tonic-gate (cswp.codeset_type == LDTERM_CS_TYPE_EUC &&
1277c478bd9Sstevel@tonic-gate cswp.csinfo_num > LDTERM_CS_TYPE_EUC_MAX_SUBCS) ||
1287c478bd9Sstevel@tonic-gate (cswp.codeset_type == LDTERM_CS_TYPE_PCCS &&
1297c478bd9Sstevel@tonic-gate (cswp.csinfo_num < LDTERM_CS_TYPE_PCCS_MIN_SUBCS ||
1307c478bd9Sstevel@tonic-gate cswp.csinfo_num > LDTERM_CS_TYPE_PCCS_MAX_SUBCS))) {
1317c478bd9Sstevel@tonic-gate (void) memset((void *)&cswp, 0, sizeof (cswp));
1327c478bd9Sstevel@tonic-gate invalid_ldterm_dat_file = 1;
1337c478bd9Sstevel@tonic-gate } else {
1347c478bd9Sstevel@tonic-gate (void) strcpy(cswp.locale_name, lc);
1357c478bd9Sstevel@tonic-gate }
1367c478bd9Sstevel@tonic-gate }
1377c478bd9Sstevel@tonic-gate }
1387c478bd9Sstevel@tonic-gate
1397c478bd9Sstevel@tonic-gate getwidth(&wp);
1407c478bd9Sstevel@tonic-gate #endif /* EUC */
1417c478bd9Sstevel@tonic-gate
1427c478bd9Sstevel@tonic-gate if ((term = get_ttymode(0, &ocb, &cb, &stio, &termiox, &winsize
1437c478bd9Sstevel@tonic-gate #ifdef EUC
1447c478bd9Sstevel@tonic-gate /* */, &kwp, &kcswp
1457c478bd9Sstevel@tonic-gate #endif /* EUC */
1467c478bd9Sstevel@tonic-gate /* */)) < 0) {
1477c478bd9Sstevel@tonic-gate perror(STTY);
1487c478bd9Sstevel@tonic-gate exit(2);
1497c478bd9Sstevel@tonic-gate }
1507c478bd9Sstevel@tonic-gate owinsize = winsize;
1517c478bd9Sstevel@tonic-gate if (argc == 1) {
1527c478bd9Sstevel@tonic-gate prmodes();
1537c478bd9Sstevel@tonic-gate exit(0);
1547c478bd9Sstevel@tonic-gate }
155*3bb2c156SToomas Soome if ((argc == 2) && (argv[1][0] == '-') && (argv[1][2] == '\0')) {
156*3bb2c156SToomas Soome switch (argv[1][1]) {
1577c478bd9Sstevel@tonic-gate case 'a':
1587c478bd9Sstevel@tonic-gate pramodes();
1597c478bd9Sstevel@tonic-gate return (0);
1607c478bd9Sstevel@tonic-gate case 'g':
1617c478bd9Sstevel@tonic-gate prencode();
1627c478bd9Sstevel@tonic-gate return (0);
1637c478bd9Sstevel@tonic-gate case '-':
1647c478bd9Sstevel@tonic-gate prmodes(); /* stty -- */
1657c478bd9Sstevel@tonic-gate return (0);
1667c478bd9Sstevel@tonic-gate default:
1677c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext(
16819d32b9aSRobert Mustacchi "usage: stty [-a| -g]\n"));
1697c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext(
17019d32b9aSRobert Mustacchi " stty [modes]\n"));
1717c478bd9Sstevel@tonic-gate return (2);
172*3bb2c156SToomas Soome }
1737c478bd9Sstevel@tonic-gate }
1747c478bd9Sstevel@tonic-gate
175*3bb2c156SToomas Soome if ((argc == 3) && (argv[1][0] == '-') &&
176*3bb2c156SToomas Soome (argv[1][2] == '\0') &&
177*3bb2c156SToomas Soome (argv[2][0] == '-') &&
178*3bb2c156SToomas Soome (argv[2][1] == '-') &&
179*3bb2c156SToomas Soome (argv[2][2] == '\0')) {
180*3bb2c156SToomas Soome switch (argv[1][1]) {
181*3bb2c156SToomas Soome case 'a':
182*3bb2c156SToomas Soome pramodes();
183*3bb2c156SToomas Soome return (0);
184*3bb2c156SToomas Soome case 'g':
185*3bb2c156SToomas Soome prencode();
186*3bb2c156SToomas Soome return (0);
187*3bb2c156SToomas Soome default:
188*3bb2c156SToomas Soome (void) fprintf(stderr, gettext(
189*3bb2c156SToomas Soome "usage: stty [-a| -g]\n"));
190*3bb2c156SToomas Soome (void) fprintf(stderr, gettext(
191*3bb2c156SToomas Soome " stty [modes]\n"));
192*3bb2c156SToomas Soome return (2);
193*3bb2c156SToomas Soome }
1947c478bd9Sstevel@tonic-gate }
1957c478bd9Sstevel@tonic-gate if ((argc >= 3) && (argv[1][0] == '-') && (argv[1][1] == '-') &&
19619d32b9aSRobert Mustacchi (argv[1][2] == '\0')) {
1977c478bd9Sstevel@tonic-gate /* ignore -- */
1987c478bd9Sstevel@tonic-gate --argc;
1997c478bd9Sstevel@tonic-gate ++argv;
2007c478bd9Sstevel@tonic-gate }
2017c478bd9Sstevel@tonic-gate #ifdef EUC
202*3bb2c156SToomas Soome s_arg = sttyparse(argc, argv, term, &ocb, &cb, &termiox, &winsize,
203*3bb2c156SToomas Soome &wp, &kwp, &cswp, &kcswp);
204*3bb2c156SToomas Soome #else
205*3bb2c156SToomas Soome s_arg = sttyparse(argc, argv, term, &ocb, &cb, &termiox, &winsize);
2067c478bd9Sstevel@tonic-gate #endif /* EUC */
207*3bb2c156SToomas Soome if (s_arg != NULL) {
2087c478bd9Sstevel@tonic-gate char *s = s_arg;
2097c478bd9Sstevel@tonic-gate if (*s == '-') s++;
2107c478bd9Sstevel@tonic-gate for (i = 0; not_supported[i]; i++) {
2117c478bd9Sstevel@tonic-gate if (strcmp(not_supported[i], s) == 0) {
2127c478bd9Sstevel@tonic-gate (void) fprintf(stderr,
21319d32b9aSRobert Mustacchi gettext(
21419d32b9aSRobert Mustacchi "mode not supported on this device: %s\n"),
21519d32b9aSRobert Mustacchi s_arg);
2167c478bd9Sstevel@tonic-gate exit(2);
2177c478bd9Sstevel@tonic-gate }
2187c478bd9Sstevel@tonic-gate }
2197c478bd9Sstevel@tonic-gate (void) fprintf(stderr, gettext("unknown mode: %s\n"), s_arg);
2207c478bd9Sstevel@tonic-gate return (2);
2217c478bd9Sstevel@tonic-gate }
2227c478bd9Sstevel@tonic-gate
2237c478bd9Sstevel@tonic-gate if (set_ttymode(0, term, &ocb, &cb, &stio, &termiox, &winsize, &owinsize
2247c478bd9Sstevel@tonic-gate #ifdef EUC
2257c478bd9Sstevel@tonic-gate /* */, &kwp, &kcswp, invalid_ldterm_dat_file
2267c478bd9Sstevel@tonic-gate #endif /* EUC */
2277c478bd9Sstevel@tonic-gate /* */) == -1) {
2287c478bd9Sstevel@tonic-gate perror(STTY);
2297c478bd9Sstevel@tonic-gate return (2);
2307c478bd9Sstevel@tonic-gate }
2317c478bd9Sstevel@tonic-gate return (0);
2327c478bd9Sstevel@tonic-gate }
2337c478bd9Sstevel@tonic-gate
234*3bb2c156SToomas Soome static void
prmodes(void)2357c478bd9Sstevel@tonic-gate prmodes(void) /* print modes, no options, argc is 1 */
2367c478bd9Sstevel@tonic-gate {
2377c478bd9Sstevel@tonic-gate int m;
2387c478bd9Sstevel@tonic-gate
2397c478bd9Sstevel@tonic-gate if (!(term & ASYNC)) {
2407c478bd9Sstevel@tonic-gate m = stio.imode;
2417c478bd9Sstevel@tonic-gate if (m & IUCLC)
2427c478bd9Sstevel@tonic-gate (void) printf("iuclc ");
2437c478bd9Sstevel@tonic-gate else
2447c478bd9Sstevel@tonic-gate (void) printf("-iuclc ");
2457c478bd9Sstevel@tonic-gate m = stio.omode;
2467c478bd9Sstevel@tonic-gate if (m & OLCUC)
2477c478bd9Sstevel@tonic-gate (void) printf("olcuc ");
2487c478bd9Sstevel@tonic-gate else
2497c478bd9Sstevel@tonic-gate (void) printf("-olcuc ");
2507c478bd9Sstevel@tonic-gate if (m & TAB3)
2517c478bd9Sstevel@tonic-gate (void) printf("tab3 ");
2527c478bd9Sstevel@tonic-gate m = stio.lmode;
2537c478bd9Sstevel@tonic-gate if (m & XCASE)
2547c478bd9Sstevel@tonic-gate (void) printf("xcase ");
2557c478bd9Sstevel@tonic-gate else
2567c478bd9Sstevel@tonic-gate (void) printf("-xcase ");
2577c478bd9Sstevel@tonic-gate if (m & STFLUSH)
2587c478bd9Sstevel@tonic-gate (void) printf("stflush ");
2597c478bd9Sstevel@tonic-gate else
2607c478bd9Sstevel@tonic-gate (void) printf("-stflush ");
2617c478bd9Sstevel@tonic-gate if (m & STWRAP)
2627c478bd9Sstevel@tonic-gate (void) printf("stwrap ");
2637c478bd9Sstevel@tonic-gate else
2647c478bd9Sstevel@tonic-gate (void) printf("-stwrap ");
2657c478bd9Sstevel@tonic-gate if (m & STAPPL)
2667c478bd9Sstevel@tonic-gate (void) printf("stappl ");
2677c478bd9Sstevel@tonic-gate else
2687c478bd9Sstevel@tonic-gate (void) printf("-stappl ");
2697c478bd9Sstevel@tonic-gate (void) printf("\n");
2707c478bd9Sstevel@tonic-gate }
2717c478bd9Sstevel@tonic-gate if (term & ASYNC) {
2727c478bd9Sstevel@tonic-gate m = cb.c_cflag;
2737c478bd9Sstevel@tonic-gate if ((term & TERMIOS) && cfgetispeed(&cb) != 0 &&
2747c478bd9Sstevel@tonic-gate cfgetispeed(&cb) != cfgetospeed(&cb)) {
2757c478bd9Sstevel@tonic-gate prspeed("ispeed ", cfgetispeed(&cb));
2767c478bd9Sstevel@tonic-gate prspeed("ospeed ", cfgetospeed(&cb));
2777c478bd9Sstevel@tonic-gate } else
2787c478bd9Sstevel@tonic-gate prspeed("speed ", cfgetospeed(&cb));
2797c478bd9Sstevel@tonic-gate if (m&PARENB) {
2807c478bd9Sstevel@tonic-gate if ((m&PAREXT) && (term & TERMIOS)) {
2817c478bd9Sstevel@tonic-gate if (m&PARODD)
2827c478bd9Sstevel@tonic-gate (void) printf("markp ");
2837c478bd9Sstevel@tonic-gate else
2847c478bd9Sstevel@tonic-gate (void) printf("spacep ");
2857c478bd9Sstevel@tonic-gate } else {
2867c478bd9Sstevel@tonic-gate if (m&PARODD)
2877c478bd9Sstevel@tonic-gate (void) printf("oddp ");
2887c478bd9Sstevel@tonic-gate else
2897c478bd9Sstevel@tonic-gate (void) printf("evenp ");
2907c478bd9Sstevel@tonic-gate }
2917c478bd9Sstevel@tonic-gate } else
2927c478bd9Sstevel@tonic-gate (void) printf("-parity ");
2937c478bd9Sstevel@tonic-gate if (((m&PARENB) && !(m&CS7)) || (!(m&PARENB) && !(m&CS8)))
2947c478bd9Sstevel@tonic-gate (void) printf("cs%c ", '5'+(m&CSIZE)/CS6);
2957c478bd9Sstevel@tonic-gate if (m&CSTOPB)
2967c478bd9Sstevel@tonic-gate (void) printf("cstopb ");
2977c478bd9Sstevel@tonic-gate if (m&HUPCL)
2987c478bd9Sstevel@tonic-gate (void) printf("hupcl ");
2997c478bd9Sstevel@tonic-gate if (!(m&CREAD))
3007c478bd9Sstevel@tonic-gate (void) printf("-cread ");
3017c478bd9Sstevel@tonic-gate if (m&CLOCAL)
3027c478bd9Sstevel@tonic-gate (void) printf("clocal ");
3037c478bd9Sstevel@tonic-gate if (m&LOBLK)
3047c478bd9Sstevel@tonic-gate (void) printf("loblk ");
3057c478bd9Sstevel@tonic-gate (void) printf("\n");
3067c478bd9Sstevel@tonic-gate if (ocb.c_line != 0)
3077c478bd9Sstevel@tonic-gate (void) printf(gettext("line = %d; "), ocb.c_line);
3087c478bd9Sstevel@tonic-gate if (term & WINDOW) {
30919d32b9aSRobert Mustacchi (void) printf(gettext("rows = %d; columns = %d;"),
31019d32b9aSRobert Mustacchi winsize.ws_row, winsize.ws_col);
3117c478bd9Sstevel@tonic-gate (void) printf(gettext(
31219d32b9aSRobert Mustacchi " ypixels = %d; xpixels = %d;\n"),
31319d32b9aSRobert Mustacchi winsize.ws_ypixel, winsize.ws_xpixel);
3147c478bd9Sstevel@tonic-gate }
3157c478bd9Sstevel@tonic-gate if ((cb.c_lflag&ICANON) == 0)
3167c478bd9Sstevel@tonic-gate (void) printf(gettext("min = %d; time = %d;\n"),
3177c478bd9Sstevel@tonic-gate cb.c_cc[VMIN], cb.c_cc[VTIME]);
3187c478bd9Sstevel@tonic-gate if (cb.c_cc[VINTR] != CINTR)
3197c478bd9Sstevel@tonic-gate pit(cb.c_cc[VINTR], "intr", "; ");
3207c478bd9Sstevel@tonic-gate if (cb.c_cc[VQUIT] != CQUIT)
3217c478bd9Sstevel@tonic-gate pit(cb.c_cc[VQUIT], "quit", "; ");
3227c478bd9Sstevel@tonic-gate if (cb.c_cc[VERASE] != CERASE)
3237c478bd9Sstevel@tonic-gate pit(cb.c_cc[VERASE], "erase", "; ");
3249a2c4685SToomas Soome if (term & TERMIOS) {
3259a2c4685SToomas Soome if (cb.c_cc[VERASE2] != CERASE2)
3269a2c4685SToomas Soome pit(cb.c_cc[VERASE], "erase2", "; ");
3279a2c4685SToomas Soome }
3287c478bd9Sstevel@tonic-gate if (cb.c_cc[VKILL] != CKILL)
3297c478bd9Sstevel@tonic-gate pit(cb.c_cc[VKILL], "kill", "; ");
3307c478bd9Sstevel@tonic-gate if (cb.c_cc[VEOF] != CEOF)
3317c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOF], "eof", "; ");
3327c478bd9Sstevel@tonic-gate if (cb.c_cc[VEOL] != CNUL)
3337c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOL], "eol", "; ");
3347c478bd9Sstevel@tonic-gate if (cb.c_cc[VEOL2] != CNUL)
3357c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOL2], "eol2", "; ");
3367c478bd9Sstevel@tonic-gate if (cb.c_cc[VSWTCH] != CSWTCH)
3377c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSWTCH], "swtch", "; ");
3387c478bd9Sstevel@tonic-gate if (term & TERMIOS) {
3397c478bd9Sstevel@tonic-gate if (cb.c_cc[VSTART] != CSTART)
3407c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSTART], "start", "; ");
3417c478bd9Sstevel@tonic-gate if (cb.c_cc[VSTOP] != CSTOP)
3427c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSTOP], "stop", "; ");
3437c478bd9Sstevel@tonic-gate if (cb.c_cc[VSUSP] != CSUSP)
3447c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSUSP], "susp", "; ");
3457c478bd9Sstevel@tonic-gate if (cb.c_cc[VDSUSP] != CDSUSP)
3467c478bd9Sstevel@tonic-gate pit(cb.c_cc[VDSUSP], "dsusp", "; ");
3477c478bd9Sstevel@tonic-gate if (cb.c_cc[VREPRINT] != CRPRNT)
3487c478bd9Sstevel@tonic-gate pit(cb.c_cc[VREPRINT], "rprnt", "; ");
3497c478bd9Sstevel@tonic-gate if (cb.c_cc[VDISCARD] != CFLUSH)
3507c478bd9Sstevel@tonic-gate pit(cb.c_cc[VDISCARD], "flush", "; ");
3517c478bd9Sstevel@tonic-gate if (cb.c_cc[VWERASE] != CWERASE)
3527c478bd9Sstevel@tonic-gate pit(cb.c_cc[VWERASE], "werase", "; ");
3537c478bd9Sstevel@tonic-gate if (cb.c_cc[VLNEXT] != CLNEXT)
3547c478bd9Sstevel@tonic-gate pit(cb.c_cc[VLNEXT], "lnext", "; ");
35519d32b9aSRobert Mustacchi if (cb.c_cc[VSTATUS] != CSTATUS)
35619d32b9aSRobert Mustacchi pit(cb.c_cc[VSTATUS], "status", "; ");
3577c478bd9Sstevel@tonic-gate }
3587c478bd9Sstevel@tonic-gate if (pitt) (void) printf("\n");
3597c478bd9Sstevel@tonic-gate m = cb.c_iflag;
3607c478bd9Sstevel@tonic-gate if (m&IGNBRK)
3617c478bd9Sstevel@tonic-gate (void) printf("ignbrk ");
3627c478bd9Sstevel@tonic-gate else if (m&BRKINT)
3637c478bd9Sstevel@tonic-gate (void) printf("brkint ");
3647c478bd9Sstevel@tonic-gate if (!(m&INPCK))
3657c478bd9Sstevel@tonic-gate (void) printf("-inpck ");
3667c478bd9Sstevel@tonic-gate else if (m&IGNPAR)
3677c478bd9Sstevel@tonic-gate (void) printf("ignpar ");
3687c478bd9Sstevel@tonic-gate if (m&PARMRK)
3697c478bd9Sstevel@tonic-gate (void) printf("parmrk ");
3707c478bd9Sstevel@tonic-gate if (!(m&ISTRIP))
3717c478bd9Sstevel@tonic-gate (void) printf("-istrip ");
3727c478bd9Sstevel@tonic-gate if (m&INLCR)
3737c478bd9Sstevel@tonic-gate (void) printf("inlcr ");
3747c478bd9Sstevel@tonic-gate if (m&IGNCR)
3757c478bd9Sstevel@tonic-gate (void) printf("igncr ");
3767c478bd9Sstevel@tonic-gate if (m&ICRNL)
3777c478bd9Sstevel@tonic-gate (void) printf("icrnl ");
3787c478bd9Sstevel@tonic-gate if (m&IUCLC)
3797c478bd9Sstevel@tonic-gate (void) printf("iuclc ");
3807c478bd9Sstevel@tonic-gate if (!(m&IXON))
3817c478bd9Sstevel@tonic-gate (void) printf("-ixon ");
3827c478bd9Sstevel@tonic-gate else if (!(m&IXANY))
3837c478bd9Sstevel@tonic-gate (void) printf("-ixany ");
3847c478bd9Sstevel@tonic-gate if (m&IXOFF)
3857c478bd9Sstevel@tonic-gate (void) printf("ixoff ");
3867c478bd9Sstevel@tonic-gate if ((term & TERMIOS) && (m&IMAXBEL))
3877c478bd9Sstevel@tonic-gate (void) printf("imaxbel ");
3887c478bd9Sstevel@tonic-gate m = cb.c_oflag;
3897c478bd9Sstevel@tonic-gate if (!(m&OPOST))
3907c478bd9Sstevel@tonic-gate (void) printf("-opost ");
3917c478bd9Sstevel@tonic-gate else {
3927c478bd9Sstevel@tonic-gate if (m&OLCUC)
3937c478bd9Sstevel@tonic-gate (void) printf("olcuc ");
3947c478bd9Sstevel@tonic-gate if (m&ONLCR)
3957c478bd9Sstevel@tonic-gate (void) printf("onlcr ");
3967c478bd9Sstevel@tonic-gate if (m&OCRNL)
3977c478bd9Sstevel@tonic-gate (void) printf("ocrnl ");
3987c478bd9Sstevel@tonic-gate if (m&ONOCR)
3997c478bd9Sstevel@tonic-gate (void) printf("onocr ");
4007c478bd9Sstevel@tonic-gate if (m&ONLRET)
4017c478bd9Sstevel@tonic-gate (void) printf("onlret ");
402*3bb2c156SToomas Soome if (m&OFILL) {
4037c478bd9Sstevel@tonic-gate if (m&OFDEL)
4047c478bd9Sstevel@tonic-gate (void) printf("del-fill ");
4057c478bd9Sstevel@tonic-gate else
4067c478bd9Sstevel@tonic-gate (void) printf("nul-fill ");
407*3bb2c156SToomas Soome }
4087c478bd9Sstevel@tonic-gate delay((m&CRDLY)/CR1, "cr");
4097c478bd9Sstevel@tonic-gate delay((m&NLDLY)/NL1, "nl");
4107c478bd9Sstevel@tonic-gate delay((m&TABDLY)/TAB1, "tab");
4117c478bd9Sstevel@tonic-gate delay((m&BSDLY)/BS1, "bs");
4127c478bd9Sstevel@tonic-gate delay((m&VTDLY)/VT1, "vt");
4137c478bd9Sstevel@tonic-gate delay((m&FFDLY)/FF1, "ff");
4147c478bd9Sstevel@tonic-gate }
4157c478bd9Sstevel@tonic-gate (void) printf("\n");
4167c478bd9Sstevel@tonic-gate m = cb.c_lflag;
4177c478bd9Sstevel@tonic-gate if (!(m&ISIG))
4187c478bd9Sstevel@tonic-gate (void) printf("-isig ");
4197c478bd9Sstevel@tonic-gate if (!(m&ICANON))
4207c478bd9Sstevel@tonic-gate (void) printf("-icanon ");
4217c478bd9Sstevel@tonic-gate if (m&XCASE)
4227c478bd9Sstevel@tonic-gate (void) printf("xcase ");
4237c478bd9Sstevel@tonic-gate (void) printf("-echo "+((m&ECHO) != 0));
4247c478bd9Sstevel@tonic-gate (void) printf("-echoe "+((m&ECHOE) != 0));
4257c478bd9Sstevel@tonic-gate (void) printf("-echok "+((m&ECHOK) != 0));
4267c478bd9Sstevel@tonic-gate if (m&ECHONL)
4277c478bd9Sstevel@tonic-gate (void) printf("echonl ");
4287c478bd9Sstevel@tonic-gate if (m&NOFLSH)
4297c478bd9Sstevel@tonic-gate (void) printf("noflsh ");
4307c478bd9Sstevel@tonic-gate if (m&TOSTOP)
4317c478bd9Sstevel@tonic-gate (void) printf("tostop ");
4327c478bd9Sstevel@tonic-gate if (m&ECHOCTL)
4337c478bd9Sstevel@tonic-gate (void) printf("echoctl ");
4347c478bd9Sstevel@tonic-gate if (m&ECHOPRT)
4357c478bd9Sstevel@tonic-gate (void) printf("echoprt ");
4367c478bd9Sstevel@tonic-gate if (m&ECHOKE)
4377c478bd9Sstevel@tonic-gate (void) printf("echoke ");
4387c478bd9Sstevel@tonic-gate if (m&DEFECHO)
4397c478bd9Sstevel@tonic-gate (void) printf("defecho ");
4407c478bd9Sstevel@tonic-gate if (m&FLUSHO)
4417c478bd9Sstevel@tonic-gate (void) printf("flusho ");
4427c478bd9Sstevel@tonic-gate if (m&PENDIN)
4437c478bd9Sstevel@tonic-gate (void) printf("pendin ");
4447c478bd9Sstevel@tonic-gate if (m&IEXTEN)
4457c478bd9Sstevel@tonic-gate (void) printf("iexten ");
4467c478bd9Sstevel@tonic-gate (void) printf("\n");
4477c478bd9Sstevel@tonic-gate }
4487c478bd9Sstevel@tonic-gate if (term & FLOW) {
4497c478bd9Sstevel@tonic-gate m = termiox.x_hflag;
4507c478bd9Sstevel@tonic-gate if (m & RTSXOFF)
4517c478bd9Sstevel@tonic-gate (void) printf("rtsxoff ");
4527c478bd9Sstevel@tonic-gate if (m & CTSXON)
4537c478bd9Sstevel@tonic-gate (void) printf("ctsxon ");
4547c478bd9Sstevel@tonic-gate if (m & DTRXOFF)
4557c478bd9Sstevel@tonic-gate (void) printf("dtrxoff ");
4567c478bd9Sstevel@tonic-gate if (m & CDXON)
4577c478bd9Sstevel@tonic-gate (void) printf("cdxon ");
4587c478bd9Sstevel@tonic-gate if (m & ISXOFF)
4597c478bd9Sstevel@tonic-gate (void) printf("isxoff ");
4607c478bd9Sstevel@tonic-gate m = termiox.x_cflag;
4617c478bd9Sstevel@tonic-gate switch (m & XMTCLK) {
4627c478bd9Sstevel@tonic-gate case XCIBRG: (void)printf("xcibrg ");
46319d32b9aSRobert Mustacchi break;
4647c478bd9Sstevel@tonic-gate case XCTSET: (void)printf("xctset ");
46519d32b9aSRobert Mustacchi break;
4667c478bd9Sstevel@tonic-gate case XCRSET: (void)printf("xcrset ");
4677c478bd9Sstevel@tonic-gate }
4687c478bd9Sstevel@tonic-gate
4697c478bd9Sstevel@tonic-gate switch (m & RCVCLK) {
4707c478bd9Sstevel@tonic-gate case RCIBRG: (void)printf("rcibrg ");
47119d32b9aSRobert Mustacchi break;
4727c478bd9Sstevel@tonic-gate case RCTSET: (void)printf("rctset ");
47319d32b9aSRobert Mustacchi break;
4747c478bd9Sstevel@tonic-gate case RCRSET: (void)printf("rcrset ");
4757c478bd9Sstevel@tonic-gate }
4767c478bd9Sstevel@tonic-gate
4777c478bd9Sstevel@tonic-gate switch (m & TSETCLK) {
4787c478bd9Sstevel@tonic-gate case TSETCOFF: (void)printf("tsetcoff ");
47919d32b9aSRobert Mustacchi break;
4807c478bd9Sstevel@tonic-gate case TSETCRBRG: (void)printf("tsetcrbrg ");
48119d32b9aSRobert Mustacchi break;
4827c478bd9Sstevel@tonic-gate case TSETCTBRG: (void)printf("tsetctbrg ");
48319d32b9aSRobert Mustacchi break;
4847c478bd9Sstevel@tonic-gate case TSETCTSET: (void)printf("tsetctset ");
48519d32b9aSRobert Mustacchi break;
4867c478bd9Sstevel@tonic-gate case TSETCRSET: (void)printf("tsetcrset ");
4877c478bd9Sstevel@tonic-gate }
4887c478bd9Sstevel@tonic-gate
4897c478bd9Sstevel@tonic-gate switch (m & RSETCLK) {
4907c478bd9Sstevel@tonic-gate case RSETCOFF: (void)printf("rsetcoff ");
49119d32b9aSRobert Mustacchi break;
4927c478bd9Sstevel@tonic-gate case RSETCRBRG: (void)printf("rsetcrbrg ");
49319d32b9aSRobert Mustacchi break;
4947c478bd9Sstevel@tonic-gate case RSETCTBRG: (void)printf("rsetctbrg ");
49519d32b9aSRobert Mustacchi break;
4967c478bd9Sstevel@tonic-gate case RSETCTSET: (void)printf("rsetctset ");
49719d32b9aSRobert Mustacchi break;
4987c478bd9Sstevel@tonic-gate case RSETCRSET: (void)printf("rsetcrset ");
4997c478bd9Sstevel@tonic-gate }
5007c478bd9Sstevel@tonic-gate (void) printf("\n");
5017c478bd9Sstevel@tonic-gate }
5027c478bd9Sstevel@tonic-gate }
5037c478bd9Sstevel@tonic-gate
504*3bb2c156SToomas Soome static void
pramodes(void)5057c478bd9Sstevel@tonic-gate pramodes(void) /* print all modes, -a option */
5067c478bd9Sstevel@tonic-gate {
5077c478bd9Sstevel@tonic-gate int m;
5087c478bd9Sstevel@tonic-gate
5097c478bd9Sstevel@tonic-gate m = cb.c_cflag;
5107c478bd9Sstevel@tonic-gate if (term & ASYNC) {
5117c478bd9Sstevel@tonic-gate if ((term & TERMIOS) && cfgetispeed(&cb) != 0 &&
5127c478bd9Sstevel@tonic-gate cfgetispeed(&cb) != cfgetospeed(&cb)) {
5137c478bd9Sstevel@tonic-gate prspeed("ispeed ", cfgetispeed(&cb));
5147c478bd9Sstevel@tonic-gate prspeed("ospeed ", cfgetospeed(&cb));
5157c478bd9Sstevel@tonic-gate } else
5167c478bd9Sstevel@tonic-gate prspeed("speed ", cfgetospeed(&cb));
5177c478bd9Sstevel@tonic-gate if (!(term & TERMIOS))
5187c478bd9Sstevel@tonic-gate (void) printf(gettext("line = %d; "), ocb.c_line);
5197c478bd9Sstevel@tonic-gate (void) printf("\n");
5207c478bd9Sstevel@tonic-gate if (term & WINDOW) {
5217c478bd9Sstevel@tonic-gate (void) printf(gettext("rows = %d; columns = %d;"),
52219d32b9aSRobert Mustacchi winsize.ws_row, winsize.ws_col);
5237c478bd9Sstevel@tonic-gate (void) printf(gettext(
52419d32b9aSRobert Mustacchi " ypixels = %d; xpixels = %d;\n"),
52519d32b9aSRobert Mustacchi winsize.ws_ypixel, winsize.ws_xpixel);
5267c478bd9Sstevel@tonic-gate }
5277c478bd9Sstevel@tonic-gate #ifdef EUC
5287c478bd9Sstevel@tonic-gate if ((term & CSIW) && kcswp.locale_name[0]) {
5297c478bd9Sstevel@tonic-gate (void) printf("csdata %s\n", kcswp.locale_name);
5307c478bd9Sstevel@tonic-gate } else {
5317c478bd9Sstevel@tonic-gate (void) printf("csdata ?\n");
5327c478bd9Sstevel@tonic-gate }
5337c478bd9Sstevel@tonic-gate /*
5347c478bd9Sstevel@tonic-gate * If kwp.eucw[0] is zero, it means the current codeset type
5357c478bd9Sstevel@tonic-gate * in the ldterm is not EUC.
5367c478bd9Sstevel@tonic-gate */
5377c478bd9Sstevel@tonic-gate if ((term & EUCW) && kwp.eucw[0]) {
5387c478bd9Sstevel@tonic-gate (void) printf("eucw %d:%d:%d:%d, ", kwp.eucw[0],
53919d32b9aSRobert Mustacchi kwp.eucw[1], kwp.eucw[2], kwp.eucw[3]);
5407c478bd9Sstevel@tonic-gate (void) printf("scrw %d:%d:%d:%d\n", kwp.scrw[0],
54119d32b9aSRobert Mustacchi kwp.scrw[1], kwp.scrw[2], kwp.scrw[3]);
5427c478bd9Sstevel@tonic-gate } else
5437c478bd9Sstevel@tonic-gate (void) printf("eucw ?, scrw ?\n");
5447c478bd9Sstevel@tonic-gate #endif /* EUC */
5457c478bd9Sstevel@tonic-gate if ((cb.c_lflag&ICANON) == 0)
5467c478bd9Sstevel@tonic-gate (void) printf(gettext("min = %d; time = %d;\n"),
54719d32b9aSRobert Mustacchi cb.c_cc[VMIN], cb.c_cc[VTIME]);
5487c478bd9Sstevel@tonic-gate pit(cb.c_cc[VINTR], "intr", "; ");
5497c478bd9Sstevel@tonic-gate pit(cb.c_cc[VQUIT], "quit", "; ");
5507c478bd9Sstevel@tonic-gate pit(cb.c_cc[VERASE], "erase", "; ");
5519a2c4685SToomas Soome if (term & TERMIOS)
5529a2c4685SToomas Soome pit(cb.c_cc[VERASE2], "erase2", "; ");
5537c478bd9Sstevel@tonic-gate pit(cb.c_cc[VKILL], "kill", ";\n");
5547c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOF], "eof", "; ");
5557c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOL], "eol", "; ");
5567c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOL2], "eol2", "; ");
5577c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSWTCH], "swtch", ";\n");
5587c478bd9Sstevel@tonic-gate if (term & TERMIOS) {
5597c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSTART], "start", "; ");
5607c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSTOP], "stop", "; ");
5617c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSUSP], "susp", "; ");
5627c478bd9Sstevel@tonic-gate pit(cb.c_cc[VDSUSP], "dsusp", ";\n");
5637c478bd9Sstevel@tonic-gate pit(cb.c_cc[VREPRINT], "rprnt", "; ");
5647c478bd9Sstevel@tonic-gate pit(cb.c_cc[VDISCARD], "flush", "; ");
5657c478bd9Sstevel@tonic-gate pit(cb.c_cc[VWERASE], "werase", "; ");
5667c478bd9Sstevel@tonic-gate pit(cb.c_cc[VLNEXT], "lnext", ";\n");
56719d32b9aSRobert Mustacchi pit(cb.c_cc[VSTATUS], "status", ";\n");
5687c478bd9Sstevel@tonic-gate }
5697c478bd9Sstevel@tonic-gate } else
5707c478bd9Sstevel@tonic-gate pit((unsigned)stio.tab, "ctab", "\n");
5717c478bd9Sstevel@tonic-gate m = cb.c_cflag;
5727c478bd9Sstevel@tonic-gate (void) printf("-parenb "+((m&PARENB) != 0));
5737c478bd9Sstevel@tonic-gate (void) printf("-parodd "+((m&PARODD) != 0));
5747c478bd9Sstevel@tonic-gate (void) printf("cs%c ", '5'+(m&CSIZE)/CS6);
5757c478bd9Sstevel@tonic-gate (void) printf("-cstopb "+((m&CSTOPB) != 0));
5767c478bd9Sstevel@tonic-gate (void) printf("-hupcl "+((m&HUPCL) != 0));
5777c478bd9Sstevel@tonic-gate (void) printf("-cread "+((m&CREAD) != 0));
5787c478bd9Sstevel@tonic-gate (void) printf("-clocal "+((m&CLOCAL) != 0));
5797c478bd9Sstevel@tonic-gate
5807c478bd9Sstevel@tonic-gate (void) printf("-loblk "+((m&LOBLK) != 0));
5817c478bd9Sstevel@tonic-gate (void) printf("-crtscts "+((m&CRTSCTS) != 0));
5827c478bd9Sstevel@tonic-gate (void) printf("-crtsxoff "+((m&CRTSXOFF) != 0));
5837c478bd9Sstevel@tonic-gate if (term & TERMIOS)
5847c478bd9Sstevel@tonic-gate (void) printf("-parext "+((m&PAREXT) != 0));
5857c478bd9Sstevel@tonic-gate
5867c478bd9Sstevel@tonic-gate (void) printf("\n");
5877c478bd9Sstevel@tonic-gate m = cb.c_iflag;
5887c478bd9Sstevel@tonic-gate (void) printf("-ignbrk "+((m&IGNBRK) != 0));
5897c478bd9Sstevel@tonic-gate (void) printf("-brkint "+((m&BRKINT) != 0));
5907c478bd9Sstevel@tonic-gate (void) printf("-ignpar "+((m&IGNPAR) != 0));
5917c478bd9Sstevel@tonic-gate (void) printf("-parmrk "+((m&PARMRK) != 0));
5927c478bd9Sstevel@tonic-gate (void) printf("-inpck "+((m&INPCK) != 0));
5937c478bd9Sstevel@tonic-gate (void) printf("-istrip "+((m&ISTRIP) != 0));
5947c478bd9Sstevel@tonic-gate (void) printf("-inlcr "+((m&INLCR) != 0));
5957c478bd9Sstevel@tonic-gate (void) printf("-igncr "+((m&IGNCR) != 0));
5967c478bd9Sstevel@tonic-gate (void) printf("-icrnl "+((m&ICRNL) != 0));
5977c478bd9Sstevel@tonic-gate (void) printf("-iuclc "+((m&IUCLC) != 0));
5987c478bd9Sstevel@tonic-gate (void) printf("\n");
5997c478bd9Sstevel@tonic-gate (void) printf("-ixon "+((m&IXON) != 0));
6007c478bd9Sstevel@tonic-gate (void) printf("-ixany "+((m&IXANY) != 0));
6017c478bd9Sstevel@tonic-gate (void) printf("-ixoff "+((m&IXOFF) != 0));
6027c478bd9Sstevel@tonic-gate if (term & TERMIOS)
6037c478bd9Sstevel@tonic-gate (void) printf("-imaxbel "+((m&IMAXBEL) != 0));
6047c478bd9Sstevel@tonic-gate (void) printf("\n");
6057c478bd9Sstevel@tonic-gate m = cb.c_lflag;
6067c478bd9Sstevel@tonic-gate (void) printf("-isig "+((m&ISIG) != 0));
6077c478bd9Sstevel@tonic-gate (void) printf("-icanon "+((m&ICANON) != 0));
6087c478bd9Sstevel@tonic-gate (void) printf("-xcase "+((m&XCASE) != 0));
6097c478bd9Sstevel@tonic-gate (void) printf("-echo "+((m&ECHO) != 0));
6107c478bd9Sstevel@tonic-gate (void) printf("-echoe "+((m&ECHOE) != 0));
6117c478bd9Sstevel@tonic-gate (void) printf("-echok "+((m&ECHOK) != 0));
6127c478bd9Sstevel@tonic-gate (void) printf("-echonl "+((m&ECHONL) != 0));
6137c478bd9Sstevel@tonic-gate (void) printf("-noflsh "+((m&NOFLSH) != 0));
6147c478bd9Sstevel@tonic-gate if (term & TERMIOS) {
6157c478bd9Sstevel@tonic-gate (void) printf("\n");
6167c478bd9Sstevel@tonic-gate (void) printf("-tostop "+((m&TOSTOP) != 0));
6177c478bd9Sstevel@tonic-gate (void) printf("-echoctl "+((m&ECHOCTL) != 0));
6187c478bd9Sstevel@tonic-gate (void) printf("-echoprt "+((m&ECHOPRT) != 0));
6197c478bd9Sstevel@tonic-gate (void) printf("-echoke "+((m&ECHOKE) != 0));
6207c478bd9Sstevel@tonic-gate (void) printf("-defecho "+((m&DEFECHO) != 0));
6217c478bd9Sstevel@tonic-gate (void) printf("-flusho "+((m&FLUSHO) != 0));
6227c478bd9Sstevel@tonic-gate (void) printf("-pendin "+((m&PENDIN) != 0));
6237c478bd9Sstevel@tonic-gate (void) printf("-iexten "+((m&IEXTEN) != 0));
6247c478bd9Sstevel@tonic-gate }
6257c478bd9Sstevel@tonic-gate if (!(term & ASYNC)) {
6267c478bd9Sstevel@tonic-gate (void) printf("-stflush "+((m&STFLUSH) != 0));
6277c478bd9Sstevel@tonic-gate (void) printf("-stwrap "+((m&STWRAP) != 0));
6287c478bd9Sstevel@tonic-gate (void) printf("-stappl "+((m&STAPPL) != 0));
6297c478bd9Sstevel@tonic-gate }
6307c478bd9Sstevel@tonic-gate (void) printf("\n");
6317c478bd9Sstevel@tonic-gate m = cb.c_oflag;
6327c478bd9Sstevel@tonic-gate (void) printf("-opost "+((m&OPOST) != 0));
6337c478bd9Sstevel@tonic-gate (void) printf("-olcuc "+((m&OLCUC) != 0));
6347c478bd9Sstevel@tonic-gate (void) printf("-onlcr "+((m&ONLCR) != 0));
6357c478bd9Sstevel@tonic-gate (void) printf("-ocrnl "+((m&OCRNL) != 0));
6367c478bd9Sstevel@tonic-gate (void) printf("-onocr "+((m&ONOCR) != 0));
6377c478bd9Sstevel@tonic-gate (void) printf("-onlret "+((m&ONLRET) != 0));
6387c478bd9Sstevel@tonic-gate (void) printf("-ofill "+((m&OFILL) != 0));
6397c478bd9Sstevel@tonic-gate (void) printf("-ofdel "+((m&OFDEL) != 0));
6407c478bd9Sstevel@tonic-gate delay((m&CRDLY)/CR1, "cr");
6417c478bd9Sstevel@tonic-gate delay((m&NLDLY)/NL1, "nl");
6427c478bd9Sstevel@tonic-gate delay((m&TABDLY)/TAB1, "tab");
6437c478bd9Sstevel@tonic-gate delay((m&BSDLY)/BS1, "bs");
6447c478bd9Sstevel@tonic-gate delay((m&VTDLY)/VT1, "vt");
6457c478bd9Sstevel@tonic-gate delay((m&FFDLY)/FF1, "ff");
6467c478bd9Sstevel@tonic-gate (void) printf("\n");
6477c478bd9Sstevel@tonic-gate if (term & FLOW) {
6487c478bd9Sstevel@tonic-gate m = termiox.x_hflag;
6497c478bd9Sstevel@tonic-gate (void) printf("-rtsxoff "+((m&RTSXOFF) != 0));
6507c478bd9Sstevel@tonic-gate (void) printf("-ctsxon "+((m&CTSXON) != 0));
6517c478bd9Sstevel@tonic-gate (void) printf("-dtrxoff "+((m&DTRXOFF) != 0));
6527c478bd9Sstevel@tonic-gate (void) printf("-cdxon "+((m&CDXON) != 0));
6537c478bd9Sstevel@tonic-gate (void) printf("-isxoff "+((m&ISXOFF) != 0));
6547c478bd9Sstevel@tonic-gate m = termiox.x_cflag;
6557c478bd9Sstevel@tonic-gate switch (m & XMTCLK) {
6567c478bd9Sstevel@tonic-gate case XCIBRG: (void)printf("xcibrg ");
65719d32b9aSRobert Mustacchi break;
6587c478bd9Sstevel@tonic-gate case XCTSET: (void)printf("xctset ");
65919d32b9aSRobert Mustacchi break;
6607c478bd9Sstevel@tonic-gate case XCRSET: (void)printf("xcrset ");
6617c478bd9Sstevel@tonic-gate }
6627c478bd9Sstevel@tonic-gate
6637c478bd9Sstevel@tonic-gate switch (m & RCVCLK) {
6647c478bd9Sstevel@tonic-gate case RCIBRG: (void)printf("rcibrg ");
66519d32b9aSRobert Mustacchi break;
6667c478bd9Sstevel@tonic-gate case RCTSET: (void)printf("rctset ");
66719d32b9aSRobert Mustacchi break;
6687c478bd9Sstevel@tonic-gate case RCRSET: (void)printf("rcrset ");
6697c478bd9Sstevel@tonic-gate }
6707c478bd9Sstevel@tonic-gate
6717c478bd9Sstevel@tonic-gate switch (m & TSETCLK) {
6727c478bd9Sstevel@tonic-gate case TSETCOFF: (void)printf("tsetcoff ");
67319d32b9aSRobert Mustacchi break;
6747c478bd9Sstevel@tonic-gate case TSETCRBRG: (void)printf("tsetcrbrg ");
67519d32b9aSRobert Mustacchi break;
6767c478bd9Sstevel@tonic-gate case TSETCTBRG: (void)printf("tsetctbrg ");
67719d32b9aSRobert Mustacchi break;
6787c478bd9Sstevel@tonic-gate case TSETCTSET: (void)printf("tsetctset ");
67919d32b9aSRobert Mustacchi break;
6807c478bd9Sstevel@tonic-gate case TSETCRSET: (void)printf("tsetcrset ");
6817c478bd9Sstevel@tonic-gate }
6827c478bd9Sstevel@tonic-gate
6837c478bd9Sstevel@tonic-gate switch (m & RSETCLK) {
6847c478bd9Sstevel@tonic-gate case RSETCOFF: (void)printf("rsetcoff ");
68519d32b9aSRobert Mustacchi break;
6867c478bd9Sstevel@tonic-gate case RSETCRBRG: (void)printf("rsetcrbrg ");
68719d32b9aSRobert Mustacchi break;
6887c478bd9Sstevel@tonic-gate case RSETCTBRG: (void)printf("rsetctbrg ");
68919d32b9aSRobert Mustacchi break;
6907c478bd9Sstevel@tonic-gate case RSETCTSET: (void)printf("rsetctset ");
69119d32b9aSRobert Mustacchi break;
6927c478bd9Sstevel@tonic-gate case RSETCRSET: (void)printf("rsetcrset ");
6937c478bd9Sstevel@tonic-gate }
6947c478bd9Sstevel@tonic-gate (void) printf("\n");
6957c478bd9Sstevel@tonic-gate }
6967c478bd9Sstevel@tonic-gate }
6977c478bd9Sstevel@tonic-gate
6987c478bd9Sstevel@tonic-gate /* print function for prmodes() and pramodes() */
6997c478bd9Sstevel@tonic-gate void
pit(unsigned char what,char * itsname,char * sep)7007c478bd9Sstevel@tonic-gate pit(unsigned char what, char *itsname, char *sep)
7017c478bd9Sstevel@tonic-gate {
7027c478bd9Sstevel@tonic-gate
7037c478bd9Sstevel@tonic-gate pitt++;
7047c478bd9Sstevel@tonic-gate (void) printf("%s", itsname);
705*3bb2c156SToomas Soome if (((term & TERMIOS) && what == _POSIX_VDISABLE) ||
706*3bb2c156SToomas Soome (!(term & TERMIOS) && what == 0200)) {
7077c478bd9Sstevel@tonic-gate (void) printf(" = <undef>%s", sep);
7087c478bd9Sstevel@tonic-gate return;
7097c478bd9Sstevel@tonic-gate }
7107c478bd9Sstevel@tonic-gate (void) printf(" = ");
7117c478bd9Sstevel@tonic-gate if (what & 0200 && !isprint(what)) {
7127c478bd9Sstevel@tonic-gate (void) printf("-");
7137c478bd9Sstevel@tonic-gate what &= ~ 0200;
7147c478bd9Sstevel@tonic-gate }
7157c478bd9Sstevel@tonic-gate if (what == 0177) {
7167c478bd9Sstevel@tonic-gate (void) printf("^?%s", sep);
7177c478bd9Sstevel@tonic-gate return;
7187c478bd9Sstevel@tonic-gate } else if (what < ' ') {
7197c478bd9Sstevel@tonic-gate (void) printf("^");
7207c478bd9Sstevel@tonic-gate what += '`';
7217c478bd9Sstevel@tonic-gate if (what > 'z')
7227c478bd9Sstevel@tonic-gate what -= 'a' -'A';
7237c478bd9Sstevel@tonic-gate }
7247c478bd9Sstevel@tonic-gate (void) printf("%c%s", what, sep);
7257c478bd9Sstevel@tonic-gate }
7267c478bd9Sstevel@tonic-gate
7277c478bd9Sstevel@tonic-gate void
delay(int m,char * s)7287c478bd9Sstevel@tonic-gate delay(int m, char *s)
7297c478bd9Sstevel@tonic-gate {
7307c478bd9Sstevel@tonic-gate if (m)
7317c478bd9Sstevel@tonic-gate (void) printf("%s%d ", s, m);
7327c478bd9Sstevel@tonic-gate }
7337c478bd9Sstevel@tonic-gate
7347c478bd9Sstevel@tonic-gate void
prspeed(char * c,int scode)7357c478bd9Sstevel@tonic-gate prspeed(char *c, int scode)
7367c478bd9Sstevel@tonic-gate {
7377c478bd9Sstevel@tonic-gate int sval = -1;
7387c478bd9Sstevel@tonic-gate int i;
7397c478bd9Sstevel@tonic-gate
7407c478bd9Sstevel@tonic-gate for (i = 0; speeds[i].string; i++) {
7417c478bd9Sstevel@tonic-gate if (speeds[i].code == scode) {
7427c478bd9Sstevel@tonic-gate sval = speeds[i].value;
7437c478bd9Sstevel@tonic-gate break;
7447c478bd9Sstevel@tonic-gate }
7457c478bd9Sstevel@tonic-gate }
7467c478bd9Sstevel@tonic-gate
7477c478bd9Sstevel@tonic-gate (void) printf("%s%d baud; ", c, sval);
7487c478bd9Sstevel@tonic-gate }
7497c478bd9Sstevel@tonic-gate
7507c478bd9Sstevel@tonic-gate /* print current settings for use with */
751*3bb2c156SToomas Soome static void
prencode(void)7527c478bd9Sstevel@tonic-gate prencode(void) /* another stty cmd, used for -g option */
7537c478bd9Sstevel@tonic-gate {
7547c478bd9Sstevel@tonic-gate int i, last;
7557c478bd9Sstevel@tonic-gate
7567c478bd9Sstevel@tonic-gate /*
7577c478bd9Sstevel@tonic-gate * Although there are only 16 control chars defined as of April 1995,
7587c478bd9Sstevel@tonic-gate * prencode() and encode() will not have to be changed if up to MAX_CC
7597c478bd9Sstevel@tonic-gate * control chars are defined in the future. A maximum of MAX_CC rather
7607c478bd9Sstevel@tonic-gate * than NCCS control chars are printed because the last control slot
7617c478bd9Sstevel@tonic-gate * is unused. "stty -g" prints out a total of NUM_FIELDS fields
7627c478bd9Sstevel@tonic-gate * (NUM_MODES modes + MAX_CC control chars). First print the input,
7637c478bd9Sstevel@tonic-gate * output, control, and line discipline modes.
7647c478bd9Sstevel@tonic-gate */
7657c478bd9Sstevel@tonic-gate (void) printf("%x:%x:%x:%x", cb.c_iflag, cb.c_oflag, cb.c_cflag,
76619d32b9aSRobert Mustacchi cb.c_lflag);
7677c478bd9Sstevel@tonic-gate
7687c478bd9Sstevel@tonic-gate /* Print the control character fields. */
7697c478bd9Sstevel@tonic-gate if (term & TERMIOS)
7707c478bd9Sstevel@tonic-gate last = MAX_CC;
7717c478bd9Sstevel@tonic-gate else
7727c478bd9Sstevel@tonic-gate last = NCC;
7737c478bd9Sstevel@tonic-gate #ifdef EUC
7747c478bd9Sstevel@tonic-gate if (term & CSIW) {
7757c478bd9Sstevel@tonic-gate for (i = 0; i < MAX_CC; i++)
7767c478bd9Sstevel@tonic-gate (void) printf(":%x", (i >= last) ? 0 : cb.c_cc[i]);
7777c478bd9Sstevel@tonic-gate /*
7787c478bd9Sstevel@tonic-gate * Print out ldterm_cs_data_user_t data fields for
7797c478bd9Sstevel@tonic-gate * PSARC/1999/140 TCR2. This change introduces additional
7807c478bd9Sstevel@tonic-gate * 44 fields that come from the ldterm_cs_data_user_t data
7817c478bd9Sstevel@tonic-gate * structure.
7827c478bd9Sstevel@tonic-gate */
7837c478bd9Sstevel@tonic-gate (void) printf(":%x:%x:%x:", kcswp.version, kcswp.codeset_type,
78419d32b9aSRobert Mustacchi kcswp.csinfo_num);
7857c478bd9Sstevel@tonic-gate if (*kcswp.locale_name == '\0') {
7867c478bd9Sstevel@tonic-gate (void) printf("00");
7877c478bd9Sstevel@tonic-gate } else {
788*3bb2c156SToomas Soome for (i = 0; i < MAXNAMELEN &&
789*3bb2c156SToomas Soome kcswp.locale_name[i] != '\0'; i++)
7907c478bd9Sstevel@tonic-gate (void) printf("%02x", kcswp.locale_name[i]);
7917c478bd9Sstevel@tonic-gate }
7927c478bd9Sstevel@tonic-gate for (i = 0; i < LDTERM_CS_MAX_CODESETS; i++)
7937c478bd9Sstevel@tonic-gate (void) printf(":%x:%x:%x:%x",
79419d32b9aSRobert Mustacchi kcswp.eucpc_data[i].byte_length,
79519d32b9aSRobert Mustacchi kcswp.eucpc_data[i].screen_width,
79619d32b9aSRobert Mustacchi kcswp.eucpc_data[i].msb_start,
79719d32b9aSRobert Mustacchi kcswp.eucpc_data[i].msb_end);
7987c478bd9Sstevel@tonic-gate } else {
7997c478bd9Sstevel@tonic-gate #endif /* EUC */
8007c478bd9Sstevel@tonic-gate for (i = 0; i < last; i++)
8017c478bd9Sstevel@tonic-gate (void) printf(":%x", cb.c_cc[i]);
8027c478bd9Sstevel@tonic-gate #ifdef EUC
8037c478bd9Sstevel@tonic-gate }
8047c478bd9Sstevel@tonic-gate #endif /* EUC */
8057c478bd9Sstevel@tonic-gate (void) printf("\n");
8067c478bd9Sstevel@tonic-gate }
807