]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
zlib 0.91 v0.91
authorMark Adler <madler@alumni.caltech.edu>
Sat, 10 Sep 2011 06:07:35 +0000 (23:07 -0700)
committerMark Adler <madler@alumni.caltech.edu>
Sat, 10 Sep 2011 06:07:35 +0000 (23:07 -0700)
16 files changed:
ChangeLog
Makefile
Makefile.bak [deleted file]
Makefile.bor
Makefile.msc
Makefile.tc
README
deflate.c
example.c
gzio.c
inflate.c
minigzip.c
zconf.h
zlib.h
zutil.c
zutil.h

index 54470f237eca1627533c7801a1fe2b7ad0e3c30e..e97948e99603aa9ba04e9af1cf2cbeb0082a2928 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
                ChangeLog file for zlib
 
+Changes in 0.91 (2 May 95)
+- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h
+- Document the memory requirements in zconf.h
+- added "make install"
+- fix sync search logic in inflateSync
+- deflate(Z_FULL_FLUSH) now works even if output buffer too short
+- after inflateSync, don't scare people with just "lo world"
+- added support for DJGPP
+
 Changes in 0.9 (1 May 95)
 - don't assume that zalloc clears the allocated memory (the TurboC bug
   was Mark's bug after all :)
@@ -10,6 +19,7 @@ Changes in 0.9 (1 May 95)
 - document explicitly that zalloc(64K) on MSDOS must return a normalized
   pointer (zero offset)
 - added Makefiles for Microsoft C, Turbo C, Borland C++
+- faster crc32()
 
 Changes in 0.8 (29 April 95)
 - added fast inflate (inffast.c)
index f251670522032d79aa1716c9e159010e16f76107..9a48249acb032c4f55ed5a34e07af9db71eca901 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,17 @@
+# Makefile for zlib
+# Copyright (C) 1995 Jean-loup Gailly.
+# For conditions of distribution and use, see copyright notice in zlib.h 
+
 CC=cc
 CFLAGS=-O
+#CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
 #CFLAGS=-g -DDEBUG
 LDFLAGS=-L. -lgz
 
 RANLIB=ranlib
 
+prefix=/usr/local
+
 OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
        zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
 
@@ -16,6 +23,14 @@ test: all
        ./example
        echo hello world | ./minigzip | ./minigzip -d 
 
+install: libgz.a
+       -@mkdir $(prefix)/include
+       -@mkdir $(prefix)/lib
+       cp zlib.h zconf.h $(prefix)/include
+       chmod 644 $(prefix)/include/zlib.h $(prefix)/include/zconf.h
+       cp libgz.a $(prefix)/lib
+       chmod 644 $(prefix)/lib/libgz.a
+
 libgz.a: $(OBJS)
        ar rc $@ $(OBJS)
        $(RANLIB) $@
