10 static inline bool Is8859Character(
char c) {
11 const unsigned char cc =
static_cast<unsigned char>(c);
12 return (cc >= 32 && cc <= 126) || (cc >= 160);
19 m_filename.assign(reinterpret_cast<const char*>(v.
begin()), v.
size());
21 m_comment.assign(reinterpret_cast<const char*>(v.
begin()), v.
size());
25 void Gzip::WritePrestreamHeader()
31 if(!m_filename.empty())
33 if(!m_comment.empty())
46 if(!m_filename.empty())
50 if(!m_comment.empty())
54 void Gzip::ProcessUncompressedData(
const byte *inString,
size_t length)
56 m_crc.
Update(inString, length);
57 m_totalLen += (word32)length;
60 void Gzip::WritePoststreamTail()
74 if(throwOnEncodingError)
76 for(
size_t i = 0; i < comment.length(); i++) {
77 const char c = comment[i];
78 if(!Is8859Character(c))
88 if(throwOnEncodingError)
90 for(
size_t i = 0; i < filename.length(); i++) {
91 const char c = filename[i];
92 if(!Is8859Character(c))
97 m_filename = filename;
103 :
Inflator(attachment, repeat, propagation), m_length(0), m_filetime(0)
107 void Gunzip::ProcessPrestreamHeader()
119 if (m_inQueue.Get(buf, 2)!=2)
throw HeaderErr();
120 if (buf[0] != MAGIC1 || buf[1] != MAGIC2)
throw HeaderErr();
121 if (!m_inQueue.Get(b) || (b != DEFLATED))
throw HeaderErr();
122 if (!m_inQueue.Get(flags))
throw HeaderErr();
123 if (flags & (ENCRYPTED | CONTINUED))
throw HeaderErr();
125 if (m_inQueue.Skip(2)!=2)
throw HeaderErr();
127 if (flags & EXTRA_FIELDS)
131 if (m_inQueue.Skip(length)!=length)
throw HeaderErr();
134 if (flags & FILENAME)
139 if(b) m_filename.append( 1, (
char)b );
144 if (flags & COMMENTS)
149 if(b) m_comment.append( 1, (
char)b );
155 void Gunzip::ProcessDecompressedData(
const byte *inString,
size_t length)
158 m_crc.
Update(inString, length);
159 m_length += (word32)length;
162 void Gunzip::ProcessPoststreamTail()
165 if (m_inQueue.Get(crc, 4) != 4)
173 if (lengthCheck != m_length)
179 if(throwOnEncodingError)
181 for(
size_t i = 0; i < m_comment.length(); i++) {
182 const char c = m_comment[i];
183 if(!Is8859Character(c))
193 if(throwOnEncodingError)
195 for(
size_t i = 0; i < m_filename.length(); i++) {
196 const char c = m_filename[i];
197 if(!Is8859Character(c))
Used to pass byte array input as part of a NameValuePairs object.
int GetIntValueWithDefault(const char *name, int defaultValue) const
Get a named value with type int, with default.
Standard names for retrieving values by name when working with NameValuePairs.
size_t size() const
Length of the memory block.
Exception thrown when a CRC error occurs.
Exception thrown when a length error occurs.
void SetFilename(const std::string &filename, bool throwOnEncodingError=false)
byte order is little-endian
Gunzip(BufferedTransformation *attachment=NULL, bool repeat=false, int autoSignalPropagation=-1)
Construct a Gunzip decompressor.
GZIP compression and decompression (RFC 1952)
const char * FileTime()
int
Exception thrown when the tail is too short.
const byte * begin() const
Pointer to the first byte in the memory block.
BufferedTransformation * AttachedTransformation()
Retrieve attached transformation.
void SetComment(const std::string &comment, bool throwOnEncodingError=false)
void Update(const byte *input, size_t length)
Updates a hash with additional input.
const std::string & GetComment(bool throwOnEncodingError=false) const
const std::string & GetFilename(bool throwOnEncodingError=false) const
DEFLATE decompressor (RFC 1951)
int GetDeflateLevel() const
Retrieves the deflation level.
const char * Comment()
const char *
Crypto++ library namespace.
bool GetValue(const char *name, T &value) const
Get a named value.
const char * FileName()
const char *
void IsolatedInitialize(const NameValuePairs ¶meters)
Initialize or reinitialize this object, without signal propagation.
Interface for retrieving values given their names.