Compare commits

...
Sign in to create a new pull request.

201 commits

Author SHA1 Message Date
Vollstrecker
5a82f71ed1 Use generated zconf.h in cmake build.
This restores the inclusion of the local zconf.h (double quoted)
in normal usage.
2025-02-18 15:00:15 -08:00
Mark Adler
7108497fda Check that HAVE_UNISTD_H and HAVE_STDARG_H are not defined as 0. 2025-02-13 22:44:48 -08:00
Vollstrecker
00161eff1d Do not look for zconf.h in the source directory.
Temporary patch for cmake, but too violent. A better solution will
need to be found.
2025-02-13 11:51:26 -08:00
Mark Adler
8a844d434f Use zconf.h instead of zconf.h.in for cmake. 2025-02-06 17:16:52 -08:00
Vollstrecker
d20659fc74 Repair MinGW cmake build. 2025-02-06 16:23:45 -08:00
spectralio
0b29118367 Fix Ada bindings on x64. 2025-02-05 21:43:36 -08:00
Mark Adler
c715ad71fe Restore zconf.h to distribution. 2025-02-05 16:10:11 -08:00
Mark Adler
ed1610791c Revert previous commit, restoring the memcpy() call.
The reported issue was due to an error in their test code, not in
inflate. This use of memcpy() in inflate is correct.
2025-02-02 11:06:17 -08:00
Mark Adler
ab0266a362 Avoid use of memcpy() in inflate when areas can overlap. 2025-02-01 17:16:39 -08:00
Mark Adler
ec346f1c39 Update Makefile to not recreate zconf.h and zconf.h.cmakein.
Both were removed as zconf.h.cmakein is no longer needed, and
zconf.h is made from zconf.h.in.
2025-01-31 20:18:50 -08:00
Vollstrecker
61a56bcbb0 CMake: Make USE_FILE32API part of the interface. 2025-01-31 20:02:26 -08:00
Vollstrecker
4891d8185a CMake: Give minizip a suffix on Cygwin as well. 2025-01-31 20:02:26 -08:00
Vollstrecker
de4dea8007 CMake: Disable minizip on Cygwin. 2025-01-31 20:02:26 -08:00
Vollstrecker
953b3d79bf CMake: Correct workflow line continuation. 2025-01-31 20:02:26 -08:00
Vollstrecker
2c62f8885c CMake: Clean up spaces in required versions. 2025-01-31 20:02:26 -08:00
Vollstrecker
cdb3ab194c CMake: Correct workflow options to disable bzip2 on Windows.
Note that Vollstrecker hates yaml.
2025-01-31 20:02:26 -08:00
Vollstrecker
5a31e529bc CMake: Add the tested version of cmake (3.31).
Per @ClausKlein suggestion.
2025-01-31 20:02:26 -08:00
Vollstrecker
6c2ab4ddc6 CMake: Do not test with bzip2 on Windows or Cygwin. 2025-01-31 20:02:26 -08:00
Vollstrecker
05051d236b CMake: Install bzip2 on Cygwin in workflow. 2025-01-31 20:02:26 -08:00
Vollstrecker
5760ba1570 CMake: Correct runner.os to Linux. 2025-01-31 20:02:26 -08:00
Vollstrecker
c6d44927c5 CMake: Switch from make back to ninja.
Limit to one job.
2025-01-31 20:02:26 -08:00
Vollstrecker
63ded6faaf CMake: Install missing bzip2 in workflow. 2025-01-31 20:02:26 -08:00
Vollstrecker
1cac365fe4 CMake: Add make to Cygwin. 2025-01-31 20:02:26 -08:00
Vollstrecker
03449d49ba CMake: Re-enable testing with bzip2. 2025-01-31 20:02:26 -08:00
Vollstrecker
6c224f159e CMake: Change README-cmake to README-cmake.md with formatting.
Per @ClausKlein suggestion.
2025-01-31 20:02:26 -08:00
Vollstrecker
213998f2b0 CMake: Include bzip2 in the interface. 2025-01-31 20:02:26 -08:00
Vollstrecker
734f974753 CMake: Re-enable Cygwin tests without Ninja. 2025-01-31 20:02:26 -08:00
Vollstrecker
6925d39b50 CMake: Fix typo. 2025-01-31 20:02:26 -08:00
Vollstrecker
8b8a124eb4 CMake: Add cmake-format.yaml and reformat the cmake files. 2025-01-31 20:02:26 -08:00
Vollstrecker
4f2671d50c CMake: Remove unused variable. 2025-01-31 20:02:26 -08:00
Vollstrecker
00cbe1d6b1 CMake: Disable testing on Cygwin. 2025-01-31 20:02:26 -08:00
Vollstrecker
b9cf26c056 CMake: Increase CMake minimum version to 3.12.
For HOMPAGE_URL.
2025-01-31 20:02:26 -08:00
Vollstrecker
b8ae23d4c8 CMake: Disable bzip2 for tests.
It's not installed everywhere.
2025-01-31 20:02:26 -08:00
Vollstrecker
7667ca5593 CMake: Re-enable Cygwin and MSYS tests. 2025-01-31 20:02:26 -08:00
Vollstrecker
c31099862f CMake: Add one more alias for llvm-cov. 2025-01-31 20:02:26 -08:00
Vollstrecker
1be9392124 CMake: Add a README.cmake. 2025-01-31 20:02:26 -08:00
Vollstrecker
42a670ec20 CMake: Restore lost variable. 2025-01-31 20:02:26 -08:00
Vollstrecker
33b8e6f507 CMake: Rename option to ZLIB_INSTALL.
Not only the libraries are installed.
2025-01-31 20:02:26 -08:00
Vollstrecker
10a12ec427 CMake: Correct wording for minizip options. 2025-01-31 20:02:26 -08:00
Vollstrecker
abf7487d6c CMake: Add components selection. 2025-01-31 20:02:26 -08:00
Vollstrecker
e843c631d6 CMake: Refine tests. 2025-01-31 20:02:26 -08:00
Vollstrecker
d51255713b CMake: Do not link to bzip2. 2025-01-31 20:02:26 -08:00
Vollstrecker
8fee881981 CMake: Clean up formatting. 2025-01-31 20:02:26 -08:00
Vollstrecker
5fd63442f9 CMake: Search for zlib by CONFIG to get all needed targets. 2025-01-31 20:02:26 -08:00
Vollstrecker
62b5b4eff8 CMake: Make bzip2 required if it's requested. 2025-01-31 20:02:26 -08:00
Vollstrecker
f42008f5b4 CMake: Avoid double inclusion of CPack warning. 2025-01-31 20:02:26 -08:00
Vollstrecker
15a3751836 CMake: Order the includes consistently. 2025-01-31 20:02:26 -08:00
Vollstrecker
ede311d685 CMake: Make bzip2 optional. 2025-01-31 20:01:41 -08:00
Vollstrecker
d82da0fd15 CMake: Remove cmake out-of-tree test.
CMake is designed for that.
2025-01-31 20:01:41 -08:00
Vollstrecker
373bc1d7c5 CMake: Uncomment stop sign. 2025-01-31 20:01:41 -08:00
Vollstrecker
c99a4ae60f CMake: Depend on bzip2 only if it's found. 2025-01-31 20:01:41 -08:00
Vollstrecker
5a2ca3cb80 CMake: Add packaging to tests. 2025-01-31 20:01:41 -08:00
Vollstrecker
e573155946 CMake: Add CPack. 2025-01-31 20:01:41 -08:00
Vollstrecker
09b21ebd33 Correct one more comment style in minizip. 2025-01-31 20:01:41 -08:00
Vollstrecker
0263e58ad4 CMake: Prevent a 32-bit minizip build. 2025-01-31 20:01:41 -08:00
Vollstrecker
9d25fa340e Use consistent comment style in minizip. 2025-01-31 20:01:41 -08:00
Vollstrecker
e677f1f1c7 Disable make cover if no gcov was found. 2025-01-31 20:01:41 -08:00
Vollstrecker
039c3610e5 Remove -Werror from configure workflow. 2025-01-31 20:01:41 -08:00
Vollstrecker
2408dedfa5 Support clang without version suffix for coverage testing. 2025-01-31 20:01:41 -08:00
Vollstrecker
121e4168b9 CMake: Increase CMake version to 3.12 for minizip tests.
And look for ZLIB package.
2025-01-31 20:01:41 -08:00
Vollstrecker
44919160de Adjust coverage testing to the llvm gcov calling convention. 2025-01-31 19:59:10 -08:00
Vollstrecker
9ddf1b4bc5 CMake: Correct build directory for second workflow run. 2025-01-31 19:59:10 -08:00
Vollstrecker
a5db296ace CMake: Increase CMake version to 3.10 for tests.
And correct package name to ZLIB.
2025-01-31 19:59:10 -08:00
Vollstrecker
c9467bd5f8 Correct QEMU package name to qemu-system in workflow.
As in Ubuntu 24.04.
2025-01-31 19:59:10 -08:00
Vollstrecker
c7e9d282e7 CMake: Do just one build with -Werror in workflow. 2025-01-31 19:59:10 -08:00
Vollstrecker
1869359d44 CMake: Split the builds of infcover and minizip in workflow. 2025-01-31 19:59:10 -08:00
Vollstrecker
3b613563d3 CMake: Prefix coverage test name with zlib. 2025-01-31 19:59:10 -08:00
Vollstrecker
d80817ac95 CMake: Restore leading underscore in _LARGEFILE64_SOURCE. 2025-01-31 19:59:10 -08:00
Vollstrecker
0b9b43b45b Fix inflate coverage test in Makefile.in. 2025-01-31 19:59:10 -08:00
Vollstrecker
93457606bf CMake: Add inflate coverage test. 2025-01-31 19:59:10 -08:00
Vollstrecker
27198174ca CMake: Correct target to minizip. 2025-01-31 19:59:10 -08:00
Vollstrecker
d3ab1df503 CMake: Test minizip in the workflows. 2025-01-31 19:59:10 -08:00
Vollstrecker
5163cb6d3b CMake: Move testing into test/CMakeLists.txt.
Use the right environment to find the libraries.
2025-01-31 19:59:10 -08:00
Werner
99d41ee5c6 CMake: Make minizip search for config. 2025-01-31 19:59:10 -08:00
Werner
dfaf27b0c8 CMake: Change to FindZLIB and ZLIB.cmake. 2025-01-31 19:59:10 -08:00
Werner
5f98365bc9 CMake: Install ints.h for minizip. 2025-01-31 19:59:10 -08:00
Werner
aefb4b5b94 CMake: Rename exports of minizip.
minizip-ng has prior art.
2025-01-31 19:59:10 -08:00
Vollstrecker
5ff476ee43 CMake: Add minizip. 2025-01-31 19:59:10 -08:00
Vollstrecker
920385267f CMake: Fix parallel testing. 2025-01-31 19:59:10 -08:00
Vollstrecker
d7afcaa2be CMake: Shorten test names. 2025-01-31 19:59:10 -08:00
Vollstrecker
adb40de349 CMake: Indicate a clear signature in add_test. 2025-01-31 19:59:10 -08:00
Vollstrecker
cff14d5dc3 CMake: Use the full version number. 2025-01-31 19:59:10 -08:00
Vollstrecker
82665659ad CMake: Remove leading underscore from _LARGEFILE64_SOURCE. 2025-01-31 19:59:10 -08:00
Vollstrecker
a7c6dbf821 CMake: Detect visibility attribute in MSVC. 2025-01-31 19:59:10 -08:00
Vollstrecker
79d96ebdb7 CMake: Clear variable with unset. 2025-01-31 19:59:10 -08:00
Vollstrecker
b5c01971c2 CMake: Remove zconf.h.
zconf.h is always created by cmake and configure.
2025-01-31 19:59:10 -08:00
Vollstrecker
3d6dc3c3aa CMake: Create zconf.h from zconf.h.in.
Instead of zconf.h.cmakein, which is removed.
2025-01-31 19:59:10 -08:00
Vollstrecker
9e058e8443 CMake: Add option for ZLIB_PREFIX. 2025-01-31 19:59:10 -08:00
Vollstrecker
53c2727aaf CMake: Silence deprecation warning on the action runners. 2025-01-31 19:59:10 -08:00
Vollstrecker
15ba5055a9 CMake: Adapt pkgconfig-file to the GnuInstallDirs layout. 2025-01-31 19:59:10 -08:00
Vollstrecker
155d88378e CMake: Test static builds. 2025-01-31 19:59:10 -08:00
Vollstrecker
fd00a94838 CMake: Disable MinGW and Cygwin tests. 2025-01-31 19:59:10 -08:00
Vollstrecker
b74d77a0dd CMake: Install compatible DLL on MinGW. 2025-01-31 19:59:10 -08:00
Vollstrecker
e0b78cea4f CMake: Name the shared library cygz.dll on Cygwin. 2025-01-31 19:59:10 -08:00
Vollstrecker
494830e2df CMake: Remove use of ZLIB_BUILD_EXAMPLES option in workflow. 2025-01-31 19:59:10 -08:00
Vollstrecker
01ef679251 CMake: Pass CC and CFLAGS to the tests. 2025-01-31 19:59:10 -08:00
Vollstrecker
4d74e4498e CMake: Add the version to the exported configuration. 2025-01-31 19:59:10 -08:00
Vollstrecker
6084c550c3 CMake: Set the platform and configuration for the tests. 2025-01-31 19:59:10 -08:00
Vollstrecker
1fce5f2cdf CMake: Add more tests. 2025-01-31 19:59:10 -08:00
Vollstrecker
7dc2b78206 CMake: Add test for usage with find_package. 2025-01-31 19:59:10 -08:00
Vollstrecker
a794225144 CMake: Permit install to put different things in different places. 2025-01-31 19:59:10 -08:00
Vollstrecker
f4624f3f03 CMake: Add zlibExport. 2025-01-31 19:59:10 -08:00
Vollstrecker
e37a1a8345 CMake: Warn if no build-type is selected. 2025-01-31 19:59:10 -08:00
Vollstrecker
f7ab6e4373 CMake: Add aliases to match the export names. 2025-01-31 19:59:10 -08:00
Vollstrecker
f0175c69e2 CMake: Add INSTALL_INTERFACE for a proper export. 2025-01-31 19:59:10 -08:00
Vollstrecker
633ec87677 CMake: Add zlib1.rc to Cygwin build. 2025-01-31 19:59:10 -08:00
Vollstrecker
48b9ee48ca CMake: Use CMAKE_DEBUG_POSTFIX for simplification. 2025-01-31 19:59:10 -08:00
Vollstrecker
c33f3bc641 CMake: Move version setting for Cygwin into set_target_properties. 2025-01-31 19:59:10 -08:00
Vollstrecker
b6cb6f4c21 CMake: Rename examples to testing to reflect their intent. 2025-01-31 19:59:10 -08:00
Vollstrecker
c18815b630 CMake: Simplify to one install option.
What to install is chosen with components.
2025-01-31 19:59:10 -08:00
Vollstrecker
64e8307d6a CMake: Make formatting consistent. 2025-01-31 19:59:10 -08:00
Vollstrecker
ffbbe01b6d CMake: Remove allowance for unclosed constructs. 2025-01-31 19:59:10 -08:00
Vollstrecker
1af1bb6ce4 CMake: Let cmake handle zlib1.rc. 2025-01-31 19:59:10 -08:00
Vollstrecker
899ef97c4a CMake: Use the same definition we checked for off64_t.
Move to target_compile_definitions.
2025-01-31 19:59:10 -08:00
Vollstrecker
31d2462c1d CMake: Move compile_definitions to the targets. 2025-01-31 19:59:10 -08:00
Vollstrecker
feb7fd325a CMake: Remove doubled include directories. 2025-01-31 19:59:10 -08:00
Vollstrecker
902f6eedf3 CMake: Remove checks for sys/types.h, stdint.h and stddef.h.
This is done by check_type_size.
2025-01-31 19:59:10 -08:00
Vollstrecker
2b2eec69b5 CMake: Remove unneeded renaming for in-tree builds and the option for it. 2025-01-31 19:59:10 -08:00
Vollstrecker
6762467523 CMake: Rename examples and tests to avoid chain building confusion. 2025-01-31 19:58:40 -08:00
Vollstrecker
76c6a8601c CMake: Set version in project call.
Use variables set by it.
2025-01-31 07:41:44 -08:00
Vollstrecker
6628a10f14 CMake: Move versionscript block to zlib definition. 2025-01-31 07:41:44 -08:00
Vollstrecker
7f849d109f CMake: Bump minimum version. 2025-01-31 07:41:44 -08:00
Vollstrecker
ae5946e5d8 CMake: Add pdb install.
Adjust minimum required version for regex.
2025-01-31 07:41:44 -08:00
Vollstrecker
74247f0947 CMake: Install libs with static and debug suffix.
Add option to also install zlib1.ddl for compatibility.
2025-01-31 07:41:44 -08:00
Vollstrecker
ee00230f8e CMake: Switch to GNUInstallDirs. 2025-01-31 07:41:44 -08:00
Vollstrecker
b3907c2cd9 CMake: Add options for shared and static build. 2025-01-31 07:41:43 -08:00
Josh Varga
2359cd3d60 Add Bazel targets. 2025-01-21 23:29:35 -05:00
Mark Adler
71045aef60 Fix indent in infback.c. 2024-12-30 18:52:33 -08:00
Mark Adler
ef24c4c750 Reject invalid MAX_WBITS values at compile time. 2024-11-08 19:37:34 -08:00
AlexisWilke
6d3a66a11a Avoid attempting to redefine z_const in zconf.h. 2024-10-13 17:40:35 -07:00
Oscar Lesta
64191119d8 Add Haiku to configure for proper LDSHARED settings. 2024-10-07 07:28:11 -07:00
Mark Adler
d476828316 Repair github workflows for their updated macOS runner gcc name. 2024-09-01 13:35:20 -07:00
Mark Adler
f7d01aae6e Avoid out-of-bounds pointer arithmetic in inflateCopy().
Though it does not matter for code correctness, clang's UBSan
injects code that complains about computing a pointer from an array
where the result is out-of-bounds for that array, even though the
pointer is never dereferenced. Go figure. This commit avoids that
possibility when computing distcode in inflateCopy().
2024-09-01 13:17:29 -07:00
Mark Adler
2968a496d9 Remove unneeded dependency on limits.h in examples/zran.c. 2024-09-01 13:17:29 -07:00
Mark Adler
fff132fe7c Avoid the use of a reserved macro name in contrib/minizip/ioapi.h. 2024-09-01 13:16:26 -07:00
Mark Adler
545f194963 Add old gcc ULONG_LONG_MAX macro to find a 64-bit type in zutil.h. 2024-07-31 22:33:12 -07:00
Mark Adler
4cacc3562b Add header file dependencies to contrib/minizip/Makefile. 2024-07-31 22:32:56 -07:00
Mark Adler
be24a8f4ca Avoid use of stdint.h in contrib/minizip. 2024-07-31 22:32:47 -07:00
Mark Adler
164b8e3c9f Avoid use of uintmax_t in enough.c. 2024-07-29 14:30:50 -07:00
Meiye-lj
3f44e55d5d Add required gzguts.h dependencies in Makefile.in. 2024-07-29 00:37:16 -07:00
Mark Adler
ceadaf28df Fix test/infcover.c function prototype when ZLIB_CONST defined. 2024-07-11 09:22:47 -07:00
Mark Adler
3adaa095a7 One more correction for deflateUsed() bits in stored case. 2024-07-05 23:04:59 -05:00
Mark Adler
884e0c0809 Correct used bits from deflateUsed() for deflate_stored() case. 2024-07-05 00:48:56 -05:00
Mark Adler
e011d8c164 Add deflateUsed() function to get the used bits in the last byte.
This returns the number of used bits in the last byte of a stream
that has just been compressed with deflate.
2024-07-01 19:34:40 -05:00
Ram Shanker
534864bccd Add build folder to .gitignore.
A library is usually expected to be built in a folder /build at
its root. Whenever this repository is added as a submodule of
another project and compiled, git shows all the generated files as
changes. To suppress those git messages, this ignores the build
folder.
2024-06-28 23:03:38 -05:00
Mark Adler
7e6f0784cc Remedy conflict between libzip and minizip zip.h.
minizip.pc.in would add @include@/minizip to the include path,
which would permit simply #include <zip.h> to use minizip. However
that conflicts with the zip.h from libzip that is put in the root
include directory. This now does not add /minizip to the include
path. Now when using pkg-config, #include <minizip/zip.h> must be
used, where #include <zip.h> would be used for libzip. This is an
incompatible change with the previous state. Users of minizip and
pkg-config will need to update their code. #include <unzip.h> will
need to be updated to #include <minizip/unzip.h> as well.
2024-06-04 09:36:01 -07:00
Mark Adler
0f3b7b9595 Correct typo in zlib.h comment. 2024-05-16 19:07:00 -07:00
Matthieu Longo
1b70083bed Replace autotools macro AC_HELP_STRING with AS_HELP_STRING.
In minizip's configure.ac. AC_HELP_STRING is obsolete.
2024-04-29 18:14:17 -07:00
Lwisce Zeng
2ba25b2dda Use z_const for setting msg to literal strings. 2024-04-01 11:49:05 -07:00
Mark Adler
c5e87dcdef Make z_off_t 64 bits by default. 2024-03-31 16:34:43 -07:00
qyt
4f8a17e8cb Add -fPIC to compiler options for static library build on Android. 2024-03-29 18:36:16 -07:00
Mark Adler
0f51fb4933 Avert minizip warnings for MSVC. 2024-03-29 12:20:37 -07:00
Mark Adler
d201f04c72 Avoid conversion warning on 32-bit architectures in minizip. 2024-03-22 22:47:36 -07:00
Mark Adler
90c677bc25 Use long long offsets for MinGW. 2024-03-22 22:29:01 -07:00
Alexander Miller
f02ea29e5f Improve detection of UNIX-style systems in minizip.
Not all toolchains on UNIX-style operating systems predefine
"unix". For example, it's missing on NetBSD, OpenBSD/gcc, AIX,
HP-UX. There is no single macro defined everywhere, but checking
both "__unix__" and "__unix" should cover everything except macOS,
which is already checked for using "__APPLE__".

Note that case sensitivity should default to off on macOS and
cygwin, so the check there is different.
2024-03-16 11:18:50 -07:00
Mark Adler
9f418e1028 Update old comment in inflate.h. 2024-03-15 17:49:20 -07:00
Mark Adler
99b229487c Avoid signed shift in minizip zip.c. 2024-03-12 13:40:57 -07:00
Mark Adler
f60ce91139 Improve random number seeding in skipset.h. 2024-03-10 23:21:10 -07:00
Mark Adler
4a5e3e7d25 Add zipAlreadyThere() to minizip zip.c to help avoid duplicates. 2024-03-10 00:37:23 -08:00
Mark Adler
54e205f878 Permit changing minizip Makefile optimization with CFLAGS. 2024-03-09 23:53:44 -08:00
Mark Adler
a8c321be84 Make deflateBound() more conservative and handle Z_STREAM_END. 2024-03-09 23:53:37 -08:00
Mark Adler
72d6aa2672 Reduce Windows header inclusion to speed up compilation. 2024-02-28 18:46:54 -08:00
Mark Adler
6544c3ecb7 Use lseek under WinCE. 2024-02-13 08:00:40 -08:00
Mark Adler
35175f2c0e Remove conversion warning from msdos/Makefile.dj2. 2024-02-12 00:33:15 -08:00
Mark Adler
5c42a230b7 Correct argument types for 64-bit combine functions. 2024-02-11 15:42:08 -08:00
Mark Adler
04134633fa Use 64-bit offsets in DJGPP. 2024-02-11 15:37:46 -08:00
Mark Adler
c983609168 Include unistd.h on DJGPP. 2024-02-10 20:06:15 -08:00
pmqs
0e95839324 Add github workflow to build with all available C standards. 2024-02-10 10:33:23 -08:00
pmqs
d9243a0f06 Add warnings and error on warning to configure and cmake tests. 2024-02-10 09:27:55 -08:00
Mark Adler
fd5fe8b17e Further address Microsoft deprecation warnings. 2024-02-09 20:11:54 -08:00
Mark Adler
ceac32f156 Keep lines short in gzread.c. 2024-02-09 20:11:39 -08:00
Mark Adler
1bff6f0fd5 Avoid signedness change warning in test/minigzip.c. 2024-02-09 20:11:39 -08:00
Mark Adler
7a7202de35 Correct a variable type in deflate.c. 2024-02-09 20:11:18 -08:00
Mark Adler
3c13497a61 One more github actions version update. 2024-02-09 09:33:54 -08:00
Mark Adler
76156087c8 Update github actions versions. 2024-02-09 09:23:11 -08:00
Mark Adler
25740f4ad5 Include share.h on Windows for _SH_DENYNO. 2024-02-09 08:27:07 -08:00
Mark Adler
985a62d118 Address Microsoft deprecation warnings. 2024-02-08 18:45:49 -08:00
Justin Dhillon
504403f3e4 Fix broken links. 2024-02-07 15:35:51 -08:00
Mark Adler
81e7c38608 Correct printf formats in test/infcover.c to %zu. 2024-02-07 14:38:57 -08:00
Mark Adler
96d3e9e3dd Expand on the deflate strategy parameter in zlib.h. 2024-02-07 10:48:55 -08:00
Mark Adler
e342bb3dae Assume no snprintf() or vsnprintf() if C89/90 in gzguts.h.
Those functions were introduced in C99. However it is assumed that
they are there if under Windows, since Visual C claims C89/90, but
does have those functions, or variants.
2024-02-06 18:27:44 -08:00
Mark Adler
915a3d5b7b Avoid use of snprintf() in test/minigzip.c.
It was being used only as a safe version of strcpy(). Instead, use
a safe alternative to strcpy().
2024-02-06 18:27:31 -08:00
Mark Adler
1382e66114 Use _POSIX_C_SOURCE in gzguts.h, instead of _POSIX_SOURCE. 2024-02-06 18:27:24 -08:00
Paul Marquess
4b98fd39c8 Enable fileno() for POSIX system in minigzip.c. 2024-02-05 23:51:31 -08:00
Mark Adler
abd3d1a289 Update zran version. 2024-02-04 18:51:31 -08:00
Mark Adler
037bca67fd Allocate the dictionaries in examples/zran.c.
This reduces the memory needed for dictionaries, and avoids the
need to reallocate the index at the end to return unused memory.
2024-02-04 18:51:14 -08:00
Mark Adler
6378d33478 Provide a reusable inflate engine in the index in example/zran.c.
Avoids the overhead of creating a new inflate engine for each
random access extraction.
2024-02-04 18:49:40 -08:00
Mark Adler
bb054d95d0 Stop decoding in zran.c once request is satisfied. 2024-02-04 18:49:40 -08:00
Mark Adler
be4db0a79a Set returned index to NULL on an index build error in zran.c.
An attempt to use the returned pointer in deflate_index_extract()
will now return cleanly with an error. The returned pointer can
now also be used with deflate_index_free() even on error.
2024-02-04 18:48:30 -08:00
Mark Adler
f1f503da85 Fix cmake build directory interference issue. 2024-01-28 21:50:26 -08:00
Mark Adler
b14484997a Fix version numbers in vstudio definition files.
They can only have a major and a minor version.
2024-01-28 12:54:11 -08:00
Mark Adler
31d3dd4306 Update copyright years in LICENSE file. 2024-01-24 14:46:09 -08:00
Aleksei Shpakovskii
04ca30003f Enable build of shared library on AIX. 2024-01-23 18:21:05 -08:00
Mark Adler
f56ad0aafa Note termination of returned strings in contrib/minizip/unzip.h. 2024-01-23 12:00:26 -08:00
Mark Adler
b289a50fc5 Ignore unknown options in configure. 2024-01-23 10:59:41 -08:00
Levi Broderick
8a76f02e0e Avoid implicit conversion warnings in deflate.c and trees.c. 2024-01-23 08:45:00 -08:00
Tomas Berger
df3b265064 Add option to CMakeLists.txt to disable renaming of zconf.h. 2024-01-23 08:39:24 -08:00
Mark Adler
d4eaa1d939 Avoid unterminated file name in contrib/minizip/miniunz.c. 2024-01-23 08:19:24 -08:00
Mark Adler
da5937705d Permit compiling contrib/minizip/unzip.c with decryption. 2024-01-23 08:02:38 -08:00
Cameron Cawley
4de0b054a5 Improve portability to RISC OS. 2024-01-23 06:27:49 -08:00
Mark Adler
9f0f2d4f9f Change version number on develop branch to 1.3.1.1. 2024-01-22 13:07:41 -08:00
109 changed files with 4323 additions and 2068 deletions

245
.cmake-format.yaml Normal file
View file