diff --git a/Makefile.bak b/Makefile.bak
deleted file mode 100644 (file)
index bfe1b74..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-CC=gcc
-CFLAGS=-O2
-#CFLAGS=-g -DDEBUG
-LDFLAGS=-L. -lgz
-
-RANLIB=ranlib
-
-OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \
-       zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o
-
-TEST_OBJS = example.o minigzip.o inftest.o
-
-all: example minigzip inftest
-
-test: all
-       ./example
-       echo hello world | ./minigzip | ./minigzip -d 
-
-libgz.a: $(OBJS)
-       ar rc $@ $(OBJS)
-       $(RANLIB) $@
-
-example: example.o libgz.a
-       $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS)
-
-minigzip: minigzip.o libgz.a
-       $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS)
-
-inftest: inftest.o libgz.a
-       $(CC) $(CFLAGS) -o $@ inftest.o $(LDFLAGS)
-
-clean:
-       rm -f *.o example minigzip inftest libgz.a foo.gz
-
-zip:
-       zip -ul9 zlib README ChangeLog Makefile *.[ch]
-
-tgz:
-       cd ..; tar cfz zlib/zlib.tgz zlib/README zlib/ChangeLog zlib/Makefile \
-               zlib/*.[ch]
-
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-adler32.o: zutil.h zlib.h zconf.h
-compress.o: zlib.h zconf.h
-crc32.o: zutil.h zlib.h zconf.h
-deflate.o: deflate.h zutil.h zlib.h zconf.h
-example.o: zlib.h zconf.h
-gzio.o: zutil.h zlib.h zconf.h
-infblock.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h
-infcodes.o: zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h
-inflate.o: zutil.h zlib.h zconf.h infblock.h
-inftest.o: zutil.h zlib.h zconf.h
-inftrees.o: zutil.h zlib.h zconf.h inftrees.h
-infutil.o: zutil.h zlib.h zconf.h inftrees.h infutil.h
-minigzip.o: zlib.h zconf.h
-trees.o: deflate.h zutil.h zlib.h zconf.h
-uncompr.o: zlib.h zconf.h
-zutil.o: zutil.h zlib.h zconf.h
index 877ed6224ed0c8a42691b52536dddbee53441f99..732ea5ddb58d746f8bb52bd89d4bf1a01669972f 100644 (file)
@@ -4,7 +4,10 @@
 # To use, do "make -fmakefile.bor"
 
 # WARNING: the small model is supported but only for small values of
-# MAX_WBITS and MAX_MEM_LEVEL
+# MAX_WBITS and MAX_MEM_LEVEL. If you wish to reduce the memory
+# requirements (default 256K for big objects plus a few K), you can add
+# to CFLAGS below: -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
+# See zconf.h for details about the memory requirements.
 
 # ------------- Turbo C++, Borland C++ -------------
 MODEL=-ml
index 375d21c1135faf8914b61cdecd277b18d46e32e2..d6899d828abf4c2d332f610fda24979dea0a7018 100644 (file)
@@ -4,7 +4,10 @@
 # To use, do "make makefile.msc"
 
 # WARNING: the small model is supported but only for small values of
-# MAX_WBITS and MAX_MEM_LEVEL
+# MAX_WBITS and MAX_MEM_LEVEL. If you wish to reduce the memory
+# requirements (default 256K for big objects plus a few K), you can add
+# to CFLAGS below: -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
+# See zconf.h for details about the memory requirements.
 
 # ------------- Microsoft C 5.1 and later -------------
 MODEL=-AL
index 51075f75cd54f96ffc1d72b75b234ec1797e1bda..e173a559f544c20b2eb674fa2fbd67f0bd32656e 100644 (file)
@@ -4,7 +4,10 @@
 # To use, do "make -fmakefile.tc"
 
 # WARNING: the small model is supported but only for small values of
-# MAX_WBITS and MAX_MEM_LEVEL
+# MAX_WBITS and MAX_MEM_LEVEL. If you wish to reduce the memory
+# requirements (default 256K for big objects plus a few K), you can add
+# to CFLAGS below: -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14
+# See zconf.h for details about the memory requirements.
 
 # ------------- Turbo C 2.0 -------------
 MODEL=-ml
diff --git a/README b/README
index 0c718f19855db0ae449954143107f7a5c3541845..caeccb965323076b34174ce6300ae25796edc536 100644 (file)
--- a/README
+++ b/README
@@ -1,25 +1,31 @@
-zlib 0.9 is a beta version of a general purpose compression library.
+zlib 0.91 is a beta version of a general purpose compression library.
 
 The data format used by the zlib library is described in the
-file zlib-3.1.doc, deflate-1.1.doc and gzip-4.1.doc, available
+files zlib-3.1.doc, deflate-1.1.doc and gzip-4.1.doc, available
 in ftp.uu.net:/pub/archiving/zip/doc.
 
 All functions of the compression library are documented in the file
 zlib.h. A usage example of the library is given in the file example.c
 which also tests that the library is working correctly.
-To compile all files and run the test program, just type: make test
 
-The changes made in version 0.9 are documented in the file ChangeLog.
-The main changes since 0.8 are:
-- don't assume that zalloc clears the allocated memory
-- let again gzread copy uncompressed data unchanged (was working in 0.71)
-- deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented
+To compile all files and run the test program, just type: make test
+(For MSDOS, use one of the special makefiles such as Makefile.msc.)
+To install the zlib library (libgz.a) in /usr/local/lib, type: make install
+To install in a different directory, use for example: make install prefix=$HOME
+This will install in $HOME/lib instead of /usr/local/lib.
+
+The changes made in version 0.91 are documented in the file ChangeLog.
+The main changes since 0.9 are:
+- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h
+- Document the memory requirements in zconf.h
+- added "make install"
+- added support for DJGPP
 
 On MSDOS, this version works in both large and small model. However
-small model compression works only for small values of MEM_LEVEL and
-WBITS (see zutil.h). Small model decompression should work up to WBITS=15.
-This version of zlib does not support small or medium model with far
-allocation of big objects.
+small model compression works only for small values of MAX_MEM_LEVEL
+and MAX_WBITS (see zconf.h). Small model decompression should work up
+to MAX_WBITS=15.  This version of zlib does not support small or
+medium model with far allocation of big objects.
 
 
   Copyright (C) 1995 Jean-loup Gailly and Mark Adler
index 75db3d0d7344888eeb02ad06815e17d7f8720e86..b65ba2513033af1fddd75e46fee02be61a6ee470 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -47,7 +47,7 @@
  *
  */
 
