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 1995 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 #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <stdio.h> 347c478bd9Sstevel@tonic-gate #include <ctype.h> 357c478bd9Sstevel@tonic-gate #include <sys/types.h> 367c478bd9Sstevel@tonic-gate #include <termio.h> 377c478bd9Sstevel@tonic-gate #include <sys/stermio.h> 387c478bd9Sstevel@tonic-gate #include <sys/termiox.h> 397c478bd9Sstevel@tonic-gate #include "stty.h" 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate extern char *getenv(); 427c478bd9Sstevel@tonic-gate extern void exit(); 437c478bd9Sstevel@tonic-gate extern void perror(); 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate static char *STTY="stty: "; 467c478bd9Sstevel@tonic-gate static char *USAGE="usage: stty [-agh] [modes]\n"; 477c478bd9Sstevel@tonic-gate static int pitt = 0; 487c478bd9Sstevel@tonic-gate static struct termios cb; 497c478bd9Sstevel@tonic-gate static struct termio ocb; /* for non-streams devices */ 507c478bd9Sstevel@tonic-gate static struct stio stio; 517c478bd9Sstevel@tonic-gate static struct termiox termiox; 527c478bd9Sstevel@tonic-gate static struct winsize winsize, owinsize; 537c478bd9Sstevel@tonic-gate static int term; 547c478bd9Sstevel@tonic-gate 55*cc6c5292Schin void prmodes(int); 56*cc6c5292Schin void pramodes(int); 57*cc6c5292Schin void prachars(void); 58*cc6c5292Schin void pcol(int, int); 59*cc6c5292Schin void pit(unsigned char, char *, char *); 60*cc6c5292Schin void delay(int, char *s); 61*cc6c5292Schin void prspeed(char *, int); 62*cc6c5292Schin void prencode(void); 63*cc6c5292Schin 647c478bd9Sstevel@tonic-gate #define ioctl_desc 1 657c478bd9Sstevel@tonic-gate #define output stderr 667c478bd9Sstevel@tonic-gate 67*cc6c5292Schin int 68*cc6c5292Schin main(int argc, char *argv[]) 697c478bd9Sstevel@tonic-gate { 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate int i; 727c478bd9Sstevel@tonic-gate char *s_arg, *sttyparse(); /* s_arg: ptr to mode to be set */ 737c478bd9Sstevel@tonic-gate extern const struct speeds speeds[]; 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate if (argc == 2) { 767c478bd9Sstevel@tonic-gate /* 777c478bd9Sstevel@tonic-gate * "stty size", "stty speed" and "stty -g" are intended for 787c478bd9Sstevel@tonic-gate * use within backquotes; thus, they do the "fetch" "ioctl" 797c478bd9Sstevel@tonic-gate * from "/dev/tty" and always print their result on the 807c478bd9Sstevel@tonic-gate * standard output. 817c478bd9Sstevel@tonic-gate * Since their standard output is likely to be a pipe, they 827c478bd9Sstevel@tonic-gate * should not try to read the modes from the standard output. 837c478bd9Sstevel@tonic-gate */ 847c478bd9Sstevel@tonic-gate if (strcmp(argv[1], "size") == 0) { 857c478bd9Sstevel@tonic-gate if ((i = open("/dev/tty", 0)) < 0) { 867c478bd9Sstevel@tonic-gate perror("stty: Cannot open /dev/tty"); 877c478bd9Sstevel@tonic-gate exit(2); 887c478bd9Sstevel@tonic-gate } 897c478bd9Sstevel@tonic-gate if (ioctl(i, TIOCGWINSZ, &winsize) < 0) { 907c478bd9Sstevel@tonic-gate perror("stty: TIOCGWINSZ"); 917c478bd9Sstevel@tonic-gate exit(2); 927c478bd9Sstevel@tonic-gate } 937c478bd9Sstevel@tonic-gate (void) printf("%d %d\n",winsize.ws_row,winsize.ws_col); 947c478bd9Sstevel@tonic-gate exit(0); 957c478bd9Sstevel@tonic-gate } 967c478bd9Sstevel@tonic-gate else if (strcmp(argv[1], "speed") == 0) { 977c478bd9Sstevel@tonic-gate if ((i = open("/dev/tty", 0)) < 0) { 987c478bd9Sstevel@tonic-gate perror("stty: Cannot open /dev/tty"); 997c478bd9Sstevel@tonic-gate exit(2); 1007c478bd9Sstevel@tonic-gate } 1017c478bd9Sstevel@tonic-gate if((term = get_ttymode(i, &ocb, &cb, &stio, &termiox, 1027c478bd9Sstevel@tonic-gate &winsize)) < 0) { 1037c478bd9Sstevel@tonic-gate perror(STTY); 1047c478bd9Sstevel@tonic-gate exit(2); 1057c478bd9Sstevel@tonic-gate } 1067c478bd9Sstevel@tonic-gate if (term & TERMIOS) { 1077c478bd9Sstevel@tonic-gate for(i=0; speeds[i].string; i++) 1087c478bd9Sstevel@tonic-gate if (cfgetospeed(&cb) == speeds[i].speed) { 1097c478bd9Sstevel@tonic-gate (void) printf("%s\n", speeds[i].string); 1107c478bd9Sstevel@tonic-gate exit(0); 1117c478bd9Sstevel@tonic-gate } 1127c478bd9Sstevel@tonic-gate } else { 1137c478bd9Sstevel@tonic-gate for(i=0; speeds[i].string; i++) 1147c478bd9Sstevel@tonic-gate if ((cb.c_cflag&CBAUD) == speeds[i].speed) { 1157c478bd9Sstevel@tonic-gate (void) printf("%s\n", speeds[i].string); 1167c478bd9Sstevel@tonic-gate exit(0); 1177c478bd9Sstevel@tonic-gate } 1187c478bd9Sstevel@tonic-gate } 1197c478bd9Sstevel@tonic-gate (void) printf("unknown\n"); 1207c478bd9Sstevel@tonic-gate exit(1); 1217c478bd9Sstevel@tonic-gate } 1227c478bd9Sstevel@tonic-gate 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 } 1277c478bd9Sstevel@tonic-gate if((term = get_ttymode(i, &ocb, &cb, &stio, &termiox, 1287c478bd9Sstevel@tonic-gate &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 1377c478bd9Sstevel@tonic-gate if((term = get_ttymode(ioctl_desc, &ocb, &cb, &stio, &termiox, &winsize)) < 0) { 1387c478bd9Sstevel@tonic-gate perror(STTY); 1397c478bd9Sstevel@tonic-gate exit(2); 1407c478bd9Sstevel@tonic-gate } 1417c478bd9Sstevel@tonic-gate owinsize = winsize; 1427c478bd9Sstevel@tonic-gate if (argc == 1) { 1437c478bd9Sstevel@tonic-gate prmodes(0); 1447c478bd9Sstevel@tonic-gate exit(0); 1457c478bd9Sstevel@tonic-gate } 1467c478bd9Sstevel@tonic-gate if ((argc ==2) && strcmp(argv[1], "all") ==0) { 1477c478bd9Sstevel@tonic-gate prmodes(1); 1487c478bd9Sstevel@tonic-gate exit(0); 1497c478bd9Sstevel@tonic-gate } 1507c478bd9Sstevel@tonic-gate if ((argc ==2) && strcmp(argv[1], "everything") ==0) { 1517c478bd9Sstevel@tonic-gate pramodes(1); 1527c478bd9Sstevel@tonic-gate exit(0); 1537c478bd9Sstevel@tonic-gate } 1547c478bd9Sstevel@tonic-gate if ((argc == 2) && (argv[1][0] == '-') && (argv[1][2] == '\0')) 1557c478bd9Sstevel@tonic-gate switch(argv[1][1]) { 1567c478bd9Sstevel@tonic-gate case 'a': 1577c478bd9Sstevel@tonic-gate pramodes(0); 1587c478bd9Sstevel@tonic-gate exit(0); 1597c478bd9Sstevel@tonic-gate case 'h': 1607c478bd9Sstevel@tonic-gate pramodes(1); 1617c478bd9Sstevel@tonic-gate exit(0); 1627c478bd9Sstevel@tonic-gate default: 1637c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "%s", USAGE); 1647c478bd9Sstevel@tonic-gate exit(2); 1657c478bd9Sstevel@tonic-gate } 1667c478bd9Sstevel@tonic-gate if (s_arg = sttyparse(argc, argv, term, &ocb, &cb, &termiox, &winsize)) { 1677c478bd9Sstevel@tonic-gate (void) fprintf(stderr, "unknown mode: %s\n", s_arg); 1687c478bd9Sstevel@tonic-gate exit(2); 1697c478bd9Sstevel@tonic-gate } 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate if(set_ttymode(ioctl_desc, term, &ocb, &cb, &stio, &termiox, &winsize, &owinsize) == -1) { 1727c478bd9Sstevel@tonic-gate perror(STTY); 1737c478bd9Sstevel@tonic-gate exit(2); 1747c478bd9Sstevel@tonic-gate } 175*cc6c5292Schin return (0); /*NOTREACHED*/ 1767c478bd9Sstevel@tonic-gate } 1777c478bd9Sstevel@tonic-gate 178*cc6c5292Schin void 179*cc6c5292Schin prmodes(int moremodes) 180*cc6c5292Schin /* print modes, no options, argc is 1 */ 1817c478bd9Sstevel@tonic-gate { 182*cc6c5292Schin int m; 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate if (!(term & ASYNC)) { 1857c478bd9Sstevel@tonic-gate m = stio.imode; 1867c478bd9Sstevel@tonic-gate if (m & IUCLC) (void) fprintf(output, "iuclc "); 1877c478bd9Sstevel@tonic-gate else (void) fprintf(output, "-iuclc "); 1887c478bd9Sstevel@tonic-gate m = stio.omode; 1897c478bd9Sstevel@tonic-gate if (m & OLCUC) (void) fprintf(output, "olcuc "); 1907c478bd9Sstevel@tonic-gate else (void) fprintf(output, "-olcuc "); 1917c478bd9Sstevel@tonic-gate if (m & TAB3) (void) fprintf(output, "tab3 "); 1927c478bd9Sstevel@tonic-gate m = stio.lmode; 1937c478bd9Sstevel@tonic-gate if (m & XCASE) (void) fprintf(output, "xcase "); 1947c478bd9Sstevel@tonic-gate else (void) fprintf(output, "-xcase "); 1957c478bd9Sstevel@tonic-gate if (m & STFLUSH) (void) fprintf(output, "stflush "); 1967c478bd9Sstevel@tonic-gate else (void) fprintf(output, "-stflush "); 1977c478bd9Sstevel@tonic-gate if (m & STWRAP) (void)fprintf(output, "stwrap "); 1987c478bd9Sstevel@tonic-gate else (void) fprintf(output, "-stwrap "); 1997c478bd9Sstevel@tonic-gate if (m & STAPPL) (void) fprintf(output, "stappl "); 2007c478bd9Sstevel@tonic-gate else (void) fprintf(output, "-stappl "); 2017c478bd9Sstevel@tonic-gate (void) fprintf(output, "\n"); 2027c478bd9Sstevel@tonic-gate } 2037c478bd9Sstevel@tonic-gate if (term & ASYNC) { 2047c478bd9Sstevel@tonic-gate m = cb.c_cflag; 2057c478bd9Sstevel@tonic-gate if ((term & TERMIOS) && cfgetispeed(&cb) != 0 && 2067c478bd9Sstevel@tonic-gate cfgetispeed(&cb) != cfgetospeed(&cb)) { 2077c478bd9Sstevel@tonic-gate prspeed("ispeed ", cfgetispeed(&cb)); 2087c478bd9Sstevel@tonic-gate prspeed("ospeed ", cfgetospeed(&cb)); 2097c478bd9Sstevel@tonic-gate } else 2107c478bd9Sstevel@tonic-gate prspeed("speed ", cfgetospeed(&cb)); 2117c478bd9Sstevel@tonic-gate if (m&PARENB) { 2127c478bd9Sstevel@tonic-gate if((m&PAREXT) && (term & TERMIOS)) { 2137c478bd9Sstevel@tonic-gate if (m&PARODD) 2147c478bd9Sstevel@tonic-gate (void) fprintf(output,"markp "); 2157c478bd9Sstevel@tonic-gate else 2167c478bd9Sstevel@tonic-gate (void) fprintf(output,"spacep "); 2177c478bd9Sstevel@tonic-gate } else { 2187c478bd9Sstevel@tonic-gate if (m&PARODD) 2197c478bd9Sstevel@tonic-gate (void) fprintf(output,"oddp "); 2207c478bd9Sstevel@tonic-gate else 2217c478bd9Sstevel@tonic-gate (void) fprintf(output,"evenp "); 2227c478bd9Sstevel@tonic-gate } 2237c478bd9Sstevel@tonic-gate } else 2247c478bd9Sstevel@tonic-gate (void) fprintf(output,"-parity "); 2257c478bd9Sstevel@tonic-gate if(((m&PARENB) && !(m&CS7)) || (!(m&PARENB) && !(m&CS8))) 2267c478bd9Sstevel@tonic-gate (void) fprintf(output,"cs%c ",'5'+(m&CSIZE)/CS6); 2277c478bd9Sstevel@tonic-gate if (m&CSTOPB) 2287c478bd9Sstevel@tonic-gate (void) fprintf(output,"cstopb "); 2297c478bd9Sstevel@tonic-gate if (m&HUPCL) 2307c478bd9Sstevel@tonic-gate (void) fprintf(output,"hupcl "); 2317c478bd9Sstevel@tonic-gate if (!(m&CREAD)) 2327c478bd9Sstevel@tonic-gate (void) fprintf(output,"-cread "); 2337c478bd9Sstevel@tonic-gate if (m&CLOCAL) 2347c478bd9Sstevel@tonic-gate (void) fprintf(output,"clocal "); 2357c478bd9Sstevel@tonic-gate if (m&LOBLK) 2367c478bd9Sstevel@tonic-gate (void) fprintf(output,"loblk "); 2377c478bd9Sstevel@tonic-gate (void) fprintf(output,"\n"); 2387c478bd9Sstevel@tonic-gate if(ocb.c_line != 0) 2397c478bd9Sstevel@tonic-gate (void) fprintf(output,"line = %d; ", ocb.c_line); 2407c478bd9Sstevel@tonic-gate if(term & WINDOW) { 2417c478bd9Sstevel@tonic-gate (void)fprintf(output,"rows = %d; columns = %d;", winsize.ws_row, winsize.ws_col); 2427c478bd9Sstevel@tonic-gate (void)fprintf(output," ypixels = %d; xpixels = %d;\n", winsize.ws_ypixel, winsize.ws_xpixel); 2437c478bd9Sstevel@tonic-gate } 2447c478bd9Sstevel@tonic-gate if((cb.c_lflag&ICANON)== 0) 2457c478bd9Sstevel@tonic-gate (void) fprintf(output,"min = %d; time = %d;\n", 2467c478bd9Sstevel@tonic-gate cb.c_cc[VMIN], cb.c_cc[VTIME]); 2477c478bd9Sstevel@tonic-gate if (!moremodes) { 2487c478bd9Sstevel@tonic-gate if(cb.c_cc[VINTR] != CINTR) 2497c478bd9Sstevel@tonic-gate pit(cb.c_cc[VINTR], "intr", "; "); 2507c478bd9Sstevel@tonic-gate if(cb.c_cc[VQUIT] != CQUIT) 2517c478bd9Sstevel@tonic-gate pit(cb.c_cc[VQUIT], "quit", "; "); 2527c478bd9Sstevel@tonic-gate if(cb.c_cc[VERASE] != CERASE) 2537c478bd9Sstevel@tonic-gate pit(cb.c_cc[VERASE], "erase", "; "); 2547c478bd9Sstevel@tonic-gate if(cb.c_cc[VKILL] != CKILL) 2557c478bd9Sstevel@tonic-gate pit(cb.c_cc[VKILL], "kill", "; "); 2567c478bd9Sstevel@tonic-gate if(cb.c_cc[VEOF] != CEOF) 2577c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOF], "eof", "; "); 2587c478bd9Sstevel@tonic-gate if(cb.c_cc[VEOL] != CNUL) 2597c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOL], "eol", "; "); 2607c478bd9Sstevel@tonic-gate if(cb.c_cc[VEOL2] != CNUL) 2617c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOL2], "eol2", "; "); 2627c478bd9Sstevel@tonic-gate if(cb.c_cc[VSWTCH] != CSWTCH) 2637c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSWTCH], "swtch", "; "); 2647c478bd9Sstevel@tonic-gate if(term & TERMIOS) { 2657c478bd9Sstevel@tonic-gate if(cb.c_cc[VSTART] != CSTART) 2667c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSTART], "start", "; "); 2677c478bd9Sstevel@tonic-gate if(cb.c_cc[VSTOP] != CSTOP) 2687c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSTOP], "stop", "; "); 2697c478bd9Sstevel@tonic-gate if(cb.c_cc[VSUSP] != CSUSP) 2707c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSUSP], "susp", "; "); 2717c478bd9Sstevel@tonic-gate if(cb.c_cc[VDSUSP] != CDSUSP) 2727c478bd9Sstevel@tonic-gate pit(cb.c_cc[VDSUSP], "dsusp", "; "); 2737c478bd9Sstevel@tonic-gate if(cb.c_cc[VREPRINT] != CRPRNT) 2747c478bd9Sstevel@tonic-gate pit(cb.c_cc[VREPRINT], "rprnt", "; "); 2757c478bd9Sstevel@tonic-gate if(cb.c_cc[VDISCARD] != CFLUSH) 2767c478bd9Sstevel@tonic-gate pit(cb.c_cc[VDISCARD], "flush", "; "); 2777c478bd9Sstevel@tonic-gate if(cb.c_cc[VWERASE] != CWERASE) 2787c478bd9Sstevel@tonic-gate pit(cb.c_cc[VWERASE], "werase", "; "); 2797c478bd9Sstevel@tonic-gate if(cb.c_cc[VLNEXT] != CLNEXT) 2807c478bd9Sstevel@tonic-gate pit(cb.c_cc[VLNEXT], "lnext", "; "); 2817c478bd9Sstevel@tonic-gate } 2827c478bd9Sstevel@tonic-gate } 2837c478bd9Sstevel@tonic-gate if(pitt) (void) fprintf(output,"\n"); 2847c478bd9Sstevel@tonic-gate m = cb.c_iflag; 2857c478bd9Sstevel@tonic-gate if (m&IGNBRK) 2867c478bd9Sstevel@tonic-gate (void) fprintf(output,"ignbrk "); 2877c478bd9Sstevel@tonic-gate else if (!(m&BRKINT)) 2887c478bd9Sstevel@tonic-gate (void) fprintf(output,"-brkint "); 2897c478bd9Sstevel@tonic-gate if (!(m&INPCK)) 2907c478bd9Sstevel@tonic-gate (void) fprintf(output,"-inpck "); 2917c478bd9Sstevel@tonic-gate else if (!(m&IGNPAR)) 2927c478bd9Sstevel@tonic-gate (void) fprintf(output,"-ignpar "); 2937c478bd9Sstevel@tonic-gate if (m&PARMRK) 2947c478bd9Sstevel@tonic-gate (void) fprintf(output,"parmrk "); 2957c478bd9Sstevel@tonic-gate if (!(m&ISTRIP)) 2967c478bd9Sstevel@tonic-gate (void) fprintf(output,"-istrip "); 2977c478bd9Sstevel@tonic-gate if (m&INLCR) 2987c478bd9Sstevel@tonic-gate (void) fprintf(output,"inlcr "); 2997c478bd9Sstevel@tonic-gate if (m&IGNCR) 3007c478bd9Sstevel@tonic-gate (void) fprintf(output,"igncr "); 3017c478bd9Sstevel@tonic-gate if (!(m&ICRNL)) 3027c478bd9Sstevel@tonic-gate (void) fprintf(output,"-icrnl "); 3037c478bd9Sstevel@tonic-gate if (m&IUCLC) 3047c478bd9Sstevel@tonic-gate (void) fprintf(output,"iuclc "); 3057c478bd9Sstevel@tonic-gate if (!(m&IXON)) 3067c478bd9Sstevel@tonic-gate (void) fprintf(output,"-ixon "); 3077c478bd9Sstevel@tonic-gate else if (m&IXANY) 3087c478bd9Sstevel@tonic-gate (void) fprintf(output,"ixany "); 3097c478bd9Sstevel@tonic-gate if (m&IXOFF) 3107c478bd9Sstevel@tonic-gate (void) fprintf(output,"ixoff "); 3117c478bd9Sstevel@tonic-gate if ((term & TERMIOS) && (m&IMAXBEL)) 3127c478bd9Sstevel@tonic-gate (void) fprintf(output,"imaxbel "); 3137c478bd9Sstevel@tonic-gate m = cb.c_oflag; 3147c478bd9Sstevel@tonic-gate if (!(m&OPOST)) 3157c478bd9Sstevel@tonic-gate (void) fprintf(output,"-opost "); 3167c478bd9Sstevel@tonic-gate else { 3177c478bd9Sstevel@tonic-gate if (m&OLCUC) 3187c478bd9Sstevel@tonic-gate (void) fprintf(output,"olcuc "); 3197c478bd9Sstevel@tonic-gate if (!(m&ONLCR)) 3207c478bd9Sstevel@tonic-gate (void) fprintf(output,"-onlcr "); 3217c478bd9Sstevel@tonic-gate if (m&OCRNL) 3227c478bd9Sstevel@tonic-gate (void) fprintf(output,"ocrnl "); 3237c478bd9Sstevel@tonic-gate if (m&ONOCR) 3247c478bd9Sstevel@tonic-gate (void) fprintf(output,"onocr "); 3257c478bd9Sstevel@tonic-gate if (m&ONLRET) 3267c478bd9Sstevel@tonic-gate (void) fprintf(output,"onlret "); 3277c478bd9Sstevel@tonic-gate if (m&OFILL) 3287c478bd9Sstevel@tonic-gate if (m&OFDEL) 3297c478bd9Sstevel@tonic-gate (void) fprintf(output,"del-fill "); 3307c478bd9Sstevel@tonic-gate else 3317c478bd9Sstevel@tonic-gate (void) fprintf(output,"nul-fill "); 3327c478bd9Sstevel@tonic-gate delay((m&CRDLY)/CR1, "cr"); 3337c478bd9Sstevel@tonic-gate delay((m&NLDLY)/NL1, "nl"); 3347c478bd9Sstevel@tonic-gate if ((m&TABDLY) == XTABS) 3357c478bd9Sstevel@tonic-gate (void) fprintf(output,"-tabs "); 3367c478bd9Sstevel@tonic-gate else 3377c478bd9Sstevel@tonic-gate delay((m&TABDLY)/TAB1, "tab"); 3387c478bd9Sstevel@tonic-gate delay((m&BSDLY)/BS1, "bs"); 3397c478bd9Sstevel@tonic-gate delay((m&VTDLY)/VT1, "vt"); 3407c478bd9Sstevel@tonic-gate delay((m&FFDLY)/FF1, "ff"); 3417c478bd9Sstevel@tonic-gate } 3427c478bd9Sstevel@tonic-gate (void) fprintf(output,"\n"); 3437c478bd9Sstevel@tonic-gate m = cb.c_lflag; 3447c478bd9Sstevel@tonic-gate if (!(m&ISIG)) 3457c478bd9Sstevel@tonic-gate (void) fprintf(output,"-isig "); 3467c478bd9Sstevel@tonic-gate if (!(m&ICANON)) 3477c478bd9Sstevel@tonic-gate (void) fprintf(output,"-icanon "); 3487c478bd9Sstevel@tonic-gate if (m&XCASE) 3497c478bd9Sstevel@tonic-gate (void) fprintf(output,"xcase "); 3507c478bd9Sstevel@tonic-gate if (!(m&ECHO)) 3517c478bd9Sstevel@tonic-gate (void) fprintf(output,"-echo "); 3527c478bd9Sstevel@tonic-gate if (m&ECHOE) { 3537c478bd9Sstevel@tonic-gate if (m&ECHOKE) 3547c478bd9Sstevel@tonic-gate (void) fprintf(output,"crt "); 3557c478bd9Sstevel@tonic-gate else 3567c478bd9Sstevel@tonic-gate (void) fprintf(output,"echoe -echoke "); 3577c478bd9Sstevel@tonic-gate } else { 3587c478bd9Sstevel@tonic-gate if (!(m&ECHOPRT)) 3597c478bd9Sstevel@tonic-gate (void) fprintf(output,"-echoprt "); 3607c478bd9Sstevel@tonic-gate } 3617c478bd9Sstevel@tonic-gate if (!(m&ECHOK)) 3627c478bd9Sstevel@tonic-gate (void) fprintf(output,"-echok "); 3637c478bd9Sstevel@tonic-gate if (m&ECHONL) 3647c478bd9Sstevel@tonic-gate (void) fprintf(output,"echonl "); 3657c478bd9Sstevel@tonic-gate if (m&NOFLSH) 3667c478bd9Sstevel@tonic-gate (void) fprintf(output,"noflsh "); 3677c478bd9Sstevel@tonic-gate if (m&TOSTOP) 3687c478bd9Sstevel@tonic-gate (void) fprintf(output,"tostop "); 3697c478bd9Sstevel@tonic-gate if (!(m&ECHOCTL)) 3707c478bd9Sstevel@tonic-gate (void) fprintf(output,"-echoctl "); 3717c478bd9Sstevel@tonic-gate if (m&DEFECHO) 3727c478bd9Sstevel@tonic-gate (void) fprintf(output,"defecho "); 3737c478bd9Sstevel@tonic-gate if (m&FLUSHO) 3747c478bd9Sstevel@tonic-gate (void) fprintf(output,"flusho "); 3757c478bd9Sstevel@tonic-gate if (m&PENDIN) 3767c478bd9Sstevel@tonic-gate (void) fprintf(output,"pendin "); 3777c478bd9Sstevel@tonic-gate if (m&IEXTEN) 3787c478bd9Sstevel@tonic-gate (void) fprintf(output,"iexten "); 3797c478bd9Sstevel@tonic-gate (void) fprintf(output,"\n"); 3807c478bd9Sstevel@tonic-gate } 3817c478bd9Sstevel@tonic-gate if(term & FLOW) { 3827c478bd9Sstevel@tonic-gate m = termiox.x_hflag; 3837c478bd9Sstevel@tonic-gate if(m & RTSXOFF) 3847c478bd9Sstevel@tonic-gate (void) fprintf(output,"rtsxoff "); 3857c478bd9Sstevel@tonic-gate if(m & CTSXON) 3867c478bd9Sstevel@tonic-gate (void) fprintf(output,"ctsxon "); 3877c478bd9Sstevel@tonic-gate if(m & DTRXOFF) 3887c478bd9Sstevel@tonic-gate (void) fprintf(output,"dterxoff "); 3897c478bd9Sstevel@tonic-gate if(m & CDXON) 3907c478bd9Sstevel@tonic-gate (void) fprintf(output,"rlsdxon "); 3917c478bd9Sstevel@tonic-gate if(m & ISXOFF) 3927c478bd9Sstevel@tonic-gate (void) fprintf(output,"isxoff "); 3937c478bd9Sstevel@tonic-gate m = termiox.x_cflag; 3947c478bd9Sstevel@tonic-gate switch(m & XMTCLK) 3957c478bd9Sstevel@tonic-gate { 3967c478bd9Sstevel@tonic-gate case XCIBRG: (void)fprintf(output,"xcibrg "); 3977c478bd9Sstevel@tonic-gate break; 3987c478bd9Sstevel@tonic-gate case XCTSET: (void)fprintf(output,"xctset "); 3997c478bd9Sstevel@tonic-gate break; 4007c478bd9Sstevel@tonic-gate case XCRSET: (void)fprintf(output,"xcrset "); 4017c478bd9Sstevel@tonic-gate } 4027c478bd9Sstevel@tonic-gate 4037c478bd9Sstevel@tonic-gate switch(m & RCVCLK) 4047c478bd9Sstevel@tonic-gate { 4057c478bd9Sstevel@tonic-gate case RCIBRG: (void)fprintf(output,"rcibrg "); 4067c478bd9Sstevel@tonic-gate break; 4077c478bd9Sstevel@tonic-gate case RCTSET: (void)fprintf(output,"rctset "); 4087c478bd9Sstevel@tonic-gate break; 4097c478bd9Sstevel@tonic-gate case RCRSET: (void)fprintf(output,"rcrset "); 4107c478bd9Sstevel@tonic-gate } 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate switch(m & TSETCLK) 4137c478bd9Sstevel@tonic-gate { 4147c478bd9Sstevel@tonic-gate case TSETCOFF: (void)fprintf(output,"tsetcoff "); 4157c478bd9Sstevel@tonic-gate break; 4167c478bd9Sstevel@tonic-gate case TSETCRBRG: (void)fprintf(output,"tsetcrc "); 4177c478bd9Sstevel@tonic-gate break; 4187c478bd9Sstevel@tonic-gate case TSETCTBRG: (void)fprintf(output,"tsetcxc "); 4197c478bd9Sstevel@tonic-gate } 4207c478bd9Sstevel@tonic-gate 4217c478bd9Sstevel@tonic-gate switch(m & RSETCLK) 4227c478bd9Sstevel@tonic-gate { 4237c478bd9Sstevel@tonic-gate case RSETCOFF: (void)fprintf(output,"rsetcoff "); 4247c478bd9Sstevel@tonic-gate break; 4257c478bd9Sstevel@tonic-gate case RSETCRBRG: (void)fprintf(output,"rsetcrc "); 4267c478bd9Sstevel@tonic-gate break; 4277c478bd9Sstevel@tonic-gate case RSETCTBRG: (void)fprintf(output,"rsetcxc "); 4287c478bd9Sstevel@tonic-gate } 4297c478bd9Sstevel@tonic-gate (void) fprintf(output,"\n"); 4307c478bd9Sstevel@tonic-gate } 4317c478bd9Sstevel@tonic-gate if(moremodes) 4327c478bd9Sstevel@tonic-gate prachars(); 4337c478bd9Sstevel@tonic-gate } 4347c478bd9Sstevel@tonic-gate 435*cc6c5292Schin void 436*cc6c5292Schin pramodes(int tabform) 437*cc6c5292Schin /* print all modes, -a option */ 4387c478bd9Sstevel@tonic-gate { 439*cc6c5292Schin int m; 4407c478bd9Sstevel@tonic-gate 4417c478bd9Sstevel@tonic-gate m = cb.c_cflag; 4427c478bd9Sstevel@tonic-gate if(term & ASYNC) { 4437c478bd9Sstevel@tonic-gate if ((term & TERMIOS) && cfgetispeed(&cb) != 0 && 4447c478bd9Sstevel@tonic-gate cfgetispeed(&cb) != cfgetospeed(&cb)) { 4457c478bd9Sstevel@tonic-gate prspeed("ispeed ", cfgetispeed(&cb)); 4467c478bd9Sstevel@tonic-gate prspeed("ospeed ", cfgetospeed(&cb)); 4477c478bd9Sstevel@tonic-gate } else 4487c478bd9Sstevel@tonic-gate prspeed("speed ", cfgetospeed(&cb)); 4497c478bd9Sstevel@tonic-gate if(!(term & TERMIOS)) 4507c478bd9Sstevel@tonic-gate (void) fprintf(output,"line = %d; ", ocb.c_line); 4517c478bd9Sstevel@tonic-gate (void) fprintf(output,"\n"); 4527c478bd9Sstevel@tonic-gate if(term & WINDOW) { 4537c478bd9Sstevel@tonic-gate (void)fprintf(output,"rows = %d columns = %d; ", winsize.ws_row, winsize.ws_col); 4547c478bd9Sstevel@tonic-gate (void)fprintf(output,"ypixels = %d xpixels = %d\n", winsize.ws_ypixel, winsize.ws_xpixel); 4557c478bd9Sstevel@tonic-gate } 4567c478bd9Sstevel@tonic-gate if((cb.c_lflag&ICANON)== 0) 4577c478bd9Sstevel@tonic-gate (void) fprintf(output,"min = %d; time = %d;\n", cb.c_cc[VMIN], 4587c478bd9Sstevel@tonic-gate cb.c_cc[VTIME]); 4597c478bd9Sstevel@tonic-gate if (!tabform) { 4607c478bd9Sstevel@tonic-gate pit(cb.c_cc[VINTR], "intr", "; "); 4617c478bd9Sstevel@tonic-gate pit(cb.c_cc[VQUIT], "quit", "; "); 4627c478bd9Sstevel@tonic-gate pit(cb.c_cc[VERASE], "erase", "; "); 4637c478bd9Sstevel@tonic-gate pit(cb.c_cc[VKILL], "kill", ";\n"); 4647c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOF], "eof", "; "); 4657c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOL], "eol", "; "); 4667c478bd9Sstevel@tonic-gate pit(cb.c_cc[VEOL2], "eol2", "; "); 4677c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSWTCH], "swtch", ";\n"); 4687c478bd9Sstevel@tonic-gate if(term & TERMIOS) { 4697c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSTART], "start", "; "); 4707c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSTOP], "stop", "; "); 4717c478bd9Sstevel@tonic-gate pit(cb.c_cc[VSUSP], "susp", "; "); 4727c478bd9Sstevel@tonic-gate pit(cb.c_cc[VDSUSP], "dsusp", ";\n"); 4737c478bd9Sstevel@tonic-gate pit(cb.c_cc[VREPRINT], "rprnt", "; "); 4747c478bd9Sstevel@tonic-gate pit(cb.c_cc[VDISCARD], "flush", "; "); 4757c478bd9Sstevel@tonic-gate pit(cb.c_cc[VWERASE], "werase", "; "); 4767c478bd9Sstevel@tonic-gate pit(cb.c_cc[VLNEXT], "lnext", ";\n"); 4777c478bd9Sstevel@tonic-gate } 4787c478bd9Sstevel@tonic-gate } 4797c478bd9Sstevel@tonic-gate } else 4807c478bd9Sstevel@tonic-gate pit((unsigned)stio.tab, "ctab", "\n"); 4817c478bd9Sstevel@tonic-gate m = cb.c_cflag; 4827c478bd9Sstevel@tonic-gate (void) fprintf(output,"-parenb "+((m&PARENB)!=0)); 4837c478bd9Sstevel@tonic-gate (void) fprintf(output,"-parodd "+((m&PARODD)!=0)); 4847c478bd9Sstevel@tonic-gate (void) fprintf(output,"cs%c ",'5'+(m&CSIZE)/CS6); 4857c478bd9Sstevel@tonic-gate (void) fprintf(output,"-cstopb "+((m&CSTOPB)!=0)); 4867c478bd9Sstevel@tonic-gate (void) fprintf(output,"-hupcl "+((m&HUPCL)!=0)); 4877c478bd9Sstevel@tonic-gate (void) fprintf(output,"-cread "+((m&CREAD)!=0)); 4887c478bd9Sstevel@tonic-gate (void) fprintf(output,"-clocal "+((m&CLOCAL)!=0)); 4897c478bd9Sstevel@tonic-gate 4907c478bd9Sstevel@tonic-gate (void) fprintf(output,"-loblk "+((m&LOBLK)!=0)); 4917c478bd9Sstevel@tonic-gate if(term & TERMIOS) 4927c478bd9Sstevel@tonic-gate (void) fprintf(output,"-parext "+((m&PAREXT)!=0)); 4937c478bd9Sstevel@tonic-gate 4947c478bd9Sstevel@tonic-gate (void) fprintf(output,"\n"); 4957c478bd9Sstevel@tonic-gate m = cb.c_iflag; 4967c478bd9Sstevel@tonic-gate (void) fprintf(output,"-ignbrk "+((m&IGNBRK)!=0)); 4977c478bd9Sstevel@tonic-gate (void) fprintf(output,"-brkint "+((m&BRKINT)!=0)); 4987c478bd9Sstevel@tonic-gate (void) fprintf(output,"-ignpar "+((m&IGNPAR)!=0)); 4997c478bd9Sstevel@tonic-gate (void) fprintf(output,"-parmrk "+((m&PARMRK)!=0)); 5007c478bd9Sstevel@tonic-gate (void) fprintf(output,"-inpck "+((m&INPCK)!=0)); 5017c478bd9Sstevel@tonic-gate (void) fprintf(output,"-istrip "+((m&ISTRIP)!=0)); 5027c478bd9Sstevel@tonic-gate (void) fprintf(output,"-inlcr "+((m&INLCR)!=0)); 5037c478bd9Sstevel@tonic-gate (void) fprintf(output,"-igncr "+((m&IGNCR)!=0)); 5047c478bd9Sstevel@tonic-gate (void) fprintf(output,"-icrnl "+((m&ICRNL)!=0)); 5057c478bd9Sstevel@tonic-gate (void) fprintf(output,"-iuclc "+((m&IUCLC)!=0)); 5067c478bd9Sstevel@tonic-gate (void) fprintf(output,"\n"); 5077c478bd9Sstevel@tonic-gate (void) fprintf(output,"-ixon "+((m&IXON)!=0)); 5087c478bd9Sstevel@tonic-gate (void) fprintf(output,"-ixany "+((m&IXANY)!=0)); 5097c478bd9Sstevel@tonic-gate (void) fprintf(output,"-ixoff "+((m&IXOFF)!=0)); 5107c478bd9Sstevel@tonic-gate if(term & TERMIOS) 5117c478bd9Sstevel@tonic-gate (void) fprintf(output,"-imaxbel "+((m&IMAXBEL)!=0)); 5127c478bd9Sstevel@tonic-gate (void) fprintf(output,"\n"); 5137c478bd9Sstevel@tonic-gate m = cb.c_lflag; 5147c478bd9Sstevel@tonic-gate (void) fprintf(output,"-isig "+((m&ISIG)!=0)); 5157c478bd9Sstevel@tonic-gate (void) fprintf(output,"-icanon "+((m&ICANON)!=0)); 5167c478bd9Sstevel@tonic-gate (void) fprintf(output,"-xcase "+((m&XCASE)!=0)); 5177c478bd9Sstevel@tonic-gate (void) fprintf(output,"-echo "+((m&ECHO)!=0)); 5187c478bd9Sstevel@tonic-gate (void) fprintf(output,"-echoe "+((m&ECHOE)!=0)); 5197c478bd9Sstevel@tonic-gate (void) fprintf(output,"-echok "+((m&ECHOK)!=0)); 5207c478bd9Sstevel@tonic-gate (void) fprintf(output,"-echonl "+((m&ECHONL)!=0)); 5217c478bd9Sstevel@tonic-gate (void) fprintf(output,"-noflsh "+((m&NOFLSH)!=0)); 5227c478bd9Sstevel@tonic-gate if(term & TERMIOS) { 5237c478bd9Sstevel@tonic-gate (void) fprintf(output,"\n"); 5247c478bd9Sstevel@tonic-gate (void) fprintf(output,"-tostop "+((m&TOSTOP)!=0)); 5257c478bd9Sstevel@tonic-gate (void) fprintf(output,"-echoctl "+((m&ECHOCTL)!=0)); 5267c478bd9Sstevel@tonic-gate (void) fprintf(output,"-echoprt "+((m&ECHOPRT)!=0)); 5277c478bd9Sstevel@tonic-gate (void) fprintf(output,"-echoke "+((m&ECHOKE)!=0)); 5287c478bd9Sstevel@tonic-gate (void) fprintf(output,"-defecho "+((m&DEFECHO)!=0)); 5297c478bd9Sstevel@tonic-gate (void) fprintf(output,"-flusho "+((m&FLUSHO)!=0)); 5307c478bd9Sstevel@tonic-gate (void) fprintf(output,"-pendin "+((m&PENDIN)!=0)); 5317c478bd9Sstevel@tonic-gate (void) fprintf(output,"-iexten "+((m&IEXTEN)!=0)); 5327c478bd9Sstevel@tonic-gate } 5337c478bd9Sstevel@tonic-gate if(!(term & ASYNC)) { 5347c478bd9Sstevel@tonic-gate (void) fprintf(output,"-stflush "+((m&STFLUSH)!=0)); 5357c478bd9Sstevel@tonic-gate (void) fprintf(output,"-stwrap "+((m&STWRAP)!=0)); 5367c478bd9Sstevel@tonic-gate (void) fprintf(output,"-stappl "+((m&STAPPL)!=0)); 5377c478bd9Sstevel@tonic-gate } 5387c478bd9Sstevel@tonic-gate (void) fprintf(output,"\n"); 5397c478bd9Sstevel@tonic-gate m = cb.c_oflag; 5407c478bd9Sstevel@tonic-gate (void) fprintf(output,"-opost "+((m&OPOST)!=0)); 5417c478bd9Sstevel@tonic-gate (void) fprintf(output,"-olcuc "+((m&OLCUC)!=0)); 5427c478bd9Sstevel@tonic-gate (void) fprintf(output,"-onlcr "+((m&ONLCR)!=0)); 5437c478bd9Sstevel@tonic-gate (void) fprintf(output,"-ocrnl "+((m&OCRNL)!=0)); 5447c478bd9Sstevel@tonic-gate (void) fprintf(output,"-onocr "+((m&ONOCR)!=0)); 5457c478bd9Sstevel@tonic-gate (void) fprintf(output,"-onlret "+((m&ONLRET)!=0)); 5467c478bd9Sstevel@tonic-gate (void) fprintf(output,"-ofill "+((m&OFILL)!=0)); 5477c478bd9Sstevel@tonic-gate (void) fprintf(output,"-ofdel "+((m&OFDEL)!=0)); 5487c478bd9Sstevel@tonic-gate delay((m&CRDLY)/CR1, "cr"); 5497c478bd9Sstevel@tonic-gate delay((m&NLDLY)/NL1, "nl"); 5507c478bd9Sstevel@tonic-gate if ((m&TABDLY) == XTABS) 5517c478bd9Sstevel@tonic-gate (void) fprintf(output,"-tabs "); 5527c478bd9Sstevel@tonic-gate else 5537c478bd9Sstevel@tonic-gate delay((m&TABDLY)/TAB1, "tab"); 5547c478bd9Sstevel@tonic-gate delay((m&BSDLY)/BS1, "bs"); 5557c478bd9Sstevel@tonic-gate delay((m&VTDLY)/VT1, "vt"); 5567c478bd9Sstevel@tonic-gate delay((m&FFDLY)/FF1, "ff"); 5577c478bd9Sstevel@tonic-gate (void) fprintf(output,"\n"); 5587c478bd9Sstevel@tonic-gate if(term & FLOW) { 5597c478bd9Sstevel@tonic-gate m = termiox.x_hflag; 5607c478bd9Sstevel@tonic-gate (void) fprintf(output,"-rtsxoff "+((m&RTSXOFF)!=0)); 5617c478bd9Sstevel@tonic-gate (void) fprintf(output,"-ctsxon "+((m&CTSXON)!=0)); 5627c478bd9Sstevel@tonic-gate (void) fprintf(output,"-dterxoff "+((m&DTRXOFF)!=0)); 5637c478bd9Sstevel@tonic-gate (void) fprintf(output,"-rlsdxon "+((m&CDXON)!=0)); 5647c478bd9Sstevel@tonic-gate (void) fprintf(output,"-isxoff "+((m&ISXOFF)!=0)); 5657c478bd9Sstevel@tonic-gate m = termiox.x_cflag; 5667c478bd9Sstevel@tonic-gate switch(m & XMTCLK) 5677c478bd9Sstevel@tonic-gate { 5687c478bd9Sstevel@tonic-gate case XCIBRG: (void)fprintf(output,"xcibrg "); 5697c478bd9Sstevel@tonic-gate break; 5707c478bd9Sstevel@tonic-gate case XCTSET: (void)fprintf(output,"xctset "); 5717c478bd9Sstevel@tonic-gate break; 5727c478bd9Sstevel@tonic-gate case XCRSET: (void)fprintf(output,"xcrset "); 5737c478bd9Sstevel@tonic-gate } 5747c478bd9Sstevel@tonic-gate 5757c478bd9Sstevel@tonic-gate switch(m & RCVCLK) 5767c478bd9Sstevel@tonic-gate { 5777c478bd9Sstevel@tonic-gate case RCIBRG: (void)fprintf(output,"rcibrg "); 5787c478bd9Sstevel@tonic-gate break; 5797c478bd9Sstevel@tonic-gate case RCTSET: (void)fprintf(output,"rctset "); 5807c478bd9Sstevel@tonic-gate break; 5817c478bd9Sstevel@tonic-gate case RCRSET: (void)fprintf(output,"rcrset "); 5827c478bd9Sstevel@tonic-gate } 5837c478bd9Sstevel@tonic-gate 5847c478bd9Sstevel@tonic-gate switch(m & TSETCLK) 5857c478bd9Sstevel@tonic-gate { 5867c478bd9Sstevel@tonic-gate case TSETCOFF: (void)fprintf(output,"tsetcoff "); 5877c478bd9Sstevel@tonic-gate break; 5887c478bd9Sstevel@tonic-gate case TSETCRBRG: (void)fprintf(output,"tsetcrc "); 5897c478bd9Sstevel@tonic-gate break; 5907c478bd9Sstevel@tonic-gate case TSETCTBRG: (void)fprintf(output,"tsetcxc "); 5917c478bd9Sstevel@tonic-gate } 5927c478bd9Sstevel@tonic-gate 5937c478bd9Sstevel@tonic-gate switch(m & RSETCLK) 5947c478bd9Sstevel@tonic-gate { 5957c478bd9Sstevel@tonic-gate case RSETCOFF: (void)fprintf(output,"rsetcoff "); 5967c478bd9Sstevel@tonic-gate break; 5977c478bd9Sstevel@tonic-gate case RSETCRBRG: (void)fprintf(output,"rsetcrc "); 5987c478bd9Sstevel@tonic-gate break; 5997c478bd9Sstevel@tonic-gate case RSETCTBRG: (void)fprintf(output,"rsetcxc "); 6007c478bd9Sstevel@tonic-gate } 6017c478bd9Sstevel@tonic-gate (void) fprintf(output,"\n"); 6027c478bd9Sstevel@tonic-gate } 6037c478bd9Sstevel@tonic-gate if (tabform) 6047c478bd9Sstevel@tonic-gate prachars(); 6057c478bd9Sstevel@tonic-gate } 6067c478bd9Sstevel@tonic-gate 607*cc6c5292Schin void 608*cc6c5292Schin prachars(void) 6097c478bd9Sstevel@tonic-gate { 6107c478bd9Sstevel@tonic-gate if ((cb.c_lflag&ICANON)==0) 6117c478bd9Sstevel@tonic-gate (void) fprintf(output,"min %d, time %d\n", cb.c_cc[VMIN], 6127c478bd9Sstevel@tonic-gate cb.c_cc[VTIME]); 6137c478bd9Sstevel@tonic-gate (void) fprintf(output,"\ 6147c478bd9Sstevel@tonic-gate erase kill werase rprnt flush lnext susp intr quit stop eof\ 6157c478bd9Sstevel@tonic-gate \n"); 6167c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VERASE], 0); 6177c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VKILL], 0); 6187c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VWERASE], 0); 6197c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VREPRINT], 0); 6207c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VDISCARD], 0); 6217c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VLNEXT], 0); 6227c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VSUSP], cb.c_cc[VDSUSP]); 6237c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VINTR], 0); 6247c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VQUIT], 0); 6257c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VSTOP], cb.c_cc[VSTART]); 6267c478bd9Sstevel@tonic-gate if (cb.c_lflag&ICANON) 6277c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VEOF], cb.c_cc[VEOL]); 6287c478bd9Sstevel@tonic-gate (void) fprintf(output,"\n"); 6297c478bd9Sstevel@tonic-gate if (cb.c_cc[VEOL2] != 0 || cb.c_cc[VSWTCH] != 0) { 6307c478bd9Sstevel@tonic-gate (void) fprintf(output,"\ 6317c478bd9Sstevel@tonic-gate eol2 swtch\ 6327c478bd9Sstevel@tonic-gate \n"); 6337c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VEOL2], 0); 6347c478bd9Sstevel@tonic-gate pcol(cb.c_cc[VSWTCH], 0); 6357c478bd9Sstevel@tonic-gate (void) fprintf(output,"\n"); 6367c478bd9Sstevel@tonic-gate } 6377c478bd9Sstevel@tonic-gate } 6387c478bd9Sstevel@tonic-gate 639*cc6c5292Schin void 640*cc6c5292Schin pcol(int ch1, int ch2) 6417c478bd9Sstevel@tonic-gate { 6427c478bd9Sstevel@tonic-gate int nout = 0; 6437c478bd9Sstevel@tonic-gate 6447c478bd9Sstevel@tonic-gate ch1 &= 0377; 6457c478bd9Sstevel@tonic-gate ch2 &= 0377; 6467c478bd9Sstevel@tonic-gate if (ch1 == ch2) 6477c478bd9Sstevel@tonic-gate ch2 = 0; 6487c478bd9Sstevel@tonic-gate for (; ch1 != 0 || ch2 != 0; ch1 = ch2, ch2 = 0) { 6497c478bd9Sstevel@tonic-gate if (ch1 == 0) 6507c478bd9Sstevel@tonic-gate continue; 6517c478bd9Sstevel@tonic-gate if (ch1 & 0200 && !isprint(ch1)) { 6527c478bd9Sstevel@tonic-gate (void) fprintf(output,"M-"); 6537c478bd9Sstevel@tonic-gate nout += 2; 6547c478bd9Sstevel@tonic-gate ch1 &= ~ 0200; 6557c478bd9Sstevel@tonic-gate } 6567c478bd9Sstevel@tonic-gate if (ch1 == 0177) { 6577c478bd9Sstevel@tonic-gate (void) fprintf(output,"^"); 6587c478bd9Sstevel@tonic-gate nout++; 6597c478bd9Sstevel@tonic-gate ch1 = '?'; 6607c478bd9Sstevel@tonic-gate } else if (ch1 < ' ') { 6617c478bd9Sstevel@tonic-gate (void) fprintf(output,"^"); 6627c478bd9Sstevel@tonic-gate nout++; 6637c478bd9Sstevel@tonic-gate ch1 += '@'; 6647c478bd9Sstevel@tonic-gate } 6657c478bd9Sstevel@tonic-gate (void) fprintf(output,"%c", ch1); 6667c478bd9Sstevel@tonic-gate nout++; 6677c478bd9Sstevel@tonic-gate if (ch2 != 0) { 6687c478bd9Sstevel@tonic-gate (void) fprintf(output,"/"); 6697c478bd9Sstevel@tonic-gate nout++; 6707c478bd9Sstevel@tonic-gate } 6717c478bd9Sstevel@tonic-gate } 6727c478bd9Sstevel@tonic-gate while (nout < 7) { 6737c478bd9Sstevel@tonic-gate (void) fprintf(output," "); 6747c478bd9Sstevel@tonic-gate nout++; 6757c478bd9Sstevel@tonic-gate } 6767c478bd9Sstevel@tonic-gate } 6777c478bd9Sstevel@tonic-gate 678*cc6c5292Schin void 679*cc6c5292Schin pit(unsigned char what, char *itsname, char *sep) 680*cc6c5292Schin /* print function for prmodes() and pramodes() */ 6817c478bd9Sstevel@tonic-gate { 6827c478bd9Sstevel@tonic-gate 6837c478bd9Sstevel@tonic-gate pitt++; 6847c478bd9Sstevel@tonic-gate (void) fprintf(output,"%s", itsname); 6857c478bd9Sstevel@tonic-gate if ((term & TERMIOS) && what == _POSIX_VDISABLE || !(term & TERMIOS) && what == 0200) { 6867c478bd9Sstevel@tonic-gate (void) fprintf(output," = <undef>%s", sep); 6877c478bd9Sstevel@tonic-gate return; 6887c478bd9Sstevel@tonic-gate } 6897c478bd9Sstevel@tonic-gate (void) fprintf(output," = "); 6907c478bd9Sstevel@tonic-gate if (what & 0200 && !isprint(what)) { 6917c478bd9Sstevel@tonic-gate (void) fprintf(output,"-"); 6927c478bd9Sstevel@tonic-gate what &= ~ 0200; 6937c478bd9Sstevel@tonic-gate } 6947c478bd9Sstevel@tonic-gate if (what == 0177) { 6957c478bd9Sstevel@tonic-gate (void) fprintf(output,"^?%s", sep); 6967c478bd9Sstevel@tonic-gate return; 6977c478bd9Sstevel@tonic-gate } else if (what < ' ') { 6987c478bd9Sstevel@tonic-gate (void) fprintf(output,"^"); 6997c478bd9Sstevel@tonic-gate what += '`'; 7007c478bd9Sstevel@tonic-gate } 7017c478bd9Sstevel@tonic-gate (void) fprintf(output,"%c%s", what, sep); 7027c478bd9Sstevel@tonic-gate } 7037c478bd9Sstevel@tonic-gate 704*cc6c5292Schin void 705*cc6c5292Schin delay(int m, char *s) 7067c478bd9Sstevel@tonic-gate { 7077c478bd9Sstevel@tonic-gate if(m) 7087c478bd9Sstevel@tonic-gate (void) fprintf(output,"%s%d ", s, m); 7097c478bd9Sstevel@tonic-gate } 7107c478bd9Sstevel@tonic-gate 7117c478bd9Sstevel@tonic-gate long speed[] = { 7127c478bd9Sstevel@tonic-gate 0,50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,19200,38400, 7137c478bd9Sstevel@tonic-gate 57600,76800,115200,153600,230400,307200,460800 7147c478bd9Sstevel@tonic-gate }; 7157c478bd9Sstevel@tonic-gate 716*cc6c5292Schin void 717*cc6c5292Schin prspeed(char *c, int s) 7187c478bd9Sstevel@tonic-gate { 7197c478bd9Sstevel@tonic-gate 7207c478bd9Sstevel@tonic-gate (void) fprintf(output,"%s%d baud; ", c, speed[s]); 7217c478bd9Sstevel@tonic-gate } 7227c478bd9Sstevel@tonic-gate 723*cc6c5292Schin /* 724*cc6c5292Schin * print current settings for use with 725*cc6c5292Schin * another stty cmd, used for -g option 726*cc6c5292Schin */ 727*cc6c5292Schin void 728*cc6c5292Schin prencode(void) 7297c478bd9Sstevel@tonic-gate { 7307c478bd9Sstevel@tonic-gate int i, last; 7317c478bd9Sstevel@tonic-gate 732*cc6c5292Schin /* Since the -g option is mostly used for redirecting to a file */ 7337c478bd9Sstevel@tonic-gate /* We must print to stdout here, not stderr */ 7347c478bd9Sstevel@tonic-gate 7357c478bd9Sstevel@tonic-gate (void) printf("%x:%x:%x:%x:",cb.c_iflag,cb.c_oflag,cb.c_cflag,cb.c_lflag); 7367c478bd9Sstevel@tonic-gate 7377c478bd9Sstevel@tonic-gate if(term & TERMIOS) 7387c478bd9Sstevel@tonic-gate /* last control slot is unused */ 7397c478bd9Sstevel@tonic-gate last = NCCS - 2; 7407c478bd9Sstevel@tonic-gate else 7417c478bd9Sstevel@tonic-gate last = NCC - 1; 7427c478bd9Sstevel@tonic-gate for(i = 0; i < last; i++) 7437c478bd9Sstevel@tonic-gate (void) printf("%x:", cb.c_cc[i]); 7447c478bd9Sstevel@tonic-gate (void) printf("%x\n", cb.c_cc[last]); 7457c478bd9Sstevel@tonic-gate } 746