istream-zlib.h \
ostream-zlib.h
+noinst_HEADERS = \
+ iostream-zstd-private.h
+
pkglib_LTLIBRARIES = libdovecot-compression.la
libdovecot_compression_la_SOURCES =
libdovecot_compression_la_LIBADD = libcompression.la ../lib-dovecot/libdovecot.la $(COMPRESS_LIBS)
--- /dev/null
+#ifndef IOSTREAM_ZSTD_PRIVATE_H
+#define IOSTREAM_ZSTD_PRIVATE_H 1
+
+/* a horrible hack to fix issues when the installed libzstd is lot
+ newer than what we were compiled against. */
+static inline ZSTD_ErrorCode zstd_version_errcode(ZSTD_ErrorCode err)
+{
+#if ZSTD_VERSION_NUMBER < 10301
+ if (ZSTD_versionNumber() > 10300) {
+ /* reinterpret them */
+ if (err == 10)
+ return ZSTD_error_prefix_unknown;
+ if (err == 32)
+ return ZSTD_error_dictionary_wrong;
+ if (err == 62)
+ return ZSTD_error_init_missing;
+ if (err == 64)
+ return ZSTD_error_memory_allocation;
+ return ZSTD_error_GENERIC;
+ }
+#endif
+ return err;
+}
+
+#endif
#include "zstd.h"
#include "zstd_errors.h"
+#include "iostream-zstd-private.h"
#ifndef HAVE_ZSTD_GETERRORCODE
ZSTD_ErrorCode ZSTD_getErrorCode(size_t functionResult)
static void i_stream_zstd_read_error(struct zstd_istream *zstream, size_t err)
{
- ZSTD_ErrorCode errcode = ZSTD_getErrorCode(err);
+ ZSTD_ErrorCode errcode = zstd_version_errcode(ZSTD_getErrorCode(err));
const char *error = ZSTD_getErrorName(err);
if (errcode == ZSTD_error_memory_allocation)
i_fatal_status(FATAL_OUTOFMEM, "zstd.read(%s): Out of memory",
#include "zstd.h"
#include "zstd_errors.h"
+#include "iostream-zstd-private.h"
struct zstd_ostream {
struct ostream_private ostream;
static void o_stream_zstd_write_error(struct zstd_ostream *zstream, size_t err)
{
- ZSTD_ErrorCode errcode = ZSTD_getErrorCode(err);
+ ZSTD_ErrorCode errcode = zstd_version_errcode(ZSTD_getErrorCode(err));
const char *error = ZSTD_getErrorName(err);
if (errcode == ZSTD_error_memory_allocation)
i_fatal_status(FATAL_OUTOFMEM, "zstd.write(%s): Out of memory",