-/* $Id: deflate.c,v 1.6 1995/05/01 17:23:57 jloup Exp $ */
+/* $Id: deflate.c,v 1.7 1995/05/02 13:28:18 jloup Exp $ */
 
 #include "deflate.h"
 
@@ -165,7 +165,7 @@ int deflateInit (strm, level)
     z_stream *strm;
     int level;
 {
-    return deflateInit2 (strm, level, DEFLATED, MAX_WBITS, MAX_MEM_LEVEL, 0);
+    return deflateInit2 (strm, level, DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, 0);
     /* To do: ignore strm->next_in if we use it as window */
 }
 
@@ -344,22 +344,23 @@ int deflate (strm, flush)
      */
     if (strm->avail_in != 0 ||
        (flush == Z_FINISH && strm->state->status != FINISH_STATE)) {
+       int quit;
        
        if (flush == Z_FINISH) {
            strm->state->status = FINISH_STATE;
        }
         if (strm->state->level <= 3) {
-           if (deflate_fast(strm->state, flush)) return Z_OK;
+           quit = deflate_fast(strm->state, flush);
        } else {
-           if (deflate_slow(strm->state, flush)) return Z_OK;
+           quit = deflate_slow(strm->state, flush);
        }
-       /* ??? remember Z_FULL_FLUSH if we didn't have enough space */
        if (flush == Z_FULL_FLUSH) {
            ct_stored_block(strm->state, (char*)0, 0L, 0); /* special marker */
            flush_pending(strm);
            CLEAR_HASH(strm->state);             /* forget history */
            if (strm->avail_out == 0) return Z_OK;
        }
+       if (quit) return Z_OK;
     }
     Assert(strm->avail_out > 0, "bug2");
 
index c1bac1ebd8d82906e1d7b3fcf611ce2fab2955ea..5c34733dba30219c035230610434c3f17e7caa09 100644 (file)
--- a/example.c
+++ b/example.c
@@ -3,7 +3,7 @@
  * For conditions of distribution and use, see copyright notice in zlib.h 
  */
 
-/* $Id: example.c,v 1.7 1995/05/01 16:57:22 jloup Exp $ */
+/* $Id: example.c,v 1.8 1995/05/02 15:52:32 jloup Exp $ */
 
 #include <stdio.h>
 #include "zlib.h"
@@ -12,7 +12,9 @@
 #  include <string.h>
 #endif
 
+#ifndef __GO32__
 extern void exit  __P((int));
+#endif
 
 #define BUFLEN 4096
 
@@ -253,7 +255,7 @@ void test_sync(compr)
     err = inflateEnd(&d_stream);
     CHECK_ERR(err, "inflateEnd");
 
-    printf("after inflateSync(): %s\n", uncompr);
+    printf("after inflateSync(): hel%s\n", uncompr);
 }
 
 /* ===========================================================================
diff --git a/gzio.c b/gzio.c
index 1f5e130355f42626f9a38d6fc053d2d8ff4cd932..7a3d05a1c3cc3d7839b6cf877ed2a13d448353f1 100644 (file)
--- a/gzio.c
+++ b/gzio.c
@@ -3,7 +3,7 @@
  * For conditions of distribution and use, see copyright notice in zlib.h
  */
 
-/* $Id: gzio.c,v 1.6 1995/04/30 19:52:21 jloup Exp $ */
+/* $Id: gzio.c,v 1.7 1995/05/02 12:22:08 jloup Exp $ */
 
 #include <stdio.h>
 
@@ -128,7 +128,7 @@ local gzFile gz_open (path, mode, fd)
     
     if (s->mode == 'w') {
        err = deflateInit2(&(s->stream), Z_DEFAULT_COMPRESSION,
-                          DEFLATED, -MAX_WBITS, MAX_MEM_LEVEL, 0);
+                          DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, 0);
        /* windowBits is passed < 0 to suppress zlib header */
 
        s->stream.next_out = s->outbuf = ALLOC(Z_BUFSIZE);
@@ -221,7 +221,7 @@ gzFile gzdopen (fd, mode)
     char *mode;
 {
     char name[20];
-    sprintf(name, "_fd:%d_", fd); /* for debugging */
+    sprintf(name, "<fd:%d>", fd); /* for debugging */
 
     return gz_open (name, mode, fd);
 }
