Compare commits
	
		
			5 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | ebd3c2c0e7 | ||
|   | ff11b0a61f | ||
|   | e26a448e96 | ||
|   | 423eb40306 | ||
|   | 8a2acbffc8 | 
							
								
								
									
										59
									
								
								ChangeLog
									
									
									
									
									
								
							
							
						
						
									
										59
									
								
								ChangeLog
									
									
									
									
									
								
							| @@ -1,7 +1,64 @@ | ||||
|  | ||||
| 		ChangeLog file for zlib | ||||
|  | ||||
| Changes in 1.0 (15 Jan 96) | ||||
| Changes in 1.0.5 (3 Jan 98) | ||||
| - Fix inflate to terminate gracefully when fed corrupted or invalid data | ||||
| - Use const for rommable constants in inflate | ||||
| - Eliminate memory leaks on error conditions in inflate | ||||
| - Removed some vestigial code in inflate | ||||
| - Update web address in README | ||||
|  | ||||
| Changes in 1.0.4 (24 Jul 96) | ||||
| - In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF | ||||
|   bit, so the decompressor could decompress all the correct data but went | ||||
|   on to attempt decompressing extra garbage data. This affected minigzip too. | ||||
| - zlibVersion and gzerror return const char* (needed for DLL) | ||||
| - port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno) | ||||
| - use z_error only for DEBUG (avoid problem with DLLs) | ||||
|  | ||||
| Changes in 1.0.3 (2 Jul 96) | ||||
| - use z_streamp instead of z_stream *, which is now a far pointer in MSDOS | ||||
|   small and medium models; this makes the library incompatible with previous | ||||
|   versions for these models. (No effect in large model or on other systems.) | ||||
| - return OK instead of BUF_ERROR if previous deflate call returned with | ||||
|   avail_out as zero but there is nothing to do | ||||
| - added memcmp for non STDC compilers | ||||
| - define NO_DUMMY_DECL for more Mac compilers (.h files merged incorrectly) | ||||
| - define __32BIT__ if __386__ or i386 is defined (pb. with Watcom and SCO) | ||||
| - better check for 16-bit mode MSC (avoids problem with Symantec) | ||||
|  | ||||
| Changes in 1.0.2 (23 May 96) | ||||
| - added Windows DLL support | ||||
| - added a function zlibVersion (for the DLL support) | ||||
| - fixed declarations using Bytef in infutil.c (pb with MSDOS medium model) | ||||
| - Bytef is define's instead of typedef'd only for Borland C | ||||
| - avoid reading uninitialized memory in example.c | ||||
| - mention in README that the zlib format is now RFC1950 | ||||
| - updated Makefile.dj2 | ||||
| - added algorithm.doc | ||||
|  | ||||
| Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion] | ||||
| - fix array overlay in deflate.c which sometimes caused bad compressed data | ||||
| - fix inflate bug with empty stored block | ||||
| - fix MSDOS medium model which was broken in 0.99 | ||||
| - fix deflateParams() which could generated bad compressed data. | ||||
| - Bytef is define'd instead of typedef'ed (work around Borland bug) | ||||
| - added an INDEX file | ||||
| - new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32), | ||||
|   Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas) | ||||
| - speed up adler32 for modern machines without auto-increment | ||||
| - added -ansi for IRIX in configure | ||||
| - static_init_done in trees.c is an int | ||||
| - define unlink as delete for VMS | ||||
| - fix configure for QNX | ||||
| - add configure branch for SCO and HPUX | ||||
| - avoid many warnings (unused variables, dead assignments, etc...) | ||||
| - no fdopen for BeOS | ||||
| - fix the Watcom fix for 32 bit mode (define FAR as empty) | ||||
| - removed redefinition of Byte for MKWERKS | ||||
| - work around an MWKERKS bug (incorrect merge of all .h files) | ||||
|  | ||||
| Changes in 0.99 (27 Jan 96) | ||||
| - allow preset dictionary shared between compressor and decompressor | ||||
| - allow compression level 0 (no compression) | ||||
| - add deflateParams in zlib.h: allow dynamic change of compression level | ||||
|   | ||||
							
								
								
									
										51
									
								
								INDEX
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								INDEX
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| ChangeLog	history of changes | ||||
| INDEX		this file | ||||
| Make_vms.com	script for Vax/VMS | ||||
| Makefile	makefile for Unix (generated by configure) | ||||
| Makefile.b32	makefile for Borland C++   32-bit | ||||
| Makefile.bor	makefile for Borland C/C++ 16-bit | ||||
| Makefile.dj2	makefile for DJGPP 2.x | ||||
| Makefile.in	makefile for Unix (template for configure) | ||||
| Makefile.msc	makefile for Microsoft C 16-bit | ||||
| Makefile.riscos makefile for RISCOS | ||||
| Makefile.sas	makefile for Amiga SAS/C | ||||
| Makefile.tc	makefile for Turbo C | ||||
| Makefile.wat	makefile for Watcom C | ||||
| README		guess what | ||||
| algorithm.doc	description of the compression & decompression algorithms | ||||
| configure	configure script for Unix | ||||
| descrip.mms	makefile for Vax/VMS | ||||
| zlib.def        definition file for Windows DLL | ||||
| zlib.rc         definition file for Windows DLL | ||||
|  | ||||
|  | ||||
| 		zlib public header files (must be kept): | ||||
| zconf.h | ||||
| zlib.h | ||||
|  | ||||
| 		private source files used to build the zlib library: | ||||
| adler32.c | ||||
| compress.c | ||||
| crc32.c | ||||
| deflate.c | ||||
| deflate.h | ||||
| gzio.c | ||||
| infblock.c | ||||
| infblock.h | ||||
| infcodes.c | ||||
| infcodes.h | ||||
| inffast.c | ||||
| inffast.h | ||||
| inflate.c | ||||
| inftrees.c | ||||
| inftrees.h | ||||
| infutil.c | ||||
| infutil.h | ||||
| trees.c | ||||
| uncompr.c | ||||
| zutil.c | ||||
| zutil.h | ||||
|  | ||||
| 		source files for sample programs: | ||||
| example.c | ||||
| minigzip.c | ||||
							
								
								
									
										12
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								Makefile
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | ||||
| # Makefile for zlib | ||||
| # Copyright (C) 1995-1996 Jean-loup Gailly. | ||||
| # Copyright (C) 1995-1998 Jean-loup Gailly. | ||||
| # For conditions of distribution and use, see copyright notice in zlib.h  | ||||
|  | ||||
| # To compile and test, type: | ||||
| @@ -22,7 +22,7 @@ CFLAGS=-O | ||||
| LDFLAGS=-L. -lz | ||||
| LDSHARED=$(CC) | ||||
|  | ||||
| VER=1.0 | ||||
| VER=1.0.5 | ||||
| LIBS=libz.a | ||||
|  | ||||
| AR=ar rc | ||||
| @@ -37,8 +37,8 @@ OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | ||||
|  | ||||
| TEST_OBJS = example.o minigzip.o | ||||
|  | ||||
| DISTFILES = README ChangeLog configure Makefile.in Makefile Makefile.msc \ | ||||
| 	    Makefile.bor Makefile.tc Make_vms.com descrip.mms *.[ch] | ||||
| DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] descrip.mms \ | ||||
| 	    zlib.def zlib.rc algorithm.doc  *.[ch] | ||||
|  | ||||
| all: example minigzip | ||||
|  | ||||
| @@ -86,8 +86,8 @@ clean: | ||||
|  | ||||
| zip: | ||||
| 	mv Makefile Makefile~; cp -p Makefile.in Makefile | ||||
| 	v=`sed -n -e 's/\./-/' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ | ||||
| 	zip -ul9 zlib-$$v $(DISTFILES) | ||||
| 	v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ | ||||
| 	zip -ul9 zlib$$v $(DISTFILES) | ||||
| 	mv Makefile~ Makefile | ||||
|  | ||||
| dist: | ||||
|   | ||||
							
								
								
									
										104
									
								
								Makefile.b32
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										104
									
								
								Makefile.b32
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,104 @@ | ||||
| # Makefile for zlib | ||||
| # Borland C++    | ||||
|  | ||||
| # This version of the zlib makefile was adapted by Chris Young for use | ||||
| # with Borland C 4.5x with the Dos Power Pack for a 32-bit protected mode | ||||
| # flat memory model.  It was created for use with POV-Ray ray tracer and | ||||
| # you may choose to edit the CFLAGS to suit your needs but the | ||||
| # switches -WX and -DMSDOS are required. | ||||
| # -- Chris Young 76702.1655@compuserve.com | ||||
|  | ||||
| # To use, do "make -fmakefile.b32" | ||||
|  | ||||
| # See zconf.h for details about the memory requirements. | ||||
|  | ||||
| # ------------- Borland C++ ------------- | ||||
| MODEL=-WX  | ||||
| CFLAGS= $(MODEL) -P-C -K -N- -k- -d -3 -r- -v- -f -DMSDOS | ||||
| CC=bcc32 | ||||
| LD=bcc32 | ||||
| LIB=tlib | ||||
| LDFLAGS= $(MODEL) | ||||
| O=.obj | ||||
|  | ||||
| # variables | ||||
| OBJ1 = adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) \ | ||||
|   trees$(O) | ||||
| OBJP1 = adler32$(O)+compress$(O)+crc32$(O)+gzio$(O)+uncompr$(O)+deflate$(O)+\ | ||||
|   trees$(O) | ||||
| OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \ | ||||
|   infutil$(O) inffast$(O) | ||||
| OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ | ||||
|   infutil$(O)+inffast$(O) | ||||
|  | ||||
| all: test | ||||
|  | ||||
| adler32.obj: adler32.c zutil.h zlib.h zconf.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| compress.obj: compress.c zlib.h zconf.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| crc32.obj: crc32.c zutil.h zlib.h zconf.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| gzio.obj: gzio.c zutil.h zlib.h zconf.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| infblock.obj: infblock.c zutil.h zlib.h zconf.h infblock.h inftrees.h\ | ||||
|    infcodes.h infutil.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| infcodes.obj: infcodes.c zutil.h zlib.h zconf.h inftrees.h infutil.h\ | ||||
|    infcodes.h inffast.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| inflate.obj: inflate.c zutil.h zlib.h zconf.h infblock.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| infutil.obj: infutil.c zutil.h zlib.h zconf.h inftrees.h infutil.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| trees.obj: trees.c deflate.h zutil.h zlib.h zconf.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| uncompr.obj: uncompr.c zlib.h zconf.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| zutil.obj: zutil.c zutil.h zlib.h zconf.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| example.obj: example.c zlib.h zconf.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| minigzip.obj: minigzip.c zlib.h zconf.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| # we must cut the command line to fit in the MS/DOS 128 byte limit: | ||||
| zlib.lib: $(OBJ1) $(OBJ2) | ||||
| 	del zlib.lib | ||||
| 	$(LIB) zlib +$(OBJP1) | ||||
| 	$(LIB) zlib +$(OBJP2) | ||||
|  | ||||
| example.exe: example.obj zlib.lib | ||||
| 	$(LD) $(LDFLAGS) example.obj zlib.lib | ||||
|  | ||||
| minigzip.exe: minigzip.obj zlib.lib | ||||
| 	$(LD) $(LDFLAGS) minigzip.obj zlib.lib | ||||
|  | ||||
| test: example.exe minigzip.exe | ||||
| 	example | ||||
| 	echo hello world | minigzip | minigzip -d  | ||||
|  | ||||
| #clean: | ||||
| #	del *.obj | ||||
| #	del *.exe | ||||
							
								
								
									
										93
									
								
								Makefile.dj2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								Makefile.dj2
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,93 @@ | ||||
| # Makefile for zlib.  Modified for djgpp v2.0 by F. J. Donahoe, 3/15/96. | ||||
| # Copyright (C) 1995-1996 Jean-loup Gailly. | ||||
| # For conditions of distribution and use, see copyright notice in zlib.h  | ||||
|  | ||||
| # To compile, or to compile and test, type: | ||||
| #  | ||||
| #   make -fmakefile.dj2;  make test -fmakefile.dj2 | ||||
| #  | ||||
| # To install libz.a, zconf.h and zlib.h in the djgpp directories, type: | ||||
| #  | ||||
| #    make install -fmakefile.dj2 | ||||
| #  | ||||
| # after first defining LIBRARY_PATH and INCLUDE_PATH in djgpp.env as | ||||
| # in the sample below if the pattern of the DJGPP distribution is to | ||||
| # be followed.  Remember that, while <sp>'es around <=> are ignored in | ||||
| # makefiles, they are *not* in batch files or in djgpp.env. | ||||
| # - - - - - | ||||
| # [make] | ||||
| # INCLUDE_PATH=%\>;INCLUDE_PATH%%\DJDIR%\include | ||||
| # LIBRARY_PATH=%\>;LIBRARY_PATH%%\DJDIR%\lib | ||||
| # BUTT=-m486 | ||||
| # - - - - - | ||||
| # Alternately, these variables may be defined below, overriding the values | ||||
| # in djgpp.env, as | ||||
| INCLUDE_PATH=c:\usr\include | ||||
|  | ||||
| CC=gcc | ||||
|  | ||||
| #CFLAGS=-MMD -O | ||||
| #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 | ||||
| #CFLAGS=-MMD -g -DDEBUG | ||||
| CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ | ||||
|              -Wstrict-prototypes -Wmissing-prototypes | ||||
|  | ||||
| # If cp.exe is not found, replace with copy /Y . | ||||
| CP=cp -f | ||||
| # If install.exe is not found, replace with $(CP). | ||||
| INSTALL=install | ||||
| # The default value of RM is "rm -f."  If "rm.exe" is not found, uncomment: | ||||
| # RM=del | ||||
| LDLIBS=-L. -lz | ||||
| LD=$(CC) -s -o | ||||
| LDSHARED=$(CC) | ||||
|  | ||||
| INCL=zlib.h zconf.h | ||||
| LIBS=libz.a | ||||
|  | ||||
| AR=ar rcs | ||||
|  | ||||
| prefix=/usr/local | ||||
| exec_prefix = $(prefix) | ||||
|  | ||||
| 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 | ||||
|  | ||||
| all: example.exe minigzip.exe | ||||
|  | ||||
| test: all | ||||
| 	./example | ||||
| 	echo hello world | .\minigzip | .\minigzip -d  | ||||
|  | ||||
| %.o : %.c | ||||
| 	$(CC) $(CFLAGS) -c $< -o $@ | ||||
|  | ||||
| libz.a: $(OBJS) | ||||
| 	$(AR) $@ $(OBJS) | ||||
|  | ||||
| %.exe : %.o $(LIBS) | ||||
| 	$(LD) $@ $< $(LDLIBS) | ||||
|  | ||||
| # INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env . | ||||
|  | ||||
| .PHONY : uninstall clean | ||||
|  | ||||
| install: $(INCL) $(LIBS) | ||||
| 	-@if not exist $(INCLUDE_PATH)\nul mkdir $(INCLUDE_PATH) | ||||
| 	-@if not exist $(LIBRARY_PATH)\nul mkdir $(LIBRARY_PATH) | ||||
| 	for %%f in ($(INCL)) do $(INSTALL) %%f $(INCLUDE_PATH) | ||||
| 	for %%p in ($(LIBS)) do $(INSTALL) %%p $(LIBRARY_PATH) | ||||
|  | ||||
| uninstall: | ||||
| 	for %%f in ($(INCL)) do $(RM) $(INCLUDE_PATH)\%%f | ||||
| 	for %%p in ($(LIBS)) do $(RM) $(LIBRARY_PATH)\%%p | ||||
|  | ||||
| clean: | ||||
| 	for %%p in (*.d *.o *.exe libz.a libz.so* foo.gz) do $(RM) %%p | ||||
|  | ||||
| DEPS := $(wildcard *.d) | ||||
| ifneq ($(DEPS),) | ||||
| include $(DEPS) | ||||
| endif | ||||
							
								
								
									
										12
									
								
								Makefile.in
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								Makefile.in
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | ||||
| # Makefile for zlib | ||||
| # Copyright (C) 1995-1996 Jean-loup Gailly. | ||||
| # Copyright (C) 1995-1998 Jean-loup Gailly. | ||||
| # For conditions of distribution and use, see copyright notice in zlib.h  | ||||
|  | ||||
| # To compile and test, type: | ||||
| @@ -22,7 +22,7 @@ CFLAGS=-O | ||||
| LDFLAGS=-L. -lz | ||||
| LDSHARED=$(CC) | ||||
|  | ||||
| VER=1.0 | ||||
| VER=1.0.5 | ||||
| LIBS=libz.a | ||||
|  | ||||
| AR=ar rc | ||||
| @@ -37,8 +37,8 @@ OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | ||||
|  | ||||
| TEST_OBJS = example.o minigzip.o | ||||
|  | ||||
| DISTFILES = README ChangeLog configure Makefile.in Makefile Makefile.msc \ | ||||
| 	    Makefile.bor Makefile.tc Make_vms.com descrip.mms *.[ch] | ||||
| DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] descrip.mms \ | ||||
| 	    zlib.def zlib.rc algorithm.doc  *.[ch] | ||||
|  | ||||
| all: example minigzip | ||||
|  | ||||
| @@ -86,8 +86,8 @@ clean: | ||||
|  | ||||
| zip: | ||||
| 	mv Makefile Makefile~; cp -p Makefile.in Makefile | ||||
| 	v=`sed -n -e 's/\./-/' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ | ||||
| 	zip -ul9 zlib-$$v $(DISTFILES) | ||||
| 	v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ | ||||
| 	zip -ul9 zlib$$v $(DISTFILES) | ||||
| 	mv Makefile~ Makefile | ||||
|  | ||||
| dist: | ||||
|   | ||||
| @@ -28,6 +28,8 @@ OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \ | ||||
| OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ | ||||
|   infutil$(O)+inffast$(O) | ||||
|  | ||||
| all:  zlib.lib example.exe minigzip.exe | ||||
|  | ||||
| adler32.obj: adler32.c zutil.h zlib.h zconf.h | ||||
| 	$(CC) -c $(CFLAGS) $*.c | ||||
|  | ||||
| @@ -80,7 +82,7 @@ minigzip.obj: minigzip.c zlib.h zconf.h | ||||
|  | ||||
| # we must cut the command line to fit in the MS/DOS 128 byte limit: | ||||
| zlib.lib: $(OBJ1) $(OBJ2) | ||||
|         del zlib.lib | ||||
| 	if exist zlib.lib del zlib.lib | ||||
| 	lib zlib $(OBJ1); | ||||
| 	lib zlib $(OBJ2); | ||||
|  | ||||
|   | ||||
							
								
								
									
										46
									
								
								Makefile.riscos
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								Makefile.riscos
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | ||||
| # Project:   zlib_1_03 | ||||
|  | ||||
|  | ||||
| # Toolflags: | ||||
| CCflags = -c -depend !Depend -IC: -g -throwback  -DRISCOS  -fnah  | ||||
| C++flags = -c -depend !Depend -IC: -throwback | ||||
| Linkflags = -aif -c++ -o $@  | ||||
| ObjAsmflags = -throwback -NoCache -depend !Depend | ||||
| CMHGflags =  | ||||
| LibFileflags = -c -l -o $@  | ||||
| Squeezeflags = -o $@ | ||||
|  | ||||
|  | ||||
| # Final targets: | ||||
| @.zlib_lib:   @.o.adler32 @.o.compress @.o.crc32 @.o.deflate @.o.gzio \ | ||||
|         @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil @.o.trees \ | ||||
|         @.o.uncompress @.o.zutil  | ||||
|         LibFile $(LibFileflags) @.o.adler32 @.o.compress @.o.crc32 @.o.deflate \ | ||||
|         @.o.gzio @.o.infblock @.o.infcodes @.o.inffast @.o.inflate @.o.inftrees @.o.infutil \ | ||||
|         @.o.trees @.o.uncompress @.o.zutil  | ||||
| @.test:   @.tests.minigzip @.tests.example  | ||||
|         echo Please run "Test" in directory tests  | ||||
| @.tests.minigzip:   @.o.minigzip @.zlib_lib C:o.Stubs  | ||||
|         Link $(Linkflags) @.o.minigzip @.zlib_lib C:o.Stubs  | ||||
| @.tests.example:   @.o.example @.zlib_lib C:o.Stubs  | ||||
|         Link $(Linkflags) @.o.example @.zlib_lib C:o.Stubs  | ||||
|  | ||||
|  | ||||
| # User-editable dependencies: | ||||
| .c.o: | ||||
|         cc $(ccflags) -o $@ $< | ||||
|  | ||||
| # Static dependencies: | ||||
| @.o.example:   @.tests.c.example | ||||
|         cc $(ccflags) -o @.o.example @.tests.c.example  | ||||
| @.o.minigzip:   @.tests.c.minigzip | ||||
|         cc $(ccflags) -o @.o.minigzip @.tests.c.minigzip  | ||||
|  | ||||
|  | ||||
| # Dynamic dependencies: | ||||
| o.minigzip:	tests.c.minigzip | ||||
| o.minigzip:	h.zlib | ||||
| o.minigzip:	h.zconf | ||||
| o.example:	tests.c.example | ||||
| o.example:	h.zlib | ||||
| o.example:	h.zconf | ||||
							
								
								
									
										64
									
								
								Makefile.sas
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								Makefile.sas
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,64 @@ | ||||
| # SMakefile for zlib | ||||
| # Modified from the standard UNIX Makefile Copyright Jean-loup Gailly | ||||
| # Osma Ahvenlampi <Osma.Ahvenlampi@hut.fi> | ||||
| # Amiga, SAS/C 6.56 & Smake | ||||
|  | ||||
| CC=sc | ||||
| CFLAGS=OPT | ||||
| #CFLAGS=OPT CPU=68030 | ||||
| #CFLAGS=DEBUG=LINE | ||||
| LDFLAGS=LIB z.lib | ||||
|  | ||||
| SCOPTIONS=OPTSCHED OPTINLINE OPTALIAS OPTTIME OPTINLOCAL STRMERGE \ | ||||
|        NOICONS PARMS=BOTH NOSTACKCHECK UTILLIB NOVERSION ERRORREXX  | ||||
|  | ||||
| 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 | ||||
|  | ||||
| all: SCOPTIONS example minigzip | ||||
|  | ||||
| test: all | ||||
| 	`cd`/example | ||||
| 	echo hello world | minigzip | minigzip -d  | ||||
|  | ||||
| install: z.lib | ||||
| 	copy zlib.h zconf.h INCLUDE: clone | ||||
| 	copy z.lib LIB: clone | ||||
|  | ||||
| z.lib: $(OBJS) | ||||
| 	oml z.lib r $(OBJS) | ||||
|  | ||||
| example: example.o z.lib | ||||
| 	$(CC) $(CFLAGS) LINK TO $@ example.o $(LDFLAGS) | ||||
|  | ||||
| minigzip: minigzip.o z.lib | ||||
| 	$(CC) $(CFLAGS) LINK TO $@ minigzip.o $(LDFLAGS) | ||||
|  | ||||
| clean: | ||||
| 	-delete force quiet *.o example minigzip z.lib foo.gz *.lnk SCOPTIONS | ||||
|  | ||||
| SCOPTIONS: Smakefile | ||||
|         copy to $@ <from < | ||||
| $(SCOPTIONS) | ||||
| < | ||||
|  | ||||
| # 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 inffast.h | ||||
| inffast.o: zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h | ||||
| inflate.o: zutil.h zlib.h zconf.h infblock.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 | ||||
							
								
								
									
										103
									
								
								Makefile.wat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										103
									
								
								Makefile.wat
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,103 @@ | ||||
| # Makefile for zlib | ||||
| # Watcom 10a | ||||
|  | ||||
| # This version of the zlib makefile was adapted by Chris Young for use | ||||
| # with Watcom 10a 32-bit protected mode flat memory model.  It was created  | ||||
| # for use with POV-Ray ray tracer and you may choose to edit the CFLAGS to  | ||||
| # suit your needs but the -DMSDOS is required. | ||||
| # -- Chris Young 76702.1655@compuserve.com | ||||
|  | ||||
| # To use, do "wmake -f makefile.wat" | ||||
|  | ||||
| # See zconf.h for details about the memory requirements. | ||||
|  | ||||
| # ------------- Watcom 10a ------------- | ||||
| MODEL=-mf  | ||||
| CFLAGS= $(MODEL) -fpi87 -fp5 -zp4 -5r -w5 -oneatx -DMSDOS | ||||
| CC=wcc386 | ||||
| LD=wcl386 | ||||
| LIB=wlib -b -c  | ||||
| LDFLAGS=  | ||||
| O=.obj | ||||
|  | ||||
| # variables | ||||
| OBJ1=adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O)  | ||||
| OBJ2=trees$(O) zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O)  | ||||
| OBJ3=infutil$(O) inffast$(O) | ||||
| OBJP1=adler32$(O)+compress$(O)+crc32$(O)+gzio$(O)+uncompr$(O)+deflate$(O) | ||||
| OBJP2=trees$(O)+zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O) | ||||
| OBJP3=infutil$(O)+inffast$(O) | ||||
|  | ||||
| all: test | ||||
|  | ||||
| adler32.obj: adler32.c zutil.h zlib.h zconf.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| compress.obj: compress.c zlib.h zconf.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| crc32.obj: crc32.c zutil.h zlib.h zconf.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| gzio.obj: gzio.c zutil.h zlib.h zconf.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| infblock.obj: infblock.c zutil.h zlib.h zconf.h infblock.h inftrees.h & | ||||
|   infcodes.h infutil.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| infcodes.obj: infcodes.c zutil.h zlib.h zconf.h inftrees.h infutil.h & | ||||
|   infcodes.h inffast.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| inflate.obj: inflate.c zutil.h zlib.h zconf.h infblock.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| infutil.obj: infutil.c zutil.h zlib.h zconf.h inftrees.h infutil.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| trees.obj: trees.c deflate.h zutil.h zlib.h zconf.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| uncompr.obj: uncompr.c zlib.h zconf.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| zutil.obj: zutil.c zutil.h zlib.h zconf.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| example.obj: example.c zlib.h zconf.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| minigzip.obj: minigzip.c zlib.h zconf.h | ||||
| 	$(CC) $(CFLAGS) $*.c | ||||
|  | ||||
| # we must cut the command line to fit in the MS/DOS 128 byte limit: | ||||
| zlib.lib: $(OBJ1) $(OBJ2) $(OBJ3)  | ||||
| 	del zlib.lib | ||||
| 	$(LIB) zlib.lib +$(OBJP1) | ||||
| 	$(LIB) zlib.lib +$(OBJP2) | ||||
| 	$(LIB) zlib.lib +$(OBJP3) | ||||
|  | ||||
| example.exe: example.obj zlib.lib | ||||
| 	$(LD) $(LDFLAGS) example.obj zlib.lib | ||||
|  | ||||
| minigzip.exe: minigzip.obj zlib.lib | ||||
| 	$(LD) $(LDFLAGS) minigzip.obj zlib.lib | ||||
|  | ||||
| test: minigzip.exe example.exe | ||||
| 	example | ||||
| 	echo hello world | minigzip | minigzip -d >test | ||||
| 	type test | ||||
|  | ||||
| #clean: | ||||
| #	del *.obj | ||||
| #	del *.exe | ||||
							
								
								
									
										60
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										60
									
								
								README
									
									
									
									
									
								
							| @@ -1,7 +1,9 @@ | ||||