@ -0,0 +1,245 @@
_help_parse: Options affecting listfile parsing
parse:
_help_additional_commands:
- Specify structure for custom cmake functions
additional_commands:
foo:
flags:
- BAR
- BAZ
kwargs:
HEADERS: '*'
SOURCES: '*'
DEPENDS: '*'
_help_override_spec:
- Override configurations per-command where available
override_spec: {}
_help_vartags:
- Specify variable tags.
vartags: []
_help_proptags:
- Specify property tags.
proptags: []
_help_format: Options affecting formatting.
format:
_help_disable:
- Disable formatting entirely, making cmake-format a no-op
disable: false
_help_line_width:
- How wide to allow formatted cmake files
line_width: 80
_help_tab_size:
- How many spaces to tab for indent
tab_size: 4
_help_use_tabchars:
- If true, lines are indented using tab characters (utf-8
- 0x09) instead of <tab_size> space characters (utf-8 0x20).
- In cases where the layout would require a fractional tab
- character, the behavior of the fractional indentation is
- governed by <fractional_tab_policy>
use_tabchars: false
_help_fractional_tab_policy:
- If <use_tabchars> is True, then the value of this variable
- indicates how fractional indentions are handled during
- whitespace replacement. If set to 'use-space', fractional
- indentation is left as spaces (utf-8 0x20). If set to
- '`round-up` fractional indentation is replaced with a single'
- tab character (utf-8 0x09) effectively shifting the column
- to the next tabstop
fractional_tab_policy: use-space
_help_max_subgroups_hwrap:
- If an argument group contains more than this many sub-groups
- (parg or kwarg groups) then force it to a vertical layout.
max_subgroups_hwrap: 2
_help_max_pargs_hwrap:
- If a positional argument group contains more than this many
- arguments, then force it to a vertical layout.
max_pargs_hwrap: 6
_help_max_rows_cmdline:
- If a cmdline positional group consumes more than this many
- lines without nesting, then invalidate the layout (and nest)
max_rows_cmdline: 2
_help_separate_ctrl_name_with_space:
- If true, separate flow control names from their parentheses
- with a space
separate_ctrl_name_with_space: false
_help_separate_fn_name_with_space:
- If true, separate function names from parentheses with a
- space
separate_fn_name_with_space: false
_help_dangle_parens:
- If a statement is wrapped to more than one line, than dangle
- the closing parenthesis on its own line.
dangle_parens: false
_help_dangle_align:
- If the trailing parenthesis must be 'dangled' on its on
- 'line, then align it to this reference: `prefix`: the start'
- 'of the statement, `prefix-indent`: the start of the'
- 'statement, plus one indentation level, `child`: align to'
- the column of the arguments
dangle_align: prefix
_help_min_prefix_chars:
- If the statement spelling length (including space and
- parenthesis) is smaller than this amount, then force reject
- nested layouts.
min_prefix_chars: 4
_help_max_prefix_chars:
- If the statement spelling length (including space and
- parenthesis) is larger than the tab width by more than this
- amount, then force reject un-nested layouts.
max_prefix_chars: 10
_help_max_lines_hwrap:
- If a candidate layout is wrapped horizontally but it exceeds
- this many lines, then reject the layout.
max_lines_hwrap: 2
_help_line_ending:
- What style line endings to use in the output.
line_ending: unix
_help_command_case:
- Format command names consistently as 'lower' or 'upper' case
command_case: canonical
_help_keyword_case:
- Format keywords consistently as 'lower' or 'upper' case
keyword_case: unchanged
_help_always_wrap:
- A list of command names which should always be wrapped
always_wrap: []
_help_enable_sort:
- If true, the argument lists which are known to be sortable
- will be sorted lexicographicall
enable_sort: true
_help_autosort:
- If true, the parsers may infer whether or not an argument
- list is sortable (without annotation).
autosort: false
_help_require_valid_layout:
- By default, if cmake-format cannot successfully fit
- everything into the desired linewidth it will apply the
- last, most aggressive attempt that it made. If this flag is
- True, however, cmake-format will print error, exit with non-
- zero status code, and write-out nothing
require_valid_layout: false
_help_layout_passes:
- A dictionary mapping layout nodes to a list of wrap
- decisions. See the documentation for more information.
layout_passes: {}
_help_markup: Options affecting comment reflow and formatting.
markup:
_help_bullet_char:
- What character to use for bulleted lists
bullet_char: '*'
_help_enum_char:
- What character to use as punctuation after numerals in an
- enumerated list
enum_char: .
_help_first_comment_is_literal:
- If comment markup is enabled, don't reflow the first comment
- block in each listfile. Use this to preserve formatting of
- your copyright/license statements.
first_comment_is_literal: false
_help_literal_comment_pattern:
- If comment markup is enabled, don't reflow any comment block
- which matches this (regex) pattern. Default is `None`
- (disabled).
literal_comment_pattern: null
_help_fence_pattern:
- Regular expression to match preformat fences in comments
- default= ``r'^\s*([`~]{3}[`~]*)(.*)$'``
fence_pattern: ^\s*([`~]{3}[`~]*)(.*)$
_help_ruler_pattern:
- Regular expression to match rulers in comments default=
- '``r''^\s*[^\w\s]{3}.*[^\w\s]{3}$''``'
ruler_pattern: ^\s*[^\w\s]{3}.*[^\w\s]{3}$
_help_explicit_trailing_pattern:
- If a comment line matches starts with this pattern then it
- is explicitly a trailing comment for the preceding argument.
- Default is '#<'
explicit_trailing_pattern: '#<'
_help_hashruler_min_length:
- If a comment line starts with at least this many consecutive
- hash characters, then don't lstrip() them off. This allows
- for lazy hash rulers where the first hash char is not
- separated by space
hashruler_min_length: 10
_help_canonicalize_hashrulers:
- If true, then insert a space between the first hash char and
- remaining hash chars in a hash ruler, and normalize its
- length to fill the column
canonicalize_hashrulers: true
_help_enable_markup:
- enable comment markup parsing and reflow
enable_markup: true
_help_lint: Options affecting the linter
lint:
_help_disabled_codes:
- a list of lint codes to disable
disabled_codes: []
_help_function_pattern:
- regular expression pattern describing valid function names
function_pattern: '[0-9a-z_]+'
_help_macro_pattern:
- regular expression pattern describing valid macro names
macro_pattern: '[0-9A-Z_]+'
_help_global_var_pattern:
- regular expression pattern describing valid names for
- variables with global (cache) scope
global_var_pattern: '[A-Z][0-9A-Z_]+'
_help_internal_var_pattern:
- regular expression pattern describing valid names for
- variables with global scope (but internal semantic)
internal_var_pattern: _[A-Z][0-9A-Z_]+
_help_local_var_pattern:
- regular expression pattern describing valid names for
- variables with local scope
local_var_pattern: '[a-z][a-z0-9_]+'
_help_private_var_pattern:
- regular expression pattern describing valid names for
- privatedirectory variables
private_var_pattern: _[0-9a-z_]+
_help_public_var_pattern:
- regular expression pattern describing valid names for public
- directory variables
public_var_pattern: '[A-Z][0-9A-Z_]+'
_help_argument_var_pattern:
- regular expression pattern describing valid names for
- function/macro arguments and loop variables.
argument_var_pattern: '[a-z][a-z0-9_]+'
_help_keyword_pattern:
- regular expression pattern describing valid names for
- keywords used in functions or macros
keyword_pattern: '[A-Z][0-9A-Z_]+'
_help_max_conditionals_custom_parser:
- In the heuristic for C0201, how many conditionals to match
- within a loop in before considering the loop a parser.
max_conditionals_custom_parser: 2
_help_min_statement_spacing:
- Require at least this many newlines between statements
min_statement_spacing: 1
_help_max_statement_spacing:
- Require no more than this many newlines between statements
max_statement_spacing: 2
max_returns: 6
max_branches: 12
max_arguments: 5
max_localvars: 15
max_statements: 50
_help_encode: Options affecting file encoding
encode:
_help_emit_byteorder_mark:
- If true, emit the unicode byte-order mark (BOM) at the start
- of the file
emit_byteorder_mark: false
_help_input_encoding:
- Specify the encoding of the input file. Defaults to utf-8
input_encoding: utf-8
_help_output_encoding:
- Specify the encoding of the output file. Defaults to utf-8.
- Note that cmake only claims to support utf-8 so be careful
- when using anything else
output_encoding: utf-8
_help_misc: Miscellaneous configurations options.
misc:
_help_per_command:
- A dictionary containing any per-command configuration
- overrides. Currently only `command_case` is supported.
per_command: {}

230
.github/workflows/c-std.yml vendored Normal file
View file

@ -0,0 +1,230 @@
name: C Standard
# Compile with as many C standards as possible.
# The worflow is setup to fail on any compilation warnings.
on:
workflow_dispatch:
push:
pull_request:
jobs:
main:
name: ${{ matrix.os.name }} ${{ matrix.compiler }} ${{ matrix.arch.name }} ${{ matrix.std.name }} ${{ matrix.builder }}
runs-on: ${{ matrix.os.value }}
strategy:
fail-fast: false
matrix:
os:
- name: Linux
value: ubuntu-latest
- name: MacOS
value: macos-latest
- name: Windows
value: windows-latest
cmake-opt: -G Ninja
compiler:
- gcc
- clang
arch:
- name: 64-bit
tag: amd64
compiler-opt: -m64
cmake-opt: -A x64
- name: 32-bit
tag: i386
compiler-opt: -m32
cmake-opt: -A Win32
builder:
- configure
- cmake
std:
- name: c89
value: c89
- name: gnu89
value: gnu89
- name: c94
value: iso9899:199409
- name: c99
value: c99
- name: gnu99
value: gnu99
- name: c11
value: c11
- name: gnu11
value: gnu11
- name: c17
value: c17
- name: gnu17
value: gnu17
- name: c2x
value: c2x
- name: gnu2x
value: gnu2x
exclude:
# Don't run 32-bit on MacOS
- { os: { name: MacOS },
arch: { tag: i386 } }
# Don't run configure on Windows
- { os: { name: Windows },
builder: configure }
# Don't run gcc 32-bit on Windows
- { os: { name: Windows },
arch: { tag: i386 } }
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: 'false'
- name: Install packages (Linux)
if: runner.os == 'Linux' && matrix.arch.tag == 'i386'
run: |
sudo apt-get update
sudo apt install gcc-multilib libc6-dev-i386-cross
- name: Install packages (Windows)
if: runner.os == 'Windows'
run: |
choco install --no-progress ninja
- name: Generate project files (configure)
if: matrix.builder == 'configure'
run: |
./configure
env:
CC: ${{ matrix.compiler }}
CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Werror -Wall -Wextra
- name: Compile source code (configure)
if: matrix.builder == 'configure'
run: make -j2
- name: Run test cases (configure)
if: matrix.builder == 'configure'
run: |
make test
make cover
- name: Generate project files (cmake)
if: matrix.builder == 'cmake'
run: |
cmake -S . -B ./build1 -D CMAKE_BUILD_TYPE=Release ${{ matrix.os.cmake-opt }} -DZLIB_BUILD_TESTING=OFF
env:
CC: ${{ matrix.compiler }}
CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Werror -Wall -Wextra
- name: Generate project files with tests (cmake)
if: matrix.builder == 'cmake'
run: |
cmake -S . -B ./build2 -D CMAKE_BUILD_TYPE=Release ${{ matrix.os.cmake-opt }} -DZLIB_BUILD_MINIZIP=ON -DMINIZIP_ENABLE_BZIP2=OFF
env:
CC: ${{ matrix.compiler }}
CFLAGS: -std=${{ matrix.std.value }} ${{ matrix.arch.compiler-opt }} -Wall -Wextra
- name: Compile source code (cmake)
if: matrix.builder == 'cmake'
run: cmake --build ./build1 --config Release
- name: Compile source code with tests (cmake)
if: matrix.builder == 'cmake'
run: cmake --build ./build2 --config Release
- name: Run test cases (cmake)
if: matrix.builder == 'cmake'
run: ctest ./build2 -C Release --output-on-failure --max-width 120
msvc:
name: ${{ matrix.os.name }} ${{ matrix.compiler }} ${{ matrix.arch.name }} ${{ matrix.std.name }} ${{ matrix.builder }}
runs-on: ${{ matrix.os.value }}
strategy:
fail-fast: false
matrix:
os:
- name: Windows
value: windows-latest
compiler:
- cl
arch:
- name: 32-bit
value: -A Win32
- name: 64-bit
value: -A x64
builder:
- cmake
std:
- name: default
value: ""
- name: C11
value: /std:c11
- name: C17
value: /std:c17
# not available on the runner yet
# - name: C20
# value: /std:c20
- name: latest
value: /std:clatest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: 'false'
- name: Generate project files (cmake)
run: |
cmake -S . -B ./build1 ${{ matrix.arch.value }} -D CMAKE_BUILD_TYPE=Release -DZLIB_BUILD_TESTING=OFF
env:
CC: ${{ matrix.compiler }}
CFLAGS: /WX ${{ matrix.std.value }}
- name: Generate project files with tests (cmake)
run: |
cmake -S . -B ./build2 ${{ matrix.arch.value }} -D CMAKE_BUILD_TYPE=Release -DZLIB_BUILD_MINIZIP=ON -DMINIZIP_ENABLE_BZIP2=OFF
env:
CC: ${{ matrix.compiler }}
CFLAGS: ${{ matrix.std.value }}
- name: Compile source code (cmake)
run: cmake --build ./build1 --config Release -v
- name: Compile source code with tests(cmake)
run: cmake --build ./build2 --config Release -v
- name: Run test cases (cmake)
run: ctest ./build2 -C Release --output-on-failure --max-width 120

View file

@ -11,79 +11,102 @@ jobs:
- name: Ubuntu GCC
os: ubuntu-latest
compiler: gcc
# Test out of source builds
- name: Ubuntu GCC OSB
os: ubuntu-latest
compiler: gcc
build-dir: ../build
src-dir: ../zlib
cflags: -Wall -Wextra
pkgtgt: package package_source
cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
- name: Ubuntu GCC -O3
os: ubuntu-latest
compiler: gcc
cflags: -O3
cflags: -O3 -Wall -Wextra
pkgtgt: package package_source
cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
- name: Ubuntu Clang
os: ubuntu-latest
compiler: clang
cflags: -Wall -Wextra
pkgtgt: package package_source
cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
- name: Ubuntu Clang Debug
os: ubuntu-latest
compiler: clang
cflags: -Wall -Wextra
build-config: Debug
pkgtgt: package package_source
cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
- name: Windows MSVC Win32
os: windows-latest
compiler: cl
cflags: /W3
cmake-args: -A Win32
pkgtgt: PACKAGE
- name: Windows MSVC Win64
os: windows-latest
compiler: cl
cmake-args: -A x64
cflags: /W3
cmake-args: -A x64 -DMINIZIP_ENABLE_BZIP2=OFF
pkgtgt: PACKAGE
- name: Windows GCC
os: windows-latest
compiler: gcc
cmake-args: -G Ninja
cflags: -Wall -Wextra
cmake-args: -G Ninja -DMINIZIP_ENABLE_BZIP2=OFF
pkgtgt: package
- name: macOS Clang
os: macos-latest
compiler: clang
cflags: -Wall -Wextra
pkgtgt: package
cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
- name: macOS GCC
os: macos-latest
compiler: gcc-11
compiler: gcc-12
cflags: -Wall -Wextra
pkgtgt: package
cmake-args: -DMINIZIP_ENABLE_BZIP2=ON
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install packages (Windows)
if: runner.os == 'Windows'
run: |
choco install --no-progress ninja ${{ matrix.packages }}
choco install --no-progress ninja
- name: Install packages (Linux)
if: runner.os == 'Linux'
run: |
sudo apt install libbz2-dev
- name: Generate project files
run: cmake -S ${{ matrix.src-dir || '.' }} -B ${{ matrix.build-dir || '.' }} ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }}
run: cmake -S . -B ../build ${{ matrix.cmake-args }} -D CMAKE_BUILD_TYPE=${{ matrix.build-config || 'Release' }} -DZLIB_BUILD_MINIZIP=ON
env:
CC: ${{ matrix.compiler }}
CFLAGS: ${{ matrix.cflags }}
- name: Compile source code
run: cmake --build ${{ matrix.build-dir || '.' }} --config ${{ matrix.build-config || 'Release' }}
run: cmake --build ../build --config ${{ matrix.build-config || 'Release' }}
- name: Run test cases
run: ctest -C Release --output-on-failure --max-width 120
working-directory: ${{ matrix.build-dir || '.' }}
working-directory: ../build
- name: create packages
run: cmake --build ../build --config ${{ matrix.build-config || 'Release' }} -t ${{ matrix.pkgtgt }}
- name: Upload build errors
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ matrix.name }} (cmake)
path: |
**/CMakeFiles/CMakeOutput.log
**/CMakeFiles/CMakeError.log
../build/CMakeFiles/CMakeOutput.log
../build/CMakeFiles/CMakeError.log
retention-days: 7

View file

@ -26,7 +26,7 @@ jobs:
compiler: arm-linux-gnueabi-gcc
configure-args: --warn
chost: arm-linux-gnueabi
packages: qemu qemu-user gcc-arm-linux-gnueabi libc-dev-armel-cross
packages: qemu-system qemu-user gcc-arm-linux-gnueabi libc-dev-armel-cross
qemu-run: qemu-arm -L /usr/arm-linux-gnueabi
- name: Ubuntu GCC ARM HF
@ -34,7 +34,7 @@ jobs:
compiler: arm-linux-gnueabihf-gcc
configure-args: --warn
chost: arm-linux-gnueabihf
packages: qemu qemu-user gcc-arm-linux-gnueabihf libc-dev-armhf-cross
packages: qemu-system qemu-user gcc-arm-linux-gnueabihf libc-dev-armhf-cross
qemu-run: qemu-arm -L /usr/arm-linux-gnueabihf
- name: Ubuntu GCC AARCH64
@ -42,7 +42,7 @@ jobs:
compiler: aarch64-linux-gnu-gcc
configure-args: --warn
chost: aarch64-linux-gnu
packages: qemu qemu-user gcc-aarch64-linux-gnu libc-dev-arm64-cross
packages: qemu-system qemu-user gcc-aarch64-linux-gnu libc-dev-arm64-cross
qemu-run: qemu-aarch64 -L /usr/aarch64-linux-gnu
- name: Ubuntu GCC PPC
@ -50,7 +50,7 @@ jobs:
compiler: powerpc-linux-gnu-gcc
configure-args: --warn --static
chost: powerpc-linux-gnu
packages: qemu qemu-user gcc-powerpc-linux-gnu libc-dev-powerpc-cross
packages: qemu-system qemu-user gcc-powerpc-linux-gnu libc-dev-powerpc-cross
qemu-run: qemu-ppc -L /usr/powerpc-linux-gnu
cflags: -static
ldflags: -static
@ -60,7 +60,7 @@ jobs:
compiler: powerpc64-linux-gnu-gcc
configure-args: --warn --static
chost: powerpc-linux-gnu
packages: qemu qemu-user gcc-powerpc64-linux-gnu libc-dev-ppc64-cross
packages: qemu-system qemu-user gcc-powerpc64-linux-gnu libc-dev-ppc64-cross
qemu-run: qemu-ppc64 -L /usr/powerpc64-linux-gnu
cflags: -static
ldflags: -static
@ -70,7 +70,7 @@ jobs:
compiler: powerpc64le-linux-gnu-gcc
configure-args: --warn
chost: powerpc64le-linux-gnu
packages: qemu qemu-user gcc-powerpc64le-linux-gnu libc-dev-ppc64el-cross
packages: qemu-system qemu-user gcc-powerpc64le-linux-gnu libc-dev-ppc64el-cross
qemu-run: qemu-ppc64le -L /usr/powerpc64le-linux-gnu
- name: Ubuntu GCC S390X
@ -78,14 +78,14 @@ jobs:
compiler: s390x-linux-gnu-gcc
configure-args: --warn --static
chost: s390x-linux-gnu
packages: qemu qemu-user gcc-s390x-linux-gnu libc-dev-s390x-cross
packages: qemu-system qemu-user gcc-s390x-linux-gnu libc-dev-s390x-cross
qemu-run: qemu-s390x -L /usr/s390x-linux-gnu
cflags: -static
ldflags: -static
- name: macOS GCC
os: macos-latest
compiler: gcc-11
compiler: gcc-12
configure-args: --warn
- name: macOS Clang
@ -95,7 +95,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Install packages (Ubuntu)
if: runner.os == 'Linux' && matrix.packages
@ -127,7 +127,7 @@ jobs:
QEMU_RUN: ${{ matrix.qemu-run }}
- name: Upload build errors
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: ${{ matrix.name }} (configure)

View file

@ -18,7 +18,7 @@ jobs:
dry-run: false
- name: Upload Crash
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: artifacts

77
.github/workflows/msys-cygwin.yml vendored Normal file
View file

@ -0,0 +1,77 @@
name: mingw/cygwin
on: [push, pull_request]
jobs:
MSys:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
sys: [mingw32, mingw64, ucrt64, clang64]
name: MSys - ${{ matrix.sys }}
defaults:
run:
shell: msys2 {0}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.sys }}
update: true
install: >-
make
pacboy: >-
toolchain:p
cmake:p
- name: Configure
run: |
cmake -G"Unix Makefiles" \
-S . \
-B build \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_BUILD_TYPE=Release \
-DMINIZIP_ENABLE_BZIP2=ON
- name: Build
run: cmake --build build --config Release
- name: Run tests
run: ctest --output-on-failure --test-dir build -C Release
cygwin:
strategy:
fail-fast: false
runs-on: windows-latest
defaults:
run:
shell: C:\cygwin\bin\bash.exe --login -o igncr '{0}'
name: Cygwin
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup cygwin
uses: cygwin/cygwin-install-action@master
with:
packages: >-
cmake
cygwin-devel
gcc-core
gcc-g++
ninja
- name: Configure
run: |
cmake /cygdrive/d/a/zlib/zlib \
-B build \
-DCMAKE_BUILD_TYPE=Release \
-DZLIB_BUILD_MINIZIP=ON \
-DMINIZIP_ENABLE_BZIP2=OFF \
-G Ninja
- name: Build
run: cmake --build build --config Release -v -j1
- name: Run tests
run: ctest --output-on-failure --test-dir build -C Release

15
.gitignore vendored
View file

@ -13,6 +13,8 @@
*.gcno
*.gcov
/zconf.h
/Makefile
/example
/example64
/examplesh
@ -22,6 +24,7 @@
/minigzipsh
/zlib.pc
/configure.log
/build
.DS_Store
.vs
@ -34,3 +37,15 @@ contrib/vstudio/vc143/arm64
contrib/nuget/bin
contrib/nuget/obj
*.included
# Bazel directories
/bazel-*
/bazel-bin
/bazel-genfiles
/bazel-out
/bazel-testlogs
user.bazelrc
# MODULE.bazel.lock is ignored for now as per this recommendation:
# https://github.com/bazelbuild/bazel/issues/20369
MODULE.bazel.lock

134
BUILD.bazel Normal file
View file

@ -0,0 +1,134 @@
# Copied from https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/zlib/1.3.1.bcr.4/patches
# Adapted from https://github.com/protocolbuffers/protobuf/blob/master/third_party/zlib.BUILD
# Copyright 2008 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Code generated by the Protocol Buffer compiler is owned by the owner
# of the input file used when generating it. This code is not
# standalone and requires a support library to be linked with it. This
# support library is itself covered by the above license.
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_license//rules:license.bzl", "license")
package(
default_applicable_licenses = [":license"],
)
license(
name = "license",
license_kinds = ["@rules_license//licenses/spdx:Zlib"],
license_text = "LICENSE",
)
exports_files([
"LICENSE",
])
_ZLIB_HEADERS = [
"crc32.h",
"deflate.h",
"gzguts.h",
"inffast.h",
"inffixed.h",
"inflate.h",
"inftrees.h",
"trees.h",
"zconf.h",
"zlib.h",
"zutil.h",
]
_ZLIB_PREFIXED_HEADERS = ["zlib/include/" + hdr for hdr in _ZLIB_HEADERS]
# In order to limit the damage from the `includes` propagation
# via `:zlib`, copy the public headers to a subdirectory and
# expose those.
genrule(
name = "copy_public_headers",
srcs = _ZLIB_HEADERS,
outs = _ZLIB_PREFIXED_HEADERS,
cmd_bash = "cp $(SRCS) $(@D)/zlib/include/",
cmd_bat = " && ".join(
["@copy /Y \"$(location %s)\" \"$(@D)\\zlib\\include\\\" >NUL" %
s for s in _ZLIB_HEADERS],
),
)
config_setting(
name = "mingw_gcc_compiler",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "mingw-gcc",
},
visibility = [":__subpackages__"],
)
cc_library(
name = "z",
srcs = [
"adler32.c",
"compress.c",
"crc32.c",
"deflate.c",
"gzclose.c",
"gzlib.c",
"gzread.c",
"gzwrite.c",
"infback.c",
"inffast.c",
"inflate.c",
"inftrees.c",
"trees.c",
"uncompr.c",
"zutil.c",
# Include the un-prefixed headers in srcs to work
# around the fact that zlib isn't consistent in its
# choice of <> or "" delimiter when including itself.
] + _ZLIB_HEADERS,
hdrs = _ZLIB_PREFIXED_HEADERS,
copts = select({
":mingw_gcc_compiler": [
"-fpermissive",
],
"@platforms//os:windows": [],
"//conditions:default": [
"-Wno-deprecated-non-prototype",
"-Wno-unused-variable",
"-Wno-implicit-function-declaration",
],
}),
includes = ["zlib/include/"],
visibility = ["//visibility:public"],
)
alias(
name = "zlib",
actual = ":z",
visibility = ["//visibility:public"],
)

View file

