projects
/
apt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
test framework: Correctly generate new paths in noopchroot
[apt.git]
/
apt-pkg
/
contrib
/
hashsum_template.h
diff --git
a/apt-pkg/contrib/hashsum_template.h
b/apt-pkg/contrib/hashsum_template.h
index 85d94c2afafdd6df9990df20b7a9d53a4eb936e1..d0ea0971ea5e2502e92ef18845789604765836fa 100644
(file)
--- a/
apt-pkg/contrib/hashsum_template.h
+++ b/
apt-pkg/contrib/hashsum_template.h
@@
-10,28
+10,42
@@
#ifndef APTPKG_HASHSUM_TEMPLATE_H
#define APTPKG_HASHSUM_TEMPLATE_H
#ifndef APTPKG_HASHSUM_TEMPLATE_H
#define APTPKG_HASHSUM_TEMPLATE_H
+
#include <string>
#include <cstring>
#include <string>
#include <cstring>
+
+#include <apt-pkg/strutl.h>
+
+#ifndef APT_10_CLEANER_HEADERS
+#include <apt-pkg/fileutl.h>
#include <algorithm>
#include <stdint.h>
#include <algorithm>
#include <stdint.h>
-
+#endif
+#ifndef APT_8_CLEANER_HEADERS
using std::string;
using std::min;
using std::string;
using std::min;
+#endif
+
+class FileFd;
template<int N>
class HashSumValue
{
unsigned char Sum[N/8];
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;
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;
+ }
- string Value() const
+ st
d::st
ring Value() const
{
char Conv[16] =
{ '0','1','2','3','4','5','6','7','8','9','a','b',
{
char Conv[16] =
{ '0','1','2','3','4','5','6','7','8','9','a','b',
@@
-39,7
+53,7
@@
class HashSumValue
};
char Result[((N/8)*2)+1];
Result[(N/8)*2] = 0;
};
char Result[((N/8)*2)+1];
Result[(N/8)*2] = 0;
-
+
// Convert each char into two letters
int J = 0;
int I = 0;
// Convert each char into two letters
int J = 0;
int I = 0;
@@
-48,32
+62,32
@@
class HashSumValue
Result[I] = Conv[Sum[J] >> 4];
Result[I + 1] = Conv[Sum[J] & 0xF];
}
Result[I] = Conv[Sum[J] >> 4];
Result[I + 1] = Conv[Sum[J] & 0xF];
}
- return string(Result);
- }
;
-
+ return st
d::st
ring(Result);
+ }
+
inline void Value(unsigned char S[N/8])
{
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];
S[I] = Sum[I];
- }
;
+ }
- inline operator st
ring() const
+ inline operator st
d::string() const
{
return Value();
{
return Value();
- }
;
+ }
- bool Set(st
ring Str)
+ bool Set(st
d::string Str)
{
return Hex2Num(Str,Sum,sizeof(Sum));
{
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];
Sum[I] = S[I];
- }
;
+ }
- HashSumValue(string Str)
+ explicit HashSumValue(std::string const &Str)
{
memset(Sum,0,sizeof(Sum));
Set(Str);
{
memset(Sum,0,sizeof(Sum));
Set(Str);
@@
-87,21
+101,22
@@
class HashSumValue
class SummationImplementation
{
public:
class SummationImplementation
{
public:
- virtual bool Add(const unsigned char *inbuf, unsigned long inlen) = 0;
- inline bool Add(const char *inbuf, unsigned long const inlen)
- { return Add((
unsigned char *)inbuf, 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((
const unsigned char *)inbuf, inlen); }
inline bool Add(const unsigned char *Data)
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)
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)
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)
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 Size = 0);
+ bool AddFD(int Fd, unsigned long long Size = 0);
+ bool AddFD(FileFd &Fd, unsigned long long Size = 0);
};
#endif
};
#endif