/* Copyright (c) 2010-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#ifdef HAVE_BZLIB
#include "ostream-private.h"
#include "ostream-zlib.h"
#include <bzlib.h>
struct bzlib_ostream {
};
bool close_parent)
{
if (close_parent)
}
{
if (zstream->outbuf_used == 0)
return 1;
if (ret < 0) {
return -1;
}
return 0;
}
zstream->outbuf_offset = 0;
zstream->outbuf_used = 0;
return 1;
}
static ssize_t
{
int ret;
/* previous block was compressed. send it and start
compression for a new block. */
return -1;
if (ret == 0) {
/* parent stream's buffer full */
break;
}
}
case BZ_RUN_OK:
break;
default:
i_unreached();
}
}
return size;
}
{
int ret;
return 0;
return ret;
return ret;
do {
if (len != 0) {
return ret;
if (done)
break;
}
switch (ret) {
case BZ_STREAM_END:
break;
case BZ_FINISH_OK:
break;
default:
i_unreached();
}
return 0;
}
{
if (o_stream_bzlib_send_flush(zstream) < 0)
return -1;
return o_stream_flush_parent(stream);
}
static ssize_t
{
unsigned int i;
/* error / we still couldn't flush existing data to
parent stream. */
return ret;
}
for (i = 0; i < iov_count; i++) {
if (ret < 0)
return -1;
break;
}
/* avail_in!=0 check is used to detect errors. if it's non-zero here
it simply means we didn't send all the data */
return bytes;
}
{
int ret;
switch (ret) {
case BZ_OK:
break;
case BZ_MEM_ERROR:
"bzlib: Out of memory");
case BZ_CONFIG_ERROR:
i_fatal("Wrong bzlib library version (broken compilation)");
case BZ_PARAM_ERROR:
i_fatal("bzlib: Invalid parameters");
default:
}
}
#endif