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 5*de81e71eSTim Marsland * Common Development and Distribution License (the "License"). 6*de81e71eSTim Marsland * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*de81e71eSTim Marsland 227c478bd9Sstevel@tonic-gate /* 23*de81e71eSTim Marsland * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 287c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <stdio.h> 317c478bd9Sstevel@tonic-gate #include <ctype.h> 327c478bd9Sstevel@tonic-gate #include <sys/types.h> 337c478bd9Sstevel@tonic-gate #include <termio.h> 347c478bd9Sstevel@tonic-gate #include <sys/stermio.h> 357c478bd9Sstevel@tonic-gate #include <sys/termiox.h> 367c478bd9Sstevel@tonic-gate #include "stty.h" 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate extern char *getenv(); 397c478bd9Sstevel@tonic-gate extern void exit(); 407c478bd9Sstevel@tonic-gate extern void perror(); 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate static char *STTY = "stty: "; 437c478bd9Sstevel@tonic-gate static char *USAGE = "usage: stty [-agh] [modes]\n"; 447c478bd9Sstevel@tonic-gate static int pitt = 0; 457c478bd9Sstevel@tonic-gate static struct termios cb; 467c478bd9Sstevel@tonic-gate static struct termio ocb; /* for non-streams devices */ 477c478bd9Sstevel@tonic-gate static struct stio stio; 487c478bd9Sstevel@tonic-gate static struct termiox termiox; 497c478bd9Sstevel@tonic-gate static struct winsize winsize, owinsize; 507c478bd9Sstevel@tonic-gate static int term; 517c478bd9Sstevel@tonic-gate 52cc6c5292Schin void prmodes(int); 53cc6c5292Schin void pramodes(int); 54cc6c5292Schin void prachars(void); 55cc6c5292Schin void pcol(int, int); 56cc6c5292Schin void pit(unsigned char, char *, char *); 57cc6c5292Schin void delay(int, char *s); 58cc6c5292Schin void prspeed(char *, int); 59cc6c5292Schin void prencode(void); 60cc6c5292Schin 617c478bd9Sstevel@tonic-gate #define ioctl_desc 1 627c478bd9Sstevel@tonic-gate #define output stderr 637c478bd9Sstevel@tonic-gate 64cc6c5292Schin int 65cc6c5292Schin main(int argc, char *argv[]) 667c478bd9Sstevel@tonic-gate { 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate int i; 697c478bd9Sstevel@tonic-gate char *s_arg, *sttyparse(); /* s_arg: ptr to mode to be set */ 707c478bd9Sstevel@tonic-gate extern const struct speeds speeds[]; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate if (argc == 2) { 737c478bd9Sstevel@tonic-gate /* 747c478bd9Sstevel@tonic-gate * "stty size", "stty speed" and "stty -g" are intended for 757c478bd9Sstevel@tonic-gate * use within backquotes; thus, they do the "fetch" "ioctl" 767c478bd9Sstevel@tonic-gate * from "/dev/tty" and always print their result on the 777c478bd9Sstevel@tonic-gate * standard output. 787c478bd9Sstevel@tonic-gate * Since their standard output is likely to be a pipe, they 797c478bd9Sstevel@tonic-gate * should not try to read the modes from the standard output. 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate if (strcmp(argv[1], "size") == 0) { 827c478bd9Sstevel@tonic-gate if ((i = open("/dev/tty", 0)) < 0) { 837c478bd9Sstevel@tonic-gate perror("stty: Cannot open /dev/tty"); 847c478bd9Sstevel@tonic-gate exit(2); 857c478bd9Sstevel@tonic-gate } 867c478bd9Sstevel@tonic-gate if (ioctl(i, TIOCGWINSZ, &winsize) < 0) { 877c478bd9Sstevel@tonic-gate perror("stty: TIOCGWINSZ"); 887c478bd9Sstevel@tonic-gate exit(2); 897c478bd9Sstevel@tonic-gate } 90*de81e71eSTim Marsland (void) printf("%d %d\n", 91*de81e71eSTim Marsland winsize.ws_row, winsize.ws_col); 927c478bd9Sstevel@tonic-gate exit(0); 93*de81e71eSTim Marsland } else if (strcmp(argv[1], "speed") == 0) { 947c478bd9Sstevel@tonic-gate if ((i = open("/dev/tty", 0)) < 0) { 957c478bd9Sstevel@tonic-gate perror("stty: Cannot open /dev/tty"); 967c478bd9Sstevel@tonic-gate exit(2); 977c478bd9Sstevel@tonic-gate } 98*de81e71eSTim Marsland if ((term = get_ttymode(i, 99*de81e71eSTim Marsland &ocb, &cb, &stio, &termiox, &winsize)) < 0) { 1007c478bd9Sstevel@tonic-gate perror(STTY); 1017c478bd9Sstevel@tonic-gate exit(2); 1027c478bd9Sstevel@tonic-gate } 1037c478bd9Sstevel@tonic-gate if (term & TERMIOS) { 1047c478bd9Sstevel@tonic-gate for (i = 0; speeds[i].string; i++) 105*de81e71eSTim Marsland if (cfgetospeed(&cb) == 106*de81e71eSTim Marsland speeds[i].speed) { 107*de81e71eSTim Marsland (void) printf("%s\n", 108*de81e71eSTim Marsland speeds[i].string); 1097c478bd9Sstevel@tonic-gate exit(0); 1107c478bd9Sstevel@tonic-gate } 1117c478bd9Sstevel@tonic-gate } else { 1127c478bd9Sstevel@tonic-gate for (i = 0; speeds[i].string; i++) 113*de81e71eSTim Marsland if ((cb.c_cflag&CBAUD) == 114*de81e71eSTim Marsland speeds[i].speed) { 115*de81e71eSTim Marsland (void) printf("%s\n", 116*de81e71eSTim Marsland speeds[i].string); 1177c478bd9Sstevel@tonic-gate exit(0); 1187c478bd9Sstevel@tonic-gate } 1197c478bd9Sstevel@tonic-gate } 1207c478bd9Sstevel@tonic-gate (void) printf("unknown\n"); 1217c478bd9Sstevel@tonic-gate exit(1); 122*de81e71eSTim Marsland } else if (strcmp(argv[1], "-g") == 0) { 1237c478bd9Sstevel@tonic-gate if ((i = open("/dev/tty", 0)) < 0) { 1247c478bd9Sstevel@tonic-gate perror("stty: Cannot open /dev/tty"); 1257c478bd9Sstevel@tonic-gate exit(2); 1267c478bd9Sstevel@tonic-gate } 127*de81e71eSTim Marsland if ((term = get_ttymode(i, 128*de81e71eSTim Marsland &ocb, &cb, &stio, &termiox, &winsize)) < 0) { 1297c478bd9Sstevel@tonic-gate perror(STTY); 1307c478bd9Sstevel@tonic-gate exit(2); 1317c478bd9Sstevel@tonic-gate } 1327c478bd9Sstevel@tonic-gate prencode(); 1337c478bd9Sstevel@tonic-gate exit(0); 1347c478bd9Sstevel@tonic-gate } 1357c478bd9Sstevel@tonic-gate } 1367c478bd9Sstevel@tonic-gate 137*de81e71eSTim Marsland if ((term = get_ttymode(ioctl_desc, 138*de81e71eSTim Marsland &ocb, &cb, &stio, &termiox, &winsize)) < 0) { 1397c478bd9Sstevel@tonic-gate perror(STTY); 1407c478bd9Sstevel@tonic-gate exit(2); 1417c478bd9Sstevel@tonic-gate } 1427c478bd9Sstevel@tonic-gate owinsize = winsize; 1437c478bd9Sstevel@tonic-gate if (argc == 1) { 1447c478bd9Sstevel@tonic-gate prmodes(0); 1457c478bd9Sstevel@tonic-gate exit(0); 1467c478bd9Sstevel@tonic-gate } 1477c478bd9Sstevel@tonic-gate if ((argc == 2) && strcmp(argv[1], "all") == 0) { 1487c478bd9Sstevel@tonic-gate prmodes(1); 1497c478bd9Sstevel@tonic-gate exit(0); 1507c478bd9Sstevel@tonic-gate } 1517c478bd9Sstevel@tonic-gate if ((argc == 2) && strcmp(argv[1], "everything") == 0) { 1527c478bd9Sstevel@tonic-gate pramodes(1); 1537c478bd9Sstevel@tonic-gate exit(0); 1547c478bd9Sstevel@tonic-gate } 1557c478bd9Sstevel@tonic-gate if ((argc == 2) && (argv[1][0] == '-') && (argv[1][2] == '\0')) 1567c478bd9Sstevel@tonic-gate switch (argv[1][1]) { 1577c478bd9Sstevel@tonic-gate case 'a': 1587c478bd9Sstevel@tonic-gate pramodes(0); 1597c478bd9Sstevel@tonic-gate exit(0); 1607c478bd9Sstevel@tonic-gate case 'h': 1617c478bd9Sstevel@tonic-gate pramodes(1); 1627c478bd9Sstevel@tonic-gate exit(0); 1637c478bd9Sstevel@tonic-gate default: 1647c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s", USAGE); 1657c478bd9Sstevel@tonic-gate exit(2); 1667c478bd9Sstevel@tonic-gate } 167*de81e71eSTim Marsland if (s_arg = sttyparse(argc, argv, 168*de81e71eSTim Marsland term, &ocb, &cb, &termiox, &winsize)) { 1697c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "unknown mode: %s\n", s_arg); 1707c478bd9Sstevel@tonic-gate exit(2); 1717c478bd9Sstevel@tonic-gate } 1727c478bd9Sstevel@tonic-gate 173*de81e71eSTim Marsland if (set_ttymode(ioctl_desc, 174*de81e71eSTim Marsland term, &ocb, &cb, &stio, &termiox, &winsize, &owinsize) == -1) { 1757c478bd9Sstevel@tonic-gate perror(STTY); 1767c478bd9Sstevel@tonic-gate exit(2); 1777c478bd9Sstevel@tonic-gate } 178cc6c5292Schin return (0); /*NOTREACHED*/ 1797c478bd9Sstevel@tonic-gate } 1807c478bd9Sstevel@tonic-gate 181cc6c5292Schin void 182cc6c5292Schin prmodes(int moremodes) 183cc6c5292Schin /* print modes, no options, argc is 1 */ 1847c478bd9Sstevel@tonic-gate { 185cc6c5292Schin int m; 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate if (!(term & ASYNC)) { 1887c478bd9Sstevel@tonic-gate m = stio.imode; 189*de81e71eSTim Marsland if (m & IUCLC) 190*de81e71eSTim Marsland (void) fprintf(output, "iuclc "); 191*de81e71eSTim Marsland else 192*de81e71eSTim Marsland (void) fprintf(output, "-iuclc "); 1937c478bd9Sstevel@tonic-gate m = stio.omode; 194*de81e71eSTim Marsland if (m & OLCUC) 195*de81e71eSTim Marsland (void) fprintf(output, "olcuc "); 196*de81e71eSTim Marsland else 197*de81e71eSTim Marsland (void) fprintf(output, "-olcuc "); 198*de81e71eSTim Marsland if (m & TAB3) 199*de81e71eSTim Marsland (void) fprintf(output, "tab3 "); 2007c478bd9Sstevel@tonic-gate m = stio.lmode; 201*de81e71eSTim Marsland if (m & XCASE) 202*de81e71eSTim Marsland (void) fprintf(output, "xcase "); 203*de81e71eSTim Marsland else 204*de81e71eSTim Marsland (void) fprintf(output, "-xcase "); 205*de81e71eSTim Marsland if (m & STFLUSH) 206*de81e71eSTim Marsland (void) fprintf(output, "stflush "); 207*de81e71eSTim Marsland else 208*de81e71eSTim Marsland (void) fprintf(output, "-stflush "); 209*de81e71eSTim Marsland if (m & STWRAP) 210*de81e71eSTim Marsland (void) fprintf(output, "stwrap "); 211*de81e71eSTim Marsland else 212*de81e71eSTim Marsland (void) fprintf(output, "-stwrap "); 213*de81e71eSTim Marsland if (m & STAPPL) 214*de81e71eSTim Marsland (void) fprintf(output, "stappl "); 215*de81e71eSTim Marsland else 216*de81e71eSTim Marsland (void) fprintf(output, "-stappl "); 2177c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 2187c478bd9Sstevel@tonic-gate } 2197c478bd9Sstevel@tonic-gate if (term & ASYNC) { 2207c478bd9Sstevel@tonic-gate m = cb.c_cflag; 2217c478bd9Sstevel@tonic-gate if ((term & TERMIOS) && cfgetispeed(&cb) != 0 && 2227c478bd9Sstevel@tonic-gate cfgetispeed(&cb) != cfgetospeed(&cb)) { 2237c478bd9Sstevel@tonic-gate prspeed("ispeed ", cfgetispeed(&cb)); 2247c478bd9Sstevel@tonic-gate prspeed("ospeed ", cfgetospeed(&cb)); 2257c478bd9Sstevel@tonic-gate } else 2267c478bd9Sstevel@tonic-gate prspeed("speed ", cfgetospeed(&cb)); 2277c478bd9Sstevel@tonic-gate if (m & PARENB) { 2287c478bd9Sstevel@tonic-gate if ((m & PAREXT) && (term & TERMIOS)) { 2297c478bd9Sstevel@tonic-gate if (m & PARODD) 2307c478bd9Sstevel@tonic-gate (void) fprintf(output, "markp "); 2317c478bd9Sstevel@tonic-gate else 2327c478bd9Sstevel@tonic-gate (void) fprintf(output, "spacep "); 2337c478bd9Sstevel@tonic-gate } else { 2347c478bd9Sstevel@tonic-gate if (m & PARODD) 2357c478bd9Sstevel@tonic-gate (void) fprintf(output, "oddp "); 2367c478bd9Sstevel@tonic-gate else 2377c478bd9Sstevel@tonic-gate (void) fprintf(output, "evenp "); 2387c478bd9Sstevel@tonic-gate } 2397c478bd9Sstevel@tonic-gate } else 2407c478bd9Sstevel@tonic-gate (void) fprintf(output, "-parity "); 241*de81e71eSTim Marsland if (((m & PARENB) && !(m & CS7)) || 242*de81e71eSTim Marsland (!(m & PARENB) && !(m & CS8))) 2437c478bd9Sstevel@tonic-gate (void) fprintf(output, "cs%c ", '5' + (m & CSIZE)/CS6); 2447c478bd9Sstevel@tonic-gate if (m & CSTOPB) 2457c478bd9Sstevel@tonic-gate (void) fprintf(output, "cstopb "); 2467c478bd9Sstevel@tonic-gate if (m & HUPCL) 2477c478bd9Sstevel@tonic-gate (void) fprintf(output, "hupcl "); 2487c478bd9Sstevel@tonic-gate if (!(m & CREAD)) 2497c478bd9Sstevel@tonic-gate (void) fprintf(output, "-cread "); 2507c478bd9Sstevel@tonic-gate if (m & CLOCAL) 2517c478bd9Sstevel@tonic-gate (void) fprintf(output, "clocal "); 2527c478bd9Sstevel@tonic-gate if (m & LOBLK) 2537c478bd9Sstevel@tonic-gate (void) fprintf(output, "loblk "); 2547c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 2557c478bd9Sstevel@tonic-gate if (ocb.c_line != 0) 2567c478bd9Sstevel@tonic-gate (void) fprintf(output, "line = %d; ", ocb.c_line); 2577c478bd9Sstevel@tonic-gate if (term & WINDOW) { 258*de81e71eSTim Marsland (void) fprintf(output, "rows = %d; columns = %d;", 259*de81e71eSTim Marsland winsize.ws_row, winsize.ws_col); 260*de81e71eSTim Marsland (void) fprintf(output, " ypixels = %d; xpixels = %d;\n", 261*de81e71eSTim Marsland winsize.ws_ypixel, winsize.ws_xpixel); 2627c478bd9Sstevel@tonic-gate } 2637c478bd9Sstevel@tonic-gate if ((cb.c_lflag & ICANON) == 0) 2647c478bd9Sstevel@tonic-gate (void) fprintf(output, "min = %d; time = %d;\n", 2657c478bd9Sstevel@tonic-gate cb.c_cc[VMIN], cb.c_cc[VTIME]); 2667c478bd9Sstevel@tonic-gate if (!moremodes) { 2677c478bd9Sstevel@tonic-gate if (cb.c_cc[VINTR] != CINTR) 2687c478bd9Sstevel@tonic-gate pit(cb.c_cc[VINTR], "intr", "; "); 2697c478bd9Sstevel@tonic-gate if (cb.c_cc[VQUIT] != CQUIT) 2707c478bd9Sstevel@tonic-gate pit(cb.c_cc[VQUIT], "quit", "; "); 2717c478bd9Sstevel@tonic-gate if (cb.c_cc[VERASE] != CERASE) 2727c478bd9Sstevel@tonic-gate pit(cb.c_cc[VERASE], "erase", "; "); 2737c478bd9Sstevel@tonic-gate if (cb.c_cc[VKILL] != CKILL) 2747c478bd9Sstevel@tonic-gate pit(cb.c_cc[VKILL], "kill", "; "); 2757c478bd9Sstevel@tonic-gate if (cb.c_cc[VEOF] != CEOF) 2767c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOF], "eof", "; "); 2777c478bd9Sstevel@tonic-gate if (cb.c_cc[VEOL] != CNUL) 2787c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOL], "eol", "; "); 2797c478bd9Sstevel@tonic-gate if (cb.c_cc[VEOL2] != CNUL) 2807c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOL2], "eol2", "; "); 2817c478bd9Sstevel@tonic-gate if (cb.c_cc[VSWTCH] != CSWTCH) 2827c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSWTCH], "swtch", "; "); 2837c478bd9Sstevel@tonic-gate if (term & TERMIOS) { 2847c478bd9Sstevel@tonic-gate if (cb.c_cc[VSTART] != CSTART) 2857c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSTART], "start", "; "); 2867c478bd9Sstevel@tonic-gate if (cb.c_cc[VSTOP] != CSTOP) 2877c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSTOP], "stop", "; "); 2887c478bd9Sstevel@tonic-gate if (cb.c_cc[VSUSP] != CSUSP) 2897c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSUSP], "susp", "; "); 2907c478bd9Sstevel@tonic-gate if (cb.c_cc[VDSUSP] != CDSUSP) 2917c478bd9Sstevel@tonic-gate pit(cb.c_cc[VDSUSP], "dsusp", "; "); 2927c478bd9Sstevel@tonic-gate if (cb.c_cc[VREPRINT] != CRPRNT) 2937c478bd9Sstevel@tonic-gate pit(cb.c_cc[VREPRINT], "rprnt", "; "); 2947c478bd9Sstevel@tonic-gate if (cb.c_cc[VDISCARD] != CFLUSH) 2957c478bd9Sstevel@tonic-gate pit(cb.c_cc[VDISCARD], "flush", "; "); 2967c478bd9Sstevel@tonic-gate if (cb.c_cc[VWERASE] != CWERASE) 2977c478bd9Sstevel@tonic-gate pit(cb.c_cc[VWERASE], "werase", "; "); 2987c478bd9Sstevel@tonic-gate if (cb.c_cc[VLNEXT] != CLNEXT) 2997c478bd9Sstevel@tonic-gate pit(cb.c_cc[VLNEXT], "lnext", "; "); 3007c478bd9Sstevel@tonic-gate } 3017c478bd9Sstevel@tonic-gate } 302*de81e71eSTim Marsland if (pitt) 303*de81e71eSTim Marsland (void) fprintf(output, "\n"); 3047c478bd9Sstevel@tonic-gate m = cb.c_iflag; 3057c478bd9Sstevel@tonic-gate if (m & IGNBRK) 3067c478bd9Sstevel@tonic-gate (void) fprintf(output, "ignbrk "); 3077c478bd9Sstevel@tonic-gate else if (!(m & BRKINT)) 3087c478bd9Sstevel@tonic-gate (void) fprintf(output, "-brkint "); 3097c478bd9Sstevel@tonic-gate if (!(m & INPCK)) 3107c478bd9Sstevel@tonic-gate (void) fprintf(output, "-inpck "); 3117c478bd9Sstevel@tonic-gate else if (!(m & IGNPAR)) 3127c478bd9Sstevel@tonic-gate (void) fprintf(output, "-ignpar "); 3137c478bd9Sstevel@tonic-gate if (m & PARMRK) 3147c478bd9Sstevel@tonic-gate (void) fprintf(output, "parmrk "); 3157c478bd9Sstevel@tonic-gate if (!(m & ISTRIP)) 3167c478bd9Sstevel@tonic-gate (void) fprintf(output, "-istrip "); 3177c478bd9Sstevel@tonic-gate if (m & INLCR) 3187c478bd9Sstevel@tonic-gate (void) fprintf(output, "inlcr "); 3197c478bd9Sstevel@tonic-gate if (m & IGNCR) 3207c478bd9Sstevel@tonic-gate (void) fprintf(output, "igncr "); 3217c478bd9Sstevel@tonic-gate if (!(m & ICRNL)) 3227c478bd9Sstevel@tonic-gate (void) fprintf(output, "-icrnl "); 3237c478bd9Sstevel@tonic-gate if (m & IUCLC) 3247c478bd9Sstevel@tonic-gate (void) fprintf(output, "iuclc "); 3257c478bd9Sstevel@tonic-gate if (!(m & IXON)) 3267c478bd9Sstevel@tonic-gate (void) fprintf(output, "-ixon "); 3277c478bd9Sstevel@tonic-gate else if (m & IXANY) 3287c478bd9Sstevel@tonic-gate (void) fprintf(output, "ixany "); 3297c478bd9Sstevel@tonic-gate if (m & IXOFF) 3307c478bd9Sstevel@tonic-gate (void) fprintf(output, "ixoff "); 3317c478bd9Sstevel@tonic-gate if ((term & TERMIOS) && (m & IMAXBEL)) 3327c478bd9Sstevel@tonic-gate (void) fprintf(output, "imaxbel "); 3337c478bd9Sstevel@tonic-gate m = cb.c_oflag; 3347c478bd9Sstevel@tonic-gate if (!(m & OPOST)) 3357c478bd9Sstevel@tonic-gate (void) fprintf(output, "-opost "); 3367c478bd9Sstevel@tonic-gate else { 3377c478bd9Sstevel@tonic-gate if (m & OLCUC) 3387c478bd9Sstevel@tonic-gate (void) fprintf(output, "olcuc "); 3397c478bd9Sstevel@tonic-gate if (!(m & ONLCR)) 3407c478bd9Sstevel@tonic-gate (void) fprintf(output, "-onlcr "); 3417c478bd9Sstevel@tonic-gate if (m & OCRNL) 3427c478bd9Sstevel@tonic-gate (void) fprintf(output, "ocrnl "); 3437c478bd9Sstevel@tonic-gate if (m & ONOCR) 3447c478bd9Sstevel@tonic-gate (void) fprintf(output, "onocr "); 3457c478bd9Sstevel@tonic-gate if (m & ONLRET) 3467c478bd9Sstevel@tonic-gate (void) fprintf(output, "onlret "); 3477c478bd9Sstevel@tonic-gate if (m & OFILL) 3487c478bd9Sstevel@tonic-gate if (m & OFDEL) 3497c478bd9Sstevel@tonic-gate (void) fprintf(output, "del-fill "); 3507c478bd9Sstevel@tonic-gate else 3517c478bd9Sstevel@tonic-gate (void) fprintf(output, "nul-fill "); 3527c478bd9Sstevel@tonic-gate delay((m & CRDLY)/CR1, "cr"); 3537c478bd9Sstevel@tonic-gate delay((m & NLDLY)/NL1, "nl"); 3547c478bd9Sstevel@tonic-gate if ((m & TABDLY) == XTABS) 3557c478bd9Sstevel@tonic-gate (void) fprintf(output, "-tabs "); 3567c478bd9Sstevel@tonic-gate else 3577c478bd9Sstevel@tonic-gate delay((m & TABDLY)/TAB1, "tab"); 3587c478bd9Sstevel@tonic-gate delay((m & BSDLY)/BS1, "bs"); 3597c478bd9Sstevel@tonic-gate delay((m & VTDLY)/VT1, "vt"); 3607c478bd9Sstevel@tonic-gate delay((m & FFDLY)/FF1, "ff"); 3617c478bd9Sstevel@tonic-gate } 3627c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 3637c478bd9Sstevel@tonic-gate m = cb.c_lflag; 3647c478bd9Sstevel@tonic-gate if (!(m & ISIG)) 3657c478bd9Sstevel@tonic-gate (void) fprintf(output, "-isig "); 3667c478bd9Sstevel@tonic-gate if (!(m & ICANON)) 3677c478bd9Sstevel@tonic-gate (void) fprintf(output, "-icanon "); 3687c478bd9Sstevel@tonic-gate if (m & XCASE) 3697c478bd9Sstevel@tonic-gate (void) fprintf(output, "xcase "); 3707c478bd9Sstevel@tonic-gate if (!(m & ECHO)) 3717c478bd9Sstevel@tonic-gate (void) fprintf(output, "-echo "); 3727c478bd9Sstevel@tonic-gate if (m & ECHOE) { 3737c478bd9Sstevel@tonic-gate if (m & ECHOKE) 3747c478bd9Sstevel@tonic-gate (void) fprintf(output, "crt "); 3757c478bd9Sstevel@tonic-gate else 3767c478bd9Sstevel@tonic-gate (void) fprintf(output, "echoe -echoke "); 3777c478bd9Sstevel@tonic-gate } else { 3787c478bd9Sstevel@tonic-gate if (!(m & ECHOPRT)) 3797c478bd9Sstevel@tonic-gate (void) fprintf(output, "-echoprt "); 3807c478bd9Sstevel@tonic-gate } 3817c478bd9Sstevel@tonic-gate if (!(m & ECHOK)) 3827c478bd9Sstevel@tonic-gate (void) fprintf(output, "-echok "); 3837c478bd9Sstevel@tonic-gate if (m & ECHONL) 3847c478bd9Sstevel@tonic-gate (void) fprintf(output, "echonl "); 3857c478bd9Sstevel@tonic-gate if (m & NOFLSH) 3867c478bd9Sstevel@tonic-gate (void) fprintf(output, "noflsh "); 3877c478bd9Sstevel@tonic-gate if (m & TOSTOP) 3887c478bd9Sstevel@tonic-gate (void) fprintf(output, "tostop "); 3897c478bd9Sstevel@tonic-gate if (!(m & ECHOCTL)) 3907c478bd9Sstevel@tonic-gate (void) fprintf(output, "-echoctl "); 3917c478bd9Sstevel@tonic-gate if (m & DEFECHO) 3927c478bd9Sstevel@tonic-gate (void) fprintf(output, "defecho "); 3937c478bd9Sstevel@tonic-gate if (m & FLUSHO) 3947c478bd9Sstevel@tonic-gate (void) fprintf(output, "flusho "); 3957c478bd9Sstevel@tonic-gate if (m & PENDIN) 3967c478bd9Sstevel@tonic-gate (void) fprintf(output, "pendin "); 3977c478bd9Sstevel@tonic-gate if (m & IEXTEN) 3987c478bd9Sstevel@tonic-gate (void) fprintf(output, "iexten "); 3997c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 4007c478bd9Sstevel@tonic-gate } 4017c478bd9Sstevel@tonic-gate if (term & FLOW) { 4027c478bd9Sstevel@tonic-gate m = termiox.x_hflag; 4037c478bd9Sstevel@tonic-gate if (m & RTSXOFF) 4047c478bd9Sstevel@tonic-gate (void) fprintf(output, "rtsxoff "); 4057c478bd9Sstevel@tonic-gate if (m & CTSXON) 4067c478bd9Sstevel@tonic-gate (void) fprintf(output, "ctsxon "); 4077c478bd9Sstevel@tonic-gate if (m & DTRXOFF) 4087c478bd9Sstevel@tonic-gate (void) fprintf(output, "dterxoff "); 4097c478bd9Sstevel@tonic-gate if (m & CDXON) 4107c478bd9Sstevel@tonic-gate (void) fprintf(output, "rlsdxon "); 4117c478bd9Sstevel@tonic-gate if (m & ISXOFF) 4127c478bd9Sstevel@tonic-gate (void) fprintf(output, "isxoff "); 4137c478bd9Sstevel@tonic-gate m = termiox.x_cflag; 414*de81e71eSTim Marsland switch (m & XMTCLK) { 415*de81e71eSTim Marsland case XCIBRG: 416*de81e71eSTim Marsland (void) fprintf(output, "xcibrg "); 4177c478bd9Sstevel@tonic-gate break; 418*de81e71eSTim Marsland case XCTSET: 419*de81e71eSTim Marsland (void) fprintf(output, "xctset "); 4207c478bd9Sstevel@tonic-gate break; 421*de81e71eSTim Marsland case XCRSET: 422*de81e71eSTim Marsland (void) fprintf(output, "xcrset "); 423*de81e71eSTim Marsland break; 4247c478bd9Sstevel@tonic-gate } 4257c478bd9Sstevel@tonic-gate 426*de81e71eSTim Marsland switch (m & RCVCLK) { 427*de81e71eSTim Marsland case RCIBRG: 428*de81e71eSTim Marsland (void) fprintf(output, "rcibrg "); 4297c478bd9Sstevel@tonic-gate break; 430*de81e71eSTim Marsland case RCTSET: 431*de81e71eSTim Marsland (void) fprintf(output, "rctset "); 4327c478bd9Sstevel@tonic-gate break; 433*de81e71eSTim Marsland case RCRSET: 434*de81e71eSTim Marsland (void) fprintf(output, "rcrset "); 435*de81e71eSTim Marsland break; 4367c478bd9Sstevel@tonic-gate } 4377c478bd9Sstevel@tonic-gate 438*de81e71eSTim Marsland switch (m & TSETCLK) { 439*de81e71eSTim Marsland case TSETCOFF: 440*de81e71eSTim Marsland (void) fprintf(output, "tsetcoff "); 4417c478bd9Sstevel@tonic-gate break; 442*de81e71eSTim Marsland case TSETCRBRG: 443*de81e71eSTim Marsland (void) fprintf(output, "tsetcrc "); 4447c478bd9Sstevel@tonic-gate break; 445*de81e71eSTim Marsland case TSETCTBRG: 446*de81e71eSTim Marsland (void) fprintf(output, "tsetcxc "); 447*de81e71eSTim Marsland break; 4487c478bd9Sstevel@tonic-gate } 4497c478bd9Sstevel@tonic-gate 450*de81e71eSTim Marsland switch (m & RSETCLK) { 451*de81e71eSTim Marsland case RSETCOFF: 452*de81e71eSTim Marsland (void) fprintf(output, "rsetcoff "); 4537c478bd9Sstevel@tonic-gate break; 454*de81e71eSTim Marsland case RSETCRBRG: 455*de81e71eSTim Marsland (void) fprintf(output, "rsetcrc "); 4567c478bd9Sstevel@tonic-gate break; 457*de81e71eSTim Marsland case RSETCTBRG: 458*de81e71eSTim Marsland (void) fprintf(output, "rsetcxc "); 4597c478bd9Sstevel@tonic-gate } 4607c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 4617c478bd9Sstevel@tonic-gate } 4627c478bd9Sstevel@tonic-gate if (moremodes) 4637c478bd9Sstevel@tonic-gate prachars(); 4647c478bd9Sstevel@tonic-gate } 4657c478bd9Sstevel@tonic-gate 466cc6c5292Schin void 467cc6c5292Schin pramodes(int tabform) 468cc6c5292Schin /* print all modes, -a option */ 4697c478bd9Sstevel@tonic-gate { 470cc6c5292Schin int m; 4717c478bd9Sstevel@tonic-gate 4727c478bd9Sstevel@tonic-gate m = cb.c_cflag; 4737c478bd9Sstevel@tonic-gate if (term & ASYNC) { 4747c478bd9Sstevel@tonic-gate if ((term & TERMIOS) && cfgetispeed(&cb) != 0 && 4757c478bd9Sstevel@tonic-gate cfgetispeed(&cb) != cfgetospeed(&cb)) { 4767c478bd9Sstevel@tonic-gate prspeed("ispeed ", cfgetispeed(&cb)); 4777c478bd9Sstevel@tonic-gate prspeed("ospeed ", cfgetospeed(&cb)); 4787c478bd9Sstevel@tonic-gate } else 4797c478bd9Sstevel@tonic-gate prspeed("speed ", cfgetospeed(&cb)); 4807c478bd9Sstevel@tonic-gate if (!(term & TERMIOS)) 4817c478bd9Sstevel@tonic-gate (void) fprintf(output, "line = %d; ", ocb.c_line); 4827c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 4837c478bd9Sstevel@tonic-gate if (term & WINDOW) { 484*de81e71eSTim Marsland (void) fprintf(output, "rows = %d columns = %d; ", 485*de81e71eSTim Marsland winsize.ws_row, winsize.ws_col); 486*de81e71eSTim Marsland (void) fprintf(output, "ypixels = %d xpixels = %d\n", 487*de81e71eSTim Marsland winsize.ws_ypixel, winsize.ws_xpixel); 4887c478bd9Sstevel@tonic-gate } 4897c478bd9Sstevel@tonic-gate if ((cb.c_lflag & ICANON) == 0) 490*de81e71eSTim Marsland (void) fprintf(output, "min = %d; time = %d;\n", 491*de81e71eSTim Marsland cb.c_cc[VMIN], cb.c_cc[VTIME]); 4927c478bd9Sstevel@tonic-gate if (!tabform) { 4937c478bd9Sstevel@tonic-gate pit(cb.c_cc[VINTR], "intr", "; "); 4947c478bd9Sstevel@tonic-gate pit(cb.c_cc[VQUIT], "quit", "; "); 4957c478bd9Sstevel@tonic-gate pit(cb.c_cc[VERASE], "erase", "; "); 4967c478bd9Sstevel@tonic-gate pit(cb.c_cc[VKILL], "kill", ";\n"); 4977c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOF], "eof", "; "); 4987c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOL], "eol", "; "); 4997c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOL2], "eol2", "; "); 5007c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSWTCH], "swtch", ";\n"); 5017c478bd9Sstevel@tonic-gate if (term & TERMIOS) { 5027c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSTART], "start", "; "); 5037c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSTOP], "stop", "; "); 5047c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSUSP], "susp", "; "); 5057c478bd9Sstevel@tonic-gate pit(cb.c_cc[VDSUSP], "dsusp", ";\n"); 5067c478bd9Sstevel@tonic-gate pit(cb.c_cc[VREPRINT], "rprnt", "; "); 5077c478bd9Sstevel@tonic-gate pit(cb.c_cc[VDISCARD], "flush", "; "); 5087c478bd9Sstevel@tonic-gate pit(cb.c_cc[VWERASE], "werase", "; "); 5097c478bd9Sstevel@tonic-gate pit(cb.c_cc[VLNEXT], "lnext", ";\n"); 5107c478bd9Sstevel@tonic-gate } 5117c478bd9Sstevel@tonic-gate } 5127c478bd9Sstevel@tonic-gate } else 5137c478bd9Sstevel@tonic-gate pit((unsigned)stio.tab, "ctab", "\n"); 5147c478bd9Sstevel@tonic-gate m = cb.c_cflag; 5157c478bd9Sstevel@tonic-gate (void) fprintf(output, "-parenb " + ((m & PARENB) != 0)); 5167c478bd9Sstevel@tonic-gate (void) fprintf(output, "-parodd " + ((m & PARODD) != 0)); 5177c478bd9Sstevel@tonic-gate (void) fprintf(output, "cs%c ", '5'+ (m & CSIZE)/CS6); 5187c478bd9Sstevel@tonic-gate (void) fprintf(output, "-cstopb " + ((m & CSTOPB) != 0)); 5197c478bd9Sstevel@tonic-gate (void) fprintf(output, "-hupcl " + ((m & HUPCL) != 0)); 5207c478bd9Sstevel@tonic-gate (void) fprintf(output, "-cread " + ((m & CREAD) != 0)); 5217c478bd9Sstevel@tonic-gate (void) fprintf(output, "-clocal " + ((m & CLOCAL) != 0)); 5227c478bd9Sstevel@tonic-gate 5237c478bd9Sstevel@tonic-gate (void) fprintf(output, "-loblk " + ((m & LOBLK) != 0)); 5247c478bd9Sstevel@tonic-gate if (term & TERMIOS) 5257c478bd9Sstevel@tonic-gate (void) fprintf(output, "-parext " + ((m & PAREXT) != 0)); 5267c478bd9Sstevel@tonic-gate 5277c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 5287c478bd9Sstevel@tonic-gate m = cb.c_iflag; 5297c478bd9Sstevel@tonic-gate (void) fprintf(output, "-ignbrk " + ((m & IGNBRK) != 0)); 5307c478bd9Sstevel@tonic-gate (void) fprintf(output, "-brkint " + ((m & BRKINT) != 0)); 5317c478bd9Sstevel@tonic-gate (void) fprintf(output, "-ignpar " + ((m & IGNPAR) != 0)); 5327c478bd9Sstevel@tonic-gate (void) fprintf(output, "-parmrk " + ((m & PARMRK) != 0)); 5337c478bd9Sstevel@tonic-gate (void) fprintf(output, "-inpck " + ((m & INPCK) != 0)); 5347c478bd9Sstevel@tonic-gate (void) fprintf(output, "-istrip " + ((m & ISTRIP) != 0)); 5357c478bd9Sstevel@tonic-gate (void) fprintf(output, "-inlcr " + ((m & INLCR) != 0)); 5367c478bd9Sstevel@tonic-gate (void) fprintf(output, "-igncr " + ((m & IGNCR) != 0)); 5377c478bd9Sstevel@tonic-gate (void) fprintf(output, "-icrnl " + ((m & ICRNL) != 0)); 5387c478bd9Sstevel@tonic-gate (void) fprintf(output, "-iuclc " + ((m & IUCLC) != 0)); 5397c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 5407c478bd9Sstevel@tonic-gate (void) fprintf(output, "-ixon " + ((m & IXON) != 0)); 5417c478bd9Sstevel@tonic-gate (void) fprintf(output, "-ixany " + ((m & IXANY) != 0)); 5427c478bd9Sstevel@tonic-gate (void) fprintf(output, "-ixoff " + ((m & IXOFF) != 0)); 5437c478bd9Sstevel@tonic-gate if (term & TERMIOS) 5447c478bd9Sstevel@tonic-gate (void) fprintf(output, "-imaxbel " + ((m & IMAXBEL) != 0)); 5457c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 5467c478bd9Sstevel@tonic-gate m = cb.c_lflag; 5477c478bd9Sstevel@tonic-gate (void) fprintf(output, "-isig " + ((m & ISIG) != 0)); 5487c478bd9Sstevel@tonic-gate (void) fprintf(output, "-icanon " + ((m & ICANON) != 0)); 5497c478bd9Sstevel@tonic-gate (void) fprintf(output, "-xcase " + ((m & XCASE) != 0)); 5507c478bd9Sstevel@tonic-gate (void) fprintf(output, "-echo " + ((m & ECHO) != 0)); 5517c478bd9Sstevel@tonic-gate (void) fprintf(output, "-echoe " + ((m & ECHOE) != 0)); 5527c478bd9Sstevel@tonic-gate (void) fprintf(output, "-echok " + ((m & ECHOK) != 0)); 5537c478bd9Sstevel@tonic-gate (void) fprintf(output, "-echonl " + ((m & ECHONL) != 0)); 5547c478bd9Sstevel@tonic-gate (void) fprintf(output, "-noflsh " + ((m & NOFLSH) != 0)); 5557c478bd9Sstevel@tonic-gate if (term & TERMIOS) { 5567c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 5577c478bd9Sstevel@tonic-gate (void) fprintf(output, "-tostop " + ((m & TOSTOP) != 0)); 5587c478bd9Sstevel@tonic-gate (void) fprintf(output, "-echoctl " + ((m & ECHOCTL) != 0)); 5597c478bd9Sstevel@tonic-gate (void) fprintf(output, "-echoprt " + ((m & ECHOPRT) != 0)); 5607c478bd9Sstevel@tonic-gate (void) fprintf(output, "-echoke " + ((m & ECHOKE) != 0)); 5617c478bd9Sstevel@tonic-gate (void) fprintf(output, "-defecho " + ((m & DEFECHO) != 0)); 5627c478bd9Sstevel@tonic-gate (void) fprintf(output, "-flusho " + ((m & FLUSHO) != 0)); 5637c478bd9Sstevel@tonic-gate (void) fprintf(output, "-pendin " + ((m & PENDIN) != 0)); 5647c478bd9Sstevel@tonic-gate (void) fprintf(output, "-iexten " + ((m & IEXTEN) != 0)); 5657c478bd9Sstevel@tonic-gate } 5667c478bd9Sstevel@tonic-gate if (!(term & ASYNC)) { 5677c478bd9Sstevel@tonic-gate (void) fprintf(output, "-stflush " + ((m & STFLUSH) != 0)); 5687c478bd9Sstevel@tonic-gate (void) fprintf(output, "-stwrap " + ((m & STWRAP) != 0)); 5697c478bd9Sstevel@tonic-gate (void) fprintf(output, "-stappl " + ((m & STAPPL) != 0)); 5707c478bd9Sstevel@tonic-gate } 5717c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 5727c478bd9Sstevel@tonic-gate m = cb.c_oflag; 5737c478bd9Sstevel@tonic-gate (void) fprintf(output, "-opost " + ((m & OPOST) != 0)); 5747c478bd9Sstevel@tonic-gate (void) fprintf(output, "-olcuc " + ((m & OLCUC) != 0)); 5757c478bd9Sstevel@tonic-gate (void) fprintf(output, "-onlcr " + ((m & ONLCR) != 0)); 5767c478bd9Sstevel@tonic-gate (void) fprintf(output, "-ocrnl " + ((m & OCRNL) != 0)); 5777c478bd9Sstevel@tonic-gate (void) fprintf(output, "-onocr " + ((m & ONOCR) != 0)); 5787c478bd9Sstevel@tonic-gate (void) fprintf(output, "-onlret " + ((m & ONLRET) != 0)); 5797c478bd9Sstevel@tonic-gate (void) fprintf(output, "-ofill " + ((m & OFILL) != 0)); 5807c478bd9Sstevel@tonic-gate (void) fprintf(output, "-ofdel " + ((m & OFDEL) != 0)); 5817c478bd9Sstevel@tonic-gate delay((m & CRDLY)/CR1, "cr"); 5827c478bd9Sstevel@tonic-gate delay((m & NLDLY)/NL1, "nl"); 5837c478bd9Sstevel@tonic-gate if ((m & TABDLY) == XTABS) 5847c478bd9Sstevel@tonic-gate (void) fprintf(output, "-tabs "); 5857c478bd9Sstevel@tonic-gate else 5867c478bd9Sstevel@tonic-gate delay((m & TABDLY)/TAB1, "tab"); 5877c478bd9Sstevel@tonic-gate delay((m & BSDLY)/BS1, "bs"); 5887c478bd9Sstevel@tonic-gate delay((m & VTDLY)/VT1, "vt"); 5897c478bd9Sstevel@tonic-gate delay((m & FFDLY)/FF1, "ff"); 5907c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 5917c478bd9Sstevel@tonic-gate if (term & FLOW) { 5927c478bd9Sstevel@tonic-gate m = termiox.x_hflag; 5937c478bd9Sstevel@tonic-gate (void) fprintf(output, "-rtsxoff " + ((m & RTSXOFF) != 0)); 5947c478bd9Sstevel@tonic-gate (void) fprintf(output, "-ctsxon " + ((m & CTSXON) != 0)); 5957c478bd9Sstevel@tonic-gate (void) fprintf(output, "-dterxoff " + ((m & DTRXOFF) != 0)); 5967c478bd9Sstevel@tonic-gate (void) fprintf(output, "-rlsdxon " + ((m & CDXON) != 0)); 5977c478bd9Sstevel@tonic-gate (void) fprintf(output, "-isxoff " + ((m & ISXOFF) != 0)); 5987c478bd9Sstevel@tonic-gate m = termiox.x_cflag; 599*de81e71eSTim Marsland switch (m & XMTCLK) { 600*de81e71eSTim Marsland case XCIBRG: 601*de81e71eSTim Marsland (void) fprintf(output, "xcibrg "); 6027c478bd9Sstevel@tonic-gate break; 603*de81e71eSTim Marsland case XCTSET: 604*de81e71eSTim Marsland (void) fprintf(output, "xctset "); 6057c478bd9Sstevel@tonic-gate break; 606*de81e71eSTim Marsland case XCRSET: 607*de81e71eSTim Marsland (void) fprintf(output, "xcrset "); 608*de81e71eSTim Marsland break; 6097c478bd9Sstevel@tonic-gate } 6107c478bd9Sstevel@tonic-gate 611*de81e71eSTim Marsland switch (m & RCVCLK) { 612*de81e71eSTim Marsland case RCIBRG: 613*de81e71eSTim Marsland (void) fprintf(output, "rcibrg "); 6147c478bd9Sstevel@tonic-gate break; 615*de81e71eSTim Marsland case RCTSET: 616*de81e71eSTim Marsland (void) fprintf(output, "rctset "); 6177c478bd9Sstevel@tonic-gate break; 618*de81e71eSTim Marsland case RCRSET: 619*de81e71eSTim Marsland (void) fprintf(output, "rcrset "); 620*de81e71eSTim Marsland break; 6217c478bd9Sstevel@tonic-gate } 6227c478bd9Sstevel@tonic-gate 623*de81e71eSTim Marsland switch (m & TSETCLK) { 624*de81e71eSTim Marsland case TSETCOFF: 625*de81e71eSTim Marsland (void) fprintf(output, "tsetcoff "); 6267c478bd9Sstevel@tonic-gate break; 627*de81e71eSTim Marsland case TSETCRBRG: 628*de81e71eSTim Marsland (void) fprintf(output, "tsetcrc "); 6297c478bd9Sstevel@tonic-gate break; 630*de81e71eSTim Marsland case TSETCTBRG: 631*de81e71eSTim Marsland (void) fprintf(output, "tsetcxc "); 632*de81e71eSTim Marsland break; 6337c478bd9Sstevel@tonic-gate } 6347c478bd9Sstevel@tonic-gate 635*de81e71eSTim Marsland switch (m & RSETCLK) { 636*de81e71eSTim Marsland case RSETCOFF: 637*de81e71eSTim Marsland (void) fprintf(output, "rsetcoff "); 6387c478bd9Sstevel@tonic-gate break; 639*de81e71eSTim Marsland case RSETCRBRG: 640*de81e71eSTim Marsland (void) fprintf(output, "rsetcrc "); 6417c478bd9Sstevel@tonic-gate break; 642*de81e71eSTim Marsland case RSETCTBRG: 643*de81e71eSTim Marsland (void) fprintf(output, "rsetcxc "); 644*de81e71eSTim Marsland break; 6457c478bd9Sstevel@tonic-gate } 6467c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 6477c478bd9Sstevel@tonic-gate } 6487c478bd9Sstevel@tonic-gate if (tabform) 6497c478bd9Sstevel@tonic-gate prachars(); 6507c478bd9Sstevel@tonic-gate } 6517c478bd9Sstevel@tonic-gate 652cc6c5292Schin void 653cc6c5292Schin prachars(void) 6547c478bd9Sstevel@tonic-gate { 6557c478bd9Sstevel@tonic-gate if ((cb.c_lflag & ICANON) == 0) 6567c478bd9Sstevel@tonic-gate (void) fprintf(output, "min %d, time %d\n", cb.c_cc[VMIN], 6577c478bd9Sstevel@tonic-gate cb.c_cc[VTIME]); 6587c478bd9Sstevel@tonic-gate (void) fprintf(output, "\ 6597c478bd9Sstevel@tonic-gate erase kill werase rprnt flush lnext susp intr quit stop eof\ 6607c478bd9Sstevel@tonic-gate \n"); 6617c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VERASE], 0); 6627c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VKILL], 0); 6637c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VWERASE], 0); 6647c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VREPRINT], 0); 6657c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VDISCARD], 0); 6667c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VLNEXT], 0); 6677c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VSUSP], cb.c_cc[VDSUSP]); 6687c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VINTR], 0); 6697c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VQUIT], 0); 6707c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VSTOP], cb.c_cc[VSTART]); 6717c478bd9Sstevel@tonic-gate if (cb.c_lflag&ICANON) 6727c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VEOF], cb.c_cc[VEOL]); 6737c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 6747c478bd9Sstevel@tonic-gate if (cb.c_cc[VEOL2] != 0 || cb.c_cc[VSWTCH] != 0) { 6757c478bd9Sstevel@tonic-gate (void) fprintf(output, "\ 6767c478bd9Sstevel@tonic-gate eol2 swtch\ 6777c478bd9Sstevel@tonic-gate \n"); 6787c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VEOL2], 0); 6797c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VSWTCH], 0); 6807c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 6817c478bd9Sstevel@tonic-gate } 6827c478bd9Sstevel@tonic-gate } 6837c478bd9Sstevel@tonic-gate 684cc6c5292Schin void 685cc6c5292Schin pcol(int ch1, int ch2) 6867c478bd9Sstevel@tonic-gate { 6877c478bd9Sstevel@tonic-gate int nout = 0; 6887c478bd9Sstevel@tonic-gate 6897c478bd9Sstevel@tonic-gate ch1 &= 0377; 6907c478bd9Sstevel@tonic-gate ch2 &= 0377; 6917c478bd9Sstevel@tonic-gate if (ch1 == ch2) 6927c478bd9Sstevel@tonic-gate ch2 = 0; 6937c478bd9Sstevel@tonic-gate for (; ch1 != 0 || ch2 != 0; ch1 = ch2, ch2 = 0) { 6947c478bd9Sstevel@tonic-gate if (ch1 == 0) 6957c478bd9Sstevel@tonic-gate continue; 6967c478bd9Sstevel@tonic-gate if (ch1 & 0200 && !isprint(ch1)) { 6977c478bd9Sstevel@tonic-gate (void) fprintf(output, "M-"); 6987c478bd9Sstevel@tonic-gate nout += 2; 6997c478bd9Sstevel@tonic-gate ch1 &= ~ 0200; 7007c478bd9Sstevel@tonic-gate } 7017c478bd9Sstevel@tonic-gate if (ch1 == 0177) { 7027c478bd9Sstevel@tonic-gate (void) fprintf(output, "^"); 7037c478bd9Sstevel@tonic-gate nout++; 7047c478bd9Sstevel@tonic-gate ch1 = '?'; 7057c478bd9Sstevel@tonic-gate } else if (ch1 < ' ') { 7067c478bd9Sstevel@tonic-gate (void) fprintf(output, "^"); 7077c478bd9Sstevel@tonic-gate nout++; 7087c478bd9Sstevel@tonic-gate ch1 += '@'; 7097c478bd9Sstevel@tonic-gate } 7107c478bd9Sstevel@tonic-gate (void) fprintf(output, "%c", ch1); 7117c478bd9Sstevel@tonic-gate nout++; 7127c478bd9Sstevel@tonic-gate if (ch2 != 0) { 7137c478bd9Sstevel@tonic-gate (void) fprintf(output, "/"); 7147c478bd9Sstevel@tonic-gate nout++; 7157c478bd9Sstevel@tonic-gate } 7167c478bd9Sstevel@tonic-gate } 7177c478bd9Sstevel@tonic-gate while (nout < 7) { 7187c478bd9Sstevel@tonic-gate (void) fprintf(output, " "); 7197c478bd9Sstevel@tonic-gate nout++; 7207c478bd9Sstevel@tonic-gate } 7217c478bd9Sstevel@tonic-gate } 7227c478bd9Sstevel@tonic-gate 723cc6c5292Schin void 724cc6c5292Schin pit(unsigned char what, char *itsname, char *sep) 725cc6c5292Schin /* print function for prmodes() and pramodes() */ 7267c478bd9Sstevel@tonic-gate { 7277c478bd9Sstevel@tonic-gate 7287c478bd9Sstevel@tonic-gate pitt++; 7297c478bd9Sstevel@tonic-gate (void) fprintf(output, "%s", itsname); 730*de81e71eSTim Marsland if ((term & TERMIOS) && what == _POSIX_VDISABLE || 731*de81e71eSTim Marsland !(term & TERMIOS) && what == 0200) { 7327c478bd9Sstevel@tonic-gate (void) fprintf(output, " = <undef>%s", sep); 7337c478bd9Sstevel@tonic-gate return; 7347c478bd9Sstevel@tonic-gate } 7357c478bd9Sstevel@tonic-gate (void) fprintf(output, " = "); 7367c478bd9Sstevel@tonic-gate if (what & 0200 && !isprint(what)) { 7377c478bd9Sstevel@tonic-gate (void) fprintf(output, "-"); 7387c478bd9Sstevel@tonic-gate what &= ~ 0200; 7397c478bd9Sstevel@tonic-gate } 7407c478bd9Sstevel@tonic-gate if (what == 0177) { 7417c478bd9Sstevel@tonic-gate (void) fprintf(output, "^?%s", sep); 7427c478bd9Sstevel@tonic-gate return; 7437c478bd9Sstevel@tonic-gate } else if (what < ' ') { 7447c478bd9Sstevel@tonic-gate (void) fprintf(output, "^"); 7457c478bd9Sstevel@tonic-gate what += '`'; 7467c478bd9Sstevel@tonic-gate } 7477c478bd9Sstevel@tonic-gate (void) fprintf(output, "%c%s", what, sep); 7487c478bd9Sstevel@tonic-gate } 7497c478bd9Sstevel@tonic-gate 750cc6c5292Schin void 751cc6c5292Schin delay(int m, char *s) 7527c478bd9Sstevel@tonic-gate { 7537c478bd9Sstevel@tonic-gate if (m) 7547c478bd9Sstevel@tonic-gate (void) fprintf(output, "%s%d ", s, m); 7557c478bd9Sstevel@tonic-gate } 7567c478bd9Sstevel@tonic-gate 7577c478bd9Sstevel@tonic-gate long speed[] = { 758*de81e71eSTim Marsland 0, 50, 75, 110, 134, 150, 200, 300, 759*de81e71eSTim Marsland 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 760*de81e71eSTim Marsland 57600, 76800, 115200, 153600, 230400, 307200, 460800, 921600 7617c478bd9Sstevel@tonic-gate }; 7627c478bd9Sstevel@tonic-gate 763cc6c5292Schin void 764cc6c5292Schin prspeed(char *c, int s) 7657c478bd9Sstevel@tonic-gate { 7667c478bd9Sstevel@tonic-gate (void) fprintf(output, "%s%d baud; ", c, speed[s]); 7677c478bd9Sstevel@tonic-gate } 7687c478bd9Sstevel@tonic-gate 769cc6c5292Schin /* 770cc6c5292Schin * print current settings for use with 771cc6c5292Schin * another stty cmd, used for -g option 772cc6c5292Schin */ 773cc6c5292Schin void 774cc6c5292Schin prencode(void) 7757c478bd9Sstevel@tonic-gate { 7767c478bd9Sstevel@tonic-gate int i, last; 7777c478bd9Sstevel@tonic-gate 778cc6c5292Schin /* Since the -g option is mostly used for redirecting to a file */ 7797c478bd9Sstevel@tonic-gate /* We must print to stdout here, not stderr */ 7807c478bd9Sstevel@tonic-gate 781*de81e71eSTim Marsland (void) printf("%x:%x:%x:%x:", cb.c_iflag, cb.c_oflag, 782*de81e71eSTim Marsland cb.c_cflag, cb.c_lflag); 7837c478bd9Sstevel@tonic-gate 7847c478bd9Sstevel@tonic-gate if (term & TERMIOS) 7857c478bd9Sstevel@tonic-gate /* last control slot is unused */ 7867c478bd9Sstevel@tonic-gate last = NCCS - 2; 7877c478bd9Sstevel@tonic-gate else 7887c478bd9Sstevel@tonic-gate last = NCC - 1; 7897c478bd9Sstevel@tonic-gate for (i = 0; i < last; i++) 7907c478bd9Sstevel@tonic-gate (void) printf("%x:", cb.c_cc[i]); 7917c478bd9Sstevel@tonic-gate (void) printf("%x\n", cb.c_cc[last]); 7927c478bd9Sstevel@tonic-gate } 793