1 #ifndef CRYPTOPP_ZINFLATE_H
2 #define CRYPTOPP_ZINFLATE_H
9 NAMESPACE_BEGIN(CryptoPP)
16 : m_store(store), m_buffer(0), m_bitsBuffered(0) {}
17 unsigned int BitsBuffered()
const {
return m_bitsBuffered;}
18 unsigned long PeekBuffer()
const {
return m_buffer;}
19 bool FillBuffer(
unsigned int length);
20 unsigned long PeekBits(
unsigned int length);
21 void SkipBits(
unsigned int length);
22 unsigned long GetBits(
unsigned int length);
26 unsigned long m_buffer;
27 unsigned int m_bitsBuffered;
36 typedef unsigned int code_t;
37 typedef unsigned int value_t;
38 enum {MAX_CODE_BITS =
sizeof(code_t)*8};
42 HuffmanDecoder() : m_maxCodeBits(0), m_cacheBits(0), m_cacheMask(0), m_normalizedCacheMask(0) {}
43 HuffmanDecoder(
const unsigned int *codeBitLengths,
unsigned int nCodes)
44 : m_maxCodeBits(0), m_cacheBits(0), m_cacheMask(0), m_normalizedCacheMask(0)
45 {Initialize(codeBitLengths, nCodes);}
47 void Initialize(
const unsigned int *codeBitLengths,
unsigned int nCodes);
48 unsigned int Decode(code_t code, value_t &value)
const;
56 CodeInfo(code_t code=0,
unsigned int len=0, value_t value=0) : code(code), len(len), value(value) {}
57 inline bool operator<(
const CodeInfo &rhs)
const {
return code < rhs.code;}
69 const CodeInfo *begin;
78 static code_t NormalizeCode(code_t code,
unsigned int codeBits);
79 void FillCacheEntry(LookupEntry &entry, code_t normalizedCode)
const;
81 unsigned int m_maxCodeBits, m_cacheBits, m_cacheMask, m_normalizedCacheMask;
82 std::vector<CodeInfo, AllocatorWithCleanup<CodeInfo> > m_codeToValue;
83 mutable std::vector<LookupEntry, AllocatorWithCleanup<LookupEntry> > m_cache;
107 size_t Put2(
const byte *inString,
size_t length,
int messageEnd,
bool blocking);
108 bool IsolatedFlush(
bool hardFlush,
bool blocking);
110 virtual unsigned int GetLog2WindowSize()
const {
return 15;}
116 virtual unsigned int MaxPrestreamHeaderSize()
const {
return 0;}
117 virtual void ProcessPrestreamHeader() {}
118 virtual void ProcessDecompressedData(
const byte *
string,
size_t length)
119 {AttachedTransformation()->
Put(
string, length);}
120 virtual unsigned int MaxPoststreamTailSize()
const {
return 0;}
121 virtual void ProcessPoststreamTail() {}
123 void ProcessInput(
bool flush);
127 void OutputByte(byte b);
128 void OutputString(
const byte *
string,
size_t length);
129 void OutputPast(
unsigned int length,
unsigned int distance);
137 enum State {PRE_STREAM, WAIT_HEADER, DECODING_BODY, POST_STREAM, AFTER_END};
139 bool m_repeat, m_eof, m_wrappedAround;
142 enum NextDecode {LITERAL, LENGTH_BITS, DISTANCE, DISTANCE_BITS};
143 NextDecode m_nextDecode;
144 unsigned int m_literal, m_distance;
148 size_t m_current, m_lastFlush;
Base class for all exceptions thrown by the library.
const char * what() const
Retrieves a C-string describing the exception.
ErrorType
Error types or categories.
Exception(ErrorType errorType, const std::string &s)
Construct a new Exception.
Abstract base classes that provide a uniform interface to this library.
SecBlock<byte> typedef.
Classes and functions for secure memory allocations.
Input data was received that did not conform to expected format.
bool operator<(const OID &lhs, const OID &rhs)
Compare two OIDs for ordering.
Data structure used to store byte strings.
Implementation of BufferedTransformation's attachment interface.
DEFLATE (RFC 1951) decompressor.
Provides auto signaling support.
Interface for retrieving values given their names.