zlibWrapper: support for zlib versions from 1.2.3 to 1.2.8
diff --git a/.travis.yml b/.travis.yml
index e6a32c2..41f67c7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,6 +22,9 @@
     - os: linux
       sudo: false
       env: PLATFORM="Ubuntu 12.04 container" MAKE_PARAM=asan
+    - os: linux
+      sudo: false
+      env: PLATFORM="Ubuntu 12.04 container" MAKE_PARAM=zlibwrapper
     # Standard Ubuntu 12.04 LTS Server Edition 64 bit
     - os: linux
       sudo: required
@@ -53,15 +56,6 @@
     - os: linux
       sudo: required
       env: PLATFORM="Ubuntu 12.04" MAKE_PARAM="-C programs valgrindTest"
-    - os: linux
-      sudo: required
-      env: PLATFORM="Ubuntu 12.04" MAKE_PARAM=gnu90test
-    - os: linux
-      sudo: required
-      env: PLATFORM="Ubuntu 12.04" MAKE_PARAM=c99test
-    #- os: linux
-    #  sudo: required
-    #  env: PLATFORM="Ubuntu 12.04" MAKE_PARAM=zlibwrapper
     # Ubuntu 14.04 LTS Server Edition 64 bit
     - os: linux
       dist: trusty
diff --git a/zlibWrapper/Makefile b/zlibWrapper/Makefile
index 3f293cd..6c00622 100644
--- a/zlibWrapper/Makefile
+++ b/zlibWrapper/Makefile
@@ -7,8 +7,9 @@
 
 # Paths to static and dynamic zlib and zstd libraries
 ifneq (,$(filter Windows%,$(OS)))
-STATICLIB = ../../zlib/libz.a ../lib/libzstd.a
-IMPLIB    = ../../zlib/libz.dll.a ../lib/libzstd.a
+ZLIBDIR = ../../zlib1.2.8
+STATICLIB = $(ZLIBDIR)/libz.a ../lib/libzstd.a
+IMPLIB    = $(ZLIBDIR)/libz.dll.a ../lib/libzstd.a
 else
 STATICLIB = -static -lz ../lib/libzstd.a
 IMPLIB    = -lz ../lib/libzstd.a
@@ -17,12 +18,12 @@
 ZLIBWRAPPER_PATH = .
 EXAMPLE_PATH = examples
 CC = gcc
-CFLAGS = $(LOC) -I../lib/common -I$(ZLIBWRAPPER_PATH) -O3 -Wall -std=gnu89
+CFLAGS = $(LOC) -I../lib/common -I$(ZLIBDIR) -I$(ZLIBWRAPPER_PATH) -O3 -Wall -std=gnu89
 LDFLAGS = $(LOC)
 RM = rm -f
 
 
-all: clean test testdll testzstd
+all: clean test testzstd
 
 test: example
 	./example
diff --git a/zlibWrapper/zstd_zlibwrapper.c b/zlibWrapper/zstd_zlibwrapper.c
index 7ec68a4..c9a8b1d 100644
--- a/zlibWrapper/zstd_zlibwrapper.c
+++ b/zlibWrapper/zstd_zlibwrapper.c
@@ -31,6 +31,7 @@
 
 #include <stdio.h>           /* fprintf */
 #include <stdlib.h>          /* malloc */
+#include <stdarg.h>          /* va_list */
 #include <zlib.h>
 #include "zstd_zlibwrapper.h"
 #include "zstd.h"
@@ -492,6 +493,7 @@
 }
 
 
+#if ZLIB_VERNUM >= 0x1260
 ZEXTERN int ZEXPORT z_deflatePending OF((z_streamp strm,
                                        unsigned *pending,
                                        int *bits))
@@ -500,6 +502,7 @@
         return deflatePending(strm, pending, bits);
     FINISH_WITH_ERR("deflatePending is not supported!");
 }
