/* Copyright (c) 2010-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#ifdef HAVE_LZMA
#include "ostream-private.h"
#include "ostream-zlib.h"
#include <lzma.h>
struct lzma_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;
}
}
switch (ret) {
case LZMA_OK:
break;
case LZMA_MEM_ERROR:
"lzma.write(%s): Out of memory",
default:
i_panic("lzma.write(%s) failed with unexpected code %d",
}
}
return size;
}
{
int ret;
return 0;
return ret;
return ret;
do {
switch (ret) {
case LZMA_OK:
break;
case LZMA_STREAM_END:
break;
case LZMA_MEM_ERROR:
"lzma.write(%s): Out of memory",
default:
i_panic("lzma.write(%s) flush failed with unexpected code %d",
}
return ret;
}
} while (!done);
return 0;
}
{
if (o_stream_lzma_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;
}
{
switch (ret) {
case LZMA_OK:
break;
case LZMA_MEM_ERROR:
case LZMA_OPTIONS_ERROR:
i_fatal("lzma: Invalid level");
default:
}
}
#endif