Commit 5372a0f1 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

1.3

parent 3bab137f
cmake_minimum_required(VERSION 2.4.4) cmake_minimum_required(VERSION 2.4.4...3.15.0)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
project(zlib C) project(zlib C)
set(VERSION "1.2.13") set(VERSION "1.3")
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") 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_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
......
ChangeLog file for zlib ChangeLog file for zlib
Changes in 1.3 (18 Aug 2023)
- Remove K&R function definitions and zlib2ansi
- Fix bug in deflateBound() for level 0 and memLevel 9
- Fix bug when gzungetc() is used immediately after gzopen()
- Fix bug when using gzflush() with a very small buffer
- Fix crash when gzsetparams() attempted for transparent write
- Fix test/example.c to work with FORCE_STORED
- Rewrite of zran in examples (see zran.c version history)
- Fix minizip to allow it to open an empty zip file
- Fix reading disk number start on zip64 files in minizip
- Fix logic error in minizip argument processing
- Add minizip testing to Makefile
- Read multiple bytes instead of byte-by-byte in minizip unzip.c
- Add memory sanitizer to configure (--memory)
- Various portability improvements
- Various documentation improvements
- Various spelling and typo corrections
Changes in 1.2.13 (13 Oct 2022) Changes in 1.2.13 (13 Oct 2022)
- Fix configure issue that discarded provided CC definition - Fix configure issue that discarded provided CC definition
- Correct incorrect inputs provided to the CRC functions - Correct incorrect inputs provided to the CRC functions
...@@ -1445,7 +1463,7 @@ Changes in 0.99 (27 Jan 96) ...@@ -1445,7 +1463,7 @@ Changes in 0.99 (27 Jan 96)
- fix typo in Make_vms.com (f$trnlnm -> f$getsyi) - fix typo in Make_vms.com (f$trnlnm -> f$getsyi)
- in fcalloc, normalize pointer if size > 65520 bytes - in fcalloc, normalize pointer if size > 65520 bytes
- don't use special fcalloc for 32 bit Borland C++ - don't use special fcalloc for 32 bit Borland C++
- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc... - use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc.
- use Z_BINARY instead of BINARY - use Z_BINARY instead of BINARY
- document that gzclose after gzdopen will close the file - document that gzclose after gzdopen will close the file
- allow "a" as mode in gzopen - allow "a" as mode in gzopen
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
If your question is not there, please check the zlib home page If your question is not there, please check the zlib home page
http://zlib.net/ which may have more recent information. http://zlib.net/ which may have more recent information.
The lastest zlib FAQ is at http://zlib.net/zlib_faq.html The latest zlib FAQ is at http://zlib.net/zlib_faq.html
1. Is zlib Y2K-compliant? 1. Is zlib Y2K-compliant?
......
...@@ -28,7 +28,7 @@ CPP=$(CC) -E ...@@ -28,7 +28,7 @@ CPP=$(CC) -E
STATICLIB=libz.a STATICLIB=libz.a
SHAREDLIB=libz.so SHAREDLIB=libz.so
SHAREDLIBV=libz.so.1.2.13 SHAREDLIBV=libz.so.1.3
SHAREDLIBM=libz.so.1 SHAREDLIBM=libz.so.1
LIBS=$(STATICLIB) $(SHAREDLIBV) LIBS=$(STATICLIB) $(SHAREDLIBV)
...@@ -359,8 +359,14 @@ zconf.h.cmakein: $(SRCDIR)zconf.h.in ...@@ -359,8 +359,14 @@ zconf.h.cmakein: $(SRCDIR)zconf.h.in
zconf: $(SRCDIR)zconf.h.in zconf: $(SRCDIR)zconf.h.in
cp -p $(SRCDIR)zconf.h.in zconf.h cp -p $(SRCDIR)zconf.h.in zconf.h
minizip-test: static
cd contrib/minizip && { CFLAGS="$(CFLAGS)" $(MAKE) test ; cd ../.. ; }
minizip-clean:
cd contrib/minizip && { $(MAKE) clean ; cd ../.. ; }
mostlyclean: clean mostlyclean: clean
clean: clean: minizip-clean
rm -f *.o *.lo *~ \ rm -f *.o *.lo *~ \
example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \ example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
example64$(EXE) minigzip64$(EXE) \ example64$(EXE) minigzip64$(EXE) \
......
ZLIB DATA COMPRESSION LIBRARY ZLIB DATA COMPRESSION LIBRARY
zlib 1.2.13 is a general purpose data compression library. All the code is zlib 1.3 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files (Request for Comments) 1950 to 1952 in the files
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
...@@ -29,18 +29,17 @@ PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. ...@@ -29,18 +29,17 @@ PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997 Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available at issue of Dr. Dobb's Journal; a copy of the article is available at
http://marknelson.us/1997/01/01/zlib-engine/ . https://marknelson.us/posts/1997/01/01/zlib-engine.html .
The changes made in version 1.2.13 are documented in the file ChangeLog. The changes made in version 1.3 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory contrib/ . Unsupported third party contributions are provided in directory contrib/ .
zlib is available in Java using the java.util.zip package, documented at zlib is available in Java using the java.util.zip package. Follow the API
http://java.sun.com/developer/technicalArticles/Programming/compression/ . Documentation link at: https://docs.oracle.com/search/?q=java.util.zip .
A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is available A Perl interface to zlib and bzip2 written by Paul Marquess <pmqs@cpan.org>
at CPAN (Comprehensive Perl Archive Network) sites, including can be found at https://github.com/pmqs/IO-Compress .
http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
available in Python 1.5 and later versions, see available in Python 1.5 and later versions, see
...@@ -64,7 +63,7 @@ Notes for some targets: ...@@ -64,7 +63,7 @@ Notes for some targets:
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
when compiled with cc. when compiled with cc.
- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is - On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is
necessary to get gzprintf working correctly. This is done by configure. necessary to get gzprintf working correctly. This is done by configure.
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
...@@ -84,7 +83,7 @@ Acknowledgments: ...@@ -84,7 +83,7 @@ Acknowledgments:
Copyright notice: Copyright notice:
(C) 1995-2022 Jean-loup Gailly and Mark Adler (C) 1995-2023 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages warranty. In no event will the authors be held liable for any damages
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include "zutil.h" #include "zutil.h"
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
#define BASE 65521U /* largest prime smaller than 65536 */ #define BASE 65521U /* largest prime smaller than 65536 */
#define NMAX 5552 #define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
...@@ -60,11 +58,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); ...@@ -60,11 +58,7 @@ local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
#endif #endif
/* ========================================================================= */ /* ========================================================================= */
uLong ZEXPORT adler32_z(adler, buf, len) uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
uLong adler;
const Bytef *buf;
z_size_t len;
{
unsigned long sum2; unsigned long sum2;
unsigned n; unsigned n;
...@@ -131,20 +125,12 @@ uLong ZEXPORT adler32_z(adler, buf, len) ...@@ -131,20 +125,12 @@ uLong ZEXPORT adler32_z(adler, buf, len)
} }
/* ========================================================================= */ /* ========================================================================= */
uLong ZEXPORT adler32(adler, buf, len) uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
uLong adler;
const Bytef *buf;
uInt len;
{
return adler32_z(adler, buf, len); return adler32_z(adler, buf, len);
} }
/* ========================================================================= */ /* ========================================================================= */
local uLong adler32_combine_(adler1, adler2, len2) local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
uLong adler1;
uLong adler2;
z_off64_t len2;
{
unsigned long sum1; unsigned long sum1;
unsigned long sum2; unsigned long sum2;
unsigned rem; unsigned rem;
...@@ -169,18 +155,10 @@ local uLong adler32_combine_(adler1, adler2, len2) ...@@ -169,18 +155,10 @@ local uLong adler32_combine_(adler1, adler2, len2)
} }
/* ========================================================================= */ /* ========================================================================= */
uLong ZEXPORT adler32_combine(adler1, adler2, len2) uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) {
uLong adler1;
uLong adler2;
z_off_t len2;
{
return adler32_combine_(adler1, adler2, len2); return adler32_combine_(adler1, adler2, len2);
} }
uLong ZEXPORT adler32_combine64(adler1, adler2, len2) uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) {
uLong adler1;
uLong adler2;
z_off64_t len2;
{
return adler32_combine_(adler1, adler2, len2); return adler32_combine_(adler1, adler2, len2);
} }
...@@ -19,13 +19,8 @@ ...@@ -19,13 +19,8 @@
memory, Z_BUF_ERROR if there was not enough room in the output buffer, memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid. Z_STREAM_ERROR if the level parameter is invalid.
*/ */
int ZEXPORT compress2(dest, destLen, source, sourceLen, level) int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
Bytef *dest; uLong sourceLen, int level) {
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
int level;
{
z_stream stream; z_stream stream;
int err; int err;
const uInt max = (uInt)-1; const uInt max = (uInt)-1;
...@@ -65,12 +60,8 @@ int ZEXPORT compress2(dest, destLen, source, sourceLen, level) ...@@ -65,12 +60,8 @@ int ZEXPORT compress2(dest, destLen, source, sourceLen, level)
/* =========================================================================== /* ===========================================================================
*/ */
int ZEXPORT compress(dest, destLen, source, sourceLen) int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
Bytef *dest; uLong sourceLen) {
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
{
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
} }
...@@ -78,9 +69,7 @@ int ZEXPORT compress(dest, destLen, source, sourceLen) ...@@ -78,9 +69,7 @@ int ZEXPORT compress(dest, destLen, source, sourceLen)
If the default memLevel or windowBits for deflateInit() is changed, then If the default memLevel or windowBits for deflateInit() is changed, then
this function needs to be updated. this function needs to be updated.
*/ */
uLong ZEXPORT compressBound(sourceLen) uLong ZEXPORT compressBound(uLong sourceLen) {
uLong sourceLen;
{
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
(sourceLen >> 25) + 13; (sourceLen >> 25) + 13;
} }
...@@ -44,8 +44,6 @@ STATICLIB=libz.a ...@@ -44,8 +44,6 @@ STATICLIB=libz.a
# extract zlib version numbers from zlib.h # extract zlib version numbers from zlib.h
VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h` VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h`
VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h`
VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h` VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
# establish commands for library building # establish commands for library building
...@@ -90,7 +88,8 @@ build64=0 ...@@ -90,7 +88,8 @@ build64=0
gcc=0 gcc=0
warn=0 warn=0
debug=0 debug=0
sanitize=0 address=0
memory=0
old_cc="$CC" old_cc="$CC"
old_cflags="$CFLAGS" old_cflags="$CFLAGS"
OBJC='$(OBJZ) $(OBJG)' OBJC='$(OBJZ) $(OBJG)'
...@@ -102,7 +101,7 @@ leave() ...@@ -102,7 +101,7 @@ leave()
if test "$*" != "0"; then if test "$*" != "0"; then
echo "** $0 aborting." | tee -a configure.log echo "** $0 aborting." | tee -a configure.log
fi fi
rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version rm -rf $test.[co] $test $test$shared_ext $test.gcno $test.dSYM ./--version
echo -------------------- >> configure.log echo -------------------- >> configure.log
echo >> configure.log echo >> configure.log
echo >> configure.log echo >> configure.log
...@@ -141,7 +140,9 @@ case "$1" in ...@@ -141,7 +140,9 @@ case "$1" in
-c* | --const) zconst=1; shift ;; -c* | --const) zconst=1; shift ;;
-w* | --warn) warn=1; shift ;; -w* | --warn) warn=1; shift ;;
-d* | --debug) debug=1; shift ;; -d* | --debug) debug=1; shift ;;
--sanitize) sanitize=1; shift ;; --sanitize) address=1; shift ;;
--address) address=1; shift ;;
--memory) memory=1; shift ;;
*) *)
echo "unknown option: $1" | tee -a configure.log echo "unknown option: $1" | tee -a configure.log
echo "$0 --help for help" | tee -a configure.log echo "$0 --help for help" | tee -a configure.log
...@@ -211,8 +212,11 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then ...@@ -211,8 +212,11 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
CFLAGS="${CFLAGS} -Wall -Wextra" CFLAGS="${CFLAGS} -Wall -Wextra"
fi fi
fi fi
if test $sanitize -eq 1; then if test $address -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=address" CFLAGS="${CFLAGS} -g -fsanitize=address -fno-omit-frame-pointer"
fi
if test $memory -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=memory -fno-omit-frame-pointer"
fi fi
if test $debug -eq 1; then if test $debug -eq 1; then
CFLAGS="${CFLAGS} -DZLIB_DEBUG" CFLAGS="${CFLAGS} -DZLIB_DEBUG"
...@@ -259,8 +263,10 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then ...@@ -259,8 +263,10 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
SHAREDLIB=libz$shared_ext SHAREDLIB=libz$shared_ext
SHAREDLIBV=libz.$VER$shared_ext SHAREDLIBV=libz.$VER$shared_ext
SHAREDLIBM=libz.$VER1$shared_ext SHAREDLIBM=libz.$VER1$shared_ext
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER"}
if libtool -V 2>&1 | grep Apple > /dev/null; then if "${CROSS_PREFIX}libtool" -V 2>&1 | grep Apple > /dev/null; then
AR="${CROSS_PREFIX}libtool"
elif libtool -V 2>&1 | grep Apple > /dev/null; then
AR="libtool" AR="libtool"
else else
AR="/usr/bin/libtool" AR="/usr/bin/libtool"
...@@ -860,7 +866,7 @@ echo prefix = $prefix >> configure.log ...@@ -860,7 +866,7 @@ echo prefix = $prefix >> configure.log
echo sharedlibdir = $sharedlibdir >> configure.log echo sharedlibdir = $sharedlibdir >> configure.log
echo uname = $uname >> configure.log echo uname = $uname >> configure.log
# udpate Makefile with the configure results # update Makefile with the configure results
sed < ${SRCDIR}Makefile.in " sed < ${SRCDIR}Makefile.in "
/^CC *=/s#=.*#=$CC# /^CC *=/s#=.*#=$CC#
/^CFLAGS *=/s#=.*#=$CFLAGS# /^CFLAGS *=/s#=.*#=$CFLAGS#
......
...@@ -8,8 +8,8 @@ It provides Ada-style access to the ZLib C library. ...@@ -8,8 +8,8 @@ It provides Ada-style access to the ZLib C library.
Here are the main changes since ZLib.Ada 1.2: Here are the main changes since ZLib.Ada 1.2:
- Attension: ZLib.Read generic routine have a initialization requirement - Attention: ZLib.Read generic routine have a initialization requirement
for Read_Last parameter now. It is a bit incompartible with previous version, for Read_Last parameter now. It is a bit incompatible with previous version,
but extends functionality, we could use new parameters Allow_Read_Some and but extends functionality, we could use new parameters Allow_Read_Some and
Flush now. Flush now.
......
...@@ -65,12 +65,12 @@ procedure Test is ...@@ -65,12 +65,12 @@ procedure Test is
Time_Stamp : Ada.Calendar.Time; Time_Stamp : Ada.Calendar.Time;
procedure Generate_File; procedure Generate_File;
-- Generate file of spetsified size with some random data. -- Generate file of specified size with some random data.
-- The random data is repeatable, for the good compression. -- The random data is repeatable, for the good compression.
procedure Compare_Streams procedure Compare_Streams
(Left, Right : in out Root_Stream_Type'Class); (Left, Right : in out Root_Stream_Type'Class);
-- The procedure compearing data in 2 streams. -- The procedure comparing data in 2 streams.
-- It is for compare data before and after compression/decompression. -- It is for compare data before and after compression/decompression.
procedure Compare_Files (Left, Right : String); procedure Compare_Files (Left, Right : String);
......
...@@ -62,7 +62,7 @@ package ZLib.Streams is ...@@ -62,7 +62,7 @@ package ZLib.Streams is
:= Default_Buffer_Size; := Default_Buffer_Size;
Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size); := Default_Buffer_Size);
-- Create the Comression/Decompression stream. -- Create the Compression/Decompression stream.
-- If mode is In_Stream then Write operation is disabled. -- If mode is In_Stream then Write operation is disabled.
-- If mode is Out_Stream then Read operation is disabled. -- If mode is Out_Stream then Read operation is disabled.
......
...@@ -204,7 +204,7 @@ package body ZLib is ...@@ -204,7 +204,7 @@ package body ZLib is
end if; end if;
-- We allow ZLib to make header only in case of default header type. -- We allow ZLib to make header only in case of default header type.
-- Otherwise we would either do header by ourselfs, or do not do -- Otherwise we would either do header by ourselves, or do not do
-- header at all. -- header at all.
if Header = None or else Header = GZip then if Header = None or else Header = GZip then
......
...@@ -114,7 +114,7 @@ package ZLib is ...@@ -114,7 +114,7 @@ package ZLib is
-- Compression strategy constants -- -- Compression strategy constants --
------------------------------------ ------------------------------------
-- RLE stategy could be used only in version 1.2.0 and later. -- RLE strategy could be used only in version 1.2.0 and later.
Filtered : constant Strategy_Type; Filtered : constant Strategy_Type;
Huffman_Only : constant Strategy_Type; Huffman_Only : constant Strategy_Type;
......
...@@ -152,7 +152,7 @@ procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer; ...@@ -152,7 +152,7 @@ procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
const OutBuf: Pointer; BufSize: Integer); const OutBuf: Pointer; BufSize: Integer);
const const
zlib_version = '1.2.13'; zlib_version = '1.3.0';
type type
EZlibError = class(Exception); EZlibError = class(Exception);
......
...@@ -61,7 +61,7 @@ namespace DotZLib ...@@ -61,7 +61,7 @@ namespace DotZLib
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception> /// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception> /// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception> /// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
/// <remarks>All the other <c>Update</c> methods are implmeneted in terms of this one. /// <remarks>All the other <c>Update</c> methods are implemented in terms of this one.
/// This is therefore the only method a derived class has to implement</remarks> /// This is therefore the only method a derived class has to implement</remarks>
public abstract void Update(byte[] data, int offset, int count); public abstract void Update(byte[] data, int offset, int count);
......
...@@ -139,7 +139,7 @@ namespace DotZLib ...@@ -139,7 +139,7 @@ namespace DotZLib
/// <remarks>This must be implemented by a derived class</remarks> /// <remarks>This must be implemented by a derived class</remarks>
protected abstract void CleanUp(); protected abstract void CleanUp();
// performs the release of the handles and calls the dereived CleanUp() // performs the release of the handles and calls the derived CleanUp()
private void CleanUp(bool isDisposing) private void CleanUp(bool isDisposing)
{ {
if (!_isDisposed) if (!_isDisposed)
...@@ -160,7 +160,7 @@ namespace DotZLib ...@@ -160,7 +160,7 @@ namespace DotZLib
#region Helper methods #region Helper methods
/// <summary> /// <summary>
/// Copies a number of bytes to the internal codec buffer - ready for proccesing /// Copies a number of bytes to the internal codec buffer - ready for processing
/// </summary> /// </summary>
/// <param name="data">The byte array that contains the data to copy</param> /// <param name="data">The byte array that contains the data to copy</param>
/// <param name="startIndex">The index of the first byte to copy</param> /// <param name="startIndex">The index of the first byte to copy</param>
......
...@@ -246,7 +246,7 @@ namespace DotZLib ...@@ -246,7 +246,7 @@ namespace DotZLib
} }
/// <summary> /// <summary>
/// Not suppported. /// Not supported.
/// </summary> /// </summary>
/// <param name="offset"></param> /// <param name="offset"></param>
/// <param name="origin"></param> /// <param name="origin"></param>
...@@ -268,7 +268,7 @@ namespace DotZLib ...@@ -268,7 +268,7 @@ namespace DotZLib
} }
/// <summary> /// <summary>
/// Gets/sets the current position in the <c>GZipStream</c>. Not suppported. /// Gets/sets the current position in the <c>GZipStream</c>. Not supported.
/// </summary> /// </summary>
/// <remarks>In this implementation this property is not supported</remarks> /// <remarks>In this implementation this property is not supported</remarks>
/// <exception cref="NotSupportedException">Always thrown</exception> /// <exception cref="NotSupportedException">Always thrown</exception>
...@@ -285,7 +285,7 @@ namespace DotZLib ...@@ -285,7 +285,7 @@ namespace DotZLib
} }
/// <summary> /// <summary>
/// Gets the size of the stream. Not suppported. /// Gets the size of the stream. Not supported.
/// </summary> /// </summary>
/// <remarks>In this implementation this property is not supported</remarks> /// <remarks>In this implementation this property is not supported</remarks>
/// <exception cref="NotSupportedException">Always thrown</exception> /// <exception cref="NotSupportedException">Always thrown</exception>
......
...@@ -156,7 +156,7 @@ namespace DotZLibTests ...@@ -156,7 +156,7 @@ namespace DotZLibTests
public void Info_Version() public void Info_Version()
{ {
Info info = new Info(); Info info = new Info();
Assert.AreEqual("1.2.13", Info.Version); Assert.AreEqual("1.3.0", Info.Version);
Assert.AreEqual(32, info.SizeOfUInt); Assert.AreEqual(32, info.SizeOfUInt);
Assert.AreEqual(32, info.SizeOfULong); Assert.AreEqual(32, info.SizeOfULong);
Assert.AreEqual(32, info.SizeOfPointer); Assert.AreEqual(32, info.SizeOfPointer);
......
...@@ -36,7 +36,7 @@ Build instructions: ...@@ -36,7 +36,7 @@ Build instructions:
in the same directory as the DotZLib.build file. in the same directory as the DotZLib.build file.
You can define 2 properties on the nant command-line to control the build: You can define 2 properties on the nant command-line to control the build:
debug={true|false} to toggle between release/debug builds (default=true). debug={true|false} to toggle between release/debug builds (default=true).
nunit={true|false} to include or esclude unit tests (default=true). nunit={true|false} to include or exclude unit tests (default=true).
Also the target clean will remove binaries. Also the target clean will remove binaries.
Output file (DotZLib.dll) will be found in either ./DotZLib/bin/release Output file (DotZLib.dll) will be found in either ./DotZLib/bin/release
or ./DotZLib/bin/debug, depending on whether you are building the release or ./DotZLib/bin/debug, depending on whether you are building the release
......
...@@ -16,12 +16,8 @@ ...@@ -16,12 +16,8 @@
window is a user-supplied window and output buffer that is 64K bytes. window is a user-supplied window and output buffer that is 64K bytes.
*/ */
int ZEXPORT inflateBack9Init_(strm, window, version, stream_size) int ZEXPORT inflateBack9Init_(z_stream FAR *strm, unsigned char FAR *window,
z_stream FAR *strm; const char *version, int stream_size) {
unsigned char FAR *window;
const char *version;
int stream_size;
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
...@@ -51,8 +47,7 @@ int stream_size; ...@@ -51,8 +47,7 @@ int stream_size;
#ifdef MAKEFIXED #ifdef MAKEFIXED
#include <stdio.h> #include <stdio.h>
void makefixed9(void) void makefixed9(void) {
{
unsigned sym, bits, low, size; unsigned sym, bits, low, size;
code *next, *lenfix, *distfix; code *next, *lenfix, *distfix;
struct inflate_state state; struct inflate_state state;
...@@ -214,13 +209,8 @@ void makefixed9(void) ...@@ -214,13 +209,8 @@ void makefixed9(void)
inflateBack() can also return Z_STREAM_ERROR if the input parameters inflateBack() can also return Z_STREAM_ERROR if the input parameters
are not correct, i.e. strm is Z_NULL or the state was not initialized. are not correct, i.e. strm is Z_NULL or the state was not initialized.
*/ */
int ZEXPORT inflateBack9(strm, in, in_desc, out, out_desc) int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc,
z_stream FAR *strm; out_func out, void FAR *out_desc) {
in_func in;
void FAR *in_desc;
out_func out;
void FAR *out_desc;
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
z_const unsigned char FAR *next; /* next input */ z_const unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next output */ unsigned char FAR *put; /* next output */
...@@ -603,9 +593,7 @@ void FAR *out_desc; ...@@ -603,9 +593,7 @@ void FAR *out_desc;
return ret; return ret;
} }
int ZEXPORT inflateBack9End(strm) int ZEXPORT inflateBack9End(z_stream FAR *strm) {
z_stream FAR *strm;
{
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
ZFREE(strm, strm->state); ZFREE(strm, strm->state);
......
...@@ -20,14 +20,14 @@ ...@@ -20,14 +20,14 @@
extern "C" { extern "C" {
#endif #endif
ZEXTERN int ZEXPORT inflateBack9 OF((z_stream FAR *strm, ZEXTERN int ZEXPORT inflateBack9(z_stream FAR *strm,
in_func in, void FAR *in_desc, in_func in, void FAR *in_desc,
out_func out, void FAR *out_desc)); out_func out, void FAR *out_desc);
ZEXTERN int ZEXPORT inflateBack9End OF((z_stream FAR *strm)); ZEXTERN int ZEXPORT inflateBack9End(z_stream FAR *strm);
ZEXTERN int ZEXPORT inflateBack9Init_ OF((z_stream FAR *strm, ZEXTERN int ZEXPORT inflateBack9Init_(z_stream FAR *strm,
unsigned char FAR *window, unsigned char FAR *window,
const char *version, const char *version,
int stream_size)); int stream_size);
#define inflateBack9Init(strm, window) \ #define inflateBack9Init(strm, window) \
inflateBack9Init_((strm), (window), \ inflateBack9Init_((strm), (window), \
ZLIB_VERSION, sizeof(z_stream)) ZLIB_VERSION, sizeof(z_stream))
......
/* inftree9.c -- generate Huffman trees for efficient decoding /* inftree9.c -- generate Huffman trees for efficient decoding
* Copyright (C) 1995-2022 Mark Adler * Copyright (C) 1995-2023 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#define MAXBITS 15 #define MAXBITS 15
const char inflate9_copyright[] = const char inflate9_copyright[] =
" inflate9 1.2.13 Copyright 1995-2022 Mark Adler "; " inflate9 1.3 Copyright 1995-2023 Mark Adler ";
/* /*
If you use the zlib library in a product, an acknowledgment is welcome If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot in the documentation of your product. If for some reason you cannot
...@@ -29,14 +29,9 @@ const char inflate9_copyright[] = ...@@ -29,14 +29,9 @@ const char inflate9_copyright[] =
table index bits. It will differ if the request is greater than the table index bits. It will differ if the request is greater than the
longest code or if it is less than the shortest code. longest code or if it is less than the shortest code.
*/ */
int inflate_table9(type, lens, codes, table, bits, work) int inflate_table9(codetype type, unsigned short FAR *lens, unsigned codes,
codetype type; code FAR * FAR *table, unsigned FAR *bits,
unsigned short FAR *lens; unsigned short FAR *work) {
unsigned codes;
code FAR * FAR *table;
unsigned FAR *bits;
unsigned short FAR *work;
{
unsigned len; /* a code's length in bits */ unsigned len; /* a code's length in bits */
unsigned sym; /* index of code symbols */ unsigned sym; /* index of code symbols */
unsigned min, max; /* minimum and maximum code lengths */ unsigned min, max; /* minimum and maximum code lengths */
...@@ -64,7 +59,7 @@ unsigned short FAR *work; ...@@ -64,7 +59,7 @@ unsigned short FAR *work;
static const unsigned short lext[31] = { /* Length codes 257..285 extra */ static const unsigned short lext[31] = { /* Length codes 257..285 extra */
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
133, 133, 133, 133, 144, 194, 65}; 133, 133, 133, 133, 144, 198, 203};
static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
......
...@@ -56,6 +56,6 @@ typedef enum { ...@@ -56,6 +56,6 @@ typedef enum {
DISTS DISTS
} codetype; } codetype;
extern int inflate_table9 OF((codetype type, unsigned short FAR *lens, extern int inflate_table9(codetype type, unsigned short FAR *lens,
unsigned codes, code FAR * FAR *table, unsigned codes, code FAR * FAR *table,
unsigned FAR *bits, unsigned short FAR *work)); unsigned FAR *bits, unsigned short FAR *work);
MiniZip 1.1 was derrived from MiniZip at version 1.01f MiniZip 1.1 was derived from MiniZip at version 1.01f
Change in 1.0 (Okt 2009) Change in 1.0 (Okt 2009)
- **TODO - Add history** - **TODO - Add history**
......
# -*- Autoconf -*- # -*- Autoconf -*-
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_INIT([minizip], [1.2.13], [bugzilla.redhat.com]) AC_INIT([minizip], [1.3.0], [bugzilla.redhat.com])
AC_CONFIG_SRCDIR([minizip.c]) AC_CONFIG_SRCDIR([minizip.c])
AM_INIT_AUTOMAKE([foreign]) AM_INIT_AUTOMAKE([foreign])
LT_INIT LT_INIT
......
...@@ -32,8 +32,7 @@ ...@@ -32,8 +32,7 @@
/*********************************************************************** /***********************************************************************
* Return the next byte in the pseudo-random sequence * Return the next byte in the pseudo-random sequence
*/ */
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
{
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem * unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */ * with any known compiler so far, though */
...@@ -46,8 +45,7 @@ static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) ...@@ -46,8 +45,7 @@ static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
/*********************************************************************** /***********************************************************************
* Update the encryption keys with the next byte of plain text * Update the encryption keys with the next byte of plain text
*/ */
static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c) static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab, int c) {
{
(*(pkeys+0)) = CRC32((*(pkeys+0)), c); (*(pkeys+0)) = CRC32((*(pkeys+0)), c);
(*(pkeys+1)) += (*(pkeys+0)) & 0xff; (*(pkeys+1)) += (*(pkeys+0)) & 0xff;
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
...@@ -63,8 +61,7 @@ static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c) ...@@ -63,8 +61,7 @@ static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
* Initialize the encryption keys and the random header according to * Initialize the encryption keys and the random header according to
* the given password. * the given password.
*/ */
static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab) static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab) {
{
*(pkeys+0) = 305419896L; *(pkeys+0) = 305419896L;
*(pkeys+1) = 591751049L; *(pkeys+1) = 591751049L;
*(pkeys+2) = 878082192L; *(pkeys+2) = 878082192L;
...@@ -93,8 +90,7 @@ static unsigned crypthead(const char* passwd, /* password string */ ...@@ -93,8 +90,7 @@ static unsigned crypthead(const char* passwd, /* password string */
int bufSize, int bufSize,
unsigned long* pkeys, unsigned long* pkeys,
const z_crc_t* pcrc_32_tab, const z_crc_t* pcrc_32_tab,
unsigned long crcForCrypting) unsigned long crcForCrypting) {
{
unsigned n; /* index in random header */ unsigned n; /* index in random header */
int t; /* temporary */ int t; /* temporary */
int c; /* random byte */ int c; /* random byte */
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#endif #endif
#if defined(__APPLE__) || defined(IOAPI_NO_64) #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 FOPEN_FUNC(filename, mode) fopen(filename, mode)
#define FTELLO_FUNC(stream) ftello(stream) #define FTELLO_FUNC(stream) ftello(stream)
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
#include "ioapi.h" #include "ioapi.h"
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc, const void*filename, int mode) {
{
if (pfilefunc->zfile_func64.zopen64_file != NULL) if (pfilefunc->zfile_func64.zopen64_file != NULL)
return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode); return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode);
else else
...@@ -38,8 +37,7 @@ voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename ...@@ -38,8 +37,7 @@ voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename
} }
} }
long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) {
{
if (pfilefunc->zfile_func64.zseek64_file != NULL) if (pfilefunc->zfile_func64.zseek64_file != NULL)
return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin); return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin);
else else
...@@ -52,8 +50,7 @@ long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZP ...@@ -52,8 +50,7 @@ long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZP
} }
} }
ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream) ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc, voidpf filestream) {
{
if (pfilefunc->zfile_func64.zseek64_file != NULL) if (pfilefunc->zfile_func64.zseek64_file != NULL)
return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream); return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream);
else else
...@@ -66,11 +63,9 @@ ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream ...@@ -66,11 +63,9 @@ ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream
} }
} }
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32) void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32, const zlib_filefunc_def* p_filefunc32) {
{
p_filefunc64_32->zfile_func64.zopen64_file = NULL; p_filefunc64_32->zfile_func64.zopen64_file = NULL;
p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file; p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file;
p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file;
p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file; p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file;
p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file; p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file;
p_filefunc64_32->zfile_func64.ztell64_file = NULL; p_filefunc64_32->zfile_func64.ztell64_file = NULL;
...@@ -84,16 +79,7 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef ...@@ -84,16 +79,7 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef
static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode)); static voidpf ZCALLBACK fopen_file_func(voidpf opaque, const char* filename, int mode) {
static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size));
static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream));
static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream));
static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream));
static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode)
{
FILE* file = NULL; FILE* file = NULL;
const char* mode_fopen = NULL; const char* mode_fopen = NULL;
(void)opaque; (void)opaque;
...@@ -111,8 +97,7 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in ...@@ -111,8 +97,7 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in
return file; return file;
} }
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) static voidpf ZCALLBACK fopen64_file_func(voidpf opaque, const void* filename, int mode) {
{
FILE* file = NULL; FILE* file = NULL;
const char* mode_fopen = NULL; const char* mode_fopen = NULL;
(void)opaque; (void)opaque;
...@@ -131,24 +116,21 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, ...@@ -131,24 +116,21 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
} }
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) static uLong ZCALLBACK fread_file_func(voidpf opaque, voidpf stream, void* buf, uLong size) {
{
uLong ret; uLong ret;
(void)opaque; (void)opaque;
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
return ret; return ret;
} }
static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) static uLong ZCALLBACK fwrite_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
{
uLong ret; uLong ret;
(void)opaque; (void)opaque;
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
return ret; return ret;
} }
static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) static long ZCALLBACK ftell_file_func(voidpf opaque, voidpf stream) {
{
long ret; long ret;
(void)opaque; (void)opaque;
ret = ftell((FILE *)stream); ret = ftell((FILE *)stream);
...@@ -156,16 +138,14 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) ...@@ -156,16 +138,14 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
} }
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) static ZPOS64_T ZCALLBACK ftell64_file_func(voidpf opaque, voidpf stream) {
{
ZPOS64_T ret; ZPOS64_T ret;
(void)opaque; (void)opaque;
ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream); ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream);
return ret; return ret;
} }
static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) static long ZCALLBACK fseek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
{
int fseek_origin=0; int fseek_origin=0;
long ret; long ret;
(void)opaque; (void)opaque;
...@@ -188,8 +168,7 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs ...@@ -188,8 +168,7 @@ static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offs
return ret; return ret;
} }
static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) static long ZCALLBACK fseek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
{
int fseek_origin=0; int fseek_origin=0;
long ret; long ret;
(void)opaque; (void)opaque;
...@@ -208,32 +187,28 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T ...@@ -208,32 +187,28 @@ static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T
} }
ret = 0; ret = 0;
if(FSEEKO_FUNC((FILE *)stream, (z_off_t)offset, fseek_origin) != 0) if(FSEEKO_FUNC((FILE *)stream, (z_off64_t)offset, fseek_origin) != 0)
ret = -1; ret = -1;
return ret; return ret;
} }
static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) static int ZCALLBACK fclose_file_func(voidpf opaque, voidpf stream) {
{
int ret; int ret;
(void)opaque; (void)opaque;
ret = fclose((FILE *)stream); ret = fclose((FILE *)stream);
return ret; return ret;
} }
static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) static int ZCALLBACK ferror_file_func(voidpf opaque, voidpf stream) {
{
int ret; int ret;
(void)opaque; (void)opaque;
ret = ferror((FILE *)stream); ret = ferror((FILE *)stream);
return ret; return ret;
} }
void fill_fopen_filefunc (pzlib_filefunc_def) void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def) {
zlib_filefunc_def* pzlib_filefunc_def;
{
pzlib_filefunc_def->zopen_file = fopen_file_func; pzlib_filefunc_def->zopen_file = fopen_file_func;
pzlib_filefunc_def->zread_file = fread_file_func; pzlib_filefunc_def->zread_file = fread_file_func;
pzlib_filefunc_def->zwrite_file = fwrite_file_func; pzlib_filefunc_def->zwrite_file = fwrite_file_func;
...@@ -244,8 +219,7 @@ void fill_fopen_filefunc (pzlib_filefunc_def) ...@@ -244,8 +219,7 @@ void fill_fopen_filefunc (pzlib_filefunc_def)
pzlib_filefunc_def->opaque = NULL; pzlib_filefunc_def->opaque = NULL;
} }
void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def) void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def) {
{
pzlib_filefunc_def->zopen64_file = fopen64_file_func; pzlib_filefunc_def->zopen64_file = fopen64_file_func;
pzlib_filefunc_def->zread_file = fread_file_func; pzlib_filefunc_def->zread_file = fread_file_func;
pzlib_filefunc_def->zwrite_file = fwrite_file_func; pzlib_filefunc_def->zwrite_file = fwrite_file_func;
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
#define ftello64 ftell #define ftello64 ftell
#define fseeko64 fseek #define fseeko64 fseek
#else #else
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
#define fopen64 fopen #define fopen64 fopen
#define ftello64 ftello #define ftello64 ftello
#define fseeko64 fseeko #define fseeko64 fseeko
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
#include "mz64conf.h" #include "mz64conf.h"
#endif #endif
/* a type choosen by DEFINE */ /* a type chosen by DEFINE */
#ifdef HAVE_64BIT_INT_CUSTOM #ifdef HAVE_64BIT_INT_CUSTOM
typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T;
#else #else
...@@ -134,14 +134,14 @@ extern "C" { ...@@ -134,14 +134,14 @@ extern "C" {
typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode);
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size);
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size);
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream);
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream);
typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream);
typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin);
/* here is the "old" 32 bits structure structure */ /* here is the "old" 32 bits structure structure */
...@@ -157,9 +157,9 @@ typedef struct zlib_filefunc_def_s ...@@ -157,9 +157,9 @@ typedef struct zlib_filefunc_def_s
voidpf opaque; voidpf opaque;
} zlib_filefunc_def; } zlib_filefunc_def;
typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); typedef ZPOS64_T (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream);
typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin);
typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void* filename, int mode);
typedef struct zlib_filefunc64_def_s typedef struct zlib_filefunc64_def_s
{ {
...@@ -173,8 +173,8 @@ typedef struct zlib_filefunc64_def_s ...@@ -173,8 +173,8 @@ typedef struct zlib_filefunc64_def_s
voidpf opaque; voidpf opaque;
} zlib_filefunc64_def; } zlib_filefunc64_def;
void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def);
void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def);
/* now internal definition, only for zip.c and unzip.h */ /* now internal definition, only for zip.c and unzip.h */
typedef struct zlib_filefunc64_32_def_s typedef struct zlib_filefunc64_32_def_s
...@@ -193,11 +193,11 @@ typedef struct zlib_filefunc64_32_def_s ...@@ -193,11 +193,11 @@ typedef struct zlib_filefunc64_32_def_s
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) #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)) #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); voidpf call_zopen64(const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode);
long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); long call_zseek64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin);
ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); ZPOS64_T call_ztell64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream);
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode)))
#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream)))
......
...@@ -38,14 +38,6 @@ ...@@ -38,14 +38,6 @@
#endif #endif
#endif #endif
voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode));
uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size));
uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
ZPOS64_T ZCALLBACK win32_tell64_file_func OF((voidpf opaque, voidpf stream));
long ZCALLBACK win32_seek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
int ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream));
int ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream));
typedef struct typedef struct
{ {
HANDLE hf; HANDLE hf;
...@@ -57,8 +49,7 @@ static void win32_translate_open_mode(int mode, ...@@ -57,8 +49,7 @@ static void win32_translate_open_mode(int mode,
DWORD* lpdwDesiredAccess, DWORD* lpdwDesiredAccess,
DWORD* lpdwCreationDisposition, DWORD* lpdwCreationDisposition,
DWORD* lpdwShareMode, DWORD* lpdwShareMode,
DWORD* lpdwFlagsAndAttributes) DWORD* lpdwFlagsAndAttributes) {
{
*lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0; *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0;
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
...@@ -79,8 +70,7 @@ static void win32_translate_open_mode(int mode, ...@@ -79,8 +70,7 @@ static void win32_translate_open_mode(int mode,
} }
} }
static voidpf win32_build_iowin(HANDLE hFile) static voidpf win32_build_iowin(HANDLE hFile) {
{
voidpf ret=NULL; voidpf ret=NULL;
if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE)) if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE))
...@@ -98,8 +88,7 @@ static voidpf win32_build_iowin(HANDLE hFile) ...@@ -98,8 +88,7 @@ static voidpf win32_build_iowin(HANDLE hFile)
return ret; return ret;
} }
voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode) voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int mode) {
{
const char* mode_fopen = NULL; const char* mode_fopen = NULL;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL; HANDLE hFile = NULL;
...@@ -127,8 +116,7 @@ voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int ...@@ -127,8 +116,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) voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, int mode) {
{
const char* mode_fopen = NULL; const char* mode_fopen = NULL;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL; HANDLE hFile = NULL;
...@@ -151,8 +139,7 @@ voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int ...@@ -151,8 +139,7 @@ voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int
} }
voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode) voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, int mode) {
{
const char* mode_fopen = NULL; const char* mode_fopen = NULL;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL; HANDLE hFile = NULL;
...@@ -171,8 +158,7 @@ voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int ...@@ -171,8 +158,7 @@ voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int
} }
voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode) voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int mode) {
{
const char* mode_fopen = NULL; const char* mode_fopen = NULL;
DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ;
HANDLE hFile = NULL; HANDLE hFile = NULL;
...@@ -200,8 +186,7 @@ voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mo ...@@ -200,8 +186,7 @@ voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mo
} }
uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size) uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLong size) {
{
uLong ret=0; uLong ret=0;
HANDLE hFile = NULL; HANDLE hFile = NULL;
if (stream!=NULL) if (stream!=NULL)
...@@ -222,8 +207,7 @@ uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uL ...@@ -222,8 +207,7 @@ uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uL
} }
uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size) uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) {
{
uLong ret=0; uLong ret=0;
HANDLE hFile = NULL; HANDLE hFile = NULL;
if (stream!=NULL) if (stream!=NULL)
...@@ -243,8 +227,7 @@ uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* b ...@@ -243,8 +227,7 @@ uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* b
return ret; return ret;
} }
static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) {
{
#ifdef IOWIN32_USING_WINRT_API #ifdef IOWIN32_USING_WINRT_API
return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod); return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod);
#else #else
...@@ -263,8 +246,7 @@ static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *n ...@@ -263,8 +246,7 @@ static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *n
#endif #endif
} }
long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream) long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) {
{
long ret=-1; long ret=-1;
HANDLE hFile = NULL; HANDLE hFile = NULL;
if (stream!=NULL) if (stream!=NULL)
...@@ -286,8 +268,7 @@ long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream) ...@@ -286,8 +268,7 @@ long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream)
return ret; return ret;
} }
ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream) ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) {
{
ZPOS64_T ret= (ZPOS64_T)-1; ZPOS64_T ret= (ZPOS64_T)-1;
HANDLE hFile = NULL; HANDLE hFile = NULL;
if (stream!=NULL) if (stream!=NULL)
...@@ -311,8 +292,7 @@ ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream) ...@@ -311,8 +292,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) long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) {
{
DWORD dwMoveMethod=0xFFFFFFFF; DWORD dwMoveMethod=0xFFFFFFFF;
HANDLE hFile = NULL; HANDLE hFile = NULL;
...@@ -349,8 +329,7 @@ long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,in ...@@ -349,8 +329,7 @@ long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,in
return ret; return ret;
} }
long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin) long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) {
{
DWORD dwMoveMethod=0xFFFFFFFF; DWORD dwMoveMethod=0xFFFFFFFF;
HANDLE hFile = NULL; HANDLE hFile = NULL;
long ret=-1; long ret=-1;
...@@ -388,8 +367,7 @@ long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T off ...@@ -388,8 +367,7 @@ long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T off
return ret; return ret;
} }
int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream) int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) {
{
int ret=-1; int ret=-1;
if (stream!=NULL) if (stream!=NULL)
...@@ -406,8 +384,7 @@ int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream) ...@@ -406,8 +384,7 @@ int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream)
return ret; return ret;
} }
int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream) int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) {
{
int ret=-1; int ret=-1;
if (stream!=NULL) if (stream!=NULL)
{ {
...@@ -416,8 +393,7 @@ int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream) ...@@ -416,8 +393,7 @@ int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream)
return ret; return ret;
} }
void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def) void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def) {
{
pzlib_filefunc_def->zopen_file = win32_open_file_func; pzlib_filefunc_def->zopen_file = win32_open_file_func;
pzlib_filefunc_def->zread_file = win32_read_file_func; pzlib_filefunc_def->zread_file = win32_read_file_func;
pzlib_filefunc_def->zwrite_file = win32_write_file_func; pzlib_filefunc_def->zwrite_file = win32_write_file_func;
...@@ -428,8 +404,7 @@ void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def) ...@@ -428,8 +404,7 @@ void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def)
pzlib_filefunc_def->opaque = NULL; pzlib_filefunc_def->opaque = NULL;
} }
void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) {
{
pzlib_filefunc_def->zopen64_file = win32_open64_file_func; pzlib_filefunc_def->zopen64_file = win32_open64_file_func;
pzlib_filefunc_def->zread_file = win32_read_file_func; pzlib_filefunc_def->zread_file = win32_read_file_func;
pzlib_filefunc_def->zwrite_file = win32_write_file_func; pzlib_filefunc_def->zwrite_file = win32_write_file_func;
...@@ -441,8 +416,7 @@ void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) ...@@ -441,8 +416,7 @@ void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def)
} }
void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) {
{
pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA; pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA;
pzlib_filefunc_def->zread_file = win32_read_file_func; pzlib_filefunc_def->zread_file = win32_read_file_func;
pzlib_filefunc_def->zwrite_file = win32_write_file_func; pzlib_filefunc_def->zwrite_file = win32_write_file_func;
...@@ -454,8 +428,7 @@ void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) ...@@ -454,8 +428,7 @@ void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def)
} }
void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) {
{
pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW; pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW;
pzlib_filefunc_def->zread_file = win32_read_file_func; pzlib_filefunc_def->zread_file = win32_read_file_func;
pzlib_filefunc_def->zwrite_file = win32_write_file_func; pzlib_filefunc_def->zwrite_file = win32_write_file_func;
......
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
extern "C" { extern "C" {
#endif #endif
void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def);
void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def)); void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def);
void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def)); void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def);
void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def)); void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#endif #endif
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__) || 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 FOPEN_FUNC(filename, mode) fopen(filename, mode)
#define FTELLO_FUNC(stream) ftello(stream) #define FTELLO_FUNC(stream) ftello(stream)
...@@ -81,11 +81,7 @@ ...@@ -81,11 +81,7 @@
filename : the filename of the file where date/time must be modified filename : the filename of the file where date/time must be modified
dosdate : the new date at the MSDos format (4 bytes) dosdate : the new date at the MSDos format (4 bytes)
tmu_date : the SAME new date at the tm_unz format */ tmu_date : the SAME new date at the tm_unz format */
static void change_file_date(filename,dosdate,tmu_date) static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) {
const char *filename;
uLong dosdate;
tm_unz tmu_date;
{
#ifdef _WIN32 #ifdef _WIN32
HANDLE hFile; HANDLE hFile;
FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
...@@ -115,6 +111,10 @@ static void change_file_date(filename,dosdate,tmu_date) ...@@ -115,6 +111,10 @@ static void change_file_date(filename,dosdate,tmu_date)
ut.actime=ut.modtime=mktime(&newdate); ut.actime=ut.modtime=mktime(&newdate);
utime(filename,&ut); utime(filename,&ut);
#else
(void)filename;
(void)dosdate;
(void)tmu_date;
#endif #endif
#endif #endif
} }
...@@ -123,9 +123,7 @@ static void change_file_date(filename,dosdate,tmu_date) ...@@ -123,9 +123,7 @@ static void change_file_date(filename,dosdate,tmu_date)
/* mymkdir and change_file_date are not 100 % portable /* mymkdir and change_file_date are not 100 % portable
As I don't know well Unix, I wait feedback for the unix portion */ As I don't know well Unix, I wait feedback for the unix portion */
static int mymkdir(dirname) static int mymkdir(const char* dirname) {
const char* dirname;
{
int ret=0; int ret=0;
#ifdef _WIN32 #ifdef _WIN32
ret = _mkdir(dirname); ret = _mkdir(dirname);
...@@ -133,13 +131,13 @@ static int mymkdir(dirname) ...@@ -133,13 +131,13 @@ static int mymkdir(dirname)
ret = mkdir (dirname,0775); ret = mkdir (dirname,0775);
#elif __APPLE__ #elif __APPLE__
ret = mkdir (dirname,0775); ret = mkdir (dirname,0775);
#else
(void)dirname;
#endif #endif
return ret; return ret;
} }
static int makedir (newdir) static int makedir(const char *newdir) {
const char *newdir;
{
char *buffer ; char *buffer ;
char *p; char *p;
size_t len = strlen(newdir); size_t len = strlen(newdir);
...@@ -187,14 +185,12 @@ static int makedir (newdir) ...@@ -187,14 +185,12 @@ static int makedir (newdir)
return 1; return 1;
} }
static void do_banner() static void do_banner(void) {
{
printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n"); printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n");
printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
} }
static void do_help() static void do_help(void) {
{
printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \ printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
" -e Extract without pathname (junk paths)\n" \ " -e Extract without pathname (junk paths)\n" \
" -x Extract with pathname\n" \ " -x Extract with pathname\n" \
...@@ -202,11 +198,10 @@ static void do_help() ...@@ -202,11 +198,10 @@ static void do_help()
" -l list files\n" \ " -l list files\n" \
" -d directory to extract into\n" \ " -d directory to extract into\n" \
" -o overwrite files without prompting\n" \ " -o overwrite files without prompting\n" \
" -p extract crypted file using password\n\n"); " -p extract encrypted file using password\n\n");
} }
static void Display64BitsSize(ZPOS64_T n, int size_char) static void Display64BitsSize(ZPOS64_T n, int size_char) {
{
/* to avoid compatibility problem , we do here the conversion */ /* to avoid compatibility problem , we do here the conversion */
char number[21]; char number[21];
int offset=19; int offset=19;
...@@ -233,9 +228,7 @@ static void Display64BitsSize(ZPOS64_T n, int size_char) ...@@ -233,9 +228,7 @@ static void Display64BitsSize(ZPOS64_T n, int size_char)
printf("%s",&number[pos_string]); printf("%s",&number[pos_string]);
} }
static int do_list(uf) static int do_list(unzFile uf) {
unzFile uf;
{
uLong i; uLong i;
unz_global_info64 gi; unz_global_info64 gi;
int err; int err;
...@@ -250,7 +243,7 @@ static int do_list(uf) ...@@ -250,7 +243,7 @@ static int do_list(uf)
char filename_inzip[256]; char filename_inzip[256];
unz_file_info64 file_info; unz_file_info64 file_info;
uLong ratio=0; uLong ratio=0;
const char *string_method; const char *string_method = "";
char charCrypt=' '; char charCrypt=' ';
err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
if (err!=UNZ_OK) if (err!=UNZ_OK)
...@@ -261,7 +254,7 @@ static int do_list(uf) ...@@ -261,7 +254,7 @@ static int do_list(uf)
if (file_info.uncompressed_size>0) if (file_info.uncompressed_size>0)
ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size); ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size);
/* display a '*' if the file is crypted */ /* display a '*' if the file is encrypted */
if ((file_info.flag & 1) != 0) if ((file_info.flag & 1) != 0)
charCrypt='*'; charCrypt='*';
...@@ -311,12 +304,7 @@ static int do_list(uf) ...@@ -311,12 +304,7 @@ static int do_list(uf)
} }
static int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password) static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password) {
unzFile uf;
const int* popt_extract_without_path;
int* popt_overwrite;
const char* password;
{
char filename_inzip[256]; char filename_inzip[256];
char* filename_withoutpath; char* filename_withoutpath;
char* p; char* p;
...@@ -473,12 +461,7 @@ static int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,pa ...@@ -473,12 +461,7 @@ static int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,pa
} }
static int do_extract(uf,opt_extract_without_path,opt_overwrite,password) static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password) {
unzFile uf;
int opt_extract_without_path;
int opt_overwrite;
const char* password;
{
uLong i; uLong i;
unz_global_info64 gi; unz_global_info64 gi;
int err; int err;
...@@ -508,13 +491,7 @@ static int do_extract(uf,opt_extract_without_path,opt_overwrite,password) ...@@ -508,13 +491,7 @@ static int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
return 0; return 0;
} }
static int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password) static int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_without_path, int opt_overwrite, const char* password) {
unzFile uf;
const char* filename;
int opt_extract_without_path;
int opt_overwrite;
const char* password;
{
if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK) if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
{ {
printf("file %s not found in the zipfile\n",filename); printf("file %s not found in the zipfile\n",filename);
...@@ -530,10 +507,7 @@ static int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite ...@@ -530,10 +507,7 @@ static int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite
} }
int main(argc,argv) int main(int argc, char *argv[]) {
int argc;
char *argv[];
{
const char *zipfilename=NULL; const char *zipfilename=NULL;
const char *filename_to_extract=NULL; const char *filename_to_extract=NULL;
const char *password=NULL; const char *password=NULL;
...@@ -606,7 +580,7 @@ int main(argc,argv) ...@@ -606,7 +580,7 @@ int main(argc,argv)
# endif # endif
strncpy(filename_try, zipfilename,MAXFILENAME-1); strncpy(filename_try, zipfilename,MAXFILENAME-1);
/* strncpy doesnt append the trailing NULL, of the string is too long. */ /* strncpy doesn't append the trailing NULL, of the string is too long. */
filename_try[ MAXFILENAME ] = '\0'; filename_try[ MAXFILENAME ] = '\0';
# ifdef USEWIN32IOAPI # ifdef USEWIN32IOAPI
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#endif #endif
#endif #endif
#ifdef __APPLE__ #if defined(__APPLE__) || 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 FOPEN_FUNC(filename, mode) fopen(filename, mode)
#define FTELLO_FUNC(stream) ftello(stream) #define FTELLO_FUNC(stream) ftello(stream)
...@@ -71,11 +71,9 @@ ...@@ -71,11 +71,9 @@
#define MAXFILENAME (256) #define MAXFILENAME (256)
#ifdef _WIN32 #ifdef _WIN32
static int filetime(f, tmzip, dt) /* f: name of file to get info on, tmzip: return value: access,
const char *f; /* name of file to get info on */ modification and creation times, dt: dostime */
tm_zip *tmzip; /* return value: access, modific. and creation times */ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
uLong *dt; /* dostime */
{
int ret = 0; int ret = 0;
{ {
FILETIME ftLocal; FILETIME ftLocal;
...@@ -95,11 +93,9 @@ static int filetime(f, tmzip, dt) ...@@ -95,11 +93,9 @@ static int filetime(f, tmzip, dt)
} }
#else #else
#if defined(unix) || defined(__APPLE__) #if defined(unix) || defined(__APPLE__)
static int filetime(f, tmzip, dt) /* f: name of file to get info on, tmzip: return value: access,
const char *f; /* name of file to get info on */ modification and creation times, dt: dostime */
tm_zip *tmzip; /* return value: access, modific. and creation times */ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
uLong *dt; /* dostime */
{
(void)dt; (void)dt;
int ret=0; int ret=0;
struct stat s; /* results of stat() */ struct stat s; /* results of stat() */
...@@ -114,7 +110,7 @@ static int filetime(f, tmzip, dt) ...@@ -114,7 +110,7 @@ static int filetime(f, tmzip, dt)
len = MAXFILENAME; len = MAXFILENAME;
strncpy(name, f,MAXFILENAME-1); strncpy(name, f,MAXFILENAME-1);
/* strncpy doesnt append the trailing NULL, of the string is too long. */ /* strncpy doesn't append the trailing NULL, of the string is too long. */
name[ MAXFILENAME ] = '\0'; name[ MAXFILENAME ] = '\0';
if (name[len - 1] == '/') if (name[len - 1] == '/')
...@@ -138,11 +134,12 @@ static int filetime(f, tmzip, dt) ...@@ -138,11 +134,12 @@ static int filetime(f, tmzip, dt)
return ret; return ret;
} }
#else #else
uLong filetime(f, tmzip, dt) /* f: name of file to get info on, tmzip: return value: access,
const char *f; /* name of file to get info on */ modification and creation times, dt: dostime */
tm_zip *tmzip; /* return value: access, modific. and creation times */ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
uLong *dt; /* dostime */ (void)f;
{ (void)tmzip;
(void)dt;
return 0; return 0;
} }
#endif #endif
...@@ -151,9 +148,7 @@ uLong filetime(f, tmzip, dt) ...@@ -151,9 +148,7 @@ uLong filetime(f, tmzip, dt)
static int check_exist_file(filename) static int check_exist_file(const char* filename) {
const char* filename;
{
FILE* ftestexist; FILE* ftestexist;
int ret = 1; int ret = 1;
ftestexist = FOPEN_FUNC(filename,"rb"); ftestexist = FOPEN_FUNC(filename,"rb");
...@@ -164,14 +159,12 @@ static int check_exist_file(filename) ...@@ -164,14 +159,12 @@ static int check_exist_file(filename)
return ret; return ret;
} }
static void do_banner() static void do_banner(void) {
{
printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n"); printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n");
printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n"); printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n");
} }
static void do_help() static void do_help(void) {
{
printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \ printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \
" -o Overwrite existing file.zip\n" \ " -o Overwrite existing file.zip\n" \
" -a Append to existing file.zip\n" \ " -a Append to existing file.zip\n" \
...@@ -183,8 +176,7 @@ static void do_help() ...@@ -183,8 +176,7 @@ static void do_help()
/* calculate the CRC32 of a file, /* calculate the CRC32 of a file,
because to encrypt a file, we need known the CRC32 of the file before */ because to encrypt a file, we need known the CRC32 of the file before */
static int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc) static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_buf, unsigned long* result_crc) {
{
unsigned long calculate_crc=0; unsigned long calculate_crc=0;
int err=ZIP_OK; int err=ZIP_OK;
FILE * fin = FOPEN_FUNC(filenameinzip,"rb"); FILE * fin = FOPEN_FUNC(filenameinzip,"rb");
...@@ -222,8 +214,7 @@ static int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf, ...@@ -222,8 +214,7 @@ static int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,
return err; return err;
} }
static int isLargeFile(const char* filename) static int isLargeFile(const char* filename) {
{
int largeFile = 0; int largeFile = 0;
ZPOS64_T pos = 0; ZPOS64_T pos = 0;
FILE* pFile = FOPEN_FUNC(filename, "rb"); FILE* pFile = FOPEN_FUNC(filename, "rb");
...@@ -233,7 +224,7 @@ static int isLargeFile(const char* filename) ...@@ -233,7 +224,7 @@ static int isLargeFile(const char* filename)
FSEEKO_FUNC(pFile, 0, SEEK_END); FSEEKO_FUNC(pFile, 0, SEEK_END);
pos = (ZPOS64_T)FTELLO_FUNC(pFile); pos = (ZPOS64_T)FTELLO_FUNC(pFile);
printf("File : %s is %lld bytes\n", filename, pos); printf("File : %s is %llu bytes\n", filename, pos);
if(pos >= 0xffffffff) if(pos >= 0xffffffff)
largeFile = 1; largeFile = 1;
...@@ -244,10 +235,7 @@ static int isLargeFile(const char* filename) ...@@ -244,10 +235,7 @@ static int isLargeFile(const char* filename)
return largeFile; return largeFile;
} }
int main(argc,argv) int main(int argc, char *argv[]) {
int argc;
char *argv[];
{
int i; int i;
int opt_overwrite=0; int opt_overwrite=0;
int opt_compress_level=Z_DEFAULT_COMPRESSION; int opt_compress_level=Z_DEFAULT_COMPRESSION;
...@@ -323,7 +311,7 @@ int main(argc,argv) ...@@ -323,7 +311,7 @@ int main(argc,argv)
zipok = 1 ; zipok = 1 ;
strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1); strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1);
/* strncpy doesnt append the trailing NULL, of the string is too long. */ /* strncpy doesn't append the trailing NULL, of the string is too long. */
filename_try[ MAXFILENAME ] = '\0'; filename_try[ MAXFILENAME ] = '\0';
len=(int)strlen(filename_try); len=(int)strlen(filename_try);
...@@ -393,10 +381,10 @@ int main(argc,argv) ...@@ -393,10 +381,10 @@ int main(argc,argv)
((argv[i][1]=='o') || (argv[i][1]=='O') || ((argv[i][1]=='o') || (argv[i][1]=='O') ||
(argv[i][1]=='a') || (argv[i][1]=='A') || (argv[i][1]=='a') || (argv[i][1]=='A') ||
(argv[i][1]=='p') || (argv[i][1]=='P') || (argv[i][1]=='p') || (argv[i][1]=='P') ||
((argv[i][1]>='0') || (argv[i][1]<='9'))) && ((argv[i][1]>='0') && (argv[i][1]<='9'))) &&
(strlen(argv[i]) == 2))) (strlen(argv[i]) == 2)))
{ {
FILE * fin; FILE * fin = NULL;
size_t size_read; size_t size_read;
const char* filenameinzip = argv[i]; const char* filenameinzip = argv[i];
const char *savefilenameinzip; const char *savefilenameinzip;
......
...@@ -27,13 +27,7 @@ ...@@ -27,13 +27,7 @@
WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \ WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \
} while(0) } while(0)
extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered) extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered) {
const char* file;
const char* fileOut;
const char* fileOutTmp;
uLong* nRecovered;
uLong* bytesRecovered;
{
int err = Z_OK; int err = Z_OK;
FILE* fpZip = fopen(file, "rb"); FILE* fpZip = fopen(file, "rb");
FILE* fpOut = fopen(fileOut, "wb"); FILE* fpOut = fopen(fileOut, "wb");
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -10,7 +10,7 @@ unit zlibpas; ...@@ -10,7 +10,7 @@ unit zlibpas;
interface interface
const const
ZLIB_VERSION = '1.2.13'; ZLIB_VERSION = '1.3.0';
ZLIB_VERNUM = $12a0; ZLIB_VERNUM = $12a0;
type type
......
...@@ -169,7 +169,7 @@ int main(int argc, char *argv[]) ...@@ -169,7 +169,7 @@ int main(int argc, char *argv[])
printf("error reading %s\n",argv[1]); printf("error reading %s\n",argv[1]);
return 1; return 1;
} }
else printf("file %s read, %u bytes\n",argv[1],lFileSize); else printf("file %s read, %ld bytes\n",argv[1],lFileSize);
if (argc>=3) if (argc>=3)
BlockSizeCompress=atol(argv[2]); BlockSizeCompress=atol(argv[2]);
......
...@@ -4,6 +4,22 @@ ...@@ -4,6 +4,22 @@
* written by Pedro A. Aranda Gutierrez <paag@tid.es> * written by Pedro A. Aranda Gutierrez <paag@tid.es>
* adaptation to Unix by Jean-loup Gailly <jloup@gzip.org> * adaptation to Unix by Jean-loup Gailly <jloup@gzip.org>
* various fixes by Cosmin Truta <cosmint@cs.ubbcluj.ro> * various fixes by Cosmin Truta <cosmint@cs.ubbcluj.ro>
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/ */
#include <stdio.h> #include <stdio.h>
...@@ -14,15 +30,10 @@ ...@@ -14,15 +30,10 @@
#include "zlib.h" #include "zlib.h"
#ifdef unix #ifdef _WIN32
# include <unistd.h>
#else
# include <direct.h> # include <direct.h>
# include <io.h> # include <io.h>
#endif # include <windows.h>
#ifdef WIN32
#include <windows.h>
# ifndef F_OK # ifndef F_OK
# define F_OK 0 # define F_OK 0
# endif # endif
...@@ -33,6 +44,8 @@ ...@@ -33,6 +44,8 @@
# define strdup(str) _strdup(str) # define strdup(str) _strdup(str)
# endif # endif
#else #else
# include <sys/stat.h>
# include <unistd.h>
# include <utime.h> # include <utime.h>
#endif #endif
...@@ -102,28 +115,14 @@ struct attr_item ...@@ -102,28 +115,14 @@ struct attr_item
enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID }; enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID };
char *TGZfname OF((const char *));
void TGZnotfound OF((const char *));
int getoct OF((char *, int));
char *strtime OF((time_t *));
int setfiletime OF((char *, time_t));
void push_attr OF((struct attr_item **, char *, int, time_t));
void restore_attr OF((struct attr_item **));
int ExprMatch OF((char *, char *));
int makedir OF((char *));
int matchname OF((int, int, char **, char *));
void error OF((const char *));
int tar OF((gzFile, int, int, int, char **));
void help OF((int));
int main OF((int, char **));
char *prog; char *prog;
void error(const char *msg)
{
fprintf(stderr, "%s: %s\n", prog, msg);
exit(1);
}
const char *TGZsuffix[] = { "\0", ".tar", ".tar.gz", ".taz", ".tgz", NULL }; const char *TGZsuffix[] = { "\0", ".tar", ".tar.gz", ".taz", ".tgz", NULL };
/* return the file name of the TGZ archive */ /* return the file name of the TGZ archive */
...@@ -205,7 +204,7 @@ char *strtime (time_t *t) ...@@ -205,7 +204,7 @@ char *strtime (time_t *t)
int setfiletime (char *fname,time_t ftime) int setfiletime (char *fname,time_t ftime)
{ {
#ifdef WIN32 #ifdef _WIN32
static int isWinNT = -1; static int isWinNT = -1;
SYSTEMTIME st; SYSTEMTIME st;
FILETIME locft, modft; FILETIME locft, modft;
...@@ -590,12 +589,6 @@ void help(int exitval) ...@@ -590,12 +589,6 @@ void help(int exitval)
exit(exitval); exit(exitval);
} }
void error(const char *msg)
{
fprintf(stderr, "%s: %s\n", prog, msg);
exit(1);
}
/* ============================================================ */ /* ============================================================ */
...@@ -608,7 +601,7 @@ int main(int argc,char **argv) ...@@ -608,7 +601,7 @@ int main(int argc,char **argv)
int action = TGZ_EXTRACT; int action = TGZ_EXTRACT;
int arg = 1; int arg = 1;
char *TGZfile; char *TGZfile;
gzFile *f; gzFile f;
prog = strrchr(argv[0],'\\'); prog = strrchr(argv[0],'\\');
if (prog == NULL) if (prog == NULL)
......
Building instructions for the DLL versions of Zlib 1.2.13 Building instructions for the DLL versions of Zlib 1.3.0
======================================================== ========================================================
This directory contains projects that build zlib and minizip using This directory contains projects that build zlib and minizip using
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
#define IDR_VERSION1 1 #define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 2, 13, 0 FILEVERSION 1, 3, 0, 0
PRODUCTVERSION 1, 2, 13, 0 PRODUCTVERSION 1, 3, 0, 0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0 FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32 FILEOS VOS_DOS_WINDOWS32
...@@ -17,12 +17,12 @@ BEGIN ...@@ -17,12 +17,12 @@ BEGIN
BEGIN BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.2.13\0" VALUE "FileVersion", "1.3.0\0"
VALUE "InternalName", "zlib\0" VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0" VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0" VALUE "ProductName", "ZLib.DLL\0"
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
......
LIBRARY LIBRARY
; zlib data compression and ZIP file I/O library ; zlib data compression and ZIP file I/O library
VERSION 1.2 VERSION 1.3
EXPORTS EXPORTS
adler32 @1 adler32 @1
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
#define IDR_VERSION1 1 #define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 2, 13, 0 FILEVERSION 1, 3, 0, 0
PRODUCTVERSION 1, 2, 13, 0 PRODUCTVERSION 1, 3, 0, 0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0 FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32 FILEOS VOS_DOS_WINDOWS32
...@@ -17,12 +17,12 @@ BEGIN ...@@ -17,12 +17,12 @@ BEGIN
BEGIN BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.2.13\0" VALUE "FileVersion", "1.3.0\0"
VALUE "InternalName", "zlib\0" VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0" VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0" VALUE "ProductName", "ZLib.DLL\0"
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
......
LIBRARY LIBRARY
; zlib data compression and ZIP file I/O library ; zlib data compression and ZIP file I/O library
VERSION 1.2 VERSION 1.3
EXPORTS EXPORTS
adler32 @1 adler32 @1
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
#define IDR_VERSION1 1 #define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 2, 13, 0 FILEVERSION 1, 3, 0, 0
PRODUCTVERSION 1, 2, 13, 0 PRODUCTVERSION 1, 3, 0, 0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0 FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32 FILEOS VOS_DOS_WINDOWS32
...@@ -17,12 +17,12 @@ BEGIN ...@@ -17,12 +17,12 @@ BEGIN
BEGIN BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.2.13\0" VALUE "FileVersion", "1.3.0\0"
VALUE "InternalName", "zlib\0" VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0" VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0" VALUE "ProductName", "ZLib.DLL\0"
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
......
LIBRARY LIBRARY
; zlib data compression and ZIP file I/O library ; zlib data compression and ZIP file I/O library
VERSION 1.2 VERSION 1.3
EXPORTS EXPORTS
adler32 @1 adler32 @1
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
#define IDR_VERSION1 1 #define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 2, 13, 0 FILEVERSION 1, 3, 0, 0
PRODUCTVERSION 1, 2, 13, 0 PRODUCTVERSION 1, 3, 0, 0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0 FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32 FILEOS VOS_DOS_WINDOWS32
...@@ -17,12 +17,12 @@ BEGIN ...@@ -17,12 +17,12 @@ BEGIN
BEGIN BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.2.13\0" VALUE "FileVersion", "1.3.0\0"
VALUE "InternalName", "zlib\0" VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0" VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0" VALUE "ProductName", "ZLib.DLL\0"
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
......
LIBRARY LIBRARY
; zlib data compression and ZIP file I/O library ; zlib data compression and ZIP file I/O library
VERSION 1.2 VERSION 1.3
EXPORTS EXPORTS
adler32 @1 adler32 @1
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
#define IDR_VERSION1 1 #define IDR_VERSION1 1
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
FILEVERSION 1, 2, 13, 0 FILEVERSION 1, 3, 0, 0
PRODUCTVERSION 1, 2, 13, 0 PRODUCTVERSION 1, 3, 0, 0
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0 FILEFLAGS 0
FILEOS VOS_DOS_WINDOWS32 FILEOS VOS_DOS_WINDOWS32
...@@ -17,12 +17,12 @@ BEGIN ...@@ -17,12 +17,12 @@ BEGIN
BEGIN BEGIN
VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0"
VALUE "FileVersion", "1.2.13\0" VALUE "FileVersion", "1.3.0\0"
VALUE "InternalName", "zlib\0" VALUE "InternalName", "zlib\0"
VALUE "OriginalFilename", "zlibwapi.dll\0" VALUE "OriginalFilename", "zlibwapi.dll\0"
VALUE "ProductName", "ZLib.DLL\0" VALUE "ProductName", "ZLib.DLL\0"
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
......
LIBRARY LIBRARY
; zlib data compression and ZIP file I/O library ; zlib data compression and ZIP file I/O library
VERSION 1.2 VERSION 1.3
EXPORTS EXPORTS
adler32 @1 adler32 @1
......
This diff is collapsed.
This diff is collapsed.
...@@ -291,14 +291,14 @@ typedef struct internal_state { ...@@ -291,14 +291,14 @@ typedef struct internal_state {
memory checker errors from longest match routines */ memory checker errors from longest match routines */
/* in trees.c */ /* in trees.c */
void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); void ZLIB_INTERNAL _tr_init(deflate_state *s);
int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc);
void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
ulg stored_len, int last)); ulg stored_len, int last);
void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s);
void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); void ZLIB_INTERNAL _tr_align(deflate_state *s);
void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
ulg stored_len, int last)); ulg stored_len, int last);
#define d_code(dist) \ #define d_code(dist) \
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
......
...@@ -198,7 +198,7 @@ int main(int argc, char **argv) ...@@ -198,7 +198,7 @@ int main(int argc, char **argv)
if (ret == Z_MEM_ERROR) if (ret == Z_MEM_ERROR)
quit("out of memory"); quit("out of memory");
/* set up for next reocmpression */ /* set up for next recompression */
ret = inflateReset(&inf); ret = inflateReset(&inf);
assert(ret != Z_STREAM_ERROR); assert(ret != Z_STREAM_ERROR);
ret = deflateReset(&def); ret = deflateReset(&def);
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd"> "http://www.w3.org/TR/html4/loose.dtd">
<html> <html>
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>zlib Usage Example</title> <title>zlib Usage Example</title>
<!-- Copyright (c) 2004, 2005 Mark Adler. --> <!-- Copyright (c) 2004-2023 Mark Adler. -->
</head> </head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#00A000"> <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#00A000">
<h2 align="center"> zlib Usage Example </h2> <h2 align="center"> zlib Usage Example </h2>
...@@ -17,7 +17,7 @@ from an input file to an output file using <tt>deflate()</tt> and <tt>inflate()< ...@@ -17,7 +17,7 @@ from an input file to an output file using <tt>deflate()</tt> and <tt>inflate()<
annotations are interspersed between lines of the code. So please read between the lines. annotations are interspersed between lines of the code. So please read between the lines.
We hope this helps explain some of the intricacies of <em>zlib</em>. We hope this helps explain some of the intricacies of <em>zlib</em>.
<p> <p>
Without further adieu, here is the program <a href="zpipe.c"><tt>zpipe.c</tt></a>: Without further ado, here is the program <a href="zpipe.c"><tt>zpipe.c</tt></a>:
<pre><b> <pre><b>
/* zpipe.c: example of proper use of zlib's inflate() and deflate() /* zpipe.c: example of proper use of zlib's inflate() and deflate()
Not copyrighted -- provided to the public domain Not copyrighted -- provided to the public domain
...@@ -155,13 +155,11 @@ before we fall out of the loop at the bottom. ...@@ -155,13 +155,11 @@ before we fall out of the loop at the bottom.
</b></pre> </b></pre>
We start off by reading data from the input file. The number of bytes read is put directly We start off by reading data from the input file. The number of bytes read is put directly
into <tt>avail_in</tt>, and a pointer to those bytes is put into <tt>next_in</tt>. We also into <tt>avail_in</tt>, and a pointer to those bytes is put into <tt>next_in</tt>. We also
check to see if end-of-file on the input has been reached. If we are at the end of file, then <tt>flush</tt> is set to the check to see if end-of-file on the input has been reached using feof().
If we are at the end of file, then <tt>flush</tt> is set to the
<em>zlib</em> constant <tt>Z_FINISH</tt>, which is later passed to <tt>deflate()</tt> to <em>zlib</em> constant <tt>Z_FINISH</tt>, which is later passed to <tt>deflate()</tt> to
indicate that this is the last chunk of input data to compress. We need to use <tt>feof()</tt> indicate that this is the last chunk of input data to compress.
to check for end-of-file as opposed to seeing if fewer than <tt>CHUNK</tt> bytes have been read. The If we are not yet at the end of the input, then the <em>zlib</em>
reason is that if the input file length is an exact multiple of <tt>CHUNK</tt>, we will miss
the fact that we got to the end-of-file, and not know to tell <tt>deflate()</tt> to finish
up the compressed stream. If we are not yet at the end of the input, then the <em>zlib</em>
constant <tt>Z_NO_FLUSH</tt> will be passed to <tt>deflate</tt> to indicate that we are still constant <tt>Z_NO_FLUSH</tt> will be passed to <tt>deflate</tt> to indicate that we are still
in the middle of the uncompressed data. in the middle of the uncompressed data.
<p> <p>
...@@ -540,6 +538,12 @@ int main(int argc, char **argv) ...@@ -540,6 +538,12 @@ int main(int argc, char **argv)
} }
</b></pre> </b></pre>
<hr> <hr>
<i>Copyright (c) 2004, 2005 by Mark Adler<br>Last modified 11 December 2005</i> <i>Last modified 24 January 2023<br>
Copyright &#169; 2004-2023 Mark Adler</i><br>
<a rel="license" href="http://creativecommons.org/licenses/by-nd/4.0/">
<img alt="Creative Commons License" style="border-width:0"
src="https://i.creativecommons.org/l/by-nd/4.0/88x31.png"></a>
<a rel="license" href="http://creativecommons.org/licenses/by-nd/4.0/">
Creative Commons Attribution-NoDerivatives 4.0 International License</a>.
</body> </body>
</html> </html>
This diff is collapsed.
/* zran.h -- example of zlib/gzip stream indexing and random access /* zran.h -- example of deflated stream indexing and random access
* Copyright (C) 2005, 2012, 2018 Mark Adler * Copyright (C) 2005, 2012, 2018, 2023 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
* Version 1.2 14 Oct 2018 Mark Adler */ * Version 1.3 18 Feb 2023 Mark Adler */
#include <stdio.h> #include <stdio.h>
#include "zlib.h" #include "zlib.h"
/* Access point list. */ // Access point.
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
} point_t;
// Access point list.
struct deflate_index { struct deflate_index {
int have; /* number of list entries */ int have; // number of access points in list
int gzip; /* 1 if the index is of a gzip file, 0 if it is of a int mode; // -15 for raw, 15 for zlib, or 31 for gzip
zlib stream */ off_t length; // total length of uncompressed data
off_t length; /* total length of uncompressed data */ point_t *list; // allocated list of access points
void *list; /* allocated list of entries */
}; };
/* Make one entire pass through a zlib or gzip compressed stream and build an // Make one pass through a zlib, gzip, or raw deflate compressed stream and
index, with access points about every span bytes of uncompressed output. // build an index, with access points about every span bytes of uncompressed
gzip files with multiple members are indexed in their entirety. span should // output. gzip files with multiple members are fully indexed. span should be
be chosen to balance the speed of random access against the memory // chosen to balance the speed of random access against the memory requirements
requirements of the list, about 32K bytes per access point. The return value // of the list, which is about 32K bytes per access point. The return value is
is the number of access points on success (>= 1), Z_MEM_ERROR for out of // the number of access points on success (>= 1), Z_MEM_ERROR for out of
memory, Z_DATA_ERROR for an error in the input file, or Z_ERRNO for a file // memory, Z_BUF_ERROR for a premature end of input, Z_DATA_ERROR for a format
read error. On success, *built points to the resulting index. */ // or verification error in the input file, or Z_ERRNO for a file read error.
// On success, *built points to the resulting index.
int deflate_index_build(FILE *in, off_t span, struct deflate_index **built); int deflate_index_build(FILE *in, off_t span, struct deflate_index **built);
/* Deallocate an index built by deflate_index_build() */ // Use the index to read len bytes from offset into buf. Return the number of
void deflate_index_free(struct deflate_index *index); // bytes read or a negative error code. If data is requested past the end of
// the uncompressed data, then deflate_index_extract() will return a value less
// than len, indicating how much was actually read into buf. If given a valid
// index, this function should not return an error unless the file was modified
// somehow since the index was generated, given that deflate_index_build() had
// validated all of the input. If nevertheless there is a failure, Z_BUF_ERROR
// is returned if the compressed data ends prematurely, Z_DATA_ERROR if the
// deflate compressed data is not valid, Z_MEM_ERROR if out of memory,
// Z_STREAM_ERROR if the index is not valid, or Z_ERRNO if there is an error
// reading or seeking on the input file.
ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index,
off_t offset, unsigned char *buf, size_t len);
/* Use the index to read len bytes from offset into buf. Return bytes read or // Deallocate an index built by deflate_index_build().
negative for error (Z_DATA_ERROR or Z_MEM_ERROR). If data is requested past void deflate_index_free(struct deflate_index *index);
the end of the uncompressed data, then deflate_index_extract() will return a
value less than len, indicating how much was actually read into buf. This
function should not return a data error unless the file was modified since
the index was generated, since deflate_index_build() validated all of the
input. deflate_index_extract() will return Z_ERRNO if there is an error on
reading or seeking the input file. */
int deflate_index_extract(FILE *in, struct deflate_index *index, off_t offset,
unsigned char *buf, int len);
...@@ -8,9 +8,7 @@ ...@@ -8,9 +8,7 @@
/* gzclose() is in a separate file so that it is linked in only if it is used. /* gzclose() is in a separate file so that it is linked in only if it is used.
That way the other gzclose functions can be used instead to avoid linking in That way the other gzclose functions can be used instead to avoid linking in
unneeded compression or decompression routines. */ unneeded compression or decompression routines. */
int ZEXPORT gzclose(file) int ZEXPORT gzclose(gzFile file) {
gzFile file;
{
#ifndef NO_GZCOMPRESS #ifndef NO_GZCOMPRESS
gz_statep state; gz_statep state;
......
...@@ -7,9 +7,8 @@ ...@@ -7,9 +7,8 @@
# ifndef _LARGEFILE_SOURCE # ifndef _LARGEFILE_SOURCE
# define _LARGEFILE_SOURCE 1 # define _LARGEFILE_SOURCE 1
# endif # endif
# ifdef _FILE_OFFSET_BITS # undef _FILE_OFFSET_BITS
# undef _FILE_OFFSET_BITS # undef _TIME_BITS
# endif
#endif #endif
#ifdef HAVE_HIDDEN #ifdef HAVE_HIDDEN
...@@ -119,8 +118,8 @@ ...@@ -119,8 +118,8 @@
/* gz* functions always use library allocation functions */ /* gz* functions always use library allocation functions */
#ifndef STDC #ifndef STDC
extern voidp malloc OF((uInt size)); extern voidp malloc(uInt size);
extern void free OF((voidpf ptr)); extern void free(voidpf ptr);
#endif #endif
/* get errno and strerror definition */ /* get errno and strerror definition */
...@@ -138,10 +137,10 @@ ...@@ -138,10 +137,10 @@
/* provide prototypes for these when building zlib without LFS */ /* provide prototypes for these when building zlib without LFS */
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int);
ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); ZEXTERN z_off64_t ZEXPORT gztell64(gzFile);
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile);
#endif #endif
/* default memLevel */ /* default memLevel */
...@@ -203,9 +202,9 @@ typedef struct { ...@@ -203,9 +202,9 @@ typedef struct {
typedef gz_state FAR *gz_statep; typedef gz_state FAR *gz_statep;
/* shared functions */ /* shared functions */
void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); void ZLIB_INTERNAL gz_error(gz_statep, int, const char *);
#if defined UNDER_CE #if defined UNDER_CE
char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
#endif #endif
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
...@@ -214,6 +213,6 @@ char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); ...@@ -214,6 +213,6 @@ char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
#ifdef INT_MAX #ifdef INT_MAX
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
#else #else
unsigned ZLIB_INTERNAL gz_intmax OF((void)); unsigned ZLIB_INTERNAL gz_intmax(void);
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
#endif #endif
...@@ -15,10 +15,6 @@ ...@@ -15,10 +15,6 @@
#endif #endif
#endif #endif
/* Local functions */
local void gz_reset OF((gz_statep));
local gzFile gz_open OF((const void *, int, const char *));
#if defined UNDER_CE #if defined UNDER_CE
/* Map the Windows error number in ERROR to a locale-dependent error message /* Map the Windows error number in ERROR to a locale-dependent error message
...@@ -30,9 +26,7 @@ local gzFile gz_open OF((const void *, int, const char *)); ...@@ -30,9 +26,7 @@ local gzFile gz_open OF((const void *, int, const char *));
The gz_strwinerror function does not change the current setting of The gz_strwinerror function does not change the current setting of
GetLastError. */ GetLastError. */
char ZLIB_INTERNAL *gz_strwinerror(error) char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
DWORD error;
{
static char buf[1024]; static char buf[1024];
wchar_t *msgbuf; wchar_t *msgbuf;
...@@ -72,9 +66,7 @@ char ZLIB_INTERNAL *gz_strwinerror(error) ...@@ -72,9 +66,7 @@ char ZLIB_INTERNAL *gz_strwinerror(error)
#endif /* UNDER_CE */ #endif /* UNDER_CE */
/* Reset gzip file state */ /* Reset gzip file state */
local void gz_reset(state) local void gz_reset(gz_statep state) {
gz_statep state;
{
state->x.have = 0; /* no output data available */ state->x.have = 0; /* no output data available */
if (state->mode == GZ_READ) { /* for reading ... */ if (state->mode == GZ_READ) { /* for reading ... */
state->eof = 0; /* not at end of file */ state->eof = 0; /* not at end of file */
...@@ -90,11 +82,7 @@ local void gz_reset(state) ...@@ -90,11 +82,7 @@ local void gz_reset(state)
} }
/* Open a gzip file either by name or file descriptor. */ /* Open a gzip file either by name or file descriptor. */
local gzFile gz_open(path, fd, mode) local gzFile gz_open(const void *path, int fd, const char *mode) {
const void *path;
int fd;
const char *mode;
{
gz_statep state; gz_statep state;
z_size_t len; z_size_t len;
int oflag; int oflag;
...@@ -269,26 +257,17 @@ local gzFile gz_open(path, fd, mode) ...@@ -269,26 +257,17 @@ local gzFile gz_open(path, fd, mode)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
gzFile ZEXPORT gzopen(path, mode) gzFile ZEXPORT gzopen(const char *path, const char *mode) {
const char *path;
const char *mode;
{
return gz_open(path, -1, mode); return gz_open(path, -1, mode);
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
gzFile ZEXPORT gzopen64(path, mode) gzFile ZEXPORT gzopen64(const char *path, const char *mode) {
const char *path;
const char *mode;
{
return gz_open(path, -1, mode); return gz_open(path, -1, mode);
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
gzFile ZEXPORT gzdopen(fd, mode) gzFile ZEXPORT gzdopen(int fd, const char *mode) {
int fd;
const char *mode;
{
char *path; /* identifier for error messages */ char *path; /* identifier for error messages */
gzFile gz; gzFile gz;
...@@ -306,19 +285,13 @@ gzFile ZEXPORT gzdopen(fd, mode) ...@@ -306,19 +285,13 @@ gzFile ZEXPORT gzdopen(fd, mode)
/* -- see zlib.h -- */ /* -- see zlib.h -- */
#ifdef WIDECHAR #ifdef WIDECHAR
gzFile ZEXPORT gzopen_w(path, mode) gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) {
const wchar_t *path;
const char *mode;
{
return gz_open(path, -2, mode); return gz_open(path, -2, mode);
} }
#endif #endif
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzbuffer(file, size) int ZEXPORT gzbuffer(gzFile file, unsigned size) {
gzFile file;
unsigned size;
{
gz_statep state; gz_statep state;
/* get internal structure and check integrity */ /* get internal structure and check integrity */
...@@ -335,16 +308,14 @@ int ZEXPORT gzbuffer(file, size) ...@@ -335,16 +308,14 @@ int ZEXPORT gzbuffer(file, size)
/* check and set requested size */ /* check and set requested size */
if ((size << 1) < size) if ((size << 1) < size)
return -1; /* need to be able to double it */ return -1; /* need to be able to double it */
if (size < 2) if (size < 8)
size = 2; /* need two bytes to check magic header */ size = 8; /* needed to behave well with flushing */
state->want = size; state->want = size;
return 0; return 0;
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzrewind(file) int ZEXPORT gzrewind(gzFile file) {
gzFile file;
{
gz_statep state; gz_statep state;
/* get internal structure */ /* get internal structure */
...@@ -365,11 +336,7 @@ int ZEXPORT gzrewind(file) ...@@ -365,11 +336,7 @@ int ZEXPORT gzrewind(file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_off64_t ZEXPORT gzseek64(file, offset, whence) z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
gzFile file;
z_off64_t offset;
int whence;
{
unsigned n; unsigned n;
z_off64_t ret; z_off64_t ret;
gz_statep state; gz_statep state;
...@@ -442,11 +409,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence) ...@@ -442,11 +409,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_off_t ZEXPORT gzseek(file, offset, whence) z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) {
gzFile file;
z_off_t offset;
int whence;
{
z_off64_t ret; z_off64_t ret;
ret = gzseek64(file, (z_off64_t)offset, whence); ret = gzseek64(file, (z_off64_t)offset, whence);
...@@ -454,9 +417,7 @@ z_off_t ZEXPORT gzseek(file, offset, whence) ...@@ -454,9 +417,7 @@ z_off_t ZEXPORT gzseek(file, offset, whence)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_off64_t ZEXPORT gztell64(file) z_off64_t ZEXPORT gztell64(gzFile file) {
gzFile file;
{
gz_statep state; gz_statep state;
/* get internal structure and check integrity */ /* get internal structure and check integrity */
...@@ -471,9 +432,7 @@ z_off64_t ZEXPORT gztell64(file) ...@@ -471,9 +432,7 @@ z_off64_t ZEXPORT gztell64(file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_off_t ZEXPORT gztell(file) z_off_t ZEXPORT gztell(gzFile file) {
gzFile file;
{
z_off64_t ret; z_off64_t ret;
ret = gztell64(file); ret = gztell64(file);
...@@ -481,9 +440,7 @@ z_off_t ZEXPORT gztell(file) ...@@ -481,9 +440,7 @@ z_off_t ZEXPORT gztell(file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_off64_t ZEXPORT gzoffset64(file) z_off64_t ZEXPORT gzoffset64(gzFile file) {
gzFile file;
{
z_off64_t offset; z_off64_t offset;
gz_statep state; gz_statep state;
...@@ -504,9 +461,7 @@ z_off64_t ZEXPORT gzoffset64(file) ...@@ -504,9 +461,7 @@ z_off64_t ZEXPORT gzoffset64(file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_off_t ZEXPORT gzoffset(file) z_off_t ZEXPORT gzoffset(gzFile file) {
gzFile file;
{
z_off64_t ret; z_off64_t ret;
ret = gzoffset64(file); ret = gzoffset64(file);
...@@ -514,9 +469,7 @@ z_off_t ZEXPORT gzoffset(file) ...@@ -514,9 +469,7 @@ z_off_t ZEXPORT gzoffset(file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzeof(file) int ZEXPORT gzeof(gzFile file) {
gzFile file;
{
gz_statep state; gz_statep state;
/* get internal structure and check integrity */ /* get internal structure and check integrity */
...@@ -531,10 +484,7 @@ int ZEXPORT gzeof(file) ...@@ -531,10 +484,7 @@ int ZEXPORT gzeof(file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
const char * ZEXPORT gzerror(file, errnum) const char * ZEXPORT gzerror(gzFile file, int *errnum) {
gzFile file;
int *errnum;
{
gz_statep state; gz_statep state;
/* get internal structure and check integrity */ /* get internal structure and check integrity */
...@@ -552,9 +502,7 @@ const char * ZEXPORT gzerror(file, errnum) ...@@ -552,9 +502,7 @@ const char * ZEXPORT gzerror(file, errnum)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
void ZEXPORT gzclearerr(file) void ZEXPORT gzclearerr(gzFile file) {
gzFile file;
{
gz_statep state; gz_statep state;
/* get internal structure and check integrity */ /* get internal structure and check integrity */
...@@ -578,11 +526,7 @@ void ZEXPORT gzclearerr(file) ...@@ -578,11 +526,7 @@ void ZEXPORT gzclearerr(file)
memory). Simply save the error message as a static string. If there is an memory). Simply save the error message as a static string. If there is an
allocation failure constructing the error message, then convert the error to allocation failure constructing the error message, then convert the error to
out of memory. */ out of memory. */
void ZLIB_INTERNAL gz_error(state, err, msg) void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
gz_statep state;
int err;
const char *msg;
{
/* free previously allocated message and clear */ /* free previously allocated message and clear */
if (state->msg != NULL) { if (state->msg != NULL) {
if (state->err != Z_MEM_ERROR) if (state->err != Z_MEM_ERROR)
...@@ -624,8 +568,7 @@ void ZLIB_INTERNAL gz_error(state, err, msg) ...@@ -624,8 +568,7 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
available) -- we need to do this to cover cases where 2's complement not available) -- we need to do this to cover cases where 2's complement not
used, since C standard permits 1's complement and sign-bit representations, used, since C standard permits 1's complement and sign-bit representations,
otherwise we could just use ((unsigned)-1) >> 1 */ otherwise we could just use ((unsigned)-1) >> 1 */
unsigned ZLIB_INTERNAL gz_intmax() unsigned ZLIB_INTERNAL gz_intmax(void) {
{
unsigned p, q; unsigned p, q;
p = 1; p = 1;
......
...@@ -5,25 +5,12 @@ ...@@ -5,25 +5,12 @@
#include "gzguts.h" #include "gzguts.h"
/* Local functions */
local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
local int gz_avail OF((gz_statep));
local int gz_look OF((gz_statep));
local int gz_decomp OF((gz_statep));
local int gz_fetch OF((gz_statep));
local int gz_skip OF((gz_statep, z_off64_t));
local z_size_t gz_read OF((gz_statep, voidp, z_size_t));
/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from
state->fd, and update state->eof, state->err, and state->msg as appropriate. state->fd, and update state->eof, state->err, and state->msg as appropriate.
This function needs to loop on read(), since read() is not guaranteed to This function needs to loop on read(), since read() is not guaranteed to
read the number of bytes requested, depending on the type of descriptor. */ read the number of bytes requested, depending on the type of descriptor. */
local int gz_load(state, buf, len, have) local int gz_load(gz_statep state, unsigned char *buf, unsigned len,
gz_statep state; unsigned *have) {
unsigned char *buf;
unsigned len;
unsigned *have;
{
int ret; int ret;
unsigned get, max = ((unsigned)-1 >> 2) + 1; unsigned get, max = ((unsigned)-1 >> 2) + 1;
...@@ -53,9 +40,7 @@ local int gz_load(state, buf, len, have) ...@@ -53,9 +40,7 @@ local int gz_load(state, buf, len, have)
If strm->avail_in != 0, then the current data is moved to the beginning of If strm->avail_in != 0, then the current data is moved to the beginning of
the input buffer, and then the remainder of the buffer is loaded with the the input buffer, and then the remainder of the buffer is loaded with the
available data from the input file. */ available data from the input file. */
local int gz_avail(state) local int gz_avail(gz_statep state) {
gz_statep state;
{
unsigned got; unsigned got;
z_streamp strm = &(state->strm); z_streamp strm = &(state->strm);
...@@ -88,9 +73,7 @@ local int gz_avail(state) ...@@ -88,9 +73,7 @@ local int gz_avail(state)
case, all further file reads will be directly to either the output buffer or case, all further file reads will be directly to either the output buffer or
a user buffer. If decompressing, the inflate state will be initialized. a user buffer. If decompressing, the inflate state will be initialized.
gz_look() will return 0 on success or -1 on failure. */ gz_look() will return 0 on success or -1 on failure. */
local int gz_look(state) local int gz_look(gz_statep state) {
gz_statep state;
{
z_streamp strm = &(state->strm); z_streamp strm = &(state->strm);
/* allocate read buffers and inflate memory */ /* allocate read buffers and inflate memory */
...@@ -170,9 +153,7 @@ local int gz_look(state) ...@@ -170,9 +153,7 @@ local int gz_look(state)
data. If the gzip stream completes, state->how is reset to LOOK to look for data. If the gzip stream completes, state->how is reset to LOOK to look for
the next gzip stream or raw data, once state->x.have is depleted. Returns 0 the next gzip stream or raw data, once state->x.have is depleted. Returns 0
on success, -1 on failure. */ on success, -1 on failure. */
local int gz_decomp(state) local int gz_decomp(gz_statep state) {
gz_statep state;
{
int ret = Z_OK; int ret = Z_OK;
unsigned had; unsigned had;
z_streamp strm = &(state->strm); z_streamp strm = &(state->strm);
...@@ -224,9 +205,7 @@ local int gz_decomp(state) ...@@ -224,9 +205,7 @@ local int gz_decomp(state)
looked for to determine whether to copy or decompress. Returns -1 on error, looked for to determine whether to copy or decompress. Returns -1 on error,
otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the
end of the input file has been reached and all data has been processed. */ end of the input file has been reached and all data has been processed. */
local int gz_fetch(state) local int gz_fetch(gz_statep state) {
gz_statep state;
{
z_streamp strm = &(state->strm); z_streamp strm = &(state->strm);
do { do {
...@@ -254,10 +233,7 @@ local int gz_fetch(state) ...@@ -254,10 +233,7 @@ local int gz_fetch(state)
} }
/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */
local int gz_skip(state, len) local int gz_skip(gz_statep state, z_off64_t len) {
gz_statep state;
z_off64_t len;
{
unsigned n; unsigned n;
/* skip over len bytes or reach end-of-file, whichever comes first */ /* skip over len bytes or reach end-of-file, whichever comes first */
...@@ -289,11 +265,7 @@ local int gz_skip(state, len) ...@@ -289,11 +265,7 @@ local int gz_skip(state, len)
input. Return the number of bytes read. If zero is returned, either the input. Return the number of bytes read. If zero is returned, either the
end of file was reached, or there was an error. state->err must be end of file was reached, or there was an error. state->err must be
consulted in that case to determine which. */ consulted in that case to determine which. */
local z_size_t gz_read(state, buf, len) local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
gz_statep state;
voidp buf;
z_size_t len;
{
z_size_t got; z_size_t got;
unsigned n; unsigned n;
...@@ -370,11 +342,7 @@ local z_size_t gz_read(state, buf, len) ...@@ -370,11 +342,7 @@ local z_size_t gz_read(state, buf, len)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzread(file, buf, len) int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) {
gzFile file;
voidp buf;
unsigned len;
{
gz_statep state; gz_statep state;
/* get internal structure */ /* get internal structure */
...@@ -406,12 +374,7 @@ int ZEXPORT gzread(file, buf, len) ...@@ -406,12 +374,7 @@ int ZEXPORT gzread(file, buf, len)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_size_t ZEXPORT gzfread(buf, size, nitems, file) z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) {
voidp buf;
z_size_t size;
z_size_t nitems;
gzFile file;
{
z_size_t len; z_size_t len;
gz_statep state; gz_statep state;
...@@ -442,9 +405,7 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file) ...@@ -442,9 +405,7 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file)
#else #else
# undef gzgetc # undef gzgetc
#endif #endif
int ZEXPORT gzgetc(file) int ZEXPORT gzgetc(gzFile file) {
gzFile file;
{
unsigned char buf[1]; unsigned char buf[1];
gz_statep state; gz_statep state;
...@@ -469,17 +430,12 @@ int ZEXPORT gzgetc(file) ...@@ -469,17 +430,12 @@ int ZEXPORT gzgetc(file)
return gz_read(state, buf, 1) < 1 ? -1 : buf[0]; return gz_read(state, buf, 1) < 1 ? -1 : buf[0];
} }
int ZEXPORT gzgetc_(file) int ZEXPORT gzgetc_(gzFile file) {
gzFile file;
{
return gzgetc(file); return gzgetc(file);
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzungetc(c, file) int ZEXPORT gzungetc(int c, gzFile file) {
int c;
gzFile file;
{
gz_statep state; gz_statep state;
/* get internal structure */ /* get internal structure */
...@@ -487,6 +443,10 @@ int ZEXPORT gzungetc(c, file) ...@@ -487,6 +443,10 @@ int ZEXPORT gzungetc(c, file)
return -1; return -1;
state = (gz_statep)file; state = (gz_statep)file;
/* in case this was just opened, set up the input buffer */
if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
(void)gz_look(state);
/* check that we're reading and that there's no (serious) error */ /* check that we're reading and that there's no (serious) error */
if (state->mode != GZ_READ || if (state->mode != GZ_READ ||
(state->err != Z_OK && state->err != Z_BUF_ERROR)) (state->err != Z_OK && state->err != Z_BUF_ERROR))
...@@ -536,11 +496,7 @@ int ZEXPORT gzungetc(c, file) ...@@ -536,11 +496,7 @@ int ZEXPORT gzungetc(c, file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
char * ZEXPORT gzgets(file, buf, len) char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
gzFile file;
char *buf;
int len;
{
unsigned left, n; unsigned left, n;
char *str; char *str;
unsigned char *eol; unsigned char *eol;
...@@ -600,9 +556,7 @@ char * ZEXPORT gzgets(file, buf, len) ...@@ -600,9 +556,7 @@ char * ZEXPORT gzgets(file, buf, len)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzdirect(file) int ZEXPORT gzdirect(gzFile file) {
gzFile file;
{
gz_statep state; gz_statep state;
/* get internal structure */ /* get internal structure */
...@@ -620,9 +574,7 @@ int ZEXPORT gzdirect(file) ...@@ -620,9 +574,7 @@ int ZEXPORT gzdirect(file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzclose_r(file) int ZEXPORT gzclose_r(gzFile file) {
gzFile file;
{
int ret, err; int ret, err;
gz_statep state; gz_statep state;
......
This diff is collapsed.
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
#include "inflate.h" #include "inflate.h"
#include "inffast.h" #include "inffast.h"
/* function prototypes */
local void fixedtables OF((struct inflate_state FAR *state));
/* /*
strm provides memory allocation functions in zalloc and zfree, or strm provides memory allocation functions in zalloc and zfree, or
Z_NULL to use the library memory allocation functions. Z_NULL to use the library memory allocation functions.
...@@ -25,13 +22,9 @@ local void fixedtables OF((struct inflate_state FAR *state)); ...@@ -25,13 +22,9 @@ local void fixedtables OF((struct inflate_state FAR *state));
windowBits is in the range 8..15, and window is a user-supplied windowBits is in the range 8..15, and window is a user-supplied
window and output buffer that is 2**windowBits bytes. window and output buffer that is 2**windowBits bytes.
*/ */
int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
z_streamp strm; unsigned char FAR *window, const char *version,
int windowBits; int stream_size) {
unsigned char FAR *window;
const char *version;
int stream_size;
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
...@@ -80,9 +73,7 @@ int stream_size; ...@@ -80,9 +73,7 @@ int stream_size;
used for threaded applications, since the rewriting of the tables and virgin used for threaded applications, since the rewriting of the tables and virgin
may not be thread-safe. may not be thread-safe.
*/ */
local void fixedtables(state) local void fixedtables(struct inflate_state FAR *state) {
struct inflate_state FAR *state;
{
#ifdef BUILDFIXED #ifdef BUILDFIXED
static int virgin = 1; static int virgin = 1;
static code *lenfix, *distfix; static code *lenfix, *distfix;
...@@ -248,13 +239,8 @@ struct inflate_state FAR *state; ...@@ -248,13 +239,8 @@ struct inflate_state FAR *state;
inflateBack() can also return Z_STREAM_ERROR if the input parameters inflateBack() can also return Z_STREAM_ERROR if the input parameters
are not correct, i.e. strm is Z_NULL or the state was not initialized. are not correct, i.e. strm is Z_NULL or the state was not initialized.
*/ */
int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
z_streamp strm; out_func out, void FAR *out_desc) {
in_func in;
void FAR *in_desc;
out_func out;
void FAR *out_desc;
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
z_const unsigned char FAR *next; /* next input */ z_const unsigned char FAR *next; /* next input */
unsigned char FAR *put; /* next output */ unsigned char FAR *put; /* next output */
...@@ -632,9 +618,7 @@ void FAR *out_desc; ...@@ -632,9 +618,7 @@ void FAR *out_desc;
return ret; return ret;
} }
int ZEXPORT inflateBackEnd(strm) int ZEXPORT inflateBackEnd(z_streamp strm) {
z_streamp strm;
{
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
ZFREE(strm, strm->state); ZFREE(strm, strm->state);
......
...@@ -47,10 +47,7 @@ ...@@ -47,10 +47,7 @@
requires strm->avail_out >= 258 for each loop to avoid checking for requires strm->avail_out >= 258 for each loop to avoid checking for
output space. output space.
*/ */
void ZLIB_INTERNAL inflate_fast(strm, start) void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) {
z_streamp strm;
unsigned start; /* inflate()'s starting value for strm->avail_out */
{
struct inflate_state FAR *state; struct inflate_state FAR *state;
z_const unsigned char FAR *in; /* local strm->next_in */ z_const unsigned char FAR *in; /* local strm->next_in */
z_const unsigned char FAR *last; /* have enough input while in < last */ z_const unsigned char FAR *last; /* have enough input while in < last */
......
...@@ -8,4 +8,4 @@ ...@@ -8,4 +8,4 @@
subject to change. Applications should only use zlib.h. subject to change. Applications should only use zlib.h.
*/ */
void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start);
This diff is collapsed.
/* inftrees.c -- generate Huffman trees for efficient decoding /* inftrees.c -- generate Huffman trees for efficient decoding
* Copyright (C) 1995-2022 Mark Adler * Copyright (C) 1995-2023 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#define MAXBITS 15 #define MAXBITS 15
const char inflate_copyright[] = const char inflate_copyright[] =
" inflate 1.2.13 Copyright 1995-2022 Mark Adler "; " inflate 1.3 Copyright 1995-2023 Mark Adler ";
/* /*
If you use the zlib library in a product, an acknowledgment is welcome If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot in the documentation of your product. If for some reason you cannot
...@@ -29,14 +29,9 @@ const char inflate_copyright[] = ...@@ -29,14 +29,9 @@ const char inflate_copyright[] =
table index bits. It will differ if the request is greater than the table index bits. It will differ if the request is greater than the
longest code or if it is less than the shortest code. longest code or if it is less than the shortest code.
*/ */
int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
codetype type; unsigned codes, code FAR * FAR *table,
unsigned short FAR *lens; unsigned FAR *bits, unsigned short FAR *work) {
unsigned codes;
code FAR * FAR *table;
unsigned FAR *bits;
unsigned short FAR *work;
{
unsigned len; /* a code's length in bits */ unsigned len; /* a code's length in bits */
unsigned sym; /* index of code symbols */ unsigned sym; /* index of code symbols */
unsigned min, max; /* minimum and maximum code lengths */ unsigned min, max; /* minimum and maximum code lengths */
...@@ -62,7 +57,7 @@ unsigned short FAR *work; ...@@ -62,7 +57,7 @@ unsigned short FAR *work;
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */ static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 194, 65}; 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 198, 203};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
No preview for this file type
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment