|
|
1.1 ! root 1: #include "stdio.h" ! 2: #include "cbt.h" ! 3: #include "sys/types.h" ! 4: #include "sys/stat.h" ! 5: extern bfile *bopen(); ! 6: ! 7: long ndcnt[MXHT + 1]; ! 8: long frcnt, reccnt, reclen; ! 9: bfile *bt; ! 10: ! 11: main(argc, argv) ! 12: char **argv; ! 13: { int i, j; ! 14: for(i = 1; i < argc; i++) { ! 15: doarg(argv[i]); ! 16: for(j = 0; j <= MXHT; j++) ! 17: ndcnt[j] = 0; ! 18: frcnt = reccnt = reclen = 0; ! 19: if(i+1 < argc) ! 20: putchar('\n'); ! 21: } ! 22: exit(0); ! 23: } ! 24: ! 25: doarg(s) ! 26: char *s; ! 27: { struct stat statbuf; ! 28: long x; ! 29: int i; ! 30: bt = bopen(s, 0); ! 31: if(bt == NULL) { ! 32: i = strlen(s); ! 33: if(s[i-2] == '.') { ! 34: s[i-2] = 0; ! 35: if(s[i-1] == 'F') ! 36: return; ! 37: if(s[i-1] == 'T') ! 38: bt = bopen(s, 0); ! 39: } ! 40: if(bt == NULL) { ! 41: perror(s); ! 42: return; ! 43: } ! 44: } ! 45: fstat(bt->tfd, &statbuf); ! 46: printf("%s.T %ld bytes", s, statbuf.st_size); ! 47: if(bt->dfd > 0 && fstat(bt->dfd, &statbuf) == 0) ! 48: printf(", %s.F %ld bytes", s, statbuf.st_size); ! 49: putchar('\n'); ! 50: donode(0); ! 51: for(x = i = 0; i <= MXHT; i++) ! 52: x += ndcnt[i] * NDSZ; ! 53: printf("%ld bytes used in tree\n", x); ! 54: for(i = 0; i <= bt->height; i++) ! 55: printf(" %ld nodes at level %d", ndcnt[i], i); ! 56: printf("\n%ld bytes free\n", frcnt); ! 57: printf("%ld records totalling %ld bytes\n", reccnt, reclen); ! 58: bclose(bt); ! 59: } ! 60: ! 61: /* this routine believes the tree is well-formed */ ! 62: donode(n) ! 63: { char buf[NDSZ]; ! 64: hdr *b = (hdr *)buf; ! 65: int i; ! 66: (void) lseek(bt->tfd, (long)NDSZ * n, 0); ! 67: (void) read(bt->tfd, buf, NDSZ); ! 68: ndcnt[b->hlev]++; ! 69: frcnt += nfree(b); ! 70: if(b->hlev) ! 71: for(i = 0; i <= b->kcnt; i++) ! 72: donode(*ndadr(b, i)); ! 73: else ! 74: for(i = 0; i < b->kcnt; i++) { ! 75: reccnt++; ! 76: if(!(b->htype & INDEX)) ! 77: reclen += lfadr(b, i)->llen; ! 78: } ! 79: } ! 80: static struct D { struct D *a; char *b;} VER = {&VER,"\n81/4/26:btreport.c\n"}; ! 81: /*1010101001010110*/
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.