Lines Matching refs:zstream
26 struct bzlib_ostream *zstream = (struct bzlib_ostream *)stream;
28 (void)BZ2_bzCompressEnd(&zstream->zs);
30 o_stream_close(zstream->ostream.parent);
33 static int o_stream_zlib_send_outbuf(struct bzlib_ostream *zstream)
38 if (zstream->outbuf_used == 0)
41 size = zstream->outbuf_used - zstream->outbuf_offset;
43 ret = o_stream_send(zstream->ostream.parent,
44 zstream->outbuf + zstream->outbuf_offset, size);
46 o_stream_copy_error_from_parent(&zstream->ostream);
50 zstream->outbuf_offset += ret;
53 zstream->outbuf_offset = 0;
54 zstream->outbuf_used = 0;
59 o_stream_bzlib_send_chunk(struct bzlib_ostream *zstream,
62 bz_stream *zs = &zstream->zs;
65 i_assert(zstream->outbuf_used == 0);
73 zs->next_out = zstream->outbuf;
74 zs->avail_out = sizeof(zstream->outbuf);
76 zstream->outbuf_used = sizeof(zstream->outbuf);
77 if ((ret = o_stream_zlib_send_outbuf(zstream)) < 0)
94 zstream->flushed = FALSE;
98 static int o_stream_bzlib_send_flush(struct bzlib_ostream *zstream)
100 bz_stream *zs = &zstream->zs;
107 if (zstream->flushed)
110 if ((ret = o_stream_flush_parent_if_needed(&zstream->ostream)) <= 0)
112 if ((ret = o_stream_zlib_send_outbuf(zstream)) <= 0)
115 i_assert(zstream->outbuf_used == 0);
117 len = sizeof(zstream->outbuf) - zs->avail_out;
119 zs->next_out = zstream->outbuf;
120 zs->avail_out = sizeof(zstream->outbuf);
122 zstream->outbuf_used = len;
123 if ((ret = o_stream_zlib_send_outbuf(zstream)) <= 0)
139 } while (zs->avail_out != sizeof(zstream->outbuf));
141 zstream->flushed = TRUE;
147 struct bzlib_ostream *zstream = (struct bzlib_ostream *)stream;
149 if (o_stream_bzlib_send_flush(zstream) < 0)
159 struct bzlib_ostream *zstream = (struct bzlib_ostream *)stream;
163 if ((ret = o_stream_zlib_send_outbuf(zstream)) <= 0) {
170 ret = o_stream_bzlib_send_chunk(zstream, iov[i].iov_base,
182 zstream->zs.avail_in = 0;
188 struct bzlib_ostream *zstream;
193 zstream = i_new(struct bzlib_ostream, 1);
194 zstream->ostream.sendv = o_stream_bzlib_sendv;
195 zstream->ostream.flush = o_stream_bzlib_flush;
196 zstream->ostream.iostream.close = o_stream_bzlib_close;
198 ret = BZ2_bzCompressInit(&zstream->zs, level, 0, 0);
213 zstream->zs.next_out = zstream->outbuf;
214 zstream->zs.avail_out = sizeof(zstream->outbuf);
215 return o_stream_create(&zstream->ostream, output,