12 #ifndef TOOLS_USE_OUREX_ZLIB
15 #include <ourex_zlib.h>
24 unsigned int a_srcsize,
const char* a_src,
25 unsigned int a_tgtsize,
char* a_tgt,
26 unsigned int& a_irep) {
30 stream.next_in = (Bytef*)(a_src);
31 stream.avail_in = (uInt)(a_srcsize);
32 stream.next_out = (Bytef*)a_tgt;
33 stream.avail_out = (uInt)(a_tgtsize);
34 stream.zalloc = (alloc_func)0;
35 stream.zfree = (free_func)0;
36 stream.opaque = (voidpf)0;
40 int err = deflateInit(&stream,a_level);
42 a_out <<
"tools::compress_buffer :"
43 <<
" error in zlib/deflateInit." << std::endl;
48 err = deflate(&stream, Z_FINISH);
49 if(err!=Z_STREAM_END) {
51 a_out <<
"tools::compress_buffer :"
52 <<
" error in zlib/deflate." << std::endl;
62 a_irep = stream.total_out;
68 unsigned int a_srcsize,
const char* a_src,
69 unsigned int a_tgtsize,
char* a_tgt,
70 unsigned int& a_irep) {
74 stream.next_in = (Bytef*)(a_src);
75 stream.avail_in = (uInt)(a_srcsize);
76 stream.next_out = (Bytef*)a_tgt;
77 stream.avail_out = (uInt)(a_tgtsize);
78 stream.zalloc = (alloc_func)0;
79 stream.zfree = (free_func)0;
80 stream.opaque = (voidpf)0;
84 int err = inflateInit(&stream);
86 a_out <<
"tools::decompress_buffer :"
87 <<
" error " << err <<
" in zlib/inflateInit." << std::endl;
91 err = inflate(&stream, Z_FINISH);
92 if (err != Z_STREAM_END) {
94 a_out <<
"tools::decompress_buffer :"
95 <<
" error " << err <<
" in zlib/inflate." << std::endl;
104 a_irep = stream.total_out;
111 #if ZLIB_VERNUM <= 0x1140
117 #if ZLIB_VERNUM <= 0x1140
119 int c = *a_buffer;a_buffer++;
124 #define TOOLS_ZLIB_HEAD_CRC 0x02
125 #define TOOLS_ZLIB_EXTRA_FIELD 0x04
126 #define TOOLS_ZLIB_ORIG_NAME 0x08
127 #define TOOLS_ZLIB_COMMENT 0x10
128 #define TOOLS_ZLIB_RESERVED 0xE0
134 for (len = 0; len < 2; len++) {
175 #undef TOOLS_ZLIB_HEAD_CRC
176 #undef TOOLS_ZLIB_EXTRA_FIELD
177 #undef TOOLS_ZLIB_ORIG_NAME
178 #undef TOOLS_ZLIB_COMMENT
179 #undef TOOLS_ZLIB_RESERVED
181 #endif //ZLIB_VERNUM <= 0x1140
184 unsigned int a_srcsize,
const char* a_src,
185 unsigned int a_tgtsize,
char* a_tgt,
186 unsigned int& a_irep) {
190 #if ZLIB_VERNUM <= 0x1140
191 char* pos = (
char*)a_src;
193 stream.next_in = (Bytef*)pos;
194 stream.avail_in = (uInt)(a_srcsize-(pos-a_src));
196 stream.next_in = (Bytef*)a_src;
197 stream.avail_in = (uInt)a_srcsize;
200 stream.next_out = (Bytef*)a_tgt;
201 stream.avail_out = (uInt)a_tgtsize;
202 stream.zalloc = (alloc_func)0;
203 stream.zfree = (free_func)0;
204 stream.opaque = (voidpf)0;
206 #if ZLIB_VERNUM <= 0x1140
207 int err = inflateInit2(&stream,-MAX_WBITS);
209 int err = inflateInit2(&stream,MAX_WBITS+16);
212 a_out <<
"tools::gunzip_buffer :"
213 <<
" error " << err <<
" in zlib/inflateInit2." << std::endl;
217 err = inflate(&stream, Z_FINISH);
218 if (err != Z_STREAM_END) {
220 a_out <<
"tools::gunzip_buffer :"
221 <<
" error " << err <<
" in zlib/inflate." << std::endl;
227 a_irep = stream.total_out;