Compare commits
	
		
			2 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 85e7d7d9ba | ||
|   | 8e34b3a802 | 
							
								
								
									
										43
									
								
								ChangeLog
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								ChangeLog
									
									
									
									
									
								
							| @@ -1,5 +1,46 @@ | |||||||
|  |  | ||||||
|                 ChangeLog file for zlib |                 ChangeLog file for zlib | ||||||
|  | Changes in 1.2.0.3 (19 July 2003) | ||||||
|  | - Fix silly error in gzungetc() implementation [Vollant] | ||||||
|  | - Update contrib/minizip and contrib/vstudio [Vollant] | ||||||
|  | - Fix printf format in example.c | ||||||
|  | - Correct cdecl support in zconf.in.h [Anisimkov] | ||||||
|  | - Minor FAQ updates | ||||||
|  |  | ||||||
|  | Changes in 1.2.0.2 (13 July 2003) | ||||||
|  | - Add ZLIB_VERNUM in zlib.h for numerical preprocessor comparisons | ||||||
|  | - Attempt to avoid warnings in crc32.c for pointer-int conversion | ||||||
|  | - Add AIX to configure, remove aix directory [Bakker] | ||||||
|  | - Add some casts to minigzip.c | ||||||
|  | - Improve checking after insecure sprintf() or vsprintf() calls | ||||||
|  | - Remove #elif's from crc32.c | ||||||
|  | - Change leave label to inf_leave in inflate.c and infback.c to avoid | ||||||
|  |   library conflicts | ||||||
|  | - Remove inflate gzip decoding by default--only enable gzip decoding by | ||||||
|  |   special request for stricter backward compatibility | ||||||
|  | - Add zlibCompileFlags() function to return compilation information | ||||||
|  | - More typecasting in deflate.c to avoid warnings | ||||||
|  | - Remove leading underscore from _Capital #defines [Truta] | ||||||
|  | - Fix configure to link shared library when testing | ||||||
|  | - Add some Windows CE target adjustments [Mai] | ||||||
|  | - Remove #define ZLIB_DLL in zconf.h [Vollant] | ||||||
|  | - Add zlib.3 [Rodgers] | ||||||
|  | - Update RFC URL in deflate.c and algorithm.txt [Mai] | ||||||
|  | - Add zlib_dll_FAQ.txt to contrib [Truta] | ||||||
|  | - Add UL to some constants [Truta] | ||||||
|  | - Update minizip and vstudio [Vollant] | ||||||
|  | - Remove vestigial NEED_DUMMY_RETURN from zconf.in.h | ||||||
|  | - Expand use of NO_DUMMY_DECL to avoid all dummy structures | ||||||
|  | - Added iostream3 to contrib [Schwardt] | ||||||
|  | - Replace rewind() with fseek() for WinCE [Truta] | ||||||
|  | - Improve setting of zlib format compression level flags | ||||||
|  |     - Report 0 for huffman and rle strategies and for level == 0 or 1 | ||||||
|  |     - Report 2 only for level == 6 | ||||||
|  | - Only deal with 64K limit when necessary at compile time [Truta] | ||||||
|  | - Allow TOO_FAR check to be turned off at compile time [Truta] | ||||||
|  | - Add gzclearerr() function [Souza] | ||||||
|  | - Add gzungetc() function | ||||||
|  |  | ||||||
| Changes in 1.2.0.1 (17 March 2003) | Changes in 1.2.0.1 (17 March 2003) | ||||||
| - Add Z_RLE strategy for run-length encoding [Truta] | - Add Z_RLE strategy for run-length encoding [Truta] | ||||||
|     - When Z_RLE requested, restrict matches to distance one |     - When Z_RLE requested, restrict matches to distance one | ||||||
| @@ -12,7 +53,7 @@ Changes in 1.2.0.1 (17 March 2003) | |||||||
|     - Include additional header file on VMS for off_t typedef |     - Include additional header file on VMS for off_t typedef | ||||||
| - Try to use _vsnprintf where it supplants vsprintf [Vollant] | - Try to use _vsnprintf where it supplants vsprintf [Vollant] | ||||||
| - Add some casts in inffast.c | - Add some casts in inffast.c | ||||||
| - Enchance comments in zlib.h on what happens if the gzprintf() tries to | - Enchance comments in zlib.h on what happens if gzprintf() tries to | ||||||
|   write more than 4095 bytes before compression |   write more than 4095 bytes before compression | ||||||
| - Remove unused state from inflateBackEnd() | - Remove unused state from inflateBackEnd() | ||||||
| - Remove exit(0) from minigzip.c, example.c | - Remove exit(0) from minigzip.c, example.c | ||||||
|   | |||||||
							
								
								
									
										53
									
								
								FAQ
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								FAQ
									
									
									
									
									
								
							| @@ -20,7 +20,7 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html | |||||||
|  3. Where can I get a Visual Basic interface to zlib? |  3. Where can I get a Visual Basic interface to zlib? | ||||||
|  |  | ||||||
|     See |     See | ||||||
|         * http://www.winimage.com/zLibDll/cmp-z-it.zip |         * http://www.winimage.com/zLibDll/ | ||||||
|         * http://www.dogma.net/markn/articles/zlibtool/zlibtool.htm |         * http://www.dogma.net/markn/articles/zlibtool/zlibtool.htm | ||||||
|         * contrib/visual-basic.txt in the zlib distribution |         * contrib/visual-basic.txt in the zlib distribution | ||||||
|  |  | ||||||
| @@ -147,11 +147,14 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html | |||||||
| 22. The license says that altered source versions must be "plainly marked". So | 22. The license says that altered source versions must be "plainly marked". So | ||||||
|     what exactly do I need to do to meet that requirement? |     what exactly do I need to do to meet that requirement? | ||||||
|  |  | ||||||
|     You need to append something the ZLIB_VERSION string in zlib.h. For |     You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In | ||||||
|     example, if the version of the base zlib you are altering is "1.2.3", then |     particular, the final version number needs to be changed to "f", and an | ||||||
|     you could change the string to "1.2.3-fred-mods-v3". You should not change |     identification string should be appended to ZLIB_VERSION. Version numbers | ||||||
|     it to "1.2.4" or "1.2.3.1" since the zlib authors would like to reserve |     x.x.x.f are reserved for modifications to zlib by others than the zlib | ||||||
|     those forms of the version for their own use. |     maintainers. For example, if the version of the base zlib you are altering | ||||||
|  |     is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and | ||||||
|  |     ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also | ||||||
|  |     update the version strings in deflate.c and inftrees.c. | ||||||
|  |  | ||||||
|     For altered source distributions, you should also note the origin and |     For altered source distributions, you should also note the origin and | ||||||
|     nature of the changes in zlib.h, as well as in ChangeLog and README, along |     nature of the changes in zlib.h, as well as in ChangeLog and README, along | ||||||
| @@ -161,8 +164,8 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html | |||||||
|  |  | ||||||
|     Note that distributing a compiled zlib library along with zlib.h and |     Note that distributing a compiled zlib library along with zlib.h and | ||||||
|     zconf.h is also a source distribution, and so you should change |     zconf.h is also a source distribution, and so you should change | ||||||
|     ZLIB_VERSION and note the origin and nature of the changes in zlib.h as you |     ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes | ||||||
|     would for a full source distribution. |     in zlib.h as you would for a full source distribution. | ||||||
|  |  | ||||||
| 23. Will zlib work on a big-endian or little-endian architecture, and can I | 23. Will zlib work on a big-endian or little-endian architecture, and can I | ||||||
|     exchange compressed data between them? |     exchange compressed data between them? | ||||||
| @@ -212,12 +215,20 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html | |||||||
| 30. Can zlib work with greater than 4 GB of data? | 30. Can zlib work with greater than 4 GB of data? | ||||||
|  |  | ||||||
|     Yes. inflate() and deflate() will process any amount of data correctly. |     Yes. inflate() and deflate() will process any amount of data correctly. | ||||||
|     However the strm.total_in and strm_total_out counters may be limited to |     Each call of inflate() or deflate() is limited to input and output chunks | ||||||
|     4 GB. The application can easily set up its own counters updated after each |     of the maximum value that can be stored in the compiler's "unsigned int" | ||||||
|     call of inflate() or deflate() to count beyond 4 GB. compress() and |     type, but there is no limit to the number of chunks. Note however that the | ||||||
|     uncompress() may be limited to 4 GB, since they operate in a single call |     strm.total_in and strm_total_out counters may be limited to 4 GB. These | ||||||
|     using unsigned long lengths. gzseek() and gztell() may be limited to 4 GB |     counters are provided as a convenience and are not used internally by | ||||||
|     depending on how zlib is compiled. |     inflate() or deflate(). The application can easily set up its own counters | ||||||
|  |     updated after each call of inflate() or deflate() to count beyond 4 GB. | ||||||
|  |     compress() and uncompress() may be limited to 4 GB, since they operate in a | ||||||
|  |     single call. gzseek() and gztell() may be limited to 4 GB depending on how | ||||||
|  |     zlib is compiled. See the zlibCompileFlags() function in zlib.h. | ||||||
|  |  | ||||||
|  |     The word "may" appears several times above since there is a 4 GB limit | ||||||
|  |     only if the compiler's "long" type is 32 bits. If the compiler's "long" | ||||||
|  |     type is 64 bits, then the limit is 16 exabytes. | ||||||
|  |  | ||||||
| 31. Does zlib have any security vulnerabilities? | 31. Does zlib have any security vulnerabilities? | ||||||
|  |  | ||||||
| @@ -228,7 +239,8 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html | |||||||
|     hand, if zlib is compiled to use snprintf() or vsnprintf(), which should |     hand, if zlib is compiled to use snprintf() or vsnprintf(), which should | ||||||
|     normally be the case, then there is no vulnerability. The ./configure |     normally be the case, then there is no vulnerability. The ./configure | ||||||
|     script will display warnings if an insecure variation of sprintf() will |     script will display warnings if an insecure variation of sprintf() will | ||||||
|     be used by gzprintf(). |     be used by gzprintf(). Also the zlibCompileFlags() function will return | ||||||
|  |     information on what variant of sprintf() is used by gzprintf(). | ||||||
|  |  | ||||||
|     If you don't have snprintf() or vsnprintf() and would like one, you can |     If you don't have snprintf() or vsnprintf() and would like one, you can | ||||||
|     find a portable implementation here: |     find a portable implementation here: | ||||||
| @@ -261,9 +273,10 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html | |||||||
|  |  | ||||||
| 35. How can I encrypt/decrypt zip files with zlib? | 35. How can I encrypt/decrypt zip files with zlib? | ||||||
|  |  | ||||||
|     zlib doesn't support encryption. PKZIP encryption is very weak and can be |     zlib doesn't support encryption. The original PKZIP encryption is very weak | ||||||
|     broken with freely available programs. To get strong encryption, use gpg |     and can be broken with freely available programs. To get strong encryption, | ||||||
|     which already includes zlib compression. |     use gpg ( http://www.gnupg.org/ ) which already includes zlib compression. | ||||||
|  |     For PKZIP compatible "encryption", look at http://www.info-zip.org/ | ||||||
|  |  | ||||||
| 36. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings? | 36. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings? | ||||||
|  |  | ||||||
| @@ -279,6 +292,8 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html | |||||||
|     for), using the "gzip" transfer encoding is probably more reliable due to |     for), using the "gzip" transfer encoding is probably more reliable due to | ||||||
|     an unfortunate choice of name on the part of the HTTP 1.1 authors. |     an unfortunate choice of name on the part of the HTTP 1.1 authors. | ||||||
|  |  | ||||||
|  |     Bottom line: use the gzip format for HTTP 1.1 encoding. | ||||||
|  |  | ||||||
| 37. Does zlib support the new "Deflate64" format introduced by PKWare? | 37. Does zlib support the new "Deflate64" format introduced by PKWare? | ||||||
|  |  | ||||||
|     No. PKWare has apparently decided to keep that format proprietary, since |     No. PKWare has apparently decided to keep that format proprietary, since | ||||||
| @@ -289,4 +304,4 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html | |||||||
| 38. Can you please sign these lengthy legal documents and fax them back to us | 38. Can you please sign these lengthy legal documents and fax them back to us | ||||||
|     so that we can use your software in our product? |     so that we can use your software in our product? | ||||||
|  |  | ||||||
|     No. Go away. |     No. Go away. Shoo. | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							| @@ -24,7 +24,7 @@ LDFLAGS=libz.a | |||||||
| LDSHARED=$(CC) | LDSHARED=$(CC) | ||||||
| CPP=$(CC) -E | CPP=$(CC) -E | ||||||
|  |  | ||||||
| VER=1.2.0.1 | VER=1.2.0.3 | ||||||
| LIBS=libz.a | LIBS=libz.a | ||||||
| SHAREDLIB=libz.so | SHAREDLIB=libz.so | ||||||
|  |  | ||||||
|   | |||||||
| @@ -24,7 +24,7 @@ LDFLAGS=libz.a | |||||||
| LDSHARED=$(CC) | LDSHARED=$(CC) | ||||||
| CPP=$(CC) -E | CPP=$(CC) -E | ||||||
|  |  | ||||||
| VER=1.2.0.1 | VER=1.2.0.3 | ||||||
| LIBS=libz.a | LIBS=libz.a | ||||||
| SHAREDLIB=libz.so | SHAREDLIB=libz.so | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								README
									
									
									
									
									
								
							| @@ -1,6 +1,6 @@ | |||||||
