X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/73545f2ccb49d1bbada4240d1344041ecdc6c0ff..f94e821c782952437d7fe5a2ae1e0b1db8a4f4ab:/checksum.c diff --git a/checksum.c b/checksum.c index 809b09f9..1fd1c55c 100644 --- a/checksum.c +++ b/checksum.c @@ -24,6 +24,7 @@ int csum_length=SUM_LENGTH; #define CSUM_CHUNK 64 int checksum_seed = 0; +extern int remote_version; /* a simple 32 bit checksum that can be upadted from either end @@ -127,6 +128,10 @@ void file_checksum(char *fname,char *sum,off_t size) void checksum_init(void) { + if (remote_version >= 14) + csum_length = 2; /* adaptive */ + else + csum_length = SUM_LENGTH; } @@ -147,6 +152,12 @@ void sum_init(void) void sum_update(char *p,int len) { int i; + if (len + sumresidue < CSUM_CHUNK) { + bcopy(p,sumrbuf+sumresidue,len); + sumresidue += len; + return; + } + if (sumresidue) { i = MIN(CSUM_CHUNK-sumresidue,len); bcopy(p,sumrbuf+sumresidue,i); @@ -180,22 +191,3 @@ void sum_end(char *sum) } -#ifdef CHECKSUM_MAIN - int main(int argc,char *argv[]) -{ - char sum[SUM_LENGTH]; - int i,j; - - checksum_init(); - - for (i=1;i