summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/hashes.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-07-13 23:10:38 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-07-13 23:10:38 +0200
commit1dab797ca6dc0357474675a0f132c962dee4a2c2 (patch)
treef2b6a5fbef520da33a48b9f769511e0c85082c04 /apt-pkg/contrib/hashes.cc
parent96c9fb174df24fadcde516f26f89d1a64f42eea7 (diff)
enable Hashes::AddFD() to skip creation of certain hashes
Diffstat (limited to 'apt-pkg/contrib/hashes.cc')
-rw-r--r--apt-pkg/contrib/hashes.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index 66ae33146..d217747df 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -107,7 +107,8 @@ string HashString::toStr() const
// Hashes::AddFD - Add the contents of the FD /*{{{*/
// ---------------------------------------------------------------------
/* */
-bool Hashes::AddFD(int Fd,unsigned long Size)
+bool Hashes::AddFD(int const Fd,unsigned long Size, bool const addMD5,
+ bool const addSHA1, bool const addSHA256, bool const addSHA512)
{
unsigned char Buf[64*64];
int Res = 0;
@@ -118,14 +119,18 @@ bool Hashes::AddFD(int Fd,unsigned long Size)
if (!ToEOF) n = min(Size,(unsigned long)n);
Res = read(Fd,Buf,n);
if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read
- return false;
+ return false;
if (ToEOF && Res == 0) // EOF
- break;
+ break;
Size -= Res;
- MD5.Add(Buf,Res);
- SHA1.Add(Buf,Res);
- SHA256.Add(Buf,Res);
- SHA512.Add(Buf,Res);
+ if (addMD5 == true)
+ MD5.Add(Buf,Res);
+ if (addSHA1 == true)
+ SHA1.Add(Buf,Res);
+ if (addSHA256 == true)
+ SHA256.Add(Buf,Res);
+ if (addSHA512 == true)
+ SHA512.Add(Buf,Res);
}
return true;
}