# define unopen(fil) {if (fil!=NULL) {fclose(fil); fil=NULL;}}
static union {unsigned *a
; long *b
;} master NULL
;
extern char *fgnames
[], **fgnamp
;
char *sinput
, *soutput
, *tagout
;
long indexdate
0, gdate();
/* read query from stdin, expect name of indexes in argv[1] */
static FILE *fa
, *fb
, *fc
;
char indexname
[100], *qitem
[100], *rprog
0;
static char oldname
[30] ;
int falseflg
0, nitem
, nfound
, frtbl
;
fprintf(stderr
, "in glue1 argc %d argv %o %o\n", argc
, argv
[0],argv
[1]);
while (argv
[1][0] == '-')
fprintf(stderr
, "argv.1 is %s\n",argv
[1]);
case 'a': /* all output, incl. false drops */
case 'F': /* put out full text */
full
= setfrom(argv
[1][2]);
case 'T': /* put out tags */
tags
= setfrom(argv
[1][2]);
case 'i': /* input in argument string */
case 's': /*text output to string */
case 't': /*tag output to string */
case 'l': /* specify length of lists */
fprintf(stderr
, "lmaster now %d\n",lmaster
);
strcpy (indexname
, todir(argv
[1]));
fprintf(stderr
, "in huntmain indexname %s typeindex %d\n", indexname
, typeindex
);
if (typeindex
== 0 || strcmp (oldname
, indexname
) !=0)
strcpy (oldname
, indexname
);
unopen(fa
); unopen(fb
); unopen(fc
);
if (ckexist(indexname
, ".ib"))
fprintf(stderr
, "found old index\n");
fa
= iopen(indexname
, ".ia");
fb
= iopen(indexname
, ".ib");
fc
= iopen(indexname
, ".ic");
fprintf(stderr
, "opened f's as %o %o %o\n",fa
,fb
,fc
);
fread (&nhash
, sizeof(nhash
), 1, fa
);
fread (&iflong
, sizeof(iflong
), 1, fa
);
free (hpt
, maxhash
, sizeof(*hpt
));
free(hfreq
, maxhash
, sizeof(*hfreq
));
fprintf(stderr
, "Freed if needed maxhash %d\n",maxhash
);
hpt
= zalloc(nhash
, sizeof(*hpt
));
fprintf(stderr
, "hpt now %o\n",hpt
);
err ("No space for hash list (%d)", nhash
);
fread( hpt
, sizeof(*hpt
), nhash
, fa
);
hfreq
=zalloc(nhash
, sizeof(*hfreq
));
err ("No space for hash frequencies (%d)", nhash
);
frtbl
= fread(hfreq
, sizeof(*hfreq
), nhash
, fa
);
hfrflg
= (frtbl
== nhash
);
fprintf(stderr
,"Read pointer files\n");
master
.b
= zalloc(lmaster
, sizeof(long));
master
.a
= zalloc(lmaster
, sizeof(int));
err ("no space for answer list",0);
if (makefgrep(indexname
))
err ("No files %s\n",indexname
);
fprintf(stderr
, "typeindex now %d\n",typeindex
);
grepcall(sinput
, tagout
, indexname
);
fprintf(stderr
, " back from grepcall\n");
fprintf(stderr
, "approaching doquery fb %o\n", fb
);
nfound
= doquery(hpt
, nhash
, fb
, nitem
, qitem
, master
);
fprintf(stderr
, "return from doquery with nfound %d\n", nfound
);
nfound
= baddrop(master
, nfound
, fc
, nitem
, qitem
, rprog
, full
);
fprintf(stderr
, "after baddrop with nfound %d\n",nfound
);
fprintf(stderr
, "tagout is /%s/, sout /%s/\n",tagout
, soutput
);
result (master
, nfound
>tags
? tags
: nfound
, fc
);
fprintf(stderr
, "done with huntmain\n");
fprintf(stderr
, "tagout is /%s/\n", tagout
);
fprintf(stderr
, "string out is /%s/\n", soutput
);
fprintf(stderr
, "were %d bad files\n", fgnamp
-fgnames
);
strcat(grepquery
, qitem
[k
]);
for(fgp
=fgnames
; fgp
<fgnamp
; fgp
++)
fprintf(stderr
, "Now on %s query /%s/\n", *fgp
, grepquery
);
grepcall(grepquery
, tagout
, *fgp
);
fprintf(stderr
, "tagout now /%s/\n", tagout
);
while (s
>=t
&& *s
!= '/') s
--;
case '2': case '3': case '4': case '5':
case '6': case '7': case '8': case '9':