1: #if !defined(lint) && defined(DOSCCS)
   2: static char *sccsid = "@(#)hunt8.c	4.2.1 (2.11BSD) 1996/10/23";
   3: #endif
   4: 
   5: #include <stdio.h>
   6: #include <assert.h>
   7: #define unopen(fil) {if (fil!=NULL) {fclose(fil); fil=NULL;}}
   8: 
   9: extern long indexdate, gdate();
  10: extern FILE *iopen();
  11: runbib (s)
  12: char *s;
  13: {
  14:     /* make a file suitable for fgrep */
  15:     char tmp[200];
  16:     sprintf(tmp, "/usr/libexec/refer/mkey %s >%s.ig", s,s);
  17:     system(tmp);
  18: }
  19: 
  20: makefgrep(indexname)
  21: char *indexname;
  22: {
  23:     FILE *fa, *fb;
  24:     if (ckexist(indexname, ".ig"))
  25:     {
  26:         /* existing gfrep -type index */
  27: # if D1
  28:         fprintf(stderr, "found fgrep\n");
  29: # endif
  30:         fa = iopen(indexname, ".ig");
  31:         fb = iopen(indexname, "");
  32:         if (gdate(fb)>gdate(fa))
  33:         {
  34:             if (fa!=NULL)
  35:                 fclose(fa);
  36:             runbib(indexname);
  37:             fa= iopen(indexname, ".ig");
  38:         }
  39:         indexdate = gdate(fa);
  40:         unopen(fa);
  41:         unopen(fb);
  42:     }
  43:     else
  44:         if (ckexist(indexname, ""))
  45:         {
  46:             /* make fgrep */
  47: # if D1
  48:             fprintf(stderr, "make fgrep\n");
  49: # endif
  50:             runbib(indexname);
  51:             time(&indexdate);
  52:         }
  53:         else /* failure */
  54:         return(0);
  55:     return(1); /* success */
  56: }
  57: 
  58: ckexist(s, t)
  59: char *s, *t;
  60: {
  61:     char fnam[100];
  62:     strcpy (fnam, s);
  63:     strcat (fnam, t);
  64:     return (access(fnam, 04) != -1);
  65: }
  66: 
  67: FILE *
  68: iopen(s, t)
  69: char *s, *t;
  70: {
  71:     char fnam[100];
  72:     FILE *f;
  73:     strcpy (fnam, s);
  74:     strcat (fnam, t);
  75:     f = fopen (fnam, "r");
  76:     if (f == NULL)
  77:     {
  78:         err("Missing expected file %s", fnam);
  79:         exit(1);
  80:     }
  81:     return(f);
  82: }

Defined functions

ckexist defined in line 58; used 3 times
iopen defined in line 67; used 8 times
makefgrep defined in line 20; used 3 times
runbib defined in line 11; used 2 times

Defined variables

sccsid defined in line 2; never used

Defined macros

unopen defined in line 7; used 2 times
Last modified: 1996-10-24
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2660
Valid CSS Valid XHTML 1.0 Strict