|
|
1.1 ! root 1: # include "stdio.h" ! 2: # include "assert.h" ! 3: # define TXTLEN 1000 ! 4: char *outbuf= 0; ! 5: extern char *soutput; ! 6: extern int soutlen, iflong; ! 7: extern long indexdate; ! 8: baddrop(master, nf, fc, nitem, qitem, rprog, full) ! 9: union ptr {unsigned *a; long *b; } master; ! 10: FILE *fc; ! 11: char *qitem[], *rprog; ! 12: { ! 13: /* checks list of drops for real bad drops; ! 14: uses "deliv" to find items. */ ! 15: int i, g, j, need, got, na, len; ! 16: long lp; ! 17: char res[100], *ar[50], output[TXTLEN]; ! 18: extern int colevel, reached; ! 19: # if D1 ! 20: if (iflong) ! 21: fprintf(stderr,"in baddrop, nf %d master %ld %ld %ld\n", nf, master.b[0], master.b[1], master.b[2]); ! 22: else ! 23: fprintf(stderr,"in baddrop, nf %d master %d %d %d\n", nf, master.a[0], master.a[1], master.a[2]); ! 24: # endif ! 25: for (i=g=0; i<nf; i++) ! 26: { ! 27: lp = iflong ? master.b[i] : master.a[i]; ! 28: # if D1 ! 29: if (iflong) ! 30: fprintf(stderr, "i %d master %lo lp %lo\n", i, master.b[i], lp); ! 31: else ! 32: fprintf(stderr, "i %d master %o lp %lo\n", i, master.a[i], lp); ! 33: # endif ! 34: fseek (fc, lp, 0); ! 35: fgets( res, 100, fc); ! 36: # if D1 ! 37: fprintf(stderr, "tag %s", res); ! 38: # endif ! 39: if (!auxil(res,output)) ! 40: { ! 41: char *s; int c; ! 42: # if D1 ! 43: fprintf(stderr, "not auxil try rprog %c\n", rprog? 'y': 'n'); ! 44: # endif ! 45: for(s=res; c= *s; s++) ! 46: if (c == ';' || c == '\n') ! 47: {*s=0; break;} ! 48: len = rprog ? ! 49: corout (res, output, rprog, 0, TXTLEN) : ! 50: findline (res, output, TXTLEN, indexdate); ! 51: } ! 52: # if D1 ! 53: assert (len <TXTLEN); ! 54: fprintf(stderr,"item %d of %d, tag %s len %d output\n%s\n..\n",i,nf,res, len,output); ! 55: # endif ! 56: if (len==0) ! 57: continue; ! 58: need = colevel ? reached : nitem; ! 59: na=0; ! 60: ar[na++] = "fgrep"; ! 61: ar[na++] = "-r"; ! 62: ar[na++] = "-n"; ! 63: ar[na++] = (char *) need; ! 64: ar[na++] = "-i"; ! 65: ar[na++] = output; ! 66: ar[na++] = (char *) len; ! 67: for(j=0; j<nitem; j++) ! 68: ar[na++] = qitem[j]; ! 69: # ifdef D1 ! 70: fprintf(stderr, "calling fgrep len %d ar[4] %s %o %d \n",len,ar[4],ar[5],ar[6]); ! 71: fprintf(stderr, "? strings %s , %s\n", qitem[0], qitem[1]); ! 72: # endif ! 73: if (fgrep(na, ar)==0) ! 74: { ! 75: # ifdef D1 ! 76: fprintf(stderr, "fgrep found it\n"); ! 77: # endif ! 78: if (iflong) ! 79: master.b[g++] = master.b[i]; ! 80: else ! 81: master.a[g++] = master.a[i]; ! 82: if (full >= g) ! 83: if (soutput==0) ! 84: fputs(output, stdout); ! 85: else ! 86: strcpy (soutput, output); ! 87: } ! 88: # ifdef D1 ! 89: fprintf(stderr, "after fgrep g = %d\n", g); ! 90: # endif ! 91: } ! 92: return(g); ! 93: } ! 94: auxil( res, output) ! 95: char *res, *output; ! 96: { ! 97: extern FILE *fd; ! 98: long lp, c; int len; ! 99: if (fd==0)return(0); ! 100: while (c = *res++) ! 101: { ! 102: if (c == ';') ! 103: { ! 104: sscanf(res, "%ld,%d", &lp, &len); ! 105: fseek (fd, lp, 0); ! 106: fgets(output, len, fd); ! 107: return(1); ! 108: } ! 109: } ! 110: return(0); ! 111: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.