@ -1,98 +1,131 @@
cmake_minimum_required(VERSION 2.4.4...3.15.0)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
cmake_minimum_required(VERSION 3.12...3.31)
project(zlib C)
project(
zlib
LANGUAGES C
VERSION 1.4.1.1
HOMEPAGE_URL "https://zlib.net/"
DESCRIPTION "a general-purpose lossless data-compression library")
set(VERSION "1.3.1")
# ============================================================================
# CPack
# ============================================================================
set(CPACK_PACKAGE_VENDOR "zlib-Project")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${zlib_SOURCE_DIR}/README)
set(CPACK_RESOURCE_FILE_LICENSE ${zlib_SOURCE_DIR}/LICENSE)
set(CPACK_RESOURCE_FILE_README ${zlib_SOURCE_DIR}/README)
option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON)
# ============================================================================
# configuration
# ============================================================================
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
option(ZLIB_BUILD_TESTING "Enable Zlib Examples as tests" ON)
option(ZLIB_BUILD_SHARED "Enable building zlib shared library" ON)
option(ZLIB_BUILD_STATIC "Enable building zlib static library" ON)
option(ZLIB_BUILD_MINIZIP "Enable building libminizip contrib library" OFF)
option(ZLIB_INSTALL "Enable installation of zlib" ON)
option(ZLIB_PREFIX "prefix for all types and library functions, see zconf.h.in"
OFF)
mark_as_advanced(ZLIB_PREFIX)
include(CheckTypeSize)
if(WIN32)
option(ZLIB_INSTALL_COMPAT_DLL "Install a copy as zlib1.dll" ON)
endif(WIN32)
get_property(IS_MULTI GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
message(STATUS "No CMAKE_BUILD_TYPE set -- using Release")
set(CMAKE_BUILD_TYPE Release)
endif(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
include(CheckCSourceCompiles)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
enable_testing()
include(CMakePackageConfigHelpers)
include(CheckTypeSize)
include(CPack)
include(GNUInstallDirs)
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)
set(CPACK_INCLUDED TRUE)
if(NOT ZLIB_CONF_WRITTEN)
set(Z_PREFIX ${ZLIB_PREFIX})
set(CONF_OUT_FILE ${zlib_BINARY_DIR}/zconf.h.cmakein)
file(READ ${zlib_SOURCE_DIR}/zconf.h ZCONF_CONTENT LIMIT 245)
file(WRITE ${CONF_OUT_FILE} ${ZCONF_CONTENT})
file(APPEND ${CONF_OUT_FILE} "#cmakedefine Z_PREFIX 1\n")
file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_STDARG_H 1\n")
file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_UNISTD_H 1\n")
file(READ ${zlib_SOURCE_DIR}/zconf.h ZCONF_CONTENT OFFSET 244)
set(FIRST_ITEM TRUE)
foreach(item IN LISTS ZCONF_CONTENT)
if(FIRST_ITEM)
string(APPEND OUT_CONTENT ${item})
set(FIRST_ITEM FALSE)
else(FIRST_ITEM)
string(APPEND OUT_CONTENT "\;" ${item})
endif(FIRST_ITEM)
endforeach(item IN LISTS ${ZCONF_CONTENT})
file(APPEND ${CONF_OUT_FILE} ${OUT_CONTENT})
set(ZLIB_CONF_WRITTEN
TRUE
CACHE BOOL "zconf.h.cmakein was created")
mark_as_advanced(ZLIB_CONF_WRITTEN)
endif(NOT ZLIB_CONF_WRITTEN)
#
# 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
unset(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 stdarg.h
#
check_include_file(stdarg.h HAVE_STDARG_H)
#
# Check for unistd.h
#
check_include_file(unistd.h Z_HAVE_UNISTD_H)
check_include_file(unistd.h HAVE_UNISTD_H)
#
# Check visibility attribute is supported
#
if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
endif()
set(CMAKE_REQUIRED_FLAGS "-WX")
else(MSVC)
set(CMAKE_REQUIRED_FLAGS "-WError")
endif(MSVC)
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(STATUS "Renaming")
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
message(STATUS "to 'zconf.h.included' because this file is included with zlib")
message(STATUS "but CMake generates it automatically in the build directory.")
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
endif()
endif()
check_c_source_compiles(
"
#include <stdlib.h>
static void f(void) __attribute__ ((visibility(\"hidden\")));
int main(void) {return 0;}
"
HAVE___ATTR__VIS_HIDDEN)
set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
${ZLIB_PC} @ONLY)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
unset(CMAKE_COMPILE_FLAGS)
set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)
configure_file(${zlib_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
configure_file(${zlib_BINARY_DIR}/zconf.h.cmakein ${zlib_BINARY_DIR}/zconf.h)
#============================================================================
# ============================================================================
# zlib
#============================================================================
# ============================================================================
set(ZLIB_PUBLIC_HDRS ${zlib_BINARY_DIR}/zconf.h zlib.h)
set(ZLIB_PUBLIC_HDRS
${CMAKE_CURRENT_BINARY_DIR}/zconf.h
zlib.h
)
set(ZLIB_PRIVATE_HDRS
crc32.h
deflate.h
@ -102,8 +135,8 @@ set(ZLIB_PRIVATE_HDRS
inflate.h
inftrees.h
trees.h
zutil.h
)
zutil.h)
set(ZLIB_SRCS
adler32.c
compress.c
@ -119,100 +152,179 @@ set(ZLIB_SRCS
inffast.c
trees.c
uncompr.c
zutil.c
)
zutil.c)
if(NOT MINGW)
set(ZLIB_DLL_SRCS
win32/zlib1.rc # If present will override custom build rule below.
)
endif()
if(WIN32)
set(zlib_static_suffix "s")
set(CMAKE_DEBUG_POSTFIX "d")
endif(WIN32)
# 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(ZLIB_BUILD_SHARED)
add_library(
zlib SHARED ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}
$<$<OR:$<BOOL:${WIN32}>,$<BOOL:${CYGWIN}>>:win32/zlib1.rc>)
add_library(ZLIB::ZLIB ALIAS zlib)
target_include_directories(
zlib
PUBLIC $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
$<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_definitions(
zlib
PRIVATE ZLIB_BUILD
$<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
$<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
set(INSTALL_VERSION ${zlib_VERSION})
if(MINGW)
# This gets us DLL resource information when compiling on MinGW.
if(NOT CMAKE_RC_COMPILER)
set(CMAKE_RC_COMPILER windres.exe)
endif()
if(NOT CYGWIN)
set_target_properties(zlib PROPERTIES SOVERSION ${zlib_VERSION_MAJOR}
VERSION ${INSTALL_VERSION})
endif(NOT CYGWIN)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
COMMAND ${CMAKE_RC_COMPILER}
-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_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif(MINGW)
set_target_properties(
zlib
PROPERTIES DEFINE_SYMBOL ZLIB_DLL
EXPORT_NAME ZLIB
OUTPUT_NAME z)
if(UNIX
AND NOT APPLE
AND NOT (CMAKE_SYSTEM_NAME STREQUAL AIX))
# On unix-like platforms the library is almost always called libz
set_target_properties(
zlib
PROPERTIES LINK_FLAGS
"-Wl,--version-script,\"${zlib_SOURCE_DIR}/zlib.map\"")
endif(
UNIX
AND NOT APPLE
AND NOT (CMAKE_SYSTEM_NAME STREQUAL AIX))
endif(ZLIB_BUILD_SHARED)
add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
set_target_properties(zlib PROPERTIES SOVERSION 1)
if(ZLIB_BUILD_STATIC)
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS}
${ZLIB_PRIVATE_HDRS})
add_library(ZLIB::ZLIBSTATIC ALIAS zlibstatic)
target_include_directories(
zlibstatic
PUBLIC $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
$<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_definitions(
zlibstatic
PRIVATE ZLIB_BUILD
$<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
$<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
set_target_properties(
zlibstatic PROPERTIES EXPORT_NAME ZLIBSTATIC OUTPUT_NAME
z${zlib_static_suffix})
endif(ZLIB_BUILD_STATIC)
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(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
endif()
if(ZLIB_INSTALL)
if(ZLIB_BUILD_SHARED)
install(
TARGETS zlib
COMPONENT Runtime
EXPORT zlibSharedExport
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT zlibSharedExport
FILE ZLIB-shared.cmake
NAMESPACE ZLIB::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
if(ZLIB_INSTALL_COMPAT_DLL)
install(
FILES $<TARGET_FILE:zlib>
COMPONENT Runtime
RENAME zlib1.dll
DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif(ZLIB_INSTALL_COMPAT_DLL)
if(UNIX)
# On unix-like platforms the library is almost always called libz
set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
endif()
elseif(BUILD_SHARED_LIBS AND WIN32)
# Creates zlib1.dll when building shared library version
set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
endif()
if(MSVC)
install(
FILES $<TARGET_PDB_FILE:zlib>
COMPONENT Runtime
DESTINATION ${CMAKE_INSTALL_BINDIR}
CONFIGURATIONS Debug OR RelWithDebInfo
OPTIONAL)
endif(MSVC)
endif(ZLIB_BUILD_SHARED)
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
install(TARGETS zlib zlibstatic
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
endif()
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}")
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3")
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}")
endif()
if(ZLIB_BUILD_STATIC)
install(
TARGETS zlibstatic
COMPONENT Development
EXPORT zlibStaticExport
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT zlibStaticExport
FILE ZLIB-static.cmake
NAMESPACE ZLIB::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
#============================================================================
# Example binaries
#============================================================================
if(ZLIB_BUILD_EXAMPLES)
add_executable(example test/example.c)
target_link_libraries(example zlib)
add_test(example example)
if(ZLIB_INSTALL_COMPAT_DLL AND MINGW)
install(
FILES $<TARGET_FILE:zlibstatic>
COMPONENT Development
RENAME libz.dll.a
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif(ZLIB_INSTALL_COMPAT_DLL AND MINGW)
endif(ZLIB_BUILD_STATIC)
add_executable(minigzip test/minigzip.c)
target_link_libraries(minigzip zlib)
configure_package_config_file(
${zlib_SOURCE_DIR}/zlibConfig.cmake.in
${zlib_BINARY_DIR}/ZLIBConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
if(HAVE_OFF64_T)
add_executable(example64 test/example.c)
target_link_libraries(example64 zlib)
set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
add_test(example64 example64)
write_basic_package_version_file(
"${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake"
VERSION "${zlib_VERSION}"
COMPATIBILITY AnyNewerVersion)
add_executable(minigzip64 test/minigzip.c)
target_link_libraries(minigzip64 zlib)
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
endif()
endif()
install(FILES ${zlib_BINARY_DIR}/ZLIBConfig.cmake
${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
install(
FILES ${ZLIB_PUBLIC_HDRS}
COMPONENT Development
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(
FILES zlib.3
COMPONENT Docs
DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
install(
FILES LICENSE
doc/algorithm.txt
doc/crc-doc.1.0.pdf
doc/rfc1950.txt
doc/rfc1951.txt
doc/rfc1952.txt
doc/txtvsbin.txt
COMPONENT Docs
DESTINATION "${CMAKE_INSTALL_DOCDIR}/zlib")
install(
FILES ${ZLIB_PC}
COMPONENT Development
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif(ZLIB_INSTALL)
# ============================================================================
# Tests
# ============================================================================
if(ZLIB_BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif(ZLIB_BUILD_TESTING)
if(ZLIB_BUILD_MINIZIP)
add_subdirectory(contrib/minizip/)
endif(ZLIB_BUILD_MINIZIP)

View file

@ -1,6 +1,9 @@
ChangeLog file for zlib
Changes in 1.3.1.1 (xx Jan 2024)
-
Changes in 1.3.1 (22 Jan 2024)
- Reject overflows of zip header fields in minizip
- Fix bug in inflateSync() for data held in bit buffer

2
FAQ
View file

@ -19,7 +19,7 @@ The latest zlib FAQ is at http://zlib.net/zlib_faq.html
3. Where can I get a Visual Basic interface to zlib?
See
* http://marknelson.us/1997/01/01/zlib-engine/
* https://marknelson.us/posts/1997/01/01/zlib-engine.html
* win32/DLL_FAQ.txt in the zlib distribution
4. compress() returns Z_BUF_ERROR.

View file

@ -1,6 +1,6 @@
Copyright notice:
(C) 1995-2022 Jean-loup Gailly and Mark Adler
(C) 1995-2024 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

9
MODULE.bazel Normal file
View file

@ -0,0 +1,9 @@
module(
name = "zlib",
version = "0.0.0",
compatibility_level = 1,
)
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_cc", version = "0.0.16")
bazel_dep(name = "rules_license", version = "1.0.0")

View file

@ -13,6 +13,8 @@
# make install prefix=$HOME
CC=cc
GCOV=GCOV
LLVM_GCOV_FLAG=LLMV_GCOV_FLAG
CFLAGS=-O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
@ -28,7 +30,7 @@ CPP=$(CC) -E
STATICLIB=libz.a
SHAREDLIB=libz.so
SHAREDLIBV=libz.so.1.3.1
SHAREDLIBV=libz.so.1.3.1.1
SHAREDLIBM=libz.so.1
LIBS=$(STATICLIB) $(SHAREDLIBV)
@ -113,15 +115,19 @@ test64: all64
@rm -f tmp64_$$
infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/infcover.c
$(CC) $(CFLAGS) $(ZINCOUT) -c -coverage -o $@ $(SRCDIR)test/infcover.c
infcover: infcover.o libz.a
$(CC) $(CFLAGS) -o $@ infcover.o libz.a
$(CC) $(CFLAGS) -coverage -o $@ infcover.o libz.a
cover: infcover
ifdef $(GCOV)
rm -f *.gcda
${QEMU_RUN} ./infcover
gcov inf*.c
${GCOV} ${LLVM_GCOV_FLAG} inf*.c -o ./infcover.gcda
else
@echo 'cover disabled as no suitable gcov was found'
endif
libz.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
@ -176,7 +182,7 @@ inftrees.o: $(SRCDIR)inftrees.c
trees.o: $(SRCDIR)trees.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)trees.c
zutil.o: $(SRCDIR)zutil.c
zutil.o: $(SRCDIR)zutil.c $(SRCDIR)gzguts.h
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)zutil.c
compress.o: $(SRCDIR)compress.c
@ -238,7 +244,7 @@ trees.lo: $(SRCDIR)trees.c
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/trees.o $(SRCDIR)trees.c
-@mv objs/trees.o $@
zutil.lo: $(SRCDIR)zutil.c
zutil.lo: $(SRCDIR)zutil.c $(SRCDIR)gzguts.h
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/zutil.o $(SRCDIR)zutil.c
-@mv objs/zutil.o $@
@ -349,12 +355,13 @@ docs: zlib.3.pdf
zlib.3.pdf: $(SRCDIR)zlib.3
groff -mandoc -f H -T ps $(SRCDIR)zlib.3 | ps2pdf - $@
zconf.h.cmakein: $(SRCDIR)zconf.h.in
-@ TEMPFILE=zconfh_$$; \
echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\
touch -r $(SRCDIR)zconf.h.in $@ &&\
rm $$TEMPFILE
# zconf.h.cmakein: $(SRCDIR)zconf.h.in
# -@ TEMPFILE=zconfh_$$; \
# echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
# sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\
# touch -r $(SRCDIR)zconf.h.in $@ &&\
# rm $$TEMPFILE
#
zconf: $(SRCDIR)zconf.h.in
cp -p $(SRCDIR)zconf.h.in zconf.h
@ -378,7 +385,7 @@ clean: minizip-clean
rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov
maintainer-clean: distclean
distclean: clean zconf zconf.h.cmakein
distclean: clean zconf # zconf.h.cmakein
rm -f Makefile zlib.pc configure.log
-@rm -f .DS_Store
@if [ -f Makefile.in ]; then \
@ -389,7 +396,8 @@ distclean: clean zconf zconf.h.cmakein
tags:
etags $(SRCDIR)*.[ch]
adler32.o zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
adler32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
gzclose.o gzlib.o gzread.o gzwrite.o: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
compress.o example.o minigzip.o uncompr.o: $(SRCDIR)zlib.h zconf.h
crc32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h
@ -399,7 +407,8 @@ inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR
inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
adler32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)zlib.h zconf.h
crc32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h

6
README
View file

@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY
zlib 1.3.1 is a general purpose data compression library. All the code is
zlib 1.3.1.1 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
(Request for Comments) 1950 to 1952 in the files
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
@ -31,7 +31,7 @@ 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 at
https://marknelson.us/posts/1997/01/01/zlib-engine.html .
The changes made in version 1.3.1 are documented in the file ChangeLog.
The changes made in version 1.3.1.1 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory contrib/ .
@ -69,8 +69,6 @@ Notes for some targets:
- 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.
- gzdopen is not supported on RISCOS or BEOS.
- For PalmOs, see http://palmzlib.sourceforge.net/

83
README-cmake.md Normal file
View file

@ -0,0 +1,83 @@
# For building with cmake at least version 3.12 (minizip 3.12) is needed
In most cases the usual
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release
will create everything you need, however if you want something off default you can adjust several options fit your needs.
Every option is list below (excluding the cmake-standard options), they can be set via cmake-gui or on cmdline with
-D<option>=ON/OFF
## ZLIB-options with defaults ##
ZLIB_BUILD_TESTING=ON -- Enable Zlib Examples as tests
ZLIB_BUILD_SHARED=ON -- Enable building zlib shared library
ZLIB_BUILD_STATIC=ON -- Enable building zlib static library
ZLIB_BUILD_MINIZIP=ON -- Enable building libminizip contrib library
If this option is turned on, additional options are available from minizip (see below)
ZLIB_INSTALL=ON -- Enable installation of zlib
ZLIB_PREFIX=OFF -- prefix for all types and library functions, see zconf.h.in
ZLIB_INSTALL_COMPAT_DLL=ON -- Install a copy as zlib1.dll
This option is only on windows available and may/will be turned off and removed somewhen in the future.
If you rely cmake for finding and using zlib, this can be turned off, as `zlib1.dll` will never be used.
## minizip-options with defaults ##
MINIZIP_BUILD_SHARED=ON -- Enable building minizip shared library
MINIZIP_BUILD_STATIC=ON -- Enable building minizip static library
MINIZIP_BUILD_TESTING=ON -- Enable testing of minizip
MINIZIP_ENABLE_BZIP2=ON -- Build minizip withj bzip2 support
A usable installation of bzip2 is needed or config will fail. Turn this option of in this case.
MINIZIP_INSTALL=ON -- Enable installation of minizip
MINIZIP_INSTALL_COMPAT_DLL=ON -- Install a copy as libminizip-1.dll
This option is only available on mingw as they tend to name this lib different. Maybe this will also be
removed in the future as. If you rely cmake for finding and using zlib, this can be turned off, as
the other file will never be used.
## Using the libs ##
To pull in what you need it's enough to just write
find_package(ZLIB CONFIG)
or
find_package(minizip CONFIG)
in your CMakeLists.txt, however it is advised to specify what you really want via:
find_package(ZLIB CONFIG COMPONENTS shared static REQUIRED)
or
find_package(minizip CONFIG COMPONENTS shared static REQUIRED)
As it's possible to only build the shared or the static lib, you can make sure that everything you need
is found. If no COMPONENTS are requested, everything that is found will satisfy your request. If the
libraries are optional in you project, you can omit the REQUIRED and check yourself if the targets you
want to link against are created.
When you search for minizip, it will search zlib for you, so only one of both is needed.
## Imported targets ##
When found the following targets are created for you:
ZLIB::ZLIB and ZLIB::ZLIBSTATIC -- for zlib
MINIZIP::minizip and MINIZIP::minizipstatic -- for minizip

65
configure vendored
View file

@ -87,10 +87,12 @@ zprefix=0
zconst=0
build64=0
gcc=0
clang=0
warn=0
debug=0
address=0
memory=0
unknown=0
old_cc="$CC"
old_cflags="$CFLAGS"
OBJC='$(OBJZ) $(OBJG)'
@ -144,12 +146,12 @@ case "$1" in
--sanitize) address=1; shift ;;
--address) address=1; shift ;;
--memory) memory=1; shift ;;
*)
echo "unknown option: $1" | tee -a configure.log
echo "$0 --help for help" | tee -a configure.log
leave 1;;
*) unknown=1; echo "unknown option ignored: $1" | tee -a configure.log; shift;;
esac
done
if test $unknown -eq 1; then
echo "$0 --help for help" | tee -a configure.log
fi
# temporary file name
test=ztest$$
@ -184,20 +186,53 @@ else
fi
case "$cc" in
*gcc*) gcc=1 ;;
*clang*) gcc=1 ;;
*gcc*) gcc=1
GCOV="gcov" ;;
*clang*) gcc=1
clang=1 ;;
esac
case `$cc -v 2>&1` in
*gcc*) gcc=1 ;;
*clang*) gcc=1 ;;
*gcc*) gcc=1
GCOV="gcov" ;;
*clang*) gcc=1
clang=1 ;;
esac
if test "$clang" -eq 1; then
if test "$cc" = "clang"; then
if which -s llvm-cov; then
GCOV="llvm-cov"
LLVM_GCOV_FLAG="gcov"
GCOV="llvm-cov"
LLVM_GCOV_FLAG="gcov"
echo "Using ${GCOV} for coverage"
else
cover=0
GCOV=""
LLVM_GCOV_FLAG=""
echo "Deactivating cover as no suitable gcov can be found"
fi
else
clangV=`echo "$cc" | sed -e 's/^.*-//'`
if which -s llvm-cov-${clangV}; then
GCOV="llvm-cov-${clangV}"
LLVM_GCOV_FLAG="gcov"
echo "Using ${GCOV} for coverage"
else
cover=0
GCOV=""
LLVM_GCOV_FLAG=""
echo "Deactivating cover as no suitable gcov can be found"
fi
fi
fi
show $cc -c $test.c
if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
echo ... using gcc >> configure.log
CC="$cc"
CFLAGS="${CFLAGS--O3}"
SFLAGS="${CFLAGS--O3} -fPIC"
CFLAGS="${CFLAGS--O3} -fPIC"
SFLAGS="${CFLAGS--O3}"
if test "$ARCHS"; then
CFLAGS="${CFLAGS} ${ARCHS}"
LDFLAGS="${LDFLAGS} ${ARCHS}"
@ -227,7 +262,7 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
uname=`(uname -s || echo unknown) 2>/dev/null`
fi
case "$uname" in
Linux* | linux* | *-linux* | GNU | GNU/* | solaris*)
Linux* | linux* | *-linux* | GNU | GNU/* | solaris* | Haiku)
case "$mname" in
*sparc*)
LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;;
@ -258,6 +293,7 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
SHAREDLIB='libz.sl' ;;
esac ;;
AIX*)
LDSHARED=${LDSHARED-"$cc -shared"}
LDFLAGS="${LDFLAGS} -Wl,-brtl" ;;
Darwin* | darwin* | *-darwin*)
shared_ext='.dylib'
@ -575,7 +611,7 @@ cat > $test.c <<EOF
int main() { return 0; }
EOF
if try $CC -c $CFLAGS $test.c; then
sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
sed < zconf.h "/^#if HAVE_UNISTD_H-0.* may be/s/ HAVE_UNISTD_H-0\(.*\) may be/ 1\1 was/" > zconf.temp.h
mv zconf.temp.h zconf.h
echo "Checking for unistd.h... Yes." | tee -a configure.log
else
@ -590,7 +626,7 @@ cat > $test.c <<EOF
int main() { return 0; }
EOF
if try $CC -c $CFLAGS $test.c; then
sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
sed < zconf.h "/^#if HAVE_STDARG_H-0.* may be/s/ HAVE_STDARG_H-0\(.*\) may be/ 1\1 was/" > zconf.temp.h
mv zconf.temp.h zconf.h
echo "Checking for stdarg.h... Yes." | tee -a configure.log
else
@ -618,7 +654,6 @@ fi
# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
if test $cover -eq 1; then
CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
if test -n "$GCC_CLASSIC"; then
CC=$GCC_CLASSIC
fi
@ -870,6 +905,8 @@ echo uname = $uname >> configure.log
# update Makefile with the configure results
sed < ${SRCDIR}Makefile.in "
/^CC *=/s#=.*#=$CC#
/^GCOV *=/s#=.*#=$GCOV#
/^LLVM_GCOV_FLAG *=/s#=.*#=$LLVM_GCOV_FLAG#
/^CFLAGS *=/s#=.*#=$CFLAGS#
/^SFLAGS *=/s#=.*#=$SFLAGS#
/^LDFLAGS *=/s#=.*#=$LDFLAGS#

View file

@ -2,7 +2,7 @@
Release 1.3
ZLib.Ada is a thick binding interface to the popular ZLib data
compression library, available at http://www.gzip.org/zlib/.
compression library, available at https://zlib.net/.
It provides Ada-style access to the ZLib C library.

View file

@ -12,7 +12,8 @@ package body ZLib.Thin is
ZLIB_VERSION : constant Chars_Ptr := zlibVersion;
Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit;
Dummy : Z_Stream;
Z_Stream_Size : constant Int := Dummy'Size / System.Storage_Unit;
--------------
-- Avail_In --

View file

@ -152,7 +152,7 @@ procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
const OutBuf: Pointer; BufSize: Integer);
const
zlib_version = '1.3.1';
zlib_version = '1.3.1.1';
type
EZlibError = class(Exception);

View file

@ -156,7 +156,7 @@ namespace DotZLibTests
public void Info_Version()
{
Info info = new Info();
Assert.AreEqual("1.3.1", Info.Version);
Assert.AreEqual("1.3.1.1", Info.Version);
Assert.AreEqual(32, info.SizeOfUInt);
Assert.AreEqual(32, info.SizeOfULong);
Assert.AreEqual(32, info.SizeOfPointer);

File diff suppressed because it is too large Load diff

View file

@ -293,7 +293,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
mode = TABLE;
break;
case 3:
strm->msg = (char *)"invalid block type";
strm->msg = (z_const char *)"invalid block type";
mode = BAD;
}
DROPBITS(2);
@ -304,7 +304,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
BYTEBITS(); /* go to byte boundary */
NEEDBITS(32);
if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
strm->msg = (char *)"invalid stored block lengths";
strm->msg = (z_const char *)"invalid stored block lengths";
mode = BAD;
break;
}
@ -341,7 +341,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
state->ncode = BITS(4) + 4;
DROPBITS(4);
if (state->nlen > 286) {
strm->msg = (char *)"too many length symbols";
strm->msg = (z_const char *)"too many length symbols";
mode = BAD;
break;
}
@ -362,7 +362,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
ret = inflate_table9(CODES, state->lens, 19, &(state->next),
&(lenbits), state->work);
if (ret) {
strm->msg = (char *)"invalid code lengths set";
strm->msg = (z_const char *)"invalid code lengths set";
mode = BAD;
break;
}
@ -386,7 +386,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
NEEDBITS(here.bits + 2);
DROPBITS(here.bits);
if (state->have == 0) {
strm->msg = (char *)"invalid bit length repeat";
strm->msg = (z_const char *)"invalid bit length repeat";
mode = BAD;
break;
}
@ -409,7 +409,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
DROPBITS(7);
}
if (state->have + copy > state->nlen + state->ndist) {
strm->msg = (char *)"invalid bit length repeat";
strm->msg = (z_const char *)"invalid bit length repeat";
mode = BAD;
break;
}
@ -423,7 +423,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
/* check for end-of-block code (better have one) */
if (state->lens[256] == 0) {
strm->msg = (char *)"invalid code -- missing end-of-block";
strm->msg = (z_const char *)"invalid code -- missing end-of-block";
mode = BAD;
break;
}
@ -437,7 +437,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
ret = inflate_table9(LENS, state->lens, state->nlen,
&(state->next), &(lenbits), state->work);
if (ret) {
strm->msg = (char *)"invalid literal/lengths set";
strm->msg = (z_const char *)"invalid literal/lengths set";
mode = BAD;
break;
}
@ -447,7 +447,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
state->ndist, &(state->next), &(distbits),
state->work);
if (ret) {
strm->msg = (char *)"invalid distances set";
strm->msg = (z_const char *)"invalid distances set";
mode = BAD;
break;
}
@ -495,7 +495,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
/* invalid code */
if (here.op & 64) {
strm->msg = (char *)"invalid literal/length code";
strm->msg = (z_const char *)"invalid literal/length code";
mode = BAD;
break;
}
@ -527,7 +527,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
}
DROPBITS(here.bits);
if (here.op & 64) {
strm->msg = (char *)"invalid distance code";
strm->msg = (z_const char *)"invalid distance code";
mode = BAD;
break;
}
@ -541,7 +541,7 @@ int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
DROPBITS(extra);
}
if (offset > WSIZE - (wrap ? 0: left)) {
strm->msg = (char *)"invalid distance too far back";
strm->msg = (z_const char *)"invalid distance too far back";
mode = BAD;
break;
}

View file

