2 ** A utility for printing an SQLite database journal.
13 static int pagesize
= 1024;
15 static int mxPage
= 0;
17 static void out_of_memory(void){
18 fprintf(stderr
,"Out of memory...\n");
22 static print_page(int iPg
){
25 aData
= malloc(pagesize
);
26 if( aData
==0 ) out_of_memory();
27 read(db
, aData
, pagesize
);
28 fprintf(stdout
, "Page %d:\n", iPg
);
29 for(i
=0; i
<pagesize
; i
+= 16){
30 fprintf(stdout
, " %03x: ",i
);
32 fprintf(stdout
,"%02x ", aData
[i
+j
]);
35 fprintf(stdout
,"%c", isprint(aData
[i
+j
]) ? aData
[i
+j
] : '.');
42 int main(int argc
, char **argv
){
46 unsigned char zBuf
[10];
47 unsigned char zBuf2
[sizeof(u
)];
49 fprintf(stderr
,"Usage: %s FILENAME\n", argv
[0]);
52 db
= open(argv
[1], O_RDONLY
);
54 fprintf(stderr
,"%s: can't open %s\n", argv
[0], argv
[1]);
59 read(db
, &u
, sizeof(u
));
60 printf("Records in Journal: %u\n", u
);
61 read(db
, &u
, sizeof(u
));
62 printf("Magic Number: 0x%08x\n", u
);
64 read(db
, zBuf2
, sizeof(zBuf2
));
65 u
= zBuf2
[0]<<24 | zBuf2
[1]<<16 | zBuf2
[2]<<8 | zBuf2
[3];
66 printf("Database Size: %u\n", u
);
67 while( read(db
, zBuf2
, sizeof(zBuf2
))==sizeof(zBuf2
) ){
68 u
= zBuf2
[0]<<24 | zBuf2
[1]<<16 | zBuf2
[2]<<8 | zBuf2
[3];
71 read(db
, &u
, sizeof(u
));
72 printf("Checksum: 0x%08x\n", u
);