1*12309Stut #ifndef lint 2*12309Stut static char *sccsid = "@(#)what3.c 4.1 (Berkeley) 05/06/83"; 3*12309Stut #endif 4*12309Stut 5*12309Stut #include "what..c" 6*12309Stut 7*12309Stut doclook(argc, argv, colevel) 8*12309Stut char *argv[]; 9*12309Stut { 10*12309Stut int fpa[2], fpb[2], fpc[2], pid1, pid2, st; 11*12309Stut int iarg; 12*12309Stut char *s; 13*12309Stut FILE *ansf; 14*12309Stut struct filans *af; 15*12309Stut struct stat statbuf; 16*12309Stut # define RD 0 17*12309Stut # define WR 1 18*12309Stut # define fmv(x,y) close(y); dup(x); close(x); 19*12309Stut /* we want to run chkbib and then lhunt and pipe in & out */ 20*12309Stut pipe (fpa); /* from this program to chkbib */ 21*12309Stut pipe (fpb); /* from chkbib to lhunt */ 22*12309Stut pipe (fpc); /* from lhunt to us */ 23*12309Stut if ( (pid1 = fork()) ==0) 24*12309Stut { 25*12309Stut fmv(fpa[RD], 0); 26*12309Stut fmv(fpb[WR], 1); 27*12309Stut close(fpa[WR]); 28*12309Stut close(fpb[RD]); 29*12309Stut close(fpc[RD]); 30*12309Stut close(fpc[WR]); 31*12309Stut execl("/usr/lib/refer/mkey", "mkey", "-s", 0); 32*12309Stut _assert(0); 33*12309Stut } 34*12309Stut if ( (pid2 = fork()) == 0) 35*12309Stut { 36*12309Stut char coarg[20]; 37*12309Stut sprintf(coarg, "-C%d", colevel); 38*12309Stut fmv(fpb[RD], 0); 39*12309Stut fmv(fpc[WR], 1); 40*12309Stut close(fpa[RD]); 41*12309Stut close(fpa[WR]); 42*12309Stut close(fpb[WR]); 43*12309Stut close(fpc[RD]); 44*12309Stut execl("/usr/lib/refer/hunt", "hunt", 45*12309Stut /* "-P", */ 46*12309Stut coarg, "-Ty", "-Fn", "/usr/dict/lookall/All", 0); 47*12309Stut _assert(0); 48*12309Stut } 49*12309Stut _assert (pid1 != -1); 50*12309Stut _assert(pid2 != -1); 51*12309Stut close(fpb[RD]); 52*12309Stut close(fpb[WR]); 53*12309Stut close(fpa[RD]); 54*12309Stut close(fpc[WR]); 55*12309Stut ansf = fopen("/dev/null", "r"); 56*12309Stut fmv (fpc[RD], ansf->_file); 57*12309Stut for(iarg=1; iarg<argc; iarg++) 58*12309Stut prod(fpa[WR], argv[iarg]); 59*12309Stut close(fpa[WR]); 60*12309Stut s=fnames; 61*12309Stut af=files; 62*12309Stut while (af < files+NFILES) 63*12309Stut { 64*12309Stut if (fgets(af->nm=s, NAMES, ansf)==0) 65*12309Stut break; 66*12309Stut trimnl(s); 67*12309Stut if (*s==0) continue; 68*12309Stut while (*s++); 69*12309Stut _assert(s<fnames+NAMES); 70*12309Stut st = stat(af->nm, &statbuf); 71*12309Stut if (st<0) continue; 72*12309Stut af->uid = statbuf.st_uid; 73*12309Stut af->fdate = statbuf.st_mtime; 74*12309Stut af->size = statbuf.st_size; 75*12309Stut af++; 76*12309Stut } 77*12309Stut fclose(ansf); 78*12309Stut return(af-files); 79*12309Stut } 80*12309Stut 81*12309Stut prod(f,s) 82*12309Stut char *s; 83*12309Stut { 84*12309Stut write (f, s, strlen(s)); 85*12309Stut write (f, "\n", 1); 86*12309Stut } 87