Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.1 KiB

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