X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/1dab797ca6dc0357474675a0f132c962dee4a2c2..32ed73df439850ee47e5e5edb8bfe1fe647ed794:/apt-pkg/contrib/hashsum_template.h diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h index 85d94c2af..9bf160b2b 100644 --- a/apt-pkg/contrib/hashsum_template.h +++ b/apt-pkg/contrib/hashsum_template.h @@ -10,13 +10,19 @@ #ifndef APTPKG_HASHSUM_TEMPLATE_H #define APTPKG_HASHSUM_TEMPLATE_H +#include + #include #include #include #include +#include + +#ifndef APT_8_CLEANER_HEADERS using std::string; using std::min; +#endif template class HashSumValue @@ -29,9 +35,13 @@ class HashSumValue bool operator ==(const HashSumValue &rhs) const { return memcmp(Sum,rhs.Sum,sizeof(Sum)) == 0; - }; + }; + bool operator !=(const HashSumValue &rhs) const + { + return memcmp(Sum,rhs.Sum,sizeof(Sum)) != 0; + }; - string Value() const + std::string Value() const { char Conv[16] = { '0','1','2','3','4','5','6','7','8','9','a','b', @@ -48,7 +58,7 @@ class HashSumValue Result[I] = Conv[Sum[J] >> 4]; Result[I + 1] = Conv[Sum[J] & 0xF]; } - return string(Result); + return std::string(Result); }; inline void Value(unsigned char S[N/8]) @@ -57,12 +67,12 @@ class HashSumValue S[I] = Sum[I]; }; - inline operator string() const + inline operator std::string() const { return Value(); }; - bool Set(string Str) + bool Set(std::string Str) { return Hex2Num(Str,Sum,sizeof(Sum)); }; @@ -73,7 +83,7 @@ class HashSumValue Sum[I] = S[I]; }; - HashSumValue(string Str) + HashSumValue(std::string Str) { memset(Sum,0,sizeof(Sum)); Set(Str); @@ -87,8 +97,8 @@ class HashSumValue class SummationImplementation { public: - virtual bool Add(const unsigned char *inbuf, unsigned long inlen) = 0; - inline bool Add(const char *inbuf, unsigned long const inlen) + virtual bool Add(const unsigned char *inbuf, unsigned long long inlen) = 0; + inline bool Add(const char *inbuf, unsigned long long const inlen) { return Add((unsigned char *)inbuf, inlen); }; inline bool Add(const unsigned char *Data) @@ -101,7 +111,8 @@ class SummationImplementation inline bool Add(const char *Beg, const char *End) { return Add((const unsigned char *)Beg, End - Beg); }; - bool AddFD(int Fd, unsigned long Size = 0); + bool AddFD(int Fd, unsigned long long Size = 0); + bool AddFD(FileFd &Fd, unsigned long long Size = 0); }; #endif