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