diff options
author | drh <drh@noemail.net> | 2017-07-30 19:50:42 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2017-07-30 19:50:42 +0000 |
commit | ea2844f153e356af985ad35ee050184cb9049b60 (patch) | |
tree | 9ff85c6f39ae20e436f6ca546be790dfd70a269b /src/tclsqlite.c | |
parent | df94966c8b98abfa36fc76174b8cb5683a1921fc (diff) | |
download | sqlite-ea2844f153e356af985ad35ee050184cb9049b60.tar.gz sqlite-ea2844f153e356af985ad35ee050184cb9049b60.zip |
Add the schema6.test module for demonstrating schemas that generate identical
and different content.
FossilOrigin-Name: ac1da06a829051d393ccb8bb986e78f5bd35b060687688f6b3661913b13c9a5a
Diffstat (limited to 'src/tclsqlite.c')
-rw-r--r-- | src/tclsqlite.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/tclsqlite.c b/src/tclsqlite.c index 341d3f0dc..1b9f91405 100644 --- a/src/tclsqlite.c +++ b/src/tclsqlite.c @@ -3882,28 +3882,39 @@ static int SQLITE_TCLAPI md5file_cmd( const char **argv ){ FILE *in; + int ofst; + int amt; MD5Context ctx; void (*converter)(unsigned char*, char*); unsigned char digest[16]; char zBuf[10240]; - if( argc!=2 ){ + if( argc!=2 && argc!=4 ){ Tcl_AppendResult(interp,"wrong # args: should be \"", argv[0], - " FILENAME\"", (char*)0); + " FILENAME [OFFSET AMT]\"", (char*)0); return TCL_ERROR; } + if( argc==4 ){ + ofst = atoi(argv[2]); + amt = atoi(argv[3]); + }else{ + ofst = 0; + amt = 2147483647; + } in = fopen(argv[1],"rb"); if( in==0 ){ Tcl_AppendResult(interp,"unable to open file \"", argv[1], "\" for reading", (char*)0); return TCL_ERROR; } + fseek(in, ofst, SEEK_SET); MD5Init(&ctx); - for(;;){ + while( amt>0 ){ int n; - n = (int)fread(zBuf, 1, sizeof(zBuf), in); + n = (int)fread(zBuf, 1, sizeof(zBuf)<=amt ? sizeof(zBuf) : amt, in); if( n<=0 ) break; MD5Update(&ctx, (unsigned char*)zBuf, (unsigned)n); + amt -= n; } fclose(in); MD5Final(digest, &ctx); |