1 #ifndef CRYPTOPP_ZINFLATE_H
2 #define CRYPTOPP_ZINFLATE_H
7 NAMESPACE_BEGIN(CryptoPP)
14 : m_store(store), m_buffer(0), m_bitsBuffered(0) {}
16 unsigned int BitsBuffered()
const {
return m_bitsBuffered;}
17 unsigned long PeekBuffer()
const {
return m_buffer;}
18 bool FillBuffer(
unsigned int length);
19 unsigned long PeekBits(
unsigned int length);
20 void SkipBits(
unsigned int length);
21 unsigned long GetBits(
unsigned int length);
25 unsigned long m_buffer;
26 unsigned int m_bitsBuffered;
35 typedef unsigned int code_t;
36 typedef unsigned int value_t;
37 enum {MAX_CODE_BITS =
sizeof(code_t)*8};
42 HuffmanDecoder(
const unsigned int *codeBitLengths,
unsigned int nCodes) {Initialize(codeBitLengths, nCodes);}
44 void Initialize(
const unsigned int *codeBitLengths,
unsigned int nCodes);
45 unsigned int Decode(code_t code, value_t &value)
const;
49 friend struct CodeLessThan;
53 CodeInfo(code_t code=0,
unsigned int len=0, value_t value=0) : code(code), len(len), value(value) {}
54 inline bool operator<(
const CodeInfo &rhs)
const {
return code < rhs.code;}
66 const CodeInfo *begin;
75 static code_t NormalizeCode(code_t code,
unsigned int codeBits);
76 void FillCacheEntry(LookupEntry &entry, code_t normalizedCode)
const;
78 unsigned int m_maxCodeBits, m_cacheBits, m_cacheMask, m_normalizedCacheMask;
79 std::vector<CodeInfo, AllocatorWithCleanup<CodeInfo> > m_codeToValue;
80 mutable std::vector<LookupEntry, AllocatorWithCleanup<LookupEntry> > m_cache;
103 size_t Put2(
const byte *inString,
size_t length,
int messageEnd,
bool blocking);
104 bool IsolatedFlush(
bool hardFlush,
bool blocking);
106 virtual unsigned int GetLog2WindowSize()
const {
return 15;}
112 virtual unsigned int MaxPrestreamHeaderSize()
const {
return 0;}
113 virtual void ProcessPrestreamHeader() {}
114 virtual void ProcessDecompressedData(
const byte *
string,
size_t length)
115 {AttachedTransformation()->
Put(
string, length);}
116 virtual unsigned int MaxPoststreamTailSize()
const {
return 0;}
117 virtual void ProcessPoststreamTail() {}
119 void ProcessInput(
bool flush);
123 void OutputByte(byte b);
124 void OutputString(
const byte *
string,
size_t length);
125 void OutputPast(
unsigned int length,
unsigned int distance);
133 enum State {PRE_STREAM, WAIT_HEADER, DECODING_BODY, POST_STREAM, AFTER_END};
135 bool m_repeat, m_eof, m_wrappedAround;
138 enum NextDecode {LITERAL, LENGTH_BITS, DISTANCE, DISTANCE_BITS};
139 NextDecode m_nextDecode;
140 unsigned int m_literal, m_distance;
144 size_t m_current, m_lastFlush;
base class for all exceptions thrown by Crypto++
received input data that doesn't conform to expected format
bool operator<(const ::PolynomialMod2 &a, const ::PolynomialMod2 &b)
compares degree
DEFLATE (RFC 1951) decompressor.
interface for retrieving values given their names