monotone

monotone Mtn Source Tree

Root/cryptopp/gzip.h

1#ifndef CRYPTOPP_GZIP_H
2#define CRYPTOPP_GZIP_H
3
4#include "zdeflate.h"
5#include "zinflate.h"
6#include "crc.h"
7
8NAMESPACE_BEGIN(CryptoPP)
9
10/// GZIP Compression (RFC 1952)
11class Gzip : public Deflator
12{
13public:
14Gzip(BufferedTransformation *attachment=NULL, unsigned int deflateLevel=DEFAULT_DEFLATE_LEVEL, unsigned int log2WindowSize=DEFAULT_LOG2_WINDOW_SIZE)
15: Deflator(attachment, deflateLevel, log2WindowSize) {}
16Gzip(const NameValuePairs &parameters, BufferedTransformation *attachment=NULL)
17: Deflator(parameters, attachment) {}
18
19protected:
20enum {MAGIC1=0x1f, MAGIC2=0x8b, // flags for the header
21 DEFLATED=8, FAST=4, SLOW=2};
22
23void WritePrestreamHeader();
24void ProcessUncompressedData(const byte *string, unsigned int length);
25void WritePoststreamTail();
26
27unsigned long m_totalLen;
28CRC32 m_crc;
29};
30
31/// GZIP Decompression (RFC 1952)
32class Gunzip : public Inflator
33{
34public:
35typedef Inflator::Err Err;
36class HeaderErr : public Err {public: HeaderErr() : Err(INVALID_DATA_FORMAT, "Gunzip: header decoding error") {}};
37class TailErr : public Err {public: TailErr() : Err(INVALID_DATA_FORMAT, "Gunzip: tail too short") {}};
38class CrcErr : public Err {public: CrcErr() : Err(DATA_INTEGRITY_CHECK_FAILED, "Gunzip: CRC check error") {}};
39class LengthErr : public Err {public: LengthErr() : Err(DATA_INTEGRITY_CHECK_FAILED, "Gunzip: length check error") {}};
40
41/*! \param repeat decompress multiple compressed streams in series
42\param autoSignalPropagation 0 to turn off MessageEnd signal
43*/
44Gunzip(BufferedTransformation *attachment = NULL, bool repeat = false, int autoSignalPropagation = -1);
45
46protected:
47enum {MAGIC1=0x1f, MAGIC2=0x8b, // flags for the header
48DEFLATED=8};
49
50enum FLAG_MASKS {
51CONTINUED=2, EXTRA_FIELDS=4, FILENAME=8, COMMENTS=16, ENCRYPTED=32};
52
53unsigned int MaxPrestreamHeaderSize() const {return 1024;}
54void ProcessPrestreamHeader();
55void ProcessDecompressedData(const byte *string, unsigned int length);
56unsigned int MaxPoststreamTailSize() const {return 8;}
57void ProcessPoststreamTail();
58
59unsigned long m_length;
60CRC32 m_crc;
61};
62
63NAMESPACE_END
64
65#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status