Adapt code to support PREFIX macros and update build scripts

This commit is contained in:
Mika Lindqvist 2017-11-04 20:49:21 +02:00 committed by Hans Kristian Rosbach
parent 4408564a27
commit aff0fc6e3c
38 changed files with 550 additions and 390 deletions

4
.gitignore vendored
View File

@ -17,10 +17,12 @@
/example64 /example64
/examplesh /examplesh
/libz.so* /libz.so*
/libz-ng.so*
/minigzip /minigzip
/minigzip64 /minigzip64
/minigzipsh /minigzipsh
/zlib.pc /zlib.pc
/zlib-ng.pc
/CVE-2003-0107 /CVE-2003-0107
.DS_Store .DS_Store
@ -48,6 +50,8 @@ Testing
zconf.h zconf.h
zconf.h.cmakein zconf.h.cmakein
zconf.h.included zconf.h.included
zconf-ng.h
zconf-ng.h.cmakein
ztest* ztest*
configure.log configure.log

View File

@ -58,7 +58,7 @@ if (ZLIB_COMPAT)
else(ZLIB_COMPAT) else(ZLIB_COMPAT)
set (LIBNAME1 libz-ng) set (LIBNAME1 libz-ng)
set (LIBNAME2 zlib-ng) set (LIBNAME2 zlib-ng)
set (SUFFIX -ng) set (SUFFIX "-ng")
endif (ZLIB_COMPAT) endif (ZLIB_COMPAT)
option (WITH_GZFILEOP "Compile with support for gzFile related functions" OFF) option (WITH_GZFILEOP "Compile with support for gzFile related functions" OFF)
@ -553,15 +553,19 @@ endif (WITH_GZFILEOP)
if(NOT MINGW AND NOT MSYS) if(NOT MINGW AND NOT MSYS)
set(ZLIB_DLL_SRCS 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() endif()
# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION # 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) file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib${SUFFIX}.h _zlib_h_contents)
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" if (ZLIB_COMPAT)
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) "\\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) if(MINGW OR MSYS)
# This gets us DLL resource information when compiling on MinGW. # This gets us DLL resource information when compiling on MinGW.
if(NOT CMAKE_RC_COMPILER) if(NOT CMAKE_RC_COMPILER)
@ -574,7 +578,7 @@ if(MINGW OR MSYS)
-I ${CMAKE_CURRENT_SOURCE_DIR} -I ${CMAKE_CURRENT_SOURCE_DIR}
-I ${CMAKE_CURRENT_BINARY_DIR} -I ${CMAKE_CURRENT_BINARY_DIR}
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj -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) set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif(MINGW OR MSYS) endif(MINGW OR MSYS)

View File

