59 stream << _algorithm << _origin_size;
60 len -= _algorithm.
getLength() + _origin_size.getLength();
67 stream >> _origin_size;
164 const uInt CHUNK_SIZE = 16384;
168 unsigned char in[CHUNK_SIZE];
169 unsigned char out[CHUNK_SIZE];
173 strm.zalloc = Z_NULL;
175 strm.opaque = Z_NULL;
176 ret = deflateInit(&strm, Z_DEFAULT_COMPRESSION);
182 is.read((
char*)&in, CHUNK_SIZE);
183 strm.avail_in =
static_cast<uInt
>(is.gcount());
185 flush = is.eof() ? Z_FINISH : Z_NO_FLUSH;
189 strm.avail_out = CHUNK_SIZE;
192 ret = deflate(&strm, flush);
193 assert(ret != Z_STREAM_ERROR);
196 have = CHUNK_SIZE - strm.avail_out;
199 os.write((
char*)&out, have);
203 (void)deflateEnd(&strm);
207 }
while (strm.avail_out == 0);
208 assert(strm.avail_in == 0);
209 }
while (flush != Z_FINISH);
210 assert(ret == Z_STREAM_END);
212 (void)deflateEnd(&strm);
231 const uInt CHUNK_SIZE = 16384;
235 unsigned char in[CHUNK_SIZE];
236 unsigned char out[CHUNK_SIZE];
239 strm.zalloc = Z_NULL;
241 strm.opaque = Z_NULL;
243 strm.next_in = Z_NULL;
244 ret = inflateInit(&strm);
250 is.read((
char*)&in, CHUNK_SIZE);
251 strm.avail_in =
static_cast<uInt
>(is.gcount());
254 if ((strm.avail_in == 0) && (ret != Z_STREAM_END))
256 (void)inflateEnd(&strm);
262 strm.avail_out = CHUNK_SIZE;
265 ret = inflate(&strm, Z_NO_FLUSH);
266 assert(ret != Z_STREAM_ERROR);
274 (void)inflateEnd(&strm);
279 have = CHUNK_SIZE - strm.avail_out;
282 os.write((
char*)&out, have);
287 (void)inflateEnd(&strm);
291 }
while (strm.avail_out == 0);
292 assert(strm.avail_in == 0);
293 }
while (ret != Z_STREAM_END);
295 (void)inflateEnd(&strm);