Index: tool/showdb.c ================================================================== --- tool/showdb.c +++ tool/showdb.c @@ -32,10 +32,17 @@ } v = (v<<8) + (z[i]&0xff); *pVal = v; return 9; } + +/* +** Extract a big-endian 32-bit integer +*/ +static unsigned int decodeInt32(const unsigned char *z){ + return (z[0]<<24) + (z[1]<<16) + (z[2]<<8) + z[3]; +} /* Report an out-of-memory error and die. */ static void out_of_memory(void){ fprintf(stderr,"Out of memory...\n"); @@ -243,16 +250,69 @@ cofst = a[cofst]*256 + a[cofst+1]; describeCell(a[0], &a[cofst-hdrSize], &zDesc); printf(" %03x: cell[%d] %s\n", cofst, i, zDesc); } } + +/* +** Decode a freelist trunk page. +*/ +static void decode_trunk_page( + int pgno, /* The page number */ + int pagesize, /* Size of each page */ + int detail, /* Show leaf pages if true */ + int recursive /* Follow the trunk change if true */ +){ + int n, i, k; + unsigned char *a; + while( pgno>0 ){ + a = getContent((pgno-1)*pagesize, pagesize); + printf("Decode of freelist trunk page %d:\n", pgno); + print_decode_line(a, 0, 4, "Next freelist trunk page"); + print_decode_line(a, 4, 4, "Number of entries on this page"); + if( detail ){ + n = (int)decodeInt32(&a[4]); + for(i=0; imxPage ){ fprintf(stderr,