239{
241 int rc;
242
243 zctx->
write.
z.avail_in = (uInt) count;
244 zctx->
write.
z.next_in = (Bytef *) buf;
246 zctx->write.z.next_out = (Bytef *) zctx->write.buf;
247
248 do
249 {
250 int zrc = deflate(&zctx->write.z, Z_PARTIAL_FLUSH);
251 if (zrc == Z_OK)
252 {
253
254 zctx->write.pos = zctx->write.len - zctx->write.z.avail_out;
255 char *wbufp = zctx->write.buf;
257 count - zctx->write.z.avail_in, count);
258 while (zctx->write.pos > 0)
259 {
260 rc = zctx->next_conn.write(&zctx->next_conn, wbufp, zctx->write.pos);
262 if (rc < 0)
263 return -1;
264
265 wbufp += rc;
266 zctx->write.pos -= rc;
267 }
268
269
270
271
272 if ((zctx->write.z.avail_out != 0) && (zctx->write.z.avail_in == 0))
273 break;
274
275 zctx->write.z.avail_out = (uInt) zctx->write.len;
276 zctx->write.z.next_out = (Bytef *) zctx->write.buf;
277 }
278 else
279 {
280
281
282 return -1;
283 }
284 } while (true);
285
286
287 if (count > INT_MAX)
288 {
290 return -1;
291 }
292 return (int) count;
293}
@ LL_DEBUG5
Log at debug level 5.
struct ZstrmDirection write
Data being compressed and written.
unsigned int len
Length of data.
z_stream z
zlib compression handle