zlib 1.2.2
This commit is contained in:
parent
7a6955760b
commit
79fbcdc939
@ -1,6 +1,15 @@
|
|||||||
|
|
||||||
ChangeLog file for zlib
|
ChangeLog file for zlib
|
||||||
|
|
||||||
|
Changes in 1.2.2 (3 October 2004)
|
||||||
|
- Update zlib.h comments on gzip in-memory processing
|
||||||
|
- Set adler to 1 in inflateReset() to support Java test suite [Walles]
|
||||||
|
- Add contrib/dotzlib [Ravn]
|
||||||
|
- Update win32/DLL_FAQ.txt [Truta]
|
||||||
|
- Update contrib/minizip [Vollant]
|
||||||
|
- Move contrib/visual-basic.txt to old/ [Truta]
|
||||||
|
- Fix assembler builds in projects/visualc6/ [Truta]
|
||||||
|
|
||||||
Changes in 1.2.1.2 (9 September 2004)
|
Changes in 1.2.1.2 (9 September 2004)
|
||||||
- Update INDEX file
|
- Update INDEX file
|
||||||
- Fix trees.c to update strm->data_type (no one ever noticed!)
|
- Fix trees.c to update strm->data_type (no one ever noticed!)
|
||||||
|
2
FAQ
2
FAQ
@ -117,7 +117,7 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html
|
|||||||
After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib
|
After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib
|
||||||
generates an error such as:
|
generates an error such as:
|
||||||
|
|
||||||
ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so:
|
ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so:
|
||||||
symbol __register_frame_info: referenced symbol not found
|
symbol __register_frame_info: referenced symbol not found
|
||||||
|
|
||||||
The symbol __register_frame_info is not part of zlib, it is generated by
|
The symbol __register_frame_info is not part of zlib, it is generated by
|
||||||
|
2
INDEX
2
INDEX
@ -8,7 +8,7 @@ algorithm.txt description of the (de)compression algorithm
|
|||||||
configure configure script for Unix
|
configure configure script for Unix
|
||||||
zconf.in.h template for zconf.h (used by configure)
|
zconf.in.h template for zconf.h (used by configure)
|
||||||
|
|
||||||
amiga/ makefiles for Amiga SAS C
|
amiga/ makefiles for Amiga SAS C
|
||||||
as400/ makefiles for IBM AS/400
|
as400/ makefiles for IBM AS/400
|
||||||
msdos/ makefiles for MSDOS
|
msdos/ makefiles for MSDOS
|
||||||
old/ makefiles for various architectures and zlib documentation
|
old/ makefiles for various architectures and zlib documentation
|
||||||
|
2
Makefile
2
Makefile
@ -30,7 +30,7 @@ CPP=$(CC) -E
|
|||||||
|
|
||||||
LIBS=libz.a
|
LIBS=libz.a
|
||||||
SHAREDLIB=libz.so
|
SHAREDLIB=libz.so
|
||||||
SHAREDLIBV=libz.so.1.2.1.2
|
SHAREDLIBV=libz.so.1.2.2
|
||||||
SHAREDLIBM=libz.so.1
|
SHAREDLIBM=libz.so.1
|
||||||
|
|
||||||
AR=ar rc
|
AR=ar rc
|
||||||
|
@ -30,7 +30,7 @@ CPP=$(CC) -E
|
|||||||
|
|
||||||
LIBS=libz.a
|
LIBS=libz.a
|
||||||
SHAREDLIB=libz.so
|
SHAREDLIB=libz.so
|
||||||
SHAREDLIBV=libz.so.1.2.1.2
|
SHAREDLIBV=libz.so.1.2.2
|
||||||
SHAREDLIBM=libz.so.1
|
SHAREDLIBM=libz.so.1
|
||||||
|
|
||||||
AR=ar rc
|
AR=ar rc
|
||||||
|
4
README
4
README
@ -1,6 +1,6 @@
|
|||||||
ZLIB DATA COMPRESSION LIBRARY
|
ZLIB DATA COMPRESSION LIBRARY
|
||||||
|
|
||||||
zlib 1.2.1.2 is a general purpose data compression library. All the code is
|
zlib 1.2.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
|
thread safe. The data format used by the zlib library is described by RFCs
|
||||||
(Request for Comments) 1950 to 1952 in the files
|
(Request for Comments) 1950 to 1952 in the files
|
||||||
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
|
http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format)
|
||||||
@ -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
|
issue of Dr. Dobb's Journal; a copy of the article is available in
|
||||||
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
|
http://dogma.net/markn/articles/zlibtool/zlibtool.htm
|
||||||
|
|
||||||
The changes made in version 1.2.1.2 are documented in the file ChangeLog.
|
The changes made in version 1.2.2 are documented in the file ChangeLog.
|
||||||
|
|
||||||
Unsupported third party contributions are provided in directory "contrib".
|
Unsupported third party contributions are provided in directory "contrib".
|
||||||
|
|
||||||
|
@ -118,6 +118,6 @@
|
|||||||
&MODLIB/INFTREES &MODLIB/TREES +
|
&MODLIB/INFTREES &MODLIB/TREES +
|
||||||
&MODLIB/UNCOMPR &MODLIB/ZUTIL) +
|
&MODLIB/UNCOMPR &MODLIB/ZUTIL) +
|
||||||
SRCFILE(&SRCLIB/&CTLFILE) SRCMBR(BNDSRC) +
|
SRCFILE(&SRCLIB/&CTLFILE) SRCMBR(BNDSRC) +
|
||||||
TEXT('ZLIB 1.2.1') TGTRLS(V4R4M0)
|
TEXT('ZLIB 1.2.2') TGTRLS(V4R4M0)
|
||||||
|
|
||||||
ENDPGM
|
ENDPGM
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
ZLIB version 1.2.1 for AS400 installation instructions
|
ZLIB version 1.2.2 for AS400 installation instructions
|
||||||
|
|
||||||
I) From an AS400 *SAVF file:
|
I) From an AS400 *SAVF file:
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
* ZLIB.INC - Interface to the general purpose compression library
|
* ZLIB.INC - Interface to the general purpose compression library
|
||||||
*
|
*
|
||||||
* ILE RPG400 version by Patrick Monnerat, DATASPHERE.
|
* ILE RPG400 version by Patrick Monnerat, DATASPHERE.
|
||||||
* Version 1.2.1.2
|
* Version 1.2.2
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* WARNING:
|
* WARNING:
|
||||||
@ -20,8 +20,8 @@
|
|||||||
* Constants
|
* Constants
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
*
|
*
|
||||||
D ZLIB_VERSION C '1.2.1.2' Header's version
|
D ZLIB_VERSION C '1.2.2' Header's version
|
||||||
D ZLIB_VERNUM C X'1212'
|
D ZLIB_VERNUM C X'1220'
|
||||||
*
|
*
|
||||||
D Z_NO_FLUSH C 0
|
D Z_NO_FLUSH C 0
|
||||||
D Z_SYNC_FLUSH C 2
|
D Z_SYNC_FLUSH C 2
|
||||||
|
@ -19,6 +19,9 @@ blast/ by Mark Adler <madler@alumni.caltech.edu>
|
|||||||
delphi/ by Cosmin Truta <cosmint@cs.ubbcluj.ro>
|
delphi/ by Cosmin Truta <cosmint@cs.ubbcluj.ro>
|
||||||
Support for Delphi and C++ Builder
|
Support for Delphi and C++ Builder
|
||||||
|
|
||||||
|
dotzlib/ by Henrik Ravn <henrik@ravn.com>
|
||||||
|
Support for Microsoft .Net and Visual C++ .Net
|
||||||
|
|
||||||
gzappend/ by Mark Adler <madler@alumni.caltech.edu>
|
gzappend/ by Mark Adler <madler@alumni.caltech.edu>
|
||||||
append to a gzip file -- illustrates the use of Z_BLOCK
|
append to a gzip file -- illustrates the use of Z_BLOCK
|
||||||
|
|
||||||
@ -60,11 +63,8 @@ puff/ by Mark Adler <madler@alumni.caltech.edu>
|
|||||||
testzlib/ by Gilles Vollant <info@winimage.com>
|
testzlib/ by Gilles Vollant <info@winimage.com>
|
||||||
Example of the use of zlib
|
Example of the use of zlib
|
||||||
|
|
||||||
untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es>
|
untgz/ by Pedro A. Aranda Gutierrez <paag@tid.es>
|
||||||
A very simple tar.gz file extractor using zlib
|
A very simple tar.gz file extractor using zlib
|
||||||
|
|
||||||
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>
|
vstudio/ by Gilles Vollant <info@winimage.com>
|
||||||
Building a minizip-enhanced zlib with Visual Studio .NET
|
Building a minizip-enhanced zlib with Microsoft Visual Studio
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
ZLib for Ada thick binding (ZLib.Ada)
|
ZLib for Ada thick binding (ZLib.Ada)
|
||||||
Release 1.3
|
Release 1.3
|
||||||
|
|
||||||
ZLib.Ada is a thick binding interface to the popular ZLib data
|
ZLib.Ada is a thick binding interface to the popular ZLib data
|
||||||
compression library, available at http://www.gzip.org/zlib/.
|
compression library, available at http://www.gzip.org/zlib/.
|
||||||
It provides Ada-style access to the ZLib C library.
|
It provides Ada-style access to the ZLib C library.
|
||||||
|
|
||||||
|
|
||||||
Here are the main changes since ZLib.Ada 1.2:
|
Here are the main changes since ZLib.Ada 1.2:
|
||||||
|
|
||||||
- Attension: ZLib.Read generic routine have a initialization requirement
|
- Attension: ZLib.Read generic routine have a initialization requirement
|
||||||
for Read_Last parameter now. It is a bit incompartible with previous version,
|
for Read_Last parameter now. It is a bit incompartible with previous version,
|
||||||
@ -28,7 +28,7 @@ It provides Ada-style access to the ZLib C library.
|
|||||||
- Add pragma Assertion that Ada.Streams.Stream_Element size is 8 bit.
|
- Add pragma Assertion that Ada.Streams.Stream_Element size is 8 bit.
|
||||||
|
|
||||||
|
|
||||||
How to build ZLib.Ada under GNAT
|
How to build ZLib.Ada under GNAT
|
||||||
|
|
||||||
You should have the ZLib library already build on your computer, before
|
You should have the ZLib library already build on your computer, before
|
||||||
building ZLib.Ada. Make the directory of ZLib.Ada sources current and
|
building ZLib.Ada. Make the directory of ZLib.Ada sources current and
|
||||||
@ -41,7 +41,7 @@ Or use the GNAT project file build for GNAT 3.15 or later:
|
|||||||
gnatmake -Pzlib.gpr -L<directory where libz.a is>
|
gnatmake -Pzlib.gpr -L<directory where libz.a is>
|
||||||
|
|
||||||
|
|
||||||
How to build ZLib.Ada under Aonix ObjectAda for Win32 7.2.2
|
How to build ZLib.Ada under Aonix ObjectAda for Win32 7.2.2
|
||||||
|
|
||||||
1. Make a project with all *.ads and *.adb files from the distribution.
|
1. Make a project with all *.ads and *.adb files from the distribution.
|
||||||
2. Build the libz.a library from the ZLib C sources.
|
2. Build the libz.a library from the ZLib C sources.
|
||||||
@ -51,7 +51,7 @@ Or use the GNAT project file build for GNAT 3.15 or later:
|
|||||||
6. Build the executable using test.adb as a main procedure.
|
6. Build the executable using test.adb as a main procedure.
|
||||||
|
|
||||||
|
|
||||||
How to use ZLib.Ada
|
How to use ZLib.Ada
|
||||||
|
|
||||||
The source files test.adb and read.adb are small demo programs that show
|
The source files test.adb and read.adb are small demo programs that show
|
||||||
the main functionality of ZLib.Ada.
|
the main functionality of ZLib.Ada.
|
||||||
|
@ -222,4 +222,4 @@ package body ZLib.Streams is
|
|||||||
return Total_Out (Stream.Writer);
|
return Total_Out (Stream.Writer);
|
||||||
end Write_Total_Out;
|
end Write_Total_Out;
|
||||||
|
|
||||||
end ZLib.Streams;
|
end ZLib.Streams;
|
||||||
|
@ -111,4 +111,4 @@ private
|
|||||||
Writer : Filter_Type;
|
Writer : Filter_Type;
|
||||||
end record;
|
end record;
|
||||||
|
|
||||||
end ZLib.Streams;
|
end ZLib.Streams;
|
||||||
|
@ -1,21 +1,20 @@
|
|||||||
project Zlib is
|
project Zlib is
|
||||||
|
|
||||||
for Languages use ("Ada");
|
for Languages use ("Ada");
|
||||||
for Source_Dirs use (".");
|
for Source_Dirs use (".");
|
||||||
for Object_Dir use ".";
|
for Object_Dir use ".";
|
||||||
for Main use ("test.adb", "mtest.adb", "read.adb", "buffer_demo");
|
for Main use ("test.adb", "mtest.adb", "read.adb", "buffer_demo");
|
||||||
|
|
||||||
package Compiler is
|
package Compiler is
|
||||||
for Default_Switches ("ada") use ("-gnatwcfilopru", "-gnatVcdfimorst", "-gnatyabcefhiklmnoprst");
|
for Default_Switches ("ada") use ("-gnatwcfilopru", "-gnatVcdfimorst", "-gnatyabcefhiklmnoprst");
|
||||||
end Compiler;
|
end Compiler;
|
||||||
|
|
||||||
package Linker is
|
package Linker is
|
||||||
for Default_Switches ("ada") use ("-lz");
|
for Default_Switches ("ada") use ("-lz");
|
||||||
end Linker;
|
end Linker;
|
||||||
|
|
||||||
package Builder is
|
package Builder is
|
||||||
for Default_Switches ("ada") use ("-s", "-gnatQ");
|
for Default_Switches ("ada") use ("-s", "-gnatQ");
|
||||||
end Builder;
|
end Builder;
|
||||||
|
|
||||||
end Zlib;
|
end Zlib;
|
||||||
|
|
||||||
|
33
contrib/dotzlib/DotZLib.build
Normal file
33
contrib/dotzlib/DotZLib.build
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<project name="DotZLib" default="build" basedir="./DotZLib">
|
||||||
|
<description>A .Net wrapper library around ZLib1.dll</description>
|
||||||
|
|
||||||
|
<property name="nunit.location" value="c:/program files/NUnit V2.1/bin" />
|
||||||
|
<property name="build.root" value="bin" />
|
||||||
|
|
||||||
|
<property name="debug" value="true" />
|
||||||
|
<property name="nunit" value="true" />
|
||||||
|
|
||||||
|
<property name="build.folder" value="${build.root}/debug/" if="${debug}" />
|
||||||
|
<property name="build.folder" value="${build.root}/release/" unless="${debug}" />
|
||||||
|
|
||||||
|
<target name="clean" description="Remove all generated files">
|
||||||
|
<delete dir="${build.root}" failonerror="false" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="build" description="compiles the source code">
|
||||||
|
|
||||||
|
<mkdir dir="${build.folder}" />
|
||||||
|
<csc target="library" output="${build.folder}DotZLib.dll" debug="${debug}">
|
||||||
|
<references basedir="${nunit.location}">
|
||||||
|
<includes if="${nunit}" name="nunit.framework.dll" />
|
||||||
|
</references>
|
||||||
|
<sources>
|
||||||
|
<includes name="*.cs" />
|
||||||
|
<excludes name="UnitTests.cs" unless="${nunit}" />
|
||||||
|
</sources>
|
||||||
|
<arg value="/d:nunit" if="${nunit}" />
|
||||||
|
</csc>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
</project>
|
BIN
contrib/dotzlib/DotZLib.chm
Normal file
BIN
contrib/dotzlib/DotZLib.chm
Normal file
Binary file not shown.
21
contrib/dotzlib/DotZLib.sln
Normal file
21
contrib/dotzlib/DotZLib.sln
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotZLib", "DotZLib\DotZLib.csproj", "{BB1EE0B1-1808-46CB-B786-949D91117FC5}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfiguration) = preSolution
|
||||||
|
Debug = Debug
|
||||||
|
Release = Release
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfiguration) = postSolution
|
||||||
|
{BB1EE0B1-1808-46CB-B786-949D91117FC5}.Debug.ActiveCfg = Debug|.NET
|
||||||
|
{BB1EE0B1-1808-46CB-B786-949D91117FC5}.Debug.Build.0 = Debug|.NET
|
||||||
|
{BB1EE0B1-1808-46CB-B786-949D91117FC5}.Release.ActiveCfg = Release|.NET
|
||||||
|
{BB1EE0B1-1808-46CB-B786-949D91117FC5}.Release.Build.0 = Release|.NET
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
58
contrib/dotzlib/DotZLib/AssemblyInfo.cs
Normal file
58
contrib/dotzlib/DotZLib/AssemblyInfo.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
//
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
//
|
||||||
|
[assembly: AssemblyTitle("DotZLib")]
|
||||||
|
[assembly: AssemblyDescription(".Net bindings for ZLib compression dll 1.2.x")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("Henrik Ravn")]
|
||||||
|
[assembly: AssemblyProduct("")]
|
||||||
|
[assembly: AssemblyCopyright("(c) 2004 by Henrik Ravn")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
//
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Revision and Build Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
|
||||||
|
[assembly: AssemblyVersion("1.0.*")]
|
||||||
|
|
||||||
|
//
|
||||||
|
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||||
|
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||||
|
//
|
||||||
|
// Use the attributes below to control which key is used for signing.
|
||||||
|
//
|
||||||
|
// Notes:
|
||||||
|
// (*) If no key is specified, the assembly is not signed.
|
||||||
|
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||||
|
// Provider (CSP) on your machine. KeyFile refers to a file which contains
|
||||||
|
// a key.
|
||||||
|
// (*) If the KeyFile and the KeyName values are both specified, the
|
||||||
|
// following processing occurs:
|
||||||
|
// (1) If the KeyName can be found in the CSP, that key is used.
|
||||||
|
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||||
|
// in the KeyFile is installed into the CSP and used.
|
||||||
|
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
|
||||||
|
// When specifying the KeyFile, the location of the KeyFile should be
|
||||||
|
// relative to the project output directory which is
|
||||||
|
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
|
||||||
|
// located in the project directory, you would specify the AssemblyKeyFile
|
||||||
|
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
||||||
|
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||||
|
// documentation for more information on this.
|
||||||
|
//
|
||||||
|
[assembly: AssemblyDelaySign(false)]
|
||||||
|
[assembly: AssemblyKeyFile("")]
|
||||||
|
[assembly: AssemblyKeyName("")]
|
202
contrib/dotzlib/DotZLib/ChecksumImpl.cs
Normal file
202
contrib/dotzlib/DotZLib/ChecksumImpl.cs
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
//
|
||||||
|
// © Copyright Henrik Ravn 2004
|
||||||
|
//
|
||||||
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DotZLib
|
||||||
|
{
|
||||||
|
#region ChecksumGeneratorBase
|
||||||
|
/// <summary>
|
||||||
|
/// Implements the common functionality needed for all <see cref="ChecksumGenerator"/>s
|
||||||
|
/// </summary>
|
||||||
|
/// <example></example>
|
||||||
|
public abstract class ChecksumGeneratorBase : ChecksumGenerator
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The value of the current checksum
|
||||||
|
/// </summary>
|
||||||
|
protected uint _current;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the checksum generator base - the current checksum is
|
||||||
|
/// set to zero
|
||||||
|
/// </summary>
|
||||||
|
public ChecksumGeneratorBase()
|
||||||
|
{
|
||||||
|
_current = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the checksum generator basewith a specified value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="initialValue">The value to set the current checksum to</param>
|
||||||
|
public ChecksumGeneratorBase(uint initialValue)
|
||||||
|
{
|
||||||
|
_current = initialValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the current checksum to zero
|
||||||
|
/// </summary>
|
||||||
|
public void Reset() { _current = 0; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current checksum value
|
||||||
|
/// </summary>
|
||||||
|
public uint Value { get { return _current; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the current checksum with part of an array of bytes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The data to update the checksum with</param>
|
||||||
|
/// <param name="offset">Where in <c>data</c> to start updating</param>
|
||||||
|
/// <param name="count">The number of bytes from <c>data</c> to use</param>
|
||||||
|
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
|
||||||
|
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
|
||||||
|
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
|
||||||
|
/// <remarks>All the other <c>Update</c> methods are implmeneted in terms of this one.
|
||||||
|
/// This is therefore the only method a derived class has to implement</remarks>
|
||||||
|
public abstract void Update(byte[] data, int offset, int count);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the current checksum with an array of bytes.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The data to update the checksum with</param>
|
||||||
|
public void Update(byte[] data)
|
||||||
|
{
|
||||||
|
Update(data, 0, data.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the current checksum with the data from a string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The string to update the checksum with</param>
|
||||||
|
/// <remarks>The characters in the string are converted by the UTF-8 encoding</remarks>
|
||||||
|
public void Update(string data)
|
||||||
|
{
|
||||||
|
Update(Encoding.UTF8.GetBytes(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the current checksum with the data from a string, using a specific encoding
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The string to update the checksum with</param>
|
||||||
|
/// <param name="encoding">The encoding to use</param>
|
||||||
|
public void Update(string data, Encoding encoding)
|
||||||
|
{
|
||||||
|
Update(encoding.GetBytes(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region CRC32
|
||||||
|
/// <summary>
|
||||||
|
/// Implements a CRC32 checksum generator
|
||||||
|
/// </summary>
|
||||||
|
public sealed class CRC32Checksum : ChecksumGeneratorBase
|
||||||
|
{
|
||||||
|
#region DLL imports
|
||||||
|
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern uint crc32(uint crc, int data, uint length);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the CRC32 checksum generator
|
||||||
|
/// </summary>
|
||||||
|
public CRC32Checksum() : base() {}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the CRC32 checksum generator with a specified value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="initialValue">The value to set the current checksum to</param>
|
||||||
|
public CRC32Checksum(uint initialValue) : base(initialValue) {}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the current checksum with part of an array of bytes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The data to update the checksum with</param>
|
||||||
|
/// <param name="offset">Where in <c>data</c> to start updating</param>
|
||||||
|
/// <param name="count">The number of bytes from <c>data</c> to use</param>
|
||||||
|
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
|
||||||
|
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
|
||||||
|
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
|
||||||
|
public override void Update(byte[] data, int offset, int count)
|
||||||
|
{
|
||||||
|
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
|
||||||
|
if ((offset+count) > data.Length) throw new ArgumentException();
|
||||||
|
GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_current = crc32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
hData.Free();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Adler
|
||||||
|
/// <summary>
|
||||||
|
/// Implements a checksum generator that computes the Adler checksum on data
|
||||||
|
/// </summary>
|
||||||
|
public sealed class AdlerChecksum : ChecksumGeneratorBase
|
||||||
|
{
|
||||||
|
#region DLL imports
|
||||||
|
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern uint adler32(uint adler, int data, uint length);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the Adler checksum generator
|
||||||
|
/// </summary>
|
||||||
|
public AdlerChecksum() : base() {}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the Adler checksum generator with a specified value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="initialValue">The value to set the current checksum to</param>
|
||||||
|
public AdlerChecksum(uint initialValue) : base(initialValue) {}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the current checksum with part of an array of bytes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The data to update the checksum with</param>
|
||||||
|
/// <param name="offset">Where in <c>data</c> to start updating</param>
|
||||||
|
/// <param name="count">The number of bytes from <c>data</c> to use</param>
|
||||||
|
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
|
||||||
|
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
|
||||||
|
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
|
||||||
|
public override void Update(byte[] data, int offset, int count)
|
||||||
|
{
|
||||||
|
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
|
||||||
|
if ((offset+count) > data.Length) throw new ArgumentException();
|
||||||
|
GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_current = adler32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
hData.Free();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
83
contrib/dotzlib/DotZLib/CircularBuffer.cs
Normal file
83
contrib/dotzlib/DotZLib/CircularBuffer.cs
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
//
|
||||||
|
// © Copyright Henrik Ravn 2004
|
||||||
|
//
|
||||||
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace DotZLib
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class implements a circular buffer
|
||||||
|
/// </summary>
|
||||||
|
internal class CircularBuffer
|
||||||
|
{
|
||||||
|
#region Private data
|
||||||
|
private int _capacity;
|
||||||
|
private int _head;
|
||||||
|
private int _tail;
|
||||||
|
private int _size;
|
||||||
|
private byte[] _buffer;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public CircularBuffer(int capacity)
|
||||||
|
{
|
||||||
|
Debug.Assert( capacity > 0 );
|
||||||
|
_buffer = new byte[capacity];
|
||||||
|
_capacity = capacity;
|
||||||
|
_head = 0;
|
||||||
|
_tail = 0;
|
||||||
|
_size = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Size { get { return _size; } }
|
||||||
|
|
||||||
|
public int Put(byte[] source, int offset, int count)
|
||||||
|
{
|
||||||
|
Debug.Assert( count > 0 );
|
||||||
|
int trueCount = Math.Min(count, _capacity - Size);
|
||||||
|
for (int i = 0; i < trueCount; ++i)
|
||||||
|
_buffer[(_tail+i) % _capacity] = source[offset+i];
|
||||||
|
_tail += trueCount;
|
||||||
|
_tail %= _capacity;
|
||||||
|
_size += trueCount;
|
||||||
|
return trueCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Put(byte b)
|
||||||
|
{
|
||||||
|
if (Size == _capacity) // no room
|
||||||
|
return false;
|
||||||
|
_buffer[_tail++] = b;
|
||||||
|
_tail %= _capacity;
|
||||||
|
++_size;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Get(byte[] destination, int offset, int count)
|
||||||
|
{
|
||||||
|
int trueCount = Math.Min(count,Size);
|
||||||
|
for (int i = 0; i < trueCount; ++i)
|
||||||
|
destination[offset + i] = _buffer[(_head+i) % _capacity];
|
||||||
|
_head += trueCount;
|
||||||
|
_head %= _capacity;
|
||||||
|
_size -= trueCount;
|
||||||
|
return trueCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Get()
|
||||||
|
{
|
||||||
|
if (Size == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
int result = (int)_buffer[_head++ % _capacity];
|
||||||
|
--_size;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
198
contrib/dotzlib/DotZLib/CodecBase.cs
Normal file
198
contrib/dotzlib/DotZLib/CodecBase.cs
Normal file
@ -0,0 +1,198 @@
|
|||||||
|
//
|
||||||
|
// © Copyright Henrik Ravn 2004
|
||||||
|
//
|
||||||
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace DotZLib
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Implements the common functionality needed for all <see cref="Codec"/>s
|
||||||
|
/// </summary>
|
||||||
|
public abstract class CodecBase : Codec, IDisposable
|
||||||
|
{
|
||||||
|
|
||||||
|
#region Data members
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Instance of the internal zlib buffer structure that is
|
||||||
|
/// passed to all functions in the zlib dll
|
||||||
|
/// </summary>
|
||||||
|
internal ZStream _ztream = new ZStream();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True if the object instance has been disposed, false otherwise
|
||||||
|
/// </summary>
|
||||||
|
protected bool _isDisposed = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The size of the internal buffers
|
||||||
|
/// </summary>
|
||||||
|
protected const int kBufferSize = 16384;
|
||||||
|
|
||||||
|
private byte[] _outBuffer = new byte[kBufferSize];
|
||||||
|
private byte[] _inBuffer = new byte[kBufferSize];
|
||||||
|
|
||||||
|
private GCHandle _hInput;
|
||||||
|
private GCHandle _hOutput;
|
||||||
|
|
||||||
|
private uint _checksum = 0;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <c>CodeBase</c> class.
|
||||||
|
/// </summary>
|
||||||
|
public CodecBase()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_hInput = GCHandle.Alloc(_inBuffer, GCHandleType.Pinned);
|
||||||
|
_hOutput = GCHandle.Alloc(_outBuffer, GCHandleType.Pinned);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
CleanUp(false);
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region Codec Members
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs when more processed data are available.
|
||||||
|
/// </summary>
|
||||||
|
public event DataAvailableHandler DataAvailable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fires the <see cref="DataAvailable"/> event
|
||||||
|
/// </summary>
|
||||||
|
protected void OnDataAvailable()
|
||||||
|
{
|
||||||
|
if (_ztream.total_out > 0)
|
||||||
|
{
|
||||||
|
if (DataAvailable != null)
|
||||||
|
DataAvailable( _outBuffer, 0, (int)_ztream.total_out);
|
||||||
|
resetOutput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds more data to the codec to be processed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">Byte array containing the data to be added to the codec</param>
|
||||||
|
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
|
||||||
|
public void Add(byte[] data)
|
||||||
|
{
|
||||||
|
Add(data,0,data.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds more data to the codec to be processed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">Byte array containing the data to be added to the codec</param>
|
||||||
|
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
|
||||||
|
/// <param name="count">The number of bytes to add</param>
|
||||||
|
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
|
||||||
|
/// <remarks>This must be implemented by a derived class</remarks>
|
||||||
|
public abstract void Add(byte[] data, int offset, int count);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Finishes up any pending data that needs to be processed and handled.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This must be implemented by a derived class</remarks>
|
||||||
|
public abstract void Finish();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the checksum of the data that has been added so far
|
||||||
|
/// </summary>
|
||||||
|
public uint Checksum { get { return _checksum; } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Destructor & IDisposable stuff
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Destroys this instance
|
||||||
|
/// </summary>
|
||||||
|
~CodecBase()
|
||||||
|
{
|
||||||
|
CleanUp(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Releases any unmanaged resources and calls the <see cref="CleanUp()"/> method of the derived class
|
||||||
|
/// </summary>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
CleanUp(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Performs any codec specific cleanup
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>This must be implemented by a derived class</remarks>
|
||||||
|
protected abstract void CleanUp();
|
||||||
|
|
||||||
|
// performs the release of the handles and calls the dereived CleanUp()
|
||||||
|
private void CleanUp(bool isDisposing)
|
||||||
|
{
|
||||||
|
if (!_isDisposed)
|
||||||
|
{
|
||||||
|
CleanUp();
|
||||||
|
if (_hInput.IsAllocated)
|
||||||
|
_hInput.Free();
|
||||||
|
if (_hOutput.IsAllocated)
|
||||||
|
_hOutput.Free();
|
||||||
|
|
||||||
|
_isDisposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Helper methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Copies a number of bytes to the internal codec buffer - ready for proccesing
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The byte array that contains the data to copy</param>
|
||||||
|
/// <param name="startIndex">The index of the first byte to copy</param>
|
||||||
|
/// <param name="count">The number of bytes to copy from <c>data</c></param>
|
||||||
|
protected void copyInput(byte[] data, int startIndex, int count)
|
||||||
|
{
|
||||||
|
Array.Copy(data, startIndex, _inBuffer,0, count);
|
||||||
|
_ztream.next_in = _hInput.AddrOfPinnedObject();
|
||||||
|
_ztream.total_in = 0;
|
||||||
|
_ztream.avail_in = (uint)count;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the internal output buffers to a known state - ready for processing
|
||||||
|
/// </summary>
|
||||||
|
protected void resetOutput()
|
||||||
|
{
|
||||||
|
_ztream.total_out = 0;
|
||||||
|
_ztream.avail_out = kBufferSize;
|
||||||
|
_ztream.next_out = _hOutput.AddrOfPinnedObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the running checksum property
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newSum">The new checksum value</param>
|
||||||
|
protected void setChecksum(uint newSum)
|
||||||
|
{
|
||||||
|
_checksum = newSum;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
106
contrib/dotzlib/DotZLib/Deflater.cs
Normal file
106
contrib/dotzlib/DotZLib/Deflater.cs
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
//
|
||||||
|
// © Copyright Henrik Ravn 2004
|
||||||
|
//
|
||||||
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace DotZLib
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Implements a data compressor, using the deflate algorithm in the ZLib dll
|
||||||
|
/// </summary>
|
||||||
|
public sealed class Deflater : CodecBase
|
||||||
|
{
|
||||||
|
#region Dll imports
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
|
||||||
|
private static extern int deflateInit_(ref ZStream sz, int level, string vs, int size);
|
||||||
|
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern int deflate(ref ZStream sz, int flush);
|
||||||
|
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern int deflateReset(ref ZStream sz);
|
||||||
|
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern int deflateEnd(ref ZStream sz);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs an new instance of the <c>Deflater</c>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="level">The compression level to use for this <c>Deflater</c></param>
|
||||||
|
public Deflater(CompressLevel level) : base()
|
||||||
|
{
|
||||||
|
int retval = deflateInit_(ref _ztream, (int)level, Info.Version, Marshal.SizeOf(_ztream));
|
||||||
|
if (retval != 0)
|
||||||
|
throw new ZLibException(retval, "Could not initialize deflater");
|
||||||
|
|
||||||
|
resetOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds more data to the codec to be processed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">Byte array containing the data to be added to the codec</param>
|
||||||
|
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
|
||||||
|
/// <param name="count">The number of bytes to add</param>
|
||||||
|
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
|
||||||
|
public override void Add(byte[] data, int offset, int count)
|
||||||
|
{
|
||||||
|
if (data == null) throw new ArgumentNullException();
|
||||||
|
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
|
||||||
|
if ((offset+count) > data.Length) throw new ArgumentException();
|
||||||
|
|
||||||
|
int total = count;
|
||||||
|
int inputIndex = offset;
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
while (err >= 0 && inputIndex < total)
|
||||||
|
{
|
||||||
|
copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize));
|
||||||
|
while (err >= 0 && _ztream.avail_in > 0)
|
||||||
|
{
|
||||||
|
err = deflate(ref _ztream, (int)FlushTypes.None);
|
||||||
|
if (err == 0)
|
||||||
|
while (_ztream.avail_out == 0)
|
||||||
|
{
|
||||||
|
OnDataAvailable();
|
||||||
|
err = deflate(ref _ztream, (int)FlushTypes.None);
|
||||||
|
}
|
||||||
|
inputIndex += (int)_ztream.total_in;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setChecksum( _ztream.adler );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Finishes up any pending data that needs to be processed and handled.
|
||||||
|
/// </summary>
|
||||||
|
public override void Finish()
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
err = deflate(ref _ztream, (int)FlushTypes.Finish);
|
||||||
|
OnDataAvailable();
|
||||||
|
}
|
||||||
|
while (err == 0);
|
||||||
|
setChecksum( _ztream.adler );
|
||||||
|
deflateReset(ref _ztream);
|
||||||
|
resetOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the internal zlib deflate stream
|
||||||
|
/// </summary>
|
||||||
|
protected override void CleanUp() { deflateEnd(ref _ztream); }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
288
contrib/dotzlib/DotZLib/DotZLib.cs
Normal file
288
contrib/dotzlib/DotZLib/DotZLib.cs
Normal file
@ -0,0 +1,288 @@
|
|||||||
|
//
|
||||||
|
// © Copyright Henrik Ravn 2004
|
||||||
|
//
|
||||||
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DotZLib
|
||||||
|
{
|
||||||
|
|
||||||
|
#region Internal types
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Defines constants for the various flush types used with zlib
|
||||||
|
/// </summary>
|
||||||
|
internal enum FlushTypes
|
||||||
|
{
|
||||||
|
None, Partial, Sync, Full, Finish, Block
|
||||||
|
}
|
||||||
|
|
||||||
|
#region ZStream structure
|
||||||
|
// internal mapping of the zlib zstream structure for marshalling
|
||||||
|
[StructLayoutAttribute(LayoutKind.Sequential, Pack=4, Size=0, CharSet=CharSet.Ansi)]
|
||||||
|
internal struct ZStream
|
||||||
|
{
|
||||||
|
public IntPtr next_in;
|
||||||
|
public uint avail_in;
|
||||||
|
public uint total_in;
|
||||||
|
|
||||||
|
public IntPtr next_out;
|
||||||
|
public uint avail_out;
|
||||||
|
public uint total_out;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.LPStr)]
|
||||||
|
string msg;
|
||||||
|
uint state;
|
||||||
|
|
||||||
|
uint zalloc;
|
||||||
|
uint zfree;
|
||||||
|
uint opaque;
|
||||||
|
|
||||||
|
int data_type;
|
||||||
|
public uint adler;
|
||||||
|
uint reserved;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public enums
|
||||||
|
/// <summary>
|
||||||
|
/// Defines constants for the available compression levels in zlib
|
||||||
|
/// </summary>
|
||||||
|
public enum CompressLevel : int
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The default compression level with a reasonable compromise between compression and speed
|
||||||
|
/// </summary>
|
||||||
|
Default = -1,
|
||||||
|
/// <summary>
|
||||||
|
/// No compression at all. The data are passed straight through.
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum compression rate available.
|
||||||
|
/// </summary>
|
||||||
|
Best = 9,
|
||||||
|
/// <summary>
|
||||||
|
/// The fastest available compression level.
|
||||||
|
/// </summary>
|
||||||
|
Fastest = 1
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Exception classes
|
||||||
|
/// <summary>
|
||||||
|
/// The exception that is thrown when an error occurs on the zlib dll
|
||||||
|
/// </summary>
|
||||||
|
public class ZLibException : ApplicationException
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ZLibException"/> class with a specified
|
||||||
|
/// error message and error code
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="errorCode">The zlib error code that caused the exception</param>
|
||||||
|
/// <param name="msg">A message that (hopefully) describes the error</param>
|
||||||
|
public ZLibException(int errorCode, string msg) : base(String.Format("ZLib error {0} {1}", errorCode, msg))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="ZLibException"/> class with a specified
|
||||||
|
/// error code
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="errorCode">The zlib error code that caused the exception</param>
|
||||||
|
public ZLibException(int errorCode) : base(String.Format("ZLib error {0}", errorCode))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Interfaces
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Declares methods and properties that enables a running checksum to be calculated
|
||||||
|
/// </summary>
|
||||||
|
public interface ChecksumGenerator
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current value of the checksum
|
||||||
|
/// </summary>
|
||||||
|
uint Value { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clears the current checksum to 0
|
||||||
|
/// </summary>
|
||||||
|
void Reset();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the current checksum with an array of bytes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The data to update the checksum with</param>
|
||||||
|
void Update(byte[] data);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the current checksum with part of an array of bytes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The data to update the checksum with</param>
|
||||||
|
/// <param name="offset">Where in <c>data</c> to start updating</param>
|
||||||
|
/// <param name="count">The number of bytes from <c>data</c> to use</param>
|
||||||
|
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
|
||||||
|
/// <exception cref="ArgumentNullException"><c>data</c> is a null reference</exception>
|
||||||
|
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
|
||||||
|
void Update(byte[] data, int offset, int count);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the current checksum with the data from a string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The string to update the checksum with</param>
|
||||||
|
/// <remarks>The characters in the string are converted by the UTF-8 encoding</remarks>
|
||||||
|
void Update(string data);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the current checksum with the data from a string, using a specific encoding
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">The string to update the checksum with</param>
|
||||||
|
/// <param name="encoding">The encoding to use</param>
|
||||||
|
void Update(string data, Encoding encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the method that will be called from a codec when new data
|
||||||
|
/// are available.
|
||||||
|
/// </summary>
|
||||||
|
/// <paramref name="data">The byte array containing the processed data</paramref>
|
||||||
|
/// <paramref name="startIndex">The index of the first processed byte in <c>data</c></paramref>
|
||||||
|
/// <paramref name="count">The number of processed bytes available</paramref>
|
||||||
|
/// <remarks>On return from this method, the data may be overwritten, so grab it while you can.
|
||||||
|
/// You cannot assume that startIndex will be zero.
|
||||||
|
/// </remarks>
|
||||||
|
public delegate void DataAvailableHandler(byte[] data, int startIndex, int count);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Declares methods and events for implementing compressors/decompressors
|
||||||
|
/// </summary>
|
||||||
|
public interface Codec
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Occurs when more processed data are available.
|
||||||
|
/// </summary>
|
||||||
|
event DataAvailableHandler DataAvailable;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds more data to the codec to be processed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">Byte array containing the data to be added to the codec</param>
|
||||||
|
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
|
||||||
|
void Add(byte[] data);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds more data to the codec to be processed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">Byte array containing the data to be added to the codec</param>
|
||||||
|
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
|
||||||
|
/// <param name="count">The number of bytes to add</param>
|
||||||
|
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
|
||||||
|
void Add(byte[] data, int offset, int count);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Finishes up any pending data that needs to be processed and handled.
|
||||||
|
/// </summary>
|
||||||
|
void Finish();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the checksum of the data that has been added so far
|
||||||
|
/// </summary>
|
||||||
|
uint Checksum { get; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Classes
|
||||||
|
/// <summary>
|
||||||
|
/// Encapsulates general information about the ZLib library
|
||||||
|
/// </summary>
|
||||||
|
public class Info
|
||||||
|
{
|
||||||
|
#region DLL imports
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern uint zlibCompileFlags();
|
||||||
|
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern string zlibVersion();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private stuff
|
||||||
|
private uint _flags;
|
||||||
|
|
||||||
|
// helper function that unpacks a bitsize mask
|
||||||
|
private static int bitSize(uint bits)
|
||||||
|
{
|
||||||
|
switch (bits)
|
||||||
|
{
|
||||||
|
case 0: return 16;
|
||||||
|
case 1: return 32;
|
||||||
|
case 2: return 64;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs an instance of the <c>Info</c> class.
|
||||||
|
/// </summary>
|
||||||
|
public Info()
|
||||||
|
{
|
||||||
|
_flags = zlibCompileFlags();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True if the library is compiled with debug info
|
||||||
|
/// </summary>
|
||||||
|
public bool HasDebugInfo { get { return 0 != (_flags & 0x100); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// True if the library is compiled with assembly optimizations
|
||||||
|
/// </summary>
|
||||||
|
public bool UsesAssemblyCode { get { return 0 != (_flags & 0x200); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the size of the unsigned int that was compiled into Zlib
|
||||||
|
/// </summary>
|
||||||
|
public int SizeOfUInt { get { return bitSize(_flags & 3); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the size of the unsigned long that was compiled into Zlib
|
||||||
|
/// </summary>
|
||||||
|
public int SizeOfULong { get { return bitSize((_flags >> 2) & 3); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the size of the pointers that were compiled into Zlib
|
||||||
|
/// </summary>
|
||||||
|
public int SizeOfPointer { get { return bitSize((_flags >> 4) & 3); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the size of the z_off_t type that was compiled into Zlib
|
||||||
|
/// </summary>
|
||||||
|
public int SizeOfOffset { get { return bitSize((_flags >> 6) & 3); } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the version of ZLib as a string, e.g. "1.2.1"
|
||||||
|
/// </summary>
|
||||||
|
public static string Version { get { return zlibVersion(); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
141
contrib/dotzlib/DotZLib/DotZLib.csproj
Normal file
141
contrib/dotzlib/DotZLib/DotZLib.csproj
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
<VisualStudioProject>
|
||||||
|
<CSHARP
|
||||||
|
ProjectType = "Local"
|
||||||
|
ProductVersion = "7.10.3077"
|
||||||
|
SchemaVersion = "2.0"
|
||||||
|
ProjectGuid = "{BB1EE0B1-1808-46CB-B786-949D91117FC5}"
|
||||||
|
>
|
||||||
|
<Build>
|
||||||
|
<Settings
|
||||||
|
ApplicationIcon = ""
|
||||||
|
AssemblyKeyContainerName = ""
|
||||||
|
AssemblyName = "DotZLib"
|
||||||
|
AssemblyOriginatorKeyFile = ""
|
||||||
|
DefaultClientScript = "JScript"
|
||||||
|
DefaultHTMLPageLayout = "Grid"
|
||||||
|
DefaultTargetSchema = "IE50"
|
||||||
|
DelaySign = "false"
|
||||||
|
OutputType = "Library"
|
||||||
|
PreBuildEvent = ""
|
||||||
|
PostBuildEvent = ""
|
||||||
|
RootNamespace = "DotZLib"
|
||||||
|
RunPostBuildEvent = "OnBuildSuccess"
|
||||||
|
StartupObject = ""
|
||||||
|
>
|
||||||
|
<Config
|
||||||
|
Name = "Debug"
|
||||||
|
AllowUnsafeBlocks = "false"
|
||||||
|
BaseAddress = "285212672"
|
||||||
|
CheckForOverflowUnderflow = "false"
|
||||||
|
ConfigurationOverrideFile = ""
|
||||||
|
DefineConstants = "DEBUG;TRACE"
|
||||||
|
DocumentationFile = "docs\DotZLib.xml"
|
||||||
|
DebugSymbols = "true"
|
||||||
|
FileAlignment = "4096"
|
||||||
|
IncrementalBuild = "false"
|
||||||
|
NoStdLib = "false"
|
||||||
|
NoWarn = "1591"
|
||||||
|
Optimize = "false"
|
||||||
|
OutputPath = "bin\Debug\"
|
||||||
|
RegisterForComInterop = "false"
|
||||||
|
RemoveIntegerChecks = "false"
|
||||||
|
TreatWarningsAsErrors = "false"
|
||||||
|
WarningLevel = "4"
|
||||||
|
/>
|
||||||
|
<Config
|
||||||
|
Name = "Release"
|
||||||
|
AllowUnsafeBlocks = "false"
|
||||||
|
BaseAddress = "285212672"
|
||||||
|
CheckForOverflowUnderflow = "false"
|
||||||
|
ConfigurationOverrideFile = ""
|
||||||
|
DefineConstants = "TRACE"
|
||||||
|
DocumentationFile = "docs\DotZLib.xml"
|
||||||
|
DebugSymbols = "false"
|
||||||
|
FileAlignment = "4096"
|
||||||
|
IncrementalBuild = "false"
|
||||||
|
NoStdLib = "false"
|
||||||
|
NoWarn = ""
|
||||||
|
Optimize = "true"
|
||||||
|
OutputPath = "bin\Release\"
|
||||||
|
RegisterForComInterop = "false"
|
||||||
|
RemoveIntegerChecks = "false"
|
||||||
|
TreatWarningsAsErrors = "false"
|
||||||
|
WarningLevel = "4"
|
||||||
|
/>
|
||||||
|
</Settings>
|
||||||
|
<References>
|
||||||
|
<Reference
|
||||||
|
Name = "System"
|
||||||
|
AssemblyName = "System"
|
||||||
|
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.dll"
|
||||||
|
/>
|
||||||
|
<Reference
|
||||||
|
Name = "System.Data"
|
||||||
|
AssemblyName = "System.Data"
|
||||||
|
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
|
||||||
|
/>
|
||||||
|
<Reference
|
||||||
|
Name = "System.XML"
|
||||||
|
AssemblyName = "System.Xml"
|
||||||
|
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
|
||||||
|
/>
|
||||||
|
<Reference
|
||||||
|
Name = "nunit.framework"
|
||||||
|
AssemblyName = "nunit.framework"
|
||||||
|
HintPath = "E:\apps\NUnit V2.1\\bin\nunit.framework.dll"
|
||||||
|
AssemblyFolderKey = "hklm\dn\nunit.framework"
|
||||||
|
/>
|
||||||
|
</References>
|
||||||
|
</Build>
|
||||||
|
<Files>
|
||||||
|
<Include>
|
||||||
|
<File
|
||||||
|
RelPath = "AssemblyInfo.cs"
|
||||||
|
SubType = "Code"
|
||||||
|
BuildAction = "Compile"
|
||||||
|
/>
|
||||||
|
<File
|
||||||
|
RelPath = "ChecksumImpl.cs"
|
||||||
|
SubType = "Code"
|
||||||
|
BuildAction = "Compile"
|
||||||
|
/>
|
||||||
|
<File
|
||||||
|
RelPath = "CircularBuffer.cs"
|
||||||
|
SubType = "Code"
|
||||||
|
BuildAction = "Compile"
|
||||||
|
/>
|
||||||
|
<File
|
||||||
|
RelPath = "CodecBase.cs"
|
||||||
|
SubType = "Code"
|
||||||
|
BuildAction = "Compile"
|
||||||
|
/>
|
||||||
|
<File
|
||||||
|
RelPath = "Deflater.cs"
|
||||||
|
SubType = "Code"
|
||||||
|
BuildAction = "Compile"
|
||||||
|
/>
|
||||||
|
<File
|
||||||
|
RelPath = "DotZLib.cs"
|
||||||
|
SubType = "Code"
|
||||||
|
BuildAction = "Compile"
|
||||||
|
/>
|
||||||
|
<File
|
||||||
|
RelPath = "GZipStream.cs"
|
||||||
|
SubType = "Code"
|
||||||
|
BuildAction = "Compile"
|
||||||
|
/>
|
||||||
|
<File
|
||||||
|
RelPath = "Inflater.cs"
|
||||||
|
SubType = "Code"
|
||||||
|
BuildAction = "Compile"
|
||||||
|
/>
|
||||||
|
<File
|
||||||
|
RelPath = "UnitTests.cs"
|
||||||
|
SubType = "Code"
|
||||||
|
BuildAction = "Compile"
|
||||||
|
/>
|
||||||
|
</Include>
|
||||||
|
</Files>
|
||||||
|
</CSHARP>
|
||||||
|
</VisualStudioProject>
|
||||||
|
|
301
contrib/dotzlib/DotZLib/GZipStream.cs
Normal file
301
contrib/dotzlib/DotZLib/GZipStream.cs
Normal file
@ -0,0 +1,301 @@
|
|||||||
|
//
|
||||||
|
// © Copyright Henrik Ravn 2004
|
||||||
|
//
|
||||||
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace DotZLib
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Implements a compressed <see cref="Stream"/>, in GZip (.gz) format.
|
||||||
|
/// </summary>
|
||||||
|
public class GZipStream : Stream, IDisposable
|
||||||
|
{
|
||||||
|
#region Dll Imports
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
|
||||||
|
private static extern IntPtr gzopen(string name, string mode);
|
||||||
|
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern int gzclose(IntPtr gzFile);
|
||||||
|
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern int gzwrite(IntPtr gzFile, int data, int length);
|
||||||
|
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern int gzread(IntPtr gzFile, int data, int length);
|
||||||
|
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern int gzgetc(IntPtr gzFile);
|
||||||
|
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern int gzputc(IntPtr gzFile, int c);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private data
|
||||||
|
private IntPtr _gzFile;
|
||||||
|
private bool _isDisposed = false;
|
||||||
|
private bool _isWriting;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new file as a writeable GZipStream
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">The name of the compressed file to create</param>
|
||||||
|
/// <param name="level">The compression level to use when adding data</param>
|
||||||
|
/// <exception cref="ZLibException">If an error occurred in the internal zlib function</exception>
|
||||||
|
public GZipStream(string fileName, CompressLevel level)
|
||||||
|
{
|
||||||
|
_isWriting = true;
|
||||||
|
_gzFile = gzopen(fileName, String.Format("wb{0}", (int)level));
|
||||||
|
if (_gzFile == IntPtr.Zero)
|
||||||
|
throw new ZLibException(-1, "Could not open " + fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Opens an existing file as a readable GZipStream
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">The name of the file to open</param>
|
||||||
|
/// <exception cref="ZLibException">If an error occurred in the internal zlib function</exception>
|
||||||
|
public GZipStream(string fileName)
|
||||||
|
{
|
||||||
|
_isWriting = false;
|
||||||
|
_gzFile = gzopen(fileName, "rb");
|
||||||
|
if (_gzFile == IntPtr.Zero)
|
||||||
|
throw new ZLibException(-1, "Could not open " + fileName);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Access properties
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true of this stream can be read from, false otherwise
|
||||||
|
/// </summary>
|
||||||
|
public override bool CanRead
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return !_isWriting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns false.
|
||||||
|
/// </summary>
|
||||||
|
public override bool CanSeek
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if this tsream is writeable, false otherwise
|
||||||
|
/// </summary>
|
||||||
|
public override bool CanWrite
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _isWriting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Destructor & IDispose stuff
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Destroys this instance
|
||||||
|
/// </summary>
|
||||||
|
~GZipStream()
|
||||||
|
{
|
||||||
|
cleanUp(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the external file handle
|
||||||
|
/// </summary>
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
cleanUp(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Does the actual closing of the file handle.
|
||||||
|
private void cleanUp(bool isDisposing)
|
||||||
|
{
|
||||||
|
if (!_isDisposed)
|
||||||
|
{
|
||||||
|
gzclose(_gzFile);
|
||||||
|
_isDisposed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Basic reading and writing
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to read a number of bytes from the stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="buffer">The destination data buffer</param>
|
||||||
|
/// <param name="offset">The index of the first destination byte in <c>buffer</c></param>
|
||||||
|
/// <param name="count">The number of bytes requested</param>
|
||||||
|
/// <returns>The number of bytes read</returns>
|
||||||
|
/// <exception cref="ArgumentNullException">If <c>buffer</c> is null</exception>
|
||||||
|
/// <exception cref="ArgumentOutOfRangeException">If <c>count</c> or <c>offset</c> are negative</exception>
|
||||||
|
/// <exception cref="ArgumentException">If <c>offset</c> + <c>count</c> is > buffer.Length</exception>
|
||||||
|
/// <exception cref="NotSupportedException">If this stream is not readable.</exception>
|
||||||
|
/// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception>
|
||||||
|
public override int Read(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
if (!CanRead) throw new NotSupportedException();
|
||||||
|
if (buffer == null) throw new ArgumentNullException();
|
||||||
|
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
|
||||||
|
if ((offset+count) > buffer.Length) throw new ArgumentException();
|
||||||
|
if (_isDisposed) throw new ObjectDisposedException("GZipStream");
|
||||||
|
|
||||||
|
GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
||||||
|
int result;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = gzread(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count);
|
||||||
|
if (result < 0)
|
||||||
|
throw new IOException();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
h.Free();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to read a single byte from the stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The byte that was read, or -1 in case of error or End-Of-File</returns>
|
||||||
|
public override int ReadByte()
|
||||||
|
{
|
||||||
|
if (!CanRead) throw new NotSupportedException();
|
||||||
|
if (_isDisposed) throw new ObjectDisposedException("GZipStream");
|
||||||
|
return gzgetc(_gzFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes a number of bytes to the stream
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="buffer"></param>
|
||||||
|
/// <param name="offset"></param>
|
||||||
|
/// <param name="count"></param>
|
||||||
|
/// <exception cref="ArgumentNullException">If <c>buffer</c> is null</exception>
|
||||||
|
/// <exception cref="ArgumentOutOfRangeException">If <c>count</c> or <c>offset</c> are negative</exception>
|
||||||
|
/// <exception cref="ArgumentException">If <c>offset</c> + <c>count</c> is > buffer.Length</exception>
|
||||||
|
/// <exception cref="NotSupportedException">If this stream is not writeable.</exception>
|
||||||
|
/// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception>
|
||||||
|
public override void Write(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
if (!CanWrite) throw new NotSupportedException();
|
||||||
|
if (buffer == null) throw new ArgumentNullException();
|
||||||
|
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
|
||||||
|
if ((offset+count) > buffer.Length) throw new ArgumentException();
|
||||||
|
if (_isDisposed) throw new ObjectDisposedException("GZipStream");
|
||||||
|
|
||||||
|
GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int result = gzwrite(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count);
|
||||||
|
if (result < 0)
|
||||||
|
throw new IOException();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
h.Free();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes a single byte to the stream
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The byte to add to the stream.</param>
|
||||||
|
/// <exception cref="NotSupportedException">If this stream is not writeable.</exception>
|
||||||
|
/// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception>
|
||||||
|
public override void WriteByte(byte value)
|
||||||
|
{
|
||||||
|
if (!CanWrite) throw new NotSupportedException();
|
||||||
|
if (_isDisposed) throw new ObjectDisposedException("GZipStream");
|
||||||
|
|
||||||
|
int result = gzputc(_gzFile, (int)value);
|
||||||
|
if (result < 0)
|
||||||
|
throw new IOException();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Position & length stuff
|
||||||
|
/// <summary>
|
||||||
|
/// Not supported.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <exception cref="NotSupportedException">Always thrown</exception>
|
||||||
|
public override void SetLength(long value)
|
||||||
|
{
|
||||||
|
throw new NotSupportedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Not suppported.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="offset"></param>
|
||||||
|
/// <param name="origin"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <exception cref="NotSupportedException">Always thrown</exception>
|
||||||
|
public override long Seek(long offset, SeekOrigin origin)
|
||||||
|
{
|
||||||
|
throw new NotSupportedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Flushes the <c>GZipStream</c>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>In this implementation, this method does nothing. This is because excessive
|
||||||
|
/// flushing may degrade the achievable compression rates.</remarks>
|
||||||
|
public override void Flush()
|
||||||
|
{
|
||||||
|
// left empty on purpose
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets/sets the current position in the <c>GZipStream</c>. Not suppported.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>In this implementation this property is not supported</remarks>
|
||||||
|
/// <exception cref="NotSupportedException">Always thrown</exception>
|
||||||
|
public override long Position
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
throw new NotSupportedException();
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
throw new NotSupportedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the size of the stream. Not suppported.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>In this implementation this property is not supported</remarks>
|
||||||
|
/// <exception cref="NotSupportedException">Always thrown</exception>
|
||||||
|
public override long Length
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
throw new NotSupportedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
105
contrib/dotzlib/DotZLib/Inflater.cs
Normal file
105
contrib/dotzlib/DotZLib/Inflater.cs
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
//
|
||||||
|
// © Copyright Henrik Ravn 2004
|
||||||
|
//
|
||||||
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace DotZLib
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Implements a data decompressor, using the inflate algorithm in the ZLib dll
|
||||||
|
/// </summary>
|
||||||
|
public class Inflater : CodecBase
|
||||||
|
{
|
||||||
|
#region Dll imports
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
|
||||||
|
private static extern int inflateInit_(ref ZStream sz, string vs, int size);
|
||||||
|
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern int inflate(ref ZStream sz, int flush);
|
||||||
|
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern int inflateReset(ref ZStream sz);
|
||||||
|
|
||||||
|
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
|
||||||
|
private static extern int inflateEnd(ref ZStream sz);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs an new instance of the <c>Inflater</c>
|
||||||
|
/// </summary>
|
||||||
|
public Inflater() : base()
|
||||||
|
{
|
||||||
|
int retval = inflateInit_(ref _ztream, Info.Version, Marshal.SizeOf(_ztream));
|
||||||
|
if (retval != 0)
|
||||||
|
throw new ZLibException(retval, "Could not initialize inflater");
|
||||||
|
|
||||||
|
resetOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds more data to the codec to be processed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">Byte array containing the data to be added to the codec</param>
|
||||||
|
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
|
||||||
|
/// <param name="count">The number of bytes to add</param>
|
||||||
|
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
|
||||||
|
public override void Add(byte[] data, int offset, int count)
|
||||||
|
{
|
||||||
|
if (data == null) throw new ArgumentNullException();
|
||||||
|
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
|
||||||
|
if ((offset+count) > data.Length) throw new ArgumentException();
|
||||||
|
|
||||||
|
int total = count;
|
||||||
|
int inputIndex = offset;
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
while (err >= 0 && inputIndex < total)
|
||||||
|
{
|
||||||
|
copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize));
|
||||||
|
err = inflate(ref _ztream, (int)FlushTypes.None);
|
||||||
|
if (err == 0)
|
||||||
|
while (_ztream.avail_out == 0)
|
||||||
|
{
|
||||||
|
OnDataAvailable();
|
||||||
|
err = inflate(ref _ztream, (int)FlushTypes.None);
|
||||||
|
}
|
||||||
|
|
||||||
|
inputIndex += (int)_ztream.total_in;
|
||||||
|
}
|
||||||
|
setChecksum( _ztream.adler );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Finishes up any pending data that needs to be processed and handled.
|
||||||
|
/// </summary>
|
||||||
|
public override void Finish()
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
err = inflate(ref _ztream, (int)FlushTypes.Finish);
|
||||||
|
OnDataAvailable();
|
||||||
|
}
|
||||||
|
while (err == 0);
|
||||||
|
setChecksum( _ztream.adler );
|
||||||
|
inflateReset(ref _ztream);
|
||||||
|
resetOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Closes the internal zlib inflate stream
|
||||||
|
/// </summary>
|
||||||
|
protected override void CleanUp() { inflateEnd(ref _ztream); }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
274
contrib/dotzlib/DotZLib/UnitTests.cs
Normal file
274
contrib/dotzlib/DotZLib/UnitTests.cs
Normal file
@ -0,0 +1,274 @@
|
|||||||
|
//
|
||||||
|
// © Copyright Henrik Ravn 2004
|
||||||
|
//
|
||||||
|
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
// uncomment the define below to include unit tests
|
||||||
|
//#define nunit
|
||||||
|
#if nunit
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
// Unit tests for the DotZLib class library
|
||||||
|
// ----------------------------------------
|
||||||
|
//
|
||||||
|
// Use this with NUnit 2 from http://www.nunit.org
|
||||||
|
//
|
||||||
|
|
||||||
|
namespace DotZLibTests
|
||||||
|
{
|
||||||
|
using DotZLib;
|
||||||
|
|
||||||
|
// helper methods
|
||||||
|
internal class Utils
|
||||||
|
{
|
||||||
|
public static bool byteArrEqual( byte[] lhs, byte[] rhs )
|
||||||
|
{
|
||||||
|
if (lhs.Length != rhs.Length)
|
||||||
|
return false;
|
||||||
|
for (int i = lhs.Length-1; i >= 0; --i)
|
||||||
|
if (lhs[i] != rhs[i])
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class CircBufferTests
|
||||||
|
{
|
||||||
|
#region Circular buffer tests
|
||||||
|
[Test]
|
||||||
|
public void SinglePutGet()
|
||||||
|
{
|
||||||
|
CircularBuffer buf = new CircularBuffer(10);
|
||||||
|
Assert.AreEqual( 0, buf.Size );
|
||||||
|
Assert.AreEqual( -1, buf.Get() );
|
||||||
|
|
||||||
|
Assert.IsTrue(buf.Put( 1 ));
|
||||||
|
Assert.AreEqual( 1, buf.Size );
|
||||||
|
Assert.AreEqual( 1, buf.Get() );
|
||||||
|
Assert.AreEqual( 0, buf.Size );
|
||||||
|
Assert.AreEqual( -1, buf.Get() );
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void BlockPutGet()
|
||||||
|
{
|
||||||
|
CircularBuffer buf = new CircularBuffer(10);
|
||||||
|
byte[] arr = {1,2,3,4,5,6,7,8,9,10};
|
||||||
|
Assert.AreEqual( 10, buf.Put(arr,0,10) );
|
||||||
|
Assert.AreEqual( 10, buf.Size );
|
||||||
|
Assert.IsFalse( buf.Put(11) );
|
||||||
|
Assert.AreEqual( 1, buf.Get() );
|
||||||
|
Assert.IsTrue( buf.Put(11) );
|
||||||
|
|
||||||
|
byte[] arr2 = (byte[])arr.Clone();
|
||||||
|
Assert.AreEqual( 9, buf.Get(arr2,1,9) );
|
||||||
|
Assert.IsTrue( Utils.byteArrEqual(arr,arr2) );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class ChecksumTests
|
||||||
|
{
|
||||||
|
#region CRC32 Tests
|
||||||
|
[Test]
|
||||||
|
public void CRC32_Null()
|
||||||
|
{
|
||||||
|
CRC32Checksum crc32 = new CRC32Checksum();
|
||||||
|
Assert.AreEqual( 0, crc32.Value );
|
||||||
|
|
||||||
|
crc32 = new CRC32Checksum(1);
|
||||||
|
Assert.AreEqual( 1, crc32.Value );
|
||||||
|
|
||||||
|
crc32 = new CRC32Checksum(556);
|
||||||
|
Assert.AreEqual( 556, crc32.Value );
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CRC32_Data()
|
||||||
|
{
|
||||||
|
CRC32Checksum crc32 = new CRC32Checksum();
|
||||||
|
byte[] data = { 1,2,3,4,5,6,7 };
|
||||||
|
crc32.Update(data);
|
||||||
|
Assert.AreEqual( 0x70e46888, crc32.Value );
|
||||||
|
|
||||||
|
crc32 = new CRC32Checksum();
|
||||||
|
crc32.Update("penguin");
|
||||||
|
Assert.AreEqual( 0x0e5c1a120, crc32.Value );
|
||||||
|
|
||||||
|
crc32 = new CRC32Checksum(1);
|
||||||
|
crc32.Update("penguin");
|
||||||
|
Assert.AreEqual(0x43b6aa94, crc32.Value);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Adler tests
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Adler_Null()
|
||||||
|
{
|
||||||
|
AdlerChecksum adler = new AdlerChecksum();
|
||||||
|
Assert.AreEqual(0, adler.Value);
|
||||||
|
|
||||||
|
adler = new AdlerChecksum(1);
|
||||||
|
Assert.AreEqual( 1, adler.Value );
|
||||||
|
|
||||||
|
adler = new AdlerChecksum(556);
|
||||||
|
Assert.AreEqual( 556, adler.Value );
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Adler_Data()
|
||||||
|
{
|
||||||
|
AdlerChecksum adler = new AdlerChecksum(1);
|
||||||
|
byte[] data = { 1,2,3,4,5,6,7 };
|
||||||
|
adler.Update(data);
|
||||||
|
Assert.AreEqual( 0x5b001d, adler.Value );
|
||||||
|
|
||||||
|
adler = new AdlerChecksum();
|
||||||
|
adler.Update("penguin");
|
||||||
|
Assert.AreEqual(0x0bcf02f6, adler.Value );
|
||||||
|
|
||||||
|
adler = new AdlerChecksum(1);
|
||||||
|
adler.Update("penguin");
|
||||||
|
Assert.AreEqual(0x0bd602f7, adler.Value);
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class InfoTests
|
||||||
|
{
|
||||||
|
#region Info tests
|
||||||
|
[Test]
|
||||||
|
public void Info_Version()
|
||||||
|
{
|
||||||
|
Info info = new Info();
|
||||||
|
Assert.AreEqual("1.2.2", Info.Version);
|
||||||
|
Assert.AreEqual(32, info.SizeOfUInt);
|
||||||
|
Assert.AreEqual(32, info.SizeOfULong);
|
||||||
|
Assert.AreEqual(32, info.SizeOfPointer);
|
||||||
|
Assert.AreEqual(32, info.SizeOfOffset);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class DeflateInflateTests
|
||||||
|
{
|
||||||
|
#region Deflate tests
|
||||||
|
[Test]
|
||||||
|
public void Deflate_Init()
|
||||||
|
{
|
||||||
|
using (Deflater def = new Deflater(CompressLevel.Default))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArrayList compressedData = new ArrayList();
|
||||||
|
private uint adler1;
|
||||||
|
|
||||||
|
private ArrayList uncompressedData = new ArrayList();
|
||||||
|
private uint adler2;
|
||||||
|
|
||||||
|
public void CDataAvail(byte[] data, int startIndex, int count)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; ++i)
|
||||||
|
compressedData.Add(data[i+startIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Deflate_Compress()
|
||||||
|
{
|
||||||
|
compressedData.Clear();
|
||||||
|
|
||||||
|
byte[] testData = new byte[35000];
|
||||||
|
for (int i = 0; i < testData.Length; ++i)
|
||||||
|
testData[i] = 5;
|
||||||
|
|
||||||
|
using (Deflater def = new Deflater((CompressLevel)5))
|
||||||
|
{
|
||||||
|
def.DataAvailable += new DataAvailableHandler(CDataAvail);
|
||||||
|
def.Add(testData);
|
||||||
|
def.Finish();
|
||||||
|
adler1 = def.Checksum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Inflate tests
|
||||||
|
[Test]
|
||||||
|
public void Inflate_Init()
|
||||||
|
{
|
||||||
|
using (Inflater inf = new Inflater())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DDataAvail(byte[] data, int startIndex, int count)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; ++i)
|
||||||
|
uncompressedData.Add(data[i+startIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Inflate_Expand()
|
||||||
|
{
|
||||||
|
uncompressedData.Clear();
|
||||||
|
|
||||||
|
using (Inflater inf = new Inflater())
|
||||||
|
{
|
||||||
|
inf.DataAvailable += new DataAvailableHandler(DDataAvail);
|
||||||
|
inf.Add((byte[])compressedData.ToArray(typeof(byte)));
|
||||||
|
inf.Finish();
|
||||||
|
adler2 = inf.Checksum;
|
||||||
|
}
|
||||||
|
Assert.AreEqual( adler1, adler2 );
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class GZipStreamTests
|
||||||
|
{
|
||||||
|
#region GZipStream test
|
||||||
|
[Test]
|
||||||
|
public void GZipStream_WriteRead()
|
||||||
|
{
|
||||||
|
using (GZipStream gzOut = new GZipStream("gzstream.gz", CompressLevel.Best))
|
||||||
|
{
|
||||||
|
BinaryWriter writer = new BinaryWriter(gzOut);
|
||||||
|
writer.Write("hi there");
|
||||||
|
writer.Write(Math.PI);
|
||||||
|
writer.Write(42);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (GZipStream gzIn = new GZipStream("gzstream.gz"))
|
||||||
|
{
|
||||||
|
BinaryReader reader = new BinaryReader(gzIn);
|
||||||
|
string s = reader.ReadString();
|
||||||
|
Assert.AreEqual("hi there",s);
|
||||||
|
double d = reader.ReadDouble();
|
||||||
|
Assert.AreEqual(Math.PI, d);
|
||||||
|
int i = reader.ReadInt32();
|
||||||
|
Assert.AreEqual(42,i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
23
contrib/dotzlib/LICENSE_1_0.txt
Normal file
23
contrib/dotzlib/LICENSE_1_0.txt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
Boost Software License - Version 1.0 - August 17th, 2003
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
do so, all subject to the following:
|
||||||
|
|
||||||
|
The copyright notices in the Software and this entire statement, including
|
||||||
|
the above license grant, this restriction and the following disclaimer,
|
||||||
|
must be included in all copies of the Software, in whole or in part, and
|
||||||
|
all derivative works of the Software, unless such copies or derivative
|
||||||
|
works are solely in the form of machine-executable object code generated by
|
||||||
|
a source language processor.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
58
contrib/dotzlib/readme.txt
Normal file
58
contrib/dotzlib/readme.txt
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
This directory contains a .Net wrapper class library for the ZLib1.dll
|
||||||
|
|
||||||
|
The wrapper includes support for inflating/deflating memory buffers,
|
||||||
|
.Net streaming wrappers for the gz streams part of zlib, and wrappers
|
||||||
|
for the checksum parts of zlib. See DotZLib/UnitTests.cs for examples.
|
||||||
|
|
||||||
|
Directory structure:
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
LICENSE_1_0.txt - License file.
|
||||||
|
readme.txt - This file.
|
||||||
|
DotZLib.chm - Class library documentation
|
||||||
|
DotZLib.build - NAnt build file
|
||||||
|
DotZLib.sln - Microsoft Visual Studio 2003 solution file
|
||||||
|
|
||||||
|
DotZLib\*.cs - Source files for the class library
|
||||||
|
|
||||||
|
Unit tests:
|
||||||
|
-----------
|
||||||
|
The file DotZLib/UnitTests.cs contains unit tests for use with NUnit 2.1 or higher.
|
||||||
|
To include unit tests in the build, define nunit before building.
|
||||||
|
|
||||||
|
|
||||||
|
Build instructions:
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
1. Using Visual Studio.Net 2003:
|
||||||
|
Open DotZLib.sln in VS.Net and build from there. Output file (DotZLib.dll)
|
||||||
|
will be found ./DotZLib/bin/release or ./DotZLib/bin/debug, depending on
|
||||||
|
you are building the release or debug version of the library. Check
|
||||||
|
DotZLib/UnitTests.cs for instructions on how to include unit tests in the
|
||||||
|
build.
|
||||||
|
|
||||||
|
2. Using NAnt:
|
||||||
|
Open a command prompt with access to the build environment and run nant
|
||||||
|
in the same directory as the DotZLib.build file.
|
||||||
|
You can define 2 properties on the nant command-line to control the build:
|
||||||
|
debug={true|false} to toggle between release/debug builds (default=true).
|
||||||
|
nunit={true|false} to include or esclude unit tests (default=true).
|
||||||
|
Also the target clean will remove binaries.
|
||||||
|
Output file (DotZLib.dll) will be found in either ./DotZLib/bin/release
|
||||||
|
or ./DotZLib/bin/debug, depending on whether you are building the release
|
||||||
|
or debug version of the library.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
nant -D:debug=false -D:nunit=false
|
||||||
|
will build a release mode version of the library without unit tests.
|
||||||
|
nant
|
||||||
|
will build a debug version of the library with unit tests
|
||||||
|
nant clean
|
||||||
|
will remove all previously built files.
|
||||||
|
|
||||||
|
|
||||||
|
---------------------------------
|
||||||
|
Copyright (c) Henrik Ravn 2004
|
||||||
|
|
||||||
|
Use, modification and distribution are subject to the Boost Software License, Version 1.0.
|
||||||
|
(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
@ -48,10 +48,10 @@
|
|||||||
unfriendly behavior that if gzappend fails, the gzip file is corrupted.
|
unfriendly behavior that if gzappend fails, the gzip file is corrupted.
|
||||||
|
|
||||||
This program was written to illustrate the use of the new Z_BLOCK option of
|
This program was written to illustrate the use of the new Z_BLOCK option of
|
||||||
zlib 1.2.1's inflate() function. This option returns from inflate() at each
|
zlib 1.2.x's inflate() function. This option returns from inflate() at each
|
||||||
block boundary to facilitate locating and modifying the last block bit at
|
block boundary to facilitate locating and modifying the last block bit at
|
||||||
the start of the final deflate block. Also whether using Z_BLOCK or not,
|
the start of the final deflate block. Also whether using Z_BLOCK or not,
|
||||||
another required feature of zlib 1.2.1 is that inflate() now provides the
|
another required feature of zlib 1.2.x is that inflate() now provides the
|
||||||
number of unusued bits in the last input byte used. gzappend will not work
|
number of unusued bits in the last input byte used. gzappend will not work
|
||||||
with versions of zlib earlier than 1.2.1.
|
with versions of zlib earlier than 1.2.1.
|
||||||
|
|
||||||
|
@ -430,8 +430,8 @@ void FAR *out_desc;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handle error breaks in while */
|
/* handle error breaks in while */
|
||||||
if (mode == BAD) break;
|
if (mode == BAD) break;
|
||||||
|
|
||||||
/* build code tables */
|
/* build code tables */
|
||||||
state->next = state->codes;
|
state->next = state->codes;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#define MAXBITS 15
|
#define MAXBITS 15
|
||||||
|
|
||||||
const char inflate9_copyright[] =
|
const char inflate9_copyright[] =
|
||||||
" inflate9 1.2.1.2 Copyright 1995-2004 Mark Adler ";
|
" inflate9 1.2.2 Copyright 1995-2004 Mark Adler ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
If you use the zlib library in a product, an acknowledgment is welcome
|
||||||
in the documentation of your product. If for some reason you cannot
|
in the documentation of your product. If for some reason you cannot
|
||||||
@ -64,7 +64,7 @@ unsigned short FAR *work;
|
|||||||
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
||||||
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
|
128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129,
|
||||||
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
|
130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132,
|
||||||
133, 133, 133, 133, 144, 77, 194};
|
133, 133, 133, 133, 144, 199, 198};
|
||||||
static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
|
static const unsigned short dbase[32] = { /* Distance codes 0..31 base */
|
||||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
|
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49,
|
||||||
65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
|
65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073,
|
||||||
|
@ -94,7 +94,7 @@ uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
|
|||||||
uLong size;
|
uLong size;
|
||||||
{
|
{
|
||||||
uLong ret;
|
uLong ret;
|
||||||
ret = fread(buf, 1, (size_t)size, (FILE *)stream);
|
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
|
|||||||
uLong size;
|
uLong size;
|
||||||
{
|
{
|
||||||
uLong ret;
|
uLong ret;
|
||||||
ret = fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
|
|||||||
|
|
||||||
printf("The file %s exists. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename);
|
printf("The file %s exists. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename);
|
||||||
ret = scanf("%1s",answer);
|
ret = scanf("%1s",answer);
|
||||||
if (ret != 1)
|
if (ret != 1)
|
||||||
{
|
{
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
@ -567,7 +567,7 @@ int main(argc,argv)
|
|||||||
return do_list(uf);
|
return do_list(uf);
|
||||||
else if (opt_do_extract==1)
|
else if (opt_do_extract==1)
|
||||||
{
|
{
|
||||||
if (opt_extractdir && chdir(dirname))
|
if (opt_extractdir && chdir(dirname))
|
||||||
{
|
{
|
||||||
printf("Error changing into %s, aborting\n", dirname);
|
printf("Error changing into %s, aborting\n", dirname);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
@ -62,7 +62,7 @@ uLong* bytesRecovered;
|
|||||||
unsigned int fnsize = READ_16(header + 26); /* file name length */
|
unsigned int fnsize = READ_16(header + 26); /* file name length */
|
||||||
unsigned int extsize = READ_16(header + 28); /* extra field length */
|
unsigned int extsize = READ_16(header + 28); /* extra field length */
|
||||||
filename[0] = extra[0] = '\0';
|
filename[0] = extra[0] = '\0';
|
||||||
|
|
||||||
/* Header */
|
/* Header */
|
||||||
if (fwrite(header, 1, 30, fpOut) == 30) {
|
if (fwrite(header, 1, 30, fpOut) == 30) {
|
||||||
offset += 30;
|
offset += 30;
|
||||||
@ -70,7 +70,7 @@ uLong* bytesRecovered;
|
|||||||
err = Z_ERRNO;
|
err = Z_ERRNO;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Filename */
|
/* Filename */
|
||||||
if (fnsize > 0) {
|
if (fnsize > 0) {
|
||||||
if (fread(filename, 1, fnsize, fpZip) == fnsize) {
|
if (fread(filename, 1, fnsize, fpZip) == fnsize) {
|
||||||
@ -103,7 +103,7 @@ uLong* bytesRecovered;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Data */
|
/* Data */
|
||||||
{
|
{
|
||||||
int dataSize = cpsize;
|
int dataSize = cpsize;
|
||||||
@ -133,7 +133,7 @@ uLong* bytesRecovered;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Central directory entry */
|
/* Central directory entry */
|
||||||
{
|
{
|
||||||
char header[46];
|
char header[46];
|
||||||
@ -159,7 +159,7 @@ uLong* bytesRecovered;
|
|||||||
/* Header */
|
/* Header */
|
||||||
if (fwrite(header, 1, 46, fpOutCD) == 46) {
|
if (fwrite(header, 1, 46, fpOutCD) == 46) {
|
||||||
offsetCD += 46;
|
offsetCD += 46;
|
||||||
|
|
||||||
/* Filename */
|
/* Filename */
|
||||||
if (fnsize > 0) {
|
if (fnsize > 0) {
|
||||||
if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) {
|
if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) {
|
||||||
@ -172,7 +172,7 @@ uLong* bytesRecovered;
|
|||||||
err = Z_STREAM_ERROR;
|
err = Z_STREAM_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extra field */
|
/* Extra field */
|
||||||
if (extsize > 0) {
|
if (extsize > 0) {
|
||||||
if (fwrite(extra, 1, extsize, fpOutCD) == extsize) {
|
if (fwrite(extra, 1, extsize, fpOutCD) == extsize) {
|
||||||
@ -182,7 +182,7 @@ uLong* bytesRecovered;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Comment field */
|
/* Comment field */
|
||||||
if (comsize > 0) {
|
if (comsize > 0) {
|
||||||
if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) {
|
if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) {
|
||||||
@ -192,8 +192,8 @@ uLong* bytesRecovered;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
err = Z_ERRNO;
|
err = Z_ERRNO;
|
||||||
break;
|
break;
|
||||||
@ -225,17 +225,17 @@ uLong* bytesRecovered;
|
|||||||
WRITE_32(header + 12, offsetCD); /* size of CD */
|
WRITE_32(header + 12, offsetCD); /* size of CD */
|
||||||
WRITE_32(header + 16, offset); /* offset to CD */
|
WRITE_32(header + 16, offset); /* offset to CD */
|
||||||
WRITE_16(header + 20, comsize); /* comment */
|
WRITE_16(header + 20, comsize); /* comment */
|
||||||
|
|
||||||
/* Header */
|
/* Header */
|
||||||
if (fwrite(header, 1, 22, fpOutCD) == 22) {
|
if (fwrite(header, 1, 22, fpOutCD) == 22) {
|
||||||
|
|
||||||
/* Comment field */
|
/* Comment field */
|
||||||
if (comsize > 0) {
|
if (comsize > 0) {
|
||||||
if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) {
|
if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) {
|
||||||
err = Z_ERRNO;
|
err = Z_ERRNO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
err = Z_ERRNO;
|
err = Z_ERRNO;
|
||||||
}
|
}
|
||||||
@ -257,14 +257,14 @@ uLong* bytesRecovered;
|
|||||||
fclose(fpOutCD);
|
fclose(fpOutCD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close */
|
/* Close */
|
||||||
fclose(fpZip);
|
fclose(fpZip);
|
||||||
fclose(fpOut);
|
fclose(fpOut);
|
||||||
|
|
||||||
/* Wipe temporary file */
|
/* Wipe temporary file */
|
||||||
(void)remove(fileOutTmp);
|
(void)remove(fileOutTmp);
|
||||||
|
|
||||||
/* Number of recovered entries */
|
/* Number of recovered entries */
|
||||||
if (err == Z_OK) {
|
if (err == Z_OK) {
|
||||||
if (nRecovered != NULL) {
|
if (nRecovered != NULL) {
|
||||||
|
@ -17,14 +17,14 @@ extern "C" {
|
|||||||
|
|
||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
|
|
||||||
/* Repair a ZIP file (missing central directory)
|
/* Repair a ZIP file (missing central directory)
|
||||||
file: file to recover
|
file: file to recover
|
||||||
fileOut: output file after recovery
|
fileOut: output file after recovery
|
||||||
fileOutTmp: temporary file name used for recovery
|
fileOutTmp: temporary file name used for recovery
|
||||||
*/
|
*/
|
||||||
extern int ZEXPORT unzRepair(const char* file,
|
extern int ZEXPORT unzRepair(const char* file,
|
||||||
const char* fileOut,
|
const char* fileOut,
|
||||||
const char* fileOutTmp,
|
const char* fileOutTmp,
|
||||||
uLong* nRecovered,
|
uLong* nRecovered,
|
||||||
uLong* bytesRecovered);
|
uLong* bytesRecovered);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* unzip.c -- IO for uncompress .zip files using zlib
|
/* unzip.c -- IO for uncompress .zip files using zlib
|
||||||
Version 1.01c, August 23th, 2004
|
Version 1.01d, September 22th, 2004
|
||||||
|
|
||||||
Copyright (C) 1998-2004 Gilles Vollant
|
Copyright (C) 1998-2004 Gilles Vollant
|
||||||
|
|
||||||
@ -1250,10 +1250,12 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
|
|||||||
pfile_in_zip_read_info->stream.avail_out =
|
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) &&
|
if ((len>pfile_in_zip_read_info->rest_read_compressed+
|
||||||
(pfile_in_zip_read_info->raw))
|
pfile_in_zip_read_info->stream.avail_in) &&
|
||||||
|
(pfile_in_zip_read_info->raw))
|
||||||
pfile_in_zip_read_info->stream.avail_out =
|
pfile_in_zip_read_info->stream.avail_out =
|
||||||
(uInt)pfile_in_zip_read_info->rest_read_compressed;
|
(uInt)pfile_in_zip_read_info->rest_read_compressed+
|
||||||
|
pfile_in_zip_read_info->stream.avail_in;
|
||||||
|
|
||||||
while (pfile_in_zip_read_info->stream.avail_out>0)
|
while (pfile_in_zip_read_info->stream.avail_out>0)
|
||||||
{
|
{
|
||||||
|
@ -717,9 +717,9 @@ extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi,
|
|||||||
if (comment==NULL)
|
if (comment==NULL)
|
||||||
size_comment = 0;
|
size_comment = 0;
|
||||||
else
|
else
|
||||||
size_comment = strlen(comment);
|
size_comment = (uInt)strlen(comment);
|
||||||
|
|
||||||
size_filename = strlen(filename);
|
size_filename = (uInt)strlen(filename);
|
||||||
|
|
||||||
if (zipfi == NULL)
|
if (zipfi == NULL)
|
||||||
zi->ci.dosDate = 0;
|
zi->ci.dosDate = 0;
|
||||||
@ -1126,7 +1126,7 @@ extern int ZEXPORT zipClose (file, global_comment)
|
|||||||
if (global_comment==NULL)
|
if (global_comment==NULL)
|
||||||
size_global_comment = 0;
|
size_global_comment = 0;
|
||||||
else
|
else
|
||||||
size_global_comment = strlen(global_comment);
|
size_global_comment = (uInt)strlen(global_comment);
|
||||||
|
|
||||||
|
|
||||||
centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream);
|
centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream);
|
||||||
|
@ -97,7 +97,7 @@ struct attr_item
|
|||||||
struct attr_item *next;
|
struct attr_item *next;
|
||||||
char *fname;
|
char *fname;
|
||||||
int mode;
|
int mode;
|
||||||
time_t time;
|
time_t time;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID };
|
enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID };
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
#define IDR_VERSION1 1
|
#define IDR_VERSION1 1
|
||||||
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
||||||
FILEVERSION 1,2,1,2
|
FILEVERSION 1,2,2
|
||||||
PRODUCTVERSION 1,2,1,2
|
PRODUCTVERSION 1,2,2
|
||||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||||
FILEFLAGS 0
|
FILEFLAGS 0
|
||||||
FILEOS VOS_DOS_WINDOWS32
|
FILEOS VOS_DOS_WINDOWS32
|
||||||
@ -17,7 +17,7 @@ BEGIN
|
|||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "FileDescription", "zlib data compression library\0"
|
VALUE "FileDescription", "zlib data compression library\0"
|
||||||
VALUE "FileVersion", "1.2.1.2\0"
|
VALUE "FileVersion", "1.2.2\0"
|
||||||
VALUE "InternalName", "zlib\0"
|
VALUE "InternalName", "zlib\0"
|
||||||
VALUE "OriginalFilename", "zlib.dll\0"
|
VALUE "OriginalFilename", "zlib.dll\0"
|
||||||
VALUE "ProductName", "ZLib.DLL\0"
|
VALUE "ProductName", "ZLib.DLL\0"
|
||||||
|
88
crc32.c
88
crc32.c
@ -12,11 +12,11 @@
|
|||||||
/* @(#) $Id$ */
|
/* @(#) $Id$ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore protection
|
Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
|
||||||
on the static variables used to control the first-use generation of the crc
|
protection on the static variables used to control the first-use generation
|
||||||
tables. Therefore if you #define DYNAMIC_CRC_TABLE, you should first call
|
of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
|
||||||
get_crc_table() to initialize the tables before allowing more than on thread
|
first call get_crc_table() to initialize the tables before allowing more than
|
||||||
to use crc32().
|
one thread to use crc32().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef MAKECRCH
|
#ifdef MAKECRCH
|
||||||
@ -103,51 +103,51 @@ local void make_crc_table()
|
|||||||
{
|
{
|
||||||
unsigned long c;
|
unsigned long c;
|
||||||
int n, k;
|
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): */
|
/* terms of polynomial defining this crc (except x^32): */
|
||||||
static volatile int first = 1; /* flag to limit concurrent making */
|
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};
|
static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
|
||||||
|
|
||||||
/* See if another task is already doing this (not thread-safe, but better
|
/* See if another task is already doing this (not thread-safe, but better
|
||||||
than nothing -- significantly reduces duration of vulnerability in
|
than nothing -- significantly reduces duration of vulnerability in
|
||||||
case the advice about DYNAMIC_CRC_TABLE is ignored) */
|
case the advice about DYNAMIC_CRC_TABLE is ignored) */
|
||||||
if (first) {
|
if (first) {
|
||||||
first = 0;
|
first = 0;
|
||||||
|
|
||||||
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
|
/* make exclusive-or pattern from polynomial (0xedb88320UL) */
|
||||||
poly = 0UL;
|
poly = 0UL;
|
||||||
for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
|
for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
|
||||||
poly |= 1UL << (31 - p[n]);
|
poly |= 1UL << (31 - p[n]);
|
||||||
|
|
||||||
/* generate a crc for every 8-bit value */
|
/* generate a crc for every 8-bit value */
|
||||||
for (n = 0; n < 256; n++) {
|
for (n = 0; n < 256; n++) {
|
||||||
c = (unsigned long)n;
|
c = (unsigned long)n;
|
||||||
for (k = 0; k < 8; k++)
|
for (k = 0; k < 8; k++)
|
||||||
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
|
c = c & 1 ? poly ^ (c >> 1) : c >> 1;
|
||||||
crc_table[0][n] = c;
|
crc_table[0][n] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BYFOUR
|
#ifdef BYFOUR
|
||||||
/* generate crc for each value followed by one, two, and three zeros, and
|
/* generate crc for each value followed by one, two, and three zeros,
|
||||||
then the byte reversal of those as well as the first table */
|
and then the byte reversal of those as well as the first table */
|
||||||
for (n = 0; n < 256; n++) {
|
for (n = 0; n < 256; n++) {
|
||||||
c = crc_table[0][n];
|
c = crc_table[0][n];
|
||||||
crc_table[4][n] = REV(c);
|
crc_table[4][n] = REV(c);
|
||||||
for (k = 1; k < 4; k++) {
|
for (k = 1; k < 4; k++) {
|
||||||
c = crc_table[0][c & 0xff] ^ (c >> 8);
|
c = crc_table[0][c & 0xff] ^ (c >> 8);
|
||||||
crc_table[k][n] = c;
|
crc_table[k][n] = c;
|
||||||
crc_table[k + 4][n] = REV(c);
|
crc_table[k + 4][n] = REV(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* BYFOUR */
|
#endif /* BYFOUR */
|
||||||
|
|
||||||
crc_table_empty = 0;
|
crc_table_empty = 0;
|
||||||
}
|
}
|
||||||
else { /* not first */
|
else { /* not first */
|
||||||
/* wait for the other guy to finish (not exactly efficient, but rare) */
|
/* wait for the other guy to finish (not efficient, but rare) */
|
||||||
while (crc_table_empty)
|
while (crc_table_empty)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MAKECRCH
|
#ifdef MAKECRCH
|
||||||
/* write out CRC tables to crc32.h */
|
/* write out CRC tables to crc32.h */
|
||||||
@ -201,10 +201,10 @@ local void write_table(out, table)
|
|||||||
const unsigned long FAR * ZEXPORT get_crc_table()
|
const unsigned long FAR * ZEXPORT get_crc_table()
|
||||||
{
|
{
|
||||||
#ifdef DYNAMIC_CRC_TABLE
|
#ifdef DYNAMIC_CRC_TABLE
|
||||||
if (crc_table_empty)
|
if (crc_table_empty)
|
||||||
make_crc_table();
|
make_crc_table();
|
||||||
#endif /* DYNAMIC_CRC_TABLE */
|
#endif /* DYNAMIC_CRC_TABLE */
|
||||||
return (const unsigned long FAR *)crc_table;
|
return (const unsigned long FAR *)crc_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* deflate.c -- compress data using the deflation algorithm
|
/* deflate.c -- compress data using the deflation algorithm
|
||||||
* 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
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -52,7 +52,7 @@
|
|||||||
#include "deflate.h"
|
#include "deflate.h"
|
||||||
|
|
||||||
const char deflate_copyright[] =
|
const char deflate_copyright[] =
|
||||||
" deflate 1.2.1.2 Copyright 1995-2004 Jean-loup Gailly ";
|
" deflate 1.2.2 Copyright 1995-2004 Jean-loup Gailly ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
If you use the zlib library in a product, an acknowledgment is welcome
|
||||||
in the documentation of your product. If for some reason you cannot
|
in the documentation of your product. If for some reason you cannot
|
||||||
|
8
gzio.c
8
gzio.c
@ -455,10 +455,10 @@ int ZEXPORT gzread (file, buf, len)
|
|||||||
s->z_err = Z_ERRNO;
|
s->z_err = Z_ERRNO;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (feof(s->file)) { /* avoid error for empty file */
|
if (feof(s->file)) { /* avoid error for empty file */
|
||||||
s->z_err = Z_STREAM_END;
|
s->z_err = Z_STREAM_END;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s->stream.next_in = s->inbuf;
|
s->stream.next_in = s->inbuf;
|
||||||
}
|
}
|
||||||
|
@ -434,8 +434,8 @@ void FAR *out_desc;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handle error breaks in while */
|
/* handle error breaks in while */
|
||||||
if (state->mode == BAD) break;
|
if (state->mode == BAD) break;
|
||||||
|
|
||||||
/* build code tables */
|
/* build code tables */
|
||||||
state->next = state->codes;
|
state->next = state->codes;
|
||||||
|
@ -109,6 +109,7 @@ z_streamp strm;
|
|||||||
state = (struct inflate_state FAR *)strm->state;
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
strm->total_in = strm->total_out = state->total = 0;
|
strm->total_in = strm->total_out = state->total = 0;
|
||||||
strm->msg = Z_NULL;
|
strm->msg = Z_NULL;
|
||||||
|
strm->adler = 1; /* to support ill-conceived Java test suite */
|
||||||
state->mode = HEAD;
|
state->mode = HEAD;
|
||||||
state->last = 0;
|
state->last = 0;
|
||||||
state->havedict = 0;
|
state->havedict = 0;
|
||||||
@ -861,8 +862,8 @@ int flush;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* handle error breaks in while */
|
/* handle error breaks in while */
|
||||||
if (state->mode == BAD) break;
|
if (state->mode == BAD) break;
|
||||||
|
|
||||||
/* build code tables */
|
/* build code tables */
|
||||||
state->next = state->codes;
|
state->next = state->codes;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#define MAXBITS 15
|
#define MAXBITS 15
|
||||||
|
|
||||||
const char inflate_copyright[] =
|
const char inflate_copyright[] =
|
||||||
" inflate 1.2.1.2 Copyright 1995-2004 Mark Adler ";
|
" inflate 1.2.2 Copyright 1995-2004 Mark Adler ";
|
||||||
/*
|
/*
|
||||||
If you use the zlib library in a product, an acknowledgment is welcome
|
If you use the zlib library in a product, an acknowledgment is welcome
|
||||||
in the documentation of your product. If for some reason you cannot
|
in the documentation of your product. If for some reason you cannot
|
||||||
@ -62,7 +62,7 @@ unsigned short FAR *work;
|
|||||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||||
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
||||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
||||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 194};
|
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 198};
|
||||||
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
||||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
This directory contains files that have not been updated for zlib 1.2.1
|
This directory contains files that have not been updated for zlib 1.2.x
|
||||||
|
|
||||||
(Volunteers are encouraged to help clean this up. Thanks.)
|
(Volunteers are encouraged to help clean this up. Thanks.)
|
||||||
|
@ -418,7 +418,73 @@ SOURCE=..\..\win32\zlib1.rc
|
|||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\contrib\masmx86\gvmat32.asm
|
SOURCE=..\..\contrib\masmx86\gvmat32.asm
|
||||||
|
|
||||||
|
!IF "$(CFG)" == "zlib - Win32 DLL Release"
|
||||||
|
|
||||||
# PROP Exclude_From_Build 1
|
# PROP Exclude_From_Build 1
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug"
|
||||||
|
|
||||||
|
# PROP Exclude_From_Build 1
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release"
|
||||||
|
|
||||||
|
# Begin Custom Build - Assembling...
|
||||||
|
IntDir=.\Win32_DLL_ASM_Release
|
||||||
|
InputPath=..\..\contrib\masmx86\gvmat32.asm
|
||||||
|
InputName=gvmat32
|
||||||
|
|
||||||
|
"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||||
|
ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
|
||||||
|
|
||||||
|
# End Custom Build
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug"
|
||||||
|
|
||||||
|
# Begin Custom Build - Assembling...
|
||||||
|
IntDir=.\Win32_DLL_ASM_Debug
|
||||||
|
InputPath=..\..\contrib\masmx86\gvmat32.asm
|
||||||
|
InputName=gvmat32
|
||||||
|
|
||||||
|
"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||||
|
ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
|
||||||
|
|
||||||
|
# End Custom Build
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "zlib - Win32 LIB Release"
|
||||||
|
|
||||||
|
# PROP Exclude_From_Build 1
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug"
|
||||||
|
|
||||||
|
# PROP Exclude_From_Build 1
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release"
|
||||||
|
|
||||||
|
# Begin Custom Build - Assembling...
|
||||||
|
IntDir=.\Win32_LIB_ASM_Release
|
||||||
|
InputPath=..\..\contrib\masmx86\gvmat32.asm
|
||||||
|
InputName=gvmat32
|
||||||
|
|
||||||
|
"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||||
|
ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
|
||||||
|
|
||||||
|
# End Custom Build
|
||||||
|
|
||||||
|
!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug"
|
||||||
|
|
||||||
|
# Begin Custom Build - Assembling...
|
||||||
|
IntDir=.\Win32_LIB_ASM_Debug
|
||||||
|
InputPath=..\..\contrib\masmx86\gvmat32.asm
|
||||||
|
InputName=gvmat32
|
||||||
|
|
||||||
|
"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||||
|
ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
|
||||||
|
|
||||||
|
# End Custom Build
|
||||||
|
|
||||||
|
!ENDIF
|
||||||
|
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
@ -466,11 +532,6 @@ SOURCE=..\..\contrib\masmx86\gvmat32c.c
|
|||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\contrib\masmx86\inffas32.asm
|
SOURCE=..\..\contrib\masmx86\inffas32.asm
|
||||||
# PROP Exclude_From_Build 1
|
|
||||||
# End Source File
|
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\contrib\masmx86\gvmat32.obj
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "zlib - Win32 DLL Release"
|
!IF "$(CFG)" == "zlib - Win32 DLL Release"
|
||||||
|
|
||||||
@ -482,8 +543,28 @@ SOURCE=..\..\contrib\masmx86\gvmat32.obj
|
|||||||
|
|
||||||
!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release"
|
!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release"
|
||||||
|
|
||||||
|
# Begin Custom Build - Assembling...
|
||||||
|
IntDir=.\Win32_DLL_ASM_Release
|
||||||
|
InputPath=..\..\contrib\masmx86\inffas32.asm
|
||||||
|
InputName=inffas32
|
||||||
|
|
||||||
|
"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||||
|
ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
|
||||||
|
|
||||||
|
# End Custom Build
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug"
|
!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug"
|
||||||
|
|
||||||
|
# Begin Custom Build - Assembling...
|
||||||
|
IntDir=.\Win32_DLL_ASM_Debug
|
||||||
|
InputPath=..\..\contrib\masmx86\inffas32.asm
|
||||||
|
InputName=inffas32
|
||||||
|
|
||||||
|
"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||||
|
ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
|
||||||
|
|
||||||
|
# End Custom Build
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "zlib - Win32 LIB Release"
|
!ELSEIF "$(CFG)" == "zlib - Win32 LIB Release"
|
||||||
|
|
||||||
# PROP Exclude_From_Build 1
|
# PROP Exclude_From_Build 1
|
||||||
@ -494,39 +575,28 @@ SOURCE=..\..\contrib\masmx86\gvmat32.obj
|
|||||||
|
|
||||||
!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release"
|
!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release"
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug"
|
# Begin Custom Build - Assembling...
|
||||||
|
IntDir=.\Win32_LIB_ASM_Release
|
||||||
|
InputPath=..\..\contrib\masmx86\inffas32.asm
|
||||||
|
InputName=inffas32
|
||||||
|
|
||||||
!ENDIF
|
"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||||
|
ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
|
||||||
|
|
||||||
# End Source File
|
# End Custom Build
|
||||||
# Begin Source File
|
|
||||||
|
|
||||||
SOURCE=..\..\contrib\masmx86\inffas32.obj
|
|
||||||
|
|
||||||
!IF "$(CFG)" == "zlib - Win32 DLL Release"
|
|
||||||
|
|
||||||
# PROP Exclude_From_Build 1
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug"
|
|
||||||
|
|
||||||
# PROP Exclude_From_Build 1
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "zlib - Win32 LIB Release"
|
|
||||||
|
|
||||||
# PROP Exclude_From_Build 1
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug"
|
|
||||||
|
|
||||||
# PROP Exclude_From_Build 1
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release"
|
|
||||||
|
|
||||||
!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug"
|
!ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug"
|
||||||
|
|
||||||
|
# Begin Custom Build - Assembling...
|
||||||
|
IntDir=.\Win32_LIB_ASM_Debug
|
||||||
|
InputPath=..\..\contrib\masmx86\inffas32.asm
|
||||||
|
InputName=inffas32
|
||||||
|
|
||||||
|
"$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||||
|
ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)"
|
||||||
|
|
||||||
|
# End Custom Build
|
||||||
|
|
||||||
!ENDIF
|
!ENDIF
|
||||||
|
|
||||||
# End Source File
|
# End Source File
|
||||||
|
@ -25,10 +25,10 @@
|
|||||||
<QPG:Files>
|
<QPG:Files>
|
||||||
<QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/>
|
<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="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/>
|
||||||
<QPG:Add file="../libz.so.1.2.1.2" install="/opt/lib/" user="root:bin" permission="644"/>
|
<QPG:Add file="../libz.so.1.2.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" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.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" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.2"/>
|
||||||
<QPG:Add file="../libz.so.1.2.1.2" install="/opt/lib/" component="slib"/>
|
<QPG:Add file="../libz.so.1.2.2" install="/opt/lib/" component="slib"/>
|
||||||
</QPG:Files>
|
</QPG:Files>
|
||||||
|
|
||||||
<QPG:PackageFilter>
|
<QPG:PackageFilter>
|
||||||
@ -63,7 +63,7 @@
|
|||||||
</QPM:ProductDescription>
|
</QPM:ProductDescription>
|
||||||
|
|
||||||
<QPM:ReleaseDescription>
|
<QPM:ReleaseDescription>
|
||||||
<QPM:ReleaseVersion>1.2.1.2</QPM:ReleaseVersion>
|
<QPM:ReleaseVersion>1.2.2</QPM:ReleaseVersion>
|
||||||
<QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
|
<QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency>
|
||||||
<QPM:ReleaseStability>Stable</QPM:ReleaseStability>
|
<QPM:ReleaseStability>Stable</QPM:ReleaseStability>
|
||||||
<QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>
|
<QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor>
|
||||||
|
@ -175,7 +175,7 @@ in the zlib distribution, or at the following location:
|
|||||||
zlib in other programming languages. Some of them, like Ada
|
zlib in other programming languages. Some of them, like Ada
|
||||||
(GNAT) and Fortran (GNU G77), have C bindings implemented
|
(GNAT) and Fortran (GNU G77), have C bindings implemented
|
||||||
initially on Unix, and relying on the C calling convention.
|
initially on Unix, and relying on the C calling convention.
|
||||||
On the other hand, the pre- .NET versions of Microsoft Visual
|
On the other hand, the pre- .Net versions of Microsoft Visual
|
||||||
Basic require STDCALL, while Borland Delphi prefers, although
|
Basic require STDCALL, while Borland Delphi prefers, although
|
||||||
it does not require, FASTCALL.
|
it does not require, FASTCALL.
|
||||||
|
|
||||||
@ -203,13 +203,11 @@ in the zlib distribution, or at the following location:
|
|||||||
zlib distribution.
|
zlib distribution.
|
||||||
|
|
||||||
|
|
||||||
8. I need a DLL for my Microsoft .NET project. What can I do?
|
8. I need to use zlib in my Microsoft .Net project. What can I
|
||||||
|
do?
|
||||||
|
|
||||||
- We did not implement a COM wrapper around zlib, so you will
|
- Henrik Ravn has contributed a .Net wrapper around zlib. Look
|
||||||
have to develop it yourself, or to get it from somewhere else.
|
into contrib/dotzlib/, inside the zlib distribution.
|
||||||
|
|
||||||
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
|
9. If my application uses ZLIB1.DLL, should I link it to
|
||||||
|
3
win32/VisualC.txt
Normal file
3
win32/VisualC.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
To build zlib using the Microsoft Visual C++ environment,
|
||||||
|
use the appropriate project from the projects/ directory.
|
@ -5,8 +5,8 @@ VS_VERSION_INFO VERSIONINFO
|
|||||||
#else
|
#else
|
||||||
VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE
|
||||||
#endif
|
#endif
|
||||||
FILEVERSION 1,2,1,2
|
FILEVERSION 1,2,2
|
||||||
PRODUCTVERSION 1,2,1,2
|
PRODUCTVERSION 1,2,2
|
||||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 1
|
FILEFLAGS 1
|
||||||
@ -23,12 +23,12 @@ BEGIN
|
|||||||
//language ID = U.S. English, char set = Windows, Multilingual
|
//language ID = U.S. English, char set = Windows, Multilingual
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "FileDescription", "zlib data compression library\0"
|
VALUE "FileDescription", "zlib data compression library\0"
|
||||||
VALUE "FileVersion", "1.2.1.2\0"
|
VALUE "FileVersion", "1.2.2\0"
|
||||||
VALUE "InternalName", "zlib1.dll\0"
|
VALUE "InternalName", "zlib1.dll\0"
|
||||||
VALUE "LegalCopyright", "(C) 1995-2004 Jean-loup Gailly & Mark Adler\0"
|
VALUE "LegalCopyright", "(C) 1995-2004 Jean-loup Gailly & Mark Adler\0"
|
||||||
VALUE "OriginalFilename", "zlib1.dll\0"
|
VALUE "OriginalFilename", "zlib1.dll\0"
|
||||||
VALUE "ProductName", "zlib\0"
|
VALUE "ProductName", "zlib\0"
|
||||||
VALUE "ProductVersion", "1.2.1.2\0"
|
VALUE "ProductVersion", "1.2.2\0"
|
||||||
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
|
VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
|
4
zlib.3
4
zlib.3
@ -1,4 +1,4 @@
|
|||||||
.TH ZLIB 3 "9 September 2004"
|
.TH ZLIB 3 "3 October 2004"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
zlib \- compression/decompression library
|
zlib \- compression/decompression library
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -133,7 +133,7 @@ before asking for help.
|
|||||||
Send questions and/or comments to zlib@gzip.org,
|
Send questions and/or comments to zlib@gzip.org,
|
||||||
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
|
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
|
||||||
.SH AUTHORS
|
.SH AUTHORS
|
||||||
Version 1.2.1.2
|
Version 1.2.2
|
||||||
Copyright (C) 1995-2004 Jean-loup Gailly (jloup@gzip.org)
|
Copyright (C) 1995-2004 Jean-loup Gailly (jloup@gzip.org)
|
||||||
and Mark Adler (madler@alumni.caltech.edu).
|
and Mark Adler (madler@alumni.caltech.edu).
|
||||||
.LP
|
.LP
|
||||||
|
24
zlib.h
24
zlib.h
@ -1,5 +1,5 @@
|
|||||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||||
version 1.2.1.2, September 9th, 2004
|
version 1.2.2, October 3rd, 2004
|
||||||
|
|
||||||
Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler
|
Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler
|
||||||
|
|
||||||
@ -37,8 +37,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ZLIB_VERSION "1.2.1.2"
|
#define ZLIB_VERSION "1.2.2"
|
||||||
#define ZLIB_VERNUM 0x1212
|
#define ZLIB_VERNUM 0x1220
|
||||||
|
|
||||||
/*
|
/*
|
||||||
The 'zlib' compression library provides in-memory compression and
|
The 'zlib' compression library provides in-memory compression and
|
||||||
@ -53,24 +53,22 @@ extern "C" {
|
|||||||
application must provide more input and/or consume the output
|
application must provide more input and/or consume the output
|
||||||
(providing more output space) before each call.
|
(providing more output space) before each call.
|
||||||
|
|
||||||
The compressed data format used by the in-memory functions is the zlib
|
The compressed data format used by default by the in-memory functions is
|
||||||
format, which is a zlib wrapper documented in RFC 1950, wrapped around a
|
the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
|
||||||
deflate stream, which is itself documented in RFC 1951.
|
around a deflate stream, which is itself documented in RFC 1951.
|
||||||
|
|
||||||
The library also supports reading and writing files in gzip (.gz) format
|
The library also supports reading and writing files in gzip (.gz) format
|
||||||
with an interface similar to that of stdio using the functions that start
|
with an interface similar to that of stdio using the functions that start
|
||||||
with "gz". The gzip format is different from the zlib format. gzip is a
|
with "gz". The gzip format is different from the zlib format. gzip is a
|
||||||
gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
|
gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
|
||||||
|
|
||||||
|
This library can optionally read and write gzip streams in memory as well.
|
||||||
|
|
||||||
The zlib format was designed to be compact and fast for use in memory
|
The zlib format was designed to be compact and fast for use in memory
|
||||||
and on communications channels. The gzip format was designed for single-
|
and on communications channels. The gzip format was designed for single-
|
||||||
file compression on file systems, has a larger header than zlib to maintain
|
file compression on file systems, has a larger header than zlib to maintain
|
||||||
directory information, and uses a different, slower check method than zlib.
|
directory information, and uses a different, slower check method than zlib.
|
||||||
|
|
||||||
This library does not provide any functions to write gzip files in memory.
|
|
||||||
However such functions could be easily written using zlib's deflate function,
|
|
||||||
the documentation in the gzip RFC, and the examples in gzio.c.
|
|
||||||
|
|
||||||
The library does not install any signal handler. The decoder checks
|
The library does not install any signal handler. The decoder checks
|
||||||
the consistency of the compressed data, so the library should never
|
the consistency of the compressed data, so the library should never
|
||||||
crash even in case of corrupted input.
|
crash even in case of corrupted input.
|
||||||
@ -478,7 +476,8 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
|
|||||||
16 to windowBits to write a simple gzip header and trailer around the
|
16 to windowBits to write a simple gzip header and trailer around the
|
||||||
compressed data instead of a zlib wrapper. The gzip header will have no
|
compressed data instead of a zlib wrapper. The gzip header will have no
|
||||||
file name, no extra data, no comment, no modification time (set to zero),
|
file name, no extra data, no comment, no modification time (set to zero),
|
||||||
no header crc, and the operating system will be set to 255 (unknown).
|
no header crc, and the operating system will be set to 255 (unknown). If a
|
||||||
|
gzip stream is being written, strm->adler is a crc32 instead of an adler32.
|
||||||
|
|
||||||
The memLevel parameter specifies how much memory should be allocated
|
The memLevel parameter specifies how much memory should be allocated
|
||||||
for the internal compression state. memLevel=1 uses minimum memory but
|
for the internal compression state. memLevel=1 uses minimum memory but
|
||||||
@ -649,7 +648,8 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
|
|||||||
windowBits can also be greater than 15 for optional gzip decoding. Add
|
windowBits can also be greater than 15 for optional gzip decoding. Add
|
||||||
32 to windowBits to enable zlib and gzip decoding with automatic header
|
32 to windowBits to enable zlib and gzip decoding with automatic header
|
||||||
detection, or add 16 to decode only the gzip format (the zlib format will
|
detection, or add 16 to decode only the gzip format (the zlib format will
|
||||||
return a Z_DATA_ERROR).
|
return a Z_DATA_ERROR. If a gzip stream is being decoded, strm->adler is
|
||||||
|
a crc32 instead of an adler32.
|
||||||
|
|
||||||
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
|
||||||
memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
|
memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative
|
||||||
|
Loading…
Reference in New Issue
Block a user