istream-zlib.c revision 01e606cda5192c4254c090624a0b2ca92da6da8e
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Copyright (c) 2005-2009 Dovecot authors, see the included COPYING file */
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen/* Default maximum buffer size. Seeking backwards is very expensive, so keep
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen this pretty large */
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainenstatic void i_stream_zlib_close(struct iostream_private *stream)
c251a38df327599a62d341bf5c2282f31352faa5Timo Sirainen struct zlib_istream *zstream = (struct zlib_istream *)stream;
beb6125ee872e7fed57745ab33e6de99639180f3Timo Sirainenstatic ssize_t i_stream_zlib_read(struct istream_private *stream)
8d80659e504ffb34bb0c6a633184fece35751b18Timo Sirainen struct zlib_istream *zstream = (struct zlib_istream *)stream;
1175f27441385a7011629f295f42708f9a3a4ffcTimo Sirainen /* don't try to keep anything cached if we don't
72cbf33ae81fde08384d30c779ff540752d9256cTimo Sirainen have a seek mark. */
46c31f64b9f0949f00b7819f45b22f2d64b2ea27Timo Sirainen stream->buffer_size < stream->max_buffer_size) {
46c31f64b9f0949f00b7819f45b22f2d64b2ea27Timo Sirainen /* buffer is full - grow it */
d6badc27cd6e8d3398877b6766cb0aaeef3a7800Timo Sirainen i_stream_grow_buffer(stream, I_STREAM_MIN_SIZE);
7c95b03620a03a43dd72d39608cea5fc77393ad6Timo Sirainen /* lose our buffer cache */
24fc71a693331ffe77e2b6d81c70aca6fa055e47Timo Sirainen i_assert(zstream->seek_offset == stream->istream.v_offset +
d5cebe7f98e63d4e2822863ef2faa4971e8b3a5dTimo Sirainen ret = gzread(zstream->file, stream->w_buffer + stream->pos,
985fa802913c96ce6f2e25bbc788ee39c416a7e0Timo Sirainen } while (ret < 0 && errno == EINTR && stream->istream.blocking);
if (ret < 0) {
ret = 0;
return ret;
#ifndef HAVE_GZSEEK
v_offset -
if (mark) {
static const struct stat *
return NULL;
if (!exact)