Lines Matching refs:zstream

29 	struct bzlib_istream *zstream = (struct bzlib_istream *)stream;
31 if (!zstream->zs_closed) {
32 (void)BZ2_bzDecompressEnd(&zstream->zs);
33 zstream->zs_closed = TRUE;
36 i_stream_close(zstream->istream.parent);
39 static void bzlib_read_error(struct bzlib_istream *zstream, const char *error)
41 io_stream_set_error(&zstream->istream.iostream,
43 i_stream_get_name(&zstream->istream.istream), error,
44 i_stream_get_absolute_offset(&zstream->istream.istream));
45 if (zstream->log_errors)
46 i_error("%s", zstream->istream.iostream.error);
51 struct bzlib_istream *zstream = (struct bzlib_istream *)stream;
58 if (zstream->eof_offset == high_offset) {
59 i_assert(zstream->high_pos == 0 ||
60 zstream->high_pos == stream->pos);
65 if (stream->pos < zstream->high_pos) {
67 ret = zstream->high_pos - stream->pos;
68 stream->pos = zstream->high_pos;
69 zstream->high_pos = 0;
71 if (zstream->eof_offset != (uoff_t)-1) {
74 i_assert(zstream->eof_offset == high_offset);
79 zstream->high_pos = 0;
81 if (!zstream->marked) {
96 bzlib_read_error(zstream, "unexpected EOF");
107 zstream->zs.next_in = (char *)data;
108 zstream->zs.avail_in = size;
110 zstream->zs.next_out = (char *)stream->w_buffer + stream->pos;
111 zstream->zs.avail_out = out_size;
112 ret = BZ2_bzDecompress(&zstream->zs);
114 out_size -= zstream->zs.avail_out;
117 i_stream_skip(stream->parent, size - zstream->zs.avail_in);
125 bzlib_read_error(zstream, "corrupted data");
129 bzlib_read_error(zstream,
137 zstream->eof_offset = stream->istream.v_offset +
139 zstream->stream_size = zstream->eof_offset;
155 static void i_stream_bzlib_init(struct bzlib_istream *zstream)
159 ret = BZ2_bzDecompressInit(&zstream->zs, 0, 0);
174 static void i_stream_bzlib_reset(struct bzlib_istream *zstream)
176 struct istream_private *stream = &zstream->istream;
179 zstream->eof_offset = (uoff_t)-1;
180 zstream->zs.next_in = NULL;
181 zstream->zs.avail_in = 0;
186 zstream->high_pos = 0;
188 (void)BZ2_bzDecompressEnd(&zstream->zs);
189 i_stream_bzlib_init(zstream);
195 struct bzlib_istream *zstream = (struct bzlib_istream *) stream;
200 i_stream_bzlib_reset(zstream);
202 } else if (zstream->high_pos != 0) {
203 stream->pos = zstream->high_pos;
204 zstream->high_pos = 0;
211 zstream->high_pos = stream->pos;
248 zstream->marked = TRUE;
254 struct bzlib_istream *zstream = (struct bzlib_istream *) stream;
271 if (zstream->stream_size == (uoff_t)-1) {
282 if (zstream->stream_size == (uoff_t)-1)
285 stream->statbuf.st_size = zstream->stream_size;
291 struct bzlib_istream *zstream = (struct bzlib_istream *) stream;
295 if (memcmp(&zstream->last_parent_statbuf,
301 zstream->last_parent_statbuf = *st;
303 i_stream_bzlib_reset(zstream);
308 struct bzlib_istream *zstream;
310 zstream = i_new(struct bzlib_istream, 1);
311 zstream->eof_offset = (uoff_t)-1;
312 zstream->stream_size = (uoff_t)-1;
313 zstream->log_errors = log_errors;
315 i_stream_bzlib_init(zstream);
317 zstream->istream.iostream.close = i_stream_bzlib_close;
318 zstream->istream.max_buffer_size = input->real_stream->max_buffer_size;
319 zstream->istream.read = i_stream_bzlib_read;
320 zstream->istream.seek = i_stream_bzlib_seek;
321 zstream->istream.stat = i_stream_bzlib_stat;
322 zstream->istream.sync = i_stream_bzlib_sync;
324 zstream->istream.istream.readable_fd = FALSE;
325 zstream->istream.istream.blocking = input->blocking;
326 zstream->istream.istream.seekable = input->seekable;
328 return i_stream_create(&zstream->istream, input,