diff options
Diffstat (limited to '')
39 files changed, 4752 insertions, 109 deletions
| @@ -1,6 +1,25 @@ | |||
| 1 | 1 | ||
| 2 | ChangeLog file for zlib | 2 | ChangeLog file for zlib |
| 3 | 3 | ||
| 4 | Changes in 1.1.2 (19 March 98) | ||
| 5 | - added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant) | ||
| 6 | See http://www.winimage.com/zLibDll/unzip.html | ||
| 7 | - preinitialize the inflate tables for fixed codes, to make the code | ||
| 8 | completely thread safe (Mark) | ||
| 9 | - some simplifications and slight speed-up to the inflate code (Mark) | ||
| 10 | - fix gzeof on non-compressed files (Allan Schrum) | ||
| 11 | - add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs) | ||
| 12 | - use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn) | ||
| 13 | - added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny) | ||
| 14 | - add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori) | ||
| 15 | - do not wrap extern "C" around system includes (Tom Lane) | ||
| 16 | - mention zlib binding for TCL in README (Andreas Kupries) | ||
| 17 | - added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert) | ||
| 18 | - allow "make install prefix=..." even after configure (Glenn Randers-Pehrson) | ||
| 19 | - allow "configure --prefix $HOME" (Tim Mooney) | ||
| 20 | - remove warnings in example.c and gzio.c (Glenn Randers-Pehrson) | ||
| 21 | - move Makefile.sas to amiga/Makefile.sas | ||
| 22 | |||
| 4 | Changes in 1.1.1 (27 Feb 98) | 23 | Changes in 1.1.1 (27 Feb 98) |
| 5 | - fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson) | 24 | - fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson) |
| 6 | - remove block truncation heuristic which had very marginal effect for zlib | 25 | - remove block truncation heuristic which had very marginal effect for zlib |
| @@ -138,7 +157,7 @@ Changes in 1.0.6 (19 Jan 1998) | |||
| 138 | - allow compilation with ANSI keywords only enabled for TurboC in large model | 157 | - allow compilation with ANSI keywords only enabled for TurboC in large model |
| 139 | - avoid "versionString"[0] (Borland bug) | 158 | - avoid "versionString"[0] (Borland bug) |
| 140 | - add NEED_DUMMY_RETURN for Borland | 159 | - add NEED_DUMMY_RETURN for Borland |
| 141 | - use variable z_verbose for tracing in debug mode (Peter Deutsch). | 160 | - use variable z_verbose for tracing in debug mode (L. Peter Deutsch). |
| 142 | - allow compilation with CC | 161 | - allow compilation with CC |
| 143 | - defined STDC for OS/2 (David Charlap) | 162 | - defined STDC for OS/2 (David Charlap) |
| 144 | - limit external names to 8 chars for MVS (Thomas Lund) | 163 | - limit external names to 8 chars for MVS (Thomas Lund) |
| @@ -5,7 +5,6 @@ Makefile makefile for Unix (generated by configure) | |||
| 5 | Makefile.in makefile for Unix (template for configure) | 5 | Makefile.in makefile for Unix (template for configure) |
| 6 | Makefile.msc makefile for Microsoft C 16-bit | 6 | Makefile.msc makefile for Microsoft C 16-bit |
| 7 | Makefile.riscos makefile for RISCOS | 7 | Makefile.riscos makefile for RISCOS |
| 8 | Makefile.sas makefile for Amiga SAS/C | ||
| 9 | README guess what | 8 | README guess what |
| 10 | algorithm.txt description of the (de)compression algorithm | 9 | algorithm.txt description of the (de)compression algorithm |
| 11 | configure configure script for Unix | 10 | configure configure script for Unix |
| @@ -13,6 +12,9 @@ descrip.mms makefile for Vax/VMS | |||
| 13 | zlib.3 mini man page for zlib (volunteers to write full | 12 | zlib.3 mini man page for zlib (volunteers to write full |
| 14 | man pages from zlib.h welcome. write to jloup@gzip.org) | 13 | man pages from zlib.h welcome. write to jloup@gzip.org) |
| 15 | 14 | ||
| 15 | amiga/Makefile.sas makefile for Amiga SAS/C | ||
| 16 | amiga/Makefile.pup makefile for Amiga powerUP SAS/C PPC | ||
| 17 | |||
| 16 | msdos/Makefile.w32 makefile for Microsoft Visual C++ 32-bit | 18 | msdos/Makefile.w32 makefile for Microsoft Visual C++ 32-bit |
| 17 | msdos/Makefile.b32 makefile for Borland C++ 32-bit | 19 | msdos/Makefile.b32 makefile for Borland C++ 32-bit |
| 18 | msdos/Makefile.bor makefile for Borland C/C++ 16-bit | 20 | msdos/Makefile.bor makefile for Borland C/C++ 16-bit |
| @@ -48,6 +50,7 @@ inftrees.c | |||
| 48 | inftrees.h | 50 | inftrees.h |
| 49 | infutil.c | 51 | infutil.c |
| 50 | infutil.h | 52 | infutil.h |
| 53 | maketree.c | ||
| 51 | trees.c | 54 | trees.c |
| 52 | uncompr.c | 55 | uncompr.c |
| 53 | zutil.c | 56 | zutil.c |
| @@ -62,6 +65,10 @@ minigzip.c | |||
| 62 | contrib/asm386/ by Gilles Vollant <info@winimage.com> | 65 | contrib/asm386/ by Gilles Vollant <info@winimage.com> |
| 63 | 386 asm code replacing longest_match(). | 66 | 386 asm code replacing longest_match(). |
| 64 | 67 | ||
| 68 | contrib/minizip/ by Gilles Vollant <info@winimage.com> | ||
| 69 | Mini zip and unzip based on zlib | ||
| 70 | See http://www.winimage.com/zLibDll/unzip.html | ||
| 71 | |||
| 65 | contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu> | 72 | contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu> |
| 66 | A C++ I/O streams interface to the zlib gz* functions | 73 | A C++ I/O streams interface to the zlib gz* functions |
| 67 | 74 | ||
| @@ -23,7 +23,7 @@ CFLAGS=-O | |||
| 23 | LDFLAGS=-L. -lz | 23 | LDFLAGS=-L. -lz |
| 24 | LDSHARED=$(CC) | 24 | LDSHARED=$(CC) |
| 25 | 25 | ||
| 26 | VER=1.1.1 | 26 | VER=1.1.2 |
| 27 | LIBS=libz.a | 27 | LIBS=libz.a |
| 28 | SHAREDLIB=libz.so | 28 | SHAREDLIB=libz.so |
| 29 | 29 | ||
| @@ -32,8 +32,8 @@ RANLIB=ranlib | |||
| 32 | TAR=tar | 32 | TAR=tar |
| 33 | SHELL=/bin/sh | 33 | SHELL=/bin/sh |
| 34 | 34 | ||
| 35 | prefix=/usr/local | 35 | prefix = /usr/local |
| 36 | exec_prefix = $(prefix) | 36 | exec_prefix = ${prefix} |
| 37 | 37 | ||
| 38 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | 38 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ |
| 39 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o | 39 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o |
| @@ -42,11 +42,13 @@ TEST_OBJS = example.o minigzip.o | |||
| 42 | 42 | ||
| 43 | DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \ | 43 | DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \ |
| 44 | algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ | 44 | algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ |
| 45 | nt/Makefile.nt nt/zlib.dnt contrib/README.contrib contrib/*.txt \ | 45 | nt/Makefile.nt nt/zlib.dnt amiga/Make*.??? contrib/README.contrib \ |
| 46 | contrib/asm386/*.asm contrib/asm386/*.c \ | 46 | contrib/*.txt contrib/asm386/*.asm contrib/asm386/*.c \ |
| 47 | contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \ | 47 | contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \ |
| 48 | contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \ | 48 | contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \ |
| 49 | contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 | 49 | contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 \ |
| 50 | contrib/minizip/[CM]*[pe] contrib/minizip/*.[ch] contrib/minizip/*.[td]?? | ||
| 51 | |||
| 50 | 52 | ||
| 51 | all: example minigzip | 53 | all: example minigzip |
| 52 | 54 | ||
| @@ -112,14 +114,14 @@ distclean: clean | |||
| 112 | 114 | ||
| 113 | zip: | 115 | zip: |
| 114 | mv Makefile Makefile~; cp -p Makefile.in Makefile | 116 | mv Makefile Makefile~; cp -p Makefile.in Makefile |
| 115 | rm -f test.c ztest*.c | 117 | rm -f test.c ztest*.c contrib/minizip/test.zip |
| 116 | v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ | 118 | v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ |
| 117 | zip -ul9 zlib$$v $(DISTFILES) | 119 | zip -ul9 zlib$$v $(DISTFILES) |
| 118 | mv Makefile~ Makefile | 120 | mv Makefile~ Makefile |
| 119 | 121 | ||
| 120 | dist: | 122 | dist: |
| 121 | mv Makefile Makefile~; cp -p Makefile.in Makefile | 123 | mv Makefile Makefile~; cp -p Makefile.in Makefile |
| 122 | rm -f test.c ztest*.c | 124 | rm -f test.c ztest*.c contrib/minizip/test.zip |
| 123 | d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ | 125 | d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ |
| 124 | rm -f $$d.tar.gz; \ | 126 | rm -f $$d.tar.gz; \ |
| 125 | if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \ | 127 | if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \ |
diff --git a/Makefile.in b/Makefile.in index 772bc31..c8bb6e9 100644 --- a/Makefile.in +++ b/Makefile.in | |||
| @@ -23,7 +23,7 @@ CFLAGS=-O | |||
| 23 | LDFLAGS=-L. -lz | 23 | LDFLAGS=-L. -lz |
| 24 | LDSHARED=$(CC) | 24 | LDSHARED=$(CC) |
| 25 | 25 | ||
| 26 | VER=1.1.1 | 26 | VER=1.1.2 |
| 27 | LIBS=libz.a | 27 | LIBS=libz.a |
| 28 | SHAREDLIB=libz.so | 28 | SHAREDLIB=libz.so |
| 29 | 29 | ||
| @@ -32,8 +32,8 @@ RANLIB=ranlib | |||
| 32 | TAR=tar | 32 | TAR=tar |
| 33 | SHELL=/bin/sh | 33 | SHELL=/bin/sh |
| 34 | 34 | ||
| 35 | prefix=/usr/local | 35 | prefix = /usr/local |
| 36 | exec_prefix = $(prefix) | 36 | exec_prefix = ${prefix} |
| 37 | 37 | ||
| 38 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | 38 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ |
| 39 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o | 39 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o |
| @@ -42,11 +42,13 @@ TEST_OBJS = example.o minigzip.o | |||
| 42 | 42 | ||
| 43 | DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \ | 43 | DISTFILES = README INDEX ChangeLog configure Make*[a-z0-9] *.[ch] descrip.mms \ |
| 44 | algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ | 44 | algorithm.txt zlib.3 msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ |
| 45 | nt/Makefile.nt nt/zlib.dnt contrib/README.contrib contrib/*.txt \ | 45 | nt/Makefile.nt nt/zlib.dnt amiga/Make*.??? contrib/README.contrib \ |
| 46 | contrib/asm386/*.asm contrib/asm386/*.c \ | 46 | contrib/*.txt contrib/asm386/*.asm contrib/asm386/*.c \ |
| 47 | contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \ | 47 | contrib/asm386/*.bat contrib/asm386/zlibvc.d?? contrib/iostream/*.cpp \ |
| 48 | contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \ | 48 | contrib/iostream/*.h contrib/iostream2/*.h contrib/iostream2/*.cpp \ |
| 49 | contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 | 49 | contrib/untgz/Makefile contrib/untgz/*.c contrib/untgz/*.w32 \ |
| 50 | contrib/minizip/[CM]*[pe] contrib/minizip/*.[ch] contrib/minizip/*.[td]?? | ||
| 51 | |||
| 50 | 52 | ||
| 51 | all: example minigzip | 53 | all: example minigzip |
| 52 | 54 | ||
| @@ -112,14 +114,14 @@ distclean: clean | |||
| 112 | 114 | ||
| 113 | zip: | 115 | zip: |
| 114 | mv Makefile Makefile~; cp -p Makefile.in Makefile | 116 | mv Makefile Makefile~; cp -p Makefile.in Makefile |
| 115 | rm -f test.c ztest*.c | 117 | rm -f test.c ztest*.c contrib/minizip/test.zip |
| 116 | v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ | 118 | v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ |
| 117 | zip -ul9 zlib$$v $(DISTFILES) | 119 | zip -ul9 zlib$$v $(DISTFILES) |
| 118 | mv Makefile~ Makefile | 120 | mv Makefile~ Makefile |
| 119 | 121 | ||
| 120 | dist: | 122 | dist: |
| 121 | mv Makefile Makefile~; cp -p Makefile.in Makefile | 123 | mv Makefile Makefile~; cp -p Makefile.in Makefile |
| 122 | rm -f test.c ztest*.c | 124 | rm -f test.c ztest*.c contrib/minizip/test.zip |
| 123 | d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ | 125 | d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ |
| 124 | rm -f $$d.tar.gz; \ | 126 | rm -f $$d.tar.gz; \ |
| 125 | if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \ | 127 | if test ! -d ../$$d; then rm -f ../$$d; ln -s `pwd` ../$$d; fi; \ |
| @@ -1,4 +1,4 @@ | |||
| 1 | zlib 1.1.1 is a general purpose data compression library. All the code | 1 | zlib 1.1.2 is a general purpose data compression library. All the code |
| 2 | is thread safe. The data format used by the zlib library | 2 | is thread safe. The data format used by the zlib library |
| 3 | is described by RFCs (Request for Comments) 1950 to 1952 in the files | 3 | is described by RFCs (Request for Comments) 1950 to 1952 in the files |
| 4 | ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate | 4 | ftp://ds.internic.net/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate |
| @@ -21,18 +21,27 @@ Questions about zlib should be sent to <zlib@quest.jpl.nasa.gov> or, | |||
| 21 | if this fails, to the addresses given below in the Copyright section. | 21 | if this fails, to the addresses given below in the Copyright section. |
| 22 | The zlib home page is http://www.cdrom.com/pub/infozip/zlib/ | 22 | The zlib home page is http://www.cdrom.com/pub/infozip/zlib/ |
| 23 | The official zlib ftp site is ftp://ftp.cdrom.com/pub/infozip/zlib/ | 23 | The official zlib ftp site is ftp://ftp.cdrom.com/pub/infozip/zlib/ |
| 24 | Mark Nelson wrote an article about zlib for the Jan. 1997 issue of | 24 | Mark Nelson <markn@tiny.com> wrote an article about zlib for the Jan. 1997 |
| 25 | Dr. Dobb's Journal; a copy of the article is available in | 25 | issue of Dr. Dobb's Journal; a copy of the article is available in |
| 26 | http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm | 26 | http://web2.airmail.net/markn/articles/zlibtool/zlibtool.htm |
| 27 | 27 | ||
| 28 | The changes made in version 1.1.1 are documented in the file ChangeLog. | 28 | The changes made in version 1.1.2 are documented in the file ChangeLog. |
| 29 | The main changes since 1.1.0 are: | 29 | The main changes since 1.1.1 are: |
| 30 | 30 | ||
| 31 | - fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson) | 31 | - added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant) |
| 32 | - remove block truncation heuristic which had very marginal effect for zlib | 32 | See http://www.winimage.com/zLibDll/unzip.html |
| 33 | (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the | 33 | - preinitialize the inflate tables for fixed codes, to make the code |
| 34 | compression ratio on some files. This also allows inlining _tr_tally for | 34 | completely thread safe (Mark) |
| 35 | matches in deflate_slow. | 35 | - some simplifications and slight speed-up to the inflate code (Mark) |
| 36 | - fix gzeof on non-compressed files (Allan Schrum) | ||
| 37 | - add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs) | ||
| 38 | - use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn) | ||
| 39 | - added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny) | ||
| 40 | - add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori) | ||
| 41 | - do not wrap extern "C" around system includes (Tom Lane) | ||
| 42 | - added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert) | ||
| 43 | - allow "make install prefix=..." even after configure (Glenn Randers-Pehrson) | ||
| 44 | - allow "configure --prefix $HOME" (Tim Mooney) | ||
| 36 | 45 | ||
| 37 | 46 | ||
| 38 | Unsupported third party contributions are provided in directory "contrib". | 47 | Unsupported third party contributions are provided in directory "contrib". |
| @@ -49,9 +58,13 @@ A Python interface to zlib written by A.M. Kuchling <amk@magnet.com> | |||
| 49 | is available from the Python Software Association sites, such as: | 58 | is available from the Python Software Association sites, such as: |
| 50 | ftp://ftp.python.org/pub/python/contrib/Encoding/zlib*.tar.gz | 59 | ftp://ftp.python.org/pub/python/contrib/Encoding/zlib*.tar.gz |
| 51 | 60 | ||
| 52 | An experimental package to read files in .zip format, written on top of | 61 | A zlib binding for TCL written by Andreas Kupries <a.kupries@westend.com> |
| 53 | zlib by Gilles Vollant <info@winimage.com>, is available at | 62 | is availlable at http://www.westend.com/~kupries/doc/trf/man/man.html |
| 54 | http://www.winimage.com/zLibDll/unzip.html | 63 | |
| 64 | An experimental package to read and write files in .zip format, | ||
| 65 | written on top of zlib by Gilles Vollant <info@winimage.com>, is | ||
| 66 | available at http://www.winimage.com/zLibDll/unzip.html | ||
| 67 | and also in the contrib/minizip directory of zlib. | ||
| 55 | 68 | ||
| 56 | 69 | ||
| 57 | Notes for some targets: | 70 | Notes for some targets: |
| @@ -74,6 +87,9 @@ Notes for some targets: | |||
| 74 | - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 | 87 | - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 |
| 75 | it works when compiled with cc. | 88 | it works when compiled with cc. |
| 76 | 89 | ||
| 90 | - on Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 | ||
| 91 | is necessary to get gzprintf working correctly. This is done by configure. | ||
| 92 | |||
| 77 | - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works | 93 | - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works |
| 78 | with other compilers. Use "make test" to check your compiler. | 94 | with other compilers. Use "make test" to check your compiler. |
| 79 | 95 | ||
| @@ -90,7 +106,7 @@ Notes for some targets: | |||
| 90 | Acknowledgments: | 106 | Acknowledgments: |
| 91 | 107 | ||
| 92 | The deflate format used by zlib was defined by Phil Katz. The deflate | 108 | The deflate format used by zlib was defined by Phil Katz. The deflate |
| 93 | and zlib specifications were written by Peter Deutsch. Thanks to all the | 109 | and zlib specifications were written by L. Peter Deutsch. Thanks to all the |
| 94 | people who reported problems and suggested various improvements in zlib; | 110 | people who reported problems and suggested various improvements in zlib; |
| 95 | they are too numerous to cite here. | 111 | they are too numerous to cite here. |
| 96 | 112 | ||
diff --git a/amiga/Makefile.pup b/amiga/Makefile.pup new file mode 100644 index 0000000..6cfad1d --- /dev/null +++ b/amiga/Makefile.pup | |||
| @@ -0,0 +1,66 @@ | |||
| 1 | # Amiga powerUP (TM) Makefile | ||
| 2 | # makefile for libpng and SAS C V6.58/7.00 PPC compiler | ||
| 3 | # Copyright (C) 1998 by Andreas R. Kleinert | ||
| 4 | |||
| 5 | CC = scppc | ||
| 6 | CFLAGS = NOSTKCHK NOSINT OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL \ | ||
| 7 | OPTLOOP OPTRDEP=8 OPTDEP=8 OPTCOMP=8 | ||
| 8 | LIBNAME = libzip.a | ||
| 9 | AR = ppc-amigaos-ar | ||
| 10 | AR_FLAGS = cr | ||
| 11 | RANLIB = ppc-amigaos-ranlib | ||
| 12 | LDFLAGS = -r -o | ||
| 13 | LDLIBS = LIB:scppc.a | ||
| 14 | LN = ppc-amigaos-ld | ||
| 15 | RM = delete quiet | ||
| 16 | |||
| 17 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | ||
| 18 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o | ||
| 19 | |||
| 20 | TEST_OBJS = example.o minigzip.o | ||
| 21 | |||
| 22 | all: example minigzip | ||
| 23 | |||
| 24 | test: all | ||
| 25 | example | ||
| 26 | echo hello world | minigzip | minigzip -d | ||
| 27 | |||
| 28 | $(LIBNAME): $(OBJS) | ||
| 29 | $(AR) $(AR_FLAGS) $@ $(OBJS) | ||
| 30 | $(RANLIB) $@ | ||
| 31 | |||
| 32 | example: example.o $(LIBNAME) | ||
| 33 | $(LN) $(LDFLAGS) example LIB:c_ppc.o example.o $(LIBNAME) $(LDLIBS) LIB:end.o | ||
| 34 | |||
| 35 | minigzip: minigzip.o $(LIBNAME) | ||
| 36 | $(LN) $(LDFLAGS) minigzip LIB:c_ppc.o minigzip.o $(LIBNAME) $(LDLIBS) LIB:end.o | ||
| 37 | |||
| 38 | clean: | ||
| 39 | $(RM) *.o example minigzip $(LIBNAME) foo.gz | ||
| 40 | |||
| 41 | zip: | ||
| 42 | zip -ul9 zlib README ChangeLog Makefile Make????.??? Makefile.?? \ | ||
| 43 | descrip.mms *.[ch] | ||
| 44 | |||
| 45 | tgz: | ||
| 46 | cd ..; tar cfz zlib/zlib.tgz zlib/README zlib/ChangeLog zlib/Makefile \ | ||
| 47 | zlib/Make????.??? zlib/Makefile.?? zlib/descrip.mms zlib/*.[ch] | ||
| 48 | |||
| 49 | # DO NOT DELETE THIS LINE -- make depend depends on it. | ||
| 50 | |||
| 51 | adler32.o: zutil.h zlib.h zconf.h | ||
| 52 | compress.o: zlib.h zconf.h | ||
| 53 | crc32.o: zutil.h zlib.h zconf.h | ||
| 54 | deflate.o: deflate.h zutil.h zlib.h zconf.h | ||
| 55 | example.o: zlib.h zconf.h | ||
| 56 | gzio.o: zutil.h zlib.h zconf.h | ||
| 57 | infblock.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h | ||
| 58 | infcodes.o: zutil.h zlib.h zconf.h inftrees.h infutil.h infcodes.h inffast.h | ||
| 59 | inffast.o: zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h | ||
| 60 | inflate.o: zutil.h zlib.h zconf.h infblock.h | ||
| 61 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h | ||
| 62 | infutil.o: zutil.h zlib.h zconf.h inftrees.h infutil.h | ||
| 63 | minigzip.o: zlib.h zconf.h | ||
| 64 | trees.o: deflate.h zutil.h zlib.h zconf.h | ||
| 65 | uncompr.o: zlib.h zconf.h | ||
| 66 | zutil.o: zutil.h zlib.h zconf.h | ||
diff --git a/Makefile.sas b/amiga/Makefile.sas index 5323e82..5323e82 100644 --- a/Makefile.sas +++ b/amiga/Makefile.sas | |||
| @@ -24,7 +24,6 @@ VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h` | |||
| 24 | AR=${AR-"ar rc"} | 24 | AR=${AR-"ar rc"} |
| 25 | RANLIB=${RANLIB-"ranlib"} | 25 | RANLIB=${RANLIB-"ranlib"} |
| 26 | prefix=${prefix-/usr/local} | 26 | prefix=${prefix-/usr/local} |
| 27 | exec_prefix=${exec_prefix-$prefix} | ||
| 28 | shared_ext='.so' | 27 | shared_ext='.so' |
| 29 | shared=0 | 28 | shared=0 |
| 30 | gcc=0 | 29 | gcc=0 |
| @@ -32,8 +31,10 @@ old_cc="$CC" | |||
| 32 | old_cflags="$CFLAGS" | 31 | old_cflags="$CFLAGS" |
| 33 | 32 | ||
| 34 | case "$1" in | 33 | case "$1" in |
| 34 | -h* | --h*) echo 'syntax: configure [ --shared ] [--prefix PREFIX]'; exit 0;; | ||
| 35 | -p*=* | --p*=*) prefix=`echo $1 | sed 's/[-a-z_]*=//'`; shift;; | ||
| 36 | -p* | --p*) prefix="$2"; shift; shift;; | ||
| 35 | -s* | --s*) shared=1; shift;; | 37 | -s* | --s*) shared=1; shift;; |
| 36 | -h* | --h*) echo 'syntax: configure [ --shared ]'; exit 0;; | ||
| 37 | esac | 38 | esac |
| 38 | 39 | ||
| 39 | test=ztest$$ | 40 | test=ztest$$ |
| @@ -61,15 +62,18 @@ else | |||
| 61 | # find system name and corresponding cc options | 62 | # find system name and corresponding cc options |
| 62 | CC=${CC-cc} | 63 | CC=${CC-cc} |
| 63 | case `(uname -sr || echo unknown) 2>/dev/null` in | 64 | case `(uname -sr || echo unknown) 2>/dev/null` in |
| 64 | SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."} | 65 | HP-UX*) SFLAGS=${CFLAGS-"-O +z"} |
| 65 | CFLAGS=${CFLAGS-"-fast -xcg89"} | 66 | CFLAGS=${CFLAGS-"-O"} |
| 66 | LDSHARED=${LDSHARED-"cc -G"};; | 67 | # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} |
| 67 | SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"} | 68 | LDSHARED=${LDSHARED-"ld -b"} |
| 68 | CFLAGS=${CFLAGS-"-O2"} | 69 | shared_ext='.sl' |
| 69 | LDSHARED=${LDSHARED-"ld"};; | 70 | SHAREDLIB='libz.sl';; |
| 70 | IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."} | 71 | IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."} |
| 71 | CFLAGS=${CFLAGS-"-ansi -O2"} | 72 | CFLAGS=${CFLAGS-"-ansi -O2"} |
| 72 | LDSHARED=${LDSHARED-"cc -shared"};; | 73 | LDSHARED=${LDSHARED-"cc -shared"};; |
| 74 | OSF1) SFLAGS=${CFLAGS-"-O -std1"} | ||
| 75 | CFLAGS=${CFLAGS-"-O -std1"} | ||
| 76 | LDSHARED=${LDSHARED-"cc -shared"};; | ||
| 73 | QNX*) SFLAGS=${CFLAGS-"-4 -O"} | 77 | QNX*) SFLAGS=${CFLAGS-"-4 -O"} |
| 74 | CFLAGS=${CFLAGS-"-4 -O"} | 78 | CFLAGS=${CFLAGS-"-4 -O"} |
| 75 | LDSHARED=${LDSHARED-"cc"} | 79 | LDSHARED=${LDSHARED-"cc"} |
| @@ -78,16 +82,20 @@ else | |||
| 78 | SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "} | 82 | SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "} |
| 79 | CFLAGS=${CFLAGS-"-O3"} | 83 | CFLAGS=${CFLAGS-"-O3"} |
| 80 | LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};; | 84 | LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};; |
| 81 | HP-UX*) SFLAGS=${CFLAGS-"-O +z"} | 85 | SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."} |
| 82 | CFLAGS=${CFLAGS-"-O"} | 86 | CFLAGS=${CFLAGS-"-fast -xcg89"} |
| 83 | # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} | 87 | LDSHARED=${LDSHARED-"cc -G"};; |
| 84 | LDSHARED=${LDSHARED-"ld -b"} | 88 | SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"} |
| 85 | shared_ext='.sl' | 89 | CFLAGS=${CFLAGS-"-O2"} |
| 86 | SHAREDLIB='libz.sl';; | 90 | LDSHARED=${LDSHARED-"ld"};; |
| 87 | UNIX_System_V\ 4.2.0) | 91 | UNIX_System_V\ 4.2.0) |
| 88 | SFLAGS=${CFLAGS-"-KPIC -O"} | 92 | SFLAGS=${CFLAGS-"-KPIC -O"} |
| 89 | CFLAGS=${CFLAGS-"-O"} | 93 | CFLAGS=${CFLAGS-"-O"} |
| 90 | LDSHARED=${LDSHARED-"cc -G"};; | 94 | LDSHARED=${LDSHARED-"cc -G"};; |
| 95 | UNIX_SV\ 4.2MP) | ||
| 96 | SFLAGS=${CFLAGS-"-Kconform_pic -O"} | ||
| 97 | CFLAGS=${CFLAGS-"-O"} | ||
| 98 | LDSHARED=${LDSHARED-"cc -G"};; | ||
| 91 | # send working options for other systems to support@gzip.org | 99 | # send working options for other systems to support@gzip.org |
| 92 | *) SFLAGS=${CFLAGS-"-O"} | 100 | *) SFLAGS=${CFLAGS-"-O"} |
| 93 | CFLAGS=${CFLAGS-"-O"} | 101 | CFLAGS=${CFLAGS-"-O"} |
| @@ -152,5 +160,4 @@ sed < Makefile.in " | |||
| 152 | /^RANLIB *=/s%=.*%=$RANLIB% | 160 | /^RANLIB *=/s%=.*%=$RANLIB% |
| 153 | /^VER *=/s%=.*%=$VER% | 161 | /^VER *=/s%=.*%=$VER% |
| 154 | /^prefix *=/s%=.*%=$prefix% | 162 | /^prefix *=/s%=.*%=$prefix% |
| 155 | /^exec_prefix *=/s%=.*%=$exec_prefix% | ||
| 156 | " > Makefile | 163 | " > Makefile |
diff --git a/contrib/README.contrib b/contrib/README.contrib index 443eb6b..dfe9031 100644 --- a/contrib/README.contrib +++ b/contrib/README.contrib | |||
| @@ -7,6 +7,10 @@ for help about these, not the zlib authors. Thanks. | |||
| 7 | asm386/ by Gilles Vollant <info@winimage.com> | 7 | asm386/ by Gilles Vollant <info@winimage.com> |
| 8 | 386 asm code replacing longest_match(), for Visual C++ 4.2 and ML 6.11c | 8 | 386 asm code replacing longest_match(), for Visual C++ 4.2 and ML 6.11c |
| 9 | 9 | ||
| 10 | minizip/ by Gilles Vollant <info@winimage.com> | ||
| 11 | Mini zip and unzip based on zlib | ||
| 12 | See http://www.winimage.com/zLibDll/unzip.html | ||
| 13 | |||
| 10 | iostream/ by Kevin Ruland <kevin@rodin.wustl.edu> | 14 | iostream/ by Kevin Ruland <kevin@rodin.wustl.edu> |
| 11 | A C++ I/O streams interface to the zlib gz* functions | 15 | A C++ I/O streams interface to the zlib gz* functions |
| 12 | 16 | ||
diff --git a/contrib/asm386/zlibvc.def b/contrib/asm386/zlibvc.def new file mode 100644 index 0000000..7e9d60d --- /dev/null +++ b/contrib/asm386/zlibvc.def | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | LIBRARY "zlib" | ||
| 2 | |||
| 3 | DESCRIPTION '"""zlib data compression library"""' | ||
| 4 | |||
| 5 | |||
| 6 | VERSION 1.11 | ||
| 7 | |||
| 8 | |||
| 9 | HEAPSIZE 1048576,8192 | ||
| 10 | |||
| 11 | EXPORTS | ||
| 12 | adler32 @1 | ||
| 13 | compress @2 | ||
| 14 | crc32 @3 | ||
| 15 | deflate @4 | ||
| 16 | deflateCopy @5 | ||
| 17 | deflateEnd @6 | ||
| 18 | deflateInit2_ @7 | ||
| 19 | deflateInit_ @8 | ||
| 20 | deflateParams @9 | ||
| 21 | deflateReset @10 | ||
| 22 | deflateSetDictionary @11 | ||
| 23 | gzclose @12 | ||
| 24 | gzdopen @13 | ||
| 25 | gzerror @14 | ||
| 26 | gzflush @15 | ||
| 27 | gzopen @16 | ||
| 28 | gzread @17 | ||
| 29 | gzwrite @18 | ||
| 30 | inflate @19 | ||
| 31 | inflateEnd @20 | ||
| 32 | inflateInit2_ @21 | ||
| 33 | inflateInit_ @22 | ||
| 34 | inflateReset @23 | ||
| 35 | inflateSetDictionary @24 | ||
| 36 | inflateSync @25 | ||
| 37 | uncompress @26 | ||
| 38 | zlibVersion @27 | ||
| 39 | gzprintf @28 | ||
| 40 | gzputc @29 | ||
| 41 | gzgetc @30 | ||
| 42 | gzseek @31 | ||
| 43 | gzrewind @32 | ||
| 44 | gztell @33 | ||
| 45 | gzeof @34 | ||
| 46 | gzsetparams @35 | ||
| 47 | zError @36 | ||
| 48 | inflateSyncPoint @37 | ||
| 49 | get_crc_table @38 | ||
| 50 | compress2 @39 | ||
| 51 | gzputs @40 | ||
| 52 | gzgets @41 | ||
| 53 | |||
| 54 | unzOpen @61 | ||
| 55 | unzClose @62 | ||
| 56 | unzGetGlobalInfo @63 | ||
| 57 | unzGetCurrentFileInfo @64 | ||
| 58 | unzGoToFirstFile @65 | ||
| 59 | unzGoToNextFile @66 | ||
| 60 | unzOpenCurrentFile @67 | ||
| 61 | unzReadCurrentFile @68 | ||
| 62 | unztell @70 | ||
| 63 | unzeof @71 | ||
| 64 | unzCloseCurrentFile @72 | ||
| 65 | unzGetGlobalComment @73 | ||
| 66 | unzStringFileNameCompare @74 | ||
| 67 | unzLocateFile @75 | ||
| 68 | unzGetLocalExtrafield @76 | ||
| 69 | |||
| 70 | zipOpen @80 | ||
| 71 | zipOpenNewFileInZip @81 | ||
| 72 | zipWriteInFileInZip @82 | ||
| 73 | zipCloseFileInZip @83 | ||
| 74 | zipClose @84 | ||
diff --git a/contrib/asm386/zlibvc.dsp b/contrib/asm386/zlibvc.dsp index 98676db..a70d4d4 100644 --- a/contrib/asm386/zlibvc.dsp +++ b/contrib/asm386/zlibvc.dsp | |||
| @@ -47,7 +47,8 @@ CFG=zlibvc - Win32 Release | |||
| 47 | # PROP Target_Dir "" | 47 | # PROP Target_Dir "" |
| 48 | CPP=cl.exe | 48 | CPP=cl.exe |
| 49 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c | 49 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c |
| 50 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /YX /FD /c | 50 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /FD /c |
| 51 | # SUBTRACT CPP /YX | ||
| 51 | MTL=midl.exe | 52 | MTL=midl.exe |
| 52 | # ADD BASE MTL /nologo /D "NDEBUG" /win32 | 53 | # ADD BASE MTL /nologo /D "NDEBUG" /win32 |
| 53 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | 54 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 |
| @@ -76,7 +77,8 @@ LINK32=link.exe | |||
| 76 | # PROP Target_Dir "" | 77 | # PROP Target_Dir "" |
| 77 | CPP=cl.exe | 78 | CPP=cl.exe |
| 78 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c | 79 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c |
| 79 | # ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /YX /FD /c | 80 | # ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /FD /c |
| 81 | # SUBTRACT CPP /YX | ||
| 80 | MTL=midl.exe | 82 | MTL=midl.exe |
| 81 | # ADD BASE MTL /nologo /D "_DEBUG" /win32 | 83 | # ADD BASE MTL /nologo /D "_DEBUG" /win32 |
| 82 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 | 84 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 |
| @@ -109,7 +111,8 @@ MTL=midl.exe | |||
| 109 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | 111 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 |
| 110 | CPP=cl.exe | 112 | CPP=cl.exe |
| 111 | # ADD BASE CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c | 113 | # ADD BASE CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c |
| 112 | # ADD CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c | 114 | # ADD CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /FD /c |
| 115 | # SUBTRACT CPP /YX | ||
| 113 | RSC=rc.exe | 116 | RSC=rc.exe |
| 114 | # ADD BASE RSC /l 0x40c /d "NDEBUG" | 117 | # ADD BASE RSC /l 0x40c /d "NDEBUG" |
| 115 | # ADD RSC /l 0x40c /d "NDEBUG" | 118 | # ADD RSC /l 0x40c /d "NDEBUG" |
| @@ -138,7 +141,8 @@ LINK32=link.exe | |||
| 138 | # PROP Target_Dir "" | 141 | # PROP Target_Dir "" |
| 139 | CPP=cl.exe | 142 | CPP=cl.exe |
| 140 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c | 143 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c |
| 141 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c | 144 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /FD /c |
| 145 | # SUBTRACT CPP /YX | ||
| 142 | MTL=midl.exe | 146 | MTL=midl.exe |
| 143 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | 147 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 |
| 144 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | 148 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 |
| @@ -170,7 +174,8 @@ LINK32=link.exe | |||
| 170 | # PROP Target_Dir "" | 174 | # PROP Target_Dir "" |
| 171 | CPP=cl.exe | 175 | CPP=cl.exe |
| 172 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /YX /FD /c | 176 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /YX /FD /c |
| 173 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /YX /FD /c | 177 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /FD /c |
| 178 | # SUBTRACT CPP /YX | ||
| 174 | MTL=midl.exe | 179 | MTL=midl.exe |
| 175 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | 180 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 |
| 176 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | 181 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 |
| @@ -534,6 +539,40 @@ DEP_CPP_UNCOM=\ | |||
| 534 | # End Source File | 539 | # End Source File |
| 535 | # Begin Source File | 540 | # Begin Source File |
| 536 | 541 | ||
| 542 | SOURCE=.\unzip.c | ||
| 543 | |||
| 544 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 545 | |||
| 546 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 547 | |||
| 548 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 549 | |||
| 550 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 551 | |||
| 552 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 553 | |||
| 554 | !ENDIF | ||
| 555 | |||
| 556 | # End Source File | ||
| 557 | # Begin Source File | ||
| 558 | |||
| 559 | SOURCE=.\zip.c | ||
| 560 | |||
| 561 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 562 | |||
| 563 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 564 | |||
| 565 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 566 | |||
| 567 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 568 | |||
| 569 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 570 | |||
| 571 | !ENDIF | ||
| 572 | |||
| 573 | # End Source File | ||
| 574 | # Begin Source File | ||
| 575 | |||
| 537 | SOURCE=.\zlib.rc | 576 | SOURCE=.\zlib.rc |
| 538 | # End Source File | 577 | # End Source File |
| 539 | # Begin Source File | 578 | # Begin Source File |
diff --git a/contrib/asm386/zlibvc.dsw b/contrib/asm386/zlibvc.dsw index b62e50b..493cd87 100644 --- a/contrib/asm386/zlibvc.dsw +++ b/contrib/asm386/zlibvc.dsw | |||
| @@ -3,7 +3,19 @@ Microsoft Developer Studio Workspace File, Format Version 5.00 | |||
| 3 | 3 | ||
| 4 | ############################################################################### | 4 | ############################################################################### |
| 5 | 5 | ||
| 6 | Project: "zlibvc"=".\zlibvc.dsp" - Package Owner=<4> | 6 | Project: "zlibstat"=.\zlibstat.dsp - Package Owner=<4> |
| 7 | |||
| 8 | Package=<5> | ||
| 9 | {{{ | ||
| 10 | }}} | ||
| 11 | |||
| 12 | Package=<4> | ||
| 13 | {{{ | ||
| 14 | }}} | ||
| 15 | |||
| 16 | ############################################################################### | ||
| 17 | |||
| 18 | Project: "zlibvc"=.\zlibvc.dsp - Package Owner=<4> | ||
| 7 | 19 | ||
| 8 | Package=<5> | 20 | Package=<5> |
| 9 | {{{ | 21 | {{{ |
diff --git a/contrib/minizip/ChangeLogUnzip b/contrib/minizip/ChangeLogUnzip new file mode 100644 index 0000000..9987c54 --- /dev/null +++ b/contrib/minizip/ChangeLogUnzip | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | Change in 0.15: (19 Mar 98) | ||
| 2 | - fix memory leak in minizip.c | ||
| 3 | |||
| 4 | Change in 0.14: (10 Mar 98) | ||
| 5 | - fix bugs in minizip.c sample for zipping big file | ||
| 6 | - fix problem in month in date handling | ||
| 7 | - fix bug in unzlocal_GetCurrentFileInfoInternal in unzip.c for | ||
| 8 | comment handling | ||
| 9 | |||
| 10 | Change in 0.13: (6 Mar 98) | ||
| 11 | - fix bugs in zip.c | ||
| 12 | - add real minizip sample | ||
| 13 | |||
| 14 | Change in 0.12: (4 Mar 98) | ||
| 15 | - add zip.c and zip.h for creates .zip file | ||
| 16 | - fix change_file_date in miniunz.c for Unix (Jean-loup Gailly) | ||
| 17 | - fix miniunz.c for file without specific record for directory | ||
| 18 | |||
| 19 | Change in 0.11: (3 Mar 98) | ||
| 20 | - fix bug in unzGetCurrentFileInfo for get extra field and comment | ||
| 21 | - enhance miniunz sample, remove the bad unztst.c sample | ||
| 22 | |||
| 23 | Change in 0.10: (2 Mar 98) | ||
| 24 | - fix bug in unzReadCurrentFile | ||
| 25 | - rename unzip* to unz* function and structure | ||
| 26 | - remove Windows-like hungary notation variable name | ||
| 27 | - modify some structure in unzip.h | ||
| 28 | - add somes comment in source | ||
| 29 | - remove unzipGetcCurrentFile function | ||
| 30 | - replace ZUNZEXPORT by ZEXPORT | ||
| 31 | - add unzGetLocalExtrafield for get the local extrafield info | ||
| 32 | - add a new sample, miniunz.c | ||
| 33 | |||
| 34 | Change in 0.4: (25 Feb 98) | ||
| 35 | - suppress the type unzipFileInZip. | ||
| 36 | Only on file in the zipfile can be open at the same time | ||
| 37 | - fix somes typo in code | ||
| 38 | - added tm_unz structure in unzip_file_info (date/time in readable format) | ||
diff --git a/contrib/minizip/Makefile b/contrib/minizip/Makefile new file mode 100644 index 0000000..a1dfc16 --- /dev/null +++ b/contrib/minizip/Makefile | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | CC=cc | ||
| 2 | CFLAGS=-O -I../.. | ||
| 3 | |||
| 4 | UNZ_OBJS = miniunz.o unzip.o ../../libz.a | ||
| 5 | ZIP_OBJS = minizip.o zip.o ../../libz.a | ||
| 6 | |||
| 7 | .c.o: | ||
| 8 | $(CC) -c $(CFLAGS) $*.c | ||
| 9 | |||
| 10 | all: miniunz minizip | ||
| 11 | |||
| 12 | miniunz: $(UNZ_OBJS) | ||
| 13 | $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS) | ||
| 14 | |||
| 15 | minizip: $(ZIP_OBJS) | ||
| 16 | $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS) | ||
| 17 | |||
| 18 | test: miniunz minizip | ||
| 19 | ./minizip test readme.txt | ||
| 20 | ./miniunz -l test.zip | ||
| 21 | mv readme.txt readme.old | ||
| 22 | ./miniunz test.zip | ||
| 23 | |||
| 24 | clean: | ||
| 25 | /bin/rm -f *.o *~ minizip miniunz | ||
diff --git a/contrib/minizip/miniunz.c b/contrib/minizip/miniunz.c new file mode 100644 index 0000000..f3b7832 --- /dev/null +++ b/contrib/minizip/miniunz.c | |||
| @@ -0,0 +1,508 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <string.h> | ||
| 4 | #include <time.h> | ||
| 5 | #include <errno.h> | ||
| 6 | #include <fcntl.h> | ||
| 7 | |||
| 8 | #ifdef unix | ||
| 9 | # include <unistd.h> | ||
| 10 | # include <utime.h> | ||
| 11 | #else | ||
| 12 | # include <direct.h> | ||
| 13 | # include <io.h> | ||
| 14 | #endif | ||
| 15 | |||
| 16 | #include "unzip.h" | ||
| 17 | |||
| 18 | #define CASESENSITIVITY (0) | ||
| 19 | #define WRITEBUFFERSIZE (8192) | ||
| 20 | |||
| 21 | /* | ||
| 22 | mini unzip, demo of unzip package | ||
| 23 | |||
| 24 | usage : | ||
| 25 | Usage : miniunz [-exvlo] file.zip [file_to_extract] | ||
| 26 | |||
| 27 | list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT | ||
| 28 | if it exists | ||
| 29 | */ | ||
| 30 | |||
| 31 | |||
| 32 | /* change_file_date : change the date/time of a file | ||
| 33 | filename : the filename of the file where date/time must be modified | ||
| 34 | dosdate : the new date at the MSDos format (4 bytes) | ||
| 35 | tmu_date : the SAME new date at the tm_unz format */ | ||
| 36 | void change_file_date(filename,dosdate,tmu_date) | ||
| 37 | const char *filename; | ||
| 38 | uLong dosdate; | ||
| 39 | tm_unz tmu_date; | ||
| 40 | { | ||
| 41 | #ifdef WIN32 | ||
| 42 | HANDLE hFile; | ||
| 43 | FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; | ||
| 44 | |||
| 45 | hFile = CreateFile(filename,GENERIC_READ | GENERIC_WRITE, | ||
| 46 | 0,NULL,OPEN_EXISTING,0,NULL); | ||
| 47 | GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite); | ||
| 48 | DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal); | ||
| 49 | LocalFileTimeToFileTime(&ftLocal,&ftm); | ||
| 50 | SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); | ||
| 51 | CloseHandle(hFile); | ||
| 52 | #else | ||
| 53 | #ifdef unix | ||
| 54 | struct utimbuf ut; | ||
| 55 | struct tm newdate; | ||
| 56 | newdate.tm_sec = tmu_date.tm_sec; | ||
| 57 | newdate.tm_min=tmu_date.tm_min; | ||
| 58 | newdate.tm_hour=tmu_date.tm_hour; | ||
| 59 | newdate.tm_mday=tmu_date.tm_mday; | ||
| 60 | newdate.tm_mon=tmu_date.tm_mon; | ||
| 61 | if (tmu_date.tm_year > 1900) | ||
| 62 | newdate.tm_year=tmu_date.tm_year - 1900; | ||
| 63 | else | ||
| 64 | newdate.tm_year=tmu_date.tm_year ; | ||
| 65 | newdate.tm_isdst=-1; | ||
| 66 | |||
| 67 | ut.actime=ut.modtime=mktime(&newdate); | ||
| 68 | utime(filename,&ut); | ||
| 69 | #endif | ||
| 70 | #endif | ||
| 71 | } | ||
| 72 | |||
| 73 | |||
| 74 | /* mymkdir and change_file_date are not 100 % portable | ||
| 75 | As I don't know well Unix, I wait feedback for the unix portion */ | ||
| 76 | |||
| 77 | int mymkdir(dirname) | ||
| 78 | const char* dirname; | ||
| 79 | { | ||
| 80 | int ret=0; | ||
| 81 | #ifdef WIN32 | ||
| 82 | ret = mkdir(dirname); | ||
| 83 | #else | ||
| 84 | #ifdef unix | ||
| 85 | ret = mkdir (dirname,0775); | ||
| 86 | #endif | ||
| 87 | #endif | ||
| 88 | return ret; | ||
| 89 | } | ||
| 90 | |||
| 91 | int makedir (newdir) | ||
| 92 | char *newdir; | ||
| 93 | { | ||
| 94 | char *buffer ; | ||
| 95 | char *p; | ||
| 96 | int len = strlen(newdir); | ||
| 97 | |||
| 98 | if (len <= 0) | ||
| 99 | return 0; | ||
| 100 | |||
| 101 | buffer = (char*)malloc(len+1); | ||
| 102 | strcpy(buffer,newdir); | ||
| 103 | |||
| 104 | if (buffer[len-1] == '/') { | ||
| 105 | buffer[len-1] = '\0'; | ||
| 106 | } | ||
| 107 | if (mymkdir(buffer) == 0) | ||
| 108 | { | ||
| 109 | free(buffer); | ||
| 110 | return 1; | ||
| 111 | } | ||
| 112 | |||
| 113 | p = buffer+1; | ||
| 114 | while (1) | ||
| 115 | { | ||
| 116 | char hold; | ||
| 117 | |||
| 118 | while(*p && *p != '\\' && *p != '/') | ||
| 119 | p++; | ||
| 120 | hold = *p; | ||
| 121 | *p = 0; | ||
| 122 | if ((mymkdir(buffer) == -1) && (errno == ENOENT)) | ||
| 123 | { | ||
| 124 | printf("couldn't create directory %s\n",buffer); | ||
| 125 | free(buffer); | ||
| 126 | return 0; | ||
| 127 | } | ||
| 128 | if (hold == 0) | ||
| 129 | break; | ||
| 130 | *p++ = hold; | ||
| 131 | } | ||
| 132 | free(buffer); | ||
| 133 | return 1; | ||
| 134 | } | ||
| 135 | |||
| 136 | void do_banner() | ||
| 137 | { | ||
| 138 | printf("MiniUnz 0.15, demo of zLib + Unz package written by Gilles Vollant\n"); | ||
| 139 | printf("more info at http://wwww.winimage/zLibDll/unzip.htm\n\n"); | ||
| 140 | } | ||
| 141 | |||
| 142 | void do_help() | ||
| 143 | { | ||
| 144 | printf("Usage : miniunz [-exvlo] file.zip [file_to_extract]\n\n") ; | ||
| 145 | } | ||
| 146 | |||
| 147 | |||
| 148 | int do_list(uf) | ||
| 149 | unzFile uf; | ||
| 150 | { | ||
| 151 | uLong i; | ||
| 152 | unz_global_info gi; | ||
| 153 | int err; | ||
| 154 | |||
| 155 | err = unzGetGlobalInfo (uf,&gi); | ||
| 156 | if (err!=UNZ_OK) | ||
| 157 | printf("error %d with zipfile in unzGetGlobalInfo \n",err); | ||
| 158 | printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); | ||
| 159 | printf(" ------ ------ ---- ----- ---- ---- ------ ----\n"); | ||
| 160 | for (i=0;i<gi.number_entry;i++) | ||
| 161 | { | ||
| 162 | char filename_inzip[256]; | ||
| 163 | unz_file_info file_info; | ||
| 164 | uLong ratio=0; | ||
| 165 | const char *string_method; | ||
| 166 | err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); | ||
| 167 | if (err!=UNZ_OK) | ||
| 168 | { | ||
| 169 | printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); | ||
| 170 | break; | ||
| 171 | } | ||
| 172 | if (file_info.uncompressed_size>0) | ||
| 173 | ratio = (file_info.compressed_size*100)/file_info.uncompressed_size; | ||
| 174 | |||
| 175 | if (file_info.compression_method==0) | ||
| 176 | string_method="Stored"; | ||
| 177 | else | ||
| 178 | if (file_info.compression_method==Z_DEFLATED) | ||
| 179 | { | ||
| 180 | uInt iLevel=(uInt)((file_info.flag & 0x6)/2); | ||
| 181 | if (iLevel==0) | ||
| 182 | string_method="Defl:N"; | ||
| 183 | else if (iLevel==1) | ||
| 184 | string_method="Defl:X"; | ||
| 185 | else if ((iLevel==2) || (iLevel==3)) | ||
| 186 | string_method="Defl:F"; /* 2:fast , 3 : extra fast*/ | ||
| 187 | } | ||
| 188 | else | ||
| 189 | string_method="Unkn. "; | ||
| 190 | |||
| 191 | printf("%7lu %6s %7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n", | ||
| 192 | file_info.uncompressed_size,string_method,file_info.compressed_size, | ||
| 193 | ratio, | ||
| 194 | (uLong)file_info.tmu_date.tm_mon + 1, | ||
| 195 | (uLong)file_info.tmu_date.tm_mday, | ||
| 196 | (uLong)file_info.tmu_date.tm_year % 100, | ||
| 197 | (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min, | ||
| 198 | (uLong)file_info.crc,filename_inzip); | ||
| 199 | if ((i+1)<gi.number_entry) | ||
| 200 | { | ||
| 201 | err = unzGoToNextFile(uf); | ||
| 202 | if (err!=UNZ_OK) | ||
| 203 | { | ||
| 204 | printf("error %d with zipfile in unzGoToNextFile\n",err); | ||
| 205 | break; | ||
| 206 | } | ||
| 207 | } | ||
| 208 | } | ||
| 209 | |||
| 210 | return 0; | ||
| 211 | } | ||
| 212 | |||
| 213 | |||
| 214 | int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite) | ||
| 215 | unzFile uf; | ||
| 216 | const int* popt_extract_without_path; | ||
| 217 | int* popt_overwrite; | ||
| 218 | { | ||
| 219 | char filename_inzip[256]; | ||
| 220 | char* filename_withoutpath; | ||
| 221 | char* p; | ||
| 222 | int err=UNZ_OK; | ||
| 223 | FILE *fout=NULL; | ||
| 224 | void* buf; | ||
| 225 | uInt size_buf; | ||
| 226 | |||
| 227 | unz_file_info file_info; | ||
| 228 | uLong ratio=0; | ||
| 229 | err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); | ||
| 230 | |||
| 231 | if (err!=UNZ_OK) | ||
| 232 | { | ||
| 233 | printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); | ||
| 234 | return err; | ||
| 235 | } | ||
| 236 | |||
| 237 | size_buf = WRITEBUFFERSIZE; | ||
| 238 | buf = (void*)malloc(size_buf); | ||
| 239 | if (buf==NULL) | ||
| 240 | { | ||
| 241 | printf("Error allocating memory\n"); | ||
| 242 | return UNZ_INTERNALERROR; | ||
| 243 | } | ||
| 244 | |||
| 245 | p = filename_withoutpath = filename_inzip; | ||
| 246 | while ((*p) != '\0') | ||
| 247 | { | ||
| 248 | if (((*p)=='/') || ((*p)=='\\')) | ||
| 249 | filename_withoutpath = p+1; | ||
| 250 | p++; | ||
| 251 | } | ||
| 252 | |||
| 253 | if ((*filename_withoutpath)=='\0') | ||
| 254 | { | ||
| 255 | if ((*popt_extract_without_path)==0) | ||
| 256 | { | ||
| 257 | printf("creating directory: %s\n",filename_inzip); | ||
| 258 | mymkdir(filename_inzip); | ||
| 259 | } | ||
| 260 | } | ||
| 261 | else | ||
| 262 | { | ||
| 263 | const char* write_filename; | ||
| 264 | int skip=0; | ||
| 265 | |||
| 266 | if ((*popt_extract_without_path)==0) | ||
| 267 | write_filename = filename_inzip; | ||
| 268 | else | ||
| 269 | write_filename = filename_withoutpath; | ||
| 270 | |||
| 271 | err = unzOpenCurrentFile(uf); | ||
| 272 | if (err!=UNZ_OK) | ||
| 273 | { | ||
| 274 | printf("error %d with zipfile in unzOpenCurrentFile\n",err); | ||
| 275 | } | ||
| 276 | |||
| 277 | if (((*popt_overwrite)==0) && (err==UNZ_OK)) | ||
| 278 | { | ||
| 279 | char rep; | ||
| 280 | FILE* ftestexist; | ||
| 281 | ftestexist = fopen(write_filename,"rb"); | ||
| 282 | if (ftestexist!=NULL) | ||
| 283 | { | ||
| 284 | fclose(ftestexist); | ||
| 285 | do | ||
| 286 | { | ||
| 287 | char answer[128]; | ||
| 288 | printf("The file %s exist. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename); | ||
| 289 | scanf("%1s",answer); | ||
| 290 | rep = answer[0] ; | ||
| 291 | if ((rep>='a') && (rep<='z')) | ||
| 292 | rep -= 0x20; | ||
| 293 | } | ||
| 294 | while ((rep!='Y') && (rep!='N') && (rep!='A')); | ||
| 295 | } | ||
| 296 | |||
| 297 | if (rep == 'N') | ||
| 298 | skip = 1; | ||
| 299 | |||
| 300 | if (rep == 'A') | ||
| 301 | *popt_overwrite=1; | ||
| 302 | } | ||
| 303 | |||
| 304 | if ((skip==0) && (err==UNZ_OK)) | ||
| 305 | { | ||
| 306 | fout=fopen(write_filename,"wb"); | ||
| 307 | |||
| 308 | /* some zipfile don't contain directory alone before file */ | ||
| 309 | if ((fout==NULL) && ((*popt_extract_without_path)==0) && | ||
| 310 | (filename_withoutpath!=(char*)filename_inzip)) | ||
| 311 | { | ||
| 312 | char c=*(filename_withoutpath-1); | ||
| 313 | *(filename_withoutpath-1)='\0'; | ||
| 314 | makedir(write_filename); | ||
| 315 | *(filename_withoutpath-1)=c; | ||
| 316 | fout=fopen(write_filename,"wb"); | ||
| 317 | } | ||
| 318 | |||
| 319 | if (fout==NULL) | ||
| 320 | { | ||
| 321 | printf("error opening %s\n",write_filename); | ||
| 322 | } | ||
| 323 | } | ||
| 324 | |||
| 325 | if (fout!=NULL) | ||
| 326 | { | ||
| 327 | printf(" extracting: %s\n",write_filename); | ||
| 328 | |||
| 329 | do | ||
| 330 | { | ||
| 331 | err = unzReadCurrentFile(uf,buf,size_buf); | ||
| 332 | if (err<0) | ||
| 333 | { | ||
| 334 | printf("error %d with zipfile in unzReadCurrentFile\n",err); | ||
| 335 | break; | ||
| 336 | } | ||
| 337 | if (err>0) | ||
| 338 | if (fwrite(buf,err,1,fout)!=1) | ||
| 339 | { | ||
| 340 | printf("error in writing extracted file\n"); | ||
| 341 | err=UNZ_ERRNO; | ||
| 342 | break; | ||
| 343 | } | ||
| 344 | } | ||
| 345 | while (err>0); | ||
| 346 | fclose(fout); | ||
| 347 | if (err==0) | ||
| 348 | change_file_date(write_filename,file_info.dosDate, | ||
| 349 | file_info.tmu_date); | ||
| 350 | } | ||
| 351 | |||
| 352 | if (err==UNZ_OK) | ||
| 353 | { | ||
| 354 | err = unzCloseCurrentFile (uf); | ||
| 355 | if (err!=UNZ_OK) | ||
| 356 | { | ||
| 357 | printf("error %d with zipfile in unzCloseCurrentFile\n",err); | ||
| 358 | } | ||
| 359 | } | ||
| 360 | else | ||
| 361 | unzCloseCurrentFile(uf); /* don't lose the error */ | ||
| 362 | } | ||
| 363 | |||
| 364 | free(buf); | ||
| 365 | return err; | ||
| 366 | } | ||
| 367 | |||
| 368 | |||
| 369 | int do_extract(uf,opt_extract_without_path,opt_overwrite) | ||
| 370 | unzFile uf; | ||
| 371 | int opt_extract_without_path; | ||
| 372 | int opt_overwrite; | ||
| 373 | { | ||
| 374 | uLong i; | ||
| 375 | unz_global_info gi; | ||
| 376 | int err; | ||
| 377 | FILE* fout=NULL; | ||
| 378 | |||
| 379 | err = unzGetGlobalInfo (uf,&gi); | ||
| 380 | if (err!=UNZ_OK) | ||
| 381 | printf("error %d with zipfile in unzGetGlobalInfo \n",err); | ||
| 382 | |||
| 383 | for (i=0;i<gi.number_entry;i++) | ||
| 384 | { | ||
| 385 | if (do_extract_currentfile(uf,&opt_extract_without_path, | ||
| 386 | &opt_overwrite) != UNZ_OK) | ||
| 387 | break; | ||
| 388 | |||
| 389 | if ((i+1)<gi.number_entry) | ||
| 390 | { | ||
| 391 | err = unzGoToNextFile(uf); | ||
| 392 | if (err!=UNZ_OK) | ||
| 393 | { | ||
| 394 | printf("error %d with zipfile in unzGoToNextFile\n",err); | ||
| 395 | break; | ||
| 396 | } | ||
| 397 | } | ||
| 398 | } | ||
| 399 | |||
| 400 | return 0; | ||
| 401 | } | ||
| 402 | |||
| 403 | int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite) | ||
| 404 | unzFile uf; | ||
| 405 | const char* filename; | ||
| 406 | int opt_extract_without_path; | ||
| 407 | int opt_overwrite; | ||
| 408 | { | ||
| 409 | int err = UNZ_OK; | ||
| 410 | if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK) | ||
| 411 | { | ||
| 412 | printf("file %s not found in the zipfile\n",filename); | ||
| 413 | return 2; | ||
| 414 | } | ||
| 415 | |||
| 416 | if (do_extract_currentfile(uf,&opt_extract_without_path, | ||
| 417 | &opt_overwrite) == UNZ_OK) | ||
| 418 | return 0; | ||
| 419 | else | ||
| 420 | return 1; | ||
| 421 | } | ||
| 422 | |||
| 423 | |||
| 424 | int main(argc,argv) | ||
| 425 | int argc; | ||
| 426 | char *argv[]; | ||
| 427 | { | ||
| 428 | const char *zipfilename=NULL; | ||
| 429 | const char *filename_to_extract=NULL; | ||
| 430 | int i; | ||
| 431 | int opt_do_list=0; | ||
| 432 | int opt_do_extract=1; | ||
| 433 | int opt_do_extract_withoutpath=0; | ||
| 434 | int opt_overwrite=0; | ||
| 435 | char filename_try[512]; | ||
| 436 | unzFile uf=NULL; | ||
| 437 | |||
| 438 | do_banner(); | ||
| 439 | if (argc==1) | ||
| 440 | { | ||
| 441 | do_help(); | ||
| 442 | exit(0); | ||
| 443 | } | ||
| 444 | else | ||
| 445 | { | ||
| 446 | for (i=1;i<argc;i++) | ||
| 447 | { | ||
| 448 | if ((*argv[i])=='-') | ||
| 449 | { | ||
| 450 | const char *p=argv[i]+1; | ||
| 451 | |||
| 452 | while ((*p)!='\0') | ||
| 453 | { | ||
| 454 | char c=*(p++);; | ||
| 455 | if ((c=='l') || (c=='L')) | ||
| 456 | opt_do_list = 1; | ||
| 457 | if ((c=='v') || (c=='V')) | ||
| 458 | opt_do_list = 1; | ||
| 459 | if ((c=='x') || (c=='X')) | ||
| 460 | opt_do_extract = 1; | ||
| 461 | if ((c=='e') || (c=='E')) | ||
| 462 | opt_do_extract = opt_do_extract_withoutpath = 1; | ||
| 463 | if ((c=='o') || (c=='O')) | ||
| 464 | opt_overwrite=1; | ||
| 465 | } | ||
| 466 | } | ||
| 467 | else | ||
| 468 | { | ||
| 469 | if (zipfilename == NULL) | ||
| 470 | zipfilename = argv[i]; | ||
| 471 | else if (filename_to_extract==NULL) | ||
| 472 | filename_to_extract = argv[i] ; | ||
| 473 | } | ||
| 474 | } | ||
| 475 | } | ||
| 476 | |||
| 477 | if (zipfilename!=NULL) | ||
| 478 | { | ||
| 479 | strcpy(filename_try,zipfilename); | ||
| 480 | uf = unzOpen(zipfilename); | ||
| 481 | if (uf==NULL) | ||
| 482 | { | ||
| 483 | strcat(filename_try,".zip"); | ||
| 484 | uf = unzOpen(filename_try); | ||
| 485 | } | ||
| 486 | } | ||
| 487 | |||
| 488 | if (uf==NULL) | ||
| 489 | { | ||
| 490 | printf("Cannot open %s or %s.zip\n",zipfilename,zipfilename); | ||
| 491 | exit (1); | ||
| 492 | } | ||
| 493 | printf("%s opened\n",filename_try); | ||
| 494 | |||
| 495 | if (opt_do_list==1) | ||
| 496 | return do_list(uf); | ||
| 497 | else if (opt_do_extract==1) | ||
| 498 | { | ||
| 499 | if (filename_to_extract == NULL) | ||
| 500 | return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite); | ||
| 501 | else | ||
| 502 | return do_extract_onefile(uf,filename_to_extract, | ||
| 503 | opt_do_extract_withoutpath,opt_overwrite); | ||
| 504 | } | ||
| 505 | unzCloseCurrentFile(uf); | ||
| 506 | |||
| 507 | return 0; /* to avoid warning */ | ||
| 508 | } | ||
diff --git a/contrib/minizip/minizip.c b/contrib/minizip/minizip.c new file mode 100644 index 0000000..5e492d2 --- /dev/null +++ b/contrib/minizip/minizip.c | |||
| @@ -0,0 +1,302 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <string.h> | ||
| 4 | #include <time.h> | ||
| 5 | #include <errno.h> | ||
| 6 | #include <fcntl.h> | ||
| 7 | |||
| 8 | #ifdef unix | ||
| 9 | # include <unistd.h> | ||
| 10 | # include <utime.h> | ||
| 11 | # include <sys/types.h> | ||
| 12 | # include <sys/stat.h> | ||
| 13 | #else | ||
| 14 | # include <direct.h> | ||
| 15 | # include <io.h> | ||
| 16 | #endif | ||
| 17 | |||
| 18 | #include "zip.h" | ||
| 19 | |||
| 20 | |||
| 21 | #define WRITEBUFFERSIZE (16384) | ||
| 22 | #define MAXFILENAME (256) | ||
| 23 | |||
| 24 | #ifdef WIN32 | ||
| 25 | uLong filetime(f, tmzip, dt) | ||
| 26 | char *f; /* name of file to get info on */ | ||
| 27 | tm_zip *tmzip; /* return value: access, modific. and creation times */ | ||
| 28 | uLong *dt; /* dostime */ | ||
| 29 | { | ||
| 30 | int ret = 0; | ||
| 31 | { | ||
| 32 | FILETIME ftLocal; | ||
| 33 | HANDLE hFind; | ||
| 34 | WIN32_FIND_DATA ff32; | ||
| 35 | |||
| 36 | hFind = FindFirstFile(f,&ff32); | ||
| 37 | if (hFind != INVALID_HANDLE_VALUE) | ||
| 38 | { | ||
| 39 | FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal); | ||
| 40 | FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0); | ||
| 41 | FindClose(hFind); | ||
| 42 | ret = 1; | ||
| 43 | } | ||
| 44 | } | ||
| 45 | return ret; | ||
| 46 | } | ||
| 47 | #else | ||
| 48 | #ifdef unix | ||
| 49 | uLong filetime(f, tmzip, dt) | ||
| 50 | char *f; /* name of file to get info on */ | ||
| 51 | tm_zip *tmzip; /* return value: access, modific. and creation times */ | ||
| 52 | uLong *dt; /* dostime */ | ||
| 53 | { | ||
| 54 | int ret=0; | ||
| 55 | struct stat s; /* results of stat() */ | ||
| 56 | struct tm* filedate; | ||
| 57 | time_t tm_t=0; | ||
| 58 | |||
| 59 | if (strcmp(f,"-")!=0) | ||
| 60 | { | ||
| 61 | char name[MAXFILENAME]; | ||
| 62 | int len = strlen(f); | ||
| 63 | strcpy(name, f); | ||
| 64 | if (name[len - 1] == '/') | ||
| 65 | name[len - 1] = '\0'; | ||
| 66 | /* not all systems allow stat'ing a file with / appended */ | ||
| 67 | if (stat(name,&s)==0) | ||
| 68 | { | ||
| 69 | tm_t = s.st_mtime; | ||
| 70 | ret = 1; | ||
| 71 | } | ||
| 72 | } | ||
| 73 | filedate = localtime(&tm_t); | ||
| 74 | |||
| 75 | tmzip->tm_sec = filedate->tm_sec; | ||
| 76 | tmzip->tm_min = filedate->tm_min; | ||
| 77 | tmzip->tm_hour = filedate->tm_hour; | ||
| 78 | tmzip->tm_mday = filedate->tm_mday; | ||
| 79 | tmzip->tm_mon = filedate->tm_mon ; | ||
| 80 | tmzip->tm_year = filedate->tm_year; | ||
| 81 | |||
| 82 | return ret; | ||
| 83 | } | ||
| 84 | #else | ||
| 85 | uLong filetime(f, tmzip, dt) | ||
| 86 | char *f; /* name of file to get info on */ | ||
| 87 | tm_zip *tmzip; /* return value: access, modific. and creation times */ | ||
| 88 | uLong *dt; /* dostime */ | ||
| 89 | { | ||
| 90 | return 0; | ||
| 91 | } | ||
| 92 | #endif | ||
| 93 | #endif | ||
| 94 | |||
| 95 | |||
| 96 | |||
| 97 | |||
| 98 | int check_exist_file(filename) | ||
| 99 | const char* filename; | ||
| 100 | { | ||
| 101 | FILE* ftestexist; | ||
| 102 | int ret = 1; | ||
| 103 | ftestexist = fopen(filename,"rb"); | ||
| 104 | if (ftestexist==NULL) | ||
| 105 | ret = 0; | ||
| 106 | else | ||
| 107 | fclose(ftestexist); | ||
| 108 | return ret; | ||
| 109 | } | ||
| 110 | |||
| 111 | void do_banner() | ||
| 112 | { | ||
| 113 | printf("MiniZip 0.15, demo of zLib + Zip package written by Gilles Vollant\n"); | ||
| 114 | printf("more info at http://wwww.winimage/zLibDll/unzip.htm\n\n"); | ||
| 115 | } | ||
| 116 | |||
| 117 | void do_help() | ||
| 118 | { | ||
| 119 | printf("Usage : minizip [-o] file.zip [files_to_add]\n\n") ; | ||
| 120 | } | ||
| 121 | |||
| 122 | int main(argc,argv) | ||
| 123 | int argc; | ||
| 124 | char *argv[]; | ||
| 125 | { | ||
| 126 | int i; | ||
| 127 | int opt_overwrite=0; | ||
| 128 | int opt_compress_level=Z_DEFAULT_COMPRESSION; | ||
| 129 | int zipfilenamearg = 0; | ||
| 130 | char filename_try[MAXFILENAME]; | ||
| 131 | int zipok; | ||
| 132 | int err=0; | ||
| 133 | int size_buf=0; | ||
| 134 | void* buf=NULL, | ||
| 135 | |||
| 136 | |||
| 137 | do_banner(); | ||
| 138 | if (argc==1) | ||
| 139 | { | ||
| 140 | do_help(); | ||
| 141 | exit(0); | ||
| 142 | return 0; | ||
| 143 | } | ||
| 144 | else | ||
| 145 | { | ||
| 146 | for (i=1;i<argc;i++) | ||
| 147 | { | ||
| 148 | if ((*argv[i])=='-') | ||
| 149 | { | ||
| 150 | const char *p=argv[i]+1; | ||
| 151 | |||
| 152 | while ((*p)!='\0') | ||
| 153 | { | ||
| 154 | char c=*(p++);; | ||
| 155 | if ((c=='o') || (c=='O')) | ||
| 156 | opt_overwrite = 1; | ||
| 157 | if ((c>='0') && (c<='9')) | ||
| 158 | opt_compress_level = c-'0'; | ||
| 159 | } | ||
| 160 | } | ||
| 161 | else | ||
| 162 | if (zipfilenamearg == 0) | ||
| 163 | zipfilenamearg = i ; | ||
| 164 | } | ||
| 165 | } | ||
| 166 | |||
| 167 | size_buf = WRITEBUFFERSIZE; | ||
| 168 | buf = (void*)malloc(size_buf); | ||
| 169 | if (buf==NULL) | ||
| 170 | { | ||
| 171 | printf("Error allocating memory\n"); | ||
| 172 | return ZIP_INTERNALERROR; | ||
| 173 | } | ||
| 174 | |||
| 175 | if (zipfilenamearg==0) | ||
| 176 | zipok=0; | ||
| 177 | else | ||
| 178 | { | ||
| 179 | int i,len; | ||
| 180 | int dot_found=0; | ||
| 181 | |||
| 182 | zipok = 1 ; | ||
| 183 | strcpy(filename_try,argv[zipfilenamearg]); | ||
| 184 | len=strlen(filename_try); | ||
| 185 | for (i=0;i<len;i++) | ||
| 186 | if (filename_try[i]=='.') | ||
| 187 | dot_found=1; | ||
| 188 | |||
| 189 | if (dot_found==0) | ||
| 190 | strcat(filename_try,".zip"); | ||
| 191 | |||
| 192 | if (opt_overwrite==0) | ||
| 193 | if (check_exist_file(filename_try)!=0) | ||
| 194 | { | ||
| 195 | char rep; | ||
| 196 | do | ||
| 197 | { | ||
| 198 | char answer[128]; | ||
| 199 | printf("The file %s exist. Overwrite ? [y]es, [n]o : ",filename_try); | ||
| 200 | scanf("%1s",answer); | ||
| 201 | rep = answer[0] ; | ||
| 202 | if ((rep>='a') && (rep<='z')) | ||
| 203 | rep -= 0x20; | ||
| 204 | } | ||
| 205 | while ((rep!='Y') && (rep!='N')); | ||
| 206 | if (rep=='N') | ||
| 207 | zipok = 0; | ||
| 208 | } | ||
| 209 | } | ||
| 210 | |||
| 211 | if (zipok==1) | ||
| 212 | { | ||
| 213 | zipFile zf; | ||
| 214 | int errclose; | ||
| 215 | zf = zipOpen(filename_try,0); | ||
| 216 | if (zf == NULL) | ||
| 217 | { | ||
| 218 | printf("error opening %s\n",filename_try); | ||
| 219 | err= ZIP_ERRNO; | ||
| 220 | } | ||
| 221 | else | ||
| 222 | printf("creating %s\n",filename_try); | ||
| 223 | |||
| 224 | for (i=zipfilenamearg+1;(i<argc) && (err==ZIP_OK);i++) | ||
| 225 | { | ||
| 226 | if (((*(argv[i]))!='-') && ((*(argv[i]))!='/')) | ||
| 227 | { | ||
| 228 | FILE * fin; | ||
| 229 | int size_read; | ||
| 230 | const char* filenameinzip = argv[i]; | ||
| 231 | zip_fileinfo zi; | ||
| 232 | |||
| 233 | zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour = | ||
| 234 | zi.tmz_date.tm_mday = zi.tmz_date.tm_min = zi.tmz_date.tm_year = 0; | ||
| 235 | zi.dosDate = 0; | ||
| 236 | zi.internal_fa = 0; | ||
| 237 | zi.external_fa = 0; | ||
| 238 | filetime(filenameinzip,&zi.tmz_date,&zi.dosDate); | ||
| 239 | |||
| 240 | |||
| 241 | err = zipOpenNewFileInZip(zf,filenameinzip,&zi, | ||
| 242 | NULL,0,NULL,0,NULL /* comment*/, | ||
| 243 | (opt_compress_level != 0) ? Z_DEFLATED : 0, | ||
| 244 | opt_compress_level); | ||
| 245 | |||
| 246 | if (err != ZIP_OK) | ||
| 247 | printf("error in opening %s in zipfile\n",filenameinzip); | ||
| 248 | else | ||
| 249 | { | ||
| 250 | fin = fopen(filenameinzip,"rb"); | ||
| 251 | if (fin==NULL) | ||
| 252 | { | ||
| 253 | err=ZIP_ERRNO; | ||
| 254 | printf("error in opening %s for reading\n",filenameinzip); | ||
| 255 | } | ||
| 256 | } | ||
| 257 | |||
| 258 | if (err == ZIP_OK) | ||
| 259 | do | ||
| 260 | { | ||
| 261 | err = ZIP_OK; | ||
| 262 | size_read = fread(buf,1,size_buf,fin); | ||
| 263 | if (size_read < size_buf) | ||
| 264 | if (feof(fin)==0) | ||
| 265 | { | ||
| 266 | printf("error in reading %s\n",filenameinzip); | ||
| 267 | err = ZIP_ERRNO; | ||
| 268 | } | ||
| 269 | |||
| 270 | if (size_read>0) | ||
| 271 | { | ||
| 272 | err = zipWriteInFileInZip (zf,buf,size_read); | ||
| 273 | if (err<0) | ||
| 274 | { | ||
| 275 | printf("error in writing %s in the zipfile\n", | ||
| 276 | filenameinzip); | ||
| 277 | } | ||
| 278 | |||
| 279 | } | ||
| 280 | } while ((err == ZIP_OK) && (size_read>0)); | ||
| 281 | |||
| 282 | fclose(fin); | ||
| 283 | if (err<0) | ||
| 284 | err=ZIP_ERRNO; | ||
| 285 | else | ||
| 286 | { | ||
| 287 | err = zipCloseFileInZip(zf); | ||
| 288 | if (err!=ZIP_OK) | ||
| 289 | printf("error in closing %s in the zipfile\n", | ||
| 290 | filenameinzip); | ||
| 291 | } | ||
| 292 | } | ||
| 293 | } | ||
| 294 | errclose = zipClose(zf,NULL); | ||
| 295 | if (errclose != ZIP_OK) | ||
| 296 | printf("error in closing %s\n",filename_try); | ||
| 297 | } | ||
| 298 | |||
| 299 | free(buf); | ||
| 300 | exit(0); | ||
| 301 | return 0; /* to avoid warning */ | ||
| 302 | } | ||
diff --git a/contrib/minizip/readme.txt b/contrib/minizip/readme.txt new file mode 100644 index 0000000..1fc023c --- /dev/null +++ b/contrib/minizip/readme.txt | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | |||
| 2 | UnZip 0.15 additionnal library | ||
| 3 | |||
| 4 | |||
| 5 | This unzip package allow extract file from .ZIP file, compatible with | ||
| 6 | PKZip 2.04g, WinZip, InfoZip tools and compatible. | ||
| 7 | |||
| 8 | Multi volume ZipFile (span) are not supported, and old compression used by old | ||
| 9 | PKZip 1.x are not supported. | ||
| 10 | |||
| 11 | See probdesc.zip from PKWare for specification of .ZIP format. | ||
| 12 | |||
| 13 | What is Unzip | ||
| 14 | The Zlib library support the deflate compression and the creation of gzip (.gz) | ||
| 15 | file. Zlib is free and small. | ||
| 16 | The .Zip format, which can contain several compressed files (.gz can containt | ||
| 17 | only one file) is a very popular format. This is why I've written a package for reading file compressed in Zipfile. | ||
| 18 | |||
| 19 | Using Unzip package | ||
| 20 | |||
| 21 | You need source of Zlib (get zlib111.zip and read zlib.h). | ||
| 22 | Get unzlb015.zip and read unzip.h (whith documentation of unzip functions) | ||
| 23 | |||
| 24 | The Unzip package is only two file : unzip.h and unzip.c. But it use the Zlib | ||
| 25 | files. | ||
| 26 | unztst.c is a simple sample program, which list file in a zipfile and display | ||
| 27 | README.TXT or FILE_ID.DIZ (if these files are found). | ||
| 28 | miniunz.c is a mini unzip program. | ||
| 29 | |||
| 30 | I'm also currenlyt writing a zipping portion (zip.h, zip.c and test with minizip.c) | ||
| 31 | |||
| 32 | Please email me for feedback. | ||
| 33 | I hope my source is compatible with Unix system, but I need your help for be sure | ||
| 34 | |||
| 35 | Latest revision : Mar 04th, 1998 | ||
| 36 | |||
| 37 | Check http://www.winimage.com/zLibDll/unzip.html for up to date info. | ||
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c new file mode 100644 index 0000000..78a8473 --- /dev/null +++ b/contrib/minizip/unzip.c | |||
| @@ -0,0 +1,1294 @@ | |||
| 1 | /* unzip.c -- IO on .zip files using zlib | ||
| 2 | Version 0.15 beta, Mar 19th, 1998, | ||
| 3 | |||
| 4 | Read unzip.h for more info | ||
| 5 | */ | ||
| 6 | |||
| 7 | |||
| 8 | #include <stdio.h> | ||
| 9 | #include <stdlib.h> | ||
| 10 | #include <string.h> | ||
| 11 | #include "zlib.h" | ||
| 12 | #include "unzip.h" | ||
| 13 | |||
| 14 | #ifdef STDC | ||
| 15 | # include <stddef.h> | ||
| 16 | # include <string.h> | ||
| 17 | # include <stdlib.h> | ||
| 18 | #endif | ||
| 19 | #ifdef NO_ERRNO_H | ||
| 20 | extern int errno; | ||
| 21 | #else | ||
| 22 | # include <errno.h> | ||
| 23 | #endif | ||
| 24 | |||
| 25 | |||
| 26 | #ifndef local | ||
| 27 | # define local static | ||
| 28 | #endif | ||
| 29 | /* compile with -Dlocal if your debugger can't find static symbols */ | ||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | #if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \ | ||
| 34 | !defined(CASESENSITIVITYDEFAULT_NO) | ||
| 35 | #define CASESENSITIVITYDEFAULT_NO | ||
| 36 | #endif | ||
| 37 | |||
| 38 | |||
| 39 | #ifndef UNZ_BUFSIZE | ||
| 40 | #define UNZ_BUFSIZE (16384) | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #ifndef UNZ_MAXFILENAMEINZIP | ||
| 44 | #define UNZ_MAXFILENAMEINZIP (256) | ||
| 45 | #endif | ||
| 46 | |||
| 47 | #ifndef ALLOC | ||
| 48 | # define ALLOC(size) (malloc(size)) | ||
| 49 | #endif | ||
| 50 | #ifndef TRYFREE | ||
| 51 | # define TRYFREE(p) {if (p) free(p);} | ||
| 52 | #endif | ||
| 53 | |||
| 54 | #define SIZECENTRALDIRITEM (0x2e) | ||
| 55 | #define SIZEZIPLOCALHEADER (0x1e) | ||
| 56 | |||
| 57 | |||
| 58 | /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ | ||
| 59 | |||
| 60 | #ifndef SEEK_CUR | ||
| 61 | #define SEEK_CUR 1 | ||
| 62 | #endif | ||
| 63 | |||
| 64 | #ifndef SEEK_END | ||
| 65 | #define SEEK_END 2 | ||
| 66 | #endif | ||
| 67 | |||
| 68 | #ifndef SEEK_SET | ||
| 69 | #define SEEK_SET 0 | ||
| 70 | #endif | ||
| 71 | |||
| 72 | const char unz_copyright[] = | ||
| 73 | " unzip 0.15 Copyright 1998 Gilles Vollant "; | ||
| 74 | |||
| 75 | /* unz_file_info_interntal contain internal info about a file in zipfile*/ | ||
| 76 | typedef struct unz_file_info_internal_s | ||
| 77 | { | ||
| 78 | uLong offset_curfile;/* relative offset of local header 4 bytes */ | ||
| 79 | } unz_file_info_internal; | ||
| 80 | |||
| 81 | |||
| 82 | /* file_in_zip_read_info_s contain internal information about a file in zipfile, | ||
| 83 | when reading and decompress it */ | ||
| 84 | typedef struct | ||
| 85 | { | ||
| 86 | char *read_buffer; /* internal buffer for compressed data */ | ||
| 87 | z_stream stream; /* zLib stream structure for inflate */ | ||
| 88 | |||
| 89 | uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ | ||
| 90 | uLong stream_initialised; /* flag set if stream structure is initialised*/ | ||
| 91 | |||
| 92 | uLong offset_local_extrafield;/* offset of the local extra field */ | ||
| 93 | uInt size_local_extrafield;/* size of the local extra field */ | ||
| 94 | uLong pos_local_extrafield; /* position in the local extra field in read*/ | ||
| 95 | |||
| 96 | uLong crc32; /* crc32 of all data uncompressed */ | ||
| 97 | uLong crc32_wait; /* crc32 we must obtain after decompress all */ | ||
| 98 | uLong rest_read_compressed; /* number of byte to be decompressed */ | ||
| 99 | uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ | ||
| 100 | FILE* file; /* io structore of the zipfile */ | ||
| 101 | uLong compression_method; /* compression method (0==store) */ | ||
| 102 | uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ | ||
| 103 | } file_in_zip_read_info_s; | ||
| 104 | |||
| 105 | |||
| 106 | /* unz_s contain internal information about the zipfile | ||
| 107 | */ | ||
| 108 | typedef struct | ||
| 109 | { | ||
| 110 | FILE* file; /* io structore of the zipfile */ | ||
| 111 | unz_global_info gi; /* public global information */ | ||
| 112 | uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ | ||
| 113 | uLong num_file; /* number of the current file in the zipfile*/ | ||
| 114 | uLong pos_in_central_dir; /* pos of the current file in the central dir*/ | ||
| 115 | uLong current_file_ok; /* flag about the usability of the current file*/ | ||
| 116 | uLong central_pos; /* position of the beginning of the central dir*/ | ||
| 117 | |||
| 118 | uLong size_central_dir; /* size of the central directory */ | ||
| 119 | uLong offset_central_dir; /* offset of start of central directory with | ||
| 120 | respect to the starting disk number */ | ||
| 121 | |||
| 122 | unz_file_info cur_file_info; /* public info about the current file in zip*/ | ||
| 123 | unz_file_info_internal cur_file_info_internal; /* private info about it*/ | ||
| 124 | file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current | ||
| 125 | file if we are decompressing it */ | ||
| 126 | } unz_s; | ||
| 127 | |||
| 128 | |||
| 129 | /* =========================================================================== | ||
| 130 | Read a byte from a gz_stream; update next_in and avail_in. Return EOF | ||
| 131 | for end of file. | ||
| 132 | IN assertion: the stream s has been sucessfully opened for reading. | ||
| 133 | */ | ||
| 134 | |||
| 135 | |||
| 136 | local int unzlocal_getByte(fin,pi) | ||
| 137 | FILE *fin; | ||
| 138 | int *pi; | ||
| 139 | { | ||
| 140 | unsigned char c; | ||
| 141 | int err = fread(&c, 1, 1, fin); | ||
| 142 | if (err==1) | ||
| 143 | { | ||
| 144 | *pi = (int)c; | ||
| 145 | return UNZ_OK; | ||
| 146 | } | ||
| 147 | else | ||
| 148 | { | ||
| 149 | if (ferror(fin)) | ||
| 150 | return UNZ_ERRNO; | ||
| 151 | else | ||
| 152 | return UNZ_EOF; | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 156 | |||
| 157 | /* =========================================================================== | ||
| 158 | Reads a long in LSB order from the given gz_stream. Sets | ||
| 159 | */ | ||
| 160 | local int unzlocal_getShort (fin,pX) | ||
| 161 | FILE* fin; | ||
| 162 | uLong *pX; | ||
| 163 | { | ||
| 164 | uLong x ; | ||
| 165 | int i; | ||
| 166 | int err; | ||
| 167 | |||
| 168 | err = unzlocal_getByte(fin,&i); | ||
| 169 | x = (uLong)i; | ||
| 170 | |||
| 171 | if (err==UNZ_OK) | ||
| 172 | err = unzlocal_getByte(fin,&i); | ||
| 173 | x += ((uLong)i)<<8; | ||
| 174 | |||
| 175 | if (err==UNZ_OK) | ||
| 176 | *pX = x; | ||
| 177 | else | ||
| 178 | *pX = 0; | ||
| 179 | return err; | ||
| 180 | } | ||
| 181 | |||
| 182 | local int unzlocal_getLong (fin,pX) | ||
| 183 | FILE* fin; | ||
| 184 | uLong *pX; | ||
| 185 | { | ||
| 186 | uLong x ; | ||
| 187 | int i; | ||
| 188 | int err; | ||
| 189 | |||
| 190 | err = unzlocal_getByte(fin,&i); | ||
| 191 | x = (uLong)i; | ||
| 192 | |||
| 193 | if (err==UNZ_OK) | ||
| 194 | err = unzlocal_getByte(fin,&i); | ||
| 195 | x += ((uLong)i)<<8; | ||
| 196 | |||
| 197 | if (err==UNZ_OK) | ||
| 198 | err = unzlocal_getByte(fin,&i); | ||
| 199 | x += ((uLong)i)<<16; | ||
| 200 | |||
| 201 | if (err==UNZ_OK) | ||
| 202 | err = unzlocal_getByte(fin,&i); | ||
| 203 | x += ((uLong)i)<<24; | ||
| 204 | |||
| 205 | if (err==UNZ_OK) | ||
| 206 | *pX = x; | ||
| 207 | else | ||
| 208 | *pX = 0; | ||
| 209 | return err; | ||
| 210 | } | ||
| 211 | |||
| 212 | |||
| 213 | /* My own strcmpi / strcasecmp */ | ||
| 214 | local int strcmpcasenosensitive_internal (fileName1,fileName2) | ||
| 215 | const char* fileName1; | ||
| 216 | const char* fileName2; | ||
| 217 | { | ||
| 218 | for (;;) | ||
| 219 | { | ||
| 220 | char c1=*(fileName1++); | ||
| 221 | char c2=*(fileName2++); | ||
| 222 | if ((c1>='a') && (c1<='z')) | ||
| 223 | c1 -= 0x20; | ||
| 224 | if ((c2>='a') && (c2<='z')) | ||
| 225 | c2 -= 0x20; | ||
| 226 | if (c1=='\0') | ||
| 227 | return ((c2=='\0') ? 0 : -1); | ||
| 228 | if (c2=='\0') | ||
| 229 | return 1; | ||
| 230 | if (c1<c2) | ||
| 231 | return -1; | ||
| 232 | if (c1>c2) | ||
| 233 | return 1; | ||
| 234 | } | ||
| 235 | } | ||
| 236 | |||
| 237 | |||
| 238 | #ifdef CASESENSITIVITYDEFAULT_NO | ||
| 239 | #define CASESENSITIVITYDEFAULTVALUE 2 | ||
| 240 | #else | ||
| 241 | #define CASESENSITIVITYDEFAULTVALUE 1 | ||
| 242 | #endif | ||
| 243 | |||
| 244 | #ifndef STRCMPCASENOSENTIVEFUNCTION | ||
| 245 | #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal | ||
| 246 | #endif | ||
| 247 | |||
| 248 | /* | ||
| 249 | Compare two filename (fileName1,fileName2). | ||
| 250 | If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) | ||
| 251 | If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi | ||
| 252 | or strcasecmp) | ||
| 253 | If iCaseSenisivity = 0, case sensitivity is defaut of your operating system | ||
| 254 | (like 1 on Unix, 2 on Windows) | ||
| 255 | |||
| 256 | */ | ||
| 257 | extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) | ||
| 258 | const char* fileName1; | ||
| 259 | const char* fileName2; | ||
| 260 | int iCaseSensitivity; | ||
| 261 | { | ||
| 262 | if (iCaseSensitivity==0) | ||
| 263 | iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; | ||
| 264 | |||
| 265 | if (iCaseSensitivity==1) | ||
| 266 | return strcmp(fileName1,fileName2); | ||
| 267 | |||
| 268 | return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); | ||
| 269 | } | ||
| 270 | |||
| 271 | #define BUFREADCOMMENT (0x400) | ||
| 272 | |||
| 273 | /* | ||
| 274 | Locate the Central directory of a zipfile (at the end, just before | ||
| 275 | the global comment) | ||
| 276 | */ | ||
| 277 | local uLong unzlocal_SearchCentralDir(fin) | ||
| 278 | FILE *fin; | ||
| 279 | { | ||
| 280 | unsigned char* buf; | ||
| 281 | uLong uSizeFile; | ||
| 282 | uLong uBackRead; | ||
| 283 | uLong uMaxBack=0xffff; /* maximum size of global comment */ | ||
| 284 | uLong uPosFound=0; | ||
| 285 | |||
| 286 | if (fseek(fin,0,SEEK_END) != 0) | ||
| 287 | return 0; | ||
| 288 | |||
| 289 | |||
| 290 | uSizeFile = ftell( fin ); | ||
| 291 | |||
| 292 | if (uMaxBack>uSizeFile) | ||
| 293 | uMaxBack = uSizeFile; | ||
| 294 | |||
| 295 | buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); | ||
| 296 | if (buf==NULL) | ||
| 297 | return 0; | ||
| 298 | |||
| 299 | uBackRead = 4; | ||
| 300 | while (uBackRead<uMaxBack) | ||
| 301 | { | ||
| 302 | uLong uReadSize,uReadPos ; | ||
| 303 | int i; | ||
| 304 | if (uBackRead+BUFREADCOMMENT>uMaxBack) | ||
| 305 | uBackRead = uMaxBack; | ||
| 306 | else | ||
| 307 | uBackRead+=BUFREADCOMMENT; | ||
| 308 | uReadPos = uSizeFile-uBackRead ; | ||
| 309 | |||
| 310 | uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? | ||
| 311 | (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); | ||
| 312 | if (fseek(fin,uReadPos,SEEK_SET)!=0) | ||
| 313 | break; | ||
| 314 | |||
| 315 | if (fread(buf,(uInt)uReadSize,1,fin)!=1) | ||
| 316 | break; | ||
| 317 | |||
| 318 | for (i=0;i<(int)uReadSize-3;i++) | ||
| 319 | if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && | ||
| 320 | ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) | ||
| 321 | { | ||
| 322 | uPosFound = uReadPos+i; | ||
| 323 | break; | ||
| 324 | } | ||
| 325 | |||
| 326 | if (uPosFound!=0) | ||
| 327 | break; | ||
| 328 | } | ||
| 329 | TRYFREE(buf); | ||
| 330 | return uPosFound; | ||
| 331 | } | ||
| 332 | |||
| 333 | /* | ||
| 334 | Open a Zip file. path contain the full pathname (by example, | ||
| 335 | on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer | ||
| 336 | "zlib/zlib109.zip". | ||
| 337 | If the zipfile cannot be opened (file don't exist or in not valid), the | ||
| 338 | return value is NULL. | ||
| 339 | Else, the return value is a unzFile Handle, usable with other function | ||
| 340 | of this unzip package. | ||
| 341 | */ | ||
| 342 | extern unzFile ZEXPORT unzOpen (path) | ||
| 343 | const char *path; | ||
| 344 | { | ||
| 345 | unz_s us; | ||
| 346 | unz_s *s; | ||
| 347 | uLong central_pos,uL; | ||
| 348 | FILE * fin ; | ||
| 349 | |||
| 350 | uLong number_disk; /* number of the current dist, used for | ||
| 351 | spaning ZIP, unsupported, always 0*/ | ||
| 352 | uLong number_disk_with_CD; /* number the the disk with central dir, used | ||
| 353 | for spaning ZIP, unsupported, always 0*/ | ||
| 354 | uLong number_entry_CD; /* total number of entries in | ||
| 355 | the central dir | ||
| 356 | (same than number_entry on nospan) */ | ||
| 357 | |||
| 358 | int err=UNZ_OK; | ||
| 359 | |||
| 360 | if (unz_copyright[0]!=' ') | ||
| 361 | return NULL; | ||
| 362 | |||
| 363 | fin=fopen(path,"rb"); | ||
| 364 | if (fin==NULL) | ||
| 365 | return NULL; | ||
| 366 | |||
| 367 | central_pos = unzlocal_SearchCentralDir(fin); | ||
| 368 | if (central_pos==0) | ||
| 369 | err=UNZ_ERRNO; | ||
| 370 | |||
| 371 | if (fseek(fin,central_pos,SEEK_SET)!=0) | ||
| 372 | err=UNZ_ERRNO; | ||
| 373 | |||
| 374 | /* the signature, already checked */ | ||
| 375 | if (unzlocal_getLong(fin,&uL)!=UNZ_OK) | ||
| 376 | err=UNZ_ERRNO; | ||
| 377 | |||
| 378 | /* number of this disk */ | ||
| 379 | if (unzlocal_getShort(fin,&number_disk)!=UNZ_OK) | ||
| 380 | err=UNZ_ERRNO; | ||
| 381 | |||
| 382 | /* number of the disk with the start of the central directory */ | ||
| 383 | if (unzlocal_getShort(fin,&number_disk_with_CD)!=UNZ_OK) | ||
| 384 | err=UNZ_ERRNO; | ||
| 385 | |||
| 386 | /* total number of entries in the central dir on this disk */ | ||
| 387 | if (unzlocal_getShort(fin,&us.gi.number_entry)!=UNZ_OK) | ||
| 388 | err=UNZ_ERRNO; | ||
| 389 | |||
| 390 | /* total number of entries in the central dir */ | ||
| 391 | if (unzlocal_getShort(fin,&number_entry_CD)!=UNZ_OK) | ||
| 392 | err=UNZ_ERRNO; | ||
| 393 | |||
| 394 | if ((number_entry_CD!=us.gi.number_entry) || | ||
| 395 | (number_disk_with_CD!=0) || | ||
| 396 | (number_disk!=0)) | ||
| 397 | err=UNZ_BADZIPFILE; | ||
| 398 | |||
| 399 | /* size of the central directory */ | ||
| 400 | if (unzlocal_getLong(fin,&us.size_central_dir)!=UNZ_OK) | ||
| 401 | err=UNZ_ERRNO; | ||
| 402 | |||
| 403 | /* offset of start of central directory with respect to the | ||
| 404 | starting disk number */ | ||
| 405 | if (unzlocal_getLong(fin,&us.offset_central_dir)!=UNZ_OK) | ||
| 406 | err=UNZ_ERRNO; | ||
| 407 | |||
| 408 | /* zipfile comment length */ | ||
| 409 | if (unzlocal_getShort(fin,&us.gi.size_comment)!=UNZ_OK) | ||
| 410 | err=UNZ_ERRNO; | ||
| 411 | |||
| 412 | if ((central_pos<us.offset_central_dir+us.size_central_dir) && | ||
| 413 | (err==UNZ_OK)) | ||
| 414 | err=UNZ_BADZIPFILE; | ||
| 415 | |||
| 416 | if (err!=UNZ_OK) | ||
| 417 | { | ||
| 418 | fclose(fin); | ||
| 419 | return NULL; | ||
| 420 | } | ||
| 421 | |||
| 422 | us.file=fin; | ||
| 423 | us.byte_before_the_zipfile = central_pos - | ||
| 424 | (us.offset_central_dir+us.size_central_dir); | ||
| 425 | us.central_pos = central_pos; | ||
| 426 | us.pfile_in_zip_read = NULL; | ||
| 427 | |||
| 428 | |||
| 429 | s=(unz_s*)ALLOC(sizeof(unz_s)); | ||
| 430 | *s=us; | ||
| 431 | unzGoToFirstFile((unzFile)s); | ||
| 432 | return (unzFile)s; | ||
| 433 | } | ||
| 434 | |||
| 435 | |||
| 436 | /* | ||
| 437 | Close a ZipFile opened with unzipOpen. | ||
| 438 | If there is files inside the .Zip opened with unzipOpenCurrentFile (see later), | ||
| 439 | these files MUST be closed with unzipCloseCurrentFile before call unzipClose. | ||
| 440 | return UNZ_OK if there is no problem. */ | ||
| 441 | extern int ZEXPORT unzClose (file) | ||
| 442 | unzFile file; | ||
| 443 | { | ||
| 444 | unz_s* s; | ||
| 445 | if (file==NULL) | ||
| 446 | return UNZ_PARAMERROR; | ||
| 447 | s=(unz_s*)file; | ||
| 448 | |||
| 449 | if (s->pfile_in_zip_read!=NULL) | ||
| 450 | unzCloseCurrentFile(file); | ||
| 451 | |||
| 452 | fclose(s->file); | ||
| 453 | TRYFREE(s); | ||
| 454 | return UNZ_OK; | ||
| 455 | } | ||
| 456 | |||
| 457 | |||
| 458 | /* | ||
| 459 | Write info about the ZipFile in the *pglobal_info structure. | ||
| 460 | No preparation of the structure is needed | ||
| 461 | return UNZ_OK if there is no problem. */ | ||
| 462 | extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) | ||
| 463 | unzFile file; | ||
| 464 | unz_global_info *pglobal_info; | ||
| 465 | { | ||
| 466 | unz_s* s; | ||
| 467 | if (file==NULL) | ||
| 468 | return UNZ_PARAMERROR; | ||
| 469 | s=(unz_s*)file; | ||
| 470 | *pglobal_info=s->gi; | ||
| 471 | return UNZ_OK; | ||
| 472 | } | ||
| 473 | |||
| 474 | |||
| 475 | /* | ||
| 476 | Translate date/time from Dos format to tm_unz (readable more easilty) | ||
| 477 | */ | ||
| 478 | local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) | ||
| 479 | uLong ulDosDate; | ||
| 480 | tm_unz* ptm; | ||
| 481 | { | ||
| 482 | uLong uDate; | ||
| 483 | uDate = (uLong)(ulDosDate>>16); | ||
| 484 | ptm->tm_mday = (uInt)(uDate&0x1f) ; | ||
| 485 | ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; | ||
| 486 | ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; | ||
| 487 | |||
| 488 | ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); | ||
| 489 | ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; | ||
| 490 | ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; | ||
| 491 | } | ||
| 492 | |||
| 493 | /* | ||
| 494 | Get Info about the current file in the zipfile, with internal only info | ||
| 495 | */ | ||
| 496 | local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, | ||
| 497 | unz_file_info *pfile_info, | ||
| 498 | unz_file_info_internal | ||
| 499 | *pfile_info_internal, | ||
| 500 | char *szFileName, | ||
| 501 | uLong fileNameBufferSize, | ||
| 502 | void *extraField, | ||
| 503 | uLong extraFieldBufferSize, | ||
| 504 | char *szComment, | ||
| 505 | uLong commentBufferSize)); | ||
| 506 | |||
| 507 | local int unzlocal_GetCurrentFileInfoInternal (file, | ||
| 508 | pfile_info, | ||
| 509 | pfile_info_internal, | ||
| 510 | szFileName, fileNameBufferSize, | ||
| 511 | extraField, extraFieldBufferSize, | ||
| 512 | szComment, commentBufferSize) | ||
| 513 | unzFile file; | ||
| 514 | unz_file_info *pfile_info; | ||
| 515 | unz_file_info_internal *pfile_info_internal; | ||
| 516 | char *szFileName; | ||
| 517 | uLong fileNameBufferSize; | ||
| 518 | void *extraField; | ||
| 519 | uLong extraFieldBufferSize; | ||
| 520 | char *szComment; | ||
| 521 | uLong commentBufferSize; | ||
| 522 | { | ||
| 523 | unz_s* s; | ||
| 524 | unz_file_info file_info; | ||
| 525 | unz_file_info_internal file_info_internal; | ||
| 526 | int err=UNZ_OK; | ||
| 527 | uLong uMagic; | ||
| 528 | long lSeek=0; | ||
| 529 | |||
| 530 | if (file==NULL) | ||
| 531 | return UNZ_PARAMERROR; | ||
| 532 | s=(unz_s*)file; | ||
| 533 | if (fseek(s->file,s->pos_in_central_dir+s->byte_before_the_zipfile,SEEK_SET)!=0) | ||
| 534 | err=UNZ_ERRNO; | ||
| 535 | |||
| 536 | |||
| 537 | /* we check the magic */ | ||
| 538 | if (err==UNZ_OK) | ||
| 539 | if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) | ||
| 540 | err=UNZ_ERRNO; | ||
| 541 | else if (uMagic!=0x02014b50) | ||
| 542 | err=UNZ_BADZIPFILE; | ||
| 543 | |||
| 544 | if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK) | ||
| 545 | err=UNZ_ERRNO; | ||
| 546 | |||
| 547 | if (unzlocal_getShort(s->file,&file_info.version_needed) != UNZ_OK) | ||
| 548 | err=UNZ_ERRNO; | ||
| 549 | |||
| 550 | if (unzlocal_getShort(s->file,&file_info.flag) != UNZ_OK) | ||
| 551 | err=UNZ_ERRNO; | ||
| 552 | |||
| 553 | if (unzlocal_getShort(s->file,&file_info.compression_method) != UNZ_OK) | ||
| 554 | err=UNZ_ERRNO; | ||
| 555 | |||
| 556 | if (unzlocal_getLong(s->file,&file_info.dosDate) != UNZ_OK) | ||
| 557 | err=UNZ_ERRNO; | ||
| 558 | |||
| 559 | unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); | ||
| 560 | |||
| 561 | if (unzlocal_getLong(s->file,&file_info.crc) != UNZ_OK) | ||
| 562 | err=UNZ_ERRNO; | ||
| 563 | |||
| 564 | if (unzlocal_getLong(s->file,&file_info.compressed_size) != UNZ_OK) | ||
| 565 | err=UNZ_ERRNO; | ||
| 566 | |||
| 567 | if (unzlocal_getLong(s->file,&file_info.uncompressed_size) != UNZ_OK) | ||
| 568 | err=UNZ_ERRNO; | ||
| 569 | |||
| 570 | if (unzlocal_getShort(s->file,&file_info.size_filename) != UNZ_OK) | ||
| 571 | err=UNZ_ERRNO; | ||
| 572 | |||
| 573 | if (unzlocal_getShort(s->file,&file_info.size_file_extra) != UNZ_OK) | ||
| 574 | err=UNZ_ERRNO; | ||
| 575 | |||
| 576 | if (unzlocal_getShort(s->file,&file_info.size_file_comment) != UNZ_OK) | ||
| 577 | err=UNZ_ERRNO; | ||
| 578 | |||
| 579 | if (unzlocal_getShort(s->file,&file_info.disk_num_start) != UNZ_OK) | ||
| 580 | err=UNZ_ERRNO; | ||
| 581 | |||
| 582 | if (unzlocal_getShort(s->file,&file_info.internal_fa) != UNZ_OK) | ||
| 583 | err=UNZ_ERRNO; | ||
| 584 | |||
| 585 | if (unzlocal_getLong(s->file,&file_info.external_fa) != UNZ_OK) | ||
| 586 | err=UNZ_ERRNO; | ||
| 587 | |||
| 588 | if (unzlocal_getLong(s->file,&file_info_internal.offset_curfile) != UNZ_OK) | ||
| 589 | err=UNZ_ERRNO; | ||
| 590 | |||
| 591 | lSeek+=file_info.size_filename; | ||
| 592 | if ((err==UNZ_OK) && (szFileName!=NULL)) | ||
| 593 | { | ||
| 594 | uLong uSizeRead ; | ||
| 595 | if (file_info.size_filename<fileNameBufferSize) | ||
| 596 | { | ||
| 597 | *(szFileName+file_info.size_filename)='\0'; | ||
| 598 | uSizeRead = file_info.size_filename; | ||
| 599 | } | ||
| 600 | else | ||
| 601 | uSizeRead = fileNameBufferSize; | ||
| 602 | |||
| 603 | if ((file_info.size_filename>0) && (fileNameBufferSize>0)) | ||
| 604 | if (fread(szFileName,(uInt)uSizeRead,1,s->file)!=1) | ||
| 605 | err=UNZ_ERRNO; | ||
| 606 | lSeek -= uSizeRead; | ||
| 607 | } | ||
| 608 | |||
| 609 | |||
| 610 | if ((err==UNZ_OK) && (extraField!=NULL)) | ||
| 611 | { | ||
| 612 | uLong uSizeRead ; | ||
| 613 | if (file_info.size_file_extra<extraFieldBufferSize) | ||
| 614 | uSizeRead = file_info.size_file_extra; | ||
| 615 | else | ||
| 616 | uSizeRead = extraFieldBufferSize; | ||
| 617 | |||
| 618 | if (lSeek!=0) | ||
| 619 | if (fseek(s->file,lSeek,SEEK_CUR)==0) | ||
| 620 | lSeek=0; | ||
| 621 | else | ||
| 622 | err=UNZ_ERRNO; | ||
| 623 | if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) | ||
| 624 | if (fread(extraField,(uInt)uSizeRead,1,s->file)!=1) | ||
| 625 | err=UNZ_ERRNO; | ||
| 626 | lSeek += file_info.size_file_extra - uSizeRead; | ||
| 627 | } | ||
| 628 | else | ||
| 629 | lSeek+=file_info.size_file_extra; | ||
| 630 | |||
| 631 | |||
| 632 | if ((err==UNZ_OK) && (szComment!=NULL)) | ||
| 633 | { | ||
| 634 | uLong uSizeRead ; | ||
| 635 | if (file_info.size_file_comment<commentBufferSize) | ||
| 636 | { | ||
| 637 | *(szComment+file_info.size_file_comment)='\0'; | ||
| 638 | uSizeRead = file_info.size_file_comment; | ||
| 639 | } | ||
| 640 | else | ||
| 641 | uSizeRead = commentBufferSize; | ||
| 642 | |||
| 643 | if (lSeek!=0) | ||
| 644 | if (fseek(s->file,lSeek,SEEK_CUR)==0) | ||
| 645 | lSeek=0; | ||
| 646 | else | ||
| 647 | err=UNZ_ERRNO; | ||
| 648 | if ((file_info.size_file_comment>0) && (commentBufferSize>0)) | ||
| 649 | if (fread(szComment,(uInt)uSizeRead,1,s->file)!=1) | ||
| 650 | err=UNZ_ERRNO; | ||
| 651 | lSeek+=file_info.size_file_comment - uSizeRead; | ||
| 652 | } | ||
| 653 | else | ||
| 654 | lSeek+=file_info.size_file_comment; | ||
| 655 | |||
| 656 | if ((err==UNZ_OK) && (pfile_info!=NULL)) | ||
| 657 | *pfile_info=file_info; | ||
| 658 | |||
| 659 | if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) | ||
| 660 | *pfile_info_internal=file_info_internal; | ||
| 661 | |||
| 662 | return err; | ||
| 663 | } | ||
| 664 | |||
| 665 | |||
| 666 | |||
| 667 | /* | ||
| 668 | Write info about the ZipFile in the *pglobal_info structure. | ||
| 669 | No preparation of the structure is needed | ||
| 670 | return UNZ_OK if there is no problem. | ||
| 671 | */ | ||
| 672 | extern int ZEXPORT unzGetCurrentFileInfo (file, | ||
| 673 | pfile_info, | ||
| 674 | szFileName, fileNameBufferSize, | ||
| 675 | extraField, extraFieldBufferSize, | ||
| 676 | szComment, commentBufferSize) | ||
| 677 | unzFile file; | ||
| 678 | unz_file_info *pfile_info; | ||
| 679 | char *szFileName; | ||
| 680 | uLong fileNameBufferSize; | ||
| 681 | void *extraField; | ||
| 682 | uLong extraFieldBufferSize; | ||
| 683 | char *szComment; | ||
| 684 | uLong commentBufferSize; | ||
| 685 | { | ||
| 686 | return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, | ||
| 687 | szFileName,fileNameBufferSize, | ||
| 688 | extraField,extraFieldBufferSize, | ||
| 689 | szComment,commentBufferSize); | ||
| 690 | } | ||
| 691 | |||
| 692 | /* | ||
| 693 | Set the current file of the zipfile to the first file. | ||
| 694 | return UNZ_OK if there is no problem | ||
| 695 | */ | ||
| 696 | extern int ZEXPORT unzGoToFirstFile (file) | ||
| 697 | unzFile file; | ||
| 698 | { | ||
| 699 | int err=UNZ_OK; | ||
| 700 | unz_s* s; | ||
| 701 | if (file==NULL) | ||
| 702 | return UNZ_PARAMERROR; | ||
| 703 | s=(unz_s*)file; | ||
| 704 | s->pos_in_central_dir=s->offset_central_dir; | ||
| 705 | s->num_file=0; | ||
| 706 | err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, | ||
| 707 | &s->cur_file_info_internal, | ||
| 708 | NULL,0,NULL,0,NULL,0); | ||
| 709 | s->current_file_ok = (err == UNZ_OK); | ||
| 710 | return err; | ||
| 711 | } | ||
| 712 | |||
| 713 | |||
| 714 | /* | ||
| 715 | Set the current file of the zipfile to the next file. | ||
| 716 | return UNZ_OK if there is no problem | ||
| 717 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. | ||
| 718 | */ | ||
| 719 | extern int ZEXPORT unzGoToNextFile (file) | ||
| 720 | unzFile file; | ||
| 721 | { | ||
| 722 | unz_s* s; | ||
| 723 | int err; | ||
| 724 | |||
| 725 | if (file==NULL) | ||
| 726 | return UNZ_PARAMERROR; | ||
| 727 | s=(unz_s*)file; | ||
| 728 | if (!s->current_file_ok) | ||
| 729 | return UNZ_END_OF_LIST_OF_FILE; | ||
| 730 | if (s->num_file+1==s->gi.number_entry) | ||
| 731 | return UNZ_END_OF_LIST_OF_FILE; | ||
| 732 | |||
| 733 | s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + | ||
| 734 | s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; | ||
| 735 | s->num_file++; | ||
| 736 | err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, | ||
| 737 | &s->cur_file_info_internal, | ||
| 738 | NULL,0,NULL,0,NULL,0); | ||
| 739 | s->current_file_ok = (err == UNZ_OK); | ||
| 740 | return err; | ||
| 741 | } | ||
| 742 | |||
| 743 | |||
| 744 | /* | ||
| 745 | Try locate the file szFileName in the zipfile. | ||
| 746 | For the iCaseSensitivity signification, see unzipStringFileNameCompare | ||
| 747 | |||
| 748 | return value : | ||
| 749 | UNZ_OK if the file is found. It becomes the current file. | ||
| 750 | UNZ_END_OF_LIST_OF_FILE if the file is not found | ||
| 751 | */ | ||
| 752 | extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) | ||
| 753 | unzFile file; | ||
| 754 | const char *szFileName; | ||
| 755 | int iCaseSensitivity; | ||
| 756 | { | ||
| 757 | unz_s* s; | ||
| 758 | int err; | ||
| 759 | |||
| 760 | |||
| 761 | uLong num_fileSaved; | ||
| 762 | uLong pos_in_central_dirSaved; | ||
| 763 | |||
| 764 | |||
| 765 | if (file==NULL) | ||
| 766 | return UNZ_PARAMERROR; | ||
| 767 | |||
| 768 | if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) | ||
| 769 | return UNZ_PARAMERROR; | ||
| 770 | |||
| 771 | s=(unz_s*)file; | ||
| 772 | if (!s->current_file_ok) | ||
| 773 | return UNZ_END_OF_LIST_OF_FILE; | ||
| 774 | |||
| 775 | num_fileSaved = s->num_file; | ||
| 776 | pos_in_central_dirSaved = s->pos_in_central_dir; | ||
| 777 | |||
| 778 | err = unzGoToFirstFile(file); | ||
| 779 | |||
| 780 | while (err == UNZ_OK) | ||
| 781 | { | ||
| 782 | char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; | ||
| 783 | unzGetCurrentFileInfo(file,NULL, | ||
| 784 | szCurrentFileName,sizeof(szCurrentFileName)-1, | ||
| 785 | NULL,0,NULL,0); | ||
| 786 | if (unzStringFileNameCompare(szCurrentFileName, | ||
| 787 | szFileName,iCaseSensitivity)==0) | ||
| 788 | return UNZ_OK; | ||
| 789 | err = unzGoToNextFile(file); | ||
| 790 | } | ||
| 791 | |||
| 792 | s->num_file = num_fileSaved ; | ||
| 793 | s->pos_in_central_dir = pos_in_central_dirSaved ; | ||
| 794 | return err; | ||
| 795 | } | ||
| 796 | |||
| 797 | |||
| 798 | /* | ||
| 799 | Read the local header of the current zipfile | ||
| 800 | Check the coherency of the local header and info in the end of central | ||
| 801 | directory about this file | ||
| 802 | store in *piSizeVar the size of extra info in local header | ||
| 803 | (filename and size of extra field data) | ||
| 804 | */ | ||
| 805 | local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, | ||
| 806 | poffset_local_extrafield, | ||
| 807 | psize_local_extrafield) | ||
| 808 | unz_s* s; | ||
| 809 | uInt* piSizeVar; | ||
| 810 | uLong *poffset_local_extrafield; | ||
| 811 | uInt *psize_local_extrafield; | ||
| 812 | { | ||
| 813 | uLong uMagic,uData,uFlags; | ||
| 814 | uLong size_filename; | ||
| 815 | uLong size_extra_field; | ||
| 816 | int err=UNZ_OK; | ||
| 817 | |||
| 818 | *piSizeVar = 0; | ||
| 819 | *poffset_local_extrafield = 0; | ||
| 820 | *psize_local_extrafield = 0; | ||
| 821 | |||
| 822 | if (fseek(s->file,s->cur_file_info_internal.offset_curfile + | ||
| 823 | s->byte_before_the_zipfile,SEEK_SET)!=0) | ||
| 824 | return UNZ_ERRNO; | ||
| 825 | |||
| 826 | |||
| 827 | if (err==UNZ_OK) | ||
| 828 | if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK) | ||
| 829 | err=UNZ_ERRNO; | ||
| 830 | else if (uMagic!=0x04034b50) | ||
| 831 | err=UNZ_BADZIPFILE; | ||
| 832 | |||
| 833 | if (unzlocal_getShort(s->file,&uData) != UNZ_OK) | ||
| 834 | err=UNZ_ERRNO; | ||
| 835 | /* | ||
| 836 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) | ||
| 837 | err=UNZ_BADZIPFILE; | ||
| 838 | */ | ||
| 839 | if (unzlocal_getShort(s->file,&uFlags) != UNZ_OK) | ||
| 840 | err=UNZ_ERRNO; | ||
| 841 | |||
| 842 | if (unzlocal_getShort(s->file,&uData) != UNZ_OK) | ||
| 843 | err=UNZ_ERRNO; | ||
| 844 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) | ||
| 845 | err=UNZ_BADZIPFILE; | ||
| 846 | |||
| 847 | if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && | ||
| 848 | (s->cur_file_info.compression_method!=Z_DEFLATED)) | ||
| 849 | err=UNZ_BADZIPFILE; | ||
| 850 | |||
| 851 | if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */ | ||
| 852 | err=UNZ_ERRNO; | ||
| 853 | |||
| 854 | if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */ | ||
| 855 | err=UNZ_ERRNO; | ||
| 856 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && | ||
| 857 | ((uFlags & 8)==0)) | ||
| 858 | err=UNZ_BADZIPFILE; | ||
| 859 | |||
| 860 | if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size compr */ | ||
| 861 | err=UNZ_ERRNO; | ||
| 862 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && | ||
| 863 | ((uFlags & 8)==0)) | ||
| 864 | err=UNZ_BADZIPFILE; | ||
| 865 | |||
| 866 | if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* size uncompr */ | ||
| 867 | err=UNZ_ERRNO; | ||
| 868 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && | ||
| 869 | ((uFlags & 8)==0)) | ||
| 870 | err=UNZ_BADZIPFILE; | ||
| 871 | |||
| 872 | |||
| 873 | if (unzlocal_getShort(s->file,&size_filename) != UNZ_OK) | ||
| 874 | err=UNZ_ERRNO; | ||
| 875 | else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) | ||
| 876 | err=UNZ_BADZIPFILE; | ||
| 877 | |||
| 878 | *piSizeVar += (uInt)size_filename; | ||
| 879 | |||
| 880 | if (unzlocal_getShort(s->file,&size_extra_field) != UNZ_OK) | ||
| 881 | err=UNZ_ERRNO; | ||
| 882 | *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + | ||
| 883 | SIZEZIPLOCALHEADER + size_filename; | ||
| 884 | *psize_local_extrafield = (uInt)size_extra_field; | ||
| 885 | |||
| 886 | *piSizeVar += (uInt)size_extra_field; | ||
| 887 | |||
| 888 | return err; | ||
| 889 | } | ||
| 890 | |||
| 891 | /* | ||
| 892 | Open for reading data the current file in the zipfile. | ||
| 893 | If there is no error and the file is opened, the return value is UNZ_OK. | ||
| 894 | */ | ||
| 895 | extern int ZEXPORT unzOpenCurrentFile (file) | ||
| 896 | unzFile file; | ||
| 897 | { | ||
| 898 | int err=UNZ_OK; | ||
| 899 | int Store; | ||
| 900 | uInt iSizeVar; | ||
| 901 | unz_s* s; | ||
| 902 | file_in_zip_read_info_s* pfile_in_zip_read_info; | ||
| 903 | uLong offset_local_extrafield; /* offset of the local extra field */ | ||
| 904 | uInt size_local_extrafield; /* size of the local extra field */ | ||
| 905 | |||
| 906 | if (file==NULL) | ||
| 907 | return UNZ_PARAMERROR; | ||
| 908 | s=(unz_s*)file; | ||
| 909 | if (!s->current_file_ok) | ||
| 910 | return UNZ_PARAMERROR; | ||
| 911 | |||
| 912 | if (s->pfile_in_zip_read != NULL) | ||
| 913 | unzCloseCurrentFile(file); | ||
| 914 | |||
| 915 | if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, | ||
| 916 | &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) | ||
| 917 | return UNZ_BADZIPFILE; | ||
| 918 | |||
| 919 | pfile_in_zip_read_info = (file_in_zip_read_info_s*) | ||
| 920 | ALLOC(sizeof(file_in_zip_read_info_s)); | ||
| 921 | if (pfile_in_zip_read_info==NULL) | ||
| 922 | return UNZ_INTERNALERROR; | ||
| 923 | |||
| 924 | pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); | ||
| 925 | pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; | ||
| 926 | pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; | ||
| 927 | pfile_in_zip_read_info->pos_local_extrafield=0; | ||
| 928 | |||
| 929 | if (pfile_in_zip_read_info->read_buffer==NULL) | ||
| 930 | { | ||
| 931 | TRYFREE(pfile_in_zip_read_info); | ||
| 932 | return UNZ_INTERNALERROR; | ||
| 933 | } | ||
| 934 | |||
| 935 | pfile_in_zip_read_info->stream_initialised=0; | ||
| 936 | |||
| 937 | if ((s->cur_file_info.compression_method!=0) && | ||
| 938 | (s->cur_file_info.compression_method!=Z_DEFLATED)) | ||
| 939 | err=UNZ_BADZIPFILE; | ||
| 940 | Store = s->cur_file_info.compression_method==0; | ||
| 941 | |||
| 942 | pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; | ||
| 943 | pfile_in_zip_read_info->crc32=0; | ||
| 944 | pfile_in_zip_read_info->compression_method = | ||
| 945 | s->cur_file_info.compression_method; | ||
| 946 | pfile_in_zip_read_info->file=s->file; | ||
| 947 | pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; | ||
| 948 | |||
| 949 | pfile_in_zip_read_info->stream.total_out = 0; | ||
| 950 | |||
| 951 | if (!Store) | ||
| 952 | { | ||
| 953 | pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; | ||
| 954 | pfile_in_zip_read_info->stream.zfree = (free_func)0; | ||
| 955 | pfile_in_zip_read_info->stream.opaque = (voidpf)0; | ||
| 956 | |||
| 957 | err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); | ||
| 958 | if (err == Z_OK) | ||
| 959 | pfile_in_zip_read_info->stream_initialised=1; | ||
| 960 | /* windowBits is passed < 0 to tell that there is no zlib header. | ||
| 961 | * Note that in this case inflate *requires* an extra "dummy" byte | ||
| 962 | * after the compressed stream in order to complete decompression and | ||
| 963 | * return Z_STREAM_END. | ||
| 964 | * In unzip, i don't wait absolutely Z_STREAM_END because I known the | ||
| 965 | * size of both compressed and uncompressed data | ||
| 966 | */ | ||
| 967 | } | ||
| 968 | pfile_in_zip_read_info->rest_read_compressed = | ||
| 969 | s->cur_file_info.compressed_size ; | ||
| 970 | pfile_in_zip_read_info->rest_read_uncompressed = | ||
| 971 | s->cur_file_info.uncompressed_size ; | ||
| 972 | |||
| 973 | |||
| 974 | pfile_in_zip_read_info->pos_in_zipfile = | ||
| 975 | s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + | ||
| 976 | iSizeVar; | ||
| 977 | |||
| 978 | pfile_in_zip_read_info->stream.avail_in = (uInt)0; | ||
| 979 | |||
| 980 | |||
| 981 | s->pfile_in_zip_read = pfile_in_zip_read_info; | ||
| 982 | return UNZ_OK; | ||
| 983 | } | ||
| 984 | |||
| 985 | |||
| 986 | /* | ||
| 987 | Read bytes from the current file. | ||
| 988 | buf contain buffer where data must be copied | ||
| 989 | len the size of buf. | ||
| 990 | |||
| 991 | return the number of byte copied if somes bytes are copied | ||
| 992 | return 0 if the end of file was reached | ||
| 993 | return <0 with error code if there is an error | ||
| 994 | (UNZ_ERRNO for IO error, or zLib error for uncompress error) | ||
| 995 | */ | ||
| 996 | extern int ZEXPORT unzReadCurrentFile (file, buf, len) | ||
| 997 | unzFile file; | ||
| 998 | voidp buf; | ||
| 999 | unsigned len; | ||
| 1000 | { | ||
| 1001 | int err=UNZ_OK; | ||
| 1002 | uInt iRead = 0; | ||
| 1003 | unz_s* s; | ||
| 1004 | file_in_zip_read_info_s* pfile_in_zip_read_info; | ||
| 1005 | if (file==NULL) | ||
| 1006 | return UNZ_PARAMERROR; | ||
| 1007 | s=(unz_s*)file; | ||
| 1008 | pfile_in_zip_read_info=s->pfile_in_zip_read; | ||
| 1009 | |||
| 1010 | if (pfile_in_zip_read_info==NULL) | ||
| 1011 | return UNZ_PARAMERROR; | ||
| 1012 | |||
| 1013 | |||
| 1014 | if ((pfile_in_zip_read_info->read_buffer == NULL)) | ||
| 1015 | return UNZ_END_OF_LIST_OF_FILE; | ||
| 1016 | if (len==0) | ||
| 1017 | return 0; | ||
| 1018 | |||
| 1019 | pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; | ||
| 1020 | |||
| 1021 | pfile_in_zip_read_info->stream.avail_out = (uInt)len; | ||
| 1022 | |||
| 1023 | if (len>pfile_in_zip_read_info->rest_read_uncompressed) | ||
| 1024 | pfile_in_zip_read_info->stream.avail_out = | ||
| 1025 | (uInt)pfile_in_zip_read_info->rest_read_uncompressed; | ||
| 1026 | |||
| 1027 | while (pfile_in_zip_read_info->stream.avail_out>0) | ||
| 1028 | { | ||
| 1029 | if ((pfile_in_zip_read_info->stream.avail_in==0) && | ||
| 1030 | (pfile_in_zip_read_info->rest_read_compressed>0)) | ||
| 1031 | { | ||
| 1032 | uInt uReadThis = UNZ_BUFSIZE; | ||
| 1033 | if (pfile_in_zip_read_info->rest_read_compressed<uReadThis) | ||
| 1034 | uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed; | ||
| 1035 | if (uReadThis == 0) | ||
| 1036 | return UNZ_EOF; | ||
| 1037 | if (fseek(pfile_in_zip_read_info->file, | ||
| 1038 | pfile_in_zip_read_info->pos_in_zipfile + | ||
| 1039 | pfile_in_zip_read_info->byte_before_the_zipfile,SEEK_SET)!=0) | ||
| 1040 | return UNZ_ERRNO; | ||
| 1041 | if (fread(pfile_in_zip_read_info->read_buffer,uReadThis,1, | ||
| 1042 | pfile_in_zip_read_info->file)!=1) | ||
| 1043 | return UNZ_ERRNO; | ||
| 1044 | pfile_in_zip_read_info->pos_in_zipfile += uReadThis; | ||
| 1045 | |||
| 1046 | pfile_in_zip_read_info->rest_read_compressed-=uReadThis; | ||
| 1047 | |||
| 1048 | pfile_in_zip_read_info->stream.next_in = | ||
| 1049 | (Bytef*)pfile_in_zip_read_info->read_buffer; | ||
| 1050 | pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; | ||
| 1051 | } | ||
| 1052 | |||
| 1053 | if (pfile_in_zip_read_info->compression_method==0) | ||
| 1054 | { | ||
| 1055 | uInt uDoCopy,i ; | ||
| 1056 | if (pfile_in_zip_read_info->stream.avail_out < | ||
| 1057 | pfile_in_zip_read_info->stream.avail_in) | ||
| 1058 | uDoCopy = pfile_in_zip_read_info->stream.avail_out ; | ||
| 1059 | else | ||
| 1060 | uDoCopy = pfile_in_zip_read_info->stream.avail_in ; | ||
| 1061 | |||
| 1062 | for (i=0;i<uDoCopy;i++) | ||
| 1063 | *(pfile_in_zip_read_info->stream.next_out+i) = | ||
| 1064 | *(pfile_in_zip_read_info->stream.next_in+i); | ||
| 1065 | |||
| 1066 | pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, | ||
| 1067 | pfile_in_zip_read_info->stream.next_out, | ||
| 1068 | uDoCopy); | ||
| 1069 | pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; | ||
| 1070 | pfile_in_zip_read_info->stream.avail_in -= uDoCopy; | ||
| 1071 | pfile_in_zip_read_info->stream.avail_out -= uDoCopy; | ||
| 1072 | pfile_in_zip_read_info->stream.next_out += uDoCopy; | ||
| 1073 | pfile_in_zip_read_info->stream.next_in += uDoCopy; | ||
| 1074 | pfile_in_zip_read_info->stream.total_out += uDoCopy; | ||
| 1075 | iRead += uDoCopy; | ||
| 1076 | } | ||
| 1077 | else | ||
| 1078 | { | ||
| 1079 | uLong uTotalOutBefore,uTotalOutAfter; | ||
| 1080 | const Bytef *bufBefore; | ||
| 1081 | uLong uOutThis; | ||
| 1082 | int flush=Z_SYNC_FLUSH; | ||
| 1083 | |||
| 1084 | uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; | ||
| 1085 | bufBefore = pfile_in_zip_read_info->stream.next_out; | ||
| 1086 | |||
| 1087 | /* | ||
| 1088 | if ((pfile_in_zip_read_info->rest_read_uncompressed == | ||
| 1089 | pfile_in_zip_read_info->stream.avail_out) && | ||
| 1090 | (pfile_in_zip_read_info->rest_read_compressed == 0)) | ||
| 1091 | flush = Z_FINISH; | ||
| 1092 | */ | ||
| 1093 | err=inflate(&pfile_in_zip_read_info->stream,flush); | ||
| 1094 | |||
| 1095 | uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; | ||
| 1096 | uOutThis = uTotalOutAfter-uTotalOutBefore; | ||
| 1097 | |||
| 1098 | pfile_in_zip_read_info->crc32 = | ||
| 1099 | crc32(pfile_in_zip_read_info->crc32,bufBefore, | ||
| 1100 | (uInt)(uOutThis)); | ||
| 1101 | |||
| 1102 | pfile_in_zip_read_info->rest_read_uncompressed -= | ||
| 1103 | uOutThis; | ||
| 1104 | |||
| 1105 | iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); | ||
| 1106 | |||
| 1107 | if (err==Z_STREAM_END) | ||
| 1108 | return (iRead==0) ? UNZ_EOF : iRead; | ||
| 1109 | if (err!=Z_OK) | ||
| 1110 | break; | ||
| 1111 | } | ||
| 1112 | } | ||
| 1113 | |||
| 1114 | if (err==Z_OK) | ||
| 1115 | return iRead; | ||
| 1116 | return err; | ||
| 1117 | } | ||
| 1118 | |||
| 1119 | |||
| 1120 | /* | ||
| 1121 | Give the current position in uncompressed data | ||
| 1122 | */ | ||
| 1123 | extern z_off_t ZEXPORT unztell (file) | ||
| 1124 | unzFile file; | ||
| 1125 | { | ||
| 1126 | unz_s* s; | ||
| 1127 | file_in_zip_read_info_s* pfile_in_zip_read_info; | ||
| 1128 | if (file==NULL) | ||
| 1129 | return UNZ_PARAMERROR; | ||
| 1130 | s=(unz_s*)file; | ||
| 1131 | pfile_in_zip_read_info=s->pfile_in_zip_read; | ||
| 1132 | |||
| 1133 | if (pfile_in_zip_read_info==NULL) | ||
| 1134 | return UNZ_PARAMERROR; | ||
| 1135 | |||
| 1136 | return (z_off_t)pfile_in_zip_read_info->stream.total_out; | ||
| 1137 | } | ||
| 1138 | |||
| 1139 | |||
| 1140 | /* | ||
| 1141 | return 1 if the end of file was reached, 0 elsewhere | ||
| 1142 | */ | ||
| 1143 | extern int ZEXPORT unzeof (file) | ||
| 1144 | unzFile file; | ||
| 1145 | { | ||
| 1146 | unz_s* s; | ||
| 1147 | file_in_zip_read_info_s* pfile_in_zip_read_info; | ||
| 1148 | if (file==NULL) | ||
| 1149 | return UNZ_PARAMERROR; | ||
| 1150 | s=(unz_s*)file; | ||
| 1151 | pfile_in_zip_read_info=s->pfile_in_zip_read; | ||
| 1152 | |||
| 1153 | if (pfile_in_zip_read_info==NULL) | ||
| 1154 | return UNZ_PARAMERROR; | ||
| 1155 | |||
| 1156 | if (pfile_in_zip_read_info->rest_read_uncompressed == 0) | ||
| 1157 | return 1; | ||
| 1158 | else | ||
| 1159 | return 0; | ||
| 1160 | } | ||
| 1161 | |||
| 1162 | |||
| 1163 | |||
| 1164 | /* | ||
| 1165 | Read extra field from the current file (opened by unzOpenCurrentFile) | ||
| 1166 | This is the local-header version of the extra field (sometimes, there is | ||
| 1167 | more info in the local-header version than in the central-header) | ||
| 1168 | |||
| 1169 | if buf==NULL, it return the size of the local extra field that can be read | ||
| 1170 | |||
| 1171 | if buf!=NULL, len is the size of the buffer, the extra header is copied in | ||
| 1172 | buf. | ||
| 1173 | the return value is the number of bytes copied in buf, or (if <0) | ||
| 1174 | the error code | ||
| 1175 | */ | ||
| 1176 | extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) | ||
| 1177 | unzFile file; | ||
| 1178 | voidp buf; | ||
| 1179 | unsigned len; | ||
| 1180 | { | ||
| 1181 | unz_s* s; | ||
| 1182 | file_in_zip_read_info_s* pfile_in_zip_read_info; | ||
| 1183 | uInt read_now; | ||
| 1184 | uLong size_to_read; | ||
| 1185 | |||
| 1186 | if (file==NULL) | ||
| 1187 | return UNZ_PARAMERROR; | ||
| 1188 | s=(unz_s*)file; | ||
| 1189 | pfile_in_zip_read_info=s->pfile_in_zip_read; | ||
| 1190 | |||
| 1191 | if (pfile_in_zip_read_info==NULL) | ||
| 1192 | return UNZ_PARAMERROR; | ||
| 1193 | |||
| 1194 | size_to_read = (pfile_in_zip_read_info->size_local_extrafield - | ||
| 1195 | pfile_in_zip_read_info->pos_local_extrafield); | ||
| 1196 | |||
| 1197 | if (buf==NULL) | ||
| 1198 | return (int)size_to_read; | ||
| 1199 | |||
| 1200 | if (len>size_to_read) | ||
| 1201 | read_now = (uInt)size_to_read; | ||
| 1202 | else | ||
| 1203 | read_now = (uInt)len ; | ||
| 1204 | |||
| 1205 | if (read_now==0) | ||
| 1206 | return 0; | ||
| 1207 | |||
| 1208 | if (fseek(pfile_in_zip_read_info->file, | ||
| 1209 | pfile_in_zip_read_info->offset_local_extrafield + | ||
| 1210 | pfile_in_zip_read_info->pos_local_extrafield,SEEK_SET)!=0) | ||
| 1211 | return UNZ_ERRNO; | ||
| 1212 | |||
| 1213 | if (fread(buf,(uInt)size_to_read,1,pfile_in_zip_read_info->file)!=1) | ||
| 1214 | return UNZ_ERRNO; | ||
| 1215 | |||
| 1216 | return (int)read_now; | ||
| 1217 | } | ||
| 1218 | |||
| 1219 | /* | ||
| 1220 | Close the file in zip opened with unzipOpenCurrentFile | ||
| 1221 | Return UNZ_CRCERROR if all the file was read but the CRC is not good | ||
| 1222 | */ | ||
| 1223 | extern int ZEXPORT unzCloseCurrentFile (file) | ||
| 1224 | unzFile file; | ||
| 1225 | { | ||
| 1226 | int err=UNZ_OK; | ||
| 1227 | |||
| 1228 | unz_s* s; | ||
| 1229 | file_in_zip_read_info_s* pfile_in_zip_read_info; | ||
| 1230 | if (file==NULL) | ||
| 1231 | return UNZ_PARAMERROR; | ||
| 1232 | s=(unz_s*)file; | ||
| 1233 | pfile_in_zip_read_info=s->pfile_in_zip_read; | ||
| 1234 | |||
| 1235 | if (pfile_in_zip_read_info==NULL) | ||
| 1236 | return UNZ_PARAMERROR; | ||
| 1237 | |||
| 1238 | |||
| 1239 | if (pfile_in_zip_read_info->rest_read_uncompressed == 0) | ||
| 1240 | { | ||
| 1241 | if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) | ||
| 1242 | err=UNZ_CRCERROR; | ||
| 1243 | } | ||
| 1244 | |||
| 1245 | |||
| 1246 | TRYFREE(pfile_in_zip_read_info->read_buffer); | ||
| 1247 | pfile_in_zip_read_info->read_buffer = NULL; | ||
| 1248 | if (pfile_in_zip_read_info->stream_initialised) | ||
| 1249 | inflateEnd(&pfile_in_zip_read_info->stream); | ||
| 1250 | |||
| 1251 | pfile_in_zip_read_info->stream_initialised = 0; | ||
| 1252 | TRYFREE(pfile_in_zip_read_info); | ||
| 1253 | |||
| 1254 | s->pfile_in_zip_read=NULL; | ||
| 1255 | |||
| 1256 | return err; | ||
| 1257 | } | ||
| 1258 | |||
| 1259 | |||
| 1260 | /* | ||
| 1261 | Get the global comment string of the ZipFile, in the szComment buffer. | ||
| 1262 | uSizeBuf is the size of the szComment buffer. | ||
| 1263 | return the number of byte copied or an error code <0 | ||
| 1264 | */ | ||
| 1265 | extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) | ||
| 1266 | unzFile file; | ||
| 1267 | char *szComment; | ||
| 1268 | uLong uSizeBuf; | ||
| 1269 | { | ||
| 1270 | int err=UNZ_OK; | ||
| 1271 | unz_s* s; | ||
| 1272 | uLong uReadThis ; | ||
| 1273 | if (file==NULL) | ||
| 1274 | return UNZ_PARAMERROR; | ||
| 1275 | s=(unz_s*)file; | ||
| 1276 | |||
| 1277 | uReadThis = uSizeBuf; | ||
| 1278 | if (uReadThis>s->gi.size_comment) | ||
| 1279 | uReadThis = s->gi.size_comment; | ||
| 1280 | |||
| 1281 | if (fseek(s->file,s->central_pos+22,SEEK_SET)!=0) | ||
| 1282 | return UNZ_ERRNO; | ||
| 1283 | |||
| 1284 | if (uReadThis>0) | ||
| 1285 | { | ||
| 1286 | *szComment='\0'; | ||
| 1287 | if (fread(szComment,(uInt)uReadThis,1,s->file)!=1) | ||
| 1288 | return UNZ_ERRNO; | ||
| 1289 | } | ||
| 1290 | |||
| 1291 | if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) | ||
| 1292 | *(szComment+s->gi.size_comment)='\0'; | ||
| 1293 | return (int)uReadThis; | ||
| 1294 | } | ||
diff --git a/contrib/minizip/unzip.def b/contrib/minizip/unzip.def new file mode 100644 index 0000000..f6ede89 --- /dev/null +++ b/contrib/minizip/unzip.def | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | unzOpen @61 | ||
| 2 | unzClose @62 | ||
| 3 | unzGetGlobalInfo @63 | ||
| 4 | unzGetCurrentFileInfo @64 | ||
| 5 | unzGoToFirstFile @65 | ||
| 6 | unzGoToNextFile @66 | ||
| 7 | unzOpenCurrentFile @67 | ||
| 8 | unzReadCurrentFile @68 | ||
| 9 | unztell @70 | ||
| 10 | unzeof @71 | ||
| 11 | unzCloseCurrentFile @72 | ||
| 12 | unzGetGlobalComment @73 | ||
| 13 | unzStringFileNameCompare @74 | ||
| 14 | unzLocateFile @75 | ||
| 15 | unzGetLocalExtrafield @76 | ||
diff --git a/contrib/minizip/unzip.h b/contrib/minizip/unzip.h new file mode 100644 index 0000000..76692cb --- /dev/null +++ b/contrib/minizip/unzip.h | |||
| @@ -0,0 +1,275 @@ | |||
| 1 | /* unzip.h -- IO for uncompress .zip files using zlib | ||
| 2 | Version 0.15 beta, Mar 19th, 1998, | ||
| 3 | |||
| 4 | Copyright (C) 1998 Gilles Vollant | ||
| 5 | |||
| 6 | This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g | ||
| 7 | WinZip, InfoZip tools and compatible. | ||
| 8 | Encryption and multi volume ZipFile (span) are not supported. | ||
| 9 | Old compressions used by old PKZip 1.x are not supported | ||
| 10 | |||
| 11 | THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE | ||
| 12 | CAN CHANGE IN FUTURE VERSION !! | ||
| 13 | I WAIT FEEDBACK at mail info@winimage.com | ||
| 14 | Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution | ||
| 15 | |||
| 16 | Condition of use and distribution are the same than zlib : | ||
| 17 | |||
| 18 | This software is provided 'as-is', without any express or implied | ||
| 19 | warranty. In no event will the authors be held liable for any damages | ||
| 20 | arising from the use of this software. | ||
| 21 | |||
| 22 | Permission is granted to anyone to use this software for any purpose, | ||
| 23 | including commercial applications, and to alter it and redistribute it | ||
| 24 | freely, subject to the following restrictions: | ||
| 25 | |||
| 26 | 1. The origin of this software must not be misrepresented; you must not | ||
| 27 | claim that you wrote the original software. If you use this software | ||
| 28 | in a product, an acknowledgment in the product documentation would be | ||
| 29 | appreciated but is not required. | ||
| 30 | 2. Altered source versions must be plainly marked as such, and must not be | ||
| 31 | misrepresented as being the original software. | ||
| 32 | 3. This notice may not be removed or altered from any source distribution. | ||
| 33 | |||
| 34 | |||
| 35 | */ | ||
| 36 | /* for more info about .ZIP format, see | ||
| 37 | ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip | ||
| 38 | PkWare has also a specification at : | ||
| 39 | ftp://ftp.pkware.com/probdesc.zip */ | ||
| 40 | |||
| 41 | #ifndef _unz_H | ||
| 42 | #define _unz_H | ||
| 43 | |||
| 44 | #ifdef __cplusplus | ||
| 45 | extern "C" { | ||
| 46 | #endif | ||
| 47 | |||
| 48 | #ifndef _ZLIB_H | ||
| 49 | #include "zlib.h" | ||
| 50 | #endif | ||
| 51 | |||
| 52 | #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) | ||
| 53 | /* like the STRICT of WIN32, we define a pointer that cannot be converted | ||
| 54 | from (void*) without cast */ | ||
| 55 | typedef struct TagunzFile__ { int unused; } unzFile__; | ||
| 56 | typedef unzFile__ *unzFile; | ||
| 57 | #else | ||
| 58 | typedef voidp unzFile; | ||
| 59 | #endif | ||
| 60 | |||
| 61 | |||
| 62 | #define UNZ_OK (0) | ||
| 63 | #define UNZ_END_OF_LIST_OF_FILE (-100) | ||
| 64 | #define UNZ_ERRNO (Z_ERRNO) | ||
| 65 | #define UNZ_EOF (0) | ||
| 66 | #define UNZ_PARAMERROR (-102) | ||
| 67 | #define UNZ_BADZIPFILE (-103) | ||
| 68 | #define UNZ_INTERNALERROR (-104) | ||
| 69 | #define UNZ_CRCERROR (-105) | ||
| 70 | |||
| 71 | /* tm_unz contain date/time info */ | ||
| 72 | typedef struct tm_unz_s | ||
| 73 | { | ||
| 74 | uInt tm_sec; /* seconds after the minute - [0,59] */ | ||
| 75 | uInt tm_min; /* minutes after the hour - [0,59] */ | ||
| 76 | uInt tm_hour; /* hours since midnight - [0,23] */ | ||
| 77 | uInt tm_mday; /* day of the month - [1,31] */ | ||
| 78 | uInt tm_mon; /* months since January - [0,11] */ | ||
| 79 | uInt tm_year; /* years - [1980..2044] */ | ||
| 80 | } tm_unz; | ||
| 81 | |||
| 82 | /* unz_global_info structure contain global data about the ZIPfile | ||
| 83 | These data comes from the end of central dir */ | ||
| 84 | typedef struct unz_global_info_s | ||
| 85 | { | ||
| 86 | uLong number_entry; /* total number of entries in | ||
| 87 | the central dir on this disk */ | ||
| 88 | uLong size_comment; /* size of the global comment of the zipfile */ | ||
| 89 | } unz_global_info; | ||
| 90 | |||
| 91 | |||
| 92 | /* unz_file_info contain information about a file in the zipfile */ | ||
| 93 | typedef struct unz_file_info_s | ||
| 94 | { | ||
| 95 | uLong version; /* version made by 2 bytes */ | ||
| 96 | uLong version_needed; /* version needed to extract 2 bytes */ | ||
| 97 | uLong flag; /* general purpose bit flag 2 bytes */ | ||
| 98 | uLong compression_method; /* compression method 2 bytes */ | ||
| 99 | uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ | ||
| 100 | uLong crc; /* crc-32 4 bytes */ | ||
| 101 | uLong compressed_size; /* compressed size 4 bytes */ | ||
| 102 | uLong uncompressed_size; /* uncompressed size 4 bytes */ | ||
| 103 | uLong size_filename; /* filename length 2 bytes */ | ||
| 104 | uLong size_file_extra; /* extra field length 2 bytes */ | ||
| 105 | uLong size_file_comment; /* file comment length 2 bytes */ | ||
| 106 | |||
| 107 | uLong disk_num_start; /* disk number start 2 bytes */ | ||
| 108 | uLong internal_fa; /* internal file attributes 2 bytes */ | ||
| 109 | uLong external_fa; /* external file attributes 4 bytes */ | ||
| 110 | |||
| 111 | tm_unz tmu_date; | ||
| 112 | } unz_file_info; | ||
| 113 | |||
| 114 | extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, | ||
| 115 | const char* fileName2, | ||
| 116 | int iCaseSensitivity)); | ||
| 117 | /* | ||
| 118 | Compare two filename (fileName1,fileName2). | ||
| 119 | If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) | ||
| 120 | If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi | ||
| 121 | or strcasecmp) | ||
| 122 | If iCaseSenisivity = 0, case sensitivity is defaut of your operating system | ||
| 123 | (like 1 on Unix, 2 on Windows) | ||
| 124 | */ | ||
| 125 | |||
| 126 | |||
| 127 | extern unzFile ZEXPORT unzOpen OF((const char *path)); | ||
| 128 | /* | ||
| 129 | Open a Zip file. path contain the full pathname (by example, | ||
| 130 | on a Windows NT computer "c:\\zlib\\zlib111.zip" or on an Unix computer | ||
| 131 | "zlib/zlib111.zip". | ||
| 132 | If the zipfile cannot be opened (file don't exist or in not valid), the | ||
| 133 | return value is NULL. | ||
| 134 | Else, the return value is a unzFile Handle, usable with other function | ||
| 135 | of this unzip package. | ||
| 136 | */ | ||
| 137 | |||
| 138 | extern int ZEXPORT unzClose OF((unzFile file)); | ||
| 139 | /* | ||
| 140 | Close a ZipFile opened with unzipOpen. | ||
| 141 | If there is files inside the .Zip opened with unzOpenCurrentFile (see later), | ||
| 142 | these files MUST be closed with unzipCloseCurrentFile before call unzipClose. | ||
| 143 | return UNZ_OK if there is no problem. */ | ||
| 144 | |||
| 145 | extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, | ||
| 146 | unz_global_info *pglobal_info)); | ||
| 147 | /* | ||
| 148 | Write info about the ZipFile in the *pglobal_info structure. | ||
| 149 | No preparation of the structure is needed | ||
| 150 | return UNZ_OK if there is no problem. */ | ||
| 151 | |||
| 152 | |||
| 153 | extern int ZEXPORT unzGetGlobalComment OF((unzFile file, | ||
| 154 | char *szComment, | ||
| 155 | uLong uSizeBuf)); | ||
| 156 | /* | ||
| 157 | Get the global comment string of the ZipFile, in the szComment buffer. | ||
| 158 | uSizeBuf is the size of the szComment buffer. | ||
| 159 | return the number of byte copied or an error code <0 | ||
| 160 | */ | ||
| 161 | |||
| 162 | |||
| 163 | /***************************************************************************/ | ||
| 164 | /* Unzip package allow you browse the directory of the zipfile */ | ||
| 165 | |||
| 166 | extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); | ||
| 167 | /* | ||
| 168 | Set the current file of the zipfile to the first file. | ||
| 169 | return UNZ_OK if there is no problem | ||
| 170 | */ | ||
| 171 | |||
| 172 | extern int ZEXPORT unzGoToNextFile OF((unzFile file)); | ||
| 173 | /* | ||
| 174 | Set the current file of the zipfile to the next file. | ||
| 175 | return UNZ_OK if there is no problem | ||
| 176 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. | ||
| 177 | */ | ||
| 178 | |||
| 179 | extern int ZEXPORT unzLocateFile OF((unzFile file, | ||
| 180 | const char *szFileName, | ||
| 181 | int iCaseSensitivity)); | ||
| 182 | /* | ||
| 183 | Try locate the file szFileName in the zipfile. | ||
| 184 | For the iCaseSensitivity signification, see unzStringFileNameCompare | ||
| 185 | |||
| 186 | return value : | ||
| 187 | UNZ_OK if the file is found. It becomes the current file. | ||
| 188 | UNZ_END_OF_LIST_OF_FILE if the file is not found | ||
| 189 | */ | ||
| 190 | |||
| 191 | |||
| 192 | extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, | ||
| 193 | unz_file_info *pfile_info, | ||
| 194 | char *szFileName, | ||
| 195 | uLong fileNameBufferSize, | ||
| 196 | void *extraField, | ||
| 197 | uLong extraFieldBufferSize, | ||
| 198 | char *szComment, | ||
| 199 | uLong commentBufferSize)); | ||
| 200 | /* | ||
| 201 | Get Info about the current file | ||
| 202 | if pfile_info!=NULL, the *pfile_info structure will contain somes info about | ||
| 203 | the current file | ||
| 204 | if szFileName!=NULL, the filemane string will be copied in szFileName | ||
| 205 | (fileNameBufferSize is the size of the buffer) | ||
| 206 | if extraField!=NULL, the extra field information will be copied in extraField | ||
| 207 | (extraFieldBufferSize is the size of the buffer). | ||
| 208 | This is the Central-header version of the extra field | ||
| 209 | if szComment!=NULL, the comment string of the file will be copied in szComment | ||
| 210 | (commentBufferSize is the size of the buffer) | ||
| 211 | */ | ||
| 212 | |||
| 213 | /***************************************************************************/ | ||
| 214 | /* for reading the content of the current zipfile, you can open it, read data | ||
| 215 | from it, and close it (you can close it before reading all the file) | ||
| 216 | */ | ||
| 217 | |||
| 218 | extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); | ||
| 219 | /* | ||
| 220 | Open for reading data the current file in the zipfile. | ||
| 221 | If there is no error, the return value is UNZ_OK. | ||
| 222 | */ | ||
| 223 | |||
| 224 | extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); | ||
| 225 | /* | ||
| 226 | Close the file in zip opened with unzOpenCurrentFile | ||
| 227 | Return UNZ_CRCERROR if all the file was read but the CRC is not good | ||
| 228 | */ | ||
| 229 | |||
| 230 | |||
| 231 | extern int ZEXPORT unzReadCurrentFile OF((unzFile file, | ||
| 232 | voidp buf, | ||
| 233 | unsigned len)); | ||
| 234 | /* | ||
| 235 | Read bytes from the current file (opened by unzOpenCurrentFile) | ||
| 236 | buf contain buffer where data must be copied | ||
| 237 | len the size of buf. | ||
| 238 | |||
| 239 | return the number of byte copied if somes bytes are copied | ||
| 240 | return 0 if the end of file was reached | ||
| 241 | return <0 with error code if there is an error | ||
| 242 | (UNZ_ERRNO for IO error, or zLib error for uncompress error) | ||
| 243 | */ | ||
| 244 | |||
| 245 | extern z_off_t ZEXPORT unztell OF((unzFile file)); | ||
| 246 | /* | ||
| 247 | Give the current position in uncompressed data | ||
| 248 | */ | ||
| 249 | |||
| 250 | extern int ZEXPORT unzeof OF((unzFile file)); | ||
| 251 | /* | ||
| 252 | return 1 if the end of file was reached, 0 elsewhere | ||
| 253 | */ | ||
| 254 | |||
| 255 | extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, | ||
| 256 | voidp buf, | ||
| 257 | unsigned len)); | ||
| 258 | /* | ||
| 259 | Read extra field from the current file (opened by unzOpenCurrentFile) | ||
| 260 | This is the local-header version of the extra field (sometimes, there is | ||
| 261 | more info in the local-header version than in the central-header) | ||
| 262 | |||
| 263 | if buf==NULL, it return the size of the local extra field | ||
| 264 | |||
| 265 | if buf!=NULL, len is the size of the buffer, the extra header is copied in | ||
| 266 | buf. | ||
| 267 | the return value is the number of bytes copied in buf, or (if <0) | ||
| 268 | the error code | ||
| 269 | */ | ||
| 270 | |||
| 271 | #ifdef __cplusplus | ||
| 272 | } | ||
| 273 | #endif | ||
| 274 | |||
| 275 | #endif /* _unz_H */ | ||
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c new file mode 100644 index 0000000..ddb2334 --- /dev/null +++ b/contrib/minizip/zip.c | |||
| @@ -0,0 +1,716 @@ | |||
| 1 | /* zip.c -- IO on .zip files using zlib | ||
| 2 | Version 0.15 beta, Mar 19th, 1998, | ||
| 3 | |||
| 4 | Read zip.h for more info | ||
| 5 | */ | ||
| 6 | |||
| 7 | |||
| 8 | #include <stdio.h> | ||
| 9 | #include <stdlib.h> | ||
| 10 | #include <string.h> | ||
| 11 | #include "zlib.h" | ||
| 12 | #include "zip.h" | ||
| 13 | |||
| 14 | #ifdef STDC | ||
| 15 | # include <stddef.h> | ||
| 16 | # include <string.h> | ||
| 17 | # include <stdlib.h> | ||
| 18 | #endif | ||
| 19 | #ifdef NO_ERRNO_H | ||
| 20 | extern int errno; | ||
| 21 | #else | ||
| 22 | # include <errno.h> | ||
| 23 | #endif | ||
| 24 | |||
| 25 | |||
| 26 | #ifndef local | ||
| 27 | # define local static | ||
| 28 | #endif | ||
| 29 | /* compile with -Dlocal if your debugger can't find static symbols */ | ||
| 30 | |||
| 31 | #ifndef VERSIONMADEBY | ||
| 32 | # define VERSIONMADEBY (0x0) /* platform depedent */ | ||
| 33 | #endif | ||
| 34 | |||
| 35 | #ifndef Z_BUFSIZE | ||
| 36 | #define Z_BUFSIZE (16384) | ||
| 37 | #endif | ||
| 38 | |||
| 39 | #ifndef Z_MAXFILENAMEINZIP | ||
| 40 | #define Z_MAXFILENAMEINZIP (256) | ||
| 41 | #endif | ||
| 42 | |||
| 43 | #ifndef ALLOC | ||
| 44 | # define ALLOC(size) (malloc(size)) | ||
| 45 | #endif | ||
| 46 | #ifndef TRYFREE | ||
| 47 | # define TRYFREE(p) {if (p) free(p);} | ||
| 48 | #endif | ||
| 49 | |||
| 50 | /* | ||
| 51 | #define SIZECENTRALDIRITEM (0x2e) | ||
| 52 | #define SIZEZIPLOCALHEADER (0x1e) | ||
| 53 | */ | ||
| 54 | |||
| 55 | /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ | ||
| 56 | |||
| 57 | #ifndef SEEK_CUR | ||
| 58 | #define SEEK_CUR 1 | ||
| 59 | #endif | ||
| 60 | |||
| 61 | #ifndef SEEK_END | ||
| 62 | #define SEEK_END 2 | ||
| 63 | #endif | ||
| 64 | |||
| 65 | #ifndef SEEK_SET | ||
| 66 | #define SEEK_SET 0 | ||
| 67 | #endif | ||
| 68 | |||
| 69 | const char zip_copyright[] = | ||
| 70 | " zip 0.15 Copyright 1998 Gilles Vollant "; | ||
| 71 | |||
| 72 | |||
| 73 | #define SIZEDATA_INDATABLOCK (4096-(4*4)) | ||
| 74 | |||
| 75 | #define LOCALHEADERMAGIC (0x04034b50) | ||
| 76 | #define CENTRALHEADERMAGIC (0x02014b50) | ||
| 77 | #define ENDHEADERMAGIC (0x06054b50) | ||
| 78 | |||
| 79 | #define FLAG_LOCALHEADER_OFFSET (0x06) | ||
| 80 | #define CRC_LOCALHEADER_OFFSET (0x0e) | ||
| 81 | |||
| 82 | #define SIZECENTRALHEADER (0x2e) /* 46 */ | ||
| 83 | |||
| 84 | typedef struct linkedlist_datablock_internal_s | ||
| 85 | { | ||
| 86 | struct linkedlist_datablock_internal_s* next_datablock; | ||
| 87 | uLong avail_in_this_block; | ||
| 88 | uLong filled_in_this_block; | ||
| 89 | uLong unused; /* for future use and alignement */ | ||
| 90 | unsigned char data[SIZEDATA_INDATABLOCK]; | ||
| 91 | } linkedlist_datablock_internal; | ||
| 92 | |||
| 93 | typedef struct linkedlist_data_s | ||
| 94 | { | ||
| 95 | linkedlist_datablock_internal* first_block; | ||
| 96 | linkedlist_datablock_internal* last_block; | ||
| 97 | } linkedlist_data; | ||
| 98 | |||
| 99 | |||
| 100 | typedef struct | ||
| 101 | { | ||
| 102 | z_stream stream; /* zLib stream structure for inflate */ | ||
| 103 | int stream_initialised; /* 1 is stream is initialised */ | ||
| 104 | uInt pos_in_buffered_data; /* last written byte in buffered_data */ | ||
| 105 | |||
| 106 | uLong pos_local_header; /* offset of the local header of the file | ||
| 107 | currenty writing */ | ||
| 108 | char* central_header; /* central header data for the current file */ | ||
| 109 | uLong size_centralheader; /* size of the central header for cur file */ | ||
| 110 | uLong flag; /* flag of the file currently writing */ | ||
| 111 | |||
| 112 | int method; /* compression method of file currenty wr.*/ | ||
| 113 | Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ | ||
| 114 | uLong dosDate; | ||
| 115 | uLong crc32; | ||
| 116 | } curfile_info; | ||
| 117 | |||
| 118 | typedef struct | ||
| 119 | { | ||
| 120 | FILE * filezip; | ||
| 121 | linkedlist_data central_dir;/* datablock with central dir in construction*/ | ||
| 122 | int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ | ||
| 123 | curfile_info ci; /* info on the file curretly writing */ | ||
| 124 | |||
| 125 | uLong begin_pos; /* position of the beginning of the zipfile */ | ||
| 126 | uLong number_entry; | ||
| 127 | } zip_internal; | ||
| 128 | |||
| 129 | local linkedlist_datablock_internal* allocate_new_datablock() | ||
| 130 | { | ||
| 131 | linkedlist_datablock_internal* ldi; | ||
| 132 | ldi = (linkedlist_datablock_internal*) | ||
| 133 | ALLOC(sizeof(linkedlist_datablock_internal)); | ||
| 134 | if (ldi!=NULL) | ||
| 135 | { | ||
| 136 | ldi->next_datablock = NULL ; | ||
| 137 | ldi->filled_in_this_block = 0 ; | ||
| 138 | ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; | ||
| 139 | } | ||
| 140 | return ldi; | ||
| 141 | } | ||
| 142 | |||
| 143 | local void free_datablock(ldi) | ||
| 144 | linkedlist_datablock_internal* ldi; | ||
| 145 | { | ||
| 146 | while (ldi!=NULL) | ||
| 147 | { | ||
| 148 | linkedlist_datablock_internal* ldinext = ldi->next_datablock; | ||
| 149 | TRYFREE(ldi); | ||
| 150 | ldi = ldinext; | ||
| 151 | } | ||
| 152 | } | ||
| 153 | |||
| 154 | local void init_linkedlist(ll) | ||
| 155 | linkedlist_data* ll; | ||
| 156 | { | ||
| 157 | ll->first_block = ll->last_block = NULL; | ||
| 158 | } | ||
| 159 | |||
| 160 | local void free_linkedlist(ll) | ||
| 161 | linkedlist_data* ll; | ||
| 162 | { | ||
| 163 | free_datablock(ll->first_block); | ||
| 164 | ll->first_block = ll->last_block = NULL; | ||
| 165 | } | ||
| 166 | |||
| 167 | |||
| 168 | local int add_data_in_datablock(ll,buf,len) | ||
| 169 | linkedlist_data* ll; | ||
| 170 | const void* buf; | ||
| 171 | uLong len; | ||
| 172 | { | ||
| 173 | linkedlist_datablock_internal* ldi; | ||
| 174 | const unsigned char* from_copy; | ||
| 175 | |||
| 176 | if (ll==NULL) | ||
| 177 | return ZIP_INTERNALERROR; | ||
| 178 | |||
| 179 | if (ll->last_block == NULL) | ||
| 180 | { | ||
| 181 | ll->first_block = ll->last_block = allocate_new_datablock(); | ||
| 182 | if (ll->first_block == NULL) | ||
| 183 | return ZIP_INTERNALERROR; | ||
| 184 | } | ||
| 185 | |||
| 186 | ldi = ll->last_block; | ||
| 187 | from_copy = (unsigned char*)buf; | ||
| 188 | |||
| 189 | while (len>0) | ||
| 190 | { | ||
| 191 | uInt copy_this; | ||
| 192 | uInt i; | ||
| 193 | unsigned char* to_copy; | ||
| 194 | |||
| 195 | if (ldi->avail_in_this_block==0) | ||
| 196 | { | ||
| 197 | ldi->next_datablock = allocate_new_datablock(); | ||
| 198 | if (ldi->next_datablock == NULL) | ||
| 199 | return ZIP_INTERNALERROR; | ||
| 200 | ldi = ldi->next_datablock ; | ||
| 201 | ll->last_block = ldi; | ||
| 202 | } | ||
| 203 | |||
| 204 | if (ldi->avail_in_this_block < len) | ||
| 205 | copy_this = (uInt)ldi->avail_in_this_block; | ||
| 206 | else | ||
| 207 | copy_this = (uInt)len; | ||
| 208 | |||
| 209 | to_copy = &(ldi->data[ldi->filled_in_this_block]); | ||
| 210 | |||
| 211 | for (i=0;i<copy_this;i++) | ||
| 212 | *(to_copy+i)=*(from_copy+i); | ||
| 213 | |||
| 214 | ldi->filled_in_this_block += copy_this; | ||
| 215 | ldi->avail_in_this_block -= copy_this; | ||
| 216 | from_copy += copy_this ; | ||
| 217 | len -= copy_this; | ||
| 218 | } | ||
| 219 | return ZIP_OK; | ||
| 220 | } | ||
| 221 | |||
| 222 | |||
| 223 | local int write_datablock(fout,ll) | ||
| 224 | FILE * fout; | ||
| 225 | linkedlist_data* ll; | ||
| 226 | { | ||
| 227 | linkedlist_datablock_internal* ldi; | ||
| 228 | ldi = ll->first_block; | ||
| 229 | while (ldi!=NULL) | ||
| 230 | { | ||
| 231 | if (ldi->filled_in_this_block > 0) | ||
| 232 | if (fwrite(ldi->data,(uInt)ldi->filled_in_this_block,1,fout)!=1) | ||
| 233 | return ZIP_ERRNO; | ||
| 234 | ldi = ldi->next_datablock; | ||
| 235 | } | ||
| 236 | return ZIP_OK; | ||
| 237 | } | ||
| 238 | |||
| 239 | /****************************************************************************/ | ||
| 240 | |||
| 241 | /* =========================================================================== | ||
| 242 | Outputs a long in LSB order to the given file | ||
| 243 | nbByte == 1, 2 or 4 (byte, short or long) | ||
| 244 | */ | ||
| 245 | local int ziplocal_putValue (file, x, nbByte) | ||
| 246 | FILE *file; | ||
| 247 | uLong x; | ||
| 248 | int nbByte; | ||
| 249 | { | ||
| 250 | unsigned char buf[4]; | ||
| 251 | int n; | ||
| 252 | for (n = 0; n < nbByte; n++) { | ||
| 253 | buf[n] = (unsigned char)(x & 0xff); | ||
| 254 | x >>= 8; | ||
| 255 | } | ||
| 256 | if (fwrite(buf,nbByte,1,file)!=1) | ||
| 257 | return ZIP_ERRNO; | ||
| 258 | else | ||
| 259 | return ZIP_OK; | ||
| 260 | } | ||
| 261 | |||
| 262 | |||
| 263 | local void ziplocal_putValue_inmemory (dest, x, nbByte) | ||
| 264 | void* dest; | ||
| 265 | uLong x; | ||
| 266 | int nbByte; | ||
| 267 | { | ||
| 268 | unsigned char* buf=(unsigned char*)dest; | ||
| 269 | int n; | ||
| 270 | for (n = 0; n < nbByte; n++) { | ||
| 271 | buf[n] = (unsigned char)(x & 0xff); | ||
| 272 | x >>= 8; | ||
| 273 | } | ||
| 274 | } | ||
| 275 | /****************************************************************************/ | ||
| 276 | |||
| 277 | |||
| 278 | local uLong ziplocal_TmzDateToDosDate(ptm,dosDate) | ||
| 279 | tm_zip* ptm; | ||
| 280 | uLong dosDate; | ||
| 281 | { | ||
| 282 | uLong year = (uLong)ptm->tm_year; | ||
| 283 | if (year>1980) | ||
| 284 | year-=1980; | ||
| 285 | else if (year>80) | ||
| 286 | year-=80; | ||
| 287 | return | ||
| 288 | (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | | ||
| 289 | ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); | ||
| 290 | } | ||
| 291 | |||
| 292 | |||
| 293 | /****************************************************************************/ | ||
| 294 | |||
| 295 | extern zipFile ZEXPORT zipOpen (pathname, append) | ||
| 296 | const char *pathname; | ||
| 297 | int append; | ||
| 298 | { | ||
| 299 | zip_internal ziinit; | ||
| 300 | zip_internal* zi; | ||
| 301 | |||
| 302 | ziinit.filezip = fopen(pathname,(append == 0) ? "wb" : "ab"); | ||
| 303 | if (ziinit.filezip == NULL) | ||
| 304 | return NULL; | ||
| 305 | ziinit.begin_pos = ftell(ziinit.filezip); | ||
| 306 | ziinit.in_opened_file_inzip = 0; | ||
| 307 | ziinit.ci.stream_initialised = 0; | ||
| 308 | ziinit.number_entry = 0; | ||
| 309 | init_linkedlist(&(ziinit.central_dir)); | ||
| 310 | |||
| 311 | |||
| 312 | zi = (zip_internal*)ALLOC(sizeof(zip_internal)); | ||
| 313 | if (zi==NULL) | ||
| 314 | { | ||
| 315 | fclose(ziinit.filezip); | ||
| 316 | return NULL; | ||
| 317 | } | ||
| 318 | |||
| 319 | *zi = ziinit; | ||
| 320 | return (zipFile)zi; | ||
| 321 | } | ||
| 322 | |||
| 323 | extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, | ||
| 324 | extrafield_local, size_extrafield_local, | ||
| 325 | extrafield_global, size_extrafield_global, | ||
| 326 | comment, method, level) | ||
| 327 | zipFile file; | ||
| 328 | const char* filename; | ||
| 329 | const zip_fileinfo* zipfi; | ||
| 330 | const void* extrafield_local; | ||
| 331 | uInt size_extrafield_local; | ||
| 332 | const void* extrafield_global; | ||
| 333 | uInt size_extrafield_global; | ||
| 334 | const char* comment; | ||
| 335 | int method; | ||
| 336 | int level; | ||
| 337 | { | ||
| 338 | zip_internal* zi; | ||
| 339 | uInt size_filename; | ||
| 340 | uInt size_comment; | ||
| 341 | uInt i; | ||
| 342 | int err = ZIP_OK; | ||
| 343 | |||
| 344 | if (file == NULL) | ||
| 345 | return ZIP_PARAMERROR; | ||
| 346 | if ((method!=0) && (method!=Z_DEFLATED)) | ||
| 347 | return ZIP_PARAMERROR; | ||
| 348 | |||
| 349 | zi = (zip_internal*)file; | ||
| 350 | |||
| 351 | if (zi->in_opened_file_inzip == 1) | ||
| 352 | { | ||
| 353 | err = zipCloseFileInZip (file); | ||
| 354 | if (err != ZIP_OK) | ||
| 355 | return err; | ||
| 356 | } | ||
| 357 | |||
| 358 | |||
| 359 | if (filename==NULL) | ||
| 360 | filename="-"; | ||
| 361 | |||
| 362 | if (comment==NULL) | ||
| 363 | size_comment = 0; | ||
| 364 | else | ||
| 365 | size_comment = strlen(comment); | ||
| 366 | |||
| 367 | size_filename = strlen(filename); | ||
| 368 | |||
| 369 | if (zipfi == NULL) | ||
| 370 | zi->ci.dosDate = 0; | ||
| 371 | else | ||
| 372 | { | ||
| 373 | if (zipfi->dosDate != 0) | ||
| 374 | zi->ci.dosDate = zipfi->dosDate; | ||
| 375 | else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate); | ||
| 376 | } | ||
| 377 | |||
| 378 | zi->ci.flag = 0; | ||
| 379 | if ((level==8) || (level==9)) | ||
| 380 | zi->ci.flag |= 2; | ||
| 381 | if ((level==2)) | ||
| 382 | zi->ci.flag |= 4; | ||
| 383 | if ((level==1)) | ||
| 384 | zi->ci.flag |= 6; | ||
| 385 | |||
| 386 | zi->ci.crc32 = 0; | ||
| 387 | zi->ci.method = method; | ||
| 388 | zi->ci.stream_initialised = 0; | ||
| 389 | zi->ci.pos_in_buffered_data = 0; | ||
| 390 | zi->ci.pos_local_header = ftell(zi->filezip); | ||
| 391 | zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + | ||
| 392 | size_extrafield_global + size_comment; | ||
| 393 | zi->ci.central_header = (char*)ALLOC(zi->ci.size_centralheader); | ||
| 394 | |||
| 395 | ziplocal_putValue_inmemory(zi->ci.central_header,CENTRALHEADERMAGIC,4); | ||
| 396 | /* version info */ | ||
| 397 | ziplocal_putValue_inmemory(zi->ci.central_header+4,VERSIONMADEBY,2); | ||
| 398 | ziplocal_putValue_inmemory(zi->ci.central_header+6,20,2); | ||
| 399 | ziplocal_putValue_inmemory(zi->ci.central_header+8,zi->ci.flag,2); | ||
| 400 | ziplocal_putValue_inmemory(zi->ci.central_header+10,zi->ci.method,2); | ||
| 401 | ziplocal_putValue_inmemory(zi->ci.central_header+12,zi->ci.dosDate,4); | ||
| 402 | ziplocal_putValue_inmemory(zi->ci.central_header+16,0,4); /*crc*/ | ||
| 403 | ziplocal_putValue_inmemory(zi->ci.central_header+20,0,4); /*compr size*/ | ||
| 404 | ziplocal_putValue_inmemory(zi->ci.central_header+24,0,4); /*uncompr size*/ | ||
| 405 | ziplocal_putValue_inmemory(zi->ci.central_header+28,size_filename,2); | ||
| 406 | ziplocal_putValue_inmemory(zi->ci.central_header+30,size_extrafield_global,2); | ||
| 407 | ziplocal_putValue_inmemory(zi->ci.central_header+32,size_comment,2); | ||
| 408 | ziplocal_putValue_inmemory(zi->ci.central_header+34,0,2); /*disk nm start*/ | ||
| 409 | |||
| 410 | if (zipfi==NULL) | ||
| 411 | ziplocal_putValue_inmemory(zi->ci.central_header+36,0,2); | ||
| 412 | else | ||
| 413 | ziplocal_putValue_inmemory(zi->ci.central_header+36,zipfi->internal_fa,2); | ||
| 414 | |||
| 415 | if (zipfi==NULL) | ||
| 416 | ziplocal_putValue_inmemory(zi->ci.central_header+38,0,4); | ||
| 417 | else | ||
| 418 | ziplocal_putValue_inmemory(zi->ci.central_header+38,zipfi->external_fa,4); | ||
| 419 | |||
| 420 | ziplocal_putValue_inmemory(zi->ci.central_header+42,zi->ci.pos_local_header,4); | ||
| 421 | |||
| 422 | for (i=0;i<size_filename;i++) | ||
| 423 | *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i); | ||
| 424 | |||
| 425 | for (i=0;i<size_extrafield_global;i++) | ||
| 426 | *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+i) = | ||
| 427 | *(((const char*)extrafield_global)+i); | ||
| 428 | |||
| 429 | for (i=0;i<size_comment;i++) | ||
| 430 | *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+ | ||
| 431 | size_extrafield_global+i) = *(filename+i); | ||
| 432 | if (zi->ci.central_header == NULL) | ||
| 433 | return ZIP_INTERNALERROR; | ||
| 434 | |||
| 435 | /* write the local header */ | ||
| 436 | err = ziplocal_putValue(zi->filezip,LOCALHEADERMAGIC,4); | ||
| 437 | |||
| 438 | if (err==ZIP_OK) | ||
| 439 | err = ziplocal_putValue(zi->filezip,20,2);/* version needed to extract */ | ||
| 440 | if (err==ZIP_OK) | ||
| 441 | err = ziplocal_putValue(zi->filezip,zi->ci.flag,2); | ||
| 442 | |||
| 443 | if (err==ZIP_OK) | ||
| 444 | err = ziplocal_putValue(zi->filezip,zi->ci.method,2); | ||
| 445 | |||
| 446 | if (err==ZIP_OK) | ||
| 447 | err = ziplocal_putValue(zi->filezip,zi->ci.dosDate,4); | ||
| 448 | |||
| 449 | if (err==ZIP_OK) | ||
| 450 | err = ziplocal_putValue(zi->filezip,0,4); /* crc 32, unknown */ | ||
| 451 | if (err==ZIP_OK) | ||
| 452 | err = ziplocal_putValue(zi->filezip,0,4); /* compressed size, unknown */ | ||
| 453 | if (err==ZIP_OK) | ||
| 454 | err = ziplocal_putValue(zi->filezip,0,4); /* uncompressed size, unknown */ | ||
| 455 | |||
| 456 | if (err==ZIP_OK) | ||
| 457 | err = ziplocal_putValue(zi->filezip,(uLong)size_filename,2); | ||
| 458 | |||
| 459 | if (err==ZIP_OK) | ||
| 460 | err = ziplocal_putValue(zi->filezip,(uLong)size_extrafield_local,2); | ||
| 461 | |||
| 462 | if ((err==ZIP_OK) && (size_filename>0)) | ||
| 463 | if (fwrite(filename,(uInt)size_filename,1,zi->filezip)!=1) | ||
| 464 | err = ZIP_ERRNO; | ||
| 465 | |||
| 466 | if ((err==ZIP_OK) && (size_extrafield_local>0)) | ||
| 467 | if (fwrite(extrafield_local,(uInt)size_extrafield_local,1,zi->filezip) | ||
| 468 | !=1) | ||
| 469 | err = ZIP_ERRNO; | ||
| 470 | |||
| 471 | zi->ci.stream.avail_in = (uInt)0; | ||
| 472 | zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; | ||
| 473 | zi->ci.stream.next_out = zi->ci.buffered_data; | ||
| 474 | zi->ci.stream.total_in = 0; | ||
| 475 | zi->ci.stream.total_out = 0; | ||
| 476 | |||
| 477 | if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED)) | ||
| 478 | { | ||
| 479 | zi->ci.stream.zalloc = (alloc_func)0; | ||
| 480 | zi->ci.stream.zfree = (free_func)0; | ||
| 481 | zi->ci.stream.opaque = (voidpf)0; | ||
| 482 | |||
| 483 | err = deflateInit2(&zi->ci.stream, level, | ||
| 484 | Z_DEFLATED, -MAX_WBITS, /*DEF_MEM_LEVEL*/8, 0); | ||
| 485 | |||
| 486 | if (err==Z_OK) | ||
| 487 | zi->ci.stream_initialised = 1; | ||
| 488 | } | ||
| 489 | |||
| 490 | |||
| 491 | if (err==Z_OK) | ||
| 492 | zi->in_opened_file_inzip = 1; | ||
| 493 | return err; | ||
| 494 | } | ||
| 495 | |||
| 496 | extern int ZEXPORT zipWriteInFileInZip (file, buf, len) | ||
| 497 | zipFile file; | ||
| 498 | const voidp buf; | ||
| 499 | unsigned len; | ||
| 500 | { | ||
| 501 | zip_internal* zi; | ||
| 502 | int err=ZIP_OK; | ||
| 503 | |||
| 504 | if (file == NULL) | ||
| 505 | return ZIP_PARAMERROR; | ||
| 506 | zi = (zip_internal*)file; | ||
| 507 | |||
| 508 | if (zi->in_opened_file_inzip == 0) | ||
| 509 | return ZIP_PARAMERROR; | ||
| 510 | |||
| 511 | zi->ci.stream.next_in = buf; | ||
| 512 | zi->ci.stream.avail_in = len; | ||
| 513 | zi->ci.crc32 = crc32(zi->ci.crc32,buf,len); | ||
| 514 | |||
| 515 | while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) | ||
| 516 | { | ||
| 517 | if (zi->ci.stream.avail_out == 0) | ||
| 518 | { | ||
| 519 | if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip) | ||
| 520 | !=1) | ||
| 521 | err = ZIP_ERRNO; | ||
| 522 | zi->ci.pos_in_buffered_data = 0; | ||
| 523 | zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; | ||
| 524 | zi->ci.stream.next_out = zi->ci.buffered_data; | ||
| 525 | } | ||
| 526 | |||
| 527 | if (zi->ci.method == Z_DEFLATED) | ||
| 528 | { | ||
| 529 | uLong uTotalOutBefore = zi->ci.stream.total_out; | ||
| 530 | err=deflate(&zi->ci.stream, Z_NO_FLUSH); | ||
| 531 | zi->ci.pos_in_buffered_data += zi->ci.stream.total_out - uTotalOutBefore ; | ||
| 532 | |||
| 533 | } | ||
| 534 | else | ||
| 535 | { | ||
| 536 | uInt copy_this,i; | ||
| 537 | if (zi->ci.stream.avail_in < zi->ci.stream.avail_out) | ||
| 538 | copy_this = zi->ci.stream.avail_in; | ||
| 539 | else | ||
| 540 | copy_this = zi->ci.stream.avail_out; | ||
| 541 | for (i=0;i<copy_this;i++) | ||
| 542 | *(((char*)zi->ci.stream.next_out)+i) = | ||
| 543 | *(((const char*)zi->ci.stream.next_in)+i); | ||
| 544 | { | ||
| 545 | zi->ci.stream.avail_in -= copy_this; | ||
| 546 | zi->ci.stream.avail_out-= copy_this; | ||
| 547 | zi->ci.stream.next_in+= copy_this; | ||
| 548 | zi->ci.stream.next_out+= copy_this; | ||
| 549 | zi->ci.stream.total_in+= copy_this; | ||
| 550 | zi->ci.stream.total_out+= copy_this; | ||
| 551 | zi->ci.pos_in_buffered_data += copy_this; | ||
| 552 | } | ||
| 553 | } | ||
| 554 | } | ||
| 555 | |||
| 556 | return 0; | ||
| 557 | } | ||
| 558 | |||
| 559 | extern int ZEXPORT zipCloseFileInZip (file) | ||
| 560 | zipFile file; | ||
| 561 | { | ||
| 562 | zip_internal* zi; | ||
| 563 | int err=ZIP_OK; | ||
| 564 | |||
| 565 | if (file == NULL) | ||
| 566 | return ZIP_PARAMERROR; | ||
| 567 | zi = (zip_internal*)file; | ||
| 568 | |||
| 569 | if (zi->in_opened_file_inzip == 0) | ||
| 570 | return ZIP_PARAMERROR; | ||
| 571 | zi->ci.stream.avail_in = 0; | ||
| 572 | |||
| 573 | if (zi->ci.method == Z_DEFLATED) | ||
| 574 | while (err==ZIP_OK) | ||
| 575 | { | ||
| 576 | uLong uTotalOutBefore; | ||
| 577 | if (zi->ci.stream.avail_out == 0) | ||
| 578 | { | ||
| 579 | if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip) | ||
| 580 | !=1) | ||
| 581 | err = ZIP_ERRNO; | ||
| 582 | zi->ci.pos_in_buffered_data = 0; | ||
| 583 | zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; | ||
| 584 | zi->ci.stream.next_out = zi->ci.buffered_data; | ||
| 585 | } | ||
| 586 | uTotalOutBefore = zi->ci.stream.total_out; | ||
| 587 | err=deflate(&zi->ci.stream, Z_FINISH); | ||
| 588 | zi->ci.pos_in_buffered_data += zi->ci.stream.total_out - uTotalOutBefore ; | ||
| 589 | } | ||
| 590 | |||
| 591 | if (err==Z_STREAM_END) | ||
| 592 | err=ZIP_OK; /* this is normal */ | ||
| 593 | |||
| 594 | if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) | ||
| 595 | if (fwrite(zi->ci.buffered_data,(uInt)zi->ci.pos_in_buffered_data,1,zi->filezip) | ||
| 596 | !=1) | ||
| 597 | err = ZIP_ERRNO; | ||
| 598 | |||
| 599 | if ((zi->ci.method == Z_DEFLATED) && (err==ZIP_OK)) | ||
| 600 | { | ||
| 601 | err=deflateEnd(&zi->ci.stream); | ||
| 602 | zi->ci.stream_initialised = 0; | ||
| 603 | } | ||
| 604 | |||
| 605 | ziplocal_putValue_inmemory(zi->ci.central_header+16,zi->ci.crc32,4); /*crc*/ | ||
| 606 | ziplocal_putValue_inmemory(zi->ci.central_header+20, | ||
| 607 | zi->ci.stream.total_out,4); /*compr size*/ | ||
| 608 | ziplocal_putValue_inmemory(zi->ci.central_header+24, | ||
| 609 | zi->ci.stream.total_in,4); /*uncompr size*/ | ||
| 610 | |||
| 611 | if (err==ZIP_OK) | ||
| 612 | err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, | ||
| 613 | (uLong)zi->ci.size_centralheader); | ||
| 614 | free(zi->ci.central_header); | ||
| 615 | |||
| 616 | if (err==ZIP_OK) | ||
| 617 | { | ||
| 618 | long cur_pos_inzip = ftell(zi->filezip); | ||
| 619 | if (fseek(zi->filezip, | ||
| 620 | zi->ci.pos_local_header + 14,SEEK_SET)!=0) | ||
| 621 | err = ZIP_ERRNO; | ||
| 622 | |||
| 623 | if (err==ZIP_OK) | ||
| 624 | err = ziplocal_putValue(zi->filezip,zi->ci.crc32,4); /* crc 32, unknown */ | ||
| 625 | |||
| 626 | if (err==ZIP_OK) /* compressed size, unknown */ | ||
| 627 | err = ziplocal_putValue(zi->filezip,zi->ci.stream.total_out,4); | ||
| 628 | |||
| 629 | if (err==ZIP_OK) /* uncompressed size, unknown */ | ||
| 630 | err = ziplocal_putValue(zi->filezip,zi->ci.stream.total_in,4); | ||
| 631 | |||
| 632 | if (fseek(zi->filezip, | ||
| 633 | cur_pos_inzip,SEEK_SET)!=0) | ||
| 634 | err = ZIP_ERRNO; | ||
| 635 | } | ||
| 636 | |||
| 637 | zi->number_entry ++; | ||
| 638 | zi->in_opened_file_inzip = 0; | ||
| 639 | |||
| 640 | return err; | ||
| 641 | } | ||
| 642 | |||
| 643 | extern int ZEXPORT zipClose (file, global_comment) | ||
| 644 | zipFile file; | ||
| 645 | const char* global_comment; | ||
| 646 | { | ||
| 647 | zip_internal* zi; | ||
| 648 | int err = 0; | ||
| 649 | uLong size_centraldir = 0; | ||
| 650 | uLong centraldir_pos_inzip ; | ||
| 651 | uInt size_global_comment; | ||
| 652 | if (file == NULL) | ||
| 653 | return ZIP_PARAMERROR; | ||
| 654 | zi = (zip_internal*)file; | ||
| 655 | |||
| 656 | if (zi->in_opened_file_inzip == 1) | ||
| 657 | { | ||
| 658 | err = zipCloseFileInZip (file); | ||
| 659 | } | ||
| 660 | |||
| 661 | if (global_comment==NULL) | ||
| 662 | size_global_comment = 0; | ||
| 663 | else | ||
| 664 | size_global_comment = strlen(global_comment); | ||
| 665 | |||
| 666 | |||
| 667 | centraldir_pos_inzip = ftell(zi->filezip); | ||
| 668 | if (err==ZIP_OK) | ||
| 669 | { | ||
| 670 | linkedlist_datablock_internal* ldi = zi->central_dir.first_block ; | ||
| 671 | while (ldi!=NULL) | ||
| 672 | { | ||
| 673 | if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) | ||
| 674 | if (fwrite(ldi->data,(uInt)ldi->filled_in_this_block, | ||
| 675 | 1,zi->filezip) !=1 ) | ||
| 676 | err = ZIP_ERRNO; | ||
| 677 | |||
| 678 | size_centraldir += ldi->filled_in_this_block; | ||
| 679 | ldi = ldi->next_datablock; | ||
| 680 | } | ||
| 681 | } | ||
| 682 | free_datablock(zi->central_dir.first_block); | ||
| 683 | |||
| 684 | if (err==ZIP_OK) /* Magic End */ | ||
| 685 | err = ziplocal_putValue(zi->filezip,ENDHEADERMAGIC,4); | ||
| 686 | |||
| 687 | if (err==ZIP_OK) /* number of this disk */ | ||
| 688 | err = ziplocal_putValue(zi->filezip,0,2); | ||
| 689 | |||
| 690 | if (err==ZIP_OK) /* number of the disk with the start of the central directory */ | ||
| 691 | err = ziplocal_putValue(zi->filezip,0,2); | ||
| 692 | |||
| 693 | if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ | ||
| 694 | err = ziplocal_putValue(zi->filezip,zi->number_entry,2); | ||
| 695 | |||
| 696 | if (err==ZIP_OK) /* total number of entries in the central dir */ | ||
| 697 | err = ziplocal_putValue(zi->filezip,zi->number_entry,2); | ||
| 698 | |||
| 699 | if (err==ZIP_OK) /* size of the central directory */ | ||
| 700 | err = ziplocal_putValue(zi->filezip,size_centraldir,4); | ||
| 701 | |||
| 702 | if (err==ZIP_OK) /* offset of start of central directory with respect to the | ||
| 703 | starting disk number */ | ||
| 704 | err = ziplocal_putValue(zi->filezip,centraldir_pos_inzip ,4); | ||
| 705 | |||
| 706 | if (err==ZIP_OK) /* zipfile comment length */ | ||
| 707 | err = ziplocal_putValue(zi->filezip,(uLong)size_global_comment,2); | ||
| 708 | |||
| 709 | if ((err==ZIP_OK) && (size_global_comment>0)) | ||
| 710 | if (fwrite(global_comment,(uInt)size_global_comment,1,zi->filezip) !=1 ) | ||
| 711 | err = ZIP_ERRNO; | ||
| 712 | fclose(zi->filezip); | ||
| 713 | TRYFREE(zi); | ||
| 714 | |||
| 715 | return err; | ||
| 716 | } | ||
diff --git a/contrib/minizip/zip.def b/contrib/minizip/zip.def new file mode 100644 index 0000000..5d5079f --- /dev/null +++ b/contrib/minizip/zip.def | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | zipOpen @80 | ||
| 2 | zipOpenNewFileInZip @81 | ||
| 3 | zipWriteInFileInZip @82 | ||
| 4 | zipCloseFileInZip @83 | ||
| 5 | zipClose @84 | ||
diff --git a/contrib/minizip/zip.h b/contrib/minizip/zip.h new file mode 100644 index 0000000..678260b --- /dev/null +++ b/contrib/minizip/zip.h | |||
| @@ -0,0 +1,150 @@ | |||
| 1 | /* zip.h -- IO for compress .zip files using zlib | ||
| 2 | Version 0.15 alpha, Mar 19th, 1998, | ||
| 3 | |||
| 4 | Copyright (C) 1998 Gilles Vollant | ||
| 5 | |||
| 6 | This unzip package allow creates .ZIP file, compatible with PKZip 2.04g | ||
| 7 | WinZip, InfoZip tools and compatible. | ||
| 8 | Encryption and multi volume ZipFile (span) are not supported. | ||
| 9 | Old compressions used by old PKZip 1.x are not supported | ||
| 10 | |||
| 11 | For uncompress .zip file, look at unzip.h | ||
| 12 | |||
| 13 | THIS IS AN ALPHA VERSION. AT THIS STAGE OF DEVELOPPEMENT, SOMES API OR STRUCTURE | ||
| 14 | CAN CHANGE IN FUTURE VERSION !! | ||
| 15 | I WAIT FEEDBACK at mail info@winimage.com | ||
| 16 | Visit also http://www.winimage.com/zLibDll/zip.htm for evolution | ||
| 17 | |||
| 18 | Condition of use and distribution are the same than zlib : | ||
| 19 | |||
| 20 | This software is provided 'as-is', without any express or implied | ||
| 21 | warranty. In no event will the authors be held liable for any damages | ||
| 22 | arising from the use of this software. | ||
| 23 | |||
| 24 | Permission is granted to anyone to use this software for any purpose, | ||
| 25 | including commercial applications, and to alter it and redistribute it | ||
| 26 | freely, subject to the following restrictions: | ||
| 27 | |||
| 28 | 1. The origin of this software must not be misrepresented; you must not | ||
| 29 | claim that you wrote the original software. If you use this software | ||
| 30 | in a product, an acknowledgment in the product documentation would be | ||
| 31 | appreciated but is not required. | ||
| 32 | 2. Altered source versions must be plainly marked as such, and must not be | ||
| 33 | misrepresented as being the original software. | ||
| 34 | 3. This notice may not be removed or altered from any source distribution. | ||
| 35 | |||
| 36 | |||
| 37 | */ | ||
| 38 | |||
| 39 | /* for more info about .ZIP format, see | ||
| 40 | ftp://ftp.cdrom.com/pub/infozip/doc/appnote-970311-iz.zip | ||
| 41 | PkWare has also a specification at : | ||
| 42 | ftp://ftp.pkware.com/probdesc.zip | ||
| 43 | */ | ||
| 44 | |||
| 45 | #ifndef _zip_H | ||
| 46 | #define _zip_H | ||
| 47 | |||
| 48 | #ifdef __cplusplus | ||
| 49 | extern "C" { | ||
| 50 | #endif | ||
| 51 | |||
| 52 | #ifndef _ZLIB_H | ||
| 53 | #include "zlib.h" | ||
| 54 | #endif | ||
| 55 | |||
| 56 | #if defined(STRICTZIP) || defined(STRICTZIPUNZIP) | ||
| 57 | /* like the STRICT of WIN32, we define a pointer that cannot be converted | ||
| 58 | from (void*) without cast */ | ||
| 59 | typedef struct TagzipFile__ { int unused; } zipFile__; | ||
| 60 | typedef zipFile__ *zipFile; | ||
| 61 | #else | ||
| 62 | typedef voidp zipFile; | ||
| 63 | #endif | ||
| 64 | |||
| 65 | #define ZIP_OK (0) | ||
| 66 | #define ZIP_ERRNO (Z_ERRNO) | ||
| 67 | #define ZIP_PARAMERROR (-102) | ||
| 68 | #define ZIP_INTERNALERROR (-104) | ||
| 69 | |||
| 70 | /* tm_zip contain date/time info */ | ||
| 71 | typedef struct tm_zip_s | ||
| 72 | { | ||
| 73 | uInt tm_sec; /* seconds after the minute - [0,59] */ | ||
| 74 | uInt tm_min; /* minutes after the hour - [0,59] */ | ||
| 75 | uInt tm_hour; /* hours since midnight - [0,23] */ | ||
| 76 | uInt tm_mday; /* day of the month - [1,31] */ | ||
| 77 | uInt tm_mon; /* months since January - [0,11] */ | ||
| 78 | uInt tm_year; /* years - [1980..2044] */ | ||
| 79 | } tm_zip; | ||
| 80 | |||
| 81 | typedef struct | ||
| 82 | { | ||
| 83 | tm_zip tmz_date; /* date in understandable format */ | ||
| 84 | uLong dosDate; /* if dos_date == 0, tmu_date is used */ | ||
| 85 | /* uLong flag; */ /* general purpose bit flag 2 bytes */ | ||
| 86 | |||
| 87 | uLong internal_fa; /* internal file attributes 2 bytes */ | ||
| 88 | uLong external_fa; /* external file attributes 4 bytes */ | ||
| 89 | } zip_fileinfo; | ||
| 90 | |||
| 91 | extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); | ||
| 92 | /* | ||
| 93 | Create a zipfile. | ||
| 94 | pathname contain on Windows NT a filename like "c:\\zlib\\zlib111.zip" or on | ||
| 95 | an Unix computer "zlib/zlib111.zip". | ||
| 96 | if the file pathname exist and append=1, the zip will be created at the end | ||
| 97 | of the file. (useful if the file contain a self extractor code) | ||
| 98 | If the zipfile cannot be opened, the return value is NULL. | ||
| 99 | Else, the return value is a zipFile Handle, usable with other function | ||
| 100 | of this zip package. | ||
| 101 | |||
| 102 | |||
| 103 | */ | ||
| 104 | |||
| 105 | extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, | ||
| 106 | const char* filename, | ||
| 107 | const zip_fileinfo* zipfi, | ||
| 108 | const void* extrafield_local, | ||
| 109 | uInt size_extrafield_local, | ||
| 110 | const void* extrafield_global, | ||
| 111 | uInt size_extrafield_global, | ||
| 112 | const char* comment, | ||
| 113 | int method, | ||
| 114 | int level)); | ||
| 115 | /* | ||
| 116 | Open a file in the ZIP for writing. | ||
| 117 | filename : the filename in zip (if NULL, '-' without quote will be used | ||
| 118 | *zipfi contain supplemental information | ||
| 119 | if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local | ||
| 120 | contains the extrafield data the the local header | ||
| 121 | if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global | ||
| 122 | contains the extrafield data the the local header | ||
| 123 | if comment != NULL, comment contain the comment string | ||
| 124 | method contain the compression method (0 for store, Z_DEFLATED for deflate) | ||
| 125 | level contain the level of compression (can be Z_DEFAULT_COMPRESSION) | ||
| 126 | */ | ||
| 127 | |||
| 128 | extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, | ||
| 129 | const voidp buf, | ||
| 130 | unsigned len)); | ||
| 131 | /* | ||
| 132 | Write data in the zipfile | ||
| 133 | */ | ||
| 134 | |||
| 135 | extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); | ||
| 136 | /* | ||
| 137 | Close the current file in the zipfile | ||
| 138 | */ | ||
| 139 | |||
| 140 | extern int ZEXPORT zipClose OF((zipFile file, | ||
| 141 | const char* global_comment)); | ||
| 142 | /* | ||
| 143 | Close the zipfile | ||
| 144 | */ | ||
| 145 | |||
| 146 | #ifdef __cplusplus | ||
| 147 | } | ||
| 148 | #endif | ||
| 149 | |||
| 150 | #endif /* _zip_H */ | ||
diff --git a/contrib/minizip/zlibvc.def b/contrib/minizip/zlibvc.def new file mode 100644 index 0000000..7e9d60d --- /dev/null +++ b/contrib/minizip/zlibvc.def | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | LIBRARY "zlib" | ||
| 2 | |||
| 3 | DESCRIPTION '"""zlib data compression library"""' | ||
| 4 | |||
| 5 | |||
| 6 | VERSION 1.11 | ||
| 7 | |||
| 8 | |||
| 9 | HEAPSIZE 1048576,8192 | ||
| 10 | |||
| 11 | EXPORTS | ||
| 12 | adler32 @1 | ||
| 13 | compress @2 | ||
| 14 | crc32 @3 | ||
| 15 | deflate @4 | ||
| 16 | deflateCopy @5 | ||
| 17 | deflateEnd @6 | ||
| 18 | deflateInit2_ @7 | ||
| 19 | deflateInit_ @8 | ||
| 20 | deflateParams @9 | ||
| 21 | deflateReset @10 | ||
| 22 | deflateSetDictionary @11 | ||
| 23 | gzclose @12 | ||
| 24 | gzdopen @13 | ||
| 25 | gzerror @14 | ||
| 26 | gzflush @15 | ||
| 27 | gzopen @16 | ||
| 28 | gzread @17 | ||
| 29 | gzwrite @18 | ||
| 30 | inflate @19 | ||
| 31 | inflateEnd @20 | ||
| 32 | inflateInit2_ @21 | ||
| 33 | inflateInit_ @22 | ||
| 34 | inflateReset @23 | ||
| 35 | inflateSetDictionary @24 | ||
| 36 | inflateSync @25 | ||
| 37 | uncompress @26 | ||
| 38 | zlibVersion @27 | ||
| 39 | gzprintf @28 | ||
| 40 | gzputc @29 | ||
| 41 | gzgetc @30 | ||
| 42 | gzseek @31 | ||
| 43 | gzrewind @32 | ||
| 44 | gztell @33 | ||
| 45 | gzeof @34 | ||
| 46 | gzsetparams @35 | ||
| 47 | zError @36 | ||
| 48 | inflateSyncPoint @37 | ||
| 49 | get_crc_table @38 | ||
| 50 | compress2 @39 | ||
| 51 | gzputs @40 | ||
| 52 | gzgets @41 | ||
| 53 | |||
| 54 | unzOpen @61 | ||
| 55 | unzClose @62 | ||
| 56 | unzGetGlobalInfo @63 | ||
| 57 | unzGetCurrentFileInfo @64 | ||
| 58 | unzGoToFirstFile @65 | ||
| 59 | unzGoToNextFile @66 | ||
| 60 | unzOpenCurrentFile @67 | ||
| 61 | unzReadCurrentFile @68 | ||
| 62 | unztell @70 | ||
| 63 | unzeof @71 | ||
| 64 | unzCloseCurrentFile @72 | ||
| 65 | unzGetGlobalComment @73 | ||
| 66 | unzStringFileNameCompare @74 | ||
| 67 | unzLocateFile @75 | ||
| 68 | unzGetLocalExtrafield @76 | ||
| 69 | |||
| 70 | zipOpen @80 | ||
| 71 | zipOpenNewFileInZip @81 | ||
| 72 | zipWriteInFileInZip @82 | ||
| 73 | zipCloseFileInZip @83 | ||
| 74 | zipClose @84 | ||
diff --git a/contrib/minizip/zlibvc.dsp b/contrib/minizip/zlibvc.dsp new file mode 100644 index 0000000..a70d4d4 --- /dev/null +++ b/contrib/minizip/zlibvc.dsp | |||
| @@ -0,0 +1,651 @@ | |||
| 1 | # Microsoft Developer Studio Project File - Name="zlibvc" - Package Owner=<4> | ||
| 2 | # Microsoft Developer Studio Generated Build File, Format Version 5.00 | ||
| 3 | # ** DO NOT EDIT ** | ||
| 4 | |||
| 5 | # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 | ||
| 6 | # TARGTYPE "Win32 (ALPHA) Dynamic-Link Library" 0x0602 | ||
| 7 | |||
| 8 | CFG=zlibvc - Win32 Release | ||
| 9 | !MESSAGE This is not a valid makefile. To build this project using NMAKE, | ||
| 10 | !MESSAGE use the Export Makefile command and run | ||
| 11 | !MESSAGE | ||
| 12 | !MESSAGE NMAKE /f "zlibvc.mak". | ||
| 13 | !MESSAGE | ||
| 14 | !MESSAGE You can specify a configuration when running NMAKE | ||
| 15 | !MESSAGE by defining the macro CFG on the command line. For example: | ||
| 16 | !MESSAGE | ||
| 17 | !MESSAGE NMAKE /f "zlibvc.mak" CFG="zlibvc - Win32 Release" | ||
| 18 | !MESSAGE | ||
| 19 | !MESSAGE Possible choices for configuration are: | ||
| 20 | !MESSAGE | ||
| 21 | !MESSAGE "zlibvc - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") | ||
| 22 | !MESSAGE "zlibvc - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") | ||
| 23 | !MESSAGE "zlibvc - Win32 ReleaseAxp" (based on\ | ||
| 24 | "Win32 (ALPHA) Dynamic-Link Library") | ||
| 25 | !MESSAGE "zlibvc - Win32 ReleaseWithoutAsm" (based on\ | ||
| 26 | "Win32 (x86) Dynamic-Link Library") | ||
| 27 | !MESSAGE "zlibvc - Win32 ReleaseWithoutCrtdll" (based on\ | ||
| 28 | "Win32 (x86) Dynamic-Link Library") | ||
| 29 | !MESSAGE | ||
| 30 | |||
| 31 | # Begin Project | ||
| 32 | # PROP Scc_ProjName "" | ||
| 33 | # PROP Scc_LocalPath "" | ||
| 34 | |||
| 35 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 36 | |||
| 37 | # PROP BASE Use_MFC 0 | ||
| 38 | # PROP BASE Use_Debug_Libraries 0 | ||
| 39 | # PROP BASE Output_Dir ".\Release" | ||
| 40 | # PROP BASE Intermediate_Dir ".\Release" | ||
| 41 | # PROP BASE Target_Dir "" | ||
| 42 | # PROP Use_MFC 0 | ||
| 43 | # PROP Use_Debug_Libraries 0 | ||
| 44 | # PROP Output_Dir ".\Release" | ||
| 45 | # PROP Intermediate_Dir ".\Release" | ||
| 46 | # PROP Ignore_Export_Lib 0 | ||
| 47 | # PROP Target_Dir "" | ||
| 48 | CPP=cl.exe | ||
| 49 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c | ||
| 50 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /FD /c | ||
| 51 | # SUBTRACT CPP /YX | ||
| 52 | MTL=midl.exe | ||
| 53 | # ADD BASE MTL /nologo /D "NDEBUG" /win32 | ||
| 54 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | ||
| 55 | RSC=rc.exe | ||
| 56 | # ADD BASE RSC /l 0x40c /d "NDEBUG" | ||
| 57 | # ADD RSC /l 0x40c /d "NDEBUG" | ||
| 58 | BSC32=bscmake.exe | ||
| 59 | # ADD BASE BSC32 /nologo | ||
| 60 | # ADD BSC32 /nologo | ||
| 61 | LINK32=link.exe | ||
| 62 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 | ||
| 63 | # ADD LINK32 gvmat32.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\Release\zlib.dll" | ||
| 64 | # SUBTRACT LINK32 /pdb:none | ||
| 65 | |||
| 66 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 67 | |||
| 68 | # PROP BASE Use_MFC 0 | ||
| 69 | # PROP BASE Use_Debug_Libraries 1 | ||
| 70 | # PROP BASE Output_Dir ".\Debug" | ||
| 71 | # PROP BASE Intermediate_Dir ".\Debug" | ||
| 72 | # PROP BASE Target_Dir "" | ||
| 73 | # PROP Use_MFC 0 | ||
| 74 | # PROP Use_Debug_Libraries 1 | ||
| 75 | # PROP Output_Dir ".\Debug" | ||
| 76 | # PROP Intermediate_Dir ".\Debug" | ||
| 77 | # PROP Target_Dir "" | ||
| 78 | CPP=cl.exe | ||
| 79 | # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c | ||
| 80 | # ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /FD /c | ||
| 81 | # SUBTRACT CPP /YX | ||
| 82 | MTL=midl.exe | ||
| 83 | # ADD BASE MTL /nologo /D "_DEBUG" /win32 | ||
| 84 | # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 | ||
| 85 | RSC=rc.exe | ||
| 86 | # ADD BASE RSC /l 0x40c /d "_DEBUG" | ||
| 87 | # ADD RSC /l 0x40c /d "_DEBUG" | ||
| 88 | BSC32=bscmake.exe | ||
| 89 | # ADD BASE BSC32 /nologo | ||
| 90 | # ADD BSC32 /nologo | ||
| 91 | LINK32=link.exe | ||
| 92 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 | ||
| 93 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:".\Debug\zlib.dll" | ||
| 94 | |||
| 95 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 96 | |||
| 97 | # PROP BASE Use_MFC 0 | ||
| 98 | # PROP BASE Use_Debug_Libraries 0 | ||
| 99 | # PROP BASE Output_Dir "zlibvc__" | ||
| 100 | # PROP BASE Intermediate_Dir "zlibvc__" | ||
| 101 | # PROP BASE Ignore_Export_Lib 0 | ||
| 102 | # PROP BASE Target_Dir "" | ||
| 103 | # PROP Use_MFC 0 | ||
| 104 | # PROP Use_Debug_Libraries 0 | ||
| 105 | # PROP Output_Dir "zlibvc__" | ||
| 106 | # PROP Intermediate_Dir "zlibvc__" | ||
| 107 | # PROP Ignore_Export_Lib 0 | ||
| 108 | # PROP Target_Dir "" | ||
| 109 | MTL=midl.exe | ||
| 110 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | ||
| 111 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | ||
| 112 | CPP=cl.exe | ||
| 113 | # ADD BASE CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c | ||
| 114 | # ADD CPP /nologo /MT /Gt0 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /FD /c | ||
| 115 | # SUBTRACT CPP /YX | ||
| 116 | RSC=rc.exe | ||
| 117 | # ADD BASE RSC /l 0x40c /d "NDEBUG" | ||
| 118 | # ADD RSC /l 0x40c /d "NDEBUG" | ||
| 119 | BSC32=bscmake.exe | ||
| 120 | # ADD BASE BSC32 /nologo | ||
| 121 | # ADD BSC32 /nologo | ||
| 122 | LINK32=link.exe | ||
| 123 | # ADD BASE LINK32 crtdll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /map /machine:ALPHA /nodefaultlib /out:".\Release\zlib.dll" | ||
| 124 | # SUBTRACT BASE LINK32 /pdb:none | ||
| 125 | # ADD LINK32 crtdll.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /dll /map /machine:ALPHA /nodefaultlib /out:"zlibvc__\zlib.dll" | ||
| 126 | # SUBTRACT LINK32 /pdb:none | ||
| 127 | |||
| 128 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 129 | |||
| 130 | # PROP BASE Use_MFC 0 | ||
| 131 | # PROP BASE Use_Debug_Libraries 0 | ||
| 132 | # PROP BASE Output_Dir "zlibvc_0" | ||
| 133 | # PROP BASE Intermediate_Dir "zlibvc_0" | ||
| 134 | # PROP BASE Ignore_Export_Lib 0 | ||
| 135 | # PROP BASE Target_Dir "" | ||
| 136 | # PROP Use_MFC 0 | ||
| 137 | # PROP Use_Debug_Libraries 0 | ||
| 138 | # PROP Output_Dir "zlibvc_0" | ||
| 139 | # PROP Intermediate_Dir "zlibvc_0" | ||
| 140 | # PROP Ignore_Export_Lib 0 | ||
| 141 | # PROP Target_Dir "" | ||
| 142 | CPP=cl.exe | ||
| 143 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /YX /FD /c | ||
| 144 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /FAcs /FR /FD /c | ||
| 145 | # SUBTRACT CPP /YX | ||
| 146 | MTL=midl.exe | ||
| 147 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | ||
| 148 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | ||
| 149 | RSC=rc.exe | ||
| 150 | # ADD BASE RSC /l 0x40c /d "NDEBUG" | ||
| 151 | # ADD RSC /l 0x40c /d "NDEBUG" | ||
| 152 | BSC32=bscmake.exe | ||
| 153 | # ADD BASE BSC32 /nologo | ||
| 154 | # ADD BSC32 /nologo | ||
| 155 | LINK32=link.exe | ||
| 156 | # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\Release\zlib.dll" | ||
| 157 | # SUBTRACT BASE LINK32 /pdb:none | ||
| 158 | # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\zlibvc_0\zlib.dll" | ||
| 159 | # SUBTRACT LINK32 /pdb:none | ||
| 160 | |||
| 161 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 162 | |||
| 163 | # PROP BASE Use_MFC 0 | ||
| 164 | # PROP BASE Use_Debug_Libraries 0 | ||
| 165 | # PROP BASE Output_Dir "zlibvc_1" | ||
| 166 | # PROP BASE Intermediate_Dir "zlibvc_1" | ||
| 167 | # PROP BASE Ignore_Export_Lib 0 | ||
| 168 | # PROP BASE Target_Dir "" | ||
| 169 | # PROP Use_MFC 0 | ||
| 170 | # PROP Use_Debug_Libraries 0 | ||
| 171 | # PROP Output_Dir "zlibvc_1" | ||
| 172 | # PROP Intermediate_Dir "zlibvc_1" | ||
| 173 | # PROP Ignore_Export_Lib 0 | ||
| 174 | # PROP Target_Dir "" | ||
| 175 | CPP=cl.exe | ||
| 176 | # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /YX /FD /c | ||
| 177 | # ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_WINDLL" /D "_WIN32" /D "BUILD_ZLIBDLL" /D "ZLIB_DLL" /D "DYNAMIC_CRC_TABLE" /D "ASMV" /FAcs /FR /FD /c | ||
| 178 | # SUBTRACT CPP /YX | ||
| 179 | MTL=midl.exe | ||
| 180 | # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | ||
| 181 | # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 | ||
| 182 | RSC=rc.exe | ||
| 183 | # ADD BASE RSC /l 0x40c /d "NDEBUG" | ||
| 184 | # ADD RSC /l 0x40c /d "NDEBUG" | ||
| 185 | BSC32=bscmake.exe | ||
| 186 | # ADD BASE BSC32 /nologo | ||
| 187 | # ADD BSC32 /nologo | ||
| 188 | LINK32=link.exe | ||
| 189 | # ADD BASE LINK32 gvmat32.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\Release\zlib.dll" | ||
| 190 | # SUBTRACT BASE LINK32 /pdb:none | ||
| 191 | # ADD LINK32 gvmat32.obj kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib crtdll.lib /nologo /subsystem:windows /dll /map /machine:I386 /nodefaultlib /out:".\zlibvc_1\zlib.dll" | ||
| 192 | # SUBTRACT LINK32 /pdb:none | ||
| 193 | |||
| 194 | !ENDIF | ||
| 195 | |||
| 196 | # Begin Target | ||
| 197 | |||
| 198 | # Name "zlibvc - Win32 Release" | ||
| 199 | # Name "zlibvc - Win32 Debug" | ||
| 200 | # Name "zlibvc - Win32 ReleaseAxp" | ||
| 201 | # Name "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 202 | # Name "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 203 | # Begin Group "Source Files" | ||
| 204 | |||
| 205 | # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90" | ||
| 206 | # Begin Source File | ||
| 207 | |||
| 208 | SOURCE=.\adler32.c | ||
| 209 | |||
| 210 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 211 | |||
| 212 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 213 | |||
| 214 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 215 | |||
| 216 | DEP_CPP_ADLER=\ | ||
| 217 | ".\zconf.h"\ | ||
| 218 | ".\zlib.h"\ | ||
| 219 | |||
| 220 | |||
| 221 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 222 | |||
| 223 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 224 | |||
| 225 | !ENDIF | ||
| 226 | |||
| 227 | # End Source File | ||
| 228 | # Begin Source File | ||
| 229 | |||
| 230 | SOURCE=.\compress.c | ||
| 231 | |||
| 232 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 233 | |||
| 234 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 235 | |||
| 236 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 237 | |||
| 238 | DEP_CPP_COMPR=\ | ||
| 239 | ".\zconf.h"\ | ||
| 240 | ".\zlib.h"\ | ||
| 241 | |||
| 242 | |||
| 243 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 244 | |||
| 245 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 246 | |||
| 247 | !ENDIF | ||
| 248 | |||
| 249 | # End Source File | ||
| 250 | # Begin Source File | ||
| 251 | |||
| 252 | SOURCE=.\crc32.c | ||
| 253 | |||
| 254 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 255 | |||
| 256 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 257 | |||
| 258 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 259 | |||
| 260 | DEP_CPP_CRC32=\ | ||
| 261 | ".\zconf.h"\ | ||
| 262 | ".\zlib.h"\ | ||
| 263 | |||
| 264 | |||
| 265 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 266 | |||
| 267 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 268 | |||
| 269 | !ENDIF | ||
| 270 | |||
| 271 | # End Source File | ||
| 272 | # Begin Source File | ||
| 273 | |||
| 274 | SOURCE=.\deflate.c | ||
| 275 | |||
| 276 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 277 | |||
| 278 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 279 | |||
| 280 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 281 | |||
| 282 | DEP_CPP_DEFLA=\ | ||
| 283 | ".\deflate.h"\ | ||
| 284 | ".\zconf.h"\ | ||
| 285 | ".\zlib.h"\ | ||
| 286 | ".\zutil.h"\ | ||
| 287 | |||
| 288 | |||
| 289 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 290 | |||
| 291 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 292 | |||
| 293 | !ENDIF | ||
| 294 | |||
| 295 | # End Source File | ||
| 296 | # Begin Source File | ||
| 297 | |||
| 298 | SOURCE=.\gvmat32c.c | ||
| 299 | |||
| 300 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 301 | |||
| 302 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 303 | |||
| 304 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 305 | |||
| 306 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 307 | |||
| 308 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 309 | |||
| 310 | !ENDIF | ||
| 311 | |||
| 312 | # End Source File | ||
| 313 | # Begin Source File | ||
| 314 | |||
| 315 | SOURCE=.\gzio.c | ||
| 316 | |||
| 317 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 318 | |||
| 319 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 320 | |||
| 321 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 322 | |||
| 323 | DEP_CPP_GZIO_=\ | ||
| 324 | ".\zconf.h"\ | ||
| 325 | ".\zlib.h"\ | ||
| 326 | ".\zutil.h"\ | ||
| 327 | |||
| 328 | |||
| 329 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 330 | |||
| 331 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 332 | |||
| 333 | !ENDIF | ||
| 334 | |||
| 335 | # End Source File | ||
| 336 | # Begin Source File | ||
| 337 | |||
| 338 | SOURCE=.\infblock.c | ||
| 339 | |||
| 340 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 341 | |||
| 342 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 343 | |||
| 344 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 345 | |||
| 346 | DEP_CPP_INFBL=\ | ||
| 347 | ".\infblock.h"\ | ||
| 348 | ".\infcodes.h"\ | ||
| 349 | ".\inftrees.h"\ | ||
| 350 | ".\infutil.h"\ | ||
| 351 | ".\zconf.h"\ | ||
| 352 | ".\zlib.h"\ | ||
| 353 | ".\zutil.h"\ | ||
| 354 | |||
| 355 | |||
| 356 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 357 | |||
| 358 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 359 | |||
| 360 | !ENDIF | ||
| 361 | |||
| 362 | # End Source File | ||
| 363 | # Begin Source File | ||
| 364 | |||
| 365 | SOURCE=.\infcodes.c | ||
| 366 | |||
| 367 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 368 | |||
| 369 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 370 | |||
| 371 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 372 | |||
| 373 | DEP_CPP_INFCO=\ | ||
| 374 | ".\infblock.h"\ | ||
| 375 | ".\infcodes.h"\ | ||
| 376 | ".\inffast.h"\ | ||
| 377 | ".\inftrees.h"\ | ||
| 378 | ".\infutil.h"\ | ||
| 379 | ".\zconf.h"\ | ||
| 380 | ".\zlib.h"\ | ||
| 381 | ".\zutil.h"\ | ||
| 382 | |||
| 383 | |||
| 384 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 385 | |||
| 386 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 387 | |||
| 388 | !ENDIF | ||
| 389 | |||
| 390 | # End Source File | ||
| 391 | # Begin Source File | ||
| 392 | |||
| 393 | SOURCE=.\inffast.c | ||
| 394 | |||
| 395 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 396 | |||
| 397 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 398 | |||
| 399 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 400 | |||
| 401 | DEP_CPP_INFFA=\ | ||
| 402 | ".\infblock.h"\ | ||
| 403 | ".\infcodes.h"\ | ||
| 404 | ".\inffast.h"\ | ||
| 405 | ".\inftrees.h"\ | ||
| 406 | ".\infutil.h"\ | ||
| 407 | ".\zconf.h"\ | ||
| 408 | ".\zlib.h"\ | ||
| 409 | ".\zutil.h"\ | ||
| 410 | |||
| 411 | |||
| 412 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 413 | |||
| 414 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 415 | |||
| 416 | !ENDIF | ||
| 417 | |||
| 418 | # End Source File | ||
| 419 | # Begin Source File | ||
| 420 | |||
| 421 | SOURCE=.\inflate.c | ||
| 422 | |||
| 423 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 424 | |||
| 425 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 426 | |||
| 427 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 428 | |||
| 429 | DEP_CPP_INFLA=\ | ||
| 430 | ".\infblock.h"\ | ||
| 431 | ".\zconf.h"\ | ||
| 432 | ".\zlib.h"\ | ||
| 433 | ".\zutil.h"\ | ||
| 434 | |||
| 435 | |||
| 436 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 437 | |||
| 438 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 439 | |||
| 440 | !ENDIF | ||
| 441 | |||
| 442 | # End Source File | ||
| 443 | # Begin Source File | ||
| 444 | |||
| 445 | SOURCE=.\inftrees.c | ||
| 446 | |||
| 447 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 448 | |||
| 449 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 450 | |||
| 451 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 452 | |||
| 453 | DEP_CPP_INFTR=\ | ||
| 454 | ".\inftrees.h"\ | ||
| 455 | ".\zconf.h"\ | ||
| 456 | ".\zlib.h"\ | ||
| 457 | ".\zutil.h"\ | ||
| 458 | |||
| 459 | |||
| 460 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 461 | |||
| 462 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 463 | |||
| 464 | !ENDIF | ||
| 465 | |||
| 466 | # End Source File | ||
| 467 | # Begin Source File | ||
| 468 | |||
| 469 | SOURCE=.\infutil.c | ||
| 470 | |||
| 471 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 472 | |||
| 473 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 474 | |||
| 475 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 476 | |||
| 477 | DEP_CPP_INFUT=\ | ||
| 478 | ".\infblock.h"\ | ||
| 479 | ".\infcodes.h"\ | ||
| 480 | ".\inftrees.h"\ | ||
| 481 | ".\infutil.h"\ | ||
| 482 | ".\zconf.h"\ | ||
| 483 | ".\zlib.h"\ | ||
| 484 | ".\zutil.h"\ | ||
| 485 | |||
| 486 | |||
| 487 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 488 | |||
| 489 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 490 | |||
| 491 | !ENDIF | ||
| 492 | |||
| 493 | # End Source File | ||
| 494 | # Begin Source File | ||
| 495 | |||
| 496 | SOURCE=.\trees.c | ||
| 497 | |||
| 498 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 499 | |||
| 500 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 501 | |||
| 502 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 503 | |||
| 504 | DEP_CPP_TREES=\ | ||
| 505 | ".\deflate.h"\ | ||
| 506 | ".\zconf.h"\ | ||
| 507 | ".\zlib.h"\ | ||
| 508 | ".\zutil.h"\ | ||
| 509 | |||
| 510 | |||
| 511 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 512 | |||
| 513 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 514 | |||
| 515 | !ENDIF | ||
| 516 | |||
| 517 | # End Source File | ||
| 518 | # Begin Source File | ||
| 519 | |||
| 520 | SOURCE=.\uncompr.c | ||
| 521 | |||
| 522 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 523 | |||
| 524 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 525 | |||
| 526 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 527 | |||
| 528 | DEP_CPP_UNCOM=\ | ||
| 529 | ".\zconf.h"\ | ||
| 530 | ".\zlib.h"\ | ||
| 531 | |||
| 532 | |||
| 533 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 534 | |||
| 535 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 536 | |||
| 537 | !ENDIF | ||
| 538 | |||
| 539 | # End Source File | ||
| 540 | # Begin Source File | ||
| 541 | |||
| 542 | SOURCE=.\unzip.c | ||
| 543 | |||
| 544 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 545 | |||
| 546 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 547 | |||
| 548 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 549 | |||
| 550 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 551 | |||
| 552 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 553 | |||
| 554 | !ENDIF | ||
| 555 | |||
| 556 | # End Source File | ||
| 557 | # Begin Source File | ||
| 558 | |||
| 559 | SOURCE=.\zip.c | ||
| 560 | |||
| 561 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 562 | |||
| 563 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 564 | |||
| 565 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 566 | |||
| 567 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 568 | |||
| 569 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 570 | |||
| 571 | !ENDIF | ||
| 572 | |||
| 573 | # End Source File | ||
| 574 | # Begin Source File | ||
| 575 | |||
| 576 | SOURCE=.\zlib.rc | ||
| 577 | # End Source File | ||
| 578 | # Begin Source File | ||
| 579 | |||
| 580 | SOURCE=.\zlibvc.def | ||
| 581 | # End Source File | ||
| 582 | # Begin Source File | ||
| 583 | |||
| 584 | SOURCE=.\zutil.c | ||
| 585 | |||
| 586 | !IF "$(CFG)" == "zlibvc - Win32 Release" | ||
| 587 | |||
| 588 | !ELSEIF "$(CFG)" == "zlibvc - Win32 Debug" | ||
| 589 | |||
| 590 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseAxp" | ||
| 591 | |||
| 592 | DEP_CPP_ZUTIL=\ | ||
| 593 | ".\zconf.h"\ | ||
| 594 | ".\zlib.h"\ | ||
| 595 | ".\zutil.h"\ | ||
| 596 | |||
| 597 | |||
| 598 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutAsm" | ||
| 599 | |||
| 600 | !ELSEIF "$(CFG)" == "zlibvc - Win32 ReleaseWithoutCrtdll" | ||
| 601 | |||
| 602 | !ENDIF | ||
| 603 | |||
| 604 | # End Source File | ||
| 605 | # End Group | ||
| 606 | # Begin Group "Header Files" | ||
| 607 | |||
| 608 | # PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd" | ||
| 609 | # Begin Source File | ||
| 610 | |||
| 611 | SOURCE=.\deflate.h | ||
| 612 | # End Source File | ||
| 613 | # Begin Source File | ||
| 614 | |||
| 615 | SOURCE=.\infblock.h | ||
| 616 | # End Source File | ||
| 617 | # Begin Source File | ||
| 618 | |||
| 619 | SOURCE=.\infcodes.h | ||
| 620 | # End Source File | ||
| 621 | # Begin Source File | ||
| 622 | |||
| 623 | SOURCE=.\inffast.h | ||
| 624 | # End Source File | ||
| 625 | # Begin Source File | ||
| 626 | |||
| 627 | SOURCE=.\inftrees.h | ||
| 628 | # End Source File | ||
| 629 | # Begin Source File | ||
| 630 | |||
| 631 | SOURCE=.\infutil.h | ||
| 632 | # End Source File | ||
| 633 | # Begin Source File | ||
| 634 | |||
| 635 | SOURCE=.\zconf.h | ||
| 636 | # End Source File | ||
| 637 | # Begin Source File | ||
| 638 | |||
| 639 | SOURCE=.\zlib.h | ||
| 640 | # End Source File | ||
| 641 | # Begin Source File | ||
| 642 | |||
| 643 | SOURCE=.\zutil.h | ||
| 644 | # End Source File | ||
| 645 | # End Group | ||
| 646 | # Begin Group "Resource Files" | ||
| 647 | |||
| 648 | # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe" | ||
| 649 | # End Group | ||
| 650 | # End Target | ||
| 651 | # End Project | ||
diff --git a/contrib/minizip/zlibvc.dsw b/contrib/minizip/zlibvc.dsw new file mode 100644 index 0000000..493cd87 --- /dev/null +++ b/contrib/minizip/zlibvc.dsw | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | Microsoft Developer Studio Workspace File, Format Version 5.00 | ||
| 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! | ||
| 3 | |||
| 4 | ############################################################################### | ||
| 5 | |||
| 6 | Project: "zlibstat"=.\zlibstat.dsp - Package Owner=<4> | ||
| 7 | |||
| 8 | Package=<5> | ||
| 9 | {{{ | ||
| 10 | }}} | ||
| 11 | |||
| 12 | Package=<4> | ||
| 13 | {{{ | ||
| 14 | }}} | ||
| 15 | |||
| 16 | ############################################################################### | ||
| 17 | |||
| 18 | Project: "zlibvc"=.\zlibvc.dsp - Package Owner=<4> | ||
| 19 | |||
| 20 | Package=<5> | ||
| 21 | {{{ | ||
| 22 | }}} | ||
| 23 | |||
| 24 | Package=<4> | ||
| 25 | {{{ | ||
| 26 | }}} | ||
| 27 | |||
| 28 | ############################################################################### | ||
| 29 | |||
| 30 | Global: | ||
| 31 | |||
| 32 | Package=<5> | ||
| 33 | {{{ | ||
| 34 | }}} | ||
| 35 | |||
| 36 | Package=<3> | ||
| 37 | {{{ | ||
| 38 | }}} | ||
| 39 | |||
| 40 | ############################################################################### | ||
| 41 | |||
| @@ -52,7 +52,7 @@ | |||
| 52 | #include "deflate.h" | 52 | #include "deflate.h" |
| 53 | 53 | ||
| 54 | const char deflate_copyright[] = | 54 | const char deflate_copyright[] = |
| 55 | " deflate 1.1.1 Copyright 1995-1998 Jean-loup Gailly "; | 55 | " deflate 1.1.2 Copyright 1995-1998 Jean-loup Gailly "; |
| 56 | /* | 56 | /* |
| 57 | If you use the zlib library in a product, an acknowledgment is welcome | 57 | If you use the zlib library in a product, an acknowledgment is welcome |
| 58 | in the documentation of your product. If for some reason you cannot | 58 | in the documentation of your product. If for some reason you cannot |
| @@ -71,7 +71,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen) | |||
| 71 | fprintf(stderr, "bad uncompress\n"); | 71 | fprintf(stderr, "bad uncompress\n"); |
| 72 | exit(1); | 72 | exit(1); |
| 73 | } else { | 73 | } else { |
| 74 | printf("uncompress(): %s\n", uncompr); | 74 | printf("uncompress(): %s\n", (char *)uncompr); |
| 75 | } | 75 | } |
| 76 | } | 76 | } |
| 77 | 77 | ||
| @@ -121,13 +121,13 @@ void test_gzio(out, in, uncompr, uncomprLen) | |||
| 121 | fprintf(stderr, "bad gzread: %s\n", (char*)uncompr); | 121 | fprintf(stderr, "bad gzread: %s\n", (char*)uncompr); |
| 122 | exit(1); | 122 | exit(1); |
| 123 | } else { | 123 | } else { |
| 124 | printf("gzread(): %s\n", uncompr); | 124 | printf("gzread(): %s\n", (char *)uncompr); |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | pos = gzseek(file, -8L, SEEK_CUR); | 127 | pos = gzseek(file, -8L, SEEK_CUR); |
| 128 | if (pos != 6 || gztell(file) != pos) { | 128 | if (pos != 6 || gztell(file) != pos) { |
| 129 | fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", | 129 | fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", |
| 130 | pos, gztell(file)); | 130 | (long)pos, (long)gztell(file)); |
| 131 | exit(1); | 131 | exit(1); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| @@ -146,7 +146,7 @@ void test_gzio(out, in, uncompr, uncomprLen) | |||
| 146 | fprintf(stderr, "bad gzgets after gzseek\n"); | 146 | fprintf(stderr, "bad gzgets after gzseek\n"); |
| 147 | exit(1); | 147 | exit(1); |
| 148 | } else { | 148 | } else { |
| 149 | printf("gzgets() after gzseek: %s\n", uncompr); | 149 | printf("gzgets() after gzseek: %s\n", (char *)uncompr); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | gzclose(file); | 152 | gzclose(file); |
| @@ -227,7 +227,7 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen) | |||
| 227 | fprintf(stderr, "bad inflate\n"); | 227 | fprintf(stderr, "bad inflate\n"); |
| 228 | exit(1); | 228 | exit(1); |
| 229 | } else { | 229 | } else { |
| 230 | printf("inflate(): %s\n", uncompr); | 230 | printf("inflate(): %s\n", (char *)uncompr); |
| 231 | } | 231 | } |
| 232 | } | 232 | } |
| 233 | 233 | ||
| @@ -406,7 +406,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen) | |||
| 406 | err = inflateEnd(&d_stream); | 406 | err = inflateEnd(&d_stream); |
| 407 | CHECK_ERR(err, "inflateEnd"); | 407 | CHECK_ERR(err, "inflateEnd"); |
| 408 | 408 | ||
| 409 | printf("after inflateSync(): hel%s\n", uncompr); | 409 | printf("after inflateSync(): hel%s\n", (char *)uncompr); |
| 410 | } | 410 | } |
| 411 | 411 | ||
| 412 | /* =========================================================================== | 412 | /* =========================================================================== |
| @@ -492,7 +492,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) | |||
| 492 | fprintf(stderr, "bad inflate with dict\n"); | 492 | fprintf(stderr, "bad inflate with dict\n"); |
| 493 | exit(1); | 493 | exit(1); |
| 494 | } else { | 494 | } else { |
| 495 | printf("inflate with dictionary: %s\n", uncompr); | 495 | printf("inflate with dictionary: %s\n", (char *)uncompr); |
| 496 | } | 496 | } |
| 497 | } | 497 | } |
| 498 | 498 | ||
| @@ -13,8 +13,16 @@ | |||
| 13 | 13 | ||
| 14 | struct internal_state {int dummy;}; /* for buggy compilers */ | 14 | struct internal_state {int dummy;}; /* for buggy compilers */ |
| 15 | 15 | ||
| 16 | #define Z_BUFSIZE 16384 | 16 | #ifndef Z_BUFSIZE |
| 17 | #define Z_PRINTF_BUFSIZE 4096 | 17 | # ifdef MAXSEG_64K |
| 18 | # define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ | ||
| 19 | # else | ||
| 20 | # define Z_BUFSIZE 16384 | ||
| 21 | # endif | ||
| 22 | #endif | ||
| 23 | #ifndef Z_PRINTF_BUFSIZE | ||
| 24 | # define Z_PRINTF_BUFSIZE 4096 | ||
| 25 | #endif | ||
| 18 | 26 | ||
| 19 | #define ALLOC(size) malloc(size) | 27 | #define ALLOC(size) malloc(size) |
| 20 | #define TRYFREE(p) {if (p) free(p);} | 28 | #define TRYFREE(p) {if (p) free(p);} |
| @@ -132,8 +140,12 @@ local gzFile gz_open (path, mode, fd) | |||
| 132 | s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); | 140 | s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); |
| 133 | 141 | ||
| 134 | err = inflateInit2(&(s->stream), -MAX_WBITS); | 142 | err = inflateInit2(&(s->stream), -MAX_WBITS); |
| 135 | /* windowBits is passed < 0 to tell that there is no zlib header */ | 143 | /* windowBits is passed < 0 to tell that there is no zlib header. |
| 136 | 144 | * Note that in this case inflate *requires* an extra "dummy" byte | |
| 145 | * after the compressed stream in order to complete decompression and | ||
| 146 | * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are | ||
| 147 | * present after the compressed stream. | ||
| 148 | */ | ||
| 137 | if (err != Z_OK || s->inbuf == Z_NULL) { | 149 | if (err != Z_OK || s->inbuf == Z_NULL) { |
| 138 | return destroy(s), (gzFile)Z_NULL; | 150 | return destroy(s), (gzFile)Z_NULL; |
| 139 | } | 151 | } |
| @@ -379,6 +391,7 @@ int ZEXPORT gzread (file, buf, len) | |||
| 379 | len -= s->stream.avail_out; | 391 | len -= s->stream.avail_out; |
| 380 | s->stream.total_in += (uLong)len; | 392 | s->stream.total_in += (uLong)len; |
| 381 | s->stream.total_out += (uLong)len; | 393 | s->stream.total_out += (uLong)len; |
| 394 | if (len == 0) s->z_eof = 1; | ||
| 382 | return (int)len; | 395 | return (int)len; |
| 383 | } | 396 | } |
| 384 | if (s->stream.avail_in == 0 && !s->z_eof) { | 397 | if (s->stream.avail_in == 0 && !s->z_eof) { |
| @@ -572,7 +585,7 @@ int ZEXPORT gzputs(file, s) | |||
| 572 | gzFile file; | 585 | gzFile file; |
| 573 | const char *s; | 586 | const char *s; |
| 574 | { | 587 | { |
| 575 | return gzwrite(file, (const voidp)s, (unsigned)strlen(s)); | 588 | return gzwrite(file, (char*)s, (unsigned)strlen(s)); |
| 576 | } | 589 | } |
| 577 | 590 | ||
| 578 | 591 | ||
| @@ -11,6 +11,10 @@ | |||
| 11 | 11 | ||
| 12 | struct inflate_codes_state {int dummy;}; /* for buggy compilers */ | 12 | struct inflate_codes_state {int dummy;}; /* for buggy compilers */ |
| 13 | 13 | ||
| 14 | /* simplify the use of the inflate_huft type with some defines */ | ||
| 15 | #define exop word.what.Exop | ||
| 16 | #define bits word.what.Bits | ||
| 17 | |||
| 14 | /* Table for deflate from PKZIP's appnote.txt. */ | 18 | /* Table for deflate from PKZIP's appnote.txt. */ |
| 15 | local const uInt border[] = { /* Order of the bit length code lengths */ | 19 | local const uInt border[] = { /* Order of the bit length code lengths */ |
| 16 | 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; | 20 | 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; |
| @@ -264,8 +268,8 @@ int r; | |||
| 264 | t = s->sub.trees.bb; | 268 | t = s->sub.trees.bb; |
| 265 | NEEDBITS(t) | 269 | NEEDBITS(t) |
| 266 | h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]); | 270 | h = s->sub.trees.tb + ((uInt)b & inflate_mask[t]); |
| 267 | t = h->word.what.Bits; | 271 | t = h->bits; |
| 268 | c = h->more.Base; | 272 | c = h->base; |
| 269 | if (c < 16) | 273 | if (c < 16) |
| 270 | { | 274 | { |
| 271 | DUMPBITS(t) | 275 | DUMPBITS(t) |
| @@ -11,8 +11,6 @@ | |||
| 11 | #include "inffast.h" | 11 | #include "inffast.h" |
| 12 | 12 | ||
| 13 | /* simplify the use of the inflate_huft type with some defines */ | 13 | /* simplify the use of the inflate_huft type with some defines */ |
| 14 | #define base more.Base | ||
| 15 | #define next more.Next | ||
| 16 | #define exop word.what.Exop | 14 | #define exop word.what.Exop |
| 17 | #define bits word.what.Bits | 15 | #define bits word.what.Bits |
| 18 | 16 | ||
| @@ -145,7 +143,7 @@ int r; | |||
| 145 | if ((e & 64) == 0) /* next table */ | 143 | if ((e & 64) == 0) /* next table */ |
| 146 | { | 144 | { |
| 147 | c->sub.code.need = e; | 145 | c->sub.code.need = e; |
| 148 | c->sub.code.tree = t->next; | 146 | c->sub.code.tree = t + t->base; |
| 149 | break; | 147 | break; |
| 150 | } | 148 | } |
| 151 | if (e & 32) /* end of block */ | 149 | if (e & 32) /* end of block */ |
| @@ -183,7 +181,7 @@ int r; | |||
| 183 | if ((e & 64) == 0) /* next table */ | 181 | if ((e & 64) == 0) /* next table */ |
| 184 | { | 182 | { |
| 185 | c->sub.code.need = e; | 183 | c->sub.code.need = e; |
| 186 | c->sub.code.tree = t->next; | 184 | c->sub.code.tree = t + t->base; |
| 187 | break; | 185 | break; |
| 188 | } | 186 | } |
| 189 | c->mode = BADCODE; /* invalid code */ | 187 | c->mode = BADCODE; /* invalid code */ |
| @@ -13,14 +13,12 @@ | |||
| 13 | struct inflate_codes_state {int dummy;}; /* for buggy compilers */ | 13 | struct inflate_codes_state {int dummy;}; /* for buggy compilers */ |
| 14 | 14 | ||
| 15 | /* simplify the use of the inflate_huft type with some defines */ | 15 | /* simplify the use of the inflate_huft type with some defines */ |
| 16 | #define base more.Base | ||
| 17 | #define next more.Next | ||
| 18 | #define exop word.what.Exop | 16 | #define exop word.what.Exop |
| 19 | #define bits word.what.Bits | 17 | #define bits word.what.Bits |
| 20 | 18 | ||
| 21 | /* macros for bit input with no checking and for returning unused bytes */ | 19 | /* macros for bit input with no checking and for returning unused bytes */ |
| 22 | #define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}} | 20 | #define GRABBITS(j) {while(k<(j)){b|=((uLong)NEXTBYTE)<<k;k+=8;}} |
| 23 | #define UNGRAB {n+=(c=k>>3);p-=c;k&=7;} | 21 | #define UNGRAB {c=z->avail_in-n;c=(k>>3)<c?k>>3:c;n+=c;p-=c;k-=c<<3;} |
| 24 | 22 | ||
| 25 | /* Called with number of bytes left to write in window at least 258 | 23 | /* Called with number of bytes left to write in window at least 258 |
| 26 | (the maximum string length) and number of input bytes available | 24 | (the maximum string length) and number of input bytes available |
| @@ -120,7 +118,10 @@ z_streamp z; | |||
| 120 | break; | 118 | break; |
| 121 | } | 119 | } |
| 122 | else if ((e & 64) == 0) | 120 | else if ((e & 64) == 0) |
| 123 | e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop; | 121 | { |
| 122 | t += t->base; | ||
| 123 | e = (t += ((uInt)b & inflate_mask[e]))->exop; | ||
| 124 | } | ||
| 124 | else | 125 | else |
| 125 | { | 126 | { |
| 126 | z->msg = (char*)"invalid distance code"; | 127 | z->msg = (char*)"invalid distance code"; |
| @@ -133,7 +134,8 @@ z_streamp z; | |||
| 133 | } | 134 | } |
| 134 | if ((e & 64) == 0) | 135 | if ((e & 64) == 0) |
| 135 | { | 136 | { |
| 136 | if ((e = (t = t->next + ((uInt)b & inflate_mask[e]))->exop) == 0) | 137 | t += t->base; |
| 138 | if ((e = (t += ((uInt)b & inflate_mask[e]))->exop) == 0) | ||
| 137 | { | 139 | { |
| 138 | DUMPBITS(t->bits) | 140 | DUMPBITS(t->bits) |
| 139 | Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? | 141 | Tracevv((stderr, t->base >= 0x20 && t->base < 0x7f ? |
diff --git a/inffixed.h b/inffixed.h new file mode 100644 index 0000000..644ef6c --- /dev/null +++ b/inffixed.h | |||
| @@ -0,0 +1,125 @@ | |||
| 1 | /* inffixed.h -- table for decoding fixed codes | ||
| 2 | * Generated automatically by the maketree.c program | ||
| 3 | */ | ||
| 4 | |||
| 5 | /* WARNING: this file should *not* be used by applications. It is | ||
| 6 | part of the implementation of the compression library and is | ||
| 7 | subject to change. Applications should only use zlib.h. | ||
| 8 | */ | ||
| 9 | |||
| 10 | local uInt fixed_bl = 9; | ||
| 11 | local uInt fixed_bd = 5; | ||
| 12 | local inflate_huft fixed_tl[] = { | ||
| 13 | {{96,7},256}, {{0,8},80}, {{0,8},16}, {{84,8},115}, {{82,7},31}, | ||
| 14 | {{0,8},112}, {{0,8},48}, {{0,9},192}, {{80,7},10}, {{0,8},96}, | ||
| 15 | {{0,8},32}, {{0,9},160}, {{0,8},0}, {{0,8},128}, {{0,8},64}, | ||
| 16 | {{0,9},224}, {{80,7},6}, {{0,8},88}, {{0,8},24}, {{0,9},144}, | ||
| 17 | {{83,7},59}, {{0,8},120}, {{0,8},56}, {{0,9},208}, {{81,7},17}, | ||
| 18 | {{0,8},104}, {{0,8},40}, {{0,9},176}, {{0,8},8}, {{0,8},136}, | ||
| 19 | {{0,8},72}, {{0,9},240}, {{80,7},4}, {{0,8},84}, {{0,8},20}, | ||
| 20 | {{85,8},227}, {{83,7},43}, {{0,8},116}, {{0,8},52}, {{0,9},200}, | ||
| 21 | {{81,7},13}, {{0,8},100}, {{0,8},36}, {{0,9},168}, {{0,8},4}, | ||
| 22 | {{0,8},132}, {{0,8},68}, {{0,9},232}, {{80,7},8}, {{0,8},92}, | ||
| 23 | {{0,8},28}, {{0,9},152}, {{84,7},83}, {{0,8},124}, {{0,8},60}, | ||
| 24 | {{0,9},216}, {{82,7},23}, {{0,8},108}, {{0,8},44}, {{0,9},184}, | ||
| 25 | {{0,8},12}, {{0,8},140}, {{0,8},76}, {{0,9},248}, {{80,7},3}, | ||
| 26 | {{0,8},82}, {{0,8},18}, {{85,8},163}, {{83,7},35}, {{0,8},114}, | ||
| 27 | {{0,8},50}, {{0,9},196}, {{81,7},11}, {{0,8},98}, {{0,8},34}, | ||
| 28 | {{0,9},164}, {{0,8},2}, {{0,8},130}, {{0,8},66}, {{0,9},228}, | ||
| 29 | {{80,7},7}, {{0,8},90}, {{0,8},26}, {{0,9},148}, {{84,7},67}, | ||
| 30 | {{0,8},122}, {{0,8},58}, {{0,9},212}, {{82,7},19}, {{0,8},106}, | ||
| 31 | {{0,8},42}, {{0,9},180}, {{0,8},10}, {{0,8},138}, {{0,8},74}, | ||
| 32 | {{0,9},244}, {{80,7},5}, {{0,8},86}, {{0,8},22}, {{192,8},0}, | ||
| 33 | {{83,7},51}, {{0,8},118}, {{0,8},54}, {{0,9},204}, {{81,7},15}, | ||
| 34 | {{0,8},102}, {{0,8},38}, {{0,9},172}, {{0,8},6}, {{0,8},134}, | ||
| 35 | {{0,8},70}, {{0,9},236}, {{80,7},9}, {{0,8},94}, {{0,8},30}, | ||
| 36 | {{0,9},156}, {{84,7},99}, {{0,8},126}, {{0,8},62}, {{0,9},220}, | ||
| 37 | {{82,7},27}, {{0,8},110}, {{0,8},46}, {{0,9},188}, {{0,8},14}, | ||
| 38 | {{0,8},142}, {{0,8},78}, {{0,9},252}, {{96,7},256}, {{0,8},81}, | ||
| 39 | {{0,8},17}, {{85,8},131}, {{82,7},31}, {{0,8},113}, {{0,8},49}, | ||
| 40 | {{0,9},194}, {{80,7},10}, {{0,8},97}, {{0,8},33}, {{0,9},162}, | ||
| 41 | {{0,8},1}, {{0,8},129}, {{0,8},65}, {{0,9},226}, {{80,7},6}, | ||
| 42 | {{0,8},89}, {{0,8},25}, {{0,9},146}, {{83,7},59}, {{0,8},121}, | ||
| 43 | {{0,8},57}, {{0,9},210}, {{81,7},17}, {{0,8},105}, {{0,8},41}, | ||
| 44 | {{0,9},178}, {{0,8},9}, {{0,8},137}, {{0,8},73}, {{0,9},242}, | ||
| 45 | {{80,7},4}, {{0,8},85}, {{0,8},21}, {{80,8},258}, {{83,7},43}, | ||
| 46 | {{0,8},117}, {{0,8},53}, {{0,9},202}, {{81,7},13}, {{0,8},101}, | ||
| 47 | {{0,8},37}, {{0,9},170}, {{0,8},5}, {{0,8},133}, {{0,8},69}, | ||
| 48 | {{0,9},234}, {{80,7},8}, {{0,8},93}, {{0,8},29}, {{0,9},154}, | ||
| 49 | {{84,7},83}, {{0,8},125}, {{0,8},61}, {{0,9},218}, {{82,7},23}, | ||
| 50 | {{0,8},109}, {{0,8},45}, {{0,9},186}, {{0,8},13}, {{0,8},141}, | ||
| 51 | {{0,8},77}, {{0,9},250}, {{80,7},3}, {{0,8},83}, {{0,8},19}, | ||
| 52 | {{85,8},195}, {{83,7},35}, {{0,8},115}, {{0,8},51}, {{0,9},198}, | ||
| 53 | {{81,7},11}, {{0,8},99}, {{0,8},35}, {{0,9},166}, {{0,8},3}, | ||
| 54 | {{0,8},131}, {{0,8},67}, {{0,9},230}, {{80,7},7}, {{0,8},91}, | ||
| 55 | {{0,8},27}, {{0,9},150}, {{84,7},67}, {{0,8},123}, {{0,8},59}, | ||
| 56 | {{0,9},214}, {{82,7},19}, {{0,8},107}, {{0,8},43}, {{0,9},182}, | ||
| 57 | {{0,8},11}, {{0,8},139}, {{0,8},75}, {{0,9},246}, {{80,7},5}, | ||
| 58 | {{0,8},87}, {{0,8},23}, {{192,8},0}, {{83,7},51}, {{0,8},119}, | ||
| 59 | {{0,8},55}, {{0,9},206}, {{81,7},15}, {{0,8},103}, {{0,8},39}, | ||
| 60 | {{0,9},174}, {{0,8},7}, {{0,8},135}, {{0,8},71}, {{0,9},238}, | ||
| 61 | {{80,7},9}, {{0,8},95}, {{0,8},31}, {{0,9},158}, {{84,7},99}, | ||
| 62 | {{0,8},127}, {{0,8},63}, {{0,9},222}, {{82,7},27}, {{0,8},111}, | ||
| 63 | {{0,8},47}, {{0,9},190}, {{0,8},15}, {{0,8},143}, {{0,8},79}, | ||
| 64 | {{0,9},254}, {{96,7},256}, {{0,8},80}, {{0,8},16}, {{84,8},115}, | ||
| 65 | {{82,7},31}, {{0,8},112}, {{0,8},48}, {{0,9},193}, {{80,7},10}, | ||
| 66 | {{0,8},96}, {{0,8},32}, {{0,9},161}, {{0,8},0}, {{0,8},128}, | ||
| 67 | {{0,8},64}, {{0,9},225}, {{80,7},6}, {{0,8},88}, {{0,8},24}, | ||
| 68 | {{0,9},145}, {{83,7},59}, {{0,8},120}, {{0,8},56}, {{0,9},209}, | ||
| 69 | {{81,7},17}, {{0,8},104}, {{0,8},40}, {{0,9},177}, {{0,8},8}, | ||
| 70 | {{0,8},136}, {{0,8},72}, {{0,9},241}, {{80,7},4}, {{0,8},84}, | ||
| 71 | {{0,8},20}, {{85,8},227}, {{83,7},43}, {{0,8},116}, {{0,8},52}, | ||
| 72 | {{0,9},201}, {{81,7},13}, {{0,8},100}, {{0,8},36}, {{0,9},169}, | ||
| 73 | {{0,8},4}, {{0,8},132}, {{0,8},68}, {{0,9},233}, {{80,7},8}, | ||
| 74 | {{0,8},92}, {{0,8},28}, {{0,9},153}, {{84,7},83}, {{0,8},124}, | ||
| 75 | {{0,8},60}, {{0,9},217}, {{82,7},23}, {{0,8},108}, {{0,8},44}, | ||
| 76 | {{0,9},185}, {{0,8},12}, {{0,8},140}, {{0,8},76}, {{0,9},249}, | ||
| 77 | {{80,7},3}, {{0,8},82}, {{0,8},18}, {{85,8},163}, {{83,7},35}, | ||
| 78 | {{0,8},114}, {{0,8},50}, {{0,9},197}, {{81,7},11}, {{0,8},98}, | ||
| 79 | {{0,8},34}, {{0,9},165}, {{0,8},2}, {{0,8},130}, {{0,8},66}, | ||
| 80 | {{0,9},229}, {{80,7},7}, {{0,8},90}, {{0,8},26}, {{0,9},149}, | ||
| 81 | {{84,7},67}, {{0,8},122}, {{0,8},58}, {{0,9},213}, {{82,7},19}, | ||
| 82 | {{0,8},106}, {{0,8},42}, {{0,9},181}, {{0,8},10}, {{0,8},138}, | ||
| 83 | {{0,8},74}, {{0,9},245}, {{80,7},5}, {{0,8},86}, {{0,8},22}, | ||
| 84 | {{192,8},0}, {{83,7},51}, {{0,8},118}, {{0,8},54}, {{0,9},205}, | ||
| 85 | {{81,7},15}, {{0,8},102}, {{0,8},38}, {{0,9},173}, {{0,8},6}, | ||
| 86 | {{0,8},134}, {{0,8},70}, {{0,9},237}, {{80,7},9}, {{0,8},94}, | ||
| 87 | {{0,8},30}, {{0,9},157}, {{84,7},99}, {{0,8},126}, {{0,8},62}, | ||
| 88 | {{0,9},221}, {{82,7},27}, {{0,8},110}, {{0,8},46}, {{0,9},189}, | ||
| 89 | {{0,8},14}, {{0,8},142}, {{0,8},78}, {{0,9},253}, {{96,7},256}, | ||
| 90 | {{0,8},81}, {{0,8},17}, {{85,8},131}, {{82,7},31}, {{0,8},113}, | ||
| 91 | {{0,8},49}, {{0,9},195}, {{80,7},10}, {{0,8},97}, {{0,8},33}, | ||
| 92 | {{0,9},163}, {{0,8},1}, {{0,8},129}, {{0,8},65}, {{0,9},227}, | ||
| 93 | {{80,7},6}, {{0,8},89}, {{0,8},25}, {{0,9},147}, {{83,7},59}, | ||
| 94 | {{0,8},121}, {{0,8},57}, {{0,9},211}, {{81,7},17}, {{0,8},105}, | ||
| 95 | {{0,8},41}, {{0,9},179}, {{0,8},9}, {{0,8},137}, {{0,8},73}, | ||
| 96 | {{0,9},243}, {{80,7},4}, {{0,8},85}, {{0,8},21}, {{80,8},258}, | ||
| 97 | {{83,7},43}, {{0,8},117}, {{0,8},53}, {{0,9},203}, {{81,7},13}, | ||
| 98 | {{0,8},101}, {{0,8},37}, {{0,9},171}, {{0,8},5}, {{0,8},133}, | ||
| 99 | {{0,8},69}, {{0,9},235}, {{80,7},8}, {{0,8},93}, {{0,8},29}, | ||
| 100 | {{0,9},155}, {{84,7},83}, {{0,8},125}, {{0,8},61}, {{0,9},219}, | ||
| 101 | {{82,7},23}, {{0,8},109}, {{0,8},45}, {{0,9},187}, {{0,8},13}, | ||
| 102 | {{0,8},141}, {{0,8},77}, {{0,9},251}, {{80,7},3}, {{0,8},83}, | ||
| 103 | {{0,8},19}, {{85,8},195}, {{83,7},35}, {{0,8},115}, {{0,8},51}, | ||
| 104 | {{0,9},199}, {{81,7},11}, {{0,8},99}, {{0,8},35}, {{0,9},167}, | ||
| 105 | {{0,8},3}, {{0,8},131}, {{0,8},67}, {{0,9},231}, {{80,7},7}, | ||
| 106 | {{0,8},91}, {{0,8},27}, {{0,9},151}, {{84,7},67}, {{0,8},123}, | ||
| 107 | {{0,8},59}, {{0,9},215}, {{82,7},19}, {{0,8},107}, {{0,8},43}, | ||
| 108 | {{0,9},183}, {{0,8},11}, {{0,8},139}, {{0,8},75}, {{0,9},247}, | ||
| 109 | {{80,7},5}, {{0,8},87}, {{0,8},23}, {{192,8},0}, {{83,7},51}, | ||
| 110 | {{0,8},119}, {{0,8},55}, {{0,9},207}, {{81,7},15}, {{0,8},103}, | ||
| 111 | {{0,8},39}, {{0,9},175}, {{0,8},7}, {{0,8},135}, {{0,8},71}, | ||
| 112 | {{0,9},239}, {{80,7},9}, {{0,8},95}, {{0,8},31}, {{0,9},159}, | ||
| 113 | {{84,7},99}, {{0,8},127}, {{0,8},63}, {{0,9},223}, {{82,7},27}, | ||
| 114 | {{0,8},111}, {{0,8},47}, {{0,9},191}, {{0,8},15}, {{0,8},143}, | ||
| 115 | {{0,8},79}, {{0,9},255} | ||
| 116 | }; | ||
| 117 | local inflate_huft fixed_td[] = { | ||
| 118 | {{80,5},1}, {{87,5},257}, {{83,5},17}, {{91,5},4097}, {{81,5},5}, | ||
| 119 | {{89,5},1025}, {{85,5},65}, {{93,5},16385}, {{80,5},3}, {{88,5},513}, | ||
| 120 | {{84,5},33}, {{92,5},8193}, {{82,5},9}, {{90,5},2049}, {{86,5},129}, | ||
| 121 | {{192,5},24577}, {{80,5},2}, {{87,5},385}, {{83,5},25}, {{91,5},6145}, | ||
| 122 | {{81,5},7}, {{89,5},1537}, {{85,5},97}, {{93,5},24577}, {{80,5},4}, | ||
| 123 | {{88,5},769}, {{84,5},49}, {{92,5},12289}, {{82,5},13}, {{90,5},3073}, | ||
| 124 | {{86,5},193}, {{192,5},24577} | ||
| 125 | }; | ||
| @@ -6,8 +6,12 @@ | |||
| 6 | #include "zutil.h" | 6 | #include "zutil.h" |
| 7 | #include "inftrees.h" | 7 | #include "inftrees.h" |
| 8 | 8 | ||
| 9 | #if !defined(BUILDFIXED) && !defined(STDC) | ||
| 10 | # define BUILDFIXED /* non ANSI compilers may not accept inffixed.h */ | ||
| 11 | #endif | ||
| 12 | |||
| 9 | const char inflate_copyright[] = | 13 | const char inflate_copyright[] = |
| 10 | " inflate 1.1.1 Copyright 1995-1998 Mark Adler "; | 14 | " inflate 1.1.2 Copyright 1995-1998 Mark Adler "; |
| 11 | /* | 15 | /* |
| 12 | If you use the zlib library in a product, an acknowledgment is welcome | 16 | If you use the zlib library in a product, an acknowledgment is welcome |
| 13 | in the documentation of your product. If for some reason you cannot | 17 | in the documentation of your product. If for some reason you cannot |
| @@ -17,8 +21,6 @@ const char inflate_copyright[] = | |||
| 17 | struct internal_state {int dummy;}; /* for buggy compilers */ | 21 | struct internal_state {int dummy;}; /* for buggy compilers */ |
| 18 | 22 | ||
| 19 | /* simplify the use of the inflate_huft type with some defines */ | 23 | /* simplify the use of the inflate_huft type with some defines */ |
| 20 | #define base more.Base | ||
| 21 | #define next more.Next | ||
| 22 | #define exop word.what.Exop | 24 | #define exop word.what.Exop |
| 23 | #define bits word.what.Bits | 25 | #define bits word.what.Bits |
| 24 | 26 | ||
| @@ -232,11 +234,6 @@ uIntf *v; /* working area: values in order of bit length */ | |||
| 232 | return Z_MEM_ERROR; /* not enough memory */ | 234 | return Z_MEM_ERROR; /* not enough memory */ |
| 233 | u[h] = q = hp + *hn; | 235 | u[h] = q = hp + *hn; |
| 234 | *hn += z; | 236 | *hn += z; |
| 235 | if (t != Z_NULL) /* first table is returned result */ | ||
| 236 | { | ||
| 237 | *t = q; | ||
| 238 | t = Z_NULL; | ||
| 239 | } | ||
| 240 | 237 | ||
| 241 | /* connect to last table, if there is one */ | 238 | /* connect to last table, if there is one */ |
| 242 | if (h) | 239 | if (h) |
| @@ -244,10 +241,12 @@ uIntf *v; /* working area: values in order of bit length */ | |||
| 244 | x[h] = i; /* save pattern for backing up */ | 241 | x[h] = i; /* save pattern for backing up */ |
| 245 | r.bits = (Byte)l; /* bits to dump before this table */ | 242 | r.bits = (Byte)l; /* bits to dump before this table */ |
| 246 | r.exop = (Byte)j; /* bits in this table */ | 243 | r.exop = (Byte)j; /* bits in this table */ |
| 247 | r.next = q; /* pointer to this table */ | 244 | j = i >> (w - l); |
| 248 | j = i >> (w - l); /* (get around Turbo C bug) */ | 245 | r.base = (uInt)(q - u[h-1] - j); /* offset to this table */ |
| 249 | u[h-1][j] = r; /* connect to last table */ | 246 | u[h-1][j] = r; /* connect to last table */ |
| 250 | } | 247 | } |
| 248 | else | ||
| 249 | *t = q; /* first table is returned result */ | ||
| 251 | } | 250 | } |
| 252 | 251 | ||
| 253 | /* set up table entry in r */ | 252 | /* set up table entry in r */ |
| @@ -384,13 +383,17 @@ z_streamp z; /* for messages */ | |||
| 384 | 383 | ||
| 385 | 384 | ||
| 386 | /* build fixed tables only once--keep them here */ | 385 | /* build fixed tables only once--keep them here */ |
| 386 | #ifdef BUILDFIXED | ||
| 387 | local int fixed_built = 0; | 387 | local int fixed_built = 0; |
| 388 | #define FIXEDH 424 /* number of hufts used by fixed tables */ | 388 | #define FIXEDH 544 /* number of hufts used by fixed tables */ |
| 389 | local inflate_huft fixed_mem[FIXEDH]; | 389 | local inflate_huft fixed_mem[FIXEDH]; |
| 390 | local uInt fixed_bl; | 390 | local uInt fixed_bl; |
| 391 | local uInt fixed_bd; | 391 | local uInt fixed_bd; |
| 392 | local inflate_huft *fixed_tl; | 392 | local inflate_huft *fixed_tl; |
| 393 | local inflate_huft *fixed_td; | 393 | local inflate_huft *fixed_td; |
| 394 | #else | ||
| 395 | #include "inffixed.h" | ||
| 396 | #endif | ||
| 394 | 397 | ||
| 395 | 398 | ||
| 396 | int inflate_trees_fixed(bl, bd, tl, td, z) | 399 | int inflate_trees_fixed(bl, bd, tl, td, z) |
| @@ -400,7 +403,8 @@ inflate_huft * FAR *tl; /* literal/length tree result */ | |||
| 400 | inflate_huft * FAR *td; /* distance tree result */ | 403 | inflate_huft * FAR *td; /* distance tree result */ |
| 401 | z_streamp z; /* for memory allocation */ | 404 | z_streamp z; /* for memory allocation */ |
| 402 | { | 405 | { |
| 403 | /* build fixed tables if not already (multiple overlapped executions ok) */ | 406 | #ifdef BUILDFIXED |
| 407 | /* build fixed tables if not already */ | ||
| 404 | if (!fixed_built) | 408 | if (!fixed_built) |
| 405 | { | 409 | { |
| 406 | int k; /* temporary variable */ | 410 | int k; /* temporary variable */ |
| @@ -426,7 +430,7 @@ z_streamp z; /* for memory allocation */ | |||
| 426 | c[k] = 7; | 430 | c[k] = 7; |
| 427 | for (; k < 288; k++) | 431 | for (; k < 288; k++) |
| 428 | c[k] = 8; | 432 | c[k] = 8; |
| 429 | fixed_bl = 7; | 433 | fixed_bl = 9; |
| 430 | huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, | 434 | huft_build(c, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, |
| 431 | fixed_mem, &f, v); | 435 | fixed_mem, &f, v); |
| 432 | 436 | ||
| @@ -442,6 +446,7 @@ z_streamp z; /* for memory allocation */ | |||
| 442 | ZFREE(z, c); | 446 | ZFREE(z, c); |
| 443 | fixed_built = 1; | 447 | fixed_built = 1; |
| 444 | } | 448 | } |
| 449 | #endif | ||
| 445 | *bl = fixed_bl; | 450 | *bl = fixed_bl; |
| 446 | *bd = fixed_bd; | 451 | *bd = fixed_bd; |
| 447 | *tl = fixed_tl; | 452 | *tl = fixed_tl; |
| @@ -19,17 +19,15 @@ struct inflate_huft_s { | |||
| 19 | Byte Exop; /* number of extra bits or operation */ | 19 | Byte Exop; /* number of extra bits or operation */ |
| 20 | Byte Bits; /* number of bits in this code or subcode */ | 20 | Byte Bits; /* number of bits in this code or subcode */ |
| 21 | } what; | 21 | } what; |
| 22 | Bytef *pad; /* pad structure to a power of 2 (4 bytes for */ | 22 | uInt pad; /* pad structure to a power of 2 (4 bytes for */ |
| 23 | } word; /* 16-bit, 8 bytes for 32-bit machines) */ | 23 | } word; /* 16-bit, 8 bytes for 32-bit int's) */ |
| 24 | union { | 24 | uInt base; /* literal, length base, distance base, |
| 25 | uInt Base; /* literal, length base, or distance base */ | 25 | or table offset */ |
| 26 | inflate_huft *Next; /* pointer to next level of table */ | ||
| 27 | } more; | ||
| 28 | }; | 26 | }; |
| 29 | 27 | ||
| 30 | /* Maximum size of dynamic tree. The maximum found in a long but non- | 28 | /* Maximum size of dynamic tree. The maximum found in a long but non- |
| 31 | exhaustive search was 1041 huft structures (875 for length/literals | 29 | exhaustive search was 1004 huft structures (850 for length/literals |
| 32 | and 166 for distances, the latter actually the result of an | 30 | and 154 for distances, the latter actually the result of an |
| 33 | exhaustive search). The actual maximum is not known, but the | 31 | exhaustive search). The actual maximum is not known, but the |
| 34 | value below is more than safe. */ | 32 | value below is more than safe. */ |
| 35 | #define MANY 1440 | 33 | #define MANY 1440 |
diff --git a/maketree.c b/maketree.c new file mode 100644 index 0000000..66dd828 --- /dev/null +++ b/maketree.c | |||
| @@ -0,0 +1,119 @@ | |||
| 1 | /* maketree.c -- make inffixed.h table for decoding fixed codes | ||
| 2 | * Copyright (C) 1998 Mark Adler | ||
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
| 4 | */ | ||
| 5 | |||
| 6 | /* WARNING: this file should *not* be used by applications. It is | ||
| 7 | part of the implementation of the compression library and is | ||
| 8 | subject to change. Applications should only use zlib.h. | ||
| 9 | */ | ||
| 10 | |||
| 11 | /* This program is included in the distribution for completeness. | ||
| 12 | You do not need to compile or run this program since inffixed.h | ||
| 13 | is already included in the distribution. To use this program | ||
| 14 | you need to compile zlib with BUILDFIXED defined and then compile | ||
| 15 | and link this program with the zlib library. Then the output of | ||
| 16 | this program can be piped to inffixed.h. */ | ||
| 17 | |||
| 18 | #include <stdio.h> | ||
| 19 | #include <stdlib.h> | ||
| 20 | #include "zutil.h" | ||
| 21 | #include "inftrees.h" | ||
| 22 | |||
| 23 | /* simplify the use of the inflate_huft type with some defines */ | ||
| 24 | #define exop word.what.Exop | ||
| 25 | #define bits word.what.Bits | ||
| 26 | |||
| 27 | /* showtree is only used for debugging purposes */ | ||
| 28 | void showtree(uInt b, inflate_huft *t, int d) | ||
| 29 | { | ||
| 30 | int i, e; | ||
| 31 | char p[2*d+1]; | ||
| 32 | |||
| 33 | for (i = 0; i < 2*d; i++) | ||
| 34 | p[i] = ' '; | ||
| 35 | p[i] = 0; | ||
| 36 | printf("%s[%d]\n", p, 1<<b); | ||
| 37 | for (i = 0; i < (1<<b); i++) | ||
| 38 | { | ||
| 39 | e = t[i].exop; | ||
| 40 | if (e == 0) /* simple code */ | ||
| 41 | printf("%s%d(%d): literal=%d\n", p, i, t[i].bits, t[i].base); | ||
| 42 | else if (e & 16) /* length */ | ||
| 43 | printf("%s%d(%d): length/distance=%d+(%d)\n", | ||
| 44 | p, i, t[i].bits, t[i].base, e & 15); | ||
| 45 | else if ((e & 64) == 0) /* next table */ | ||
| 46 | { | ||
| 47 | printf("%s%d(%d): *sub table*\n", p, i, t[i].bits); | ||
| 48 | showtree(e, t + t[i].base, d + 1); | ||
| 49 | } | ||
| 50 | else if (e & 32) /* end of block */ | ||
| 51 | printf("%s%d(%d): end of block\n", p, i, t[i].bits); | ||
| 52 | else /* bad code */ | ||
| 53 | printf("%s%d: bad code\n", p, i); | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | /* generate initialization table for an inflate_huft structure array */ | ||
| 58 | void maketree(uInt b, inflate_huft *t) | ||
| 59 | { | ||
| 60 | int i, e; | ||
| 61 | |||
| 62 | i = 0; | ||
| 63 | while (1) | ||
| 64 | { | ||
| 65 | e = t[i].exop; | ||
| 66 | if (e && (e & (16+64)) == 0) /* table pointer */ | ||
| 67 | { | ||
| 68 | fprintf(stderr, "maketree: cannot initialize sub-tables!\n"); | ||
| 69 | exit(1); | ||
| 70 | } | ||
| 71 | if (i % 5 == 0) | ||
| 72 | printf("\n "); | ||
| 73 | printf(" {{%u,%u},%u}", t[i].exop, t[i].bits, t[i].base); | ||
| 74 | if (++i == (1<<b)) | ||
| 75 | break; | ||
| 76 | putchar(','); | ||
| 77 | } | ||
| 78 | puts(""); | ||
| 79 | } | ||
| 80 | |||
| 81 | /* create the fixed tables in C initialization syntax */ | ||
| 82 | void main(void) | ||
| 83 | { | ||
| 84 | int r; | ||
| 85 | uInt bl, bd; | ||
| 86 | inflate_huft *tl, *td; | ||
| 87 | z_stream z; | ||
| 88 | |||
| 89 | z.zalloc = zcalloc; | ||
| 90 | z.opaque = (voidpf)0; | ||
| 91 | z.zfree = zcfree; | ||
| 92 | r = inflate_trees_fixed(&bl, &bd, &tl, &td, &z); | ||
| 93 | if (r) | ||
| 94 | { | ||
| 95 | fprintf(stderr, "inflate_trees_fixed error %d\n", r); | ||
| 96 | return; | ||
| 97 | } | ||
| 98 | /* puts("Literal/Length Tree:"); | ||
| 99 | showtree(bl, tl, 1); | ||
| 100 | puts("Distance Tree:"); | ||
| 101 | showtree(bd, td, 1); */ | ||
| 102 | puts("/* inffixed.h -- table for decoding fixed codes"); | ||
| 103 | puts(" * Generated automatically by the maketree.c program"); | ||
| 104 | puts(" */"); | ||
| 105 | puts(""); | ||
| 106 | puts("/* WARNING: this file should *not* be used by applications. It is"); | ||
| 107 | puts(" part of the implementation of the compression library and is"); | ||
| 108 | puts(" subject to change. Applications should only use zlib.h."); | ||
| 109 | puts(" */"); | ||
| 110 | puts(""); | ||
| 111 | printf("local uInt fixed_bl = %d;\n", bl); | ||
| 112 | printf("local uInt fixed_bd = %d;\n", bd); | ||
| 113 | printf("local inflate_huft fixed_tl[] = {"); | ||
| 114 | maketree(bl, tl); | ||
| 115 | puts(" };"); | ||
| 116 | printf("local inflate_huft fixed_td[] = {"); | ||
| 117 | maketree(bd, td); | ||
| 118 | puts(" };"); | ||
| 119 | } | ||
diff --git a/msdos/zlib.rc b/msdos/zlib.rc index 2984720..0a38186 100644 --- a/msdos/zlib.rc +++ b/msdos/zlib.rc | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | #define IDR_VERSION1 1 | 3 | #define IDR_VERSION1 1 |
| 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE | 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | FILEVERSION 1,1,1,0 | 5 | FILEVERSION 1,1,2,0 |
| 6 | PRODUCTVERSION 1,1,1,0 | 6 | PRODUCTVERSION 1,1,2,0 |
| 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK | 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | FILEFLAGS 0 | 8 | FILEFLAGS 0 |
| 9 | FILEOS VOS_DOS_WINDOWS32 | 9 | FILEOS VOS_DOS_WINDOWS32 |
| @@ -17,7 +17,7 @@ BEGIN | |||
| 17 | 17 | ||
| 18 | BEGIN | 18 | BEGIN |
| 19 | VALUE "FileDescription", "zlib data compression library\0" | 19 | VALUE "FileDescription", "zlib data compression library\0" |
| 20 | VALUE "FileVersion", "1.1.1\0" | 20 | VALUE "FileVersion", "1.1.2\0" |
| 21 | VALUE "InternalName", "zlib\0" | 21 | VALUE "InternalName", "zlib\0" |
| 22 | VALUE "OriginalFilename", "zlib.dll\0" | 22 | VALUE "OriginalFilename", "zlib.dll\0" |
| 23 | VALUE "ProductName", "ZLib.DLL\0" | 23 | VALUE "ProductName", "ZLib.DLL\0" |
| @@ -1,4 +1,4 @@ | |||
| 1 | .TH ZLIB 3 "27 February 1998" | 1 | .TH ZLIB 3 "19 March 1998" |
| 2 | .SH NAME | 2 | .SH NAME |
| 3 | zlib \- compression/decompression library | 3 | zlib \- compression/decompression library |
| 4 | .SH SYNOPSIS | 4 | .SH SYNOPSIS |
| @@ -81,7 +81,7 @@ These documents are also available in other formats from: | |||
| 81 | .IP | 81 | .IP |
| 82 | ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html | 82 | ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html |
| 83 | .SH AUTHORS | 83 | .SH AUTHORS |
| 84 | Version 1.1.1 | 84 | Version 1.1.2 |
| 85 | Copyright (C) 1995-1998 Jean-loup Gailly (jloup@gzip.org) | 85 | Copyright (C) 1995-1998 Jean-loup Gailly (jloup@gzip.org) |
| 86 | and Mark Adler (madler@alumni.caltech.edu). | 86 | and Mark Adler (madler@alumni.caltech.edu). |
| 87 | .LP | 87 | .LP |
| @@ -96,7 +96,7 @@ The deflate format used by | |||
| 96 | was defined by Phil Katz. | 96 | was defined by Phil Katz. |
| 97 | The deflate and | 97 | The deflate and |
| 98 | .I zlib | 98 | .I zlib |
| 99 | specifications were written by Peter Deutsch. | 99 | specifications were written by L. Peter Deutsch. |
| 100 | Thanks to all the people who reported problems and suggested various | 100 | Thanks to all the people who reported problems and suggested various |
| 101 | improvements in | 101 | improvements in |
| 102 | .IR zlib ; | 102 | .IR zlib ; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* zlib.h -- interface of the 'zlib' general purpose compression library | 1 | /* zlib.h -- interface of the 'zlib' general purpose compression library |
| 2 | version 1.1.1, Feb 27th, 1998 | 2 | version 1.1.2, March 19th, 1998 |
| 3 | 3 | ||
| 4 | Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler | 4 | Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler |
| 5 | 5 | ||
| @@ -31,13 +31,13 @@ | |||
| 31 | #ifndef _ZLIB_H | 31 | #ifndef _ZLIB_H |
| 32 | #define _ZLIB_H | 32 | #define _ZLIB_H |
| 33 | 33 | ||
| 34 | #include "zconf.h" | ||
| 35 | |||
| 34 | #ifdef __cplusplus | 36 | #ifdef __cplusplus |
| 35 | extern "C" { | 37 | extern "C" { |
| 36 | #endif | 38 | #endif |
| 37 | 39 | ||
| 38 | #include "zconf.h" | 40 | #define ZLIB_VERSION "1.1.2" |
| 39 | |||
| 40 | #define ZLIB_VERSION "1.1.1" | ||
| 41 | 41 | ||
| 42 | /* | 42 | /* |
| 43 | The 'zlib' compression library provides in-memory compression and | 43 | The 'zlib' compression library provides in-memory compression and |
