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

Defined functions

ckexist defined in line 50; used 3 times
iopen defined in line 58; used 6 times
runbib defined in line 5; used 2 times

Defined macros

unopen defined in line 3; used 3 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 809
Valid CSS Valid XHTML 1.0 Strict