istream-zlib.c revision a94936bafd127680184da114c6a177b37ff656e5
/* Copyright (C) 2005 Timo Sirainen */
#include "lib.h"
#include "istream-internal.h"
#include "istream-zlib.h"
#include <zlib.h>
/* Default maximum buffer size. Seeking backwards is very expensive, so keep
this pretty large */
struct zlib_istream {
struct istream_private istream;
int fd;
unsigned int marked:1;
};
{
}
}
{
}
{
int ret;
return -1;
/* don't try to keep anything cached if we don't
have a seek mark. */
}
if (stream->max_buffer_size == 0 ||
/* buffer is full - grow it */
}
/* lose our buffer cache */
}
return -2; /* buffer full */
}
}
ret = -1;
do {
size);
if (ret == 0) {
/* EOF */
return -1;
}
if (ret < 0) {
ret = 0;
} else {
return -1;
}
}
return ret;
}
static void
{
if (v_offset < start_offset) {
/* have to seek backwards */
/* seeking backwards within what's already cached */
} else {
/* read and cache forward */
do {
v_offset -
break;
}
} while (i_stream_zlib_read(stream) >= 0);
/* some failure, we've broken it */
i_error("zlib_istream.seek() failed: %s",
} else {
/* unexpected EOF. allow it since we may just
want to check if there's anything.. */
}
}
}
if (mark) {
}
}
static const struct stat *
{
i_error("zlib_istream.fstat() failed: %m");
return NULL;
}
if (!exact)
do {
} while (i_stream_zlib_read(stream) > 0);
}
}
{
}
{
struct zlib_istream *zstream;
/* if it's a file, set the flags properly */
}
}