6 NAMESPACE_BEGIN(CryptoPP)
8 void
Gzip::WritePrestreamHeader()
13 AttachedTransformation()->
Put(MAGIC1);
14 AttachedTransformation()->Put(MAGIC2);
15 AttachedTransformation()->Put(DEFLATED);
16 AttachedTransformation()->Put(0);
17 AttachedTransformation()->PutWord32(0);
18 byte extra = (GetDeflateLevel() == 1) ? FAST : ((GetDeflateLevel() == 9) ? SLOW : 0);
19 AttachedTransformation()->Put(extra);
20 AttachedTransformation()->Put(GZIP_OS_CODE);
23 void Gzip::ProcessUncompressedData(
const byte *inString,
size_t length)
25 m_crc.
Update(inString, length);
26 m_totalLen += (word32)length;
29 void Gzip::WritePoststreamTail()
40 :
Inflator(attachment, repeat, propagation)
44 void Gunzip::ProcessPrestreamHeader()
52 if (m_inQueue.
Get(buf, 2)!=2)
throw HeaderErr();
53 if (buf[0] != MAGIC1 || buf[1] != MAGIC2)
throw HeaderErr();
54 if (!m_inQueue.
Skip(1))
throw HeaderErr();
55 if (!m_inQueue.
Get(flags))
throw HeaderErr();
56 if (flags & (ENCRYPTED | CONTINUED))
throw HeaderErr();
57 if (m_inQueue.
Skip(6)!=6)
throw HeaderErr();
59 if (flags & EXTRA_FIELDS)
62 if (m_inQueue.
GetWord16(length, LITTLE_ENDIAN_ORDER) != 2)
throw HeaderErr();
63 if (m_inQueue.
Skip(length)!=length)
throw HeaderErr();
68 if(!m_inQueue.
Get(b))
throw HeaderErr();
73 if(!m_inQueue.
Get(b))
throw HeaderErr();
77 void Gunzip::ProcessDecompressedData(
const byte *inString,
size_t length)
80 m_crc.
Update(inString, length);
81 m_length += (word32)length;
84 void Gunzip::ProcessPoststreamTail()
87 if (m_inQueue.
Get(crc, 4) != 4)
93 if (m_inQueue.
GetWord32(lengthCheck, LITTLE_ENDIAN_ORDER) != 4)
95 if (lengthCheck != m_length)
a block of memory allocated using A
Gunzip(BufferedTransformation *attachment=NULL, bool repeat=false, int autoSignalPropagation=-1)
BufferedTransformation * AttachedTransformation()
returns the object immediately attached to this object or NULL for no attachment
void Update(const byte *input, size_t length)
process more input
DEFLATE (RFC 1951) decompressor.
GZIP Compression (RFC 1952)
size_t Get(byte &outByte)
try to retrieve a single byte