113073Ssam #ifndef lint 2*13817Ssam static char *sccsid ="@(#)stty.c 4.14 (Berkeley) 07/06/83"; 313073Ssam #endif 41179Sbill /* 51179Sbill * set teletype modes 61179Sbill */ 71179Sbill 81179Sbill #include <stdio.h> 91179Sbill #include <sgtty.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; 13013073Ssam int lmode; 1311179Sbill int oldisc, ldisc; 1321179Sbill 1331179Sbill struct special { 1341179Sbill char *name; 1351179Sbill char *cp; 1361179Sbill char def; 1371179Sbill } special[] = { 13813073Ssam "erase", &mode.sg_erase, CERASE, 13913073Ssam "kill", &mode.sg_kill, CKILL, 14013073Ssam "intr", &tc.t_intrc, CINTR, 14113073Ssam "quit", &tc.t_quitc, CQUIT, 14213073Ssam "start", &tc.t_startc, CSTART, 14313073Ssam "stop", &tc.t_stopc, CSTOP, 14413073Ssam "eof", &tc.t_eofc, CEOF, 14513073Ssam "brk", &tc.t_brkc, CBRK, 14613073Ssam "susp", <c.t_suspc, CSUSP, 14713073Ssam "dsusp", <c.t_dsuspc, CDSUSP, 14813073Ssam "rprnt", <c.t_rprntc, CRPRNT, 14913073Ssam "flush", <c.t_flushc, CFLUSH, 15013073Ssam "werase", <c.t_werasc, CWERASE, 15113073Ssam "lnext", <c.t_lnextc, CLNEXT, 1521179Sbill 0 1531179Sbill }; 1541179Sbill char *arg; 1551179Sbill 1561179Sbill int argc; 1571179Sbill char **argv; 1581179Sbill main(iargc, iargv) 15913073Ssam char **iargv; 1601179Sbill { 1611179Sbill int i; 1621179Sbill register struct special *sp; 1631179Sbill char obuf[BUFSIZ]; 1641179Sbill 1651179Sbill setbuf(stderr, obuf); 1661179Sbill argc = iargc; 1671179Sbill argv = iargv; 16813073Ssam ioctl(1, TIOCGETP, &mode); 1691179Sbill ioctl(1, TIOCGETD, &ldisc); 1701179Sbill oldisc = ldisc; 17113073Ssam ioctl(1, TIOCGETC, &tc); 17213073Ssam ioctl(1, TIOCLGET, &lmode); 17313073Ssam ioctl(1, TIOCGLTC, <c); 17413073Ssam if(argc == 1) { 1751179Sbill prmodes(0); 1761179Sbill exit(0); 1771179Sbill } 1781179Sbill if (argc == 2 && !strcmp(argv[1], "all")) { 1791179Sbill prmodes(1); 1801179Sbill exit(0); 1811179Sbill } 1821179Sbill if (argc == 2 && !strcmp(argv[1], "everything")) { 1831179Sbill prmodes(2); 1841179Sbill exit(0); 1851179Sbill } 18613073Ssam /* 18713073Ssam if (argc == 2 && !strcmp(argv[1], "all")) { 18813073Ssam prmodes(2); 18913073Ssam exit(0); 19013073Ssam } 19113073Ssam */ 19213073Ssam while(--argc > 0) { 1931179Sbill arg = *++argv; 19413073Ssam if (eq("ek")){ 19513073Ssam mode.sg_erase = '#'; 19613073Ssam mode.sg_kill = '@'; 1971179Sbill continue; 1981179Sbill } 19913073Ssam if (eq("new")){ 2001179Sbill ldisc = NTTYDISC; 20113073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2021179Sbill perror("ioctl"); 2031179Sbill continue; 2041179Sbill } 20513073Ssam if (eq("newcrt")){ 2061179Sbill ldisc = NTTYDISC; 20713073Ssam lmode &= ~LPRTERA; 20813073Ssam lmode |= LCRTBS|LCTLECH; 20913073Ssam if (mode.sg_ospeed >= B1200) 21013073Ssam lmode |= LCRTERA|LCRTKIL; 21113073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2121179Sbill perror("ioctl"); 2131179Sbill continue; 2141179Sbill } 21513073Ssam if (eq("crt")){ 21613073Ssam lmode &= ~LPRTERA; 21713073Ssam lmode |= LCRTBS|LCTLECH; 21813073Ssam if (mode.sg_ospeed >= B1200) 21913073Ssam lmode |= LCRTERA|LCRTKIL; 2201179Sbill continue; 2211179Sbill } 22213073Ssam if (eq("old")){ 22313073Ssam ldisc = 0; 22413073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2251179Sbill perror("ioctl"); 2261179Sbill continue; 2271179Sbill } 22813073Ssam if (eq("dec")){ 22913073Ssam mode.sg_erase = 0177; 23013073Ssam mode.sg_kill = CTRL(u); 23113073Ssam tc.t_intrc = CTRL(c); 2323797Sroot ldisc = NTTYDISC; 23313073Ssam lmode &= ~LPRTERA; 23413073Ssam lmode |= LCRTBS|LCTLECH|LDECCTQ; 23513073Ssam if (mode.sg_ospeed >= B1200) 23613073Ssam lmode |= LCRTERA|LCRTKIL; 23713073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2383797Sroot perror("ioctl"); 2393797Sroot continue; 2403797Sroot } 2411179Sbill for (sp = special; sp->name; sp++) 2421179Sbill if (eq(sp->name)) { 2431179Sbill if (--argc == 0) 2441179Sbill goto done; 2451179Sbill if (**++argv == 'u') 2461179Sbill *sp->cp = 0377; 2471179Sbill else if (**argv == '^') 2483955Sroot *sp->cp = ((*argv)[1] == '?') ? 2491179Sbill 0177 : (*argv)[1] & 037; 2501179Sbill else 2511179Sbill *sp->cp = **argv; 2521179Sbill goto cont; 2531179Sbill } 2541179Sbill if (eq("gspeed")) { 25513073Ssam mode.sg_ispeed = B300; 25613073Ssam mode.sg_ospeed = B9600; 2571179Sbill continue; 2581179Sbill } 2591179Sbill if (eq("hup")) { 26013073Ssam ioctl(1, TIOCHPCL, NULL); 2611179Sbill continue; 2621179Sbill } 26313073Ssam for(i=0; speeds[i].string; i++) 26413073Ssam if(eq(speeds[i].string)) { 26513073Ssam mode.sg_ispeed = mode.sg_ospeed = speeds[i].speed; 2661179Sbill goto cont; 2671179Sbill } 2681179Sbill if (eq("speed")) { 26913073Ssam ioctl(open("/dev/tty", 0), TIOCGETP, &mode); 27013073Ssam for(i=0; speeds[i].string; i++) 27113073Ssam if (mode.sg_ospeed == speeds[i].speed) { 2721179Sbill printf("%s\n", speeds[i].string); 2731179Sbill exit(0); 2741179Sbill } 2751179Sbill printf("unknown\n"); 2761179Sbill exit(1); 2771179Sbill } 27813073Ssam for(i=0; modes[i].string; i++) 27913073Ssam if(eq(modes[i].string)) { 28013073Ssam mode.sg_flags &= ~modes[i].reset; 28113073Ssam mode.sg_flags |= modes[i].set; 28213073Ssam lmode &= ~modes[i].lreset; 28313073Ssam lmode |= modes[i].lset; 2841179Sbill } 28513073Ssam if(arg) 2861179Sbill fprintf(stderr,"unknown mode: %s\n", arg); 2871179Sbill cont: 2881179Sbill ; 2891179Sbill } 2901179Sbill done: 29113073Ssam ioctl(1, TIOCSETN, &mode); 29213073Ssam ioctl(1, TIOCSETC, &tc); 29313073Ssam ioctl(1, TIOCSLTC, <c); 29413073Ssam ioctl(1, TIOCLSET, &lmode); 2951179Sbill } 2961179Sbill 2971179Sbill eq(string) 29813073Ssam char *string; 2991179Sbill { 3001179Sbill int i; 3011179Sbill 30213073Ssam if(!arg) 30313073Ssam return(0); 3041179Sbill i = 0; 3051179Sbill loop: 30613073Ssam if(arg[i] != string[i]) 3071179Sbill return(0); 30813073Ssam if(arg[i++] != '\0') 3091179Sbill goto loop; 3101179Sbill arg = 0; 31113073Ssam return(1); 3121179Sbill } 3131179Sbill 3141179Sbill prmodes(all) 3151179Sbill { 3161179Sbill register m; 3171179Sbill int any; 3181179Sbill 31913073Ssam if(ldisc==NETLDISC) 3201179Sbill fprintf(stderr, "net discipline, "); 32113073Ssam else if(ldisc==NTTYDISC) 3221179Sbill fprintf(stderr, "new tty, "); 32313073Ssam else if(all==2) 3241179Sbill fprintf(stderr, "old tty, "); 32513073Ssam if(mode.sg_ispeed != mode.sg_ospeed) { 32613073Ssam prspeed("input speed ", mode.sg_ispeed); 32713073Ssam prspeed("output speed ", mode.sg_ospeed); 3281179Sbill } else 32913073Ssam prspeed("speed ", mode.sg_ispeed); 33013073Ssam fprintf(stderr, all==2 ? "\n" : "; "); 33113073Ssam m = mode.sg_flags; 33213073Ssam if(all==2 || (m&(EVENP|ODDP))!=(EVENP|ODDP)) { 33313073Ssam if(m & EVENP) fprintf(stderr,"even "); 33413073Ssam if(m & ODDP) fprintf(stderr,"odd "); 3351179Sbill } 33613073Ssam if(all==2 || m&RAW) 33713073Ssam fprintf(stderr,"-raw "+((m&RAW)!=0)); 33813073Ssam if(all==2 || (m&CRMOD)==0) 33913073Ssam fprintf(stderr,"-nl "+((m&CRMOD)==0)); 34013073Ssam if(all==2 || (m&ECHO)==0) 34113073Ssam fprintf(stderr,"-echo "+((m&ECHO)!=0)); 34213073Ssam if(all==2 || (m&LCASE)) 34313073Ssam fprintf(stderr,"-lcase "+((m&LCASE)!=0)); 34413073Ssam if(all==2 || (m&TANDEM)) 34513073Ssam fprintf(stderr,"-tandem "+((m&TANDEM)!=0)); 34613073Ssam fprintf(stderr,"-tabs "+((m&XTABS)!=XTABS)); 34713073Ssam if(all==2 || (m&CBREAK)) 34813073Ssam fprintf(stderr,"-cbreak "+((m&CBREAK)!=0)); 34913073Ssam if(all==2 || (m&NLDELAY)) 35013073Ssam delay((m&NLDELAY)/NL1, "nl"); 35113073Ssam if ((m&TBDELAY)!=XTABS) 35213073Ssam delay((m&TBDELAY)/TAB1, "tab"); 35313073Ssam if(all==2 || (m&CRDELAY)) 35413073Ssam delay((m&CRDELAY)/CR1, "cr"); 35513073Ssam if(all==2 || (m&VTDELAY)) 35613073Ssam delay((m&VTDELAY)/FF1, "ff"); 35713073Ssam if(all==2 || (m&BSDELAY)) 35813073Ssam delay((m&BSDELAY)/BS1, "bs"); 3591179Sbill if (all) 3601179Sbill fprintf(stderr,"\n"); 3611179Sbill #define lpit(what,str) \ 36213073Ssam if (all==2||(lmode&what)) { \ 36313073Ssam fprintf(stderr,str+((lmode&what)!=0)); any++; \ 3641179Sbill } 3651179Sbill if (ldisc == NTTYDISC) { 36613073Ssam int newcrt = (lmode&(LCTLECH|LCRTBS)) == (LCTLECH|LCRTBS) && 36713073Ssam (lmode&(LCRTERA|LCRTKIL)) == 36813073Ssam ((mode.sg_ospeed > B300) ? LCRTERA|LCRTKIL : 0); 369*13817Ssam int nothing = 1; 3701179Sbill if (newcrt) { 37113073Ssam if (all==2) 37213073Ssam fprintf(stderr, "crt: (crtbs crterase crtkill ctlecho) "); 37313073Ssam else 37413073Ssam fprintf(stderr, "crt "); 3751179Sbill any++; 3761179Sbill } else { 37713073Ssam lpit(LCRTBS, "-crtbs "); 37813073Ssam lpit(LCRTERA, "-crterase "); 37913073Ssam lpit(LCRTKIL, "-crtkill "); 38013073Ssam lpit(LCTLECH, "-ctlecho "); 38113073Ssam lpit(LPRTERA, "-prterase "); 3821179Sbill } 38313073Ssam lpit(LTOSTOP, "-tostop "); 38413073Ssam if (all==2) { 3851179Sbill fprintf(stderr, "\n"); 3861179Sbill any = 0; 387*13817Ssam nothing = 0; 3881179Sbill } 38913073Ssam lpit(LTILDE, "-tilde "); 39013073Ssam lpit(LFLUSHO, "-flusho "); 39113073Ssam lpit(LMDMBUF, "-mdmbuf "); 39213073Ssam lpit(LLITOUT, "-litout "); 39313073Ssam lpit(LNOHANG, "-nohang "); 3944017Sroot if (any) { 3954017Sroot fprintf(stderr,"\n"); 3964017Sroot any = 0; 397*13817Ssam nothing = 0; 3984017Sroot } 3999853Ssam #ifdef notdef 40013073Ssam lpit(LETXACK, "-etxack "); 4019853Ssam #endif 40213073Ssam lpit(LPENDIN, "-pendin "); 40313073Ssam lpit(LDECCTQ, "-decctlq "); 40413073Ssam lpit(LNOFLSH, "-noflsh "); 405*13817Ssam if (any || nothing) 4061179Sbill fprintf(stderr,"\n"); 4071179Sbill } else if (!all) 4081179Sbill fprintf(stderr,"\n"); 4091179Sbill if (all) { 4101179Sbill switch (ldisc) { 4111179Sbill 4121179Sbill case 0: 4131179Sbill fprintf(stderr,"\ 4141179Sbill erase kill intr quit stop eof\ 4151179Sbill \n"); 41613073Ssam pcol(mode.sg_erase, -1); 41713073Ssam pcol(mode.sg_kill, -1); 41813073Ssam pcol(tc.t_intrc, -1); 41913073Ssam pcol(tc.t_quitc, -1); 42013073Ssam pcol(tc.t_stopc, tc.t_startc); 42113073Ssam pcol(tc.t_eofc, tc.t_brkc); 4221179Sbill fprintf(stderr,"\n"); 4231179Sbill break; 4241179Sbill 4251179Sbill case NTTYDISC: 4261179Sbill fprintf(stderr,"\ 4271179Sbill erase kill werase rprnt flush lnext susp intr quit stop eof\ 4281179Sbill \n"); 42913073Ssam pcol(mode.sg_erase, -1); 43013073Ssam pcol(mode.sg_kill, -1); 43113073Ssam pcol(ltc.t_werasc, -1); 43213073Ssam pcol(ltc.t_rprntc, -1); 43313073Ssam pcol(ltc.t_flushc, -1); 43413073Ssam pcol(ltc.t_lnextc, -1); 43513073Ssam pcol(ltc.t_suspc, ltc.t_dsuspc); 43613073Ssam pcol(tc.t_intrc, -1); 43713073Ssam pcol(tc.t_quitc, -1); 43813073Ssam pcol(tc.t_stopc, tc.t_startc); 43913073Ssam pcol(tc.t_eofc, tc.t_brkc); 4401179Sbill fprintf(stderr,"\n"); 4411179Sbill break; 4421179Sbill } 4431179Sbill } else if (ldisc != NETLDISC) { 4441179Sbill register struct special *sp; 4451179Sbill int first = 1; 446*13817Ssam 4471179Sbill for (sp = special; sp->name; sp++) { 4481179Sbill if ((*sp->cp&0377) != (sp->def&0377)) { 4491179Sbill pit(*sp->cp, sp->name, first ? "" : ", "); 4501179Sbill first = 0; 4511179Sbill }; 45213073Ssam if (sp->cp == &tc.t_brkc && ldisc == 0) 4531179Sbill break; 4541179Sbill } 455*13817Ssam if (!first) 45613073Ssam fprintf(stderr, "\n"); 4571179Sbill } 4581179Sbill } 4591179Sbill 4601179Sbill pcol(ch1, ch2) 4611179Sbill int ch1, ch2; 4621179Sbill { 4631179Sbill int nout = 0; 4641179Sbill 4651179Sbill ch1 &= 0377; 4661179Sbill ch2 &= 0377; 4671179Sbill if (ch1 == ch2) 4681179Sbill ch2 = 0377; 4691179Sbill for (; ch1 != 0377 || ch2 != 0377; ch1 = ch2, ch2 = 0377) { 4701179Sbill if (ch1 == 0377) 4711179Sbill continue; 4721179Sbill if (ch1 & 0200) { 4731179Sbill fprintf(stderr, "M-"); 4741179Sbill nout += 2; 4751179Sbill ch1 &= ~ 0200; 4761179Sbill } 4771179Sbill if (ch1 == 0177) { 4781179Sbill fprintf(stderr, "^"); 4791179Sbill nout++; 4801179Sbill ch1 = '?'; 4811179Sbill } else if (ch1 < ' ') { 4821179Sbill fprintf(stderr, "^"); 4831179Sbill nout++; 4841179Sbill ch1 += '@'; 4851179Sbill } 4861179Sbill fprintf(stderr, "%c", ch1); 4871179Sbill nout++; 4881179Sbill if (ch2 != 0377) { 4891179Sbill fprintf(stderr, "/"); 4901179Sbill nout++; 4911179Sbill } 4921179Sbill } 4931179Sbill while (nout < 7) { 4941179Sbill fprintf(stderr, " "); 4951179Sbill nout++; 4961179Sbill } 4971179Sbill } 4981179Sbill 4991179Sbill pit(what, itsname, sep) 5001179Sbill unsigned what; 5011179Sbill char *itsname, *sep; 5021179Sbill { 5031179Sbill 5041179Sbill what &= 0377; 5051179Sbill fprintf(stderr, "%s%s", sep, itsname); 5061179Sbill if (what == 0377) { 5071179Sbill fprintf(stderr, " <undef>"); 5081179Sbill return; 5091179Sbill } 5101179Sbill fprintf(stderr, " = "); 5111179Sbill if (what & 0200) { 5121179Sbill fprintf(stderr, "M-"); 5131179Sbill what &= ~ 0200; 5141179Sbill } 5151179Sbill if (what == 0177) { 5161179Sbill fprintf(stderr, "^"); 5171179Sbill what = '?'; 5181179Sbill } else if (what < ' ') { 5191179Sbill fprintf(stderr, "^"); 5201179Sbill what += '@'; 5211179Sbill } 5221179Sbill fprintf(stderr, "%c", what); 5231179Sbill } 5241179Sbill 5251179Sbill delay(m, s) 52613073Ssam char *s; 5271179Sbill { 5281179Sbill 52913073Ssam if(m) 5301179Sbill fprintf(stderr,"%s%d ", s, m); 5311179Sbill } 5321179Sbill 5331179Sbill int speed[] = { 5346815Swnj 0,50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,19200,38400 5351179Sbill }; 5361179Sbill 5371179Sbill prspeed(c, s) 5381179Sbill char *c; 5391179Sbill { 5401179Sbill 5411179Sbill fprintf(stderr,"%s%d baud", c, speed[s]); 5421179Sbill } 543