Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
z_digest.cpp
Go to the documentation of this file.
1 #include <xstream/config.h>
2 #include <xstream/digest.h>
3 
4 #include "debug.h"
5 
6 #if HAVE_LIBZ
7 
8 //for adler32 and crc32
9 #include <zlib.h>
10 
11 
12 namespace xstream{
13 namespace digest{
14 
15  ////////////////////////////////
16  /////// Adler32 digest /////////
17  ////////////////////////////////
18 
19  static const size_t buffer_size = 4000 * 1024;
20  typedef unsigned long int uli;
21 
22  z_common::z_common()
23  : common<uli>(buffer_size), _digest(0)
24  {
25  LOG("digest::z_common");
26  }
27 
28  unsigned long int z_common::digest()
29  {
30  LOG("digest::z_common::digest");
31  return _digest;
32  }
33 
34  void z_common::reset_digest()
35  {
36  _digest=0;
37  }
38 
39  void adler32::calculate_digest()
40  {
41  LOG("digest::adler32::calculate_digest");
42  _digest = ::adler32(_digest, reinterpret_cast<Bytef*>(pbase()), taken());
43  LOG("\tdigest = " << _digest);
44  }
45 
46  //////////////////////////////
47  /////// CRC32 digest /////////
48  //////////////////////////////
49 
50 
51  void crc32::calculate_digest()
52  {
53  LOG("digest::crc32::calculate_digest");
54  _digest = ::crc32(_digest, reinterpret_cast<Bytef*>(pbase()), taken());
55  LOG("\tdigest = " << _digest);
56  }
57 
58  }//namespace digest
59 }//namespace xstream
60 
61 
62 #endif
debugging/logging support
C++ objects to calculate digests of data.
static const size_t buffer_size
Definition: common.cpp:8
#define LOG(s)
Definition: debug.h:30