1: #ifndef lint
2: static char *sccsid = "@(#)hunt8.c 4.2 (Berkeley) 6/23/83";
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/lib/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
iopen
defined in line
67; used 8 times
Defined variables
sccsid
defined in line
2;
never used
Defined macros
unopen
defined in line
7; used 2 times