@ -109,7 +109,7 @@ $(ARCHDIR)/%.lo: $(SRCDIR)/$(ARCHDIR)/%.c
test: all test: all
$(MAKE) -C test $(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 $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/test/infcover.c
infcover$(EXE): infcover.o $(STATICLIB) infcover$(EXE): infcover.o $(STATICLIB)
@ -127,20 +127,20 @@ $(STATICLIB): $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS) $(AR) $(ARFLAGS) $@ $(OBJS)
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1 -@ ($(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 $(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 $(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 $(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 $(CC) $(CFLAGS) -D_FILE_OFFSET_BITS=64 $(INCLUDES) -c -o $@ $(SRCDIR)/test/minigzip.c
zlibrc.o: win32/zlib1.rc zlibrc.o: win32/zlib$(SUFFIX)1.rc
$(RC) $(RCFLAGS) -o $@ win32/zlib1.rc $(RC) $(RCFLAGS) -o $@ win32/zlib$(SUFFIX)1.rc
.SUFFIXES: .lo .SUFFIXES: .lo
@ -316,60 +316,60 @@ depend:
# DO NOT DELETE THIS LINE -- make depend depends on it. # 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 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 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.h zconf.h compress.o example.o minigzip.o uncompr.o: $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h
crc32.o: $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/crc32.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.h zconf.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.h zconf.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.h zconf.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.h zconf.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.h zconf.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/inffixed.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.h zconf.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/memcopy.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.h zconf.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/inffixed.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.h zconf.h $(SRCDIR)/inftrees.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.h zconf.h $(SRCDIR)/trees.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.h zconf.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/adler32_neon.o: $(SRCDIR)/arch/aarch64/adler32_neon.h
arch/aarch64/crc32_acle.o: zconf.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/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.h zconf.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/adler32_neon.o: $(SRCDIR)/arch/arm/adler32_neon.h
arch/arm/crc32_acle.o: zconf.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/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.h zconf.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.h zconf.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.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$(SUFFIX).h zconf$(SUFFIX).h
arch/x86/deflate_quick.o: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.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.h zconf.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 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 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 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.h zconf.h compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)/zlib$(SUFFIX).h zconf$(SUFFIX).h
crc32.lo: $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.h $(SRCDIR)/crc32.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.h zconf.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.h zconf.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.h zconf.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.h zconf.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.h zconf.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/inffixed.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.h zconf.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/memcopy.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.h zconf.h $(SRCDIR)/inftrees.h $(SRCDIR)/inflate.h $(SRCDIR)/inffast.h $(SRCDIR)/inffixed.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.h zconf.h $(SRCDIR)/inftrees.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.h zconf.h $(SRCDIR)/trees.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.h zconf.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/adler32_neon.lo: $(SRCDIR)/arch/aarch64/adler32_neon.h
arch/aarch64/crc32_acle.lo: zconf.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/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.h zconf.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/adler32_neon.lo: $(SRCDIR)/arch/arm/adler32_neon.h
arch/arm/crc32_acle.lo: zconf.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/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.h zconf.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.h zconf.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.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$(SUFFIX).h zconf$(SUFFIX).h
arch/x86/deflate_quick.lo: $(SRCDIR)/deflate.h $(SRCDIR)/zutil.h $(SRCDIR)/zlib.h zconf.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.h zconf.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 arch/x86/x86.lo: $(SRCDIR)/arch/x86/x86.h

View File

@ -6,6 +6,7 @@ CC=
CFLAGS= CFLAGS=
SFLAGS= SFLAGS=
INCLUDES= INCLUDES=
SUFFIX=
SRCDIR=. SRCDIR=.
SRCTOP=../.. SRCTOP=../..
@ -55,12 +56,12 @@ depend:
# DO NOT DELETE THIS LINE -- make depend depends on it. # DO NOT DELETE THIS LINE -- make depend depends on it.
adler32_neon.o: $(SRCDIR)/adler32_neon.h adler32_neon.o: $(SRCDIR)/adler32_neon.h
crc32_acle.o: $(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.h $(TOPDIR)/zconf.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.h $(TOPDIR)/zconf.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 adler32_neon.lo: $(SRCDIR)/adler32_neon.h
crc32_acle.lo: $(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.h $(TOPDIR)/zconf.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.h $(TOPDIR)/zconf.h insert_string_acle.lo: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h

View File

@ -14,7 +14,7 @@
#include "deflate_p.h" #include "deflate_p.h"
#include "functable.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 #if __ARM_NEON
#include <arm_neon.h> #include <arm_neon.h>

View File

@ -6,6 +6,7 @@ CC=
CFLAGS= CFLAGS=
SFLAGS= SFLAGS=
INCLUDES= INCLUDES=
SUFFIX=
SRCDIR=. SRCDIR=.
SRCTOP=../.. SRCTOP=../..
@ -55,12 +56,12 @@ depend:
# DO NOT DELETE THIS LINE -- make depend depends on it. # DO NOT DELETE THIS LINE -- make depend depends on it.
adler32_neon.o: $(SRCDIR)/adler32_neon.h adler32_neon.o: $(SRCDIR)/adler32_neon.h
crc32_acle.o: $(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.h $(TOPDIR)/zconf.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.h $(TOPDIR)/zconf.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 adler32_neon.lo: $(SRCDIR)/adler32_neon.h
crc32_acle.lo: $(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.h $(TOPDIR)/zconf.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.h $(TOPDIR)/zconf.h insert_string_acle.lo: $(SRCTOP)/deflate.h $(SRCTOP)/zutil.h $(SRCTOP)/zlib$(SUFFIX).h $(TOPDIR)/zconf$(SUFFIX).h

View File

@ -14,7 +14,7 @@
#include "deflate_p.h" #include "deflate_p.h"
#include "functable.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__ #if __ARM_NEON__
#include <arm_neon.h> #include <arm_neon.h>

View File

@ -6,6 +6,7 @@ CC=
CFLAGS= CFLAGS=
SFLAGS= SFLAGS=
INCLUDES= INCLUDES=
SUFFIX=
SSE2FLAG=-msse2 SSE2FLAG=-msse2
SSE4FLAG=-msse4 SSE4FLAG=-msse4
@ -70,14 +71,14 @@ depend:
# DO NOT DELETE THIS LINE -- make depend depends on it. # 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_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.h $(TOPDIR)/zconf.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.h $(TOPDIR)/zconf.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.h $(TOPDIR)/zconf.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 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_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.h $(TOPDIR)/zconf.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.h $(TOPDIR)/zconf.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.h $(TOPDIR)/zconf.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 x86.lo: $(SRCDIR)/x86.h

View File

@ -14,7 +14,7 @@ ZLIB_INTERNAL void crc_reset(deflate_state *const s) {
crc_fold_init(s); crc_fold_init(s);
return; 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) { 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); 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) { if (x86_cpu_has_pclmulqdq) {
crc_fold_copy(strm->state, dst, strm->next_in, size); crc_fold_copy(strm->state, dst, strm->next_in, size);
return; return;
} }
memcpy(dst, strm->next_in, size); memcpy(dst, strm->next_in, size);
strm->adler = crc32(strm->adler, dst, size); strm->adler = PREFIX(crc32)(strm->adler, dst, size);
} }
#endif #endif

View File

@ -28,7 +28,7 @@
#endif #endif
extern void fill_window_sse(deflate_state *s); 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) { static inline long compare258(const unsigned char *const src0, const unsigned char *const src1) {
#ifdef _MSC_VER #ifdef _MSC_VER

View File

@ -15,7 +15,7 @@
#include "deflate_p.h" #include "deflate_p.h"
#include "functable.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) { ZLIB_INTERNAL void fill_window_sse(deflate_state *s) {
const __m128i xmm_wsize = _mm_set1_epi16(s->w_size); const __m128i xmm_wsize = _mm_set1_epi16(s->w_size);

View File

@ -25,7 +25,7 @@
*/ */
int ZEXPORT PREFIX(compress2)(unsigned char *dest, size_t *destLen, const unsigned char *source, int ZEXPORT PREFIX(compress2)(unsigned char *dest, size_t *destLen, const unsigned char *source,
size_t sourceLen, int level) { size_t sourceLen, int level) {
z_stream stream; PREFIX3(stream) stream;
int err; int err;
const unsigned int max = (unsigned int)-1; const unsigned int max = (unsigned int)-1;
size_t left; size_t left;
@ -37,7 +37,7 @@ int ZEXPORT PREFIX(compress2)(unsigned char *dest, size_t *destLen, const unsign
stream.zfree = NULL; stream.zfree = NULL;
stream.opaque = NULL; stream.opaque = NULL;
err = deflateInit(&stream, level); err = PREFIX(deflateInit)(&stream, level);
if (err != Z_OK) if (err != Z_OK)
return err; 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; stream.avail_in = sourceLen > (unsigned long)max ? max : (unsigned int)sourceLen;
sourceLen -= stream.avail_in; 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); } while (err == Z_OK);
*destLen = stream.total_out; *destLen = stream.total_out;
deflateEnd(&stream); PREFIX(deflateEnd)(&stream);
return err == Z_STREAM_END ? Z_OK : err; return err == Z_STREAM_END ? Z_OK : err;
} }

11
configure vendored
View File

@ -230,7 +230,7 @@ else
fi fi
STATICLIB=${LIBNAME}.a STATICLIB=${LIBNAME}.a
MAPNAME=$LIBNAME2.map MAPNAME=${LIBNAME2}.map
# extract zlib version numbers from zlib.h # extract zlib version numbers from zlib.h
if test $compat -eq 0; then 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"} LDSHARED=${LDSHARED-"$cc"}
LDSHAREDFLAGS="-shared -Wl,--out-implib,${IMPORTLIB},--version-script,${SRCDIR}/${MAPNAME}" LDSHAREDFLAGS="-shared -Wl,--out-implib,${IMPORTLIB},--version-script,${SRCDIR}/${MAPNAME}"
LDSHAREDLIBC="" LDSHAREDLIBC=""
DEFFILE='win32/zlib.def' DEFFILE='win32/${LIBNAME2}.def'
RC="${CROSS_PREFIX}windres" RC="${CROSS_PREFIX}windres"
RCFLAGS='--define GCC_WINDRES' RCFLAGS='--define GCC_WINDRES'
RCOBJS='zlibrc.o' 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"} LDSHARED=${LDSHARED-"$cc"}
LDSHAREDFLAGS="-shared -Wl,--out-implib,${IMPORTLIB}" LDSHAREDFLAGS="-shared -Wl,--out-implib,${IMPORTLIB}"
LDSHAREDLIBC="" LDSHAREDLIBC=""
DEFFILE='win32/zlib.def' DEFFILE='win32/${LIBNAME2}.def'
RC="${CROSS_PREFIX}windres" RC="${CROSS_PREFIX}windres"
RCFLAGS='--define GCC_WINDRES' RCFLAGS='--define GCC_WINDRES'
RCOBJS='zlibrc.o' 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"} LDSHARED=${LDSHARED-"$cc"}
LDSHAREDFLAGS="-shared -Wl,--out-implib=${IMPORTLIB} -Wl,--version-script=${SRCDIR}/${MAPNAME}" LDSHAREDFLAGS="-shared -Wl,--out-implib=${IMPORTLIB} -Wl,--version-script=${SRCDIR}/${MAPNAME}"
LDSHAREDLIBC="" LDSHAREDLIBC=""
DEFFILE='win32/zlib.def' DEFFILE='win32/${LIBNAME2}.def'
RC="${CROSS_PREFIX}windres" RC="${CROSS_PREFIX}windres"
RCFLAGS='--define GCC_WINDRES' RCFLAGS='--define GCC_WINDRES'
if [ "$CC" == "mingw32-gcc" ]; then if [ "$CC" == "mingw32-gcc" ]; then
@ -672,7 +672,7 @@ echo >> configure.log
cat > $test.c <<EOF cat > $test.c <<EOF
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include "zconf.h" #include "zconf${SUFFIX}.h"
int main() { int main() {
#ifdef STDC #ifdef STDC
return 0; return 0;
@ -1048,6 +1048,7 @@ sed < $SRCDIR/$ARCHDIR/Makefile.in "
/^SFLAGS *=/s#=.*#=$SFLAGS# /^SFLAGS *=/s#=.*#=$SFLAGS#
/^LDFLAGS *=/s#=.*#=$LDFLAGS# /^LDFLAGS *=/s#=.*#=$LDFLAGS#
/^INCLUDES *=/s#=.*#=$ARCHINCLUDES# /^INCLUDES *=/s#=.*#=$ARCHINCLUDES#
/^SUFFIX *=/s#=.*#=$SUFFIX#
/^SRCDIR *=/s#=.*#=$SRCDIR/$ARCHDIR# /^SRCDIR *=/s#=.*#=$SRCDIR/$ARCHDIR#
/^SRCTOP *=/s#=.*#=$SRCDIR# /^SRCTOP *=/s#=.*#=$SRCDIR#
/^TOPDIR *=/s#=.*#=$BUILDDIR# /^TOPDIR *=/s#=.*#=$BUILDDIR#

View File

@ -452,12 +452,12 @@ uint32_t ZEXPORT PREFIX(crc32_combine64)(uint32_t crc1, uint32_t crc2, z_off64_t
#ifndef X86_PCLMULQDQ_CRC #ifndef X86_PCLMULQDQ_CRC
ZLIB_INTERNAL void crc_reset(deflate_state *const s) { 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); memcpy(dst, strm->next_in, size);
strm->adler = crc32(strm->adler, dst, size); strm->adler = PREFIX(crc32)(strm->adler, dst, size);
} }
#endif #endif

View File

@ -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); typedef block_state (*compress_func) (deflate_state *s, int flush);
/* Compression function. Returns the block state after the call. */ /* 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 void slide_hash (deflate_state *s);
static block_state deflate_stored (deflate_state *s, int flush); static block_state deflate_stored (deflate_state *s, int flush);
ZLIB_INTERNAL block_state deflate_fast (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 block_state deflate_huff (deflate_state *s, int flush);
static void lm_init (deflate_state *s); static void lm_init (deflate_state *s);
static void putShortMSB (deflate_state *s, uint16_t b); static void putShortMSB (deflate_state *s, uint16_t b);
ZLIB_INTERNAL void flush_pending (z_stream *strm); ZLIB_INTERNAL void flush_pending (PREFIX3(stream) *strm);
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);
extern void crc_reset(deflate_state *const s); extern void crc_reset(deflate_state *const s);
#ifdef X86_PCLMULQDQ_CRC #ifdef X86_PCLMULQDQ_CRC
extern void crc_finalize(deflate_state *const s); extern void crc_finalize(deflate_state *const s);
#endif #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 * 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); 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 */ /* 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) { int memLevel, int strategy, const char *version, int stream_size) {
unsigned window_padding = 0; unsigned window_padding = 0;
deflate_state *s; deflate_state *s;
int wrap = 1; int wrap = 1;
static const char my_version[] = ZLIB_VERSION; static const char my_version[] = PREFIX2(VERSION);
uint16_t *overlay; uint16_t *overlay;
/* We overlay pending_buf and d_buf+l_buf. This works since the average /* 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(); x86_check_features();
#endif #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; return Z_VERSION_ERROR;
} }
if (strm == NULL) 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->pending_buf == NULL) {
s->status = FINISH_STATE; s->status = FINISH_STATE;
strm->msg = ERR_MSG(Z_MEM_ERROR); strm->msg = ERR_MSG(Z_MEM_ERROR);
deflateEnd(strm); PREFIX(deflateEnd)(strm);
return Z_MEM_ERROR; return Z_MEM_ERROR;
} }
s->d_buf = overlay + s->lit_bufsize/sizeof(uint16_t); 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->method = (unsigned char)method;
s->block_open = 0; 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. * 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; deflate_state *s;
if (strm == NULL || if (strm == NULL ||
strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) 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; deflate_state *s;
unsigned int str, n; unsigned int str, n;
int wrap; 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; deflate_state *s;
unsigned int len; 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; deflate_state *s;
if (deflateStateCheck(strm)) { 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; int ret;
ret = deflateResetKeep(strm); ret = PREFIX(deflateResetKeep)(strm);
if (ret == Z_OK) if (ret == Z_OK)
lm_init(strm->state); lm_init(strm->state);
return ret; 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) if (deflateStateCheck(strm) || strm->state->wrap != 2)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
strm->state->gzhead = head; 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)) if (deflateStateCheck(strm))
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
if (pending != NULL) 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; deflate_state *s;
int put; 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; deflate_state *s;
compress_func func; 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) { if ((strategy != s->strategy || func != configuration_table[level].func) && s->high_water) {
/* Flush the last buffer: */ /* Flush the last buffer: */
int err = deflate(strm, Z_BLOCK); int err = PREFIX(deflate)(strm, Z_BLOCK);
if (err == Z_STREAM_ERROR) if (err == Z_STREAM_ERROR)
return err; return err;
if (strm->avail_out == 0) 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; deflate_state *s;
if (deflateStateCheck(strm)) 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 * upper bound of about 14% expansion does not seem onerous for output buffer
* allocation. * 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; deflate_state *s;
unsigned long complen, wraplen; 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 * applications may wish to modify it to avoid allocating a large
* strm->next_out buffer and copying into it. (See also read_buf()). * 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; uint32_t len;
deflate_state *s = strm->state; deflate_state *s = strm->state;
@ -704,11 +704,11 @@ ZLIB_INTERNAL void flush_pending(z_stream *strm) {
#define HCRC_UPDATE(beg) \ #define HCRC_UPDATE(beg) \
do { \ do { \
if (s->gzhead->hcrc && s->pending > (beg)) \ 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) } 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 */ int old_flush; /* value of flush param for previous deflate call */
deflate_state *s; 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); put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
} }
if (s->gzhead->hcrc) 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->gzindex = 0;
s->status = EXTRA_STATE; 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; int status;
if (deflateStateCheck(strm)) if (deflateStateCheck(strm))
@ -1048,7 +1048,7 @@ int ZEXPORT PREFIX(deflateEnd)(z_stream *strm) {
/* ========================================================================= /* =========================================================================
* Copy the source state to the destination state. * 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 *ds;
deflate_state *ss; deflate_state *ss;
uint16_t *overlay; uint16_t *overlay;
@ -1059,7 +1059,7 @@ int ZEXPORT PREFIX(deflateCopy)(z_stream *dest, z_stream *source) {
ss = source->state; 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)); ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
if (ds == NULL) if (ds == NULL)
@ -1075,7 +1075,7 @@ int ZEXPORT PREFIX(deflateCopy)(z_stream *dest, z_stream *source) {
ds->pending_buf = (unsigned char *) overlay; ds->pending_buf = (unsigned char *) overlay;
if (ds->window == NULL || ds->prev == NULL || ds->head == NULL || ds->pending_buf == NULL) { if (ds->window == NULL || ds->prev == NULL || ds->head == NULL || ds->pending_buf == NULL) {
deflateEnd(dest); PREFIX(deflateEnd)(dest);
return Z_MEM_ERROR; 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. * allocating a large strm->next_in buffer and copying from it.
* (See also flush_pending()). * (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; uint32_t len = strm->avail_in;
if (len > size) if (len > size)

View File

@ -103,14 +103,14 @@ typedef unsigned IPos;
*/ */
typedef struct internal_state { typedef struct internal_state {
z_stream *strm; /* pointer back to this zlib stream */ PREFIX3(stream) *strm; /* pointer back to this zlib stream */
int status; /* as the name implies */ int status; /* as the name implies */
unsigned char *pending_buf; /* output still pending */ unsigned char *pending_buf; /* output still pending */
unsigned long pending_buf_size; /* size of pending_buf */ unsigned long pending_buf_size; /* size of pending_buf */
unsigned char *pending_out; /* next pending byte to output to the stream */ unsigned char *pending_out; /* next pending byte to output to the stream */
uint32_t pending; /* nb of bytes in the pending buffer */ uint32_t pending; /* nb of bytes in the pending buffer */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
gz_headerp gzhead; /* gzip header information to write */ PREFIX(gz_headerp) gzhead; /* gzip header information to write */
uint32_t gzindex; /* where in extra, name, or comment */ uint32_t gzindex; /* where in extra, name, or comment */
unsigned char method; /* can only be DEFLATED */ unsigned char method; /* can only be DEFLATED */
int last_flush; /* value of flush param for previous deflate call */ int last_flush; /* value of flush param for previous deflate call */

View File

@ -20,7 +20,7 @@ void check_match(deflate_state *s, IPos start, IPos match, int length);
#else #else
#define check_match(s, start, match, length) #define check_match(s, start, match, length)
#endif #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 * Insert string str in the dictionary and set match_head to the previous head

View File

@ -16,8 +16,8 @@ int ZEXPORT PREFIX(gzclose)(gzFile file) {
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
state = (gz_state *)file; 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 #else
return gzclose_r(file); return PREFIX(gzclose_r)(file);
#endif #endif
} }

View File

@ -331,7 +331,7 @@ z_off64_t ZEXPORT PREFIX(gzseek64)(gzFile file, z_off64_t offset, int whence) {
offset += state->x.pos; offset += state->x.pos;
if (offset < 0) /* before start of file! */ if (offset < 0) /* before start of file! */
return -1; return -1;
if (gzrewind(file) == -1) /* rewind, then skip to offset */ if (PREFIX(gzrewind)(file) == -1) /* rewind, then skip to offset */
return -1; 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_off_t ZEXPORT PREFIX(gzseek)(gzFile file, z_off_t offset, int whence) {
z_off64_t ret; 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; 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_off_t ZEXPORT PREFIX(gztell)(gzFile file) {
z_off64_t ret; z_off64_t ret;
ret = gztell64(file); ret = PREFIX(gztell64)(file);
return ret == (z_off_t)ret ? (z_off_t)ret : -1; 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_off_t ZEXPORT PREFIX(gzoffset)(gzFile file) {
z_off64_t ret; z_off64_t ret;
ret = gzoffset64(file); ret = PREFIX(gzoffset64)(file);
return ret == (z_off_t)ret ? (z_off_t)ret : -1; return ret == (z_off_t)ret ? (z_off_t)ret : -1;
} }

View File

@ -98,7 +98,7 @@ static int gz_look(gz_state *state) {
state->strm.opaque = NULL; state->strm.opaque = NULL;
state->strm.avail_in = 0; state->strm.avail_in = 0;
state->strm.next_in = NULL; 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->out);
free(state->in); free(state->in);
state->size = 0; 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) */ single byte is sufficient indication that it is not a gzip file) */
if (strm->avail_in > 1 && if (strm->avail_in > 1 &&
strm->next_in[0] == 31 && strm->next_in[1] == 139) { strm->next_in[0] == 31 && strm->next_in[1] == 139) {
inflateReset(strm); PREFIX(inflateReset)(strm);
state->how = GZIP; state->how = GZIP;
state->direct = 0; state->direct = 0;
return 0; return 0;
@ -175,7 +175,7 @@ static int gz_decomp(gz_state *state) {
} }
/* decompress and handle errors */ /* 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) { if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {
gz_error(state, Z_STREAM_ERROR, "internal error: inflate stream corrupt"); gz_error(state, Z_STREAM_ERROR, "internal error: inflate stream corrupt");
return -1; return -1;
@ -432,7 +432,7 @@ int ZEXPORT PREFIX(gzgetc)(gzFile file) {
} }
int ZEXPORT PREFIX(gzgetc_)(gzFile file) { int ZEXPORT PREFIX(gzgetc_)(gzFile file) {
return gzgetc(file); return PREFIX(gzgetc)(file);
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
@ -586,7 +586,7 @@ int ZEXPORT PREFIX(gzclose_r)(gzFile file) {
/* free memory and close file */ /* free memory and close file */
if (state->size) { if (state->size) {
inflateEnd(&(state->strm)); PREFIX(inflateEnd)(&(state->strm));
free(state->out); free(state->out);
free(state->in); free(state->in);
} }

View File

@ -40,7 +40,7 @@ static int gz_init(gz_state *state) {
strm->zalloc = NULL; strm->zalloc = NULL;
strm->zfree = NULL; strm->zfree = NULL;
strm->opaque = 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) { if (ret != Z_OK) {
free(state->out); free(state->out);
free(state->in); free(state->in);
@ -110,7 +110,7 @@ static int gz_comp(gz_state *state, int flush) {
/* compress */ /* compress */
have = strm->avail_out; have = strm->avail_out;
ret = deflate(strm, flush); ret = PREFIX(deflate)(strm, flush);
if (ret == Z_STREAM_ERROR) { if (ret == Z_STREAM_ERROR) {
gz_error(state, Z_STREAM_ERROR, "internal error: deflate stream corrupt"); gz_error(state, Z_STREAM_ERROR, "internal error: deflate stream corrupt");
return -1; 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 that completed a deflate stream, allow another to start */
if (flush == Z_FINISH) if (flush == Z_FINISH)
deflateReset(strm); PREFIX(deflateReset)(strm);
/* all done, no errors */ /* all done, no errors */
return 0; return 0;
@ -400,7 +400,7 @@ int ZEXPORTVA PREFIX(gzprintf)(gzFile file, const char *format, ...) {
int ret; int ret;
va_start(va, format); va_start(va, format);
ret = gzvprintf(file, format, va); ret = PREFIX(gzvprintf)(file, format, va);
va_end(va); va_end(va);
return ret; return ret;
} }
@ -465,7 +465,7 @@ int ZEXPORT PREFIX(gzsetparams)(gzFile file, int level, int strategy) {
/* flush previous input with previous parameters before changing */ /* flush previous input with previous parameters before changing */
if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1) if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1)
return state->err; return state->err;
deflateParams(strm, level, strategy); PREFIX(deflateParams)(strm, level, strategy);
} }
state->level = level; state->level = level;
state->strategy = strategy; state->strategy = strategy;
@ -498,7 +498,7 @@ int ZEXPORT PREFIX(gzclose_w)(gzFile file) {
ret = state->err; ret = state->err;
if (state->size) { if (state->size) {
if (!state->direct) { if (!state->direct) {
(void)deflateEnd(&(state->strm)); (void)PREFIX(deflateEnd)(&(state->strm));
free(state->out); free(state->out);
} }
free(state->in); free(state->in);

View File

@ -25,11 +25,11 @@ static void fixedtables(struct inflate_state *state);
windowBits is in the range 8..15, and window is a user-supplied windowBits is in the range 8..15, and window is a user-supplied
window and output buffer that is 2**windowBits bytes. 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) { const char *version, int stream_size) {
struct inflate_state *state; 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; return Z_VERSION_ERROR;
if (strm == NULL || window == NULL || windowBits < 8 || windowBits > 15) if (strm == NULL || window == NULL || windowBits < 8 || windowBits > 15)
return Z_STREAM_ERROR; 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 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. 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; struct inflate_state *state;
const unsigned char *next; /* next input */ const unsigned char *next; /* next input */
unsigned char *put; /* next output */ 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; 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) if (strm == NULL || strm->state == NULL || strm->zfree == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
ZFREE(strm, strm->state); ZFREE(strm, strm->state);

View File

@ -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 requires strm->avail_out >= 258 for each loop to avoid checking for
output space. 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 */ /* start: inflate()'s starting value for strm->avail_out */
struct inflate_state *state; struct inflate_state *state;
const unsigned char *in; /* local strm->next_in */ const unsigned char *in; /* local strm->next_in */

View File

@ -10,7 +10,7 @@
subject to change. Applications should only use zlib.h. 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__) #if (defined(__GNUC__) || defined(__clang__)) && defined(__ARM_NEON__)

View File

@ -94,15 +94,15 @@
#endif #endif
/* function prototypes */ /* function prototypes */
static int inflateStateCheck(z_stream *strm); static int inflateStateCheck(PREFIX3(stream) *strm);
static void fixedtables(struct inflate_state *state); 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 #ifdef BUILDFIXED
void makefixed(void); void makefixed(void);
#endif #endif
static uint32_t syncsearch(uint32_t *have, const unsigned char *buf, uint32_t len); 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; struct inflate_state *state;
if (strm == NULL || strm->zalloc == NULL || strm->zfree == NULL) if (strm == NULL || strm->zalloc == NULL || strm->zfree == NULL)
return 1; return 1;
@ -112,7 +112,7 @@ static int inflateStateCheck(z_stream *strm) {
return 0; return 0;
} }
int ZEXPORT PREFIX(inflateResetKeep)(z_stream *strm) { int ZEXPORT PREFIX(inflateResetKeep)(PREFIX3(stream) *strm) {
struct inflate_state *state; struct inflate_state *state;
if (inflateStateCheck(strm)) if (inflateStateCheck(strm))
@ -136,7 +136,7 @@ int ZEXPORT PREFIX(inflateResetKeep)(z_stream *strm) {
return Z_OK; return Z_OK;
} }
int ZEXPORT PREFIX(inflateReset)(z_stream *strm) { int ZEXPORT PREFIX(inflateReset)(PREFIX3(stream) *strm) {
struct inflate_state *state; struct inflate_state *state;
if (inflateStateCheck(strm)) if (inflateStateCheck(strm))
@ -145,10 +145,10 @@ int ZEXPORT PREFIX(inflateReset)(z_stream *strm) {
state->wsize = 0; state->wsize = 0;
state->whave = 0; state->whave = 0;
state->wnext = 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; int wrap;
struct inflate_state *state; 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 */ /* update state and reset the rest of it */
state->wrap = wrap; state->wrap = wrap;
state->wbits = (unsigned)windowBits; 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; int ret;
struct inflate_state *state; 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; return Z_VERSION_ERROR;
if (strm == NULL) if (strm == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
@ -206,7 +206,7 @@ int ZEXPORT PREFIX(inflateInit2_)(z_stream *strm, int windowBits, const char *ve
state->strm = strm; state->strm = strm;
state->window = NULL; state->window = NULL;
state->mode = HEAD; /* to pass state test in inflateReset2() */ state->mode = HEAD; /* to pass state test in inflateReset2() */
ret = inflateReset2(strm, windowBits); ret = PREFIX(inflateReset2)(strm, windowBits);
if (ret != Z_OK) { if (ret != Z_OK) {
ZFREE(strm, state); ZFREE(strm, state);
strm->state = NULL; strm->state = NULL;
@ -214,11 +214,11 @@ int ZEXPORT PREFIX(inflateInit2_)(z_stream *strm, int windowBits, const char *ve
return ret; return ret;
} }
int ZEXPORT PREFIX(inflateInit_)(z_stream *strm, const char *version, int stream_size) { int ZEXPORT PREFIX(inflateInit_)(PREFIX3(stream) *strm, const char *version, int stream_size) {
return inflateInit2_(strm, DEF_WBITS, version, 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; struct inflate_state *state;
if (inflateStateCheck(strm)) if (inflateStateCheck(strm))
@ -365,7 +365,7 @@ void makefixed(void) {
output will fall in the output data, making match copies simpler and faster. 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. 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; struct inflate_state *state;
uint32_t dist; 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 */ /* check function to use adler32() for zlib or crc32() for gzip */
#ifdef GUNZIP #ifdef GUNZIP
# define UPDATE(check, buf, len) \ # 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 #else
# define UPDATE(check, buf, len) functable.adler32(check, buf, len) # define UPDATE(check, buf, len) functable.adler32(check, buf, len)
#endif #endif
@ -435,7 +435,7 @@ static int updatewindow(z_stream *strm, const unsigned char *end, uint32_t copy)
do { \ do { \
hbuf[0] = (unsigned char)(word); \ hbuf[0] = (unsigned char)(word); \
hbuf[1] = (unsigned char)((word) >> 8); \ hbuf[1] = (unsigned char)((word) >> 8); \
check = crc32(check, hbuf, 2); \ check = PREFIX(crc32)(check, hbuf, 2); \
} while (0) } while (0)
# define CRC4(check, word) \ # 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[1] = (unsigned char)((word) >> 8); \
hbuf[2] = (unsigned char)((word) >> 16); \ hbuf[2] = (unsigned char)((word) >> 16); \
hbuf[3] = (unsigned char)((word) >> 24); \ hbuf[3] = (unsigned char)((word) >> 24); \
check = crc32(check, hbuf, 4); \ check = PREFIX(crc32)(check, hbuf, 4); \
} while (0) } while (0)
#endif #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. 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; struct inflate_state *state;
const unsigned char *next; /* next input */ const unsigned char *next; /* next input */
unsigned char *put; /* next output */ 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->wrap & 2) && hold == 0x8b1f) { /* gzip header */
if (state->wbits == 0) if (state->wbits == 0)
state->wbits = 15; state->wbits = 15;
state->check = crc32(0L, NULL, 0); state->check = PREFIX(crc32)(0L, NULL, 0);
CRC2(state->check, hold); CRC2(state->check, hold);
INITBITS(); INITBITS();
state->mode = FLAGS; state->mode = FLAGS;
@ -741,7 +741,7 @@ int ZEXPORT PREFIX(inflate)(z_stream *strm, int flush) {
state->head->extra_max - len : copy); state->head->extra_max - len : copy);
} }
if ((state->flags & 0x0200) && (state->wrap & 4)) if ((state->flags & 0x0200) && (state->wrap & 4))
state->check = crc32(state->check, next, copy); state->check = PREFIX(crc32)(state->check, next, copy);
have -= copy; have -= copy;
next += copy; next += copy;
state->length -= 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; state->head->name[state->length++] = (unsigned char)len;
} while (len && copy < have); } while (len && copy < have);
if ((state->flags & 0x0200) && (state->wrap & 4)) if ((state->flags & 0x0200) && (state->wrap & 4))
state->check = crc32(state->check, next, copy); state->check = PREFIX(crc32)(state->check, next, copy);
have -= copy; have -= copy;
next += copy; next += copy;
if (len) if (len)
@ -782,7 +782,7 @@ int ZEXPORT PREFIX(inflate)(z_stream *strm, int flush) {
state->head->comment[state->length++] = (unsigned char)len; state->head->comment[state->length++] = (unsigned char)len;
} while (len && copy < have); } while (len && copy < have);
if ((state->flags & 0x0200) && (state->wrap & 4)) if ((state->flags & 0x0200) && (state->wrap & 4))
state->check = crc32(state->check, next, copy); state->check = PREFIX(crc32)(state->check, next, copy);
have -= copy; have -= copy;
next += copy; next += copy;
if (len) 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->hcrc = (int)((state->flags >> 9) & 1);
state->head->done = 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; state->mode = TYPE;
break; break;
#endif #endif
@ -1259,7 +1259,7 @@ int ZEXPORT PREFIX(inflate)(z_stream *strm, int flush) {
return ret; return ret;
} }
int ZEXPORT PREFIX(inflateEnd)(z_stream *strm) { int ZEXPORT PREFIX(inflateEnd)(PREFIX3(stream) *strm) {
struct inflate_state *state; struct inflate_state *state;
if (inflateStateCheck(strm)) if (inflateStateCheck(strm))
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
@ -1272,7 +1272,7 @@ int ZEXPORT PREFIX(inflateEnd)(z_stream *strm) {
return Z_OK; 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; struct inflate_state *state;
/* check state */ /* check state */
@ -1290,7 +1290,7 @@ int ZEXPORT PREFIX(inflateGetDictionary)(z_stream *strm, unsigned char *dictiona
return Z_OK; 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; struct inflate_state *state;
unsigned long dictid; unsigned long dictid;
int ret; int ret;
@ -1322,7 +1322,7 @@ int ZEXPORT PREFIX(inflateSetDictionary)(z_stream *strm, const unsigned char *di
return Z_OK; 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; struct inflate_state *state;
/* check state */ /* check state */
@ -1368,7 +1368,7 @@ static unsigned syncsearch(uint32_t *have, const unsigned char *buf, uint32_t le
return next; 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 */ unsigned len; /* number of bytes to look at or looked at */
size_t in, out; /* temporary to save total_in and total_out */ size_t in, out; /* temporary to save total_in and total_out */
unsigned char buf[4]; /* to restore bit buffer to byte string */ 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; return Z_DATA_ERROR;
in = strm->total_in; in = strm->total_in;
out = strm->total_out; out = strm->total_out;
inflateReset(strm); PREFIX(inflateReset)(strm);
strm->total_in = in; strm->total_in = in;
strm->total_out = out; strm->total_out = out;
state->mode = TYPE; 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, block. When decompressing, PPP checks that at the end of input packet,
inflate is waiting for these length bytes. 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; struct inflate_state *state;
if (inflateStateCheck(strm)) if (inflateStateCheck(strm))
@ -1431,7 +1431,7 @@ int ZEXPORT PREFIX(inflateSyncPoint)(z_stream *strm) {
return state->mode == STORED && state->bits == 0; 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 *state;
struct inflate_state *copy; struct inflate_state *copy;
unsigned char *window; unsigned char *window;
@ -1457,7 +1457,7 @@ int ZEXPORT PREFIX(inflateCopy)(z_stream *dest, z_stream *source) {
} }
/* copy state */ /* 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)); memcpy((void *)copy, (void *)state, sizeof(struct inflate_state));
copy->strm = dest; copy->strm = dest;
if (state->lencode >= state->codes && state->lencode <= state->codes + ENOUGH - 1) { 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; 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; struct inflate_state *state;
if (inflateStateCheck(strm)) if (inflateStateCheck(strm))
@ -1490,7 +1490,7 @@ int ZEXPORT PREFIX(inflateUndermine)(z_stream *strm, int subvert) {
#endif #endif
} }
int ZEXPORT PREFIX(inflateValidate)(z_stream *strm, int check) { int ZEXPORT PREFIX(inflateValidate)(PREFIX3(stream) *strm, int check) {
struct inflate_state *state; struct inflate_state *state;
if (inflateStateCheck(strm)) if (inflateStateCheck(strm))
@ -1503,7 +1503,7 @@ int ZEXPORT PREFIX(inflateValidate)(z_stream *strm, int check) {
return Z_OK; return Z_OK;
} }
long ZEXPORT PREFIX(inflateMark)(z_stream *strm) { long ZEXPORT PREFIX(inflateMark)(PREFIX3(stream) *strm) {
struct inflate_state *state; struct inflate_state *state;
if (inflateStateCheck(strm)) if (inflateStateCheck(strm))
@ -1513,7 +1513,7 @@ long ZEXPORT PREFIX(inflateMark)(z_stream *strm) {
(state->mode == MATCH ? state->was - state->length : 0)); (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; struct inflate_state *state;
if (strm == NULL || strm->state == NULL) if (strm == NULL || strm->state == NULL)
return (unsigned long)-1; return (unsigned long)-1;

View File

@ -83,7 +83,7 @@ typedef enum {
/* State maintained between inflate() calls -- approximately 7K bytes, not /* State maintained between inflate() calls -- approximately 7K bytes, not
including the allocated sliding window, which is up to 32K bytes. */ including the allocated sliding window, which is up to 32K bytes. */
struct inflate_state { 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 */ inflate_mode mode; /* current inflate mode */
int last; /* true if processing last block */ int last; /* true if processing last block */
int wrap; /* bit 0 true for zlib, bit 1 true for gzip, 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 dmax; /* zlib header max distance (INFLATE_STRICT) */
unsigned long check; /* protected copy of check value */ unsigned long check; /* protected copy of check value */
unsigned long total; /* protected copy of output count */ 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 */ /* sliding window */
unsigned wbits; /* log base 2 of requested window size */ unsigned wbits; /* log base 2 of requested window size */
uint32_t wsize; /* window size or zero if not using window */ uint32_t wsize; /* window size or zero if not using window */

View File

@ -5,7 +5,12 @@
/* @(#) $Id$ */ /* @(#) $Id$ */
#include "zlib.h" #ifdef ZLIB_COMPAT
# include "zlib.h"
#else
# include "zlib-ng.h"
#endif
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -54,12 +59,12 @@ void test_compress(unsigned char *compr, size_t comprLen, unsigned char *uncompr
int err; int err;
size_t len = strlen(hello)+1; 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"); CHECK_ERR(err, "compress");
strcpy((char*)uncompr, "garbage"); strcpy((char*)uncompr, "garbage");
err = uncompress(uncompr, &uncomprLen, compr, comprLen); err = PREFIX(uncompress)(uncompr, &uncomprLen, compr, comprLen);
CHECK_ERR(err, "uncompress"); CHECK_ERR(err, "uncompress");
if (strcmp((char*)uncompr, hello)) { if (strcmp((char*)uncompr, hello)) {
@ -87,32 +92,32 @@ void test_gzio(const char *fname, unsigned char *uncompr, size_t uncomprLen)
gzFile file; gzFile file;
z_off_t pos; z_off_t pos;
file = gzopen(fname, "wb"); file = PREFIX(gzopen)(fname, "wb");
if (file == NULL) { if (file == NULL) {
fprintf(stderr, "gzopen error\n"); fprintf(stderr, "gzopen error\n");
exit(1); exit(1);
} }
gzputc(file, 'h'); PREFIX(gzputc)(file, 'h');
if (gzputs(file, "ello") != 4) { if (PREFIX(gzputs)(file, "ello") != 4) {
fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err)); fprintf(stderr, "gzputs err: %s\n", PREFIX(gzerror)(file, &err));
exit(1); exit(1);
} }
if (gzprintf(file, ", %s!", "hello") != 8) { if (PREFIX(gzprintf)(file, ", %s!", "hello") != 8) {
fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err)); fprintf(stderr, "gzprintf err: %s\n", PREFIX(gzerror)(file, &err));
exit(1); exit(1);
} }
gzseek(file, 1L, SEEK_CUR); /* add one zero byte */ PREFIX(gzseek)(file, 1L, SEEK_CUR); /* add one zero byte */
gzclose(file); PREFIX(gzclose)(file);
file = gzopen(fname, "rb"); file = PREFIX(gzopen)(fname, "rb");
if (file == NULL) { if (file == NULL) {
fprintf(stderr, "gzopen error\n"); fprintf(stderr, "gzopen error\n");
exit(1); exit(1);
} }
strcpy((char*)uncompr, "garbage"); strcpy((char*)uncompr, "garbage");
if (gzread(file, uncompr, (unsigned)uncomprLen) != len) { if (PREFIX(gzread)(file, uncompr, (unsigned)uncomprLen) != len) {
fprintf(stderr, "gzread err: %s\n", gzerror(file, &err)); fprintf(stderr, "gzread err: %s\n", PREFIX(gzerror)(file, &err));
exit(1); exit(1);
} }
if (strcmp((char*)uncompr, hello)) { 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); printf("gzread(): %s\n", (char*)uncompr);
} }
pos = gzseek(file, -8L, SEEK_CUR); pos = PREFIX(gzseek)(file, -8L, SEEK_CUR);
if (pos != 6 || gztell(file) != pos) { if (pos != 6 || PREFIX(gztell)(file) != pos) {
fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
(long)pos, (long)gztell(file)); (long)pos, (long)PREFIX(gztell)(file));
exit(1); exit(1);
} }
if (gzgetc(file) != ' ') { if (PREFIX(gzgetc)(file) != ' ') {
fprintf(stderr, "gzgetc error\n"); fprintf(stderr, "gzgetc error\n");
exit(1); exit(1);
} }
if (gzungetc(' ', file) != ' ') { if (PREFIX(gzungetc)(' ', file) != ' ') {
fprintf(stderr, "gzungetc error\n"); fprintf(stderr, "gzungetc error\n");
exit(1); exit(1);
} }
gzgets(file, (char*)uncompr, (int)uncomprLen); PREFIX(gzgets)(file, (char*)uncompr, (int)uncomprLen);
if (strlen((char*)uncompr) != 7) { /* " hello!" */ 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); exit(1);
} }
if (strcmp((char*)uncompr, hello + 6)) { 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); printf("gzgets() after gzseek: %s\n", (char*)uncompr);
} }
gzclose(file); PREFIX(gzclose)(file);
#endif #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) void test_deflate(unsigned char *compr, size_t comprLen)
{ {
z_stream c_stream; /* compression stream */ PREFIX3(stream) c_stream; /* compression stream */
int err; int err;
unsigned long len = (unsigned long)strlen(hello)+1; 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.zfree = zfree;
c_stream.opaque = (void *)0; c_stream.opaque = (void *)0;
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION);
CHECK_ERR(err, "deflateInit"); CHECK_ERR(err, "deflateInit");
c_stream.next_in = (const unsigned char *)hello; 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) { while (c_stream.total_in != len && c_stream.total_out < comprLen) {
c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ 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"); CHECK_ERR(err, "deflate");
} }
/* Finish the stream, still forcing small buffers: */ /* Finish the stream, still forcing small buffers: */
for (;;) { for (;;) {
c_stream.avail_out = 1; c_stream.avail_out = 1;
err = deflate(&c_stream, Z_FINISH); err = PREFIX(deflate)(&c_stream, Z_FINISH);
if (err == Z_STREAM_END) break; if (err == Z_STREAM_END) break;
CHECK_ERR(err, "deflate"); CHECK_ERR(err, "deflate");
} }
err = deflateEnd(&c_stream); err = PREFIX(deflateEnd)(&c_stream);
CHECK_ERR(err, "deflateEnd"); 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) void test_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen)
{ {
int err; int err;
z_stream d_stream; /* decompression stream */ PREFIX3(stream) d_stream; /* decompression stream */
strcpy((char*)uncompr, "garbage"); 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.avail_in = 0;
d_stream.next_out = uncompr; d_stream.next_out = uncompr;
err = inflateInit(&d_stream); err = PREFIX(inflateInit)(&d_stream);
CHECK_ERR(err, "inflateInit"); CHECK_ERR(err, "inflateInit");
while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) { while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) {
d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */ 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; if (err == Z_STREAM_END) break;
CHECK_ERR(err, "inflate"); CHECK_ERR(err, "inflate");
} }
err = inflateEnd(&d_stream); err = PREFIX(inflateEnd)(&d_stream);
CHECK_ERR(err, "inflateEnd"); CHECK_ERR(err, "inflateEnd");
if (strcmp((char*)uncompr, hello)) { 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) 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; int err;
c_stream.zalloc = zalloc; c_stream.zalloc = zalloc;
c_stream.zfree = zfree; c_stream.zfree = zfree;
c_stream.opaque = (void *)0; c_stream.opaque = (void *)0;
err = deflateInit(&c_stream, Z_BEST_SPEED); err = PREFIX(deflateInit)(&c_stream, Z_BEST_SPEED);
CHECK_ERR(err, "deflateInit"); CHECK_ERR(err, "deflateInit");
c_stream.next_out = compr; 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.next_in = uncompr;
c_stream.avail_in = (unsigned int)uncomprLen; 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"); CHECK_ERR(err, "deflate");
if (c_stream.avail_in != 0) { if (c_stream.avail_in != 0) {
fprintf(stderr, "deflate not greedy\n"); 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: */ /* 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.next_in = compr;
c_stream.avail_in = (unsigned int)comprLen/2; 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"); CHECK_ERR(err, "deflate");
/* Switch back to compressing mode: */ /* 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.next_in = uncompr;
c_stream.avail_in = (unsigned int)uncomprLen; 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"); CHECK_ERR(err, "deflate");
err = deflate(&c_stream, Z_FINISH); err = PREFIX(deflate)(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) { if (err != Z_STREAM_END) {
fprintf(stderr, "deflate should report Z_STREAM_END\n"); fprintf(stderr, "deflate should report Z_STREAM_END\n");
exit(1); exit(1);
} }
err = deflateEnd(&c_stream); err = PREFIX(deflateEnd)(&c_stream);
CHECK_ERR(err, "deflateEnd"); 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) void test_large_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen)
{ {
int err; int err;
z_stream d_stream; /* decompression stream */ PREFIX3(stream) d_stream; /* decompression stream */
strcpy((char*)uncompr, "garbage"); 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.next_in = compr;
d_stream.avail_in = (unsigned int)comprLen; d_stream.avail_in = (unsigned int)comprLen;
err = inflateInit(&d_stream); err = PREFIX(inflateInit)(&d_stream);
CHECK_ERR(err, "inflateInit"); CHECK_ERR(err, "inflateInit");
for (;;) { for (;;) {
d_stream.next_out = uncompr; /* discard the output */ d_stream.next_out = uncompr; /* discard the output */
d_stream.avail_out = (unsigned int)uncomprLen; 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; if (err == Z_STREAM_END) break;
CHECK_ERR(err, "large inflate"); CHECK_ERR(err, "large inflate");
} }
err = inflateEnd(&d_stream); err = PREFIX(inflateEnd)(&d_stream);
CHECK_ERR(err, "inflateEnd"); CHECK_ERR(err, "inflateEnd");
if (d_stream.total_out != 2*uncomprLen + comprLen/2) { 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) void test_flush(unsigned char *compr, size_t *comprLen)
{ {
z_stream c_stream; /* compression stream */ PREFIX3(stream) c_stream; /* compression stream */
int err; int err;
unsigned int len = (unsigned int)strlen(hello)+1; 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.zfree = zfree;
c_stream.opaque = (void *)0; c_stream.opaque = (void *)0;
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION);
CHECK_ERR(err, "deflateInit"); CHECK_ERR(err, "deflateInit");
c_stream.next_in = (const unsigned char *)hello; c_stream.next_in = (const unsigned char *)hello;
c_stream.next_out = compr; c_stream.next_out = compr;
c_stream.avail_in = 3; c_stream.avail_in = 3;
c_stream.avail_out = (unsigned int)*comprLen; 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"); CHECK_ERR(err, "deflate");
compr[3]++; /* force an error in first compressed block */ compr[3]++; /* force an error in first compressed block */
c_stream.avail_in = len - 3; c_stream.avail_in = len - 3;
err = deflate(&c_stream, Z_FINISH); err = PREFIX(deflate)(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) { if (err != Z_STREAM_END) {
CHECK_ERR(err, "deflate"); CHECK_ERR(err, "deflate");
} }
err = deflateEnd(&c_stream); err = PREFIX(deflateEnd)(&c_stream);
CHECK_ERR(err, "deflateEnd"); CHECK_ERR(err, "deflateEnd");
*comprLen = c_stream.total_out; *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) void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen)
{ {
int err; int err;
z_stream d_stream; /* decompression stream */ PREFIX3(stream) d_stream; /* decompression stream */
strcpy((char*)uncompr, "garbage"); 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.next_in = compr;
d_stream.avail_in = 2; /* just read the zlib header */ d_stream.avail_in = 2; /* just read the zlib header */
err = inflateInit(&d_stream); err = PREFIX(inflateInit)(&d_stream);
CHECK_ERR(err, "inflateInit"); CHECK_ERR(err, "inflateInit");
d_stream.next_out = uncompr; d_stream.next_out = uncompr;
d_stream.avail_out = (unsigned int)uncomprLen; 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"); CHECK_ERR(err, "inflate");
d_stream.avail_in = (unsigned int)comprLen-2; /* read all compressed data */ 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"); CHECK_ERR(err, "inflateSync");
err = inflate(&d_stream, Z_FINISH); err = PREFIX(inflate)(&d_stream, Z_FINISH);
if (err != Z_DATA_ERROR) { if (err != Z_DATA_ERROR) {
fprintf(stderr, "inflate should report DATA_ERROR\n"); fprintf(stderr, "inflate should report DATA_ERROR\n");
/* Because of incorrect adler32 */ /* Because of incorrect adler32 */
exit(1); exit(1);
} }
err = inflateEnd(&d_stream); err = PREFIX(inflateEnd)(&d_stream);
CHECK_ERR(err, "inflateEnd"); CHECK_ERR(err, "inflateEnd");
printf("after inflateSync(): hel%s\n", (char *)uncompr); 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) void test_dict_deflate(unsigned char *compr, size_t comprLen)
{ {
z_stream c_stream; /* compression stream */ PREFIX3(stream) c_stream; /* compression stream */
int err; int err;
c_stream.zalloc = zalloc; c_stream.zalloc = zalloc;
c_stream.zfree = zfree; c_stream.zfree = zfree;
c_stream.opaque = (void *)0; c_stream.opaque = (void *)0;
err = deflateInit(&c_stream, Z_BEST_COMPRESSION); err = PREFIX(deflateInit)(&c_stream, Z_BEST_COMPRESSION);
CHECK_ERR(err, "deflateInit"); CHECK_ERR(err, "deflateInit");
err = deflateSetDictionary(&c_stream, err = PREFIX(deflateSetDictionary)(&c_stream,
(const unsigned char*)dictionary, (int)sizeof(dictionary)); (const unsigned char*)dictionary, (int)sizeof(dictionary));
CHECK_ERR(err, "deflateSetDictionary"); 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.next_in = (const unsigned char *)hello;
c_stream.avail_in = (unsigned int)strlen(hello)+1; 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) { if (err != Z_STREAM_END) {
fprintf(stderr, "deflate should report Z_STREAM_END\n"); fprintf(stderr, "deflate should report Z_STREAM_END\n");
exit(1); exit(1);
} }
err = deflateEnd(&c_stream); err = PREFIX(deflateEnd)(&c_stream);
CHECK_ERR(err, "deflateEnd"); 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) void test_dict_inflate(unsigned char *compr, size_t comprLen, unsigned char *uncompr, size_t uncomprLen)
{ {
int err; int err;
z_stream d_stream; /* decompression stream */ PREFIX3(stream) d_stream; /* decompression stream */
strcpy((char*)uncompr, "garbage"); 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.next_in = compr;
d_stream.avail_in = (unsigned int)comprLen; d_stream.avail_in = (unsigned int)comprLen;
err = inflateInit(&d_stream); err = PREFIX(inflateInit)(&d_stream);
CHECK_ERR(err, "inflateInit"); CHECK_ERR(err, "inflateInit");
d_stream.next_out = uncompr; d_stream.next_out = uncompr;
d_stream.avail_out = (unsigned int)uncomprLen; d_stream.avail_out = (unsigned int)uncomprLen;
for (;;) { 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_STREAM_END) break;
if (err == Z_NEED_DICT) { if (err == Z_NEED_DICT) {
if (d_stream.adler != dictId) { if (d_stream.adler != dictId) {
fprintf(stderr, "unexpected dictionary"); fprintf(stderr, "unexpected dictionary");
exit(1); exit(1);
} }
err = inflateSetDictionary(&d_stream, (const unsigned char*)dictionary, err = PREFIX(inflateSetDictionary)(&d_stream, (const unsigned char*)dictionary,
(int)sizeof(dictionary)); (int)sizeof(dictionary));
} }
CHECK_ERR(err, "inflate with dict"); CHECK_ERR(err, "inflate with dict");
} }
err = inflateEnd(&d_stream); err = PREFIX(inflateEnd)(&d_stream);
CHECK_ERR(err, "inflateEnd"); CHECK_ERR(err, "inflateEnd");
if (strcmp((char*)uncompr, hello)) { if (strcmp((char*)uncompr, hello)) {
@ -494,18 +499,18 @@ int main(int argc, char *argv[])
unsigned char *compr, *uncompr; unsigned char *compr, *uncompr;
size_t comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ size_t comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
size_t uncomprLen = comprLen; 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"); fprintf(stderr, "incompatible zlib version\n");
exit(1); exit(1);
} else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { } else if (strcmp(zVersion(), PREFIX2(VERSION)) != 0) {
fprintf(stderr, "warning: different zlib version\n"); fprintf(stderr, "warning: different zlib version\n");
} }
printf("zlib version %s = 0x%04x, compile flags = 0x%lx\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); compr = (unsigned char*)calloc((unsigned int)comprLen, 1);
uncompr = (unsigned char*)calloc((unsigned int)uncomprLen, 1); uncompr = (unsigned char*)calloc((unsigned int)uncomprLen, 1);

View File

@ -14,7 +14,11 @@
/* @(#) $Id$ */ /* @(#) $Id$ */
#include "zlib.h" #ifdef ZLIB_COMPAT
# include "zlib.h"
#else
# include "zlib-ng.h"
#endif
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -80,20 +84,20 @@ typedef struct gzFile_s {
int write; int write;
int err; int err;
const char *msg; const char *msg;
z_stream strm; PREFIX3(stream) strm;
unsigned char *buf; unsigned char *buf;
} *gzFile; } *gzFile;
gzFile gzopen (const char *, const char *); gzFile PREFIX(gzopen)(const char *, const char *);
gzFile gzdopen (int, const char *); gzFile PREFIX(gzdopen)(int, const char *);
gzFile gz_open (const char *, 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); 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); return gz_open(NULL, fd, mode);
} }
@ -127,11 +131,11 @@ gzFile gz_open(const char *path, int fd, const char *mode)
plevel++; plevel++;
} }
if (gz->write) 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 { else {
gz->strm.next_in = NULL; gz->strm.next_in = NULL;
gz->strm.avail_in = 0; gz->strm.avail_in = 0;
ret = inflateInit2(&(gz->strm), 15 + 16); ret = PREFIX(inflateInit2)(&(gz->strm), 15 + 16);
} }
if (ret != Z_OK) { if (ret != Z_OK) {
free(gz); 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") : gz->file = path == NULL ? fdopen(fd, gz->write ? "wb" : "rb") :
fopen(path, gz->write ? "wb" : "rb"); fopen(path, gz->write ? "wb" : "rb");
if (gz->file == NULL) { if (gz->file == NULL) {
gz->write ? deflateEnd(&(gz->strm)) : inflateEnd(&(gz->strm)); gz->write ? PREFIX(deflateEnd)(&(gz->strm)) : PREFIX(inflateEnd)(&(gz->strm));
free(gz); free(gz);
return NULL; return NULL;
} }
@ -149,11 +153,11 @@ gzFile gz_open(const char *path, int fd, const char *mode)
return gz; 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) if (gz == NULL || !gz->write)
return 0; return 0;
@ -163,17 +167,17 @@ int gzwrite(gzFile gz, const void *buf, unsigned len)
do { do {
strm->next_out = gz->buf; strm->next_out = gz->buf;
strm->avail_out = BUFLENW; 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); fwrite(gz->buf, 1, BUFLENW - strm->avail_out, gz->file);
} while (strm->avail_out == 0); } while (strm->avail_out == 0);
return len; 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) if (gz == NULL || gz->write || gz->err)
return 0; return 0;
@ -188,14 +192,14 @@ int gzread(gzFile gz, void *buf, unsigned len)
} }
if (strm->avail_in > 0) 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) { if (ret == Z_DATA_ERROR) {
gz->err = ret; gz->err = ret;
gz->msg = strm->msg; gz->msg = strm->msg;
return 0; return 0;
} }
else if (ret == Z_STREAM_END) else if (ret == Z_STREAM_END)
inflateReset(strm); PREFIX(inflateReset)(strm);
} }
else else
break; break;
@ -203,11 +207,11 @@ int gzread(gzFile gz, void *buf, unsigned len)
return len - strm->avail_out; 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) if (gz == NULL)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
@ -218,22 +222,22 @@ int gzclose(gzFile gz)
do { do {
strm->next_out = gz->buf; strm->next_out = gz->buf;
strm->avail_out = BUFLENW; 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); fwrite(gz->buf, 1, BUFLENW - strm->avail_out, gz->file);
} while (strm->avail_out == 0); } while (strm->avail_out == 0);
deflateEnd(strm); PREFIX(deflateEnd)(strm);
} }
else else
inflateEnd(strm); PREFIX(inflateEnd)(strm);
free(gz->buf); free(gz->buf);
fclose(gz->file); fclose(gz->file);
free(gz); free(gz);
return Z_OK; 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; *err = gz->err;
return gz->msg; return gz->msg;
@ -286,10 +290,10 @@ void gz_compress(FILE *in, gzFile out)
} }
if (len == 0) break; 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); 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 <malbrech@eso.org> */ #ifdef USE_MMAP /* MMAP version, Miguel Albrecht <malbrech@eso.org> */
@ -316,13 +320,13 @@ int gz_compress_mmap(FILE *in, gzFile out)
if (buf == (caddr_t)(-1)) return Z_ERRNO; if (buf == (caddr_t)(-1)) return Z_ERRNO;
/* Compress the whole file at once: */ /* 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); munmap(buf, buf_len);
fclose(in); fclose(in);
if (gzclose(out) != Z_OK) error("failed gzclose"); if (PREFIX(gzclose)(out) != Z_OK) error("failed gzclose");
return Z_OK; return Z_OK;
} }
#endif /* USE_MMAP */ #endif /* USE_MMAP */
@ -337,8 +341,8 @@ void gz_uncompress(gzFile in, FILE *out)
int err; int err;
for (;;) { for (;;) {
len = gzread(in, buf, sizeof(buf)); len = PREFIX(gzread)(in, buf, sizeof(buf));
if (len < 0) error (gzerror(in, &err)); if (len < 0) error (PREFIX(gzerror)(in, &err));
if (len == 0) break; if (len == 0) break;
if ((int)fwrite(buf, 1, (unsigned)len, out) != len) { 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 (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); perror(file);
exit(1); exit(1);
} }
out = gzopen(outfile, mode); out = PREFIX(gzopen)(outfile, mode);
if (out == NULL) { if (out == NULL) {
fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile);
exit(1); exit(1);
@ -411,7 +415,7 @@ void file_uncompress(char *file)
infile = buf; infile = buf;
snprintf(buf + len, sizeof(buf) - len, "%s", GZ_SUFFIX); snprintf(buf + len, sizeof(buf) - len, "%s", GZ_SUFFIX);
} }
in = gzopen(infile, "rb"); in = PREFIX(gzopen)(infile, "rb");
if (in == NULL) { if (in == NULL) {
fprintf(stderr, "%s: can't gzopen %s\n", prog, infile); fprintf(stderr, "%s: can't gzopen %s\n", prog, infile);
exit(1); exit(1);
@ -484,11 +488,11 @@ int main(int argc, char *argv[])
SET_BINARY_MODE(stdin); SET_BINARY_MODE(stdin);
SET_BINARY_MODE(stdout); SET_BINARY_MODE(stdout);
if (uncompr) { if (uncompr) {
file = gzdopen(fileno(stdin), "rb"); file = PREFIX(gzdopen)(fileno(stdin), "rb");
if (file == NULL) error("can't gzdopen stdin"); if (file == NULL) error("can't gzdopen stdin");
gz_uncompress(file, stdout); gz_uncompress(file, stdout);
} else { } else {
file = gzdopen(fileno(stdout), outmode); file = PREFIX(gzdopen)(fileno(stdout), outmode);
if (file == NULL) error("can't gzdopen stdout"); if (file == NULL) error("can't gzdopen stdout");
gz_compress(stdin, file); gz_compress(stdin, file);
} }
@ -499,7 +503,7 @@ int main(int argc, char *argv[])
do { do {
if (uncompr) { if (uncompr) {
if (copyout) { if (copyout) {
file = gzopen(*argv, "rb"); file = PREFIX(gzopen)(*argv, "rb");
if (file == NULL) if (file == NULL)
fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv); fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv);
else else
@ -514,7 +518,7 @@ int main(int argc, char *argv[])
if (in == NULL) { if (in == NULL) {
perror(*argv); perror(*argv);
} else { } else {
file = gzdopen(fileno(stdout), outmode); file = PREFIX(gzdopen)(fileno(stdout), outmode);
if (file == NULL) error("can't gzdopen stdout"); if (file == NULL) error("can't gzdopen stdout");
gz_compress(in, file); gz_compress(in, file);

View File

@ -6,7 +6,11 @@
/* @(#) $Id$ */ /* @(#) $Id$ */
#define ZLIB_INTERNAL #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 Decompresses the source buffer into the destination buffer. *sourceLen is
@ -25,7 +29,7 @@
an incomplete zlib stream. an incomplete zlib stream.
*/ */
int ZEXPORT PREFIX(uncompress2)(unsigned char *dest, size_t *destLen, const unsigned char *source, size_t *sourceLen) { 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; int err;
const unsigned int max = (unsigned int)-1; const unsigned int max = (unsigned int)-1;
size_t len, left; size_t len, left;
@ -47,7 +51,7 @@ int ZEXPORT PREFIX(uncompress2)(unsigned char *dest, size_t *destLen, const unsi
stream.zfree = NULL; stream.zfree = NULL;
stream.opaque = NULL; stream.opaque = NULL;
err = inflateInit(&stream); err = PREFIX(inflateInit)(&stream);
if (err != Z_OK) return err; if (err != Z_OK) return err;
stream.next_out = dest; 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; stream.avail_in = len > (unsigned long)max ? max : (unsigned int)len;
len -= stream.avail_in; len -= stream.avail_in;
} }
err = inflate(&stream, Z_NO_FLUSH); err = PREFIX(inflate)(&stream, Z_NO_FLUSH);
} while (err == Z_OK); } while (err == Z_OK);
*sourceLen -= len + stream.avail_in; *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) else if (stream.total_out && err == Z_BUF_ERROR)
left = 1; left = 1;
inflateEnd(&stream); PREFIX(inflateEnd)(&stream);
return err == Z_STREAM_END ? Z_OK : return err == Z_STREAM_END ? Z_OK :
err == Z_NEED_DICT ? Z_DATA_ERROR : err == Z_NEED_DICT ? Z_DATA_ERROR :
err == Z_BUF_ERROR && left + stream.avail_out ? 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) 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);
} }

View File

@ -28,18 +28,29 @@ LDFLAGS = -nologo -debug -incremental:no -opt:ref -manifest
ARFLAGS = -nologo ARFLAGS = -nologo
RCFLAGS = /dARM /r RCFLAGS = /dARM /r
DEFFILE = zlib.def DEFFILE = zlib.def
RCFILE = zlib1.rc
RESFILE = zlib1.res
WITH_GZFILEOP = WITH_GZFILEOP =
WITH_ACLE = WITH_ACLE =
WITH_NEON = WITH_NEON =
WITH_VFPV3 = WITH_VFPV3 =
NEON_ARCH = /arch:VFPv4 NEON_ARCH = /arch:VFPv4
SUFFIX =
OBJS = adler32.obj compress.obj crc32.obj deflate.obj deflate_fast.obj deflate_slow.obj \ 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)" != "" !if "$(WITH_GZFILEOP)" != ""
WFLAGS = $(WFLAGS) -DWITH_GZFILEOP WFLAGS = $(WFLAGS) -DWITH_GZFILEOP
OBJS = $(OBJS) gzclose.obj gzlib.obj gzread.obj gzwrite.obj OBJS = $(OBJS) gzclose.obj gzlib.obj gzread.obj gzwrite.obj
DEFFILE = zlibcompat.def 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 !endif
!if "$(WITH_ACLE)" != "" !if "$(WITH_ACLE)" != ""
WFLAGS = $(WFLAGS) -DARM_ACLE_CRC_HASH WFLAGS = $(WFLAGS) -DARM_ACLE_CRC_HASH
@ -58,17 +69,17 @@ OBJS = $(OBJS) adler32_neon.obj
all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \ all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \
example.exe minigzip.exe example_d.exe minigzip_d.exe example.exe minigzip.exe example_d.exe minigzip_d.exe
zconf: $(TOP)/zconf.h.in zconf: $(TOP)/zconf$(SUFFIX).h.in
$(CP) $(TOP)\zconf.h.in $(TOP)\zconf.h $(CP) $(TOP)\zconf$(SUFFIX).h.in $(TOP)\zconf$(SUFFIX).h
$(STATICLIB): zconf $(OBJS) $(STATICLIB): zconf $(OBJS)
$(AR) $(ARFLAGS) -out:$@ $(OBJS) $(AR) $(ARFLAGS) -out:$@ $(OBJS)
$(IMPLIB): $(SHAREDLIB) $(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) \ $(LD) $(LDFLAGS) -def:$(TOP)/win32/$(DEFFILE) -dll -implib:$(IMPLIB) \
-out:$@ -base:0x5A4C0000 $(OBJS) zlib1.res -out:$@ -base:0x5A4C0000 $(OBJS) $(RESFILE)
if exist $@.manifest \ if exist $@.manifest \
mt -nologo -manifest $@.manifest -outputresource:$@;2 mt -nologo -manifest $@.manifest -outputresource:$@;2
@ -101,49 +112,49 @@ minigzip_d.exe: minigzip.obj $(IMPLIB)
{$(TOP)/test}.c.obj: {$(TOP)/test}.c.obj:
$(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $< $(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 $(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 $(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 $(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 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 $(RESFILE): $(TOP)/win32/$(RCFILE)
$(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/zlib1.rc $(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/$(RCFILE)
# testing # testing
test: example.exe minigzip.exe test: example.exe minigzip.exe
@ -166,7 +177,6 @@ clean:
-del *.exe -del *.exe
-del *.pdb -del *.pdb
-del *.manifest -del *.manifest
-del foo.gz
distclean: clean distclean: clean
-del zconf.h -del zconf$(SUFFIX).h

View File

@ -28,7 +28,10 @@ LDFLAGS = -nologo -debug -incremental:no -opt:ref -manifest
ARFLAGS = -nologo ARFLAGS = -nologo
RCFLAGS = /dWIN32 /r RCFLAGS = /dWIN32 /r
DEFFILE = zlib.def DEFFILE = zlib.def
RCFILE = zlib1.rc
RESFILE = zlib1.res
WITH_GZFILEOP = WITH_GZFILEOP =
SUFFIX =
OBJS = adler32.obj compress.obj crc32.obj deflate.obj deflate_fast.obj deflate_quick.obj deflate_slow.obj \ 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 \ 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 WFLAGS = $(WFLAGS) -DWITH_GZFILEOP
OBJS = $(OBJS) gzclose.obj gzlib.obj gzread.obj gzwrite.obj OBJS = $(OBJS) gzclose.obj gzlib.obj gzread.obj gzwrite.obj
DEFFILE = zlibcompat.def 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 !endif
# targets # targets
all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \ all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \
example.exe minigzip.exe example_d.exe minigzip_d.exe 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) $(AR) $(ARFLAGS) -out:$@ $(OBJS)
$(IMPLIB): $(SHAREDLIB) $(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) \ $(LD) $(LDFLAGS) -def:$(TOP)/win32/$(DEFFILE) -dll -implib:$(IMPLIB) \
-out:$@ -base:0x5A4C0000 $(OBJS) zlib1.res -out:$@ -base:0x5A4C0000 $(OBJS) $(RESFILE)
if exist $@.manifest \ if exist $@.manifest \
mt -nologo -manifest $@.manifest -outputresource:$@;2 mt -nologo -manifest $@.manifest -outputresource:$@;2
@ -83,50 +97,49 @@ minigzip_d.exe: minigzip.obj $(IMPLIB)
{$(TOP)/test}.c.obj: {$(TOP)/test}.c.obj:
$(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $< $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $<
$(TOP)/zconf.h: $(TOP)/zconf.h.in $(TOP)/zconf$(SUFFIX).h: zconf
$(CP) $(TOP)\zconf.h.in $(TOP)\zconf.h
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 $(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 $(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 $(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 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 $(RESFILE): $(TOP)/win32/$(RCFILE)
$(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/zlib1.rc $(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/$(RCFILE)
# testing # testing
test: example.exe minigzip.exe test: example.exe minigzip.exe
@ -149,7 +162,6 @@ clean:
-del *.exe -del *.exe
-del *.pdb -del *.pdb
-del *.manifest -del *.manifest
-del foo.gz
distclean: clean distclean: clean
-del zconf.h -del zconf$(SUFFIX).h

61
win32/zlib-ng.def Normal file
View File

@ -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

40
win32/zlib-ng1.rc Normal file
View File

@ -0,0 +1,40 @@
#include <winver.h>
#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

View File

@ -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 * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* @(#) $Id$ */ /* @(#) $Id$ */
#ifndef ZCONF_H #ifndef ZCONFNG_H
#define ZCONF_H #define ZCONFNG_H
#define PREFIX(x) zng_ ## x #define PREFIX(x) zng_ ## x
#define PREFIX2(x) ZLIBNG_ ## x
#define PREFIX3(x) zng_ ## x
#define zVersion zlibng_version
#if defined(_WINDOWS) && !defined(WINDOWS) #if defined(_WINDOWS) && !defined(WINDOWS)
# define WINDOWS # define WINDOWS
@ -173,4 +176,4 @@ typedef void *voidp;
# endif # endif
#endif #endif
#endif /* ZCONF_H */ #endif /* ZCONFNG_H */

View File

@ -8,7 +8,10 @@
#ifndef ZCONF_H #ifndef ZCONF_H
#define 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) #if defined(_WINDOWS) && !defined(WINDOWS)
# define WINDOWS # define WINDOWS

View File

@ -1,6 +1,6 @@
#ifndef ZNGLIB_H_ #ifndef ZNGLIB_H_
#define 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 Forked from and compatible with zlib 1.2.11
Copyright (C) 1995-2016 Jean-loup Gailly and Mark Adler 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 */ unsigned long reserved; /* reserved for future use */
} zng_stream; } 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 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 */ /* basic functions */
ZEXTERN const char * ZEXPORT zng_version(void); ZEXTERN const char * ZEXPORT zlibng_version(void);
/* The application can compare zlibVersion and ZLIB_VERSION for consistency. /* The application can compare zlibng_version and ZLIBNG_VERSION for consistency.
If the first character differs, the library code actually used is not 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. 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 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 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 Z_VERSION_ERROR if the zlib library version (zng_version) is incompatible
with the version assumed by the caller (ZLIB_VERSION). msg is set to null 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: if there is no error message. deflateInit does not perform any compression:
this will be done by deflate(). 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 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 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 method), or Z_VERSION_ERROR if the zlib library version (zng_version) is
incompatible with the version assumed by the caller (ZLIB_VERSION). msg 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 set to null if there is no error message. deflateInit2 does not perform any
compression: this will be done by deflate(). 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_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, ZEXTERN int ZEXPORT zng_inflateBackInit_(zng_stream *strm, int windowBits, unsigned char *window,
const char *version, int stream_size); const char *version, int stream_size);
#define zng_deflateInit(strm, level) zng_deflateInit_((strm), (level), 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), ZLIB_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) \ #define zng_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
zng_deflateInit2_((strm), (level), (method), (windowBits), (memLevel), \ zng_deflateInit2_((strm), (level), (method), (windowBits), (memLevel), \
(strategy), ZLIB_VERSION, (int)sizeof(zng_stream)) (strategy), ZLIBNG_VERSION, (int)sizeof(zng_stream))
#define zng_inflateInit2(strm, windowBits) inflateInit2_((strm), (windowBits), ZLIB_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) \ #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 #ifdef WITH_GZFILEOP

View File

@ -26,10 +26,12 @@ const char * const z_errmsg[10] = {
const char zlibng_string[] = const char zlibng_string[] =
" zlib-ng 1.9.9 forked from zlib 1.2.11 "; " zlib-ng 1.9.9 forked from zlib 1.2.11 ";
#ifdef ZLIB_COMPAT
const char * ZEXPORT zlibVersion(void) const char * ZEXPORT zlibVersion(void)
{ {
return ZLIB_VERSION; return ZLIB_VERSION;
} }
#endif
const char * ZEXPORT zlibng_version(void) const char * ZEXPORT zlibng_version(void)
{ {

View File

@ -24,7 +24,11 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#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 unsigned char uch; /* Included for compatibility with external code only */
typedef uint16_t ush; /* Included for compatibility with external code only */ typedef uint16_t ush; /* Included for compatibility with external code only */