1
2 #pragma ident "%Z%%M% %I% %E% SMI"
3
4 /*
5 ** A utility for printing the differences between two SQLite database files.
6 */
7 #include <stdio.h>
8 #include <ctype.h>
9 #include <sys/types.h>
10 #include <sys/stat.h>
11 #include <fcntl.h>
12 #include <unistd.h>
13 #include <stdlib.h>
14
15
16 #define PAGESIZE 1024
17 static int db1 = -1;
18 static int db2 = -1;
19
main(int argc,char ** argv)20 int main(int argc, char **argv){
21 int iPg;
22 unsigned char a1[PAGESIZE], a2[PAGESIZE];
23 if( argc!=3 ){
24 fprintf(stderr,"Usage: %s FILENAME FILENAME\n", argv[0]);
25 exit(1);
26 }
27 db1 = open(argv[1], O_RDONLY);
28 if( db1<0 ){
29 fprintf(stderr,"%s: can't open %s\n", argv[0], argv[1]);
30 exit(1);
31 }
32 db2 = open(argv[2], O_RDONLY);
33 if( db2<0 ){
34 fprintf(stderr,"%s: can't open %s\n", argv[0], argv[2]);
35 exit(1);
36 }
37 iPg = 1;
38 while( read(db1, a1, PAGESIZE)==PAGESIZE && read(db2,a2,PAGESIZE)==PAGESIZE ){
39 if( memcmp(a1,a2,PAGESIZE) ){
40 printf("Page %d\n", iPg);
41 }
42 iPg++;
43 }
44 printf("%d pages checked\n", iPg-1);
45 close(db1);
46 close(db2);
47 }
48