1*6815Swnj static char *sccsid ="@(#)stty.c 4.9 (Berkeley) 05/12/82"; 21179Sbill /* 31179Sbill * set teletype modes 41179Sbill */ 51179Sbill 61179Sbill #include <stdio.h> 71179Sbill #include <sgtty.h> 81179Sbill 91179Sbill struct 101179Sbill { 111179Sbill char *string; 121179Sbill int speed; 131179Sbill } speeds[] = { 141179Sbill "0", B0, 151179Sbill "50", B50, 161179Sbill "75", B75, 171179Sbill "110", B110, 181179Sbill "134", B134, 191179Sbill "134.5",B134, 201179Sbill "150", B150, 211179Sbill "200", B200, 221179Sbill "300", B300, 231179Sbill "600", B600, 241179Sbill "1200", B1200, 251179Sbill "1800", B1800, 261179Sbill "2400", B2400, 271179Sbill "4800", B4800, 281179Sbill "9600", B9600, 291179Sbill "exta", EXTA, 30*6815Swnj "19200", EXTA, 311179Sbill "extb", EXTB, 32*6815Swnj "38400", EXTB, 331179Sbill 0, 341179Sbill }; 351179Sbill struct 361179Sbill { 371179Sbill char *string; 381179Sbill int set; 391179Sbill int reset; 401179Sbill int lset; 411179Sbill int lreset; 421179Sbill } modes[] = { 431179Sbill "even", EVENP, 0, 0, 0, 441179Sbill "-even", 0, EVENP, 0, 0, 451179Sbill "odd", ODDP, 0, 0, 0, 461179Sbill "-odd", 0, ODDP, 0, 0, 471179Sbill "raw", RAW, 0, 0, 0, 481179Sbill "-raw", 0, RAW, 0, 0, 491179Sbill "cooked", 0, RAW, 0, 0, 501179Sbill "-nl", CRMOD, 0, 0, 0, 511179Sbill "nl", 0, CRMOD, 0, 0, 521179Sbill "echo", ECHO, 0, 0, 0, 531179Sbill "-echo", 0, ECHO, 0, 0, 541179Sbill "LCASE", LCASE, 0, 0, 0, 551179Sbill "lcase", LCASE, 0, 0, 0, 561179Sbill "-LCASE", 0, LCASE, 0, 0, 571179Sbill "-lcase", 0, LCASE, 0, 0, 581179Sbill "-tabs", XTABS, 0, 0, 0, 591179Sbill "tabs", 0, XTABS, 0, 0, 601179Sbill "tandem", TANDEM, 0, 0, 0, 611179Sbill "-tandem", 0, TANDEM, 0, 0, 621179Sbill "cbreak", CBREAK, 0, 0, 0, 631179Sbill "-cbreak", 0, CBREAK, 0, 0, 641179Sbill "cr0", CR0, CR3, 0, 0, 651179Sbill "cr1", CR1, CR3, 0, 0, 661179Sbill "cr2", CR2, CR3, 0, 0, 671179Sbill "cr3", CR3, CR3, 0, 0, 681179Sbill "tab0", TAB0, XTABS, 0, 0, 691179Sbill "tab1", TAB1, XTABS, 0, 0, 701179Sbill "tab2", TAB2, XTABS, 0, 0, 711179Sbill "nl0", NL0, NL3, 0, 0, 721179Sbill "nl1", NL1, NL3, 0, 0, 731179Sbill "nl2", NL2, NL3, 0, 0, 741179Sbill "nl3", NL3, NL3, 0, 0, 751179Sbill "ff0", FF0, FF1, 0, 0, 761179Sbill "ff1", FF1, FF1, 0, 0, 771179Sbill "bs0", BS0, BS1, 0, 0, 781179Sbill "bs1", BS1, BS1, 0, 0, 791179Sbill "33", CR1, ALLDELAY, 0, 0, 801179Sbill "tty33", CR1, ALLDELAY, 0, 0, 811179Sbill "37", FF1+CR2+TAB1+NL1, ALLDELAY, 0, 0, 821179Sbill "tty37", FF1+CR2+TAB1+NL1, ALLDELAY, 0, 0, 831179Sbill "05", NL2, ALLDELAY, 0, 0, 841179Sbill "vt05", NL2, ALLDELAY, 0, 0, 851179Sbill "tn", CR1, ALLDELAY, 0, 0, 861179Sbill "tn300", CR1, ALLDELAY, 0, 0, 871179Sbill "ti", CR2, ALLDELAY, 0, 0, 881179Sbill "ti700", CR2, ALLDELAY, 0, 0, 891179Sbill "tek", FF1, ALLDELAY, 0, 0, 901179Sbill "crtbs", 0, 0, LCRTBS, LPRTERA, 911179Sbill "-crtbs", 0, 0, 0, LCRTBS, 921179Sbill "prterase", 0, 0, LPRTERA, LCRTBS+LCRTKIL+LCRTERA, 931179Sbill "-prterase", 0, 0, 0, LPRTERA, 941179Sbill "crterase", 0, 0, LCRTERA, LPRTERA, 951179Sbill "-crterase", 0, 0, 0, LCRTERA, 961179Sbill "crtkill", 0, 0, LCRTKIL, LPRTERA, 971179Sbill "-crtkill", 0, 0, 0, LCRTKIL, 981179Sbill "tilde", 0, 0, LTILDE, 0, 991179Sbill "-tilde", 0, 0, 0, LTILDE, 1001179Sbill "mdmbuf", 0, 0, LMDMBUF, 0, 1011179Sbill "-mdmbuf", 0, 0, 0, LMDMBUF, 1021179Sbill "litout", 0, 0, LLITOUT, 0, 1031179Sbill "-litout", 0, 0, 0, LLITOUT, 1041179Sbill "tostop", 0, 0, LTOSTOP, 0, 1051179Sbill "-tostop", 0, 0, 0, LTOSTOP, 1061179Sbill "flusho", 0, 0, LFLUSHO, 0, 1071179Sbill "-flusho", 0, 0, 0, LFLUSHO, 1081179Sbill "nohang", 0, 0, LNOHANG, 0, 1091179Sbill "-nohang", 0, 0, 0, LNOHANG, 1101179Sbill "etxack", 0, 0, LETXACK, 0, 1111179Sbill "-etxack", 0, 0, 0, LETXACK, 1121179Sbill "ctlecho", 0, 0, LCTLECH, 0, 1131179Sbill "-ctlecho", 0, 0, 0, LCTLECH, 1141179Sbill "pendin", 0, 0, LPENDIN, 0, 1151179Sbill "-pendin", 0, 0, 0, LPENDIN, 1163797Sroot "decctlq", 0, 0, LDECCTQ, 0, 1173797Sroot "-decctlq", 0, 0, 0, LDECCTQ, 1184017Sroot "noflsh", 0, 0, LNOFLSH, 0, 1194017Sroot "-noflsh", 0, 0, 0, LNOFLSH, 1201179Sbill 0, 1211179Sbill }; 1221179Sbill 1231179Sbill struct tchars tc; 1241179Sbill struct ltchars ltc; 1251179Sbill struct sgttyb mode; 1261179Sbill int lmode; 1271179Sbill int oldisc, ldisc; 1281179Sbill 1291179Sbill #define CTRL(x) ('x'&037) 1301179Sbill 1311179Sbill struct special { 1321179Sbill char *name; 1331179Sbill char *cp; 1341179Sbill char def; 1351179Sbill } special[] = { 1361179Sbill "erase", &mode.sg_erase, CTRL(h), 1371179Sbill "kill", &mode.sg_kill, '@', 1381179Sbill "intr", &tc.t_intrc, 0177, 1391179Sbill "quit", &tc.t_quitc, CTRL(\\\\), 1401179Sbill "start", &tc.t_startc, CTRL(q), 1411179Sbill "stop", &tc.t_stopc, CTRL(s), 1421179Sbill "eof", &tc.t_eofc, CTRL(d), 1431179Sbill "brk", &tc.t_brkc, 0377, 1441179Sbill "susp", <c.t_suspc, CTRL(z), 1451179Sbill "dsusp", <c.t_dsuspc, CTRL(y), 1461179Sbill "rprnt", <c.t_rprntc, CTRL(r), 1471179Sbill "flush", <c.t_flushc, CTRL(o), 1481179Sbill "werase", <c.t_werasc, CTRL(w), 1491179Sbill "lnext", <c.t_lnextc, CTRL(v), 1501179Sbill 0 1511179Sbill }; 1521179Sbill char *arg; 1531179Sbill 1541179Sbill int argc; 1551179Sbill char **argv; 1561179Sbill main(iargc, iargv) 1571179Sbill char **iargv; 1581179Sbill { 1591179Sbill int i; 1601179Sbill register struct special *sp; 1611179Sbill char obuf[BUFSIZ]; 1621179Sbill 1631179Sbill setbuf(stderr, obuf); 1641179Sbill argc = iargc; 1651179Sbill argv = iargv; 1661179Sbill gtty(1, &mode); 1671179Sbill ioctl(1, TIOCGETD, &ldisc); 1681179Sbill oldisc = ldisc; 1691179Sbill ioctl(1, TIOCGETC, &tc); 1701179Sbill ioctl(1, TIOCLGET, &lmode); 1711179Sbill ioctl(1, TIOCGLTC, <c); 1721179Sbill if(argc == 1) { 1731179Sbill prmodes(0); 1741179Sbill exit(0); 1751179Sbill } 1761179Sbill if (argc == 2 && !strcmp(argv[1], "all")) { 1771179Sbill prmodes(1); 1781179Sbill exit(0); 1791179Sbill } 1801179Sbill if (argc == 2 && !strcmp(argv[1], "everything")) { 1811179Sbill prmodes(2); 1821179Sbill exit(0); 1831179Sbill } 1841179Sbill /* 1851179Sbill if (argc == 2 && !strcmp(argv[1], "all")) { 1861179Sbill prmodes(2); 1871179Sbill exit(0); 1881179Sbill } 1891179Sbill */ 1901179Sbill while(--argc > 0) { 1911179Sbill arg = *++argv; 1921179Sbill if (eq("ek")){ 1931179Sbill mode.sg_erase = '#'; 1941179Sbill mode.sg_kill = '@'; 1951179Sbill continue; 1961179Sbill } 1971179Sbill if (eq("new")){ 1981179Sbill ldisc = NTTYDISC; 1991179Sbill if (ioctl(1, TIOCSETD, &ldisc)<0) 2001179Sbill perror("ioctl"); 2011179Sbill continue; 2021179Sbill } 2031179Sbill if (eq("newcrt")){ 2041179Sbill ldisc = NTTYDISC; 2051179Sbill lmode &= ~LPRTERA; 2061179Sbill lmode |= LCRTBS|LCTLECH; 2071179Sbill if (mode.sg_ospeed >= B1200) 2081179Sbill lmode |= LCRTERA|LCRTKIL; 2091179Sbill if (ioctl(1, TIOCSETD, &ldisc)<0) 2101179Sbill perror("ioctl"); 2111179Sbill continue; 2121179Sbill } 2131179Sbill if (eq("crt")){ 2141179Sbill lmode &= ~LPRTERA; 2151179Sbill lmode |= LCRTBS|LCTLECH; 2161179Sbill if (mode.sg_ospeed >= B1200) 2171179Sbill lmode |= LCRTERA|LCRTKIL; 2181179Sbill continue; 2191179Sbill } 2201179Sbill if (eq("old")){ 2211179Sbill ldisc = 0; 2221179Sbill if (ioctl(1, TIOCSETD, &ldisc)<0) 2231179Sbill perror("ioctl"); 2241179Sbill continue; 2251179Sbill } 2263797Sroot if (eq("dec")){ 2273797Sroot mode.sg_erase = 0177; 2283797Sroot mode.sg_kill = CTRL(u); 2293797Sroot tc.t_intrc = CTRL(c); 2303797Sroot ldisc = NTTYDISC; 2313797Sroot lmode &= ~LPRTERA; 2323797Sroot lmode |= LCRTBS|LCTLECH|LDECCTQ; 2333797Sroot if (mode.sg_ospeed >= B1200) 2343797Sroot lmode |= LCRTERA|LCRTKIL; 2353797Sroot if (ioctl(1, TIOCSETD, &ldisc)<0) 2363797Sroot perror("ioctl"); 2373797Sroot continue; 2383797Sroot } 2391179Sbill for (sp = special; sp->name; sp++) 2401179Sbill if (eq(sp->name)) { 2411179Sbill if (--argc == 0) 2421179Sbill goto done; 2431179Sbill if (**++argv == 'u') 2441179Sbill *sp->cp = 0377; 2451179Sbill else if (**argv == '^') 2463955Sroot *sp->cp = ((*argv)[1] == '?') ? 2471179Sbill 0177 : (*argv)[1] & 037; 2481179Sbill else 2491179Sbill *sp->cp = **argv; 2501179Sbill goto cont; 2511179Sbill } 2521179Sbill if (eq("gspeed")) { 2531179Sbill mode.sg_ispeed = B300; 2541179Sbill mode.sg_ospeed = B9600; 2551179Sbill continue; 2561179Sbill } 2571179Sbill if (eq("hup")) { 2581179Sbill ioctl(1, TIOCHPCL, NULL); 2591179Sbill continue; 2601179Sbill } 2611179Sbill for(i=0; speeds[i].string; i++) 2621179Sbill if(eq(speeds[i].string)) { 2631179Sbill mode.sg_ispeed = mode.sg_ospeed = speeds[i].speed; 2641179Sbill goto cont; 2651179Sbill } 2661179Sbill if (eq("speed")) { 2671179Sbill gtty(open("/dev/tty", 0), &mode); 2681179Sbill for(i=0; speeds[i].string; i++) 2691179Sbill if (mode.sg_ospeed == speeds[i].speed) { 2701179Sbill printf("%s\n", speeds[i].string); 2711179Sbill exit(0); 2721179Sbill } 2731179Sbill printf("unknown\n"); 2741179Sbill exit(1); 2751179Sbill } 2761179Sbill for(i=0; modes[i].string; i++) 2771179Sbill if(eq(modes[i].string)) { 2781179Sbill mode.sg_flags &= ~modes[i].reset; 2791179Sbill mode.sg_flags |= modes[i].set; 2801179Sbill lmode &= ~modes[i].lreset; 2811179Sbill lmode |= modes[i].lset; 2821179Sbill } 2831179Sbill if(arg) 2841179Sbill fprintf(stderr,"unknown mode: %s\n", arg); 2851179Sbill cont: 2861179Sbill ; 2871179Sbill } 2881179Sbill done: 2891179Sbill ioctl(1, TIOCSETN, &mode); 2901179Sbill ioctl(1, TIOCSETC, &tc); 2911179Sbill ioctl(1, TIOCSLTC, <c); 2921179Sbill ioctl(1, TIOCLSET, &lmode); 2931179Sbill } 2941179Sbill 2951179Sbill eq(string) 2961179Sbill char *string; 2971179Sbill { 2981179Sbill int i; 2991179Sbill 3001179Sbill if(!arg) 3011179Sbill return(0); 3021179Sbill i = 0; 3031179Sbill loop: 3041179Sbill if(arg[i] != string[i]) 3051179Sbill return(0); 3061179Sbill if(arg[i++] != '\0') 3071179Sbill goto loop; 3081179Sbill arg = 0; 3091179Sbill return(1); 3101179Sbill } 3111179Sbill 3121179Sbill prmodes(all) 3131179Sbill { 3141179Sbill register m; 3151179Sbill int any; 3161179Sbill 3171179Sbill if(ldisc==NETLDISC) 3181179Sbill fprintf(stderr, "net discipline, "); 3191179Sbill else if(ldisc==NTTYDISC) 3201179Sbill fprintf(stderr, "new tty, "); 3211179Sbill else if(all==2) 3221179Sbill fprintf(stderr, "old tty, "); 3231179Sbill if(mode.sg_ispeed != mode.sg_ospeed) { 3241179Sbill prspeed("input speed ", mode.sg_ispeed); 3251179Sbill prspeed("output speed ", mode.sg_ospeed); 3261179Sbill } else 3271179Sbill prspeed("speed ", mode.sg_ispeed); 3281179Sbill fprintf(stderr, all==2 ? "\n" : "; "); 3291179Sbill m = mode.sg_flags; 3301179Sbill if(all==2 || (m&(EVENP|ODDP))!=(EVENP|ODDP)) { 3311179Sbill if(m & EVENP) fprintf(stderr,"even "); 3321179Sbill if(m & ODDP) fprintf(stderr,"odd "); 3331179Sbill } 3341179Sbill if(all==2 || m&RAW) 3351179Sbill fprintf(stderr,"-raw "+((m&RAW)!=0)); 3361179Sbill if(all==2 || (m&CRMOD)==0) 3371179Sbill fprintf(stderr,"-nl "+((m&CRMOD)==0)); 3381179Sbill if(all==2 || (m&ECHO)==0) 3391179Sbill fprintf(stderr,"-echo "+((m&ECHO)!=0)); 3401179Sbill if(all==2 || (m&LCASE)) 3411179Sbill fprintf(stderr,"-lcase "+((m&LCASE)!=0)); 3421179Sbill if(all==2 || (m&TANDEM)) 3431179Sbill fprintf(stderr,"-tandem "+((m&TANDEM)!=0)); 3441179Sbill fprintf(stderr,"-tabs "+((m&XTABS)!=XTABS)); 3451179Sbill if(all==2 || (m&CBREAK)) 3461179Sbill fprintf(stderr,"-cbreak "+((m&CBREAK)!=0)); 3471179Sbill if(all==2 || (m&NLDELAY)) 3481179Sbill delay((m&NLDELAY)/NL1, "nl"); 3491179Sbill if ((m&TBDELAY)!=XTABS) 3501179Sbill delay((m&TBDELAY)/TAB1, "tab"); 3511179Sbill if(all==2 || (m&CRDELAY)) 3521179Sbill delay((m&CRDELAY)/CR1, "cr"); 3531179Sbill if(all==2 || (m&VTDELAY)) 3541179Sbill delay((m&VTDELAY)/FF1, "ff"); 3551179Sbill if(all==2 || (m&BSDELAY)) 3561179Sbill delay((m&BSDELAY)/BS1, "bs"); 3571179Sbill if (all) 3581179Sbill fprintf(stderr,"\n"); 3591179Sbill #define lpit(what,str) \ 3601179Sbill if (all==2||(lmode&what)) { \ 3611179Sbill fprintf(stderr,str+((lmode&what)!=0)); any++; \ 3621179Sbill } 3631179Sbill if (ldisc == NTTYDISC) { 3641179Sbill int newcrt = (lmode&(LCTLECH|LCRTBS)) == (LCTLECH|LCRTBS) && 3651179Sbill (lmode&(LCRTERA|LCRTKIL)) == 3661179Sbill ((mode.sg_ospeed > B300) ? LCRTERA|LCRTKIL : 0); 3671179Sbill if (newcrt) { 3681179Sbill if (all==2) 3691402Sbill fprintf(stderr, "crt: (crtbs crterase crtkill ctlecho) "); 3701179Sbill else 3711402Sbill fprintf(stderr, "crt "); 3721179Sbill any++; 3731179Sbill } else { 3741179Sbill lpit(LCRTBS, "-crtbs "); 3751179Sbill lpit(LCRTERA, "-crterase "); 3761179Sbill lpit(LCRTKIL, "-crtkill "); 3771179Sbill lpit(LCTLECH, "-ctlecho "); 3781179Sbill lpit(LPRTERA, "-prterase "); 3791179Sbill } 3801179Sbill lpit(LTOSTOP, "-tostop "); 3811179Sbill if (all==2) { 3821179Sbill fprintf(stderr, "\n"); 3831179Sbill any = 0; 3841179Sbill } 3851179Sbill lpit(LTILDE, "-tilde "); 3861179Sbill lpit(LFLUSHO, "-flusho "); 3871179Sbill lpit(LMDMBUF, "-mdmbuf "); 3881179Sbill lpit(LLITOUT, "-litout "); 3891179Sbill lpit(LNOHANG, "-nohang "); 3904017Sroot if (any) { 3914017Sroot fprintf(stderr,"\n"); 3924017Sroot any = 0; 3934017Sroot } 3941179Sbill lpit(LETXACK, "-etxack "); 3951179Sbill lpit(LPENDIN, "-pendin "); 3964017Sroot lpit(LDECCTQ, "-decctlq "); 3974017Sroot lpit(LNOFLSH, "-noflsh "); 3981179Sbill if (any) 3991179Sbill fprintf(stderr,"\n"); 4001179Sbill } else if (!all) 4011179Sbill fprintf(stderr,"\n"); 4021179Sbill if (all) { 4031179Sbill switch (ldisc) { 4041179Sbill 4051179Sbill case 0: 4061179Sbill fprintf(stderr,"\ 4071179Sbill erase kill intr quit stop eof\ 4081179Sbill \n"); 4091179Sbill pcol(mode.sg_erase, -1); 4101179Sbill pcol(mode.sg_kill, -1); 4111179Sbill pcol(tc.t_intrc, -1); 4121179Sbill pcol(tc.t_quitc, -1); 4131179Sbill pcol(tc.t_stopc, tc.t_startc); 4141179Sbill pcol(tc.t_eofc, tc.t_brkc); 4151179Sbill fprintf(stderr,"\n"); 4161179Sbill break; 4171179Sbill 4181179Sbill case NTTYDISC: 4191179Sbill fprintf(stderr,"\ 4201179Sbill erase kill werase rprnt flush lnext susp intr quit stop eof\ 4211179Sbill \n"); 4221179Sbill pcol(mode.sg_erase, -1); 4231179Sbill pcol(mode.sg_kill, -1); 4241179Sbill pcol(ltc.t_werasc, -1); 4251179Sbill pcol(ltc.t_rprntc, -1); 4261179Sbill pcol(ltc.t_flushc, -1); 4271179Sbill pcol(ltc.t_lnextc, -1); 4281179Sbill pcol(ltc.t_suspc, ltc.t_dsuspc); 4291179Sbill pcol(tc.t_intrc, -1); 4301179Sbill pcol(tc.t_quitc, -1); 4311179Sbill pcol(tc.t_stopc, tc.t_startc); 4321179Sbill pcol(tc.t_eofc, tc.t_brkc); 4331179Sbill fprintf(stderr,"\n"); 4341179Sbill break; 4351179Sbill } 4361179Sbill } else if (ldisc != NETLDISC) { 4371179Sbill register struct special *sp; 4381179Sbill int first = 1; 4391179Sbill for (sp = special; sp->name; sp++) { 4401179Sbill if ((*sp->cp&0377) != (sp->def&0377)) { 4411179Sbill pit(*sp->cp, sp->name, first ? "" : ", "); 4421179Sbill first = 0; 4431179Sbill }; 4441179Sbill if (sp->cp == &tc.t_brkc && ldisc == 0) 4451179Sbill break; 4461179Sbill } 4471179Sbill if (first == 0) 4481179Sbill fprintf(stderr, "\n"); 4491179Sbill } 4501179Sbill } 4511179Sbill 4521179Sbill pcol(ch1, ch2) 4531179Sbill int ch1, ch2; 4541179Sbill { 4551179Sbill int nout = 0; 4561179Sbill 4571179Sbill ch1 &= 0377; 4581179Sbill ch2 &= 0377; 4591179Sbill if (ch1 == ch2) 4601179Sbill ch2 = 0377; 4611179Sbill for (; ch1 != 0377 || ch2 != 0377; ch1 = ch2, ch2 = 0377) { 4621179Sbill if (ch1 == 0377) 4631179Sbill continue; 4641179Sbill if (ch1 & 0200) { 4651179Sbill fprintf(stderr, "M-"); 4661179Sbill nout += 2; 4671179Sbill ch1 &= ~ 0200; 4681179Sbill } 4691179Sbill if (ch1 == 0177) { 4701179Sbill fprintf(stderr, "^"); 4711179Sbill nout++; 4721179Sbill ch1 = '?'; 4731179Sbill } else if (ch1 < ' ') { 4741179Sbill fprintf(stderr, "^"); 4751179Sbill nout++; 4761179Sbill ch1 += '@'; 4771179Sbill } 4781179Sbill fprintf(stderr, "%c", ch1); 4791179Sbill nout++; 4801179Sbill if (ch2 != 0377) { 4811179Sbill fprintf(stderr, "/"); 4821179Sbill nout++; 4831179Sbill } 4841179Sbill } 4851179Sbill while (nout < 7) { 4861179Sbill fprintf(stderr, " "); 4871179Sbill nout++; 4881179Sbill } 4891179Sbill } 4901179Sbill 4911179Sbill pit(what, itsname, sep) 4921179Sbill unsigned what; 4931179Sbill char *itsname, *sep; 4941179Sbill { 4951179Sbill 4961179Sbill what &= 0377; 4971179Sbill fprintf(stderr, "%s%s", sep, itsname); 4981179Sbill if (what == 0377) { 4991179Sbill fprintf(stderr, " <undef>"); 5001179Sbill return; 5011179Sbill } 5021179Sbill fprintf(stderr, " = "); 5031179Sbill if (what & 0200) { 5041179Sbill fprintf(stderr, "M-"); 5051179Sbill what &= ~ 0200; 5061179Sbill } 5071179Sbill if (what == 0177) { 5081179Sbill fprintf(stderr, "^"); 5091179Sbill what = '?'; 5101179Sbill } else if (what < ' ') { 5111179Sbill fprintf(stderr, "^"); 5121179Sbill what += '@'; 5131179Sbill } 5141179Sbill fprintf(stderr, "%c", what); 5151179Sbill } 5161179Sbill 5171179Sbill delay(m, s) 5181179Sbill char *s; 5191179Sbill { 5201179Sbill 5211179Sbill if(m) 5221179Sbill fprintf(stderr,"%s%d ", s, m); 5231179Sbill } 5241179Sbill 5251179Sbill int speed[] = { 526*6815Swnj 0,50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,19200,38400 5271179Sbill }; 5281179Sbill 5291179Sbill prspeed(c, s) 5301179Sbill char *c; 5311179Sbill { 5321179Sbill 5331179Sbill fprintf(stderr,"%s%d baud", c, speed[s]); 5341179Sbill } 535