diff options
| author | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:07:35 -0700 |
|---|---|---|
| committer | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:07:35 -0700 |
| commit | 1c71d8b13b54f91ddec361d3053ecce26e6ff761 (patch) | |
| tree | 84f806bb79cc8c7458ddbd7b5402dbf1eec76dd4 | |
| parent | 64b2e892035cf6ea98800c54dce0d63730d50272 (diff) | |
| download | zlib-1c71d8b13b54f91ddec361d3053ecce26e6ff761.tar.gz zlib-1c71d8b13b54f91ddec361d3053ecce26e6ff761.tar.bz2 zlib-1c71d8b13b54f91ddec361d3053ecce26e6ff761.zip | |
zlib 0.91v0.91
Diffstat (limited to '')
| -rw-r--r-- | ChangeLog | 10 | ||||
| -rw-r--r-- | Makefile | 15 | ||||
| -rw-r--r-- | Makefile.bak | 59 | ||||
| -rw-r--r-- | Makefile.bor | 5 | ||||
| -rw-r--r-- | Makefile.msc | 5 | ||||
| -rw-r--r-- | Makefile.tc | 5 | ||||
| -rw-r--r-- | README | 30 | ||||
| -rw-r--r-- | deflate.c | 11 | ||||
| -rw-r--r-- | example.c | 6 | ||||
| -rw-r--r-- | gzio.c | 6 | ||||
| -rw-r--r-- | inflate.c | 11 | ||||
| -rw-r--r-- | minigzip.c | 4 | ||||
| -rw-r--r-- | zconf.h | 17 | ||||
| -rw-r--r-- | zlib.h | 7 | ||||
| -rw-r--r-- | zutil.c | 23 | ||||
| -rw-r--r-- | zutil.h | 12 |
16 files changed, 125 insertions, 101 deletions
| @@ -1,5 +1,14 @@ | |||
| 1 | ChangeLog file for zlib | 1 | ChangeLog file for zlib |
| 2 | 2 | ||
| 3 | Changes in 0.91 (2 May 95) | ||
| 4 | - Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h | ||
| 5 | - Document the memory requirements in zconf.h | ||
| 6 | - added "make install" | ||
| 7 | - fix sync search logic in inflateSync | ||
| 8 | - deflate(Z_FULL_FLUSH) now works even if output buffer too short | ||
| 9 | - after inflateSync, don't scare people with just "lo world" | ||
| 10 | - added support for DJGPP | ||
| 11 | |||
| 3 | Changes in 0.9 (1 May 95) | 12 | Changes in 0.9 (1 May 95) |
| 4 | - don't assume that zalloc clears the allocated memory (the TurboC bug | 13 | - don't assume that zalloc clears the allocated memory (the TurboC bug |
| 5 | was Mark's bug after all :) | 14 | was Mark's bug after all :) |
| @@ -10,6 +19,7 @@ Changes in 0.9 (1 May 95) | |||
| 10 | - document explicitly that zalloc(64K) on MSDOS must return a normalized | 19 | - document explicitly that zalloc(64K) on MSDOS must return a normalized |
| 11 | pointer (zero offset) | 20 | pointer (zero offset) |
| 12 | - added Makefiles for Microsoft C, Turbo C, Borland C++ | 21 | - added Makefiles for Microsoft C, Turbo C, Borland C++ |
| 22 | - faster crc32() | ||
| 13 | 23 | ||
| 14 | Changes in 0.8 (29 April 95) | 24 | Changes in 0.8 (29 April 95) |
| 15 | - added fast inflate (inffast.c) | 25 | - added fast inflate (inffast.c) |
| @@ -1,10 +1,17 @@ | |||
| 1 | # Makefile for zlib | ||
| 2 | # Copyright (C) 1995 Jean-loup Gailly. | ||
| 3 | # For conditions of distribution and use, see copyright notice in zlib.h | ||
| 4 | |||
| 1 | CC=cc | 5 | CC=cc |
| 2 | CFLAGS=-O | 6 | CFLAGS=-O |
| 7 | #CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" | ||
| 3 | #CFLAGS=-g -DDEBUG | 8 | #CFLAGS=-g -DDEBUG |
| 4 | LDFLAGS=-L. -lgz | 9 | LDFLAGS=-L. -lgz |
| 5 | 10 | ||
| 6 | RANLIB=ranlib | 11 | RANLIB=ranlib |
| 7 | 12 | ||
| 13 | prefix=/usr/local | ||
| 14 | |||
| 8 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | 15 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ |
| 9 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o | 16 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o |
| 10 | 17 | ||
| @@ -16,6 +23,14 @@ test: all | |||
| 16 | ./example | 23 | ./example |
| 17 | echo hello world | ./minigzip | ./minigzip -d | 24 | echo hello world | ./minigzip | ./minigzip -d |
| 18 | 25 | ||
| 26 | install: libgz.a | ||
| 27 | -@mkdir $(prefix)/include | ||
| 28 | -@mkdir $(prefix)/lib | ||
| 29 | cp zlib.h zconf.h $(prefix)/include | ||
| 30 | chmod 644 $(prefix)/include/zlib.h $(prefix)/include/zconf.h | ||
| 31 | cp libgz.a $(prefix)/lib | ||
| 32 | chmod 644 $(prefix)/lib/libgz.a | ||
| 33 | |||
| 19 | libgz.a: $(OBJS) | 34 | libgz.a: $(OBJS) |
| 20 | ar rc $@ $(OBJS) | 35 | ar rc $@ $(OBJS) |
| 21 | $(RANLIB) $@ | 36 | $(RANLIB) $@ |
diff --git a/Makefile.bak b/Makefile.bak deleted file mode 100644 index bfe1b74..0000000 --- a/Makefile.bak +++ /dev/null | |||
| @@ -1,59 +0,0 @@ | |||
| 1 | CC=gcc | ||
| 2 | CFLAGS=-O2 | ||
| 3 | #CFLAGS=-g -DDEBUG | ||
| 4 | LDFLAGS=-L. -lgz | ||
| 5 | |||
| 6 | RANLIB=ranlib | ||
| 7 | |||
| 8 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | ||
| 9 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o | ||
| 10 | |||
| 11 | TEST_OBJS = example.o minigzip.o inftest.o | ||
| 12 | |||
| 13 | all: example minigzip inftest | ||
| 14 | |||
| 15 | test: all | ||
| 16 | ./example | ||
| 17 | echo hello world | ./minigzip | ./minigzip -d | ||
| 18 | |||
| 19 | libgz.a: $(OBJS) | ||
| 20 | ar rc $@ $(OBJS) | ||
| 21 | $(RANLIB) $@ | ||
| 22 | |||
| 23 | example: example.o libgz.a | ||
| 24 | $(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) | ||
| 25 | |||
| 26 | minigzip: minigzip.o libgz.a | ||
| 27 | $(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) | ||
| 28 | |||
| 29 | inftest: inftest.o libgz.a | ||
| 30 | $(CC) $(CFLAGS) -o $@ inftest.o $(LDFLAGS) | ||
| 31 | |||
| 32 | clean: | ||
| 33 | rm -f *.o example minigzip inftest libgz.a foo.gz | ||
| 34 | |||
| 35 | zip: | ||
| 36 | zip -ul9 zlib README ChangeLog Makefile *.[ch] | ||
| 37 | |||
| 38 | tgz: | ||
| 39 | cd ..; tar cfz zlib/zlib.tgz zlib/README zlib/ChangeLog zlib/Makefile \ | ||
| 40 | zlib/*.[ch] | ||
| 41 | |||
| 42 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
| 43 | |||
| 44 | adler32.o: zutil.h zlib.h zconf.h | ||
| 45 | compress.o: zlib.h zconf.h | ||
| 46 | crc32.o: zutil.h zlib.h zconf.h | ||
| 47 | deflate.o: deflate.h zutil.h zlib.h zconf.h | ||
| 48 | example.o: zlib.h zconf.h | ||
| 49 | gzio.o: zutil.h zlib.h zconf.h | ||
| 50 | infblock.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h | ||
| 51 | infcodes.o: zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h | ||
| 52 | inflate.o: zutil.h zlib.h zconf.h infblock.h | ||
| 53 | inftest.o: zutil.h zlib.h zconf.h | ||
| 54 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h | ||
| 55 | infutil.o: zutil.h zlib.h zconf.h inftrees.h infutil.h | ||
| 56 | minigzip.o: zlib.h zconf.h | ||
| 57 | trees.o: deflate.h zutil.h zlib.h zconf.h | ||
| 58 | uncompr.o: zlib.h zconf.h | ||
| 59 | zutil.o: zutil.h zlib.h zconf.h | ||
diff --git a/Makefile.bor b/Makefile.bor index 877ed62..732ea5d 100644 --- a/Makefile.bor +++ b/Makefile.bor | |||
| @@ -4,7 +4,10 @@ | |||
| 4 | # To use, do "make -fmakefile.bor" | 4 | # To use, do "make -fmakefile.bor" |
| 5 | 5 | ||
| 6 | # WARNING: the small model is supported but only for small values of | 6 | # WARNING: the small model is supported but only for small values of |
| 7 | # MAX_WBITS and MAX_MEM_LEVEL | 7 | # MAX_WBITS and MAX_MEM_LEVEL. If you wish to reduce the memory |
| 8 | # requirements (default 256K for big objects plus a few K), you can add | ||
| 9 | # to CFLAGS below: -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 | ||
| 10 | # See zconf.h for details about the memory requirements. | ||
| 8 | 11 | ||
| 9 | # ------------- Turbo C++, Borland C++ ------------- | 12 | # ------------- Turbo C++, Borland C++ ------------- |
| 10 | MODEL=-ml | 13 | MODEL=-ml |
diff --git a/Makefile.msc b/Makefile.msc index 375d21c..d6899d8 100644 --- a/Makefile.msc +++ b/Makefile.msc | |||
| @@ -4,7 +4,10 @@ | |||
| 4 | # To use, do "make makefile.msc" | 4 | # To use, do "make makefile.msc" |
| 5 | 5 | ||
| 6 | # WARNING: the small model is supported but only for small values of | 6 | # WARNING: the small model is supported but only for small values of |
| 7 | # MAX_WBITS and MAX_MEM_LEVEL | 7 | # MAX_WBITS and MAX_MEM_LEVEL. If you wish to reduce the memory |
| 8 | # requirements (default 256K for big objects plus a few K), you can add | ||
| 9 | # to CFLAGS below: -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 | ||
| 10 | # See zconf.h for details about the memory requirements. | ||
| 8 | 11 | ||
| 9 | # ------------- Microsoft C 5.1 and later ------------- | 12 | # ------------- Microsoft C 5.1 and later ------------- |
| 10 | MODEL=-AL | 13 | MODEL=-AL |
diff --git a/Makefile.tc b/Makefile.tc index 51075f7..e173a55 100644 --- a/Makefile.tc +++ b/Makefile.tc | |||
| @@ -4,7 +4,10 @@ | |||
| 4 | # To use, do "make -fmakefile.tc" | 4 | # To use, do "make -fmakefile.tc" |
| 5 | 5 | ||
| 6 | # WARNING: the small model is supported but only for small values of | 6 | # WARNING: the small model is supported but only for small values of |
| 7 | # MAX_WBITS and MAX_MEM_LEVEL | 7 | # MAX_WBITS and MAX_MEM_LEVEL. If you wish to reduce the memory |
| 8 | # requirements (default 256K for big objects plus a few K), you can add | ||
| 9 | # to CFLAGS below: -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 | ||
| 10 | # See zconf.h for details about the memory requirements. | ||
| 8 | 11 | ||
| 9 | # ------------- Turbo C 2.0 ------------- | 12 | # ------------- Turbo C 2.0 ------------- |
| 10 | MODEL=-ml | 13 | MODEL=-ml |
| @@ -1,25 +1,31 @@ | |||
| 1 | zlib 0.9 is a beta version of a general purpose compression library. | 1 | zlib 0.91 is a beta version of a general purpose compression library. |
| 2 | 2 | ||
| 3 | The data format used by the zlib library is described in the | 3 | The data format used by the zlib library is described in the |
| 4 | file zlib-3.1.doc, deflate-1.1.doc and gzip-4.1.doc, available | 4 | files zlib-3.1.doc, deflate-1.1.doc and gzip-4.1.doc, available |
| 5 | in ftp.uu.net:/pub/archiving/zip/doc. | 5 | in ftp.uu.net:/pub/archiving/zip/doc. |
| 6 | 6 | ||
| 7 | All functions of the compression library are documented in the file | 7 | All functions of the compression library are documented in the file |
| 8 | zlib.h. A usage example of the library is given in the file example.c | 8 | zlib.h. A usage example of the library is given in the file example.c |
| 9 | which also tests that the library is working correctly. | 9 | which also tests that the library is working correctly. |
| 10 | To compile all files and run the test program, just type: make test | ||
| 11 | 10 | ||
| 12 | The changes made in version 0.9 are documented in the file ChangeLog. | 11 | To compile all files and run the test program, just type: make test |
| 13 | The main changes since 0.8 are: | 12 | (For MSDOS, use one of the special makefiles such as Makefile.msc.) |
| 14 | - don't assume that zalloc clears the allocated memory | 13 | To install the zlib library (libgz.a) in /usr/local/lib, type: make install |
| 15 | - let again gzread copy uncompressed data unchanged (was working in 0.71) | 14 | To install in a different directory, use for example: make install prefix=$HOME |
| 16 | - deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented | 15 | This will install in $HOME/lib instead of /usr/local/lib. |
| 16 | |||
| 17 | The changes made in version 0.91 are documented in the file ChangeLog. | ||
| 18 | The main changes since 0.9 are: | ||
| 19 | - Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h | ||
| 20 | - Document the memory requirements in zconf.h | ||
| 21 | - added "make install" | ||
| 22 | - added support for DJGPP | ||
| 17 | 23 | ||
| 18 | On MSDOS, this version works in both large and small model. However | 24 | On MSDOS, this version works in both large and small model. However |
| 19 | small model compression works only for small values of MEM_LEVEL and | 25 | small model compression works only for small values of MAX_MEM_LEVEL |
| 20 | WBITS (see zutil.h). Small model decompression should work up to WBITS=15. | 26 | and MAX_WBITS (see zconf.h). Small model decompression should work up |
| 21 | This version of zlib does not support small or medium model with far | 27 | to MAX_WBITS=15. This version of zlib does not support small or |
| 22 | allocation of big objects. | 28 | medium model with far allocation of big objects. |
| 23 | 29 | ||
| 24 | 30 | ||
| 25 | Copyright (C) 1995 Jean-loup Gailly and Mark Adler | 31 | Copyright (C) 1995 Jean-loup Gailly and Mark Adler |
| @@ -47,7 +47,7 @@ | |||
| 47 | * | 47 | * |
| 48 | */ | 48 | */ |
| 49 | 49 | ||
| 50 | /* $Id: deflate.c,v 1.6 1995/05/01 17:23:57 jloup Exp $ */ | 50 | /* $Id: deflate.c,v 1.7 1995/05/02 13:28:18 jloup Exp $ */ |
| 51 | 51 | ||
| 52 | #include "deflate.h" | 52 | #include "deflate.h" |
| 53 | 53 | ||
| @@ -165,7 +165,7 @@ int deflateInit (strm, level) | |||
| 165 | z_stream *strm; | 165 | z_stream *strm; |
| 166 | int level; | 166 | int level; |
| 167 | { | 167 | { |
| 168 | return deflateInit2 (strm, level, DEFLATED, MAX_WBITS, MAX_MEM_LEVEL, 0); | 168 | return deflateInit2 (strm, level, DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, 0); |
| 169 | /* To do: ignore strm->next_in if we use it as window */ | 169 | /* To do: ignore strm->next_in if we use it as window */ |
| 170 | } | 170 | } |
| 171 | 171 | ||
| @@ -344,22 +344,23 @@ int deflate (strm, flush) | |||
| 344 | */ | 344 | */ |
| 345 | if (strm->avail_in != 0 || | 345 | if (strm->avail_in != 0 || |
| 346 | (flush == Z_FINISH && strm->state->status != FINISH_STATE)) { | 346 | (flush == Z_FINISH && strm->state->status != FINISH_STATE)) { |
| 347 | int quit; | ||
| 347 | 348 | ||
| 348 | if (flush == Z_FINISH) { | 349 | if (flush == Z_FINISH) { |
| 349 | strm->state->status = FINISH_STATE; | 350 | strm->state->status = FINISH_STATE; |
| 350 | } | 351 | } |
| 351 | if (strm->state->level <= 3) { | 352 | if (strm->state->level <= 3) { |
| 352 | if (deflate_fast(strm->state, flush)) return Z_OK; | 353 | quit = deflate_fast(strm->state, flush); |
| 353 | } else { | 354 | } else { |
| 354 | if (deflate_slow(strm->state, flush)) return Z_OK; | 355 | quit = deflate_slow(strm->state, flush); |
| 355 | } | 356 | } |
| 356 | /* ??? remember Z_FULL_FLUSH if we didn't have enough space */ | ||
| 357 | if (flush == Z_FULL_FLUSH) { | 357 | if (flush == Z_FULL_FLUSH) { |
| 358 | ct_stored_block(strm->state, (char*)0, 0L, 0); /* special marker */ | 358 | ct_stored_block(strm->state, (char*)0, 0L, 0); /* special marker */ |
| 359 | flush_pending(strm); | 359 | flush_pending(strm); |
| 360 | CLEAR_HASH(strm->state); /* forget history */ | 360 | CLEAR_HASH(strm->state); /* forget history */ |
| 361 | if (strm->avail_out == 0) return Z_OK; | 361 | if (strm->avail_out == 0) return Z_OK; |
| 362 | } | 362 | } |
| 363 | if (quit) return Z_OK; | ||
| 363 | } | 364 | } |
| 364 | Assert(strm->avail_out > 0, "bug2"); | 365 | Assert(strm->avail_out > 0, "bug2"); |
| 365 | 366 | ||
| @@ -3,7 +3,7 @@ | |||
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | /* $Id: example.c,v 1.7 1995/05/01 16:57:22 jloup Exp $ */ | 6 | /* $Id: example.c,v 1.8 1995/05/02 15:52:32 jloup Exp $ */ |
| 7 | 7 | ||
| 8 | #include <stdio.h> | 8 | #include <stdio.h> |
| 9 | #include "zlib.h" | 9 | #include "zlib.h" |
| @@ -12,7 +12,9 @@ | |||
| 12 | # include <string.h> | 12 | # include <string.h> |
| 13 | #endif | 13 | #endif |
| 14 | 14 | ||
| 15 | #ifndef __GO32__ | ||
| 15 | extern void exit __P((int)); | 16 | extern void exit __P((int)); |
| 17 | #endif | ||
| 16 | 18 | ||
| 17 | #define BUFLEN 4096 | 19 | #define BUFLEN 4096 |
| 18 | 20 | ||
| @@ -253,7 +255,7 @@ void test_sync(compr) | |||
| 253 | err = inflateEnd(&d_stream); | 255 | err = inflateEnd(&d_stream); |
| 254 | CHECK_ERR(err, "inflateEnd"); | 256 | CHECK_ERR(err, "inflateEnd"); |
| 255 | 257 | ||
| 256 | printf("after inflateSync(): %s\n", uncompr); | 258 | printf("after inflateSync(): hel%s\n", uncompr); |
| 257 | } | 259 | } |
| 258 | 260 | ||
| 259 | /* =========================================================================== | 261 | /* =========================================================================== |
| @@ -3,7 +3,7 @@ | |||
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | /* $Id: gzio.c,v 1.6 1995/04/30 19:52:21 jloup Exp $ */ | 6 | /* $Id: gzio.c,v 1.7 1995/05/02 12:22:08 jloup Exp $ */ |
| 7 | 7 | ||
| 8 | #include <stdio.h> | 8 | #include <stdio.h> |
| 9 | 9 | ||
| @@ -128,7 +128,7 @@ local gzFile gz_open (path, mode, fd) | |||
| 128 | 128 | ||
| 129 | if (s->mode == 'w') { | 129 | if (s->mode == 'w') { |
| 130 | err = deflateInit2(&(s->stream), Z_DEFAULT_COMPRESSION, | 130 | err = deflateInit2(&(s->stream), Z_DEFAULT_COMPRESSION, |
| 131 | DEFLATED, -MAX_WBITS, MAX_MEM_LEVEL, 0); | 131 | DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, 0); |
| 132 | /* windowBits is passed < 0 to suppress zlib header */ | 132 | /* windowBits is passed < 0 to suppress zlib header */ |
| 133 | 133 | ||
| 134 | s->stream.next_out = s->outbuf = ALLOC(Z_BUFSIZE); | 134 | s->stream.next_out = s->outbuf = ALLOC(Z_BUFSIZE); |
| @@ -221,7 +221,7 @@ gzFile gzdopen (fd, mode) | |||
| 221 | char *mode; | 221 | char *mode; |
| 222 | { | 222 | { |
| 223 | char name[20]; | 223 | char name[20]; |
| 224 | sprintf(name, "_fd:%d_", fd); /* for debugging */ | 224 | sprintf(name, "<fd:%d>", fd); /* for debugging */ |
| 225 | 225 | ||
| 226 | return gz_open (name, mode, fd); | 226 | return gz_open (name, mode, fd); |
| 227 | } | 227 | } |
| @@ -145,7 +145,7 @@ int f; | |||
| 145 | { | 145 | { |
| 146 | case METHOD: | 146 | case METHOD: |
| 147 | NEEDBYTE | 147 | NEEDBYTE |
| 148 | if (((z->state->sub.method = NEXTBYTE) & 0xf != DEFLATED)) | 148 | if (((z->state->sub.method = NEXTBYTE) & 0xf) != DEFLATED) |
| 149 | { | 149 | { |
| 150 | z->state->mode = BAD; | 150 | z->state->mode = BAD; |
| 151 | z->msg = "unknown compression method"; | 151 | z->msg = "unknown compression method"; |
| @@ -243,7 +243,10 @@ z_stream *z; | |||
| 243 | if (z == Z_NULL || z->state == Z_NULL) | 243 | if (z == Z_NULL || z->state == Z_NULL) |
| 244 | return Z_STREAM_ERROR; | 244 | return Z_STREAM_ERROR; |
| 245 | if (z->state->mode != BAD) | 245 | if (z->state->mode != BAD) |
| 246 | { | ||
| 247 | z->state->mode = BAD; | ||
| 246 | z->state->sub.marker = 0; | 248 | z->state->sub.marker = 0; |
| 249 | } | ||
| 247 | if ((n = z->avail_in) == 0) | 250 | if ((n = z->avail_in) == 0) |
| 248 | return Z_BUF_ERROR; | 251 | return Z_BUF_ERROR; |
| 249 | p = z->next_in; | 252 | p = z->next_in; |
| @@ -252,10 +255,12 @@ z_stream *z; | |||
| 252 | /* search */ | 255 | /* search */ |
| 253 | while (n && m < 4) | 256 | while (n && m < 4) |
| 254 | { | 257 | { |
| 255 | if (*p == (m < 2 ? 0 : 0xff)) | 258 | if (*p == (Byte)(m < 2 ? 0 : 0xff)) |
| 256 | m++; | 259 | m++; |
| 257 | else if (*p || m > 2) | 260 | else if (*p) |
| 258 | m = 0; | 261 | m = 0; |
| 262 | else | ||
| 263 | m = 4 - m; | ||
| 259 | p++, n--; | 264 | p++, n--; |
| 260 | } | 265 | } |
| 261 | 266 | ||
| @@ -13,12 +13,14 @@ | |||
| 13 | * or in pipe mode. | 13 | * or in pipe mode. |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | /* $Id: minigzip.c,v 1.3 1995/04/29 14:27:21 jloup Exp $ */ | 16 | /* $Id: minigzip.c,v 1.4 1995/05/02 15:54:22 jloup Exp $ */ |
| 17 | 17 | ||
| 18 | #include <stdio.h> | 18 | #include <stdio.h> |
| 19 | #include "zlib.h" | 19 | #include "zlib.h" |
| 20 | 20 | ||
| 21 | #ifndef __GO32__ | ||
| 21 | extern void exit __P((int)); | 22 | extern void exit __P((int)); |
| 23 | #endif | ||
| 22 | extern int unlink __P((const char *)); | 24 | extern int unlink __P((const char *)); |
| 23 | 25 | ||
| 24 | #ifdef STDC | 26 | #ifdef STDC |
| @@ -3,7 +3,7 @@ | |||
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | /* $Id: zconf.h,v 1.10 1995/04/30 19:27:14 jloup Exp $ */ | 6 | /* $Id: zconf.h,v 1.11 1995/05/02 13:07:21 jloup Exp $ */ |
| 7 | 7 | ||
| 8 | #ifndef _ZCONF_H | 8 | #ifndef _ZCONF_H |
| 9 | #define _ZCONF_H | 9 | #define _ZCONF_H |
| @@ -32,6 +32,7 @@ | |||
| 32 | # define STDC | 32 | # define STDC |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | /* Maximum value for memLevel in deflateInit2 */ | ||
| 35 | #ifndef MAX_MEM_LEVEL | 36 | #ifndef MAX_MEM_LEVEL |
| 36 | # ifdef MAXSEG_64K | 37 | # ifdef MAXSEG_64K |
| 37 | # define MAX_MEM_LEVEL 8 | 38 | # define MAX_MEM_LEVEL 8 |
| @@ -40,10 +41,24 @@ | |||
| 40 | # endif | 41 | # endif |
| 41 | #endif | 42 | #endif |
| 42 | 43 | ||
| 44 | /* Maximum value for windowBits in deflateInit2 and inflateInit2 */ | ||
| 43 | #ifndef MAX_WBITS | 45 | #ifndef MAX_WBITS |
| 44 | # define MAX_WBITS 15 /* 32K LZ77 window */ | 46 | # define MAX_WBITS 15 /* 32K LZ77 window */ |
| 45 | #endif | 47 | #endif |
| 46 | 48 | ||
| 49 | /* The memory requirements for deflate are (in bytes): | ||
| 50 | 1 << (windowBits+2) + 1 << (memLevel+9) | ||
| 51 | that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) | ||
| 52 | plus a few kilobytes for small objects. For example, if you want to reduce | ||
| 53 | the default memory requirements from 256K to 128K, compile with | ||
| 54 | make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" | ||
| 55 | Of course this will generally degrade compression (there's no free lunch). | ||
| 56 | |||
| 57 | The memory requirements for inflate are (in bytes) 1 << windowBits | ||
| 58 | that is, 32K for windowBits=15 (default value) plus a few kilobytes | ||
| 59 | for small objects. | ||
| 60 | */ | ||
| 61 | |||
| 47 | /* Type declarations */ | 62 | /* Type declarations */ |
| 48 | 63 | ||
| 49 | #ifndef __P /* function prototypes */ | 64 | #ifndef __P /* function prototypes */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* zlib.h -- interface of the 'zlib' general purpose compression library | 1 | /* zlib.h -- interface of the 'zlib' general purpose compression library |
| 2 | version 0.9 April 30th, 1995. | 2 | version 0.91 May 2nd, 1995. |
| 3 | 3 | ||
| 4 | Copyright (C) 1995 Jean-loup Gailly and Mark Adler | 4 | Copyright (C) 1995 Jean-loup Gailly and Mark Adler |
| 5 | 5 | ||
| @@ -28,7 +28,7 @@ | |||
| 28 | 28 | ||
| 29 | #include "zconf.h" | 29 | #include "zconf.h" |
| 30 | 30 | ||
| 31 | #define ZLIB_VERSION "0.9" | 31 | #define ZLIB_VERSION "0.91" |
| 32 | 32 | ||
| 33 | /* | 33 | /* |
| 34 | The 'zlib' compression library provides in-memory compression and | 34 | The 'zlib' compression library provides in-memory compression and |
| @@ -335,7 +335,8 @@ extern int deflateInit2 __P((z_stream *strm, | |||
| 335 | The memLevel parameter specifies how much memory should be allocated | 335 | The memLevel parameter specifies how much memory should be allocated |
| 336 | for the internal compression state. memLevel=1 uses minimum memory but | 336 | for the internal compression state. memLevel=1 uses minimum memory but |
| 337 | is slow and reduces compression ratio; memLevel=9 uses maximum memory | 337 | is slow and reduces compression ratio; memLevel=9 uses maximum memory |
| 338 | for optimal speed. The default value is 8. | 338 | for optimal speed. The default value is 8. See zconf.h for total memory |
| 339 | usage as a function of windowBits and memLevel. | ||
| 339 | 340 | ||
| 340 | The strategy parameter is used to tune the compression algorithm. Use | 341 | The strategy parameter is used to tune the compression algorithm. Use |
| 341 | the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data | 342 | the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data |
| @@ -3,13 +3,15 @@ | |||
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | /* $Id: zutil.c,v 1.6 1995/04/29 14:54:02 jloup Exp $ */ | 6 | /* $Id: zutil.c,v 1.7 1995/05/02 15:54:47 jloup Exp $ */ |
| 7 | 7 | ||
| 8 | #include <stdio.h> | 8 | #include <stdio.h> |
| 9 | 9 | ||
| 10 | #include "zutil.h" | 10 | #include "zutil.h" |
| 11 | 11 | ||
| 12 | #ifndef __GO32__ | ||
| 12 | extern void exit __P((int)); | 13 | extern void exit __P((int)); |
| 14 | #endif | ||
| 13 | 15 | ||
| 14 | char *zlib_version = ZLIB_VERSION; | 16 | char *zlib_version = ZLIB_VERSION; |
| 15 | 17 | ||
| @@ -55,8 +57,9 @@ void zmemzero(dest, len) | |||
| 55 | } | 57 | } |
| 56 | #endif | 58 | #endif |
| 57 | 59 | ||
| 58 | #if defined(MSDOS) && !defined(__SMALL__) && !defined(M_I86SM) | 60 | #if defined(__TURBOC__) && !defined(__SMALL__) |
| 59 | # ifdef __TURBOC__ | 61 | |
| 62 | # define MY_ZCALLOC | ||
| 60 | 63 | ||
| 61 | /* Turbo C malloc() does not allow dynamic allocation of 64K bytes | 64 | /* Turbo C malloc() does not allow dynamic allocation of 64K bytes |
| 62 | * and farmalloc(64K) returns a pointer with an offset of 8, so we | 65 | * and farmalloc(64K) returns a pointer with an offset of 8, so we |
| @@ -124,8 +127,11 @@ void zcfree (voidp opaque, voidp ptr) | |||
| 124 | ptr = opaque; /* just to make some compilers happy */ | 127 | ptr = opaque; /* just to make some compilers happy */ |
| 125 | z_error("zcfree: ptr not found"); | 128 | z_error("zcfree: ptr not found"); |
| 126 | } | 129 | } |
| 130 | #endif /* __TURBOC__ */ | ||
| 131 | |||
| 132 | #if defined(M_I86CM) || defined(M_I86LM) /* MSC compact or large model */ | ||
| 127 | 133 | ||
| 128 | # else /* MSC */ | 134 | # define MY_ZCALLOC |
| 129 | 135 | ||
| 130 | #if (!defined(_MSC_VER) || (_MSC_VER < 600)) | 136 | #if (!defined(_MSC_VER) || (_MSC_VER < 600)) |
| 131 | # define _halloc halloc | 137 | # define _halloc halloc |
| @@ -144,12 +150,15 @@ void zcfree (voidp opaque, voidp ptr) | |||
| 144 | _hfree(ptr); | 150 | _hfree(ptr); |
| 145 | } | 151 | } |
| 146 | 152 | ||
| 147 | # endif /* __TURBOC__ ? */ | 153 | #endif /* defined(M_I86CM) || defined(M_I86LM) */ |
| 148 | 154 | ||
| 149 | #else /* !MSDOS */ | ||
| 150 | 155 | ||
| 156 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ | ||
| 157 | |||
| 158 | #ifndef __GO32__ | ||
| 151 | extern voidp calloc __P((uInt items, uInt size)); | 159 | extern voidp calloc __P((uInt items, uInt size)); |
| 152 | extern void free __P((voidp ptr)); | 160 | extern void free __P((voidp ptr)); |
| 161 | #endif | ||
| 153 | 162 | ||
| 154 | voidp zcalloc (opaque, items, size) | 163 | voidp zcalloc (opaque, items, size) |
| 155 | voidp opaque; | 164 | voidp opaque; |
| @@ -166,4 +175,4 @@ void zcfree (opaque, ptr) | |||
| 166 | free(ptr); | 175 | free(ptr); |
| 167 | } | 176 | } |
| 168 | 177 | ||
| 169 | #endif /* MSDOS */ | 178 | #endif /* MY_ZCALLOC */ |
| @@ -8,7 +8,7 @@ | |||
| 8 | subject to change. Applications should only use zlib.h. | 8 | subject to change. Applications should only use zlib.h. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | /* $Id: zutil.h,v 1.7 1995/04/30 10:55:33 jloup Exp $ */ | 11 | /* $Id: zutil.h,v 1.8 1995/05/02 15:44:46 jloup Exp $ */ |
| 12 | 12 | ||
| 13 | #ifndef _Z_UTIL_H | 13 | #ifndef _Z_UTIL_H |
| 14 | #define _Z_UTIL_H | 14 | #define _Z_UTIL_H |
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | #ifdef MSDOS | 18 | #ifdef MSDOS |
| 19 | # include <stddef.h> | 19 | # include <stddef.h> |
| 20 | # include <errno.h> | ||
| 20 | #else | 21 | #else |
| 21 | extern int errno; | 22 | extern int errno; |
| 22 | #endif | 23 | #endif |
| @@ -43,7 +44,14 @@ extern char *z_errmsg[]; /* indexed by 1-zlib_error */ | |||
| 43 | #define DEFLATED 8 | 44 | #define DEFLATED 8 |
| 44 | 45 | ||
| 45 | #define DEF_WBITS 15 | 46 | #define DEF_WBITS 15 |
| 46 | /* default WBITS for decompression. MAX_WBITS is useful for compression only */ | 47 | /* default windowBits for decompression. MAX_WBITS is for compression only */ |
| 48 | |||
| 49 | #if MAX_MEM_LEVEL >= 8 | ||
| 50 | # define DEF_MEM_LEVEL 8 | ||
| 51 | #else | ||
| 52 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL | ||
| 53 | #endif | ||
| 54 | /* default memLevel */ | ||
| 47 | 55 | ||
| 48 | #define STORED_BLOCK 0 | 56 | #define STORED_BLOCK 0 |
| 49 | #define STATIC_TREES 1 | 57 | #define STATIC_TREES 1 |
