summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime/zlibw.c10
-rw-r--r--runtime/zlibw.h1
-rw-r--r--tools/omfile.c30
3 files changed, 36 insertions, 5 deletions
diff --git a/runtime/zlibw.c b/runtime/zlibw.c
index 95ac9138..2b386213 100644
--- a/runtime/zlibw.c
+++ b/runtime/zlibw.c
@@ -51,9 +51,9 @@ static int myDeflateInit(z_streamp strm, int level)
return deflateInit(strm, level);
}
-static int myDeflate(z_streamp strm, int flush)
+static int myDeflateInit2(z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy)
{
- return deflate(strm, flush);
+ return deflateInit2(strm, level, method, windowBits, memLevel, strategy);
}
static int myDeflateEnd(z_streamp strm)
@@ -61,6 +61,11 @@ static int myDeflateEnd(z_streamp strm)
return deflateEnd(strm);
}
+static int myDeflate(z_streamp strm, int flush)
+{
+ return deflate(strm, flush);
+}
+
/* queryInterface function
* rgerhards, 2008-03-05
@@ -77,6 +82,7 @@ CODESTARTobjQueryInterface(zlibw)
* of course, also affects the "if" above).
*/
pIf->DeflateInit = myDeflateInit;
+ pIf->DeflateInit2 = myDeflateInit2;
pIf->Deflate = myDeflate;
pIf->DeflateEnd = myDeflateEnd;
finalize_it:
diff --git a/runtime/zlibw.h b/runtime/zlibw.h
index 01e0b054..63d8f386 100644
--- a/runtime/zlibw.h
+++ b/runtime/zlibw.h
@@ -30,6 +30,7 @@
/* interfaces */
BEGINinterface(zlibw) /* name must also be changed in ENDinterface macro! */
int (*DeflateInit)(z_streamp strm, int);
+ int (*DeflateInit2)(z_streamp strm, int level, int method, int windowBits, int memLevel, int strategy);
int (*Deflate)(z_streamp strm, int);
int (*DeflateEnd)(z_streamp strm);
ENDinterface(zlibw)
diff --git a/tools/omfile.c b/tools/omfile.c
index 62a044d8..08c33a7f 100644
--- a/tools/omfile.c
+++ b/tools/omfile.c
@@ -14,6 +14,29 @@
*
* Copyright 2007-2009 Rainer Gerhards and Adiscon GmbH.
*
+ * An important note on writing gzip format via zlib (kept anonymous
+ * by request):
+ *
+ * --------------------------------------------------------------------------
+ * We'd like to make sure the output file is in full gzip format
+ * (compatible with gzip -d/zcat etc). There is a flag in how the output
+ * is initialized within zlib to properly add the gzip wrappers to the
+ * output. (gzip is effectively a small metadata wrapper around raw
+ * zstream output.)
+ *
+ * I had written an old bit of code to do this - the documentation on
+ * deflatInit2() was pretty tricky to nail down on this specific feature:
+ *
+ * int deflateInit2 (z_streamp strm, int level, int method, int windowBits,
+ * int memLevel, int strategy);
+ *
+ * I believe "31" would be the value for the "windowBits" field that you'd
+ * want to try:
+ *
+ * deflateInit2(zstrmptr, 6, Z_DEFLATED, 31, 9, Z_DEFAULT_STRATEGY);
+ * --------------------------------------------------------------------------
+ *
+ *
* This file is part of rsyslog.
*
* Rsyslog is free software: you can redistribute it and/or modify
@@ -698,12 +721,13 @@ doZipWrite(instanceData *pData)
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
- zRet = zlibw.DeflateInit(&strm, 9);
+ /* see note in file header for the params we use with deflateInit2() */
+ zRet = zlibw.DeflateInit2(&strm, 9, Z_DEFLATED, 31, 9, Z_DEFAULT_STRATEGY);
if(zRet != Z_OK) {
- dbgprintf("error %d returned from zlib/deflateInit()\n", zRet);
+ dbgprintf("error %d returned from zlib/deflateInit2()\n", zRet);
ABORT_FINALIZE(RS_RET_ZLIB_ERR);
}
-RUNLOG_STR("deflateInit() done successfully\n");
+RUNLOG_STR("deflateInit2() done successfully\n");
/* now doing the compression */
strm.avail_in = poBuf->iBuf;