├── .github └── workflows │ ├── cmake.yml │ └── make.yml ├── .gitignore ├── CMakeLists.txt ├── ChangeLog ├── FAQ ├── INDEX ├── Makefile.in ├── README ├── adler32.c ├── adler32_simd.c ├── adler32_simd.h ├── amiga ├── Makefile.pup └── Makefile.sas ├── as400 ├── bndsrc ├── compile.clp ├── readme.txt └── zlib.inc ├── chunkcopy.h ├── compress.c ├── configure ├── crc32.c ├── crc32.h ├── crc32_simd.c ├── crc32_simd.h ├── deflate.c ├── deflate.h ├── doc ├── algorithm.txt ├── rfc1950.txt ├── rfc1951.txt ├── rfc1952.txt └── txtvsbin.txt ├── examples ├── README.examples ├── enough.c ├── fitblk.c ├── gun.c ├── gzappend.c ├── gzjoin.c ├── gzlog.c ├── gzlog.h ├── zlib_how.html ├── zpipe.c └── zran.c ├── gzclose.c ├── gzguts.h ├── gzlib.c ├── gzread.c ├── gzwrite.c ├── infback.c ├── inffast.c ├── inffast.h ├── inffast_chunk.c ├── inffast_chunk.h ├── inffixed.h ├── inflate.c ├── inflate.h ├── inftrees.c ├── inftrees.h ├── make_vms.com ├── msdos ├── Makefile.bor ├── Makefile.dj2 ├── Makefile.emx ├── Makefile.msc └── Makefile.tc ├── nintendods ├── Makefile └── README ├── old ├── Makefile.emx ├── Makefile.riscos ├── README ├── descrip.mms ├── os2 │ ├── Makefile.os2 │ └── zlib.def └── visual-basic.txt ├── qnx └── package.qpg ├── test ├── example.c ├── infcover.c └── minigzip.c ├── treebuild.xml ├── trees.c ├── trees.h ├── ucm.cmake ├── uncompr.c ├── watcom ├── watcom_f.mak └── watcom_l.mak ├── win32 ├── DLL_FAQ.txt ├── Makefile.bor ├── Makefile.gcc ├── Makefile.msc ├── README-WIN32.txt ├── VisualC.txt ├── zlib.def └── zlib1.rc ├── zconf.h ├── zconf.h.cmakein ├── zconf.h.in ├── zlib.3 ├── zlib.3.pdf ├── zlib.h ├── zlib.map ├── zlib.pc.cmakein ├── zlib.pc.in ├── zlib2ansi ├── zutil.c └── zutil.h /.github/workflows/cmake.yml: -------------------------------------------------------------------------------- 1 | name: CMake 2 | 3 | on: [push] 4 | 5 | env: 6 | # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) 7 | BUILD_TYPE: Release 8 | 9 | jobs: 10 | build: 11 | # The CMake configure and build commands are platform agnostic and should work equally 12 | # well on Windows or Mac. You can convert this to a matrix build if you need 13 | # cross-platform coverage. 14 | # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix 15 | runs-on: ${{ matrix.os }} 16 | strategy: 17 | matrix: 18 | os: [ubuntu-latest, windows-latest, macos-latest] 19 | steps: 20 | - uses: actions/checkout@v2 21 | 22 | - name: Create Build Environment 23 | # Some projects don't allow in-source building, so create a separate build directory 24 | # We'll use this as our working directory for all subsequent commands 25 | run: cmake -E make_directory ${{runner.workspace}}/build 26 | 27 | - name: Configure CMake 28 | # Use a bash shell so we can use the same syntax for environment variable 29 | # access regardless of the host operating system 30 | shell: bash 31 | working-directory: ${{runner.workspace}}/build 32 | # Note the current convention is to use the -S and -B options here to specify source 33 | # and build directories, but this is only available with CMake 3.13 and higher. 34 | # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 35 | run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_EXAMPLES=on -DBUILD_SHARED_LIBS=on 36 | 37 | - name: Build 38 | working-directory: ${{runner.workspace}}/build 39 | shell: bash 40 | # Execute the build. You can specify a specific target with "--target " 41 | run: cmake --build . --config $BUILD_TYPE 42 | 43 | - name: Test 44 | working-directory: ${{runner.workspace}}/build 45 | shell: bash 46 | # Execute tests defined by the CMake configuration. 47 | # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail 48 | run: ctest -C $BUILD_TYPE 49 | -------------------------------------------------------------------------------- /.github/workflows/make.yml: -------------------------------------------------------------------------------- 1 | name: Makefile CI 2 | 3 | on: 4 | push: 5 | branches: [ gcc.amd64 ] 6 | pull_request: 7 | branches: [ gcc.amd64 ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ${{ matrix.os }} 13 | strategy: 14 | matrix: 15 | os: [ubuntu-latest, macos-latest] 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: configure 20 | run: ./configure 21 | - name: make 22 | run: make 23 | - name: make check 24 | run: make check 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.diff 2 | *.patch 3 | *.orig 4 | *.rej 5 | 6 | *~ 7 | *.a 8 | *.lo 9 | *.o 10 | *.dylib 11 | 12 | *.gcda 13 | *.gcno 14 | *.gcov 15 | 16 | /example 17 | /example64 18 | /examplesh 19 | /libz.so* 20 | /minigzip 21 | /minigzip64 22 | /minigzipsh 23 | /zlib.pc 24 | /zconf.h.included 25 | 26 | .DS_Store 27 | 28 | /build 29 | /Makefile 30 | /configure.log 31 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dougallj/zlib-dougallj/35ab598c216c4a985c108d7b425bc8e24d87419b/ChangeLog -------------------------------------------------------------------------------- /INDEX: -------------------------------------------------------------------------------- 1 | CMakeLists.txt cmake build file 2 | ChangeLog history of changes 3 | FAQ Frequently Asked Questions about zlib 4 | INDEX this file 5 | Makefile dummy Makefile that tells you to ./configure 6 | Makefile.in template for Unix Makefile 7 | README guess what 8 | configure configure script for Unix 9 | make_vms.com makefile for VMS 10 | test/example.c zlib usages examples for build testing 11 | test/minigzip.c minimal gzip-like functionality for build testing 12 | test/infcover.c inf*.c code coverage for build coverage testing 13 | treebuild.xml XML description of source file dependencies 14 | zconf.h.cmakein zconf.h template for cmake 15 | zconf.h.in zconf.h template for configure 16 | zlib.3 Man page for zlib 17 | zlib.3.pdf Man page in PDF format 18 | zlib.map Linux symbol information 19 | zlib.pc.in Template for pkg-config descriptor 20 | zlib.pc.cmakein zlib.pc template for cmake 21 | zlib2ansi perl script to convert source files for C++ compilation 22 | 23 | amiga/ makefiles for Amiga SAS C 24 | as400/ makefiles for AS/400 25 | doc/ documentation for formats and algorithms 26 | msdos/ makefiles for MSDOS 27 | nintendods/ makefile for Nintendo DS 28 | old/ makefiles for various architectures and zlib documentation 29 | files that have not yet been updated for zlib 1.2.x 30 | qnx/ makefiles for QNX 31 | watcom/ makefiles for OpenWatcom 32 | win32/ makefiles for Windows 33 | 34 | zlib public header files (required for library use): 35 | zconf.h 36 | zlib.h 37 | 38 | private source files used to build the zlib library: 39 | adler32.c 40 | compress.c 41 | crc32.c 42 | crc32.h 43 | deflate.c 44 | deflate.h 45 | gzclose.c 46 | gzguts.h 47 | gzlib.c 48 | gzread.c 49 | gzwrite.c 50 | infback.c 51 | inffast.c 52 | inffast.h 53 | inffixed.h 54 | inflate.c 55 | inflate.h 56 | inftrees.c 57 | inftrees.h 58 | trees.c 59 | trees.h 60 | uncompr.c 61 | zutil.c 62 | zutil.h 63 | 64 | source files for sample programs 65 | See examples/README.examples 66 | 67 | unsupported contributions by third parties 68 | See contrib/README.contrib 69 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ZLIB DATA COMPRESSION LIBRARY 2 | 3 | zlib 1.2.8 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 5 | (Request for Comments) 1950 to 1952 in the files 6 | http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and 7 | rfc1952 (gzip format). 8 | 9 | All functions of the compression library are documented in the file zlib.h 10 | (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example 11 | of the library is given in the file test/example.c which also tests that 12 | the library is working correctly. Another example is given in the file 13 | test/minigzip.c. The compression library itself is composed of all source 14 | files in the root directory. 15 | 16 | To compile all files and run the test program, follow the instructions given at 17 | the top of Makefile.in. In short "./configure; make test", and if that goes 18 | well, "make install" should work for most flavors of Unix. For Windows, use 19 | one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use 20 | make_vms.com. 21 | 22 | Questions about zlib should be sent to , or to Gilles Vollant 23 | for the Windows DLL version. The zlib home page is 24 | http://zlib.net/ . Before reporting a problem, please check this site to 25 | verify that you have the latest version of zlib; otherwise get the latest 26 | version and check whether the problem still exists or not. 27 | 28 | PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. 29 | 30 | Mark Nelson wrote an article about zlib for the Jan. 1997 31 | issue of Dr. Dobb's Journal; a copy of the article is available at 32 | http://marknelson.us/1997/01/01/zlib-engine/ . 33 | 34 | The changes made in version 1.2.8 are documented in the file ChangeLog. 35 | 36 | Unsupported third party contributions are provided in directory contrib/ . 37 | 38 | zlib is available in Java using the java.util.zip package, documented at 39 | http://java.sun.com/developer/technicalArticles/Programming/compression/ . 40 | 41 | A Perl interface to zlib written by Paul Marquess is available 42 | at CPAN (Comprehensive Perl Archive Network) sites, including 43 | http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . 44 | 45 | A Python interface to zlib written by A.M. Kuchling is 46 | available in Python 1.5 and later versions, see 47 | http://docs.python.org/library/zlib.html . 48 | 49 | zlib is built into tcl: http://wiki.tcl.tk/4610 . 50 | 51 | An experimental package to read and write files in .zip format, written on top 52 | of zlib by Gilles Vollant , is available in the 53 | contrib/minizip directory of zlib. 54 | 55 | 56 | Notes for some targets: 57 | 58 | - For Windows DLL versions, please see win32/DLL_FAQ.txt 59 | 60 | - For 64-bit Irix, deflate.c must be compiled without any optimization. With 61 | -O, one libpng test fails. The test works in 32 bit mode (with the -n32 62 | compiler flag). The compiler bug has been reported to SGI. 63 | 64 | - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works 65 | when compiled with cc. 66 | 67 | - On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is 68 | necessary to get gzprintf working correctly. This is done by configure. 69 | 70 | - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with 71 | other compilers. Use "make test" to check your compiler. 72 | 73 | - gzdopen is not supported on RISCOS or BEOS. 74 | 75 | - For PalmOs, see http://palmzlib.sourceforge.net/ 76 | 77 | 78 | Acknowledgments: 79 | 80 | The deflate format used by zlib was defined by Phil Katz. The deflate and 81 | zlib specifications were written by L. Peter Deutsch. Thanks to all the 82 | people who reported problems and suggested various improvements in zlib; they 83 | are too numerous to cite here. 84 | 85 | Copyright notice: 86 | 87 | (C) 1995-2013 Jean-loup Gailly and Mark Adler 88 | 89 | This software is provided 'as-is', without any express or implied 90 | warranty. In no event will the authors be held liable for any damages 91 | arising from the use of this software. 92 | 93 | Permission is granted to anyone to use this software for any purpose, 94 | including commercial applications, and to alter it and redistribute it 95 | freely, subject to the following restrictions: 96 | 97 | 1. The origin of this software must not be misrepresented; you must not 98 | claim that you wrote the original software. If you use this software 99 | in a product, an acknowledgment in the product documentation would be 100 | appreciated but is not required. 101 | 2. Altered source versions must be plainly marked as such, and must not be 102 | misrepresented as being the original software. 103 | 3. This notice may not be removed or altered from any source distribution. 104 | 105 | Jean-loup Gailly Mark Adler 106 | jloup@gzip.org madler@alumni.caltech.edu 107 | 108 | If you use the zlib library in a product, we would appreciate *not* receiving 109 | lengthy legal documents to sign. The sources are provided for free but without 110 | warranty of any kind. The library has been entirely written by Jean-loup 111 | Gailly and Mark Adler; it does not include third-party code. 112 | 113 | If you redistribute modified sources, we would appreciate that you include in 114 | the file ChangeLog history information documenting your changes. Please read 115 | the FAQ for more information on the distribution of modified source versions. 116 | -------------------------------------------------------------------------------- /adler32.c: -------------------------------------------------------------------------------- 1 | /* adler32.c -- compute the Adler-32 checksum of a data stream 2 | * Copyright (C) 1995-2011 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #include "zutil.h" 9 | 10 | #define local static 11 | 12 | local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); 13 | 14 | #define BASE 65521 /* largest prime smaller than 65536 */ 15 | #define NMAX 5552 16 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 17 | 18 | #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} 19 | #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); 20 | #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); 21 | #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); 22 | #define DO16(buf) DO8(buf,0); DO8(buf,8); 23 | 24 | /* use NO_DIVIDE if your processor does not do division in hardware -- 25 | try it both ways to see which is faster */ 26 | #ifdef NO_DIVIDE 27 | /* note that this assumes BASE is 65521, where 65536 % 65521 == 15 28 | (thank you to John Reiser for pointing this out) */ 29 | # define CHOP(a) \ 30 | do { \ 31 | unsigned long tmp = a >> 16; \ 32 | a &= 0xffffUL; \ 33 | a += (tmp << 4) - tmp; \ 34 | } while (0) 35 | # define MOD28(a) \ 36 | do { \ 37 | CHOP(a); \ 38 | if (a >= BASE) a -= BASE; \ 39 | } while (0) 40 | # define MOD(a) \ 41 | do { \ 42 | CHOP(a); \ 43 | MOD28(a); \ 44 | } while (0) 45 | # define MOD63(a) \ 46 | do { /* this assumes a is not negative */ \ 47 | z_off64_t tmp = a >> 32; \ 48 | a &= 0xffffffffL; \ 49 | a += (tmp << 8) - (tmp << 5) + tmp; \ 50 | tmp = a >> 16; \ 51 | a &= 0xffffL; \ 52 | a += (tmp << 4) - tmp; \ 53 | tmp = a >> 16; \ 54 | a &= 0xffffL; \ 55 | a += (tmp << 4) - tmp; \ 56 | if (a >= BASE) a -= BASE; \ 57 | } while (0) 58 | #else 59 | # define MOD(a) a %= BASE 60 | # define MOD28(a) a %= BASE 61 | # define MOD63(a) a %= BASE 62 | #endif 63 | 64 | #if defined(ADLER32_SIMD_NEON) || defined (ADLER32_SIMD_SSSE3) 65 | #include "adler32_simd.h" 66 | #endif 67 | 68 | /* ========================================================================= */ 69 | uLong ZEXPORT adler32(adler, buf, len) 70 | uLong adler; 71 | const Bytef *buf; 72 | uInt len; 73 | { 74 | unsigned long sum2; 75 | unsigned n; 76 | 77 | #if defined(ADLER32_SIMD_NEON) || defined(ADLER32_SIMD_SSSE3) 78 | if (buf && len >= 64) 79 | return adler32_simd_(adler, buf, len); 80 | #endif 81 | 82 | /* split Adler-32 into component sums */ 83 | sum2 = (adler >> 16) & 0xffff; 84 | adler &= 0xffff; 85 | 86 | /* in case user likes doing a byte at a time, keep it fast */ 87 | if (len == 1) { 88 | adler += buf[0]; 89 | if (adler >= BASE) 90 | adler -= BASE; 91 | sum2 += adler; 92 | if (sum2 >= BASE) 93 | sum2 -= BASE; 94 | return adler | (sum2 << 16); 95 | } 96 | 97 | /* initial Adler-32 value (deferred check for len == 1 speed) */ 98 | if (buf == Z_NULL) 99 | return 1L; 100 | 101 | /* in case short lengths are provided, keep it somewhat fast */ 102 | if (len < 16) { 103 | while (len--) { 104 | adler += *buf++; 105 | sum2 += adler; 106 | } 107 | if (adler >= BASE) 108 | adler -= BASE; 109 | MOD28(sum2); /* only added so many BASE's */ 110 | return adler | (sum2 << 16); 111 | } 112 | 113 | /* do length NMAX blocks -- requires just one modulo operation */ 114 | while (len >= NMAX) { 115 | len -= NMAX; 116 | n = NMAX / 16; /* NMAX is divisible by 16 */ 117 | do { 118 | DO16(buf); /* 16 sums unrolled */ 119 | buf += 16; 120 | } while (--n); 121 | MOD(adler); 122 | MOD(sum2); 123 | } 124 | 125 | /* do remaining bytes (less than NMAX, still just one modulo) */ 126 | if (len) { /* avoid modulos if none remaining */ 127 | while (len >= 16) { 128 | len -= 16; 129 | DO16(buf); 130 | buf += 16; 131 | } 132 | while (len--) { 133 | adler += *buf++; 134 | sum2 += adler; 135 | } 136 | MOD(adler); 137 | MOD(sum2); 138 | } 139 | 140 | /* return recombined sums */ 141 | return adler | (sum2 << 16); 142 | } 143 | 144 | /* ========================================================================= */ 145 | local uLong adler32_combine_(adler1, adler2, len2) 146 | uLong adler1; 147 | uLong adler2; 148 | z_off64_t len2; 149 | { 150 | unsigned long sum1; 151 | unsigned long sum2; 152 | unsigned rem; 153 | 154 | /* for negative len, return invalid adler32 as a clue for debugging */ 155 | if (len2 < 0) 156 | return 0xffffffffUL; 157 | 158 | /* the derivation of this formula is left as an exercise for the reader */ 159 | MOD63(len2); /* assumes len2 >= 0 */ 160 | rem = (unsigned)len2; 161 | sum1 = adler1 & 0xffff; 162 | sum2 = rem * sum1; 163 | MOD(sum2); 164 | sum1 += (adler2 & 0xffff) + BASE - 1; 165 | sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; 166 | if (sum1 >= BASE) sum1 -= BASE; 167 | if (sum1 >= BASE) sum1 -= BASE; 168 | if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1); 169 | if (sum2 >= BASE) sum2 -= BASE; 170 | return sum1 | (sum2 << 16); 171 | } 172 | 173 | /* ========================================================================= */ 174 | uLong ZEXPORT adler32_combine(adler1, adler2, len2) 175 | uLong adler1; 176 | uLong adler2; 177 | z_off_t len2; 178 | { 179 | return adler32_combine_(adler1, adler2, len2); 180 | } 181 | 182 | uLong ZEXPORT adler32_combine64(adler1, adler2, len2) 183 | uLong adler1; 184 | uLong adler2; 185 | z_off64_t len2; 186 | { 187 | return adler32_combine_(adler1, adler2, len2); 188 | } 189 | -------------------------------------------------------------------------------- /adler32_simd.h: -------------------------------------------------------------------------------- 1 | /* adler32_simd.h 2 | * 3 | * (C) 1995-2013 Jean-loup Gailly and Mark Adler 4 | * 5 | * This software is provided 'as-is', without any express or implied 6 | * warranty. In no event will the authors be held liable for any damages 7 | * arising from the use of this software. 8 | * 9 | * Permission is granted to anyone to use this software for any purpose, 10 | * including commercial applications, and to alter it and redistribute it 11 | * freely, subject to the following restrictions: 12 | * 13 | * 1. The origin of this software must not be misrepresented; you must not 14 | * claim that you wrote the original software. If you use this software 15 | * in a product, an acknowledgment in the product documentation would be 16 | * appreciated but is not required. 17 | * 2. Altered source versions must be plainly marked as such, and must not be 18 | * misrepresented as being the original software. 19 | * 3. This notice may not be removed or altered from any source distribution. 20 | * 21 | * Jean-loup Gailly Mark Adler 22 | * jloup@gzip.org madler@alumni.caltech.edu 23 | * 24 | * Copyright 2017 The Chromium Authors. All rights reserved. 25 | * Use of this source code is governed by a BSD-style license that can be 26 | * found in the Chromium source repository LICENSE file. 27 | */ 28 | 29 | #include 30 | 31 | #include "zconf.h" 32 | #include "zutil.h" 33 | 34 | uint32_t ZLIB_INTERNAL adler32_simd_( 35 | uint32_t adler, 36 | const unsigned char *buf, 37 | unsigned long len); 38 | -------------------------------------------------------------------------------- /amiga/Makefile.pup: -------------------------------------------------------------------------------- 1 | # Amiga powerUP (TM) Makefile 2 | # makefile for libpng and SAS C V6.58/7.00 PPC compiler 3 | # Copyright (C) 1998 by Andreas R. Kleinert 4 | 5 | LIBNAME = libzip.a 6 | 7 | CC = scppc 8 | CFLAGS = NOSTKCHK NOSINT OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL \ 9 | OPTLOOP OPTRDEP=8 OPTDEP=8 OPTCOMP=8 NOVER 10 | AR = ppc-amigaos-ar cr 11 | RANLIB = ppc-amigaos-ranlib 12 | LD = ppc-amigaos-ld -r 13 | LDFLAGS = -o 14 | LDLIBS = LIB:scppc.a LIB:end.o 15 | RM = delete quiet 16 | 17 | OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \ 18 | uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o 19 | 20 | TEST_OBJS = example.o minigzip.o 21 | 22 | all: example minigzip 23 | 24 | check: test 25 | test: all 26 | example 27 | echo hello world | minigzip | minigzip -d 28 | 29 | $(LIBNAME): $(OBJS) 30 | $(AR) $@ $(OBJS) 31 | -$(RANLIB) $@ 32 | 33 | example: example.o $(LIBNAME) 34 | $(LD) $(LDFLAGS) $@ LIB:c_ppc.o $@.o $(LIBNAME) $(LDLIBS) 35 | 36 | minigzip: minigzip.o $(LIBNAME) 37 | $(LD) $(LDFLAGS) $@ LIB:c_ppc.o $@.o $(LIBNAME) $(LDLIBS) 38 | 39 | mostlyclean: clean 40 | clean: 41 | $(RM) *.o example minigzip $(LIBNAME) foo.gz 42 | 43 | zip: 44 | zip -ul9 zlib README ChangeLog Makefile Make????.??? Makefile.?? \ 45 | descrip.mms *.[ch] 46 | 47 | tgz: 48 | cd ..; tar cfz zlib/zlib.tgz zlib/README zlib/ChangeLog zlib/Makefile \ 49 | zlib/Make????.??? zlib/Makefile.?? zlib/descrip.mms zlib/*.[ch] 50 | 51 | # DO NOT DELETE THIS LINE -- make depend depends on it. 52 | 53 | adler32.o: zlib.h zconf.h 54 | compress.o: zlib.h zconf.h 55 | crc32.o: crc32.h zlib.h zconf.h 56 | deflate.o: deflate.h zutil.h zlib.h zconf.h 57 | example.o: zlib.h zconf.h 58 | gzclose.o: zlib.h zconf.h gzguts.h 59 | gzlib.o: zlib.h zconf.h gzguts.h 60 | gzread.o: zlib.h zconf.h gzguts.h 61 | gzwrite.o: zlib.h zconf.h gzguts.h 62 | inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h 63 | inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h 64 | infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h 65 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h 66 | minigzip.o: zlib.h zconf.h 67 | trees.o: deflate.h zutil.h zlib.h zconf.h trees.h 68 | uncompr.o: zlib.h zconf.h 69 | zutil.o: zutil.h zlib.h zconf.h 70 | -------------------------------------------------------------------------------- /amiga/Makefile.sas: -------------------------------------------------------------------------------- 1 | # SMakefile for zlib 2 | # Modified from the standard UNIX Makefile Copyright Jean-loup Gailly 3 | # Osma Ahvenlampi 4 | # Amiga, SAS/C 6.56 & Smake 5 | 6 | CC=sc 7 | CFLAGS=OPT 8 | #CFLAGS=OPT CPU=68030 9 | #CFLAGS=DEBUG=LINE 10 | LDFLAGS=LIB z.lib 11 | 12 | SCOPTIONS=OPTSCHED OPTINLINE OPTALIAS OPTTIME OPTINLOCAL STRMERGE \ 13 | NOICONS PARMS=BOTH NOSTACKCHECK UTILLIB NOVERSION ERRORREXX \ 14 | DEF=POSTINC 15 | 16 | OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \ 17 | uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o 18 | 19 | TEST_OBJS = example.o minigzip.o 20 | 21 | all: SCOPTIONS example minigzip 22 | 23 | check: test 24 | test: all 25 | example 26 | echo hello world | minigzip | minigzip -d 27 | 28 | install: z.lib 29 | copy clone zlib.h zconf.h INCLUDE: 30 | copy clone z.lib LIB: 31 | 32 | z.lib: $(OBJS) 33 | oml z.lib r $(OBJS) 34 | 35 | example: example.o z.lib 36 | $(CC) $(CFLAGS) LINK TO $@ example.o $(LDFLAGS) 37 | 38 | minigzip: minigzip.o z.lib 39 | $(CC) $(CFLAGS) LINK TO $@ minigzip.o $(LDFLAGS) 40 | 41 | mostlyclean: clean 42 | clean: 43 | -delete force quiet example minigzip *.o z.lib foo.gz *.lnk SCOPTIONS 44 | 45 | SCOPTIONS: Makefile.sas 46 | copy to $@ 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | #endif 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | stream.opaque = (voidpf)0; 45 | 46 | err = deflateInit(&stream, level); 47 | if (err != Z_OK) return err; 48 | 49 | err = deflate(&stream, Z_FINISH); 50 | if (err != Z_STREAM_END) { 51 | deflateEnd(&stream); 52 | return err == Z_OK ? Z_BUF_ERROR : err; 53 | } 54 | *destLen = stream.total_out; 55 | 56 | err = deflateEnd(&stream); 57 | return err; 58 | } 59 | 60 | /* =========================================================================== 61 | */ 62 | int ZEXPORT compress (dest, destLen, source, sourceLen) 63 | Bytef *dest; 64 | uLongf *destLen; 65 | const Bytef *source; 66 | uLong sourceLen; 67 | { 68 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 69 | } 70 | 71 | /* =========================================================================== 72 | If the default memLevel or windowBits for deflateInit() is changed, then 73 | this function needs to be updated. 74 | */ 75 | uLong ZEXPORT compressBound (sourceLen) 76 | uLong sourceLen; 77 | { 78 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 79 | (sourceLen >> 25) + 13; 80 | } 81 | -------------------------------------------------------------------------------- /crc32_simd.c: -------------------------------------------------------------------------------- 1 | /* crc32_simd.c 2 | * 3 | * Copyright 2017 The Chromium Authors. All rights reserved. 4 | * Use of this source code is governed by a BSD-style license that can be 5 | * found in the Chromium source repository LICENSE file. 6 | */ 7 | 8 | 9 | #include "crc32_simd.h" 10 | 11 | #if defined(CRC32_SIMD_SSE42_PCLMUL) 12 | 13 | /* 14 | * crc32_sse42_simd_(): compute the crc32 of the buffer, where the buffer 15 | * length must be at least 64, and a multiple of 16. Based on: 16 | * 17 | * "Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction" 18 | * V. Gopal, E. Ozturk, et al., 2009, http://intel.ly/2ySEwL0 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | uint32_t ZLIB_INTERNAL crc32_sse42_simd_( /* SSE4.2+PCLMUL */ 26 | const unsigned char *buf, 27 | z_size_t len, 28 | uint32_t crc) 29 | { 30 | /* 31 | * Definitions of the bit-reflected domain constants k1,k2,k3, etc and 32 | * the CRC32+Barrett polynomials given at the end of the paper. 33 | */ 34 | static const uint64_t zalign(16) k1k2[] = { 0x0154442bd4, 0x01c6e41596 }; 35 | static const uint64_t zalign(16) k3k4[] = { 0x01751997d0, 0x00ccaa009e }; 36 | static const uint64_t zalign(16) k5k0[] = { 0x0163cd6124, 0x0000000000 }; 37 | static const uint64_t zalign(16) poly[] = { 0x01db710641, 0x01f7011641 }; 38 | 39 | __m128i x0, x1, x2, x3, x4, x5, x6, x7, x8, y5, y6, y7, y8; 40 | 41 | /* 42 | * There's at least one block of 64. 43 | */ 44 | x1 = _mm_loadu_si128((__m128i *)(buf + 0x00)); 45 | x2 = _mm_loadu_si128((__m128i *)(buf + 0x10)); 46 | x3 = _mm_loadu_si128((__m128i *)(buf + 0x20)); 47 | x4 = _mm_loadu_si128((__m128i *)(buf + 0x30)); 48 | 49 | x1 = _mm_xor_si128(x1, _mm_cvtsi32_si128(crc)); 50 | 51 | x0 = _mm_load_si128((__m128i *)k1k2); 52 | 53 | buf += 64; 54 | len -= 64; 55 | 56 | /* 57 | * Parallel fold blocks of 64, if any. 58 | */ 59 | while (len >= 64) 60 | { 61 | x5 = _mm_clmulepi64_si128(x1, x0, 0x00); 62 | x6 = _mm_clmulepi64_si128(x2, x0, 0x00); 63 | x7 = _mm_clmulepi64_si128(x3, x0, 0x00); 64 | x8 = _mm_clmulepi64_si128(x4, x0, 0x00); 65 | 66 | x1 = _mm_clmulepi64_si128(x1, x0, 0x11); 67 | x2 = _mm_clmulepi64_si128(x2, x0, 0x11); 68 | x3 = _mm_clmulepi64_si128(x3, x0, 0x11); 69 | x4 = _mm_clmulepi64_si128(x4, x0, 0x11); 70 | 71 | y5 = _mm_loadu_si128((__m128i *)(buf + 0x00)); 72 | y6 = _mm_loadu_si128((__m128i *)(buf + 0x10)); 73 | y7 = _mm_loadu_si128((__m128i *)(buf + 0x20)); 74 | y8 = _mm_loadu_si128((__m128i *)(buf + 0x30)); 75 | 76 | x1 = _mm_xor_si128(x1, x5); 77 | x2 = _mm_xor_si128(x2, x6); 78 | x3 = _mm_xor_si128(x3, x7); 79 | x4 = _mm_xor_si128(x4, x8); 80 | 81 | x1 = _mm_xor_si128(x1, y5); 82 | x2 = _mm_xor_si128(x2, y6); 83 | x3 = _mm_xor_si128(x3, y7); 84 | x4 = _mm_xor_si128(x4, y8); 85 | 86 | buf += 64; 87 | len -= 64; 88 | } 89 | 90 | /* 91 | * Fold into 128-bits. 92 | */ 93 | x0 = _mm_load_si128((__m128i *)k3k4); 94 | 95 | x5 = _mm_clmulepi64_si128(x1, x0, 0x00); 96 | x1 = _mm_clmulepi64_si128(x1, x0, 0x11); 97 | x1 = _mm_xor_si128(x1, x2); 98 | x1 = _mm_xor_si128(x1, x5); 99 | 100 | x5 = _mm_clmulepi64_si128(x1, x0, 0x00); 101 | x1 = _mm_clmulepi64_si128(x1, x0, 0x11); 102 | x1 = _mm_xor_si128(x1, x3); 103 | x1 = _mm_xor_si128(x1, x5); 104 | 105 | x5 = _mm_clmulepi64_si128(x1, x0, 0x00); 106 | x1 = _mm_clmulepi64_si128(x1, x0, 0x11); 107 | x1 = _mm_xor_si128(x1, x4); 108 | x1 = _mm_xor_si128(x1, x5); 109 | 110 | /* 111 | * Single fold blocks of 16, if any. 112 | */ 113 | while (len >= 16) 114 | { 115 | x2 = _mm_loadu_si128((__m128i *)buf); 116 | 117 | x5 = _mm_clmulepi64_si128(x1, x0, 0x00); 118 | x1 = _mm_clmulepi64_si128(x1, x0, 0x11); 119 | x1 = _mm_xor_si128(x1, x2); 120 | x1 = _mm_xor_si128(x1, x5); 121 | 122 | buf += 16; 123 | len -= 16; 124 | } 125 | 126 | /* 127 | * Fold 128-bits to 64-bits. 128 | */ 129 | x2 = _mm_clmulepi64_si128(x1, x0, 0x10); 130 | x3 = _mm_setr_epi32(~0, 0, ~0, 0); 131 | x1 = _mm_srli_si128(x1, 8); 132 | x1 = _mm_xor_si128(x1, x2); 133 | 134 | x0 = _mm_loadl_epi64((__m128i*)k5k0); 135 | 136 | x2 = _mm_srli_si128(x1, 4); 137 | x1 = _mm_and_si128(x1, x3); 138 | x1 = _mm_clmulepi64_si128(x1, x0, 0x00); 139 | x1 = _mm_xor_si128(x1, x2); 140 | 141 | /* 142 | * Barret reduce to 32-bits. 143 | */ 144 | x0 = _mm_load_si128((__m128i*)poly); 145 | 146 | x2 = _mm_and_si128(x1, x3); 147 | x2 = _mm_clmulepi64_si128(x2, x0, 0x10); 148 | x2 = _mm_and_si128(x2, x3); 149 | x2 = _mm_clmulepi64_si128(x2, x0, 0x00); 150 | x1 = _mm_xor_si128(x1, x2); 151 | 152 | /* 153 | * Return the crc32. 154 | */ 155 | return _mm_extract_epi32(x1, 1); 156 | } 157 | 158 | #elif defined(CRC32_ARMV8_CRC32) 159 | 160 | /* CRC32 checksums using ARMv8-a crypto instructions. 161 | * 162 | * TODO: implement a version using the PMULL instruction. 163 | */ 164 | 165 | #if defined(__clang__) 166 | /* CRC32 intrinsics are #ifdef'ed out of arm_acle.h unless we build with an 167 | * armv8 target, which is incompatible with ThinLTO optimizations on Android. 168 | * (Namely, mixing and matching different module-level targets makes ThinLTO 169 | * warn, and Android defaults to armv7-a. This restriction does not apply to 170 | * function-level `target`s, however.) 171 | * 172 | * Since we only need four crc intrinsics, and since clang's implementation of 173 | * those are just wrappers around compiler builtins, it's simplest to #define 174 | * those builtins directly. If this #define list grows too much (or we depend on 175 | * an intrinsic that isn't a trivial wrapper), we may have to find a better way 176 | * to go about this. 177 | * 178 | * NOTE: clang currently complains that "'+soft-float-abi' is not a recognized 179 | * feature for this target (ignoring feature)." This appears to be a harmless 180 | * bug in clang. 181 | */ 182 | #define __crc32b __builtin_arm_crc32b 183 | #define __crc32d __builtin_arm_crc32d 184 | #define __crc32w __builtin_arm_crc32w 185 | #define __crc32cw __builtin_arm_crc32cw 186 | 187 | #if defined(__aarch64__) 188 | #define TARGET_ARMV8_WITH_CRC __attribute__((target("crc"))) 189 | #else // !defined(__aarch64__) 190 | #define TARGET_ARMV8_WITH_CRC __attribute__((target("armv8-a,crc"))) 191 | #endif // defined(__aarch64__) 192 | 193 | #elif defined(__GNUC__) 194 | /* For GCC, we are setting CRC extensions at module level, so ThinLTO is not 195 | * allowed. We can just include arm_acle.h. 196 | */ 197 | #include 198 | #define TARGET_ARMV8_WITH_CRC 199 | #else // !defined(__GNUC__) && !defined(_aarch64__) 200 | #error ARM CRC32 SIMD extensions only supported for Clang and GCC 201 | #endif 202 | 203 | TARGET_ARMV8_WITH_CRC 204 | uint32_t ZLIB_INTERNAL armv8_crc32_little(unsigned long crc, 205 | const unsigned char *buf, 206 | z_size_t len) 207 | { 208 | uint32_t c = (uint32_t) ~crc; 209 | 210 | while (len && ((uintptr_t)buf & 7)) { 211 | c = __crc32b(c, *buf++); 212 | --len; 213 | } 214 | 215 | const uint64_t *buf8 = (const uint64_t *)buf; 216 | 217 | while (len >= 64) { 218 | c = __crc32d(c, *buf8++); 219 | c = __crc32d(c, *buf8++); 220 | c = __crc32d(c, *buf8++); 221 | c = __crc32d(c, *buf8++); 222 | 223 | c = __crc32d(c, *buf8++); 224 | c = __crc32d(c, *buf8++); 225 | c = __crc32d(c, *buf8++); 226 | c = __crc32d(c, *buf8++); 227 | len -= 64; 228 | } 229 | 230 | while (len >= 8) { 231 | c = __crc32d(c, *buf8++); 232 | len -= 8; 233 | } 234 | 235 | buf = (const unsigned char *)buf8; 236 | 237 | while (len--) { 238 | c = __crc32b(c, *buf++); 239 | } 240 | 241 | return ~c; 242 | } 243 | 244 | #endif -------------------------------------------------------------------------------- /crc32_simd.h: -------------------------------------------------------------------------------- 1 | //https://cs.chromium.org/chromium/src/third_party/zlib/crc32_simd.c 2 | /* crc32_simd.h 3 | * 4 | * Copyright 2017 The Chromium Authors. All rights reserved. 5 | * Use of this source code is governed by a BSD-style license that can be 6 | * found in the Chromium source repository LICENSE file. 7 | */ 8 | #ifndef CRC32_SIMD_H 9 | #define CRC32_SIMD_H 10 | 11 | 12 | #include 13 | 14 | //#include "zconf.h" 15 | //#include "zutil.h" 16 | #include "deflate.h" 17 | 18 | //#ifndef local 19 | // #define local static 20 | //#endif 21 | 22 | //#ifndef z_crc_t 23 | // #ifdef Z_U4 24 | // typedef Z_U4 z_crc_t; 25 | // #else 26 | // typedef unsigned long z_crc_t; 27 | // #endif 28 | //#endif 29 | #ifdef HAS_PCLMUL 30 | #define CRC32_SIMD_SSE42_PCLMUL 31 | #endif 32 | 33 | #ifndef z_size_t 34 | #define z_size_t size_t 35 | #endif 36 | #ifndef zalign 37 | #ifdef _MSC_VER 38 | #define zalign(x) __declspec(align(x)) 39 | #else 40 | #define zalign(x) __attribute__((aligned((x)))) 41 | #endif 42 | #endif 43 | 44 | 45 | 46 | /* 47 | * crc32_sse42_simd_(): compute the crc32 of the buffer, where the buffer 48 | * length must be at least 64, and a multiple of 16. 49 | */ 50 | uint32_t ZLIB_INTERNAL crc32_sse42_simd_( 51 | const unsigned char *buf, 52 | z_size_t len, 53 | uint32_t crc); 54 | 55 | /* 56 | * crc32_sse42_simd_ buffer size constraints: see the use in zlib/crc32.c 57 | * for computing the crc32 of an arbitrary length buffer. 58 | */ 59 | #define Z_CRC32_SSE42_MINIMUM_LENGTH 64 60 | #define Z_CRC32_SSE42_CHUNKSIZE_MASK 15 61 | 62 | /* 63 | * CRC32 checksums using ARMv8-a crypto instructions. 64 | */ 65 | uint32_t ZLIB_INTERNAL armv8_crc32_little(unsigned long crc, 66 | const unsigned char* buf, 67 | z_size_t len); 68 | 69 | #endif /* CRC32_SIMD_H */ -------------------------------------------------------------------------------- /doc/txtvsbin.txt: -------------------------------------------------------------------------------- 1 | A Fast Method for Identifying Plain Text Files 2 | ============================================== 3 | 4 | 5 | Introduction 6 | ------------ 7 | 8 | Given a file coming from an unknown source, it is sometimes desirable 9 | to find out whether the format of that file is plain text. Although 10 | this may appear like a simple task, a fully accurate detection of the 11 | file type requires heavy-duty semantic analysis on the file contents. 12 | It is, however, possible to obtain satisfactory results by employing 13 | various heuristics. 14 | 15 | Previous versions of PKZip and other zip-compatible compression tools 16 | were using a crude detection scheme: if more than 80% (4/5) of the bytes 17 | found in a certain buffer are within the range [7..127], the file is 18 | labeled as plain text, otherwise it is labeled as binary. A prominent 19 | limitation of this scheme is the restriction to Latin-based alphabets. 20 | Other alphabets, like Greek, Cyrillic or Asian, make extensive use of 21 | the bytes within the range [128..255], and texts using these alphabets 22 | are most often misidentified by this scheme; in other words, the rate 23 | of false negatives is sometimes too high, which means that the recall 24 | is low. Another weakness of this scheme is a reduced precision, due to 25 | the false positives that may occur when binary files containing large 26 | amounts of textual characters are misidentified as plain text. 27 | 28 | In this article we propose a new, simple detection scheme that features 29 | a much increased precision and a near-100% recall. This scheme is 30 | designed to work on ASCII, Unicode and other ASCII-derived alphabets, 31 | and it handles single-byte encodings (ISO-8859, MacRoman, KOI8, etc.) 32 | and variable-sized encodings (ISO-2022, UTF-8, etc.). Wider encodings 33 | (UCS-2/UTF-16 and UCS-4/UTF-32) are not handled, however. 34 | 35 | 36 | The Algorithm 37 | ------------- 38 | 39 | The algorithm works by dividing the set of bytecodes [0..255] into three 40 | categories: 41 | - The white list of textual bytecodes: 42 | 9 (TAB), 10 (LF), 13 (CR), 32 (SPACE) to 255. 43 | - The gray list of tolerated bytecodes: 44 | 7 (BEL), 8 (BS), 11 (VT), 12 (FF), 26 (SUB), 27 (ESC). 45 | - The black list of undesired, non-textual bytecodes: 46 | 0 (NUL) to 6, 14 to 31. 47 | 48 | If a file contains at least one byte that belongs to the white list and 49 | no byte that belongs to the black list, then the file is categorized as 50 | plain text; otherwise, it is categorized as binary. (The boundary case, 51 | when the file is empty, automatically falls into the latter category.) 52 | 53 | 54 | Rationale 55 | --------- 56 | 57 | The idea behind this algorithm relies on two observations. 58 | 59 | The first observation is that, although the full range of 7-bit codes 60 | [0..127] is properly specified by the ASCII standard, most control 61 | characters in the range [0..31] are not used in practice. The only 62 | widely-used, almost universally-portable control codes are 9 (TAB), 63 | 10 (LF) and 13 (CR). There are a few more control codes that are 64 | recognized on a reduced range of platforms and text viewers/editors: 65 | 7 (BEL), 8 (BS), 11 (VT), 12 (FF), 26 (SUB) and 27 (ESC); but these 66 | codes are rarely (if ever) used alone, without being accompanied by 67 | some printable text. Even the newer, portable text formats such as 68 | XML avoid using control characters outside the list mentioned here. 69 | 70 | The second observation is that most of the binary files tend to contain 71 | control characters, especially 0 (NUL). Even though the older text 72 | detection schemes observe the presence of non-ASCII codes from the range 73 | [128..255], the precision rarely has to suffer if this upper range is 74 | labeled as textual, because the files that are genuinely binary tend to 75 | contain both control characters and codes from the upper range. On the 76 | other hand, the upper range needs to be labeled as textual, because it 77 | is used by virtually all ASCII extensions. In particular, this range is 78 | used for encoding non-Latin scripts. 79 | 80 | Since there is no counting involved, other than simply observing the 81 | presence or the absence of some byte values, the algorithm produces 82 | consistent results, regardless what alphabet encoding is being used. 83 | (If counting were involved, it could be possible to obtain different 84 | results on a text encoded, say, using ISO-8859-16 versus UTF-8.) 85 | 86 | There is an extra category of plain text files that are "polluted" with 87 | one or more black-listed codes, either by mistake or by peculiar design 88 | considerations. In such cases, a scheme that tolerates a small fraction 89 | of black-listed codes would provide an increased recall (i.e. more true 90 | positives). This, however, incurs a reduced precision overall, since 91 | false positives are more likely to appear in binary files that contain 92 | large chunks of textual data. Furthermore, "polluted" plain text should 93 | be regarded as binary by general-purpose text detection schemes, because 94 | general-purpose text processing algorithms might not be applicable. 95 | Under this premise, it is safe to say that our detection method provides 96 | a near-100% recall. 97 | 98 | Experiments have been run on many files coming from various platforms 99 | and applications. We tried plain text files, system logs, source code, 100 | formatted office documents, compiled object code, etc. The results 101 | confirm the optimistic assumptions about the capabilities of this 102 | algorithm. 103 | 104 | 105 | -- 106 | Cosmin Truta 107 | Last updated: 2006-May-28 108 | -------------------------------------------------------------------------------- /examples/README.examples: -------------------------------------------------------------------------------- 1 | This directory contains examples of the use of zlib and other relevant 2 | programs and documentation. 3 | 4 | enough.c 5 | calculation and justification of ENOUGH parameter in inftrees.h 6 | - calculates the maximum table space used in inflate tree 7 | construction over all possible Huffman codes 8 | 9 | fitblk.c 10 | compress just enough input to nearly fill a requested output size 11 | - zlib isn't designed to do this, but fitblk does it anyway 12 | 13 | gun.c 14 | uncompress a gzip file 15 | - illustrates the use of inflateBack() for high speed file-to-file 16 | decompression using call-back functions 17 | - is approximately twice as fast as gzip -d 18 | - also provides Unix uncompress functionality, again twice as fast 19 | 20 | gzappend.c 21 | append to a gzip file 22 | - illustrates the use of the Z_BLOCK flush parameter for inflate() 23 | - illustrates the use of deflatePrime() to start at any bit 24 | 25 | gzjoin.c 26 | join gzip files without recalculating the crc or recompressing 27 | - illustrates the use of the Z_BLOCK flush parameter for inflate() 28 | - illustrates the use of crc32_combine() 29 | 30 | gzlog.c 31 | gzlog.h 32 | efficiently and robustly maintain a message log file in gzip format 33 | - illustrates use of raw deflate, Z_PARTIAL_FLUSH, deflatePrime(), 34 | and deflateSetDictionary() 35 | - illustrates use of a gzip header extra field 36 | 37 | zlib_how.html 38 | painfully comprehensive description of zpipe.c (see below) 39 | - describes in excruciating detail the use of deflate() and inflate() 40 | 41 | zpipe.c 42 | reads and writes zlib streams from stdin to stdout 43 | - illustrates the proper use of deflate() and inflate() 44 | - deeply commented in zlib_how.html (see above) 45 | 46 | zran.c 47 | index a zlib or gzip stream and randomly access it 48 | - illustrates the use of Z_BLOCK, inflatePrime(), and 49 | inflateSetDictionary() to provide random access 50 | -------------------------------------------------------------------------------- /examples/gzlog.h: -------------------------------------------------------------------------------- 1 | /* gzlog.h 2 | Copyright (C) 2004, 2008, 2012 Mark Adler, all rights reserved 3 | version 2.2, 14 Aug 2012 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the author be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | 21 | Mark Adler madler@alumni.caltech.edu 22 | */ 23 | 24 | /* Version History: 25 | 1.0 26 Nov 2004 First version 26 | 2.0 25 Apr 2008 Complete redesign for recovery of interrupted operations 27 | Interface changed slightly in that now path is a prefix 28 | Compression now occurs as needed during gzlog_write() 29 | gzlog_write() now always leaves the log file as valid gzip 30 | 2.1 8 Jul 2012 Fix argument checks in gzlog_compress() and gzlog_write() 31 | 2.2 14 Aug 2012 Clean up signed comparisons 32 | */ 33 | 34 | /* 35 | The gzlog object allows writing short messages to a gzipped log file, 36 | opening the log file locked for small bursts, and then closing it. The log 37 | object works by appending stored (uncompressed) data to the gzip file until 38 | 1 MB has been accumulated. At that time, the stored data is compressed, and 39 | replaces the uncompressed data in the file. The log file is truncated to 40 | its new size at that time. After each write operation, the log file is a 41 | valid gzip file that can decompressed to recover what was written. 42 | 43 | The gzlog operations can be interupted at any point due to an application or 44 | system crash, and the log file will be recovered the next time the log is 45 | opened with gzlog_open(). 46 | */ 47 | 48 | #ifndef GZLOG_H 49 | #define GZLOG_H 50 | 51 | /* gzlog object type */ 52 | typedef void gzlog; 53 | 54 | /* Open a gzlog object, creating the log file if it does not exist. Return 55 | NULL on error. Note that gzlog_open() could take a while to complete if it 56 | has to wait to verify that a lock is stale (possibly for five minutes), or 57 | if there is significant contention with other instantiations of this object 58 | when locking the resource. path is the prefix of the file names created by 59 | this object. If path is "foo", then the log file will be "foo.gz", and 60 | other auxiliary files will be created and destroyed during the process: 61 | "foo.dict" for a compression dictionary, "foo.temp" for a temporary (next) 62 | dictionary, "foo.add" for data being added or compressed, "foo.lock" for the 63 | lock file, and "foo.repairs" to log recovery operations performed due to 64 | interrupted gzlog operations. A gzlog_open() followed by a gzlog_close() 65 | will recover a previously interrupted operation, if any. */ 66 | gzlog *gzlog_open(char *path); 67 | 68 | /* Write to a gzlog object. Return zero on success, -1 if there is a file i/o 69 | error on any of the gzlog files (this should not happen if gzlog_open() 70 | succeeded, unless the device has run out of space or leftover auxiliary 71 | files have permissions or ownership that prevent their use), -2 if there is 72 | a memory allocation failure, or -3 if the log argument is invalid (e.g. if 73 | it was not created by gzlog_open()). This function will write data to the 74 | file uncompressed, until 1 MB has been accumulated, at which time that data 75 | will be compressed. The log file will be a valid gzip file upon successful 76 | return. */ 77 | int gzlog_write(gzlog *log, void *data, size_t len); 78 | 79 | /* Force compression of any uncompressed data in the log. This should be used 80 | sparingly, if at all. The main application would be when a log file will 81 | not be appended to again. If this is used to compress frequently while 82 | appending, it will both significantly increase the execution time and 83 | reduce the compression ratio. The return codes are the same as for 84 | gzlog_write(). */ 85 | int gzlog_compress(gzlog *log); 86 | 87 | /* Close a gzlog object. Return zero on success, -3 if the log argument is 88 | invalid. The log object is freed, and so cannot be referenced again. */ 89 | int gzlog_close(gzlog *log); 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /examples/zpipe.c: -------------------------------------------------------------------------------- 1 | /* zpipe.c: example of proper use of zlib's inflate() and deflate() 2 | Not copyrighted -- provided to the public domain 3 | Version 1.4 11 December 2005 Mark Adler */ 4 | 5 | /* Version history: 6 | 1.0 30 Oct 2004 First version 7 | 1.1 8 Nov 2004 Add void casting for unused return values 8 | Use switch statement for inflate() return values 9 | 1.2 9 Nov 2004 Add assertions to document zlib guarantees 10 | 1.3 6 Apr 2005 Remove incorrect assertion in inf() 11 | 1.4 11 Dec 2005 Add hack to avoid MSDOS end-of-line conversions 12 | Avoid some compiler warnings for input and output buffers 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | #include "zlib.h" 19 | 20 | #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) 21 | # include 22 | # include 23 | # define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) 24 | #else 25 | # define SET_BINARY_MODE(file) 26 | #endif 27 | 28 | #define CHUNK 16384 29 | 30 | /* Compress from file source to file dest until EOF on source. 31 | def() returns Z_OK on success, Z_MEM_ERROR if memory could not be 32 | allocated for processing, Z_STREAM_ERROR if an invalid compression 33 | level is supplied, Z_VERSION_ERROR if the version of zlib.h and the 34 | version of the library linked do not match, or Z_ERRNO if there is 35 | an error reading or writing the files. */ 36 | int def(FILE *source, FILE *dest, int level) 37 | { 38 | int ret, flush; 39 | unsigned have; 40 | z_stream strm; 41 | unsigned char in[CHUNK]; 42 | unsigned char out[CHUNK]; 43 | 44 | /* allocate deflate state */ 45 | strm.zalloc = Z_NULL; 46 | strm.zfree = Z_NULL; 47 | strm.opaque = Z_NULL; 48 | ret = deflateInit(&strm, level); 49 | if (ret != Z_OK) 50 | return ret; 51 | 52 | /* compress until end of file */ 53 | do { 54 | strm.avail_in = fread(in, 1, CHUNK, source); 55 | if (ferror(source)) { 56 | (void)deflateEnd(&strm); 57 | return Z_ERRNO; 58 | } 59 | flush = feof(source) ? Z_FINISH : Z_NO_FLUSH; 60 | strm.next_in = in; 61 | 62 | /* run deflate() on input until output buffer not full, finish 63 | compression if all of source has been read in */ 64 | do { 65 | strm.avail_out = CHUNK; 66 | strm.next_out = out; 67 | ret = deflate(&strm, flush); /* no bad return value */ 68 | assert(ret != Z_STREAM_ERROR); /* state not clobbered */ 69 | have = CHUNK - strm.avail_out; 70 | if (fwrite(out, 1, have, dest) != have || ferror(dest)) { 71 | (void)deflateEnd(&strm); 72 | return Z_ERRNO; 73 | } 74 | } while (strm.avail_out == 0); 75 | assert(strm.avail_in == 0); /* all input will be used */ 76 | 77 | /* done when last data in file processed */ 78 | } while (flush != Z_FINISH); 79 | assert(ret == Z_STREAM_END); /* stream will be complete */ 80 | 81 | /* clean up and return */ 82 | (void)deflateEnd(&strm); 83 | return Z_OK; 84 | } 85 | 86 | /* Decompress from file source to file dest until stream ends or EOF. 87 | inf() returns Z_OK on success, Z_MEM_ERROR if memory could not be 88 | allocated for processing, Z_DATA_ERROR if the deflate data is 89 | invalid or incomplete, Z_VERSION_ERROR if the version of zlib.h and 90 | the version of the library linked do not match, or Z_ERRNO if there 91 | is an error reading or writing the files. */ 92 | int inf(FILE *source, FILE *dest) 93 | { 94 | int ret; 95 | unsigned have; 96 | z_stream strm; 97 | unsigned char in[CHUNK]; 98 | unsigned char out[CHUNK]; 99 | 100 | /* allocate inflate state */ 101 | strm.zalloc = Z_NULL; 102 | strm.zfree = Z_NULL; 103 | strm.opaque = Z_NULL; 104 | strm.avail_in = 0; 105 | strm.next_in = Z_NULL; 106 | ret = inflateInit(&strm); 107 | if (ret != Z_OK) 108 | return ret; 109 | 110 | /* decompress until deflate stream ends or end of file */ 111 | do { 112 | strm.avail_in = fread(in, 1, CHUNK, source); 113 | if (ferror(source)) { 114 | (void)inflateEnd(&strm); 115 | return Z_ERRNO; 116 | } 117 | if (strm.avail_in == 0) 118 | break; 119 | strm.next_in = in; 120 | 121 | /* run inflate() on input until output buffer not full */ 122 | do { 123 | strm.avail_out = CHUNK; 124 | strm.next_out = out; 125 | ret = inflate(&strm, Z_NO_FLUSH); 126 | assert(ret != Z_STREAM_ERROR); /* state not clobbered */ 127 | switch (ret) { 128 | case Z_NEED_DICT: 129 | ret = Z_DATA_ERROR; /* and fall through */ 130 | case Z_DATA_ERROR: 131 | case Z_MEM_ERROR: 132 | (void)inflateEnd(&strm); 133 | return ret; 134 | } 135 | have = CHUNK - strm.avail_out; 136 | if (fwrite(out, 1, have, dest) != have || ferror(dest)) { 137 | (void)inflateEnd(&strm); 138 | return Z_ERRNO; 139 | } 140 | } while (strm.avail_out == 0); 141 | 142 | /* done when inflate() says it's done */ 143 | } while (ret != Z_STREAM_END); 144 | 145 | /* clean up and return */ 146 | (void)inflateEnd(&strm); 147 | return ret == Z_STREAM_END ? Z_OK : Z_DATA_ERROR; 148 | } 149 | 150 | /* report a zlib or i/o error */ 151 | void zerr(int ret) 152 | { 153 | fputs("zpipe: ", stderr); 154 | switch (ret) { 155 | case Z_ERRNO: 156 | if (ferror(stdin)) 157 | fputs("error reading stdin\n", stderr); 158 | if (ferror(stdout)) 159 | fputs("error writing stdout\n", stderr); 160 | break; 161 | case Z_STREAM_ERROR: 162 | fputs("invalid compression level\n", stderr); 163 | break; 164 | case Z_DATA_ERROR: 165 | fputs("invalid or incomplete deflate data\n", stderr); 166 | break; 167 | case Z_MEM_ERROR: 168 | fputs("out of memory\n", stderr); 169 | break; 170 | case Z_VERSION_ERROR: 171 | fputs("zlib version mismatch!\n", stderr); 172 | } 173 | } 174 | 175 | /* compress or decompress from stdin to stdout */ 176 | int main(int argc, char **argv) 177 | { 178 | int ret; 179 | 180 | /* avoid end-of-line conversions */ 181 | SET_BINARY_MODE(stdin); 182 | SET_BINARY_MODE(stdout); 183 | 184 | /* do compression if no arguments */ 185 | if (argc == 1) { 186 | ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION); 187 | if (ret != Z_OK) 188 | zerr(ret); 189 | return ret; 190 | } 191 | 192 | /* do decompression if -d specified */ 193 | else if (argc == 2 && strcmp(argv[1], "-d") == 0) { 194 | ret = inf(stdin, stdout); 195 | if (ret != Z_OK) 196 | zerr(ret); 197 | return ret; 198 | } 199 | 200 | /* otherwise, report usage */ 201 | else { 202 | fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr); 203 | return 1; 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /gzguts.h: -------------------------------------------------------------------------------- 1 | /* gzguts.h -- zlib internal header definitions for gz* operations 2 | * Copyright (C) 2004, 2005, 2010, 2011, 2012, 2013 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #ifdef _LARGEFILE64_SOURCE 7 | # ifndef _LARGEFILE_SOURCE 8 | # define _LARGEFILE_SOURCE 1 9 | # endif 10 | # ifdef _FILE_OFFSET_BITS 11 | # undef _FILE_OFFSET_BITS 12 | # endif 13 | #endif 14 | 15 | #ifdef HAVE_HIDDEN 16 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 17 | #else 18 | # define ZLIB_INTERNAL 19 | #endif 20 | 21 | #include 22 | #include "zlib.h" 23 | #ifdef STDC 24 | # include 25 | # include 26 | # include 27 | #endif 28 | #include 29 | 30 | #ifdef _WIN32 31 | # include 32 | #endif 33 | 34 | #if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) 35 | # include 36 | #endif 37 | 38 | #ifdef WINAPI_FAMILY 39 | # define open _open 40 | # define read _read 41 | # define write _write 42 | # define close _close 43 | #endif 44 | 45 | #ifdef NO_DEFLATE /* for compatibility with old definition */ 46 | # define NO_GZCOMPRESS 47 | #endif 48 | 49 | #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) 50 | # ifndef HAVE_VSNPRINTF 51 | # define HAVE_VSNPRINTF 52 | # endif 53 | #endif 54 | 55 | #if defined(__CYGWIN__) 56 | # ifndef HAVE_VSNPRINTF 57 | # define HAVE_VSNPRINTF 58 | # endif 59 | #endif 60 | 61 | #if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410) 62 | # ifndef HAVE_VSNPRINTF 63 | # define HAVE_VSNPRINTF 64 | # endif 65 | #endif 66 | 67 | #ifndef HAVE_VSNPRINTF 68 | # ifdef MSDOS 69 | /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), 70 | but for now we just assume it doesn't. */ 71 | # define NO_vsnprintf 72 | # endif 73 | # ifdef __TURBOC__ 74 | # define NO_vsnprintf 75 | # endif 76 | # ifdef WIN32 77 | /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ 78 | # if !defined(vsnprintf) && !defined(NO_vsnprintf) 79 | # if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) 80 | # define vsnprintf _vsnprintf 81 | # endif 82 | # endif 83 | # endif 84 | # ifdef __SASC 85 | # define NO_vsnprintf 86 | # endif 87 | # ifdef VMS 88 | # define NO_vsnprintf 89 | # endif 90 | # ifdef __OS400__ 91 | # define NO_vsnprintf 92 | # endif 93 | # ifdef __MVS__ 94 | # define NO_vsnprintf 95 | # endif 96 | #endif 97 | 98 | /* unlike snprintf (which is required in C99, yet still not supported by 99 | Microsoft more than a decade later!), _snprintf does not guarantee null 100 | termination of the result -- however this is only used in gzlib.c where 101 | the result is assured to fit in the space provided */ 102 | #ifdef _MSC_VER 103 | # define snprintf _snprintf 104 | #endif 105 | 106 | #ifndef local 107 | # define local static 108 | #endif 109 | /* compile with -Dlocal if your debugger can't find static symbols */ 110 | 111 | /* gz* functions always use library allocation functions */ 112 | #ifndef STDC 113 | extern voidp malloc OF((uInt size)); 114 | extern void free OF((voidpf ptr)); 115 | #endif 116 | 117 | /* get errno and strerror definition */ 118 | #if defined UNDER_CE 119 | # include 120 | # define zstrerror() gz_strwinerror((DWORD)GetLastError()) 121 | #else 122 | # ifndef NO_STRERROR 123 | # include 124 | # define zstrerror() strerror(errno) 125 | # else 126 | # define zstrerror() "stdio error (consult errno)" 127 | # endif 128 | #endif 129 | 130 | /* provide prototypes for these when building zlib without LFS */ 131 | #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 132 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); 133 | ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); 134 | ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); 135 | ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); 136 | #endif 137 | 138 | /* default memLevel */ 139 | #if MAX_MEM_LEVEL >= 8 140 | # define DEF_MEM_LEVEL 8 141 | #else 142 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL 143 | #endif 144 | 145 | /* default i/o buffer size -- double this for output when reading (this and 146 | twice this must be able to fit in an unsigned type) */ 147 | #define GZBUFSIZE 8192 148 | 149 | /* gzip modes, also provide a little integrity check on the passed structure */ 150 | #define GZ_NONE 0 151 | #define GZ_READ 7247 152 | #define GZ_WRITE 31153 153 | #define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */ 154 | 155 | /* values for gz_state how */ 156 | #define LOOK 0 /* look for a gzip header */ 157 | #define COPY 1 /* copy input directly */ 158 | #define GZIP 2 /* decompress a gzip stream */ 159 | 160 | /* internal gzip file state data structure */ 161 | typedef struct { 162 | /* exposed contents for gzgetc() macro */ 163 | struct gzFile_s x; /* "x" for exposed */ 164 | /* x.have: number of bytes available at x.next */ 165 | /* x.next: next output data to deliver or write */ 166 | /* x.pos: current position in uncompressed data */ 167 | /* used for both reading and writing */ 168 | int mode; /* see gzip modes above */ 169 | int fd; /* file descriptor */ 170 | char *path; /* path or fd for error messages */ 171 | unsigned size; /* buffer size, zero if not allocated yet */ 172 | unsigned want; /* requested buffer size, default is GZBUFSIZE */ 173 | unsigned char *in; /* input buffer */ 174 | unsigned char *out; /* output buffer (double-sized when reading) */ 175 | int direct; /* 0 if processing gzip, 1 if transparent */ 176 | /* just for reading */ 177 | int how; /* 0: get header, 1: copy, 2: decompress */ 178 | z_off64_t start; /* where the gzip data started, for rewinding */ 179 | int eof; /* true if end of input file reached */ 180 | int past; /* true if read requested past end */ 181 | /* just for writing */ 182 | int level; /* compression level */ 183 | int strategy; /* compression strategy */ 184 | /* seek request */ 185 | z_off64_t skip; /* amount to skip (already rewound if backwards) */ 186 | int seek; /* true if seek request pending */ 187 | /* error information */ 188 | int err; /* error code */ 189 | char *msg; /* error message */ 190 | /* zlib inflate or deflate stream */ 191 | z_stream strm; /* stream structure in-place (not a pointer) */ 192 | } gz_state; 193 | typedef gz_state FAR *gz_statep; 194 | 195 | /* shared functions */ 196 | void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); 197 | #if defined UNDER_CE 198 | char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); 199 | #endif 200 | 201 | /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t 202 | value -- needed when comparing unsigned to z_off64_t, which is signed 203 | (possible z_off64_t types off_t, off64_t, and long are all signed) */ 204 | #ifdef INT_MAX 205 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) 206 | #else 207 | unsigned ZLIB_INTERNAL gz_intmax OF((void)); 208 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) 209 | #endif 210 | -------------------------------------------------------------------------------- /inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* INFLATE_FAST_MIN_INPUT: the minimum number of input bytes needed so that 12 | we can safely call inflate_fast() with only one up-front bounds check. One 13 | length/distance code pair (15 bits for the length code, 5 bits for length 14 | extra, 15 bits for the distance code, 13 bits for distance extra) requires 15 | reading up to 48 input bits (6 bytes). 16 | */ 17 | #define INFLATE_FAST_MIN_INPUT 6 18 | 19 | /* INFLATE_FAST_MIN_OUTPUT: the minimum number of output bytes needed so that 20 | we can safely call inflate_fast() with only one up-front bounds check. One 21 | length/distance code pair can output up to 258 bytes, which is the maximum 22 | length that can be coded. 23 | */ 24 | #define INFLATE_FAST_MIN_OUTPUT 258 25 | 26 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 27 | -------------------------------------------------------------------------------- /inffast_chunk.h: -------------------------------------------------------------------------------- 1 | /* inffast_chunk.h -- header to use inffast_chunk.c 2 | * 3 | * (C) 1995-2013 Jean-loup Gailly and Mark Adler 4 | * 5 | * This software is provided 'as-is', without any express or implied 6 | * warranty. In no event will the authors be held liable for any damages 7 | * arising from the use of this software. 8 | * 9 | * Permission is granted to anyone to use this software for any purpose, 10 | * including commercial applications, and to alter it and redistribute it 11 | * freely, subject to the following restrictions: 12 | * 13 | * 1. The origin of this software must not be misrepresented; you must not 14 | * claim that you wrote the original software. If you use this software 15 | * in a product, an acknowledgment in the product documentation would be 16 | * appreciated but is not required. 17 | * 2. Altered source versions must be plainly marked as such, and must not be 18 | * misrepresented as being the original software. 19 | * 3. This notice may not be removed or altered from any source distribution. 20 | * 21 | * Jean-loup Gailly Mark Adler 22 | * jloup@gzip.org madler@alumni.caltech.edu 23 | * 24 | * Copyright (C) 1995-2003, 2010 Mark Adler 25 | * Copyright (C) 2017 ARM, Inc. 26 | * For conditions of distribution and use, see copyright notice in zlib.h 27 | */ 28 | 29 | /* WARNING: this file should *not* be used by applications. It is 30 | part of the implementation of the compression library and is 31 | subject to change. Applications should only use zlib.h. 32 | */ 33 | 34 | #include "inffast.h" 35 | 36 | /* INFLATE_FAST_MIN_INPUT: the minimum number of input bytes needed so that 37 | we can safely call inflate_fast() with only one up-front bounds check. One 38 | length/distance code pair (15 bits for the length code, 5 bits for length 39 | extra, 15 bits for the distance code, 13 bits for distance extra) requires 40 | reading up to 48 input bits (6 bytes). 41 | 42 | For chunked decoding use a hopefully-pesimistic bound of two worst-case 43 | advances: 7 + 7, plus one 8-byte refill. 44 | */ 45 | #ifdef INFLATE_CHUNK_READ_64LE 46 | #undef INFLATE_FAST_MIN_INPUT 47 | #define INFLATE_FAST_MIN_INPUT 22 48 | #endif 49 | 50 | /* INFLATE_FAST_MIN_OUTPUT is usually 258, but we can copy two fast-path bytes 51 | as well */ 52 | #undef INFLATE_FAST_MIN_OUTPUT 53 | #define INFLATE_FAST_MIN_OUTPUT 260 54 | 55 | void ZLIB_INTERNAL inflate_fast_chunk_ OF((z_streamp strm, unsigned start)); 56 | -------------------------------------------------------------------------------- /inffixed.h: -------------------------------------------------------------------------------- 1 | /* inffixed.h -- table for decoding fixed codes 2 | * Generated automatically by makefixed(). 3 | */ 4 | 5 | /* WARNING: this file should *not* be used by applications. 6 | It is part of the implementation of this library and is 7 | subject to change. Applications should only use zlib.h. 8 | */ 9 | 10 | static const code lenfix[512] = { 11 | {7,96,0},{8,0,80},{8,0,16},{12,24,115},{9,23,31},{8,0,112},{8,0,48}, 12 | {9,0,192},{7,23,10},{8,0,96},{8,0,32},{9,0,160},{8,0,0},{8,0,128}, 13 | {8,0,64},{9,0,224},{7,23,6},{8,0,88},{8,0,24},{9,0,144},{10,23,59}, 14 | {8,0,120},{8,0,56},{9,0,208},{8,23,17},{8,0,104},{8,0,40},{9,0,176}, 15 | {8,0,8},{8,0,136},{8,0,72},{9,0,240},{7,23,4},{8,0,84},{8,0,20}, 16 | {13,24,227},{10,23,43},{8,0,116},{8,0,52},{9,0,200},{8,23,13},{8,0,100}, 17 | {8,0,36},{9,0,168},{8,0,4},{8,0,132},{8,0,68},{9,0,232},{7,23,8}, 18 | {8,0,92},{8,0,28},{9,0,152},{11,23,83},{8,0,124},{8,0,60},{9,0,216}, 19 | {9,23,23},{8,0,108},{8,0,44},{9,0,184},{8,0,12},{8,0,140},{8,0,76}, 20 | {9,0,248},{7,23,3},{8,0,82},{8,0,18},{13,24,163},{10,23,35},{8,0,114}, 21 | {8,0,50},{9,0,196},{8,23,11},{8,0,98},{8,0,34},{9,0,164},{8,0,2}, 22 | {8,0,130},{8,0,66},{9,0,228},{7,23,7},{8,0,90},{8,0,26},{9,0,148}, 23 | {11,23,67},{8,0,122},{8,0,58},{9,0,212},{9,23,19},{8,0,106},{8,0,42}, 24 | {9,0,180},{8,0,10},{8,0,138},{8,0,74},{9,0,244},{7,23,5},{8,0,86}, 25 | {8,0,22},{16,72,0},{10,23,51},{8,0,118},{8,0,54},{9,0,204},{8,23,15}, 26 | {8,0,102},{8,0,38},{9,0,172},{8,0,6},{8,0,134},{8,0,70},{9,0,236}, 27 | {7,23,9},{8,0,94},{8,0,30},{9,0,156},{11,23,99},{8,0,126},{8,0,62}, 28 | {9,0,220},{9,23,27},{8,0,110},{8,0,46},{9,0,188},{8,0,14},{8,0,142}, 29 | {8,0,78},{9,0,252},{7,96,0},{8,0,81},{8,0,17},{13,24,131},{9,23,31}, 30 | {8,0,113},{8,0,49},{9,0,194},{7,23,10},{8,0,97},{8,0,33},{9,0,162}, 31 | {8,0,1},{8,0,129},{8,0,65},{9,0,226},{7,23,6},{8,0,89},{8,0,25}, 32 | {9,0,146},{10,23,59},{8,0,121},{8,0,57},{9,0,210},{8,23,17},{8,0,105}, 33 | {8,0,41},{9,0,178},{8,0,9},{8,0,137},{8,0,73},{9,0,242},{7,23,4}, 34 | {8,0,85},{8,0,21},{8,24,258},{10,23,43},{8,0,117},{8,0,53},{9,0,202}, 35 | {8,23,13},{8,0,101},{8,0,37},{9,0,170},{8,0,5},{8,0,133},{8,0,69}, 36 | {9,0,234},{7,23,8},{8,0,93},{8,0,29},{9,0,154},{11,23,83},{8,0,125}, 37 | {8,0,61},{9,0,218},{9,23,23},{8,0,109},{8,0,45},{9,0,186},{8,0,13}, 38 | {8,0,141},{8,0,77},{9,0,250},{7,23,3},{8,0,83},{8,0,19},{13,24,195}, 39 | {10,23,35},{8,0,115},{8,0,51},{9,0,198},{8,23,11},{8,0,99},{8,0,35}, 40 | {9,0,166},{8,0,3},{8,0,131},{8,0,67},{9,0,230},{7,23,7},{8,0,91}, 41 | {8,0,27},{9,0,150},{11,23,67},{8,0,123},{8,0,59},{9,0,214},{9,23,19}, 42 | {8,0,107},{8,0,43},{9,0,182},{8,0,11},{8,0,139},{8,0,75},{9,0,246}, 43 | {7,23,5},{8,0,87},{8,0,23},{22,78,0},{10,23,51},{8,0,119},{8,0,55}, 44 | {9,0,206},{8,23,15},{8,0,103},{8,0,39},{9,0,174},{8,0,7},{8,0,135}, 45 | {8,0,71},{9,0,238},{7,23,9},{8,0,95},{8,0,31},{9,0,158},{11,23,99}, 46 | {8,0,127},{8,0,63},{9,0,222},{9,23,27},{8,0,111},{8,0,47},{9,0,190}, 47 | {8,0,15},{8,0,143},{8,0,79},{9,0,254},{7,96,0},{8,0,80},{8,0,16}, 48 | {12,24,115},{9,23,31},{8,0,112},{8,0,48},{9,0,193},{7,23,10},{8,0,96}, 49 | {8,0,32},{9,0,161},{8,0,0},{8,0,128},{8,0,64},{9,0,225},{7,23,6}, 50 | {8,0,88},{8,0,24},{9,0,145},{10,23,59},{8,0,120},{8,0,56},{9,0,209}, 51 | {8,23,17},{8,0,104},{8,0,40},{9,0,177},{8,0,8},{8,0,136},{8,0,72}, 52 | {9,0,241},{7,23,4},{8,0,84},{8,0,20},{13,24,227},{10,23,43},{8,0,116}, 53 | {8,0,52},{9,0,201},{8,23,13},{8,0,100},{8,0,36},{9,0,169},{8,0,4}, 54 | {8,0,132},{8,0,68},{9,0,233},{7,23,8},{8,0,92},{8,0,28},{9,0,153}, 55 | {11,23,83},{8,0,124},{8,0,60},{9,0,217},{9,23,23},{8,0,108},{8,0,44}, 56 | {9,0,185},{8,0,12},{8,0,140},{8,0,76},{9,0,249},{7,23,3},{8,0,82}, 57 | {8,0,18},{13,24,163},{10,23,35},{8,0,114},{8,0,50},{9,0,197},{8,23,11}, 58 | {8,0,98},{8,0,34},{9,0,165},{8,0,2},{8,0,130},{8,0,66},{9,0,229}, 59 | {7,23,7},{8,0,90},{8,0,26},{9,0,149},{11,23,67},{8,0,122},{8,0,58}, 60 | {9,0,213},{9,23,19},{8,0,106},{8,0,42},{9,0,181},{8,0,10},{8,0,138}, 61 | {8,0,74},{9,0,245},{7,23,5},{8,0,86},{8,0,22},{16,72,0},{10,23,51}, 62 | {8,0,118},{8,0,54},{9,0,205},{8,23,15},{8,0,102},{8,0,38},{9,0,173}, 63 | {8,0,6},{8,0,134},{8,0,70},{9,0,237},{7,23,9},{8,0,94},{8,0,30}, 64 | {9,0,157},{11,23,99},{8,0,126},{8,0,62},{9,0,221},{9,23,27},{8,0,110}, 65 | {8,0,46},{9,0,189},{8,0,14},{8,0,142},{8,0,78},{9,0,253},{7,96,0}, 66 | {8,0,81},{8,0,17},{13,24,131},{9,23,31},{8,0,113},{8,0,49},{9,0,195}, 67 | {7,23,10},{8,0,97},{8,0,33},{9,0,163},{8,0,1},{8,0,129},{8,0,65}, 68 | {9,0,227},{7,23,6},{8,0,89},{8,0,25},{9,0,147},{10,23,59},{8,0,121}, 69 | {8,0,57},{9,0,211},{8,23,17},{8,0,105},{8,0,41},{9,0,179},{8,0,9}, 70 | {8,0,137},{8,0,73},{9,0,243},{7,23,4},{8,0,85},{8,0,21},{8,24,258}, 71 | {10,23,43},{8,0,117},{8,0,53},{9,0,203},{8,23,13},{8,0,101},{8,0,37}, 72 | {9,0,171},{8,0,5},{8,0,133},{8,0,69},{9,0,235},{7,23,8},{8,0,93}, 73 | {8,0,29},{9,0,155},{11,23,83},{8,0,125},{8,0,61},{9,0,219},{9,23,23}, 74 | {8,0,109},{8,0,45},{9,0,187},{8,0,13},{8,0,141},{8,0,77},{9,0,251}, 75 | {7,23,3},{8,0,83},{8,0,19},{13,24,195},{10,23,35},{8,0,115},{8,0,51}, 76 | {9,0,199},{8,23,11},{8,0,99},{8,0,35},{9,0,167},{8,0,3},{8,0,131}, 77 | {8,0,67},{9,0,231},{7,23,7},{8,0,91},{8,0,27},{9,0,151},{11,23,67}, 78 | {8,0,123},{8,0,59},{9,0,215},{9,23,19},{8,0,107},{8,0,43},{9,0,183}, 79 | {8,0,11},{8,0,139},{8,0,75},{9,0,247},{7,23,5},{8,0,87},{8,0,23}, 80 | {22,78,0},{10,23,51},{8,0,119},{8,0,55},{9,0,207},{8,23,15},{8,0,103}, 81 | {8,0,39},{9,0,175},{8,0,7},{8,0,135},{8,0,71},{9,0,239},{7,23,9}, 82 | {8,0,95},{8,0,31},{9,0,159},{11,23,99},{8,0,127},{8,0,63},{9,0,223}, 83 | {9,23,27},{8,0,111},{8,0,47},{9,0,191},{8,0,15},{8,0,143},{8,0,79}, 84 | {9,0,255} 85 | }; 86 | 87 | static const code distfix[32] = { 88 | {5,21,1},{12,21,257},{8,21,17},{16,21,4097},{6,21,5},{14,21,1025}, 89 | {10,21,65},{18,21,16385},{5,21,3},{13,21,513},{9,21,33},{17,21,8193}, 90 | {7,21,9},{15,21,2049},{11,21,129},{5,64,0},{5,21,2},{12,21,385}, 91 | {8,21,25},{16,21,6145},{6,21,7},{14,21,1537},{10,21,97},{18,21,24577}, 92 | {5,21,4},{13,21,769},{9,21,49},{17,21,12289},{7,21,13},{15,21,3073}, 93 | {11,21,193},{5,64,0} 94 | }; 95 | -------------------------------------------------------------------------------- /inflate.h: -------------------------------------------------------------------------------- 1 | /* inflate.h -- internal inflate state definition 2 | * Copyright (C) 1995-2009 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* define NO_GZIP when compiling if you want to disable gzip header and 12 | trailer decoding by inflate(). NO_GZIP would be used to avoid linking in 13 | the crc code when it is not needed. For shared libraries, gzip decoding 14 | should be left enabled. */ 15 | #ifndef NO_GZIP 16 | # define GUNZIP 17 | #endif 18 | 19 | /* Possible inflate modes between inflate() calls */ 20 | typedef enum { 21 | HEAD = 16180, /* i: waiting for magic header */ 22 | FLAGS, /* i: waiting for method and flags (gzip) */ 23 | TIME, /* i: waiting for modification time (gzip) */ 24 | OS, /* i: waiting for extra flags and operating system (gzip) */ 25 | EXLEN, /* i: waiting for extra length (gzip) */ 26 | EXTRA, /* i: waiting for extra bytes (gzip) */ 27 | NAME, /* i: waiting for end of file name (gzip) */ 28 | COMMENT, /* i: waiting for end of comment (gzip) */ 29 | HCRC, /* i: waiting for header crc (gzip) */ 30 | DICTID, /* i: waiting for dictionary check value */ 31 | DICT, /* waiting for inflateSetDictionary() call */ 32 | TYPE, /* i: waiting for type bits, including last-flag bit */ 33 | TYPEDO, /* i: same, but skip check to exit inflate on new block */ 34 | STORED, /* i: waiting for stored size (length and complement) */ 35 | COPY_, /* i/o: same as COPY below, but only first time in */ 36 | COPY, /* i/o: waiting for input or output to copy stored block */ 37 | TABLE, /* i: waiting for dynamic block table lengths */ 38 | LENLENS, /* i: waiting for code length code lengths */ 39 | CODELENS, /* i: waiting for length/lit and distance code lengths */ 40 | LEN_, /* i: same as LEN below, but only first time in */ 41 | LEN, /* i: waiting for length/lit/eob code */ 42 | LENEXT, /* i: waiting for length extra bits */ 43 | DIST, /* i: waiting for distance code */ 44 | DISTEXT, /* i: waiting for distance extra bits */ 45 | MATCH, /* o: waiting for output space to copy string */ 46 | LIT, /* o: waiting for output space to write literal */ 47 | CHECK, /* i: waiting for 32-bit check value */ 48 | LENGTH, /* i: waiting for 32-bit length (gzip) */ 49 | DONE, /* finished check, done -- remain here until reset */ 50 | BAD, /* got a data error -- remain here until reset */ 51 | MEM, /* got an inflate() memory error -- remain here until reset */ 52 | SYNC /* looking for synchronization bytes to restart inflate() */ 53 | } inflate_mode; 54 | 55 | /* 56 | State transitions between above modes - 57 | 58 | (most modes can go to BAD or MEM on error -- not shown for clarity) 59 | 60 | Process header: 61 | HEAD -> (gzip) or (zlib) or (raw) 62 | (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> 63 | HCRC -> TYPE 64 | (zlib) -> DICTID or TYPE 65 | DICTID -> DICT -> TYPE 66 | (raw) -> TYPEDO 67 | Read deflate blocks: 68 | TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK 69 | STORED -> COPY_ -> COPY -> TYPE 70 | TABLE -> LENLENS -> CODELENS -> LEN_ 71 | LEN_ -> LEN 72 | Read deflate codes in fixed or dynamic block: 73 | LEN -> LENEXT or LIT or TYPE 74 | LENEXT -> DIST -> DISTEXT -> MATCH -> LEN 75 | LIT -> LEN 76 | Process trailer: 77 | CHECK -> LENGTH -> DONE 78 | */ 79 | 80 | /* state maintained between inflate() calls. Approximately 10K bytes. */ 81 | struct inflate_state { 82 | z_streamp strm; /* pointer back to this zlib stream */ 83 | inflate_mode mode; /* current inflate mode */ 84 | int last; /* true if processing last block */ 85 | int wrap; /* bit 0 true for zlib, bit 1 true for gzip, 86 | bit 2 true to validate check value */ 87 | int havedict; /* true if dictionary provided */ 88 | int flags; /* gzip header method and flags (0 if zlib) */ 89 | unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ 90 | unsigned long check; /* protected copy of check value */ 91 | unsigned long total; /* protected copy of output count */ 92 | gz_headerp head; /* where to save gzip header information */ 93 | /* sliding window */ 94 | unsigned wbits; /* log base 2 of requested window size */ 95 | unsigned wsize; /* window size or zero if not using window */ 96 | unsigned whave; /* valid bytes in the window */ 97 | unsigned wnext; /* window write index */ 98 | unsigned char FAR *window; /* allocated sliding window, if needed */ 99 | /* bit accumulator */ 100 | unsigned long hold; /* input bit accumulator */ 101 | unsigned bits; /* number of bits in "in" */ 102 | /* for string and stored block copying */ 103 | unsigned length; /* literal or length of data to copy */ 104 | unsigned offset; /* distance back to copy string from */ 105 | /* for table and code decoding */ 106 | unsigned extra; /* extra bits needed */ 107 | /* fixed and dynamic code tables */ 108 | code const FAR *lencode; /* starting table for length/literal codes */ 109 | code const FAR *distcode; /* starting table for distance codes */ 110 | unsigned lenbits; /* index bits for lencode */ 111 | unsigned distbits; /* index bits for distcode */ 112 | /* dynamic table building */ 113 | unsigned ncode; /* number of code length code lengths */ 114 | unsigned nlen; /* number of length code lengths */ 115 | unsigned ndist; /* number of distance code lengths */ 116 | unsigned have; /* number of code lengths in lens[] */ 117 | code FAR *next; /* next available space in codes[] */ 118 | unsigned short lens[320]; /* temporary storage for code lengths */ 119 | unsigned short work[288]; /* work area for code table building */ 120 | code codes[ENOUGH]; /* space for code tables */ 121 | int sane; /* if false, allow invalid distance too far */ 122 | int back; /* bits back of last unprocessed length/lit */ 123 | unsigned was; /* initial length of match */ 124 | }; 125 | -------------------------------------------------------------------------------- /inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char bits; /* bits in this part of the code */ 26 | unsigned char op; /* operation, extra bits, table bits */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of non-extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1924, which is the sum of 1332 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribtution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 10 15" for literal/length codes 44 | returns returns 1332, and "enough 30 9 15" for distance codes returns 592. 45 | The initial root table size (10 or 9) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 1332 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR * FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /msdos/Makefile.bor: -------------------------------------------------------------------------------- 1 | # Makefile for zlib 2 | # Borland C++ 3 | # Last updated: 15-Mar-2003 4 | 5 | # To use, do "make -fmakefile.bor" 6 | # To compile in small model, set below: MODEL=s 7 | 8 | # WARNING: the small model is supported but only for small values of 9 | # MAX_WBITS and MAX_MEM_LEVEL. For example: 10 | # -DMAX_WBITS=11 -DDEF_WBITS=11 -DMAX_MEM_LEVEL=3 11 | # If you wish to reduce the memory requirements (default 256K for big 12 | # objects plus a few K), you can add to the LOC macro below: 13 | # -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 14 | # See zconf.h for details about the memory requirements. 15 | 16 | # ------------ Turbo C++, Borland C++ ------------ 17 | 18 | # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) 19 | # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added 20 | # to the declaration of LOC here: 21 | LOC = $(LOCAL_ZLIB) 22 | 23 | # type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. 24 | CPU_TYP = 0 25 | 26 | # memory model: one of s, m, c, l (small, medium, compact, large) 27 | MODEL=l 28 | 29 | # replace bcc with tcc for Turbo C++ 1.0, with bcc32 for the 32 bit version 30 | CC=bcc 31 | LD=bcc 32 | AR=tlib 33 | 34 | # compiler flags 35 | # replace "-O2" by "-O -G -a -d" for Turbo C++ 1.0 36 | CFLAGS=-O2 -Z -m$(MODEL) $(LOC) 37 | 38 | LDFLAGS=-m$(MODEL) -f- 39 | 40 | 41 | # variables 42 | ZLIB_LIB = zlib_$(MODEL).lib 43 | 44 | OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj 45 | OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj 46 | OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj 47 | OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj 48 | 49 | 50 | # targets 51 | all: $(ZLIB_LIB) example.exe minigzip.exe 52 | 53 | .c.obj: 54 | $(CC) -c $(CFLAGS) $*.c 55 | 56 | adler32.obj: adler32.c zlib.h zconf.h 57 | 58 | compress.obj: compress.c zlib.h zconf.h 59 | 60 | crc32.obj: crc32.c zlib.h zconf.h crc32.h 61 | 62 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h 63 | 64 | gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h 65 | 66 | gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h 67 | 68 | gzread.obj: gzread.c zlib.h zconf.h gzguts.h 69 | 70 | gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h 71 | 72 | infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 73 | inffast.h inffixed.h 74 | 75 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 76 | inffast.h 77 | 78 | inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 79 | inffast.h inffixed.h 80 | 81 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h 82 | 83 | trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h 84 | 85 | uncompr.obj: uncompr.c zlib.h zconf.h 86 | 87 | zutil.obj: zutil.c zutil.h zlib.h zconf.h 88 | 89 | example.obj: test/example.c zlib.h zconf.h 90 | 91 | minigzip.obj: test/minigzip.c zlib.h zconf.h 92 | 93 | 94 | # the command line is cut to fit in the MS-DOS 128 byte limit: 95 | $(ZLIB_LIB): $(OBJ1) $(OBJ2) 96 | -del $(ZLIB_LIB) 97 | $(AR) $(ZLIB_LIB) $(OBJP1) 98 | $(AR) $(ZLIB_LIB) $(OBJP2) 99 | 100 | example.exe: example.obj $(ZLIB_LIB) 101 | $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) 102 | 103 | minigzip.exe: minigzip.obj $(ZLIB_LIB) 104 | $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) 105 | 106 | test: example.exe minigzip.exe 107 | example 108 | echo hello world | minigzip | minigzip -d 109 | 110 | clean: 111 | -del *.obj 112 | -del *.lib 113 | -del *.exe 114 | -del zlib_*.bak 115 | -del foo.gz 116 | -------------------------------------------------------------------------------- /msdos/Makefile.dj2: -------------------------------------------------------------------------------- 1 | # Makefile for zlib. Modified for djgpp v2.0 by F. J. Donahoe, 3/15/96. 2 | # Copyright (C) 1995-1998 Jean-loup Gailly. 3 | # For conditions of distribution and use, see copyright notice in zlib.h 4 | 5 | # To compile, or to compile and test, type: 6 | # 7 | # make -fmakefile.dj2; make test -fmakefile.dj2 8 | # 9 | # To install libz.a, zconf.h and zlib.h in the djgpp directories, type: 10 | # 11 | # make install -fmakefile.dj2 12 | # 13 | # after first defining LIBRARY_PATH and INCLUDE_PATH in djgpp.env as 14 | # in the sample below if the pattern of the DJGPP distribution is to 15 | # be followed. Remember that, while 'es around <=> are ignored in 16 | # makefiles, they are *not* in batch files or in djgpp.env. 17 | # - - - - - 18 | # [make] 19 | # INCLUDE_PATH=%\>;INCLUDE_PATH%%\DJDIR%\include 20 | # LIBRARY_PATH=%\>;LIBRARY_PATH%%\DJDIR%\lib 21 | # BUTT=-m486 22 | # - - - - - 23 | # Alternately, these variables may be defined below, overriding the values 24 | # in djgpp.env, as 25 | # INCLUDE_PATH=c:\usr\include 26 | # LIBRARY_PATH=c:\usr\lib 27 | 28 | CC=gcc 29 | 30 | #CFLAGS=-MMD -O 31 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 32 | #CFLAGS=-MMD -g -DDEBUG 33 | CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ 34 | -Wstrict-prototypes -Wmissing-prototypes 35 | 36 | # If cp.exe is available, replace "copy /Y" with "cp -fp" . 37 | CP=copy /Y 38 | # If gnu install.exe is available, replace $(CP) with ginstall. 39 | INSTALL=$(CP) 40 | # The default value of RM is "rm -f." If "rm.exe" is found, comment out: 41 | RM=del 42 | LDLIBS=-L. -lz 43 | LD=$(CC) -s -o 44 | LDSHARED=$(CC) 45 | 46 | INCL=zlib.h zconf.h 47 | LIBS=libz.a 48 | 49 | AR=ar rcs 50 | 51 | prefix=/usr/local 52 | exec_prefix = $(prefix) 53 | 54 | OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \ 55 | uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o 56 | 57 | OBJA = 58 | # to use the asm code: make OBJA=match.o 59 | 60 | TEST_OBJS = example.o minigzip.o 61 | 62 | all: example.exe minigzip.exe 63 | 64 | check: test 65 | test: all 66 | ./example 67 | echo hello world | .\minigzip | .\minigzip -d 68 | 69 | %.o : %.c 70 | $(CC) $(CFLAGS) -c $< -o $@ 71 | 72 | libz.a: $(OBJS) $(OBJA) 73 | $(AR) $@ $(OBJS) $(OBJA) 74 | 75 | %.exe : %.o $(LIBS) 76 | $(LD) $@ $< $(LDLIBS) 77 | 78 | # INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env . 79 | 80 | .PHONY : uninstall clean 81 | 82 | install: $(INCL) $(LIBS) 83 | -@if not exist $(INCLUDE_PATH)\nul mkdir $(INCLUDE_PATH) 84 | -@if not exist $(LIBRARY_PATH)\nul mkdir $(LIBRARY_PATH) 85 | $(INSTALL) zlib.h $(INCLUDE_PATH) 86 | $(INSTALL) zconf.h $(INCLUDE_PATH) 87 | $(INSTALL) libz.a $(LIBRARY_PATH) 88 | 89 | uninstall: 90 | $(RM) $(INCLUDE_PATH)\zlib.h 91 | $(RM) $(INCLUDE_PATH)\zconf.h 92 | $(RM) $(LIBRARY_PATH)\libz.a 93 | 94 | clean: 95 | $(RM) *.d 96 | $(RM) *.o 97 | $(RM) *.exe 98 | $(RM) libz.a 99 | $(RM) foo.gz 100 | 101 | DEPS := $(wildcard *.d) 102 | ifneq ($(DEPS),) 103 | include $(DEPS) 104 | endif 105 | -------------------------------------------------------------------------------- /msdos/Makefile.emx: -------------------------------------------------------------------------------- 1 | # Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98. 2 | # Copyright (C) 1995-1998 Jean-loup Gailly. 3 | # For conditions of distribution and use, see copyright notice in zlib.h 4 | 5 | # To compile, or to compile and test, type: 6 | # 7 | # make -fmakefile.emx; make test -fmakefile.emx 8 | # 9 | 10 | CC=gcc 11 | 12 | #CFLAGS=-MMD -O 13 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 14 | #CFLAGS=-MMD -g -DDEBUG 15 | CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ 16 | -Wstrict-prototypes -Wmissing-prototypes 17 | 18 | # If cp.exe is available, replace "copy /Y" with "cp -fp" . 19 | CP=copy /Y 20 | # If gnu install.exe is available, replace $(CP) with ginstall. 21 | INSTALL=$(CP) 22 | # The default value of RM is "rm -f." If "rm.exe" is found, comment out: 23 | RM=del 24 | LDLIBS=-L. -lzlib 25 | LD=$(CC) -s -o 26 | LDSHARED=$(CC) 27 | 28 | INCL=zlib.h zconf.h 29 | LIBS=zlib.a 30 | 31 | AR=ar rcs 32 | 33 | prefix=/usr/local 34 | exec_prefix = $(prefix) 35 | 36 | OBJS = adler32.o compress.o crc32.o gzclose.o gzlib.o gzread.o gzwrite.o \ 37 | uncompr.o deflate.o trees.o zutil.o inflate.o infback.o inftrees.o inffast.o 38 | 39 | TEST_OBJS = example.o minigzip.o 40 | 41 | all: example.exe minigzip.exe 42 | 43 | test: all 44 | ./example 45 | echo hello world | .\minigzip | .\minigzip -d 46 | 47 | %.o : %.c 48 | $(CC) $(CFLAGS) -c $< -o $@ 49 | 50 | zlib.a: $(OBJS) 51 | $(AR) $@ $(OBJS) 52 | 53 | %.exe : %.o $(LIBS) 54 | $(LD) $@ $< $(LDLIBS) 55 | 56 | 57 | .PHONY : clean 58 | 59 | clean: 60 | $(RM) *.d 61 | $(RM) *.o 62 | $(RM) *.exe 63 | $(RM) zlib.a 64 | $(RM) foo.gz 65 | 66 | DEPS := $(wildcard *.d) 67 | ifneq ($(DEPS),) 68 | include $(DEPS) 69 | endif 70 | -------------------------------------------------------------------------------- /msdos/Makefile.msc: -------------------------------------------------------------------------------- 1 | # Makefile for zlib 2 | # Microsoft C 5.1 or later 3 | # Last updated: 19-Mar-2003 4 | 5 | # To use, do "make makefile.msc" 6 | # To compile in small model, set below: MODEL=S 7 | 8 | # If you wish to reduce the memory requirements (default 256K for big 9 | # objects plus a few K), you can add to the LOC macro below: 10 | # -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 11 | # See zconf.h for details about the memory requirements. 12 | 13 | # ------------- Microsoft C 5.1 and later ------------- 14 | 15 | # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) 16 | # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added 17 | # to the declaration of LOC here: 18 | LOC = $(LOCAL_ZLIB) 19 | 20 | # Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. 21 | CPU_TYP = 0 22 | 23 | # Memory model: one of S, M, C, L (small, medium, compact, large) 24 | MODEL=L 25 | 26 | CC=cl 27 | CFLAGS=-nologo -A$(MODEL) -G$(CPU_TYP) -W3 -Oait -Gs $(LOC) 28 | #-Ox generates bad code with MSC 5.1 29 | LIB_CFLAGS=-Zl $(CFLAGS) 30 | 31 | LD=link 32 | LDFLAGS=/noi/e/st:0x1500/noe/farcall/packcode 33 | # "/farcall/packcode" are only useful for `large code' memory models 34 | # but should be a "no-op" for small code models. 35 | 36 | 37 | # variables 38 | ZLIB_LIB = zlib_$(MODEL).lib 39 | 40 | OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj 41 | OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj 42 | 43 | 44 | # targets 45 | all: $(ZLIB_LIB) example.exe minigzip.exe 46 | 47 | .c.obj: 48 | $(CC) -c $(LIB_CFLAGS) $*.c 49 | 50 | adler32.obj: adler32.c zlib.h zconf.h 51 | 52 | compress.obj: compress.c zlib.h zconf.h 53 | 54 | crc32.obj: crc32.c zlib.h zconf.h crc32.h 55 | 56 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h 57 | 58 | gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h 59 | 60 | gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h 61 | 62 | gzread.obj: gzread.c zlib.h zconf.h gzguts.h 63 | 64 | gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h 65 | 66 | infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 67 | inffast.h inffixed.h 68 | 69 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 70 | inffast.h 71 | 72 | inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 73 | inffast.h inffixed.h 74 | 75 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h 76 | 77 | trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h 78 | 79 | uncompr.obj: uncompr.c zlib.h zconf.h 80 | 81 | zutil.obj: zutil.c zutil.h zlib.h zconf.h 82 | 83 | example.obj: test/example.c zlib.h zconf.h 84 | $(CC) -c $(CFLAGS) $*.c 85 | 86 | minigzip.obj: test/minigzip.c zlib.h zconf.h 87 | $(CC) -c $(CFLAGS) $*.c 88 | 89 | 90 | # the command line is cut to fit in the MS-DOS 128 byte limit: 91 | $(ZLIB_LIB): $(OBJ1) $(OBJ2) 92 | if exist $(ZLIB_LIB) del $(ZLIB_LIB) 93 | lib $(ZLIB_LIB) $(OBJ1); 94 | lib $(ZLIB_LIB) $(OBJ2); 95 | 96 | example.exe: example.obj $(ZLIB_LIB) 97 | $(LD) $(LDFLAGS) example.obj,,,$(ZLIB_LIB); 98 | 99 | minigzip.exe: minigzip.obj $(ZLIB_LIB) 100 | $(LD) $(LDFLAGS) minigzip.obj,,,$(ZLIB_LIB); 101 | 102 | test: example.exe minigzip.exe 103 | example 104 | echo hello world | minigzip | minigzip -d 105 | 106 | clean: 107 | -del *.obj 108 | -del *.lib 109 | -del *.exe 110 | -del *.map 111 | -del zlib_*.bak 112 | -del foo.gz 113 | -------------------------------------------------------------------------------- /msdos/Makefile.tc: -------------------------------------------------------------------------------- 1 | # Makefile for zlib 2 | # Turbo C 2.01, Turbo C++ 1.01 3 | # Last updated: 15-Mar-2003 4 | 5 | # To use, do "make -fmakefile.tc" 6 | # To compile in small model, set below: MODEL=s 7 | 8 | # WARNING: the small model is supported but only for small values of 9 | # MAX_WBITS and MAX_MEM_LEVEL. For example: 10 | # -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 11 | # If you wish to reduce the memory requirements (default 256K for big 12 | # objects plus a few K), you can add to CFLAGS below: 13 | # -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 14 | # See zconf.h for details about the memory requirements. 15 | 16 | # ------------ Turbo C 2.01, Turbo C++ 1.01 ------------ 17 | MODEL=l 18 | CC=tcc 19 | LD=tcc 20 | AR=tlib 21 | # CFLAGS=-O2 -G -Z -m$(MODEL) -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 22 | CFLAGS=-O2 -G -Z -m$(MODEL) 23 | LDFLAGS=-m$(MODEL) -f- 24 | 25 | 26 | # variables 27 | ZLIB_LIB = zlib_$(MODEL).lib 28 | 29 | OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj 30 | OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj 31 | OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj 32 | OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj 33 | 34 | 35 | # targets 36 | all: $(ZLIB_LIB) example.exe minigzip.exe 37 | 38 | .c.obj: 39 | $(CC) -c $(CFLAGS) $*.c 40 | 41 | adler32.obj: adler32.c zlib.h zconf.h 42 | 43 | compress.obj: compress.c zlib.h zconf.h 44 | 45 | crc32.obj: crc32.c zlib.h zconf.h crc32.h 46 | 47 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h 48 | 49 | gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h 50 | 51 | gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h 52 | 53 | gzread.obj: gzread.c zlib.h zconf.h gzguts.h 54 | 55 | gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h 56 | 57 | infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 58 | inffast.h inffixed.h 59 | 60 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 61 | inffast.h 62 | 63 | inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 64 | inffast.h inffixed.h 65 | 66 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h 67 | 68 | trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h 69 | 70 | uncompr.obj: uncompr.c zlib.h zconf.h 71 | 72 | zutil.obj: zutil.c zutil.h zlib.h zconf.h 73 | 74 | example.obj: test/example.c zlib.h zconf.h 75 | 76 | minigzip.obj: test/minigzip.c zlib.h zconf.h 77 | 78 | 79 | # the command line is cut to fit in the MS-DOS 128 byte limit: 80 | $(ZLIB_LIB): $(OBJ1) $(OBJ2) 81 | -del $(ZLIB_LIB) 82 | $(AR) $(ZLIB_LIB) $(OBJP1) 83 | $(AR) $(ZLIB_LIB) $(OBJP2) 84 | 85 | example.exe: example.obj $(ZLIB_LIB) 86 | $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) 87 | 88 | minigzip.exe: minigzip.obj $(ZLIB_LIB) 89 | $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) 90 | 91 | test: example.exe minigzip.exe 92 | example 93 | echo hello world | minigzip | minigzip -d 94 | 95 | clean: 96 | -del *.obj 97 | -del *.lib 98 | -del *.exe 99 | -del zlib_*.bak 100 | -del foo.gz 101 | -------------------------------------------------------------------------------- /nintendods/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITARM)),) 6 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 7 | endif 8 | 9 | include $(DEVKITARM)/ds_rules 10 | 11 | #--------------------------------------------------------------------------------- 12 | # TARGET is the name of the output 13 | # BUILD is the directory where object files & intermediate files will be placed 14 | # SOURCES is a list of directories containing source code 15 | # DATA is a list of directories containing data files 16 | # INCLUDES is a list of directories containing header files 17 | #--------------------------------------------------------------------------------- 18 | TARGET := $(shell basename $(CURDIR)) 19 | BUILD := build 20 | SOURCES := ../../ 21 | DATA := data 22 | INCLUDES := include 23 | 24 | #--------------------------------------------------------------------------------- 25 | # options for code generation 26 | #--------------------------------------------------------------------------------- 27 | ARCH := -mthumb -mthumb-interwork 28 | 29 | CFLAGS := -Wall -O2\ 30 | -march=armv5te -mtune=arm946e-s \ 31 | -fomit-frame-pointer -ffast-math \ 32 | $(ARCH) 33 | 34 | CFLAGS += $(INCLUDE) -DARM9 35 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 36 | 37 | ASFLAGS := $(ARCH) -march=armv5te -mtune=arm946e-s 38 | LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) 39 | 40 | #--------------------------------------------------------------------------------- 41 | # list of directories containing libraries, this must be the top level containing 42 | # include and lib 43 | #--------------------------------------------------------------------------------- 44 | LIBDIRS := $(LIBNDS) 45 | 46 | #--------------------------------------------------------------------------------- 47 | # no real need to edit anything past this point unless you need to add additional 48 | # rules for different file extensions 49 | #--------------------------------------------------------------------------------- 50 | ifneq ($(BUILD),$(notdir $(CURDIR))) 51 | #--------------------------------------------------------------------------------- 52 | 53 | export OUTPUT := $(CURDIR)/lib/libz.a 54 | 55 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 56 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 57 | 58 | export DEPSDIR := $(CURDIR)/$(BUILD) 59 | 60 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 61 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 62 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 63 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 64 | 65 | #--------------------------------------------------------------------------------- 66 | # use CXX for linking C++ projects, CC for standard C 67 | #--------------------------------------------------------------------------------- 68 | ifeq ($(strip $(CPPFILES)),) 69 | #--------------------------------------------------------------------------------- 70 | export LD := $(CC) 71 | #--------------------------------------------------------------------------------- 72 | else 73 | #--------------------------------------------------------------------------------- 74 | export LD := $(CXX) 75 | #--------------------------------------------------------------------------------- 76 | endif 77 | #--------------------------------------------------------------------------------- 78 | 79 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 80 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 81 | 82 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 83 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 84 | -I$(CURDIR)/$(BUILD) 85 | 86 | .PHONY: $(BUILD) clean all 87 | 88 | #--------------------------------------------------------------------------------- 89 | all: $(BUILD) 90 | @[ -d $@ ] || mkdir -p include 91 | @cp ../../*.h include 92 | 93 | lib: 94 | @[ -d $@ ] || mkdir -p $@ 95 | 96 | $(BUILD): lib 97 | @[ -d $@ ] || mkdir -p $@ 98 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 99 | 100 | #--------------------------------------------------------------------------------- 101 | clean: 102 | @echo clean ... 103 | @rm -fr $(BUILD) lib 104 | 105 | #--------------------------------------------------------------------------------- 106 | else 107 | 108 | DEPENDS := $(OFILES:.o=.d) 109 | 110 | #--------------------------------------------------------------------------------- 111 | # main targets 112 | #--------------------------------------------------------------------------------- 113 | $(OUTPUT) : $(OFILES) 114 | 115 | #--------------------------------------------------------------------------------- 116 | %.bin.o : %.bin 117 | #--------------------------------------------------------------------------------- 118 | @echo $(notdir $<) 119 | @$(bin2o) 120 | 121 | 122 | -include $(DEPENDS) 123 | 124 | #--------------------------------------------------------------------------------------- 125 | endif 126 | #--------------------------------------------------------------------------------------- 127 | -------------------------------------------------------------------------------- /nintendods/README: -------------------------------------------------------------------------------- 1 | This Makefile requires devkitARM (http://www.devkitpro.org/category/devkitarm/) and works inside "contrib/nds". It is based on a devkitARM template. 2 | 3 | Eduardo Costa 4 | January 3, 2009 5 | 6 | -------------------------------------------------------------------------------- /old/Makefile.emx: -------------------------------------------------------------------------------- 1 | # Makefile for zlib. Modified for emx/rsxnt by Chr. Spieler, 6/16/98. 2 | # Copyright (C) 1995-1998 Jean-loup Gailly. 3 | # For conditions of distribution and use, see copyright notice in zlib.h 4 | 5 | # To compile, or to compile and test, type: 6 | # 7 | # make -fmakefile.emx; make test -fmakefile.emx 8 | # 9 | 10 | CC=gcc -Zwin32 11 | 12 | #CFLAGS=-MMD -O 13 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 14 | #CFLAGS=-MMD -g -DDEBUG 15 | CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ 16 | -Wstrict-prototypes -Wmissing-prototypes 17 | 18 | # If cp.exe is available, replace "copy /Y" with "cp -fp" . 19 | CP=copy /Y 20 | # If gnu install.exe is available, replace $(CP) with ginstall. 21 | INSTALL=$(CP) 22 | # The default value of RM is "rm -f." If "rm.exe" is found, comment out: 23 | RM=del 24 | LDLIBS=-L. -lzlib 25 | LD=$(CC) -s -o 26 | LDSHARED=$(CC) 27 | 28 | INCL=zlib.h zconf.h 29 | LIBS=zlib.a 30 | 31 | AR=ar rcs 32 | 33 | prefix=/usr/local 34 | exec_prefix = $(prefix) 35 | 36 | OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \ 37 | gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o 38 | 39 | TEST_OBJS = example.o minigzip.o 40 | 41 | all: example.exe minigzip.exe 42 | 43 | test: all 44 | ./example 45 | echo hello world | .\minigzip | .\minigzip -d 46 | 47 | %.o : %.c 48 | $(CC) $(CFLAGS) -c $< -o $@ 49 | 50 | zlib.a: $(OBJS) 51 | $(AR) $@ $(OBJS) 52 | 53 | %.exe : %.o $(LIBS) 54 | $(LD) $@ $< $(LDLIBS) 55 | 56 | 57 | .PHONY : clean 58 | 59 | clean: 60 | $(RM) *.d 61 | $(RM) *.o 62 | $(RM) *.exe 63 | $(RM) zlib.a 64 | $(RM) foo.gz 65 | 66 | DEPS := $(wildcard *.d) 67 | ifneq ($(DEPS),) 68 | include $(DEPS) 69 | endif 70 | -------------------------------------------------------------------------------- /old/Makefile.riscos: -------------------------------------------------------------------------------- 1 | # Project: zlib_1_03 2 | # Patched for zlib 1.1.2 rw@shadow.org.uk 19980430 3 | # test works out-of-the-box, installs `somewhere' on demand 4 | 5 | # Toolflags: 6 | CCflags = -c -depend !Depend -IC: -g -throwback -DRISCOS -fah 7 | C++flags = -c -depend !Depend -IC: -throwback 8 | Linkflags = -aif -c++ -o $@ 9 | ObjAsmflags = -throwback -NoCache -depend !Depend 10 | CMHGflags = 11 | LibFileflags = -c -l -o $@ 12 | Squeezeflags = -o $@ 13 | 14 | # change the line below to where _you_ want the library installed. 15 | libdest = lib:zlib 16 | 17 | # Final targets: 18 | @.lib: @.o.adler32 @.o.compress @.o.crc32 @.o.deflate @.o.gzio \ 19 | @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil @.o.trees \ 20 | @.o.uncompr @.o.zutil 21 | LibFile $(LibFileflags) @.o.adler32 @.o.compress @.o.crc32 @.o.deflate \ 22 | @.o.gzio @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil \ 23 | @.o.trees @.o.uncompr @.o.zutil 24 | test: @.minigzip @.example @.lib 25 | @copy @.lib @.libc A~C~DF~L~N~P~Q~RS~TV 26 | @echo running tests: hang on. 27 | @/@.minigzip -f -9 libc 28 | @/@.minigzip -d libc-gz 29 | @/@.minigzip -f -1 libc 30 | @/@.minigzip -d libc-gz 31 | @/@.minigzip -h -9 libc 32 | @/@.minigzip -d libc-gz 33 | @/@.minigzip -h -1 libc 34 | @/@.minigzip -d libc-gz 35 | @/@.minigzip -9 libc 36 | @/@.minigzip -d libc-gz 37 | @/@.minigzip -1 libc 38 | @/@.minigzip -d libc-gz 39 | @diff @.lib @.libc 40 | @echo that should have reported '@.lib and @.libc identical' if you have diff. 41 | @/@.example @.fred @.fred 42 | @echo that will have given lots of hello!'s. 43 | 44 | @.minigzip: @.o.minigzip @.lib C:o.Stubs 45 | Link $(Linkflags) @.o.minigzip @.lib C:o.Stubs 46 | @.example: @.o.example @.lib C:o.Stubs 47 | Link $(Linkflags) @.o.example @.lib C:o.Stubs 48 | 49 | install: @.lib 50 | cdir $(libdest) 51 | cdir $(libdest).h 52 | @copy @.h.zlib $(libdest).h.zlib A~C~DF~L~N~P~Q~RS~TV 53 | @copy @.h.zconf $(libdest).h.zconf A~C~DF~L~N~P~Q~RS~TV 54 | @copy @.lib $(libdest).lib A~C~DF~L~N~P~Q~RS~TV 55 | @echo okay, installed zlib in $(libdest) 56 | 57 | clean:; remove @.minigzip 58 | remove @.example 59 | remove @.libc 60 | -wipe @.o.* F~r~cV 61 | remove @.fred 62 | 63 | # User-editable dependencies: 64 | .c.o: 65 | cc $(ccflags) -o $@ $< 66 | 67 | # Static dependencies: 68 | 69 | # Dynamic dependencies: 70 | o.example: c.example 71 | o.example: h.zlib 72 | o.example: h.zconf 73 | o.minigzip: c.minigzip 74 | o.minigzip: h.zlib 75 | o.minigzip: h.zconf 76 | o.adler32: c.adler32 77 | o.adler32: h.zlib 78 | o.adler32: h.zconf 79 | o.compress: c.compress 80 | o.compress: h.zlib 81 | o.compress: h.zconf 82 | o.crc32: c.crc32 83 | o.crc32: h.zlib 84 | o.crc32: h.zconf 85 | o.deflate: c.deflate 86 | o.deflate: h.deflate 87 | o.deflate: h.zutil 88 | o.deflate: h.zlib 89 | o.deflate: h.zconf 90 | o.gzio: c.gzio 91 | o.gzio: h.zutil 92 | o.gzio: h.zlib 93 | o.gzio: h.zconf 94 | o.infblock: c.infblock 95 | o.infblock: h.zutil 96 | o.infblock: h.zlib 97 | o.infblock: h.zconf 98 | o.infblock: h.infblock 99 | o.infblock: h.inftrees 100 | o.infblock: h.infcodes 101 | o.infblock: h.infutil 102 | o.infcodes: c.infcodes 103 | o.infcodes: h.zutil 104 | o.infcodes: h.zlib 105 | o.infcodes: h.zconf 106 | o.infcodes: h.inftrees 107 | o.infcodes: h.infblock 108 | o.infcodes: h.infcodes 109 | o.infcodes: h.infutil 110 | o.infcodes: h.inffast 111 | o.inffast: c.inffast 112 | o.inffast: h.zutil 113 | o.inffast: h.zlib 114 | o.inffast: h.zconf 115 | o.inffast: h.inftrees 116 | o.inffast: h.infblock 117 | o.inffast: h.infcodes 118 | o.inffast: h.infutil 119 | o.inffast: h.inffast 120 | o.inflate: c.inflate 121 | o.inflate: h.zutil 122 | o.inflate: h.zlib 123 | o.inflate: h.zconf 124 | o.inflate: h.infblock 125 | o.inftrees: c.inftrees 126 | o.inftrees: h.zutil 127 | o.inftrees: h.zlib 128 | o.inftrees: h.zconf 129 | o.inftrees: h.inftrees 130 | o.inftrees: h.inffixed 131 | o.infutil: c.infutil 132 | o.infutil: h.zutil 133 | o.infutil: h.zlib 134 | o.infutil: h.zconf 135 | o.infutil: h.infblock 136 | o.infutil: h.inftrees 137 | o.infutil: h.infcodes 138 | o.infutil: h.infutil 139 | o.trees: c.trees 140 | o.trees: h.deflate 141 | o.trees: h.zutil 142 | o.trees: h.zlib 143 | o.trees: h.zconf 144 | o.trees: h.trees 145 | o.uncompr: c.uncompr 146 | o.uncompr: h.zlib 147 | o.uncompr: h.zconf 148 | o.zutil: c.zutil 149 | o.zutil: h.zutil 150 | o.zutil: h.zlib 151 | o.zutil: h.zconf 152 | -------------------------------------------------------------------------------- /old/README: -------------------------------------------------------------------------------- 1 | This directory contains files that have not been updated for zlib 1.2.x 2 | 3 | (Volunteers are encouraged to help clean this up. Thanks.) 4 | -------------------------------------------------------------------------------- /old/descrip.mms: -------------------------------------------------------------------------------- 1 | # descrip.mms: MMS description file for building zlib on VMS 2 | # written by Martin P.J. Zinser 3 | 4 | cc_defs = 5 | c_deb = 6 | 7 | .ifdef __DECC__ 8 | pref = /prefix=all 9 | .endif 10 | 11 | OBJS = adler32.obj, compress.obj, crc32.obj, gzio.obj, uncompr.obj,\ 12 | deflate.obj, trees.obj, zutil.obj, inflate.obj, infblock.obj,\ 13 | inftrees.obj, infcodes.obj, infutil.obj, inffast.obj 14 | 15 | CFLAGS= $(C_DEB) $(CC_DEFS) $(PREF) 16 | 17 | all : example.exe minigzip.exe 18 | @ write sys$output " Example applications available" 19 | libz.olb : libz.olb($(OBJS)) 20 | @ write sys$output " libz available" 21 | 22 | example.exe : example.obj libz.olb 23 | link example,libz.olb/lib 24 | 25 | minigzip.exe : minigzip.obj libz.olb 26 | link minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib 27 | 28 | clean : 29 | delete *.obj;*,libz.olb;* 30 | 31 | 32 | # Other dependencies. 33 | adler32.obj : zutil.h zlib.h zconf.h 34 | compress.obj : zlib.h zconf.h 35 | crc32.obj : zutil.h zlib.h zconf.h 36 | deflate.obj : deflate.h zutil.h zlib.h zconf.h 37 | example.obj : zlib.h zconf.h 38 | gzio.obj : zutil.h zlib.h zconf.h 39 | infblock.obj : zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h 40 | infcodes.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h inffast.h 41 | inffast.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h 42 | inflate.obj : zutil.h zlib.h zconf.h infblock.h 43 | inftrees.obj : zutil.h zlib.h zconf.h inftrees.h 44 | infutil.obj : zutil.h zlib.h zconf.h inftrees.h infutil.h 45 | minigzip.obj : zlib.h zconf.h 46 | trees.obj : deflate.h zutil.h zlib.h zconf.h 47 | uncompr.obj : zlib.h zconf.h 48 | zutil.obj : zutil.h zlib.h zconf.h 49 | -------------------------------------------------------------------------------- /old/os2/Makefile.os2: -------------------------------------------------------------------------------- 1 | # Makefile for zlib under OS/2 using GCC (PGCC) 2 | # For conditions of distribution and use, see copyright notice in zlib.h 3 | 4 | # To compile and test, type: 5 | # cp Makefile.os2 .. 6 | # cd .. 7 | # make -f Makefile.os2 test 8 | 9 | # This makefile will build a static library z.lib, a shared library 10 | # z.dll and a import library zdll.lib. You can use either z.lib or 11 | # zdll.lib by specifying either -lz or -lzdll on gcc's command line 12 | 13 | CC=gcc -Zomf -s 14 | 15 | CFLAGS=-O6 -Wall 16 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 17 | #CFLAGS=-g -DDEBUG 18 | #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ 19 | # -Wstrict-prototypes -Wmissing-prototypes 20 | 21 | #################### BUG WARNING: ##################### 22 | ## infcodes.c hits a bug in pgcc-1.0, so you have to use either 23 | ## -O# where # <= 4 or one of (-fno-ommit-frame-pointer or -fno-force-mem) 24 | ## This bug is reportedly fixed in pgcc >1.0, but this was not tested 25 | CFLAGS+=-fno-force-mem 26 | 27 | LDFLAGS=-s -L. -lzdll -Zcrtdll 28 | LDSHARED=$(CC) -s -Zomf -Zdll -Zcrtdll 29 | 30 | VER=1.1.0 31 | ZLIB=z.lib 32 | SHAREDLIB=z.dll 33 | SHAREDLIBIMP=zdll.lib 34 | LIBS=$(ZLIB) $(SHAREDLIB) $(SHAREDLIBIMP) 35 | 36 | AR=emxomfar cr 37 | IMPLIB=emximp 38 | RANLIB=echo 39 | TAR=tar 40 | SHELL=bash 41 | 42 | prefix=/usr/local 43 | exec_prefix = $(prefix) 44 | 45 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ 46 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o 47 | 48 | TEST_OBJS = example.o minigzip.o 49 | 50 | DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \ 51 | algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ 52 | nt/Makefile.nt nt/zlib.dnt contrib/README.contrib contrib/*.txt \ 53 | contrib/asm386/*.asm contrib/asm386/*.c \ 54 | contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \ 55 | contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \ 56 | contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 57 | 58 | all: example.exe minigzip.exe 59 | 60 | test: all 61 | @LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ 62 | echo hello world | ./minigzip | ./minigzip -d || \ 63 | echo ' *** minigzip test FAILED ***' ; \ 64 | if ./example; then \ 65 | echo ' *** zlib test OK ***'; \ 66 | else \ 67 | echo ' *** zlib test FAILED ***'; \ 68 | fi 69 | 70 | $(ZLIB): $(OBJS) 71 | $(AR) $@ $(OBJS) 72 | -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 73 | 74 | $(SHAREDLIB): $(OBJS) os2/z.def 75 | $(LDSHARED) -o $@ $^ 76 | 77 | $(SHAREDLIBIMP): os2/z.def 78 | $(IMPLIB) -o $@ $^ 79 | 80 | example.exe: example.o $(LIBS) 81 | $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) 82 | 83 | minigzip.exe: minigzip.o $(LIBS) 84 | $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) 85 | 86 | clean: 87 | rm -f *.o *~ example minigzip libz.a libz.so* foo.gz 88 | 89 | distclean: clean 90 | 91 | zip: 92 | mv Makefile Makefile~; cp -p Makefile.in Makefile 93 | rm -f test.c ztest*.c 94 | v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ 95 | zip -ul9 zlib$$v $(DISTFILES) 96 | mv Makefile~ Makefile 97 | 98 | dist: 99 | mv Makefile Makefile~; cp -p Makefile.in Makefile 100 | rm -f test.c ztest*.c 101 | d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ 102 | rm -f $$d.tar.gz; \ 103 | if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \ 104 | files=""; \ 105 | for f in $(DISTFILES); do files="$$files $$d/$$f"; done; \ 106 | cd ..; \ 107 | GZIP=-9 $(TAR) chofz $$d/$$d.tar.gz $$files; \ 108 | if test ! -d $$d; then rm -f $$d; fi 109 | mv Makefile~ Makefile 110 | 111 | tags: 112 | etags *.[ch] 113 | 114 | depend: 115 | makedepend -- $(CFLAGS) -- *.[ch] 116 | 117 | # DO NOT DELETE THIS LINE -- make depend depends on it. 118 | 119 | adler32.o: zlib.h zconf.h 120 | compress.o: zlib.h zconf.h 121 | crc32.o: zlib.h zconf.h 122 | deflate.o: deflate.h zutil.h zlib.h zconf.h 123 | example.o: zlib.h zconf.h 124 | gzio.o: zutil.h zlib.h zconf.h 125 | infblock.o: infblock.h inftrees.h infcodes.h infutil.h zutil.h zlib.h zconf.h 126 | infcodes.o: zutil.h zlib.h zconf.h 127 | infcodes.o: inftrees.h infblock.h infcodes.h infutil.h inffast.h 128 | inffast.o: zutil.h zlib.h zconf.h inftrees.h 129 | inffast.o: infblock.h infcodes.h infutil.h inffast.h 130 | inflate.o: zutil.h zlib.h zconf.h infblock.h 131 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h 132 | infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h 133 | minigzip.o: zlib.h zconf.h 134 | trees.o: deflate.h zutil.h zlib.h zconf.h trees.h 135 | uncompr.o: zlib.h zconf.h 136 | zutil.o: zutil.h zlib.h zconf.h 137 | -------------------------------------------------------------------------------- /old/os2/zlib.def: -------------------------------------------------------------------------------- 1 | ; 2 | ; Slightly modified version of ../nt/zlib.dnt :-) 3 | ; 4 | 5 | LIBRARY Z 6 | DESCRIPTION "Zlib compression library for OS/2" 7 | CODE PRELOAD MOVEABLE DISCARDABLE 8 | DATA PRELOAD MOVEABLE MULTIPLE 9 | 10 | EXPORTS 11 | adler32 12 | compress 13 | crc32 14 | deflate 15 | deflateCopy 16 | deflateEnd 17 | deflateInit2_ 18 | deflateInit_ 19 | deflateParams 20 | deflateReset 21 | deflateSetDictionary 22 | gzclose 23 | gzdopen 24 | gzerror 25 | gzflush 26 | gzopen 27 | gzread 28 | gzwrite 29 | inflate 30 | inflateEnd 31 | inflateInit2_ 32 | inflateInit_ 33 | inflateReset 34 | inflateSetDictionary 35 | inflateSync 36 | uncompress 37 | zlibVersion 38 | gzprintf 39 | gzputc 40 | gzgetc 41 | gzseek 42 | gzrewind 43 | gztell 44 | gzeof 45 | gzsetparams 46 | zError 47 | inflateSyncPoint 48 | get_crc_table 49 | compress2 50 | gzputs 51 | gzgets 52 | -------------------------------------------------------------------------------- /old/visual-basic.txt: -------------------------------------------------------------------------------- 1 | See below some functions declarations for Visual Basic. 2 | 3 | Frequently Asked Question: 4 | 5 | Q: Each time I use the compress function I get the -5 error (not enough 6 | room in the output buffer). 7 | 8 | A: Make sure that the length of the compressed buffer is passed by 9 | reference ("as any"), not by value ("as long"). Also check that 10 | before the call of compress this length is equal to the total size of 11 | the compressed buffer and not zero. 12 | 13 | 14 | From: "Jon Caruana" 15 | Subject: Re: How to port zlib declares to vb? 16 | Date: Mon, 28 Oct 1996 18:33:03 -0600 17 | 18 | Got the answer! (I haven't had time to check this but it's what I got, and 19 | looks correct): 20 | 21 | He has the following routines working: 22 | compress 23 | uncompress 24 | gzopen 25 | gzwrite 26 | gzread 27 | gzclose 28 | 29 | Declares follow: (Quoted from Carlos Rios , in Vb4 form) 30 | 31 | #If Win16 Then 'Use Win16 calls. 32 | Declare Function compress Lib "ZLIB.DLL" (ByVal compr As 33 | String, comprLen As Any, ByVal buf As String, ByVal buflen 34 | As Long) As Integer 35 | Declare Function uncompress Lib "ZLIB.DLL" (ByVal uncompr 36 | As String, uncomprLen As Any, ByVal compr As String, ByVal 37 | lcompr As Long) As Integer 38 | Declare Function gzopen Lib "ZLIB.DLL" (ByVal filePath As 39 | String, ByVal mode As String) As Long 40 | Declare Function gzread Lib "ZLIB.DLL" (ByVal file As 41 | Long, ByVal uncompr As String, ByVal uncomprLen As Integer) 42 | As Integer 43 | Declare Function gzwrite Lib "ZLIB.DLL" (ByVal file As 44 | Long, ByVal uncompr As String, ByVal uncomprLen As Integer) 45 | As Integer 46 | Declare Function gzclose Lib "ZLIB.DLL" (ByVal file As 47 | Long) As Integer 48 | #Else 49 | Declare Function compress Lib "ZLIB32.DLL" 50 | (ByVal compr As String, comprLen As Any, ByVal buf As 51 | String, ByVal buflen As Long) As Integer 52 | Declare Function uncompress Lib "ZLIB32.DLL" 53 | (ByVal uncompr As String, uncomprLen As Any, ByVal compr As 54 | String, ByVal lcompr As Long) As Long 55 | Declare Function gzopen Lib "ZLIB32.DLL" 56 | (ByVal file As String, ByVal mode As String) As Long 57 | Declare Function gzread Lib "ZLIB32.DLL" 58 | (ByVal file As Long, ByVal uncompr As String, ByVal 59 | uncomprLen As Long) As Long 60 | Declare Function gzwrite Lib "ZLIB32.DLL" 61 | (ByVal file As Long, ByVal uncompr As String, ByVal 62 | uncomprLen As Long) As Long 63 | Declare Function gzclose Lib "ZLIB32.DLL" 64 | (ByVal file As Long) As Long 65 | #End If 66 | 67 | -Jon Caruana 68 | jon-net@usa.net 69 | Microsoft Sitebuilder Network Level 1 Member - HTML Writer's Guild Member 70 | 71 | 72 | Here is another example from Michael that he 73 | says conforms to the VB guidelines, and that solves the problem of not 74 | knowing the uncompressed size by storing it at the end of the file: 75 | 76 | 'Calling the functions: 77 | 'bracket meaning: [optional] {Range of possible values} 78 | 'Call subCompressFile( [, , [level of compression {1..9}]]) 80 | 'Call subUncompressFile() 81 | 82 | Option Explicit 83 | Private lngpvtPcnSml As Long 'Stores value for 'lngPercentSmaller' 84 | Private Const SUCCESS As Long = 0 85 | Private Const strFilExt As String = ".cpr" 86 | Private Declare Function lngfncCpr Lib "zlib.dll" Alias "compress2" (ByRef 87 | dest As Any, ByRef destLen As Any, ByRef src As Any, ByVal srcLen As Long, 88 | ByVal level As Integer) As Long 89 | Private Declare Function lngfncUcp Lib "zlib.dll" Alias "uncompress" (ByRef 90 | dest As Any, ByRef destLen As Any, ByRef src As Any, ByVal srcLen As Long) 91 | As Long 92 | 93 | Public Sub subCompressFile(ByVal strargOriFilPth As String, Optional ByVal 94 | strargCprFilPth As String, Optional ByVal intLvl As Integer = 9) 95 | Dim strCprPth As String 96 | Dim lngOriSiz As Long 97 | Dim lngCprSiz As Long 98 | Dim bytaryOri() As Byte 99 | Dim bytaryCpr() As Byte 100 | lngOriSiz = FileLen(strargOriFilPth) 101 | ReDim bytaryOri(lngOriSiz - 1) 102 | Open strargOriFilPth For Binary Access Read As #1 103 | Get #1, , bytaryOri() 104 | Close #1 105 | strCprPth = IIf(strargCprFilPth = "", strargOriFilPth, strargCprFilPth) 106 | 'Select file path and name 107 | strCprPth = strCprPth & IIf(Right(strCprPth, Len(strFilExt)) = 108 | strFilExt, "", strFilExt) 'Add file extension if not exists 109 | lngCprSiz = (lngOriSiz * 1.01) + 12 'Compression needs temporary a bit 110 | more space then original file size 111 | ReDim bytaryCpr(lngCprSiz - 1) 112 | If lngfncCpr(bytaryCpr(0), lngCprSiz, bytaryOri(0), lngOriSiz, intLvl) = 113 | SUCCESS Then 114 | lngpvtPcnSml = (1# - (lngCprSiz / lngOriSiz)) * 100 115 | ReDim Preserve bytaryCpr(lngCprSiz - 1) 116 | Open strCprPth For Binary Access Write As #1 117 | Put #1, , bytaryCpr() 118 | Put #1, , lngOriSiz 'Add the the original size value to the end 119 | (last 4 bytes) 120 | Close #1 121 | Else 122 | MsgBox "Compression error" 123 | End If 124 | Erase bytaryCpr 125 | Erase bytaryOri 126 | End Sub 127 | 128 | Public Sub subUncompressFile(ByVal strargFilPth As String) 129 | Dim bytaryCpr() As Byte 130 | Dim bytaryOri() As Byte 131 | Dim lngOriSiz As Long 132 | Dim lngCprSiz As Long 133 | Dim strOriPth As String 134 | lngCprSiz = FileLen(strargFilPth) 135 | ReDim bytaryCpr(lngCprSiz - 1) 136 | Open strargFilPth For Binary Access Read As #1 137 | Get #1, , bytaryCpr() 138 | Close #1 139 | 'Read the original file size value: 140 | lngOriSiz = bytaryCpr(lngCprSiz - 1) * (2 ^ 24) _ 141 | + bytaryCpr(lngCprSiz - 2) * (2 ^ 16) _ 142 | + bytaryCpr(lngCprSiz - 3) * (2 ^ 8) _ 143 | + bytaryCpr(lngCprSiz - 4) 144 | ReDim Preserve bytaryCpr(lngCprSiz - 5) 'Cut of the original size value 145 | ReDim bytaryOri(lngOriSiz - 1) 146 | If lngfncUcp(bytaryOri(0), lngOriSiz, bytaryCpr(0), lngCprSiz) = SUCCESS 147 | Then 148 | strOriPth = Left(strargFilPth, Len(strargFilPth) - Len(strFilExt)) 149 | Open strOriPth For Binary Access Write As #1 150 | Put #1, , bytaryOri() 151 | Close #1 152 | Else 153 | MsgBox "Uncompression error" 154 | End If 155 | Erase bytaryCpr 156 | Erase bytaryOri 157 | End Sub 158 | Public Property Get lngPercentSmaller() As Long 159 | lngPercentSmaller = lngpvtPcnSml 160 | End Property 161 | -------------------------------------------------------------------------------- /qnx/package.qpg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | Library 38 | 39 | Medium 40 | 41 | 2.0 42 | 43 | 44 | 45 | zlib 46 | zlib 47 | alain.bonnefoy@icbt.com 48 | Public 49 | public 50 | www.gzip.org/zlib 51 | 52 | 53 | Jean-Loup Gailly,Mark Adler 54 | www.gzip.org/zlib 55 | 56 | zlib@gzip.org 57 | 58 | 59 | A massively spiffy yet delicately unobtrusive compression library. 60 | zlib is designed to be a free, general-purpose, legally unencumbered, lossless data compression library for use on virtually any computer hardware and operating system. 61 | http://www.gzip.org/zlib 62 | 63 | 64 | 65 | 66 | 1.2.8 67 | Medium 68 | Stable 69 | 70 | 71 | 72 | 73 | 74 | 75 | No License 76 | 77 | 78 | 79 | Software Development/Libraries and Extensions/C Libraries 80 | zlib,compression 81 | qnx6 82 | qnx6 83 | None 84 | Developer 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | Install 99 | Post 100 | No 101 | Ignore 102 | 103 | No 104 | Optional 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | InstallOver 118 | zlib 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | InstallOver 132 | zlib-dev 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /treebuild.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | zip compression library 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 117 | -------------------------------------------------------------------------------- /trees.h: -------------------------------------------------------------------------------- 1 | /* header created automatically with -DGEN_TREES_H */ 2 | 3 | local const ct_data static_ltree[L_CODES+2] = { 4 | {{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, 5 | {{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, 6 | {{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, 7 | {{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, 8 | {{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, 9 | {{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, 10 | {{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, 11 | {{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, 12 | {{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, 13 | {{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, 14 | {{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, 15 | {{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, 16 | {{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, 17 | {{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, 18 | {{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, 19 | {{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, 20 | {{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, 21 | {{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, 22 | {{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, 23 | {{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, 24 | {{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, 25 | {{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, 26 | {{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, 27 | {{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, 28 | {{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, 29 | {{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, 30 | {{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, 31 | {{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, 32 | {{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, 33 | {{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, 34 | {{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, 35 | {{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, 36 | {{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, 37 | {{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, 38 | {{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, 39 | {{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, 40 | {{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, 41 | {{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, 42 | {{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, 43 | {{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, 44 | {{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, 45 | {{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, 46 | {{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, 47 | {{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, 48 | {{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, 49 | {{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, 50 | {{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, 51 | {{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, 52 | {{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, 53 | {{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, 54 | {{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, 55 | {{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, 56 | {{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, 57 | {{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, 58 | {{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, 59 | {{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, 60 | {{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, 61 | {{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} 62 | }; 63 | 64 | local const ct_data static_dtree[D_CODES] = { 65 | {{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, 66 | {{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, 67 | {{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, 68 | {{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, 69 | {{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, 70 | {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} 71 | }; 72 | 73 | const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { 74 | 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 75 | 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 76 | 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 77 | 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 78 | 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 79 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 80 | 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 81 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 82 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 83 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 84 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 85 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 86 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 87 | 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 88 | 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 89 | 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 90 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 91 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 92 | 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 93 | 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 94 | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 95 | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 96 | 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 97 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 98 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 99 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 100 | }; 101 | 102 | const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { 103 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 104 | 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 105 | 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 106 | 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 107 | 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 108 | 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 109 | 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 110 | 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 111 | 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 112 | 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 113 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 114 | 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 115 | 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 116 | }; 117 | 118 | local const int base_length[LENGTH_CODES] = { 119 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 120 | 64, 80, 96, 112, 128, 160, 192, 224, 0 121 | }; 122 | 123 | local const int base_dist[D_CODES] = { 124 | 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 125 | 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 126 | 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 127 | }; 128 | 129 | -------------------------------------------------------------------------------- /uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | 20 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 21 | enough memory, Z_BUF_ERROR if there was not enough room in the output 22 | buffer, or Z_DATA_ERROR if the input data was corrupted. 23 | */ 24 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 25 | Bytef *dest; 26 | uLongf *destLen; 27 | const Bytef *source; 28 | uLong sourceLen; 29 | { 30 | z_stream stream; 31 | int err; 32 | 33 | stream.next_in = (z_const Bytef *)source; 34 | stream.avail_in = (uInt)sourceLen; 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | 45 | err = inflateInit(&stream); 46 | if (err != Z_OK) return err; 47 | 48 | err = inflate(&stream, Z_FINISH); 49 | if (err != Z_STREAM_END) { 50 | inflateEnd(&stream); 51 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 52 | return Z_DATA_ERROR; 53 | return err; 54 | } 55 | *destLen = stream.total_out; 56 | 57 | err = inflateEnd(&stream); 58 | return err; 59 | } 60 | -------------------------------------------------------------------------------- /watcom/watcom_f.mak: -------------------------------------------------------------------------------- 1 | # Makefile for zlib 2 | # OpenWatcom flat model 3 | # Last updated: 28-Dec-2005 4 | 5 | # To use, do "wmake -f watcom_f.mak" 6 | 7 | C_SOURCE = adler32.c compress.c crc32.c deflate.c & 8 | gzclose.c gzlib.c gzread.c gzwrite.c & 9 | infback.c inffast.c inflate.c inftrees.c & 10 | trees.c uncompr.c zutil.c 11 | 12 | OBJS = adler32.obj compress.obj crc32.obj deflate.obj & 13 | gzclose.obj gzlib.obj gzread.obj gzwrite.obj & 14 | infback.obj inffast.obj inflate.obj inftrees.obj & 15 | trees.obj uncompr.obj zutil.obj 16 | 17 | CC = wcc386 18 | LINKER = wcl386 19 | CFLAGS = -zq -mf -3r -fp3 -s -bt=dos -oilrtfm -fr=nul -wx 20 | ZLIB_LIB = zlib_f.lib 21 | 22 | .C.OBJ: 23 | $(CC) $(CFLAGS) $[@ 24 | 25 | all: $(ZLIB_LIB) example.exe minigzip.exe 26 | 27 | $(ZLIB_LIB): $(OBJS) 28 | wlib -b -c $(ZLIB_LIB) -+adler32.obj -+compress.obj -+crc32.obj 29 | wlib -b -c $(ZLIB_LIB) -+gzclose.obj -+gzlib.obj -+gzread.obj -+gzwrite.obj 30 | wlib -b -c $(ZLIB_LIB) -+deflate.obj -+infback.obj 31 | wlib -b -c $(ZLIB_LIB) -+inffast.obj -+inflate.obj -+inftrees.obj 32 | wlib -b -c $(ZLIB_LIB) -+trees.obj -+uncompr.obj -+zutil.obj 33 | 34 | example.exe: $(ZLIB_LIB) example.obj 35 | $(LINKER) -ldos32a -fe=example.exe example.obj $(ZLIB_LIB) 36 | 37 | minigzip.exe: $(ZLIB_LIB) minigzip.obj 38 | $(LINKER) -ldos32a -fe=minigzip.exe minigzip.obj $(ZLIB_LIB) 39 | 40 | clean: .SYMBOLIC 41 | del *.obj 42 | del $(ZLIB_LIB) 43 | @echo Cleaning done 44 | -------------------------------------------------------------------------------- /watcom/watcom_l.mak: -------------------------------------------------------------------------------- 1 | # Makefile for zlib 2 | # OpenWatcom large model 3 | # Last updated: 28-Dec-2005 4 | 5 | # To use, do "wmake -f watcom_l.mak" 6 | 7 | C_SOURCE = adler32.c compress.c crc32.c deflate.c & 8 | gzclose.c gzlib.c gzread.c gzwrite.c & 9 | infback.c inffast.c inflate.c inftrees.c & 10 | trees.c uncompr.c zutil.c 11 | 12 | OBJS = adler32.obj compress.obj crc32.obj deflate.obj & 13 | gzclose.obj gzlib.obj gzread.obj gzwrite.obj & 14 | infback.obj inffast.obj inflate.obj inftrees.obj & 15 | trees.obj uncompr.obj zutil.obj 16 | 17 | CC = wcc 18 | LINKER = wcl 19 | CFLAGS = -zq -ml -s -bt=dos -oilrtfm -fr=nul -wx 20 | ZLIB_LIB = zlib_l.lib 21 | 22 | .C.OBJ: 23 | $(CC) $(CFLAGS) $[@ 24 | 25 | all: $(ZLIB_LIB) example.exe minigzip.exe 26 | 27 | $(ZLIB_LIB): $(OBJS) 28 | wlib -b -c $(ZLIB_LIB) -+adler32.obj -+compress.obj -+crc32.obj 29 | wlib -b -c $(ZLIB_LIB) -+gzclose.obj -+gzlib.obj -+gzread.obj -+gzwrite.obj 30 | wlib -b -c $(ZLIB_LIB) -+deflate.obj -+infback.obj 31 | wlib -b -c $(ZLIB_LIB) -+inffast.obj -+inflate.obj -+inftrees.obj 32 | wlib -b -c $(ZLIB_LIB) -+trees.obj -+uncompr.obj -+zutil.obj 33 | 34 | example.exe: $(ZLIB_LIB) example.obj 35 | $(LINKER) -fe=example.exe example.obj $(ZLIB_LIB) 36 | 37 | minigzip.exe: $(ZLIB_LIB) minigzip.obj 38 | $(LINKER) -fe=minigzip.exe minigzip.obj $(ZLIB_LIB) 39 | 40 | clean: .SYMBOLIC 41 | del *.obj 42 | del $(ZLIB_LIB) 43 | @echo Cleaning done 44 | -------------------------------------------------------------------------------- /win32/Makefile.bor: -------------------------------------------------------------------------------- 1 | # Makefile for zlib 2 | # Borland C++ for Win32 3 | # 4 | # Usage: 5 | # make -f win32/Makefile.bor 6 | # make -f win32/Makefile.bor LOCAL_ZLIB=-DASMV OBJA=match.obj OBJPA=+match.obj 7 | 8 | # ------------ Borland C++ ------------ 9 | 10 | # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) 11 | # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or 12 | # added to the declaration of LOC here: 13 | LOC = $(LOCAL_ZLIB) 14 | 15 | CC = bcc32 16 | AS = bcc32 17 | LD = bcc32 18 | AR = tlib 19 | CFLAGS = -a -d -k- -O2 $(LOC) 20 | ASFLAGS = $(LOC) 21 | LDFLAGS = $(LOC) 22 | 23 | 24 | # variables 25 | ZLIB_LIB = zlib.lib 26 | 27 | OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj 28 | OBJ2 = gzwrite.obj infback.obj inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj 29 | #OBJA = 30 | OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzclose.obj+gzlib.obj+gzread.obj 31 | OBJP2 = +gzwrite.obj+infback.obj+inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj 32 | #OBJPA= 33 | 34 | 35 | # targets 36 | all: $(ZLIB_LIB) example.exe minigzip.exe 37 | 38 | .c.obj: 39 | $(CC) -c $(CFLAGS) $< 40 | 41 | .asm.obj: 42 | $(AS) -c $(ASFLAGS) $< 43 | 44 | adler32.obj: adler32.c zlib.h zconf.h 45 | 46 | compress.obj: compress.c zlib.h zconf.h 47 | 48 | crc32.obj: crc32.c zlib.h zconf.h crc32.h 49 | 50 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h 51 | 52 | gzclose.obj: gzclose.c zlib.h zconf.h gzguts.h 53 | 54 | gzlib.obj: gzlib.c zlib.h zconf.h gzguts.h 55 | 56 | gzread.obj: gzread.c zlib.h zconf.h gzguts.h 57 | 58 | gzwrite.obj: gzwrite.c zlib.h zconf.h gzguts.h 59 | 60 | infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 61 | inffast.h inffixed.h 62 | 63 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 64 | inffast.h 65 | 66 | inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ 67 | inffast.h inffixed.h 68 | 69 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h 70 | 71 | trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h 72 | 73 | uncompr.obj: uncompr.c zlib.h zconf.h 74 | 75 | zutil.obj: zutil.c zutil.h zlib.h zconf.h 76 | 77 | example.obj: test/example.c zlib.h zconf.h 78 | 79 | minigzip.obj: test/minigzip.c zlib.h zconf.h 80 | 81 | 82 | # For the sake of the old Borland make, 83 | # the command line is cut to fit in the MS-DOS 128 byte limit: 84 | $(ZLIB_LIB): $(OBJ1) $(OBJ2) $(OBJA) 85 | -del $(ZLIB_LIB) 86 | $(AR) $(ZLIB_LIB) $(OBJP1) 87 | $(AR) $(ZLIB_LIB) $(OBJP2) 88 | $(AR) $(ZLIB_LIB) $(OBJPA) 89 | 90 | 91 | # testing 92 | test: example.exe minigzip.exe 93 | example 94 | echo hello world | minigzip | minigzip -d 95 | 96 | example.exe: example.obj $(ZLIB_LIB) 97 | $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) 98 | 99 | minigzip.exe: minigzip.obj $(ZLIB_LIB) 100 | $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) 101 | 102 | 103 | # cleanup 104 | clean: 105 | -del $(ZLIB_LIB) 106 | -del *.obj 107 | -del *.exe 108 | -del *.tds 109 | -del zlib.bak 110 | -del foo.gz 111 | -------------------------------------------------------------------------------- /win32/Makefile.gcc: -------------------------------------------------------------------------------- 1 | # Makefile for zlib, derived from Makefile.dj2. 2 | # Modified for mingw32 by C. Spieler, 6/16/98. 3 | # Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003. 4 | # Last updated: Mar 2012. 5 | # Tested under Cygwin and MinGW. 6 | 7 | # Copyright (C) 1995-2003 Jean-loup Gailly. 8 | # For conditions of distribution and use, see copyright notice in zlib.h 9 | 10 | # To compile, or to compile and test, type from the top level zlib directory: 11 | # 12 | # make -fwin32/Makefile.gcc; make test testdll -fwin32/Makefile.gcc 13 | # 14 | # To use the asm code, type: 15 | # cp contrib/asm?86/match.S ./match.S 16 | # make LOC=-DASMV OBJA=match.o -fwin32/Makefile.gcc 17 | # 18 | # To install libz.a, zconf.h and zlib.h in the system directories, type: 19 | # 20 | # make install -fwin32/Makefile.gcc 21 | # 22 | # BINARY_PATH, INCLUDE_PATH and LIBRARY_PATH must be set. 23 | # 24 | # To install the shared lib, append SHARED_MODE=1 to the make command : 25 | # 26 | # make install -fwin32/Makefile.gcc SHARED_MODE=1 27 | 28 | # Note: 29 | # If the platform is *not* MinGW (e.g. it is Cygwin or UWIN), 30 | # the DLL name should be changed from "zlib1.dll". 31 | 32 | STATICLIB = libz.a 33 | SHAREDLIB = zlib1.dll 34 | IMPLIB = libz.dll.a 35 | 36 | # 37 | # Set to 1 if shared object needs to be installed 38 | # 39 | SHARED_MODE=0 40 | 41 | #LOC = -DASMV 42 | #LOC = -DDEBUG -g 43 | 44 | PREFIX = 45 | CC = $(PREFIX)gcc 46 | CFLAGS = $(LOC) -O3 -Wall 47 | 48 | AS = $(CC) 49 | ASFLAGS = $(LOC) -Wall 50 | 51 | LD = $(CC) 52 | LDFLAGS = $(LOC) 53 | 54 | AR = $(PREFIX)ar 55 | ARFLAGS = rcs 56 | 57 | RC = $(PREFIX)windres 58 | RCFLAGS = --define GCC_WINDRES 59 | 60 | STRIP = $(PREFIX)strip 61 | 62 | CP = cp -fp 63 | # If GNU install is available, replace $(CP) with install. 64 | INSTALL = $(CP) 65 | RM = rm -f 66 | 67 | prefix ?= /usr/local 68 | exec_prefix = $(prefix) 69 | 70 | OBJS = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \ 71 | gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o 72 | OBJA = 73 | 74 | all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example.exe minigzip.exe example_d.exe minigzip_d.exe 75 | 76 | test: example.exe minigzip.exe 77 | ./example 78 | echo hello world | ./minigzip | ./minigzip -d 79 | 80 | testdll: example_d.exe minigzip_d.exe 81 | ./example_d 82 | echo hello world | ./minigzip_d | ./minigzip_d -d 83 | 84 | .c.o: 85 | $(CC) $(CFLAGS) -c -o $@ $< 86 | 87 | .S.o: 88 | $(AS) $(ASFLAGS) -c -o $@ $< 89 | 90 | $(STATICLIB): $(OBJS) $(OBJA) 91 | $(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA) 92 | 93 | $(IMPLIB): $(SHAREDLIB) 94 | 95 | $(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o 96 | $(CC) -shared -Wl,--out-implib,$(IMPLIB) $(LDFLAGS) \ 97 | -o $@ win32/zlib.def $(OBJS) $(OBJA) zlibrc.o 98 | $(STRIP) $@ 99 | 100 | example.exe: example.o $(STATICLIB) 101 | $(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB) 102 | $(STRIP) $@ 103 | 104 | minigzip.exe: minigzip.o $(STATICLIB) 105 | $(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB) 106 | $(STRIP) $@ 107 | 108 | example_d.exe: example.o $(IMPLIB) 109 | $(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB) 110 | $(STRIP) $@ 111 | 112 | minigzip_d.exe: minigzip.o $(IMPLIB) 113 | $(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB) 114 | $(STRIP) $@ 115 | 116 | example.o: test/example.c zlib.h zconf.h 117 | $(CC) $(CFLAGS) -I. -c -o $@ test/example.c 118 | 119 | minigzip.o: test/minigzip.c zlib.h zconf.h 120 | $(CC) $(CFLAGS) -I. -c -o $@ test/minigzip.c 121 | 122 | zlibrc.o: win32/zlib1.rc 123 | $(RC) $(RCFLAGS) -o $@ win32/zlib1.rc 124 | 125 | .PHONY: install uninstall clean 126 | 127 | install: zlib.h zconf.h $(STATICLIB) $(IMPLIB) 128 | @if test -z "$(DESTDIR)$(INCLUDE_PATH)" -o -z "$(DESTDIR)$(LIBRARY_PATH)" -o -z "$(DESTDIR)$(BINARY_PATH)"; then \ 129 | echo INCLUDE_PATH, LIBRARY_PATH, and BINARY_PATH must be specified; \ 130 | exit 1; \ 131 | fi 132 | -@mkdir -p '$(DESTDIR)$(INCLUDE_PATH)' 133 | -@mkdir -p '$(DESTDIR)$(LIBRARY_PATH)' '$(DESTDIR)$(LIBRARY_PATH)'/pkgconfig 134 | -if [ "$(SHARED_MODE)" = "1" ]; then \ 135 | mkdir -p '$(DESTDIR)$(BINARY_PATH)'; \ 136 | $(INSTALL) $(SHAREDLIB) '$(DESTDIR)$(BINARY_PATH)'; \ 137 | $(INSTALL) $(IMPLIB) '$(DESTDIR)$(LIBRARY_PATH)'; \ 138 | fi 139 | -$(INSTALL) zlib.h '$(DESTDIR)$(INCLUDE_PATH)' 140 | -$(INSTALL) zconf.h '$(DESTDIR)$(INCLUDE_PATH)' 141 | -$(INSTALL) $(STATICLIB) '$(DESTDIR)$(LIBRARY_PATH)' 142 | sed \ 143 | -e 's|@prefix@|${prefix}|g' \ 144 | -e 's|@exec_prefix@|${exec_prefix}|g' \ 145 | -e 's|@libdir@|$(LIBRARY_PATH)|g' \ 146 | -e 's|@sharedlibdir@|$(LIBRARY_PATH)|g' \ 147 | -e 's|@includedir@|$(INCLUDE_PATH)|g' \ 148 | -e 's|@VERSION@|'`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' zlib.h`'|g' \ 149 | zlib.pc.in > '$(DESTDIR)$(LIBRARY_PATH)'/pkgconfig/zlib.pc 150 | 151 | uninstall: 152 | -if [ "$(SHARED_MODE)" = "1" ]; then \ 153 | $(RM) '$(DESTDIR)$(BINARY_PATH)'/$(SHAREDLIB); \ 154 | $(RM) '$(DESTDIR)$(LIBRARY_PATH)'/$(IMPLIB); \ 155 | fi 156 | -$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/zlib.h 157 | -$(RM) '$(DESTDIR)$(INCLUDE_PATH)'/zconf.h 158 | -$(RM) '$(DESTDIR)$(LIBRARY_PATH)'/$(STATICLIB) 159 | 160 | clean: 161 | -$(RM) $(STATICLIB) 162 | -$(RM) $(SHAREDLIB) 163 | -$(RM) $(IMPLIB) 164 | -$(RM) *.o 165 | -$(RM) *.exe 166 | -$(RM) foo.gz 167 | 168 | adler32.o: zlib.h zconf.h 169 | compress.o: zlib.h zconf.h 170 | crc32.o: crc32.h zlib.h zconf.h 171 | deflate.o: deflate.h zutil.h zlib.h zconf.h 172 | gzclose.o: zlib.h zconf.h gzguts.h 173 | gzlib.o: zlib.h zconf.h gzguts.h 174 | gzread.o: zlib.h zconf.h gzguts.h 175 | gzwrite.o: zlib.h zconf.h gzguts.h 176 | inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h 177 | inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h 178 | infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h 179 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h 180 | trees.o: deflate.h zutil.h zlib.h zconf.h trees.h 181 | uncompr.o: zlib.h zconf.h 182 | zutil.o: zutil.h zlib.h zconf.h 183 | -------------------------------------------------------------------------------- /win32/Makefile.msc: -------------------------------------------------------------------------------- 1 | # Makefile for zlib using Microsoft (Visual) C 2 | # zlib is copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler 3 | # 4 | # Usage: 5 | # nmake -f win32/Makefile.msc (standard build) 6 | # nmake -f win32/Makefile.msc LOC=-DFOO (nonstandard build) 7 | # nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" \ 8 | # OBJA="inffas32.obj match686.obj" (use ASM code, x86) 9 | # nmake -f win32/Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -I." \ 10 | # OBJA="inffasx64.obj gvmat64.obj inffas8664.obj" (use ASM code, x64) 11 | 12 | # The toplevel directory of the source tree. 13 | # 14 | TOP = . 15 | 16 | # optional build flags 17 | LOC = 18 | 19 | # variables 20 | STATICLIB = zlib.lib 21 | SHAREDLIB = zlib1.dll 22 | IMPLIB = zdll.lib 23 | 24 | CC = cl 25 | AS = ml 26 | LD = link 27 | AR = lib 28 | RC = rc 29 | CFLAGS = -nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC) 30 | WFLAGS = -DHAS_PCLMUL -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE 31 | ASFLAGS = -coff -Zi $(LOC) 32 | LDFLAGS = -nologo -debug -incremental:no -opt:ref 33 | ARFLAGS = -nologo 34 | RCFLAGS = /dWIN32 /r 35 | 36 | OBJS = adler32.obj compress.obj crc32_simd.obj crc32.obj deflate.obj gzclose.obj gzlib.obj gzread.obj \ 37 | gzwrite.obj infback.obj inflate.obj inftrees.obj inffast.obj trees.obj uncompr.obj zutil.obj 38 | OBJA = 39 | 40 | 41 | # targets 42 | all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \ 43 | example.exe minigzip.exe example_d.exe minigzip_d.exe 44 | 45 | $(STATICLIB): $(OBJS) $(OBJA) 46 | $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(OBJA) 47 | 48 | $(IMPLIB): $(SHAREDLIB) 49 | 50 | $(SHAREDLIB): $(TOP)/win32/zlib.def $(OBJS) $(OBJA) zlib1.res 51 | $(LD) $(LDFLAGS) -def:$(TOP)/win32/zlib.def -dll -implib:$(IMPLIB) \ 52 | -out:$@ -base:0x5A4C0000 $(OBJS) $(OBJA) zlib1.res 53 | if exist $@.manifest \ 54 | mt -nologo -manifest $@.manifest -outputresource:$@;2 55 | 56 | example.exe: example.obj $(STATICLIB) 57 | $(LD) $(LDFLAGS) example.obj $(STATICLIB) 58 | if exist $@.manifest \ 59 | mt -nologo -manifest $@.manifest -outputresource:$@;1 60 | 61 | minigzip.exe: minigzip.obj $(STATICLIB) 62 | $(LD) $(LDFLAGS) minigzip.obj $(STATICLIB) 63 | if exist $@.manifest \ 64 | mt -nologo -manifest $@.manifest -outputresource:$@;1 65 | 66 | example_d.exe: example.obj $(IMPLIB) 67 | $(LD) $(LDFLAGS) -out:$@ example.obj $(IMPLIB) 68 | if exist $@.manifest \ 69 | mt -nologo -manifest $@.manifest -outputresource:$@;1 70 | 71 | minigzip_d.exe: minigzip.obj $(IMPLIB) 72 | $(LD) $(LDFLAGS) -out:$@ minigzip.obj $(IMPLIB) 73 | if exist $@.manifest \ 74 | mt -nologo -manifest $@.manifest -outputresource:$@;1 75 | 76 | {$(TOP)}.c.obj: 77 | $(CC) -c $(WFLAGS) $(CFLAGS) $< 78 | 79 | {$(TOP)/test}.c.obj: 80 | $(CC) -c -I$(TOP) $(WFLAGS) $(CFLAGS) $< 81 | 82 | {$(TOP)/contrib/masmx64}.c.obj: 83 | $(CC) -c $(WFLAGS) $(CFLAGS) $< 84 | 85 | {$(TOP)/contrib/masmx64}.asm.obj: 86 | $(AS) -c $(ASFLAGS) $< 87 | 88 | {$(TOP)/contrib/masmx86}.asm.obj: 89 | $(AS) -c $(ASFLAGS) $< 90 | 91 | adler32.obj: $(TOP)/adler32.c $(TOP)/zlib.h $(TOP)/zconf.h 92 | 93 | compress.obj: $(TOP)/compress.c $(TOP)/zlib.h $(TOP)/zconf.h 94 | 95 | crc32.obj: $(TOP)/crc32.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/crc32.h 96 | 97 | deflate.obj: $(TOP)/deflate.c $(TOP)/deflate.h $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h 98 | 99 | gzclose.obj: $(TOP)/gzclose.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h 100 | 101 | gzlib.obj: $(TOP)/gzlib.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h 102 | 103 | gzread.obj: $(TOP)/gzread.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h 104 | 105 | gzwrite.obj: $(TOP)/gzwrite.c $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/gzguts.h 106 | 107 | infback.obj: $(TOP)/infback.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ 108 | $(TOP)/inffast.h $(TOP)/inffixed.h 109 | 110 | inffast.obj: $(TOP)/inffast.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ 111 | $(TOP)/inffast.h 112 | 113 | inflate.obj: $(TOP)/inflate.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h $(TOP)/inflate.h \ 114 | $(TOP)/inffast.h $(TOP)/inffixed.h 115 | 116 | inftrees.obj: $(TOP)/inftrees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/inftrees.h 117 | 118 | trees.obj: $(TOP)/trees.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h $(TOP)/deflate.h $(TOP)/trees.h 119 | 120 | uncompr.obj: $(TOP)/uncompr.c $(TOP)/zlib.h $(TOP)/zconf.h 121 | 122 | zutil.obj: $(TOP)/zutil.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h 123 | 124 | gvmat64.obj: $(TOP)/contrib\masmx64\gvmat64.asm 125 | 126 | inffasx64.obj: $(TOP)/contrib\masmx64\inffasx64.asm 127 | 128 | inffas8664.obj: $(TOP)/contrib\masmx64\inffas8664.c $(TOP)/zutil.h $(TOP)/zlib.h $(TOP)/zconf.h \ 129 | $(TOP)/inftrees.h $(TOP)/inflate.h $(TOP)/inffast.h 130 | 131 | inffas32.obj: $(TOP)/contrib\masmx86\inffas32.asm 132 | 133 | match686.obj: $(TOP)/contrib\masmx86\match686.asm 134 | 135 | example.obj: $(TOP)/test/example.c $(TOP)/zlib.h $(TOP)/zconf.h 136 | 137 | minigzip.obj: $(TOP)/test/minigzip.c $(TOP)/zlib.h $(TOP)/zconf.h 138 | 139 | zlib1.res: $(TOP)/win32/zlib1.rc 140 | $(RC) $(RCFLAGS) /fo$@ $(TOP)/win32/zlib1.rc 141 | 142 | # testing 143 | test: example.exe minigzip.exe 144 | example 145 | echo hello world | minigzip | minigzip -d 146 | 147 | testdll: example_d.exe minigzip_d.exe 148 | example_d 149 | echo hello world | minigzip_d | minigzip_d -d 150 | 151 | 152 | # cleanup 153 | clean: 154 | -del $(STATICLIB) 155 | -del $(SHAREDLIB) 156 | -del $(IMPLIB) 157 | -del *.obj 158 | -del *.res 159 | -del *.exp 160 | -del *.exe 161 | -del *.pdb 162 | -del *.manifest 163 | -del foo.gz 164 | -------------------------------------------------------------------------------- /win32/README-WIN32.txt: -------------------------------------------------------------------------------- 1 | ZLIB DATA COMPRESSION LIBRARY 2 | 3 | zlib 1.2.8 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 5 | (Request for Comments) 1950 to 1952 in the files 6 | http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) 7 | and rfc1952.txt (gzip format). 8 | 9 | All functions of the compression library are documented in the file zlib.h 10 | (volunteer to write man pages welcome, contact zlib@gzip.org). Two compiled 11 | examples are distributed in this package, example and minigzip. The example_d 12 | and minigzip_d flavors validate that the zlib1.dll file is working correctly. 13 | 14 | Questions about zlib should be sent to . The zlib home page 15 | is http://zlib.net/ . Before reporting a problem, please check this site to 16 | verify that you have the latest version of zlib; otherwise get the latest 17 | version and check whether the problem still exists or not. 18 | 19 | PLEASE read DLL_FAQ.txt, and the the zlib FAQ http://zlib.net/zlib_faq.html 20 | before asking for help. 21 | 22 | 23 | Manifest: 24 | 25 | The package zlib-1.2.8-win32-x86.zip will contain the following files: 26 | 27 | README-WIN32.txt This document 28 | ChangeLog Changes since previous zlib packages 29 | DLL_FAQ.txt Frequently asked questions about zlib1.dll 30 | zlib.3.pdf Documentation of this library in Adobe Acrobat format 31 | 32 | example.exe A statically-bound example (using zlib.lib, not the dll) 33 | example.pdb Symbolic information for debugging example.exe 34 | 35 | example_d.exe A zlib1.dll bound example (using zdll.lib) 36 | example_d.pdb Symbolic information for debugging example_d.exe 37 | 38 | minigzip.exe A statically-bound test program (using zlib.lib, not the dll) 39 | minigzip.pdb Symbolic information for debugging minigzip.exe 40 | 41 | minigzip_d.exe A zlib1.dll bound test program (using zdll.lib) 42 | minigzip_d.pdb Symbolic information for debugging minigzip_d.exe 43 | 44 | zlib.h Install these files into the compilers' INCLUDE path to 45 | zconf.h compile programs which use zlib.lib or zdll.lib 46 | 47 | zdll.lib Install these files into the compilers' LIB path if linking 48 | zdll.exp a compiled program to the zlib1.dll binary 49 | 50 | zlib.lib Install these files into the compilers' LIB path to link zlib 51 | zlib.pdb into compiled programs, without zlib1.dll runtime dependency 52 | (zlib.pdb provides debugging info to the compile time linker) 53 | 54 | zlib1.dll Install this binary shared library into the system PATH, or 55 | the program's runtime directory (where the .exe resides) 56 | zlib1.pdb Install in the same directory as zlib1.dll, in order to debug 57 | an application crash using WinDbg or similar tools. 58 | 59 | All .pdb files above are entirely optional, but are very useful to a developer 60 | attempting to diagnose program misbehavior or a crash. Many additional 61 | important files for developers can be found in the zlib127.zip source package 62 | available from http://zlib.net/ - review that package's README file for details. 63 | 64 | 65 | Acknowledgments: 66 | 67 | The deflate format used by zlib was defined by Phil Katz. The deflate and 68 | zlib specifications were written by L. Peter Deutsch. Thanks to all the 69 | people who reported problems and suggested various improvements in zlib; they 70 | are too numerous to cite here. 71 | 72 | 73 | Copyright notice: 74 | 75 | (C) 1995-2012 Jean-loup Gailly and Mark Adler 76 | 77 | This software is provided 'as-is', without any express or implied 78 | warranty. In no event will the authors be held liable for any damages 79 | arising from the use of this software. 80 | 81 | Permission is granted to anyone to use this software for any purpose, 82 | including commercial applications, and to alter it and redistribute it 83 | freely, subject to the following restrictions: 84 | 85 | 1. The origin of this software must not be misrepresented; you must not 86 | claim that you wrote the original software. If you use this software 87 | in a product, an acknowledgment in the product documentation would be 88 | appreciated but is not required. 89 | 2. Altered source versions must be plainly marked as such, and must not be 90 | misrepresented as being the original software. 91 | 3. This notice may not be removed or altered from any source distribution. 92 | 93 | Jean-loup Gailly Mark Adler 94 | jloup@gzip.org madler@alumni.caltech.edu 95 | 96 | If you use the zlib library in a product, we would appreciate *not* receiving 97 | lengthy legal documents to sign. The sources are provided for free but without 98 | warranty of any kind. The library has been entirely written by Jean-loup 99 | Gailly and Mark Adler; it does not include third-party code. 100 | 101 | If you redistribute modified sources, we would appreciate that you include in 102 | the file ChangeLog history information documenting your changes. Please read 103 | the FAQ for more information on the distribution of modified source versions. 104 | -------------------------------------------------------------------------------- /win32/VisualC.txt: -------------------------------------------------------------------------------- 1 | 2 | To build zlib using the Microsoft Visual C++ environment, 3 | use the appropriate project from the projects/ directory. 4 | -------------------------------------------------------------------------------- /win32/zlib.def: -------------------------------------------------------------------------------- 1 | ; zlib data compression library 2 | EXPORTS 3 | ; basic functions 4 | zlibVersion 5 | deflate 6 | deflateEnd 7 | inflate 8 | inflateEnd 9 | ; advanced functions 10 | deflateSetDictionary 11 | deflateCopy 12 | deflateReset 13 | deflateParams 14 | deflateTune 15 | deflateBound 16 | deflatePending 17 | deflatePrime 18 | deflateSetHeader 19 | inflateSetDictionary 20 | inflateGetDictionary 21 | inflateSync 22 | inflateCopy 23 | inflateReset 24 | inflateReset2 25 | inflatePrime 26 | inflateMark 27 | inflateGetHeader 28 | inflateBack 29 | inflateBackEnd 30 | zlibCompileFlags 31 | ; utility functions 32 | compress 33 | compress2 34 | compressBound 35 | uncompress 36 | gzopen 37 | gzdopen 38 | gzbuffer 39 | gzsetparams 40 | gzread 41 | gzwrite 42 | gzprintf 43 | gzvprintf 44 | gzputs 45 | gzgets 46 | gzputc 47 | gzgetc 48 | gzungetc 49 | gzflush 50 | gzseek 51 | gzrewind 52 | gztell 53 | gzoffset 54 | gzeof 55 | gzdirect 56 | gzclose 57 | gzclose_r 58 | gzclose_w 59 | gzerror 60 | gzclearerr 61 | ; large file functions 62 | gzopen64 63 | gzseek64 64 | gztell64 65 | gzoffset64 66 | adler32_combine64 67 | crc32_combine64 68 | ; checksum functions 69 | adler32 70 | crc32 71 | adler32_combine 72 | crc32_combine 73 | ; various hacks, don't look :) 74 | deflateInit_ 75 | deflateInit2_ 76 | inflateInit_ 77 | inflateInit2_ 78 | inflateBackInit_ 79 | gzgetc_ 80 | zError 81 | inflateSyncPoint 82 | get_crc_table 83 | inflateUndermine 84 | inflateResetKeep 85 | deflateResetKeep 86 | gzopen_w 87 | -------------------------------------------------------------------------------- /win32/zlib1.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "../zlib.h" 3 | 4 | #ifdef GCC_WINDRES 5 | VS_VERSION_INFO VERSIONINFO 6 | #else 7 | VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE 8 | #endif 9 | FILEVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0 10 | PRODUCTVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0 11 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 12 | #ifdef _DEBUG 13 | FILEFLAGS 1 14 | #else 15 | FILEFLAGS 0 16 | #endif 17 | FILEOS VOS__WINDOWS32 18 | FILETYPE VFT_DLL 19 | FILESUBTYPE 0 // not used 20 | BEGIN 21 | BLOCK "StringFileInfo" 22 | BEGIN 23 | BLOCK "040904E4" 24 | //language ID = U.S. English, char set = Windows, Multilingual 25 | BEGIN 26 | VALUE "FileDescription", "zlib data compression library\0" 27 | VALUE "FileVersion", ZLIB_VERSION "\0" 28 | VALUE "InternalName", "zlib1.dll\0" 29 | VALUE "LegalCopyright", "(C) 1995-2013 Jean-loup Gailly & Mark Adler\0" 30 | VALUE "OriginalFilename", "zlib1.dll\0" 31 | VALUE "ProductName", "zlib\0" 32 | VALUE "ProductVersion", ZLIB_VERSION "\0" 33 | VALUE "Comments", "For more information visit http://www.zlib.net/\0" 34 | END 35 | END 36 | BLOCK "VarFileInfo" 37 | BEGIN 38 | VALUE "Translation", 0x0409, 1252 39 | END 40 | END 41 | -------------------------------------------------------------------------------- /zlib.3: -------------------------------------------------------------------------------- 1 | .TH ZLIB 3 "28 Apr 2013" 2 | .SH NAME 3 | zlib \- compression/decompression library 4 | .SH SYNOPSIS 5 | [see 6 | .I zlib.h 7 | for full description] 8 | .SH DESCRIPTION 9 | The 10 | .I zlib 11 | library is a general purpose data compression library. 12 | The code is thread safe, assuming that the standard library functions 13 | used are thread safe, such as memory allocation routines. 14 | It provides in-memory compression and decompression functions, 15 | including integrity checks of the uncompressed data. 16 | This version of the library supports only one compression method (deflation) 17 | but other algorithms may be added later 18 | with the same stream interface. 19 | .LP 20 | Compression can be done in a single step if the buffers are large enough 21 | or can be done by repeated calls of the compression function. 22 | In the latter case, 23 | the application must provide more input and/or consume the output 24 | (providing more output space) before each call. 25 | .LP 26 | The library also supports reading and writing files in 27 | .IR gzip (1) 28 | (.gz) format 29 | with an interface similar to that of stdio. 30 | .LP 31 | The library does not install any signal handler. 32 | The decoder checks the consistency of the compressed data, 33 | so the library should never crash even in the case of corrupted input. 34 | .LP 35 | All functions of the compression library are documented in the file 36 | .IR zlib.h . 37 | The distribution source includes examples of use of the library 38 | in the files 39 | .I test/example.c 40 | and 41 | .IR test/minigzip.c, 42 | as well as other examples in the 43 | .IR examples/ 44 | directory. 45 | .LP 46 | Changes to this version are documented in the file 47 | .I ChangeLog 48 | that accompanies the source. 49 | .LP 50 | .I zlib 51 | is available in Java using the java.util.zip package: 52 | .IP 53 | http://java.sun.com/developer/technicalArticles/Programming/compression/ 54 | .LP 55 | A Perl interface to 56 | .IR zlib , 57 | written by Paul Marquess (pmqs@cpan.org), 58 | is available at CPAN (Comprehensive Perl Archive Network) sites, 59 | including: 60 | .IP 61 | http://search.cpan.org/~pmqs/IO-Compress-Zlib/ 62 | .LP 63 | A Python interface to 64 | .IR zlib , 65 | written by A.M. Kuchling (amk@magnet.com), 66 | is available in Python 1.5 and later versions: 67 | .IP 68 | http://docs.python.org/library/zlib.html 69 | .LP 70 | .I zlib 71 | is built into 72 | .IR tcl: 73 | .IP 74 | http://wiki.tcl.tk/4610 75 | .LP 76 | An experimental package to read and write files in .zip format, 77 | written on top of 78 | .I zlib 79 | by Gilles Vollant (info@winimage.com), 80 | is available at: 81 | .IP 82 | http://www.winimage.com/zLibDll/minizip.html 83 | and also in the 84 | .I contrib/minizip 85 | directory of the main 86 | .I zlib 87 | source distribution. 88 | .SH "SEE ALSO" 89 | The 90 | .I zlib 91 | web site can be found at: 92 | .IP 93 | http://zlib.net/ 94 | .LP 95 | The data format used by the zlib library is described by RFC 96 | (Request for Comments) 1950 to 1952 in the files: 97 | .IP 98 | http://tools.ietf.org/html/rfc1950 (for the zlib header and trailer format) 99 | .br 100 | http://tools.ietf.org/html/rfc1951 (for the deflate compressed data format) 101 | .br 102 | http://tools.ietf.org/html/rfc1952 (for the gzip header and trailer format) 103 | .LP 104 | Mark Nelson wrote an article about 105 | .I zlib 106 | for the Jan. 1997 issue of Dr. Dobb's Journal; 107 | a copy of the article is available at: 108 | .IP 109 | http://marknelson.us/1997/01/01/zlib-engine/ 110 | .SH "REPORTING PROBLEMS" 111 | Before reporting a problem, 112 | please check the 113 | .I zlib 114 | web site to verify that you have the latest version of 115 | .IR zlib ; 116 | otherwise, 117 | obtain the latest version and see if the problem still exists. 118 | Please read the 119 | .I zlib 120 | FAQ at: 121 | .IP 122 | http://zlib.net/zlib_faq.html 123 | .LP 124 | before asking for help. 125 | Send questions and/or comments to zlib@gzip.org, 126 | or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). 127 | .SH AUTHORS 128 | Version 1.2.8 129 | Copyright (C) 1995-2013 Jean-loup Gailly (jloup@gzip.org) 130 | and Mark Adler (madler@alumni.caltech.edu). 131 | .LP 132 | This software is provided "as-is," 133 | without any express or implied warranty. 134 | In no event will the authors be held liable for any damages 135 | arising from the use of this software. 136 | See the distribution directory with respect to requirements 137 | governing redistribution. 138 | The deflate format used by 139 | .I zlib 140 | was defined by Phil Katz. 141 | The deflate and 142 | .I zlib 143 | specifications were written by L. Peter Deutsch. 144 | Thanks to all the people who reported problems and suggested various 145 | improvements in 146 | .IR zlib ; 147 | who are too numerous to cite here. 148 | .LP 149 | UNIX manual page by R. P. C. Rodgers, 150 | U.S. National Library of Medicine (rodgers@nlm.nih.gov). 151 | .\" end of man page 152 | -------------------------------------------------------------------------------- /zlib.3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dougallj/zlib-dougallj/35ab598c216c4a985c108d7b425bc8e24d87419b/zlib.3.pdf -------------------------------------------------------------------------------- /zlib.map: -------------------------------------------------------------------------------- 1 | ZLIB_1.2.0 { 2 | global: 3 | compressBound; 4 | deflateBound; 5 | inflateBack; 6 | inflateBackEnd; 7 | inflateBackInit_; 8 | inflateCopy; 9 | local: 10 | deflate_copyright; 11 | inflate_copyright; 12 | inflate_fast; 13 | inflate_table; 14 | zcalloc; 15 | zcfree; 16 | z_errmsg; 17 | gz_error; 18 | gz_intmax; 19 | _*; 20 | }; 21 | 22 | ZLIB_1.2.0.2 { 23 | gzclearerr; 24 | gzungetc; 25 | zlibCompileFlags; 26 | } ZLIB_1.2.0; 27 | 28 | ZLIB_1.2.0.8 { 29 | deflatePrime; 30 | } ZLIB_1.2.0.2; 31 | 32 | ZLIB_1.2.2 { 33 | adler32_combine; 34 | crc32_combine; 35 | deflateSetHeader; 36 | inflateGetHeader; 37 | } ZLIB_1.2.0.8; 38 | 39 | ZLIB_1.2.2.3 { 40 | deflateTune; 41 | gzdirect; 42 | } ZLIB_1.2.2; 43 | 44 | ZLIB_1.2.2.4 { 45 | inflatePrime; 46 | } ZLIB_1.2.2.3; 47 | 48 | ZLIB_1.2.3.3 { 49 | adler32_combine64; 50 | crc32_combine64; 51 | gzopen64; 52 | gzseek64; 53 | gztell64; 54 | inflateUndermine; 55 | } ZLIB_1.2.2.4; 56 | 57 | ZLIB_1.2.3.4 { 58 | inflateReset2; 59 | inflateMark; 60 | } ZLIB_1.2.3.3; 61 | 62 | ZLIB_1.2.3.5 { 63 | gzbuffer; 64 | gzoffset; 65 | gzoffset64; 66 | gzclose_r; 67 | gzclose_w; 68 | } ZLIB_1.2.3.4; 69 | 70 | ZLIB_1.2.5.1 { 71 | deflatePending; 72 | } ZLIB_1.2.3.5; 73 | 74 | ZLIB_1.2.5.2 { 75 | deflateResetKeep; 76 | gzgetc_; 77 | inflateResetKeep; 78 | } ZLIB_1.2.5.1; 79 | 80 | ZLIB_1.2.7.1 { 81 | inflateGetDictionary; 82 | gzvprintf; 83 | } ZLIB_1.2.5.2; 84 | -------------------------------------------------------------------------------- /zlib.pc.cmakein: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=@CMAKE_INSTALL_PREFIX@/bin 3 | libdir=@CMAKE_INSTALL_PREFIX@/lib 4 | sharedlibdir=@CMAKE_INSTALL_PREFIX@/lib 5 | includedir=@CMAKE_INSTALL_PREFIX@/include 6 | 7 | Name: zlib 8 | Description: zlib compression library 9 | Version: @ZLIB_VERSION@ 10 | 11 | Requires: 12 | Libs: -L${libdir} -L${sharedlibdir} -lz 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /zlib.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | sharedlibdir=@sharedlibdir@ 5 | includedir=@includedir@ 6 | 7 | Name: zlib 8 | Description: zlib compression library 9 | Version: @VERSION@ 10 | 11 | Requires: 12 | Libs: -L${libdir} -L${sharedlibdir} -lz 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /zlib2ansi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | # Transform K&R C function definitions into ANSI equivalent. 4 | # 5 | # Author: Paul Marquess 6 | # Version: 1.0 7 | # Date: 3 October 2006 8 | 9 | # TODO 10 | # 11 | # Asumes no function pointer parameters. unless they are typedefed. 12 | # Assumes no literal strings that look like function definitions 13 | # Assumes functions start at the beginning of a line 14 | 15 | use strict; 16 | use warnings; 17 | 18 | local $/; 19 | $_ = <>; 20 | 21 | my $sp = qr{ \s* (?: /\* .*? \*/ )? \s* }x; # assume no nested comments 22 | 23 | my $d1 = qr{ $sp (?: [\w\*\s]+ $sp)* $sp \w+ $sp [\[\]\s]* $sp }x ; 24 | my $decl = qr{ $sp (?: \w+ $sp )+ $d1 }xo ; 25 | my $dList = qr{ $sp $decl (?: $sp , $d1 )* $sp ; $sp }xo ; 26 | 27 | 28 | while (s/^ 29 | ( # Start $1 30 | ( # Start $2 31 | .*? # Minimal eat content 32 | ( ^ \w [\w\s\*]+ ) # $3 -- function name 33 | \s* # optional whitespace 34 | ) # $2 - Matched up to before parameter list 35 | 36 | \( \s* # Literal "(" + optional whitespace 37 | ( [^\)]+ ) # $4 - one or more anythings except ")" 38 | \s* \) # optional whitespace surrounding a Literal ")" 39 | 40 | ( (?: $dList )+ ) # $5 41 | 42 | $sp ^ { # literal "{" at start of line 43 | ) # Remember to $1 44 | //xsom 45 | ) 46 | { 47 | my $all = $1 ; 48 | my $prefix = $2; 49 | my $param_list = $4 ; 50 | my $params = $5; 51 | 52 | StripComments($params); 53 | StripComments($param_list); 54 | $param_list =~ s/^\s+//; 55 | $param_list =~ s/\s+$//; 56 | 57 | my $i = 0 ; 58 | my %pList = map { $_ => $i++ } 59 | split /\s*,\s*/, $param_list; 60 | my $pMatch = '(\b' . join('|', keys %pList) . '\b)\W*$' ; 61 | 62 | my @params = split /\s*;\s*/, $params; 63 | my @outParams = (); 64 | foreach my $p (@params) 65 | { 66 | if ($p =~ /,/) 67 | { 68 | my @bits = split /\s*,\s*/, $p; 69 | my $first = shift @bits; 70 | $first =~ s/^\s*//; 71 | push @outParams, $first; 72 | $first =~ /^(\w+\s*)/; 73 | my $type = $1 ; 74 | push @outParams, map { $type . $_ } @bits; 75 | } 76 | else 77 | { 78 | $p =~ s/^\s+//; 79 | push @outParams, $p; 80 | } 81 | } 82 | 83 | 84 | my %tmp = map { /$pMatch/; $_ => $pList{$1} } 85 | @outParams ; 86 | 87 | @outParams = map { " $_" } 88 | sort { $tmp{$a} <=> $tmp{$b} } 89 | @outParams ; 90 | 91 | print $prefix ; 92 | print "(\n" . join(",\n", @outParams) . ")\n"; 93 | print "{" ; 94 | 95 | } 96 | 97 | # Output any trailing code. 98 | print ; 99 | exit 0; 100 | 101 | 102 | sub StripComments 103 | { 104 | 105 | no warnings; 106 | 107 | # Strip C & C++ coments 108 | # From the perlfaq 109 | $_[0] =~ 110 | 111 | s{ 112 | /\* ## Start of /* ... */ comment 113 | [^*]*\*+ ## Non-* followed by 1-or-more *'s 114 | ( 115 | [^/*][^*]*\*+ 116 | )* ## 0-or-more things which don't start with / 117 | ## but do end with '*' 118 | / ## End of /* ... */ comment 119 | 120 | | ## OR C++ Comment 121 | // ## Start of C++ comment // 122 | [^\n]* ## followed by 0-or-more non end of line characters 123 | 124 | | ## OR various things which aren't comments: 125 | 126 | ( 127 | " ## Start of " ... " string 128 | ( 129 | \\. ## Escaped char 130 | | ## OR 131 | [^"\\] ## Non "\ 132 | )* 133 | " ## End of " ... " string 134 | 135 | | ## OR 136 | 137 | ' ## Start of ' ... ' string 138 | ( 139 | \\. ## Escaped char 140 | | ## OR 141 | [^'\\] ## Non '\ 142 | )* 143 | ' ## End of ' ... ' string 144 | 145 | | ## OR 146 | 147 | . ## Anything other char 148 | [^/"'\\]* ## Chars which doesn't start a comment, string or escape 149 | ) 150 | }{$2}gxs; 151 | 152 | } 153 | -------------------------------------------------------------------------------- /zutil.c: -------------------------------------------------------------------------------- 1 | /* zutil.c -- target dependent utility functions for the compression library 2 | * Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #include "zutil.h" 9 | #ifndef Z_SOLO 10 | # include "gzguts.h" 11 | #endif 12 | 13 | #ifndef NO_DUMMY_DECL 14 | struct internal_state {int dummy;}; /* for buggy compilers */ 15 | #endif 16 | 17 | z_const char * const z_errmsg[10] = { 18 | "need dictionary", /* Z_NEED_DICT 2 */ 19 | "stream end", /* Z_STREAM_END 1 */ 20 | "", /* Z_OK 0 */ 21 | "file error", /* Z_ERRNO (-1) */ 22 | "stream error", /* Z_STREAM_ERROR (-2) */ 23 | "data error", /* Z_DATA_ERROR (-3) */ 24 | "insufficient memory", /* Z_MEM_ERROR (-4) */ 25 | "buffer error", /* Z_BUF_ERROR (-5) */ 26 | "incompatible version",/* Z_VERSION_ERROR (-6) */ 27 | ""}; 28 | 29 | 30 | const char * ZEXPORT zlibVersion() 31 | { 32 | return ZLIB_VERSION; 33 | } 34 | 35 | uLong ZEXPORT zlibCompileFlags() 36 | { 37 | uLong flags; 38 | 39 | flags = 0; 40 | switch ((int)(sizeof(uInt))) { 41 | case 2: break; 42 | case 4: flags += 1; break; 43 | case 8: flags += 2; break; 44 | default: flags += 3; 45 | } 46 | switch ((int)(sizeof(uLong))) { 47 | case 2: break; 48 | case 4: flags += 1 << 2; break; 49 | case 8: flags += 2 << 2; break; 50 | default: flags += 3 << 2; 51 | } 52 | switch ((int)(sizeof(voidpf))) { 53 | case 2: break; 54 | case 4: flags += 1 << 4; break; 55 | case 8: flags += 2 << 4; break; 56 | default: flags += 3 << 4; 57 | } 58 | switch ((int)(sizeof(z_off_t))) { 59 | case 2: break; 60 | case 4: flags += 1 << 6; break; 61 | case 8: flags += 2 << 6; break; 62 | default: flags += 3 << 6; 63 | } 64 | #ifdef DEBUG 65 | flags += 1 << 8; 66 | #endif 67 | #if defined(ASMV) || defined(ASMINF) 68 | flags += 1 << 9; 69 | #endif 70 | #ifdef ZLIB_WINAPI 71 | flags += 1 << 10; 72 | #endif 73 | #ifdef BUILDFIXED 74 | flags += 1 << 12; 75 | #endif 76 | #ifdef DYNAMIC_CRC_TABLE 77 | flags += 1 << 13; 78 | #endif 79 | #ifdef NO_GZCOMPRESS 80 | flags += 1L << 16; 81 | #endif 82 | #ifdef NO_GZIP 83 | flags += 1L << 17; 84 | #endif 85 | #ifdef PKZIP_BUG_WORKAROUND 86 | flags += 1L << 20; 87 | #endif 88 | #ifdef FASTEST 89 | flags += 1L << 21; 90 | #endif 91 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) 92 | # ifdef NO_vsnprintf 93 | flags += 1L << 25; 94 | # ifdef HAS_vsprintf_void 95 | flags += 1L << 26; 96 | # endif 97 | # else 98 | # ifdef HAS_vsnprintf_void 99 | flags += 1L << 26; 100 | # endif 101 | # endif 102 | #else 103 | flags += 1L << 24; 104 | # ifdef NO_snprintf 105 | flags += 1L << 25; 106 | # ifdef HAS_sprintf_void 107 | flags += 1L << 26; 108 | # endif 109 | # else 110 | # ifdef HAS_snprintf_void 111 | flags += 1L << 26; 112 | # endif 113 | # endif 114 | #endif 115 | return flags; 116 | } 117 | 118 | #ifdef DEBUG 119 | 120 | # ifndef verbose 121 | # define verbose 0 122 | # endif 123 | int ZLIB_INTERNAL z_verbose = verbose; 124 | 125 | void ZLIB_INTERNAL z_error (m) 126 | char *m; 127 | { 128 | fprintf(stderr, "%s\n", m); 129 | exit(1); 130 | } 131 | #endif 132 | 133 | /* exported to allow conversion of error code to string for compress() and 134 | * uncompress() 135 | */ 136 | const char * ZEXPORT zError(err) 137 | int err; 138 | { 139 | return ERR_MSG(err); 140 | } 141 | 142 | #if defined(_WIN32_WCE) 143 | /* The Microsoft C Run-Time Library for Windows CE doesn't have 144 | * errno. We define it as a global variable to simplify porting. 145 | * Its value is always 0 and should not be used. 146 | */ 147 | int errno = 0; 148 | #endif 149 | 150 | #ifndef HAVE_MEMCPY 151 | 152 | void ZLIB_INTERNAL zmemcpy(dest, source, len) 153 | Bytef* dest; 154 | const Bytef* source; 155 | uInt len; 156 | { 157 | if (len == 0) return; 158 | do { 159 | *dest++ = *source++; /* ??? to be unrolled */ 160 | } while (--len != 0); 161 | } 162 | 163 | int ZLIB_INTERNAL zmemcmp(s1, s2, len) 164 | const Bytef* s1; 165 | const Bytef* s2; 166 | uInt len; 167 | { 168 | uInt j; 169 | 170 | for (j = 0; j < len; j++) { 171 | if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; 172 | } 173 | return 0; 174 | } 175 | 176 | void ZLIB_INTERNAL zmemzero(dest, len) 177 | Bytef* dest; 178 | uInt len; 179 | { 180 | if (len == 0) return; 181 | do { 182 | *dest++ = 0; /* ??? to be unrolled */ 183 | } while (--len != 0); 184 | } 185 | #endif 186 | 187 | #ifndef Z_SOLO 188 | 189 | #ifdef SYS16BIT 190 | 191 | #ifdef __TURBOC__ 192 | /* Turbo C in 16-bit mode */ 193 | 194 | # define MY_ZCALLOC 195 | 196 | /* Turbo C malloc() does not allow dynamic allocation of 64K bytes 197 | * and farmalloc(64K) returns a pointer with an offset of 8, so we 198 | * must fix the pointer. Warning: the pointer must be put back to its 199 | * original form in order to free it, use zcfree(). 200 | */ 201 | 202 | #define MAX_PTR 10 203 | /* 10*64K = 640K */ 204 | 205 | local int next_ptr = 0; 206 | 207 | typedef struct ptr_table_s { 208 | voidpf org_ptr; 209 | voidpf new_ptr; 210 | } ptr_table; 211 | 212 | local ptr_table table[MAX_PTR]; 213 | /* This table is used to remember the original form of pointers 214 | * to large buffers (64K). Such pointers are normalized with a zero offset. 215 | * Since MSDOS is not a preemptive multitasking OS, this table is not 216 | * protected from concurrent access. This hack doesn't work anyway on 217 | * a protected system like OS/2. Use Microsoft C instead. 218 | */ 219 | 220 | voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) 221 | { 222 | voidpf buf = opaque; /* just to make some compilers happy */ 223 | ulg bsize = (ulg)items*size; 224 | 225 | /* If we allocate less than 65520 bytes, we assume that farmalloc 226 | * will return a usable pointer which doesn't have to be normalized. 227 | */ 228 | if (bsize < 65520L) { 229 | buf = farmalloc(bsize); 230 | if (*(ush*)&buf != 0) return buf; 231 | } else { 232 | buf = farmalloc(bsize + 16L); 233 | } 234 | if (buf == NULL || next_ptr >= MAX_PTR) return NULL; 235 | table[next_ptr].org_ptr = buf; 236 | 237 | /* Normalize the pointer to seg:0 */ 238 | *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; 239 | *(ush*)&buf = 0; 240 | table[next_ptr++].new_ptr = buf; 241 | return buf; 242 | } 243 | 244 | void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) 245 | { 246 | int n; 247 | if (*(ush*)&ptr != 0) { /* object < 64K */ 248 | farfree(ptr); 249 | return; 250 | } 251 | /* Find the original pointer */ 252 | for (n = 0; n < next_ptr; n++) { 253 | if (ptr != table[n].new_ptr) continue; 254 | 255 | farfree(table[n].org_ptr); 256 | while (++n < next_ptr) { 257 | table[n-1] = table[n]; 258 | } 259 | next_ptr--; 260 | return; 261 | } 262 | ptr = opaque; /* just to make some compilers happy */ 263 | Assert(0, "zcfree: ptr not found"); 264 | } 265 | 266 | #endif /* __TURBOC__ */ 267 | 268 | 269 | #ifdef M_I86 270 | /* Microsoft C in 16-bit mode */ 271 | 272 | # define MY_ZCALLOC 273 | 274 | #if (!defined(_MSC_VER) || (_MSC_VER <= 600)) 275 | # define _halloc halloc 276 | # define _hfree hfree 277 | #endif 278 | 279 | voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) 280 | { 281 | if (opaque) opaque = 0; /* to make compiler happy */ 282 | return _halloc((long)items, size); 283 | } 284 | 285 | void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) 286 | { 287 | if (opaque) opaque = 0; /* to make compiler happy */ 288 | _hfree(ptr); 289 | } 290 | 291 | #endif /* M_I86 */ 292 | 293 | #endif /* SYS16BIT */ 294 | 295 | 296 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ 297 | 298 | #ifndef STDC 299 | extern voidp malloc OF((uInt size)); 300 | extern voidp calloc OF((uInt items, uInt size)); 301 | extern void free OF((voidpf ptr)); 302 | #endif 303 | 304 | voidpf ZLIB_INTERNAL zcalloc (opaque, items, size) 305 | voidpf opaque; 306 | unsigned items; 307 | unsigned size; 308 | { 309 | if (opaque) items += size - size; /* make compiler happy */ 310 | return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : 311 | (voidpf)calloc(items, size); 312 | } 313 | 314 | void ZLIB_INTERNAL zcfree (opaque, ptr) 315 | voidpf opaque; 316 | voidpf ptr; 317 | { 318 | free(ptr); 319 | if (opaque) return; /* make compiler happy */ 320 | } 321 | 322 | #endif /* MY_ZCALLOC */ 323 | 324 | #endif /* !Z_SOLO */ 325 | -------------------------------------------------------------------------------- /zutil.h: -------------------------------------------------------------------------------- 1 | /* zutil.h -- internal interface and configuration of the compression library 2 | * Copyright (C) 1995-2013 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* @(#) $Id$ */ 12 | 13 | #ifndef ZUTIL_H 14 | #define ZUTIL_H 15 | 16 | #ifdef HAVE_HIDDEN 17 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 18 | #else 19 | # define ZLIB_INTERNAL 20 | #endif 21 | 22 | #include "zlib.h" 23 | #include 24 | 25 | #if defined(STDC) && !defined(Z_SOLO) 26 | # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) 27 | # include 28 | # endif 29 | # include 30 | # include 31 | #endif 32 | 33 | #ifdef Z_SOLO 34 | typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */ 35 | #endif 36 | 37 | #ifndef local 38 | # define local static 39 | #endif 40 | /* compile with -Dlocal if your debugger can't find static symbols */ 41 | 42 | typedef unsigned char uch; 43 | typedef uch FAR uchf; 44 | typedef unsigned short ush; 45 | typedef ush FAR ushf; 46 | typedef unsigned long ulg; 47 | 48 | extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ 49 | /* (size given to avoid silly warnings with Visual C++) */ 50 | 51 | #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] 52 | 53 | #define ERR_RETURN(strm,err) \ 54 | return (strm->msg = ERR_MSG(err), (err)) 55 | /* To be used only when the state is known to be valid */ 56 | 57 | /* common constants */ 58 | 59 | #ifndef DEF_WBITS 60 | # define DEF_WBITS MAX_WBITS 61 | #endif 62 | /* default windowBits for decompression. MAX_WBITS is for compression only */ 63 | 64 | #if MAX_MEM_LEVEL >= 8 65 | # define DEF_MEM_LEVEL 8 66 | #else 67 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL 68 | #endif 69 | /* default memLevel */ 70 | 71 | #define STORED_BLOCK 0 72 | #define STATIC_TREES 1 73 | #define DYN_TREES 2 74 | /* The three kinds of block type */ 75 | 76 | #define MIN_MATCH 3 77 | #define MAX_MATCH 258 78 | /* The minimum and maximum match lengths */ 79 | 80 | #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ 81 | 82 | /* target dependencies */ 83 | 84 | #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) 85 | # define OS_CODE 0x00 86 | # ifndef Z_SOLO 87 | # if defined(__TURBOC__) || defined(__BORLANDC__) 88 | # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) 89 | /* Allow compilation with ANSI keywords only enabled */ 90 | void _Cdecl farfree( void *block ); 91 | void *_Cdecl farmalloc( unsigned long nbytes ); 92 | # else 93 | # include 94 | # endif 95 | # else /* MSC or DJGPP */ 96 | # include 97 | # endif 98 | # endif 99 | #endif 100 | 101 | #ifdef AMIGA 102 | # define OS_CODE 0x01 103 | #endif 104 | 105 | #if defined(VAXC) || defined(VMS) 106 | # define OS_CODE 0x02 107 | # define F_OPEN(name, mode) \ 108 | fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") 109 | #endif 110 | 111 | #if defined(ATARI) || defined(atarist) 112 | # define OS_CODE 0x05 113 | #endif 114 | 115 | #ifdef OS2 116 | # define OS_CODE 0x06 117 | # if defined(M_I86) && !defined(Z_SOLO) 118 | # include 119 | # endif 120 | #endif 121 | 122 | #if defined(MACOS) || defined(TARGET_OS_MAC) 123 | # define OS_CODE 0x07 124 | # ifndef Z_SOLO 125 | # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os 126 | # include /* for fdopen */ 127 | # else 128 | # ifndef fdopen 129 | # define fdopen(fd,mode) NULL /* No fdopen() */ 130 | # endif 131 | # endif 132 | # endif 133 | #endif 134 | 135 | #ifdef TOPS20 136 | # define OS_CODE 0x0a 137 | #endif 138 | 139 | #ifdef WIN32 140 | # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ 141 | # define OS_CODE 0x0b 142 | # endif 143 | #endif 144 | 145 | #ifdef __50SERIES /* Prime/PRIMOS */ 146 | # define OS_CODE 0x0f 147 | #endif 148 | 149 | #if defined(_BEOS_) || defined(RISCOS) 150 | # define fdopen(fd,mode) NULL /* No fdopen() */ 151 | #endif 152 | 153 | #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX 154 | # if defined(_WIN32_WCE) 155 | # define fdopen(fd,mode) NULL /* No fdopen() */ 156 | # ifndef _PTRDIFF_T_DEFINED 157 | typedef int ptrdiff_t; 158 | # define _PTRDIFF_T_DEFINED 159 | # endif 160 | # else 161 | # define fdopen(fd,type) _fdopen(fd,type) 162 | # endif 163 | #endif 164 | 165 | #if defined(__BORLANDC__) && !defined(MSDOS) 166 | #pragma warn -8004 167 | #pragma warn -8008 168 | #pragma warn -8066 169 | #endif 170 | 171 | /* provide prototypes for these when building zlib without LFS */ 172 | #if !defined(_WIN32) && \ 173 | (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) 174 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); 175 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); 176 | #endif 177 | 178 | /* common defaults */ 179 | 180 | #ifndef OS_CODE 181 | # define OS_CODE 0x03 /* assume Unix */ 182 | #endif 183 | 184 | #ifndef F_OPEN 185 | # define F_OPEN(name, mode) fopen((name), (mode)) 186 | #endif 187 | 188 | /* functions */ 189 | 190 | #if defined(pyr) || defined(Z_SOLO) 191 | # define NO_MEMCPY 192 | #endif 193 | #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) 194 | /* Use our own functions for small and medium model with MSC <= 5.0. 195 | * You may have to use the same strategy for Borland C (untested). 196 | * The __SC__ check is for Symantec. 197 | */ 198 | # define NO_MEMCPY 199 | #endif 200 | #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) 201 | # define HAVE_MEMCPY 202 | #endif 203 | #ifdef HAVE_MEMCPY 204 | # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ 205 | # define zmemcpy _fmemcpy 206 | # define zmemcmp _fmemcmp 207 | # define zmemzero(dest, len) _fmemset(dest, 0, len) 208 | # else 209 | # define zmemcpy memcpy 210 | # define zmemcmp memcmp 211 | # define zmemzero(dest, len) memset(dest, 0, len) 212 | # endif 213 | #else 214 | void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); 215 | int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); 216 | void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); 217 | #endif 218 | 219 | /* Diagnostic functions */ 220 | #ifdef DEBUG 221 | # include 222 | extern int ZLIB_INTERNAL z_verbose; 223 | extern void ZLIB_INTERNAL z_error OF((char *m)); 224 | # define Assert(cond,msg) {if(!(cond)) z_error(msg);} 225 | # define Trace(x) {if (z_verbose>=0) fprintf x ;} 226 | # define Tracev(x) {if (z_verbose>0) fprintf x ;} 227 | # define Tracevv(x) {if (z_verbose>1) fprintf x ;} 228 | # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} 229 | # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} 230 | #else 231 | # define Assert(cond,msg) 232 | # define Trace(x) 233 | # define Tracev(x) 234 | # define Tracevv(x) 235 | # define Tracec(c,x) 236 | # define Tracecv(c,x) 237 | #endif 238 | 239 | #ifndef Z_SOLO 240 | voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, 241 | unsigned size)); 242 | void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); 243 | #endif 244 | 245 | #define ZALLOC(strm, items, size) \ 246 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) 247 | #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) 248 | #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} 249 | 250 | /* Reverse the bytes in a 32-bit value */ 251 | #define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ 252 | (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) 253 | 254 | #ifdef _MSC_VER 255 | 256 | /* MSC doesn't have __builtin_expect. Just ignore likely/unlikely and 257 | hope the compiler optimizes for the best. 258 | */ 259 | #define likely(x) (x) 260 | #define unlikely(x) (x) 261 | #else 262 | #define likely(x) __builtin_expect((x),1) 263 | #define unlikely(x) __builtin_expect((x),0) 264 | #endif 265 | 266 | #endif /* ZUTIL_H */ 267 | --------------------------------------------------------------------------------