diff options
55 files changed, 2167 insertions, 194 deletions
@@ -1,6 +1,15 @@ | |||
1 | 1 | ||
2 | ChangeLog file for zlib | 2 | ChangeLog file for zlib |
3 | 3 | ||
4 | Changes in 1.2.2 (3 October 2004) | ||
5 | - Update zlib.h comments on gzip in-memory processing | ||
6 | - Set adler to 1 in inflateReset() to support Java test suite [Walles] | ||
7 | - Add contrib/dotzlib [Ravn] | ||
8 | - Update win32/DLL_FAQ.txt [Truta] | ||
9 | - Update contrib/minizip [Vollant] | ||
10 | - Move contrib/visual-basic.txt to old/ [Truta] | ||
11 | - Fix assembler builds in projects/visualc6/ [Truta] | ||
12 | |||
4 | Changes in 1.2.1.2 (9 September 2004) | 13 | Changes in 1.2.1.2 (9 September 2004) |
5 | - Update INDEX file | 14 | - Update INDEX file |
6 | - Fix trees.c to update strm->data_type (no one ever noticed!) | 15 | - Fix trees.c to update strm->data_type (no one ever noticed!) |
@@ -117,7 +117,7 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html | |||
117 | After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib | 117 | After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib |
118 | generates an error such as: | 118 | generates an error such as: |
119 | 119 | ||
120 | ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so: | 120 | ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so: |
121 | symbol __register_frame_info: referenced symbol not found | 121 | symbol __register_frame_info: referenced symbol not found |
122 | 122 | ||
123 | The symbol __register_frame_info is not part of zlib, it is generated by | 123 | The symbol __register_frame_info is not part of zlib, it is generated by |
@@ -8,7 +8,7 @@ algorithm.txt description of the (de)compression algorithm | |||
8 | configure configure script for Unix | 8 | configure configure script for Unix |
9 | zconf.in.h template for zconf.h (used by configure) | 9 | zconf.in.h template for zconf.h (used by configure) |
10 | 10 | ||
11 | amiga/ makefiles for Amiga SAS C | 11 | amiga/ makefiles for Amiga SAS C |
12 | as400/ makefiles for IBM AS/400 | 12 | as400/ makefiles for IBM AS/400 |
13 | msdos/ makefiles for MSDOS | 13 | msdos/ makefiles for MSDOS |
14 | old/ makefiles for various architectures and zlib documentation | 14 | old/ makefiles for various architectures and zlib documentation |
@@ -30,7 +30,7 @@ CPP=$(CC) -E | |||
30 | 30 | ||
31 | LIBS=libz.a | 31 | LIBS=libz.a |
32 | SHAREDLIB=libz.so | 32 | SHAREDLIB=libz.so |
33 | SHAREDLIBV=libz.so.1.2.1.2 | 33 | SHAREDLIBV=libz.so.1.2.2 |
34 | SHAREDLIBM=libz.so.1 | 34 | SHAREDLIBM=libz.so.1 |
35 | 35 | ||
36 | AR=ar rc | 36 | AR=ar rc |
diff --git a/Makefile.in b/Makefile.in index 9f04797..a29e9bc 100644 --- a/Makefile.in +++ b/Makefile.in | |||
@@ -30,7 +30,7 @@ CPP=$(CC) -E | |||
30 | 30 | ||
31 | LIBS=libz.a | 31 | LIBS=libz.a |
32 | SHAREDLIB=libz.so | 32 | SHAREDLIB=libz.so |
33 | SHAREDLIBV=libz.so.1.2.1.2 | 33 | SHAREDLIBV=libz.so.1.2.2 |
34 | SHAREDLIBM=libz.so.1 | 34 | SHAREDLIBM=libz.so.1 |
35 | 35 | ||
36 | AR=ar rc | 36 | AR=ar rc |
@@ -1,6 +1,6 @@ | |||
1 | ZLIB DATA COMPRESSION LIBRARY | 1 | ZLIB DATA COMPRESSION LIBRARY |
2 | 2 | ||
3 | zlib 1.2.1.2 is a general purpose data compression library. All the code is | 3 | zlib 1.2.2 is a general purpose data compression library. All the code is |
4 | thread safe. The data format used by the zlib library is described by RFCs | 4 | thread safe. The data format used by the zlib library is described by RFCs |
5 | (Request for Comments) 1950 to 1952 in the files | 5 | (Request for Comments) 1950 to 1952 in the files |
6 | http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) | 6 | 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 | |||
34 | issue of Dr. Dobb's Journal; a copy of the article is available in | 34 | issue of Dr. Dobb's Journal; a copy of the article is available in |
35 | http://dogma.net/markn/articles/zlibtool/zlibtool.htm | 35 | http://dogma.net/markn/articles/zlibtool/zlibtool.htm |
36 | 36 | ||
37 | The changes made in version 1.2.1.2 are documented in the file ChangeLog. | 37 | The changes made in version 1.2.2 are documented in the file ChangeLog. |
38 | 38 | ||
39 | Unsupported third party contributions are provided in directory "contrib". | 39 | Unsupported third party contributions are provided in directory "contrib". |
40 | 40 | ||
diff --git a/as400/compile.clp b/as400/compile.clp index dcd2421..3c47bb4 100644 --- a/as400/compile.clp +++ b/as400/compile.clp | |||
@@ -118,6 +118,6 @@ | |||
118 | &MODLIB/INFTREES &MODLIB/TREES + | 118 | &MODLIB/INFTREES &MODLIB/TREES + |
119 | &MODLIB/UNCOMPR &MODLIB/ZUTIL) + | 119 | &MODLIB/UNCOMPR &MODLIB/ZUTIL) + |
120 | SRCFILE(&SRCLIB/&CTLFILE) SRCMBR(BNDSRC) + | 120 | SRCFILE(&SRCLIB/&CTLFILE) SRCMBR(BNDSRC) + |
121 | TEXT('ZLIB 1.2.1') TGTRLS(V4R4M0) | 121 | TEXT('ZLIB 1.2.2') TGTRLS(V4R4M0) |
122 | 122 | ||
123 | ENDPGM | 123 | ENDPGM |
diff --git a/as400/readme.txt b/as400/readme.txt index eef7cb2..27ca676 100644 --- a/as400/readme.txt +++ b/as400/readme.txt | |||
@@ -1,4 +1,4 @@ | |||
1 | ZLIB version 1.2.1 for AS400 installation instructions | 1 | ZLIB version 1.2.2 for AS400 installation instructions |
2 | 2 | ||
3 | I) From an AS400 *SAVF file: | 3 | I) From an AS400 *SAVF file: |
4 | 4 | ||
diff --git a/as400/zlib.inc b/as400/zlib.inc index bb24691..e31e1a7 100644 --- a/as400/zlib.inc +++ b/as400/zlib.inc | |||
@@ -1,7 +1,7 @@ | |||
1 | * ZLIB.INC - Interface to the general purpose compression library | 1 | * ZLIB.INC - Interface to the general purpose compression library |
2 | * | 2 | * |
3 | * ILE RPG400 version by Patrick Monnerat, DATASPHERE. | 3 | * ILE RPG400 version by Patrick Monnerat, DATASPHERE. |
4 | * Version 1.2.1.2 | 4 | * Version 1.2.2 |
5 | * | 5 | * |
6 | * | 6 | * |
7 | * WARNING: | 7 | * WARNING: |
@@ -20,8 +20,8 @@ | |||
20 | * Constants | 20 | * Constants |
21 | ************************************************************************** | 21 | ************************************************************************** |
22 | * | 22 | * |
23 | D ZLIB_VERSION C '1.2.1.2' Header's version | 23 | D ZLIB_VERSION C '1.2.2' Header's version |
24 | D ZLIB_VERNUM C X'1212' | 24 | D ZLIB_VERNUM C X'1220' |
25 | * | 25 | * |
26 | D Z_NO_FLUSH C 0 | 26 | D Z_NO_FLUSH C 0 |
27 | D Z_SYNC_FLUSH C 2 | 27 | D Z_SYNC_FLUSH C 2 |
diff --git a/contrib/README.contrib b/contrib/README.contrib index eae15aa..7778980 100644 --- a/contrib/README.contrib +++ b/contrib/README.contrib | |||
@@ -19,6 +19,9 @@ blast/ by Mark Adler <madler@alumni.caltech.edu> | |||
19 | delphi/ by Cosmin Truta <cosmint@cs.ubbcluj.ro> | 19 | delphi/ by Cosmin Truta <cosmint@cs.ubbcluj.ro> |
20 | Support for Delphi and C++ Builder | 20 | Support for Delphi and C++ Builder |
21 | 21 | ||
22 | dotzlib/ by Henrik Ravn <henrik@ravn.com> | ||
23 | Support for Microsoft .Net and Visual C++ .Net | ||
24 | |||
22 | gzappend/ by Mark Adler <madler@alumni.caltech.edu> | 25 | gzappend/ by Mark Adler <madler@alumni.caltech.edu> |
23 | append to a gzip file -- illustrates the use of Z_BLOCK | 26 | append to a gzip file -- illustrates the use of Z_BLOCK |
24 | 27 | ||
@@ -60,11 +63,8 @@ puff/ by Mark Adler <madler@alumni.caltech.edu> | |||
60 | testzlib/ by Gilles Vollant <info@winimage.com> | 63 | testzlib/ by Gilles Vollant <info@winimage.com> |
61 | Example of the use of zlib | 64 | Example of the use of zlib |
62 | 65 | ||
63 | untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es> | 66 | untgz/ by Pedro A. Aranda Gutierrez <paag@tid.es> |
64 | A very simple tar.gz file extractor using zlib | 67 | A very simple tar.gz file extractor using zlib |
65 | 68 | ||
66 | visual-basic.txt by Carlos Rios <c_rios@sonda.cl> | ||
67 | How to use compress(), uncompress() and the gz* functions from VB | ||
68 | |||
69 | vstudio/ by Gilles Vollant <info@winimage.com> | 69 | vstudio/ by Gilles Vollant <info@winimage.com> |
70 | Building a minizip-enhanced zlib with Visual Studio .NET | 70 | Building a minizip-enhanced zlib with Microsoft Visual Studio |
diff --git a/contrib/ada/readme.txt b/contrib/ada/readme.txt index dec7ef3..ce4d2ca 100644 --- a/contrib/ada/readme.txt +++ b/contrib/ada/readme.txt | |||
@@ -1,12 +1,12 @@ | |||
1 | ZLib for Ada thick binding (ZLib.Ada) | 1 | ZLib for Ada thick binding (ZLib.Ada) |
2 | Release 1.3 | 2 | Release 1.3 |
3 | 3 | ||
4 | ZLib.Ada is a thick binding interface to the popular ZLib data | 4 | ZLib.Ada is a thick binding interface to the popular ZLib data |
5 | compression library, available at http://www.gzip.org/zlib/. | 5 | compression library, available at http://www.gzip.org/zlib/. |
6 | It provides Ada-style access to the ZLib C library. | 6 | It provides Ada-style access to the ZLib C library. |
7 | 7 | ||
8 | 8 | ||
9 | Here are the main changes since ZLib.Ada 1.2: | 9 | Here are the main changes since ZLib.Ada 1.2: |
10 | 10 | ||
11 | - Attension: ZLib.Read generic routine have a initialization requirement | 11 | - Attension: ZLib.Read generic routine have a initialization requirement |
12 | for Read_Last parameter now. It is a bit incompartible with previous version, | 12 | 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. | |||
28 | - Add pragma Assertion that Ada.Streams.Stream_Element size is 8 bit. | 28 | - Add pragma Assertion that Ada.Streams.Stream_Element size is 8 bit. |
29 | 29 | ||
30 | 30 | ||
31 | How to build ZLib.Ada under GNAT | 31 | How to build ZLib.Ada under GNAT |
32 | 32 | ||
33 | You should have the ZLib library already build on your computer, before | 33 | You should have the ZLib library already build on your computer, before |
34 | building ZLib.Ada. Make the directory of ZLib.Ada sources current and | 34 | 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: | |||
41 | gnatmake -Pzlib.gpr -L<directory where libz.a is> | 41 | gnatmake -Pzlib.gpr -L<directory where libz.a is> |
42 | 42 | ||
43 | 43 | ||
44 | How to build ZLib.Ada under Aonix ObjectAda for Win32 7.2.2 | 44 | How to build ZLib.Ada under Aonix ObjectAda for Win32 7.2.2 |
45 | 45 | ||
46 | 1. Make a project with all *.ads and *.adb files from the distribution. | 46 | 1. Make a project with all *.ads and *.adb files from the distribution. |
47 | 2. Build the libz.a library from the ZLib C sources. | 47 | 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: | |||
51 | 6. Build the executable using test.adb as a main procedure. | 51 | 6. Build the executable using test.adb as a main procedure. |
52 | 52 | ||
53 | 53 | ||
54 | How to use ZLib.Ada | 54 | How to use ZLib.Ada |
55 | 55 | ||
56 | The source files test.adb and read.adb are small demo programs that show | 56 | The source files test.adb and read.adb are small demo programs that show |
57 | the main functionality of ZLib.Ada. | 57 | the main functionality of ZLib.Ada. |
diff --git a/contrib/ada/zlib-streams.adb b/contrib/ada/zlib-streams.adb index 398664a..b6497ba 100644 --- a/contrib/ada/zlib-streams.adb +++ b/contrib/ada/zlib-streams.adb | |||
@@ -222,4 +222,4 @@ package body ZLib.Streams is | |||
222 | return Total_Out (Stream.Writer); | 222 | return Total_Out (Stream.Writer); |
223 | end Write_Total_Out; | 223 | end Write_Total_Out; |
224 | 224 | ||
225 | end ZLib.Streams; \ No newline at end of file | 225 | end ZLib.Streams; |
diff --git a/contrib/ada/zlib-streams.ads b/contrib/ada/zlib-streams.ads index 5c68667..f0193c6 100644 --- a/contrib/ada/zlib-streams.ads +++ b/contrib/ada/zlib-streams.ads | |||
@@ -111,4 +111,4 @@ private | |||
111 | Writer : Filter_Type; | 111 | Writer : Filter_Type; |
112 | end record; | 112 | end record; |
113 | 113 | ||
114 | end ZLib.Streams; \ No newline at end of file | 114 | end ZLib.Streams; |
diff --git a/contrib/ada/zlib.gpr b/contrib/ada/zlib.gpr index 88f51cc..296b22a 100644 --- a/contrib/ada/zlib.gpr +++ b/contrib/ada/zlib.gpr | |||
@@ -1,21 +1,20 @@ | |||
1 | project Zlib is | 1 | project Zlib is |
2 | 2 | ||
3 | for Languages use ("Ada"); | 3 | for Languages use ("Ada"); |
4 | for Source_Dirs use ("."); | 4 | for Source_Dirs use ("."); |
5 | for Object_Dir use "."; | 5 | for Object_Dir use "."; |
6 | for Main use ("test.adb", "mtest.adb", "read.adb", "buffer_demo"); | 6 | for Main use ("test.adb", "mtest.adb", "read.adb", "buffer_demo"); |
7 | 7 | ||
8 | package Compiler is | 8 | package Compiler is |
9 | for Default_Switches ("ada") use ("-gnatwcfilopru", "-gnatVcdfimorst", "-gnatyabcefhiklmnoprst"); | 9 | for Default_Switches ("ada") use ("-gnatwcfilopru", "-gnatVcdfimorst", "-gnatyabcefhiklmnoprst"); |
10 | end Compiler; | 10 | end Compiler; |
11 | 11 | ||
12 | package Linker is | 12 | package Linker is |
13 | for Default_Switches ("ada") use ("-lz"); | 13 | for Default_Switches ("ada") use ("-lz"); |
14 | end Linker; | 14 | end Linker; |
15 | 15 | ||
16 | package Builder is | 16 | package Builder is |
17 | for Default_Switches ("ada") use ("-s", "-gnatQ"); | 17 | for Default_Switches ("ada") use ("-s", "-gnatQ"); |
18 | end Builder; | 18 | end Builder; |
19 | 19 | ||
20 | end Zlib; | 20 | end Zlib; |
21 | |||
diff --git a/contrib/dotzlib/DotZLib.build b/contrib/dotzlib/DotZLib.build new file mode 100644 index 0000000..ed19cc9 --- /dev/null +++ b/contrib/dotzlib/DotZLib.build | |||
@@ -0,0 +1,33 @@ | |||
1 | <?xml version="1.0" encoding="utf-8" ?> | ||
2 | <project name="DotZLib" default="build" basedir="./DotZLib"> | ||
3 | <description>A .Net wrapper library around ZLib1.dll</description> | ||
4 | |||
5 | <property name="nunit.location" value="c:/program files/NUnit V2.1/bin" /> | ||
6 | <property name="build.root" value="bin" /> | ||
7 | |||
8 | <property name="debug" value="true" /> | ||
9 | <property name="nunit" value="true" /> | ||
10 | |||
11 | <property name="build.folder" value="${build.root}/debug/" if="${debug}" /> | ||
12 | <property name="build.folder" value="${build.root}/release/" unless="${debug}" /> | ||
13 | |||
14 | <target name="clean" description="Remove all generated files"> | ||
15 | <delete dir="${build.root}" failonerror="false" /> | ||
16 | </target> | ||
17 | |||
18 | <target name="build" description="compiles the source code"> | ||
19 | |||
20 | <mkdir dir="${build.folder}" /> | ||
21 | <csc target="library" output="${build.folder}DotZLib.dll" debug="${debug}"> | ||
22 | <references basedir="${nunit.location}"> | ||
23 | <includes if="${nunit}" name="nunit.framework.dll" /> | ||
24 | </references> | ||
25 | <sources> | ||
26 | <includes name="*.cs" /> | ||
27 | <excludes name="UnitTests.cs" unless="${nunit}" /> | ||
28 | </sources> | ||
29 | <arg value="/d:nunit" if="${nunit}" /> | ||
30 | </csc> | ||
31 | </target> | ||
32 | |||
33 | </project> \ No newline at end of file | ||
diff --git a/contrib/dotzlib/DotZLib.chm b/contrib/dotzlib/DotZLib.chm new file mode 100644 index 0000000..0bc7df7 --- /dev/null +++ b/contrib/dotzlib/DotZLib.chm | |||
Binary files differ | |||
diff --git a/contrib/dotzlib/DotZLib.sln b/contrib/dotzlib/DotZLib.sln new file mode 100644 index 0000000..ac45ca0 --- /dev/null +++ b/contrib/dotzlib/DotZLib.sln | |||
@@ -0,0 +1,21 @@ | |||
1 | Microsoft Visual Studio Solution File, Format Version 8.00 | ||
2 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotZLib", "DotZLib\DotZLib.csproj", "{BB1EE0B1-1808-46CB-B786-949D91117FC5}" | ||
3 | ProjectSection(ProjectDependencies) = postProject | ||
4 | EndProjectSection | ||
5 | EndProject | ||
6 | Global | ||
7 | GlobalSection(SolutionConfiguration) = preSolution | ||
8 | Debug = Debug | ||
9 | Release = Release | ||
10 | EndGlobalSection | ||
11 | GlobalSection(ProjectConfiguration) = postSolution | ||
12 | {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Debug.ActiveCfg = Debug|.NET | ||
13 | {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Debug.Build.0 = Debug|.NET | ||
14 | {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Release.ActiveCfg = Release|.NET | ||
15 | {BB1EE0B1-1808-46CB-B786-949D91117FC5}.Release.Build.0 = Release|.NET | ||
16 | EndGlobalSection | ||
17 | GlobalSection(ExtensibilityGlobals) = postSolution | ||
18 | EndGlobalSection | ||
19 | GlobalSection(ExtensibilityAddIns) = postSolution | ||
20 | EndGlobalSection | ||
21 | EndGlobal | ||
diff --git a/contrib/dotzlib/DotZLib/AssemblyInfo.cs b/contrib/dotzlib/DotZLib/AssemblyInfo.cs new file mode 100644 index 0000000..6fc0fdc --- /dev/null +++ b/contrib/dotzlib/DotZLib/AssemblyInfo.cs | |||
@@ -0,0 +1,58 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | |||
4 | // | ||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | // | ||
9 | [assembly: AssemblyTitle("DotZLib")] | ||
10 | [assembly: AssemblyDescription(".Net bindings for ZLib compression dll 1.2.x")] | ||
11 | [assembly: AssemblyConfiguration("")] | ||
12 | [assembly: AssemblyCompany("Henrik Ravn")] | ||
13 | [assembly: AssemblyProduct("")] | ||
14 | [assembly: AssemblyCopyright("(c) 2004 by Henrik Ravn")] | ||
15 | [assembly: AssemblyTrademark("")] | ||
16 | [assembly: AssemblyCulture("")] | ||
17 | |||
18 | // | ||
19 | // Version information for an assembly consists of the following four values: | ||
20 | // | ||
21 | // Major Version | ||
22 | // Minor Version | ||
23 | // Build Number | ||
24 | // Revision | ||
25 | // | ||
26 | // You can specify all the values or you can default the Revision and Build Numbers | ||
27 | // by using the '*' as shown below: | ||
28 | |||
29 | [assembly: AssemblyVersion("1.0.*")] | ||
30 | |||
31 | // | ||
32 | // In order to sign your assembly you must specify a key to use. Refer to the | ||
33 | // Microsoft .NET Framework documentation for more information on assembly signing. | ||
34 | // | ||
35 | // Use the attributes below to control which key is used for signing. | ||
36 | // | ||
37 | // Notes: | ||
38 | // (*) If no key is specified, the assembly is not signed. | ||
39 | // (*) KeyName refers to a key that has been installed in the Crypto Service | ||
40 | // Provider (CSP) on your machine. KeyFile refers to a file which contains | ||
41 | // a key. | ||
42 | // (*) If the KeyFile and the KeyName values are both specified, the | ||
43 | // following processing occurs: | ||
44 | // (1) If the KeyName can be found in the CSP, that key is used. | ||
45 | // (2) If the KeyName does not exist and the KeyFile does exist, the key | ||
46 | // in the KeyFile is installed into the CSP and used. | ||
47 | // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. | ||
48 | // When specifying the KeyFile, the location of the KeyFile should be | ||
49 | // relative to the project output directory which is | ||
50 | // %Project Directory%\obj\<configuration>. For example, if your KeyFile is | ||
51 | // located in the project directory, you would specify the AssemblyKeyFile | ||
52 | // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] | ||
53 | // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework | ||
54 | // documentation for more information on this. | ||
55 | // | ||
56 | [assembly: AssemblyDelaySign(false)] | ||
57 | [assembly: AssemblyKeyFile("")] | ||
58 | [assembly: AssemblyKeyName("")] | ||
diff --git a/contrib/dotzlib/DotZLib/ChecksumImpl.cs b/contrib/dotzlib/DotZLib/ChecksumImpl.cs new file mode 100644 index 0000000..dfe7e90 --- /dev/null +++ b/contrib/dotzlib/DotZLib/ChecksumImpl.cs | |||
@@ -0,0 +1,202 @@ | |||
1 | // | ||
2 | // © Copyright Henrik Ravn 2004 | ||
3 | // | ||
4 | // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | ||
5 | // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
6 | // | ||
7 | |||
8 | using System; | ||
9 | using System.Runtime.InteropServices; | ||
10 | using System.Text; | ||
11 | |||
12 | |||
13 | namespace DotZLib | ||
14 | { | ||
15 | #region ChecksumGeneratorBase | ||
16 | /// <summary> | ||
17 | /// Implements the common functionality needed for all <see cref="ChecksumGenerator"/>s | ||
18 | /// </summary> | ||
19 | /// <example></example> | ||
20 | public abstract class ChecksumGeneratorBase : ChecksumGenerator | ||
21 | { | ||
22 | /// <summary> | ||
23 | /// The value of the current checksum | ||
24 | /// </summary> | ||
25 | protected uint _current; | ||
26 | |||
27 | /// <summary> | ||
28 | /// Initializes a new instance of the checksum generator base - the current checksum is | ||
29 | /// set to zero | ||
30 | /// </summary> | ||
31 | public ChecksumGeneratorBase() | ||
32 | { | ||
33 | _current = 0; | ||
34 | } | ||
35 | |||
36 | /// <summary> | ||
37 | /// Initializes a new instance of the checksum generator basewith a specified value | ||
38 | /// </summary> | ||
39 | /// <param name="initialValue">The value to set the current checksum to</param> | ||
40 | public ChecksumGeneratorBase(uint initialValue) | ||
41 | { | ||
42 | _current = initialValue; | ||
43 | } | ||
44 | |||
45 | /// <summary> | ||
46 | /// Resets the current checksum to zero | ||
47 | /// </summary> | ||
48 | public void Reset() { _current = 0; } | ||
49 | |||
50 | /// <summary> | ||
51 | /// Gets the current checksum value | ||
52 | /// </summary> | ||
53 | public uint Value { get { return _current; } } | ||
54 | |||
55 | /// <summary> | ||
56 | /// Updates the current checksum with part of an array of bytes | ||
57 | /// </summary> | ||
58 | /// <param name="data">The data to update the checksum with</param> | ||
59 | /// <param name="offset">Where in <c>data</c> to start updating</param> | ||
60 | /// <param name="count">The number of bytes from <c>data</c> to use</param> | ||
61 | /// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception> | ||
62 | /// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception> | ||
63 | /// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception> | ||
64 | /// <remarks>All the other <c>Update</c> methods are implmeneted in terms of this one. | ||
65 | /// This is therefore the only method a derived class has to implement</remarks> | ||
66 | public abstract void Update(byte[] data, int offset, int count); | ||
67 | |||
68 | /// <summary> | ||
69 | /// Updates the current checksum with an array of bytes. | ||
70 | /// </summary> | ||
71 | /// <param name="data">The data to update the checksum with</param> | ||
72 | public void Update(byte[] data) | ||
73 | { | ||
74 | Update(data, 0, data.Length); | ||
75 | } | ||
76 | |||
77 | /// <summary> | ||
78 | /// Updates the current checksum with the data from a string | ||
79 | /// </summary> | ||
80 | /// <param name="data">The string to update the checksum with</param> | ||
81 | /// <remarks>The characters in the string are converted by the UTF-8 encoding</remarks> | ||
82 | public void Update(string data) | ||
83 | { | ||
84 | Update(Encoding.UTF8.GetBytes(data)); | ||
85 | } | ||
86 | |||
87 | /// <summary> | ||
88 | /// Updates the current checksum with the data from a string, using a specific encoding | ||
89 | /// </summary> | ||
90 | /// <param name="data">The string to update the checksum with</param> | ||
91 | /// <param name="encoding">The encoding to use</param> | ||
92 | public void Update(string data, Encoding encoding) | ||
93 | { | ||
94 | Update(encoding.GetBytes(data)); | ||
95 | } | ||
96 | |||
97 | } | ||
98 | #endregion | ||
99 | |||
100 | #region CRC32 | ||
101 | /// <summary> | ||
102 | /// Implements a CRC32 checksum generator | ||
103 | /// </summary> | ||
104 | public sealed class CRC32Checksum : ChecksumGeneratorBase | ||
105 | { | ||
106 | #region DLL imports | ||
107 | |||
108 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
109 | private static extern uint crc32(uint crc, int data, uint length); | ||
110 | |||
111 | #endregion | ||
112 | |||
113 | /// <summary> | ||
114 | /// Initializes a new instance of the CRC32 checksum generator | ||
115 | /// </summary> | ||
116 | public CRC32Checksum() : base() {} | ||
117 | |||
118 | /// <summary> | ||
119 | /// Initializes a new instance of the CRC32 checksum generator with a specified value | ||
120 | /// </summary> | ||
121 | /// <param name="initialValue">The value to set the current checksum to</param> | ||
122 | public CRC32Checksum(uint initialValue) : base(initialValue) {} | ||
123 | |||
124 | /// <summary> | ||
125 | /// Updates the current checksum with part of an array of bytes | ||
126 | /// </summary> | ||
127 | /// <param name="data">The data to update the checksum with</param> | ||
128 | /// <param name="offset">Where in <c>data</c> to start updating</param> | ||
129 | /// <param name="count">The number of bytes from <c>data</c> to use</param> | ||
130 | /// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception> | ||
131 | /// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception> | ||
132 | /// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception> | ||
133 | public override void Update(byte[] data, int offset, int count) | ||
134 | { | ||
135 | if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); | ||
136 | if ((offset+count) > data.Length) throw new ArgumentException(); | ||
137 | GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned); | ||
138 | try | ||
139 | { | ||
140 | _current = crc32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count); | ||
141 | } | ||
142 | finally | ||
143 | { | ||
144 | hData.Free(); | ||
145 | } | ||
146 | } | ||
147 | |||
148 | } | ||
149 | #endregion | ||
150 | |||
151 | #region Adler | ||
152 | /// <summary> | ||
153 | /// Implements a checksum generator that computes the Adler checksum on data | ||
154 | /// </summary> | ||
155 | public sealed class AdlerChecksum : ChecksumGeneratorBase | ||
156 | { | ||
157 | #region DLL imports | ||
158 | |||
159 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
160 | private static extern uint adler32(uint adler, int data, uint length); | ||
161 | |||
162 | #endregion | ||
163 | |||
164 | /// <summary> | ||
165 | /// Initializes a new instance of the Adler checksum generator | ||
166 | /// </summary> | ||
167 | public AdlerChecksum() : base() {} | ||
168 | |||
169 | /// <summary> | ||
170 | /// Initializes a new instance of the Adler checksum generator with a specified value | ||
171 | /// </summary> | ||
172 | /// <param name="initialValue">The value to set the current checksum to</param> | ||
173 | public AdlerChecksum(uint initialValue) : base(initialValue) {} | ||
174 | |||
175 | /// <summary> | ||
176 | /// Updates the current checksum with part of an array of bytes | ||
177 | /// </summary> | ||
178 | /// <param name="data">The data to update the checksum with</param> | ||
179 | /// <param name="offset">Where in <c>data</c> to start updating</param> | ||
180 | /// <param name="count">The number of bytes from <c>data</c> to use</param> | ||
181 | /// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception> | ||
182 | /// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception> | ||
183 | /// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception> | ||
184 | public override void Update(byte[] data, int offset, int count) | ||
185 | { | ||
186 | if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); | ||
187 | if ((offset+count) > data.Length) throw new ArgumentException(); | ||
188 | GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned); | ||
189 | try | ||
190 | { | ||
191 | _current = adler32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count); | ||
192 | } | ||
193 | finally | ||
194 | { | ||
195 | hData.Free(); | ||
196 | } | ||
197 | } | ||
198 | |||
199 | } | ||
200 | #endregion | ||
201 | |||
202 | } \ No newline at end of file | ||
diff --git a/contrib/dotzlib/DotZLib/CircularBuffer.cs b/contrib/dotzlib/DotZLib/CircularBuffer.cs new file mode 100644 index 0000000..16997e9 --- /dev/null +++ b/contrib/dotzlib/DotZLib/CircularBuffer.cs | |||
@@ -0,0 +1,83 @@ | |||
1 | // | ||
2 | // © Copyright Henrik Ravn 2004 | ||
3 | // | ||
4 | // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | ||
5 | // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
6 | // | ||
7 | |||
8 | using System; | ||
9 | using System.Diagnostics; | ||
10 | |||
11 | namespace DotZLib | ||
12 | { | ||
13 | |||
14 | /// <summary> | ||
15 | /// This class implements a circular buffer | ||
16 | /// </summary> | ||
17 | internal class CircularBuffer | ||
18 | { | ||
19 | #region Private data | ||
20 | private int _capacity; | ||
21 | private int _head; | ||
22 | private int _tail; | ||
23 | private int _size; | ||
24 | private byte[] _buffer; | ||
25 | #endregion | ||
26 | |||
27 | public CircularBuffer(int capacity) | ||
28 | { | ||
29 | Debug.Assert( capacity > 0 ); | ||
30 | _buffer = new byte[capacity]; | ||
31 | _capacity = capacity; | ||
32 | _head = 0; | ||
33 | _tail = 0; | ||
34 | _size = 0; | ||
35 | } | ||
36 | |||
37 | public int Size { get { return _size; } } | ||
38 | |||
39 | public int Put(byte[] source, int offset, int count) | ||
40 | { | ||
41 | Debug.Assert( count > 0 ); | ||
42 | int trueCount = Math.Min(count, _capacity - Size); | ||
43 | for (int i = 0; i < trueCount; ++i) | ||
44 | _buffer[(_tail+i) % _capacity] = source[offset+i]; | ||
45 | _tail += trueCount; | ||
46 | _tail %= _capacity; | ||
47 | _size += trueCount; | ||
48 | return trueCount; | ||
49 | } | ||
50 | |||
51 | public bool Put(byte b) | ||
52 | { | ||
53 | if (Size == _capacity) // no room | ||
54 | return false; | ||
55 | _buffer[_tail++] = b; | ||
56 | _tail %= _capacity; | ||
57 | ++_size; | ||
58 | return true; | ||
59 | } | ||
60 | |||
61 | public int Get(byte[] destination, int offset, int count) | ||
62 | { | ||
63 | int trueCount = Math.Min(count,Size); | ||
64 | for (int i = 0; i < trueCount; ++i) | ||
65 | destination[offset + i] = _buffer[(_head+i) % _capacity]; | ||
66 | _head += trueCount; | ||
67 | _head %= _capacity; | ||
68 | _size -= trueCount; | ||
69 | return trueCount; | ||
70 | } | ||
71 | |||
72 | public int Get() | ||
73 | { | ||
74 | if (Size == 0) | ||
75 | return -1; | ||
76 | |||
77 | int result = (int)_buffer[_head++ % _capacity]; | ||
78 | --_size; | ||
79 | return result; | ||
80 | } | ||
81 | |||
82 | } | ||
83 | } | ||
diff --git a/contrib/dotzlib/DotZLib/CodecBase.cs b/contrib/dotzlib/DotZLib/CodecBase.cs new file mode 100644 index 0000000..954db7d --- /dev/null +++ b/contrib/dotzlib/DotZLib/CodecBase.cs | |||
@@ -0,0 +1,198 @@ | |||
1 | // | ||
2 | // © Copyright Henrik Ravn 2004 | ||
3 | // | ||
4 | // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | ||
5 | // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
6 | // | ||
7 | |||
8 | using System; | ||
9 | using System.Runtime.InteropServices; | ||
10 | |||
11 | namespace DotZLib | ||
12 | { | ||
13 | /// <summary> | ||
14 | /// Implements the common functionality needed for all <see cref="Codec"/>s | ||
15 | /// </summary> | ||
16 | public abstract class CodecBase : Codec, IDisposable | ||
17 | { | ||
18 | |||
19 | #region Data members | ||
20 | |||
21 | /// <summary> | ||
22 | /// Instance of the internal zlib buffer structure that is | ||
23 | /// passed to all functions in the zlib dll | ||
24 | /// </summary> | ||
25 | internal ZStream _ztream = new ZStream(); | ||
26 | |||
27 | /// <summary> | ||
28 | /// True if the object instance has been disposed, false otherwise | ||
29 | /// </summary> | ||
30 | protected bool _isDisposed = false; | ||
31 | |||
32 | /// <summary> | ||
33 | /// The size of the internal buffers | ||
34 | /// </summary> | ||
35 | protected const int kBufferSize = 16384; | ||
36 | |||
37 | private byte[] _outBuffer = new byte[kBufferSize]; | ||
38 | private byte[] _inBuffer = new byte[kBufferSize]; | ||
39 | |||
40 | private GCHandle _hInput; | ||
41 | private GCHandle _hOutput; | ||
42 | |||
43 | private uint _checksum = 0; | ||
44 | |||
45 | #endregion | ||
46 | |||
47 | /// <summary> | ||
48 | /// Initializes a new instance of the <c>CodeBase</c> class. | ||
49 | /// </summary> | ||
50 | public CodecBase() | ||
51 | { | ||
52 | try | ||
53 | { | ||
54 | _hInput = GCHandle.Alloc(_inBuffer, GCHandleType.Pinned); | ||
55 | _hOutput = GCHandle.Alloc(_outBuffer, GCHandleType.Pinned); | ||
56 | } | ||
57 | catch (Exception) | ||
58 | { | ||
59 | CleanUp(false); | ||
60 | throw; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | |||
65 | #region Codec Members | ||
66 | |||
67 | /// <summary> | ||
68 | /// Occurs when more processed data are available. | ||
69 | /// </summary> | ||
70 | public event DataAvailableHandler DataAvailable; | ||
71 | |||
72 | /// <summary> | ||
73 | /// Fires the <see cref="DataAvailable"/> event | ||
74 | /// </summary> | ||
75 | protected void OnDataAvailable() | ||
76 | { | ||
77 | if (_ztream.total_out > 0) | ||
78 | { | ||
79 | if (DataAvailable != null) | ||
80 | DataAvailable( _outBuffer, 0, (int)_ztream.total_out); | ||
81 | resetOutput(); | ||
82 | } | ||
83 | } | ||
84 | |||
85 | /// <summary> | ||
86 | /// Adds more data to the codec to be processed. | ||
87 | /// </summary> | ||
88 | /// <param name="data">Byte array containing the data to be added to the codec</param> | ||
89 | /// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks> | ||
90 | public void Add(byte[] data) | ||
91 | { | ||
92 | Add(data,0,data.Length); | ||
93 | } | ||
94 | |||
95 | /// <summary> | ||
96 | /// Adds more data to the codec to be processed. | ||
97 | /// </summary> | ||
98 | /// <param name="data">Byte array containing the data to be added to the codec</param> | ||
99 | /// <param name="offset">The index of the first byte to add from <c>data</c></param> | ||
100 | /// <param name="count">The number of bytes to add</param> | ||
101 | /// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks> | ||
102 | /// <remarks>This must be implemented by a derived class</remarks> | ||
103 | public abstract void Add(byte[] data, int offset, int count); | ||
104 | |||
105 | /// <summary> | ||
106 | /// Finishes up any pending data that needs to be processed and handled. | ||
107 | /// </summary> | ||
108 | /// <remarks>This must be implemented by a derived class</remarks> | ||
109 | public abstract void Finish(); | ||
110 | |||
111 | /// <summary> | ||
112 | /// Gets the checksum of the data that has been added so far | ||
113 | /// </summary> | ||
114 | public uint Checksum { get { return _checksum; } } | ||
115 | |||
116 | #endregion | ||
117 | |||
118 | #region Destructor & IDisposable stuff | ||
119 | |||
120 | /// <summary> | ||
121 | /// Destroys this instance | ||
122 | /// </summary> | ||
123 | ~CodecBase() | ||
124 | { | ||
125 | CleanUp(false); | ||
126 | } | ||
127 | |||
128 | /// <summary> | ||
129 | /// Releases any unmanaged resources and calls the <see cref="CleanUp()"/> method of the derived class | ||
130 | /// </summary> | ||
131 | public void Dispose() | ||
132 | { | ||
133 | CleanUp(true); | ||
134 | } | ||
135 | |||
136 | /// <summary> | ||
137 | /// Performs any codec specific cleanup | ||
138 | /// </summary> | ||
139 | /// <remarks>This must be implemented by a derived class</remarks> | ||
140 | protected abstract void CleanUp(); | ||
141 | |||
142 | // performs the release of the handles and calls the dereived CleanUp() | ||
143 | private void CleanUp(bool isDisposing) | ||
144 | { | ||
145 | if (!_isDisposed) | ||
146 | { | ||
147 | CleanUp(); | ||
148 | if (_hInput.IsAllocated) | ||
149 | _hInput.Free(); | ||
150 | if (_hOutput.IsAllocated) | ||
151 | _hOutput.Free(); | ||
152 | |||
153 | _isDisposed = true; | ||
154 | } | ||
155 | } | ||
156 | |||
157 | |||
158 | #endregion | ||
159 | |||
160 | #region Helper methods | ||
161 | |||
162 | /// <summary> | ||
163 | /// Copies a number of bytes to the internal codec buffer - ready for proccesing | ||
164 | /// </summary> | ||
165 | /// <param name="data">The byte array that contains the data to copy</param> | ||
166 | /// <param name="startIndex">The index of the first byte to copy</param> | ||
167 | /// <param name="count">The number of bytes to copy from <c>data</c></param> | ||
168 | protected void copyInput(byte[] data, int startIndex, int count) | ||
169 | { | ||
170 | Array.Copy(data, startIndex, _inBuffer,0, count); | ||
171 | _ztream.next_in = _hInput.AddrOfPinnedObject(); | ||
172 | _ztream.total_in = 0; | ||
173 | _ztream.avail_in = (uint)count; | ||
174 | |||
175 | } | ||
176 | |||
177 | /// <summary> | ||
178 | /// Resets the internal output buffers to a known state - ready for processing | ||
179 | /// </summary> | ||
180 | protected void resetOutput() | ||
181 | { | ||
182 | _ztream.total_out = 0; | ||
183 | _ztream.avail_out = kBufferSize; | ||
184 | _ztream.next_out = _hOutput.AddrOfPinnedObject(); | ||
185 | } | ||
186 | |||
187 | /// <summary> | ||
188 | /// Updates the running checksum property | ||
189 | /// </summary> | ||
190 | /// <param name="newSum">The new checksum value</param> | ||
191 | protected void setChecksum(uint newSum) | ||
192 | { | ||
193 | _checksum = newSum; | ||
194 | } | ||
195 | #endregion | ||
196 | |||
197 | } | ||
198 | } | ||
diff --git a/contrib/dotzlib/DotZLib/Deflater.cs b/contrib/dotzlib/DotZLib/Deflater.cs new file mode 100644 index 0000000..d7b8dcc --- /dev/null +++ b/contrib/dotzlib/DotZLib/Deflater.cs | |||
@@ -0,0 +1,106 @@ | |||
1 | // | ||
2 | // © Copyright Henrik Ravn 2004 | ||
3 | // | ||
4 | // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | ||
5 | // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
6 | // | ||
7 | |||
8 | using System; | ||
9 | using System.Diagnostics; | ||
10 | using System.Runtime.InteropServices; | ||
11 | |||
12 | namespace DotZLib | ||
13 | { | ||
14 | |||
15 | /// <summary> | ||
16 | /// Implements a data compressor, using the deflate algorithm in the ZLib dll | ||
17 | /// </summary> | ||
18 | public sealed class Deflater : CodecBase | ||
19 | { | ||
20 | #region Dll imports | ||
21 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)] | ||
22 | private static extern int deflateInit_(ref ZStream sz, int level, string vs, int size); | ||
23 | |||
24 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
25 | private static extern int deflate(ref ZStream sz, int flush); | ||
26 | |||
27 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
28 | private static extern int deflateReset(ref ZStream sz); | ||
29 | |||
30 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
31 | private static extern int deflateEnd(ref ZStream sz); | ||
32 | #endregion | ||
33 | |||
34 | /// <summary> | ||
35 | /// Constructs an new instance of the <c>Deflater</c> | ||
36 | /// </summary> | ||
37 | /// <param name="level">The compression level to use for this <c>Deflater</c></param> | ||
38 | public Deflater(CompressLevel level) : base() | ||
39 | { | ||
40 | int retval = deflateInit_(ref _ztream, (int)level, Info.Version, Marshal.SizeOf(_ztream)); | ||
41 | if (retval != 0) | ||
42 | throw new ZLibException(retval, "Could not initialize deflater"); | ||
43 | |||
44 | resetOutput(); | ||
45 | } | ||
46 | |||
47 | /// <summary> | ||
48 | /// Adds more data to the codec to be processed. | ||
49 | /// </summary> | ||
50 | /// <param name="data">Byte array containing the data to be added to the codec</param> | ||
51 | /// <param name="offset">The index of the first byte to add from <c>data</c></param> | ||
52 | /// <param name="count">The number of bytes to add</param> | ||
53 | /// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks> | ||
54 | public override void Add(byte[] data, int offset, int count) | ||
55 | { | ||
56 | if (data == null) throw new ArgumentNullException(); | ||
57 | if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); | ||
58 | if ((offset+count) > data.Length) throw new ArgumentException(); | ||
59 | |||
60 | int total = count; | ||
61 | int inputIndex = offset; | ||
62 | int err = 0; | ||
63 | |||
64 | while (err >= 0 && inputIndex < total) | ||
65 | { | ||
66 | copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize)); | ||
67 | while (err >= 0 && _ztream.avail_in > 0) | ||
68 | { | ||
69 | err = deflate(ref _ztream, (int)FlushTypes.None); | ||
70 | if (err == 0) | ||
71 | while (_ztream.avail_out == 0) | ||
72 | { | ||
73 | OnDataAvailable(); | ||
74 | err = deflate(ref _ztream, (int)FlushTypes.None); | ||
75 | } | ||
76 | inputIndex += (int)_ztream.total_in; | ||
77 | } | ||
78 | } | ||
79 | setChecksum( _ztream.adler ); | ||
80 | } | ||
81 | |||
82 | |||
83 | /// <summary> | ||
84 | /// Finishes up any pending data that needs to be processed and handled. | ||
85 | /// </summary> | ||
86 | public override void Finish() | ||
87 | { | ||
88 | int err; | ||
89 | do | ||
90 | { | ||
91 | err = deflate(ref _ztream, (int)FlushTypes.Finish); | ||
92 | OnDataAvailable(); | ||
93 | } | ||
94 | while (err == 0); | ||
95 | setChecksum( _ztream.adler ); | ||
96 | deflateReset(ref _ztream); | ||
97 | resetOutput(); | ||
98 | } | ||
99 | |||
100 | /// <summary> | ||
101 | /// Closes the internal zlib deflate stream | ||
102 | /// </summary> | ||
103 | protected override void CleanUp() { deflateEnd(ref _ztream); } | ||
104 | |||
105 | } | ||
106 | } | ||
diff --git a/contrib/dotzlib/DotZLib/DotZLib.cs b/contrib/dotzlib/DotZLib/DotZLib.cs new file mode 100644 index 0000000..410deb0 --- /dev/null +++ b/contrib/dotzlib/DotZLib/DotZLib.cs | |||
@@ -0,0 +1,288 @@ | |||
1 | // | ||
2 | // © Copyright Henrik Ravn 2004 | ||
3 | // | ||
4 | // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | ||
5 | // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
6 | // | ||
7 | |||
8 | using System; | ||
9 | using System.IO; | ||
10 | using System.Runtime.InteropServices; | ||
11 | using System.Text; | ||
12 | |||
13 | |||
14 | namespace DotZLib | ||
15 | { | ||
16 | |||
17 | #region Internal types | ||
18 | |||
19 | /// <summary> | ||
20 | /// Defines constants for the various flush types used with zlib | ||
21 | /// </summary> | ||
22 | internal enum FlushTypes | ||
23 | { | ||
24 | None, Partial, Sync, Full, Finish, Block | ||
25 | } | ||
26 | |||
27 | #region ZStream structure | ||
28 | // internal mapping of the zlib zstream structure for marshalling | ||
29 | [StructLayoutAttribute(LayoutKind.Sequential, Pack=4, Size=0, CharSet=CharSet.Ansi)] | ||
30 | internal struct ZStream | ||
31 | { | ||
32 | public IntPtr next_in; | ||
33 | public uint avail_in; | ||
34 | public uint total_in; | ||
35 | |||
36 | public IntPtr next_out; | ||
37 | public uint avail_out; | ||
38 | public uint total_out; | ||
39 | |||
40 | [MarshalAs(UnmanagedType.LPStr)] | ||
41 | string msg; | ||
42 | uint state; | ||
43 | |||
44 | uint zalloc; | ||
45 | uint zfree; | ||
46 | uint opaque; | ||
47 | |||
48 | int data_type; | ||
49 | public uint adler; | ||
50 | uint reserved; | ||
51 | } | ||
52 | |||
53 | #endregion | ||
54 | |||
55 | #endregion | ||
56 | |||
57 | #region Public enums | ||
58 | /// <summary> | ||
59 | /// Defines constants for the available compression levels in zlib | ||
60 | /// </summary> | ||
61 | public enum CompressLevel : int | ||
62 | { | ||
63 | /// <summary> | ||
64 | /// The default compression level with a reasonable compromise between compression and speed | ||
65 | /// </summary> | ||
66 | Default = -1, | ||
67 | /// <summary> | ||
68 | /// No compression at all. The data are passed straight through. | ||
69 | /// </summary> | ||
70 | None = 0, | ||
71 | /// <summary> | ||
72 | /// The maximum compression rate available. | ||
73 | /// </summary> | ||
74 | Best = 9, | ||
75 | /// <summary> | ||
76 | /// The fastest available compression level. | ||
77 | /// </summary> | ||
78 | Fastest = 1 | ||
79 | } | ||
80 | #endregion | ||
81 | |||
82 | #region Exception classes | ||
83 | /// <summary> | ||
84 | /// The exception that is thrown when an error occurs on the zlib dll | ||
85 | /// </summary> | ||
86 | public class ZLibException : ApplicationException | ||
87 | { | ||
88 | /// <summary> | ||
89 | /// Initializes a new instance of the <see cref="ZLibException"/> class with a specified | ||
90 | /// error message and error code | ||
91 | /// </summary> | ||
92 | /// <param name="errorCode">The zlib error code that caused the exception</param> | ||
93 | /// <param name="msg">A message that (hopefully) describes the error</param> | ||
94 | public ZLibException(int errorCode, string msg) : base(String.Format("ZLib error {0} {1}", errorCode, msg)) | ||
95 | { | ||
96 | } | ||
97 | |||
98 | /// <summary> | ||
99 | /// Initializes a new instance of the <see cref="ZLibException"/> class with a specified | ||
100 | /// error code | ||
101 | /// </summary> | ||
102 | /// <param name="errorCode">The zlib error code that caused the exception</param> | ||
103 | public ZLibException(int errorCode) : base(String.Format("ZLib error {0}", errorCode)) | ||
104 | { | ||
105 | } | ||
106 | } | ||
107 | #endregion | ||
108 | |||
109 | #region Interfaces | ||
110 | |||
111 | /// <summary> | ||
112 | /// Declares methods and properties that enables a running checksum to be calculated | ||
113 | /// </summary> | ||
114 | public interface ChecksumGenerator | ||
115 | { | ||
116 | /// <summary> | ||
117 | /// Gets the current value of the checksum | ||
118 | /// </summary> | ||
119 | uint Value { get; } | ||
120 | |||
121 | /// <summary> | ||
122 | /// Clears the current checksum to 0 | ||
123 | /// </summary> | ||
124 | void Reset(); | ||
125 | |||
126 | /// <summary> | ||
127 | /// Updates the current checksum with an array of bytes | ||
128 | /// </summary> | ||
129 | /// <param name="data">The data to update the checksum with</param> | ||
130 | void Update(byte[] data); | ||
131 | |||
132 | /// <summary> | ||
133 | /// Updates the current checksum with part of an array of bytes | ||
134 | /// </summary> | ||
135 | /// <param name="data">The data to update the checksum with</param> | ||
136 | /// <param name="offset">Where in <c>data</c> to start updating</param> | ||
137 | /// <param name="count">The number of bytes from <c>data</c> to use</param> | ||
138 | /// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception> | ||
139 | /// <exception cref="ArgumentNullException"><c>data</c> is a null reference</exception> | ||
140 | /// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception> | ||
141 | void Update(byte[] data, int offset, int count); | ||
142 | |||
143 | /// <summary> | ||
144 | /// Updates the current checksum with the data from a string | ||
145 | /// </summary> | ||
146 | /// <param name="data">The string to update the checksum with</param> | ||
147 | /// <remarks>The characters in the string are converted by the UTF-8 encoding</remarks> | ||
148 | void Update(string data); | ||
149 | |||
150 | /// <summary> | ||
151 | /// Updates the current checksum with the data from a string, using a specific encoding | ||
152 | /// </summary> | ||
153 | /// <param name="data">The string to update the checksum with</param> | ||
154 | /// <param name="encoding">The encoding to use</param> | ||
155 | void Update(string data, Encoding encoding); | ||
156 | } | ||
157 | |||
158 | |||
159 | /// <summary> | ||
160 | /// Represents the method that will be called from a codec when new data | ||
161 | /// are available. | ||
162 | /// </summary> | ||
163 | /// <paramref name="data">The byte array containing the processed data</paramref> | ||
164 | /// <paramref name="startIndex">The index of the first processed byte in <c>data</c></paramref> | ||
165 | /// <paramref name="count">The number of processed bytes available</paramref> | ||
166 | /// <remarks>On return from this method, the data may be overwritten, so grab it while you can. | ||
167 | /// You cannot assume that startIndex will be zero. | ||
168 | /// </remarks> | ||
169 | public delegate void DataAvailableHandler(byte[] data, int startIndex, int count); | ||
170 | |||
171 | /// <summary> | ||
172 | /// Declares methods and events for implementing compressors/decompressors | ||
173 | /// </summary> | ||
174 | public interface Codec | ||
175 | { | ||
176 | /// <summary> | ||
177 | /// Occurs when more processed data are available. | ||
178 | /// </summary> | ||
179 | event DataAvailableHandler DataAvailable; | ||
180 | |||
181 | /// <summary> | ||
182 | /// Adds more data to the codec to be processed. | ||
183 | /// </summary> | ||
184 | /// <param name="data">Byte array containing the data to be added to the codec</param> | ||
185 | /// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks> | ||
186 | void Add(byte[] data); | ||
187 | |||
188 | /// <summary> | ||
189 | /// Adds more data to the codec to be processed. | ||
190 | /// </summary> | ||
191 | /// <param name="data">Byte array containing the data to be added to the codec</param> | ||
192 | /// <param name="offset">The index of the first byte to add from <c>data</c></param> | ||
193 | /// <param name="count">The number of bytes to add</param> | ||
194 | /// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks> | ||
195 | void Add(byte[] data, int offset, int count); | ||
196 | |||
197 | /// <summary> | ||
198 | /// Finishes up any pending data that needs to be processed and handled. | ||
199 | /// </summary> | ||
200 | void Finish(); | ||
201 | |||
202 | /// <summary> | ||
203 | /// Gets the checksum of the data that has been added so far | ||
204 | /// </summary> | ||
205 | uint Checksum { get; } | ||
206 | |||
207 | |||
208 | } | ||
209 | |||
210 | #endregion | ||
211 | |||
212 | #region Classes | ||
213 | /// <summary> | ||
214 | /// Encapsulates general information about the ZLib library | ||
215 | /// </summary> | ||
216 | public class Info | ||
217 | { | ||
218 | #region DLL imports | ||
219 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
220 | private static extern uint zlibCompileFlags(); | ||
221 | |||
222 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
223 | private static extern string zlibVersion(); | ||
224 | #endregion | ||
225 | |||
226 | #region Private stuff | ||
227 | private uint _flags; | ||
228 | |||
229 | // helper function that unpacks a bitsize mask | ||
230 | private static int bitSize(uint bits) | ||
231 | { | ||
232 | switch (bits) | ||
233 | { | ||
234 | case 0: return 16; | ||
235 | case 1: return 32; | ||
236 | case 2: return 64; | ||
237 | } | ||
238 | return -1; | ||
239 | } | ||
240 | #endregion | ||
241 | |||
242 | /// <summary> | ||
243 | /// Constructs an instance of the <c>Info</c> class. | ||
244 | /// </summary> | ||
245 | public Info() | ||
246 | { | ||
247 | _flags = zlibCompileFlags(); | ||
248 | } | ||
249 | |||
250 | /// <summary> | ||
251 | /// True if the library is compiled with debug info | ||
252 | /// </summary> | ||
253 | public bool HasDebugInfo { get { return 0 != (_flags & 0x100); } } | ||
254 | |||
255 | /// <summary> | ||
256 | /// True if the library is compiled with assembly optimizations | ||
257 | /// </summary> | ||
258 | public bool UsesAssemblyCode { get { return 0 != (_flags & 0x200); } } | ||
259 | |||
260 | /// <summary> | ||
261 | /// Gets the size of the unsigned int that was compiled into Zlib | ||
262 | /// </summary> | ||
263 | public int SizeOfUInt { get { return bitSize(_flags & 3); } } | ||
264 | |||
265 | /// <summary> | ||
266 | /// Gets the size of the unsigned long that was compiled into Zlib | ||
267 | /// </summary> | ||
268 | public int SizeOfULong { get { return bitSize((_flags >> 2) & 3); } } | ||
269 | |||
270 | /// <summary> | ||
271 | /// Gets the size of the pointers that were compiled into Zlib | ||
272 | /// </summary> | ||
273 | public int SizeOfPointer { get { return bitSize((_flags >> 4) & 3); } } | ||
274 | |||
275 | /// <summary> | ||
276 | /// Gets the size of the z_off_t type that was compiled into Zlib | ||
277 | /// </summary> | ||
278 | public int SizeOfOffset { get { return bitSize((_flags >> 6) & 3); } } | ||
279 | |||
280 | /// <summary> | ||
281 | /// Gets the version of ZLib as a string, e.g. "1.2.1" | ||
282 | /// </summary> | ||
283 | public static string Version { get { return zlibVersion(); } } | ||
284 | } | ||
285 | |||
286 | #endregion | ||
287 | |||
288 | } | ||
diff --git a/contrib/dotzlib/DotZLib/DotZLib.csproj b/contrib/dotzlib/DotZLib/DotZLib.csproj new file mode 100644 index 0000000..71eeb85 --- /dev/null +++ b/contrib/dotzlib/DotZLib/DotZLib.csproj | |||
@@ -0,0 +1,141 @@ | |||
1 | <VisualStudioProject> | ||
2 | <CSHARP | ||
3 | ProjectType = "Local" | ||
4 | ProductVersion = "7.10.3077" | ||
5 | SchemaVersion = "2.0" | ||
6 | ProjectGuid = "{BB1EE0B1-1808-46CB-B786-949D91117FC5}" | ||
7 | > | ||
8 | <Build> | ||
9 | <Settings | ||
10 | ApplicationIcon = "" | ||
11 | AssemblyKeyContainerName = "" | ||
12 | AssemblyName = "DotZLib" | ||
13 | AssemblyOriginatorKeyFile = "" | ||
14 | DefaultClientScript = "JScript" | ||
15 | DefaultHTMLPageLayout = "Grid" | ||
16 | DefaultTargetSchema = "IE50" | ||
17 | DelaySign = "false" | ||
18 | OutputType = "Library" | ||
19 | PreBuildEvent = "" | ||
20 | PostBuildEvent = "" | ||
21 | RootNamespace = "DotZLib" | ||
22 | RunPostBuildEvent = "OnBuildSuccess" | ||
23 | StartupObject = "" | ||
24 | > | ||
25 | <Config | ||
26 | Name = "Debug" | ||
27 | AllowUnsafeBlocks = "false" | ||
28 | BaseAddress = "285212672" | ||
29 | CheckForOverflowUnderflow = "false" | ||
30 | ConfigurationOverrideFile = "" | ||
31 | DefineConstants = "DEBUG;TRACE" | ||
32 | DocumentationFile = "docs\DotZLib.xml" | ||
33 | DebugSymbols = "true" | ||
34 | FileAlignment = "4096" | ||
35 | IncrementalBuild = "false" | ||
36 | NoStdLib = "false" | ||
37 | NoWarn = "1591" | ||
38 | Optimize = "false" | ||
39 | OutputPath = "bin\Debug\" | ||
40 | RegisterForComInterop = "false" | ||
41 | RemoveIntegerChecks = "false" | ||
42 | TreatWarningsAsErrors = "false" | ||
43 | WarningLevel = "4" | ||
44 | /> | ||
45 | <Config | ||
46 | Name = "Release" | ||
47 | AllowUnsafeBlocks = "false" | ||
48 | BaseAddress = "285212672" | ||
49 | CheckForOverflowUnderflow = "false" | ||
50 | ConfigurationOverrideFile = "" | ||
51 | DefineConstants = "TRACE" | ||
52 | DocumentationFile = "docs\DotZLib.xml" | ||
53 | DebugSymbols = "false" | ||
54 | FileAlignment = "4096" | ||
55 | IncrementalBuild = "false" | ||
56 | NoStdLib = "false" | ||
57 | NoWarn = "" | ||
58 | Optimize = "true" | ||
59 | OutputPath = "bin\Release\" | ||
60 | RegisterForComInterop = "false" | ||
61 | RemoveIntegerChecks = "false" | ||
62 | TreatWarningsAsErrors = "false" | ||
63 | WarningLevel = "4" | ||
64 | /> | ||
65 | </Settings> | ||
66 | <References> | ||
67 | <Reference | ||
68 | Name = "System" | ||
69 | AssemblyName = "System" | ||
70 | HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.dll" | ||
71 | /> | ||
72 | <Reference | ||
73 | Name = "System.Data" | ||
74 | AssemblyName = "System.Data" | ||
75 | HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" | ||
76 | /> | ||
77 | <Reference | ||
78 | Name = "System.XML" | ||
79 | AssemblyName = "System.Xml" | ||
80 | HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" | ||
81 | /> | ||
82 | <Reference | ||
83 | Name = "nunit.framework" | ||
84 | AssemblyName = "nunit.framework" | ||
85 | HintPath = "E:\apps\NUnit V2.1\\bin\nunit.framework.dll" | ||
86 | AssemblyFolderKey = "hklm\dn\nunit.framework" | ||
87 | /> | ||
88 | </References> | ||
89 | </Build> | ||
90 | <Files> | ||
91 | <Include> | ||
92 | <File | ||
93 | RelPath = "AssemblyInfo.cs" | ||
94 | SubType = "Code" | ||
95 | BuildAction = "Compile" | ||
96 | /> | ||
97 | <File | ||
98 | RelPath = "ChecksumImpl.cs" | ||
99 | SubType = "Code" | ||
100 | BuildAction = "Compile" | ||
101 | /> | ||
102 | <File | ||
103 | RelPath = "CircularBuffer.cs" | ||
104 | SubType = "Code" | ||
105 | BuildAction = "Compile" | ||
106 | /> | ||
107 | <File | ||
108 | RelPath = "CodecBase.cs" | ||
109 | SubType = "Code" | ||
110 | BuildAction = "Compile" | ||
111 | /> | ||
112 | <File | ||
113 | RelPath = "Deflater.cs" | ||
114 | SubType = "Code" | ||
115 | BuildAction = "Compile" | ||
116 | /> | ||
117 | <File | ||
118 | RelPath = "DotZLib.cs" | ||
119 | SubType = "Code" | ||
120 | BuildAction = "Compile" | ||
121 | /> | ||
122 | <File | ||
123 | RelPath = "GZipStream.cs" | ||
124 | SubType = "Code" | ||
125 | BuildAction = "Compile" | ||
126 | /> | ||
127 | <File | ||
128 | RelPath = "Inflater.cs" | ||
129 | SubType = "Code" | ||
130 | BuildAction = "Compile" | ||
131 | /> | ||
132 | <File | ||
133 | RelPath = "UnitTests.cs" | ||
134 | SubType = "Code" | ||
135 | BuildAction = "Compile" | ||
136 | /> | ||
137 | </Include> | ||
138 | </Files> | ||
139 | </CSHARP> | ||
140 | </VisualStudioProject> | ||
141 | |||
diff --git a/contrib/dotzlib/DotZLib/GZipStream.cs b/contrib/dotzlib/DotZLib/GZipStream.cs new file mode 100644 index 0000000..f861675 --- /dev/null +++ b/contrib/dotzlib/DotZLib/GZipStream.cs | |||
@@ -0,0 +1,301 @@ | |||
1 | // | ||
2 | // © Copyright Henrik Ravn 2004 | ||
3 | // | ||
4 | // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | ||
5 | // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
6 | // | ||
7 | |||
8 | using System; | ||
9 | using System.IO; | ||
10 | using System.Runtime.InteropServices; | ||
11 | |||
12 | namespace DotZLib | ||
13 | { | ||
14 | /// <summary> | ||
15 | /// Implements a compressed <see cref="Stream"/>, in GZip (.gz) format. | ||
16 | /// </summary> | ||
17 | public class GZipStream : Stream, IDisposable | ||
18 | { | ||
19 | #region Dll Imports | ||
20 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)] | ||
21 | private static extern IntPtr gzopen(string name, string mode); | ||
22 | |||
23 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
24 | private static extern int gzclose(IntPtr gzFile); | ||
25 | |||
26 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
27 | private static extern int gzwrite(IntPtr gzFile, int data, int length); | ||
28 | |||
29 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
30 | private static extern int gzread(IntPtr gzFile, int data, int length); | ||
31 | |||
32 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
33 | private static extern int gzgetc(IntPtr gzFile); | ||
34 | |||
35 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
36 | private static extern int gzputc(IntPtr gzFile, int c); | ||
37 | |||
38 | #endregion | ||
39 | |||
40 | #region Private data | ||
41 | private IntPtr _gzFile; | ||
42 | private bool _isDisposed = false; | ||
43 | private bool _isWriting; | ||
44 | #endregion | ||
45 | |||
46 | #region Constructors | ||
47 | /// <summary> | ||
48 | /// Creates a new file as a writeable GZipStream | ||
49 | /// </summary> | ||
50 | /// <param name="fileName">The name of the compressed file to create</param> | ||
51 | /// <param name="level">The compression level to use when adding data</param> | ||
52 | /// <exception cref="ZLibException">If an error occurred in the internal zlib function</exception> | ||
53 | public GZipStream(string fileName, CompressLevel level) | ||
54 | { | ||
55 | _isWriting = true; | ||
56 | _gzFile = gzopen(fileName, String.Format("wb{0}", (int)level)); | ||
57 | if (_gzFile == IntPtr.Zero) | ||
58 | throw new ZLibException(-1, "Could not open " + fileName); | ||
59 | } | ||
60 | |||
61 | /// <summary> | ||
62 | /// Opens an existing file as a readable GZipStream | ||
63 | /// </summary> | ||
64 | /// <param name="fileName">The name of the file to open</param> | ||
65 | /// <exception cref="ZLibException">If an error occurred in the internal zlib function</exception> | ||
66 | public GZipStream(string fileName) | ||
67 | { | ||
68 | _isWriting = false; | ||
69 | _gzFile = gzopen(fileName, "rb"); | ||
70 | if (_gzFile == IntPtr.Zero) | ||
71 | throw new ZLibException(-1, "Could not open " + fileName); | ||
72 | |||
73 | } | ||
74 | #endregion | ||
75 | |||
76 | #region Access properties | ||
77 | /// <summary> | ||
78 | /// Returns true of this stream can be read from, false otherwise | ||
79 | /// </summary> | ||
80 | public override bool CanRead | ||
81 | { | ||
82 | get | ||
83 | { | ||
84 | return !_isWriting; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | |||
89 | /// <summary> | ||
90 | /// Returns false. | ||
91 | /// </summary> | ||
92 | public override bool CanSeek | ||
93 | { | ||
94 | get | ||
95 | { | ||
96 | return false; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | /// <summary> | ||
101 | /// Returns true if this tsream is writeable, false otherwise | ||
102 | /// </summary> | ||
103 | public override bool CanWrite | ||
104 | { | ||
105 | get | ||
106 | { | ||
107 | return _isWriting; | ||
108 | } | ||
109 | } | ||
110 | #endregion | ||
111 | |||
112 | #region Destructor & IDispose stuff | ||
113 | |||
114 | /// <summary> | ||
115 | /// Destroys this instance | ||
116 | /// </summary> | ||
117 | ~GZipStream() | ||
118 | { | ||
119 | cleanUp(false); | ||
120 | } | ||
121 | |||
122 | /// <summary> | ||
123 | /// Closes the external file handle | ||
124 | /// </summary> | ||
125 | public void Dispose() | ||
126 | { | ||
127 | cleanUp(true); | ||
128 | } | ||
129 | |||
130 | // Does the actual closing of the file handle. | ||
131 | private void cleanUp(bool isDisposing) | ||
132 | { | ||
133 | if (!_isDisposed) | ||
134 | { | ||
135 | gzclose(_gzFile); | ||
136 | _isDisposed = true; | ||
137 | } | ||
138 | } | ||
139 | #endregion | ||
140 | |||
141 | #region Basic reading and writing | ||
142 | /// <summary> | ||
143 | /// Attempts to read a number of bytes from the stream. | ||
144 | /// </summary> | ||
145 | /// <param name="buffer">The destination data buffer</param> | ||
146 | /// <param name="offset">The index of the first destination byte in <c>buffer</c></param> | ||
147 | /// <param name="count">The number of bytes requested</param> | ||
148 | /// <returns>The number of bytes read</returns> | ||
149 | /// <exception cref="ArgumentNullException">If <c>buffer</c> is null</exception> | ||
150 | /// <exception cref="ArgumentOutOfRangeException">If <c>count</c> or <c>offset</c> are negative</exception> | ||
151 | /// <exception cref="ArgumentException">If <c>offset</c> + <c>count</c> is > buffer.Length</exception> | ||
152 | /// <exception cref="NotSupportedException">If this stream is not readable.</exception> | ||
153 | /// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception> | ||
154 | public override int Read(byte[] buffer, int offset, int count) | ||
155 | { | ||
156 | if (!CanRead) throw new NotSupportedException(); | ||
157 | if (buffer == null) throw new ArgumentNullException(); | ||
158 | if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); | ||
159 | if ((offset+count) > buffer.Length) throw new ArgumentException(); | ||
160 | if (_isDisposed) throw new ObjectDisposedException("GZipStream"); | ||
161 | |||
162 | GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned); | ||
163 | int result; | ||
164 | try | ||
165 | { | ||
166 | result = gzread(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count); | ||
167 | if (result < 0) | ||
168 | throw new IOException(); | ||
169 | } | ||
170 | finally | ||
171 | { | ||
172 | h.Free(); | ||
173 | } | ||
174 | return result; | ||
175 | } | ||
176 | |||
177 | /// <summary> | ||
178 | /// Attempts to read a single byte from the stream. | ||
179 | /// </summary> | ||
180 | /// <returns>The byte that was read, or -1 in case of error or End-Of-File</returns> | ||
181 | public override int ReadByte() | ||
182 | { | ||
183 | if (!CanRead) throw new NotSupportedException(); | ||
184 | if (_isDisposed) throw new ObjectDisposedException("GZipStream"); | ||
185 | return gzgetc(_gzFile); | ||
186 | } | ||
187 | |||
188 | /// <summary> | ||
189 | /// Writes a number of bytes to the stream | ||
190 | /// </summary> | ||
191 | /// <param name="buffer"></param> | ||
192 | /// <param name="offset"></param> | ||
193 | /// <param name="count"></param> | ||
194 | /// <exception cref="ArgumentNullException">If <c>buffer</c> is null</exception> | ||
195 | /// <exception cref="ArgumentOutOfRangeException">If <c>count</c> or <c>offset</c> are negative</exception> | ||
196 | /// <exception cref="ArgumentException">If <c>offset</c> + <c>count</c> is > buffer.Length</exception> | ||
197 | /// <exception cref="NotSupportedException">If this stream is not writeable.</exception> | ||
198 | /// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception> | ||
199 | public override void Write(byte[] buffer, int offset, int count) | ||
200 | { | ||
201 | if (!CanWrite) throw new NotSupportedException(); | ||
202 | if (buffer == null) throw new ArgumentNullException(); | ||
203 | if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); | ||
204 | if ((offset+count) > buffer.Length) throw new ArgumentException(); | ||
205 | if (_isDisposed) throw new ObjectDisposedException("GZipStream"); | ||
206 | |||
207 | GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned); | ||
208 | try | ||
209 | { | ||
210 | int result = gzwrite(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count); | ||
211 | if (result < 0) | ||
212 | throw new IOException(); | ||
213 | } | ||
214 | finally | ||
215 | { | ||
216 | h.Free(); | ||
217 | } | ||
218 | } | ||
219 | |||
220 | /// <summary> | ||
221 | /// Writes a single byte to the stream | ||
222 | /// </summary> | ||
223 | /// <param name="value">The byte to add to the stream.</param> | ||
224 | /// <exception cref="NotSupportedException">If this stream is not writeable.</exception> | ||
225 | /// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception> | ||
226 | public override void WriteByte(byte value) | ||
227 | { | ||
228 | if (!CanWrite) throw new NotSupportedException(); | ||
229 | if (_isDisposed) throw new ObjectDisposedException("GZipStream"); | ||
230 | |||
231 | int result = gzputc(_gzFile, (int)value); | ||
232 | if (result < 0) | ||
233 | throw new IOException(); | ||
234 | } | ||
235 | #endregion | ||
236 | |||
237 | #region Position & length stuff | ||
238 | /// <summary> | ||
239 | /// Not supported. | ||
240 | /// </summary> | ||
241 | /// <param name="value"></param> | ||
242 | /// <exception cref="NotSupportedException">Always thrown</exception> | ||
243 | public override void SetLength(long value) | ||
244 | { | ||
245 | throw new NotSupportedException(); | ||
246 | } | ||
247 | |||
248 | /// <summary> | ||
249 | /// Not suppported. | ||
250 | /// </summary> | ||
251 | /// <param name="offset"></param> | ||
252 | /// <param name="origin"></param> | ||
253 | /// <returns></returns> | ||
254 | /// <exception cref="NotSupportedException">Always thrown</exception> | ||
255 | public override long Seek(long offset, SeekOrigin origin) | ||
256 | { | ||
257 | throw new NotSupportedException(); | ||
258 | } | ||
259 | |||
260 | /// <summary> | ||
261 | /// Flushes the <c>GZipStream</c>. | ||
262 | /// </summary> | ||
263 | /// <remarks>In this implementation, this method does nothing. This is because excessive | ||
264 | /// flushing may degrade the achievable compression rates.</remarks> | ||
265 | public override void Flush() | ||
266 | { | ||
267 | // left empty on purpose | ||
268 | } | ||
269 | |||
270 | /// <summary> | ||
271 | /// Gets/sets the current position in the <c>GZipStream</c>. Not suppported. | ||
272 | /// </summary> | ||
273 | /// <remarks>In this implementation this property is not supported</remarks> | ||
274 | /// <exception cref="NotSupportedException">Always thrown</exception> | ||
275 | public override long Position | ||
276 | { | ||
277 | get | ||
278 | { | ||
279 | throw new NotSupportedException(); | ||
280 | } | ||
281 | set | ||
282 | { | ||
283 | throw new NotSupportedException(); | ||
284 | } | ||
285 | } | ||
286 | |||
287 | /// <summary> | ||
288 | /// Gets the size of the stream. Not suppported. | ||
289 | /// </summary> | ||
290 | /// <remarks>In this implementation this property is not supported</remarks> | ||
291 | /// <exception cref="NotSupportedException">Always thrown</exception> | ||
292 | public override long Length | ||
293 | { | ||
294 | get | ||
295 | { | ||
296 | throw new NotSupportedException(); | ||
297 | } | ||
298 | } | ||
299 | #endregion | ||
300 | } | ||
301 | } | ||
diff --git a/contrib/dotzlib/DotZLib/Inflater.cs b/contrib/dotzlib/DotZLib/Inflater.cs new file mode 100644 index 0000000..4e60cda --- /dev/null +++ b/contrib/dotzlib/DotZLib/Inflater.cs | |||
@@ -0,0 +1,105 @@ | |||
1 | // | ||
2 | // © Copyright Henrik Ravn 2004 | ||
3 | // | ||
4 | // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | ||
5 | // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
6 | // | ||
7 | |||
8 | using System; | ||
9 | using System.Diagnostics; | ||
10 | using System.Runtime.InteropServices; | ||
11 | |||
12 | namespace DotZLib | ||
13 | { | ||
14 | |||
15 | /// <summary> | ||
16 | /// Implements a data decompressor, using the inflate algorithm in the ZLib dll | ||
17 | /// </summary> | ||
18 | public class Inflater : CodecBase | ||
19 | { | ||
20 | #region Dll imports | ||
21 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)] | ||
22 | private static extern int inflateInit_(ref ZStream sz, string vs, int size); | ||
23 | |||
24 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
25 | private static extern int inflate(ref ZStream sz, int flush); | ||
26 | |||
27 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
28 | private static extern int inflateReset(ref ZStream sz); | ||
29 | |||
30 | [DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)] | ||
31 | private static extern int inflateEnd(ref ZStream sz); | ||
32 | #endregion | ||
33 | |||
34 | /// <summary> | ||
35 | /// Constructs an new instance of the <c>Inflater</c> | ||
36 | /// </summary> | ||
37 | public Inflater() : base() | ||
38 | { | ||
39 | int retval = inflateInit_(ref _ztream, Info.Version, Marshal.SizeOf(_ztream)); | ||
40 | if (retval != 0) | ||
41 | throw new ZLibException(retval, "Could not initialize inflater"); | ||
42 | |||
43 | resetOutput(); | ||
44 | } | ||
45 | |||
46 | |||
47 | /// <summary> | ||
48 | /// Adds more data to the codec to be processed. | ||
49 | /// </summary> | ||
50 | /// <param name="data">Byte array containing the data to be added to the codec</param> | ||
51 | /// <param name="offset">The index of the first byte to add from <c>data</c></param> | ||
52 | /// <param name="count">The number of bytes to add</param> | ||
53 | /// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks> | ||
54 | public override void Add(byte[] data, int offset, int count) | ||
55 | { | ||
56 | if (data == null) throw new ArgumentNullException(); | ||
57 | if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException(); | ||
58 | if ((offset+count) > data.Length) throw new ArgumentException(); | ||
59 | |||
60 | int total = count; | ||
61 | int inputIndex = offset; | ||
62 | int err = 0; | ||
63 | |||
64 | while (err >= 0 && inputIndex < total) | ||
65 | { | ||
66 | copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize)); | ||
67 | err = inflate(ref _ztream, (int)FlushTypes.None); | ||
68 | if (err == 0) | ||
69 | while (_ztream.avail_out == 0) | ||
70 | { | ||
71 | OnDataAvailable(); | ||
72 | err = inflate(ref _ztream, (int)FlushTypes.None); | ||
73 | } | ||
74 | |||
75 | inputIndex += (int)_ztream.total_in; | ||
76 | } | ||
77 | setChecksum( _ztream.adler ); | ||
78 | } | ||
79 | |||
80 | |||
81 | /// <summary> | ||
82 | /// Finishes up any pending data that needs to be processed and handled. | ||
83 | /// </summary> | ||
84 | public override void Finish() | ||
85 | { | ||
86 | int err; | ||
87 | do | ||
88 | { | ||
89 | err = inflate(ref _ztream, (int)FlushTypes.Finish); | ||
90 | OnDataAvailable(); | ||
91 | } | ||
92 | while (err == 0); | ||
93 | setChecksum( _ztream.adler ); | ||
94 | inflateReset(ref _ztream); | ||
95 | resetOutput(); | ||
96 | } | ||
97 | |||
98 | /// <summary> | ||
99 | /// Closes the internal zlib inflate stream | ||
100 | /// </summary> | ||
101 | protected override void CleanUp() { inflateEnd(ref _ztream); } | ||
102 | |||
103 | |||
104 | } | ||
105 | } | ||
diff --git a/contrib/dotzlib/DotZLib/UnitTests.cs b/contrib/dotzlib/DotZLib/UnitTests.cs new file mode 100644 index 0000000..2f374b6 --- /dev/null +++ b/contrib/dotzlib/DotZLib/UnitTests.cs | |||
@@ -0,0 +1,274 @@ | |||
1 | // | ||
2 | // © Copyright Henrik Ravn 2004 | ||
3 | // | ||
4 | // Use, modification and distribution are subject to the Boost Software License, Version 1.0. | ||
5 | // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
6 | // | ||
7 | |||
8 | using System; | ||
9 | using System.Collections; | ||
10 | using System.IO; | ||
11 | |||
12 | // uncomment the define below to include unit tests | ||
13 | //#define nunit | ||
14 | #if nunit | ||
15 | using NUnit.Framework; | ||
16 | |||
17 | // Unit tests for the DotZLib class library | ||
18 | // ---------------------------------------- | ||
19 | // | ||
20 | // Use this with NUnit 2 from http://www.nunit.org | ||
21 | // | ||
22 | |||
23 | namespace DotZLibTests | ||
24 | { | ||
25 | using DotZLib; | ||
26 | |||
27 | // helper methods | ||
28 | internal class Utils | ||
29 | { | ||
30 | public static bool byteArrEqual( byte[] lhs, byte[] rhs ) | ||
31 | { | ||
32 | if (lhs.Length != rhs.Length) | ||
33 | return false; | ||
34 | for (int i = lhs.Length-1; i >= 0; --i) | ||
35 | if (lhs[i] != rhs[i]) | ||
36 | return false; | ||
37 | return true; | ||
38 | } | ||
39 | |||
40 | } | ||
41 | |||
42 | |||
43 | [TestFixture] | ||
44 | public class CircBufferTests | ||
45 | { | ||
46 | #region Circular buffer tests | ||
47 | [Test] | ||
48 | public void SinglePutGet() | ||
49 | { | ||
50 | CircularBuffer buf = new CircularBuffer(10); | ||
51 | Assert.AreEqual( 0, buf.Size ); | ||
52 | Assert.AreEqual( -1, buf.Get() ); | ||
53 | |||
54 | Assert.IsTrue(buf.Put( 1 )); | ||
55 | Assert.AreEqual( 1, buf.Size ); | ||
56 | Assert.AreEqual( 1, buf.Get() ); | ||
57 | Assert.AreEqual( 0, buf.Size ); | ||
58 | Assert.AreEqual( -1, buf.Get() ); | ||
59 | } | ||
60 | |||
61 | [Test] | ||
62 | public void BlockPutGet() | ||
63 | { | ||
64 | CircularBuffer buf = new CircularBuffer(10); | ||
65 | byte[] arr = {1,2,3,4,5,6,7,8,9,10}; | ||
66 | Assert.AreEqual( 10, buf.Put(arr,0,10) ); | ||
67 | Assert.AreEqual( 10, buf.Size ); | ||
68 | Assert.IsFalse( buf.Put(11) ); | ||
69 | Assert.AreEqual( 1, buf.Get() ); | ||
70 | Assert.IsTrue( buf.Put(11) ); | ||
71 | |||
72 | byte[] arr2 = (byte[])arr.Clone(); | ||
73 | Assert.AreEqual( 9, buf.Get(arr2,1,9) ); | ||
74 | Assert.IsTrue( Utils.byteArrEqual(arr,arr2) ); | ||
75 | } | ||
76 | |||
77 | #endregion | ||
78 | } | ||
79 | |||
80 | [TestFixture] | ||
81 | public class ChecksumTests | ||
82 | { | ||
83 | #region CRC32 Tests | ||
84 | [Test] | ||
85 | public void CRC32_Null() | ||
86 | { | ||
87 | CRC32Checksum crc32 = new CRC32Checksum(); | ||
88 | Assert.AreEqual( 0, crc32.Value ); | ||
89 | |||
90 | crc32 = new CRC32Checksum(1); | ||
91 | Assert.AreEqual( 1, crc32.Value ); | ||
92 | |||
93 | crc32 = new CRC32Checksum(556); | ||
94 | Assert.AreEqual( 556, crc32.Value ); | ||
95 | } | ||
96 | |||
97 | [Test] | ||
98 | public void CRC32_Data() | ||
99 | { | ||
100 | CRC32Checksum crc32 = new CRC32Checksum(); | ||
101 | byte[] data = { 1,2,3,4,5,6,7 }; | ||
102 | crc32.Update(data); | ||
103 | Assert.AreEqual( 0x70e46888, crc32.Value ); | ||
104 | |||
105 | crc32 = new CRC32Checksum(); | ||
106 | crc32.Update("penguin"); | ||
107 | Assert.AreEqual( 0x0e5c1a120, crc32.Value ); | ||
108 | |||
109 | crc32 = new CRC32Checksum(1); | ||
110 | crc32.Update("penguin"); | ||
111 | Assert.AreEqual(0x43b6aa94, crc32.Value); | ||
112 | |||
113 | } | ||
114 | #endregion | ||
115 | |||
116 | #region Adler tests | ||
117 | |||
118 | [Test] | ||
119 | public void Adler_Null() | ||
120 | { | ||
121 | AdlerChecksum adler = new AdlerChecksum(); | ||
122 | Assert.AreEqual(0, adler.Value); | ||
123 | |||
124 | adler = new AdlerChecksum(1); | ||
125 | Assert.AreEqual( 1, adler.Value ); | ||
126 | |||
127 | adler = new AdlerChecksum(556); | ||
128 | Assert.AreEqual( 556, adler.Value ); | ||
129 | } | ||
130 | |||
131 | [Test] | ||
132 | public void Adler_Data() | ||
133 | { | ||
134 | AdlerChecksum adler = new AdlerChecksum(1); | ||
135 | byte[] data = { 1,2,3,4,5,6,7 }; | ||
136 | adler.Update(data); | ||
137 | Assert.AreEqual( 0x5b001d, adler.Value ); | ||
138 | |||
139 | adler = new AdlerChecksum(); | ||
140 | adler.Update("penguin"); | ||
141 | Assert.AreEqual(0x0bcf02f6, adler.Value ); | ||
142 | |||
143 | adler = new AdlerChecksum(1); | ||
144 | adler.Update("penguin"); | ||
145 | Assert.AreEqual(0x0bd602f7, adler.Value); | ||
146 | |||
147 | } | ||
148 | #endregion | ||
149 | } | ||
150 | |||
151 | [TestFixture] | ||
152 | public class InfoTests | ||
153 | { | ||
154 | #region Info tests | ||
155 | [Test] | ||
156 | public void Info_Version() | ||
157 | { | ||
158 | Info info = new Info(); | ||
159 | Assert.AreEqual("1.2.2", Info.Version); | ||
160 | Assert.AreEqual(32, info.SizeOfUInt); | ||
161 | Assert.AreEqual(32, info.SizeOfULong); | ||
162 | Assert.AreEqual(32, info.SizeOfPointer); | ||
163 | Assert.AreEqual(32, info.SizeOfOffset); | ||
164 | } | ||
165 | #endregion | ||
166 | } | ||
167 | |||
168 | [TestFixture] | ||
169 | public class DeflateInflateTests | ||
170 | { | ||
171 | #region Deflate tests | ||
172 | [Test] | ||
173 | public void Deflate_Init() | ||
174 | { | ||
175 | using (Deflater def = new Deflater(CompressLevel.Default)) | ||
176 | { | ||
177 | } | ||
178 | } | ||
179 | |||
180 | private ArrayList compressedData = new ArrayList(); | ||
181 | private uint adler1; | ||
182 | |||
183 | private ArrayList uncompressedData = new ArrayList(); | ||
184 | private uint adler2; | ||
185 | |||
186 | public void CDataAvail(byte[] data, int startIndex, int count) | ||
187 | { | ||
188 | for (int i = 0; i < count; ++i) | ||
189 | compressedData.Add(data[i+startIndex]); | ||
190 | } | ||
191 | |||
192 | [Test] | ||
193 | public void Deflate_Compress() | ||
194 | { | ||
195 | compressedData.Clear(); | ||
196 | |||
197 | byte[] testData = new byte[35000]; | ||
198 | for (int i = 0; i < testData.Length; ++i) | ||
199 | testData[i] = 5; | ||
200 | |||
201 | using (Deflater def = new Deflater((CompressLevel)5)) | ||
202 | { | ||
203 | def.DataAvailable += new DataAvailableHandler(CDataAvail); | ||
204 | def.Add(testData); | ||
205 | def.Finish(); | ||
206 | adler1 = def.Checksum; | ||
207 | } | ||
208 | } | ||
209 | #endregion | ||
210 | |||
211 | #region Inflate tests | ||
212 | [Test] | ||
213 | public void Inflate_Init() | ||
214 | { | ||
215 | using (Inflater inf = new Inflater()) | ||
216 | { | ||
217 | } | ||
218 | } | ||
219 | |||
220 | private void DDataAvail(byte[] data, int startIndex, int count) | ||
221 | { | ||
222 | for (int i = 0; i < count; ++i) | ||
223 | uncompressedData.Add(data[i+startIndex]); | ||
224 | } | ||
225 | |||
226 | [Test] | ||
227 | public void Inflate_Expand() | ||
228 | { | ||
229 | uncompressedData.Clear(); | ||
230 | |||
231 | using (Inflater inf = new Inflater()) | ||
232 | { | ||
233 | inf.DataAvailable += new DataAvailableHandler(DDataAvail); | ||
234 | inf.Add((byte[])compressedData.ToArray(typeof(byte))); | ||
235 | inf.Finish(); | ||
236 | adler2 = inf.Checksum; | ||
237 | } | ||
238 | Assert.AreEqual( adler1, adler2 ); | ||
239 | } | ||
240 | #endregion | ||
241 | } | ||
242 | |||
243 | [TestFixture] | ||
244 | public class GZipStreamTests | ||
245 | { | ||
246 | #region GZipStream test | ||
247 | [Test] | ||
248 | public void GZipStream_WriteRead() | ||
249 | { | ||
250 | using (GZipStream gzOut = new GZipStream("gzstream.gz", CompressLevel.Best)) | ||
251 | { | ||
252 | BinaryWriter writer = new BinaryWriter(gzOut); | ||
253 | writer.Write("hi there"); | ||
254 | writer.Write(Math.PI); | ||
255 | writer.Write(42); | ||
256 | } | ||
257 | |||
258 | using (GZipStream gzIn = new GZipStream("gzstream.gz")) | ||
259 | { | ||
260 | BinaryReader reader = new BinaryReader(gzIn); | ||
261 | string s = reader.ReadString(); | ||
262 | Assert.AreEqual("hi there",s); | ||
263 | double d = reader.ReadDouble(); | ||
264 | Assert.AreEqual(Math.PI, d); | ||
265 | int i = reader.ReadInt32(); | ||
266 | Assert.AreEqual(42,i); | ||
267 | } | ||
268 | |||
269 | } | ||
270 | #endregion | ||
271 | } | ||
272 | } | ||
273 | |||
274 | #endif \ No newline at end of file | ||
diff --git a/contrib/dotzlib/LICENSE_1_0.txt b/contrib/dotzlib/LICENSE_1_0.txt new file mode 100644 index 0000000..30aac2c --- /dev/null +++ b/contrib/dotzlib/LICENSE_1_0.txt | |||
@@ -0,0 +1,23 @@ | |||
1 | Boost Software License - Version 1.0 - August 17th, 2003 | ||
2 | |||
3 | Permission is hereby granted, free of charge, to any person or organization | ||
4 | obtaining a copy of the software and accompanying documentation covered by | ||
5 | this license (the "Software") to use, reproduce, display, distribute, | ||
6 | execute, and transmit the Software, and to prepare derivative works of the | ||
7 | Software, and to permit third-parties to whom the Software is furnished to | ||
8 | do so, all subject to the following: | ||
9 | |||
10 | The copyright notices in the Software and this entire statement, including | ||
11 | the above license grant, this restriction and the following disclaimer, | ||
12 | must be included in all copies of the Software, in whole or in part, and | ||
13 | all derivative works of the Software, unless such copies or derivative | ||
14 | works are solely in the form of machine-executable object code generated by | ||
15 | a source language processor. | ||
16 | |||
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | ||
20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | ||
21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | ||
22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
23 | DEALINGS IN THE SOFTWARE. \ No newline at end of file | ||
diff --git a/contrib/dotzlib/readme.txt b/contrib/dotzlib/readme.txt new file mode 100644 index 0000000..210f4b0 --- /dev/null +++ b/contrib/dotzlib/readme.txt | |||
@@ -0,0 +1,58 @@ | |||
1 | This directory contains a .Net wrapper class library for the ZLib1.dll | ||
2 | |||
3 | The wrapper includes support for inflating/deflating memory buffers, | ||
4 | .Net streaming wrappers for the gz streams part of zlib, and wrappers | ||
5 | for the checksum parts of zlib. See DotZLib/UnitTests.cs for examples. | ||
6 | |||
7 | Directory structure: | ||
8 | -------------------- | ||
9 | |||
10 | LICENSE_1_0.txt - License file. | ||
11 | readme.txt - This file. | ||
12 | DotZLib.chm - Class library documentation | ||
13 | DotZLib.build - NAnt build file | ||
14 | DotZLib.sln - Microsoft Visual Studio 2003 solution file | ||
15 | |||
16 | DotZLib\*.cs - Source files for the class library | ||
17 | |||
18 | Unit tests: | ||
19 | ----------- | ||
20 | The file DotZLib/UnitTests.cs contains unit tests for use with NUnit 2.1 or higher. | ||
21 | To include unit tests in the build, define nunit before building. | ||
22 | |||
23 | |||
24 | Build instructions: | ||
25 | ------------------- | ||
26 | |||
27 | 1. Using Visual Studio.Net 2003: | ||
28 | Open DotZLib.sln in VS.Net and build from there. Output file (DotZLib.dll) | ||
29 | will be found ./DotZLib/bin/release or ./DotZLib/bin/debug, depending on | ||
30 | you are building the release or debug version of the library. Check | ||
31 | DotZLib/UnitTests.cs for instructions on how to include unit tests in the | ||
32 | build. | ||
33 | |||
34 | 2. Using NAnt: | ||
35 | Open a command prompt with access to the build environment and run nant | ||
36 | in the same directory as the DotZLib.build file. | ||
37 | You can define 2 properties on the nant command-line to control the build: | ||
38 | debug={true|false} to toggle between release/debug builds (default=true). | ||
39 | nunit={true|false} to include or esclude unit tests (default=true). | ||
40 | Also the target clean will remove binaries. | ||
41 | Output file (DotZLib.dll) will be found in either ./DotZLib/bin/release | ||
42 | or ./DotZLib/bin/debug, depending on whether you are building the release | ||
43 | or debug version of the library. | ||
44 | |||
45 | Examples: | ||
46 | nant -D:debug=false -D:nunit=false | ||
47 | will build a release mode version of the library without unit tests. | ||
48 | nant | ||
49 | will build a debug version of the library with unit tests | ||
50 | nant clean | ||
51 | will remove all previously built files. | ||
52 | |||
53 | |||
54 | --------------------------------- | ||
55 | Copyright (c) Henrik Ravn 2004 | ||
56 | |||
57 | Use, modification and distribution are subject to the Boost Software License, Version 1.0. | ||
58 | (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
diff --git a/contrib/gzappend/gzappend.c b/contrib/gzappend/gzappend.c index f2e9e4f..e9e878e 100644 --- a/contrib/gzappend/gzappend.c +++ b/contrib/gzappend/gzappend.c | |||
@@ -48,10 +48,10 @@ | |||
48 | unfriendly behavior that if gzappend fails, the gzip file is corrupted. | 48 | unfriendly behavior that if gzappend fails, the gzip file is corrupted. |
49 | 49 | ||
50 | This program was written to illustrate the use of the new Z_BLOCK option of | 50 | This program was written to illustrate the use of the new Z_BLOCK option of |
51 | zlib 1.2.1's inflate() function. This option returns from inflate() at each | 51 | zlib 1.2.x's inflate() function. This option returns from inflate() at each |
52 | block boundary to facilitate locating and modifying the last block bit at | 52 | block boundary to facilitate locating and modifying the last block bit at |
53 | the start of the final deflate block. Also whether using Z_BLOCK or not, | 53 | the start of the final deflate block. Also whether using Z_BLOCK or not, |
54 | another required feature of zlib 1.2.1 is that inflate() now provides the | 54 | another required feature of zlib 1.2.x is that inflate() now provides the |
55 | number of unusued bits in the last input byte used. gzappend will not work | 55 | number of unusued bits in the last input byte used. gzappend will not work |
56 | with versions of zlib earlier than 1.2.1. | 56 | with versions of zlib earlier than 1.2.1. |
57 | 57 | ||
diff --git a/contrib/infback9/infback9.c b/contrib/infback9/infback9.c index 103d901..f5ddde6 100644 --- a/contrib/infback9/infback9.c +++ b/contrib/infback9/infback9.c | |||
@@ -430,8 +430,8 @@ void FAR *out_desc; | |||
430 | } | 430 | } |
431 | } | 431 | } |
432 | 432 | ||
433 | /* handle error breaks in while */ | 433 | /* handle error breaks in while */ |
434 | if (mode == BAD) break; | 434 | if (mode == BAD) break; |
435 | 435 | ||
436 | /* build code tables */ | 436 | /* build code tables */ |
437 | state->next = state->codes; | 437 | state->next = state->codes; |
diff --git a/contrib/infback9/inftree9.c b/contrib/infback9/inftree9.c index 5fd5b4a..9b48bc5 100644 --- a/contrib/infback9/inftree9.c +++ b/contrib/infback9/inftree9.c | |||
@@ -9,7 +9,7 @@ | |||
9 | #define MAXBITS 15 | 9 | #define MAXBITS 15 |
10 | 10 | ||
11 | const char inflate9_copyright[] = | 11 | const char inflate9_copyright[] = |
12 | " inflate9 1.2.1.2 Copyright 1995-2004 Mark Adler "; | 12 | " inflate9 1.2.2 Copyright 1995-2004 Mark Adler "; |
13 | /* | 13 | /* |
14 | If you use the zlib library in a product, an acknowledgment is welcome | 14 | If you use the zlib library in a product, an acknowledgment is welcome |
15 | in the documentation of your product. If for some reason you cannot | 15 | in the documentation of your product. If for some reason you cannot |
@@ -64,7 +64,7 @@ unsigned short FAR *work; | |||
64 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ | 64 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ |
65 | 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, | 65 | 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, |
66 | 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, | 66 | 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, |
67 | 133, 133, 133, 133, 144, 77, 194}; | 67 | 133, 133, 133, 133, 144, 199, 198}; |
68 | static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ | 68 | static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ |
69 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, | 69 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, |
70 | 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, | 70 | 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, |
diff --git a/contrib/minizip/ioapi.c b/contrib/minizip/ioapi.c index 6ddfd36..c9e69f2 100644 --- a/contrib/minizip/ioapi.c +++ b/contrib/minizip/ioapi.c | |||
@@ -94,7 +94,7 @@ uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) | |||
94 | uLong size; | 94 | uLong size; |
95 | { | 95 | { |
96 | uLong ret; | 96 | uLong ret; |
97 | ret = fread(buf, 1, (size_t)size, (FILE *)stream); | 97 | ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); |
98 | return ret; | 98 | return ret; |
99 | } | 99 | } |
100 | 100 | ||
@@ -106,7 +106,7 @@ uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) | |||
106 | uLong size; | 106 | uLong size; |
107 | { | 107 | { |
108 | uLong ret; | 108 | uLong ret; |
109 | ret = fwrite(buf, 1, (size_t)size, (FILE *)stream); | 109 | ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); |
110 | return ret; | 110 | return ret; |
111 | } | 111 | } |
112 | 112 | ||
diff --git a/contrib/minizip/miniunz.c b/contrib/minizip/miniunz.c index 11b7260..a6b06a2 100644 --- a/contrib/minizip/miniunz.c +++ b/contrib/minizip/miniunz.c | |||
@@ -317,7 +317,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password) | |||
317 | 317 | ||
318 | printf("The file %s exists. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename); | 318 | printf("The file %s exists. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename); |
319 | ret = scanf("%1s",answer); | 319 | ret = scanf("%1s",answer); |
320 | if (ret != 1) | 320 | if (ret != 1) |
321 | { | 321 | { |
322 | exit(EXIT_FAILURE); | 322 | exit(EXIT_FAILURE); |
323 | } | 323 | } |
@@ -567,7 +567,7 @@ int main(argc,argv) | |||
567 | return do_list(uf); | 567 | return do_list(uf); |
568 | else if (opt_do_extract==1) | 568 | else if (opt_do_extract==1) |
569 | { | 569 | { |
570 | if (opt_extractdir && chdir(dirname)) | 570 | if (opt_extractdir && chdir(dirname)) |
571 | { | 571 | { |
572 | printf("Error changing into %s, aborting\n", dirname); | 572 | printf("Error changing into %s, aborting\n", dirname); |
573 | exit(-1); | 573 | exit(-1); |
diff --git a/contrib/minizip/mztools.c b/contrib/minizip/mztools.c index 363ee13..c1266bc 100644 --- a/contrib/minizip/mztools.c +++ b/contrib/minizip/mztools.c | |||
@@ -62,7 +62,7 @@ uLong* bytesRecovered; | |||
62 | unsigned int fnsize = READ_16(header + 26); /* file name length */ | 62 | unsigned int fnsize = READ_16(header + 26); /* file name length */ |
63 | unsigned int extsize = READ_16(header + 28); /* extra field length */ | 63 | unsigned int extsize = READ_16(header + 28); /* extra field length */ |
64 | filename[0] = extra[0] = '\0'; | 64 | filename[0] = extra[0] = '\0'; |
65 | 65 | ||
66 | /* Header */ | 66 | /* Header */ |
67 | if (fwrite(header, 1, 30, fpOut) == 30) { | 67 | if (fwrite(header, 1, 30, fpOut) == 30) { |
68 | offset += 30; | 68 | offset += 30; |
@@ -70,7 +70,7 @@ uLong* bytesRecovered; | |||
70 | err = Z_ERRNO; | 70 | err = Z_ERRNO; |
71 | break; | 71 | break; |
72 | } | 72 | } |
73 | 73 | ||
74 | /* Filename */ | 74 | /* Filename */ |
75 | if (fnsize > 0) { | 75 | if (fnsize > 0) { |
76 | if (fread(filename, 1, fnsize, fpZip) == fnsize) { | 76 | if (fread(filename, 1, fnsize, fpZip) == fnsize) { |
@@ -103,7 +103,7 @@ uLong* bytesRecovered; | |||
103 | break; | 103 | break; |
104 | } | 104 | } |
105 | } | 105 | } |
106 | 106 | ||
107 | /* Data */ | 107 | /* Data */ |
108 | { | 108 | { |
109 | int dataSize = cpsize; | 109 | int dataSize = cpsize; |
@@ -133,7 +133,7 @@ uLong* bytesRecovered; | |||
133 | } | 133 | } |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | /* Central directory entry */ | 137 | /* Central directory entry */ |
138 | { | 138 | { |
139 | char header[46]; | 139 | char header[46]; |
@@ -159,7 +159,7 @@ uLong* bytesRecovered; | |||
159 | /* Header */ | 159 | /* Header */ |
160 | if (fwrite(header, 1, 46, fpOutCD) == 46) { | 160 | if (fwrite(header, 1, 46, fpOutCD) == 46) { |
161 | offsetCD += 46; | 161 | offsetCD += 46; |
162 | 162 | ||
163 | /* Filename */ | 163 | /* Filename */ |
164 | if (fnsize > 0) { | 164 | if (fnsize > 0) { |
165 | if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) { | 165 | if (fwrite(filename, 1, fnsize, fpOutCD) == fnsize) { |
@@ -172,7 +172,7 @@ uLong* bytesRecovered; | |||
172 | err = Z_STREAM_ERROR; | 172 | err = Z_STREAM_ERROR; |
173 | break; | 173 | break; |
174 | } | 174 | } |
175 | 175 | ||
176 | /* Extra field */ | 176 | /* Extra field */ |
177 | if (extsize > 0) { | 177 | if (extsize > 0) { |
178 | if (fwrite(extra, 1, extsize, fpOutCD) == extsize) { | 178 | if (fwrite(extra, 1, extsize, fpOutCD) == extsize) { |
@@ -182,7 +182,7 @@ uLong* bytesRecovered; | |||
182 | break; | 182 | break; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | /* Comment field */ | 186 | /* Comment field */ |
187 | if (comsize > 0) { | 187 | if (comsize > 0) { |
188 | if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) { | 188 | if ((int)fwrite(comment, 1, comsize, fpOutCD) == comsize) { |
@@ -192,8 +192,8 @@ uLong* bytesRecovered; | |||
192 | break; | 192 | break; |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | 196 | ||
197 | } else { | 197 | } else { |
198 | err = Z_ERRNO; | 198 | err = Z_ERRNO; |
199 | break; | 199 | break; |
@@ -225,17 +225,17 @@ uLong* bytesRecovered; | |||
225 | WRITE_32(header + 12, offsetCD); /* size of CD */ | 225 | WRITE_32(header + 12, offsetCD); /* size of CD */ |
226 | WRITE_32(header + 16, offset); /* offset to CD */ | 226 | WRITE_32(header + 16, offset); /* offset to CD */ |
227 | WRITE_16(header + 20, comsize); /* comment */ | 227 | WRITE_16(header + 20, comsize); /* comment */ |
228 | 228 | ||
229 | /* Header */ | 229 | /* Header */ |
230 | if (fwrite(header, 1, 22, fpOutCD) == 22) { | 230 | if (fwrite(header, 1, 22, fpOutCD) == 22) { |
231 | 231 | ||
232 | /* Comment field */ | 232 | /* Comment field */ |
233 | if (comsize > 0) { | 233 | if (comsize > 0) { |
234 | if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) { | 234 | if ((int)fwrite(comment, 1, comsize, fpOutCD) != comsize) { |
235 | err = Z_ERRNO; | 235 | err = Z_ERRNO; |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | } else { | 239 | } else { |
240 | err = Z_ERRNO; | 240 | err = Z_ERRNO; |
241 | } | 241 | } |
@@ -257,14 +257,14 @@ uLong* bytesRecovered; | |||
257 | fclose(fpOutCD); | 257 | fclose(fpOutCD); |
258 | } | 258 | } |
259 | } | 259 | } |
260 | 260 | ||
261 | /* Close */ | 261 | /* Close */ |
262 | fclose(fpZip); | 262 | fclose(fpZip); |
263 | fclose(fpOut); | 263 | fclose(fpOut); |
264 | 264 | ||
265 | /* Wipe temporary file */ | 265 | /* Wipe temporary file */ |
266 | (void)remove(fileOutTmp); | 266 | (void)remove(fileOutTmp); |
267 | 267 | ||
268 | /* Number of recovered entries */ | 268 | /* Number of recovered entries */ |
269 | if (err == Z_OK) { | 269 | if (err == Z_OK) { |
270 | if (nRecovered != NULL) { | 270 | if (nRecovered != NULL) { |
diff --git a/contrib/minizip/mztools.h b/contrib/minizip/mztools.h index eee78dc..88b3459 100644 --- a/contrib/minizip/mztools.h +++ b/contrib/minizip/mztools.h | |||
@@ -17,14 +17,14 @@ extern "C" { | |||
17 | 17 | ||
18 | #include "unzip.h" | 18 | #include "unzip.h" |
19 | 19 | ||
20 | /* Repair a ZIP file (missing central directory) | 20 | /* Repair a ZIP file (missing central directory) |
21 | file: file to recover | 21 | file: file to recover |
22 | fileOut: output file after recovery | 22 | fileOut: output file after recovery |
23 | fileOutTmp: temporary file name used for recovery | 23 | fileOutTmp: temporary file name used for recovery |
24 | */ | 24 | */ |
25 | extern int ZEXPORT unzRepair(const char* file, | 25 | extern int ZEXPORT unzRepair(const char* file, |
26 | const char* fileOut, | 26 | const char* fileOut, |
27 | const char* fileOutTmp, | 27 | const char* fileOutTmp, |
28 | uLong* nRecovered, | 28 | uLong* nRecovered, |
29 | uLong* bytesRecovered); | 29 | uLong* bytesRecovered); |
30 | 30 | ||
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c index e804a2a..e14de9e 100644 --- a/contrib/minizip/unzip.c +++ b/contrib/minizip/unzip.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* unzip.c -- IO for uncompress .zip files using zlib | 1 | /* unzip.c -- IO for uncompress .zip files using zlib |
2 | Version 1.01c, August 23th, 2004 | 2 | Version 1.01d, September 22th, 2004 |
3 | 3 | ||
4 | Copyright (C) 1998-2004 Gilles Vollant | 4 | Copyright (C) 1998-2004 Gilles Vollant |
5 | 5 | ||
@@ -1250,10 +1250,12 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len) | |||
1250 | pfile_in_zip_read_info->stream.avail_out = | 1250 | pfile_in_zip_read_info->stream.avail_out = |
1251 | (uInt)pfile_in_zip_read_info->rest_read_uncompressed; | 1251 | (uInt)pfile_in_zip_read_info->rest_read_uncompressed; |
1252 | 1252 | ||
1253 | if ((len>pfile_in_zip_read_info->rest_read_compressed) && | 1253 | if ((len>pfile_in_zip_read_info->rest_read_compressed+ |
1254 | (pfile_in_zip_read_info->raw)) | 1254 | pfile_in_zip_read_info->stream.avail_in) && |
1255 | (pfile_in_zip_read_info->raw)) | ||
1255 | pfile_in_zip_read_info->stream.avail_out = | 1256 | pfile_in_zip_read_info->stream.avail_out = |
1256 | (uInt)pfile_in_zip_read_info->rest_read_compressed; | 1257 | (uInt)pfile_in_zip_read_info->rest_read_compressed+ |
1258 | pfile_in_zip_read_info->stream.avail_in; | ||
1257 | 1259 | ||
1258 | while (pfile_in_zip_read_info->stream.avail_out>0) | 1260 | while (pfile_in_zip_read_info->stream.avail_out>0) |
1259 | { | 1261 | { |
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c index ce1444c..2ccd7fd 100644 --- a/contrib/minizip/zip.c +++ b/contrib/minizip/zip.c | |||
@@ -717,9 +717,9 @@ extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, | |||
717 | if (comment==NULL) | 717 | if (comment==NULL) |
718 | size_comment = 0; | 718 | size_comment = 0; |
719 | else | 719 | else |
720 | size_comment = strlen(comment); | 720 | size_comment = (uInt)strlen(comment); |
721 | 721 | ||
722 | size_filename = strlen(filename); | 722 | size_filename = (uInt)strlen(filename); |
723 | 723 | ||
724 | if (zipfi == NULL) | 724 | if (zipfi == NULL) |
725 | zi->ci.dosDate = 0; | 725 | zi->ci.dosDate = 0; |
@@ -1126,7 +1126,7 @@ extern int ZEXPORT zipClose (file, global_comment) | |||
1126 | if (global_comment==NULL) | 1126 | if (global_comment==NULL) |
1127 | size_global_comment = 0; | 1127 | size_global_comment = 0; |
1128 | else | 1128 | else |
1129 | size_global_comment = strlen(global_comment); | 1129 | size_global_comment = (uInt)strlen(global_comment); |
1130 | 1130 | ||
1131 | 1131 | ||
1132 | centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); | 1132 | centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); |
diff --git a/contrib/untgz/untgz.c b/contrib/untgz/untgz.c index 3a30768..2c391e5 100644 --- a/contrib/untgz/untgz.c +++ b/contrib/untgz/untgz.c | |||
@@ -97,7 +97,7 @@ struct attr_item | |||
97 | struct attr_item *next; | 97 | struct attr_item *next; |
98 | char *fname; | 98 | char *fname; |
99 | int mode; | 99 | int mode; |
100 | time_t time; | 100 | time_t time; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID }; | 103 | enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID }; |
diff --git a/contrib/vstudio/vc7/zlib.rc b/contrib/vstudio/vc7/zlib.rc index 2eb7c6b..3ebe25b 100644 --- a/contrib/vstudio/vc7/zlib.rc +++ b/contrib/vstudio/vc7/zlib.rc | |||
@@ -2,8 +2,8 @@ | |||
2 | 2 | ||
3 | #define IDR_VERSION1 1 | 3 | #define IDR_VERSION1 1 |
4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE | 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
5 | FILEVERSION 1,2,1,2 | 5 | FILEVERSION 1,2,2 |
6 | PRODUCTVERSION 1,2,1,2 | 6 | PRODUCTVERSION 1,2,2 |
7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK | 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
8 | FILEFLAGS 0 | 8 | FILEFLAGS 0 |
9 | FILEOS VOS_DOS_WINDOWS32 | 9 | FILEOS VOS_DOS_WINDOWS32 |
@@ -17,7 +17,7 @@ BEGIN | |||
17 | 17 | ||
18 | BEGIN | 18 | BEGIN |
19 | VALUE "FileDescription", "zlib data compression library\0" | 19 | VALUE "FileDescription", "zlib data compression library\0" |
20 | VALUE "FileVersion", "1.2.1.2\0" | 20 | VALUE "FileVersion", "1.2.2\0" |
21 | VALUE "InternalName", "zlib\0" | 21 | VALUE "InternalName", "zlib\0" |
22 | VALUE "OriginalFilename", "zlib.dll\0" | 22 | VALUE "OriginalFilename", "zlib.dll\0" |
23 | VALUE "ProductName", "ZLib.DLL\0" | 23 | VALUE "ProductName", "ZLib.DLL\0" |
@@ -12,11 +12,11 @@ | |||
12 | /* @(#) $Id$ */ | 12 | /* @(#) $Id$ */ |
13 | 13 | ||
14 | /* | 14 | /* |
15 | Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore protection | 15 | Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore |
16 | on the static variables used to control the first-use generation of the crc | 16 | protection on the static variables used to control the first-use generation |
17 | tables. Therefore if you #define DYNAMIC_CRC_TABLE, you should first call | 17 | of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should |
18 | get_crc_table() to initialize the tables before allowing more than on thread | 18 | first call get_crc_table() to initialize the tables before allowing more than |
19 | to use crc32(). | 19 | one thread to use crc32(). |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifdef MAKECRCH | 22 | #ifdef MAKECRCH |
@@ -103,51 +103,51 @@ local void make_crc_table() | |||
103 | { | 103 | { |
104 | unsigned long c; | 104 | unsigned long c; |
105 | int n, k; | 105 | int n, k; |
106 | unsigned long poly; /* polynomial exclusive-or pattern */ | 106 | unsigned long poly; /* polynomial exclusive-or pattern */ |
107 | /* terms of polynomial defining this crc (except x^32): */ | 107 | /* terms of polynomial defining this crc (except x^32): */ |
108 | static volatile int first = 1; /* flag to limit concurrent making */ | 108 | static volatile int first = 1; /* flag to limit concurrent making */ |
109 | static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; | 109 | static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; |
110 | 110 | ||
111 | /* See if another task is already doing this (not thread-safe, but better | 111 | /* See if another task is already doing this (not thread-safe, but better |
112 | than nothing -- significantly reduces duration of vulnerability in | 112 | than nothing -- significantly reduces duration of vulnerability in |
113 | case the advice about DYNAMIC_CRC_TABLE is ignored) */ | 113 | case the advice about DYNAMIC_CRC_TABLE is ignored) */ |
114 | if (first) { | 114 | if (first) { |
115 | first = 0; | 115 | first = 0; |
116 | 116 | ||
117 | /* make exclusive-or pattern from polynomial (0xedb88320UL) */ | 117 | /* make exclusive-or pattern from polynomial (0xedb88320UL) */ |
118 | poly = 0UL; | 118 | poly = 0UL; |
119 | for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) | 119 | for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) |
120 | poly |= 1UL << (31 - p[n]); | 120 | poly |= 1UL << (31 - p[n]); |
121 | 121 | ||
122 | /* generate a crc for every 8-bit value */ | 122 | /* generate a crc for every 8-bit value */ |
123 | for (n = 0; n < 256; n++) { | 123 | for (n = 0; n < 256; n++) { |
124 | c = (unsigned long)n; | 124 | c = (unsigned long)n; |
125 | for (k = 0; k < 8; k++) | 125 | for (k = 0; k < 8; k++) |
126 | c = c & 1 ? poly ^ (c >> 1) : c >> 1; | 126 | c = c & 1 ? poly ^ (c >> 1) : c >> 1; |
127 | crc_table[0][n] = c; | 127 | crc_table[0][n] = c; |
128 | } | 128 | } |
129 | 129 | ||
130 | #ifdef BYFOUR | 130 | #ifdef BYFOUR |
131 | /* generate crc for each value followed by one, two, and three zeros, and | 131 | /* generate crc for each value followed by one, two, and three zeros, |
132 | then the byte reversal of those as well as the first table */ | 132 | and then the byte reversal of those as well as the first table */ |
133 | for (n = 0; n < 256; n++) { | 133 | for (n = 0; n < 256; n++) { |
134 | c = crc_table[0][n]; | 134 | c = crc_table[0][n]; |
135 | crc_table[4][n] = REV(c); | 135 | crc_table[4][n] = REV(c); |
136 | for (k = 1; k < 4; k++) { | 136 | for (k = 1; k < 4; k++) { |
137 | c = crc_table[0][c & 0xff] ^ (c >> 8); | 137 | c = crc_table[0][c & 0xff] ^ (c >> 8); |
138 | crc_table[k][n] = c; | 138 | crc_table[k][n] = c; |
139 | crc_table[k + 4][n] = REV(c); | 139 | crc_table[k + 4][n] = REV(c); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | #endif /* BYFOUR */ | 142 | #endif /* BYFOUR */ |
143 | 143 | ||
144 | crc_table_empty = 0; | 144 | crc_table_empty = 0; |
145 | } | 145 | } |
146 | else { /* not first */ | 146 | else { /* not first */ |
147 | /* wait for the other guy to finish (not exactly efficient, but rare) */ | 147 | /* wait for the other guy to finish (not efficient, but rare) */ |
148 | while (crc_table_empty) | 148 | while (crc_table_empty) |
149 | ; | 149 | ; |
150 | } | 150 | } |
151 | 151 | ||
152 | #ifdef MAKECRCH | 152 | #ifdef MAKECRCH |
153 | /* write out CRC tables to crc32.h */ | 153 | /* write out CRC tables to crc32.h */ |
@@ -201,10 +201,10 @@ local void write_table(out, table) | |||
201 | const unsigned long FAR * ZEXPORT get_crc_table() | 201 | const unsigned long FAR * ZEXPORT get_crc_table() |
202 | { | 202 | { |
203 | #ifdef DYNAMIC_CRC_TABLE | 203 | #ifdef DYNAMIC_CRC_TABLE |
204 | if (crc_table_empty) | 204 | if (crc_table_empty) |
205 | make_crc_table(); | 205 | make_crc_table(); |
206 | #endif /* DYNAMIC_CRC_TABLE */ | 206 | #endif /* DYNAMIC_CRC_TABLE */ |
207 | return (const unsigned long FAR *)crc_table; | 207 | return (const unsigned long FAR *)crc_table; |
208 | } | 208 | } |
209 | 209 | ||
210 | /* ========================================================================= */ | 210 | /* ========================================================================= */ |
@@ -1,5 +1,5 @@ | |||
1 | /* deflate.c -- compress data using the deflation algorithm | 1 | /* deflate.c -- compress data using the deflation algorithm |
2 | * Copyright (C) 1995-2003 Jean-loup Gailly. | 2 | * Copyright (C) 1995-2004 Jean-loup Gailly. |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
@@ -52,7 +52,7 @@ | |||
52 | #include "deflate.h" | 52 | #include "deflate.h" |
53 | 53 | ||
54 | const char deflate_copyright[] = | 54 | const char deflate_copyright[] = |
55 | " deflate 1.2.1.2 Copyright 1995-2004 Jean-loup Gailly "; | 55 | " deflate 1.2.2 Copyright 1995-2004 Jean-loup Gailly "; |
56 | /* | 56 | /* |
57 | If you use the zlib library in a product, an acknowledgment is welcome | 57 | If you use the zlib library in a product, an acknowledgment is welcome |
58 | in the documentation of your product. If for some reason you cannot | 58 | in the documentation of your product. If for some reason you cannot |
@@ -455,10 +455,10 @@ int ZEXPORT gzread (file, buf, len) | |||
455 | s->z_err = Z_ERRNO; | 455 | s->z_err = Z_ERRNO; |
456 | break; | 456 | break; |
457 | } | 457 | } |
458 | if (feof(s->file)) { /* avoid error for empty file */ | 458 | if (feof(s->file)) { /* avoid error for empty file */ |
459 | s->z_err = Z_STREAM_END; | 459 | s->z_err = Z_STREAM_END; |
460 | break; | 460 | break; |
461 | } | 461 | } |
462 | } | 462 | } |
463 | s->stream.next_in = s->inbuf; | 463 | s->stream.next_in = s->inbuf; |
464 | } | 464 | } |
@@ -434,8 +434,8 @@ void FAR *out_desc; | |||
434 | } | 434 | } |
435 | } | 435 | } |
436 | 436 | ||
437 | /* handle error breaks in while */ | 437 | /* handle error breaks in while */ |
438 | if (state->mode == BAD) break; | 438 | if (state->mode == BAD) break; |
439 | 439 | ||
440 | /* build code tables */ | 440 | /* build code tables */ |
441 | state->next = state->codes; | 441 | state->next = state->codes; |
@@ -109,6 +109,7 @@ z_streamp strm; | |||
109 | state = (struct inflate_state FAR *)strm->state; | 109 | state = (struct inflate_state FAR *)strm->state; |
110 | strm->total_in = strm->total_out = state->total = 0; | 110 | strm->total_in = strm->total_out = state->total = 0; |
111 | strm->msg = Z_NULL; | 111 | strm->msg = Z_NULL; |
112 | strm->adler = 1; /* to support ill-conceived Java test suite */ | ||
112 | state->mode = HEAD; | 113 | state->mode = HEAD; |
113 | state->last = 0; | 114 | state->last = 0; |
114 | state->havedict = 0; | 115 | state->havedict = 0; |
@@ -861,8 +862,8 @@ int flush; | |||
861 | } | 862 | } |
862 | } | 863 | } |
863 | 864 | ||
864 | /* handle error breaks in while */ | 865 | /* handle error breaks in while */ |
865 | if (state->mode == BAD) break; | 866 | if (state->mode == BAD) break; |
866 | 867 | ||
867 | /* build code tables */ | 868 | /* build code tables */ |
868 | state->next = state->codes; | 869 | state->next = state->codes; |
@@ -9,7 +9,7 @@ | |||
9 | #define MAXBITS 15 | 9 | #define MAXBITS 15 |
10 | 10 | ||
11 | const char inflate_copyright[] = | 11 | const char inflate_copyright[] = |
12 | " inflate 1.2.1.2 Copyright 1995-2004 Mark Adler "; | 12 | " inflate 1.2.2 Copyright 1995-2004 Mark Adler "; |
13 | /* | 13 | /* |
14 | If you use the zlib library in a product, an acknowledgment is welcome | 14 | If you use the zlib library in a product, an acknowledgment is welcome |
15 | in the documentation of your product. If for some reason you cannot | 15 | in the documentation of your product. If for some reason you cannot |
@@ -62,7 +62,7 @@ unsigned short FAR *work; | |||
62 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; | 62 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; |
63 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ | 63 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ |
64 | 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, | 64 | 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, |
65 | 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 77, 194}; | 65 | 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 198}; |
66 | static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ | 66 | static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ |
67 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, | 67 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, |
68 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, | 68 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, |
@@ -1,3 +1,3 @@ | |||
1 | This directory contains files that have not been updated for zlib 1.2.1 | 1 | This directory contains files that have not been updated for zlib 1.2.x |
2 | 2 | ||
3 | (Volunteers are encouraged to help clean this up. Thanks.) | 3 | (Volunteers are encouraged to help clean this up. Thanks.) |
diff --git a/contrib/visual-basic.txt b/old/visual-basic.txt index 57efe58..57efe58 100644 --- a/contrib/visual-basic.txt +++ b/old/visual-basic.txt | |||
diff --git a/projects/visualc6/zlib.dsp b/projects/visualc6/zlib.dsp index a1a401a..8f16513 100644 --- a/projects/visualc6/zlib.dsp +++ b/projects/visualc6/zlib.dsp | |||
@@ -418,90 +418,120 @@ SOURCE=..\..\win32\zlib1.rc | |||
418 | # Begin Source File | 418 | # Begin Source File |
419 | 419 | ||
420 | SOURCE=..\..\contrib\masmx86\gvmat32.asm | 420 | SOURCE=..\..\contrib\masmx86\gvmat32.asm |
421 | # PROP Exclude_From_Build 1 | ||
422 | # End Source File | ||
423 | # Begin Source File | ||
424 | |||
425 | SOURCE=..\..\contrib\masmx86\gvmat32c.c | ||
426 | 421 | ||
427 | !IF "$(CFG)" == "zlib - Win32 DLL Release" | 422 | !IF "$(CFG)" == "zlib - Win32 DLL Release" |
428 | 423 | ||
429 | # PROP Exclude_From_Build 1 | 424 | # PROP Exclude_From_Build 1 |
430 | # ADD CPP /I "..\.." | ||
431 | 425 | ||
432 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug" | 426 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug" |
433 | 427 | ||
434 | # PROP Exclude_From_Build 1 | 428 | # PROP Exclude_From_Build 1 |
435 | # ADD CPP /I "..\.." | ||
436 | 429 | ||
437 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release" | 430 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release" |
438 | 431 | ||
439 | # ADD CPP /I "..\.." | 432 | # Begin Custom Build - Assembling... |
433 | IntDir=.\Win32_DLL_ASM_Release | ||
434 | InputPath=..\..\contrib\masmx86\gvmat32.asm | ||
435 | InputName=gvmat32 | ||
436 | |||
437 | "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
438 | ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" | ||
439 | |||
440 | # End Custom Build | ||
440 | 441 | ||
441 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug" | 442 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug" |
442 | 443 | ||
443 | # ADD CPP /I "..\.." | 444 | # Begin Custom Build - Assembling... |
445 | IntDir=.\Win32_DLL_ASM_Debug | ||
446 | InputPath=..\..\contrib\masmx86\gvmat32.asm | ||
447 | InputName=gvmat32 | ||
448 | |||
449 | "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
450 | ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" | ||
451 | |||
452 | # End Custom Build | ||
444 | 453 | ||
445 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB Release" | 454 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB Release" |
446 | 455 | ||
447 | # PROP Exclude_From_Build 1 | 456 | # PROP Exclude_From_Build 1 |
448 | # ADD CPP /I "..\.." | ||
449 | 457 | ||
450 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug" | 458 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug" |
451 | 459 | ||
452 | # PROP Exclude_From_Build 1 | 460 | # PROP Exclude_From_Build 1 |
453 | # ADD CPP /I "..\.." | ||
454 | 461 | ||
455 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release" | 462 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release" |
456 | 463 | ||
457 | # ADD CPP /I "..\.." | 464 | # Begin Custom Build - Assembling... |
465 | IntDir=.\Win32_LIB_ASM_Release | ||
466 | InputPath=..\..\contrib\masmx86\gvmat32.asm | ||
467 | InputName=gvmat32 | ||
468 | |||
469 | "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
470 | ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" | ||
471 | |||
472 | # End Custom Build | ||
458 | 473 | ||
459 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug" | 474 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug" |
460 | 475 | ||
461 | # ADD CPP /I "..\.." | 476 | # Begin Custom Build - Assembling... |
477 | IntDir=.\Win32_LIB_ASM_Debug | ||
478 | InputPath=..\..\contrib\masmx86\gvmat32.asm | ||
479 | InputName=gvmat32 | ||
462 | 480 | ||
463 | !ENDIF | 481 | "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" |
482 | ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" | ||
464 | 483 | ||
465 | # End Source File | 484 | # End Custom Build |
466 | # Begin Source File | 485 | |
486 | !ENDIF | ||
467 | 487 | ||
468 | SOURCE=..\..\contrib\masmx86\inffas32.asm | ||
469 | # PROP Exclude_From_Build 1 | ||
470 | # End Source File | 488 | # End Source File |
471 | # Begin Source File | 489 | # Begin Source File |
472 | 490 | ||
473 | SOURCE=..\..\contrib\masmx86\gvmat32.obj | 491 | SOURCE=..\..\contrib\masmx86\gvmat32c.c |
474 | 492 | ||
475 | !IF "$(CFG)" == "zlib - Win32 DLL Release" | 493 | !IF "$(CFG)" == "zlib - Win32 DLL Release" |
476 | 494 | ||
477 | # PROP Exclude_From_Build 1 | 495 | # PROP Exclude_From_Build 1 |
496 | # ADD CPP /I "..\.." | ||
478 | 497 | ||
479 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug" | 498 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL Debug" |
480 | 499 | ||
481 | # PROP Exclude_From_Build 1 | 500 | # PROP Exclude_From_Build 1 |
501 | # ADD CPP /I "..\.." | ||
482 | 502 | ||
483 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release" | 503 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release" |
484 | 504 | ||
505 | # ADD CPP /I "..\.." | ||
506 | |||
485 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug" | 507 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug" |
486 | 508 | ||
509 | # ADD CPP /I "..\.." | ||
510 | |||
487 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB Release" | 511 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB Release" |
488 | 512 | ||
489 | # PROP Exclude_From_Build 1 | 513 | # PROP Exclude_From_Build 1 |
514 | # ADD CPP /I "..\.." | ||
490 | 515 | ||
491 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug" | 516 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB Debug" |
492 | 517 | ||
493 | # PROP Exclude_From_Build 1 | 518 | # PROP Exclude_From_Build 1 |
519 | # ADD CPP /I "..\.." | ||
494 | 520 | ||
495 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release" | 521 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release" |
496 | 522 | ||
523 | # ADD CPP /I "..\.." | ||
524 | |||
497 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug" | 525 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug" |
498 | 526 | ||
527 | # ADD CPP /I "..\.." | ||
528 | |||
499 | !ENDIF | 529 | !ENDIF |
500 | 530 | ||
501 | # End Source File | 531 | # End Source File |
502 | # Begin Source File | 532 | # Begin Source File |
503 | 533 | ||
504 | SOURCE=..\..\contrib\masmx86\inffas32.obj | 534 | SOURCE=..\..\contrib\masmx86\inffas32.asm |
505 | 535 | ||
506 | !IF "$(CFG)" == "zlib - Win32 DLL Release" | 536 | !IF "$(CFG)" == "zlib - Win32 DLL Release" |
507 | 537 | ||
@@ -513,8 +543,28 @@ SOURCE=..\..\contrib\masmx86\inffas32.obj | |||
513 | 543 | ||
514 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release" | 544 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Release" |
515 | 545 | ||
546 | # Begin Custom Build - Assembling... | ||
547 | IntDir=.\Win32_DLL_ASM_Release | ||
548 | InputPath=..\..\contrib\masmx86\inffas32.asm | ||
549 | InputName=inffas32 | ||
550 | |||
551 | "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
552 | ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" | ||
553 | |||
554 | # End Custom Build | ||
555 | |||
516 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug" | 556 | !ELSEIF "$(CFG)" == "zlib - Win32 DLL ASM Debug" |
517 | 557 | ||
558 | # Begin Custom Build - Assembling... | ||
559 | IntDir=.\Win32_DLL_ASM_Debug | ||
560 | InputPath=..\..\contrib\masmx86\inffas32.asm | ||
561 | InputName=inffas32 | ||
562 | |||
563 | "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
564 | ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" | ||
565 | |||
566 | # End Custom Build | ||
567 | |||
518 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB Release" | 568 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB Release" |
519 | 569 | ||
520 | # PROP Exclude_From_Build 1 | 570 | # PROP Exclude_From_Build 1 |
@@ -525,8 +575,28 @@ SOURCE=..\..\contrib\masmx86\inffas32.obj | |||
525 | 575 | ||
526 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release" | 576 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Release" |
527 | 577 | ||
578 | # Begin Custom Build - Assembling... | ||
579 | IntDir=.\Win32_LIB_ASM_Release | ||
580 | InputPath=..\..\contrib\masmx86\inffas32.asm | ||
581 | InputName=inffas32 | ||
582 | |||
583 | "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
584 | ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" | ||
585 | |||
586 | # End Custom Build | ||
587 | |||
528 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug" | 588 | !ELSEIF "$(CFG)" == "zlib - Win32 LIB ASM Debug" |
529 | 589 | ||
590 | # Begin Custom Build - Assembling... | ||
591 | IntDir=.\Win32_LIB_ASM_Debug | ||
592 | InputPath=..\..\contrib\masmx86\inffas32.asm | ||
593 | InputName=inffas32 | ||
594 | |||
595 | "$(IntDir)\$(InputName).obj" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" | ||
596 | ml /nologo /c /Cx /coff /Zi /Fo"$(IntDir)\$(InputName).obj" "$(InputPath)" | ||
597 | |||
598 | # End Custom Build | ||
599 | |||
530 | !ENDIF | 600 | !ENDIF |
531 | 601 | ||
532 | # End Source File | 602 | # End Source File |
diff --git a/qnx/package.qpg b/qnx/package.qpg index 9986c6d..bf14280 100644 --- a/qnx/package.qpg +++ b/qnx/package.qpg | |||
@@ -25,10 +25,10 @@ | |||
25 | <QPG:Files> | 25 | <QPG:Files> |
26 | <QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/> | 26 | <QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/> |
27 | <QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/> | 27 | <QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/> |
28 | <QPG:Add file="../libz.so.1.2.1.2" install="/opt/lib/" user="root:bin" permission="644"/> | 28 | <QPG:Add file="../libz.so.1.2.2" install="/opt/lib/" user="root:bin" permission="644"/> |
29 | <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.1.2"/> | 29 | <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.2"/> |
30 | <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.1.2"/> | 30 | <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.2"/> |
31 | <QPG:Add file="../libz.so.1.2.1.2" install="/opt/lib/" component="slib"/> | 31 | <QPG:Add file="../libz.so.1.2.2" install="/opt/lib/" component="slib"/> |
32 | </QPG:Files> | 32 | </QPG:Files> |
33 | 33 | ||
34 | <QPG:PackageFilter> | 34 | <QPG:PackageFilter> |
@@ -63,7 +63,7 @@ | |||
63 | </QPM:ProductDescription> | 63 | </QPM:ProductDescription> |
64 | 64 | ||
65 | <QPM:ReleaseDescription> | 65 | <QPM:ReleaseDescription> |
66 | <QPM:ReleaseVersion>1.2.1.2</QPM:ReleaseVersion> | 66 | <QPM:ReleaseVersion>1.2.2</QPM:ReleaseVersion> |
67 | <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency> | 67 | <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency> |
68 | <QPM:ReleaseStability>Stable</QPM:ReleaseStability> | 68 | <QPM:ReleaseStability>Stable</QPM:ReleaseStability> |
69 | <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor> | 69 | <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor> |
diff --git a/win32/DLL_FAQ.txt b/win32/DLL_FAQ.txt index a3ed5dd..1746a95 100644 --- a/win32/DLL_FAQ.txt +++ b/win32/DLL_FAQ.txt | |||
@@ -175,7 +175,7 @@ in the zlib distribution, or at the following location: | |||
175 | zlib in other programming languages. Some of them, like Ada | 175 | zlib in other programming languages. Some of them, like Ada |
176 | (GNAT) and Fortran (GNU G77), have C bindings implemented | 176 | (GNAT) and Fortran (GNU G77), have C bindings implemented |
177 | initially on Unix, and relying on the C calling convention. | 177 | initially on Unix, and relying on the C calling convention. |
178 | On the other hand, the pre- .NET versions of Microsoft Visual | 178 | On the other hand, the pre- .Net versions of Microsoft Visual |
179 | Basic require STDCALL, while Borland Delphi prefers, although | 179 | Basic require STDCALL, while Borland Delphi prefers, although |
180 | it does not require, FASTCALL. | 180 | it does not require, FASTCALL. |
181 | 181 | ||
@@ -203,13 +203,11 @@ in the zlib distribution, or at the following location: | |||
203 | zlib distribution. | 203 | zlib distribution. |
204 | 204 | ||
205 | 205 | ||
206 | 8. I need a DLL for my Microsoft .NET project. What can I do? | 206 | 8. I need to use zlib in my Microsoft .Net project. What can I |
207 | do? | ||
207 | 208 | ||
208 | - We did not implement a COM wrapper around zlib, so you will | 209 | - Henrik Ravn has contributed a .Net wrapper around zlib. Look |
209 | have to develop it yourself, or to get it from somewhere else. | 210 | into contrib/dotzlib/, inside the zlib distribution. |
210 | |||
211 | If you would be so generous as to contribute such a wrapper, | ||
212 | we would like to include it in a future zlib version. | ||
213 | 211 | ||
214 | 212 | ||
215 | 9. If my application uses ZLIB1.DLL, should I link it to | 213 | 9. If my application uses ZLIB1.DLL, should I link it to |
diff --git a/win32/VisualC.txt b/win32/VisualC.txt new file mode 100644 index 0000000..579a5fc --- /dev/null +++ b/win32/VisualC.txt | |||
@@ -0,0 +1,3 @@ | |||
1 | |||
2 | To build zlib using the Microsoft Visual C++ environment, | ||
3 | use the appropriate project from the projects/ directory. | ||
diff --git a/win32/zlib1.rc b/win32/zlib1.rc index 130493a..162ab8f 100644 --- a/win32/zlib1.rc +++ b/win32/zlib1.rc | |||
@@ -5,8 +5,8 @@ VS_VERSION_INFO VERSIONINFO | |||
5 | #else | 5 | #else |
6 | VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE | 6 | VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
7 | #endif | 7 | #endif |
8 | FILEVERSION 1,2,1,2 | 8 | FILEVERSION 1,2,2 |
9 | PRODUCTVERSION 1,2,1,2 | 9 | PRODUCTVERSION 1,2,2 |
10 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK | 10 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
11 | #ifdef _DEBUG | 11 | #ifdef _DEBUG |
12 | FILEFLAGS 1 | 12 | FILEFLAGS 1 |
@@ -23,12 +23,12 @@ BEGIN | |||
23 | //language ID = U.S. English, char set = Windows, Multilingual | 23 | //language ID = U.S. English, char set = Windows, Multilingual |
24 | BEGIN | 24 | BEGIN |
25 | VALUE "FileDescription", "zlib data compression library\0" | 25 | VALUE "FileDescription", "zlib data compression library\0" |
26 | VALUE "FileVersion", "1.2.1.2\0" | 26 | VALUE "FileVersion", "1.2.2\0" |
27 | VALUE "InternalName", "zlib1.dll\0" | 27 | VALUE "InternalName", "zlib1.dll\0" |
28 | VALUE "LegalCopyright", "(C) 1995-2004 Jean-loup Gailly & Mark Adler\0" | 28 | VALUE "LegalCopyright", "(C) 1995-2004 Jean-loup Gailly & Mark Adler\0" |
29 | VALUE "OriginalFilename", "zlib1.dll\0" | 29 | VALUE "OriginalFilename", "zlib1.dll\0" |
30 | VALUE "ProductName", "zlib\0" | 30 | VALUE "ProductName", "zlib\0" |
31 | VALUE "ProductVersion", "1.2.1.2\0" | 31 | VALUE "ProductVersion", "1.2.2\0" |
32 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" | 32 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
33 | END | 33 | END |
34 | END | 34 | END |
@@ -1,4 +1,4 @@ | |||
1 | .TH ZLIB 3 "9 September 2004" | 1 | .TH ZLIB 3 "3 October 2004" |
2 | .SH NAME | 2 | .SH NAME |
3 | zlib \- compression/decompression library | 3 | zlib \- compression/decompression library |
4 | .SH SYNOPSIS | 4 | .SH SYNOPSIS |
@@ -133,7 +133,7 @@ before asking for help. | |||
133 | Send questions and/or comments to zlib@gzip.org, | 133 | Send questions and/or comments to zlib@gzip.org, |
134 | or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). | 134 | or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). |
135 | .SH AUTHORS | 135 | .SH AUTHORS |
136 | Version 1.2.1.2 | 136 | Version 1.2.2 |
137 | Copyright (C) 1995-2004 Jean-loup Gailly (jloup@gzip.org) | 137 | Copyright (C) 1995-2004 Jean-loup Gailly (jloup@gzip.org) |
138 | and Mark Adler (madler@alumni.caltech.edu). | 138 | and Mark Adler (madler@alumni.caltech.edu). |
139 | .LP | 139 | .LP |
@@ -1,5 +1,5 @@ | |||
1 | /* zlib.h -- interface of the 'zlib' general purpose compression library | 1 | /* zlib.h -- interface of the 'zlib' general purpose compression library |
2 | version 1.2.1.2, September 9th, 2004 | 2 | version 1.2.2, October 3rd, 2004 |
3 | 3 | ||
4 | Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler | 4 | Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler |
5 | 5 | ||
@@ -37,8 +37,8 @@ | |||
37 | extern "C" { | 37 | extern "C" { |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #define ZLIB_VERSION "1.2.1.2" | 40 | #define ZLIB_VERSION "1.2.2" |
41 | #define ZLIB_VERNUM 0x1212 | 41 | #define ZLIB_VERNUM 0x1220 |
42 | 42 | ||
43 | /* | 43 | /* |
44 | The 'zlib' compression library provides in-memory compression and | 44 | The 'zlib' compression library provides in-memory compression and |
@@ -53,24 +53,22 @@ extern "C" { | |||
53 | application must provide more input and/or consume the output | 53 | application must provide more input and/or consume the output |
54 | (providing more output space) before each call. | 54 | (providing more output space) before each call. |
55 | 55 | ||
56 | The compressed data format used by the in-memory functions is the zlib | 56 | The compressed data format used by default by the in-memory functions is |
57 | format, which is a zlib wrapper documented in RFC 1950, wrapped around a | 57 | the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped |
58 | deflate stream, which is itself documented in RFC 1951. | 58 | around a deflate stream, which is itself documented in RFC 1951. |
59 | 59 | ||
60 | The library also supports reading and writing files in gzip (.gz) format | 60 | The library also supports reading and writing files in gzip (.gz) format |
61 | with an interface similar to that of stdio using the functions that start | 61 | with an interface similar to that of stdio using the functions that start |
62 | with "gz". The gzip format is different from the zlib format. gzip is a | 62 | with "gz". The gzip format is different from the zlib format. gzip is a |
63 | gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. | 63 | gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. |
64 | 64 | ||
65 | This library can optionally read and write gzip streams in memory as well. | ||
66 | |||
65 | The zlib format was designed to be compact and fast for use in memory | 67 | The zlib format was designed to be compact and fast for use in memory |
66 | and on communications channels. The gzip format was designed for single- | 68 | and on communications channels. The gzip format was designed for single- |
67 | file compression on file systems, has a larger header than zlib to maintain | 69 | file compression on file systems, has a larger header than zlib to maintain |
68 | directory information, and uses a different, slower check method than zlib. | 70 | directory information, and uses a different, slower check method than zlib. |
69 | 71 | ||
70 | This library does not provide any functions to write gzip files in memory. | ||
71 | However such functions could be easily written using zlib's deflate function, | ||
72 | the documentation in the gzip RFC, and the examples in gzio.c. | ||
73 | |||
74 | The library does not install any signal handler. The decoder checks | 72 | The library does not install any signal handler. The decoder checks |
75 | the consistency of the compressed data, so the library should never | 73 | the consistency of the compressed data, so the library should never |
76 | crash even in case of corrupted input. | 74 | crash even in case of corrupted input. |
@@ -478,7 +476,8 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, | |||
478 | 16 to windowBits to write a simple gzip header and trailer around the | 476 | 16 to windowBits to write a simple gzip header and trailer around the |
479 | compressed data instead of a zlib wrapper. The gzip header will have no | 477 | compressed data instead of a zlib wrapper. The gzip header will have no |
480 | file name, no extra data, no comment, no modification time (set to zero), | 478 | file name, no extra data, no comment, no modification time (set to zero), |
481 | no header crc, and the operating system will be set to 255 (unknown). | 479 | no header crc, and the operating system will be set to 255 (unknown). If a |
480 | gzip stream is being written, strm->adler is a crc32 instead of an adler32. | ||
482 | 481 | ||
483 | The memLevel parameter specifies how much memory should be allocated | 482 | The memLevel parameter specifies how much memory should be allocated |
484 | for the internal compression state. memLevel=1 uses minimum memory but | 483 | for the internal compression state. memLevel=1 uses minimum memory but |
@@ -649,7 +648,8 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, | |||
649 | windowBits can also be greater than 15 for optional gzip decoding. Add | 648 | windowBits can also be greater than 15 for optional gzip decoding. Add |
650 | 32 to windowBits to enable zlib and gzip decoding with automatic header | 649 | 32 to windowBits to enable zlib and gzip decoding with automatic header |
651 | detection, or add 16 to decode only the gzip format (the zlib format will | 650 | detection, or add 16 to decode only the gzip format (the zlib format will |
652 | return a Z_DATA_ERROR). | 651 | return a Z_DATA_ERROR. If a gzip stream is being decoded, strm->adler is |
652 | a crc32 instead of an adler32. | ||
653 | 653 | ||
654 | inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough | 654 | inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
655 | memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative | 655 | memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative |