xref: /csrg-svn/bin/stty/stty.c (revision 13073)
1*13073Ssam #ifndef lint
2*13073Ssam static char *sccsid ="@(#)stty.c	4.13 (Berkeley) 06/13/83";
3*13073Ssam #endif
41179Sbill /*
51179Sbill  * set teletype modes
61179Sbill  */
71179Sbill 
81179Sbill #include <stdio.h>
91179Sbill #include <sgtty.h>
101179Sbill 
11*13073Ssam struct
12*13073Ssam {
131179Sbill 	char	*string;
141179Sbill 	int	speed;
151179Sbill } speeds[] = {
16*13073Ssam 	"0",	B0,
17*13073Ssam 	"50",	B50,
18*13073Ssam 	"75",	B75,
19*13073Ssam 	"110",	B110,
20*13073Ssam 	"134",	B134,
21*13073Ssam 	"134.5",B134,
22*13073Ssam 	"150",	B150,
23*13073Ssam 	"200",	B200,
24*13073Ssam 	"300",	B300,
25*13073Ssam 	"600",	B600,
26*13073Ssam 	"1200",	B1200,
27*13073Ssam 	"1800",	B1800,
28*13073Ssam 	"2400",	B2400,
29*13073Ssam 	"4800",	B4800,
30*13073Ssam 	"9600",	B9600,
31*13073Ssam 	"exta",	EXTA,
32*13073Ssam 	"19200", EXTA,
33*13073Ssam 	"extb",	EXTB,
34*13073Ssam 	"38400", EXTB,
35*13073Ssam 	0,
361179Sbill };
37*13073Ssam struct
38*13073Ssam {
391179Sbill 	char	*string;
40*13073Ssam 	int	set;
41*13073Ssam 	int	reset;
42*13073Ssam 	int	lset;
43*13073Ssam 	int	lreset;
441179Sbill } modes[] = {
45*13073Ssam 	"even",		EVENP, 0, 0, 0,
46*13073Ssam 	"-even",	0, EVENP, 0, 0,
47*13073Ssam 	"odd",		ODDP, 0, 0, 0,
48*13073Ssam 	"-odd",		0, ODDP, 0, 0,
49*13073Ssam 	"raw",		RAW, 0, 0, 0,
50*13073Ssam 	"-raw",		0, RAW, 0, 0,
51*13073Ssam 	"cooked",	0, RAW, 0, 0,
52*13073Ssam 	"-nl",		CRMOD, 0, 0, 0,
53*13073Ssam 	"nl",		0, CRMOD, 0, 0,
54*13073Ssam 	"echo",		ECHO, 0, 0, 0,
55*13073Ssam 	"-echo",	0, ECHO, 0, 0,
56*13073Ssam 	"LCASE",	LCASE, 0, 0, 0,
57*13073Ssam 	"lcase",	LCASE, 0, 0, 0,
58*13073Ssam 	"-LCASE",	0, LCASE, 0, 0,
59*13073Ssam 	"-lcase",	0, LCASE, 0, 0,
60*13073Ssam 	"-tabs",	XTABS, 0, 0, 0,
61*13073Ssam 	"tabs",		0, XTABS, 0, 0,
62*13073Ssam 	"tandem",	TANDEM, 0, 0, 0,
63*13073Ssam 	"-tandem",	0, TANDEM, 0, 0,
64*13073Ssam 	"cbreak",	CBREAK, 0, 0, 0,
65*13073Ssam 	"-cbreak",	0, CBREAK, 0, 0,
66*13073Ssam 	"cr0",		CR0, CR3, 0, 0,
67*13073Ssam 	"cr1",		CR1, CR3, 0, 0,
68*13073Ssam 	"cr2",		CR2, CR3, 0, 0,
69*13073Ssam 	"cr3",		CR3, CR3, 0, 0,
70*13073Ssam 	"tab0",		TAB0, XTABS, 0, 0,
71*13073Ssam 	"tab1",		TAB1, XTABS, 0, 0,
72*13073Ssam 	"tab2",		TAB2, XTABS, 0, 0,
73*13073Ssam 	"nl0",		NL0, NL3, 0, 0,
74*13073Ssam 	"nl1",		NL1, NL3, 0, 0,
75*13073Ssam 	"nl2",		NL2, NL3, 0, 0,
76*13073Ssam 	"nl3",		NL3, NL3, 0, 0,
77*13073Ssam 	"ff0",		FF0, FF1, 0, 0,
78*13073Ssam 	"ff1",		FF1, FF1, 0, 0,
79*13073Ssam 	"bs0",		BS0, BS1, 0, 0,
80*13073Ssam 	"bs1",		BS1, BS1, 0, 0,
81*13073Ssam 	"33",		CR1, ALLDELAY, 0, 0,
82*13073Ssam 	"tty33",	CR1, ALLDELAY, 0, 0,
83*13073Ssam 	"37",		FF1+CR2+TAB1+NL1, ALLDELAY, 0, 0,
84*13073Ssam 	"tty37",	FF1+CR2+TAB1+NL1, ALLDELAY, 0, 0,
85*13073Ssam 	"05",		NL2, ALLDELAY, 0, 0,
86*13073Ssam 	"vt05",		NL2, ALLDELAY, 0, 0,
87*13073Ssam 	"tn",		CR1, ALLDELAY, 0, 0,
88*13073Ssam 	"tn300",	CR1, ALLDELAY, 0, 0,
89*13073Ssam 	"ti",		CR2, ALLDELAY, 0, 0,
90*13073Ssam 	"ti700",	CR2, ALLDELAY, 0, 0,
91*13073Ssam 	"tek",		FF1, ALLDELAY, 0, 0,
92*13073Ssam 	"crtbs",	0, 0, LCRTBS, LPRTERA,
93*13073Ssam 	"-crtbs",	0, 0, 0, LCRTBS,
94*13073Ssam 	"prterase",	0, 0, LPRTERA, LCRTBS+LCRTKIL+LCRTERA,
95*13073Ssam 	"-prterase",	0, 0, 0, LPRTERA,
96*13073Ssam 	"crterase",	0, 0, LCRTERA, LPRTERA,
97*13073Ssam 	"-crterase",	0, 0, 0, LCRTERA,
98*13073Ssam 	"crtkill",	0, 0, LCRTKIL, LPRTERA,
99*13073Ssam 	"-crtkill",	0, 0, 0, LCRTKIL,
100*13073Ssam 	"tilde",	0, 0, LTILDE, 0,
101*13073Ssam 	"-tilde",	0, 0, 0, LTILDE,
102*13073Ssam 	"mdmbuf",	0, 0, LMDMBUF, 0,
103*13073Ssam 	"-mdmbuf",	0, 0, 0, LMDMBUF,
104*13073Ssam 	"litout",	0, 0, LLITOUT, 0,
105*13073Ssam 	"-litout",	0, 0, 0, LLITOUT,
106*13073Ssam 	"tostop",	0, 0, LTOSTOP, 0,
107*13073Ssam 	"-tostop",	0, 0, 0, LTOSTOP,
108*13073Ssam 	"flusho",	0, 0, LFLUSHO, 0,
109*13073Ssam 	"-flusho",	0, 0, 0, LFLUSHO,
110*13073Ssam 	"nohang",	0, 0, LNOHANG, 0,
111*13073Ssam 	"-nohang",	0, 0, 0, LNOHANG,
1129853Ssam #ifdef notdef
113*13073Ssam 	"etxack",	0, 0, LETXACK, 0,
114*13073Ssam 	"-etxack",	0, 0, 0, LETXACK,
1159853Ssam #endif
116*13073Ssam 	"ctlecho",	0, 0, LCTLECH, 0,
117*13073Ssam 	"-ctlecho",	0, 0, 0, LCTLECH,
118*13073Ssam 	"pendin",	0, 0, LPENDIN, 0,
119*13073Ssam 	"-pendin",	0, 0, 0, LPENDIN,
120*13073Ssam 	"decctlq",	0, 0, LDECCTQ, 0,
121*13073Ssam 	"-decctlq",	0, 0, 0, LDECCTQ,
122*13073Ssam 	"noflsh",	0, 0, LNOFLSH, 0,
123*13073Ssam 	"-noflsh",	0, 0, 0, LNOFLSH,
124*13073Ssam 	0,
1251179Sbill };
1261179Sbill 
127*13073Ssam struct tchars tc;
128*13073Ssam struct ltchars ltc;
129*13073Ssam struct sgttyb mode;
130*13073Ssam int	lmode;
1311179Sbill int	oldisc, ldisc;
1321179Sbill 
1331179Sbill struct	special {
1341179Sbill 	char	*name;
1351179Sbill 	char	*cp;
1361179Sbill 	char	def;
1371179Sbill } special[] = {
138*13073Ssam 	"erase",	&mode.sg_erase,		CERASE,
139*13073Ssam 	"kill",		&mode.sg_kill,		CKILL,
140*13073Ssam 	"intr",		&tc.t_intrc,		CINTR,
141*13073Ssam 	"quit",		&tc.t_quitc,		CQUIT,
142*13073Ssam 	"start",	&tc.t_startc,		CSTART,
143*13073Ssam 	"stop",		&tc.t_stopc,		CSTOP,
144*13073Ssam 	"eof",		&tc.t_eofc,		CEOF,
145*13073Ssam 	"brk",		&tc.t_brkc,		CBRK,
146*13073Ssam 	"susp",		&ltc.t_suspc,		CSUSP,
147*13073Ssam 	"dsusp",	&ltc.t_dsuspc,		CDSUSP,
148*13073Ssam 	"rprnt",	&ltc.t_rprntc,		CRPRNT,
149*13073Ssam 	"flush",	&ltc.t_flushc,		CFLUSH,
150*13073Ssam 	"werase",	&ltc.t_werasc,		CWERASE,
151*13073Ssam 	"lnext",	&ltc.t_lnextc,		CLNEXT,
1521179Sbill 	0
1531179Sbill };
1541179Sbill char	*arg;
1551179Sbill 
1561179Sbill int	argc;
1571179Sbill char	**argv;
1581179Sbill main(iargc, iargv)
159*13073Ssam 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;
168*13073Ssam 	ioctl(1, TIOCGETP, &mode);
1691179Sbill 	ioctl(1, TIOCGETD, &ldisc);
1701179Sbill 	oldisc = ldisc;
171*13073Ssam 	ioctl(1, TIOCGETC, &tc);
172*13073Ssam 	ioctl(1, TIOCLGET, &lmode);
173*13073Ssam 	ioctl(1, TIOCGLTC, &ltc);
174*13073Ssam 	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 	}
186*13073Ssam /*
187*13073Ssam 	if (argc == 2 && !strcmp(argv[1], "all")) {
188*13073Ssam 		prmodes(2);
189*13073Ssam 		exit(0);
190*13073Ssam 	}
191*13073Ssam */
192*13073Ssam 	while(--argc > 0) {
1931179Sbill 		arg = *++argv;
194*13073Ssam 		if (eq("ek")){
195*13073Ssam 			mode.sg_erase = '#';
196*13073Ssam 			mode.sg_kill = '@';
1971179Sbill 			continue;
1981179Sbill 		}
199*13073Ssam 		if (eq("new")){
2001179Sbill 			ldisc = NTTYDISC;
201*13073Ssam 			if (ioctl(1, TIOCSETD, &ldisc)<0)
2021179Sbill 				perror("ioctl");
2031179Sbill 			continue;
2041179Sbill 		}
205*13073Ssam 		if (eq("newcrt")){
2061179Sbill 			ldisc = NTTYDISC;
207*13073Ssam 			lmode &= ~LPRTERA;
208*13073Ssam 			lmode |= LCRTBS|LCTLECH;
209*13073Ssam 			if (mode.sg_ospeed >= B1200)
210*13073Ssam 				lmode |= LCRTERA|LCRTKIL;
211*13073Ssam 			if (ioctl(1, TIOCSETD, &ldisc)<0)
2121179Sbill 				perror("ioctl");
2131179Sbill 			continue;
2141179Sbill 		}
215*13073Ssam 		if (eq("crt")){
216*13073Ssam 			lmode &= ~LPRTERA;
217*13073Ssam 			lmode |= LCRTBS|LCTLECH;
218*13073Ssam 			if (mode.sg_ospeed >= B1200)
219*13073Ssam 				lmode |= LCRTERA|LCRTKIL;
2201179Sbill 			continue;
2211179Sbill 		}
222*13073Ssam 		if (eq("old")){
223*13073Ssam 			ldisc = 0;
224*13073Ssam 			if (ioctl(1, TIOCSETD, &ldisc)<0)
2251179Sbill 				perror("ioctl");
2261179Sbill 			continue;
2271179Sbill 		}
228*13073Ssam 		if (eq("dec")){
229*13073Ssam 			mode.sg_erase = 0177;
230*13073Ssam 			mode.sg_kill = CTRL(u);
231*13073Ssam 			tc.t_intrc = CTRL(c);
2323797Sroot 			ldisc = NTTYDISC;
233*13073Ssam 			lmode &= ~LPRTERA;
234*13073Ssam 			lmode |= LCRTBS|LCTLECH|LDECCTQ;
235*13073Ssam 			if (mode.sg_ospeed >= B1200)
236*13073Ssam 				lmode |= LCRTERA|LCRTKIL;
237*13073Ssam 			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")) {
255*13073Ssam 			mode.sg_ispeed = B300;
256*13073Ssam 			mode.sg_ospeed = B9600;
2571179Sbill 			continue;
2581179Sbill 		}
2591179Sbill 		if (eq("hup")) {
260*13073Ssam 			ioctl(1, TIOCHPCL, NULL);
2611179Sbill 			continue;
2621179Sbill 		}
263*13073Ssam 		for(i=0; speeds[i].string; i++)
264*13073Ssam 			if(eq(speeds[i].string)) {
265*13073Ssam 				mode.sg_ispeed = mode.sg_ospeed = speeds[i].speed;
2661179Sbill 				goto cont;
2671179Sbill 			}
2681179Sbill 		if (eq("speed")) {
269*13073Ssam 			ioctl(open("/dev/tty", 0), TIOCGETP, &mode);
270*13073Ssam 			for(i=0; speeds[i].string; i++)
271*13073Ssam 				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 		}
278*13073Ssam 		for(i=0; modes[i].string; i++)
279*13073Ssam 			if(eq(modes[i].string)) {
280*13073Ssam 				mode.sg_flags &= ~modes[i].reset;
281*13073Ssam 				mode.sg_flags |= modes[i].set;
282*13073Ssam 				lmode &= ~modes[i].lreset;
283*13073Ssam 				lmode |= modes[i].lset;
2841179Sbill 			}
285*13073Ssam 		if(arg)
2861179Sbill 			fprintf(stderr,"unknown mode: %s\n", arg);
2871179Sbill cont:
2881179Sbill 		;
2891179Sbill 	}
2901179Sbill done:
291*13073Ssam 	ioctl(1, TIOCSETN, &mode);
292*13073Ssam 	ioctl(1, TIOCSETC, &tc);
293*13073Ssam 	ioctl(1, TIOCSLTC, &ltc);
294*13073Ssam 	ioctl(1, TIOCLSET, &lmode);
2951179Sbill }
2961179Sbill 
2971179Sbill eq(string)
298*13073Ssam char *string;
2991179Sbill {
3001179Sbill 	int i;
3011179Sbill 
302*13073Ssam 	if(!arg)
303*13073Ssam 		return(0);
3041179Sbill 	i = 0;
3051179Sbill loop:
306*13073Ssam 	if(arg[i] != string[i])
3071179Sbill 		return(0);
308*13073Ssam 	if(arg[i++] != '\0')
3091179Sbill 		goto loop;
3101179Sbill 	arg = 0;
311*13073Ssam 	return(1);
3121179Sbill }
3131179Sbill 
3141179Sbill prmodes(all)
3151179Sbill {
3161179Sbill 	register m;
3171179Sbill 	int any;
3181179Sbill 
319*13073Ssam 	if(ldisc==NETLDISC)
3201179Sbill 		fprintf(stderr, "net discipline, ");
321*13073Ssam 	else if(ldisc==NTTYDISC)
3221179Sbill 		fprintf(stderr, "new tty, ");
323*13073Ssam 	else if(all==2)
3241179Sbill 		fprintf(stderr, "old tty, ");
325*13073Ssam 	if(mode.sg_ispeed != mode.sg_ospeed) {
326*13073Ssam 		prspeed("input speed ", mode.sg_ispeed);
327*13073Ssam 		prspeed("output speed ", mode.sg_ospeed);
3281179Sbill 	} else
329*13073Ssam 		prspeed("speed ", mode.sg_ispeed);
330*13073Ssam 	fprintf(stderr, all==2 ? "\n" : "; ");
331*13073Ssam 	m = mode.sg_flags;
332*13073Ssam 	if(all==2 || (m&(EVENP|ODDP))!=(EVENP|ODDP)) {
333*13073Ssam 		if(m & EVENP)	fprintf(stderr,"even ");
334*13073Ssam 		if(m & ODDP)	fprintf(stderr,"odd ");
3351179Sbill 	}
336*13073Ssam 	if(all==2 || m&RAW)
337*13073Ssam 		fprintf(stderr,"-raw "+((m&RAW)!=0));
338*13073Ssam 	if(all==2 || (m&CRMOD)==0)
339*13073Ssam 		fprintf(stderr,"-nl "+((m&CRMOD)==0));
340*13073Ssam 	if(all==2 || (m&ECHO)==0)
341*13073Ssam 		fprintf(stderr,"-echo "+((m&ECHO)!=0));
342*13073Ssam 	if(all==2 || (m&LCASE))
343*13073Ssam 		fprintf(stderr,"-lcase "+((m&LCASE)!=0));
344*13073Ssam 	if(all==2 || (m&TANDEM))
345*13073Ssam 		fprintf(stderr,"-tandem "+((m&TANDEM)!=0));
346*13073Ssam 	fprintf(stderr,"-tabs "+((m&XTABS)!=XTABS));
347*13073Ssam 	if(all==2 || (m&CBREAK))
348*13073Ssam 		fprintf(stderr,"-cbreak "+((m&CBREAK)!=0));
349*13073Ssam 	if(all==2 || (m&NLDELAY))
350*13073Ssam 		delay((m&NLDELAY)/NL1,	"nl");
351*13073Ssam 	if ((m&TBDELAY)!=XTABS)
352*13073Ssam 		delay((m&TBDELAY)/TAB1,	"tab");
353*13073Ssam 	if(all==2 || (m&CRDELAY))
354*13073Ssam 		delay((m&CRDELAY)/CR1,	"cr");
355*13073Ssam 	if(all==2 || (m&VTDELAY))
356*13073Ssam 		delay((m&VTDELAY)/FF1,	"ff");
357*13073Ssam 	if(all==2 || (m&BSDELAY))
358*13073Ssam 		delay((m&BSDELAY)/BS1,	"bs");
3591179Sbill 	if (all)
3601179Sbill 		fprintf(stderr,"\n");
3611179Sbill #define	lpit(what,str) \
362*13073Ssam 	if (all==2||(lmode&what)) { \
363*13073Ssam 		fprintf(stderr,str+((lmode&what)!=0)); any++; \
3641179Sbill 	}
3651179Sbill 	if (ldisc == NTTYDISC) {
366*13073Ssam 		int newcrt = (lmode&(LCTLECH|LCRTBS)) == (LCTLECH|LCRTBS) &&
367*13073Ssam 		    (lmode&(LCRTERA|LCRTKIL)) ==
368*13073Ssam 		      ((mode.sg_ospeed > B300) ? LCRTERA|LCRTKIL : 0);
3691179Sbill 		if (newcrt) {
370*13073Ssam 			if (all==2)
371*13073Ssam 				fprintf(stderr, "crt: (crtbs crterase crtkill ctlecho) ");
372*13073Ssam 			else
373*13073Ssam 				fprintf(stderr, "crt ");
3741179Sbill 			any++;
3751179Sbill 		} else {
376*13073Ssam 			lpit(LCRTBS, "-crtbs ");
377*13073Ssam 			lpit(LCRTERA, "-crterase ");
378*13073Ssam 			lpit(LCRTKIL, "-crtkill ");
379*13073Ssam 			lpit(LCTLECH, "-ctlecho ");
380*13073Ssam 			lpit(LPRTERA, "-prterase ");
3811179Sbill 		}
382*13073Ssam 		lpit(LTOSTOP, "-tostop ");
383*13073Ssam 		if (all==2) {
3841179Sbill 			fprintf(stderr, "\n");
3851179Sbill 			any = 0;
3861179Sbill 		}
387*13073Ssam 		lpit(LTILDE, "-tilde ");
388*13073Ssam 		lpit(LFLUSHO, "-flusho ");
389*13073Ssam 		lpit(LMDMBUF, "-mdmbuf ");
390*13073Ssam 		lpit(LLITOUT, "-litout ");
391*13073Ssam 		lpit(LNOHANG, "-nohang ");
3924017Sroot 		if (any) {
3934017Sroot 			fprintf(stderr,"\n");
3944017Sroot 			any = 0;
3954017Sroot 		}
3969853Ssam #ifdef notdef
397*13073Ssam 		lpit(LETXACK, "-etxack ");
3989853Ssam #endif
399*13073Ssam 		lpit(LPENDIN, "-pendin ");
400*13073Ssam 		lpit(LDECCTQ, "-decctlq ");
401*13073Ssam 		lpit(LNOFLSH, "-noflsh ");
4021179Sbill 		if (any)
4031179Sbill 			fprintf(stderr,"\n");
4041179Sbill 	} else if (!all)
4051179Sbill 		fprintf(stderr,"\n");
4061179Sbill 	if (all) {
4071179Sbill 		switch (ldisc) {
4081179Sbill 
4091179Sbill 		case 0:
4101179Sbill 			fprintf(stderr,"\
4111179Sbill erase  kill   intr   quit   stop   eof\
4121179Sbill \n");
413*13073Ssam 			pcol(mode.sg_erase, -1);
414*13073Ssam 			pcol(mode.sg_kill, -1);
415*13073Ssam 			pcol(tc.t_intrc, -1);
416*13073Ssam 			pcol(tc.t_quitc, -1);
417*13073Ssam 			pcol(tc.t_stopc, tc.t_startc);
418*13073Ssam 			pcol(tc.t_eofc, tc.t_brkc);
4191179Sbill 			fprintf(stderr,"\n");
4201179Sbill 			break;
4211179Sbill 
4221179Sbill 		case NTTYDISC:
4231179Sbill 			fprintf(stderr,"\
4241179Sbill erase  kill   werase rprnt  flush  lnext  susp   intr   quit   stop   eof\
4251179Sbill \n");
426*13073Ssam 			pcol(mode.sg_erase, -1);
427*13073Ssam 			pcol(mode.sg_kill, -1);
428*13073Ssam 			pcol(ltc.t_werasc, -1);
429*13073Ssam 			pcol(ltc.t_rprntc, -1);
430*13073Ssam 			pcol(ltc.t_flushc, -1);
431*13073Ssam 			pcol(ltc.t_lnextc, -1);
432*13073Ssam 			pcol(ltc.t_suspc, ltc.t_dsuspc);
433*13073Ssam 			pcol(tc.t_intrc, -1);
434*13073Ssam 			pcol(tc.t_quitc, -1);
435*13073Ssam 			pcol(tc.t_stopc, tc.t_startc);
436*13073Ssam 			pcol(tc.t_eofc, tc.t_brkc);
4371179Sbill 			fprintf(stderr,"\n");
4381179Sbill 			break;
4391179Sbill 		}
4401179Sbill 	} else if (ldisc != NETLDISC) {
4411179Sbill 		register struct special *sp;
4421179Sbill 		int first = 1;
4431179Sbill 		for (sp = special; sp->name; sp++) {
4441179Sbill 			if ((*sp->cp&0377) != (sp->def&0377)) {
4451179Sbill 				pit(*sp->cp, sp->name, first ? "" : ", ");
4461179Sbill 				first = 0;
4471179Sbill 			};
448*13073Ssam 			if (sp->cp == &tc.t_brkc && ldisc == 0)
4491179Sbill 				break;
4501179Sbill 		}
451*13073Ssam 		if (first == 0)
452*13073Ssam 			fprintf(stderr, "\n");
4531179Sbill 	}
4541179Sbill }
4551179Sbill 
4561179Sbill pcol(ch1, ch2)
4571179Sbill 	int ch1, ch2;
4581179Sbill {
4591179Sbill 	int nout = 0;
4601179Sbill 
4611179Sbill 	ch1 &= 0377;
4621179Sbill 	ch2 &= 0377;
4631179Sbill 	if (ch1 == ch2)
4641179Sbill 		ch2 = 0377;
4651179Sbill 	for (; ch1 != 0377 || ch2 != 0377; ch1 = ch2, ch2 = 0377) {
4661179Sbill 		if (ch1 == 0377)
4671179Sbill 			continue;
4681179Sbill 		if (ch1 & 0200) {
4691179Sbill 			fprintf(stderr, "M-");
4701179Sbill 			nout += 2;
4711179Sbill 			ch1 &= ~ 0200;
4721179Sbill 		}
4731179Sbill 		if (ch1 == 0177) {
4741179Sbill 			fprintf(stderr, "^");
4751179Sbill 			nout++;
4761179Sbill 			ch1 = '?';
4771179Sbill 		} else if (ch1 < ' ') {
4781179Sbill 			fprintf(stderr, "^");
4791179Sbill 			nout++;
4801179Sbill 			ch1 += '@';
4811179Sbill 		}
4821179Sbill 		fprintf(stderr, "%c", ch1);
4831179Sbill 		nout++;
4841179Sbill 		if (ch2 != 0377) {
4851179Sbill 			fprintf(stderr, "/");
4861179Sbill 			nout++;
4871179Sbill 		}
4881179Sbill 	}
4891179Sbill 	while (nout < 7) {
4901179Sbill 		fprintf(stderr, " ");
4911179Sbill 		nout++;
4921179Sbill 	}
4931179Sbill }
4941179Sbill 
4951179Sbill pit(what, itsname, sep)
4961179Sbill 	unsigned what;
4971179Sbill 	char *itsname, *sep;
4981179Sbill {
4991179Sbill 
5001179Sbill 	what &= 0377;
5011179Sbill 	fprintf(stderr, "%s%s", sep, itsname);
5021179Sbill 	if (what == 0377) {
5031179Sbill 		fprintf(stderr, " <undef>");
5041179Sbill 		return;
5051179Sbill 	}
5061179Sbill 	fprintf(stderr, " = ");
5071179Sbill 	if (what & 0200) {
5081179Sbill 		fprintf(stderr, "M-");
5091179Sbill 		what &= ~ 0200;
5101179Sbill 	}
5111179Sbill 	if (what == 0177) {
5121179Sbill 		fprintf(stderr, "^");
5131179Sbill 		what = '?';
5141179Sbill 	} else if (what < ' ') {
5151179Sbill 		fprintf(stderr, "^");
5161179Sbill 		what += '@';
5171179Sbill 	}
5181179Sbill 	fprintf(stderr, "%c", what);
5191179Sbill }
5201179Sbill 
5211179Sbill delay(m, s)
522*13073Ssam char *s;
5231179Sbill {
5241179Sbill 
525*13073Ssam 	if(m)
5261179Sbill 		fprintf(stderr,"%s%d ", s, m);
5271179Sbill }
5281179Sbill 
5291179Sbill int	speed[] = {
5306815Swnj 	0,50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,19200,38400
5311179Sbill };
5321179Sbill 
5331179Sbill prspeed(c, s)
5341179Sbill char *c;
5351179Sbill {
5361179Sbill 
5371179Sbill 	fprintf(stderr,"%s%d baud",  c, speed[s]);
5381179Sbill }
539