]>
Commit | Line | Data |
---|---|---|
63b1700f AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
3 | // $Id: hashes.cc,v 1.1 2001/03/06 07:15:29 jgg Exp $ | |
4 | /* ###################################################################### | |
5 | ||
6 | Hashes - Simple wrapper around the hash functions | |
7 | ||
8 | This is just used to make building the methods simpler, this is the | |
9 | only interface required.. | |
10 | ||
11 | ##################################################################### */ | |
12 | /*}}}*/ | |
13 | // Include Files /*{{{*/ | |
14 | #ifdef __GNUG__ | |
15 | #pragma implementation "apt-pkg/hashes.h" | |
16 | #endif | |
17 | ||
18 | #include <apt-pkg/hashes.h> | |
19 | ||
20 | #include <unistd.h> | |
21 | #include <system.h> | |
22 | /*}}}*/ | |
23 | ||
24 | // Hashes::AddFD - Add the contents of the FD /*{{{*/ | |
25 | // --------------------------------------------------------------------- | |
26 | /* */ | |
27 | bool Hashes::AddFD(int Fd,unsigned long Size) | |
28 | { | |
29 | unsigned char Buf[64*64]; | |
30 | int Res = 0; | |
31 | while (Size != 0) | |
32 | { | |
42ab8223 MV |
33 | Res = read(Fd,Buf,min(Size,(unsigned long)sizeof(Buf))); |
34 | if (Res < 0 || (unsigned)Res != min(Size,(unsigned long)sizeof(Buf))) | |
63b1700f AL |
35 | return false; |
36 | Size -= Res; | |
37 | MD5.Add(Buf,Res); | |
38 | SHA1.Add(Buf,Res); | |
cde41ae8 | 39 | SHA256.Add(Buf,Res); |
63b1700f AL |
40 | } |
41 | return true; | |
42 | } | |
43 | /*}}}*/ | |
44 |