]> git.saurik.com Git - apt.git/blob - apt-pkg/contrib/hashes.cc
* Removed the more leftover #pragma interface/implementation
[apt.git] / apt-pkg / contrib / hashes.cc
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 #include <apt-pkg/hashes.h>
15
16 #include <unistd.h>
17 #include <system.h>
18 /*}}}*/
19
20 // Hashes::AddFD - Add the contents of the FD /*{{{*/
21 // ---------------------------------------------------------------------
22 /* */
23 bool Hashes::AddFD(int Fd,unsigned long Size)
24 {
25 unsigned char Buf[64*64];
26 int Res = 0;
27 while (Size != 0)
28 {
29 Res = read(Fd,Buf,min(Size,(unsigned long)sizeof(Buf)));
30 if (Res < 0 || (unsigned)Res != min(Size,(unsigned long)sizeof(Buf)))
31 return false;
32 Size -= Res;
33 MD5.Add(Buf,Res);
34 SHA1.Add(Buf,Res);
35 SHA256.Add(Buf,Res);
36 }
37 return true;
38 }
39 /*}}}*/
40