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