index bed4e544a4d0e7c97cdca83f3d0805b6c30c5ff5..0b0ee873c98dfd96d41727fca0da322d38be69a7 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -145,7 +145,7 @@ int f;
   {
     case METHOD:
       NEEDBYTE
-      if (((z->state->sub.method = NEXTBYTE) & 0xf != DEFLATED))
+      if (((z->state->sub.method = NEXTBYTE) & 0xf) != DEFLATED)
       {
         z->state->mode = BAD;
        z->msg = "unknown compression method";
@@ -243,7 +243,10 @@ z_stream *z;
   if (z == Z_NULL || z->state == Z_NULL)
     return Z_STREAM_ERROR;
   if (z->state->mode != BAD)
+  {
+    z->state->mode = BAD;
     z->state->sub.marker = 0;
+  }
   if ((n = z->avail_in) == 0)
     return Z_BUF_ERROR;
   p = z->next_in;
@@ -252,10 +255,12 @@ z_stream *z;
   /* search */
   while (n && m < 4)
   {
-    if (*p == (m < 2 ? 0 : 0xff))
+    if (*p == (Byte)(m < 2 ? 0 : 0xff))
       m++;
-    else if (*p || m > 2)
+    else if (*p)
       m = 0;
+    else
+      m = 4 - m;
     p++, n--;
   }
 
index d3d2fe92a3eeb72cc99770a66708f8471aa1050d..8f580802c6ba810ec8246407e91d7275bebc0223 100644 (file)
  * or in pipe mode.
  */
 
-/* $Id: minigzip.c,v 1.3 1995/04/29 14:27:21 jloup Exp $ */
+/* $Id: minigzip.c,v 1.4 1995/05/02 15:54:22 jloup Exp $ */
 
 #include <stdio.h>
 #include "zlib.h"
 
+#ifndef __GO32__
 extern void exit  __P((int));
+#endif
 extern int unlink __P((const char *));
 
 #ifdef STDC
diff --git a/zconf.h b/zconf.h
index 4e05a3e5af46cd5c307d650720b05b795af5bf27..1abb0ea3b39c9f63c3f08386958185badfd4a36f 100644 (file)
--- a/zconf.h
+++ b/zconf.h
@@ -3,7 +3,7 @@
  * For conditions of distribution and use, see copyright notice in zlib.h 
  */
 
-/* $Id: zconf.h,v 1.10 1995/04/30 19:27:14 jloup Exp $ */
+/* $Id: zconf.h,v 1.11 1995/05/02 13:07:21 jloup Exp $ */
 
 #ifndef _ZCONF_H
 #define _ZCONF_H
@@ -32,6 +32,7 @@
 #  define STDC
 #endif
 
+/* Maximum value for memLevel in deflateInit2 */
 #ifndef MAX_MEM_LEVEL
 #  ifdef MAXSEG_64K
 #    define MAX_MEM_LEVEL 8
 #  endif
 #endif
 
+/* Maximum value for windowBits in deflateInit2 and inflateInit2 */
 #ifndef MAX_WBITS
 #  define MAX_WBITS   15 /* 32K LZ77 window */
 #endif
 
+/* The memory requirements for deflate are (in bytes):
+            1 << (windowBits+2)   +  1 << (memLevel+9)
+ that is: 128K for windowBits=15  +  128K for memLevel = 8  (default values)
+ plus a few kilobytes for small objects. For example, if you want to reduce
+ the default memory requirements from 256K to 128K, compile with
+     make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
+ Of course this will generally degrade compression (there's no free lunch).
+
+   The memory requirements for inflate are (in bytes) 1 << windowBits
+ that is, 32K for windowBits=15 (default value) plus a few kilobytes
+ for small objects.
+*/
+
                        /* Type declarations */
 
 #ifndef __P /* function prototypes */
diff --git a/zlib.h b/zlib.h
index e64ab91fbb084c295da557d0bb7c961d8f5119a1..171220914a99902535d5a114a5abc66055d6b5d0 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -1,5 +1,5 @@
 /* zlib.h -- interface of the 'zlib' general purpose compression library
-  version 0.9 April 30th, 1995.
+  version 0.91 May 2nd, 1995.
 
   Copyright (C) 1995 Jean-loup Gailly and Mark Adler
 
@@ -28,7 +28,7 @@
 
 #include "zconf.h"
 
-#define ZLIB_VERSION "0.9"
+#define ZLIB_VERSION "0.91"
 
 /* 
      The 'zlib' compression library provides in-memory compression and
@@ -335,7 +335,8 @@ extern int deflateInit2 __P((z_stream *strm,
     The memLevel parameter specifies how much memory should be allocated
    for the internal compression state. memLevel=1 uses minimum memory but
    is slow and reduces compression ratio; memLevel=9 uses maximum memory
-   for optimal speed. The default value is 8.
+   for optimal speed. The default value is 8. See zconf.h for total memory
+   usage as a function of windowBits and memLevel.
 
      The strategy parameter is used to tune the compression algorithm. Use
    the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data
diff --git a/zutil.c b/zutil.c
index 4ceb89fd5593a94c09a65eff7fcf7c6906781584..508ad62bf1b783c02e281016c5015d2929fad8f3 100644 (file)
--- a/zutil.c
+++ b/zutil.c
@@ -3,13 +3,15 @@
  * For conditions of distribution and use, see copyright notice in zlib.h 
  */
 
-/* $Id: zutil.c,v 1.6 1995/04/29 14:54:02 jloup Exp $ */
+/* $Id: zutil.c,v 1.7 1995/05/02 15:54:47 jloup Exp $ */
 
 #include <stdio.h>
 
 #include "zutil.h"
 
+#ifndef __GO32__
 extern void exit __P((int));
+#endif
 
 char *zlib_version = ZLIB_VERSION;
 
@@ -55,8 +57,9 @@ void zmemzero(dest, len)
 }
 #endif
 
-#if defined(MSDOS) && !defined(__SMALL__) && !defined(M_I86SM)
-#  ifdef __TURBOC__
+#if defined(__TURBOC__) && !defined(__SMALL__)
+
+#  define MY_ZCALLOC
 
 /* Turbo C malloc() does not allow dynamic allocation of 64K bytes
  * and farmalloc(64K) returns a pointer with an offset of 8, so we
@@ -124,8 +127,11 @@ void  zcfree (voidp opaque, voidp ptr)
     ptr = opaque; /* just to make some compilers happy */
     z_error("zcfree: ptr not found");
 }
