Annotation of 41BSD/cmd/refer/mkey1.c, revision 1.1.1.1

1.1       root        1: # include "stdio.h"
                      2: extern char *comname; /* "/usr/lib/eign" */
                      3: int wholefile = 0;
                      4: int keycount = 100;
                      5: int labels = 1;
                      6: int minlen = 3;
                      7: extern int comcount;
                      8: char *iglist = "XYZ#";
                      9: 
                     10: main (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: 
                     21: int i;
                     22: char *name, qn[200];
                     23: char *inlist = 0;
                     24: 
                     25: FILE *f, *ff;
                     26: 
                     27: while (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:        }
                     61: if (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:        }
                     74: else
                     75: if (argc<=1)
                     76:        dofile(stdin, "");
                     77: else
                     78: for(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:        }
                     86: exit(0);
                     87: }

unix.superglobalmegacorp.com

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