home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / CMCD0304.ISO / Software / Freeware / Programare / nullsoft / nsis20.exe / Source / czlib.h < prev    next >
C/C++ Source or Header  |  2003-11-23  |  1KB  |  55 lines

  1. #ifndef __CZLIB_H__
  2. #define __CZLIB_H__
  3.  
  4. #include "compressor.h"
  5. #include "zlib/ZLIB.H"
  6.  
  7. class CZlib : public ICompressor {
  8.   public:
  9.     int Init(int level) {
  10.       stream = new z_stream;
  11.       if (!stream) return Z_MEM_ERROR;
  12.       return deflateInit(stream, level);
  13.     }
  14.  
  15.     int End() {
  16.       int ret = deflateEnd(stream);
  17.       delete stream;
  18.       return ret;
  19.     }
  20.  
  21.     int Compress(BOOL finish) {
  22.       return deflate(stream, finish?Z_FINISH:0);
  23.     }
  24.  
  25.     void SetNextIn(char *in, unsigned int size) {
  26.       stream->next_in = (unsigned char*)in;
  27.       stream->avail_in = size;
  28.     }
  29.  
  30.     void SetNextOut(char *out, unsigned int size) {
  31.       stream->next_out = (unsigned char*)out;
  32.       stream->avail_out = size;
  33.     }
  34.  
  35.     virtual char* GetNextOut() {
  36.       return (char*)stream->next_out;
  37.     }
  38.  
  39.     virtual unsigned int GetAvailIn() {
  40.       return stream->avail_in;
  41.     }
  42.  
  43.     virtual unsigned int GetAvailOut() {
  44.       return stream->avail_out;
  45.     }
  46.  
  47.     const char* GetName() {
  48.       return "zlib";
  49.     }
  50.  
  51.   private:
  52.     z_stream *stream;
  53. };
  54.  
  55. #endif