| zlib 1.0 is a general purpose data compression library.  All the code | ||||
| zlib 1.0.5 is a general purpose data compression library.  All the code | ||||
| is reentrant (thread safe).  The data format used by the zlib library | ||||
| is described in the files zlib-3.3.doc, deflate-1.3.doc and | ||||
| gzip-4.3.doc, available in ftp://ftp.uu.net/pub/archiving/zip/doc/ | ||||
| is described by RFCs (Request for Comments) 1950 to 1952 in the files  | ||||
| ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate | ||||
| format) and rfc1952.txt (gzip format). These documents are also available in | ||||
| other formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html | ||||
|  | ||||
| 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 | ||||
| @@ -16,30 +18,19 @@ makefiles such as Makefile.msc; for VMS, use Make_vms.com or descrip.mms. | ||||
|  | ||||
| Questions about zlib should be sent to <zlib@quest.jpl.nasa.gov> or, | ||||
| if this fails, to the addresses given below in the Copyright section. | ||||
| The zlib home page is http://www.cdrom.com/pub/infozip/zlib/ | ||||
|  | ||||
| The changes made in version 1.0.5 are documented in the file ChangeLog. | ||||
| The main changes since 1.0.4 are: | ||||
|  | ||||
| - Fix inflate to terminate gracefully when fed corrupted or invalid data | ||||
| - Use const for rommable constants in inflate | ||||
|  | ||||
|  | ||||
| A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk> | ||||
| is in the CPAN (Comprehensive Perl Archive Network) sites, such as: | ||||
| ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/by-module/Compress/Compress-Zlib* | ||||
|  | ||||
| The changes made in version 1.0 are documented in the file ChangeLog. | ||||
| The main changes since 0.95 are: | ||||
| - allow preset dictionary shared between compressor and decompressor | ||||
| - allow compression level 0 (no compression) | ||||
| - add deflateParams in zlib.h: allow dynamic change of compression level | ||||
|   and compression strategy. | ||||
| - test large buffers and deflateParams in example.c | ||||
| - add optional "configure" to build zlib as a shared library | ||||
| - suppress Makefile.qnx, use configure instead | ||||
| - fixes for 64-bit systems (needed for Alpha and Cray) | ||||
| - declare Z_DEFLATED in zlib.h (possible parameter for deflateInit2) | ||||
| - always return Z_BUF_ERROR when deflate() has nothing to do | ||||
| - deflateInit and inflateInit are now macros to allow version checking | ||||
| - prefix all global functions and types with z_ with -DZ_PREFIX | ||||
| - fix some very unlikely race conditions in multi-threaded environment | ||||
| - several minor fixes for better portability | ||||
| - free in reverse order of allocation to help memory manager | ||||
| - use zlib-1.0/* instead of zlib/* inside the tar.gz | ||||
| - make zlib warning-free with "gcc -O3 -Wall -Wwrite-strings -Wpointer-arith | ||||
|   -Wconversion -Wstrict-prototypes -Wmissing-prototypes" | ||||
| - allow gzread on concatenated .gz files | ||||
| - deflateEnd now returns Z_DATA_ERROR if it was premature | ||||
| - deflate is finally (?) fully deterministic | ||||
|  | ||||
| Notes for some targets: | ||||
|  | ||||
| @@ -47,8 +38,8 @@ Notes for some targets: | ||||
|   avoid any far allocation; it was tested with -DMAX_WBITS=11 -DMAX_MEM_LEVEL=3 | ||||
|  | ||||
| - For 64-bit Iris, deflate.c must be compiled without any optimization. | ||||
|   With -O, one libpng test fails. The test works in 32 bit mode (with the | ||||
|   -32 compiler flag). | ||||
|   With -O, one libpng test fails. The test works in 32 bit mode (with | ||||
|   the -32 compiler flag). The compiler bug has been reported to SGI. | ||||
|  | ||||
| - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1    | ||||
|   it works when compiled with cc. | ||||
| @@ -56,9 +47,14 @@ Notes for some targets: | ||||
| - zlib doesn't work on HP-UX 9.05 with one cc compiler (the one not | ||||
|   accepting the -O option). It works with the other cc compiler. | ||||
|  | ||||
| A Perl interface to zlib written by Paul Marquess <pmarquess@bfsec.bt.co.uk> | ||||
| is in the CPAN (Comprehensive Perl Archive Network) sites, such as: | ||||
| ftp://ftp.cis.ufl.edu/pub/perl/CPAN/modules/by-module/Compress/Compress-Zlib* | ||||
| - To build a Windows DLL version, include in a DLL project zlib.def, zlib.rc | ||||
|   and all .c files except example.c and minigzip.c; compile with -DZLIB_DLL | ||||
|   For help on building a zlib DLL, contact Alessandro Iacopetti | ||||
|   <iaco@email.alessandria.alpcom.it>  http://lisa.unial.it/iaco , | ||||
|   or contact Brad Clarke <bclarke@cyberus.ca>. | ||||
|  | ||||
| - gzdopen is not supported on RISCOS | ||||
|  | ||||
|  | ||||
| Acknowledgments: | ||||
|  | ||||
| @@ -69,7 +65,7 @@ Acknowledgments: | ||||
|  | ||||
| Copyright notice: | ||||
|  | ||||
|  (C) 1995-1996 Jean-loup Gailly and Mark Adler | ||||
|  (C) 1995-1998 Jean-loup Gailly and Mark Adler | ||||
|  | ||||
|   This software is provided 'as-is', without any express or implied | ||||
|   warranty.  In no event will the authors be held liable for any damages | ||||
|   | ||||
							
								
								
									
										16
									
								
								adler32.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								adler32.c
									
									
									
									
									
								
							| @@ -3,7 +3,7 @@ | ||||
|  * For conditions of distribution and use, see copyright notice in zlib.h  | ||||
|  */ | ||||
|  | ||||
| /* $Id: adler32.c,v 1.6 1995/05/03 17:27:08 jloup Exp $ */ | ||||
| /* $Id: adler32.c,v 1.10 1996/05/22 11:52:18 me Exp $ */ | ||||
|  | ||||
| #include "zlib.h" | ||||
|  | ||||
| @@ -11,11 +11,11 @@ | ||||
| #define NMAX 5552 | ||||
| /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ | ||||
|  | ||||
| #define DO1(buf)  {s1 += *buf++; s2 += s1;} | ||||
| #define DO2(buf)  DO1(buf); DO1(buf); | ||||
| #define DO4(buf)  DO2(buf); DO2(buf); | ||||
| #define DO8(buf)  DO4(buf); DO4(buf); | ||||
| #define DO16(buf) DO8(buf); DO8(buf); | ||||
| #define DO1(buf,i)  {s1 += buf[i]; s2 += s1;} | ||||
| #define DO2(buf,i)  DO1(buf,i); DO1(buf,i+1); | ||||
| #define DO4(buf,i)  DO2(buf,i); DO2(buf,i+2); | ||||
| #define DO8(buf,i)  DO4(buf,i); DO4(buf,i+4); | ||||
| #define DO16(buf)   DO8(buf,0); DO8(buf,8); | ||||
|  | ||||
| /* ========================================================================= */ | ||||
| uLong adler32(adler, buf, len) | ||||
| @@ -34,10 +34,12 @@ uLong adler32(adler, buf, len) | ||||
|         len -= k; | ||||
|         while (k >= 16) { | ||||
|             DO16(buf); | ||||
| 	    buf += 16; | ||||
|             k -= 16; | ||||
|         } | ||||
|         if (k != 0) do { | ||||
|             DO1(buf); | ||||
|             s1 += *buf++; | ||||
| 	    s2 += s1; | ||||
|         } while (--k); | ||||
|         s1 %= BASE; | ||||
|         s2 %= BASE; | ||||
|   | ||||
							
								
								
									
										105
									
								
								algorithm.doc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										105
									
								
								algorithm.doc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,105 @@ | ||||
