1*48292Sbostic /*-
2*48292Sbostic * %sccs.include.proprietary.c%
3*48292Sbostic */
4*48292Sbostic
512309Stut #ifndef lint
6*48292Sbostic static char sccsid[] = "@(#)what3.c 4.3 (Berkeley) 04/18/91";
7*48292Sbostic #endif /* not lint */
812309Stut
912309Stut #include "what..c"
1037895Sbostic #include "pathnames.h"
1112309Stut
doclook(argc,argv,colevel)1212309Stut doclook(argc, argv, colevel)
1312309Stut char *argv[];
1412309Stut {
1512309Stut int fpa[2], fpb[2], fpc[2], pid1, pid2, st;
1612309Stut int iarg;
1712309Stut char *s;
1812309Stut FILE *ansf;
1912309Stut struct filans *af;
2012309Stut struct stat statbuf;
2112309Stut # define RD 0
2212309Stut # define WR 1
2312309Stut # define fmv(x,y) close(y); dup(x); close(x);
2412309Stut /* we want to run chkbib and then lhunt and pipe in & out */
2512309Stut pipe (fpa); /* from this program to chkbib */
2612309Stut pipe (fpb); /* from chkbib to lhunt */
2712309Stut pipe (fpc); /* from lhunt to us */
2812309Stut if ( (pid1 = fork()) ==0)
2912309Stut {
3012309Stut fmv(fpa[RD], 0);
3112309Stut fmv(fpb[WR], 1);
3212309Stut close(fpa[WR]);
3312309Stut close(fpb[RD]);
3412309Stut close(fpc[RD]);
3512309Stut close(fpc[WR]);
3637895Sbostic execl(_PATH_MKEY, "mkey", "-s", 0);
3712309Stut _assert(0);
3812309Stut }
3912309Stut if ( (pid2 = fork()) == 0)
4012309Stut {
4112309Stut char coarg[20];
4212309Stut sprintf(coarg, "-C%d", colevel);
4312309Stut fmv(fpb[RD], 0);
4412309Stut fmv(fpc[WR], 1);
4512309Stut close(fpa[RD]);
4612309Stut close(fpa[WR]);
4712309Stut close(fpb[WR]);
4812309Stut close(fpc[RD]);
4937895Sbostic execl(_PATH_HUNT, "hunt",
5012309Stut /* "-P", */
5137895Sbostic coarg, "-Ty", "-Fn", _PATH_ALL, 0);
5212309Stut _assert(0);
5312309Stut }
5412309Stut _assert (pid1 != -1);
5512309Stut _assert(pid2 != -1);
5612309Stut close(fpb[RD]);
5712309Stut close(fpb[WR]);
5812309Stut close(fpa[RD]);
5912309Stut close(fpc[WR]);
6037895Sbostic ansf = fopen(_PATH_DEVNULL, "r");
6112309Stut fmv (fpc[RD], ansf->_file);
6212309Stut for(iarg=1; iarg<argc; iarg++)
6312309Stut prod(fpa[WR], argv[iarg]);
6412309Stut close(fpa[WR]);
6512309Stut s=fnames;
6612309Stut af=files;
6712309Stut while (af < files+NFILES)
6812309Stut {
6912309Stut if (fgets(af->nm=s, NAMES, ansf)==0)
7012309Stut break;
7112309Stut trimnl(s);
7212309Stut if (*s==0) continue;
7312309Stut while (*s++);
7412309Stut _assert(s<fnames+NAMES);
7512309Stut st = stat(af->nm, &statbuf);
7612309Stut if (st<0) continue;
7712309Stut af->uid = statbuf.st_uid;
7812309Stut af->fdate = statbuf.st_mtime;
7912309Stut af->size = statbuf.st_size;
8012309Stut af++;
8112309Stut }
8212309Stut fclose(ansf);
8312309Stut return(af-files);
8412309Stut }
8512309Stut
prod(f,s)8612309Stut prod(f,s)
8712309Stut char *s;
8812309Stut {
8912309Stut write (f, s, strlen(s));
9012309Stut write (f, "\n", 1);
9112309Stut }
92