Research V7 development
[unix-history] / usr / src / cmd / refer / mkey1.c
CommitLineData
52960f2f
ML
1# include "stdio.h"
2extern char *comname; /* "/usr/lib/eign" */
3int wholefile = 0;
4int keycount = 100;
5int labels = 1;
6int minlen = 3;
7extern int comcount;
8char *iglist "XYZ#";
9
10main (argc,argv)
11 char *argv[];
12{
13/* this program expects as its arguments a list of
14 files and generates a set of lines of the form
15 filename:byte-add,length (tab) key1 key2 key3
16 where the byte addresses give the position within
17 the file and the keys are the strings off the lines
18 which are alphabetic, first six characters only.
19*/
20
21int i;
22char *name, qn[200];
23char *inlist 0;
24
25FILE *f, *ff;
26
27while (argc>1 && argv[1][0] == '-')
28 {
29 switch(argv[1][1])
30 {
31 case 'c':
32 comname = argv[2];
33 argv++; argc--;
34 break;
35 case 'w':
36 wholefile = 1; break;
37 case 'f':
38 inlist = argv[2];
39 argv++; argc--;
40 break;
41 case 'i':
42 iglist = argv[2];
43 argv++; argc--;
44 break;
45 case 'l':
46 minlen = atoi(argv[1]+2);
47 if (minlen<=0) minlen=3;
48 break;
49 case 'n': /* number of common words to use */
50 comcount = atoi(argv[1]+2);
51 break;
52 case 'k': /* number of keys per file max */
53 keycount = atoi(argv[1]+2);
54 break;
55 case 's': /* suppress labels, search only */
56 labels = 0;
57 break;
58 }
59 argc--; argv++;
60 }
61if (inlist)
62 {
63 ff = fopen(inlist, "r");
64 while (fgets(qn, 200, ff))
65 {
66 trimnl(qn);
67 f = fopen (qn, "r");
68 if (f!=NULL)
69 dofile(f, qn);
70 else
71 fprintf(stderr, "Can't read %s\n",qn);
72 }
73 }
74else
75if (argc<=1)
76 dofile(stdin, "");
77else
78for(i=1; i<argc; i++)
79 {
80 f = fopen(name=argv[i], "r");
81 if (f==NULL)
82 err("No file %s",name);
83 else
84 dofile(f, name);
85 }
86exit(0);
87}