1: #ifndef lint
   2: static char *sccsid = "@(#)what1.c	4.1 (Berkeley) 5/6/83";
   3: #endif
   4: 
   5: #include "what..c"
   6: 
   7: struct filans files[NFILES];
   8: char fnames[NAMES];
   9: int relfeed 0;
  10: char *rb[NFEED];
  11: char rbb[200], *rbp rbb;
  12: ;
  13: 
  14: main(argc,argv)
  15: char *argv[];
  16: {
  17:     char *s, *t, *xargv[50], *wd[50];
  18:     struct filans *af;
  19:     int xargc 0, nw, nf, i;
  20:     while (argc>1 && argv[1][0]=='-')
  21:     {
  22:         switch(argv[1][1])
  23:         {
  24:         case 'r':
  25:             relfeed=1;
  26:             break;
  27:         }
  28:         argc--;
  29:         argv++;
  30:     }
  31:     if (argc<=1)
  32:     {
  33:         printf("No query.\n");
  34:         return(0);
  35:     }
  36:     nf = doclook(argc,argv,0);
  37:     printf("   %d files\n",nf);
  38:     if (relfeed && nf>NFEED)
  39:     {
  40:         wrdoc(NFEED, argc, argv, 1);
  41:         nw = freqwd (rb, wd, argc);
  42:         for(i=0; rb[i]; i++)
  43:             unlink(rb[i]);
  44:     }
  45:     for(i=0; i<argc; i++)
  46:         xargv[xargc++]=argv[i];
  47:     if (relfeed)
  48:     {
  49:         printf("Adding: ");
  50:         for(i=0; i<nw; i++)
  51:             if (!lfind(wd[i], xargc, xargv))
  52:                 printf("%s ", xargv[xargc++]=wd[i]);
  53:         printf("\n");
  54:         nf = doclook(xargc, xargv, relfeed? xargc/4 : 0);
  55:         printf("  %d files\n",nf);
  56:     }
  57:     shell (nf, comp, exch);
  58:     wrdoc(nf, xargc, xargv, 0);
  59:     return(0);
  60: }
  61: 
  62: exch( i1, i2 )
  63: {
  64:     struct filans *p1, *p2;
  65:     struct filans xt;
  66:     p1=files+i1;
  67:     p2=files+i2;
  68:     xt = *p1;
  69:     *p1 = *p2;
  70:     *p2 = xt;
  71: }
  72: 
  73: comp(i1, i2)
  74: {
  75:     struct filans *p1, *p2;
  76:     p1 = files+i1;
  77:     p2= files+i2;
  78:     if (p1->fdate != p2->fdate)
  79:         return(p2->fdate > p1->fdate);
  80:     return(p2->uid >= p1->uid);
  81: }
  82: 
  83: wrdoc ( np, argc, argv, relfeed )
  84: {
  85:     struct filans *af;
  86:     char *s, *t, buf[200];
  87:     int eval, k, pid;
  88:     FILE *rf NULL;
  89:     FILE *ans NULL;
  90:     pid=getpid();
  91:     for(af=files; af<files+np; af++)
  92:     {
  93:         t = ctime(&af->fdate);
  94:         getpw(af->uid, s=buf);
  95:         while (*s && *s!=':') s++;
  96:         *s=0;
  97:         printf("%s (%.20s)  %s, %ld bytes\n",af->nm,t+4,buf,af->size);
  98:         if (relfeed)
  99:         {
 100:             k=af-files;
 101:             _assert (k<NFEED);
 102:             sprintf(rb[k]=rbp, "rf%d.%d",pid, k);
 103:             rf = fopen(rb[k], "w");
 104:             while (*rbp++);
 105:         }
 106:         describe(af->nm, argc,argv, rf);
 107:         if (relfeed)
 108:         {
 109:             printf("You like that one?");
 110:             fflush(stdout);
 111:             fgets(buf, 100, stdin);
 112:             switch(buf[0])
 113:             {
 114:             case 'y':
 115:             case 'Y':
 116:                 eval=1;
 117:                 break;
 118:             case 'n':
 119:             case 'N':
 120:                 eval = -1;
 121:                 break;
 122:             default:
 123:                 eval=0;
 124:                 break;
 125:             }
 126:             fclose(rf);
 127:             if (eval<=0)
 128:             {
 129:                 unlink(rb[k]);
 130:                 rb[k][0]=0;
 131:             }
 132:         }
 133:     }
 134:     if (relfeed) rb[np]=0;
 135: }
 136: 
 137: lfind( wl, n, wds)
 138: char *wl, *wds[];
 139: {
 140:     int i;
 141:     for(i=0; i<n; i++)
 142:         if (str6cmp(wl, wds[i])==0)
 143:             return(1);
 144:     return(0);
 145: }
 146: 
 147: str6cmp(s, t)
 148: char *s, *t;
 149: {
 150:     int i 0, c;
 151:     while ( (c= *s++ ) == ( *t++))
 152:         if (c==0 || ++i ==6)
 153:             return(0);
 154:     return(1);
 155: }

Defined functions

comp defined in line 73; used 2 times
exch defined in line 62; used 2 times
lfind defined in line 137; used 1 times
  • in line 51
main defined in line 14; never used
str6cmp defined in line 147; used 1 times
wrdoc defined in line 83; used 2 times

Defined variables

files defined in line 7; used 17 times
fnames defined in line 8; used 2 times
rb defined in line 10; used 8 times
rbb defined in line 11; never used
rbp defined in line 11; used 2 times
relfeed defined in line 9; used 8 times
sccsid defined in line 2; never used
Last modified: 1983-05-08
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1371
Valid CSS Valid XHTML 1.0 Strict