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);
21 m_filename.assign(reinterpret_cast<const char*>(v.
begin()), v.
size());
23 m_comment.assign(reinterpret_cast<const char*>(v.
begin()), v.
size());
27 void Gzip::WritePrestreamHeader()
33 if(!m_filename.empty())
35 if(!m_comment.empty())
49 if(!m_filename.empty())
53 if(!m_comment.empty())
57 void Gzip::ProcessUncompressedData(
const byte *inString,
size_t length)
59 m_crc.
Update(inString, length);
60 m_totalLen += (word32)length;
63 void Gzip::WritePoststreamTail()
77 if(throwOnEncodingError)
79 for(
size_t i = 0; i < comment.length(); i++) {
80 const char c = comment[i];
81 if(!Is8859Character(c))
91 if(throwOnEncodingError)
93 for(
size_t i = 0; i < filename.length(); i++) {
94 const char c = filename[i];
95 if(!Is8859Character(c))
100 m_filename = filename;
106 :
Inflator(attachment, repeat, propagation), m_length(0), m_filetime(0)
110 void Gunzip::ProcessPrestreamHeader()
122 if (m_inQueue.Get(buf, 2)!=2)
throw HeaderErr();
123 if (buf[0] != MAGIC1 || buf[1] != MAGIC2)
throw HeaderErr();
124 if (!m_inQueue.Get(b) || (b != DEFLATED))
throw HeaderErr();
125 if (!m_inQueue.Get(flags))
throw HeaderErr();
126 if (flags & (ENCRYPTED | CONTINUED))
throw HeaderErr();
128 if (m_inQueue.Skip(2)!=2)
throw HeaderErr();
130 if (flags & EXTRA_FIELDS)
134 if (m_inQueue.Skip(length)!=length)
throw HeaderErr();
137 if (flags & FILENAME)
141 if(!m_inQueue.Get(b))
throw HeaderErr();
142 if(b) m_filename.append( 1, (
char)b );
147 if (flags & COMMENTS)
151 if(!m_inQueue.Get(b))
throw HeaderErr();
152 if(b) m_comment.append( 1, (
char)b );
158 void Gunzip::ProcessDecompressedData(
const byte *inString,
size_t length)
161 m_crc.
Update(inString, length);
162 m_length += (word32)length;
165 void Gunzip::ProcessPoststreamTail()
168 if (m_inQueue.Get(crc, 4) != 4)
176 if (lengthCheck != m_length)
182 if(throwOnEncodingError)
184 for(
size_t i = 0; i < m_comment.length(); i++) {
185 const char c = m_comment[i];
186 if(!Is8859Character(c))
196 if(throwOnEncodingError)
198 for(
size_t i = 0; i < m_filename.length(); i++) {
199 const char c = m_filename[i];
200 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.
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
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.
void IsolatedInitialize(const NameValuePairs ¶meters)
Initialize or reinitialize this object, without signal propagation.
Interface for retrieving values given their names.