6 #ifndef CRYPTOPP_ZINFLATE_H
7 #define CRYPTOPP_ZINFLATE_H
21 : m_store(store), m_buffer(0), m_bitsBuffered(0) {}
22 unsigned int BitsBuffered()
const {
return m_bitsBuffered;}
23 unsigned long PeekBuffer()
const {
return m_buffer;}
24 bool FillBuffer(
unsigned int length);
25 unsigned long PeekBits(
unsigned int length);
26 void SkipBits(
unsigned int length);
27 unsigned long GetBits(
unsigned int length);
31 unsigned long m_buffer;
32 unsigned int m_bitsBuffered;
42 typedef unsigned int code_t;
43 typedef unsigned int value_t;
44 enum {MAX_CODE_BITS =
sizeof(code_t)*8};
48 HuffmanDecoder() : m_maxCodeBits(0), m_cacheBits(0), m_cacheMask(0), m_normalizedCacheMask(0) {}
49 HuffmanDecoder(
const unsigned int *codeBitLengths,
unsigned int nCodes)
50 : m_maxCodeBits(0), m_cacheBits(0), m_cacheMask(0), m_normalizedCacheMask(0)
51 {Initialize(codeBitLengths, nCodes);}
53 void Initialize(
const unsigned int *codeBitLengths,
unsigned int nCodes);
54 unsigned int Decode(code_t code, value_t &value)
const;
62 CodeInfo(code_t code=0,
unsigned int len=0, value_t value=0) : code(code), len(len), value(value) {}
63 inline bool operator<(
const CodeInfo &rhs)
const {
return code < rhs.code;}
75 const CodeInfo *begin;
84 static code_t NormalizeCode(code_t code,
unsigned int codeBits);
85 void FillCacheEntry(LookupEntry &entry, code_t normalizedCode)
const;
87 unsigned int m_maxCodeBits, m_cacheBits, m_cacheMask, m_normalizedCacheMask;
88 std::vector<CodeInfo, AllocatorWithCleanup<CodeInfo> > m_codeToValue;
89 mutable std::vector<LookupEntry, AllocatorWithCleanup<LookupEntry> > m_cache;
117 size_t Put2(
const byte *inString,
size_t length,
int messageEnd,
bool blocking);
120 virtual unsigned int GetLog2WindowSize()
const {
return 15;}
126 virtual unsigned int MaxPrestreamHeaderSize()
const {
return 0;}
127 virtual void ProcessPrestreamHeader() {}
128 virtual void ProcessDecompressedData(
const byte *
string,
size_t length)
130 virtual unsigned int MaxPoststreamTailSize()
const {
return 0;}
131 virtual void ProcessPoststreamTail() {}
133 void ProcessInput(
bool flush);
137 void OutputByte(
byte b);
138 void OutputString(
const byte *
string,
size_t length);
139 void OutputPast(
unsigned int length,
unsigned int distance);
141 void CreateFixedDistanceDecoder();
142 void CreateFixedLiteralDecoder();
147 enum State {PRE_STREAM, WAIT_HEADER, DECODING_BODY, POST_STREAM, AFTER_END};
149 bool m_repeat, m_eof, m_wrappedAround;
152 enum NextDecode {LITERAL, LENGTH_BITS, DISTANCE, DISTANCE_BITS};
153 NextDecode m_nextDecode;
154 unsigned int m_literal, m_distance;
159 size_t m_current, m_lastFlush;