From e36d23a85ebff914d74bb541558c2b6082b78edb Mon Sep 17 00:00:00 2001 From: dan miller Date: Sat, 20 Oct 2007 02:49:29 +0000 Subject: sqlite source (unix build) added to libraries --- libraries/sqlite/unix/sqlite-3.5.1/tool/diffdb.c | 44 ++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 libraries/sqlite/unix/sqlite-3.5.1/tool/diffdb.c (limited to 'libraries/sqlite/unix/sqlite-3.5.1/tool/diffdb.c') diff --git a/libraries/sqlite/unix/sqlite-3.5.1/tool/diffdb.c b/libraries/sqlite/unix/sqlite-3.5.1/tool/diffdb.c new file mode 100644 index 0000000..0537d38 --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/tool/diffdb.c @@ -0,0 +1,44 @@ +/* +** A utility for printing the differences between two SQLite database files. +*/ +#include +#include +#include +#include +#include +#include +#include + + +#define PAGESIZE 1024 +static int db1 = -1; +static int db2 = -1; + +int main(int argc, char **argv){ + int iPg; + unsigned char a1[PAGESIZE], a2[PAGESIZE]; + if( argc!=3 ){ + fprintf(stderr,"Usage: %s FILENAME FILENAME\n", argv[0]); + exit(1); + } + db1 = open(argv[1], O_RDONLY); + if( db1<0 ){ + fprintf(stderr,"%s: can't open %s\n", argv[0], argv[1]); + exit(1); + } + db2 = open(argv[2], O_RDONLY); + if( db2<0 ){ + fprintf(stderr,"%s: can't open %s\n", argv[0], argv[2]); + exit(1); + } + iPg = 1; + while( read(db1, a1, PAGESIZE)==PAGESIZE && read(db2,a2,PAGESIZE)==PAGESIZE ){ + if( memcmp(a1,a2,PAGESIZE) ){ + printf("Page %d\n", iPg); + } + iPg++; + } + printf("%d pages checked\n", iPg-1); + close(db1); + close(db2); +} -- cgit v1.1