summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/hashsum_template.h
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2014-05-07 17:55:10 +0200
committerMichael Vogt <mvo@debian.org>2014-05-07 17:55:10 +0200
commit38d2959ffb8c6f5f291b2910014a67b1b352ab4c (patch)
treec5977b8f34aaf973ed3956952ec3ff43ac59f143 /apt-pkg/contrib/hashsum_template.h
parentfce69e7a0f38299c57ef96ae1c1dd9a5379bfd5a (diff)
parent3fa4e98f62e469f4292d2811b4e15f4afb678fbd (diff)
Merge branch 'debian/sid' into debian/experimental
Conflicts: apt-pkg/cachefilter.h apt-pkg/contrib/fileutl.cc apt-pkg/contrib/netrc.h apt-pkg/deb/debsrcrecords.cc apt-pkg/init.h apt-pkg/pkgcache.cc debian/apt.install.in debian/changelog
Diffstat (limited to 'apt-pkg/contrib/hashsum_template.h')
-rw-r--r--apt-pkg/contrib/hashsum_template.h52
1 files changed, 28 insertions, 24 deletions
diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h
index 9bf160b2b..869dc5cb7 100644
--- a/apt-pkg/contrib/hashsum_template.h
+++ b/apt-pkg/contrib/hashsum_template.h
@@ -10,36 +10,40 @@
#ifndef APTPKG_HASHSUM_TEMPLATE_H
#define APTPKG_HASHSUM_TEMPLATE_H
-#include <apt-pkg/fileutl.h>
#include <string>
#include <cstring>
-#include <algorithm>
-#include <stdint.h>
#include <apt-pkg/strutl.h>
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/fileutl.h>
+#include <algorithm>
+#include <stdint.h>
+#endif
#ifndef APT_8_CLEANER_HEADERS
using std::string;
using std::min;
#endif
+class FileFd;
+
template<int N>
class HashSumValue
{
unsigned char Sum[N/8];
-
+
public:
// Accessors
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;
- };
+ }
std::string Value() const
{
@@ -49,7 +53,7 @@ class HashSumValue
};
char Result[((N/8)*2)+1];
Result[(N/8)*2] = 0;
-
+
// Convert each char into two letters
int J = 0;
int I = 0;
@@ -59,31 +63,31 @@ class HashSumValue
Result[I + 1] = Conv[Sum[J] & 0xF];
}
return std::string(Result);
- };
-
+ }
+
inline void Value(unsigned char S[N/8])
{
- for (int I = 0; I != sizeof(Sum); I++)
+ for (int I = 0; I != sizeof(Sum); ++I)
S[I] = Sum[I];
- };
+ }
- inline operator std::string() const
+ inline operator std::string() const
{
return Value();
- };
+ }
- bool Set(std::string Str)
+ bool Set(std::string Str)
{
return Hex2Num(Str,Sum,sizeof(Sum));
- };
+ }
- inline void Set(unsigned char S[N/8])
+ inline void Set(unsigned char S[N/8])
{
- for (int I = 0; I != sizeof(Sum); I++)
+ for (int I = 0; I != sizeof(Sum); ++I)
Sum[I] = S[I];
- };
+ }
- HashSumValue(std::string Str)
+ HashSumValue(std::string Str)
{
memset(Sum,0,sizeof(Sum));
Set(Str);
@@ -99,17 +103,17 @@ class SummationImplementation
public:
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); };
+ { return Add((const unsigned char *)inbuf, inlen); }
inline bool Add(const unsigned char *Data)
- { return Add(Data, strlen((const char *)Data)); };
+ { return Add(Data, strlen((const char *)Data)); }
inline bool Add(const char *Data)
- { return Add((const unsigned char *)Data, strlen((const char *)Data)); };
+ { return Add((const unsigned char *)Data, strlen(Data)); }
inline bool Add(const unsigned char *Beg, const unsigned char *End)
- { return Add(Beg, End - Beg); };
+ { return Add(Beg, End - Beg); }
inline bool Add(const char *Beg, const char *End)
- { return Add((const unsigned char *)Beg, End - Beg); };
+ { return Add((const unsigned char *)Beg, End - Beg); }
bool AddFD(int Fd, unsigned long long Size = 0);
bool AddFD(FileFd &Fd, unsigned long long Size = 0);