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(
reinterpret_cast<const char*
>(
buf) + start, len);
389 dig.update(
reinterpret_cast<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)
445 DBG <<
"Delta XFER: Can not reuse blocks because we have no chksumlen" << std::endl;
449 if ( (
fp =
fopen(filename.c_str(),
"r")) == 0 ) {
450 DBG <<
"Delta XFER: Can not reuse blocks, unable to open file "<< filename << std::endl;
466 for ( std::size_t
i = 0;
i <
rsums.size();
i++ ) {
468 unsigned short s = 0,
m = 0;
469 s = (
rs >> 16) & 65535;
475 const auto &
calc_rhash = [&](
const rsum*
e ) ->
unsigned {
487 size_t blksize =
blocks[0].size;
498 while ((2U << (
i - 1)) >
nblks &&
i > 4)
510 for (
size_t id = 0;
id <
nblks;
id++) {
537 if ((blksize & (blksize - 1)) == 0)
556 for (
const auto blkno : list ) {
692 const auto blkOff = (
i*blksize );
706 auto buf = std::make_unique<unsigned char[]>(
bufl );
715 buf = std::make_unique<unsigned char[]>(
bufl );
734 DBG <<
"Delta XFER: No reusable blocks found for " << filename << std::endl;
738 std::vector<MediaBlock>
nblocks;
739 std::vector<unsigned char>
nchksums;
740 std::vector<unsigned int>
nrsums;
762 DBG <<
"Delta XFER: Found blocks to reuse, " <<
blocks.size() <<
" vs " <<
nblocks.size() <<
", resused blocks: " <<
blocks.size() -
nblocks.size() <<
"\n"
775 DBG <<
"Delta XFER: Can not reuse blocks because we have no chksumlen" << std::endl;
779 if ( (
fp =
fopen(filename.c_str(),
"r")) == 0 ) {
780 DBG <<
"Delta XFER: Can not reuse blocks, unable to open file "<< filename << std::endl;
784 std::vector<bool>
found;
788 size_t blksize =
blocks[0].size;
797 unsigned int hm =
rsums.size() * 2;
798 while (
hm & (
hm - 1)) {
812 for (
unsigned int i = 0;
i <
rsums.size();
i++)
817 unsigned int h =
r &
hm;
830 auto ringBuf = std::make_unique<unsigned char[]>( blksize );
833 auto buf2 = std::make_unique<unsigned char[]>( blksize );
844 if ((blksize & (blksize - 1)) == 0)
851 unsigned short a = 0,
b = 0;
862 for (
size_t i = 0;
i < blksize;
i++)
909 if (
size_t(
i) != blksize - 1)
914 unsigned int r = ((
unsigned int)
a & 65535) << 16 | ((
unsigned int)
b & 65535);
917 unsigned int h =
r &
hm;
998 auto buf = std::make_unique<unsigned char[]>(
bufl );
1007 buf = std::make_unique<unsigned char[]>(
bufl );
1026 DBG <<
"Delta XFER: No reusable blocks found for " << filename << std::endl;
1030 std::vector<MediaBlock>
nblocks;
1031 std::vector<unsigned char>
nchksums;
1032 std::vector<unsigned int>
nrsums;
1054 DBG <<
"Delta XFER: Found blocks to reuse, " <<
blocks.size() <<
" vs " <<
nblocks.size() <<
", resused blocks: " <<
blocks.size() -
nblocks.size() <<
"\n"
1065 size_t i = 0,
j = 0;
1073 s =
"[ BlockList, filesize unknown\n";
1075 s +=
" No block information\n";
1083 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