#ifndef COMPRESSED_FILE
#define COMPRESSED_FILE

#include <zlib.h>

extern "C" {
	typedef void* (*MALLOC_ZLIB)(void*,unsigned int items, unsigned int size);
	typedef void (*FREE_ZLIB)(void*,void* address);
}

class CompressedFile
{
public:
	CompressedFile(const char* filename);
	CompressedFile(const char* filename,MALLOC_ZLIB,FREE_ZLIB);
	~CompressedFile();

	int write(void* data, int size);

	static const int buf_size = 5000;

private:
	void init();

	int fd_;
	z_stream str_;
	char in_[buf_size];
	char out_[buf_size];
	MALLOC_ZLIB malloc_func_;
	FREE_ZLIB free_func_;
};

#endif
