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.

58 lines
2.1 KiB

  1. #ifndef CRYPTOPP_ZLIB_H
  2. #define CRYPTOPP_ZLIB_H
  3. #include "adler32.h"
  4. #include "zdeflate.h"
  5. #include "zinflate.h"
  6. NAMESPACE_BEGIN(CryptoPP)
  7. /// ZLIB Compressor (RFC 1950)
  8. class ZlibCompressor : public Deflator
  9. {
  10. public:
  11. ZlibCompressor(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. ZlibCompressor(const NameValuePairs &parameters, BufferedTransformation *attachment=NULL)
  14. : Deflator(parameters, attachment) {}
  15. unsigned int GetCompressionLevel() const;
  16. protected:
  17. void WritePrestreamHeader();
  18. void ProcessUncompressedData(const byte *string, size_t length);
  19. void WritePoststreamTail();
  20. Adler32 m_adler32;
  21. };
  22. /// ZLIB Decompressor (RFC 1950)
  23. class ZlibDecompressor : public Inflator
  24. {
  25. public:
  26. typedef Inflator::Err Err;
  27. class HeaderErr : public Err {public: HeaderErr() : Err(INVALID_DATA_FORMAT, "ZlibDecompressor: header decoding error") {}};
  28. class Adler32Err : public Err {public: Adler32Err() : Err(DATA_INTEGRITY_CHECK_FAILED, "ZlibDecompressor: ADLER32 check error") {}};
  29. class UnsupportedAlgorithm : public Err {public: UnsupportedAlgorithm() : Err(INVALID_DATA_FORMAT, "ZlibDecompressor: unsupported algorithm") {}};
  30. class UnsupportedPresetDictionary : public Err {public: UnsupportedPresetDictionary() : Err(INVALID_DATA_FORMAT, "ZlibDecompressor: unsupported preset dictionary") {}};
  31. /*! \param repeat decompress multiple compressed streams in series
  32. \param autoSignalPropagation 0 to turn off MessageEnd signal
  33. */
  34. ZlibDecompressor(BufferedTransformation *attachment = NULL, bool repeat = false, int autoSignalPropagation = -1);
  35. unsigned int GetLog2WindowSize() const {return m_log2WindowSize;}
  36. private:
  37. unsigned int MaxPrestreamHeaderSize() const {return 2;}
  38. void ProcessPrestreamHeader();
  39. void ProcessDecompressedData(const byte *string, size_t length);
  40. unsigned int MaxPoststreamTailSize() const {return 4;}
  41. void ProcessPoststreamTail();
  42. unsigned int m_log2WindowSize;
  43. Adler32 m_adler32;
  44. };
  45. NAMESPACE_END
  46. #endif