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/showdb.c | 86 ++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 libraries/sqlite/unix/sqlite-3.5.1/tool/showdb.c (limited to 'libraries/sqlite/unix/sqlite-3.5.1/tool/showdb.c') diff --git a/libraries/sqlite/unix/sqlite-3.5.1/tool/showdb.c b/libraries/sqlite/unix/sqlite-3.5.1/tool/showdb.c new file mode 100644 index 0000000..b2ed562 --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/tool/showdb.c @@ -0,0 +1,86 @@ +/* +** A utility for printing all or part of an SQLite database file. +*/ +#include +#include +#include +#include +#include +#include +#include + + +static int pagesize = 1024; +static int db = -1; +static int mxPage = 0; +static int perLine = 32; + +static void out_of_memory(void){ + fprintf(stderr,"Out of memory...\n"); + exit(1); +} + +static print_page(int iPg){ + unsigned char *aData; + int i, j; + aData = malloc(pagesize); + if( aData==0 ) out_of_memory(); + lseek(db, (iPg-1)*pagesize, SEEK_SET); + read(db, aData, pagesize); + fprintf(stdout, "Page %d:\n", iPg); + for(i=0; imxPage ){ + fprintf(stderr, + "Page argument should be LOWER?..UPPER?. Range 1 to %d\n", + mxPage); + exit(1); + } + while( iStart<=iEnd ){ + print_page(iStart); + iStart++; + } + } + } + close(db); +} -- cgit v1.1