summaryrefslogtreecommitdiff
path: root/components/external/SQLite-3.8.1/tool/diffdb.c
diff options
context:
space:
mode:
authorgeniusgogo <[email protected]>2013-11-13 22:27:45 +0800
committergeniusgogo <[email protected]>2013-11-30 14:59:51 +0800
commita186d329a47ebe7f4a2481016407898028454fde (patch)
treee983ff6d38238b55ac442aeaa7919a92b7d093ec /components/external/SQLite-3.8.1/tool/diffdb.c
parent0347f8ab9c75f17d89d7f565f6a398dcbf0f700b (diff)
add SQLite-3.8.1 authority original source tree
Diffstat (limited to 'components/external/SQLite-3.8.1/tool/diffdb.c')
-rw-r--r--components/external/SQLite-3.8.1/tool/diffdb.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/components/external/SQLite-3.8.1/tool/diffdb.c b/components/external/SQLite-3.8.1/tool/diffdb.c
new file mode 100644
index 0000000000..0537d38723
--- /dev/null
+++ b/components/external/SQLite-3.8.1/tool/diffdb.c
@@ -0,0 +1,44 @@
+/*
+** A utility for printing the differences between two SQLite database files.
+*/
+#include <stdio.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+
+#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);
+}