istream-zlib.c revision c06f4017027263cf3a08becc551f5126409e2a83
/* 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 */
#define I_STREAM_MIN_SIZE 4096
struct zlib_istream {
int fd;
unsigned int marked:1;
};
{
}
}
{
}
{
}
{
else {
}
if (zstream->max_buffer_size > 0 &&
}
{
}
{
int ret;
return -1;
/* don't try to keep anything cached if we don't
have a seek mark. */
}
if (zstream->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;
}
{
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;
}
/* 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) {
}
}
{
i_error("zlib_istream.fstat() failed: %m");
return NULL;
}
if (!exact)
do {
}
}
{
}
{
struct zlib_istream *zstream;
/* if it's a file, set the flags properly */
}
}