119907Sdist /* 219907Sdist * Copyright (c) 1980 Regents of the University of California. 319907Sdist * All rights reserved. The Berkeley software License Agreement 419907Sdist * specifies the terms and conditions for redistribution. 519907Sdist */ 619907Sdist 713073Ssam #ifndef lint 819907Sdist char copyright[] = 919907Sdist "@(#) Copyright (c) 1980 Regents of the University of California.\n\ 1019907Sdist All rights reserved.\n"; 1119907Sdist #endif not lint 1219907Sdist 1319907Sdist #ifndef lint 14*24277Slepreau static char sccsid[] = "@(#)stty.c 5.2 (Berkeley) 08/13/85"; 1519907Sdist #endif not lint 1619907Sdist 171179Sbill /* 181179Sbill * set teletype modes 191179Sbill */ 201179Sbill 211179Sbill #include <stdio.h> 2218023Sbloom #include <sys/ioctl.h> 231179Sbill 2413073Ssam struct 2513073Ssam { 261179Sbill char *string; 271179Sbill int speed; 281179Sbill } speeds[] = { 2913073Ssam "0", B0, 3013073Ssam "50", B50, 3113073Ssam "75", B75, 3213073Ssam "110", B110, 3313073Ssam "134", B134, 3413073Ssam "134.5",B134, 3513073Ssam "150", B150, 3613073Ssam "200", B200, 3713073Ssam "300", B300, 3813073Ssam "600", B600, 3913073Ssam "1200", B1200, 4013073Ssam "1800", B1800, 4113073Ssam "2400", B2400, 4213073Ssam "4800", B4800, 4313073Ssam "9600", B9600, 4413073Ssam "exta", EXTA, 4513073Ssam "19200", EXTA, 4613073Ssam "extb", EXTB, 4713073Ssam "38400", EXTB, 4813073Ssam 0, 491179Sbill }; 5013073Ssam struct 5113073Ssam { 521179Sbill char *string; 5313073Ssam int set; 5413073Ssam int reset; 5513073Ssam int lset; 5613073Ssam int lreset; 571179Sbill } modes[] = { 5813073Ssam "even", EVENP, 0, 0, 0, 5913073Ssam "-even", 0, EVENP, 0, 0, 6013073Ssam "odd", ODDP, 0, 0, 0, 6113073Ssam "-odd", 0, ODDP, 0, 0, 6213073Ssam "raw", RAW, 0, 0, 0, 6313073Ssam "-raw", 0, RAW, 0, 0, 6413073Ssam "cooked", 0, RAW, 0, 0, 6513073Ssam "-nl", CRMOD, 0, 0, 0, 6613073Ssam "nl", 0, CRMOD, 0, 0, 6713073Ssam "echo", ECHO, 0, 0, 0, 6813073Ssam "-echo", 0, ECHO, 0, 0, 6913073Ssam "LCASE", LCASE, 0, 0, 0, 7013073Ssam "lcase", LCASE, 0, 0, 0, 7113073Ssam "-LCASE", 0, LCASE, 0, 0, 7213073Ssam "-lcase", 0, LCASE, 0, 0, 7313073Ssam "-tabs", XTABS, 0, 0, 0, 7413073Ssam "tabs", 0, XTABS, 0, 0, 7513073Ssam "tandem", TANDEM, 0, 0, 0, 7613073Ssam "-tandem", 0, TANDEM, 0, 0, 7713073Ssam "cbreak", CBREAK, 0, 0, 0, 7813073Ssam "-cbreak", 0, CBREAK, 0, 0, 7913073Ssam "cr0", CR0, CR3, 0, 0, 8013073Ssam "cr1", CR1, CR3, 0, 0, 8113073Ssam "cr2", CR2, CR3, 0, 0, 8213073Ssam "cr3", CR3, CR3, 0, 0, 8313073Ssam "tab0", TAB0, XTABS, 0, 0, 8413073Ssam "tab1", TAB1, XTABS, 0, 0, 8513073Ssam "tab2", TAB2, XTABS, 0, 0, 8613073Ssam "nl0", NL0, NL3, 0, 0, 8713073Ssam "nl1", NL1, NL3, 0, 0, 8813073Ssam "nl2", NL2, NL3, 0, 0, 8913073Ssam "nl3", NL3, NL3, 0, 0, 9013073Ssam "ff0", FF0, FF1, 0, 0, 9113073Ssam "ff1", FF1, FF1, 0, 0, 9213073Ssam "bs0", BS0, BS1, 0, 0, 9313073Ssam "bs1", BS1, BS1, 0, 0, 9413073Ssam "33", CR1, ALLDELAY, 0, 0, 9513073Ssam "tty33", CR1, ALLDELAY, 0, 0, 9613073Ssam "37", FF1+CR2+TAB1+NL1, ALLDELAY, 0, 0, 9713073Ssam "tty37", FF1+CR2+TAB1+NL1, ALLDELAY, 0, 0, 9813073Ssam "05", NL2, ALLDELAY, 0, 0, 9913073Ssam "vt05", NL2, ALLDELAY, 0, 0, 10013073Ssam "tn", CR1, ALLDELAY, 0, 0, 10113073Ssam "tn300", CR1, ALLDELAY, 0, 0, 10213073Ssam "ti", CR2, ALLDELAY, 0, 0, 10313073Ssam "ti700", CR2, ALLDELAY, 0, 0, 10413073Ssam "tek", FF1, ALLDELAY, 0, 0, 10513073Ssam "crtbs", 0, 0, LCRTBS, LPRTERA, 10613073Ssam "-crtbs", 0, 0, 0, LCRTBS, 10713073Ssam "prterase", 0, 0, LPRTERA, LCRTBS+LCRTKIL+LCRTERA, 10813073Ssam "-prterase", 0, 0, 0, LPRTERA, 10913073Ssam "crterase", 0, 0, LCRTERA, LPRTERA, 11013073Ssam "-crterase", 0, 0, 0, LCRTERA, 11113073Ssam "crtkill", 0, 0, LCRTKIL, LPRTERA, 11213073Ssam "-crtkill", 0, 0, 0, LCRTKIL, 11313073Ssam "tilde", 0, 0, LTILDE, 0, 11413073Ssam "-tilde", 0, 0, 0, LTILDE, 11513073Ssam "mdmbuf", 0, 0, LMDMBUF, 0, 11613073Ssam "-mdmbuf", 0, 0, 0, LMDMBUF, 11713073Ssam "litout", 0, 0, LLITOUT, 0, 11813073Ssam "-litout", 0, 0, 0, LLITOUT, 119*24277Slepreau "pass8", 0, 0, LPASS8, 0, 120*24277Slepreau "-pass8", 0, 0, 0, LPASS8, 12113073Ssam "tostop", 0, 0, LTOSTOP, 0, 12213073Ssam "-tostop", 0, 0, 0, LTOSTOP, 12313073Ssam "flusho", 0, 0, LFLUSHO, 0, 12413073Ssam "-flusho", 0, 0, 0, LFLUSHO, 12513073Ssam "nohang", 0, 0, LNOHANG, 0, 12613073Ssam "-nohang", 0, 0, 0, LNOHANG, 1279853Ssam #ifdef notdef 12813073Ssam "etxack", 0, 0, LETXACK, 0, 12913073Ssam "-etxack", 0, 0, 0, LETXACK, 1309853Ssam #endif 13113073Ssam "ctlecho", 0, 0, LCTLECH, 0, 13213073Ssam "-ctlecho", 0, 0, 0, LCTLECH, 13313073Ssam "pendin", 0, 0, LPENDIN, 0, 13413073Ssam "-pendin", 0, 0, 0, LPENDIN, 13513073Ssam "decctlq", 0, 0, LDECCTQ, 0, 13613073Ssam "-decctlq", 0, 0, 0, LDECCTQ, 13713073Ssam "noflsh", 0, 0, LNOFLSH, 0, 13813073Ssam "-noflsh", 0, 0, 0, LNOFLSH, 13913073Ssam 0, 1401179Sbill }; 1411179Sbill 14213073Ssam struct tchars tc; 14313073Ssam struct ltchars ltc; 14413073Ssam struct sgttyb mode; 14518023Sbloom struct winsize win; 14613073Ssam int lmode; 1471179Sbill int oldisc, ldisc; 1481179Sbill 1491179Sbill struct special { 1501179Sbill char *name; 1511179Sbill char *cp; 1521179Sbill char def; 1531179Sbill } special[] = { 15413073Ssam "erase", &mode.sg_erase, CERASE, 15513073Ssam "kill", &mode.sg_kill, CKILL, 15613073Ssam "intr", &tc.t_intrc, CINTR, 15713073Ssam "quit", &tc.t_quitc, CQUIT, 15813073Ssam "start", &tc.t_startc, CSTART, 15913073Ssam "stop", &tc.t_stopc, CSTOP, 16013073Ssam "eof", &tc.t_eofc, CEOF, 16113073Ssam "brk", &tc.t_brkc, CBRK, 16213073Ssam "susp", <c.t_suspc, CSUSP, 16313073Ssam "dsusp", <c.t_dsuspc, CDSUSP, 16413073Ssam "rprnt", <c.t_rprntc, CRPRNT, 16513073Ssam "flush", <c.t_flushc, CFLUSH, 16613073Ssam "werase", <c.t_werasc, CWERASE, 16713073Ssam "lnext", <c.t_lnextc, CLNEXT, 1681179Sbill 0 1691179Sbill }; 1701179Sbill char *arg; 1711179Sbill 1721179Sbill int argc; 1731179Sbill char **argv; 1741179Sbill main(iargc, iargv) 17513073Ssam char **iargv; 1761179Sbill { 1771179Sbill int i; 1781179Sbill register struct special *sp; 1791179Sbill char obuf[BUFSIZ]; 1801179Sbill 1811179Sbill setbuf(stderr, obuf); 1821179Sbill argc = iargc; 1831179Sbill argv = iargv; 18413073Ssam ioctl(1, TIOCGETP, &mode); 1851179Sbill ioctl(1, TIOCGETD, &ldisc); 1861179Sbill oldisc = ldisc; 18713073Ssam ioctl(1, TIOCGETC, &tc); 18813073Ssam ioctl(1, TIOCLGET, &lmode); 18913073Ssam ioctl(1, TIOCGLTC, <c); 19018023Sbloom ioctl(1, TIOCGWINSZ, &win); 19113073Ssam if(argc == 1) { 1921179Sbill prmodes(0); 1931179Sbill exit(0); 1941179Sbill } 1951179Sbill if (argc == 2 && !strcmp(argv[1], "all")) { 1961179Sbill prmodes(1); 1971179Sbill exit(0); 1981179Sbill } 1991179Sbill if (argc == 2 && !strcmp(argv[1], "everything")) { 2001179Sbill prmodes(2); 2011179Sbill exit(0); 2021179Sbill } 20313073Ssam /* 20413073Ssam if (argc == 2 && !strcmp(argv[1], "all")) { 20513073Ssam prmodes(2); 20613073Ssam exit(0); 20713073Ssam } 20813073Ssam */ 20913073Ssam while(--argc > 0) { 2101179Sbill arg = *++argv; 21113073Ssam if (eq("ek")){ 21213073Ssam mode.sg_erase = '#'; 21313073Ssam mode.sg_kill = '@'; 2141179Sbill continue; 2151179Sbill } 21613073Ssam if (eq("new")){ 2171179Sbill ldisc = NTTYDISC; 21813073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2191179Sbill perror("ioctl"); 2201179Sbill continue; 2211179Sbill } 22213073Ssam if (eq("newcrt")){ 2231179Sbill ldisc = NTTYDISC; 22413073Ssam lmode &= ~LPRTERA; 22513073Ssam lmode |= LCRTBS|LCTLECH; 22613073Ssam if (mode.sg_ospeed >= B1200) 22713073Ssam lmode |= LCRTERA|LCRTKIL; 22813073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2291179Sbill perror("ioctl"); 2301179Sbill continue; 2311179Sbill } 23213073Ssam if (eq("crt")){ 23313073Ssam lmode &= ~LPRTERA; 23413073Ssam lmode |= LCRTBS|LCTLECH; 23513073Ssam if (mode.sg_ospeed >= B1200) 23613073Ssam lmode |= LCRTERA|LCRTKIL; 2371179Sbill continue; 2381179Sbill } 23913073Ssam if (eq("old")){ 24013073Ssam ldisc = 0; 24113073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2421179Sbill perror("ioctl"); 2431179Sbill continue; 2441179Sbill } 24513073Ssam if (eq("dec")){ 24613073Ssam mode.sg_erase = 0177; 24713073Ssam mode.sg_kill = CTRL(u); 24813073Ssam tc.t_intrc = CTRL(c); 2493797Sroot ldisc = NTTYDISC; 25013073Ssam lmode &= ~LPRTERA; 25113073Ssam lmode |= LCRTBS|LCTLECH|LDECCTQ; 25213073Ssam if (mode.sg_ospeed >= B1200) 25313073Ssam lmode |= LCRTERA|LCRTKIL; 25413073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2553797Sroot perror("ioctl"); 2563797Sroot continue; 2573797Sroot } 2581179Sbill for (sp = special; sp->name; sp++) 2591179Sbill if (eq(sp->name)) { 2601179Sbill if (--argc == 0) 2611179Sbill goto done; 2621179Sbill if (**++argv == 'u') 2631179Sbill *sp->cp = 0377; 2641179Sbill else if (**argv == '^') 2653955Sroot *sp->cp = ((*argv)[1] == '?') ? 2661179Sbill 0177 : (*argv)[1] & 037; 2671179Sbill else 2681179Sbill *sp->cp = **argv; 2691179Sbill goto cont; 2701179Sbill } 2711179Sbill if (eq("gspeed")) { 27213073Ssam mode.sg_ispeed = B300; 27313073Ssam mode.sg_ospeed = B9600; 2741179Sbill continue; 2751179Sbill } 2761179Sbill if (eq("hup")) { 27713073Ssam ioctl(1, TIOCHPCL, NULL); 2781179Sbill continue; 2791179Sbill } 28018023Sbloom if (eq("rows")) { 28118023Sbloom if (--argc == 0) 28218023Sbloom goto done; 28318023Sbloom win.ws_row = atoi(*++argv); 28418023Sbloom } 28518023Sbloom if (eq("columns")) { 28618023Sbloom if (--argc == 0) 28718023Sbloom goto done; 28818023Sbloom win.ws_col = atoi(*++argv); 28918023Sbloom } 29013073Ssam for(i=0; speeds[i].string; i++) 29113073Ssam if(eq(speeds[i].string)) { 29213073Ssam mode.sg_ispeed = mode.sg_ospeed = speeds[i].speed; 2931179Sbill goto cont; 2941179Sbill } 2951179Sbill if (eq("speed")) { 29613073Ssam ioctl(open("/dev/tty", 0), TIOCGETP, &mode); 29713073Ssam for(i=0; speeds[i].string; i++) 29813073Ssam if (mode.sg_ospeed == speeds[i].speed) { 2991179Sbill printf("%s\n", speeds[i].string); 3001179Sbill exit(0); 3011179Sbill } 3021179Sbill printf("unknown\n"); 3031179Sbill exit(1); 3041179Sbill } 30513073Ssam for(i=0; modes[i].string; i++) 30613073Ssam if(eq(modes[i].string)) { 30713073Ssam mode.sg_flags &= ~modes[i].reset; 30813073Ssam mode.sg_flags |= modes[i].set; 30913073Ssam lmode &= ~modes[i].lreset; 31013073Ssam lmode |= modes[i].lset; 3111179Sbill } 31213073Ssam if(arg) 3131179Sbill fprintf(stderr,"unknown mode: %s\n", arg); 3141179Sbill cont: 3151179Sbill ; 3161179Sbill } 3171179Sbill done: 31813073Ssam ioctl(1, TIOCSETN, &mode); 31913073Ssam ioctl(1, TIOCSETC, &tc); 32013073Ssam ioctl(1, TIOCSLTC, <c); 32113073Ssam ioctl(1, TIOCLSET, &lmode); 32218023Sbloom ioctl(1, TIOCSWINSZ, &win); 3231179Sbill } 3241179Sbill 3251179Sbill eq(string) 32613073Ssam char *string; 3271179Sbill { 3281179Sbill int i; 3291179Sbill 33013073Ssam if(!arg) 33113073Ssam return(0); 3321179Sbill i = 0; 3331179Sbill loop: 33413073Ssam if(arg[i] != string[i]) 3351179Sbill return(0); 33613073Ssam if(arg[i++] != '\0') 3371179Sbill goto loop; 3381179Sbill arg = 0; 33913073Ssam return(1); 3401179Sbill } 3411179Sbill 3421179Sbill prmodes(all) 3431179Sbill { 3441179Sbill register m; 3451179Sbill int any; 3461179Sbill 34713073Ssam if(ldisc==NETLDISC) 3481179Sbill fprintf(stderr, "net discipline, "); 34913073Ssam else if(ldisc==NTTYDISC) 3501179Sbill fprintf(stderr, "new tty, "); 35113073Ssam else if(all==2) 3521179Sbill fprintf(stderr, "old tty, "); 35313073Ssam if(mode.sg_ispeed != mode.sg_ospeed) { 35413073Ssam prspeed("input speed ", mode.sg_ispeed); 35513073Ssam prspeed("output speed ", mode.sg_ospeed); 3561179Sbill } else 35713073Ssam prspeed("speed ", mode.sg_ispeed); 35818023Sbloom if (all) 35918023Sbloom fprintf(stderr, ", %d rows, %d columns", win.ws_row, win.ws_col); 36013073Ssam fprintf(stderr, all==2 ? "\n" : "; "); 36113073Ssam m = mode.sg_flags; 36213073Ssam if(all==2 || (m&(EVENP|ODDP))!=(EVENP|ODDP)) { 36313073Ssam if(m & EVENP) fprintf(stderr,"even "); 36413073Ssam if(m & ODDP) fprintf(stderr,"odd "); 3651179Sbill } 36613073Ssam if(all==2 || m&RAW) 36713073Ssam fprintf(stderr,"-raw "+((m&RAW)!=0)); 36813073Ssam if(all==2 || (m&CRMOD)==0) 36913073Ssam fprintf(stderr,"-nl "+((m&CRMOD)==0)); 37013073Ssam if(all==2 || (m&ECHO)==0) 37113073Ssam fprintf(stderr,"-echo "+((m&ECHO)!=0)); 37213073Ssam if(all==2 || (m&LCASE)) 37313073Ssam fprintf(stderr,"-lcase "+((m&LCASE)!=0)); 37413073Ssam if(all==2 || (m&TANDEM)) 37513073Ssam fprintf(stderr,"-tandem "+((m&TANDEM)!=0)); 37613073Ssam fprintf(stderr,"-tabs "+((m&XTABS)!=XTABS)); 37713073Ssam if(all==2 || (m&CBREAK)) 37813073Ssam fprintf(stderr,"-cbreak "+((m&CBREAK)!=0)); 37913073Ssam if(all==2 || (m&NLDELAY)) 38013073Ssam delay((m&NLDELAY)/NL1, "nl"); 38113073Ssam if ((m&TBDELAY)!=XTABS) 38213073Ssam delay((m&TBDELAY)/TAB1, "tab"); 38313073Ssam if(all==2 || (m&CRDELAY)) 38413073Ssam delay((m&CRDELAY)/CR1, "cr"); 38513073Ssam if(all==2 || (m&VTDELAY)) 38613073Ssam delay((m&VTDELAY)/FF1, "ff"); 38713073Ssam if(all==2 || (m&BSDELAY)) 38813073Ssam delay((m&BSDELAY)/BS1, "bs"); 3891179Sbill if (all) 3901179Sbill fprintf(stderr,"\n"); 3911179Sbill #define lpit(what,str) \ 39213073Ssam if (all==2||(lmode&what)) { \ 39313073Ssam fprintf(stderr,str+((lmode&what)!=0)); any++; \ 3941179Sbill } 3951179Sbill if (ldisc == NTTYDISC) { 39613073Ssam int newcrt = (lmode&(LCTLECH|LCRTBS)) == (LCTLECH|LCRTBS) && 39713073Ssam (lmode&(LCRTERA|LCRTKIL)) == 39813073Ssam ((mode.sg_ospeed > B300) ? LCRTERA|LCRTKIL : 0); 39913817Ssam int nothing = 1; 4001179Sbill if (newcrt) { 40113073Ssam if (all==2) 40213073Ssam fprintf(stderr, "crt: (crtbs crterase crtkill ctlecho) "); 40313073Ssam else 40413073Ssam fprintf(stderr, "crt "); 4051179Sbill any++; 4061179Sbill } else { 40713073Ssam lpit(LCRTBS, "-crtbs "); 40813073Ssam lpit(LCRTERA, "-crterase "); 40913073Ssam lpit(LCRTKIL, "-crtkill "); 41013073Ssam lpit(LCTLECH, "-ctlecho "); 41113073Ssam lpit(LPRTERA, "-prterase "); 4121179Sbill } 41313073Ssam lpit(LTOSTOP, "-tostop "); 41413073Ssam if (all==2) { 4151179Sbill fprintf(stderr, "\n"); 4161179Sbill any = 0; 41713817Ssam nothing = 0; 4181179Sbill } 41913073Ssam lpit(LTILDE, "-tilde "); 42013073Ssam lpit(LFLUSHO, "-flusho "); 42113073Ssam lpit(LMDMBUF, "-mdmbuf "); 42213073Ssam lpit(LLITOUT, "-litout "); 423*24277Slepreau lpit(LPASS8, "-pass8 "); 42413073Ssam lpit(LNOHANG, "-nohang "); 4254017Sroot if (any) { 4264017Sroot fprintf(stderr,"\n"); 4274017Sroot any = 0; 42813817Ssam nothing = 0; 4294017Sroot } 4309853Ssam #ifdef notdef 43113073Ssam lpit(LETXACK, "-etxack "); 4329853Ssam #endif 43313073Ssam lpit(LPENDIN, "-pendin "); 43413073Ssam lpit(LDECCTQ, "-decctlq "); 43513073Ssam lpit(LNOFLSH, "-noflsh "); 43613817Ssam if (any || nothing) 4371179Sbill fprintf(stderr,"\n"); 4381179Sbill } else if (!all) 4391179Sbill fprintf(stderr,"\n"); 4401179Sbill if (all) { 4411179Sbill switch (ldisc) { 4421179Sbill 4431179Sbill case 0: 4441179Sbill fprintf(stderr,"\ 4451179Sbill erase kill intr quit stop eof\ 4461179Sbill \n"); 44713073Ssam pcol(mode.sg_erase, -1); 44813073Ssam pcol(mode.sg_kill, -1); 44913073Ssam pcol(tc.t_intrc, -1); 45013073Ssam pcol(tc.t_quitc, -1); 45113073Ssam pcol(tc.t_stopc, tc.t_startc); 45213073Ssam pcol(tc.t_eofc, tc.t_brkc); 4531179Sbill fprintf(stderr,"\n"); 4541179Sbill break; 4551179Sbill 4561179Sbill case NTTYDISC: 4571179Sbill fprintf(stderr,"\ 4581179Sbill erase kill werase rprnt flush lnext susp intr quit stop eof\ 4591179Sbill \n"); 46013073Ssam pcol(mode.sg_erase, -1); 46113073Ssam pcol(mode.sg_kill, -1); 46213073Ssam pcol(ltc.t_werasc, -1); 46313073Ssam pcol(ltc.t_rprntc, -1); 46413073Ssam pcol(ltc.t_flushc, -1); 46513073Ssam pcol(ltc.t_lnextc, -1); 46613073Ssam pcol(ltc.t_suspc, ltc.t_dsuspc); 46713073Ssam pcol(tc.t_intrc, -1); 46813073Ssam pcol(tc.t_quitc, -1); 46913073Ssam pcol(tc.t_stopc, tc.t_startc); 47013073Ssam pcol(tc.t_eofc, tc.t_brkc); 4711179Sbill fprintf(stderr,"\n"); 4721179Sbill break; 4731179Sbill } 4741179Sbill } else if (ldisc != NETLDISC) { 4751179Sbill register struct special *sp; 4761179Sbill int first = 1; 47713817Ssam 4781179Sbill for (sp = special; sp->name; sp++) { 4791179Sbill if ((*sp->cp&0377) != (sp->def&0377)) { 4801179Sbill pit(*sp->cp, sp->name, first ? "" : ", "); 4811179Sbill first = 0; 4821179Sbill }; 48313073Ssam if (sp->cp == &tc.t_brkc && ldisc == 0) 4841179Sbill break; 4851179Sbill } 48613817Ssam if (!first) 48713073Ssam fprintf(stderr, "\n"); 4881179Sbill } 4891179Sbill } 4901179Sbill 4911179Sbill pcol(ch1, ch2) 4921179Sbill int ch1, ch2; 4931179Sbill { 4941179Sbill int nout = 0; 4951179Sbill 4961179Sbill ch1 &= 0377; 4971179Sbill ch2 &= 0377; 4981179Sbill if (ch1 == ch2) 4991179Sbill ch2 = 0377; 5001179Sbill for (; ch1 != 0377 || ch2 != 0377; ch1 = ch2, ch2 = 0377) { 5011179Sbill if (ch1 == 0377) 5021179Sbill continue; 5031179Sbill if (ch1 & 0200) { 5041179Sbill fprintf(stderr, "M-"); 5051179Sbill nout += 2; 5061179Sbill ch1 &= ~ 0200; 5071179Sbill } 5081179Sbill if (ch1 == 0177) { 5091179Sbill fprintf(stderr, "^"); 5101179Sbill nout++; 5111179Sbill ch1 = '?'; 5121179Sbill } else if (ch1 < ' ') { 5131179Sbill fprintf(stderr, "^"); 5141179Sbill nout++; 5151179Sbill ch1 += '@'; 5161179Sbill } 5171179Sbill fprintf(stderr, "%c", ch1); 5181179Sbill nout++; 5191179Sbill if (ch2 != 0377) { 5201179Sbill fprintf(stderr, "/"); 5211179Sbill nout++; 5221179Sbill } 5231179Sbill } 5241179Sbill while (nout < 7) { 5251179Sbill fprintf(stderr, " "); 5261179Sbill nout++; 5271179Sbill } 5281179Sbill } 5291179Sbill 5301179Sbill pit(what, itsname, sep) 5311179Sbill unsigned what; 5321179Sbill char *itsname, *sep; 5331179Sbill { 5341179Sbill 5351179Sbill what &= 0377; 5361179Sbill fprintf(stderr, "%s%s", sep, itsname); 5371179Sbill if (what == 0377) { 5381179Sbill fprintf(stderr, " <undef>"); 5391179Sbill return; 5401179Sbill } 5411179Sbill fprintf(stderr, " = "); 5421179Sbill if (what & 0200) { 5431179Sbill fprintf(stderr, "M-"); 5441179Sbill what &= ~ 0200; 5451179Sbill } 5461179Sbill if (what == 0177) { 5471179Sbill fprintf(stderr, "^"); 5481179Sbill what = '?'; 5491179Sbill } else if (what < ' ') { 5501179Sbill fprintf(stderr, "^"); 5511179Sbill what += '@'; 5521179Sbill } 5531179Sbill fprintf(stderr, "%c", what); 5541179Sbill } 5551179Sbill 5561179Sbill delay(m, s) 55713073Ssam char *s; 5581179Sbill { 5591179Sbill 56013073Ssam if(m) 5611179Sbill fprintf(stderr,"%s%d ", s, m); 5621179Sbill } 5631179Sbill 5641179Sbill int speed[] = { 5656815Swnj 0,50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,19200,38400 5661179Sbill }; 5671179Sbill 5681179Sbill prspeed(c, s) 5691179Sbill char *c; 5701179Sbill { 5711179Sbill 5721179Sbill fprintf(stderr,"%s%d baud", c, speed[s]); 5731179Sbill } 574