aboutsummaryrefslogtreecommitdiff
path: root/CPP/Common/CksumReg.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CPP/Common/CksumReg.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/CPP/Common/CksumReg.cpp b/CPP/Common/CksumReg.cpp
index 29d9f82..8c9c449 100644
--- a/CPP/Common/CksumReg.cpp
+++ b/CPP/Common/CksumReg.cpp
@@ -7,35 +7,30 @@
7#include "../Common/MyCom.h" 7#include "../Common/MyCom.h"
8 8
9#include "../7zip/Common/RegisterCodec.h" 9#include "../7zip/Common/RegisterCodec.h"
10
11#include "../7zip/Compress/BZip2Crc.h" 10#include "../7zip/Compress/BZip2Crc.h"
12 11
13class CCksumHasher: 12Z7_CLASS_IMP_COM_1(
14 public IHasher, 13 CCksumHasher
15 public CMyUnknownImp 14 , IHasher
16{ 15)
17 CBZip2Crc _crc; 16 CBZip2Crc _crc;
18 UInt64 _size; 17 UInt64 _size;
19 Byte mtDummy[1 << 7];
20
21public: 18public:
19 // Byte _mtDummy[1 << 7];
22 CCksumHasher() 20 CCksumHasher()
23 { 21 {
24 _crc.Init(0); 22 _crc.Init(0);
25 _size = 0; 23 _size = 0;
26 } 24 }
27
28 MY_UNKNOWN_IMP1(IHasher)
29 INTERFACE_IHasher(;)
30}; 25};
31 26
32STDMETHODIMP_(void) CCksumHasher::Init() throw() 27Z7_COM7F_IMF2(void, CCksumHasher::Init())
33{ 28{
34 _crc.Init(0); 29 _crc.Init(0);
35 _size = 0; 30 _size = 0;
36} 31}
37 32
38STDMETHODIMP_(void) CCksumHasher::Update(const void *data, UInt32 size) throw() 33Z7_COM7F_IMF2(void, CCksumHasher::Update(const void *data, UInt32 size))
39{ 34{
40 _size += size; 35 _size += size;
41 CBZip2Crc crc = _crc; 36 CBZip2Crc crc = _crc;
@@ -44,7 +39,7 @@ STDMETHODIMP_(void) CCksumHasher::Update(const void *data, UInt32 size) throw()
44 _crc = crc; 39 _crc = crc;
45} 40}
46 41
47STDMETHODIMP_(void) CCksumHasher::Final(Byte *digest) throw() 42Z7_COM7F_IMF2(void, CCksumHasher::Final(Byte *digest))
48{ 43{
49 UInt64 size = _size; 44 UInt64 size = _size;
50 CBZip2Crc crc = _crc; 45 CBZip2Crc crc = _crc;
@@ -54,7 +49,7 @@ STDMETHODIMP_(void) CCksumHasher::Final(Byte *digest) throw()
54 size >>= 8; 49 size >>= 8;
55 } 50 }
56 const UInt32 val = crc.GetDigest(); 51 const UInt32 val = crc.GetDigest();
57 SetUi32(digest, val); 52 SetUi32(digest, val)
58} 53}
59 54
60REGISTER_HASHER(CCksumHasher, 0x203, "CKSUM", 4) 55REGISTER_HASHER(CCksumHasher, 0x203, "CKSUM", 4)