| ZLIB DATA COMPRESSION LIBRARY | ZLIB DATA COMPRESSION LIBRARY | ||||||
|  |  | ||||||
| zlib 1.2.0.1 is a general purpose data compression library.  All the code is | zlib 1.2.0.3 is a general purpose data compression library.  All the code is | ||||||
| thread safe.  The data format used by the zlib library is described by RFCs | thread safe.  The data format used by the zlib library is described by RFCs | ||||||
| (Request for Comments) 1950 to 1952 in the files | (Request for Comments) 1950 to 1952 in the files | ||||||
| http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) | http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) | ||||||
| @@ -34,7 +34,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997 | |||||||
| issue of  Dr. Dobb's Journal; a copy of the article is available in | issue of  Dr. Dobb's Journal; a copy of the article is available in | ||||||
| http://dogma.net/markn/articles/zlibtool/zlibtool.htm | http://dogma.net/markn/articles/zlibtool/zlibtool.htm | ||||||
|  |  | ||||||
| The changes made in version 1.2.0.1 are documented in the file ChangeLog. | The changes made in version 1.2.0.3 are documented in the file ChangeLog. | ||||||
|  |  | ||||||
| Unsupported third party contributions are provided in directory "contrib". | Unsupported third party contributions are provided in directory "contrib". | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,6 +5,7 @@ | |||||||
|  |  | ||||||
| /* @(#) $Id$ */ | /* @(#) $Id$ */ | ||||||
|  |  | ||||||
|  | #define ZLIB_INTERNAL | ||||||
| #include "zlib.h" | #include "zlib.h" | ||||||
|  |  | ||||||
| #define BASE 65521L /* largest prime smaller than 65536 */ | #define BASE 65521L /* largest prime smaller than 65536 */ | ||||||
|   | |||||||
| @@ -1,9 +0,0 @@ | |||||||
| To make a shared library: |  | ||||||
|  |  | ||||||
| 1. Compile a static library |  | ||||||
| 2. Use mkexps on that to create libz.exp |  | ||||||
| 3. Apply the configure.diff patch to configure |  | ||||||
| 4. Run the new configure to make a new Makefile |  | ||||||
| 5. Use the new Makefile to make the shared library |  | ||||||
|  |  | ||||||
| Courtesy of dbakker@arrayasolutions.com |  | ||||||
| @@ -1,57 +0,0 @@ | |||||||
| *** ../orig/zlib-1.1.4/configure	Wed Jul  8 14:19:35 1998 |  | ||||||
| --- configure	Sun Feb  9 11:11:19 2003 |  | ||||||
| *************** |  | ||||||
| *** 18,23 **** |  | ||||||
| --- 18,24 ---- |  | ||||||
|   # If you have problems, try without defining CC and CFLAGS before reporting |  | ||||||
|   # an error. |  | ||||||
|    |  | ||||||
| + LDFLAGS="-L. -lz" |  | ||||||
|   LIBS=libz.a |  | ||||||
|   SHAREDLIB=libz.so |  | ||||||
|   VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` |  | ||||||
| *************** |  | ||||||
| *** 116,121 **** |  | ||||||
| --- 117,128 ---- |  | ||||||
|   	     SFLAGS=${CFLAGS-"-Kconform_pic -O"} |  | ||||||
|   	     CFLAGS=${CFLAGS-"-O"} |  | ||||||
|   	     LDSHARED=${LDSHARED-"cc -G"};; |  | ||||||
| +   AIX*)      |  | ||||||
| + 	     SFLAGS=${CFLAGS-"-O -qmaxmem=8192"} |  | ||||||
| + 	     CFLAGS=${CFLAGS-"-O -qmaxmem=8192"} |  | ||||||
| + 	     LDTESTSHARED=${LDSHARED-"cc -G"} |  | ||||||
| + 	     LDSHAREDFLAGS="-L. libz.so" |  | ||||||
| + 	     LDSHARED=${LDSHARED-"cc -G"};; |  | ||||||
|     # send working options for other systems to support@gzip.org |  | ||||||
|     *)         SFLAGS=${CFLAGS-"-O"} |  | ||||||
|   	     CFLAGS=${CFLAGS-"-O"} |  | ||||||
| *************** |  | ||||||
| *** 127,135 **** |  | ||||||
|     echo Checking for shared library support... |  | ||||||
|     # we must test in two steps (cc then ld), required at least on SunOS 4.x |  | ||||||
|     if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" && |  | ||||||
| !      test "`($LDSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then |  | ||||||
|       CFLAGS="$SFLAGS" |  | ||||||
|       LIBS="$SHAREDLIB.$VER" |  | ||||||
|       echo Building shared library $SHAREDLIB.$VER with $CC. |  | ||||||
|     elif test -z "$old_cc" -a -z "$old_cflags"; then |  | ||||||
|       echo No shared library suppport. |  | ||||||
| --- 134,143 ---- |  | ||||||
|     echo Checking for shared library support... |  | ||||||
|     # we must test in two steps (cc then ld), required at least on SunOS 4.x |  | ||||||
|     if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" && |  | ||||||
| !      test "`($LDTESTSHARED -o $test$shared_ext $test.o) 2>&1`" = ""; then |  | ||||||
|       CFLAGS="$SFLAGS" |  | ||||||
|       LIBS="$SHAREDLIB.$VER" |  | ||||||
| + 	LDFLAGS="$LDSHAREDFLAGS" |  | ||||||
|       echo Building shared library $SHAREDLIB.$VER with $CC. |  | ||||||
|     elif test -z "$old_cc" -a -z "$old_cflags"; then |  | ||||||
|       echo No shared library suppport. |  | ||||||
| *************** |  | ||||||
| *** 209,212 **** |  | ||||||
| --- 217,221 ---- |  | ||||||
|   /^exec_prefix *=/s%=.*%=$exec_prefix% |  | ||||||
|   /^libdir *=/s%=.*%=$libdir% |  | ||||||
|   /^includedir *=/s%=.*%=$includedir% |  | ||||||
| + /^LDFLAGS *=/s%=.*%=$LDFLAGS% |  | ||||||
|   " > Makefile |  | ||||||
							
								
								
									
										37
									
								
								aix/mkexps
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								aix/mkexps
									
									
									
									
									
								
							| @@ -1,37 +0,0 @@ | |||||||
| #!/bin/ksh |  | ||||||
| # |  | ||||||
| # mkexps - make export list |  | ||||||
| # This program creates an export list by combining all the "." and normal names |  | ||||||
| # into one list. |  | ||||||
| # |  | ||||||
| if [[ "$#" -ne 1 ]] |  | ||||||
| then |  | ||||||
|     print "Usage: mkexps ArchiveFile" |  | ||||||
|     exit -2 |  | ||||||
| fi |  | ||||||
| if [[ ! -f $1 ]] |  | ||||||
| then |  | ||||||
|     print "mkexps: Cannot open file \"$1\"" |  | ||||||
|     exit -1 |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| dump -g $1 | awk ' |  | ||||||
| BEGIN { |  | ||||||
|         top = 1 |  | ||||||
| } |  | ||||||
| /^[ ]*[0-9][0-9]*/ { |  | ||||||
|     if ( (n = index( $2, "." )) > 0 ) { |  | ||||||
|         export_array[ top++ ] = substr( $2, n+1, length( $2 )) |  | ||||||
|     } |  | ||||||
|     else { |  | ||||||
| 	export_array[ top++ ] = $2 |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| END { |  | ||||||
|     for ( i = 1; i < top; i++ ) |  | ||||||
|     { |  | ||||||
| 	print export_array[ i ] |  | ||||||
|     } |  | ||||||
|  |  | ||||||
| }' | sort | uniq |  | ||||||
| @@ -206,4 +206,4 @@ Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3, | |||||||
| pp. 337-343. | pp. 337-343. | ||||||
|  |  | ||||||
| ``DEFLATE Compressed Data Format Specification'' available in | ``DEFLATE Compressed Data Format Specification'' available in | ||||||
| ftp://ds.internic.net/rfc/rfc1951.txt | http://www.ietf.org/rfc/rfc1951.txt | ||||||
|   | |||||||
| @@ -5,6 +5,7 @@ | |||||||
|  |  | ||||||
| /* @(#) $Id$ */ | /* @(#) $Id$ */ | ||||||
|  |  | ||||||
|  | #define ZLIB_INTERNAL | ||||||
| #include "zlib.h" | #include "zlib.h" | ||||||
|  |  | ||||||
| /* =========================================================================== | /* =========================================================================== | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								configure
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								configure
									
									
									
									
										vendored
									
									
								
							| @@ -19,6 +19,7 @@ | |||||||
| # an error. | # an error. | ||||||
|  |  | ||||||
| LIBS=libz.a | LIBS=libz.a | ||||||
|  | LDFLAGS="-L. ${LIBS}" | ||||||
| SHAREDLIB=libz.so | SHAREDLIB=libz.so | ||||||
| VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` | VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` | ||||||
| AR=${AR-"ar rc"} | AR=${AR-"ar rc"} | ||||||
| @@ -53,6 +54,10 @@ case "$1" in | |||||||
|     esac |     esac | ||||||
| done | done | ||||||
|  |  | ||||||
|  | if [ $shared -eq 1 ]; then | ||||||
|  |   LDFLAGS="-L. ${SHAREDLIB}" | ||||||
|  | fi | ||||||
|  |  | ||||||
| test=ztest$$ | test=ztest$$ | ||||||
| cat > $test.c <<EOF | cat > $test.c <<EOF | ||||||
| extern int getchar(); | extern int getchar(); | ||||||
| @@ -123,6 +128,10 @@ else | |||||||
| 	     SFLAGS=${CFLAGS-"-KPIC -O"} | 	     SFLAGS=${CFLAGS-"-KPIC -O"} | ||||||
| 	     CFLAGS=${CFLAGS-"-O"} | 	     CFLAGS=${CFLAGS-"-O"} | ||||||
| 	     LDSHARED=${LDSHARED-"cc -G"};; | 	     LDSHARED=${LDSHARED-"cc -G"};; | ||||||
|  |   AIX*)  # Courtesy of dbakker@arrayasolutions.com | ||||||
|  | 	     SFLAGS=${CFLAGS-"-O -qmaxmem=8192"} | ||||||
|  | 	     CFLAGS=${CFLAGS-"-O -qmaxmem=8192"} | ||||||
|  | 	     LDSHARED=${LDSHARED-"xlc -G"};; | ||||||
|   # send working options for other systems to support@gzip.org |   # send working options for other systems to support@gzip.org | ||||||
|   *)         SFLAGS=${CFLAGS-"-O"} |   *)         SFLAGS=${CFLAGS-"-O"} | ||||||
| 	     CFLAGS=${CFLAGS-"-O"} | 	     CFLAGS=${CFLAGS-"-O"} | ||||||
| @@ -422,4 +431,5 @@ sed < Makefile.in " | |||||||
| /^exec_prefix *=/s%=.*%=$exec_prefix% | /^exec_prefix *=/s%=.*%=$exec_prefix% | ||||||
| /^libdir *=/s%=.*%=$libdir% | /^libdir *=/s%=.*%=$libdir% | ||||||
| /^includedir *=/s%=.*%=$includedir% | /^includedir *=/s%=.*%=$includedir% | ||||||
|  | /^LDFLAGS *=/s%=.*%=$LDFLAGS% | ||||||
| " > Makefile | " > Makefile | ||||||
|   | |||||||
							
								
								
									
										35
									
								
								contrib/iostream3/README
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								contrib/iostream3/README
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | |||||||
|  | These classes provide a C++ stream interface to the zlib library. It allows you | ||||||
|  | to do things like: | ||||||
|  |  | ||||||
|  |   gzofstream outf("blah.gz"); | ||||||
|  |   outf << "These go into the gzip file " << 123 << endl; | ||||||
|  |    | ||||||
|  | It does this by deriving a specialized stream buffer for gzipped files, which is | ||||||
|  | the way Stroustrup would have done it. :->  | ||||||
|  |  | ||||||
|  | The gzifstream and gzofstream classes were originally written by Kevin Ruland | ||||||
|  | and made available in the zlib contrib/iostream directory. The older version still | ||||||
|  | compiles under gcc 2.xx, but not under gcc 3.xx, which sparked the development of  | ||||||
|  | this version. | ||||||
|  |  | ||||||
|  | The new classes are as standard-compliant as possible, closely following the  | ||||||
|  | approach of the standard library's fstream classes. It compiles under gcc versions  | ||||||
|  | 3.2 and 3.3, but not under gcc 2.xx. This is mainly due to changes in the standard  | ||||||
|  | library naming scheme. The new version of gzifstream/gzofstream/gzfilebuf differs  | ||||||
|  | from the previous one in the following respects: | ||||||
|  | - added showmanyc | ||||||
|  | - added setbuf, with support for unbuffered output via setbuf(0,0) | ||||||
|  | - a few bug fixes of stream behavior | ||||||
|  | - gzipped output file opened with default compression level instead of maximum level | ||||||
|  | - setcompressionlevel()/strategy() members replaced by single setcompression() | ||||||
|  |  | ||||||
|  | The code is provided "as is", with the permission to use, copy, modify, distribute  | ||||||
|  | and sell it for any purpose without fee. | ||||||
|  |  | ||||||
|  | Ludwig Schwardt | ||||||
|  | <schwardt@sun.ac.za> | ||||||
|  |  | ||||||
|  | DSP Lab | ||||||
|  | Electrical & Electronic Engineering Department | ||||||
|  | University of Stellenbosch | ||||||
|  | South Africa | ||||||
							
								
								
									
										17
									
								
								contrib/iostream3/TODO
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								contrib/iostream3/TODO
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | |||||||
|  | Possible upgrades to gzfilebuf: | ||||||
|  |  | ||||||
|  | - The ability to do putback (e.g. putbackfail) | ||||||
|  |  | ||||||
|  | - The ability to seek (zlib supports this, but could be slow/tricky) | ||||||
|  |  | ||||||
|  | - Simultaneous read/write access (does it make sense?) | ||||||
|  |  | ||||||
|  | - Support for ios_base::ate open mode | ||||||
|  |  | ||||||
|  | - Locale support? | ||||||
|  |  | ||||||
|  | - Check public interface to see which calls give problems | ||||||
|  |   (due to dependence on library internals) | ||||||
|  |  | ||||||
|  | - Override operator<<(ostream&, gzfilebuf*) to allow direct copying  | ||||||
|  |   of stream buffer to stream ( i.e. os << is.rdbuf(); ) | ||||||
							
								
								
									
										50
									
								
								contrib/iostream3/test.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								contrib/iostream3/test.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | |||||||
|  | /* | ||||||
|  |  * Test program for gzifstream and gzofstream | ||||||
|  |  *  | ||||||
|  |  * by Ludwig Schwardt <schwardt@sun.ac.za> | ||||||
|  |  * original version by Kevin Ruland <kevin@rodin.wustl.edu> | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | #include "zfstream.h" | ||||||
|  | #include <iostream>      // for cout | ||||||
|  |  | ||||||
|  | int main() { | ||||||
|  |  | ||||||
|  |   gzofstream outf; | ||||||
|  |   gzifstream inf; | ||||||
|  |   char buf[80]; | ||||||
|  |    | ||||||
|  |   outf.open("test1.txt.gz"); | ||||||
|  |   outf << "The quick brown fox sidestepped the lazy canine\n"  | ||||||
|  |        << 1.3 << "\nPlan " << 9 << std::endl; | ||||||
|  |   outf.close(); | ||||||
|  |   std::cout << "Wrote the following message to 'test1.txt.gz' (check with zcat or zless):\n" | ||||||
|  |             << "The quick brown fox sidestepped the lazy canine\n" | ||||||
|  |             << 1.3 << "\nPlan " << 9 << std::endl; | ||||||
|  |    | ||||||
|  |   std::cout << "\nReading 'test1.txt.gz' (buffered) produces:\n"; | ||||||
|  |   inf.open("test1.txt.gz"); | ||||||
|  |   while (inf.getline(buf,80,'\n')) { | ||||||
|  |     std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n"; | ||||||
|  |   } | ||||||
|  |   inf.close(); | ||||||
|  |  | ||||||
|  |   outf.rdbuf()->pubsetbuf(0,0); | ||||||
|  |   outf.open("test2.txt.gz"); | ||||||
|  |   outf << setcompression(Z_NO_COMPRESSION) | ||||||
|  |        << "The quick brown fox sidestepped the lazy canine\n" | ||||||
|  |        << 1.3 << "\nPlan " << 9 << std::endl; | ||||||
|  |   outf.close(); | ||||||
|  |   std::cout << "\nWrote the same message to 'test2.txt.gz' in uncompressed form"; | ||||||
|  |  | ||||||
|  |   std::cout << "\nReading 'test2.txt.gz' (unbuffered) produces:\n"; | ||||||
|  |   inf.rdbuf()->pubsetbuf(0,0); | ||||||
|  |   inf.open("test2.txt.gz"); | ||||||
|  |   while (inf.getline(buf,80,'\n')) { | ||||||
|  |     std::cout << buf << "\t(" << inf.rdbuf()->in_avail() << " chars left in buffer)\n"; | ||||||
|  |   } | ||||||
|  |   inf.close(); | ||||||
|  |  | ||||||
|  |   return 0; | ||||||
|  |  | ||||||
|  | } | ||||||
							
								
								
									
										479
									
								
								contrib/iostream3/zfstream.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										479
									
								
								contrib/iostream3/zfstream.cc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,479 @@ | |||||||
|  | /* | ||||||
|  |  * A C++ I/O streams interface to the zlib gz* functions | ||||||
|  |  *  | ||||||
|  |  * by Ludwig Schwardt <schwardt@sun.ac.za> | ||||||
|  |  * original version by Kevin Ruland <kevin@rodin.wustl.edu> | ||||||
|  |  *  | ||||||
|  |  * This version is standard-compliant and compatible with gcc 3.x. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | #include "zfstream.h" | ||||||
|  | #include <cstring>          // for strcpy, strcat, strlen (mode strings) | ||||||
|  | #include <cstdio>           // for BUFSIZ | ||||||
|  |  | ||||||
|  | // Internal buffer sizes (default and "unbuffered" versions) | ||||||
|  | #define BIGBUFSIZE BUFSIZ | ||||||
|  | #define SMALLBUFSIZE 1 | ||||||
|  |  | ||||||
|  | /*****************************************************************************/ | ||||||
|  |  | ||||||
|  | // Default constructor | ||||||
|  | gzfilebuf::gzfilebuf()  | ||||||
|  | : file(NULL), io_mode(std::ios_base::openmode(0)), own_fd(false),  | ||||||
|  |   buffer(NULL), buffer_size(BIGBUFSIZE), own_buffer(true) | ||||||
|  | { | ||||||
|  |   // No buffers to start with | ||||||
|  |   this->disable_buffer(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Destructor | ||||||
|  | gzfilebuf::~gzfilebuf()  | ||||||
|  | { | ||||||
|  |   // Sync output buffer and close only if responsible for file | ||||||
|  |   // (i.e. attached streams should be left open at this stage) | ||||||
|  |   this->sync(); | ||||||
|  |   if (own_fd)  | ||||||
|  |     this->close(); | ||||||
|  |   // Make sure internal buffer is deallocated | ||||||
|  |   this->disable_buffer(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Set compression level and strategy | ||||||
|  | int | ||||||
|  | gzfilebuf::setcompression(int comp_level, | ||||||
|  | 			  int comp_strategy) | ||||||
|  | { | ||||||
|  |   return gzsetparams(file, comp_level, comp_strategy); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Open gzipped file | ||||||
|  | gzfilebuf*  | ||||||
|  | gzfilebuf::open(const char *name,  | ||||||
|  | 		std::ios_base::openmode mode) | ||||||
|  | { | ||||||
|  |   // Fail if file already open | ||||||
|  |   if (this->is_open())  | ||||||
|  |     return NULL; | ||||||
|  |   // Don't support simultaneous read/write access (yet) | ||||||
|  |   if ((mode & std::ios_base::in) && (mode & std::ios_base::out))  | ||||||
|  |     return NULL; | ||||||
|  |    | ||||||
|  |   // Build mode string for gzopen and check it [27.8.1.3.2] | ||||||
|  |   char char_mode[6] = "\0\0\0\0\0"; | ||||||
|  |   if (!this->open_mode(mode, char_mode)) | ||||||
|  |     return NULL; | ||||||
|  |    | ||||||
|  |   // Attempt to open file | ||||||
|  |   if ((file = gzopen(name, char_mode)) == NULL)  | ||||||
|  |     return NULL; | ||||||
|  |  | ||||||
|  |   // On success, allocate internal buffer and set flags | ||||||
|  |   this->enable_buffer(); | ||||||
|  |   io_mode = mode; | ||||||
|  |   own_fd = true; | ||||||
|  |   return this; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Attach to gzipped file | ||||||
|  | gzfilebuf* | ||||||
|  | gzfilebuf::attach(int fd, | ||||||
|  | 		  std::ios_base::openmode mode)  | ||||||
|  | { | ||||||
|  |   // Fail if file already open | ||||||
|  |   if (this->is_open())  | ||||||
|  |     return NULL; | ||||||
|  |   // Don't support simultaneous read/write access (yet) | ||||||
|  |   if ((mode & std::ios_base::in) && (mode & std::ios_base::out))  | ||||||
|  |     return NULL; | ||||||
|  |    | ||||||
|  |   // Build mode string for gzdopen and check it [27.8.1.3.2] | ||||||
|  |   char char_mode[6] = "\0\0\0\0\0"; | ||||||
|  |   if (!this->open_mode(mode, char_mode)) | ||||||
|  |     return NULL; | ||||||
|  |    | ||||||
|  |   // Attempt to attach to file | ||||||
|  |   if ((file = gzdopen(fd, char_mode)) == NULL) | ||||||
|  |     return NULL; | ||||||
|  |    | ||||||
|  |   // On success, allocate internal buffer and set flags | ||||||
|  |   this->enable_buffer(); | ||||||
|  |   io_mode = mode; | ||||||
|  |   own_fd = false; | ||||||
|  |   return this; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Close gzipped file | ||||||
|  | gzfilebuf* | ||||||
|  | gzfilebuf::close()  | ||||||
|  | { | ||||||
|  |   // Fail immediately if no file is open | ||||||
|  |   if (!this->is_open()) | ||||||
|  |     return NULL; | ||||||
|  |   // Assume success | ||||||
|  |   gzfilebuf* retval = this; | ||||||
|  |   // Attempt to sync and close gzipped file | ||||||
|  |   if (this->sync() == -1) | ||||||
|  |     retval = NULL; | ||||||
|  |   if (gzclose(file) < 0) | ||||||
|  |     retval = NULL; | ||||||
|  |   // File is now gone anyway (postcondition [27.8.1.3.8]) | ||||||
|  |   file = NULL; | ||||||
|  |   own_fd = false; | ||||||
|  |   // Destroy internal buffer if it exists | ||||||
|  |   this->disable_buffer(); | ||||||
|  |   return retval; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||||||
|  |  | ||||||
|  | // Convert int open mode to mode string | ||||||
|  | bool  | ||||||
|  | gzfilebuf::open_mode(std::ios_base::openmode mode,  | ||||||
|  | 		     char* c_mode) const | ||||||
|  | { | ||||||
|  |   bool testb = mode & std::ios_base::binary; | ||||||
|  |   bool testi = mode & std::ios_base::in; | ||||||
|  |   bool testo = mode & std::ios_base::out; | ||||||
|  |   bool testt = mode & std::ios_base::trunc; | ||||||
|  |   bool testa = mode & std::ios_base::app; | ||||||
|  |        | ||||||
|  |   // Check for valid flag combinations - see [27.8.1.3.2] (Table 92) | ||||||
|  |   // Original zfstream hardcoded the compression level to maximum here... | ||||||
|  |   // Double the time for less than 1% size improvement seems | ||||||
|  |   // excessive though - keeping it at the default level | ||||||
|  |   // To change back, just append "9" to the next three mode strings | ||||||
|  |   if (!testi && testo && !testt && !testa) | ||||||
|  |     strcpy(c_mode, "w"); | ||||||
|  |   if (!testi && testo && !testt && testa) | ||||||
|  |     strcpy(c_mode, "a"); | ||||||
|  |   if (!testi && testo && testt && !testa) | ||||||
|  |     strcpy(c_mode, "w"); | ||||||
|  |   if (testi && !testo && !testt && !testa) | ||||||
|  |     strcpy(c_mode, "r"); | ||||||
|  |   // No read/write mode yet | ||||||
|  | //  if (testi && testo && !testt && !testa) | ||||||
|  | //    strcpy(c_mode, "r+"); | ||||||
|  | //  if (testi && testo && testt && !testa) | ||||||
|  | //    strcpy(c_mode, "w+"); | ||||||
|  |  | ||||||
|  |   // Mode string should be empty for invalid combination of flags     | ||||||
|  |   if (strlen(c_mode) == 0) | ||||||
|  |     return false; | ||||||
|  |   if (testb) | ||||||
|  |     strcat(c_mode, "b"); | ||||||
|  |   return true; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Determine number of characters in internal get buffer | ||||||
|  | std::streamsize  | ||||||
|  | gzfilebuf::showmanyc() | ||||||
|  | { | ||||||
|  |   // Calls to underflow will fail if file not opened for reading | ||||||
|  |   if (!this->is_open() || !(io_mode & std::ios_base::in)) | ||||||
|  |     return -1; | ||||||
|  |   // Make sure get area is in use | ||||||
|  |   if (this->gptr() && (this->gptr() < this->egptr())) | ||||||
|  |     return std::streamsize(this->egptr() - this->gptr()); | ||||||
|  |   else | ||||||
|  |     return 0; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Fill get area from gzipped file | ||||||
|  | gzfilebuf::int_type | ||||||
|  | gzfilebuf::underflow()  | ||||||
|  | { | ||||||
|  |   // If something is left in the get area by chance, return it | ||||||
|  |   // (this shouldn't normally happen, as underflow is only supposed  | ||||||
|  |   // to be called when gptr >= egptr, but it serves as error check) | ||||||
|  |   if (this->gptr() && (this->gptr() < this->egptr())) | ||||||
|  |     return traits_type::to_int_type(*(this->gptr())); | ||||||
|  |  | ||||||
|  |   // If the file hasn't been opened for reading, produce error | ||||||
|  |   if (!this->is_open() || !(io_mode & std::ios_base::in)) | ||||||
|  |     return traits_type::eof(); | ||||||
|  |  | ||||||
|  |   // Attempt to fill internal buffer from gzipped file | ||||||
|  |   // (buffer must be guaranteed to exist...) | ||||||
|  |   int bytes_read = gzread(file, buffer, buffer_size); | ||||||
|  |   // Indicates error or EOF | ||||||
|  |   if (bytes_read <= 0) | ||||||
|  |   { | ||||||
|  |     // Reset get area | ||||||
|  |     this->setg(buffer, buffer, buffer); | ||||||
|  |     return traits_type::eof(); | ||||||
|  |   } | ||||||
|  |   // Make all bytes read from file available as get area | ||||||
|  |   this->setg(buffer, buffer, buffer + bytes_read); | ||||||
|  |    | ||||||
|  |   // Return next character in get area | ||||||
|  |   return traits_type::to_int_type(*(this->gptr())); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Write put area to gzipped file | ||||||
|  | gzfilebuf::int_type | ||||||
|  | gzfilebuf::overflow(int_type c)  | ||||||
|  | { | ||||||
|  |   // Determine whether put area is in use | ||||||
|  |   if (this->pbase()) | ||||||
|  |   { | ||||||
|  |     // Double-check pointer range | ||||||
|  |     if (this->pptr() > this->epptr() || this->pptr() < this->pbase()) | ||||||
|  |       return traits_type::eof(); | ||||||
|  |     // Add extra character to buffer if not EOF | ||||||
|  |     if (!traits_type::eq_int_type(c, traits_type::eof())) | ||||||
|  |     { | ||||||
|  |       *(this->pptr()) = traits_type::to_char_type(c); | ||||||
|  |       this->pbump(1); | ||||||
|  |     } | ||||||
|  |     // Number of characters to write to file | ||||||
|  |     int bytes_to_write = this->pptr() - this->pbase(); | ||||||
|  |     // Overflow doesn't fail if nothing is to be written | ||||||
|  |     if (bytes_to_write > 0) | ||||||
|  |     { | ||||||
|  |       // If the file hasn't been opened for writing, produce error | ||||||
|  |       if (!this->is_open() || !(io_mode & std::ios_base::out)) | ||||||
|  | 	return traits_type::eof(); | ||||||
|  |       // If gzipped file won't accept all bytes written to it, fail | ||||||
|  |       if (gzwrite(file, this->pbase(), bytes_to_write) != bytes_to_write) | ||||||
|  | 	return traits_type::eof(); | ||||||
|  |       // Reset next pointer to point to pbase on success | ||||||
|  |       this->pbump(-bytes_to_write); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   // Write extra character to file if not EOF | ||||||
|  |   else if (!traits_type::eq_int_type(c, traits_type::eof())) | ||||||
|  |   { | ||||||
|  |     // If the file hasn't been opened for writing, produce error | ||||||
|  |     if (!this->is_open() || !(io_mode & std::ios_base::out)) | ||||||
|  |       return traits_type::eof(); | ||||||
|  |     // Impromptu char buffer (allows "unbuffered" output) | ||||||
|  |     char_type last_char = traits_type::to_char_type(c); | ||||||
|  |     // If gzipped file won't accept this character, fail | ||||||
|  |     if (gzwrite(file, &last_char, 1) != 1) | ||||||
|  |       return traits_type::eof();       | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   // If you got here, you have succeeded (even if c was EOF) | ||||||
|  |   // The return value should therefore be non-EOF | ||||||
|  |   if (traits_type::eq_int_type(c, traits_type::eof())) | ||||||
|  |     return traits_type::not_eof(c); | ||||||
|  |   else | ||||||
|  |     return c; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Assign new buffer | ||||||
|  | std::streambuf*  | ||||||
|  | gzfilebuf::setbuf(char_type* p, | ||||||
|  | 		  std::streamsize n) | ||||||
|  | { | ||||||
|  |   // First make sure stuff is sync'ed, for safety | ||||||
|  |   if (this->sync() == -1) | ||||||
|  |     return NULL; | ||||||
|  |   // If buffering is turned off on purpose via setbuf(0,0), still allocate one... | ||||||
|  |   // "Unbuffered" only really refers to put [27.8.1.4.10], while get needs at | ||||||
|  |   // least a buffer of size 1 (very inefficient though, therefore make it bigger?) | ||||||
|  |   // This follows from [27.5.2.4.3]/12 (gptr needs to point at something, it seems) | ||||||
|  |   if (!p || !n) | ||||||
|  |   { | ||||||
|  |     // Replace existing buffer (if any) with small internal buffer | ||||||
|  |     this->disable_buffer(); | ||||||
|  |     buffer = NULL; | ||||||
|  |     buffer_size = 0; | ||||||
|  |     own_buffer = true; | ||||||
|  |     this->enable_buffer(); | ||||||
|  |   } | ||||||
|  |   else | ||||||
|  |   { | ||||||
|  |     // Replace existing buffer (if any) with external buffer | ||||||
|  |     this->disable_buffer(); | ||||||
|  |     buffer = p; | ||||||
|  |     buffer_size = n; | ||||||
|  |     own_buffer = false; | ||||||
|  |     this->enable_buffer(); | ||||||
|  |   } | ||||||
|  |   return this; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Write put area to gzipped file (i.e. ensures that put area is empty) | ||||||
|  | int  | ||||||
|  | gzfilebuf::sync()  | ||||||
|  | { | ||||||
|  |   return traits_type::eq_int_type(this->overflow(), traits_type::eof()) ? -1 : 0; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||||||
|  |  | ||||||
|  | // Allocate internal buffer | ||||||
|  | void  | ||||||
|  | gzfilebuf::enable_buffer()  | ||||||
|  | { | ||||||
|  |   // If internal buffer required, allocate one | ||||||
|  |   if (own_buffer && !buffer)  | ||||||
|  |   { | ||||||
|  |     // Check for buffered vs. "unbuffered" | ||||||
|  |     if (buffer_size > 0) | ||||||
|  |     { | ||||||
|  |       // Allocate internal buffer | ||||||
|  |       buffer = new char_type[buffer_size]; | ||||||
|  |       // Get area starts empty and will be expanded by underflow as need arises | ||||||
|  |       this->setg(buffer, buffer, buffer); | ||||||
|  |       // Setup entire internal buffer as put area. | ||||||
|  |       // The one-past-end pointer actually points to the last element of the buffer, | ||||||
|  |       // so that overflow(c) can safely add the extra character c to the sequence. | ||||||
|  |       // These pointers remain in place for the duration of the buffer | ||||||
|  |       this->setp(buffer, buffer + buffer_size - 1); | ||||||
|  |     } | ||||||
|  |     else | ||||||
|  |     { | ||||||
|  |       // Even in "unbuffered" case, (small?) get buffer is still required | ||||||
|  |       buffer_size = SMALLBUFSIZE; | ||||||
|  |       buffer = new char_type[buffer_size]; | ||||||
|  |       this->setg(buffer, buffer, buffer); | ||||||
|  |       // "Unbuffered" means no put buffer | ||||||
|  |       this->setp(0, 0); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |   else | ||||||
|  |   { | ||||||
|  |     // If buffer already allocated, reset buffer pointers just to make sure no  | ||||||
|  |     // stale chars are lying around | ||||||
|  |     this->setg(buffer, buffer, buffer); | ||||||
|  |     this->setp(buffer, buffer + buffer_size - 1); | ||||||
|  |   }   | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Destroy internal buffer | ||||||
|  | void  | ||||||
|  | gzfilebuf::disable_buffer()  | ||||||
|  | { | ||||||
|  |   // If internal buffer exists, deallocate it | ||||||
|  |   if (own_buffer && buffer) | ||||||
|  |   { | ||||||
|  |     // Preserve unbuffered status by zeroing size | ||||||
|  |     if (!this->pbase()) | ||||||
|  |       buffer_size = 0; | ||||||
|  |     delete[] buffer; | ||||||
|  |     buffer = NULL; | ||||||
|  |     this->setg(0, 0, 0); | ||||||
|  |     this->setp(0, 0); | ||||||
|  |   } | ||||||
|  |   else | ||||||
|  |   { | ||||||
|  |     // Reset buffer pointers to initial state if external buffer exists | ||||||
|  |     this->setg(buffer, buffer, buffer); | ||||||
|  |     if (buffer) | ||||||
|  |       this->setp(buffer, buffer + buffer_size - 1); | ||||||
|  |     else | ||||||
|  |       this->setp(0, 0); | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /*****************************************************************************/ | ||||||
|  |  | ||||||
|  | // Default constructor initializes stream buffer | ||||||
|  | gzifstream::gzifstream()  | ||||||
|  | : std::istream(NULL), sb() | ||||||
|  | { this->init(&sb); } | ||||||
|  |  | ||||||
|  | // Initialize stream buffer and open file | ||||||
|  | gzifstream::gzifstream(const char* name, | ||||||
|  | 		       std::ios_base::openmode mode) | ||||||
|  | : std::istream(NULL), sb() | ||||||
|  | { | ||||||
|  |   this->init(&sb); | ||||||
|  |   this->open(name, mode); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Initialize stream buffer and attach to file | ||||||
|  | gzifstream::gzifstream(int fd, | ||||||
|  | 		       std::ios_base::openmode mode) | ||||||
|  | : std::istream(NULL), sb() | ||||||
|  | { | ||||||
|  |   this->init(&sb); | ||||||
|  |   this->attach(fd, mode); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Open file and go into fail() state if unsuccessful | ||||||
|  | void  | ||||||
|  | gzifstream::open(const char* name,  | ||||||
|  | 		 std::ios_base::openmode mode) | ||||||
|  | { | ||||||
|  |   if (!sb.open(name, mode | std::ios_base::in)) | ||||||
|  |     this->setstate(std::ios_base::failbit); | ||||||
|  |   else | ||||||
|  |     this->clear(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Attach to file and go into fail() state if unsuccessful | ||||||
|  | void  | ||||||
|  | gzifstream::attach(int fd,  | ||||||
|  | 		   std::ios_base::openmode mode) | ||||||
|  | { | ||||||
|  |   if (!sb.attach(fd, mode | std::ios_base::in)) | ||||||
|  |     this->setstate(std::ios_base::failbit); | ||||||
|  |   else | ||||||
|  |     this->clear(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Close file | ||||||
|  | void  | ||||||
|  | gzifstream::close() | ||||||
|  | { | ||||||
|  |   if (!sb.close()) | ||||||
|  |     this->setstate(std::ios_base::failbit); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /*****************************************************************************/ | ||||||
|  |  | ||||||
|  | // Default constructor initializes stream buffer | ||||||
|  | gzofstream::gzofstream()  | ||||||
|  | : std::ostream(NULL), sb() | ||||||
|  | { this->init(&sb); } | ||||||
|  |  | ||||||
|  | // Initialize stream buffer and open file | ||||||
|  | gzofstream::gzofstream(const char* name, | ||||||
|  | 		       std::ios_base::openmode mode) | ||||||
|  | : std::ostream(NULL), sb() | ||||||
|  | { | ||||||
|  |   this->init(&sb); | ||||||
|  |   this->open(name, mode); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Initialize stream buffer and attach to file | ||||||
|  | gzofstream::gzofstream(int fd, | ||||||
|  | 		       std::ios_base::openmode mode) | ||||||
|  | : std::ostream(NULL), sb() | ||||||
|  | { | ||||||
|  |   this->init(&sb); | ||||||
|  |   this->attach(fd, mode); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Open file and go into fail() state if unsuccessful | ||||||
|  | void  | ||||||
|  | gzofstream::open(const char* name,  | ||||||
|  | 		 std::ios_base::openmode mode) | ||||||
|  | { | ||||||
|  |   if (!sb.open(name, mode | std::ios_base::out)) | ||||||
|  |     this->setstate(std::ios_base::failbit); | ||||||
|  |   else | ||||||
|  |     this->clear(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Attach to file and go into fail() state if unsuccessful | ||||||
|  | void  | ||||||
|  | gzofstream::attach(int fd,  | ||||||
|  | 		   std::ios_base::openmode mode) | ||||||
|  | { | ||||||
|  |   if (!sb.attach(fd, mode | std::ios_base::out)) | ||||||
|  |     this->setstate(std::ios_base::failbit); | ||||||
|  |   else | ||||||
|  |     this->clear(); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Close file | ||||||
|  | void  | ||||||
|  | gzofstream::close() | ||||||
|  | { | ||||||
|  |   if (!sb.close()) | ||||||
|  |     this->setstate(std::ios_base::failbit); | ||||||
|  | } | ||||||
							
								
								
									
										466
									
								
								contrib/iostream3/zfstream.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										466
									
								
								contrib/iostream3/zfstream.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,466 @@ | |||||||
|  | /* | ||||||
|  |  * A C++ I/O streams interface to the zlib gz* functions | ||||||
|  |  *  | ||||||
|  |  * by Ludwig Schwardt <schwardt@sun.ac.za> | ||||||
|  |  * original version by Kevin Ruland <kevin@rodin.wustl.edu> | ||||||
|  |  *  | ||||||
|  |  * This version is standard-compliant and compatible with gcc 3.x. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | #ifndef ZFSTREAM_H | ||||||
|  | #define ZFSTREAM_H | ||||||
|  |  | ||||||
|  | #include <istream>  // not iostream, since we don't need cin/cout | ||||||
|  | #include <ostream> | ||||||
|  | #include "zlib.h" | ||||||
|  |  | ||||||
|  | /*****************************************************************************/ | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  *  @brief  Gzipped file stream buffer class. | ||||||
|  |  * | ||||||
|  |  *  This class implements basic_filebuf for gzipped files. It doesn't yet support | ||||||
|  |  *  seeking (allowed by zlib but slow/limited), putback and read/write access  | ||||||
|  |  *  (tricky). Otherwise, it attempts to be a drop-in replacement for the standard  | ||||||
|  |  *  file streambuf. | ||||||
|  | */ | ||||||
|  | class gzfilebuf : public std::streambuf  | ||||||
|  | { | ||||||
|  | public:    | ||||||
|  |   //  Default constructor. | ||||||
|  |   gzfilebuf(); | ||||||
|  |    | ||||||
|  |   //  Destructor. | ||||||
|  |   virtual  | ||||||
|  |   ~gzfilebuf(); | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    *  @brief  Set compression level and strategy on the fly. | ||||||
|  |    *  @param  comp_level  Compression level (see zlib.h for allowed values)  | ||||||
|  |    *  @param  comp_strategy  Compression strategy (see zlib.h for allowed values)  | ||||||
|  |    *  @return  Z_OK on success, Z_STREAM_ERROR otherwise. | ||||||
|  |    *  | ||||||
|  |    *  Unfortunately, these parameters cannot be modified separately, as the | ||||||
|  |    *  previous zfstream version assumed. Since the strategy is seldom changed, | ||||||
|  |    *  it can default and setcompression(level) then becomes like the old | ||||||
|  |    *  setcompressionlevel(level). | ||||||
|  |   */ | ||||||
|  |   int  | ||||||
|  |   setcompression(int comp_level,  | ||||||
|  | 		 int comp_strategy = Z_DEFAULT_STRATEGY); | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  @brief  Check if file is open. | ||||||
|  |    *  @return  True if file is open. | ||||||
|  |   */ | ||||||
|  |   bool  | ||||||
|  |   is_open() const { return (file != NULL); } | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  @brief  Open gzipped file. | ||||||
|  |    *  @param  name  File name. | ||||||
|  |    *  @param  mode  Open mode flags. | ||||||
|  |    *  @return  @c this on success, NULL on failure. | ||||||
|  |   */ | ||||||
|  |   gzfilebuf*  | ||||||
|  |   open(const char* name,  | ||||||
|  |        std::ios_base::openmode mode); | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  @brief  Attach to already open gzipped file. | ||||||
|  |    *  @param  fd  File descriptor. | ||||||
|  |    *  @param  mode  Open mode flags. | ||||||
|  |    *  @return  @c this on success, NULL on failure. | ||||||
|  |   */ | ||||||
|  |   gzfilebuf*  | ||||||
|  |   attach(int fd,  | ||||||
|  | 	 std::ios_base::openmode mode); | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  @brief  Close gzipped file. | ||||||
|  |    *  @return  @c this on success, NULL on failure. | ||||||
|  |   */ | ||||||
|  |   gzfilebuf*  | ||||||
|  |   close(); | ||||||
|  |     | ||||||
|  | protected: | ||||||
|  |   /** | ||||||
|  |    *  @brief  Convert ios open mode int to mode string used by zlib. | ||||||
|  |    *  @return  True if valid mode flag combination. | ||||||
|  |   */ | ||||||
|  |   bool  | ||||||
|  |   open_mode(std::ios_base::openmode mode,  | ||||||
|  | 	    char* c_mode) const; | ||||||
|  |    | ||||||
|  |   /** | ||||||
|  |    *  @brief  Number of characters available in stream buffer. | ||||||
|  |    *  @return  Number of characters. | ||||||
|  |    *  | ||||||
|  |    *  This indicates number of characters in get area of stream buffer. | ||||||
|  |    *  These characters can be read without accessing the gzipped file. | ||||||
|  |   */ | ||||||
|  |   virtual std::streamsize | ||||||
|  |   showmanyc(); | ||||||
|  |    | ||||||
|  |   /** | ||||||
|  |    *  @brief  Fill get area from gzipped file. | ||||||
|  |    *  @return  First character in get area on success, EOF on error. | ||||||
|  |    *  | ||||||
|  |    *  This actually reads characters from gzipped file to stream | ||||||
|  |    *  buffer. Always buffered. | ||||||
|  |   */ | ||||||
|  |   virtual int_type | ||||||
|  |   underflow(); | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  @brief  Write put area to gzipped file. | ||||||
|  |    *  @param  c  Extra character to add to buffer contents. | ||||||
|  |    *  @return  Non-EOF on success, EOF on error. | ||||||
|  |    *  | ||||||
|  |    *  This actually writes characters in stream buffer to  | ||||||
|  |    *  gzipped file. With unbuffered output this is done one  | ||||||
|  |    *  character at a time. | ||||||
|  |   */  | ||||||
|  |   virtual int_type  | ||||||
|  |   overflow(int_type c = traits_type::eof()); | ||||||
|  |      | ||||||
|  |   /** | ||||||
|  |    *  @brief  Installs external stream buffer. | ||||||
|  |    *  @param  p  Pointer to char buffer. | ||||||
|  |    *  @param  n  Size of external buffer. | ||||||
|  |    *  @return  @c this on success, NULL on failure. | ||||||
|  |    *  | ||||||
|  |    *  Call setbuf(0,0) to enable unbuffered output. | ||||||
|  |   */ | ||||||
|  |   virtual std::streambuf*  | ||||||
|  |   setbuf(char_type* p,  | ||||||
|  | 	 std::streamsize n); | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    *  @brief  Flush stream buffer to file. | ||||||
|  |    *  @return  0 on success, -1 on error. | ||||||
|  |    *  | ||||||
|  |    *  This calls underflow(EOF) to do the job. | ||||||
|  |   */ | ||||||
|  |   virtual int  | ||||||
|  |   sync(); | ||||||
|  |     | ||||||
|  | // | ||||||
|  | // Some future enhancements | ||||||
|  | //  | ||||||
|  | //  virtual int_type uflow(); | ||||||
|  | //  virtual int_type pbackfail(int_type c = traits_type::eof()); | ||||||
|  | //  virtual pos_type  | ||||||
|  | //  seekoff(off_type off,  | ||||||
|  | //	    std::ios_base::seekdir way, | ||||||
|  | //	    std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); | ||||||
|  | //  virtual pos_type  | ||||||
|  | //  seekpos(pos_type sp,  | ||||||
|  | //	    std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); | ||||||
|  |     | ||||||
|  | private: | ||||||
|  |   /** | ||||||
|  |    *  @brief  Allocate internal buffer. | ||||||
|  |    *  | ||||||
|  |    *  This function is safe to call multiple times. It will ensure | ||||||
|  |    *  that a proper internal buffer exists if it is required. If the | ||||||
|  |    *  buffer already exists or is external, the buffer pointers will be | ||||||
|  |    *  reset to their original state. | ||||||
|  |   */ | ||||||
|  |   void  | ||||||
|  |   enable_buffer(); | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  @brief  Destroy internal buffer. | ||||||
|  |    *  | ||||||
|  |    *  This function is safe to call multiple times. It will ensure | ||||||
|  |    *  that the internal buffer is deallocated if it exists. In any | ||||||
|  |    *  case, it will also reset the buffer pointers. | ||||||
|  |   */ | ||||||
|  |   void  | ||||||
|  |   disable_buffer(); | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  Underlying file pointer. | ||||||
|  |   */ | ||||||
|  |   gzFile file; | ||||||
|  |    | ||||||
|  |   /** | ||||||
|  |    *  Mode in which file was opened. | ||||||
|  |   */ | ||||||
|  |   std::ios_base::openmode io_mode; | ||||||
|  |    | ||||||
|  |   /** | ||||||
|  |    *  @brief  True if this object owns file descriptor. | ||||||
|  |    * | ||||||
|  |    *  This makes the class responsible for closing the file  | ||||||
|  |    *  upon destruction. | ||||||
|  |   */ | ||||||
|  |   bool own_fd; | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  @brief  Stream buffer. | ||||||
|  |    *  | ||||||
|  |    *  For simplicity this remains allocated on the free store for the  | ||||||
|  |    *  entire life span of the gzfilebuf object, unless replaced by setbuf. | ||||||
|  |   */ | ||||||
|  |   char_type* buffer; | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  @brief  Stream buffer size. | ||||||
|  |    *  | ||||||
|  |    *  Defaults to system default buffer size (typically 8192 bytes). | ||||||
|  |    *  Modified by setbuf. | ||||||
|  |   */ | ||||||
|  |   std::streamsize buffer_size; | ||||||
|  |    | ||||||
|  |   /** | ||||||
|  |    *  @brief  True if this object owns stream buffer. | ||||||
|  |    * | ||||||
|  |    *  This makes the class responsible for deleting the buffer  | ||||||
|  |    *  upon destruction. | ||||||
|  |   */ | ||||||
|  |   bool own_buffer; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | /*****************************************************************************/ | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  *  @brief  Gzipped file input stream class. | ||||||
|  |  * | ||||||
|  |  *  This class implements ifstream for gzipped files. Seeking and putback | ||||||
|  |  *  is not supported yet. | ||||||
|  | */ | ||||||
|  | class gzifstream : public std::istream  | ||||||
|  | { | ||||||
|  | public: | ||||||
|  |   //  Default constructor | ||||||
|  |   gzifstream(); | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  @brief  Construct stream on gzipped file to be opened. | ||||||
|  |    *  @param  name  File name. | ||||||
|  |    *  @param  mode  Open mode flags (forced to contain ios::in). | ||||||
|  |   */ | ||||||
|  |   explicit | ||||||
|  |   gzifstream(const char* name,  | ||||||
|  | 	     std::ios_base::openmode mode = std::ios_base::in); | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  @brief  Construct stream on already open gzipped file. | ||||||
|  |    *  @param  fd    File descriptor. | ||||||
|  |    *  @param  mode  Open mode flags (forced to contain ios::in). | ||||||
|  |   */ | ||||||
|  |   explicit  | ||||||
|  |   gzifstream(int fd,  | ||||||
|  | 	     std::ios_base::openmode mode = std::ios_base::in); | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    *  Obtain underlying stream buffer. | ||||||
|  |   */   | ||||||
|  |   gzfilebuf*  | ||||||
|  |   rdbuf() const | ||||||
|  |   { return const_cast<gzfilebuf*>(&sb); }   | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    *  @brief  Check if file is open. | ||||||
|  |    *  @return  True if file is open. | ||||||
|  |   */ | ||||||
|  |   bool  | ||||||
|  |   is_open() { return sb.is_open(); } | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  @brief  Open gzipped file. | ||||||
|  |    *  @param  name  File name. | ||||||
|  |    *  @param  mode  Open mode flags (forced to contain ios::in). | ||||||
|  |    *   | ||||||
|  |    *  Stream will be in state good() if file opens successfully; | ||||||
|  |    *  otherwise in state fail(). This differs from the behavior of | ||||||
|  |    *  ifstream, which never sets the state to good() and therefore | ||||||
|  |    *  won't allow you to reuse the stream for a second file unless | ||||||
|  |    *  you manually clear() the state. The choice is a matter of | ||||||
|  |    *  convenience. | ||||||
|  |   */ | ||||||
|  |   void  | ||||||
|  |   open(const char* name,  | ||||||
|  |        std::ios_base::openmode mode = std::ios_base::in); | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    *  @brief  Attach to already open gzipped file. | ||||||
|  |    *  @param  fd  File descriptor. | ||||||
|  |    *  @param  mode  Open mode flags (forced to contain ios::in). | ||||||
|  |    *   | ||||||
|  |    *  Stream will be in state good() if attach succeeded; otherwise | ||||||
|  |    *  in state fail(). | ||||||
|  |   */ | ||||||
|  |   void  | ||||||
|  |   attach(int fd,  | ||||||
|  | 	 std::ios_base::openmode mode = std::ios_base::in); | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    *  @brief  Close gzipped file. | ||||||
|  |    *   | ||||||
|  |    *  Stream will be in state fail() if close failed. | ||||||
|  |   */ | ||||||
|  |   void  | ||||||
|  |   close(); | ||||||
|  |     | ||||||
|  | private: | ||||||
|  |   /** | ||||||
|  |    *  Underlying stream buffer. | ||||||
|  |   */     | ||||||
|  |   gzfilebuf sb; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | /*****************************************************************************/ | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  *  @brief  Gzipped file output stream class. | ||||||
|  |  * | ||||||
|  |  *  This class implements ofstream for gzipped files. Seeking and putback | ||||||
|  |  *  is not supported yet. | ||||||
|  | */ | ||||||
|  | class gzofstream : public std::ostream | ||||||
|  | { | ||||||
|  | public: | ||||||
|  |   //  Default constructor | ||||||
|  |   gzofstream(); | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  @brief  Construct stream on gzipped file to be opened. | ||||||
|  |    *  @param  name  File name. | ||||||
|  |    *  @param  mode  Open mode flags (forced to contain ios::out). | ||||||
|  |   */ | ||||||
|  |   explicit | ||||||
|  |   gzofstream(const char* name,  | ||||||
|  | 	     std::ios_base::openmode mode = std::ios_base::out); | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  @brief  Construct stream on already open gzipped file. | ||||||
|  |    *  @param  fd    File descriptor. | ||||||
|  |    *  @param  mode  Open mode flags (forced to contain ios::out). | ||||||
|  |   */ | ||||||
|  |   explicit  | ||||||
|  |   gzofstream(int fd,  | ||||||
|  | 	     std::ios_base::openmode mode = std::ios_base::out); | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    *  Obtain underlying stream buffer. | ||||||
|  |   */   | ||||||
|  |   gzfilebuf*  | ||||||
|  |   rdbuf() const | ||||||
|  |   { return const_cast<gzfilebuf*>(&sb); }   | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    *  @brief  Check if file is open. | ||||||
|  |    *  @return  True if file is open. | ||||||
|  |   */ | ||||||
|  |   bool  | ||||||
|  |   is_open() { return sb.is_open(); } | ||||||
|  |     | ||||||
|  |   /** | ||||||
|  |    *  @brief  Open gzipped file. | ||||||
|  |    *  @param  name  File name. | ||||||
|  |    *  @param  mode  Open mode flags (forced to contain ios::out). | ||||||
|  |    *   | ||||||
|  |    *  Stream will be in state good() if file opens successfully; | ||||||
|  |    *  otherwise in state fail(). This differs from the behavior of | ||||||
|  |    *  ofstream, which never sets the state to good() and therefore | ||||||
|  |    *  won't allow you to reuse the stream for a second file unless | ||||||
|  |    *  you manually clear() the state. The choice is a matter of | ||||||
|  |    *  convenience. | ||||||
|  |   */ | ||||||
|  |   void  | ||||||
|  |   open(const char* name,  | ||||||
|  |        std::ios_base::openmode mode = std::ios_base::out); | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    *  @brief  Attach to already open gzipped file. | ||||||
|  |    *  @param  fd  File descriptor. | ||||||
|  |    *  @param  mode  Open mode flags (forced to contain ios::out). | ||||||
|  |    *   | ||||||
|  |    *  Stream will be in state good() if attach succeeded; otherwise | ||||||
|  |    *  in state fail(). | ||||||
|  |   */ | ||||||
|  |   void  | ||||||
|  |   attach(int fd,  | ||||||
|  | 	 std::ios_base::openmode mode = std::ios_base::out); | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    *  @brief  Close gzipped file. | ||||||
|  |    *   | ||||||
|  |    *  Stream will be in state fail() if close failed. | ||||||
|  |   */ | ||||||
|  |   void  | ||||||
|  |   close(); | ||||||
|  |     | ||||||
|  | private: | ||||||
|  |   /** | ||||||
|  |    *  Underlying stream buffer. | ||||||
|  |   */     | ||||||
|  |   gzfilebuf sb; | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | /*****************************************************************************/ | ||||||
|  |    | ||||||
|  | /** | ||||||
|  |  *  @brief  Gzipped file output stream manipulator class. | ||||||
|  |  * | ||||||
|  |  *  This class defines a two-argument manipulator for gzofstream. It is used | ||||||
|  |  *  as base for the setcompression(int,int) manipulator. | ||||||
|  | */ | ||||||
|  | template<typename T1, typename T2> | ||||||
|  |   class gzomanip2 | ||||||
|  |   { | ||||||
|  |   public: | ||||||
|  |     // Allows insertor to peek at internals | ||||||
|  |     template <typename Ta, typename Tb> | ||||||
|  |       friend gzofstream&  | ||||||
|  |       operator<<(gzofstream&,  | ||||||
|  | 		 const gzomanip2<Ta,Tb>&); | ||||||
|  |       | ||||||
|  |     // Constructor | ||||||
|  |     gzomanip2(gzofstream& (*f)(gzofstream&, T1, T2), | ||||||
|  | 	      T1 v1, | ||||||
|  | 	      T2 v2); | ||||||
|  |   private: | ||||||
|  |     // Underlying manipulator function | ||||||
|  |     gzofstream& | ||||||
|  |     (*func)(gzofstream&, T1, T2); | ||||||
|  |       | ||||||
|  |     // Arguments for manipulator function  | ||||||
|  |     T1 val1; | ||||||
|  |     T2 val2; | ||||||
|  |   }; | ||||||
|  |  | ||||||
|  | /*****************************************************************************/ | ||||||
|  |    | ||||||
|  | // Manipulator function thunks through to stream buffer | ||||||
|  | inline gzofstream&  | ||||||
|  | setcompression(gzofstream &gzs, int l, int s = Z_DEFAULT_STRATEGY) | ||||||
|  | { | ||||||
|  |   (gzs.rdbuf())->setcompression(l, s); | ||||||
|  |   return gzs; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // Manipulator constructor stores arguments | ||||||
|  | template<typename T1, typename T2> | ||||||
|  |   inline  | ||||||
|  |   gzomanip2<T1,T2>::gzomanip2(gzofstream &(*f)(gzofstream &, T1, T2), | ||||||
|  | 			      T1 v1, | ||||||
|  | 			      T2 v2)  | ||||||
|  |   : func(f), val1(v1), val2(v2) | ||||||
|  |   { } | ||||||
|  |  | ||||||
|  | // Insertor applies underlying manipulator function to stream | ||||||
|  | template<typename T1, typename T2> | ||||||
|  |   inline gzofstream&  | ||||||
|  |   operator<<(gzofstream& s, const gzomanip2<T1,T2>& m)  | ||||||
|  |   { return (*m.func)(s, m.val1, m.val2); } | ||||||
|  |  | ||||||
|  | // Insert this onto stream to simplify setting of compression level | ||||||
|  | inline gzomanip2<int,int>  | ||||||
|  | setcompression(int l, int s = Z_DEFAULT_STRATEGY)  | ||||||
|  | { return gzomanip2<int,int>(&setcompression, l, s); } | ||||||
|  |  | ||||||
|  | #endif // ZFSTREAM_H | ||||||
| @@ -1,3 +1,7 @@ | |||||||
|  | Change in 0.22: (19 May 03) | ||||||
|  | - crypting support (unless you define NOCRYPT) | ||||||
|  | - append file in existing zipfile | ||||||
|  |  | ||||||
| Change in 0.21: (10 Mar 03) | Change in 0.21: (10 Mar 03) | ||||||
| - bug fixes | - bug fixes | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| /* ioapi.c -- IO base function header for compress/uncompress .zip | /* ioapi.c -- IO base function header for compress/uncompress .zip | ||||||
|    files using zlib + zip or unzip API |    files using zlib + zip or unzip API | ||||||
|  |  | ||||||
|    Version 0.21, March 10th, 2003 |    Version 0.22, May 19th, 2003 | ||||||
|  |  | ||||||
|    Copyright (C) 1998-2003 Gilles Vollant |    Copyright (C) 1998-2003 Gilles Vollant | ||||||
| */ | */ | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| /* ioapi.h -- IO base function header for compress/uncompress .zip | /* ioapi.h -- IO base function header for compress/uncompress .zip | ||||||
|    files using zlib + zip or unzip API |    files using zlib + zip or unzip API | ||||||
|  |  | ||||||
|    Version 0.21, March 10th, 2003 |    Version 0.22, May 19th, 2003 | ||||||
|  |  | ||||||
|    Copyright (C) 1998-2003 Gilles Vollant |    Copyright (C) 1998-2003 Gilles Vollant | ||||||
| */ | */ | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ | |||||||
|    files using zlib + zip or unzip API |    files using zlib + zip or unzip API | ||||||
|    This IO API version uses the Win32 API (for Microsoft Windows) |    This IO API version uses the Win32 API (for Microsoft Windows) | ||||||
|  |  | ||||||
|    Version 0.21, March 10th, 2003 |    Version 0.22, May 19th, 2003 | ||||||
|  |  | ||||||
|    Copyright (C) 1998-2003 Gilles Vollant |    Copyright (C) 1998-2003 Gilles Vollant | ||||||
| */ | */ | ||||||
|   | |||||||
| @@ -2,7 +2,7 @@ | |||||||
|    files using zlib + zip or unzip API |    files using zlib + zip or unzip API | ||||||
|    This IO API version uses the Win32 API (for Microsoft Windows) |    This IO API version uses the Win32 API (for Microsoft Windows) | ||||||
|  |  | ||||||
|    Version 0.21, March 10th, 2003 |    Version 0.22, May 19th, 2003 | ||||||
|  |  | ||||||
|    Copyright (C) 1998-2003 Gilles Vollant |    Copyright (C) 1998-2003 Gilles Vollant | ||||||
| */ | */ | ||||||
|   | |||||||
| @@ -140,13 +140,19 @@ int makedir (newdir) | |||||||
|  |  | ||||||
| void do_banner() | void do_banner() | ||||||
| { | { | ||||||
|     printf("MiniUnz 0.15, demo of zLib + Unz package written by Gilles Vollant\n"); |     printf("MiniUnz 0.22, demo of zLib + Unz package written by Gilles Vollant\n"); | ||||||
|     printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); |     printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); | ||||||
| } | } | ||||||
|  |  | ||||||
| void do_help() | void do_help() | ||||||
| { | { | ||||||
|     printf("Usage : miniunz [-exvlo] file.zip [file_to_extract]\n\n") ; |     printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.]\n\n" \ | ||||||
|  |            "  -e  Extract without pathname (junk paths)\n" \ | ||||||
|  |            "  -x  Extract with pathname\n" \ | ||||||
|  |            "  -v  list files\n" \ | ||||||
|  |            "  -l  list files\n" \ | ||||||
|  |            "  -o  overwrite files without prompting\n" \ | ||||||
|  |            "  -p  extract crypted file using password\n\n"); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -168,6 +174,7 @@ int do_list(uf) | |||||||
|         unz_file_info file_info; |         unz_file_info file_info; | ||||||
|         uLong ratio=0; |         uLong ratio=0; | ||||||
|         const char *string_method; |         const char *string_method; | ||||||
|  |         char charCrypt=' '; | ||||||
|         err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); |         err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); | ||||||
|         if (err!=UNZ_OK) |         if (err!=UNZ_OK) | ||||||
|         { |         { | ||||||
| @@ -177,6 +184,10 @@ int do_list(uf) | |||||||
|         if (file_info.uncompressed_size>0) |         if (file_info.uncompressed_size>0) | ||||||
|             ratio = (file_info.compressed_size*100)/file_info.uncompressed_size; |             ratio = (file_info.compressed_size*100)/file_info.uncompressed_size; | ||||||
|  |  | ||||||
|  |         /* display a '*' if the file is crypted */ | ||||||
|  |         if ((file_info.flag & 1) != 0) | ||||||
|  |             charCrypt='*'; | ||||||
|  |  | ||||||
|         if (file_info.compression_method==0) |         if (file_info.compression_method==0) | ||||||
|             string_method="Stored"; |             string_method="Stored"; | ||||||
|         else |         else | ||||||
| @@ -193,8 +204,10 @@ int do_list(uf) | |||||||
|         else |         else | ||||||
|             string_method="Unkn. "; |             string_method="Unkn. "; | ||||||
|  |  | ||||||
|         printf("%7lu  %6s %7lu %3lu%%  %2.2lu-%2.2lu-%2.2lu  %2.2lu:%2.2lu  %8.8lx   %s\n", |         printf("%7lu  %6s%c%7lu %3lu%%  %2.2lu-%2.2lu-%2.2lu  %2.2lu:%2.2lu  %8.8lx   %s\n", | ||||||
|                 file_info.uncompressed_size,string_method,file_info.compressed_size, |                 file_info.uncompressed_size,string_method, | ||||||
|  |                 charCrypt, | ||||||
|  |                 file_info.compressed_size, | ||||||
|                 ratio, |                 ratio, | ||||||
|                 (uLong)file_info.tmu_date.tm_mon + 1, |                 (uLong)file_info.tmu_date.tm_mon + 1, | ||||||
|                 (uLong)file_info.tmu_date.tm_mday, |                 (uLong)file_info.tmu_date.tm_mday, | ||||||
|   | |||||||
| @@ -120,13 +120,18 @@ int check_exist_file(filename) | |||||||
|  |  | ||||||
| void do_banner() | void do_banner() | ||||||
| { | { | ||||||
|     printf("MiniZip 0.15, demo of zLib + Zip package written by Gilles Vollant\n"); |     printf("MiniZip 0.22, demo of zLib + Zip package written by Gilles Vollant\n"); | ||||||
|     printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); |     printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); | ||||||
| } | } | ||||||
|  |  | ||||||
| void do_help() | void do_help() | ||||||
| { | { | ||||||
|     printf("Usage : minizip [-o] file.zip [files_to_add]\n\n") ; |     printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] file.zip [files_to_add]\n\n" \ | ||||||
|  |            "  -o  Overwrite existing file.zip\n" \ | ||||||
|  |            "  -a  Append to existing file.zip\n" \ | ||||||
|  |            "  -0  Store only\n" \ | ||||||
|  |            "  -1  Compress faster\n" \ | ||||||
|  |            "  -9  Compress better\n\n"); | ||||||
| } | } | ||||||
|  |  | ||||||
| /* calculate the CRC32 of a file, | /* calculate the CRC32 of a file, | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /* unzip.c -- IO for uncompress .zip files using zlib | /* unzip.c -- IO for uncompress .zip files using zlib | ||||||
|    Version 0.21 with encryption, March 10th, 2003 |    Version 0.22, May 19th, 2003 | ||||||
|  |  | ||||||
|    Copyright (C) 1998-2003 Gilles Vollant |    Copyright (C) 1998-2003 Gilles Vollant | ||||||
|  |  | ||||||
| @@ -88,7 +88,7 @@ woven in by Terry Thorsen 1/2003. | |||||||
|  |  | ||||||
|  |  | ||||||
| const char unz_copyright[] = | const char unz_copyright[] = | ||||||
|    " unzip 0.21 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; |    " unzip 0.22 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; | ||||||
|  |  | ||||||
| /* unz_file_info_interntal contain internal info about a file in zipfile*/ | /* unz_file_info_interntal contain internal info about a file in zipfile*/ | ||||||
| typedef struct unz_file_info_internal_s | typedef struct unz_file_info_internal_s | ||||||
| @@ -145,14 +145,14 @@ typedef struct | |||||||
|     file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current |     file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current | ||||||
|                                         file if we are decompressing it */ |                                         file if we are decompressing it */ | ||||||
|     int encrypted; |     int encrypted; | ||||||
|     #ifndef NOUNCRPYT |     #ifndef NOUNCRYPT | ||||||
|     unsigned long keys[3];     /* keys defining the pseudo-random sequence */ |     unsigned long keys[3];     /* keys defining the pseudo-random sequence */ | ||||||
|     const unsigned long* pcrc_32_tab; |     const unsigned long* pcrc_32_tab; | ||||||
|     #endif |     #endif | ||||||
| } unz_s; | } unz_s; | ||||||
|  |  | ||||||
|  |  | ||||||
| #ifndef NOUNCRPYT | #ifndef NOUNCRYPT | ||||||
| #include "crypt.h" | #include "crypt.h" | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -828,7 +828,11 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) | |||||||
|     unz_s* s; |     unz_s* s; | ||||||
|     int err; |     int err; | ||||||
|  |  | ||||||
|  |     /* We remember the 'current' position in the file so that we can jump | ||||||
|  |      * back there if we fail. | ||||||
|  |      */ | ||||||
|  |     unz_file_info cur_file_infoSaved; | ||||||
|  |     unz_file_info_internal cur_file_info_internalSaved; | ||||||
|     uLong num_fileSaved; |     uLong num_fileSaved; | ||||||
|     uLong pos_in_central_dirSaved; |     uLong pos_in_central_dirSaved; | ||||||
|  |  | ||||||
| @@ -843,25 +847,36 @@ extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) | |||||||
|     if (!s->current_file_ok) |     if (!s->current_file_ok) | ||||||
|         return UNZ_END_OF_LIST_OF_FILE; |         return UNZ_END_OF_LIST_OF_FILE; | ||||||
|  |  | ||||||
|  |     /* Save the current state */ | ||||||
|     num_fileSaved = s->num_file; |     num_fileSaved = s->num_file; | ||||||
|     pos_in_central_dirSaved = s->pos_in_central_dir; |     pos_in_central_dirSaved = s->pos_in_central_dir; | ||||||
|  |     cur_file_infoSaved = s->cur_file_info; | ||||||
|  |     cur_file_info_internalSaved = s->cur_file_info_internal; | ||||||
|  |  | ||||||
|     err = unzGoToFirstFile(file); |     err = unzGoToFirstFile(file); | ||||||
|  |  | ||||||
|     while (err == UNZ_OK) |     while (err == UNZ_OK) | ||||||
|     { |     { | ||||||
|         char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; |         char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; | ||||||
|         unzGetCurrentFileInfo(file,NULL, |         err = unzGetCurrentFileInfo(file,NULL, | ||||||
|                                 szCurrentFileName,sizeof(szCurrentFileName)-1, |                                     szCurrentFileName,sizeof(szCurrentFileName)-1, | ||||||
|                                 NULL,0,NULL,0); |                                     NULL,0,NULL,0); | ||||||
|         if (unzStringFileNameCompare(szCurrentFileName, |         if (err == UNZ_OK) | ||||||
|                                         szFileName,iCaseSensitivity)==0) |         { | ||||||
|             return UNZ_OK; |             if (unzStringFileNameCompare(szCurrentFileName, | ||||||
|         err = unzGoToNextFile(file); |                                             szFileName,iCaseSensitivity)==0) | ||||||
|  |                 return UNZ_OK; | ||||||
|  |             err = unzGoToNextFile(file); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /* We failed, so restore the state of the 'current file' to where we | ||||||
|  |      * were. | ||||||
|  |      */ | ||||||
|     s->num_file = num_fileSaved ; |     s->num_file = num_fileSaved ; | ||||||
|     s->pos_in_central_dir = pos_in_central_dirSaved ; |     s->pos_in_central_dir = pos_in_central_dirSaved ; | ||||||
|  |     s->cur_file_info = cur_file_infoSaved; | ||||||
|  |     s->cur_file_info_internal = cur_file_info_internalSaved; | ||||||
|     return err; |     return err; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -1041,7 +1056,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) | |||||||
|     file_in_zip_read_info_s* pfile_in_zip_read_info; |     file_in_zip_read_info_s* pfile_in_zip_read_info; | ||||||
|     uLong offset_local_extrafield;  /* offset of the local extra field */ |     uLong offset_local_extrafield;  /* offset of the local extra field */ | ||||||
|     uInt  size_local_extrafield;    /* size of the local extra field */ |     uInt  size_local_extrafield;    /* size of the local extra field */ | ||||||
|     #ifndef NOUNCRPYT |     #ifndef NOUNCRYPT | ||||||
|     char source[12]; |     char source[12]; | ||||||
|     #else |     #else | ||||||
|     if (password != NULL) |     if (password != NULL) | ||||||
| @@ -1114,6 +1129,8 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) | |||||||
|       pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; |       pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; | ||||||
|       pfile_in_zip_read_info->stream.zfree = (free_func)0; |       pfile_in_zip_read_info->stream.zfree = (free_func)0; | ||||||
|       pfile_in_zip_read_info->stream.opaque = (voidpf)0; |       pfile_in_zip_read_info->stream.opaque = (voidpf)0; | ||||||
|  |       pfile_in_zip_read_info->stream.next_in = (voidpf)0; | ||||||
|  |       pfile_in_zip_read_info->stream.avail_in = 0; | ||||||
|  |  | ||||||
|       err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); |       err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); | ||||||
|       if (err == Z_OK) |       if (err == Z_OK) | ||||||
| @@ -1142,7 +1159,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) | |||||||
|  |  | ||||||
|     s->pfile_in_zip_read = pfile_in_zip_read_info; |     s->pfile_in_zip_read = pfile_in_zip_read_info; | ||||||
|  |  | ||||||
|     #ifndef NOUNCRPYT |     #ifndef NOUNCRYPT | ||||||
|     if (password != NULL) |     if (password != NULL) | ||||||
|     { |     { | ||||||
|         int i; |         int i; | ||||||
| @@ -1254,7 +1271,7 @@ extern int ZEXPORT unzReadCurrentFile  (file, buf, len) | |||||||
|                 return UNZ_ERRNO; |                 return UNZ_ERRNO; | ||||||
|  |  | ||||||
|  |  | ||||||
|             #ifndef NOUNCRPYT |             #ifndef NOUNCRYPT | ||||||
|             if(s->encrypted) |             if(s->encrypted) | ||||||
|             { |             { | ||||||
|                 uInt i; |                 uInt i; | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /* unzip.h -- IO for uncompress .zip files using zlib | /* unzip.h -- IO for uncompress .zip files using zlib | ||||||
|    Version 0.21, March 10th, 2003 |    Version 0.22, May 19th, 2003 | ||||||
|  |  | ||||||
|    Copyright (C) 1998-2003 Gilles Vollant |    Copyright (C) 1998-2003 Gilles Vollant | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /* zip.c -- IO on .zip files using zlib | /* zip.c -- IO on .zip files using zlib | ||||||
|    Version 0.21, March 10th, 2003 |    Version 0.22, May 19th, 2003 | ||||||
|  |  | ||||||
|    Read zip.h for more info |    Read zip.h for more info | ||||||
| */ | */ | ||||||
| @@ -75,7 +75,7 @@ | |||||||
| #endif | #endif | ||||||
| #endif | #endif | ||||||
| const char zip_copyright[] = | const char zip_copyright[] = | ||||||
|    " zip 0.21 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; |    " zip 0.22 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; | ||||||
|  |  | ||||||
|  |  | ||||||
| #define SIZEDATA_INDATABLOCK (4096-(4*4)) | #define SIZEDATA_INDATABLOCK (4096-(4*4)) | ||||||
| @@ -123,7 +123,7 @@ typedef struct | |||||||
|     uLong dosDate; |     uLong dosDate; | ||||||
|     uLong crc32; |     uLong crc32; | ||||||
|     int  encrypt; |     int  encrypt; | ||||||
| #ifndef NOCRPYT | #ifndef NOCRYPT | ||||||
|     unsigned long keys[3];     /* keys defining the pseudo-random sequence */ |     unsigned long keys[3];     /* keys defining the pseudo-random sequence */ | ||||||
|     const unsigned long* pcrc_32_tab; |     const unsigned long* pcrc_32_tab; | ||||||
|     int crypt_header_size; |     int crypt_header_size; | ||||||
| @@ -145,7 +145,7 @@ typedef struct | |||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| #ifndef NOCRPYT | #ifndef NOCRYPT | ||||||
| #define INCLUDECRYPTINGCODE_IFCRYPTALLOWED | #define INCLUDECRYPTINGCODE_IFCRYPTALLOWED | ||||||
| #include "crypt.h" | #include "crypt.h" | ||||||
| #endif | #endif | ||||||
| @@ -671,7 +671,7 @@ extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, | |||||||
|     uInt i; |     uInt i; | ||||||
|     int err = ZIP_OK; |     int err = ZIP_OK; | ||||||
|  |  | ||||||
|     #ifdef NOCRPYT |     #ifdef NOCRYPT | ||||||
|     if (password != NULL) |     if (password != NULL) | ||||||
|         return ZIP_PARAMERROR; |         return ZIP_PARAMERROR; | ||||||
|     #endif |     #endif | ||||||
| @@ -827,26 +827,24 @@ extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, | |||||||
|  |  | ||||||
|         if (err==Z_OK) |         if (err==Z_OK) | ||||||
|             zi->ci.stream_initialised = 1; |             zi->ci.stream_initialised = 1; | ||||||
|  |  | ||||||
|         #ifndef NOCRPYT |  | ||||||
|         zi->ci.crypt_header_size = 0; |  | ||||||
|         if ((err==Z_OK) && (password != NULL)) |  | ||||||
|         { |  | ||||||
|             unsigned char bufHead[RAND_HEAD_LEN]; |  | ||||||
|             unsigned int sizeHead; |  | ||||||
|             zi->ci.encrypt = 1; |  | ||||||
|             zi->ci.pcrc_32_tab = get_crc_table(); |  | ||||||
|             /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/ |  | ||||||
|  |  | ||||||
|             sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting); |  | ||||||
|             zi->ci.crypt_header_size = sizeHead; |  | ||||||
|  |  | ||||||
|             if (ZWRITE(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead) |  | ||||||
|                     err = ZIP_ERRNO; |  | ||||||
|         } |  | ||||||
|         #endif |  | ||||||
|     } |     } | ||||||
|  |     #ifndef NOCRYPT | ||||||
|  |     zi->ci.crypt_header_size = 0; | ||||||
|  |     if ((err==Z_OK) && (password != NULL)) | ||||||
|  |     { | ||||||
|  |         unsigned char bufHead[RAND_HEAD_LEN]; | ||||||
|  |         unsigned int sizeHead; | ||||||
|  |         zi->ci.encrypt = 1; | ||||||
|  |         zi->ci.pcrc_32_tab = get_crc_table(); | ||||||
|  |         /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/ | ||||||
|  |  | ||||||
|  |         sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting); | ||||||
|  |         zi->ci.crypt_header_size = sizeHead; | ||||||
|  |  | ||||||
|  |         if (ZWRITE(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead) | ||||||
|  |                 err = ZIP_ERRNO; | ||||||
|  |     } | ||||||
|  |     #endif | ||||||
|  |  | ||||||
|     if (err==Z_OK) |     if (err==Z_OK) | ||||||
|         zi->in_opened_file_inzip = 1; |         zi->in_opened_file_inzip = 1; | ||||||
| @@ -905,11 +903,13 @@ local int zipFlushWriteBuffer(zi) | |||||||
|  |  | ||||||
|     if (zi->ci.encrypt != 0) |     if (zi->ci.encrypt != 0) | ||||||
|     { |     { | ||||||
|  | #ifndef NOCRYPT | ||||||
|         uInt i; |         uInt i; | ||||||
|         int t; |         int t; | ||||||
|         for (i=0;i<zi->ci.pos_in_buffered_data;i++) |         for (i=0;i<zi->ci.pos_in_buffered_data;i++) | ||||||
|             zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, |             zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, | ||||||
|                                        zi->ci.buffered_data[i],t); |                                        zi->ci.buffered_data[i],t); | ||||||
|  | #endif | ||||||
|     } |     } | ||||||
|     if (ZWRITE(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) |     if (ZWRITE(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) | ||||||
|                                                                     !=zi->ci.pos_in_buffered_data) |                                                                     !=zi->ci.pos_in_buffered_data) | ||||||
| @@ -1035,7 +1035,7 @@ extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32) | |||||||
|         uncompressed_size = (uLong)zi->ci.stream.total_in; |         uncompressed_size = (uLong)zi->ci.stream.total_in; | ||||||
|     } |     } | ||||||
|     compressed_size = (uLong)zi->ci.stream.total_out; |     compressed_size = (uLong)zi->ci.stream.total_out; | ||||||
|     #ifndef NOCRPYT |     #ifndef NOCRYPT | ||||||
|     compressed_size += zi->ci.crypt_header_size; |     compressed_size += zi->ci.crypt_header_size; | ||||||
|     #endif |     #endif | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| /* zip.h -- IO for compress .zip files using zlib | /* zip.h -- IO for compress .zip files using zlib | ||||||
|    Version 0.21, March 10th, 2003 |    Version 0.22, May 19th, 2003 | ||||||
|  |  | ||||||
|    Copyright (C) 1998-2003 Gilles Vollant |    Copyright (C) 1998-2003 Gilles Vollant | ||||||
|  |  | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ | |||||||
| 			<Tool | 			<Tool | ||||||
| 				Name="VCCLCompilerTool" | 				Name="VCCLCompilerTool" | ||||||
| 				Optimization="0" | 				Optimization="0" | ||||||
| 				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" | 				PreprocessorDefinitions="WIN32;ZLIB_DLL;_DEBUG;_CONSOLE" | ||||||
| 				MinimalRebuild="TRUE" | 				MinimalRebuild="TRUE" | ||||||
| 				BasicRuntimeChecks="3" | 				BasicRuntimeChecks="3" | ||||||
| 				RuntimeLibrary="5" | 				RuntimeLibrary="5" | ||||||
| @@ -63,7 +63,7 @@ | |||||||
| 				Optimization="2" | 				Optimization="2" | ||||||
| 				InlineFunctionExpansion="1" | 				InlineFunctionExpansion="1" | ||||||
| 				OmitFramePointers="TRUE" | 				OmitFramePointers="TRUE" | ||||||
| 				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" | 				PreprocessorDefinitions="WIN32;ZLIB_DLL;NDEBUG;_CONSOLE" | ||||||
| 				StringPooling="TRUE" | 				StringPooling="TRUE" | ||||||
| 				RuntimeLibrary="4" | 				RuntimeLibrary="4" | ||||||
| 				EnableFunctionLevelLinking="TRUE" | 				EnableFunctionLevelLinking="TRUE" | ||||||
|   | |||||||
| @@ -14,4 +14,9 @@ open zlibvc.sln with Microsoft Visual C++ 7.0 (Visual Studio .net) | |||||||
|  |  | ||||||
|  |  | ||||||
| Note : You don't need recompile yourself. There is compiled .LIB in | Note : You don't need recompile yourself. There is compiled .LIB in | ||||||
|   http://www.winimage.com/zLibDll |   http://www.winimage.com/zLibDll . See this page for more information | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | Gilles Vollant | ||||||
|  | info@winimage.com | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ DESCRIPTION	'"""zlib data compression library"""' | |||||||
|  |  | ||||||
| EXETYPE		WINDOWS | EXETYPE		WINDOWS | ||||||
|  |  | ||||||
| VERSION		1.20 | VERSION		1.21 | ||||||
|  |  | ||||||
| CODE    PRELOAD MOVEABLE DISCARDABLE | CODE    PRELOAD MOVEABLE DISCARDABLE | ||||||
| DATA    PRELOAD MOVEABLE SINGLE | DATA    PRELOAD MOVEABLE SINGLE | ||||||
|   | |||||||
| @@ -22,8 +22,8 @@ CPPUSEPCHFLAG = | |||||||
| FIRSTC = ADLER32.C    | FIRSTC = ADLER32.C    | ||||||
| FIRSTCPP =              | FIRSTCPP =              | ||||||
| RC = rc | RC = rc | ||||||
| CFLAGS_D_WDLL = /nologo /G2 /W3 /Zi /ALw /Od /D "_DEBUG" /D "WINDOWS" /D "ZLIB_DLL" /FR /GD /Fd"ZLIB.PDB" | CFLAGS_D_WDLL = /nologo /G2 /W3 /Zi /ALw /Od /D "_DEBUG" /D "WINDOWS" /D "ZLIB_DLL" /D "ZLIB_INTERNAL" /FR /GD /Fd"ZLIB.PDB" | ||||||
| CFLAGS_R_WDLL = /nologo /W3 /ALw /O1 /D "NDEBUG" /D "WINDOWS" /D "ZLIB_DLL" /FR /GD  | CFLAGS_R_WDLL = /nologo /W3 /ALw /O1 /D "NDEBUG" /D "WINDOWS" /D "ZLIB_DLL" /D "ZLIB_INTERNAL" /FR /GD  | ||||||
| LFLAGS_D_WDLL = /NOLOGO /ONERROR:NOEXE /NOD /PACKC:61440 /CO /NOE /ALIGN:16 /MAP:FULL | LFLAGS_D_WDLL = /NOLOGO /ONERROR:NOEXE /NOD /PACKC:61440 /CO /NOE /ALIGN:16 /MAP:FULL | ||||||
| LFLAGS_R_WDLL = /NOLOGO /ONERROR:NOEXE /NOD /PACKC:61440 /NOE /ALIGN:16 /MAP:FULL | LFLAGS_R_WDLL = /NOLOGO /ONERROR:NOEXE /NOD /PACKC:61440 /NOE /ALIGN:16 /MAP:FULL | ||||||
| LIBS_D_WDLL = oldnames libw commdlg shell olecli olesvr ldllcew | LIBS_D_WDLL = oldnames libw commdlg shell olecli olesvr ldllcew | ||||||
| @@ -74,7 +74,8 @@ COMPRESS_DEP = c:\zlib\zlib.h \ | |||||||
| 	c:\zlib\zconf.h | 	c:\zlib\zconf.h | ||||||
|  |  | ||||||
|  |  | ||||||
| CRC32_DEP = c:\zlib\zlib.h \ | CRC32_DEP = c:\zlib\zutil.h \ | ||||||
|  | 	c:\zlib\zlib.h \ | ||||||
| 	c:\zlib\zconf.h \ | 	c:\zlib\zconf.h \ | ||||||
| 	c:\zlib\crc32.h | 	c:\zlib\crc32.h | ||||||
|  |  | ||||||
| @@ -128,13 +129,15 @@ ZLIB16_RCDEP = | |||||||
| ZIP_DEP = c:\zlib\zlib.h \ | ZIP_DEP = c:\zlib\zlib.h \ | ||||||
| 	c:\zlib\zconf.h \ | 	c:\zlib\zconf.h \ | ||||||
| 	c:\zlib\zip.h \ | 	c:\zlib\zip.h \ | ||||||
| 	c:\zlib\ioapi.h | 	c:\zlib\ioapi.h \ | ||||||
|  | 	c:\zlib\crypt.h | ||||||
|  |  | ||||||
|  |  | ||||||
| UNZIP_DEP = c:\zlib\zlib.h \ | UNZIP_DEP = c:\zlib\zlib.h \ | ||||||
| 	c:\zlib\zconf.h \ | 	c:\zlib\zconf.h \ | ||||||
| 	c:\zlib\unzip.h \ | 	c:\zlib\unzip.h \ | ||||||
| 	c:\zlib\ioapi.h | 	c:\zlib\ioapi.h \ | ||||||
|  | 	c:\zlib\crypt.h | ||||||
|  |  | ||||||
|  |  | ||||||
| INFBACK_DEP = c:\zlib\zutil.h \ | INFBACK_DEP = c:\zlib\zutil.h \ | ||||||
|   | |||||||
| @@ -3,8 +3,8 @@ | |||||||
|  |  | ||||||
| #define IDR_VERSION1  1 | #define IDR_VERSION1  1 | ||||||
| IDR_VERSION1	VERSIONINFO	MOVEABLE IMPURE LOADONCALL DISCARDABLE | IDR_VERSION1	VERSIONINFO	MOVEABLE IMPURE LOADONCALL DISCARDABLE | ||||||
|   FILEVERSION	 1,2,0,0 |   FILEVERSION	 1,2,1,0 | ||||||
|   PRODUCTVERSION 1,2,0,0 |   PRODUCTVERSION 1,2,1,0 | ||||||
|   FILEFLAGSMASK	VS_FFI_FILEFLAGSMASK |   FILEFLAGSMASK	VS_FFI_FILEFLAGSMASK | ||||||
|   FILEFLAGS	0 |   FILEFLAGS	0 | ||||||
|   FILEOS	VOS_DOS_WINDOWS16 |   FILEOS	VOS_DOS_WINDOWS16 | ||||||
| @@ -18,7 +18,7 @@ BEGIN | |||||||
|  |  | ||||||
|     BEGIN |     BEGIN | ||||||
|       VALUE "FileDescription", "zlib data compression library\0" |       VALUE "FileDescription", "zlib data compression library\0" | ||||||
|       VALUE "FileVersion",	"1.2.0\0" |       VALUE "FileVersion",	"1.2.1\0" | ||||||
|       VALUE "InternalName",	"zlib16\0" |       VALUE "InternalName",	"zlib16\0" | ||||||
|       VALUE "OriginalFilename",	"zlib16.dll\0" |       VALUE "OriginalFilename",	"zlib16.dll\0" | ||||||
|       VALUE "ProductName",	"ZLib16.DLL\0" |       VALUE "ProductName",	"ZLib16.DLL\0" | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ | |||||||
| 			<Tool | 			<Tool | ||||||
| 				Name="VCCLCompilerTool" | 				Name="VCCLCompilerTool" | ||||||
| 				Optimization="0" | 				Optimization="0" | ||||||
| 				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" | 				PreprocessorDefinitions="WIN32;ZLIB_DLL;_DEBUG;_CONSOLE" | ||||||
| 				MinimalRebuild="TRUE" | 				MinimalRebuild="TRUE" | ||||||
| 				BasicRuntimeChecks="3" | 				BasicRuntimeChecks="3" | ||||||
| 				RuntimeLibrary="5" | 				RuntimeLibrary="5" | ||||||
| @@ -63,7 +63,7 @@ | |||||||
| 				Optimization="2" | 				Optimization="2" | ||||||
| 				InlineFunctionExpansion="1" | 				InlineFunctionExpansion="1" | ||||||
| 				OmitFramePointers="TRUE" | 				OmitFramePointers="TRUE" | ||||||
| 				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" | 				PreprocessorDefinitions="WIN32;ZLIB_DLL;NDEBUG;_CONSOLE" | ||||||
| 				StringPooling="TRUE" | 				StringPooling="TRUE" | ||||||
| 				RuntimeLibrary="4" | 				RuntimeLibrary="4" | ||||||
| 				EnableFunctionLevelLinking="TRUE" | 				EnableFunctionLevelLinking="TRUE" | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ | |||||||
| 			<Tool | 			<Tool | ||||||
| 				Name="VCCLCompilerTool" | 				Name="VCCLCompilerTool" | ||||||
| 				Optimization="0" | 				Optimization="0" | ||||||
| 				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" | 				PreprocessorDefinitions="WIN32;ZLIB_DLL;_DEBUG;_CONSOLE" | ||||||
| 				MinimalRebuild="TRUE" | 				MinimalRebuild="TRUE" | ||||||
| 				BasicRuntimeChecks="3" | 				BasicRuntimeChecks="3" | ||||||
| 				RuntimeLibrary="5" | 				RuntimeLibrary="5" | ||||||
| @@ -63,7 +63,7 @@ | |||||||
| 				Optimization="2" | 				Optimization="2" | ||||||
| 				InlineFunctionExpansion="1" | 				InlineFunctionExpansion="1" | ||||||
| 				OmitFramePointers="TRUE" | 				OmitFramePointers="TRUE" | ||||||
| 				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" | 				PreprocessorDefinitions="WIN32;ZLIB_DLL;NDEBUG;_CONSOLE" | ||||||
| 				StringPooling="TRUE" | 				StringPooling="TRUE" | ||||||
| 				RuntimeLibrary="4" | 				RuntimeLibrary="4" | ||||||
| 				EnableFunctionLevelLinking="TRUE" | 				EnableFunctionLevelLinking="TRUE" | ||||||
|   | |||||||
| @@ -2,8 +2,8 @@ | |||||||
|  |  | ||||||
| #define IDR_VERSION1  1 | #define IDR_VERSION1  1 | ||||||
| IDR_VERSION1	VERSIONINFO	MOVEABLE IMPURE LOADONCALL DISCARDABLE | IDR_VERSION1	VERSIONINFO	MOVEABLE IMPURE LOADONCALL DISCARDABLE | ||||||
|   FILEVERSION	 1,2,0,0 |   FILEVERSION	 1,2,1,0 | ||||||
|   PRODUCTVERSION 1,2,0,0 |   PRODUCTVERSION 1,2,1,0 | ||||||
|   FILEFLAGSMASK	VS_FFI_FILEFLAGSMASK |   FILEFLAGSMASK	VS_FFI_FILEFLAGSMASK | ||||||
|   FILEFLAGS	0 |   FILEFLAGS	0 | ||||||
|   FILEOS	VOS_DOS_WINDOWS32 |   FILEOS	VOS_DOS_WINDOWS32 | ||||||
| @@ -17,7 +17,7 @@ BEGIN | |||||||
|  |  | ||||||
|     BEGIN |     BEGIN | ||||||
|       VALUE "FileDescription", "zlib data compression library\0" |       VALUE "FileDescription", "zlib data compression library\0" | ||||||
|       VALUE "FileVersion",	"1.2.0.0\0" |       VALUE "FileVersion",	"1.2.1.0\0" | ||||||
|       VALUE "InternalName",	"zlib\0" |       VALUE "InternalName",	"zlib\0" | ||||||
|       VALUE "OriginalFilename",	"zlib.dll\0" |       VALUE "OriginalFilename",	"zlib.dll\0" | ||||||
|       VALUE "ProductName",	"ZLib.DLL\0" |       VALUE "ProductName",	"ZLib.DLL\0" | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ | |||||||
| 			<Tool | 			<Tool | ||||||
| 				Name="VCCLCompilerTool" | 				Name="VCCLCompilerTool" | ||||||
| 				Optimization="0" | 				Optimization="0" | ||||||
| 				PreprocessorDefinitions="WIN32" | 				PreprocessorDefinitions="WIN32;ZLIB_DLL" | ||||||
| 				ExceptionHandling="FALSE" | 				ExceptionHandling="FALSE" | ||||||
| 				RuntimeLibrary="5" | 				RuntimeLibrary="5" | ||||||
| 				PrecompiledHeaderFile=".\zlibstatDebug/zlibstat.pch" | 				PrecompiledHeaderFile=".\zlibstatDebug/zlibstat.pch" | ||||||
| @@ -61,7 +61,7 @@ | |||||||
| 			<Tool | 			<Tool | ||||||
| 				Name="VCCLCompilerTool" | 				Name="VCCLCompilerTool" | ||||||
| 				InlineFunctionExpansion="1" | 				InlineFunctionExpansion="1" | ||||||
| 				PreprocessorDefinitions="WIN32" | 				PreprocessorDefinitions="WIN32;ZLIB_DLL" | ||||||
| 				StringPooling="TRUE" | 				StringPooling="TRUE" | ||||||
| 				ExceptionHandling="FALSE" | 				ExceptionHandling="FALSE" | ||||||
| 				RuntimeLibrary="4" | 				RuntimeLibrary="4" | ||||||
| @@ -102,7 +102,7 @@ | |||||||
| 			<Tool | 			<Tool | ||||||
| 				Name="VCCLCompilerTool" | 				Name="VCCLCompilerTool" | ||||||
| 				InlineFunctionExpansion="1" | 				InlineFunctionExpansion="1" | ||||||
| 				PreprocessorDefinitions="WIN32,ASMV" | 				PreprocessorDefinitions="WIN32;ZLIB_DLL,ASMV" | ||||||
| 				StringPooling="TRUE" | 				StringPooling="TRUE" | ||||||
| 				ExceptionHandling="FALSE" | 				ExceptionHandling="FALSE" | ||||||
| 				RuntimeLibrary="4" | 				RuntimeLibrary="4" | ||||||
| @@ -144,7 +144,7 @@ | |||||||
| 			<Tool | 			<Tool | ||||||
| 				Name="VCCLCompilerTool" | 				Name="VCCLCompilerTool" | ||||||
| 				InlineFunctionExpansion="1" | 				InlineFunctionExpansion="1" | ||||||
| 				PreprocessorDefinitions="WIN32" | 				PreprocessorDefinitions="WIN32;ZLIB_DLL" | ||||||
| 				StringPooling="TRUE" | 				StringPooling="TRUE" | ||||||
| 				ExceptionHandling="FALSE" | 				ExceptionHandling="FALSE" | ||||||
| 				RuntimeLibrary="4" | 				RuntimeLibrary="4" | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| LIBRARY		"zlib" | LIBRARY		"zlib" | ||||||
|  |  | ||||||
| VERSION		1.20 | VERSION		1.21 | ||||||
|  |  | ||||||
| HEAPSIZE	1048576,8192 | HEAPSIZE	1048576,8192 | ||||||
|  |  | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ | |||||||
| 			<Tool | 			<Tool | ||||||
| 				Name="VCCLCompilerTool" | 				Name="VCCLCompilerTool" | ||||||
| 				Optimization="0" | 				Optimization="0" | ||||||
| 				PreprocessorDefinitions="WIN32,ASMV" | 				PreprocessorDefinitions="WIN32,ZLIB_DLL,ASMV" | ||||||
| 				ExceptionHandling="FALSE" | 				ExceptionHandling="FALSE" | ||||||
| 				RuntimeLibrary="1" | 				RuntimeLibrary="1" | ||||||
| 				PrecompiledHeaderFile=".\DebugDll/zlibvc.pch" | 				PrecompiledHeaderFile=".\DebugDll/zlibvc.pch" | ||||||
| @@ -76,7 +76,7 @@ | |||||||
| 			<Tool | 			<Tool | ||||||
| 				Name="VCCLCompilerTool" | 				Name="VCCLCompilerTool" | ||||||
| 				InlineFunctionExpansion="1" | 				InlineFunctionExpansion="1" | ||||||
| 				PreprocessorDefinitions="WIN32" | 				PreprocessorDefinitions="WIN32,ZLIB_DLL" | ||||||
| 				StringPooling="TRUE" | 				StringPooling="TRUE" | ||||||
| 				ExceptionHandling="FALSE" | 				ExceptionHandling="FALSE" | ||||||
| 				RuntimeLibrary="0" | 				RuntimeLibrary="0" | ||||||
| @@ -138,7 +138,7 @@ | |||||||
| 			<Tool | 			<Tool | ||||||
| 				Name="VCCLCompilerTool" | 				Name="VCCLCompilerTool" | ||||||
| 				InlineFunctionExpansion="1" | 				InlineFunctionExpansion="1" | ||||||
| 				PreprocessorDefinitions="WIN32,ASMV" | 				PreprocessorDefinitions="WIN32,ZLIB_DLL,ASMV" | ||||||
| 				StringPooling="TRUE" | 				StringPooling="TRUE" | ||||||
| 				ExceptionHandling="FALSE" | 				ExceptionHandling="FALSE" | ||||||
| 				RuntimeLibrary="0" | 				RuntimeLibrary="0" | ||||||
| @@ -200,7 +200,7 @@ | |||||||
| 			<Tool | 			<Tool | ||||||
| 				Name="VCCLCompilerTool" | 				Name="VCCLCompilerTool" | ||||||
| 				InlineFunctionExpansion="1" | 				InlineFunctionExpansion="1" | ||||||
| 				PreprocessorDefinitions="WIN32" | 				PreprocessorDefinitions="WIN32,ZLIB_DLL" | ||||||
| 				StringPooling="TRUE" | 				StringPooling="TRUE" | ||||||
| 				ExceptionHandling="FALSE" | 				ExceptionHandling="FALSE" | ||||||
| 				RuntimeLibrary="0" | 				RuntimeLibrary="0" | ||||||
| @@ -260,7 +260,7 @@ | |||||||
| 			<Tool | 			<Tool | ||||||
| 				Name="VCCLCompilerTool" | 				Name="VCCLCompilerTool" | ||||||
| 				InlineFunctionExpansion="1" | 				InlineFunctionExpansion="1" | ||||||
| 				PreprocessorDefinitions="WIN32,ASMV" | 				PreprocessorDefinitions="WIN32,ZLIB_DLL,ASMV" | ||||||
| 				StringPooling="TRUE" | 				StringPooling="TRUE" | ||||||
| 				ExceptionHandling="FALSE" | 				ExceptionHandling="FALSE" | ||||||
| 				RuntimeLibrary="0" | 				RuntimeLibrary="0" | ||||||
| @@ -379,9 +379,23 @@ | |||||||
| 			</File> | 			</File> | ||||||
| 			<File | 			<File | ||||||
| 				RelativePath=".\unzip.c"> | 				RelativePath=".\unzip.c"> | ||||||
|  | 				<FileConfiguration | ||||||
|  | 					Name="Release|Win32"> | ||||||
|  | 					<Tool | ||||||
|  | 						Name="VCCLCompilerTool" | ||||||
|  | 						AdditionalIncludeDirectories="" | ||||||
|  | 						PreprocessorDefinitions="ZLIB_INTERNAL"/> | ||||||
|  | 				</FileConfiguration> | ||||||
| 			</File> | 			</File> | ||||||
| 			<File | 			<File | ||||||
| 				RelativePath=".\zip.c"> | 				RelativePath=".\zip.c"> | ||||||
|  | 				<FileConfiguration | ||||||
|  | 					Name="Release|Win32"> | ||||||
|  | 					<Tool | ||||||
|  | 						Name="VCCLCompilerTool" | ||||||
|  | 						AdditionalIncludeDirectories="" | ||||||
|  | 						PreprocessorDefinitions="ZLIB_INTERNAL"/> | ||||||
|  | 				</FileConfiguration> | ||||||
| 			</File> | 			</File> | ||||||
| 			<File | 			<File | ||||||
| 				RelativePath=".\zlib.rc"> | 				RelativePath=".\zlib.rc"> | ||||||
|   | |||||||
							
								
								
									
										257
									
								
								contrib/zlib_dll_FAQ.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										257
									
								
								contrib/zlib_dll_FAQ.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,257 @@ | |||||||
|  |  | ||||||
|  |             Frequently Asked Questions about ZLIB.DLL | ||||||
|  |  | ||||||
|  |  | ||||||
|  | This FAQ is about the design, the rationale, and the use of | ||||||
|  | ZLIB.DLL. If you have general questions about zlib, you should | ||||||
|  | check the file "FAQ" found in the zlib distribution, or at the | ||||||
|  | location http://www.gzip.org/zlib/zlib_faq.html | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  1. Why am I having problems using ZLIB.DLL? My application works | ||||||
|  |     with the static build of zlib just fine, and I didn't make any | ||||||
|  |     modification when recompiling it for ZLIB.DLL. | ||||||
|  |  | ||||||
|  |   - Make sure you define ZLIB_DLL before including "zlib.h". | ||||||
|  |     Applications that link to ZLIB.DLL will work properly if | ||||||
|  |     the source files are compiled in this (or in a compatible) | ||||||
|  |     way, and the executables are linked to MSVCRT.DLL. | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  2. Why do I have to do this? When I use other libraries, I can | ||||||
|  |     link my code to their static or dynamic versions, without | ||||||
|  |     needing any source code modification or recompilation. | ||||||
|  |  | ||||||
|  |   - In order to preserve the backwards compatibility with the | ||||||
|  |     older versions of ZLIB.DLL, and give the ability to use zlib | ||||||
|  |     to the non-C programmers at the same time, we had to do this | ||||||
|  |     compromise. | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  3. What exactly is this mess about, and why is it happening? | ||||||
|  |  | ||||||
|  |   - It's about the calling convention used for the zlib functions. | ||||||
|  |     If linked in statically, zlib uses the C (CDECL) convention. | ||||||
|  |     If linked in dynamically (via ZLIB.DLL), it uses the STDCALL | ||||||
|  |     convention. The ZLIB_DLL macro switches on the use of STDCALL. | ||||||
|  |  | ||||||
|  |     It happens because we need to preserve compatibility with the | ||||||
|  |     old releases of ZLIB.DLL that use STDCALL, and, at the same | ||||||
|  |     time, we must provide support for programmers who use other | ||||||
|  |     programming languages with bindings that require CDECL. | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  4. Why not use the STDCALL convention all the time? | ||||||
|  |     It's the standard convention in Win32, and I need it in my | ||||||
|  |     Visual Basic project! | ||||||
|  |  | ||||||
|  |   - Most of the Win32 API functions (without varargs) use indeed | ||||||
|  |     the STDCALL (WINAPI) convention, but the standard C functions | ||||||
|  |     use the default CDECL. If one calls Win32 functions such as | ||||||
|  |     CreateFile(), sometimes it makes sense to decorate one's own | ||||||
|  |     functions with STDCALL. But if one is aiming at ANSI C or | ||||||
|  |     POSIX portability, and calls functions such as fopen(), it is | ||||||
|  |     not a sound decision to include <windows.h> or to use non-ANSI | ||||||
|  |     constructs only to make one's functions STDCALL-able. This is | ||||||
|  |     not the biggest problem, however. | ||||||
|  |  | ||||||
|  |     Technically, STDCALL is not bad; it is even a little faster | ||||||
|  |     than CDECL. The problem of using STDCALL is actually a problem | ||||||
|  |     of using any explicit calling convention. FASTCALL falls into | ||||||
|  |     the same category. | ||||||
|  |  | ||||||
|  |     Explicit specification of calling conventions, whether it's | ||||||
|  |     direct or indirect via a macro, happens commonly in Windows, | ||||||
|  |     but it is regarded as a noisy, non-standard C quirk on other | ||||||
|  |     platforms. It isn't possible to write an ANSI C -conforming | ||||||
|  |     program, for example, if it is necessary to specify calling | ||||||
|  |     conventions. Libraries can hide the dirty stuff in header | ||||||
|  |     files, under macros, but callbacks will still remain exposed. | ||||||
|  |     This is why the zlib callbacks will not be decorated. | ||||||
|  |     (The old Windows callbacks, such as WndProc, are decorated, | ||||||
|  |     but the newer ones are not.) | ||||||
|  |  | ||||||
|  |     There is one more problem with explicit, non-default calling | ||||||
|  |     conventions: the ability to use zlib in other programming | ||||||
|  |     languages. Some of them, like Ada (GNAT) and Fortran (GNU G77) | ||||||
|  |     have C bindings implemented initially on Unix, hence relying | ||||||
|  |     on the C calling convention. | ||||||
|  |  | ||||||
|  |     So we are decorating the functions using STDCALL in ZLIB.DLL | ||||||
|  |     to maintain compatibility with the old versions, but we are | ||||||
|  |     using the default CDECL in the static library, to allow other | ||||||
|  |     programming languages to use zlib in a portable fashion, via | ||||||
|  |     C bindings. | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  5. Why not use the default (CDECL) convention all the time? | ||||||
|  |     It's the standard convention in C, and I need it in my Ada | ||||||
|  |     project! | ||||||
|  |  | ||||||
|  |   - Originally, ZLIB.DLL was intended to run under Visual Basic, | ||||||
|  |     and VB6 and earlier need STDCALL. | ||||||
|  |  | ||||||
|  |     We admit that cluttering the main zlib sources, for the sake | ||||||
|  |     of interfacing with Visual Basic and at the expense of other | ||||||
|  |     programming languages, is not fair. It would have been better | ||||||
|  |     to maintain a "VB-only" project in the contrib/ directory, and | ||||||
|  |     to build a custom ZLIBVB.DLL, for example -- as we did with | ||||||
|  |     the Delphi projects. Another possible solution would have been | ||||||
|  |     to build STDCALL wrappers around the CDECL-exported functions. | ||||||
|  |  | ||||||
|  |     But this was the accident that we have to live with, in order | ||||||
|  |     to maintain binary compatibility with the older versions of | ||||||
|  |     ZLIB.DLL. | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  6. If my application uses ZLIB.DLL, do I have to link it to | ||||||
|  |     MSVCRT.DLL? Why? | ||||||
|  |  | ||||||
|  |   - The executables (.EXE, .DLL, etc.) that are involved in the | ||||||
|  |     same process and are using the C run-time library (i.e. they | ||||||
|  |     are calling any standard C function), must link to the same | ||||||
|  |     library. There are several libraries in the Win32 system: | ||||||
|  |     CRTDLL.DLL, MSVCRT.DLL, the static C libraries, etc. | ||||||
|  |     Since ZLIB.DLL is linked to MSVCRT.DLL, the executables that | ||||||
|  |     depend on it must also link to MSVCRT.DLL. | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  7. Why are you saying that ZLIB.DLL and my application must be | ||||||
|  |     linked to the same C run-time library (CRT)? I linked my | ||||||
|  |     application and my DLLs to different C libraries (e.g. my | ||||||
|  |     application to a static library, and my DLLs to MSVCRT.DLL), | ||||||
|  |     and everything works fine. | ||||||
|  |  | ||||||
|  |   - If a library invokes only pure Win32 API (i.e. accessible | ||||||
|  |     via <windows.h>), its DLL build will work in any context. | ||||||
|  |     But if a library invokes standard C functions, things get | ||||||
|  |     more complicated. | ||||||
|  |  | ||||||
|  |     There is a single Win32 library in a Win32 system. Every | ||||||
|  |     function in this library resides in a single DLL module, that | ||||||
|  |     is safe to call from anywhere. On the other hand, there are | ||||||
|  |     multiple versions of the C library that are all at the same | ||||||
|  |     time in the system, and all of them have internal states, | ||||||
|  |     therefore it is dangerous to intermix them with each other. | ||||||
|  |  | ||||||
|  |     Intermixing multiple C libraries is possible, as long as their | ||||||
|  |     internal states are kept intact. The Microsoft Knowledge Base | ||||||
|  |     article Q140584 "HOWTO: Link with the Correct C Run-Time (CRT) | ||||||
|  |     Library" enumerates some of the potential problems raised by | ||||||
|  |     intermixing, but does not offer a complete description of how | ||||||
|  |     to avoid them, except by advising not to mix the C libraries. | ||||||
|  |     If you can send us more information about this issue, we will | ||||||
|  |     highly appreciate it. (But please do NOT send us source code | ||||||
|  |     from Microsoft, even if it comes with your legitimate copy of | ||||||
|  |     Visual C++!) | ||||||
|  |  | ||||||
|  |     If this kind of intermixing works for you, it's because your | ||||||
|  |     application and DLLs are avoiding the corruption of the CRT's | ||||||
|  |     internal states, due to a fortunate accident. It's not because | ||||||
|  |     those libraries really work together. | ||||||
|  |  | ||||||
|  |     Also note that linking ZLIB.DLL to non-Microsoft C libraries | ||||||
|  |     (such as Borland's) raises similar problems. | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  8. Why are you linking ZLIB.DLL to MSVCRT.DLL? | ||||||
|  |  | ||||||
|  |   - MSVCRT.DLL exists on every Windows 95 with a new service pack | ||||||
|  |     installed, or with Microsoft Internet Explorer 4 or later, and | ||||||
|  |     on all other Windows 4.x or later (Windows 98, Windows NT 4, | ||||||
|  |     or later). It is freely distributable; if not present in the | ||||||
|  |     system, it can be downloaded from Microsoft or from other | ||||||
|  |     software provider for free. | ||||||
|  |  | ||||||
|  |     The fact that MSVCRT.DLL does not exist on a virgin Windows 95 | ||||||
|  |     is not so problematic. The number of Windows 95 installations | ||||||
|  |     is rapidly decreasing, Microsoft stopped supporting it a long | ||||||
|  |     time ago, and many recent applications from various vendors | ||||||
|  |     including Microsoft, do not even run on it. Even without these | ||||||
|  |     arguments, no serious user should run Windows 95 without a | ||||||
|  |     proper update installed. | ||||||
|  |  | ||||||
|  |     There is also the fact that the mainstream C compilers for | ||||||
|  |     Windows are Microsoft Visual C++ 6.0, and gcc/MinGW. Both | ||||||
|  |     are producing executables that link to MSVCRT.DLL by default, | ||||||
|  |     without offering other dynamic CRTs as alternatives easy to | ||||||
|  |     select by users. | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  9. Why are you not linking ZLIB.DLL to | ||||||
|  |     <<my favorite C run-time library>> ? | ||||||
|  |  | ||||||
|  |   - We considered and abandoned the following alternatives: | ||||||
|  |  | ||||||
|  |     * Linking ZLIB.DLL to a static C library (LIBC.LIB, or | ||||||
|  |       LIBCMT.LIB) is not a good option. People are using ZLIB.DLL | ||||||
|  |       mainly to save disk space. If you are linking your program | ||||||
|  |       to a static C library, you may as well consider linking zlib | ||||||
|  |       in statically, too. | ||||||
|  |  | ||||||
|  |     * Linking ZLIB.DLL to CRTDLL.DLL looks very appealing, | ||||||
|  |       because CRTDLL.DLL is present on every Win32 installation. | ||||||
|  |       Unfortunately, it has a series of problems: it raises | ||||||
|  |       difficulties when linking to the Microsoft C++ libraries, | ||||||
|  |       it is not thread-safe, and Microsoft has discontinued its | ||||||
|  |       support a long time ago. | ||||||
|  |  | ||||||
|  |     * Linking ZLIB.DLL to MSVCRT70.DLL, supplied with the | ||||||
|  |       Microsoft .NET platform and Visual C++ 7.0, is not a good | ||||||
|  |       option. Although it can be downloaded and distributed | ||||||
|  |       freely, it is hardly present on today's Win32 installations. | ||||||
|  |       If it will become more popular than MSVCRT.DLL, and will be | ||||||
|  |       pre-installed on the future Win32 systems, we will probably | ||||||
|  |       think again about it. | ||||||
|  |  | ||||||
|  |     * Linking ZLIB.DLL to NTDLL.DLL is not possible. | ||||||
|  |       NTDLL.DLL exports only a part of the C library, and only | ||||||
|  |       on Windows NT systems. | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 10. I understand your reasons. However, my project needs ZLIB.DLL | ||||||
|  |     linked to something different than MSVCRT.DLL. What can I do? | ||||||
|  |  | ||||||
|  |     Feel free to rebuild this DLL from the zlib sources, and link | ||||||
|  |     it the way you want. It is required, however, to clearly | ||||||
|  |     state that your build is unofficial. Another thing that is not | ||||||
|  |     required, but highly recommended, is to name that custom DLL | ||||||
|  |     differently, and/or to install it in a private directory that | ||||||
|  |     can be accessed by your application, but is not visible to the | ||||||
|  |     others (e.g. it's not the SYSTEM or the SYSTEM32 directory, | ||||||
|  |     and it's not in the PATH). Otherwise, your build may clash | ||||||
|  |     with applications that link to the official build. | ||||||
|  |  | ||||||
|  |     For example, in Cygwin, zlib is linked to their runtime | ||||||
|  |     CYGWIN1.DLL, and it is distributed under the name CYGZ.DLL. | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 11. My I include additional pieces of code that I find useful, | ||||||
|  |     link them in ZLIB.DLL, and export them? | ||||||
|  |  | ||||||
|  |     No. A legitimate build of ZLIB.DLL must not include code that | ||||||
|  |     does not originate from the official zlib sources. But you can | ||||||
|  |     make your own private build, and give it a different name, as | ||||||
|  |     suggested in the previous answer. | ||||||
|  |  | ||||||
|  |     For example, in Borland Delphi and C++ Builder, zlib is part | ||||||
|  |     of the standard VCL library. If an application links to VCL | ||||||
|  |     dynamically, the name of the distributable binary (VCLxx.DLL) | ||||||
|  |     does not posess any danger of clashing with a legitimate but | ||||||
|  |     incompatible ZLIB.DLL. | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 12. I see that I may have all kinds of problems if I use ZLIB.DLL. | ||||||
|  |     Do you recommend to link zlib in statically? Do I get rid of | ||||||
|  |     problems? | ||||||
|  |  | ||||||
|  |   - Yes, definitely. In fact, unless you are distributing a large | ||||||
|  |     number of executables, each of them linking to zlib, you will | ||||||
|  |     save space by linking zlib in statically (assuming that you | ||||||
|  |     would otherwise distribute ZLIB.DLL with your application). | ||||||
|  |     zlib is not a big library, and the space saved by ZLIB.DLL is | ||||||
|  |     little. Much of the actual size of the DLL is due to the 4KB | ||||||
|  |     alignment in the binary. | ||||||
|  |  | ||||||
|  |     But you may have reasons, other than size, to use the DLL. | ||||||
|  |     That is entirely up to you. | ||||||
							
								
								
									
										28
									
								
								crc32.c
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								crc32.c
									
									
									
									
									
								
							| @@ -18,25 +18,29 @@ | |||||||
| #  endif /* !DYNAMIC_CRC_TABLE */ | #  endif /* !DYNAMIC_CRC_TABLE */ | ||||||
| #endif /* MAKECRCH */ | #endif /* MAKECRCH */ | ||||||
|  |  | ||||||
| #include "zlib.h" | #include "zutil.h" | ||||||
|  |  | ||||||
| #define local static | #define local static | ||||||
|  |  | ||||||
| /* Find a four-byte integer type for crc32_little() and crc32_big(). */ | /* Find a four-byte integer type for crc32_little() and crc32_big(). */ | ||||||
| #ifndef NOBYFOUR | #ifndef NOBYFOUR | ||||||
| #  ifdef __STDC__       /* need ANSI C limits.h to determine sizes */ | #  ifdef STDC           /* need ANSI C limits.h to determine sizes */ | ||||||
| #    include <limits.h> | #    include <limits.h> | ||||||
| #    define BYFOUR | #    define BYFOUR | ||||||
| #    if (UINT_MAX == 4294967295) | #    if (UINT_MAX == 0xffffffffUL) | ||||||
|        typedef unsigned int u4; |        typedef unsigned int u4; | ||||||
| #    elif (ULONG_MAX == 4294967295) |  | ||||||
|        typedef unsigned long u4; |  | ||||||
| #    elif (USHRT_MAX == 4294967295) |  | ||||||
|        typedef unsigned short u4; |  | ||||||
| #    else | #    else | ||||||
| #      undef BYFOUR     /* can't find a four-byte integer type! */ | #      if (ULONG_MAX == 0xffffffffUL) | ||||||
|  |          typedef unsigned long u4; | ||||||
|  | #      else | ||||||
|  | #        if (USHRT_MAX == 0xffffffffUL) | ||||||
|  |            typedef unsigned short u4; | ||||||
|  | #        else | ||||||
|  | #          undef BYFOUR     /* can't find a four-byte integer type! */ | ||||||
|  | #        endif | ||||||
|  | #      endif | ||||||
| #    endif | #    endif | ||||||
| #  endif /* __STDC__ */ | #  endif /* STDC */ | ||||||
| #endif /* !NOBYFOUR */ | #endif /* !NOBYFOUR */ | ||||||
|  |  | ||||||
| /* Definitions for doing the crc four data bytes at a time. */ | /* Definitions for doing the crc four data bytes at a time. */ | ||||||
| @@ -95,7 +99,7 @@ local void make_crc_table() | |||||||
|     /* terms of polynomial defining this crc (except x^32): */ |     /* terms of polynomial defining this crc (except x^32): */ | ||||||
|     static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; |     static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26}; | ||||||
|  |  | ||||||
|     /* make exclusive-or pattern from polynomial (0xedb88320L) */ |     /* make exclusive-or pattern from polynomial (0xedb88320UL) */ | ||||||
|     poly = 0UL; |     poly = 0UL; | ||||||
|     for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) |     for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++) | ||||||
|         poly |= 1UL << (31 - p[n]); |         poly |= 1UL << (31 - p[n]); | ||||||
| @@ -240,7 +244,7 @@ local unsigned long crc32_little(crc, buf, len) | |||||||
|  |  | ||||||
|     c = (u4)crc; |     c = (u4)crc; | ||||||
|     c = ~c; |     c = ~c; | ||||||
|     while (len && ((int)buf & 3)) { |     while (len && ((size_t)buf & 3)) { | ||||||
|         c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); |         c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); | ||||||
|         len--; |         len--; | ||||||
|     } |     } | ||||||
| @@ -280,7 +284,7 @@ local unsigned long crc32_big(crc, buf, len) | |||||||
|  |  | ||||||
|     c = REV((u4)crc); |     c = REV((u4)crc); | ||||||
|     c = ~c; |     c = ~c; | ||||||
|     while (len && ((int)buf & 3)) { |     while (len && ((size_t)buf & 3)) { | ||||||
|         c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); |         c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); | ||||||
|         len--; |         len--; | ||||||
|     } |     } | ||||||
|   | |||||||
							
								
								
									
										50
									
								
								deflate.c
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								deflate.c
									
									
									
									
									
								
							| @@ -37,7 +37,7 @@ | |||||||
|  *  REFERENCES |  *  REFERENCES | ||||||
|  * |  * | ||||||
|  *      Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". |  *      Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". | ||||||
|  *      Available in ftp://ds.internic.net/rfc/rfc1951.txt |  *      Available in http://www.ietf.org/rfc/rfc1951.txt | ||||||
|  * |  * | ||||||
|  *      A description of the Rabin and Karp algorithm is given in the book |  *      A description of the Rabin and Karp algorithm is given in the book | ||||||
|  *         "Algorithms" by R. Sedgewick, Addison-Wesley, p252. |  *         "Algorithms" by R. Sedgewick, Addison-Wesley, p252. | ||||||
| @@ -52,7 +52,7 @@ | |||||||
| #include "deflate.h" | #include "deflate.h" | ||||||
|  |  | ||||||
| const char deflate_copyright[] = | const char deflate_copyright[] = | ||||||
|    " deflate 1.2.0.1 Copyright 1995-2003 Jean-loup Gailly "; |    " deflate 1.2.0.3 Copyright 1995-2003 Jean-loup Gailly "; | ||||||
| /* | /* | ||||||
|   If you use the zlib library in a product, an acknowledgment is welcome |   If you use the zlib library in a product, an acknowledgment is welcome | ||||||
|   in the documentation of your product. If for some reason you cannot |   in the documentation of your product. If for some reason you cannot | ||||||
| @@ -157,7 +157,9 @@ local const config configuration_table[10] = { | |||||||
| #define EQUAL 0 | #define EQUAL 0 | ||||||
| /* result of memcmp for equal strings */ | /* result of memcmp for equal strings */ | ||||||
|  |  | ||||||
|  | #ifndef NO_DUMMY_DECL | ||||||
| struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ | struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ | ||||||
|  | #endif | ||||||
|  |  | ||||||
| /* =========================================================================== | /* =========================================================================== | ||||||
|  * Update a hash value with the given input byte |  * Update a hash value with the given input byte | ||||||
| @@ -255,10 +257,11 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, | |||||||
|         windowBits = -windowBits; |         windowBits = -windowBits; | ||||||
|     } |     } | ||||||
|     if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || |     if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || method != Z_DEFLATED || | ||||||
|         windowBits < 9 || windowBits > 15 || level < 0 || level > 9 || |         windowBits < 8 || windowBits > 15 || level < 0 || level > 9 || | ||||||
|         strategy < 0 || strategy > Z_RLE) { |         strategy < 0 || strategy > Z_RLE) { | ||||||
|         return Z_STREAM_ERROR; |         return Z_STREAM_ERROR; | ||||||
|     } |     } | ||||||
|  |     if (windowBits == 8) windowBits = 9;  /* until 256-byte window bug fixed */ | ||||||
|     s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); |     s = (deflate_state *) ZALLOC(strm, 1, sizeof(deflate_state)); | ||||||
|     if (s == Z_NULL) return Z_MEM_ERROR; |     if (s == Z_NULL) return Z_MEM_ERROR; | ||||||
|     strm->state = (struct internal_state FAR *)s; |     strm->state = (struct internal_state FAR *)s; | ||||||
| @@ -520,9 +523,16 @@ int ZEXPORT deflate (strm, flush) | |||||||
|     if (s->status == INIT_STATE) { |     if (s->status == INIT_STATE) { | ||||||
|  |  | ||||||
|         uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; |         uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; | ||||||
|         uInt level_flags = (s->level-1) >> 1; |         uInt level_flags; | ||||||
|  |  | ||||||
|         if (level_flags > 3) level_flags = 3; |         if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) | ||||||
|  |             level_flags = 0; | ||||||
|  |         else if (s->level < 6) | ||||||
|  |             level_flags = 1; | ||||||
|  |         else if (s->level == 6) | ||||||
|  |             level_flags = 2; | ||||||
|  |         else | ||||||
|  |             level_flags = 3; | ||||||
|         header |= (level_flags << 6); |         header |= (level_flags << 6); | ||||||
|         if (s->strstart != 0) header |= PRESET_DICT; |         if (s->strstart != 0) header |= PRESET_DICT; | ||||||
|         header += 31 - (header % 31); |         header += 31 - (header % 31); | ||||||
| @@ -975,7 +985,7 @@ local uInt longest_match_fast(s, cur_match) | |||||||
|     if (len < MIN_MATCH) return MIN_MATCH - 1; |     if (len < MIN_MATCH) return MIN_MATCH - 1; | ||||||
|  |  | ||||||
|     s->match_start = cur_match; |     s->match_start = cur_match; | ||||||
|     return len <= s->lookahead ? len : s->lookahead; |     return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; | ||||||
| } | } | ||||||
|  |  | ||||||
| #ifdef DEBUG | #ifdef DEBUG | ||||||
| @@ -1028,19 +1038,22 @@ local void fill_window(s) | |||||||
|         more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); |         more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); | ||||||
|  |  | ||||||
|         /* Deal with !@#$% 64K limit: */ |         /* Deal with !@#$% 64K limit: */ | ||||||
|         if (more == 0 && s->strstart == 0 && s->lookahead == 0) { |         if (sizeof(int) <= 2) { | ||||||
|             more = wsize; |             if (more == 0 && s->strstart == 0 && s->lookahead == 0) { | ||||||
|  |                 more = wsize; | ||||||
|      |      | ||||||
|         } else if (more == (unsigned)(-1)) { |             } else if (more == (unsigned)(-1)) { | ||||||
|             /* Very unlikely, but possible on 16 bit machine if strstart == 0 |                 /* Very unlikely, but possible on 16 bit machine if | ||||||
|              * and lookahead == 1 (input done one byte at time) |                  * strstart == 0 && lookahead == 1 (input done one byte at time) | ||||||
|              */ |                  */ | ||||||
|             more--; |                 more--; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|         /* If the window is almost full and there is insufficient lookahead, |         /* If the window is almost full and there is insufficient lookahead, | ||||||
|          * move the upper half to the lower one to make room in the upper half. |          * move the upper half to the lower one to make room in the upper half. | ||||||
|          */ |          */ | ||||||
|         } else if (s->strstart >= wsize+MAX_DIST(s)) { |         if (s->strstart >= wsize+MAX_DIST(s)) { | ||||||
|  |  | ||||||
|             zmemcpy(s->window, s->window+wsize, (unsigned)wsize); |             zmemcpy(s->window, s->window+wsize, (unsigned)wsize); | ||||||
|             s->match_start -= wsize; |             s->match_start -= wsize; | ||||||
| @@ -1347,9 +1360,12 @@ local block_state deflate_slow(s, flush) | |||||||
|             } |             } | ||||||
|             /* longest_match() or longest_match_fast() sets match_start */ |             /* longest_match() or longest_match_fast() sets match_start */ | ||||||
|  |  | ||||||
|             if (s->match_length <= 5 && (s->strategy == Z_FILTERED || |             if (s->match_length <= 5 && (s->strategy == Z_FILTERED | ||||||
|                  (s->match_length == MIN_MATCH && | #if TOO_FAR < 32768 | ||||||
|                   s->strstart - s->match_start > TOO_FAR))) { |                 || (s->match_length == MIN_MATCH && | ||||||
|  |                     s->strstart - s->match_start > TOO_FAR) | ||||||
|  | #endif | ||||||
|  |                 )) { | ||||||
|  |  | ||||||
|                 /* If prev_match is also MIN_MATCH, match_start is garbage |                 /* If prev_match is also MIN_MATCH, match_start is garbage | ||||||
|                  * but we will ignore the current match anyway. |                  * but we will ignore the current match anyway. | ||||||
|   | |||||||
| @@ -10,8 +10,8 @@ | |||||||
|  |  | ||||||
| /* @(#) $Id$ */ | /* @(#) $Id$ */ | ||||||
|  |  | ||||||
| #ifndef _DEFLATE_H | #ifndef DEFLATE_H | ||||||
| #define _DEFLATE_H | #define DEFLATE_H | ||||||
|  |  | ||||||
| #include "zutil.h" | #include "zutil.h" | ||||||
|  |  | ||||||
| @@ -315,4 +315,4 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, | |||||||
|               flush = _tr_tally(s, distance, length)  |               flush = _tr_tally(s, distance, length)  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #endif | #endif /* DEFLATE_H */ | ||||||
|   | |||||||
							
								
								
									
										12
									
								
								example.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								example.c
									
									
									
									
									
								
							| @@ -142,13 +142,18 @@ void test_gzio(out, in, uncompr, uncomprLen) | |||||||
|         exit(1); |         exit(1); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     if (gzungetc(' ', file) != ' ') { | ||||||
|  |         fprintf(stderr, "gzungetc error\n"); | ||||||
|  |         exit(1); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     gzgets(file, (char*)uncompr, uncomprLen); |     gzgets(file, (char*)uncompr, uncomprLen); | ||||||
|     uncomprLen = strlen((char*)uncompr); |     uncomprLen = strlen((char*)uncompr); | ||||||
|     if (uncomprLen != 6) { /* "hello!" */ |     if (uncomprLen != 7) { /* " hello!" */ | ||||||
|         fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err)); |         fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err)); | ||||||
|         exit(1); |         exit(1); | ||||||
|     } |     } | ||||||
|     if (strcmp((char*)uncompr, hello+7)) { |     if (strcmp((char*)uncompr, hello+6)) { | ||||||
|         fprintf(stderr, "bad gzgets after gzseek\n"); |         fprintf(stderr, "bad gzgets after gzseek\n"); | ||||||
|         exit(1); |         exit(1); | ||||||
|     } else { |     } else { | ||||||
| @@ -523,6 +528,9 @@ int main(argc, argv) | |||||||
|         fprintf(stderr, "warning: different zlib version\n"); |         fprintf(stderr, "warning: different zlib version\n"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n", | ||||||
|  |             ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags()); | ||||||
|  |  | ||||||
|     compr    = (Byte*)calloc((uInt)comprLen, 1); |     compr    = (Byte*)calloc((uInt)comprLen, 1); | ||||||
|     uncompr  = (Byte*)calloc((uInt)uncomprLen, 1); |     uncompr  = (Byte*)calloc((uInt)uncomprLen, 1); | ||||||
|     /* compr and uncompr are cleared to avoid reading uninitialized |     /* compr and uncompr are cleared to avoid reading uninitialized | ||||||
|   | |||||||
							
								
								
									
										91
									
								
								gzio.c
									
									
									
									
									
								
							
							
						
						
									
										91
									
								
								gzio.c
									
									
									
									
									
								
							| @@ -11,7 +11,9 @@ | |||||||
|  |  | ||||||
| #include "zutil.h" | #include "zutil.h" | ||||||
|  |  | ||||||
|  | #ifndef NO_DUMMY_DECL | ||||||
| struct internal_state {int dummy;}; /* for buggy compilers */ | struct internal_state {int dummy;}; /* for buggy compilers */ | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifndef Z_BUFSIZE | #ifndef Z_BUFSIZE | ||||||
| #  ifdef MAXSEG_64K | #  ifdef MAXSEG_64K | ||||||
| @@ -55,6 +57,8 @@ typedef struct gz_stream { | |||||||
|     int      transparent; /* 1 if input file is not a .gz file */ |     int      transparent; /* 1 if input file is not a .gz file */ | ||||||
|     char     mode;    /* 'w' or 'r' */ |     char     mode;    /* 'w' or 'r' */ | ||||||
|     long     startpos; /* start of compressed data in file (header skipped) */ |     long     startpos; /* start of compressed data in file (header skipped) */ | ||||||
|  |     int      back;    /* one character push-back */ | ||||||
|  |     int      last;    /* true if push-back is last character */ | ||||||
| } gz_stream; | } gz_stream; | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -102,6 +106,7 @@ local gzFile gz_open (path, mode, fd) | |||||||
|     s->file = NULL; |     s->file = NULL; | ||||||
|     s->z_err = Z_OK; |     s->z_err = Z_OK; | ||||||
|     s->z_eof = 0; |     s->z_eof = 0; | ||||||
|  |     s->back = EOF; | ||||||
|     s->crc = crc32(0L, Z_NULL, 0); |     s->crc = crc32(0L, Z_NULL, 0); | ||||||
|     s->msg = NULL; |     s->msg = NULL; | ||||||
|     s->transparent = 0; |     s->transparent = 0; | ||||||
| @@ -391,6 +396,18 @@ int ZEXPORT gzread (file, buf, len) | |||||||
|     s->stream.next_out = (Bytef*)buf; |     s->stream.next_out = (Bytef*)buf; | ||||||
|     s->stream.avail_out = len; |     s->stream.avail_out = len; | ||||||
|  |  | ||||||
|  |     if (s->stream.avail_out && s->back != EOF) { | ||||||
|  |         *next_out++ = s->back; | ||||||
|  |         s->stream.next_out++; | ||||||
|  |         s->stream.avail_out--; | ||||||
|  |         s->back = EOF; | ||||||
|  |         s->stream.total_out++; | ||||||
|  |         if (s->last) { | ||||||
|  |             s->z_err = Z_STREAM_END; | ||||||
|  |             return 1; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     while (s->stream.avail_out != 0) { |     while (s->stream.avail_out != 0) { | ||||||
|  |  | ||||||
|         if (s->transparent) { |         if (s->transparent) { | ||||||
| @@ -476,6 +493,25 @@ int ZEXPORT gzgetc(file) | |||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /* =========================================================================== | ||||||
|  |       Push one byte back onto the stream. | ||||||
|  | */ | ||||||
|  | int ZEXPORT gzungetc(c, file) | ||||||
|  |     int c; | ||||||
|  |     gzFile file; | ||||||
|  | { | ||||||
|  |     gz_stream *s = (gz_stream*)file; | ||||||
|  |  | ||||||
|  |     if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF; | ||||||
|  |     s->back = c; | ||||||
|  |     s->stream.total_out--; | ||||||
|  |     s->last = (s->z_err == Z_STREAM_END); | ||||||
|  |     if (s->last) s->z_err = Z_OK; | ||||||
|  |     s->z_eof = 0; | ||||||
|  |     return c; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* =========================================================================== | /* =========================================================================== | ||||||
|       Reads bytes from the compressed file until len-1 characters are |       Reads bytes from the compressed file until len-1 characters are | ||||||
|    read, or a newline character is read and transferred to buf, or an |    read, or a newline character is read and transferred to buf, or an | ||||||
| @@ -535,6 +571,7 @@ int ZEXPORT gzwrite (file, buf, len) | |||||||
|     return (int)(len - s->stream.avail_in); |     return (int)(len - s->stream.avail_in); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| /* =========================================================================== | /* =========================================================================== | ||||||
|      Converts, formats, and writes the args to the compressed file under |      Converts, formats, and writes the args to the compressed file under | ||||||
|    control of the format string, as in fprintf. gzprintf returns the number of |    control of the format string, as in fprintf. gzprintf returns the number of | ||||||
| @@ -549,34 +586,30 @@ int ZEXPORTVA gzprintf (gzFile file, const char *format, /* args */ ...) | |||||||
|     va_list va; |     va_list va; | ||||||
|     int len; |     int len; | ||||||
|  |  | ||||||
|  |     buf[sizeof(buf) - 1] = 0; | ||||||
|     va_start(va, format); |     va_start(va, format); | ||||||
| #ifdef NO_vsnprintf | #ifdef NO_vsnprintf | ||||||
| #  ifdef HAS_vsprintf_void | #  ifdef HAS_vsprintf_void | ||||||
|     (void)vsprintf(buf, format, va); |     (void)vsprintf(buf, format, va); | ||||||
|     va_end(va); |     va_end(va); | ||||||
|     len = strlen(buf); /* some *sprintf don't return the nb of bytes written */ |     for (len = 0; len < sizeof(buf); len++) | ||||||
|     if (len <= 0) return 0; |         if (buf[len] == 0) break; | ||||||
| #  else | #  else | ||||||
|     len = vsprintf(buf, format, va); |     len = vsprintf(buf, format, va); | ||||||
|     va_end(va); |     va_end(va); | ||||||
|     if (len <= 0 || len >= sizeof(buf)) |  | ||||||
|         return 0; |  | ||||||
| #  endif | #  endif | ||||||
| #else | #else | ||||||
| #  ifdef HAS_vsnprintf_void | #  ifdef HAS_vsnprintf_void | ||||||
|     (void)vsnprintf(buf, sizeof(buf), format, va); |     (void)vsnprintf(buf, sizeof(buf), format, va); | ||||||
|     va_end(va); |     va_end(va); | ||||||
|     len = strlen(buf); |     len = strlen(buf); | ||||||
|     if (len <= 0) |  | ||||||
|         return 0; |  | ||||||
| #  else | #  else | ||||||
|     len = vsnprintf(buf, sizeof(buf), format, va); |     len = vsnprintf(buf, sizeof(buf), format, va); | ||||||
|     va_end(va); |     va_end(va); | ||||||
|     if (len <= 0 || len >= sizeof(buf)) |  | ||||||
|         return 0; |  | ||||||
| #  endif | #  endif | ||||||
| #endif | #endif | ||||||
|  |     if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0) | ||||||
|  |         return 0; | ||||||
|     return gzwrite(file, buf, (unsigned)len); |     return gzwrite(file, buf, (unsigned)len); | ||||||
| } | } | ||||||
| #else /* not ANSI C */ | #else /* not ANSI C */ | ||||||
| @@ -591,33 +624,29 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, | |||||||
|     char buf[Z_PRINTF_BUFSIZE]; |     char buf[Z_PRINTF_BUFSIZE]; | ||||||
|     int len; |     int len; | ||||||
|  |  | ||||||
|  |     buf[sizeof(buf) - 1] = 0; | ||||||
| #ifdef NO_snprintf | #ifdef NO_snprintf | ||||||
| #  ifdef HAS_sprintf_void | #  ifdef HAS_sprintf_void | ||||||
|     sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, |     sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, | ||||||
|             a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); |             a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); | ||||||
|     len = strlen(buf); /* old sprintf doesn't return the nb of bytes written */ |     for (len = 0; len < sizeof(buf); len++) | ||||||
|     if (len <= 0) return 0; |         if (buf[len] == 0) break; | ||||||
| #  else | #  else | ||||||
|     len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, |     len = sprintf(buf, format, a1, a2, a3, a4, a5, a6, a7, a8, | ||||||
|                 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); |                 a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); | ||||||
|     if (len <= 0 || len >= sizeof(buf)) |  | ||||||
|         return 0; |  | ||||||
| #  endif | #  endif | ||||||
| #else | #else | ||||||
| #  ifdef HAS_snprintf_void | #  ifdef HAS_snprintf_void | ||||||
|     snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, |     snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, | ||||||
|              a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); |              a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); | ||||||
|     len = strlen(buf); |     len = strlen(buf); | ||||||
|     if (len <= 0) |  | ||||||
|         return 0; |  | ||||||
| #  else | #  else | ||||||
|     len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, |     len = snprintf(buf, sizeof(buf), format, a1, a2, a3, a4, a5, a6, a7, a8, | ||||||
|                  a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); |                  a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); | ||||||
|     if (len <= 0 || len >= sizeof(buf)) |  | ||||||
|         return 0; |  | ||||||
| #  endif | #  endif | ||||||
| #endif | #endif | ||||||
|  |     if (len <= 0 || len >= sizeof(buf) || buf[sizeof(buf) - 1] != 0) | ||||||
|  |         return 0; | ||||||
|     return gzwrite(file, buf, len); |     return gzwrite(file, buf, len); | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
| @@ -762,6 +791,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence) | |||||||
|  |  | ||||||
|     if (s->transparent) { |     if (s->transparent) { | ||||||
|         /* map to fseek */ |         /* map to fseek */ | ||||||
|  |         s->back = EOF; | ||||||
|         s->stream.avail_in = 0; |         s->stream.avail_in = 0; | ||||||
|         s->stream.next_in = s->inbuf; |         s->stream.next_in = s->inbuf; | ||||||
|         if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; |         if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; | ||||||
| @@ -782,6 +812,12 @@ z_off_t ZEXPORT gzseek (file, offset, whence) | |||||||
|         s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); |         s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); | ||||||
|         if (s->outbuf == Z_NULL) return -1L; |         if (s->outbuf == Z_NULL) return -1L; | ||||||
|     } |     } | ||||||
|  |     if (offset && s->back != EOF) { | ||||||
|  |         s->back = EOF; | ||||||
|  |         s->stream.total_out++; | ||||||
|  |         offset--; | ||||||
|  |         if (s->last) s->z_err = Z_STREAM_END; | ||||||
|  |     } | ||||||
|     while (offset > 0)  { |     while (offset > 0)  { | ||||||
|         int size = Z_BUFSIZE; |         int size = Z_BUFSIZE; | ||||||
|         if (offset < Z_BUFSIZE) size = (int)offset; |         if (offset < Z_BUFSIZE) size = (int)offset; | ||||||
| @@ -805,12 +841,13 @@ int ZEXPORT gzrewind (file) | |||||||
|  |  | ||||||
|     s->z_err = Z_OK; |     s->z_err = Z_OK; | ||||||
|     s->z_eof = 0; |     s->z_eof = 0; | ||||||
|  |     s->back = EOF; | ||||||
|     s->stream.avail_in = 0; |     s->stream.avail_in = 0; | ||||||
|     s->stream.next_in = s->inbuf; |     s->stream.next_in = s->inbuf; | ||||||
|     s->crc = crc32(0L, Z_NULL, 0); |     s->crc = crc32(0L, Z_NULL, 0); | ||||||
|  |  | ||||||
|     if (s->startpos == 0) { /* not a compressed file */ |     if (s->startpos == 0) { /* not a compressed file */ | ||||||
|         rewind(s->file); |         fseek(s->file, 0L, SEEK_SET);   /* rewind() is not always available */ | ||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -906,7 +943,7 @@ int ZEXPORT gzclose (file) | |||||||
|    errnum is set to Z_ERRNO and the application may consult errno |    errnum is set to Z_ERRNO and the application may consult errno | ||||||
|    to get the exact error code. |    to get the exact error code. | ||||||
| */ | */ | ||||||
| const char*  ZEXPORT gzerror (file, errnum) | const char * ZEXPORT gzerror (file, errnum) | ||||||
|     gzFile file; |     gzFile file; | ||||||
|     int *errnum; |     int *errnum; | ||||||
| { | { | ||||||
| @@ -932,3 +969,17 @@ const char*  ZEXPORT gzerror (file, errnum) | |||||||
|     strcat(s->msg, m); |     strcat(s->msg, m); | ||||||
|     return (const char*)s->msg; |     return (const char*)s->msg; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /* =========================================================================== | ||||||
|  |      Clear the error and end-of-file flags, and do the same for the real file. | ||||||
|  | */ | ||||||
|  | void ZEXPORT gzclearerr (file) | ||||||
|  |     gzFile file; | ||||||
|  | { | ||||||
|  |     gz_stream *s = (gz_stream*)file; | ||||||
|  |  | ||||||
|  |     if (s == NULL) return; | ||||||
|  |     if (s->z_err != Z_STREAM_END) s->z_err = Z_OK; | ||||||
|  |     s->z_eof = 0; | ||||||
|  |     clearerr(s->file); | ||||||
|  | } | ||||||
|   | |||||||
							
								
								
									
										12
									
								
								infback.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								infback.c
									
									
									
									
									
								
							| @@ -151,7 +151,7 @@ struct inflate_state FAR *state; | |||||||
|             if (have == 0) { \ |             if (have == 0) { \ | ||||||
|                 next = Z_NULL; \ |                 next = Z_NULL; \ | ||||||
|                 ret = Z_BUF_ERROR; \ |                 ret = Z_BUF_ERROR; \ | ||||||
|                 goto leave; \ |                 goto inf_leave; \ | ||||||
|             } \ |             } \ | ||||||
|         } \ |         } \ | ||||||
|     } while (0) |     } while (0) | ||||||
| @@ -203,7 +203,7 @@ struct inflate_state FAR *state; | |||||||
|             left = state->wsize; \ |             left = state->wsize; \ | ||||||
|             if (out(out_desc, put, left)) { \ |             if (out(out_desc, put, left)) { \ | ||||||
|                 ret = Z_BUF_ERROR; \ |                 ret = Z_BUF_ERROR; \ | ||||||
|                 goto leave; \ |                 goto inf_leave; \ | ||||||
|             } \ |             } \ | ||||||
|         } \ |         } \ | ||||||
|     } while (0) |     } while (0) | ||||||
| @@ -582,19 +582,19 @@ void FAR *out_desc; | |||||||
|                 if (out(out_desc, state->window, state->wsize - left)) |                 if (out(out_desc, state->window, state->wsize - left)) | ||||||
|                     ret = Z_BUF_ERROR; |                     ret = Z_BUF_ERROR; | ||||||
|             } |             } | ||||||
|             goto leave; |             goto inf_leave; | ||||||
|  |  | ||||||
|         case BAD: |         case BAD: | ||||||
|             ret = Z_DATA_ERROR; |             ret = Z_DATA_ERROR; | ||||||
|             goto leave; |             goto inf_leave; | ||||||
|  |  | ||||||
|         default:                /* can't happen, but makes compilers happy */ |         default:                /* can't happen, but makes compilers happy */ | ||||||
|             ret = Z_STREAM_ERROR; |             ret = Z_STREAM_ERROR; | ||||||
|             goto leave; |             goto inf_leave; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|     /* Return unused input */ |     /* Return unused input */ | ||||||
|   leave: |   inf_leave: | ||||||
|     strm->next_in = next; |     strm->next_in = next; | ||||||
|     strm->avail_in = have; |     strm->avail_in = have; | ||||||
|     return ret; |     return ret; | ||||||
|   | |||||||
							
								
								
									
										61
									
								
								inflate.c
									
									
									
									
									
								
							
							
						
						
									
										61
									
								
								inflate.c
									
									
									
									
									
								
							| @@ -77,7 +77,7 @@ | |||||||
|  *   and buffer address return values for the input function |  *   and buffer address return values for the input function | ||||||
|  * - Check next_in and next_out for Z_NULL on entry to inflate() |  * - Check next_in and next_out for Z_NULL on entry to inflate() | ||||||
|  * |  * | ||||||
|  * The history for versions past 1.2.0 are in ChangeLog in zlib distribution. |  * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include "zutil.h" | #include "zutil.h" | ||||||
| @@ -147,8 +147,12 @@ int stream_size; | |||||||
|         state->wrap = 0; |         state->wrap = 0; | ||||||
|         windowBits = -windowBits; |         windowBits = -windowBits; | ||||||
|     } |     } | ||||||
|     else |     else { | ||||||
|         state->wrap = 1; |         state->wrap = (windowBits >> 4) + 1; | ||||||
|  | #ifdef GUNZIP | ||||||
|  |         windowBits &= 15; | ||||||
|  | #endif | ||||||
|  |     } | ||||||
|     if (windowBits < 8 || windowBits > 15) { |     if (windowBits < 8 || windowBits > 15) { | ||||||
|         ZFREE(strm, state); |         ZFREE(strm, state); | ||||||
|         strm->state = Z_NULL; |         strm->state = Z_NULL; | ||||||
| @@ -403,7 +407,7 @@ unsigned out; | |||||||
|    if there is no input available. */ |    if there is no input available. */ | ||||||
| #define PULLBYTE() \ | #define PULLBYTE() \ | ||||||
|     do { \ |     do { \ | ||||||
|         if (have == 0) goto leave; \ |         if (have == 0) goto inf_leave; \ | ||||||
|         have--; \ |         have--; \ | ||||||
|         hold += (unsigned long)(*next++) << bits; \ |         hold += (unsigned long)(*next++) << bits; \ | ||||||
|         bits += 8; \ |         bits += 8; \ | ||||||
| @@ -502,14 +506,14 @@ unsigned out; | |||||||
|    complete that state.  Those states are copying stored data, writing a |    complete that state.  Those states are copying stored data, writing a | ||||||
|    literal byte, and copying a matching string. |    literal byte, and copying a matching string. | ||||||
|  |  | ||||||
|    When returning, a "goto leave" is used to update the total counters, update |    When returning, a "goto inf_leave" is used to update the total counters, | ||||||
|    the check value, and determine whether any progress has been made during |    update the check value, and determine whether any progress has been made | ||||||
|    that inflate() call in order to return the proper return code.  Progress is |    during that inflate() call in order to return the proper return code. | ||||||
|    defined as a change in either strm->avail_in or strm->avail_out.  When there |    Progress is defined as a change in either strm->avail_in or strm->avail_out. | ||||||
|    is a window, goto leave will update the window with the last output written. |    When there is a window, goto inf_leave will update the window with the last | ||||||
|    If a goto leave occurs in the middle of decompression and there is no window |    output written.  If a goto inf_leave occurs in the middle of decompression | ||||||
|    currently, goto leave will create one and copy output to the window for the |    and there is no window currently, goto inf_leave will create one and copy | ||||||
|    next call of inflate(). |    output to the window for the next call of inflate(). | ||||||
|  |  | ||||||
|    In this implementation, the flush parameter of inflate() only affects the |    In this implementation, the flush parameter of inflate() only affects the | ||||||
|    return code (per zlib.h).  inflate() always writes as much as possible to |    return code (per zlib.h).  inflate() always writes as much as possible to | ||||||
| @@ -562,16 +566,19 @@ int flush; | |||||||
|             } |             } | ||||||
|             NEEDBITS(16); |             NEEDBITS(16); | ||||||
| #ifdef GUNZIP | #ifdef GUNZIP | ||||||
|             if (hold == 0x8b1f) {       /* gzip header */ |             if ((state->wrap & 2) && hold == 0x8b1f) {  /* gzip header */ | ||||||
|                 state->check = crc32(0L, Z_NULL, 0); |                 state->check = crc32(0L, Z_NULL, 0); | ||||||
|                 CRC2(state->check, hold); |                 CRC2(state->check, hold); | ||||||
|                 INITBITS(); |                 INITBITS(); | ||||||
|                 state->mode = FLAGS; |                 state->mode = FLAGS; | ||||||
|                 break; |                 break; | ||||||
|             } |             } | ||||||
|             state->flags = 0;                   /* expect zlib header */ |             state->flags = 0;           /* expect zlib header */ | ||||||
|  |             if (!(state->wrap & 1) ||   /* check if zlib header allowed */ | ||||||
|  | #else | ||||||
|  |             if ( | ||||||
| #endif | #endif | ||||||
|             if (((BITS(8) << 8) + (hold >> 8)) % 31) { |                 ((BITS(8) << 8) + (hold >> 8)) % 31) { | ||||||
|                 strm->msg = (char *)"incorrect header check"; |                 strm->msg = (char *)"incorrect header check"; | ||||||
|                 state->mode = BAD; |                 state->mode = BAD; | ||||||
|                 break; |                 break; | ||||||
| @@ -638,12 +645,12 @@ int flush; | |||||||
|                     next += copy; |                     next += copy; | ||||||
|                     state->length -= copy; |                     state->length -= copy; | ||||||
|                 } |                 } | ||||||
|                 if (state->length) goto leave; |                 if (state->length) goto inf_leave; | ||||||
|             } |             } | ||||||
|             state->mode = NAME; |             state->mode = NAME; | ||||||
|         case NAME: |         case NAME: | ||||||
|             if (state->flags & 0x0800) { |             if (state->flags & 0x0800) { | ||||||
|                 if (have == 0) goto leave; |                 if (have == 0) goto inf_leave; | ||||||
|                 copy = 0; |                 copy = 0; | ||||||
|                 do { |                 do { | ||||||
|                     len = (unsigned)(next[copy++]); |                     len = (unsigned)(next[copy++]); | ||||||
| @@ -652,12 +659,12 @@ int flush; | |||||||
|                     state->check = crc32(state->check, next, copy); |                     state->check = crc32(state->check, next, copy); | ||||||
|                 have -= copy; |                 have -= copy; | ||||||
|                 next += copy; |                 next += copy; | ||||||
|                 if (len) goto leave; |                 if (len) goto inf_leave; | ||||||
|             } |             } | ||||||
|             state->mode = COMMENT; |             state->mode = COMMENT; | ||||||
|         case COMMENT: |         case COMMENT: | ||||||
|             if (state->flags & 0x1000) { |             if (state->flags & 0x1000) { | ||||||
|                 if (have == 0) goto leave; |                 if (have == 0) goto inf_leave; | ||||||
|                 copy = 0; |                 copy = 0; | ||||||
|                 do { |                 do { | ||||||
|                     len = (unsigned)(next[copy++]); |                     len = (unsigned)(next[copy++]); | ||||||
| @@ -666,7 +673,7 @@ int flush; | |||||||
|                     state->check = crc32(state->check, next, copy); |                     state->check = crc32(state->check, next, copy); | ||||||
|                 have -= copy; |                 have -= copy; | ||||||
|                 next += copy; |                 next += copy; | ||||||
|                 if (len) goto leave; |                 if (len) goto inf_leave; | ||||||
|             } |             } | ||||||
|             state->mode = HCRC; |             state->mode = HCRC; | ||||||
|         case HCRC: |         case HCRC: | ||||||
| @@ -745,7 +752,7 @@ int flush; | |||||||
|             if (copy) { |             if (copy) { | ||||||
|                 if (copy > have) copy = have; |                 if (copy > have) copy = have; | ||||||
|                 if (copy > left) copy = left; |                 if (copy > left) copy = left; | ||||||
|                 if (copy == 0) goto leave; |                 if (copy == 0) goto inf_leave; | ||||||
|                 zmemcpy(put, next, copy); |                 zmemcpy(put, next, copy); | ||||||
|                 have -= copy; |                 have -= copy; | ||||||
|                 next += copy; |                 next += copy; | ||||||
| @@ -958,7 +965,7 @@ int flush; | |||||||
|             Tracevv((stderr, "inflate:         distance %u\n", state->offset)); |             Tracevv((stderr, "inflate:         distance %u\n", state->offset)); | ||||||
|             state->mode = MATCH; |             state->mode = MATCH; | ||||||
|         case MATCH: |         case MATCH: | ||||||
|             if (left == 0) goto leave; |             if (left == 0) goto inf_leave; | ||||||
|             copy = out - left; |             copy = out - left; | ||||||
|             if (state->offset > copy) {         /* copy from window */ |             if (state->offset > copy) {         /* copy from window */ | ||||||
|                 copy = state->offset - copy; |                 copy = state->offset - copy; | ||||||
| @@ -983,7 +990,7 @@ int flush; | |||||||
|             if (state->length == 0) state->mode = LEN; |             if (state->length == 0) state->mode = LEN; | ||||||
|             break; |             break; | ||||||
|         case LIT: |         case LIT: | ||||||
|             if (left == 0) goto leave; |             if (left == 0) goto inf_leave; | ||||||
|             *put++ = (unsigned char)(state->length); |             *put++ = (unsigned char)(state->length); | ||||||
|             left--; |             left--; | ||||||
|             state->mode = LEN; |             state->mode = LEN; | ||||||
| @@ -1015,7 +1022,7 @@ int flush; | |||||||
|         case LENGTH: |         case LENGTH: | ||||||
|             if (state->wrap && state->flags) { |             if (state->wrap && state->flags) { | ||||||
|                 NEEDBITS(32); |                 NEEDBITS(32); | ||||||
|                 if (hold != (state->total & 0xffffffff)) { |                 if (hold != (state->total & 0xffffffffUL)) { | ||||||
|                     strm->msg = (char *)"incorrect length check"; |                     strm->msg = (char *)"incorrect length check"; | ||||||
|                     state->mode = BAD; |                     state->mode = BAD; | ||||||
|                     break; |                     break; | ||||||
| @@ -1027,10 +1034,10 @@ int flush; | |||||||
|             state->mode = DONE; |             state->mode = DONE; | ||||||
|         case DONE: |         case DONE: | ||||||
|             ret = Z_STREAM_END; |             ret = Z_STREAM_END; | ||||||
|             goto leave; |             goto inf_leave; | ||||||
|         case BAD: |         case BAD: | ||||||
|             ret = Z_DATA_ERROR; |             ret = Z_DATA_ERROR; | ||||||
|             goto leave; |             goto inf_leave; | ||||||
|         case MEM: |         case MEM: | ||||||
|             return Z_MEM_ERROR; |             return Z_MEM_ERROR; | ||||||
|         case SYNC: |         case SYNC: | ||||||
| @@ -1044,7 +1051,7 @@ int flush; | |||||||
|        error.  Call updatewindow() to create and/or update the window state. |        error.  Call updatewindow() to create and/or update the window state. | ||||||
|        Note: a memory error from inflate() is non-recoverable. |        Note: a memory error from inflate() is non-recoverable. | ||||||
|      */ |      */ | ||||||
|   leave: |   inf_leave: | ||||||
|     RESTORE(); |     RESTORE(); | ||||||
|     if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) |     if (state->wsize || (state->mode < CHECK && out != strm->avail_out)) | ||||||
|         if (updatewindow(strm, out)) { |         if (updatewindow(strm, out)) { | ||||||
|   | |||||||
| @@ -80,7 +80,7 @@ typedef enum { | |||||||
| struct inflate_state { | struct inflate_state { | ||||||
|     inflate_mode mode;          /* current inflate mode */ |     inflate_mode mode;          /* current inflate mode */ | ||||||
|     int last;                   /* true if processing last block */ |     int last;                   /* true if processing last block */ | ||||||
|     int wrap;                   /* true to process header and trailer */ |     int wrap;                   /* bit 0 true for zlib, bit 1 true for gzip */ | ||||||
|     int havedict;               /* true if dictionary provided */ |     int havedict;               /* true if dictionary provided */ | ||||||
|     int flags;                  /* gzip header method and flags (0 if zlib) */ |     int flags;                  /* gzip header method and flags (0 if zlib) */ | ||||||
|     unsigned long check;        /* protected copy of check value */ |     unsigned long check;        /* protected copy of check value */ | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
| #define MAXBITS 15 | #define MAXBITS 15 | ||||||
|  |  | ||||||
| const char inflate_copyright[] = | const char inflate_copyright[] = | ||||||
|    " inflate 1.2.0.1 Copyright 1995-2003 Mark Adler "; |    " inflate 1.2.0.3 Copyright 1995-2003 Mark Adler "; | ||||||
| /* | /* | ||||||
|   If you use the zlib library in a product, an acknowledgment is welcome |   If you use the zlib library in a product, an acknowledgment is welcome | ||||||
|   in the documentation of your product. If for some reason you cannot |   in the documentation of your product. If for some reason you cannot | ||||||
| @@ -62,7 +62,7 @@ unsigned short FAR *work; | |||||||
|         35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; |         35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; | ||||||
|     static const unsigned short lext[31] = { /* Length codes 257..285 extra */ |     static const unsigned short lext[31] = { /* Length codes 257..285 extra */ | ||||||
|         16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, |         16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, | ||||||
|         19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 205, 64}; |         19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 193, 193}; | ||||||
|     static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ |     static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ | ||||||
|         1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, |         1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, | ||||||
|         257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, |         257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, | ||||||
|   | |||||||
| @@ -113,7 +113,7 @@ void gz_compress(in, out) | |||||||
|     if (gz_compress_mmap(in, out) == Z_OK) return; |     if (gz_compress_mmap(in, out) == Z_OK) return; | ||||||
| #endif | #endif | ||||||
|     for (;;) { |     for (;;) { | ||||||
|         len = fread(buf, 1, sizeof(buf), in); |         len = (int)fread(buf, 1, sizeof(buf), in); | ||||||
|         if (ferror(in)) { |         if (ferror(in)) { | ||||||
|             perror("fread"); |             perror("fread"); | ||||||
|             exit(1); |             exit(1); | ||||||
| @@ -230,7 +230,7 @@ void file_uncompress(file) | |||||||
|     char *infile, *outfile; |     char *infile, *outfile; | ||||||
|     FILE  *out; |     FILE  *out; | ||||||
|     gzFile in; |     gzFile in; | ||||||
|     int len = strlen(file); |     int len = (int)strlen(file); | ||||||
|  |  | ||||||
|     strcpy(buf, file); |     strcpy(buf, file); | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										107
									
								
								old/zlib.3
									
									
									
									
									
								
							
							
						
						
									
										107
									
								
								old/zlib.3
									
									
									
									
									
								
							| @@ -1,107 +0,0 @@ | |||||||
| .TH ZLIB 3 "11 March 2002" |  | ||||||
| .SH NAME |  | ||||||
| zlib \- compression/decompression library |  | ||||||
| .SH SYNOPSIS |  | ||||||
| [see |  | ||||||
| .I zlib.h |  | ||||||
| for full description] |  | ||||||
| .SH DESCRIPTION |  | ||||||
| The |  | ||||||
| .I zlib |  | ||||||
| library is a general purpose data compression library. |  | ||||||
| The code is thread safe. |  | ||||||
| It provides in-memory compression and decompression functions, |  | ||||||
| including integrity checks of the uncompressed data. |  | ||||||
| This version of the library supports only one compression method (deflation) |  | ||||||
| but other algorithms will be added later and will have the same stream interface. |  | ||||||
| .LP |  | ||||||
| Compression can be done in a single step if the buffers are large enough |  | ||||||
| (for example if an input file is mmap'ed), |  | ||||||
| or can be done by repeated calls of the compression function. |  | ||||||
| In the latter case, |  | ||||||
| the application must provide more input and/or consume the output |  | ||||||
| (providing more output space) before each call. |  | ||||||
| .LP |  | ||||||
| The library also supports reading and writing files in |  | ||||||
| .I gzip |  | ||||||
| (.gz) format |  | ||||||
| with an interface similar to that of stdio. |  | ||||||
| .LP |  | ||||||
| The library does not install any signal handler. The decoder checks |  | ||||||
| the consistency of the compressed data, so the library should never |  | ||||||
| crash even in case of corrupted input. |  | ||||||
| .LP |  | ||||||
| All functions of the compression library are documented in the file |  | ||||||
| .IR zlib.h. |  | ||||||
| The distribution source includes examples of use of the library |  | ||||||
| the files |  | ||||||
| .I example.c |  | ||||||
| and |  | ||||||
| .IR minigzip.c . |  | ||||||
| .LP |  | ||||||
| A Java implementation of |  | ||||||
| .IR zlib |  | ||||||
| is available in the Java Development Kit 1.1 |  | ||||||
| .IP |  | ||||||
| http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html |  | ||||||
| .LP |  | ||||||
| A Perl interface to |  | ||||||
| .IR zlib , |  | ||||||
| written by Paul Marquess (pmarquess@bfsec.bt.co.uk) |  | ||||||
| is available at CPAN (Comprehensive Perl Archive Network) sites, |  | ||||||
| such as: |  | ||||||
| .IP |  | ||||||
| ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/by-module/Compress/Compress-Zlib* |  | ||||||
| .LP |  | ||||||
| A Python interface to |  | ||||||
| .IR zlib |  | ||||||
| written by A.M. Kuchling <amk@magnet.com> |  | ||||||
| is available from the Python Software Association sites, such as: |  | ||||||
| .IP |  | ||||||
| ftp://ftp.python.org/pub/python/contrib/Encoding/zlib*.tar.gz |  | ||||||
| .SH "SEE ALSO" |  | ||||||
| Questions about zlib should be sent to: |  | ||||||
| .IP |  | ||||||
| zlib@quest.jpl.nasa.gov |  | ||||||
| or, if this fails, to the author addresses given below. |  | ||||||
| The zlib home page is: |  | ||||||
| .IP |  | ||||||
| http://www.cdrom.com/pub/infozip/zlib/ |  | ||||||
| .LP |  | ||||||
| The data format used by the zlib library is described by RFC |  | ||||||
| (Request for Comments) 1950 to 1952 in the files:  |  | ||||||
| .IP |  | ||||||
| ftp://ds.internic.net/rfc/rfc1950.txt (zlib format) |  | ||||||
| .br |  | ||||||
| rfc1951.txt (deflate format) |  | ||||||
| .br |  | ||||||
| rfc1952.txt (gzip format) |  | ||||||
| .LP |  | ||||||
| These documents are also available in other formats from: |  | ||||||
| .IP |  | ||||||
| ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html |  | ||||||
| .SH AUTHORS |  | ||||||
| Version 1.1.4 |  | ||||||
| Copyright (C) 1995-2002 Jean-loup Gailly (jloup@gzip.org) |  | ||||||
| and Mark Adler (madler@alumni.caltech.edu). |  | ||||||
| .LP |  | ||||||
| This software is provided "as-is," |  | ||||||
| without any express or implied warranty. |  | ||||||
| In no event will the authors be held liable for any damages |  | ||||||
| arising from the use of this software. |  | ||||||
| See the distribution directory with respect to requirements |  | ||||||
| governing redistribution. |  | ||||||
| The deflate format used by |  | ||||||
| .I zlib |  | ||||||
| was defined by Phil Katz. |  | ||||||
| The deflate and |  | ||||||
| .I zlib |  | ||||||
| specifications were written by L. Peter Deutsch. |  | ||||||
| Thanks to all the people who reported problems and suggested various |  | ||||||
| improvements in |  | ||||||
| .IR zlib ; |  | ||||||
| who are too numerous to cite here. |  | ||||||
| .LP |  | ||||||
| UNIX manual page by R. P. C. Rodgers, |  | ||||||
| U.S. National Library of Medicine (rodgers@nlm.nih.gov). |  | ||||||
| .\" end of man page |  | ||||||
| @@ -5,6 +5,7 @@ | |||||||
|  |  | ||||||
| /* @(#) $Id$ */ | /* @(#) $Id$ */ | ||||||
|  |  | ||||||
|  | #define ZLIB_INTERNAL | ||||||
| #include "zlib.h" | #include "zlib.h" | ||||||
|  |  | ||||||
| /* =========================================================================== | /* =========================================================================== | ||||||
|   | |||||||
| @@ -16,7 +16,7 @@ | |||||||
| #  | #  | ||||||
|  |  | ||||||
| LIB = libz.a | LIB = libz.a | ||||||
| SHAREDLIB = libz.so | SHAREDLIB = zlib.dll | ||||||
| VER = 1.2.0 | VER = 1.2.0 | ||||||
|  |  | ||||||
| CC = gcc | CC = gcc | ||||||
| @@ -32,6 +32,8 @@ LDFLAGS = $(LOC) -s | |||||||
| AR = ar | AR = ar | ||||||
| ARFLAGS = rcs | ARFLAGS = rcs | ||||||
|  |  | ||||||
|  | RC = windres | ||||||
|  |  | ||||||
| CP = cp -fp | CP = cp -fp | ||||||
| # If GNU install is available, replace $(CP) with install. | # If GNU install is available, replace $(CP) with install. | ||||||
| INSTALL = $(CP) | INSTALL = $(CP) | ||||||
| @@ -43,12 +45,14 @@ exec_prefix = $(prefix) | |||||||
| OBJS = adler32.o compress.o crc32.o deflate.o gzio.o infback.o \ | OBJS = adler32.o compress.o crc32.o deflate.o gzio.o infback.o \ | ||||||
|        inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o |        inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o | ||||||
|  |  | ||||||
|  | DLLDEF = win32/zlibgcc.def | ||||||
|  |  | ||||||
| # to use the asm code: make OBJA=match.o | # to use the asm code: make OBJA=match.o | ||||||
| OBJA = | OBJA = | ||||||
|  |  | ||||||
| TEST_OBJS = example.o minigzip.o | TEST_OBJS = example.o minigzip.o | ||||||
|  |  | ||||||
| all: $(LIB) example minigzip | all: $(LIB) $(SHAREDLIB) example minigzip | ||||||
|  |  | ||||||
| test: all | test: all | ||||||
| 	./example | 	./example | ||||||
| @@ -60,12 +64,18 @@ test: all | |||||||
| libz.a: $(OBJS) | libz.a: $(OBJS) | ||||||
| 	$(AR) $(ARFLAGS) $@ $(OBJS) | 	$(AR) $(ARFLAGS) $@ $(OBJS) | ||||||
|  |  | ||||||
|  | $(SHAREDLIB): $(OBJS) $(DLLDEF) zlibrc.o | ||||||
|  | 	dllwrap --driver-name $(CC) --def $(DLLDEF) -o $@ $(OBJS) zlibrc.o | ||||||
|  |  | ||||||
| example: example.o $(LIB) | example: example.o $(LIB) | ||||||
| 	$(LD) -o $@ $< $(LIB) | 	$(LD) -o $@ $< $(LIB) | ||||||
|  |  | ||||||
| minigzip: minigzip.o $(LIB) | minigzip: minigzip.o $(LIB) | ||||||
| 	$(LD) -o $@ $< $(LIB) | 	$(LD) -o $@ $< $(LIB) | ||||||
|  |  | ||||||
|  | zlibrc.o: win32/zlib.rc | ||||||
|  | 	-$(RC) -o $@ --define GCC_WINDRES win32/zlib.rc | ||||||
|  |  | ||||||
|  |  | ||||||
| # INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env . | # INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env . | ||||||
|  |  | ||||||
| @@ -87,6 +97,7 @@ clean: | |||||||
| 	$(RM) *.o | 	$(RM) *.o | ||||||
| 	$(RM) *.exe | 	$(RM) *.exe | ||||||
| 	$(RM) libz.a | 	$(RM) libz.a | ||||||
|  | 	$(RM) zlib.dll | ||||||
| 	$(RM) foo.gz | 	$(RM) foo.gz | ||||||
|  |  | ||||||
| adler32.o: zlib.h zconf.h | adler32.o: zlib.h zconf.h | ||||||
|   | |||||||
| @@ -1,10 +1,13 @@ | |||||||
| # Makefile for (static) zlib -- Microsoft (Visual) C. | # Makefile for Win32 zlib.dll and the static library zlibstat.lib | ||||||
| # Author: Cosmin Truta, 11-Mar-2003. | # -- Microsoft (Visual) C. | ||||||
|  | # Author: Cosmin Truta, 11-Mar-2003 | ||||||
|  | #         Christian Spieler, 19-Mar-2003 | ||||||
| # | # | ||||||
| # Usage: nmake -f win32/Makefile.msc | # Usage: nmake -f win32/Makefile.msc | ||||||
|  |  | ||||||
| CC = cl | CC = cl | ||||||
| LD = cl | LD = cl | ||||||
|  | RC = rc | ||||||
| CFLAGS = -nologo -MD -O2 | CFLAGS = -nologo -MD -O2 | ||||||
| LDFLAGS = -nologo | LDFLAGS = -nologo | ||||||
|  |  | ||||||
| @@ -12,19 +15,33 @@ OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj \ | |||||||
|        inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj |        inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj | ||||||
|  |  | ||||||
| # targets | # targets | ||||||
| all: zlib.lib example.exe minigzip.exe | all: zlib.dll zlibstat.lib example.exe minigzip.exe exampl_s.exe minigz_s.exe | ||||||
|  |  | ||||||
| zlib.lib: $(OBJS) | zlibstat.lib: $(OBJS) | ||||||
| 	lib -out:$@ $(OBJS) | 	lib -out:$@ $(OBJS) | ||||||
|  |  | ||||||
|  | zlib.dll: $(OBJS) zlib.res win32/zlib.def | ||||||
|  | 	link -release -def:win32/zlib.def -dll -out:$@ $(OBJS) zlib.res | ||||||
|  |  | ||||||
|  | zlib.lib: zlib.dll | ||||||
|  |  | ||||||
| example.exe: example.obj zlib.lib | example.exe: example.obj zlib.lib | ||||||
| 	$(LD) $(LDFLAGS) example.obj zlib.lib | 	$(LD) $(LDFLAGS) example.obj zlib.lib | ||||||
|  |  | ||||||
| minigzip.exe: minigzip.obj zlib.lib | minigzip.exe: minigzip.obj zlib.lib | ||||||
| 	$(LD) $(LDFLAGS) minigzip.obj zlib.lib | 	$(LD) $(LDFLAGS) minigzip.obj zlib.lib | ||||||
|  |  | ||||||
|  | exampl_s.exe: example.obj zlibstat.lib | ||||||
|  | 	$(LD) $(LDFLAGS) -o $@ example.obj zlibstat.lib | ||||||
|  |  | ||||||
|  | minigz_s.exe: minigzip.obj zlibstat.lib | ||||||
|  | 	$(LD) $(LDFLAGS) -o $@ minigzip.obj zlibstat.lib | ||||||
|  |  | ||||||
| .c.obj: | .c.obj: | ||||||
| 	$(CC) -c $(CFLAGS) $*.c | 	$(CC) -c $(CFLAGS) $< | ||||||
|  |  | ||||||
|  | zlib.res: win32/zlib.rc | ||||||
|  | 	$(RC) /l 0x409 /fo$@ /d WIN32 win32/zlib.rc | ||||||
|  |  | ||||||
| adler32.obj: adler32.c zlib.h zconf.h | adler32.obj: adler32.c zlib.h zconf.h | ||||||
|  |  | ||||||
| @@ -62,8 +79,14 @@ test: example.exe minigzip.exe | |||||||
| 	example | 	example | ||||||
| 	echo hello world | minigzip | minigzip -d  | 	echo hello world | minigzip | minigzip -d  | ||||||
|  |  | ||||||
|  | teststat: exampl_s.exe minigz_s.exe | ||||||
|  | 	exampl_s | ||||||
|  | 	echo hello world | minigz_s | minigz_s -d  | ||||||
|  |  | ||||||
| # cleanup | # cleanup | ||||||
| clean: | clean: | ||||||
| 	del *.obj | 	del *.obj | ||||||
|  | 	del *.dll | ||||||
| 	del *.lib | 	del *.lib | ||||||
|  | 	del *.exp | ||||||
| 	del *.exe | 	del *.exe | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| LIBRARY		zlib.dll | LIBRARY		zlib.dll | ||||||
| DESCRIPTION	"zlib compression library for Windows" | DESCRIPTION	"zlib data compression library" | ||||||
|  |  | ||||||
| EXPORTS | EXPORTS | ||||||
|     adler32                        @1 |     adler32                        @1 | ||||||
| @@ -43,7 +43,10 @@ EXPORTS | |||||||
|     compress2                      @39 |     compress2                      @39 | ||||||
|     gzputs                         @40 |     gzputs                         @40 | ||||||
|     gzgets                         @41 |     gzgets                         @41 | ||||||
| ; The following functions exist since zlib-1.2.0 | ; since zlib-1.2.0: | ||||||
| ;   deflateBound                   @42 |     inflateCopy                    @42 | ||||||
| ;   compressBound                  @43 |     inflateBackInit_               @43 | ||||||
| ; etc. |     inflateBack                    @44 | ||||||
|  |     inflateBackEnd                 @45 | ||||||
|  |     compressBound                  @46 | ||||||
|  |     deflateBound                   @47 | ||||||
|   | |||||||
							
								
								
									
										90
									
								
								zconf.h
									
									
									
									
									
								
							
							
						
						
									
										90
									
								
								zconf.h
									
									
									
									
									
								
							| @@ -5,8 +5,8 @@ | |||||||
|  |  | ||||||
| /* @(#) $Id$ */ | /* @(#) $Id$ */ | ||||||
|  |  | ||||||
| #ifndef _ZCONF_H | #ifndef ZCONF_H | ||||||
| #define _ZCONF_H | #define ZCONF_H | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * If you *really* need a unique prefix for all types and library functions, |  * If you *really* need a unique prefix for all types and library functions, | ||||||
| @@ -100,15 +100,6 @@ | |||||||
| #  define NO_DUMMY_DECL | #  define NO_DUMMY_DECL | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| /* Old Borland C incorrectly complains about missing returns: */ |  | ||||||
| #if defined(__BORLANDC__) && (__BORLANDC__ < 0x460) |  | ||||||
| #  define NEED_DUMMY_RETURN |  | ||||||
| #endif |  | ||||||
| #if defined(__TURBOC__) && !defined(__BORLANDC__) |  | ||||||
| #  define NEED_DUMMY_RETURN |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Maximum value for memLevel in deflateInit2 */ | /* Maximum value for memLevel in deflateInit2 */ | ||||||
| #ifndef MAX_MEM_LEVEL | #ifndef MAX_MEM_LEVEL | ||||||
| #  ifdef MAXSEG_64K | #  ifdef MAXSEG_64K | ||||||
| @@ -172,46 +163,55 @@ | |||||||
| #  endif | #  endif | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if defined(WIN32) && (!defined(ZLIB_WIN32_NODLL)) && (!defined(ZLIB_DLL)) | /* If building or using a Windows DLL, compile with -DZLIB_DLL. | ||||||
| #  define ZLIB_DLL |  * The calls to ZEXTERN functions will be more efficient this way. | ||||||
| #endif |  */ | ||||||
|  | #if defined(_WINDOWS) || defined(WINDOWS) || defined(WIN32) | ||||||
| /* Compile with -DZLIB_DLL for Windows DLL support */ | #  ifdef FAR | ||||||
| #if defined(ZLIB_DLL) | #    undef FAR | ||||||
| #  if defined(_WINDOWS) || defined(WINDOWS) || defined(WIN32) |  | ||||||
| #    ifndef WINAPIV |  | ||||||
| #      ifdef FAR |  | ||||||
| #        undef FAR |  | ||||||
| #      endif |  | ||||||
| #      include <windows.h> |  | ||||||
| #    endif |  | ||||||
| #    ifdef WIN32 |  | ||||||
| #      define ZEXPORT  WINAPI |  | ||||||
| #      define ZEXPORTVA  WINAPIV |  | ||||||
| #    else |  | ||||||
| #      define ZEXPORT  WINAPI _export |  | ||||||
| #      define ZEXPORTVA  FAR _cdecl _export |  | ||||||
| #    endif |  | ||||||
| #  endif | #  endif | ||||||
| #  if defined (__BORLANDC__) |    /* For zlib, the basic Win32 API declarations are sufficient.  Whenever | ||||||
| #    if (__BORLANDC__ >= 0x0500) && defined (WIN32) |     * a program that uses zlib requires the full Win32 API set, it has | ||||||
| #      include <windows.h> |     * to include <windows.h> prior to "zlib.h". | ||||||
| #      define ZEXPORT __declspec(dllexport) WINAPI |     */ | ||||||
| #      define ZEXPORTVA __declspec(dllexport) WINAPIV | #  if defined(WIN32) && (!defined(WIN32_LEAN_AND_MEAN)) | ||||||
|  | #    define WIN32_LEAN_AND_MEAN | ||||||
|  | #  endif | ||||||
|  | #  include <windows.h> | ||||||
|  | #  if !defined(WIN32) || (defined(__BORLANDC__) && (__BORLANDC__ < 0x500)) | ||||||
|  | #    if defined(ZLIB_DLL) && defined(ZLIB_INTERNAL) | ||||||
|  | #      define ZEXPORT   WINAPI _export | ||||||
|  | #      define ZEXPORTVA FAR _cdecl _export | ||||||
| #    else | #    else | ||||||
| #      if defined (_Windows) && defined (__DLL__) | #      define ZEXPORT   FAR _cdecl | ||||||
| #        define ZEXPORT _export | #      define ZEXPORTVA FAR _cdecl | ||||||
| #        define ZEXPORTVA _export | #    endif | ||||||
|  | #  else | ||||||
|  |      /* a fully Win32-compliant compiler */ | ||||||
|  | #    define ZEXPORTVA CDECL | ||||||
|  | #    ifdef ZLIB_DLL | ||||||
|  | #      define ZEXPORT WINAPI | ||||||
|  | #      ifdef ZLIB_INTERNAL | ||||||
|  | #        define ZEXTERN extern __declspec(dllexport) | ||||||
|  | #      else | ||||||
|  | #        define ZEXTERN extern __declspec(dllimport) | ||||||
| #      endif | #      endif | ||||||
|  | #    else | ||||||
|  | #      define ZEXPORT CDECL | ||||||
|  | #      define ZEXTERN extern | ||||||
| #    endif | #    endif | ||||||
| #  endif | #  endif | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if defined (__BEOS__) | #if defined (__BEOS__) | ||||||
| #  if defined (ZLIB_DLL) | #  ifdef ZLIB_DLL | ||||||
| #    define ZEXTERN extern __declspec(dllexport) | #    ifdef ZLIB_INTERNAL | ||||||
| #  else | #      define ZEXPORT   __declspec(dllexport) | ||||||
| #    define ZEXTERN extern __declspec(dllimport) | #      define ZEXPORTVA __declspec(dllexport) | ||||||
|  | #    else | ||||||
|  | #      define ZEXPORT   __declspec(dllimport) | ||||||
|  | #      define ZEXPORTVA __declspec(dllimport) | ||||||
|  | #    endif | ||||||
| #  endif | #  endif | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -226,7 +226,7 @@ | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifndef FAR | #ifndef FAR | ||||||
| #   define FAR | #  define FAR | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if !defined(__MACTYPES__) | #if !defined(__MACTYPES__) | ||||||
| @@ -290,4 +290,4 @@ typedef uLong FAR uLongf; | |||||||
| #   pragma map(inflate_copyright,"INCOPY") | #   pragma map(inflate_copyright,"INCOPY") | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #endif /* _ZCONF_H */ | #endif /* ZCONF_H */ | ||||||
|   | |||||||
							
								
								
									
										90
									
								
								zconf.in.h
									
									
									
									
									
								
							
							
						
						
									
										90
									
								
								zconf.in.h
									
									
									
									
									
								
							| @@ -5,8 +5,8 @@ | |||||||
|  |  | ||||||
| /* @(#) $Id$ */ | /* @(#) $Id$ */ | ||||||
|  |  | ||||||
| #ifndef _ZCONF_H | #ifndef ZCONF_H | ||||||
| #define _ZCONF_H | #define ZCONF_H | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * If you *really* need a unique prefix for all types and library functions, |  * If you *really* need a unique prefix for all types and library functions, | ||||||
| @@ -100,15 +100,6 @@ | |||||||
| #  define NO_DUMMY_DECL | #  define NO_DUMMY_DECL | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| /* Old Borland C incorrectly complains about missing returns: */ |  | ||||||
| #if defined(__BORLANDC__) && (__BORLANDC__ < 0x460) |  | ||||||
| #  define NEED_DUMMY_RETURN |  | ||||||
| #endif |  | ||||||
| #if defined(__TURBOC__) && !defined(__BORLANDC__) |  | ||||||
| #  define NEED_DUMMY_RETURN |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|  |  | ||||||
| /* Maximum value for memLevel in deflateInit2 */ | /* Maximum value for memLevel in deflateInit2 */ | ||||||
| #ifndef MAX_MEM_LEVEL | #ifndef MAX_MEM_LEVEL | ||||||
| #  ifdef MAXSEG_64K | #  ifdef MAXSEG_64K | ||||||
| @@ -172,46 +163,55 @@ | |||||||
| #  endif | #  endif | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if defined(WIN32) && (!defined(ZLIB_WIN32_NODLL)) && (!defined(ZLIB_DLL)) | /* If building or using a Windows DLL, compile with -DZLIB_DLL. | ||||||
| #  define ZLIB_DLL |  * The calls to ZEXTERN functions will be more efficient this way. | ||||||
| #endif |  */ | ||||||
|  | #if defined(_WINDOWS) || defined(WINDOWS) || defined(WIN32) | ||||||
| /* Compile with -DZLIB_DLL for Windows DLL support */ | #  ifdef FAR | ||||||
| #if defined(ZLIB_DLL) | #    undef FAR | ||||||
| #  if defined(_WINDOWS) || defined(WINDOWS) || defined(WIN32) |  | ||||||
| #    ifndef WINAPIV |  | ||||||
| #      ifdef FAR |  | ||||||
| #        undef FAR |  | ||||||
| #      endif |  | ||||||
| #      include <windows.h> |  | ||||||
| #    endif |  | ||||||
| #    ifdef WIN32 |  | ||||||
| #      define ZEXPORT  WINAPI |  | ||||||
| #      define ZEXPORTVA  WINAPIV |  | ||||||
| #    else |  | ||||||
| #      define ZEXPORT  WINAPI _export |  | ||||||
| #      define ZEXPORTVA  FAR _cdecl _export |  | ||||||
| #    endif |  | ||||||
| #  endif | #  endif | ||||||
| #  if defined (__BORLANDC__) |    /* For zlib, the basic Win32 API declarations are sufficient.  Whenever | ||||||
| #    if (__BORLANDC__ >= 0x0500) && defined (WIN32) |     * a program that uses zlib requires the full Win32 API set, it has | ||||||
| #      include <windows.h> |     * to include <windows.h> prior to "zlib.h". | ||||||
| #      define ZEXPORT __declspec(dllexport) WINAPI |     */ | ||||||
| #      define ZEXPORTVA __declspec(dllexport) WINAPIV | #  if defined(WIN32) && (!defined(WIN32_LEAN_AND_MEAN)) | ||||||
|  | #    define WIN32_LEAN_AND_MEAN | ||||||
|  | #  endif | ||||||
|  | #  include <windows.h> | ||||||
|  | #  if !defined(WIN32) || (defined(__BORLANDC__) && (__BORLANDC__ < 0x500)) | ||||||
|  | #    if defined(ZLIB_DLL) && defined(ZLIB_INTERNAL) | ||||||
|  | #      define ZEXPORT   WINAPI _export | ||||||
|  | #      define ZEXPORTVA FAR _cdecl _export | ||||||
| #    else | #    else | ||||||
| #      if defined (_Windows) && defined (__DLL__) | #      define ZEXPORT   FAR _cdecl | ||||||
| #        define ZEXPORT _export | #      define ZEXPORTVA FAR _cdecl | ||||||
| #        define ZEXPORTVA _export | #    endif | ||||||
|  | #  else | ||||||
|  |      /* a fully Win32-compliant compiler */ | ||||||
|  | #    define ZEXPORTVA CDECL | ||||||
|  | #    ifdef ZLIB_DLL | ||||||
|  | #      define ZEXPORT WINAPI | ||||||
|  | #      ifdef ZLIB_INTERNAL | ||||||
|  | #        define ZEXTERN extern __declspec(dllexport) | ||||||
|  | #      else | ||||||
|  | #        define ZEXTERN extern __declspec(dllimport) | ||||||
| #      endif | #      endif | ||||||
|  | #    else | ||||||
|  | #      define ZEXPORT CDECL | ||||||
|  | #      define ZEXTERN extern | ||||||
| #    endif | #    endif | ||||||
| #  endif | #  endif | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if defined (__BEOS__) | #if defined (__BEOS__) | ||||||
| #  if defined (ZLIB_DLL) | #  ifdef ZLIB_DLL | ||||||
| #    define ZEXTERN extern __declspec(dllexport) | #    ifdef ZLIB_INTERNAL | ||||||
| #  else | #      define ZEXPORT   __declspec(dllexport) | ||||||
| #    define ZEXTERN extern __declspec(dllimport) | #      define ZEXPORTVA __declspec(dllexport) | ||||||
|  | #    else | ||||||
|  | #      define ZEXPORT   __declspec(dllimport) | ||||||
|  | #      define ZEXPORTVA __declspec(dllimport) | ||||||
|  | #    endif | ||||||
| #  endif | #  endif | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -226,7 +226,7 @@ | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifndef FAR | #ifndef FAR | ||||||
| #   define FAR | #  define FAR | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if !defined(__MACTYPES__) | #if !defined(__MACTYPES__) | ||||||
| @@ -290,4 +290,4 @@ typedef uLong FAR uLongf; | |||||||
| #   pragma map(inflate_copyright,"INCOPY") | #   pragma map(inflate_copyright,"INCOPY") | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #endif /* _ZCONF_H */ | #endif /* ZCONF_H */ | ||||||
|   | |||||||
							
								
								
									
										159
									
								
								zlib.3
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										159
									
								
								zlib.3
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,159 @@ | |||||||
|  | .TH ZLIB 3 "12 May 2003" | ||||||
|  | .SH NAME | ||||||
|  | zlib \- compression/decompression library | ||||||
|  | .SH SYNOPSIS | ||||||
|  | [see | ||||||
|  | .I zlib.h | ||||||
|  | for full description] | ||||||
|  | .SH DESCRIPTION | ||||||
|  | The | ||||||
|  | .I zlib | ||||||
|  | library is a general purpose data compression library. | ||||||
|  | The code is thread safe. | ||||||
|  | It provides in-memory compression and decompression functions, | ||||||
|  | including integrity checks of the uncompressed data. | ||||||
|  | This version of the library supports only one compression method (deflation) | ||||||
|  | but other algorithms will be added later | ||||||
|  | and will have the same stream interface. | ||||||
|  | .LP | ||||||
|  | Compression can be done in a single step if the buffers are large enough | ||||||
|  | (for example if an input file is mmap'ed), | ||||||
|  | or can be done by repeated calls of the compression function. | ||||||
|  | In the latter case, | ||||||
|  | the application must provide more input and/or consume the output | ||||||
|  | (providing more output space) before each call. | ||||||
|  | .LP | ||||||
|  | The library also supports reading and writing files in | ||||||
|  | .IR gzip (1) | ||||||
|  | (.gz) format | ||||||
|  | with an interface similar to that of stdio. | ||||||
|  | .LP | ||||||
|  | The library does not install any signal handler. | ||||||
|  | The decoder checks the consistency of the compressed data, | ||||||
|  | so the library should never crash even in case of corrupted input. | ||||||
|  | .LP | ||||||
|  | All functions of the compression library are documented in the file | ||||||
|  | .IR zlib.h . | ||||||
|  | The distribution source includes examples of use of the library | ||||||
|  | in the files | ||||||
|  | .I example.c | ||||||
|  | and | ||||||
|  | .IR minigzip.c . | ||||||
|  | .LP | ||||||
|  | Changes to this version are documented in the file | ||||||
|  | .I ChangeLog | ||||||
|  | that accompanies the source, | ||||||
|  | and are concerned primarily with bug fixes and portability enhancements. | ||||||
|  | .LP | ||||||
|  | A Java implementation of | ||||||
|  | .I zlib | ||||||
|  | is available in the Java Development Kit 1.1: | ||||||
|  | .IP | ||||||
|  | http://www.javasoft.com/products/JDK/1.1/docs/api/Package-java.util.zip.html | ||||||
|  | .LP | ||||||
|  | A Perl interface to | ||||||
|  | .IR zlib , | ||||||
|  | written by Paul Marquess (pmqs@cpan.org), | ||||||
|  | is available at CPAN (Comprehensive Perl Archive Network) sites, | ||||||
|  | including: | ||||||
|  | .IP | ||||||
|  | http://www.cpan.org/modules/by-module/Compress/ | ||||||
|  | .LP | ||||||
|  | A Python interface to | ||||||
|  | .IR zlib , | ||||||
|  | written by A.M. Kuchling (amk@magnet.com), | ||||||
|  | is available in Python 1.5 and later versions: | ||||||
|  | .IP | ||||||
|  | http://www.python.org/doc/lib/module-zlib.html | ||||||
|  | .LP | ||||||
|  | A | ||||||
|  | .I zlib | ||||||
|  | binding for | ||||||
|  | .IR tcl (1), | ||||||
|  | written by Andreas Kupries (a.kupries@westend.com), | ||||||
|  | is availlable at: | ||||||
|  | .IP | ||||||
|  | http://www.westend.com/~kupries/doc/trf/man/man.html | ||||||
|  | .LP | ||||||
|  | An experimental package to read and write files in .zip format, | ||||||
|  | written on top of | ||||||
|  | .I zlib | ||||||
|  | by Gilles Vollant (info@winimage.com), | ||||||
|  | is available at: | ||||||
|  | .IP | ||||||
|  | http://www.winimage.com/zLibDll/unzip.html | ||||||
|  | and also in the | ||||||
|  | .I contrib/minizip | ||||||
|  | directory of the main | ||||||
|  | .I zlib | ||||||
|  | web site. | ||||||
|  | .SH "SEE ALSO" | ||||||
|  | The | ||||||
|  | .I zlib | ||||||
|  | web site can be found at either of these locations: | ||||||
|  | .IP | ||||||
|  | http://www.zlib.org | ||||||
|  | .br | ||||||
|  | http://www.gzip.org/zlib/ | ||||||
|  | .LP | ||||||
|  | The data format used by the zlib library is described by RFC | ||||||
|  | (Request for Comments) 1950 to 1952 in the files:  | ||||||
|  | .IP | ||||||
|  | http://www.ietf.org/rfc/rfc1950.txt (concerning zlib format) | ||||||
|  | .br | ||||||
|  | http://www.ietf.org/rfc/rfc1951.txt (concerning deflate format) | ||||||
|  | .br | ||||||
|  | http://www.ietf.org/rfc/rfc1952.txt (concerning gzip format) | ||||||
|  | .LP | ||||||
|  | These documents are also available in other formats from: | ||||||
|  | .IP | ||||||
|  | ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html | ||||||
|  | .LP | ||||||
|  | Mark Nelson (markn@ieee.org) wrote an article about | ||||||
|  | .I zlib | ||||||
|  | for the Jan. 1997 issue of  Dr. Dobb's Journal; | ||||||
|  | a copy of the article is available at: | ||||||
|  | .IP | ||||||
|  | http://dogma.net/markn/articles/zlibtool/zlibtool.htm | ||||||
|  | .SH "REPORTING PROBLEMS" | ||||||
|  | Before reporting a problem, | ||||||
|  | please check the | ||||||
|  | .I zlib | ||||||
|  | web site to verify that you have the latest version of | ||||||
|  | .IR zlib ; | ||||||
|  | otherwise, | ||||||
|  | obtain the latest version and see if the problem still exists. | ||||||
|  | Please read the | ||||||
|  | .I zlib | ||||||
|  | FAQ at: | ||||||
|  | .IP | ||||||
|  | http://www.gzip.org/zlib/zlib_faq.html | ||||||
|  | .LP | ||||||
|  | before asking for help. | ||||||
|  | Send questions and/or comments to zlib@gzip.org, | ||||||
|  | or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). | ||||||
|  | .SH AUTHORS | ||||||
|  | Version 1.2.0.3 | ||||||
|  | Copyright (C) 1995-2003 Jean-loup Gailly (jloup@gzip.org) | ||||||
|  | and Mark Adler (madler@alumni.caltech.edu). | ||||||
|  | .LP | ||||||
|  | This software is provided "as-is," | ||||||
|  | without any express or implied warranty. | ||||||
|  | In no event will the authors be held liable for any damages | ||||||
|  | arising from the use of this software. | ||||||
|  | See the distribution directory with respect to requirements | ||||||
|  | governing redistribution. | ||||||
|  | The deflate format used by | ||||||
|  | .I zlib | ||||||
|  | was defined by Phil Katz. | ||||||
|  | The deflate and | ||||||
|  | .I zlib | ||||||
|  | specifications were written by L. Peter Deutsch. | ||||||
|  | Thanks to all the people who reported problems and suggested various | ||||||
|  | improvements in | ||||||
|  | .IR zlib ; | ||||||
|  | who are too numerous to cite here. | ||||||
|  | .LP | ||||||
|  | UNIX manual page by R. P. C. Rodgers, | ||||||
|  | U.S. National Library of Medicine (rodgers@nlm.nih.gov). | ||||||
|  | .\" end of man page | ||||||
							
								
								
									
										107
									
								
								zlib.h
									
									
									
									
									
								
							
							
						
						
									
										107
									
								
								zlib.h
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | |||||||
| /* zlib.h -- interface of the 'zlib' general purpose compression library | /* zlib.h -- interface of the 'zlib' general purpose compression library | ||||||
|   version 1.2.0.1, March 17th, 2003 |   version 1.2.0.3, July 19th, 2003 | ||||||
|  |  | ||||||
|   Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler |   Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler | ||||||
|  |  | ||||||
| @@ -28,8 +28,8 @@ | |||||||
|   (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). |   (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). | ||||||
| */ | */ | ||||||
|  |  | ||||||
| #ifndef _ZLIB_H | #ifndef ZLIB_H | ||||||
| #define _ZLIB_H | #define ZLIB_H | ||||||
|  |  | ||||||
| #include "zconf.h" | #include "zconf.h" | ||||||
|  |  | ||||||
| @@ -37,7 +37,8 @@ | |||||||
| extern "C" { | extern "C" { | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #define ZLIB_VERSION "1.2.0.1" | #define ZLIB_VERSION "1.2.0.3" | ||||||
|  | #define ZLIB_VERNUM 0x1203 | ||||||
|  |  | ||||||
| /*  | /*  | ||||||
|      The 'zlib' compression library provides in-memory compression and |      The 'zlib' compression library provides in-memory compression and | ||||||
| @@ -334,9 +335,9 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); | |||||||
| ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); | ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); | ||||||
| /* | /* | ||||||
|     inflate decompresses as much data as possible, and stops when the input |     inflate decompresses as much data as possible, and stops when the input | ||||||
|   buffer becomes empty or the output buffer becomes full. It may some |   buffer becomes empty or the output buffer becomes full. It may introduce | ||||||
|   introduce some output latency (reading input without producing any output) |   some output latency (reading input without producing any output) except when | ||||||
|   except when forced to flush. |   forced to flush. | ||||||
|  |  | ||||||
|   The detailed semantics are as follows. inflate performs one or both of the |   The detailed semantics are as follows. inflate performs one or both of the | ||||||
|   following actions: |   following actions: | ||||||
| @@ -586,20 +587,28 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, | |||||||
|      The windowBits parameter is the base two logarithm of the maximum window |      The windowBits parameter is the base two logarithm of the maximum window | ||||||
|    size (the size of the history buffer).  It should be in the range 8..15 for |    size (the size of the history buffer).  It should be in the range 8..15 for | ||||||
|    this version of the library. The default value is 15 if inflateInit is used |    this version of the library. The default value is 15 if inflateInit is used | ||||||
|    instead. If a compressed stream with a larger window size is given as |    instead. windowBits must be greater than or equal to the windowBits value | ||||||
|    input, inflate() will return with the error code Z_DATA_ERROR instead of |    provided to deflateInit2() while compressing, or it must be equal to 15 if | ||||||
|    trying to allocate a larger window. |    deflateInit2() was not used. If a compressed stream with a larger window | ||||||
|  |    size is given as input, inflate() will return with the error code | ||||||
|  |    Z_DATA_ERROR instead of trying to allocate a larger window. | ||||||
|  |  | ||||||
|      windowBits can also be -8..-15 for raw inflate.  In this case, -windowBits |      windowBits can also be -8..-15 for raw inflate. In this case, -windowBits | ||||||
|    determines the window size.  inflate() will then process raw deflate data, |    determines the window size. inflate() will then process raw deflate data, | ||||||
|    not looking for a zlib or gzip header, not generating a check value, and not |    not looking for a zlib or gzip header, not generating a check value, and not | ||||||
|    looking for any check values for comparison at the end of the stream.  This |    looking for any check values for comparison at the end of the stream. This | ||||||
|    is for use with other formats that use the deflate compressed data format |    is for use with other formats that use the deflate compressed data format | ||||||
|    such as zip.  Those formats provide their own check values.  If a custom |    such as zip.  Those formats provide their own check values. If a custom | ||||||
|    format is developed using the raw deflate format for compressed data, it is |    format is developed using the raw deflate format for compressed data, it is | ||||||
|    recommended that a check value such as an adler32 or a crc32 be applied to |    recommended that a check value such as an adler32 or a crc32 be applied to | ||||||
|    the uncompressed data as is done in the zlib, gzip, and zip formats.  For |    the uncompressed data as is done in the zlib, gzip, and zip formats.  For | ||||||
|    most applications, the zlib format should be used as is. |    most applications, the zlib format should be used as is. Note that comments | ||||||
|  |    above on the use in deflateInit2() applies to the magnitude of windowBits. | ||||||
|  |  | ||||||
|  |      windowBits can also be greater than 15 for optional gzip decoding. Add | ||||||
|  |    32 to windowBits to enable zlib and gzip decoding with automatic header | ||||||
|  |    detection, or add 16 to decode only the gzip format (the zlib format will | ||||||
|  |    return a Z_DATA_ERROR). | ||||||
|  |  | ||||||
|      inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |      inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough | ||||||
|    memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative |    memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative | ||||||
| @@ -771,6 +780,45 @@ ZEXTERN int ZEXPORT inflateBackEnd(z_stream FAR *strm); | |||||||
|    state was inconsistent. |    state was inconsistent. | ||||||
| */ | */ | ||||||
|  |  | ||||||
|  | ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); | ||||||
|  | /* Return flags indicating compile-time options. | ||||||
|  |  | ||||||
|  |     Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: | ||||||
|  |      1.0: size of uInt | ||||||
|  |      3.2: size of uLong | ||||||
|  |      5.4: size of voidpf (pointers) | ||||||
|  |      7.6: size of z_off_t | ||||||
|  |  | ||||||
|  |     Debug options: | ||||||
|  |      8: DEBUG | ||||||
|  |      9-11: 0 (reserved) | ||||||
|  |  | ||||||
|  |     One-time table building (smaller code, but not thread-safe if true): | ||||||
|  |      12: BUILDFIXED -- build static block decoding tables when needed | ||||||
|  |      13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed | ||||||
|  |      14,15: 0 (reserved) | ||||||
|  |  | ||||||
|  |     Library content (indicates missing functionality): | ||||||
|  |      16: NO_DEFLATE -- gz* functions cannot compress (to avoid linking deflate | ||||||
|  |                        code when not needed) | ||||||
|  |      17: NO_GUNZIP -- inflate can't detect and decode gzip streams, to avoid | ||||||
|  |                       linking crc code | ||||||
|  |      18-19: 0 (reserved) | ||||||
|  |  | ||||||
|  |     Operation variations (changes in library functionality): | ||||||
|  |      20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate | ||||||
|  |      21: FASTEST -- deflate algorithm with only one, lowest compression level | ||||||
|  |      22,23: 0 (reserved) | ||||||
|  |  | ||||||
|  |     The sprintf variant used by gzprintf (zero is best): | ||||||
|  |      24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format | ||||||
|  |      25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! | ||||||
|  |      26: 0 = returns value, 1 = void -- 1 means inferred string length returned | ||||||
|  |  | ||||||
|  |     Remainder: | ||||||
|  |      27-31: 0 (reserved) | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  |  | ||||||
|                         /* utility functions */ |                         /* utility functions */ | ||||||
|  |  | ||||||
| @@ -901,10 +949,10 @@ ZEXTERN int ZEXPORTVA   gzprintf OF((gzFile file, const char *format, ...)); | |||||||
|    control of the format string, as in fprintf. gzprintf returns the number of |    control of the format string, as in fprintf. gzprintf returns the number of | ||||||
|    uncompressed bytes actually written (0 in case of error).  The number of |    uncompressed bytes actually written (0 in case of error).  The number of | ||||||
|    uncompressed bytes written is limited to 4095. The caller should assure that |    uncompressed bytes written is limited to 4095. The caller should assure that | ||||||
|    this limit is not exceeded. If it is exceeded, then either gzprintf() will |    this limit is not exceeded. If it is exceeded, then gzprintf() will return | ||||||
|    return an error (0) with nothing written, or there will be a buffer overflow |    return an error (0) with nothing written. In this case, there may also be a | ||||||
|    with unpredictable consequences. The latter is possible only if zlib was |    buffer overflow with unpredictable consequences, which is possible only if | ||||||
|    compiled with insecure variants of printf, i.e. sprintf() or vsprintf() |    zlib was compiled with the insecure functions sprintf() or vsprintf() | ||||||
|    because the secure snprintf() or vsnprintf() functions were not available. |    because the secure snprintf() or vsnprintf() functions were not available. | ||||||
| */ | */ | ||||||
|  |  | ||||||
| @@ -936,6 +984,16 @@ ZEXTERN int ZEXPORT    gzgetc OF((gzFile file)); | |||||||
|    or -1 in case of end of file or error. |    or -1 in case of end of file or error. | ||||||
| */ | */ | ||||||
|  |  | ||||||
|  | ZEXTERN int ZEXPORT    gzungetc OF((int c, gzFile file)); | ||||||
|  | /* | ||||||
|  |       Push one character back onto the stream to be read again later. | ||||||
|  |    Only one character of push-back is allowed.  gzungetc() returns the | ||||||
|  |    character pushed, or -1 on failure.  gzungetc() will fail if a | ||||||
|  |    character has been pushed but not read yet, or if c is -1. The pushed | ||||||
|  |    character will be discarded if the stream is repositioned with gzseek() | ||||||
|  |    or gzrewind(). | ||||||
|  | */ | ||||||
|  |  | ||||||
| ZEXTERN int ZEXPORT    gzflush OF((gzFile file, int flush)); | ZEXTERN int ZEXPORT    gzflush OF((gzFile file, int flush)); | ||||||
| /* | /* | ||||||
|      Flushes all pending output into the compressed file. The parameter |      Flushes all pending output into the compressed file. The parameter | ||||||
| @@ -1002,6 +1060,13 @@ ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); | |||||||
|    to get the exact error code. |    to get the exact error code. | ||||||
| */ | */ | ||||||
|  |  | ||||||
|  | ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); | ||||||
|  | /* | ||||||
|  |      Clears the error and end-of-file flags for file. This is analogous to the | ||||||
|  |    clearerr() function in stdio. This is useful for continuing to read a gzip | ||||||
|  |    file that is being written concurrently. | ||||||
|  | */ | ||||||
|  |  | ||||||
|                         /* checksum functions */ |                         /* checksum functions */ | ||||||
|  |  | ||||||
| /* | /* | ||||||
| @@ -1077,7 +1142,7 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_stream FAR *strm, int windowBits, | |||||||
|         ZLIB_VERSION, sizeof(z_stream)) |         ZLIB_VERSION, sizeof(z_stream)) | ||||||
|  |  | ||||||
|  |  | ||||||
| #if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) | #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) | ||||||
|     struct internal_state {int dummy;}; /* hack for buggy compilers */ |     struct internal_state {int dummy;}; /* hack for buggy compilers */ | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -1089,4 +1154,4 @@ ZEXTERN const uLongf * ZEXPORT get_crc_table    OF((void)); | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #endif /* _ZLIB_H */ | #endif /* ZLIB_H */ | ||||||
|   | |||||||
							
								
								
									
										83
									
								
								zutil.c
									
									
									
									
									
								
							
							
						
						
									
										83
									
								
								zutil.c
									
									
									
									
									
								
							| @@ -7,7 +7,9 @@ | |||||||
|  |  | ||||||
| #include "zutil.h" | #include "zutil.h" | ||||||
|  |  | ||||||
|  | #ifndef NO_DUMMY_DECL | ||||||
| struct internal_state      {int dummy;}; /* for buggy compilers */ | struct internal_state      {int dummy;}; /* for buggy compilers */ | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifndef STDC | #ifndef STDC | ||||||
| extern void exit OF((int)); | extern void exit OF((int)); | ||||||
| @@ -31,6 +33,83 @@ const char * ZEXPORT zlibVersion() | |||||||
|     return ZLIB_VERSION; |     return ZLIB_VERSION; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | uLong ZEXPORT zlibCompileFlags() | ||||||
|  | { | ||||||
|  |     uLong flags; | ||||||
|  |  | ||||||
|  |     flags = 0; | ||||||
|  |     switch (sizeof(uInt)) { | ||||||
|  |     case 2:     break; | ||||||
|  |     case 4:     flags += 1;     break; | ||||||
|  |     case 8:     flags += 2;     break; | ||||||
|  |     default:    flags += 3; | ||||||
|  |     } | ||||||
|  |     switch (sizeof(uLong)) { | ||||||
|  |     case 2:     break; | ||||||
|  |     case 4:     flags += 1 << 2;        break; | ||||||
|  |     case 8:     flags += 2 << 2;        break; | ||||||
|  |     default:    flags += 3 << 2; | ||||||
|  |     } | ||||||
|  |     switch (sizeof(voidpf)) { | ||||||
|  |     case 2:     break; | ||||||
|  |     case 4:     flags += 1 << 4;        break; | ||||||
|  |     case 8:     flags += 2 << 4;        break; | ||||||
|  |     default:    flags += 3 << 4; | ||||||
|  |     } | ||||||
|  |     switch (sizeof(z_off_t)) { | ||||||
|  |     case 2:     break; | ||||||
|  |     case 4:     flags += 1 << 6;        break; | ||||||
|  |     case 8:     flags += 2 << 6;        break; | ||||||
|  |     default:    flags += 3 << 6; | ||||||
|  |     } | ||||||
|  | #ifdef DEBUG | ||||||
|  |     flags += 1 << 8; | ||||||
|  | #endif | ||||||
|  | #ifdef BUILDFIXED | ||||||
|  |     flags += 1 << 12; | ||||||
|  | #endif | ||||||
|  | #ifdef DYNAMIC_CRC_TABLE | ||||||
|  |     flags += 1 << 13; | ||||||
|  | #endif | ||||||
|  | #ifdef NO_DEFLATE | ||||||
|  |     flags += 1 << 16; | ||||||
|  | #endif | ||||||
|  | #ifdef NO_GUNZIP | ||||||
|  |     flags += 1 << 17; | ||||||
|  | #endif | ||||||
|  | #ifdef PKZIP_BUG_WORKAROUND | ||||||
|  |     flags += 1 << 20; | ||||||
|  | #endif | ||||||
|  | #ifdef FASTEST | ||||||
|  |     flags += 1 << 21; | ||||||
|  | #endif | ||||||
|  | #ifdef STDC | ||||||
|  | #  ifdef NO_vsnprintf | ||||||
|  |         flags += 1 << 25; | ||||||
|  | #    ifdef HAS_vsprintf_void | ||||||
|  |         flags += 1 << 26; | ||||||
|  | #    endif | ||||||
|  | #  else | ||||||
|  | #    ifdef HAS_vsnprintf_void | ||||||
|  |         flags += 1 << 26; | ||||||
|  | #    endif | ||||||
|  | #  endif | ||||||
|  | #else | ||||||
|  |         flags += 1 << 24; | ||||||
|  | #  ifdef NO_snprintf | ||||||
|  |         flags += 1 << 25; | ||||||
|  | #    ifdef HAS_sprintf_void | ||||||
|  |         flags += 1 << 26; | ||||||
|  | #    endif | ||||||
|  | #  else | ||||||
|  | #    ifdef HAS_snprintf_void | ||||||
|  |         flags += 1 << 26; | ||||||
|  | #    endif | ||||||
|  | #  endif | ||||||
|  | #endif | ||||||
|  |     return flags; | ||||||
|  | } | ||||||
|  |  | ||||||
| #ifdef DEBUG | #ifdef DEBUG | ||||||
|  |  | ||||||
| #  ifndef verbose | #  ifndef verbose | ||||||
| @@ -55,6 +134,10 @@ const char * ZEXPORT zError(err) | |||||||
|     return ERR_MSG(err); |     return ERR_MSG(err); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | #if defined(_WIN32_WCE) | ||||||
|  |     /* does not exist on WCE */ | ||||||
|  |     int errno = 0; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifndef HAVE_MEMCPY | #ifndef HAVE_MEMCPY | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								zutil.h
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								zutil.h
									
									
									
									
									
								
							| @@ -10,9 +10,10 @@ | |||||||
|  |  | ||||||
| /* @(#) $Id$ */ | /* @(#) $Id$ */ | ||||||
|  |  | ||||||
| #ifndef _Z_UTIL_H | #ifndef ZUTIL_H | ||||||
| #define _Z_UTIL_H | #define ZUTIL_H | ||||||
|  |  | ||||||
|  | #define ZLIB_INTERNAL | ||||||
| #include "zlib.h" | #include "zlib.h" | ||||||
|  |  | ||||||
| #ifdef STDC | #ifdef STDC | ||||||
| @@ -134,7 +135,11 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if (defined(_MSC_VER) && (_MSC_VER > 600)) | #if (defined(_MSC_VER) && (_MSC_VER > 600)) | ||||||
| #  define fdopen(fd,type)  _fdopen(fd,type) | #  if defined(_WIN32_WCE) | ||||||
|  | #    define fdopen(fd,mode) NULL /* No fdopen() */ | ||||||
|  | #  else | ||||||
|  | #    define fdopen(fd,type)  _fdopen(fd,type) | ||||||
|  | #  endif | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -157,7 +162,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||||||
| #    endif | #    endif | ||||||
| #  endif | #  endif | ||||||
| #endif | #endif | ||||||
| #if !defined(STDC99) && !(defined(__TURBOC__) && __TURBOC__ >= 0x550) && !defined(VSNPRINTF_DEFINED) | #if !defined(STDC99) && !(defined(__TURBOC__) && __TURBOC__ >= 0x550) && !defined(HAVE_VSNPRINTF) | ||||||
| #  ifdef MSDOS | #  ifdef MSDOS | ||||||
|      /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), |      /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), | ||||||
|         but for now we just assume it doesn't. */ |         but for now we just assume it doesn't. */ | ||||||
| @@ -239,4 +244,4 @@ void   zcfree  OF((voidpf opaque, voidpf ptr)); | |||||||
| #define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) | #define ZFREE(strm, addr)  (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) | ||||||
| #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} | #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} | ||||||
|  |  | ||||||
| #endif /* _Z_UTIL_H */ | #endif /* ZUTIL_H */ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user