@ -9,7 +9,7 @@
#define MAXBITS 15
const char inflate9_copyright[] =
" inflate9 1.3.1 Copyright 1995-2024 Mark Adler ";
" inflate9 1.3.1.1 Copyright 1995-2024 Mark Adler ";
/*
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
@ -59,7 +59,7 @@ int inflate_table9(codetype type, unsigned short FAR *lens, unsigned codes,
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
133, 133, 133, 133, 144, 203, 77};
133, 133, 133, 133, 144, 73, 200};
static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,

View file

@ -0,0 +1,380 @@
cmake_minimum_required(VERSION 3.12...3.31)
project(
minizip
VERSION 1.0.0
LANGUAGES C
DESCRIPTION "A library for creating zipfiles based in zlib"
HOMEPAGE_URL "https://www.winimage.com/zLibDll/minizip.html")
if(CMAKE_SIZEOF_VOID_P LESS 8 AND NOT MINGW)
message(WARNING "libminizip needs 64bit - stopping here")
return()
endif(CMAKE_SIZEOF_VOID_P LESS 8 AND NOT MINGW)
# ============================================================================
# CPack
# ============================================================================
set(CPACK_PACKAGE_VENDOR "zlib-Project")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${minizip_SOURCE_DIR}/MiniZip64_info.txt)
set(CPACK_RESOURCE_FILE_LICENSE ${minizip_SOURCE_DIR}/../../LICENSE)
set(CPACK_RESOURCE_FILE_README ${minizip_SOURCE_DIR}/MiniZip64_info.txt)
# ============================================================================
# configuration
# ============================================================================
option(MINIZIP_BUILD_SHARED "Enable building minizip shared library" ON)
option(MINIZIP_BUILD_STATIC "Enable building minizip static library" ON)
option(MINIZIP_BUILD_TESTING "Enable testing of minizip" ON)
option(MINIZIP_ENABLE_BZIP2 "Build minizip withj bzip2 support" ON)
option(MINIZIP_INSTALL "Enable installation of minizip" ON)
if(MINGW)
option(MINIZIP_INSTALL_COMPAT_DLL "Install a copy as libminizip-1.dll" ON)
endif(MINGW)
include(CheckCSourceCompiles)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CMakePackageConfigHelpers)
include(CheckTypeSize)
include(GNUInstallDirs)
if(NOT CPACK_INCLUDED)
include(CPack)
endif(NOT CPACK_INCLUDED)
if(MINIZIP_ENABLE_BZIP2)
find_package(BZip2 REQUIRED)
endif(MINIZIP_ENABLE_BZIP2)
#
# Check for fopen64
#
check_function_exists(fopen64 HAVE_FOPEN64)
#
# Check for fseeko
#
check_function_exists(fseeko HAVE_FSEEKO)
#
# Check for unistd.h
#
check_include_file(unistd.h HAVE_UNISTD_H)
#
# Check to see if we have large file support
#
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
check_type_size(off64_t OFF64_T)
unset(CMAKE_REQUIRED_DEFINITIONS) # clear variable
#
# Check visibility attribute is supported
#
if(MSVC)
set(CMAKE_REQUIRED_FLAGS "-WX")
else(MSVC)
set(CMAKE_REQUIRED_FLAGS "-WError")
endif(MSVC)
check_c_source_compiles(
"
#include <stdlib.h>
static void f(void) __attribute__ ((visibility(\"hidden\")));
int main(void) {return 0;}
"
HAVE___ATTR__VIS_HIDDEN)
unset(CMAKE_REQUIRED_FLAGS)
if(NOT TARGET ZLIB::ZLIB)
find_package(ZLIB REQUIRED CONFIG)
endif(NOT TARGET ZLIB::ZLIB)
set(LIBMINIZIP_SRCS ioapi.c mztools.c unzip.c zip.c)
set(LIBMINIZIP_HDRS crypt.h ints.h ioapi.h mztools.h unzip.h zip.h)
set(MINIZIP_SRCS ioapi.c $<$<BOOL:${WIN32}>:iowin32.c> minizip.c zip.c)
set(MINIZIP_HDRS crypt.h ints.h ioapi.h $<$<BOOL:${WIN32}>:iowin32.h> skipset.h
zip.h)
set(MINIUNZIP_SRCS ioapi.c $<$<BOOL:${WIN32}>:iowin32.c> miniunz.c unzip.c
zip.c)
set(MINIUNZIP_HDRS
crypt.h
ints.h
ioapi.h
$<$<BOOL:${WIN32}>:iowin32.h>
skipset.h
unzip.h
zip.h)
if(WIN32 OR CYGWIN)
set(minizip_static_suffix "s")
set(CMAKE_DEBUG_POSTFIX "d")
endif(WIN32 OR CYGWIN)
if(MINIZIP_BUILD_SHARED)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
add_library(libminizip SHARED ${LIBMINIZIP_SRCS} ${LIBMINIZIP_HDRS})
add_library(MINIZIP::minizip ALIAS libminizip)
target_include_directories(
libminizip PUBLIC $<BUILD_INTERFACE:${minizip_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_definitions(
libminizip
PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
$<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>
$<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
$<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
if(NOT CYGWIN)
set_target_properties(libminizip PROPERTIES SOVERSION
${minizip_VERSION_MAJOR})
endif(NOT CYGWIN)
set_target_properties(
libminizip
PROPERTIES EXPORT_NAME minizip
OUTPUT_NAME minizip
VERSION ${minizip_VERSION}
SOVERSION ${minizip_VERSION_MAJOR})
target_link_libraries(libminizip
PUBLIC ZLIB::ZLIB
$<$<BOOL:${BZIP2_FOUND}>:BZip2::BZip2>)
add_executable(minizip ${MINIZIP_SRCS} ${MINIZIP_HDRS})
set_target_properties(minizip PROPERTIES EXPORT_NAME minizip_executable)
target_compile_definitions(
minizip PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
target_link_libraries(minizip PRIVATE MINIZIP::minizip)
add_executable(miniunzip ${MINIUNZIP_SRCS} ${MINIUNZIP_HDRS})
set_target_properties(miniunzip PROPERTIES EXPORT_NAME miniunzip_executable)
target_compile_definitions(
miniunzip PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
target_link_libraries(miniunzip PRIVATE MINIZIP::minizip)
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
add_library(libminizipstatic STATIC ${LIBMINIZIP_SRCS} ${LIBMINIZIP_HDRS})
add_library(MINIZIP::minizipstatic ALIAS libminizipstatic)
target_include_directories(
libminizipstatic
PUBLIC $<BUILD_INTERFACE:${minizip_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_definitions(
libminizipstatic
PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
$<$<BOOL:${HAVE_UNISTD_H}>:HAVE_UNISTD_H=1>
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>
$<$<BOOL:${BZIP2_FOUND}>:HAVE_BZIP2=1>
$<$<BOOL:NOT:${HAVE_FOPEN64}>:USE_FILE32API=1>)
set_target_properties(
libminizipstatic PROPERTIES EXPORT_NAME minizipstatic
OUTPUT_NAME minizip${minizip_static_suffix})
if(CYGWIN)
set_target_properties(libminizipstatic PROPERTIES SUFFIX ".dll.a")
endif(CYGWIN)
target_link_libraries(libminizipstatic PUBLIC ZLIB::ZLIBSTATIC
$<$<BOOL:${BZIP2_FOUND}>:BZip2::BZip2>)
add_executable(minizipstatic ${MINIZIP_SRCS} ${MINIZIP_HDRS})
set_target_properties(minizipstatic PROPERTIES EXPORT_NAME
minizip_static_executable)
target_compile_definitions(
minizipstatic PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
target_link_libraries(minizipstatic PRIVATE MINIZIP::minizipstatic)
add_executable(miniunzipstatic ${MINIUNZIP_SRCS} ${MINIUNZIP_HDRS})
set_target_properties(miniunzipstatic
PROPERTIES EXPORT_NAME miniunzip_static_executable)
target_compile_definitions(
miniunzipstatic PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
target_link_libraries(miniunzipstatic PRIVATE MINIZIP::minizipstatic)
endif(MINIZIP_BUILD_STATIC)
if(MINIZIP_INSTALL)
if(MINIZIP_BUILD_SHARED)
install(
TARGETS libminizip minizip miniunzip
COMPONENT Runtime
EXPORT minizipSharedExport
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT minizipSharedExport
FILE minizip-shared.cmake
NAMESPACE MINIZIP::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
if(MINIZIP_INSTALL_COMPAT_DLL)
install(
FILES $<TARGET_FILE:libminizip>
COMPONENT Runtime
RENAME libminizip-${minizip_VERSION_MAJOR}.dll
DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif(MINIZIP_INSTALL_COMPAT_DLL)
if(MSVC)
install(
FILES $<TARGET_PDB_FILE:libminizip>
COMPONENT Runtime
DESTINATION ${CMAKE_INSTALL_BINDIR}
CONFIGURATIONS Debug OR RelWithDebInfo
OPTIONAL)
endif(MSVC)
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
install(
TARGETS libminizipstatic
COMPONENT Development
TARGETS minizipstatic miniunzipstatic
COMPONENT Runtime
EXPORT minizipStaticExport
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT minizipStaticExport
FILE minizip-static.cmake
NAMESPACE MINIZIP::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
endif(MINIZIP_BUILD_STATIC)
configure_package_config_file(
${minizip_SOURCE_DIR}/minizipConfig.cmake.in
${minizip_BINARY_DIR}/minizipConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
write_basic_package_version_file(
"${minizip_BINARY_DIR}/minizipConfigVersion.cmake"
VERSION "${minizip_VERSION}"
COMPATIBILITY AnyNewerVersion)
install(FILES ${minizip_BINARY_DIR}/minizipConfig.cmake
${minizip_BINARY_DIR}/minizipConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/minizip)
install(
FILES ${LIBMINIZIP_HDRS}
COMPONENT Development
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
endif(MINIZIP_INSTALL)
if(MINIZIP_BUILD_TESTING)
enable_testing()
if(MINIZIP_BUILD_SHARED AND NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL
".dll")
add_test(
NAME minizip_prepare_shared_zip
COMMAND ${CMAKE_COMMAND} -DCREATE_SHARED=ON -P
${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_zipping_test_file_shared
COMMAND minizip test_file_shared.zip test_file_shared.txt
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_prepare_shared_unzip
COMMAND ${CMAKE_COMMAND} -DMOVE_SHARED=ON -P
${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_miniunzipping_test_file_shared.zip
COMMAND miniunzip test_file_shared.zip
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_compare_shared
COMMAND ${CMAKE_COMMAND} -E compare_files test_file_shared.txt
test_file_shared.orig
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_clean_shared_zip
COMMAND ${CMAKE_COMMAND} -DDELETE_SHARED=ON -P
${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
set_tests_properties(minizip_prepare_shared_zip
PROPERTIES FIXTURES_SETUP prepare_shared)
set_tests_properties(
minizip_zipping_test_file_shared
PROPERTIES FIXTURES_REQUIRED prepare_shared FIXTURES_SETUP
zip_shared)
set_tests_properties(
minizip_prepare_shared_unzip
PROPERTIES FIXTURES_REQUIRED zip_shared FIXTURES_SETUP
prepare_unzip_shared)
set_tests_properties(
minizip_miniunzipping_test_file_shared.zip
PROPERTIES FIXTURES_REQUIRED prepare_unzip_shared FIXTURES_SETUP
prepare_compare_shared)
set_tests_properties(
minizip_compare_shared
PROPERTIES FIXTURES_REQUIRED prepare_compare_shared FIXTURES_SETUP
compared_shared)
set_tests_properties(minizip_clean_shared_zip
PROPERTIES FIXTURES_CLEANUP compared_shared)
endif(MINIZIP_BUILD_SHARED AND NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL
".dll")
if(MINIZIP_BUILD_STATIC)
add_test(
NAME minizip_prepare_static_zip
COMMAND ${CMAKE_COMMAND} -DCREATE_STATIC=ON -P
${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_zipping_test_file_static
COMMAND minizipstatic test_file_static.zip test_file_static.txt
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_prepare_static_unzip
COMMAND ${CMAKE_COMMAND} -DMOVE_STATIC=ON -P
${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_miniunzipping_test_file_static.zip
COMMAND miniunzipstatic test_file_static.zip
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_compare_static
COMMAND ${CMAKE_COMMAND} -E compare_files test_file_static.txt
test_file_static.orig
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
add_test(
NAME minizip_clean_static_zip
COMMAND ${CMAKE_COMMAND} -DDELETE_STATIC=ON -P
${CMAKE_CURRENT_SOURCE_DIR}/test/test_helper.cm
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test)
set_tests_properties(minizip_prepare_static_zip
PROPERTIES FIXTURES_SETUP prepare_static)
set_tests_properties(
minizip_zipping_test_file_static
PROPERTIES FIXTURES_REQUIRED prepare_static FIXTURES_SETUP
zip_static)
set_tests_properties(
minizip_prepare_static_unzip
PROPERTIES FIXTURES_REQUIRED zip_static FIXTURES_SETUP
prepare_unzip_static)
set_tests_properties(
minizip_miniunzipping_test_file_static.zip
PROPERTIES FIXTURES_REQUIRED prepare_unzip_static FIXTURES_SETUP
prepare_compare_static)
set_tests_properties(
minizip_compare_static
PROPERTIES FIXTURES_REQUIRED prepare_compare_static FIXTURES_SETUP
compared_static)
set_tests_properties(minizip_clean_static_zip
PROPERTIES FIXTURES_CLEANUP compared_static)
endif(MINIZIP_BUILD_STATIC)
add_subdirectory(test)
endif(MINIZIP_BUILD_TESTING)

View file

@ -1,5 +1,5 @@
CC?=cc
CFLAGS := $(CFLAGS) -O -I../..
CFLAGS := -O $(CFLAGS) -I../..
UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a
ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a
@ -9,13 +9,21 @@ ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a
all: miniunz minizip
miniunz: $(UNZ_OBJS)
miniunz.o: miniunz.c unzip.h iowin32.h
minizip.o: minizip.c zip.h iowin32.h ints.h
unzip.o: unzip.c unzip.h crypt.h
zip.o: zip.c zip.h crypt.h skipset.h ints.h
ioapi.o: ioapi.c ioapi.h ints.h
iowin32.o: iowin32.c iowin32.h ioapi.h
mztools.o: mztools.c unzip.h
miniunz: $(UNZ_OBJS)
$(CC) $(CFLAGS) -o $@ $(UNZ_OBJS)
minizip: $(ZIP_OBJS)
minizip: $(ZIP_OBJS)
$(CC) $(CFLAGS) -o $@ $(ZIP_OBJS)
test: miniunz minizip
test: miniunz minizip
@rm -f test.*
@echo hello hello hello > test.txt
./minizip test test.txt

View file

@ -1,13 +1,13 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_INIT([minizip], [1.3.1], [bugzilla.redhat.com])
AC_INIT([minizip], [1.3.1.1], [bugzilla.redhat.com])
AC_CONFIG_SRCDIR([minizip.c])
AM_INIT_AUTOMAKE([foreign])
LT_INIT
AC_MSG_CHECKING([whether to build example programs])
AC_ARG_ENABLE([demos], AC_HELP_STRING([--enable-demos], [build example programs]))
AC_ARG_ENABLE([demos], AS_HELP_STRING([--enable-demos], [build example programs]))
AM_CONDITIONAL([COND_DEMOS], [test "$enable_demos" = yes])
if test "$enable_demos" = yes
then

57
contrib/minizip/ints.h Normal file
View file

@ -0,0 +1,57 @@
/* ints.h -- create integer types for 8, 16, 32, and 64 bits
* Copyright (C) 2024 Mark Adler
* For conditions of distribution and use, see the copyright notice in zlib.h
*
* There exist compilers with limits.h, but not stdint.h or inttypes.h.
*/
#ifndef INTS_H
#define INTS_H
#include <limits.h>
#if defined(UCHAR_MAX) && UCHAR_MAX == 0xff
typedef signed char i8_t;
typedef unsigned char ui8_t;
#else
# error "no 8-bit integer"
#endif
#if defined(USHRT_MAX) && USHRT_MAX == 0xffff
typedef short i16_t;
typedef unsigned short ui16_t;
#elif defined(UINT_MAX) && UINT_MAX == 0xffff
typedef int i16_t;
typedef unsigned ui16_t;
#else
# error "no 16-bit integer"
#endif
#if defined(UINT_MAX) && UINT_MAX == 0xffffffff
typedef int i32_t;
typedef unsigned ui32_t;
# define PI32 "d"
# define PUI32 "u"
#elif defined(ULONG_MAX) && ULONG_MAX == 0xffffffff
typedef long i32_t;
typedef unsigned long ui32_t;
# define PI32 "ld"
# define PUI32 "lu"
#else
# error "no 32-bit integer"
#endif
#if defined(ULONG_MAX) && ULONG_MAX == 0xffffffffffffffff
typedef long i64_t;
typedef unsigned long ui64_t;
# define PI64 "ld"
# define PUI64 "lu"
#elif defined(ULLONG_MAX) && ULLONG_MAX == 0xffffffffffffffff
typedef long long i64_t;
typedef unsigned long long ui64_t;
# define PI64 "lld"
# define PUI64 "llu"
#elif defined(ULONG_LONG_MAX) && ULONG_LONG_MAX == 0xffffffffffffffff
typedef long long i64_t;
typedef unsigned long long ui64_t;
# define PI64 "lld"
# define PUI64 "llu"
#else
# error "no 64-bit integer"
#endif
#endif

View file

@ -15,7 +15,7 @@
#endif
#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
// In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
/* In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions */
#define FOPEN_FUNC(filename, mode) fopen(filename, mode)
#define FTELLO_FUNC(stream) ftello(stream)
#define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin)

View file

@ -18,13 +18,13 @@
*/
#ifndef _ZLIBIOAPI64_H
#define _ZLIBIOAPI64_H
#ifndef ZLIBIOAPI64_H
#define ZLIBIOAPI64_H
#if (!defined(_WIN32)) && (!defined(WIN32)) && (!defined(__APPLE__))
// Linux needs this to support file operation on files larger then 4+GB
// But might need better if/def to select just the platforms that needs them.
/* Linux needs this to support file operation on files larger then 4+GB */
/* But might need better if/def to select just the platforms that needs them.*/
#ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64
@ -67,39 +67,12 @@
#endif
#endif
/*
#ifndef ZPOS64_T
#ifdef _WIN32
#define ZPOS64_T fpos_t
#else
#include <stdint.h>
#define ZPOS64_T uint64_t
#endif
#endif
*/
#ifdef HAVE_MINIZIP64_CONF_H
#include "mz64conf.h"
#endif
/* a type chosen by DEFINE */
#ifdef HAVE_64BIT_INT_CUSTOM
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
#else
#ifdef HAS_STDINT_H
#include "stdint.h"
typedef uint64_t ZPOS64_T;
#else
#if defined(_MSC_VER) || defined(__BORLANDC__)
typedef unsigned __int64 ZPOS64_T;
#else
typedef unsigned long long int ZPOS64_T;
#endif
#endif
#endif
#include "ints.h"
typedef ui64_t ZPOS64_T;
/* Maximum unsigned 32-bit value used as placeholder for zip64 */
#ifndef MAXU32
@ -188,8 +161,8 @@ typedef struct zlib_filefunc64_32_def_s
#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size))
//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream))
//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode))
/*#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) */
/*#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) */
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))

View file

