1 #ifndef CRYPTOPP_ZDEFLATE_H 2 #define CRYPTOPP_ZDEFLATE_H 15 void PutBits(
unsigned long value,
unsigned int length);
16 void FlushBitBuffer();
17 void ClearBitBuffer();
20 unsigned long FinishCounting();
24 unsigned long m_bitCount;
25 unsigned long m_buffer;
26 unsigned int m_bitsBuffered, m_bytesBuffered;
34 typedef unsigned int code_t;
35 typedef unsigned int value_t;
48 void Initialize(
const unsigned int *codeBits,
unsigned int nCodes);
50 static void GenerateCodeLengths(
unsigned int *codeBits,
unsigned int maxCodeBits,
const unsigned int *codeCounts,
size_t nCodes);
68 enum {MIN_DEFLATE_LEVEL = 0, DEFAULT_DEFLATE_LEVEL = 6, MAX_DEFLATE_LEVEL = 9};
69 enum {MIN_LOG2_WINDOW_SIZE = 9, DEFAULT_LOG2_WINDOW_SIZE = 15, MAX_LOG2_WINDOW_SIZE = 15};
73 Deflator(
BufferedTransformation *attachment=NULL,
int deflateLevel=DEFAULT_DEFLATE_LEVEL,
int log2WindowSize=DEFAULT_LOG2_WINDOW_SIZE,
bool detectUncompressible=
true);
78 void SetDeflateLevel(
int deflateLevel);
79 int GetDeflateLevel()
const {
return m_deflateLevel;}
80 int GetLog2WindowSize()
const {
return m_log2WindowSize;}
83 size_t Put2(
const byte *inString,
size_t length,
int messageEnd,
bool blocking);
84 bool IsolatedFlush(
bool hardFlush,
bool blocking);
87 virtual void WritePrestreamHeader() {}
88 virtual void ProcessUncompressedData(
const byte *
string,
size_t length)
89 {CRYPTOPP_UNUSED(
string), CRYPTOPP_UNUSED(length);}
90 virtual void WritePoststreamTail() {}
92 enum {STORED = 0, STATIC = 1, DYNAMIC = 2};
93 enum {MIN_MATCH = 3, MAX_MATCH = 258};
95 void InitializeStaticEncoders();
96 void Reset(
bool forceReset =
false);
97 unsigned int FillWindow(
const byte *str,
size_t length);
98 unsigned int ComputeHash(
const byte *str)
const;
99 unsigned int LongestMatch(
unsigned int &bestMatch)
const;
100 void InsertString(
unsigned int start);
101 void ProcessBuffer();
103 void LiteralByte(byte b);
104 void MatchFound(
unsigned int distance,
unsigned int length);
105 void EncodeBlock(
bool eof,
unsigned int blockType);
106 void EndBlock(
bool eof);
110 unsigned literalCode : 9;
111 unsigned literalExtra : 5;
112 unsigned distanceCode : 5;
113 unsigned distanceExtra : 13;
116 int m_deflateLevel, m_log2WindowSize, m_compressibleDeflateLevel;
117 unsigned int m_detectSkip, m_detectCount;
118 unsigned int DSIZE, DMASK, HSIZE, HMASK, GOOD_MATCH, MAX_LAZYLENGTH, MAX_CHAIN_LENGTH;
119 bool m_headerWritten, m_matchAvailable;
120 unsigned int m_dictionaryEnd, m_stringStart, m_lookahead, m_minLookahead, m_previousMatch, m_previousLength;
121 HuffmanEncoder m_staticLiteralEncoder, m_staticDistanceEncoder, m_dynamicLiteralEncoder, m_dynamicDistanceEncoder;
127 unsigned int m_matchBufferEnd, m_blockStart, m_blockLength;
Utility functions for the Crypto++ library.
Secure memory block with allocator and cleanup.
Abstract base classes that provide a uniform interface to this library.
DEFLATE (RFC 1951) compressor.
SecByteBlock is a SecBlock<byte> typedef.
HuffmanEncoder()
Construct a HuffmanEncoder.
Implementation of BufferedTransformation's attachment interface in cryptlib.h.
void Initialize(const unsigned int *codeBits, unsigned int nCodes)
Initialize or reinitialize this object.
Implementation of BufferedTransformation's attachment interface.
Crypto++ library namespace.
Interface for retrieving values given their names.