| 1. Compression algorithm (deflate) | ||||
|  | ||||
| The deflation algorithm used by zlib (also zip and gzip) is a variation of | ||||
| LZ77 (Lempel-Ziv 1977, see reference below). It finds duplicated strings in | ||||
| the input data.  The second occurrence of a string is replaced by a | ||||
| pointer to the previous string, in the form of a pair (distance, | ||||
| length).  Distances are limited to 32K bytes, and lengths are limited | ||||
| to 258 bytes. When a string does not occur anywhere in the previous | ||||
| 32K bytes, it is emitted as a sequence of literal bytes.  (In this | ||||
| description, `string' must be taken as an arbitrary sequence of bytes, | ||||
| and is not restricted to printable characters.) | ||||
|  | ||||
| Literals or match lengths are compressed with one Huffman tree, and | ||||
| match distances are compressed with another tree. The trees are stored | ||||
| in a compact form at the start of each block. The blocks can have any | ||||
| size (except that the compressed data for one block must fit in | ||||
| available memory). A block is terminated when deflate() determines that | ||||
| it would be useful to start another block with fresh trees. (This is | ||||
| somewhat similar to the behavior of LZW-based _compress_.) | ||||
|  | ||||
| Duplicated strings are found using a hash table. All input strings of | ||||
| length 3 are inserted in the hash table. A hash index is computed for | ||||
| the next 3 bytes. If the hash chain for this index is not empty, all | ||||
| strings in the chain are compared with the current input string, and | ||||
| the longest match is selected. | ||||
|  | ||||
| The hash chains are searched starting with the most recent strings, to | ||||
| favor small distances and thus take advantage of the Huffman encoding. | ||||
| The hash chains are singly linked. There are no deletions from the | ||||
| hash chains, the algorithm simply discards matches that are too old. | ||||
|  | ||||
| To avoid a worst-case situation, very long hash chains are arbitrarily | ||||
| truncated at a certain length, determined by a runtime option (level | ||||
| parameter of deflateInit). So deflate() does not always find the longest | ||||
| possible match but generally finds a match which is long enough. | ||||
|  | ||||
| deflate() also defers the selection of matches with a lazy evaluation | ||||
| mechanism. After a match of length N has been found, deflate() searches for a | ||||
| longer match at the next input byte. If a longer match is found, the | ||||
| previous match is truncated to a length of one (thus producing a single | ||||
| literal byte) and the longer match is emitted afterwards.  Otherwise, | ||||
| the original match is kept, and the next match search is attempted only | ||||
| N steps later. | ||||
|  | ||||
| The lazy match evaluation is also subject to a runtime parameter. If | ||||
| the current match is long enough, deflate() reduces the search for a longer | ||||
| match, thus speeding up the whole process. If compression ratio is more | ||||
| important than speed, deflate() attempts a complete second search even if | ||||
| the first match is already long enough. | ||||
|  | ||||
| The lazy match evaluation is not performed for the fastest compression | ||||
| modes (level parameter 1 to 3). For these fast modes, new strings | ||||
| are inserted in the hash table only when no match was found, or | ||||
| when the match is not too long. This degrades the compression ratio | ||||
| but saves time since there are both fewer insertions and fewer searches. | ||||
|  | ||||
|  | ||||
| 2. Decompression algorithm (inflate) | ||||
|  | ||||
| The real question is, given a Huffman tree, how to decode fast.  The most | ||||
| important realization is that shorter codes are much more common than | ||||
| longer codes, so pay attention to decoding the short codes fast, and let | ||||
| the long codes take longer to decode. | ||||
|  | ||||
| inflate() sets up a first level table that covers some number of bits of | ||||
| input less than the length of longest code.  It gets that many bits from the | ||||
| stream, and looks it up in the table.  The table will tell if the next | ||||
| code is that many bits or less and how many, and if it is, it will tell | ||||
| the value, else it will point to the next level table for which inflate() | ||||
| grabs more bits and tries to decode a longer code. | ||||
|  | ||||
| How many bits to make the first lookup is a tradeoff between the time it | ||||
| takes to decode and the time it takes to build the table.  If building the | ||||
| table took no time (and if you had infinite memory), then there would only | ||||
| be a first level table to cover all the way to the longest code.  However, | ||||
| building the table ends up taking a lot longer for more bits since short | ||||
| codes are replicated many times in such a table.  What inflate() does is | ||||
| simply to make the number of bits in the first table a variable, and set it | ||||
| for the maximum speed. | ||||
|  | ||||
| inflate() sends new trees relatively often, so it is possibly set for a | ||||
| smaller first level table than an application that has only one tree for | ||||
| all the data.  For inflate, which has 286 possible codes for the | ||||
| literal/length tree, the size of the first table is nine bits.  Also the | ||||
| distance trees have 30 possible values, and the size of the first table is | ||||
| six bits.  Note that for each of those cases, the table ended up one bit | ||||
| longer than the ``average'' code length, i.e. the code length of an | ||||
| approximately flat code which would be a little more than eight bits for | ||||
| 286 symbols and a little less than five bits for 30 symbols.  It would be | ||||
| interesting to see if optimizing the first level table for other | ||||
| applications gave values within a bit or two of the flat code size. | ||||
|  | ||||
|  | ||||
| Jean-loup Gailly        Mark Adler | ||||
| gzip@prep.ai.mit.edu    madler@alumni.caltech.edu | ||||
|  | ||||
|  | ||||
| References: | ||||
|  | ||||
| [LZ77] Ziv J., Lempel A., ``A Universal Algorithm for Sequential Data | ||||
| Compression,'' IEEE Transactions on Information Theory, Vol. 23, No. 3, | ||||
| pp. 337-343. | ||||
|  | ||||
| ``DEFLATE Compressed Data Format Specification'' available in | ||||
| ftp://ds.internic.net/rfc/rfc1951.txt | ||||
| @@ -3,7 +3,7 @@ | ||||
|  * For conditions of distribution and use, see copyright notice in zlib.h  | ||||
|  */ | ||||
|  | ||||
| /* $Id: compress.c,v 1.6 1995/05/03 17:27:08 jloup Exp $ */ | ||||
| /* $Id: compress.c,v 1.10 1996/05/23 16:51:12 me Exp $ */ | ||||
|  | ||||
| #include "zlib.h" | ||||
|  | ||||
| @@ -30,9 +30,10 @@ int compress (dest, destLen, source, sourceLen) | ||||
|  | ||||
|     stream.next_in = (Bytef*)source; | ||||
|     stream.avail_in = (uInt)sourceLen; | ||||
| #ifdef MAXSEG_64K | ||||
|     /* Check for source > 64K on 16-bit machine: */ | ||||
|     if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; | ||||
|  | ||||
| #endif | ||||
|     stream.next_out = dest; | ||||
|     stream.avail_out = (uInt)*destLen; | ||||
|     if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; | ||||
|   | ||||
							
								
								
									
										29
									
								
								configure
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										29
									
								
								configure
									
									
									
									
										vendored
									
									
								
							| @@ -13,6 +13,7 @@ | ||||
| LIBS=libz.a | ||||
| VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` | ||||
| AR=${AR-"ar rc"} | ||||
| RANLIB=${RANLIB-"ranlib"} | ||||
| prefix=${prefix-/usr/local} | ||||
| exec_prefix=${exec_prefix-$prefix} | ||||
|  | ||||
| @@ -36,25 +37,32 @@ else | ||||
|   SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"} | ||||
| 	     CFLAGS=${CFLAGS-"-O2"} | ||||
| 	     LDSHARED=${LDSHARED-"ld"};; | ||||
|   IRIX*)     SFLAGS=${CFLAGS-"-O2 -rpath ."} | ||||
| 	     CFLAGS=${CFLAGS-"-O2"} | ||||
|   IRIX*)     SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."} | ||||
| 	     CFLAGS=${CFLAGS-"-ansi -O2"} | ||||
| 	     LDSHARED=${LDSHARED-"cc -shared"};; | ||||
|   QNX*)      SFLAGS=${CFLAGS-"-4 -O -Q"} | ||||
|              CFLAGS=${CFLAGS-"-4 -O -Q"} | ||||
|   QNX*)      SFLAGS=${CFLAGS-"-4 -O"} | ||||
|              CFLAGS=${CFLAGS-"-4 -O"} | ||||
| 	     LDSHARED=${LDSHARED-"cc"} | ||||
|              LIBS=zlib.lib | ||||
|              RANLIB=${RANLIB-"true"} | ||||
|              AR="cc -A";; | ||||
|   SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "} | ||||
| 	     CFLAGS=${CFLAGS-"-O3"} | ||||
| 	     LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};; | ||||
|   HP-UX*)    SFLAGS=${CFLAGS-"-O +z"} | ||||
| 	     CFLAGS=${CFLAGS-"-O"} | ||||
| 	     LDSHARED=${LDSHARED-"ld -b"} | ||||
| 	     SHAREDLIBS='libz.sl';; | ||||
|   # send working options for other systems to gzip@prep.ai.mit.edu | ||||
|   *)         SFLAGS=${CFLAGS-"-O"} | ||||
| 	     CFLAGS=${CFLAGS-"-O"} | ||||
| 	     LDSHARED=${LDSHARED-"-shared"};; | ||||
| 	     LDSHARED=${LDSHARED-"cc -shared"};; | ||||
|   esac | ||||
| fi | ||||
|  | ||||
| echo Checking for shared library support... | ||||
| # we must test in two steps (cc then ld), required at least on SunOS 4.x | ||||
| if test "`$CC -c $SFLAGS $test.c 2>&1`" = "" && | ||||
|    test "`$LDSHARED -o $test.so $test.o 2>&1`" = ""; then | ||||
| if test "`($CC -c $SFLAGS $test.c) 2>&1`" = "" && | ||||
|    test "`($LDSHARED -o $test.so $test.o) 2>&1`" = ""; then | ||||
|   CFLAGS="$SFLAGS" | ||||
|   LIBS='libz.so.$(VER)' | ||||
|   echo Building shared library libz.so.$VER with $CC. | ||||
| @@ -65,17 +73,14 @@ fi | ||||
| rm -f $test.[co] $test.so | ||||
|  | ||||
| # udpate Makefile | ||||
| # ed -s Makefile <<EOF | ||||
| sed < Makefile.in " | ||||
| /^CC *=/s/=.*/=$CC/ | ||||
| /^CFLAGS *=/s/=.*/=$CFLAGS/ | ||||
| /^LDSHARED *=/s/=.*/=$LDSHARED/ | ||||
| /^LIBS *=/s,=.*,=$LIBS, | ||||
| /^AR *=/s/=.*/=$AR/ | ||||
| /^RANLIB *=/s,=.*,=$RANLIB, | ||||
| /^VER *=/s/=.*/=$VER/ | ||||
| /^prefix *=/s,=.*,=$prefix, | ||||
| /^exec_prefix *=/s,=.*,=$exec_prefix, | ||||
| " > Makefile | ||||
| #w | ||||
| #q | ||||
| #EOF | ||||
|   | ||||
							
								
								
									
										2
									
								
								crc32.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								crc32.c
									
									
									
									
									
								
							| @@ -3,7 +3,7 @@ | ||||
