Skip to content

Commit

Permalink
zlib 0.91
Browse files Browse the repository at this point in the history
  • Loading branch information
madler committed Sep 10, 2011
1 parent 64b2e89 commit 1c71d8b
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 101 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -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 :)
Expand 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)
Expand Down
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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) $@
Expand Down
59 changes: 0 additions & 59 deletions Makefile.bak

This file was deleted.

5 changes: 4 additions & 1 deletion Makefile.bor
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion Makefile.msc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion Makefile.tc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 18 additions & 12 deletions README
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 6 additions & 5 deletions deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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 */
}

Expand Down Expand Up @@ -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");

Expand Down
6 changes: 4 additions & 2 deletions example.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -12,7 +12,9 @@
# include <string.h>
#endif

#ifndef __GO32__
extern void exit __P((int));
#endif

#define BUFLEN 4096

Expand Down Expand Up @@ -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);
}

/* ===========================================================================
Expand Down
6 changes: 3 additions & 3 deletions gzio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
11 changes: 8 additions & 3 deletions inflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand All @@ -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--;
}

Expand Down
4 changes: 3 additions & 1 deletion minigzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
* 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
Expand Down
17 changes: 16 additions & 1 deletion zconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -40,10 +41,24 @@
# 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 */
Expand Down
Loading

0 comments on commit 1c71d8b

Please sign in to comment.