diff options
| -rw-r--r-- | ChangeLog | 26 | ||||
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | Makefile.in | 4 | ||||
| -rw-r--r-- | README | 4 | ||||
| -rw-r--r-- | as400/zlib.inc | 6 | ||||
| -rwxr-xr-x | configure | 15 | ||||
| -rw-r--r-- | contrib/infback9/inftree9.c | 4 | ||||
| -rw-r--r-- | contrib/vstudio/vc7/zlib.rc | 6 | ||||
| -rw-r--r-- | crc32.c | 9 | ||||
| -rw-r--r-- | deflate.c | 82 | ||||
| -rw-r--r-- | deflate.h | 4 | ||||
| -rw-r--r-- | examples/README.examples | 5 | ||||
| -rw-r--r-- | examples/fitblk.c | 14 | ||||
| -rw-r--r-- | examples/gun.c | 23 | ||||
| -rw-r--r-- | examples/gzjoin.c | 5 | ||||
| -rw-r--r-- | examples/zran.c | 404 | ||||
| -rw-r--r-- | gzio.c | 7 | ||||
| -rw-r--r-- | infback.c | 4 | ||||
| -rw-r--r-- | inflate.c | 31 | ||||
| -rw-r--r-- | inftrees.c | 9 | ||||
| -rw-r--r-- | inftrees.h | 10 | ||||
| -rw-r--r-- | make_vms.com | 409 | ||||
| -rw-r--r-- | qnx/package.qpg | 10 | ||||
| -rw-r--r-- | trees.c | 4 | ||||
| -rw-r--r-- | win32/zlib1.rc | 8 | ||||
| -rw-r--r-- | zlib.3 | 6 | ||||
| -rw-r--r-- | zlib.h | 32 | ||||
| -rw-r--r-- | zutil.c | 24 | ||||
| -rw-r--r-- | zutil.h | 3 |
29 files changed, 1035 insertions, 137 deletions
| @@ -1,6 +1,30 @@ | |||
| 1 | 1 | ||
| 2 | ChangeLog file for zlib | 2 | ChangeLog file for zlib |
| 3 | 3 | ||
| 4 | Changes in 1.2.2.4 (11 July 2005) | ||
| 5 | - Add inflatePrime() function for starting inflation at bit boundary | ||
| 6 | - Avoid some Visual C warnings in deflate.c | ||
| 7 | - Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit | ||
| 8 | compile | ||
| 9 | - Fix some spelling errors in comments [Betts] | ||
| 10 | - Correct inflateInit2() error return documentation in zlib.h | ||
| 11 | - Added zran.c example of compressed data random access to examples | ||
| 12 | directory, shows use of inflatePrime() | ||
| 13 | - Fix cast for assignments to strm->state in inflate.c and infback.c | ||
| 14 | - Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer] | ||
| 15 | - Move declarations of gf2 functions to right place in crc32.c [Oberhumer] | ||
| 16 | - Add cast in trees.c t avoid a warning [Oberhumer] | ||
| 17 | - Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer] | ||
| 18 | - Update make_vms.com [Zinser] | ||
| 19 | - Initialize state->write in inflateReset() since copied in inflate_fast() | ||
| 20 | - Be more strict on incomplete code sets in inflate_table() and increase | ||
| 21 | ENOUGH and MAXD -- this repairs a possible security vulnerability for | ||
| 22 | invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for | ||
| 23 | discovering the vulnerability and providing test cases. | ||
| 24 | - Add ia64 support to configure for HP-UX [Smith] | ||
| 25 | - Add error return to gzread() for format or i/o error [Levin] | ||
| 26 | - Use malloc.h for OS/2 [Necasek] | ||
| 27 | |||
| 4 | Changes in 1.2.2.3 (27 May 2005) | 28 | Changes in 1.2.2.3 (27 May 2005) |
| 5 | - Replace 1U constants in inflate.c and inftrees.c for 64-bit compile | 29 | - Replace 1U constants in inflate.c and inftrees.c for 64-bit compile |
| 6 | - Typecast fread() return values in gzio.c [Vollant] | 30 | - Typecast fread() return values in gzio.c [Vollant] |
| @@ -511,7 +535,7 @@ Changes in 1.0.7 (20 Jan 1998) | |||
| 511 | Changes in 1.0.6 (19 Jan 1998) | 535 | Changes in 1.0.6 (19 Jan 1998) |
| 512 | - add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and | 536 | - add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and |
| 513 | gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code) | 537 | gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code) |
| 514 | - Fix a deflate bug occuring only with compression level 0 (thanks to | 538 | - Fix a deflate bug occurring only with compression level 0 (thanks to |
| 515 | Andy Buckler for finding this one). | 539 | Andy Buckler for finding this one). |
| 516 | - In minigzip, pass transparently also the first byte for .Z files. | 540 | - In minigzip, pass transparently also the first byte for .Z files. |
| 517 | - return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress() | 541 | - return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress() |
| @@ -1,5 +1,5 @@ | |||
| 1 | # Makefile for zlib | 1 | # Makefile for zlib |
| 2 | # Copyright (C) 1995-2003 Jean-loup Gailly. | 2 | # Copyright (C) 1995-2005 Jean-loup Gailly. |
| 3 | # For conditions of distribution and use, see copyright notice in zlib.h | 3 | # For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | 4 | ||
| 5 | # To compile and test, type: | 5 | # To compile and test, type: |
| @@ -30,7 +30,7 @@ CPP=$(CC) -E | |||
| 30 | 30 | ||
| 31 | LIBS=libz.a | 31 | LIBS=libz.a |
| 32 | SHAREDLIB=libz.so | 32 | SHAREDLIB=libz.so |
| 33 | SHAREDLIBV=libz.so.1.2.2.3 | 33 | SHAREDLIBV=libz.so.1.2.2.4 |
| 34 | SHAREDLIBM=libz.so.1 | 34 | SHAREDLIBM=libz.so.1 |
| 35 | 35 | ||
| 36 | AR=ar rc | 36 | AR=ar rc |
diff --git a/Makefile.in b/Makefile.in index 535779d..26f63cd 100644 --- a/Makefile.in +++ b/Makefile.in | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | # Makefile for zlib | 1 | # Makefile for zlib |
| 2 | # Copyright (C) 1995-2003 Jean-loup Gailly. | 2 | # Copyright (C) 1995-2005 Jean-loup Gailly. |
| 3 | # For conditions of distribution and use, see copyright notice in zlib.h | 3 | # For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | 4 | ||
| 5 | # To compile and test, type: | 5 | # To compile and test, type: |
| @@ -30,7 +30,7 @@ CPP=$(CC) -E | |||
| 30 | 30 | ||
| 31 | LIBS=libz.a | 31 | LIBS=libz.a |
| 32 | SHAREDLIB=libz.so | 32 | SHAREDLIB=libz.so |
| 33 | SHAREDLIBV=libz.so.1.2.2.3 | 33 | SHAREDLIBV=libz.so.1.2.2.4 |
| 34 | SHAREDLIBM=libz.so.1 | 34 | SHAREDLIBM=libz.so.1 |
| 35 | 35 | ||
| 36 | AR=ar rc | 36 | AR=ar rc |
| @@ -1,6 +1,6 @@ | |||
| 1 | ZLIB DATA COMPRESSION LIBRARY | 1 | ZLIB DATA COMPRESSION LIBRARY |
| 2 | 2 | ||
| 3 | zlib 1.2.2.3 is a general purpose data compression library. All the code is | 3 | zlib 1.2.2.4 is a general purpose data compression library. All the code is |
| 4 | thread safe. The data format used by the zlib library is described by RFCs | 4 | thread safe. The data format used by the zlib library is described by RFCs |
| 5 | (Request for Comments) 1950 to 1952 in the files | 5 | (Request for Comments) 1950 to 1952 in the files |
| 6 | http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) | 6 | http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) |
| @@ -33,7 +33,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997 | |||
| 33 | issue of Dr. Dobb's Journal; a copy of the article is available in | 33 | issue of Dr. Dobb's Journal; a copy of the article is available in |
| 34 | http://dogma.net/markn/articles/zlibtool/zlibtool.htm | 34 | http://dogma.net/markn/articles/zlibtool/zlibtool.htm |
| 35 | 35 | ||
| 36 | The changes made in version 1.2.2.3 are documented in the file ChangeLog. | 36 | The changes made in version 1.2.2.4 are documented in the file ChangeLog. |
| 37 | 37 | ||
| 38 | Unsupported third party contributions are provided in directory "contrib". | 38 | Unsupported third party contributions are provided in directory "contrib". |
| 39 | 39 | ||
diff --git a/as400/zlib.inc b/as400/zlib.inc index 2905ee0..263677d 100644 --- a/as400/zlib.inc +++ b/as400/zlib.inc | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | * ZLIB.INC - Interface to the general purpose compression library | 1 | * ZLIB.INC - Interface to the general purpose compression library |
| 2 | * | 2 | * |
| 3 | * ILE RPG400 version by Patrick Monnerat, DATASPHERE. | 3 | * ILE RPG400 version by Patrick Monnerat, DATASPHERE. |
| 4 | * Version 1.2.2.3 | 4 | * Version 1.2.2.4 |
| 5 | * | 5 | * |
| 6 | * | 6 | * |
| 7 | * WARNING: | 7 | * WARNING: |
| @@ -22,8 +22,8 @@ | |||
| 22 | * | 22 | * |
| 23 | * Versioning information. | 23 | * Versioning information. |
| 24 | * | 24 | * |
| 25 | D ZLIB_VERSION C '1.2.2.3' | 25 | D ZLIB_VERSION C '1.2.2.4' |
| 26 | D ZLIB_VERNUM C X'1223' | 26 | D ZLIB_VERNUM C X'1224' |
| 27 | * | 27 | * |
| 28 | * Other equates. | 28 | * Other equates. |
| 29 | * | 29 | * |
| @@ -82,9 +82,16 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then | |||
| 82 | QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 | 82 | QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 |
| 83 | # (alain.bonnefoy@icbt.com) | 83 | # (alain.bonnefoy@icbt.com) |
| 84 | LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"};; | 84 | LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"};; |
| 85 | HP-UX*) LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"} | 85 | HP-UX*) |
| 86 | LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"} | ||
| 87 | case `(uname -m || echo unknown) 2>/dev/null` in | ||
| 88 | ia64) | ||
| 89 | shared_ext='.so' | ||
| 90 | SHAREDLIB='libz.so';; | ||
| 91 | *) | ||
| 86 | shared_ext='.sl' | 92 | shared_ext='.sl' |
| 87 | SHAREDLIB='libz.sl';; | 93 | SHAREDLIB='libz.sl';; |
| 94 | esac;; | ||
| 88 | Darwin*) shared_ext='.dylib' | 95 | Darwin*) shared_ext='.dylib' |
| 89 | SHAREDLIB=libz$shared_ext | 96 | SHAREDLIB=libz$shared_ext |
| 90 | SHAREDLIBV=libz.$VER$shared_ext | 97 | SHAREDLIBV=libz.$VER$shared_ext |
| @@ -100,8 +107,14 @@ else | |||
| 100 | CFLAGS=${CFLAGS-"-O"} | 107 | CFLAGS=${CFLAGS-"-O"} |
| 101 | # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} | 108 | # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} |
| 102 | LDSHARED=${LDSHARED-"ld -b"} | 109 | LDSHARED=${LDSHARED-"ld -b"} |
| 110 | case `(uname -m || echo unknown) 2>/dev/null` in | ||
| 111 | ia64) | ||
| 112 | shared_ext='.so' | ||
| 113 | SHAREDLIB='libz.so';; | ||
| 114 | *) | ||
| 103 | shared_ext='.sl' | 115 | shared_ext='.sl' |
| 104 | SHAREDLIB='libz.sl';; | 116 | SHAREDLIB='libz.sl';; |
| 117 | esac;; | ||
| 105 | IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."} | 118 | IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."} |
| 106 | CFLAGS=${CFLAGS-"-ansi -O2"} | 119 | CFLAGS=${CFLAGS-"-ansi -O2"} |
| 107 | LDSHARED=${LDSHARED-"cc -shared"};; | 120 | LDSHARED=${LDSHARED-"cc -shared"};; |
diff --git a/contrib/infback9/inftree9.c b/contrib/infback9/inftree9.c index ac4575c..9e37840 100644 --- a/contrib/infback9/inftree9.c +++ b/contrib/infback9/inftree9.c | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #define MAXBITS 15 | 9 | #define MAXBITS 15 |
| 10 | 10 | ||
| 11 | const char inflate9_copyright[] = | 11 | const char inflate9_copyright[] = |
| 12 | " inflate9 1.2.2.3 Copyright 1995-2005 Mark Adler "; | 12 | " inflate9 1.2.2.4 Copyright 1995-2005 Mark Adler "; |
| 13 | /* | 13 | /* |
| 14 | If you use the zlib library in a product, an acknowledgment is welcome | 14 | If you use the zlib library in a product, an acknowledgment is welcome |
| 15 | in the documentation of your product. If for some reason you cannot | 15 | in the documentation of your product. If for some reason you cannot |
| @@ -64,7 +64,7 @@ unsigned short FAR *work; | |||
| 64 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ | 64 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ |
| 65 | 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, | 65 | 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, |
| 66 | 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, | 66 | 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, |
| 67 | 133, 133, 133, 133, 144, 66, 71}; | 67 | 133, 133, 133, 133, 144, 206, 69}; |
| 68 | static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ | 68 | static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ |
| 69 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, | 69 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, |
| 70 | 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, | 70 | 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, |
diff --git a/contrib/vstudio/vc7/zlib.rc b/contrib/vstudio/vc7/zlib.rc index d0651ec..e9d748f 100644 --- a/contrib/vstudio/vc7/zlib.rc +++ b/contrib/vstudio/vc7/zlib.rc | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | #define IDR_VERSION1 1 | 3 | #define IDR_VERSION1 1 |
| 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE | 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | FILEVERSION 1,2,2,3 | 5 | FILEVERSION 1,2,2,4 |
| 6 | PRODUCTVERSION 1,2,2,3 | 6 | PRODUCTVERSION 1,2,2,4 |
| 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK | 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | FILEFLAGS 0 | 8 | FILEFLAGS 0 |
| 9 | FILEOS VOS_DOS_WINDOWS32 | 9 | FILEOS VOS_DOS_WINDOWS32 |
| @@ -17,7 +17,7 @@ BEGIN | |||
| 17 | 17 | ||
| 18 | BEGIN | 18 | BEGIN |
| 19 | VALUE "FileDescription", "zlib data compression library\0" | 19 | VALUE "FileDescription", "zlib data compression library\0" |
| 20 | VALUE "FileVersion", "1.2.2.3\0" | 20 | VALUE "FileVersion", "1.2.2.4\0" |
| 21 | VALUE "InternalName", "zlib\0" | 21 | VALUE "InternalName", "zlib\0" |
| 22 | VALUE "OriginalFilename", "zlib.dll\0" | 22 | VALUE "OriginalFilename", "zlib.dll\0" |
| 23 | VALUE "ProductName", "ZLib.DLL\0" | 23 | VALUE "ProductName", "ZLib.DLL\0" |
| @@ -64,6 +64,11 @@ | |||
| 64 | # define TBLS 1 | 64 | # define TBLS 1 |
| 65 | #endif /* BYFOUR */ | 65 | #endif /* BYFOUR */ |
| 66 | 66 | ||
| 67 | /* Local functions for crc concatenation */ | ||
| 68 | local unsigned long gf2_matrix_times OF((unsigned long *mat, | ||
| 69 | unsigned long vec)); | ||
| 70 | local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); | ||
| 71 | |||
| 67 | #ifdef DYNAMIC_CRC_TABLE | 72 | #ifdef DYNAMIC_CRC_TABLE |
| 68 | 73 | ||
| 69 | local volatile int crc_table_empty = 1; | 74 | local volatile int crc_table_empty = 1; |
| @@ -72,10 +77,6 @@ local void make_crc_table OF((void)); | |||
| 72 | #ifdef MAKECRCH | 77 | #ifdef MAKECRCH |
| 73 | local void write_table OF((FILE *, const unsigned long FAR *)); | 78 | local void write_table OF((FILE *, const unsigned long FAR *)); |
| 74 | #endif /* MAKECRCH */ | 79 | #endif /* MAKECRCH */ |
| 75 | local unsigned long gf2_matrix_times OF((unsigned long *mat, | ||
| 76 | unsigned long vec)); | ||
| 77 | local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); | ||
| 78 | |||
| 79 | /* | 80 | /* |
| 80 | Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: | 81 | Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: |
| 81 | x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. | 82 | x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. |
| @@ -52,7 +52,7 @@ | |||
| 52 | #include "deflate.h" | 52 | #include "deflate.h" |
| 53 | 53 | ||
| 54 | const char deflate_copyright[] = | 54 | const char deflate_copyright[] = |
| 55 | " deflate 1.2.2.3 Copyright 1995-2005 Jean-loup Gailly "; | 55 | " deflate 1.2.2.4 Copyright 1995-2005 Jean-loup Gailly "; |
| 56 | /* | 56 | /* |
| 57 | If you use the zlib library in a product, an acknowledgment is welcome | 57 | If you use the zlib library in a product, an acknowledgment is welcome |
| 58 | in the documentation of your product. If for some reason you cannot | 58 | in the documentation of your product. If for some reason you cannot |
| @@ -600,10 +600,10 @@ int ZEXPORT deflate (strm, flush) | |||
| 600 | (s->gzhead->name == Z_NULL ? 0 : 8) + | 600 | (s->gzhead->name == Z_NULL ? 0 : 8) + |
| 601 | (s->gzhead->comment == Z_NULL ? 0 : 16) | 601 | (s->gzhead->comment == Z_NULL ? 0 : 16) |
| 602 | ); | 602 | ); |
| 603 | put_byte(s, s->gzhead->time & 0xff); | 603 | put_byte(s, (Byte)(s->gzhead->time & 0xff)); |
| 604 | put_byte(s, (s->gzhead->time >> 8) & 0xff); | 604 | put_byte(s, (Byte)((s->gzhead->time >> 8) & 0xff)); |
| 605 | put_byte(s, (s->gzhead->time >> 16) & 0xff); | 605 | put_byte(s, (Byte)((s->gzhead->time >> 16) & 0xff)); |
| 606 | put_byte(s, (s->gzhead->time >> 24) & 0xff); | 606 | put_byte(s, (Byte)((s->gzhead->time >> 24) & 0xff)); |
| 607 | put_byte(s, s->level == 9 ? 2 : | 607 | put_byte(s, s->level == 9 ? 2 : |
| 608 | (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? | 608 | (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2 ? |
| 609 | 4 : 0)); | 609 | 4 : 0)); |
| @@ -651,7 +651,7 @@ int ZEXPORT deflate (strm, flush) | |||
| 651 | #ifdef GZIP | 651 | #ifdef GZIP |
| 652 | if (s->status == EXTRA_STATE) { | 652 | if (s->status == EXTRA_STATE) { |
| 653 | if (s->gzhead->extra != NULL) { | 653 | if (s->gzhead->extra != NULL) { |
| 654 | int beg = s->pending; /* start of bytes to update crc */ | 654 | uInt beg = s->pending; /* start of bytes to update crc */ |
| 655 | 655 | ||
| 656 | while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { | 656 | while (s->gzindex < (s->gzhead->extra_len & 0xffff)) { |
| 657 | if (s->pending == s->pending_buf_size) { | 657 | if (s->pending == s->pending_buf_size) { |
| @@ -679,7 +679,7 @@ int ZEXPORT deflate (strm, flush) | |||
| 679 | } | 679 | } |
| 680 | if (s->status == NAME_STATE) { | 680 | if (s->status == NAME_STATE) { |
| 681 | if (s->gzhead->name != NULL) { | 681 | if (s->gzhead->name != NULL) { |
| 682 | int beg = s->pending; /* start of bytes to update crc */ | 682 | uInt beg = s->pending; /* start of bytes to update crc */ |
| 683 | int val; | 683 | int val; |
| 684 | 684 | ||
| 685 | do { | 685 | do { |
| @@ -710,7 +710,7 @@ int ZEXPORT deflate (strm, flush) | |||
| 710 | } | 710 | } |
| 711 | if (s->status == COMMENT_STATE) { | 711 | if (s->status == COMMENT_STATE) { |
| 712 | if (s->gzhead->comment != NULL) { | 712 | if (s->gzhead->comment != NULL) { |
| 713 | int beg = s->pending; /* start of bytes to update crc */ | 713 | uInt beg = s->pending; /* start of bytes to update crc */ |
| 714 | int val; | 714 | int val; |
| 715 | 715 | ||
| 716 | do { | 716 | do { |
| @@ -742,8 +742,8 @@ int ZEXPORT deflate (strm, flush) | |||
| 742 | if (s->pending + 2 > s->pending_buf_size) | 742 | if (s->pending + 2 > s->pending_buf_size) |
| 743 | flush_pending(strm); | 743 | flush_pending(strm); |
| 744 | if (s->pending + 2 <= s->pending_buf_size) { | 744 | if (s->pending + 2 <= s->pending_buf_size) { |
| 745 | put_byte(s, strm->adler & 0xff); | 745 | put_byte(s, (Byte)(strm->adler & 0xff)); |
| 746 | put_byte(s, (strm->adler >> 8) & 0xff); | 746 | put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); |
| 747 | strm->adler = crc32(0L, Z_NULL, 0); | 747 | strm->adler = crc32(0L, Z_NULL, 0); |
| 748 | s->status = BUSY_STATE; | 748 | s->status = BUSY_STATE; |
| 749 | } | 749 | } |
| @@ -1303,6 +1303,7 @@ local void fill_window(s) | |||
| 1303 | later. (Using level 0 permanently is not an optimal usage of | 1303 | later. (Using level 0 permanently is not an optimal usage of |
| 1304 | zlib, so we don't care about this pathological case.) | 1304 | zlib, so we don't care about this pathological case.) |
| 1305 | */ | 1305 | */ |
| 1306 | /* %%% avoid this when Z_RLE */ | ||
| 1306 | n = s->hash_size; | 1307 | n = s->hash_size; |
| 1307 | p = &s->head[n]; | 1308 | p = &s->head[n]; |
| 1308 | do { | 1309 | do { |
| @@ -1672,3 +1673,64 @@ local block_state deflate_slow(s, flush) | |||
| 1672 | return flush == Z_FINISH ? finish_done : block_done; | 1673 | return flush == Z_FINISH ? finish_done : block_done; |
| 1673 | } | 1674 | } |
| 1674 | #endif /* FASTEST */ | 1675 | #endif /* FASTEST */ |
| 1676 | |||
| 1677 | #if 0 | ||
| 1678 | /* =========================================================================== | ||
| 1679 | * For Z_RLE, simply look for runs of bytes, generate matches only of distance | ||
| 1680 | * one. Do not maintain a hash table. (It will be regenerated if this run of | ||
| 1681 | * deflate switches away from Z_RLE.) | ||
| 1682 | */ | ||
| 1683 | local block_state deflate_rle(s, flush) | ||
| 1684 | deflate_state *s; | ||
| 1685 | int flush; | ||
| 1686 | { | ||
| 1687 | int bflush; /* set if current block must be flushed */ | ||
| 1688 | uInt run; /* length of run */ | ||
| 1689 | uInt max; /* maximum length of run */ | ||
| 1690 | uInt prev; /* byte at distance one to match */ | ||
| 1691 | Bytef *scan; /* scan for end of run */ | ||
| 1692 | |||
| 1693 | for (;;) { | ||
| 1694 | /* Make sure that we always have enough lookahead, except | ||
| 1695 | * at the end of the input file. We need MAX_MATCH bytes | ||
| 1696 | * for the longest encodable run. | ||
| 1697 | */ | ||
| 1698 | if (s->lookahead < MAX_MATCH) { | ||
| 1699 | fill_window(s); | ||
| 1700 | if (s->lookahead < MAX_MATCH && flush == Z_NO_FLUSH) { | ||
| 1701 | return need_more; | ||
| 1702 | } | ||
| 1703 | if (s->lookahead == 0) break; /* flush the current block */ | ||
| 1704 | } | ||
| 1705 | |||
| 1706 | /* See how many times the previous byte repeats */ | ||
| 1707 | run = 0; | ||
| 1708 | if (s->strstart > 0) { /* if there is a previous byte, that is */ | ||
| 1709 | max = s->lookahead < MAX_MATCH ? s->lookahead : MAX_MATCH; | ||
| 1710 | scan = s->window + s->strstart - 1; | ||
| 1711 | prev = *scan++; | ||
| 1712 | do { | ||
| 1713 | if (*scan++ != prev) | ||
| 1714 | break; | ||
| 1715 | } while (++run < max); | ||
| 1716 | } | ||
| 1717 | |||
| 1718 | /* Emit match if have run of MIN_MATCH or longer, else emit literal */ | ||
| 1719 | if (run >= MIN_MATCH) { | ||
| 1720 | check_match(s, s->strstart, s->strstart - 1, run); | ||
| 1721 | _tr_tally_dist(s, 1, run - MIN_MATCH, bflush); | ||
| 1722 | s->lookahead -= run; | ||
| 1723 | s->strstart += run; | ||
| 1724 | } else { | ||
| 1725 | /* No match, output a literal byte */ | ||
| 1726 | Tracevv((stderr,"%c", s->window[s->strstart])); | ||
| 1727 | _tr_tally_lit (s, s->window[s->strstart], bflush); | ||
| 1728 | s->lookahead--; | ||
| 1729 | s->strstart++; | ||
| 1730 | } | ||
| 1731 | if (bflush) FLUSH_BLOCK(s, 0); | ||
| 1732 | } | ||
| 1733 | FLUSH_BLOCK(s, flush == Z_FINISH); | ||
| 1734 | return flush == Z_FINISH ? finish_done : block_done; | ||
| 1735 | } | ||
| 1736 | #endif | ||
| @@ -97,10 +97,10 @@ typedef struct internal_state { | |||
| 97 | Bytef *pending_buf; /* output still pending */ | 97 | Bytef *pending_buf; /* output still pending */ |
| 98 | ulg pending_buf_size; /* size of pending_buf */ | 98 | ulg pending_buf_size; /* size of pending_buf */ |
| 99 | Bytef *pending_out; /* next pending byte to output to the stream */ | 99 | Bytef *pending_out; /* next pending byte to output to the stream */ |
| 100 | int pending; /* nb of bytes in the pending buffer */ | 100 | uInt pending; /* nb of bytes in the pending buffer */ |
| 101 | int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ | 101 | int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ |
| 102 | gz_headerp gzhead; /* gzip header information to write */ | 102 | gz_headerp gzhead; /* gzip header information to write */ |
| 103 | int gzindex; /* where in extra, name, or comment */ | 103 | uInt gzindex; /* where in extra, name, or comment */ |
| 104 | Byte method; /* STORED (for zip only) or DEFLATED */ | 104 | Byte method; /* STORED (for zip only) or DEFLATED */ |
| 105 | int last_flush; /* value of flush param for previous deflate call */ | 105 | int last_flush; /* value of flush param for previous deflate call */ |
| 106 | 106 | ||
diff --git a/examples/README.examples b/examples/README.examples index 75e9970..5632d7a 100644 --- a/examples/README.examples +++ b/examples/README.examples | |||
| @@ -35,3 +35,8 @@ zpipe.c | |||
| 35 | reads and writes zlib streams from stdin to stdout | 35 | reads and writes zlib streams from stdin to stdout |
| 36 | - illustrates the proper use of deflate() and inflate() | 36 | - illustrates the proper use of deflate() and inflate() |
| 37 | - deeply commented in zlib_how.html (see above) | 37 | - deeply commented in zlib_how.html (see above) |
| 38 | |||
| 39 | zran.c | ||
| 40 | index a zlib or gzip stream and randomly access it | ||
| 41 | - illustrates the use of Z_BLOCK, inflatePrime(), and | ||
| 42 | inflateSetDictionary() to provide random access | ||
diff --git a/examples/fitblk.c b/examples/fitblk.c index 5f83114..c61de5c 100644 --- a/examples/fitblk.c +++ b/examples/fitblk.c | |||
| @@ -73,7 +73,7 @@ local void quit(char *why) | |||
| 73 | local int partcompress(FILE *in, z_streamp def) | 73 | local int partcompress(FILE *in, z_streamp def) |
| 74 | { | 74 | { |
| 75 | int ret, flush; | 75 | int ret, flush; |
| 76 | char raw[RAWLEN]; | 76 | unsigned char raw[RAWLEN]; |
| 77 | 77 | ||
| 78 | flush = Z_NO_FLUSH; | 78 | flush = Z_NO_FLUSH; |
| 79 | do { | 79 | do { |
| @@ -96,7 +96,7 @@ local int partcompress(FILE *in, z_streamp def) | |||
| 96 | local int recompress(z_streamp inf, z_streamp def) | 96 | local int recompress(z_streamp inf, z_streamp def) |
| 97 | { | 97 | { |
| 98 | int ret, flush; | 98 | int ret, flush; |
| 99 | char raw[RAWLEN]; | 99 | unsigned char raw[RAWLEN]; |
| 100 | 100 | ||
| 101 | flush = Z_NO_FLUSH; | 101 | flush = Z_NO_FLUSH; |
| 102 | do { | 102 | do { |
| @@ -129,8 +129,8 @@ int main(int argc, char **argv) | |||
| 129 | int ret; /* return code */ | 129 | int ret; /* return code */ |
| 130 | unsigned size; /* requested fixed output block size */ | 130 | unsigned size; /* requested fixed output block size */ |
| 131 | unsigned have; /* bytes written by deflate() call */ | 131 | unsigned have; /* bytes written by deflate() call */ |
| 132 | char *blk; /* intermediate and final stream */ | 132 | unsigned char *blk; /* intermediate and final stream */ |
| 133 | char *tmp; /* close to desired size stream */ | 133 | unsigned char *tmp; /* close to desired size stream */ |
| 134 | z_stream def, inf; /* zlib deflate and inflate states */ | 134 | z_stream def, inf; /* zlib deflate and inflate states */ |
| 135 | 135 | ||
| 136 | /* get requested output size */ | 136 | /* get requested output size */ |
| @@ -163,8 +163,7 @@ int main(int argc, char **argv) | |||
| 163 | if (ret == Z_STREAM_END && def.avail_out >= EXCESS) { | 163 | if (ret == Z_STREAM_END && def.avail_out >= EXCESS) { |
| 164 | /* write block to stdout */ | 164 | /* write block to stdout */ |
| 165 | have = size + EXCESS - def.avail_out; | 165 | have = size + EXCESS - def.avail_out; |
| 166 | ret = fwrite(blk, 1, have, stdout); | 166 | if (fwrite(blk, 1, have, stdout) != have || ferror(stdout)) |
| 167 | if (ret != have || ferror(stdout)) | ||
| 168 | quit("error writing output"); | 167 | quit("error writing output"); |
| 169 | 168 | ||
| 170 | /* clean up and print results to stderr */ | 169 | /* clean up and print results to stderr */ |
| @@ -217,8 +216,7 @@ int main(int argc, char **argv) | |||
| 217 | 216 | ||
| 218 | /* done -- write block to stdout */ | 217 | /* done -- write block to stdout */ |
| 219 | have = size - def.avail_out; | 218 | have = size - def.avail_out; |
| 220 | ret = fwrite(blk, 1, have, stdout); | 219 | if (fwrite(blk, 1, have, stdout) != have || ferror(stdout)) |
| 221 | if (ret != have || ferror(stdout)) | ||
| 222 | quit("error writing output"); | 220 | quit("error writing output"); |
| 223 | 221 | ||
| 224 | /* clean up and print results to stderr */ | 222 | /* clean up and print results to stderr */ |
diff --git a/examples/gun.c b/examples/gun.c index 1c0d8e5..bfec590 100644 --- a/examples/gun.c +++ b/examples/gun.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* gun.c -- simple gunzip to give an example of the use of inflateBack() | 1 | /* gun.c -- simple gunzip to give an example of the use of inflateBack() |
| 2 | * Copyright (C) 2003, 2005 Mark Adler | 2 | * Copyright (C) 2003, 2005 Mark Adler |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | Version 1.2 20 March 2005 Mark Adler */ | 4 | Version 1.3 12 June 2005 Mark Adler */ |
| 5 | 5 | ||
| 6 | /* Version history: | 6 | /* Version history: |
| 7 | 1.0 16 Feb 2003 First version for testing of inflateBack() | 7 | 1.0 16 Feb 2003 First version for testing of inflateBack() |
| @@ -14,6 +14,7 @@ | |||
| 14 | Add a bunch of comments | 14 | Add a bunch of comments |
| 15 | 1.2 20 Mar 2005 Add Unix compress (LZW) decompression | 15 | 1.2 20 Mar 2005 Add Unix compress (LZW) decompression |
| 16 | Copy file attributes from input file to output file | 16 | Copy file attributes from input file to output file |
| 17 | 1.3 12 Jun 2005 Add casts for error messages [Oberhumer] | ||
| 17 | */ | 18 | */ |
| 18 | 19 | ||
| 19 | /* | 20 | /* |
| @@ -221,12 +222,12 @@ local int lunpipe(unsigned have, unsigned char *next, struct ind *indp, | |||
| 221 | if (last == -1) | 222 | if (last == -1) |
| 222 | return Z_BUF_ERROR; | 223 | return Z_BUF_ERROR; |
| 223 | if (flags & 0x60) { | 224 | if (flags & 0x60) { |
| 224 | strm->msg = "unknown lzw flags set"; | 225 | strm->msg = (char *)"unknown lzw flags set"; |
| 225 | return Z_DATA_ERROR; | 226 | return Z_DATA_ERROR; |
| 226 | } | 227 | } |
| 227 | max = flags & 0x1f; | 228 | max = flags & 0x1f; |
| 228 | if (max < 9 || max > 16) { | 229 | if (max < 9 || max > 16) { |
| 229 | strm->msg = "lzw bits out of range"; | 230 | strm->msg = (char *)"lzw bits out of range"; |
| 230 | return Z_DATA_ERROR; | 231 | return Z_DATA_ERROR; |
| 231 | } | 232 | } |
| 232 | if (max == 9) /* 9 doesn't really mean 9 */ | 233 | if (max == 9) /* 9 doesn't really mean 9 */ |
| @@ -246,7 +247,7 @@ local int lunpipe(unsigned have, unsigned char *next, struct ind *indp, | |||
| 246 | if (NEXT() == -1) /* missing a bit */ | 247 | if (NEXT() == -1) /* missing a bit */ |
| 247 | return Z_BUF_ERROR; | 248 | return Z_BUF_ERROR; |
| 248 | if (last & 1) { /* code must be < 256 */ | 249 | if (last & 1) { /* code must be < 256 */ |
| 249 | strm->msg = "invalid lzw code"; | 250 | strm->msg = (char *)"invalid lzw code"; |
| 250 | return Z_DATA_ERROR; | 251 | return Z_DATA_ERROR; |
| 251 | } | 252 | } |
| 252 | rem = (unsigned)last >> 1; /* remaining 7 bits */ | 253 | rem = (unsigned)last >> 1; /* remaining 7 bits */ |
| @@ -313,7 +314,7 @@ local int lunpipe(unsigned have, unsigned char *next, struct ind *indp, | |||
| 313 | to detect random or corrupted input after a compress header. | 314 | to detect random or corrupted input after a compress header. |
| 314 | In any case, the prev > end check must be retained. */ | 315 | In any case, the prev > end check must be retained. */ |
| 315 | if (code != end + 1 || prev > end) { | 316 | if (code != end + 1 || prev > end) { |
| 316 | strm->msg = "invalid lzw code"; | 317 | strm->msg = (char *)"invalid lzw code"; |
| 317 | return Z_DATA_ERROR; | 318 | return Z_DATA_ERROR; |
| 318 | } | 319 | } |
| 319 | match[stack++] = (unsigned char)final; | 320 | match[stack++] = (unsigned char)final; |
| @@ -394,7 +395,7 @@ local int gunpipe(z_stream *strm, int infile, int outfile) | |||
| 394 | break; /* empty gzip stream is ok */ | 395 | break; /* empty gzip stream is ok */ |
| 395 | } | 396 | } |
| 396 | if (last != 31 || (NEXT() != 139 && last != 157)) { | 397 | if (last != 31 || (NEXT() != 139 && last != 157)) { |
| 397 | strm->msg = "incorrect header check"; | 398 | strm->msg = (char *)"incorrect header check"; |
| 398 | ret = first ? Z_DATA_ERROR : Z_ERRNO; | 399 | ret = first ? Z_DATA_ERROR : Z_ERRNO; |
| 399 | break; /* not a gzip or compress header */ | 400 | break; /* not a gzip or compress header */ |
| 400 | } | 401 | } |
| @@ -410,7 +411,7 @@ local int gunpipe(z_stream *strm, int infile, int outfile) | |||
| 410 | ret = Z_BUF_ERROR; | 411 | ret = Z_BUF_ERROR; |
| 411 | if (NEXT() != 8) { /* only deflate method allowed */ | 412 | if (NEXT() != 8) { /* only deflate method allowed */ |
| 412 | if (last == -1) break; | 413 | if (last == -1) break; |
| 413 | strm->msg = "unknown compression method"; | 414 | strm->msg = (char *)"unknown compression method"; |
| 414 | ret = Z_DATA_ERROR; | 415 | ret = Z_DATA_ERROR; |
| 415 | break; | 416 | break; |
| 416 | } | 417 | } |
| @@ -423,7 +424,7 @@ local int gunpipe(z_stream *strm, int infile, int outfile) | |||
| 423 | NEXT(); | 424 | NEXT(); |
| 424 | if (last == -1) break; | 425 | if (last == -1) break; |
| 425 | if (flags & 0xe0) { | 426 | if (flags & 0xe0) { |
| 426 | strm->msg = "unknown header flags set"; | 427 | strm->msg = (char *)"unknown header flags set"; |
| 427 | ret = Z_DATA_ERROR; | 428 | ret = Z_DATA_ERROR; |
| 428 | break; | 429 | break; |
| 429 | } | 430 | } |
| @@ -476,7 +477,7 @@ local int gunpipe(z_stream *strm, int infile, int outfile) | |||
| 476 | NEXT() != ((outd.crc >> 24) & 0xff)) { | 477 | NEXT() != ((outd.crc >> 24) & 0xff)) { |
| 477 | /* crc error */ | 478 | /* crc error */ |
| 478 | if (last != -1) { | 479 | if (last != -1) { |
| 479 | strm->msg = "incorrect data check"; | 480 | strm->msg = (char *)"incorrect data check"; |
| 480 | ret = Z_DATA_ERROR; | 481 | ret = Z_DATA_ERROR; |
| 481 | } | 482 | } |
| 482 | break; | 483 | break; |
| @@ -487,7 +488,7 @@ local int gunpipe(z_stream *strm, int infile, int outfile) | |||
| 487 | NEXT() != ((outd.total >> 24) & 0xff)) { | 488 | NEXT() != ((outd.total >> 24) & 0xff)) { |
| 488 | /* length error */ | 489 | /* length error */ |
| 489 | if (last != -1) { | 490 | if (last != -1) { |
| 490 | strm->msg = "incorrect length check"; | 491 | strm->msg = (char *)"incorrect length check"; |
| 491 | ret = Z_DATA_ERROR; | 492 | ret = Z_DATA_ERROR; |
| 492 | } | 493 | } |
| 493 | break; | 494 | break; |
| @@ -641,7 +642,7 @@ int main(int argc, char **argv) | |||
| 641 | argv++; | 642 | argv++; |
| 642 | test = 0; | 643 | test = 0; |
| 643 | if (argc && strcmp(*argv, "-h") == 0) { | 644 | if (argc && strcmp(*argv, "-h") == 0) { |
| 644 | fprintf(stderr, "gun 1.2 (20 Mar 2005)\n"); | 645 | fprintf(stderr, "gun 1.3 (12 Jun 2005)\n"); |
| 645 | fprintf(stderr, "Copyright (c) 2005 Mark Adler\n"); | 646 | fprintf(stderr, "Copyright (c) 2005 Mark Adler\n"); |
| 646 | fprintf(stderr, "usage: gun [-t] [file1.gz [file2.Z ...]]\n"); | 647 | fprintf(stderr, "usage: gun [-t] [file1.gz [file2.Z ...]]\n"); |
| 647 | return 0; | 648 | return 0; |
diff --git a/examples/gzjoin.c b/examples/gzjoin.c index 7434c5b..129347c 100644 --- a/examples/gzjoin.c +++ b/examples/gzjoin.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | * Change history: | 26 | * Change history: |
| 27 | * | 27 | * |
| 28 | * 1.0 11 Dec 2004 - First version | 28 | * 1.0 11 Dec 2004 - First version |
| 29 | * 1.1 12 Jun 2005 - Changed ssize_t to long for portability | ||
| 29 | */ | 30 | */ |
| 30 | 31 | ||
| 31 | /* | 32 | /* |
| @@ -118,7 +119,7 @@ local bin *bopen(char *name) | |||
| 118 | 1 indicating that end-of-file was reached */ | 119 | 1 indicating that end-of-file was reached */ |
| 119 | local int bload(bin *in) | 120 | local int bload(bin *in) |
| 120 | { | 121 | { |
| 121 | ssize_t len; | 122 | long len; |
| 122 | 123 | ||
| 123 | if (in == NULL) | 124 | if (in == NULL) |
| 124 | return -1; | 125 | return -1; |
| @@ -126,7 +127,7 @@ local int bload(bin *in) | |||
| 126 | return 0; | 127 | return 0; |
| 127 | in->next = in->buf; | 128 | in->next = in->buf; |
| 128 | do { | 129 | do { |
| 129 | len = read(in->fd, in->buf + in->left, CHUNK - in->left); | 130 | len = (long)read(in->fd, in->buf + in->left, CHUNK - in->left); |
| 130 | if (len < 0) | 131 | if (len < 0) |
| 131 | return -1; | 132 | return -1; |
| 132 | in->left += (unsigned)len; | 133 | in->left += (unsigned)len; |
diff --git a/examples/zran.c b/examples/zran.c new file mode 100644 index 0000000..8c7717e --- /dev/null +++ b/examples/zran.c | |||
| @@ -0,0 +1,404 @@ | |||
| 1 | /* zran.c -- example of zlib/gzip stream indexing and random access | ||
| 2 | * Copyright (C) 2005 Mark Adler | ||
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
| 4 | Version 1.0 29 May 2005 Mark Adler */ | ||
| 5 | |||
| 6 | /* Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary() | ||
| 7 | for random access of a compressed file. A file containing a zlib or gzip | ||
| 8 | stream is provided on the command line. The compressed stream is decoded in | ||
| 9 | its entirety, and an index built with access points about every SPAN bytes | ||
| 10 | in the uncompressed output. The compressed file is left open, and can then | ||
| 11 | be read randomly, having to decompress on the average SPAN/2 uncompressed | ||
| 12 | bytes before getting to the desired block of data. | ||
| 13 | |||
| 14 | An access point can be created at the start of any deflate block, by saving | ||
| 15 | the starting file offset and bit of that block, and the 32K bytes of | ||
| 16 | uncompressed data that precede that block. Also the uncompressed offset of | ||
| 17 | that block is saved to provide a referece for locating a desired starting | ||
| 18 | point in the uncompressed stream. build_index() works by decompressing the | ||
| 19 | input zlib or gzip stream a block at a time, and at the end of each block | ||
| 20 | deciding if enough uncompressed data has gone by to justify the creation of | ||
| 21 | a new access point. If so, that point is saved in a data structure that | ||
| 22 | grows as needed to accommodate the points. | ||
| 23 | |||
| 24 | To use the index, an offset in the uncompressed data is provided, for which | ||
| 25 | the latest accees point at or preceding that offset is located in the index. | ||
| 26 | The input file is positioned to the specified location in the index, and if | ||
| 27 | necessary the first few bits of the compressed data is read from the file. | ||
| 28 | inflate is initialized with those bits and the 32K of uncompressed data, and | ||
| 29 | the decompression then proceeds until the desired offset in the file is | ||
| 30 | reached. Then the decompression continues to read the desired uncompressed | ||
| 31 | data from the file. | ||
| 32 | |||
| 33 | Another approach would be to generate the index on demand. In that case, | ||
| 34 | requests for random access reads from the compressed data would try to use | ||
| 35 | the index, but if a read far enough past the end of the index is required, | ||
| 36 | then further index entries would be generated and added. | ||
| 37 | |||
| 38 | There is some fair bit of overhead to starting inflation for the random | ||
| 39 | access, mainly copying the 32K byte dictionary. So if small pieces of the | ||
| 40 | file are being accessed, it would make sense to implement a cache to hold | ||
| 41 | some lookahead and avoid many calls to extract() for small lengths. | ||
| 42 | |||
| 43 | Another way to build an index would be to use inflateCopy(). That would | ||
| 44 | not be constrained to have access points at block boundaries, but requires | ||
| 45 | more memory per access point, and also cannot be saved to file due to the | ||
| 46 | use of pointers in the state. The approach here allows for storage of the | ||
| 47 | index in a file. | ||
| 48 | */ | ||
| 49 | |||
| 50 | #include <stdio.h> | ||
| 51 | #include <stdlib.h> | ||
| 52 | #include <string.h> | ||
| 53 | #include "zlib.h" | ||
| 54 | |||
| 55 | #define local static | ||
| 56 | |||
| 57 | #define SPAN 1048576L /* desired distance between access points */ | ||
| 58 | #define WINSIZE 32768U /* sliding window size */ | ||
| 59 | #define CHUNK 16384 /* file input buffer size */ | ||
| 60 | |||
| 61 | /* access point entry */ | ||
| 62 | struct point { | ||
| 63 | off_t out; /* corresponding offset in uncompressed data */ | ||
| 64 | off_t in; /* offset in input file of first full byte */ | ||
| 65 | int bits; /* number of bits (1-7) from byte at in - 1, or 0 */ | ||
| 66 | unsigned char window[WINSIZE]; /* preceding 32K of uncompressed data */ | ||
| 67 | }; | ||
| 68 | |||
| 69 | /* access point list */ | ||
| 70 | struct access { | ||
| 71 | int have; /* number of list entries filled in */ | ||
| 72 | int size; /* number of list entries allocated */ | ||
| 73 | struct point *list; /* allocated list */ | ||
| 74 | }; | ||
| 75 | |||
| 76 | /* Deallocate an index built by build_index() */ | ||
| 77 | local void free_index(struct access *index) | ||
| 78 | { | ||
| 79 | if (index != NULL) { | ||
| 80 | free(index->list); | ||
| 81 | free(index); | ||
| 82 | } | ||
| 83 | } | ||
| 84 | |||
| 85 | /* Add an entry to the access point list. If out of memory, deallocate the | ||
| 86 | existing list and return NULL. */ | ||
| 87 | local struct access *addpoint(struct access *index, int bits, | ||
| 88 | off_t in, off_t out, unsigned left, unsigned char *window) | ||
| 89 | { | ||
| 90 | struct point *next; | ||
| 91 | |||
| 92 | /* if list is empty, create it (start with eight points) */ | ||
| 93 | if (index == NULL) { | ||
| 94 | index = malloc(sizeof(struct access)); | ||
| 95 | if (index == NULL) return NULL; | ||
| 96 | index->list = malloc(sizeof(struct point) << 3); | ||
| 97 | if (index->list == NULL) { | ||
| 98 | free(index); | ||
| 99 | return NULL; | ||
| 100 | } | ||
| 101 | index->size = 8; | ||
| 102 | index->have = 0; | ||
| 103 | } | ||
| 104 | |||
| 105 | /* if list is full, make it bigger */ | ||
| 106 | else if (index->have == index->size) { | ||
| 107 | index->size <<= 1; | ||
| 108 | next = realloc(index->list, sizeof(struct point) * index->size); | ||
| 109 | if (next == NULL) { | ||
| 110 | free_index(index); | ||
| 111 | return NULL; | ||
| 112 | } | ||
| 113 | index->list = next; | ||
| 114 | } | ||
| 115 | |||
| 116 | /* fill in entry and increment how many we have */ | ||
| 117 | next = index->list + index->have; | ||
| 118 | next->bits = bits; | ||
| 119 | next->in = in; | ||
| 120 | next->out = out; | ||
| 121 | if (left) | ||
| 122 | memcpy(next->window, window + WINSIZE - left, left); | ||
| 123 | if (left < WINSIZE) | ||
| 124 | memcpy(next->window + left, window, WINSIZE - left); | ||
| 125 | index->have++; | ||
| 126 | |||
| 127 | /* return list, possibly reallocated */ | ||
| 128 | return index; | ||
| 129 | } | ||
| 130 | |||
| 131 | /* Make one entire pass through the compressed stream and build an index, with | ||
| 132 | access points about every span bytes of uncompressed output -- span is | ||
| 133 | chosen to balance the speed of random access against the memory requirements | ||
| 134 | of the list, about 32K bytes per access point. Note that data after the end | ||
| 135 | of the first zlib or gzip stream in the file is ignored. build_index() | ||
| 136 | returns the number of access points on success (>= 1), Z_MEM_ERROR for out | ||
| 137 | of memory, Z_DATA_ERROR for an error in the input file, or Z_ERRNO for a | ||
| 138 | file read error. On success, *built points to the resulting index. */ | ||
| 139 | local int build_index(FILE *in, off_t span, struct access **built) | ||
| 140 | { | ||
| 141 | int ret; | ||
| 142 | off_t totin, totout; /* our own total counters to avoid 4GB limit */ | ||
| 143 | off_t last; /* totout value of last access point */ | ||
| 144 | struct access *index; /* access points being generated */ | ||
| 145 | z_stream strm; | ||
| 146 | unsigned char input[CHUNK]; | ||
| 147 | unsigned char window[WINSIZE]; | ||
| 148 | |||
| 149 | /* initialize inflate */ | ||
| 150 | strm.zalloc = Z_NULL; | ||
| 151 | strm.zfree = Z_NULL; | ||
| 152 | strm.opaque = Z_NULL; | ||
| 153 | strm.avail_in = 0; | ||
| 154 | strm.next_in = Z_NULL; | ||
| 155 | ret = inflateInit2(&strm, 47); /* automatic zlib or gzip decoding */ | ||
| 156 | if (ret != Z_OK) | ||
| 157 | return ret; | ||
| 158 | |||
| 159 | /* inflate the input, maintain a sliding window, and build an index -- this | ||
| 160 | also validates the integrity of the compressed data using the check | ||
| 161 | information at the end of the gzip or zlib stream */ | ||
| 162 | totin = totout = last = 0; | ||
| 163 | index = NULL; /* will be allocated by first addpoint() */ | ||
| 164 | strm.avail_out = 0; | ||
| 165 | do { | ||
| 166 | /* get some compressed data from input file */ | ||
| 167 | strm.avail_in = fread(input, 1, CHUNK, in); | ||
| 168 | if (ferror(in)) { | ||
| 169 | ret = Z_ERRNO; | ||
| 170 | goto build_index_error; | ||
| 171 | } | ||
| 172 | if (strm.avail_in == 0) { | ||
| 173 | ret = Z_DATA_ERROR; | ||
| 174 | goto build_index_error; | ||
| 175 | } | ||
| 176 | strm.next_in = input; | ||
| 177 | |||
| 178 | /* process all of that, or until end of stream */ | ||
| 179 | do { | ||
| 180 | /* reset sliding window if necessary */ | ||
| 181 | if (strm.avail_out == 0) { | ||
| 182 | strm.avail_out = WINSIZE; | ||
| 183 | strm.next_out = window; | ||
| 184 | } | ||
| 185 | |||
| 186 | /* inflate until out of input, output, or at end of block -- | ||
| 187 | update the total input and output counters */ | ||
| 188 | totin += strm.avail_in; | ||
| 189 | totout += strm.avail_out; | ||
| 190 | ret = inflate(&strm, Z_BLOCK); /* return at end of block */ | ||
| 191 | totin -= strm.avail_in; | ||
| 192 | totout -= strm.avail_out; | ||
| 193 | if (ret == Z_NEED_DICT) | ||
| 194 | ret = Z_DATA_ERROR; | ||
| 195 | if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR) | ||
| 196 | goto build_index_error; | ||
| 197 | if (ret == Z_STREAM_END) | ||
| 198 | break; | ||
| 199 | |||
| 200 | /* if at end of block, consider adding an index entry (note that if | ||
| 201 | data_type indicates an end-of-block, then all of the | ||
| 202 | uncompressed data from that block has been delivered, and none | ||
| 203 | of the compressed data after that block has been consumed, | ||
| 204 | except for up to seven bits) -- the totout == 0 provides an | ||
| 205 | entry point after the zlib or gzip header, and assures that the | ||
| 206 | index always has at least one access point; we avoid creating an | ||
| 207 | access point after the last block by checking bit 6 of data_type | ||
| 208 | */ | ||
| 209 | if ((strm.data_type & 128) && !(strm.data_type & 64) && | ||
| 210 | (totout == 0 || totout - last > span)) { | ||
| 211 | index = addpoint(index, strm.data_type & 7, totin, | ||
| 212 | totout, strm.avail_out, window); | ||
| 213 | if (index == NULL) { | ||
| 214 | ret = Z_MEM_ERROR; | ||
| 215 | goto build_index_error; | ||
| 216 | } | ||
| 217 | last = totout; | ||
| 218 | } | ||
| 219 | } while (strm.avail_in != 0); | ||
| 220 | } while (ret != Z_STREAM_END); | ||
| 221 | |||
| 222 | /* clean up and return index (release unused entries in list) */ | ||
| 223 | (void)inflateEnd(&strm); | ||
| 224 | index = realloc(index, sizeof(struct point) * index->have); | ||
| 225 | index->size = index->have; | ||
| 226 | *built = index; | ||
| 227 | return index->size; | ||
| 228 | |||
| 229 | /* return error */ | ||
| 230 | build_index_error: | ||
| 231 | (void)inflateEnd(&strm); | ||
| 232 | if (index != NULL) | ||
| 233 | free_index(index); | ||
| 234 | return ret; | ||
| 235 | } | ||
| 236 | |||
| 237 | /* Use the index to read len bytes from offset into buf, return bytes read or | ||
| 238 | negative for error (Z_DATA_ERROR or Z_MEM_ERROR). If data is requested past | ||
| 239 | the end of the uncompressed data, then extract() will return a value less | ||
| 240 | than len, indicating how much as actually read into buf. This function | ||
| 241 | should not return a data error unless the file was modified since the index | ||
| 242 | was generated. extract() may also return Z_ERRNO if there is an error on | ||
| 243 | reading or seeking the input file. */ | ||
| 244 | local int extract(FILE *in, struct access *index, off_t offset, | ||
| 245 | unsigned char *buf, int len) | ||
| 246 | { | ||
| 247 | int ret, skip; | ||
| 248 | z_stream strm; | ||
| 249 | struct point *here; | ||
| 250 | unsigned char input[CHUNK]; | ||
| 251 | unsigned char discard[WINSIZE]; | ||
| 252 | |||
| 253 | /* proceed only if something reasonable to do */ | ||
| 254 | if (len < 0) | ||
| 255 | return 0; | ||
| 256 | |||
| 257 | /* find where in stream to start */ | ||
| 258 | here = index->list; | ||
| 259 | ret = index->have; | ||
| 260 | while (--ret && here[1].out <= offset) | ||
| 261 | here++; | ||
| 262 | |||
| 263 | /* initialize file and inflate state to start there */ | ||
| 264 | strm.zalloc = Z_NULL; | ||
| 265 | strm.zfree = Z_NULL; | ||
| 266 | strm.opaque = Z_NULL; | ||
| 267 | strm.avail_in = 0; | ||
| 268 | strm.next_in = Z_NULL; | ||
| 269 | ret = inflateInit2(&strm, -15); /* raw inflate */ | ||
| 270 | if (ret != Z_OK) | ||
| 271 | return ret; | ||
| 272 | ret = fseeko(in, here->in - (here->bits ? 1 : 0), SEEK_SET); | ||
| 273 | if (ret == -1) | ||
| 274 | goto extract_ret; | ||
| 275 | if (here->bits) { | ||
| 276 | ret = getc(in); | ||
| 277 | if (ret == -1) { | ||
| 278 | ret = ferror(in) ? Z_ERRNO : Z_DATA_ERROR; | ||
| 279 | goto extract_ret; | ||
| 280 | } | ||
| 281 | (void)inflatePrime(&strm, here->bits, ret >> (8 - here->bits)); | ||
| 282 | } | ||
| 283 | (void)inflateSetDictionary(&strm, here->window, WINSIZE); | ||
| 284 | |||
| 285 | /* skip uncompressed bytes until offset reached, then satisfy request */ | ||
| 286 | offset -= here->out; | ||
| 287 | strm.avail_in = 0; | ||
| 288 | skip = 1; /* while skipping to offset */ | ||
| 289 | do { | ||
| 290 | /* define where to put uncompressed data, and how much */ | ||
| 291 | if (offset == 0 && skip) { /* at offset now */ | ||
| 292 | strm.avail_out = len; | ||
| 293 | strm.next_out = buf; | ||
| 294 | skip = 0; /* only do this once */ | ||
| 295 | } | ||
| 296 | if (offset > WINSIZE) { /* skip WINSIZE bytes */ | ||
| 297 | strm.avail_out = WINSIZE; | ||
| 298 | strm.next_out = discard; | ||
| 299 | offset -= WINSIZE; | ||
| 300 | } | ||
| 301 | else if (offset != 0) { /* last skip */ | ||
| 302 | strm.avail_out = (unsigned)offset; | ||
| 303 | strm.next_out = discard; | ||
| 304 | offset = 0; | ||
| 305 | } | ||
| 306 | |||
| 307 | /* uncompress until avail_out filled, or end of stream */ | ||
| 308 | do { | ||
| 309 | if (strm.avail_in == 0) { | ||
| 310 | strm.avail_in = fread(input, 1, CHUNK, in); | ||
| 311 | if (ferror(in)) { | ||
| 312 | ret = Z_ERRNO; | ||
| 313 | goto extract_ret; | ||
| 314 | } | ||
| 315 | if (strm.avail_in == 0) { | ||
| 316 | ret = Z_DATA_ERROR; | ||
| 317 | goto extract_ret; | ||
| 318 | } | ||
| 319 | strm.next_in = input; | ||
| 320 | } | ||
| 321 | ret = inflate(&strm, Z_NO_FLUSH); /* normal inflate */ | ||
| 322 | if (ret == Z_NEED_DICT) | ||
| 323 | ret = Z_DATA_ERROR; | ||
| 324 | if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR) | ||
| 325 | goto extract_ret; | ||
| 326 | if (ret == Z_STREAM_END) | ||
| 327 | break; | ||
| 328 | } while (strm.avail_out != 0); | ||
| 329 | |||
| 330 | /* if reach end of stream, then don't keep trying to get more */ | ||
| 331 | if (ret == Z_STREAM_END) | ||
| 332 | break; | ||
| 333 | |||
| 334 | /* do until offset reached and requested data read, or stream ends */ | ||
| 335 | } while (skip); | ||
| 336 | |||
| 337 | /* compute number of uncompressed bytes read after offset */ | ||
| 338 | ret = skip ? 0 : len - strm.avail_out; | ||
| 339 | |||
| 340 | /* clean up and return bytes read or error */ | ||
| 341 | extract_ret: | ||
| 342 | (void)inflateEnd(&strm); | ||
| 343 | return ret; | ||
| 344 | } | ||
| 345 | |||
| 346 | /* Demonstrate the use of build_index() and extract() by processing the file | ||
| 347 | provided on the command line, and the extracting 16K from about 2/3rds of | ||
| 348 | the way through the uncompressed output, and writing that to stdout. */ | ||
| 349 | int main(int argc, char **argv) | ||
| 350 | { | ||
| 351 | int len; | ||
| 352 | off_t offset; | ||
| 353 | FILE *in; | ||
| 354 | struct access *index; | ||
| 355 | unsigned char buf[CHUNK]; | ||
| 356 | |||
| 357 | /* open input file */ | ||
| 358 | if (argc != 2) { | ||
| 359 | fprintf(stderr, "usage: zran file.gz\n"); | ||
| 360 | return 1; | ||
| 361 | } | ||
| 362 | in = fopen(argv[1], "rb"); | ||
| 363 | if (in == NULL) { | ||
| 364 | fprintf(stderr, "zran: could not open %s for reading\n", argv[1]); | ||
| 365 | return 1; | ||
| 366 | } | ||
| 367 | |||
| 368 | /* build index */ | ||
| 369 | len = build_index(in, SPAN, &index); | ||
| 370 | if (len < 0) { | ||
| 371 | fclose(in); | ||
| 372 | switch (len) { | ||
| 373 | case Z_MEM_ERROR: | ||
| 374 | fprintf(stderr, "zran: out of memory\n"); | ||
| 375 | break; | ||
| 376 | case Z_DATA_ERROR: | ||
| 377 | fprintf(stderr, "zran: compressed data error in %s\n", argv[1]); | ||
| 378 | break; | ||
| 379 | case Z_ERRNO: | ||
| 380 | fprintf(stderr, "zran: read error on %s\n", argv[1]); | ||
| 381 | break; | ||
| 382 | default: | ||
| 383 | fprintf(stderr, "zran: error %d while building index\n", len); | ||
| 384 | } | ||
| 385 | return 1; | ||
| 386 | } | ||
| 387 | fprintf(stderr, "zran: built index with %d access points\n", len); | ||
| 388 | |||
| 389 | /* use index by reading some bytes from an arbitrary offset */ | ||
| 390 | offset = (index->list[index->have - 1].out << 1) / 3; | ||
| 391 | len = extract(in, index, offset, buf, CHUNK); | ||
| 392 | if (len < 0) | ||
| 393 | fprintf(stderr, "zran: extraction failed: %s error\n", | ||
| 394 | len == Z_MEM_ERROR ? "out of memory" : "input corrupted"); | ||
| 395 | else { | ||
| 396 | fwrite(buf, 1, len, stdout); | ||
| 397 | fprintf(stderr, "zran: extracted %d bytes at %llu\n", len, offset); | ||
| 398 | } | ||
| 399 | |||
| 400 | /* clean up and exit */ | ||
| 401 | free_index(index); | ||
| 402 | fclose(in); | ||
| 403 | return 0; | ||
| 404 | } | ||
| @@ -489,6 +489,9 @@ int ZEXPORT gzread (file, buf, len) | |||
| 489 | } | 489 | } |
| 490 | s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); | 490 | s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); |
| 491 | 491 | ||
| 492 | if (len == s->stream.avail_out && | ||
| 493 | (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO)) | ||
| 494 | return -1; | ||
| 492 | return (int)(len - s->stream.avail_out); | 495 | return (int)(len - s->stream.avail_out); |
| 493 | } | 496 | } |
| 494 | 497 | ||
| @@ -975,9 +978,9 @@ int ZEXPORT gzclose (file) | |||
| 975 | #endif | 978 | #endif |
| 976 | 979 | ||
| 977 | /* =========================================================================== | 980 | /* =========================================================================== |
| 978 | Returns the error message for the last error which occured on the | 981 | Returns the error message for the last error which occurred on the |
| 979 | given compressed file. errnum is set to zlib error number. If an | 982 | given compressed file. errnum is set to zlib error number. If an |
| 980 | error occured in the file system and not in the compression library, | 983 | error occurred in the file system and not in the compression library, |
| 981 | errnum is set to Z_ERRNO and the application may consult errno | 984 | errnum is set to Z_ERRNO and the application may consult errno |
| 982 | to get the exact error code. | 985 | to get the exact error code. |
| 983 | */ | 986 | */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* infback.c -- inflate using a call-back interface | 1 | /* infback.c -- inflate using a call-back interface |
| 2 | * Copyright (C) 1995-2004 Mark Adler | 2 | * Copyright (C) 1995-2005 Mark Adler |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| @@ -50,7 +50,7 @@ int stream_size; | |||
| 50 | sizeof(struct inflate_state)); | 50 | sizeof(struct inflate_state)); |
| 51 | if (state == Z_NULL) return Z_MEM_ERROR; | 51 | if (state == Z_NULL) return Z_MEM_ERROR; |
| 52 | Tracev((stderr, "inflate: allocated\n")); | 52 | Tracev((stderr, "inflate: allocated\n")); |
| 53 | strm->state = (voidpf)state; | 53 | strm->state = (struct internal_state FAR *)state; |
| 54 | state->dmax = 32768U; | 54 | state->dmax = 32768U; |
| 55 | state->wbits = windowBits; | 55 | state->wbits = windowBits; |
| 56 | state->wsize = 1U << windowBits; | 56 | state->wsize = 1U << windowBits; |
| @@ -117,6 +117,7 @@ z_streamp strm; | |||
| 117 | state->head = Z_NULL; | 117 | state->head = Z_NULL; |
| 118 | state->wsize = 0; | 118 | state->wsize = 0; |
| 119 | state->whave = 0; | 119 | state->whave = 0; |
| 120 | state->write = 0; | ||
| 120 | state->hold = 0; | 121 | state->hold = 0; |
| 121 | state->bits = 0; | 122 | state->bits = 0; |
| 122 | state->lencode = state->distcode = state->next = state->codes; | 123 | state->lencode = state->distcode = state->next = state->codes; |
| @@ -124,6 +125,22 @@ z_streamp strm; | |||
| 124 | return Z_OK; | 125 | return Z_OK; |
| 125 | } | 126 | } |
| 126 | 127 | ||
| 128 | int ZEXPORT inflatePrime(strm, bits, value) | ||
| 129 | z_streamp strm; | ||
| 130 | int bits; | ||
| 131 | int value; | ||
| 132 | { | ||
| 133 | struct inflate_state FAR *state; | ||
| 134 | |||
| 135 | if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; | ||
| 136 | state = (struct inflate_state FAR *)strm->state; | ||
| 137 | if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR; | ||
| 138 | value &= (1L << bits) - 1; | ||
| 139 | state->hold += value << state->bits; | ||
| 140 | state->bits += bits; | ||
| 141 | return Z_OK; | ||
| 142 | } | ||
| 143 | |||
| 127 | int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) | 144 | int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) |
| 128 | z_streamp strm; | 145 | z_streamp strm; |
| 129 | int windowBits; | 146 | int windowBits; |
| @@ -146,7 +163,7 @@ int stream_size; | |||
| 146 | ZALLOC(strm, 1, sizeof(struct inflate_state)); | 163 | ZALLOC(strm, 1, sizeof(struct inflate_state)); |
| 147 | if (state == Z_NULL) return Z_MEM_ERROR; | 164 | if (state == Z_NULL) return Z_MEM_ERROR; |
| 148 | Tracev((stderr, "inflate: allocated\n")); | 165 | Tracev((stderr, "inflate: allocated\n")); |
| 149 | strm->state = (voidpf)state; | 166 | strm->state = (struct internal_state FAR *)state; |
| 150 | if (windowBits < 0) { | 167 | if (windowBits < 0) { |
| 151 | state->wrap = 0; | 168 | state->wrap = 0; |
| 152 | windowBits = -windowBits; | 169 | windowBits = -windowBits; |
| @@ -1310,6 +1327,7 @@ z_streamp source; | |||
| 1310 | struct inflate_state FAR *state; | 1327 | struct inflate_state FAR *state; |
| 1311 | struct inflate_state FAR *copy; | 1328 | struct inflate_state FAR *copy; |
| 1312 | unsigned char FAR *window; | 1329 | unsigned char FAR *window; |
| 1330 | unsigned wsize; | ||
| 1313 | 1331 | ||
| 1314 | /* check input */ | 1332 | /* check input */ |
| 1315 | if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || | 1333 | if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || |
| @@ -1335,15 +1353,16 @@ z_streamp source; | |||
| 1335 | zmemcpy(dest, source, sizeof(z_stream)); | 1353 | zmemcpy(dest, source, sizeof(z_stream)); |
| 1336 | zmemcpy(copy, state, sizeof(struct inflate_state)); | 1354 | zmemcpy(copy, state, sizeof(struct inflate_state)); |
| 1337 | if (state->lencode >= state->codes && | 1355 | if (state->lencode >= state->codes && |
| 1338 | state->lencode <= state->codes + ENOUGH - 1) | 1356 | state->lencode <= state->codes + ENOUGH - 1) { |
| 1339 | { | ||
| 1340 | copy->lencode = copy->codes + (state->lencode - state->codes); | 1357 | copy->lencode = copy->codes + (state->lencode - state->codes); |
| 1341 | copy->distcode = copy->codes + (state->distcode - state->codes); | 1358 | copy->distcode = copy->codes + (state->distcode - state->codes); |
| 1342 | } | 1359 | } |
| 1343 | copy->next = copy->codes + (state->next - state->codes); | 1360 | copy->next = copy->codes + (state->next - state->codes); |
| 1344 | if (window != Z_NULL) | 1361 | if (window != Z_NULL) { |
| 1345 | zmemcpy(window, state->window, (uInt)(1U << state->wbits)); | 1362 | wsize = 1U << state->wbits; |
| 1363 | zmemcpy(window, state->window, wsize); | ||
| 1364 | } | ||
| 1346 | copy->window = window; | 1365 | copy->window = window; |
| 1347 | dest->state = (voidpf)copy; | 1366 | dest->state = (struct internal_state FAR *)copy; |
| 1348 | return Z_OK; | 1367 | return Z_OK; |
| 1349 | } | 1368 | } |
| @@ -9,7 +9,7 @@ | |||
| 9 | #define MAXBITS 15 | 9 | #define MAXBITS 15 |
| 10 | 10 | ||
| 11 | const char inflate_copyright[] = | 11 | const char inflate_copyright[] = |
| 12 | " inflate 1.2.2.3 Copyright 1995-2005 Mark Adler "; | 12 | " inflate 1.2.2.4 Copyright 1995-2005 Mark Adler "; |
| 13 | /* | 13 | /* |
| 14 | If you use the zlib library in a product, an acknowledgment is welcome | 14 | If you use the zlib library in a product, an acknowledgment is welcome |
| 15 | in the documentation of your product. If for some reason you cannot | 15 | in the documentation of your product. If for some reason you cannot |
| @@ -62,7 +62,7 @@ unsigned short FAR *work; | |||
| 62 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; | 62 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; |
| 63 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ | 63 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ |
| 64 | 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, | 64 | 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, |
| 65 | 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 66, 71}; | 65 | 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 206, 69}; |
| 66 | static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ | 66 | static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ |
| 67 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, | 67 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, |
| 68 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, | 68 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, |
| @@ -134,7 +134,7 @@ unsigned short FAR *work; | |||
| 134 | left -= count[len]; | 134 | left -= count[len]; |
| 135 | if (left < 0) return -1; /* over-subscribed */ | 135 | if (left < 0) return -1; /* over-subscribed */ |
| 136 | } | 136 | } |
| 137 | if (left > 0 && (type == CODES || (codes - count[0] != 1))) | 137 | if (left > 0 && (type == CODES || max != 1)) |
| 138 | return -1; /* incomplete set */ | 138 | return -1; /* incomplete set */ |
| 139 | 139 | ||
| 140 | /* generate offsets into symbol table for each length for sorting */ | 140 | /* generate offsets into symbol table for each length for sorting */ |
| @@ -232,6 +232,7 @@ unsigned short FAR *work; | |||
| 232 | /* replicate for those indices with low len bits equal to huff */ | 232 | /* replicate for those indices with low len bits equal to huff */ |
| 233 | incr = 1U << (len - drop); | 233 | incr = 1U << (len - drop); |
| 234 | fill = 1U << curr; | 234 | fill = 1U << curr; |
| 235 | min = fill; /* save offset to next table */ | ||
| 235 | do { | 236 | do { |
| 236 | fill -= incr; | 237 | fill -= incr; |
| 237 | next[(huff >> drop) + fill] = this; | 238 | next[(huff >> drop) + fill] = this; |
| @@ -262,7 +263,7 @@ unsigned short FAR *work; | |||
| 262 | drop = root; | 263 | drop = root; |
| 263 | 264 | ||
| 264 | /* increment past last table */ | 265 | /* increment past last table */ |
| 265 | next += (unsigned)(1U << curr); | 266 | next += min; /* here min is 1 << curr */ |
| 266 | 267 | ||
| 267 | /* determine length of next table */ | 268 | /* determine length of next table */ |
| 268 | curr = len - drop; | 269 | curr = len - drop; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* inftrees.h -- header to use inftrees.c | 1 | /* inftrees.h -- header to use inftrees.c |
| 2 | * Copyright (C) 1995-2003 Mark Adler | 2 | * Copyright (C) 1995-2005 Mark Adler |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| @@ -36,12 +36,12 @@ typedef struct { | |||
| 36 | */ | 36 | */ |
| 37 | 37 | ||
| 38 | /* Maximum size of dynamic tree. The maximum found in a long but non- | 38 | /* Maximum size of dynamic tree. The maximum found in a long but non- |
| 39 | exhaustive search was 1004 code structures (850 for length/literals | 39 | exhaustive search was 1444 code structures (852 for length/literals |
| 40 | and 154 for distances, the latter actually the result of an | 40 | and 592 for distances, the latter actually the result of an |
| 41 | exhaustive search). The true maximum is not known, but the value | 41 | exhaustive search). The true maximum is not known, but the value |
| 42 | below is more than safe. */ | 42 | below is more than safe. */ |
| 43 | #define ENOUGH 1440 | 43 | #define ENOUGH 2048 |
| 44 | #define MAXD 154 | 44 | #define MAXD 592 |
| 45 | 45 | ||
| 46 | /* Type of code to build for inftable() */ | 46 | /* Type of code to build for inftable() */ |
| 47 | typedef enum { | 47 | typedef enum { |
diff --git a/make_vms.com b/make_vms.com index e6587cd..c3e5b58 100644 --- a/make_vms.com +++ b/make_vms.com | |||
| @@ -1,30 +1,69 @@ | |||
| 1 | $! make libz under VMS | 1 | $! make libz under VMS written by |
| 2 | $! written by Martin P.J. Zinser <m.zinser@gsi.de> | 2 | $! Martin P.J. Zinser |
| 3 | $! <zinser@zinser.no-ip.info or zinser@sysdev.deutsche-boerse.com> | ||
| 4 | $! | ||
| 5 | $ on error then goto err_exit | ||
| 6 | $! | ||
| 7 | $! | ||
| 8 | $! Just some general constants... | ||
| 9 | $! | ||
| 10 | $ true = 1 | ||
| 11 | $ false = 0 | ||
| 12 | $ tmpnam = "temp_" + f$getjpi("","pid") | ||
| 13 | $ SAY = "WRITE SYS$OUTPUT" | ||
| 14 | $! | ||
| 15 | $! Setup variables holding "config" information | ||
| 16 | $! | ||
| 17 | $ Make = "" | ||
| 18 | $ name = "Zlib" | ||
| 19 | $ version = "?.?.?" | ||
| 20 | $ v_string = "ZLIB_VERSION" | ||
| 21 | $ v_file = "zlib.h" | ||
| 22 | $ ccopt = "" | ||
| 23 | $ lopts = "" | ||
| 24 | $ linkonly = false | ||
| 25 | $ optfile = name + ".opt" | ||
| 26 | $ its_decc = false | ||
| 27 | $ its_vaxc = false | ||
| 28 | $ its_gnuc = false | ||
| 29 | $ axp = f$getsyi("HW_MODEL").ge.1024 | ||
| 30 | $ s_case = false | ||
| 31 | $! Check for MMK/MMS | ||
| 32 | $! | ||
| 33 | $ If F$Search ("Sys$System:MMS.EXE") .nes. "" Then Make = "MMS" | ||
| 34 | $ If F$Type (MMK) .eqs. "STRING" Then Make = "MMK" | ||
| 35 | $! | ||
| 36 | $! | ||
| 37 | $ gosub find_version | ||
| 38 | $! | ||
| 39 | $ gosub check_opts | ||
| 3 | $! | 40 | $! |
| 4 | $! Look for the compiler used | 41 | $! Look for the compiler used |
| 5 | $! | 42 | $! |
| 6 | $ ccopt = "" | 43 | $ gosub check_compiler |
| 7 | $ if f$getsyi("HW_MODEL").ge.1024 | 44 | $ if its_decc |
| 8 | $ then | 45 | $ then |
| 9 | $ ccopt = "/prefix=all"+ccopt | 46 | $ ccopt = "/prefix=all" + ccopt |
| 10 | $ comp = "__decc__=1" | 47 | $ if f$trnlnm("SYS") .eqs. "" |
| 11 | $ if f$trnlnm("SYS").eqs."" then define sys sys$library: | ||
| 12 | $ else | ||
| 13 | $ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs."" | ||
| 14 | $ then | 48 | $ then |
| 15 | $ comp = "__vaxc__=1" | 49 | $ if axp |
| 16 | $ if f$trnlnm("SYS").eqs."" then define sys sys$library: | 50 | $ then |
| 17 | $ else | 51 | $ define sys sys$library: |
| 18 | $ if f$trnlnm("SYS").eqs."" then define sys decc$library_include: | 52 | $ else |
| 19 | $ ccopt = "/decc/prefix=all"+ccopt | 53 | $ ccopt = "/decc" + ccopt |
| 20 | $ comp = "__decc__=1" | 54 | $ define sys decc$library_include: |
| 21 | $ endif | 55 | $ endif |
| 56 | $ endif | ||
| 22 | $ endif | 57 | $ endif |
| 58 | $ if its_vaxc .or. its_gnuc | ||
| 59 | $ then | ||
| 60 | $ if f$trnlnm("SYS").eqs."" then define sys sys$library: | ||
| 61 | $ endif | ||
| 23 | $! | 62 | $! |
| 24 | $! Build the thing plain or with mms | 63 | $! Build the thing plain or with mms |
| 25 | $! | 64 | $! |
| 26 | $ write sys$output "Compiling Zlib sources ..." | 65 | $ write sys$output "Compiling Zlib sources ..." |
| 27 | $ if f$search("SYS$SYSTEM:MMS.EXE").eqs."" | 66 | $ if make.eqs."" |
| 28 | $ then | 67 | $ then |
| 29 | $ dele example.obj;*,minigzip.obj;* | 68 | $ dele example.obj;*,minigzip.obj;* |
| 30 | $ CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" - | 69 | $ CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" - |
| @@ -32,24 +71,21 @@ $ CALL MAKE adler32.OBJ "CC ''CCOPT' adler32" - | |||
| 32 | $ CALL MAKE compress.OBJ "CC ''CCOPT' compress" - | 71 | $ CALL MAKE compress.OBJ "CC ''CCOPT' compress" - |
| 33 | compress.c zlib.h zconf.h | 72 | compress.c zlib.h zconf.h |
| 34 | $ CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" - | 73 | $ CALL MAKE crc32.OBJ "CC ''CCOPT' crc32" - |
| 35 | crc32.c crc32.h zlib.h zconf.h zutil.h | 74 | crc32.c zlib.h zconf.h |
| 36 | $ CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" - | 75 | $ CALL MAKE deflate.OBJ "CC ''CCOPT' deflate" - |
| 37 | deflate.c deflate.h zutil.h zlib.h zconf.h | 76 | deflate.c deflate.h zutil.h zlib.h zconf.h |
| 38 | $ CALL MAKE gzio.OBJ "CC ''CCOPT' gzio /define=""NO_vsnprintf""" - | 77 | $ CALL MAKE gzio.OBJ "CC ''CCOPT' gzio" - |
| 39 | gzio.c zutil.h zlib.h zconf.h | 78 | gzio.c zutil.h zlib.h zconf.h |
| 40 | $ CALL MAKE infback.OBJ "CC ''CCOPT' infback" - | 79 | $ CALL MAKE infback.OBJ "CC ''CCOPT' infback" - |
| 41 | infback.c zutil.h zlib.h zconf.h - | 80 | infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h |
| 42 | "inftrees.h inflate.h inffast.h inffixed.h" | ||
| 43 | $ CALL MAKE inffast.OBJ "CC ''CCOPT' inffast" - | 81 | $ CALL MAKE inffast.OBJ "CC ''CCOPT' inffast" - |
| 44 | inffast.c zutil.h zlib.h zconf.h - | 82 | inffast.c zutil.h zlib.h zconf.h inffast.h |
| 45 | "inftrees.h inflate.h inffast.h" | ||
| 46 | $ CALL MAKE inflate.OBJ "CC ''CCOPT' inflate" - | 83 | $ CALL MAKE inflate.OBJ "CC ''CCOPT' inflate" - |
| 47 | inflate.c zutil.h zlib.h zconf.h - | 84 | inflate.c zutil.h zlib.h zconf.h infblock.h |
| 48 | "inftrees.h inflate.h inffast.h inffixed.h" | ||
| 49 | $ CALL MAKE inftrees.OBJ "CC ''CCOPT' inftrees" - | 85 | $ CALL MAKE inftrees.OBJ "CC ''CCOPT' inftrees" - |
| 50 | inftrees.c zutil.h zlib.h zconf.h inftrees.h | 86 | inftrees.c zutil.h zlib.h zconf.h inftrees.h |
| 51 | $ CALL MAKE trees.OBJ "CC ''CCOPT' trees" - | 87 | $ CALL MAKE trees.OBJ "CC ''CCOPT' trees" - |
| 52 | trees.c trees.h deflate.h zutil.h zlib.h zconf.h | 88 | trees.c deflate.h zutil.h zlib.h zconf.h |
| 53 | $ CALL MAKE uncompr.OBJ "CC ''CCOPT' uncompr" - | 89 | $ CALL MAKE uncompr.OBJ "CC ''CCOPT' uncompr" - |
| 54 | uncompr.c zlib.h zconf.h | 90 | uncompr.c zlib.h zconf.h |
| 55 | $ CALL MAKE zutil.OBJ "CC ''CCOPT' zutil" - | 91 | $ CALL MAKE zutil.OBJ "CC ''CCOPT' zutil" - |
| @@ -60,17 +96,45 @@ $ write sys$output "Building example..." | |||
| 60 | $ CALL MAKE example.OBJ "CC ''CCOPT' example" - | 96 | $ CALL MAKE example.OBJ "CC ''CCOPT' example" - |
| 61 | example.c zlib.h zconf.h | 97 | example.c zlib.h zconf.h |
| 62 | $ call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb | 98 | $ call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb |
| 63 | $ write sys$output "Building minigzip..." | 99 | $ if f$search("x11vms:xvmsutils.olb") .nes. "" |
| 64 | $ CALL MAKE minigzip.OBJ "CC ''CCOPT' minigzip" - | 100 | $ then |
| 101 | $ write sys$output "Building minigzip..." | ||
| 102 | $ CALL MAKE minigzip.OBJ "CC ''CCOPT' minigzip" - | ||
| 65 | minigzip.c zlib.h zconf.h | 103 | minigzip.c zlib.h zconf.h |
| 66 | $ call make minigzip.exe - | 104 | $ call make minigzip.exe - |
| 67 | "LINK minigzip,libz.olb/lib" - | 105 | "LINK minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib" - |
| 68 | minigzip.obj libz.olb | 106 | minigzip.obj libz.olb |
| 107 | $ endif | ||
| 69 | $ else | 108 | $ else |
| 70 | $ mms/macro=('comp') | 109 | $ gosub crea_mms |
| 110 | $ SAY "Make ''name' ''version' with ''Make' " | ||
| 111 | $ 'make' | ||
| 71 | $ endif | 112 | $ endif |
| 113 | $! | ||
| 114 | $! Alpha gets a shareable image | ||
| 115 | $! | ||
| 116 | $ If axp | ||
| 117 | $ Then | ||
| 118 | $ gosub crea_olist | ||
| 119 | $ write sys$output "Creating libzshr.exe" | ||
| 120 | $ call anal_obj_axp modules.opt _link.opt | ||
| 121 | $ if s_case | ||
| 122 | $ then | ||
| 123 | $ open/append optf modules.opt | ||
| 124 | $ write optf "case_sensitive=YES" | ||
| 125 | $ close optf | ||
| 126 | $ endif | ||
| 127 | $ LINK_'lopts'/SHARE=libzshr.exe modules.opt/opt,_link.opt/opt | ||
| 128 | $ endif | ||
| 72 | $ write sys$output "Zlib build completed" | 129 | $ write sys$output "Zlib build completed" |
| 73 | $ exit | 130 | $ exit |
| 131 | $CC_ERR: | ||
| 132 | $ write sys$output "C compiler required to build ''name'" | ||
| 133 | $ goto err_exit | ||
| 134 | $ERR_EXIT: | ||
| 135 | $ set message/facil/ident/sever/text | ||
| 136 | $ write sys$output "Exiting..." | ||
| 137 | $ exit 2 | ||
| 74 | $! | 138 | $! |
| 75 | $! | 139 | $! |
| 76 | $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES | 140 | $MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES |
| @@ -112,3 +176,286 @@ $ VV='F$Verify(VV) | |||
| 112 | $Exit: | 176 | $Exit: |
| 113 | $ If V Then Set Verify | 177 | $ If V Then Set Verify |
| 114 | $ENDSUBROUTINE | 178 | $ENDSUBROUTINE |
| 179 | $!------------------------------------------------------------------------------ | ||
| 180 | $! | ||
| 181 | $! Check command line options and set symbols accordingly | ||
| 182 | $! | ||
| 183 | $ CHECK_OPTS: | ||
| 184 | $ i = 1 | ||
| 185 | $ OPT_LOOP: | ||
| 186 | $ if i .lt. 9 | ||
| 187 | $ then | ||
| 188 | $ cparm = f$edit(p'i',"upcase") | ||
| 189 | $ if cparm .eqs. "DEBUG" | ||
| 190 | $ then | ||
| 191 | $ ccopt = ccopt + "/noopt/deb" | ||
| 192 | $ lopts = lopts + "/deb" | ||
| 193 | $ endif | ||
| 194 | $ if f$locate("CCOPT=",cparm) .lt. f$length(cparm) | ||
| 195 | $ then | ||
| 196 | $ start = f$locate("=",cparm) + 1 | ||
| 197 | $ len = f$length(cparm) - start | ||
| 198 | $ ccopt = ccopt + f$extract(start,len,cparm) | ||
| 199 | $ if f$locate("AS_IS",f$edit(ccopt,"UPCASE")) .lt. f$length(ccopt) - | ||
| 200 | then s_case = true | ||
| 201 | $ endif | ||
| 202 | $ if cparm .eqs. "LINK" then linkonly = true | ||
| 203 | $ if f$locate("LOPTS=",cparm) .lt. f$length(cparm) | ||
| 204 | $ then | ||
| 205 | $ start = f$locate("=",cparm) + 1 | ||
| 206 | $ len = f$length(cparm) - start | ||
| 207 | $ lopts = lopts + f$extract(start,len,cparm) | ||
| 208 | $ endif | ||
| 209 | $ if f$locate("CC=",cparm) .lt. f$length(cparm) | ||
| 210 | $ then | ||
| 211 | $ start = f$locate("=",cparm) + 1 | ||
| 212 | $ len = f$length(cparm) - start | ||
| 213 | $ cc_com = f$extract(start,len,cparm) | ||
| 214 | if (cc_com .nes. "DECC") .and. - | ||
| 215 | (cc_com .nes. "VAXC") .and. - | ||
| 216 | (cc_com .nes. "GNUC") | ||
| 217 | $ then | ||
| 218 | $ write sys$output "Unsupported compiler choice ''cc_com' ignored" | ||
| 219 | $ write sys$output "Use DECC, VAXC, or GNUC instead" | ||
| 220 | $ else | ||
| 221 | $ if cc_com .eqs. "DECC" then its_decc = true | ||
| 222 | $ if cc_com .eqs. "VAXC" then its_vaxc = true | ||
| 223 | $ if cc_com .eqs. "GNUC" then its_gnuc = true | ||
| 224 | $ endif | ||
| 225 | $ endif | ||
| 226 | $ if f$locate("MAKE=",cparm) .lt. f$length(cparm) | ||
| 227 | $ then | ||
| 228 | $ start = f$locate("=",cparm) + 1 | ||
| 229 | $ len = f$length(cparm) - start | ||
| 230 | $ mmks = f$extract(start,len,cparm) | ||
| 231 | $ if (mmks .eqs. "MMK") .or. (mmks .eqs. "MMS") | ||
| 232 | $ then | ||
| 233 | $ make = mmks | ||
| 234 | $ else | ||
| 235 | $ write sys$output "Unsupported make choice ''mmks' ignored" | ||
| 236 | $ write sys$output "Use MMK or MMS instead" | ||
| 237 | $ endif | ||
| 238 | $ endif | ||
| 239 | $ i = i + 1 | ||
| 240 | $ goto opt_loop | ||
| 241 | $ endif | ||
| 242 | $ return | ||
| 243 | $!------------------------------------------------------------------------------ | ||
| 244 | $! | ||
| 245 | $! Look for the compiler used | ||
| 246 | $! | ||
| 247 | $CHECK_COMPILER: | ||
| 248 | $ if (.not. (its_decc .or. its_vaxc .or. its_gnuc)) | ||
| 249 | $ then | ||
| 250 | $ its_decc = (f$search("SYS$SYSTEM:DECC$COMPILER.EXE") .nes. "") | ||
| 251 | $ its_vaxc = .not. its_decc .and. (F$Search("SYS$System:VAXC.Exe") .nes. "") | ||
| 252 | $ its_gnuc = .not. (its_decc .or. its_vaxc) .and. (f$trnlnm("gnu_cc") .nes. "") | ||
| 253 | $ endif | ||
| 254 | $! | ||
| 255 | $! Exit if no compiler available | ||
| 256 | $! | ||
| 257 | $ if (.not. (its_decc .or. its_vaxc .or. its_gnuc)) | ||
| 258 | $ then goto CC_ERR | ||
| 259 | $ else | ||
| 260 | $ if its_decc then write sys$output "CC compiler check ... Compaq C" | ||
| 261 | $ if its_vaxc then write sys$output "CC compiler check ... VAX C" | ||
| 262 | $ if its_gnuc then write sys$output "CC compiler check ... GNU C" | ||
| 263 | $ endif | ||
| 264 | $ return | ||
| 265 | $!------------------------------------------------------------------------------ | ||
| 266 | $! | ||
| 267 | $! If MMS/MMK are available dump out the descrip.mms if required | ||
| 268 | $! | ||
| 269 | $CREA_MMS: | ||
| 270 | $ write sys$output "Creating descrip.mms..." | ||
| 271 | $ create descrip.mms | ||
| 272 | $ open/append out descrip.mms | ||
| 273 | $ copy sys$input: out | ||
| 274 | $ deck | ||
| 275 | # descrip.mms: MMS description file for building zlib on VMS | ||
| 276 | # written by Martin P.J. Zinser | ||
| 277 | # <zinser@zinser.no-ip.info or zinser@sysdev.deutsche-boerse.com> | ||
| 278 | |||
| 279 | OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj, infback.obj\ | ||
| 280 | deflate.obj, trees.obj, zutil.obj, inflate.obj, \ | ||
| 281 | inftrees.obj, inffast.obj | ||
| 282 | |||
| 283 | $ eod | ||
| 284 | $ write out "CFLAGS=", ccopt | ||
| 285 | $ write out "LOPTS=", lopts | ||
| 286 | $ copy sys$input: out | ||
| 287 | $ deck | ||
| 288 | |||
| 289 | all : example.exe minigzip.exe libz.olb | ||
| 290 | @ write sys$output " Example applications available" | ||
| 291 | |||
| 292 | libz.olb : libz.olb($(OBJS)) | ||
| 293 | @ write sys$output " libz available" | ||
| 294 | |||
| 295 | example.exe : example.obj libz.olb | ||
| 296 | link $(LOPTS) example,libz.olb/lib | ||
| 297 | |||
| 298 | minigzip.exe : minigzip.obj libz.olb | ||
| 299 | link $(LOPTS) minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib | ||
| 300 | |||
| 301 | clean : | ||
| 302 | delete *.obj;*,libz.olb;*,*.opt;*,*.exe;* | ||
| 303 | |||
| 304 | |||
| 305 | # Other dependencies. | ||
| 306 | adler32.obj : adler32.c zutil.h zlib.h zconf.h | ||
| 307 | compress.obj : compress.c zlib.h zconf.h | ||
| 308 | crc32.obj : crc32.c zutil.h zlib.h zconf.h | ||
| 309 | deflate.obj : deflate.c deflate.h zutil.h zlib.h zconf.h | ||
| 310 | example.obj : example.c zlib.h zconf.h | ||
| 311 | gzio.obj : gzio.c zutil.h zlib.h zconf.h | ||
| 312 | inffast.obj : inffast.c zutil.h zlib.h zconf.h inftrees.h inffast.h | ||
| 313 | inflate.obj : inflate.c zutil.h zlib.h zconf.h | ||
| 314 | inftrees.obj : inftrees.c zutil.h zlib.h zconf.h inftrees.h | ||
| 315 | minigzip.obj : minigzip.c zlib.h zconf.h | ||
| 316 | trees.obj : trees.c deflate.h zutil.h zlib.h zconf.h | ||
| 317 | uncompr.obj : uncompr.c zlib.h zconf.h | ||
| 318 | zutil.obj : zutil.c zutil.h zlib.h zconf.h | ||
| 319 | infback.obj : infback.c zutil.h inftrees.h inflate.h inffast.h inffixed.h | ||
| 320 | $ eod | ||
| 321 | $ close out | ||
| 322 | $ return | ||
| 323 | $!------------------------------------------------------------------------------ | ||
| 324 | $! | ||
| 325 | $! Read list of core library sources from makefile.in and create options | ||
| 326 | $! needed to build shareable image | ||
| 327 | $! | ||
| 328 | $CREA_OLIST: | ||
| 329 | $ open/read min makefile.in | ||
| 330 | $ open/write mod modules.opt | ||
| 331 | $ src_check = "OBJS =" | ||
| 332 | $MRLOOP: | ||
| 333 | $ read/end=mrdone min rec | ||
| 334 | $ if (f$extract(0,6,rec) .nes. src_check) then goto mrloop | ||
| 335 | $ rec = rec - src_check | ||
| 336 | $ gosub extra_filnam | ||
| 337 | $ if (f$element(1,"\",rec) .eqs. "\") then goto mrdone | ||
| 338 | $MRSLOOP: | ||
| 339 | $ read/end=mrdone min rec | ||
| 340 | $ gosub extra_filnam | ||
| 341 | $ if (f$element(1,"\",rec) .nes. "\") then goto mrsloop | ||
| 342 | $MRDONE: | ||
| 343 | $ close min | ||
| 344 | $ close mod | ||
| 345 | $ return | ||
| 346 | $!------------------------------------------------------------------------------ | ||
| 347 | $! | ||
| 348 | $! Take record extracted in crea_olist and split it into single filenames | ||
| 349 | $! | ||
| 350 | $EXTRA_FILNAM: | ||
| 351 | $ myrec = f$edit(rec - "\", "trim,compress") | ||
| 352 | $ i = 0 | ||
| 353 | $FELOOP: | ||
| 354 | $ srcfil = f$element(i," ", myrec) | ||
| 355 | $ if (srcfil .nes. " ") | ||
| 356 | $ then | ||
| 357 | $ write mod f$parse(srcfil,,,"NAME"), ".obj" | ||
| 358 | $ i = i + 1 | ||
| 359 | $ goto feloop | ||
| 360 | $ endif | ||
| 361 | $ return | ||
| 362 | $!------------------------------------------------------------------------------ | ||
| 363 | $! | ||
| 364 | $! Find current Zlib version number | ||
| 365 | $! | ||
| 366 | $FIND_VERSION: | ||
| 367 | $ open/read h_in 'v_file' | ||
| 368 | $hloop: | ||
| 369 | $ read/end=hdone h_in rec | ||
| 370 | $ rec = f$edit(rec,"TRIM") | ||
| 371 | $ if (f$extract(0,1,rec) .nes. "#") then goto hloop | ||
| 372 | $ rec = f$edit(rec - "#", "TRIM") | ||
| 373 | $ if f$element(0," ",rec) .nes. "define" then goto hloop | ||
| 374 | $ if f$element(1," ",rec) .eqs. v_string | ||
| 375 | $ then | ||
| 376 | $ version = 'f$element(2," ",rec)' | ||
| 377 | $ goto hdone | ||
| 378 | $ endif | ||
| 379 | $ goto hloop | ||
| 380 | $hdone: | ||
| 381 | $ close h_in | ||
| 382 | $ return | ||
| 383 | $!------------------------------------------------------------------------------ | ||
| 384 | $! | ||
| 385 | $! Analyze Object files for OpenVMS AXP to extract Procedure and Data | ||
| 386 | $! information to build a symbol vector for a shareable image | ||
| 387 | $! All the "brains" of this logic was suggested by Hartmut Becker | ||
| 388 | $! (Hartmut.Becker@compaq.com). All the bugs were introduced by me | ||
| 389 | $! (zinser@decus.de), so if you do have problem reports please do not | ||
| 390 | $! bother Hartmut/HP, but get in touch with me | ||
| 391 | $! | ||
| 392 | $ ANAL_OBJ_AXP: Subroutine | ||
| 393 | $ V = 'F$Verify(0) | ||
| 394 | $ SAY := "WRITE_ SYS$OUTPUT" | ||
| 395 | $ | ||
| 396 | $ IF F$SEARCH("''P1'") .EQS. "" | ||
| 397 | $ THEN | ||
| 398 | $ SAY "ANAL_OBJ_AXP-E-NOSUCHFILE: Error, inputfile ''p1' not available" | ||
| 399 | $ goto exit_aa | ||
| 400 | $ ENDIF | ||
| 401 | $ IF "''P2'" .EQS. "" | ||
| 402 | $ THEN | ||
| 403 | $ SAY "ANAL_OBJ_AXP: Error, no output file provided" | ||
| 404 | $ goto exit_aa | ||
| 405 | $ ENDIF | ||
| 406 | $ | ||
| 407 | $ open/read in 'p1 | ||
| 408 | $ create a.tmp | ||
| 409 | $ open/append atmp a.tmp | ||
| 410 | $ loop: | ||
| 411 | $ read/end=end_loop in line | ||
| 412 | $ f= f$search(line) | ||
| 413 | $ if f .eqs. "" | ||
| 414 | $ then | ||
| 415 | $ write sys$output "ANAL_OBJ_AXP-w-nosuchfile, ''line'" | ||
| 416 | $ goto loop | ||
| 417 | $ endif | ||
| 418 | $ define/user sys$output nl: | ||
| 419 | $ define/user sys$error nl: | ||
| 420 | $ anal/obj/gsd 'f /out=x.tmp | ||
| 421 | $ open/read xtmp x.tmp | ||
| 422 | $ XLOOP: | ||
| 423 | $ read/end=end_xloop xtmp xline | ||
| 424 | $ xline = f$edit(xline,"compress") | ||
| 425 | $ write atmp xline | ||
| 426 | $ goto xloop | ||
| 427 | $ END_XLOOP: | ||
| 428 | $ close xtmp | ||
| 429 | $ goto loop | ||
| 430 | $ end_loop: | ||
| 431 | $ close in | ||
| 432 | $ close atmp | ||
| 433 | $ if f$search("a.tmp") .eqs. "" - | ||
| 434 | then $ exit | ||
| 435 | $ ! all global definitions | ||
| 436 | $ search a.tmp "symbol:","EGSY$V_DEF 1","EGSY$V_NORM 1"/out=b.tmp | ||
| 437 | $ ! all procedures | ||
| 438 | $ search b.tmp "EGSY$V_NORM 1"/wind=(0,1) /out=c.tmp | ||
| 439 | $ search c.tmp "symbol:"/out=d.tmp | ||
| 440 | $ define/user sys$output nl: | ||
| 441 | $ edito/edt/command=sys$input d.tmp | ||
| 442 | sub/symbol: "/symbol_vector=(/whole | ||
| 443 | sub/"/=PROCEDURE)/whole | ||
| 444 | exit | ||
| 445 | $ ! all data | ||
| 446 | $ search b.tmp "EGSY$V_DEF 1"/wind=(0,1) /out=e.tmp | ||
| 447 | $ search e.tmp "symbol:"/out=f.tmp | ||
| 448 | $ define/user sys$output nl: | ||
| 449 | $ edito/edt/command=sys$input f.tmp | ||
| 450 | sub/symbol: "/symbol_vector=(/whole | ||
| 451 | sub/"/=DATA)/whole | ||
| 452 | exit | ||
| 453 | $ sort/nodupl d.tmp,f.tmp 'p2' | ||
| 454 | $ delete a.tmp;*,b.tmp;*,c.tmp;*,d.tmp;*,e.tmp;*,f.tmp;* | ||
| 455 | $ if f$search("x.tmp") .nes. "" - | ||
| 456 | then $ delete x.tmp;* | ||
| 457 | $! | ||
| 458 | $ EXIT_AA: | ||
| 459 | $ if V then set verify | ||
| 460 | $ endsubroutine | ||
| 461 | $!------------------------------------------------------------------------------ | ||
diff --git a/qnx/package.qpg b/qnx/package.qpg index b08778d..f728ebe 100644 --- a/qnx/package.qpg +++ b/qnx/package.qpg | |||
| @@ -25,10 +25,10 @@ | |||
| 25 | <QPG:Files> | 25 | <QPG:Files> |
| 26 | <QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/> | 26 | <QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/> |
| 27 | <QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/> | 27 | <QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/> |
| 28 | <QPG:Add file="../libz.so.1.2.2.3" install="/opt/lib/" user="root:bin" permission="644"/> | 28 | <QPG:Add file="../libz.so.1.2.2.4" install="/opt/lib/" user="root:bin" permission="644"/> |
| 29 | <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.2.3"/> | 29 | <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.2.4"/> |
| 30 | <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.2.3"/> | 30 | <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.2.4"/> |
| 31 | <QPG:Add file="../libz.so.1.2.2.3" install="/opt/lib/" component="slib"/> | 31 | <QPG:Add file="../libz.so.1.2.2.4" install="/opt/lib/" component="slib"/> |
| 32 | </QPG:Files> | 32 | </QPG:Files> |
| 33 | 33 | ||
| 34 | <QPG:PackageFilter> | 34 | <QPG:PackageFilter> |
| @@ -63,7 +63,7 @@ | |||
| 63 | </QPM:ProductDescription> | 63 | </QPM:ProductDescription> |
| 64 | 64 | ||
| 65 | <QPM:ReleaseDescription> | 65 | <QPM:ReleaseDescription> |
| 66 | <QPM:ReleaseVersion>1.2.2.3</QPM:ReleaseVersion> | 66 | <QPM:ReleaseVersion>1.2.2.4</QPM:ReleaseVersion> |
| 67 | <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency> | 67 | <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency> |
| 68 | <QPM:ReleaseStability>Stable</QPM:ReleaseStability> | 68 | <QPM:ReleaseStability>Stable</QPM:ReleaseStability> |
| 69 | <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor> | 69 | <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor> |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* trees.c -- output deflated data using Huffman coding | 1 | /* trees.c -- output deflated data using Huffman coding |
| 2 | * Copyright (C) 1995-2004 Jean-loup Gailly | 2 | * Copyright (C) 1995-2005 Jean-loup Gailly |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| @@ -555,7 +555,7 @@ local void gen_bitlen(s, desc) | |||
| 555 | while (n != 0) { | 555 | while (n != 0) { |
| 556 | m = s->heap[--h]; | 556 | m = s->heap[--h]; |
| 557 | if (m > max_code) continue; | 557 | if (m > max_code) continue; |
| 558 | if (tree[m].Len != (unsigned) bits) { | 558 | if ((unsigned) tree[m].Len != (unsigned) bits) { |
| 559 | Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); | 559 | Trace((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); |
| 560 | s->opt_len += ((long)bits - (long)tree[m].Len) | 560 | s->opt_len += ((long)bits - (long)tree[m].Len) |
| 561 | *(long)tree[m].Freq; | 561 | *(long)tree[m].Freq; |
diff --git a/win32/zlib1.rc b/win32/zlib1.rc index e49a81c..8cff589 100644 --- a/win32/zlib1.rc +++ b/win32/zlib1.rc | |||
| @@ -5,8 +5,8 @@ VS_VERSION_INFO VERSIONINFO | |||
| 5 | #else | 5 | #else |
| 6 | VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE | 6 | VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 7 | #endif | 7 | #endif |
| 8 | FILEVERSION 1,2,2,3 | 8 | FILEVERSION 1,2,2,4 |
| 9 | PRODUCTVERSION 1,2,2,3 | 9 | PRODUCTVERSION 1,2,2,4 |
| 10 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK | 10 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 11 | #ifdef _DEBUG | 11 | #ifdef _DEBUG |
| 12 | FILEFLAGS 1 | 12 | FILEFLAGS 1 |
| @@ -23,12 +23,12 @@ BEGIN | |||
| 23 | //language ID = U.S. English, char set = Windows, Multilingual | 23 | //language ID = U.S. English, char set = Windows, Multilingual |
| 24 | BEGIN | 24 | BEGIN |
| 25 | VALUE "FileDescription", "zlib data compression library\0" | 25 | VALUE "FileDescription", "zlib data compression library\0" |
| 26 | VALUE "FileVersion", "1.2.2.3\0" | 26 | VALUE "FileVersion", "1.2.2.4\0" |
| 27 | VALUE "InternalName", "zlib1.dll\0" | 27 | VALUE "InternalName", "zlib1.dll\0" |
| 28 | VALUE "LegalCopyright", "(C) 1995-2004 Jean-loup Gailly & Mark Adler\0" | 28 | VALUE "LegalCopyright", "(C) 1995-2004 Jean-loup Gailly & Mark Adler\0" |
| 29 | VALUE "OriginalFilename", "zlib1.dll\0" | 29 | VALUE "OriginalFilename", "zlib1.dll\0" |
| 30 | VALUE "ProductName", "zlib\0" | 30 | VALUE "ProductName", "zlib\0" |
| 31 | VALUE "ProductVersion", "1.2.2.3\0" | 31 | VALUE "ProductVersion", "1.2.2.4\0" |
| 32 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" | 32 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 33 | END | 33 | END |
| 34 | END | 34 | END |
| @@ -1,4 +1,4 @@ | |||
| 1 | .TH ZLIB 3 "27 May 2005" | 1 | .TH ZLIB 3 "11 July 2005" |
| 2 | .SH NAME | 2 | .SH NAME |
| 3 | zlib \- compression/decompression library | 3 | zlib \- compression/decompression library |
| 4 | .SH SYNOPSIS | 4 | .SH SYNOPSIS |
| @@ -133,8 +133,8 @@ before asking for help. | |||
| 133 | Send questions and/or comments to zlib@gzip.org, | 133 | Send questions and/or comments to zlib@gzip.org, |
| 134 | or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). | 134 | or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). |
| 135 | .SH AUTHORS | 135 | .SH AUTHORS |
| 136 | Version 1.2.2.3 | 136 | Version 1.2.2.4 |
| 137 | Copyright (C) 1995-2004 Jean-loup Gailly (jloup@gzip.org) | 137 | Copyright (C) 1995-2005 Jean-loup Gailly (jloup@gzip.org) |
| 138 | and Mark Adler (madler@alumni.caltech.edu). | 138 | and Mark Adler (madler@alumni.caltech.edu). |
| 139 | .LP | 139 | .LP |
| 140 | This software is provided "as-is," | 140 | This software is provided "as-is," |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* zlib.h -- interface of the 'zlib' general purpose compression library | 1 | /* zlib.h -- interface of the 'zlib' general purpose compression library |
| 2 | version 1.2.2.3, May 27th, 2005 | 2 | version 1.2.2.4, July 11th, 2005 |
| 3 | 3 | ||
| 4 | Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler | 4 | Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler |
| 5 | 5 | ||
| @@ -37,8 +37,8 @@ | |||
| 37 | extern "C" { | 37 | extern "C" { |
| 38 | #endif | 38 | #endif |
| 39 | 39 | ||
| 40 | #define ZLIB_VERSION "1.2.2.3" | 40 | #define ZLIB_VERSION "1.2.2.4" |
| 41 | #define ZLIB_VERNUM 0x1223 | 41 | #define ZLIB_VERNUM 0x1224 |
| 42 | 42 | ||
| 43 | /* | 43 | /* |
| 44 | The 'zlib' compression library provides in-memory compression and | 44 | The 'zlib' compression library provides in-memory compression and |
| @@ -726,11 +726,11 @@ ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, | |||
| 726 | a crc32 instead of an adler32. | 726 | a crc32 instead of an adler32. |
| 727 | 727 | ||
| 728 | inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough | 728 | inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 729 | memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative | 729 | memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg |
| 730 | memLevel). msg is set to null if there is no error message. inflateInit2 | 730 | is set to null if there is no error message. inflateInit2 does not perform |
| 731 | does not perform any decompression apart from reading the zlib header if | 731 | any decompression apart from reading the zlib header if present: this will |
| 732 | present: this will be done by inflate(). (So next_in and avail_in may be | 732 | be done by inflate(). (So next_in and avail_in may be modified, but next_out |
| 733 | modified, but next_out and avail_out are unchanged.) | 733 | and avail_out are unchanged.) |
| 734 | */ | 734 | */ |
| 735 | 735 | ||
| 736 | ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, | 736 | ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, |
| @@ -796,6 +796,22 @@ ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); | |||
| 796 | stream state was inconsistent (such as zalloc or state being NULL). | 796 | stream state was inconsistent (such as zalloc or state being NULL). |
| 797 | */ | 797 | */ |
| 798 | 798 | ||
| 799 | ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, | ||
| 800 | int bits, | ||
| 801 | int value)); | ||
| 802 | /* | ||
| 803 | This function inserts bits in the inflate input stream. The intent is | ||
| 804 | that this function is used to start inflating at a bit position in the | ||
| 805 | middle of a byte. The provided bits will be used before any bytes are used | ||
| 806 | from next_in. This function should only be used with raw inflate, and | ||
| 807 | should be used before the first inflate() call after inflateInit2() or | ||
| 808 | inflateReset(). bits must be less than or equal to 16, and that many of the | ||
| 809 | least significant bits of value will be inserted in the input. | ||
| 810 | |||
| 811 | inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source | ||
| 812 | stream state was inconsistent. | ||
| 813 | */ | ||
| 814 | |||
| 799 | ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, | 815 | ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, |
| 800 | gz_headerp head)); | 816 | gz_headerp head)); |
| 801 | /* | 817 | /* |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* zutil.c -- target dependent utility functions for the compression library | 1 | /* zutil.c -- target dependent utility functions for the compression library |
| 2 | * Copyright (C) 1995-2004 Jean-loup Gailly. | 2 | * Copyright (C) 1995-2005 Jean-loup Gailly. |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| @@ -74,38 +74,38 @@ uLong ZEXPORT zlibCompileFlags() | |||
| 74 | flags += 1 << 13; | 74 | flags += 1 << 13; |
| 75 | #endif | 75 | #endif |
| 76 | #ifdef NO_GZCOMPRESS | 76 | #ifdef NO_GZCOMPRESS |
| 77 | flags += 1 << 16; | 77 | flags += 1L << 16; |
| 78 | #endif | 78 | #endif |
| 79 | #ifdef NO_GZIP | 79 | #ifdef NO_GZIP |
| 80 | flags += 1 << 17; | 80 | flags += 1L << 17; |
| 81 | #endif | 81 | #endif |
| 82 | #ifdef PKZIP_BUG_WORKAROUND | 82 | #ifdef PKZIP_BUG_WORKAROUND |
| 83 | flags += 1 << 20; | 83 | flags += 1L << 20; |
| 84 | #endif | 84 | #endif |
| 85 | #ifdef FASTEST | 85 | #ifdef FASTEST |
| 86 | flags += 1 << 21; | 86 | flags += 1L << 21; |
| 87 | #endif | 87 | #endif |
| 88 | #ifdef STDC | 88 | #ifdef STDC |
| 89 | # ifdef NO_vsnprintf | 89 | # ifdef NO_vsnprintf |
| 90 | flags += 1 << 25; | 90 | flags += 1L << 25; |
| 91 | # ifdef HAS_vsprintf_void | 91 | # ifdef HAS_vsprintf_void |
| 92 | flags += 1 << 26; | 92 | flags += 1L << 26; |
| 93 | # endif | 93 | # endif |
| 94 | # else | 94 | # else |
| 95 | # ifdef HAS_vsnprintf_void | 95 | # ifdef HAS_vsnprintf_void |
| 96 | flags += 1 << 26; | 96 | flags += 1L << 26; |
| 97 | # endif | 97 | # endif |
| 98 | # endif | 98 | # endif |
| 99 | #else | 99 | #else |
| 100 | flags += 1 << 24; | 100 | flags += 1L << 24; |
| 101 | # ifdef NO_snprintf | 101 | # ifdef NO_snprintf |
| 102 | flags += 1 << 25; | 102 | flags += 1L << 25; |
| 103 | # ifdef HAS_sprintf_void | 103 | # ifdef HAS_sprintf_void |
| 104 | flags += 1 << 26; | 104 | flags += 1L << 26; |
| 105 | # endif | 105 | # endif |
| 106 | # else | 106 | # else |
| 107 | # ifdef HAS_snprintf_void | 107 | # ifdef HAS_snprintf_void |
| 108 | flags += 1 << 26; | 108 | flags += 1L << 26; |
| 109 | # endif | 109 | # endif |
| 110 | # endif | 110 | # endif |
| 111 | #endif | 111 | #endif |
| @@ -117,6 +117,9 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
| 117 | 117 | ||
| 118 | #ifdef OS2 | 118 | #ifdef OS2 |
| 119 | # define OS_CODE 0x06 | 119 | # define OS_CODE 0x06 |
| 120 | # ifdef M_I86 | ||
| 121 | #include <malloc.h> | ||
| 122 | # endif | ||
| 120 | #endif | 123 | #endif |
| 121 | 124 | ||
| 122 | #if defined(MACOS) || defined(TARGET_OS_MAC) | 125 | #if defined(MACOS) || defined(TARGET_OS_MAC) |