+#endif /* __TURBOC__ */
+
+#if defined(M_I86CM) || defined(M_I86LM) /* MSC compact or large model */
 
-#  else /* MSC */
+#  define MY_ZCALLOC
 
 #if (!defined(_MSC_VER) || (_MSC_VER < 600))
 #  define _halloc  halloc
@@ -144,12 +150,15 @@ void  zcfree (voidp opaque, voidp ptr)
     _hfree(ptr);
 }
 
-#  endif /* __TURBOC__ ? */
+#endif /* defined(M_I86CM) || defined(M_I86LM) */
 
-#else /* !MSDOS */
 
+#ifndef MY_ZCALLOC /* Any system without a special alloc function */
+
+#ifndef __GO32__
 extern voidp calloc __P((uInt items, uInt size));
 extern void  free   __P((voidp ptr));
+#endif
 
 voidp zcalloc (opaque, items, size)
     voidp opaque;
@@ -166,4 +175,4 @@ void  zcfree (opaque, ptr)
     free(ptr);
 }
 
-#endif /* MSDOS */
+#endif /* MY_ZCALLOC */
diff --git a/zutil.h b/zutil.h
index a4b00a0c4634fa0aa26b2324242ed5662ebd9961..503a44544fd1b889bda5270a3a88f723a99d75bf 100644 (file)
--- a/zutil.h
+++ b/zutil.h
@@ -8,7 +8,7 @@
    subject to change. Applications should only use zlib.h.
  */
 
-/* $Id: zutil.h,v 1.7 1995/04/30 10:55:33 jloup Exp $ */
+/* $Id: zutil.h,v 1.8 1995/05/02 15:44:46 jloup Exp $ */
 
 #ifndef _Z_UTIL_H
 #define _Z_UTIL_H
@@ -17,6 +17,7 @@
 
 #ifdef MSDOS
 #   include <stddef.h>
+#   include <errno.h>
 #else
     extern int errno;
 #endif
@@ -43,7 +44,14 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */
 #define DEFLATED   8
 
 #define DEF_WBITS 15
-/* default WBITS for decompression. MAX_WBITS is useful for compression only */
+/* default windowBits for decompression. MAX_WBITS is for compression only */
+
+#if MAX_MEM_LEVEL >= 8
+#  define DEF_MEM_LEVEL 8
+#else
+#  define DEF_MEM_LEVEL  MAX_MEM_LEVEL
+#endif
+/* default memLevel */
 
 #define STORED_BLOCK 0
 #define STATIC_TREES 1