Annotation of 43BSDTahoe/new/bib/src/lookup.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char sccsid[] = "@(#)lookup.c   2.5     6/10/85";
                      3: #endif not lint
                      4: # include "stdio.h"
                      5: # include "streams.h"
                      6: # include "bib.h"
                      7: 
                      8: char *locate();
                      9: 
                     10: int     fflag =   0;        /*  print out file names                    */
                     11: int     Aflag =   0;        /*  print hits from All indexes            */
                     12: int     max_klen =   6;     /*  max length of keys                      */
                     13: char    *common =           /*  name of file of common words            */
                     14:             COMFILE;
                     15: char    INDEX[maxstr] =     /*  name of index file                      */
                     16:             INDXFILE;
                     17: 
                     18: int     argc;
                     19: char    **argv;
                     20: 
                     21: main(argcount,arglist)
                     22: int argcount;
                     23: char **arglist;
                     24: {   char *refs;
                     25:     char keys[maxstr];
                     26:     char *p,*q;
                     27:     char one_index[maxstr];
                     28:     int found;
                     29: 
                     30:     strcpy(BMACLIB, N_BMACLIB);
                     31:     strcpy(COMFILE, N_COMFILE);
                     32:     strcpy(DEFSTYLE, N_DEFSTYLE);
                     33: 
                     34:     argc= argcount-1;
                     35:     argv= arglist+1;
                     36:     flags();
                     37: 
                     38:     /*  add SYSINDEX to search path.  all names are comma terminated */
                     39:        strcat(INDEX, ",");
                     40:        strcat(INDEX, SYSINDEX);
                     41:        strcat(INDEX, ",");
                     42: 
                     43:     while (fgets(keys,maxstr,stdin)!=NULL)
                     44:     {  found = 0;
                     45:        for (p = one_index, q = INDEX; *q != 0 ; q++)
                     46:            if (*q == ',' )
                     47:            {   *p = 0;
                     48:                refs = locate(keys, one_index, max_klen, common);
                     49:                if( refs==NULL )
                     50:                {   fprintf(stderr,
                     51:                        "%s removed from index list.\n", one_index);
                     52:                    /* delete this file name (shift remainder on top) */
                     53:                        strcpy(q-strlen(one_index),q+1);
                     54:                        q = q-strlen(one_index)-1;
                     55:                }
                     56:                 if (refs!=NULL && *refs!=NULL)
                     57:                {
                     58:                    printf("%s", refs);
                     59:                    free(refs);
                     60:                    found = 1;
                     61:                    if (!Aflag) break;
                     62:                }
                     63:                p = one_index;
                     64:            }
                     65:            else *p++ = *q;
                     66: 
                     67:         if (!found)  printf("No references found.\n");
                     68:     }
                     69:     exit(0);
                     70: }
                     71: 
                     72: # define    operand     (strlen(*argv+2)==0 ? (argv++,argc--,*argv) : *argv+2)
                     73: 
                     74: flags()
                     75: {
                     76:     char *p;
                     77:     for (; argc>0 && *argv[0]=='-';  argc--,argv++)
                     78:     {   switch ((*argv)[1])
                     79:         {   case 'l':   max_klen= atoi(operand);
                     80:                         break;
                     81:            case 'f':   fflag++;
                     82:                        break;
                     83:             case 'c':   common=  operand;
                     84:                         break;
                     85:            case 'A':   Aflag++;
                     86:                        break;
                     87:             case 'p':   strcpy(INDEX,operand);
                     88:                         break;
                     89:            case 'd':
                     90:                p = &argv[0][2];
                     91:                if (!p) { 
                     92:                        argv++;
                     93:                        p = &argv[0][0];
                     94:                }
                     95:                strreplace(COMFILE, BMACLIB, p);
                     96:                strcpy(BMACLIB, p);
                     97:                break;
                     98:             default:    fprintf(stderr, "unknown flag '%s'\n", *argv);
                     99:         }
                    100:     }
                    101: }

unix.superglobalmegacorp.com

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