Annotation of 3BSD/cmd/refer/hunt8.c, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.