diff --git a/.gitignore b/.gitignore index d4afda15..257e4df2 100644 --- a/.gitignore +++ b/.gitignore @@ -17,10 +17,12 @@ /example64 /examplesh /libz.so* +/libz-ng.so* /minigzip /minigzip64 /minigzipsh /zlib.pc +/zlib-ng.pc /CVE-2003-0107 .DS_Store @@ -48,6 +50,8 @@ Testing zconf.h zconf.h.cmakein zconf.h.included +zconf-ng.h +zconf-ng.h.cmakein ztest* configure.log diff --git a/CMakeLists.txt b/CMakeLists.txt index b322f20f..07a98e7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,7 +58,7 @@ if (ZLIB_COMPAT) else(ZLIB_COMPAT) set (LIBNAME1 libz-ng) set (LIBNAME2 zlib-ng) - set (SUFFIX -ng) + set (SUFFIX "-ng") endif (ZLIB_COMPAT) option (WITH_GZFILEOP "Compile with support for gzFile related functions" OFF) @@ -553,15 +553,19 @@ endif (WITH_GZFILEOP) if(NOT MINGW AND NOT MSYS) set(ZLIB_DLL_SRCS - win32/zlib1.rc # If present will override custom build rule below. + win32/zlib${SUFFIX}1.rc # If present will override custom build rule below. ) endif() # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib${SUFFIX}.h _zlib_h_contents) -string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" - "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) - +if (ZLIB_COMPAT) + string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" + "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) +else() + string(REGEX REPLACE ".*#define[ \t]+ZLIBNG_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" + "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) +endif() if(MINGW OR MSYS) # This gets us DLL resource information when compiling on MinGW. if(NOT CMAKE_RC_COMPILER) @@ -574,7 +578,7 @@ if(MINGW OR MSYS) -I ${CMAKE_CURRENT_SOURCE_DIR} -I ${CMAKE_CURRENT_BINARY_DIR} -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj - -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) + -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib${SUFFIX}1.rc) set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) endif(MINGW OR MSYS) diff --git a/Makefile.in b/Makefile.in index 5db8b5ff..605f4f11 100644 --- a/Makefile.in +++ b/Makefile.in @@ -109,7 +109,7 @@ $(ARCHDIR)/%.lo: $(SRCDIR)/$(ARCHDIR)/%.c test: all $(MAKE) -C test -infcover.o: $(SRCDIR)/test/infcover.c $(SRCDIR)/zlib.h zconf.h +infcover.o: $(SRCDIR)/test/infcover.c $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/test/infcover.c infcover$(EXE): infcover.o $(STATICLIB) @@ -127,20 +127,20 @@ $(STATICLIB): $(OBJS) $(AR) $(ARFLAGS) $@ $(OBJS) -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 -example.o: $(SRCDIR)/test/example.c $(SRCDIR)/zlib.h zconf.h +example.o: $(SRCDIR)/test/example.c $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/test/example.c -minigzip.o: $(SRCDIR)/test/minigzip.c $(SRCDIR)/zlib.h zconf.h +minigzip.o: $(SRCDIR)/test/minigzip.c $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/test/minigzip.c -example64.o: $(SRCDIR)/test/example.c $(SRCDIR)/zlib.h zconf.h +example64.o: $(SRCDIR)/test/example.c $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 $(INCLUDES) -c -o $@ $(SRCDIR)/test/example.c -minigzip64.o: $(SRCDIR)/test/minigzip.c $(SRCDIR)/zlib.h zconf.h +minigzip64.o: $(SRCDIR)/test/minigzip.c $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 $(INCLUDES) -c -o $@ $(SRCDIR)/test/minigzip.c -zlibrc.o: win32/zlib1.rc - $(RC) $(RCFLAGS) -o $@ win32/zlib1.rc +zlibrc.o: win32/zlib$(SUFFIX)1.rc + $(RC) $(RCFLAGS) -o $@ win32/zlib$(SUFFIX)1.rc .SUFFIXES: .lo @@ -316,60 +316,60 @@ depend: # DO NOT DELETE THIS LINE -- make depend depends on it. -adler32.o: $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h +adler32.o: $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h functable.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h -gzclose.o gzlib.o gzread.o gzwrite.o: $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/gzguts.h -compress.o example.o minigzip.o uncompr.o: $(SRCDIR)/zlib.h zconf.h -crc32.o: $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/crc32.h -deflate.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -deflate_fast.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -deflate_medium.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -deflate_slow.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -infback.o: $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/inffixed.h -inffast.o: $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/memcopy.h -inflate.o: $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/inffixed.h $(SRCDIR)/memcopy.h -inftrees.o: $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/inftrees.h -trees.o: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/trees.h -zutil.o: $(SRCDIR)/zutil.h $(SRCDIR)/gzguts.h $(SRCDIR)/zlib.h zconf.h +gzclose.o gzlib.o gzread.o gzwrite.o: $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(SRCDIR)/gzguts.h +compress.o example.o minigzip.o uncompr.o: $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +crc32.o: $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(SRCDIR)/crc32.h +deflate.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +deflate_fast.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +deflate_medium.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +deflate_slow.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +infback.o: $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/inffixed.h +inffast.o: $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/memcopy.h +inflate.o: $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/inffixed.h $(SRCDIR)/memcopy.h +inftrees.o: $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(SRCDIR)/inftrees.h +trees.o: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(SRCDIR)/trees.h +zutil.o: $(SRCDIR)/zutil.h $(SRCDIR)/gzguts.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h arch/aarch64/adler32_neon.o: $(SRCDIR)/arch/aarch64/adler32_neon.h arch/aarch64/crc32_acle.o: zconf.h -arch/aarch64/fill_window_arm.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -arch/aarch64/insert_string_acle.o: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h +arch/aarch64/fill_window_arm.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +arch/aarch64/insert_string_acle.o: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h arch/arm/adler32_neon.o: $(SRCDIR)/arch/arm/adler32_neon.h arch/arm/crc32_acle.o: zconf.h -arch/arm/fill_window_arm.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -arch/arm/insert_string_acle.o: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -arch/x86/crc_folding.o: $(SRCDIR)/arch/x86/crc_folding.h $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -arch/x86/crc_pclmulqdq.o: $(SRCDIR)/arch/x86/x86.h $(SRCDIR)/arch/x86/crc_folding.h $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -arch/x86/deflate_quick.o: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -arch/x86/fill_window_sse.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h +arch/arm/fill_window_arm.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +arch/arm/insert_string_acle.o: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +arch/x86/crc_folding.o: $(SRCDIR)/arch/x86/crc_folding.h $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +arch/x86/crc_pclmulqdq.o: $(SRCDIR)/arch/x86/x86.h $(SRCDIR)/arch/x86/crc_folding.h $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +arch/x86/deflate_quick.o: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +arch/x86/fill_window_sse.o: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h arch/x86/x86.o: $(SRCDIR)/arch/x86/x86.h -adler32.lo: $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h +adler32.lo: $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h functable.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h -gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/gzguts.h -compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)/zlib.h zconf.h -crc32.lo: $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/crc32.h -deflate.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -deflate_fast.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -deflate_medium.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -deflate_slow.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -infback.lo: $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/inffixed.h -inffast.lo: $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/memcopy.h -inflate.lo: $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/inffixed.h $(SRCDIR)/memcopy.h -inftrees.lo: $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/inftrees.h -trees.lo: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/trees.h -zutil.lo: $(SRCDIR)/zutil.h $(SRCDIR)/gzguts.h $(SRCDIR)/zlib.h zconf.h +gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(SRCDIR)/gzguts.h +compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +crc32.lo: $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(SRCDIR)/crc32.h +deflate.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +deflate_fast.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +deflate_medium.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +deflate_slow.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/match.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +infback.lo: $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/inffixed.h +inffast.lo: $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/memcopy.h +inflate.lo: $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/inffixed.h $(SRCDIR)/memcopy.h +inftrees.lo: $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(SRCDIR)/inftrees.h +trees.lo: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h $(SRCDIR)/trees.h +zutil.lo: $(SRCDIR)/zutil.h $(SRCDIR)/gzguts.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h arch/aarch64/adler32_neon.lo: $(SRCDIR)/arch/aarch64/adler32_neon.h arch/aarch64/crc32_acle.lo: zconf.h -arch/aarch64/fill_window_arm.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -arch/aarch64/insert_string_acle.lo: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h +arch/aarch64/fill_window_arm.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +arch/aarch64/insert_string_acle.lo: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h arch/arm/adler32_neon.lo: $(SRCDIR)/arch/arm/adler32_neon.h arch/arm/crc32_acle.lo: zconf.h -arch/arm/fill_window_arm.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -arch/arm/insert_string_acle.lo: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -arch/x86/crc_folding.lo: $(SRCDIR)/arch/x86/crc_folding.h $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -arch/x86/crc_pclmulqdq.lo: $(SRCDIR)/arch/x86/x86.h $(SRCDIR)/arch/x86/crc_folding.h $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -arch/x86/deflate_quick.lo: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h -arch/x86/fill_window_sse.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h +arch/arm/fill_window_arm.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +arch/arm/insert_string_acle.lo: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +arch/x86/crc_folding.lo: $(SRCDIR)/arch/x86/crc_folding.h $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +arch/x86/crc_pclmulqdq.lo: $(SRCDIR)/arch/x86/x86.h $(SRCDIR)/arch/x86/crc_folding.h $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +arch/x86/deflate_quick.lo: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h +arch/x86/fill_window_sse.lo: $(SRCDIR)/deflate.h $(SRCDIR)/deflate_p.h $(SRCDIR)/functable.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h arch/x86/x86.lo: $(SRCDIR)/arch/x86/x86.h diff --git a/arch/aarch64/Makefile.in b/arch/aarch64/Makefile.in index 1f297231..3c2bebc0 100644 --- a/arch/aarch64/Makefile.in +++ b/arch/aarch64/Makefile.in @@ -6,6 +6,7 @@ CC= CFLAGS= SFLAGS= INCLUDES= +SUFFIX= SRCDIR=. SRCTOP=../.. @@ -55,12 +56,12 @@ depend: # DO NOT DELETE THIS LINE -- make depend depends on it. adler32_neon.o: $(SRCDIR)/adler32_neon.h -crc32_acle.o: $(TOPDIR)/zconf.h -fill_window_arm.o: $(SRCTOP)/deflate.h $(SRCTOP)/deflate_p.h $(SRCTOP)/functable.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h -insert_string_acle.o: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h +crc32_acle.o: $(TOPDIR)/zconf$(SUFFIX).h +fill_window_arm.o: $(SRCTOP)/deflate.h $(SRCTOP)/deflate_p.h $(SRCTOP)/functable.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h +insert_string_acle.o: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h adler32_neon.lo: $(SRCDIR)/adler32_neon.h -crc32_acle.lo: $(TOPDIR)/zconf.h -fill_window_arm.lo: $(SRCTOP)/deflate.h $(SRCTOP)/deflate_p.h $(SRCTOP)/functable.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h -insert_string_acle.lo: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h +crc32_acle.lo: $(TOPDIR)/zconf$(SUFFIX).h +fill_window_arm.lo: $(SRCTOP)/deflate.h $(SRCTOP)/deflate_p.h $(SRCTOP)/functable.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h +insert_string_acle.lo: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h diff --git a/arch/aarch64/fill_window_arm.c b/arch/aarch64/fill_window_arm.c index c409b3cd..e7388a8d 100644 --- a/arch/aarch64/fill_window_arm.c +++ b/arch/aarch64/fill_window_arm.c @@ -14,7 +14,7 @@ #include "deflate_p.h" #include "functable.h" -extern ZLIB_INTERNAL int read_buf(z_stream *strm, unsigned char *buf, unsigned size); +extern ZLIB_INTERNAL int read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size); #if __ARM_NEON #include diff --git a/arch/arm/Makefile.in b/arch/arm/Makefile.in index 1f297231..3c2bebc0 100644 --- a/arch/arm/Makefile.in +++ b/arch/arm/Makefile.in @@ -6,6 +6,7 @@ CC= CFLAGS= SFLAGS= INCLUDES= +SUFFIX= SRCDIR=. SRCTOP=../.. @@ -55,12 +56,12 @@ depend: # DO NOT DELETE THIS LINE -- make depend depends on it. adler32_neon.o: $(SRCDIR)/adler32_neon.h -crc32_acle.o: $(TOPDIR)/zconf.h -fill_window_arm.o: $(SRCTOP)/deflate.h $(SRCTOP)/deflate_p.h $(SRCTOP)/functable.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h -insert_string_acle.o: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h +crc32_acle.o: $(TOPDIR)/zconf$(SUFFIX).h +fill_window_arm.o: $(SRCTOP)/deflate.h $(SRCTOP)/deflate_p.h $(SRCTOP)/functable.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h +insert_string_acle.o: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h adler32_neon.lo: $(SRCDIR)/adler32_neon.h -crc32_acle.lo: $(TOPDIR)/zconf.h -fill_window_arm.lo: $(SRCTOP)/deflate.h $(SRCTOP)/deflate_p.h $(SRCTOP)/functable.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h -insert_string_acle.lo: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h +crc32_acle.lo: $(TOPDIR)/zconf$(SUFFIX).h +fill_window_arm.lo: $(SRCTOP)/deflate.h $(SRCTOP)/deflate_p.h $(SRCTOP)/functable.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h +insert_string_acle.lo: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h diff --git a/arch/arm/fill_window_arm.c b/arch/arm/fill_window_arm.c index d227662a..c27db3c7 100644 --- a/arch/arm/fill_window_arm.c +++ b/arch/arm/fill_window_arm.c @@ -14,7 +14,7 @@ #include "deflate_p.h" #include "functable.h" -extern ZLIB_INTERNAL int read_buf(z_stream *strm, unsigned char *buf, unsigned size); +extern ZLIB_INTERNAL int read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size); #if __ARM_NEON__ #include diff --git a/arch/x86/Makefile.in b/arch/x86/Makefile.in index b8f9259b..7de12bf3 100644 --- a/arch/x86/Makefile.in +++ b/arch/x86/Makefile.in @@ -6,6 +6,7 @@ CC= CFLAGS= SFLAGS= INCLUDES= +SUFFIX= SSE2FLAG=-msse2 SSE4FLAG=-msse4 @@ -70,14 +71,14 @@ depend: # DO NOT DELETE THIS LINE -- make depend depends on it. -crc_folding.o: $(SRCDIR)/crc_folding.h $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h -crc_pclmulqdq.o: $(SRCDIR)/x86.h $(SRCDIR)/crc_folding.h $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h -deflate_quick.o: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h -fill_window_sse.o: $(SRCTOP)/deflate.h $(SRCTOP)/deflate_p.h $(SRCTOP)/functable.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h +crc_folding.o: $(SRCDIR)/crc_folding.h $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h +crc_pclmulqdq.o: $(SRCDIR)/x86.h $(SRCDIR)/crc_folding.h $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h +deflate_quick.o: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h +fill_window_sse.o: $(SRCTOP)/deflate.h $(SRCTOP)/deflate_p.h $(SRCTOP)/functable.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h x86.o: $(SRCDIR)/x86.h -crc_folding.lo: $(SRCDIR)/crc_folding.h $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h -crc_pclmulqdq.lo: $(SRCDIR)/x86.h $(SRCDIR)/crc_folding.h $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h -deflate_quick.lo: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h -fill_window_sse.lo: $(SRCTOP)/deflate.h $(SRCTOP)/deflate_p.h $(SRCTOP)/functable.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib.h $(TOPDIR)/zconf.h +crc_folding.lo: $(SRCDIR)/crc_folding.h $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h +crc_pclmulqdq.lo: $(SRCDIR)/x86.h $(SRCDIR)/crc_folding.h $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h +deflate_quick.lo: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h +fill_window_sse.lo: $(SRCTOP)/deflate.h $(SRCTOP)/deflate_p.h $(SRCTOP)/functable.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h x86.lo: $(SRCDIR)/x86.h diff --git a/arch/x86/crc_pclmulqdq.c b/arch/x86/crc_pclmulqdq.c index a513d6cc..ac0b7eb9 100644 --- a/arch/x86/crc_pclmulqdq.c +++ b/arch/x86/crc_pclmulqdq.c @@ -14,7 +14,7 @@ ZLIB_INTERNAL void crc_reset(deflate_state *const s) { crc_fold_init(s); return; } - s->strm->adler = crc32(0L, NULL, 0); + s->strm->adler = PREFIX(crc32)(0L, NULL, 0); } ZLIB_INTERNAL void crc_finalize(deflate_state *const s) { @@ -22,12 +22,12 @@ ZLIB_INTERNAL void crc_finalize(deflate_state *const s) { s->strm->adler = crc_fold_512to32(s); } -ZLIB_INTERNAL void copy_with_crc(z_stream *strm, unsigned char *dst, unsigned long size) { +ZLIB_INTERNAL void copy_with_crc(PREFIX3(stream) *strm, unsigned char *dst, unsigned long size) { if (x86_cpu_has_pclmulqdq) { crc_fold_copy(strm->state, dst, strm->next_in, size); return; } memcpy(dst, strm->next_in, size); - strm->adler = crc32(strm->adler, dst, size); + strm->adler = PREFIX(crc32)(strm->adler, dst, size); } #endif diff --git a/arch/x86/deflate_quick.c b/arch/x86/deflate_quick.c index 7596f750..2c645b8c 100644 --- a/arch/x86/deflate_quick.c +++ b/arch/x86/deflate_quick.c @@ -28,7 +28,7 @@ #endif extern void fill_window_sse(deflate_state *s); -extern void flush_pending(z_stream *strm); +extern void flush_pending(PREFIX3(stream) *strm); static inline long compare258(const unsigned char *const src0, const unsigned char *const src1) { #ifdef _MSC_VER diff --git a/arch/x86/fill_window_sse.c b/arch/x86/fill_window_sse.c index 11e95f55..7d6f88d5 100644 --- a/arch/x86/fill_window_sse.c +++ b/arch/x86/fill_window_sse.c @@ -15,7 +15,7 @@ #include "deflate_p.h" #include "functable.h" -extern int read_buf(z_stream *strm, unsigned char *buf, unsigned size); +extern int read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size); ZLIB_INTERNAL void fill_window_sse(deflate_state *s) { const __m128i xmm_wsize = _mm_set1_epi16(s->w_size); diff --git a/compress.c b/compress.c index 3c2ebae4..b132357a 100644 --- a/compress.c +++ b/compress.c @@ -25,7 +25,7 @@ */ int ZEXPORT PREFIX(compress2)(unsigned char *dest, size_t *destLen, const unsigned char *source, size_t sourceLen, int level) { - z_stream stream; + PREFIX3(stream) stream; int err; const unsigned int max = (unsigned int)-1; size_t left; @@ -37,7 +37,7 @@ int ZEXPORT PREFIX(compress2)(unsigned char *dest, size_t *destLen, const unsign stream.zfree = NULL; stream.opaque = NULL; - err = deflateInit(&stream, level); + err = PREFIX(deflateInit)(&stream, level); if (err != Z_OK) return err; @@ -55,11 +55,11 @@ int ZEXPORT PREFIX(compress2)(unsigned char *dest, size_t *destLen, const unsign stream.avail_in = sourceLen > (unsigned long)max ? max : (unsigned int)sourceLen; sourceLen -= stream.avail_in; } - err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH); + err = PREFIX(deflate)(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH); } while (err == Z_OK); *destLen = stream.total_out; - deflateEnd(&stream); + PREFIX(deflateEnd)(&stream); return err == Z_STREAM_END ? Z_OK : err; } diff --git a/configure b/configure index 2450264a..98c33a78 100755 --- a/configure +++ b/configure @@ -230,7 +230,7 @@ else fi STATICLIB=${LIBNAME}.a -MAPNAME=$LIBNAME2.map +MAPNAME=${LIBNAME2}.map # extract zlib version numbers from zlib.h if test $compat -eq 0; then @@ -326,7 +326,7 @@ if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then LDSHARED=${LDSHARED-"$cc"} LDSHAREDFLAGS="-shared -Wl,--out-implib,${IMPORTLIB},--version-script,${SRCDIR}/${MAPNAME}" LDSHAREDLIBC="" - DEFFILE='win32/zlib.def' + DEFFILE='win32/${LIBNAME2}.def' RC="${CROSS_PREFIX}windres" RCFLAGS='--define GCC_WINDRES' RCOBJS='zlibrc.o' @@ -349,7 +349,7 @@ if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then LDSHARED=${LDSHARED-"$cc"} LDSHAREDFLAGS="-shared -Wl,--out-implib,${IMPORTLIB}" LDSHAREDLIBC="" - DEFFILE='win32/zlib.def' + DEFFILE='win32/${LIBNAME2}.def' RC="${CROSS_PREFIX}windres" RCFLAGS='--define GCC_WINDRES' RCOBJS='zlibrc.o' @@ -369,7 +369,7 @@ if test "$gcc" -eq 1 && ($cc $CFLAGS -c $test.c) >> configure.log 2>&1; then LDSHARED=${LDSHARED-"$cc"} LDSHAREDFLAGS="-shared -Wl,--out-implib=${IMPORTLIB} -Wl,--version-script=${SRCDIR}/${MAPNAME}" LDSHAREDLIBC="" - DEFFILE='win32/zlib.def' + DEFFILE='win32/${LIBNAME2}.def' RC="${CROSS_PREFIX}windres" RCFLAGS='--define GCC_WINDRES' if [ "$CC" == "mingw32-gcc" ]; then @@ -672,7 +672,7 @@ echo >> configure.log cat > $test.c < #include -#include "zconf.h" +#include "zconf${SUFFIX}.h" int main() { #ifdef STDC return 0; @@ -1048,6 +1048,7 @@ sed < $SRCDIR/$ARCHDIR/Makefile.in " /^SFLAGS *=/s#=.*#=$SFLAGS# /^LDFLAGS *=/s#=.*#=$LDFLAGS# /^INCLUDES *=/s#=.*#=$ARCHINCLUDES# +/^SUFFIX *=/s#=.*#=$SUFFIX# /^SRCDIR *=/s#=.*#=$SRCDIR/$ARCHDIR# /^SRCTOP *=/s#=.*#=$SRCDIR# /^TOPDIR *=/s#=.*#=$BUILDDIR# diff --git a/crc32.c b/crc32.c index ba5babb0..88e4c5b5 100644 --- a/crc32.c +++ b/crc32.c @@ -452,12 +452,12 @@ uint32_t ZEXPORT PREFIX(crc32_combine64)(uint32_t crc1, uint32_t crc2, z_off64_t #ifndef X86_PCLMULQDQ_CRC ZLIB_INTERNAL void crc_reset(deflate_state *const s) { - s->strm->adler = crc32(0L, NULL, 0); + s->strm->adler = PREFIX(crc32)(0L, NULL, 0); } -ZLIB_INTERNAL void copy_with_crc(z_stream *strm, unsigned char *dst, unsigned long size) { +ZLIB_INTERNAL void copy_with_crc(PREFIX3(stream) *strm, unsigned char *dst, unsigned long size) { memcpy(dst, strm->next_in, size); - strm->adler = crc32(strm->adler, dst, size); + strm->adler = PREFIX(crc32)(strm->adler, dst, size); } #endif diff --git a/deflate.c b/deflate.c index 2fcdf9b2..54e84d39 100644 --- a/deflate.c +++ b/deflate.c @@ -69,7 +69,7 @@ const char deflate_copyright[] = " deflate 1.2.11.f Copyright 1995-2016 Jean-lou typedef block_state (*compress_func) (deflate_state *s, int flush); /* Compression function. Returns the block state after the call. */ -static int deflateStateCheck (z_stream *strm); +static int deflateStateCheck (PREFIX3(stream) *strm); static void slide_hash (deflate_state *s); static block_state deflate_stored (deflate_state *s, int flush); ZLIB_INTERNAL block_state deflate_fast (deflate_state *s, int flush); @@ -82,14 +82,14 @@ static block_state deflate_rle (deflate_state *s, int flush); static block_state deflate_huff (deflate_state *s, int flush); static void lm_init (deflate_state *s); static void putShortMSB (deflate_state *s, uint16_t b); -ZLIB_INTERNAL void flush_pending (z_stream *strm); -ZLIB_INTERNAL unsigned read_buf (z_stream *strm, unsigned char *buf, unsigned size); +ZLIB_INTERNAL void flush_pending (PREFIX3(stream) *strm); +ZLIB_INTERNAL unsigned read_buf (PREFIX3(stream) *strm, unsigned char *buf, unsigned size); extern void crc_reset(deflate_state *const s); #ifdef X86_PCLMULQDQ_CRC extern void crc_finalize(deflate_state *const s); #endif -extern void copy_with_crc(z_stream *strm, unsigned char *dst, unsigned long size); +extern void copy_with_crc(PREFIX3(stream) *strm, unsigned char *dst, unsigned long size); /* =========================================================================== * Local data @@ -219,18 +219,18 @@ static void slide_hash(deflate_state *s) { } /* ========================================================================= */ -int ZEXPORT PREFIX(deflateInit_)(z_stream *strm, int level, const char *version, int stream_size) { +int ZEXPORT PREFIX(deflateInit_)(PREFIX3(stream) *strm, int level, const char *version, int stream_size) { return PREFIX(deflateInit2_)(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, version, stream_size); /* Todo: ignore strm->next_in if we use it as window */ } /* ========================================================================= */ -int ZEXPORT PREFIX(deflateInit2_)(z_stream *strm, int level, int method, int windowBits, +int ZEXPORT PREFIX(deflateInit2_)(PREFIX3(stream) *strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size) { unsigned window_padding = 0; deflate_state *s; int wrap = 1; - static const char my_version[] = ZLIB_VERSION; + static const char my_version[] = PREFIX2(VERSION); uint16_t *overlay; /* We overlay pending_buf and d_buf+l_buf. This works since the average @@ -241,7 +241,7 @@ int ZEXPORT PREFIX(deflateInit2_)(z_stream *strm, int level, int method, int win x86_check_features(); #endif - if (version == NULL || version[0] != my_version[0] || stream_size != sizeof(z_stream)) { + if (version == NULL || version[0] != my_version[0] || stream_size != sizeof(PREFIX3(stream))) { return Z_VERSION_ERROR; } if (strm == NULL) @@ -326,7 +326,7 @@ int ZEXPORT PREFIX(deflateInit2_)(z_stream *strm, int level, int method, int win s->pending_buf == NULL) { s->status = FINISH_STATE; strm->msg = ERR_MSG(Z_MEM_ERROR); - deflateEnd(strm); + PREFIX(deflateEnd)(strm); return Z_MEM_ERROR; } s->d_buf = overlay + s->lit_bufsize/sizeof(uint16_t); @@ -337,13 +337,13 @@ int ZEXPORT PREFIX(deflateInit2_)(z_stream *strm, int level, int method, int win s->method = (unsigned char)method; s->block_open = 0; - return deflateReset(strm); + return PREFIX(deflateReset)(strm); } /* ========================================================================= * Check for a valid deflate stream state. Return 0 if ok, 1 if not. */ -static int deflateStateCheck (z_stream *strm) { +static int deflateStateCheck (PREFIX3(stream) *strm) { deflate_state *s; if (strm == NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) @@ -364,7 +364,7 @@ static int deflateStateCheck (z_stream *strm) { } /* ========================================================================= */ -int ZEXPORT PREFIX(deflateSetDictionary)(z_stream *strm, const unsigned char *dictionary, unsigned int dictLength) { +int ZEXPORT PREFIX(deflateSetDictionary)(PREFIX3(stream) *strm, const unsigned char *dictionary, unsigned int dictLength) { deflate_state *s; unsigned int str, n; int wrap; @@ -422,7 +422,7 @@ int ZEXPORT PREFIX(deflateSetDictionary)(z_stream *strm, const unsigned char *di } /* ========================================================================= */ -int ZEXPORT PREFIX(deflateGetDictionary)(z_stream *strm, unsigned char *dictionary, unsigned int *dictLength) { +int ZEXPORT PREFIX(deflateGetDictionary)(PREFIX3(stream) *strm, unsigned char *dictionary, unsigned int *dictLength) { deflate_state *s; unsigned int len; @@ -440,7 +440,7 @@ int ZEXPORT PREFIX(deflateGetDictionary)(z_stream *strm, unsigned char *dictiona } /* ========================================================================= */ -int ZEXPORT PREFIX(deflateResetKeep)(z_stream *strm) { +int ZEXPORT PREFIX(deflateResetKeep)(PREFIX3(stream) *strm) { deflate_state *s; if (deflateStateCheck(strm)) { @@ -478,17 +478,17 @@ int ZEXPORT PREFIX(deflateResetKeep)(z_stream *strm) { } /* ========================================================================= */ -int ZEXPORT PREFIX(deflateReset)(z_stream *strm) { +int ZEXPORT PREFIX(deflateReset)(PREFIX3(stream) *strm) { int ret; - ret = deflateResetKeep(strm); + ret = PREFIX(deflateResetKeep)(strm); if (ret == Z_OK) lm_init(strm->state); return ret; } /* ========================================================================= */ -int ZEXPORT PREFIX(deflateSetHeader)(z_stream *strm, gz_headerp head) { +int ZEXPORT PREFIX(deflateSetHeader)(PREFIX3(stream) *strm, PREFIX(gz_headerp) head) { if (deflateStateCheck(strm) || strm->state->wrap != 2) return Z_STREAM_ERROR; strm->state->gzhead = head; @@ -496,7 +496,7 @@ int ZEXPORT PREFIX(deflateSetHeader)(z_stream *strm, gz_headerp head) { } /* ========================================================================= */ -int ZEXPORT PREFIX(deflatePending)(z_stream *strm, uint32_t *pending, int *bits) { +int ZEXPORT PREFIX(deflatePending)(PREFIX3(stream) *strm, uint32_t *pending, int *bits) { if (deflateStateCheck(strm)) return Z_STREAM_ERROR; if (pending != NULL) @@ -507,7 +507,7 @@ int ZEXPORT PREFIX(deflatePending)(z_stream *strm, uint32_t *pending, int *bits) } /* ========================================================================= */ -int ZEXPORT PREFIX(deflatePrime)(z_stream *strm, int bits, int value) { +int ZEXPORT PREFIX(deflatePrime)(PREFIX3(stream) *strm, int bits, int value) { deflate_state *s; int put; @@ -530,7 +530,7 @@ int ZEXPORT PREFIX(deflatePrime)(z_stream *strm, int bits, int value) { } /* ========================================================================= */ -int ZEXPORT PREFIX(deflateParams)(z_stream *strm, int level, int strategy) { +int ZEXPORT PREFIX(deflateParams)(PREFIX3(stream) *strm, int level, int strategy) { deflate_state *s; compress_func func; @@ -547,7 +547,7 @@ int ZEXPORT PREFIX(deflateParams)(z_stream *strm, int level, int strategy) { if ((strategy != s->strategy || func != configuration_table[level].func) && s->high_water) { /* Flush the last buffer: */ - int err = deflate(strm, Z_BLOCK); + int err = PREFIX(deflate)(strm, Z_BLOCK); if (err == Z_STREAM_ERROR) return err; if (strm->avail_out == 0) @@ -573,7 +573,7 @@ int ZEXPORT PREFIX(deflateParams)(z_stream *strm, int level, int strategy) { } /* ========================================================================= */ -int ZEXPORT PREFIX(deflateTune)(z_stream *strm, int good_length, int max_lazy, int nice_length, int max_chain) { +int ZEXPORT PREFIX(deflateTune)(PREFIX3(stream) *strm, int good_length, int max_lazy, int nice_length, int max_chain) { deflate_state *s; if (deflateStateCheck(strm)) @@ -603,7 +603,7 @@ int ZEXPORT PREFIX(deflateTune)(z_stream *strm, int good_length, int max_lazy, i * upper bound of about 14% expansion does not seem onerous for output buffer * allocation. */ -unsigned long ZEXPORT PREFIX(deflateBound)(z_stream *strm, unsigned long sourceLen) { +unsigned long ZEXPORT PREFIX(deflateBound)(PREFIX3(stream) *strm, unsigned long sourceLen) { deflate_state *s; unsigned long complen, wraplen; @@ -676,7 +676,7 @@ static void putShortMSB(deflate_state *s, uint16_t b) { * applications may wish to modify it to avoid allocating a large * strm->next_out buffer and copying into it. (See also read_buf()). */ -ZLIB_INTERNAL void flush_pending(z_stream *strm) { +ZLIB_INTERNAL void flush_pending(PREFIX3(stream) *strm) { uint32_t len; deflate_state *s = strm->state; @@ -704,11 +704,11 @@ ZLIB_INTERNAL void flush_pending(z_stream *strm) { #define HCRC_UPDATE(beg) \ do { \ if (s->gzhead->hcrc && s->pending > (beg)) \ - strm->adler = crc32(strm->adler, s->pending_buf + (beg), s->pending - (beg)); \ + strm->adler = PREFIX(crc32)(strm->adler, s->pending_buf + (beg), s->pending - (beg)); \ } while (0) /* ========================================================================= */ -int ZEXPORT PREFIX(deflate)(z_stream *strm, int flush) { +int ZEXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int flush) { int old_flush; /* value of flush param for previous deflate call */ deflate_state *s; @@ -836,7 +836,7 @@ int ZEXPORT PREFIX(deflate)(z_stream *strm, int flush) { put_byte(s, (s->gzhead->extra_len >> 8) & 0xff); } if (s->gzhead->hcrc) - strm->adler = crc32(strm->adler, s->pending_buf, s->pending); + strm->adler = PREFIX(crc32)(strm->adler, s->pending_buf, s->pending); s->gzindex = 0; s->status = EXTRA_STATE; } @@ -1025,7 +1025,7 @@ int ZEXPORT PREFIX(deflate)(z_stream *strm, int flush) { } /* ========================================================================= */ -int ZEXPORT PREFIX(deflateEnd)(z_stream *strm) { +int ZEXPORT PREFIX(deflateEnd)(PREFIX3(stream) *strm) { int status; if (deflateStateCheck(strm)) @@ -1048,7 +1048,7 @@ int ZEXPORT PREFIX(deflateEnd)(z_stream *strm) { /* ========================================================================= * Copy the source state to the destination state. */ -int ZEXPORT PREFIX(deflateCopy)(z_stream *dest, z_stream *source) { +int ZEXPORT PREFIX(deflateCopy)(PREFIX3(stream) *dest, PREFIX3(stream) *source) { deflate_state *ds; deflate_state *ss; uint16_t *overlay; @@ -1059,7 +1059,7 @@ int ZEXPORT PREFIX(deflateCopy)(z_stream *dest, z_stream *source) { ss = source->state; - memcpy((void *)dest, (void *)source, sizeof(z_stream)); + memcpy((void *)dest, (void *)source, sizeof(PREFIX3(stream))); ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); if (ds == NULL) @@ -1075,7 +1075,7 @@ int ZEXPORT PREFIX(deflateCopy)(z_stream *dest, z_stream *source) { ds->pending_buf = (unsigned char *) overlay; if (ds->window == NULL || ds->prev == NULL || ds->head == NULL || ds->pending_buf == NULL) { - deflateEnd(dest); + PREFIX(deflateEnd)(dest); return Z_MEM_ERROR; } @@ -1102,7 +1102,7 @@ int ZEXPORT PREFIX(deflateCopy)(z_stream *dest, z_stream *source) { * allocating a large strm->next_in buffer and copying from it. * (See also flush_pending()). */ -ZLIB_INTERNAL unsigned read_buf(z_stream *strm, unsigned char *buf, unsigned size) { +ZLIB_INTERNAL unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) { uint32_t len = strm->avail_in; if (len > size) diff --git a/deflate.h b/deflate.h index 3d707eed..4ea90606 100644 --- a/deflate.h +++ b/deflate.h @@ -103,17 +103,17 @@ typedef unsigned IPos; */ typedef struct internal_state { - z_stream *strm; /* pointer back to this zlib stream */ - int status; /* as the name implies */ - unsigned char *pending_buf; /* output still pending */ - unsigned long pending_buf_size; /* size of pending_buf */ - unsigned char *pending_out; /* next pending byte to output to the stream */ - uint32_t pending; /* nb of bytes in the pending buffer */ - int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ - gz_headerp gzhead; /* gzip header information to write */ - uint32_t gzindex; /* where in extra, name, or comment */ - unsigned char method; /* can only be DEFLATED */ - int last_flush; /* value of flush param for previous deflate call */ + PREFIX3(stream) *strm; /* pointer back to this zlib stream */ + int status; /* as the name implies */ + unsigned char *pending_buf; /* output still pending */ + unsigned long pending_buf_size; /* size of pending_buf */ + unsigned char *pending_out; /* next pending byte to output to the stream */ + uint32_t pending; /* nb of bytes in the pending buffer */ + int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ + PREFIX(gz_headerp) gzhead; /* gzip header information to write */ + uint32_t gzindex; /* where in extra, name, or comment */ + unsigned char method; /* can only be DEFLATED */ + int last_flush; /* value of flush param for previous deflate call */ #ifdef X86_PCLMULQDQ_CRC unsigned ALIGNED_(16) crc0[4 * 5]; diff --git a/deflate_p.h b/deflate_p.h index f5e8e4cb..02fbf66c 100644 --- a/deflate_p.h +++ b/deflate_p.h @@ -20,7 +20,7 @@ void check_match(deflate_state *s, IPos start, IPos match, int length); #else #define check_match(s, start, match, length) #endif -void flush_pending(z_stream *strm); +void flush_pending(PREFIX3(stream) *strm); /* =========================================================================== * Insert string str in the dictionary and set match_head to the previous head diff --git a/gzclose.c b/gzclose.c index 0f4c5794..12f34c5d 100644 --- a/gzclose.c +++ b/gzclose.c @@ -16,8 +16,8 @@ int ZEXPORT PREFIX(gzclose)(gzFile file) { return Z_STREAM_ERROR; state = (gz_state *)file; - return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); + return state->mode == GZ_READ ? PREFIX(gzclose_r)(file) : PREFIX(gzclose_w)(file); #else - return gzclose_r(file); + return PREFIX(gzclose_r)(file); #endif } diff --git a/gzlib.c b/gzlib.c index 045a7636..7b0e136e 100644 --- a/gzlib.c +++ b/gzlib.c @@ -331,7 +331,7 @@ z_off64_t ZEXPORT PREFIX(gzseek64)(gzFile file, z_off64_t offset, int whence) { offset += state->x.pos; if (offset < 0) /* before start of file! */ return -1; - if (gzrewind(file) == -1) /* rewind, then skip to offset */ + if (PREFIX(gzrewind)(file) == -1) /* rewind, then skip to offset */ return -1; } @@ -356,7 +356,7 @@ z_off64_t ZEXPORT PREFIX(gzseek64)(gzFile file, z_off64_t offset, int whence) { z_off_t ZEXPORT PREFIX(gzseek)(gzFile file, z_off_t offset, int whence) { z_off64_t ret; - ret = gzseek64(file, (z_off64_t)offset, whence); + ret = PREFIX(gzseek64)(file, (z_off64_t)offset, whence); return ret == (z_off_t)ret ? (z_off_t)ret : -1; } @@ -379,7 +379,7 @@ z_off64_t ZEXPORT PREFIX(gztell64)(gzFile file) { z_off_t ZEXPORT PREFIX(gztell)(gzFile file) { z_off64_t ret; - ret = gztell64(file); + ret = PREFIX(gztell64)(file); return ret == (z_off_t)ret ? (z_off_t)ret : -1; } @@ -408,7 +408,7 @@ z_off64_t ZEXPORT PREFIX(gzoffset64)(gzFile file) { z_off_t ZEXPORT PREFIX(gzoffset)(gzFile file) { z_off64_t ret; - ret = gzoffset64(file); + ret = PREFIX(gzoffset64)(file); return ret == (z_off_t)ret ? (z_off_t)ret : -1; } diff --git a/gzread.c b/gzread.c index d2ba0787..47f2f752 100644 --- a/gzread.c +++ b/gzread.c @@ -98,7 +98,7 @@ static int gz_look(gz_state *state) { state->strm.opaque = NULL; state->strm.avail_in = 0; state->strm.next_in = NULL; - if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) { /* gunzip */ + if (PREFIX(inflateInit2)(&(state->strm), 15 + 16) != Z_OK) { /* gunzip */ free(state->out); free(state->in); state->size = 0; @@ -124,7 +124,7 @@ static int gz_look(gz_state *state) { single byte is sufficient indication that it is not a gzip file) */ if (strm->avail_in > 1 && strm->next_in[0] == 31 && strm->next_in[1] == 139) { - inflateReset(strm); + PREFIX(inflateReset)(strm); state->how = GZIP; state->direct = 0; return 0; @@ -175,7 +175,7 @@ static int gz_decomp(gz_state *state) { } /* decompress and handle errors */ - ret = inflate(strm, Z_NO_FLUSH); + ret = PREFIX(inflate)(strm, Z_NO_FLUSH); if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) { gz_error(state, Z_STREAM_ERROR, "internal error: inflate stream corrupt"); return -1; @@ -432,7 +432,7 @@ int ZEXPORT PREFIX(gzgetc)(gzFile file) { } int ZEXPORT PREFIX(gzgetc_)(gzFile file) { - return gzgetc(file); + return PREFIX(gzgetc)(file); } /* -- see zlib.h -- */ @@ -586,7 +586,7 @@ int ZEXPORT PREFIX(gzclose_r)(gzFile file) { /* free memory and close file */ if (state->size) { - inflateEnd(&(state->strm)); + PREFIX(inflateEnd)(&(state->strm)); free(state->out); free(state->in); } diff --git a/gzwrite.c b/gzwrite.c index 7ea1725e..f07dc1af 100644 --- a/gzwrite.c +++ b/gzwrite.c @@ -40,7 +40,7 @@ static int gz_init(gz_state *state) { strm->zalloc = NULL; strm->zfree = NULL; strm->opaque = NULL; - ret = deflateInit2(strm, state->level, Z_DEFLATED, MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy); + ret = PREFIX(deflateInit2)(strm, state->level, Z_DEFLATED, MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy); if (ret != Z_OK) { free(state->out); free(state->in); @@ -110,7 +110,7 @@ static int gz_comp(gz_state *state, int flush) { /* compress */ have = strm->avail_out; - ret = deflate(strm, flush); + ret = PREFIX(deflate)(strm, flush); if (ret == Z_STREAM_ERROR) { gz_error(state, Z_STREAM_ERROR, "internal error: deflate stream corrupt"); return -1; @@ -120,7 +120,7 @@ static int gz_comp(gz_state *state, int flush) { /* if that completed a deflate stream, allow another to start */ if (flush == Z_FINISH) - deflateReset(strm); + PREFIX(deflateReset)(strm); /* all done, no errors */ return 0; @@ -400,7 +400,7 @@ int ZEXPORTVA PREFIX(gzprintf)(gzFile file, const char *format, ...) { int ret; va_start(va, format); - ret = gzvprintf(file, format, va); + ret = PREFIX(gzvprintf)(file, format, va); va_end(va); return ret; } @@ -465,7 +465,7 @@ int ZEXPORT PREFIX(gzsetparams)(gzFile file, int level, int strategy) { /* flush previous input with previous parameters before changing */ if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1) return state->err; - deflateParams(strm, level, strategy); + PREFIX(deflateParams)(strm, level, strategy); } state->level = level; state->strategy = strategy; @@ -498,7 +498,7 @@ int ZEXPORT PREFIX(gzclose_w)(gzFile file) { ret = state->err; if (state->size) { if (!state->direct) { - (void)deflateEnd(&(state->strm)); + (void)PREFIX(deflateEnd)(&(state->strm)); free(state->out); } free(state->in); diff --git a/infback.c b/infback.c index f2a1b46b..337a3ba0 100644 --- a/infback.c +++ b/infback.c @@ -25,11 +25,11 @@ static void fixedtables(struct inflate_state *state); windowBits is in the range 8..15, and window is a user-supplied window and output buffer that is 2**windowBits bytes. */ -int ZEXPORT PREFIX(inflateBackInit_)(z_stream *strm, int windowBits, unsigned char *window, +int ZEXPORT PREFIX(inflateBackInit_)(PREFIX3(stream) *strm, int windowBits, unsigned char *window, const char *version, int stream_size) { struct inflate_state *state; - if (version == NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream))) + if (version == NULL || version[0] != PREFIX2(VERSION)[0] || stream_size != (int)(sizeof(PREFIX3(stream)))) return Z_VERSION_ERROR; if (strm == NULL || window == NULL || windowBits < 8 || windowBits > 15) return Z_STREAM_ERROR; @@ -230,7 +230,7 @@ static void fixedtables(struct inflate_state *state) { inflateBack() can also return Z_STREAM_ERROR if the input parameters are not correct, i.e. strm is NULL or the state was not initialized. */ -int ZEXPORT PREFIX(inflateBack)(z_stream *strm, in_func in, void *in_desc, out_func out, void *out_desc) { +int ZEXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in_desc, out_func out, void *out_desc) { struct inflate_state *state; const unsigned char *next; /* next input */ unsigned char *put; /* next output */ @@ -602,7 +602,7 @@ int ZEXPORT PREFIX(inflateBack)(z_stream *strm, in_func in, void *in_desc, out_f return ret; } -int ZEXPORT PREFIX(inflateBackEnd)(z_stream *strm) { +int ZEXPORT PREFIX(inflateBackEnd)(PREFIX3(stream) *strm) { if (strm == NULL || strm->state == NULL || strm->zfree == NULL) return Z_STREAM_ERROR; ZFREE(strm, strm->state); diff --git a/inffast.c b/inffast.c index 32bb4f34..ca05b2f4 100644 --- a/inffast.c +++ b/inffast.c @@ -136,7 +136,7 @@ static inline unsigned char* chunkunroll(unsigned char *out, unsigned *dist, uns requires strm->avail_out >= 258 for each loop to avoid checking for output space. */ -void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned long start) { +void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start) { /* start: inflate()'s starting value for strm->avail_out */ struct inflate_state *state; const unsigned char *in; /* local strm->next_in */ diff --git a/inffast.h b/inffast.h index fdf5a187..464f6c8d 100644 --- a/inffast.h +++ b/inffast.h @@ -10,7 +10,7 @@ subject to change. Applications should only use zlib.h. */ -void ZLIB_INTERNAL inflate_fast(z_stream *strm, unsigned long start); +void ZLIB_INTERNAL inflate_fast(PREFIX3(stream) *strm, unsigned long start); #if (defined(__GNUC__) || defined(__clang__)) && defined(__ARM_NEON__) diff --git a/inflate.c b/inflate.c index 551fa885..93d1df34 100644 --- a/inflate.c +++ b/inflate.c @@ -94,15 +94,15 @@ #endif /* function prototypes */ -static int inflateStateCheck(z_stream *strm); +static int inflateStateCheck(PREFIX3(stream) *strm); static void fixedtables(struct inflate_state *state); -static int updatewindow(z_stream *strm, const unsigned char *end, uint32_t copy); +static int updatewindow(PREFIX3(stream) *strm, const unsigned char *end, uint32_t copy); #ifdef BUILDFIXED void makefixed(void); #endif static uint32_t syncsearch(uint32_t *have, const unsigned char *buf, uint32_t len); -static int inflateStateCheck(z_stream *strm) { +static int inflateStateCheck(PREFIX3(stream) *strm) { struct inflate_state *state; if (strm == NULL || strm->zalloc == NULL || strm->zfree == NULL) return 1; @@ -112,7 +112,7 @@ static int inflateStateCheck(z_stream *strm) { return 0; } -int ZEXPORT PREFIX(inflateResetKeep)(z_stream *strm) { +int ZEXPORT PREFIX(inflateResetKeep)(PREFIX3(stream) *strm) { struct inflate_state *state; if (inflateStateCheck(strm)) @@ -136,7 +136,7 @@ int ZEXPORT PREFIX(inflateResetKeep)(z_stream *strm) { return Z_OK; } -int ZEXPORT PREFIX(inflateReset)(z_stream *strm) { +int ZEXPORT PREFIX(inflateReset)(PREFIX3(stream) *strm) { struct inflate_state *state; if (inflateStateCheck(strm)) @@ -145,10 +145,10 @@ int ZEXPORT PREFIX(inflateReset)(z_stream *strm) { state->wsize = 0; state->whave = 0; state->wnext = 0; - return inflateResetKeep(strm); + return PREFIX(inflateResetKeep)(strm); } -int ZEXPORT PREFIX(inflateReset2)(z_stream *strm, int windowBits) { +int ZEXPORT PREFIX(inflateReset2)(PREFIX3(stream) *strm, int windowBits) { int wrap; struct inflate_state *state; @@ -180,14 +180,14 @@ int ZEXPORT PREFIX(inflateReset2)(z_stream *strm, int windowBits) { /* update state and reset the rest of it */ state->wrap = wrap; state->wbits = (unsigned)windowBits; - return inflateReset(strm); + return PREFIX(inflateReset)(strm); } -int ZEXPORT PREFIX(inflateInit2_)(z_stream *strm, int windowBits, const char *version, int stream_size) { +int ZEXPORT PREFIX(inflateInit2_)(PREFIX3(stream) *strm, int windowBits, const char *version, int stream_size) { int ret; struct inflate_state *state; - if (version == NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream))) + if (version == NULL || version[0] != PREFIX2(VERSION)[0] || stream_size != (int)(sizeof(PREFIX3(stream)))) return Z_VERSION_ERROR; if (strm == NULL) return Z_STREAM_ERROR; @@ -206,7 +206,7 @@ int ZEXPORT PREFIX(inflateInit2_)(z_stream *strm, int windowBits, const char *ve state->strm = strm; state->window = NULL; state->mode = HEAD; /* to pass state test in inflateReset2() */ - ret = inflateReset2(strm, windowBits); + ret = PREFIX(inflateReset2)(strm, windowBits); if (ret != Z_OK) { ZFREE(strm, state); strm->state = NULL; @@ -214,11 +214,11 @@ int ZEXPORT PREFIX(inflateInit2_)(z_stream *strm, int windowBits, const char *ve return ret; } -int ZEXPORT PREFIX(inflateInit_)(z_stream *strm, const char *version, int stream_size) { - return inflateInit2_(strm, DEF_WBITS, version, stream_size); +int ZEXPORT PREFIX(inflateInit_)(PREFIX3(stream) *strm, const char *version, int stream_size) { + return PREFIX(inflateInit2_)(strm, DEF_WBITS, version, stream_size); } -int ZEXPORT PREFIX(inflatePrime)(z_stream *strm, int bits, int value) { +int ZEXPORT PREFIX(inflatePrime)(PREFIX3(stream) *strm, int bits, int value) { struct inflate_state *state; if (inflateStateCheck(strm)) @@ -365,7 +365,7 @@ void makefixed(void) { output will fall in the output data, making match copies simpler and faster. The advantage may be dependent on the size of the processor's data caches. */ -static int updatewindow(z_stream *strm, const unsigned char *end, uint32_t copy) { +static int updatewindow(PREFIX3(stream) *strm, const unsigned char *end, uint32_t copy) { struct inflate_state *state; uint32_t dist; @@ -424,7 +424,7 @@ static int updatewindow(z_stream *strm, const unsigned char *end, uint32_t copy) /* check function to use adler32() for zlib or crc32() for gzip */ #ifdef GUNZIP # define UPDATE(check, buf, len) \ - (state->flags ? crc32(check, buf, len) : functable.adler32(check, buf, len)) + (state->flags ? PREFIX(crc32)(check, buf, len) : functable.adler32(check, buf, len)) #else # define UPDATE(check, buf, len) functable.adler32(check, buf, len) #endif @@ -435,7 +435,7 @@ static int updatewindow(z_stream *strm, const unsigned char *end, uint32_t copy) do { \ hbuf[0] = (unsigned char)(word); \ hbuf[1] = (unsigned char)((word) >> 8); \ - check = crc32(check, hbuf, 2); \ + check = PREFIX(crc32)(check, hbuf, 2); \ } while (0) # define CRC4(check, word) \ @@ -444,7 +444,7 @@ static int updatewindow(z_stream *strm, const unsigned char *end, uint32_t copy) hbuf[1] = (unsigned char)((word) >> 8); \ hbuf[2] = (unsigned char)((word) >> 16); \ hbuf[3] = (unsigned char)((word) >> 24); \ - check = crc32(check, hbuf, 4); \ + check = PREFIX(crc32)(check, hbuf, 4); \ } while (0) #endif @@ -595,7 +595,7 @@ static int updatewindow(z_stream *strm, const unsigned char *end, uint32_t copy) will return Z_BUF_ERROR if it has not reached the end of the stream. */ -int ZEXPORT PREFIX(inflate)(z_stream *strm, int flush) { +int ZEXPORT PREFIX(inflate)(PREFIX3(stream) *strm, int flush) { struct inflate_state *state; const unsigned char *next; /* next input */ unsigned char *put; /* next output */ @@ -638,7 +638,7 @@ int ZEXPORT PREFIX(inflate)(z_stream *strm, int flush) { if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ if (state->wbits == 0) state->wbits = 15; - state->check = crc32(0L, NULL, 0); + state->check = PREFIX(crc32)(0L, NULL, 0); CRC2(state->check, hold); INITBITS(); state->mode = FLAGS; @@ -741,7 +741,7 @@ int ZEXPORT PREFIX(inflate)(z_stream *strm, int flush) { state->head->extra_max - len : copy); } if ((state->flags & 0x0200) && (state->wrap & 4)) - state->check = crc32(state->check, next, copy); + state->check = PREFIX(crc32)(state->check, next, copy); have -= copy; next += copy; state->length -= copy; @@ -761,7 +761,7 @@ int ZEXPORT PREFIX(inflate)(z_stream *strm, int flush) { state->head->name[state->length++] = (unsigned char)len; } while (len && copy < have); if ((state->flags & 0x0200) && (state->wrap & 4)) - state->check = crc32(state->check, next, copy); + state->check = PREFIX(crc32)(state->check, next, copy); have -= copy; next += copy; if (len) @@ -782,7 +782,7 @@ int ZEXPORT PREFIX(inflate)(z_stream *strm, int flush) { state->head->comment[state->length++] = (unsigned char)len; } while (len && copy < have); if ((state->flags & 0x0200) && (state->wrap & 4)) - state->check = crc32(state->check, next, copy); + state->check = PREFIX(crc32)(state->check, next, copy); have -= copy; next += copy; if (len) @@ -805,7 +805,7 @@ int ZEXPORT PREFIX(inflate)(z_stream *strm, int flush) { state->head->hcrc = (int)((state->flags >> 9) & 1); state->head->done = 1; } - strm->adler = state->check = crc32(0L, NULL, 0); + strm->adler = state->check = PREFIX(crc32)(0L, NULL, 0); state->mode = TYPE; break; #endif @@ -1259,7 +1259,7 @@ int ZEXPORT PREFIX(inflate)(z_stream *strm, int flush) { return ret; } -int ZEXPORT PREFIX(inflateEnd)(z_stream *strm) { +int ZEXPORT PREFIX(inflateEnd)(PREFIX3(stream) *strm) { struct inflate_state *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; @@ -1272,7 +1272,7 @@ int ZEXPORT PREFIX(inflateEnd)(z_stream *strm) { return Z_OK; } -int ZEXPORT PREFIX(inflateGetDictionary)(z_stream *strm, unsigned char *dictionary, unsigned int *dictLength) { +int ZEXPORT PREFIX(inflateGetDictionary)(PREFIX3(stream) *strm, unsigned char *dictionary, unsigned int *dictLength) { struct inflate_state *state; /* check state */ @@ -1290,7 +1290,7 @@ int ZEXPORT PREFIX(inflateGetDictionary)(z_stream *strm, unsigned char *dictiona return Z_OK; } -int ZEXPORT PREFIX(inflateSetDictionary)(z_stream *strm, const unsigned char *dictionary, unsigned int dictLength) { +int ZEXPORT PREFIX(inflateSetDictionary)(PREFIX3(stream) *strm, const unsigned char *dictionary, unsigned int dictLength) { struct inflate_state *state; unsigned long dictid; int ret; @@ -1322,7 +1322,7 @@ int ZEXPORT PREFIX(inflateSetDictionary)(z_stream *strm, const unsigned char *di return Z_OK; } -int ZEXPORT PREFIX(inflateGetHeader)(z_stream *strm, gz_headerp head) { +int ZEXPORT PREFIX(inflateGetHeader)(PREFIX3(stream) *strm, PREFIX(gz_headerp) head) { struct inflate_state *state; /* check state */ @@ -1368,7 +1368,7 @@ static unsigned syncsearch(uint32_t *have, const unsigned char *buf, uint32_t le return next; } -int ZEXPORT PREFIX(inflateSync)(z_stream *strm) { +int ZEXPORT PREFIX(inflateSync)(PREFIX3(stream) *strm) { unsigned len; /* number of bytes to look at or looked at */ size_t in, out; /* temporary to save total_in and total_out */ unsigned char buf[4]; /* to restore bit buffer to byte string */ @@ -1407,7 +1407,7 @@ int ZEXPORT PREFIX(inflateSync)(z_stream *strm) { return Z_DATA_ERROR; in = strm->total_in; out = strm->total_out; - inflateReset(strm); + PREFIX(inflateReset)(strm); strm->total_in = in; strm->total_out = out; state->mode = TYPE; @@ -1422,7 +1422,7 @@ int ZEXPORT PREFIX(inflateSync)(z_stream *strm) { block. When decompressing, PPP checks that at the end of input packet, inflate is waiting for these length bytes. */ -int ZEXPORT PREFIX(inflateSyncPoint)(z_stream *strm) { +int ZEXPORT PREFIX(inflateSyncPoint)(PREFIX3(stream) *strm) { struct inflate_state *state; if (inflateStateCheck(strm)) @@ -1431,7 +1431,7 @@ int ZEXPORT PREFIX(inflateSyncPoint)(z_stream *strm) { return state->mode == STORED && state->bits == 0; } -int ZEXPORT PREFIX(inflateCopy)(z_stream *dest, z_stream *source) { +int ZEXPORT PREFIX(inflateCopy)(PREFIX3(stream) *dest, PREFIX3(stream) *source) { struct inflate_state *state; struct inflate_state *copy; unsigned char *window; @@ -1457,7 +1457,7 @@ int ZEXPORT PREFIX(inflateCopy)(z_stream *dest, z_stream *source) { } /* copy state */ - memcpy((void *)dest, (void *)source, sizeof(z_stream)); + memcpy((void *)dest, (void *)source, sizeof(PREFIX3(stream))); memcpy((void *)copy, (void *)state, sizeof(struct inflate_state)); copy->strm = dest; if (state->lencode >= state->codes && state->lencode <= state->codes + ENOUGH - 1) { @@ -1474,7 +1474,7 @@ int ZEXPORT PREFIX(inflateCopy)(z_stream *dest, z_stream *source) { return Z_OK; } -int ZEXPORT PREFIX(inflateUndermine)(z_stream *strm, int subvert) { +int ZEXPORT PREFIX(inflateUndermine)(PREFIX3(stream) *strm, int subvert) { struct inflate_state *state; if (inflateStateCheck(strm)) @@ -1490,7 +1490,7 @@ int ZEXPORT PREFIX(inflateUndermine)(z_stream *strm, int subvert) { #endif } -int ZEXPORT PREFIX(inflateValidate)(z_stream *strm, int check) { +int ZEXPORT PREFIX(inflateValidate)(PREFIX3(stream) *strm, int check) { struct inflate_state *state; if (inflateStateCheck(strm)) @@ -1503,7 +1503,7 @@ int ZEXPORT PREFIX(inflateValidate)(z_stream *strm, int check) { return Z_OK; } -long ZEXPORT PREFIX(inflateMark)(z_stream *strm) { +long ZEXPORT PREFIX(inflateMark)(PREFIX3(stream) *strm) { struct inflate_state *state; if (inflateStateCheck(strm)) @@ -1513,7 +1513,7 @@ long ZEXPORT PREFIX(inflateMark)(z_stream *strm) { (state->mode == MATCH ? state->was - state->length : 0)); } -unsigned long ZEXPORT PREFIX(inflateCodesUsed)(z_stream *strm) { +unsigned long ZEXPORT PREFIX(inflateCodesUsed)(PREFIX3(stream) *strm) { struct inflate_state *state; if (strm == NULL || strm->state == NULL) return (unsigned long)-1; diff --git a/inflate.h b/inflate.h index 2e2e4e27..8c142a97 100644 --- a/inflate.h +++ b/inflate.h @@ -83,7 +83,7 @@ typedef enum { /* State maintained between inflate() calls -- approximately 7K bytes, not including the allocated sliding window, which is up to 32K bytes. */ struct inflate_state { - z_stream *strm; /* pointer back to this zlib stream */ + PREFIX3(stream) *strm; /* pointer back to this zlib stream */ inflate_mode mode; /* current inflate mode */ int last; /* true if processing last block */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip, @@ -93,7 +93,7 @@ struct inflate_state { unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ unsigned long check; /* protected copy of check value */ unsigned long total; /* protected copy of output count */ - gz_headerp head; /* where to save gzip header information */ + PREFIX(gz_headerp) head; /* where to save gzip header information */ /* sliding window */ unsigned wbits; /* log base 2 of requested window size */ uint32_t wsize; /* window size or zero if not using window */ diff --git a/test/example.c b/test/example.c index 4352e66c..77c53bfb 100644 --- a/test/example.c +++ b/test/example.c @@ -5,7 +5,12 @@ /* @(#) $Id$ */ -#include "zlib.h" +#ifdef ZLIB_COMPAT +# include "zlib.h" +#else +# include "zlib-ng.h" +#endif + #include #include @@ -54,12 +59,12 @@ void test_compress(unsigned char *compr, size_t comprLen, unsigned char *uncompr int err; size_t len = strlen(hello)+1; - err = compress(compr, &comprLen, (const unsigned char*)hello, len); + err = PREFIX(compress)(compr, &comprLen, (const unsigned char*)hello, len); CHECK_ERR(err, "compress"); strcpy((char*)uncompr, "garbage"); - err = uncompress(uncompr, &uncomprLen, compr, comprLen); + err = PREFIX(uncompress)(uncompr, &uncomprLen, compr, comprLen); CHECK_ERR(err, "uncompress"); if (strcmp((char*)uncompr, hello)) { @@ -87,32 +92,32 @@ void test_gzio(const char *fname, unsigned char *uncompr, size_t uncomprLen) gzFile file; z_off_t pos; - file = gzopen(fname, "wb"); + file = PREFIX(gzopen)(fname, "wb"); if (file == NULL) { fprintf(stderr, "gzopen error\n"); exit(1); } - gzputc(file, 'h'); - if (gzputs(file, "ello") != 4) { - fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err)); + PREFIX(gzputc)(file, 'h'); + if (PREFIX(gzputs)(file, "ello") != 4) { + fprintf(stderr, "gzputs err: %s\n", PREFIX(gzerror)(file, &err)); exit(1); } - if (gzprintf(file, ", %s!", "hello") != 8) { - fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err)); + if (PREFIX(gzprintf)(file, ", %s!", "hello") != 8) { + fprintf(stderr, "gzprintf err: %s\n", PREFIX(gzerror)(file, &err)); exit(1); } - gzseek(file, 1L, SEEK_CUR); /* add one zero byte */ - gzclose(file); + PREFIX(gzseek)(file, 1L, SEEK_CUR); /* add one zero byte */ + PREFIX(gzclose)(file); - file = gzopen(fname, "rb"); + file = PREFIX(gzopen)(fname, "rb"); if (file == NULL) { fprintf(stderr, "gzopen error\n"); exit(1); } strcpy((char*)uncompr, "garbage"); - if (gzread(file, uncompr, (unsigned)uncomprLen) != len) { - fprintf(stderr, "gzread err: %s\n", gzerror(file, &err)); + if (PREFIX(gzread)(file, uncompr, (unsigned)uncomprLen) != len) { + fprintf(stderr, "gzread err: %s\n", PREFIX(gzerror)(file, &err)); exit(1); } if (strcmp((char*)uncompr, hello)) { @@ -122,26 +127,26 @@ void test_gzio(const char *fname, unsigned char *uncompr, size_t uncomprLen) printf("gzread(): %s\n", (char*)uncompr); } - pos = gzseek(file, -8L, SEEK_CUR); - if (pos != 6 || gztell(file) != pos) { + pos = PREFIX(gzseek)(file, -8L, SEEK_CUR); + if (pos != 6 || PREFIX(gztell)(file) != pos) { fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", - (long)pos, (long)gztell(file)); + (long)pos, (long)PREFIX(gztell)(file)); exit(1); } - if (gzgetc(file) != ' ') { + if (PREFIX(gzgetc)(file) != ' ') { fprintf(stderr, "gzgetc error\n"); exit(1); } - if (gzungetc(' ', file) != ' ') { + if (PREFIX(gzungetc)(' ', file) != ' ') { fprintf(stderr, "gzungetc error\n"); exit(1); } - gzgets(file, (char*)uncompr, (int)uncomprLen); + PREFIX(gzgets)(file, (char*)uncompr, (int)uncomprLen); if (strlen((char*)uncompr) != 7) { /* " hello!" */ - fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err)); + fprintf(stderr, "gzgets err after gzseek: %s\n", PREFIX(gzerror)(file, &err)); exit(1); } if (strcmp((char*)uncompr, hello + 6)) { @@ -151,7 +156,7 @@ void test_gzio(const char *fname, unsigned char *uncompr, size_t uncomprLen) printf("gzgets() after gzseek: %s\n", (char*)uncompr); } - gzclose(file); + PREFIX(gzclose)(file); #endif } @@ -162,7 +167,7 @@ void test_gzio(const char *fname, unsigned char *uncompr, size_t uncomprLen) */ void test_deflate(unsigned char *compr, size_t comprLen) { - z_stream c_stream; /* compression stream */ + PREFIX3(stream) c_stream; /* compression stream */ int err; unsigned long len = (unsigned long)strlen(hello)+1; @@ -170,7 +175,7 @@ void test_deflate(unsigned char *compr, size_t comprLen) c_stream.zfree = zfree; c_stream.opaque = (void *)0; - err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); + err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); CHECK_ERR(err, "deflateInit"); c_stream.next_in = (const unsigned char *)hello; @@ -178,18 +183,18 @@ void test_deflate(unsigned char *compr, size_t comprLen) while (c_stream.total_in != len && c_stream.total_out < comprLen) { c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ - err = deflate(&c_stream, Z_NO_FLUSH); + err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); CHECK_ERR(err, "deflate"); } /* Finish the stream, still forcing small buffers: */ for (;;) { c_stream.avail_out = 1; - err = deflate(&c_stream, Z_FINISH); + err = PREFIX(deflate)(&c_stream, Z_FINISH); if (err == Z_STREAM_END) break; CHECK_ERR(err, "deflate"); } - err = deflateEnd(&c_stream); + err = PREFIX(deflateEnd)(&c_stream); CHECK_ERR(err, "deflateEnd"); } @@ -199,7 +204,7 @@ void test_deflate(unsigned char *compr, size_t comprLen) void test_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { int err; - z_stream d_stream; /* decompression stream */ + PREFIX3(stream) d_stream; /* decompression stream */ strcpy((char*)uncompr, "garbage"); @@ -211,17 +216,17 @@ void test_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, d_stream.avail_in = 0; d_stream.next_out = uncompr; - err = inflateInit(&d_stream); + err = PREFIX(inflateInit)(&d_stream); CHECK_ERR(err, "inflateInit"); while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) { d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */ - err = inflate(&d_stream, Z_NO_FLUSH); + err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); if (err == Z_STREAM_END) break; CHECK_ERR(err, "inflate"); } - err = inflateEnd(&d_stream); + err = PREFIX(inflateEnd)(&d_stream); CHECK_ERR(err, "inflateEnd"); if (strcmp((char*)uncompr, hello)) { @@ -237,14 +242,14 @@ void test_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, */ void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { - z_stream c_stream; /* compression stream */ + PREFIX3(stream) c_stream; /* compression stream */ int err; c_stream.zalloc = zalloc; c_stream.zfree = zfree; c_stream.opaque = (void *)0; - err = deflateInit(&c_stream, Z_BEST_SPEED); + err = PREFIX(deflateInit)(&c_stream, Z_BEST_SPEED); CHECK_ERR(err, "deflateInit"); c_stream.next_out = compr; @@ -255,7 +260,7 @@ void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *un */ c_stream.next_in = uncompr; c_stream.avail_in = (unsigned int)uncomprLen; - err = deflate(&c_stream, Z_NO_FLUSH); + err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); CHECK_ERR(err, "deflate"); if (c_stream.avail_in != 0) { fprintf(stderr, "deflate not greedy\n"); @@ -263,25 +268,25 @@ void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *un } /* Feed in already compressed data and switch to no compression: */ - deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); + PREFIX(deflateParams)(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); c_stream.next_in = compr; c_stream.avail_in = (unsigned int)comprLen/2; - err = deflate(&c_stream, Z_NO_FLUSH); + err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); CHECK_ERR(err, "deflate"); /* Switch back to compressing mode: */ - deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); + PREFIX(deflateParams)(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); c_stream.next_in = uncompr; c_stream.avail_in = (unsigned int)uncomprLen; - err = deflate(&c_stream, Z_NO_FLUSH); + err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); CHECK_ERR(err, "deflate"); - err = deflate(&c_stream, Z_FINISH); + err = PREFIX(deflate)(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { fprintf(stderr, "deflate should report Z_STREAM_END\n"); exit(1); } - err = deflateEnd(&c_stream); + err = PREFIX(deflateEnd)(&c_stream); CHECK_ERR(err, "deflateEnd"); } @@ -291,7 +296,7 @@ void test_large_deflate(unsigned char *compr, size_t comprLen, unsigned char *un void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { int err; - z_stream d_stream; /* decompression stream */ + PREFIX3(stream) d_stream; /* decompression stream */ strcpy((char*)uncompr, "garbage"); @@ -302,18 +307,18 @@ void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *un d_stream.next_in = compr; d_stream.avail_in = (unsigned int)comprLen; - err = inflateInit(&d_stream); + err = PREFIX(inflateInit)(&d_stream); CHECK_ERR(err, "inflateInit"); for (;;) { d_stream.next_out = uncompr; /* discard the output */ d_stream.avail_out = (unsigned int)uncomprLen; - err = inflate(&d_stream, Z_NO_FLUSH); + err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); if (err == Z_STREAM_END) break; CHECK_ERR(err, "large inflate"); } - err = inflateEnd(&d_stream); + err = PREFIX(inflateEnd)(&d_stream); CHECK_ERR(err, "inflateEnd"); if (d_stream.total_out != 2*uncomprLen + comprLen/2) { @@ -329,7 +334,7 @@ void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *un */ void test_flush(unsigned char *compr, size_t *comprLen) { - z_stream c_stream; /* compression stream */ + PREFIX3(stream) c_stream; /* compression stream */ int err; unsigned int len = (unsigned int)strlen(hello)+1; @@ -337,24 +342,24 @@ void test_flush(unsigned char *compr, size_t *comprLen) c_stream.zfree = zfree; c_stream.opaque = (void *)0; - err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); + err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); CHECK_ERR(err, "deflateInit"); c_stream.next_in = (const unsigned char *)hello; c_stream.next_out = compr; c_stream.avail_in = 3; c_stream.avail_out = (unsigned int)*comprLen; - err = deflate(&c_stream, Z_FULL_FLUSH); + err = PREFIX(deflate)(&c_stream, Z_FULL_FLUSH); CHECK_ERR(err, "deflate"); compr[3]++; /* force an error in first compressed block */ c_stream.avail_in = len - 3; - err = deflate(&c_stream, Z_FINISH); + err = PREFIX(deflate)(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { CHECK_ERR(err, "deflate"); } - err = deflateEnd(&c_stream); + err = PREFIX(deflateEnd)(&c_stream); CHECK_ERR(err, "deflateEnd"); *comprLen = c_stream.total_out; @@ -366,7 +371,7 @@ void test_flush(unsigned char *compr, size_t *comprLen) void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { int err; - z_stream d_stream; /* decompression stream */ + PREFIX3(stream) d_stream; /* decompression stream */ strcpy((char*)uncompr, "garbage"); @@ -377,26 +382,26 @@ void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, si d_stream.next_in = compr; d_stream.avail_in = 2; /* just read the zlib header */ - err = inflateInit(&d_stream); + err = PREFIX(inflateInit)(&d_stream); CHECK_ERR(err, "inflateInit"); d_stream.next_out = uncompr; d_stream.avail_out = (unsigned int)uncomprLen; - err = inflate(&d_stream, Z_NO_FLUSH); + err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); CHECK_ERR(err, "inflate"); d_stream.avail_in = (unsigned int)comprLen-2; /* read all compressed data */ - err = inflateSync(&d_stream); /* but skip the damaged part */ + err = PREFIX(inflateSync)(&d_stream); /* but skip the damaged part */ CHECK_ERR(err, "inflateSync"); - err = inflate(&d_stream, Z_FINISH); + err = PREFIX(inflate)(&d_stream, Z_FINISH); if (err != Z_DATA_ERROR) { fprintf(stderr, "inflate should report DATA_ERROR\n"); /* Because of incorrect adler32 */ exit(1); } - err = inflateEnd(&d_stream); + err = PREFIX(inflateEnd)(&d_stream); CHECK_ERR(err, "inflateEnd"); printf("after inflateSync(): hel%s\n", (char *)uncompr); @@ -407,17 +412,17 @@ void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, si */ void test_dict_deflate(unsigned char *compr, size_t comprLen) { - z_stream c_stream; /* compression stream */ + PREFIX3(stream) c_stream; /* compression stream */ int err; c_stream.zalloc = zalloc; c_stream.zfree = zfree; c_stream.opaque = (void *)0; - err = deflateInit(&c_stream, Z_BEST_COMPRESSION); + err = PREFIX(deflateInit)(&c_stream, Z_BEST_COMPRESSION); CHECK_ERR(err, "deflateInit"); - err = deflateSetDictionary(&c_stream, + err = PREFIX(deflateSetDictionary)(&c_stream, (const unsigned char*)dictionary, (int)sizeof(dictionary)); CHECK_ERR(err, "deflateSetDictionary"); @@ -428,12 +433,12 @@ void test_dict_deflate(unsigned char *compr, size_t comprLen) c_stream.next_in = (const unsigned char *)hello; c_stream.avail_in = (unsigned int)strlen(hello)+1; - err = deflate(&c_stream, Z_FINISH); + err = PREFIX(deflate)(&c_stream, Z_FINISH); if (err != Z_STREAM_END) { fprintf(stderr, "deflate should report Z_STREAM_END\n"); exit(1); } - err = deflateEnd(&c_stream); + err = PREFIX(deflateEnd)(&c_stream); CHECK_ERR(err, "deflateEnd"); } @@ -443,7 +448,7 @@ void test_dict_deflate(unsigned char *compr, size_t comprLen) void test_dict_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen) { int err; - z_stream d_stream; /* decompression stream */ + PREFIX3(stream) d_stream; /* decompression stream */ strcpy((char*)uncompr, "garbage"); @@ -454,27 +459,27 @@ void test_dict_inflate(unsigned char *compr, size_t comprLen, unsigned char *unc d_stream.next_in = compr; d_stream.avail_in = (unsigned int)comprLen; - err = inflateInit(&d_stream); + err = PREFIX(inflateInit)(&d_stream); CHECK_ERR(err, "inflateInit"); d_stream.next_out = uncompr; d_stream.avail_out = (unsigned int)uncomprLen; for (;;) { - err = inflate(&d_stream, Z_NO_FLUSH); + err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); if (err == Z_STREAM_END) break; if (err == Z_NEED_DICT) { if (d_stream.adler != dictId) { fprintf(stderr, "unexpected dictionary"); exit(1); } - err = inflateSetDictionary(&d_stream, (const unsigned char*)dictionary, + err = PREFIX(inflateSetDictionary)(&d_stream, (const unsigned char*)dictionary, (int)sizeof(dictionary)); } CHECK_ERR(err, "inflate with dict"); } - err = inflateEnd(&d_stream); + err = PREFIX(inflateEnd)(&d_stream); CHECK_ERR(err, "inflateEnd"); if (strcmp((char*)uncompr, hello)) { @@ -494,18 +499,18 @@ int main(int argc, char *argv[]) unsigned char *compr, *uncompr; size_t comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ size_t uncomprLen = comprLen; - static const char* myVersion = ZLIB_VERSION; + static const char* myVersion = PREFIX2(VERSION); - if (zlibVersion()[0] != myVersion[0]) { + if (zVersion()[0] != myVersion[0]) { fprintf(stderr, "incompatible zlib version\n"); exit(1); - } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { + } else if (strcmp(zVersion(), PREFIX2(VERSION)) != 0) { fprintf(stderr, "warning: different zlib version\n"); } printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n", - ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags()); + PREFIX2(VERSION), PREFIX2(VERNUM), PREFIX(zlibCompileFlags)()); compr = (unsigned char*)calloc((unsigned int)comprLen, 1); uncompr = (unsigned char*)calloc((unsigned int)uncomprLen, 1); diff --git a/test/minigzip.c b/test/minigzip.c index 600619fc..f7e3758d 100644 --- a/test/minigzip.c +++ b/test/minigzip.c @@ -14,7 +14,11 @@ /* @(#) $Id$ */ -#include "zlib.h" +#ifdef ZLIB_COMPAT +# include "zlib.h" +#else +# include "zlib-ng.h" +#endif #include #include @@ -80,20 +84,20 @@ typedef struct gzFile_s { int write; int err; const char *msg; - z_stream strm; + PREFIX3(stream) strm; unsigned char *buf; } *gzFile; -gzFile gzopen (const char *, const char *); -gzFile gzdopen (int, const char *); +gzFile PREFIX(gzopen)(const char *, const char *); +gzFile PREFIX(gzdopen)(int, const char *); gzFile gz_open (const char *, int, const char *); -gzFile gzopen(const char *path, const char *mode) +gzFile PREFIX(gzopen)(const char *path, const char *mode) { return gz_open(path, -1, mode); } -gzFile gzdopen(int fd, const char *mode) +gzFile PREFIX(gzdopen)(int fd, const char *mode) { return gz_open(NULL, fd, mode); } @@ -127,11 +131,11 @@ gzFile gz_open(const char *path, int fd, const char *mode) plevel++; } if (gz->write) - ret = deflateInit2(&(gz->strm), level, 8, 15 + 16, 8, 0); + ret = PREFIX(deflateInit2)(&(gz->strm), level, 8, 15 + 16, 8, 0); else { gz->strm.next_in = NULL; gz->strm.avail_in = 0; - ret = inflateInit2(&(gz->strm), 15 + 16); + ret = PREFIX(inflateInit2)(&(gz->strm), 15 + 16); } if (ret != Z_OK) { free(gz); @@ -140,7 +144,7 @@ gzFile gz_open(const char *path, int fd, const char *mode) gz->file = path == NULL ? fdopen(fd, gz->write ? "wb" : "rb") : fopen(path, gz->write ? "wb" : "rb"); if (gz->file == NULL) { - gz->write ? deflateEnd(&(gz->strm)) : inflateEnd(&(gz->strm)); + gz->write ? PREFIX(deflateEnd)(&(gz->strm)) : PREFIX(inflateEnd)(&(gz->strm)); free(gz); return NULL; } @@ -149,11 +153,11 @@ gzFile gz_open(const char *path, int fd, const char *mode) return gz; } -int gzwrite (gzFile, const void *, unsigned); +int PREFIX(gzwrite)(gzFile, const void *, unsigned); -int gzwrite(gzFile gz, const void *buf, unsigned len) +int PREFIX(gzwrite)(gzFile gz, const void *buf, unsigned len) { - z_stream *strm; + PREFIX3(stream) *strm; if (gz == NULL || !gz->write) return 0; @@ -163,17 +167,17 @@ int gzwrite(gzFile gz, const void *buf, unsigned len) do { strm->next_out = gz->buf; strm->avail_out = BUFLENW; - (void)deflate(strm, Z_NO_FLUSH); + (void)PREFIX(deflate)(strm, Z_NO_FLUSH); fwrite(gz->buf, 1, BUFLENW - strm->avail_out, gz->file); } while (strm->avail_out == 0); return len; } -int gzread (gzFile, void *, unsigned); +int PREFIX(gzread)(gzFile, void *, unsigned); -int gzread(gzFile gz, void *buf, unsigned len) +int PREFIX(gzread)(gzFile gz, void *buf, unsigned len) { - z_stream *strm; + PREFIX3(stream) *strm; if (gz == NULL || gz->write || gz->err) return 0; @@ -188,14 +192,14 @@ int gzread(gzFile gz, void *buf, unsigned len) } if (strm->avail_in > 0) { - int ret = inflate(strm, Z_NO_FLUSH); + int ret = PREFIX(inflate)(strm, Z_NO_FLUSH); if (ret == Z_DATA_ERROR) { gz->err = ret; gz->msg = strm->msg; return 0; } else if (ret == Z_STREAM_END) - inflateReset(strm); + PREFIX(inflateReset)(strm); } else break; @@ -203,11 +207,11 @@ int gzread(gzFile gz, void *buf, unsigned len) return len - strm->avail_out; } -int gzclose (gzFile); +int PREFIX(gzclose)(gzFile); -int gzclose(gzFile gz) +int PREFIX(gzclose)(gzFile gz) { - z_stream *strm; + PREFIX3(stream) *strm; if (gz == NULL) return Z_STREAM_ERROR; @@ -218,22 +222,22 @@ int gzclose(gzFile gz) do { strm->next_out = gz->buf; strm->avail_out = BUFLENW; - (void)deflate(strm, Z_FINISH); + (void)PREFIX(deflate)(strm, Z_FINISH); fwrite(gz->buf, 1, BUFLENW - strm->avail_out, gz->file); } while (strm->avail_out == 0); - deflateEnd(strm); + PREFIX(deflateEnd)(strm); } else - inflateEnd(strm); + PREFIX(inflateEnd)(strm); free(gz->buf); fclose(gz->file); free(gz); return Z_OK; } -const char *gzerror (gzFile, int *); +const char *PREFIX(gzerror)(gzFile, int *); -const char *gzerror(gzFile gz, int *err) +const char *PREFIX(gzerror)(gzFile gz, int *err) { *err = gz->err; return gz->msg; @@ -286,10 +290,10 @@ void gz_compress(FILE *in, gzFile out) } if (len == 0) break; - if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); + if (PREFIX(gzwrite)(out, buf, (unsigned)len) != len) error(PREFIX(gzerror)(out, &err)); } fclose(in); - if (gzclose(out) != Z_OK) error("failed gzclose"); + if (PREFIX(gzclose)(out) != Z_OK) error("failed gzclose"); } #ifdef USE_MMAP /* MMAP version, Miguel Albrecht */ @@ -316,13 +320,13 @@ int gz_compress_mmap(FILE *in, gzFile out) if (buf == (caddr_t)(-1)) return Z_ERRNO; /* Compress the whole file at once: */ - len = gzwrite(out, (char *)buf, (unsigned)buf_len); + len = PREFIX(gzwrite)(out, (char *)buf, (unsigned)buf_len); - if (len != (int)buf_len) error(gzerror(out, &err)); + if (len != (int)buf_len) error(PREFIX(gzerror)(out, &err)); munmap(buf, buf_len); fclose(in); - if (gzclose(out) != Z_OK) error("failed gzclose"); + if (PREFIX(gzclose)(out) != Z_OK) error("failed gzclose"); return Z_OK; } #endif /* USE_MMAP */ @@ -337,8 +341,8 @@ void gz_uncompress(gzFile in, FILE *out) int err; for (;;) { - len = gzread(in, buf, sizeof(buf)); - if (len < 0) error (gzerror(in, &err)); + len = PREFIX(gzread)(in, buf, sizeof(buf)); + if (len < 0) error (PREFIX(gzerror)(in, &err)); if (len == 0) break; if ((int)fwrite(buf, 1, (unsigned)len, out) != len) { @@ -347,7 +351,7 @@ void gz_uncompress(gzFile in, FILE *out) } if (fclose(out)) error("failed fclose"); - if (gzclose(in) != Z_OK) error("failed gzclose"); + if (PREFIX(gzclose)(in) != Z_OK) error("failed gzclose"); } @@ -373,7 +377,7 @@ void file_compress(char *file, char *mode) perror(file); exit(1); } - out = gzopen(outfile, mode); + out = PREFIX(gzopen)(outfile, mode); if (out == NULL) { fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); exit(1); @@ -411,7 +415,7 @@ void file_uncompress(char *file) infile = buf; snprintf(buf + len, sizeof(buf) - len, "%s", GZ_SUFFIX); } - in = gzopen(infile, "rb"); + in = PREFIX(gzopen)(infile, "rb"); if (in == NULL) { fprintf(stderr, "%s: can't gzopen %s\n", prog, infile); exit(1); @@ -484,11 +488,11 @@ int main(int argc, char *argv[]) SET_BINARY_MODE(stdin); SET_BINARY_MODE(stdout); if (uncompr) { - file = gzdopen(fileno(stdin), "rb"); + file = PREFIX(gzdopen)(fileno(stdin), "rb"); if (file == NULL) error("can't gzdopen stdin"); gz_uncompress(file, stdout); } else { - file = gzdopen(fileno(stdout), outmode); + file = PREFIX(gzdopen)(fileno(stdout), outmode); if (file == NULL) error("can't gzdopen stdout"); gz_compress(stdin, file); } @@ -499,7 +503,7 @@ int main(int argc, char *argv[]) do { if (uncompr) { if (copyout) { - file = gzopen(*argv, "rb"); + file = PREFIX(gzopen)(*argv, "rb"); if (file == NULL) fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv); else @@ -514,7 +518,7 @@ int main(int argc, char *argv[]) if (in == NULL) { perror(*argv); } else { - file = gzdopen(fileno(stdout), outmode); + file = PREFIX(gzdopen)(fileno(stdout), outmode); if (file == NULL) error("can't gzdopen stdout"); gz_compress(in, file); diff --git a/uncompr.c b/uncompr.c index 9214005b..f9dc95a7 100644 --- a/uncompr.c +++ b/uncompr.c @@ -6,7 +6,11 @@ /* @(#) $Id$ */ #define ZLIB_INTERNAL -#include "zlib.h" +#ifdef ZLIB_COMPAT +# include "zlib.h" +#else +# include "zlib-ng.h" +#endif /* =========================================================================== Decompresses the source buffer into the destination buffer. *sourceLen is @@ -25,7 +29,7 @@ an incomplete zlib stream. */ int ZEXPORT PREFIX(uncompress2)(unsigned char *dest, size_t *destLen, const unsigned char *source, size_t *sourceLen) { - z_stream stream; + PREFIX3(stream) stream; int err; const unsigned int max = (unsigned int)-1; size_t len, left; @@ -47,7 +51,7 @@ int ZEXPORT PREFIX(uncompress2)(unsigned char *dest, size_t *destLen, const unsi stream.zfree = NULL; stream.opaque = NULL; - err = inflateInit(&stream); + err = PREFIX(inflateInit)(&stream); if (err != Z_OK) return err; stream.next_out = dest; @@ -62,7 +66,7 @@ int ZEXPORT PREFIX(uncompress2)(unsigned char *dest, size_t *destLen, const unsi stream.avail_in = len > (unsigned long)max ? max : (unsigned int)len; len -= stream.avail_in; } - err = inflate(&stream, Z_NO_FLUSH); + err = PREFIX(inflate)(&stream, Z_NO_FLUSH); } while (err == Z_OK); *sourceLen -= len + stream.avail_in; @@ -71,7 +75,7 @@ int ZEXPORT PREFIX(uncompress2)(unsigned char *dest, size_t *destLen, const unsi else if (stream.total_out && err == Z_BUF_ERROR) left = 1; - inflateEnd(&stream); + PREFIX(inflateEnd)(&stream); return err == Z_STREAM_END ? Z_OK : err == Z_NEED_DICT ? Z_DATA_ERROR : err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR : @@ -80,5 +84,5 @@ int ZEXPORT PREFIX(uncompress2)(unsigned char *dest, size_t *destLen, const unsi int ZEXPORT PREFIX(uncompress)(unsigned char *dest, size_t *destLen, const unsigned char *source, size_t sourceLen) { - return uncompress2(dest, destLen, source, &sourceLen); + return PREFIX(uncompress2)(dest, destLen, source, &sourceLen); } diff --git a/win32/Makefile.arm b/win32/Makefile.arm index d8c51da2..2ffb725c 100644 --- a/win32/Makefile.arm +++ b/win32/Makefile.arm @@ -28,18 +28,29 @@ LDFLAGS = -nologo -debug -incremental:no -opt:ref -manifest ARFLAGS = -nologo RCFLAGS = /dARM /r DEFFILE = zlib.def +RCFILE = zlib1.rc +RESFILE = zlib1.res WITH_GZFILEOP = WITH_ACLE = WITH_NEON = WITH_VFPV3 = NEON_ARCH = /arch:VFPv4 +SUFFIX = OBJS = adler32.obj compress.obj crc32.obj deflate.obj deflate_fast.obj deflate_slow.obj \ - infback.obj inflate.obj inftrees.obj inffast.obj match.obj trees.obj uncompr.obj zutil.obj fill_window_arm.obj + functable.obj infback.obj inflate.obj inftrees.obj inffast.obj match.obj trees.obj uncompr.obj zutil.obj fill_window_arm.obj !if "$(WITH_GZFILEOP)" != "" WFLAGS = $(WFLAGS) -DWITH_GZFILEOP OBJS = $(OBJS) gzclose.obj gzlib.obj gzread.obj gzwrite.obj DEFFILE = zlibcompat.def +!else +STATICLIB = zlib-ng.lib +SHAREDLIB = zlib-ng1.dll +IMPLIB = zngdll.lib +DEFFILE = zlib-ng.def +RCFILE = zlib-ng1.rc +RESFILE = zlib-ng1.res +SUFFIX = -ng !endif !if "$(WITH_ACLE)" != "" WFLAGS = $(WFLAGS) -DARM_ACLE_CRC_HASH @@ -58,17 +69,17 @@ OBJS = $(OBJS) adler32_neon.obj all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \ example.exe minigzip.exe example_d.exe minigzip_d.exe -zconf: $(TOP)/zconf.h.in - $(CP) $(TOP)\zconf.h.in $(TOP)\zconf.h +zconf: $(TOP)/zconf$(SUFFIX).h.in + $(CP) $(TOP)\zconf$(SUFFIX).h.in $(TOP)\zconf$(SUFFIX).h $(STATICLIB): zconf $(OBJS) $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(IMPLIB): $(SHAREDLIB) -$(SHAREDLIB): zconf $(TOP)/win32/zlib.def $(OBJS) zlib1.res +$(SHAREDLIB): zconf $(TOP)/win32/$(DEFFILE) $(OBJS) $(RESFILE) $(LD) $(LDFLAGS) -def:$(TOP)/win32/$(DEFFILE) -dll -implib:$(IMPLIB) \ - -out:$@ -base:0x5A4C0000 $(OBJS) zlib1.res + -out:$@ -base:0x5A4C0000 $(OBJS) $(RESFILE) if exist $@.manifest \ mt -nologo -manifest $@.manifest -outputresource:$@;2 @@ -101,49 +112,49 @@ minigzip_d.exe: minigzip.obj $(IMPLIB) {$(TOP)/test}.c.obj: $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $< -$(TOP)/zconf.h: zconf +$(TOP)/zconf$(SUFFIX).h: zconf -adler32.obj: $(TOP)/adler32.c $(TOP)/zlib.h $(TOP)/zconf.h +adler32.obj: $(TOP)/adler32.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h -compress.obj: $(TOP)/compress.c $(TOP)/zlib.h $(TOP)/zconf.h +compress.obj: $(TOP)/compress.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h -crc32.obj: $(TOP)/crc32.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/crc32.h +crc32.obj: $(TOP)/crc32.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/crc32.h -deflate.obj: $(TOP)/deflate.c $(TOP)/deflate.h $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h +deflate.obj: $(TOP)/deflate.c $(TOP)/deflate.h $(TOP)/zutil.h $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h -gzclose.obj: $(TOP)/gzclose.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h +gzclose.obj: $(TOP)/gzclose.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/gzguts.h -gzlib.obj: $(TOP)/gzlib.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h +gzlib.obj: $(TOP)/gzlib.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/gzguts.h -gzread.obj: $(TOP)/gzread.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h +gzread.obj: $(TOP)/gzread.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/gzguts.h -gzwrite.obj: $(TOP)/gzwrite.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h +gzwrite.obj: $(TOP)/gzwrite.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/gzguts.h -infback.obj: $(TOP)/infback.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ +infback.obj: $(TOP)/infback.c $(TOP)/zutil.h $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/inftrees.h $(TOP)/inflate.h \ $(TOP)/inffast.h $(TOP)/inffixed.h -inffast.obj: $(TOP)/inffast.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ +inffast.obj: $(TOP)/inffast.c $(TOP)/zutil.h $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/inftrees.h $(TOP)/inflate.h \ $(TOP)/inffast.h -inflate.obj: $(TOP)/inflate.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ +inflate.obj: $(TOP)/inflate.c $(TOP)/zutil.h $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/inftrees.h $(TOP)/inflate.h \ $(TOP)/inffast.h $(TOP)/inffixed.h -inftrees.obj: $(TOP)/inftrees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h +inftrees.obj: $(TOP)/inftrees.c $(TOP)/zutil.h $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/inftrees.h match.obj: $(TOP)/match.c $(TOP)/deflate.h -trees.obj: $(TOP)/trees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/deflate.h $(TOP)/trees.h +trees.obj: $(TOP)/trees.c $(TOP)/zutil.h $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/deflate.h $(TOP)/trees.h -uncompr.obj: $(TOP)/uncompr.c $(TOP)/zlib.h $(TOP)/zconf.h +uncompr.obj: $(TOP)/uncompr.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h -zutil.obj: $(TOP)/zutil.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h +zutil.obj: $(TOP)/zutil.c $(TOP)/zutil.h $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h -example.obj: $(TOP)/test/example.c $(TOP)/zlib.h $(TOP)/zconf.h +example.obj: $(TOP)/test/example.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h -minigzip.obj: $(TOP)/test/minigzip.c $(TOP)/zlib.h $(TOP)/zconf.h +minigzip.obj: $(TOP)/test/minigzip.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h -zlib1.res: $(TOP)/win32/zlib1.rc - $(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/zlib1.rc +$(RESFILE): $(TOP)/win32/$(RCFILE) + $(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/$(RCFILE) # testing test: example.exe minigzip.exe @@ -166,7 +177,6 @@ clean: -del *.exe -del *.pdb -del *.manifest - -del foo.gz distclean: clean - -del zconf.h + -del zconf$(SUFFIX).h diff --git a/win32/Makefile.msc b/win32/Makefile.msc index d9b93b74..38c37207 100644 --- a/win32/Makefile.msc +++ b/win32/Makefile.msc @@ -28,7 +28,10 @@ LDFLAGS = -nologo -debug -incremental:no -opt:ref -manifest ARFLAGS = -nologo RCFLAGS = /dWIN32 /r DEFFILE = zlib.def +RCFILE = zlib1.rc +RESFILE = zlib1.res WITH_GZFILEOP = +SUFFIX = OBJS = adler32.obj compress.obj crc32.obj deflate.obj deflate_fast.obj deflate_quick.obj deflate_slow.obj \ functable.obj infback.obj inflate.obj inftrees.obj inffast.obj match.obj trees.obj uncompr.obj zutil.obj \ @@ -37,20 +40,31 @@ OBJS = adler32.obj compress.obj crc32.obj deflate.obj deflate_fast.obj deflate_q WFLAGS = $(WFLAGS) -DWITH_GZFILEOP OBJS = $(OBJS) gzclose.obj gzlib.obj gzread.obj gzwrite.obj DEFFILE = zlibcompat.def +!else +STATICLIB = zlib-ng.lib +SHAREDLIB = zlib-ng1.dll +IMPLIB = zngdll.lib +DEFFILE = zlib-ng.def +RCFILE = zlib-ng1.rc +RESFILE = zlib-ng1.res +SUFFIX = -ng !endif # targets all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \ example.exe minigzip.exe example_d.exe minigzip_d.exe -$(STATICLIB): $(OBJS) +zconf: $(TOP)/zconf$(SUFFIX).h.in + $(CP) $(TOP)\zconf$(SUFFIX).h.in $(TOP)\zconf$(SUFFIX).h + +$(STATICLIB): zconf $(OBJS) $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(IMPLIB): $(SHAREDLIB) -$(SHAREDLIB): $(TOP)/win32/zlib.def $(OBJS) zlib1.res +$(SHAREDLIB): zconf $(TOP)/win32/$(DEFFILE) $(OBJS) $(RESFILE) $(LD) $(LDFLAGS) -def:$(TOP)/win32/$(DEFFILE) -dll -implib:$(IMPLIB) \ - -out:$@ -base:0x5A4C0000 $(OBJS) zlib1.res + -out:$@ -base:0x5A4C0000 $(OBJS) $(RESFILE) if exist $@.manifest \ mt -nologo -manifest $@.manifest -outputresource:$@;2 @@ -83,50 +97,49 @@ minigzip_d.exe: minigzip.obj $(IMPLIB) {$(TOP)/test}.c.obj: $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $< -$(TOP)/zconf.h: $(TOP)/zconf.h.in - $(CP) $(TOP)\zconf.h.in $(TOP)\zconf.h +$(TOP)/zconf$(SUFFIX).h: zconf -adler32.obj: $(TOP)/adler32.c $(TOP)/zlib.h $(TOP)/zconf.h +adler32.obj: $(TOP)/adler32.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h -compress.obj: $(TOP)/compress.c $(TOP)/zlib.h $(TOP)/zconf.h +compress.obj: $(TOP)/compress.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h -crc32.obj: $(TOP)/crc32.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/crc32.h +crc32.obj: $(TOP)/crc32.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/crc32.h -deflate.obj: $(TOP)/deflate.c $(TOP)/deflate.h $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h +deflate.obj: $(TOP)/deflate.c $(TOP)/deflate.h $(TOP)/zutil.h $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h -gzclose.obj: $(TOP)/gzclose.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h +gzclose.obj: $(TOP)/gzclose.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/gzguts.h -gzlib.obj: $(TOP)/gzlib.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h +gzlib.obj: $(TOP)/gzlib.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/gzguts.h -gzread.obj: $(TOP)/gzread.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h +gzread.obj: $(TOP)/gzread.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/gzguts.h -gzwrite.obj: $(TOP)/gzwrite.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h +gzwrite.obj: $(TOP)/gzwrite.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/gzguts.h -infback.obj: $(TOP)/infback.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ +infback.obj: $(TOP)/infback.c $(TOP)/zutil.h $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/inftrees.h $(TOP)/inflate.h \ $(TOP)/inffast.h $(TOP)/inffixed.h -inffast.obj: $(TOP)/inffast.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ +inffast.obj: $(TOP)/inffast.c $(TOP)/zutil.h $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/inftrees.h $(TOP)/inflate.h \ $(TOP)/inffast.h -inflate.obj: $(TOP)/inflate.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ +inflate.obj: $(TOP)/inflate.c $(TOP)/zutil.h $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/inftrees.h $(TOP)/inflate.h \ $(TOP)/inffast.h $(TOP)/inffixed.h -inftrees.obj: $(TOP)/inftrees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h +inftrees.obj: $(TOP)/inftrees.c $(TOP)/zutil.h $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/inftrees.h match.obj: $(TOP)/match.c $(TOP)/deflate.h -trees.obj: $(TOP)/trees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/deflate.h $(TOP)/trees.h +trees.obj: $(TOP)/trees.c $(TOP)/zutil.h $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h $(TOP)/deflate.h $(TOP)/trees.h -uncompr.obj: $(TOP)/uncompr.c $(TOP)/zlib.h $(TOP)/zconf.h +uncompr.obj: $(TOP)/uncompr.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h -zutil.obj: $(TOP)/zutil.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h +zutil.obj: $(TOP)/zutil.c $(TOP)/zutil.h $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h -example.obj: $(TOP)/test/example.c $(TOP)/zlib.h $(TOP)/zconf.h +example.obj: $(TOP)/test/example.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h -minigzip.obj: $(TOP)/test/minigzip.c $(TOP)/zlib.h $(TOP)/zconf.h +minigzip.obj: $(TOP)/test/minigzip.c $(TOP)/zlib$(SUFFIX).h $(TOP)/zconf$(SUFFIX).h -zlib1.res: $(TOP)/win32/zlib1.rc - $(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/zlib1.rc +$(RESFILE): $(TOP)/win32/$(RCFILE) + $(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/$(RCFILE) # testing test: example.exe minigzip.exe @@ -149,7 +162,6 @@ clean: -del *.exe -del *.pdb -del *.manifest - -del foo.gz distclean: clean - -del zconf.h + -del zconf$(SUFFIX).h diff --git a/win32/zlib-ng.def b/win32/zlib-ng.def new file mode 100644 index 00000000..fd1047f4 --- /dev/null +++ b/win32/zlib-ng.def @@ -0,0 +1,61 @@ +; zlib-ng data compression library +EXPORTS +; basic functions + zlibng_version + zng_deflate + zng_deflateEnd + zng_inflate + zng_inflateEnd +; advanced functions + zng_deflateSetDictionary + zng_deflateGetDictionary + zng_deflateCopy + zng_deflateReset + zng_deflateParams + zng_deflateTune + zng_deflateBound + zng_deflatePending + zng_deflatePrime + zng_deflateSetHeader + zng_inflateSetDictionary + zng_inflateGetDictionary + zng_inflateSync + zng_inflateCopy + zng_inflateReset + zng_inflateReset2 + zng_inflatePrime + zng_inflateMark + zng_inflateGetHeader + zng_inflateBack + zng_inflateBackEnd + zng_zlibCompileFlags +; utility functions + zng_compress + zng_compress2 + zng_compressBound + zng_uncompress + zng_uncompress2 +; large file functions + zng_adler32_combine64 + zng_crc32_combine64 +; checksum functions + zng_adler32 + zng_adler32_z + zng_crc32 + zng_crc32_z + zng_adler32_combine + zng_crc32_combine +; various hacks, don't look :) + zng_deflateInit_ + zng_deflateInit2_ + zng_inflateInit_ + zng_inflateInit2_ + zng_inflateBackInit_ + zng_zError + zng_inflateSyncPoint + zng_get_crc_table + zng_inflateUndermine + zng_inflateValidate + zng_inflateCodesUsed + zng_inflateResetKeep + zng_deflateResetKeep diff --git a/win32/zlib-ng1.rc b/win32/zlib-ng1.rc new file mode 100644 index 00000000..fdac56ff --- /dev/null +++ b/win32/zlib-ng1.rc @@ -0,0 +1,40 @@ +#include +#include "../zlib-ng.h" + +#ifdef GCC_WINDRES +VS_VERSION_INFO VERSIONINFO +#else +VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE +#endif + FILEVERSION ZLIBNG_VER_MAJOR,ZLIBNG_VER_MINOR,ZLIBNG_VER_REVISION,0 + PRODUCTVERSION ZLIBNG_VER_MAJOR,ZLIBNG_VER_MINOR,ZLIBNG_VER_REVISION,0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS 1 +#else + FILEFLAGS 0 +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_DLL + FILESUBTYPE 0 // not used +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + //language ID = U.S. English, char set = Windows, Multilingual + BEGIN + VALUE "FileDescription", "zlib data compression library\0" + VALUE "FileVersion", ZLIBNG_VERSION "\0" + VALUE "InternalName", "zlib-ng1.dll\0" + VALUE "LegalCopyright", "(C) 1995-2013 Jean-loup Gailly & Mark Adler\0" + VALUE "OriginalFilename", "zlib-ng1.dll\0" + VALUE "ProductName", "zlib\0" + VALUE "ProductVersion", ZLIBNG_VERSION "\0" + VALUE "Comments", "For more information visit http://www.zlib.net/\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 1252 + END +END diff --git a/zconf-ng.h.in b/zconf-ng.h.in index d6cbd6f5..c6b06a27 100644 --- a/zconf-ng.h.in +++ b/zconf-ng.h.in @@ -1,14 +1,17 @@ -/* zconf.h -- configuration of the zlib compression library +/* zconf-ng.h -- configuration of the zlib-ng compression library * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ -#ifndef ZCONF_H -#define ZCONF_H +#ifndef ZCONFNG_H +#define ZCONFNG_H #define PREFIX(x) zng_ ## x +#define PREFIX2(x) ZLIBNG_ ## x +#define PREFIX3(x) zng_ ## x +#define zVersion zlibng_version #if defined(_WINDOWS) && !defined(WINDOWS) # define WINDOWS @@ -173,4 +176,4 @@ typedef void *voidp; # endif #endif -#endif /* ZCONF_H */ +#endif /* ZCONFNG_H */ diff --git a/zconf.h.in b/zconf.h.in index d6cbd6f5..b15cb256 100644 --- a/zconf.h.in +++ b/zconf.h.in @@ -8,7 +8,10 @@ #ifndef ZCONF_H #define ZCONF_H -#define PREFIX(x) zng_ ## x +#define PREFIX(x) x +#define PREFIX2(x) ZLIB_ ## x +#define PREFIX3(x) z_ ## x +#define zVersion zlibVersion #if defined(_WINDOWS) && !defined(WINDOWS) # define WINDOWS diff --git a/zlib-ng.h b/zlib-ng.h index 3dd3f7cd..a2e59dee 100644 --- a/zlib-ng.h +++ b/zlib-ng.h @@ -1,6 +1,6 @@ #ifndef ZNGLIB_H_ #define ZNGLIB_H_ -/* zlib.h -- interface of the 'zlib-ng' compression library +/* zlib-ng.h -- interface of the 'zlib-ng' compression library Forked from and compatible with zlib 1.2.11 Copyright (C) 1995-2016 Jean-loup Gailly and Mark Adler @@ -105,7 +105,7 @@ typedef struct zng_stream_s { unsigned long reserved; /* reserved for future use */ } zng_stream; -typedef zng_stream *zng_streamp; // Obsolete type, retained for compatability only +typedef zng_stream *zng_streamp; /* Obsolete type, retained for compatibility only */ /* gzip header information passed to and from zlib routines. See RFC 1952 @@ -204,10 +204,10 @@ typedef zng_gz_header *zng_gz_headerp; /* basic functions */ -ZEXTERN const char * ZEXPORT zng_version(void); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. +ZEXTERN const char * ZEXPORT zlibng_version(void); +/* The application can compare zlibng_version and ZLIBNG_VERSION for consistency. If the first character differs, the library code actually used is not - compatible with the zlib.h header file used by the application. This check + compatible with the zlib-ng.h header file used by the application. This check is automatically made by deflateInit and inflateInit. */ @@ -227,8 +227,8 @@ ZEXTERN int ZEXPORT zng_deflateInit (zng_stream *strm, int level); deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if level is not a valid compression level, or - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). msg is set to null + Z_VERSION_ERROR if the zlib library version (zng_version) is incompatible + with the version assumed by the caller (ZLIBNG_VERSION). msg is set to null if there is no error message. deflateInit does not perform any compression: this will be done by deflate(). */ @@ -589,8 +589,8 @@ ZEXTERN int ZEXPORT zng_deflateInit2 (zng_stream *strm, deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid - method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is - incompatible with the version assumed by the caller (ZLIB_VERSION). msg is + method), or Z_VERSION_ERROR if the zlib library version (zng_version) is + incompatible with the version assumed by the caller (ZLIBNG_VERSION). msg is set to null if there is no error message. deflateInit2 does not perform any compression: this will be done by deflate(). */ @@ -1714,14 +1714,14 @@ ZEXTERN int ZEXPORT zng_deflateInit2_(zng_stream *strm, int level, int method, ZEXTERN int ZEXPORT zng_inflateInit2_(zng_stream *strm, int windowBits, const char *version, int stream_size); ZEXTERN int ZEXPORT zng_inflateBackInit_(zng_stream *strm, int windowBits, unsigned char *window, const char *version, int stream_size); -#define zng_deflateInit(strm, level) zng_deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(zng_stream)) -#define zng_inflateInit(strm) zng_inflateInit_((strm), ZLIB_VERSION, (int)sizeof(zng_stream)) +#define zng_deflateInit(strm, level) zng_deflateInit_((strm), (level), ZLIBNG_VERSION, (int)sizeof(zng_stream)) +#define zng_inflateInit(strm) zng_inflateInit_((strm), ZLIBNG_VERSION, (int)sizeof(zng_stream)) #define zng_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ zng_deflateInit2_((strm), (level), (method), (windowBits), (memLevel), \ - (strategy), ZLIB_VERSION, (int)sizeof(zng_stream)) -#define zng_inflateInit2(strm, windowBits) inflateInit2_((strm), (windowBits), ZLIB_VERSION, (int)sizeof(zng_stream)) + (strategy), ZLIBNG_VERSION, (int)sizeof(zng_stream)) +#define zng_inflateInit2(strm, windowBits) zng_inflateInit2_((strm), (windowBits), ZLIBNG_VERSION, (int)sizeof(zng_stream)) #define zng_inflateBackInit(strm, windowBits, window) \ - zng_inflateBackInit_((strm), (windowBits), (window), ZLIB_VERSION, (int)sizeof(zng_stream)) + zng_inflateBackInit_((strm), (windowBits), (window), ZLIBNG_VERSION, (int)sizeof(zng_stream)) #ifdef WITH_GZFILEOP diff --git a/zutil.c b/zutil.c index 049454d6..ff9e8fa6 100644 --- a/zutil.c +++ b/zutil.c @@ -26,10 +26,12 @@ const char * const z_errmsg[10] = { const char zlibng_string[] = " zlib-ng 1.9.9 forked from zlib 1.2.11 "; +#ifdef ZLIB_COMPAT const char * ZEXPORT zlibVersion(void) { return ZLIB_VERSION; } +#endif const char * ZEXPORT zlibng_version(void) { diff --git a/zutil.h b/zutil.h index 755479da..4889c21b 100644 --- a/zutil.h +++ b/zutil.h @@ -24,7 +24,11 @@ #include #include #include -#include "zlib.h" +#ifdef ZLIB_COMPAT +# include "zlib.h" +#else +# include "zlib-ng.h" +#endif typedef unsigned char uch; /* Included for compatibility with external code only */ typedef uint16_t ush; /* Included for compatibility with external code only */