/* Copyright (c) 2010-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#ifdef HAVE_ZLIB
#include "crc32.h"
#include "ostream-private.h"
#include "ostream-zlib.h"
#include <zlib.h>
struct zlib_ostream {
};
bool close_parent)
{
if (close_parent)
}
{
return -1;
}
return 0;
}
{
unsigned int i;
for (i = 0; i < sizeof(buf); i++) {
num >>= 8;
}
return -1;
return 0;
}
{
return 0;
return -1;
}
return 0;
}
{
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
{
if (!zstream->header_sent) {
if (o_stream_zlib_send_gz_header(zstream) < 0)
return -1;
}
/* previous block was compressed. send it and start
compression for a new block. */
return -1;
if (ret == 0) {
/* parent stream's buffer full */
break;
}
}
switch (ret) {
case Z_OK:
case Z_BUF_ERROR:
break;
case Z_STREAM_ERROR:
i_panic("zlib.write(%s) failed: Can't write more data to .gz after flushing",
default:
i_panic("zlib.write(%s) failed with unexpected code %d",
}
}
return size;
}
static int
{
return 0;
return ret;
if (!zstream->header_sent) {
if (o_stream_zlib_send_gz_header(zstream) < 0)
return -1;
}
return ret;
do {
if (len != 0) {
return ret;
if (done)
break;
}
case Z_OK:
case Z_BUF_ERROR:
break;
case Z_STREAM_END:
break;
default:
i_unreached();
}
if (final) {
if (o_stream_zlib_send_gz_trailer(zstream) < 0)
return -1;
}
return 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;
}
return -1;
}
/* 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;
}
{
hdr[0] = 0x1f;
(strategy >= Z_HUFFMAN_ONLY ||
}
static struct ostream *
{
int ret;
if (!gz)
switch (ret) {
case Z_OK:
break;
case Z_MEM_ERROR:
case Z_VERSION_ERROR:
i_fatal("Wrong zlib library version (broken compilation)");
case Z_STREAM_ERROR:
default:
}
}
{
}
{
}
#endif