2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
20 #define unopen(fil) {if (fil != NULL) {fclose(fil); fil = NULL; }}
23 extern long indexdate
, gdate();
26 int ckexist(char *, char *);
31 /* make a file suitable for fgrep */
33 sprintf(tmp
, "/usr/lib/refer/mkey '%s' > '%s.ig'", s
, s
);
38 makefgrep(char *indexname
)
41 if (ckexist(indexname
, ".ig")) {
42 /* existing gfrep -type index */
44 fprintf(stderr
, "found fgrep\n");
46 fa
= iopen(indexname
, ".ig");
47 fb
= iopen(indexname
, "");
48 if (gdate(fb
) > gdate(fa
)) {
52 fa
= iopen(indexname
, ".ig");
54 indexdate
= gdate(fa
);
58 if (ckexist(indexname
, "")) {
61 fprintf(stderr
, "make fgrep\n");
67 return (1); /* success */
71 ckexist(char *s
, char *t
)
76 return (access(fnam
, 04) != -1);
80 iopen(char *s
, char *t
)
88 err(gettext("Missing expected file %s"), fnam
);