@ -26,7 +26,7 @@
#endif
// see Include/shared/winapifamily.h in the Windows Kit
/* see Include/shared/winapifamily.h in the Windows Kit */
#if defined(WINAPI_FAMILY_PARTITION) && (!(defined(IOWIN32_USING_WINRT_API)))
#if !defined(WINAPI_FAMILY_ONE_PARTITION)
@ -89,7 +89,7 @@ static voidpf win32_build_iowin(HANDLE hFile) {
}
voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int mode) {
const char* mode_fopen = NULL;
(void)opaque;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;
@ -117,7 +117,7 @@ voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int
voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, int mode) {
const char* mode_fopen = NULL;
(void)opaque;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;
@ -140,7 +140,7 @@ voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, in
voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, int mode) {
const char* mode_fopen = NULL;
(void)opaque;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;
@ -159,7 +159,7 @@ voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, in
voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int mode) {
const char* mode_fopen = NULL;
(void)opaque;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL;
@ -187,6 +187,7 @@ voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int m
uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLong size) {
(void)opaque;
uLong ret=0;
HANDLE hFile = NULL;
if (stream!=NULL)
@ -208,6 +209,7 @@ uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLo
uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
(void)opaque;
uLong ret=0;
HANDLE hFile = NULL;
if (stream!=NULL)
@ -247,6 +249,7 @@ static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *n
}
long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
(void)opaque;
long ret=-1;
HANDLE hFile = NULL;
if (stream!=NULL)
@ -269,6 +272,7 @@ long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
}
ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) {
(void)opaque;
ZPOS64_T ret= (ZPOS64_T)-1;
HANDLE hFile = NULL;
if (stream!=NULL)
@ -293,6 +297,7 @@ ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) {
long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
(void)opaque;
DWORD dwMoveMethod=0xFFFFFFFF;
HANDLE hFile = NULL;
@ -330,6 +335,7 @@ long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset,
}
long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
(void)opaque;
DWORD dwMoveMethod=0xFFFFFFFF;
HANDLE hFile = NULL;
long ret=-1;
@ -368,6 +374,7 @@ long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T off
}
int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
(void)opaque;
int ret=-1;
if (stream!=NULL)
@ -385,6 +392,7 @@ int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
}
int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) {
(void)opaque;
int ret=-1;
if (stream!=NULL)
{

View file

@ -2,7 +2,7 @@ $ if f$search("ioapi.h_orig") .eqs. "" then copy ioapi.h ioapi.h_orig
$ open/write zdef vmsdefs.h
$ copy sys$input: zdef
$ deck
#define unix
#define __unix__
#define fill_zlib_filefunc64_32_def_from_filefunc32 fillzffunc64from
#define Write_Zip64EndOfCentralDirectoryLocator Write_Zip64EoDLocator
#define Write_Zip64EndOfCentralDirectoryRecord Write_Zip64EoDRecord

View file

@ -39,6 +39,9 @@
#endif
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -83,6 +86,7 @@
tmu_date : the SAME new date at the tm_unz format */
static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) {
#ifdef _WIN32
(void)tmu_date;
HANDLE hFile;
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
@ -93,8 +97,7 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat
LocalFileTimeToFileTime(&ftLocal,&ftm);
SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
CloseHandle(hFile);
#else
#if defined(unix) || defined(__APPLE__)
#elif defined(__unix__) || defined(__unix) || defined(__APPLE__)
(void)dosdate;
struct utimbuf ut;
struct tm newdate;
@ -116,7 +119,6 @@ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_dat
(void)dosdate;
(void)tmu_date;
#endif
#endif
}
@ -127,9 +129,7 @@ static int mymkdir(const char* dirname) {
int ret=0;
#ifdef _WIN32
ret = _mkdir(dirname);
#elif unix
ret = mkdir (dirname,0775);
#elif __APPLE__
#elif defined(__unix__) || defined(__unix) || defined(__APPLE__)
ret = mkdir (dirname,0775);
#else
(void)dirname;
@ -240,7 +240,7 @@ static int do_list(unzFile uf) {
printf(" ------ ------ ---- ----- ---- ---- ------ ----\n");
for (i=0;i<gi.number_entry;i++)
{
char filename_inzip[256];
char filename_inzip[65536+1];
unz_file_info64 file_info;
uLong ratio=0;
const char *string_method = "";
@ -305,7 +305,7 @@ static int do_list(unzFile uf) {
static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password) {
char filename_inzip[256];
char filename_inzip[65536+1];
char* filename_withoutpath;
char* p;
int err=UNZ_OK;

View file

@ -41,6 +41,9 @@
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -59,6 +62,7 @@
#endif
#include "zip.h"
#include "ints.h"
#ifdef _WIN32
#define USEWIN32IOAPI
@ -74,6 +78,7 @@
/* f: name of file to get info on, tmzip: return value: access,
modification and creation times, dt: dostime */
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
(void)tmzip;
int ret = 0;
{
FILETIME ftLocal;
@ -91,8 +96,7 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
}
return ret;
}
#else
#if defined(unix) || defined(__APPLE__)
#elif defined(__unix__) || defined(__unix) || defined(__APPLE__)
/* f: name of file to get info on, tmzip: return value: access,
modification and creation times, dt: dostime */
static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
@ -143,7 +147,6 @@ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
return 0;
}
#endif
#endif
@ -192,7 +195,7 @@ static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_b
do
{
err = ZIP_OK;
size_read = fread(buf,1,size_buf,fin);
size_read = (unsigned long)fread(buf,1,size_buf,fin);
if (size_read < size_buf)
if (feof(fin)==0)
{
@ -224,7 +227,7 @@ static int isLargeFile(const char* filename) {
FSEEKO_FUNC(pFile, 0, SEEK_END);
pos = (ZPOS64_T)FTELLO_FUNC(pFile);
printf("File : %s is %llu bytes\n", filename, pos);
printf("File : %s is %"PUI64" bytes\n", filename, pos);
if(pos >= 0xffffffff)
largeFile = 1;
@ -244,7 +247,7 @@ int main(int argc, char *argv[]) {
char filename_try[MAXFILENAME+16];
int zipok;
int err=0;
size_t size_buf=0;
unsigned long size_buf=0;
void* buf=NULL;
const char* password=NULL;
@ -306,7 +309,7 @@ int main(int argc, char *argv[]) {
}
else
{
int i,len;
int len;
int dot_found=0;
zipok = 1 ;
@ -432,7 +435,7 @@ int main(int argc, char *argv[]) {
}
if( lastslash != NULL )
{
savefilenameinzip = lastslash+1; // base filename follows last slash.
savefilenameinzip = lastslash+1; /* base filename follows last slash. */
}
}

View file

@ -1,7 +1,7 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@/minizip
includedir=@includedir@
Name: minizip
Description: Minizip zip file manipulation library

View file

@ -0,0 +1,13 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
sharedlibdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
includedir=${exec_prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Name: minizip
Description: minizip compression library
Version: @minizip_VERSION@
Requires:
Libs: -L${libdir} -L${sharedlibdir} -lz -lminizip
Cflags: -I${includedir}

View file

@ -0,0 +1,35 @@
@PACKAGE_INIT@
set(_minizip_supported_components "")
include(CMakeFindDependencyMacro)
if(@MINIZIP_BUILD_SHARED@)
list(APPEND _minizip_supported_components shared)
endif(@MINIZIP_BUILD_SHARED@)
if(@MINIZIP_BUILD_STATIC@)
list(APPEND _minizip_supported_components static)
endif(@MINIZIP_BUILD_STATIC@)
if(@MINIZIP_ENABLE_BZIP2@)
find_dependency(BZip2)
endif(@MINIZIP_ENABLE_BZIP2@)
if(minizip_FIND_COMPONENTS)
find_dependency(ZLIB CONFIG COMPONENTS ${minizip_FIND_COMPONENTS})
foreach(_comp ${minizip_FIND_COMPONENTS})
if(NOT _comp IN_LIST _MINIZIP_supported_components)
set(minizip_FOUND False)
set(minizip_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
endif(NOT _comp IN_LIST _MINIZIP_supported_components)
include("${CMAKE_CURRENT_LIST_DIR}/minizip-${_comp}.cmake")
endforeach(_comp ${ZLIB_FIND_COMPONENTS})
else(minizip_FIND_COMPONENTS)
find_dependency(ZLIB CONFIG)
foreach(_component_config IN LISTS _minizip_supported_components)
include("${CMAKE_CURRENT_LIST_DIR}/minizip-${_component_config}.cmake")
endforeach(_component_config IN LISTS _minizip_supported_components)
endif(minizip_FIND_COMPONENTS)

View file

@ -5,6 +5,9 @@
*/
/* Code */
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -140,28 +143,28 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*
/* Central directory entry */
{
char header[46];
char central[46];
char* comment = "";
int comsize = (int) strlen(comment);
WRITE_32(header, 0x02014b50);
WRITE_16(header + 4, version);
WRITE_16(header + 6, version);
WRITE_16(header + 8, gpflag);
WRITE_16(header + 10, method);
WRITE_16(header + 12, filetime);
WRITE_16(header + 14, filedate);
WRITE_32(header + 16, crc);
WRITE_32(header + 20, cpsize);
WRITE_32(header + 24, uncpsize);
WRITE_16(header + 28, fnsize);
WRITE_16(header + 30, extsize);
WRITE_16(header + 32, comsize);
WRITE_16(header + 34, 0); /* disk # */
WRITE_16(header + 36, 0); /* int attrb */
WRITE_32(header + 38, 0); /* ext attrb */
WRITE_32(header + 42, currentOffset);
WRITE_32(central, 0x02014b50);
WRITE_16(central + 4, version);
WRITE_16(central + 6, version);
WRITE_16(central + 8, gpflag);
WRITE_16(central + 10, method);
WRITE_16(central + 12, filetime);
WRITE_16(central + 14, filedate);
WRITE_32(central + 16, crc);
WRITE_32(central + 20, cpsize);
WRITE_32(central + 24, uncpsize);
WRITE_16(central + 28, fnsize);
WRITE_16(central + 30, extsize);
WRITE_16(central + 32, comsize);
WRITE_16(central + 34, 0); /* disk # */
WRITE_16(central + 36, 0); /* int attrb */
WRITE_32(central + 38, 0); /* ext attrb */
WRITE_32(central + 42, currentOffset);
/* Header */
if (fwrite(header, 1, 46, fpOutCD) == 46) {
if (fwrite(central, 1, 46, fpOutCD) == 46) {
offsetCD += 46;
/* Filename */
@ -215,23 +218,23 @@ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char*
/* Final central directory */
{
int entriesZip = entries;
char header[22];
char* comment = ""; // "ZIP File recovered by zlib/minizip/mztools";
char end[22];
char* comment = ""; /* "ZIP File recovered by zlib/minizip/mztools"; */
int comsize = (int) strlen(comment);
if (entriesZip > 0xffff) {
entriesZip = 0xffff;
}
WRITE_32(header, 0x06054b50);
WRITE_16(header + 4, 0); /* disk # */
WRITE_16(header + 6, 0); /* disk # */
WRITE_16(header + 8, entriesZip); /* hack */
WRITE_16(header + 10, entriesZip); /* hack */
WRITE_32(header + 12, offsetCD); /* size of CD */
WRITE_32(header + 16, offset); /* offset to CD */
WRITE_16(header + 20, comsize); /* comment */
WRITE_32(end, 0x06054b50);
WRITE_16(end + 4, 0); /* disk # */
WRITE_16(end + 6, 0); /* disk # */
WRITE_16(end + 8, entriesZip); /* hack */
WRITE_16(end + 10, entriesZip); /* hack */
WRITE_32(end + 12, offsetCD); /* size of CD */
WRITE_32(end + 16, offset); /* offset to CD */
WRITE_16(end + 20, comsize); /* comment */
/* Header */
if (fwrite(header, 1, 22, fpOutCD) == 22) {
if (fwrite(end, 1, 22, fpOutCD) == 22) {
/* Comment field */
if (comsize > 0) {

361
contrib/minizip/skipset.h Normal file
View file

@ -0,0 +1,361 @@
/* skipset.h -- set operations using a skiplist
// Copyright (C) 2024 Mark Adler
// See MiniZip_info.txt for the license.
// This implements a skiplist set, i.e. just keys, no data, with ~O(log n) time
// insert and search operations. The application defines the type of a key, and
// provides a function to compare two keys.
// This header is not definitions of functions found in another source file --
// it creates the set functions, with the application's key type, right where
// the #include is. Before this header is #included, these must be defined:
//
// 1. A macro or typedef for set_key_t, the type of a key.
// 2. A macro or function set_cmp(a, b) to compare two keys. The return values
// are < 0 for a < b, 0 for a == b, and > 0 for a > b.
// 3. A macro or function set_drop(s, k) to release the key k's resources, if
// any, when doing a set_end() or set_clear(). s is a pointer to the set
// that key is in, for use with set_free() if desired.
//
// Example usage:
//
// typedef int set_key_t;
// #define set_cmp(a, b) ((a) < (b) ? -1 : (a) == (b) ? 0 : 1)
// #define set_drop(s, k)
// #include "skipset.h"
//
// int test(void) { // return 0: good, 1: bad, -1: out of memory
// set_t set;
// if (setjmp(set.env))
// return -1;
// set_start(&set);
// set_insert(&set, 2);
// set_insert(&set, 1);
// set_insert(&set, 7);
// int bad = !set_found(&set, 2);
// bad = bad || set_found(&set, 5);
// set_end(&set);
// return bad;
// }
//
// Interface summary (see more details below):
// - set_t is the type of the set being operated on (a set_t pointer is passed)
// - set_start() initializes a new, empty set (initialize set.env first)
// - set_insert() inserts a new key into the set, or not if it's already there
// - set_found() determines whether or not a key is in the set
// - set_end() ends the use of the set, freeing all memory
// - set_clear() empties the set, equivalent to set_end() and then set_start()
// - set_ok() checks if set appears to be usable, i.e. started and not ended
//
// Auxiliary functions available to the application:
// - set_alloc() allocates memory with optional tracking (#define SET_TRACK)
// - set_free() deallocates memory allocated by set_alloc()
// - set_rand() returns 32 random bits (seeded by set_start()) */
#ifndef SKIPSET_H
#define SKIPSET_H
#include <stdlib.h> /* realloc(), free(), NULL, size_t */
#include <stddef.h> /* ptrdiff_t */
#include <setjmp.h> /* jmp_buf, longjmp() */
#include <errno.h> /* ENOMEM */
#include <time.h> /* time(), clock() */
#include <assert.h> /* assert.h */
#include "ints.h" /* i16_t, ui32_t, ui64_t */
/* Structures and functions below noted as "--private--" should not be used by
// the application. set_t is partially private and partially public -- see the
// comments there.
// There is no POSIX random() in MSVC, and rand() is awful. For portability, we
// cannot rely on a library function for random numbers. Instead we use the
// fast and effective algorithm below, invented by Melissa O'Neill.
// *Really* minimal PCG32 code / (c) 2014 M.E. O'Neill / www.pcg-random.org
// Licensed under Apache License 2.0 (NO WARRANTY, etc. see website)
// --private-- Random number generator state. */
typedef struct {
ui64_t state; /* 64-bit generator state */
ui64_t inc; /* 63-bit sequence id */
} set_rand_t;
/* --private-- Initialize the state *gen using seed and seq. seed seeds the
// advancing 64-bit state. seq is a sequence selection constant. */
void set_seed(set_rand_t *gen, ui64_t seed, ui64_t seq) {
gen->inc = (seq << 1) | 1;
gen->state = (seed + gen->inc) * 6364136223846793005ULL + gen->inc;
}
/* Return 32 random bits, advancing the state *gen. */
ui32_t set_rand(set_rand_t *gen) {
ui64_t state = gen->state;
gen->state = state * 6364136223846793005ULL + gen->inc;
ui32_t mix = (ui32_t)(((state >> 18) ^ state) >> 27);
int rot = state >> 59;
return (mix >> rot) | (mix << ((-rot) & 31));
}
/* End of PCG32 code. */
/* --private-- Linked-list node. */
typedef struct set_node_s set_node_t;
struct set_node_s {
set_key_t key; /* the key (not used for head or path) */
i16_t size; /* number of allocated pointers in right[] */
i16_t fill; /* number of pointers in right[] filled in */
set_node_t **right; /* pointer for each level, each to the right */
};
/* A set. The application sets env, may use gen with set_rand(), and may read
// allocs and memory. The remaining variables are --private-- . */
typedef struct set_s {
set_node_t *head; /* skiplist head -- no key, just links */
set_node_t *path; /* right[] is path to key from set_found() */
set_node_t *node; /* node under construction, in case of longjmp() */
i16_t depth; /* maximum depth of the skiplist */
ui64_t ran; /* a precious trove of random bits */
set_rand_t gen; /* random number generator state */
jmp_buf env; /* setjmp() environment for allocation errors */
#ifdef SET_TRACK
size_t allocs; /* number of allocations */
size_t memory; /* total amount of allocated memory (>= requests) */
#endif
} set_t;
/* Memory allocation and deallocation. set_alloc(set, ptr, size) returns a
// pointer to an allocation of size bytes if ptr is NULL, or the previous
// allocation ptr resized to size bytes. set_alloc() will never return NULL.
// set_free(set, ptr) frees an allocation created by set_alloc(). These may be
// used by the application. e.g. if allocation tracking is desired. */
#ifdef SET_TRACK
/* Track the number of allocations and the total backing memory size. */
# if defined(_WIN32)
# include <malloc.h>
# define SET_ALLOC_SIZE(ptr) _msize(ptr)
# elif defined(__MACH__)
# include <malloc/malloc.h>
# define SET_ALLOC_SIZE(ptr) malloc_size(ptr)
# elif defined(__linux__)
# include <malloc.h>
# define SET_ALLOC_SIZE(ptr) malloc_usable_size(ptr)
# elif defined(__FreeBSD__)
# include <malloc_np.h>
# define SET_ALLOC_SIZE(ptr) malloc_usable_size(ptr)
# elif defined(__NetBSD__)
# include <jemalloc/jemalloc.h>
# define SET_ALLOC_SIZE(ptr) malloc_usable_size(ptr)
# else // e.g. OpenBSD
# define SET_ALLOC_SIZE(ptr) 0
# endif
// With tracking.
void *set_alloc(set_t *set, void *ptr, size_t size) {
size_t had = ptr == NULL ? 0 : SET_ALLOC_SIZE(ptr);
void *mem = realloc(ptr, size);
if (mem == NULL)
longjmp(set->env, ENOMEM);
set->allocs += ptr == NULL;
set->memory += SET_ALLOC_SIZE(mem) - had;
return mem;
}
void set_free(set_t *set, void *ptr) {
if (ptr != NULL) {
set->allocs--;
set->memory -= SET_ALLOC_SIZE(ptr);
free(ptr);
}
}
#else
/* Without tracking. */
void *set_alloc(set_t *set, void *ptr, size_t size) {
void *mem = realloc(ptr, size);
if (mem == NULL)
longjmp(set->env, ENOMEM);
return mem;
}
void set_free(set_t *set, void *ptr) {
(void)set;
free(ptr);
}
#endif
/* --private-- Grow node's array right[] as needed to be able to hold at least
// want links. If fill is true, assure that the first want links are filled in,
// setting them to set->head if not previously filled in. Otherwise it is
// assumed that the first want links are about to be filled in. */
void set_grow(set_t *set, set_node_t *node, int want, int fill) {
if (node->size < want) {
int more = node->size ? node->size : 1;
while (more < want)
more <<= 1;
node->right = set_alloc(set, node->right, more * sizeof(set_node_t *));
node->size = (i16_t)more;
}
int i;
if (fill)
for (i = node->fill; i < want; i++)
node->right[i] = set->head;
node->fill = (i16_t)want;
}
/* --private-- Return a new node. key is left uninitialized. */
set_node_t *set_node(set_t *set) {
set_node_t *node = set_alloc(set, NULL, sizeof(set_node_t));
node->size = 0;
node->fill = 0;
node->right = NULL;
return node;
}
/* --private-- Free the list linked from head, along with the keys. */
void set_sweep(set_t *set) {
set_node_t *step = set->head->right[0];
while (step != set->head) {
set_node_t *next = step->right[0]; /* save link to next node */
set_drop(set, step->key);
set_free(set, step->right);
set_free(set, step);
step = next;
}
}
/* Initialize a new set. set->env must be initialized using setjmp() before
// set_start() is called. A longjmp(set->env, ENOMEM) will be used to handle a
// memory allocation failure during any of the operations. (See setjmp.h and
// errno.h.) The set can still be used if this happens, assuming that it didn't
// happen during set_start(). Whether set_start() completed or not, set_end()
// can be used to free the set's memory after a longjmp(). */
void set_start(set_t *set) {
#ifdef SET_TRACK
set->allocs = 0;
set->memory = 0;
#endif
set->head = set->path = set->node = NULL; /* in case set_node() fails */
set->path = set_node(set);
set->head = set_node(set);
set_grow(set, set->head, 1, 1); /* one link back to head for an empty set */
*(unsigned char *)&set->head->key = 137; /* set id */
set->depth = 0;
set_seed(&set->gen, ((ui64_t)(ptrdiff_t)set << 32) ^
((ui64_t)time(NULL) << 12) ^ clock(), 0);
set->ran = 1;
}
/* Return true if *set appears to be in a usable state. If *set has been zeroed
// out, then set_ok(set) will be false and set_end(set) will be safe. */
int set_ok(set_t *set) {
return set->head != NULL &&
set->head->right != NULL &&
*(unsigned char *)&set->head->key == 137;
}
/* Empty the set. This frees the memory used for the previous set contents.
// After set_clear(), *set is ready for use, as if after a set_start(). */
void set_clear(set_t *set) {
assert(set_ok(set) && "improper use");
/* Free all the keys and their nodes. */
set_sweep(set);
/* Leave the head and path allocations as is. Clear their contents, with
// head pointing to itself and setting depth to zero, for an empty set. */
set->head->right[0] = set->head;
set->head->fill = 1;
set->path->fill = 0;
set->depth = 0;
}
/* Done using the set -- free all allocations. The only operation on *set
// permitted after this is set_start(). Though another set_end() would do no
// harm. This can be done at any time after a set_start(), or after a longjmp()
// on any allocation failure, including during a set_start(). */
void set_end(set_t *set) {
if (set->head != NULL) {
/* Empty the set and free the head node. */
if (set->head->right != NULL) {
set_sweep(set);
set_free(set, set->head->right);
}
set_free(set, set->head);
set->head = NULL;
}
if (set->path != NULL) {
/* Free the path work area. */
set_free(set, set->path->right);
set_free(set, set->path);
set->path = NULL;
}
if (set->node != NULL) {
/* Free the node that was under construction when longjmp() hit. */
set_drop(set, set->node->key);
set_free(set, set->node->right);
set_free(set, set->node);
set->node = NULL;
}
}
/* Look for key. Return 1 if found or 0 if not. This also puts the path to get
// there in set->path, for use by set_insert(). */
int set_found(set_t *set, set_key_t key) {
assert(set_ok(set) && "improper use");
/* Start at depth and work down and right as determined by key comparisons. */
set_node_t *head = set->head, *here = head;
int i = set->depth;
set_grow(set, set->path, i + 1, 0);
do {
while (here->right[i] != head &&
set_cmp(here->right[i]->key, key) < 0)
here = here->right[i];
set->path->right[i] = here;
} while (i--);
/* See if the key matches. */
here = here->right[0];
return here != head && set_cmp(here->key, key) == 0;
}
/* Insert the key key. Return 0 on success, or 1 if key is already in the set. */
int set_insert(set_t *set, set_key_t key) {
assert(set_ok(set) && "improper use");
if (set_found(set, key))
/* That key is already in the set. */
return 1;
/* Randomly generate a new level-- level 0 with probability 1/2, 1 with
// probability 1/4, 2 with probability 1/8, etc. */
int level = 0;
for (;;) {
if (set->ran == 1)
/* Ran out. Get another 32 random bits. */
set->ran = set_rand(&set->gen) | (1ULL << 32);
int bit = set->ran & 1;
set->ran >>= 1;
if (bit)
break;
assert(level < 32767 &&
"Overhead, without any fuss, the stars were going out.");
level++;
}
if (level > set->depth) {
/* The maximum depth is now deeper. Update the structures. */
set_grow(set, set->path, level + 1, 1);
set_grow(set, set->head, level + 1, 1);
set->depth = (i16_t)level;
}
/* Make a new node for the provided key, and insert it in the lists up to
// and including level. */
set->node = set_node(set);
set->node->key = key;
set_grow(set, set->node, level + 1, 0);
int i;
for (i = 0; i <= level; i++) {
set->node->right[i] = set->path->right[i]->right[i];
set->path->right[i]->right[i] = set->node;
}
set->node = NULL;
return 0;
}
#else
#error ** another skiplist set already created here
/* Would need to implement a prefix in order to support multiple sets. */
#endif

View file

@ -0,0 +1,121 @@
# if we are built from with zlib, use this path's)
if(DEFINED ZLIB_BUILD_SHARED)
set(WORK_DIR ${zlib_BINARY_DIR})
set(inst_setup minizip_minizip_install)
else(DEFINED ZLIB_BUILD_SHARED)
set(WORK_DIR ${minizip_BINARY_DIR})
set(inst_setup minizip_minizip_install)
set(ZLIB_ARG "-DZLIB_DIR=${ZLIB_DIR}")
add_test(
NAME minizip_install
COMMAND ${CMAKE_COMMAND} --install ${minizip_BINARY_DIR} --prefix
${CMAKE_CURRENT_BINARY_DIR}/test_install --config $<CONFIG>
WORKING_DIRECTORY ${minizip_BINARY_DIR})
set_tests_properties(minizip_install PROPERTIES FIXTURES_SETUP
minizip_install)
endif(DEFINED ZLIB_BUILD_SHARED)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt
@ONLY)
# CMAKE_GENERATOR_PLATFORM doesn't work in the if
set(GENERATOR ${CMAKE_GENERATOR_PLATFORM})
if(GENERATOR)
set(PLATFORM "-A ${GENERATOR}")
endif(GENERATOR)
#
# findpackage_test
#
add_test(
NAME minizip_find_package_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh -G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(
NAME minizip_find_package_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
set_tests_properties(
minizip_find_package_configure PROPERTIES FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP mzfp_config)
set_tests_properties(minizip_find_package_build PROPERTIES FIXTURES_REQUIRED
mzfp_config)
#
# add_subdirectory_test
#
add_test(
NAME minizip_add_subdirectory_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh -G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
add_test(
NAME minizip_add_subdirectory_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
set_tests_properties(
minizip_add_subdirectory_configure
PROPERTIES FIXTURES_REQUIRED ${inst_setup} FIXTURES_SETUP mzas_config)
set_tests_properties(minizip_add_subdirectory_build PROPERTIES FIXTURES_REQUIRED
mzas_config)
#
# add_subdirectory_exclude_test
#
add_test(
NAME minizip_add_subdirectory_exclude_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh -G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
add_test(
NAME minizip_add_subdirectory_exclude_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
set_tests_properties(
minizip_add_subdirectory_exclude_configure
PROPERTIES FIXTURES_REQUIRED ${inst_setup} FIXTURES_SETUP mzasx_config)
set_tests_properties(minizip_add_subdirectory_exclude_build
PROPERTIES FIXTURES_REQUIRED mzasx_config)

View file

@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.12...3.31)
project(
minizip_add_subdirectory_exclude_from_all
LANGUAGES C
VERSION @minizip_VERSION@)
option(MINIZIP_BUILD_TESTING "" OFF)
option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
option(MINIZIP_ENABLE_BZIP2 "" @MINIZIP_ENABLE_BZIP2@)
add_subdirectory(@minizip_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/minizip
EXCLUDE_FROM_ALL)
set(MINIZIP_SRCS
@minizip_SOURCE_DIR@/ioapi.c
$<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
@minizip_SOURCE_DIR@/minizip.c @minizip_SOURCE_DIR@/zip.c)
if(MINIZIP_BUILD_SHARED)
add_executable(test_example ${MINIZIP_SRCS})
target_link_libraries(test_example MINIZIP::minizip)
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
add_executable(test_example_static ${MINIZIP_SRCS})
target_link_libraries(test_example_static MINIZIP::minizipstatic)
endif(MINIZIP_BUILD_STATIC)

View file

@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.12...3.31)
project(
minizip_add_subdirectory_exclude_from_all
LANGUAGES C
VERSION @minizip_VERSION@)
option(MINIZIP_BUILD_TESTING "" OFF)
option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
option(MINIZIP_ENABLE_BZIP2 "" @MINIZIP_ENABLE_BZIP2@)
add_subdirectory(@minizip_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/minizip)
set(MINIZIP_SRCS
@minizip_SOURCE_DIR@/ioapi.c
$<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
@minizip_SOURCE_DIR@/minizip.c @minizip_SOURCE_DIR@/zip.c)
if(MINIZIP_BUILD_SHARED)
add_executable(test_example ${MINIZIP_SRCS})
target_link_libraries(test_example MINIZIP::minizip)
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
add_executable(test_example_static ${MINIZIP_SRCS})
target_link_libraries(test_example_static MINIZIP::minizipstatic)
endif(MINIZIP_BUILD_STATIC)

View file

@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.12...3.31)
project(
minizip_find_package
LANGUAGES C
VERSION @minizip_VERSION@)
option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
find_package(minizip ${minizip_VERSION} CONFIG REQUIRED)
set(MINIZIP_SRCS
@minizip_SOURCE_DIR@/ioapi.c
$<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
@minizip_SOURCE_DIR@/minizip.c @minizip_SOURCE_DIR@/zip.c)
if(MINIZIP_BUILD_SHARED)
add_executable(test_example ${MINIZIP_SRCS})
target_link_libraries(test_example MINIZIP::minizip)
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
add_executable(test_example_static ${MINIZIP_SRCS})
target_link_libraries(test_example_static MINIZIP::minizipstatic)
endif(MINIZIP_BUILD_STATIC)

View file

@ -0,0 +1,32 @@
if(CREATE_SHARED)
file(REMOVE ./test_file_shared.orig ./test_file_shared.zip)
file(WRITE ./test_file_shared.txt "Hello Hello Hello")
endif(CREATE_SHARED)
if(MOVE_SHARED)
file(RENAME ./test_file_shared.txt ./test_file_shared.orig)
endif(MOVE_SHARED)
if(DELETE_SHARED)
file(REMOVE
./test_file_shared.txt
./test_file_shared.orig
./test_file_shared.zip)
endif(DELETE_SHARED)
if(CREATE_STATIC)
file(REMOVE ./test_file_static.orig ./test_file_static.zip)
file(WRITE ./test_file_static.txt "Hello Hello Hello")
endif(CREATE_STATIC)
if(MOVE_STATIC)
file(RENAME ./test_file_static.txt ./test_file_static.orig)
endif(MOVE_STATIC)
if(DELETE_STATIC)
file(REMOVE
./test_file_static.txt
./test_file_static.orig
./test_file_static.zip)
endif(DELETE_STATIC)

View file

@ -68,10 +68,6 @@
#include <stdlib.h>
#include <string.h>
#ifndef NOUNCRYPT
#define NOUNCRYPT
#endif
#include "zlib.h"
#include "unzip.h"
@ -92,7 +88,7 @@
#ifndef CASESENSITIVITYDEFAULT_NO
# if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
# if (!defined(__unix__) && !defined(__unix) || defined(__CYGWIN__)) && !defined(CASESENSITIVITYDEFAULT_YES)
# define CASESENSITIVITYDEFAULT_NO
# endif
#endif
@ -846,7 +842,7 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK)
err=UNZ_ERRNO;
// relative offset of local header
/* relative offset of local header */
if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK)
err=UNZ_ERRNO;
file_info_internal.offset_curfile = uL;
@ -869,7 +865,7 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
lSeek -= uSizeRead;
}
// Read extrafield
/* Read extrafield */
if ((err==UNZ_OK) && (extraField!=NULL))
{
ZPOS64_T uSizeRead ;
@ -900,7 +896,7 @@ local int unz64local_GetCurrentFileInfoInternal(unzFile file,
{
uLong acc = 0;
// since lSeek now points to after the extra field we need to move back
/* since lSeek now points to after the extra field we need to move back */
lSeek -= file_info.size_file_extra;
if (lSeek!=0)
@ -1529,10 +1525,10 @@ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file) {
file_in_zip64_read_info_s* pfile_in_zip_read_info;
s=(unz64_s*)file;
if (file==NULL)
return 0; //UNZ_PARAMERROR;
return 0; /* UNZ_PARAMERROR; */
pfile_in_zip_read_info=s->pfile_in_zip_read;
if (pfile_in_zip_read_info==NULL)
return 0; //UNZ_PARAMERROR;
return 0; /* UNZ_PARAMERROR; */
return pfile_in_zip_read_info->pos_in_zipfile +
pfile_in_zip_read_info->byte_before_the_zipfile;
}
@ -1613,7 +1609,7 @@ extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) {
uInt i;
for(i=0;i<uReadThis;i++)
pfile_in_zip_read_info->read_buffer[i] =
zdecode(s->keys,s->pcrc_32_tab,
(char)zdecode(s->keys,s->pcrc_32_tab,
pfile_in_zip_read_info->read_buffer[i]);
}
# endif
@ -1701,7 +1697,7 @@ extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) {
if (err!=BZ_OK)
break;
#endif
} // end Z_BZIP2ED
} /* end Z_BZIP2ED */
else
{
ZPOS64_T uTotalOutBefore,uTotalOutAfter;
@ -1944,7 +1940,7 @@ extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) {
unz64_s* s;
if (file==NULL)
return 0; //UNZ_PARAMERROR;
return 0; /* UNZ_PARAMERROR; */
s=(unz64_s*)file;
if (!s->current_file_ok)
return 0;
@ -1958,7 +1954,7 @@ extern uLong ZEXPORT unzGetOffset(unzFile file) {
ZPOS64_T offset64;
if (file==NULL)
return 0; //UNZ_PARAMERROR;
return 0; /* UNZ_PARAMERROR; */
offset64 = unzGetOffset64(file);
return (uLong)offset64;
}

View file

@ -313,6 +313,10 @@ extern int ZEXPORT unzGetCurrentFileInfo(unzFile file,
This is the Central-header version of the extra field
if szComment!=NULL, the comment string of the file will be copied in szComment
(commentBufferSize is the size of the buffer)
The file name and comment will be zero-terminated if there is room in the
provided buffer. Otherwise the buffer will contain as much as will fit. If at
least 65537 bytes of room is provided, then the result will always be
complete and zero-terminated.
*/

View file

@ -25,8 +25,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <time.h>
#ifndef ZLIB_CONST
# define ZLIB_CONST
#endif
#include "zlib.h"
#include "zip.h"
@ -50,7 +52,7 @@
#endif
#ifndef Z_BUFSIZE
#define Z_BUFSIZE (64*1024) //(16384)
#define Z_BUFSIZE (64*1024) /* (16384) */
#endif
#ifndef Z_MAXFILENAMEINZIP
@ -69,7 +71,7 @@
/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */
// NOT sure that this work on ALL platform
/* NOT sure that this work on ALL platform */
#define MAKEULONG64(a, b) ((ZPOS64_T)(((unsigned long)(a)) | ((ZPOS64_T)((unsigned long)(b))) << 32))
#ifndef SEEK_CUR
@ -123,6 +125,19 @@ typedef struct linkedlist_data_s
} linkedlist_data;
/* zipAlreadyThere() set functions for a set of zero-terminated strings, and
// a block_t type for reading the central directory datablocks. */
typedef char *set_key_t;
#define set_cmp(a, b) strcmp(a, b)
#define set_drop(s, k) set_free(s, k)
#include "skipset.h"
typedef struct {
unsigned char *next; /* next byte in datablock data */
size_t left; /* number of bytes left in data (at least) */
linkedlist_datablock_internal *node; /* current datablock */
} block_t;
typedef struct
{
z_stream stream; /* zLib stream structure for inflate */
@ -174,6 +189,10 @@ typedef struct
char *globalcomment;
#endif
/* Support for zipAlreadyThere(). */
set_t set; /* set for detecting name collisions */
block_t block; /* block for reading the central directory */
} zip64_internal;
@ -264,6 +283,228 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
return ZIP_OK;
}
/* zipAlreadyThere() operations. "set" in the zip internal structure keeps the
// set of names that are in the under-construction central directory so far. A
// skipset provides ~O(log n) time insertion and searching. Central directory
// records, stored in a linked list of allocated memory datablocks, is read
// through "block" in the zip internal structure.
// The block_*() functions support extracting the central directory file names
// from the datablocks. They are designed to support a growing directory by
// automatically continuing once more data has been appended to the linked
// datablocks.
// Initialize *block to the head of list. This should only be called once the
// list has at least some data in it, i.e. list->first_block is not NULL. */
local void block_init(block_t *block, linkedlist_data *list) {
block->node = list->first_block;
block->next = block->node->data;
block->left = block->node->filled_in_this_block;
}
/* Mark *block as bad, with all subsequent reads returning end, even if more
// data is added to the datablocks. This is invoked if the central directory is
// invalid, so there is no longer any point in attempting to interpret it. */
local void block_stop(block_t *block) {
block->left = 0;
block->next = NULL;
}
/* Return true if *block has reached the end of the data in the datablocks. */
local int block_end(block_t *block) {
linkedlist_datablock_internal *node = block->node;
if (node == NULL)
/* This block was previously terminated with extreme prejudice. */
return 1;
if (block->next < node->data + node->filled_in_this_block)
/* There are more bytes to read in the current datablock. */
return 0;
while (node->next_datablock != NULL) {
if (node->filled_in_this_block != 0)
/* There are some bytes in a later datablock. */
return 0;
node = node->next_datablock;
}
/* Reached the end of the list of datablocks. There's nothing. */
return 1;
}
/* Return one byte from *block, or -1 if the end is reached. */
local int block_get(block_t *block) {
while (block->left == 0) {
if (block->node == NULL)
/* We've been marked bad. Return end. */
return -1;
/* Update left in case more was filled in since we were last here. */
block->left = block->node->filled_in_this_block -
(block->next - block->node->data);
if (block->left != 0)
/* There was indeed more data appended in the current datablock. */
break;
if (block->node->next_datablock == NULL)
/* No more data here, and there is no next datablock. At the end. */
return -1;
/* Try the next datablock for more data. */
block->node = block->node->next_datablock;
block->next = block->node->data;
block->left = block->node->filled_in_this_block;
}
/* We have a byte to return. */
block->left--;
return *block->next++;
}
/* Return a 16-bit unsigned little-endian value from block, or a negative value
// if the end is reached. */
local long block_get2(block_t *block) {
long got = block_get(block);
return got | ((unsigned long)block_get(block) << 8);
}
/* Read up to len bytes from block into buf. Return the number of bytes read. */
local size_t block_read(block_t *block, unsigned char *buf, size_t len) {
size_t need = len;
while (need) {
if (block->left == 0) {
/* Get a byte to update and step through the linked list as needed. */
int got = block_get(block);
if (got == -1)
/* Reached the end. */
break;
*buf++ = (unsigned char)got;
need--;
continue;
}
size_t take = need > block->left ? block->left : need;
memcpy(buf, block->next, take);
block->next += take;
block->left -= take;
buf += take;
need -= take;
}
return len - need; /* return the number of bytes copied */
}
/* Skip n bytes in block. Return 0 on success or -1 if there are less than n
// bytes to the end. */
local int block_skip(block_t *block, size_t n) {
while (n > block->left) {
n -= block->left;
block->next += block->left;
block->left = 0;
if (block_get(block) == -1)
return -1;
n--;
}
block->next += n;
block->left -= n;
return 0;
}
/* Process the next central directory record at *block. Return the allocated,
// zero-terminated file name, or NULL for end of input or invalid data. If
// invalid, *block is marked bad. This uses *set for the allocation of memory. */
local char *block_central_name(block_t *block, set_t *set) {
char *name = NULL;
for (;;) {
if (block_end(block))
/* At the end of the central directory (so far). */
return NULL;
/* Check for a central directory record signature. */
if (block_get2(block) != (CENTRALHEADERMAGIC & 0xffff) ||
block_get2(block) != (CENTRALHEADERMAGIC >> 16))
/* Incorrect signature. */
break;
/* Go through the remaining fixed-length portion of the record,
// extracting the lengths of the three variable-length fields. */
block_skip(block, 24);
unsigned flen = block_get2(block); /* file name length */
unsigned xlen = block_get2(block); /* extra field length */
unsigned clen = block_get2(block); /* comment field length */
if (block_skip(block, 12) == -1)
/* Premature end of the record. */
break;
/* Extract the name and skip over the extra and comment fields. */
name = set_alloc(set, NULL, flen + 1);
if (block_read(block, (unsigned char *)name, flen) < flen ||
block_skip(block, xlen + clen) == -1)
/* Premature end of the record. */
break;
/* Check for embedded nuls in the name. */
if (memchr(name, 0, flen) != NULL) {
/* This name can never match the zero-terminated name provided to
// zipAlreadyThere(), so we discard it and go back to get another
// name. (Who the heck is putting nuls inside their zip file entry
// names anyway?) */
set_free(set, name);
continue;
}
/* All good. Return the zero-terminated file name. */
name[flen] = 0;
return name;
}
/* Invalid signature or premature end of the central directory record.
// Abandon trying to process the central directory. */
set_free(set, name);
block_stop(block);
return NULL;
}
/* Return 0 if name is not in the central directory so far, 1 if it is, -1 if
// the central directory is invalid, -2 if out of memory, or ZIP_PARAMERROR if
// file is NULL. */
extern int ZEXPORT zipAlreadyThere(zipFile file, char const *name) {
zip64_internal *zip = file;
if (zip == NULL)
return ZIP_PARAMERROR;
if (zip->central_dir.first_block == NULL)
/* No central directory yet, so no, name isn't there. */
return 0;
if (setjmp(zip->set.env)) {
/* Memory allocation failure. */
set_end(&zip->set);
return -2;
}
if (!set_ok(&zip->set)) {
/* This is the first time here with some central directory content. We
// construct this set of names only on demand. Prepare set and block. */
set_start(&zip->set);
block_init(&zip->block, &zip->central_dir);
}
/* Update the set of names from the current central directory contents.
// This reads any new central directory records since the last time we were
// here. */
for (;;) {
char *there = block_central_name(&zip->block, &zip->set);
if (there == NULL) {
if (zip->block.next == NULL)
/* The central directory is invalid. */
return -1;
break;
}
/* Add there to the set. */
if (set_insert(&zip->set, there))
/* There's already a duplicate in the central directory! We'll just
// let this be and carry on. */
set_free(&zip->set, there);
}
/* Return true if name is in the central directory. */
size_t len = strlen(name);
char *copy = set_alloc(&zip->set, NULL, len + 1);
strcpy(copy, name);
int found = set_found(&zip->set, copy);
set_free(&zip->set, copy);
return found;
}
/****************************************************************************/
@ -551,7 +792,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
for (i=(int)uReadSize-3; (i--)>0;)
{
// Signature "0x07064b50" Zip64 end of central directory locater
/* Signature "0x07064b50" Zip64 end of central directory locator */
if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07))
{
uPosFound = uReadPos+(unsigned)i;
@ -599,7 +840,7 @@ local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib
if (zip64local_getLong(pzlib_filefunc_def,filestream,&uL)!=ZIP_OK)
return 0;
if (uL != 0x06064b50) // signature of 'Zip64 end of central directory'
if (uL != 0x06064b50) /* signature of 'Zip64 end of central directory' */
return 0;
return relativeOffset;
@ -628,7 +869,7 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
int hasZIP64Record = 0;
// check first if we find a ZIP64 record
/* check first if we find a ZIP64 record */
central_pos = zip64local_SearchCentralDir64(&pziinit->z_filefunc,pziinit->filestream);
if(central_pos > 0)
{
@ -694,13 +935,13 @@ local int LoadCentralDirectoryRecord(zip64_internal* pziinit) {
if (zip64local_getLong64(&pziinit->z_filefunc, pziinit->filestream,&offset_central_dir)!=ZIP_OK)
err=ZIP_ERRNO;
// TODO..
// read the comment from the standard central header.
/* TODO..
// read the comment from the standard central header. */
size_comment = 0;
}
else
{
// Read End of central Directory info
/* Read End of central Directory info */
if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0)
err=ZIP_ERRNO;
@ -843,6 +1084,7 @@ extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* glo
ziinit.number_entry = 0;
ziinit.add_position_when_writing_offset = 0;
init_linkedlist(&(ziinit.central_dir));
memset(&ziinit.set, 0, sizeof(set_t)); /* make sure set appears dormant */
@ -858,7 +1100,7 @@ extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* glo
ziinit.globalcomment = NULL;
if (append == APPEND_STATUS_ADDINZIP)
{
// Read and Cache Central Directory Records
/* Read and Cache Central Directory Records */
err = LoadCentralDirectoryRecord(&ziinit);
}
@ -942,7 +1184,7 @@ local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt s
if (err==ZIP_OK)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4);
// CRC / Compressed size / Uncompressed size will be filled in later and rewritten later
/* CRC / Compressed size / Uncompressed size will be filled in later and rewritten later */
if (err==ZIP_OK)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */
if (err==ZIP_OK)
@ -986,13 +1228,13 @@ local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt s
if ((err==ZIP_OK) && (zi->ci.zip64))
{
// write the Zip64 extended info
/* write the Zip64 extended info */
short HeaderID = 1;
short DataSize = 16;
ZPOS64_T CompressedSize = 0;
ZPOS64_T UncompressedSize = 0;
// Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file)
/* Remember position of Zip64 extended info for the local file header. (needed when we update size after done with file) */
zi->ci.pos_zip64extrainfo = ZTELL64(zi->z_filefunc,zi->filestream);
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, (ZPOS64_T)HeaderID,2);
@ -1027,7 +1269,6 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
int err = ZIP_OK;
# ifdef NOCRYPT
(crcForCrypting);
if (password != NULL)
return ZIP_PARAMERROR;
# endif
@ -1043,14 +1284,14 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
return ZIP_PARAMERROR;
#endif
// The filename and comment length must fit in 16 bits.
/* The filename and comment length must fit in 16 bits. */
if ((filename!=NULL) && (strlen(filename)>0xffff))
return ZIP_PARAMERROR;
if ((comment!=NULL) && (strlen(comment)>0xffff))
return ZIP_PARAMERROR;
// The extra field length must fit in 16 bits. If the member also requires
/* The extra field length must fit in 16 bits. If the member also requires
// a Zip64 extra block, that will also need to fit within that 16-bit
// length, but that will be checked for later.
// length, but that will be checked for later. */
if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff))
return ZIP_PARAMERROR;
@ -1102,7 +1343,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
zi->ci.pos_local_header = ZTELL64(zi->z_filefunc,zi->filestream);
zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + size_extrafield_global + size_comment;
zi->ci.size_centralExtraFree = 32; // Extra space we have reserved in case we need to add ZIP64 extra info data
zi->ci.size_centralExtraFree = 32; /* Extra space we have reserved in case we need to add ZIP64 extra info data */
zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader + zi->ci.size_centralExtraFree);
@ -1197,7 +1438,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c
else if(zi->ci.method == Z_BZIP2ED)
{
#ifdef HAVE_BZIP2
// Init BZip stuff here
/* Init BZip stuff here */
zi->ci.bstream.bzalloc = 0;
zi->ci.bstream.bzfree = 0;
zi->ci.bstream.opaque = (voidpf)0;
@ -1399,7 +1640,7 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned i
if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))
{
uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32;
// uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32;
/* uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32; */
err=BZ2_bzCompress(&zi->ci.bstream, BZ_RUN);
zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore_lo) ;
@ -1412,7 +1653,7 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned i
else
#endif
{
zi->ci.stream.next_in = (Bytef*)(uintptr_t)buf;
zi->ci.stream.next_in = buf;
zi->ci.stream.avail_in = len;
while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
@ -1457,7 +1698,7 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned i
zi->ci.pos_in_buffered_data += copy_this;
}
}
}// while(...)
}/* while(...) */
}
return err;
@ -1563,7 +1804,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
compressed_size += zi->ci.crypt_header_size;
# endif
// update Current Item crc and sizes,
/* update Current Item crc and sizes, */
if(compressed_size >= 0xffffffff || uncompressed_size >= 0xffffffff || zi->ci.pos_local_header >= 0xffffffff)
{
/*version Made by*/
@ -1581,7 +1822,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
else
zip64local_putValue_inmemory(zi->ci.central_header+20, compressed_size,4); /*compr size*/
/// set internal file attributes field
/* set internal file attributes field */
if (zi->ci.stream.data_type == Z_ASCII)
zip64local_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2);
@ -1590,15 +1831,15 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
else
zip64local_putValue_inmemory(zi->ci.central_header+24, uncompressed_size,4); /*uncompr size*/
// Add ZIP64 extra info field for uncompressed size
/* Add ZIP64 extra info field for uncompressed size */
if(uncompressed_size >= 0xffffffff)
datasize += 8;
// Add ZIP64 extra info field for compressed size
/* Add ZIP64 extra info field for compressed size */
if(compressed_size >= 0xffffffff)
datasize += 8;
// Add ZIP64 extra info field for relative offset to local file header of current file
/* Add ZIP64 extra info field for relative offset to local file header of current file */
if(zi->ci.pos_local_header >= 0xffffffff)
datasize += 8;
@ -1608,16 +1849,16 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
if((uLong)(datasize + 4) > zi->ci.size_centralExtraFree)
{
// we cannot write more data to the buffer that we have room for.
/* we cannot write more data to the buffer that we have room for. */
return ZIP_BADZIPFILE;
}
p = zi->ci.central_header + zi->ci.size_centralheader;
// Add Extra Information Header for 'ZIP64 information'
zip64local_putValue_inmemory(p, 0x0001, 2); // HeaderID
/* Add Extra Information Header for 'ZIP64 information' */
zip64local_putValue_inmemory(p, 0x0001, 2); /* HeaderID */
p += 2;
zip64local_putValue_inmemory(p, datasize, 2); // DataSize
zip64local_putValue_inmemory(p, datasize, 2); /* DataSize */
p += 2;
if(uncompressed_size >= 0xffffffff)
@ -1638,13 +1879,13 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
p += 8;
}
// Update how much extra free space we got in the memory buffer
/* Update how much extra free space we got in the memory buffer
// and increase the centralheader size so the new ZIP64 fields are included
// ( 4 below is the size of HeaderID and DataSize field )
// ( 4 below is the size of HeaderID and DataSize field ) */
zi->ci.size_centralExtraFree -= datasize + 4;
zi->ci.size_centralheader += datasize + 4;
// Update the extra info size field
/* Update the extra info size field */
zi->ci.size_centralExtra += datasize + 4;
zip64local_putValue_inmemory(zi->ci.central_header+30,(uLong)zi->ci.size_centralExtra,2);
}
@ -1656,7 +1897,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
if (err==ZIP_OK)
{
// Update the LocalFileHeader with the new values.
/* Update the LocalFileHeader with the new values. */
ZPOS64_T cur_pos_inzip = ZTELL64(zi->z_filefunc,zi->filestream);
@ -1670,7 +1911,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
{
if(zi->ci.pos_zip64extrainfo > 0)
{
// Update the size in the ZIP64 extended field.
/* Update the size in the ZIP64 extended field. */
if (ZSEEK64(zi->z_filefunc,zi->filestream, zi->ci.pos_zip64extrainfo + 4,ZLIB_FILEFUNC_SEEK_SET)!=0)
err = ZIP_ERRNO;
@ -1681,7 +1922,7 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_si
err = zip64local_putValue(&zi->z_filefunc, zi->filestream, compressed_size, 8);
}
else
err = ZIP_BADZIPFILE; // Caller passed zip64 = 0, so no room for zip64 info -> fatal
err = ZIP_BADZIPFILE; /* Caller passed zip64 = 0, so no room for zip64 info -> fatal */
}
else
{
@ -1735,7 +1976,7 @@ local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDHEADERMAGIC,4);
if (err==ZIP_OK) /* size of this 'zip64 end of central directory' */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)Zip64DataSize,8); // why ZPOS64_T of this ?
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(ZPOS64_T)Zip64DataSize,8); /* why ZPOS64_T of this ? */
if (err==ZIP_OK) /* version made by */
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)45,2);
@ -1782,7 +2023,7 @@ local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centr
{
{
if(zi->number_entry >= 0xFFFF)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); /* use value in ZIP64 record */
else
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);
}
@ -1791,7 +2032,7 @@ local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centr
if (err==ZIP_OK) /* total number of entries in the central dir */
{
if(zi->number_entry >= 0xFFFF)
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); // use value in ZIP64 record
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)0xffff,2); /* use value in ZIP64 record */
else
err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2);
}
@ -1871,6 +2112,8 @@ extern int ZEXPORT zipClose(zipFile file, const char* global_comment) {
}
free_linkedlist(&(zi->central_dir));
set_end(&zi->set); /* set was zeroed, so this is safe */
pos = centraldir_pos_inzip - zi->add_position_when_writing_offset;
if(pos >= 0xffffffff || zi->number_entry >= 0xFFFF)
{
@ -1919,13 +2162,13 @@ extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHea
header = *(short*)p;
dataSize = *(((short*)p)+1);
if( header == sHeader ) // Header found.
if( header == sHeader ) /* Header found. */
{
p += dataSize + 4; // skip it. do not copy to temp buffer
p += dataSize + 4; /* skip it. do not copy to temp buffer */
}
else
{
// Extra Info block should not be removed, So copy it to the temp buffer.
/* Extra Info block should not be removed, So copy it to the temp buffer. */
memcpy(pTmp, p, dataSize + 4);
p += dataSize + 4;
size += dataSize + 4;
@ -1935,14 +2178,14 @@ extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHea
if(size < *dataLen)
{
// clean old extra info block.
/* clean old extra info block. */
memset(pData,0, *dataLen);
// copy the new extra info block over the old
/* copy the new extra info block over the old */
if(size > 0)
memcpy(pData, pNewHeader, size);
// set the new extra info size
/* set the new extra info size */
*dataLen = size;
retVal = ZIP_OK;

View file

@ -35,7 +35,7 @@
See header of zip.h
*/
*/
#ifndef _zip12_H
#define _zip12_H
@ -44,7 +44,7 @@
extern "C" {
#endif
//#define HAVE_BZIP2
/* #define HAVE_BZIP2 */
#ifndef _ZLIB_H
#include "zlib.h"
@ -127,12 +127,12 @@ extern zipFile ZEXPORT zipOpen64(const void *pathname, int append);
If the zipfile cannot be opened, the return value is NULL.
Else, the return value is a zipFile Handle, usable with other function
of this zip package.
*/
*/
/* Note : there is no delete function into a zipfile.
If you want delete file into a zipfile, you must open a zipfile, and create another
Of course, you can use RAW reading and writing to copy the file you did not want delete
*/
*/
extern zipFile ZEXPORT zipOpen2(const char *pathname,
int append,
@ -186,7 +186,7 @@ extern int ZEXPORT zipOpenNewFileInZip64(zipFile file,
zip64 is set to 1 if a zip64 extended information block should be added to the local file header.
this MUST be '1' if the uncompressed size is >= 0xffffffff.
*/
*/
extern int ZEXPORT zipOpenNewFileInZip2(zipFile file,
@ -311,12 +311,12 @@ extern int ZEXPORT zipWriteInFileInZip(zipFile file,
unsigned len);
/*
Write data in the zipfile
*/
*/
extern int ZEXPORT zipCloseFileInZip(zipFile file);
/*
Close the current file in the zipfile
*/
*/
extern int ZEXPORT zipCloseFileInZipRaw(zipFile file,
uLong uncompressed_size,
@ -326,17 +326,23 @@ extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file,
ZPOS64_T uncompressed_size,
uLong crc32);
extern int ZEXPORT zipAlreadyThere(zipFile file,
char const* name);
/*
See if name is already in file's central directory.
*/
/*
Close the current file in the zipfile, for file opened with
parameter raw=1 in zipOpenNewFileInZip2
uncompressed_size and crc32 are value for the uncompressed size
*/
*/
extern int ZEXPORT zipClose(zipFile file,
const char* global_comment);
/*
Close the zipfile
*/
*/
extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader);
@ -355,7 +361,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHea
Remove ZIP64 Extra information from a Local File Header extra field data
zipRemoveExtraInfoBlock(pLocalHeaderExtraFieldData, &nLocalHeaderExtraFieldDataLen, 0x0001);
*/
*/
#ifdef __cplusplus
}

View file

@ -7,7 +7,7 @@
<PackageId Condition="$([MSBuild]::IsOSPlatform('Linux'))">$(PackageId).linux</PackageId>
<PackageId Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(PackageId).osx</PackageId>
<Copyright>(C) 1995-2024 Jean-loup Gailly and Mark Adler</Copyright>
<version>1.3.1</version>
<version>1.3.1.1</version>
<PackageDescription>NuGet Package for consuming native builds of zlib into .NET without complexity.</PackageDescription>
<!--
Warns about not having any lib or ref assemblies (.NET Assemblies) in those directories.

View file

@ -10,7 +10,7 @@ unit zlibpas;
interface
const
ZLIB_VERSION = '1.3.1';
ZLIB_VERSION = '1.3.1.1';
ZLIB_VERNUM = $12a0;
type

View file

@ -16,6 +16,10 @@
testing, and causes pufftest to fail with not enough output space (-f does
a write like -w, so -w is not required). */
#if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE)
# define _CRT_NONSTDC_NO_DEPRECATE
#endif
#include <stdio.h>
#include <stdlib.h>
#include "puff.h"

View file

@ -1,4 +1,4 @@
Building instructions for the DLL versions of Zlib 1.3.1
Building instructions for the DLL versions of Zlib 1.3.1.1
========================================================
This directory contains projects that build zlib and minizip using

View file

@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 3, 1, 0
PRODUCTVERSION 1, 3, 1, 0
FILEVERSION 1, 3, 1, 1
PRODUCTVERSION 1, 3, 1, 1
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@ -17,7 +17,7 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.3.1\0"
VALUE "FileVersion", "1.3.1.1\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0"

View file

@ -1,7 +1,7 @@
LIBRARY
; zlib data compression and ZIP file I/O library
VERSION 1.3.1
VERSION 1.3
EXPORTS
adler32 @1
@ -153,6 +153,9 @@ EXPORTS
crc32_z @175
; zlib1 v1.2.12 added:
crc32_combine_gen @176
crc32_combine_gen64 @177
crc32_combine_op @178
crc32_combine_gen @176
crc32_combine_gen64 @177
crc32_combine_op @178
; zlib1 v1.3.2 added:
deflateUsed @179

View file

@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 3, 1, 0
PRODUCTVERSION 1, 3, 1, 0
FILEVERSION 1, 3, 1, 1
PRODUCTVERSION 1, 3, 1, 1
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@ -17,7 +17,7 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.3.1\0"
VALUE "FileVersion", "1.3.1.1\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0"

View file

@ -1,7 +1,7 @@
LIBRARY
; zlib data compression and ZIP file I/O library
VERSION 1.3.1
VERSION 1.3
EXPORTS
adler32 @1
@ -153,6 +153,9 @@ EXPORTS
crc32_z @175
; zlib1 v1.2.12 added:
crc32_combine_gen @176
crc32_combine_gen64 @177
crc32_combine_op @178
crc32_combine_gen @176
crc32_combine_gen64 @177
crc32_combine_op @178
; zlib1 v1.3.2 added:
deflateUsed @179

View file

@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 3, 1, 0
PRODUCTVERSION 1, 3, 1, 0
FILEVERSION 1, 3, 1, 1
PRODUCTVERSION 1, 3, 1, 1
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@ -17,7 +17,7 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.3.1\0"
VALUE "FileVersion", "1.3.1.1\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0"

View file

@ -1,7 +1,7 @@
LIBRARY
; zlib data compression and ZIP file I/O library
VERSION 1.3.1
VERSION 1.3
EXPORTS
adler32 @1
@ -153,6 +153,9 @@ EXPORTS
crc32_z @175
; zlib1 v1.2.12 added:
crc32_combine_gen @176
crc32_combine_gen64 @177
crc32_combine_op @178
crc32_combine_gen @176
crc32_combine_gen64 @177
crc32_combine_op @178
; zlib1 v1.3.2 added:
deflateUsed @179

View file

@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 3, 1, 0
PRODUCTVERSION 1, 3, 1, 0
FILEVERSION 1, 3, 1, 1
PRODUCTVERSION 1, 3, 1, 1
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@ -17,7 +17,7 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.3.1\0"
VALUE "FileVersion", "1.3.1.1\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0"

View file

@ -1,7 +1,7 @@
LIBRARY
; zlib data compression and ZIP file I/O library
VERSION 1.3.1
VERSION 1.3
EXPORTS
adler32 @1
@ -153,6 +153,9 @@ EXPORTS
crc32_z @175
; zlib1 v1.2.12 added:
crc32_combine_gen @176
crc32_combine_gen64 @177
crc32_combine_op @178
crc32_combine_gen @176
crc32_combine_gen64 @177
crc32_combine_op @178
; zlib1 v1.3.2 added:
deflateUsed @179

View file

@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 3, 1, 0
PRODUCTVERSION 1, 3, 1, 0
FILEVERSION 1, 3, 1, 1
PRODUCTVERSION 1, 3, 1, 1
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@ -17,7 +17,7 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.3.1\0"
VALUE "FileVersion", "1.3.1.1\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0"

View file

@ -1,158 +1,161 @@
LIBRARY
; zlib data compression and ZIP file I/O library
VERSION 1.3.1
EXPORTS
adler32 @1
compress @2
crc32 @3
deflate @4
deflateCopy @5
deflateEnd @6
deflateInit2_ @7
deflateInit_ @8
deflateParams @9
deflateReset @10
deflateSetDictionary @11
gzclose @12
gzdopen @13
gzerror @14
gzflush @15
gzopen @16
gzread @17
gzwrite @18
inflate @19
inflateEnd @20
inflateInit2_ @21
inflateInit_ @22
inflateReset @23
inflateSetDictionary @24
inflateSync @25
uncompress @26
zlibVersion @27
gzprintf @28
gzputc @29
gzgetc @30
gzseek @31
gzrewind @32
gztell @33
gzeof @34
gzsetparams @35
zError @36
inflateSyncPoint @37
get_crc_table @38
compress2 @39
gzputs @40
gzgets @41
inflateCopy @42
inflateBackInit_ @43
inflateBack @44
inflateBackEnd @45
compressBound @46
deflateBound @47
gzclearerr @48
gzungetc @49
zlibCompileFlags @50
deflatePrime @51
deflatePending @52
unzOpen @61
unzClose @62
unzGetGlobalInfo @63
unzGetCurrentFileInfo @64
unzGoToFirstFile @65
unzGoToNextFile @66
unzOpenCurrentFile @67
unzReadCurrentFile @68
unzOpenCurrentFile3 @69
unztell @70
unzeof @71
unzCloseCurrentFile @72
unzGetGlobalComment @73
unzStringFileNameCompare @74
unzLocateFile @75
unzGetLocalExtrafield @76
unzOpen2 @77
unzOpenCurrentFile2 @78
unzOpenCurrentFilePassword @79
zipOpen @80
zipOpenNewFileInZip @81
zipWriteInFileInZip @82
zipCloseFileInZip @83
zipClose @84
zipOpenNewFileInZip2 @86
zipCloseFileInZipRaw @87
zipOpen2 @88
zipOpenNewFileInZip3 @89
unzGetFilePos @100
unzGoToFilePos @101
fill_win32_filefunc @110
; zlibwapi v1.2.4 added:
fill_win32_filefunc64 @111
fill_win32_filefunc64A @112
fill_win32_filefunc64W @113
unzOpen64 @120
unzOpen2_64 @121
unzGetGlobalInfo64 @122
unzGetCurrentFileInfo64 @124
unzGetCurrentFileZStreamPos64 @125
unztell64 @126
unzGetFilePos64 @127
unzGoToFilePos64 @128
zipOpen64 @130
zipOpen2_64 @131
zipOpenNewFileInZip64 @132
zipOpenNewFileInZip2_64 @133
zipOpenNewFileInZip3_64 @134
zipOpenNewFileInZip4_64 @135
zipCloseFileInZipRaw64 @136
; zlib1 v1.2.4 added:
adler32_combine @140
crc32_combine @142
deflateSetHeader @144
deflateTune @145
gzbuffer @146
gzclose_r @147
gzclose_w @148
gzdirect @149
gzoffset @150
inflateGetHeader @156
inflateMark @157
inflatePrime @158
inflateReset2 @159
inflateUndermine @160
; zlib1 v1.2.6 added:
gzgetc_ @161
inflateResetKeep @163
deflateResetKeep @164
; zlib1 v1.2.7 added:
gzopen_w @165
; zlib1 v1.2.8 added:
inflateGetDictionary @166
gzvprintf @167
; zlib1 v1.2.9 added:
inflateCodesUsed @168
inflateValidate @169
uncompress2 @170
gzfread @171
gzfwrite @172
deflateGetDictionary @173
adler32_z @174
crc32_z @175
; zlib1 v1.2.12 added:
crc32_combine_gen @176
crc32_combine_gen64 @177
crc32_combine_op @178
LIBRARY
; zlib data compression and ZIP file I/O library
VERSION 1.3
EXPORTS
adler32 @1
compress @2
crc32 @3
deflate @4
deflateCopy @5
deflateEnd @6
deflateInit2_ @7
deflateInit_ @8
deflateParams @9
deflateReset @10
deflateSetDictionary @11
gzclose @12
gzdopen @13
gzerror @14
gzflush @15
gzopen @16
gzread @17
gzwrite @18
inflate @19
inflateEnd @20
inflateInit2_ @21
inflateInit_ @22
inflateReset @23
inflateSetDictionary @24
inflateSync @25
uncompress @26
zlibVersion @27
gzprintf @28
gzputc @29
gzgetc @30
gzseek @31
gzrewind @32
gztell @33
gzeof @34
gzsetparams @35
zError @36
inflateSyncPoint @37
get_crc_table @38
compress2 @39
gzputs @40
gzgets @41
inflateCopy @42
inflateBackInit_ @43
inflateBack @44
inflateBackEnd @45
compressBound @46
deflateBound @47
gzclearerr @48
gzungetc @49
zlibCompileFlags @50
deflatePrime @51
deflatePending @52
unzOpen @61
unzClose @62
unzGetGlobalInfo @63
unzGetCurrentFileInfo @64
unzGoToFirstFile @65
unzGoToNextFile @66
unzOpenCurrentFile @67
unzReadCurrentFile @68
unzOpenCurrentFile3 @69
unztell @70
unzeof @71
unzCloseCurrentFile @72
unzGetGlobalComment @73
unzStringFileNameCompare @74
unzLocateFile @75
unzGetLocalExtrafield @76
unzOpen2 @77
unzOpenCurrentFile2 @78
unzOpenCurrentFilePassword @79
zipOpen @80
zipOpenNewFileInZip @81
zipWriteInFileInZip @82
zipCloseFileInZip @83
zipClose @84
zipOpenNewFileInZip2 @86
zipCloseFileInZipRaw @87
zipOpen2 @88
zipOpenNewFileInZip3 @89
unzGetFilePos @100
unzGoToFilePos @101
fill_win32_filefunc @110
; zlibwapi v1.2.4 added:
fill_win32_filefunc64 @111
fill_win32_filefunc64A @112
fill_win32_filefunc64W @113
unzOpen64 @120
unzOpen2_64 @121
unzGetGlobalInfo64 @122
unzGetCurrentFileInfo64 @124
unzGetCurrentFileZStreamPos64 @125
unztell64 @126
unzGetFilePos64 @127
unzGoToFilePos64 @128
zipOpen64 @130
zipOpen2_64 @131
zipOpenNewFileInZip64 @132
zipOpenNewFileInZip2_64 @133
zipOpenNewFileInZip3_64 @134
zipOpenNewFileInZip4_64 @135
zipCloseFileInZipRaw64 @136
; zlib1 v1.2.4 added:
adler32_combine @140
crc32_combine @142
deflateSetHeader @144
deflateTune @145
gzbuffer @146
gzclose_r @147
gzclose_w @148
gzdirect @149
gzoffset @150
inflateGetHeader @156
inflateMark @157
inflatePrime @158
inflateReset2 @159
inflateUndermine @160
; zlib1 v1.2.6 added:
gzgetc_ @161
inflateResetKeep @163
deflateResetKeep @164
; zlib1 v1.2.7 added:
gzopen_w @165
; zlib1 v1.2.8 added:
inflateGetDictionary @166
gzvprintf @167
; zlib1 v1.2.9 added:
inflateCodesUsed @168
inflateValidate @169
uncompress2 @170
gzfread @171
gzfwrite @172
deflateGetDictionary @173
adler32_z @174
crc32_z @175
; zlib1 v1.2.12 added:
crc32_combine_gen @176
crc32_combine_gen64 @177
crc32_combine_op @178
; zlib1 v1.3.2 added:
deflateUsed @179

View file

@ -2,8 +2,8 @@
#define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 3, 1, 0
PRODUCTVERSION 1, 3, 1, 0
FILEVERSION 1, 3, 1, 1
PRODUCTVERSION 1, 3, 1, 1
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32
@ -17,7 +17,7 @@ BEGIN
BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.3.1\0"
VALUE "FileVersion", "1.3.1.1\0"
VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0"

View file

@ -1,7 +1,7 @@
LIBRARY
; zlib data compression and ZIP file I/O library
VERSION 1.3.1
VERSION 1.3
EXPORTS
adler32 @1
@ -153,6 +153,9 @@ EXPORTS
crc32_z @175
; zlib1 v1.2.12 added:
crc32_combine_gen @176
crc32_combine_gen64 @177
crc32_combine_op @178
crc32_combine_gen @176
crc32_combine_gen64 @177
crc32_combine_op @178
; zlib1 v1.3.2 added:
deflateUsed @179

View file

@ -52,7 +52,7 @@
#include "deflate.h"
const char deflate_copyright[] =
" deflate 1.3.1 Copyright 1995-2024 Jean-loup Gailly and Mark Adler ";
" deflate 1.3.1.1 Copyright 1995-2024 Jean-loup Gailly and Mark Adler ";
/*
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
@ -719,6 +719,14 @@ int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) {
return Z_OK;
}
/* ========================================================================= */
int ZEXPORT deflateUsed(z_streamp strm, int *bits) {
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
if (bits != Z_NULL)
*bits = strm->state->bi_used;
return Z_OK;
}
/* ========================================================================= */
int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
deflate_state *s;
@ -846,13 +854,13 @@ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
storelen = sourceLen + (sourceLen >> 5) + (sourceLen >> 7) +
(sourceLen >> 11) + 7;
/* if can't get parameters, return larger bound plus a zlib wrapper */
/* if can't get parameters, return larger bound plus a wrapper */
if (deflateStateCheck(strm))
return (fixedlen > storelen ? fixedlen : storelen) + 6;
return (fixedlen > storelen ? fixedlen : storelen) + 18;
/* compute wrapper length */
s = strm->state;
switch (s->wrap) {
switch (s->wrap < 0 ? -s->wrap : s->wrap) {
case 0: /* raw deflate */
wraplen = 0;
break;
@ -882,7 +890,7 @@ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) {
break;
#endif
default: /* for compiler happiness */
wraplen = 6;
wraplen = 18;
}
/* if not default parameters, return one of the conservative bounds */
@ -1635,7 +1643,8 @@ local block_state deflate_stored(deflate_state *s, int flush) {
* possible. If flushing, copy the remaining available input to next_out as
* stored blocks, if there is enough space.
*/
unsigned len, left, have, last = 0;
int last = 0;
unsigned len, left, have;
unsigned used = s->strm->avail_in;
do {
/* Set len to the maximum size block that we can copy directly with the
@ -1671,10 +1680,10 @@ local block_state deflate_stored(deflate_state *s, int flush) {
_tr_stored_block(s, (char *)0, 0L, last);
/* Replace the lengths in the dummy stored block with len. */
s->pending_buf[s->pending - 4] = len;
s->pending_buf[s->pending - 3] = len >> 8;
s->pending_buf[s->pending - 2] = ~len;
s->pending_buf[s->pending - 1] = ~len >> 8;
s->pending_buf[s->pending - 4] = (Bytef)len;
s->pending_buf[s->pending - 3] = (Bytef)(len >> 8);
s->pending_buf[s->pending - 2] = (Bytef)~len;
s->pending_buf[s->pending - 1] = (Bytef)(~len >> 8);
/* Write the stored block header bytes. */
flush_pending(s->strm);
@ -1745,8 +1754,10 @@ local block_state deflate_stored(deflate_state *s, int flush) {
s->high_water = s->strstart;
/* If the last block was written to next_out, then done. */
if (last)
if (last) {
s->bi_used = 8;
return finish_done;
}
/* If flushing and all input has been consumed, then done. */
if (flush != Z_NO_FLUSH && flush != Z_FINISH &&
@ -1798,6 +1809,8 @@ local block_state deflate_stored(deflate_state *s, int flush) {
}
/* We've done all we can with the available input and output. */
if (last)
s->bi_used = 8;
return last ? finish_started : need_more;
}

View file

@ -271,6 +271,9 @@ typedef struct internal_state {
/* Number of valid bits in bi_buf. All bits above the last valid bit
* are always zero.
*/
int bi_used;
/* Last number of used bits when going to a byte boundary.
*/
ulg high_water;
/* High water mark offset in window for initialized bytes -- bytes above

View file

@ -1,7 +1,7 @@
/* enough.c -- determine the maximum size of inflate's Huffman code tables over
* all possible valid and complete prefix codes, subject to a length limit.
* Copyright (C) 2007, 2008, 2012, 2018 Mark Adler
* Version 1.5 5 August 2018 Mark Adler
* Copyright (C) 2007, 2008, 2012, 2018, 2024 Mark Adler
* Version 1.6 29 July 2024 Mark Adler
*/
/* Version history:
@ -19,6 +19,7 @@
Clean up code indentation
1.5 5 Aug 2018 Clean up code style, formatting, and comments
Show all the codes for the maximum, and only the maximum
1.6 29 Jul 2024 Avoid use of uintmax_t
*/
/*
@ -88,33 +89,32 @@
need to be examined to cover all of the possible table memory usage cases
for the default arguments of 286 symbols limited to 15-bit codes.
Note that the uintmax_t type is used for counting. It is quite easy to
Note that unsigned long long is used for counting. It is quite easy to
exceed the capacity of an eight-byte integer with a large number of symbols
and a large maximum code length, so multiple-precision arithmetic would need
to replace the integer arithmetic in that case. This program will abort if
an overflow occurs. The big_t type identifies where the counting takes
place.
The uintmax_t type is also used for calculating the number of possible codes
remaining at the maximum length. This limits the maximum code length to the
number of bits in a long long minus the number of bits needed to represent
the symbols in a flat code. The code_t type identifies where the bit-pattern
counting takes place.
The unsigned long long type is also used for calculating the number of
possible codes remaining at the maximum length. This limits the maximum code
length to the number of bits in a long long minus the number of bits needed
to represent the symbols in a flat code. The code_t type identifies where
the bit-pattern counting takes place.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdint.h>
#include <assert.h>
#define local static
// Special data types.
typedef uintmax_t big_t; // type for code counting
#define PRIbig "ju" // printf format for big_t
typedef uintmax_t code_t; // type for bit pattern counting
typedef unsigned long long big_t; // type for code counting
#define PRIbig "llu" // printf format for big_t
typedef big_t code_t; // type for bit pattern counting
struct tab { // type for been-here check
size_t len; // allocated length of bit vector in octets
char *vec; // allocated bit vector

View file

@ -227,12 +227,12 @@ local int lunpipe(unsigned have, z_const unsigned char *next, struct ind *indp,
if (last == -1)
return Z_BUF_ERROR;
if (flags & 0x60) {
strm->msg = (char *)"unknown lzw flags set";
strm->msg = (z_const char *)"unknown lzw flags set";
return Z_DATA_ERROR;
}
max = flags & 0x1f;
if (max < 9 || max > 16) {
strm->msg = (char *)"lzw bits out of range";
strm->msg = (z_const char *)"lzw bits out of range";
return Z_DATA_ERROR;
}
if (max == 9) /* 9 doesn't really mean 9 */
@ -252,7 +252,7 @@ local int lunpipe(unsigned have, z_const unsigned char *next, struct ind *indp,
if (NEXT() == -1) /* missing a bit */
return Z_BUF_ERROR;
if (last & 1) { /* code must be < 256 */
strm->msg = (char *)"invalid lzw code";
strm->msg = (z_const char *)"invalid lzw code";
return Z_DATA_ERROR;
}
rem = (unsigned)last >> 1; /* remaining 7 bits */
@ -319,7 +319,7 @@ local int lunpipe(unsigned have, z_const unsigned char *next, struct ind *indp,
to detect random or corrupted input after a compress header.
In any case, the prev > end check must be retained. */
if (code != end + 1 || prev > end) {
strm->msg = (char *)"invalid lzw code";
strm->msg = (z_const char *)"invalid lzw code";
return Z_DATA_ERROR;
}
match[stack++] = (unsigned char)final;
@ -404,7 +404,7 @@ local int gunpipe(z_stream *strm, int infile, int outfile)
break; /* empty gzip stream is ok */
}
if (last != 31 || (NEXT() != 139 && last != 157)) {
strm->msg = (char *)"incorrect header check";
strm->msg = (z_const char *)"incorrect header check";
ret = first ? Z_DATA_ERROR : Z_ERRNO;
break; /* not a gzip or compress header */
}
@ -420,7 +420,7 @@ local int gunpipe(z_stream *strm, int infile, int outfile)
ret = Z_BUF_ERROR;
if (NEXT() != 8) { /* only deflate method allowed */
if (last == -1) break;
strm->msg = (char *)"unknown compression method";
strm->msg = (z_const char *)"unknown compression method";
ret = Z_DATA_ERROR;
break;
}
@ -433,7 +433,7 @@ local int gunpipe(z_stream *strm, int infile, int outfile)
NEXT();
if (last == -1) break;
if (flags & 0xe0) {
strm->msg = (char *)"unknown header flags set";
strm->msg = (z_const char *)"unknown header flags set";
ret = Z_DATA_ERROR;
break;
}
@ -486,7 +486,7 @@ local int gunpipe(z_stream *strm, int infile, int outfile)
NEXT() != (int)((outd.crc >> 24) & 0xff)) {
/* crc error */
if (last != -1) {
strm->msg = (char *)"incorrect data check";
strm->msg = (z_const char *)"incorrect data check";
ret = Z_DATA_ERROR;
}
break;
@ -497,7 +497,7 @@ local int gunpipe(z_stream *strm, int infile, int outfile)
NEXT() != (int)((outd.total >> 24) & 0xff)) {
/* length error */
if (last != -1) {
strm->msg = (char *)"incorrect length check";
strm->msg = (z_const char *)"incorrect length check";
ret = Z_DATA_ERROR;
}
break;

View file

@ -10,6 +10,10 @@
// the data, so it is fast, but no advantage is gained from the history that
// could be available across member boundaries.
#if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE)
# define _CRT_NONSTDC_NO_DEPRECATE
#endif
#include <stdio.h> // fread, fwrite, putc, fflush, ferror, fprintf,
// vsnprintf, stdout, stderr, NULL, FILE
#include <stdlib.h> // malloc, free

View file

@ -12,6 +12,10 @@
Avoid some compiler warnings for input and output buffers
*/
#if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE)
# define _CRT_NONSTDC_NO_DEPRECATE
#endif
#include <stdio.h>
#include <string.h>
#include <assert.h>

View file

@ -1,7 +1,7 @@
/* zran.c -- example of deflate stream indexing and random access
* Copyright (C) 2005, 2012, 2018, 2023 Mark Adler
* Copyright (C) 2005, 2012, 2018, 2023, 2024 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* Version 1.4 13 Apr 2023 Mark Adler */
* Version 1.6 2 Aug 2024 Mark Adler */
/* Version History:
1.0 29 May 2005 First version
@ -14,6 +14,11 @@
Do a binary search over the index for an access point
Expose the access point type to enable save and load
1.4 13 Apr 2023 Add a NOPRIME define to not use inflatePrime()
1.5 4 Feb 2024 Set returned index to NULL on an index build error
Stop decoding once request is satisfied
Provide a reusable inflate engine in the index
Allocate the dictionaries to reduce memory usage
1.6 2 Aug 2024 Remove unneeded dependency on limits.h
*/
// Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary()
@ -57,7 +62,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "zlib.h"
#include "zran.h"
@ -67,7 +71,11 @@
// See comments in zran.h.
void deflate_index_free(struct deflate_index *index) {
if (index != NULL) {
size_t i = index->have;
while (i)
free(index->list[--i].window);
free(index->list);
inflateEnd(&index->strm);
free(index);
}
}
@ -76,26 +84,12 @@ void deflate_index_free(struct deflate_index *index) {
// list and return NULL. index->mode is temporarily the allocated number of
// access points, until it is time for deflate_index_build() to return. Then
// index->mode is set to the mode of inflation.
static struct deflate_index *add_point(struct deflate_index *index, int bits,
off_t in, off_t out, unsigned left,
static struct deflate_index *add_point(struct deflate_index *index, off_t in,
off_t out, off_t beg,
unsigned char *window) {
if (index == NULL) {
// The list is empty. Create it, starting with eight access points.
index = malloc(sizeof(struct deflate_index));
if (index == NULL)
return NULL;
index->have = 0;
index->mode = 8;
index->list = malloc(sizeof(point_t) * index->mode);
if (index->list == NULL) {
free(index);
return NULL;
}
}
else if (index->have == index->mode) {
if (index->have == index->mode) {
// The list is full. Make it bigger.
index->mode <<= 1;
index->mode = index->mode ? index->mode << 1 : 8;
point_t *next = realloc(index->list, sizeof(point_t) * index->mode);
if (next == NULL) {
deflate_index_free(index);
@ -113,11 +107,18 @@ static struct deflate_index *add_point(struct deflate_index *index, int bits,
}
next->out = out;
next->in = in;
next->bits = bits;
if (left)
memcpy(next->window, window + WINSIZE - left, left);
if (left < WINSIZE)
memcpy(next->window + left, window, WINSIZE - left);
next->bits = index->strm.data_type & 7;
next->dict = out - beg > WINSIZE ? WINSIZE : (unsigned)(out - beg);
next->window = malloc(next->dict);
if (next->window == NULL) {
deflate_index_free(index);
return NULL;
}
unsigned recent = WINSIZE - index->strm.avail_out;
unsigned copy = recent > next->dict ? next->dict : recent;
memcpy(next->window + next->dict - copy, window + recent - copy, copy);
copy = next->dict - copy;
memcpy(next->window, window + WINSIZE - copy, copy);
// Return the index, which may have been newly allocated or destroyed.
return index;
@ -130,25 +131,39 @@ static struct deflate_index *add_point(struct deflate_index *index, int bits,
// See comments in zran.h.
int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) {
// Set up inflation state.
z_stream strm = {0}; // inflate engine (gets fired up later)
// If this returns with an error, any attempt to use the index will cleanly
// return an error.
*built = NULL;
// Create and initialize the index list.
struct deflate_index *index = malloc(sizeof(struct deflate_index));
if (index == NULL)
return Z_MEM_ERROR;
index->have = 0;
index->mode = 0; // entries in index->list allocation
index->list = NULL;
index->strm.state = Z_NULL; // so inflateEnd() can work
// Set up the inflation state.
index->strm.avail_in = 0;
index->strm.avail_out = 0;
unsigned char buf[CHUNK]; // input buffer
unsigned char win[WINSIZE] = {0}; // output sliding window
off_t totin = 0; // total bytes read from input
off_t totout = 0; // total bytes uncompressed
off_t beg = 0; // starting offset of last history reset
int mode = 0; // mode: RAW, ZLIB, or GZIP (0 => not set yet)
// Decompress from in, generating access points along the way.
int ret; // the return value from zlib, or Z_ERRNO
off_t last; // last access point uncompressed offset
struct deflate_index *index = NULL; // list of access points
do {
// Assure available input, at least until reaching EOF.
if (strm.avail_in == 0) {
strm.avail_in = fread(buf, 1, sizeof(buf), in);
totin += strm.avail_in;
strm.next_in = buf;
if (strm.avail_in < sizeof(buf) && ferror(in)) {
if (index->strm.avail_in == 0) {
index->strm.avail_in = fread(buf, 1, sizeof(buf), in);
totin += index->strm.avail_in;
index->strm.next_in = buf;
if (index->strm.avail_in < sizeof(buf) && ferror(in)) {
ret = Z_ERRNO;
break;
}
@ -159,11 +174,14 @@ int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) {
// in a false positive for zlib, but in practice the fill bits
// after a stored block are always zeros, so a raw stream won't
// start with an 8 in the low nybble.
mode = strm.avail_in == 0 ? RAW : // empty -- will fail
(strm.next_in[0] & 0xf) == 8 ? ZLIB :
strm.next_in[0] == 0x1f ? GZIP :
mode = index->strm.avail_in == 0 ? RAW : // will fail
(index->strm.next_in[0] & 0xf) == 8 ? ZLIB :
index->strm.next_in[0] == 0x1f ? GZIP :
/* else */ RAW;
ret = inflateInit2(&strm, mode);
index->strm.zalloc = Z_NULL;
index->strm.zfree = Z_NULL;
index->strm.opaque = Z_NULL;
ret = inflateInit2(&index->strm, mode);
if (ret != Z_OK)
break;
}
@ -171,32 +189,32 @@ int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) {
// Assure available output. This rotates the output through, for use as
// a sliding window on the uncompressed data.
if (strm.avail_out == 0) {
strm.avail_out = sizeof(win);
strm.next_out = win;
if (index->strm.avail_out == 0) {
index->strm.avail_out = sizeof(win);
index->strm.next_out = win;
}
if (mode == RAW && index == NULL)
if (mode == RAW && index->have == 0)
// We skip the inflate() call at the start of raw deflate data in
// order generate an access point there. Set data_type to imitate
// the end of a header.
strm.data_type = 0x80;
index->strm.data_type = 0x80;
else {
// Inflate and update the number of uncompressed bytes.
unsigned before = strm.avail_out;
ret = inflate(&strm, Z_BLOCK);
totout += before - strm.avail_out;
unsigned before = index->strm.avail_out;
ret = inflate(&index->strm, Z_BLOCK);
totout += before - index->strm.avail_out;
}
if ((strm.data_type & 0xc0) == 0x80 &&
(index == NULL || totout - last >= span)) {
if ((index->strm.data_type & 0xc0) == 0x80 &&
(index->have == 0 || totout - last >= span)) {
// We are at the end of a header or a non-last deflate block, so we
// can add an access point here. Furthermore, we are either at the
// very start for the first access point, or there has been span or
// more uncompressed bytes since the last access point, so we want
// to add an access point here.
index = add_point(index, strm.data_type & 7, totin - strm.avail_in,
totout, strm.avail_out, win);
index = add_point(index, totin - index->strm.avail_in, totout, beg,
win);
if (index == NULL) {
ret = Z_MEM_ERROR;
break;
@ -205,16 +223,17 @@ int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) {
}
if (ret == Z_STREAM_END && mode == GZIP &&
(strm.avail_in || ungetc(getc(in), in) != EOF))
(index->strm.avail_in || ungetc(getc(in), in) != EOF)) {
// There is more input after the end of a gzip member. Reset the
// inflate state to read another gzip member. On success, this will
// set ret to Z_OK to continue decompressing.
ret = inflateReset2(&strm, GZIP);
ret = inflateReset2(&index->strm, GZIP);
beg = totout; // reset history
}
// Keep going until Z_STREAM_END or error. If the compressed data ends
// prematurely without a file read error, Z_BUF_ERROR is returned.
} while (ret == Z_OK);
inflateEnd(&strm);
if (ret != Z_STREAM_END) {
// An error was encountered. Discard the index and return a negative
@ -223,17 +242,9 @@ int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) {
return ret == Z_NEED_DICT ? Z_DATA_ERROR : ret;
}
// Shrink the index to only the occupied access points and return it.
// Return the index.
index->mode = mode;
index->length = totout;
point_t *list = realloc(index->list, sizeof(point_t) * index->have);
if (list == NULL) {
// Seems like a realloc() to make something smaller should always work,
// but just in case.
deflate_index_free(index);
return Z_MEM_ERROR;
}
index->list = list;
*built = index;
return index->have;
}
@ -330,7 +341,8 @@ static int inflatePreface(z_stream *strm, int bits, int value) {
ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index,
off_t offset, unsigned char *buf, size_t len) {
// Do a quick sanity check on the index.
if (index == NULL || index->have < 1 || index->list[0].out != 0)
if (index == NULL || index->have < 1 || index->list[0].out != 0 ||
index->strm.state == Z_NULL)
return Z_STREAM_ERROR;
// If nothing to extract, return zero bytes extracted.
@ -356,13 +368,13 @@ ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index,
int ch = 0;
if (point->bits && (ch = getc(in)) == EOF)
return ferror(in) ? Z_ERRNO : Z_BUF_ERROR;
z_stream strm = {0};
ret = inflateInit2(&strm, RAW);
index->strm.avail_in = 0;
ret = inflateReset2(&index->strm, RAW);
if (ret != Z_OK)
return ret;
if (point->bits)
INFLATEPRIME(&strm, point->bits, ch >> (8 - point->bits));
inflateSetDictionary(&strm, point->window, WINSIZE);
INFLATEPRIME(&index->strm, point->bits, ch >> (8 - point->bits));
inflateSetDictionary(&index->strm, point->window, point->dict);
// Skip uncompressed bytes until offset reached, then satisfy request.
unsigned char input[CHUNK];
@ -372,48 +384,54 @@ ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index,
do {
if (offset) {
// Discard up to offset uncompressed bytes.
strm.avail_out = offset < WINSIZE ? (unsigned)offset : WINSIZE;
strm.next_out = discard;
index->strm.avail_out = offset < WINSIZE ? (unsigned)offset :
WINSIZE;
index->strm.next_out = discard;
}
else {
// Uncompress up to left bytes into buf.
strm.avail_out = left < UINT_MAX ? (unsigned)left : UINT_MAX;
strm.next_out = buf + len - left;
index->strm.avail_out = left < (unsigned)-1 ? (unsigned)left :
(unsigned)-1;
index->strm.next_out = buf + len - left;
}
// Uncompress, setting got to the number of bytes uncompressed.
if (strm.avail_in == 0) {
if (index->strm.avail_in == 0) {
// Assure available input.
strm.avail_in = fread(input, 1, CHUNK, in);
if (strm.avail_in < CHUNK && ferror(in)) {
index->strm.avail_in = fread(input, 1, CHUNK, in);
if (index->strm.avail_in < CHUNK && ferror(in)) {
ret = Z_ERRNO;
break;
}
strm.next_in = input;
index->strm.next_in = input;
}
unsigned got = strm.avail_out;
ret = inflate(&strm, Z_NO_FLUSH);
got -= strm.avail_out;
unsigned got = index->strm.avail_out;
ret = inflate(&index->strm, Z_NO_FLUSH);
got -= index->strm.avail_out;
// Update the appropriate count.
if (offset)
offset -= got;
else
else {
left -= got;
if (left == 0)
// Request satisfied.
break;
}
// If we're at the end of a gzip member and there's more to read,
// continue to the next gzip member.
if (ret == Z_STREAM_END && index->mode == GZIP) {
// Discard the gzip trailer.
unsigned drop = 8; // length of gzip trailer
if (strm.avail_in >= drop) {
strm.avail_in -= drop;
strm.next_in += drop;
if (index->strm.avail_in >= drop) {
index->strm.avail_in -= drop;
index->strm.next_in += drop;
}
else {
// Read and discard the remainder of the gzip trailer.
drop -= strm.avail_in;
strm.avail_in = 0;
drop -= index->strm.avail_in;
index->strm.avail_in = 0;
do {
if (getc(in) == EOF)
// The input does not have a complete trailer.
@ -421,33 +439,32 @@ ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index,
} while (--drop);
}
if (strm.avail_in || ungetc(getc(in), in) != EOF) {
if (index->strm.avail_in || ungetc(getc(in), in) != EOF) {
// There's more after the gzip trailer. Use inflate to skip the
// gzip header and resume the raw inflate there.
inflateReset2(&strm, GZIP);
inflateReset2(&index->strm, GZIP);
do {
if (strm.avail_in == 0) {
strm.avail_in = fread(input, 1, CHUNK, in);
if (strm.avail_in < CHUNK && ferror(in)) {
if (index->strm.avail_in == 0) {
index->strm.avail_in = fread(input, 1, CHUNK, in);
if (index->strm.avail_in < CHUNK && ferror(in)) {
ret = Z_ERRNO;
break;
}
strm.next_in = input;
index->strm.next_in = input;
}
strm.avail_out = WINSIZE;
strm.next_out = discard;
ret = inflate(&strm, Z_BLOCK); // stop at end of header
} while (ret == Z_OK && (strm.data_type & 0x80) == 0);
index->strm.avail_out = WINSIZE;
index->strm.next_out = discard;
ret = inflate(&index->strm, Z_BLOCK); // stop after header
} while (ret == Z_OK && (index->strm.data_type & 0x80) == 0);
if (ret != Z_OK)
break;
inflateReset2(&strm, RAW);
inflateReset2(&index->strm, RAW);
}
}
// Continue until we have the requested data, the deflate data has
// ended, or an error is encountered.
} while (ret == Z_OK && left);
inflateEnd(&strm);
} while (ret == Z_OK);
// Return the number of uncompressed bytes read into buf, or the error.
return ret == Z_OK || ret == Z_STREAM_END ? len - left : ret;

View file

@ -1,7 +1,7 @@
/* zran.h -- example of deflated stream indexing and random access
* Copyright (C) 2005, 2012, 2018, 2023 Mark Adler
* Copyright (C) 2005, 2012, 2018, 2023, 2024 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
* Version 1.3 18 Feb 2023 Mark Adler */
* Version 1.5 4 Feb 2024 Mark Adler */
#include <stdio.h>
#include "zlib.h"
@ -11,7 +11,8 @@ typedef struct point {
off_t out; // offset in uncompressed data
off_t in; // offset in compressed file of first full byte
int bits; // 0, or number of bits (1-7) from byte at in-1
unsigned char window[32768]; // preceding 32K of uncompressed data
unsigned dict; // number of bytes in window to use as a dictionary
unsigned char *window; // preceding 32K (or less) of uncompressed data
} point_t;
// Access point list.
@ -20,6 +21,7 @@ struct deflate_index {
int mode; // -15 for raw, 15 for zlib, or 31 for gzip
off_t length; // total length of uncompressed data
point_t *list; // allocated list of access points
z_stream strm; // re-usable inflate engine for extraction
};
// Make one pass through a zlib, gzip, or raw deflate compressed stream and
@ -30,7 +32,7 @@ struct deflate_index {
// the number of access points on success (>= 1), Z_MEM_ERROR for out of
// memory, Z_BUF_ERROR for a premature end of input, Z_DATA_ERROR for a format
// or verification error in the input file, or Z_ERRNO for a file read error.
// On success, *built points to the resulting index.
// On success, *built points to the resulting index, otherwise it's NULL.
int deflate_index_build(FILE *in, off_t span, struct deflate_index **built);
// Use the index to read len bytes from offset into buf. Return the number of

View file

@ -17,6 +17,18 @@
# define ZLIB_INTERNAL
#endif
#if defined(_WIN32)
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
# endif
# ifndef _CRT_NONSTDC_NO_DEPRECATE
# define _CRT_NONSTDC_NO_DEPRECATE
# endif
#endif
#include <stdio.h>
#include "zlib.h"
#ifdef STDC
@ -25,8 +37,8 @@
# include <limits.h>
#endif
#ifndef _POSIX_SOURCE
# define _POSIX_SOURCE
#ifndef _POSIX_C_SOURCE
# define _POSIX_C_SOURCE 200112L
#endif
#include <fcntl.h>
@ -36,19 +48,13 @@
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
# include <io.h>
# include <sys/stat.h>
#endif
#if defined(_WIN32)
#if defined(_WIN32) && !defined(WIDECHAR)
# define WIDECHAR
#endif
#ifdef WINAPI_FAMILY
# define open _open
# define read _read
# define write _write
# define close _close
#endif
#ifdef NO_DEFLATE /* for compatibility with old definition */
# define NO_GZCOMPRESS
#endif
@ -72,33 +78,28 @@
#endif
#ifndef HAVE_VSNPRINTF
# ifdef MSDOS
# if !defined(NO_vsnprintf) && \
(defined(MSDOS) || defined(__TURBOC__) || defined(__SASC) || \
defined(VMS) || defined(__OS400) || defined(__MVS__))
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
but for now we just assume it doesn't. */
# define NO_vsnprintf
# endif
# ifdef __TURBOC__
# define NO_vsnprintf
# endif
# ifdef WIN32
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
# define vsnprintf _vsnprintf
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
# ifndef vsnprintf
# define vsnprintf _vsnprintf
# endif
# endif
# endif
# ifdef __SASC
# define NO_vsnprintf
# endif
# ifdef VMS
# define NO_vsnprintf
# endif
# ifdef __OS400__
# define NO_vsnprintf
# endif
# ifdef __MVS__
# define NO_vsnprintf
# elif !defined(__STDC_VERSION__) || __STDC_VERSION__-0 < 199901L
/* Otherwise if C89/90, assume no C99 snprintf() or vsnprintf() */
# ifndef NO_snprintf
# define NO_snprintf
# endif
# ifndef NO_vsnprintf
# define NO_vsnprintf
# endif
# endif
#endif

29
gzlib.c
View file

@ -5,15 +5,15 @@
#include "gzguts.h"
#if defined(_WIN32) && !defined(__BORLANDC__)
#if defined(__DJGPP__)
# define LSEEK llseek
#elif defined(_WIN32) && !defined(__BORLANDC__) && !defined(UNDER_CE)
# define LSEEK _lseeki64
#else
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
#elif defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
# define LSEEK lseek64
#else
# define LSEEK lseek
#endif
#endif
#if defined UNDER_CE
@ -52,7 +52,7 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
msgbuf[chars] = 0;
}
wcstombs(buf, msgbuf, chars + 1);
wcstombs(buf, msgbuf, chars + 1); // assumes buf is big enough
LocalFree(msgbuf);
}
else {
@ -179,11 +179,8 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
/* save the path name for error messages */
#ifdef WIDECHAR
if (fd == -2) {
if (fd == -2)
len = wcstombs(NULL, path, 0);
if (len == (z_size_t)-1)
len = 0;
}
else
#endif
len = strlen((const char *)path);
@ -193,18 +190,21 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
return NULL;
}
#ifdef WIDECHAR
if (fd == -2)
if (fd == -2) {
if (len)
wcstombs(state->path, path, len + 1);
else
*(state->path) = 0;
}
else
#endif
{
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
(void)snprintf(state->path, len + 1, "%s", (const char *)path);
#else
strcpy(state->path, path);
#endif
}
/* compute the flags for open() */
oflag =
@ -228,11 +228,14 @@ local gzFile gz_open(const void *path, int fd, const char *mode) {
O_APPEND)));
/* open the file with the appropriate flags (or just use fd) */
state->fd = fd > -1 ? fd : (
if (fd == -1)
state->fd = open((const char *)path, oflag, 0666);
#ifdef WIDECHAR
fd == -2 ? _wopen(path, oflag, 0666) :
else if (fd == -2)
state->fd = _wopen(path, oflag, _S_IREAD | _S_IWRITE);
#endif
open((const char *)path, oflag, 0666));
else
state->fd = fd;
if (state->fd == -1) {
free(state->path);
free(state);

View file

@ -374,7 +374,8 @@ int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) {
}
/* -- see zlib.h -- */
z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) {
z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
gzFile file) {
z_size_t len;
gz_statep state;

View file

@ -46,7 +46,7 @@ int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
#ifdef Z_SOLO
return Z_STREAM_ERROR;
#else
strm->zfree = zcfree;
strm->zfree = zcfree;
#endif
state = (struct inflate_state FAR *)ZALLOC(strm, 1,
sizeof(struct inflate_state));
@ -304,7 +304,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
state->mode = TABLE;
break;
case 3:
strm->msg = (char *)"invalid block type";
strm->msg = (z_const char *)"invalid block type";
state->mode = BAD;
}
DROPBITS(2);
@ -315,7 +315,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
BYTEBITS(); /* go to byte boundary */
NEEDBITS(32);
if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
strm->msg = (char *)"invalid stored block lengths";
strm->msg = (z_const char *)"invalid stored block lengths";
state->mode = BAD;
break;
}
@ -353,7 +353,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
DROPBITS(4);
#ifndef PKZIP_BUG_WORKAROUND
if (state->nlen > 286 || state->ndist > 30) {
strm->msg = (char *)"too many length or distance symbols";
strm->msg = (z_const char *)"too many length or distance symbols";
state->mode = BAD;
break;
}
@ -375,7 +375,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
ret = inflate_table(CODES, state->lens, 19, &(state->next),
&(state->lenbits), state->work);
if (ret) {
strm->msg = (char *)"invalid code lengths set";
strm->msg = (z_const char *)"invalid code lengths set";
state->mode = BAD;
break;
}
@ -398,7 +398,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
NEEDBITS(here.bits + 2);
DROPBITS(here.bits);
if (state->have == 0) {
strm->msg = (char *)"invalid bit length repeat";
strm->msg = (z_const char *)"invalid bit length repeat";
state->mode = BAD;
break;
}
@ -421,7 +421,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
DROPBITS(7);
}
if (state->have + copy > state->nlen + state->ndist) {
strm->msg = (char *)"invalid bit length repeat";
strm->msg = (z_const char *)"invalid bit length repeat";
state->mode = BAD;
break;
}
@ -435,7 +435,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
/* check for end-of-block code (better have one) */
if (state->lens[256] == 0) {
strm->msg = (char *)"invalid code -- missing end-of-block";
strm->msg = (z_const char *)"invalid code -- missing end-of-block";
state->mode = BAD;
break;
}
@ -449,7 +449,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
&(state->lenbits), state->work);
if (ret) {
strm->msg = (char *)"invalid literal/lengths set";
strm->msg = (z_const char *)"invalid literal/lengths set";
state->mode = BAD;
break;
}
@ -458,7 +458,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
&(state->next), &(state->distbits), state->work);
if (ret) {
strm->msg = (char *)"invalid distances set";
strm->msg = (z_const char *)"invalid distances set";
state->mode = BAD;
break;
}
@ -517,7 +517,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
/* invalid code */
if (here.op & 64) {
strm->msg = (char *)"invalid literal/length code";
strm->msg = (z_const char *)"invalid literal/length code";
state->mode = BAD;
break;
}
@ -549,7 +549,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
}
DROPBITS(here.bits);
if (here.op & 64) {
strm->msg = (char *)"invalid distance code";
strm->msg = (z_const char *)"invalid distance code";
state->mode = BAD;
break;
}
@ -564,7 +564,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
}
if (state->offset > state->wsize - (state->whave < state->wsize ?
left : 0)) {
strm->msg = (char *)"invalid distance too far back";
strm->msg = (z_const char *)"invalid distance too far back";
state->mode = BAD;
break;
}

View file

@ -155,7 +155,7 @@ void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
dist += (unsigned)hold & ((1U << op) - 1);
#ifdef INFLATE_STRICT
if (dist > dmax) {
strm->msg = (char *)"invalid distance too far back";
strm->msg = (z_const char *)"invalid distance too far back";
state->mode = BAD;
break;
}
@ -169,7 +169,7 @@ void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
if (op > whave) {
if (state->sane) {
strm->msg =
(char *)"invalid distance too far back";
(z_const char *)"invalid distance too far back";
state->mode = BAD;
break;
}
@ -265,7 +265,7 @@ void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
goto dodist;
}
else {
strm->msg = (char *)"invalid distance code";
strm->msg = (z_const char *)"invalid distance code";
state->mode = BAD;
break;
}
@ -280,7 +280,7 @@ void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
break;
}
else {
strm->msg = (char *)"invalid literal/length code";
strm->msg = (z_const char *)"invalid literal/length code";
state->mode = BAD;
break;
}

View file

@ -642,12 +642,12 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
if (
#endif
((BITS(8) << 8) + (hold >> 8)) % 31) {
strm->msg = (char *)"incorrect header check";
strm->msg = (z_const char *)"incorrect header check";
state->mode = BAD;
break;
}
if (BITS(4) != Z_DEFLATED) {
strm->msg = (char *)"unknown compression method";
strm->msg = (z_const char *)"unknown compression method";
state->mode = BAD;
break;
}
@ -656,7 +656,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
if (state->wbits == 0)
state->wbits = len;
if (len > 15 || len > state->wbits) {
strm->msg = (char *)"invalid window size";
strm->msg = (z_const char *)"invalid window size";
state->mode = BAD;
break;
}
@ -672,12 +672,12 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
NEEDBITS(16);
state->flags = (int)(hold);
if ((state->flags & 0xff) != Z_DEFLATED) {
strm->msg = (char *)"unknown compression method";
strm->msg = (z_const char *)"unknown compression method";
state->mode = BAD;
break;
}
if (state->flags & 0xe000) {
strm->msg = (char *)"unknown header flags set";
strm->msg = (z_const char *)"unknown header flags set";
state->mode = BAD;
break;
}
@ -793,7 +793,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
if (state->flags & 0x0200) {
NEEDBITS(16);
if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
strm->msg = (char *)"header crc mismatch";
strm->msg = (z_const char *)"header crc mismatch";
state->mode = BAD;
break;
}
@ -855,7 +855,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
state->mode = TABLE;
break;
case 3:
strm->msg = (char *)"invalid block type";
strm->msg = (z_const char *)"invalid block type";
state->mode = BAD;
}
DROPBITS(2);
@ -864,7 +864,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
BYTEBITS(); /* go to byte boundary */
NEEDBITS(32);
if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
strm->msg = (char *)"invalid stored block lengths";
strm->msg = (z_const char *)"invalid stored block lengths";
state->mode = BAD;
break;
}
@ -905,7 +905,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
DROPBITS(4);
#ifndef PKZIP_BUG_WORKAROUND
if (state->nlen > 286 || state->ndist > 30) {
strm->msg = (char *)"too many length or distance symbols";
strm->msg = (z_const char *)"too many length or distance symbols";
state->mode = BAD;
break;
}
@ -923,12 +923,12 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
while (state->have < 19)
state->lens[order[state->have++]] = 0;
state->next = state->codes;
state->lencode = (const code FAR *)(state->next);
state->lencode = state->distcode = (const code FAR *)(state->next);
state->lenbits = 7;
ret = inflate_table(CODES, state->lens, 19, &(state->next),
&(state->lenbits), state->work);
if (ret) {
strm->msg = (char *)"invalid code lengths set";
strm->msg = (z_const char *)"invalid code lengths set";
state->mode = BAD;
break;
}
@ -952,7 +952,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
NEEDBITS(here.bits + 2);
DROPBITS(here.bits);
if (state->have == 0) {
strm->msg = (char *)"invalid bit length repeat";
strm->msg = (z_const char *)"invalid bit length repeat";
state->mode = BAD;
break;
}
@ -975,7 +975,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
DROPBITS(7);
}
if (state->have + copy > state->nlen + state->ndist) {
strm->msg = (char *)"invalid bit length repeat";
strm->msg = (z_const char *)"invalid bit length repeat";
state->mode = BAD;
break;
}
@ -989,7 +989,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
/* check for end-of-block code (better have one) */
if (state->lens[256] == 0) {
strm->msg = (char *)"invalid code -- missing end-of-block";
strm->msg = (z_const char *)"invalid code -- missing end-of-block";
state->mode = BAD;
break;
}
@ -1003,7 +1003,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
&(state->lenbits), state->work);
if (ret) {
strm->msg = (char *)"invalid literal/lengths set";
strm->msg = (z_const char *)"invalid literal/lengths set";
state->mode = BAD;
break;
}
@ -1012,7 +1012,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
&(state->next), &(state->distbits), state->work);
if (ret) {
strm->msg = (char *)"invalid distances set";
strm->msg = (z_const char *)"invalid distances set";
state->mode = BAD;
break;
}
@ -1066,7 +1066,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
break;
}
if (here.op & 64) {
strm->msg = (char *)"invalid literal/length code";
strm->msg = (z_const char *)"invalid literal/length code";
state->mode = BAD;
break;
}
@ -1104,7 +1104,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
DROPBITS(here.bits);
state->back += here.bits;
if (here.op & 64) {
strm->msg = (char *)"invalid distance code";
strm->msg = (z_const char *)"invalid distance code";
state->mode = BAD;
break;
}
@ -1121,7 +1121,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
}
#ifdef INFLATE_STRICT
if (state->offset > state->dmax) {
strm->msg = (char *)"invalid distance too far back";
strm->msg = (z_const char *)"invalid distance too far back";
state->mode = BAD;
break;
}
@ -1136,7 +1136,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
copy = state->offset - copy;
if (copy > state->whave) {
if (state->sane) {
strm->msg = (char *)"invalid distance too far back";
strm->msg = (z_const char *)"invalid distance too far back";
state->mode = BAD;
break;
}
@ -1195,7 +1195,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
state->flags ? hold :
#endif
ZSWAP32(hold)) != state->check) {
strm->msg = (char *)"incorrect data check";
strm->msg = (z_const char *)"incorrect data check";
state->mode = BAD;
break;
}
@ -1209,7 +1209,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) {
if (state->wrap && state->flags) {
NEEDBITS(32);
if ((state->wrap & 4) && hold != (state->total & 0xffffffff)) {
strm->msg = (char *)"incorrect length check";
strm->msg = (z_const char *)"incorrect length check";
state->mode = BAD;
break;
}

View file

@ -100,7 +100,7 @@ struct inflate_state {
unsigned char FAR *window; /* allocated sliding window, if needed */
/* bit accumulator */
unsigned long hold; /* input bit accumulator */
unsigned bits; /* number of bits in "in" */
unsigned bits; /* number of bits in hold */
/* for string and stored block copying */
unsigned length; /* literal or length of data to copy */
unsigned offset; /* distance back to copy string from */

View file

@ -9,7 +9,7 @@
#define MAXBITS 15
const char inflate_copyright[] =
" inflate 1.3.1 Copyright 1995-2024 Mark Adler ";
" inflate 1.3.1.1 Copyright 1995-2024 Mark Adler ";
/*
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
@ -57,7 +57,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
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 */
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, 203, 77};
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 73, 200};
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,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,

View file

@ -30,7 +30,7 @@ CC=gcc
#CFLAGS=-MMD -O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
#CFLAGS=-MMD -g -DZLIB_DEBUG
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith \
-Wstrict-prototypes -Wmissing-prototypes
# If cp.exe is available, replace "copy /Y" with "cp -fp" .

View file

@ -3,7 +3,7 @@
# test works out-of-the-box, installs `somewhere' on demand
# Toolflags:
CCflags = -c -depend !Depend -IC: -g -throwback -DRISCOS -fah
CCflags = -c -depend !Depend -IC: -g -throwback -fah
C++flags = -c -depend !Depend -IC: -throwback
Linkflags = -aif -c++ -o $@
ObjAsmflags = -throwback -NoCache -depend !Depend

View file

@ -1,4 +1,4 @@
ZLIB version 1.3.1 for OS/400 installation instructions
ZLIB version 1.3.1.1 for OS/400 installation instructions
1) Download and unpack the zlib tarball to some IFS directory.
(i.e.: /path/to/the/zlib/ifs/source/directory)

View file

@ -124,4 +124,10 @@ STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('ZLIB')
EXPORT SYMBOL("crc32_combine_gen")
EXPORT SYMBOL("crc32_combine_op")
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
/* Version 1.3.2 additional entry points. */
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
EXPORT SYMBOL("deflateUsed")
ENDPGMEXP

View file

@ -1,7 +1,7 @@
* ZLIB.INC - Interface to the general purpose compression library
*
* ILE RPG400 version by Patrick Monnerat, DATASPHERE.
* Version 1.3.1
* Version 1.3.1.1
*
*
* WARNING:
@ -22,14 +22,14 @@
*
* Versioning information.
*
D ZLIB_VERSION C '1.3.1'
D ZLIB_VERSION C '1.3.1.1'
D ZLIB_VERNUM C X'12a0'
D ZLIB_VER_MAJOR C 1
D ZLIB_VER_MINOR C 3
D ZLIB_VER_REVISION...
D C 1
D ZLIB_VER_SUBREVISION...
D C 0
D C 1
*
* Other equates.
*
@ -371,6 +371,10 @@
D pending 10U 0 Pending bytes
D bits 10I 0 Pending bits
*
D deflateUsed PR 10I 0 extproc('deflateUsed') Get used bits
D strm like(z_stream) Compression stream
D bits 10I 0 Used bits
*
D deflatePrime PR 10I 0 extproc('deflatePrime') Change level & strat
D strm like(z_stream) Compression stream
D bits 10I 0 value # of bits to insert

View file

@ -25,10 +25,10 @@
<QPG:Files>
<QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/>
<QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/>
<QPG:Add file="../libz.so.1.3.1" install="/opt/lib/" user="root:bin" permission="644"/>
<QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.3.1"/>
<QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.3.1"/>
<QPG:Add file="../libz.so.1.3.1" install="/opt/lib/" component="slib"/>
<QPG:Add file="../libz.so.1.3.1.1" install="/opt/lib/" user="root:bin" permission="644"/>
<QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.3.1.1"/>
<QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.3.1.1"/>
<QPG:Add file="../libz.so.1.3.1.1" install="/opt/lib/" component="slib"/>
</QPG:Files>
<QPG:PackageFilter>
@ -58,12 +58,12 @@
<QPM:ProductIconLarge></QPM:ProductIconLarge>
<QPM:ProductDescriptionShort>A massively spiffy yet delicately unobtrusive compression library.</QPM:ProductDescriptionShort>
<QPM:ProductDescriptionLong>zlib is designed to be a free, general-purpose, legally unencumbered, lossless data compression library for use on virtually any computer hardware and operating system.</QPM:ProductDescriptionLong>
<QPM:ProductDescriptionURL>http://www.gzip.org/zlib</QPM:ProductDescriptionURL>
<QPM:ProductDescriptionURL>https://zlib.net/</QPM:ProductDescriptionURL>
<QPM:ProductDescriptionEmbedURL></QPM:ProductDescriptionEmbedURL>
</QPM:ProductDescription>
<QPM:ReleaseDescription>
<QPM:ReleaseVersion>1.3.1</QPM:ReleaseVersion>
<QPM:ReleaseVersion>1.3.1.1</QPM:ReleaseVersion>
<QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
<QPM:ReleaseStability>Stable</QPM:ReleaseStability>
<QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>

265
test/CMakeLists.txt Normal file
View file

@ -0,0 +1,265 @@
function(ZLIB_findTestEnv testName)
set(testEnv "PATH=")
if(MSVC OR MINGW)
set(separator "\\\;")
else()
set(separator ":")
endif()
string(APPEND testEnv "$<TARGET_FILE_DIR:ZLIB::ZLIB>${separator}")
string(APPEND testEnv "$ENV{PATH}")
set_tests_properties(${testName} PROPERTIES ENVIRONMENT "${testEnv}")
endfunction()
if(ZLIB_BUILD_SHARED)
add_executable(zlib_example example.c)
target_link_libraries(zlib_example ZLIB::ZLIB)
target_compile_definitions(zlib_example PRIVATE ZLIB_BUILD)
add_test(NAME zlib_example COMMAND zlib_example)
add_executable(minigzip minigzip.c)
target_compile_definitions(
minigzip PRIVATE $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
target_link_libraries(minigzip ZLIB::ZLIB)
if(MSVC
OR MSYS
OR MINGW
OR CYGWIN)
zlib_findtestenv(zlib_example)
endif(
MSVC
OR MSYS
OR MINGW
OR CYGWIN)
if(HAVE_OFF64_T)
add_executable(zlib_example64 example.c)
target_compile_definitions(
zlib_example64
PRIVATE ZLIB_BUILD
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
target_link_libraries(zlib_example64 ZLIB::ZLIB)
add_test(NAME zlib_example64 COMMAND zlib_example64)
if(MSVC
OR MSYS
OR MINGW
OR CYGWIN)
zlib_findtestenv(zlib_example64)
endif(
MSVC
OR MSYS
OR MINGW
OR CYGWIN)
endif(HAVE_OFF64_T)
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
add_executable(zlib_static_example example.c)
target_link_libraries(zlib_static_example ZLIB::ZLIBSTATIC)
target_compile_definitions(
zlib_static_example
PRIVATE ZLIB_BUILD
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
add_test(NAME zlib_static_example COMMAND zlib_static_example)
add_executable(static_minigzip minigzip.c)
target_link_libraries(static_minigzip ZLIB::ZLIBSTATIC)
if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL
"Clang")
set(CFLAGS_OLD ${CMAKE_C_FLAGS})
set({CMAKE_C_FLAGS
""
CACHE STRING "" FORCE)
if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
find_program(GCOV_EXECUTABLE gcov)
endif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
set(llvm_names llvm_cov)
list(APPEND llvm_names llvm-cov)
foreach(ver RANGE 11 99)
list(APPEND llvm_names llvm-cov-${ver})
endforeach(ver RANGE 11 99)
find_program(GCOV_EXECUTABLE NAMES ${llvm_names})
set(llvm_option "gcov")
endif(${CMAKE_C_COMPILER_ID} STREQUAL "Clang")
add_executable(infcover infcover.c)
target_link_libraries(infcover ZLIB::ZLIBSTATIC)
target_compile_options(infcover PRIVATE -coverage)
target_link_options(infcover PRIVATE -coverage)
target_compile_definitions(
infcover PRIVATE $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
add_test(NAME zlib-coverage COMMAND infcover)
set(INFCOVER_DIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/infcover.dir)
add_test(
NAME zlib-coverage-summary
COMMAND
${GCOV_EXECUTABLE} ${llvm_option}
${CMAKE_CURRENT_SOURCE_DIR}/infcover.c -o
${INFCOVER_DIR}/infcover.c.gcda)
set_tests_properties(zlib-coverage-summary PROPERTIES DEPENDS
zlib-coverage)
set({CMAKE_C_FLAGS
${CFLAGS_OLD}
CACHE STRING "" FORCE)
endif(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID}
STREQUAL "Clang")
if(HAVE_OFF64_T)
add_executable(zlib_static_example64 example.c)
target_compile_definitions(
zlib_static_example64
PRIVATE ZLIB_BUILD
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
target_link_libraries(zlib_static_example64 ZLIB::ZLIBSTATIC)
add_test(NAME zlib_static_example64 COMMAND zlib_static_example64)
endif(HAVE_OFF64_T)
endif(ZLIB_BUILD_STATIC)
add_test(
NAME zlib_install
COMMAND ${CMAKE_COMMAND} --install ${zlib_BINARY_DIR} --prefix
${CMAKE_CURRENT_BINARY_DIR}/test_install --config $<CONFIG>
WORKING_DIRECTORY ${zlib_BINARY_DIR})
set_tests_properties(zlib_install PROPERTIES FIXTURES_SETUP zlib_install)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt
@ONLY)
# CMAKE_GENERATOR_PLATFORM doesn't work in the if
set(GENERATOR ${CMAKE_GENERATOR_PLATFORM})
if(GENERATOR)
set(PLATFORM "-A ${GENERATOR}")
endif(GENERATOR)
#
# findpackage_test
#
add_test(
NAME zlib_find_package_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install --fresh
-G "${CMAKE_GENERATOR}" -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(
NAME zlib_find_package_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
add_test(
NAME zlib_find_package_test
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
set_tests_properties(
zlib_find_package_configure PROPERTIES FIXTURES_REQUIRED zlib_install
FIXTURES_SETUP fp_config)
set_tests_properties(
zlib_find_package_build PROPERTIES FIXTURES_REQUIRED fp_config
FIXTURES_SETUP fp_build)
set_tests_properties(
zlib_find_package_test PROPERTIES FIXTURES_REQUIRED fp_build ENVIRONMENT
CTEST_OUTPUT_ON_FAILURE=1)
#
# add_subdirectory_test
#
add_test(
NAME zlib_add_subdirectory_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install --fresh
-G "${CMAKE_GENERATOR}" -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(
NAME zlib_add_subdirectory_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
add_test(
NAME zlib_add_subdirectory_test
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
set_tests_properties(
zlib_add_subdirectory_configure PROPERTIES FIXTURES_REQUIRED zlib_install
FIXTURES_SETUP as_config)
set_tests_properties(
zlib_add_subdirectory_build PROPERTIES FIXTURES_REQUIRED as_config
FIXTURES_SETUP as_build)
set_tests_properties(
zlib_add_subdirectory_test PROPERTIES FIXTURES_REQUIRED as_build
ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
#
# add_subdirectory_exclude_test
#
add_test(
NAME zlib_add_subdirectory_exclude_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install --fresh
-G "${CMAKE_GENERATOR}" -S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(
NAME zlib_add_subdirectory_exclude_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
add_test(
NAME zlib_add_subdirectory_exclude_test
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
set_tests_properties(
zlib_add_subdirectory_exclude_configure
PROPERTIES FIXTURES_REQUIRED zlib_install FIXTURES_SETUP asx_config)
set_tests_properties(
zlib_add_subdirectory_exclude_build PROPERTIES FIXTURES_REQUIRED as_config
FIXTURES_SETUP asx_build)
set_tests_properties(
zlib_add_subdirectory_exclude_test
PROPERTIES FIXTURES_REQUIRED asx_build ENVIRONMENT
CTEST_OUTPUT_ON_FAILURE=1)

View file

@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.12...3.31)
project(
zlib_find_package_test
LANGUAGES C
VERSION @zlib_VERSION@)
enable_testing()
option(ZLIB_BUILD_TESTING "" OFF)
option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
add_subdirectory(@zlib_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/zlib
EXCLUDE_FROM_ALL)
if(ZLIB_BUILD_SHARED)
add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example ZLIB::ZLIB)
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
add_test(NAME zlib_test_example_shared COMMAND test_example)
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
add_test(NAME zlib_test_example_static COMMAND test_example_static)
endif(ZLIB_BUILD_STATIC)

View file

@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.12...3.31)
project(
zlib_find_package_test
LANGUAGES C
VERSION @zlib_VERSION@)
enable_testing()
option(ZLIB_BUILD_TESTING "" OFF)
option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
add_subdirectory(@zlib_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/zlib)
if(ZLIB_BUILD_SHARED)
add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example ZLIB::ZLIB)
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
add_test(NAME zlib_test_example_shared COMMAND test_example)
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
add_test(NAME zlib_test_example_static COMMAND test_example_static)
endif(@ZLIB_BUILD_STATIC)

View file

@ -5,6 +5,10 @@
/* @(#) $Id$ */
#if defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS)
# define _CRT_SECURE_NO_WARNINGS
#endif
#include "zlib.h"
#include <stdio.h>
@ -13,8 +17,10 @@
# include <stdlib.h>
#endif
#if defined(VMS) || defined(RISCOS)
#if defined(VMS)
# define TESTFILE "foo-gz"
#elif defined(__riscos) && !defined(__TARGET_UNIXLIB__)
# define TESTFILE "foo/gz"
#else
# define TESTFILE "foo.gz"
#endif

View file

@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.12...3.31)
project(
zlib_find_package_test
LANGUAGES C
VERSION @zlib_VERSION@)
enable_testing()
find_package(ZLIB @zlib_VERSION@ CONFIG REQUIRED)
option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
if(ZLIB_BUILD_SHARED)
add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example ZLIB::ZLIB)
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
add_test(NAME zlib_test_example_shared COMMAND test_example)
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
add_test(NAME zlib_test_example_static COMMAND test_example_static)
endif(ZLIB_BUILD_STATIC)

View file

@ -1,5 +1,5 @@
/* infcover.c -- test zlib's inflate routines with full code coverage
* Copyright (C) 2011, 2016 Mark Adler
* Copyright (C) 2011, 2016, 2024 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@ -185,7 +185,7 @@ local void mem_used(z_stream *strm, char *prefix)
{
struct mem_zone *zone = strm->opaque;
fprintf(stderr, "%s: %lu allocated\n", prefix, zone->total);
fprintf(stderr, "%s: %zu allocated\n", prefix, zone->total);
}
/* show the high water allocation in bytes */
@ -193,7 +193,7 @@ local void mem_high(z_stream *strm, char *prefix)
{
struct mem_zone *zone = strm->opaque;
fprintf(stderr, "%s: %lu high water mark\n", prefix, zone->highwater);
fprintf(stderr, "%s: %zu high water mark\n", prefix, zone->highwater);
}
/* release the memory allocation zone -- if there are any surprises, notify */
@ -218,7 +218,7 @@ local void mem_done(z_stream *strm, char *prefix)
/* issue alerts about anything unexpected */
if (count || zone->total)
fprintf(stderr, "** %s: %lu bytes in %d blocks not freed\n",
fprintf(stderr, "** %s: %zu bytes in %d blocks not freed\n",
prefix, zone->total, count);
if (zone->notlifo)
fprintf(stderr, "** %s: %d frees not LIFO\n", prefix, zone->notlifo);
@ -444,7 +444,7 @@ local void cover_wrap(void)
}
/* input and output functions for inflateBack() */
local unsigned pull(void *desc, unsigned char **buf)
local unsigned pull(void *desc, unsigned char z_const **buf)
{
static unsigned int next = 0;
static unsigned char dat[] = {0x63, 0, 2, 0};

View file

@ -15,6 +15,17 @@
/* @(#) $Id$ */
#ifndef _POSIX_C_SOURCE
# define _POSIX_C_SOURCE 200112L
#endif
#if defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS)
# define _CRT_SECURE_NO_WARNINGS
#endif
#if defined(_WIN32) && !defined(_CRT_NONSTDC_NO_DEPRECATE)
# define _CRT_NONSTDC_NO_DEPRECATE
#endif
#include "zlib.h"
#include <stdio.h>
@ -40,18 +51,16 @@
# define SET_BINARY_MODE(file)
#endif
#if defined(_MSC_VER) && _MSC_VER < 1900
# define snprintf _snprintf
#endif
#ifdef VMS
# define unlink delete
# define GZ_SUFFIX "-gz"
#endif
#ifdef RISCOS
# define unlink remove
# define GZ_SUFFIX "-gz"
# define fileno(file) file->__file
#if defined(__riscos) && !defined(__TARGET_UNIXLIB__)
# define GZ_SUFFIX "/gz"
# ifndef __GNUC__
# define unlink remove
# define fileno(file) file->__file
# endif
#endif
#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fileno */
@ -142,6 +151,25 @@ static void pwinerror (s)
# define local
#endif
/* ===========================================================================
* Safe string copy. Copy up to len bytes from src to dst, if src terminates
* with a null by then. If not, copy len-1 bytes from src, terminating it with
* a null in dst[len-1], cutting src short. Return a pointer to the terminating
* null. If len is zero, nothing is written to *dst and NULL is returned.
*/
static char *string_copy(char *dst, char const *src, z_size_t len) {
if (len == 0)
return NULL;
while (--len) {
*dst = *src++;
if (*dst == 0)
return dst;
dst++;
}
*dst = 0;
return dst;
}
#ifdef Z_SOLO
/* for Z_SOLO, create simplified gz* functions using deflate and inflate */
@ -391,7 +419,7 @@ static void gz_uncompress(gzFile in, FILE *out) {
* original.
*/
static void file_compress(char *file, char *mode) {
local char outfile[MAX_NAME_LEN];
local char outfile[MAX_NAME_LEN+1], *end;
FILE *in;
gzFile out;
@ -400,12 +428,8 @@ static void file_compress(char *file, char *mode) {
exit(1);
}
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
snprintf(outfile, sizeof(outfile), "%s%s", file, GZ_SUFFIX);
#else
strcpy(outfile, file);
strcat(outfile, GZ_SUFFIX);
#endif
end = string_copy(outfile, file, sizeof(outfile));
string_copy(end, GZ_SUFFIX, sizeof(outfile) - (z_size_t)(end - outfile));
in = fopen(file, "rb");
if (in == NULL) {
@ -427,7 +451,7 @@ static void file_compress(char *file, char *mode) {
* Uncompress the given file and remove the original.
*/
static void file_uncompress(char *file) {
local char buf[MAX_NAME_LEN];
local char buf[MAX_NAME_LEN+1];
char *infile, *outfile;
FILE *out;
gzFile in;
@ -438,11 +462,7 @@ static void file_uncompress(char *file) {
exit(1);
}
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
snprintf(buf, sizeof(buf), "%s", file);
#else
strcpy(buf, file);
#endif
string_copy(buf, file, sizeof(buf));
if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) {
infile = file;
@ -451,11 +471,7 @@ static void file_uncompress(char *file) {
} else {
outfile = file;
infile = buf;
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
snprintf(buf + len, sizeof(buf) - len, "%s", GZ_SUFFIX);
#else
strcat(infile, GZ_SUFFIX);
#endif
string_copy(buf + len, GZ_SUFFIX, sizeof(buf) - len);
}
in = gzopen(infile, "rb");
if (in == NULL) {
@ -488,14 +504,9 @@ int main(int argc, char *argv[]) {
int copyout = 0;
int uncompr = 0;
gzFile file;
char *bname, outmode[20];
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
snprintf(outmode, sizeof(outmode), "%s", "wb6 ");
#else
strcpy(outmode, "wb6 ");
#endif
char *bname, outmode[5];
string_copy(outmode, "wb6 ", sizeof(outmode));
prog = argv[0];
bname = strrchr(argv[0], '/');
if (bname)

View file

@ -1,6 +1,6 @@
<?xml version="1.0" ?>
<package name="zlib" version="1.3.1">
<library name="zlib" dlversion="1.3.1" dlname="z">
<package name="zlib" version="1.3.1.1">
<library name="zlib" dlversion="1.3.1.1" dlname="z">
<property name="description"> zip compression library </property>
<property name="include-target-dir" value="$(@PACKAGE/install-includedir)" />

View file

@ -184,6 +184,7 @@ local void bi_windup(deflate_state *s) {
} else if (s->bi_valid > 0) {
put_byte(s, (Byte)s->bi_buf);
}
s->bi_used = ((s->bi_valid - 1) & 7) + 1;
s->bi_buf = 0;
s->bi_valid = 0;
#ifdef ZLIB_DEBUG
@ -466,6 +467,7 @@ void ZLIB_INTERNAL _tr_init(deflate_state *s) {
s->bi_buf = 0;
s->bi_valid = 0;
s->bi_used = 0;
#ifdef ZLIB_DEBUG
s->compressed_len = 0L;
s->bits_sent = 0L;
@ -724,7 +726,7 @@ local void scan_tree(deflate_state *s, ct_data *tree, int max_code) {
if (++count < max_count && curlen == nextlen) {
continue;
} else if (count < min_count) {
s->bl_tree[curlen].Freq += count;
s->bl_tree[curlen].Freq += (ush)count;
} else if (curlen != 0) {
if (curlen != prevlen) s->bl_tree[curlen].Freq++;
s->bl_tree[REP_3_6].Freq++;

View file

@ -6,7 +6,7 @@ This document describes the design, the rationale, and the usage
of the common DLL build of zlib, named ZLIB1.DLL. If you have
general questions about zlib, you should see the file "FAQ" found
in the zlib distribution, or at the following location:
http://www.gzip.org/zlib/zlib_faq.html
https://www.zlib.net/zlib_faq.html
1. What is ZLIB1.DLL, and how can I get it?

View file

@ -50,7 +50,7 @@ AR = $(PREFIX)ar
ARFLAGS = rcs
RC = $(PREFIX)windres
RCFLAGS = --define GCC_WINDRES
RCFLAGS =
STRIP = $(PREFIX)strip

View file

@ -1,6 +1,6 @@
ZLIB DATA COMPRESSION LIBRARY
zlib 1.3.1 is a general purpose data compression library. All the code is
zlib 1.3.1.1 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
(Request for Comments) 1950 to 1952 in the files
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
@ -22,7 +22,7 @@ asking for help.
Manifest:
The package zlib-1.3.1-win32-x86.zip will contain the following files:
The package zlib-1.3.1.1-win32-x86.zip will contain the following files:
README-WIN32.txt This document
ChangeLog Changes since previous zlib packages

View file

@ -15,6 +15,7 @@ EXPORTS
deflateTune
deflateBound
deflatePending
deflateUsed
deflatePrime
deflateSetHeader
inflateSetDictionary

View file

@ -1,11 +1,8 @@
#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

Some files were not shown because too many files have changed in this diff Show more