- upgrade to pristine zlib-1.2.1.2.
CVS patchset: 7420 CVS date: 2004/09/19 16:14:54
This commit is contained in:
parent
59293dd892
commit
4040942914
|
@ -1,11 +1,37 @@
|
|||
|
||||
ChangeLog file for zlib
|
||||
|
||||
Changes in 1.2.1.2 (9 September 2004)
|
||||
- Update INDEX file
|
||||
- Fix trees.c to update strm->data_type (no one ever noticed!)
|
||||
- Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown]
|
||||
- Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE)
|
||||
- Add limited multitasking protection to DYNAMIC_CRC_TABLE
|
||||
- Add NO_vsnprintf for VMS in zutil.h [Mozilla]
|
||||
- Don't declare strerror() under VMS [Mozilla]
|
||||
- Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize
|
||||
- Update contrib/ada [Anisimkov]
|
||||
- Update contrib/minizip [Vollant]
|
||||
- Fix configure to not hardcode directories for Darwin [Peterson]
|
||||
- Fix gzio.c to not return error on empty files [Brown]
|
||||
- Fix indentation; update version in contrib/delphi/ZLib.pas and
|
||||
contrib/pascal/zlibpas.pas [Truta]
|
||||
- Update mkasm.bat in contrib/masmx86 [Truta]
|
||||
- Update contrib/untgz [Truta]
|
||||
- Add projects/README.projects [Truta]
|
||||
- Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta]
|
||||
- Update win32/DLL_FAQ.txt [Truta]
|
||||
- Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta]
|
||||
- Remove an unnecessary assignment to curr in inftrees.c [Truta]
|
||||
- Add OS/2 to exe builds in configure [Poltorak]
|
||||
- Remove err dummy parameter in zlib.h [Kientzle]
|
||||
|
||||
Changes in 1.2.1.1 (9 January 2004)
|
||||
- Updated email address in README
|
||||
- Update email address in README
|
||||
- Several FAQ updates
|
||||
- Fixed a big fat bug in inftrees.c that prevented decoding valid
|
||||
dynamic blocks with only literals and no distance codes.
|
||||
- Fix a big fat bug in inftrees.c that prevented decoding valid
|
||||
dynamic blocks with only literals and no distance codes --
|
||||
Thanks to "Hot Emu" for the bug report and sample file
|
||||
- Add a note to puff.c on no distance codes case.
|
||||
|
||||
Changes in 1.2.1 (17 November 2003)
|
||||
|
|
|
@ -8,9 +8,12 @@ algorithm.txt description of the (de)compression algorithm
|
|||
configure configure script for Unix
|
||||
zconf.in.h template for zconf.h (used by configure)
|
||||
|
||||
amiga/ makefiles for Amiga SAS C
|
||||
as400/ makefiles for IBM AS/400
|
||||
msdos/ makefiles for MSDOS
|
||||
old/ makefiles for various architectures and zlib documentation
|
||||
files that have not yet been updated for zlib 1.2.x
|
||||
projects/ projects for various Integrated Development Environments
|
||||
qnx/ makefiles for QNX
|
||||
win32/ makefiles for Windows
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
ZLIB DATA COMPRESSION LIBRARY
|
||||
|
||||
zlib 1.2.1.1 is a general purpose data compression library. All the code is
|
||||
zlib 1.2.1.2 is a general purpose data compression library. All the code is
|
||||
thread safe. The data format used by the zlib library is described by RFCs
|
||||
(Request for Comments) 1950 to 1952 in the files
|
||||
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
|
||||
|
@ -34,7 +34,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
|
|||
issue of Dr. Dobb's Journal; a copy of the article is available in
|
||||
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
|
||||
|
||||
The changes made in version 1.2.1.1 are documented in the file ChangeLog.
|
||||
The changes made in version 1.2.1.2 are documented in the file ChangeLog.
|
||||
|
||||
Unsupported third party contributions are provided in directory "contrib".
|
||||
|
||||
|
@ -93,7 +93,7 @@ Acknowledgments:
|
|||
|
||||
Copyright notice:
|
||||
|
||||
(C) 1995-2003 Jean-loup Gailly and Mark Adler
|
||||
(C) 1995-2004 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
|
|
|
@ -44,7 +44,10 @@
|
|||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len)
|
||||
uLong ZEXPORT adler32(adler, buf, len)
|
||||
uLong adler;
|
||||
const Bytef *buf;
|
||||
uInt len;
|
||||
{
|
||||
unsigned long s1 = adler & 0xffff;
|
||||
unsigned long s2 = (adler >> 16) & 0xffff;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
* ZLIB.INC - Interface to the general purpose compression library
|
||||
*
|
||||
* ILE RPG400 version by Patrick Monnerat, DATASPHERE.
|
||||
* Version 1.2.1.1
|
||||
* Version 1.2.1.2
|
||||
*
|
||||
*
|
||||
* WARNING:
|
||||
|
@ -20,8 +20,8 @@
|
|||
* Constants
|
||||
**************************************************************************
|
||||
*
|
||||
D ZLIB_VERSION C '1.2.1.1' Header's version
|
||||
D ZLIB_VERNUM C X'1211'
|
||||
D ZLIB_VERSION C '1.2.1.2' Header's version
|
||||
D ZLIB_VERNUM C X'1212'
|
||||
*
|
||||
D Z_NO_FLUSH C 0
|
||||
D Z_SYNC_FLUSH C 2
|
||||
|
|
|
@ -19,7 +19,12 @@
|
|||
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
||||
Z_STREAM_ERROR if the level parameter is invalid.
|
||||
*/
|
||||
int ZEXPORT compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level)
|
||||
int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
|
||||
Bytef *dest;
|
||||
uLongf *destLen;
|
||||
const Bytef *source;
|
||||
uLong sourceLen;
|
||||
int level;
|
||||
{
|
||||
z_stream stream;
|
||||
int err;
|
||||
|
@ -54,7 +59,11 @@ int ZEXPORT compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong
|
|||
|
||||
/* ===========================================================================
|
||||
*/
|
||||
int ZEXPORT compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
|
||||
int ZEXPORT compress (dest, destLen, source, sourceLen)
|
||||
Bytef *dest;
|
||||
uLongf *destLen;
|
||||
const Bytef *source;
|
||||
uLong sourceLen;
|
||||
{
|
||||
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
|
||||
}
|
||||
|
@ -63,7 +72,8 @@ int ZEXPORT compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong s
|
|||
If the default memLevel or windowBits for deflateInit() is changed, then
|
||||
this function needs to be updated.
|
||||
*/
|
||||
uLong ZEXPORT compressBound (uLong sourceLen)
|
||||
uLong ZEXPORT compressBound (sourceLen)
|
||||
uLong sourceLen;
|
||||
{
|
||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -67,4 +67,4 @@ visual-basic.txt by Carlos Rios <c_rios@sonda.cl>
|
|||
How to use compress(), uncompress() and the gz* functions from VB
|
||||
|
||||
vstudio/ by Gilles Vollant <info@winimage.com>
|
||||
Building zlib with Visual Studio .NET
|
||||
Building a minizip-enhanced zlib with Visual Studio .NET
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
-- --
|
||||
-- Open source license information is in the zlib.ads file. --
|
||||
----------------------------------------------------------------
|
||||
-- Continuous test for ZLib multithreading. If the test is fail
|
||||
-- Wou should provide thread safe allocation routines for the Z_Stream.
|
||||
-- Continuous test for ZLib multithreading. If the test would fail
|
||||
-- we should provide thread safe allocation routines for the Z_Stream.
|
||||
--
|
||||
-- $Id: mtest.adb,v 1.2 2003/08/12 12:11:05 vagul Exp $
|
||||
-- $Id: mtest.adb,v 1.4 2004/07/23 07:49:54 vagul Exp $
|
||||
|
||||
with ZLib;
|
||||
with Ada.Streams;
|
||||
|
@ -148,6 +148,9 @@ procedure MTest is
|
|||
|
||||
pragma Unreferenced (Test);
|
||||
|
||||
Dummy : Character;
|
||||
|
||||
begin
|
||||
null;
|
||||
Ada.Text_IO.Get_Immediate (Dummy);
|
||||
Stop := True;
|
||||
end MTest;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
-- Open source license information is in the zlib.ads file. --
|
||||
----------------------------------------------------------------
|
||||
|
||||
-- $Id: read.adb,v 1.7 2003/08/12 12:12:35 vagul Exp $
|
||||
-- $Id: read.adb,v 1.8 2004/05/31 10:53:40 vagul Exp $
|
||||
|
||||
-- Test/demo program for the generic read interface.
|
||||
|
||||
|
@ -68,7 +68,11 @@ procedure Read is
|
|||
-- ZLib.Read
|
||||
-- reading data from the File_In.
|
||||
|
||||
procedure Read is new ZLib.Read (Read, Read_Buffer, Read_First, Read_Last);
|
||||
procedure Read is new ZLib.Read
|
||||
(Read,
|
||||
Read_Buffer,
|
||||
Rest_First => Read_First,
|
||||
Rest_Last => Read_Last);
|
||||
|
||||
----------
|
||||
-- Read --
|
||||
|
@ -103,6 +107,7 @@ procedure Read is
|
|||
Pack_Size := 0;
|
||||
Offset := 1;
|
||||
Read_First := Read_Buffer'Last + 1;
|
||||
Read_Last := Read_Buffer'Last;
|
||||
end Reset;
|
||||
|
||||
begin
|
||||
|
|
|
@ -1,20 +1,31 @@
|
|||
|
||||
ZLib for Ada thick binding (ZLib.Ada)
|
||||
Release 1.2
|
||||
Release 1.3
|
||||
|
||||
ZLib.Ada is a thick binding interface to the popular ZLib data
|
||||
compression library, available at http://www.gzip.org/zlib/.
|
||||
It provides Ada-style access to the ZLib C library.
|
||||
|
||||
|
||||
Here are the main changes since ZLib.Ada 1.1:
|
||||
Here are the main changes since ZLib.Ada 1.2:
|
||||
|
||||
- The default header type has a name "Default" now. Auto is used only for
|
||||
automatic GZip/ZLib header detection.
|
||||
- Attension: ZLib.Read generic routine have a initialization requirement
|
||||
for Read_Last parameter now. It is a bit incompartible with previous version,
|
||||
but extends functionality, we could use new parameters Allow_Read_Some and
|
||||
Flush now.
|
||||
|
||||
- Added test for multitasking mtest.adb.
|
||||
- Added Is_Open routines to ZLib and ZLib.Streams packages.
|
||||
|
||||
- Added GNAT project file zlib.gpr.
|
||||
- Add pragma Assert to check Stream_Element is 8 bit.
|
||||
|
||||
- Fix extraction to buffer with exact known decompressed size. Error reported by
|
||||
Steve Sangwine.
|
||||
|
||||
- Fix definition of ULong (changed to unsigned_long), fix regression on 64 bits
|
||||
computers. Patch provided by Pascal Obry.
|
||||
|
||||
- Add Status_Error exception definition.
|
||||
|
||||
- Add pragma Assertion that Ada.Streams.Stream_Element size is 8 bit.
|
||||
|
||||
|
||||
How to build ZLib.Ada under GNAT
|
||||
|
@ -50,3 +61,5 @@ The routines from the package specifications are commented.
|
|||
|
||||
Homepage: http://zlib-ada.sourceforge.net/
|
||||
Author: Dmitriy Anisimkov <anisimkov@yahoo.com>
|
||||
|
||||
Contributors: Pascal Obry <pascal@obry.org>, Steve Sangwine <sjs@essex.ac.uk>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
-- Open source license information is in the zlib.ads file. --
|
||||
----------------------------------------------------------------
|
||||
|
||||
-- $Id: zlib-streams.adb,v 1.9 2003/08/12 13:15:31 vagul Exp $
|
||||
-- $Id: zlib-streams.adb,v 1.10 2004/05/31 10:53:40 vagul Exp $
|
||||
|
||||
with Ada.Unchecked_Deallocation;
|
||||
|
||||
|
@ -90,6 +90,7 @@ package body ZLib.Streams is
|
|||
|
||||
Stream.Buffer := new Buffer_Subtype;
|
||||
Stream.Rest_First := Stream.Buffer'Last + 1;
|
||||
Stream.Rest_Last := Stream.Buffer'Last;
|
||||
end if;
|
||||
end Create;
|
||||
|
||||
|
@ -113,6 +114,15 @@ package body ZLib.Streams is
|
|||
end loop;
|
||||
end Flush;
|
||||
|
||||
-------------
|
||||
-- Is_Open --
|
||||
-------------
|
||||
|
||||
function Is_Open (Stream : Stream_Type) return Boolean is
|
||||
begin
|
||||
return Is_Open (Stream.Reader) or else Is_Open (Stream.Writer);
|
||||
end Is_Open;
|
||||
|
||||
----------
|
||||
-- Read --
|
||||
----------
|
||||
|
@ -212,4 +222,4 @@ package body ZLib.Streams is
|
|||
return Total_Out (Stream.Writer);
|
||||
end Write_Total_Out;
|
||||
|
||||
end ZLib.Streams;
|
||||
end ZLib.Streams;
|
|
@ -6,7 +6,7 @@
|
|||
-- Open source license information is in the zlib.ads file. --
|
||||
----------------------------------------------------------------
|
||||
|
||||
-- $Id: zlib-streams.ads,v 1.11 2003/08/12 13:15:31 vagul Exp $
|
||||
-- $Id: zlib-streams.ads,v 1.12 2004/05/31 10:53:40 vagul Exp $
|
||||
|
||||
package ZLib.Streams is
|
||||
|
||||
|
@ -77,6 +77,8 @@ package ZLib.Streams is
|
|||
-- !!! When the Need_Header is False ZLib-Ada is using undocumented
|
||||
-- ZLib 1.1.4 functionality to do not create/wait for ZLib headers.
|
||||
|
||||
function Is_Open (Stream : Stream_Type) return Boolean;
|
||||
|
||||
procedure Close (Stream : in out Stream_Type);
|
||||
|
||||
private
|
||||
|
@ -109,4 +111,4 @@ private
|
|||
Writer : Filter_Type;
|
||||
end record;
|
||||
|
||||
end ZLib.Streams;
|
||||
end ZLib.Streams;
|
|
@ -6,12 +6,11 @@
|
|||
-- Open source license information is in the zlib.ads file. --
|
||||
----------------------------------------------------------------
|
||||
|
||||
-- $Id: zlib-thin.adb,v 1.6 2003/01/21 15:26:37 vagul Exp $
|
||||
-- $Id: zlib-thin.adb,v 1.8 2003/12/14 18:27:31 vagul Exp $
|
||||
|
||||
package body ZLib.Thin is
|
||||
|
||||
ZLIB_VERSION : constant Chars_Ptr :=
|
||||
Interfaces.C.Strings.New_String ("1.1.4");
|
||||
ZLIB_VERSION : constant Chars_Ptr := zlibVersion;
|
||||
|
||||
Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit;
|
||||
|
||||
|
@ -37,14 +36,6 @@ package body ZLib.Thin is
|
|||
-- Deflate_Init --
|
||||
------------------
|
||||
|
||||
function Deflate_Init
|
||||
(strm : in Z_Streamp;
|
||||
level : in Int := Z_DEFAULT_COMPRESSION)
|
||||
return Int is
|
||||
begin
|
||||
return deflateInit (strm, level, ZLIB_VERSION, Z_Stream_Size);
|
||||
end Deflate_Init;
|
||||
|
||||
function Deflate_Init
|
||||
(strm : Z_Streamp;
|
||||
level : Int;
|
||||
|
@ -69,16 +60,15 @@ package body ZLib.Thin is
|
|||
-- Inflate_Init --
|
||||
------------------
|
||||
|
||||
function Inflate_Init (strm : Z_Streamp) return Int is
|
||||
begin
|
||||
return inflateInit (strm, ZLIB_VERSION, Z_Stream_Size);
|
||||
end Inflate_Init;
|
||||
|
||||
function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is
|
||||
begin
|
||||
return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size);
|
||||
end Inflate_Init;
|
||||
|
||||
------------------------
|
||||
-- Last_Error_Message --
|
||||
------------------------
|
||||
|
||||
function Last_Error_Message (Strm : in Z_Stream) return String is
|
||||
use Interfaces.C.Strings;
|
||||
begin
|
||||
|
@ -89,54 +79,28 @@ package body ZLib.Thin is
|
|||
end if;
|
||||
end Last_Error_Message;
|
||||
|
||||
-------------
|
||||
-- Need_In --
|
||||
-------------
|
||||
|
||||
function Need_In (strm : Z_Stream) return Boolean is
|
||||
begin
|
||||
return strm.Avail_In = 0;
|
||||
end Need_In;
|
||||
|
||||
--------------
|
||||
-- Need_Out --
|
||||
--------------
|
||||
|
||||
function Need_Out (strm : Z_Stream) return Boolean is
|
||||
begin
|
||||
return strm.Avail_Out = 0;
|
||||
end Need_Out;
|
||||
|
||||
------------
|
||||
-- Set_In --
|
||||
------------
|
||||
|
||||
procedure Set_In
|
||||
(Strm : in out Z_Stream;
|
||||
Buffer : in Byte_Access;
|
||||
Size : in UInt) is
|
||||
Buffer : in Voidp;
|
||||
Size : in UInt) is
|
||||
begin
|
||||
Strm.Next_In := Buffer;
|
||||
Strm.Avail_In := Size;
|
||||
end Set_In;
|
||||
|
||||
procedure Set_In
|
||||
(Strm : in out Z_Stream;
|
||||
Buffer : in Voidp;
|
||||
Size : in UInt) is
|
||||
begin
|
||||
Set_In (Strm, Bytes.To_Pointer (Buffer), Size);
|
||||
end Set_In;
|
||||
|
||||
------------------
|
||||
-- Set_Mem_Func --
|
||||
------------------
|
||||
|
||||
procedure Set_Mem_Func
|
||||
(Strm : in out Z_Stream;
|
||||
Opaque : in Voidp;
|
||||
Alloc : in alloc_func;
|
||||
Free : in free_func) is
|
||||
Opaque : in Voidp;
|
||||
Alloc : in alloc_func;
|
||||
Free : in free_func) is
|
||||
begin
|
||||
Strm.opaque := Opaque;
|
||||
Strm.zalloc := Alloc;
|
||||
|
@ -149,21 +113,13 @@ package body ZLib.Thin is
|
|||
|
||||
procedure Set_Out
|
||||
(Strm : in out Z_Stream;
|
||||
Buffer : in Byte_Access;
|
||||
Size : in UInt) is
|
||||
Buffer : in Voidp;
|
||||
Size : in UInt) is
|
||||
begin
|
||||
Strm.Next_Out := Buffer;
|
||||
Strm.Avail_Out := Size;
|
||||
end Set_Out;
|
||||
|
||||
procedure Set_Out
|
||||
(Strm : in out Z_Stream;
|
||||
Buffer : in Voidp;
|
||||
Size : in UInt) is
|
||||
begin
|
||||
Set_Out (Strm, Bytes.To_Pointer (Buffer), Size);
|
||||
end Set_Out;
|
||||
|
||||
--------------
|
||||
-- Total_In --
|
||||
--------------
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
-- Open source license information is in the zlib.ads file. --
|
||||
----------------------------------------------------------------
|
||||
|
||||
-- $Id: zlib-thin.ads,v 1.8 2003/08/12 13:16:51 vagul Exp $
|
||||
-- $Id: zlib-thin.ads,v 1.11 2004/07/23 06:33:11 vagul Exp $
|
||||
|
||||
with Interfaces.C.Strings;
|
||||
with System.Address_To_Access_Conversions;
|
||||
|
||||
with System;
|
||||
|
||||
private package ZLib.Thin is
|
||||
|
||||
|
@ -36,18 +37,18 @@ private package ZLib.Thin is
|
|||
-- zconf.h:216
|
||||
type Int is new Interfaces.C.int;
|
||||
|
||||
type ULong is new Interfaces.C.unsigned; -- 32 bits or more
|
||||
-- zconf.h:217
|
||||
type ULong is new Interfaces.C.unsigned_long; -- 32 bits or more
|
||||
-- zconf.h:217
|
||||
subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr;
|
||||
|
||||
type ULong_Access is access ULong;
|
||||
type Int_Access is access Int;
|
||||
|
||||
subtype Voidp is System.Address; -- zconf.h:232
|
||||
|
||||
package Bytes is new System.Address_To_Access_Conversions (Byte);
|
||||
|
||||
subtype Byte_Access is Bytes.Object_Pointer;
|
||||
subtype Byte_Access is Voidp;
|
||||
|
||||
Nul : constant Voidp := System.Null_Address;
|
||||
-- end from zconf
|
||||
|
||||
Z_NO_FLUSH : constant := 8#0000#; -- zlib.h:125
|
||||
|
@ -251,12 +252,6 @@ private package ZLib.Thin is
|
|||
stream_size : Int)
|
||||
return Int;
|
||||
|
||||
function Deflate_Init
|
||||
(strm : in Z_Streamp;
|
||||
level : in Int := Z_DEFAULT_COMPRESSION)
|
||||
return Int;
|
||||
pragma Inline (Deflate_Init);
|
||||
|
||||
function deflateInit2
|
||||
(strm : Z_Streamp;
|
||||
level : Int;
|
||||
|
@ -284,9 +279,6 @@ private package ZLib.Thin is
|
|||
stream_size : Int)
|
||||
return Int;
|
||||
|
||||
function Inflate_Init (strm : Z_Streamp) return Int;
|
||||
pragma Inline (Inflate_Init);
|
||||
|
||||
function inflateInit2
|
||||
(strm : in Z_Streamp;
|
||||
windowBits : in Int;
|
||||
|
@ -318,32 +310,12 @@ private package ZLib.Thin is
|
|||
-- has dropped to zero. The application must initialize zalloc, zfree and
|
||||
-- opaque before calling the init function.
|
||||
|
||||
function Need_In (strm : in Z_Stream) return Boolean;
|
||||
-- return true when we do not need to setup Next_In and Avail_In fields.
|
||||
pragma Inline (Need_In);
|
||||
|
||||
function Need_Out (strm : in Z_Stream) return Boolean;
|
||||
-- return true when we do not need to setup Next_Out and Avail_Out field.
|
||||
pragma Inline (Need_Out);
|
||||
|
||||
procedure Set_In
|
||||
(Strm : in out Z_Stream;
|
||||
Buffer : in Byte_Access;
|
||||
Size : in UInt);
|
||||
pragma Inline (Set_In);
|
||||
|
||||
procedure Set_In
|
||||
(Strm : in out Z_Stream;
|
||||
Buffer : in Voidp;
|
||||
Size : in UInt);
|
||||
pragma Inline (Set_In);
|
||||
|
||||
procedure Set_Out
|
||||
(Strm : in out Z_Stream;
|
||||
Buffer : in Byte_Access;
|
||||
Size : in UInt);
|
||||
pragma Inline (Set_Out);
|
||||
|
||||
procedure Set_Out
|
||||
(Strm : in out Z_Stream;
|
||||
Buffer : in Voidp;
|
||||
|
@ -388,19 +360,13 @@ private package ZLib.Thin is
|
|||
|
||||
function zlibCompileFlags return ULong;
|
||||
|
||||
function deflatePrime
|
||||
(strm : Z_Streamp;
|
||||
bits : Int;
|
||||
value : Int)
|
||||
return Int;
|
||||
|
||||
private
|
||||
|
||||
type Z_Stream is record -- zlib.h:68
|
||||
Next_In : Byte_Access; -- next input byte
|
||||
Next_In : Voidp := Nul; -- next input byte
|
||||
Avail_In : UInt := 0; -- number of bytes available at next_in
|
||||
Total_In : ULong := 0; -- total nb of input bytes read so far
|
||||
Next_Out : Byte_Access; -- next output byte should be put there
|
||||
Next_Out : Voidp := Nul; -- next output byte should be put there
|
||||
Avail_Out : UInt := 0; -- remaining free space at next_out
|
||||
Total_Out : ULong := 0; -- total nb of bytes output so far
|
||||
msg : Chars_Ptr; -- last error message, NULL if no error
|
||||
|
@ -460,14 +426,13 @@ private
|
|||
pragma Import (C, inflateSyncPoint, "inflateSyncPoint");
|
||||
pragma Import (C, get_crc_table, "get_crc_table");
|
||||
|
||||
-- added in zlib 1.2.1:
|
||||
-- since zlib 1.2.0:
|
||||
|
||||
pragma Import (C, inflateCopy, "inflateCopy");
|
||||
pragma Import (C, compressBound, "compressBound");
|
||||
pragma Import (C, deflateBound, "deflateBound");
|
||||
pragma Import (C, gzungetc, "gzungetc");
|
||||
pragma Import (C, zlibCompileFlags, "zlibCompileFlags");
|
||||
pragma Import (C, deflatePrime, "deflatePrime");
|
||||
|
||||
pragma Import (C, inflateBackInit, "inflateBackInit_");
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
----------------------------------------------------------------
|
||||
-- ZLib for Ada thick binding. --
|
||||
-- --
|
||||
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
|
||||
-- Copyright (C) 2002-2004 Dmitriy Anisimkov --
|
||||
-- --
|
||||
-- Open source license information is in the zlib.ads file. --
|
||||
----------------------------------------------------------------
|
||||
|
||||
-- $Id: zlib.adb,v 1.19 2003/07/13 16:02:19 vagul Exp $
|
||||
-- $Id: zlib.adb,v 1.31 2004/09/06 06:53:19 vagul Exp $
|
||||
|
||||
with Ada.Exceptions;
|
||||
with Ada.Unchecked_Conversion;
|
||||
|
@ -34,7 +34,7 @@ package body ZLib is
|
|||
VERSION_ERROR);
|
||||
|
||||
type Flate_Step_Function is access
|
||||
function (Strm : Thin.Z_Streamp; flush : Thin.Int) return Thin.Int;
|
||||
function (Strm : in Thin.Z_Streamp; Flush : in Thin.Int) return Thin.Int;
|
||||
pragma Convention (C, Flate_Step_Function);
|
||||
|
||||
type Flate_End_Function is access
|
||||
|
@ -82,13 +82,13 @@ package body ZLib is
|
|||
Flush_Finish : constant array (Boolean) of Flush_Mode
|
||||
:= (True => Finish, False => No_Flush);
|
||||
|
||||
procedure Raise_Error (Stream : Z_Stream);
|
||||
procedure Raise_Error (Stream : in Z_Stream);
|
||||
pragma Inline (Raise_Error);
|
||||
|
||||
procedure Raise_Error (Message : String);
|
||||
procedure Raise_Error (Message : in String);
|
||||
pragma Inline (Raise_Error);
|
||||
|
||||
procedure Check_Error (Stream : Z_Stream; Code : Thin.Int);
|
||||
procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int);
|
||||
|
||||
procedure Free is new Ada.Unchecked_Deallocation
|
||||
(Z_Stream, Z_Stream_Access);
|
||||
|
@ -118,7 +118,7 @@ package body ZLib is
|
|||
-- Check_Error --
|
||||
-----------------
|
||||
|
||||
procedure Check_Error (Stream : Z_Stream; Code : Thin.Int) is
|
||||
procedure Check_Error (Stream : in Z_Stream; Code : in Thin.Int) is
|
||||
use type Thin.Int;
|
||||
begin
|
||||
if Code /= Thin.Z_OK then
|
||||
|
@ -138,10 +138,11 @@ package body ZLib is
|
|||
is
|
||||
Code : Thin.Int;
|
||||
begin
|
||||
Code := Flate (Filter.Compression).Done
|
||||
(To_Thin_Access (Filter.Strm));
|
||||
if not Ignore_Error and then not Is_Open (Filter) then
|
||||
raise Status_Error;
|
||||
end if;
|
||||
|
||||
Filter.Opened := False;
|
||||
Code := Flate (Filter.Compression).Done (To_Thin_Access (Filter.Strm));
|
||||
|
||||
if Ignore_Error or else Code = Thin.Z_OK then
|
||||
Free (Filter.Strm);
|
||||
|
@ -154,7 +155,7 @@ package body ZLib is
|
|||
Ada.Exceptions.Raise_Exception
|
||||
(ZLib_Error'Identity,
|
||||
Return_Code_Enum'Image (Return_Code (Code))
|
||||
& ": " & Error_Message);
|
||||
& ": " & Error_Message);
|
||||
end;
|
||||
end if;
|
||||
end Close;
|
||||
|
@ -170,10 +171,9 @@ package body ZLib is
|
|||
is
|
||||
use Thin;
|
||||
begin
|
||||
return Unsigned_32 (crc32
|
||||
(ULong (CRC),
|
||||
Bytes.To_Pointer (Data'Address),
|
||||
Data'Length));
|
||||
return Unsigned_32 (crc32 (ULong (CRC),
|
||||
Data'Address,
|
||||
Data'Length));
|
||||
end CRC32;
|
||||
|
||||
procedure CRC32
|
||||
|
@ -192,13 +192,17 @@ package body ZLib is
|
|||
Level : in Compression_Level := Default_Compression;
|
||||
Strategy : in Strategy_Type := Default_Strategy;
|
||||
Method : in Compression_Method := Deflated;
|
||||
Window_Bits : in Window_Bits_Type := 15;
|
||||
Memory_Level : in Memory_Level_Type := 8;
|
||||
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
|
||||
Memory_Level : in Memory_Level_Type := Default_Memory_Level;
|
||||
Header : in Header_Type := Default)
|
||||
is
|
||||
use type Thin.Int;
|
||||
Win_Bits : Thin.Int := Thin.Int (Window_Bits);
|
||||
begin
|
||||
if Is_Open (Filter) then
|
||||
raise Status_Error;
|
||||
end if;
|
||||
|
||||
-- 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
|
||||
-- header at all.
|
||||
|
@ -216,10 +220,9 @@ package body ZLib is
|
|||
Filter.Offset := Simple_GZip_Header'Last + 1;
|
||||
end if;
|
||||
|
||||
Filter.Strm := new Z_Stream;
|
||||
Filter.Strm := new Z_Stream;
|
||||
Filter.Compression := True;
|
||||
Filter.Stream_End := False;
|
||||
Filter.Opened := True;
|
||||
Filter.Header := Header;
|
||||
|
||||
if Thin.Deflate_Init
|
||||
|
@ -255,18 +258,18 @@ package body ZLib is
|
|||
-----------------------
|
||||
|
||||
procedure Generic_Translate
|
||||
(Filter : in out ZLib.Filter_Type;
|
||||
In_Buffer_Size : Integer := Default_Buffer_Size;
|
||||
Out_Buffer_Size : Integer := Default_Buffer_Size)
|
||||
(Filter : in out ZLib.Filter_Type;
|
||||
In_Buffer_Size : in Integer := Default_Buffer_Size;
|
||||
Out_Buffer_Size : in Integer := Default_Buffer_Size)
|
||||
is
|
||||
In_Buffer : Stream_Element_Array
|
||||
(1 .. Stream_Element_Offset (In_Buffer_Size));
|
||||
In_Buffer : Stream_Element_Array
|
||||
(1 .. Stream_Element_Offset (In_Buffer_Size));
|
||||
Out_Buffer : Stream_Element_Array
|
||||
(1 .. Stream_Element_Offset (Out_Buffer_Size));
|
||||
Last : Stream_Element_Offset;
|
||||
In_Last : Stream_Element_Offset;
|
||||
In_First : Stream_Element_Offset;
|
||||
Out_Last : Stream_Element_Offset;
|
||||
(1 .. Stream_Element_Offset (Out_Buffer_Size));
|
||||
Last : Stream_Element_Offset;
|
||||
In_Last : Stream_Element_Offset;
|
||||
In_First : Stream_Element_Offset;
|
||||
Out_Last : Stream_Element_Offset;
|
||||
begin
|
||||
Main : loop
|
||||
Data_In (In_Buffer, Last);
|
||||
|
@ -275,18 +278,21 @@ package body ZLib is
|
|||
|
||||
loop
|
||||
Translate
|
||||
(Filter,
|
||||
In_Buffer (In_First .. Last),
|
||||
In_Last,
|
||||
Out_Buffer,
|
||||
Out_Last,
|
||||
Flush_Finish (Last < In_Buffer'First));
|
||||
(Filter => Filter,
|
||||
In_Data => In_Buffer (In_First .. Last),
|
||||
In_Last => In_Last,
|
||||
Out_Data => Out_Buffer,
|
||||
Out_Last => Out_Last,
|
||||
Flush => Flush_Finish (Last < In_Buffer'First));
|
||||
|
||||
Data_Out (Out_Buffer (Out_Buffer'First .. Out_Last));
|
||||
if Out_Buffer'First <= Out_Last then
|
||||
Data_Out (Out_Buffer (Out_Buffer'First .. Out_Last));
|
||||
end if;
|
||||
|
||||
exit Main when Stream_End (Filter);
|
||||
|
||||
-- The end of in buffer.
|
||||
|
||||
exit when In_Last = Last;
|
||||
|
||||
In_First := In_Last + 1;
|
||||
|
@ -301,7 +307,7 @@ package body ZLib is
|
|||
|
||||
procedure Inflate_Init
|
||||
(Filter : in out Filter_Type;
|
||||
Window_Bits : in Window_Bits_Type := 15;
|
||||
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
|
||||
Header : in Header_Type := Default)
|
||||
is
|
||||
use type Thin.Int;
|
||||
|
@ -320,6 +326,10 @@ package body ZLib is
|
|||
end Check_Version;
|
||||
|
||||
begin
|
||||
if Is_Open (Filter) then
|
||||
raise Status_Error;
|
||||
end if;
|
||||
|
||||
case Header is
|
||||
when None =>
|
||||
Check_Version;
|
||||
|
@ -344,10 +354,9 @@ package body ZLib is
|
|||
when Default => null;
|
||||
end case;
|
||||
|
||||
Filter.Strm := new Z_Stream;
|
||||
Filter.Strm := new Z_Stream;
|
||||
Filter.Compression := False;
|
||||
Filter.Stream_End := False;
|
||||
Filter.Opened := True;
|
||||
Filter.Header := Header;
|
||||
|
||||
if Thin.Inflate_Init
|
||||
|
@ -357,16 +366,25 @@ package body ZLib is
|
|||
end if;
|
||||
end Inflate_Init;
|
||||
|
||||
-------------
|
||||
-- Is_Open --
|
||||
-------------
|
||||
|
||||
function Is_Open (Filter : in Filter_Type) return Boolean is
|
||||
begin
|
||||
return Filter.Strm /= null;
|
||||
end Is_Open;
|
||||
|
||||
-----------------
|
||||
-- Raise_Error --
|
||||
-----------------
|
||||
|
||||
procedure Raise_Error (Message : String) is
|
||||
procedure Raise_Error (Message : in String) is
|
||||
begin
|
||||
Ada.Exceptions.Raise_Exception (ZLib_Error'Identity, Message);
|
||||
end Raise_Error;
|
||||
|
||||
procedure Raise_Error (Stream : Z_Stream) is
|
||||
procedure Raise_Error (Stream : in Z_Stream) is
|
||||
begin
|
||||
Raise_Error (Last_Error_Message (Stream));
|
||||
end Raise_Error;
|
||||
|
@ -378,21 +396,29 @@ package body ZLib is
|
|||
procedure Read
|
||||
(Filter : in out Filter_Type;
|
||||
Item : out Ada.Streams.Stream_Element_Array;
|
||||
Last : out Ada.Streams.Stream_Element_Offset)
|
||||
Last : out Ada.Streams.Stream_Element_Offset;
|
||||
Flush : in Flush_Mode := No_Flush)
|
||||
is
|
||||
In_Last : Stream_Element_Offset;
|
||||
Item_First : Ada.Streams.Stream_Element_Offset := Item'First;
|
||||
V_Flush : Flush_Mode := Flush;
|
||||
|
||||
begin
|
||||
pragma Assert (Rest_First in Buffer'First .. Buffer'Last + 1);
|
||||
pragma Assert (Rest_Last in Buffer'First - 1 .. Buffer'Last);
|
||||
|
||||
loop
|
||||
if Rest_First > Buffer'Last then
|
||||
if Rest_Last = Buffer'First - 1 then
|
||||
V_Flush := Finish;
|
||||
|
||||
elsif Rest_First > Rest_Last then
|
||||
Read (Buffer, Rest_Last);
|
||||
Rest_First := Buffer'First;
|
||||
end if;
|
||||
|
||||
pragma Assert (Rest_Last in Buffer'First - 1 .. Buffer'Last);
|
||||
if Rest_Last < Buffer'First then
|
||||
V_Flush := Finish;
|
||||
end if;
|
||||
end if;
|
||||
|
||||
Translate
|
||||
(Filter => Filter,
|
||||
|
@ -400,11 +426,13 @@ package body ZLib is
|
|||
In_Last => In_Last,
|
||||
Out_Data => Item (Item_First .. Item'Last),
|
||||
Out_Last => Last,
|
||||
Flush => Flush_Finish (Rest_Last < Rest_First));
|
||||
Flush => V_Flush);
|
||||
|
||||
Rest_First := In_Last + 1;
|
||||
|
||||
exit when Last = Item'Last or else Stream_End (Filter);
|
||||
exit when Stream_End (Filter)
|
||||
or else Last = Item'Last
|
||||
or else (Last >= Item'First and then Allow_Read_Some);
|
||||
|
||||
Item_First := Last + 1;
|
||||
end loop;
|
||||
|
@ -489,11 +517,11 @@ package body ZLib is
|
|||
Code : Thin.Int;
|
||||
|
||||
begin
|
||||
if Filter.Opened = False then
|
||||
raise ZLib_Error;
|
||||
if not Is_Open (Filter) then
|
||||
raise Status_Error;
|
||||
end if;
|
||||
|
||||
if Out_Data'Length = 0 then
|
||||
if Out_Data'Length = 0 and then In_Data'Length = 0 then
|
||||
raise Constraint_Error;
|
||||
end if;
|
||||
|
||||
|
@ -514,7 +542,6 @@ package body ZLib is
|
|||
- Stream_Element_Offset (Avail_In (Filter.Strm.all));
|
||||
Out_Last := Out_Data'Last
|
||||
- Stream_Element_Offset (Avail_Out (Filter.Strm.all));
|
||||
|
||||
end Translate_Auto;
|
||||
|
||||
--------------------
|
||||
|
@ -529,7 +556,7 @@ package body ZLib is
|
|||
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
||||
Flush : in Flush_Mode)
|
||||
is
|
||||
Out_First : Stream_Element_Offset;
|
||||
Out_First : Stream_Element_Offset;
|
||||
|
||||
procedure Add_Data (Data : in Stream_Element_Array);
|
||||
-- Add data to stream from the Filter.Offset till necessary,
|
||||
|
@ -596,7 +623,7 @@ package body ZLib is
|
|||
Add_Data (Simple_GZip_Header);
|
||||
|
||||
Translate_Auto
|
||||
(Filter => Filter,
|
||||
(Filter => Filter,
|
||||
In_Data => In_Data,
|
||||
In_Last => In_Last,
|
||||
Out_Data => Out_Data (Out_First .. Out_Data'Last),
|
||||
|
@ -604,7 +631,6 @@ package body ZLib is
|
|||
Flush => Flush);
|
||||
|
||||
CRC32 (Filter.CRC, In_Data (In_Data'First .. In_Last));
|
||||
|
||||
end if;
|
||||
|
||||
if Filter.Stream_End and then Out_Last <= Out_Data'Last then
|
||||
|
@ -642,10 +668,11 @@ package body ZLib is
|
|||
procedure Write
|
||||
(Filter : in out Filter_Type;
|
||||
Item : in Ada.Streams.Stream_Element_Array;
|
||||
Flush : in Flush_Mode)
|
||||
Flush : in Flush_Mode := No_Flush)
|
||||
is
|
||||
Buffer : Stream_Element_Array (1 .. Buffer_Size);
|
||||
In_Last, Out_Last : Stream_Element_Offset;
|
||||
Buffer : Stream_Element_Array (1 .. Buffer_Size);
|
||||
In_Last : Stream_Element_Offset;
|
||||
Out_Last : Stream_Element_Offset;
|
||||
In_First : Stream_Element_Offset := Item'First;
|
||||
begin
|
||||
if Item'Length = 0 and Flush = No_Flush then
|
||||
|
@ -654,7 +681,7 @@ package body ZLib is
|
|||
|
||||
loop
|
||||
Translate
|
||||
(Filter => Filter,
|
||||
(Filter => Filter,
|
||||
In_Data => Item (In_First .. Item'Last),
|
||||
In_Last => In_Last,
|
||||
Out_Data => Buffer,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
------------------------------------------------------------------------------
|
||||
-- ZLib for Ada thick binding. --
|
||||
-- --
|
||||
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
|
||||
-- Copyright (C) 2002-2004 Dmitriy Anisimkov --
|
||||
-- --
|
||||
-- This library is free software; you can redistribute it and/or modify --
|
||||
-- it under the terms of the GNU General Public License as published by --
|
||||
|
@ -25,7 +25,7 @@
|
|||
-- covered by the GNU Public License. --
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
-- $Id: zlib.ads,v 1.17 2003/08/12 13:19:07 vagul Exp $
|
||||
-- $Id: zlib.ads,v 1.26 2004/09/06 06:53:19 vagul Exp $
|
||||
|
||||
with Ada.Streams;
|
||||
|
||||
|
@ -33,7 +33,8 @@ with Interfaces;
|
|||
|
||||
package ZLib is
|
||||
|
||||
ZLib_Error : exception;
|
||||
ZLib_Error : exception;
|
||||
Status_Error : exception;
|
||||
|
||||
type Compression_Level is new Integer range -1 .. 9;
|
||||
|
||||
|
@ -55,12 +56,15 @@ package ZLib is
|
|||
|
||||
subtype Count is Ada.Streams.Stream_Element_Count;
|
||||
|
||||
Default_Memory_Level : constant Memory_Level_Type := 8;
|
||||
Default_Window_Bits : constant Window_Bits_Type := 15;
|
||||
|
||||
----------------------------------
|
||||
-- Compression method constants --
|
||||
----------------------------------
|
||||
|
||||
Deflated : constant Compression_Method;
|
||||
-- Only one method allowed in this ZLib version.
|
||||
-- Only one method allowed in this ZLib version
|
||||
|
||||
---------------------------------
|
||||
-- Compression level constants --
|
||||
|
@ -79,21 +83,29 @@ package ZLib is
|
|||
-- Regular way for compression, no flush
|
||||
|
||||
Partial_Flush : constant Flush_Mode;
|
||||
-- will be removed, use Z_SYNC_FLUSH instead
|
||||
-- Will be removed, use Z_SYNC_FLUSH instead
|
||||
|
||||
Sync_Flush : constant Flush_Mode;
|
||||
-- all pending output is flushed to the output buffer and the output
|
||||
-- All pending output is flushed to the output buffer and the output
|
||||
-- is aligned on a byte boundary, so that the decompressor can get all
|
||||
-- input data available so far. (In particular avail_in is zero after the
|
||||
-- call if enough output space has been provided before the call.)
|
||||
-- Flushing may degrade compression for some compression algorithms and so
|
||||
-- it should be used only when necessary.
|
||||
|
||||
Block_Flush : constant Flush_Mode;
|
||||
-- Z_BLOCK requests that inflate() stop
|
||||
-- if and when it get to the next deflate block boundary. When decoding the
|
||||
-- zlib or gzip format, this will cause inflate() to return immediately
|
||||
-- after the header and before the first block. When doing a raw inflate,
|
||||
-- inflate() will go ahead and process the first block, and will return
|
||||
-- when it gets to the end of that block, or when it runs out of data.
|
||||
|
||||
Full_Flush : constant Flush_Mode;
|
||||
-- all output is flushed as with SYNC_FLUSH, and the compression state
|
||||
-- All output is flushed as with SYNC_FLUSH, and the compression state
|
||||
-- is reset so that decompression can restart from this point if previous
|
||||
-- compressed data has been damaged or if random access is desired. Using
|
||||
-- FULL_FLUSH too often can seriously degrade the compression.
|
||||
-- Full_Flush too often can seriously degrade the compression.
|
||||
|
||||
Finish : constant Flush_Mode;
|
||||
-- Just for tell the compressor that input data is complete.
|
||||
|
@ -111,7 +123,7 @@ package ZLib is
|
|||
|
||||
Default_Buffer_Size : constant := 4096;
|
||||
|
||||
type Filter_Type is limited private;
|
||||
type Filter_Type is tagged limited private;
|
||||
-- The filter is for compression and for decompression.
|
||||
-- The usage of the type is depend of its initialization.
|
||||
|
||||
|
@ -124,8 +136,8 @@ package ZLib is
|
|||
Level : in Compression_Level := Default_Compression;
|
||||
Strategy : in Strategy_Type := Default_Strategy;
|
||||
Method : in Compression_Method := Deflated;
|
||||
Window_Bits : in Window_Bits_Type := 15;
|
||||
Memory_Level : in Memory_Level_Type := 8;
|
||||
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
|
||||
Memory_Level : in Memory_Level_Type := Default_Memory_Level;
|
||||
Header : in Header_Type := Default);
|
||||
-- Compressor initialization.
|
||||
-- When Header parameter is Auto or Default, then default zlib header
|
||||
|
@ -136,7 +148,7 @@ package ZLib is
|
|||
|
||||
procedure Inflate_Init
|
||||
(Filter : in out Filter_Type;
|
||||
Window_Bits : in Window_Bits_Type := 15;
|
||||
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
|
||||
Header : in Header_Type := Default);
|
||||
-- Decompressor initialization.
|
||||
-- Default header type mean that ZLib default header is expecting in the
|
||||
|
@ -146,10 +158,14 @@ package ZLib is
|
|||
-- input compressed stream.
|
||||
-- Auto header type mean that header type (GZip or Native) would be
|
||||
-- detected automatically in the input stream.
|
||||
-- Note that header types parameter values None, GZip and Auto is
|
||||
-- supporting for inflate routine only in ZLib versions 1.2.0.2 and later.
|
||||
-- Note that header types parameter values None, GZip and Auto are
|
||||
-- supported for inflate routine only in ZLib versions 1.2.0.2 and later.
|
||||
-- Deflate_Init is supporting all header types.
|
||||
|
||||
function Is_Open (Filter : in Filter_Type) return Boolean;
|
||||
pragma Inline (Is_Open);
|
||||
-- Is the filter opened for compression or decompression.
|
||||
|
||||
procedure Close
|
||||
(Filter : in out Filter_Type;
|
||||
Ignore_Error : in Boolean := False);
|
||||
|
@ -167,31 +183,31 @@ package ZLib is
|
|||
(Filter : in out Filter_Type;
|
||||
In_Buffer_Size : in Integer := Default_Buffer_Size;
|
||||
Out_Buffer_Size : in Integer := Default_Buffer_Size);
|
||||
-- Compressing/decompressing data arrived from Data_In routine
|
||||
-- Compress/decompress data fetch from Data_In routine and pass the result
|
||||
-- to the Data_Out routine. User should provide Data_In and Data_Out
|
||||
-- for compression/decompression data flow.
|
||||
-- Compression or decompression depend on initialization of Filter.
|
||||
-- Compression or decompression depend on Filter initialization.
|
||||
|
||||
function Total_In (Filter : in Filter_Type) return Count;
|
||||
pragma Inline (Total_In);
|
||||
-- Return total number of input bytes read so far.
|
||||
-- Returns total number of input bytes read so far
|
||||
|
||||
function Total_Out (Filter : in Filter_Type) return Count;
|
||||
pragma Inline (Total_Out);
|
||||
-- Return total number of bytes output so far.
|
||||
-- Returns total number of bytes output so far
|
||||
|
||||
function CRC32
|
||||
(CRC : in Unsigned_32;
|
||||
Data : in Ada.Streams.Stream_Element_Array)
|
||||
return Unsigned_32;
|
||||
pragma Inline (CRC32);
|
||||
-- Calculate CRC32, it could be necessary for make gzip format.
|
||||
-- Compute CRC32, it could be necessary for make gzip format
|
||||
|
||||
procedure CRC32
|
||||
(CRC : in out Unsigned_32;
|
||||
Data : in Ada.Streams.Stream_Element_Array);
|
||||
pragma Inline (CRC32);
|
||||
-- Calculate CRC32, it could be necessary for make gzip format.
|
||||
-- Compute CRC32, it could be necessary for make gzip format
|
||||
|
||||
-------------------------------------------------
|
||||
-- Below is more complex low level routines. --
|
||||
|
@ -204,15 +220,11 @@ package ZLib is
|
|||
Out_Data : out Ada.Streams.Stream_Element_Array;
|
||||
Out_Last : out Ada.Streams.Stream_Element_Offset;
|
||||
Flush : in Flush_Mode);
|
||||
-- Compressing/decompressing the datas from In_Data buffer to the
|
||||
-- Out_Data buffer.
|
||||
-- In_Data is incoming data portion,
|
||||
-- In_Last is the index of last element from In_Data accepted by the
|
||||
-- Filter.
|
||||
-- Out_Data is the buffer for output data from the filter.
|
||||
-- Out_Last is the last element of the received data from Filter.
|
||||
-- To tell the filter that incoming data is complete put the
|
||||
-- Flush parameter to FINISH.
|
||||
-- Compress/decompress the In_Data buffer and place the result into
|
||||
-- Out_Data. In_Last is the index of last element from In_Data accepted by
|
||||
-- the Filter. Out_Last is the last element of the received data from
|
||||
-- Filter. To tell the filter that incoming data are complete put the
|
||||
-- Flush parameter to Finish.
|
||||
|
||||
function Stream_End (Filter : in Filter_Type) return Boolean;
|
||||
pragma Inline (Stream_End);
|
||||
|
@ -239,10 +251,9 @@ package ZLib is
|
|||
procedure Write
|
||||
(Filter : in out Filter_Type;
|
||||
Item : in Ada.Streams.Stream_Element_Array;
|
||||
Flush : in Flush_Mode);
|
||||
-- Compressing/Decompressing data from Item to the
|
||||
-- generic parameter procedure Write.
|
||||
-- Output buffer size could be set in Buffer_Size generic parameter.
|
||||
Flush : in Flush_Mode := No_Flush);
|
||||
-- Compress/Decompress data from Item to the generic parameter procedure
|
||||
-- Write. Output buffer size could be set in Buffer_Size generic parameter.
|
||||
|
||||
generic
|
||||
with procedure Read
|
||||
|
@ -257,33 +268,41 @@ package ZLib is
|
|||
|
||||
Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset;
|
||||
-- Rest_First have to be initialized to Buffer'Last + 1
|
||||
-- Rest_Last have to be initialized to Buffer'Last
|
||||
-- before usage.
|
||||
|
||||
Allow_Read_Some : in Boolean := False;
|
||||
-- Is it allowed to return Last < Item'Last before end of data.
|
||||
|
||||
procedure Read
|
||||
(Filter : in out Filter_Type;
|
||||
Item : out Ada.Streams.Stream_Element_Array;
|
||||
Last : out Ada.Streams.Stream_Element_Offset);
|
||||
-- Compressing/Decompressing data from generic parameter
|
||||
-- procedure Read to the Item.
|
||||
-- User should provide Buffer for the operation
|
||||
-- and Rest_First variable first time initialized to the Buffer'Last + 1.
|
||||
Last : out Ada.Streams.Stream_Element_Offset;
|
||||
Flush : in Flush_Mode := No_Flush);
|
||||
-- Compress/Decompress data from generic parameter procedure Read to the
|
||||
-- Item. User should provide Buffer and initialized Rest_First, Rest_Last
|
||||
-- indicators. If Allow_Read_Some is True, Read routines could return
|
||||
-- Last < Item'Last only at end of stream.
|
||||
|
||||
private
|
||||
|
||||
use Ada.Streams;
|
||||
|
||||
type Flush_Mode is new Integer range 0 .. 4;
|
||||
pragma Assert (Ada.Streams.Stream_Element'Size = 8);
|
||||
pragma Assert (Ada.Streams.Stream_Element'Modulus = 2**8);
|
||||
|
||||
type Flush_Mode is new Integer range 0 .. 5;
|
||||
|
||||
type Compression_Method is new Integer range 8 .. 8;
|
||||
|
||||
type Strategy_Type is new Integer range 0 .. 3;
|
||||
|
||||
No_Flush : constant Flush_Mode := 0;
|
||||
Partial_Flush : constant Flush_Mode := 1;
|
||||
Sync_Flush : constant Flush_Mode := 2;
|
||||
Full_Flush : constant Flush_Mode := 3;
|
||||
Finish : constant Flush_Mode := 4;
|
||||
Partial_Flush : constant Flush_Mode := 1;
|
||||
-- will be removed, use Z_SYNC_FLUSH instead
|
||||
Block_Flush : constant Flush_Mode := 5;
|
||||
|
||||
Filtered : constant Strategy_Type := 1;
|
||||
Huffman_Only : constant Strategy_Type := 2;
|
||||
|
@ -296,7 +315,7 @@ private
|
|||
|
||||
type Z_Stream_Access is access all Z_Stream;
|
||||
|
||||
type Filter_Type is record
|
||||
type Filter_Type is tagged limited record
|
||||
Strm : Z_Stream_Access;
|
||||
Compression : Boolean;
|
||||
Stream_End : Boolean;
|
||||
|
@ -304,8 +323,6 @@ private
|
|||
CRC : Unsigned_32;
|
||||
Offset : Stream_Element_Offset;
|
||||
-- Offset for gzip header/footer output.
|
||||
|
||||
Opened : Boolean := False;
|
||||
end record;
|
||||
|
||||
end ZLib;
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
project Zlib is
|
||||
|
||||
for Languages use ("Ada");
|
||||
for Source_Dirs use (".");
|
||||
for Object_Dir use ".";
|
||||
for Main use ("test.adb", "mtest.adb", "read.adb");
|
||||
|
||||
package Compiler is
|
||||
for Default_Switches ("ada") use ("-gnatwbcfilopru", "-gnatVcdfimorst", "-gnatyabcefhiklmnoprst");
|
||||
end Compiler;
|
||||
|
||||
package Linker is
|
||||
for Default_Switches ("ada") use ("-lz");
|
||||
end Linker;
|
||||
|
||||
package Builder is
|
||||
for Default_Switches ("ada") use ("-s", "-gnatQ");
|
||||
end Builder;
|
||||
|
||||
end Zlib;
|
||||
|
||||
project Zlib is
|
||||
|
||||
for Languages use ("Ada");
|
||||
for Source_Dirs use (".");
|
||||
for Object_Dir use ".";
|
||||
for Main use ("test.adb", "mtest.adb", "read.adb", "buffer_demo");
|
||||
|
||||
package Compiler is
|
||||
for Default_Switches ("ada") use ("-gnatwcfilopru", "-gnatVcdfimorst", "-gnatyabcefhiklmnoprst");
|
||||
end Compiler;
|
||||
|
||||
package Linker is
|
||||
for Default_Switches ("ada") use ("-lz");
|
||||
end Linker;
|
||||
|
||||
package Builder is
|
||||
for Default_Switches ("ada") use ("-s", "-gnatQ");
|
||||
end Builder;
|
||||
|
||||
end Zlib;
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
|
|||
const OutBuf: Pointer; BufSize: Integer);
|
||||
|
||||
const
|
||||
zlib_version = '1.2.1';
|
||||
zlib_version = '1.2.2';
|
||||
|
||||
type
|
||||
EZlibError = class(Exception);
|
||||
|
@ -510,7 +510,7 @@ begin
|
|||
Result := Count - FZRec.avail_out;
|
||||
Exit;
|
||||
end;
|
||||
FZRec.next_in := FBuffer;
|
||||
FZRec.next_in := FBuffer;
|
||||
FStrmPos := FStrm.Position;
|
||||
Progress(Self);
|
||||
end;
|
||||
|
|
|
@ -430,6 +430,9 @@ void FAR *out_desc;
|
|||
}
|
||||
}
|
||||
|
||||
/* handle error breaks in while */
|
||||
if (mode == BAD) break;
|
||||
|
||||
/* build code tables */
|
||||
state->next = state->codes;
|
||||
lencode = (code const FAR *)(state->next);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#define MAXBITS 15
|
||||
|
||||
const char inflate9_copyright[] =
|
||||
" inflate9 1.2.1.1 Copyright 1995-2003 Mark Adler ";
|
||||
" inflate9 1.2.1.2 Copyright 1995-2004 Mark Adler ";
|
||||
/*
|
||||
If you use the zlib library in a product, an acknowledgment is welcome
|
||||
in the documentation of your product. If for some reason you cannot
|
||||
|
@ -64,7 +64,7 @@ unsigned short FAR *work;
|
|||
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
||||
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
|
||||
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
|
||||
133, 133, 133, 133, 144, 202, 196};
|
||||
133, 133, 133, 133, 144, 77, 194};
|
||||
static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
|
||||
65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
cl /I..\.. /O2 /c gvmat32c.c
|
||||
cl /DASMV /I..\.. /O2 /c gvmat32c.c
|
||||
ml /coff /Zi /c /Flgvmat32.lst gvmat32.asm
|
||||
ml /coff /Zi /c /Flinffas32.lst inffas32.asm
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
Change in 1.01b (20 may 04)
|
||||
- Integrate patch from Debian package (submited by Mark Brown)
|
||||
- Add tools mztools from Xavier Roche
|
||||
|
||||
Change in 1.01 (8 may 04)
|
||||
- fix buffer overrun risk in unzip.c (Xavier Roche)
|
||||
- fix a minor buffer insecurity in minizip.c (Mike Whittaker)
|
||||
|
||||
Change in 1.00: (10 sept 03)
|
||||
- rename to 1.00
|
||||
- cosmetic code change
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* crypt.h -- base code for crypt/uncrypt ZIPfile
|
||||
|
||||
|
||||
Version 1.00, September 10th, 2003
|
||||
Version 1.01, May 8th, 2004
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
Copyright (C) 1998-2004 Gilles Vollant
|
||||
|
||||
This code is a modified version of crypting code in Infozip distribution
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* ioapi.c -- IO base function header for compress/uncompress .zip
|
||||
files using zlib + zip or unzip API
|
||||
|
||||
Version 1.00, September 10th, 2003
|
||||
Version 1.01, May 8th, 2004
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
Copyright (C) 1998-2004 Gilles Vollant
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* ioapi.h -- IO base function header for compress/uncompress .zip
|
||||
files using zlib + zip or unzip API
|
||||
|
||||
Version 1.00, September 10th, 2003
|
||||
Version 1.01, May 8th, 2004
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
Copyright (C) 1998-2004 Gilles Vollant
|
||||
*/
|
||||
|
||||
#ifndef _ZLIBIOAPI_H
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
files using zlib + zip or unzip API
|
||||
This IO API version uses the Win32 API (for Microsoft Windows)
|
||||
|
||||
Version 1.00, September 10th, 2003
|
||||
Version 1.01, May 8th, 2004
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
Copyright (C) 1998-2004 Gilles Vollant
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
files using zlib + zip or unzip API
|
||||
This IO API version uses the Win32 API (for Microsoft Windows)
|
||||
|
||||
Version 1.00, September 10th, 2003
|
||||
Version 1.01, May 8th, 2004
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
Copyright (C) 1998-2004 Gilles Vollant
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
/*
|
||||
miniunz.c
|
||||
Version 1.01b, May 30th, 2004
|
||||
|
||||
Copyright (C) 1998-2004 Gilles Vollant
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -27,7 +35,7 @@
|
|||
mini unzip, demo of unzip package
|
||||
|
||||
usage :
|
||||
Usage : miniunz [-exvlo] file.zip [file_to_extract]
|
||||
Usage : miniunz [-exvlo] file.zip [file_to_extract] [-d extractdir]
|
||||
|
||||
list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT
|
||||
if it exists
|
||||
|
@ -140,17 +148,18 @@ int makedir (newdir)
|
|||
|
||||
void do_banner()
|
||||
{
|
||||
printf("MiniUnz 1.00, 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");
|
||||
}
|
||||
|
||||
void do_help()
|
||||
{
|
||||
printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.]\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" \
|
||||
" -x Extract with pathname\n" \
|
||||
" -v list files\n" \
|
||||
" -l list files\n" \
|
||||
" -d directory to extract into\n" \
|
||||
" -o overwrite files without prompting\n" \
|
||||
" -p extract crypted file using password\n\n");
|
||||
}
|
||||
|
@ -304,8 +313,14 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
|||
do
|
||||
{
|
||||
char answer[128];
|
||||
printf("The file %s exist. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename);
|
||||
scanf("%1s",answer);
|
||||
int ret;
|
||||
|
||||
printf("The file %s exists. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename);
|
||||
ret = scanf("%1s",answer);
|
||||
if (ret != 1)
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
rep = answer[0] ;
|
||||
if ((rep>='a') && (rep<='z'))
|
||||
rep -= 0x20;
|
||||
|
@ -459,6 +474,8 @@ int main(argc,argv)
|
|||
int opt_do_extract=1;
|
||||
int opt_do_extract_withoutpath=0;
|
||||
int opt_overwrite=0;
|
||||
int opt_extractdir=0;
|
||||
const char *dirname=NULL;
|
||||
unzFile uf=NULL;
|
||||
|
||||
do_banner();
|
||||
|
@ -488,6 +505,12 @@ int main(argc,argv)
|
|||
opt_do_extract = opt_do_extract_withoutpath = 1;
|
||||
if ((c=='o') || (c=='O'))
|
||||
opt_overwrite=1;
|
||||
if ((c=='d') || (c=='D'))
|
||||
{
|
||||
opt_extractdir=1;
|
||||
dirname=argv[i+1];
|
||||
}
|
||||
|
||||
if (((c=='p') || (c=='P')) && (i+1<argc))
|
||||
{
|
||||
password=argv[i+1];
|
||||
|
@ -499,7 +522,7 @@ int main(argc,argv)
|
|||
{
|
||||
if (zipfilename == NULL)
|
||||
zipfilename = argv[i];
|
||||
else if (filename_to_extract==NULL)
|
||||
else if ((filename_to_extract==NULL) && (!opt_extractdir))
|
||||
filename_to_extract = argv[i] ;
|
||||
}
|
||||
}
|
||||
|
@ -544,6 +567,12 @@ int main(argc,argv)
|
|||
return do_list(uf);
|
||||
else if (opt_do_extract==1)
|
||||
{
|
||||
if (opt_extractdir && chdir(dirname))
|
||||
{
|
||||
printf("Error changing into %s, aborting\n", dirname);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (filename_to_extract == NULL)
|
||||
return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,password);
|
||||
else
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/*
|
||||
minizip.c
|
||||
Version 1.01b, May 30th, 2004
|
||||
|
||||
Copyright (C) 1998-2004 Gilles Vollant
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -53,8 +60,8 @@ uLong filetime(f, tmzip, dt)
|
|||
#else
|
||||
#ifdef unix
|
||||
uLong filetime(f, tmzip, dt)
|
||||
char *f; /* name of file to get info on */
|
||||
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
||||
char *f; /* name of file to get info on */
|
||||
tm_zip *tmzip; /* return value: access, modific. and creation times */
|
||||
uLong *dt; /* dostime */
|
||||
{
|
||||
int ret=0;
|
||||
|
@ -66,6 +73,8 @@ uLong filetime(f, tmzip, dt)
|
|||
{
|
||||
char name[MAXFILENAME+1];
|
||||
int len = strlen(f);
|
||||
if (len > MAXFILENAME)
|
||||
len = MAXFILENAME;
|
||||
|
||||
strncpy(name, f,MAXFILENAME-1);
|
||||
/* strncpy doesnt append the trailing NULL, of the string is too long. */
|
||||
|
@ -120,7 +129,7 @@ int check_exist_file(filename)
|
|||
|
||||
void do_banner()
|
||||
{
|
||||
printf("MiniZip 1.00, demo of zLib + Zip package written by Gilles Vollant\n");
|
||||
printf("MiniZip 1.01b, demo of zLib + Zip package written by Gilles Vollant\n");
|
||||
printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
|
||||
}
|
||||
|
||||
|
@ -269,8 +278,13 @@ int main(argc,argv)
|
|||
do
|
||||
{
|
||||
char answer[128];
|
||||
printf("The file %s exist. Overwrite ? [y]es, [n]o, [a]ppend : ",filename_try);
|
||||
scanf("%1s",answer);
|
||||
int ret;
|
||||
printf("The file %s exists. Overwrite ? [y]es, [n]o, [a]ppend : ",filename_try);
|
||||
ret = scanf("%1s",answer);
|
||||
if (ret != 1)
|
||||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
rep = answer[0] ;
|
||||
if ((rep>='a') && (rep<='z'))
|
||||
rep -= 0x20;
|
||||
|
@ -305,7 +319,12 @@ int main(argc,argv)
|
|||
|
||||
for (i=zipfilenamearg+1;(i<argc) && (err==ZIP_OK);i++)
|
||||
{
|
||||
if (((*(argv[i]))!='-') && ((*(argv[i]))!='/'))
|
||||
if (!((((*(argv[i]))=='-') || ((*(argv[i]))=='/')) &&
|
||||
((argv[i][1]=='o') || (argv[i][1]=='O') ||
|
||||
(argv[i][1]=='a') || (argv[i][1]=='A') ||
|
||||
(argv[i][1]=='p') || (argv[i][1]=='P') ||
|
||||
((argv[i][1]>='0') || (argv[i][1]<='9'))) &&
|
||||
(strlen(argv[i]) == 2)))
|
||||
{
|
||||
FILE * fin;
|
||||
int size_read;
|
||||
|
@ -390,7 +409,11 @@ int main(argc,argv)
|
|||
errclose = zipClose(zf,NULL);
|
||||
if (errclose != ZIP_OK)
|
||||
printf("error in closing %s\n",filename_try);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
do_help();
|
||||
}
|
||||
|
||||
free(buf);
|
||||
return 0;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* unzip.c -- IO for uncompress .zip files using zlib
|
||||
Version 1.00, September 10th, 2003
|
||||
Version 1.01c, August 23th, 2004
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
Copyright (C) 1998-2004 Gilles Vollant
|
||||
|
||||
Read unzip.h for more info
|
||||
*/
|
||||
|
@ -88,7 +88,7 @@ woven in by Terry Thorsen 1/2003.
|
|||
|
||||
|
||||
const char unz_copyright[] =
|
||||
" unzip 1.00 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll";
|
||||
" unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
|
||||
|
||||
/* unz_file_info_interntal contain internal info about a file in zipfile*/
|
||||
typedef struct unz_file_info_internal_s
|
||||
|
@ -798,7 +798,8 @@ extern int ZEXPORT unzGoToNextFile (file)
|
|||
s=(unz_s*)file;
|
||||
if (!s->current_file_ok)
|
||||
return UNZ_END_OF_LIST_OF_FILE;
|
||||
if (s->num_file+1==s->gi.number_entry)
|
||||
if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */
|
||||
if (s->num_file+1==s->gi.number_entry)
|
||||
return UNZ_END_OF_LIST_OF_FILE;
|
||||
|
||||
s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename +
|
||||
|
@ -1244,9 +1245,15 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
|
|||
|
||||
pfile_in_zip_read_info->stream.avail_out = (uInt)len;
|
||||
|
||||
if (len>pfile_in_zip_read_info->rest_read_uncompressed)
|
||||
if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
|
||||
(!(pfile_in_zip_read_info->raw)))
|
||||
pfile_in_zip_read_info->stream.avail_out =
|
||||
(uInt)pfile_in_zip_read_info->rest_read_uncompressed;
|
||||
(uInt)pfile_in_zip_read_info->rest_read_uncompressed;
|
||||
|
||||
if ((len>pfile_in_zip_read_info->rest_read_compressed) &&
|
||||
(pfile_in_zip_read_info->raw))
|
||||
pfile_in_zip_read_info->stream.avail_out =
|
||||
(uInt)pfile_in_zip_read_info->rest_read_compressed;
|
||||
|
||||
while (pfile_in_zip_read_info->stream.avail_out>0)
|
||||
{
|
||||
|
@ -1339,6 +1346,9 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
|
|||
*/
|
||||
err=inflate(&pfile_in_zip_read_info->stream,flush);
|
||||
|
||||
if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL))
|
||||
err = Z_DATA_ERROR;
|
||||
|
||||
uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
|
||||
uOutThis = uTotalOutAfter-uTotalOutBefore;
|
||||
|
||||
|
@ -1461,7 +1471,7 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
|
|||
|
||||
if (ZREAD(pfile_in_zip_read_info->z_filefunc,
|
||||
pfile_in_zip_read_info->filestream,
|
||||
buf,size_to_read)!=size_to_read)
|
||||
buf,read_now)!=read_now)
|
||||
return UNZ_ERRNO;
|
||||
|
||||
return (int)read_now;
|
||||
|
@ -1544,3 +1554,40 @@ extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
|
|||
*(szComment+s->gi.size_comment)='\0';
|
||||
return (int)uReadThis;
|
||||
}
|
||||
|
||||
/* Additions by RX '2004 */
|
||||
extern uLong ZEXPORT unzGetOffset (file)
|
||||
unzFile file;
|
||||
{
|
||||
unz_s* s;
|
||||
|
||||
if (file==NULL)
|
||||
return UNZ_PARAMERROR;
|
||||
s=(unz_s*)file;
|
||||
if (!s->current_file_ok)
|
||||
return 0;
|
||||
if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff)
|
||||
if (s->num_file==s->gi.number_entry)
|
||||
return 0;
|
||||
return s->pos_in_central_dir;
|
||||
}
|
||||
|
||||
extern int ZEXPORT unzSetOffset (file, pos)
|
||||
unzFile file;
|
||||
uLong pos;
|
||||
{
|
||||
unz_s* s;
|
||||
int err;
|
||||
|
||||
if (file==NULL)
|
||||
return UNZ_PARAMERROR;
|
||||
s=(unz_s*)file;
|
||||
|
||||
s->pos_in_central_dir = pos;
|
||||
s->num_file = s->gi.number_entry; /* hack */
|
||||
err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info,
|
||||
&s->cur_file_info_internal,
|
||||
NULL,0,NULL,0,NULL,0);
|
||||
s->current_file_ok = (err == UNZ_OK);
|
||||
return err;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* unzip.h -- IO for uncompress .zip files using zlib
|
||||
Version 1.00, September 10th, 2003
|
||||
Version 1.01, May 8th, 2004
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
Copyright (C) 1998-2004 Gilles Vollant
|
||||
|
||||
This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
|
@ -335,6 +335,16 @@ extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
|
|||
the error code
|
||||
*/
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* Get the current file offset */
|
||||
extern uLong ZEXPORT unzGetOffset (unzFile file);
|
||||
|
||||
/* Set the current file offset */
|
||||
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* zip.c -- IO on .zip files using zlib
|
||||
Version 1.00, September 10th, 2003
|
||||
Version 1.01, May 8th, 2004
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
Copyright (C) 1998-2004 Gilles Vollant
|
||||
|
||||
Read zip.h for more info
|
||||
*/
|
||||
|
@ -77,7 +77,7 @@
|
|||
#endif
|
||||
#endif
|
||||
const char zip_copyright[] =
|
||||
" zip 1.00 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll";
|
||||
" zip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll";
|
||||
|
||||
|
||||
#define SIZEDATA_INDATABLOCK (4096-(4*4))
|
||||
|
@ -265,10 +265,19 @@ local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte)
|
|||
{
|
||||
unsigned char buf[4];
|
||||
int n;
|
||||
for (n = 0; n < nbByte; n++) {
|
||||
for (n = 0; n < nbByte; n++)
|
||||
{
|
||||
buf[n] = (unsigned char)(x & 0xff);
|
||||
x >>= 8;
|
||||
}
|
||||
if (x != 0)
|
||||
{ /* data overflow - hack for ZIP64 (X Roche) */
|
||||
for (n = 0; n < nbByte; n++)
|
||||
{
|
||||
buf[n] = 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
if (ZWRITE(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte)
|
||||
return ZIP_ERRNO;
|
||||
else
|
||||
|
@ -287,7 +296,16 @@ local void ziplocal_putValue_inmemory (dest, x, nbByte)
|
|||
buf[n] = (unsigned char)(x & 0xff);
|
||||
x >>= 8;
|
||||
}
|
||||
|
||||
if (x != 0)
|
||||
{ /* data overflow - hack for ZIP64 */
|
||||
for (n = 0; n < nbByte; n++)
|
||||
{
|
||||
buf[n] = 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* zip.h -- IO for compress .zip files using zlib
|
||||
Version 1.00, September 10th, 2003
|
||||
Version 1.01, May 8th, 2004
|
||||
|
||||
Copyright (C) 1998-2003 Gilles Vollant
|
||||
Copyright (C) 1998-2004 Gilles Vollant
|
||||
|
||||
This unzip package allow creates .ZIP file, compatible with PKZip 2.04g
|
||||
WinZip, InfoZip tools and compatible.
|
||||
|
@ -212,7 +212,6 @@ extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
|
|||
Close the current file in the zipfile
|
||||
*/
|
||||
|
||||
|
||||
extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
|
||||
uLong uncompressed_size,
|
||||
uLong crc32));
|
||||
|
|
|
@ -10,7 +10,7 @@ unit zlibpas;
|
|||
interface
|
||||
|
||||
const
|
||||
ZLIB_VERSION = '1.2.1';
|
||||
ZLIB_VERSION = '1.2.2';
|
||||
|
||||
type
|
||||
alloc_func = function(opaque: Pointer; items, size: Integer): Pointer;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* untgz.c -- Display contents and extract files from a gzip'd TAR file
|
||||
*
|
||||
* written by "Pedro A. Aranda Guti\irrez" <paag@tid.es>
|
||||
* written by Pedro A. Aranda Gutierrez <paag@tid.es>
|
||||
* adaptation to Unix by Jean-loup Gailly <jloup@gzip.org>
|
||||
* various fixes by Cosmin Truta <cosmint@cs.ubbcluj.ro>
|
||||
*/
|
||||
|
@ -15,10 +15,10 @@
|
|||
#include "zlib.h"
|
||||
|
||||
#ifdef unix
|
||||
# include <unistd.h>
|
||||
# include <unistd.h>
|
||||
#else
|
||||
# include <direct.h>
|
||||
# include <io.h>
|
||||
# include <direct.h>
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -28,8 +28,9 @@
|
|||
# endif
|
||||
# define mkdir(dirname,mode) _mkdir(dirname)
|
||||
# ifdef _MSC_VER
|
||||
# define strdup(str) _strdup(str)
|
||||
# define access(path,mode) _access(path,mode)
|
||||
# define chmod(path,mode) _chmod(path,mode)
|
||||
# define strdup(str) _strdup(str)
|
||||
# endif
|
||||
#else
|
||||
# include <utime.h>
|
||||
|
@ -48,7 +49,21 @@
|
|||
#define FIFOTYPE '6' /* FIFO special */
|
||||
#define CONTTYPE '7' /* reserved */
|
||||
|
||||
#define BLOCKSIZE 512
|
||||
/* GNU tar extensions */
|
||||
|
||||
#define GNUTYPE_DUMPDIR 'D' /* file names from dumped directory */
|
||||
#define GNUTYPE_LONGLINK 'K' /* long link name */
|
||||
#define GNUTYPE_LONGNAME 'L' /* long file name */
|
||||
#define GNUTYPE_MULTIVOL 'M' /* continuation of file from another volume */
|
||||
#define GNUTYPE_NAMES 'N' /* file name that does not fit into main hdr */
|
||||
#define GNUTYPE_SPARSE 'S' /* sparse file */
|
||||
#define GNUTYPE_VOLHDR 'V' /* tape/volume header */
|
||||
|
||||
|
||||
/* tar header */
|
||||
|
||||
#define BLOCKSIZE 512
|
||||
#define SHORTNAMESIZE 100
|
||||
|
||||
struct tar_header
|
||||
{ /* byte offset */
|
||||
|
@ -71,11 +86,20 @@ struct tar_header
|
|||
/* 500 */
|
||||
};
|
||||
|
||||
union tar_buffer {
|
||||
union tar_buffer
|
||||
{
|
||||
char buffer[BLOCKSIZE];
|
||||
struct tar_header header;
|
||||
};
|
||||
|
||||
struct attr_item
|
||||
{
|
||||
struct attr_item *next;
|
||||
char *fname;
|
||||
int mode;
|
||||
time_t time;
|
||||
};
|
||||
|
||||
enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID };
|
||||
|
||||
char *TGZfname OF((const char *));
|
||||
|
@ -84,6 +108,9 @@ 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 *));
|
||||
|
@ -221,7 +248,42 @@ int setfiletime (char *fname,time_t ftime)
|
|||
}
|
||||
|
||||
|
||||
/* regular expression matching */
|
||||
/* push file attributes */
|
||||
|
||||
void push_attr(struct attr_item **list,char *fname,int mode,time_t time)
|
||||
{
|
||||
struct attr_item *item;
|
||||
|
||||
item = (struct attr_item *)malloc(sizeof(struct attr_item));
|
||||
if (item == NULL)
|
||||
error("Out of memory");
|
||||
item->fname = strdup(fname);
|
||||
item->mode = mode;
|
||||
item->time = time;
|
||||
item->next = *list;
|
||||
*list = item;
|
||||
}
|
||||
|
||||
|
||||
/* restore file attributes */
|
||||
|
||||
void restore_attr(struct attr_item **list)
|
||||
{
|
||||
struct attr_item *item, *prev;
|
||||
|
||||
for (item = *list; item != NULL; )
|
||||
{
|
||||
setfiletime(item->fname,item->time);
|
||||
chmod(item->fname,item->mode);
|
||||
prev = item;
|
||||
item = item->next;
|
||||
free(prev);
|
||||
}
|
||||
*list = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* match regular expression */
|
||||
|
||||
#define ISSPECIAL(c) (((c) == '*') || ((c) == '/'))
|
||||
|
||||
|
@ -332,6 +394,7 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
|
|||
char fname[BLOCKSIZE];
|
||||
int tarmode;
|
||||
time_t tartime;
|
||||
struct attr_item *attributes = NULL;
|
||||
|
||||
if (action == TGZ_LIST)
|
||||
printf(" date time size file\n"
|
||||
|
@ -354,14 +417,15 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
|
|||
/*
|
||||
* If we have to get a tar header
|
||||
*/
|
||||
if (getheader == 1)
|
||||
if (getheader >= 1)
|
||||
{
|
||||
/*
|
||||
* if we met the end of the tar
|
||||
* or the end-of-tar block,
|
||||
* we are done
|
||||
*/
|
||||
if ((len == 0) || (buffer.header.name[0] == 0)) break;
|
||||
if (len == 0 || buffer.header.name[0] == 0)
|
||||
break;
|
||||
|
||||
tarmode = getoct(buffer.header.mode,8);
|
||||
tartime = (time_t)getoct(buffer.header.mtime,12);
|
||||
|
@ -371,8 +435,25 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
|
|||
action = TGZ_INVALID;
|
||||
}
|
||||
|
||||
strcpy(fname,buffer.header.name);
|
||||
if (getheader == 1)
|
||||
{
|
||||
strncpy(fname,buffer.header.name,SHORTNAMESIZE);
|
||||
if (fname[SHORTNAMESIZE-1] != 0)
|
||||
fname[SHORTNAMESIZE] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* The file name is longer than SHORTNAMESIZE
|
||||
*/
|
||||
if (strncmp(fname,buffer.header.name,SHORTNAMESIZE-1) != 0)
|
||||
error("bad long name");
|
||||
getheader = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Act according to the type flag
|
||||
*/
|
||||
switch (buffer.header.typeflag)
|
||||
{
|
||||
case DIRTYPE:
|
||||
|
@ -381,7 +462,7 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
|
|||
if (action == TGZ_EXTRACT)
|
||||
{
|
||||
makedir(fname);
|
||||
setfiletime(fname,tartime);
|
||||
push_attr(&attributes,fname,tarmode,tartime);
|
||||
}
|
||||
break;
|
||||
case REGTYPE:
|
||||
|
@ -419,6 +500,24 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
|
|||
}
|
||||
getheader = 0;
|
||||
break;
|
||||
case GNUTYPE_LONGLINK:
|
||||
case GNUTYPE_LONGNAME:
|
||||
remaining = getoct(buffer.header.size,12);
|
||||
if (remaining < 0 || remaining >= BLOCKSIZE)
|
||||
{
|
||||
action = TGZ_INVALID;
|
||||
break;
|
||||
}
|
||||
len = gzread(in, fname, BLOCKSIZE);
|
||||
if (len < 0)
|
||||
error(gzerror(in, &err));
|
||||
if (fname[BLOCKSIZE-1] != 0 || (int)strlen(fname) > remaining)
|
||||
{
|
||||
action = TGZ_INVALID;
|
||||
break;
|
||||
}
|
||||
getheader = 2;
|
||||
break;
|
||||
default:
|
||||
if (action == TGZ_LIST)
|
||||
printf(" %s <---> %s\n",strtime(&tartime),fname);
|
||||
|
@ -433,7 +532,8 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
|
|||
{
|
||||
if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes)
|
||||
{
|
||||
fprintf(stderr,"%s: Error writing %s -- skipping\n",prog,fname);
|
||||
fprintf(stderr,
|
||||
"%s: Error writing %s -- skipping\n",prog,fname);
|
||||
fclose(outfile);
|
||||
outfile = NULL;
|
||||
remove(fname);
|
||||
|
@ -450,7 +550,7 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
|
|||
fclose(outfile);
|
||||
outfile = NULL;
|
||||
if (action != TGZ_INVALID)
|
||||
setfiletime(fname,tartime);
|
||||
push_attr(&attributes,fname,tarmode,tartime);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,6 +564,11 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore file modes and time stamps
|
||||
*/
|
||||
restore_attr(&attributes);
|
||||
|
||||
if (gzclose(in) != Z_OK)
|
||||
error("failed gzclose");
|
||||
|
||||
|
@ -475,7 +580,7 @@ int tar (gzFile in,int action,int arg,int argc,char **argv)
|
|||
|
||||
void help(int exitval)
|
||||
{
|
||||
printf("untgz version 0.2\n"
|
||||
printf("untgz version 0.2.1\n"
|
||||
" using zlib version %s\n\n",
|
||||
zlibVersion());
|
||||
printf("Usage: untgz file.tgz extract all files\n"
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#define IDR_VERSION1 1
|
||||
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
||||
FILEVERSION 1,2,1,0
|
||||
PRODUCTVERSION 1,2,1,0
|
||||
FILEVERSION 1,2,1,2
|
||||
PRODUCTVERSION 1,2,1,2
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
FILEFLAGS 0
|
||||
FILEOS VOS_DOS_WINDOWS32
|
||||
|
@ -17,7 +17,7 @@ BEGIN
|
|||
|
||||
BEGIN
|
||||
VALUE "FileDescription", "zlib data compression library\0"
|
||||
VALUE "FileVersion", "1.2.1.0\0"
|
||||
VALUE "FileVersion", "1.2.1.2\0"
|
||||
VALUE "InternalName", "zlib\0"
|
||||
VALUE "OriginalFilename", "zlib.dll\0"
|
||||
VALUE "ProductName", "ZLib.DLL\0"
|
||||
|
|
105
zlib/crc32.c
105
zlib/crc32.c
|
@ -11,6 +11,14 @@
|
|||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
/*
|
||||
Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore protection
|
||||
on the static variables used to control the first-use generation of the crc
|
||||
tables. Therefore if you #define DYNAMIC_CRC_TABLE, you should first call
|
||||
get_crc_table() to initialize the tables before allowing more than on thread
|
||||
to use crc32().
|
||||
*/
|
||||
|
||||
#ifdef MAKECRCH
|
||||
# include <stdio.h>
|
||||
# ifndef DYNAMIC_CRC_TABLE
|
||||
|
@ -48,11 +56,9 @@
|
|||
# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
|
||||
(((w)&0xff00)<<8)+(((w)&0xff)<<24))
|
||||
local unsigned long crc32_little OF((unsigned long,
|
||||
const unsigned char FAR *, unsigned))
|
||||
/*@*/;
|
||||
const unsigned char FAR *, unsigned));
|
||||
local unsigned long crc32_big OF((unsigned long,
|
||||
const unsigned char FAR *, unsigned))
|
||||
/*@*/;
|
||||
const unsigned char FAR *, unsigned));
|
||||
# define TBLS 8
|
||||
#else
|
||||
# define TBLS 1
|
||||
|
@ -60,13 +66,11 @@
|
|||
|
||||
#ifdef DYNAMIC_CRC_TABLE
|
||||
|
||||
local int crc_table_empty = 1;
|
||||
local volatile int crc_table_empty = 1;
|
||||
local unsigned long FAR crc_table[TBLS][256];
|
||||
local void make_crc_table OF((void))
|
||||
/*@*/;
|
||||
local void make_crc_table OF((void));
|
||||
#ifdef MAKECRCH
|
||||
local void write_table OF((FILE *, const unsigned long FAR *))
|
||||
/*@*/;
|
||||
local void write_table OF((FILE *, const unsigned long FAR *));
|
||||
#endif /* MAKECRCH */
|
||||
|
||||
/*
|
||||
|
@ -99,38 +103,51 @@ local void make_crc_table()
|
|||
{
|
||||
unsigned long c;
|
||||
int n, k;
|
||||
unsigned long poly; /* polynomial exclusive-or pattern */
|
||||
unsigned long poly; /* polynomial exclusive-or pattern */
|
||||
/* terms of polynomial defining this crc (except x^32): */
|
||||
static volatile int first = 1; /* flag to limit concurrent making */
|
||||
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
|
||||
|
||||
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
|
||||
poly = 0UL;
|
||||
for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
|
||||
poly |= 1UL << (31 - p[n]);
|
||||
/* See if another task is already doing this (not thread-safe, but better
|
||||
than nothing -- significantly reduces duration of vulnerability in
|
||||
case the advice about DYNAMIC_CRC_TABLE is ignored) */
|
||||
if (first) {
|
||||
first = 0;
|
||||
|
||||
/* generate a crc for every 8-bit value */
|
||||
for (n = 0; n < 256; n++) {
|
||||
c = (unsigned long)n;
|
||||
for (k = 0; k < 8; k++)
|
||||
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
|
||||
crc_table[0][n] = c;
|
||||
}
|
||||
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
|
||||
poly = 0UL;
|
||||
for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
|
||||
poly |= 1UL << (31 - p[n]);
|
||||
|
||||
/* generate a crc for every 8-bit value */
|
||||
for (n = 0; n < 256; n++) {
|
||||
c = (unsigned long)n;
|
||||
for (k = 0; k < 8; k++)
|
||||
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
|
||||
crc_table[0][n] = c;
|
||||
}
|
||||
|
||||
#ifdef BYFOUR
|
||||
/* generate crc for each value followed by one, two, and three zeros, and
|
||||
then the byte reversal of those as well as the first table */
|
||||
for (n = 0; n < 256; n++) {
|
||||
c = crc_table[0][n];
|
||||
crc_table[4][n] = REV(c);
|
||||
for (k = 1; k < 4; k++) {
|
||||
c = crc_table[0][c & 0xff] ^ (c >> 8);
|
||||
crc_table[k][n] = c;
|
||||
crc_table[k + 4][n] = REV(c);
|
||||
}
|
||||
}
|
||||
/* generate crc for each value followed by one, two, and three zeros, and
|
||||
then the byte reversal of those as well as the first table */
|
||||
for (n = 0; n < 256; n++) {
|
||||
c = crc_table[0][n];
|
||||
crc_table[4][n] = REV(c);
|
||||
for (k = 1; k < 4; k++) {
|
||||
c = crc_table[0][c & 0xff] ^ (c >> 8);
|
||||
crc_table[k][n] = c;
|
||||
crc_table[k + 4][n] = REV(c);
|
||||
}
|
||||
}
|
||||
#endif /* BYFOUR */
|
||||
|
||||
crc_table_empty = 0;
|
||||
crc_table_empty = 0;
|
||||
}
|
||||
else { /* not first */
|
||||
/* wait for the other guy to finish (not exactly efficient, but rare) */
|
||||
while (crc_table_empty)
|
||||
;
|
||||
}
|
||||
|
||||
#ifdef MAKECRCH
|
||||
/* write out CRC tables to crc32.h */
|
||||
|
@ -181,12 +198,13 @@ local void write_table(out, table)
|
|||
/* =========================================================================
|
||||
* This function can be used by asm versions of crc32()
|
||||
*/
|
||||
const unsigned long FAR * ZEXPORT get_crc_table(void)
|
||||
const unsigned long FAR * ZEXPORT get_crc_table()
|
||||
{
|
||||
#ifdef DYNAMIC_CRC_TABLE
|
||||
if (crc_table_empty) make_crc_table();
|
||||
if (crc_table_empty)
|
||||
make_crc_table();
|
||||
#endif /* DYNAMIC_CRC_TABLE */
|
||||
return (const unsigned long FAR *)crc_table;
|
||||
return (const unsigned long FAR *)crc_table;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
@ -194,7 +212,10 @@ const unsigned long FAR * ZEXPORT get_crc_table(void)
|
|||
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
|
||||
|
||||
/* ========================================================================= */
|
||||
unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, unsigned len)
|
||||
unsigned long ZEXPORT crc32(crc, buf, len)
|
||||
unsigned long crc;
|
||||
const unsigned char FAR *buf;
|
||||
unsigned len;
|
||||
{
|
||||
if (buf == Z_NULL) return 0UL;
|
||||
|
||||
|
@ -234,7 +255,10 @@ unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, uns
|
|||
#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
|
||||
|
||||
/* ========================================================================= */
|
||||
local unsigned long crc32_little(unsigned long crc, const unsigned char FAR *buf, unsigned len)
|
||||
local unsigned long crc32_little(crc, buf, len)
|
||||
unsigned long crc;
|
||||
const unsigned char FAR *buf;
|
||||
unsigned len;
|
||||
{
|
||||
register u4 c;
|
||||
register const u4 FAR *buf4;
|
||||
|
@ -271,7 +295,10 @@ local unsigned long crc32_little(unsigned long crc, const unsigned char FAR *buf
|
|||
#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
|
||||
|
||||
/* ========================================================================= */
|
||||
local unsigned long crc32_big(unsigned long crc, const unsigned char FAR *buf, unsigned len)
|
||||
local unsigned long crc32_big(crc, buf, len)
|
||||
unsigned long crc;
|
||||
const unsigned char FAR *buf;
|
||||
unsigned len;
|
||||
{
|
||||
register u4 c;
|
||||
register const u4 FAR *buf4;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
* Generated automatically by crc32.c
|
||||
*/
|
||||
|
||||
/*@unchecked@*/ /*@observer@*/
|
||||
local const unsigned long FAR crc_table[TBLS][256] =
|
||||
{
|
||||
{
|
||||
|
|
141
zlib/deflate.c
141
zlib/deflate.c
|
@ -51,9 +51,8 @@
|
|||
|
||||
#include "deflate.h"
|
||||
|
||||
/*@unchecked@*/ /*@observer@*/
|
||||
const char deflate_copyright[] =
|
||||
" deflate 1.2.1.1 Copyright 1995-2003 Jean-loup Gailly ";
|
||||
" deflate 1.2.1.2 Copyright 1995-2004 Jean-loup Gailly ";
|
||||
/*
|
||||
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
|
||||
|
@ -71,46 +70,32 @@ typedef enum {
|
|||
finish_done /* finish done, accept no more input or output */
|
||||
} block_state;
|
||||
|
||||
typedef block_state (*compress_func) OF((deflate_state *s, int flush))
|
||||
/*@*/;
|
||||
typedef block_state (*compress_func) OF((deflate_state *s, int flush));
|
||||
/* Compression function. Returns the block state after the call. */
|
||||
|
||||
local void fill_window OF((deflate_state *s))
|
||||
/*@modifies *s @*/;
|
||||
local block_state deflate_stored OF((deflate_state *s, int flush))
|
||||
/*@modifies *s @*/;
|
||||
local block_state deflate_fast OF((deflate_state *s, int flush))
|
||||
/*@modifies *s @*/;
|
||||
local void fill_window OF((deflate_state *s));
|
||||
local block_state deflate_stored OF((deflate_state *s, int flush));
|
||||
local block_state deflate_fast OF((deflate_state *s, int flush));
|
||||
#ifndef FASTEST
|
||||
local block_state deflate_slow OF((deflate_state *s, int flush))
|
||||
/*@modifies *s @*/;
|
||||
local block_state deflate_slow OF((deflate_state *s, int flush));
|
||||
#endif
|
||||
local void lm_init OF((deflate_state *s))
|
||||
/*@modifies *s @*/;
|
||||
local void putShortMSB OF((deflate_state *s, uInt b))
|
||||
/*@modifies *s @*/;
|
||||
local void flush_pending OF((z_streamp strm))
|
||||
/*@modifies strm @*/;
|
||||
local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size))
|
||||
/*@modifies strm, *buf @*/;
|
||||
local void lm_init OF((deflate_state *s));
|
||||
local void putShortMSB OF((deflate_state *s, uInt b));
|
||||
local void flush_pending OF((z_streamp strm));
|
||||
local int read_buf OF((z_streamp strm, Bytef *buf, unsigned size));
|
||||
#ifndef FASTEST
|
||||
#ifdef ASMV
|
||||
void match_init OF((void)) /* asm code initialization */
|
||||
/*@*/;
|
||||
uInt longest_match OF((deflate_state *s, IPos cur_match))
|
||||
/*@modifies *s @*/;
|
||||
void match_init OF((void)); /* asm code initialization */
|
||||
uInt longest_match OF((deflate_state *s, IPos cur_match));
|
||||
#else
|
||||
local uInt longest_match OF((deflate_state *s, IPos cur_match))
|
||||
/*@modifies *s @*/;
|
||||
local uInt longest_match OF((deflate_state *s, IPos cur_match));
|
||||
#endif
|
||||
#endif
|
||||
local uInt longest_match_fast OF((deflate_state *s, IPos cur_match))
|
||||
/*@modifies *s @*/;
|
||||
local uInt longest_match_fast OF((deflate_state *s, IPos cur_match));
|
||||
|
||||
#ifdef DEBUG
|
||||
local void check_match OF((deflate_state *s, IPos start, IPos match,
|
||||
int length))
|
||||
/*@*/;
|
||||
int length));
|
||||
#endif
|
||||
|
||||
/* ===========================================================================
|
||||
|
@ -143,7 +128,6 @@ typedef struct config_s {
|
|||
compress_func func;
|
||||
} config;
|
||||
|
||||
/*@unchecked@*/ /*@observer@*/
|
||||
#ifdef FASTEST
|
||||
local const config configuration_table[2] = {
|
||||
/* good lazy nice chain */
|
||||
|
@ -217,7 +201,11 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */
|
|||
zmemzero((Bytef *)s->head, (unsigned)(s->hash_size-1)*sizeof(*s->head));
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, int stream_size)
|
||||
int ZEXPORT deflateInit_(strm, level, version, stream_size)
|
||||
z_streamp strm;
|
||||
int level;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{
|
||||
return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL,
|
||||
Z_DEFAULT_STRATEGY, version, stream_size);
|
||||
|
@ -225,9 +213,16 @@ int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, int str
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
|
||||
int windowBits, int memLevel, int strategy,
|
||||
const char *version, int stream_size)
|
||||
int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
|
||||
version, stream_size)
|
||||
z_streamp strm;
|
||||
int level;
|
||||
int method;
|
||||
int windowBits;
|
||||
int memLevel;
|
||||
int strategy;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{
|
||||
deflate_state *s;
|
||||
int wrap = 1;
|
||||
|
@ -316,7 +311,10 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt dictLength)
|
||||
int ZEXPORT deflateSetDictionary (strm, dictionary, dictLength)
|
||||
z_streamp strm;
|
||||
const Bytef *dictionary;
|
||||
uInt dictLength;
|
||||
{
|
||||
deflate_state *s;
|
||||
uInt length = dictLength;
|
||||
|
@ -357,7 +355,8 @@ int ZEXPORT deflateSetDictionary (z_streamp strm, const Bytef *dictionary, uInt
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateReset (z_streamp strm)
|
||||
int ZEXPORT deflateReset (strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
deflate_state *s;
|
||||
|
||||
|
@ -392,7 +391,10 @@ int ZEXPORT deflateReset (z_streamp strm)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflatePrime (z_streamp strm, int bits, int value)
|
||||
int ZEXPORT deflatePrime (strm, bits, value)
|
||||
z_streamp strm;
|
||||
int bits;
|
||||
int value;
|
||||
{
|
||||
if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
|
||||
strm->state->bi_valid = bits;
|
||||
|
@ -401,7 +403,10 @@ int ZEXPORT deflatePrime (z_streamp strm, int bits, int value)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateParams(z_streamp strm, int level, int strategy)
|
||||
int ZEXPORT deflateParams(strm, level, strategy)
|
||||
z_streamp strm;
|
||||
int level;
|
||||
int strategy;
|
||||
{
|
||||
deflate_state *s;
|
||||
compress_func func;
|
||||
|
@ -452,7 +457,9 @@ int ZEXPORT deflateParams(z_streamp strm, int level, int strategy)
|
|||
* But even the conservative upper bound of about 14% expansion does not
|
||||
* seem onerous for output buffer allocation.
|
||||
*/
|
||||
uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen)
|
||||
uLong ZEXPORT deflateBound(strm, sourceLen)
|
||||
z_streamp strm;
|
||||
uLong sourceLen;
|
||||
{
|
||||
deflate_state *s;
|
||||
uLong destLen;
|
||||
|
@ -479,7 +486,9 @@ uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen)
|
|||
* IN assertion: the stream state is correct and there is enough room in
|
||||
* pending_buf.
|
||||
*/
|
||||
local void putShortMSB (deflate_state *s, uInt b)
|
||||
local void putShortMSB (s, b)
|
||||
deflate_state *s;
|
||||
uInt b;
|
||||
{
|
||||
put_byte(s, (Byte)(b >> 8));
|
||||
put_byte(s, (Byte)(b & 0xff));
|
||||
|
@ -491,7 +500,8 @@ local void putShortMSB (deflate_state *s, uInt b)
|
|||
* to avoid allocating a large strm->next_out buffer and copying into it.
|
||||
* (See also read_buf()).
|
||||
*/
|
||||
local void flush_pending(z_streamp strm)
|
||||
local void flush_pending(strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
unsigned len = strm->state->pending;
|
||||
|
||||
|
@ -510,7 +520,9 @@ local void flush_pending(z_streamp strm)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflate (z_streamp strm, int flush)
|
||||
int ZEXPORT deflate (strm, flush)
|
||||
z_streamp strm;
|
||||
int flush;
|
||||
{
|
||||
int old_flush; /* value of flush param for previous deflate call */
|
||||
deflate_state *s;
|
||||
|
@ -684,7 +696,8 @@ int ZEXPORT deflate (z_streamp strm, int flush)
|
|||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
int ZEXPORT deflateEnd (z_streamp strm)
|
||||
int ZEXPORT deflateEnd (strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
int status;
|
||||
|
||||
|
@ -713,7 +726,9 @@ int ZEXPORT deflateEnd (z_streamp strm)
|
|||
* To simplify the source, this is not supported for 16-bit MSDOS (which
|
||||
* doesn't have enough memory anyway to duplicate compression states).
|
||||
*/
|
||||
int ZEXPORT deflateCopy (z_streamp dest, z_streamp source)
|
||||
int ZEXPORT deflateCopy (dest, source)
|
||||
z_streamp dest;
|
||||
z_streamp source;
|
||||
{
|
||||
#ifdef MAXSEG_64K
|
||||
return Z_STREAM_ERROR;
|
||||
|
@ -773,7 +788,10 @@ int ZEXPORT deflateCopy (z_streamp dest, z_streamp source)
|
|||
* allocating a large strm->next_in buffer and copying from it.
|
||||
* (See also flush_pending()).
|
||||
*/
|
||||
local int read_buf(z_streamp strm, Bytef *buf, unsigned size)
|
||||
local int read_buf(strm, buf, size)
|
||||
z_streamp strm;
|
||||
Bytef *buf;
|
||||
unsigned size;
|
||||
{
|
||||
unsigned len = strm->avail_in;
|
||||
|
||||
|
@ -800,7 +818,8 @@ local int read_buf(z_streamp strm, Bytef *buf, unsigned size)
|
|||
/* ===========================================================================
|
||||
* Initialize the "longest match" routines for a new zlib stream
|
||||
*/
|
||||
local void lm_init (deflate_state *s)
|
||||
local void lm_init (s)
|
||||
deflate_state *s;
|
||||
{
|
||||
s->window_size = (ulg)2L*s->w_size;
|
||||
|
||||
|
@ -838,7 +857,9 @@ local void lm_init (deflate_state *s)
|
|||
/* For 80x86 and 680x0, an optimized version will be provided in match.asm or
|
||||
* match.S. The code will be functionally equivalent.
|
||||
*/
|
||||
local uInt longest_match(deflate_state *s, IPos cur_match)
|
||||
local uInt longest_match(s, cur_match)
|
||||
deflate_state *s;
|
||||
IPos cur_match; /* current match */
|
||||
{
|
||||
unsigned chain_length = s->max_chain_length;/* max hash chain length */
|
||||
register Bytef *scan = s->window + s->strstart; /* current string */
|
||||
|
@ -979,7 +1000,9 @@ local uInt longest_match(deflate_state *s, IPos cur_match)
|
|||
/* ---------------------------------------------------------------------------
|
||||
* Optimized version for level == 1 or strategy == Z_RLE only
|
||||
*/
|
||||
local uInt longest_match_fast(deflate_state *s, IPos cur_match)
|
||||
local uInt longest_match_fast(s, cur_match)
|
||||
deflate_state *s;
|
||||
IPos cur_match; /* current match */
|
||||
{
|
||||
register Bytef *scan = s->window + s->strstart; /* current string */
|
||||
register Bytef *match; /* matched string */
|
||||
|
@ -1034,7 +1057,10 @@ local uInt longest_match_fast(deflate_state *s, IPos cur_match)
|
|||
/* ===========================================================================
|
||||
* Check that the match at match_start is indeed a match.
|
||||
*/
|
||||
local void check_match(deflate_state *s, IPos start, IPos match, int length)
|
||||
local void check_match(s, start, match, length)
|
||||
deflate_state *s;
|
||||
IPos start, match;
|
||||
int length;
|
||||
{
|
||||
/* check that the match is indeed a match */
|
||||
if (zmemcmp(s->window + match,
|
||||
|
@ -1065,7 +1091,8 @@ local void check_match(deflate_state *s, IPos start, IPos match, int length)
|
|||
* performed for at least two bytes (required for the zip translate_eol
|
||||
* option -- not supported here).
|
||||
*/
|
||||
local void fill_window(deflate_state *s)
|
||||
local void fill_window(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
register unsigned n, m;
|
||||
register Posf *p;
|
||||
|
@ -1187,7 +1214,9 @@ local void fill_window(deflate_state *s)
|
|||
* NOTE: this function should be optimized to avoid extra copying from
|
||||
* window to pending_buf.
|
||||
*/
|
||||
local block_state deflate_stored(deflate_state *s, int flush)
|
||||
local block_state deflate_stored(s, flush)
|
||||
deflate_state *s;
|
||||
int flush;
|
||||
{
|
||||
/* Stored blocks are limited to 0xffff bytes, pending_buf is limited
|
||||
* to pending_buf_size, and each stored block has a 5 byte header:
|
||||
|
@ -1243,7 +1272,9 @@ local block_state deflate_stored(deflate_state *s, int flush)
|
|||
* new strings in the dictionary only for unmatched strings or for short
|
||||
* matches. It is used only for the fast compression options.
|
||||
*/
|
||||
local block_state deflate_fast(deflate_state *s, int flush)
|
||||
local block_state deflate_fast(s, flush)
|
||||
deflate_state *s;
|
||||
int flush;
|
||||
{
|
||||
IPos hash_head = NIL; /* head of the hash chain */
|
||||
int bflush; /* set if current block must be flushed */
|
||||
|
@ -1347,7 +1378,9 @@ local block_state deflate_fast(deflate_state *s, int flush)
|
|||
* evaluation for matches: a match is finally adopted only if there is
|
||||
* no better match at the next window position.
|
||||
*/
|
||||
local block_state deflate_slow(deflate_state *s, int flush)
|
||||
local block_state deflate_slow(s, flush)
|
||||
deflate_state *s;
|
||||
int flush;
|
||||
{
|
||||
IPos hash_head = NIL; /* head of hash chain */
|
||||
int bflush; /* set if current block must be flushed */
|
||||
|
|
|
@ -74,10 +74,8 @@ typedef struct ct_data_s {
|
|||
typedef struct static_tree_desc_s static_tree_desc;
|
||||
|
||||
typedef struct tree_desc_s {
|
||||
/*@shared@*/
|
||||
ct_data *dyn_tree; /* the dynamic tree */
|
||||
int max_code; /* largest code with non zero frequency */
|
||||
/*@shared@*/
|
||||
static_tree_desc *stat_desc; /* the corresponding static tree */
|
||||
} FAR tree_desc;
|
||||
|
||||
|
@ -92,14 +90,11 @@ typedef unsigned IPos;
|
|||
typedef struct internal_state {
|
||||
z_streamp strm; /* pointer back to this zlib stream */
|
||||
int status; /* as the name implies */
|
||||
/*@owned@*/
|
||||
Bytef *pending_buf; /* output still pending */
|
||||
ulg pending_buf_size; /* size of pending_buf */
|
||||
/*@dependent@*/
|
||||
Bytef *pending_out; /* next pending byte to output to the stream */
|
||||
int pending; /* nb of bytes in the pending buffer */
|
||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
|
||||
Byte data_type; /* UNKNOWN, BINARY or ASCII */
|
||||
Byte method; /* STORED (for zip only) or DEFLATED */
|
||||
int last_flush; /* value of flush param for previous deflate call */
|
||||
|
||||
|
@ -210,7 +205,6 @@ typedef struct internal_state {
|
|||
/* Depth of each subtree used as tie breaker for trees of equal frequency
|
||||
*/
|
||||
|
||||
/*@kept@*/
|
||||
uchf *l_buf; /* buffer for literals or lengths */
|
||||
|
||||
uInt lit_bufsize;
|
||||
|
@ -279,19 +273,13 @@ typedef struct internal_state {
|
|||
*/
|
||||
|
||||
/* in trees.c */
|
||||
void _tr_init OF((deflate_state *s))
|
||||
/*@globals internalState @*/
|
||||
/*@modifies *s, internalState @*/;
|
||||
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc))
|
||||
/*@modifies *s @*/;
|
||||
void _tr_init OF((deflate_state *s));
|
||||
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
|
||||
void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
||||
int eof))
|
||||
/*@modifies *s @*/;
|
||||
void _tr_align OF((deflate_state *s))
|
||||
/*@modifies *s @*/;
|
||||
void _tr_stored_block OF((deflate_state *s, /*@null@*/ charf *buf, ulg stored_len,
|
||||
int eof))
|
||||
/*@modifies *s @*/;
|
||||
int eof));
|
||||
void _tr_align OF((deflate_state *s));
|
||||
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,
|
||||
int eof));
|
||||
|
||||
#define d_code(dist) \
|
||||
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
|
||||
|
@ -307,9 +295,7 @@ void _tr_stored_block OF((deflate_state *s, /*@null@*/ charf *buf, ulg stored_le
|
|||
extern uch _length_code[];
|
||||
extern uch _dist_code[];
|
||||
#else
|
||||
/*@unchecked@*/ /*@observer@*/
|
||||
extern const uch _length_code[];
|
||||
/*@unchecked@*/ /*@observer@*/
|
||||
extern const uch _dist_code[];
|
||||
#endif
|
||||
|
||||
|
|
154
zlib/gzio.c
154
zlib/gzio.c
|
@ -7,8 +7,6 @@
|
|||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
/*@access FILE @*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "zutil.h"
|
||||
|
@ -38,16 +36,13 @@ struct internal_state {int dummy;}; /* for buggy compilers */
|
|||
#endif
|
||||
|
||||
#ifndef STDC
|
||||
extern voidp malloc OF((uInt size))
|
||||
/*@*/;
|
||||
extern void free OF((voidpf ptr))
|
||||
/*@*/;
|
||||
extern voidp malloc OF((uInt size));
|
||||
extern void free OF((voidpf ptr));
|
||||
#endif
|
||||
|
||||
#define ALLOC(size) malloc(size)
|
||||
#define TRYFREE(p) {if (p) free(p);}
|
||||
|
||||
/*@unchecked@*/ /*@observer@*/
|
||||
static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
|
||||
|
||||
/* gzip flag byte */
|
||||
|
@ -62,16 +57,11 @@ typedef struct gz_stream {
|
|||
z_stream stream;
|
||||
int z_err; /* error code for last stream operation */
|
||||
int z_eof; /* set if end of input file */
|
||||
/*@relnull@*/ /*@dependent@*/
|
||||
FILE *file; /* .gz file */
|
||||
/*@relnull@*/
|
||||
Byte *inbuf; /* input buffer */
|
||||
/*@relnull@*/
|
||||
Byte *outbuf; /* output buffer */
|
||||
uLong crc; /* crc32 of uncompressed data */
|
||||
/*@relnull@*/
|
||||
char *msg; /* error message */
|
||||
/*@relnull@*/
|
||||
char *path; /* path name for debugging only */
|
||||
int transparent; /* 1 if input file is not a .gz file */
|
||||
char mode; /* 'w' or 'r' */
|
||||
|
@ -83,28 +73,13 @@ typedef struct gz_stream {
|
|||
} gz_stream;
|
||||
|
||||
|
||||
/*@null@*/
|
||||
local gzFile gz_open OF((const char *path, const char *mode, int fd))
|
||||
/*@globals errno, fileSystem, internalState @*/
|
||||
/*@modifies errno, fileSystem, internalState @*/;
|
||||
local int do_flush OF((gzFile file, int flush))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
local int get_byte OF((gz_stream *s))
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies s, errno, fileSystem @*/;
|
||||
local void check_header OF((gz_stream *s))
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies s, errno, fileSystem @*/;
|
||||
local int destroy OF((/*@only@*/ gz_stream *s))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies s, fileSystem @*/;
|
||||
local void putLong OF((FILE *file, uLong x))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies file, fileSystem @*/;
|
||||
local uLong getLong OF((gz_stream *s))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies s, fileSystem @*/;
|
||||
local gzFile gz_open OF((const char *path, const char *mode, int fd));
|
||||
local int do_flush OF((gzFile file, int flush));
|
||||
local int get_byte OF((gz_stream *s));
|
||||
local void check_header OF((gz_stream *s));
|
||||
local int destroy OF((gz_stream *s));
|
||||
local void putLong OF((FILE *file, uLong x));
|
||||
local uLong getLong OF((gz_stream *s));
|
||||
|
||||
/* ===========================================================================
|
||||
Opens a gzip (.gz) file for reading or writing. The mode parameter
|
||||
|
@ -115,7 +90,10 @@ local uLong getLong OF((gz_stream *s))
|
|||
can be checked to distinguish the two cases (if errno is zero, the
|
||||
zlib error is Z_MEM_ERROR).
|
||||
*/
|
||||
local gzFile gz_open (const char *path, const char *mode, int fd)
|
||||
local gzFile gz_open (path, mode, fd)
|
||||
const char *path;
|
||||
const char *mode;
|
||||
int fd;
|
||||
{
|
||||
int err;
|
||||
int level = Z_DEFAULT_COMPRESSION; /* compression level */
|
||||
|
@ -227,7 +205,9 @@ local gzFile gz_open (const char *path, const char *mode, int fd)
|
|||
/* ===========================================================================
|
||||
Opens a gzip (.gz) file for reading or writing.
|
||||
*/
|
||||
gzFile ZEXPORT gzopen (const char *path, const char *mode)
|
||||
gzFile ZEXPORT gzopen (path, mode)
|
||||
const char *path;
|
||||
const char *mode;
|
||||
{
|
||||
return gz_open (path, mode, -1);
|
||||
}
|
||||
|
@ -236,7 +216,9 @@ gzFile ZEXPORT gzopen (const char *path, const char *mode)
|
|||
Associate a gzFile with the file descriptor fd. fd is not dup'ed here
|
||||
to mimic the behavio(u)r of fdopen.
|
||||
*/
|
||||
gzFile ZEXPORT gzdopen (int fd, const char *mode)
|
||||
gzFile ZEXPORT gzdopen (fd, mode)
|
||||
int fd;
|
||||
const char *mode;
|
||||
{
|
||||
char name[20];
|
||||
|
||||
|
@ -249,7 +231,10 @@ gzFile ZEXPORT gzdopen (int fd, const char *mode)
|
|||
/* ===========================================================================
|
||||
* Update the compression level and strategy
|
||||
*/
|
||||
int ZEXPORT gzsetparams (gzFile file, int level, int strategy)
|
||||
int ZEXPORT gzsetparams (file, level, strategy)
|
||||
gzFile file;
|
||||
int level;
|
||||
int strategy;
|
||||
{
|
||||
gz_stream *s = (gz_stream*)file;
|
||||
|
||||
|
@ -273,7 +258,8 @@ int ZEXPORT gzsetparams (gzFile file, int level, int strategy)
|
|||
for end of file.
|
||||
IN assertion: the stream s has been sucessfully opened for reading.
|
||||
*/
|
||||
local int get_byte(gz_stream *s)
|
||||
local int get_byte(s)
|
||||
gz_stream *s;
|
||||
{
|
||||
if (s->z_eof) return EOF;
|
||||
if (s->stream.avail_in == 0) {
|
||||
|
@ -299,7 +285,8 @@ local int get_byte(gz_stream *s)
|
|||
s->stream.avail_in is zero for the first time, but may be non-zero
|
||||
for concatenated .gz files.
|
||||
*/
|
||||
local void check_header(gz_stream *s)
|
||||
local void check_header(s)
|
||||
gz_stream *s;
|
||||
{
|
||||
int method; /* method byte */
|
||||
int flags; /* flags byte */
|
||||
|
@ -365,7 +352,8 @@ local void check_header(gz_stream *s)
|
|||
* Cleanup then free the given gz_stream. Return a zlib error code.
|
||||
Try freeing in the reverse order of allocations.
|
||||
*/
|
||||
local int destroy (gz_stream *s)
|
||||
local int destroy (s)
|
||||
gz_stream *s;
|
||||
{
|
||||
int err = Z_OK;
|
||||
|
||||
|
@ -403,7 +391,10 @@ local int destroy (gz_stream *s)
|
|||
Reads the given number of uncompressed bytes from the compressed file.
|
||||
gzread returns the number of bytes actually read (0 for end of file).
|
||||
*/
|
||||
int ZEXPORT gzread (gzFile file, voidp buf, unsigned len)
|
||||
int ZEXPORT gzread (file, buf, len)
|
||||
gzFile file;
|
||||
voidp buf;
|
||||
unsigned len;
|
||||
{
|
||||
gz_stream *s = (gz_stream*)file;
|
||||
Bytef *start = (Bytef*)buf; /* starting point for crc computation */
|
||||
|
@ -464,6 +455,10 @@ int ZEXPORT gzread (gzFile file, voidp buf, unsigned len)
|
|||
s->z_err = Z_ERRNO;
|
||||
break;
|
||||
}
|
||||
if (feof(s->file)) { /* avoid error for empty file */
|
||||
s->z_err = Z_STREAM_END;
|
||||
break;
|
||||
}
|
||||
}
|
||||
s->stream.next_in = s->inbuf;
|
||||
}
|
||||
|
@ -505,7 +500,8 @@ int ZEXPORT gzread (gzFile file, voidp buf, unsigned len)
|
|||
Reads one byte from the compressed file. gzgetc returns this byte
|
||||
or -1 in case of end of file or error.
|
||||
*/
|
||||
int ZEXPORT gzgetc(gzFile file)
|
||||
int ZEXPORT gzgetc(file)
|
||||
gzFile file;
|
||||
{
|
||||
unsigned char c;
|
||||
|
||||
|
@ -516,7 +512,9 @@ int ZEXPORT gzgetc(gzFile file)
|
|||
/* ===========================================================================
|
||||
Push one byte back onto the stream.
|
||||
*/
|
||||
int ZEXPORT gzungetc(int c, gzFile file)
|
||||
int ZEXPORT gzungetc(c, file)
|
||||
int c;
|
||||
gzFile file;
|
||||
{
|
||||
gz_stream *s = (gz_stream*)file;
|
||||
|
||||
|
@ -539,7 +537,10 @@ int ZEXPORT gzungetc(int c, gzFile file)
|
|||
|
||||
The current implementation is not optimized at all.
|
||||
*/
|
||||
char * ZEXPORT gzgets(gzFile file, char *buf, int len)
|
||||
char * ZEXPORT gzgets(file, buf, len)
|
||||
gzFile file;
|
||||
char *buf;
|
||||
int len;
|
||||
{
|
||||
char *b = buf;
|
||||
if (buf == Z_NULL || len <= 0) return Z_NULL;
|
||||
|
@ -555,7 +556,10 @@ char * ZEXPORT gzgets(gzFile file, char *buf, int len)
|
|||
Writes the given number of uncompressed bytes into the compressed file.
|
||||
gzwrite returns the number of bytes actually written (0 in case of error).
|
||||
*/
|
||||
int ZEXPORT gzwrite (gzFile file, voidpc buf, unsigned len)
|
||||
int ZEXPORT gzwrite (file, buf, len)
|
||||
gzFile file;
|
||||
voidpc buf;
|
||||
unsigned len;
|
||||
{
|
||||
gz_stream *s = (gz_stream*)file;
|
||||
|
||||
|
@ -630,11 +634,12 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...)
|
|||
}
|
||||
#else /* not ANSI C */
|
||||
|
||||
int ZEXPORTVA gzprintf (gzFile file, const char *format,
|
||||
int a1, int a2, int a3, int a4, int a5,
|
||||
int a6, int a7, int a8, int a9, int a10,
|
||||
int a11, int a12, int a13, int a14, int a15,
|
||||
int a16, int a17, int a18, int a19, int a20)
|
||||
int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
|
||||
gzFile file;
|
||||
const char *format;
|
||||
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
|
||||
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
|
||||
{
|
||||
char buf[Z_PRINTF_BUFSIZE];
|
||||
int len;
|
||||
|
@ -670,7 +675,9 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format,
|
|||
Writes c, converted to an unsigned char, into the compressed file.
|
||||
gzputc returns the value that was written, or -1 in case of error.
|
||||
*/
|
||||
int ZEXPORT gzputc(gzFile file, int c)
|
||||
int ZEXPORT gzputc(file, c)
|
||||
gzFile file;
|
||||
int c;
|
||||
{
|
||||
unsigned char cc = (unsigned char) c; /* required for big endian systems */
|
||||
|
||||
|
@ -683,7 +690,9 @@ int ZEXPORT gzputc(gzFile file, int c)
|
|||
the terminating null character.
|
||||
gzputs returns the number of characters written, or -1 in case of error.
|
||||
*/
|
||||
int ZEXPORT gzputs(gzFile file, const char *s)
|
||||
int ZEXPORT gzputs(file, s)
|
||||
gzFile file;
|
||||
const char *s;
|
||||
{
|
||||
return gzwrite(file, (char*)s, (unsigned)strlen(s));
|
||||
}
|
||||
|
@ -693,7 +702,9 @@ int ZEXPORT gzputs(gzFile file, const char *s)
|
|||
Flushes all pending output into the compressed file. The parameter
|
||||
flush is as in the deflate() function.
|
||||
*/
|
||||
local int do_flush (gzFile file, int flush)
|
||||
local int do_flush (file, flush)
|
||||
gzFile file;
|
||||
int flush;
|
||||
{
|
||||
uInt len;
|
||||
int done = 0;
|
||||
|
@ -732,7 +743,9 @@ local int do_flush (gzFile file, int flush)
|
|||
return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
|
||||
}
|
||||
|
||||
int ZEXPORT gzflush (gzFile file, int flush)
|
||||
int ZEXPORT gzflush (file, flush)
|
||||
gzFile file;
|
||||
int flush;
|
||||
{
|
||||
gz_stream *s = (gz_stream*)file;
|
||||
int err = do_flush (file, flush);
|
||||
|
@ -751,7 +764,10 @@ int ZEXPORT gzflush (gzFile file, int flush)
|
|||
SEEK_END is not implemented, returns error.
|
||||
In this version of the library, gzseek can be extremely slow.
|
||||
*/
|
||||
z_off_t ZEXPORT gzseek (gzFile file, z_off_t offset, int whence)
|
||||
z_off_t ZEXPORT gzseek (file, offset, whence)
|
||||
gzFile file;
|
||||
z_off_t offset;
|
||||
int whence;
|
||||
{
|
||||
gz_stream *s = (gz_stream*)file;
|
||||
|
||||
|
@ -838,7 +854,8 @@ z_off_t ZEXPORT gzseek (gzFile file, z_off_t offset, int whence)
|
|||
/* ===========================================================================
|
||||
Rewinds input file.
|
||||
*/
|
||||
int ZEXPORT gzrewind (gzFile file)
|
||||
int ZEXPORT gzrewind (file)
|
||||
gzFile file;
|
||||
{
|
||||
gz_stream *s = (gz_stream*)file;
|
||||
|
||||
|
@ -861,7 +878,8 @@ int ZEXPORT gzrewind (gzFile file)
|
|||
given compressed file. This position represents a number of bytes in the
|
||||
uncompressed data stream.
|
||||
*/
|
||||
z_off_t ZEXPORT gztell (gzFile file)
|
||||
z_off_t ZEXPORT gztell (file)
|
||||
gzFile file;
|
||||
{
|
||||
return gzseek(file, 0L, SEEK_CUR);
|
||||
}
|
||||
|
@ -870,7 +888,8 @@ z_off_t ZEXPORT gztell (gzFile file)
|
|||
Returns 1 when EOF has previously been detected reading the given
|
||||
input stream, otherwise zero.
|
||||
*/
|
||||
int ZEXPORT gzeof (gzFile file)
|
||||
int ZEXPORT gzeof (file)
|
||||
gzFile file;
|
||||
{
|
||||
gz_stream *s = (gz_stream*)file;
|
||||
|
||||
|
@ -886,7 +905,9 @@ int ZEXPORT gzeof (gzFile file)
|
|||
/* ===========================================================================
|
||||
Outputs a long in LSB order to the given file
|
||||
*/
|
||||
local void putLong (FILE *file, uLong x)
|
||||
local void putLong (file, x)
|
||||
FILE *file;
|
||||
uLong x;
|
||||
{
|
||||
int n;
|
||||
for (n = 0; n < 4; n++) {
|
||||
|
@ -899,7 +920,8 @@ local void putLong (FILE *file, uLong x)
|
|||
Reads a long in LSB order from the given gz_stream. Sets z_err in case
|
||||
of error.
|
||||
*/
|
||||
local uLong getLong (gz_stream *s)
|
||||
local uLong getLong (s)
|
||||
gz_stream *s;
|
||||
{
|
||||
uLong x = (uLong)get_byte(s);
|
||||
int c;
|
||||
|
@ -916,7 +938,8 @@ local uLong getLong (gz_stream *s)
|
|||
Flushes all pending output if necessary, closes the compressed file
|
||||
and deallocates all the (de)compression state.
|
||||
*/
|
||||
int ZEXPORT gzclose (gzFile file)
|
||||
int ZEXPORT gzclose (file)
|
||||
gzFile file;
|
||||
{
|
||||
int err;
|
||||
gz_stream *s = (gz_stream*)file;
|
||||
|
@ -944,7 +967,9 @@ int ZEXPORT gzclose (gzFile file)
|
|||
errnum is set to Z_ERRNO and the application may consult errno
|
||||
to get the exact error code.
|
||||
*/
|
||||
const char * ZEXPORT gzerror (gzFile file, int *errnum)
|
||||
const char * ZEXPORT gzerror (file, errnum)
|
||||
gzFile file;
|
||||
int *errnum;
|
||||
{
|
||||
char *m;
|
||||
gz_stream *s = (gz_stream*)file;
|
||||
|
@ -972,7 +997,8 @@ const char * ZEXPORT gzerror (gzFile file, int *errnum)
|
|||
/* ===========================================================================
|
||||
Clear the error and end-of-file flags, and do the same for the real file.
|
||||
*/
|
||||
void ZEXPORT gzclearerr (gzFile file)
|
||||
void ZEXPORT gzclearerr (file)
|
||||
gzFile file;
|
||||
{
|
||||
gz_stream *s = (gz_stream*)file;
|
||||
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
#include "inffast.h"
|
||||
|
||||
/* function prototypes */
|
||||
local void fixedtables OF((struct inflate_state FAR *state))
|
||||
/*@modifies state @*/;
|
||||
local void fixedtables OF((struct inflate_state FAR *state));
|
||||
|
||||
/*
|
||||
strm provides memory allocation functions in zalloc and zfree, or
|
||||
|
@ -26,7 +25,12 @@ local void fixedtables OF((struct inflate_state FAR *state))
|
|||
windowBits is in the range 8..15, and window is a user-supplied
|
||||
window and output buffer that is 2**windowBits bytes.
|
||||
*/
|
||||
int ZEXPORT inflateBackInit_(z_stream FAR *strm, int windowBits, unsigned char FAR *window, const char *version, int stream_size)
|
||||
int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
|
||||
z_stream FAR *strm;
|
||||
int windowBits;
|
||||
unsigned char FAR *window;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
|
@ -65,7 +69,8 @@ int ZEXPORT inflateBackInit_(z_stream FAR *strm, int windowBits, unsigned char F
|
|||
used for threaded applications, since the rewriting of the tables and virgin
|
||||
may not be thread-safe.
|
||||
*/
|
||||
local void fixedtables(struct inflate_state FAR *state)
|
||||
local void fixedtables(state)
|
||||
struct inflate_state FAR *state;
|
||||
{
|
||||
#ifdef BUILDFIXED
|
||||
static int virgin = 1;
|
||||
|
@ -232,7 +237,12 @@ local void fixedtables(struct inflate_state FAR *state)
|
|||
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.
|
||||
*/
|
||||
int ZEXPORT inflateBack(z_stream FAR *strm, in_func in, void FAR *in_desc, out_func out, void FAR *out_desc)
|
||||
int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
|
||||
z_stream FAR *strm;
|
||||
in_func in;
|
||||
void FAR *in_desc;
|
||||
out_func out;
|
||||
void FAR *out_desc;
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
unsigned char FAR *next; /* next input */
|
||||
|
@ -424,6 +434,9 @@ int ZEXPORT inflateBack(z_stream FAR *strm, in_func in, void FAR *in_desc, out_f
|
|||
}
|
||||
}
|
||||
|
||||
/* handle error breaks in while */
|
||||
if (state->mode == BAD) break;
|
||||
|
||||
/* build code tables */
|
||||
state->next = state->codes;
|
||||
state->lencode = (code const FAR *)(state->next);
|
||||
|
@ -597,7 +610,8 @@ int ZEXPORT inflateBack(z_stream FAR *strm, in_func in, void FAR *in_desc, out_f
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateBackEnd(z_stream FAR *strm)
|
||||
int ZEXPORT inflateBackEnd(strm)
|
||||
z_stream FAR *strm;
|
||||
{
|
||||
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
|
||||
return Z_STREAM_ERROR;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* inffast.c -- fast decoding
|
||||
* Copyright (C) 1995-2003 Mark Adler
|
||||
* Copyright (C) 1995-2004 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
|||
- none
|
||||
No measurable difference:
|
||||
- Pentium III (Anderson)
|
||||
- 68060 (Nikl)
|
||||
- M68060 (Nikl)
|
||||
*/
|
||||
#ifdef POSTINC
|
||||
# define OFF 0
|
||||
|
@ -64,7 +64,9 @@
|
|||
requires strm->avail_out >= 258 for each loop to avoid checking for
|
||||
output space.
|
||||
*/
|
||||
void inflate_fast(z_streamp strm, unsigned start)
|
||||
void inflate_fast(strm, start)
|
||||
z_streamp strm;
|
||||
unsigned start; /* inflate()'s starting value for strm->avail_out */
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
unsigned char FAR *in; /* local strm->next_in */
|
||||
|
|
|
@ -8,5 +8,4 @@
|
|||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
void inflate_fast OF((z_streamp strm, unsigned start))
|
||||
/*@modifies strm @*/;
|
||||
void inflate_fast OF((z_streamp strm, unsigned start));
|
||||
|
|
|
@ -92,19 +92,16 @@
|
|||
#endif
|
||||
|
||||
/* function prototypes */
|
||||
local void fixedtables OF((struct inflate_state FAR *state))
|
||||
/*@modifies state @*/;
|
||||
local int updatewindow OF((z_streamp strm, unsigned out))
|
||||
/*@*/;
|
||||
local void fixedtables OF((struct inflate_state FAR *state));
|
||||
local int updatewindow OF((z_streamp strm, unsigned out));
|
||||
#ifdef BUILDFIXED
|
||||
void makefixed OF((void))
|
||||
/*@*/;
|
||||
void makefixed OF((void));
|
||||
#endif
|
||||
local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
|
||||
unsigned len))
|
||||
/*@modifies *have @*/;
|
||||
unsigned len));
|
||||
|
||||
int ZEXPORT inflateReset(z_streamp strm)
|
||||
int ZEXPORT inflateReset(strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
|
@ -124,7 +121,11 @@ int ZEXPORT inflateReset(z_streamp strm)
|
|||
return Z_OK;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version, int stream_size)
|
||||
int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
|
||||
z_streamp strm;
|
||||
int windowBits;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
|
@ -163,7 +164,10 @@ int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, const char *version, i
|
|||
return inflateReset(strm);
|
||||
}
|
||||
|
||||
int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
|
||||
int ZEXPORT inflateInit_(strm, version, stream_size)
|
||||
z_streamp strm;
|
||||
const char *version;
|
||||
int stream_size;
|
||||
{
|
||||
return inflateInit2_(strm, DEF_WBITS, version, stream_size);
|
||||
}
|
||||
|
@ -178,7 +182,8 @@ int ZEXPORT inflateInit_(z_streamp strm, const char *version, int stream_size)
|
|||
used for threaded applications, since the rewriting of the tables and virgin
|
||||
may not be thread-safe.
|
||||
*/
|
||||
local void fixedtables(struct inflate_state FAR *state)
|
||||
local void fixedtables(state)
|
||||
struct inflate_state FAR *state;
|
||||
{
|
||||
#ifdef BUILDFIXED
|
||||
static int virgin = 1;
|
||||
|
@ -241,7 +246,7 @@ local void fixedtables(struct inflate_state FAR *state)
|
|||
|
||||
a.out > inffixed.h
|
||||
*/
|
||||
void makefixed(void)
|
||||
void makefixed()
|
||||
{
|
||||
unsigned low, size;
|
||||
struct inflate_state state;
|
||||
|
@ -295,7 +300,9 @@ void makefixed(void)
|
|||
output will fall in the output data, making match copies simpler and faster.
|
||||
The advantage may be dependent on the size of the processor's data caches.
|
||||
*/
|
||||
local int updatewindow(z_streamp strm, unsigned out)
|
||||
local int updatewindow(strm, out)
|
||||
z_streamp strm;
|
||||
unsigned out;
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
unsigned copy, dist;
|
||||
|
@ -524,7 +531,9 @@ local int updatewindow(z_streamp strm, unsigned out)
|
|||
will return Z_BUF_ERROR if it has not reached the end of the stream.
|
||||
*/
|
||||
|
||||
int ZEXPORT inflate(z_streamp strm, int flush)
|
||||
int ZEXPORT inflate(strm, flush)
|
||||
z_streamp strm;
|
||||
int flush;
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
unsigned char FAR *next; /* next input */
|
||||
|
@ -852,6 +861,9 @@ int ZEXPORT inflate(z_streamp strm, int flush)
|
|||
}
|
||||
}
|
||||
|
||||
/* handle error breaks in while */
|
||||
if (state->mode == BAD) break;
|
||||
|
||||
/* build code tables */
|
||||
state->next = state->codes;
|
||||
state->lencode = (code const FAR *)(state->next);
|
||||
|
@ -1072,7 +1084,8 @@ int ZEXPORT inflate(z_streamp strm, int flush)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateEnd(z_streamp strm)
|
||||
int ZEXPORT inflateEnd(strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
|
||||
|
@ -1085,7 +1098,10 @@ int ZEXPORT inflateEnd(z_streamp strm)
|
|||
return Z_OK;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt dictLength)
|
||||
int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
|
||||
z_streamp strm;
|
||||
const Bytef *dictionary;
|
||||
uInt dictLength;
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
unsigned long id;
|
||||
|
@ -1131,7 +1147,10 @@ int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, uInt d
|
|||
called again with more data and the *have state. *have is initialized to
|
||||
zero for the first call.
|
||||
*/
|
||||
local unsigned syncsearch(unsigned FAR *have, unsigned char FAR *buf, unsigned len)
|
||||
local unsigned syncsearch(have, buf, len)
|
||||
unsigned FAR *have;
|
||||
unsigned char FAR *buf;
|
||||
unsigned len;
|
||||
{
|
||||
unsigned got;
|
||||
unsigned next;
|
||||
|
@ -1151,7 +1170,8 @@ local unsigned syncsearch(unsigned FAR *have, unsigned char FAR *buf, unsigned l
|
|||
return next;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateSync(z_streamp strm)
|
||||
int ZEXPORT inflateSync(strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
unsigned len; /* number of bytes to look at or looked at */
|
||||
unsigned long in, out; /* temporary to save total_in and total_out */
|
||||
|
@ -1201,7 +1221,8 @@ int ZEXPORT inflateSync(z_streamp strm)
|
|||
block. When decompressing, PPP checks that at the end of input packet,
|
||||
inflate is waiting for these length bytes.
|
||||
*/
|
||||
int ZEXPORT inflateSyncPoint(z_streamp strm)
|
||||
int ZEXPORT inflateSyncPoint(strm)
|
||||
z_streamp strm;
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
|
@ -1210,7 +1231,9 @@ int ZEXPORT inflateSyncPoint(z_streamp strm)
|
|||
return state->mode == STORED && state->bits == 0;
|
||||
}
|
||||
|
||||
int ZEXPORT inflateCopy(z_streamp dest, z_streamp source)
|
||||
int ZEXPORT inflateCopy(dest, source)
|
||||
z_streamp dest;
|
||||
z_streamp source;
|
||||
{
|
||||
struct inflate_state FAR *state;
|
||||
struct inflate_state FAR *copy;
|
||||
|
|
|
@ -101,9 +101,7 @@ struct inflate_state {
|
|||
/* for table and code decoding */
|
||||
unsigned extra; /* extra bits needed */
|
||||
/* fixed and dynamic code tables */
|
||||
/*@shared@*/
|
||||
code const FAR *lencode; /* starting table for length/literal codes */
|
||||
/*@shared@*/
|
||||
code const FAR *distcode; /* starting table for distance codes */
|
||||
unsigned lenbits; /* index bits for lencode */
|
||||
unsigned distbits; /* index bits for distcode */
|
||||
|
@ -112,7 +110,6 @@ struct inflate_state {
|
|||
unsigned nlen; /* number of length code lengths */
|
||||
unsigned ndist; /* number of distance code lengths */
|
||||
unsigned have; /* number of code lengths in lens[] */
|
||||
/*@shared@*/
|
||||
code FAR *next; /* next available space in codes[] */
|
||||
unsigned short lens[320]; /* temporary storage for code lengths */
|
||||
unsigned short work[288]; /* work area for code table building */
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#define MAXBITS 15
|
||||
|
||||
const char inflate_copyright[] =
|
||||
" inflate 1.2.1.1 Copyright 1995-2004 Mark Adler ";
|
||||
" inflate 1.2.1.2 Copyright 1995-2004 Mark Adler ";
|
||||
/*
|
||||
If you use the zlib library in a product, an acknowledgment is welcome
|
||||
in the documentation of your product. If for some reason you cannot
|
||||
|
@ -29,7 +29,13 @@ const char inflate_copyright[] =
|
|||
table index bits. It will differ if the request is greater than the
|
||||
longest code or if it is less than the shortest code.
|
||||
*/
|
||||
int inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code FAR * FAR *table, unsigned FAR *bits, unsigned short FAR *work)
|
||||
int inflate_table(type, lens, codes, table, bits, work)
|
||||
codetype type;
|
||||
unsigned short FAR *lens;
|
||||
unsigned codes;
|
||||
code FAR * FAR *table;
|
||||
unsigned FAR *bits;
|
||||
unsigned short FAR *work;
|
||||
{
|
||||
unsigned len; /* a code's length in bits */
|
||||
unsigned sym; /* index of code symbols */
|
||||
|
@ -56,7 +62,7 @@ int inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code
|
|||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 202, 196};
|
||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 194};
|
||||
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||
|
@ -297,7 +303,6 @@ int inflate_table(codetype type, unsigned short FAR *lens, unsigned codes, code
|
|||
drop = 0;
|
||||
len = root;
|
||||
next = *table;
|
||||
curr = root;
|
||||
this.bits = (unsigned char)len;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,5 +52,4 @@ typedef enum {
|
|||
|
||||
extern int inflate_table OF((codetype type, unsigned short FAR *lens,
|
||||
unsigned codes, code FAR * FAR *table,
|
||||
unsigned FAR *bits, unsigned short FAR *work))
|
||||
/*@modifies *lens, *table, *bits, *work @*/;
|
||||
unsigned FAR *bits, unsigned short FAR *work));
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
# include <unix.h> /* for fileno */
|
||||
#endif
|
||||
|
||||
#if !defined(WIN32) && !defined(__LCLINT__) /* unlink already in stdio.h for WIN32 */
|
||||
#ifndef WIN32 /* unlink already in stdio.h for WIN32 */
|
||||
extern int unlink OF((const char *));
|
||||
#endif
|
||||
|
||||
|
@ -64,57 +64,42 @@
|
|||
#define BUFLEN 16384
|
||||
#define MAX_NAME_LEN 1024
|
||||
|
||||
#if defined(MAXSEG_64K) || defined(__LCLINT__)
|
||||
#ifdef MAXSEG_64K
|
||||
# define local static
|
||||
/* Needed for systems with limitation on stack size. */
|
||||
#else
|
||||
# define local
|
||||
#endif
|
||||
|
||||
/*@unchecked@*/
|
||||
local char *prog;
|
||||
char *prog;
|
||||
|
||||
local void error OF((const char *msg))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies fileSystem @*/;
|
||||
local void gz_compress OF((FILE *in, gzFile out))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies in, out, fileSystem @*/;
|
||||
void error OF((const char *msg));
|
||||
void gz_compress OF((FILE *in, gzFile out));
|
||||
#ifdef USE_MMAP
|
||||
local int gz_compress_mmap OF((FILE *in, gzFile out))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies in, out, fileSystem @*/;
|
||||
int gz_compress_mmap OF((FILE *in, gzFile out));
|
||||
#endif
|
||||
local void gz_uncompress OF((gzFile in, FILE *out))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies in, out, fileSystem @*/;
|
||||
local void file_compress OF((char *file, char *mode))
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
local void file_uncompress OF((char *file))
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
int main OF((int argc, char *argv[]))
|
||||
/*@globals prog, fileSystem, internalState @*/
|
||||
/*@modifies prog, fileSystem, internalState @*/;
|
||||
void gz_uncompress OF((gzFile in, FILE *out));
|
||||
void file_compress OF((char *file, char *mode));
|
||||
void file_uncompress OF((char *file));
|
||||
int main OF((int argc, char *argv[]));
|
||||
|
||||
/* ===========================================================================
|
||||
* Display error message and exit
|
||||
*/
|
||||
void error(const char *msg)
|
||||
void error(msg)
|
||||
const char *msg;
|
||||
{
|
||||
fprintf(stderr, "%s: %s\n", prog, msg);
|
||||
#ifndef EXIT_FAILURE
|
||||
#define EXIT_FAILURE 1
|
||||
#endif
|
||||
exit(EXIT_FAILURE);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Compress input to output then close both files.
|
||||
*/
|
||||
|
||||
void gz_compress(FILE *in, gzFile out)
|
||||
void gz_compress(in, out)
|
||||
FILE *in;
|
||||
gzFile out;
|
||||
{
|
||||
local char buf[BUFLEN];
|
||||
int len;
|
||||
|
@ -130,7 +115,7 @@ void gz_compress(FILE *in, gzFile out)
|
|||
len = (int)fread(buf, 1, sizeof(buf), in);
|
||||
if (ferror(in)) {
|
||||
perror("fread");
|
||||
exit(EXIT_FAILURE);
|
||||
exit(1);
|
||||
}
|
||||
if (len == 0) break;
|
||||
|
||||
|
@ -145,7 +130,9 @@ void gz_compress(FILE *in, gzFile out)
|
|||
/* Try compressing the input file at once using mmap. Return Z_OK if
|
||||
* if success, Z_ERRNO otherwise.
|
||||
*/
|
||||
int gz_compress_mmap(FILE *in, gzFile out)
|
||||
int gz_compress_mmap(in, out)
|
||||
FILE *in;
|
||||
gzFile out;
|
||||
{
|
||||
int len;
|
||||
int err;
|
||||
|
@ -178,7 +165,9 @@ int gz_compress_mmap(FILE *in, gzFile out)
|
|||
/* ===========================================================================
|
||||
* Uncompress input to output then close both files.
|
||||
*/
|
||||
void gz_uncompress(gzFile in, FILE *out)
|
||||
void gz_uncompress(in, out)
|
||||
gzFile in;
|
||||
FILE *out;
|
||||
{
|
||||
local char buf[BUFLEN];
|
||||
int len;
|
||||
|
@ -203,7 +192,9 @@ void gz_uncompress(gzFile in, FILE *out)
|
|||
* Compress the given file: create a corresponding .gz file and remove the
|
||||
* original.
|
||||
*/
|
||||
void file_compress(char *file, char *mode)
|
||||
void file_compress(file, mode)
|
||||
char *file;
|
||||
char *mode;
|
||||
{
|
||||
local char outfile[MAX_NAME_LEN];
|
||||
FILE *in;
|
||||
|
@ -215,12 +206,12 @@ void file_compress(char *file, char *mode)
|
|||
in = fopen(file, "rb");
|
||||
if (in == NULL) {
|
||||
perror(file);
|
||||
exit(EXIT_FAILURE);
|
||||
exit(1);
|
||||
}
|
||||
out = gzopen(outfile, mode);
|
||||
if (out == NULL) {
|
||||
fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile);
|
||||
exit(EXIT_FAILURE);
|
||||
exit(1);
|
||||
}
|
||||
gz_compress(in, out);
|
||||
|
||||
|
@ -231,7 +222,8 @@ void file_compress(char *file, char *mode)
|
|||
/* ===========================================================================
|
||||
* Uncompress the given file and remove the original.
|
||||
*/
|
||||
void file_uncompress(char *file)
|
||||
void file_uncompress(file)
|
||||
char *file;
|
||||
{
|
||||
local char buf[MAX_NAME_LEN];
|
||||
char *infile, *outfile;
|
||||
|
@ -253,12 +245,12 @@ void file_uncompress(char *file)
|
|||
in = gzopen(infile, "rb");
|
||||
if (in == NULL) {
|
||||
fprintf(stderr, "%s: can't gzopen %s\n", prog, infile);
|
||||
exit(EXIT_FAILURE);
|
||||
exit(1);
|
||||
}
|
||||
out = fopen(outfile, "wb");
|
||||
if (out == NULL) {
|
||||
perror(file);
|
||||
exit(EXIT_FAILURE);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
gz_uncompress(in, out);
|
||||
|
@ -276,7 +268,9 @@ void file_uncompress(char *file)
|
|||
* -1 to -9 : compression level
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
{
|
||||
int uncompr = 0;
|
||||
gzFile file;
|
||||
|
|
|
@ -25,10 +25,10 @@
|
|||
<QPG:Files>
|
||||
<QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/>
|
||||
<QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/>
|
||||
<QPG:Add file="../libz.so.1.2.1.1" install="/opt/lib/" user="root:bin" permission="644"/>
|
||||
<QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.1.1"/>
|
||||
<QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.1.1"/>
|
||||
<QPG:Add file="../libz.so.1.2.1.1" install="/opt/lib/" component="slib"/>
|
||||
<QPG:Add file="../libz.so.1.2.1.2" install="/opt/lib/" user="root:bin" permission="644"/>
|
||||
<QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.1.2"/>
|
||||
<QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.1.2"/>
|
||||
<QPG:Add file="../libz.so.1.2.1.2" install="/opt/lib/" component="slib"/>
|
||||
</QPG:Files>
|
||||
|
||||
<QPG:PackageFilter>
|
||||
|
@ -63,7 +63,7 @@
|
|||
</QPM:ProductDescription>
|
||||
|
||||
<QPM:ReleaseDescription>
|
||||
<QPM:ReleaseVersion>1.2.1.1</QPM:ReleaseVersion>
|
||||
<QPM:ReleaseVersion>1.2.1.2</QPM:ReleaseVersion>
|
||||
<QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
|
||||
<QPM:ReleaseStability>Stable</QPM:ReleaseStability>
|
||||
<QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>
|
||||
|
|
169
zlib/trees.c
169
zlib/trees.c
|
@ -58,19 +58,15 @@
|
|||
#define REPZ_11_138 18
|
||||
/* repeat a zero length 11-138 times (7 bits of repeat count) */
|
||||
|
||||
/*@unchecked@*/ /*@observer@*/
|
||||
local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
|
||||
= {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
|
||||
|
||||
/*@unchecked@*/ /*@observer@*/
|
||||
local const int extra_dbits[D_CODES] /* extra bits for each distance code */
|
||||
= {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
|
||||
|
||||
/*@unchecked@*/ /*@observer@*/
|
||||
local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
|
||||
= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
|
||||
|
||||
/*@unchecked@*/ /*@observer@*/
|
||||
local const uch bl_order[BL_CODES]
|
||||
= {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
|
||||
/* The lengths of the bit length codes are sent in order of decreasing
|
||||
|
@ -91,7 +87,6 @@ local const uch bl_order[BL_CODES]
|
|||
#if defined(GEN_TREES_H) || !defined(STDC)
|
||||
/* non ANSI compilers may not accept trees.h */
|
||||
|
||||
/*@unchecked@*/
|
||||
local ct_data static_ltree[L_CODES+2];
|
||||
/* The static literal tree. Since the bit lengths are imposed, there is no
|
||||
* need for the L_CODES extra codes used during heap construction. However
|
||||
|
@ -99,7 +94,6 @@ local ct_data static_ltree[L_CODES+2];
|
|||
* below).
|
||||
*/
|
||||
|
||||
/*@unchecked@*/
|
||||
local ct_data static_dtree[D_CODES];
|
||||
/* The static distance tree. (Actually a trivial tree since all codes use
|
||||
* 5 bits.)
|
||||
|
@ -114,11 +108,9 @@ uch _dist_code[DIST_CODE_LEN];
|
|||
uch _length_code[MAX_MATCH-MIN_MATCH+1];
|
||||
/* length code for each normalized match length (0 == MIN_MATCH) */
|
||||
|
||||
/*@unchecked@*/
|
||||
local int base_length[LENGTH_CODES];
|
||||
/* First normalized length for each code (0 = MIN_MATCH) */
|
||||
|
||||
/*@unchecked@*/
|
||||
local int base_dist[D_CODES];
|
||||
/* First normalized distance for each code (0 = distance of 1) */
|
||||
|
||||
|
@ -127,24 +119,19 @@ local int base_dist[D_CODES];
|
|||
#endif /* GEN_TREES_H */
|
||||
|
||||
struct static_tree_desc_s {
|
||||
/*@observer@*/ /*@relnull@*/
|
||||
const ct_data *static_tree; /* static tree or NULL */
|
||||
/*@observer@*/
|
||||
const intf *extra_bits; /* extra bits for each code or NULL */
|
||||
int extra_base; /* base index for extra_bits */
|
||||
int elems; /* max number of elements in the tree */
|
||||
int max_length; /* max bit length for the codes */
|
||||
};
|
||||
|
||||
/*@unchecked@*/
|
||||
local static_tree_desc static_l_desc =
|
||||
{static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS};
|
||||
|
||||
/*@unchecked@*/
|
||||
local static_tree_desc static_d_desc =
|
||||
{static_dtree, extra_dbits, 0, D_CODES, MAX_BITS};
|
||||
|
||||
/*@unchecked@*/
|
||||
local static_tree_desc static_bl_desc =
|
||||
{(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
|
||||
|
||||
|
@ -152,46 +139,28 @@ local static_tree_desc static_bl_desc =
|
|||
* Local (static) routines in this file.
|
||||
*/
|
||||
|
||||
local void tr_static_init OF((void))
|
||||
/*@globals internalState @*/
|
||||
/*@modifies internalState @*/;
|
||||
local void init_block OF((deflate_state *s))
|
||||
/*@modifies *s @*/;
|
||||
local void pqdownheap OF((deflate_state *s, ct_data *tree, int k))
|
||||
/*@modifies *s @*/;
|
||||
local void gen_bitlen OF((deflate_state *s, tree_desc *desc))
|
||||
/*@modifies *s, *desc @*/;
|
||||
local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count))
|
||||
/*@modifies *tree @*/;
|
||||
local void build_tree OF((deflate_state *s, tree_desc *desc))
|
||||
/*@modifies *s, *desc @*/;
|
||||
local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code))
|
||||
/*@modifies *s, *tree @*/;
|
||||
local void send_tree OF((deflate_state *s, ct_data *tree, int max_code))
|
||||
/*@modifies *s @*/;
|
||||
local int build_bl_tree OF((deflate_state *s))
|
||||
/*@modifies *s @*/;
|
||||
local void tr_static_init OF((void));
|
||||
local void init_block OF((deflate_state *s));
|
||||
local void pqdownheap OF((deflate_state *s, ct_data *tree, int k));
|
||||
local void gen_bitlen OF((deflate_state *s, tree_desc *desc));
|
||||
local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count));
|
||||
local void build_tree OF((deflate_state *s, tree_desc *desc));
|
||||
local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code));
|
||||
local void send_tree OF((deflate_state *s, ct_data *tree, int max_code));
|
||||
local int build_bl_tree OF((deflate_state *s));
|
||||
local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes,
|
||||
int blcodes))
|
||||
/*@modifies *s @*/;
|
||||
int blcodes));
|
||||
local void compress_block OF((deflate_state *s, ct_data *ltree,
|
||||
ct_data *dtree))
|
||||
/*@modifies *s @*/;
|
||||
local void set_data_type OF((deflate_state *s))
|
||||
/*@modifies *s @*/;
|
||||
local unsigned bi_reverse OF((unsigned value, int length))
|
||||
/*@*/;
|
||||
local void bi_windup OF((deflate_state *s))
|
||||
/*@modifies *s @*/;
|
||||
local void bi_flush OF((deflate_state *s))
|
||||
/*@modifies *s @*/;
|
||||
ct_data *dtree));
|
||||
local void set_data_type OF((deflate_state *s));
|
||||
local unsigned bi_reverse OF((unsigned value, int length));
|
||||
local void bi_windup OF((deflate_state *s));
|
||||
local void bi_flush OF((deflate_state *s));
|
||||
local void copy_block OF((deflate_state *s, charf *buf, unsigned len,
|
||||
int header))
|
||||
/*@modifies *s @*/;
|
||||
int header));
|
||||
|
||||
#ifdef GEN_TREES_H
|
||||
local void gen_trees_header OF((void))
|
||||
/*@*/;
|
||||
local void gen_trees_header OF((void));
|
||||
#endif
|
||||
|
||||
#ifndef DEBUG
|
||||
|
@ -218,10 +187,12 @@ local void gen_trees_header OF((void))
|
|||
* IN assertion: length <= 16 and value fits in length bits.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
local void send_bits OF((deflate_state *s, int value, int length))
|
||||
/*@*/;
|
||||
local void send_bits OF((deflate_state *s, int value, int length));
|
||||
|
||||
local void send_bits(deflate_state *s, int value, int length)
|
||||
local void send_bits(s, value, length)
|
||||
deflate_state *s;
|
||||
int value; /* value to send */
|
||||
int length; /* number of bits */
|
||||
{
|
||||
Tracevv((stderr," l %2d v %4x ", length, value));
|
||||
Assert(length > 0 && length <= 15, "invalid length");
|
||||
|
@ -264,7 +235,7 @@ local void send_bits(deflate_state *s, int value, int length)
|
|||
/* ===========================================================================
|
||||
* Initialize the various 'constant' tables.
|
||||
*/
|
||||
local void tr_static_init(void)
|
||||
local void tr_static_init()
|
||||
{
|
||||
#if defined(GEN_TREES_H) || !defined(STDC)
|
||||
static int static_init_done = 0;
|
||||
|
@ -356,7 +327,7 @@ local void tr_static_init(void)
|
|||
((i) == (last)? "\n};\n\n" : \
|
||||
((i) % (width) == (width)-1 ? ",\n" : ", "))
|
||||
|
||||
void gen_trees_header(void)
|
||||
void gen_trees_header()
|
||||
{
|
||||
FILE *header = fopen("trees.h", "w");
|
||||
int i;
|
||||
|
@ -408,7 +379,8 @@ void gen_trees_header(void)
|
|||
/* ===========================================================================
|
||||
* Initialize the tree data structures for a new zlib stream.
|
||||
*/
|
||||
void _tr_init(deflate_state *s)
|
||||
void _tr_init(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
tr_static_init();
|
||||
|
||||
|
@ -436,7 +408,8 @@ void _tr_init(deflate_state *s)
|
|||
/* ===========================================================================
|
||||
* Initialize a new block.
|
||||
*/
|
||||
local void init_block(deflate_state *s)
|
||||
local void init_block(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
int n; /* iterates over tree elements */
|
||||
|
||||
|
@ -479,7 +452,10 @@ local void init_block(deflate_state *s)
|
|||
* when the heap property is re-established (each father smaller than its
|
||||
* two sons).
|
||||
*/
|
||||
local void pqdownheap(deflate_state *s, ct_data *tree, int k)
|
||||
local void pqdownheap(s, tree, k)
|
||||
deflate_state *s;
|
||||
ct_data *tree; /* the tree to restore */
|
||||
int k; /* node to move down */
|
||||
{
|
||||
int v = s->heap[k];
|
||||
int j = k << 1; /* left son of k */
|
||||
|
@ -511,7 +487,9 @@ local void pqdownheap(deflate_state *s, ct_data *tree, int k)
|
|||
* The length opt_len is updated; static_len is also updated if stree is
|
||||
* not null.
|
||||
*/
|
||||
local void gen_bitlen(deflate_state *s, tree_desc *desc)
|
||||
local void gen_bitlen(s, desc)
|
||||
deflate_state *s;
|
||||
tree_desc *desc; /* the tree descriptor */
|
||||
{
|
||||
ct_data *tree = desc->dyn_tree;
|
||||
int max_code = desc->max_code;
|
||||
|
@ -596,7 +574,10 @@ local void gen_bitlen(deflate_state *s, tree_desc *desc)
|
|||
* OUT assertion: the field code is set for all tree elements of non
|
||||
* zero code length.
|
||||
*/
|
||||
local void gen_codes (ct_data *tree, int max_code, ushf *bl_count)
|
||||
local void gen_codes (tree, max_code, bl_count)
|
||||
ct_data *tree; /* the tree to decorate */
|
||||
int max_code; /* largest code with non zero frequency */
|
||||
ushf *bl_count; /* number of codes at each bit length */
|
||||
{
|
||||
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
|
||||
ush code = 0; /* running code value */
|
||||
|
@ -635,7 +616,9 @@ local void gen_codes (ct_data *tree, int max_code, ushf *bl_count)
|
|||
* and corresponding code. The length opt_len is updated; static_len is
|
||||
* also updated if stree is not null. The field max_code is set.
|
||||
*/
|
||||
local void build_tree(deflate_state *s, tree_desc *desc)
|
||||
local void build_tree(s, desc)
|
||||
deflate_state *s;
|
||||
tree_desc *desc; /* the tree descriptor */
|
||||
{
|
||||
ct_data *tree = desc->dyn_tree;
|
||||
const ct_data *stree = desc->stat_desc->static_tree;
|
||||
|
@ -721,7 +704,10 @@ local void build_tree(deflate_state *s, tree_desc *desc)
|
|||
* Scan a literal or distance tree to determine the frequencies of the codes
|
||||
* in the bit length tree.
|
||||
*/
|
||||
local void scan_tree (deflate_state *s, ct_data *tree, int max_code)
|
||||
local void scan_tree (s, tree, max_code)
|
||||
deflate_state *s;
|
||||
ct_data *tree; /* the tree to be scanned */
|
||||
int max_code; /* and its largest code of non zero frequency */
|
||||
{
|
||||
int n; /* iterates over all tree elements */
|
||||
int prevlen = -1; /* last emitted length */
|
||||
|
@ -763,7 +749,10 @@ local void scan_tree (deflate_state *s, ct_data *tree, int max_code)
|
|||
* Send a literal or distance tree in compressed form, using the codes in
|
||||
* bl_tree.
|
||||
*/
|
||||
local void send_tree (deflate_state *s, ct_data *tree, int max_code)
|
||||
local void send_tree (s, tree, max_code)
|
||||
deflate_state *s;
|
||||
ct_data *tree; /* the tree to be scanned */
|
||||
int max_code; /* and its largest code of non zero frequency */
|
||||
{
|
||||
int n; /* iterates over all tree elements */
|
||||
int prevlen = -1; /* last emitted length */
|
||||
|
@ -811,7 +800,8 @@ local void send_tree (deflate_state *s, ct_data *tree, int max_code)
|
|||
* Construct the Huffman tree for the bit lengths and return the index in
|
||||
* bl_order of the last bit length code to send.
|
||||
*/
|
||||
local int build_bl_tree(deflate_state *s)
|
||||
local int build_bl_tree(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
int max_blindex; /* index of last bit length code of non zero freq */
|
||||
|
||||
|
@ -845,7 +835,9 @@ local int build_bl_tree(deflate_state *s)
|
|||
* lengths of the bit length codes, the literal tree and the distance tree.
|
||||
* IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
|
||||
*/
|
||||
local void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes)
|
||||
local void send_all_trees(s, lcodes, dcodes, blcodes)
|
||||
deflate_state *s;
|
||||
int lcodes, dcodes, blcodes; /* number of codes for each tree */
|
||||
{
|
||||
int rank; /* index in bl_order */
|
||||
|
||||
|
@ -872,7 +864,11 @@ local void send_all_trees(deflate_state *s, int lcodes, int dcodes, int blcodes)
|
|||
/* ===========================================================================
|
||||
* Send a stored block
|
||||
*/
|
||||
void _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int eof)
|
||||
void _tr_stored_block(s, buf, stored_len, eof)
|
||||
deflate_state *s;
|
||||
charf *buf; /* input block */
|
||||
ulg stored_len; /* length of input block */
|
||||
int eof; /* true if this is the last block for a file */
|
||||
{
|
||||
send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
|
||||
#ifdef DEBUG
|
||||
|
@ -893,8 +889,8 @@ void _tr_stored_block(deflate_state *s, charf *buf, ulg stored_len, int eof)
|
|||
* To simplify the code, we assume the worst case of last real code encoded
|
||||
* on one bit only.
|
||||
*/
|
||||
void _tr_align(deflate_state *s)
|
||||
/*@globals static_ltree @*/
|
||||
void _tr_align(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
send_bits(s, STATIC_TREES<<1, 3);
|
||||
send_code(s, END_BLOCK, static_ltree);
|
||||
|
@ -922,8 +918,11 @@ void _tr_align(deflate_state *s)
|
|||
* Determine the best encoding for the current block: dynamic trees, static
|
||||
* trees or store, and output the encoded block to the zip file.
|
||||
*/
|
||||
void _tr_flush_block(deflate_state *s, charf *buf, ulg stored_len, int eof)
|
||||
/*@globals static_dtree, static_ltree @*/
|
||||
void _tr_flush_block(s, buf, stored_len, eof)
|
||||
deflate_state *s;
|
||||
charf *buf; /* input block, or NULL if too old */
|
||||
ulg stored_len; /* length of input block */
|
||||
int eof; /* true if this is the last block for a file */
|
||||
{
|
||||
ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
|
||||
int max_blindex = 0; /* index of last bit length code of non zero freq */
|
||||
|
@ -932,7 +931,7 @@ void _tr_flush_block(deflate_state *s, charf *buf, ulg stored_len, int eof)
|
|||
if (s->level > 0) {
|
||||
|
||||
/* Check if the file is ascii or binary */
|
||||
if (s->data_type == Z_UNKNOWN) set_data_type(s);
|
||||
if (s->strm->data_type == Z_UNKNOWN) set_data_type(s);
|
||||
|
||||
/* Construct the literal and distance trees */
|
||||
build_tree(s, (tree_desc *)(&(s->l_desc)));
|
||||
|
@ -1019,7 +1018,10 @@ void _tr_flush_block(deflate_state *s, charf *buf, ulg stored_len, int eof)
|
|||
* Save the match info and tally the frequency counts. Return true if
|
||||
* the current block must be flushed.
|
||||
*/
|
||||
int _tr_tally (deflate_state *s, unsigned dist, unsigned lc)
|
||||
int _tr_tally (s, dist, lc)
|
||||
deflate_state *s;
|
||||
unsigned dist; /* distance of matched string */
|
||||
unsigned lc; /* match length-MIN_MATCH or unmatched char (if dist==0) */
|
||||
{
|
||||
s->d_buf[s->last_lit] = (ush)dist;
|
||||
s->l_buf[s->last_lit++] = (uch)lc;
|
||||
|
@ -1066,8 +1068,10 @@ int _tr_tally (deflate_state *s, unsigned dist, unsigned lc)
|
|||
/* ===========================================================================
|
||||
* Send the block data compressed using the given Huffman trees
|
||||
*/
|
||||
local void compress_block(deflate_state *s, ct_data *ltree, ct_data *dtree)
|
||||
/*@globals base_dist, base_length @*/
|
||||
local void compress_block(s, ltree, dtree)
|
||||
deflate_state *s;
|
||||
ct_data *ltree; /* literal tree */
|
||||
ct_data *dtree; /* distance tree */
|
||||
{
|
||||
unsigned dist; /* distance of matched string */
|
||||
int lc; /* match length or unmatched char (if dist == 0) */
|
||||
|
@ -1118,7 +1122,8 @@ local void compress_block(deflate_state *s, ct_data *ltree, ct_data *dtree)
|
|||
* IN assertion: the fields freq of dyn_ltree are set and the total of all
|
||||
* frequencies does not exceed 64K (to fit in an int on 16 bit machines).
|
||||
*/
|
||||
local void set_data_type(deflate_state *s)
|
||||
local void set_data_type(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
int n = 0;
|
||||
unsigned ascii_freq = 0;
|
||||
|
@ -1126,7 +1131,7 @@ local void set_data_type(deflate_state *s)
|
|||
while (n < 7) bin_freq += s->dyn_ltree[n++].Freq;
|
||||
while (n < 128) ascii_freq += s->dyn_ltree[n++].Freq;
|
||||
while (n < LITERALS) bin_freq += s->dyn_ltree[n++].Freq;
|
||||
s->data_type = (Byte)(bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII);
|
||||
s->strm->data_type = bin_freq > (ascii_freq >> 2) ? Z_BINARY : Z_ASCII;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
|
@ -1134,7 +1139,9 @@ local void set_data_type(deflate_state *s)
|
|||
* method would use a table)
|
||||
* IN assertion: 1 <= len <= 15
|
||||
*/
|
||||
local unsigned bi_reverse(unsigned code, int len)
|
||||
local unsigned bi_reverse(code, len)
|
||||
unsigned code; /* the value to invert */
|
||||
int len; /* its bit length */
|
||||
{
|
||||
register unsigned res = 0;
|
||||
do {
|
||||
|
@ -1147,7 +1154,8 @@ local unsigned bi_reverse(unsigned code, int len)
|
|||
/* ===========================================================================
|
||||
* Flush the bit buffer, keeping at most 7 bits in it.
|
||||
*/
|
||||
local void bi_flush(deflate_state *s)
|
||||
local void bi_flush(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
if (s->bi_valid == 16) {
|
||||
put_short(s, s->bi_buf);
|
||||
|
@ -1163,7 +1171,8 @@ local void bi_flush(deflate_state *s)
|
|||
/* ===========================================================================
|
||||
* Flush the bit buffer and align the output on a byte boundary
|
||||
*/
|
||||
local void bi_windup(deflate_state *s)
|
||||
local void bi_windup(s)
|
||||
deflate_state *s;
|
||||
{
|
||||
if (s->bi_valid > 8) {
|
||||
put_short(s, s->bi_buf);
|
||||
|
@ -1181,7 +1190,11 @@ local void bi_windup(deflate_state *s)
|
|||
* Copy a stored block, storing first the length and its
|
||||
* one's complement if requested.
|
||||
*/
|
||||
local void copy_block(deflate_state *s, charf *buf, unsigned len, int header)
|
||||
local void copy_block(s, buf, len, header)
|
||||
deflate_state *s;
|
||||
charf *buf; /* the input data */
|
||||
unsigned len; /* its length */
|
||||
int header; /* true if block header must be written */
|
||||
{
|
||||
bi_windup(s); /* align on byte boundary */
|
||||
s->last_eob_len = 8; /* enough lookahead for inflate */
|
||||
|
|
|
@ -23,7 +23,11 @@
|
|||
enough memory, Z_BUF_ERROR if there was not enough room in the output
|
||||
buffer, or Z_DATA_ERROR if the input data was corrupted.
|
||||
*/
|
||||
int ZEXPORT uncompress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
|
||||
int ZEXPORT uncompress (dest, destLen, source, sourceLen)
|
||||
Bytef *dest;
|
||||
uLongf *destLen;
|
||||
const Bytef *source;
|
||||
uLong sourceLen;
|
||||
{
|
||||
z_stream stream;
|
||||
int err;
|
||||
|
|
|
@ -12,7 +12,7 @@ in the zlib distribution, or at the following location:
|
|||
1. What is ZLIB1.DLL, and how can I get it?
|
||||
|
||||
- ZLIB1.DLL is the official build of zlib as a DLL.
|
||||
(Please remark the symbol '1' in the name.)
|
||||
(Please remark the character '1' in the name.)
|
||||
|
||||
Pointers to a precompiled ZLIB1.DLL can be found in the zlib
|
||||
web site at:
|
||||
|
@ -37,20 +37,19 @@ in the zlib distribution, or at the following location:
|
|||
and build settings. If you do build the DLL yourself, please
|
||||
make sure that it complies with all the above requirements,
|
||||
and it runs with the precompiled test programs, bundled with
|
||||
the original ZLIB1.DLL distribution and available at the zlib
|
||||
web site.
|
||||
the original ZLIB1.DLL distribution.
|
||||
|
||||
If, for any reason, you need to build an incompatible DLL,
|
||||
please use a different name.
|
||||
please use a different file name.
|
||||
|
||||
|
||||
2. Why did you change the name of the DLL to ZLIB1.DLL?
|
||||
What happened to the old ZLIB.DLL?
|
||||
|
||||
- The old ZLIB.DLL, built from zlib-1.1.x and earlier, required
|
||||
compilation settings that were incompatible to those used by a
|
||||
static build. The DLL settings were supposed to be enabled by
|
||||
defining the macro ZLIB_DLL, before including "zlib.h".
|
||||
- The old ZLIB.DLL, built from zlib-1.1.4 or earlier, required
|
||||
compilation settings that were incompatible to those used by
|
||||
a static build. The DLL settings were supposed to be enabled
|
||||
by defining the macro ZLIB_DLL, before including "zlib.h".
|
||||
Incorrect handling of this macro was silently accepted at
|
||||
build time, resulting in two major problems:
|
||||
|
||||
|
@ -65,8 +64,8 @@ in the zlib distribution, or at the following location:
|
|||
functions. Failure to do so resulted in creating binaries
|
||||
that were unable to run with the official ZLIB.DLL build.
|
||||
|
||||
The only possible solution that we could foresee was to make a
|
||||
binary-incompatible change in the DLL interfacing, in order to
|
||||
The only possible solution that we could foresee was to make
|
||||
a binary-incompatible change in the DLL interface, in order to
|
||||
remove the dependency on the ZLIB_DLL macro, and to release
|
||||
the new DLL under a different name.
|
||||
|
||||
|
@ -85,17 +84,13 @@ in the zlib distribution, or at the following location:
|
|||
|
||||
- In principle, you can do it by assigning calling convention
|
||||
keywords to the macros ZEXPORT and ZEXPORTVA. In practice,
|
||||
it depends on what you mean by "an old ZLIB.DLL", because
|
||||
the old DLL exists in several mutually-incompatible versions.
|
||||
|
||||
If you have a compiled application that works with a certain
|
||||
ZLIB.DLL without any known security issues, there is hardly
|
||||
a need to rebuild the DLL from new sources only to link it to
|
||||
the old app binary. But if you really want to do it, you have
|
||||
to find out first what kind of calling convention uses your
|
||||
particular ZLIB.DLL build, and to use the same one in the new
|
||||
build. If you don't know what this is all about, you might be
|
||||
better off if you would just forget it.
|
||||
it depends on what you mean by "an old ZLIB.DLL", because the
|
||||
old DLL exists in several mutually-incompatible versions.
|
||||
You have to find out first what kind of calling convention is
|
||||
being used in your particular ZLIB.DLL build, and to use the
|
||||
same one in the new build. If you don't know what this is all
|
||||
about, you might be better off if you would just leave the old
|
||||
DLL intact.
|
||||
|
||||
|
||||
4. Can I compile my application using the new zlib interface, and
|
||||
|
@ -170,19 +165,19 @@ in the zlib distribution, or at the following location:
|
|||
the K&R-style function prototypes, where the argument types
|
||||
are not specified; but that is another story for another day.
|
||||
|
||||
The fact that remains is that CDECL is the default convention.
|
||||
Even if an explicit convention (such as STDCALL or FASTCALL)
|
||||
is hard-coded into the function prototypes inside C headers,
|
||||
problems may appear. One problem, for example, deals with the
|
||||
necessity to expose the convention in users' callbacks.
|
||||
The remaining fact is that CDECL is the default convention.
|
||||
Even if an explicit convention is hard-coded into the function
|
||||
prototypes inside C headers, problems may appear. The
|
||||
necessity to expose the convention in users' callbacks is one
|
||||
of these problems.
|
||||
|
||||
The calling convention issues are also important when using
|
||||
zlib in other programming languages. Some of them, like Ada
|
||||
(GNAT) and Fortran (GNU G77), have C bindings implemented
|
||||
initially on Unix, and relying on the C calling convention.
|
||||
On the other hand, the pre- .NET versions of Microsoft Visual
|
||||
Basic require STDCALL, while Borland Delphi prefers (although
|
||||
it does not require) FASTCALL.
|
||||
Basic require STDCALL, while Borland Delphi prefers, although
|
||||
it does not require, FASTCALL.
|
||||
|
||||
In fairness to all possible uses of zlib outside the C
|
||||
programming language, we choose the default "C" convention.
|
||||
|
@ -208,7 +203,16 @@ in the zlib distribution, or at the following location:
|
|||
zlib distribution.
|
||||
|
||||
|
||||
8. If my application uses ZLIB1.DLL, should I link it to
|
||||
8. I need a DLL for my Microsoft .NET project. What can I do?
|
||||
|
||||
- We did not implement a COM wrapper around zlib, so you will
|
||||
have to develop it yourself, or to get it from somewhere else.
|
||||
|
||||
If you would be so generous as to contribute such a wrapper,
|
||||
we would like to include it in a future zlib version.
|
||||
|
||||
|
||||
9. If my application uses ZLIB1.DLL, should I link it to
|
||||
MSVCRT.DLL? Why?
|
||||
|
||||
- It is not required, but it is recommended to link your
|
||||
|
@ -223,7 +227,7 @@ in the zlib distribution, or at the following location:
|
|||
depend on it should also be linked to MSVCRT.DLL.
|
||||
|
||||
|
||||
9. Why are you saying that ZLIB1.DLL and my application must be
|
||||
10. Why are you saying that ZLIB1.DLL and my application must be
|
||||
linked to the same C run-time (CRT) library? I linked my
|
||||
application and my DLLs to different C libraries (e.g. my
|
||||
application to a static library, and my DLLs to MSVCRT.DLL),
|
||||
|
@ -255,11 +259,11 @@ in the zlib distribution, or at the following location:
|
|||
and DLLs are avoiding the corruption of each of the CRTs'
|
||||
internal states, maybe by careful design, or maybe by fortune.
|
||||
|
||||
Also note that linking ZLIB1.DLL to non-Microsoft CRTs (such
|
||||
as those provided by Borland) raises similar problems.
|
||||
Also note that linking ZLIB1.DLL to non-Microsoft CRTs, such
|
||||
as those provided by Borland, raises similar problems.
|
||||
|
||||
|
||||
10. Why are you linking ZLIB1.DLL to MSVCRT.DLL?
|
||||
11. Why are you linking ZLIB1.DLL to MSVCRT.DLL?
|
||||
|
||||
- MSVCRT.DLL exists on every Windows 95 with a new service pack
|
||||
installed, or with Microsoft Internet Explorer 4 or later, and
|
||||
|
@ -269,12 +273,11 @@ in the zlib distribution, or at the following location:
|
|||
software provider for free.
|
||||
|
||||
The fact that MSVCRT.DLL does not exist on a virgin Windows 95
|
||||
is not so problematic. The number of Windows 95 installations
|
||||
is rapidly decreasing, Microsoft stopped supporting it a long
|
||||
time ago, and many recent applications from various vendors,
|
||||
including Microsoft, do not even run on it. Furthermore, no
|
||||
serious user should run Windows 95 without a proper update
|
||||
installed.
|
||||
is not so problematic. Windows 95 is scarcely found nowadays,
|
||||
Microsoft ended its support a long time ago, and many recent
|
||||
applications from various vendors, including Microsoft, do not
|
||||
even run on it. Furthermore, no serious user should run
|
||||
Windows 95 without a proper update installed.
|
||||
|
||||
There is also the fact that the mainstream C compilers for
|
||||
Windows are Microsoft Visual C++ 6.0, and gcc/MinGW. Both
|
||||
|
@ -283,7 +286,7 @@ in the zlib distribution, or at the following location:
|
|||
select by users.
|
||||
|
||||
|
||||
11. Why are you not linking ZLIB1.DLL to
|
||||
12. Why are you not linking ZLIB1.DLL to
|
||||
<<my favorite C run-time library>> ?
|
||||
|
||||
- We considered and abandoned the following alternatives:
|
||||
|
@ -314,7 +317,7 @@ in the zlib distribution, or at the following location:
|
|||
Windows NT systems.
|
||||
|
||||
|
||||
12. I need to link my own DLL build to a CRT different than
|
||||
13. I need to link my own DLL build to a CRT different than
|
||||
MSVCRT.DLL. What can I do?
|
||||
|
||||
- Feel free to rebuild the DLL from the zlib sources, and link
|
||||
|
@ -330,7 +333,7 @@ in the zlib distribution, or at the following location:
|
|||
CYGWIN1.DLL, and it is distributed under the name CYGZ.DLL.
|
||||
|
||||
|
||||
13. May I include additional pieces of code that I find useful,
|
||||
14. May I include additional pieces of code that I find useful,
|
||||
link them in ZLIB1.DLL, and export them?
|
||||
|
||||
- No. A legitimate build of ZLIB1.DLL must not include code
|
||||
|
@ -338,14 +341,12 @@ in the zlib distribution, or at the following location:
|
|||
But you can make your own private DLL build, under a different
|
||||
file name, as suggested in the previous answer.
|
||||
|
||||
For example, in Borland Delphi and C++ Builder, zlib is a part
|
||||
of the standard VCL library. If an application links to VCL
|
||||
dynamically, the name of the distributable binary (VCLxx.DLL)
|
||||
does not posess any danger of clashing with a legitimate but
|
||||
incompatible ZLIB1.DLL.
|
||||
For example, zlib is a part of the VCL library, distributed
|
||||
with Borland Delphi and C++ Builder. The DLL build of VCL
|
||||
is a redistributable file, named VCLxx.DLL.
|
||||
|
||||
|
||||
14. May I remove some functionality out of ZLIB1.DLL, by enabling
|
||||
15. May I remove some functionality out of ZLIB1.DLL, by enabling
|
||||
macros like NO_GZCOMPRESS or NO_GZIP at compile time?
|
||||
|
||||
- No. A legitimate build of ZLIB1.DLL must provide the complete
|
||||
|
@ -354,7 +355,7 @@ in the zlib distribution, or at the following location:
|
|||
different file name, as suggested in the previous answer.
|
||||
|
||||
|
||||
15. I made my own ZLIB1.DLL build. Can I test it for compliance?
|
||||
16. I made my own ZLIB1.DLL build. Can I test it for compliance?
|
||||
|
||||
- We prefer that you download the official DLL from the zlib
|
||||
web site. If you need something peculiar from this DLL, you
|
||||
|
|
|
@ -5,8 +5,8 @@ VS_VERSION_INFO VERSIONINFO
|
|||
#else
|
||||
VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
||||
#endif
|
||||
FILEVERSION 1,2,1,1
|
||||
PRODUCTVERSION 1,2,1,1
|
||||
FILEVERSION 1,2,1,2
|
||||
PRODUCTVERSION 1,2,1,2
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 1
|
||||
|
@ -23,12 +23,12 @@ BEGIN
|
|||
//language ID = U.S. English, char set = Windows, Multilingual
|
||||
BEGIN
|
||||
VALUE "FileDescription", "zlib data compression library\0"
|
||||
VALUE "FileVersion", "1.2.1.1\0"
|
||||
VALUE "FileVersion", "1.2.1.2\0"
|
||||
VALUE "InternalName", "zlib1.dll\0"
|
||||
VALUE "LegalCopyright", "(C) 1995-2003 Jean-loup Gailly & Mark Adler\0"
|
||||
VALUE "LegalCopyright", "(C) 1995-2004 Jean-loup Gailly & Mark Adler\0"
|
||||
VALUE "OriginalFilename", "zlib1.dll\0"
|
||||
VALUE "ProductName", "zlib\0"
|
||||
VALUE "ProductVersion", "1.2.1.1\0"
|
||||
VALUE "ProductVersion", "1.2.1.2\0"
|
||||
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
|
||||
END
|
||||
END
|
||||
|
|
87
zlib/zconf.h
87
zlib/zconf.h
|
@ -1,5 +1,5 @@
|
|||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
||||
* Copyright (C) 1995-2004 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -13,43 +13,46 @@
|
|||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||
*/
|
||||
#ifdef Z_PREFIX
|
||||
# define deflateInit_ z_deflateInit_
|
||||
# define deflate z_deflate
|
||||
# define deflateEnd z_deflateEnd
|
||||
# define inflateInit_ z_inflateInit_
|
||||
# define inflate z_inflate
|
||||
# define inflateEnd z_inflateEnd
|
||||
# define deflateInit2_ z_deflateInit2_
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define deflateParams z_deflateParams
|
||||
# define deflateBound z_deflateBound
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateCopy z_inflateCopy
|
||||
# define inflateReset z_inflateReset
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define compressBound z_compressBound
|
||||
# define uncompress z_uncompress
|
||||
# define adler32 z_adler32
|
||||
# define crc32 z_crc32
|
||||
# define get_crc_table z_get_crc_table
|
||||
# define deflateInit_ z_deflateInit_
|
||||
# define deflate z_deflate
|
||||
# define deflateEnd z_deflateEnd
|
||||
# define inflateInit_ z_inflateInit_
|
||||
# define inflate z_inflate
|
||||
# define inflateEnd z_inflateEnd
|
||||
# define deflateInit2_ z_deflateInit2_
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflateParams z_deflateParams
|
||||
# define deflateBound z_deflateBound
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateCopy z_inflateCopy
|
||||
# define inflateReset z_inflateReset
|
||||
# define inflateBack z_inflateBack
|
||||
# define inflateBackEnd z_inflateBackEnd
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define compressBound z_compressBound
|
||||
# define uncompress z_uncompress
|
||||
# define adler32 z_adler32
|
||||
# define crc32 z_crc32
|
||||
# define get_crc_table z_get_crc_table
|
||||
# define zError z_zError
|
||||
|
||||
# define Byte z_Byte
|
||||
# define uInt z_uInt
|
||||
# define uLong z_uLong
|
||||
# define Bytef z_Bytef
|
||||
# define charf z_charf
|
||||
# define intf z_intf
|
||||
# define uIntf z_uIntf
|
||||
# define uLongf z_uLongf
|
||||
# define voidpf z_voidpf
|
||||
# define voidp z_voidp
|
||||
# define Byte z_Byte
|
||||
# define uInt z_uInt
|
||||
# define uLong z_uLong
|
||||
# define Bytef z_Bytef
|
||||
# define charf z_charf
|
||||
# define intf z_intf
|
||||
# define uIntf z_uIntf
|
||||
# define uLongf z_uLongf
|
||||
# define voidpf z_voidpf
|
||||
# define voidp z_voidp
|
||||
#endif
|
||||
|
||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||
|
@ -155,7 +158,7 @@
|
|||
/* Type declarations */
|
||||
|
||||
#ifndef OF /* function prototypes */
|
||||
# if defined(STDC) || defined(__LCLINT__)
|
||||
# ifdef STDC
|
||||
# define OF(args) args
|
||||
# else
|
||||
# define OF(args) ()
|
||||
|
@ -275,13 +278,13 @@ typedef uLong FAR uLongf;
|
|||
typedef Byte *voidp;
|
||||
#endif
|
||||
|
||||
#if 1 /* HAVE_UNISTD_H -- this line is updated by ./configure */
|
||||
#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
|
||||
# include <sys/types.h> /* for off_t */
|
||||
# include <unistd.h> /* for SEEK_* and off_t */
|
||||
# ifdef VMS
|
||||
# include <unixio.h> /* for off_t */
|
||||
# endif
|
||||
# define z_off_t off_t
|
||||
# define z_off_t off_t
|
||||
#endif
|
||||
#ifndef SEEK_SET
|
||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||
|
@ -289,11 +292,11 @@ typedef uLong FAR uLongf;
|
|||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||
#endif
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long
|
||||
# define z_off_t long
|
||||
#endif
|
||||
|
||||
#if defined(__OS400__)
|
||||
#define NO_vsnprintf
|
||||
# define NO_vsnprintf
|
||||
#endif
|
||||
|
||||
#if defined(__MVS__)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
||||
* Copyright (C) 1995-2004 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
|
@ -13,43 +13,46 @@
|
|||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||
*/
|
||||
#ifdef Z_PREFIX
|
||||
# define deflateInit_ z_deflateInit_
|
||||
# define deflate z_deflate
|
||||
# define deflateEnd z_deflateEnd
|
||||
# define inflateInit_ z_inflateInit_
|
||||
# define inflate z_inflate
|
||||
# define inflateEnd z_inflateEnd
|
||||
# define deflateInit2_ z_deflateInit2_
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define deflateParams z_deflateParams
|
||||
# define deflateBound z_deflateBound
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateCopy z_inflateCopy
|
||||
# define inflateReset z_inflateReset
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define compressBound z_compressBound
|
||||
# define uncompress z_uncompress
|
||||
# define adler32 z_adler32
|
||||
# define crc32 z_crc32
|
||||
# define get_crc_table z_get_crc_table
|
||||
# define deflateInit_ z_deflateInit_
|
||||
# define deflate z_deflate
|
||||
# define deflateEnd z_deflateEnd
|
||||
# define inflateInit_ z_inflateInit_
|
||||
# define inflate z_inflate
|
||||
# define inflateEnd z_inflateEnd
|
||||
# define deflateInit2_ z_deflateInit2_
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflateParams z_deflateParams
|
||||
# define deflateBound z_deflateBound
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateCopy z_inflateCopy
|
||||
# define inflateReset z_inflateReset
|
||||
# define inflateBack z_inflateBack
|
||||
# define inflateBackEnd z_inflateBackEnd
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define compressBound z_compressBound
|
||||
# define uncompress z_uncompress
|
||||
# define adler32 z_adler32
|
||||
# define crc32 z_crc32
|
||||
# define get_crc_table z_get_crc_table
|
||||
# define zError z_zError
|
||||
|
||||
# define Byte z_Byte
|
||||
# define uInt z_uInt
|
||||
# define uLong z_uLong
|
||||
# define Bytef z_Bytef
|
||||
# define charf z_charf
|
||||
# define intf z_intf
|
||||
# define uIntf z_uIntf
|
||||
# define uLongf z_uLongf
|
||||
# define voidpf z_voidpf
|
||||
# define voidp z_voidp
|
||||
# define Byte z_Byte
|
||||
# define uInt z_uInt
|
||||
# define uLong z_uLong
|
||||
# define Bytef z_Bytef
|
||||
# define charf z_charf
|
||||
# define intf z_intf
|
||||
# define uIntf z_uIntf
|
||||
# define uLongf z_uLongf
|
||||
# define voidpf z_voidpf
|
||||
# define voidp z_voidp
|
||||
#endif
|
||||
|
||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||
|
@ -281,7 +284,7 @@ typedef uLong FAR uLongf;
|
|||
# ifdef VMS
|
||||
# include <unixio.h> /* for off_t */
|
||||
# endif
|
||||
# define z_off_t off_t
|
||||
# define z_off_t off_t
|
||||
#endif
|
||||
#ifndef SEEK_SET
|
||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||
|
@ -289,11 +292,11 @@ typedef uLong FAR uLongf;
|
|||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||
#endif
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long
|
||||
# define z_off_t long
|
||||
#endif
|
||||
|
||||
#if defined(__OS400__)
|
||||
#define NO_vsnprintf
|
||||
# define NO_vsnprintf
|
||||
#endif
|
||||
|
||||
#if defined(__MVS__)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.TH ZLIB 3 "9 January 2004"
|
||||
.TH ZLIB 3 "9 September 2004"
|
||||
.SH NAME
|
||||
zlib \- compression/decompression library
|
||||
.SH SYNOPSIS
|
||||
|
@ -133,7 +133,7 @@ before asking for help.
|
|||
Send questions and/or comments to zlib@gzip.org,
|
||||
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
|
||||
.SH AUTHORS
|
||||
Version 1.2.1.1
|
||||
Version 1.2.1.2
|
||||
Copyright (C) 1995-2004 Jean-loup Gailly (jloup@gzip.org)
|
||||
and Mark Adler (madler@alumni.caltech.edu).
|
||||
.LP
|
||||
|
|
207
zlib/zlib.h
207
zlib/zlib.h
|
@ -1,5 +1,5 @@
|
|||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
version 1.2.1.1, January 9th, 2004
|
||||
version 1.2.1.2, September 9th, 2004
|
||||
|
||||
Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler
|
||||
|
||||
|
@ -37,8 +37,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ZLIB_VERSION "1.2.1.1"
|
||||
#define ZLIB_VERNUM 0x1211
|
||||
#define ZLIB_VERSION "1.2.1.2"
|
||||
#define ZLIB_VERNUM 0x1212
|
||||
|
||||
/*
|
||||
The 'zlib' compression library provides in-memory compression and
|
||||
|
@ -76,34 +76,25 @@ extern "C" {
|
|||
crash even in case of corrupted input.
|
||||
*/
|
||||
|
||||
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size))
|
||||
/*@*/;
|
||||
typedef void (*free_func) OF((voidpf opaque, voidpf address))
|
||||
/*@*/;
|
||||
typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
|
||||
typedef void (*free_func) OF((voidpf opaque, voidpf address));
|
||||
|
||||
struct internal_state;
|
||||
|
||||
typedef struct z_stream_s {
|
||||
/*@relnull@*/
|
||||
Bytef *next_in; /* next input byte */
|
||||
uInt avail_in; /* number of bytes available at next_in */
|
||||
uLong total_in; /* total nb of input bytes read so far */
|
||||
|
||||
/*@relnull@*/
|
||||
Bytef *next_out; /* next output byte should be put there */
|
||||
uInt avail_out; /* remaining free space at next_out */
|
||||
uLong total_out; /* total nb of bytes output so far */
|
||||
|
||||
/*@relnull@*/ /*@observer@*/
|
||||
char *msg; /* last error message, NULL if no error */
|
||||
/*@relnull@*/
|
||||
struct internal_state FAR *state; /* not visible by applications */
|
||||
|
||||
/*@relnull@*/
|
||||
alloc_func zalloc; /* used to allocate the internal state */
|
||||
/*@relnull@*/
|
||||
free_func zfree; /* used to free the internal state */
|
||||
/*@relnull@*/
|
||||
voidpf opaque; /* private data object passed to zalloc and zfree */
|
||||
|
||||
int data_type; /* best guess about the data type: ascii or binary */
|
||||
|
@ -195,9 +186,7 @@ typedef z_stream FAR *z_streamp;
|
|||
|
||||
/* basic functions */
|
||||
|
||||
/*@observer@*/
|
||||
ZEXTERN const char * ZEXPORT zlibVersion OF((void))
|
||||
/*@*/;
|
||||
ZEXTERN const char * ZEXPORT zlibVersion OF((void));
|
||||
/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
|
||||
If the first character differs, the library code actually used is
|
||||
not compatible with the zlib.h header file used by the application.
|
||||
|
@ -227,8 +216,7 @@ ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
|
|||
*/
|
||||
|
||||
|
||||
ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush))
|
||||
/*@modifies strm @*/;
|
||||
ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
|
||||
/*
|
||||
deflate compresses as much data as possible, and stops when the input
|
||||
buffer becomes empty or the output buffer becomes full. It may introduce some
|
||||
|
@ -310,8 +298,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush))
|
|||
*/
|
||||
|
||||
|
||||
ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm))
|
||||
/*@modifies strm @*/;
|
||||
ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
|
||||
/*
|
||||
All dynamically allocated data structures for this stream are freed.
|
||||
This function discards any unprocessed input and does not flush any
|
||||
|
@ -346,8 +333,7 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
|
|||
*/
|
||||
|
||||
|
||||
ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush))
|
||||
/*@modifies strm @*/;
|
||||
ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
|
||||
/*
|
||||
inflate decompresses as much data as possible, and stops when the input
|
||||
buffer becomes empty or the output buffer becomes full. It may introduce
|
||||
|
@ -415,7 +401,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush))
|
|||
because Z_BLOCK is used.
|
||||
|
||||
If a preset dictionary is needed after this call (see inflateSetDictionary
|
||||
below), inflate sets strm-adler to the adler32 checksum of the dictionary
|
||||
below), inflate sets strm->adler to the adler32 checksum of the dictionary
|
||||
chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
|
||||
strm->adler to the adler32 checksum of all output produced so far (that is,
|
||||
total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
|
||||
|
@ -446,8 +432,7 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush))
|
|||
*/
|
||||
|
||||
|
||||
ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm))
|
||||
/*@modifies strm @*/;
|
||||
ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
|
||||
/*
|
||||
All dynamically allocated data structures for this stream are freed.
|
||||
This function discards any unprocessed input and does not flush any
|
||||
|
@ -522,8 +507,7 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
|
|||
|
||||
ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength))
|
||||
/*@modifies strm @*/;
|
||||
uInt dictLength));
|
||||
/*
|
||||
Initializes the compression dictionary from the given byte sequence
|
||||
without producing any compressed output. This function must be called
|
||||
|
@ -559,8 +543,7 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
|
|||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
|
||||
z_streamp source))
|
||||
/*@modifies dest, source @*/;
|
||||
z_streamp source));
|
||||
/*
|
||||
Sets the destination stream as a complete copy of the source stream.
|
||||
|
||||
|
@ -577,9 +560,7 @@ ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
|
|||
destination.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm))
|
||||
/*@globals internalState @*/
|
||||
/*@modifies strm, internalState @*/;
|
||||
ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
|
||||
/*
|
||||
This function is equivalent to deflateEnd followed by deflateInit,
|
||||
but does not free and reallocate all the internal compression state.
|
||||
|
@ -592,8 +573,7 @@ ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm))
|
|||
|
||||
ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
|
||||
int level,
|
||||
int strategy))
|
||||
/*@modifies strm @*/;
|
||||
int strategy));
|
||||
/*
|
||||
Dynamically update the compression level and compression strategy. The
|
||||
interpretation of level and strategy is as in deflateInit2. This can be
|
||||
|
@ -613,8 +593,7 @@ ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
|
|||
*/
|
||||
|
||||
ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
|
||||
uLong sourceLen))
|
||||
/*@modifies strm @*/;
|
||||
uLong sourceLen));
|
||||
/*
|
||||
deflateBound() returns an upper bound on the compressed size after
|
||||
deflation of sourceLen bytes. It must be called after deflateInit()
|
||||
|
@ -624,8 +603,7 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
|
|||
|
||||
ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
|
||||
int bits,
|
||||
int value))
|
||||
/*@modifies strm @*/;
|
||||
int value));
|
||||
/*
|
||||
deflatePrime() inserts bits in the deflate output stream. The intent
|
||||
is that this function is used to start off the deflate output with the
|
||||
|
@ -683,8 +661,7 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
|
|||
|
||||
ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
|
||||
const Bytef *dictionary,
|
||||
uInt dictLength))
|
||||
/*@modifies strm @*/;
|
||||
uInt dictLength));
|
||||
/*
|
||||
Initializes the decompression dictionary from the given uncompressed byte
|
||||
sequence. This function must be called immediately after a call of inflate
|
||||
|
@ -701,8 +678,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
|
|||
inflate().
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm))
|
||||
/*@modifies strm @*/;
|
||||
ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
|
||||
/*
|
||||
Skips invalid compressed data until a full flush point (see above the
|
||||
description of deflate with Z_FULL_FLUSH) can be found, or until all
|
||||
|
@ -718,8 +694,7 @@ ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm))
|
|||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
|
||||
z_streamp source))
|
||||
/*@modifies dest, source @*/;
|
||||
z_streamp source));
|
||||
/*
|
||||
Sets the destination stream as a complete copy of the source stream.
|
||||
|
||||
|
@ -734,8 +709,7 @@ ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
|
|||
destination.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm))
|
||||
/*@modifies strm @*/;
|
||||
ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
|
||||
/*
|
||||
This function is equivalent to inflateEnd followed by inflateInit,
|
||||
but does not free and reallocate all the internal decompression state.
|
||||
|
@ -767,15 +741,12 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_stream FAR *strm, int windowBits,
|
|||
match the version of the header file.
|
||||
*/
|
||||
|
||||
typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *))
|
||||
/*@*/;
|
||||
typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned))
|
||||
/*@*/;
|
||||
typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
|
||||
typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
|
||||
|
||||
ZEXTERN int ZEXPORT inflateBack OF((z_stream FAR *strm,
|
||||
in_func in, void FAR *in_desc,
|
||||
out_func out, void FAR *out_desc))
|
||||
/*@modifies strm @*/;
|
||||
out_func out, void FAR *out_desc));
|
||||
/*
|
||||
inflateBack() does a raw inflate with a single call using a call-back
|
||||
interface for input and output. This is more efficient than inflate() for
|
||||
|
@ -842,8 +813,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_stream FAR *strm,
|
|||
that inflateBack() cannot return Z_OK.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT inflateBackEnd OF((z_stream FAR *strm))
|
||||
/*@modifies strm @*/;
|
||||
ZEXTERN int ZEXPORT inflateBackEnd OF((z_stream FAR *strm));
|
||||
/*
|
||||
All memory allocated by inflateBackInit() is freed.
|
||||
|
||||
|
@ -851,8 +821,7 @@ ZEXTERN int ZEXPORT inflateBackEnd OF((z_stream FAR *strm))
|
|||
state was inconsistent.
|
||||
*/
|
||||
|
||||
ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void))
|
||||
/*@*/;
|
||||
ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
|
||||
/* Return flags indicating compile-time options.
|
||||
|
||||
Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
|
||||
|
@ -905,9 +874,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void))
|
|||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
|
||||
const Bytef *source, uLong sourceLen))
|
||||
/*@globals internalState @*/
|
||||
/*@modifies *dest, *destLen, internalState @*/;
|
||||
const Bytef *source, uLong sourceLen));
|
||||
/*
|
||||
Compresses the source buffer into the destination buffer. sourceLen is
|
||||
the byte length of the source buffer. Upon entry, destLen is the total
|
||||
|
@ -923,9 +890,7 @@ ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
|
|||
|
||||
ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
|
||||
const Bytef *source, uLong sourceLen,
|
||||
int level))
|
||||
/*@globals internalState @*/
|
||||
/*@modifies *dest, *destLen, internalState @*/;
|
||||
int level));
|
||||
/*
|
||||
Compresses the source buffer into the destination buffer. The level
|
||||
parameter has the same meaning as in deflateInit. sourceLen is the byte
|
||||
|
@ -939,8 +904,7 @@ ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
|
|||
Z_STREAM_ERROR if the level parameter is invalid.
|
||||
*/
|
||||
|
||||
ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen))
|
||||
/*@*/;
|
||||
ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
|
||||
/*
|
||||
compressBound() returns an upper bound on the compressed size after
|
||||
compress() or compress2() on sourceLen bytes. It would be used before
|
||||
|
@ -948,8 +912,7 @@ ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen))
|
|||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
|
||||
const Bytef *source, uLong sourceLen))
|
||||
/*@modifies *dest, *destLen @*/;
|
||||
const Bytef *source, uLong sourceLen));
|
||||
/*
|
||||
Decompresses the source buffer into the destination buffer. sourceLen is
|
||||
the byte length of the source buffer. Upon entry, destLen is the total
|
||||
|
@ -969,10 +932,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
|
|||
|
||||
typedef voidp gzFile;
|
||||
|
||||
/*@null@*/
|
||||
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode))
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
|
||||
/*
|
||||
Opens a gzip (.gz) file for reading or writing. The mode parameter
|
||||
is as in fopen ("rb" or "wb") but can also include a compression level
|
||||
|
@ -989,10 +949,7 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode))
|
|||
can be checked to distinguish the two cases (if errno is zero, the
|
||||
zlib error is Z_MEM_ERROR). */
|
||||
|
||||
/*@null@*/
|
||||
ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode))
|
||||
/*@globals fileSystem, internalState @*/
|
||||
/*@modifies fileSystem, internalState @*/;
|
||||
ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
|
||||
/*
|
||||
gzdopen() associates a gzFile with the file descriptor fd. File
|
||||
descriptors are obtained from calls like open, dup, creat, pipe or
|
||||
|
@ -1005,9 +962,7 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode))
|
|||
the (de)compression state.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies file, fileSystem @*/;
|
||||
ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
|
||||
/*
|
||||
Dynamically update the compression level or strategy. See the description
|
||||
of deflateInit2 for the meaning of these parameters.
|
||||
|
@ -1015,9 +970,7 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy))
|
|||
opened for writing.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len))
|
||||
/*@globals errno, fileSystem @*/
|
||||
/*@modifies file, *buf, errno, fileSystem @*/;
|
||||
ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
|
||||
/*
|
||||
Reads the given number of uncompressed bytes from the compressed file.
|
||||
If the input file was not in gzip format, gzread copies the given number
|
||||
|
@ -1026,18 +979,14 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len))
|
|||
end of file, -1 for error). */
|
||||
|
||||
ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
|
||||
voidpc buf, unsigned len))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies file, fileSystem @*/;
|
||||
voidpc buf, unsigned len));
|
||||
/*
|
||||
Writes the given number of uncompressed bytes into the compressed file.
|
||||
gzwrite returns the number of uncompressed bytes actually written
|
||||
(0 in case of error).
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies file, fileSystem @*/;
|
||||
ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
|
||||
/*
|
||||
Converts, formats, and writes the args to the compressed file under
|
||||
control of the format string, as in fprintf. gzprintf returns the number of
|
||||
|
@ -1050,19 +999,14 @@ ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...))
|
|||
because the secure snprintf() or vsnprintf() functions were not available.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies file, fileSystem @*/;
|
||||
ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
|
||||
/*
|
||||
Writes the given null-terminated string to the compressed file, excluding
|
||||
the terminating null character.
|
||||
gzputs returns the number of characters written, or -1 in case of error.
|
||||
*/
|
||||
|
||||
/*@null@*/
|
||||
ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies file, buf, fileSystem @*/;
|
||||
ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
|
||||
/*
|
||||
Reads bytes from the compressed file until len-1 characters are read, or
|
||||
a newline character is read and transferred to buf, or an end-of-file
|
||||
|
@ -1071,24 +1015,19 @@ ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len))
|
|||
gzgets returns buf, or Z_NULL in case of error.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies file, fileSystem @*/;
|
||||
ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
|
||||
/*
|
||||
Writes c, converted to an unsigned char, into the compressed file.
|
||||
gzputc returns the value that was written, or -1 in case of error.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzgetc OF((gzFile file))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies file, fileSystem @*/;
|
||||
ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
|
||||
/*
|
||||
Reads one byte from the compressed file. gzgetc returns this byte
|
||||
or -1 in case of end of file or error.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file))
|
||||
/*@*/;
|
||||
ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
|
||||
/*
|
||||
Push one character back onto the stream to be read again later.
|
||||
Only one character of push-back is allowed. gzungetc() returns the
|
||||
|
@ -1098,9 +1037,7 @@ ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file))
|
|||
or gzrewind().
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies file, fileSystem @*/;
|
||||
ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
|
||||
/*
|
||||
Flushes all pending output into the compressed file. The parameter
|
||||
flush is as in the deflate() function. The return value is the zlib
|
||||
|
@ -1111,9 +1048,7 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush))
|
|||
*/
|
||||
|
||||
ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
|
||||
z_off_t offset, int whence))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies file, fileSystem @*/;
|
||||
z_off_t offset, int whence));
|
||||
/*
|
||||
Sets the starting position for the next gzread or gzwrite on the
|
||||
given compressed file. The offset represents a number of bytes in the
|
||||
|
@ -1130,18 +1065,14 @@ ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
|
|||
would be before the current position.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzrewind OF((gzFile file))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies file, fileSystem @*/;
|
||||
ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
|
||||
/*
|
||||
Rewinds the given file. This function is supported only for reading.
|
||||
|
||||
gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
|
||||
*/
|
||||
|
||||
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies file, fileSystem @*/;
|
||||
ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
|
||||
/*
|
||||
Returns the starting position for the next gzread or gzwrite on the
|
||||
given compressed file. This position represents a number of bytes in the
|
||||
|
@ -1150,25 +1081,20 @@ ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file))
|
|||
gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzeof OF((gzFile file))
|
||||
/*@*/;
|
||||
ZEXTERN int ZEXPORT gzeof OF((gzFile file));
|
||||
/*
|
||||
Returns 1 when EOF has previously been detected reading the given
|
||||
input stream, otherwise zero.
|
||||
*/
|
||||
|
||||
ZEXTERN int ZEXPORT gzclose OF((/*@only@*/ gzFile file))
|
||||
/*@globals fileSystem @*/
|
||||
/*@modifies file, fileSystem @*/;
|
||||
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
|
||||
/*
|
||||
Flushes all pending output if necessary, closes the compressed file
|
||||
and deallocates all the (de)compression state. The return value is the zlib
|
||||
error number (see function gzerror below).
|
||||
*/
|
||||
|
||||
/*@observer@*/
|
||||
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum))
|
||||
/*@modifies *errnum @*/;
|
||||
ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
|
||||
/*
|
||||
Returns the error message for the last error which occurred on the
|
||||
given compressed file. errnum is set to zlib error number. If an
|
||||
|
@ -1177,8 +1103,7 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum))
|
|||
to get the exact error code.
|
||||
*/
|
||||
|
||||
ZEXTERN void ZEXPORT gzclearerr OF((gzFile file))
|
||||
/*@*/;
|
||||
ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
|
||||
/*
|
||||
Clears the error and end-of-file flags for file. This is analogous to the
|
||||
clearerr() function in stdio. This is useful for continuing to read a gzip
|
||||
|
@ -1193,8 +1118,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file))
|
|||
compression library.
|
||||
*/
|
||||
|
||||
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, /*@null@*/ const Bytef *buf, uInt len))
|
||||
/*@*/;
|
||||
ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
|
||||
|
||||
/*
|
||||
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
|
||||
|
@ -1211,8 +1135,7 @@ ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, /*@null@*/ const Bytef *buf, uInt
|
|||
if (adler != original_adler) error();
|
||||
*/
|
||||
|
||||
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, /*@null@*/ const Bytef *buf, uInt len))
|
||||
/*@*/;
|
||||
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
|
||||
/*
|
||||
Update a running crc with the bytes buf[0..len-1] and return the updated
|
||||
crc. If buf is NULL, this function returns the required initial value
|
||||
|
@ -1235,26 +1158,19 @@ ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, /*@null@*/ const Bytef *buf, uInt l
|
|||
* and the compiler's view of z_stream:
|
||||
*/
|
||||
ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
|
||||
const char *version, int stream_size))
|
||||
/*@globals internalState @*/
|
||||
/*@modifies strm, internalState @*/;
|
||||
const char *version, int stream_size));
|
||||
ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
|
||||
const char *version, int stream_size))
|
||||
/*@modifies strm @*/;
|
||||
const char *version, int stream_size));
|
||||
ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
|
||||
int windowBits, int memLevel,
|
||||
int strategy, const char *version,
|
||||
int stream_size))
|
||||
/*@globals internalState @*/
|
||||
/*@modifies strm, internalState @*/;
|
||||
int stream_size));
|
||||
ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
|
||||
const char *version, int stream_size))
|
||||
/*@modifies strm @*/;
|
||||
const char *version, int stream_size));
|
||||
ZEXTERN int ZEXPORT inflateBackInit_ OF((z_stream FAR *strm, int windowBits,
|
||||
unsigned char FAR *window,
|
||||
const char *version,
|
||||
int stream_size))
|
||||
/*@modifies strm @*/;
|
||||
int stream_size));
|
||||
#define deflateInit(strm, level) \
|
||||
deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
|
||||
#define inflateInit(strm) \
|
||||
|
@ -1273,14 +1189,9 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_stream FAR *strm, int windowBits,
|
|||
struct internal_state {int dummy;}; /* hack for buggy compilers */
|
||||
#endif
|
||||
|
||||
/*@observer@*/
|
||||
ZEXTERN const char * ZEXPORT zError OF((int err))
|
||||
/*@*/;
|
||||
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z))
|
||||
/*@modifies z @*/;
|
||||
/*@observer@*/
|
||||
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void))
|
||||
/*@*/;
|
||||
ZEXTERN const char * ZEXPORT zError OF((int));
|
||||
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
|
||||
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
33
zlib/zutil.c
33
zlib/zutil.c
|
@ -28,12 +28,12 @@ const char * const z_errmsg[10] = {
|
|||
""};
|
||||
|
||||
|
||||
const char * ZEXPORT zlibVersion(void)
|
||||
const char * ZEXPORT zlibVersion()
|
||||
{
|
||||
return ZLIB_VERSION;
|
||||
}
|
||||
|
||||
uLong ZEXPORT zlibCompileFlags(void)
|
||||
uLong ZEXPORT zlibCompileFlags()
|
||||
{
|
||||
uLong flags;
|
||||
|
||||
|
@ -123,7 +123,8 @@ uLong ZEXPORT zlibCompileFlags(void)
|
|||
# endif
|
||||
int z_verbose = verbose;
|
||||
|
||||
void z_error (char *m)
|
||||
void z_error (m)
|
||||
char *m;
|
||||
{
|
||||
fprintf(stderr, "%s\n", m);
|
||||
exit(1);
|
||||
|
@ -133,7 +134,8 @@ void z_error (char *m)
|
|||
/* exported to allow conversion of error code to string for compress() and
|
||||
* uncompress()
|
||||
*/
|
||||
const char * ZEXPORT zError(int err)
|
||||
const char * ZEXPORT zError(err)
|
||||
int err;
|
||||
{
|
||||
return ERR_MSG(err);
|
||||
}
|
||||
|
@ -145,7 +147,10 @@ const char * ZEXPORT zError(int err)
|
|||
|
||||
#ifndef HAVE_MEMCPY
|
||||
|
||||
void zmemcpy(Bytef* dest, const Bytef* source, uInt len)
|
||||
void zmemcpy(dest, source, len)
|
||||
Bytef* dest;
|
||||
const Bytef* source;
|
||||
uInt len;
|
||||
{
|
||||
if (len == 0) return;
|
||||
do {
|
||||
|
@ -153,7 +158,10 @@ void zmemcpy(Bytef* dest, const Bytef* source, uInt len)
|
|||
} while (--len != 0);
|
||||
}
|
||||
|
||||
int zmemcmp(const Bytef* s1, const Bytef* s2, uInt len)
|
||||
int zmemcmp(s1, s2, len)
|
||||
const Bytef* s1;
|
||||
const Bytef* s2;
|
||||
uInt len;
|
||||
{
|
||||
uInt j;
|
||||
|
||||
|
@ -163,7 +171,9 @@ int zmemcmp(const Bytef* s1, const Bytef* s2, uInt len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void zmemzero(Bytef* dest, uInt len)
|
||||
void zmemzero(dest, len)
|
||||
Bytef* dest;
|
||||
uInt len;
|
||||
{
|
||||
if (len == 0) return;
|
||||
do {
|
||||
|
@ -288,14 +298,19 @@ extern voidp calloc OF((uInt items, uInt size));
|
|||
extern void free OF((voidpf ptr));
|
||||
#endif
|
||||
|
||||
voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
|
||||
voidpf zcalloc (opaque, items, size)
|
||||
voidpf opaque;
|
||||
unsigned items;
|
||||
unsigned size;
|
||||
{
|
||||
if (opaque) items += size - size; /* make compiler happy */
|
||||
return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
|
||||
(voidpf)calloc(items, size);
|
||||
}
|
||||
|
||||
void zcfree (voidpf opaque, voidpf ptr)
|
||||
void zcfree (opaque, ptr)
|
||||
voidpf opaque;
|
||||
voidpf ptr;
|
||||
{
|
||||
free(ptr);
|
||||
if (opaque) return; /* make compiler happy */
|
||||
|
|
25
zlib/zutil.h
25
zlib/zutil.h
|
@ -38,14 +38,13 @@ typedef unsigned short ush;
|
|||
typedef ush FAR ushf;
|
||||
typedef unsigned long ulg;
|
||||
|
||||
/*@unchecked@*/ /*@observer@*/
|
||||
extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
||||
/* (size given to avoid silly warnings with Visual C++) */
|
||||
|
||||
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
|
||||
|
||||
#define ERR_RETURN(strm,err) \
|
||||
return /*@-mods@*/ (strm->msg = (char*)ERR_MSG(err), (err)) /*@=mods@*/
|
||||
return (strm->msg = (char*)ERR_MSG(err), (err))
|
||||
/* To be used only when the state is known to be valid */
|
||||
|
||||
/* common constants */
|
||||
|
@ -190,9 +189,14 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||
# define NO_vsnprintf
|
||||
# endif
|
||||
#endif
|
||||
#ifdef VMS
|
||||
# define NO_vsnprintf
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRERROR
|
||||
extern char *strerror OF((int));
|
||||
# ifndef VMS
|
||||
extern char *strerror OF((int));
|
||||
# endif
|
||||
# define zstrerror(errnum) strerror(errnum)
|
||||
#else
|
||||
# define zstrerror(errnum) ""
|
||||
|
@ -222,11 +226,9 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||
# define zmemzero(dest, len) memset(dest, 0, len)
|
||||
# endif
|
||||
#else
|
||||
extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len))
|
||||
/*@modifies dest @*/;
|
||||
extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len))\ /*@*/;
|
||||
extern void zmemzero OF((Bytef* dest, uInt len))
|
||||
/*@modifies dest @*/;
|
||||
extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
|
||||
extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
|
||||
extern void zmemzero OF((Bytef* dest, uInt len));
|
||||
#endif
|
||||
|
||||
/* Diagnostic functions */
|
||||
|
@ -250,11 +252,8 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
|
|||
#endif
|
||||
|
||||
|
||||
/*@null@*/
|
||||
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size))
|
||||
/*@*/;
|
||||
void zcfree OF((voidpf opaque, /*@only@*/ voidpf ptr))
|
||||
/*@modifies ptr @*/;
|
||||
voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
|
||||
void zcfree OF((voidpf opaque, voidpf ptr));
|
||||
|
||||
#define ZALLOC(strm, items, size) \
|
||||
(*((strm)->zalloc))((strm)->opaque, (items), (size))
|
||||
|
|
Loading…
Reference in New Issue