2002-08-02 10:01:35 +00:00
|
|
|
#ifndef __CZLIB_H__
|
|
|
|
#define __CZLIB_H__
|
|
|
|
|
|
|
|
#include "compressor.h"
|
|
|
|
#include "zlib/ZLIB.H"
|
|
|
|
|
|
|
|
class CZlib : public ICompressor {
|
|
|
|
public:
|
|
|
|
int Init(int level) {
|
|
|
|
stream = new z_stream;
|
|
|
|
if (!stream) return Z_MEM_ERROR;
|
|
|
|
return deflateInit(stream, level);
|
|
|
|
}
|
|
|
|
|
|
|
|
int End() {
|
|
|
|
int ret = deflateEnd(stream);
|
|
|
|
delete stream;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Compress(BOOL finish) {
|
|
|
|
return deflate(stream, finish?Z_FINISH:0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetNextIn(char *in, unsigned int size) {
|
|
|
|
stream->next_in = (unsigned char*)in;
|
|
|
|
stream->avail_in = size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetNextOut(char *out, unsigned int size) {
|
|
|
|
stream->next_out = (unsigned char*)out;
|
|
|
|
stream->avail_out = size;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual char* GetNextOut() {
|
|
|
|
return (char*)stream->next_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual unsigned int GetAvailIn() {
|
|
|
|
return stream->avail_in;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual unsigned int GetAvailOut() {
|
|
|
|
return stream->avail_out;
|
|
|
|
}
|
|
|
|
|
2003-11-24 00:08:58 +00:00
|
|
|
const char* GetName() {
|
2003-02-07 23:04:25 +00:00
|
|
|
return "zlib";
|
|
|
|
}
|
|
|
|
|
2002-08-02 10:01:35 +00:00
|
|
|
private:
|
|
|
|
z_stream *stream;
|
|
|
|
};
|
|
|
|
|
2004-03-12 20:43:54 +00:00
|
|
|
#endif
|