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

Defined functions

doclook defined in line 7; used 2 times
prod defined in line 81; used 1 times
  • in line 58

Defined variables

sccsid defined in line 2; never used

Defined macros

RD defined in line 16; used 9 times
WR defined in line 17; used 10 times
fmv defined in line 18; used 5 times
Last modified: 1996-10-24
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2649
Valid CSS Valid XHTML 1.0 Strict