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*37609Sbostic static char sccsid[] = "@(#)stty.c 5.6 (Berkeley) 05/01/89"; 1519907Sdist #endif not lint 1619907Sdist 171179Sbill /* 181179Sbill * set teletype modes 191179Sbill */ 201179Sbill 21*37609Sbostic #include <sys/ioctl.h> 221179Sbill #include <stdio.h> 23*37609Sbostic #include "pathnames.h" 241179Sbill 2513073Ssam struct 2613073Ssam { 271179Sbill char *string; 281179Sbill int speed; 291179Sbill } speeds[] = { 3013073Ssam "0", B0, 3113073Ssam "50", B50, 3213073Ssam "75", B75, 3313073Ssam "110", B110, 3413073Ssam "134", B134, 3513073Ssam "134.5",B134, 3613073Ssam "150", B150, 3713073Ssam "200", B200, 3813073Ssam "300", B300, 3913073Ssam "600", B600, 4013073Ssam "1200", B1200, 4113073Ssam "1800", B1800, 4213073Ssam "2400", B2400, 4313073Ssam "4800", B4800, 4413073Ssam "9600", B9600, 4513073Ssam "exta", EXTA, 4613073Ssam "19200", EXTA, 4713073Ssam "extb", EXTB, 4813073Ssam "38400", EXTB, 4913073Ssam 0, 501179Sbill }; 5113073Ssam struct 5213073Ssam { 531179Sbill char *string; 5413073Ssam int set; 5513073Ssam int reset; 5613073Ssam int lset; 5713073Ssam int lreset; 581179Sbill } modes[] = { 5913073Ssam "even", EVENP, 0, 0, 0, 6013073Ssam "-even", 0, EVENP, 0, 0, 6113073Ssam "odd", ODDP, 0, 0, 0, 6213073Ssam "-odd", 0, ODDP, 0, 0, 6313073Ssam "raw", RAW, 0, 0, 0, 6413073Ssam "-raw", 0, RAW, 0, 0, 6513073Ssam "cooked", 0, RAW, 0, 0, 6613073Ssam "-nl", CRMOD, 0, 0, 0, 6713073Ssam "nl", 0, CRMOD, 0, 0, 6813073Ssam "echo", ECHO, 0, 0, 0, 6913073Ssam "-echo", 0, ECHO, 0, 0, 7013073Ssam "LCASE", LCASE, 0, 0, 0, 7113073Ssam "lcase", LCASE, 0, 0, 0, 7213073Ssam "-LCASE", 0, LCASE, 0, 0, 7313073Ssam "-lcase", 0, LCASE, 0, 0, 7413073Ssam "-tabs", XTABS, 0, 0, 0, 7513073Ssam "tabs", 0, XTABS, 0, 0, 7613073Ssam "tandem", TANDEM, 0, 0, 0, 7713073Ssam "-tandem", 0, TANDEM, 0, 0, 7813073Ssam "cbreak", CBREAK, 0, 0, 0, 7913073Ssam "-cbreak", 0, CBREAK, 0, 0, 8013073Ssam "cr0", CR0, CR3, 0, 0, 8113073Ssam "cr1", CR1, CR3, 0, 0, 8213073Ssam "cr2", CR2, CR3, 0, 0, 8313073Ssam "cr3", CR3, CR3, 0, 0, 8413073Ssam "tab0", TAB0, XTABS, 0, 0, 8513073Ssam "tab1", TAB1, XTABS, 0, 0, 8613073Ssam "tab2", TAB2, XTABS, 0, 0, 8713073Ssam "nl0", NL0, NL3, 0, 0, 8813073Ssam "nl1", NL1, NL3, 0, 0, 8913073Ssam "nl2", NL2, NL3, 0, 0, 9013073Ssam "nl3", NL3, NL3, 0, 0, 9113073Ssam "ff0", FF0, FF1, 0, 0, 9213073Ssam "ff1", FF1, FF1, 0, 0, 9313073Ssam "bs0", BS0, BS1, 0, 0, 9413073Ssam "bs1", BS1, BS1, 0, 0, 9513073Ssam "33", CR1, ALLDELAY, 0, 0, 9613073Ssam "tty33", CR1, ALLDELAY, 0, 0, 9713073Ssam "37", FF1+CR2+TAB1+NL1, ALLDELAY, 0, 0, 9813073Ssam "tty37", FF1+CR2+TAB1+NL1, ALLDELAY, 0, 0, 9913073Ssam "05", NL2, ALLDELAY, 0, 0, 10013073Ssam "vt05", NL2, ALLDELAY, 0, 0, 10113073Ssam "tn", CR1, ALLDELAY, 0, 0, 10213073Ssam "tn300", CR1, ALLDELAY, 0, 0, 10313073Ssam "ti", CR2, ALLDELAY, 0, 0, 10413073Ssam "ti700", CR2, ALLDELAY, 0, 0, 10513073Ssam "tek", FF1, ALLDELAY, 0, 0, 10613073Ssam "crtbs", 0, 0, LCRTBS, LPRTERA, 10713073Ssam "-crtbs", 0, 0, 0, LCRTBS, 10813073Ssam "prterase", 0, 0, LPRTERA, LCRTBS+LCRTKIL+LCRTERA, 10913073Ssam "-prterase", 0, 0, 0, LPRTERA, 11013073Ssam "crterase", 0, 0, LCRTERA, LPRTERA, 11113073Ssam "-crterase", 0, 0, 0, LCRTERA, 11213073Ssam "crtkill", 0, 0, LCRTKIL, LPRTERA, 11313073Ssam "-crtkill", 0, 0, 0, LCRTKIL, 11413073Ssam "tilde", 0, 0, LTILDE, 0, 11513073Ssam "-tilde", 0, 0, 0, LTILDE, 11613073Ssam "mdmbuf", 0, 0, LMDMBUF, 0, 11713073Ssam "-mdmbuf", 0, 0, 0, LMDMBUF, 11813073Ssam "litout", 0, 0, LLITOUT, 0, 11913073Ssam "-litout", 0, 0, 0, LLITOUT, 12024277Slepreau "pass8", 0, 0, LPASS8, 0, 12124277Slepreau "-pass8", 0, 0, 0, LPASS8, 12213073Ssam "tostop", 0, 0, LTOSTOP, 0, 12313073Ssam "-tostop", 0, 0, 0, LTOSTOP, 12413073Ssam "flusho", 0, 0, LFLUSHO, 0, 12513073Ssam "-flusho", 0, 0, 0, LFLUSHO, 12613073Ssam "nohang", 0, 0, LNOHANG, 0, 12713073Ssam "-nohang", 0, 0, 0, LNOHANG, 1289853Ssam #ifdef notdef 12913073Ssam "etxack", 0, 0, LETXACK, 0, 13013073Ssam "-etxack", 0, 0, 0, LETXACK, 1319853Ssam #endif 13213073Ssam "ctlecho", 0, 0, LCTLECH, 0, 13313073Ssam "-ctlecho", 0, 0, 0, LCTLECH, 13413073Ssam "pendin", 0, 0, LPENDIN, 0, 13513073Ssam "-pendin", 0, 0, 0, LPENDIN, 13613073Ssam "decctlq", 0, 0, LDECCTQ, 0, 13713073Ssam "-decctlq", 0, 0, 0, LDECCTQ, 13813073Ssam "noflsh", 0, 0, LNOFLSH, 0, 13913073Ssam "-noflsh", 0, 0, 0, LNOFLSH, 14013073Ssam 0, 1411179Sbill }; 1421179Sbill 14313073Ssam struct tchars tc; 14413073Ssam struct ltchars ltc; 14513073Ssam struct sgttyb mode; 14618023Sbloom struct winsize win; 14713073Ssam int lmode; 1481179Sbill int oldisc, ldisc; 1491179Sbill 1501179Sbill struct special { 1511179Sbill char *name; 1521179Sbill char *cp; 1531179Sbill char def; 1541179Sbill } special[] = { 15513073Ssam "erase", &mode.sg_erase, CERASE, 15613073Ssam "kill", &mode.sg_kill, CKILL, 15713073Ssam "intr", &tc.t_intrc, CINTR, 15813073Ssam "quit", &tc.t_quitc, CQUIT, 15913073Ssam "start", &tc.t_startc, CSTART, 16013073Ssam "stop", &tc.t_stopc, CSTOP, 16113073Ssam "eof", &tc.t_eofc, CEOF, 16213073Ssam "brk", &tc.t_brkc, CBRK, 16313073Ssam "susp", <c.t_suspc, CSUSP, 16413073Ssam "dsusp", <c.t_dsuspc, CDSUSP, 16513073Ssam "rprnt", <c.t_rprntc, CRPRNT, 16613073Ssam "flush", <c.t_flushc, CFLUSH, 16713073Ssam "werase", <c.t_werasc, CWERASE, 16813073Ssam "lnext", <c.t_lnextc, CLNEXT, 1691179Sbill 0 1701179Sbill }; 1711179Sbill char *arg; 1721179Sbill 1731179Sbill int argc; 1741179Sbill char **argv; 1751179Sbill main(iargc, iargv) 17613073Ssam char **iargv; 1771179Sbill { 1781179Sbill int i; 1791179Sbill register struct special *sp; 1801179Sbill char obuf[BUFSIZ]; 1811179Sbill 1821179Sbill setbuf(stderr, obuf); 1831179Sbill argc = iargc; 1841179Sbill argv = iargv; 18513073Ssam ioctl(1, TIOCGETP, &mode); 1861179Sbill ioctl(1, TIOCGETD, &ldisc); 1871179Sbill oldisc = ldisc; 18813073Ssam ioctl(1, TIOCGETC, &tc); 18913073Ssam ioctl(1, TIOCLGET, &lmode); 19013073Ssam ioctl(1, TIOCGLTC, <c); 19118023Sbloom ioctl(1, TIOCGWINSZ, &win); 19213073Ssam if(argc == 1) { 1931179Sbill prmodes(0); 1941179Sbill exit(0); 1951179Sbill } 1961179Sbill if (argc == 2 && !strcmp(argv[1], "all")) { 1971179Sbill prmodes(1); 1981179Sbill exit(0); 1991179Sbill } 2001179Sbill if (argc == 2 && !strcmp(argv[1], "everything")) { 2011179Sbill prmodes(2); 2021179Sbill exit(0); 2031179Sbill } 20413073Ssam /* 20513073Ssam if (argc == 2 && !strcmp(argv[1], "all")) { 20613073Ssam prmodes(2); 20713073Ssam exit(0); 20813073Ssam } 20913073Ssam */ 21013073Ssam while(--argc > 0) { 2111179Sbill arg = *++argv; 21213073Ssam if (eq("ek")){ 21313073Ssam mode.sg_erase = '#'; 21413073Ssam mode.sg_kill = '@'; 2151179Sbill continue; 2161179Sbill } 21713073Ssam if (eq("new")){ 2181179Sbill ldisc = NTTYDISC; 21913073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2201179Sbill perror("ioctl"); 2211179Sbill continue; 2221179Sbill } 22313073Ssam if (eq("newcrt")){ 2241179Sbill ldisc = NTTYDISC; 22513073Ssam lmode &= ~LPRTERA; 22613073Ssam lmode |= LCRTBS|LCTLECH; 22713073Ssam if (mode.sg_ospeed >= B1200) 22813073Ssam lmode |= LCRTERA|LCRTKIL; 22913073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2301179Sbill perror("ioctl"); 2311179Sbill continue; 2321179Sbill } 23313073Ssam if (eq("crt")){ 23413073Ssam lmode &= ~LPRTERA; 23513073Ssam lmode |= LCRTBS|LCTLECH; 23613073Ssam if (mode.sg_ospeed >= B1200) 23713073Ssam lmode |= LCRTERA|LCRTKIL; 2381179Sbill continue; 2391179Sbill } 24013073Ssam if (eq("old")){ 24113073Ssam ldisc = 0; 24213073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2431179Sbill perror("ioctl"); 2441179Sbill continue; 2451179Sbill } 24613073Ssam if (eq("dec")){ 24713073Ssam mode.sg_erase = 0177; 24833089Sbostic mode.sg_kill = CKILL; 24933089Sbostic tc.t_intrc = CINTR; 2503797Sroot ldisc = NTTYDISC; 25113073Ssam lmode &= ~LPRTERA; 25213073Ssam lmode |= LCRTBS|LCTLECH|LDECCTQ; 25313073Ssam if (mode.sg_ospeed >= B1200) 25413073Ssam lmode |= LCRTERA|LCRTKIL; 25513073Ssam if (ioctl(1, TIOCSETD, &ldisc)<0) 2563797Sroot perror("ioctl"); 2573797Sroot continue; 2583797Sroot } 2591179Sbill for (sp = special; sp->name; sp++) 2601179Sbill if (eq(sp->name)) { 2611179Sbill if (--argc == 0) 2621179Sbill goto done; 2631179Sbill if (**++argv == 'u') 2641179Sbill *sp->cp = 0377; 2651179Sbill else if (**argv == '^') 2663955Sroot *sp->cp = ((*argv)[1] == '?') ? 2671179Sbill 0177 : (*argv)[1] & 037; 2681179Sbill else 2691179Sbill *sp->cp = **argv; 2701179Sbill goto cont; 2711179Sbill } 2721179Sbill if (eq("gspeed")) { 27313073Ssam mode.sg_ispeed = B300; 27413073Ssam mode.sg_ospeed = B9600; 2751179Sbill continue; 2761179Sbill } 2771179Sbill if (eq("hup")) { 27813073Ssam ioctl(1, TIOCHPCL, NULL); 2791179Sbill continue; 2801179Sbill } 28118023Sbloom if (eq("rows")) { 28218023Sbloom if (--argc == 0) 28318023Sbloom goto done; 28418023Sbloom win.ws_row = atoi(*++argv); 28518023Sbloom } 28627011Sbloom if (eq("cols") || eq("columns")) { 28718023Sbloom if (--argc == 0) 28818023Sbloom goto done; 28918023Sbloom win.ws_col = atoi(*++argv); 29018023Sbloom } 29125791Skarels if (eq("size")) { 292*37609Sbostic ioctl(open(_PATH_DEVTTY, 0), TIOCGWINSZ, &win); 29325791Skarels printf("%d %d\n", win.ws_row, win.ws_col); 29425791Skarels exit(0); 29525791Skarels } 29613073Ssam for(i=0; speeds[i].string; i++) 29713073Ssam if(eq(speeds[i].string)) { 29813073Ssam mode.sg_ispeed = mode.sg_ospeed = speeds[i].speed; 2991179Sbill goto cont; 3001179Sbill } 3011179Sbill if (eq("speed")) { 302*37609Sbostic ioctl(open(_PATH_DEVTTY, 0), TIOCGETP, &mode); 30313073Ssam for(i=0; speeds[i].string; i++) 30413073Ssam if (mode.sg_ospeed == speeds[i].speed) { 3051179Sbill printf("%s\n", speeds[i].string); 3061179Sbill exit(0); 3071179Sbill } 3081179Sbill printf("unknown\n"); 3091179Sbill exit(1); 3101179Sbill } 31113073Ssam for(i=0; modes[i].string; i++) 31213073Ssam if(eq(modes[i].string)) { 31313073Ssam mode.sg_flags &= ~modes[i].reset; 31413073Ssam mode.sg_flags |= modes[i].set; 31513073Ssam lmode &= ~modes[i].lreset; 31613073Ssam lmode |= modes[i].lset; 3171179Sbill } 31813073Ssam if(arg) 3191179Sbill fprintf(stderr,"unknown mode: %s\n", arg); 3201179Sbill cont: 3211179Sbill ; 3221179Sbill } 3231179Sbill done: 32413073Ssam ioctl(1, TIOCSETN, &mode); 32513073Ssam ioctl(1, TIOCSETC, &tc); 32613073Ssam ioctl(1, TIOCSLTC, <c); 32713073Ssam ioctl(1, TIOCLSET, &lmode); 32818023Sbloom ioctl(1, TIOCSWINSZ, &win); 3291179Sbill } 3301179Sbill 3311179Sbill eq(string) 33213073Ssam char *string; 3331179Sbill { 3341179Sbill int i; 3351179Sbill 33613073Ssam if(!arg) 33713073Ssam return(0); 3381179Sbill i = 0; 3391179Sbill loop: 34013073Ssam if(arg[i] != string[i]) 3411179Sbill return(0); 34213073Ssam if(arg[i++] != '\0') 3431179Sbill goto loop; 3441179Sbill arg = 0; 34513073Ssam return(1); 3461179Sbill } 3471179Sbill 3481179Sbill prmodes(all) 3491179Sbill { 3501179Sbill register m; 3511179Sbill int any; 3521179Sbill 35313073Ssam if(ldisc==NETLDISC) 3541179Sbill fprintf(stderr, "net discipline, "); 35513073Ssam else if(ldisc==NTTYDISC) 3561179Sbill fprintf(stderr, "new tty, "); 35713073Ssam else if(all==2) 3581179Sbill fprintf(stderr, "old tty, "); 35913073Ssam if(mode.sg_ispeed != mode.sg_ospeed) { 36013073Ssam prspeed("input speed ", mode.sg_ispeed); 36113073Ssam prspeed("output speed ", mode.sg_ospeed); 3621179Sbill } else 36313073Ssam prspeed("speed ", mode.sg_ispeed); 36418023Sbloom if (all) 36518023Sbloom fprintf(stderr, ", %d rows, %d columns", win.ws_row, win.ws_col); 36613073Ssam fprintf(stderr, all==2 ? "\n" : "; "); 36713073Ssam m = mode.sg_flags; 36813073Ssam if(all==2 || (m&(EVENP|ODDP))!=(EVENP|ODDP)) { 36913073Ssam if(m & EVENP) fprintf(stderr,"even "); 37013073Ssam if(m & ODDP) fprintf(stderr,"odd "); 3711179Sbill } 37213073Ssam if(all==2 || m&RAW) 37313073Ssam fprintf(stderr,"-raw "+((m&RAW)!=0)); 37413073Ssam if(all==2 || (m&CRMOD)==0) 37513073Ssam fprintf(stderr,"-nl "+((m&CRMOD)==0)); 37613073Ssam if(all==2 || (m&ECHO)==0) 37713073Ssam fprintf(stderr,"-echo "+((m&ECHO)!=0)); 37813073Ssam if(all==2 || (m&LCASE)) 37913073Ssam fprintf(stderr,"-lcase "+((m&LCASE)!=0)); 38013073Ssam if(all==2 || (m&TANDEM)) 38113073Ssam fprintf(stderr,"-tandem "+((m&TANDEM)!=0)); 38213073Ssam fprintf(stderr,"-tabs "+((m&XTABS)!=XTABS)); 38313073Ssam if(all==2 || (m&CBREAK)) 38413073Ssam fprintf(stderr,"-cbreak "+((m&CBREAK)!=0)); 38513073Ssam if(all==2 || (m&NLDELAY)) 38613073Ssam delay((m&NLDELAY)/NL1, "nl"); 38713073Ssam if ((m&TBDELAY)!=XTABS) 38813073Ssam delay((m&TBDELAY)/TAB1, "tab"); 38913073Ssam if(all==2 || (m&CRDELAY)) 39013073Ssam delay((m&CRDELAY)/CR1, "cr"); 39113073Ssam if(all==2 || (m&VTDELAY)) 39213073Ssam delay((m&VTDELAY)/FF1, "ff"); 39313073Ssam if(all==2 || (m&BSDELAY)) 39413073Ssam delay((m&BSDELAY)/BS1, "bs"); 3951179Sbill if (all) 3961179Sbill fprintf(stderr,"\n"); 3971179Sbill #define lpit(what,str) \ 39813073Ssam if (all==2||(lmode&what)) { \ 39913073Ssam fprintf(stderr,str+((lmode&what)!=0)); any++; \ 4001179Sbill } 4011179Sbill if (ldisc == NTTYDISC) { 40213073Ssam int newcrt = (lmode&(LCTLECH|LCRTBS)) == (LCTLECH|LCRTBS) && 40313073Ssam (lmode&(LCRTERA|LCRTKIL)) == 40413073Ssam ((mode.sg_ospeed > B300) ? LCRTERA|LCRTKIL : 0); 40513817Ssam int nothing = 1; 4061179Sbill if (newcrt) { 40713073Ssam if (all==2) 40813073Ssam fprintf(stderr, "crt: (crtbs crterase crtkill ctlecho) "); 40913073Ssam else 41013073Ssam fprintf(stderr, "crt "); 4111179Sbill any++; 4121179Sbill } else { 41313073Ssam lpit(LCRTBS, "-crtbs "); 41413073Ssam lpit(LCRTERA, "-crterase "); 41513073Ssam lpit(LCRTKIL, "-crtkill "); 41613073Ssam lpit(LCTLECH, "-ctlecho "); 41713073Ssam lpit(LPRTERA, "-prterase "); 4181179Sbill } 41913073Ssam lpit(LTOSTOP, "-tostop "); 42013073Ssam if (all==2) { 4211179Sbill fprintf(stderr, "\n"); 4221179Sbill any = 0; 42313817Ssam nothing = 0; 4241179Sbill } 42513073Ssam lpit(LTILDE, "-tilde "); 42613073Ssam lpit(LFLUSHO, "-flusho "); 42713073Ssam lpit(LMDMBUF, "-mdmbuf "); 42813073Ssam lpit(LLITOUT, "-litout "); 42924277Slepreau lpit(LPASS8, "-pass8 "); 43013073Ssam lpit(LNOHANG, "-nohang "); 4314017Sroot if (any) { 4324017Sroot fprintf(stderr,"\n"); 4334017Sroot any = 0; 43413817Ssam nothing = 0; 4354017Sroot } 4369853Ssam #ifdef notdef 43713073Ssam lpit(LETXACK, "-etxack "); 4389853Ssam #endif 43913073Ssam lpit(LPENDIN, "-pendin "); 44013073Ssam lpit(LDECCTQ, "-decctlq "); 44113073Ssam lpit(LNOFLSH, "-noflsh "); 44213817Ssam if (any || nothing) 4431179Sbill fprintf(stderr,"\n"); 4441179Sbill } else if (!all) 4451179Sbill fprintf(stderr,"\n"); 4461179Sbill if (all) { 4471179Sbill switch (ldisc) { 4481179Sbill 4491179Sbill case 0: 4501179Sbill fprintf(stderr,"\ 4511179Sbill erase kill intr quit stop eof\ 4521179Sbill \n"); 45313073Ssam pcol(mode.sg_erase, -1); 45413073Ssam pcol(mode.sg_kill, -1); 45513073Ssam pcol(tc.t_intrc, -1); 45613073Ssam pcol(tc.t_quitc, -1); 45713073Ssam pcol(tc.t_stopc, tc.t_startc); 45813073Ssam pcol(tc.t_eofc, tc.t_brkc); 4591179Sbill fprintf(stderr,"\n"); 4601179Sbill break; 4611179Sbill 4621179Sbill case NTTYDISC: 4631179Sbill fprintf(stderr,"\ 4641179Sbill erase kill werase rprnt flush lnext susp intr quit stop eof\ 4651179Sbill \n"); 46613073Ssam pcol(mode.sg_erase, -1); 46713073Ssam pcol(mode.sg_kill, -1); 46813073Ssam pcol(ltc.t_werasc, -1); 46913073Ssam pcol(ltc.t_rprntc, -1); 47013073Ssam pcol(ltc.t_flushc, -1); 47113073Ssam pcol(ltc.t_lnextc, -1); 47213073Ssam pcol(ltc.t_suspc, ltc.t_dsuspc); 47313073Ssam pcol(tc.t_intrc, -1); 47413073Ssam pcol(tc.t_quitc, -1); 47513073Ssam pcol(tc.t_stopc, tc.t_startc); 47613073Ssam pcol(tc.t_eofc, tc.t_brkc); 4771179Sbill fprintf(stderr,"\n"); 4781179Sbill break; 4791179Sbill } 4801179Sbill } else if (ldisc != NETLDISC) { 4811179Sbill register struct special *sp; 4821179Sbill int first = 1; 48313817Ssam 4841179Sbill for (sp = special; sp->name; sp++) { 4851179Sbill if ((*sp->cp&0377) != (sp->def&0377)) { 4861179Sbill pit(*sp->cp, sp->name, first ? "" : ", "); 4871179Sbill first = 0; 4881179Sbill }; 48913073Ssam if (sp->cp == &tc.t_brkc && ldisc == 0) 4901179Sbill break; 4911179Sbill } 49213817Ssam if (!first) 49313073Ssam fprintf(stderr, "\n"); 4941179Sbill } 4951179Sbill } 4961179Sbill 4971179Sbill pcol(ch1, ch2) 4981179Sbill int ch1, ch2; 4991179Sbill { 5001179Sbill int nout = 0; 5011179Sbill 5021179Sbill ch1 &= 0377; 5031179Sbill ch2 &= 0377; 5041179Sbill if (ch1 == ch2) 5051179Sbill ch2 = 0377; 5061179Sbill for (; ch1 != 0377 || ch2 != 0377; ch1 = ch2, ch2 = 0377) { 5071179Sbill if (ch1 == 0377) 5081179Sbill continue; 5091179Sbill if (ch1 & 0200) { 5101179Sbill fprintf(stderr, "M-"); 5111179Sbill nout += 2; 5121179Sbill ch1 &= ~ 0200; 5131179Sbill } 5141179Sbill if (ch1 == 0177) { 5151179Sbill fprintf(stderr, "^"); 5161179Sbill nout++; 5171179Sbill ch1 = '?'; 5181179Sbill } else if (ch1 < ' ') { 5191179Sbill fprintf(stderr, "^"); 5201179Sbill nout++; 5211179Sbill ch1 += '@'; 5221179Sbill } 5231179Sbill fprintf(stderr, "%c", ch1); 5241179Sbill nout++; 5251179Sbill if (ch2 != 0377) { 5261179Sbill fprintf(stderr, "/"); 5271179Sbill nout++; 5281179Sbill } 5291179Sbill } 5301179Sbill while (nout < 7) { 5311179Sbill fprintf(stderr, " "); 5321179Sbill nout++; 5331179Sbill } 5341179Sbill } 5351179Sbill 5361179Sbill pit(what, itsname, sep) 5371179Sbill unsigned what; 5381179Sbill char *itsname, *sep; 5391179Sbill { 5401179Sbill 5411179Sbill what &= 0377; 5421179Sbill fprintf(stderr, "%s%s", sep, itsname); 5431179Sbill if (what == 0377) { 5441179Sbill fprintf(stderr, " <undef>"); 5451179Sbill return; 5461179Sbill } 5471179Sbill fprintf(stderr, " = "); 5481179Sbill if (what & 0200) { 5491179Sbill fprintf(stderr, "M-"); 5501179Sbill what &= ~ 0200; 5511179Sbill } 5521179Sbill if (what == 0177) { 5531179Sbill fprintf(stderr, "^"); 5541179Sbill what = '?'; 5551179Sbill } else if (what < ' ') { 5561179Sbill fprintf(stderr, "^"); 5571179Sbill what += '@'; 5581179Sbill } 5591179Sbill fprintf(stderr, "%c", what); 5601179Sbill } 5611179Sbill 5621179Sbill delay(m, s) 56313073Ssam char *s; 5641179Sbill { 5651179Sbill 56613073Ssam if(m) 5671179Sbill fprintf(stderr,"%s%d ", s, m); 5681179Sbill } 5691179Sbill 5701179Sbill int speed[] = { 5716815Swnj 0,50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,19200,38400 5721179Sbill }; 5731179Sbill 5741179Sbill prspeed(c, s) 5751179Sbill char *c; 5761179Sbill { 5771179Sbill 5781179Sbill fprintf(stderr,"%s%d baud", c, speed[s]); 5791179Sbill } 580