113073Ssam #ifndef lint 2*18023Sbloom static char *sccsid ="@(#)stty.c 4.15 (Berkeley) 02/20/85"; 313073Ssam #endif 41179Sbill /* 51179Sbill * set teletype modes 61179Sbill */ 71179Sbill 81179Sbill #include <stdio.h> 9*18023Sbloom #include <sys/ioctl.h> 101179Sbill 1113073Ssam struct 1213073Ssam { 131179Sbill char *string; 141179Sbill int speed; 151179Sbill } speeds[] = { 1613073Ssam "0", B0, 1713073Ssam "50", B50, 1813073Ssam "75", B75, 1913073Ssam "110", B110, 2013073Ssam "134", B134, 2113073Ssam "134.5",B134, 2213073Ssam "150", B150, 2313073Ssam "200", B200, 2413073Ssam "300", B300, 2513073Ssam "600", B600, 2613073Ssam "1200", B1200, 2713073Ssam "1800", B1800, 2813073Ssam "2400", B2400, 2913073Ssam "4800", B4800, 3013073Ssam "9600", B9600, 3113073Ssam "exta", EXTA, 3213073Ssam "19200", EXTA, 3313073Ssam "extb", EXTB, 3413073Ssam "38400", EXTB, 3513073Ssam 0, 361179Sbill }; 3713073Ssam struct 3813073Ssam { 391179Sbill char *string; 4013073Ssam int set; 4113073Ssam int reset; 4213073Ssam int lset; 4313073Ssam int lreset; 441179Sbill } modes[] = { 4513073Ssam "even", EVENP, 0, 0, 0, 4613073Ssam "-even", 0, EVENP, 0, 0, 4713073Ssam "odd", ODDP, 0, 0, 0, 4813073Ssam "-odd", 0, ODDP, 0, 0, 4913073Ssam "raw", RAW, 0, 0, 0, 5013073Ssam "-raw", 0, RAW, 0, 0, 5113073Ssam "cooked", 0, RAW, 0, 0, 5213073Ssam "-nl", CRMOD, 0, 0, 0, 5313073Ssam "nl", 0, CRMOD, 0, 0, 5413073Ssam "echo", ECHO, 0, 0, 0, 5513073Ssam "-echo", 0, ECHO, 0, 0, 5613073Ssam "LCASE", LCASE, 0, 0, 0, 5713073Ssam "lcase", LCASE, 0, 0, 0, 5813073Ssam "-LCASE", 0, LCASE, 0, 0, 5913073Ssam "-lcase", 0, LCASE, 0, 0, 6013073Ssam "-tabs", XTABS, 0, 0, 0, 6113073Ssam "tabs", 0, XTABS, 0, 0, 6213073Ssam "tandem", TANDEM, 0, 0, 0, 6313073Ssam "-tandem", 0, TANDEM, 0, 0, 6413073Ssam "cbreak", CBREAK, 0, 0, 0, 6513073Ssam "-cbreak", 0, CBREAK, 0, 0, 6613073Ssam "cr0", CR0, CR3, 0, 0, 6713073Ssam "cr1", CR1, CR3, 0, 0, 6813073Ssam "cr2", CR2, CR3, 0, 0, 6913073Ssam "cr3", CR3, CR3, 0, 0, 7013073Ssam "tab0", TAB0, XTABS, 0, 0, 7113073Ssam "tab1", TAB1, XTABS, 0, 0, 7213073Ssam "tab2", TAB2, XTABS, 0, 0, 7313073Ssam "nl0", NL0, NL3, 0, 0, 7413073Ssam "nl1", NL1, NL3, 0, 0, 7513073Ssam "nl2", NL2, NL3, 0, 0, 7613073Ssam "nl3", NL3, NL3, 0, 0, 7713073Ssam "ff0", FF0, FF1, 0, 0, 7813073Ssam "ff1", FF1, FF1, 0, 0, 7913073Ssam "bs0", BS0, BS1, 0, 0, 8013073Ssam "bs1", BS1, BS1, 0, 0, 8113073Ssam "33", CR1, ALLDELAY, 0, 0, 8213073Ssam "tty33", CR1, ALLDELAY, 0, 0, 8313073Ssam "37", FF1+CR2+TAB1+NL1, ALLDELAY, 0, 0, 8413073Ssam "tty37", FF1+CR2+TAB1+NL1, ALLDELAY, 0, 0, 8513073Ssam "05", NL2, ALLDELAY, 0, 0, 8613073Ssam "vt05", NL2, ALLDELAY, 0, 0, 8713073Ssam "tn", CR1, ALLDELAY, 0, 0, 8813073Ssam "tn300", CR1, ALLDELAY, 0, 0, 8913073Ssam "ti", CR2, ALLDELAY, 0, 0, 9013073Ssam "ti700", CR2, ALLDELAY, 0, 0, 9113073Ssam "tek", FF1, ALLDELAY, 0, 0, 9213073Ssam "crtbs", 0, 0, LCRTBS, LPRTERA, 9313073Ssam "-crtbs", 0, 0, 0, LCRTBS, 9413073Ssam "prterase", 0, 0, LPRTERA, LCRTBS+LCRTKIL+LCRTERA, 9513073Ssam "-prterase", 0, 0, 0, LPRTERA, 9613073Ssam "crterase", 0, 0, LCRTERA, LPRTERA, 9713073Ssam "-crterase", 0, 0, 0, LCRTERA, 9813073Ssam "crtkill", 0, 0, LCRTKIL, LPRTERA, 9913073Ssam "-crtkill", 0, 0, 0, LCRTKIL, 10013073Ssam "tilde", 0, 0, LTILDE, 0, 10113073Ssam "-tilde", 0, 0, 0, LTILDE, 10213073Ssam "mdmbuf", 0, 0, LMDMBUF, 0, 10313073Ssam "-mdmbuf", 0, 0, 0, LMDMBUF, 10413073Ssam "litout", 0, 0, LLITOUT, 0, 10513073Ssam "-litout", 0, 0, 0, LLITOUT, 10613073Ssam "tostop", 0, 0, LTOSTOP, 0, 10713073Ssam "-tostop", 0, 0, 0, LTOSTOP, 10813073Ssam "flusho", 0, 0, LFLUSHO, 0, 10913073Ssam "-flusho", 0, 0, 0, LFLUSHO, 11013073Ssam "nohang", 0, 0, LNOHANG, 0, 11113073Ssam "-nohang", 0, 0, 0, LNOHANG, 1129853Ssam #ifdef notdef 11313073Ssam "etxack", 0, 0, LETXACK, 0, 11413073Ssam "-etxack", 0, 0, 0, LETXACK, 1159853Ssam #endif 11613073Ssam "ctlecho", 0, 0, LCTLECH, 0, 11713073Ssam "-ctlecho", 0, 0, 0, LCTLECH, 11813073Ssam "pendin", 0, 0, LPENDIN, 0, 11913073Ssam "-pendin", 0, 0, 0, LPENDIN, 12013073Ssam "decctlq", 0, 0, LDECCTQ, 0, 12113073Ssam "-decctlq", 0, 0, 0, LDECCTQ, 12213073Ssam "noflsh", 0, 0, LNOFLSH, 0, 12313073Ssam "-noflsh", 0, 0, 0, LNOFLSH, 12413073Ssam 0, 1251179Sbill }; 1261179Sbill 12713073Ssam struct tchars tc; 12813073Ssam struct ltchars ltc; 12913073Ssam struct sgttyb mode; 130*18023Sbloom struct winsize win; 13113073Ssam int lmode; 1321179Sbill int oldisc, ldisc; 1331179Sbill 1341179Sbill struct special { 1351179Sbill char *name; 1361179Sbill char *cp; 1371179Sbill char def; 1381179Sbill } special[] = { 13913073Ssam "erase", &mode.sg_erase, CERASE, 14013073Ssam "kill", &mode.sg_kill, CKILL, 14113073Ssam "intr", &tc.t_intrc, CINTR, 14213073Ssam "quit", &tc.t_quitc, CQUIT, 14313073Ssam "start", &tc.t_startc, CSTART, 14413073Ssam "stop", &tc.t_stopc, CSTOP, 14513073Ssam "eof", &tc.t_eofc, CEOF, 14613073Ssam "brk", &tc.t_brkc, CBRK, 14713073Ssam "susp", <c.t_suspc, CSUSP, 14813073Ssam "dsusp", <c.t_dsuspc, CDSUSP, 14913073Ssam "rprnt", <c.t_rprntc, CRPRNT, 15013073Ssam "flush", <c.t_flushc, CFLUSH, 15113073Ssam "werase", <c.t_werasc, CWERASE, 15213073Ssam "lnext", <c.t_lnextc, CLNEXT, 1531179Sbill 0 1541179Sbill }; 1551179Sbill char *arg; 1561179Sbill 1571179Sbill int argc; 1581179Sbill char **argv; 1591179Sbill main(iargc, iargv) 16013073Ssam char **iargv; 1611179Sbill { 1621179Sbill int i; 1631179Sbill register struct special *sp; 1641179Sbill char obuf[BUFSIZ]; 1651179Sbill 1661179Sbill setbuf(stderr, obuf); 1671179Sbill argc = iargc; 1681179Sbill argv = iargv; 16913073Ssam ioctl(1, TIOCGETP, &mode); 1701179Sbill ioctl(1, TIOCGETD, &ldisc); 1711179Sbill oldisc = ldisc; 17213073Ssam ioctl(1, TIOCGETC, &tc); 17313073Ssam ioctl(1, TIOCLGET, &lmode); 17413073Ssam ioctl(1, TIOCGLTC, <c); 175*18023Sbloom ioctl(1, TIOCGWINSZ, &win); 17613073Ssam if(argc == 1) { 1771179Sbill prmodes(0); 1781179Sbill exit(0); 1791179Sbill } 1801179Sbill if (argc == 2 && !strcmp(argv[1], "all")) { 1811179Sbill prmodes(1); 1821179Sbill exit(0); 1831179Sbill } 1841179Sbill if (argc == 2 && !strcmp(argv[1], "everything")) { 1851179Sbill prmodes(2); 1861179Sbill exit(0); 1871179Sbill } 18813073Ssam /* 18913073Ssam if (argc == 2 && !strcmp(argv[1], "all")) { 19013073Ssam prmodes(2); 19113073Ssam exit(0); 19213073Ssam } 19313073Ssam */ 19413073Ssam while(--argc > 0) { 1951179Sbill arg = *++argv; 19613073Ssam if (eq("ek")){ 19713073Ssam mode.sg_erase = '#'; 19813073Ssam mode.sg_kill = '@'; 1991179Sbill continue; 2001179Sbill } 20113073Ssam if (eq("new")){ 2021179Sbill ldisc = NTTYDISC; 20313073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2041179Sbill perror("ioctl"); 2051179Sbill continue; 2061179Sbill } 20713073Ssam if (eq("newcrt")){ 2081179Sbill ldisc = NTTYDISC; 20913073Ssam lmode &= ~LPRTERA; 21013073Ssam lmode |= LCRTBS|LCTLECH; 21113073Ssam if (mode.sg_ospeed >= B1200) 21213073Ssam lmode |= LCRTERA|LCRTKIL; 21313073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2141179Sbill perror("ioctl"); 2151179Sbill continue; 2161179Sbill } 21713073Ssam if (eq("crt")){ 21813073Ssam lmode &= ~LPRTERA; 21913073Ssam lmode |= LCRTBS|LCTLECH; 22013073Ssam if (mode.sg_ospeed >= B1200) 22113073Ssam lmode |= LCRTERA|LCRTKIL; 2221179Sbill continue; 2231179Sbill } 22413073Ssam if (eq("old")){ 22513073Ssam ldisc = 0; 22613073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2271179Sbill perror("ioctl"); 2281179Sbill continue; 2291179Sbill } 23013073Ssam if (eq("dec")){ 23113073Ssam mode.sg_erase = 0177; 23213073Ssam mode.sg_kill = CTRL(u); 23313073Ssam tc.t_intrc = CTRL(c); 2343797Sroot ldisc = NTTYDISC; 23513073Ssam lmode &= ~LPRTERA; 23613073Ssam lmode |= LCRTBS|LCTLECH|LDECCTQ; 23713073Ssam if (mode.sg_ospeed >= B1200) 23813073Ssam lmode |= LCRTERA|LCRTKIL; 23913073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2403797Sroot perror("ioctl"); 2413797Sroot continue; 2423797Sroot } 2431179Sbill for (sp = special; sp->name; sp++) 2441179Sbill if (eq(sp->name)) { 2451179Sbill if (--argc == 0) 2461179Sbill goto done; 2471179Sbill if (**++argv == 'u') 2481179Sbill *sp->cp = 0377; 2491179Sbill else if (**argv == '^') 2503955Sroot *sp->cp = ((*argv)[1] == '?') ? 2511179Sbill 0177 : (*argv)[1] & 037; 2521179Sbill else 2531179Sbill *sp->cp = **argv; 2541179Sbill goto cont; 2551179Sbill } 2561179Sbill if (eq("gspeed")) { 25713073Ssam mode.sg_ispeed = B300; 25813073Ssam mode.sg_ospeed = B9600; 2591179Sbill continue; 2601179Sbill } 2611179Sbill if (eq("hup")) { 26213073Ssam ioctl(1, TIOCHPCL, NULL); 2631179Sbill continue; 2641179Sbill } 265*18023Sbloom if (eq("rows")) { 266*18023Sbloom if (--argc == 0) 267*18023Sbloom goto done; 268*18023Sbloom win.ws_row = atoi(*++argv); 269*18023Sbloom } 270*18023Sbloom if (eq("columns")) { 271*18023Sbloom if (--argc == 0) 272*18023Sbloom goto done; 273*18023Sbloom win.ws_col = atoi(*++argv); 274*18023Sbloom } 27513073Ssam for(i=0; speeds[i].string; i++) 27613073Ssam if(eq(speeds[i].string)) { 27713073Ssam mode.sg_ispeed = mode.sg_ospeed = speeds[i].speed; 2781179Sbill goto cont; 2791179Sbill } 2801179Sbill if (eq("speed")) { 28113073Ssam ioctl(open("/dev/tty", 0), TIOCGETP, &mode); 28213073Ssam for(i=0; speeds[i].string; i++) 28313073Ssam if (mode.sg_ospeed == speeds[i].speed) { 2841179Sbill printf("%s\n", speeds[i].string); 2851179Sbill exit(0); 2861179Sbill } 2871179Sbill printf("unknown\n"); 2881179Sbill exit(1); 2891179Sbill } 29013073Ssam for(i=0; modes[i].string; i++) 29113073Ssam if(eq(modes[i].string)) { 29213073Ssam mode.sg_flags &= ~modes[i].reset; 29313073Ssam mode.sg_flags |= modes[i].set; 29413073Ssam lmode &= ~modes[i].lreset; 29513073Ssam lmode |= modes[i].lset; 2961179Sbill } 29713073Ssam if(arg) 2981179Sbill fprintf(stderr,"unknown mode: %s\n", arg); 2991179Sbill cont: 3001179Sbill ; 3011179Sbill } 3021179Sbill done: 30313073Ssam ioctl(1, TIOCSETN, &mode); 30413073Ssam ioctl(1, TIOCSETC, &tc); 30513073Ssam ioctl(1, TIOCSLTC, <c); 30613073Ssam ioctl(1, TIOCLSET, &lmode); 307*18023Sbloom ioctl(1, TIOCSWINSZ, &win); 3081179Sbill } 3091179Sbill 3101179Sbill eq(string) 31113073Ssam char *string; 3121179Sbill { 3131179Sbill int i; 3141179Sbill 31513073Ssam if(!arg) 31613073Ssam return(0); 3171179Sbill i = 0; 3181179Sbill loop: 31913073Ssam if(arg[i] != string[i]) 3201179Sbill return(0); 32113073Ssam if(arg[i++] != '\0') 3221179Sbill goto loop; 3231179Sbill arg = 0; 32413073Ssam return(1); 3251179Sbill } 3261179Sbill 3271179Sbill prmodes(all) 3281179Sbill { 3291179Sbill register m; 3301179Sbill int any; 3311179Sbill 33213073Ssam if(ldisc==NETLDISC) 3331179Sbill fprintf(stderr, "net discipline, "); 33413073Ssam else if(ldisc==NTTYDISC) 3351179Sbill fprintf(stderr, "new tty, "); 33613073Ssam else if(all==2) 3371179Sbill fprintf(stderr, "old tty, "); 33813073Ssam if(mode.sg_ispeed != mode.sg_ospeed) { 33913073Ssam prspeed("input speed ", mode.sg_ispeed); 34013073Ssam prspeed("output speed ", mode.sg_ospeed); 3411179Sbill } else 34213073Ssam prspeed("speed ", mode.sg_ispeed); 343*18023Sbloom if (all) 344*18023Sbloom fprintf(stderr, ", %d rows, %d columns", win.ws_row, win.ws_col); 34513073Ssam fprintf(stderr, all==2 ? "\n" : "; "); 34613073Ssam m = mode.sg_flags; 34713073Ssam if(all==2 || (m&(EVENP|ODDP))!=(EVENP|ODDP)) { 34813073Ssam if(m & EVENP) fprintf(stderr,"even "); 34913073Ssam if(m & ODDP) fprintf(stderr,"odd "); 3501179Sbill } 35113073Ssam if(all==2 || m&RAW) 35213073Ssam fprintf(stderr,"-raw "+((m&RAW)!=0)); 35313073Ssam if(all==2 || (m&CRMOD)==0) 35413073Ssam fprintf(stderr,"-nl "+((m&CRMOD)==0)); 35513073Ssam if(all==2 || (m&ECHO)==0) 35613073Ssam fprintf(stderr,"-echo "+((m&ECHO)!=0)); 35713073Ssam if(all==2 || (m&LCASE)) 35813073Ssam fprintf(stderr,"-lcase "+((m&LCASE)!=0)); 35913073Ssam if(all==2 || (m&TANDEM)) 36013073Ssam fprintf(stderr,"-tandem "+((m&TANDEM)!=0)); 36113073Ssam fprintf(stderr,"-tabs "+((m&XTABS)!=XTABS)); 36213073Ssam if(all==2 || (m&CBREAK)) 36313073Ssam fprintf(stderr,"-cbreak "+((m&CBREAK)!=0)); 36413073Ssam if(all==2 || (m&NLDELAY)) 36513073Ssam delay((m&NLDELAY)/NL1, "nl"); 36613073Ssam if ((m&TBDELAY)!=XTABS) 36713073Ssam delay((m&TBDELAY)/TAB1, "tab"); 36813073Ssam if(all==2 || (m&CRDELAY)) 36913073Ssam delay((m&CRDELAY)/CR1, "cr"); 37013073Ssam if(all==2 || (m&VTDELAY)) 37113073Ssam delay((m&VTDELAY)/FF1, "ff"); 37213073Ssam if(all==2 || (m&BSDELAY)) 37313073Ssam delay((m&BSDELAY)/BS1, "bs"); 3741179Sbill if (all) 3751179Sbill fprintf(stderr,"\n"); 3761179Sbill #define lpit(what,str) \ 37713073Ssam if (all==2||(lmode&what)) { \ 37813073Ssam fprintf(stderr,str+((lmode&what)!=0)); any++; \ 3791179Sbill } 3801179Sbill if (ldisc == NTTYDISC) { 38113073Ssam int newcrt = (lmode&(LCTLECH|LCRTBS)) == (LCTLECH|LCRTBS) && 38213073Ssam (lmode&(LCRTERA|LCRTKIL)) == 38313073Ssam ((mode.sg_ospeed > B300) ? LCRTERA|LCRTKIL : 0); 38413817Ssam int nothing = 1; 3851179Sbill if (newcrt) { 38613073Ssam if (all==2) 38713073Ssam fprintf(stderr, "crt: (crtbs crterase crtkill ctlecho) "); 38813073Ssam else 38913073Ssam fprintf(stderr, "crt "); 3901179Sbill any++; 3911179Sbill } else { 39213073Ssam lpit(LCRTBS, "-crtbs "); 39313073Ssam lpit(LCRTERA, "-crterase "); 39413073Ssam lpit(LCRTKIL, "-crtkill "); 39513073Ssam lpit(LCTLECH, "-ctlecho "); 39613073Ssam lpit(LPRTERA, "-prterase "); 3971179Sbill } 39813073Ssam lpit(LTOSTOP, "-tostop "); 39913073Ssam if (all==2) { 4001179Sbill fprintf(stderr, "\n"); 4011179Sbill any = 0; 40213817Ssam nothing = 0; 4031179Sbill } 40413073Ssam lpit(LTILDE, "-tilde "); 40513073Ssam lpit(LFLUSHO, "-flusho "); 40613073Ssam lpit(LMDMBUF, "-mdmbuf "); 40713073Ssam lpit(LLITOUT, "-litout "); 40813073Ssam lpit(LNOHANG, "-nohang "); 4094017Sroot if (any) { 4104017Sroot fprintf(stderr,"\n"); 4114017Sroot any = 0; 41213817Ssam nothing = 0; 4134017Sroot } 4149853Ssam #ifdef notdef 41513073Ssam lpit(LETXACK, "-etxack "); 4169853Ssam #endif 41713073Ssam lpit(LPENDIN, "-pendin "); 41813073Ssam lpit(LDECCTQ, "-decctlq "); 41913073Ssam lpit(LNOFLSH, "-noflsh "); 42013817Ssam if (any || nothing) 4211179Sbill fprintf(stderr,"\n"); 4221179Sbill } else if (!all) 4231179Sbill fprintf(stderr,"\n"); 4241179Sbill if (all) { 4251179Sbill switch (ldisc) { 4261179Sbill 4271179Sbill case 0: 4281179Sbill fprintf(stderr,"\ 4291179Sbill erase kill intr quit stop eof\ 4301179Sbill \n"); 43113073Ssam pcol(mode.sg_erase, -1); 43213073Ssam pcol(mode.sg_kill, -1); 43313073Ssam pcol(tc.t_intrc, -1); 43413073Ssam pcol(tc.t_quitc, -1); 43513073Ssam pcol(tc.t_stopc, tc.t_startc); 43613073Ssam pcol(tc.t_eofc, tc.t_brkc); 4371179Sbill fprintf(stderr,"\n"); 4381179Sbill break; 4391179Sbill 4401179Sbill case NTTYDISC: 4411179Sbill fprintf(stderr,"\ 4421179Sbill erase kill werase rprnt flush lnext susp intr quit stop eof\ 4431179Sbill \n"); 44413073Ssam pcol(mode.sg_erase, -1); 44513073Ssam pcol(mode.sg_kill, -1); 44613073Ssam pcol(ltc.t_werasc, -1); 44713073Ssam pcol(ltc.t_rprntc, -1); 44813073Ssam pcol(ltc.t_flushc, -1); 44913073Ssam pcol(ltc.t_lnextc, -1); 45013073Ssam pcol(ltc.t_suspc, ltc.t_dsuspc); 45113073Ssam pcol(tc.t_intrc, -1); 45213073Ssam pcol(tc.t_quitc, -1); 45313073Ssam pcol(tc.t_stopc, tc.t_startc); 45413073Ssam pcol(tc.t_eofc, tc.t_brkc); 4551179Sbill fprintf(stderr,"\n"); 4561179Sbill break; 4571179Sbill } 4581179Sbill } else if (ldisc != NETLDISC) { 4591179Sbill register struct special *sp; 4601179Sbill int first = 1; 46113817Ssam 4621179Sbill for (sp = special; sp->name; sp++) { 4631179Sbill if ((*sp->cp&0377) != (sp->def&0377)) { 4641179Sbill pit(*sp->cp, sp->name, first ? "" : ", "); 4651179Sbill first = 0; 4661179Sbill }; 46713073Ssam if (sp->cp == &tc.t_brkc && ldisc == 0) 4681179Sbill break; 4691179Sbill } 47013817Ssam if (!first) 47113073Ssam fprintf(stderr, "\n"); 4721179Sbill } 4731179Sbill } 4741179Sbill 4751179Sbill pcol(ch1, ch2) 4761179Sbill int ch1, ch2; 4771179Sbill { 4781179Sbill int nout = 0; 4791179Sbill 4801179Sbill ch1 &= 0377; 4811179Sbill ch2 &= 0377; 4821179Sbill if (ch1 == ch2) 4831179Sbill ch2 = 0377; 4841179Sbill for (; ch1 != 0377 || ch2 != 0377; ch1 = ch2, ch2 = 0377) { 4851179Sbill if (ch1 == 0377) 4861179Sbill continue; 4871179Sbill if (ch1 & 0200) { 4881179Sbill fprintf(stderr, "M-"); 4891179Sbill nout += 2; 4901179Sbill ch1 &= ~ 0200; 4911179Sbill } 4921179Sbill if (ch1 == 0177) { 4931179Sbill fprintf(stderr, "^"); 4941179Sbill nout++; 4951179Sbill ch1 = '?'; 4961179Sbill } else if (ch1 < ' ') { 4971179Sbill fprintf(stderr, "^"); 4981179Sbill nout++; 4991179Sbill ch1 += '@'; 5001179Sbill } 5011179Sbill fprintf(stderr, "%c", ch1); 5021179Sbill nout++; 5031179Sbill if (ch2 != 0377) { 5041179Sbill fprintf(stderr, "/"); 5051179Sbill nout++; 5061179Sbill } 5071179Sbill } 5081179Sbill while (nout < 7) { 5091179Sbill fprintf(stderr, " "); 5101179Sbill nout++; 5111179Sbill } 5121179Sbill } 5131179Sbill 5141179Sbill pit(what, itsname, sep) 5151179Sbill unsigned what; 5161179Sbill char *itsname, *sep; 5171179Sbill { 5181179Sbill 5191179Sbill what &= 0377; 5201179Sbill fprintf(stderr, "%s%s", sep, itsname); 5211179Sbill if (what == 0377) { 5221179Sbill fprintf(stderr, " <undef>"); 5231179Sbill return; 5241179Sbill } 5251179Sbill fprintf(stderr, " = "); 5261179Sbill if (what & 0200) { 5271179Sbill fprintf(stderr, "M-"); 5281179Sbill what &= ~ 0200; 5291179Sbill } 5301179Sbill if (what == 0177) { 5311179Sbill fprintf(stderr, "^"); 5321179Sbill what = '?'; 5331179Sbill } else if (what < ' ') { 5341179Sbill fprintf(stderr, "^"); 5351179Sbill what += '@'; 5361179Sbill } 5371179Sbill fprintf(stderr, "%c", what); 5381179Sbill } 5391179Sbill 5401179Sbill delay(m, s) 54113073Ssam char *s; 5421179Sbill { 5431179Sbill 54413073Ssam if(m) 5451179Sbill fprintf(stderr,"%s%d ", s, m); 5461179Sbill } 5471179Sbill 5481179Sbill int speed[] = { 5496815Swnj 0,50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,19200,38400 5501179Sbill }; 5511179Sbill 5521179Sbill prspeed(c, s) 5531179Sbill char *c; 5541179Sbill { 5551179Sbill 5561179Sbill fprintf(stderr,"%s%d baud", c, speed[s]); 5571179Sbill } 558