+#endif
 
 
 ZEXTERN int ZEXPORT z_deflatePrime OF((z_streamp strm,
@@ -524,6 +527,7 @@
 
 
 /* Advanced compression functions */
+#if ZLIB_VERNUM >= 0x1280
 ZEXTERN int ZEXPORT z_inflateGetDictionary OF((z_streamp strm,
                                              Bytef *dictionary,
                                              uInt  *dictLength))
@@ -532,7 +536,7 @@
         return inflateGetDictionary(strm, dictionary, dictLength);
     FINISH_WITH_ERR("inflateGetDictionary is not supported!");
 }
-
+#endif
 
 
 ZEXTERN int ZEXPORT z_inflateCopy OF((z_streamp dest,
@@ -552,6 +556,7 @@
 }
 
 
+#if ZLIB_VERNUM >= 0x1240
 ZEXTERN int ZEXPORT z_inflateReset2 OF((z_streamp strm,
                                       int windowBits))
 {
@@ -559,6 +564,17 @@
         return inflateReset2(strm, windowBits);
     FINISH_WITH_ERR("inflateReset2 is not supported!");
 }
+#endif
+
+
+#if ZLIB_VERNUM >= 0x1240
+ZEXTERN long ZEXPORT z_inflateMark OF((z_streamp strm))
+{
+    if (!strm->reserved)
+        return inflateMark(strm);
+    FINISH_WITH_ERR("inflateMark is not supported!");
+}
+#endif
 
 
 ZEXTERN int ZEXPORT z_inflatePrime OF((z_streamp strm,
@@ -571,14 +587,6 @@
 }
 
 
-ZEXTERN long ZEXPORT z_inflateMark OF((z_streamp strm))
-{
-    if (!strm->reserved)
-        return inflateMark(strm);
-    FINISH_WITH_ERR("inflateMark is not supported!");
-}
-
-
 ZEXTERN int ZEXPORT z_inflateGetHeader OF((z_streamp strm,
                                          gz_headerp head))
 {
@@ -699,6 +707,7 @@
 }
 
 
+#if ZLIB_VERNUM >= 0x1240
 ZEXTERN int ZEXPORT z_gzbuffer OF((gzFile file, unsigned size))
 {
     if (!g_useZSTD)
@@ -707,6 +716,31 @@
 }
 
 
+ZEXTERN z_off_t ZEXPORT z_gzoffset OF((gzFile file))
+{
+    if (!g_useZSTD)
+        return gzoffset(file);
+    FINISH_WITH_ERR("gzoffset is not supported!");
+}
+
+
+ZEXTERN int ZEXPORT z_gzclose_r OF((gzFile file))
+{
+    if (!g_useZSTD)
+        return gzclose_r(file);
+    FINISH_WITH_ERR("gzclose_r is not supported!");
+}
+
+
+ZEXTERN int ZEXPORT z_gzclose_w OF((gzFile file))
+{
+    if (!g_useZSTD)
+        return gzclose_w(file);
+    FINISH_WITH_ERR("gzclose_w is not supported!");
+}
+#endif
+
+
 ZEXTERN int ZEXPORT z_gzsetparams OF((gzFile file, int level, int strategy))
 {
     if (!g_useZSTD)
@@ -732,7 +766,11 @@
 }
 
 
+#if ZLIB_VERNUM >= 0x1260
 ZEXTERN int ZEXPORTVA z_gzprintf Z_ARG((gzFile file, const char *format, ...))
+#else
+ZEXTERN int ZEXPORTVA z_gzprintf OF((gzFile file, const char *format, ...))
+#endif
 {
     if (!g_useZSTD) {
         int ret;
@@ -774,7 +812,11 @@
 }
 
 
+#if ZLIB_VERNUM == 0x1260
+ZEXTERN int ZEXPORT z_gzgetc_ OF((gzFile file))
+#else
 ZEXTERN int ZEXPORT z_gzgetc OF((gzFile file))
+#endif
 {
     if (!g_useZSTD)
         return gzgetc(file);
@@ -822,14 +864,6 @@
 }
 
 
-ZEXTERN z_off_t ZEXPORT z_gzoffset OF((gzFile file))
-{
-    if (!g_useZSTD)
-        return gzoffset(file);
-    FINISH_WITH_ERR("gzoffset is not supported!");
-}
-
-
 ZEXTERN int ZEXPORT z_gzeof OF((gzFile file))
 {
     if (!g_useZSTD)
@@ -854,22 +888,6 @@
 }
 
 
-ZEXTERN int ZEXPORT z_gzclose_r OF((gzFile file))
-{
-    if (!g_useZSTD)
-        return gzclose_r(file);
-    FINISH_WITH_ERR("gzclose_r is not supported!");
-}
-
-
-ZEXTERN int ZEXPORT z_gzclose_w OF((gzFile file))
-{
-    if (!g_useZSTD)
-        return gzclose_w(file);
-    FINISH_WITH_ERR("gzclose_w is not supported!");
-}
-
-
 ZEXTERN const char * ZEXPORT z_gzerror OF((gzFile file, int *errnum))
 {
     if (!g_useZSTD)
diff --git a/zlibWrapper/zstd_zlibwrapper.h b/zlibWrapper/zstd_zlibwrapper.h
index c2c908d..e438789 100644
--- a/zlibWrapper/zstd_zlibwrapper.h
+++ b/zlibWrapper/zstd_zlibwrapper.h
@@ -41,7 +41,11 @@
 #include <zlib.h>
 
 #if !defined(z_const)
-#  define z_const const 
+#if ZLIB_VERNUM >= 0x1260
+    #define z_const const 
+#else
+    #define z_const
+#endif
 #endif
 
 void useZSTD(int turn_on);