1*48299Sbostic /*-
2*48299Sbostic * %sccs.include.proprietary.c%
3*48299Sbostic */
4*48299Sbostic
512299Stut #ifndef lint
6*48299Sbostic static char sccsid[] = "@(#)mkey1.c 4.2 (Berkeley) 04/18/91";
7*48299Sbostic #endif /* not lint */
812299Stut
912299Stut #include <stdio.h>
1012299Stut
1112299Stut extern char *comname; /* "/usr/lib/eign" */
1212299Stut int wholefile = 0;
1312299Stut int keycount = 100;
1412299Stut int labels = 1;
1512299Stut int minlen = 3;
1612299Stut extern int comcount;
1712299Stut char *iglist = "XYZ#";
1812299Stut
main(argc,argv)1912299Stut main (argc,argv)
2012299Stut char *argv[];
2112299Stut {
2212299Stut /* this program expects as its arguments a list of
2312299Stut * files and generates a set of lines of the form
2412299Stut * filename:byte-add,length (tab) key1 key2 key3
2512299Stut * where the byte addresses give the position within
2612299Stut * the file and the keys are the strings off the lines
2712299Stut * which are alphabetic, first six characters only.
2812299Stut */
2912299Stut
3012299Stut int i;
3112299Stut char *name, qn[200];
3212299Stut char *inlist = 0;
3312299Stut
3412299Stut FILE *f, *ff;
3512299Stut
3612299Stut while (argc>1 && argv[1][0] == '-')
3712299Stut {
3812299Stut switch(argv[1][1])
3912299Stut {
4012299Stut case 'c':
4112299Stut comname = argv[2];
4212299Stut argv++;
4312299Stut argc--;
4412299Stut break;
4512299Stut case 'w':
4612299Stut wholefile = 1;
4712299Stut break;
4812299Stut case 'f':
4912299Stut inlist = argv[2];
5012299Stut argv++;
5112299Stut argc--;
5212299Stut break;
5312299Stut case 'i':
5412299Stut iglist = argv[2];
5512299Stut argv++;
5612299Stut argc--;
5712299Stut break;
5812299Stut case 'l':
5912299Stut minlen = atoi(argv[1]+2);
6012299Stut if (minlen<=0) minlen=3;
6112299Stut break;
6212299Stut case 'n': /* number of common words to use */
6312299Stut comcount = atoi(argv[1]+2);
6412299Stut break;
6512299Stut case 'k': /* number of keys per file max */
6612299Stut keycount = atoi(argv[1]+2);
6712299Stut break;
6812299Stut case 's': /* suppress labels, search only */
6912299Stut labels = 0;
7012299Stut break;
7112299Stut }
7212299Stut argc--;
7312299Stut argv++;
7412299Stut }
7512299Stut if (inlist)
7612299Stut {
7712299Stut ff = fopen(inlist, "r");
7812299Stut while (fgets(qn, 200, ff))
7912299Stut {
8012299Stut trimnl(qn);
8112299Stut f = fopen (qn, "r");
8212299Stut if (f!=NULL)
8312299Stut dofile(f, qn);
8412299Stut else
8512299Stut fprintf(stderr, "Can't read %s\n",qn);
8612299Stut }
8712299Stut }
8812299Stut else
8912299Stut if (argc<=1)
9012299Stut dofile(stdin, "");
9112299Stut else
9212299Stut for(i=1; i<argc; i++)
9312299Stut {
9412299Stut f = fopen(name=argv[i], "r");
9512299Stut if (f==NULL)
9612299Stut err("No file %s",name);
9712299Stut else
9812299Stut dofile(f, name);
9912299Stut }
10012299Stut exit(0);
10112299Stut }
102