1 #ifndef CRYPTOPP_ZINFLATE_H 2 #define CRYPTOPP_ZINFLATE_H 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;
37 typedef unsigned int code_t;
38 typedef unsigned int value_t;
39 enum {MAX_CODE_BITS =
sizeof(code_t)*8};
43 HuffmanDecoder() : m_maxCodeBits(0), m_cacheBits(0), m_cacheMask(0), m_normalizedCacheMask(0) {}
44 HuffmanDecoder(
const unsigned int *codeBitLengths,
unsigned int nCodes)
45 : m_maxCodeBits(0), m_cacheBits(0), m_cacheMask(0), m_normalizedCacheMask(0)
46 {Initialize(codeBitLengths, nCodes);}
48 void Initialize(
const unsigned int *codeBitLengths,
unsigned int nCodes);
49 unsigned int Decode(code_t code, value_t &value)
const;
57 CodeInfo(code_t code=0,
unsigned int len=0, value_t value=0) : code(code), len(len), value(value) {}
58 inline bool operator<(
const CodeInfo &rhs)
const {
return code < rhs.code;}
70 const CodeInfo *begin;
79 static code_t NormalizeCode(code_t code,
unsigned int codeBits);
80 void FillCacheEntry(LookupEntry &entry, code_t normalizedCode)
const;
82 unsigned int m_maxCodeBits, m_cacheBits, m_cacheMask, m_normalizedCacheMask;
83 std::vector<CodeInfo, AllocatorWithCleanup<CodeInfo> > m_codeToValue;
84 mutable std::vector<LookupEntry, AllocatorWithCleanup<LookupEntry> > m_cache;
112 size_t Put2(
const byte *inString,
size_t length,
int messageEnd,
bool blocking);
115 virtual unsigned int GetLog2WindowSize()
const {
return 15;}
121 virtual unsigned int MaxPrestreamHeaderSize()
const {
return 0;}
122 virtual void ProcessPrestreamHeader() {}
123 virtual void ProcessDecompressedData(
const byte *
string,
size_t length)
125 virtual unsigned int MaxPoststreamTailSize()
const {
return 0;}
126 virtual void ProcessPoststreamTail() {}
128 void ProcessInput(
bool flush);
132 void OutputByte(byte b);
133 void OutputString(
const byte *
string,
size_t length);
134 void OutputPast(
unsigned int length,
unsigned int distance);
136 void CreateFixedDistanceDecoder();
137 void CreateFixedLiteralDecoder();
142 enum State {PRE_STREAM, WAIT_HEADER, DECODING_BODY, POST_STREAM, AFTER_END};
144 bool m_repeat, m_eof, m_wrappedAround;
147 enum NextDecode {LITERAL, LENGTH_BITS, DISTANCE, DISTANCE_BITS};
148 NextDecode m_nextDecode;
149 unsigned int m_literal, m_distance;
154 size_t m_current, m_lastFlush;
Inflator(BufferedTransformation *attachment=NULL, bool repeat=false, int autoSignalPropagation=-1)
RFC 1951 Decompressor.
Base class for all exceptions thrown by the library.
ErrorType
Error types or categories.
const char * what() const
Retrieves a C-string describing the exception.
Exception thrown when a truncated stream is encountered.
Exception(ErrorType errorType, const std::string &s)
Construct a new Exception.
Abstract base classes that provide a uniform interface to this library.
bool IsolatedFlush(bool hardFlush, bool blocking)
Flushes data buffered by this object, without signal propagation.
Classes and functions for secure memory allocations.
void IsolatedInitialize(const NameValuePairs ¶meters)
Initialize or reinitialize this object, without signal propagation.
Input data was received that did not conform to expected format.
bool operator<(const OID &lhs, const OID &rhs)
Compare two OIDs for ordering.
BufferedTransformation * AttachedTransformation()
Retrieve attached transformation.
Exception thrown when an invalid distance is encountered.
Data structure used to store byte strings.
Implementation of BufferedTransformation's attachment interface.
DEFLATE decompressor (RFC 1951)
Provides auto signaling support.
size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking)
Input multiple bytes for processing.
Crypto++ library namespace.
Exception thrown when a bad block is encountered.
Interface for retrieving values given their names.