usr.sbin/lpr/common_source/printcap.c
/*
 * tnchktc: check the last entry, see if it's tc=xxx. If so,
 * recursively find xxx and append that entry (minus the names)
 * to take the place of the tc=xxx entry. This allows termcap
 * entries to say "like an HP2621 but doesn't turn on the labels".
 * Note that this works because of the left to right scan.
 */
check the last entry, see if it's tc=xxx. If so,
recursively find xxx and append that entry (minus the names)
to take the place of the tc=xxx entry. This allows termcap
entries to say "like an HP2621 but doesn't turn on the labels".
Note that this works because of the left to right scan.
check the last entry see if it ' s tc = xxx . If so recursively find xxx and append that entry ( minus the names ) to take the place of the tc = xxx entry . This allows termcap entries to say " like an HP2621 but doesn ' t turn on the labels " . Note that this works because of the left to right scan .
int
tnchktc()
{
	register char *p, *q;
	char tcname[16];	
	char tcbuf[BUFSIZ];
	char *holdtbuf = tbuf;
	int l;
	p = tbuf + strlen(tbuf) - 2;	
	while (*--p != ':')
		if (p<tbuf) {
			write(2, "Bad termcap entry\n", 18);
			return (0);
		}
	p++;
	if (p[0] != 't' || p[1] != 'c')
		return(1);
	strcpy(tcname,p+3);
	q = tcname;
	while (q && *q != ':')
		q++;
	*q = 0;
	if (++hopcount > MAXHOP) {
		write(2, "Infinite tc= loop\n", 18);
		return (0);
	}
	if (tgetent(tcbuf, tcname) != 1)
		return(0);
	for (q=tcbuf; *q != ':'; q++)
		;
	l = p - holdtbuf + strlen(q);
	if (l > BUFSIZ) {
		write(2, "Termcap entry too long\n", 23);
		q[BUFSIZ - (p-tbuf)] = 0;
	}
	strcpy(p, q+1);
	tbuf = holdtbuf;
	return(1);
}
int tnchktc ( ) { register char * p , * q ; char tcname [ 16 ] ; char tcbuf [ BUFSIZ ] ; char * holdtbuf = tbuf ; int l ; p = tbuf + strlen ( tbuf ) - 2 ; while ( * -- p != ' ' ) if ( p < tbuf ) { write ( 2 , " \n " , 18 ) ; return ( 0 ) ; } p ++ ; if ( p [ 0 ] != ' ' || p [ 1 ] != ' ' ) return ( 1 ) ; strcpy ( tcname , p + 3 ) ; q = tcname ; while ( q && * q != ' ' ) q ++ ; * q = 0 ; if ( ++ hopcount > MAXHOP ) { write ( 2 , " \n " , 18 ) ; return ( 0 ) ; } if ( tgetent ( tcbuf , tcname ) != 1 ) return ( 0 ) ; for ( q = tcbuf ; * q != ' ' ; q ++ ) ; l = p - holdtbuf + strlen ( q ) ; if ( l > BUFSIZ ) { write ( 2 , " \n " , 23 ) ; q [ BUFSIZ - ( p - tbuf ) ] = 0 ; } strcpy ( p , q + 1 ) ; tbuf = holdtbuf ; return ( 1 ) ; }
tnchktc: check the last entry, see if it's tc=xxx.
tnchktc : check the last entry see if it ' s tc = xxx .
/* name of similar terminal */ /* before the last colon */ /* p now points to beginning of last field */