103#include <sys/types.h>
126 unsigned short a = 0;
127 unsigned short b = 0;
133 unsigned short a = 0;
134 unsigned short b = 0;
137 unsigned char c = *data++;
146 #define UPDATE_RSUM(a, b, oldc, newc, bshift) do { (a) += ((unsigned char)(newc)) - ((unsigned char)(oldc)); (b) += (a) - ((oldc) << (bshift)); } while (0)
301 unsigned short s = 0,
m = 0;
302 s = (
rs >> 16) & 65535;
304 for (; len > 0 ; len--)
306 unsigned short c = (
unsigned char)*
bytes++;
310 return (
s & 65535) << 16 | (
m & 65535);
323 unsigned short s = 0,
m = 0;
324 s = (
rs >> 16) & 65535;
327 rs = (
s & 65535) << 16 | (
m & 65535);
386 size_t len =
bufl - start > size ? size :
bufl - start;
387 dig.update((
const char *)
buf + start, len);
389 dig.update((
const char *)
buf, size - len);
405 size_t len =
bufl - start > size ? size :
bufl - start;
408 if (size > len &&
fwrite(
buf, size - len, 1,
fp) != 1)
446 DBG <<
"Delta XFER: Can not reuse blocks because we have no chksumlen" << std::endl;
450 if ( (
fp =
fopen(filename.c_str(),
"r")) == 0 ) {
451 DBG <<
"Delta XFER: Can not reuse blocks, unable to open file "<< filename << std::endl;
467 for ( std::size_t
i = 0;
i <
rsums.size();
i++ ) {
469 unsigned short s = 0,
m = 0;
470 s = (
rs >> 16) & 65535;
476 const auto &
calc_rhash = [&](
const rsum*
e ) ->
unsigned {
488 size_t blksize =
blocks[0].size;
499 while ((2 << (
i - 1)) >
nblks &&
i > 4)
511 for (
size_t id = 0;
id <
nblks;
id++) {
538 if ((blksize & (blksize - 1)) == 0)
557 for (
const auto blkno : list ) {
693 const auto blkOff = (
i*blksize );
707 auto buf = std::make_unique<unsigned char[]>(
bufl );
716 buf = std::make_unique<unsigned char[]>(
bufl );
735 DBG <<
"Delta XFER: No reusable blocks found for " << filename << std::endl;
739 std::vector<MediaBlock>
nblocks;
740 std::vector<unsigned char>
nchksums;
741 std::vector<unsigned int>
nrsums;
763 DBG <<
"Delta XFER: Found blocks to reuse, " <<
blocks.size() <<
" vs " <<
nblocks.size() <<
", resused blocks: " <<
blocks.size() -
nblocks.size() <<
"\n"
776 DBG <<
"Delta XFER: Can not reuse blocks because we have no chksumlen" << std::endl;
780 if ( (
fp =
fopen(filename.c_str(),
"r")) == 0 ) {
781 DBG <<
"Delta XFER: Can not reuse blocks, unable to open file "<< filename << std::endl;
785 std::vector<bool>
found;
789 size_t blksize =
blocks[0].size;
798 unsigned int hm =
rsums.size() * 2;
799 while (
hm & (
hm - 1)) {
813 for (
unsigned int i = 0;
i <
rsums.size();
i++)
818 unsigned int h =
r &
hm;
831 auto ringBuf = std::make_unique<unsigned char[]>( blksize );
834 auto buf2 = std::make_unique<unsigned char[]>( blksize );
845 if ((blksize & (blksize - 1)) == 0)
852 unsigned short a = 0,
b = 0;
863 for (
size_t i = 0;
i < blksize;
i++)
910 if (
size_t(
i) != blksize - 1)
915 unsigned int r = ((
unsigned int)
a & 65535) << 16 | ((
unsigned int)
b & 65535);
918 unsigned int h =
r &
hm;
999 auto buf = std::make_unique<unsigned char[]>(
bufl );
1008 buf = std::make_unique<unsigned char[]>(
bufl );
1027 DBG <<
"Delta XFER: No reusable blocks found for " << filename << std::endl;
1031 std::vector<MediaBlock>
nblocks;
1032 std::vector<unsigned char>
nchksums;
1033 std::vector<unsigned int>
nrsums;
1055 DBG <<
"Delta XFER: Found blocks to reuse, " <<
blocks.size() <<
" vs " <<
nblocks.size() <<
", resused blocks: " <<
blocks.size() -
nblocks.size() <<
"\n"
1066 size_t i = 0,
j = 0;
1074 s =
"[ BlockList, filesize unknown\n";
1076 s +=
" No block information\n";
1084 long long size=
blocks[
i].size;
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
void reset()
Reset to default Ctor values.
Compute Message Digests (MD5, SHA1 etc)
UByteArray digestVector()
get vector of unsigned char representation of the digest
bool update(const char *bytes, size_t len)
feed data into digest computation algorithm
bool create(const std::string &name)
initialize creation of a new message digest
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
Easy-to use interface to the ZYPP dependency resolver.
AutoDispose<FILE*> calling ::fclose