|  * For conditions of distribution and use, see copyright notice in zlib.h  | ||||
|  */ | ||||
|  | ||||
| /* $Id: crc32.c,v 1.4 1995/04/14 14:55:12 jloup Exp $ */ | ||||
| /* $Id: crc32.c,v 1.8 1996/01/30 21:59:10 me Exp $ */ | ||||
|  | ||||
| #include "zlib.h" | ||||
|  | ||||
|   | ||||
							
								
								
									
										186
									
								
								deflate.c
									
									
									
									
									
								
							
							
						
						
									
										186
									
								
								deflate.c
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | ||||
| /* deflate.c -- compress data using the deflation algorithm | ||||
|  * Copyright (C) 1995-1996 Jean-loup Gailly. | ||||
|  * Copyright (C) 1995-1998 Jean-loup Gailly. | ||||
|  * For conditions of distribution and use, see copyright notice in zlib.h  | ||||
|  */ | ||||
|  | ||||
| @@ -47,11 +47,10 @@ | ||||
|  * | ||||
|  */ | ||||
|  | ||||
| /* $Id: deflate.c,v 1.8 1995/05/03 17:27:08 jloup Exp $ */ | ||||
|  | ||||
| #include "deflate.h" | ||||
|  | ||||
| char deflate_copyright[] = " deflate 1.0 Copyright 1995-1996 Jean-loup Gailly "; | ||||
| char deflate_copyright[] = " deflate 1.0.5 Copyright 1995-1998 Jean-loup Gailly "; | ||||
| /* | ||||
|   If you use the zlib library in a product, an acknowledgment is welcome | ||||
|   in the documentation of your product. If for some reason you cannot | ||||
| @@ -62,15 +61,25 @@ char deflate_copyright[] = " deflate 1.0 Copyright 1995-1996 Jean-loup Gailly "; | ||||
| /* =========================================================================== | ||||
|  *  Function prototypes. | ||||
|  */ | ||||
| typedef enum { | ||||
|     need_more,      /* block not completed, need more input or more output */ | ||||
|     block_done,     /* block flush performed */ | ||||
|     finish_started, /* finish started, need only more output at next deflate */ | ||||
|     finish_done     /* finish done, accept no more input or output */ | ||||
| } block_state; | ||||
|  | ||||
| typedef block_state (*compress_func) OF((deflate_state *s, int flush)); | ||||
| /* Compression function. Returns the block state after the call. */ | ||||
|  | ||||
| local void fill_window    OF((deflate_state *s)); | ||||
| local int  deflate_stored OF((deflate_state *s, int flush)); | ||||
| local int  deflate_fast   OF((deflate_state *s, int flush)); | ||||
| local int  deflate_slow   OF((deflate_state *s, int flush)); | ||||
| local block_state deflate_stored OF((deflate_state *s, int flush)); | ||||
| local block_state deflate_fast   OF((deflate_state *s, int flush)); | ||||
| local block_state deflate_slow   OF((deflate_state *s, int flush)); | ||||
| local void lm_init        OF((deflate_state *s)); | ||||
| local int longest_match   OF((deflate_state *s, IPos cur_match)); | ||||
| local uInt longest_match  OF((deflate_state *s, IPos cur_match)); | ||||
| local void putShortMSB    OF((deflate_state *s, uInt b)); | ||||
| local void flush_pending  OF((z_stream *strm)); | ||||
| local int read_buf        OF((z_stream *strm, charf *buf, unsigned size)); | ||||
| local void flush_pending  OF((z_streamp strm)); | ||||
| local int read_buf        OF((z_streamp strm, charf *buf, unsigned size)); | ||||
| #ifdef ASMV | ||||
|       void match_init OF((void)); /* asm code initialization */ | ||||
| #endif | ||||
| @@ -97,9 +106,6 @@ local  void check_match OF((deflate_state *s, IPos start, IPos match, | ||||
|  * See deflate.c for comments about the MIN_MATCH+1. | ||||
|  */ | ||||
|  | ||||
| typedef int (*compress_func) OF((deflate_state *s, int flush)); | ||||
| /* Compressing function */ | ||||
|  | ||||
| /* Values for max_lazy_match, good_match and max_chain_length, depending on | ||||
|  * the desired pack level (0..9). The values given below have been tuned to | ||||
|  * exclude worst case performance for pathological files. Better values may be | ||||
| @@ -157,7 +163,7 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ | ||||
| #define INSERT_STRING(s, str, match_head) \ | ||||
|    (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ | ||||
|     s->prev[(str) & s->w_mask] = match_head = s->head[s->ins_h], \ | ||||
|     s->head[s->ins_h] = (str)) | ||||
|     s->head[s->ins_h] = (Pos)(str)) | ||||
|  | ||||
| /* =========================================================================== | ||||
|  * Initialize the hash table (avoiding 64K overflow for 16 bit systems). | ||||
| @@ -169,7 +175,7 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ | ||||
|  | ||||
| /* ========================================================================= */ | ||||
| int deflateInit_(strm, level, version, stream_size) | ||||
|     z_stream *strm; | ||||
|     z_streamp strm; | ||||
|     int level; | ||||
|     const char *version; | ||||
|     int stream_size; | ||||
| @@ -182,7 +188,7 @@ int deflateInit_(strm, level, version, stream_size) | ||||
| /* ========================================================================= */ | ||||
| int deflateInit2_(strm, level, method, windowBits, memLevel, strategy, | ||||
| 		  version, stream_size) | ||||
|     z_stream *strm; | ||||
|     z_streamp strm; | ||||
|     int  level; | ||||
|     int  method; | ||||
|     int  windowBits; | ||||
| @@ -194,6 +200,11 @@ int deflateInit2_(strm, level, method, windowBits, memLevel, strategy, | ||||
|     deflate_state *s; | ||||
|     int noheader = 0; | ||||
|  | ||||
|     ushf *overlay; | ||||
|     /* We overlay pending_buf and d_buf+l_buf. This works since the average | ||||
|      * output size for (length,distance) codes is <= 24 bits. | ||||
|      */ | ||||
|  | ||||
|     if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || | ||||
|         stream_size != sizeof(z_stream)) { | ||||
| 	return Z_VERSION_ERROR; | ||||
| @@ -239,20 +250,17 @@ int deflateInit2_(strm, level, method, windowBits, memLevel, strategy, | ||||
|  | ||||
|     s->lit_bufsize = 1 << (memLevel + 6); /* 16K elements by default */ | ||||
|  | ||||
|     s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 2*sizeof(ush)); | ||||
|     overlay = (ushf *) ZALLOC(strm, s->lit_bufsize, sizeof(ush)+2); | ||||
|     s->pending_buf = (uchf *) overlay; | ||||
|  | ||||
|     if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || | ||||
|         s->pending_buf == Z_NULL) { | ||||
|         strm->msg = ERR_MSG(Z_MEM_ERROR); | ||||
|         strm->msg = (char*)ERR_MSG(Z_MEM_ERROR); | ||||
|         deflateEnd (strm); | ||||
|         return Z_MEM_ERROR; | ||||
|     } | ||||
|     s->l_buf = (uchf *) &(s->pending_buf[s->lit_bufsize]); | ||||
|     s->d_buf = (ushf *) &(s->pending_buf[2*s->lit_bufsize]); | ||||
|     /* We overlay pending_buf and d_buf+l_buf. This works since the average | ||||
|      * output size for (length,distance) codes is <= 32 bits (worst case | ||||
|      * is 15+15+13=33). d_buf is put last in case sizeof(short)>2. | ||||
|      */ | ||||
|     s->d_buf = overlay + s->lit_bufsize/sizeof(ush); | ||||
|     s->l_buf = s->pending_buf + (1+sizeof(ush))*s->lit_bufsize; | ||||
|  | ||||
|     s->level = level; | ||||
|     s->strategy = strategy; | ||||
| @@ -263,14 +271,14 @@ int deflateInit2_(strm, level, method, windowBits, memLevel, strategy, | ||||
|  | ||||
| /* ========================================================================= */ | ||||
| int deflateSetDictionary (strm, dictionary, dictLength) | ||||
|     z_stream *strm; | ||||
|     z_streamp strm; | ||||
|     const Bytef *dictionary; | ||||
|     uInt  dictLength; | ||||
| { | ||||
|     deflate_state *s; | ||||
|     uInt length = dictLength; | ||||
|     uInt n; | ||||
|     IPos hash_head; | ||||
|     IPos hash_head = 0; | ||||
|  | ||||
|     if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL || | ||||
|         strm->state->status != INIT_STATE) return Z_STREAM_ERROR; | ||||
| @@ -296,12 +304,13 @@ int deflateSetDictionary (strm, dictionary, dictLength) | ||||
|     for (n = 0; n <= length - MIN_MATCH; n++) { | ||||
| 	INSERT_STRING(s, n, hash_head); | ||||
|     } | ||||
|     if (hash_head) hash_head = 0;  /* to make compiler happy */ | ||||
|     return Z_OK; | ||||
| } | ||||
|  | ||||
| /* ========================================================================= */ | ||||
| int deflateReset (strm) | ||||
|     z_stream *strm; | ||||
|     z_streamp strm; | ||||
| { | ||||
|     deflate_state *s; | ||||
|      | ||||
| @@ -331,12 +340,13 @@ int deflateReset (strm) | ||||
|  | ||||
| /* ========================================================================= */ | ||||
| int deflateParams(strm, level, strategy) | ||||
|     z_stream *strm; | ||||
|     z_streamp strm; | ||||
|     int level; | ||||
|     int strategy; | ||||
| { | ||||
|     deflate_state *s; | ||||
|     compress_func func; | ||||
|     int err = Z_OK; | ||||
|  | ||||
|     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; | ||||
|     s = strm->state; | ||||
| @@ -349,11 +359,9 @@ int deflateParams(strm, level, strategy) | ||||
|     } | ||||
|     func = configuration_table[s->level].func; | ||||
|  | ||||
|     if (func != configuration_table[level].func | ||||
| 	&& strm->state->lookahead != 0) { | ||||
|  | ||||
|     if (func != configuration_table[level].func && strm->total_in != 0) { | ||||
| 	/* Flush the last buffer: */ | ||||
| 	(void)(*func)(strm->state, Z_PARTIAL_FLUSH); | ||||
| 	err = deflate(strm, Z_PARTIAL_FLUSH); | ||||
|     } | ||||
|     if (s->level != level) { | ||||
| 	s->level = level; | ||||
| @@ -363,7 +371,7 @@ int deflateParams(strm, level, strategy) | ||||
| 	s->max_chain_length = configuration_table[level].max_chain; | ||||
|     } | ||||
|     s->strategy = strategy; | ||||
|     return Z_OK; | ||||
|     return err; | ||||
| } | ||||
|  | ||||
| /* ========================================================================= | ||||
| @@ -386,7 +394,7 @@ local void putShortMSB (s, b) | ||||
|  * (See also read_buf()). | ||||
|  */ | ||||
| local void flush_pending(strm) | ||||
|     z_stream *strm; | ||||
|     z_streamp strm; | ||||
| { | ||||
|     unsigned len = strm->state->pending; | ||||
|  | ||||
| @@ -406,14 +414,16 @@ local void flush_pending(strm) | ||||
|  | ||||
| /* ========================================================================= */ | ||||
| int deflate (strm, flush) | ||||
|     z_stream *strm; | ||||
|     z_streamp strm; | ||||
|     int flush; | ||||
| { | ||||
|     int old_flush; /* value of flush param for previous deflate call */ | ||||
|     deflate_state *s; | ||||
|  | ||||
|     if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; | ||||
|      | ||||
|     if (strm == Z_NULL || strm->state == Z_NULL || | ||||
| 	flush > Z_FINISH || flush < 0) { | ||||
|         return Z_STREAM_ERROR; | ||||
|     } | ||||
|     s = strm->state; | ||||
|  | ||||
|     if (strm->next_out == Z_NULL || | ||||
| @@ -445,14 +455,23 @@ int deflate (strm, flush) | ||||
| 	if (s->strstart != 0) { | ||||
| 	    putShortMSB(s, (uInt)(strm->adler >> 16)); | ||||
| 	    putShortMSB(s, (uInt)(strm->adler & 0xffff)); | ||||
| 	    strm->adler = 1L; | ||||
| 	} | ||||
| 	strm->adler = 1L; | ||||
|     } | ||||
|  | ||||
|     /* Flush as much pending output as possible */ | ||||
|     if (s->pending != 0) { | ||||
|         flush_pending(strm); | ||||
|         if (strm->avail_out == 0) return Z_OK; | ||||
|         if (strm->avail_out == 0) { | ||||
| 	    /* Since avail_out is 0, deflate will be called again with | ||||
| 	     * more output space, but possibly with both pending and | ||||
| 	     * avail_in equal to zero. There won't be anything to do, | ||||
| 	     * but this is not an error situation so make sure we | ||||
| 	     * return OK instead of BUF_ERROR at next call of deflate: | ||||
|              */ | ||||
| 	    s->last_flush = -1; | ||||
| 	    return Z_OK; | ||||
| 	} | ||||
|  | ||||
|     /* Make sure there is something to do and avoid duplicate consecutive | ||||
|      * flushes. For repeated and useless calls with Z_FINISH, we keep | ||||
| @@ -472,22 +491,27 @@ int deflate (strm, flush) | ||||
|      */ | ||||
|     if (strm->avail_in != 0 || s->lookahead != 0 || | ||||
|         (flush != Z_NO_FLUSH && s->status != FINISH_STATE)) { | ||||
|         int quit; | ||||
|         block_state bstate; | ||||
|  | ||||
|         if (flush == Z_FINISH) { | ||||
| 	bstate = (*(configuration_table[s->level].func))(s, flush); | ||||
|  | ||||
|         if (bstate == finish_started || bstate == finish_done) { | ||||
|             s->status = FINISH_STATE; | ||||
|         } | ||||
| 	quit = (*(configuration_table[s->level].func))(s, flush); | ||||
|  | ||||
|         if (quit || strm->avail_out == 0) return Z_OK; | ||||
|         /* If flush != Z_NO_FLUSH && avail_out == 0, the next call | ||||
|          * of deflate should use the same flush parameter to make sure | ||||
|          * that the flush is complete. So we don't have to output an | ||||
|          * empty block here, this will be done at next call. This also | ||||
|          * ensures that for a very small output buffer, we emit at most | ||||
|          * one empty block. | ||||
|          */ | ||||
|         if (flush != Z_NO_FLUSH && flush != Z_FINISH) { | ||||
|         if (bstate == need_more || bstate == finish_started) { | ||||
| 	    if (strm->avail_out == 0) { | ||||
| 	        s->last_flush = -1; /* avoid BUF_ERROR next call, see above */ | ||||
| 	    } | ||||
| 	    return Z_OK; | ||||
| 	    /* If flush != Z_NO_FLUSH && avail_out == 0, the next call | ||||
| 	     * of deflate should use the same flush parameter to make sure | ||||
| 	     * that the flush is complete. So we don't have to output an | ||||
| 	     * empty block here, this will be done at next call. This also | ||||
| 	     * ensures that for a very small output buffer, we emit at most | ||||
| 	     * one empty block. | ||||
| 	     */ | ||||
| 	} | ||||
|         if (bstate == block_done) { | ||||
|             if (flush == Z_PARTIAL_FLUSH) { | ||||
|                 _tr_align(s); | ||||
|             } else { /* FULL_FLUSH or SYNC_FLUSH */ | ||||
| @@ -500,7 +524,10 @@ int deflate (strm, flush) | ||||
|                 } | ||||
|             } | ||||
|             flush_pending(strm); | ||||
|             if (strm->avail_out == 0) return Z_OK; | ||||
| 	    if (strm->avail_out == 0) { | ||||
| 	      s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */ | ||||
| 	      return Z_OK; | ||||
| 	    } | ||||
|         } | ||||
|     } | ||||
|     Assert(strm->avail_out > 0, "bug2"); | ||||
| @@ -521,7 +548,7 @@ int deflate (strm, flush) | ||||
|  | ||||
| /* ========================================================================= */ | ||||
| int deflateEnd (strm) | ||||
|     z_stream *strm; | ||||
|     z_streamp strm; | ||||
| { | ||||
|     int status; | ||||
|  | ||||
| @@ -542,8 +569,8 @@ int deflateEnd (strm) | ||||
|  | ||||
| /* ========================================================================= */ | ||||
| int deflateCopy (dest, source) | ||||
|     z_stream *dest; | ||||
|     z_stream *source; | ||||
|     z_streamp dest; | ||||
|     z_streamp source; | ||||
| { | ||||
|     if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { | ||||
|         return Z_STREAM_ERROR; | ||||
| @@ -568,7 +595,7 @@ int deflateCopy (dest, source) | ||||
|  * (See also flush_pending()). | ||||
|  */ | ||||
| local int read_buf(strm, buf, size) | ||||
|     z_stream *strm; | ||||
|     z_streamp strm; | ||||
|     charf *buf; | ||||
|     unsigned size; | ||||
| { | ||||
| @@ -630,7 +657,7 @@ local void lm_init (s) | ||||
| /* For 80x86 and 680x0, an optimized version will be provided in match.asm or | ||||
|  * match.S. The code will be functionally equivalent. | ||||
|  */ | ||||
| local int longest_match(s, cur_match) | ||||
| local uInt longest_match(s, cur_match) | ||||
|     deflate_state *s; | ||||
|     IPos cur_match;                             /* current match */ | ||||
| { | ||||
| @@ -673,7 +700,7 @@ local int longest_match(s, cur_match) | ||||
|     /* Do not look for matches beyond the end of the input. This is necessary | ||||
|      * to make deflate deterministic. | ||||
|      */ | ||||
|     if (nice_match > s->lookahead) nice_match = s->lookahead; | ||||
|     if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; | ||||
|  | ||||
|     Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); | ||||
|  | ||||
| @@ -764,7 +791,7 @@ local int longest_match(s, cur_match) | ||||
|     } while ((cur_match = prev[cur_match & wmask]) > limit | ||||
|              && --chain_length != 0); | ||||
|  | ||||
|     if (best_len <= s->lookahead) return best_len; | ||||
|     if ((uInt)best_len <= s->lookahead) return best_len; | ||||
|     return s->lookahead; | ||||
| } | ||||
| #endif /* ASMV */ | ||||
| @@ -914,18 +941,18 @@ local void fill_window(s) | ||||
| /* Same but force premature exit if necessary. */ | ||||
| #define FLUSH_BLOCK(s, eof) { \ | ||||
|    FLUSH_BLOCK_ONLY(s, eof); \ | ||||
|    if (s->strm->avail_out == 0) return 1; \ | ||||
|    if (s->strm->avail_out == 0) return (eof) ? finish_started : need_more; \ | ||||
| } | ||||
|  | ||||
| /* =========================================================================== | ||||
|  * Copy without compression as much as possible from the input stream, return | ||||
|  * true if processing was terminated prematurely (no more input or output | ||||
|  * space).  This function does not insert new strings in the dictionary | ||||
|  * since uncompressible data is probably not useful. This function is used | ||||
|  * the current block state. | ||||
|  * This function does not insert new strings in the dictionary since | ||||
|  * uncompressible data is probably not useful. This function is used | ||||
|  * only for the level=0 compression option. | ||||
|  * NOTE: this function should be optimized to avoid extra copying. | ||||
|  */ | ||||
| local int deflate_stored(s, flush) | ||||
| local block_state deflate_stored(s, flush) | ||||
|     deflate_state *s; | ||||
|     int flush; | ||||
| { | ||||
| @@ -937,7 +964,7 @@ local int deflate_stored(s, flush) | ||||
| 		   s->block_start >= (long)s->w_size, "slide too late"); | ||||
|  | ||||
|             fill_window(s); | ||||
|             if (s->lookahead == 0 && flush == Z_NO_FLUSH) return 1; | ||||
|             if (s->lookahead == 0 && flush == Z_NO_FLUSH) return need_more; | ||||
|  | ||||
|             if (s->lookahead == 0) break; /* flush the current block */ | ||||
|         } | ||||
| @@ -947,7 +974,7 @@ local int deflate_stored(s, flush) | ||||
| 	s->lookahead = 0; | ||||
|  | ||||
|         /* Stored blocks are limited to 0xffff bytes: */ | ||||
|         if (s->strstart == 0 || s->strstart > 0xffff) { | ||||
|         if (s->strstart == 0 || s->strstart > 0xfffe) { | ||||
| 	    /* strstart == 0 is possible when wraparound on 16-bit machine */ | ||||
| 	    s->lookahead = s->strstart - 0xffff; | ||||
| 	    s->strstart = 0xffff; | ||||
| @@ -959,17 +986,17 @@ local int deflate_stored(s, flush) | ||||
| 	} | ||||
|     } | ||||
|     FLUSH_BLOCK(s, flush == Z_FINISH); | ||||
|     return 0; /* normal exit */ | ||||
|     return flush == Z_FINISH ? finish_done : block_done; | ||||
| } | ||||
|  | ||||
| /* =========================================================================== | ||||
|  * Compress as much as possible from the input stream, return true if | ||||
|  * processing was terminated prematurely (no more input or output space). | ||||
|  * Compress as much as possible from the input stream, return the current | ||||
|  * block state. | ||||
|  * This function does not perform lazy evaluation of matches and inserts | ||||
|  * new strings in the dictionary only for unmatched strings or for short | ||||
|  * matches. It is used only for the fast compression options. | ||||
|  */ | ||||
| local int deflate_fast(s, flush) | ||||
| local block_state deflate_fast(s, flush) | ||||
|     deflate_state *s; | ||||
|     int flush; | ||||
| { | ||||
| @@ -984,8 +1011,9 @@ local int deflate_fast(s, flush) | ||||
|          */ | ||||
|         if (s->lookahead < MIN_LOOKAHEAD) { | ||||
|             fill_window(s); | ||||
|             if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) return 1; | ||||
|  | ||||
|             if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { | ||||
| 	        return need_more; | ||||
| 	    } | ||||
|             if (s->lookahead == 0) break; /* flush the current block */ | ||||
|         } | ||||
|  | ||||
| @@ -1053,7 +1081,7 @@ local int deflate_fast(s, flush) | ||||
|         if (bflush) FLUSH_BLOCK(s, 0); | ||||
|     } | ||||
|     FLUSH_BLOCK(s, flush == Z_FINISH); | ||||
|     return 0; /* normal exit */ | ||||
|     return flush == Z_FINISH ? finish_done : block_done; | ||||
| } | ||||
|  | ||||
| /* =========================================================================== | ||||
| @@ -1061,7 +1089,7 @@ local int deflate_fast(s, flush) | ||||
|  * evaluation for matches: a match is finally adopted only if there is | ||||
|  * no better match at the next window position. | ||||
|  */ | ||||
| local int deflate_slow(s, flush) | ||||
| local block_state deflate_slow(s, flush) | ||||
|     deflate_state *s; | ||||
|     int flush; | ||||
| { | ||||
| @@ -1077,8 +1105,9 @@ local int deflate_slow(s, flush) | ||||
|          */ | ||||
|         if (s->lookahead < MIN_LOOKAHEAD) { | ||||
|             fill_window(s); | ||||
|             if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) return 1; | ||||
|  | ||||
|             if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { | ||||
| 	        return need_more; | ||||
| 	    } | ||||
|             if (s->lookahead == 0) break; /* flush the current block */ | ||||
|         } | ||||
|  | ||||
| @@ -1156,7 +1185,7 @@ local int deflate_slow(s, flush) | ||||
|             } | ||||
|             s->strstart++; | ||||
|             s->lookahead--; | ||||
|             if (s->strm->avail_out == 0) return 1; | ||||
|             if (s->strm->avail_out == 0) return need_more; | ||||
|         } else { | ||||
|             /* There is no previous match to compare with, wait for | ||||
|              * the next step to decide. | ||||
| @@ -1173,6 +1202,5 @@ local int deflate_slow(s, flush) | ||||
|         s->match_available = 0; | ||||
|     } | ||||
|     FLUSH_BLOCK(s, flush == Z_FINISH); | ||||
|     return 0; | ||||
|     return flush == Z_FINISH ? finish_done : block_done; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|    subject to change. Applications should only use zlib.h. | ||||
|  */ | ||||
|  | ||||
| /* $Id: deflate.h,v 1.5 1995/05/03 17:27:09 jloup Exp $ */ | ||||
| /* $Id: deflate.h,v 1.10 1996/07/02 12:41:00 me Exp $ */ | ||||
|  | ||||
| #ifndef _DEFLATE_H | ||||
| #define _DEFLATE_H | ||||
| @@ -80,7 +80,7 @@ typedef unsigned IPos; | ||||
|  */ | ||||
|  | ||||
| typedef struct internal_state { | ||||
|     z_stream *strm;      /* pointer back to this zlib stream */ | ||||
|     z_streamp strm;      /* pointer back to this zlib stream */ | ||||
|     int   status;        /* as the name implies */ | ||||
|     Bytef *pending_buf;  /* output still pending */ | ||||
|     Bytef *pending_out;  /* next pending byte to output to the stream */ | ||||
|   | ||||
							
								
								
									
										69
									
								
								example.c
									
									
									
									
									
								
							
							
						
						
									
										69
									
								
								example.c
									
									
									
									
									
								
							| @@ -3,7 +3,7 @@ | ||||
|  * For conditions of distribution and use, see copyright notice in zlib.h  | ||||
|  */ | ||||
|  | ||||
| /* $Id: example.c,v 1.9 1995/05/03 17:27:09 jloup Exp $ */ | ||||
| /* $Id: example.c,v 1.16 1996/05/23 17:11:28 me Exp $ */ | ||||
|  | ||||
| #include <stdio.h> | ||||
| #include "zlib.h" | ||||
| @@ -30,30 +30,30 @@ const char hello[] = "hello, hello!"; | ||||
| const char dictionary[] = "hello"; | ||||
| uLong dictId; /* Adler32 value of the dictionary */ | ||||
|  | ||||
| void test_compress      OF((Bytef *compr, uLong comprLen, | ||||
| 		            Bytef *uncompr, uLong uncomprLen)); | ||||
| void test_compress      OF((Byte *compr, uLong comprLen, | ||||
| 		            Byte *uncompr, uLong uncomprLen)); | ||||
| void test_gzio          OF((const char *out, const char *in,  | ||||
| 		            Bytef *uncompr, int uncomprLen)); | ||||
| void test_deflate       OF((Bytef *compr, uLong comprLen)); | ||||
| void test_inflate       OF((Bytef *compr, uLong comprLen, | ||||
| 		            Bytef *uncompr, uLong uncomprLen)); | ||||
| void test_large_deflate OF((Bytef *compr, uLong comprLen, | ||||
| 		            Bytef *uncompr, uLong uncomprLen)); | ||||
| void test_large_inflate OF((Bytef *compr, uLong comprLen, | ||||
| 		            Bytef *uncompr, uLong uncomprLen)); | ||||
| void test_flush         OF((Bytef *compr, uLong comprLen)); | ||||
| void test_sync          OF((Bytef *compr, uLong comprLen, | ||||
| 		            Bytef *uncompr, uLong uncomprLen)); | ||||
| void test_dict_deflate  OF((Bytef *compr, uLong comprLen)); | ||||
| void test_dict_inflate  OF((Bytef *compr, uLong comprLen, | ||||
| 		            Bytef *uncompr, uLong uncomprLen)); | ||||
| 		            Byte *uncompr, int uncomprLen)); | ||||
| void test_deflate       OF((Byte *compr, uLong comprLen)); | ||||
| void test_inflate       OF((Byte *compr, uLong comprLen, | ||||
| 		            Byte *uncompr, uLong uncomprLen)); | ||||
| void test_large_deflate OF((Byte *compr, uLong comprLen, | ||||
| 		            Byte *uncompr, uLong uncomprLen)); | ||||
| void test_large_inflate OF((Byte *compr, uLong comprLen, | ||||
| 		            Byte *uncompr, uLong uncomprLen)); | ||||
| void test_flush         OF((Byte *compr, uLong comprLen)); | ||||
| void test_sync          OF((Byte *compr, uLong comprLen, | ||||
| 		            Byte *uncompr, uLong uncomprLen)); | ||||
| void test_dict_deflate  OF((Byte *compr, uLong comprLen)); | ||||
| void test_dict_inflate  OF((Byte *compr, uLong comprLen, | ||||
| 		            Byte *uncompr, uLong uncomprLen)); | ||||
| int  main               OF((int argc, char *argv[])); | ||||
|  | ||||
| /* =========================================================================== | ||||
|  * Test compress() and uncompress() | ||||
|  */ | ||||
| void test_compress(compr, comprLen, uncompr, uncomprLen) | ||||
|     Bytef *compr, *uncompr; | ||||
|     Byte *compr, *uncompr; | ||||
|     uLong comprLen, uncomprLen; | ||||
| { | ||||
|     int err; | ||||
| @@ -80,7 +80,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen) | ||||
| void test_gzio(out, in, uncompr, uncomprLen) | ||||
|     const char *out; /* output file */ | ||||
|     const char *in;  /* input file */ | ||||
|     Bytef *uncompr; | ||||
|     Byte *uncompr; | ||||
|     int  uncomprLen; | ||||
| { | ||||
|     int err; | ||||
| @@ -121,7 +121,7 @@ void test_gzio(out, in, uncompr, uncomprLen) | ||||
|  * Test deflate() with small buffers | ||||
|  */ | ||||
| void test_deflate(compr, comprLen) | ||||
|     Bytef *compr; | ||||
|     Byte *compr; | ||||
|     uLong comprLen; | ||||
| { | ||||
|     z_stream c_stream; /* compression stream */ | ||||
| @@ -159,7 +159,7 @@ void test_deflate(compr, comprLen) | ||||
|  * Test inflate() with small buffers | ||||
|  */ | ||||
| void test_inflate(compr, comprLen, uncompr, uncomprLen) | ||||
|     Bytef *compr, *uncompr; | ||||
|     Byte *compr, *uncompr; | ||||
|     uLong comprLen, uncomprLen; | ||||
| { | ||||
|     int err; | ||||
| @@ -198,7 +198,7 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen) | ||||
|  * Test deflate() with large buffers and dynamic change of compression level | ||||
|  */ | ||||
| void test_large_deflate(compr, comprLen, uncompr, uncomprLen) | ||||
|     Bytef *compr, *uncompr; | ||||
|     Byte *compr, *uncompr; | ||||
|     uLong comprLen, uncomprLen; | ||||
| { | ||||
|     z_stream c_stream; /* compression stream */ | ||||
| @@ -251,7 +251,7 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen) | ||||
|  * Test inflate() with large buffers | ||||
|  */ | ||||
| void test_large_inflate(compr, comprLen, uncompr, uncomprLen) | ||||
|     Bytef *compr, *uncompr; | ||||
|     Byte *compr, *uncompr; | ||||
|     uLong comprLen, uncomprLen; | ||||
| { | ||||
|     int err; | ||||
| @@ -291,7 +291,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen) | ||||
|  * Test deflate() with full flush | ||||
|  */ | ||||
| void test_flush(compr, comprLen) | ||||
|     Bytef *compr; | ||||
|     Byte *compr; | ||||
|     uLong comprLen; | ||||
| { | ||||
|     z_stream c_stream; /* compression stream */ | ||||
| @@ -327,7 +327,7 @@ void test_flush(compr, comprLen) | ||||
|  * Test inflateSync() | ||||
|  */ | ||||
| void test_sync(compr, comprLen, uncompr, uncomprLen) | ||||
|     Bytef *compr, *uncompr; | ||||
|     Byte *compr, *uncompr; | ||||
|     uLong comprLen, uncomprLen; | ||||
| { | ||||
|     int err; | ||||
| @@ -369,7 +369,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen) | ||||
|  * Test deflate() with preset dictionary | ||||
|  */ | ||||
| void test_dict_deflate(compr, comprLen) | ||||
|     Bytef *compr; | ||||
|     Byte *compr; | ||||
|     uLong comprLen; | ||||
| { | ||||
|     z_stream c_stream; /* compression stream */ | ||||
| @@ -405,7 +405,7 @@ void test_dict_deflate(compr, comprLen) | ||||
|  * Test inflate() with a preset dictionary | ||||
|  */ | ||||
| void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) | ||||
|     Bytef *compr, *uncompr; | ||||
|     Byte *compr, *uncompr; | ||||
|     uLong comprLen, uncomprLen; | ||||
| { | ||||
|     int err; | ||||
| @@ -458,20 +458,23 @@ int main(argc, argv) | ||||
|     int argc; | ||||
|     char *argv[]; | ||||
| { | ||||
|     Bytef *compr, *uncompr; | ||||
|     uLong comprLen = 32750*sizeof(int); /* don't overflow on MSDOS */ | ||||
|     Byte *compr, *uncompr; | ||||
|     uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ | ||||
|     uLong uncomprLen = comprLen; | ||||
|  | ||||
|     if (zlib_version[0] != ZLIB_VERSION[0]) { | ||||
|     if (zlibVersion()[0] != ZLIB_VERSION[0]) { | ||||
|         fprintf(stderr, "incompatible zlib version\n"); | ||||
|         exit(1); | ||||
|  | ||||
|     } else if (strcmp(zlib_version, ZLIB_VERSION) != 0) { | ||||
|     } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { | ||||
|         fprintf(stderr, "warning: different zlib version\n"); | ||||
|     } | ||||
|  | ||||
|     compr    = (Bytef*)malloc((uInt)comprLen); | ||||
|     uncompr  = (Bytef*)calloc((uInt)uncomprLen, 1); /* must be cleared */ | ||||
|     compr    = (Byte*)calloc((uInt)comprLen, 1); | ||||
|     uncompr  = (Byte*)calloc((uInt)uncomprLen, 1); | ||||
|     /* compr and uncompr are cleared to avoid reading uninitialized | ||||
|      * data and to ensure that uncompr compresses well. | ||||
|      */ | ||||
|     if (compr == Z_NULL || uncompr == Z_NULL) { | ||||
|         printf("out of memory\n"); | ||||
| 	exit(1); | ||||
|   | ||||
							
								
								
									
										28
									
								
								gzio.c
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								gzio.c
									
									
									
									
									
								
							| @@ -3,7 +3,7 @@ | ||||
|  * For conditions of distribution and use, see copyright notice in zlib.h | ||||
|  */ | ||||
|  | ||||
| /* $Id: gzio.c,v 1.8 1995/05/03 17:27:09 jloup Exp $ */ | ||||
| /* $Id: gzio.c,v 1.14 1996/07/24 13:41:01 me Exp $ */ | ||||
|  | ||||
| #include <stdio.h> | ||||
|  | ||||
| @@ -203,8 +203,8 @@ local int get_byte(s) | ||||
| local void check_header(s) | ||||
|     gz_stream *s; | ||||
| { | ||||
|     int method = 0; | ||||
|     int flags = 0; | ||||
|     int method; /* method byte */ | ||||
|     int flags;  /* flags byte */ | ||||
|     uInt len; | ||||
|     int c; | ||||
|  | ||||
| @@ -288,14 +288,15 @@ int gzread (file, buf, len) | ||||
|     unsigned len; | ||||
| { | ||||
|     gz_stream *s = (gz_stream*)file; | ||||
|     Byte *start = buf; /* starting point for crc computation */ | ||||
|     Bytef *start = buf; /* starting point for crc computation */ | ||||
|     Byte  *next_out; /* == stream.next_out but not forced far (for MSDOS) */ | ||||
|  | ||||
|     if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR; | ||||
|  | ||||
|     if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1; | ||||
|     if (s->z_err == Z_STREAM_END) return 0;  /* EOF */ | ||||
|  | ||||
|     s->stream.next_out = buf; | ||||
|     s->stream.next_out = next_out = buf; | ||||
|     s->stream.avail_out = len; | ||||
|  | ||||
|     while (s->stream.avail_out != 0) { | ||||
| @@ -306,14 +307,15 @@ int gzread (file, buf, len) | ||||
| 	    if (n > s->stream.avail_out) n = s->stream.avail_out; | ||||
| 	    if (n > 0) { | ||||
| 		zmemcpy(s->stream.next_out, s->stream.next_in, n); | ||||
| 		s->stream.next_out  += n; | ||||
| 		next_out += n; | ||||
| 		s->stream.next_out = next_out; | ||||
| 		s->stream.next_in   += n; | ||||
| 		s->stream.avail_out -= n; | ||||
| 		s->stream.avail_in  -= n; | ||||
| 	    } | ||||
| 	    if (s->stream.avail_out > 0) { | ||||
| 		s->stream.avail_out -= fread(s->stream.next_out, | ||||
| 					     1, s->stream.avail_out, s->file); | ||||
| 		s->stream.avail_out -= fread(next_out, 1, s->stream.avail_out, | ||||
| 					     s->file); | ||||
| 	    } | ||||
| 	    return (int)(len - s->stream.avail_out); | ||||
| 	} | ||||
| @@ -494,7 +496,7 @@ int gzclose (file) | ||||
|    errnum is set to Z_ERRNO and the application may consult errno | ||||
|    to get the exact error code. | ||||
| */ | ||||
| char*  gzerror (file, errnum) | ||||
| const char*  gzerror (file, errnum) | ||||
|     gzFile file; | ||||
|     int *errnum; | ||||
| { | ||||
| @@ -503,19 +505,19 @@ char*  gzerror (file, errnum) | ||||
|  | ||||
|     if (s == NULL) { | ||||
|         *errnum = Z_STREAM_ERROR; | ||||
|         return ERR_MSG(Z_STREAM_ERROR); | ||||
|         return (const char*)ERR_MSG(Z_STREAM_ERROR); | ||||
|     } | ||||
|     *errnum = s->z_err; | ||||
|     if (*errnum == Z_OK) return (char*)""; | ||||
|     if (*errnum == Z_OK) return (const char*)""; | ||||
|  | ||||
|     m =  (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg); | ||||
|  | ||||
|     if (m == NULL || *m == '\0') m = (char*)z_errmsg[1-s->z_err]; | ||||
|     if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err); | ||||
|  | ||||
|     TRYFREE(s->msg); | ||||
|     s->msg = (char*)ALLOC(strlen(s->path) + strlen(m) + 3); | ||||
|     strcpy(s->msg, s->path); | ||||
|     strcat(s->msg, ": "); | ||||
|     strcat(s->msg, m); | ||||
|     return s->msg; | ||||
|     return (const char*)s->msg; | ||||
| } | ||||
|   | ||||
							
								
								
									
										33
									
								
								infblock.c
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								infblock.c
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | ||||
| /* infblock.c -- interpret and process block types to last block | ||||
|  * Copyright (C) 1995-1996 Mark Adler | ||||
|  * Copyright (C) 1995-1998 Mark Adler | ||||
|  * For conditions of distribution and use, see copyright notice in zlib.h  | ||||
|  */ | ||||
|  | ||||
| @@ -12,7 +12,7 @@ | ||||
| struct inflate_codes_state {int dummy;}; /* for buggy compilers */ | ||||
|  | ||||
| /* Table for deflate from PKZIP's appnote.txt. */ | ||||
| local uInt border[] = { /* Order of the bit length code lengths */ | ||||
| local const uInt border[] = { /* Order of the bit length code lengths */ | ||||
|         16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; | ||||
|  | ||||
| /* | ||||
| @@ -63,7 +63,7 @@ local uInt border[] = { /* Order of the bit length code lengths */ | ||||
|  | ||||
| void inflate_blocks_reset(s, z, c) | ||||
| inflate_blocks_statef *s; | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| uLongf *c; | ||||
| { | ||||
|   if (s->checkfn != Z_NULL) | ||||
| @@ -87,7 +87,7 @@ uLongf *c; | ||||
|  | ||||
|  | ||||
| inflate_blocks_statef *inflate_blocks_new(z, c, w) | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| check_func c; | ||||
| uInt w; | ||||
| { | ||||
| @@ -110,9 +110,12 @@ uInt w; | ||||
| } | ||||
|  | ||||
|  | ||||
| #ifdef DEBUG | ||||
|   extern uInt inflate_hufts; | ||||
| #endif | ||||
| int inflate_blocks(s, z, r) | ||||
| inflate_blocks_statef *s; | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| int r; | ||||
| { | ||||
|   uInt t;               /* temporary storage */ | ||||
| @@ -189,7 +192,7 @@ int r; | ||||
|       s->sub.left = (uInt)b & 0xffff; | ||||
|       b = k = 0;                      /* dump bits */ | ||||
|       Tracev((stderr, "inflate:       stored length %u\n", s->sub.left)); | ||||
|       s->mode = s->sub.left ? STORED : TYPE; | ||||
|       s->mode = s->sub.left ? STORED : (s->last ? DRY : TYPE); | ||||
|       break; | ||||
|     case STORED: | ||||
|       if (n == 0) | ||||
| @@ -221,8 +224,6 @@ int r; | ||||
|       } | ||||
| #endif | ||||
|       t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); | ||||
|       if (t < 19) | ||||
|         t = 19; | ||||
|       if ((s->sub.trees.blens = (uIntf*)ZALLOC(z, t, sizeof(uInt))) == Z_NULL) | ||||
|       { | ||||
|         r = Z_MEM_ERROR; | ||||
| @@ -246,6 +247,7 @@ int r; | ||||
|                              &s->sub.trees.tb, z); | ||||
|       if (t != Z_OK) | ||||
|       { | ||||
|         ZFREE(z, s->sub.trees.blens); | ||||
|         r = t; | ||||
|         if (r == Z_DATA_ERROR) | ||||
|           s->mode = BAD; | ||||
| @@ -284,6 +286,8 @@ int r; | ||||
|           if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || | ||||
|               (c == 16 && i < 1)) | ||||
|           { | ||||
|             inflate_trees_free(s->sub.trees.tb, z); | ||||
|             ZFREE(z, s->sub.trees.blens); | ||||
|             s->mode = BAD; | ||||
|             z->msg = (char*)"invalid bit length repeat"; | ||||
|             r = Z_DATA_ERROR; | ||||
| @@ -306,8 +310,12 @@ int r; | ||||
|         bl = 9;         /* must be <= 9 for lookahead assumptions */ | ||||
|         bd = 6;         /* must be <= 9 for lookahead assumptions */ | ||||
|         t = s->sub.trees.table; | ||||
| #ifdef DEBUG | ||||
|       inflate_hufts = 0; | ||||
| #endif | ||||
|         t = inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), | ||||
|                                   s->sub.trees.blens, &bl, &bd, &tl, &td, z); | ||||
|         ZFREE(z, s->sub.trees.blens); | ||||
|         if (t != Z_OK) | ||||
|         { | ||||
|           if (t == (uInt)Z_DATA_ERROR) | ||||
| @@ -315,7 +323,8 @@ int r; | ||||
|           r = t; | ||||
|           LEAVE | ||||
|         } | ||||
|         Tracev((stderr, "inflate:       trees ok\n")); | ||||
|         Tracev((stderr, "inflate:       trees ok, %d * %d bytes used\n", | ||||
|               inflate_hufts, sizeof(inflate_huft))); | ||||
|         if ((c = inflate_codes_new(bl, bd, tl, td, z)) == Z_NULL) | ||||
|         { | ||||
|           inflate_trees_free(td, z); | ||||
| @@ -323,7 +332,6 @@ int r; | ||||
|           r = Z_MEM_ERROR; | ||||
|           LEAVE | ||||
|         } | ||||
|         ZFREE(z, s->sub.trees.blens); | ||||
|         s->sub.decode.codes = c; | ||||
|         s->sub.decode.tl = tl; | ||||
|         s->sub.decode.td = td; | ||||
| @@ -374,7 +382,7 @@ int r; | ||||
|  | ||||
| int inflate_blocks_free(s, z, c) | ||||
| inflate_blocks_statef *s; | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| uLongf *c; | ||||
| { | ||||
|   inflate_blocks_reset(s, z, c); | ||||
| @@ -385,9 +393,8 @@ uLongf *c; | ||||
| } | ||||
|  | ||||
|  | ||||
| void inflate_set_dictionary(s, z, d, n) | ||||
| void inflate_set_dictionary(s, d, n) | ||||
| inflate_blocks_statef *s; | ||||
| z_stream *z; | ||||
| const Bytef *d; | ||||
| uInt  n; | ||||
| { | ||||
|   | ||||
| @@ -12,27 +12,26 @@ struct inflate_blocks_state; | ||||
| typedef struct inflate_blocks_state FAR inflate_blocks_statef; | ||||
|  | ||||
| extern inflate_blocks_statef * inflate_blocks_new OF(( | ||||
|     z_stream *z, | ||||
|     z_streamp z, | ||||
|     check_func c,               /* check function */ | ||||
|     uInt w));                   /* window size */ | ||||
|  | ||||
| extern int inflate_blocks OF(( | ||||
|     inflate_blocks_statef *, | ||||
|     z_stream *, | ||||
|     z_streamp , | ||||
|     int));                      /* initial return code */ | ||||
|  | ||||
| extern void inflate_blocks_reset OF(( | ||||
|     inflate_blocks_statef *, | ||||
|     z_stream *, | ||||
|     z_streamp , | ||||
|     uLongf *));                  /* check value on output */ | ||||
|  | ||||
| extern int inflate_blocks_free OF(( | ||||
|     inflate_blocks_statef *, | ||||
|     z_stream *, | ||||
|     z_streamp , | ||||
|     uLongf *));                  /* check value on output */ | ||||
|  | ||||
| extern void inflate_set_dictionary OF(( | ||||
|     inflate_blocks_statef *s, | ||||
|     z_stream *z, | ||||
|     const Bytef *d,  /* dictionary */ | ||||
|     uInt  n));       /* dictionary length */ | ||||
|   | ||||
| @@ -60,7 +60,7 @@ inflate_codes_statef *inflate_codes_new(bl, bd, tl, td, z) | ||||
| uInt bl, bd; | ||||
| inflate_huft *tl; | ||||
| inflate_huft *td; /* need separate declaration for Borland C++ */ | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| { | ||||
|   inflate_codes_statef *c; | ||||
|  | ||||
| @@ -80,7 +80,7 @@ z_stream *z; | ||||
|  | ||||
| int inflate_codes(s, z, r) | ||||
| inflate_blocks_statef *s; | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| int r; | ||||
| { | ||||
|   uInt j;               /* temporary storage */ | ||||
| @@ -240,7 +240,7 @@ int r; | ||||
|  | ||||
| void inflate_codes_free(c, z) | ||||
| inflate_codes_statef *c; | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| { | ||||
|   ZFREE(z, c); | ||||
|   Tracev((stderr, "inflate:       codes free\n")); | ||||
|   | ||||
| @@ -14,14 +14,14 @@ typedef struct inflate_codes_state FAR inflate_codes_statef; | ||||
| extern inflate_codes_statef *inflate_codes_new OF(( | ||||
|     uInt, uInt, | ||||
|     inflate_huft *, inflate_huft *, | ||||
|     z_stream *)); | ||||
|     z_streamp )); | ||||
|  | ||||
| extern int inflate_codes OF(( | ||||
|     inflate_blocks_statef *, | ||||
|     z_stream *, | ||||
|     z_streamp , | ||||
|     int)); | ||||
|  | ||||
| extern void inflate_codes_free OF(( | ||||
|     inflate_codes_statef *, | ||||
|     z_stream *)); | ||||
|     z_streamp )); | ||||
|  | ||||
|   | ||||
| @@ -32,7 +32,7 @@ uInt bl, bd; | ||||
| inflate_huft *tl; | ||||
| inflate_huft *td; /* need separate declaration for Borland C++ */ | ||||
| inflate_blocks_statef *s; | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| { | ||||
|   inflate_huft *t;      /* temporary pointer */ | ||||
|   uInt e;               /* extra bits or operation */ | ||||
|   | ||||
| @@ -14,4 +14,4 @@ extern int inflate_fast OF(( | ||||
|     inflate_huft *, | ||||
|     inflate_huft *, | ||||
|     inflate_blocks_statef *, | ||||
|     z_stream *)); | ||||
|     z_streamp )); | ||||
|   | ||||
							
								
								
									
										23
									
								
								inflate.c
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								inflate.c
									
									
									
									
									
								
							| @@ -49,7 +49,7 @@ struct internal_state { | ||||
|  | ||||
|  | ||||
| int inflateReset(z) | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| { | ||||
|   uLong c; | ||||
|  | ||||
| @@ -65,7 +65,7 @@ z_stream *z; | ||||
|  | ||||
|  | ||||
| int inflateEnd(z) | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| { | ||||
|   uLong c; | ||||
|  | ||||
| @@ -81,7 +81,7 @@ z_stream *z; | ||||
|  | ||||
|  | ||||
| int inflateInit2_(z, w, version, stream_size) | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| int w; | ||||
| const char *version; | ||||
| int stream_size; | ||||
| @@ -138,7 +138,7 @@ int stream_size; | ||||
|  | ||||
|  | ||||
| int inflateInit_(z, version, stream_size) | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| const char *version; | ||||
| int stream_size; | ||||
| { | ||||
| @@ -150,13 +150,13 @@ int stream_size; | ||||
| #define NEXTBYTE (z->avail_in--,z->total_in++,*z->next_in++) | ||||
|  | ||||
| int inflate(z, f) | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| int f; | ||||
| { | ||||
|   int r = f;    /* to avoid warning about unused f */ | ||||
|   int r; | ||||
|   uInt b; | ||||
|  | ||||
|   if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL) | ||||
|   if (z == Z_NULL || z->state == Z_NULL || z->next_in == Z_NULL || f < 0) | ||||
|     return Z_STREAM_ERROR; | ||||
|   r = Z_BUF_ERROR; | ||||
|   while (1) switch (z->state->mode) | ||||
| @@ -272,7 +272,7 @@ int f; | ||||
|  | ||||
|  | ||||
| int inflateSetDictionary(z, dictionary, dictLength) | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| const Bytef *dictionary; | ||||
| uInt  dictLength; | ||||
| { | ||||
| @@ -280,22 +280,23 @@ uInt  dictLength; | ||||
|  | ||||
|   if (z == Z_NULL || z->state == Z_NULL || z->state->mode != DICT0) | ||||
|     return Z_STREAM_ERROR; | ||||
|  | ||||
|   if (adler32(1L, dictionary, dictLength) != z->adler) return Z_DATA_ERROR; | ||||
|   z->adler = 1L; | ||||
|  | ||||
|   if (length >= (1<<z->state->wbits)) | ||||
|   if (length >= ((uInt)1<<z->state->wbits)) | ||||
|   { | ||||
|     length = (1<<z->state->wbits)-1; | ||||
|     dictionary += dictLength - length; | ||||
|   } | ||||
|   inflate_set_dictionary(z->state->blocks, z, dictionary, length); | ||||
|   inflate_set_dictionary(z->state->blocks, dictionary, length); | ||||
|   z->state->mode = BLOCKS; | ||||
|   return Z_OK; | ||||
| } | ||||
|  | ||||
|  | ||||
| int inflateSync(z) | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| { | ||||
|   uInt n;       /* number of bytes to look at */ | ||||
|   Bytef *p;     /* pointer to bytes */ | ||||
|   | ||||
							
								
								
									
										63
									
								
								inftrees.c
									
									
									
									
									
								
							
							
						
						
									
										63
									
								
								inftrees.c
									
									
									
									
									
								
							| @@ -1,12 +1,12 @@ | ||||
| /* inftrees.c -- generate Huffman trees for efficient decoding | ||||
|  * Copyright (C) 1995-1996 Mark Adler | ||||
|  * Copyright (C) 1995-1998 Mark Adler | ||||
|  * For conditions of distribution and use, see copyright notice in zlib.h  | ||||
|  */ | ||||
|  | ||||
| #include "zutil.h" | ||||
| #include "inftrees.h" | ||||
|  | ||||
| char inflate_copyright[] = " inflate 1.0 Copyright 1995-1996 Mark Adler "; | ||||
| char inflate_copyright[] = " inflate 1.0.5 Copyright 1995-1998 Mark Adler "; | ||||
| /* | ||||
|   If you use the zlib library in a product, an acknowledgment is welcome | ||||
|   in the documentation of your product. If for some reason you cannot | ||||
| @@ -26,11 +26,11 @@ local int huft_build OF(( | ||||
|     uIntf *,            /* code lengths in bits */ | ||||
|     uInt,               /* number of codes */ | ||||
|     uInt,               /* number of "simple" codes */ | ||||
|     uIntf *,            /* list of base values for non-simple codes */ | ||||
|     uIntf *,            /* list of extra bits for non-simple codes */ | ||||
|     const uIntf *,      /* list of base values for non-simple codes */ | ||||
|     const uIntf *,      /* list of extra bits for non-simple codes */ | ||||
|     inflate_huft * FAR*,/* result: starting table */ | ||||
|     uIntf *,            /* maximum lookup bits (returns actual) */ | ||||
|     z_stream *));       /* for zalloc function */ | ||||
|     z_streamp ));       /* for zalloc function */ | ||||
|  | ||||
| local voidpf falloc OF(( | ||||
|     voidpf,             /* opaque pointer (not used) */ | ||||
| @@ -38,18 +38,18 @@ local voidpf falloc OF(( | ||||
|     uInt));             /* size of item */ | ||||
|  | ||||
| /* Tables for deflate from PKZIP's appnote.txt. */ | ||||
| local uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */ | ||||
| local const uInt cplens[31] = { /* Copy lengths for literal codes 257..285 */ | ||||
|         3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, | ||||
|         35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; | ||||
|         /* actually lengths - 2; also see note #13 above about 258 */ | ||||
| local uInt cplext[31] = { /* Extra bits for literal codes 257..285 */ | ||||
|         /* see note #13 above about 258 */ | ||||
| local const uInt cplext[31] = { /* Extra bits for literal codes 257..285 */ | ||||
|         0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, | ||||
|         3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 192, 192}; /* 192==invalid */ | ||||
| local uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */ | ||||
|         3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */ | ||||
| local const uInt cpdist[30] = { /* Copy offsets for distance codes 0..29 */ | ||||
|         1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, | ||||
|         257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, | ||||
|         8193, 12289, 16385, 24577}; | ||||
| local uInt cpdext[30] = { /* Extra bits for distance codes */ | ||||
| local const uInt cpdext[30] = { /* Extra bits for distance codes */ | ||||
|         0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, | ||||
|         7, 7, 8, 8, 9, 9, 10, 10, 11, 11, | ||||
|         12, 12, 13, 13}; | ||||
| @@ -99,16 +99,16 @@ local int huft_build(b, n, s, d, e, t, m, zs) | ||||
| uIntf *b;               /* code lengths in bits (all assumed <= BMAX) */ | ||||
| uInt n;                 /* number of codes (assumed <= N_MAX) */ | ||||
| uInt s;                 /* number of simple-valued codes (0..s-1) */ | ||||
| uIntf *d;               /* list of base values for non-simple codes */ | ||||
| uIntf *e;               /* list of extra bits for non-simple codes */   | ||||
| const uIntf *d;         /* list of base values for non-simple codes */ | ||||
| const uIntf *e;         /* list of extra bits for non-simple codes */ | ||||
| inflate_huft * FAR *t;  /* result: starting table */ | ||||
| uIntf *m;               /* maximum lookup bits, returns actual */ | ||||
| z_stream *zs;           /* for zalloc function */ | ||||
| z_streamp zs;           /* for zalloc function */ | ||||
| /* Given a list of code lengths and a maximum table size, make a set of | ||||
|    tables to decode that set of codes.  Return Z_OK on success, Z_BUF_ERROR | ||||
|    if the given code set is incomplete (the tables are still built in this | ||||
|    case), Z_DATA_ERROR if the input is invalid (all zero length codes or an | ||||
|    over-subscribed set of lengths), or Z_MEM_ERROR if not enough memory. */ | ||||
|    case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of | ||||
|    lengths), or Z_MEM_ERROR if not enough memory. */ | ||||
| { | ||||
|  | ||||
|   uInt a;                       /* counter for codes of length k */ | ||||
| @@ -190,6 +190,7 @@ z_stream *zs;           /* for zalloc function */ | ||||
|     if ((j = *p++) != 0) | ||||
|       v[x[j]++] = i; | ||||
|   } while (++i < n); | ||||
|   n = x[g];                     /* set n to length of v */ | ||||
|  | ||||
|  | ||||
|   /* Generate the Huffman codes and for each, make the table entries */ | ||||
| @@ -215,7 +216,8 @@ z_stream *zs;           /* for zalloc function */ | ||||
|         w += l;                 /* previous table always l bits */ | ||||
|  | ||||
|         /* compute minimum size table less than or equal to l bits */ | ||||
|         z = (z = g - w) > (uInt)l ? l : z;      /* table size upper limit */ | ||||
|         z = g - w; | ||||
|         z = z > (uInt)l ? l : z;        /* table size upper limit */ | ||||
|         if ((f = 1 << (j = k - w)) > a + 1)     /* try a k-w bit table */ | ||||
|         {                       /* too few codes for k-w bit table */ | ||||
|           f -= a + 1;           /* deduct codes from patterns left */ | ||||
| @@ -268,7 +270,7 @@ z_stream *zs;           /* for zalloc function */ | ||||
|       } | ||||
|       else | ||||
|       { | ||||
|         r.exop = (Byte)e[*p - s] + 16 + 64; /* non-simple--look up in lists */ | ||||
|         r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */ | ||||
|         r.base = d[*p++ - s]; | ||||
|       } | ||||
|  | ||||
| @@ -301,14 +303,14 @@ int inflate_trees_bits(c, bb, tb, z) | ||||
| uIntf *c;               /* 19 code lengths */ | ||||
| uIntf *bb;              /* bits tree desired/actual depth */ | ||||
| inflate_huft * FAR *tb; /* bits tree result */ | ||||
| z_stream *z;            /* for zfree function */ | ||||
| z_streamp z;            /* for zfree function */ | ||||
| { | ||||
|   int r; | ||||
|  | ||||
|   r = huft_build(c, 19, 19, (uIntf*)Z_NULL, (uIntf*)Z_NULL, tb, bb, z); | ||||
|   if (r == Z_DATA_ERROR) | ||||
|     z->msg = (char*)"oversubscribed dynamic bit lengths tree"; | ||||
|   else if (r == Z_BUF_ERROR) | ||||
|   else if (r == Z_BUF_ERROR || *bb == 0) | ||||
|   { | ||||
|     inflate_trees_free(*tb, z); | ||||
|     z->msg = (char*)"incomplete dynamic bit lengths tree"; | ||||
| @@ -326,16 +328,17 @@ uIntf *bl;              /* literal desired/actual bit depth */ | ||||
| uIntf *bd;              /* distance desired/actual bit depth */ | ||||
| inflate_huft * FAR *tl; /* literal/length tree result */ | ||||
| inflate_huft * FAR *td; /* distance tree result */ | ||||
| z_stream *z;            /* for zfree function */ | ||||
| z_streamp z;            /* for zfree function */ | ||||
| { | ||||
|   int r; | ||||
|  | ||||
|   /* build literal/length tree */ | ||||
|   if ((r = huft_build(c, nl, 257, cplens, cplext, tl, bl, z)) != Z_OK) | ||||
|   r = huft_build(c, nl, 257, cplens, cplext, tl, bl, z); | ||||
|   if (r != Z_OK || *bl == 0) | ||||
|   { | ||||
|     if (r == Z_DATA_ERROR) | ||||
|       z->msg = (char*)"oversubscribed literal/length tree"; | ||||
|     else if (r == Z_BUF_ERROR) | ||||
|     else if (r != Z_MEM_ERROR) | ||||
|     { | ||||
|       inflate_trees_free(*tl, z); | ||||
|       z->msg = (char*)"incomplete literal/length tree"; | ||||
| @@ -345,17 +348,23 @@ z_stream *z;            /* for zfree function */ | ||||
|   } | ||||
|  | ||||
|   /* build distance tree */ | ||||
|   if ((r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, z)) != Z_OK) | ||||
|   r = huft_build(c + nl, nd, 0, cpdist, cpdext, td, bd, z); | ||||
|   if (r != Z_OK || (*bd == 0 && nl > 257)) | ||||
|   { | ||||
|     if (r == Z_DATA_ERROR) | ||||
|       z->msg = (char*)"oversubscribed literal/length tree"; | ||||
|       z->msg = (char*)"oversubscribed distance tree"; | ||||
|     else if (r == Z_BUF_ERROR) { | ||||
| #ifdef PKZIP_BUG_WORKAROUND | ||||
|       r = Z_OK; | ||||
|     } | ||||
| #else | ||||
|       inflate_trees_free(*td, z); | ||||
|       z->msg = (char*)"incomplete literal/length tree"; | ||||
|       z->msg = (char*)"incomplete distance tree"; | ||||
|       r = Z_DATA_ERROR; | ||||
|     } | ||||
|     else if (r != Z_MEM_ERROR) | ||||
|     { | ||||
|       z->msg = (char*)"empty distance tree with lengths"; | ||||
|       r = Z_DATA_ERROR; | ||||
|     } | ||||
|     inflate_trees_free(*tl, z); | ||||
| @@ -441,7 +450,7 @@ inflate_huft * FAR *td;  /* distance tree result */ | ||||
|  | ||||
| int inflate_trees_free(t, z) | ||||
| inflate_huft *t;        /* table to free */ | ||||
| z_stream *z;            /* for zfree function */ | ||||
| z_streamp z;            /* for zfree function */ | ||||
| /* Free the malloc'ed tables built by huft_build(), which makes a linked | ||||
|    list of the tables it made, with the links in a dummy first entry of | ||||
|    each table. */ | ||||
|   | ||||
| @@ -35,7 +35,7 @@ extern int inflate_trees_bits OF(( | ||||
|     uIntf *,                    /* 19 code lengths */ | ||||
|     uIntf *,                    /* bits tree desired/actual depth */ | ||||
|     inflate_huft * FAR *,       /* bits tree result */ | ||||
|     z_stream *));               /* for zalloc, zfree functions */ | ||||
|     z_streamp ));               /* for zalloc, zfree functions */ | ||||
|  | ||||
| extern int inflate_trees_dynamic OF(( | ||||
|     uInt,                       /* number of literal/length codes */ | ||||
| @@ -45,7 +45,7 @@ extern int inflate_trees_dynamic OF(( | ||||
|     uIntf *,                    /* distance desired/actual bit depth */ | ||||
|     inflate_huft * FAR *,       /* literal/length tree result */ | ||||
|     inflate_huft * FAR *,       /* distance tree result */ | ||||
|     z_stream *));               /* for zalloc, zfree functions */ | ||||
|     z_streamp ));               /* for zalloc, zfree functions */ | ||||
|  | ||||
| extern int inflate_trees_fixed OF(( | ||||
|     uIntf *,                    /* literal desired/actual bit depth */ | ||||
| @@ -55,5 +55,5 @@ extern int inflate_trees_fixed OF(( | ||||
|  | ||||
| extern int inflate_trees_free OF(( | ||||
|     inflate_huft *,             /* tables to free */ | ||||
|     z_stream *));               /* for zfree function */ | ||||
|     z_streamp ));               /* for zfree function */ | ||||
|  | ||||
|   | ||||
| @@ -22,11 +22,12 @@ uInt inflate_mask[17] = { | ||||
| /* copy as much as possible from the sliding window to the output area */ | ||||
| int inflate_flush(s, z, r) | ||||
| inflate_blocks_statef *s; | ||||
| z_stream *z; | ||||
| z_streamp z; | ||||
| int r; | ||||
| { | ||||
|   uInt n; | ||||
|   Bytef *p, *q; | ||||
|   Bytef *p; | ||||
|   Bytef *q; | ||||
|  | ||||
|   /* local copies of source and destination pointers */ | ||||
|   p = z->next_out; | ||||
|   | ||||
| @@ -41,7 +41,8 @@ struct inflate_blocks_state { | ||||
|       inflate_huft *tb;         /* bit length decoding tree */ | ||||
|     } trees;            /* if DTREE, decoding info for trees */ | ||||
|     struct { | ||||
|       inflate_huft *tl, *td;    /* trees to free */ | ||||
|       inflate_huft *tl; | ||||
|       inflate_huft *td;         /* trees to free */ | ||||
|       inflate_codes_statef  | ||||
|          *codes; | ||||
|     } decode;           /* if CODES, current state */ | ||||
| @@ -90,7 +91,7 @@ extern uInt inflate_mask[17]; | ||||
| /* copy as much as possible from the sliding window to the output area */ | ||||
| extern int inflate_flush OF(( | ||||
|     inflate_blocks_statef *, | ||||
|     z_stream *, | ||||
|     z_streamp , | ||||
|     int)); | ||||
|  | ||||
| struct internal_state      {int dummy;}; /* for buggy compilers */ | ||||
|   | ||||
							
								
								
									
										16
									
								
								minigzip.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								minigzip.c
									
									
									
									
									
								
							| @@ -13,7 +13,7 @@ | ||||
|  * or in pipe mode. | ||||
|  */ | ||||
|  | ||||
| /* $Id: minigzip.c,v 1.5 1995/05/03 17:27:11 jloup Exp $ */ | ||||
| /* $Id: minigzip.c,v 1.10 1996/07/24 13:41:04 me Exp $ */ | ||||
|  | ||||
| #include <stdio.h> | ||||
| #include "zlib.h" | ||||
| @@ -24,7 +24,7 @@ | ||||
| #else | ||||
|    extern void exit  OF((int)); | ||||
| #endif | ||||
| extern int unlink OF((const char *)); | ||||
|  | ||||
|  | ||||
| #if defined(MSDOS) || defined(OS2) || defined(WIN32) | ||||
| #  include <fcntl.h> | ||||
| @@ -35,12 +35,22 @@ extern int unlink OF((const char *)); | ||||
| #endif | ||||
|  | ||||
| #ifdef VMS | ||||
| #  define unlink delete | ||||
| #  define GZ_SUFFIX "-gz" | ||||
| #else | ||||
| #endif | ||||
| #ifdef RISCOS | ||||
| #  define unlink remove | ||||
| #  define GZ_SUFFIX "-gz" | ||||
| #  define fileno(file) file->__file | ||||
| #endif | ||||
|  | ||||
| #ifndef GZ_SUFFIX | ||||
| #  define GZ_SUFFIX ".gz" | ||||
| #endif | ||||
| #define SUFFIX_LEN sizeof(GZ_SUFFIX) | ||||
|  | ||||
| extern int unlink OF((const char *)); | ||||
|  | ||||
| #define BUFLEN 4096 | ||||
| #define MAX_NAME_LEN 1024 | ||||
|  | ||||
|   | ||||
							
								
								
									
										6
									
								
								trees.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								trees.c
									
									
									
									
									
								
							| @@ -29,7 +29,7 @@ | ||||
|  *          Addison-Wesley, 1983. ISBN 0-201-06672-6. | ||||
|  */ | ||||
|  | ||||
| /* $Id: trees.c,v 1.5 1995/05/03 17:27:12 jloup Exp $ */ | ||||
| /* $Id: trees.c,v 1.11 1996/07/24 13:41:06 me Exp $ */ | ||||
|  | ||||
| #include "deflate.h" | ||||
|  | ||||
| @@ -154,7 +154,7 @@ local void copy_block     OF((deflate_state *s, charf *buf, unsigned len, | ||||
|  | ||||
| #else /* DEBUG */ | ||||
| #  define send_code(s, c, tree) \ | ||||
|      { if (verbose>1) fprintf(stderr,"\ncd %3d ",(c)); \ | ||||
|      { if (verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ | ||||
|        send_bits(s, tree[c].Code, tree[c].Len); } | ||||
| #endif | ||||
|  | ||||
| @@ -232,7 +232,7 @@ local void send_bits(s, value, length) | ||||
|  */ | ||||
| local void tr_static_init() | ||||
| { | ||||
|     static static_init_done = 0; | ||||
|     static int static_init_done = 0; | ||||
|     int n;        /* iterates over tree elements */ | ||||
|     int bits;     /* bit counter */ | ||||
|     int length;   /* length value */ | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
|  * For conditions of distribution and use, see copyright notice in zlib.h  | ||||
|  */ | ||||
|  | ||||
| /* $Id: uncompr.c,v 1.5 1995/05/03 17:27:12 jloup Exp $ */ | ||||
| /* $Id: uncompr.c,v 1.8 1996/01/30 21:59:26 me Exp $ */ | ||||
|  | ||||
| #include "zlib.h" | ||||
|  | ||||
|   | ||||
							
								
								
									
										54
									
								
								zconf.h
									
									
									
									
									
								
							
							
						
						
									
										54
									
								
								zconf.h
									
									
									
									
									
								
							| @@ -3,14 +3,14 @@ | ||||
|  * For conditions of distribution and use, see copyright notice in zlib.h  | ||||
|  */ | ||||
|  | ||||
| /* $Id: zconf.h,v 1.12 1995/05/03 17:27:12 jloup Exp $ */ | ||||
| /* $Id: zconf.h,v 1.20 1996/07/02 15:09:28 me Exp $ */ | ||||
|  | ||||
| #ifndef _ZCONF_H | ||||
| #define _ZCONF_H | ||||
|  | ||||
| /* | ||||
|  * People prefering a unique prefix for all types and library functions | ||||
|  * should compile with -DZ_PREFIX | ||||
|  * If you *really* need a unique prefix for all types and library functions, | ||||
|  * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. | ||||
|  */ | ||||
| #ifdef Z_PREFIX | ||||
| #  define deflateInit_	z_deflateInit_ | ||||
| @@ -20,10 +20,12 @@ | ||||
| #  define inflate	z_inflate | ||||
| #  define inflateEnd	z_inflateEnd | ||||
| #  define deflateInit2_	z_deflateInit2_ | ||||
| #  define deflateSetDictionary z_deflateSetDictionary | ||||
| #  define deflateCopy	z_deflateCopy | ||||
| #  define deflateReset	z_deflateReset | ||||
| #  define deflateParams	z_deflateParams | ||||
| #  define inflateInit2_	z_inflateInit2_ | ||||
| #  define inflateSetDictionary z_inflateSetDictionary | ||||
| #  define inflateSync	z_inflateSync | ||||
| #  define inflateReset	z_inflateReset | ||||
| #  define compress	z_compress | ||||
| @@ -35,7 +37,7 @@ | ||||
| #  define Byte		z_Byte | ||||
| #  define uInt		z_uInt | ||||
| #  define uLong		z_uLong | ||||
| #  define Bytef		z_Bytef | ||||
| #  define Bytef	        z_Bytef | ||||
| #  define charf		z_charf | ||||
| #  define intf		z_intf | ||||
| #  define uIntf		z_uIntf | ||||
| @@ -47,8 +49,10 @@ | ||||
| #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) | ||||
| #  define WIN32 | ||||
| #endif | ||||
| #if (defined(__GNUC__) || defined(WIN32)) && !defined(__32BIT__) | ||||
| #  define __32BIT__ | ||||
| #if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) | ||||
| #  ifndef __32BIT__ | ||||
| #    define __32BIT__ | ||||
| #  endif | ||||
| #endif | ||||
| #if defined(__MSDOS__) && !defined(MSDOS) | ||||
| #  define MSDOS | ||||
| @@ -72,13 +76,15 @@ | ||||
| #  define STDC | ||||
| #endif | ||||
|  | ||||
| #if !defined(STDC) && !defined(const) | ||||
| #  define const | ||||
| #ifndef STDC | ||||
| #  ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ | ||||
| #    define const | ||||
| #  endif | ||||
| #endif | ||||
|  | ||||
| #ifdef	__MWERKS__ /* Metrowerks CodeWarrior declares fileno() in unix.h */ | ||||
| #  include <unix.h> | ||||
| #  define Byte _Byte /* Byte already used on Mac */ | ||||
| /* Some Mac compilers merge all .h files incorrectly: */ | ||||
| #if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) | ||||
| #  define NO_DUMMY_DECL | ||||
| #endif | ||||
|  | ||||
| /* Maximum value for memLevel in deflateInit2 */ | ||||
| @@ -124,7 +130,8 @@ | ||||
|  * to define NO_MEMCPY in zutil.h.  If you don't need the mixed model, | ||||
|  * just define FAR to be empty. | ||||
|  */ | ||||
| #if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */ | ||||
| #if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) | ||||
|    /* MSC small or medium model */ | ||||
| #  define SMALL_MEDIUM | ||||
| #  ifdef _MSC_VER | ||||
| #    define FAR __far | ||||
| @@ -133,23 +140,25 @@ | ||||
| #  endif | ||||
| #endif | ||||
| #if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) | ||||
| #  ifndef __32BIT__ | ||||
| #    define SMALL_MEDIUM | ||||
| #    define FAR __far | ||||
| #  endif | ||||
| #endif | ||||
| #ifndef FAR | ||||
| #   define FAR | ||||
| #endif | ||||
| /* The Watcom compiler defines M_I86SM and __SMALL__ even in 32 bit mode */ | ||||
| #if defined(__WATCOMC__) && defined(__386__) | ||||
| #  undef FAR | ||||
| #  undef SMALL_MEDIUM | ||||
| #endif | ||||
|  | ||||
| typedef unsigned char  Byte;  /* 8 bits */ | ||||
| typedef unsigned int   uInt;  /* 16 bits or more */ | ||||
| typedef unsigned long  uLong; /* 32 bits or more */ | ||||
|  | ||||
| typedef Byte  FAR Bytef; | ||||
| #if defined(__BORLANDC__) && defined(SMALL_MEDIUM) | ||||
|    /* Borland C/C++ ignores FAR inside typedef */ | ||||
| #  define Bytef Byte FAR | ||||
| #else | ||||
|    typedef Byte  FAR Bytef; | ||||
| #endif | ||||
| typedef char  FAR charf; | ||||
| typedef int   FAR intf; | ||||
| typedef uInt  FAR uIntf; | ||||
| @@ -163,4 +172,13 @@ typedef uLong FAR uLongf; | ||||
|    typedef Byte     *voidp; | ||||
| #endif | ||||
|  | ||||
|  | ||||
| /* Compile with -DZLIB_DLL for Windows DLL support */ | ||||
| #if (defined(_WINDOWS) || defined(WINDOWS)) && defined(ZLIB_DLL) | ||||
| #  include <windows.h> | ||||
| #  define EXPORT  WINAPI | ||||
| #else | ||||
| #  define EXPORT | ||||
| #endif | ||||
|  | ||||
| #endif /* _ZCONF_H */ | ||||
|   | ||||
							
								
								
									
										46
									
								
								zlib.def
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								zlib.def
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | ||||
| LIBRARY		"zlib" | ||||
|  | ||||
| DESCRIPTION	'"""zlib data compression library"""' | ||||
|  | ||||
| EXETYPE		NT | ||||
|  | ||||
| SUBSYSTEM	WINDOWS | ||||
|  | ||||
| STUB		'WINSTUB.EXE' | ||||
|  | ||||
| VERSION		1.05 | ||||
|  | ||||
| CODE		 EXECUTE READ | ||||
|  | ||||
| DATA		 READ WRITE | ||||
|  | ||||
| HEAPSIZE	1048576,4096 | ||||
|  | ||||
| EXPORTS | ||||
| 		zlibVersion | ||||
| 		deflate | ||||
| 		deflateEnd | ||||
| 		inflate | ||||
| 		inflateEnd | ||||
| 		deflateSetDictionary | ||||
| 		deflateCopy | ||||
| 		deflateReset | ||||
| 		deflateParams | ||||
| 		inflateSetDictionary | ||||
| 		inflateSync | ||||
| 		inflateReset | ||||
| 		compress | ||||
| 		uncompress | ||||
| 		gzopen | ||||
| 		gzdopen | ||||
| 		gzread | ||||
| 		gzwrite | ||||
| 		gzflush | ||||
| 		gzclose | ||||
| 		gzerror | ||||
| 		adler32 | ||||
| 		crc32 | ||||
| 		deflateInit_ | ||||
| 		inflateInit_ | ||||
| 		deflateInit2_ | ||||
| 		inflateInit2_ | ||||
							
								
								
									
										153
									
								
								zlib.h
									
									
									
									
									
								
							
							
						
						
									
										153
									
								
								zlib.h
									
									
									
									
									
								
							| @@ -1,7 +1,7 @@ | ||||
| /* zlib.h -- interface of the 'zlib' general purpose compression library | ||||
|   version 1.0, Jan 27th, 1996. | ||||
|   version 1.0.5, Jan 3rd, 1998. | ||||
|  | ||||
|   Copyright (C) 1995-1996 Jean-loup Gailly and Mark Adler | ||||
|   Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler | ||||
|  | ||||
|   This software is provided 'as-is', without any express or implied | ||||
|   warranty.  In no event will the authors be held liable for any damages | ||||
| @@ -21,7 +21,12 @@ | ||||
|  | ||||
|   Jean-loup Gailly        Mark Adler | ||||
|   gzip@prep.ai.mit.edu    madler@alumni.caltech.edu | ||||
|  */ | ||||
|  | ||||
|  | ||||
|   The data format used by the zlib library is described by RFCs (Request for | ||||
|   Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt | ||||
|   (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). | ||||
| */ | ||||
|  | ||||
| #ifndef _ZLIB_H | ||||
| #define _ZLIB_H | ||||
| @@ -32,7 +37,7 @@ extern "C" { | ||||
|  | ||||
| #include "zconf.h" | ||||
|  | ||||
| #define ZLIB_VERSION "1.0" | ||||
| #define ZLIB_VERSION "1.0.5" | ||||
|  | ||||
| /*  | ||||
|      The 'zlib' compression library provides in-memory compression and | ||||
| @@ -84,6 +89,8 @@ typedef struct z_stream_s { | ||||
|     uLong   reserved;   /* reserved for future use */ | ||||
| } z_stream; | ||||
|  | ||||
| typedef z_stream FAR *z_streamp; | ||||
|  | ||||
| /* | ||||
|    The application must update next_in and avail_in when avail_in has | ||||
|    dropped to zero. It must update next_out and avail_out when avail_out | ||||
| @@ -156,16 +163,20 @@ typedef struct z_stream_s { | ||||
|  | ||||
| #define Z_NULL  0  /* for initializing zalloc, zfree, opaque */ | ||||
|  | ||||
| extern const char *zlib_version; | ||||
| /* The application can compare zlib_version and ZLIB_VERSION for consistency. | ||||
|    If the first character differs, the library code actually used is | ||||
|    not compatible with the zlib.h header file used by the application. | ||||
|  */ | ||||
| #define zlib_version zlibVersion() | ||||
| /* for compatibility with versions < 1.0.2 */ | ||||
|  | ||||
|                         /* basic functions */ | ||||
|  | ||||
| extern const char * EXPORT zlibVersion OF((void)); | ||||
| /* The application can compare zlibVersion and ZLIB_VERSION for consistency. | ||||
|    If the first character differs, the library code actually used is | ||||
|    not compatible with the zlib.h header file used by the application. | ||||
|    This check is automatically made by deflateInit and inflateInit. | ||||
|  */ | ||||
|  | ||||
| /*  | ||||
| extern int deflateInit OF((z_stream *strm, int level)); | ||||
| extern int EXPORT deflateInit OF((z_streamp strm, int level)); | ||||
|  | ||||
|      Initializes the internal stream state for compression. The fields | ||||
|    zalloc, zfree and opaque must be initialized before by the caller. | ||||
| @@ -187,7 +198,7 @@ extern int deflateInit OF((z_stream *strm, int level)); | ||||
| */ | ||||
|  | ||||
|  | ||||
| extern int deflate OF((z_stream *strm, int flush)); | ||||
| extern int EXPORT deflate OF((z_streamp strm, int flush)); | ||||
| /* | ||||
|   Performs one or both of the following actions: | ||||
|  | ||||
| @@ -207,7 +218,9 @@ extern int deflate OF((z_stream *strm, int flush)); | ||||
|   more output, and updating avail_in or avail_out accordingly; avail_out | ||||
|   should never be zero before the call. The application can consume the | ||||
|   compressed output when it wants, for example when the output buffer is full | ||||
|   (avail_out == 0), or after each call of deflate(). | ||||
|   (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK | ||||
|   and with zero avail_out, it must be called again after making room in the | ||||
|   output buffer because there might be more output pending. | ||||
|  | ||||
|     If the parameter flush is set to Z_PARTIAL_FLUSH, the current compression | ||||
|   block is terminated and flushed to the output buffer so that the | ||||
| @@ -228,8 +241,8 @@ extern int deflate OF((z_stream *strm, int flush)); | ||||
|   parameter and more output space (updated avail_out), until the flush is | ||||
|   complete (deflate returns with non-zero avail_out). | ||||
|  | ||||
|     If the parameter flush is set to Z_FINISH, all pending input is processed, | ||||
|   all pending output is flushed and deflate returns with Z_STREAM_END if there | ||||
|     If the parameter flush is set to Z_FINISH, pending input is processed, | ||||
|   pending output is flushed and deflate returns with Z_STREAM_END if there | ||||
|   was enough output space; if deflate returns with Z_OK, this function must be | ||||
|   called again with Z_FINISH and more output space (updated avail_out) but no | ||||
|   more input data, until it returns with Z_STREAM_END or an error. After | ||||
| @@ -254,7 +267,7 @@ extern int deflate OF((z_stream *strm, int flush)); | ||||
| */ | ||||
|  | ||||
|  | ||||
| extern int deflateEnd OF((z_stream *strm)); | ||||
| extern int EXPORT deflateEnd OF((z_streamp strm)); | ||||
| /* | ||||
|      All dynamically allocated data structures for this stream are freed. | ||||
|    This function discards any unprocessed input and does not flush any | ||||
| @@ -269,7 +282,7 @@ extern int deflateEnd OF((z_stream *strm)); | ||||
|  | ||||
|  | ||||
| /*  | ||||
| extern int inflateInit OF((z_stream *strm)); | ||||
| extern int EXPORT inflateInit OF((z_streamp strm)); | ||||
|  | ||||
|      Initializes the internal stream state for decompression. The fields | ||||
|    zalloc, zfree and opaque must be initialized before by the caller.  If | ||||
| @@ -284,7 +297,7 @@ extern int inflateInit OF((z_stream *strm)); | ||||
| */ | ||||
|  | ||||
|  | ||||
| extern int inflate OF((z_stream *strm, int flush)); | ||||
| extern int EXPORT inflate OF((z_streamp strm, int flush)); | ||||
| /* | ||||
|   Performs one or both of the following actions: | ||||
|  | ||||
| @@ -294,15 +307,18 @@ extern int inflate OF((z_stream *strm, int flush)); | ||||
|     will resume at this point for the next call of inflate(). | ||||
|  | ||||
|   - Provide more output starting at next_out and update next_out and avail_out | ||||
|     accordingly.  inflate() always provides as much output as possible | ||||
|     (until there is no more input data or no more space in the output buffer). | ||||
|     accordingly.  inflate() provides as much output as possible, until there | ||||
|     is no more input data or no more space in the output buffer (see below | ||||
|     about the flush parameter). | ||||
|  | ||||
|   Before the call of inflate(), the application should ensure that at least | ||||
|   one of the actions is possible, by providing more input and/or consuming | ||||
|   more output, and updating the next_* and avail_* values accordingly. | ||||
|   The application can consume the uncompressed output when it wants, for | ||||
|   example when the output buffer is full (avail_out == 0), or after each | ||||
|   call of inflate(). | ||||
|   call of inflate(). If inflate returns Z_OK and with zero avail_out, it | ||||
|   must be called again after making room in the output buffer because there | ||||
|   might be more output pending. | ||||
|  | ||||
|     If the parameter flush is set to Z_PARTIAL_FLUSH, inflate flushes as much | ||||
|   output as possible to the output buffer. The flushing behavior of inflate is | ||||
| @@ -336,7 +352,7 @@ extern int inflate OF((z_stream *strm, int flush)); | ||||
| */ | ||||
|  | ||||
|  | ||||
| extern int inflateEnd OF((z_stream *strm)); | ||||
| extern int EXPORT inflateEnd OF((z_streamp strm)); | ||||
| /* | ||||
|      All dynamically allocated data structures for this stream are freed. | ||||
|    This function discards any unprocessed input and does not flush any | ||||
| @@ -354,12 +370,12 @@ extern int inflateEnd OF((z_stream *strm)); | ||||
| */ | ||||
|  | ||||
| /*    | ||||
| extern int deflateInit2 OF((z_stream *strm, | ||||
|                             int  level, | ||||
|                             int  method, | ||||
|                             int  windowBits, | ||||
|                             int  memLevel, | ||||
|                             int  strategy)); | ||||
| extern int EXPORT deflateInit2 OF((z_streamp strm, | ||||
|                                    int  level, | ||||
|                                    int  method, | ||||
|                                    int  windowBits, | ||||
|                                    int  memLevel, | ||||
|                                    int  strategy)); | ||||
|  | ||||
|      This is another version of deflateInit with more compression options. The | ||||
|    fields next_in, zalloc, zfree and opaque must be initialized before by | ||||
| @@ -412,9 +428,9 @@ extern int deflateInit2 OF((z_stream *strm, | ||||
|    deflate().  | ||||
| */ | ||||
|                              | ||||
| extern int deflateSetDictionary OF((z_stream *strm, | ||||
| 				    const Bytef *dictionary, | ||||
| 				    uInt  dictLength)); | ||||
| extern int EXPORT deflateSetDictionary OF((z_streamp strm, | ||||
|                                            const Bytef *dictionary, | ||||
| 				           uInt  dictLength)); | ||||
| /* | ||||
|      Initializes the compression dictionary (history buffer) from the given | ||||
|    byte sequence without producing any compressed output. This function must | ||||
| @@ -441,8 +457,8 @@ extern int deflateSetDictionary OF((z_stream *strm, | ||||
|    be done by deflate().  | ||||
| */ | ||||
|  | ||||
| extern int deflateCopy OF((z_stream *dest, | ||||
|                            z_stream *source)); | ||||
| extern int EXPORT deflateCopy OF((z_streamp dest, | ||||
|                                   z_streamp source)); | ||||
| /* | ||||
|      Sets the destination stream as a complete copy of the source stream.  If | ||||
|    the source stream is using an application-supplied history buffer, a new | ||||
| @@ -464,7 +480,7 @@ extern int deflateCopy OF((z_stream *dest, | ||||
|    destination. | ||||
| */ | ||||
|  | ||||
| extern int deflateReset OF((z_stream *strm)); | ||||
| extern int EXPORT deflateReset OF((z_streamp strm)); | ||||
| /* | ||||
|      This function is equivalent to deflateEnd followed by deflateInit, | ||||
|    but does not free and reallocate all the internal compression state. | ||||
| @@ -475,7 +491,7 @@ extern int deflateReset OF((z_stream *strm)); | ||||
|    stream state was inconsistent (such as zalloc or state being NULL). | ||||
| */ | ||||
|  | ||||
| extern int deflateParams OF((z_stream *strm, int level, int strategy)); | ||||
| extern int EXPORT deflateParams OF((z_streamp strm, int level, int strategy)); | ||||
| /* | ||||
|      Dynamically update the compression level and compression strategy. | ||||
|    This can be used to switch between compression and straight copy of | ||||
| @@ -484,13 +500,18 @@ extern int deflateParams OF((z_stream *strm, int level, int strategy)); | ||||
|    available so far is compressed with the old level (and may be flushed); | ||||
|    the new level will take effect only at the next call of deflate(). | ||||
|  | ||||
|      Before the call of deflateParams, the stream state must be set as for | ||||
|    a call of deflate(), since the currently available input may have to | ||||
|    be compressed and flushed. In particular, strm->avail_out must be non-zero. | ||||
|  | ||||
|      deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source | ||||
|    stream state was inconsistent or if a parameter was invalid. | ||||
|    stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR | ||||
|    if strm->avail_out was zero. | ||||
| */ | ||||
|  | ||||
| /*    | ||||
| extern int inflateInit2 OF((z_stream *strm, | ||||
|                             int  windowBits)); | ||||
| extern int EXPORT inflateInit2 OF((z_streamp strm, | ||||
|                                    int  windowBits)); | ||||
|  | ||||
|      This is another version of inflateInit with more compression options. The | ||||
|    fields next_out, zalloc, zfree and opaque must be initialized before by | ||||
| @@ -523,9 +544,9 @@ extern int inflateInit2 OF((z_stream *strm, | ||||
|    inflate(). | ||||
| */ | ||||
|  | ||||
| extern int inflateSetDictionary OF((z_stream *strm, | ||||
| 				    const Bytef *dictionary, | ||||
| 				    uInt  dictLength)); | ||||
| extern int EXPORT inflateSetDictionary OF((z_streamp strm, | ||||
| 				           const Bytef *dictionary, | ||||
| 					   uInt  dictLength)); | ||||
| /* | ||||
|      Initializes the decompression dictionary (history buffer) from the given | ||||
|    uncompressed byte sequence. This function must be called immediately after | ||||
| @@ -542,7 +563,7 @@ extern int inflateSetDictionary OF((z_stream *strm, | ||||
|    inflate(). | ||||
| */ | ||||
|  | ||||
| extern int inflateSync OF((z_stream *strm)); | ||||
| extern int EXPORT inflateSync OF((z_streamp strm)); | ||||
| /*  | ||||
|     Skips invalid compressed data until the special marker (see deflate() | ||||
|   above) can be found, or until all available input is skipped. No output | ||||
| @@ -557,7 +578,7 @@ extern int inflateSync OF((z_stream *strm)); | ||||
|   until success or end of the input data. | ||||
| */ | ||||
|  | ||||
| extern int inflateReset OF((z_stream *strm)); | ||||
| extern int EXPORT inflateReset OF((z_streamp strm)); | ||||
| /* | ||||
|      This function is equivalent to inflateEnd followed by inflateInit, | ||||
|    but does not free and reallocate all the internal decompression state. | ||||
| @@ -578,8 +599,8 @@ extern int inflateReset OF((z_stream *strm)); | ||||
|    utility functions can easily be modified if you need special options. | ||||
| */ | ||||
|  | ||||
| extern int compress OF((Bytef *dest,   uLongf *destLen, | ||||
|                         const Bytef *source, uLong sourceLen)); | ||||
| extern int EXPORT compress OF((Bytef *dest,   uLongf *destLen, | ||||
| 			       const Bytef *source, uLong sourceLen)); | ||||
| /* | ||||
|      Compresses the source buffer into the destination buffer.  sourceLen is | ||||
|    the byte length of the source buffer. Upon entry, destLen is the total | ||||
| @@ -593,8 +614,8 @@ extern int compress OF((Bytef *dest,   uLongf *destLen, | ||||
|    buffer. | ||||
| */ | ||||
|  | ||||
| extern int uncompress OF((Bytef *dest,   uLongf *destLen, | ||||
|                           const Bytef *source, uLong sourceLen)); | ||||
| extern int EXPORT uncompress OF((Bytef *dest,   uLongf *destLen, | ||||
| 				 const Bytef *source, uLong sourceLen)); | ||||
| /* | ||||
|      Decompresses the source buffer into the destination buffer.  sourceLen is | ||||
|    the byte length of the source buffer. Upon entry, destLen is the total | ||||
| @@ -614,7 +635,7 @@ extern int uncompress OF((Bytef *dest,   uLongf *destLen, | ||||
|  | ||||
| typedef voidp gzFile; | ||||
|  | ||||
| extern gzFile gzopen  OF((const char *path, const char *mode)); | ||||
| extern gzFile EXPORT gzopen  OF((const char *path, const char *mode)); | ||||
| /* | ||||
|      Opens a gzip (.gz) file for reading or writing. The mode parameter | ||||
|    is as in fopen ("rb" or "wb") but can also include a compression level | ||||
| @@ -626,12 +647,12 @@ extern gzFile gzopen  OF((const char *path, const char *mode)); | ||||
|    zlib error is Z_MEM_ERROR). | ||||
| */ | ||||
|  | ||||
| extern gzFile gzdopen  OF((int fd, const char *mode)); | ||||
| extern gzFile EXPORT gzdopen  OF((int fd, const char *mode)); | ||||
| /* | ||||
|      gzdopen() associates a gzFile with the file descriptor fd.  File | ||||
|    descriptors are obtained from calls like open, dup, creat, pipe or | ||||
|    fileno (in the file has been previously opened with fopen). | ||||
|    The mode parameter is as in fopen ("rb" or "wb"). | ||||
|    The mode parameter is as in gzopen. | ||||
|      The next call of gzclose on the returned gzFile will also close the | ||||
|    file descriptor fd, just like fclose(fdopen(fd), mode) closes the file | ||||
|    descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). | ||||
| @@ -639,7 +660,7 @@ extern gzFile gzdopen  OF((int fd, const char *mode)); | ||||
|    the (de)compression state. | ||||
| */ | ||||
|  | ||||
| extern int    gzread  OF((gzFile file, voidp buf, unsigned len)); | ||||
| extern int EXPORT    gzread  OF((gzFile file, voidp buf, unsigned len)); | ||||
| /* | ||||
|      Reads the given number of uncompressed bytes from the compressed file. | ||||
|    If the input file was not in gzip format, gzread copies the given number | ||||
| @@ -647,14 +668,14 @@ extern int    gzread  OF((gzFile file, voidp buf, unsigned len)); | ||||
|      gzread returns the number of uncompressed bytes actually read (0 for | ||||
|    end of file, -1 for error). */ | ||||
|  | ||||
| extern int    gzwrite OF((gzFile file, const voidp buf, unsigned len)); | ||||
| extern int EXPORT    gzwrite OF((gzFile file, const voidp buf, unsigned len)); | ||||
| /* | ||||
|      Writes the given number of uncompressed bytes into the compressed file. | ||||
|    gzwrite returns the number of uncompressed bytes actually written | ||||
|    (0 in case of error). | ||||
| */ | ||||
|  | ||||
| extern int    gzflush OF((gzFile file, int flush)); | ||||
| extern int EXPORT    gzflush OF((gzFile file, int flush)); | ||||
| /* | ||||
|      Flushes all pending output into the compressed file. The parameter | ||||
|    flush is as in the deflate() function. The return value is the zlib | ||||
| @@ -664,14 +685,14 @@ extern int    gzflush OF((gzFile file, int flush)); | ||||
|    degrade compression. | ||||
| */ | ||||
|  | ||||
| extern int    gzclose OF((gzFile file)); | ||||
| extern int EXPORT    gzclose OF((gzFile file)); | ||||
| /* | ||||
|      Flushes all pending output if necessary, closes the compressed file | ||||
|    and deallocates all the (de)compression state. The return value is the zlib | ||||
|    error number (see function gzerror below). | ||||
| */ | ||||
|  | ||||
| extern char*   gzerror OF((gzFile file, int *errnum)); | ||||
| extern const char * EXPORT gzerror OF((gzFile file, int *errnum)); | ||||
| /* | ||||
|      Returns the error message for the last error which occurred on the | ||||
|    given compressed file. errnum is set to zlib error number. If an | ||||
| @@ -688,7 +709,7 @@ extern char*   gzerror OF((gzFile file, int *errnum)); | ||||
|    compression library. | ||||
| */ | ||||
|  | ||||
| extern uLong adler32 OF((uLong adler, const Bytef *buf, uInt len)); | ||||
| extern uLong EXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); | ||||
|  | ||||
| /* | ||||
|      Update a running Adler-32 checksum with the bytes buf[0..len-1] and | ||||
| @@ -705,7 +726,7 @@ extern uLong adler32 OF((uLong adler, const Bytef *buf, uInt len)); | ||||
|      if (adler != original_adler) error(); | ||||
| */ | ||||
|  | ||||
| extern uLong crc32   OF((uLong crc, const Bytef *buf, uInt len)); | ||||
| extern uLong EXPORT crc32   OF((uLong crc, const Bytef *buf, uInt len)); | ||||
| /* | ||||
|      Update a running crc with the bytes buf[0..len-1] and return the updated | ||||
|    crc. If buf is NULL, this function returns the required initial value | ||||
| @@ -727,15 +748,15 @@ extern uLong crc32   OF((uLong crc, const Bytef *buf, uInt len)); | ||||
| /* deflateInit and inflateInit are macros to allow checking the zlib version | ||||
|  * and the compiler's view of z_stream: | ||||
|  */ | ||||
| extern int deflateInit_ OF((z_stream *strm, int level, | ||||
| 			    const char *version, int stream_size)); | ||||
| extern int inflateInit_ OF((z_stream *strm, | ||||
| 			    const char *version, int stream_size)); | ||||
| extern int deflateInit2_ OF((z_stream *strm, int  level, int  method, | ||||
|                              int  windowBits, int  memLevel, int  strategy, | ||||
| 			     const char *version, int stream_size)); | ||||
| extern int inflateInit2_ OF((z_stream *strm, int  windowBits, | ||||
| 			     const char *version, int stream_size)); | ||||
| extern int EXPORT deflateInit_ OF((z_streamp strm, int level, | ||||
| 			           const char *version, int stream_size)); | ||||
| extern int EXPORT inflateInit_ OF((z_streamp strm, | ||||
| 				   const char *version, int stream_size)); | ||||
| extern int EXPORT deflateInit2_ OF((z_streamp strm, int  level, int  method, | ||||
| 				    int windowBits, int memLevel, int strategy, | ||||
| 				    const char *version, int stream_size)); | ||||
| extern int EXPORT inflateInit2_ OF((z_streamp strm, int  windowBits, | ||||
| 				    const char *version, int stream_size)); | ||||
| #define deflateInit(strm, level) \ | ||||
|         deflateInit_((strm), (level),       ZLIB_VERSION, sizeof(z_stream)) | ||||
| #define inflateInit(strm) \ | ||||
| @@ -746,7 +767,7 @@ extern int inflateInit2_ OF((z_stream *strm, int  windowBits, | ||||
| #define inflateInit2(strm, windowBits) \ | ||||
|         inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) | ||||
|  | ||||
| #ifndef _Z_UTIL_H | ||||
| #if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) | ||||
|     struct internal_state {int dummy;}; /* hack for buggy compilers */ | ||||
| #endif | ||||
|  | ||||
|   | ||||
							
								
								
									
										32
									
								
								zlib.rc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								zlib.rc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,32 @@ | ||||
| #include <windows.h> | ||||
|  | ||||
| #define IDR_VERSION1  1 | ||||
| IDR_VERSION1	VERSIONINFO	MOVEABLE IMPURE LOADONCALL DISCARDABLE | ||||
|   FILEVERSION	 1,0,5,0 | ||||
|   PRODUCTVERSION 1,0,5,0 | ||||
|   FILEFLAGSMASK	VS_FFI_FILEFLAGSMASK | ||||
|   FILEFLAGS	0 | ||||
|   FILEOS	VOS_DOS_WINDOWS32 | ||||
|   FILETYPE	VFT_DLL | ||||
|   FILESUBTYPE	0	// not used | ||||
| BEGIN | ||||
|   BLOCK "StringFileInfo" | ||||
|   BEGIN | ||||
|     BLOCK "040904E4" | ||||
|     //language ID = U.S. English, char set = Windows, Multilingual | ||||
|  | ||||
|     BEGIN | ||||
|       VALUE "FileDescription", "zlib data compression library\0" | ||||
|       VALUE "FileVersion",	"1.0.5\0" | ||||
|       VALUE "InternalName",	"zlib\0" | ||||
|       VALUE "OriginalFilename",	"zlib.lib\0" | ||||
|       VALUE "ProductName",	"ZLib.DLL\0" | ||||
|       VALUE "Comments",	"DLL support by Alessandro Iacopetti\0" | ||||
|       VALUE "LegalCopyright", "(C) 1995-1996 Jean-loup Gailly & Mark Adler\0" | ||||
|     END | ||||
|   END | ||||
|   BLOCK "VarFileInfo" | ||||
|   BEGIN | ||||
|     VALUE "Translation", 0x0409, 1252 | ||||
|   END | ||||
| END | ||||
							
								
								
									
										34
									
								
								zutil.c
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								zutil.c
									
									
									
									
									
								
							| @@ -3,7 +3,7 @@ | ||||
|  * For conditions of distribution and use, see copyright notice in zlib.h  | ||||
|  */ | ||||
|  | ||||
| /* $Id: zutil.c,v 1.8 1995/05/03 17:27:12 jloup Exp $ */ | ||||
| /* $Id: zutil.c,v 1.17 1996/07/24 13:41:12 me Exp $ */ | ||||
|  | ||||
| #include <stdio.h> | ||||
|  | ||||
| @@ -15,8 +15,6 @@ struct internal_state      {int dummy;}; /* for buggy compilers */ | ||||
| extern void exit OF((int)); | ||||
| #endif | ||||
|  | ||||
| const char *zlib_version = ZLIB_VERSION; | ||||
|  | ||||
| const char *z_errmsg[10] = { | ||||
| "need dictionary",     /* Z_NEED_DICT       2  */ | ||||
| "stream end",          /* Z_STREAM_END      1  */ | ||||
| @@ -30,12 +28,19 @@ const char *z_errmsg[10] = { | ||||
| ""}; | ||||
|  | ||||
|  | ||||
| const char *zlibVersion() | ||||
| { | ||||
|     return ZLIB_VERSION; | ||||
| } | ||||
|  | ||||
| #ifdef DEBUG | ||||
| void z_error (m) | ||||
|     char *m; | ||||
| { | ||||
|     fprintf(stderr, "%s\n", m); | ||||
|     exit(1); | ||||
| } | ||||
| #endif | ||||
|  | ||||
| #ifndef HAVE_MEMCPY | ||||
|  | ||||
| @@ -50,6 +55,19 @@ void zmemcpy(dest, source, len) | ||||
|     } while (--len != 0); | ||||
| } | ||||
|  | ||||
| int zmemcmp(s1, s2, len) | ||||
|     Bytef* s1; | ||||
|     Bytef* s2; | ||||
|     uInt  len; | ||||
| { | ||||
|     uInt j; | ||||
|  | ||||
|     for (j = 0; j < len; j++) { | ||||
|         if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; | ||||
|     } | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| void zmemzero(dest, len) | ||||
|     Bytef* dest; | ||||
|     uInt  len; | ||||
| @@ -135,14 +153,14 @@ void  zcfree (voidpf opaque, voidpf ptr) | ||||
|         return; | ||||
|     } | ||||
|     ptr = opaque; /* just to make some compilers happy */ | ||||
|     z_error("zcfree: ptr not found"); | ||||
|     Assert(0, "zcfree: ptr not found"); | ||||
| } | ||||
| #endif | ||||
| #endif /* __TURBOC__ */ | ||||
|  | ||||
|  | ||||
| #if defined(M_I86) && !(defined(__WATCOMC__) && defined(__386__)) | ||||
| /* Microsoft C */ | ||||
| #if defined(M_I86) && !defined(__32BIT__) | ||||
| /* Microsoft C in 16-bit mode */ | ||||
|  | ||||
| #  define MY_ZCALLOC | ||||
|  | ||||
| @@ -178,7 +196,7 @@ voidpf zcalloc (opaque, items, size) | ||||
|     unsigned items; | ||||
|     unsigned size; | ||||
| { | ||||
|     if (opaque) opaque = 0; /* to make compiler happy */ | ||||
|     if (opaque) items += size - size; /* make compiler happy */ | ||||
|     return (voidpf)calloc(items, size); | ||||
| } | ||||
|  | ||||
| @@ -186,8 +204,8 @@ void  zcfree (opaque, ptr) | ||||
|     voidpf opaque; | ||||
|     voidpf ptr; | ||||
| { | ||||
|     if (opaque) opaque = 0; /* to make compiler happy */ | ||||
|     free(ptr); | ||||
|     if (opaque) return; /* make compiler happy */ | ||||
| } | ||||
|  | ||||
| #endif /* MY_ZCALLOC */ | ||||
|   | ||||
							
								
								
									
										16
									
								
								zutil.h
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								zutil.h
									
									
									
									
									
								
							| @@ -8,14 +8,14 @@ | ||||
|    subject to change. Applications should only use zlib.h. | ||||
|  */ | ||||
|  | ||||
| /* $Id: zutil.h,v 1.9 1995/05/03 17:27:12 jloup Exp $ */ | ||||
| /* $Id: zutil.h,v 1.16 1996/07/24 13:41:13 me Exp $ */ | ||||
|  | ||||
| #ifndef _Z_UTIL_H | ||||
| #define _Z_UTIL_H | ||||
|  | ||||
| #include "zlib.h" | ||||
|  | ||||
| #if defined(MSDOS) || defined(VMS) || defined(CRAY) || defined(WIN32) | ||||
| #if defined(MSDOS)||defined(VMS)||defined(CRAY)||defined(WIN32)||defined(RISCOS) | ||||
| #   include <stddef.h> | ||||
| #   include <errno.h> | ||||
| #else | ||||
| @@ -40,10 +40,10 @@ typedef unsigned long  ulg; | ||||
| extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ | ||||
| /* (size given to avoid silly warnings with Visual C++) */ | ||||
|  | ||||
| #define ERR_MSG(err) (char*)z_errmsg[Z_NEED_DICT-(err)] | ||||
| #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] | ||||
|  | ||||
| #define ERR_RETURN(strm,err) \ | ||||
|   return (strm->msg = ERR_MSG(err), (err)) | ||||
|   return (strm->msg = (char*)ERR_MSG(err), (err)) | ||||
| /* To be used only when the state is known to be valid */ | ||||
|  | ||||
|         /* common constants */ | ||||
| @@ -114,6 +114,10 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ | ||||
|  | ||||
| #ifdef TOPS20 | ||||
| #  define OS_CODE  0x0a | ||||
| #endif | ||||
|  | ||||
| #if defined(_BEOS_) || defined(RISCOS) | ||||
| #  define fdopen(fd,mode) NULL /* No fdopen() */ | ||||
| #endif | ||||
|  | ||||
|         /* Common defaults */ | ||||
| @@ -159,6 +163,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ | ||||
| #  endif | ||||
| #else | ||||
|    extern void zmemcpy  OF((Bytef* dest, Bytef* source, uInt len)); | ||||
|    extern int  zmemcmp  OF((Bytef* s1,   Bytef* s2, uInt len)); | ||||
|    extern void zmemzero OF((Bytef* dest, uInt len)); | ||||
| #endif | ||||
|  | ||||
| @@ -168,6 +173,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ | ||||
| #  ifndef verbose | ||||
| #    define verbose 0 | ||||
| #  endif | ||||
|    extern void z_error    OF((char *m)); | ||||
| #  define Assert(cond,msg) {if(!(cond)) z_error(msg);} | ||||
| #  define Trace(x) fprintf x | ||||
| #  define Tracev(x) {if (verbose) fprintf x ;} | ||||
| @@ -186,8 +192,6 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ | ||||
|  | ||||
| typedef uLong (*check_func) OF((uLong check, const Bytef *buf, uInt len)); | ||||
|  | ||||
| extern void z_error    OF((char *m)); | ||||
|  | ||||
| voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); | ||||
| void   zcfree  OF((voidpf opaque, voidpf ptr)); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user