Update mojo sdk to rev 1dc8a9a5db73d3718d99917fadf31f5fb2ebad4f
[chromium-blink-merge.git] / third_party / sqlite / sqlite-src-3080704 / tool / diffdb.c
blob0537d38723e6622ca13e47f036c72a1924fb4c77
1 /*
2 ** A utility for printing the differences between two SQLite database files.
3 */
4 #include <stdio.h>
5 #include <ctype.h>
6 #include <sys/types.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9 #include <unistd.h>
10 #include <stdlib.h>
13 #define PAGESIZE 1024
14 static int db1 = -1;
15 static int db2 = -1;
17 int main(int argc, char **argv){
18 int iPg;
19 unsigned char a1[PAGESIZE], a2[PAGESIZE];
20 if( argc!=3 ){
21 fprintf(stderr,"Usage: %s FILENAME FILENAME\n", argv[0]);
22 exit(1);
24 db1 = open(argv[1], O_RDONLY);
25 if( db1<0 ){
26 fprintf(stderr,"%s: can't open %s\n", argv[0], argv[1]);
27 exit(1);
29 db2 = open(argv[2], O_RDONLY);
30 if( db2<0 ){
31 fprintf(stderr,"%s: can't open %s\n", argv[0], argv[2]);
32 exit(1);
34 iPg = 1;
35 while( read(db1, a1, PAGESIZE)==PAGESIZE && read(db2,a2,PAGESIZE)==PAGESIZE ){
36 if( memcmp(a1,a2,PAGESIZE) ){
37 printf("Page %d\n", iPg);
39 iPg++;
41 printf("%d pages checked\n", iPg-1);
42 close(db1);
43 close(db2);