#
/* PURPOSE - what -- find and print sccs id information
 */
/* RESPONSIBLE PROGRAMMER
	D.B.Knudsen	4/9/75
	M.J.Rochkind	1/18/74
 */
/* PROPRIETARY NOTICE
	This information is proprietary and is the property of
	Bell Telephone Laboratories, Incorporated.  Its
	reproduction or disclosure to others, either orally or
	in writing, is prohibited without written permission of
	Bell Laboratories.
   PROPRIETARY NOTICE */
/* SCCS ID INFO */
char what__[] "@(#)what.c	3.1	12/29/76	11:56:59	%O%";
/* SCCS ID INFO */
#define NEXTCHAR (CHAR=getc(&buf))
#define EOF -1
char pattern[] "@(#)";
char opattern[] "~|^`";
char noopen[] "can't open ";
struct {int fildes;
	int nleft;
	char *nextp;
	char buffer[512];
} buf;
main(argc,argv)
int argc;
char *argv[];
{
	register int CHAR,i;
	register char c;
	while (--argc) {
		if (fopen(argv++[1],&buf)<0) {
			write(2,noopen,length(noopen));
			write(2,argv[0],length(argv[0]));
			write(2," (26)\n",6);
			continue;
		}
		write(1,argv[0],length(argv[0]));
		write(1,":\n",2);
		while (NEXTCHAR!= EOF)
findpat:		if (CHAR==pattern[0]) {
				for (i=1;c=pattern[i++];)
					if (NEXTCHAR!=c) goto findpat;
				putchar('\t');
				while (NEXTCHAR && CHAR!='"' && CHAR!= -1 && 
					CHAR!='>' && CHAR!='\n')putchar(CHAR);
				putchar('\n');
			}
			else if (CHAR==opattern[0]) {
				for (i=1;c=opattern[i++];)
					if (NEXTCHAR!=c) goto findpat;
				putchar('\t');
				while (NEXTCHAR && CHAR!='"' && CHAR!= -1 && 
					CHAR!='>' && CHAR!='\n')putchar(CHAR);
				putchar('\n');
			}
		close(buf.fildes);
	}
}
length(st)  char *st; {register int i; for (i=0;st[i];i++); return i; }
