mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-22 03:51:11 +00:00
- Update zlib to version 1.2.5.
SVN r3172 (trunk)
This commit is contained in:
parent
ddac7de3fe
commit
b477ed8490
33 changed files with 2614 additions and 1938 deletions
|
@ -1,20 +1,192 @@
|
||||||
cmake_minimum_required( VERSION 2.4 )
|
cmake_minimum_required(VERSION 2.4.4)
|
||||||
|
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
|
||||||
|
|
||||||
if( CMAKE_COMPILER_IS_GNUC )
|
project(zlib C)
|
||||||
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -fomit-frame-pointer" )
|
|
||||||
endif( CMAKE_COMPILER_IS_GNUC )
|
|
||||||
|
|
||||||
add_library( z
|
if(NOT DEFINED BUILD_SHARED_LIBS)
|
||||||
|
option(BUILD_SHARED_LIBS "Build a shared library form of zlib" OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(ZLIBNAME z)
|
||||||
|
|
||||||
|
include(CheckTypeSize)
|
||||||
|
include(CheckFunctionExists)
|
||||||
|
include(CheckIncludeFile)
|
||||||
|
include(CheckCSourceCompiles)
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
|
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
|
||||||
|
check_include_file(stdint.h HAVE_STDINT_H)
|
||||||
|
check_include_file(stddef.h HAVE_STDDEF_H)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check to see if we have large file support
|
||||||
|
#
|
||||||
|
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
|
||||||
|
# We add these other definitions here because CheckTypeSize.cmake
|
||||||
|
# in CMake 2.4.x does not automatically do so and we want
|
||||||
|
# compatibility with CMake 2.4.x.
|
||||||
|
if(HAVE_SYS_TYPES_H)
|
||||||
|
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
|
||||||
|
endif()
|
||||||
|
if(HAVE_STDINT_H)
|
||||||
|
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
|
||||||
|
endif()
|
||||||
|
if(HAVE_STDDEF_H)
|
||||||
|
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
|
||||||
|
endif()
|
||||||
|
check_type_size(off64_t OFF64_T)
|
||||||
|
if(HAVE_OFF64_T)
|
||||||
|
add_definitions(-D_LARGEFILE64_SOURCE=1)
|
||||||
|
endif()
|
||||||
|
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for fseeko
|
||||||
|
#
|
||||||
|
check_function_exists(fseeko HAVE_FSEEKO)
|
||||||
|
if(NOT HAVE_FSEEKO)
|
||||||
|
add_definitions(-DNO_FSEEKO)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Check for unistd.h
|
||||||
|
#
|
||||||
|
check_include_file(unistd.h Z_HAVE_UNISTD_H)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
set(CMAKE_DEBUG_POSTFIX "d")
|
||||||
|
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||||
|
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||||
|
# # If we're doing an out of source build and the user has a zconf.h
|
||||||
|
# # in their source tree...
|
||||||
|
# if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
|
||||||
|
# message(FATAL_ERROR
|
||||||
|
# "You must remove ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h "
|
||||||
|
# "from the source tree. This file is included with zlib "
|
||||||
|
# "but CMake generates this file for you automatically "
|
||||||
|
# "in the build directory.")
|
||||||
|
# endif()
|
||||||
|
#endif()
|
||||||
|
#
|
||||||
|
#configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
|
||||||
|
# ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
|
||||||
|
#include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
|
||||||
|
#============================================================================
|
||||||
|
# zlib
|
||||||
|
#============================================================================
|
||||||
|
|
||||||
|
set(ZLIB_PUBLIC_HDRS
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/zconf.h
|
||||||
|
zlib.h
|
||||||
|
)
|
||||||
|
set(ZLIB_PRIVATE_HDRS
|
||||||
|
crc32.h
|
||||||
|
deflate.h
|
||||||
|
# gzguts.h
|
||||||
|
inffast.h
|
||||||
|
inffixed.h
|
||||||
|
inflate.h
|
||||||
|
inftrees.h
|
||||||
|
trees.h
|
||||||
|
zutil.h
|
||||||
|
)
|
||||||
|
set(ZLIB_SRCS
|
||||||
adler32.c
|
adler32.c
|
||||||
compress.c
|
compress.c
|
||||||
crc32.c
|
crc32.c
|
||||||
gzio.c
|
|
||||||
uncompr.c
|
|
||||||
deflate.c
|
deflate.c
|
||||||
trees.c
|
# gzclose.c
|
||||||
zutil.c
|
# gzlib.c
|
||||||
|
# gzread.c
|
||||||
|
# gzwrite.c
|
||||||
inflate.c
|
inflate.c
|
||||||
infback.c
|
infback.c
|
||||||
inftrees.c
|
inftrees.c
|
||||||
inffast.c )
|
inffast.c
|
||||||
target_link_libraries( z )
|
trees.c
|
||||||
|
uncompr.c
|
||||||
|
zutil.c
|
||||||
|
win32/zlib1.rc
|
||||||
|
)
|
||||||
|
|
||||||
|
# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
|
||||||
|
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
|
||||||
|
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([0-9A-Za-z.]+)\".*"
|
||||||
|
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
|
||||||
|
|
||||||
|
if(MINGW)
|
||||||
|
# This gets us DLL resource information when compiling on MinGW.
|
||||||
|
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
|
||||||
|
COMMAND windres.exe
|
||||||
|
-D GCC_WINDRES
|
||||||
|
-I ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
-I ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
|
||||||
|
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
|
||||||
|
set(ZLIB_SRCS ${ZLIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
|
||||||
|
endif(MINGW)
|
||||||
|
|
||||||
|
add_library(${ZLIBNAME} ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||||
|
set_target_properties(${ZLIBNAME} PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
|
||||||
|
|
||||||
|
set_target_properties(${ZLIBNAME} PROPERTIES SOVERSION 1)
|
||||||
|
|
||||||
|
if(NOT CYGWIN)
|
||||||
|
# This property causes shared libraries on Linux to have the full version
|
||||||
|
# encoded into their final filename. We disable this on Cygwin because
|
||||||
|
# it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
|
||||||
|
# seems to be the default.
|
||||||
|
#
|
||||||
|
# This has no effect with MSVC, on that platform the version info for
|
||||||
|
# the DLL comes from the resource file win32/zlib1.rc
|
||||||
|
set_target_properties(${ZLIBNAME} PROPERTIES VERSION ${ZLIB_FULL_VERSION})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_SHARED_LIBS AND WIN32)
|
||||||
|
# Creates zlib1.dll when building shared library version
|
||||||
|
set_target_properties(${ZLIBNAME} PROPERTIES SUFFIX "1.dll")
|
||||||
|
else()
|
||||||
|
# On unix-like platforms the library is almost always called libz
|
||||||
|
set_target_properties(${ZLIBNAME} PROPERTIES OUTPUT_NAME z)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||||
|
install(TARGETS ${ZLIBNAME}
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
LIBRARY DESTINATION lib )
|
||||||
|
endif()
|
||||||
|
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
|
||||||
|
install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION include)
|
||||||
|
endif()
|
||||||
|
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
|
||||||
|
install(FILES zlib.3 DESTINATION share/man/man3)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#============================================================================
|
||||||
|
# Example binaries
|
||||||
|
#============================================================================
|
||||||
|
|
||||||
|
#add_executable(example example.c)
|
||||||
|
#target_link_libraries(example ${ZLIBNAME})
|
||||||
|
#add_test(example example)
|
||||||
|
|
||||||
|
#add_executable(minigzip minigzip.c)
|
||||||
|
#target_link_libraries(minigzip ${ZLIBNAME})
|
||||||
|
|
||||||
|
#if(HAVE_OFF64_T)
|
||||||
|
# add_executable(example64 example.c)
|
||||||
|
# target_link_libraries(example64 ${ZLIBNAME})
|
||||||
|
# set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
|
||||||
|
# add_test(example64 example64)
|
||||||
|
#
|
||||||
|
# add_executable(minigzip64 minigzip.c)
|
||||||
|
# target_link_libraries(minigzip64 ${ZLIBNAME})
|
||||||
|
# set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
|
||||||
|
#endif()
|
||||||
|
|
355
zlib/ChangeLog
355
zlib/ChangeLog
|
@ -1,6 +1,359 @@
|
||||||
|
|
||||||
ChangeLog file for zlib
|
ChangeLog file for zlib
|
||||||
|
|
||||||
|
Changes in 1.2.5 (19 Apr 2010)
|
||||||
|
- Disable visibility attribute in win32/Makefile.gcc [Bar-Lev]
|
||||||
|
- Default to libdir as sharedlibdir in configure [Nieder]
|
||||||
|
- Update copyright dates on modified source files
|
||||||
|
- Update trees.c to be able to generate modified trees.h
|
||||||
|
- Exit configure for MinGW, suggesting win32/Makefile.gcc
|
||||||
|
|
||||||
|
Changes in 1.2.4.5 (18 Apr 2010)
|
||||||
|
- Set sharedlibdir in configure [Torok]
|
||||||
|
- Set LDFLAGS in Makefile.in [Bar-Lev]
|
||||||
|
- Avoid mkdir objs race condition in Makefile.in [Bowler]
|
||||||
|
- Add ZLIB_INTERNAL in front of internal inter-module functions and arrays
|
||||||
|
- Define ZLIB_INTERNAL to hide internal functions and arrays for GNU C
|
||||||
|
- Don't use hidden attribute when it is a warning generator (e.g. Solaris)
|
||||||
|
|
||||||
|
Changes in 1.2.4.4 (18 Apr 2010)
|
||||||
|
- Fix CROSS_PREFIX executable testing, CHOST extract, mingw* [Torok]
|
||||||
|
- Undefine _LARGEFILE64_SOURCE in zconf.h if it is zero, but not if empty
|
||||||
|
- Try to use bash or ksh regardless of functionality of /bin/sh
|
||||||
|
- Fix configure incompatibility with NetBSD sh
|
||||||
|
- Remove attempt to run under bash or ksh since have better NetBSD fix
|
||||||
|
- Fix win32/Makefile.gcc for MinGW [Bar-Lev]
|
||||||
|
- Add diagnostic messages when using CROSS_PREFIX in configure
|
||||||
|
- Added --sharedlibdir option to configure [Weigelt]
|
||||||
|
- Use hidden visibility attribute when available [Frysinger]
|
||||||
|
|
||||||
|
Changes in 1.2.4.3 (10 Apr 2010)
|
||||||
|
- Only use CROSS_PREFIX in configure for ar and ranlib if they exist
|
||||||
|
- Use CROSS_PREFIX for nm [Bar-Lev]
|
||||||
|
- Assume _LARGEFILE64_SOURCE defined is equivalent to true
|
||||||
|
- Avoid use of undefined symbols in #if with && and ||
|
||||||
|
- Make *64 prototypes in gzguts.h consistent with functions
|
||||||
|
- Add -shared load option for MinGW in configure [Bowler]
|
||||||
|
- Move z_off64_t to public interface, use instead of off64_t
|
||||||
|
- Remove ! from shell test in configure (not portable to Solaris)
|
||||||
|
- Change +0 macro tests to -0 for possibly increased portability
|
||||||
|
|
||||||
|
Changes in 1.2.4.2 (9 Apr 2010)
|
||||||
|
- Add consistent carriage returns to readme.txt's in masmx86 and masmx64
|
||||||
|
- Really provide prototypes for *64 functions when building without LFS
|
||||||
|
- Only define unlink() in minigzip.c if unistd.h not included
|
||||||
|
- Update README to point to contrib/vstudio project files
|
||||||
|
- Move projects/vc6 to old/ and remove projects/
|
||||||
|
- Include stdlib.h in minigzip.c for setmode() definition under WinCE
|
||||||
|
- Clean up assembler builds in win32/Makefile.msc [Rowe]
|
||||||
|
- Include sys/types.h for Microsoft for off_t definition
|
||||||
|
- Fix memory leak on error in gz_open()
|
||||||
|
- Symbolize nm as $NM in configure [Weigelt]
|
||||||
|
- Use TEST_LDSHARED instead of LDSHARED to link test programs [Weigelt]
|
||||||
|
- Add +0 to _FILE_OFFSET_BITS and _LFS64_LARGEFILE in case not defined
|
||||||
|
- Fix bug in gzeof() to take into account unused input data
|
||||||
|
- Avoid initialization of structures with variables in puff.c
|
||||||
|
- Updated win32/README-WIN32.txt [Rowe]
|
||||||
|
|
||||||
|
Changes in 1.2.4.1 (28 Mar 2010)
|
||||||
|
- Remove the use of [a-z] constructs for sed in configure [gentoo 310225]
|
||||||
|
- Remove $(SHAREDLIB) from LIBS in Makefile.in [Creech]
|
||||||
|
- Restore "for debugging" comment on sprintf() in gzlib.c
|
||||||
|
- Remove fdopen for MVS from gzguts.h
|
||||||
|
- Put new README-WIN32.txt in win32 [Rowe]
|
||||||
|
- Add check for shell to configure and invoke another shell if needed
|
||||||
|
- Fix big fat stinking bug in gzseek() on uncompressed files
|
||||||
|
- Remove vestigial F_OPEN64 define in zutil.h
|
||||||
|
- Set and check the value of _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE
|
||||||
|
- Avoid errors on non-LFS systems when applications define LFS macros
|
||||||
|
- Set EXE to ".exe" in configure for MINGW [Kahle]
|
||||||
|
- Match crc32() in crc32.c exactly to the prototype in zlib.h [Sherrill]
|
||||||
|
- Add prefix for cross-compilation in win32/makefile.gcc [Bar-Lev]
|
||||||
|
- Add DLL install in win32/makefile.gcc [Bar-Lev]
|
||||||
|
- Allow Linux* or linux* from uname in configure [Bar-Lev]
|
||||||
|
- Allow ldconfig to be redefined in configure and Makefile.in [Bar-Lev]
|
||||||
|
- Add cross-compilation prefixes to configure [Bar-Lev]
|
||||||
|
- Match type exactly in gz_load() invocation in gzread.c
|
||||||
|
- Match type exactly of zcalloc() in zutil.c to zlib.h alloc_func
|
||||||
|
- Provide prototypes for *64 functions when building zlib without LFS
|
||||||
|
- Don't use -lc when linking shared library on MinGW
|
||||||
|
- Remove errno.h check in configure and vestigial errno code in zutil.h
|
||||||
|
|
||||||
|
Changes in 1.2.4 (14 Mar 2010)
|
||||||
|
- Fix VER3 extraction in configure for no fourth subversion
|
||||||
|
- Update zlib.3, add docs to Makefile.in to make .pdf out of it
|
||||||
|
- Add zlib.3.pdf to distribution
|
||||||
|
- Don't set error code in gzerror() if passed pointer is NULL
|
||||||
|
- Apply destination directory fixes to CMakeLists.txt [Lowman]
|
||||||
|
- Move #cmakedefine's to a new zconf.in.cmakein
|
||||||
|
- Restore zconf.h for builds that don't use configure or cmake
|
||||||
|
- Add distclean to dummy Makefile for convenience
|
||||||
|
- Update and improve INDEX, README, and FAQ
|
||||||
|
- Update CMakeLists.txt for the return of zconf.h [Lowman]
|
||||||
|
- Update contrib/vstudio/vc9 and vc10 [Vollant]
|
||||||
|
- Change libz.dll.a back to libzdll.a in win32/Makefile.gcc
|
||||||
|
- Apply license and readme changes to contrib/asm686 [Raiter]
|
||||||
|
- Check file name lengths and add -c option in minigzip.c [Li]
|
||||||
|
- Update contrib/amd64 and contrib/masmx86/ [Vollant]
|
||||||
|
- Avoid use of "eof" parameter in trees.c to not shadow library variable
|
||||||
|
- Update make_vms.com for removal of zlibdefs.h [Zinser]
|
||||||
|
- Update assembler code and vstudio projects in contrib [Vollant]
|
||||||
|
- Remove outdated assembler code contrib/masm686 and contrib/asm586
|
||||||
|
- Remove old vc7 and vc8 from contrib/vstudio
|
||||||
|
- Update win32/Makefile.msc, add ZLIB_VER_SUBREVISION [Rowe]
|
||||||
|
- Fix memory leaks in gzclose_r() and gzclose_w(), file leak in gz_open()
|
||||||
|
- Add contrib/gcc_gvmat64 for longest_match and inflate_fast [Vollant]
|
||||||
|
- Remove *64 functions from win32/zlib.def (they're not 64-bit yet)
|
||||||
|
- Fix bug in void-returning vsprintf() case in gzwrite.c
|
||||||
|
- Fix name change from inflate.h in contrib/inflate86/inffas86.c
|
||||||
|
- Check if temporary file exists before removing in make_vms.com [Zinser]
|
||||||
|
- Fix make install and uninstall for --static option
|
||||||
|
- Fix usage of _MSC_VER in gzguts.h and zutil.h [Truta]
|
||||||
|
- Update readme.txt in contrib/masmx64 and masmx86 to assemble
|
||||||
|
|
||||||
|
Changes in 1.2.3.9 (21 Feb 2010)
|
||||||
|
- Expunge gzio.c
|
||||||
|
- Move as400 build information to old
|
||||||
|
- Fix updates in contrib/minizip and contrib/vstudio
|
||||||
|
- Add const to vsnprintf test in configure to avoid warnings [Weigelt]
|
||||||
|
- Delete zconf.h (made by configure) [Weigelt]
|
||||||
|
- Change zconf.in.h to zconf.h.in per convention [Weigelt]
|
||||||
|
- Check for NULL buf in gzgets()
|
||||||
|
- Return empty string for gzgets() with len == 1 (like fgets())
|
||||||
|
- Fix description of gzgets() in zlib.h for end-of-file, NULL return
|
||||||
|
- Update minizip to 1.1 [Vollant]
|
||||||
|
- Avoid MSVC loss of data warnings in gzread.c, gzwrite.c
|
||||||
|
- Note in zlib.h that gzerror() should be used to distinguish from EOF
|
||||||
|
- Remove use of snprintf() from gzlib.c
|
||||||
|
- Fix bug in gzseek()
|
||||||
|
- Update contrib/vstudio, adding vc9 and vc10 [Kuno, Vollant]
|
||||||
|
- Fix zconf.h generation in CMakeLists.txt [Lowman]
|
||||||
|
- Improve comments in zconf.h where modified by configure
|
||||||
|
|
||||||
|
Changes in 1.2.3.8 (13 Feb 2010)
|
||||||
|
- Clean up text files (tabs, trailing whitespace, etc.) [Oberhumer]
|
||||||
|
- Use z_off64_t in gz_zero() and gz_skip() to match state->skip
|
||||||
|
- Avoid comparison problem when sizeof(int) == sizeof(z_off64_t)
|
||||||
|
- Revert to Makefile.in from 1.2.3.6 (live with the clutter)
|
||||||
|
- Fix missing error return in gzflush(), add zlib.h note
|
||||||
|
- Add *64 functions to zlib.map [Levin]
|
||||||
|
- Fix signed/unsigned comparison in gz_comp()
|
||||||
|
- Use SFLAGS when testing shared linking in configure
|
||||||
|
- Add --64 option to ./configure to use -m64 with gcc
|
||||||
|
- Fix ./configure --help to correctly name options
|
||||||
|
- Have make fail if a test fails [Levin]
|
||||||
|
- Avoid buffer overrun in contrib/masmx64/gvmat64.asm [Simpson]
|
||||||
|
- Remove assembler object files from contrib
|
||||||
|
|
||||||
|
Changes in 1.2.3.7 (24 Jan 2010)
|
||||||
|
- Always gzopen() with O_LARGEFILE if available
|
||||||
|
- Fix gzdirect() to work immediately after gzopen() or gzdopen()
|
||||||
|
- Make gzdirect() more precise when the state changes while reading
|
||||||
|
- Improve zlib.h documentation in many places
|
||||||
|
- Catch memory allocation failure in gz_open()
|
||||||
|
- Complete close operation if seek forward in gzclose_w() fails
|
||||||
|
- Return Z_ERRNO from gzclose_r() if close() fails
|
||||||
|
- Return Z_STREAM_ERROR instead of EOF for gzclose() being passed NULL
|
||||||
|
- Return zero for gzwrite() errors to match zlib.h description
|
||||||
|
- Return -1 on gzputs() error to match zlib.h description
|
||||||
|
- Add zconf.in.h to allow recovery from configure modification [Weigelt]
|
||||||
|
- Fix static library permissions in Makefile.in [Weigelt]
|
||||||
|
- Avoid warnings in configure tests that hide functionality [Weigelt]
|
||||||
|
- Add *BSD and DragonFly to Linux case in configure [gentoo 123571]
|
||||||
|
- Change libzdll.a to libz.dll.a in win32/Makefile.gcc [gentoo 288212]
|
||||||
|
- Avoid access of uninitialized data for first inflateReset2 call [Gomes]
|
||||||
|
- Keep object files in subdirectories to reduce the clutter somewhat
|
||||||
|
- Remove default Makefile and zlibdefs.h, add dummy Makefile
|
||||||
|
- Add new external functions to Z_PREFIX, remove duplicates, z_z_ -> z_
|
||||||
|
- Remove zlibdefs.h completely -- modify zconf.h instead
|
||||||
|
|
||||||
|
Changes in 1.2.3.6 (17 Jan 2010)
|
||||||
|
- Avoid void * arithmetic in gzread.c and gzwrite.c
|
||||||
|
- Make compilers happier with const char * for gz_error message
|
||||||
|
- Avoid unused parameter warning in inflate.c
|
||||||
|
- Avoid signed-unsigned comparison warning in inflate.c
|
||||||
|
- Indent #pragma's for traditional C
|
||||||
|
- Fix usage of strwinerror() in glib.c, change to gz_strwinerror()
|
||||||
|
- Correct email address in configure for system options
|
||||||
|
- Update make_vms.com and add make_vms.com to contrib/minizip [Zinser]
|
||||||
|
- Update zlib.map [Brown]
|
||||||
|
- Fix Makefile.in for Solaris 10 make of example64 and minizip64 [Torok]
|
||||||
|
- Apply various fixes to CMakeLists.txt [Lowman]
|
||||||
|
- Add checks on len in gzread() and gzwrite()
|
||||||
|
- Add error message for no more room for gzungetc()
|
||||||
|
- Remove zlib version check in gzwrite()
|
||||||
|
- Defer compression of gzprintf() result until need to
|
||||||
|
- Use snprintf() in gzdopen() if available
|
||||||
|
- Remove USE_MMAP configuration determination (only used by minigzip)
|
||||||
|
- Remove examples/pigz.c (available separately)
|
||||||
|
- Update examples/gun.c to 1.6
|
||||||
|
|
||||||
|
Changes in 1.2.3.5 (8 Jan 2010)
|
||||||
|
- Add space after #if in zutil.h for some compilers
|
||||||
|
- Fix relatively harmless bug in deflate_fast() [Exarevsky]
|
||||||
|
- Fix same problem in deflate_slow()
|
||||||
|
- Add $(SHAREDLIBV) to LIBS in Makefile.in [Brown]
|
||||||
|
- Add deflate_rle() for faster Z_RLE strategy run-length encoding
|
||||||
|
- Add deflate_huff() for faster Z_HUFFMAN_ONLY encoding
|
||||||
|
- Change name of "write" variable in inffast.c to avoid library collisions
|
||||||
|
- Fix premature EOF from gzread() in gzio.c [Brown]
|
||||||
|
- Use zlib header window size if windowBits is 0 in inflateInit2()
|
||||||
|
- Remove compressBound() call in deflate.c to avoid linking compress.o
|
||||||
|
- Replace use of errno in gz* with functions, support WinCE [Alves]
|
||||||
|
- Provide alternative to perror() in minigzip.c for WinCE [Alves]
|
||||||
|
- Don't use _vsnprintf on later versions of MSVC [Lowman]
|
||||||
|
- Add CMake build script and input file [Lowman]
|
||||||
|
- Update contrib/minizip to 1.1 [Svensson, Vollant]
|
||||||
|
- Moved nintendods directory from contrib to .
|
||||||
|
- Replace gzio.c with a new set of routines with the same functionality
|
||||||
|
- Add gzbuffer(), gzoffset(), gzclose_r(), gzclose_w() as part of above
|
||||||
|
- Update contrib/minizip to 1.1b
|
||||||
|
- Change gzeof() to return 0 on error instead of -1 to agree with zlib.h
|
||||||
|
|
||||||
|
Changes in 1.2.3.4 (21 Dec 2009)
|
||||||
|
- Use old school .SUFFIXES in Makefile.in for FreeBSD compatibility
|
||||||
|
- Update comments in configure and Makefile.in for default --shared
|
||||||
|
- Fix test -z's in configure [Marquess]
|
||||||
|
- Build examplesh and minigzipsh when not testing
|
||||||
|
- Change NULL's to Z_NULL's in deflate.c and in comments in zlib.h
|
||||||
|
- Import LDFLAGS from the environment in configure
|
||||||
|
- Fix configure to populate SFLAGS with discovered CFLAGS options
|
||||||
|
- Adapt make_vms.com to the new Makefile.in [Zinser]
|
||||||
|
- Add zlib2ansi script for C++ compilation [Marquess]
|
||||||
|
- Add _FILE_OFFSET_BITS=64 test to make test (when applicable)
|
||||||
|
- Add AMD64 assembler code for longest match to contrib [Teterin]
|
||||||
|
- Include options from $SFLAGS when doing $LDSHARED
|
||||||
|
- Simplify 64-bit file support by introducing z_off64_t type
|
||||||
|
- Make shared object files in objs directory to work around old Sun cc
|
||||||
|
- Use only three-part version number for Darwin shared compiles
|
||||||
|
- Add rc option to ar in Makefile.in for when ./configure not run
|
||||||
|
- Add -WI,-rpath,. to LDFLAGS for OSF 1 V4*
|
||||||
|
- Set LD_LIBRARYN32_PATH for SGI IRIX shared compile
|
||||||
|
- Protect against _FILE_OFFSET_BITS being defined when compiling zlib
|
||||||
|
- Rename Makefile.in targets allstatic to static and allshared to shared
|
||||||
|
- Fix static and shared Makefile.in targets to be independent
|
||||||
|
- Correct error return bug in gz_open() by setting state [Brown]
|
||||||
|
- Put spaces before ;;'s in configure for better sh compatibility
|
||||||
|
- Add pigz.c (parallel implementation of gzip) to examples/
|
||||||
|
- Correct constant in crc32.c to UL [Leventhal]
|
||||||
|
- Reject negative lengths in crc32_combine()
|
||||||
|
- Add inflateReset2() function to work like inflateEnd()/inflateInit2()
|
||||||
|
- Include sys/types.h for _LARGEFILE64_SOURCE [Brown]
|
||||||
|
- Correct typo in doc/algorithm.txt [Janik]
|
||||||
|
- Fix bug in adler32_combine() [Zhu]
|
||||||
|
- Catch missing-end-of-block-code error in all inflates and in puff
|
||||||
|
Assures that random input to inflate eventually results in an error
|
||||||
|
- Added enough.c (calculation of ENOUGH for inftrees.h) to examples/
|
||||||
|
- Update ENOUGH and its usage to reflect discovered bounds
|
||||||
|
- Fix gzerror() error report on empty input file [Brown]
|
||||||
|
- Add ush casts in trees.c to avoid pedantic runtime errors
|
||||||
|
- Fix typo in zlib.h uncompress() description [Reiss]
|
||||||
|
- Correct inflate() comments with regard to automatic header detection
|
||||||
|
- Remove deprecation comment on Z_PARTIAL_FLUSH (it stays)
|
||||||
|
- Put new version of gzlog (2.0) in examples with interruption recovery
|
||||||
|
- Add puff compile option to permit invalid distance-too-far streams
|
||||||
|
- Add puff TEST command options, ability to read piped input
|
||||||
|
- Prototype the *64 functions in zlib.h when _FILE_OFFSET_BITS == 64, but
|
||||||
|
_LARGEFILE64_SOURCE not defined
|
||||||
|
- Fix Z_FULL_FLUSH to truly erase the past by resetting s->strstart
|
||||||
|
- Fix deflateSetDictionary() to use all 32K for output consistency
|
||||||
|
- Remove extraneous #define MIN_LOOKAHEAD in deflate.c (in deflate.h)
|
||||||
|
- Clear bytes after deflate lookahead to avoid use of uninitialized data
|
||||||
|
- Change a limit in inftrees.c to be more transparent to Coverity Prevent
|
||||||
|
- Update win32/zlib.def with exported symbols from zlib.h
|
||||||
|
- Correct spelling error in zlib.h [Willem]
|
||||||
|
- Allow Z_BLOCK for deflate() to force a new block
|
||||||
|
- Allow negative bits in inflatePrime() to delete existing bit buffer
|
||||||
|
- Add Z_TREES flush option to inflate() to return at end of trees
|
||||||
|
- Add inflateMark() to return current state information for random access
|
||||||
|
- Add Makefile for NintendoDS to contrib [Costa]
|
||||||
|
- Add -w in configure compile tests to avoid spurious warnings [Beucler]
|
||||||
|
- Fix typos in zlib.h comments for deflateSetDictionary()
|
||||||
|
- Fix EOF detection in transparent gzread() [Maier]
|
||||||
|
|
||||||
|
Changes in 1.2.3.3 (2 October 2006)
|
||||||
|
- Make --shared the default for configure, add a --static option
|
||||||
|
- Add compile option to permit invalid distance-too-far streams
|
||||||
|
- Add inflateUndermine() function which is required to enable above
|
||||||
|
- Remove use of "this" variable name for C++ compatibility [Marquess]
|
||||||
|
- Add testing of shared library in make test, if shared library built
|
||||||
|
- Use ftello() and fseeko() if available instead of ftell() and fseek()
|
||||||
|
- Provide two versions of all functions that use the z_off_t type for
|
||||||
|
binary compatibility -- a normal version and a 64-bit offset version,
|
||||||
|
per the Large File Support Extension when _LARGEFILE64_SOURCE is
|
||||||
|
defined; use the 64-bit versions by default when _FILE_OFFSET_BITS
|
||||||
|
is defined to be 64
|
||||||
|
- Add a --uname= option to configure to perhaps help with cross-compiling
|
||||||
|
|
||||||
|
Changes in 1.2.3.2 (3 September 2006)
|
||||||
|
- Turn off silly Borland warnings [Hay]
|
||||||
|
- Use off64_t and define _LARGEFILE64_SOURCE when present
|
||||||
|
- Fix missing dependency on inffixed.h in Makefile.in
|
||||||
|
- Rig configure --shared to build both shared and static [Teredesai, Truta]
|
||||||
|
- Remove zconf.in.h and instead create a new zlibdefs.h file
|
||||||
|
- Fix contrib/minizip/unzip.c non-encrypted after encrypted [Vollant]
|
||||||
|
- Add treebuild.xml (see http://treebuild.metux.de/) [Weigelt]
|
||||||
|
|
||||||
|
Changes in 1.2.3.1 (16 August 2006)
|
||||||
|
- Add watcom directory with OpenWatcom make files [Daniel]
|
||||||
|
- Remove #undef of FAR in zconf.in.h for MVS [Fedtke]
|
||||||
|
- Update make_vms.com [Zinser]
|
||||||
|
- Use -fPIC for shared build in configure [Teredesai, Nicholson]
|
||||||
|
- Use only major version number for libz.so on IRIX and OSF1 [Reinholdtsen]
|
||||||
|
- Use fdopen() (not _fdopen()) for Interix in zutil.h [BŠck]
|
||||||
|
- Add some FAQ entries about the contrib directory
|
||||||
|
- Update the MVS question in the FAQ
|
||||||
|
- Avoid extraneous reads after EOF in gzio.c [Brown]
|
||||||
|
- Correct spelling of "successfully" in gzio.c [Randers-Pehrson]
|
||||||
|
- Add comments to zlib.h about gzerror() usage [Brown]
|
||||||
|
- Set extra flags in gzip header in gzopen() like deflate() does
|
||||||
|
- Make configure options more compatible with double-dash conventions
|
||||||
|
[Weigelt]
|
||||||
|
- Clean up compilation under Solaris SunStudio cc [Rowe, Reinholdtsen]
|
||||||
|
- Fix uninstall target in Makefile.in [Truta]
|
||||||
|
- Add pkgconfig support [Weigelt]
|
||||||
|
- Use $(DESTDIR) macro in Makefile.in [Reinholdtsen, Weigelt]
|
||||||
|
- Replace set_data_type() with a more accurate detect_data_type() in
|
||||||
|
trees.c, according to the txtvsbin.txt document [Truta]
|
||||||
|
- Swap the order of #include <stdio.h> and #include "zlib.h" in
|
||||||
|
gzio.c, example.c and minigzip.c [Truta]
|
||||||
|
- Shut up annoying VS2005 warnings about standard C deprecation [Rowe,
|
||||||
|
Truta] (where?)
|
||||||
|
- Fix target "clean" from win32/Makefile.bor [Truta]
|
||||||
|
- Create .pdb and .manifest files in win32/makefile.msc [Ziegler, Rowe]
|
||||||
|
- Update zlib www home address in win32/DLL_FAQ.txt [Truta]
|
||||||
|
- Update contrib/masmx86/inffas32.asm for VS2005 [Vollant, Van Wassenhove]
|
||||||
|
- Enable browse info in the "Debug" and "ASM Debug" configurations in
|
||||||
|
the Visual C++ 6 project, and set (non-ASM) "Debug" as default [Truta]
|
||||||
|
- Add pkgconfig support [Weigelt]
|
||||||
|
- Add ZLIB_VER_MAJOR, ZLIB_VER_MINOR and ZLIB_VER_REVISION in zlib.h,
|
||||||
|
for use in win32/zlib1.rc [Polushin, Rowe, Truta]
|
||||||
|
- Add a document that explains the new text detection scheme to
|
||||||
|
doc/txtvsbin.txt [Truta]
|
||||||
|
- Add rfc1950.txt, rfc1951.txt and rfc1952.txt to doc/ [Truta]
|
||||||
|
- Move algorithm.txt into doc/ [Truta]
|
||||||
|
- Synchronize FAQ with website
|
||||||
|
- Fix compressBound(), was low for some pathological cases [Fearnley]
|
||||||
|
- Take into account wrapper variations in deflateBound()
|
||||||
|
- Set examples/zpipe.c input and output to binary mode for Windows
|
||||||
|
- Update examples/zlib_how.html with new zpipe.c (also web site)
|
||||||
|
- Fix some warnings in examples/gzlog.c and examples/zran.c (it seems
|
||||||
|
that gcc became pickier in 4.0)
|
||||||
|
- Add zlib.map for Linux: "All symbols from zlib-1.1.4 remain
|
||||||
|
un-versioned, the patch adds versioning only for symbols introduced in
|
||||||
|
zlib-1.2.0 or later. It also declares as local those symbols which are
|
||||||
|
not designed to be exported." [Levin]
|
||||||
|
- Update Z_PREFIX list in zconf.in.h, add --zprefix option to configure
|
||||||
|
- Do not initialize global static by default in trees.c, add a response
|
||||||
|
NO_INIT_GLOBAL_POINTERS to initialize them if needed [Marquess]
|
||||||
|
- Don't use strerror() in gzio.c under WinCE [Yakimov]
|
||||||
|
- Don't use errno.h in zutil.h under WinCE [Yakimov]
|
||||||
|
- Move arguments for AR to its usage to allow replacing ar [Marot]
|
||||||
|
- Add HAVE_VISIBILITY_PRAGMA in zconf.in.h for Mozilla [Randers-Pehrson]
|
||||||
|
- Improve inflateInit() and inflateInit2() documentation
|
||||||
|
- Fix structure size comment in inflate.h
|
||||||
|
- Change configure help option from --h* to --help [Santos]
|
||||||
|
|
||||||
Changes in 1.2.3 (18 July 2005)
|
Changes in 1.2.3 (18 July 2005)
|
||||||
- Apply security vulnerability fixes to contrib/infback9 as well
|
- Apply security vulnerability fixes to contrib/infback9 as well
|
||||||
- Clean up some text files (carriage returns, trailing space)
|
- Clean up some text files (carriage returns, trailing space)
|
||||||
|
@ -13,7 +366,7 @@ Changes in 1.2.2.4 (11 July 2005)
|
||||||
compile
|
compile
|
||||||
- Fix some spelling errors in comments [Betts]
|
- Fix some spelling errors in comments [Betts]
|
||||||
- Correct inflateInit2() error return documentation in zlib.h
|
- Correct inflateInit2() error return documentation in zlib.h
|
||||||
- Added zran.c example of compressed data random access to examples
|
- Add zran.c example of compressed data random access to examples
|
||||||
directory, shows use of inflatePrime()
|
directory, shows use of inflatePrime()
|
||||||
- Fix cast for assignments to strm->state in inflate.c and infback.c
|
- Fix cast for assignments to strm->state in inflate.c and infback.c
|
||||||
- Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer]
|
- Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer]
|
||||||
|
|
261
zlib/FAQ
261
zlib/FAQ
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
|
|
||||||
If your question is not there, please check the zlib home page
|
If your question is not there, please check the zlib home page
|
||||||
http://www.zlib.org which may have more recent information.
|
http://zlib.net/ which may have more recent information.
|
||||||
The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
|
The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
|
||||||
|
|
||||||
|
|
||||||
1. Is zlib Y2K-compliant?
|
1. Is zlib Y2K-compliant?
|
||||||
|
@ -13,54 +13,51 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
|
||||||
|
|
||||||
2. Where can I get a Windows DLL version?
|
2. Where can I get a Windows DLL version?
|
||||||
|
|
||||||
The zlib sources can be compiled without change to produce a DLL.
|
The zlib sources can be compiled without change to produce a DLL. See the
|
||||||
See the file win32/DLL_FAQ.txt in the zlib distribution.
|
file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the
|
||||||
Pointers to the precompiled DLL are found in the zlib web site at
|
precompiled DLL are found in the zlib web site at http://zlib.net/ .
|
||||||
http://www.zlib.org.
|
|
||||||
|
|
||||||
3. Where can I get a Visual Basic interface to zlib?
|
3. Where can I get a Visual Basic interface to zlib?
|
||||||
|
|
||||||
See
|
See
|
||||||
* http://www.dogma.net/markn/articles/zlibtool/zlibtool.htm
|
* http://marknelson.us/1997/01/01/zlib-engine/
|
||||||
* contrib/visual-basic.txt in the zlib distribution
|
|
||||||
* win32/DLL_FAQ.txt in the zlib distribution
|
* win32/DLL_FAQ.txt in the zlib distribution
|
||||||
|
|
||||||
4. compress() returns Z_BUF_ERROR.
|
4. compress() returns Z_BUF_ERROR.
|
||||||
|
|
||||||
Make sure that before the call of compress, the length of the compressed
|
Make sure that before the call of compress(), the length of the compressed
|
||||||
buffer is equal to the total size of the compressed buffer and not
|
buffer is equal to the available size of the compressed buffer and not
|
||||||
zero. For Visual Basic, check that this parameter is passed by reference
|
zero. For Visual Basic, check that this parameter is passed by reference
|
||||||
("as any"), not by value ("as long").
|
("as any"), not by value ("as long").
|
||||||
|
|
||||||
5. deflate() or inflate() returns Z_BUF_ERROR.
|
5. deflate() or inflate() returns Z_BUF_ERROR.
|
||||||
|
|
||||||
Before making the call, make sure that avail_in and avail_out are not
|
Before making the call, make sure that avail_in and avail_out are not zero.
|
||||||
zero. When setting the parameter flush equal to Z_FINISH, also make sure
|
When setting the parameter flush equal to Z_FINISH, also make sure that
|
||||||
that avail_out is big enough to allow processing all pending input.
|
avail_out is big enough to allow processing all pending input. Note that a
|
||||||
Note that a Z_BUF_ERROR is not fatal--another call to deflate() or
|
Z_BUF_ERROR is not fatal--another call to deflate() or inflate() can be
|
||||||
inflate() can be made with more input or output space. A Z_BUF_ERROR
|
made with more input or output space. A Z_BUF_ERROR may in fact be
|
||||||
may in fact be unavoidable depending on how the functions are used, since
|
unavoidable depending on how the functions are used, since it is not
|
||||||
it is not possible to tell whether or not there is more output pending
|
possible to tell whether or not there is more output pending when
|
||||||
when strm.avail_out returns with zero.
|
strm.avail_out returns with zero. See http://zlib.net/zlib_how.html for a
|
||||||
|
heavily annotated example.
|
||||||
|
|
||||||
6. Where's the zlib documentation (man pages, etc.)?
|
6. Where's the zlib documentation (man pages, etc.)?
|
||||||
|
|
||||||
It's in zlib.h for the moment, and Francis S. Lin has converted it to a
|
It's in zlib.h . Examples of zlib usage are in the files example.c and
|
||||||
web page zlib.html. Volunteers to transform this to Unix-style man pages,
|
minigzip.c, with more in examples/ .
|
||||||
please contact us (zlib@gzip.org). Examples of zlib usage are in the files
|
|
||||||
example.c and minigzip.c.
|
|
||||||
|
|
||||||
7. Why don't you use GNU autoconf or libtool or ...?
|
7. Why don't you use GNU autoconf or libtool or ...?
|
||||||
|
|
||||||
Because we would like to keep zlib as a very small and simple
|
Because we would like to keep zlib as a very small and simple package.
|
||||||
package. zlib is rather portable and doesn't need much configuration.
|
zlib is rather portable and doesn't need much configuration.
|
||||||
|
|
||||||
8. I found a bug in zlib.
|
8. I found a bug in zlib.
|
||||||
|
|
||||||
Most of the time, such problems are due to an incorrect usage of
|
Most of the time, such problems are due to an incorrect usage of zlib.
|
||||||
zlib. Please try to reproduce the problem with a small program and send
|
Please try to reproduce the problem with a small program and send the
|
||||||
the corresponding source to us at zlib@gzip.org . Do not send
|
corresponding source to us at zlib@gzip.org . Do not send multi-megabyte
|
||||||
multi-megabyte data files without prior agreement.
|
data files without prior agreement.
|
||||||
|
|
||||||
9. Why do I get "undefined reference to gzputc"?
|
9. Why do I get "undefined reference to gzputc"?
|
||||||
|
|
||||||
|
@ -82,7 +79,7 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
|
||||||
|
|
||||||
12. Can zlib handle .Z files?
|
12. Can zlib handle .Z files?
|
||||||
|
|
||||||
No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt
|
No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt
|
||||||
the code of uncompress on your own.
|
the code of uncompress on your own.
|
||||||
|
|
||||||
13. How can I make a Unix shared library?
|
13. How can I make a Unix shared library?
|
||||||
|
@ -99,8 +96,10 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
|
||||||
|
|
||||||
However, many flavors of Unix come with a shared zlib already installed.
|
However, many flavors of Unix come with a shared zlib already installed.
|
||||||
Before going to the trouble of compiling a shared version of zlib and
|
Before going to the trouble of compiling a shared version of zlib and
|
||||||
trying to install it, you may want to check if it's already there! If you
|
trying to install it, you may want to check if it's already there! If you
|
||||||
can #include <zlib.h>, it's there. The -lz option will probably link to it.
|
can #include <zlib.h>, it's there. The -lz option will probably link to
|
||||||
|
it. You can check the version at the top of zlib.h or with the
|
||||||
|
ZLIB_VERSION symbol defined in zlib.h .
|
||||||
|
|
||||||
15. I have a question about OttoPDF.
|
15. I have a question about OttoPDF.
|
||||||
|
|
||||||
|
@ -109,8 +108,8 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
|
||||||
|
|
||||||
16. Can zlib decode Flate data in an Adobe PDF file?
|
16. Can zlib decode Flate data in an Adobe PDF file?
|
||||||
|
|
||||||
Yes. See http://www.fastio.com/ (ClibPDF), or http://www.pdflib.com/ .
|
Yes. See http://www.pdflib.com/ . To modify PDF forms, see
|
||||||
To modify PDF forms, see http://sourceforge.net/projects/acroformtool/ .
|
http://sourceforge.net/projects/acroformtool/ .
|
||||||
|
|
||||||
17. Why am I getting this "register_frame_info not found" error on Solaris?
|
17. Why am I getting this "register_frame_info not found" error on Solaris?
|
||||||
|
|
||||||
|
@ -121,67 +120,67 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
|
||||||
symbol __register_frame_info: referenced symbol not found
|
symbol __register_frame_info: referenced symbol not found
|
||||||
|
|
||||||
The symbol __register_frame_info is not part of zlib, it is generated by
|
The symbol __register_frame_info is not part of zlib, it is generated by
|
||||||
the C compiler (cc or gcc). You must recompile applications using zlib
|
the C compiler (cc or gcc). You must recompile applications using zlib
|
||||||
which have this problem. This problem is specific to Solaris. See
|
which have this problem. This problem is specific to Solaris. See
|
||||||
http://www.sunfreeware.com for Solaris versions of zlib and applications
|
http://www.sunfreeware.com for Solaris versions of zlib and applications
|
||||||
using zlib.
|
using zlib.
|
||||||
|
|
||||||
18. Why does gzip give an error on a file I make with compress/deflate?
|
18. Why does gzip give an error on a file I make with compress/deflate?
|
||||||
|
|
||||||
The compress and deflate functions produce data in the zlib format, which
|
The compress and deflate functions produce data in the zlib format, which
|
||||||
is different and incompatible with the gzip format. The gz* functions in
|
is different and incompatible with the gzip format. The gz* functions in
|
||||||
zlib on the other hand use the gzip format. Both the zlib and gzip
|
zlib on the other hand use the gzip format. Both the zlib and gzip formats
|
||||||
formats use the same compressed data format internally, but have different
|
use the same compressed data format internally, but have different headers
|
||||||
headers and trailers around the compressed data.
|
and trailers around the compressed data.
|
||||||
|
|
||||||
19. Ok, so why are there two different formats?
|
19. Ok, so why are there two different formats?
|
||||||
|
|
||||||
The gzip format was designed to retain the directory information about
|
The gzip format was designed to retain the directory information about a
|
||||||
a single file, such as the name and last modification date. The zlib
|
single file, such as the name and last modification date. The zlib format
|
||||||
format on the other hand was designed for in-memory and communication
|
on the other hand was designed for in-memory and communication channel
|
||||||
channel applications, and has a much more compact header and trailer and
|
applications, and has a much more compact header and trailer and uses a
|
||||||
uses a faster integrity check than gzip.
|
faster integrity check than gzip.
|
||||||
|
|
||||||
20. Well that's nice, but how do I make a gzip file in memory?
|
20. Well that's nice, but how do I make a gzip file in memory?
|
||||||
|
|
||||||
You can request that deflate write the gzip format instead of the zlib
|
You can request that deflate write the gzip format instead of the zlib
|
||||||
format using deflateInit2(). You can also request that inflate decode
|
format using deflateInit2(). You can also request that inflate decode the
|
||||||
the gzip format using inflateInit2(). Read zlib.h for more details.
|
gzip format using inflateInit2(). Read zlib.h for more details.
|
||||||
|
|
||||||
21. Is zlib thread-safe?
|
21. Is zlib thread-safe?
|
||||||
|
|
||||||
Yes. However any library routines that zlib uses and any application-
|
Yes. However any library routines that zlib uses and any application-
|
||||||
provided memory allocation routines must also be thread-safe. zlib's gz*
|
provided memory allocation routines must also be thread-safe. zlib's gz*
|
||||||
functions use stdio library routines, and most of zlib's functions use the
|
functions use stdio library routines, and most of zlib's functions use the
|
||||||
library memory allocation routines by default. zlib's Init functions allow
|
library memory allocation routines by default. zlib's *Init* functions
|
||||||
for the application to provide custom memory allocation routines.
|
allow for the application to provide custom memory allocation routines.
|
||||||
|
|
||||||
Of course, you should only operate on any given zlib or gzip stream from a
|
Of course, you should only operate on any given zlib or gzip stream from a
|
||||||
single thread at a time.
|
single thread at a time.
|
||||||
|
|
||||||
22. Can I use zlib in my commercial application?
|
22. Can I use zlib in my commercial application?
|
||||||
|
|
||||||
Yes. Please read the license in zlib.h.
|
Yes. Please read the license in zlib.h.
|
||||||
|
|
||||||
23. Is zlib under the GNU license?
|
23. Is zlib under the GNU license?
|
||||||
|
|
||||||
No. Please read the license in zlib.h.
|
No. Please read the license in zlib.h.
|
||||||
|
|
||||||
24. The license says that altered source versions must be "plainly marked". So
|
24. The license says that altered source versions must be "plainly marked". So
|
||||||
what exactly do I need to do to meet that requirement?
|
what exactly do I need to do to meet that requirement?
|
||||||
|
|
||||||
You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In
|
You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In
|
||||||
particular, the final version number needs to be changed to "f", and an
|
particular, the final version number needs to be changed to "f", and an
|
||||||
identification string should be appended to ZLIB_VERSION. Version numbers
|
identification string should be appended to ZLIB_VERSION. Version numbers
|
||||||
x.x.x.f are reserved for modifications to zlib by others than the zlib
|
x.x.x.f are reserved for modifications to zlib by others than the zlib
|
||||||
maintainers. For example, if the version of the base zlib you are altering
|
maintainers. For example, if the version of the base zlib you are altering
|
||||||
is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and
|
is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and
|
||||||
ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also
|
ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also
|
||||||
update the version strings in deflate.c and inftrees.c.
|
update the version strings in deflate.c and inftrees.c.
|
||||||
|
|
||||||
For altered source distributions, you should also note the origin and
|
For altered source distributions, you should also note the origin and
|
||||||
nature of the changes in zlib.h, as well as in ChangeLog and README, along
|
nature of the changes in zlib.h, as well as in ChangeLog and README, along
|
||||||
with the dates of the alterations. The origin should include at least your
|
with the dates of the alterations. The origin should include at least your
|
||||||
name (or your company's name), and an email address to contact for help or
|
name (or your company's name), and an email address to contact for help or
|
||||||
issues with the library.
|
issues with the library.
|
||||||
|
|
||||||
|
@ -197,105 +196,112 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
|
||||||
|
|
||||||
26. Will zlib work on a 64-bit machine?
|
26. Will zlib work on a 64-bit machine?
|
||||||
|
|
||||||
It should. It has been tested on 64-bit machines, and has no dependence
|
Yes. It has been tested on 64-bit machines, and has no dependence on any
|
||||||
on any data types being limited to 32-bits in length. If you have any
|
data types being limited to 32-bits in length. If you have any
|
||||||
difficulties, please provide a complete problem report to zlib@gzip.org
|
difficulties, please provide a complete problem report to zlib@gzip.org
|
||||||
|
|
||||||
27. Will zlib decompress data from the PKWare Data Compression Library?
|
27. Will zlib decompress data from the PKWare Data Compression Library?
|
||||||
|
|
||||||
No. The PKWare DCL uses a completely different compressed data format
|
No. The PKWare DCL uses a completely different compressed data format than
|
||||||
than does PKZIP and zlib. However, you can look in zlib's contrib/blast
|
does PKZIP and zlib. However, you can look in zlib's contrib/blast
|
||||||
directory for a possible solution to your problem.
|
directory for a possible solution to your problem.
|
||||||
|
|
||||||
28. Can I access data randomly in a compressed stream?
|
28. Can I access data randomly in a compressed stream?
|
||||||
|
|
||||||
No, not without some preparation. If when compressing you periodically
|
No, not without some preparation. If when compressing you periodically use
|
||||||
use Z_FULL_FLUSH, carefully write all the pending data at those points,
|
Z_FULL_FLUSH, carefully write all the pending data at those points, and
|
||||||
and keep an index of those locations, then you can start decompression
|
keep an index of those locations, then you can start decompression at those
|
||||||
at those points. You have to be careful to not use Z_FULL_FLUSH too
|
points. You have to be careful to not use Z_FULL_FLUSH too often, since it
|
||||||
often, since it can significantly degrade compression.
|
can significantly degrade compression. Alternatively, you can scan a
|
||||||
|
deflate stream once to generate an index, and then use that index for
|
||||||
|
random access. See examples/zran.c .
|
||||||
|
|
||||||
29. Does zlib work on MVS, OS/390, CICS, etc.?
|
29. Does zlib work on MVS, OS/390, CICS, etc.?
|
||||||
|
|
||||||
We don't know for sure. We have heard occasional reports of success on
|
It has in the past, but we have not heard of any recent evidence. There
|
||||||
these systems. If you do use it on one of these, please provide us with
|
were working ports of zlib 1.1.4 to MVS, but those links no longer work.
|
||||||
a report, instructions, and patches that we can reference when we get
|
If you know of recent, successful applications of zlib on these operating
|
||||||
these questions. Thanks.
|
systems, please let us know. Thanks.
|
||||||
|
|
||||||
30. Is there some simpler, easier to read version of inflate I can look at
|
30. Is there some simpler, easier to read version of inflate I can look at to
|
||||||
to understand the deflate format?
|
understand the deflate format?
|
||||||
|
|
||||||
First off, you should read RFC 1951. Second, yes. Look in zlib's
|
First off, you should read RFC 1951. Second, yes. Look in zlib's
|
||||||
contrib/puff directory.
|
contrib/puff directory.
|
||||||
|
|
||||||
31. Does zlib infringe on any patents?
|
31. Does zlib infringe on any patents?
|
||||||
|
|
||||||
As far as we know, no. In fact, that was originally the whole point behind
|
As far as we know, no. In fact, that was originally the whole point behind
|
||||||
zlib. Look here for some more information:
|
zlib. Look here for some more information:
|
||||||
|
|
||||||
http://www.gzip.org/#faq11
|
http://www.gzip.org/#faq11
|
||||||
|
|
||||||
32. Can zlib work with greater than 4 GB of data?
|
32. Can zlib work with greater than 4 GB of data?
|
||||||
|
|
||||||
Yes. inflate() and deflate() will process any amount of data correctly.
|
Yes. inflate() and deflate() will process any amount of data correctly.
|
||||||
Each call of inflate() or deflate() is limited to input and output chunks
|
Each call of inflate() or deflate() is limited to input and output chunks
|
||||||
of the maximum value that can be stored in the compiler's "unsigned int"
|
of the maximum value that can be stored in the compiler's "unsigned int"
|
||||||
type, but there is no limit to the number of chunks. Note however that the
|
type, but there is no limit to the number of chunks. Note however that the
|
||||||
strm.total_in and strm_total_out counters may be limited to 4 GB. These
|
strm.total_in and strm_total_out counters may be limited to 4 GB. These
|
||||||
counters are provided as a convenience and are not used internally by
|
counters are provided as a convenience and are not used internally by
|
||||||
inflate() or deflate(). The application can easily set up its own counters
|
inflate() or deflate(). The application can easily set up its own counters
|
||||||
updated after each call of inflate() or deflate() to count beyond 4 GB.
|
updated after each call of inflate() or deflate() to count beyond 4 GB.
|
||||||
compress() and uncompress() may be limited to 4 GB, since they operate in a
|
compress() and uncompress() may be limited to 4 GB, since they operate in a
|
||||||
single call. gzseek() and gztell() may be limited to 4 GB depending on how
|
single call. gzseek() and gztell() may be limited to 4 GB depending on how
|
||||||
zlib is compiled. See the zlibCompileFlags() function in zlib.h.
|
zlib is compiled. See the zlibCompileFlags() function in zlib.h.
|
||||||
|
|
||||||
The word "may" appears several times above since there is a 4 GB limit
|
The word "may" appears several times above since there is a 4 GB limit only
|
||||||
only if the compiler's "long" type is 32 bits. If the compiler's "long"
|
if the compiler's "long" type is 32 bits. If the compiler's "long" type is
|
||||||
type is 64 bits, then the limit is 16 exabytes.
|
64 bits, then the limit is 16 exabytes.
|
||||||
|
|
||||||
33. Does zlib have any security vulnerabilities?
|
33. Does zlib have any security vulnerabilities?
|
||||||
|
|
||||||
The only one that we are aware of is potentially in gzprintf(). If zlib
|
The only one that we are aware of is potentially in gzprintf(). If zlib is
|
||||||
is compiled to use sprintf() or vsprintf(), then there is no protection
|
compiled to use sprintf() or vsprintf(), then there is no protection
|
||||||
against a buffer overflow of a 4K string space, other than the caller of
|
against a buffer overflow of an 8K string space (or other value as set by
|
||||||
gzprintf() assuring that the output will not exceed 4K. On the other
|
gzbuffer()), other than the caller of gzprintf() assuring that the output
|
||||||
hand, if zlib is compiled to use snprintf() or vsnprintf(), which should
|
will not exceed 8K. On the other hand, if zlib is compiled to use
|
||||||
normally be the case, then there is no vulnerability. The ./configure
|
snprintf() or vsnprintf(), which should normally be the case, then there is
|
||||||
script will display warnings if an insecure variation of sprintf() will
|
no vulnerability. The ./configure script will display warnings if an
|
||||||
be used by gzprintf(). Also the zlibCompileFlags() function will return
|
insecure variation of sprintf() will be used by gzprintf(). Also the
|
||||||
information on what variant of sprintf() is used by gzprintf().
|
zlibCompileFlags() function will return information on what variant of
|
||||||
|
sprintf() is used by gzprintf().
|
||||||
|
|
||||||
If you don't have snprintf() or vsnprintf() and would like one, you can
|
If you don't have snprintf() or vsnprintf() and would like one, you can
|
||||||
find a portable implementation here:
|
find a portable implementation here:
|
||||||
|
|
||||||
http://www.ijs.si/software/snprintf/
|
http://www.ijs.si/software/snprintf/
|
||||||
|
|
||||||
Note that you should be using the most recent version of zlib. Versions
|
Note that you should be using the most recent version of zlib. Versions
|
||||||
1.1.3 and before were subject to a double-free vulnerability.
|
1.1.3 and before were subject to a double-free vulnerability, and versions
|
||||||
|
1.2.1 and 1.2.2 were subject to an access exception when decompressing
|
||||||
|
invalid compressed data.
|
||||||
|
|
||||||
34. Is there a Java version of zlib?
|
34. Is there a Java version of zlib?
|
||||||
|
|
||||||
Probably what you want is to use zlib in Java. zlib is already included
|
Probably what you want is to use zlib in Java. zlib is already included
|
||||||
as part of the Java SDK in the java.util.zip package. If you really want
|
as part of the Java SDK in the java.util.zip package. If you really want
|
||||||
a version of zlib written in the Java language, look on the zlib home
|
a version of zlib written in the Java language, look on the zlib home
|
||||||
page for links: http://www.zlib.org/
|
page for links: http://zlib.net/ .
|
||||||
|
|
||||||
35. I get this or that compiler or source-code scanner warning when I crank it
|
35. I get this or that compiler or source-code scanner warning when I crank it
|
||||||
up to maximally-pedantic. Can't you guys write proper code?
|
up to maximally-pedantic. Can't you guys write proper code?
|
||||||
|
|
||||||
Many years ago, we gave up attempting to avoid warnings on every compiler
|
Many years ago, we gave up attempting to avoid warnings on every compiler
|
||||||
in the universe. It just got to be a waste of time, and some compilers
|
in the universe. It just got to be a waste of time, and some compilers
|
||||||
were downright silly. So now, we simply make sure that the code always
|
were downright silly as well as contradicted each other. So now, we simply
|
||||||
works.
|
make sure that the code always works.
|
||||||
|
|
||||||
36. Valgrind (or some similar memory access checker) says that deflate is
|
36. Valgrind (or some similar memory access checker) says that deflate is
|
||||||
performing a conditional jump that depends on an uninitialized value.
|
performing a conditional jump that depends on an uninitialized value.
|
||||||
Isn't that a bug?
|
Isn't that a bug?
|
||||||
|
|
||||||
No. That is intentional for performance reasons, and the output of
|
No. That is intentional for performance reasons, and the output of deflate
|
||||||
deflate is not affected. This only started showing up recently since
|
is not affected. This only started showing up recently since zlib 1.2.x
|
||||||
zlib 1.2.x uses malloc() by default for allocations, whereas earlier
|
uses malloc() by default for allocations, whereas earlier versions used
|
||||||
versions used calloc(), which zeros out the allocated memory.
|
calloc(), which zeros out the allocated memory. Even though the code was
|
||||||
|
correct, versions 1.2.4 and later was changed to not stimulate these
|
||||||
|
checkers.
|
||||||
|
|
||||||
37. Will zlib read the (insert any ancient or arcane format here) compressed
|
37. Will zlib read the (insert any ancient or arcane format here) compressed
|
||||||
data format?
|
data format?
|
||||||
|
@ -305,20 +311,21 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
|
||||||
|
|
||||||
38. How can I encrypt/decrypt zip files with zlib?
|
38. How can I encrypt/decrypt zip files with zlib?
|
||||||
|
|
||||||
zlib doesn't support encryption. The original PKZIP encryption is very weak
|
zlib doesn't support encryption. The original PKZIP encryption is very
|
||||||
and can be broken with freely available programs. To get strong encryption,
|
weak and can be broken with freely available programs. To get strong
|
||||||
use GnuPG, http://www.gnupg.org/ , which already includes zlib compression.
|
encryption, use GnuPG, http://www.gnupg.org/ , which already includes zlib
|
||||||
For PKZIP compatible "encryption", look at http://www.info-zip.org/
|
compression. For PKZIP compatible "encryption", look at
|
||||||
|
http://www.info-zip.org/
|
||||||
|
|
||||||
39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
|
39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
|
||||||
|
|
||||||
"gzip" is the gzip format, and "deflate" is the zlib format. They should
|
"gzip" is the gzip format, and "deflate" is the zlib format. They should
|
||||||
probably have called the second one "zlib" instead to avoid confusion
|
probably have called the second one "zlib" instead to avoid confusion with
|
||||||
with the raw deflate compressed data format. While the HTTP 1.1 RFC 2616
|
the raw deflate compressed data format. While the HTTP 1.1 RFC 2616
|
||||||
correctly points to the zlib specification in RFC 1950 for the "deflate"
|
correctly points to the zlib specification in RFC 1950 for the "deflate"
|
||||||
transfer encoding, there have been reports of servers and browsers that
|
transfer encoding, there have been reports of servers and browsers that
|
||||||
incorrectly produce or expect raw deflate data per the deflate
|
incorrectly produce or expect raw deflate data per the deflate
|
||||||
specficiation in RFC 1951, most notably Microsoft. So even though the
|
specficiation in RFC 1951, most notably Microsoft. So even though the
|
||||||
"deflate" transfer encoding using the zlib format would be the more
|
"deflate" transfer encoding using the zlib format would be the more
|
||||||
efficient approach (and in fact exactly what the zlib format was designed
|
efficient approach (and in fact exactly what the zlib format was designed
|
||||||
for), using the "gzip" transfer encoding is probably more reliable due to
|
for), using the "gzip" transfer encoding is probably more reliable due to
|
||||||
|
@ -328,12 +335,32 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
|
||||||
|
|
||||||
40. Does zlib support the new "Deflate64" format introduced by PKWare?
|
40. Does zlib support the new "Deflate64" format introduced by PKWare?
|
||||||
|
|
||||||
No. PKWare has apparently decided to keep that format proprietary, since
|
No. PKWare has apparently decided to keep that format proprietary, since
|
||||||
they have not documented it as they have previous compression formats.
|
they have not documented it as they have previous compression formats. In
|
||||||
In any case, the compression improvements are so modest compared to other
|
any case, the compression improvements are so modest compared to other more
|
||||||
more modern approaches, that it's not worth the effort to implement.
|
modern approaches, that it's not worth the effort to implement.
|
||||||
|
|
||||||
41. Can you please sign these lengthy legal documents and fax them back to us
|
41. I'm having a problem with the zip functions in zlib, can you help?
|
||||||
|
|
||||||
|
There are no zip functions in zlib. You are probably using minizip by
|
||||||
|
Giles Vollant, which is found in the contrib directory of zlib. It is not
|
||||||
|
part of zlib. In fact none of the stuff in contrib is part of zlib. The
|
||||||
|
files in there are not supported by the zlib authors. You need to contact
|
||||||
|
the authors of the respective contribution for help.
|
||||||
|
|
||||||
|
42. The match.asm code in contrib is under the GNU General Public License.
|
||||||
|
Since it's part of zlib, doesn't that mean that all of zlib falls under the
|
||||||
|
GNU GPL?
|
||||||
|
|
||||||
|
No. The files in contrib are not part of zlib. They were contributed by
|
||||||
|
other authors and are provided as a convenience to the user within the zlib
|
||||||
|
distribution. Each item in contrib has its own license.
|
||||||
|
|
||||||
|
43. Is zlib subject to export controls? What is its ECCN?
|
||||||
|
|
||||||
|
zlib is not subject to export controls, and so is classified as EAR99.
|
||||||
|
|
||||||
|
44. Can you please sign these lengthy legal documents and fax them back to us
|
||||||
so that we can use your software in our product?
|
so that we can use your software in our product?
|
||||||
|
|
||||||
No. Go away. Shoo.
|
No. Go away. Shoo.
|
||||||
|
|
30
zlib/INDEX
30
zlib/INDEX
|
@ -1,23 +1,32 @@
|
||||||
|
CMakeLists.txt cmake build file
|
||||||
ChangeLog history of changes
|
ChangeLog history of changes
|
||||||
FAQ Frequently Asked Questions about zlib
|
FAQ Frequently Asked Questions about zlib
|
||||||
INDEX this file
|
INDEX this file
|
||||||
Makefile makefile for Unix (generated by configure)
|
Makefile dummy Makefile that tells you to ./configure
|
||||||
Makefile.in makefile for Unix (template for configure)
|
Makefile.in template for Unix Makefile
|
||||||
README guess what
|
README guess what
|
||||||
algorithm.txt description of the (de)compression algorithm
|
|
||||||
configure configure script for Unix
|
configure configure script for Unix
|
||||||
zconf.in.h template for zconf.h (used by configure)
|
make_vms.com makefile for VMS
|
||||||
|
treebuild.xml XML description of source file dependencies
|
||||||
|
zconf.h.cmakein zconf.h template for cmake
|
||||||
|
zconf.h.in zconf.h template for configure
|
||||||
|
zlib.3 Man page for zlib
|
||||||
|
zlib.3.pdf Man page in PDF format
|
||||||
|
zlib.map Linux symbol information
|
||||||
|
zlib.pc.in Template for pkg-config descriptor
|
||||||
|
zlib2ansi perl script to convert source files for C++ compilation
|
||||||
|
|
||||||
amiga/ makefiles for Amiga SAS C
|
amiga/ makefiles for Amiga SAS C
|
||||||
as400/ makefiles for IBM AS/400
|
doc/ documentation for formats and algorithms
|
||||||
msdos/ makefiles for MSDOS
|
msdos/ makefiles for MSDOS
|
||||||
|
nintendods/ makefile for Nintendo DS
|
||||||
old/ makefiles for various architectures and zlib documentation
|
old/ makefiles for various architectures and zlib documentation
|
||||||
files that have not yet been updated for zlib 1.2.x
|
files that have not yet been updated for zlib 1.2.x
|
||||||
projects/ projects for various Integrated Development Environments
|
|
||||||
qnx/ makefiles for QNX
|
qnx/ makefiles for QNX
|
||||||
|
watcom/ makefiles for OpenWatcom
|
||||||
win32/ makefiles for Windows
|
win32/ makefiles for Windows
|
||||||
|
|
||||||
zlib public header files (must be kept):
|
zlib public header files (required for library use):
|
||||||
zconf.h
|
zconf.h
|
||||||
zlib.h
|
zlib.h
|
||||||
|
|
||||||
|
@ -28,7 +37,11 @@ crc32.c
|
||||||
crc32.h
|
crc32.h
|
||||||
deflate.c
|
deflate.c
|
||||||
deflate.h
|
deflate.h
|
||||||
gzio.c
|
gzclose.c
|
||||||
|
gzguts.h
|
||||||
|
gzlib.c
|
||||||
|
gzread.c
|
||||||
|
gzwrite.c
|
||||||
infback.c
|
infback.c
|
||||||
inffast.c
|
inffast.c
|
||||||
inffast.h
|
inffast.h
|
||||||
|
@ -46,6 +59,7 @@ zutil.h
|
||||||
source files for sample programs:
|
source files for sample programs:
|
||||||
example.c
|
example.c
|
||||||
minigzip.c
|
minigzip.c
|
||||||
|
See examples/README.examples for more
|
||||||
|
|
||||||
unsupported contribution by third parties
|
unsupported contribution by third parties
|
||||||
See contrib/README.contrib
|
See contrib/README.contrib
|
||||||
|
|
86
zlib/README
86
zlib/README
|
@ -1,56 +1,52 @@
|
||||||
ZLIB DATA COMPRESSION LIBRARY
|
ZLIB DATA COMPRESSION LIBRARY
|
||||||
|
|
||||||
zlib 1.2.3 is a general purpose data compression library. All the code is
|
zlib 1.2.5 is a general purpose data compression library. All the code is
|
||||||
thread safe. The data format used by the zlib library is described by RFCs
|
thread safe. The data format used by the zlib library is described by RFCs
|
||||||
(Request for Comments) 1950 to 1952 in the files
|
(Request for Comments) 1950 to 1952 in the files
|
||||||
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
|
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
|
||||||
and rfc1952.txt (gzip format). These documents are also available in other
|
and rfc1952.txt (gzip format).
|
||||||
formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
|
|
||||||
|
|
||||||
All functions of the compression library are documented in the file zlib.h
|
All functions of the compression library are documented in the file zlib.h
|
||||||
(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
|
(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
|
||||||
of the library is given in the file example.c which also tests that the library
|
of the library is given in the file example.c which also tests that the library
|
||||||
is working correctly. Another example is given in the file minigzip.c. The
|
is working correctly. Another example is given in the file minigzip.c. The
|
||||||
compression library itself is composed of all source files except example.c and
|
compression library itself is composed of all source files except example.c and
|
||||||
minigzip.c.
|
minigzip.c.
|
||||||
|
|
||||||
To compile all files and run the test program, follow the instructions given at
|
To compile all files and run the test program, follow the instructions given at
|
||||||
the top of Makefile. In short "make test; make install" should work for most
|
the top of Makefile.in. In short "./configure; make test", and if that goes
|
||||||
machines. For Unix: "./configure; make test; make install". For MSDOS, use one
|
well, "make install" should work for most flavors of Unix. For Windows, use one
|
||||||
of the special makefiles such as Makefile.msc. For VMS, use make_vms.com.
|
of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use
|
||||||
|
make_vms.com.
|
||||||
|
|
||||||
Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
|
Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
|
||||||
<info@winimage.com> for the Windows DLL version. The zlib home page is
|
<info@winimage.com> for the Windows DLL version. The zlib home page is
|
||||||
http://www.zlib.org or http://www.gzip.org/zlib/ Before reporting a problem,
|
http://zlib.net/ . Before reporting a problem, please check this site to
|
||||||
please check this site to verify that you have the latest version of zlib;
|
verify that you have the latest version of zlib; otherwise get the latest
|
||||||
otherwise get the latest version and check whether the problem still exists or
|
version and check whether the problem still exists or not.
|
||||||
not.
|
|
||||||
|
|
||||||
PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html before asking
|
PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
|
||||||
for help.
|
|
||||||
|
|
||||||
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
|
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
|
||||||
issue of Dr. Dobb's Journal; a copy of the article is available in
|
issue of Dr. Dobb's Journal; a copy of the article is available at
|
||||||
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
|
http://marknelson.us/1997/01/01/zlib-engine/ .
|
||||||
|
|
||||||
The changes made in version 1.2.3 are documented in the file ChangeLog.
|
The changes made in version 1.2.5 are documented in the file ChangeLog.
|
||||||
|
|
||||||
Unsupported third party contributions are provided in directory "contrib".
|
Unsupported third party contributions are provided in directory contrib/ .
|
||||||
|
|
||||||
A Java implementation of zlib is available in the Java Development Kit
|
zlib is available in Java using the java.util.zip package, documented at
|
||||||
http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html
|
http://java.sun.com/developer/technicalArticles/Programming/compression/ .
|
||||||
See the zlib home page http://www.zlib.org for details.
|
|
||||||
|
|
||||||
A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is in the
|
A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is available
|
||||||
CPAN (Comprehensive Perl Archive Network) sites
|
at CPAN (Comprehensive Perl Archive Network) sites, including
|
||||||
http://www.cpan.org/modules/by-module/Compress/
|
http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
|
||||||
|
|
||||||
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
|
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
|
||||||
available in Python 1.5 and later versions, see
|
available in Python 1.5 and later versions, see
|
||||||
http://www.python.org/doc/lib/module-zlib.html
|
http://www.python.org/doc/lib/module-zlib.html .
|
||||||
|
|
||||||
A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> is
|
zlib is built into tcl: http://wiki.tcl.tk/4610 .
|
||||||
availlable at http://www.oche.de/~akupries/soft/trf/trf_zip.html
|
|
||||||
|
|
||||||
An experimental package to read and write files in .zip format, written on top
|
An experimental package to read and write files in .zip format, written on top
|
||||||
of zlib by Gilles Vollant <info@winimage.com>, is available in the
|
of zlib by Gilles Vollant <info@winimage.com>, is available in the
|
||||||
|
@ -74,25 +70,21 @@ Notes for some targets:
|
||||||
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
|
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
|
||||||
other compilers. Use "make test" to check your compiler.
|
other compilers. Use "make test" to check your compiler.
|
||||||
|
|
||||||
- gzdopen is not supported on RISCOS, BEOS and by some Mac compilers.
|
- gzdopen is not supported on RISCOS or BEOS.
|
||||||
|
|
||||||
- For PalmOs, see http://palmzlib.sourceforge.net/
|
- For PalmOs, see http://palmzlib.sourceforge.net/
|
||||||
|
|
||||||
- When building a shared, i.e. dynamic library on Mac OS X, the library must be
|
|
||||||
installed before testing (do "make install" before "make test"), since the
|
|
||||||
library location is specified in the library.
|
|
||||||
|
|
||||||
|
|
||||||
Acknowledgments:
|
Acknowledgments:
|
||||||
|
|
||||||
The deflate format used by zlib was defined by Phil Katz. The deflate
|
The deflate format used by zlib was defined by Phil Katz. The deflate and
|
||||||
and zlib specifications were written by L. Peter Deutsch. Thanks to all the
|
zlib specifications were written by L. Peter Deutsch. Thanks to all the
|
||||||
people who reported problems and suggested various improvements in zlib;
|
people who reported problems and suggested various improvements in zlib; they
|
||||||
they are too numerous to cite here.
|
are too numerous to cite here.
|
||||||
|
|
||||||
Copyright notice:
|
Copyright notice:
|
||||||
|
|
||||||
(C) 1995-2004 Jean-loup Gailly and Mark Adler
|
(C) 1995-2010 Jean-loup Gailly and Mark Adler
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied
|
This software is provided 'as-is', without any express or implied
|
||||||
warranty. In no event will the authors be held liable for any damages
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
@ -113,13 +105,11 @@ Copyright notice:
|
||||||
Jean-loup Gailly Mark Adler
|
Jean-loup Gailly Mark Adler
|
||||||
jloup@gzip.org madler@alumni.caltech.edu
|
jloup@gzip.org madler@alumni.caltech.edu
|
||||||
|
|
||||||
If you use the zlib library in a product, we would appreciate *not*
|
If you use the zlib library in a product, we would appreciate *not* receiving
|
||||||
receiving lengthy legal documents to sign. The sources are provided
|
lengthy legal documents to sign. The sources are provided for free but without
|
||||||
for free but without warranty of any kind. The library has been
|
warranty of any kind. The library has been entirely written by Jean-loup
|
||||||
entirely written by Jean-loup Gailly and Mark Adler; it does not
|
Gailly and Mark Adler; it does not include third-party code.
|
||||||
include third-party code.
|
|
||||||
|
|
||||||
If you redistribute modified sources, we would appreciate that you include
|
If you redistribute modified sources, we would appreciate that you include in
|
||||||
in the file ChangeLog history information documenting your changes. Please
|
the file ChangeLog history information documenting your changes. Please read
|
||||||
read the FAQ for more information on the distribution of modified source
|
the FAQ for more information on the distribution of modified source versions.
|
||||||
versions.
|
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
/* adler32.c -- compute the Adler-32 checksum of a data stream
|
||||||
* Copyright (C) 1995-2004 Mark Adler
|
* Copyright (C) 1995-2007 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$ */
|
||||||
|
|
||||||
#define ZLIB_INTERNAL
|
#include "zutil.h"
|
||||||
#include "zlib.h"
|
|
||||||
|
#define local static
|
||||||
|
|
||||||
|
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
|
||||||
|
|
||||||
#define BASE 65521UL /* largest prime smaller than 65536 */
|
#define BASE 65521UL /* largest prime smaller than 65536 */
|
||||||
#define NMAX 5552
|
#define NMAX 5552
|
||||||
|
@ -125,10 +128,10 @@ uLong ZEXPORT adler32(adler, buf, len)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
|
local uLong adler32_combine_(adler1, adler2, len2)
|
||||||
uLong adler1;
|
uLong adler1;
|
||||||
uLong adler2;
|
uLong adler2;
|
||||||
z_off_t len2;
|
z_off64_t len2;
|
||||||
{
|
{
|
||||||
unsigned long sum1;
|
unsigned long sum1;
|
||||||
unsigned long sum2;
|
unsigned long sum2;
|
||||||
|
@ -141,9 +144,26 @@ uLong ZEXPORT adler32_combine(adler1, adler2, len2)
|
||||||
MOD(sum2);
|
MOD(sum2);
|
||||||
sum1 += (adler2 & 0xffff) + BASE - 1;
|
sum1 += (adler2 & 0xffff) + BASE - 1;
|
||||||
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
|
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
|
||||||
if (sum1 > BASE) sum1 -= BASE;
|
if (sum1 >= BASE) sum1 -= BASE;
|
||||||
if (sum1 > BASE) sum1 -= BASE;
|
if (sum1 >= BASE) sum1 -= BASE;
|
||||||
if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
|
if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
|
||||||
if (sum2 > BASE) sum2 -= BASE;
|
if (sum2 >= BASE) sum2 -= BASE;
|
||||||
return sum1 | (sum2 << 16);
|
return sum1 | (sum2 << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ========================================================================= */
|
||||||
|
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
|
||||||
|
uLong adler1;
|
||||||
|
uLong adler2;
|
||||||
|
z_off_t len2;
|
||||||
|
{
|
||||||
|
return adler32_combine_(adler1, adler2, len2);
|
||||||
|
}
|
||||||
|
|
||||||
|
uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
|
||||||
|
uLong adler1;
|
||||||
|
uLong adler2;
|
||||||
|
z_off64_t len2;
|
||||||
|
{
|
||||||
|
return adler32_combine_(adler1, adler2, len2);
|
||||||
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ At least for deflate's output that generates new trees every several 10's of
|
||||||
kbytes. You can imagine that filling in a 2^15 entry table for a 15-bit code
|
kbytes. You can imagine that filling in a 2^15 entry table for a 15-bit code
|
||||||
would take too long if you're only decoding several thousand symbols. At the
|
would take too long if you're only decoding several thousand symbols. At the
|
||||||
other extreme, you could make a new table for every bit in the code. In fact,
|
other extreme, you could make a new table for every bit in the code. In fact,
|
||||||
that's essentially a Huffman tree. But then you spend two much time
|
that's essentially a Huffman tree. But then you spend too much time
|
||||||
traversing the tree while decoding, even for short symbols.
|
traversing the tree while decoding, even for short symbols.
|
||||||
|
|
||||||
So the number of bits for the first lookup table is a trade of the time to
|
So the number of bits for the first lookup table is a trade of the time to
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* compress.c -- compress a memory buffer
|
/* compress.c -- compress a memory buffer
|
||||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -75,5 +75,6 @@ int ZEXPORT compress (dest, destLen, source, sourceLen)
|
||||||
uLong ZEXPORT compressBound (sourceLen)
|
uLong ZEXPORT compressBound (sourceLen)
|
||||||
uLong sourceLen;
|
uLong sourceLen;
|
||||||
{
|
{
|
||||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
|
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
||||||
|
(sourceLen >> 25) + 13;
|
||||||
}
|
}
|
||||||
|
|
459
zlib/configure
vendored
459
zlib/configure
vendored
|
@ -1,459 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# configure script for zlib. This script is needed only if
|
|
||||||
# you wish to build a shared library and your system supports them,
|
|
||||||
# of if you need special compiler, flags or install directory.
|
|
||||||
# Otherwise, you can just use directly "make test; make install"
|
|
||||||
#
|
|
||||||
# To create a shared library, use "configure --shared"; by default a static
|
|
||||||
# library is created. If the primitive shared library support provided here
|
|
||||||
# does not work, use ftp://prep.ai.mit.edu/pub/gnu/libtool-*.tar.gz
|
|
||||||
#
|
|
||||||
# To impose specific compiler or flags or install directory, use for example:
|
|
||||||
# prefix=$HOME CC=cc CFLAGS="-O4" ./configure
|
|
||||||
# or for csh/tcsh users:
|
|
||||||
# (setenv prefix $HOME; setenv CC cc; setenv CFLAGS "-O4"; ./configure)
|
|
||||||
# LDSHARED is the command to be used to create a shared library
|
|
||||||
|
|
||||||
# Incorrect settings of CC or CFLAGS may prevent creating a shared library.
|
|
||||||
# If you have problems, try without defining CC and CFLAGS before reporting
|
|
||||||
# an error.
|
|
||||||
|
|
||||||
LIBS=libz.a
|
|
||||||
LDFLAGS="-L. ${LIBS}"
|
|
||||||
VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`
|
|
||||||
VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < zlib.h`
|
|
||||||
VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < zlib.h`
|
|
||||||
AR=${AR-"ar rc"}
|
|
||||||
RANLIB=${RANLIB-"ranlib"}
|
|
||||||
prefix=${prefix-/usr/local}
|
|
||||||
exec_prefix=${exec_prefix-'${prefix}'}
|
|
||||||
libdir=${libdir-'${exec_prefix}/lib'}
|
|
||||||
includedir=${includedir-'${prefix}/include'}
|
|
||||||
mandir=${mandir-'${prefix}/share/man'}
|
|
||||||
shared_ext='.so'
|
|
||||||
shared=0
|
|
||||||
gcc=0
|
|
||||||
old_cc="$CC"
|
|
||||||
old_cflags="$CFLAGS"
|
|
||||||
|
|
||||||
while test $# -ge 1
|
|
||||||
do
|
|
||||||
case "$1" in
|
|
||||||
-h* | --h*)
|
|
||||||
echo 'usage:'
|
|
||||||
echo ' configure [--shared] [--prefix=PREFIX] [--exec_prefix=EXPREFIX]'
|
|
||||||
echo ' [--libdir=LIBDIR] [--includedir=INCLUDEDIR]'
|
|
||||||
exit 0;;
|
|
||||||
-p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
|
|
||||||
-e*=* | --e*=*) exec_prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
|
|
||||||
-l*=* | --libdir=*) libdir=`echo $1 | sed 's/[-a-z_]*=//'`; shift;;
|
|
||||||
-i*=* | --includedir=*) includedir=`echo $1 | sed 's/[-a-z_]*=//'`;shift;;
|
|
||||||
-p* | --p*) prefix="$2"; shift; shift;;
|
|
||||||
-e* | --e*) exec_prefix="$2"; shift; shift;;
|
|
||||||
-l* | --l*) libdir="$2"; shift; shift;;
|
|
||||||
-i* | --i*) includedir="$2"; shift; shift;;
|
|
||||||
-s* | --s*) shared=1; shift;;
|
|
||||||
*) echo "unknown option: $1"; echo "$0 --help for help"; exit 1;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
test=ztest$$
|
|
||||||
cat > $test.c <<EOF
|
|
||||||
extern int getchar();
|
|
||||||
int hello() {return getchar();}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
test -z "$CC" && echo Checking for gcc...
|
|
||||||
cc=${CC-gcc}
|
|
||||||
cflags=${CFLAGS-"-O3"}
|
|
||||||
# to force the asm version use: CFLAGS="-O3 -DASMV" ./configure
|
|
||||||
case "$cc" in
|
|
||||||
*gcc*) gcc=1;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then
|
|
||||||
CC="$cc"
|
|
||||||
SFLAGS=${CFLAGS-"-fPIC -O3"}
|
|
||||||
CFLAGS="$cflags"
|
|
||||||
case `(uname -s || echo unknown) 2>/dev/null` in
|
|
||||||
Linux | linux | GNU | GNU/*) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};;
|
|
||||||
CYGWIN* | Cygwin* | cygwin* | OS/2* )
|
|
||||||
EXE='.exe';;
|
|
||||||
QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4
|
|
||||||
# (alain.bonnefoy@icbt.com)
|
|
||||||
LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"};;
|
|
||||||
HP-UX*)
|
|
||||||
LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"}
|
|
||||||
case `(uname -m || echo unknown) 2>/dev/null` in
|
|
||||||
ia64)
|
|
||||||
shared_ext='.so'
|
|
||||||
SHAREDLIB='libz.so';;
|
|
||||||
*)
|
|
||||||
shared_ext='.sl'
|
|
||||||
SHAREDLIB='libz.sl';;
|
|
||||||
esac;;
|
|
||||||
Darwin*) shared_ext='.dylib'
|
|
||||||
SHAREDLIB=libz$shared_ext
|
|
||||||
SHAREDLIBV=libz.$VER$shared_ext
|
|
||||||
SHAREDLIBM=libz.$VER1$shared_ext
|
|
||||||
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER"};;
|
|
||||||
*) LDSHARED=${LDSHARED-"$cc -shared"};;
|
|
||||||
esac
|
|
||||||
else
|
|
||||||
# find system name and corresponding cc options
|
|
||||||
CC=${CC-cc}
|
|
||||||
case `(uname -sr || echo unknown) 2>/dev/null` in
|
|
||||||
HP-UX*) SFLAGS=${CFLAGS-"-O +z"}
|
|
||||||
CFLAGS=${CFLAGS-"-O"}
|
|
||||||
# LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"}
|
|
||||||
LDSHARED=${LDSHARED-"ld -b"}
|
|
||||||
case `(uname -m || echo unknown) 2>/dev/null` in
|
|
||||||
ia64)
|
|
||||||
shared_ext='.so'
|
|
||||||
SHAREDLIB='libz.so';;
|
|
||||||
*)
|
|
||||||
shared_ext='.sl'
|
|
||||||
SHAREDLIB='libz.sl';;
|
|
||||||
esac;;
|
|
||||||
IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."}
|
|
||||||
CFLAGS=${CFLAGS-"-ansi -O2"}
|
|
||||||
LDSHARED=${LDSHARED-"cc -shared"};;
|
|
||||||
OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"}
|
|
||||||
CFLAGS=${CFLAGS-"-O -std1"}
|
|
||||||
LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,libz.so -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};;
|
|
||||||
OSF1*) SFLAGS=${CFLAGS-"-O -std1"}
|
|
||||||
CFLAGS=${CFLAGS-"-O -std1"}
|
|
||||||
LDSHARED=${LDSHARED-"cc -shared"};;
|
|
||||||
QNX*) SFLAGS=${CFLAGS-"-4 -O"}
|
|
||||||
CFLAGS=${CFLAGS-"-4 -O"}
|
|
||||||
LDSHARED=${LDSHARED-"cc"}
|
|
||||||
RANLIB=${RANLIB-"true"}
|
|
||||||
AR="cc -A";;
|
|
||||||
SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "}
|
|
||||||
CFLAGS=${CFLAGS-"-O3"}
|
|
||||||
LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};;
|
|
||||||
SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."}
|
|
||||||
CFLAGS=${CFLAGS-"-fast -xcg89"}
|
|
||||||
LDSHARED=${LDSHARED-"cc -G"};;
|
|
||||||
SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"}
|
|
||||||
CFLAGS=${CFLAGS-"-O2"}
|
|
||||||
LDSHARED=${LDSHARED-"ld"};;
|
|
||||||
SunStudio\ 9*) SFLAGS=${CFLAGS-"-DUSE_MMAP -fast -xcode=pic32 -xtarget=ultra3 -xarch=v9b"}
|
|
||||||
CFLAGS=${CFLAGS-"-DUSE_MMAP -fast -xtarget=ultra3 -xarch=v9b"}
|
|
||||||
LDSHARED=${LDSHARED-"cc -xarch=v9b"};;
|
|
||||||
UNIX_System_V\ 4.2.0)
|
|
||||||
SFLAGS=${CFLAGS-"-KPIC -O"}
|
|
||||||
CFLAGS=${CFLAGS-"-O"}
|
|
||||||
LDSHARED=${LDSHARED-"cc -G"};;
|
|
||||||
UNIX_SV\ 4.2MP)
|
|
||||||
SFLAGS=${CFLAGS-"-Kconform_pic -O"}
|
|
||||||
CFLAGS=${CFLAGS-"-O"}
|
|
||||||
LDSHARED=${LDSHARED-"cc -G"};;
|
|
||||||
OpenUNIX\ 5)
|
|
||||||
SFLAGS=${CFLAGS-"-KPIC -O"}
|
|
||||||
CFLAGS=${CFLAGS-"-O"}
|
|
||||||
LDSHARED=${LDSHARED-"cc -G"};;
|
|
||||||
AIX*) # Courtesy of dbakker@arrayasolutions.com
|
|
||||||
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
|
|
||||||
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
|
|
||||||
LDSHARED=${LDSHARED-"xlc -G"};;
|
|
||||||
# send working options for other systems to support@gzip.org
|
|
||||||
*) SFLAGS=${CFLAGS-"-O"}
|
|
||||||
CFLAGS=${CFLAGS-"-O"}
|
|
||||||
LDSHARED=${LDSHARED-"cc -shared"};;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
SHAREDLIB=${SHAREDLIB-"libz$shared_ext"}
|
|
||||||
SHAREDLIBV=${SHAREDLIBV-"libz$shared_ext.$VER"}
|
|
||||||
SHAREDLIBM=${SHAREDLIBM-"libz$shared_ext.$VER1"}
|
|
||||||
|
|
||||||
if test $shared -eq 1; then
|
|
||||||
echo Checking for shared library support...
|
|
||||||
# we must test in two steps (cc then ld), required at least on SunOS 4.x
|
|
||||||
if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" &&
|
|
||||||
test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then
|
|
||||||
CFLAGS="$SFLAGS"
|
|
||||||
LIBS="$SHAREDLIBV"
|
|
||||||
echo Building shared library $SHAREDLIBV with $CC.
|
|
||||||
elif test -z "$old_cc" -a -z "$old_cflags"; then
|
|
||||||
echo No shared library support.
|
|
||||||
shared=0;
|
|
||||||
else
|
|
||||||
echo 'No shared library support; try without defining CC and CFLAGS'
|
|
||||||
shared=0;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if test $shared -eq 0; then
|
|
||||||
LDSHARED="$CC"
|
|
||||||
echo Building static library $LIBS version $VER with $CC.
|
|
||||||
else
|
|
||||||
LDFLAGS="-L. ${SHAREDLIBV}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat > $test.c <<EOF
|
|
||||||
#include <unistd.h>
|
|
||||||
int main() { return 0; }
|
|
||||||
EOF
|
|
||||||
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
|
|
||||||
sed < zconf.in.h "/HAVE_UNISTD_H/s%0%1%" > zconf.h
|
|
||||||
echo "Checking for unistd.h... Yes."
|
|
||||||
else
|
|
||||||
cp -p zconf.in.h zconf.h
|
|
||||||
echo "Checking for unistd.h... No."
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat > $test.c <<EOF
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include "zconf.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
#ifndef STDC
|
|
||||||
choke me
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
|
|
||||||
echo "Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf()"
|
|
||||||
|
|
||||||
cat > $test.c <<EOF
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
int mytest(char *fmt, ...)
|
|
||||||
{
|
|
||||||
char buf[20];
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsnprintf(buf, sizeof(buf), fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
return (mytest("Hello%d\n", 1));
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
|
|
||||||
echo "Checking for vsnprintf() in stdio.h... Yes."
|
|
||||||
|
|
||||||
cat >$test.c <<EOF
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
int mytest(char *fmt, ...)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
char buf[20];
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
n = vsnprintf(buf, sizeof(buf), fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
return (mytest("Hello%d\n", 1));
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
|
|
||||||
echo "Checking for return value of vsnprintf()... Yes."
|
|
||||||
else
|
|
||||||
CFLAGS="$CFLAGS -DHAS_vsnprintf_void"
|
|
||||||
echo "Checking for return value of vsnprintf()... No."
|
|
||||||
echo " WARNING: apparently vsnprintf() does not return a value. zlib"
|
|
||||||
echo " can build but will be open to possible string-format security"
|
|
||||||
echo " vulnerabilities."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
CFLAGS="$CFLAGS -DNO_vsnprintf"
|
|
||||||
echo "Checking for vsnprintf() in stdio.h... No."
|
|
||||||
echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib"
|
|
||||||
echo " can build but will be open to possible buffer-overflow security"
|
|
||||||
echo " vulnerabilities."
|
|
||||||
|
|
||||||
cat >$test.c <<EOF
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
int mytest(char *fmt, ...)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
char buf[20];
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
n = vsprintf(buf, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
return (mytest("Hello%d\n", 1));
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
|
|
||||||
echo "Checking for return value of vsprintf()... Yes."
|
|
||||||
else
|
|
||||||
CFLAGS="$CFLAGS -DHAS_vsprintf_void"
|
|
||||||
echo "Checking for return value of vsprintf()... No."
|
|
||||||
echo " WARNING: apparently vsprintf() does not return a value. zlib"
|
|
||||||
echo " can build but will be open to possible string-format security"
|
|
||||||
echo " vulnerabilities."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf()"
|
|
||||||
|
|
||||||
cat >$test.c <<EOF
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int mytest()
|
|
||||||
{
|
|
||||||
char buf[20];
|
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s", "foo");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
return (mytest());
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
if test "`($CC $CFLAGS -o $test $test.c) 2>&1`" = ""; then
|
|
||||||
echo "Checking for snprintf() in stdio.h... Yes."
|
|
||||||
|
|
||||||
cat >$test.c <<EOF
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int mytest()
|
|
||||||
{
|
|
||||||
char buf[20];
|
|
||||||
|
|
||||||
return snprintf(buf, sizeof(buf), "%s", "foo");
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
return (mytest());
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
|
|
||||||
echo "Checking for return value of snprintf()... Yes."
|
|
||||||
else
|
|
||||||
CFLAGS="$CFLAGS -DHAS_snprintf_void"
|
|
||||||
echo "Checking for return value of snprintf()... No."
|
|
||||||
echo " WARNING: apparently snprintf() does not return a value. zlib"
|
|
||||||
echo " can build but will be open to possible string-format security"
|
|
||||||
echo " vulnerabilities."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
CFLAGS="$CFLAGS -DNO_snprintf"
|
|
||||||
echo "Checking for snprintf() in stdio.h... No."
|
|
||||||
echo " WARNING: snprintf() not found, falling back to sprintf(). zlib"
|
|
||||||
echo " can build but will be open to possible buffer-overflow security"
|
|
||||||
echo " vulnerabilities."
|
|
||||||
|
|
||||||
cat >$test.c <<EOF
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int mytest()
|
|
||||||
{
|
|
||||||
char buf[20];
|
|
||||||
|
|
||||||
return sprintf(buf, "%s", "foo");
|
|
||||||
}
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
return (mytest());
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
|
|
||||||
echo "Checking for return value of sprintf()... Yes."
|
|
||||||
else
|
|
||||||
CFLAGS="$CFLAGS -DHAS_sprintf_void"
|
|
||||||
echo "Checking for return value of sprintf()... No."
|
|
||||||
echo " WARNING: apparently sprintf() does not return a value. zlib"
|
|
||||||
echo " can build but will be open to possible string-format security"
|
|
||||||
echo " vulnerabilities."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat >$test.c <<EOF
|
|
||||||
#include <errno.h>
|
|
||||||
int main() { return 0; }
|
|
||||||
EOF
|
|
||||||
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
|
|
||||||
echo "Checking for errno.h... Yes."
|
|
||||||
else
|
|
||||||
echo "Checking for errno.h... No."
|
|
||||||
CFLAGS="$CFLAGS -DNO_ERRNO_H"
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat > $test.c <<EOF
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
caddr_t hello() {
|
|
||||||
return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then
|
|
||||||
CFLAGS="$CFLAGS -DUSE_MMAP"
|
|
||||||
echo Checking for mmap support... Yes.
|
|
||||||
else
|
|
||||||
echo Checking for mmap support... No.
|
|
||||||
fi
|
|
||||||
|
|
||||||
CPP=${CPP-"$CC -E"}
|
|
||||||
case $CFLAGS in
|
|
||||||
*ASMV*)
|
|
||||||
if test "`nm $test.o | grep _hello`" = ""; then
|
|
||||||
CPP="$CPP -DNO_UNDERLINE"
|
|
||||||
echo Checking for underline in external names... No.
|
|
||||||
else
|
|
||||||
echo Checking for underline in external names... Yes.
|
|
||||||
fi;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
rm -f $test.[co] $test $test$shared_ext
|
|
||||||
|
|
||||||
# udpate Makefile
|
|
||||||
sed < Makefile.in "
|
|
||||||
/^CC *=/s#=.*#=$CC#
|
|
||||||
/^CFLAGS *=/s#=.*#=$CFLAGS#
|
|
||||||
/^CPP *=/s#=.*#=$CPP#
|
|
||||||
/^LDSHARED *=/s#=.*#=$LDSHARED#
|
|
||||||
/^LIBS *=/s#=.*#=$LIBS#
|
|
||||||
/^SHAREDLIB *=/s#=.*#=$SHAREDLIB#
|
|
||||||
/^SHAREDLIBV *=/s#=.*#=$SHAREDLIBV#
|
|
||||||
/^SHAREDLIBM *=/s#=.*#=$SHAREDLIBM#
|
|
||||||
/^AR *=/s#=.*#=$AR#
|
|
||||||
/^RANLIB *=/s#=.*#=$RANLIB#
|
|
||||||
/^EXE *=/s#=.*#=$EXE#
|
|
||||||
/^prefix *=/s#=.*#=$prefix#
|
|
||||||
/^exec_prefix *=/s#=.*#=$exec_prefix#
|
|
||||||
/^libdir *=/s#=.*#=$libdir#
|
|
||||||
/^includedir *=/s#=.*#=$includedir#
|
|
||||||
/^mandir *=/s#=.*#=$mandir#
|
|
||||||
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
|
|
||||||
" > Makefile
|
|
35
zlib/crc32.c
35
zlib/crc32.c
|
@ -1,5 +1,5 @@
|
||||||
/* crc32.c -- compute the CRC-32 of a data stream
|
/* crc32.c -- compute the CRC-32 of a data stream
|
||||||
* Copyright (C) 1995-2005 Mark Adler
|
* Copyright (C) 1995-2006, 2010 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
|
||||||
*
|
*
|
||||||
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
|
* Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
|
|
||||||
/* Definitions for doing the crc four data bytes at a time. */
|
/* Definitions for doing the crc four data bytes at a time. */
|
||||||
#ifdef BYFOUR
|
#ifdef BYFOUR
|
||||||
# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
|
# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
|
||||||
(((w)&0xff00)<<8)+(((w)&0xff)<<24))
|
(((w)&0xff00)<<8)+(((w)&0xff)<<24))
|
||||||
local unsigned long crc32_little OF((unsigned long,
|
local unsigned long crc32_little OF((unsigned long,
|
||||||
const unsigned char FAR *, unsigned));
|
const unsigned char FAR *, unsigned));
|
||||||
|
@ -68,6 +68,8 @@
|
||||||
local unsigned long gf2_matrix_times OF((unsigned long *mat,
|
local unsigned long gf2_matrix_times OF((unsigned long *mat,
|
||||||
unsigned long vec));
|
unsigned long vec));
|
||||||
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
|
local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
|
||||||
|
local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2);
|
||||||
|
|
||||||
|
|
||||||
#ifdef DYNAMIC_CRC_TABLE
|
#ifdef DYNAMIC_CRC_TABLE
|
||||||
|
|
||||||
|
@ -219,7 +221,7 @@ const unsigned long FAR * ZEXPORT get_crc_table()
|
||||||
unsigned long ZEXPORT crc32(crc, buf, len)
|
unsigned long ZEXPORT crc32(crc, buf, len)
|
||||||
unsigned long crc;
|
unsigned long crc;
|
||||||
const unsigned char FAR *buf;
|
const unsigned char FAR *buf;
|
||||||
unsigned len;
|
uInt len;
|
||||||
{
|
{
|
||||||
if (buf == Z_NULL) return 0UL;
|
if (buf == Z_NULL) return 0UL;
|
||||||
|
|
||||||
|
@ -367,22 +369,22 @@ local void gf2_matrix_square(square, mat)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
uLong ZEXPORT crc32_combine(crc1, crc2, len2)
|
local uLong crc32_combine_(crc1, crc2, len2)
|
||||||
uLong crc1;
|
uLong crc1;
|
||||||
uLong crc2;
|
uLong crc2;
|
||||||
z_off_t len2;
|
z_off64_t len2;
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
unsigned long row;
|
unsigned long row;
|
||||||
unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
|
unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
|
||||||
unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
|
unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
|
||||||
|
|
||||||
/* degenerate case */
|
/* degenerate case (also disallow negative lengths) */
|
||||||
if (len2 == 0)
|
if (len2 <= 0)
|
||||||
return crc1;
|
return crc1;
|
||||||
|
|
||||||
/* put operator for one zero bit in odd */
|
/* put operator for one zero bit in odd */
|
||||||
odd[0] = 0xedb88320L; /* CRC-32 polynomial */
|
odd[0] = 0xedb88320UL; /* CRC-32 polynomial */
|
||||||
row = 1;
|
row = 1;
|
||||||
for (n = 1; n < GF2_DIM; n++) {
|
for (n = 1; n < GF2_DIM; n++) {
|
||||||
odd[n] = row;
|
odd[n] = row;
|
||||||
|
@ -421,3 +423,20 @@ uLong ZEXPORT crc32_combine(crc1, crc2, len2)
|
||||||
crc1 ^= crc2;
|
crc1 ^= crc2;
|
||||||
return crc1;
|
return crc1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ========================================================================= */
|
||||||
|
uLong ZEXPORT crc32_combine(crc1, crc2, len2)
|
||||||
|
uLong crc1;
|
||||||
|
uLong crc2;
|
||||||
|
z_off_t len2;
|
||||||
|
{
|
||||||
|
return crc32_combine_(crc1, crc2, len2);
|
||||||
|
}
|
||||||
|
|
||||||
|
uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
|
||||||
|
uLong crc1;
|
||||||
|
uLong crc2;
|
||||||
|
z_off64_t len2;
|
||||||
|
{
|
||||||
|
return crc32_combine_(crc1, crc2, len2);
|
||||||
|
}
|
||||||
|
|
268
zlib/deflate.c
268
zlib/deflate.c
|
@ -1,5 +1,5 @@
|
||||||
/* deflate.c -- compress data using the deflation algorithm
|
/* deflate.c -- compress data using the deflation algorithm
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
* Copyright (C) 1995-2010 Jean-loup Gailly and 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
#include "deflate.h"
|
#include "deflate.h"
|
||||||
|
|
||||||
const char deflate_copyright[] =
|
const char deflate_copyright[] =
|
||||||
" deflate 1.2.3 Copyright 1995-2005 Jean-loup Gailly ";
|
" deflate 1.2.5 Copyright 1995-2010 Jean-loup Gailly and Mark Adler ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
If you use the zlib library in a product, an acknowledgment is welcome
|
||||||
in the documentation of your product. If for some reason you cannot
|
in the documentation of your product. If for some reason you cannot
|
||||||
|
@ -79,19 +79,18 @@ local block_state deflate_fast OF((deflate_state *s, int flush));
|
||||||
#ifndef FASTEST
|
#ifndef FASTEST
|
||||||
local block_state deflate_slow OF((deflate_state *s, int flush));
|
local block_state deflate_slow OF((deflate_state *s, int flush));
|
||||||
#endif
|
#endif
|
||||||
|
local block_state deflate_rle OF((deflate_state *s, int flush));
|
||||||
|
local block_state deflate_huff OF((deflate_state *s, int flush));
|
||||||
local void lm_init OF((deflate_state *s));
|
local void lm_init OF((deflate_state *s));
|
||||||
local void putShortMSB OF((deflate_state *s, uInt b));
|
local void putShortMSB OF((deflate_state *s, uInt b));
|
||||||
local void flush_pending OF((z_streamp strm));
|
local void flush_pending OF((z_streamp strm));
|
||||||
local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
|
local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
|
||||||
#ifndef FASTEST
|
|
||||||
#ifdef ASMV
|
#ifdef ASMV
|
||||||
void match_init OF((void)); /* asm code initialization */
|
void match_init OF((void)); /* asm code initialization */
|
||||||
uInt longest_match OF((deflate_state *s, IPos cur_match));
|
uInt longest_match OF((deflate_state *s, IPos cur_match));
|
||||||
#else
|
#else
|
||||||
local uInt longest_match OF((deflate_state *s, IPos cur_match));
|
local uInt longest_match OF((deflate_state *s, IPos cur_match));
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
local void check_match OF((deflate_state *s, IPos start, IPos match,
|
local void check_match OF((deflate_state *s, IPos start, IPos match,
|
||||||
|
@ -110,11 +109,6 @@ local void check_match OF((deflate_state *s, IPos start, IPos match,
|
||||||
#endif
|
#endif
|
||||||
/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
|
/* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
|
||||||
|
|
||||||
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
|
|
||||||
/* Minimum amount of lookahead, except at the end of the input file.
|
|
||||||
* See deflate.c for comments about the MIN_MATCH+1.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Values for max_lazy_match, good_match and max_chain_length, depending on
|
/* Values for max_lazy_match, good_match and max_chain_length, depending on
|
||||||
* the desired pack level (0..9). The values given below have been tuned to
|
* the desired pack level (0..9). The values given below have been tuned to
|
||||||
* exclude worst case performance for pathological files. Better values may be
|
* exclude worst case performance for pathological files. Better values may be
|
||||||
|
@ -288,6 +282,8 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||||
s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
|
s->prev = (Posf *) ZALLOC(strm, s->w_size, sizeof(Pos));
|
||||||
s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
|
s->head = (Posf *) ZALLOC(strm, s->hash_size, sizeof(Pos));
|
||||||
|
|
||||||
|
s->high_water = 0; /* nothing written to s->window yet */
|
||||||
|
|
||||||
s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
|
s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */
|
||||||
|
|
||||||
overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
|
overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2);
|
||||||
|
@ -332,8 +328,8 @@ int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
|
||||||
strm->adler = adler32(strm->adler, dictionary, dictLength);
|
strm->adler = adler32(strm->adler, dictionary, dictLength);
|
||||||
|
|
||||||
if (length < MIN_MATCH) return Z_OK;
|
if (length < MIN_MATCH) return Z_OK;
|
||||||
if (length > MAX_DIST(s)) {
|
if (length > s->w_size) {
|
||||||
length = MAX_DIST(s);
|
length = s->w_size;
|
||||||
dictionary += dictLength - length; /* use the tail of the dictionary */
|
dictionary += dictLength - length; /* use the tail of the dictionary */
|
||||||
}
|
}
|
||||||
zmemcpy(s->window, dictionary, length);
|
zmemcpy(s->window, dictionary, length);
|
||||||
|
@ -435,9 +431,10 @@ int ZEXPORT deflateParams(strm, level, strategy)
|
||||||
}
|
}
|
||||||
func = configuration_table[s->level].func;
|
func = configuration_table[s->level].func;
|
||||||
|
|
||||||
if (func != configuration_table[level].func && strm->total_in != 0) {
|
if ((strategy != s->strategy || func != configuration_table[level].func) &&
|
||||||
|
strm->total_in != 0) {
|
||||||
/* Flush the last buffer: */
|
/* Flush the last buffer: */
|
||||||
err = deflate(strm, Z_PARTIAL_FLUSH);
|
err = deflate(strm, Z_BLOCK);
|
||||||
}
|
}
|
||||||
if (s->level != level) {
|
if (s->level != level) {
|
||||||
s->level = level;
|
s->level = level;
|
||||||
|
@ -481,33 +478,66 @@ int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain)
|
||||||
* resulting from using fixed blocks instead of stored blocks, which deflate
|
* resulting from using fixed blocks instead of stored blocks, which deflate
|
||||||
* can emit on compressed data for some combinations of the parameters.
|
* can emit on compressed data for some combinations of the parameters.
|
||||||
*
|
*
|
||||||
* This function could be more sophisticated to provide closer upper bounds
|
* This function could be more sophisticated to provide closer upper bounds for
|
||||||
* for every combination of windowBits and memLevel, as well as wrap.
|
* every combination of windowBits and memLevel. But even the conservative
|
||||||
* But even the conservative upper bound of about 14% expansion does not
|
* upper bound of about 14% expansion does not seem onerous for output buffer
|
||||||
* seem onerous for output buffer allocation.
|
* allocation.
|
||||||
*/
|
*/
|
||||||
uLong ZEXPORT deflateBound(strm, sourceLen)
|
uLong ZEXPORT deflateBound(strm, sourceLen)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
uLong sourceLen;
|
uLong sourceLen;
|
||||||
{
|
{
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
uLong destLen;
|
uLong complen, wraplen;
|
||||||
|
Bytef *str;
|
||||||
|
|
||||||
/* conservative upper bound */
|
/* conservative upper bound for compressed data */
|
||||||
destLen = sourceLen +
|
complen = sourceLen +
|
||||||
((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11;
|
((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 5;
|
||||||
|
|
||||||
/* if can't get parameters, return conservative bound */
|
/* if can't get parameters, return conservative bound plus zlib wrapper */
|
||||||
if (strm == Z_NULL || strm->state == Z_NULL)
|
if (strm == Z_NULL || strm->state == Z_NULL)
|
||||||
return destLen;
|
return complen + 6;
|
||||||
|
|
||||||
|
/* compute wrapper length */
|
||||||
|
s = strm->state;
|
||||||
|
switch (s->wrap) {
|
||||||
|
case 0: /* raw deflate */
|
||||||
|
wraplen = 0;
|
||||||
|
break;
|
||||||
|
case 1: /* zlib wrapper */
|
||||||
|
wraplen = 6 + (s->strstart ? 4 : 0);
|
||||||
|
break;
|
||||||
|
case 2: /* gzip wrapper */
|
||||||
|
wraplen = 18;
|
||||||
|
if (s->gzhead != Z_NULL) { /* user-supplied gzip header */
|
||||||
|
if (s->gzhead->extra != Z_NULL)
|
||||||
|
wraplen += 2 + s->gzhead->extra_len;
|
||||||
|
str = s->gzhead->name;
|
||||||
|
if (str != Z_NULL)
|
||||||
|
do {
|
||||||
|
wraplen++;
|
||||||
|
} while (*str++);
|
||||||
|
str = s->gzhead->comment;
|
||||||
|
if (str != Z_NULL)
|
||||||
|
do {
|
||||||
|
wraplen++;
|
||||||
|
} while (*str++);
|
||||||
|
if (s->gzhead->hcrc)
|
||||||
|
wraplen += 2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default: /* for compiler happiness */
|
||||||
|
wraplen = 6;
|
||||||
|
}
|
||||||
|
|
||||||
/* if not default parameters, return conservative bound */
|
/* if not default parameters, return conservative bound */
|
||||||
s = strm->state;
|
|
||||||
if (s->w_bits != 15 || s->hash_bits != 8 + 7)
|
if (s->w_bits != 15 || s->hash_bits != 8 + 7)
|
||||||
return destLen;
|
return complen + wraplen;
|
||||||
|
|
||||||
/* default settings: return tight bound for that case */
|
/* default settings: return tight bound for that case */
|
||||||
return compressBound(sourceLen);
|
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
||||||
|
(sourceLen >> 25) + 13 - 6 + wraplen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
|
@ -557,7 +587,7 @@ int ZEXPORT deflate (strm, flush)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
|
|
||||||
if (strm == Z_NULL || strm->state == Z_NULL ||
|
if (strm == Z_NULL || strm->state == Z_NULL ||
|
||||||
flush > Z_FINISH || flush < 0) {
|
flush > Z_BLOCK || flush < 0) {
|
||||||
return Z_STREAM_ERROR;
|
return Z_STREAM_ERROR;
|
||||||
}
|
}
|
||||||
s = strm->state;
|
s = strm->state;
|
||||||
|
@ -581,7 +611,7 @@ int ZEXPORT deflate (strm, flush)
|
||||||
put_byte(s, 31);
|
put_byte(s, 31);
|
||||||
put_byte(s, 139);
|
put_byte(s, 139);
|
||||||
put_byte(s, 8);
|
put_byte(s, 8);
|
||||||
if (s->gzhead == NULL) {
|
if (s->gzhead == Z_NULL) {
|
||||||
put_byte(s, 0);
|
put_byte(s, 0);
|
||||||
put_byte(s, 0);
|
put_byte(s, 0);
|
||||||
put_byte(s, 0);
|
put_byte(s, 0);
|
||||||
|
@ -608,7 +638,7 @@ int ZEXPORT deflate (strm, flush)
|
||||||
(s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
|
(s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ?
|
||||||
4 : 0));
|
4 : 0));
|
||||||
put_byte(s, s->gzhead->os & 0xff);
|
put_byte(s, s->gzhead->os & 0xff);
|
||||||
if (s->gzhead->extra != NULL) {
|
if (s->gzhead->extra != Z_NULL) {
|
||||||
put_byte(s, s->gzhead->extra_len & 0xff);
|
put_byte(s, s->gzhead->extra_len & 0xff);
|
||||||
put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
|
put_byte(s, (s->gzhead->extra_len >> 8) & 0xff);
|
||||||
}
|
}
|
||||||
|
@ -650,7 +680,7 @@ int ZEXPORT deflate (strm, flush)
|
||||||
}
|
}
|
||||||
#ifdef GZIP
|
#ifdef GZIP
|
||||||
if (s->status == EXTRA_STATE) {
|
if (s->status == EXTRA_STATE) {
|
||||||
if (s->gzhead->extra != NULL) {
|
if (s->gzhead->extra != Z_NULL) {
|
||||||
uInt beg = s->pending; /* start of bytes to update crc */
|
uInt beg = s->pending; /* start of bytes to update crc */
|
||||||
|
|
||||||
while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
|
while (s->gzindex < (s->gzhead->extra_len & 0xffff)) {
|
||||||
|
@ -678,7 +708,7 @@ int ZEXPORT deflate (strm, flush)
|
||||||
s->status = NAME_STATE;
|
s->status = NAME_STATE;
|
||||||
}
|
}
|
||||||
if (s->status == NAME_STATE) {
|
if (s->status == NAME_STATE) {
|
||||||
if (s->gzhead->name != NULL) {
|
if (s->gzhead->name != Z_NULL) {
|
||||||
uInt beg = s->pending; /* start of bytes to update crc */
|
uInt beg = s->pending; /* start of bytes to update crc */
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
|
@ -709,7 +739,7 @@ int ZEXPORT deflate (strm, flush)
|
||||||
s->status = COMMENT_STATE;
|
s->status = COMMENT_STATE;
|
||||||
}
|
}
|
||||||
if (s->status == COMMENT_STATE) {
|
if (s->status == COMMENT_STATE) {
|
||||||
if (s->gzhead->comment != NULL) {
|
if (s->gzhead->comment != Z_NULL) {
|
||||||
uInt beg = s->pending; /* start of bytes to update crc */
|
uInt beg = s->pending; /* start of bytes to update crc */
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
|
@ -787,7 +817,9 @@ int ZEXPORT deflate (strm, flush)
|
||||||
(flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
|
(flush != Z_NO_FLUSH && s->status != FINISH_STATE)) {
|
||||||
block_state bstate;
|
block_state bstate;
|
||||||
|
|
||||||
bstate = (*(configuration_table[s->level].func))(s, flush);
|
bstate = s->strategy == Z_HUFFMAN_ONLY ? deflate_huff(s, flush) :
|
||||||
|
(s->strategy == Z_RLE ? deflate_rle(s, flush) :
|
||||||
|
(*(configuration_table[s->level].func))(s, flush));
|
||||||
|
|
||||||
if (bstate == finish_started || bstate == finish_done) {
|
if (bstate == finish_started || bstate == finish_done) {
|
||||||
s->status = FINISH_STATE;
|
s->status = FINISH_STATE;
|
||||||
|
@ -808,13 +840,17 @@ int ZEXPORT deflate (strm, flush)
|
||||||
if (bstate == block_done) {
|
if (bstate == block_done) {
|
||||||
if (flush == Z_PARTIAL_FLUSH) {
|
if (flush == Z_PARTIAL_FLUSH) {
|
||||||
_tr_align(s);
|
_tr_align(s);
|
||||||
} else { /* FULL_FLUSH or SYNC_FLUSH */
|
} else if (flush != Z_BLOCK) { /* FULL_FLUSH or SYNC_FLUSH */
|
||||||
_tr_stored_block(s, (char*)0, 0L, 0);
|
_tr_stored_block(s, (char*)0, 0L, 0);
|
||||||
/* For a full flush, this empty block will be recognized
|
/* For a full flush, this empty block will be recognized
|
||||||
* as a special marker by inflate_sync().
|
* as a special marker by inflate_sync().
|
||||||
*/
|
*/
|
||||||
if (flush == Z_FULL_FLUSH) {
|
if (flush == Z_FULL_FLUSH) {
|
||||||
CLEAR_HASH(s); /* forget history */
|
CLEAR_HASH(s); /* forget history */
|
||||||
|
if (s->lookahead == 0) {
|
||||||
|
s->strstart = 0;
|
||||||
|
s->block_start = 0L;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flush_pending(strm);
|
flush_pending(strm);
|
||||||
|
@ -1167,12 +1203,13 @@ local uInt longest_match(s, cur_match)
|
||||||
return s->lookahead;
|
return s->lookahead;
|
||||||
}
|
}
|
||||||
#endif /* ASMV */
|
#endif /* ASMV */
|
||||||
#endif /* FASTEST */
|
|
||||||
|
#else /* FASTEST */
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------
|
/* ---------------------------------------------------------------------------
|
||||||
* Optimized version for level == 1 or strategy == Z_RLE only
|
* Optimized version for FASTEST only
|
||||||
*/
|
*/
|
||||||
local uInt longest_match_fast(s, cur_match)
|
local uInt longest_match(s, cur_match)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
IPos cur_match; /* current match */
|
IPos cur_match; /* current match */
|
||||||
{
|
{
|
||||||
|
@ -1225,6 +1262,8 @@ local uInt longest_match_fast(s, cur_match)
|
||||||
return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
|
return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* FASTEST */
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Check that the match at match_start is indeed a match.
|
* Check that the match at match_start is indeed a match.
|
||||||
|
@ -1303,7 +1342,6 @@ local void fill_window(s)
|
||||||
later. (Using level 0 permanently is not an optimal usage of
|
later. (Using level 0 permanently is not an optimal usage of
|
||||||
zlib, so we don't care about this pathological case.)
|
zlib, so we don't care about this pathological case.)
|
||||||
*/
|
*/
|
||||||
/* %%% avoid this when Z_RLE */
|
|
||||||
n = s->hash_size;
|
n = s->hash_size;
|
||||||
p = &s->head[n];
|
p = &s->head[n];
|
||||||
do {
|
do {
|
||||||
|
@ -1355,27 +1393,61 @@ local void fill_window(s)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
} while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
|
} while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0);
|
||||||
|
|
||||||
|
/* If the WIN_INIT bytes after the end of the current data have never been
|
||||||
|
* written, then zero those bytes in order to avoid memory check reports of
|
||||||
|
* the use of uninitialized (or uninitialised as Julian writes) bytes by
|
||||||
|
* the longest match routines. Update the high water mark for the next
|
||||||
|
* time through here. WIN_INIT is set to MAX_MATCH since the longest match
|
||||||
|
* routines allow scanning to strstart + MAX_MATCH, ignoring lookahead.
|
||||||
|
*/
|
||||||
|
if (s->high_water < s->window_size) {
|
||||||
|
ulg curr = s->strstart + (ulg)(s->lookahead);
|
||||||
|
ulg init;
|
||||||
|
|
||||||
|
if (s->high_water < curr) {
|
||||||
|
/* Previous high water mark below current data -- zero WIN_INIT
|
||||||
|
* bytes or up to end of window, whichever is less.
|
||||||
|
*/
|
||||||
|
init = s->window_size - curr;
|
||||||
|
if (init > WIN_INIT)
|
||||||
|
init = WIN_INIT;
|
||||||
|
zmemzero(s->window + curr, (unsigned)init);
|
||||||
|
s->high_water = curr + init;
|
||||||
|
}
|
||||||
|
else if (s->high_water < (ulg)curr + WIN_INIT) {
|
||||||
|
/* High water mark at or above current data, but below current data
|
||||||
|
* plus WIN_INIT -- zero out to current data plus WIN_INIT, or up
|
||||||
|
* to end of window, whichever is less.
|
||||||
|
*/
|
||||||
|
init = (ulg)curr + WIN_INIT - s->high_water;
|
||||||
|
if (init > s->window_size - s->high_water)
|
||||||
|
init = s->window_size - s->high_water;
|
||||||
|
zmemzero(s->window + s->high_water, (unsigned)init);
|
||||||
|
s->high_water += init;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Flush the current block, with given end-of-file flag.
|
* Flush the current block, with given end-of-file flag.
|
||||||
* IN assertion: strstart is set to the end of the current match.
|
* IN assertion: strstart is set to the end of the current match.
|
||||||
*/
|
*/
|
||||||
#define FLUSH_BLOCK_ONLY(s, eof) { \
|
#define FLUSH_BLOCK_ONLY(s, last) { \
|
||||||
_tr_flush_block(s, (s->block_start >= 0L ? \
|
_tr_flush_block(s, (s->block_start >= 0L ? \
|
||||||
(charf *)&s->window[(unsigned)s->block_start] : \
|
(charf *)&s->window[(unsigned)s->block_start] : \
|
||||||
(charf *)Z_NULL), \
|
(charf *)Z_NULL), \
|
||||||
(ulg)((long)s->strstart - s->block_start), \
|
(ulg)((long)s->strstart - s->block_start), \
|
||||||
(eof)); \
|
(last)); \
|
||||||
s->block_start = s->strstart; \
|
s->block_start = s->strstart; \
|
||||||
flush_pending(s->strm); \
|
flush_pending(s->strm); \
|
||||||
Tracev((stderr,"[FLUSH]")); \
|
Tracev((stderr,"[FLUSH]")); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Same but force premature exit if necessary. */
|
/* Same but force premature exit if necessary. */
|
||||||
#define FLUSH_BLOCK(s, eof) { \
|
#define FLUSH_BLOCK(s, last) { \
|
||||||
FLUSH_BLOCK_ONLY(s, eof); \
|
FLUSH_BLOCK_ONLY(s, last); \
|
||||||
if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \
|
if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
|
@ -1449,7 +1521,7 @@ local block_state deflate_fast(s, flush)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
int flush;
|
int flush;
|
||||||
{
|
{
|
||||||
IPos hash_head = NIL; /* head of the hash chain */
|
IPos hash_head; /* head of the hash chain */
|
||||||
int bflush; /* set if current block must be flushed */
|
int bflush; /* set if current block must be flushed */
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -1469,6 +1541,7 @@ local block_state deflate_fast(s, flush)
|
||||||
/* Insert the string window[strstart .. strstart+2] in the
|
/* Insert the string window[strstart .. strstart+2] in the
|
||||||
* dictionary, and set hash_head to the head of the hash chain:
|
* dictionary, and set hash_head to the head of the hash chain:
|
||||||
*/
|
*/
|
||||||
|
hash_head = NIL;
|
||||||
if (s->lookahead >= MIN_MATCH) {
|
if (s->lookahead >= MIN_MATCH) {
|
||||||
INSERT_STRING(s, s->strstart, hash_head);
|
INSERT_STRING(s, s->strstart, hash_head);
|
||||||
}
|
}
|
||||||
|
@ -1481,19 +1554,8 @@ local block_state deflate_fast(s, flush)
|
||||||
* of window index 0 (in particular we have to avoid a match
|
* of window index 0 (in particular we have to avoid a match
|
||||||
* of the string with itself at the start of the input file).
|
* of the string with itself at the start of the input file).
|
||||||
*/
|
*/
|
||||||
#ifdef FASTEST
|
s->match_length = longest_match (s, hash_head);
|
||||||
if ((s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) ||
|
/* longest_match() sets match_start */
|
||||||
(s->strategy == Z_RLE && s->strstart - hash_head == 1)) {
|
|
||||||
s->match_length = longest_match_fast (s, hash_head);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
|
|
||||||
s->match_length = longest_match (s, hash_head);
|
|
||||||
} else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
|
|
||||||
s->match_length = longest_match_fast (s, hash_head);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/* longest_match() or longest_match_fast() sets match_start */
|
|
||||||
}
|
}
|
||||||
if (s->match_length >= MIN_MATCH) {
|
if (s->match_length >= MIN_MATCH) {
|
||||||
check_match(s, s->strstart, s->match_start, s->match_length);
|
check_match(s, s->strstart, s->match_start, s->match_length);
|
||||||
|
@ -1555,7 +1617,7 @@ local block_state deflate_slow(s, flush)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
int flush;
|
int flush;
|
||||||
{
|
{
|
||||||
IPos hash_head = NIL; /* head of hash chain */
|
IPos hash_head; /* head of hash chain */
|
||||||
int bflush; /* set if current block must be flushed */
|
int bflush; /* set if current block must be flushed */
|
||||||
|
|
||||||
/* Process the input block. */
|
/* Process the input block. */
|
||||||
|
@ -1576,6 +1638,7 @@ local block_state deflate_slow(s, flush)
|
||||||
/* Insert the string window[strstart .. strstart+2] in the
|
/* Insert the string window[strstart .. strstart+2] in the
|
||||||
* dictionary, and set hash_head to the head of the hash chain:
|
* dictionary, and set hash_head to the head of the hash chain:
|
||||||
*/
|
*/
|
||||||
|
hash_head = NIL;
|
||||||
if (s->lookahead >= MIN_MATCH) {
|
if (s->lookahead >= MIN_MATCH) {
|
||||||
INSERT_STRING(s, s->strstart, hash_head);
|
INSERT_STRING(s, s->strstart, hash_head);
|
||||||
}
|
}
|
||||||
|
@ -1591,12 +1654,8 @@ local block_state deflate_slow(s, flush)
|
||||||
* of window index 0 (in particular we have to avoid a match
|
* of window index 0 (in particular we have to avoid a match
|
||||||
* of the string with itself at the start of the input file).
|
* of the string with itself at the start of the input file).
|
||||||
*/
|
*/
|
||||||
if (s->strategy != Z_HUFFMAN_ONLY && s->strategy != Z_RLE) {
|
s->match_length = longest_match (s, hash_head);
|
||||||
s->match_length = longest_match (s, hash_head);
|
/* longest_match() sets match_start */
|
||||||
} else if (s->strategy == Z_RLE && s->strstart - hash_head == 1) {
|
|
||||||
s->match_length = longest_match_fast (s, hash_head);
|
|
||||||
}
|
|
||||||
/* longest_match() or longest_match_fast() sets match_start */
|
|
||||||
|
|
||||||
if (s->match_length <= 5 && (s->strategy == Z_FILTERED
|
if (s->match_length <= 5 && (s->strategy == Z_FILTERED
|
||||||
#if TOO_FAR <= 32767
|
#if TOO_FAR <= 32767
|
||||||
|
@ -1674,7 +1733,6 @@ local block_state deflate_slow(s, flush)
|
||||||
}
|
}
|
||||||
#endif /* FASTEST */
|
#endif /* FASTEST */
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* For Z_RLE, simply look for runs of bytes, generate matches only of distance
|
* For Z_RLE, simply look for runs of bytes, generate matches only of distance
|
||||||
* one. Do not maintain a hash table. (It will be regenerated if this run of
|
* one. Do not maintain a hash table. (It will be regenerated if this run of
|
||||||
|
@ -1684,11 +1742,9 @@ local block_state deflate_rle(s, flush)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
int flush;
|
int flush;
|
||||||
{
|
{
|
||||||
int bflush; /* set if current block must be flushed */
|
int bflush; /* set if current block must be flushed */
|
||||||
uInt run; /* length of run */
|
uInt prev; /* byte at distance one to match */
|
||||||
uInt max; /* maximum length of run */
|
Bytef *scan, *strend; /* scan goes up to strend for length of run */
|
||||||
uInt prev; /* byte at distance one to match */
|
|
||||||
Bytef *scan; /* scan for end of run */
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* Make sure that we always have enough lookahead, except
|
/* Make sure that we always have enough lookahead, except
|
||||||
|
@ -1704,23 +1760,33 @@ local block_state deflate_rle(s, flush)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See how many times the previous byte repeats */
|
/* See how many times the previous byte repeats */
|
||||||
run = 0;
|
s->match_length = 0;
|
||||||
if (s->strstart > 0) { /* if there is a previous byte, that is */
|
if (s->lookahead >= MIN_MATCH && s->strstart > 0) {
|
||||||
max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH;
|
|
||||||
scan = s->window + s->strstart - 1;
|
scan = s->window + s->strstart - 1;
|
||||||
prev = *scan++;
|
prev = *scan;
|
||||||
do {
|
if (prev == *++scan && prev == *++scan && prev == *++scan) {
|
||||||
if (*scan++ != prev)
|
strend = s->window + s->strstart + MAX_MATCH;
|
||||||
break;
|
do {
|
||||||
} while (++run < max);
|
} while (prev == *++scan && prev == *++scan &&
|
||||||
|
prev == *++scan && prev == *++scan &&
|
||||||
|
prev == *++scan && prev == *++scan &&
|
||||||
|
prev == *++scan && prev == *++scan &&
|
||||||
|
scan < strend);
|
||||||
|
s->match_length = MAX_MATCH - (int)(strend - scan);
|
||||||
|
if (s->match_length > s->lookahead)
|
||||||
|
s->match_length = s->lookahead;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Emit match if have run of MIN_MATCH or longer, else emit literal */
|
/* Emit match if have run of MIN_MATCH or longer, else emit literal */
|
||||||
if (run >= MIN_MATCH) {
|
if (s->match_length >= MIN_MATCH) {
|
||||||
check_match(s, s->strstart, s->strstart - 1, run);
|
check_match(s, s->strstart, s->strstart - 1, s->match_length);
|
||||||
_tr_tally_dist(s, 1, run - MIN_MATCH, bflush);
|
|
||||||
s->lookahead -= run;
|
_tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush);
|
||||||
s->strstart += run;
|
|
||||||
|
s->lookahead -= s->match_length;
|
||||||
|
s->strstart += s->match_length;
|
||||||
|
s->match_length = 0;
|
||||||
} else {
|
} else {
|
||||||
/* No match, output a literal byte */
|
/* No match, output a literal byte */
|
||||||
Tracevv((stderr,"%c", s->window[s->strstart]));
|
Tracevv((stderr,"%c", s->window[s->strstart]));
|
||||||
|
@ -1733,4 +1799,36 @@ local block_state deflate_rle(s, flush)
|
||||||
FLUSH_BLOCK(s, flush == Z_FINISH);
|
FLUSH_BLOCK(s, flush == Z_FINISH);
|
||||||
return flush == Z_FINISH ? finish_done : block_done;
|
return flush == Z_FINISH ? finish_done : block_done;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
/* ===========================================================================
|
||||||
|
* For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.
|
||||||
|
* (It will be regenerated if this run of deflate switches away from Huffman.)
|
||||||
|
*/
|
||||||
|
local block_state deflate_huff(s, flush)
|
||||||
|
deflate_state *s;
|
||||||
|
int flush;
|
||||||
|
{
|
||||||
|
int bflush; /* set if current block must be flushed */
|
||||||
|
|
||||||
|
for (;;) {
|
||||||
|
/* Make sure that we have a literal to write. */
|
||||||
|
if (s->lookahead == 0) {
|
||||||
|
fill_window(s);
|
||||||
|
if (s->lookahead == 0) {
|
||||||
|
if (flush == Z_NO_FLUSH)
|
||||||
|
return need_more;
|
||||||
|
break; /* flush the current block */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Output a literal byte */
|
||||||
|
s->match_length = 0;
|
||||||
|
Tracevv((stderr,"%c", s->window[s->strstart]));
|
||||||
|
_tr_tally_lit (s, s->window[s->strstart], bflush);
|
||||||
|
s->lookahead--;
|
||||||
|
s->strstart++;
|
||||||
|
if (bflush) FLUSH_BLOCK(s, 0);
|
||||||
|
}
|
||||||
|
FLUSH_BLOCK(s, flush == Z_FINISH);
|
||||||
|
return flush == Z_FINISH ? finish_done : block_done;
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* deflate.h -- internal compression state
|
/* deflate.h -- internal compression state
|
||||||
* Copyright (C) 1995-2004 Jean-loup Gailly
|
* Copyright (C) 1995-2010 Jean-loup Gailly
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -260,6 +260,13 @@ typedef struct internal_state {
|
||||||
* are always zero.
|
* are always zero.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
ulg high_water;
|
||||||
|
/* High water mark offset in window for initialized bytes -- bytes above
|
||||||
|
* this are set to zero in order to avoid memory check warnings when
|
||||||
|
* longest match routines access bytes past the input. This is then
|
||||||
|
* updated to the new high water mark.
|
||||||
|
*/
|
||||||
|
|
||||||
} FAR deflate_state;
|
} FAR deflate_state;
|
||||||
|
|
||||||
/* Output a byte on the stream.
|
/* Output a byte on the stream.
|
||||||
|
@ -278,14 +285,18 @@ typedef struct internal_state {
|
||||||
* distances are limited to MAX_DIST instead of WSIZE.
|
* distances are limited to MAX_DIST instead of WSIZE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define WIN_INIT MAX_MATCH
|
||||||
|
/* Number of bytes after end of data in window to initialize in order to avoid
|
||||||
|
memory checker errors from longest match routines */
|
||||||
|
|
||||||
/* in trees.c */
|
/* in trees.c */
|
||||||
void _tr_init OF((deflate_state *s));
|
void ZLIB_INTERNAL _tr_init OF((deflate_state *s));
|
||||||
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
|
int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
|
||||||
void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf,
|
||||||
int eof));
|
ulg stored_len, int last));
|
||||||
void _tr_align OF((deflate_state *s));
|
void ZLIB_INTERNAL _tr_align OF((deflate_state *s));
|
||||||
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf,
|
||||||
int eof));
|
ulg stored_len, int last));
|
||||||
|
|
||||||
#define d_code(dist) \
|
#define d_code(dist) \
|
||||||
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
|
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
|
||||||
|
@ -298,11 +309,11 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
||||||
/* Inline versions of _tr_tally for speed: */
|
/* Inline versions of _tr_tally for speed: */
|
||||||
|
|
||||||
#if defined(GEN_TREES_H) || !defined(STDC)
|
#if defined(GEN_TREES_H) || !defined(STDC)
|
||||||
extern uch _length_code[];
|
extern uch ZLIB_INTERNAL _length_code[];
|
||||||
extern uch _dist_code[];
|
extern uch ZLIB_INTERNAL _dist_code[];
|
||||||
#else
|
#else
|
||||||
extern const uch _length_code[];
|
extern const uch ZLIB_INTERNAL _length_code[];
|
||||||
extern const uch _dist_code[];
|
extern const uch ZLIB_INTERNAL _dist_code[];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# define _tr_tally_lit(s, c, flush) \
|
# define _tr_tally_lit(s, c, flush) \
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/* example.c -- usage example of the zlib compression library
|
/* example.c -- usage example of the zlib compression library
|
||||||
* Copyright (C) 1995-2004 Jean-loup Gailly.
|
* Copyright (C) 1995-2006 Jean-loup Gailly.
|
||||||
* 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$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef STDC
|
#ifdef STDC
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* infback.c -- inflate using a call-back interface
|
/* infback.c -- inflate using a call-back interface
|
||||||
* Copyright (C) 1995-2005 Mark Adler
|
* Copyright (C) 1995-2009 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ int stream_size;
|
||||||
state->wbits = windowBits;
|
state->wbits = windowBits;
|
||||||
state->wsize = 1U << windowBits;
|
state->wsize = 1U << windowBits;
|
||||||
state->window = window;
|
state->window = window;
|
||||||
state->write = 0;
|
state->wnext = 0;
|
||||||
state->whave = 0;
|
state->whave = 0;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ void FAR *out_desc;
|
||||||
unsigned bits; /* bits in bit buffer */
|
unsigned bits; /* bits in bit buffer */
|
||||||
unsigned copy; /* number of stored or match bytes to copy */
|
unsigned copy; /* number of stored or match bytes to copy */
|
||||||
unsigned char FAR *from; /* where to copy match bytes from */
|
unsigned char FAR *from; /* where to copy match bytes from */
|
||||||
code this; /* current decoding table entry */
|
code here; /* current decoding table entry */
|
||||||
code last; /* parent table entry */
|
code last; /* parent table entry */
|
||||||
unsigned len; /* length to copy for repeats, bits to drop */
|
unsigned len; /* length to copy for repeats, bits to drop */
|
||||||
int ret; /* return code */
|
int ret; /* return code */
|
||||||
|
@ -389,19 +389,19 @@ void FAR *out_desc;
|
||||||
state->have = 0;
|
state->have = 0;
|
||||||
while (state->have < state->nlen + state->ndist) {
|
while (state->have < state->nlen + state->ndist) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[BITS(state->lenbits)];
|
here = state->lencode[BITS(state->lenbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if (this.val < 16) {
|
if (here.val < 16) {
|
||||||
NEEDBITS(this.bits);
|
NEEDBITS(here.bits);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
state->lens[state->have++] = this.val;
|
state->lens[state->have++] = here.val;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this.val == 16) {
|
if (here.val == 16) {
|
||||||
NEEDBITS(this.bits + 2);
|
NEEDBITS(here.bits + 2);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
if (state->have == 0) {
|
if (state->have == 0) {
|
||||||
strm->msg = (char *)"invalid bit length repeat";
|
strm->msg = (char *)"invalid bit length repeat";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
|
@ -411,16 +411,16 @@ void FAR *out_desc;
|
||||||
copy = 3 + BITS(2);
|
copy = 3 + BITS(2);
|
||||||
DROPBITS(2);
|
DROPBITS(2);
|
||||||
}
|
}
|
||||||
else if (this.val == 17) {
|
else if (here.val == 17) {
|
||||||
NEEDBITS(this.bits + 3);
|
NEEDBITS(here.bits + 3);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
len = 0;
|
len = 0;
|
||||||
copy = 3 + BITS(3);
|
copy = 3 + BITS(3);
|
||||||
DROPBITS(3);
|
DROPBITS(3);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NEEDBITS(this.bits + 7);
|
NEEDBITS(here.bits + 7);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
len = 0;
|
len = 0;
|
||||||
copy = 11 + BITS(7);
|
copy = 11 + BITS(7);
|
||||||
DROPBITS(7);
|
DROPBITS(7);
|
||||||
|
@ -438,7 +438,16 @@ void FAR *out_desc;
|
||||||
/* handle error breaks in while */
|
/* handle error breaks in while */
|
||||||
if (state->mode == BAD) break;
|
if (state->mode == BAD) break;
|
||||||
|
|
||||||
/* build code tables */
|
/* check for end-of-block code (better have one) */
|
||||||
|
if (state->lens[256] == 0) {
|
||||||
|
strm->msg = (char *)"invalid code -- missing end-of-block";
|
||||||
|
state->mode = BAD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* build code tables -- note: do not change the lenbits or distbits
|
||||||
|
values here (9 and 6) without reading the comments in inftrees.h
|
||||||
|
concerning the ENOUGH constants, which depend on those values */
|
||||||
state->next = state->codes;
|
state->next = state->codes;
|
||||||
state->lencode = (code const FAR *)(state->next);
|
state->lencode = (code const FAR *)(state->next);
|
||||||
state->lenbits = 9;
|
state->lenbits = 9;
|
||||||
|
@ -474,28 +483,28 @@ void FAR *out_desc;
|
||||||
|
|
||||||
/* get a literal, length, or end-of-block code */
|
/* get a literal, length, or end-of-block code */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[BITS(state->lenbits)];
|
here = state->lencode[BITS(state->lenbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if (this.op && (this.op & 0xf0) == 0) {
|
if (here.op && (here.op & 0xf0) == 0) {
|
||||||
last = this;
|
last = here;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[last.val +
|
here = state->lencode[last.val +
|
||||||
(BITS(last.bits + last.op) >> last.bits)];
|
(BITS(last.bits + last.op) >> last.bits)];
|
||||||
if ((unsigned)(last.bits + this.bits) <= bits) break;
|
if ((unsigned)(last.bits + here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
DROPBITS(last.bits);
|
DROPBITS(last.bits);
|
||||||
}
|
}
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
state->length = (unsigned)this.val;
|
state->length = (unsigned)here.val;
|
||||||
|
|
||||||
/* process literal */
|
/* process literal */
|
||||||
if (this.op == 0) {
|
if (here.op == 0) {
|
||||||
Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
|
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
||||||
"inflate: literal '%c'\n" :
|
"inflate: literal '%c'\n" :
|
||||||
"inflate: literal 0x%02x\n", this.val));
|
"inflate: literal 0x%02x\n", here.val));
|
||||||
ROOM();
|
ROOM();
|
||||||
*put++ = (unsigned char)(state->length);
|
*put++ = (unsigned char)(state->length);
|
||||||
left--;
|
left--;
|
||||||
|
@ -504,21 +513,21 @@ void FAR *out_desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* process end of block */
|
/* process end of block */
|
||||||
if (this.op & 32) {
|
if (here.op & 32) {
|
||||||
Tracevv((stderr, "inflate: end of block\n"));
|
Tracevv((stderr, "inflate: end of block\n"));
|
||||||
state->mode = TYPE;
|
state->mode = TYPE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* invalid code */
|
/* invalid code */
|
||||||
if (this.op & 64) {
|
if (here.op & 64) {
|
||||||
strm->msg = (char *)"invalid literal/length code";
|
strm->msg = (char *)"invalid literal/length code";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* length code -- get extra bits, if any */
|
/* length code -- get extra bits, if any */
|
||||||
state->extra = (unsigned)(this.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
if (state->extra != 0) {
|
if (state->extra != 0) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
state->length += BITS(state->extra);
|
state->length += BITS(state->extra);
|
||||||
|
@ -528,30 +537,30 @@ void FAR *out_desc;
|
||||||
|
|
||||||
/* get distance code */
|
/* get distance code */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->distcode[BITS(state->distbits)];
|
here = state->distcode[BITS(state->distbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if ((this.op & 0xf0) == 0) {
|
if ((here.op & 0xf0) == 0) {
|
||||||
last = this;
|
last = here;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->distcode[last.val +
|
here = state->distcode[last.val +
|
||||||
(BITS(last.bits + last.op) >> last.bits)];
|
(BITS(last.bits + last.op) >> last.bits)];
|
||||||
if ((unsigned)(last.bits + this.bits) <= bits) break;
|
if ((unsigned)(last.bits + here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
DROPBITS(last.bits);
|
DROPBITS(last.bits);
|
||||||
}
|
}
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
if (this.op & 64) {
|
if (here.op & 64) {
|
||||||
strm->msg = (char *)"invalid distance code";
|
strm->msg = (char *)"invalid distance code";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->offset = (unsigned)this.val;
|
state->offset = (unsigned)here.val;
|
||||||
|
|
||||||
/* get distance extra bits, if any */
|
/* get distance extra bits, if any */
|
||||||
state->extra = (unsigned)(this.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
if (state->extra != 0) {
|
if (state->extra != 0) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
state->offset += BITS(state->extra);
|
state->offset += BITS(state->extra);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* inffast.c -- fast decoding
|
/* inffast.c -- fast decoding
|
||||||
* Copyright (C) 1995-2004 Mark Adler
|
* Copyright (C) 1995-2008, 2010 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
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 inflate_fast(strm, start)
|
void ZLIB_INTERNAL inflate_fast(strm, start)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
unsigned start; /* inflate()'s starting value for strm->avail_out */
|
unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
{
|
{
|
||||||
|
@ -79,7 +79,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
#endif
|
#endif
|
||||||
unsigned wsize; /* window size or zero if not using window */
|
unsigned wsize; /* window size or zero if not using window */
|
||||||
unsigned whave; /* valid bytes in the window */
|
unsigned whave; /* valid bytes in the window */
|
||||||
unsigned write; /* window write index */
|
unsigned wnext; /* window write index */
|
||||||
unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
|
unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
|
||||||
unsigned long hold; /* local strm->hold */
|
unsigned long hold; /* local strm->hold */
|
||||||
unsigned bits; /* local strm->bits */
|
unsigned bits; /* local strm->bits */
|
||||||
|
@ -87,7 +87,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
code const FAR *dcode; /* local strm->distcode */
|
code const FAR *dcode; /* local strm->distcode */
|
||||||
unsigned lmask; /* mask for first level of length codes */
|
unsigned lmask; /* mask for first level of length codes */
|
||||||
unsigned dmask; /* mask for first level of distance codes */
|
unsigned dmask; /* mask for first level of distance codes */
|
||||||
code this; /* retrieved table entry */
|
code here; /* retrieved table entry */
|
||||||
unsigned op; /* code bits, operation, extra bits, or */
|
unsigned op; /* code bits, operation, extra bits, or */
|
||||||
/* window position, window bytes to copy */
|
/* window position, window bytes to copy */
|
||||||
unsigned len; /* match length, unused bytes */
|
unsigned len; /* match length, unused bytes */
|
||||||
|
@ -106,7 +106,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
#endif
|
#endif
|
||||||
wsize = state->wsize;
|
wsize = state->wsize;
|
||||||
whave = state->whave;
|
whave = state->whave;
|
||||||
write = state->write;
|
wnext = state->wnext;
|
||||||
window = state->window;
|
window = state->window;
|
||||||
hold = state->hold;
|
hold = state->hold;
|
||||||
bits = state->bits;
|
bits = state->bits;
|
||||||
|
@ -124,20 +124,20 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
hold += (unsigned long)(PUP(in)) << bits;
|
hold += (unsigned long)(PUP(in)) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
this = lcode[hold & lmask];
|
here = lcode[hold & lmask];
|
||||||
dolen:
|
dolen:
|
||||||
op = (unsigned)(this.bits);
|
op = (unsigned)(here.bits);
|
||||||
hold >>= op;
|
hold >>= op;
|
||||||
bits -= op;
|
bits -= op;
|
||||||
op = (unsigned)(this.op);
|
op = (unsigned)(here.op);
|
||||||
if (op == 0) { /* literal */
|
if (op == 0) { /* literal */
|
||||||
Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
|
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
||||||
"inflate: literal '%c'\n" :
|
"inflate: literal '%c'\n" :
|
||||||
"inflate: literal 0x%02x\n", this.val));
|
"inflate: literal 0x%02x\n", here.val));
|
||||||
PUP(out) = (unsigned char)(this.val);
|
PUP(out) = (unsigned char)(here.val);
|
||||||
}
|
}
|
||||||
else if (op & 16) { /* length base */
|
else if (op & 16) { /* length base */
|
||||||
len = (unsigned)(this.val);
|
len = (unsigned)(here.val);
|
||||||
op &= 15; /* number of extra bits */
|
op &= 15; /* number of extra bits */
|
||||||
if (op) {
|
if (op) {
|
||||||
if (bits < op) {
|
if (bits < op) {
|
||||||
|
@ -155,14 +155,14 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
hold += (unsigned long)(PUP(in)) << bits;
|
hold += (unsigned long)(PUP(in)) << bits;
|
||||||
bits += 8;
|
bits += 8;
|
||||||
}
|
}
|
||||||
this = dcode[hold & dmask];
|
here = dcode[hold & dmask];
|
||||||
dodist:
|
dodist:
|
||||||
op = (unsigned)(this.bits);
|
op = (unsigned)(here.bits);
|
||||||
hold >>= op;
|
hold >>= op;
|
||||||
bits -= op;
|
bits -= op;
|
||||||
op = (unsigned)(this.op);
|
op = (unsigned)(here.op);
|
||||||
if (op & 16) { /* distance base */
|
if (op & 16) { /* distance base */
|
||||||
dist = (unsigned)(this.val);
|
dist = (unsigned)(here.val);
|
||||||
op &= 15; /* number of extra bits */
|
op &= 15; /* number of extra bits */
|
||||||
if (bits < op) {
|
if (bits < op) {
|
||||||
hold += (unsigned long)(PUP(in)) << bits;
|
hold += (unsigned long)(PUP(in)) << bits;
|
||||||
|
@ -187,12 +187,34 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
if (dist > op) { /* see if copy from window */
|
if (dist > op) { /* see if copy from window */
|
||||||
op = dist - op; /* distance back in window */
|
op = dist - op; /* distance back in window */
|
||||||
if (op > whave) {
|
if (op > whave) {
|
||||||
strm->msg = (char *)"invalid distance too far back";
|
if (state->sane) {
|
||||||
state->mode = BAD;
|
strm->msg =
|
||||||
break;
|
(char *)"invalid distance too far back";
|
||||||
|
state->mode = BAD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||||
|
if (len <= op - whave) {
|
||||||
|
do {
|
||||||
|
PUP(out) = 0;
|
||||||
|
} while (--len);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
len -= op - whave;
|
||||||
|
do {
|
||||||
|
PUP(out) = 0;
|
||||||
|
} while (--op > whave);
|
||||||
|
if (op == 0) {
|
||||||
|
from = out - dist;
|
||||||
|
do {
|
||||||
|
PUP(out) = PUP(from);
|
||||||
|
} while (--len);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
from = window - OFF;
|
from = window - OFF;
|
||||||
if (write == 0) { /* very common case */
|
if (wnext == 0) { /* very common case */
|
||||||
from += wsize - op;
|
from += wsize - op;
|
||||||
if (op < len) { /* some from window */
|
if (op < len) { /* some from window */
|
||||||
len -= op;
|
len -= op;
|
||||||
|
@ -202,17 +224,17 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
from = out - dist; /* rest from output */
|
from = out - dist; /* rest from output */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (write < op) { /* wrap around window */
|
else if (wnext < op) { /* wrap around window */
|
||||||
from += wsize + write - op;
|
from += wsize + wnext - op;
|
||||||
op -= write;
|
op -= wnext;
|
||||||
if (op < len) { /* some from end of window */
|
if (op < len) { /* some from end of window */
|
||||||
len -= op;
|
len -= op;
|
||||||
do {
|
do {
|
||||||
PUP(out) = PUP(from);
|
PUP(out) = PUP(from);
|
||||||
} while (--op);
|
} while (--op);
|
||||||
from = window - OFF;
|
from = window - OFF;
|
||||||
if (write < len) { /* some from start of window */
|
if (wnext < len) { /* some from start of window */
|
||||||
op = write;
|
op = wnext;
|
||||||
len -= op;
|
len -= op;
|
||||||
do {
|
do {
|
||||||
PUP(out) = PUP(from);
|
PUP(out) = PUP(from);
|
||||||
|
@ -222,7 +244,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { /* contiguous in window */
|
else { /* contiguous in window */
|
||||||
from += write - op;
|
from += wnext - op;
|
||||||
if (op < len) { /* some from window */
|
if (op < len) { /* some from window */
|
||||||
len -= op;
|
len -= op;
|
||||||
do {
|
do {
|
||||||
|
@ -259,7 +281,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((op & 64) == 0) { /* 2nd level distance code */
|
else if ((op & 64) == 0) { /* 2nd level distance code */
|
||||||
this = dcode[this.val + (hold & ((1U << op) - 1))];
|
here = dcode[here.val + (hold & ((1U << op) - 1))];
|
||||||
goto dodist;
|
goto dodist;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -269,7 +291,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((op & 64) == 0) { /* 2nd level length code */
|
else if ((op & 64) == 0) { /* 2nd level length code */
|
||||||
this = lcode[this.val + (hold & ((1U << op) - 1))];
|
here = lcode[here.val + (hold & ((1U << op) - 1))];
|
||||||
goto dolen;
|
goto dolen;
|
||||||
}
|
}
|
||||||
else if (op & 32) { /* end-of-block */
|
else if (op & 32) { /* end-of-block */
|
||||||
|
@ -305,7 +327,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||||
inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
|
inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
|
||||||
- Using bit fields for code structure
|
- Using bit fields for code structure
|
||||||
- Different op definition to avoid & for extra bits (do & for table bits)
|
- Different op definition to avoid & for extra bits (do & for table bits)
|
||||||
- Three separate decoding do-loops for direct, window, and write == 0
|
- Three separate decoding do-loops for direct, window, and wnext == 0
|
||||||
- Special case for distance > 1 copies to do overlapped load and store copy
|
- Special case for distance > 1 copies to do overlapped load and store copy
|
||||||
- Explicit branch predictions (based on measured branch probabilities)
|
- Explicit branch predictions (based on measured branch probabilities)
|
||||||
- Deferring match copy and interspersed it with decoding subsequent codes
|
- Deferring match copy and interspersed it with decoding subsequent codes
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* inffast.h -- header to use inffast.c
|
/* inffast.h -- header to use inffast.c
|
||||||
* Copyright (C) 1995-2003 Mark Adler
|
* Copyright (C) 1995-2003, 2010 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -8,4 +8,4 @@
|
||||||
subject to change. Applications should only use zlib.h.
|
subject to change. Applications should only use zlib.h.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void inflate_fast OF((z_streamp strm, unsigned start));
|
void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start));
|
||||||
|
|
282
zlib/inflate.c
282
zlib/inflate.c
|
@ -1,5 +1,5 @@
|
||||||
/* inflate.c -- zlib decompression
|
/* inflate.c -- zlib decompression
|
||||||
* Copyright (C) 1995-2005 Mark Adler
|
* Copyright (C) 1995-2010 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
* - Rearrange window copies in inflate_fast() for speed and simplification
|
* - Rearrange window copies in inflate_fast() for speed and simplification
|
||||||
* - Unroll last copy for window match in inflate_fast()
|
* - Unroll last copy for window match in inflate_fast()
|
||||||
* - Use local copies of window variables in inflate_fast() for speed
|
* - Use local copies of window variables in inflate_fast() for speed
|
||||||
* - Pull out common write == 0 case for speed in inflate_fast()
|
* - Pull out common wnext == 0 case for speed in inflate_fast()
|
||||||
* - Make op and len in inflate_fast() unsigned for consistency
|
* - Make op and len in inflate_fast() unsigned for consistency
|
||||||
* - Add FAR to lcode and dcode declarations in inflate_fast()
|
* - Add FAR to lcode and dcode declarations in inflate_fast()
|
||||||
* - Simplified bad distance check in inflate_fast()
|
* - Simplified bad distance check in inflate_fast()
|
||||||
|
@ -117,28 +117,52 @@ z_streamp strm;
|
||||||
state->head = Z_NULL;
|
state->head = Z_NULL;
|
||||||
state->wsize = 0;
|
state->wsize = 0;
|
||||||
state->whave = 0;
|
state->whave = 0;
|
||||||
state->write = 0;
|
state->wnext = 0;
|
||||||
state->hold = 0;
|
state->hold = 0;
|
||||||
state->bits = 0;
|
state->bits = 0;
|
||||||
state->lencode = state->distcode = state->next = state->codes;
|
state->lencode = state->distcode = state->next = state->codes;
|
||||||
|
state->sane = 1;
|
||||||
|
state->back = -1;
|
||||||
Tracev((stderr, "inflate: reset\n"));
|
Tracev((stderr, "inflate: reset\n"));
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflatePrime(strm, bits, value)
|
int ZEXPORT inflateReset2(strm, windowBits)
|
||||||
z_streamp strm;
|
z_streamp strm;
|
||||||
int bits;
|
int windowBits;
|
||||||
int value;
|
|
||||||
{
|
{
|
||||||
|
int wrap;
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
|
/* get the state */
|
||||||
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||||
state = (struct inflate_state FAR *)strm->state;
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
|
|
||||||
value &= (1L << bits) - 1;
|
/* extract wrap request from windowBits parameter */
|
||||||
state->hold += value << state->bits;
|
if (windowBits < 0) {
|
||||||
state->bits += bits;
|
wrap = 0;
|
||||||
return Z_OK;
|
windowBits = -windowBits;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wrap = (windowBits >> 4) + 1;
|
||||||
|
#ifdef GUNZIP
|
||||||
|
if (windowBits < 48)
|
||||||
|
windowBits &= 15;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set number of window bits, free window if different */
|
||||||
|
if (windowBits && (windowBits < 8 || windowBits > 15))
|
||||||
|
return Z_STREAM_ERROR;
|
||||||
|
if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
|
||||||
|
ZFREE(strm, state->window);
|
||||||
|
state->window = Z_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* update state and reset the rest of it */
|
||||||
|
state->wrap = wrap;
|
||||||
|
state->wbits = (unsigned)windowBits;
|
||||||
|
return inflateReset(strm);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
|
int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
|
||||||
|
@ -147,6 +171,7 @@ int windowBits;
|
||||||
const char *version;
|
const char *version;
|
||||||
int stream_size;
|
int stream_size;
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
struct inflate_state FAR *state;
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
|
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
|
||||||
|
@ -164,24 +189,13 @@ int stream_size;
|
||||||
if (state == Z_NULL) return Z_MEM_ERROR;
|
if (state == Z_NULL) return Z_MEM_ERROR;
|
||||||
Tracev((stderr, "inflate: allocated\n"));
|
Tracev((stderr, "inflate: allocated\n"));
|
||||||
strm->state = (struct internal_state FAR *)state;
|
strm->state = (struct internal_state FAR *)state;
|
||||||
if (windowBits < 0) {
|
state->window = Z_NULL;
|
||||||
state->wrap = 0;
|
ret = inflateReset2(strm, windowBits);
|
||||||
windowBits = -windowBits;
|
if (ret != Z_OK) {
|
||||||
}
|
|
||||||
else {
|
|
||||||
state->wrap = (windowBits >> 4) + 1;
|
|
||||||
#ifdef GUNZIP
|
|
||||||
if (windowBits < 48) windowBits &= 15;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
if (windowBits < 8 || windowBits > 15) {
|
|
||||||
ZFREE(strm, state);
|
ZFREE(strm, state);
|
||||||
strm->state = Z_NULL;
|
strm->state = Z_NULL;
|
||||||
return Z_STREAM_ERROR;
|
|
||||||
}
|
}
|
||||||
state->wbits = (unsigned)windowBits;
|
return ret;
|
||||||
state->window = Z_NULL;
|
|
||||||
return inflateReset(strm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ZEXPORT inflateInit_(strm, version, stream_size)
|
int ZEXPORT inflateInit_(strm, version, stream_size)
|
||||||
|
@ -192,6 +206,27 @@ int stream_size;
|
||||||
return inflateInit2_(strm, DEF_WBITS, version, stream_size);
|
return inflateInit2_(strm, DEF_WBITS, version, stream_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ZEXPORT inflatePrime(strm, bits, value)
|
||||||
|
z_streamp strm;
|
||||||
|
int bits;
|
||||||
|
int value;
|
||||||
|
{
|
||||||
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
|
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||||
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
|
if (bits < 0) {
|
||||||
|
state->hold = 0;
|
||||||
|
state->bits = 0;
|
||||||
|
return Z_OK;
|
||||||
|
}
|
||||||
|
if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
|
||||||
|
value &= (1L << bits) - 1;
|
||||||
|
state->hold += value << state->bits;
|
||||||
|
state->bits += bits;
|
||||||
|
return Z_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Return state with length and distance decoding tables and index sizes set to
|
Return state with length and distance decoding tables and index sizes set to
|
||||||
fixed code decoding. Normally this returns fixed tables from inffixed.h.
|
fixed code decoding. Normally this returns fixed tables from inffixed.h.
|
||||||
|
@ -340,7 +375,7 @@ unsigned out;
|
||||||
/* if window not in use yet, initialize */
|
/* if window not in use yet, initialize */
|
||||||
if (state->wsize == 0) {
|
if (state->wsize == 0) {
|
||||||
state->wsize = 1U << state->wbits;
|
state->wsize = 1U << state->wbits;
|
||||||
state->write = 0;
|
state->wnext = 0;
|
||||||
state->whave = 0;
|
state->whave = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,22 +383,22 @@ unsigned out;
|
||||||
copy = out - strm->avail_out;
|
copy = out - strm->avail_out;
|
||||||
if (copy >= state->wsize) {
|
if (copy >= state->wsize) {
|
||||||
zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
|
zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
|
||||||
state->write = 0;
|
state->wnext = 0;
|
||||||
state->whave = state->wsize;
|
state->whave = state->wsize;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dist = state->wsize - state->write;
|
dist = state->wsize - state->wnext;
|
||||||
if (dist > copy) dist = copy;
|
if (dist > copy) dist = copy;
|
||||||
zmemcpy(state->window + state->write, strm->next_out - copy, dist);
|
zmemcpy(state->window + state->wnext, strm->next_out - copy, dist);
|
||||||
copy -= dist;
|
copy -= dist;
|
||||||
if (copy) {
|
if (copy) {
|
||||||
zmemcpy(state->window, strm->next_out - copy, copy);
|
zmemcpy(state->window, strm->next_out - copy, copy);
|
||||||
state->write = copy;
|
state->wnext = copy;
|
||||||
state->whave = state->wsize;
|
state->whave = state->wsize;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
state->write += dist;
|
state->wnext += dist;
|
||||||
if (state->write == state->wsize) state->write = 0;
|
if (state->wnext == state->wsize) state->wnext = 0;
|
||||||
if (state->whave < state->wsize) state->whave += dist;
|
if (state->whave < state->wsize) state->whave += dist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -564,7 +599,7 @@ int flush;
|
||||||
unsigned in, out; /* save starting available input and output */
|
unsigned in, out; /* save starting available input and output */
|
||||||
unsigned copy; /* number of stored or match bytes to copy */
|
unsigned copy; /* number of stored or match bytes to copy */
|
||||||
unsigned char FAR *from; /* where to copy match bytes from */
|
unsigned char FAR *from; /* where to copy match bytes from */
|
||||||
code this; /* current decoding table entry */
|
code here; /* current decoding table entry */
|
||||||
code last; /* parent table entry */
|
code last; /* parent table entry */
|
||||||
unsigned len; /* length to copy for repeats, bits to drop */
|
unsigned len; /* length to copy for repeats, bits to drop */
|
||||||
int ret; /* return code */
|
int ret; /* return code */
|
||||||
|
@ -619,7 +654,9 @@ int flush;
|
||||||
}
|
}
|
||||||
DROPBITS(4);
|
DROPBITS(4);
|
||||||
len = BITS(4) + 8;
|
len = BITS(4) + 8;
|
||||||
if (len > state->wbits) {
|
if (state->wbits == 0)
|
||||||
|
state->wbits = len;
|
||||||
|
else if (len > state->wbits) {
|
||||||
strm->msg = (char *)"invalid window size";
|
strm->msg = (char *)"invalid window size";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
|
@ -771,7 +808,7 @@ int flush;
|
||||||
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
strm->adler = state->check = adler32(0L, Z_NULL, 0);
|
||||||
state->mode = TYPE;
|
state->mode = TYPE;
|
||||||
case TYPE:
|
case TYPE:
|
||||||
if (flush == Z_BLOCK) goto inf_leave;
|
if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
|
||||||
case TYPEDO:
|
case TYPEDO:
|
||||||
if (state->last) {
|
if (state->last) {
|
||||||
BYTEBITS();
|
BYTEBITS();
|
||||||
|
@ -791,7 +828,11 @@ int flush;
|
||||||
fixedtables(state);
|
fixedtables(state);
|
||||||
Tracev((stderr, "inflate: fixed codes block%s\n",
|
Tracev((stderr, "inflate: fixed codes block%s\n",
|
||||||
state->last ? " (last)" : ""));
|
state->last ? " (last)" : ""));
|
||||||
state->mode = LEN; /* decode codes */
|
state->mode = LEN_; /* decode codes */
|
||||||
|
if (flush == Z_TREES) {
|
||||||
|
DROPBITS(2);
|
||||||
|
goto inf_leave;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2: /* dynamic block */
|
case 2: /* dynamic block */
|
||||||
Tracev((stderr, "inflate: dynamic codes block%s\n",
|
Tracev((stderr, "inflate: dynamic codes block%s\n",
|
||||||
|
@ -816,6 +857,9 @@ int flush;
|
||||||
Tracev((stderr, "inflate: stored length %u\n",
|
Tracev((stderr, "inflate: stored length %u\n",
|
||||||
state->length));
|
state->length));
|
||||||
INITBITS();
|
INITBITS();
|
||||||
|
state->mode = COPY_;
|
||||||
|
if (flush == Z_TREES) goto inf_leave;
|
||||||
|
case COPY_:
|
||||||
state->mode = COPY;
|
state->mode = COPY;
|
||||||
case COPY:
|
case COPY:
|
||||||
copy = state->length;
|
copy = state->length;
|
||||||
|
@ -876,19 +920,19 @@ int flush;
|
||||||
case CODELENS:
|
case CODELENS:
|
||||||
while (state->have < state->nlen + state->ndist) {
|
while (state->have < state->nlen + state->ndist) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[BITS(state->lenbits)];
|
here = state->lencode[BITS(state->lenbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if (this.val < 16) {
|
if (here.val < 16) {
|
||||||
NEEDBITS(this.bits);
|
NEEDBITS(here.bits);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
state->lens[state->have++] = this.val;
|
state->lens[state->have++] = here.val;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (this.val == 16) {
|
if (here.val == 16) {
|
||||||
NEEDBITS(this.bits + 2);
|
NEEDBITS(here.bits + 2);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
if (state->have == 0) {
|
if (state->have == 0) {
|
||||||
strm->msg = (char *)"invalid bit length repeat";
|
strm->msg = (char *)"invalid bit length repeat";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
|
@ -898,16 +942,16 @@ int flush;
|
||||||
copy = 3 + BITS(2);
|
copy = 3 + BITS(2);
|
||||||
DROPBITS(2);
|
DROPBITS(2);
|
||||||
}
|
}
|
||||||
else if (this.val == 17) {
|
else if (here.val == 17) {
|
||||||
NEEDBITS(this.bits + 3);
|
NEEDBITS(here.bits + 3);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
len = 0;
|
len = 0;
|
||||||
copy = 3 + BITS(3);
|
copy = 3 + BITS(3);
|
||||||
DROPBITS(3);
|
DROPBITS(3);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
NEEDBITS(this.bits + 7);
|
NEEDBITS(here.bits + 7);
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
len = 0;
|
len = 0;
|
||||||
copy = 11 + BITS(7);
|
copy = 11 + BITS(7);
|
||||||
DROPBITS(7);
|
DROPBITS(7);
|
||||||
|
@ -925,7 +969,16 @@ int flush;
|
||||||
/* handle error breaks in while */
|
/* handle error breaks in while */
|
||||||
if (state->mode == BAD) break;
|
if (state->mode == BAD) break;
|
||||||
|
|
||||||
/* build code tables */
|
/* check for end-of-block code (better have one) */
|
||||||
|
if (state->lens[256] == 0) {
|
||||||
|
strm->msg = (char *)"invalid code -- missing end-of-block";
|
||||||
|
state->mode = BAD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* build code tables -- note: do not change the lenbits or distbits
|
||||||
|
values here (9 and 6) without reading the comments in inftrees.h
|
||||||
|
concerning the ENOUGH constants, which depend on those values */
|
||||||
state->next = state->codes;
|
state->next = state->codes;
|
||||||
state->lencode = (code const FAR *)(state->next);
|
state->lencode = (code const FAR *)(state->next);
|
||||||
state->lenbits = 9;
|
state->lenbits = 9;
|
||||||
|
@ -946,88 +999,102 @@ int flush;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Tracev((stderr, "inflate: codes ok\n"));
|
Tracev((stderr, "inflate: codes ok\n"));
|
||||||
|
state->mode = LEN_;
|
||||||
|
if (flush == Z_TREES) goto inf_leave;
|
||||||
|
case LEN_:
|
||||||
state->mode = LEN;
|
state->mode = LEN;
|
||||||
case LEN:
|
case LEN:
|
||||||
if (have >= 6 && left >= 258) {
|
if (have >= 6 && left >= 258) {
|
||||||
RESTORE();
|
RESTORE();
|
||||||
inflate_fast(strm, out);
|
inflate_fast(strm, out);
|
||||||
LOAD();
|
LOAD();
|
||||||
|
if (state->mode == TYPE)
|
||||||
|
state->back = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
state->back = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[BITS(state->lenbits)];
|
here = state->lencode[BITS(state->lenbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if (this.op && (this.op & 0xf0) == 0) {
|
if (here.op && (here.op & 0xf0) == 0) {
|
||||||
last = this;
|
last = here;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->lencode[last.val +
|
here = state->lencode[last.val +
|
||||||
(BITS(last.bits + last.op) >> last.bits)];
|
(BITS(last.bits + last.op) >> last.bits)];
|
||||||
if ((unsigned)(last.bits + this.bits) <= bits) break;
|
if ((unsigned)(last.bits + here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
DROPBITS(last.bits);
|
DROPBITS(last.bits);
|
||||||
|
state->back += last.bits;
|
||||||
}
|
}
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
state->length = (unsigned)this.val;
|
state->back += here.bits;
|
||||||
if ((int)(this.op) == 0) {
|
state->length = (unsigned)here.val;
|
||||||
Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
|
if ((int)(here.op) == 0) {
|
||||||
|
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
||||||
"inflate: literal '%c'\n" :
|
"inflate: literal '%c'\n" :
|
||||||
"inflate: literal 0x%02x\n", this.val));
|
"inflate: literal 0x%02x\n", here.val));
|
||||||
state->mode = LIT;
|
state->mode = LIT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this.op & 32) {
|
if (here.op & 32) {
|
||||||
Tracevv((stderr, "inflate: end of block\n"));
|
Tracevv((stderr, "inflate: end of block\n"));
|
||||||
|
state->back = -1;
|
||||||
state->mode = TYPE;
|
state->mode = TYPE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (this.op & 64) {
|
if (here.op & 64) {
|
||||||
strm->msg = (char *)"invalid literal/length code";
|
strm->msg = (char *)"invalid literal/length code";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->extra = (unsigned)(this.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
state->mode = LENEXT;
|
state->mode = LENEXT;
|
||||||
case LENEXT:
|
case LENEXT:
|
||||||
if (state->extra) {
|
if (state->extra) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
state->length += BITS(state->extra);
|
state->length += BITS(state->extra);
|
||||||
DROPBITS(state->extra);
|
DROPBITS(state->extra);
|
||||||
|
state->back += state->extra;
|
||||||
}
|
}
|
||||||
Tracevv((stderr, "inflate: length %u\n", state->length));
|
Tracevv((stderr, "inflate: length %u\n", state->length));
|
||||||
|
state->was = state->length;
|
||||||
state->mode = DIST;
|
state->mode = DIST;
|
||||||
case DIST:
|
case DIST:
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->distcode[BITS(state->distbits)];
|
here = state->distcode[BITS(state->distbits)];
|
||||||
if ((unsigned)(this.bits) <= bits) break;
|
if ((unsigned)(here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
if ((this.op & 0xf0) == 0) {
|
if ((here.op & 0xf0) == 0) {
|
||||||
last = this;
|
last = here;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->distcode[last.val +
|
here = state->distcode[last.val +
|
||||||
(BITS(last.bits + last.op) >> last.bits)];
|
(BITS(last.bits + last.op) >> last.bits)];
|
||||||
if ((unsigned)(last.bits + this.bits) <= bits) break;
|
if ((unsigned)(last.bits + here.bits) <= bits) break;
|
||||||
PULLBYTE();
|
PULLBYTE();
|
||||||
}
|
}
|
||||||
DROPBITS(last.bits);
|
DROPBITS(last.bits);
|
||||||
|
state->back += last.bits;
|
||||||
}
|
}
|
||||||
DROPBITS(this.bits);
|
DROPBITS(here.bits);
|
||||||
if (this.op & 64) {
|
state->back += here.bits;
|
||||||
|
if (here.op & 64) {
|
||||||
strm->msg = (char *)"invalid distance code";
|
strm->msg = (char *)"invalid distance code";
|
||||||
state->mode = BAD;
|
state->mode = BAD;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->offset = (unsigned)this.val;
|
state->offset = (unsigned)here.val;
|
||||||
state->extra = (unsigned)(this.op) & 15;
|
state->extra = (unsigned)(here.op) & 15;
|
||||||
state->mode = DISTEXT;
|
state->mode = DISTEXT;
|
||||||
case DISTEXT:
|
case DISTEXT:
|
||||||
if (state->extra) {
|
if (state->extra) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
state->offset += BITS(state->extra);
|
state->offset += BITS(state->extra);
|
||||||
DROPBITS(state->extra);
|
DROPBITS(state->extra);
|
||||||
|
state->back += state->extra;
|
||||||
}
|
}
|
||||||
#ifdef INFLATE_STRICT
|
#ifdef INFLATE_STRICT
|
||||||
if (state->offset > state->dmax) {
|
if (state->offset > state->dmax) {
|
||||||
|
@ -1036,11 +1103,6 @@ int flush;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (state->offset > state->whave + out - left) {
|
|
||||||
strm->msg = (char *)"invalid distance too far back";
|
|
||||||
state->mode = BAD;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Tracevv((stderr, "inflate: distance %u\n", state->offset));
|
Tracevv((stderr, "inflate: distance %u\n", state->offset));
|
||||||
state->mode = MATCH;
|
state->mode = MATCH;
|
||||||
case MATCH:
|
case MATCH:
|
||||||
|
@ -1048,12 +1110,32 @@ int flush;
|
||||||
copy = out - left;
|
copy = out - left;
|
||||||
if (state->offset > copy) { /* copy from window */
|
if (state->offset > copy) { /* copy from window */
|
||||||
copy = state->offset - copy;
|
copy = state->offset - copy;
|
||||||
if (copy > state->write) {
|
if (copy > state->whave) {
|
||||||
copy -= state->write;
|
if (state->sane) {
|
||||||
|
strm->msg = (char *)"invalid distance too far back";
|
||||||
|
state->mode = BAD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||||
|
Trace((stderr, "inflate.c too far\n"));
|
||||||
|
copy -= state->whave;
|
||||||
|
if (copy > state->length) copy = state->length;
|
||||||
|
if (copy > left) copy = left;
|
||||||
|
left -= copy;
|
||||||
|
state->length -= copy;
|
||||||
|
do {
|
||||||
|
*put++ = 0;
|
||||||
|
} while (--copy);
|
||||||
|
if (state->length == 0) state->mode = LEN;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
if (copy > state->wnext) {
|
||||||
|
copy -= state->wnext;
|
||||||
from = state->window + (state->wsize - copy);
|
from = state->window + (state->wsize - copy);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
from = state->window + (state->write - copy);
|
from = state->window + (state->wnext - copy);
|
||||||
if (copy > state->length) copy = state->length;
|
if (copy > state->length) copy = state->length;
|
||||||
}
|
}
|
||||||
else { /* copy from output */
|
else { /* copy from output */
|
||||||
|
@ -1146,7 +1228,8 @@ int flush;
|
||||||
strm->adler = state->check =
|
strm->adler = state->check =
|
||||||
UPDATE(state->check, strm->next_out - out, out);
|
UPDATE(state->check, strm->next_out - out, out);
|
||||||
strm->data_type = state->bits + (state->last ? 64 : 0) +
|
strm->data_type = state->bits + (state->last ? 64 : 0) +
|
||||||
(state->mode == TYPE ? 128 : 0);
|
(state->mode == TYPE ? 128 : 0) +
|
||||||
|
(state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
|
||||||
if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
|
if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
|
||||||
ret = Z_BUF_ERROR;
|
ret = Z_BUF_ERROR;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1366,3 +1449,32 @@ z_streamp source;
|
||||||
dest->state = (struct internal_state FAR *)copy;
|
dest->state = (struct internal_state FAR *)copy;
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ZEXPORT inflateUndermine(strm, subvert)
|
||||||
|
z_streamp strm;
|
||||||
|
int subvert;
|
||||||
|
{
|
||||||
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
|
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||||
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
|
state->sane = !subvert;
|
||||||
|
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||||
|
return Z_OK;
|
||||||
|
#else
|
||||||
|
state->sane = 1;
|
||||||
|
return Z_DATA_ERROR;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
long ZEXPORT inflateMark(strm)
|
||||||
|
z_streamp strm;
|
||||||
|
{
|
||||||
|
struct inflate_state FAR *state;
|
||||||
|
|
||||||
|
if (strm == Z_NULL || strm->state == Z_NULL) return -1L << 16;
|
||||||
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
|
return ((long)(state->back) << 16) +
|
||||||
|
(state->mode == COPY ? state->length :
|
||||||
|
(state->mode == MATCH ? state->was - state->length : 0));
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* inflate.h -- internal inflate state definition
|
/* inflate.h -- internal inflate state definition
|
||||||
* Copyright (C) 1995-2004 Mark Adler
|
* Copyright (C) 1995-2009 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -32,11 +32,13 @@ typedef enum {
|
||||||
TYPE, /* i: waiting for type bits, including last-flag bit */
|
TYPE, /* i: waiting for type bits, including last-flag bit */
|
||||||
TYPEDO, /* i: same, but skip check to exit inflate on new block */
|
TYPEDO, /* i: same, but skip check to exit inflate on new block */
|
||||||
STORED, /* i: waiting for stored size (length and complement) */
|
STORED, /* i: waiting for stored size (length and complement) */
|
||||||
|
COPY_, /* i/o: same as COPY below, but only first time in */
|
||||||
COPY, /* i/o: waiting for input or output to copy stored block */
|
COPY, /* i/o: waiting for input or output to copy stored block */
|
||||||
TABLE, /* i: waiting for dynamic block table lengths */
|
TABLE, /* i: waiting for dynamic block table lengths */
|
||||||
LENLENS, /* i: waiting for code length code lengths */
|
LENLENS, /* i: waiting for code length code lengths */
|
||||||
CODELENS, /* i: waiting for length/lit and distance code lengths */
|
CODELENS, /* i: waiting for length/lit and distance code lengths */
|
||||||
LEN, /* i: waiting for length/lit code */
|
LEN_, /* i: same as LEN below, but only first time in */
|
||||||
|
LEN, /* i: waiting for length/lit/eob code */
|
||||||
LENEXT, /* i: waiting for length extra bits */
|
LENEXT, /* i: waiting for length extra bits */
|
||||||
DIST, /* i: waiting for distance code */
|
DIST, /* i: waiting for distance code */
|
||||||
DISTEXT, /* i: waiting for distance extra bits */
|
DISTEXT, /* i: waiting for distance extra bits */
|
||||||
|
@ -53,19 +55,21 @@ typedef enum {
|
||||||
/*
|
/*
|
||||||
State transitions between above modes -
|
State transitions between above modes -
|
||||||
|
|
||||||
(most modes can go to the BAD or MEM mode -- not shown for clarity)
|
(most modes can go to BAD or MEM on error -- not shown for clarity)
|
||||||
|
|
||||||
Process header:
|
Process header:
|
||||||
HEAD -> (gzip) or (zlib)
|
HEAD -> (gzip) or (zlib) or (raw)
|
||||||
(gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
|
(gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT ->
|
||||||
NAME -> COMMENT -> HCRC -> TYPE
|
HCRC -> TYPE
|
||||||
(zlib) -> DICTID or TYPE
|
(zlib) -> DICTID or TYPE
|
||||||
DICTID -> DICT -> TYPE
|
DICTID -> DICT -> TYPE
|
||||||
|
(raw) -> TYPEDO
|
||||||
Read deflate blocks:
|
Read deflate blocks:
|
||||||
TYPE -> STORED or TABLE or LEN or CHECK
|
TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK
|
||||||
STORED -> COPY -> TYPE
|
STORED -> COPY_ -> COPY -> TYPE
|
||||||
TABLE -> LENLENS -> CODELENS -> LEN
|
TABLE -> LENLENS -> CODELENS -> LEN_
|
||||||
Read deflate codes:
|
LEN_ -> LEN
|
||||||
|
Read deflate codes in fixed or dynamic block:
|
||||||
LEN -> LENEXT or LIT or TYPE
|
LEN -> LENEXT or LIT or TYPE
|
||||||
LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
|
LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
|
||||||
LIT -> LEN
|
LIT -> LEN
|
||||||
|
@ -73,7 +77,7 @@ typedef enum {
|
||||||
CHECK -> LENGTH -> DONE
|
CHECK -> LENGTH -> DONE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* state maintained between inflate() calls. Approximately 7K bytes. */
|
/* state maintained between inflate() calls. Approximately 10K bytes. */
|
||||||
struct inflate_state {
|
struct inflate_state {
|
||||||
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 */
|
||||||
|
@ -88,7 +92,7 @@ struct inflate_state {
|
||||||
unsigned wbits; /* log base 2 of requested window size */
|
unsigned wbits; /* log base 2 of requested window size */
|
||||||
unsigned wsize; /* window size or zero if not using window */
|
unsigned wsize; /* window size or zero if not using window */
|
||||||
unsigned whave; /* valid bytes in the window */
|
unsigned whave; /* valid bytes in the window */
|
||||||
unsigned write; /* window write index */
|
unsigned wnext; /* window write index */
|
||||||
unsigned char FAR *window; /* allocated sliding window, if needed */
|
unsigned char FAR *window; /* allocated sliding window, if needed */
|
||||||
/* bit accumulator */
|
/* bit accumulator */
|
||||||
unsigned long hold; /* input bit accumulator */
|
unsigned long hold; /* input bit accumulator */
|
||||||
|
@ -112,4 +116,7 @@ struct inflate_state {
|
||||||
unsigned short lens[320]; /* temporary storage for code lengths */
|
unsigned short lens[320]; /* temporary storage for code lengths */
|
||||||
unsigned short work[288]; /* work area for code table building */
|
unsigned short work[288]; /* work area for code table building */
|
||||||
code codes[ENOUGH]; /* space for code tables */
|
code codes[ENOUGH]; /* space for code tables */
|
||||||
|
int sane; /* if false, allow invalid distance too far */
|
||||||
|
int back; /* bits back of last unprocessed length/lit */
|
||||||
|
unsigned was; /* initial length of match */
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* inftrees.c -- generate Huffman trees for efficient decoding
|
/* inftrees.c -- generate Huffman trees for efficient decoding
|
||||||
* Copyright (C) 1995-2005 Mark Adler
|
* Copyright (C) 1995-2010 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
#define MAXBITS 15
|
#define MAXBITS 15
|
||||||
|
|
||||||
const char inflate_copyright[] =
|
const char inflate_copyright[] =
|
||||||
" inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
|
" inflate 1.2.5 Copyright 1995-2010 Mark Adler ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
If you use the zlib library in a product, an acknowledgment is welcome
|
||||||
in the documentation of your product. If for some reason you cannot
|
in the documentation of your product. If for some reason you cannot
|
||||||
|
@ -29,7 +29,7 @@ const char inflate_copyright[] =
|
||||||
table index bits. It will differ if the request is greater than the
|
table index bits. It will differ if the request is greater than the
|
||||||
longest code or if it is less than the shortest code.
|
longest code or if it is less than the shortest code.
|
||||||
*/
|
*/
|
||||||
int inflate_table(type, lens, codes, table, bits, work)
|
int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work)
|
||||||
codetype type;
|
codetype type;
|
||||||
unsigned short FAR *lens;
|
unsigned short FAR *lens;
|
||||||
unsigned codes;
|
unsigned codes;
|
||||||
|
@ -50,7 +50,7 @@ unsigned short FAR *work;
|
||||||
unsigned fill; /* index for replicating entries */
|
unsigned fill; /* index for replicating entries */
|
||||||
unsigned low; /* low bits for current root entry */
|
unsigned low; /* low bits for current root entry */
|
||||||
unsigned mask; /* mask for low root bits */
|
unsigned mask; /* mask for low root bits */
|
||||||
code this; /* table entry for duplication */
|
code here; /* table entry for duplication */
|
||||||
code FAR *next; /* next available space in table */
|
code FAR *next; /* next available space in table */
|
||||||
const unsigned short FAR *base; /* base value table to use */
|
const unsigned short FAR *base; /* base value table to use */
|
||||||
const unsigned short FAR *extra; /* extra bits table to use */
|
const unsigned short FAR *extra; /* extra bits table to use */
|
||||||
|
@ -62,7 +62,7 @@ unsigned short FAR *work;
|
||||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||||
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
||||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
||||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196};
|
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 195};
|
||||||
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
||||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||||
|
@ -115,15 +115,15 @@ unsigned short FAR *work;
|
||||||
if (count[max] != 0) break;
|
if (count[max] != 0) break;
|
||||||
if (root > max) root = max;
|
if (root > max) root = max;
|
||||||
if (max == 0) { /* no symbols to code at all */
|
if (max == 0) { /* no symbols to code at all */
|
||||||
this.op = (unsigned char)64; /* invalid code marker */
|
here.op = (unsigned char)64; /* invalid code marker */
|
||||||
this.bits = (unsigned char)1;
|
here.bits = (unsigned char)1;
|
||||||
this.val = (unsigned short)0;
|
here.val = (unsigned short)0;
|
||||||
*(*table)++ = this; /* make a table to force an error */
|
*(*table)++ = here; /* make a table to force an error */
|
||||||
*(*table)++ = this;
|
*(*table)++ = here;
|
||||||
*bits = 1;
|
*bits = 1;
|
||||||
return 0; /* no symbols, but wait for decoding to report error */
|
return 0; /* no symbols, but wait for decoding to report error */
|
||||||
}
|
}
|
||||||
for (min = 1; min <= MAXBITS; min++)
|
for (min = 1; min < max; min++)
|
||||||
if (count[min] != 0) break;
|
if (count[min] != 0) break;
|
||||||
if (root < min) root = min;
|
if (root < min) root = min;
|
||||||
|
|
||||||
|
@ -166,11 +166,10 @@ unsigned short FAR *work;
|
||||||
entered in the tables.
|
entered in the tables.
|
||||||
|
|
||||||
used keeps track of how many table entries have been allocated from the
|
used keeps track of how many table entries have been allocated from the
|
||||||
provided *table space. It is checked when a LENS table is being made
|
provided *table space. It is checked for LENS and DIST tables against
|
||||||
against the space in *table, ENOUGH, minus the maximum space needed by
|
the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
|
||||||
the worst case distance code, MAXD. This should never happen, but the
|
the initial root table size constants. See the comments in inftrees.h
|
||||||
sufficiency of ENOUGH has not been proven exhaustively, hence the check.
|
for more information.
|
||||||
This assumes that when type == LENS, bits == 9.
|
|
||||||
|
|
||||||
sym increments through all symbols, and the loop terminates when
|
sym increments through all symbols, and the loop terminates when
|
||||||
all codes of length max, i.e. all codes, have been processed. This
|
all codes of length max, i.e. all codes, have been processed. This
|
||||||
|
@ -209,24 +208,25 @@ unsigned short FAR *work;
|
||||||
mask = used - 1; /* mask for comparing low */
|
mask = used - 1; /* mask for comparing low */
|
||||||
|
|
||||||
/* check available table space */
|
/* check available table space */
|
||||||
if (type == LENS && used >= ENOUGH - MAXD)
|
if ((type == LENS && used >= ENOUGH_LENS) ||
|
||||||
|
(type == DISTS && used >= ENOUGH_DISTS))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* process all codes and make table entries */
|
/* process all codes and make table entries */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* create table entry */
|
/* create table entry */
|
||||||
this.bits = (unsigned char)(len - drop);
|
here.bits = (unsigned char)(len - drop);
|
||||||
if ((int)(work[sym]) < end) {
|
if ((int)(work[sym]) < end) {
|
||||||
this.op = (unsigned char)0;
|
here.op = (unsigned char)0;
|
||||||
this.val = work[sym];
|
here.val = work[sym];
|
||||||
}
|
}
|
||||||
else if ((int)(work[sym]) > end) {
|
else if ((int)(work[sym]) > end) {
|
||||||
this.op = (unsigned char)(extra[work[sym]]);
|
here.op = (unsigned char)(extra[work[sym]]);
|
||||||
this.val = base[work[sym]];
|
here.val = base[work[sym]];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.op = (unsigned char)(32 + 64); /* end of block */
|
here.op = (unsigned char)(32 + 64); /* end of block */
|
||||||
this.val = 0;
|
here.val = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* replicate for those indices with low len bits equal to huff */
|
/* replicate for those indices with low len bits equal to huff */
|
||||||
|
@ -235,7 +235,7 @@ unsigned short FAR *work;
|
||||||
min = fill; /* save offset to next table */
|
min = fill; /* save offset to next table */
|
||||||
do {
|
do {
|
||||||
fill -= incr;
|
fill -= incr;
|
||||||
next[(huff >> drop) + fill] = this;
|
next[(huff >> drop) + fill] = here;
|
||||||
} while (fill != 0);
|
} while (fill != 0);
|
||||||
|
|
||||||
/* backwards increment the len-bit code huff */
|
/* backwards increment the len-bit code huff */
|
||||||
|
@ -277,7 +277,8 @@ unsigned short FAR *work;
|
||||||
|
|
||||||
/* check for enough space */
|
/* check for enough space */
|
||||||
used += 1U << curr;
|
used += 1U << curr;
|
||||||
if (type == LENS && used >= ENOUGH - MAXD)
|
if ((type == LENS && used >= ENOUGH_LENS) ||
|
||||||
|
(type == DISTS && used >= ENOUGH_DISTS))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* point entry in root table to sub-table */
|
/* point entry in root table to sub-table */
|
||||||
|
@ -295,20 +296,20 @@ unsigned short FAR *work;
|
||||||
through high index bits. When the current sub-table is filled, the loop
|
through high index bits. When the current sub-table is filled, the loop
|
||||||
drops back to the root table to fill in any remaining entries there.
|
drops back to the root table to fill in any remaining entries there.
|
||||||
*/
|
*/
|
||||||
this.op = (unsigned char)64; /* invalid code marker */
|
here.op = (unsigned char)64; /* invalid code marker */
|
||||||
this.bits = (unsigned char)(len - drop);
|
here.bits = (unsigned char)(len - drop);
|
||||||
this.val = (unsigned short)0;
|
here.val = (unsigned short)0;
|
||||||
while (huff != 0) {
|
while (huff != 0) {
|
||||||
/* when done with sub-table, drop back to root table */
|
/* when done with sub-table, drop back to root table */
|
||||||
if (drop != 0 && (huff & mask) != low) {
|
if (drop != 0 && (huff & mask) != low) {
|
||||||
drop = 0;
|
drop = 0;
|
||||||
len = root;
|
len = root;
|
||||||
next = *table;
|
next = *table;
|
||||||
this.bits = (unsigned char)len;
|
here.bits = (unsigned char)len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* put invalid code marker in table */
|
/* put invalid code marker in table */
|
||||||
next[huff >> drop] = this;
|
next[huff >> drop] = here;
|
||||||
|
|
||||||
/* backwards increment the len-bit code huff */
|
/* backwards increment the len-bit code huff */
|
||||||
incr = 1U << (len - 1);
|
incr = 1U << (len - 1);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* inftrees.h -- header to use inftrees.c
|
/* inftrees.h -- header to use inftrees.c
|
||||||
* Copyright (C) 1995-2005 Mark Adler
|
* Copyright (C) 1995-2005, 2010 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -35,21 +35,28 @@ typedef struct {
|
||||||
01000000 - invalid code
|
01000000 - invalid code
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Maximum size of dynamic tree. The maximum found in a long but non-
|
/* Maximum size of the dynamic table. The maximum number of code structures is
|
||||||
exhaustive search was 1444 code structures (852 for length/literals
|
1444, which is the sum of 852 for literal/length codes and 592 for distance
|
||||||
and 592 for distances, the latter actually the result of an
|
codes. These values were found by exhaustive searches using the program
|
||||||
exhaustive search). The true maximum is not known, but the value
|
examples/enough.c found in the zlib distribtution. The arguments to that
|
||||||
below is more than safe. */
|
program are the number of symbols, the initial root table size, and the
|
||||||
#define ENOUGH 2048
|
maximum bit length of a code. "enough 286 9 15" for literal/length codes
|
||||||
#define MAXD 592
|
returns returns 852, and "enough 30 6 15" for distance codes returns 592.
|
||||||
|
The initial root table size (9 or 6) is found in the fifth argument of the
|
||||||
|
inflate_table() calls in inflate.c and infback.c. If the root table size is
|
||||||
|
changed, then these maximum sizes would be need to be recalculated and
|
||||||
|
updated. */
|
||||||
|
#define ENOUGH_LENS 852
|
||||||
|
#define ENOUGH_DISTS 592
|
||||||
|
#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
|
||||||
|
|
||||||
/* Type of code to build for inftable() */
|
/* Type of code to build for inflate_table() */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CODES,
|
CODES,
|
||||||
LENS,
|
LENS,
|
||||||
DISTS
|
DISTS
|
||||||
} codetype;
|
} codetype;
|
||||||
|
|
||||||
extern int inflate_table OF((codetype type, unsigned short FAR *lens,
|
int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens,
|
||||||
unsigned codes, code FAR * FAR *table,
|
unsigned codes, code FAR * FAR *table,
|
||||||
unsigned FAR *bits, unsigned short FAR *work));
|
unsigned FAR *bits, unsigned short FAR *work));
|
||||||
|
|
134
zlib/minigzip.c
134
zlib/minigzip.c
|
@ -1,5 +1,5 @@
|
||||||
/* minigzip.c -- simulate gzip using the zlib compression library
|
/* minigzip.c -- simulate gzip using the zlib compression library
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
* Copyright (C) 1995-2006, 2010 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -15,8 +15,8 @@
|
||||||
|
|
||||||
/* @(#) $Id$ */
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#ifdef STDC
|
#ifdef STDC
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
@ -32,6 +32,9 @@
|
||||||
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
|
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
|
||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
# include <io.h>
|
# include <io.h>
|
||||||
|
# ifdef UNDER_CE
|
||||||
|
# include <stdlib.h>
|
||||||
|
# endif
|
||||||
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
|
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY)
|
||||||
#else
|
#else
|
||||||
# define SET_BINARY_MODE(file)
|
# define SET_BINARY_MODE(file)
|
||||||
|
@ -50,9 +53,75 @@
|
||||||
# include <unix.h> /* for fileno */
|
# include <unix.h> /* for fileno */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE)
|
||||||
#ifndef WIN32 /* unlink already in stdio.h for WIN32 */
|
#ifndef WIN32 /* unlink already in stdio.h for WIN32 */
|
||||||
extern int unlink OF((const char *));
|
extern int unlink OF((const char *));
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(UNDER_CE)
|
||||||
|
# include <windows.h>
|
||||||
|
# define perror(s) pwinerror(s)
|
||||||
|
|
||||||
|
/* Map the Windows error number in ERROR to a locale-dependent error
|
||||||
|
message string and return a pointer to it. Typically, the values
|
||||||
|
for ERROR come from GetLastError.
|
||||||
|
|
||||||
|
The string pointed to shall not be modified by the application,
|
||||||
|
but may be overwritten by a subsequent call to strwinerror
|
||||||
|
|
||||||
|
The strwinerror function does not change the current setting
|
||||||
|
of GetLastError. */
|
||||||
|
|
||||||
|
static char *strwinerror (error)
|
||||||
|
DWORD error;
|
||||||
|
{
|
||||||
|
static char buf[1024];
|
||||||
|
|
||||||
|
wchar_t *msgbuf;
|
||||||
|
DWORD lasterr = GetLastError();
|
||||||
|
DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
|
||||||
|
| FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||||
|
NULL,
|
||||||
|
error,
|
||||||
|
0, /* Default language */
|
||||||
|
(LPVOID)&msgbuf,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
if (chars != 0) {
|
||||||
|
/* If there is an \r\n appended, zap it. */
|
||||||
|
if (chars >= 2
|
||||||
|
&& msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') {
|
||||||
|
chars -= 2;
|
||||||
|
msgbuf[chars] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chars > sizeof (buf) - 1) {
|
||||||
|
chars = sizeof (buf) - 1;
|
||||||
|
msgbuf[chars] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wcstombs(buf, msgbuf, chars + 1);
|
||||||
|
LocalFree(msgbuf);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sprintf(buf, "unknown win32 error (%ld)", error);
|
||||||
|
}
|
||||||
|
|
||||||
|
SetLastError(lasterr);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pwinerror (s)
|
||||||
|
const char *s;
|
||||||
|
{
|
||||||
|
if (s && *s)
|
||||||
|
fprintf(stderr, "%s: %s\n", s, strwinerror(GetLastError ()));
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%s\n", strwinerror(GetLastError ()));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* UNDER_CE */
|
||||||
|
|
||||||
#ifndef GZ_SUFFIX
|
#ifndef GZ_SUFFIX
|
||||||
# define GZ_SUFFIX ".gz"
|
# define GZ_SUFFIX ".gz"
|
||||||
|
@ -198,6 +267,11 @@ void file_compress(file, mode)
|
||||||
FILE *in;
|
FILE *in;
|
||||||
gzFile out;
|
gzFile out;
|
||||||
|
|
||||||
|
if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) {
|
||||||
|
fprintf(stderr, "%s: filename too long\n", prog);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(outfile, file);
|
strcpy(outfile, file);
|
||||||
strcat(outfile, GZ_SUFFIX);
|
strcat(outfile, GZ_SUFFIX);
|
||||||
|
|
||||||
|
@ -227,7 +301,12 @@ void file_uncompress(file)
|
||||||
char *infile, *outfile;
|
char *infile, *outfile;
|
||||||
FILE *out;
|
FILE *out;
|
||||||
gzFile in;
|
gzFile in;
|
||||||
uInt len = (uInt)strlen(file);
|
size_t len = strlen(file);
|
||||||
|
|
||||||
|
if (len + strlen(GZ_SUFFIX) >= sizeof(buf)) {
|
||||||
|
fprintf(stderr, "%s: filename too long\n", prog);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
strcpy(buf, file);
|
strcpy(buf, file);
|
||||||
|
|
||||||
|
@ -258,7 +337,8 @@ void file_uncompress(file)
|
||||||
|
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Usage: minigzip [-d] [-f] [-h] [-r] [-1 to -9] [files...]
|
* Usage: minigzip [-c] [-d] [-f] [-h] [-r] [-1 to -9] [files...]
|
||||||
|
* -c : write to standard output
|
||||||
* -d : decompress
|
* -d : decompress
|
||||||
* -f : compress with Z_FILTERED
|
* -f : compress with Z_FILTERED
|
||||||
* -h : compress with Z_HUFFMAN_ONLY
|
* -h : compress with Z_HUFFMAN_ONLY
|
||||||
|
@ -270,17 +350,30 @@ int main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char *argv[];
|
char *argv[];
|
||||||
{
|
{
|
||||||
|
int copyout = 0;
|
||||||
int uncompr = 0;
|
int uncompr = 0;
|
||||||
gzFile file;
|
gzFile file;
|
||||||
char outmode[20];
|
char *bname, outmode[20];
|
||||||
|
|
||||||
strcpy(outmode, "wb6 ");
|
strcpy(outmode, "wb6 ");
|
||||||
|
|
||||||
prog = argv[0];
|
prog = argv[0];
|
||||||
|
bname = strrchr(argv[0], '/');
|
||||||
|
if (bname)
|
||||||
|
bname++;
|
||||||
|
else
|
||||||
|
bname = argv[0];
|
||||||
argc--, argv++;
|
argc--, argv++;
|
||||||
|
|
||||||
|
if (!strcmp(bname, "gunzip"))
|
||||||
|
uncompr = 1;
|
||||||
|
else if (!strcmp(bname, "zcat"))
|
||||||
|
copyout = uncompr = 1;
|
||||||
|
|
||||||
while (argc > 0) {
|
while (argc > 0) {
|
||||||
if (strcmp(*argv, "-d") == 0)
|
if (strcmp(*argv, "-c") == 0)
|
||||||
|
copyout = 1;
|
||||||
|
else if (strcmp(*argv, "-d") == 0)
|
||||||
uncompr = 1;
|
uncompr = 1;
|
||||||
else if (strcmp(*argv, "-f") == 0)
|
else if (strcmp(*argv, "-f") == 0)
|
||||||
outmode[3] = 'f';
|
outmode[3] = 'f';
|
||||||
|
@ -310,11 +403,36 @@ int main(argc, argv)
|
||||||
gz_compress(stdin, file);
|
gz_compress(stdin, file);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (copyout) {
|
||||||
|
SET_BINARY_MODE(stdout);
|
||||||
|
}
|
||||||
do {
|
do {
|
||||||
if (uncompr) {
|
if (uncompr) {
|
||||||
file_uncompress(*argv);
|
if (copyout) {
|
||||||
|
file = gzopen(*argv, "rb");
|
||||||
|
if (file == NULL)
|
||||||
|
fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv);
|
||||||
|
else
|
||||||
|
gz_uncompress(file, stdout);
|
||||||
|
} else {
|
||||||
|
file_uncompress(*argv);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
file_compress(*argv, outmode);
|
if (copyout) {
|
||||||
|
FILE * in = fopen(*argv, "rb");
|
||||||
|
|
||||||
|
if (in == NULL) {
|
||||||
|
perror(*argv);
|
||||||
|
} else {
|
||||||
|
file = gzdopen(fileno(stdout), outmode);
|
||||||
|
if (file == NULL) error("can't gzdopen stdout");
|
||||||
|
|
||||||
|
gz_compress(in, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
file_compress(*argv, outmode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (argv++, --argc);
|
} while (argv++, --argc);
|
||||||
}
|
}
|
||||||
|
|
93
zlib/trees.c
93
zlib/trees.c
|
@ -1,5 +1,6 @@
|
||||||
/* trees.c -- output deflated data using Huffman coding
|
/* trees.c -- output deflated data using Huffman coding
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly
|
* Copyright (C) 1995-2010 Jean-loup Gailly
|
||||||
|
* detect_data_type() function provided freely by Cosmin Truta, 2006
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -152,7 +153,7 @@ local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
|
||||||
int blcodes));
|
int blcodes));
|
||||||
local void compress_block OF((deflate_state *s, ct_data *ltree,
|
local void compress_block OF((deflate_state *s, ct_data *ltree,
|
||||||
ct_data *dtree));
|
ct_data *dtree));
|
||||||
local void set_data_type OF((deflate_state *s));
|
local int detect_data_type OF((deflate_state *s));
|
||||||
local unsigned bi_reverse OF((unsigned value, int length));
|
local unsigned bi_reverse OF((unsigned value, int length));
|
||||||
local void bi_windup OF((deflate_state *s));
|
local void bi_windup OF((deflate_state *s));
|
||||||
local void bi_flush OF((deflate_state *s));
|
local void bi_flush OF((deflate_state *s));
|
||||||
|
@ -203,12 +204,12 @@ local void send_bits(s, value, length)
|
||||||
* unused bits in value.
|
* unused bits in value.
|
||||||
*/
|
*/
|
||||||
if (s->bi_valid > (int)Buf_size - length) {
|
if (s->bi_valid > (int)Buf_size - length) {
|
||||||
s->bi_buf |= (value << s->bi_valid);
|
s->bi_buf |= (ush)value << s->bi_valid;
|
||||||
put_short(s, s->bi_buf);
|
put_short(s, s->bi_buf);
|
||||||
s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
|
s->bi_buf = (ush)value >> (Buf_size - s->bi_valid);
|
||||||
s->bi_valid += length - Buf_size;
|
s->bi_valid += length - Buf_size;
|
||||||
} else {
|
} else {
|
||||||
s->bi_buf |= value << s->bi_valid;
|
s->bi_buf |= (ush)value << s->bi_valid;
|
||||||
s->bi_valid += length;
|
s->bi_valid += length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,12 +219,12 @@ local void send_bits(s, value, length)
|
||||||
{ int len = length;\
|
{ int len = length;\
|
||||||
if (s->bi_valid > (int)Buf_size - len) {\
|
if (s->bi_valid > (int)Buf_size - len) {\
|
||||||
int val = value;\
|
int val = value;\
|
||||||
s->bi_buf |= (val << s->bi_valid);\
|
s->bi_buf |= (ush)val << s->bi_valid;\
|
||||||
put_short(s, s->bi_buf);\
|
put_short(s, s->bi_buf);\
|
||||||
s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
|
s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\
|
||||||
s->bi_valid += len - Buf_size;\
|
s->bi_valid += len - Buf_size;\
|
||||||
} else {\
|
} else {\
|
||||||
s->bi_buf |= (value) << s->bi_valid;\
|
s->bi_buf |= (ush)(value) << s->bi_valid;\
|
||||||
s->bi_valid += len;\
|
s->bi_valid += len;\
|
||||||
}\
|
}\
|
||||||
}
|
}
|
||||||
|
@ -250,11 +251,13 @@ local void tr_static_init()
|
||||||
if (static_init_done) return;
|
if (static_init_done) return;
|
||||||
|
|
||||||
/* For some embedded targets, global variables are not initialized: */
|
/* For some embedded targets, global variables are not initialized: */
|
||||||
|
#ifdef NO_INIT_GLOBAL_POINTERS
|
||||||
static_l_desc.static_tree = static_ltree;
|
static_l_desc.static_tree = static_ltree;
|
||||||
static_l_desc.extra_bits = extra_lbits;
|
static_l_desc.extra_bits = extra_lbits;
|
||||||
static_d_desc.static_tree = static_dtree;
|
static_d_desc.static_tree = static_dtree;
|
||||||
static_d_desc.extra_bits = extra_dbits;
|
static_d_desc.extra_bits = extra_dbits;
|
||||||
static_bl_desc.extra_bits = extra_blbits;
|
static_bl_desc.extra_bits = extra_blbits;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Initialize the mapping length (0..255) -> length code (0..28) */
|
/* Initialize the mapping length (0..255) -> length code (0..28) */
|
||||||
length = 0;
|
length = 0;
|
||||||
|
@ -348,13 +351,14 @@ void gen_trees_header()
|
||||||
static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
|
static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n");
|
fprintf(header, "const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n");
|
||||||
for (i = 0; i < DIST_CODE_LEN; i++) {
|
for (i = 0; i < DIST_CODE_LEN; i++) {
|
||||||
fprintf(header, "%2u%s", _dist_code[i],
|
fprintf(header, "%2u%s", _dist_code[i],
|
||||||
SEPARATOR(i, DIST_CODE_LEN-1, 20));
|
SEPARATOR(i, DIST_CODE_LEN-1, 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
|
fprintf(header,
|
||||||
|
"const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
|
||||||
for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
|
for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
|
||||||
fprintf(header, "%2u%s", _length_code[i],
|
fprintf(header, "%2u%s", _length_code[i],
|
||||||
SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
|
SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
|
||||||
|
@ -379,7 +383,7 @@ void gen_trees_header()
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Initialize the tree data structures for a new zlib stream.
|
* Initialize the tree data structures for a new zlib stream.
|
||||||
*/
|
*/
|
||||||
void _tr_init(s)
|
void ZLIB_INTERNAL _tr_init(s)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
{
|
{
|
||||||
tr_static_init();
|
tr_static_init();
|
||||||
|
@ -864,13 +868,13 @@ local void send_all_trees(s, lcodes, dcodes, blcodes)
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Send a stored block
|
* Send a stored block
|
||||||
*/
|
*/
|
||||||
void _tr_stored_block(s, buf, stored_len, eof)
|
void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
charf *buf; /* input block */
|
charf *buf; /* input block */
|
||||||
ulg stored_len; /* length of input block */
|
ulg stored_len; /* length of input block */
|
||||||
int eof; /* true if this is the last block for a file */
|
int last; /* one if this is the last block for a file */
|
||||||
{
|
{
|
||||||
send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
|
send_bits(s, (STORED_BLOCK<<1)+last, 3); /* send block type */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
|
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
|
||||||
s->compressed_len += (stored_len + 4) << 3;
|
s->compressed_len += (stored_len + 4) << 3;
|
||||||
|
@ -889,7 +893,7 @@ void _tr_stored_block(s, buf, stored_len, eof)
|
||||||
* To simplify the code, we assume the worst case of last real code encoded
|
* To simplify the code, we assume the worst case of last real code encoded
|
||||||
* on one bit only.
|
* on one bit only.
|
||||||
*/
|
*/
|
||||||
void _tr_align(s)
|
void ZLIB_INTERNAL _tr_align(s)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
{
|
{
|
||||||
send_bits(s, STATIC_TREES<<1, 3);
|
send_bits(s, STATIC_TREES<<1, 3);
|
||||||
|
@ -918,11 +922,11 @@ void _tr_align(s)
|
||||||
* Determine the best encoding for the current block: dynamic trees, static
|
* Determine the best encoding for the current block: dynamic trees, static
|
||||||
* trees or store, and output the encoded block to the zip file.
|
* trees or store, and output the encoded block to the zip file.
|
||||||
*/
|
*/
|
||||||
void _tr_flush_block(s, buf, stored_len, eof)
|
void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
charf *buf; /* input block, or NULL if too old */
|
charf *buf; /* input block, or NULL if too old */
|
||||||
ulg stored_len; /* length of input block */
|
ulg stored_len; /* length of input block */
|
||||||
int eof; /* true if this is the last block for a file */
|
int last; /* one if this is the last block for a file */
|
||||||
{
|
{
|
||||||
ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
|
ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
|
||||||
int max_blindex = 0; /* index of last bit length code of non zero freq */
|
int max_blindex = 0; /* index of last bit length code of non zero freq */
|
||||||
|
@ -931,8 +935,8 @@ void _tr_flush_block(s, buf, stored_len, eof)
|
||||||
if (s->level > 0) {
|
if (s->level > 0) {
|
||||||
|
|
||||||
/* Check if the file is binary or text */
|
/* Check if the file is binary or text */
|
||||||
if (stored_len > 0 && s->strm->data_type == Z_UNKNOWN)
|
if (s->strm->data_type == Z_UNKNOWN)
|
||||||
set_data_type(s);
|
s->strm->data_type = detect_data_type(s);
|
||||||
|
|
||||||
/* Construct the literal and distance trees */
|
/* Construct the literal and distance trees */
|
||||||
build_tree(s, (tree_desc *)(&(s->l_desc)));
|
build_tree(s, (tree_desc *)(&(s->l_desc)));
|
||||||
|
@ -978,20 +982,20 @@ void _tr_flush_block(s, buf, stored_len, eof)
|
||||||
* successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
|
* successful. If LIT_BUFSIZE <= WSIZE, it is never too late to
|
||||||
* transform a block into a stored block.
|
* transform a block into a stored block.
|
||||||
*/
|
*/
|
||||||
_tr_stored_block(s, buf, stored_len, eof);
|
_tr_stored_block(s, buf, stored_len, last);
|
||||||
|
|
||||||
#ifdef FORCE_STATIC
|
#ifdef FORCE_STATIC
|
||||||
} else if (static_lenb >= 0) { /* force static trees */
|
} else if (static_lenb >= 0) { /* force static trees */
|
||||||
#else
|
#else
|
||||||
} else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
|
} else if (s->strategy == Z_FIXED || static_lenb == opt_lenb) {
|
||||||
#endif
|
#endif
|
||||||
send_bits(s, (STATIC_TREES<<1)+eof, 3);
|
send_bits(s, (STATIC_TREES<<1)+last, 3);
|
||||||
compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
|
compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
s->compressed_len += 3 + s->static_len;
|
s->compressed_len += 3 + s->static_len;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
send_bits(s, (DYN_TREES<<1)+eof, 3);
|
send_bits(s, (DYN_TREES<<1)+last, 3);
|
||||||
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
|
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
|
||||||
max_blindex+1);
|
max_blindex+1);
|
||||||
compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
|
compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
|
||||||
|
@ -1005,21 +1009,21 @@ void _tr_flush_block(s, buf, stored_len, eof)
|
||||||
*/
|
*/
|
||||||
init_block(s);
|
init_block(s);
|
||||||
|
|
||||||
if (eof) {
|
if (last) {
|
||||||
bi_windup(s);
|
bi_windup(s);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
s->compressed_len += 7; /* align on byte boundary */
|
s->compressed_len += 7; /* align on byte boundary */
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
|
Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
|
||||||
s->compressed_len-7*eof));
|
s->compressed_len-7*last));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Save the match info and tally the frequency counts. Return true if
|
* Save the match info and tally the frequency counts. Return true if
|
||||||
* the current block must be flushed.
|
* the current block must be flushed.
|
||||||
*/
|
*/
|
||||||
int _tr_tally (s, dist, lc)
|
int ZLIB_INTERNAL _tr_tally (s, dist, lc)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
unsigned dist; /* distance of matched string */
|
unsigned dist; /* distance of matched string */
|
||||||
unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
|
unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
|
||||||
|
@ -1118,24 +1122,45 @@ local void compress_block(s, ltree, dtree)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
* Set the data type to BINARY or TEXT, using a crude approximation:
|
* Check if the data type is TEXT or BINARY, using the following algorithm:
|
||||||
* set it to Z_TEXT if all symbols are either printable characters (33 to 255)
|
* - TEXT if the two conditions below are satisfied:
|
||||||
* or white spaces (9 to 13, or 32); or set it to Z_BINARY otherwise.
|
* a) There are no non-portable control characters belonging to the
|
||||||
|
* "black list" (0..6, 14..25, 28..31).
|
||||||
|
* b) There is at least one printable character belonging to the
|
||||||
|
* "white list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255).
|
||||||
|
* - BINARY otherwise.
|
||||||
|
* - The following partially-portable control characters form a
|
||||||
|
* "gray list" that is ignored in this detection algorithm:
|
||||||
|
* (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}).
|
||||||
* IN assertion: the fields Freq of dyn_ltree are set.
|
* IN assertion: the fields Freq of dyn_ltree are set.
|
||||||
*/
|
*/
|
||||||
local void set_data_type(s)
|
local int detect_data_type(s)
|
||||||
deflate_state *s;
|
deflate_state *s;
|
||||||
{
|
{
|
||||||
|
/* black_mask is the bit mask of black-listed bytes
|
||||||
|
* set bits 0..6, 14..25, and 28..31
|
||||||
|
* 0xf3ffc07f = binary 11110011111111111100000001111111
|
||||||
|
*/
|
||||||
|
unsigned long black_mask = 0xf3ffc07fUL;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
for (n = 0; n < 9; n++)
|
/* Check for non-textual ("black-listed") bytes. */
|
||||||
|
for (n = 0; n <= 31; n++, black_mask >>= 1)
|
||||||
|
if ((black_mask & 1) && (s->dyn_ltree[n].Freq != 0))
|
||||||
|
return Z_BINARY;
|
||||||
|
|
||||||
|
/* Check for textual ("white-listed") bytes. */
|
||||||
|
if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0
|
||||||
|
|| s->dyn_ltree[13].Freq != 0)
|
||||||
|
return Z_TEXT;
|
||||||
|
for (n = 32; n < LITERALS; n++)
|
||||||
if (s->dyn_ltree[n].Freq != 0)
|
if (s->dyn_ltree[n].Freq != 0)
|
||||||
break;
|
return Z_TEXT;
|
||||||
if (n == 9)
|
|
||||||
for (n = 14; n < 32; n++)
|
/* There are no "black-listed" or "white-listed" bytes:
|
||||||
if (s->dyn_ltree[n].Freq != 0)
|
* this stream either is empty or has tolerated ("gray-listed") bytes only.
|
||||||
break;
|
*/
|
||||||
s->strm->data_type = (n == 32) ? Z_TEXT : Z_BINARY;
|
return Z_BINARY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===========================================================================
|
/* ===========================================================================
|
||||||
|
|
|
@ -70,7 +70,7 @@ local const ct_data static_dtree[D_CODES] = {
|
||||||
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
|
{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}}
|
||||||
};
|
};
|
||||||
|
|
||||||
const uch _dist_code[DIST_CODE_LEN] = {
|
const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {
|
||||||
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
|
0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8,
|
||||||
8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
|
8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||||
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
|
||||||
|
@ -99,7 +99,7 @@ const uch _dist_code[DIST_CODE_LEN] = {
|
||||||
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
|
29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29
|
||||||
};
|
};
|
||||||
|
|
||||||
const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {
|
const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12,
|
||||||
13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
|
13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16,
|
||||||
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
|
17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* uncompr.c -- decompress a memory buffer
|
/* uncompr.c -- decompress a memory buffer
|
||||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
* Copyright (C) 1995-2003, 2010 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -16,8 +16,6 @@
|
||||||
been saved previously by the compressor and transmitted to the decompressor
|
been saved previously by the compressor and transmitted to the decompressor
|
||||||
by some mechanism outside the scope of this compression library.)
|
by some mechanism outside the scope of this compression library.)
|
||||||
Upon exit, destLen is the actual size of the compressed buffer.
|
Upon exit, destLen is the actual size of the compressed buffer.
|
||||||
This function can be used to decompress a whole file at once if the
|
|
||||||
input file is mmap'ed.
|
|
||||||
|
|
||||||
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
|
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
|
||||||
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
||||||
|
|
74
zlib/win32/zlib.def
Normal file
74
zlib/win32/zlib.def
Normal file
|
@ -0,0 +1,74 @@
|
||||||
|
LIBRARY
|
||||||
|
; zlib data compression library
|
||||||
|
|
||||||
|
EXPORTS
|
||||||
|
; basic functions
|
||||||
|
zlibVersion
|
||||||
|
deflate
|
||||||
|
deflateEnd
|
||||||
|
inflate
|
||||||
|
inflateEnd
|
||||||
|
; advanced functions
|
||||||
|
deflateSetDictionary
|
||||||
|
deflateCopy
|
||||||
|
deflateReset
|
||||||
|
deflateParams
|
||||||
|
deflateTune
|
||||||
|
deflateBound
|
||||||
|
deflatePrime
|
||||||
|
deflateSetHeader
|
||||||
|
inflateSetDictionary
|
||||||
|
inflateSync
|
||||||
|
inflateCopy
|
||||||
|
inflateReset
|
||||||
|
inflateReset2
|
||||||
|
inflatePrime
|
||||||
|
inflateMark
|
||||||
|
inflateGetHeader
|
||||||
|
inflateBack
|
||||||
|
inflateBackEnd
|
||||||
|
zlibCompileFlags
|
||||||
|
; utility functions
|
||||||
|
compress
|
||||||
|
compress2
|
||||||
|
compressBound
|
||||||
|
uncompress
|
||||||
|
gzopen
|
||||||
|
gzdopen
|
||||||
|
gzbuffer
|
||||||
|
gzsetparams
|
||||||
|
gzread
|
||||||
|
gzwrite
|
||||||
|
gzprintf
|
||||||
|
gzputs
|
||||||
|
gzgets
|
||||||
|
gzputc
|
||||||
|
gzgetc
|
||||||
|
gzungetc
|
||||||
|
gzflush
|
||||||
|
gzseek
|
||||||
|
gzrewind
|
||||||
|
gztell
|
||||||
|
gzoffset
|
||||||
|
gzeof
|
||||||
|
gzdirect
|
||||||
|
gzclose
|
||||||
|
gzclose_r
|
||||||
|
gzclose_w
|
||||||
|
gzerror
|
||||||
|
gzclearerr
|
||||||
|
; checksum functions
|
||||||
|
adler32
|
||||||
|
crc32
|
||||||
|
adler32_combine
|
||||||
|
crc32_combine
|
||||||
|
; various hacks, don't look :)
|
||||||
|
deflateInit_
|
||||||
|
deflateInit2_
|
||||||
|
inflateInit_
|
||||||
|
inflateInit2_
|
||||||
|
inflateBackInit_
|
||||||
|
zError
|
||||||
|
inflateSyncPoint
|
||||||
|
get_crc_table
|
||||||
|
inflateUndermine
|
40
zlib/win32/zlib1.rc
Normal file
40
zlib/win32/zlib1.rc
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#include <winver.h>
|
||||||
|
#include "../zlib.h"
|
||||||
|
|
||||||
|
#ifdef GCC_WINDRES
|
||||||
|
VS_VERSION_INFO VERSIONINFO
|
||||||
|
#else
|
||||||
|
VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
||||||
|
#endif
|
||||||
|
FILEVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0
|
||||||
|
PRODUCTVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_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", ZLIB_VERSION "\0"
|
||||||
|
VALUE "InternalName", "zlib1.dll\0"
|
||||||
|
VALUE "LegalCopyright", "(C) 1995-2006 Jean-loup Gailly & Mark Adler\0"
|
||||||
|
VALUE "OriginalFilename", "zlib1.dll\0"
|
||||||
|
VALUE "ProductName", "zlib\0"
|
||||||
|
VALUE "ProductVersion", ZLIB_VERSION "\0"
|
||||||
|
VALUE "Comments", "For more information visit http://www.zlib.net/\0"
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x0409, 1252
|
||||||
|
END
|
||||||
|
END
|
206
zlib/zconf.h
206
zlib/zconf.h
|
@ -1,5 +1,5 @@
|
||||||
/* zconf.h -- configuration of the zlib compression library
|
/* zconf.h -- configuration of the zlib compression library
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
* Copyright (C) 1995-2010 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -11,52 +11,124 @@
|
||||||
/*
|
/*
|
||||||
* If you *really* need a unique prefix for all types and library functions,
|
* If you *really* need a unique prefix for all types and library functions,
|
||||||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||||
|
* Even better than compiling with -DZ_PREFIX would be to use configure to set
|
||||||
|
* this permanently in zconf.h using "./configure --zprefix".
|
||||||
*/
|
*/
|
||||||
#ifdef Z_PREFIX
|
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
|
||||||
# define deflateInit_ z_deflateInit_
|
|
||||||
# define deflate z_deflate
|
/* all linked symbols */
|
||||||
# define deflateEnd z_deflateEnd
|
# define _dist_code z__dist_code
|
||||||
# define inflateInit_ z_inflateInit_
|
# define _length_code z__length_code
|
||||||
# define inflate z_inflate
|
# define _tr_align z__tr_align
|
||||||
# define inflateEnd z_inflateEnd
|
# define _tr_flush_block z__tr_flush_block
|
||||||
# define deflateInit2_ z_deflateInit2_
|
# define _tr_init z__tr_init
|
||||||
# define deflateSetDictionary z_deflateSetDictionary
|
# define _tr_stored_block z__tr_stored_block
|
||||||
# define deflateCopy z_deflateCopy
|
# define _tr_tally z__tr_tally
|
||||||
# define deflateReset z_deflateReset
|
# define adler32 z_adler32
|
||||||
# define deflateParams z_deflateParams
|
# define adler32_combine z_adler32_combine
|
||||||
# define deflateBound z_deflateBound
|
# define adler32_combine64 z_adler32_combine64
|
||||||
# define deflatePrime z_deflatePrime
|
|
||||||
# define inflateInit2_ z_inflateInit2_
|
|
||||||
# define inflateSetDictionary z_inflateSetDictionary
|
|
||||||
# define inflateSync z_inflateSync
|
|
||||||
# define inflateSyncPoint z_inflateSyncPoint
|
|
||||||
# define inflateCopy z_inflateCopy
|
|
||||||
# define inflateReset z_inflateReset
|
|
||||||
# define inflateBack z_inflateBack
|
|
||||||
# define inflateBackEnd z_inflateBackEnd
|
|
||||||
# define compress z_compress
|
# define compress z_compress
|
||||||
# define compress2 z_compress2
|
# define compress2 z_compress2
|
||||||
# define compressBound z_compressBound
|
# define compressBound z_compressBound
|
||||||
# define uncompress z_uncompress
|
|
||||||
# define adler32 z_adler32
|
|
||||||
# define crc32 z_crc32
|
# define crc32 z_crc32
|
||||||
|
# define crc32_combine z_crc32_combine
|
||||||
|
# define crc32_combine64 z_crc32_combine64
|
||||||
|
# define deflate z_deflate
|
||||||
|
# define deflateBound z_deflateBound
|
||||||
|
# define deflateCopy z_deflateCopy
|
||||||
|
# define deflateEnd z_deflateEnd
|
||||||
|
# define deflateInit2_ z_deflateInit2_
|
||||||
|
# define deflateInit_ z_deflateInit_
|
||||||
|
# define deflateParams z_deflateParams
|
||||||
|
# define deflatePrime z_deflatePrime
|
||||||
|
# define deflateReset z_deflateReset
|
||||||
|
# define deflateSetDictionary z_deflateSetDictionary
|
||||||
|
# define deflateSetHeader z_deflateSetHeader
|
||||||
|
# define deflateTune z_deflateTune
|
||||||
|
# define deflate_copyright z_deflate_copyright
|
||||||
# define get_crc_table z_get_crc_table
|
# define get_crc_table z_get_crc_table
|
||||||
|
# define gz_error z_gz_error
|
||||||
|
# define gz_intmax z_gz_intmax
|
||||||
|
# define gz_strwinerror z_gz_strwinerror
|
||||||
|
# define gzbuffer z_gzbuffer
|
||||||
|
# define gzclearerr z_gzclearerr
|
||||||
|
# define gzclose z_gzclose
|
||||||
|
# define gzclose_r z_gzclose_r
|
||||||
|
# define gzclose_w z_gzclose_w
|
||||||
|
# define gzdirect z_gzdirect
|
||||||
|
# define gzdopen z_gzdopen
|
||||||
|
# define gzeof z_gzeof
|
||||||
|
# define gzerror z_gzerror
|
||||||
|
# define gzflush z_gzflush
|
||||||
|
# define gzgetc z_gzgetc
|
||||||
|
# define gzgets z_gzgets
|
||||||
|
# define gzoffset z_gzoffset
|
||||||
|
# define gzoffset64 z_gzoffset64
|
||||||
|
# define gzopen z_gzopen
|
||||||
|
# define gzopen64 z_gzopen64
|
||||||
|
# define gzprintf z_gzprintf
|
||||||
|
# define gzputc z_gzputc
|
||||||
|
# define gzputs z_gzputs
|
||||||
|
# define gzread z_gzread
|
||||||
|
# define gzrewind z_gzrewind
|
||||||
|
# define gzseek z_gzseek
|
||||||
|
# define gzseek64 z_gzseek64
|
||||||
|
# define gzsetparams z_gzsetparams
|
||||||
|
# define gztell z_gztell
|
||||||
|
# define gztell64 z_gztell64
|
||||||
|
# define gzungetc z_gzungetc
|
||||||
|
# define gzwrite z_gzwrite
|
||||||
|
# define inflate z_inflate
|
||||||
|
# define inflateBack z_inflateBack
|
||||||
|
# define inflateBackEnd z_inflateBackEnd
|
||||||
|
# define inflateBackInit_ z_inflateBackInit_
|
||||||
|
# define inflateCopy z_inflateCopy
|
||||||
|
# define inflateEnd z_inflateEnd
|
||||||
|
# define inflateGetHeader z_inflateGetHeader
|
||||||
|
# define inflateInit2_ z_inflateInit2_
|
||||||
|
# define inflateInit_ z_inflateInit_
|
||||||
|
# define inflateMark z_inflateMark
|
||||||
|
# define inflatePrime z_inflatePrime
|
||||||
|
# define inflateReset z_inflateReset
|
||||||
|
# define inflateReset2 z_inflateReset2
|
||||||
|
# define inflateSetDictionary z_inflateSetDictionary
|
||||||
|
# define inflateSync z_inflateSync
|
||||||
|
# define inflateSyncPoint z_inflateSyncPoint
|
||||||
|
# define inflateUndermine z_inflateUndermine
|
||||||
|
# define inflate_copyright z_inflate_copyright
|
||||||
|
# define inflate_fast z_inflate_fast
|
||||||
|
# define inflate_table z_inflate_table
|
||||||
|
# define uncompress z_uncompress
|
||||||
# define zError z_zError
|
# define zError z_zError
|
||||||
|
# define zcalloc z_zcalloc
|
||||||
|
# define zcfree z_zcfree
|
||||||
|
# define zlibCompileFlags z_zlibCompileFlags
|
||||||
|
# define zlibVersion z_zlibVersion
|
||||||
|
|
||||||
# define alloc_func z_alloc_func
|
/* all zlib typedefs in zlib.h and zconf.h */
|
||||||
# define free_func z_free_func
|
|
||||||
# define in_func z_in_func
|
|
||||||
# define out_func z_out_func
|
|
||||||
# define Byte z_Byte
|
# define Byte z_Byte
|
||||||
# define uInt z_uInt
|
|
||||||
# define uLong z_uLong
|
|
||||||
# define Bytef z_Bytef
|
# define Bytef z_Bytef
|
||||||
|
# define alloc_func z_alloc_func
|
||||||
# define charf z_charf
|
# define charf z_charf
|
||||||
|
# define free_func z_free_func
|
||||||
|
# define gzFile z_gzFile
|
||||||
|
# define gz_header z_gz_header
|
||||||
|
# define gz_headerp z_gz_headerp
|
||||||
|
# define in_func z_in_func
|
||||||
# define intf z_intf
|
# define intf z_intf
|
||||||
|
# define out_func z_out_func
|
||||||
|
# define uInt z_uInt
|
||||||
# define uIntf z_uIntf
|
# define uIntf z_uIntf
|
||||||
|
# define uLong z_uLong
|
||||||
# define uLongf z_uLongf
|
# define uLongf z_uLongf
|
||||||
# define voidpf z_voidpf
|
|
||||||
# define voidp z_voidp
|
# define voidp z_voidp
|
||||||
|
# define voidpc z_voidpc
|
||||||
|
# define voidpf z_voidpf
|
||||||
|
|
||||||
|
/* all zlib structs in zlib.h and zconf.h */
|
||||||
|
# define gz_header_s z_gz_header_s
|
||||||
|
# define internal_state z_internal_state
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||||
|
@ -284,49 +356,73 @@ typedef uLong FAR uLongf;
|
||||||
typedef Byte *voidp;
|
typedef Byte *voidp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
|
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
|
||||||
# include <sys/types.h> /* for off_t */
|
# define Z_HAVE_UNISTD_H
|
||||||
# include <unistd.h> /* for SEEK_* and off_t */
|
|
||||||
# ifdef VMS
|
|
||||||
# include <unixio.h> /* for off_t */
|
|
||||||
# endif
|
|
||||||
# define z_off_t off_t
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef STDC
|
||||||
|
# include <sys/types.h> /* for off_t */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
||||||
|
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
|
||||||
|
* though the former does not conform to the LFS document), but considering
|
||||||
|
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
||||||
|
* equivalently requesting no 64-bit operations
|
||||||
|
*/
|
||||||
|
#if -_LARGEFILE64_SOURCE - -1 == 1
|
||||||
|
# undef _LARGEFILE64_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
||||||
|
# include <unistd.h> /* for SEEK_* and off_t */
|
||||||
|
# ifdef VMS
|
||||||
|
# include <unixio.h> /* for off_t */
|
||||||
|
# endif
|
||||||
|
# ifndef z_off_t
|
||||||
|
# define z_off_t off_t
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef SEEK_SET
|
#ifndef SEEK_SET
|
||||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||||
# define SEEK_CUR 1 /* Seek from current position. */
|
# define SEEK_CUR 1 /* Seek from current position. */
|
||||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef z_off_t
|
#ifndef z_off_t
|
||||||
# define z_off_t long
|
# define z_off_t long
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
|
||||||
|
# define z_off64_t off64_t
|
||||||
|
#else
|
||||||
|
# define z_off64_t z_off_t
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__OS400__)
|
#if defined(__OS400__)
|
||||||
# define NO_vsnprintf
|
# define NO_vsnprintf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__MVS__)
|
#if defined(__MVS__)
|
||||||
# define NO_vsnprintf
|
# define NO_vsnprintf
|
||||||
# ifdef FAR
|
|
||||||
# undef FAR
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* MVS linker does not support external names larger than 8 bytes */
|
/* MVS linker does not support external names larger than 8 bytes */
|
||||||
#if defined(__MVS__)
|
#if defined(__MVS__)
|
||||||
# pragma map(deflateInit_,"DEIN")
|
#pragma map(deflateInit_,"DEIN")
|
||||||
# pragma map(deflateInit2_,"DEIN2")
|
#pragma map(deflateInit2_,"DEIN2")
|
||||||
# pragma map(deflateEnd,"DEEND")
|
#pragma map(deflateEnd,"DEEND")
|
||||||
# pragma map(deflateBound,"DEBND")
|
#pragma map(deflateBound,"DEBND")
|
||||||
# pragma map(inflateInit_,"ININ")
|
#pragma map(inflateInit_,"ININ")
|
||||||
# pragma map(inflateInit2_,"ININ2")
|
#pragma map(inflateInit2_,"ININ2")
|
||||||
# pragma map(inflateEnd,"INEND")
|
#pragma map(inflateEnd,"INEND")
|
||||||
# pragma map(inflateSync,"INSY")
|
#pragma map(inflateSync,"INSY")
|
||||||
# pragma map(inflateSetDictionary,"INSEDI")
|
#pragma map(inflateSetDictionary,"INSEDI")
|
||||||
# pragma map(compressBound,"CMBND")
|
#pragma map(compressBound,"CMBND")
|
||||||
# pragma map(inflate_table,"INTABL")
|
#pragma map(inflate_table,"INTABL")
|
||||||
# pragma map(inflate_fast,"INFA")
|
#pragma map(inflate_fast,"INFA")
|
||||||
# pragma map(inflate_copyright,"INCOPY")
|
#pragma map(inflate_copyright,"INCOPY")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* ZCONF_H */
|
#endif /* ZCONF_H */
|
||||||
|
|
332
zlib/zconf.in.h
332
zlib/zconf.in.h
|
@ -1,332 +0,0 @@
|
||||||
/* zconf.h -- configuration of the zlib compression library
|
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* @(#) $Id$ */
|
|
||||||
|
|
||||||
#ifndef ZCONF_H
|
|
||||||
#define ZCONF_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If you *really* need a unique prefix for all types and library functions,
|
|
||||||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
|
||||||
*/
|
|
||||||
#ifdef Z_PREFIX
|
|
||||||
# define deflateInit_ z_deflateInit_
|
|
||||||
# define deflate z_deflate
|
|
||||||
# define deflateEnd z_deflateEnd
|
|
||||||
# define inflateInit_ z_inflateInit_
|
|
||||||
# define inflate z_inflate
|
|
||||||
# define inflateEnd z_inflateEnd
|
|
||||||
# define deflateInit2_ z_deflateInit2_
|
|
||||||
# define deflateSetDictionary z_deflateSetDictionary
|
|
||||||
# define deflateCopy z_deflateCopy
|
|
||||||
# define deflateReset z_deflateReset
|
|
||||||
# define deflateParams z_deflateParams
|
|
||||||
# define deflateBound z_deflateBound
|
|
||||||
# define deflatePrime z_deflatePrime
|
|
||||||
# define inflateInit2_ z_inflateInit2_
|
|
||||||
# define inflateSetDictionary z_inflateSetDictionary
|
|
||||||
# define inflateSync z_inflateSync
|
|
||||||
# define inflateSyncPoint z_inflateSyncPoint
|
|
||||||
# define inflateCopy z_inflateCopy
|
|
||||||
# define inflateReset z_inflateReset
|
|
||||||
# define inflateBack z_inflateBack
|
|
||||||
# define inflateBackEnd z_inflateBackEnd
|
|
||||||
# define compress z_compress
|
|
||||||
# define compress2 z_compress2
|
|
||||||
# define compressBound z_compressBound
|
|
||||||
# define uncompress z_uncompress
|
|
||||||
# define adler32 z_adler32
|
|
||||||
# define crc32 z_crc32
|
|
||||||
# define get_crc_table z_get_crc_table
|
|
||||||
# define zError z_zError
|
|
||||||
|
|
||||||
# define alloc_func z_alloc_func
|
|
||||||
# define free_func z_free_func
|
|
||||||
# define in_func z_in_func
|
|
||||||
# define out_func z_out_func
|
|
||||||
# define Byte z_Byte
|
|
||||||
# define uInt z_uInt
|
|
||||||
# define uLong z_uLong
|
|
||||||
# define Bytef z_Bytef
|
|
||||||
# define charf z_charf
|
|
||||||
# define intf z_intf
|
|
||||||
# define uIntf z_uIntf
|
|
||||||
# define uLongf z_uLongf
|
|
||||||
# define voidpf z_voidpf
|
|
||||||
# define voidp z_voidp
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
|
||||||
# define MSDOS
|
|
||||||
#endif
|
|
||||||
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
|
|
||||||
# define OS2
|
|
||||||
#endif
|
|
||||||
#if defined(_WINDOWS) && !defined(WINDOWS)
|
|
||||||
# define WINDOWS
|
|
||||||
#endif
|
|
||||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
|
|
||||||
# ifndef WIN32
|
|
||||||
# define WIN32
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
|
|
||||||
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
|
|
||||||
# ifndef SYS16BIT
|
|
||||||
# define SYS16BIT
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
|
|
||||||
* than 64k bytes at a time (needed on systems with 16-bit int).
|
|
||||||
*/
|
|
||||||
#ifdef SYS16BIT
|
|
||||||
# define MAXSEG_64K
|
|
||||||
#endif
|
|
||||||
#ifdef MSDOS
|
|
||||||
# define UNALIGNED_OK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __STDC_VERSION__
|
|
||||||
# ifndef STDC
|
|
||||||
# define STDC
|
|
||||||
# endif
|
|
||||||
# if __STDC_VERSION__ >= 199901L
|
|
||||||
# ifndef STDC99
|
|
||||||
# define STDC99
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
|
|
||||||
# define STDC
|
|
||||||
#endif
|
|
||||||
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
|
|
||||||
# define STDC
|
|
||||||
#endif
|
|
||||||
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
|
|
||||||
# define STDC
|
|
||||||
#endif
|
|
||||||
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
|
|
||||||
# define STDC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
|
|
||||||
# define STDC
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef STDC
|
|
||||||
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
|
|
||||||
# define const /* note: need a more gentle solution here */
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Some Mac compilers merge all .h files incorrectly: */
|
|
||||||
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
|
|
||||||
# define NO_DUMMY_DECL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Maximum value for memLevel in deflateInit2 */
|
|
||||||
#ifndef MAX_MEM_LEVEL
|
|
||||||
# ifdef MAXSEG_64K
|
|
||||||
# define MAX_MEM_LEVEL 8
|
|
||||||
# else
|
|
||||||
# define MAX_MEM_LEVEL 9
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
|
||||||
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
|
||||||
* created by gzip. (Files created by minigzip can still be extracted by
|
|
||||||
* gzip.)
|
|
||||||
*/
|
|
||||||
#ifndef MAX_WBITS
|
|
||||||
# define MAX_WBITS 15 /* 32K LZ77 window */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The memory requirements for deflate are (in bytes):
|
|
||||||
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
|
||||||
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
|
||||||
plus a few kilobytes for small objects. For example, if you want to reduce
|
|
||||||
the default memory requirements from 256K to 128K, compile with
|
|
||||||
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
|
||||||
Of course this will generally degrade compression (there's no free lunch).
|
|
||||||
|
|
||||||
The memory requirements for inflate are (in bytes) 1 << windowBits
|
|
||||||
that is, 32K for windowBits=15 (default value) plus a few kilobytes
|
|
||||||
for small objects.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Type declarations */
|
|
||||||
|
|
||||||
#ifndef OF /* function prototypes */
|
|
||||||
# ifdef STDC
|
|
||||||
# define OF(args) args
|
|
||||||
# else
|
|
||||||
# define OF(args) ()
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The following definitions for FAR are needed only for MSDOS mixed
|
|
||||||
* model programming (small or medium model with some far allocations).
|
|
||||||
* This was tested only with MSC; for other MSDOS compilers you may have
|
|
||||||
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
|
||||||
* just define FAR to be empty.
|
|
||||||
*/
|
|
||||||
#ifdef SYS16BIT
|
|
||||||
# if defined(M_I86SM) || defined(M_I86MM)
|
|
||||||
/* MSC small or medium model */
|
|
||||||
# define SMALL_MEDIUM
|
|
||||||
# ifdef _MSC_VER
|
|
||||||
# define FAR _far
|
|
||||||
# else
|
|
||||||
# define FAR far
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# if (defined(__SMALL__) || defined(__MEDIUM__))
|
|
||||||
/* Turbo C small or medium model */
|
|
||||||
# define SMALL_MEDIUM
|
|
||||||
# ifdef __BORLANDC__
|
|
||||||
# define FAR _far
|
|
||||||
# else
|
|
||||||
# define FAR far
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(WINDOWS) || defined(WIN32)
|
|
||||||
/* If building or using zlib as a DLL, define ZLIB_DLL.
|
|
||||||
* This is not mandatory, but it offers a little performance increase.
|
|
||||||
*/
|
|
||||||
# ifdef ZLIB_DLL
|
|
||||||
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
|
|
||||||
# ifdef ZLIB_INTERNAL
|
|
||||||
# define ZEXTERN extern __declspec(dllexport)
|
|
||||||
# else
|
|
||||||
# define ZEXTERN extern __declspec(dllimport)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
# endif /* ZLIB_DLL */
|
|
||||||
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
|
|
||||||
* define ZLIB_WINAPI.
|
|
||||||
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
|
|
||||||
*/
|
|
||||||
# ifdef ZLIB_WINAPI
|
|
||||||
# ifdef FAR
|
|
||||||
# undef FAR
|
|
||||||
# endif
|
|
||||||
# include <windows.h>
|
|
||||||
/* No need for _export, use ZLIB.DEF instead. */
|
|
||||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
|
||||||
# define ZEXPORT WINAPI
|
|
||||||
# ifdef WIN32
|
|
||||||
# define ZEXPORTVA WINAPIV
|
|
||||||
# else
|
|
||||||
# define ZEXPORTVA FAR CDECL
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (__BEOS__)
|
|
||||||
# ifdef ZLIB_DLL
|
|
||||||
# ifdef ZLIB_INTERNAL
|
|
||||||
# define ZEXPORT __declspec(dllexport)
|
|
||||||
# define ZEXPORTVA __declspec(dllexport)
|
|
||||||
# else
|
|
||||||
# define ZEXPORT __declspec(dllimport)
|
|
||||||
# define ZEXPORTVA __declspec(dllimport)
|
|
||||||
# endif
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ZEXTERN
|
|
||||||
# define ZEXTERN extern
|
|
||||||
#endif
|
|
||||||
#ifndef ZEXPORT
|
|
||||||
# define ZEXPORT
|
|
||||||
#endif
|
|
||||||
#ifndef ZEXPORTVA
|
|
||||||
# define ZEXPORTVA
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FAR
|
|
||||||
# define FAR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(__MACTYPES__)
|
|
||||||
typedef unsigned char Byte; /* 8 bits */
|
|
||||||
#endif
|
|
||||||
typedef unsigned int uInt; /* 16 bits or more */
|
|
||||||
typedef unsigned long uLong; /* 32 bits or more */
|
|
||||||
|
|
||||||
#ifdef SMALL_MEDIUM
|
|
||||||
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
|
||||||
# define Bytef Byte FAR
|
|
||||||
#else
|
|
||||||
typedef Byte FAR Bytef;
|
|
||||||
#endif
|
|
||||||
typedef char FAR charf;
|
|
||||||
typedef int FAR intf;
|
|
||||||
typedef uInt FAR uIntf;
|
|
||||||
typedef uLong FAR uLongf;
|
|
||||||
|
|
||||||
#ifdef STDC
|
|
||||||
typedef void const *voidpc;
|
|
||||||
typedef void FAR *voidpf;
|
|
||||||
typedef void *voidp;
|
|
||||||
#else
|
|
||||||
typedef Byte const *voidpc;
|
|
||||||
typedef Byte FAR *voidpf;
|
|
||||||
typedef Byte *voidp;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
|
|
||||||
# include <sys/types.h> /* for off_t */
|
|
||||||
# include <unistd.h> /* for SEEK_* and off_t */
|
|
||||||
# ifdef VMS
|
|
||||||
# include <unixio.h> /* for off_t */
|
|
||||||
# endif
|
|
||||||
# define z_off_t off_t
|
|
||||||
#endif
|
|
||||||
#ifndef SEEK_SET
|
|
||||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
|
||||||
# define SEEK_CUR 1 /* Seek from current position. */
|
|
||||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
|
||||||
#endif
|
|
||||||
#ifndef z_off_t
|
|
||||||
# define z_off_t long
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__OS400__)
|
|
||||||
# define NO_vsnprintf
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__MVS__)
|
|
||||||
# define NO_vsnprintf
|
|
||||||
# ifdef FAR
|
|
||||||
# undef FAR
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* MVS linker does not support external names larger than 8 bytes */
|
|
||||||
#if defined(__MVS__)
|
|
||||||
# pragma map(deflateInit_,"DEIN")
|
|
||||||
# pragma map(deflateInit2_,"DEIN2")
|
|
||||||
# pragma map(deflateEnd,"DEEND")
|
|
||||||
# pragma map(deflateBound,"DEBND")
|
|
||||||
# pragma map(inflateInit_,"ININ")
|
|
||||||
# pragma map(inflateInit2_,"ININ2")
|
|
||||||
# pragma map(inflateEnd,"INEND")
|
|
||||||
# pragma map(inflateSync,"INSY")
|
|
||||||
# pragma map(inflateSetDictionary,"INSEDI")
|
|
||||||
# pragma map(compressBound,"CMBND")
|
|
||||||
# pragma map(inflate_table,"INTABL")
|
|
||||||
# pragma map(inflate_fast,"INFA")
|
|
||||||
# pragma map(inflate_copyright,"INCOPY")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* ZCONF_H */
|
|
66
zlib/zlib.3
66
zlib/zlib.3
|
@ -1,4 +1,4 @@
|
||||||
.TH ZLIB 3 "18 July 2005"
|
.TH ZLIB 3 "19 Apr 2010"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
zlib \- compression/decompression library
|
zlib \- compression/decompression library
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
@ -9,15 +9,15 @@ for full description]
|
||||||
The
|
The
|
||||||
.I zlib
|
.I zlib
|
||||||
library is a general purpose data compression library.
|
library is a general purpose data compression library.
|
||||||
The code is thread safe.
|
The code is thread safe, assuming that the standard library functions
|
||||||
|
used are thread safe, such as memory allocation routines.
|
||||||
It provides in-memory compression and decompression functions,
|
It provides in-memory compression and decompression functions,
|
||||||
including integrity checks of the uncompressed data.
|
including integrity checks of the uncompressed data.
|
||||||
This version of the library supports only one compression method (deflation)
|
This version of the library supports only one compression method (deflation)
|
||||||
but other algorithms will be added later
|
but other algorithms may be added later
|
||||||
and will have the same stream interface.
|
with the same stream interface.
|
||||||
.LP
|
.LP
|
||||||
Compression can be done in a single step if the buffers are large enough
|
Compression can be done in a single step if the buffers are large enough
|
||||||
(for example if an input file is mmap'ed),
|
|
||||||
or can be done by repeated calls of the compression function.
|
or can be done by repeated calls of the compression function.
|
||||||
In the latter case,
|
In the latter case,
|
||||||
the application must provide more input and/or consume the output
|
the application must provide more input and/or consume the output
|
||||||
|
@ -30,7 +30,7 @@ with an interface similar to that of stdio.
|
||||||
.LP
|
.LP
|
||||||
The library does not install any signal handler.
|
The library does not install any signal handler.
|
||||||
The decoder checks the consistency of the compressed data,
|
The decoder checks the consistency of the compressed data,
|
||||||
so the library should never crash even in case of corrupted input.
|
so the library should never crash even in the case of corrupted input.
|
||||||
.LP
|
.LP
|
||||||
All functions of the compression library are documented in the file
|
All functions of the compression library are documented in the file
|
||||||
.IR zlib.h .
|
.IR zlib.h .
|
||||||
|
@ -38,18 +38,19 @@ The distribution source includes examples of use of the library
|
||||||
in the files
|
in the files
|
||||||
.I example.c
|
.I example.c
|
||||||
and
|
and
|
||||||
.IR minigzip.c .
|
.IR minigzip.c,
|
||||||
|
as well as other examples in the
|
||||||
|
.IR examples/
|
||||||
|
directory.
|
||||||
.LP
|
.LP
|
||||||
Changes to this version are documented in the file
|
Changes to this version are documented in the file
|
||||||
.I ChangeLog
|
.I ChangeLog
|
||||||
that accompanies the source,
|
that accompanies the source.
|
||||||
and are concerned primarily with bug fixes and portability enhancements.
|
|
||||||
.LP
|
.LP
|
||||||
A Java implementation of
|
|
||||||
.I zlib
|
.I zlib
|
||||||
is available in the Java Development Kit 1.1:
|
is available in Java using the java.util.zip package:
|
||||||
.IP
|
.IP
|
||||||
http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html
|
http://java.sun.com/developer/technicalArticles/Programming/compression/
|
||||||
.LP
|
.LP
|
||||||
A Perl interface to
|
A Perl interface to
|
||||||
.IR zlib ,
|
.IR zlib ,
|
||||||
|
@ -57,7 +58,7 @@ written by Paul Marquess (pmqs@cpan.org),
|
||||||
is available at CPAN (Comprehensive Perl Archive Network) sites,
|
is available at CPAN (Comprehensive Perl Archive Network) sites,
|
||||||
including:
|
including:
|
||||||
.IP
|
.IP
|
||||||
http://www.cpan.org/modules/by-module/Compress/
|
http://search.cpan.org/~pmqs/IO-Compress-Zlib/
|
||||||
.LP
|
.LP
|
||||||
A Python interface to
|
A Python interface to
|
||||||
.IR zlib ,
|
.IR zlib ,
|
||||||
|
@ -66,14 +67,11 @@ is available in Python 1.5 and later versions:
|
||||||
.IP
|
.IP
|
||||||
http://www.python.org/doc/lib/module-zlib.html
|
http://www.python.org/doc/lib/module-zlib.html
|
||||||
.LP
|
.LP
|
||||||
A
|
|
||||||
.I zlib
|
.I zlib
|
||||||
binding for
|
is built into
|
||||||
.IR tcl (1),
|
.IR tcl:
|
||||||
written by Andreas Kupries (a.kupries@westend.com),
|
|
||||||
is availlable at:
|
|
||||||
.IP
|
.IP
|
||||||
http://www.westend.com/~kupries/doc/trf/man/man.html
|
http://wiki.tcl.tk/4610
|
||||||
.LP
|
.LP
|
||||||
An experimental package to read and write files in .zip format,
|
An experimental package to read and write files in .zip format,
|
||||||
written on top of
|
written on top of
|
||||||
|
@ -81,40 +79,34 @@ written on top of
|
||||||
by Gilles Vollant (info@winimage.com),
|
by Gilles Vollant (info@winimage.com),
|
||||||
is available at:
|
is available at:
|
||||||
.IP
|
.IP
|
||||||
http://www.winimage.com/zLibDll/unzip.html
|
http://www.winimage.com/zLibDll/minizip.html
|
||||||
and also in the
|
and also in the
|
||||||
.I contrib/minizip
|
.I contrib/minizip
|
||||||
directory of the main
|
directory of the main
|
||||||
.I zlib
|
.I zlib
|
||||||
web site.
|
source distribution.
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
The
|
The
|
||||||
.I zlib
|
.I zlib
|
||||||
web site can be found at either of these locations:
|
web site can be found at:
|
||||||
.IP
|
.IP
|
||||||
http://www.zlib.org
|
http://zlib.net/
|
||||||
.br
|
|
||||||
http://www.gzip.org/zlib/
|
|
||||||
.LP
|
.LP
|
||||||
The data format used by the zlib library is described by RFC
|
The data format used by the zlib library is described by RFC
|
||||||
(Request for Comments) 1950 to 1952 in the files:
|
(Request for Comments) 1950 to 1952 in the files:
|
||||||
.IP
|
.IP
|
||||||
http://www.ietf.org/rfc/rfc1950.txt (concerning zlib format)
|
http://www.ietf.org/rfc/rfc1950.txt (for the zlib header and trailer format)
|
||||||
.br
|
.br
|
||||||
http://www.ietf.org/rfc/rfc1951.txt (concerning deflate format)
|
http://www.ietf.org/rfc/rfc1951.txt (for the deflate compressed data format)
|
||||||
.br
|
.br
|
||||||
http://www.ietf.org/rfc/rfc1952.txt (concerning gzip format)
|
http://www.ietf.org/rfc/rfc1952.txt (for the gzip header and trailer format)
|
||||||
.LP
|
.LP
|
||||||
These documents are also available in other formats from:
|
Mark Nelson wrote an article about
|
||||||
.IP
|
|
||||||
ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html
|
|
||||||
.LP
|
|
||||||
Mark Nelson (markn@ieee.org) wrote an article about
|
|
||||||
.I zlib
|
.I zlib
|
||||||
for the Jan. 1997 issue of Dr. Dobb's Journal;
|
for the Jan. 1997 issue of Dr. Dobb's Journal;
|
||||||
a copy of the article is available at:
|
a copy of the article is available at:
|
||||||
.IP
|
.IP
|
||||||
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
|
http://marknelson.us/1997/01/01/zlib-engine/
|
||||||
.SH "REPORTING PROBLEMS"
|
.SH "REPORTING PROBLEMS"
|
||||||
Before reporting a problem,
|
Before reporting a problem,
|
||||||
please check the
|
please check the
|
||||||
|
@ -127,14 +119,14 @@ Please read the
|
||||||
.I zlib
|
.I zlib
|
||||||
FAQ at:
|
FAQ at:
|
||||||
.IP
|
.IP
|
||||||
http://www.gzip.org/zlib/zlib_faq.html
|
http://zlib.net/zlib_faq.html
|
||||||
.LP
|
.LP
|
||||||
before asking for help.
|
before asking for help.
|
||||||
Send questions and/or comments to zlib@gzip.org,
|
Send questions and/or comments to zlib@gzip.org,
|
||||||
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
|
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
Version 1.2.3
|
Version 1.2.5
|
||||||
Copyright (C) 1995-2005 Jean-loup Gailly (jloup@gzip.org)
|
Copyright (C) 1995-2010 Jean-loup Gailly (jloup@gzip.org)
|
||||||
and Mark Adler (madler@alumni.caltech.edu).
|
and Mark Adler (madler@alumni.caltech.edu).
|
||||||
.LP
|
.LP
|
||||||
This software is provided "as-is,"
|
This software is provided "as-is,"
|
||||||
|
|
BIN
zlib/zlib.3.pdf
Normal file
BIN
zlib/zlib.3.pdf
Normal file
Binary file not shown.
1152
zlib/zlib.h
1152
zlib/zlib.h
File diff suppressed because it is too large
Load diff
32
zlib/zutil.c
32
zlib/zutil.c
|
@ -1,5 +1,5 @@
|
||||||
/* zutil.c -- target dependent utility functions for the compression library
|
/* zutil.c -- target dependent utility functions for the compression library
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
* Copyright (C) 1995-2005, 2010 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -34,25 +34,25 @@ uLong ZEXPORT zlibCompileFlags()
|
||||||
uLong flags;
|
uLong flags;
|
||||||
|
|
||||||
flags = 0;
|
flags = 0;
|
||||||
switch (sizeof(uInt)) {
|
switch ((int)(sizeof(uInt))) {
|
||||||
case 2: break;
|
case 2: break;
|
||||||
case 4: flags += 1; break;
|
case 4: flags += 1; break;
|
||||||
case 8: flags += 2; break;
|
case 8: flags += 2; break;
|
||||||
default: flags += 3;
|
default: flags += 3;
|
||||||
}
|
}
|
||||||
switch (sizeof(uLong)) {
|
switch ((int)(sizeof(uLong))) {
|
||||||
case 2: break;
|
case 2: break;
|
||||||
case 4: flags += 1 << 2; break;
|
case 4: flags += 1 << 2; break;
|
||||||
case 8: flags += 2 << 2; break;
|
case 8: flags += 2 << 2; break;
|
||||||
default: flags += 3 << 2;
|
default: flags += 3 << 2;
|
||||||
}
|
}
|
||||||
switch (sizeof(voidpf)) {
|
switch ((int)(sizeof(voidpf))) {
|
||||||
case 2: break;
|
case 2: break;
|
||||||
case 4: flags += 1 << 4; break;
|
case 4: flags += 1 << 4; break;
|
||||||
case 8: flags += 2 << 4; break;
|
case 8: flags += 2 << 4; break;
|
||||||
default: flags += 3 << 4;
|
default: flags += 3 << 4;
|
||||||
}
|
}
|
||||||
switch (sizeof(z_off_t)) {
|
switch ((int)(sizeof(z_off_t))) {
|
||||||
case 2: break;
|
case 2: break;
|
||||||
case 4: flags += 1 << 6; break;
|
case 4: flags += 1 << 6; break;
|
||||||
case 8: flags += 2 << 6; break;
|
case 8: flags += 2 << 6; break;
|
||||||
|
@ -117,9 +117,9 @@ uLong ZEXPORT zlibCompileFlags()
|
||||||
# ifndef verbose
|
# ifndef verbose
|
||||||
# define verbose 0
|
# define verbose 0
|
||||||
# endif
|
# endif
|
||||||
int z_verbose = verbose;
|
int ZLIB_INTERNAL z_verbose = verbose;
|
||||||
|
|
||||||
void z_error (m)
|
void ZLIB_INTERNAL z_error (m)
|
||||||
char *m;
|
char *m;
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s\n", m);
|
fprintf(stderr, "%s\n", m);
|
||||||
|
@ -146,7 +146,7 @@ const char * ZEXPORT zError(err)
|
||||||
|
|
||||||
#ifndef HAVE_MEMCPY
|
#ifndef HAVE_MEMCPY
|
||||||
|
|
||||||
void zmemcpy(dest, source, len)
|
void ZLIB_INTERNAL zmemcpy(dest, source, len)
|
||||||
Bytef* dest;
|
Bytef* dest;
|
||||||
const Bytef* source;
|
const Bytef* source;
|
||||||
uInt len;
|
uInt len;
|
||||||
|
@ -157,7 +157,7 @@ void zmemcpy(dest, source, len)
|
||||||
} while (--len != 0);
|
} while (--len != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmemcmp(s1, s2, len)
|
int ZLIB_INTERNAL zmemcmp(s1, s2, len)
|
||||||
const Bytef* s1;
|
const Bytef* s1;
|
||||||
const Bytef* s2;
|
const Bytef* s2;
|
||||||
uInt len;
|
uInt len;
|
||||||
|
@ -170,7 +170,7 @@ int zmemcmp(s1, s2, len)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmemzero(dest, len)
|
void ZLIB_INTERNAL zmemzero(dest, len)
|
||||||
Bytef* dest;
|
Bytef* dest;
|
||||||
uInt len;
|
uInt len;
|
||||||
{
|
{
|
||||||
|
@ -213,7 +213,7 @@ local ptr_table table[MAX_PTR];
|
||||||
* a protected system like OS/2. Use Microsoft C instead.
|
* a protected system like OS/2. Use Microsoft C instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
|
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size)
|
||||||
{
|
{
|
||||||
voidpf buf = opaque; /* just to make some compilers happy */
|
voidpf buf = opaque; /* just to make some compilers happy */
|
||||||
ulg bsize = (ulg)items*size;
|
ulg bsize = (ulg)items*size;
|
||||||
|
@ -237,7 +237,7 @@ voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zcfree (voidpf opaque, voidpf ptr)
|
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
if (*(ush*)&ptr != 0) { /* object < 64K */
|
if (*(ush*)&ptr != 0) { /* object < 64K */
|
||||||
|
@ -272,13 +272,13 @@ void zcfree (voidpf opaque, voidpf ptr)
|
||||||
# define _hfree hfree
|
# define _hfree hfree
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
|
voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size)
|
||||||
{
|
{
|
||||||
if (opaque) opaque = 0; /* to make compiler happy */
|
if (opaque) opaque = 0; /* to make compiler happy */
|
||||||
return _halloc((long)items, size);
|
return _halloc((long)items, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zcfree (voidpf opaque, voidpf ptr)
|
void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr)
|
||||||
{
|
{
|
||||||
if (opaque) opaque = 0; /* to make compiler happy */
|
if (opaque) opaque = 0; /* to make compiler happy */
|
||||||
_hfree(ptr);
|
_hfree(ptr);
|
||||||
|
@ -297,7 +297,7 @@ extern voidp calloc OF((uInt items, uInt size));
|
||||||
extern void free OF((voidpf ptr));
|
extern void free OF((voidpf ptr));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
voidpf zcalloc (opaque, items, size)
|
voidpf ZLIB_INTERNAL zcalloc (opaque, items, size)
|
||||||
voidpf opaque;
|
voidpf opaque;
|
||||||
unsigned items;
|
unsigned items;
|
||||||
unsigned size;
|
unsigned size;
|
||||||
|
@ -307,7 +307,7 @@ voidpf zcalloc (opaque, items, size)
|
||||||
(voidpf)calloc(items, size);
|
(voidpf)calloc(items, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zcfree (opaque, ptr)
|
void ZLIB_INTERNAL zcfree (opaque, ptr)
|
||||||
voidpf opaque;
|
voidpf opaque;
|
||||||
voidpf ptr;
|
voidpf ptr;
|
||||||
{
|
{
|
||||||
|
|
63
zlib/zutil.h
63
zlib/zutil.h
|
@ -1,5 +1,5 @@
|
||||||
/* zutil.h -- internal interface and configuration of the compression library
|
/* zutil.h -- internal interface and configuration of the compression library
|
||||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
* Copyright (C) 1995-2010 Jean-loup Gailly.
|
||||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -13,31 +13,21 @@
|
||||||
#ifndef ZUTIL_H
|
#ifndef ZUTIL_H
|
||||||
#define ZUTIL_H
|
#define ZUTIL_H
|
||||||
|
|
||||||
#define ZLIB_INTERNAL
|
#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) && !defined(__MINGW32__)
|
||||||
|
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||||
|
#else
|
||||||
|
# define ZLIB_INTERNAL
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "zlib.h"
|
#include "zlib.h"
|
||||||
|
|
||||||
#ifdef STDC
|
#ifdef STDC
|
||||||
# ifndef _WIN32_WCE
|
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
|
||||||
# include <stddef.h>
|
# include <stddef.h>
|
||||||
# endif
|
# endif
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef NO_ERRNO_H
|
|
||||||
# ifdef _WIN32_WCE
|
|
||||||
/* The Microsoft C Run-Time Library for Windows CE doesn't have
|
|
||||||
* errno. We define it as a global variable to simplify porting.
|
|
||||||
* Its value is always 0 and should not be used. We rename it to
|
|
||||||
* avoid conflict with other libraries that use the same workaround.
|
|
||||||
*/
|
|
||||||
# define errno z_errno
|
|
||||||
# endif
|
|
||||||
extern int errno;
|
|
||||||
#else
|
|
||||||
# ifndef _WIN32_WCE
|
|
||||||
# include <errno.h>
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef local
|
#ifndef local
|
||||||
# define local static
|
# define local static
|
||||||
|
@ -89,7 +79,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
|
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
|
||||||
# define OS_CODE 0x00
|
# define OS_CODE 0x00
|
||||||
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
# if defined(__TURBOC__) || defined(__BORLANDC__)
|
||||||
# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
|
||||||
/* Allow compilation with ANSI keywords only enabled */
|
/* Allow compilation with ANSI keywords only enabled */
|
||||||
void _Cdecl farfree( void *block );
|
void _Cdecl farfree( void *block );
|
||||||
void *_Cdecl farmalloc( unsigned long nbytes );
|
void *_Cdecl farmalloc( unsigned long nbytes );
|
||||||
|
@ -118,7 +108,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
#ifdef OS2
|
#ifdef OS2
|
||||||
# define OS_CODE 0x06
|
# define OS_CODE 0x06
|
||||||
# ifdef M_I86
|
# ifdef M_I86
|
||||||
#include <malloc.h>
|
# include <malloc.h>
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -151,7 +141,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(_MSC_VER) && (_MSC_VER > 600))
|
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
|
||||||
# if defined(_WIN32_WCE)
|
# if defined(_WIN32_WCE)
|
||||||
# define fdopen(fd,mode) NULL /* No fdopen() */
|
# define fdopen(fd,mode) NULL /* No fdopen() */
|
||||||
# ifndef _PTRDIFF_T_DEFINED
|
# ifndef _PTRDIFF_T_DEFINED
|
||||||
|
@ -163,6 +153,18 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__BORLANDC__)
|
||||||
|
#pragma warn -8004
|
||||||
|
#pragma warn -8008
|
||||||
|
#pragma warn -8066
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* provide prototypes for these when building zlib without LFS */
|
||||||
|
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
|
||||||
|
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
|
||||||
|
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
|
||||||
|
#endif
|
||||||
|
|
||||||
/* common defaults */
|
/* common defaults */
|
||||||
|
|
||||||
#ifndef OS_CODE
|
#ifndef OS_CODE
|
||||||
|
@ -197,7 +199,9 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
# ifdef WIN32
|
# ifdef WIN32
|
||||||
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
|
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
|
||||||
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
|
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
|
||||||
# define vsnprintf _vsnprintf
|
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
|
||||||
|
# define vsnprintf _vsnprintf
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# ifdef __SASC
|
# ifdef __SASC
|
||||||
|
@ -232,16 +236,16 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
# define zmemzero(dest, len) memset(dest, 0, len)
|
# define zmemzero(dest, len) memset(dest, 0, len)
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
|
void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
|
||||||
extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
|
int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
|
||||||
extern void zmemzero OF((Bytef* dest, uInt len));
|
void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Diagnostic functions */
|
/* Diagnostic functions */
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
extern int z_verbose;
|
extern int ZLIB_INTERNAL z_verbose;
|
||||||
extern void z_error OF((char *m));
|
extern void ZLIB_INTERNAL z_error OF((char *m));
|
||||||
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
|
||||||
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
# define Trace(x) {if (z_verbose>=0) fprintf x ;}
|
||||||
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
# define Tracev(x) {if (z_verbose>0) fprintf x ;}
|
||||||
|
@ -258,8 +262,9 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
|
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
|
||||||
void zcfree OF((voidpf opaque, voidpf ptr));
|
unsigned size));
|
||||||
|
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
|
||||||
|
|
||||||
#define ZALLOC(strm, items, size) \
|
#define ZALLOC(strm, items, size) \
|
||||||
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
||||||
|
|
Loading…
Reference in a new issue