diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:22:37 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:22:37 -0700 |
commit | 4b5a43a219d51066c01ff2ab86af18b967f2d0dd (patch) | |
tree | 4dcaf0cd18751d04cf638a9a6ec521990d4f2e90 | |
parent | 086e982175da84b3db958191031380794315f95f (diff) | |
download | zlib-4b5a43a219d51066c01ff2ab86af18b967f2d0dd.tar.gz zlib-4b5a43a219d51066c01ff2ab86af18b967f2d0dd.tar.bz2 zlib-4b5a43a219d51066c01ff2ab86af18b967f2d0dd.zip |
zlib 1.2.0.5v1.2.0.5
152 files changed, 14538 insertions, 12586 deletions
@@ -1,5 +1,72 @@ | |||
1 | 1 | ||
2 | ChangeLog file for zlib | 2 | ChangeLog file for zlib |
3 | |||
4 | Changes in 1.2.0.5 (8 September 2003) | ||
5 | - Add infback9 diffs to contrib | ||
6 | - Add OF to inflateBackEnd() declaration in zlib.h | ||
7 | - Remember start when using gzdopen in the middle of a file | ||
8 | - Use internal off_t counters in gz* functions to properly handle seeks | ||
9 | - Perform more rigorous check for distance-too-far in inffast.c | ||
10 | - Add Z_BLOCK flush option to return from inflate at block boundary | ||
11 | - Set strm->data_type on return from inflate | ||
12 | - Indicate bits unused, if at block boundary, and if in last block | ||
13 | - Replace size_t with ptrdiff_t in crc32.c, and check for correct size | ||
14 | - Add condition so old NO_DEFLATE define still works for compatibility | ||
15 | - FAQ update regarding the Windows DLL [Truta] | ||
16 | - INDEX update: add qnx entry, remove aix entry [Truta] | ||
17 | - Install zlib.3 into mandir [Wilson] | ||
18 | - Move contrib/zlib_dll_FAQ.txt to win32/DLL_FAQ.txt; update [Truta] | ||
19 | - Adapt the zlib interface to the new DLL convention guidelines [Truta] | ||
20 | - Introduce ZLIB_WINAPI macro to allow the export of functions using | ||
21 | the WINAPI calling convention, for Visual Basic [Vollant, Truta] | ||
22 | - Update msdos and win32 scripts and makefiles [Truta] | ||
23 | - Export symbols by name, not by ordinal, in win32/zlib.def [Truta] | ||
24 | - Add contrib/ada [Anisimkov] | ||
25 | - Move asm files from contrib/vstudio/vc70_32 to contrib/asm386 [Truta] | ||
26 | - Rename contrib/asm386 to contrib/masmx86 [Truta, Vollant] | ||
27 | - Add contrib/masm686 [Truta] | ||
28 | - Fix offsets in contrib/inflate86 and contrib/masmx86/inffas32.asm | ||
29 | [Truta, Vollant] | ||
30 | - Update contrib/delphi; rename to contrib/pascal; add example [Truta] | ||
31 | - Remove contrib/delphi2; add a new contrib/delphi [Truta] | ||
32 | - Avoid inclusion of the nonstandard <memory.h> in contrib/iostream, | ||
33 | and fix some method prototypes [Truta] | ||
34 | - Fix the ZCR_SEED2 constant to avoid warnings in contrib/minizip | ||
35 | [Truta] | ||
36 | - Avoid the use of backslash (\) in contrib/minizip [Vollant] | ||
37 | - Fix file time handling in contrib/untgz; update makefiles [Truta] | ||
38 | - Update contrib/vstudio/vc70_32 to comply with the new DLL guidelines | ||
39 | [Vollant] | ||
40 | - Remove contrib/vstudio/vc15_16 [Vollant] | ||
41 | - Rename contrib/vstudio/vc70_32 to contrib/vstudio/vc7 [Truta] | ||
42 | - Update README.contrib [Truta] | ||
43 | - Invert the assignment order of match_head and s->prev[...] in | ||
44 | INSERT_STRING [Truta] | ||
45 | - Compare TOO_FAR with 32767 instead of 32768, to avoid 16-bit warnings | ||
46 | [Truta] | ||
47 | - Compare function pointers with 0, not with NULL or Z_NULL [Truta] | ||
48 | - Fix prototype of syncsearch in inflate.c [Truta] | ||
49 | - Introduce ASMINF macro to be enabled when using an ASM implementation | ||
50 | of inflate_fast [Truta] | ||
51 | - Change NO_DEFLATE to NO_GZCOMPRESS [Truta] | ||
52 | - Modify test_gzio in example.c to take a single file name as a | ||
53 | parameter [Truta] | ||
54 | - Exit the example.c program if gzopen fails [Truta] | ||
55 | - Add type casts around strlen in example.c [Truta] | ||
56 | - Remove casting to sizeof in minigzip.c; give a proper type | ||
57 | to the variable compared with SUFFIX_LEN [Truta] | ||
58 | - Update definitions of STDC and STDC99 in zconf.h [Truta] | ||
59 | - Synchronize zconf.h with the new Windows DLL interface [Truta] | ||
60 | - Use SYS16BIT instead of __32BIT__ to distinguish between | ||
61 | 16- and 32-bit platforms [Truta] | ||
62 | - Use far memory allocators in small 16-bit memory models for | ||
63 | Turbo C [Truta] | ||
64 | - Add info about the use of ASMV, ASMINF and ZLIB_WINAPI in | ||
65 | zlibCompileFlags [Truta] | ||
66 | - Cygwin has vsnprintf [Wilson] | ||
67 | - In Windows16, OS_CODE is 0, as in MSDOS [Truta] | ||
68 | - In Cygwin, OS_CODE is 3 (Unix), not 11 (Windows32) [Wilson] | ||
69 | |||
3 | Changes in 1.2.0.4 (10 August 2003) | 70 | Changes in 1.2.0.4 (10 August 2003) |
4 | - Minor FAQ updates | 71 | - Minor FAQ updates |
5 | - Be more strict when checking inflateInit2's windowBits parameter | 72 | - Be more strict when checking inflateInit2's windowBits parameter |
@@ -369,7 +436,7 @@ Changes in 1.0.5 (3 Jan 98) | |||
369 | - Eliminate memory leaks on error conditions in inflate | 436 | - Eliminate memory leaks on error conditions in inflate |
370 | - Removed some vestigial code in inflate | 437 | - Removed some vestigial code in inflate |
371 | - Update web address in README | 438 | - Update web address in README |
372 | 439 | ||
373 | Changes in 1.0.4 (24 Jul 96) | 440 | Changes in 1.0.4 (24 Jul 96) |
374 | - In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF | 441 | - In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF |
375 | bit, so the decompressor could decompress all the correct data but went | 442 | bit, so the decompressor could decompress all the correct data but went |
@@ -2,7 +2,7 @@ | |||
2 | Frequently Asked Questions about zlib | 2 | Frequently Asked Questions about zlib |
3 | 3 | ||
4 | 4 | ||
5 | If your question is not there, please check the zlib home page | 5 | If your question is not there, please check the zlib home page |
6 | http://www.zlib.org which may have more recent information. | 6 | http://www.zlib.org which may have more recent information. |
7 | The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html | 7 | The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html |
8 | 8 | ||
@@ -13,9 +13,10 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html | |||
13 | 13 | ||
14 | 2. Where can I get a Windows DLL version? | 14 | 2. Where can I get a Windows DLL version? |
15 | 15 | ||
16 | The zlib sources can be compiled without change to produce a DLL. If you | 16 | The zlib sources can be compiled without change to produce a DLL. |
17 | want a precompiled DLL, see http://www.winimage.com/zLibDll/ . Questions | 17 | See the file win32/DLL_FAQ.txt in the zlib distribution. |
18 | about the zlib DLL should be sent to Gilles Vollant (info@winimage.com). | 18 | Pointers to the precompiled DLL are found in the zlib web site at |
19 | http://www.zlib.org. | ||
19 | 20 | ||
20 | 3. Where can I get a Visual Basic interface to zlib? | 21 | 3. Where can I get a Visual Basic interface to zlib? |
21 | 22 | ||
@@ -66,7 +67,7 @@ The lastest zlib FAQ is at http://www.gzip.org/zlib/zlib_faq.html | |||
66 | If "make test" produces something like | 67 | If "make test" produces something like |
67 | 68 | ||
68 | example.o(.text+0x154): undefined reference to `gzputc' | 69 | example.o(.text+0x154): undefined reference to `gzputc' |
69 | 70 | ||
70 | check that you don't have old files libz.* in /usr/lib, /usr/local/lib or | 71 | check that you don't have old files libz.* in /usr/lib, /usr/local/lib or |
71 | /usr/X11R6/lib. Remove any old versions, then do "make install". | 72 | /usr/X11R6/lib. Remove any old versions, then do "make install". |
72 | 73 | ||
@@ -8,11 +8,11 @@ algorithm.txt description of the (de)compression algorithm | |||
8 | configure configure script for Unix | 8 | configure configure script for Unix |
9 | zconf.in.h template for zconf.h (used by configure) | 9 | zconf.in.h template for zconf.h (used by configure) |
10 | 10 | ||
11 | aix/ instructions for building an AIX shared library | 11 | msdos/ makefiles for MSDOS |
12 | msdos/ makefiles for MSDOS | ||
13 | old/ makefiles for various architectures and zlib documentation | 12 | old/ makefiles for various architectures and zlib documentation |
14 | files that have not yet been updated for zlib 1.2.x | 13 | files that have not yet been updated for zlib 1.2.x |
15 | win32/ makefiles for Windows | 14 | qnx/ makefiles for QNX |
15 | win32/ makefiles for Windows | ||
16 | 16 | ||
17 | zlib public header files (must be kept): | 17 | zlib public header files (must be kept): |
18 | zconf.h | 18 | zconf.h |
@@ -1,12 +1,16 @@ | |||
1 | # Makefile for zlib | 1 | # Makefile for zlib |
2 | # Copyright (C) 1995-2003 Jean-loup Gailly. | 2 | # Copyright (C) 1995-2003 Jean-loup Gailly. |
3 | # For conditions of distribution and use, see copyright notice in zlib.h | 3 | # For conditions of distribution and use, see copyright notice in zlib.h |
4 | 4 | ||
5 | # To compile and test, type: | 5 | # To compile and test, type: |
6 | # ./configure; make test | 6 | # ./configure; make test |
7 | # The call of configure is optional if you don't have special requirements | 7 | # The call of configure is optional if you don't have special requirements |
8 | # If you wish to build zlib as a shared library, use: ./configure -s | 8 | # If you wish to build zlib as a shared library, use: ./configure -s |
9 | 9 | ||
10 | # To use the asm code, type: | ||
11 | # cp contrib/asm?86/match.S ./match.S | ||
12 | # make LOC=-DASMV OBJA=match.o | ||
13 | |||
10 | # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: | 14 | # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: |
11 | # make install | 15 | # make install |
12 | # To install in $HOME instead of /usr/local, use: | 16 | # To install in $HOME instead of /usr/local, use: |
@@ -24,7 +28,7 @@ LDFLAGS=libz.a | |||
24 | LDSHARED=$(CC) | 28 | LDSHARED=$(CC) |
25 | CPP=$(CC) -E | 29 | CPP=$(CC) -E |
26 | 30 | ||
27 | VER=1.2.0.4 | 31 | VER=1.2.0.5 |
28 | LIBS=libz.a | 32 | LIBS=libz.a |
29 | SHAREDLIB=libz.so | 33 | SHAREDLIB=libz.so |
30 | 34 | ||
@@ -37,6 +41,8 @@ prefix = /usr/local | |||
37 | exec_prefix = ${prefix} | 41 | exec_prefix = ${prefix} |
38 | libdir = ${exec_prefix}/lib | 42 | libdir = ${exec_prefix}/lib |
39 | includedir = ${prefix}/include | 43 | includedir = ${prefix}/include |
44 | mandir = ${prefix}/share/man | ||
45 | man3dir = ${mandir}/man3 | ||
40 | 46 | ||
41 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | 47 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ |
42 | zutil.o inflate.o infback.o inftrees.o inffast.o | 48 | zutil.o inflate.o infback.o inftrees.o inffast.o |
@@ -46,7 +52,7 @@ OBJA = | |||
46 | 52 | ||
47 | TEST_OBJS = example.o minigzip.o | 53 | TEST_OBJS = example.o minigzip.o |
48 | 54 | ||
49 | # Note: this hasn't been updated for zlib 1.2.0 | 55 | # Note: this has not been updated for zlib 1.2.0 |
50 | DISTFILES = README FAQ INDEX ChangeLog configure Make*[a-z0-9] *.[ch] *.mms \ | 56 | DISTFILES = README FAQ INDEX ChangeLog configure Make*[a-z0-9] *.[ch] *.mms \ |
51 | algorithm.txt zlib.3 zlib.html \ | 57 | algorithm.txt zlib.3 zlib.html \ |
52 | msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ | 58 | msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ |
@@ -97,7 +103,8 @@ minigzip: minigzip.o $(LIBS) | |||
97 | install: $(LIBS) | 103 | install: $(LIBS) |
98 | -@if [ ! -d $(exec_prefix) ]; then mkdir $(exec_prefix); fi | 104 | -@if [ ! -d $(exec_prefix) ]; then mkdir $(exec_prefix); fi |
99 | -@if [ ! -d $(includedir) ]; then mkdir $(includedir); fi | 105 | -@if [ ! -d $(includedir) ]; then mkdir $(includedir); fi |
100 | -@if [ ! -d $(libdir) ]; then mkdir $(libdir); fi | 106 | -@if [ ! -d $(libdir) ]; then mkdir $(libdir); fi |
107 | -@if [ ! -d $(man3dir) ]; then mkdir $(man3dir); fi | ||
101 | cp zlib.h zconf.h $(includedir) | 108 | cp zlib.h zconf.h $(includedir) |
102 | chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h | 109 | chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h |
103 | cp $(LIBS) $(libdir) | 110 | cp $(LIBS) $(libdir) |
@@ -109,6 +116,8 @@ install: $(LIBS) | |||
109 | ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB).1; \ | 116 | ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB).1; \ |
110 | (ldconfig || true) >/dev/null 2>&1; \ | 117 | (ldconfig || true) >/dev/null 2>&1; \ |
111 | fi | 118 | fi |
119 | cp zlib.3 $(man3dir) | ||
120 | chmod 644 $(man3dir)/zlib.3 | ||
112 | # The ranlib in install is needed on NeXTSTEP which checks file times | 121 | # The ranlib in install is needed on NeXTSTEP which checks file times |
113 | # ldconfig is for Linux | 122 | # ldconfig is for Linux |
114 | 123 | ||
@@ -123,6 +132,7 @@ uninstall: | |||
123 | if test -f $(SHAREDLIB).$$v; then \ | 132 | if test -f $(SHAREDLIB).$$v; then \ |
124 | rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \ | 133 | rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \ |
125 | fi | 134 | fi |
135 | cd $(man3dir); rm -f zlib.3 | ||
126 | 136 | ||
127 | mostlyclean: clean | 137 | mostlyclean: clean |
128 | clean: | 138 | clean: |
@@ -130,11 +140,13 @@ clean: | |||
130 | _match.s maketree | 140 | _match.s maketree |
131 | 141 | ||
132 | maintainer-clean: distclean | 142 | maintainer-clean: distclean |
133 | distclean: clean | 143 | distclean: clean |
134 | cp -p Makefile.in Makefile | 144 | cp -p Makefile.in Makefile |
135 | cp -p zconf.in.h zconf.h | 145 | cp -p zconf.in.h zconf.h |
146 | rm -f .DS_Store | ||
136 | 147 | ||
137 | zip: | 148 | zip: |
149 | echo Warning: this has not been updated for zlib 1.2.0 -- do not use | ||
138 | mv Makefile Makefile~; cp -p Makefile.in Makefile | 150 | mv Makefile Makefile~; cp -p Makefile.in Makefile |
139 | rm -f test.c ztest*.c contrib/minizip/test.zip | 151 | rm -f test.c ztest*.c contrib/minizip/test.zip |
140 | v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ | 152 | v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ |
@@ -142,7 +154,7 @@ zip: | |||
142 | mv Makefile~ Makefile | 154 | mv Makefile~ Makefile |
143 | 155 | ||
144 | dist: | 156 | dist: |
145 | echo Warning: this hasn't been updated for zlib 1.2.0 -- don't use | 157 | echo Warning: this has not been updated for zlib 1.2.0 -- do not use |
146 | mv Makefile Makefile~; cp -p Makefile.in Makefile | 158 | mv Makefile Makefile~; cp -p Makefile.in Makefile |
147 | rm -f test.c ztest*.c contrib/minizip/test.zip | 159 | rm -f test.c ztest*.c contrib/minizip/test.zip |
148 | d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ | 160 | d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ |
@@ -155,7 +167,7 @@ dist: | |||
155 | if test ! -d $$d; then rm -f $$d; fi | 167 | if test ! -d $$d; then rm -f $$d; fi |
156 | mv Makefile~ Makefile | 168 | mv Makefile~ Makefile |
157 | 169 | ||
158 | tags: | 170 | tags: |
159 | etags *.[ch] | 171 | etags *.[ch] |
160 | 172 | ||
161 | depend: | 173 | depend: |
@@ -173,7 +185,7 @@ inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h | |||
173 | inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h | 185 | inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h |
174 | infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h | 186 | infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h |
175 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h | 187 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h |
176 | minigzip.o: zlib.h zconf.h | 188 | minigzip.o: zlib.h zconf.h |
177 | trees.o: deflate.h zutil.h zlib.h zconf.h trees.h | 189 | trees.o: deflate.h zutil.h zlib.h zconf.h trees.h |
178 | uncompr.o: zlib.h zconf.h | 190 | uncompr.o: zlib.h zconf.h |
179 | zutil.o: zutil.h zlib.h zconf.h | 191 | zutil.o: zutil.h zlib.h zconf.h |
diff --git a/Makefile.in b/Makefile.in index 425ad35..ac69ed9 100644 --- a/Makefile.in +++ b/Makefile.in | |||
@@ -1,12 +1,16 @@ | |||
1 | # Makefile for zlib | 1 | # Makefile for zlib |
2 | # Copyright (C) 1995-2003 Jean-loup Gailly. | 2 | # Copyright (C) 1995-2003 Jean-loup Gailly. |
3 | # For conditions of distribution and use, see copyright notice in zlib.h | 3 | # For conditions of distribution and use, see copyright notice in zlib.h |
4 | 4 | ||
5 | # To compile and test, type: | 5 | # To compile and test, type: |
6 | # ./configure; make test | 6 | # ./configure; make test |
7 | # The call of configure is optional if you don't have special requirements | 7 | # The call of configure is optional if you don't have special requirements |
8 | # If you wish to build zlib as a shared library, use: ./configure -s | 8 | # If you wish to build zlib as a shared library, use: ./configure -s |
9 | 9 | ||
10 | # To use the asm code, type: | ||
11 | # cp contrib/asm?86/match.S ./match.S | ||
12 | # make LOC=-DASMV OBJA=match.o | ||
13 | |||
10 | # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: | 14 | # To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type: |
11 | # make install | 15 | # make install |
12 | # To install in $HOME instead of /usr/local, use: | 16 | # To install in $HOME instead of /usr/local, use: |
@@ -24,7 +28,7 @@ LDFLAGS=libz.a | |||
24 | LDSHARED=$(CC) | 28 | LDSHARED=$(CC) |
25 | CPP=$(CC) -E | 29 | CPP=$(CC) -E |
26 | 30 | ||
27 | VER=1.2.0.4 | 31 | VER=1.2.0.5 |
28 | LIBS=libz.a | 32 | LIBS=libz.a |
29 | SHAREDLIB=libz.so | 33 | SHAREDLIB=libz.so |
30 | 34 | ||
@@ -37,6 +41,8 @@ prefix = /usr/local | |||
37 | exec_prefix = ${prefix} | 41 | exec_prefix = ${prefix} |
38 | libdir = ${exec_prefix}/lib | 42 | libdir = ${exec_prefix}/lib |
39 | includedir = ${prefix}/include | 43 | includedir = ${prefix}/include |
44 | mandir = ${prefix}/share/man | ||
45 | man3dir = ${mandir}/man3 | ||
40 | 46 | ||
41 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | 47 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ |
42 | zutil.o inflate.o infback.o inftrees.o inffast.o | 48 | zutil.o inflate.o infback.o inftrees.o inffast.o |
@@ -46,7 +52,7 @@ OBJA = | |||
46 | 52 | ||
47 | TEST_OBJS = example.o minigzip.o | 53 | TEST_OBJS = example.o minigzip.o |
48 | 54 | ||
49 | # Note: this hasn't been updated for zlib 1.2.0 | 55 | # Note: this has not been updated for zlib 1.2.0 |
50 | DISTFILES = README FAQ INDEX ChangeLog configure Make*[a-z0-9] *.[ch] *.mms \ | 56 | DISTFILES = README FAQ INDEX ChangeLog configure Make*[a-z0-9] *.[ch] *.mms \ |
51 | algorithm.txt zlib.3 zlib.html \ | 57 | algorithm.txt zlib.3 zlib.html \ |
52 | msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ | 58 | msdos/Make*[a-z0-9] msdos/zlib.def msdos/zlib.rc \ |
@@ -97,7 +103,8 @@ minigzip: minigzip.o $(LIBS) | |||
97 | install: $(LIBS) | 103 | install: $(LIBS) |
98 | -@if [ ! -d $(exec_prefix) ]; then mkdir $(exec_prefix); fi | 104 | -@if [ ! -d $(exec_prefix) ]; then mkdir $(exec_prefix); fi |
99 | -@if [ ! -d $(includedir) ]; then mkdir $(includedir); fi | 105 | -@if [ ! -d $(includedir) ]; then mkdir $(includedir); fi |
100 | -@if [ ! -d $(libdir) ]; then mkdir $(libdir); fi | 106 | -@if [ ! -d $(libdir) ]; then mkdir $(libdir); fi |
107 | -@if [ ! -d $(man3dir) ]; then mkdir $(man3dir); fi | ||
101 | cp zlib.h zconf.h $(includedir) | 108 | cp zlib.h zconf.h $(includedir) |
102 | chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h | 109 | chmod 644 $(includedir)/zlib.h $(includedir)/zconf.h |
103 | cp $(LIBS) $(libdir) | 110 | cp $(LIBS) $(libdir) |
@@ -109,6 +116,8 @@ install: $(LIBS) | |||
109 | ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB).1; \ | 116 | ln -s $(SHAREDLIB).$(VER) $(SHAREDLIB).1; \ |
110 | (ldconfig || true) >/dev/null 2>&1; \ | 117 | (ldconfig || true) >/dev/null 2>&1; \ |
111 | fi | 118 | fi |
119 | cp zlib.3 $(man3dir) | ||
120 | chmod 644 $(man3dir)/zlib.3 | ||
112 | # The ranlib in install is needed on NeXTSTEP which checks file times | 121 | # The ranlib in install is needed on NeXTSTEP which checks file times |
113 | # ldconfig is for Linux | 122 | # ldconfig is for Linux |
114 | 123 | ||
@@ -123,6 +132,7 @@ uninstall: | |||
123 | if test -f $(SHAREDLIB).$$v; then \ | 132 | if test -f $(SHAREDLIB).$$v; then \ |
124 | rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \ | 133 | rm -f $(SHAREDLIB).$$v $(SHAREDLIB) $(SHAREDLIB).1; \ |
125 | fi | 134 | fi |
135 | cd $(man3dir); rm -f zlib.3 | ||
126 | 136 | ||
127 | mostlyclean: clean | 137 | mostlyclean: clean |
128 | clean: | 138 | clean: |
@@ -130,11 +140,13 @@ clean: | |||
130 | _match.s maketree | 140 | _match.s maketree |
131 | 141 | ||
132 | maintainer-clean: distclean | 142 | maintainer-clean: distclean |
133 | distclean: clean | 143 | distclean: clean |
134 | cp -p Makefile.in Makefile | 144 | cp -p Makefile.in Makefile |
135 | cp -p zconf.in.h zconf.h | 145 | cp -p zconf.in.h zconf.h |
146 | rm -f .DS_Store | ||
136 | 147 | ||
137 | zip: | 148 | zip: |
149 | echo Warning: this has not been updated for zlib 1.2.0 -- do not use | ||
138 | mv Makefile Makefile~; cp -p Makefile.in Makefile | 150 | mv Makefile Makefile~; cp -p Makefile.in Makefile |
139 | rm -f test.c ztest*.c contrib/minizip/test.zip | 151 | rm -f test.c ztest*.c contrib/minizip/test.zip |
140 | v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ | 152 | v=`sed -n -e 's/\.//g' -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ |
@@ -142,7 +154,7 @@ zip: | |||
142 | mv Makefile~ Makefile | 154 | mv Makefile~ Makefile |
143 | 155 | ||
144 | dist: | 156 | dist: |
145 | echo Warning: this hasn't been updated for zlib 1.2.0 -- don't use | 157 | echo Warning: this has not been updated for zlib 1.2.0 -- do not use |
146 | mv Makefile Makefile~; cp -p Makefile.in Makefile | 158 | mv Makefile Makefile~; cp -p Makefile.in Makefile |
147 | rm -f test.c ztest*.c contrib/minizip/test.zip | 159 | rm -f test.c ztest*.c contrib/minizip/test.zip |
148 | d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ | 160 | d=zlib-`sed -n '/VERSION "/s/.*"\(.*\)".*/\1/p' < zlib.h`;\ |
@@ -155,7 +167,7 @@ dist: | |||
155 | if test ! -d $$d; then rm -f $$d; fi | 167 | if test ! -d $$d; then rm -f $$d; fi |
156 | mv Makefile~ Makefile | 168 | mv Makefile~ Makefile |
157 | 169 | ||
158 | tags: | 170 | tags: |
159 | etags *.[ch] | 171 | etags *.[ch] |
160 | 172 | ||
161 | depend: | 173 | depend: |
@@ -173,7 +185,7 @@ inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h | |||
173 | inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h | 185 | inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h |
174 | infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h | 186 | infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h |
175 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h | 187 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h |
176 | minigzip.o: zlib.h zconf.h | 188 | minigzip.o: zlib.h zconf.h |
177 | trees.o: deflate.h zutil.h zlib.h zconf.h trees.h | 189 | trees.o: deflate.h zutil.h zlib.h zconf.h trees.h |
178 | uncompr.o: zlib.h zconf.h | 190 | uncompr.o: zlib.h zconf.h |
179 | zutil.o: zutil.h zlib.h zconf.h | 191 | zutil.o: zutil.h zlib.h zconf.h |
@@ -1,6 +1,6 @@ | |||
1 | ZLIB DATA COMPRESSION LIBRARY | 1 | ZLIB DATA COMPRESSION LIBRARY |
2 | 2 | ||
3 | zlib 1.2.0.4 is a general purpose data compression library. All the code is | 3 | zlib 1.2.0.5 is a general purpose data compression library. All the code is |
4 | thread safe. The data format used by the zlib library is described by RFCs | 4 | thread safe. The data format used by the zlib library is described by RFCs |
5 | (Request for Comments) 1950 to 1952 in the files | 5 | (Request for Comments) 1950 to 1952 in the files |
6 | http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) | 6 | http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) |
@@ -34,7 +34,7 @@ Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997 | |||
34 | issue of Dr. Dobb's Journal; a copy of the article is available in | 34 | issue of Dr. Dobb's Journal; a copy of the article is available in |
35 | http://dogma.net/markn/articles/zlibtool/zlibtool.htm | 35 | http://dogma.net/markn/articles/zlibtool/zlibtool.htm |
36 | 36 | ||
37 | The changes made in version 1.2.0.4 are documented in the file ChangeLog. | 37 | The changes made in version 1.2.0.5 are documented in the file ChangeLog. |
38 | 38 | ||
39 | Unsupported third party contributions are provided in directory "contrib". | 39 | Unsupported third party contributions are provided in directory "contrib". |
40 | 40 | ||
@@ -1,6 +1,6 @@ | |||
1 | /* adler32.c -- compute the Adler-32 checksum of a data stream | 1 | /* adler32.c -- compute the Adler-32 checksum of a data stream |
2 | * Copyright (C) 1995-2003 Mark Adler | 2 | * Copyright (C) 1995-2003 Mark Adler |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* @(#) $Id$ */ | 6 | /* @(#) $Id$ */ |
diff --git a/algorithm.txt b/algorithm.txt index a049765..b022dde 100644 --- a/algorithm.txt +++ b/algorithm.txt | |||
@@ -91,40 +91,40 @@ for 30 symbols. | |||
91 | 91 | ||
92 | 2.2 More details on the inflate table lookup | 92 | 2.2 More details on the inflate table lookup |
93 | 93 | ||
94 | Ok, you want to know what this cleverly obfuscated inflate tree actually | 94 | Ok, you want to know what this cleverly obfuscated inflate tree actually |
95 | looks like. You are correct that it's not a Huffman tree. It is simply a | 95 | looks like. You are correct that it's not a Huffman tree. It is simply a |
96 | lookup table for the first, let's say, nine bits of a Huffman symbol. The | 96 | lookup table for the first, let's say, nine bits of a Huffman symbol. The |
97 | symbol could be as short as one bit or as long as 15 bits. If a particular | 97 | symbol could be as short as one bit or as long as 15 bits. If a particular |
98 | symbol is shorter than nine bits, then that symbol's translation is duplicated | 98 | symbol is shorter than nine bits, then that symbol's translation is duplicated |
99 | in all those entries that start with that symbol's bits. For example, if the | 99 | in all those entries that start with that symbol's bits. For example, if the |
100 | symbol is four bits, then it's duplicated 32 times in a nine-bit table. If a | 100 | symbol is four bits, then it's duplicated 32 times in a nine-bit table. If a |
101 | symbol is nine bits long, it appears in the table once. | 101 | symbol is nine bits long, it appears in the table once. |
102 | 102 | ||
103 | If the symbol is longer than nine bits, then that entry in the table points | 103 | If the symbol is longer than nine bits, then that entry in the table points |
104 | to another similar table for the remaining bits. Again, there are duplicated | 104 | to another similar table for the remaining bits. Again, there are duplicated |
105 | entries as needed. The idea is that most of the time the symbol will be short | 105 | entries as needed. The idea is that most of the time the symbol will be short |
106 | and there will only be one table look up. (That's whole idea behind data | 106 | and there will only be one table look up. (That's whole idea behind data |
107 | compression in the first place.) For the less frequent long symbols, there | 107 | compression in the first place.) For the less frequent long symbols, there |
108 | will be two lookups. If you had a compression method with really long | 108 | will be two lookups. If you had a compression method with really long |
109 | symbols, you could have as many levels of lookups as is efficient. For | 109 | symbols, you could have as many levels of lookups as is efficient. For |
110 | inflate, two is enough. | 110 | inflate, two is enough. |
111 | 111 | ||
112 | So a table entry either points to another table (in which case nine bits in | 112 | So a table entry either points to another table (in which case nine bits in |
113 | the above example are gobbled), or it contains the translation for the symbol | 113 | the above example are gobbled), or it contains the translation for the symbol |
114 | and the number of bits to gobble. Then you start again with the next | 114 | and the number of bits to gobble. Then you start again with the next |
115 | ungobbled bit. | 115 | ungobbled bit. |
116 | 116 | ||
117 | You may wonder: why not just have one lookup table for how ever many bits the | 117 | You may wonder: why not just have one lookup table for how ever many bits the |
118 | longest symbol is? The reason is that if you do that, you end up spending | 118 | longest symbol is? The reason is that if you do that, you end up spending |
119 | more time filling in duplicate symbol entries than you do actually decoding. | 119 | more time filling in duplicate symbol entries than you do actually decoding. |
120 | At least for deflate's output that generates new trees every several 10's of | 120 | At least for deflate's output that generates new trees every several 10's of |
121 | kbytes. You can imagine that filling in a 2^15 entry table for a 15-bit code | 121 | kbytes. You can imagine that filling in a 2^15 entry table for a 15-bit code |
122 | would take too long if you're only decoding several thousand symbols. At the | 122 | would take too long if you're only decoding several thousand symbols. At the |
123 | other extreme, you could make a new table for every bit in the code. In fact, | 123 | other extreme, you could make a new table for every bit in the code. In fact, |
124 | that's essentially a Huffman tree. But then you spend two much time | 124 | that's essentially a Huffman tree. But then you spend two much time |
125 | traversing the tree while decoding, even for short symbols. | 125 | traversing the tree while decoding, even for short symbols. |
126 | 126 | ||
127 | So the number of bits for the first lookup table is a trade of the time to | 127 | So the number of bits for the first lookup table is a trade of the time to |
128 | fill out the table vs. the time spent looking at the second level and above of | 128 | fill out the table vs. the time spent looking at the second level and above of |
129 | the table. | 129 | the table. |
130 | 130 | ||
@@ -154,7 +154,7 @@ Let's make the first table three bits long (eight entries): | |||
154 | 110: -> table X (gobble 3 bits) | 154 | 110: -> table X (gobble 3 bits) |
155 | 111: -> table Y (gobble 3 bits) | 155 | 111: -> table Y (gobble 3 bits) |
156 | 156 | ||
157 | Each entry is what the bits decode as and how many bits that is, i.e. how | 157 | Each entry is what the bits decode as and how many bits that is, i.e. how |
158 | many bits to gobble. Or the entry points to another table, with the number of | 158 | many bits to gobble. Or the entry points to another table, with the number of |
159 | bits to gobble implicit in the size of the table. | 159 | bits to gobble implicit in the size of the table. |
160 | 160 | ||
@@ -166,7 +166,7 @@ long: | |||
166 | 10: D,2 | 166 | 10: D,2 |
167 | 11: E,2 | 167 | 11: E,2 |
168 | 168 | ||
169 | Table Y is three bits long since the longest code starting with 111 is six | 169 | Table Y is three bits long since the longest code starting with 111 is six |
170 | bits long: | 170 | bits long: |
171 | 171 | ||
172 | 000: F,2 | 172 | 000: F,2 |
@@ -178,20 +178,20 @@ bits long: | |||
178 | 110: I,3 | 178 | 110: I,3 |
179 | 111: J,3 | 179 | 111: J,3 |
180 | 180 | ||
181 | So what we have here are three tables with a total of 20 entries that had to | 181 | So what we have here are three tables with a total of 20 entries that had to |
182 | be constructed. That's compared to 64 entries for a single table. Or | 182 | be constructed. That's compared to 64 entries for a single table. Or |
183 | compared to 16 entries for a Huffman tree (six two entry tables and one four | 183 | compared to 16 entries for a Huffman tree (six two entry tables and one four |
184 | entry table). Assuming that the code ideally represents the probability of | 184 | entry table). Assuming that the code ideally represents the probability of |
185 | the symbols, it takes on the average 1.25 lookups per symbol. That's compared | 185 | the symbols, it takes on the average 1.25 lookups per symbol. That's compared |
186 | to one lookup for the single table, or 1.66 lookups per symbol for the | 186 | to one lookup for the single table, or 1.66 lookups per symbol for the |
187 | Huffman tree. | 187 | Huffman tree. |
188 | 188 | ||
189 | There, I think that gives you a picture of what's going on. For inflate, the | 189 | There, I think that gives you a picture of what's going on. For inflate, the |
190 | meaning of a particular symbol is often more than just a letter. It can be a | 190 | meaning of a particular symbol is often more than just a letter. It can be a |
191 | byte (a "literal"), or it can be either a length or a distance which | 191 | byte (a "literal"), or it can be either a length or a distance which |
192 | indicates a base value and a number of bits to fetch after the code that is | 192 | indicates a base value and a number of bits to fetch after the code that is |
193 | added to the base value. Or it might be the special end-of-block code. The | 193 | added to the base value. Or it might be the special end-of-block code. The |
194 | data structures created in inftrees.c try to encode all that information | 194 | data structures created in inftrees.c try to encode all that information |
195 | compactly in the tables. | 195 | compactly in the tables. |
196 | 196 | ||
197 | 197 | ||
@@ -1,6 +1,6 @@ | |||
1 | /* compress.c -- compress a memory buffer | 1 | /* compress.c -- compress a memory buffer |
2 | * Copyright (C) 1995-2002 Jean-loup Gailly. | 2 | * Copyright (C) 1995-2002 Jean-loup Gailly. |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* @(#) $Id$ */ | 6 | /* @(#) $Id$ */ |
@@ -28,6 +28,7 @@ prefix=${prefix-/usr/local} | |||
28 | exec_prefix=${exec_prefix-'${prefix}'} | 28 | exec_prefix=${exec_prefix-'${prefix}'} |
29 | libdir=${libdir-'${exec_prefix}/lib'} | 29 | libdir=${libdir-'${exec_prefix}/lib'} |
30 | includedir=${includedir-'${prefix}/include'} | 30 | includedir=${includedir-'${prefix}/include'} |
31 | mandir=${mandir-'${prefix}/share/man'} | ||
31 | shared_ext='.so' | 32 | shared_ext='.so' |
32 | shared=0 | 33 | shared=0 |
33 | gcc=0 | 34 | gcc=0 |
@@ -78,8 +79,9 @@ if test "$gcc" -eq 1 && ($cc -c $cflags $test.c) 2>/dev/null; then | |||
78 | CFLAGS="$cflags" | 79 | CFLAGS="$cflags" |
79 | case `(uname -s || echo unknown) 2>/dev/null` in | 80 | case `(uname -s || echo unknown) 2>/dev/null` in |
80 | Linux | linux) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};; | 81 | Linux | linux) LDSHARED=${LDSHARED-"$cc -shared -Wl,-soname,libz.so.1"};; |
81 | QNX*) #This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 (alain.bonnefoy@icbt.com) | 82 | QNX*) # This is for QNX6. I suppose that the QNX rule below is for QNX2,QNX4 |
82 | LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"};; | 83 | # (alain.bonnefoy@icbt.com) |
84 | LDSHARED=${LDSHARED-"$cc -shared -Wl,-hlibz.so.1"};; | ||
83 | HP-UX*) LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"} | 85 | HP-UX*) LDSHARED=${LDSHARED-"$cc -shared $SFLAGS"} |
84 | shared_ext='.sl' | 86 | shared_ext='.sl' |
85 | SHAREDLIB='libz.sl';; | 87 | SHAREDLIB='libz.sl';; |
@@ -90,54 +92,54 @@ else | |||
90 | CC=${CC-cc} | 92 | CC=${CC-cc} |
91 | case `(uname -sr || echo unknown) 2>/dev/null` in | 93 | case `(uname -sr || echo unknown) 2>/dev/null` in |
92 | HP-UX*) SFLAGS=${CFLAGS-"-O +z"} | 94 | HP-UX*) SFLAGS=${CFLAGS-"-O +z"} |
93 | CFLAGS=${CFLAGS-"-O"} | 95 | CFLAGS=${CFLAGS-"-O"} |
94 | # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} | 96 | # LDSHARED=${LDSHARED-"ld -b +vnocompatwarnings"} |
95 | LDSHARED=${LDSHARED-"ld -b"} | 97 | LDSHARED=${LDSHARED-"ld -b"} |
96 | shared_ext='.sl' | 98 | shared_ext='.sl' |
97 | SHAREDLIB='libz.sl';; | 99 | SHAREDLIB='libz.sl';; |
98 | IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."} | 100 | IRIX*) SFLAGS=${CFLAGS-"-ansi -O2 -rpath ."} |
99 | CFLAGS=${CFLAGS-"-ansi -O2"} | 101 | CFLAGS=${CFLAGS-"-ansi -O2"} |
100 | LDSHARED=${LDSHARED-"cc -shared"};; | 102 | LDSHARED=${LDSHARED-"cc -shared"};; |
101 | OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"} | 103 | OSF1\ V4*) SFLAGS=${CFLAGS-"-O -std1"} |
102 | CFLAGS=${CFLAGS-"-O -std1"} | 104 | CFLAGS=${CFLAGS-"-O -std1"} |
103 | LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,$SHAREDLIB -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};; | 105 | LDSHARED=${LDSHARED-"cc -shared -Wl,-soname,$SHAREDLIB -Wl,-msym -Wl,-rpath,$(libdir) -Wl,-set_version,${VER}:1.0"};; |
104 | OSF1*) SFLAGS=${CFLAGS-"-O -std1"} | 106 | OSF1*) SFLAGS=${CFLAGS-"-O -std1"} |
105 | CFLAGS=${CFLAGS-"-O -std1"} | 107 | CFLAGS=${CFLAGS-"-O -std1"} |
106 | LDSHARED=${LDSHARED-"cc -shared"};; | 108 | LDSHARED=${LDSHARED-"cc -shared"};; |
107 | QNX*) SFLAGS=${CFLAGS-"-4 -O"} | 109 | QNX*) SFLAGS=${CFLAGS-"-4 -O"} |
108 | CFLAGS=${CFLAGS-"-4 -O"} | 110 | CFLAGS=${CFLAGS-"-4 -O"} |
109 | LDSHARED=${LDSHARED-"cc"} | 111 | LDSHARED=${LDSHARED-"cc"} |
110 | RANLIB=${RANLIB-"true"} | 112 | RANLIB=${RANLIB-"true"} |
111 | AR="cc -A";; | 113 | AR="cc -A";; |
112 | SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "} | 114 | SCO_SV\ 3.2*) SFLAGS=${CFLAGS-"-O3 -dy -KPIC "} |
113 | CFLAGS=${CFLAGS-"-O3"} | 115 | CFLAGS=${CFLAGS-"-O3"} |
114 | LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};; | 116 | LDSHARED=${LDSHARED-"cc -dy -KPIC -G"};; |
115 | SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."} | 117 | SunOS\ 5*) SFLAGS=${CFLAGS-"-fast -xcg89 -KPIC -R."} |
116 | CFLAGS=${CFLAGS-"-fast -xcg89"} | 118 | CFLAGS=${CFLAGS-"-fast -xcg89"} |
117 | LDSHARED=${LDSHARED-"cc -G"};; | 119 | LDSHARED=${LDSHARED-"cc -G"};; |
118 | SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"} | 120 | SunOS\ 4*) SFLAGS=${CFLAGS-"-O2 -PIC"} |
119 | CFLAGS=${CFLAGS-"-O2"} | 121 | CFLAGS=${CFLAGS-"-O2"} |
120 | LDSHARED=${LDSHARED-"ld"};; | 122 | LDSHARED=${LDSHARED-"ld"};; |
121 | UNIX_System_V\ 4.2.0) | 123 | UNIX_System_V\ 4.2.0) |
122 | SFLAGS=${CFLAGS-"-KPIC -O"} | 124 | SFLAGS=${CFLAGS-"-KPIC -O"} |
123 | CFLAGS=${CFLAGS-"-O"} | 125 | CFLAGS=${CFLAGS-"-O"} |
124 | LDSHARED=${LDSHARED-"cc -G"};; | 126 | LDSHARED=${LDSHARED-"cc -G"};; |
125 | UNIX_SV\ 4.2MP) | 127 | UNIX_SV\ 4.2MP) |
126 | SFLAGS=${CFLAGS-"-Kconform_pic -O"} | 128 | SFLAGS=${CFLAGS-"-Kconform_pic -O"} |
127 | CFLAGS=${CFLAGS-"-O"} | 129 | CFLAGS=${CFLAGS-"-O"} |
128 | LDSHARED=${LDSHARED-"cc -G"};; | 130 | LDSHARED=${LDSHARED-"cc -G"};; |
129 | OpenUNIX\ 5) | 131 | OpenUNIX\ 5) |
130 | SFLAGS=${CFLAGS-"-KPIC -O"} | 132 | SFLAGS=${CFLAGS-"-KPIC -O"} |
131 | CFLAGS=${CFLAGS-"-O"} | 133 | CFLAGS=${CFLAGS-"-O"} |
132 | LDSHARED=${LDSHARED-"cc -G"};; | 134 | LDSHARED=${LDSHARED-"cc -G"};; |
133 | AIX*) # Courtesy of dbakker@arrayasolutions.com | 135 | AIX*) # Courtesy of dbakker@arrayasolutions.com |
134 | SFLAGS=${CFLAGS-"-O -qmaxmem=8192"} | 136 | SFLAGS=${CFLAGS-"-O -qmaxmem=8192"} |
135 | CFLAGS=${CFLAGS-"-O -qmaxmem=8192"} | 137 | CFLAGS=${CFLAGS-"-O -qmaxmem=8192"} |
136 | LDSHARED=${LDSHARED-"xlc -G"};; | 138 | LDSHARED=${LDSHARED-"xlc -G"};; |
137 | # send working options for other systems to support@gzip.org | 139 | # send working options for other systems to support@gzip.org |
138 | *) SFLAGS=${CFLAGS-"-O"} | 140 | *) SFLAGS=${CFLAGS-"-O"} |
139 | CFLAGS=${CFLAGS-"-O"} | 141 | CFLAGS=${CFLAGS-"-O"} |
140 | LDSHARED=${LDSHARED-"cc -shared"};; | 142 | LDSHARED=${LDSHARED-"cc -shared"};; |
141 | esac | 143 | esac |
142 | fi | 144 | fi |
143 | 145 | ||
@@ -150,10 +152,10 @@ if test $shared -eq 1; then | |||
150 | LIBS="$SHAREDLIB.$VER" | 152 | LIBS="$SHAREDLIB.$VER" |
151 | echo Building shared library $SHAREDLIB.$VER with $CC. | 153 | echo Building shared library $SHAREDLIB.$VER with $CC. |
152 | elif test -z "$old_cc" -a -z "$old_cflags"; then | 154 | elif test -z "$old_cc" -a -z "$old_cflags"; then |
153 | echo No shared library suppport. | 155 | echo No shared library support. |
154 | shared=0; | 156 | shared=0; |
155 | else | 157 | else |
156 | echo 'No shared library suppport; try without defining CC and CFLAGS' | 158 | echo 'No shared library support; try without defining CC and CFLAGS' |
157 | shared=0; | 159 | shared=0; |
158 | fi | 160 | fi |
159 | fi | 161 | fi |
@@ -182,7 +184,7 @@ cat > $test.c <<EOF | |||
182 | # define STDC | 184 | # define STDC |
183 | #endif | 185 | #endif |
184 | 186 | ||
185 | int main() | 187 | int main() |
186 | { | 188 | { |
187 | #ifndef STDC | 189 | #ifndef STDC |
188 | choke me | 190 | choke me |
@@ -215,7 +217,7 @@ int main() | |||
215 | return (mytest("Hello%d\n", 1)); | 217 | return (mytest("Hello%d\n", 1)); |
216 | } | 218 | } |
217 | EOF | 219 | EOF |
218 | 220 | ||
219 | if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then | 221 | if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then |
220 | echo "Checking for vsnprintf() in stdio.h... Yes." | 222 | echo "Checking for vsnprintf() in stdio.h... Yes." |
221 | 223 | ||
@@ -273,7 +275,7 @@ int mytest(char *fmt, ...) | |||
273 | return 0; | 275 | return 0; |
274 | } | 276 | } |
275 | 277 | ||
276 | int main() | 278 | int main() |
277 | { | 279 | { |
278 | return (mytest("Hello%d\n", 1)); | 280 | return (mytest("Hello%d\n", 1)); |
279 | } | 281 | } |
@@ -296,7 +298,7 @@ else | |||
296 | #include <stdio.h> | 298 | #include <stdio.h> |
297 | #include <stdarg.h> | 299 | #include <stdarg.h> |
298 | 300 | ||
299 | int mytest() | 301 | int mytest() |
300 | { | 302 | { |
301 | char buf[20]; | 303 | char buf[20]; |
302 | 304 | ||
@@ -304,7 +306,7 @@ int mytest() | |||
304 | return 0; | 306 | return 0; |
305 | } | 307 | } |
306 | 308 | ||
307 | int main() | 309 | int main() |
308 | { | 310 | { |
309 | return (mytest()); | 311 | return (mytest()); |
310 | } | 312 | } |
@@ -326,7 +328,7 @@ int mytest(char *fmt, ...) | |||
326 | return 0; | 328 | return 0; |
327 | } | 329 | } |
328 | 330 | ||
329 | int main() | 331 | int main() |
330 | { | 332 | { |
331 | return (mytest()); | 333 | return (mytest()); |
332 | } | 334 | } |
@@ -352,7 +354,7 @@ EOF | |||
352 | #include <stdio.h> | 354 | #include <stdio.h> |
353 | #include <stdarg.h> | 355 | #include <stdarg.h> |
354 | 356 | ||
355 | int mytest(char *fmt, ...) | 357 | int mytest(char *fmt, ...) |
356 | { | 358 | { |
357 | int i; | 359 | int i; |
358 | char buf[20]; | 360 | char buf[20]; |
@@ -361,7 +363,7 @@ int mytest(char *fmt, ...) | |||
361 | return 0; | 363 | return 0; |
362 | } | 364 | } |
363 | 365 | ||
364 | int main() | 366 | int main() |
365 | { | 367 | { |
366 | return (mytest()); | 368 | return (mytest()); |
367 | } | 369 | } |
@@ -384,9 +386,9 @@ cat >$test.c <<EOF | |||
384 | int main() { return 0; } | 386 | int main() { return 0; } |
385 | EOF | 387 | EOF |
386 | if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then | 388 | if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then |
387 | echo "Checking for errno.h... Yes." | 389 | echo "Checking for errno.h... Yes." |
388 | else | 390 | else |
389 | echo "Checking for errno.h... No." | 391 | echo "Checking for errno.h... No." |
390 | CFLAGS="$CFLAGS -DNO_ERRNO_H" | 392 | CFLAGS="$CFLAGS -DNO_ERRNO_H" |
391 | fi | 393 | fi |
392 | 394 | ||
@@ -395,7 +397,7 @@ cat > $test.c <<EOF | |||
395 | #include <sys/mman.h> | 397 | #include <sys/mman.h> |
396 | #include <sys/stat.h> | 398 | #include <sys/stat.h> |
397 | caddr_t hello() { | 399 | caddr_t hello() { |
398 | return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0); | 400 | return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0); |
399 | } | 401 | } |
400 | EOF | 402 | EOF |
401 | if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then | 403 | if test "`($CC -c $CFLAGS $test.c) 2>&1`" = ""; then |
@@ -433,5 +435,6 @@ sed < Makefile.in " | |||
433 | /^exec_prefix *=/s%=.*%=$exec_prefix% | 435 | /^exec_prefix *=/s%=.*%=$exec_prefix% |
434 | /^libdir *=/s%=.*%=$libdir% | 436 | /^libdir *=/s%=.*%=$libdir% |
435 | /^includedir *=/s%=.*%=$includedir% | 437 | /^includedir *=/s%=.*%=$includedir% |
438 | /^mandir *=/s%=.*%=$mandir% | ||
436 | /^LDFLAGS *=/s%=.*%=$LDFLAGS% | 439 | /^LDFLAGS *=/s%=.*%=$LDFLAGS% |
437 | " > Makefile | 440 | " > Makefile |
diff --git a/contrib/README.contrib b/contrib/README.contrib index 3579d43..b1de0d1 100644 --- a/contrib/README.contrib +++ b/contrib/README.contrib | |||
@@ -4,44 +4,64 @@ Use at your own risk. Please contact the authors of the contributions | |||
4 | for help about these, not the zlib authors. Thanks. | 4 | for help about these, not the zlib authors. Thanks. |
5 | 5 | ||
6 | 6 | ||
7 | asm386/ by Gilles Vollant <info@winimage.com> | 7 | ada/ by Dmitriy Anisimkov <anisimkov@yahoo.com> |
8 | 386 asm code replacing longest_match(), for Visual C++ 4.2 and ML 6.11c | 8 | Support for Ada |
9 | See http://zlib-ada.sourceforge.net/ | ||
9 | 10 | ||
10 | asm586/ and asm686/ by Brian Raiter <breadbox@muppetlabs.com> | 11 | asm586/ and asm686/ by Brian Raiter <breadbox@muppetlabs.com> |
11 | asm code for Pentium and Pentium Pro | 12 | asm code for Pentium and PPro/PII, using the AT&T (GNU as) syntax |
12 | See http://www.muppetlabs.com/~breadbox/software/assembly.html | 13 | See http://www.muppetlabs.com/~breadbox/software/assembly.html |
13 | 14 | ||
14 | blast/ by Mark Adler <madler@alumni.caltech.edu> | 15 | blast/ by Mark Adler <madler@alumni.caltech.edu> |
15 | Decompressor for output of PKWare Data Compression Library (DCL) | 16 | Decompressor for output of PKWare Data Compression Library (DCL) |
16 | 17 | ||
17 | delphi/ by Bob Dellaca <bobdl@xtra.co.nz> | 18 | delphi/ by Cosmin Truta <cosmint@cs.ubbcluj.ro> |
18 | Support for Delphi | 19 | Support for Delphi and C++ Builder |
19 | 20 | ||
20 | delphi2/ by Davide Moretti <dave@rimini.com> | 21 | infback9/ by Mark Adler <madler@alumni.caltech.edu> |
21 | Another support for C++Builder and Delphi | 22 | Unsupported diffs to infback to decode the deflate64 format |
23 | (Worse than that, it's not even tested) | ||
22 | 24 | ||
23 | inflate86/ by Chris Anderson <christop@charm.net> | 25 | inflate86/ by Chris Anderson <christop@charm.net> |
24 | Tuned x86 gcc asm code to replace inflate_fast() | 26 | Tuned x86 gcc asm code to replace inflate_fast() |
25 | 27 | ||
26 | minizip/ by Gilles Vollant <info@winimage.com> | ||
27 | Mini zip and unzip based on zlib | ||
28 | See http://www.winimage.com/zLibDll/unzip.html | ||
29 | |||
30 | iostream/ by Kevin Ruland <kevin@rodin.wustl.edu> | 28 | iostream/ by Kevin Ruland <kevin@rodin.wustl.edu> |
31 | A C++ I/O streams interface to the zlib gz* functions | 29 | A C++ I/O streams interface to the zlib gz* functions |
32 | 30 | ||
33 | iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no> | 31 | iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no> |
34 | Another C++ I/O streams interface | 32 | Another C++ I/O streams interface |
35 | 33 | ||
36 | testzlib/ by Gilles Vollant <info@winimage.com> | 34 | iostream3/ by Ludwig Schwardt <schwardt@sun.ac.za> |
35 | and Kevin Ruland <kevin@rodin.wustl.edu> | ||
36 | Yet another C++ I/O streams interface | ||
37 | |||
38 | masm686/ by Dan Higdon <hdan@kinesoft.com> | ||
39 | and Chuck Walbourn <chuckw@kinesoft.com> | ||
40 | asm code for Pentium Pro/PII, using the MASM syntax | ||
41 | |||
42 | masmx86/ by Gilles Vollant <info@winimage.com> | ||
43 | x86 asm code to replace longest_match() and inflate_fast(), | ||
44 | for Visual C++ and MASM | ||
45 | |||
46 | minizip/ by Gilles Vollant <info@winimage.com> | ||
47 | Mini zip and unzip based on zlib | ||
48 | See http://www.winimage.com/zLibDll/unzip.html | ||
49 | |||
50 | pascal/ by Bob Dellaca <bobdl@xtra.co.nz> et al. | ||
51 | Support for Pascal | ||
52 | |||
53 | puff/ by Mark Adler <madler@alumni.caltech.edu> | ||
54 | Small, low memory usage inflate. Also serves to provide an | ||
55 | unambiguous description of the deflate format. | ||
56 | |||
57 | testzlib/ by Gilles Vollant <info@winimage.com> | ||
37 | Example of the use of zlib | 58 | Example of the use of zlib |
38 | 59 | ||
39 | untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es> | 60 | untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es> |
40 | A very simple tar.gz file extractor using zlib | 61 | A very simple tar.gz file extractor using zlib |
41 | 62 | ||
42 | visual-basic.txt by Carlos Rios <c_rios@sonda.cl> | 63 | visual-basic.txt by Carlos Rios <c_rios@sonda.cl> |
43 | How to use compress(), uncompress() and the gz* functions from VB. | 64 | How to use compress(), uncompress() and the gz* functions from VB |
44 | 65 | ||
45 | vstudio/ by Gilles Vollant <info@winimage.com> | 66 | vstudio/ by Gilles Vollant <info@winimage.com> |
46 | Building zlib DLL with Visual Studio .NET | 67 | Building zlib with Visual Studio .NET |
47 | Includes x86 inffast.asm for MASM | ||
diff --git a/contrib/ada/mtest.adb b/contrib/ada/mtest.adb new file mode 100644 index 0000000..91a96cd --- /dev/null +++ b/contrib/ada/mtest.adb | |||
@@ -0,0 +1,153 @@ | |||
1 | ---------------------------------------------------------------- | ||
2 | -- ZLib for Ada thick binding. -- | ||
3 | -- -- | ||
4 | -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
5 | -- -- | ||
6 | -- Open source license information is in the zlib.ads file. -- | ||
7 | ---------------------------------------------------------------- | ||
8 | -- Continuous test for ZLib multithreading. If the test is fail | ||
9 | -- Wou should provide thread safe allocation routines for the Z_Stream. | ||
10 | -- | ||
11 | -- $Id: mtest.adb,v 1.2 2003/08/12 12:11:05 vagul Exp $ | ||
12 | |||
13 | with ZLib; | ||
14 | with Ada.Streams; | ||
15 | with Ada.Numerics.Discrete_Random; | ||
16 | with Ada.Text_IO; | ||
17 | with Ada.Exceptions; | ||
18 | with Ada.Task_Identification; | ||
19 | |||
20 | procedure MTest is | ||
21 | use Ada.Streams; | ||
22 | use ZLib; | ||
23 | |||
24 | Stop : Boolean := False; | ||
25 | |||
26 | pragma Atomic (Stop); | ||
27 | |||
28 | subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; | ||
29 | |||
30 | package Random_Elements is | ||
31 | new Ada.Numerics.Discrete_Random (Visible_Symbols); | ||
32 | |||
33 | task type Test_Task; | ||
34 | |||
35 | task body Test_Task is | ||
36 | Buffer : Stream_Element_Array (1 .. 100_000); | ||
37 | Gen : Random_Elements.Generator; | ||
38 | |||
39 | Buffer_First : Stream_Element_Offset; | ||
40 | Compare_First : Stream_Element_Offset; | ||
41 | |||
42 | Deflate : Filter_Type; | ||
43 | Inflate : Filter_Type; | ||
44 | |||
45 | procedure Further (Item : in Stream_Element_Array); | ||
46 | |||
47 | procedure Read_Buffer | ||
48 | (Item : out Ada.Streams.Stream_Element_Array; | ||
49 | Last : out Ada.Streams.Stream_Element_Offset); | ||
50 | |||
51 | ------------- | ||
52 | -- Further -- | ||
53 | ------------- | ||
54 | |||
55 | procedure Further (Item : in Stream_Element_Array) is | ||
56 | |||
57 | procedure Compare (Item : in Stream_Element_Array); | ||
58 | |||
59 | ------------- | ||
60 | -- Compare -- | ||
61 | ------------- | ||
62 | |||
63 | procedure Compare (Item : in Stream_Element_Array) is | ||
64 | Next_First : Stream_Element_Offset := Compare_First + Item'Length; | ||
65 | begin | ||
66 | if Buffer (Compare_First .. Next_First - 1) /= Item then | ||
67 | raise Program_Error; | ||
68 | end if; | ||
69 | |||
70 | Compare_First := Next_First; | ||
71 | end Compare; | ||
72 | |||
73 | procedure Compare_Write is new ZLib.Write (Write => Compare); | ||
74 | begin | ||
75 | Compare_Write (Inflate, Item, No_Flush); | ||
76 | end Further; | ||
77 | |||
78 | ----------------- | ||
79 | -- Read_Buffer -- | ||
80 | ----------------- | ||
81 | |||
82 | procedure Read_Buffer | ||
83 | (Item : out Ada.Streams.Stream_Element_Array; | ||
84 | Last : out Ada.Streams.Stream_Element_Offset) | ||
85 | is | ||
86 | Buff_Diff : Stream_Element_Offset := Buffer'Last - Buffer_First; | ||
87 | Next_First : Stream_Element_Offset; | ||
88 | begin | ||
89 | if Item'Length <= Buff_Diff then | ||
90 | Last := Item'Last; | ||
91 | |||
92 | Next_First := Buffer_First + Item'Length; | ||
93 | |||
94 | Item := Buffer (Buffer_First .. Next_First - 1); | ||
95 | |||
96 | Buffer_First := Next_First; | ||
97 | else | ||
98 | Last := Item'First + Buff_Diff; | ||
99 | Item (Item'First .. Last) := Buffer (Buffer_First .. Buffer'Last); | ||
100 | Buffer_First := Buffer'Last + 1; | ||
101 | end if; | ||
102 | end Read_Buffer; | ||
103 | |||
104 | procedure Translate is new Generic_Translate | ||
105 | (Data_In => Read_Buffer, | ||
106 | Data_Out => Further); | ||
107 | |||
108 | begin | ||
109 | Random_Elements.Reset (Gen); | ||
110 | |||
111 | Buffer := (others => 20); | ||
112 | |||
113 | Main : loop | ||
114 | for J in Buffer'Range loop | ||
115 | Buffer (J) := Random_Elements.Random (Gen); | ||
116 | |||
117 | Deflate_Init (Deflate); | ||
118 | Inflate_Init (Inflate); | ||
119 | |||
120 | Buffer_First := Buffer'First; | ||
121 | Compare_First := Buffer'First; | ||
122 | |||
123 | Translate (Deflate); | ||
124 | |||
125 | if Compare_First /= Buffer'Last + 1 then | ||
126 | raise Program_Error; | ||
127 | end if; | ||
128 | |||
129 | Ada.Text_IO.Put_Line | ||
130 | (Ada.Task_Identification.Image | ||
131 | (Ada.Task_Identification.Current_Task) | ||
132 | & Stream_Element_Offset'Image (J) | ||
133 | & ZLib.Count'Image (Total_Out (Deflate))); | ||
134 | |||
135 | Close (Deflate); | ||
136 | Close (Inflate); | ||
137 | |||
138 | exit Main when Stop; | ||
139 | end loop; | ||
140 | end loop Main; | ||
141 | exception | ||
142 | when E : others => | ||
143 | Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Information (E)); | ||
144 | Stop := True; | ||
145 | end Test_Task; | ||
146 | |||
147 | Test : array (1 .. 4) of Test_Task; | ||
148 | |||
149 | pragma Unreferenced (Test); | ||
150 | |||
151 | begin | ||
152 | null; | ||
153 | end MTest; | ||
diff --git a/contrib/ada/read.adb b/contrib/ada/read.adb new file mode 100644 index 0000000..184ea00 --- /dev/null +++ b/contrib/ada/read.adb | |||
@@ -0,0 +1,151 @@ | |||
1 | ---------------------------------------------------------------- | ||
2 | -- ZLib for Ada thick binding. -- | ||
3 | -- -- | ||
4 | -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
5 | -- -- | ||
6 | -- Open source license information is in the zlib.ads file. -- | ||
7 | ---------------------------------------------------------------- | ||
8 | |||
9 | -- $Id: read.adb,v 1.7 2003/08/12 12:12:35 vagul Exp $ | ||
10 | |||
11 | -- Test/demo program for the generic read interface. | ||
12 | |||
13 | with Ada.Numerics.Discrete_Random; | ||
14 | with Ada.Streams; | ||
15 | with Ada.Text_IO; | ||
16 | |||
17 | with ZLib; | ||
18 | |||
19 | procedure Read is | ||
20 | |||
21 | use Ada.Streams; | ||
22 | |||
23 | ------------------------------------ | ||
24 | -- Test configuration parameters -- | ||
25 | ------------------------------------ | ||
26 | |||
27 | File_Size : Stream_Element_Offset := 100_000; | ||
28 | |||
29 | Continuous : constant Boolean := False; | ||
30 | -- If this constant is True, the test would be repeated again and again, | ||
31 | -- with increment File_Size for every iteration. | ||
32 | |||
33 | Header : constant ZLib.Header_Type := ZLib.Default; | ||
34 | -- Do not use Header other than Default in ZLib versions 1.1.4 and older. | ||
35 | |||
36 | Init_Random : constant := 8; | ||
37 | -- We are using the same random sequence, in case of we catch bug, | ||
38 | -- so we would be able to reproduce it. | ||
39 | |||
40 | -- End -- | ||
41 | |||
42 | Pack_Size : Stream_Element_Offset; | ||
43 | Offset : Stream_Element_Offset; | ||
44 | |||
45 | Filter : ZLib.Filter_Type; | ||
46 | |||
47 | subtype Visible_Symbols | ||
48 | is Stream_Element range 16#20# .. 16#7E#; | ||
49 | |||
50 | package Random_Elements is new | ||
51 | Ada.Numerics.Discrete_Random (Visible_Symbols); | ||
52 | |||
53 | Gen : Random_Elements.Generator; | ||
54 | Period : constant Stream_Element_Offset := 200; | ||
55 | -- Period constant variable for random generator not to be very random. | ||
56 | -- Bigger period, harder random. | ||
57 | |||
58 | Read_Buffer : Stream_Element_Array (1 .. 2048); | ||
59 | Read_First : Stream_Element_Offset; | ||
60 | Read_Last : Stream_Element_Offset; | ||
61 | |||
62 | procedure Reset; | ||
63 | |||
64 | procedure Read | ||
65 | (Item : out Stream_Element_Array; | ||
66 | Last : out Stream_Element_Offset); | ||
67 | -- this procedure is for generic instantiation of | ||
68 | -- ZLib.Read | ||
69 | -- reading data from the File_In. | ||
70 | |||
71 | procedure Read is new ZLib.Read (Read, Read_Buffer, Read_First, Read_Last); | ||
72 | |||
73 | ---------- | ||
74 | -- Read -- | ||
75 | ---------- | ||
76 | |||
77 | procedure Read | ||
78 | (Item : out Stream_Element_Array; | ||
79 | Last : out Stream_Element_Offset) is | ||
80 | begin | ||
81 | Last := Stream_Element_Offset'Min | ||
82 | (Item'Last, | ||
83 | Item'First + File_Size - Offset); | ||
84 | |||
85 | for J in Item'First .. Last loop | ||
86 | if J < Item'First + Period then | ||
87 | Item (J) := Random_Elements.Random (Gen); | ||
88 | else | ||
89 | Item (J) := Item (J - Period); | ||
90 | end if; | ||
91 | |||
92 | Offset := Offset + 1; | ||
93 | end loop; | ||
94 | end Read; | ||
95 | |||
96 | ----------- | ||
97 | -- Reset -- | ||
98 | ----------- | ||
99 | |||
100 | procedure Reset is | ||
101 | begin | ||
102 | Random_Elements.Reset (Gen, Init_Random); | ||
103 | Pack_Size := 0; | ||
104 | Offset := 1; | ||
105 | Read_First := Read_Buffer'Last + 1; | ||
106 | end Reset; | ||
107 | |||
108 | begin | ||
109 | Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version); | ||
110 | |||
111 | loop | ||
112 | for Level in ZLib.Compression_Level'Range loop | ||
113 | |||
114 | Ada.Text_IO.Put ("Level =" | ||
115 | & ZLib.Compression_Level'Image (Level)); | ||
116 | |||
117 | -- Deflate using generic instantiation. | ||
118 | |||
119 | ZLib.Deflate_Init | ||
120 | (Filter, | ||
121 | Level, | ||
122 | Header => Header); | ||
123 | |||
124 | Reset; | ||
125 | |||
126 | Ada.Text_IO.Put | ||
127 | (Stream_Element_Offset'Image (File_Size) & " ->"); | ||
128 | |||
129 | loop | ||
130 | declare | ||
131 | Buffer : Stream_Element_Array (1 .. 1024); | ||
132 | Last : Stream_Element_Offset; | ||
133 | begin | ||
134 | Read (Filter, Buffer, Last); | ||
135 | |||
136 | Pack_Size := Pack_Size + Last - Buffer'First + 1; | ||
137 | |||
138 | exit when Last < Buffer'Last; | ||
139 | end; | ||
140 | end loop; | ||
141 | |||
142 | Ada.Text_IO.Put_Line (Stream_Element_Offset'Image (Pack_Size)); | ||
143 | |||
144 | ZLib.Close (Filter); | ||
145 | end loop; | ||
146 | |||
147 | exit when not Continuous; | ||
148 | |||
149 | File_Size := File_Size + 1; | ||
150 | end loop; | ||
151 | end Read; | ||
diff --git a/contrib/ada/readme.txt b/contrib/ada/readme.txt new file mode 100644 index 0000000..ad02c22 --- /dev/null +++ b/contrib/ada/readme.txt | |||
@@ -0,0 +1,52 @@ | |||
1 | |||
2 | ZLib for Ada thick binding (ZLib.Ada) | ||
3 | Release 1.2 | ||
4 | |||
5 | ZLib.Ada is a thick binding interface to the popular ZLib data | ||
6 | compression library, available at http://www.gzip.org/zlib/. | ||
7 | It provides Ada-style access to the ZLib C library. | ||
8 | |||
9 | |||
10 | Here are the main changes since ZLib.Ada 1.1: | ||
11 | |||
12 | - The default header type has a name "Default" now. Auto is used only for | ||
13 | automatic GZip/ZLib header detection. | ||
14 | |||
15 | - Added test for multitasking mtest.adb. | ||
16 | |||
17 | - Added GNAT project file zlib.gpr. | ||
18 | |||
19 | |||
20 | How to build ZLib.Ada under GNAT | ||
21 | |||
22 | You should have the ZLib library already build on your computer, before | ||
23 | building ZLib.Ada. Make the directory of ZLib.Ada sources current and | ||
24 | issue the command: | ||
25 | |||
26 | gnatmake test -largs -L<directory where libz.a is> -lz | ||
27 | |||
28 | Or use the GNAT project file build for GNAT 3.15 or later: | ||
29 | |||
30 | gnatmake -Pzlib.gpr -L<directory where libz.a is> | ||
31 | |||
32 | |||
33 | How to build ZLib.Ada under Aonix ObjectAda for Win32 7.2.2 | ||
34 | |||
35 | 1. Make a project with all *.ads and *.adb files from the distribution. | ||
36 | 2. Build the libz.a library from the ZLib C sources. | ||
37 | 3. Rename libz.a to z.lib. | ||
38 | 4. Add the library z.lib to the project. | ||
39 | 5. Add the libc.lib library from the ObjectAda distribution to the project. | ||
40 | 6. Build the executable using test.adb as a main procedure. | ||
41 | |||
42 | |||
43 | How to use ZLib.Ada | ||
44 | |||
45 | The source files test.adb and read.adb are small demo programs that show | ||
46 | the main functionality of ZLib.Ada. | ||
47 | |||
48 | The routines from the package specifications are commented. | ||
49 | |||
50 | |||
51 | Homepage: http://zlib-ada.sourceforge.net/ | ||
52 | Author: Dmitriy Anisimkov <anisimkov@yahoo.com> | ||
diff --git a/contrib/ada/test.adb b/contrib/ada/test.adb new file mode 100644 index 0000000..90773ac --- /dev/null +++ b/contrib/ada/test.adb | |||
@@ -0,0 +1,463 @@ | |||
1 | ---------------------------------------------------------------- | ||
2 | -- ZLib for Ada thick binding. -- | ||
3 | -- -- | ||
4 | -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
5 | -- -- | ||
6 | -- Open source license information is in the zlib.ads file. -- | ||
7 | ---------------------------------------------------------------- | ||
8 | |||
9 | -- $Id: test.adb,v 1.17 2003/08/12 12:13:30 vagul Exp $ | ||
10 | |||
11 | -- The program has a few aims. | ||
12 | -- 1. Test ZLib.Ada95 thick binding functionality. | ||
13 | -- 2. Show the example of use main functionality of the ZLib.Ada95 binding. | ||
14 | -- 3. Build this program automatically compile all ZLib.Ada95 packages under | ||
15 | -- GNAT Ada95 compiler. | ||
16 | |||
17 | with ZLib.Streams; | ||
18 | with Ada.Streams.Stream_IO; | ||
19 | with Ada.Numerics.Discrete_Random; | ||
20 | |||
21 | with Ada.Text_IO; | ||
22 | |||
23 | with Ada.Calendar; | ||
24 | |||
25 | procedure Test is | ||
26 | |||
27 | use Ada.Streams; | ||
28 | use Stream_IO; | ||
29 | |||
30 | ------------------------------------ | ||
31 | -- Test configuration parameters -- | ||
32 | ------------------------------------ | ||
33 | |||
34 | File_Size : Count := 100_000; | ||
35 | Continuous : constant Boolean := False; | ||
36 | |||
37 | Header : constant ZLib.Header_Type := ZLib.Default; | ||
38 | -- ZLib.None; | ||
39 | -- ZLib.Auto; | ||
40 | -- ZLib.GZip; | ||
41 | -- Do not use Header other then Default in ZLib versions 1.1.4 | ||
42 | -- and older. | ||
43 | |||
44 | Strategy : constant ZLib.Strategy_Type := ZLib.Default_Strategy; | ||
45 | Init_Random : constant := 10; | ||
46 | |||
47 | -- End -- | ||
48 | |||
49 | In_File_Name : constant String := "testzlib.in"; | ||
50 | -- Name of the input file | ||
51 | |||
52 | Z_File_Name : constant String := "testzlib.zlb"; | ||
53 | -- Name of the compressed file. | ||
54 | |||
55 | Out_File_Name : constant String := "testzlib.out"; | ||
56 | -- Name of the decompressed file. | ||
57 | |||
58 | File_In : File_Type; | ||
59 | File_Out : File_Type; | ||
60 | File_Back : File_Type; | ||
61 | File_Z : ZLib.Streams.Stream_Type; | ||
62 | |||
63 | Filter : ZLib.Filter_Type; | ||
64 | |||
65 | Time_Stamp : Ada.Calendar.Time; | ||
66 | |||
67 | procedure Generate_File; | ||
68 | -- Generate file of spetsified size with some random data. | ||
69 | -- The random data is repeatable, for the good compression. | ||
70 | |||
71 | procedure Compare_Streams | ||
72 | (Left, Right : in out Root_Stream_Type'Class); | ||
73 | -- The procedure compearing data in 2 streams. | ||
74 | -- It is for compare data before and after compression/decompression. | ||
75 | |||
76 | procedure Compare_Files (Left, Right : String); | ||
77 | -- Compare files. Based on the Compare_Streams. | ||
78 | |||
79 | procedure Copy_Streams | ||
80 | (Source, Target : in out Root_Stream_Type'Class; | ||
81 | Buffer_Size : in Stream_Element_Offset := 1024); | ||
82 | -- Copying data from one stream to another. It is for test stream | ||
83 | -- interface of the library. | ||
84 | |||
85 | procedure Data_In | ||
86 | (Item : out Stream_Element_Array; | ||
87 | Last : out Stream_Element_Offset); | ||
88 | -- this procedure is for generic instantiation of | ||
89 | -- ZLib.Generic_Translate. | ||
90 | -- reading data from the File_In. | ||
91 | |||
92 | procedure Data_Out (Item : in Stream_Element_Array); | ||
93 | -- this procedure is for generic instantiation of | ||
94 | -- ZLib.Generic_Translate. | ||
95 | -- writing data to the File_Out. | ||
96 | |||
97 | procedure Stamp; | ||
98 | -- Store the timestamp to the local variable. | ||
99 | |||
100 | procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count); | ||
101 | -- Print the time statistic with the message. | ||
102 | |||
103 | procedure Translate is new ZLib.Generic_Translate | ||
104 | (Data_In => Data_In, | ||
105 | Data_Out => Data_Out); | ||
106 | -- This procedure is moving data from File_In to File_Out | ||
107 | -- with compression or decompression, depend on initialization of | ||
108 | -- Filter parameter. | ||
109 | |||
110 | ------------------- | ||
111 | -- Compare_Files -- | ||
112 | ------------------- | ||
113 | |||
114 | procedure Compare_Files (Left, Right : String) is | ||
115 | Left_File, Right_File : File_Type; | ||
116 | begin | ||
117 | Open (Left_File, In_File, Left); | ||
118 | Open (Right_File, In_File, Right); | ||
119 | Compare_Streams (Stream (Left_File).all, Stream (Right_File).all); | ||
120 | Close (Left_File); | ||
121 | Close (Right_File); | ||
122 | end Compare_Files; | ||
123 | |||
124 | --------------------- | ||
125 | -- Compare_Streams -- | ||
126 | --------------------- | ||
127 | |||
128 | procedure Compare_Streams | ||
129 | (Left, Right : in out Ada.Streams.Root_Stream_Type'Class) | ||
130 | is | ||
131 | Left_Buffer, Right_Buffer : Stream_Element_Array (0 .. 16#FFF#); | ||
132 | Left_Last, Right_Last : Stream_Element_Offset; | ||
133 | begin | ||
134 | loop | ||
135 | Read (Left, Left_Buffer, Left_Last); | ||
136 | Read (Right, Right_Buffer, Right_Last); | ||
137 | |||
138 | if Left_Last /= Right_Last then | ||
139 | Ada.Text_IO.Put_Line ("Compare error :" | ||
140 | & Stream_Element_Offset'Image (Left_Last) | ||
141 | & " /= " | ||
142 | & Stream_Element_Offset'Image (Right_Last)); | ||
143 | |||
144 | raise Constraint_Error; | ||
145 | |||
146 | elsif Left_Buffer (0 .. Left_Last) | ||
147 | /= Right_Buffer (0 .. Right_Last) | ||
148 | then | ||
149 | Ada.Text_IO.Put_Line ("ERROR: IN and OUT files is not equal."); | ||
150 | raise Constraint_Error; | ||
151 | |||
152 | end if; | ||
153 | |||
154 | exit when Left_Last < Left_Buffer'Last; | ||
155 | end loop; | ||
156 | end Compare_Streams; | ||
157 | |||
158 | ------------------ | ||
159 | -- Copy_Streams -- | ||
160 | ------------------ | ||
161 | |||
162 | procedure Copy_Streams | ||
163 | (Source, Target : in out Ada.Streams.Root_Stream_Type'Class; | ||
164 | Buffer_Size : in Stream_Element_Offset := 1024) | ||
165 | is | ||
166 | Buffer : Stream_Element_Array (1 .. Buffer_Size); | ||
167 | Last : Stream_Element_Offset; | ||
168 | begin | ||
169 | loop | ||
170 | Read (Source, Buffer, Last); | ||
171 | Write (Target, Buffer (1 .. Last)); | ||
172 | |||
173 | exit when Last < Buffer'Last; | ||
174 | end loop; | ||
175 | end Copy_Streams; | ||
176 | |||
177 | ------------- | ||
178 | -- Data_In -- | ||
179 | ------------- | ||
180 | |||
181 | procedure Data_In | ||
182 | (Item : out Stream_Element_Array; | ||
183 | Last : out Stream_Element_Offset) is | ||
184 | begin | ||
185 | Read (File_In, Item, Last); | ||
186 | end Data_In; | ||
187 | |||
188 | -------------- | ||
189 | -- Data_Out -- | ||
190 | -------------- | ||
191 | |||
192 | procedure Data_Out (Item : in Stream_Element_Array) is | ||
193 | begin | ||
194 | Write (File_Out, Item); | ||
195 | end Data_Out; | ||
196 | |||
197 | ------------------- | ||
198 | -- Generate_File -- | ||
199 | ------------------- | ||
200 | |||
201 | procedure Generate_File is | ||
202 | subtype Visible_Symbols is Stream_Element range 16#20# .. 16#7E#; | ||
203 | |||
204 | package Random_Elements is | ||
205 | new Ada.Numerics.Discrete_Random (Visible_Symbols); | ||
206 | |||
207 | Gen : Random_Elements.Generator; | ||
208 | Buffer : Stream_Element_Array := (1 .. 77 => 16#20#) & 10; | ||
209 | |||
210 | Buffer_Count : constant Count := File_Size / Buffer'Length; | ||
211 | -- Number of same buffers in the packet. | ||
212 | |||
213 | Density : constant Count := 30; -- from 0 to Buffer'Length - 2; | ||
214 | |||
215 | procedure Fill_Buffer (J, D : in Count); | ||
216 | -- Change the part of the buffer. | ||
217 | |||
218 | ----------------- | ||
219 | -- Fill_Buffer -- | ||
220 | ----------------- | ||
221 | |||
222 | procedure Fill_Buffer (J, D : in Count) is | ||
223 | begin | ||
224 | for K in 0 .. D loop | ||
225 | Buffer | ||
226 | (Stream_Element_Offset ((J + K) mod (Buffer'Length - 1) + 1)) | ||
227 | := Random_Elements.Random (Gen); | ||
228 | |||
229 | end loop; | ||
230 | end Fill_Buffer; | ||
231 | |||
232 | begin | ||
233 | Random_Elements.Reset (Gen, Init_Random); | ||
234 | |||
235 | Create (File_In, Out_File, In_File_Name); | ||
236 | |||
237 | Fill_Buffer (1, Buffer'Length - 2); | ||
238 | |||
239 | for J in 1 .. Buffer_Count loop | ||
240 | Write (File_In, Buffer); | ||
241 | |||
242 | Fill_Buffer (J, Density); | ||
243 | end loop; | ||
244 | |||
245 | -- fill remain size. | ||
246 | |||
247 | Write | ||
248 | (File_In, | ||
249 | Buffer | ||
250 | (1 .. Stream_Element_Offset | ||
251 | (File_Size - Buffer'Length * Buffer_Count))); | ||
252 | |||
253 | Flush (File_In); | ||
254 | Close (File_In); | ||
255 | end Generate_File; | ||
256 | |||
257 | --------------------- | ||
258 | -- Print_Statistic -- | ||
259 | --------------------- | ||
260 | |||
261 | procedure Print_Statistic (Msg : String; Data_Size : ZLib.Count) is | ||
262 | use Ada.Calendar; | ||
263 | use Ada.Text_IO; | ||
264 | |||
265 | package Count_IO is new Integer_IO (ZLib.Count); | ||
266 | |||
267 | Curr_Dur : Duration := Clock - Time_Stamp; | ||
268 | begin | ||
269 | Put (Msg); | ||
270 | |||
271 | Set_Col (20); | ||
272 | Ada.Text_IO.Put ("size ="); | ||
273 | |||
274 | Count_IO.Put | ||
275 | (Data_Size, | ||
276 | Width => Stream_IO.Count'Image (File_Size)'Length); | ||
277 | |||
278 | Put_Line (" duration =" & Duration'Image (Curr_Dur)); | ||
279 | end Print_Statistic; | ||
280 | |||
281 | ----------- | ||
282 | -- Stamp -- | ||
283 | ----------- | ||
284 | |||
285 | procedure Stamp is | ||
286 | begin | ||
287 | Time_Stamp := Ada.Calendar.Clock; | ||
288 | end Stamp; | ||
289 | |||
290 | begin | ||
291 | Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version); | ||
292 | |||
293 | loop | ||
294 | Generate_File; | ||
295 | |||
296 | for Level in ZLib.Compression_Level'Range loop | ||
297 | |||
298 | Ada.Text_IO.Put_Line ("Level =" | ||
299 | & ZLib.Compression_Level'Image (Level)); | ||
300 | |||
301 | -- Test generic interface. | ||
302 | Open (File_In, In_File, In_File_Name); | ||
303 | Create (File_Out, Out_File, Z_File_Name); | ||
304 | |||
305 | Stamp; | ||
306 | |||
307 | -- Deflate using generic instantiation. | ||
308 | |||
309 | ZLib.Deflate_Init | ||
310 | (Filter => Filter, | ||
311 | Level => Level, | ||
312 | Strategy => Strategy, | ||
313 | Header => Header); | ||
314 | |||
315 | Translate (Filter); | ||
316 | Print_Statistic ("Generic compress", ZLib.Total_Out (Filter)); | ||
317 | ZLib.Close (Filter); | ||
318 | |||
319 | Close (File_In); | ||
320 | Close (File_Out); | ||
321 | |||
322 | Open (File_In, In_File, Z_File_Name); | ||
323 | Create (File_Out, Out_File, Out_File_Name); | ||
324 | |||
325 | Stamp; | ||
326 | |||
327 | -- Inflate using generic instantiation. | ||
328 | |||
329 | ZLib.Inflate_Init (Filter, Header => Header); | ||
330 | |||
331 | Translate (Filter); | ||
332 | Print_Statistic ("Generic decompress", ZLib.Total_Out (Filter)); | ||
333 | |||
334 | ZLib.Close (Filter); | ||
335 | |||
336 | Close (File_In); | ||
337 | Close (File_Out); | ||
338 | |||
339 | Compare_Files (In_File_Name, Out_File_Name); | ||
340 | |||
341 | -- Test stream interface. | ||
342 | |||
343 | -- Compress to the back stream. | ||
344 | |||
345 | Open (File_In, In_File, In_File_Name); | ||
346 | Create (File_Back, Out_File, Z_File_Name); | ||
347 | |||
348 | Stamp; | ||
349 | |||
350 | ZLib.Streams.Create | ||
351 | (Stream => File_Z, | ||
352 | Mode => ZLib.Streams.Out_Stream, | ||
353 | Back => ZLib.Streams.Stream_Access | ||
354 | (Stream (File_Back)), | ||
355 | Back_Compressed => True, | ||
356 | Level => Level, | ||
357 | Strategy => Strategy, | ||
358 | Header => Header); | ||
359 | |||
360 | Copy_Streams | ||
361 | (Source => Stream (File_In).all, | ||
362 | Target => File_Z); | ||
363 | |||
364 | -- Flushing internal buffers to the back stream. | ||
365 | |||
366 | ZLib.Streams.Flush (File_Z, ZLib.Finish); | ||
367 | |||
368 | Print_Statistic ("Write compress", | ||
369 | ZLib.Streams.Write_Total_Out (File_Z)); | ||
370 | |||
371 | ZLib.Streams.Close (File_Z); | ||
372 | |||
373 | Close (File_In); | ||
374 | Close (File_Back); | ||
375 | |||
376 | -- Compare reading from original file and from | ||
377 | -- decompression stream. | ||
378 | |||
379 | Open (File_In, In_File, In_File_Name); | ||
380 | Open (File_Back, In_File, Z_File_Name); | ||
381 | |||
382 | ZLib.Streams.Create | ||
383 | (Stream => File_Z, | ||
384 | Mode => ZLib.Streams.In_Stream, | ||
385 | Back => ZLib.Streams.Stream_Access | ||
386 | (Stream (File_Back)), | ||
387 | Back_Compressed => True, | ||
388 | Header => Header); | ||
389 | |||
390 | Stamp; | ||
391 | Compare_Streams (Stream (File_In).all, File_Z); | ||
392 | |||
393 | Print_Statistic ("Read decompress", | ||
394 | ZLib.Streams.Read_Total_Out (File_Z)); | ||
395 | |||
396 | ZLib.Streams.Close (File_Z); | ||
397 | Close (File_In); | ||
398 | Close (File_Back); | ||
399 | |||
400 | -- Compress by reading from compression stream. | ||
401 | |||
402 | Open (File_Back, In_File, In_File_Name); | ||
403 | Create (File_Out, Out_File, Z_File_Name); | ||
404 | |||
405 | ZLib.Streams.Create | ||
406 | (Stream => File_Z, | ||
407 | Mode => ZLib.Streams.In_Stream, | ||
408 | Back => ZLib.Streams.Stream_Access | ||
409 | (Stream (File_Back)), | ||
410 | Back_Compressed => False, | ||
411 | Level => Level, | ||
412 | Strategy => Strategy, | ||
413 | Header => Header); | ||
414 | |||
415 | Stamp; | ||
416 | Copy_Streams | ||
417 | (Source => File_Z, | ||
418 | Target => Stream (File_Out).all); | ||
419 | |||
420 | Print_Statistic ("Read compress", | ||
421 | ZLib.Streams.Read_Total_Out (File_Z)); | ||
422 | |||
423 | ZLib.Streams.Close (File_Z); | ||
424 | |||
425 | Close (File_Out); | ||
426 | Close (File_Back); | ||
427 | |||
428 | -- Decompress to decompression stream. | ||
429 | |||
430 | Open (File_In, In_File, Z_File_Name); | ||
431 | Create (File_Back, Out_File, Out_File_Name); | ||
432 | |||
433 | ZLib.Streams.Create | ||
434 | (Stream => File_Z, | ||
435 | Mode => ZLib.Streams.Out_Stream, | ||
436 | Back => ZLib.Streams.Stream_Access | ||
437 | (Stream (File_Back)), | ||
438 | Back_Compressed => False, | ||
439 | Header => Header); | ||
440 | |||
441 | Stamp; | ||
442 | |||
443 | Copy_Streams | ||
444 | (Source => Stream (File_In).all, | ||
445 | Target => File_Z); | ||
446 | |||
447 | Print_Statistic ("Write decompress", | ||
448 | ZLib.Streams.Write_Total_Out (File_Z)); | ||
449 | |||
450 | ZLib.Streams.Close (File_Z); | ||
451 | Close (File_In); | ||
452 | Close (File_Back); | ||
453 | |||
454 | Compare_Files (In_File_Name, Out_File_Name); | ||
455 | end loop; | ||
456 | |||
457 | Ada.Text_IO.Put_Line (Count'Image (File_Size) & " Ok."); | ||
458 | |||
459 | exit when not Continuous; | ||
460 | |||
461 | File_Size := File_Size + 1; | ||
462 | end loop; | ||
463 | end Test; | ||
diff --git a/contrib/ada/zlib-streams.adb b/contrib/ada/zlib-streams.adb new file mode 100644 index 0000000..d213b5c --- /dev/null +++ b/contrib/ada/zlib-streams.adb | |||
@@ -0,0 +1,215 @@ | |||
1 | ---------------------------------------------------------------- | ||
2 | -- ZLib for Ada thick binding. -- | ||
3 | -- -- | ||
4 | -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
5 | -- -- | ||
6 | -- Open source license information is in the zlib.ads file. -- | ||
7 | ---------------------------------------------------------------- | ||
8 | |||
9 | -- $Id: zlib-streams.adb,v 1.9 2003/08/12 13:15:31 vagul Exp $ | ||
10 | |||
11 | with Ada.Unchecked_Deallocation; | ||
12 | |||
13 | package body ZLib.Streams is | ||
14 | |||
15 | ----------- | ||
16 | -- Close -- | ||
17 | ----------- | ||
18 | |||
19 | procedure Close (Stream : in out Stream_Type) is | ||
20 | procedure Free is new Ada.Unchecked_Deallocation | ||
21 | (Stream_Element_Array, Buffer_Access); | ||
22 | begin | ||
23 | if Stream.Mode = Out_Stream or Stream.Mode = Duplex then | ||
24 | -- We should flush the data written by the writer. | ||
25 | |||
26 | Flush (Stream, Finish); | ||
27 | |||
28 | Close (Stream.Writer); | ||
29 | end if; | ||
30 | |||
31 | if Stream.Mode = In_Stream or Stream.Mode = Duplex then | ||
32 | Close (Stream.Reader); | ||
33 | Free (Stream.Buffer); | ||
34 | end if; | ||
35 | end Close; | ||
36 | |||
37 | ------------ | ||
38 | -- Create -- | ||
39 | ------------ | ||
40 | |||
41 | procedure Create | ||
42 | (Stream : out Stream_Type; | ||
43 | Mode : in Stream_Mode; | ||
44 | Back : in Stream_Access; | ||
45 | Back_Compressed : in Boolean; | ||
46 | Level : in Compression_Level := Default_Compression; | ||
47 | Strategy : in Strategy_Type := Default_Strategy; | ||
48 | Header : in Header_Type := Default; | ||
49 | Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset | ||
50 | := Default_Buffer_Size; | ||
51 | Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset | ||
52 | := Default_Buffer_Size) | ||
53 | is | ||
54 | |||
55 | subtype Buffer_Subtype is Stream_Element_Array (1 .. Read_Buffer_Size); | ||
56 | |||
57 | procedure Init_Filter | ||
58 | (Filter : in out Filter_Type; | ||
59 | Compress : in Boolean); | ||
60 | |||
61 | ----------------- | ||
62 | -- Init_Filter -- | ||
63 | ----------------- | ||
64 | |||
65 | procedure Init_Filter | ||
66 | (Filter : in out Filter_Type; | ||
67 | Compress : in Boolean) is | ||
68 | begin | ||
69 | if Compress then | ||
70 | Deflate_Init | ||
71 | (Filter, Level, Strategy, Header => Header); | ||
72 | else | ||
73 | Inflate_Init (Filter, Header => Header); | ||
74 | end if; | ||
75 | end Init_Filter; | ||
76 | |||
77 | begin | ||
78 | Stream.Back := Back; | ||
79 | Stream.Mode := Mode; | ||
80 | |||
81 | if Mode = Out_Stream or Mode = Duplex then | ||
82 | Init_Filter (Stream.Writer, Back_Compressed); | ||
83 | Stream.Buffer_Size := Write_Buffer_Size; | ||
84 | else | ||
85 | Stream.Buffer_Size := 0; | ||
86 | end if; | ||
87 | |||
88 | if Mode = In_Stream or Mode = Duplex then | ||
89 | Init_Filter (Stream.Reader, not Back_Compressed); | ||
90 | |||
91 | Stream.Buffer := new Buffer_Subtype; | ||
92 | Stream.Rest_First := Stream.Buffer'Last + 1; | ||
93 | end if; | ||
94 | end Create; | ||
95 | |||
96 | ----------- | ||
97 | -- Flush -- | ||
98 | ----------- | ||
99 | |||
100 | procedure Flush | ||
101 | (Stream : in out Stream_Type; | ||
102 | Mode : in Flush_Mode := Sync_Flush) | ||
103 | is | ||
104 | Buffer : Stream_Element_Array (1 .. Stream.Buffer_Size); | ||
105 | Last : Stream_Element_Offset; | ||
106 | begin | ||
107 | loop | ||
108 | Flush (Stream.Writer, Buffer, Last, Mode); | ||
109 | |||
110 | Ada.Streams.Write (Stream.Back.all, Buffer (1 .. Last)); | ||
111 | |||
112 | exit when Last < Buffer'Last; | ||
113 | end loop; | ||
114 | end Flush; | ||
115 | |||
116 | ---------- | ||
117 | -- Read -- | ||
118 | ---------- | ||
119 | |||
120 | procedure Read | ||
121 | (Stream : in out Stream_Type; | ||
122 | Item : out Stream_Element_Array; | ||
123 | Last : out Stream_Element_Offset) | ||
124 | is | ||
125 | |||
126 | procedure Read | ||
127 | (Item : out Stream_Element_Array; | ||
128 | Last : out Stream_Element_Offset); | ||
129 | |||
130 | ---------- | ||
131 | -- Read -- | ||
132 | ---------- | ||
133 | |||
134 | procedure Read | ||
135 | (Item : out Stream_Element_Array; | ||
136 | Last : out Stream_Element_Offset) is | ||
137 | begin | ||
138 | Ada.Streams.Read (Stream.Back.all, Item, Last); | ||
139 | end Read; | ||
140 | |||
141 | procedure Read is new ZLib.Read | ||
142 | (Read => Read, | ||
143 | Buffer => Stream.Buffer.all, | ||
144 | Rest_First => Stream.Rest_First, | ||
145 | Rest_Last => Stream.Rest_Last); | ||
146 | |||
147 | begin | ||
148 | Read (Stream.Reader, Item, Last); | ||
149 | end Read; | ||
150 | |||
151 | ------------------- | ||
152 | -- Read_Total_In -- | ||
153 | ------------------- | ||
154 | |||
155 | function Read_Total_In (Stream : in Stream_Type) return Count is | ||
156 | begin | ||
157 | return Total_In (Stream.Reader); | ||
158 | end Read_Total_In; | ||
159 | |||
160 | -------------------- | ||
161 | -- Read_Total_Out -- | ||
162 | -------------------- | ||
163 | |||
164 | function Read_Total_Out (Stream : in Stream_Type) return Count is | ||
165 | begin | ||
166 | return Total_Out (Stream.Reader); | ||
167 | end Read_Total_Out; | ||
168 | |||
169 | ----------- | ||
170 | -- Write -- | ||
171 | ----------- | ||
172 | |||
173 | procedure Write | ||
174 | (Stream : in out Stream_Type; | ||
175 | Item : in Stream_Element_Array) | ||
176 | is | ||
177 | |||
178 | procedure Write (Item : in Stream_Element_Array); | ||
179 | |||
180 | ----------- | ||
181 | -- Write -- | ||
182 | ----------- | ||
183 | |||
184 | procedure Write (Item : in Stream_Element_Array) is | ||
185 | begin | ||
186 | Ada.Streams.Write (Stream.Back.all, Item); | ||
187 | end Write; | ||
188 | |||
189 | procedure Write is new ZLib.Write | ||
190 | (Write => Write, | ||
191 | Buffer_Size => Stream.Buffer_Size); | ||
192 | |||
193 | begin | ||
194 | Write (Stream.Writer, Item, No_Flush); | ||
195 | end Write; | ||
196 | |||
197 | -------------------- | ||
198 | -- Write_Total_In -- | ||
199 | -------------------- | ||
200 | |||
201 | function Write_Total_In (Stream : in Stream_Type) return Count is | ||
202 | begin | ||
203 | return Total_In (Stream.Writer); | ||
204 | end Write_Total_In; | ||
205 | |||
206 | --------------------- | ||
207 | -- Write_Total_Out -- | ||
208 | --------------------- | ||
209 | |||
210 | function Write_Total_Out (Stream : in Stream_Type) return Count is | ||
211 | begin | ||
212 | return Total_Out (Stream.Writer); | ||
213 | end Write_Total_Out; | ||
214 | |||
215 | end ZLib.Streams; | ||
diff --git a/contrib/ada/zlib-streams.ads b/contrib/ada/zlib-streams.ads new file mode 100644 index 0000000..1d5e904 --- /dev/null +++ b/contrib/ada/zlib-streams.ads | |||
@@ -0,0 +1,112 @@ | |||
1 | ---------------------------------------------------------------- | ||
2 | -- ZLib for Ada thick binding. -- | ||
3 | -- -- | ||
4 | -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
5 | -- -- | ||
6 | -- Open source license information is in the zlib.ads file. -- | ||
7 | ---------------------------------------------------------------- | ||
8 | |||
9 | -- $Id: zlib-streams.ads,v 1.11 2003/08/12 13:15:31 vagul Exp $ | ||
10 | |||
11 | package ZLib.Streams is | ||
12 | |||
13 | type Stream_Mode is (In_Stream, Out_Stream, Duplex); | ||
14 | |||
15 | type Stream_Access is access all Ada.Streams.Root_Stream_Type'Class; | ||
16 | |||
17 | type Stream_Type is | ||
18 | new Ada.Streams.Root_Stream_Type with private; | ||
19 | |||
20 | procedure Read | ||
21 | (Stream : in out Stream_Type; | ||
22 | Item : out Ada.Streams.Stream_Element_Array; | ||
23 | Last : out Ada.Streams.Stream_Element_Offset); | ||
24 | |||
25 | procedure Write | ||
26 | (Stream : in out Stream_Type; | ||
27 | Item : in Ada.Streams.Stream_Element_Array); | ||
28 | |||
29 | procedure Flush | ||
30 | (Stream : in out Stream_Type; | ||
31 | Mode : in Flush_Mode := Sync_Flush); | ||
32 | -- Flush the written data to the back stream, | ||
33 | -- all data placed to the compressor is flushing to the Back stream. | ||
34 | -- Should not be used untill necessary, becouse it is decreasing | ||
35 | -- compression. | ||
36 | |||
37 | function Read_Total_In (Stream : in Stream_Type) return Count; | ||
38 | pragma Inline (Read_Total_In); | ||
39 | -- Return total number of bytes read from back stream so far. | ||
40 | |||
41 | function Read_Total_Out (Stream : in Stream_Type) return Count; | ||
42 | pragma Inline (Read_Total_Out); | ||
43 | -- Return total number of bytes read so far. | ||
44 | |||
45 | function Write_Total_In (Stream : in Stream_Type) return Count; | ||
46 | pragma Inline (Write_Total_In); | ||
47 | -- Return total number of bytes written so far. | ||
48 | |||
49 | function Write_Total_Out (Stream : in Stream_Type) return Count; | ||
50 | pragma Inline (Write_Total_Out); | ||
51 | -- Return total number of bytes written to the back stream. | ||
52 | |||
53 | procedure Create | ||
54 | (Stream : out Stream_Type; | ||
55 | Mode : in Stream_Mode; | ||
56 | Back : in Stream_Access; | ||
57 | Back_Compressed : in Boolean; | ||
58 | Level : in Compression_Level := Default_Compression; | ||
59 | Strategy : in Strategy_Type := Default_Strategy; | ||
60 | Header : in Header_Type := Default; | ||
61 | Read_Buffer_Size : in Ada.Streams.Stream_Element_Offset | ||
62 | := Default_Buffer_Size; | ||
63 | Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset | ||
64 | := Default_Buffer_Size); | ||
65 | -- Create the Comression/Decompression stream. | ||
66 | -- If mode is In_Stream then Write operation is disabled. | ||
67 | -- If mode is Out_Stream then Read operation is disabled. | ||
68 | |||
69 | -- If Back_Compressed is true then | ||
70 | -- Data written to the Stream is compressing to the Back stream | ||
71 | -- and data read from the Stream is decompressed data from the Back stream. | ||
72 | |||
73 | -- If Back_Compressed is false then | ||
74 | -- Data written to the Stream is decompressing to the Back stream | ||
75 | -- and data read from the Stream is compressed data from the Back stream. | ||
76 | |||
77 | -- !!! When the Need_Header is False ZLib-Ada is using undocumented | ||
78 | -- ZLib 1.1.4 functionality to do not create/wait for ZLib headers. | ||
79 | |||
80 | procedure Close (Stream : in out Stream_Type); | ||
81 | |||
82 | private | ||
83 | |||
84 | use Ada.Streams; | ||
85 | |||
86 | type Buffer_Access is access all Stream_Element_Array; | ||
87 | |||
88 | type Stream_Type | ||
89 | is new Root_Stream_Type with | ||
90 | record | ||
91 | Mode : Stream_Mode; | ||
92 | |||
93 | Buffer : Buffer_Access; | ||
94 | Rest_First : Stream_Element_Offset; | ||
95 | Rest_Last : Stream_Element_Offset; | ||
96 | -- Buffer for Read operation. | ||
97 | -- We need to have this buffer in the record | ||
98 | -- becouse not all read data from back stream | ||
99 | -- could be processed during the read operation. | ||
100 | |||
101 | Buffer_Size : Stream_Element_Offset; | ||
102 | -- Buffer size for write operation. | ||
103 | -- We do not need to have this buffer | ||
104 | -- in the record becouse all data could be | ||
105 | -- processed in the write operation. | ||
106 | |||
107 | Back : Stream_Access; | ||
108 | Reader : Filter_Type; | ||
109 | Writer : Filter_Type; | ||
110 | end record; | ||
111 | |||
112 | end ZLib.Streams; | ||
diff --git a/contrib/ada/zlib-thin.adb b/contrib/ada/zlib-thin.adb new file mode 100644 index 0000000..163bd5b --- /dev/null +++ b/contrib/ada/zlib-thin.adb | |||
@@ -0,0 +1,185 @@ | |||
1 | ---------------------------------------------------------------- | ||
2 | -- ZLib for Ada thick binding. -- | ||
3 | -- -- | ||
4 | -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
5 | -- -- | ||
6 | -- Open source license information is in the zlib.ads file. -- | ||
7 | ---------------------------------------------------------------- | ||
8 | |||
9 | -- $Id: zlib-thin.adb,v 1.6 2003/01/21 15:26:37 vagul Exp $ | ||
10 | |||
11 | package body ZLib.Thin is | ||
12 | |||
13 | ZLIB_VERSION : constant Chars_Ptr := | ||
14 | Interfaces.C.Strings.New_String ("1.1.4"); | ||
15 | |||
16 | Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit; | ||
17 | |||
18 | -------------- | ||
19 | -- Avail_In -- | ||
20 | -------------- | ||
21 | |||
22 | function Avail_In (Strm : in Z_Stream) return UInt is | ||
23 | begin | ||
24 | return Strm.Avail_In; | ||
25 | end Avail_In; | ||
26 | |||
27 | --------------- | ||
28 | -- Avail_Out -- | ||
29 | --------------- | ||
30 | |||
31 | function Avail_Out (Strm : in Z_Stream) return UInt is | ||
32 | begin | ||
33 | return Strm.Avail_Out; | ||
34 | end Avail_Out; | ||
35 | |||
36 | ------------------ | ||
37 | -- Deflate_Init -- | ||
38 | ------------------ | ||
39 | |||
40 | function Deflate_Init | ||
41 | (strm : in Z_Streamp; | ||
42 | level : in Int := Z_DEFAULT_COMPRESSION) | ||
43 | return Int is | ||
44 | begin | ||
45 | return deflateInit (strm, level, ZLIB_VERSION, Z_Stream_Size); | ||
46 | end Deflate_Init; | ||
47 | |||
48 | function Deflate_Init | ||
49 | (strm : Z_Streamp; | ||
50 | level : Int; | ||
51 | method : Int; | ||
52 | windowBits : Int; | ||
53 | memLevel : Int; | ||
54 | strategy : Int) | ||
55 | return Int is | ||
56 | begin | ||
57 | return deflateInit2 | ||
58 | (strm, | ||
59 | level, | ||
60 | method, | ||
61 | windowBits, | ||
62 | memLevel, | ||
63 | strategy, | ||
64 | ZLIB_VERSION, | ||
65 | Z_Stream_Size); | ||
66 | end Deflate_Init; | ||
67 | |||
68 | ------------------ | ||
69 | -- Inflate_Init -- | ||
70 | ------------------ | ||
71 | |||
72 | function Inflate_Init (strm : Z_Streamp) return Int is | ||
73 | begin | ||
74 | return inflateInit (strm, ZLIB_VERSION, Z_Stream_Size); | ||
75 | end Inflate_Init; | ||
76 | |||
77 | function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int is | ||
78 | begin | ||
79 | return inflateInit2 (strm, windowBits, ZLIB_VERSION, Z_Stream_Size); | ||
80 | end Inflate_Init; | ||
81 | |||
82 | function Last_Error_Message (Strm : in Z_Stream) return String is | ||
83 | use Interfaces.C.Strings; | ||
84 | begin | ||
85 | if Strm.msg = Null_Ptr then | ||
86 | return ""; | ||
87 | else | ||
88 | return Value (Strm.msg); | ||
89 | end if; | ||
90 | end Last_Error_Message; | ||
91 | |||
92 | ------------- | ||
93 | -- Need_In -- | ||
94 | ------------- | ||
95 | |||
96 | function Need_In (strm : Z_Stream) return Boolean is | ||
97 | begin | ||
98 | return strm.Avail_In = 0; | ||
99 | end Need_In; | ||
100 | |||
101 | -------------- | ||
102 | -- Need_Out -- | ||
103 | -------------- | ||
104 | |||
105 | function Need_Out (strm : Z_Stream) return Boolean is | ||
106 | begin | ||
107 | return strm.Avail_Out = 0; | ||
108 | end Need_Out; | ||
109 | |||
110 | ------------ | ||
111 | -- Set_In -- | ||
112 | ------------ | ||
113 | |||
114 | procedure Set_In | ||
115 | (Strm : in out Z_Stream; | ||
116 | Buffer : in Byte_Access; | ||
117 | Size : in UInt) is | ||
118 | begin | ||
119 | Strm.Next_In := Buffer; | ||
120 | Strm.Avail_In := Size; | ||
121 | end Set_In; | ||
122 | |||
123 | procedure Set_In | ||
124 | (Strm : in out Z_Stream; | ||
125 | Buffer : in Voidp; | ||
126 | Size : in UInt) is | ||
127 | begin | ||
128 | Set_In (Strm, Bytes.To_Pointer (Buffer), Size); | ||
129 | end Set_In; | ||
130 | |||
131 | ------------------ | ||
132 | -- Set_Mem_Func -- | ||
133 | ------------------ | ||
134 | |||
135 | procedure Set_Mem_Func | ||
136 | (Strm : in out Z_Stream; | ||
137 | Opaque : in Voidp; | ||
138 | Alloc : in alloc_func; | ||
139 | Free : in free_func) is | ||
140 | begin | ||
141 | Strm.opaque := Opaque; | ||
142 | Strm.zalloc := Alloc; | ||
143 | Strm.zfree := Free; | ||
144 | end Set_Mem_Func; | ||
145 | |||
146 | ------------- | ||
147 | -- Set_Out -- | ||
148 | ------------- | ||
149 | |||
150 | procedure Set_Out | ||
151 | (Strm : in out Z_Stream; | ||
152 | Buffer : in Byte_Access; | ||
153 | Size : in UInt) is | ||
154 | begin | ||
155 | Strm.Next_Out := Buffer; | ||
156 | Strm.Avail_Out := Size; | ||
157 | end Set_Out; | ||
158 | |||
159 | procedure Set_Out | ||
160 | (Strm : in out Z_Stream; | ||
161 | Buffer : in Voidp; | ||
162 | Size : in UInt) is | ||
163 | begin | ||
164 | Set_Out (Strm, Bytes.To_Pointer (Buffer), Size); | ||
165 | end Set_Out; | ||
166 | |||
167 | -------------- | ||
168 | -- Total_In -- | ||
169 | -------------- | ||
170 | |||
171 | function Total_In (Strm : in Z_Stream) return ULong is | ||
172 | begin | ||
173 | return Strm.Total_In; | ||
174 | end Total_In; | ||
175 | |||
176 | --------------- | ||
177 | -- Total_Out -- | ||
178 | --------------- | ||
179 | |||
180 | function Total_Out (Strm : in Z_Stream) return ULong is | ||
181 | begin | ||
182 | return Strm.Total_Out; | ||
183 | end Total_Out; | ||
184 | |||
185 | end ZLib.Thin; | ||
diff --git a/contrib/ada/zlib-thin.ads b/contrib/ada/zlib-thin.ads new file mode 100644 index 0000000..19cbb96 --- /dev/null +++ b/contrib/ada/zlib-thin.ads | |||
@@ -0,0 +1,478 @@ | |||
1 | ---------------------------------------------------------------- | ||
2 | -- ZLib for Ada thick binding. -- | ||
3 | -- -- | ||
4 | -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
5 | -- -- | ||
6 | -- Open source license information is in the zlib.ads file. -- | ||
7 | ---------------------------------------------------------------- | ||
8 | |||
9 | -- $Id: zlib-thin.ads,v 1.8 2003/08/12 13:16:51 vagul Exp $ | ||
10 | |||
11 | with Interfaces.C.Strings; | ||
12 | with System.Address_To_Access_Conversions; | ||
13 | |||
14 | private package ZLib.Thin is | ||
15 | |||
16 | -- From zconf.h | ||
17 | |||
18 | MAX_MEM_LEVEL : constant := 9; -- zconf.h:105 | ||
19 | -- zconf.h:105 | ||
20 | MAX_WBITS : constant := 15; -- zconf.h:115 | ||
21 | -- 32K LZ77 window | ||
22 | -- zconf.h:115 | ||
23 | SEEK_SET : constant := 8#0000#; -- zconf.h:244 | ||
24 | -- Seek from beginning of file. | ||
25 | -- zconf.h:244 | ||
26 | SEEK_CUR : constant := 1; -- zconf.h:245 | ||
27 | -- Seek from current position. | ||
28 | -- zconf.h:245 | ||
29 | SEEK_END : constant := 2; -- zconf.h:246 | ||
30 | -- Set file pointer to EOF plus "offset" | ||
31 | -- zconf.h:246 | ||
32 | |||
33 | type Byte is new Interfaces.C.unsigned_char; -- 8 bits | ||
34 | -- zconf.h:214 | ||
35 | type UInt is new Interfaces.C.unsigned; -- 16 bits or more | ||
36 | -- zconf.h:216 | ||
37 | type Int is new Interfaces.C.int; | ||
38 | |||
39 | type ULong is new Interfaces.C.unsigned; -- 32 bits or more | ||
40 | -- zconf.h:217 | ||
41 | subtype Chars_Ptr is Interfaces.C.Strings.chars_ptr; | ||
42 | |||
43 | type ULong_Access is access ULong; | ||
44 | type Int_Access is access Int; | ||
45 | subtype Voidp is System.Address; -- zconf.h:232 | ||
46 | |||
47 | package Bytes is new System.Address_To_Access_Conversions (Byte); | ||
48 | |||
49 | subtype Byte_Access is Bytes.Object_Pointer; | ||
50 | |||
51 | -- end from zconf | ||
52 | |||
53 | Z_NO_FLUSH : constant := 8#0000#; -- zlib.h:125 | ||
54 | -- zlib.h:125 | ||
55 | Z_PARTIAL_FLUSH : constant := 1; -- zlib.h:126 | ||
56 | -- will be removed, use | ||
57 | -- Z_SYNC_FLUSH instead | ||
58 | -- zlib.h:126 | ||
59 | Z_SYNC_FLUSH : constant := 2; -- zlib.h:127 | ||
60 | -- zlib.h:127 | ||
61 | Z_FULL_FLUSH : constant := 3; -- zlib.h:128 | ||
62 | -- zlib.h:128 | ||
63 | Z_FINISH : constant := 4; -- zlib.h:129 | ||
64 | -- zlib.h:129 | ||
65 | Z_OK : constant := 8#0000#; -- zlib.h:132 | ||
66 | -- zlib.h:132 | ||
67 | Z_STREAM_END : constant := 1; -- zlib.h:133 | ||
68 | -- zlib.h:133 | ||
69 | Z_NEED_DICT : constant := 2; -- zlib.h:134 | ||
70 | -- zlib.h:134 | ||
71 | Z_ERRNO : constant := -1; -- zlib.h:135 | ||
72 | -- zlib.h:135 | ||
73 | Z_STREAM_ERROR : constant := -2; -- zlib.h:136 | ||
74 | -- zlib.h:136 | ||
75 | Z_DATA_ERROR : constant := -3; -- zlib.h:137 | ||
76 | -- zlib.h:137 | ||
77 | Z_MEM_ERROR : constant := -4; -- zlib.h:138 | ||
78 | -- zlib.h:138 | ||
79 | Z_BUF_ERROR : constant := -5; -- zlib.h:139 | ||
80 | -- zlib.h:139 | ||
81 | Z_VERSION_ERROR : constant := -6; -- zlib.h:140 | ||
82 | -- zlib.h:140 | ||
83 | Z_NO_COMPRESSION : constant := 8#0000#; -- zlib.h:145 | ||
84 | -- zlib.h:145 | ||
85 | Z_BEST_SPEED : constant := 1; -- zlib.h:146 | ||
86 | -- zlib.h:146 | ||
87 | Z_BEST_COMPRESSION : constant := 9; -- zlib.h:147 | ||
88 | -- zlib.h:147 | ||
89 | Z_DEFAULT_COMPRESSION : constant := -1; -- zlib.h:148 | ||
90 | -- zlib.h:148 | ||
91 | Z_FILTERED : constant := 1; -- zlib.h:151 | ||
92 | -- zlib.h:151 | ||
93 | Z_HUFFMAN_ONLY : constant := 2; -- zlib.h:152 | ||
94 | -- zlib.h:152 | ||
95 | Z_DEFAULT_STRATEGY : constant := 8#0000#; -- zlib.h:153 | ||
96 | -- zlib.h:153 | ||
97 | Z_BINARY : constant := 8#0000#; -- zlib.h:156 | ||
98 | -- zlib.h:156 | ||
99 | Z_ASCII : constant := 1; -- zlib.h:157 | ||
100 | -- zlib.h:157 | ||
101 | Z_UNKNOWN : constant := 2; -- zlib.h:158 | ||
102 | -- zlib.h:158 | ||
103 | Z_DEFLATED : constant := 8; -- zlib.h:161 | ||
104 | -- zlib.h:161 | ||
105 | Z_NULL : constant := 8#0000#; -- zlib.h:164 | ||
106 | -- for initializing zalloc, zfree, opaque | ||
107 | -- zlib.h:164 | ||
108 | type gzFile is new Voidp; -- zlib.h:646 | ||
109 | |||
110 | type Z_Stream is private; | ||
111 | |||
112 | type Z_Streamp is access all Z_Stream; -- zlib.h:89 | ||
113 | |||
114 | type alloc_func is access function | ||
115 | (Opaque : Voidp; | ||
116 | Items : UInt; | ||
117 | Size : UInt) | ||
118 | return Voidp; -- zlib.h:63 | ||
119 | |||
120 | type free_func is access procedure (opaque : Voidp; address : Voidp); | ||
121 | |||
122 | function zlibVersion return Chars_Ptr; | ||
123 | |||
124 | function Deflate (strm : Z_Streamp; flush : Int) return Int; | ||
125 | |||
126 | function DeflateEnd (strm : Z_Streamp) return Int; | ||
127 | |||
128 | function Inflate (strm : Z_Streamp; flush : Int) return Int; | ||
129 | |||
130 | function InflateEnd (strm : Z_Streamp) return Int; | ||
131 | |||
132 | function deflateSetDictionary | ||
133 | (strm : Z_Streamp; | ||
134 | dictionary : Byte_Access; | ||
135 | dictLength : UInt) | ||
136 | return Int; | ||
137 | |||
138 | function deflateCopy (dest : Z_Streamp; source : Z_Streamp) return Int; | ||
139 | -- zlib.h:478 | ||
140 | |||
141 | function deflateReset (strm : Z_Streamp) return Int; -- zlib.h:495 | ||
142 | |||
143 | function deflateParams | ||
144 | (strm : Z_Streamp; | ||
145 | level : Int; | ||
146 | strategy : Int) | ||
147 | return Int; -- zlib.h:506 | ||
148 | |||
149 | function inflateSetDictionary | ||
150 | (strm : Z_Streamp; | ||
151 | dictionary : Byte_Access; | ||
152 | dictLength : UInt) | ||
153 | return Int; -- zlib.h:548 | ||
154 | |||
155 | function inflateSync (strm : Z_Streamp) return Int; -- zlib.h:565 | ||
156 | |||
157 | function inflateReset (strm : Z_Streamp) return Int; -- zlib.h:580 | ||
158 | |||
159 | function compress | ||
160 | (dest : Byte_Access; | ||
161 | destLen : ULong_Access; | ||
162 | source : Byte_Access; | ||
163 | sourceLen : ULong) | ||
164 | return Int; -- zlib.h:601 | ||
165 | |||
166 | function compress2 | ||
167 | (dest : Byte_Access; | ||
168 | destLen : ULong_Access; | ||
169 | source : Byte_Access; | ||
170 | sourceLen : ULong; | ||
171 | level : Int) | ||
172 | return Int; -- zlib.h:615 | ||
173 | |||
174 | function uncompress | ||
175 | (dest : Byte_Access; | ||
176 | destLen : ULong_Access; | ||
177 | source : Byte_Access; | ||
178 | sourceLen : ULong) | ||
179 | return Int; | ||
180 | |||
181 | function gzopen (path : Chars_Ptr; mode : Chars_Ptr) return gzFile; | ||
182 | |||
183 | function gzdopen (fd : Int; mode : Chars_Ptr) return gzFile; | ||
184 | |||
185 | function gzsetparams | ||
186 | (file : gzFile; | ||
187 | level : Int; | ||
188 | strategy : Int) | ||
189 | return Int; | ||
190 | |||
191 | function gzread | ||
192 | (file : gzFile; | ||
193 | buf : Voidp; | ||
194 | len : UInt) | ||
195 | return Int; | ||
196 | |||
197 | function gzwrite | ||
198 | (file : in gzFile; | ||
199 | buf : in Voidp; | ||
200 | len : in UInt) | ||
201 | return Int; | ||
202 | |||
203 | function gzprintf (file : in gzFile; format : in Chars_Ptr) return Int; | ||
204 | |||
205 | function gzputs (file : in gzFile; s : in Chars_Ptr) return Int; | ||
206 | |||
207 | function gzgets | ||
208 | (file : gzFile; | ||
209 | buf : Chars_Ptr; | ||
210 | len : Int) | ||
211 | return Chars_Ptr; | ||
212 | |||
213 | function gzputc (file : gzFile; char : Int) return Int; | ||
214 | |||
215 | function gzgetc (file : gzFile) return Int; | ||
216 | |||
217 | function gzflush (file : gzFile; flush : Int) return Int; | ||
218 | |||
219 | function gzseek | ||
220 | (file : gzFile; | ||
221 | offset : Int; | ||
222 | whence : Int) | ||
223 | return Int; | ||
224 | |||
225 | function gzrewind (file : gzFile) return Int; | ||
226 | |||
227 | function gztell (file : gzFile) return Int; | ||
228 | |||
229 | function gzeof (file : gzFile) return Int; | ||
230 | |||
231 | function gzclose (file : gzFile) return Int; | ||
232 | |||
233 | function gzerror (file : gzFile; errnum : Int_Access) return Chars_Ptr; | ||
234 | |||
235 | function adler32 | ||
236 | (adler : ULong; | ||
237 | buf : Byte_Access; | ||
238 | len : UInt) | ||
239 | return ULong; | ||
240 | |||
241 | function crc32 | ||
242 | (crc : ULong; | ||
243 | buf : Byte_Access; | ||
244 | len : UInt) | ||
245 | return ULong; | ||
246 | |||
247 | function deflateInit | ||
248 | (strm : Z_Streamp; | ||
249 | level : Int; | ||
250 | version : Chars_Ptr; | ||
251 | stream_size : Int) | ||
252 | return Int; | ||
253 | |||
254 | function Deflate_Init | ||
255 | (strm : in Z_Streamp; | ||
256 | level : in Int := Z_DEFAULT_COMPRESSION) | ||
257 | return Int; | ||
258 | pragma Inline (Deflate_Init); | ||
259 | |||
260 | function deflateInit2 | ||
261 | (strm : Z_Streamp; | ||
262 | level : Int; | ||
263 | method : Int; | ||
264 | windowBits : Int; | ||
265 | memLevel : Int; | ||
266 | strategy : Int; | ||
267 | version : Chars_Ptr; | ||
268 | stream_size : Int) | ||
269 | return Int; | ||
270 | |||
271 | function Deflate_Init | ||
272 | (strm : Z_Streamp; | ||
273 | level : Int; | ||
274 | method : Int; | ||
275 | windowBits : Int; | ||
276 | memLevel : Int; | ||
277 | strategy : Int) | ||
278 | return Int; | ||
279 | pragma Inline (Deflate_Init); | ||
280 | |||
281 | function inflateInit | ||
282 | (strm : Z_Streamp; | ||
283 | version : Chars_Ptr; | ||
284 | stream_size : Int) | ||
285 | return Int; | ||
286 | |||
287 | function Inflate_Init (strm : Z_Streamp) return Int; | ||
288 | pragma Inline (Inflate_Init); | ||
289 | |||
290 | function inflateInit2 | ||
291 | (strm : in Z_Streamp; | ||
292 | windowBits : in Int; | ||
293 | version : in Chars_Ptr; | ||
294 | stream_size : in Int) | ||
295 | return Int; | ||
296 | |||
297 | function inflateBackInit | ||
298 | (strm : in Z_Streamp; | ||
299 | windowBits : in Int; | ||
300 | window : in Byte_Access; | ||
301 | version : in Chars_Ptr; | ||
302 | stream_size : in Int) | ||
303 | return Int; | ||
304 | -- Size of window have to be 2**windowBits. | ||
305 | |||
306 | function Inflate_Init (strm : Z_Streamp; windowBits : Int) return Int; | ||
307 | pragma Inline (Inflate_Init); | ||
308 | |||
309 | function zError (err : Int) return Chars_Ptr; | ||
310 | |||
311 | function inflateSyncPoint (z : Z_Streamp) return Int; | ||
312 | |||
313 | function get_crc_table return ULong_Access; | ||
314 | |||
315 | -- Interface to the available fields of the z_stream structure. | ||
316 | -- The application must update next_in and avail_in when avail_in has | ||
317 | -- dropped to zero. It must update next_out and avail_out when avail_out | ||
318 | -- has dropped to zero. The application must initialize zalloc, zfree and | ||
319 | -- opaque before calling the init function. | ||
320 | |||
321 | function Need_In (strm : in Z_Stream) return Boolean; | ||
322 | -- return true when we do not need to setup Next_In and Avail_In fields. | ||
323 | pragma Inline (Need_In); | ||
324 | |||
325 | function Need_Out (strm : in Z_Stream) return Boolean; | ||
326 | -- return true when we do not need to setup Next_Out and Avail_Out field. | ||
327 | pragma Inline (Need_Out); | ||
328 | |||
329 | procedure Set_In | ||
330 | (Strm : in out Z_Stream; | ||
331 | Buffer : in Byte_Access; | ||
332 | Size : in UInt); | ||
333 | pragma Inline (Set_In); | ||
334 | |||
335 | procedure Set_In | ||
336 | (Strm : in out Z_Stream; | ||
337 | Buffer : in Voidp; | ||
338 | Size : in UInt); | ||
339 | pragma Inline (Set_In); | ||
340 | |||
341 | procedure Set_Out | ||
342 | (Strm : in out Z_Stream; | ||
343 | Buffer : in Byte_Access; | ||
344 | Size : in UInt); | ||
345 | pragma Inline (Set_Out); | ||
346 | |||
347 | procedure Set_Out | ||
348 | (Strm : in out Z_Stream; | ||
349 | Buffer : in Voidp; | ||
350 | Size : in UInt); | ||
351 | pragma Inline (Set_Out); | ||
352 | |||
353 | procedure Set_Mem_Func | ||
354 | (Strm : in out Z_Stream; | ||
355 | Opaque : in Voidp; | ||
356 | Alloc : in alloc_func; | ||
357 | Free : in free_func); | ||
358 | pragma Inline (Set_Mem_Func); | ||
359 | |||
360 | function Last_Error_Message (Strm : in Z_Stream) return String; | ||
361 | pragma Inline (Last_Error_Message); | ||
362 | |||
363 | function Avail_Out (Strm : in Z_Stream) return UInt; | ||
364 | pragma Inline (Avail_Out); | ||
365 | |||
366 | function Avail_In (Strm : in Z_Stream) return UInt; | ||
367 | pragma Inline (Avail_In); | ||
368 | |||
369 | function Total_In (Strm : in Z_Stream) return ULong; | ||
370 | pragma Inline (Total_In); | ||
371 | |||
372 | function Total_Out (Strm : in Z_Stream) return ULong; | ||
373 | pragma Inline (Total_Out); | ||
374 | |||
375 | function inflateCopy | ||
376 | (dest : in Z_Streamp; | ||
377 | Source : in Z_Streamp) | ||
378 | return Int; | ||
379 | |||
380 | function compressBound (Source_Len : in ULong) return ULong; | ||
381 | |||
382 | function deflateBound | ||
383 | (Strm : in Z_Streamp; | ||
384 | Source_Len : in ULong) | ||
385 | return ULong; | ||
386 | |||
387 | function gzungetc (C : in Int; File : in gzFile) return Int; | ||
388 | |||
389 | function zlibCompileFlags return ULong; | ||
390 | |||
391 | private | ||
392 | |||
393 | type Z_Stream is record -- zlib.h:68 | ||
394 | Next_In : Byte_Access; -- next input byte | ||
395 | Avail_In : UInt := 0; -- number of bytes available at next_in | ||
396 | Total_In : ULong := 0; -- total nb of input bytes read so far | ||
397 | Next_Out : Byte_Access; -- next output byte should be put there | ||
398 | Avail_Out : UInt := 0; -- remaining free space at next_out | ||
399 | Total_Out : ULong := 0; -- total nb of bytes output so far | ||
400 | msg : Chars_Ptr; -- last error message, NULL if no error | ||
401 | state : Voidp; -- not visible by applications | ||
402 | zalloc : alloc_func := null; -- used to allocate the internal state | ||
403 | zfree : free_func := null; -- used to free the internal state | ||
404 | opaque : Voidp; -- private data object passed to | ||
405 | -- zalloc and zfree | ||
406 | data_type : Int; -- best guess about the data type: | ||
407 | -- ascii or binary | ||
408 | adler : ULong; -- adler32 value of the uncompressed | ||
409 | -- data | ||
410 | reserved : ULong; -- reserved for future use | ||
411 | end record; | ||
412 | |||
413 | pragma Convention (C, Z_Stream); | ||
414 | |||
415 | pragma Import (C, zlibVersion, "zlibVersion"); | ||
416 | pragma Import (C, Deflate, "deflate"); | ||
417 | pragma Import (C, DeflateEnd, "deflateEnd"); | ||
418 | pragma Import (C, Inflate, "inflate"); | ||
419 | pragma Import (C, InflateEnd, "inflateEnd"); | ||
420 | pragma Import (C, deflateSetDictionary, "deflateSetDictionary"); | ||
421 | pragma Import (C, deflateCopy, "deflateCopy"); | ||
422 | pragma Import (C, deflateReset, "deflateReset"); | ||
423 | pragma Import (C, deflateParams, "deflateParams"); | ||
424 | pragma Import (C, inflateSetDictionary, "inflateSetDictionary"); | ||
425 | pragma Import (C, inflateSync, "inflateSync"); | ||
426 | pragma Import (C, inflateReset, "inflateReset"); | ||
427 | pragma Import (C, compress, "compress"); | ||
428 | pragma Import (C, compress2, "compress2"); | ||
429 | pragma Import (C, uncompress, "uncompress"); | ||
430 | pragma Import (C, gzopen, "gzopen"); | ||
431 | pragma Import (C, gzdopen, "gzdopen"); | ||
432 | pragma Import (C, gzsetparams, "gzsetparams"); | ||
433 | pragma Import (C, gzread, "gzread"); | ||
434 | pragma Import (C, gzwrite, "gzwrite"); | ||
435 | pragma Import (C, gzprintf, "gzprintf"); | ||
436 | pragma Import (C, gzputs, "gzputs"); | ||
437 | pragma Import (C, gzgets, "gzgets"); | ||
438 | pragma Import (C, gzputc, "gzputc"); | ||
439 | pragma Import (C, gzgetc, "gzgetc"); | ||
440 | pragma Import (C, gzflush, "gzflush"); | ||
441 | pragma Import (C, gzseek, "gzseek"); | ||
442 | pragma Import (C, gzrewind, "gzrewind"); | ||
443 | pragma Import (C, gztell, "gztell"); | ||
444 | pragma Import (C, gzeof, "gzeof"); | ||
445 | pragma Import (C, gzclose, "gzclose"); | ||
446 | pragma Import (C, gzerror, "gzerror"); | ||
447 | pragma Import (C, adler32, "adler32"); | ||
448 | pragma Import (C, crc32, "crc32"); | ||
449 | pragma Import (C, deflateInit, "deflateInit_"); | ||
450 | pragma Import (C, inflateInit, "inflateInit_"); | ||
451 | pragma Import (C, deflateInit2, "deflateInit2_"); | ||
452 | pragma Import (C, inflateInit2, "inflateInit2_"); | ||
453 | pragma Import (C, zError, "zError"); | ||
454 | pragma Import (C, inflateSyncPoint, "inflateSyncPoint"); | ||
455 | pragma Import (C, get_crc_table, "get_crc_table"); | ||
456 | |||
457 | -- since zlib 1.2.0: | ||
458 | |||
459 | pragma Import (C, inflateCopy, "inflateCopy"); | ||
460 | pragma Import (C, compressBound, "compressBound"); | ||
461 | pragma Import (C, deflateBound, "deflateBound"); | ||
462 | pragma Import (C, gzungetc, "gzungetc"); | ||
463 | pragma Import (C, zlibCompileFlags, "zlibCompileFlags"); | ||
464 | |||
465 | pragma Import (C, inflateBackInit, "inflateBackInit_"); | ||
466 | |||
467 | -- I stopped binding the inflateBack routines, becouse realize that | ||
468 | -- it does not support zlib and gzip headers for now, and have no | ||
469 | -- symmetric deflateBack routines. | ||
470 | -- ZLib-Ada is symmetric regarding deflate/inflate data transformation | ||
471 | -- and has a similar generic callback interface for the | ||
472 | -- deflate/inflate transformation based on the regular Deflate/Inflate | ||
473 | -- routines. | ||
474 | |||
475 | -- pragma Import (C, inflateBack, "inflateBack"); | ||
476 | -- pragma Import (C, inflateBackEnd, "inflateBackEnd"); | ||
477 | |||
478 | end ZLib.Thin; | ||
diff --git a/contrib/ada/zlib.adb b/contrib/ada/zlib.adb new file mode 100644 index 0000000..93bf885 --- /dev/null +++ b/contrib/ada/zlib.adb | |||
@@ -0,0 +1,674 @@ | |||
1 | ---------------------------------------------------------------- | ||
2 | -- ZLib for Ada thick binding. -- | ||
3 | -- -- | ||
4 | -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
5 | -- -- | ||
6 | -- Open source license information is in the zlib.ads file. -- | ||
7 | ---------------------------------------------------------------- | ||
8 | |||
9 | -- $Id: zlib.adb,v 1.19 2003/07/13 16:02:19 vagul Exp $ | ||
10 | |||
11 | with Ada.Exceptions; | ||
12 | with Ada.Unchecked_Conversion; | ||
13 | with Ada.Unchecked_Deallocation; | ||
14 | |||
15 | with Interfaces.C.Strings; | ||
16 | |||
17 | with ZLib.Thin; | ||
18 | |||
19 | package body ZLib is | ||
20 | |||
21 | use type Thin.Int; | ||
22 | |||
23 | type Z_Stream is new Thin.Z_Stream; | ||
24 | |||
25 | type Return_Code_Enum is | ||
26 | (OK, | ||
27 | STREAM_END, | ||
28 | NEED_DICT, | ||
29 | ERRNO, | ||
30 | STREAM_ERROR, | ||
31 | DATA_ERROR, | ||
32 | MEM_ERROR, | ||
33 | BUF_ERROR, | ||
34 | VERSION_ERROR); | ||
35 | |||
36 | type Flate_Step_Function is access | ||
37 | function (Strm : Thin.Z_Streamp; flush : Thin.Int) return Thin.Int; | ||
38 | pragma Convention (C, Flate_Step_Function); | ||
39 | |||
40 | type Flate_End_Function is access | ||
41 | function (Ctrm : in Thin.Z_Streamp) return Thin.Int; | ||
42 | pragma Convention (C, Flate_End_Function); | ||
43 | |||
44 | type Flate_Type is record | ||
45 | Step : Flate_Step_Function; | ||
46 | Done : Flate_End_Function; | ||
47 | end record; | ||
48 | |||
49 | subtype Footer_Array is Stream_Element_Array (1 .. 8); | ||
50 | |||
51 | Simple_GZip_Header : constant Stream_Element_Array (1 .. 10) | ||
52 | := (16#1f#, 16#8b#, -- Magic header | ||
53 | 16#08#, -- Z_DEFLATED | ||
54 | 16#00#, -- Flags | ||
55 | 16#00#, 16#00#, 16#00#, 16#00#, -- Time | ||
56 | 16#00#, -- XFlags | ||
57 | 16#03# -- OS code | ||
58 | ); | ||
59 | -- The simplest gzip header is not for informational, but just for | ||
60 | -- gzip format compatibility. | ||
61 | -- Note that some code below is using assumption | ||
62 | -- Simple_GZip_Header'Last > Footer_Array'Last, so do not make | ||
63 | -- Simple_GZip_Header'Last <= Footer_Array'Last. | ||
64 | |||
65 | Return_Code : constant array (Thin.Int range <>) of Return_Code_Enum | ||
66 | := (0 => OK, | ||
67 | 1 => STREAM_END, | ||
68 | 2 => NEED_DICT, | ||
69 | -1 => ERRNO, | ||
70 | -2 => STREAM_ERROR, | ||
71 | -3 => DATA_ERROR, | ||
72 | -4 => MEM_ERROR, | ||
73 | -5 => BUF_ERROR, | ||
74 | -6 => VERSION_ERROR); | ||
75 | |||
76 | Flate : constant array (Boolean) of Flate_Type | ||
77 | := (True => (Step => Thin.Deflate'Access, | ||
78 | Done => Thin.DeflateEnd'Access), | ||
79 | False => (Step => Thin.Inflate'Access, | ||
80 | Done => Thin.InflateEnd'Access)); | ||
81 | |||
82 | Flush_Finish : constant array (Boolean) of Flush_Mode | ||
83 | := (True => Finish, False => No_Flush); | ||
84 | |||
85 | procedure Raise_Error (Stream : Z_Stream); | ||
86 | pragma Inline (Raise_Error); | ||
87 | |||
88 | procedure Raise_Error (Message : String); | ||
89 | pragma Inline (Raise_Error); | ||
90 | |||
91 | procedure Check_Error (Stream : Z_Stream; Code : Thin.Int); | ||
92 | |||
93 | procedure Free is new Ada.Unchecked_Deallocation | ||
94 | (Z_Stream, Z_Stream_Access); | ||
95 | |||
96 | function To_Thin_Access is new Ada.Unchecked_Conversion | ||
97 | (Z_Stream_Access, Thin.Z_Streamp); | ||
98 | |||
99 | procedure Translate_GZip | ||
100 | (Filter : in out Filter_Type; | ||
101 | In_Data : in Ada.Streams.Stream_Element_Array; | ||
102 | In_Last : out Ada.Streams.Stream_Element_Offset; | ||
103 | Out_Data : out Ada.Streams.Stream_Element_Array; | ||
104 | Out_Last : out Ada.Streams.Stream_Element_Offset; | ||
105 | Flush : in Flush_Mode); | ||
106 | -- Separate translate routine for make gzip header. | ||
107 | |||
108 | procedure Translate_Auto | ||
109 | (Filter : in out Filter_Type; | ||
110 | In_Data : in Ada.Streams.Stream_Element_Array; | ||
111 | In_Last : out Ada.Streams.Stream_Element_Offset; | ||
112 | Out_Data : out Ada.Streams.Stream_Element_Array; | ||
113 | Out_Last : out Ada.Streams.Stream_Element_Offset; | ||
114 | Flush : in Flush_Mode); | ||
115 | -- translate routine without additional headers. | ||
116 | |||
117 | ----------------- | ||
118 | -- Check_Error -- | ||
119 | ----------------- | ||
120 | |||
121 | procedure Check_Error (Stream : Z_Stream; Code : Thin.Int) is | ||
122 | use type Thin.Int; | ||
123 | begin | ||
124 | if Code /= Thin.Z_OK then | ||
125 | Raise_Error | ||
126 | (Return_Code_Enum'Image (Return_Code (Code)) | ||
127 | & ": " & Last_Error_Message (Stream)); | ||
128 | end if; | ||
129 | end Check_Error; | ||
130 | |||
131 | ----------- | ||
132 | -- Close -- | ||
133 | ----------- | ||
134 | |||
135 | procedure Close | ||
136 | (Filter : in out Filter_Type; | ||
137 | Ignore_Error : in Boolean := False) | ||
138 | is | ||
139 | Code : Thin.Int; | ||
140 | begin | ||
141 | Code := Flate (Filter.Compression).Done | ||
142 | (To_Thin_Access (Filter.Strm)); | ||
143 | |||
144 | Filter.Opened := False; | ||
145 | |||
146 | if Ignore_Error or else Code = Thin.Z_OK then | ||
147 | Free (Filter.Strm); | ||
148 | else | ||
149 | declare | ||
150 | Error_Message : constant String | ||
151 | := Last_Error_Message (Filter.Strm.all); | ||
152 | begin | ||
153 | Free (Filter.Strm); | ||
154 | Ada.Exceptions.Raise_Exception | ||
155 | (ZLib_Error'Identity, | ||
156 | Return_Code_Enum'Image (Return_Code (Code)) | ||
157 | & ": " & Error_Message); | ||
158 | end; | ||
159 | end if; | ||
160 | end Close; | ||
161 | |||
162 | ----------- | ||
163 | -- CRC32 -- | ||
164 | ----------- | ||
165 | |||
166 | function CRC32 | ||
167 | (CRC : in Unsigned_32; | ||
168 | Data : in Ada.Streams.Stream_Element_Array) | ||
169 | return Unsigned_32 | ||
170 | is | ||
171 | use Thin; | ||
172 | begin | ||
173 | return Unsigned_32 (crc32 | ||
174 | (ULong (CRC), | ||
175 | Bytes.To_Pointer (Data'Address), | ||
176 | Data'Length)); | ||
177 | end CRC32; | ||
178 | |||
179 | procedure CRC32 | ||
180 | (CRC : in out Unsigned_32; | ||
181 | Data : in Ada.Streams.Stream_Element_Array) is | ||
182 | begin | ||
183 | CRC := CRC32 (CRC, Data); | ||
184 | end CRC32; | ||
185 | |||
186 | ------------------ | ||
187 | -- Deflate_Init -- | ||
188 | ------------------ | ||
189 | |||
190 | procedure Deflate_Init | ||
191 | (Filter : in out Filter_Type; | ||
192 | Level : in Compression_Level := Default_Compression; | ||
193 | Strategy : in Strategy_Type := Default_Strategy; | ||
194 | Method : in Compression_Method := Deflated; | ||
195 | Window_Bits : in Window_Bits_Type := 15; | ||
196 | Memory_Level : in Memory_Level_Type := 8; | ||
197 | Header : in Header_Type := Default) | ||
198 | is | ||
199 | use type Thin.Int; | ||
200 | Win_Bits : Thin.Int := Thin.Int (Window_Bits); | ||
201 | begin | ||
202 | -- We allow ZLib to make header only in case of default header type. | ||
203 | -- Otherwise we would either do header by ourselfs, or do not do | ||
204 | -- header at all. | ||
205 | |||
206 | if Header = None or else Header = GZip then | ||
207 | Win_Bits := -Win_Bits; | ||
208 | end if; | ||
209 | |||
210 | -- For the GZip CRC calculation and make headers. | ||
211 | |||
212 | if Header = GZip then | ||
213 | Filter.CRC := 0; | ||
214 | Filter.Offset := Simple_GZip_Header'First; | ||
215 | else | ||
216 | Filter.Offset := Simple_GZip_Header'Last + 1; | ||
217 | end if; | ||
218 | |||
219 | Filter.Strm := new Z_Stream; | ||
220 | Filter.Compression := True; | ||
221 | Filter.Stream_End := False; | ||
222 | Filter.Opened := True; | ||
223 | Filter.Header := Header; | ||
224 | |||
225 | if Thin.Deflate_Init | ||
226 | (To_Thin_Access (Filter.Strm), | ||
227 | Level => Thin.Int (Level), | ||
228 | method => Thin.Int (Method), | ||
229 | windowBits => Win_Bits, | ||
230 | memLevel => Thin.Int (Memory_Level), | ||
231 | strategy => Thin.Int (Strategy)) /= Thin.Z_OK | ||
232 | then | ||
233 | Raise_Error (Filter.Strm.all); | ||
234 | end if; | ||
235 | end Deflate_Init; | ||
236 | |||
237 | ----------- | ||
238 | -- Flush -- | ||
239 | ----------- | ||
240 | |||
241 | procedure Flush | ||
242 | (Filter : in out Filter_Type; | ||
243 | Out_Data : out Ada.Streams.Stream_Element_Array; | ||
244 | Out_Last : out Ada.Streams.Stream_Element_Offset; | ||
245 | Flush : in Flush_Mode) | ||
246 | is | ||
247 | No_Data : Stream_Element_Array := (1 .. 0 => 0); | ||
248 | Last : Stream_Element_Offset; | ||
249 | begin | ||
250 | Translate (Filter, No_Data, Last, Out_Data, Out_Last, Flush); | ||
251 | end Flush; | ||
252 | |||
253 | ----------------------- | ||
254 | -- Generic_Translate -- | ||
255 | ----------------------- | ||
256 | |||
257 | procedure Generic_Translate | ||
258 | (Filter : in out ZLib.Filter_Type; | ||
259 | In_Buffer_Size : Integer := Default_Buffer_Size; | ||
260 | Out_Buffer_Size : Integer := Default_Buffer_Size) | ||
261 | is | ||
262 | In_Buffer : Stream_Element_Array | ||
263 | (1 .. Stream_Element_Offset (In_Buffer_Size)); | ||
264 | Out_Buffer : Stream_Element_Array | ||
265 | (1 .. Stream_Element_Offset (Out_Buffer_Size)); | ||
266 | Last : Stream_Element_Offset; | ||
267 | In_Last : Stream_Element_Offset; | ||
268 | In_First : Stream_Element_Offset; | ||
269 | Out_Last : Stream_Element_Offset; | ||
270 | begin | ||
271 | Main : loop | ||
272 | Data_In (In_Buffer, Last); | ||
273 | |||
274 | In_First := In_Buffer'First; | ||
275 | |||
276 | loop | ||
277 | Translate | ||
278 | (Filter, | ||
279 | In_Buffer (In_First .. Last), | ||
280 | In_Last, | ||
281 | Out_Buffer, | ||
282 | Out_Last, | ||
283 | Flush_Finish (Last < In_Buffer'First)); | ||
284 | |||
285 | Data_Out (Out_Buffer (Out_Buffer'First .. Out_Last)); | ||
286 | |||
287 | exit Main when Stream_End (Filter); | ||
288 | |||
289 | -- The end of in buffer. | ||
290 | exit when In_Last = Last; | ||
291 | |||
292 | In_First := In_Last + 1; | ||
293 | end loop; | ||
294 | end loop Main; | ||
295 | |||
296 | end Generic_Translate; | ||
297 | |||
298 | ------------------ | ||
299 | -- Inflate_Init -- | ||
300 | ------------------ | ||
301 | |||
302 | procedure Inflate_Init | ||
303 | (Filter : in out Filter_Type; | ||
304 | Window_Bits : in Window_Bits_Type := 15; | ||
305 | Header : in Header_Type := Default) | ||
306 | is | ||
307 | use type Thin.Int; | ||
308 | Win_Bits : Thin.Int := Thin.Int (Window_Bits); | ||
309 | |||
310 | procedure Check_Version; | ||
311 | -- Check the latest header types compatibility. | ||
312 | |||
313 | procedure Check_Version is | ||
314 | begin | ||
315 | if Version <= "1.1.4" then | ||
316 | Raise_Error | ||
317 | ("Inflate header type " & Header_Type'Image (Header) | ||
318 | & " incompatible with ZLib version " & Version); | ||
319 | end if; | ||
320 | end Check_Version; | ||
321 | |||
322 | begin | ||
323 | case Header is | ||
324 | when None => | ||
325 | Check_Version; | ||
326 | |||
327 | -- Inflate data without headers determined | ||
328 | -- by negative Win_Bits. | ||
329 | |||
330 | Win_Bits := -Win_Bits; | ||
331 | when GZip => | ||
332 | Check_Version; | ||
333 | |||
334 | -- Inflate gzip data defined by flag 16. | ||
335 | |||
336 | Win_Bits := Win_Bits + 16; | ||
337 | when Auto => | ||
338 | Check_Version; | ||
339 | |||
340 | -- Inflate with automatic detection | ||
341 | -- of gzip or native header defined by flag 32. | ||
342 | |||
343 | Win_Bits := Win_Bits + 32; | ||
344 | when Default => null; | ||
345 | end case; | ||
346 | |||
347 | Filter.Strm := new Z_Stream; | ||
348 | Filter.Compression := False; | ||
349 | Filter.Stream_End := False; | ||
350 | Filter.Opened := True; | ||
351 | Filter.Header := Header; | ||
352 | |||
353 | if Thin.Inflate_Init | ||
354 | (To_Thin_Access (Filter.Strm), Win_Bits) /= Thin.Z_OK | ||
355 | then | ||
356 | Raise_Error (Filter.Strm.all); | ||
357 | end if; | ||
358 | end Inflate_Init; | ||
359 | |||
360 | ----------------- | ||
361 | -- Raise_Error -- | ||
362 | ----------------- | ||
363 | |||
364 | procedure Raise_Error (Message : String) is | ||
365 | begin | ||
366 | Ada.Exceptions.Raise_Exception (ZLib_Error'Identity, Message); | ||
367 | end Raise_Error; | ||
368 | |||
369 | procedure Raise_Error (Stream : Z_Stream) is | ||
370 | begin | ||
371 | Raise_Error (Last_Error_Message (Stream)); | ||
372 | end Raise_Error; | ||
373 | |||
374 | ---------- | ||
375 | -- Read -- | ||
376 | ---------- | ||
377 | |||
378 | procedure Read | ||
379 | (Filter : in out Filter_Type; | ||
380 | Item : out Ada.Streams.Stream_Element_Array; | ||
381 | Last : out Ada.Streams.Stream_Element_Offset) | ||
382 | is | ||
383 | In_Last : Stream_Element_Offset; | ||
384 | Item_First : Ada.Streams.Stream_Element_Offset := Item'First; | ||
385 | |||
386 | begin | ||
387 | pragma Assert (Rest_First in Buffer'First .. Buffer'Last + 1); | ||
388 | |||
389 | loop | ||
390 | if Rest_First > Buffer'Last then | ||
391 | Read (Buffer, Rest_Last); | ||
392 | Rest_First := Buffer'First; | ||
393 | end if; | ||
394 | |||
395 | pragma Assert (Rest_Last in Buffer'First - 1 .. Buffer'Last); | ||
396 | |||
397 | Translate | ||
398 | (Filter => Filter, | ||
399 | In_Data => Buffer (Rest_First .. Rest_Last), | ||
400 | In_Last => In_Last, | ||
401 | Out_Data => Item (Item_First .. Item'Last), | ||
402 | Out_Last => Last, | ||
403 | Flush => Flush_Finish (Rest_Last < Rest_First)); | ||
404 | |||
405 | Rest_First := In_Last + 1; | ||
406 | |||
407 | exit when Last = Item'Last or else Stream_End (Filter); | ||
408 | |||
409 | Item_First := Last + 1; | ||
410 | end loop; | ||
411 | end Read; | ||
412 | |||
413 | ---------------- | ||
414 | -- Stream_End -- | ||
415 | ---------------- | ||
416 | |||
417 | function Stream_End (Filter : in Filter_Type) return Boolean is | ||
418 | begin | ||
419 | if Filter.Header = GZip and Filter.Compression then | ||
420 | return Filter.Stream_End | ||
421 | and then Filter.Offset = Footer_Array'Last + 1; | ||
422 | else | ||
423 | return Filter.Stream_End; | ||
424 | end if; | ||
425 | end Stream_End; | ||
426 | |||
427 | -------------- | ||
428 | -- Total_In -- | ||
429 | -------------- | ||
430 | |||
431 | function Total_In (Filter : in Filter_Type) return Count is | ||
432 | begin | ||
433 | return Count (Thin.Total_In (To_Thin_Access (Filter.Strm).all)); | ||
434 | end Total_In; | ||
435 | |||
436 | --------------- | ||
437 | -- Total_Out -- | ||
438 | --------------- | ||
439 | |||
440 | function Total_Out (Filter : in Filter_Type) return Count is | ||
441 | begin | ||
442 | return Count (Thin.Total_Out (To_Thin_Access (Filter.Strm).all)); | ||
443 | end Total_Out; | ||
444 | |||
445 | --------------- | ||
446 | -- Translate -- | ||
447 | --------------- | ||
448 | |||
449 | procedure Translate | ||
450 | (Filter : in out Filter_Type; | ||
451 | In_Data : in Ada.Streams.Stream_Element_Array; | ||
452 | In_Last : out Ada.Streams.Stream_Element_Offset; | ||
453 | Out_Data : out Ada.Streams.Stream_Element_Array; | ||
454 | Out_Last : out Ada.Streams.Stream_Element_Offset; | ||
455 | Flush : in Flush_Mode) is | ||
456 | begin | ||
457 | if Filter.Header = GZip and then Filter.Compression then | ||
458 | Translate_GZip | ||
459 | (Filter => Filter, | ||
460 | In_Data => In_Data, | ||
461 | In_Last => In_Last, | ||
462 | Out_Data => Out_Data, | ||
463 | Out_Last => Out_Last, | ||
464 | Flush => Flush); | ||
465 | else | ||
466 | Translate_Auto | ||
467 | (Filter => Filter, | ||
468 | In_Data => In_Data, | ||
469 | In_Last => In_Last, | ||
470 | Out_Data => Out_Data, | ||
471 | Out_Last => Out_Last, | ||
472 | Flush => Flush); | ||
473 | end if; | ||
474 | end Translate; | ||
475 | |||
476 | -------------------- | ||
477 | -- Translate_Auto -- | ||
478 | -------------------- | ||
479 | |||
480 | procedure Translate_Auto | ||
481 | (Filter : in out Filter_Type; | ||
482 | In_Data : in Ada.Streams.Stream_Element_Array; | ||
483 | In_Last : out Ada.Streams.Stream_Element_Offset; | ||
484 | Out_Data : out Ada.Streams.Stream_Element_Array; | ||
485 | Out_Last : out Ada.Streams.Stream_Element_Offset; | ||
486 | Flush : in Flush_Mode) | ||
487 | is | ||
488 | use type Thin.Int; | ||
489 | Code : Thin.Int; | ||
490 | |||
491 | begin | ||
492 | if Filter.Opened = False then | ||
493 | raise ZLib_Error; | ||
494 | end if; | ||
495 | |||
496 | if Out_Data'Length = 0 then | ||
497 | raise Constraint_Error; | ||
498 | end if; | ||
499 | |||
500 | Set_Out (Filter.Strm.all, Out_Data'Address, Out_Data'Length); | ||
501 | Set_In (Filter.Strm.all, In_Data'Address, In_Data'Length); | ||
502 | |||
503 | Code := Flate (Filter.Compression).Step | ||
504 | (To_Thin_Access (Filter.Strm), | ||
505 | Thin.Int (Flush)); | ||
506 | |||
507 | if Code = Thin.Z_STREAM_END then | ||
508 | Filter.Stream_End := True; | ||
509 | else | ||
510 | Check_Error (Filter.Strm.all, Code); | ||
511 | end if; | ||
512 | |||
513 | In_Last := In_Data'Last | ||
514 | - Stream_Element_Offset (Avail_In (Filter.Strm.all)); | ||
515 | Out_Last := Out_Data'Last | ||
516 | - Stream_Element_Offset (Avail_Out (Filter.Strm.all)); | ||
517 | |||
518 | end Translate_Auto; | ||
519 | |||
520 | -------------------- | ||
521 | -- Translate_GZip -- | ||
522 | -------------------- | ||
523 | |||
524 | procedure Translate_GZip | ||
525 | (Filter : in out Filter_Type; | ||
526 | In_Data : in Ada.Streams.Stream_Element_Array; | ||
527 | In_Last : out Ada.Streams.Stream_Element_Offset; | ||
528 | Out_Data : out Ada.Streams.Stream_Element_Array; | ||
529 | Out_Last : out Ada.Streams.Stream_Element_Offset; | ||
530 | Flush : in Flush_Mode) | ||
531 | is | ||
532 | Out_First : Stream_Element_Offset; | ||
533 | |||
534 | procedure Add_Data (Data : in Stream_Element_Array); | ||
535 | -- Add data to stream from the Filter.Offset till necessary, | ||
536 | -- used for add gzip headr/footer. | ||
537 | |||
538 | procedure Put_32 | ||
539 | (Item : in out Stream_Element_Array; | ||
540 | Data : in Unsigned_32); | ||
541 | pragma Inline (Put_32); | ||
542 | |||
543 | -------------- | ||
544 | -- Add_Data -- | ||
545 | -------------- | ||
546 | |||
547 | procedure Add_Data (Data : in Stream_Element_Array) is | ||
548 | Data_First : Stream_Element_Offset renames Filter.Offset; | ||
549 | Data_Last : Stream_Element_Offset; | ||
550 | Data_Len : Stream_Element_Offset; -- -1 | ||
551 | Out_Len : Stream_Element_Offset; -- -1 | ||
552 | begin | ||
553 | Out_First := Out_Last + 1; | ||
554 | |||
555 | if Data_First > Data'Last then | ||
556 | return; | ||
557 | end if; | ||
558 | |||
559 | Data_Len := Data'Last - Data_First; | ||
560 | Out_Len := Out_Data'Last - Out_First; | ||
561 | |||
562 | if Data_Len <= Out_Len then | ||
563 | Out_Last := Out_First + Data_Len; | ||
564 | Data_Last := Data'Last; | ||
565 | else | ||
566 | Out_Last := Out_Data'Last; | ||
567 | Data_Last := Data_First + Out_Len; | ||
568 | end if; | ||
569 | |||
570 | Out_Data (Out_First .. Out_Last) := Data (Data_First .. Data_Last); | ||
571 | |||
572 | Data_First := Data_Last + 1; | ||
573 | Out_First := Out_Last + 1; | ||
574 | end Add_Data; | ||
575 | |||
576 | ------------ | ||
577 | -- Put_32 -- | ||
578 | ------------ | ||
579 | |||
580 | procedure Put_32 | ||
581 | (Item : in out Stream_Element_Array; | ||
582 | Data : in Unsigned_32) | ||
583 | is | ||
584 | D : Unsigned_32 := Data; | ||
585 | begin | ||
586 | for J in Item'First .. Item'First + 3 loop | ||
587 | Item (J) := Stream_Element (D and 16#FF#); | ||
588 | D := Shift_Right (D, 8); | ||
589 | end loop; | ||
590 | end Put_32; | ||
591 | |||
592 | begin | ||
593 | Out_Last := Out_Data'First - 1; | ||
594 | |||
595 | if not Filter.Stream_End then | ||
596 | Add_Data (Simple_GZip_Header); | ||
597 | |||
598 | Translate_Auto | ||
599 | (Filter => Filter, | ||
600 | In_Data => In_Data, | ||
601 | In_Last => In_Last, | ||
602 | Out_Data => Out_Data (Out_First .. Out_Data'Last), | ||
603 | Out_Last => Out_Last, | ||
604 | Flush => Flush); | ||
605 | |||
606 | CRC32 (Filter.CRC, In_Data (In_Data'First .. In_Last)); | ||
607 | |||
608 | end if; | ||
609 | |||
610 | if Filter.Stream_End and then Out_Last <= Out_Data'Last then | ||
611 | -- This detection method would work only when | ||
612 | -- Simple_GZip_Header'Last > Footer_Array'Last | ||
613 | |||
614 | if Filter.Offset = Simple_GZip_Header'Last + 1 then | ||
615 | Filter.Offset := Footer_Array'First; | ||
616 | end if; | ||
617 | |||
618 | declare | ||
619 | Footer : Footer_Array; | ||
620 | begin | ||
621 | Put_32 (Footer, Filter.CRC); | ||
622 | Put_32 (Footer (Footer'First + 4 .. Footer'Last), | ||
623 | Unsigned_32 (Total_In (Filter))); | ||
624 | Add_Data (Footer); | ||
625 | end; | ||
626 | end if; | ||
627 | end Translate_GZip; | ||
628 | |||
629 | ------------- | ||
630 | -- Version -- | ||
631 | ------------- | ||
632 | |||
633 | function Version return String is | ||
634 | begin | ||
635 | return Interfaces.C.Strings.Value (Thin.zlibVersion); | ||
636 | end Version; | ||
637 | |||
638 | ----------- | ||
639 | -- Write -- | ||
640 | ----------- | ||
641 | |||
642 | procedure Write | ||
643 | (Filter : in out Filter_Type; | ||
644 | Item : in Ada.Streams.Stream_Element_Array; | ||
645 | Flush : in Flush_Mode) | ||
646 | is | ||
647 | Buffer : Stream_Element_Array (1 .. Buffer_Size); | ||
648 | In_Last, Out_Last : Stream_Element_Offset; | ||
649 | In_First : Stream_Element_Offset := Item'First; | ||
650 | begin | ||
651 | if Item'Length = 0 and Flush = No_Flush then | ||
652 | return; | ||
653 | end if; | ||
654 | |||
655 | loop | ||
656 | Translate | ||
657 | (Filter => Filter, | ||
658 | In_Data => Item (In_First .. Item'Last), | ||
659 | In_Last => In_Last, | ||
660 | Out_Data => Buffer, | ||
661 | Out_Last => Out_Last, | ||
662 | Flush => Flush); | ||
663 | |||
664 | if Out_Last >= Buffer'First then | ||
665 | Write (Buffer (1 .. Out_Last)); | ||
666 | end if; | ||
667 | |||
668 | exit when In_Last = Item'Last or Stream_End (Filter); | ||
669 | |||
670 | In_First := In_Last + 1; | ||
671 | end loop; | ||
672 | end Write; | ||
673 | |||
674 | end ZLib; | ||
diff --git a/contrib/ada/zlib.ads b/contrib/ada/zlib.ads new file mode 100644 index 0000000..b72e4d2 --- /dev/null +++ b/contrib/ada/zlib.ads | |||
@@ -0,0 +1,311 @@ | |||
1 | ------------------------------------------------------------------------------ | ||
2 | -- ZLib for Ada thick binding. -- | ||
3 | -- -- | ||
4 | -- Copyright (C) 2002-2003 Dmitriy Anisimkov -- | ||
5 | -- -- | ||
6 | -- This library is free software; you can redistribute it and/or modify -- | ||
7 | -- it under the terms of the GNU General Public License as published by -- | ||
8 | -- the Free Software Foundation; either version 2 of the License, or (at -- | ||
9 | -- your option) any later version. -- | ||
10 | -- -- | ||
11 | -- This library is distributed in the hope that it will be useful, but -- | ||
12 | -- WITHOUT ANY WARRANTY; without even the implied warranty of -- | ||
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- | ||
14 | -- General Public License for more details. -- | ||
15 | -- -- | ||
16 | -- You should have received a copy of the GNU General Public License -- | ||
17 | -- along with this library; if not, write to the Free Software Foundation, -- | ||
18 | -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- | ||
19 | -- -- | ||
20 | -- As a special exception, if other files instantiate generics from this -- | ||
21 | -- unit, or you link this unit with other files to produce an executable, -- | ||
22 | -- this unit does not by itself cause the resulting executable to be -- | ||
23 | -- covered by the GNU General Public License. This exception does not -- | ||
24 | -- however invalidate any other reasons why the executable file might be -- | ||
25 | -- covered by the GNU Public License. -- | ||
26 | ------------------------------------------------------------------------------ | ||
27 | |||
28 | -- $Id: zlib.ads,v 1.17 2003/08/12 13:19:07 vagul Exp $ | ||
29 | |||
30 | with Ada.Streams; | ||
31 | |||
32 | with Interfaces; | ||
33 | |||
34 | package ZLib is | ||
35 | |||
36 | ZLib_Error : exception; | ||
37 | |||
38 | type Compression_Level is new Integer range -1 .. 9; | ||
39 | |||
40 | type Flush_Mode is private; | ||
41 | |||
42 | type Compression_Method is private; | ||
43 | |||
44 | type Window_Bits_Type is new Integer range 8 .. 15; | ||
45 | |||
46 | type Memory_Level_Type is new Integer range 1 .. 9; | ||
47 | |||
48 | type Unsigned_32 is new Interfaces.Unsigned_32; | ||
49 | |||
50 | type Strategy_Type is private; | ||
51 | |||
52 | type Header_Type is (None, Auto, Default, GZip); | ||
53 | -- Header type usage have a some limitation for inflate. | ||
54 | -- See comment for Inflate_Init. | ||
55 | |||
56 | subtype Count is Ada.Streams.Stream_Element_Count; | ||
57 | |||
58 | ---------------------------------- | ||
59 | -- Compression method constants -- | ||
60 | ---------------------------------- | ||
61 | |||
62 | Deflated : constant Compression_Method; | ||
63 | -- Only one method allowed in this ZLib version. | ||
64 | |||
65 | --------------------------------- | ||
66 | -- Compression level constants -- | ||
67 | --------------------------------- | ||
68 | |||
69 | No_Compression : constant Compression_Level := 0; | ||
70 | Best_Speed : constant Compression_Level := 1; | ||
71 | Best_Compression : constant Compression_Level := 9; | ||
72 | Default_Compression : constant Compression_Level := -1; | ||
73 | |||
74 | -------------------------- | ||
75 | -- Flush mode constants -- | ||
76 | -------------------------- | ||
77 | |||
78 | No_Flush : constant Flush_Mode; | ||
79 | -- Regular way for compression, no flush | ||
80 | |||
81 | Partial_Flush : constant Flush_Mode; | ||
82 | -- will be removed, use Z_SYNC_FLUSH instead | ||
83 | |||
84 | Sync_Flush : constant Flush_Mode; | ||
85 | -- all pending output is flushed to the output buffer and the output | ||
86 | -- is aligned on a byte boundary, so that the decompressor can get all | ||
87 | -- input data available so far. (In particular avail_in is zero after the | ||
88 | -- call if enough output space has been provided before the call.) | ||
89 | -- Flushing may degrade compression for some compression algorithms and so | ||
90 | -- it should be used only when necessary. | ||
91 | |||
92 | Full_Flush : constant Flush_Mode; | ||
93 | -- all output is flushed as with SYNC_FLUSH, and the compression state | ||
94 | -- is reset so that decompression can restart from this point if previous | ||
95 | -- compressed data has been damaged or if random access is desired. Using | ||
96 | -- FULL_FLUSH too often can seriously degrade the compression. | ||
97 | |||
98 | Finish : constant Flush_Mode; | ||
99 | -- Just for tell the compressor that input data is complete. | ||
100 | |||
101 | ------------------------------------ | ||
102 | -- Compression strategy constants -- | ||
103 | ------------------------------------ | ||
104 | |||
105 | -- RLE stategy could be used only in version 1.2.0 and later. | ||
106 | |||
107 | Filtered : constant Strategy_Type; | ||
108 | Huffman_Only : constant Strategy_Type; | ||
109 | RLE : constant Strategy_Type; | ||
110 | Default_Strategy : constant Strategy_Type; | ||
111 | |||
112 | Default_Buffer_Size : constant := 4096; | ||
113 | |||
114 | type Filter_Type is limited private; | ||
115 | -- The filter is for compression and for decompression. | ||
116 | -- The usage of the type is depend of its initialization. | ||
117 | |||
118 | function Version return String; | ||
119 | pragma Inline (Version); | ||
120 | -- Return string representation of the ZLib version. | ||
121 | |||
122 | procedure Deflate_Init | ||
123 | (Filter : in out Filter_Type; | ||
124 | Level : in Compression_Level := Default_Compression; | ||
125 | Strategy : in Strategy_Type := Default_Strategy; | ||
126 | Method : in Compression_Method := Deflated; | ||
127 | Window_Bits : in Window_Bits_Type := 15; | ||
128 | Memory_Level : in Memory_Level_Type := 8; | ||
129 | Header : in Header_Type := Default); | ||
130 | -- Compressor initialization. | ||
131 | -- When Header parameter is Auto or Default, then default zlib header | ||
132 | -- would be provided for compressed data. | ||
133 | -- When Header is GZip, then gzip header would be set instead of | ||
134 | -- default header. | ||
135 | -- When Header is None, no header would be set for compressed data. | ||
136 | |||
137 | procedure Inflate_Init | ||
138 | (Filter : in out Filter_Type; | ||
139 | Window_Bits : in Window_Bits_Type := 15; | ||
140 | Header : in Header_Type := Default); | ||
141 | -- Decompressor initialization. | ||
142 | -- Default header type mean that ZLib default header is expecting in the | ||
143 | -- input compressed stream. | ||
144 | -- Header type None mean that no header is expecting in the input stream. | ||
145 | -- GZip header type mean that GZip header is expecting in the | ||
146 | -- input compressed stream. | ||
147 | -- Auto header type mean that header type (GZip or Native) would be | ||
148 | -- detected automatically in the input stream. | ||
149 | -- Note that header types parameter values None, GZip and Auto is | ||
150 | -- supporting for inflate routine only in ZLib versions 1.2.0.2 and later. | ||
151 | -- Deflate_Init is supporting all header types. | ||
152 | |||
153 | procedure Close | ||
154 | (Filter : in out Filter_Type; | ||
155 | Ignore_Error : in Boolean := False); | ||
156 | -- Closing the compression or decompressor. | ||
157 | -- If stream is closing before the complete and Ignore_Error is False, | ||
158 | -- The exception would be raised. | ||
159 | |||
160 | generic | ||
161 | with procedure Data_In | ||
162 | (Item : out Ada.Streams.Stream_Element_Array; | ||
163 | Last : out Ada.Streams.Stream_Element_Offset); | ||
164 | with procedure Data_Out | ||
165 | (Item : in Ada.Streams.Stream_Element_Array); | ||
166 | procedure Generic_Translate | ||
167 | (Filter : in out Filter_Type; | ||
168 | In_Buffer_Size : in Integer := Default_Buffer_Size; | ||
169 | Out_Buffer_Size : in Integer := Default_Buffer_Size); | ||
170 | -- Compressing/decompressing data arrived from Data_In routine | ||
171 | -- to the Data_Out routine. User should provide Data_In and Data_Out | ||
172 | -- for compression/decompression data flow. | ||
173 | -- Compression or decompression depend on initialization of Filter. | ||
174 | |||
175 | function Total_In (Filter : in Filter_Type) return Count; | ||
176 | pragma Inline (Total_In); | ||
177 | -- Return total number of input bytes read so far. | ||
178 | |||
179 | function Total_Out (Filter : in Filter_Type) return Count; | ||
180 | pragma Inline (Total_Out); | ||
181 | -- Return total number of bytes output so far. | ||
182 | |||
183 | function CRC32 | ||
184 | (CRC : in Unsigned_32; | ||
185 | Data : in Ada.Streams.Stream_Element_Array) | ||
186 | return Unsigned_32; | ||
187 | pragma Inline (CRC32); | ||
188 | -- Calculate CRC32, it could be necessary for make gzip format. | ||
189 | |||
190 | procedure CRC32 | ||
191 | (CRC : in out Unsigned_32; | ||
192 | Data : in Ada.Streams.Stream_Element_Array); | ||
193 | pragma Inline (CRC32); | ||
194 | -- Calculate CRC32, it could be necessary for make gzip format. | ||
195 | |||
196 | ------------------------------------------------- | ||
197 | -- Below is more complex low level routines. -- | ||
198 | ------------------------------------------------- | ||
199 | |||
200 | procedure Translate | ||
201 | (Filter : in out Filter_Type; | ||
202 | In_Data : in Ada.Streams.Stream_Element_Array; | ||
203 | In_Last : out Ada.Streams.Stream_Element_Offset; | ||
204 | Out_Data : out Ada.Streams.Stream_Element_Array; | ||
205 | Out_Last : out Ada.Streams.Stream_Element_Offset; | ||
206 | Flush : in Flush_Mode); | ||
207 | -- Compressing/decompressing the datas from In_Data buffer to the | ||
208 | -- Out_Data buffer. | ||
209 | -- In_Data is incoming data portion, | ||
210 | -- In_Last is the index of last element from In_Data accepted by the | ||
211 | -- Filter. | ||
212 | -- Out_Data is the buffer for output data from the filter. | ||
213 | -- Out_Last is the last element of the received data from Filter. | ||
214 | -- To tell the filter that incoming data is complete put the | ||
215 | -- Flush parameter to FINISH. | ||
216 | |||
217 | function Stream_End (Filter : in Filter_Type) return Boolean; | ||
218 | pragma Inline (Stream_End); | ||
219 | -- Return the true when the stream is complete. | ||
220 | |||
221 | procedure Flush | ||
222 | (Filter : in out Filter_Type; | ||
223 | Out_Data : out Ada.Streams.Stream_Element_Array; | ||
224 | Out_Last : out Ada.Streams.Stream_Element_Offset; | ||
225 | Flush : in Flush_Mode); | ||
226 | pragma Inline (Flush); | ||
227 | -- Flushing the data from the compressor. | ||
228 | |||
229 | generic | ||
230 | with procedure Write | ||
231 | (Item : in Ada.Streams.Stream_Element_Array); | ||
232 | -- User should provide this routine for accept | ||
233 | -- compressed/decompressed data. | ||
234 | |||
235 | Buffer_Size : in Ada.Streams.Stream_Element_Offset | ||
236 | := Default_Buffer_Size; | ||
237 | -- Buffer size for Write user routine. | ||
238 | |||
239 | procedure Write | ||
240 | (Filter : in out Filter_Type; | ||
241 | Item : in Ada.Streams.Stream_Element_Array; | ||
242 | Flush : in Flush_Mode); | ||
243 | -- Compressing/Decompressing data from Item to the | ||
244 | -- generic parameter procedure Write. | ||
245 | -- Output buffer size could be set in Buffer_Size generic parameter. | ||
246 | |||
247 | generic | ||
248 | with procedure Read | ||
249 | (Item : out Ada.Streams.Stream_Element_Array; | ||
250 | Last : out Ada.Streams.Stream_Element_Offset); | ||
251 | -- User should provide data for compression/decompression | ||
252 | -- thru this routine. | ||
253 | |||
254 | Buffer : in out Ada.Streams.Stream_Element_Array; | ||
255 | -- Buffer for keep remaining data from the previous | ||
256 | -- back read. | ||
257 | |||
258 | Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset; | ||
259 | -- Rest_First have to be initialized to Buffer'Last + 1 | ||
260 | -- before usage. | ||
261 | |||
262 | procedure Read | ||
263 | (Filter : in out Filter_Type; | ||
264 | Item : out Ada.Streams.Stream_Element_Array; | ||
265 | Last : out Ada.Streams.Stream_Element_Offset); | ||
266 | -- Compressing/Decompressing data from generic parameter | ||
267 | -- procedure Read to the Item. | ||
268 | -- User should provide Buffer for the operation | ||
269 | -- and Rest_First variable first time initialized to the Buffer'Last + 1. | ||
270 | |||
271 | private | ||
272 | |||
273 | use Ada.Streams; | ||
274 | |||
275 | type Flush_Mode is new Integer range 0 .. 4; | ||
276 | |||
277 | type Compression_Method is new Integer range 8 .. 8; | ||
278 | |||
279 | type Strategy_Type is new Integer range 0 .. 3; | ||
280 | |||
281 | No_Flush : constant Flush_Mode := 0; | ||
282 | Sync_Flush : constant Flush_Mode := 2; | ||
283 | Full_Flush : constant Flush_Mode := 3; | ||
284 | Finish : constant Flush_Mode := 4; | ||
285 | Partial_Flush : constant Flush_Mode := 1; | ||
286 | -- will be removed, use Z_SYNC_FLUSH instead | ||
287 | |||
288 | Filtered : constant Strategy_Type := 1; | ||
289 | Huffman_Only : constant Strategy_Type := 2; | ||
290 | RLE : constant Strategy_Type := 3; | ||
291 | Default_Strategy : constant Strategy_Type := 0; | ||
292 | |||
293 | Deflated : constant Compression_Method := 8; | ||
294 | |||
295 | type Z_Stream; | ||
296 | |||
297 | type Z_Stream_Access is access all Z_Stream; | ||
298 | |||
299 | type Filter_Type is record | ||
300 | Strm : Z_Stream_Access; | ||
301 | Compression : Boolean; | ||
302 | Stream_End : Boolean; | ||
303 | Header : Header_Type; | ||
304 | CRC : Unsigned_32; | ||
305 | Offset : Stream_Element_Offset; | ||
306 | -- Offset for gzip header/footer output. | ||
307 | |||
308 | Opened : Boolean := False; | ||
309 | end record; | ||
310 | |||
311 | end ZLib; | ||
diff --git a/contrib/ada/zlib.gpr b/contrib/ada/zlib.gpr new file mode 100644 index 0000000..0f58985 --- /dev/null +++ b/contrib/ada/zlib.gpr | |||
@@ -0,0 +1,21 @@ | |||
1 | project Zlib is | ||
2 | |||
3 | for Languages use ("Ada"); | ||
4 | for Source_Dirs use ("."); | ||
5 | for Object_Dir use "."; | ||
6 | for Main use ("test.adb", "mtest.adb", "read.adb"); | ||
7 | |||
8 | package Compiler is | ||
9 | for Default_Switches ("ada") use ("-gnatwbcfilopru", "-gnatVcdfimorst", "-gnatyabcefhiklmnoprst"); | ||
10 | end Compiler; | ||
11 | |||
12 | package Linker is | ||
13 | for Default_Switches ("ada") use ("-lz"); | ||
14 | end Linker; | ||
15 | |||
16 | package Builder is | ||
17 | for Default_Switches ("ada") use ("-s", "-gnatQ"); | ||
18 | end Builder; | ||
19 | |||
20 | end Zlib; | ||
21 | |||
diff --git a/contrib/asm386/gvmat32.asm b/contrib/asm386/gvmat32.asm deleted file mode 100644 index 28d527f..0000000 --- a/contrib/asm386/gvmat32.asm +++ /dev/null | |||
@@ -1,559 +0,0 @@ | |||
1 | ; | ||
2 | ; gvmat32.asm -- Asm portion of the optimized longest_match for 32 bits x86 | ||
3 | ; Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. | ||
4 | ; File written by Gilles Vollant, by modifiying the longest_match | ||
5 | ; from Jean-loup Gailly in deflate.c | ||
6 | ; It need wmask == 0x7fff | ||
7 | ; (assembly code is faster with a fixed wmask) | ||
8 | ; | ||
9 | ; For Visual C++ 4.2 and ML 6.11c (version in directory \MASM611C of Win95 DDK) | ||
10 | ; I compile with : "ml /coff /Zi /c gvmat32.asm" | ||
11 | ; | ||
12 | |||
13 | ;uInt longest_match_7fff(s, cur_match) | ||
14 | ; deflate_state *s; | ||
15 | ; IPos cur_match; /* current match */ | ||
16 | |||
17 | NbStack equ 76 | ||
18 | cur_match equ dword ptr[esp+NbStack-0] | ||
19 | str_s equ dword ptr[esp+NbStack-4] | ||
20 | ; 5 dword on top (ret,ebp,esi,edi,ebx) | ||
21 | adrret equ dword ptr[esp+NbStack-8] | ||
22 | pushebp equ dword ptr[esp+NbStack-12] | ||
23 | pushedi equ dword ptr[esp+NbStack-16] | ||
24 | pushesi equ dword ptr[esp+NbStack-20] | ||
25 | pushebx equ dword ptr[esp+NbStack-24] | ||
26 | |||
27 | chain_length equ dword ptr [esp+NbStack-28] | ||
28 | limit equ dword ptr [esp+NbStack-32] | ||
29 | best_len equ dword ptr [esp+NbStack-36] | ||
30 | window equ dword ptr [esp+NbStack-40] | ||
31 | prev equ dword ptr [esp+NbStack-44] | ||
32 | scan_start equ word ptr [esp+NbStack-48] | ||
33 | wmask equ dword ptr [esp+NbStack-52] | ||
34 | match_start_ptr equ dword ptr [esp+NbStack-56] | ||
35 | nice_match equ dword ptr [esp+NbStack-60] | ||
36 | scan equ dword ptr [esp+NbStack-64] | ||
37 | |||
38 | windowlen equ dword ptr [esp+NbStack-68] | ||
39 | match_start equ dword ptr [esp+NbStack-72] | ||
40 | strend equ dword ptr [esp+NbStack-76] | ||
41 | NbStackAdd equ (NbStack-24) | ||
42 | |||
43 | .386p | ||
44 | |||
45 | name gvmatch | ||
46 | .MODEL FLAT | ||
47 | |||
48 | |||
49 | |||
50 | ; all the +4 offsets are due to the addition of pending_buf_size (in zlib | ||
51 | ; in the deflate_state structure since the asm code was first written | ||
52 | ; (if you compile with zlib 1.0.4 or older, remove the +4). | ||
53 | ; Note : these value are good with a 8 bytes boundary pack structure | ||
54 | dep_chain_length equ 70h+4 | ||
55 | dep_window equ 2ch+4 | ||
56 | dep_strstart equ 60h+4 | ||
57 | dep_prev_length equ 6ch+4 | ||
58 | dep_nice_match equ 84h+4 | ||
59 | dep_w_size equ 20h+4 | ||
60 | dep_prev equ 34h+4 | ||
61 | dep_w_mask equ 28h+4 | ||
62 | dep_good_match equ 80h+4 | ||
63 | dep_match_start equ 64h+4 | ||
64 | dep_lookahead equ 68h+4 | ||
65 | |||
66 | |||
67 | _TEXT segment | ||
68 | |||
69 | IFDEF NOUNDERLINE | ||
70 | public longest_match_7fff | ||
71 | ; public match_init | ||
72 | ELSE | ||
73 | public _longest_match_7fff | ||
74 | ; public _match_init | ||
75 | ENDIF | ||
76 | |||
77 | MAX_MATCH equ 258 | ||
78 | MIN_MATCH equ 3 | ||
79 | MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) | ||
80 | |||
81 | |||
82 | |||
83 | IFDEF NOUNDERLINE | ||
84 | ;match_init proc near | ||
85 | ; ret | ||
86 | ;match_init endp | ||
87 | ELSE | ||
88 | ;_match_init proc near | ||
89 | ; ret | ||
90 | ;_match_init endp | ||
91 | ENDIF | ||
92 | |||
93 | |||
94 | IFDEF NOUNDERLINE | ||
95 | longest_match_7fff proc near | ||
96 | ELSE | ||
97 | _longest_match_7fff proc near | ||
98 | ENDIF | ||
99 | |||
100 | mov edx,[esp+4] | ||
101 | |||
102 | |||
103 | |||
104 | push ebp | ||
105 | push edi | ||
106 | push esi | ||
107 | push ebx | ||
108 | |||
109 | sub esp,NbStackAdd | ||
110 | |||
111 | ; initialize or check the variables used in match.asm. | ||
112 | mov ebp,edx | ||
113 | |||
114 | ; chain_length = s->max_chain_length | ||
115 | ; if (prev_length>=good_match) chain_length >>= 2 | ||
116 | mov edx,[ebp+dep_chain_length] | ||
117 | mov ebx,[ebp+dep_prev_length] | ||
118 | cmp [ebp+dep_good_match],ebx | ||
119 | ja noshr | ||
120 | shr edx,2 | ||
121 | noshr: | ||
122 | ; we increment chain_length because in the asm, the --chain_lenght is in the beginning of the loop | ||
123 | inc edx | ||
124 | mov edi,[ebp+dep_nice_match] | ||
125 | mov chain_length,edx | ||
126 | mov eax,[ebp+dep_lookahead] | ||
127 | cmp eax,edi | ||
128 | ; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; | ||
129 | jae nolookaheadnicematch | ||
130 | mov edi,eax | ||
131 | nolookaheadnicematch: | ||
132 | ; best_len = s->prev_length | ||
133 | mov best_len,ebx | ||
134 | |||
135 | ; window = s->window | ||
136 | mov esi,[ebp+dep_window] | ||
137 | mov ecx,[ebp+dep_strstart] | ||
138 | mov window,esi | ||
139 | |||
140 | mov nice_match,edi | ||
141 | ; scan = window + strstart | ||
142 | add esi,ecx | ||
143 | mov scan,esi | ||
144 | ; dx = *window | ||
145 | mov dx,word ptr [esi] | ||
146 | ; bx = *(window+best_len-1) | ||
147 | mov bx,word ptr [esi+ebx-1] | ||
148 | add esi,MAX_MATCH-1 | ||
149 | ; scan_start = *scan | ||
150 | mov scan_start,dx | ||
151 | ; strend = scan + MAX_MATCH-1 | ||
152 | mov strend,esi | ||
153 | ; bx = scan_end = *(window+best_len-1) | ||
154 | |||
155 | ; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? | ||
156 | ; s->strstart - (IPos)MAX_DIST(s) : NIL; | ||
157 | |||
158 | mov esi,[ebp+dep_w_size] | ||
159 | sub esi,MIN_LOOKAHEAD | ||
160 | ; here esi = MAX_DIST(s) | ||
161 | sub ecx,esi | ||
162 | ja nodist | ||
163 | xor ecx,ecx | ||
164 | nodist: | ||
165 | mov limit,ecx | ||
166 | |||
167 | ; prev = s->prev | ||
168 | mov edx,[ebp+dep_prev] | ||
169 | mov prev,edx | ||
170 | |||
171 | ; | ||
172 | mov edx,dword ptr [ebp+dep_match_start] | ||
173 | mov bp,scan_start | ||
174 | mov eax,cur_match | ||
175 | mov match_start,edx | ||
176 | |||
177 | mov edx,window | ||
178 | mov edi,edx | ||
179 | add edi,best_len | ||
180 | mov esi,prev | ||
181 | dec edi | ||
182 | ; windowlen = window + best_len -1 | ||
183 | mov windowlen,edi | ||
184 | |||
185 | jmp beginloop2 | ||
186 | align 4 | ||
187 | |||
188 | ; here, in the loop | ||
189 | ; eax = ax = cur_match | ||
190 | ; ecx = limit | ||
191 | ; bx = scan_end | ||
192 | ; bp = scan_start | ||
193 | ; edi = windowlen (window + best_len -1) | ||
194 | ; esi = prev | ||
195 | |||
196 | |||
197 | ;// here; chain_length <=16 | ||
198 | normalbeg0add16: | ||
199 | add chain_length,16 | ||
200 | jz exitloop | ||
201 | normalbeg0: | ||
202 | cmp word ptr[edi+eax],bx | ||
203 | je normalbeg2noroll | ||
204 | rcontlabnoroll: | ||
205 | ; cur_match = prev[cur_match & wmask] | ||
206 | and eax,7fffh | ||
207 | mov ax,word ptr[esi+eax*2] | ||
208 | ; if cur_match > limit, go to exitloop | ||
209 | cmp ecx,eax | ||
210 | jnb exitloop | ||
211 | ; if --chain_length != 0, go to exitloop | ||
212 | dec chain_length | ||
213 | jnz normalbeg0 | ||
214 | jmp exitloop | ||
215 | |||
216 | normalbeg2noroll: | ||
217 | ; if (scan_start==*(cur_match+window)) goto normalbeg2 | ||
218 | cmp bp,word ptr[edx+eax] | ||
219 | jne rcontlabnoroll | ||
220 | jmp normalbeg2 | ||
221 | |||
222 | contloop3: | ||
223 | mov edi,windowlen | ||
224 | |||
225 | ; cur_match = prev[cur_match & wmask] | ||
226 | and eax,7fffh | ||
227 | mov ax,word ptr[esi+eax*2] | ||
228 | ; if cur_match > limit, go to exitloop | ||
229 | cmp ecx,eax | ||
230 | jnbexitloopshort1: | ||
231 | jnb exitloop | ||
232 | ; if --chain_length != 0, go to exitloop | ||
233 | |||
234 | |||
235 | ; begin the main loop | ||
236 | beginloop2: | ||
237 | sub chain_length,16+1 | ||
238 | ; if chain_length <=16, don't use the unrolled loop | ||
239 | jna normalbeg0add16 | ||
240 | |||
241 | do16: | ||
242 | cmp word ptr[edi+eax],bx | ||
243 | je normalbeg2dc0 | ||
244 | |||
245 | maccn MACRO lab | ||
246 | and eax,7fffh | ||
247 | mov ax,word ptr[esi+eax*2] | ||
248 | cmp ecx,eax | ||
249 | jnb exitloop | ||
250 | cmp word ptr[edi+eax],bx | ||
251 | je lab | ||
252 | ENDM | ||
253 | |||
254 | rcontloop0: | ||
255 | maccn normalbeg2dc1 | ||
256 | |||
257 | rcontloop1: | ||
258 | maccn normalbeg2dc2 | ||
259 | |||
260 | rcontloop2: | ||
261 | maccn normalbeg2dc3 | ||
262 | |||
263 | rcontloop3: | ||
264 | maccn normalbeg2dc4 | ||
265 | |||
266 | rcontloop4: | ||
267 | maccn normalbeg2dc5 | ||
268 | |||
269 | rcontloop5: | ||
270 | maccn normalbeg2dc6 | ||
271 | |||
272 | rcontloop6: | ||
273 | maccn normalbeg2dc7 | ||
274 | |||
275 | rcontloop7: | ||
276 | maccn normalbeg2dc8 | ||
277 | |||
278 | rcontloop8: | ||
279 | maccn normalbeg2dc9 | ||
280 | |||
281 | rcontloop9: | ||
282 | maccn normalbeg2dc10 | ||
283 | |||
284 | rcontloop10: | ||
285 | maccn short normalbeg2dc11 | ||
286 | |||
287 | rcontloop11: | ||
288 | maccn short normalbeg2dc12 | ||
289 | |||
290 | rcontloop12: | ||
291 | maccn short normalbeg2dc13 | ||
292 | |||
293 | rcontloop13: | ||
294 | maccn short normalbeg2dc14 | ||
295 | |||
296 | rcontloop14: | ||
297 | maccn short normalbeg2dc15 | ||
298 | |||
299 | rcontloop15: | ||
300 | and eax,7fffh | ||
301 | mov ax,word ptr[esi+eax*2] | ||
302 | cmp ecx,eax | ||
303 | jnb exitloop | ||
304 | |||
305 | sub chain_length,16 | ||
306 | ja do16 | ||
307 | jmp normalbeg0add16 | ||
308 | |||
309 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
310 | |||
311 | normbeg MACRO rcontlab,valsub | ||
312 | ; if we are here, we know that *(match+best_len-1) == scan_end | ||
313 | cmp bp,word ptr[edx+eax] | ||
314 | ; if (match != scan_start) goto rcontlab | ||
315 | jne rcontlab | ||
316 | ; calculate the good chain_length, and we'll compare scan and match string | ||
317 | add chain_length,16-valsub | ||
318 | jmp iseq | ||
319 | ENDM | ||
320 | |||
321 | |||
322 | normalbeg2dc11: | ||
323 | normbeg rcontloop11,11 | ||
324 | |||
325 | normalbeg2dc12: | ||
326 | normbeg short rcontloop12,12 | ||
327 | |||
328 | normalbeg2dc13: | ||
329 | normbeg short rcontloop13,13 | ||
330 | |||
331 | normalbeg2dc14: | ||
332 | normbeg short rcontloop14,14 | ||
333 | |||
334 | normalbeg2dc15: | ||
335 | normbeg short rcontloop15,15 | ||
336 | |||
337 | normalbeg2dc10: | ||
338 | normbeg rcontloop10,10 | ||
339 | |||
340 | normalbeg2dc9: | ||
341 | normbeg rcontloop9,9 | ||
342 | |||
343 | normalbeg2dc8: | ||
344 | normbeg rcontloop8,8 | ||
345 | |||
346 | normalbeg2dc7: | ||
347 | normbeg rcontloop7,7 | ||
348 | |||
349 | normalbeg2dc6: | ||
350 | normbeg rcontloop6,6 | ||
351 | |||
352 | normalbeg2dc5: | ||
353 | normbeg rcontloop5,5 | ||
354 | |||
355 | normalbeg2dc4: | ||
356 | normbeg rcontloop4,4 | ||
357 | |||
358 | normalbeg2dc3: | ||
359 | normbeg rcontloop3,3 | ||
360 | |||
361 | normalbeg2dc2: | ||
362 | normbeg rcontloop2,2 | ||
363 | |||
364 | normalbeg2dc1: | ||
365 | normbeg rcontloop1,1 | ||
366 | |||
367 | normalbeg2dc0: | ||
368 | normbeg rcontloop0,0 | ||
369 | |||
370 | |||
371 | ; we go in normalbeg2 because *(ushf*)(match+best_len-1) == scan_end | ||
372 | |||
373 | normalbeg2: | ||
374 | mov edi,window | ||
375 | |||
376 | cmp bp,word ptr[edi+eax] | ||
377 | jne contloop3 ; if *(ushf*)match != scan_start, continue | ||
378 | |||
379 | iseq: | ||
380 | ; if we are here, we know that *(match+best_len-1) == scan_end | ||
381 | ; and (match == scan_start) | ||
382 | |||
383 | mov edi,edx | ||
384 | mov esi,scan ; esi = scan | ||
385 | add edi,eax ; edi = window + cur_match = match | ||
386 | |||
387 | mov edx,[esi+3] ; compare manually dword at match+3 | ||
388 | xor edx,[edi+3] ; and scan +3 | ||
389 | |||
390 | jz begincompare ; if equal, go to long compare | ||
391 | |||
392 | ; we will determine the unmatch byte and calculate len (in esi) | ||
393 | or dl,dl | ||
394 | je eq1rr | ||
395 | mov esi,3 | ||
396 | jmp trfinval | ||
397 | eq1rr: | ||
398 | or dx,dx | ||
399 | je eq1 | ||
400 | |||
401 | mov esi,4 | ||
402 | jmp trfinval | ||
403 | eq1: | ||
404 | and edx,0ffffffh | ||
405 | jz eq11 | ||
406 | mov esi,5 | ||
407 | jmp trfinval | ||
408 | eq11: | ||
409 | mov esi,6 | ||
410 | jmp trfinval | ||
411 | |||
412 | begincompare: | ||
413 | ; here we now scan and match begin same | ||
414 | add edi,6 | ||
415 | add esi,6 | ||
416 | mov ecx,(MAX_MATCH-(2+4))/4 ; scan for at most MAX_MATCH bytes | ||
417 | repe cmpsd ; loop until mismatch | ||
418 | |||
419 | je trfin ; go to trfin if not unmatch | ||
420 | ; we determine the unmatch byte | ||
421 | sub esi,4 | ||
422 | mov edx,[edi-4] | ||
423 | xor edx,[esi] | ||
424 | |||
425 | or dl,dl | ||
426 | jnz trfin | ||
427 | inc esi | ||
428 | |||
429 | or dx,dx | ||
430 | jnz trfin | ||
431 | inc esi | ||
432 | |||
433 | and edx,0ffffffh | ||
434 | jnz trfin | ||
435 | inc esi | ||
436 | |||
437 | trfin: | ||
438 | sub esi,scan ; esi = len | ||
439 | trfinval: | ||
440 | ; here we have finised compare, and esi contain len of equal string | ||
441 | cmp esi,best_len ; if len > best_len, go newbestlen | ||
442 | ja short newbestlen | ||
443 | ; now we restore edx, ecx and esi, for the big loop | ||
444 | mov esi,prev | ||
445 | mov ecx,limit | ||
446 | mov edx,window | ||
447 | jmp contloop3 | ||
448 | |||
449 | newbestlen: | ||
450 | mov best_len,esi ; len become best_len | ||
451 | |||
452 | mov match_start,eax ; save new position as match_start | ||
453 | cmp esi,nice_match ; if best_len >= nice_match, exit | ||
454 | jae exitloop | ||
455 | mov ecx,scan | ||
456 | mov edx,window ; restore edx=window | ||
457 | add ecx,esi | ||
458 | add esi,edx | ||
459 | |||
460 | dec esi | ||
461 | mov windowlen,esi ; windowlen = window + best_len-1 | ||
462 | mov bx,[ecx-1] ; bx = *(scan+best_len-1) = scan_end | ||
463 | |||
464 | ; now we restore ecx and esi, for the big loop : | ||
465 | mov esi,prev | ||
466 | mov ecx,limit | ||
467 | jmp contloop3 | ||
468 | |||
469 | exitloop: | ||
470 | ; exit : s->match_start=match_start | ||
471 | mov ebx,match_start | ||
472 | mov ebp,str_s | ||
473 | mov ecx,best_len | ||
474 | mov dword ptr [ebp+dep_match_start],ebx | ||
475 | mov eax,dword ptr [ebp+dep_lookahead] | ||
476 | cmp ecx,eax | ||
477 | ja minexlo | ||
478 | mov eax,ecx | ||
479 | minexlo: | ||
480 | ; return min(best_len,s->lookahead) | ||
481 | |||
482 | ; restore stack and register ebx,esi,edi,ebp | ||
483 | add esp,NbStackAdd | ||
484 | |||
485 | pop ebx | ||
486 | pop esi | ||
487 | pop edi | ||
488 | pop ebp | ||
489 | ret | ||
490 | InfoAuthor: | ||
491 | ; please don't remove this string ! | ||
492 | ; Your are free use gvmat32 in any fre or commercial apps if you don't remove the string in the binary! | ||
493 | db 0dh,0ah,"GVMat32 optimised assembly code written 1996-98 by Gilles Vollant",0dh,0ah | ||
494 | |||
495 | |||
496 | |||
497 | IFDEF NOUNDERLINE | ||
498 | longest_match_7fff endp | ||
499 | ELSE | ||
500 | _longest_match_7fff endp | ||
501 | ENDIF | ||
502 | |||
503 | |||
504 | IFDEF NOUNDERLINE | ||
505 | cpudetect32 proc near | ||
506 | ELSE | ||
507 | _cpudetect32 proc near | ||
508 | ENDIF | ||
509 | |||
510 | |||
511 | pushfd ; push original EFLAGS | ||
512 | pop eax ; get original EFLAGS | ||
513 | mov ecx, eax ; save original EFLAGS | ||
514 | xor eax, 40000h ; flip AC bit in EFLAGS | ||
515 | push eax ; save new EFLAGS value on stack | ||
516 | popfd ; replace current EFLAGS value | ||
517 | pushfd ; get new EFLAGS | ||
518 | pop eax ; store new EFLAGS in EAX | ||
519 | xor eax, ecx ; can’t toggle AC bit, processor=80386 | ||
520 | jz end_cpu_is_386 ; jump if 80386 processor | ||
521 | push ecx | ||
522 | popfd ; restore AC bit in EFLAGS first | ||
523 | |||
524 | pushfd | ||
525 | pushfd | ||
526 | pop ecx | ||
527 | |||
528 | mov eax, ecx ; get original EFLAGS | ||
529 | xor eax, 200000h ; flip ID bit in EFLAGS | ||
530 | push eax ; save new EFLAGS value on stack | ||
531 | popfd ; replace current EFLAGS value | ||
532 | pushfd ; get new EFLAGS | ||
533 | pop eax ; store new EFLAGS in EAX | ||
534 | popfd ; restore original EFLAGS | ||
535 | xor eax, ecx ; can’t toggle ID bit, | ||
536 | je is_old_486 ; processor=old | ||
537 | |||
538 | mov eax,1 | ||
539 | db 0fh,0a2h ;CPUID | ||
540 | |||
541 | exitcpudetect: | ||
542 | ret | ||
543 | |||
544 | end_cpu_is_386: | ||
545 | mov eax,0300h | ||
546 | jmp exitcpudetect | ||
547 | |||
548 | is_old_486: | ||
549 | mov eax,0400h | ||
550 | jmp exitcpudetect | ||
551 | |||
552 | IFDEF NOUNDERLINE | ||
553 | cpudetect32 endp | ||
554 | ELSE | ||
555 | _cpudetect32 endp | ||
556 | ENDIF | ||
557 | |||
558 | _TEXT ends | ||
559 | end | ||
diff --git a/contrib/asm386/gvmat32c.c b/contrib/asm386/gvmat32c.c deleted file mode 100644 index d853bb7..0000000 --- a/contrib/asm386/gvmat32c.c +++ /dev/null | |||
@@ -1,200 +0,0 @@ | |||
1 | /* gvmat32.c -- C portion of the optimized longest_match for 32 bits x86 | ||
2 | * Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. | ||
3 | * File written by Gilles Vollant, by modifiying the longest_match | ||
4 | * from Jean-loup Gailly in deflate.c | ||
5 | * it prepare all parameters and call the assembly longest_match_gvasm | ||
6 | * longest_match execute standard C code is wmask != 0x7fff | ||
7 | * (assembly code is faster with a fixed wmask) | ||
8 | * | ||
9 | */ | ||
10 | |||
11 | #include "deflate.h" | ||
12 | |||
13 | #undef FAR | ||
14 | #include <windows.h> | ||
15 | |||
16 | #ifdef ASMV | ||
17 | #define NIL 0 | ||
18 | |||
19 | #define UNALIGNED_OK | ||
20 | |||
21 | |||
22 | /* if your C compiler don't add underline before function name, | ||
23 | define ADD_UNDERLINE_ASMFUNC */ | ||
24 | #ifdef ADD_UNDERLINE_ASMFUNC | ||
25 | #define longest_match_7fff _longest_match_7fff | ||
26 | #endif | ||
27 | |||
28 | |||
29 | |||
30 | void match_init() | ||
31 | { | ||
32 | } | ||
33 | |||
34 | unsigned long cpudetect32(); | ||
35 | |||
36 | uInt longest_match_c( | ||
37 | deflate_state *s, | ||
38 | IPos cur_match); /* current match */ | ||
39 | |||
40 | |||
41 | uInt longest_match_7fff( | ||
42 | deflate_state *s, | ||
43 | IPos cur_match); /* current match */ | ||
44 | |||
45 | uInt longest_match( | ||
46 | deflate_state *s, | ||
47 | IPos cur_match) /* current match */ | ||
48 | { | ||
49 | static uInt iIsPPro=2; | ||
50 | |||
51 | if ((s->w_mask == 0x7fff) && (iIsPPro==0)) | ||
52 | return longest_match_7fff(s,cur_match); | ||
53 | |||
54 | if (iIsPPro==2) | ||
55 | iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0; | ||
56 | |||
57 | return longest_match_c(s,cur_match); | ||
58 | } | ||
59 | |||
60 | |||
61 | |||
62 | uInt longest_match_c(s, cur_match) | ||
63 | deflate_state *s; | ||
64 | IPos cur_match; /* current match */ | ||
65 | { | ||
66 | unsigned chain_length = s->max_chain_length;/* max hash chain length */ | ||
67 | register Bytef *scan = s->window + s->strstart; /* current string */ | ||
68 | register Bytef *match; /* matched string */ | ||
69 | register int len; /* length of current match */ | ||
70 | int best_len = s->prev_length; /* best match length so far */ | ||
71 | int nice_match = s->nice_match; /* stop if match long enough */ | ||
72 | IPos limit = s->strstart > (IPos)MAX_DIST(s) ? | ||
73 | s->strstart - (IPos)MAX_DIST(s) : NIL; | ||
74 | /* Stop when cur_match becomes <= limit. To simplify the code, | ||
75 | * we prevent matches with the string of window index 0. | ||
76 | */ | ||
77 | Posf *prev = s->prev; | ||
78 | uInt wmask = s->w_mask; | ||
79 | |||
80 | #ifdef UNALIGNED_OK | ||
81 | /* Compare two bytes at a time. Note: this is not always beneficial. | ||
82 | * Try with and without -DUNALIGNED_OK to check. | ||
83 | */ | ||
84 | register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; | ||
85 | register ush scan_start = *(ushf*)scan; | ||
86 | register ush scan_end = *(ushf*)(scan+best_len-1); | ||
87 | #else | ||
88 | register Bytef *strend = s->window + s->strstart + MAX_MATCH; | ||
89 | register Byte scan_end1 = scan[best_len-1]; | ||
90 | register Byte scan_end = scan[best_len]; | ||
91 | #endif | ||
92 | |||
93 | /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. | ||
94 | * It is easy to get rid of this optimization if necessary. | ||
95 | */ | ||
96 | Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); | ||
97 | |||
98 | /* Do not waste too much time if we already have a good match: */ | ||
99 | if (s->prev_length >= s->good_match) { | ||
100 | chain_length >>= 2; | ||
101 | } | ||
102 | /* Do not look for matches beyond the end of the input. This is necessary | ||
103 | * to make deflate deterministic. | ||
104 | */ | ||
105 | if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; | ||
106 | |||
107 | Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); | ||
108 | |||
109 | do { | ||
110 | Assert(cur_match < s->strstart, "no future"); | ||
111 | match = s->window + cur_match; | ||
112 | |||
113 | /* Skip to next match if the match length cannot increase | ||
114 | * or if the match length is less than 2: | ||
115 | */ | ||
116 | #if (defined(UNALIGNED_OK) && MAX_MATCH == 258) | ||
117 | /* This code assumes sizeof(unsigned short) == 2. Do not use | ||
118 | * UNALIGNED_OK if your compiler uses a different size. | ||
119 | */ | ||
120 | if (*(ushf*)(match+best_len-1) != scan_end || | ||
121 | *(ushf*)match != scan_start) continue; | ||
122 | |||
123 | /* It is not necessary to compare scan[2] and match[2] since they are | ||
124 | * always equal when the other bytes match, given that the hash keys | ||
125 | * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at | ||
126 | * strstart+3, +5, ... up to strstart+257. We check for insufficient | ||
127 | * lookahead only every 4th comparison; the 128th check will be made | ||
128 | * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is | ||
129 | * necessary to put more guard bytes at the end of the window, or | ||
130 | * to check more often for insufficient lookahead. | ||
131 | */ | ||
132 | Assert(scan[2] == match[2], "scan[2]?"); | ||
133 | scan++, match++; | ||
134 | do { | ||
135 | } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && | ||
136 | *(ushf*)(scan+=2) == *(ushf*)(match+=2) && | ||
137 | *(ushf*)(scan+=2) == *(ushf*)(match+=2) && | ||
138 | *(ushf*)(scan+=2) == *(ushf*)(match+=2) && | ||
139 | scan < strend); | ||
140 | /* The funny "do {}" generates better code on most compilers */ | ||
141 | |||
142 | /* Here, scan <= window+strstart+257 */ | ||
143 | Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); | ||
144 | if (*scan == *match) scan++; | ||
145 | |||
146 | len = (MAX_MATCH - 1) - (int)(strend-scan); | ||
147 | scan = strend - (MAX_MATCH-1); | ||
148 | |||
149 | #else /* UNALIGNED_OK */ | ||
150 | |||
151 | if (match[best_len] != scan_end || | ||
152 | match[best_len-1] != scan_end1 || | ||
153 | *match != *scan || | ||
154 | *++match != scan[1]) continue; | ||
155 | |||
156 | /* The check at best_len-1 can be removed because it will be made | ||
157 | * again later. (This heuristic is not always a win.) | ||
158 | * It is not necessary to compare scan[2] and match[2] since they | ||
159 | * are always equal when the other bytes match, given that | ||
160 | * the hash keys are equal and that HASH_BITS >= 8. | ||
161 | */ | ||
162 | scan += 2, match++; | ||
163 | Assert(*scan == *match, "match[2]?"); | ||
164 | |||
165 | /* We check for insufficient lookahead only every 8th comparison; | ||
166 | * the 256th check will be made at strstart+258. | ||
167 | */ | ||
168 | do { | ||
169 | } while (*++scan == *++match && *++scan == *++match && | ||
170 | *++scan == *++match && *++scan == *++match && | ||
171 | *++scan == *++match && *++scan == *++match && | ||
172 | *++scan == *++match && *++scan == *++match && | ||
173 | scan < strend); | ||
174 | |||
175 | Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); | ||
176 | |||
177 | len = MAX_MATCH - (int)(strend - scan); | ||
178 | scan = strend - MAX_MATCH; | ||
179 | |||
180 | #endif /* UNALIGNED_OK */ | ||
181 | |||
182 | if (len > best_len) { | ||
183 | s->match_start = cur_match; | ||
184 | best_len = len; | ||
185 | if (len >= nice_match) break; | ||
186 | #ifdef UNALIGNED_OK | ||
187 | scan_end = *(ushf*)(scan+best_len-1); | ||
188 | #else | ||
189 | scan_end1 = scan[best_len-1]; | ||
190 | scan_end = scan[best_len]; | ||
191 | #endif | ||
192 | } | ||
193 | } while ((cur_match = prev[cur_match & wmask]) > limit | ||
194 | && --chain_length != 0); | ||
195 | |||
196 | if ((uInt)best_len <= s->lookahead) return (uInt)best_len; | ||
197 | return s->lookahead; | ||
198 | } | ||
199 | |||
200 | #endif /* ASMV */ | ||
diff --git a/contrib/asm386/mkgvmt32.bat b/contrib/asm386/mkgvmt32.bat deleted file mode 100644 index 6c5ffd7..0000000 --- a/contrib/asm386/mkgvmt32.bat +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | c:\masm611\bin\ml /coff /Zi /c /Flgvmat32.lst gvmat32.asm | ||
diff --git a/contrib/asm386/zlibvc.def b/contrib/asm386/zlibvc.def deleted file mode 100644 index 7e9d60d..0000000 --- a/contrib/asm386/zlibvc.def +++ /dev/null | |||
@@ -1,74 +0,0 @@ | |||
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 deleted file mode 100644 index a70d4d4..0000000 --- a/contrib/asm386/zlibvc.dsp +++ /dev/null | |||
@@ -1,651 +0,0 @@ | |||
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/asm386/zlibvc.dsw b/contrib/asm386/zlibvc.dsw deleted file mode 100644 index 493cd87..0000000 --- a/contrib/asm386/zlibvc.dsw +++ /dev/null | |||
@@ -1,41 +0,0 @@ | |||
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 | |||
diff --git a/contrib/blast/blast.c b/contrib/blast/blast.c index 67dab4e..4ce697a 100644 --- a/contrib/blast/blast.c +++ b/contrib/blast/blast.c | |||
@@ -20,36 +20,36 @@ | |||
20 | /* | 20 | /* |
21 | * Change history: | 21 | * Change history: |
22 | * | 22 | * |
23 | * 1.0 12 Feb 2003 - First version | 23 | * 1.0 12 Feb 2003 - First version |
24 | * 1.1 16 Feb 2003 - Fixed distance check for > 4 GB uncompressed data | 24 | * 1.1 16 Feb 2003 - Fixed distance check for > 4 GB uncompressed data |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */ | 27 | #include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */ |
28 | #include "blast.h" /* prototype for blast() */ | 28 | #include "blast.h" /* prototype for blast() */ |
29 | 29 | ||
30 | #define local static /* for local function definitions */ | 30 | #define local static /* for local function definitions */ |
31 | #define MAXBITS 13 /* maximum code length */ | 31 | #define MAXBITS 13 /* maximum code length */ |
32 | #define MAXWIN 4096 /* maximum window size */ | 32 | #define MAXWIN 4096 /* maximum window size */ |
33 | 33 | ||
34 | /* input and output state */ | 34 | /* input and output state */ |
35 | struct state { | 35 | struct state { |
36 | /* input state */ | 36 | /* input state */ |
37 | blast_in infun; /* input function provided by user */ | 37 | blast_in infun; /* input function provided by user */ |
38 | void *inhow; /* opaque information passed to infun() */ | 38 | void *inhow; /* opaque information passed to infun() */ |
39 | unsigned char *in; /* next input location */ | 39 | unsigned char *in; /* next input location */ |
40 | unsigned left; /* available input at in */ | 40 | unsigned left; /* available input at in */ |
41 | int bitbuf; /* bit buffer */ | 41 | int bitbuf; /* bit buffer */ |
42 | int bitcnt; /* number of bits in bit buffer */ | 42 | int bitcnt; /* number of bits in bit buffer */ |
43 | 43 | ||
44 | /* input limit error return state for bits() and decode() */ | 44 | /* input limit error return state for bits() and decode() */ |
45 | jmp_buf env; | 45 | jmp_buf env; |
46 | 46 | ||
47 | /* output state */ | 47 | /* output state */ |
48 | blast_out outfun; /* output function provided by user */ | 48 | blast_out outfun; /* output function provided by user */ |
49 | void *outhow; /* opaque information passed to outfun() */ | 49 | void *outhow; /* opaque information passed to outfun() */ |
50 | unsigned next; /* index of next write location in out[] */ | 50 | unsigned next; /* index of next write location in out[] */ |
51 | int first; /* true to check distances (for first 4K) */ | 51 | int first; /* true to check distances (for first 4K) */ |
52 | unsigned char out[MAXWIN]; /* output buffer and sliding window */ | 52 | unsigned char out[MAXWIN]; /* output buffer and sliding window */ |
53 | }; | 53 | }; |
54 | 54 | ||
55 | /* | 55 | /* |
@@ -65,16 +65,16 @@ struct state { | |||
65 | */ | 65 | */ |
66 | local int bits(struct state *s, int need) | 66 | local int bits(struct state *s, int need) |
67 | { | 67 | { |
68 | int val; /* bit accumulator */ | 68 | int val; /* bit accumulator */ |
69 | 69 | ||
70 | /* load at least need bits into val */ | 70 | /* load at least need bits into val */ |
71 | val = s->bitbuf; | 71 | val = s->bitbuf; |
72 | while (s->bitcnt < need) { | 72 | while (s->bitcnt < need) { |
73 | if (s->left == 0) { | 73 | if (s->left == 0) { |
74 | s->left = s->infun(s->inhow, &(s->in)); | 74 | s->left = s->infun(s->inhow, &(s->in)); |
75 | if (s->left == 0) longjmp(s->env, 1); /* out of input */ | 75 | if (s->left == 0) longjmp(s->env, 1); /* out of input */ |
76 | } | 76 | } |
77 | val |= (int)(*(s->in)++) << s->bitcnt; /* load eight bits */ | 77 | val |= (int)(*(s->in)++) << s->bitcnt; /* load eight bits */ |
78 | s->left--; | 78 | s->left--; |
79 | s->bitcnt += 8; | 79 | s->bitcnt += 8; |
80 | } | 80 | } |
@@ -95,8 +95,8 @@ local int bits(struct state *s, int need) | |||
95 | * seen in the function decode() below. | 95 | * seen in the function decode() below. |
96 | */ | 96 | */ |
97 | struct huffman { | 97 | struct huffman { |
98 | short *count; /* number of symbols of each length */ | 98 | short *count; /* number of symbols of each length */ |
99 | short *symbol; /* canonically ordered symbols */ | 99 | short *symbol; /* canonically ordered symbols */ |
100 | }; | 100 | }; |
101 | 101 | ||
102 | /* | 102 | /* |
@@ -122,14 +122,14 @@ struct huffman { | |||
122 | */ | 122 | */ |
123 | local int decode(struct state *s, struct huffman *h) | 123 | local int decode(struct state *s, struct huffman *h) |
124 | { | 124 | { |
125 | int len; /* current number of bits in code */ | 125 | int len; /* current number of bits in code */ |
126 | int code; /* len bits being decoded */ | 126 | int code; /* len bits being decoded */ |
127 | int first; /* first code of length len */ | 127 | int first; /* first code of length len */ |
128 | int count; /* number of codes of length len */ | 128 | int count; /* number of codes of length len */ |
129 | int index; /* index of first code of length len in symbol table */ | 129 | int index; /* index of first code of length len in symbol table */ |
130 | int bitbuf; /* bits from stream */ | 130 | int bitbuf; /* bits from stream */ |
131 | int left; /* bits left in next or left to process */ | 131 | int left; /* bits left in next or left to process */ |
132 | short *next; /* next number of codes */ | 132 | short *next; /* next number of codes */ |
133 | 133 | ||
134 | bitbuf = s->bitbuf; | 134 | bitbuf = s->bitbuf; |
135 | left = s->bitcnt; | 135 | left = s->bitcnt; |
@@ -138,15 +138,15 @@ local int decode(struct state *s, struct huffman *h) | |||
138 | next = h->count + 1; | 138 | next = h->count + 1; |
139 | while (1) { | 139 | while (1) { |
140 | while (left--) { | 140 | while (left--) { |
141 | code |= (bitbuf & 1) ^ 1; /* invert code */ | 141 | code |= (bitbuf & 1) ^ 1; /* invert code */ |
142 | bitbuf >>= 1; | 142 | bitbuf >>= 1; |
143 | count = *next++; | 143 | count = *next++; |
144 | if (code < first + count) { /* if length len, return symbol */ | 144 | if (code < first + count) { /* if length len, return symbol */ |
145 | s->bitbuf = bitbuf; | 145 | s->bitbuf = bitbuf; |
146 | s->bitcnt = (s->bitcnt - len) & 7; | 146 | s->bitcnt = (s->bitcnt - len) & 7; |
147 | return h->symbol[index + (code - first)]; | 147 | return h->symbol[index + (code - first)]; |
148 | } | 148 | } |
149 | index += count; /* else update for next length */ | 149 | index += count; /* else update for next length */ |
150 | first += count; | 150 | first += count; |
151 | first <<= 1; | 151 | first <<= 1; |
152 | code <<= 1; | 152 | code <<= 1; |
@@ -156,13 +156,13 @@ local int decode(struct state *s, struct huffman *h) | |||
156 | if (left == 0) break; | 156 | if (left == 0) break; |
157 | if (s->left == 0) { | 157 | if (s->left == 0) { |
158 | s->left = s->infun(s->inhow, &(s->in)); | 158 | s->left = s->infun(s->inhow, &(s->in)); |
159 | if (s->left == 0) longjmp(s->env, 1); /* out of input */ | 159 | if (s->left == 0) longjmp(s->env, 1); /* out of input */ |
160 | } | 160 | } |
161 | bitbuf = *(s->in)++; | 161 | bitbuf = *(s->in)++; |
162 | s->left--; | 162 | s->left--; |
163 | if (left > 8) left = 8; | 163 | if (left > 8) left = 8; |
164 | } | 164 | } |
165 | return -9; /* ran out of codes */ | 165 | return -9; /* ran out of codes */ |
166 | } | 166 | } |
167 | 167 | ||
168 | /* | 168 | /* |
@@ -184,11 +184,11 @@ local int decode(struct state *s, struct huffman *h) | |||
184 | */ | 184 | */ |
185 | local int construct(struct huffman *h, const unsigned char *rep, int n) | 185 | local int construct(struct huffman *h, const unsigned char *rep, int n) |
186 | { | 186 | { |
187 | int symbol; /* current symbol when stepping through length[] */ | 187 | int symbol; /* current symbol when stepping through length[] */ |
188 | int len; /* current length when stepping through h->count[] */ | 188 | int len; /* current length when stepping through h->count[] */ |
189 | int left; /* number of possible codes left of current length */ | 189 | int left; /* number of possible codes left of current length */ |
190 | short offs[MAXBITS+1]; /* offsets in symbol table for each length */ | 190 | short offs[MAXBITS+1]; /* offsets in symbol table for each length */ |
191 | short length[256]; /* code lengths */ | 191 | short length[256]; /* code lengths */ |
192 | 192 | ||
193 | /* convert compact repeat counts into symbol bit length list */ | 193 | /* convert compact repeat counts into symbol bit length list */ |
194 | symbol = 0; | 194 | symbol = 0; |
@@ -206,17 +206,17 @@ local int construct(struct huffman *h, const unsigned char *rep, int n) | |||
206 | for (len = 0; len <= MAXBITS; len++) | 206 | for (len = 0; len <= MAXBITS; len++) |
207 | h->count[len] = 0; | 207 | h->count[len] = 0; |
208 | for (symbol = 0; symbol < n; symbol++) | 208 | for (symbol = 0; symbol < n; symbol++) |
209 | (h->count[length[symbol]])++; /* assumes lengths are within bounds */ | 209 | (h->count[length[symbol]])++; /* assumes lengths are within bounds */ |
210 | if (h->count[0] == n) /* no codes! */ | 210 | if (h->count[0] == n) /* no codes! */ |
211 | return 0; /* complete, but decode() will fail */ | 211 | return 0; /* complete, but decode() will fail */ |
212 | 212 | ||
213 | /* check for an over-subscribed or incomplete set of lengths */ | 213 | /* check for an over-subscribed or incomplete set of lengths */ |
214 | left = 1; /* one possible code of zero length */ | 214 | left = 1; /* one possible code of zero length */ |
215 | for (len = 1; len <= MAXBITS; len++) { | 215 | for (len = 1; len <= MAXBITS; len++) { |
216 | left <<= 1; /* one more bit, double codes left */ | 216 | left <<= 1; /* one more bit, double codes left */ |
217 | left -= h->count[len]; /* deduct count from possible codes */ | 217 | left -= h->count[len]; /* deduct count from possible codes */ |
218 | if (left < 0) return left; /* over-subscribed--return negative */ | 218 | if (left < 0) return left; /* over-subscribed--return negative */ |
219 | } /* left > 0 means incomplete */ | 219 | } /* left > 0 means incomplete */ |
220 | 220 | ||
221 | /* generate offsets into symbol table for each length for sorting */ | 221 | /* generate offsets into symbol table for each length for sorting */ |
222 | offs[1] = 0; | 222 | offs[1] = 0; |
@@ -275,35 +275,35 @@ local int construct(struct huffman *h, const unsigned char *rep, int n) | |||
275 | */ | 275 | */ |
276 | local int decomp(struct state *s) | 276 | local int decomp(struct state *s) |
277 | { | 277 | { |
278 | int lit; /* true if literals are coded */ | 278 | int lit; /* true if literals are coded */ |
279 | int dict; /* log2(dictionary size) - 6 */ | 279 | int dict; /* log2(dictionary size) - 6 */ |
280 | int symbol; /* decoded symbol, extra bits for distance */ | 280 | int symbol; /* decoded symbol, extra bits for distance */ |
281 | int len; /* length for copy */ | 281 | int len; /* length for copy */ |
282 | int dist; /* distance for copy */ | 282 | int dist; /* distance for copy */ |
283 | int copy; /* copy counter */ | 283 | int copy; /* copy counter */ |
284 | unsigned char *from, *to; /* copy pointers */ | 284 | unsigned char *from, *to; /* copy pointers */ |
285 | static int virgin = 1; /* build tables once */ | 285 | static int virgin = 1; /* build tables once */ |
286 | static short litcnt[MAXBITS+1], litsym[256]; /* litcode memory */ | 286 | static short litcnt[MAXBITS+1], litsym[256]; /* litcode memory */ |
287 | static short lencnt[MAXBITS+1], lensym[16]; /* lencode memory */ | 287 | static short lencnt[MAXBITS+1], lensym[16]; /* lencode memory */ |
288 | static short distcnt[MAXBITS+1], distsym[64]; /* distcode memory */ | 288 | static short distcnt[MAXBITS+1], distsym[64]; /* distcode memory */ |
289 | static struct huffman litcode = {litcnt, litsym}; /* length code */ | 289 | static struct huffman litcode = {litcnt, litsym}; /* length code */ |
290 | static struct huffman lencode = {lencnt, lensym}; /* length code */ | 290 | static struct huffman lencode = {lencnt, lensym}; /* length code */ |
291 | static struct huffman distcode = {distcnt, distsym};/* distance code */ | 291 | static struct huffman distcode = {distcnt, distsym};/* distance code */ |
292 | /* bit lengths of literal codes */ | 292 | /* bit lengths of literal codes */ |
293 | static const unsigned char litlen[] = { | 293 | static const unsigned char litlen[] = { |
294 | 11, 124, 8, 7, 28, 7, 188, 13, 76, 4, 10, 8, 12, 10, 12, 10, 8, 23, 8, | 294 | 11, 124, 8, 7, 28, 7, 188, 13, 76, 4, 10, 8, 12, 10, 12, 10, 8, 23, 8, |
295 | 9, 7, 6, 7, 8, 7, 6, 55, 8, 23, 24, 12, 11, 7, 9, 11, 12, 6, 7, 22, 5, | 295 | 9, 7, 6, 7, 8, 7, 6, 55, 8, 23, 24, 12, 11, 7, 9, 11, 12, 6, 7, 22, 5, |
296 | 7, 24, 6, 11, 9, 6, 7, 22, 7, 11, 38, 7, 9, 8, 25, 11, 8, 11, 9, 12, | 296 | 7, 24, 6, 11, 9, 6, 7, 22, 7, 11, 38, 7, 9, 8, 25, 11, 8, 11, 9, 12, |
297 | 8, 12, 5, 38, 5, 38, 5, 11, 7, 5, 6, 21, 6, 10, 53, 8, 7, 24, 10, 27, | 297 | 8, 12, 5, 38, 5, 38, 5, 11, 7, 5, 6, 21, 6, 10, 53, 8, 7, 24, 10, 27, |
298 | 44, 253, 253, 253, 252, 252, 252, 13, 12, 45, 12, 45, 12, 61, 12, 45, | 298 | 44, 253, 253, 253, 252, 252, 252, 13, 12, 45, 12, 45, 12, 61, 12, 45, |
299 | 44, 173}; | 299 | 44, 173}; |
300 | /* bit lengths of length codes 0..15 */ | 300 | /* bit lengths of length codes 0..15 */ |
301 | static const unsigned char lenlen[] = {2, 35, 36, 53, 38, 23}; | 301 | static const unsigned char lenlen[] = {2, 35, 36, 53, 38, 23}; |
302 | /* bit lengths of distance codes 0..63 */ | 302 | /* bit lengths of distance codes 0..63 */ |
303 | static const unsigned char distlen[] = {2, 20, 53, 230, 247, 151, 248}; | 303 | static const unsigned char distlen[] = {2, 20, 53, 230, 247, 151, 248}; |
304 | static const short base[16] = { /* base for length codes */ | 304 | static const short base[16] = { /* base for length codes */ |
305 | 3, 2, 4, 5, 6, 7, 8, 9, 10, 12, 16, 24, 40, 72, 136, 264}; | 305 | 3, 2, 4, 5, 6, 7, 8, 9, 10, 12, 16, 24, 40, 72, 136, 264}; |
306 | static const char extra[16] = { /* extra bits for length codes */ | 306 | static const char extra[16] = { /* extra bits for length codes */ |
307 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8}; | 307 | 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8}; |
308 | 308 | ||
309 | /* set up decoding tables (once--might not be thread-safe) */ | 309 | /* set up decoding tables (once--might not be thread-safe) */ |
@@ -326,7 +326,7 @@ local int decomp(struct state *s) | |||
326 | /* get length */ | 326 | /* get length */ |
327 | symbol = decode(s, &lencode); | 327 | symbol = decode(s, &lencode); |
328 | len = base[symbol] + bits(s, extra[symbol]); | 328 | len = base[symbol] + bits(s, extra[symbol]); |
329 | if (len == 519) break; /* end code */ | 329 | if (len == 519) break; /* end code */ |
330 | 330 | ||
331 | /* get distance */ | 331 | /* get distance */ |
332 | symbol = len == 2 ? 2 : dict; | 332 | symbol = len == 2 ? 2 : dict; |
@@ -334,7 +334,7 @@ local int decomp(struct state *s) | |||
334 | dist += bits(s, symbol); | 334 | dist += bits(s, symbol); |
335 | dist++; | 335 | dist++; |
336 | if (s->first && dist > s->next) | 336 | if (s->first && dist > s->next) |
337 | return -3; /* distance too far back */ | 337 | return -3; /* distance too far back */ |
338 | 338 | ||
339 | /* copy length bytes from distance bytes back */ | 339 | /* copy length bytes from distance bytes back */ |
340 | do { | 340 | do { |
@@ -376,8 +376,8 @@ local int decomp(struct state *s) | |||
376 | /* See comments in blast.h */ | 376 | /* See comments in blast.h */ |
377 | int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow) | 377 | int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow) |
378 | { | 378 | { |
379 | struct state s; /* input/output state */ | 379 | struct state s; /* input/output state */ |
380 | int err; /* return value */ | 380 | int err; /* return value */ |
381 | 381 | ||
382 | /* initialize input state */ | 382 | /* initialize input state */ |
383 | s.infun = infun; | 383 | s.infun = infun; |
@@ -393,10 +393,10 @@ int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow) | |||
393 | s.first = 1; | 393 | s.first = 1; |
394 | 394 | ||
395 | /* return if bits() or decode() tries to read past available input */ | 395 | /* return if bits() or decode() tries to read past available input */ |
396 | if (setjmp(s.env) != 0) /* if came back here via longjmp(), */ | 396 | if (setjmp(s.env) != 0) /* if came back here via longjmp(), */ |
397 | err = 2; /* then skip decomp(), return error */ | 397 | err = 2; /* then skip decomp(), return error */ |
398 | else | 398 | else |
399 | err = decomp(&s); /* decompress */ | 399 | err = decomp(&s); /* decompress */ |
400 | 400 | ||
401 | /* write any leftover output and update the error code if needed */ | 401 | /* write any leftover output and update the error code if needed */ |
402 | if (err != 1 && s.next && s.outfun(s.outhow, s.out, s.next) && err == 0) | 402 | if (err != 1 && s.next && s.outfun(s.outhow, s.out, s.next) && err == 0) |
diff --git a/contrib/blast/blast.h b/contrib/blast/blast.h index 2417837..ce9e541 100644 --- a/contrib/blast/blast.h +++ b/contrib/blast/blast.h | |||
@@ -18,7 +18,7 @@ | |||
18 | misrepresented as being the original software. | 18 | misrepresented as being the original software. |
19 | 3. This notice may not be removed or altered from any source distribution. | 19 | 3. This notice may not be removed or altered from any source distribution. |
20 | 20 | ||
21 | Mark Adler madler@alumni.caltech.edu | 21 | Mark Adler madler@alumni.caltech.edu |
22 | */ | 22 | */ |
23 | 23 | ||
24 | 24 | ||
diff --git a/contrib/delphi2/zlib.pas b/contrib/delphi/ZLib.pas index 10ae4ca..ea9a17f 100644 --- a/contrib/delphi2/zlib.pas +++ b/contrib/delphi/ZLib.pas | |||
@@ -1,33 +1,33 @@ | |||
1 | {*******************************************************} | 1 | {*******************************************************} |
2 | { } | 2 | { } |
3 | { Delphi Supplemental Components } | 3 | { Borland Delphi Supplemental Components } |
4 | { ZLIB Data Compression Interface Unit } | 4 | { ZLIB Data Compression Interface Unit } |
5 | { } | 5 | { } |
6 | { Copyright (c) 1997 Borland International } | 6 | { Copyright (c) 1997,99 Borland Corporation } |
7 | { } | 7 | { } |
8 | {*******************************************************} | 8 | {*******************************************************} |
9 | 9 | ||
10 | { Modified for zlib 1.1.3 by Davide Moretti <dave@rimini.com } | 10 | { Updated for zlib 1.2.x by Cosmin Truta <cosmint@cs.ubbcluj.ro> } |
11 | 11 | ||
12 | unit zlib; | 12 | unit ZLib; |
13 | 13 | ||
14 | interface | 14 | interface |
15 | 15 | ||
16 | uses Sysutils, Classes; | 16 | uses SysUtils, Classes; |
17 | 17 | ||
18 | type | 18 | type |
19 | TAlloc = function (AppData: Pointer; Items, Size: Integer): Pointer; | 19 | TAlloc = function (AppData: Pointer; Items, Size: Integer): Pointer; cdecl; |
20 | TFree = procedure (AppData, Block: Pointer); | 20 | TFree = procedure (AppData, Block: Pointer); cdecl; |
21 | 21 | ||
22 | // Internal structure. Ignore. | 22 | // Internal structure. Ignore. |
23 | TZStreamRec = packed record | 23 | TZStreamRec = packed record |
24 | next_in: PChar; // next input byte | 24 | next_in: PChar; // next input byte |
25 | avail_in: Integer; // number of bytes available at next_in | 25 | avail_in: Integer; // number of bytes available at next_in |
26 | total_in: Integer; // total nb of input bytes read so far | 26 | total_in: Longint; // total nb of input bytes read so far |
27 | 27 | ||
28 | next_out: PChar; // next output byte should be put here | 28 | next_out: PChar; // next output byte should be put here |
29 | avail_out: Integer; // remaining free space at next_out | 29 | avail_out: Integer; // remaining free space at next_out |
30 | total_out: Integer; // total nb of bytes output so far | 30 | total_out: Longint; // total nb of bytes output so far |
31 | 31 | ||
32 | msg: PChar; // last error message, NULL if no error | 32 | msg: PChar; // last error message, NULL if no error |
33 | internal: Pointer; // not visible by applications | 33 | internal: Pointer; // not visible by applications |
@@ -36,9 +36,9 @@ type | |||
36 | zfree: TFree; // used to free the internal state | 36 | zfree: TFree; // used to free the internal state |
37 | AppData: Pointer; // private data object passed to zalloc and zfree | 37 | AppData: Pointer; // private data object passed to zalloc and zfree |
38 | 38 | ||
39 | data_type: Integer; // best guess about the data type: ascii or binary | 39 | data_type: Integer; // best guess about the data type: ascii or binary |
40 | adler: Integer; // adler32 value of the uncompressed data | 40 | adler: Longint; // adler32 value of the uncompressed data |
41 | reserved: Integer; // reserved for future use | 41 | reserved: Longint; // reserved for future use |
42 | end; | 42 | end; |
43 | 43 | ||
44 | // Abstract ancestor class | 44 | // Abstract ancestor class |
@@ -143,18 +143,26 @@ procedure CompressBuf(const InBuf: Pointer; InBytes: Integer; | |||
143 | procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer; | 143 | procedure DecompressBuf(const InBuf: Pointer; InBytes: Integer; |
144 | OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer); | 144 | OutEstimate: Integer; out OutBuf: Pointer; out OutBytes: Integer); |
145 | 145 | ||
146 | { DecompressToUserBuf decompresses data, buffer to buffer, in one call. | ||
147 | In: InBuf = ptr to compressed data | ||
148 | InBytes = number of bytes in InBuf | ||
149 | Out: OutBuf = ptr to user-allocated buffer to contain decompressed data | ||
150 | BufSize = number of bytes in OutBuf } | ||
151 | procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer; | ||
152 | const OutBuf: Pointer; BufSize: Integer); | ||
153 | |||
146 | const | 154 | const |
147 | zlib_version = '1.1.3'; | 155 | zlib_version = '1.2.0'; |
148 | 156 | ||
149 | type | 157 | type |
150 | EZlibError = class(Exception); | 158 | EZlibError = class(Exception); |
151 | ECompressionError = class(EZlibError); | 159 | ECompressionError = class(EZlibError); |
152 | EDecompressionError = class(EZlibError); | 160 | EDecompressionError = class(EZlibError); |
153 | 161 | ||
154 | function adler32(adler: Integer; buf: PChar; len: Integer): Integer; | ||
155 | |||
156 | implementation | 162 | implementation |
157 | 163 | ||
164 | uses ZLibConst; | ||
165 | |||
158 | const | 166 | const |
159 | Z_NO_FLUSH = 0; | 167 | Z_NO_FLUSH = 0; |
160 | Z_PARTIAL_FLUSH = 1; | 168 | Z_PARTIAL_FLUSH = 1; |
@@ -179,6 +187,7 @@ const | |||
179 | 187 | ||
180 | Z_FILTERED = 1; | 188 | Z_FILTERED = 1; |
181 | Z_HUFFMAN_ONLY = 2; | 189 | Z_HUFFMAN_ONLY = 2; |
190 | Z_RLE = 3; | ||
182 | Z_DEFAULT_STRATEGY = 0; | 191 | Z_DEFAULT_STRATEGY = 0; |
183 | 192 | ||
184 | Z_BINARY = 0; | 193 | Z_BINARY = 0; |
@@ -187,56 +196,41 @@ const | |||
187 | 196 | ||
188 | Z_DEFLATED = 8; | 197 | Z_DEFLATED = 8; |
189 | 198 | ||
190 | _z_errmsg: array[0..9] of PChar = ( | ||
191 | 'need dictionary', // Z_NEED_DICT (2) | ||
192 | 'stream end', // Z_STREAM_END (1) | ||
193 | '', // Z_OK (0) | ||
194 | 'file error', // Z_ERRNO (-1) | ||
195 | 'stream error', // Z_STREAM_ERROR (-2) | ||
196 | 'data error', // Z_DATA_ERROR (-3) | ||
197 | 'insufficient memory', // Z_MEM_ERROR (-4) | ||
198 | 'buffer error', // Z_BUF_ERROR (-5) | ||
199 | 'incompatible version', // Z_VERSION_ERROR (-6) | ||
200 | '' | ||
201 | ); | ||
202 | 199 | ||
200 | {$L adler32.obj} | ||
201 | {$L compress.obj} | ||
202 | {$L crc32.obj} | ||
203 | {$L deflate.obj} | 203 | {$L deflate.obj} |
204 | {$L infback.obj} | ||
205 | {$L inffast.obj} | ||
204 | {$L inflate.obj} | 206 | {$L inflate.obj} |
205 | {$L inftrees.obj} | 207 | {$L inftrees.obj} |
206 | {$L trees.obj} | 208 | {$L trees.obj} |
207 | {$L adler32.obj} | 209 | {$L uncompr.obj} |
208 | {$L infblock.obj} | 210 | {$L zutil.obj} |
209 | {$L infcodes.obj} | 211 | |
210 | {$L infutil.obj} | 212 | procedure adler32; external; |
211 | {$L inffast.obj} | 213 | procedure compressBound; external; |
214 | procedure crc32; external; | ||
215 | procedure deflateInit2_; external; | ||
216 | procedure deflateParams; external; | ||
212 | 217 | ||
213 | procedure _tr_init; external; | 218 | function _malloc(Size: Integer): Pointer; cdecl; |
214 | procedure _tr_tally; external; | 219 | begin |
215 | procedure _tr_flush_block; external; | 220 | Result := AllocMem(Size); |
216 | procedure _tr_align; external; | 221 | end; |
217 | procedure _tr_stored_block; external; | 222 | |
218 | function adler32; external; | 223 | procedure _free(Block: Pointer); cdecl; |
219 | procedure inflate_blocks_new; external; | 224 | begin |
220 | procedure inflate_blocks; external; | 225 | FreeMem(Block); |
221 | procedure inflate_blocks_reset; external; | 226 | end; |
222 | procedure inflate_blocks_free; external; | 227 | |
223 | procedure inflate_set_dictionary; external; | 228 | procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl; |
224 | procedure inflate_trees_bits; external; | ||
225 | procedure inflate_trees_dynamic; external; | ||
226 | procedure inflate_trees_fixed; external; | ||
227 | procedure inflate_codes_new; external; | ||
228 | procedure inflate_codes; external; | ||
229 | procedure inflate_codes_free; external; | ||
230 | procedure _inflate_mask; external; | ||
231 | procedure inflate_flush; external; | ||
232 | procedure inflate_fast; external; | ||
233 | |||
234 | procedure _memset(P: Pointer; B: Byte; count: Integer);cdecl; | ||
235 | begin | 229 | begin |
236 | FillChar(P^, count, B); | 230 | FillChar(P^, count, B); |
237 | end; | 231 | end; |
238 | 232 | ||
239 | procedure _memcpy(dest, source: Pointer; count: Integer);cdecl; | 233 | procedure _memcpy(dest, source: Pointer; count: Integer); cdecl; |
240 | begin | 234 | begin |
241 | Move(source^, dest^, count); | 235 | Move(source^, dest^, count); |
242 | end; | 236 | end; |
@@ -257,22 +251,23 @@ function inflateEnd(var strm: TZStreamRec): Integer; external; | |||
257 | function inflateReset(var strm: TZStreamRec): Integer; external; | 251 | function inflateReset(var strm: TZStreamRec): Integer; external; |
258 | 252 | ||
259 | 253 | ||
260 | function zcalloc(AppData: Pointer; Items, Size: Integer): Pointer; | 254 | function zlibAllocMem(AppData: Pointer; Items, Size: Integer): Pointer; cdecl; |
261 | begin | 255 | begin |
262 | GetMem(Result, Items*Size); | 256 | // GetMem(Result, Items*Size); |
257 | Result := AllocMem(Items * Size); | ||
263 | end; | 258 | end; |
264 | 259 | ||
265 | procedure zcfree(AppData, Block: Pointer); | 260 | procedure zlibFreeMem(AppData, Block: Pointer); cdecl; |
266 | begin | 261 | begin |
267 | FreeMem(Block); | 262 | FreeMem(Block); |
268 | end; | 263 | end; |
269 | 264 | ||
270 | function zlibCheck(code: Integer): Integer; | 265 | {function zlibCheck(code: Integer): Integer; |
271 | begin | 266 | begin |
272 | Result := code; | 267 | Result := code; |
273 | if code < 0 then | 268 | if code < 0 then |
274 | raise EZlibError.Create('error'); //!! | 269 | raise EZlibError.Create('error'); //!! |
275 | end; | 270 | end;} |
276 | 271 | ||
277 | function CCheck(code: Integer): Integer; | 272 | function CCheck(code: Integer): Integer; |
278 | begin | 273 | begin |
@@ -295,6 +290,8 @@ var | |||
295 | P: Pointer; | 290 | P: Pointer; |
296 | begin | 291 | begin |
297 | FillChar(strm, sizeof(strm), 0); | 292 | FillChar(strm, sizeof(strm), 0); |
293 | strm.zalloc := zlibAllocMem; | ||
294 | strm.zfree := zlibFreeMem; | ||
298 | OutBytes := ((InBytes + (InBytes div 10) + 12) + 255) and not 255; | 295 | OutBytes := ((InBytes + (InBytes div 10) + 12) + 255) and not 255; |
299 | GetMem(OutBuf, OutBytes); | 296 | GetMem(OutBuf, OutBytes); |
300 | try | 297 | try |
@@ -332,6 +329,8 @@ var | |||
332 | BufInc: Integer; | 329 | BufInc: Integer; |
333 | begin | 330 | begin |
334 | FillChar(strm, sizeof(strm), 0); | 331 | FillChar(strm, sizeof(strm), 0); |
332 | strm.zalloc := zlibAllocMem; | ||
333 | strm.zfree := zlibFreeMem; | ||
335 | BufInc := (InBytes + 255) and not 255; | 334 | BufInc := (InBytes + 255) and not 255; |
336 | if OutEstimate = 0 then | 335 | if OutEstimate = 0 then |
337 | OutBytes := BufInc | 336 | OutBytes := BufInc |
@@ -364,6 +363,26 @@ begin | |||
364 | end; | 363 | end; |
365 | end; | 364 | end; |
366 | 365 | ||
366 | procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer; | ||
367 | const OutBuf: Pointer; BufSize: Integer); | ||
368 | var | ||
369 | strm: TZStreamRec; | ||
370 | begin | ||
371 | FillChar(strm, sizeof(strm), 0); | ||
372 | strm.zalloc := zlibAllocMem; | ||
373 | strm.zfree := zlibFreeMem; | ||
374 | strm.next_in := InBuf; | ||
375 | strm.avail_in := InBytes; | ||
376 | strm.next_out := OutBuf; | ||
377 | strm.avail_out := BufSize; | ||
378 | DCheck(inflateInit_(strm, zlib_version, sizeof(strm))); | ||
379 | try | ||
380 | if DCheck(inflate(strm, Z_FINISH)) <> Z_STREAM_END then | ||
381 | raise EZlibError.CreateRes(@sTargetBufferTooSmall); | ||
382 | finally | ||
383 | DCheck(inflateEnd(strm)); | ||
384 | end; | ||
385 | end; | ||
367 | 386 | ||
368 | // TCustomZlibStream | 387 | // TCustomZlibStream |
369 | 388 | ||
@@ -372,6 +391,8 @@ begin | |||
372 | inherited Create; | 391 | inherited Create; |
373 | FStrm := Strm; | 392 | FStrm := Strm; |
374 | FStrmPos := Strm.Position; | 393 | FStrmPos := Strm.Position; |
394 | FZRec.zalloc := zlibAllocMem; | ||
395 | FZRec.zfree := zlibFreeMem; | ||
375 | end; | 396 | end; |
376 | 397 | ||
377 | procedure TCustomZLibStream.Progress(Sender: TObject); | 398 | procedure TCustomZLibStream.Progress(Sender: TObject); |
@@ -417,7 +438,7 @@ end; | |||
417 | 438 | ||
418 | function TCompressionStream.Read(var Buffer; Count: Longint): Longint; | 439 | function TCompressionStream.Read(var Buffer; Count: Longint): Longint; |
419 | begin | 440 | begin |
420 | raise ECompressionError.Create('Invalid stream operation'); | 441 | raise ECompressionError.CreateRes(@sInvalidStreamOp); |
421 | end; | 442 | end; |
422 | 443 | ||
423 | function TCompressionStream.Write(const Buffer; Count: Longint): Longint; | 444 | function TCompressionStream.Write(const Buffer; Count: Longint): Longint; |
@@ -445,7 +466,7 @@ begin | |||
445 | if (Offset = 0) and (Origin = soFromCurrent) then | 466 | if (Offset = 0) and (Origin = soFromCurrent) then |
446 | Result := FZRec.total_in | 467 | Result := FZRec.total_in |
447 | else | 468 | else |
448 | raise ECompressionError.Create('Invalid stream operation'); | 469 | raise ECompressionError.CreateRes(@sInvalidStreamOp); |
449 | end; | 470 | end; |
450 | 471 | ||
451 | function TCompressionStream.GetCompressionRate: Single; | 472 | function TCompressionStream.GetCompressionRate: Single; |
@@ -469,6 +490,7 @@ end; | |||
469 | 490 | ||
470 | destructor TDecompressionStream.Destroy; | 491 | destructor TDecompressionStream.Destroy; |
471 | begin | 492 | begin |
493 | FStrm.Seek(-FZRec.avail_in, 1); | ||
472 | inflateEnd(FZRec); | 494 | inflateEnd(FZRec); |
473 | inherited Destroy; | 495 | inherited Destroy; |
474 | end; | 496 | end; |
@@ -484,22 +506,22 @@ begin | |||
484 | begin | 506 | begin |
485 | FZRec.avail_in := FStrm.Read(FBuffer, sizeof(FBuffer)); | 507 | FZRec.avail_in := FStrm.Read(FBuffer, sizeof(FBuffer)); |
486 | if FZRec.avail_in = 0 then | 508 | if FZRec.avail_in = 0 then |
487 | begin | 509 | begin |
488 | Result := Count - FZRec.avail_out; | 510 | Result := Count - FZRec.avail_out; |
489 | Exit; | 511 | Exit; |
490 | end; | 512 | end; |
491 | FZRec.next_in := FBuffer; | 513 | FZRec.next_in := FBuffer; |
492 | FStrmPos := FStrm.Position; | 514 | FStrmPos := FStrm.Position; |
493 | Progress(Self); | 515 | Progress(Self); |
494 | end; | 516 | end; |
495 | DCheck(inflate(FZRec, 0)); | 517 | CCheck(inflate(FZRec, 0)); |
496 | end; | 518 | end; |
497 | Result := Count; | 519 | Result := Count; |
498 | end; | 520 | end; |
499 | 521 | ||
500 | function TDecompressionStream.Write(const Buffer; Count: Longint): Longint; | 522 | function TDecompressionStream.Write(const Buffer; Count: Longint): Longint; |
501 | begin | 523 | begin |
502 | raise EDecompressionError.Create('Invalid stream operation'); | 524 | raise EDecompressionError.CreateRes(@sInvalidStreamOp); |
503 | end; | 525 | end; |
504 | 526 | ||
505 | function TDecompressionStream.Seek(Offset: Longint; Origin: Word): Longint; | 527 | function TDecompressionStream.Seek(Offset: Longint; Origin: Word): Longint; |
@@ -527,8 +549,9 @@ begin | |||
527 | end; | 549 | end; |
528 | end | 550 | end |
529 | else | 551 | else |
530 | raise EDecompressionError.Create('Invalid stream operation'); | 552 | raise EDecompressionError.CreateRes(@sInvalidStreamOp); |
531 | Result := FZRec.total_out; | 553 | Result := FZRec.total_out; |
532 | end; | 554 | end; |
533 | 555 | ||
556 | |||
534 | end. | 557 | end. |
diff --git a/contrib/delphi/ZLibConst.pas b/contrib/delphi/ZLibConst.pas new file mode 100644 index 0000000..cdfe136 --- /dev/null +++ b/contrib/delphi/ZLibConst.pas | |||
@@ -0,0 +1,11 @@ | |||
1 | unit ZLibConst; | ||
2 | |||
3 | interface | ||
4 | |||
5 | resourcestring | ||
6 | sTargetBufferTooSmall = 'ZLib error: target buffer may be too small'; | ||
7 | sInvalidStreamOp = 'Invalid stream operation'; | ||
8 | |||
9 | implementation | ||
10 | |||
11 | end. | ||
diff --git a/contrib/delphi/readme.txt b/contrib/delphi/readme.txt new file mode 100644 index 0000000..65e58b3 --- /dev/null +++ b/contrib/delphi/readme.txt | |||
@@ -0,0 +1,76 @@ | |||
1 | |||
2 | Overview | ||
3 | ======== | ||
4 | |||
5 | This directory contains an update to the ZLib interface unit, | ||
6 | distributed by Borland as a Delphi supplemental component. | ||
7 | |||
8 | The original ZLib unit is Copyright (c) 1997,99 Borland Corp., | ||
9 | and is based on zlib version 1.0.4. There are a series of bugs | ||
10 | and security problems associated with that old zlib version, and | ||
11 | we recommend the users to update their ZLib unit. | ||
12 | |||
13 | |||
14 | Summary of modifications | ||
15 | ======================== | ||
16 | |||
17 | - Improved makefile, adapted to zlib version 1.2.0. | ||
18 | |||
19 | - Some field types from TZStreamRec are changed from Integer to | ||
20 | Longint, for consistency with the zlib.h header, and for 64-bit | ||
21 | readiness. | ||
22 | |||
23 | - The zlib_version constant is updated. | ||
24 | |||
25 | - The new Z_RLE strategy has its corresponding symbolic constant. | ||
26 | |||
27 | - The allocation and deallocation functions and function types | ||
28 | (TAlloc, TFree, zlibAllocMem and zlibFreeMem) are now cdecl, | ||
29 | and _malloc and _free are added as C RTL stubs. As a result, | ||
30 | the original C sources of zlib can be compiled out of the box, | ||
31 | and linked to the ZLib unit. | ||
32 | |||
33 | |||
34 | Suggestions for improvements | ||
35 | ============================ | ||
36 | |||
37 | Currently, the ZLib unit provides only a limited wrapper around | ||
38 | the zlib library, and much of the original zlib functionality is | ||
39 | missing. Handling compressed file formats like ZIP/GZIP or PNG | ||
40 | cannot be implemented without having this functionality. | ||
41 | Applications that handle these formats are either using their own, | ||
42 | duplicated code, or not using the ZLib unit at all. | ||
43 | |||
44 | Here are a few suggestions: | ||
45 | |||
46 | - Checksum class wrappers around adler32() and crc32(), similar | ||
47 | to the Java classes that implement the java.util.zip.Checksum | ||
48 | interface. | ||
49 | |||
50 | - The ability to read and write raw deflate streams, without the | ||
51 | zlib stream header and trailer. Raw deflate streams are used | ||
52 | in the ZIP file format. | ||
53 | |||
54 | - The ability to read and write gzip streams, used in the GZIP | ||
55 | file format, and normally produced by the gzip program. | ||
56 | |||
57 | - The ability to select a different compression strategy, useful | ||
58 | to PNG and MNG image compression, and to multimedia compression | ||
59 | in general. Besides the compression level | ||
60 | |||
61 | TCompressionLevel = (clNone, clFastest, clDefault, clMax); | ||
62 | |||
63 | which, in fact, could have used the 'z' prefix and avoided | ||
64 | TColor-like symbols | ||
65 | |||
66 | TCompressionLevel = (zcNone, zcFastest, zcDefault, zcMax); | ||
67 | |||
68 | there could be a compression strategy | ||
69 | |||
70 | TCompressionStrategy = (zsDefault, zsFiltered, zsHuffmanOnly, zsRle); | ||
71 | |||
72 | - ZIP and GZIP stream handling via TStreams. | ||
73 | |||
74 | |||
75 | -- | ||
76 | Cosmin Truta <cosmint@cs.ubbcluj.ro> | ||
diff --git a/contrib/delphi/zlib.mak b/contrib/delphi/zlib.mak deleted file mode 100644 index ba557e2..0000000 --- a/contrib/delphi/zlib.mak +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | # Makefile for zlib32bd.lib | ||
2 | # ------------- Borland C++ 4.5 ------------- | ||
3 | |||
4 | # The (32-bit) zlib32bd.lib made with this makefile is intended for use | ||
5 | # in making the (32-bit) DLL, png32bd.dll. It uses the "stdcall" calling | ||
6 | # convention. | ||
7 | |||
8 | CFLAGS= -ps -O2 -C -K -N- -k- -d -3 -r- -w-par -w-aus -WDE | ||
9 | CC=f:\bc45\bin\bcc32 | ||
10 | LIBFLAGS= /C | ||
11 | LIB=f:\bc45\bin\tlib | ||
12 | ZLIB=zlib32bd.lib | ||
13 | |||
14 | .autodepend | ||
15 | .c.obj: | ||
16 | $(CC) -c $(CFLAGS) $< | ||
17 | |||
18 | OBJ1=adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infblock.obj | ||
19 | OBJ2=infcodes.obj inflate.obj inftrees.obj infutil.obj inffast.obj | ||
20 | OBJ3=trees.obj uncompr.obj zutil.obj | ||
21 | pOBJ1=+adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infblock.obj | ||
22 | pOBJ2=+infcodes.obj+inflate.obj+inftrees.obj+infutil.obj+inffast.obj | ||
23 | pOBJ3=+trees.obj+uncompr.obj+zutil.obj | ||
24 | |||
25 | all: $(ZLIB) | ||
26 | |||
27 | $(ZLIB): $(OBJ1) $(OBJ2) $(OBJ3) | ||
28 | @if exist $@ del $@ | ||
29 | $(LIB) @&&| | ||
30 | $@ $(LIBFLAGS) & | ||
31 | $(pOBJ1) & | ||
32 | $(pOBJ2) & | ||
33 | $(pOBJ3) | ||
34 | | | ||
35 | |||
36 | # End of makefile for zlib32bd.lib | ||
diff --git a/contrib/delphi/zlibd32.mak b/contrib/delphi/zlibd32.mak new file mode 100644 index 0000000..88fafa0 --- /dev/null +++ b/contrib/delphi/zlibd32.mak | |||
@@ -0,0 +1,93 @@ | |||
1 | # Makefile for zlib | ||
2 | # For use with Delphi and C++ Builder under Win32 | ||
3 | # Updated for zlib 1.2.x by Cosmin Truta | ||
4 | |||
5 | # ------------ Borland C++ ------------ | ||
6 | |||
7 | # This project uses the Delphi (fastcall/register) calling convention: | ||
8 | LOC = -DZEXPORT=__fastcall -DZEXPORTVA=__cdecl | ||
9 | |||
10 | CC = bcc32 | ||
11 | LD = bcc32 | ||
12 | AR = tlib | ||
13 | # do not use "-pr" in CFLAGS | ||
14 | CFLAGS = -a -d -k- -O2 $(LOC) | ||
15 | LDFLAGS = | ||
16 | |||
17 | |||
18 | # variables | ||
19 | ZLIB_LIB = zlib.lib | ||
20 | |||
21 | OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj | ||
22 | OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj | ||
23 | OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj | ||
24 | OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj | ||
25 | |||
26 | |||
27 | # targets | ||
28 | all: $(ZLIB_LIB) example.exe minigzip.exe | ||
29 | |||
30 | .c.obj: | ||
31 | $(CC) -c $(CFLAGS) $*.c | ||
32 | |||
33 | adler32.obj: adler32.c zlib.h zconf.h | ||
34 | |||
35 | compress.obj: compress.c zlib.h zconf.h | ||
36 | |||
37 | crc32.obj: crc32.c zlib.h zconf.h crc32.h | ||
38 | |||
39 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h | ||
40 | |||
41 | gzio.obj: gzio.c zutil.h zlib.h zconf.h | ||
42 | |||
43 | infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | ||
44 | inffast.h inffixed.h | ||
45 | |||
46 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | ||
47 | inffast.h | ||
48 | |||
49 | inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | ||
50 | inffast.h inffixed.h | ||
51 | |||
52 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h | ||
53 | |||
54 | trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h | ||
55 | |||
56 | uncompr.obj: uncompr.c zlib.h zconf.h | ||
57 | |||
58 | zutil.obj: zutil.c zutil.h zlib.h zconf.h | ||
59 | |||
60 | example.obj: example.c zlib.h zconf.h | ||
61 | |||
62 | minigzip.obj: minigzip.c zlib.h zconf.h | ||
63 | |||
64 | |||
65 | # For the sake of the old Borland make, | ||
66 | # the command line is cut to fit in the MS-DOS 128 byte limit: | ||
67 | $(ZLIB_LIB): $(OBJ1) $(OBJ2) | ||
68 | -del $(ZLIB_LIB) | ||
69 | $(AR) $(ZLIB_LIB) $(OBJP1) | ||
70 | $(AR) $(ZLIB_LIB) $(OBJP2) | ||
71 | |||
72 | |||
73 | # testing | ||
74 | test: example.exe minigzip.exe | ||
75 | example | ||
76 | echo hello world | minigzip | minigzip -d | ||
77 | |||
78 | example.exe: example.obj $(ZLIB_LIB) | ||
79 | $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) | ||
80 | |||
81 | minigzip.exe: minigzip.obj $(ZLIB_LIB) | ||
82 | $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) | ||
83 | |||
84 | |||
85 | # cleanup | ||
86 | clean: | ||
87 | -del *.obj | ||
88 | -del *.exe | ||
89 | -del *.lib | ||
90 | -del *.tds | ||
91 | -del zlib.bak | ||
92 | -del foo.gz | ||
93 | |||
diff --git a/contrib/delphi/zlibdef.pas b/contrib/delphi/zlibdef.pas deleted file mode 100644 index 4f96b7d..0000000 --- a/contrib/delphi/zlibdef.pas +++ /dev/null | |||
@@ -1,169 +0,0 @@ | |||
1 | unit zlibdef; | ||
2 | |||
3 | interface | ||
4 | |||
5 | uses | ||
6 | Windows; | ||
7 | |||
8 | const | ||
9 | ZLIB_VERSION = '1.1.3'; | ||
10 | |||
11 | type | ||
12 | voidpf = Pointer; | ||
13 | int = Integer; | ||
14 | uInt = Cardinal; | ||
15 | pBytef = PChar; | ||
16 | uLong = Cardinal; | ||
17 | |||
18 | alloc_func = function(opaque: voidpf; items, size: uInt): voidpf; | ||
19 | stdcall; | ||
20 | free_func = procedure(opaque, address: voidpf); | ||
21 | stdcall; | ||
22 | |||
23 | internal_state = Pointer; | ||
24 | |||
25 | z_streamp = ^z_stream; | ||
26 | z_stream = packed record | ||
27 | next_in: pBytef; // next input byte | ||
28 | avail_in: uInt; // number of bytes available at next_in | ||
29 | total_in: uLong; // total nb of input bytes read so far | ||
30 | |||
31 | next_out: pBytef; // next output byte should be put there | ||
32 | avail_out: uInt; // remaining free space at next_out | ||
33 | total_out: uLong; // total nb of bytes output so far | ||
34 | |||
35 | msg: PChar; // last error message, NULL if no error | ||
36 | state: internal_state; // not visible by applications | ||
37 | |||
38 | zalloc: alloc_func; // used to allocate the internal state | ||
39 | zfree: free_func; // used to free the internal state | ||
40 | opaque: voidpf; // private data object passed to zalloc and zfree | ||
41 | |||
42 | data_type: int; // best guess about the data type: ascii or binary | ||
43 | adler: uLong; // adler32 value of the uncompressed data | ||
44 | reserved: uLong; // reserved for future use | ||
45 | end; | ||
46 | |||
47 | const | ||
48 | Z_NO_FLUSH = 0; | ||
49 | Z_SYNC_FLUSH = 2; | ||
50 | Z_FULL_FLUSH = 3; | ||
51 | Z_FINISH = 4; | ||
52 | |||
53 | Z_OK = 0; | ||
54 | Z_STREAM_END = 1; | ||
55 | |||
56 | Z_NO_COMPRESSION = 0; | ||
57 | Z_BEST_SPEED = 1; | ||
58 | Z_BEST_COMPRESSION = 9; | ||
59 | Z_DEFAULT_COMPRESSION = -1; | ||
60 | |||
61 | Z_FILTERED = 1; | ||
62 | Z_HUFFMAN_ONLY = 2; | ||
63 | Z_DEFAULT_STRATEGY = 0; | ||
64 | |||
65 | Z_BINARY = 0; | ||
66 | Z_ASCII = 1; | ||
67 | Z_UNKNOWN = 2; | ||
68 | |||
69 | Z_DEFLATED = 8; | ||
70 | |||
71 | MAX_MEM_LEVEL = 9; | ||
72 | |||
73 | function adler32(adler: uLong; const buf: pBytef; len: uInt): uLong; | ||
74 | stdcall; | ||
75 | function crc32(crc: uLong; const buf: pBytef; len: uInt): uLong; | ||
76 | stdcall; | ||
77 | function deflate(strm: z_streamp; flush: int): int; | ||
78 | stdcall; | ||
79 | function deflateCopy(dest, source: z_streamp): int; | ||
80 | stdcall; | ||
81 | function deflateEnd(strm: z_streamp): int; | ||
82 | stdcall; | ||
83 | function deflateInit2_(strm: z_streamp; level, method, | ||
84 | windowBits, memLevel, strategy: int; | ||
85 | const version: PChar; stream_size: int): int; | ||
86 | stdcall; | ||
87 | function deflateInit_(strm: z_streamp; level: int; | ||
88 | const version: PChar; stream_size: int): int; | ||
89 | stdcall; | ||
90 | function deflateParams(strm: z_streamp; level, strategy: int): int; | ||
91 | stdcall; | ||
92 | function deflateReset(strm: z_streamp): int; | ||
93 | stdcall; | ||
94 | function deflateSetDictionary(strm: z_streamp; | ||
95 | const dictionary: pBytef; | ||
96 | dictLength: uInt): int; | ||
97 | stdcall; | ||
98 | function inflate(strm: z_streamp; flush: int): int; | ||
99 | stdcall; | ||
100 | function inflateEnd(strm: z_streamp): int; | ||
101 | stdcall; | ||
102 | function inflateInit2_(strm: z_streamp; windowBits: int; | ||
103 | const version: PChar; stream_size: int): int; | ||
104 | stdcall; | ||
105 | function inflateInit_(strm: z_streamp; const version: PChar; | ||
106 | stream_size: int): int; | ||
107 | stdcall; | ||
108 | function inflateReset(strm: z_streamp): int; | ||
109 | stdcall; | ||
110 | function inflateSetDictionary(strm: z_streamp; | ||
111 | const dictionary: pBytef; | ||
112 | dictLength: uInt): int; | ||
113 | stdcall; | ||
114 | function inflateSync(strm: z_streamp): int; | ||
115 | stdcall; | ||
116 | |||
117 | function deflateInit(strm: z_streamp; level: int): int; | ||
118 | function deflateInit2(strm: z_streamp; level, method, windowBits, | ||
119 | memLevel, strategy: int): int; | ||
120 | function inflateInit(strm: z_streamp): int; | ||
121 | function inflateInit2(strm: z_streamp; windowBits: int): int; | ||
122 | |||
123 | implementation | ||
124 | |||
125 | function deflateInit(strm: z_streamp; level: int): int; | ||
126 | begin | ||
127 | Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream)); | ||
128 | end; | ||
129 | |||
130 | function deflateInit2(strm: z_streamp; level, method, windowBits, | ||
131 | memLevel, strategy: int): int; | ||
132 | begin | ||
133 | Result := deflateInit2_(strm, level, method, windowBits, memLevel, | ||
134 | strategy, ZLIB_VERSION, sizeof(z_stream)); | ||
135 | end; | ||
136 | |||
137 | function inflateInit(strm: z_streamp): int; | ||
138 | begin | ||
139 | Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream)); | ||
140 | end; | ||
141 | |||
142 | function inflateInit2(strm: z_streamp; windowBits: int): int; | ||
143 | begin | ||
144 | Result := inflateInit2_(strm, windowBits, ZLIB_VERSION, | ||
145 | sizeof(z_stream)); | ||
146 | end; | ||
147 | |||
148 | const | ||
149 | zlibDLL = 'png32bd.dll'; | ||
150 | |||
151 | function adler32; external zlibDLL; | ||
152 | function crc32; external zlibDLL; | ||
153 | function deflate; external zlibDLL; | ||
154 | function deflateCopy; external zlibDLL; | ||
155 | function deflateEnd; external zlibDLL; | ||
156 | function deflateInit2_; external zlibDLL; | ||
157 | function deflateInit_; external zlibDLL; | ||
158 | function deflateParams; external zlibDLL; | ||
159 | function deflateReset; external zlibDLL; | ||
160 | function deflateSetDictionary; external zlibDLL; | ||
161 | function inflate; external zlibDLL; | ||
162 | function inflateEnd; external zlibDLL; | ||
163 | function inflateInit2_; external zlibDLL; | ||
164 | function inflateInit_; external zlibDLL; | ||
165 | function inflateReset; external zlibDLL; | ||
166 | function inflateSetDictionary; external zlibDLL; | ||
167 | function inflateSync; external zlibDLL; | ||
168 | |||
169 | end. | ||
diff --git a/contrib/delphi2/d_zlib.bpr b/contrib/delphi2/d_zlib.bpr deleted file mode 100644 index 78bb254..0000000 --- a/contrib/delphi2/d_zlib.bpr +++ /dev/null | |||
@@ -1,224 +0,0 @@ | |||
1 | # --------------------------------------------------------------------------- | ||
2 | !if !$d(BCB) | ||
3 | BCB = $(MAKEDIR)\.. | ||
4 | !endif | ||
5 | |||
6 | # --------------------------------------------------------------------------- | ||
7 | # IDE SECTION | ||
8 | # --------------------------------------------------------------------------- | ||
9 | # The following section of the project makefile is managed by the BCB IDE. | ||
10 | # It is recommended to use the IDE to change any of the values in this | ||
11 | # section. | ||
12 | # --------------------------------------------------------------------------- | ||
13 | |||
14 | VERSION = BCB.03 | ||
15 | # --------------------------------------------------------------------------- | ||
16 | PROJECT = d_zlib.lib | ||
17 | OBJFILES = d_zlib.obj adler32.obj deflate.obj infblock.obj infcodes.obj inffast.obj \ | ||
18 | inflate.obj inftrees.obj infutil.obj trees.obj | ||
19 | RESFILES = | ||
20 | RESDEPEN = $(RESFILES) | ||
21 | LIBFILES = | ||
22 | LIBRARIES = VCL35.lib | ||
23 | SPARELIBS = VCL35.lib | ||
24 | DEFFILE = | ||
25 | PACKAGES = VCLX35.bpi VCL35.bpi VCLDB35.bpi VCLDBX35.bpi ibsmp35.bpi bcbsmp35.bpi \ | ||
26 | dclocx35.bpi QRPT35.bpi TEEUI35.bpi TEEDB35.bpi TEE35.bpi DSS35.bpi \ | ||
27 | NMFAST35.bpi INETDB35.bpi INET35.bpi VCLMID35.bpi | ||
28 | # --------------------------------------------------------------------------- | ||
29 | PATHCPP = .; | ||
30 | PATHASM = .; | ||
31 | PATHPAS = .; | ||
32 | PATHRC = .; | ||
33 | DEBUGLIBPATH = $(BCB)\lib\debug | ||
34 | RELEASELIBPATH = $(BCB)\lib\release | ||
35 | # --------------------------------------------------------------------------- | ||
36 | CFLAG1 = -O2 -Ve -d -k- -vi | ||
37 | CFLAG2 = -I$(BCB)\include;$(BCB)\include\vcl -H=$(BCB)\lib\vcl35.csm | ||
38 | CFLAG3 = -ff -pr -5 | ||
39 | PFLAGS = -U;$(DEBUGLIBPATH) -I$(BCB)\include;$(BCB)\include\vcl -H -W -$I- -v -JPHN -M | ||
40 | RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl | ||
41 | AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn | ||
42 | LFLAGS = | ||
43 | IFLAGS = -g -Gn | ||
44 | # --------------------------------------------------------------------------- | ||
45 | ALLOBJ = c0w32.obj $(OBJFILES) | ||
46 | ALLRES = $(RESFILES) | ||
47 | ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib | ||
48 | # --------------------------------------------------------------------------- | ||
49 | !!ifdef IDEOPTIONS | ||
50 | |||
51 | [Version Info] | ||
52 | IncludeVerInfo=0 | ||
53 | AutoIncBuild=0 | ||
54 | MajorVer=1 | ||
55 | MinorVer=0 | ||
56 | Release=0 | ||
57 | Build=0 | ||
58 | Debug=0 | ||
59 | PreRelease=0 | ||
60 | Special=0 | ||
61 | Private=0 | ||
62 | DLL=0 | ||
63 | Locale=1040 | ||
64 | CodePage=1252 | ||
65 | |||
66 | [Version Info Keys] | ||
67 | CompanyName= | ||
68 | FileDescription= | ||
69 | FileVersion=1.0.0.0 | ||
70 | InternalName= | ||
71 | LegalCopyright= | ||
72 | LegalTrademarks= | ||
73 | OriginalFilename= | ||
74 | ProductName= | ||
75 | ProductVersion=1.0.0.0 | ||
76 | Comments= | ||
77 | |||
78 | [HistoryLists\hlIncludePath] | ||
79 | Count=2 | ||
80 | Item0=$(BCB)\include | ||
81 | Item1=$(BCB)\include;$(BCB)\include\vcl | ||
82 | |||
83 | [HistoryLists\hlLibraryPath] | ||
84 | Count=1 | ||
85 | Item0=$(BCB)\lib\obj;$(BCB)\lib | ||
86 | |||
87 | [HistoryLists\hlDebugSourcePath] | ||
88 | Count=1 | ||
89 | Item0=$(BCB)\source\vcl | ||
90 | |||
91 | [Debugging] | ||
92 | DebugSourceDirs= | ||
93 | |||
94 | [Parameters] | ||
95 | RunParams= | ||
96 | HostApplication= | ||
97 | |||
98 | !endif | ||
99 | |||
100 | --------------------------------------------------------------------------- | ||
101 | # MAKE SECTION | ||
102 | # --------------------------------------------------------------------------- | ||
103 | # This section of the project file is not used by the BCB IDE. It is for | ||
104 | # the benefit of building from the command-line using the MAKE utility. | ||
105 | # --------------------------------------------------------------------------- | ||
106 | |||
107 | .autodepend | ||
108 | # --------------------------------------------------------------------------- | ||
109 | !if !$d(BCC32) | ||
110 | BCC32 = bcc32 | ||
111 | !endif | ||
112 | |||
113 | !if !$d(DCC32) | ||
114 | DCC32 = dcc32 | ||
115 | !endif | ||
116 | |||
117 | !if !$d(TASM32) | ||
118 | TASM32 = tasm32 | ||
119 | !endif | ||
120 | |||
121 | !if !$d(LINKER) | ||
122 | LINKER = TLib | ||
123 | !endif | ||
124 | |||
125 | !if !$d(BRCC32) | ||
126 | BRCC32 = brcc32 | ||
127 | !endif | ||
128 | # --------------------------------------------------------------------------- | ||
129 | !if $d(PATHCPP) | ||
130 | .PATH.CPP = $(PATHCPP) | ||
131 | .PATH.C = $(PATHCPP) | ||
132 | !endif | ||
133 | |||
134 | !if $d(PATHPAS) | ||
135 | .PATH.PAS = $(PATHPAS) | ||
136 | !endif | ||
137 | |||
138 | !if $d(PATHASM) | ||
139 | .PATH.ASM = $(PATHASM) | ||
140 | !endif | ||
141 | |||
142 | !if $d(PATHRC) | ||
143 | .PATH.RC = $(PATHRC) | ||
144 | !endif | ||
145 | # --------------------------------------------------------------------------- | ||
146 | !ifdef IDEOPTIONS | ||
147 | |||
148 | [Version Info] | ||
149 | IncludeVerInfo=0 | ||
150 | AutoIncBuild=0 | ||
151 | MajorVer=1 | ||
152 | MinorVer=0 | ||
153 | Release=0 | ||
154 | Build=0 | ||
155 | Debug=0 | ||
156 | PreRelease=0 | ||
157 | Special=0 | ||
158 | Private=0 | ||
159 | DLL=0 | ||
160 | Locale=1040 | ||
161 | CodePage=1252 | ||
162 | |||
163 | [Version Info Keys] | ||
164 | CompanyName= | ||
165 | FileDescription= | ||
166 | FileVersion=1.0.0.0 | ||
167 | InternalName= | ||
168 | LegalCopyright= | ||
169 | LegalTrademarks= | ||
170 | OriginalFilename= | ||
171 | ProductName= | ||
172 | ProductVersion=1.0.0.0 | ||
173 | Comments= | ||
174 | |||
175 | [HistoryLists\hlIncludePath] | ||
176 | Count=2 | ||
177 | Item0=$(BCB)\include;$(BCB)\include\vcl | ||
178 | Item1=$(BCB)\include | ||
179 | |||
180 | [HistoryLists\hlLibraryPath] | ||
181 | Count=1 | ||
182 | Item0=$(BCB)\lib\obj;$(BCB)\lib | ||
183 | |||
184 | [HistoryLists\hlDebugSourcePath] | ||
185 | Count=1 | ||
186 | Item0=$(BCB)\source\vcl | ||
187 | |||
188 | [Debugging] | ||
189 | DebugSourceDirs= | ||
190 | |||
191 | [Parameters] | ||
192 | RunParams= | ||
193 | HostApplication= | ||
194 | |||
195 | !endif | ||
196 | |||
197 | $(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) | ||
198 | $(BCB)\BIN\$(LINKER) @&&! | ||
199 | $(LFLAGS) $(IFLAGS) + | ||
200 | $(ALLOBJ), + | ||
201 | $(PROJECT),, + | ||
202 | $(ALLLIB), + | ||
203 | $(DEFFILE), + | ||
204 | $(ALLRES) | ||
205 | ! | ||
206 | # --------------------------------------------------------------------------- | ||
207 | .pas.hpp: | ||
208 | $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } | ||
209 | |||
210 | .pas.obj: | ||
211 | $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } | ||
212 | |||
213 | .cpp.obj: | ||
214 | $(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } | ||
215 | |||
216 | .c.obj: | ||
217 | $(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } | ||
218 | |||
219 | .asm.obj: | ||
220 | $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ | ||
221 | |||
222 | .rc.res: | ||
223 | $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< | ||
224 | # --------------------------------------------------------------------------- | ||
diff --git a/contrib/delphi2/d_zlib.cpp b/contrib/delphi2/d_zlib.cpp deleted file mode 100644 index f5dea59..0000000 --- a/contrib/delphi2/d_zlib.cpp +++ /dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | #include <condefs.h> | ||
2 | #pragma hdrstop | ||
3 | //--------------------------------------------------------------------------- | ||
4 | USEUNIT("adler32.c"); | ||
5 | USEUNIT("deflate.c"); | ||
6 | USEUNIT("infblock.c"); | ||
7 | USEUNIT("infcodes.c"); | ||
8 | USEUNIT("inffast.c"); | ||
9 | USEUNIT("inflate.c"); | ||
10 | USEUNIT("inftrees.c"); | ||
11 | USEUNIT("infutil.c"); | ||
12 | USEUNIT("trees.c"); | ||
13 | //--------------------------------------------------------------------------- | ||
14 | #define Library | ||
15 | |||
16 | // To add a file to the library use the Project menu 'Add to Project'. | ||
17 | |||
diff --git a/contrib/delphi2/readme.txt b/contrib/delphi2/readme.txt deleted file mode 100644 index cbd3162..0000000 --- a/contrib/delphi2/readme.txt +++ /dev/null | |||
@@ -1,17 +0,0 @@ | |||
1 | These are files used to compile zlib under Borland C++ Builder 3. | ||
2 | |||
3 | zlib.bpg is the main project group that can be loaded in the BCB IDE and | ||
4 | loads all other *.bpr projects | ||
5 | |||
6 | zlib.bpr is a project used to create a static zlib.lib library with C calling | ||
7 | convention for functions. | ||
8 | |||
9 | zlib32.bpr creates a zlib32.dll dynamic link library with Windows standard | ||
10 | calling convention. | ||
11 | |||
12 | d_zlib.bpr creates a set of .obj files with register calling convention. | ||
13 | These files are used by zlib.pas to create a Delphi unit containing zlib. | ||
14 | The d_zlib.lib file generated isn't useful and can be deleted. | ||
15 | |||
16 | zlib.cpp, zlib32.cpp and d_zlib.cpp are used by the above projects. | ||
17 | |||
diff --git a/contrib/delphi2/zlib.bpg b/contrib/delphi2/zlib.bpg deleted file mode 100644 index b6c9acd..0000000 --- a/contrib/delphi2/zlib.bpg +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | #------------------------------------------------------------------------------ | ||
2 | VERSION = BWS.01 | ||
3 | #------------------------------------------------------------------------------ | ||
4 | !ifndef ROOT | ||
5 | ROOT = $(MAKEDIR)\.. | ||
6 | !endif | ||
7 | #------------------------------------------------------------------------------ | ||
8 | MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$** | ||
9 | DCC = $(ROOT)\bin\dcc32.exe $** | ||
10 | BRCC = $(ROOT)\bin\brcc32.exe $** | ||
11 | #------------------------------------------------------------------------------ | ||
12 | PROJECTS = zlib zlib32 d_zlib | ||
13 | #------------------------------------------------------------------------------ | ||
14 | default: $(PROJECTS) | ||
15 | #------------------------------------------------------------------------------ | ||
16 | |||
17 | zlib: zlib.bpr | ||
18 | $(MAKE) | ||
19 | |||
20 | zlib32: zlib32.bpr | ||
21 | $(MAKE) | ||
22 | |||
23 | d_zlib: d_zlib.bpr | ||
24 | $(MAKE) | ||
25 | |||
26 | |||
diff --git a/contrib/delphi2/zlib.bpr b/contrib/delphi2/zlib.bpr deleted file mode 100644 index cf3945b..0000000 --- a/contrib/delphi2/zlib.bpr +++ /dev/null | |||
@@ -1,225 +0,0 @@ | |||
1 | # --------------------------------------------------------------------------- | ||
2 | !if !$d(BCB) | ||
3 | BCB = $(MAKEDIR)\.. | ||
4 | !endif | ||
5 | |||
6 | # --------------------------------------------------------------------------- | ||
7 | # IDE SECTION | ||
8 | # --------------------------------------------------------------------------- | ||
9 | # The following section of the project makefile is managed by the BCB IDE. | ||
10 | # It is recommended to use the IDE to change any of the values in this | ||
11 | # section. | ||
12 | # --------------------------------------------------------------------------- | ||
13 | |||
14 | VERSION = BCB.03 | ||
15 | # --------------------------------------------------------------------------- | ||
16 | PROJECT = zlib.lib | ||
17 | OBJFILES = zlib.obj adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infblock.obj \ | ||
18 | infcodes.obj inffast.obj inflate.obj inftrees.obj infutil.obj trees.obj \ | ||
19 | uncompr.obj zutil.obj | ||
20 | RESFILES = | ||
21 | RESDEPEN = $(RESFILES) | ||
22 | LIBFILES = | ||
23 | LIBRARIES = VCL35.lib | ||
24 | SPARELIBS = VCL35.lib | ||
25 | DEFFILE = | ||
26 | PACKAGES = VCLX35.bpi VCL35.bpi VCLDB35.bpi VCLDBX35.bpi ibsmp35.bpi bcbsmp35.bpi \ | ||
27 | dclocx35.bpi QRPT35.bpi TEEUI35.bpi TEEDB35.bpi TEE35.bpi DSS35.bpi \ | ||
28 | NMFAST35.bpi INETDB35.bpi INET35.bpi VCLMID35.bpi | ||
29 | # --------------------------------------------------------------------------- | ||
30 | PATHCPP = .; | ||
31 | PATHASM = .; | ||
32 | PATHPAS = .; | ||
33 | PATHRC = .; | ||
34 | DEBUGLIBPATH = $(BCB)\lib\debug | ||
35 | RELEASELIBPATH = $(BCB)\lib\release | ||
36 | # --------------------------------------------------------------------------- | ||
37 | CFLAG1 = -O2 -Ve -d -k- -vi | ||
38 | CFLAG2 = -I$(BCB)\include;$(BCB)\include\vcl -H=$(BCB)\lib\vcl35.csm | ||
39 | CFLAG3 = -ff -5 | ||
40 | PFLAGS = -U;$(DEBUGLIBPATH) -I$(BCB)\include;$(BCB)\include\vcl -H -W -$I- -v -JPHN -M | ||
41 | RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl | ||
42 | AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn | ||
43 | LFLAGS = | ||
44 | IFLAGS = -g -Gn | ||
45 | # --------------------------------------------------------------------------- | ||
46 | ALLOBJ = c0w32.obj $(OBJFILES) | ||
47 | ALLRES = $(RESFILES) | ||
48 | ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mt.lib | ||
49 | # --------------------------------------------------------------------------- | ||
50 | !!ifdef IDEOPTIONS | ||
51 | |||
52 | [Version Info] | ||
53 | IncludeVerInfo=0 | ||
54 | AutoIncBuild=0 | ||
55 | MajorVer=1 | ||
56 | MinorVer=0 | ||
57 | Release=0 | ||
58 | Build=0 | ||
59 | Debug=0 | ||
60 | PreRelease=0 | ||
61 | Special=0 | ||
62 | Private=0 | ||
63 | DLL=0 | ||
64 | Locale=1040 | ||
65 | CodePage=1252 | ||
66 | |||
67 | [Version Info Keys] | ||
68 | CompanyName= | ||
69 | FileDescription= | ||
70 | FileVersion=1.0.0.0 | ||
71 | InternalName= | ||
72 | LegalCopyright= | ||
73 | LegalTrademarks= | ||
74 | OriginalFilename= | ||
75 | ProductName= | ||
76 | ProductVersion=1.0.0.0 | ||
77 | Comments= | ||
78 | |||
79 | [HistoryLists\hlIncludePath] | ||
80 | Count=2 | ||
81 | Item0=$(BCB)\include | ||
82 | Item1=$(BCB)\include;$(BCB)\include\vcl | ||
83 | |||
84 | [HistoryLists\hlLibraryPath] | ||
85 | Count=1 | ||
86 | Item0=$(BCB)\lib\obj;$(BCB)\lib | ||
87 | |||
88 | [HistoryLists\hlDebugSourcePath] | ||
89 | Count=1 | ||
90 | Item0=$(BCB)\source\vcl | ||
91 | |||
92 | [Debugging] | ||
93 | DebugSourceDirs= | ||
94 | |||
95 | [Parameters] | ||
96 | RunParams= | ||
97 | HostApplication= | ||
98 | |||
99 | !endif | ||
100 | |||
101 | --------------------------------------------------------------------------- | ||
102 | # MAKE SECTION | ||
103 | # --------------------------------------------------------------------------- | ||
104 | # This section of the project file is not used by the BCB IDE. It is for | ||
105 | # the benefit of building from the command-line using the MAKE utility. | ||
106 | # --------------------------------------------------------------------------- | ||
107 | |||
108 | .autodepend | ||
109 | # --------------------------------------------------------------------------- | ||
110 | !if !$d(BCC32) | ||
111 | BCC32 = bcc32 | ||
112 | !endif | ||
113 | |||
114 | !if !$d(DCC32) | ||
115 | DCC32 = dcc32 | ||
116 | !endif | ||
117 | |||
118 | !if !$d(TASM32) | ||
119 | TASM32 = tasm32 | ||
120 | !endif | ||
121 | |||
122 | !if !$d(LINKER) | ||
123 | LINKER = TLib | ||
124 | !endif | ||
125 | |||
126 | !if !$d(BRCC32) | ||
127 | BRCC32 = brcc32 | ||
128 | !endif | ||
129 | # --------------------------------------------------------------------------- | ||
130 | !if $d(PATHCPP) | ||
131 | .PATH.CPP = $(PATHCPP) | ||
132 | .PATH.C = $(PATHCPP) | ||
133 | !endif | ||
134 | |||
135 | !if $d(PATHPAS) | ||
136 | .PATH.PAS = $(PATHPAS) | ||
137 | !endif | ||
138 | |||
139 | !if $d(PATHASM) | ||
140 | .PATH.ASM = $(PATHASM) | ||
141 | !endif | ||
142 | |||
143 | !if $d(PATHRC) | ||
144 | .PATH.RC = $(PATHRC) | ||
145 | !endif | ||
146 | # --------------------------------------------------------------------------- | ||
147 | !ifdef IDEOPTIONS | ||
148 | |||
149 | [Version Info] | ||
150 | IncludeVerInfo=0 | ||
151 | AutoIncBuild=0 | ||
152 | MajorVer=1 | ||
153 | MinorVer=0 | ||
154 | Release=0 | ||
155 | Build=0 | ||
156 | Debug=0 | ||
157 | PreRelease=0 | ||
158 | Special=0 | ||
159 | Private=0 | ||
160 | DLL=0 | ||
161 | Locale=1040 | ||
162 | CodePage=1252 | ||
163 | |||
164 | [Version Info Keys] | ||
165 | CompanyName= | ||
166 | FileDescription= | ||
167 | FileVersion=1.0.0.0 | ||
168 | InternalName= | ||
169 | LegalCopyright= | ||
170 | LegalTrademarks= | ||
171 | OriginalFilename= | ||
172 | ProductName= | ||
173 | ProductVersion=1.0.0.0 | ||
174 | Comments= | ||
175 | |||
176 | [HistoryLists\hlIncludePath] | ||
177 | Count=2 | ||
178 | Item0=$(BCB)\include;$(BCB)\include\vcl | ||
179 | Item1=$(BCB)\include | ||
180 | |||
181 | [HistoryLists\hlLibraryPath] | ||
182 | Count=1 | ||
183 | Item0=$(BCB)\lib\obj;$(BCB)\lib | ||
184 | |||
185 | [HistoryLists\hlDebugSourcePath] | ||
186 | Count=1 | ||
187 | Item0=$(BCB)\source\vcl | ||
188 | |||
189 | [Debugging] | ||
190 | DebugSourceDirs= | ||
191 | |||
192 | [Parameters] | ||
193 | RunParams= | ||
194 | HostApplication= | ||
195 | |||
196 | !endif | ||
197 | |||
198 | $(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) | ||
199 | $(BCB)\BIN\$(LINKER) @&&! | ||
200 | $(LFLAGS) $(IFLAGS) + | ||
201 | $(ALLOBJ), + | ||
202 | $(PROJECT),, + | ||
203 | $(ALLLIB), + | ||
204 | $(DEFFILE), + | ||
205 | $(ALLRES) | ||
206 | ! | ||
207 | # --------------------------------------------------------------------------- | ||
208 | .pas.hpp: | ||
209 | $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } | ||
210 | |||
211 | .pas.obj: | ||
212 | $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } | ||
213 | |||
214 | .cpp.obj: | ||
215 | $(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } | ||
216 | |||
217 | .c.obj: | ||
218 | $(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } | ||
219 | |||
220 | .asm.obj: | ||
221 | $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ | ||
222 | |||
223 | .rc.res: | ||
224 | $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< | ||
225 | # --------------------------------------------------------------------------- | ||
diff --git a/contrib/delphi2/zlib.cpp b/contrib/delphi2/zlib.cpp deleted file mode 100644 index bf6953b..0000000 --- a/contrib/delphi2/zlib.cpp +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | #include <condefs.h> | ||
2 | #pragma hdrstop | ||
3 | //--------------------------------------------------------------------------- | ||
4 | USEUNIT("adler32.c"); | ||
5 | USEUNIT("compress.c"); | ||
6 | USEUNIT("crc32.c"); | ||
7 | USEUNIT("deflate.c"); | ||
8 | USEUNIT("gzio.c"); | ||
9 | USEUNIT("infblock.c"); | ||
10 | USEUNIT("infcodes.c"); | ||
11 | USEUNIT("inffast.c"); | ||
12 | USEUNIT("inflate.c"); | ||
13 | USEUNIT("inftrees.c"); | ||
14 | USEUNIT("infutil.c"); | ||
15 | USEUNIT("trees.c"); | ||
16 | USEUNIT("uncompr.c"); | ||
17 | USEUNIT("zutil.c"); | ||
18 | //--------------------------------------------------------------------------- | ||
19 | #define Library | ||
20 | |||
21 | // To add a file to the library use the Project menu 'Add to Project'. | ||
22 | |||
diff --git a/contrib/delphi2/zlib32.bpr b/contrib/delphi2/zlib32.bpr deleted file mode 100644 index cabcec4..0000000 --- a/contrib/delphi2/zlib32.bpr +++ /dev/null | |||
@@ -1,174 +0,0 @@ | |||
1 | # --------------------------------------------------------------------------- | ||
2 | !if !$d(BCB) | ||
3 | BCB = $(MAKEDIR)\.. | ||
4 | !endif | ||
5 | |||
6 | # --------------------------------------------------------------------------- | ||
7 | # IDE SECTION | ||
8 | # --------------------------------------------------------------------------- | ||
9 | # The following section of the project makefile is managed by the BCB IDE. | ||
10 | # It is recommended to use the IDE to change any of the values in this | ||
11 | # section. | ||
12 | # --------------------------------------------------------------------------- | ||
13 | |||
14 | VERSION = BCB.03 | ||
15 | # --------------------------------------------------------------------------- | ||
16 | PROJECT = zlib32.dll | ||
17 | OBJFILES = zlib32.obj adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infblock.obj \ | ||
18 | infcodes.obj inffast.obj inflate.obj inftrees.obj infutil.obj trees.obj \ | ||
19 | uncompr.obj zutil.obj | ||
20 | RESFILES = | ||
21 | RESDEPEN = $(RESFILES) | ||
22 | LIBFILES = | ||
23 | LIBRARIES = | ||
24 | SPARELIBS = | ||
25 | DEFFILE = | ||
26 | PACKAGES = VCLX35.bpi VCL35.bpi VCLDB35.bpi VCLDBX35.bpi ibsmp35.bpi bcbsmp35.bpi \ | ||
27 | dclocx35.bpi QRPT35.bpi TEEUI35.bpi TEEDB35.bpi TEE35.bpi DSS35.bpi \ | ||
28 | NMFAST35.bpi INETDB35.bpi INET35.bpi VCLMID35.bpi | ||
29 | # --------------------------------------------------------------------------- | ||
30 | PATHCPP = .; | ||
31 | PATHASM = .; | ||
32 | PATHPAS = .; | ||
33 | PATHRC = .; | ||
34 | DEBUGLIBPATH = $(BCB)\lib\debug | ||
35 | RELEASELIBPATH = $(BCB)\lib\release | ||
36 | # --------------------------------------------------------------------------- | ||
37 | CFLAG1 = -WD -O2 -Ve -d -k- -vi -c -tWD | ||
38 | CFLAG2 = -D_NO_VCL;ZLIB_DLL -I$(BCB)\include | ||
39 | CFLAG3 = -ff -5 | ||
40 | PFLAGS = -D_NO_VCL;ZLIB_DLL -U$(BCB)\lib;$(RELEASELIBPATH) -I$(BCB)\include -$I- -v \ | ||
41 | -JPHN -M | ||
42 | RFLAGS = -D_NO_VCL;ZLIB_DLL -i$(BCB)\include | ||
43 | AFLAGS = /i$(BCB)\include /d_NO_VCL /dZLIB_DLL /mx /w2 /zn | ||
44 | LFLAGS = -L$(BCB)\lib;$(RELEASELIBPATH) -aa -Tpd -x -Gi | ||
45 | IFLAGS = -Gn -g | ||
46 | # --------------------------------------------------------------------------- | ||
47 | ALLOBJ = c0d32.obj $(OBJFILES) | ||
48 | ALLRES = $(RESFILES) | ||
49 | ALLLIB = $(LIBFILES) import32.lib cw32mt.lib | ||
50 | # --------------------------------------------------------------------------- | ||
51 | !ifdef IDEOPTIONS | ||
52 | |||
53 | [Version Info] | ||
54 | IncludeVerInfo=0 | ||
55 | AutoIncBuild=0 | ||
56 | MajorVer=1 | ||
57 | MinorVer=0 | ||
58 | Release=0 | ||
59 | Build=0 | ||
60 | Debug=0 | ||
61 | PreRelease=0 | ||
62 | Special=0 | ||
63 | Private=0 | ||
64 | DLL=1 | ||
65 | Locale=1040 | ||
66 | CodePage=1252 | ||
67 | |||
68 | [Version Info Keys] | ||
69 | CompanyName= | ||
70 | FileDescription=DLL (GUI) | ||
71 | FileVersion=1.0.0.0 | ||
72 | InternalName= | ||
73 | LegalCopyright= | ||
74 | LegalTrademarks= | ||
75 | OriginalFilename= | ||
76 | ProductName= | ||
77 | ProductVersion=1.0.0.0 | ||
78 | Comments= | ||
79 | |||
80 | [HistoryLists\hlIncludePath] | ||
81 | Count=1 | ||
82 | Item0=$(BCB)\include | ||
83 | |||
84 | [HistoryLists\hlLibraryPath] | ||
85 | Count=1 | ||
86 | Item0=$(BCB)\lib | ||
87 | |||
88 | [HistoryLists\hlConditionals] | ||
89 | Count=1 | ||
90 | Item0=_NO_VCL;ZLIB_DLL | ||
91 | |||
92 | [Debugging] | ||
93 | DebugSourceDirs= | ||
94 | |||
95 | [Parameters] | ||
96 | RunParams= | ||
97 | HostApplication= | ||
98 | |||
99 | !endif | ||
100 | |||
101 | # --------------------------------------------------------------------------- | ||
102 | # MAKE SECTION | ||
103 | # --------------------------------------------------------------------------- | ||
104 | # This section of the project file is not used by the BCB IDE. It is for | ||
105 | # the benefit of building from the command-line using the MAKE utility. | ||
106 | # --------------------------------------------------------------------------- | ||
107 | |||
108 | .autodepend | ||
109 | # --------------------------------------------------------------------------- | ||
110 | !if !$d(BCC32) | ||
111 | BCC32 = bcc32 | ||
112 | !endif | ||
113 | |||
114 | !if !$d(DCC32) | ||
115 | DCC32 = dcc32 | ||
116 | !endif | ||
117 | |||
118 | !if !$d(TASM32) | ||
119 | TASM32 = tasm32 | ||
120 | !endif | ||
121 | |||
122 | !if !$d(LINKER) | ||
123 | LINKER = ilink32 | ||
124 | !endif | ||
125 | |||
126 | !if !$d(BRCC32) | ||
127 | BRCC32 = brcc32 | ||
128 | !endif | ||
129 | # --------------------------------------------------------------------------- | ||
130 | !if $d(PATHCPP) | ||
131 | .PATH.CPP = $(PATHCPP) | ||
132 | .PATH.C = $(PATHCPP) | ||
133 | !endif | ||
134 | |||
135 | !if $d(PATHPAS) | ||
136 | .PATH.PAS = $(PATHPAS) | ||
137 | !endif | ||
138 | |||
139 | !if $d(PATHASM) | ||
140 | .PATH.ASM = $(PATHASM) | ||
141 | !endif | ||
142 | |||
143 | !if $d(PATHRC) | ||
144 | .PATH.RC = $(PATHRC) | ||
145 | !endif | ||
146 | # --------------------------------------------------------------------------- | ||
147 | $(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) | ||
148 | $(BCB)\BIN\$(LINKER) @&&! | ||
149 | $(LFLAGS) $(IFLAGS) + | ||
150 | $(ALLOBJ), + | ||
151 | $(PROJECT),, + | ||
152 | $(ALLLIB), + | ||
153 | $(DEFFILE), + | ||
154 | $(ALLRES) | ||
155 | ! | ||
156 | # --------------------------------------------------------------------------- | ||
157 | .pas.hpp: | ||
158 | $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } | ||
159 | |||
160 | .pas.obj: | ||
161 | $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } | ||
162 | |||
163 | .cpp.obj: | ||
164 | $(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } | ||
165 | |||
166 | .c.obj: | ||
167 | $(BCB)\BIN\$(BCC32) $(CFLAG1) $(CFLAG2) $(CFLAG3) -n$(@D) {$< } | ||
168 | |||
169 | .asm.obj: | ||
170 | $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ | ||
171 | |||
172 | .rc.res: | ||
173 | $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< | ||
174 | # --------------------------------------------------------------------------- | ||
diff --git a/contrib/delphi2/zlib32.cpp b/contrib/delphi2/zlib32.cpp deleted file mode 100644 index 7372f6b..0000000 --- a/contrib/delphi2/zlib32.cpp +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
1 | |||
2 | #include <windows.h> | ||
3 | #pragma hdrstop | ||
4 | #include <condefs.h> | ||
5 | |||
6 | |||
7 | //--------------------------------------------------------------------------- | ||
8 | // Important note about DLL memory management in a VCL DLL: | ||
9 | // | ||
10 | // | ||
11 | // | ||
12 | // If your DLL uses VCL and exports any functions that pass VCL String objects | ||
13 | // (or structs/classes containing nested Strings) as parameter or function | ||
14 | // results, you will need to build both your DLL project and any EXE projects | ||
15 | // that use your DLL with the dynamic RTL (the RTL DLL). This will change your | ||
16 | // DLL and its calling EXE's to use BORLNDMM.DLL as their memory manager. In | ||
17 | // these cases, the file BORLNDMM.DLL should be deployed along with your DLL | ||
18 | // and the RTL DLL (CP3240MT.DLL). To avoid the requiring BORLNDMM.DLL in | ||
19 | // these situations, pass string information using "char *" or ShortString | ||
20 | // parameters and then link with the static RTL. | ||
21 | // | ||
22 | //--------------------------------------------------------------------------- | ||
23 | USEUNIT("adler32.c"); | ||
24 | USEUNIT("compress.c"); | ||
25 | USEUNIT("crc32.c"); | ||
26 | USEUNIT("deflate.c"); | ||
27 | USEUNIT("gzio.c"); | ||
28 | USEUNIT("infblock.c"); | ||
29 | USEUNIT("infcodes.c"); | ||
30 | USEUNIT("inffast.c"); | ||
31 | USEUNIT("inflate.c"); | ||
32 | USEUNIT("inftrees.c"); | ||
33 | USEUNIT("infutil.c"); | ||
34 | USEUNIT("trees.c"); | ||
35 | USEUNIT("uncompr.c"); | ||
36 | USEUNIT("zutil.c"); | ||
37 | //--------------------------------------------------------------------------- | ||
38 | #pragma argsused | ||
39 | int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) | ||
40 | { | ||
41 | return 1; | ||
42 | } | ||
diff --git a/contrib/infback9/README b/contrib/infback9/README new file mode 100644 index 0000000..e75ed13 --- /dev/null +++ b/contrib/infback9/README | |||
@@ -0,0 +1 @@ | |||
See infback9.h for what this is and how to use it. | |||
diff --git a/contrib/infback9/infback9.diff b/contrib/infback9/infback9.diff new file mode 100644 index 0000000..cbe2e49 --- /dev/null +++ b/contrib/infback9/infback9.diff | |||
@@ -0,0 +1,427 @@ | |||
1 | *** infback.c Mon Aug 11 16:48:06 2003 | ||
2 | --- infback9.c Mon Sep 8 21:22:46 2003 | ||
3 | *************** | ||
4 | *** 1,19 **** | ||
5 | ! /* infback.c -- inflate using a call-back interface | ||
6 | * Copyright (C) 1995-2003 Mark Adler | ||
7 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
8 | */ | ||
9 | |||
10 | - /* | ||
11 | - This code is largely copied from inflate.c. Normally either infback.o or | ||
12 | - inflate.o would be linked into an application--not both. The interface | ||
13 | - with inffast.c is retained so that optimized assembler-coded versions of | ||
14 | - inflate_fast() can be used with either inflate.c or infback.c. | ||
15 | - */ | ||
16 | - | ||
17 | #include "zutil.h" | ||
18 | ! #include "inftrees.h" | ||
19 | #include "inflate.h" | ||
20 | - #include "inffast.h" | ||
21 | |||
22 | /* function prototypes */ | ||
23 | local void fixedtables OF((struct inflate_state FAR *state)); | ||
24 | --- 1,12 ---- | ||
25 | ! /* infback9.c -- inflate deflate64 data using a call-back interface | ||
26 | * Copyright (C) 1995-2003 Mark Adler | ||
27 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
28 | */ | ||
29 | |||
30 | #include "zutil.h" | ||
31 | ! #include "infback9.h" | ||
32 | ! #include "inftree9.h" | ||
33 | #include "inflate.h" | ||
34 | |||
35 | /* function prototypes */ | ||
36 | local void fixedtables OF((struct inflate_state FAR *state)); | ||
37 | *************** | ||
38 | *** 22,33 **** | ||
39 | strm provides memory allocation functions in zalloc and zfree, or | ||
40 | Z_NULL to use the library memory allocation functions. | ||
41 | |||
42 | ! windowBits is in the range 8..15, and window is a user-supplied | ||
43 | ! window and output buffer that is 2**windowBits bytes. | ||
44 | */ | ||
45 | ! int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) | ||
46 | z_stream FAR *strm; | ||
47 | - int windowBits; | ||
48 | unsigned char FAR *window; | ||
49 | const char *version; | ||
50 | int stream_size; | ||
51 | --- 15,24 ---- | ||
52 | strm provides memory allocation functions in zalloc and zfree, or | ||
53 | Z_NULL to use the library memory allocation functions. | ||
54 | |||
55 | ! window is a user-supplied window and output buffer that is 64K bytes. | ||
56 | */ | ||
57 | ! int ZEXPORT inflateBack9Init_(strm, window, version, stream_size) | ||
58 | z_stream FAR *strm; | ||
59 | unsigned char FAR *window; | ||
60 | const char *version; | ||
61 | int stream_size; | ||
62 | *************** | ||
63 | *** 37,44 **** | ||
64 | if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || | ||
65 | stream_size != (int)(sizeof(z_stream))) | ||
66 | return Z_VERSION_ERROR; | ||
67 | ! if (strm == Z_NULL || window == Z_NULL || | ||
68 | ! windowBits < 8 || windowBits > 15) | ||
69 | return Z_STREAM_ERROR; | ||
70 | strm->msg = Z_NULL; /* in case we return an error */ | ||
71 | if (strm->zalloc == (alloc_func)0) { | ||
72 | --- 28,34 ---- | ||
73 | if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || | ||
74 | stream_size != (int)(sizeof(z_stream))) | ||
75 | return Z_VERSION_ERROR; | ||
76 | ! if (strm == Z_NULL || window == Z_NULL) | ||
77 | return Z_STREAM_ERROR; | ||
78 | strm->msg = Z_NULL; /* in case we return an error */ | ||
79 | if (strm->zalloc == (alloc_func)0) { | ||
80 | *************** | ||
81 | *** 51,58 **** | ||
82 | if (state == Z_NULL) return Z_MEM_ERROR; | ||
83 | Tracev((stderr, "inflate: allocated\n")); | ||
84 | strm->state = (voidpf)state; | ||
85 | ! state->wbits = windowBits; | ||
86 | ! state->wsize = 1U << windowBits; | ||
87 | state->window = window; | ||
88 | state->write = 0; | ||
89 | state->whave = 0; | ||
90 | --- 41,48 ---- | ||
91 | if (state == Z_NULL) return Z_MEM_ERROR; | ||
92 | Tracev((stderr, "inflate: allocated\n")); | ||
93 | strm->state = (voidpf)state; | ||
94 | ! state->wbits = 16; | ||
95 | ! state->wsize = 1U << 16; | ||
96 | state->window = window; | ||
97 | state->write = 0; | ||
98 | state->whave = 0; | ||
99 | *************** | ||
100 | *** 91,110 **** | ||
101 | next = fixed; | ||
102 | lenfix = next; | ||
103 | bits = 9; | ||
104 | ! inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); | ||
105 | |||
106 | /* distance table */ | ||
107 | sym = 0; | ||
108 | while (sym < 32) state->lens[sym++] = 5; | ||
109 | distfix = next; | ||
110 | bits = 5; | ||
111 | ! inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); | ||
112 | |||
113 | /* do this just once */ | ||
114 | virgin = 0; | ||
115 | } | ||
116 | #else /* !BUILDFIXED */ | ||
117 | ! # include "inffixed.h" | ||
118 | #endif /* BUILDFIXED */ | ||
119 | state->lencode = lenfix; | ||
120 | state->lenbits = 9; | ||
121 | --- 81,100 ---- | ||
122 | next = fixed; | ||
123 | lenfix = next; | ||
124 | bits = 9; | ||
125 | ! inflate_table9(LENS, state->lens, 288, &(next), &(bits), state->work); | ||
126 | |||
127 | /* distance table */ | ||
128 | sym = 0; | ||
129 | while (sym < 32) state->lens[sym++] = 5; | ||
130 | distfix = next; | ||
131 | bits = 5; | ||
132 | ! inflate_table9(DISTS, state->lens, 32, &(next), &(bits), state->work); | ||
133 | |||
134 | /* do this just once */ | ||
135 | virgin = 0; | ||
136 | } | ||
137 | #else /* !BUILDFIXED */ | ||
138 | ! # include "inffix9.h" | ||
139 | #endif /* BUILDFIXED */ | ||
140 | state->lencode = lenfix; | ||
141 | state->lenbits = 9; | ||
142 | *************** | ||
143 | *** 114,141 **** | ||
144 | |||
145 | /* Macros for inflateBack(): */ | ||
146 | |||
147 | - /* Load returned state from inflate_fast() */ | ||
148 | - #define LOAD() \ | ||
149 | - do { \ | ||
150 | - put = strm->next_out; \ | ||
151 | - left = strm->avail_out; \ | ||
152 | - next = strm->next_in; \ | ||
153 | - have = strm->avail_in; \ | ||
154 | - hold = state->hold; \ | ||
155 | - bits = state->bits; \ | ||
156 | - } while (0) | ||
157 | - | ||
158 | - /* Set state from registers for inflate_fast() */ | ||
159 | - #define RESTORE() \ | ||
160 | - do { \ | ||
161 | - strm->next_out = put; \ | ||
162 | - strm->avail_out = left; \ | ||
163 | - strm->next_in = next; \ | ||
164 | - strm->avail_in = have; \ | ||
165 | - state->hold = hold; \ | ||
166 | - state->bits = bits; \ | ||
167 | - } while (0) | ||
168 | - | ||
169 | /* Clear the input bit accumulator */ | ||
170 | #define INITBITS() \ | ||
171 | do { \ | ||
172 | --- 104,109 ---- | ||
173 | *************** | ||
174 | *** 237,243 **** | ||
175 | inflateBack() can also return Z_STREAM_ERROR if the input parameters | ||
176 | are not correct, i.e. strm is Z_NULL or the state was not initialized. | ||
177 | */ | ||
178 | ! int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) | ||
179 | z_stream FAR *strm; | ||
180 | in_func in; | ||
181 | void FAR *in_desc; | ||
182 | --- 205,211 ---- | ||
183 | inflateBack() can also return Z_STREAM_ERROR if the input parameters | ||
184 | are not correct, i.e. strm is Z_NULL or the state was not initialized. | ||
185 | */ | ||
186 | ! int ZEXPORT inflateBack9(strm, in, in_desc, out, out_desc) | ||
187 | z_stream FAR *strm; | ||
188 | in_func in; | ||
189 | void FAR *in_desc; | ||
190 | *************** | ||
191 | *** 354,366 **** | ||
192 | DROPBITS(5); | ||
193 | state->ncode = BITS(4) + 4; | ||
194 | DROPBITS(4); | ||
195 | ! #ifndef PKZIP_BUG_WORKAROUND | ||
196 | ! if (state->nlen > 286 || state->ndist > 30) { | ||
197 | ! strm->msg = (char *)"too many length or distance symbols"; | ||
198 | state->mode = BAD; | ||
199 | break; | ||
200 | } | ||
201 | - #endif | ||
202 | Tracev((stderr, "inflate: table sizes ok\n")); | ||
203 | |||
204 | /* get code length code lengths (not a typo) */ | ||
205 | --- 322,332 ---- | ||
206 | DROPBITS(5); | ||
207 | state->ncode = BITS(4) + 4; | ||
208 | DROPBITS(4); | ||
209 | ! if (state->nlen > 286) { | ||
210 | ! strm->msg = (char *)"too many length symbols"; | ||
211 | state->mode = BAD; | ||
212 | break; | ||
213 | } | ||
214 | Tracev((stderr, "inflate: table sizes ok\n")); | ||
215 | |||
216 | /* get code length code lengths (not a typo) */ | ||
217 | *************** | ||
218 | *** 375,381 **** | ||
219 | state->next = state->codes; | ||
220 | state->lencode = (code const FAR *)(state->next); | ||
221 | state->lenbits = 7; | ||
222 | ! ret = inflate_table(CODES, state->lens, 19, &(state->next), | ||
223 | &(state->lenbits), state->work); | ||
224 | if (ret) { | ||
225 | strm->msg = (char *)"invalid code lengths set"; | ||
226 | --- 341,347 ---- | ||
227 | state->next = state->codes; | ||
228 | state->lencode = (code const FAR *)(state->next); | ||
229 | state->lenbits = 7; | ||
230 | ! ret = inflate_table9(CODES, state->lens, 19, &(state->next), | ||
231 | &(state->lenbits), state->work); | ||
232 | if (ret) { | ||
233 | strm->msg = (char *)"invalid code lengths set"; | ||
234 | *************** | ||
235 | *** 438,445 **** | ||
236 | state->next = state->codes; | ||
237 | state->lencode = (code const FAR *)(state->next); | ||
238 | state->lenbits = 9; | ||
239 | ! ret = inflate_table(LENS, state->lens, state->nlen, &(state->next), | ||
240 | ! &(state->lenbits), state->work); | ||
241 | if (ret) { | ||
242 | strm->msg = (char *)"invalid literal/lengths set"; | ||
243 | state->mode = BAD; | ||
244 | --- 404,411 ---- | ||
245 | state->next = state->codes; | ||
246 | state->lencode = (code const FAR *)(state->next); | ||
247 | state->lenbits = 9; | ||
248 | ! ret = inflate_table9(LENS, state->lens, state->nlen, | ||
249 | ! &(state->next), &(state->lenbits), state->work); | ||
250 | if (ret) { | ||
251 | strm->msg = (char *)"invalid literal/lengths set"; | ||
252 | state->mode = BAD; | ||
253 | *************** | ||
254 | *** 447,454 **** | ||
255 | } | ||
256 | state->distcode = (code const FAR *)(state->next); | ||
257 | state->distbits = 6; | ||
258 | ! ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist, | ||
259 | ! &(state->next), &(state->distbits), state->work); | ||
260 | if (ret) { | ||
261 | strm->msg = (char *)"invalid distances set"; | ||
262 | state->mode = BAD; | ||
263 | --- 413,421 ---- | ||
264 | } | ||
265 | state->distcode = (code const FAR *)(state->next); | ||
266 | state->distbits = 6; | ||
267 | ! ret = inflate_table9(DISTS, state->lens + state->nlen, | ||
268 | ! state->ndist, &(state->next), &(state->distbits), | ||
269 | ! state->work); | ||
270 | if (ret) { | ||
271 | strm->msg = (char *)"invalid distances set"; | ||
272 | state->mode = BAD; | ||
273 | *************** | ||
274 | *** 458,473 **** | ||
275 | state->mode = LEN; | ||
276 | |||
277 | case LEN: | ||
278 | - /* use inflate_fast() if we have enough input and output */ | ||
279 | - if (have >= 6 && left >= 258) { | ||
280 | - RESTORE(); | ||
281 | - if (state->whave < state->wsize) | ||
282 | - state->whave = state->wsize - left; | ||
283 | - inflate_fast(strm, state->wsize); | ||
284 | - LOAD(); | ||
285 | - break; | ||
286 | - } | ||
287 | - | ||
288 | /* get a literal, length, or end-of-block code */ | ||
289 | for (;;) { | ||
290 | this = state->lencode[BITS(state->lenbits)]; | ||
291 | --- 425,430 ---- | ||
292 | *************** | ||
293 | *** 607,613 **** | ||
294 | return ret; | ||
295 | } | ||
296 | |||
297 | ! int ZEXPORT inflateBackEnd(strm) | ||
298 | z_stream FAR *strm; | ||
299 | { | ||
300 | if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) | ||
301 | --- 564,570 ---- | ||
302 | return ret; | ||
303 | } | ||
304 | |||
305 | ! int ZEXPORT inflateBack9End(strm) | ||
306 | z_stream FAR *strm; | ||
307 | { | ||
308 | if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) | ||
309 | *** inftrees.c Sun Sep 7 10:59:10 2003 | ||
310 | --- inftree9.c Mon Sep 8 20:54:36 2003 | ||
311 | *************** | ||
312 | *** 1,15 **** | ||
313 | ! /* inftrees.c -- generate Huffman trees for efficient decoding | ||
314 | * Copyright (C) 1995-2003 Mark Adler | ||
315 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
316 | */ | ||
317 | |||
318 | #include "zutil.h" | ||
319 | ! #include "inftrees.h" | ||
320 | |||
321 | #define MAXBITS 15 | ||
322 | |||
323 | ! const char inflate_copyright[] = | ||
324 | ! " inflate 1.2.0.5 Copyright 1995-2003 Mark Adler "; | ||
325 | /* | ||
326 | If you use the zlib library in a product, an acknowledgment is welcome | ||
327 | in the documentation of your product. If for some reason you cannot | ||
328 | --- 1,15 ---- | ||
329 | ! /* inftree9.c -- generate Huffman trees for efficient decoding | ||
330 | * Copyright (C) 1995-2003 Mark Adler | ||
331 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
332 | */ | ||
333 | |||
334 | #include "zutil.h" | ||
335 | ! #include "inftree9.h" | ||
336 | |||
337 | #define MAXBITS 15 | ||
338 | |||
339 | ! const char inflate9_copyright[] = | ||
340 | ! " inflate9 1.2.0.5 Copyright 1995-2003 Mark Adler "; | ||
341 | /* | ||
342 | If you use the zlib library in a product, an acknowledgment is welcome | ||
343 | in the documentation of your product. If for some reason you cannot | ||
344 | *************** | ||
345 | *** 29,35 **** | ||
346 | table index bits. It will differ if the request is greater than the | ||
347 | longest code or if it is less than the shortest code. | ||
348 | */ | ||
349 | ! int inflate_table(type, lens, codes, table, bits, work) | ||
350 | codetype type; | ||
351 | unsigned short FAR *lens; | ||
352 | unsigned codes; | ||
353 | --- 29,35 ---- | ||
354 | table index bits. It will differ if the request is greater than the | ||
355 | longest code or if it is less than the shortest code. | ||
356 | */ | ||
357 | ! int inflate_table9(type, lens, codes, table, bits, work) | ||
358 | codetype type; | ||
359 | unsigned short FAR *lens; | ||
360 | unsigned codes; | ||
361 | *************** | ||
362 | *** 59,76 **** | ||
363 | unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ | ||
364 | static const unsigned short lbase[31] = { /* Length codes 257..285 base */ | ||
365 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, | ||
366 | ! 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; | ||
367 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ | ||
368 | 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, | ||
369 | ! 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 192, 78}; | ||
370 | ! static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ | ||
371 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, | ||
372 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, | ||
373 | ! 8193, 12289, 16385, 24577, 0, 0}; | ||
374 | ! static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ | ||
375 | 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, | ||
376 | 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, | ||
377 | ! 28, 28, 29, 29, 64, 64}; | ||
378 | |||
379 | /* | ||
380 | Process a set of code lengths to create a canonical Huffman code. The | ||
381 | --- 59,76 ---- | ||
382 | unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ | ||
383 | static const unsigned short lbase[31] = { /* Length codes 257..285 base */ | ||
384 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, | ||
385 | ! 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 3, 0, 0}; | ||
386 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ | ||
387 | 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, | ||
388 | ! 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 32, 192, 78}; | ||
389 | ! static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ | ||
390 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, | ||
391 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, | ||
392 | ! 8193, 12289, 16385, 24577, 32769, 49153}; | ||
393 | ! static const unsigned short dext[32] = { /* Distance codes 0..31 extra */ | ||
394 | 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, | ||
395 | 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, | ||
396 | ! 28, 28, 29, 29, 30, 30}; | ||
397 | |||
398 | /* | ||
399 | Process a set of code lengths to create a canonical Huffman code. The | ||
400 | *** inftrees.h Sun Aug 10 15:15:50 2003 | ||
401 | --- inftree9.h Mon Sep 8 20:54:51 2003 | ||
402 | *************** | ||
403 | *** 1,4 **** | ||
404 | ! /* inftrees.h -- header to use inftrees.c | ||
405 | * Copyright (C) 1995-2003 Mark Adler | ||
406 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
407 | */ | ||
408 | --- 1,4 ---- | ||
409 | ! /* inftree9.h -- header to use inftree9.c | ||
410 | * Copyright (C) 1995-2003 Mark Adler | ||
411 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
412 | */ | ||
413 | *************** | ||
414 | *** 50,55 **** | ||
415 | DISTS | ||
416 | } codetype; | ||
417 | |||
418 | ! extern int inflate_table OF((codetype type, unsigned short FAR *lens, | ||
419 | unsigned codes, code FAR * FAR *table, | ||
420 | unsigned FAR *bits, unsigned short FAR *work)); | ||
421 | --- 50,55 ---- | ||
422 | DISTS | ||
423 | } codetype; | ||
424 | |||
425 | ! extern int inflate_table9 OF((codetype type, unsigned short FAR *lens, | ||
426 | unsigned codes, code FAR * FAR *table, | ||
427 | unsigned FAR *bits, unsigned short FAR *work)); | ||
diff --git a/contrib/infback9/infback9.h b/contrib/infback9/infback9.h new file mode 100644 index 0000000..fb7c73e --- /dev/null +++ b/contrib/infback9/infback9.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* infback9.h -- header for using inflateBack9 functions | ||
2 | * Copyright (C) 2003 Mark Adler | ||
3 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
4 | */ | ||
5 | |||
6 | /* | ||
7 | * This header file and associated patches provide a decoder for PKWare's | ||
8 | * undocumented deflate64 compression method (method 9). Use with infback9.c, | ||
9 | * inftree9.h, inftree9.c, and inffix9.h. These patches are not supported. | ||
10 | * This code will almost certainly not work on 16-bit architectures. See the | ||
11 | * comments in zlib.h for inflateBack() usage. These functions are used | ||
12 | * identically, except that there is no windowBits parameter, and a 64K | ||
13 | * window must be provided. zlib.h must be included before this header file. | ||
14 | */ | ||
15 | |||
16 | ZEXTERN int ZEXPORT inflateBack9 OF((z_stream FAR *strm, | ||
17 | in_func in, void FAR *in_desc, | ||
18 | out_func out, void FAR *out_desc)); | ||
19 | ZEXTERN int ZEXPORT inflateBack9End OF((z_stream FAR *strm)); | ||
20 | ZEXTERN int ZEXPORT inflateBack9Init_ OF((z_stream FAR *strm, | ||
21 | unsigned char FAR *window, | ||
22 | const char *version, | ||
23 | int stream_size)); | ||
24 | #define inflateBack9Init(strm, window) \ | ||
25 | inflateBack9Init_((strm), (window), \ | ||
26 | ZLIB_VERSION, sizeof(z_stream)) | ||
diff --git a/contrib/infback9/inffix9.h b/contrib/infback9/inffix9.h new file mode 100644 index 0000000..8476588 --- /dev/null +++ b/contrib/infback9/inffix9.h | |||
@@ -0,0 +1,94 @@ | |||
1 | /* inffix9.h -- table for decoding fixed codes | ||
2 | * Generated automatically by makefixed(). | ||
3 | */ | ||
4 | |||
5 | /* WARNING: this file should *not* be used by applications. | ||
6 | It is part of the implementation of this library and is | ||
7 | subject to change. Applications should only use zlib.h. | ||
8 | */ | ||
9 | |||
10 | static const code lenfix[512] = { | ||
11 | {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, | ||
12 | {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, | ||
13 | {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, | ||
14 | {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, | ||
15 | {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, | ||
16 | {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, | ||
17 | {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, | ||
18 | {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, | ||
19 | {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, | ||
20 | {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, | ||
21 | {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, | ||
22 | {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, | ||
23 | {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, | ||
24 | {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, | ||
25 | {0,8,22},{192,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, | ||
26 | {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, | ||
27 | {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, | ||
28 | {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, | ||
29 | {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, | ||
30 | {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, | ||
31 | {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, | ||
32 | {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, | ||
33 | {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, | ||
34 | {0,8,85},{0,8,21},{32,8,3},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, | ||
35 | {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, | ||
36 | {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, | ||
37 | {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, | ||
38 | {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, | ||
39 | {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, | ||
40 | {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, | ||
41 | {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, | ||
42 | {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, | ||
43 | {16,7,5},{0,8,87},{0,8,23},{78,8,0},{19,7,51},{0,8,119},{0,8,55}, | ||
44 | {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, | ||
45 | {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, | ||
46 | {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, | ||
47 | {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, | ||
48 | {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, | ||
49 | {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, | ||
50 | {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, | ||
51 | {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, | ||
52 | {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, | ||
53 | {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, | ||
54 | {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, | ||
55 | {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, | ||
56 | {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, | ||
57 | {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, | ||
58 | {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, | ||
59 | {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, | ||
60 | {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, | ||
61 | {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{192,8,0},{19,7,51}, | ||
62 | {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, | ||
63 | {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, | ||
64 | {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, | ||
65 | {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, | ||
66 | {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, | ||
67 | {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, | ||
68 | {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, | ||
69 | {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, | ||
70 | {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{32,8,3}, | ||
71 | {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, | ||
72 | {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, | ||
73 | {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, | ||
74 | {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, | ||
75 | {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, | ||
76 | {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, | ||
77 | {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, | ||
78 | {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, | ||
79 | {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, | ||
80 | {78,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, | ||
81 | {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, | ||
82 | {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, | ||
83 | {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, | ||
84 | {0,9,255} | ||
85 | }; | ||
86 | |||
87 | static const code distfix[32] = { | ||
88 | {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, | ||
89 | {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, | ||
90 | {18,5,9},{26,5,2049},{22,5,129},{30,5,32769},{16,5,2},{23,5,385}, | ||
91 | {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, | ||
92 | {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, | ||
93 | {22,5,193},{30,5,49153} | ||
94 | }; | ||
diff --git a/contrib/inflate86/inffast.S b/contrib/inflate86/inffast.S index 3602907..f9bffd5 100644 --- a/contrib/inflate86/inffast.S +++ b/contrib/inflate86/inffast.S | |||
@@ -3,11 +3,11 @@ | |||
3 | * | 3 | * |
4 | * inffast.c -- fast decoding | 4 | * inffast.c -- fast decoding |
5 | * Copyright (C) 1995-2003 Mark Adler | 5 | * Copyright (C) 1995-2003 Mark Adler |
6 | * For conditions of distribution and use, see copyright notice in zlib.h | 6 | * For conditions of distribution and use, see copyright notice in zlib.h |
7 | * | 7 | * |
8 | * Copyright (C) 2003 Chris Anderson <christop@charm.net> | 8 | * Copyright (C) 2003 Chris Anderson <christop@charm.net> |
9 | * Please use the copyright conditions above. | 9 | * Please use the copyright conditions above. |
10 | * | 10 | * |
11 | * This version (Jan-23-2003) of inflate_fast was coded and tested under | 11 | * This version (Jan-23-2003) of inflate_fast was coded and tested under |
12 | * GNU/Linux on a pentium 3, using the gcc-3.2 compiler distribution. On that | 12 | * GNU/Linux on a pentium 3, using the gcc-3.2 compiler distribution. On that |
13 | * machine, I found that gzip style archives decompressed about 20% faster than | 13 | * machine, I found that gzip style archives decompressed about 20% faster than |
@@ -61,7 +61,7 @@ | |||
61 | */ | 61 | */ |
62 | #if ! defined( GAS_COFF ) && ! defined( GAS_ELF ) | 62 | #if ! defined( GAS_COFF ) && ! defined( GAS_ELF ) |
63 | 63 | ||
64 | #if defined( __CYGWIN__ ) | 64 | #if defined( WIN32 ) || defined( __CYGWIN__ ) |
65 | #define GAS_COFF /* windows object format */ | 65 | #define GAS_COFF /* windows object format */ |
66 | #else | 66 | #else |
67 | #define GAS_ELF | 67 | #define GAS_ELF |
@@ -151,14 +151,14 @@ | |||
151 | */ | 151 | */ |
152 | #define mode_state 0 /* state->mode */ | 152 | #define mode_state 0 /* state->mode */ |
153 | #define wsize_state 32 /* state->wsize */ | 153 | #define wsize_state 32 /* state->wsize */ |
154 | #define write_state 36 /* state->write */ | 154 | #define write_state 40 /* state->write */ |
155 | #define window_state 40 /* state->window */ | 155 | #define window_state 44 /* state->window */ |
156 | #define hold_state 44 /* state->hold */ | 156 | #define hold_state 48 /* state->hold */ |
157 | #define bits_state 48 /* state->bits */ | 157 | #define bits_state 52 /* state->bits */ |
158 | #define lencode_state 64 /* state->lencode */ | 158 | #define lencode_state 68 /* state->lencode */ |
159 | #define distcode_state 68 /* state->distcode */ | 159 | #define distcode_state 72 /* state->distcode */ |
160 | #define lenbits_state 72 /* state->lenbits */ | 160 | #define lenbits_state 76 /* state->lenbits */ |
161 | #define distbits_state 76 /* state->distbits */ | 161 | #define distbits_state 80 /* state->distbits */ |
162 | 162 | ||
163 | /* | 163 | /* |
164 | * inflate_fast's activation record | 164 | * inflate_fast's activation record |
@@ -387,7 +387,7 @@ inflate_fast: | |||
387 | * bios may load a cpuid instruction and | 387 | * bios may load a cpuid instruction and |
388 | * cpuid may be disabled on Cyrix 5-6x86 */ | 388 | * cpuid may be disabled on Cyrix 5-6x86 */ |
389 | popf | 389 | popf |
390 | pushf | 390 | pushf |
391 | popl %edx /* copy new eflags to edx */ | 391 | popl %edx /* copy new eflags to edx */ |
392 | xorl %eax, %edx /* test if ID bit is flipped */ | 392 | xorl %eax, %edx /* test if ID bit is flipped */ |
393 | jz .L_dont_use_mmx /* not flipped if zero */ | 393 | jz .L_dont_use_mmx /* not flipped if zero */ |
@@ -420,7 +420,7 @@ inflate_fast: | |||
420 | popl %eax | 420 | popl %eax |
421 | jmp .L_check_mmx | 421 | jmp .L_check_mmx |
422 | #endif | 422 | #endif |
423 | 423 | ||
424 | 424 | ||
425 | /*** Non-MMX code ***/ | 425 | /*** Non-MMX code ***/ |
426 | 426 | ||
@@ -443,7 +443,7 @@ inflate_fast: | |||
443 | .L_do_loop: | 443 | .L_do_loop: |
444 | /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out | 444 | /* regs: %esi = in, %ebp = hold, %bl = bits, %edi = out |
445 | * | 445 | * |
446 | * do { | 446 | * do { |
447 | * if (bits < 15) { | 447 | * if (bits < 15) { |
448 | * hold |= *((unsigned short *)in)++ << bits; | 448 | * hold |= *((unsigned short *)in)++ << bits; |
449 | * bits += 16 | 449 | * bits += 16 |
@@ -900,7 +900,7 @@ inflate_fast: | |||
900 | #define dmask_mm %mm5 | 900 | #define dmask_mm %mm5 |
901 | #define tmp_mm %mm6 | 901 | #define tmp_mm %mm6 |
902 | 902 | ||
903 | movd lmask(%esp), lmask_mm | 903 | movd lmask(%esp), lmask_mm |
904 | movq lmask_mm, lmask2_mm | 904 | movq lmask_mm, lmask2_mm |
905 | movd dmask(%esp), dmask_mm | 905 | movd dmask(%esp), dmask_mm |
906 | movq dmask_mm, dmask2_mm | 906 | movq dmask_mm, dmask2_mm |
@@ -1056,7 +1056,7 @@ inflate_fast: | |||
1056 | jmp .L_while_test_mmx | 1056 | jmp .L_while_test_mmx |
1057 | 1057 | ||
1058 | .align 16,0x90 | 1058 | .align 16,0x90 |
1059 | .L_test_for_second_level_length_mmx: | 1059 | .L_test_for_second_level_length_mmx: |
1060 | testb $64, %al | 1060 | testb $64, %al |
1061 | jnz .L_test_for_end_of_block /* if ((op & 64) != 0) */ | 1061 | jnz .L_test_for_end_of_block /* if ((op & 64) != 0) */ |
1062 | 1062 | ||
diff --git a/contrib/iostream/zfstream.cpp b/contrib/iostream/zfstream.cpp index a690bbe..d0cd85f 100644 --- a/contrib/iostream/zfstream.cpp +++ b/contrib/iostream/zfstream.cpp | |||
@@ -1,5 +1,4 @@ | |||
1 | 1 | ||
2 | #include <memory.h> | ||
3 | #include "zfstream.h" | 2 | #include "zfstream.h" |
4 | 3 | ||
5 | gzfilebuf::gzfilebuf() : | 4 | gzfilebuf::gzfilebuf() : |
@@ -17,15 +16,13 @@ gzfilebuf::~gzfilebuf() { | |||
17 | } | 16 | } |
18 | 17 | ||
19 | gzfilebuf *gzfilebuf::open( const char *name, | 18 | gzfilebuf *gzfilebuf::open( const char *name, |
20 | int io_mode ) { | 19 | int io_mode ) { |
21 | 20 | ||
22 | if ( is_open() ) | 21 | if ( is_open() ) |
23 | return NULL; | 22 | return NULL; |
24 | 23 | ||
25 | char char_mode[10]; | 24 | char char_mode[10]; |
26 | char *p; | 25 | char *p = char_mode; |
27 | memset(char_mode,'\0',10); | ||
28 | p = char_mode; | ||
29 | 26 | ||
30 | if ( io_mode & ios::in ) { | 27 | if ( io_mode & ios::in ) { |
31 | mode = ios::in; | 28 | mode = ios::in; |
@@ -48,6 +45,9 @@ gzfilebuf *gzfilebuf::open( const char *name, | |||
48 | *p++ = '9'; | 45 | *p++ = '9'; |
49 | } | 46 | } |
50 | 47 | ||
48 | // Put the end-of-string indicator | ||
49 | *p = '\0'; | ||
50 | |||
51 | if ( (file = gzopen(name, char_mode)) == NULL ) | 51 | if ( (file = gzopen(name, char_mode)) == NULL ) |
52 | return NULL; | 52 | return NULL; |
53 | 53 | ||
@@ -58,15 +58,13 @@ gzfilebuf *gzfilebuf::open( const char *name, | |||
58 | } | 58 | } |
59 | 59 | ||
60 | gzfilebuf *gzfilebuf::attach( int file_descriptor, | 60 | gzfilebuf *gzfilebuf::attach( int file_descriptor, |
61 | int io_mode ) { | 61 | int io_mode ) { |
62 | 62 | ||
63 | if ( is_open() ) | 63 | if ( is_open() ) |
64 | return NULL; | 64 | return NULL; |
65 | 65 | ||
66 | char char_mode[10]; | 66 | char char_mode[10]; |
67 | char *p; | 67 | char *p = char_mode; |
68 | memset(char_mode,'\0',10); | ||
69 | p = char_mode; | ||
70 | 68 | ||
71 | if ( io_mode & ios::in ) { | 69 | if ( io_mode & ios::in ) { |
72 | mode = ios::in; | 70 | mode = ios::in; |
@@ -89,6 +87,9 @@ gzfilebuf *gzfilebuf::attach( int file_descriptor, | |||
89 | *p++ = '9'; | 87 | *p++ = '9'; |
90 | } | 88 | } |
91 | 89 | ||
90 | // Put the end-of-string indicator | ||
91 | *p = '\0'; | ||
92 | |||
92 | if ( (file = gzdopen(file_descriptor, char_mode)) == NULL ) | 93 | if ( (file = gzdopen(file_descriptor, char_mode)) == NULL ) |
93 | return NULL; | 94 | return NULL; |
94 | 95 | ||
@@ -112,13 +113,13 @@ gzfilebuf *gzfilebuf::close() { | |||
112 | 113 | ||
113 | } | 114 | } |
114 | 115 | ||
115 | int gzfilebuf::setcompressionlevel( short comp_level ) { | 116 | int gzfilebuf::setcompressionlevel( int comp_level ) { |
116 | 117 | ||
117 | return gzsetparams(file, comp_level, -2); | 118 | return gzsetparams(file, comp_level, -2); |
118 | 119 | ||
119 | } | 120 | } |
120 | 121 | ||
121 | int gzfilebuf::setcompressionstrategy( short comp_strategy ) { | 122 | int gzfilebuf::setcompressionstrategy( int comp_strategy ) { |
122 | 123 | ||
123 | return gzsetparams(file, -2, comp_strategy); | 124 | return gzsetparams(file, -2, comp_strategy); |
124 | 125 | ||
@@ -151,7 +152,7 @@ int gzfilebuf::underflow() { | |||
151 | 152 | ||
152 | if ( out_waiting() ) { | 153 | if ( out_waiting() ) { |
153 | if ( flushbuf() == EOF ) | 154 | if ( flushbuf() == EOF ) |
154 | return EOF; | 155 | return EOF; |
155 | } | 156 | } |
156 | 157 | ||
157 | } | 158 | } |
@@ -180,11 +181,11 @@ int gzfilebuf::overflow( int c ) { | |||
180 | setg(0,0,0); | 181 | setg(0,0,0); |
181 | } else { | 182 | } else { |
182 | if (in_avail()) { | 183 | if (in_avail()) { |
183 | return EOF; | 184 | return EOF; |
184 | } | 185 | } |
185 | if (out_waiting()) { | 186 | if (out_waiting()) { |
186 | if (flushbuf() == EOF) | 187 | if (flushbuf() == EOF) |
187 | return EOF; | 188 | return EOF; |
188 | } | 189 | } |
189 | } | 190 | } |
190 | 191 | ||
@@ -282,12 +283,11 @@ void gzfilestream_common::close() { | |||
282 | 283 | ||
283 | } | 284 | } |
284 | 285 | ||
285 | gzfilebuf *gzfilestream_common::rdbuf() { | 286 | gzfilebuf *gzfilestream_common::rdbuf() |
286 | 287 | { | |
287 | return &buffer; | 288 | return &buffer; |
288 | |||
289 | } | 289 | } |
290 | 290 | ||
291 | gzifstream::gzifstream() : | 291 | gzifstream::gzifstream() : |
292 | ios( gzfilestream_common::rdbuf() ) | 292 | ios( gzfilestream_common::rdbuf() ) |
293 | { | 293 | { |
diff --git a/contrib/iostream/zfstream.h b/contrib/iostream/zfstream.h index c87fa08..ed79098 100644 --- a/contrib/iostream/zfstream.h +++ b/contrib/iostream/zfstream.h | |||
@@ -1,6 +1,6 @@ | |||
1 | 1 | ||
2 | #ifndef _zfstream_h | 2 | #ifndef zfstream_h |
3 | #define _zfstream_h | 3 | #define zfstream_h |
4 | 4 | ||
5 | #include <fstream.h> | 5 | #include <fstream.h> |
6 | #include "zlib.h" | 6 | #include "zlib.h" |
@@ -16,8 +16,8 @@ public: | |||
16 | gzfilebuf *attach( int file_descriptor, int io_mode ); | 16 | gzfilebuf *attach( int file_descriptor, int io_mode ); |
17 | gzfilebuf *close(); | 17 | gzfilebuf *close(); |
18 | 18 | ||
19 | int setcompressionlevel( short comp_level ); | 19 | int setcompressionlevel( int comp_level ); |
20 | int setcompressionstrategy( short comp_strategy ); | 20 | int setcompressionstrategy( int comp_strategy ); |
21 | 21 | ||
22 | inline int is_open() const { return (file !=NULL); } | 22 | inline int is_open() const { return (file !=NULL); } |
23 | 23 | ||
@@ -98,18 +98,19 @@ private: | |||
98 | T val; | 98 | T val; |
99 | }; | 99 | }; |
100 | 100 | ||
101 | template<class T> gzofstream &operator<<(gzofstream &s, | 101 | template<class T> gzofstream &operator<<(gzofstream &s, const gzomanip<T> &m) |
102 | const gzomanip<T> &m) { | 102 | { |
103 | return (*m.func)(s, m.val); | 103 | return (*m.func)(s, m.val); |
104 | |||
105 | } | 104 | } |
106 | 105 | ||
107 | inline gzofstream &setcompressionlevel( gzofstream &s, int l ) { | 106 | inline gzofstream &setcompressionlevel( gzofstream &s, int l ) |
107 | { | ||
108 | (s.rdbuf())->setcompressionlevel(l); | 108 | (s.rdbuf())->setcompressionlevel(l); |
109 | return s; | 109 | return s; |
110 | } | 110 | } |
111 | 111 | ||
112 | inline gzofstream &setcompressionstrategy( gzofstream &s, int l ) { | 112 | inline gzofstream &setcompressionstrategy( gzofstream &s, int l ) |
113 | { | ||
113 | (s.rdbuf())->setcompressionstrategy(l); | 114 | (s.rdbuf())->setcompressionstrategy(l); |
114 | return s; | 115 | return s; |
115 | } | 116 | } |
@@ -125,18 +126,3 @@ inline gzomanip<int> setcompressionstrategy(int l) | |||
125 | } | 126 | } |
126 | 127 | ||
127 | #endif | 128 | #endif |
128 | |||
129 | |||
130 | |||
131 | |||
132 | |||
133 | |||
134 | |||
135 | |||
136 | |||
137 | |||
138 | |||
139 | |||
140 | |||
141 | |||
142 | |||
diff --git a/contrib/iostream2/zstream_test.cpp b/contrib/iostream2/zstream_test.cpp index 5bbd56c..6273f62 100644 --- a/contrib/iostream2/zstream_test.cpp +++ b/contrib/iostream2/zstream_test.cpp | |||
@@ -4,9 +4,9 @@ | |||
4 | #include <iomanip.h> | 4 | #include <iomanip.h> |
5 | 5 | ||
6 | void main() { | 6 | void main() { |
7 | char h[256] = "Hello"; | 7 | char h[256] = "Hello"; |
8 | char* g = "Goodbye"; | 8 | char* g = "Goodbye"; |
9 | ozstream out("temp.gz"); | 9 | ozstream out("temp.gz"); |
10 | out < "This works well" < h < g; | 10 | out < "This works well" < h < g; |
11 | out.close(); | 11 | out.close(); |
12 | 12 | ||
diff --git a/contrib/iostream3/README b/contrib/iostream3/README index 6f73d58..f7b319a 100644 --- a/contrib/iostream3/README +++ b/contrib/iostream3/README | |||
@@ -3,19 +3,19 @@ to do things like: | |||
3 | 3 | ||
4 | gzofstream outf("blah.gz"); | 4 | gzofstream outf("blah.gz"); |
5 | outf << "These go into the gzip file " << 123 << endl; | 5 | outf << "These go into the gzip file " << 123 << endl; |
6 | 6 | ||
7 | It does this by deriving a specialized stream buffer for gzipped files, which is | 7 | It does this by deriving a specialized stream buffer for gzipped files, which is |
8 | the way Stroustrup would have done it. :-> | 8 | the way Stroustrup would have done it. :-> |
9 | 9 | ||
10 | The gzifstream and gzofstream classes were originally written by Kevin Ruland | 10 | The gzifstream and gzofstream classes were originally written by Kevin Ruland |
11 | and made available in the zlib contrib/iostream directory. The older version still | 11 | and made available in the zlib contrib/iostream directory. The older version still |
12 | compiles under gcc 2.xx, but not under gcc 3.xx, which sparked the development of | 12 | compiles under gcc 2.xx, but not under gcc 3.xx, which sparked the development of |
13 | this version. | 13 | this version. |
14 | 14 | ||
15 | The new classes are as standard-compliant as possible, closely following the | 15 | The new classes are as standard-compliant as possible, closely following the |
16 | approach of the standard library's fstream classes. It compiles under gcc versions | 16 | approach of the standard library's fstream classes. It compiles under gcc versions |
17 | 3.2 and 3.3, but not under gcc 2.xx. This is mainly due to changes in the standard | 17 | 3.2 and 3.3, but not under gcc 2.xx. This is mainly due to changes in the standard |
18 | library naming scheme. The new version of gzifstream/gzofstream/gzfilebuf differs | 18 | library naming scheme. The new version of gzifstream/gzofstream/gzfilebuf differs |
19 | from the previous one in the following respects: | 19 | from the previous one in the following respects: |
20 | - added showmanyc | 20 | - added showmanyc |
21 | - added setbuf, with support for unbuffered output via setbuf(0,0) | 21 | - added setbuf, with support for unbuffered output via setbuf(0,0) |
@@ -23,7 +23,7 @@ from the previous one in the following respects: | |||
23 | - gzipped output file opened with default compression level instead of maximum level | 23 | - gzipped output file opened with default compression level instead of maximum level |
24 | - setcompressionlevel()/strategy() members replaced by single setcompression() | 24 | - setcompressionlevel()/strategy() members replaced by single setcompression() |
25 | 25 | ||
26 | The code is provided "as is", with the permission to use, copy, modify, distribute | 26 | The code is provided "as is", with the permission to use, copy, modify, distribute |
27 | and sell it for any purpose without fee. | 27 | and sell it for any purpose without fee. |
28 | 28 | ||
29 | Ludwig Schwardt | 29 | Ludwig Schwardt |
diff --git a/contrib/iostream3/TODO b/contrib/iostream3/TODO index 4578326..7032f97 100644 --- a/contrib/iostream3/TODO +++ b/contrib/iostream3/TODO | |||
@@ -13,5 +13,5 @@ Possible upgrades to gzfilebuf: | |||
13 | - Check public interface to see which calls give problems | 13 | - Check public interface to see which calls give problems |
14 | (due to dependence on library internals) | 14 | (due to dependence on library internals) |
15 | 15 | ||
16 | - Override operator<<(ostream&, gzfilebuf*) to allow direct copying | 16 | - Override operator<<(ostream&, gzfilebuf*) to allow direct copying |
17 | of stream buffer to stream ( i.e. os << is.rdbuf(); ) | 17 | of stream buffer to stream ( i.e. os << is.rdbuf(); ) |
diff --git a/contrib/iostream3/test.cc b/contrib/iostream3/test.cc index 9ffa8be..9423533 100644 --- a/contrib/iostream3/test.cc +++ b/contrib/iostream3/test.cc | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Test program for gzifstream and gzofstream | 2 | * Test program for gzifstream and gzofstream |
3 | * | 3 | * |
4 | * by Ludwig Schwardt <schwardt@sun.ac.za> | 4 | * by Ludwig Schwardt <schwardt@sun.ac.za> |
5 | * original version by Kevin Ruland <kevin@rodin.wustl.edu> | 5 | * original version by Kevin Ruland <kevin@rodin.wustl.edu> |
6 | */ | 6 | */ |
@@ -13,15 +13,15 @@ int main() { | |||
13 | gzofstream outf; | 13 | gzofstream outf; |
14 | gzifstream inf; | 14 | gzifstream inf; |
15 | char buf[80]; | 15 | char buf[80]; |
16 | 16 | ||
17 | outf.open("test1.txt.gz"); | 17 | outf.open("test1.txt.gz"); |
18 | outf << "The quick brown fox sidestepped the lazy canine\n" | 18 | outf << "The quick brown fox sidestepped the lazy canine\n" |
19 | << 1.3 << "\nPlan " << 9 << std::endl; | 19 | << 1.3 << "\nPlan " << 9 << std::endl; |
20 | outf.close(); | 20 | outf.close(); |
21 | std::cout << "Wrote the following message to 'test1.txt.gz' (check with zcat or zless):\n" | 21 | std::cout << "Wrote the following message to 'test1.txt.gz' (check with zcat or zless):\n" |
22 | << "The quick brown fox sidestepped the lazy canine\n" | 22 | << "The quick brown fox sidestepped the lazy canine\n" |
23 | << 1.3 << "\nPlan " << 9 << std::endl; | 23 | << 1.3 << "\nPlan " << 9 << std::endl; |
24 | 24 | ||
25 | std::cout << "\nReading 'test1.txt.gz' (buffered) produces:\n"; | 25 | std::cout << "\nReading 'test1.txt.gz' (buffered) produces:\n"; |
26 | inf.open("test1.txt.gz"); | 26 | inf.open("test1.txt.gz"); |
27 | while (inf.getline(buf,80,'\n')) { | 27 | while (inf.getline(buf,80,'\n')) { |
diff --git a/contrib/iostream3/zfstream.cc b/contrib/iostream3/zfstream.cc index 24d15fa..94eb933 100644 --- a/contrib/iostream3/zfstream.cc +++ b/contrib/iostream3/zfstream.cc | |||
@@ -1,9 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * A C++ I/O streams interface to the zlib gz* functions | 2 | * A C++ I/O streams interface to the zlib gz* functions |
3 | * | 3 | * |
4 | * by Ludwig Schwardt <schwardt@sun.ac.za> | 4 | * by Ludwig Schwardt <schwardt@sun.ac.za> |
5 | * original version by Kevin Ruland <kevin@rodin.wustl.edu> | 5 | * original version by Kevin Ruland <kevin@rodin.wustl.edu> |
6 | * | 6 | * |
7 | * This version is standard-compliant and compatible with gcc 3.x. | 7 | * This version is standard-compliant and compatible with gcc 3.x. |
8 | */ | 8 | */ |
9 | 9 | ||
@@ -18,8 +18,8 @@ | |||
18 | /*****************************************************************************/ | 18 | /*****************************************************************************/ |
19 | 19 | ||
20 | // Default constructor | 20 | // Default constructor |
21 | gzfilebuf::gzfilebuf() | 21 | gzfilebuf::gzfilebuf() |
22 | : file(NULL), io_mode(std::ios_base::openmode(0)), own_fd(false), | 22 | : file(NULL), io_mode(std::ios_base::openmode(0)), own_fd(false), |
23 | buffer(NULL), buffer_size(BIGBUFSIZE), own_buffer(true) | 23 | buffer(NULL), buffer_size(BIGBUFSIZE), own_buffer(true) |
24 | { | 24 | { |
25 | // No buffers to start with | 25 | // No buffers to start with |
@@ -27,12 +27,12 @@ gzfilebuf::gzfilebuf() | |||
27 | } | 27 | } |
28 | 28 | ||
29 | // Destructor | 29 | // Destructor |
30 | gzfilebuf::~gzfilebuf() | 30 | gzfilebuf::~gzfilebuf() |
31 | { | 31 | { |
32 | // Sync output buffer and close only if responsible for file | 32 | // Sync output buffer and close only if responsible for file |
33 | // (i.e. attached streams should be left open at this stage) | 33 | // (i.e. attached streams should be left open at this stage) |
34 | this->sync(); | 34 | this->sync(); |
35 | if (own_fd) | 35 | if (own_fd) |
36 | this->close(); | 36 | this->close(); |
37 | // Make sure internal buffer is deallocated | 37 | // Make sure internal buffer is deallocated |
38 | this->disable_buffer(); | 38 | this->disable_buffer(); |
@@ -41,30 +41,30 @@ gzfilebuf::~gzfilebuf() | |||
41 | // Set compression level and strategy | 41 | // Set compression level and strategy |
42 | int | 42 | int |
43 | gzfilebuf::setcompression(int comp_level, | 43 | gzfilebuf::setcompression(int comp_level, |
44 | int comp_strategy) | 44 | int comp_strategy) |
45 | { | 45 | { |
46 | return gzsetparams(file, comp_level, comp_strategy); | 46 | return gzsetparams(file, comp_level, comp_strategy); |
47 | } | 47 | } |
48 | 48 | ||
49 | // Open gzipped file | 49 | // Open gzipped file |
50 | gzfilebuf* | 50 | gzfilebuf* |
51 | gzfilebuf::open(const char *name, | 51 | gzfilebuf::open(const char *name, |
52 | std::ios_base::openmode mode) | 52 | std::ios_base::openmode mode) |
53 | { | 53 | { |
54 | // Fail if file already open | 54 | // Fail if file already open |
55 | if (this->is_open()) | 55 | if (this->is_open()) |
56 | return NULL; | 56 | return NULL; |
57 | // Don't support simultaneous read/write access (yet) | 57 | // Don't support simultaneous read/write access (yet) |
58 | if ((mode & std::ios_base::in) && (mode & std::ios_base::out)) | 58 | if ((mode & std::ios_base::in) && (mode & std::ios_base::out)) |
59 | return NULL; | 59 | return NULL; |
60 | 60 | ||
61 | // Build mode string for gzopen and check it [27.8.1.3.2] | 61 | // Build mode string for gzopen and check it [27.8.1.3.2] |
62 | char char_mode[6] = "\0\0\0\0\0"; | 62 | char char_mode[6] = "\0\0\0\0\0"; |
63 | if (!this->open_mode(mode, char_mode)) | 63 | if (!this->open_mode(mode, char_mode)) |
64 | return NULL; | 64 | return NULL; |
65 | 65 | ||
66 | // Attempt to open file | 66 | // Attempt to open file |
67 | if ((file = gzopen(name, char_mode)) == NULL) | 67 | if ((file = gzopen(name, char_mode)) == NULL) |
68 | return NULL; | 68 | return NULL; |
69 | 69 | ||
70 | // On success, allocate internal buffer and set flags | 70 | // On success, allocate internal buffer and set flags |
@@ -77,24 +77,24 @@ gzfilebuf::open(const char *name, | |||
77 | // Attach to gzipped file | 77 | // Attach to gzipped file |
78 | gzfilebuf* | 78 | gzfilebuf* |
79 | gzfilebuf::attach(int fd, | 79 | gzfilebuf::attach(int fd, |
80 | std::ios_base::openmode mode) | 80 | std::ios_base::openmode mode) |
81 | { | 81 | { |
82 | // Fail if file already open | 82 | // Fail if file already open |
83 | if (this->is_open()) | 83 | if (this->is_open()) |
84 | return NULL; | 84 | return NULL; |
85 | // Don't support simultaneous read/write access (yet) | 85 | // Don't support simultaneous read/write access (yet) |
86 | if ((mode & std::ios_base::in) && (mode & std::ios_base::out)) | 86 | if ((mode & std::ios_base::in) && (mode & std::ios_base::out)) |
87 | return NULL; | 87 | return NULL; |
88 | 88 | ||
89 | // Build mode string for gzdopen and check it [27.8.1.3.2] | 89 | // Build mode string for gzdopen and check it [27.8.1.3.2] |
90 | char char_mode[6] = "\0\0\0\0\0"; | 90 | char char_mode[6] = "\0\0\0\0\0"; |
91 | if (!this->open_mode(mode, char_mode)) | 91 | if (!this->open_mode(mode, char_mode)) |
92 | return NULL; | 92 | return NULL; |
93 | 93 | ||
94 | // Attempt to attach to file | 94 | // Attempt to attach to file |
95 | if ((file = gzdopen(fd, char_mode)) == NULL) | 95 | if ((file = gzdopen(fd, char_mode)) == NULL) |
96 | return NULL; | 96 | return NULL; |
97 | 97 | ||
98 | // On success, allocate internal buffer and set flags | 98 | // On success, allocate internal buffer and set flags |
99 | this->enable_buffer(); | 99 | this->enable_buffer(); |
100 | io_mode = mode; | 100 | io_mode = mode; |
@@ -104,7 +104,7 @@ gzfilebuf::attach(int fd, | |||
104 | 104 | ||
105 | // Close gzipped file | 105 | // Close gzipped file |
106 | gzfilebuf* | 106 | gzfilebuf* |
107 | gzfilebuf::close() | 107 | gzfilebuf::close() |
108 | { | 108 | { |
109 | // Fail immediately if no file is open | 109 | // Fail immediately if no file is open |
110 | if (!this->is_open()) | 110 | if (!this->is_open()) |
@@ -127,16 +127,16 @@ gzfilebuf::close() | |||
127 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | 127 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
128 | 128 | ||
129 | // Convert int open mode to mode string | 129 | // Convert int open mode to mode string |
130 | bool | 130 | bool |
131 | gzfilebuf::open_mode(std::ios_base::openmode mode, | 131 | gzfilebuf::open_mode(std::ios_base::openmode mode, |
132 | char* c_mode) const | 132 | char* c_mode) const |
133 | { | 133 | { |
134 | bool testb = mode & std::ios_base::binary; | 134 | bool testb = mode & std::ios_base::binary; |
135 | bool testi = mode & std::ios_base::in; | 135 | bool testi = mode & std::ios_base::in; |
136 | bool testo = mode & std::ios_base::out; | 136 | bool testo = mode & std::ios_base::out; |
137 | bool testt = mode & std::ios_base::trunc; | 137 | bool testt = mode & std::ios_base::trunc; |
138 | bool testa = mode & std::ios_base::app; | 138 | bool testa = mode & std::ios_base::app; |
139 | 139 | ||
140 | // Check for valid flag combinations - see [27.8.1.3.2] (Table 92) | 140 | // Check for valid flag combinations - see [27.8.1.3.2] (Table 92) |
141 | // Original zfstream hardcoded the compression level to maximum here... | 141 | // Original zfstream hardcoded the compression level to maximum here... |
142 | // Double the time for less than 1% size improvement seems | 142 | // Double the time for less than 1% size improvement seems |
@@ -156,7 +156,7 @@ gzfilebuf::open_mode(std::ios_base::openmode mode, | |||
156 | // if (testi && testo && testt && !testa) | 156 | // if (testi && testo && testt && !testa) |
157 | // strcpy(c_mode, "w+"); | 157 | // strcpy(c_mode, "w+"); |
158 | 158 | ||
159 | // Mode string should be empty for invalid combination of flags | 159 | // Mode string should be empty for invalid combination of flags |
160 | if (strlen(c_mode) == 0) | 160 | if (strlen(c_mode) == 0) |
161 | return false; | 161 | return false; |
162 | if (testb) | 162 | if (testb) |
@@ -165,7 +165,7 @@ gzfilebuf::open_mode(std::ios_base::openmode mode, | |||
165 | } | 165 | } |
166 | 166 | ||
167 | // Determine number of characters in internal get buffer | 167 | // Determine number of characters in internal get buffer |
168 | std::streamsize | 168 | std::streamsize |
169 | gzfilebuf::showmanyc() | 169 | gzfilebuf::showmanyc() |
170 | { | 170 | { |
171 | // Calls to underflow will fail if file not opened for reading | 171 | // Calls to underflow will fail if file not opened for reading |
@@ -180,10 +180,10 @@ gzfilebuf::showmanyc() | |||
180 | 180 | ||
181 | // Fill get area from gzipped file | 181 | // Fill get area from gzipped file |
182 | gzfilebuf::int_type | 182 | gzfilebuf::int_type |
183 | gzfilebuf::underflow() | 183 | gzfilebuf::underflow() |
184 | { | 184 | { |
185 | // If something is left in the get area by chance, return it | 185 | // If something is left in the get area by chance, return it |
186 | // (this shouldn't normally happen, as underflow is only supposed | 186 | // (this shouldn't normally happen, as underflow is only supposed |
187 | // to be called when gptr >= egptr, but it serves as error check) | 187 | // to be called when gptr >= egptr, but it serves as error check) |
188 | if (this->gptr() && (this->gptr() < this->egptr())) | 188 | if (this->gptr() && (this->gptr() < this->egptr())) |
189 | return traits_type::to_int_type(*(this->gptr())); | 189 | return traits_type::to_int_type(*(this->gptr())); |
@@ -204,14 +204,14 @@ gzfilebuf::underflow() | |||
204 | } | 204 | } |
205 | // Make all bytes read from file available as get area | 205 | // Make all bytes read from file available as get area |
206 | this->setg(buffer, buffer, buffer + bytes_read); | 206 | this->setg(buffer, buffer, buffer + bytes_read); |
207 | 207 | ||
208 | // Return next character in get area | 208 | // Return next character in get area |
209 | return traits_type::to_int_type(*(this->gptr())); | 209 | return traits_type::to_int_type(*(this->gptr())); |
210 | } | 210 | } |
211 | 211 | ||
212 | // Write put area to gzipped file | 212 | // Write put area to gzipped file |
213 | gzfilebuf::int_type | 213 | gzfilebuf::int_type |
214 | gzfilebuf::overflow(int_type c) | 214 | gzfilebuf::overflow(int_type c) |
215 | { | 215 | { |
216 | // Determine whether put area is in use | 216 | // Determine whether put area is in use |
217 | if (this->pbase()) | 217 | if (this->pbase()) |
@@ -232,10 +232,10 @@ gzfilebuf::overflow(int_type c) | |||
232 | { | 232 | { |
233 | // If the file hasn't been opened for writing, produce error | 233 | // If the file hasn't been opened for writing, produce error |
234 | if (!this->is_open() || !(io_mode & std::ios_base::out)) | 234 | if (!this->is_open() || !(io_mode & std::ios_base::out)) |
235 | return traits_type::eof(); | 235 | return traits_type::eof(); |
236 | // If gzipped file won't accept all bytes written to it, fail | 236 | // If gzipped file won't accept all bytes written to it, fail |
237 | if (gzwrite(file, this->pbase(), bytes_to_write) != bytes_to_write) | 237 | if (gzwrite(file, this->pbase(), bytes_to_write) != bytes_to_write) |
238 | return traits_type::eof(); | 238 | return traits_type::eof(); |
239 | // Reset next pointer to point to pbase on success | 239 | // Reset next pointer to point to pbase on success |
240 | this->pbump(-bytes_to_write); | 240 | this->pbump(-bytes_to_write); |
241 | } | 241 | } |
@@ -250,7 +250,7 @@ gzfilebuf::overflow(int_type c) | |||
250 | char_type last_char = traits_type::to_char_type(c); | 250 | char_type last_char = traits_type::to_char_type(c); |
251 | // If gzipped file won't accept this character, fail | 251 | // If gzipped file won't accept this character, fail |
252 | if (gzwrite(file, &last_char, 1) != 1) | 252 | if (gzwrite(file, &last_char, 1) != 1) |
253 | return traits_type::eof(); | 253 | return traits_type::eof(); |
254 | } | 254 | } |
255 | 255 | ||
256 | // If you got here, you have succeeded (even if c was EOF) | 256 | // If you got here, you have succeeded (even if c was EOF) |
@@ -262,9 +262,9 @@ gzfilebuf::overflow(int_type c) | |||
262 | } | 262 | } |
263 | 263 | ||
264 | // Assign new buffer | 264 | // Assign new buffer |
265 | std::streambuf* | 265 | std::streambuf* |
266 | gzfilebuf::setbuf(char_type* p, | 266 | gzfilebuf::setbuf(char_type* p, |
267 | std::streamsize n) | 267 | std::streamsize n) |
268 | { | 268 | { |
269 | // First make sure stuff is sync'ed, for safety | 269 | // First make sure stuff is sync'ed, for safety |
270 | if (this->sync() == -1) | 270 | if (this->sync() == -1) |
@@ -295,8 +295,8 @@ gzfilebuf::setbuf(char_type* p, | |||
295 | } | 295 | } |
296 | 296 | ||
297 | // Write put area to gzipped file (i.e. ensures that put area is empty) | 297 | // Write put area to gzipped file (i.e. ensures that put area is empty) |
298 | int | 298 | int |
299 | gzfilebuf::sync() | 299 | gzfilebuf::sync() |
300 | { | 300 | { |
301 | return traits_type::eq_int_type(this->overflow(), traits_type::eof()) ? -1 : 0; | 301 | return traits_type::eq_int_type(this->overflow(), traits_type::eof()) ? -1 : 0; |
302 | } | 302 | } |
@@ -304,11 +304,11 @@ gzfilebuf::sync() | |||
304 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | 304 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
305 | 305 | ||
306 | // Allocate internal buffer | 306 | // Allocate internal buffer |
307 | void | 307 | void |
308 | gzfilebuf::enable_buffer() | 308 | gzfilebuf::enable_buffer() |
309 | { | 309 | { |
310 | // If internal buffer required, allocate one | 310 | // If internal buffer required, allocate one |
311 | if (own_buffer && !buffer) | 311 | if (own_buffer && !buffer) |
312 | { | 312 | { |
313 | // Check for buffered vs. "unbuffered" | 313 | // Check for buffered vs. "unbuffered" |
314 | if (buffer_size > 0) | 314 | if (buffer_size > 0) |
@@ -335,16 +335,16 @@ gzfilebuf::enable_buffer() | |||
335 | } | 335 | } |
336 | else | 336 | else |
337 | { | 337 | { |
338 | // If buffer already allocated, reset buffer pointers just to make sure no | 338 | // If buffer already allocated, reset buffer pointers just to make sure no |
339 | // stale chars are lying around | 339 | // stale chars are lying around |
340 | this->setg(buffer, buffer, buffer); | 340 | this->setg(buffer, buffer, buffer); |
341 | this->setp(buffer, buffer + buffer_size - 1); | 341 | this->setp(buffer, buffer + buffer_size - 1); |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | // Destroy internal buffer | 345 | // Destroy internal buffer |
346 | void | 346 | void |
347 | gzfilebuf::disable_buffer() | 347 | gzfilebuf::disable_buffer() |
348 | { | 348 | { |
349 | // If internal buffer exists, deallocate it | 349 | // If internal buffer exists, deallocate it |
350 | if (own_buffer && buffer) | 350 | if (own_buffer && buffer) |
@@ -371,13 +371,13 @@ gzfilebuf::disable_buffer() | |||
371 | /*****************************************************************************/ | 371 | /*****************************************************************************/ |
372 | 372 | ||
373 | // Default constructor initializes stream buffer | 373 | // Default constructor initializes stream buffer |
374 | gzifstream::gzifstream() | 374 | gzifstream::gzifstream() |
375 | : std::istream(NULL), sb() | 375 | : std::istream(NULL), sb() |
376 | { this->init(&sb); } | 376 | { this->init(&sb); } |
377 | 377 | ||
378 | // Initialize stream buffer and open file | 378 | // Initialize stream buffer and open file |
379 | gzifstream::gzifstream(const char* name, | 379 | gzifstream::gzifstream(const char* name, |
380 | std::ios_base::openmode mode) | 380 | std::ios_base::openmode mode) |
381 | : std::istream(NULL), sb() | 381 | : std::istream(NULL), sb() |
382 | { | 382 | { |
383 | this->init(&sb); | 383 | this->init(&sb); |
@@ -386,7 +386,7 @@ gzifstream::gzifstream(const char* name, | |||
386 | 386 | ||
387 | // Initialize stream buffer and attach to file | 387 | // Initialize stream buffer and attach to file |
388 | gzifstream::gzifstream(int fd, | 388 | gzifstream::gzifstream(int fd, |
389 | std::ios_base::openmode mode) | 389 | std::ios_base::openmode mode) |
390 | : std::istream(NULL), sb() | 390 | : std::istream(NULL), sb() |
391 | { | 391 | { |
392 | this->init(&sb); | 392 | this->init(&sb); |
@@ -394,9 +394,9 @@ gzifstream::gzifstream(int fd, | |||
394 | } | 394 | } |
395 | 395 | ||
396 | // Open file and go into fail() state if unsuccessful | 396 | // Open file and go into fail() state if unsuccessful |
397 | void | 397 | void |
398 | gzifstream::open(const char* name, | 398 | gzifstream::open(const char* name, |
399 | std::ios_base::openmode mode) | 399 | std::ios_base::openmode mode) |
400 | { | 400 | { |
401 | if (!sb.open(name, mode | std::ios_base::in)) | 401 | if (!sb.open(name, mode | std::ios_base::in)) |
402 | this->setstate(std::ios_base::failbit); | 402 | this->setstate(std::ios_base::failbit); |
@@ -405,9 +405,9 @@ gzifstream::open(const char* name, | |||
405 | } | 405 | } |
406 | 406 | ||
407 | // Attach to file and go into fail() state if unsuccessful | 407 | // Attach to file and go into fail() state if unsuccessful |
408 | void | 408 | void |
409 | gzifstream::attach(int fd, | 409 | gzifstream::attach(int fd, |
410 | std::ios_base::openmode mode) | 410 | std::ios_base::openmode mode) |
411 | { | 411 | { |
412 | if (!sb.attach(fd, mode | std::ios_base::in)) | 412 | if (!sb.attach(fd, mode | std::ios_base::in)) |
413 | this->setstate(std::ios_base::failbit); | 413 | this->setstate(std::ios_base::failbit); |
@@ -416,7 +416,7 @@ gzifstream::attach(int fd, | |||
416 | } | 416 | } |
417 | 417 | ||
418 | // Close file | 418 | // Close file |
419 | void | 419 | void |
420 | gzifstream::close() | 420 | gzifstream::close() |
421 | { | 421 | { |
422 | if (!sb.close()) | 422 | if (!sb.close()) |
@@ -426,13 +426,13 @@ gzifstream::close() | |||
426 | /*****************************************************************************/ | 426 | /*****************************************************************************/ |
427 | 427 | ||
428 | // Default constructor initializes stream buffer | 428 | // Default constructor initializes stream buffer |
429 | gzofstream::gzofstream() | 429 | gzofstream::gzofstream() |
430 | : std::ostream(NULL), sb() | 430 | : std::ostream(NULL), sb() |
431 | { this->init(&sb); } | 431 | { this->init(&sb); } |
432 | 432 | ||
433 | // Initialize stream buffer and open file | 433 | // Initialize stream buffer and open file |
434 | gzofstream::gzofstream(const char* name, | 434 | gzofstream::gzofstream(const char* name, |
435 | std::ios_base::openmode mode) | 435 | std::ios_base::openmode mode) |
436 | : std::ostream(NULL), sb() | 436 | : std::ostream(NULL), sb() |
437 | { | 437 | { |
438 | this->init(&sb); | 438 | this->init(&sb); |
@@ -441,7 +441,7 @@ gzofstream::gzofstream(const char* name, | |||
441 | 441 | ||
442 | // Initialize stream buffer and attach to file | 442 | // Initialize stream buffer and attach to file |
443 | gzofstream::gzofstream(int fd, | 443 | gzofstream::gzofstream(int fd, |
444 | std::ios_base::openmode mode) | 444 | std::ios_base::openmode mode) |
445 | : std::ostream(NULL), sb() | 445 | : std::ostream(NULL), sb() |
446 | { | 446 | { |
447 | this->init(&sb); | 447 | this->init(&sb); |
@@ -449,9 +449,9 @@ gzofstream::gzofstream(int fd, | |||
449 | } | 449 | } |
450 | 450 | ||
451 | // Open file and go into fail() state if unsuccessful | 451 | // Open file and go into fail() state if unsuccessful |
452 | void | 452 | void |
453 | gzofstream::open(const char* name, | 453 | gzofstream::open(const char* name, |
454 | std::ios_base::openmode mode) | 454 | std::ios_base::openmode mode) |
455 | { | 455 | { |
456 | if (!sb.open(name, mode | std::ios_base::out)) | 456 | if (!sb.open(name, mode | std::ios_base::out)) |
457 | this->setstate(std::ios_base::failbit); | 457 | this->setstate(std::ios_base::failbit); |
@@ -460,9 +460,9 @@ gzofstream::open(const char* name, | |||
460 | } | 460 | } |
461 | 461 | ||
462 | // Attach to file and go into fail() state if unsuccessful | 462 | // Attach to file and go into fail() state if unsuccessful |
463 | void | 463 | void |
464 | gzofstream::attach(int fd, | 464 | gzofstream::attach(int fd, |
465 | std::ios_base::openmode mode) | 465 | std::ios_base::openmode mode) |
466 | { | 466 | { |
467 | if (!sb.attach(fd, mode | std::ios_base::out)) | 467 | if (!sb.attach(fd, mode | std::ios_base::out)) |
468 | this->setstate(std::ios_base::failbit); | 468 | this->setstate(std::ios_base::failbit); |
@@ -471,7 +471,7 @@ gzofstream::attach(int fd, | |||
471 | } | 471 | } |
472 | 472 | ||
473 | // Close file | 473 | // Close file |
474 | void | 474 | void |
475 | gzofstream::close() | 475 | gzofstream::close() |
476 | { | 476 | { |
477 | if (!sb.close()) | 477 | if (!sb.close()) |
diff --git a/contrib/iostream3/zfstream.h b/contrib/iostream3/zfstream.h index ad76e8b..8574479 100644 --- a/contrib/iostream3/zfstream.h +++ b/contrib/iostream3/zfstream.h | |||
@@ -1,9 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * A C++ I/O streams interface to the zlib gz* functions | 2 | * A C++ I/O streams interface to the zlib gz* functions |
3 | * | 3 | * |
4 | * by Ludwig Schwardt <schwardt@sun.ac.za> | 4 | * by Ludwig Schwardt <schwardt@sun.ac.za> |
5 | * original version by Kevin Ruland <kevin@rodin.wustl.edu> | 5 | * original version by Kevin Ruland <kevin@rodin.wustl.edu> |
6 | * | 6 | * |
7 | * This version is standard-compliant and compatible with gcc 3.x. | 7 | * This version is standard-compliant and compatible with gcc 3.x. |
8 | */ | 8 | */ |
9 | 9 | ||
@@ -20,204 +20,204 @@ | |||
20 | * @brief Gzipped file stream buffer class. | 20 | * @brief Gzipped file stream buffer class. |
21 | * | 21 | * |
22 | * This class implements basic_filebuf for gzipped files. It doesn't yet support | 22 | * This class implements basic_filebuf for gzipped files. It doesn't yet support |
23 | * seeking (allowed by zlib but slow/limited), putback and read/write access | 23 | * seeking (allowed by zlib but slow/limited), putback and read/write access |
24 | * (tricky). Otherwise, it attempts to be a drop-in replacement for the standard | 24 | * (tricky). Otherwise, it attempts to be a drop-in replacement for the standard |
25 | * file streambuf. | 25 | * file streambuf. |
26 | */ | 26 | */ |
27 | class gzfilebuf : public std::streambuf | 27 | class gzfilebuf : public std::streambuf |
28 | { | 28 | { |
29 | public: | 29 | public: |
30 | // Default constructor. | 30 | // Default constructor. |
31 | gzfilebuf(); | 31 | gzfilebuf(); |
32 | 32 | ||
33 | // Destructor. | 33 | // Destructor. |
34 | virtual | 34 | virtual |
35 | ~gzfilebuf(); | 35 | ~gzfilebuf(); |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * @brief Set compression level and strategy on the fly. | 38 | * @brief Set compression level and strategy on the fly. |
39 | * @param comp_level Compression level (see zlib.h for allowed values) | 39 | * @param comp_level Compression level (see zlib.h for allowed values) |
40 | * @param comp_strategy Compression strategy (see zlib.h for allowed values) | 40 | * @param comp_strategy Compression strategy (see zlib.h for allowed values) |
41 | * @return Z_OK on success, Z_STREAM_ERROR otherwise. | 41 | * @return Z_OK on success, Z_STREAM_ERROR otherwise. |
42 | * | 42 | * |
43 | * Unfortunately, these parameters cannot be modified separately, as the | 43 | * Unfortunately, these parameters cannot be modified separately, as the |
44 | * previous zfstream version assumed. Since the strategy is seldom changed, | 44 | * previous zfstream version assumed. Since the strategy is seldom changed, |
45 | * it can default and setcompression(level) then becomes like the old | 45 | * it can default and setcompression(level) then becomes like the old |
46 | * setcompressionlevel(level). | 46 | * setcompressionlevel(level). |
47 | */ | 47 | */ |
48 | int | 48 | int |
49 | setcompression(int comp_level, | 49 | setcompression(int comp_level, |
50 | int comp_strategy = Z_DEFAULT_STRATEGY); | 50 | int comp_strategy = Z_DEFAULT_STRATEGY); |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * @brief Check if file is open. | 53 | * @brief Check if file is open. |
54 | * @return True if file is open. | 54 | * @return True if file is open. |
55 | */ | 55 | */ |
56 | bool | 56 | bool |
57 | is_open() const { return (file != NULL); } | 57 | is_open() const { return (file != NULL); } |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * @brief Open gzipped file. | 60 | * @brief Open gzipped file. |
61 | * @param name File name. | 61 | * @param name File name. |
62 | * @param mode Open mode flags. | 62 | * @param mode Open mode flags. |
63 | * @return @c this on success, NULL on failure. | 63 | * @return @c this on success, NULL on failure. |
64 | */ | 64 | */ |
65 | gzfilebuf* | 65 | gzfilebuf* |
66 | open(const char* name, | 66 | open(const char* name, |
67 | std::ios_base::openmode mode); | 67 | std::ios_base::openmode mode); |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * @brief Attach to already open gzipped file. | 70 | * @brief Attach to already open gzipped file. |
71 | * @param fd File descriptor. | 71 | * @param fd File descriptor. |
72 | * @param mode Open mode flags. | 72 | * @param mode Open mode flags. |
73 | * @return @c this on success, NULL on failure. | 73 | * @return @c this on success, NULL on failure. |
74 | */ | 74 | */ |
75 | gzfilebuf* | 75 | gzfilebuf* |
76 | attach(int fd, | 76 | attach(int fd, |
77 | std::ios_base::openmode mode); | 77 | std::ios_base::openmode mode); |
78 | 78 | ||
79 | /** | 79 | /** |
80 | * @brief Close gzipped file. | 80 | * @brief Close gzipped file. |
81 | * @return @c this on success, NULL on failure. | 81 | * @return @c this on success, NULL on failure. |
82 | */ | 82 | */ |
83 | gzfilebuf* | 83 | gzfilebuf* |
84 | close(); | 84 | close(); |
85 | 85 | ||
86 | protected: | 86 | protected: |
87 | /** | 87 | /** |
88 | * @brief Convert ios open mode int to mode string used by zlib. | 88 | * @brief Convert ios open mode int to mode string used by zlib. |
89 | * @return True if valid mode flag combination. | 89 | * @return True if valid mode flag combination. |
90 | */ | 90 | */ |
91 | bool | 91 | bool |
92 | open_mode(std::ios_base::openmode mode, | 92 | open_mode(std::ios_base::openmode mode, |
93 | char* c_mode) const; | 93 | char* c_mode) const; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * @brief Number of characters available in stream buffer. | 96 | * @brief Number of characters available in stream buffer. |
97 | * @return Number of characters. | 97 | * @return Number of characters. |
98 | * | 98 | * |
99 | * This indicates number of characters in get area of stream buffer. | 99 | * This indicates number of characters in get area of stream buffer. |
100 | * These characters can be read without accessing the gzipped file. | 100 | * These characters can be read without accessing the gzipped file. |
101 | */ | 101 | */ |
102 | virtual std::streamsize | 102 | virtual std::streamsize |
103 | showmanyc(); | 103 | showmanyc(); |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * @brief Fill get area from gzipped file. | 106 | * @brief Fill get area from gzipped file. |
107 | * @return First character in get area on success, EOF on error. | 107 | * @return First character in get area on success, EOF on error. |
108 | * | 108 | * |
109 | * This actually reads characters from gzipped file to stream | 109 | * This actually reads characters from gzipped file to stream |
110 | * buffer. Always buffered. | 110 | * buffer. Always buffered. |
111 | */ | 111 | */ |
112 | virtual int_type | 112 | virtual int_type |
113 | underflow(); | 113 | underflow(); |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * @brief Write put area to gzipped file. | 116 | * @brief Write put area to gzipped file. |
117 | * @param c Extra character to add to buffer contents. | 117 | * @param c Extra character to add to buffer contents. |
118 | * @return Non-EOF on success, EOF on error. | 118 | * @return Non-EOF on success, EOF on error. |
119 | * | 119 | * |
120 | * This actually writes characters in stream buffer to | 120 | * This actually writes characters in stream buffer to |
121 | * gzipped file. With unbuffered output this is done one | 121 | * gzipped file. With unbuffered output this is done one |
122 | * character at a time. | 122 | * character at a time. |
123 | */ | 123 | */ |
124 | virtual int_type | 124 | virtual int_type |
125 | overflow(int_type c = traits_type::eof()); | 125 | overflow(int_type c = traits_type::eof()); |
126 | 126 | ||
127 | /** | 127 | /** |
128 | * @brief Installs external stream buffer. | 128 | * @brief Installs external stream buffer. |
129 | * @param p Pointer to char buffer. | 129 | * @param p Pointer to char buffer. |
130 | * @param n Size of external buffer. | 130 | * @param n Size of external buffer. |
131 | * @return @c this on success, NULL on failure. | 131 | * @return @c this on success, NULL on failure. |
132 | * | 132 | * |
133 | * Call setbuf(0,0) to enable unbuffered output. | 133 | * Call setbuf(0,0) to enable unbuffered output. |
134 | */ | 134 | */ |
135 | virtual std::streambuf* | 135 | virtual std::streambuf* |
136 | setbuf(char_type* p, | 136 | setbuf(char_type* p, |
137 | std::streamsize n); | 137 | std::streamsize n); |
138 | 138 | ||
139 | /** | 139 | /** |
140 | * @brief Flush stream buffer to file. | 140 | * @brief Flush stream buffer to file. |
141 | * @return 0 on success, -1 on error. | 141 | * @return 0 on success, -1 on error. |
142 | * | 142 | * |
143 | * This calls underflow(EOF) to do the job. | 143 | * This calls underflow(EOF) to do the job. |
144 | */ | 144 | */ |
145 | virtual int | 145 | virtual int |
146 | sync(); | 146 | sync(); |
147 | 147 | ||
148 | // | 148 | // |
149 | // Some future enhancements | 149 | // Some future enhancements |
150 | // | 150 | // |
151 | // virtual int_type uflow(); | 151 | // virtual int_type uflow(); |
152 | // virtual int_type pbackfail(int_type c = traits_type::eof()); | 152 | // virtual int_type pbackfail(int_type c = traits_type::eof()); |
153 | // virtual pos_type | 153 | // virtual pos_type |
154 | // seekoff(off_type off, | 154 | // seekoff(off_type off, |
155 | // std::ios_base::seekdir way, | 155 | // std::ios_base::seekdir way, |
156 | // std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); | 156 | // std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); |
157 | // virtual pos_type | 157 | // virtual pos_type |
158 | // seekpos(pos_type sp, | 158 | // seekpos(pos_type sp, |
159 | // std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); | 159 | // std::ios_base::openmode mode = std::ios_base::in|std::ios_base::out); |
160 | 160 | ||
161 | private: | 161 | private: |
162 | /** | 162 | /** |
163 | * @brief Allocate internal buffer. | 163 | * @brief Allocate internal buffer. |
164 | * | 164 | * |
165 | * This function is safe to call multiple times. It will ensure | 165 | * This function is safe to call multiple times. It will ensure |
166 | * that a proper internal buffer exists if it is required. If the | 166 | * that a proper internal buffer exists if it is required. If the |
167 | * buffer already exists or is external, the buffer pointers will be | 167 | * buffer already exists or is external, the buffer pointers will be |
168 | * reset to their original state. | 168 | * reset to their original state. |
169 | */ | 169 | */ |
170 | void | 170 | void |
171 | enable_buffer(); | 171 | enable_buffer(); |
172 | 172 | ||
173 | /** | 173 | /** |
174 | * @brief Destroy internal buffer. | 174 | * @brief Destroy internal buffer. |
175 | * | 175 | * |
176 | * This function is safe to call multiple times. It will ensure | 176 | * This function is safe to call multiple times. It will ensure |
177 | * that the internal buffer is deallocated if it exists. In any | 177 | * that the internal buffer is deallocated if it exists. In any |
178 | * case, it will also reset the buffer pointers. | 178 | * case, it will also reset the buffer pointers. |
179 | */ | 179 | */ |
180 | void | 180 | void |
181 | disable_buffer(); | 181 | disable_buffer(); |
182 | 182 | ||
183 | /** | 183 | /** |
184 | * Underlying file pointer. | 184 | * Underlying file pointer. |
185 | */ | 185 | */ |
186 | gzFile file; | 186 | gzFile file; |
187 | 187 | ||
188 | /** | 188 | /** |
189 | * Mode in which file was opened. | 189 | * Mode in which file was opened. |
190 | */ | 190 | */ |
191 | std::ios_base::openmode io_mode; | 191 | std::ios_base::openmode io_mode; |
192 | 192 | ||
193 | /** | 193 | /** |
194 | * @brief True if this object owns file descriptor. | 194 | * @brief True if this object owns file descriptor. |
195 | * | 195 | * |
196 | * This makes the class responsible for closing the file | 196 | * This makes the class responsible for closing the file |
197 | * upon destruction. | 197 | * upon destruction. |
198 | */ | 198 | */ |
199 | bool own_fd; | 199 | bool own_fd; |
200 | 200 | ||
201 | /** | 201 | /** |
202 | * @brief Stream buffer. | 202 | * @brief Stream buffer. |
203 | * | 203 | * |
204 | * For simplicity this remains allocated on the free store for the | 204 | * For simplicity this remains allocated on the free store for the |
205 | * entire life span of the gzfilebuf object, unless replaced by setbuf. | 205 | * entire life span of the gzfilebuf object, unless replaced by setbuf. |
206 | */ | 206 | */ |
207 | char_type* buffer; | 207 | char_type* buffer; |
208 | 208 | ||
209 | /** | 209 | /** |
210 | * @brief Stream buffer size. | 210 | * @brief Stream buffer size. |
211 | * | 211 | * |
212 | * Defaults to system default buffer size (typically 8192 bytes). | 212 | * Defaults to system default buffer size (typically 8192 bytes). |
213 | * Modified by setbuf. | 213 | * Modified by setbuf. |
214 | */ | 214 | */ |
215 | std::streamsize buffer_size; | 215 | std::streamsize buffer_size; |
216 | 216 | ||
217 | /** | 217 | /** |
218 | * @brief True if this object owns stream buffer. | 218 | * @brief True if this object owns stream buffer. |
219 | * | 219 | * |
220 | * This makes the class responsible for deleting the buffer | 220 | * This makes the class responsible for deleting the buffer |
221 | * upon destruction. | 221 | * upon destruction. |
222 | */ | 222 | */ |
223 | bool own_buffer; | 223 | bool own_buffer; |
@@ -231,49 +231,49 @@ private: | |||
231 | * This class implements ifstream for gzipped files. Seeking and putback | 231 | * This class implements ifstream for gzipped files. Seeking and putback |
232 | * is not supported yet. | 232 | * is not supported yet. |
233 | */ | 233 | */ |
234 | class gzifstream : public std::istream | 234 | class gzifstream : public std::istream |
235 | { | 235 | { |
236 | public: | 236 | public: |
237 | // Default constructor | 237 | // Default constructor |
238 | gzifstream(); | 238 | gzifstream(); |
239 | 239 | ||
240 | /** | 240 | /** |
241 | * @brief Construct stream on gzipped file to be opened. | 241 | * @brief Construct stream on gzipped file to be opened. |
242 | * @param name File name. | 242 | * @param name File name. |
243 | * @param mode Open mode flags (forced to contain ios::in). | 243 | * @param mode Open mode flags (forced to contain ios::in). |
244 | */ | 244 | */ |
245 | explicit | 245 | explicit |
246 | gzifstream(const char* name, | 246 | gzifstream(const char* name, |
247 | std::ios_base::openmode mode = std::ios_base::in); | 247 | std::ios_base::openmode mode = std::ios_base::in); |
248 | 248 | ||
249 | /** | 249 | /** |
250 | * @brief Construct stream on already open gzipped file. | 250 | * @brief Construct stream on already open gzipped file. |
251 | * @param fd File descriptor. | 251 | * @param fd File descriptor. |
252 | * @param mode Open mode flags (forced to contain ios::in). | 252 | * @param mode Open mode flags (forced to contain ios::in). |
253 | */ | 253 | */ |
254 | explicit | 254 | explicit |
255 | gzifstream(int fd, | 255 | gzifstream(int fd, |
256 | std::ios_base::openmode mode = std::ios_base::in); | 256 | std::ios_base::openmode mode = std::ios_base::in); |
257 | 257 | ||
258 | /** | 258 | /** |
259 | * Obtain underlying stream buffer. | 259 | * Obtain underlying stream buffer. |
260 | */ | 260 | */ |
261 | gzfilebuf* | 261 | gzfilebuf* |
262 | rdbuf() const | 262 | rdbuf() const |
263 | { return const_cast<gzfilebuf*>(&sb); } | 263 | { return const_cast<gzfilebuf*>(&sb); } |
264 | 264 | ||
265 | /** | 265 | /** |
266 | * @brief Check if file is open. | 266 | * @brief Check if file is open. |
267 | * @return True if file is open. | 267 | * @return True if file is open. |
268 | */ | 268 | */ |
269 | bool | 269 | bool |
270 | is_open() { return sb.is_open(); } | 270 | is_open() { return sb.is_open(); } |
271 | 271 | ||
272 | /** | 272 | /** |
273 | * @brief Open gzipped file. | 273 | * @brief Open gzipped file. |
274 | * @param name File name. | 274 | * @param name File name. |
275 | * @param mode Open mode flags (forced to contain ios::in). | 275 | * @param mode Open mode flags (forced to contain ios::in). |
276 | * | 276 | * |
277 | * Stream will be in state good() if file opens successfully; | 277 | * Stream will be in state good() if file opens successfully; |
278 | * otherwise in state fail(). This differs from the behavior of | 278 | * otherwise in state fail(). This differs from the behavior of |
279 | * ifstream, which never sets the state to good() and therefore | 279 | * ifstream, which never sets the state to good() and therefore |
@@ -281,34 +281,34 @@ public: | |||
281 | * you manually clear() the state. The choice is a matter of | 281 | * you manually clear() the state. The choice is a matter of |
282 | * convenience. | 282 | * convenience. |
283 | */ | 283 | */ |
284 | void | 284 | void |
285 | open(const char* name, | 285 | open(const char* name, |
286 | std::ios_base::openmode mode = std::ios_base::in); | 286 | std::ios_base::openmode mode = std::ios_base::in); |
287 | 287 | ||
288 | /** | 288 | /** |
289 | * @brief Attach to already open gzipped file. | 289 | * @brief Attach to already open gzipped file. |
290 | * @param fd File descriptor. | 290 | * @param fd File descriptor. |
291 | * @param mode Open mode flags (forced to contain ios::in). | 291 | * @param mode Open mode flags (forced to contain ios::in). |
292 | * | 292 | * |
293 | * Stream will be in state good() if attach succeeded; otherwise | 293 | * Stream will be in state good() if attach succeeded; otherwise |
294 | * in state fail(). | 294 | * in state fail(). |
295 | */ | 295 | */ |
296 | void | 296 | void |
297 | attach(int fd, | 297 | attach(int fd, |
298 | std::ios_base::openmode mode = std::ios_base::in); | 298 | std::ios_base::openmode mode = std::ios_base::in); |
299 | 299 | ||
300 | /** | 300 | /** |
301 | * @brief Close gzipped file. | 301 | * @brief Close gzipped file. |
302 | * | 302 | * |
303 | * Stream will be in state fail() if close failed. | 303 | * Stream will be in state fail() if close failed. |
304 | */ | 304 | */ |
305 | void | 305 | void |
306 | close(); | 306 | close(); |
307 | 307 | ||
308 | private: | 308 | private: |
309 | /** | 309 | /** |
310 | * Underlying stream buffer. | 310 | * Underlying stream buffer. |
311 | */ | 311 | */ |
312 | gzfilebuf sb; | 312 | gzfilebuf sb; |
313 | }; | 313 | }; |
314 | 314 | ||
@@ -325,44 +325,44 @@ class gzofstream : public std::ostream | |||
325 | public: | 325 | public: |
326 | // Default constructor | 326 | // Default constructor |
327 | gzofstream(); | 327 | gzofstream(); |
328 | 328 | ||
329 | /** | 329 | /** |
330 | * @brief Construct stream on gzipped file to be opened. | 330 | * @brief Construct stream on gzipped file to be opened. |
331 | * @param name File name. | 331 | * @param name File name. |
332 | * @param mode Open mode flags (forced to contain ios::out). | 332 | * @param mode Open mode flags (forced to contain ios::out). |
333 | */ | 333 | */ |
334 | explicit | 334 | explicit |
335 | gzofstream(const char* name, | 335 | gzofstream(const char* name, |
336 | std::ios_base::openmode mode = std::ios_base::out); | 336 | std::ios_base::openmode mode = std::ios_base::out); |
337 | 337 | ||
338 | /** | 338 | /** |
339 | * @brief Construct stream on already open gzipped file. | 339 | * @brief Construct stream on already open gzipped file. |
340 | * @param fd File descriptor. | 340 | * @param fd File descriptor. |
341 | * @param mode Open mode flags (forced to contain ios::out). | 341 | * @param mode Open mode flags (forced to contain ios::out). |
342 | */ | 342 | */ |
343 | explicit | 343 | explicit |
344 | gzofstream(int fd, | 344 | gzofstream(int fd, |
345 | std::ios_base::openmode mode = std::ios_base::out); | 345 | std::ios_base::openmode mode = std::ios_base::out); |
346 | 346 | ||
347 | /** | 347 | /** |
348 | * Obtain underlying stream buffer. | 348 | * Obtain underlying stream buffer. |
349 | */ | 349 | */ |
350 | gzfilebuf* | 350 | gzfilebuf* |
351 | rdbuf() const | 351 | rdbuf() const |
352 | { return const_cast<gzfilebuf*>(&sb); } | 352 | { return const_cast<gzfilebuf*>(&sb); } |
353 | 353 | ||
354 | /** | 354 | /** |
355 | * @brief Check if file is open. | 355 | * @brief Check if file is open. |
356 | * @return True if file is open. | 356 | * @return True if file is open. |
357 | */ | 357 | */ |
358 | bool | 358 | bool |
359 | is_open() { return sb.is_open(); } | 359 | is_open() { return sb.is_open(); } |
360 | 360 | ||
361 | /** | 361 | /** |
362 | * @brief Open gzipped file. | 362 | * @brief Open gzipped file. |
363 | * @param name File name. | 363 | * @param name File name. |
364 | * @param mode Open mode flags (forced to contain ios::out). | 364 | * @param mode Open mode flags (forced to contain ios::out). |
365 | * | 365 | * |
366 | * Stream will be in state good() if file opens successfully; | 366 | * Stream will be in state good() if file opens successfully; |
367 | * otherwise in state fail(). This differs from the behavior of | 367 | * otherwise in state fail(). This differs from the behavior of |
368 | * ofstream, which never sets the state to good() and therefore | 368 | * ofstream, which never sets the state to good() and therefore |
@@ -370,39 +370,39 @@ public: | |||
370 | * you manually clear() the state. The choice is a matter of | 370 | * you manually clear() the state. The choice is a matter of |
371 | * convenience. | 371 | * convenience. |
372 | */ | 372 | */ |
373 | void | 373 | void |
374 | open(const char* name, | 374 | open(const char* name, |
375 | std::ios_base::openmode mode = std::ios_base::out); | 375 | std::ios_base::openmode mode = std::ios_base::out); |
376 | 376 | ||
377 | /** | 377 | /** |
378 | * @brief Attach to already open gzipped file. | 378 | * @brief Attach to already open gzipped file. |
379 | * @param fd File descriptor. | 379 | * @param fd File descriptor. |
380 | * @param mode Open mode flags (forced to contain ios::out). | 380 | * @param mode Open mode flags (forced to contain ios::out). |
381 | * | 381 | * |
382 | * Stream will be in state good() if attach succeeded; otherwise | 382 | * Stream will be in state good() if attach succeeded; otherwise |
383 | * in state fail(). | 383 | * in state fail(). |
384 | */ | 384 | */ |
385 | void | 385 | void |
386 | attach(int fd, | 386 | attach(int fd, |
387 | std::ios_base::openmode mode = std::ios_base::out); | 387 | std::ios_base::openmode mode = std::ios_base::out); |
388 | 388 | ||
389 | /** | 389 | /** |
390 | * @brief Close gzipped file. | 390 | * @brief Close gzipped file. |
391 | * | 391 | * |
392 | * Stream will be in state fail() if close failed. | 392 | * Stream will be in state fail() if close failed. |
393 | */ | 393 | */ |
394 | void | 394 | void |
395 | close(); | 395 | close(); |
396 | 396 | ||
397 | private: | 397 | private: |
398 | /** | 398 | /** |
399 | * Underlying stream buffer. | 399 | * Underlying stream buffer. |
400 | */ | 400 | */ |
401 | gzfilebuf sb; | 401 | gzfilebuf sb; |
402 | }; | 402 | }; |
403 | 403 | ||
404 | /*****************************************************************************/ | 404 | /*****************************************************************************/ |
405 | 405 | ||
406 | /** | 406 | /** |
407 | * @brief Gzipped file output stream manipulator class. | 407 | * @brief Gzipped file output stream manipulator class. |
408 | * | 408 | * |
@@ -415,28 +415,28 @@ template<typename T1, typename T2> | |||
415 | public: | 415 | public: |
416 | // Allows insertor to peek at internals | 416 | // Allows insertor to peek at internals |
417 | template <typename Ta, typename Tb> | 417 | template <typename Ta, typename Tb> |
418 | friend gzofstream& | 418 | friend gzofstream& |
419 | operator<<(gzofstream&, | 419 | operator<<(gzofstream&, |
420 | const gzomanip2<Ta,Tb>&); | 420 | const gzomanip2<Ta,Tb>&); |
421 | 421 | ||
422 | // Constructor | 422 | // Constructor |
423 | gzomanip2(gzofstream& (*f)(gzofstream&, T1, T2), | 423 | gzomanip2(gzofstream& (*f)(gzofstream&, T1, T2), |
424 | T1 v1, | 424 | T1 v1, |
425 | T2 v2); | 425 | T2 v2); |
426 | private: | 426 | private: |
427 | // Underlying manipulator function | 427 | // Underlying manipulator function |
428 | gzofstream& | 428 | gzofstream& |
429 | (*func)(gzofstream&, T1, T2); | 429 | (*func)(gzofstream&, T1, T2); |
430 | 430 | ||
431 | // Arguments for manipulator function | 431 | // Arguments for manipulator function |
432 | T1 val1; | 432 | T1 val1; |
433 | T2 val2; | 433 | T2 val2; |
434 | }; | 434 | }; |
435 | 435 | ||
436 | /*****************************************************************************/ | 436 | /*****************************************************************************/ |
437 | 437 | ||
438 | // Manipulator function thunks through to stream buffer | 438 | // Manipulator function thunks through to stream buffer |
439 | inline gzofstream& | 439 | inline gzofstream& |
440 | setcompression(gzofstream &gzs, int l, int s = Z_DEFAULT_STRATEGY) | 440 | setcompression(gzofstream &gzs, int l, int s = Z_DEFAULT_STRATEGY) |
441 | { | 441 | { |
442 | (gzs.rdbuf())->setcompression(l, s); | 442 | (gzs.rdbuf())->setcompression(l, s); |
@@ -445,22 +445,22 @@ setcompression(gzofstream &gzs, int l, int s = Z_DEFAULT_STRATEGY) | |||
445 | 445 | ||
446 | // Manipulator constructor stores arguments | 446 | // Manipulator constructor stores arguments |
447 | template<typename T1, typename T2> | 447 | template<typename T1, typename T2> |
448 | inline | 448 | inline |
449 | gzomanip2<T1,T2>::gzomanip2(gzofstream &(*f)(gzofstream &, T1, T2), | 449 | gzomanip2<T1,T2>::gzomanip2(gzofstream &(*f)(gzofstream &, T1, T2), |
450 | T1 v1, | 450 | T1 v1, |
451 | T2 v2) | 451 | T2 v2) |
452 | : func(f), val1(v1), val2(v2) | 452 | : func(f), val1(v1), val2(v2) |
453 | { } | 453 | { } |
454 | 454 | ||
455 | // Insertor applies underlying manipulator function to stream | 455 | // Insertor applies underlying manipulator function to stream |
456 | template<typename T1, typename T2> | 456 | template<typename T1, typename T2> |
457 | inline gzofstream& | 457 | inline gzofstream& |
458 | operator<<(gzofstream& s, const gzomanip2<T1,T2>& m) | 458 | operator<<(gzofstream& s, const gzomanip2<T1,T2>& m) |
459 | { return (*m.func)(s, m.val1, m.val2); } | 459 | { return (*m.func)(s, m.val1, m.val2); } |
460 | 460 | ||
461 | // Insert this onto stream to simplify setting of compression level | 461 | // Insert this onto stream to simplify setting of compression level |
462 | inline gzomanip2<int,int> | 462 | inline gzomanip2<int,int> |
463 | setcompression(int l, int s = Z_DEFAULT_STRATEGY) | 463 | setcompression(int l, int s = Z_DEFAULT_STRATEGY) |
464 | { return gzomanip2<int,int>(&setcompression, l, s); } | 464 | { return gzomanip2<int,int>(&setcompression, l, s); } |
465 | 465 | ||
466 | #endif // ZFSTREAM_H | 466 | #endif // ZFSTREAM_H |
diff --git a/contrib/masm686/match.asm b/contrib/masm686/match.asm new file mode 100644 index 0000000..2287804 --- /dev/null +++ b/contrib/masm686/match.asm | |||
@@ -0,0 +1,408 @@ | |||
1 | |||
2 | ; match.asm -- Pentium-Pro optimized version of longest_match() | ||
3 | ; | ||
4 | ; Updated for zlib 1.1.3 and converted to MASM 6.1x | ||
5 | ; Copyright (C) 2000 Dan Higdon <hdan@kinesoft.com> | ||
6 | ; and Chuck Walbourn <chuckw@kinesoft.com> | ||
7 | ; Corrections by Cosmin Truta <cosmint@cs.ubbcluj.ro> | ||
8 | ; | ||
9 | ; This is free software; you can redistribute it and/or modify it | ||
10 | ; under the terms of the GNU General Public License. | ||
11 | |||
12 | ; Based on match.S | ||
13 | ; Written for zlib 1.1.2 | ||
14 | ; Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com> | ||
15 | |||
16 | .686P | ||
17 | .MODEL FLAT | ||
18 | |||
19 | ;=========================================================================== | ||
20 | ; EQUATES | ||
21 | ;=========================================================================== | ||
22 | |||
23 | MAX_MATCH EQU 258 | ||
24 | MIN_MATCH EQU 3 | ||
25 | MIN_LOOKAHEAD EQU (MAX_MATCH + MIN_MATCH + 1) | ||
26 | MAX_MATCH_8 EQU ((MAX_MATCH + 7) AND (NOT 7)) | ||
27 | |||
28 | ;=========================================================================== | ||
29 | ; STRUCTURES | ||
30 | ;=========================================================================== | ||
31 | |||
32 | ; This STRUCT assumes a 4-byte alignment | ||
33 | |||
34 | DEFLATE_STATE STRUCT | ||
35 | ds_strm dd ? | ||
36 | ds_status dd ? | ||
37 | ds_pending_buf dd ? | ||
38 | ds_pending_buf_size dd ? | ||
39 | ds_pending_out dd ? | ||
40 | ds_pending dd ? | ||
41 | ds_wrap dd ? | ||
42 | ds_data_type db ? | ||
43 | ds_method db ? | ||
44 | db ? ; padding | ||
45 | db ? ; padding | ||
46 | ds_last_flush dd ? | ||
47 | ds_w_size dd ? ; used | ||
48 | ds_w_bits dd ? | ||
49 | ds_w_mask dd ? ; used | ||
50 | ds_window dd ? ; used | ||
51 | ds_window_size dd ? | ||
52 | ds_prev dd ? ; used | ||
53 | ds_head dd ? | ||
54 | ds_ins_h dd ? | ||
55 | ds_hash_size dd ? | ||
56 | ds_hash_bits dd ? | ||
57 | ds_hash_mask dd ? | ||
58 | ds_hash_shift dd ? | ||
59 | ds_block_start dd ? | ||
60 | ds_match_length dd ? ; used | ||
61 | ds_prev_match dd ? ; used | ||
62 | ds_match_available dd ? | ||
63 | ds_strstart dd ? ; used | ||
64 | ds_match_start dd ? ; used | ||
65 | ds_lookahead dd ? ; used | ||
66 | ds_prev_length dd ? ; used | ||
67 | ds_max_chain_length dd ? ; used | ||
68 | ds_max_laxy_match dd ? | ||
69 | ds_level dd ? | ||
70 | ds_strategy dd ? | ||
71 | ds_good_match dd ? ; used | ||
72 | ds_nice_match dd ? ; used | ||
73 | |||
74 | ; Don't need anymore of the struct for match | ||
75 | DEFLATE_STATE ENDS | ||
76 | |||
77 | ;=========================================================================== | ||
78 | ; CODE | ||
79 | ;=========================================================================== | ||
80 | _TEXT SEGMENT | ||
81 | |||
82 | ;--------------------------------------------------------------------------- | ||
83 | ; match_init | ||
84 | ;--------------------------------------------------------------------------- | ||
85 | ALIGN 4 | ||
86 | PUBLIC _match_init | ||
87 | _match_init PROC | ||
88 | ; no initialization needed | ||
89 | ret | ||
90 | _match_init ENDP | ||
91 | |||
92 | ;--------------------------------------------------------------------------- | ||
93 | ; uInt longest_match(deflate_state *deflatestate, IPos curmatch) | ||
94 | ;--------------------------------------------------------------------------- | ||
95 | ALIGN 4 | ||
96 | |||
97 | PUBLIC _longest_match | ||
98 | _longest_match PROC | ||
99 | |||
100 | ; Since this code uses EBP for a scratch register, the stack frame must | ||
101 | ; be manually constructed and referenced relative to the ESP register. | ||
102 | |||
103 | ; Stack image | ||
104 | ; Variables | ||
105 | chainlenwmask = 0 ; high word: current chain len | ||
106 | ; low word: s->wmask | ||
107 | window = 4 ; local copy of s->window | ||
108 | windowbestlen = 8 ; s->window + bestlen | ||
109 | scanend = 12 ; last two bytes of string | ||
110 | scanstart = 16 ; first two bytes of string | ||
111 | scanalign = 20 ; dword-misalignment of string | ||
112 | nicematch = 24 ; a good enough match size | ||
113 | bestlen = 28 ; size of best match so far | ||
114 | scan = 32 ; ptr to string wanting match | ||
115 | varsize = 36 ; number of bytes (also offset to last saved register) | ||
116 | |||
117 | ; Saved Registers (actually pushed into place) | ||
118 | ebx_save = 36 | ||
119 | edi_save = 40 | ||
120 | esi_save = 44 | ||
121 | ebp_save = 48 | ||
122 | |||
123 | ; Parameters | ||
124 | retaddr = 52 | ||
125 | deflatestate = 56 | ||
126 | curmatch = 60 | ||
127 | |||
128 | ; Save registers that the compiler may be using | ||
129 | push ebp | ||
130 | push edi | ||
131 | push esi | ||
132 | push ebx | ||
133 | |||
134 | ; Allocate local variable space | ||
135 | sub esp,varsize | ||
136 | |||
137 | ; Retrieve the function arguments. ecx will hold cur_match | ||
138 | ; throughout the entire function. edx will hold the pointer to the | ||
139 | ; deflate_state structure during the function's setup (before | ||
140 | ; entering the main loop). | ||
141 | |||
142 | mov edx, [esp+deflatestate] | ||
143 | ASSUME edx:PTR DEFLATE_STATE | ||
144 | |||
145 | mov ecx, [esp+curmatch] | ||
146 | |||
147 | ; uInt wmask = s->w_mask; | ||
148 | ; unsigned chain_length = s->max_chain_length; | ||
149 | ; if (s->prev_length >= s->good_match) { | ||
150 | ; chain_length >>= 2; | ||
151 | ; } | ||
152 | |||
153 | mov eax, [edx].ds_prev_length | ||
154 | mov ebx, [edx].ds_good_match | ||
155 | cmp eax, ebx | ||
156 | mov eax, [edx].ds_w_mask | ||
157 | mov ebx, [edx].ds_max_chain_length | ||
158 | jl SHORT LastMatchGood | ||
159 | shr ebx, 2 | ||
160 | LastMatchGood: | ||
161 | |||
162 | ; chainlen is decremented once beforehand so that the function can | ||
163 | ; use the sign flag instead of the zero flag for the exit test. | ||
164 | ; It is then shifted into the high word, to make room for the wmask | ||
165 | ; value, which it will always accompany. | ||
166 | |||
167 | dec ebx | ||
168 | shl ebx, 16 | ||
169 | or ebx, eax | ||
170 | mov [esp+chainlenwmask], ebx | ||
171 | |||
172 | ; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; | ||
173 | |||
174 | mov eax, [edx].ds_nice_match | ||
175 | mov ebx, [edx].ds_lookahead | ||
176 | cmp ebx, eax | ||
177 | jl SHORT LookaheadLess | ||
178 | mov ebx, eax | ||
179 | LookaheadLess: | ||
180 | mov [esp+nicematch], ebx | ||
181 | |||
182 | ;/* register Bytef *scan = s->window + s->strstart; */ | ||
183 | |||
184 | mov esi, [edx].ds_window | ||
185 | mov [esp+window], esi | ||
186 | mov ebp, [edx].ds_strstart | ||
187 | lea edi, [esi+ebp] | ||
188 | mov [esp+scan],edi | ||
189 | |||
190 | ;/* Determine how many bytes the scan ptr is off from being */ | ||
191 | ;/* dword-aligned. */ | ||
192 | |||
193 | mov eax, edi | ||
194 | neg eax | ||
195 | and eax, 3 | ||
196 | mov [esp+scanalign], eax | ||
197 | |||
198 | ;/* IPos limit = s->strstart > (IPos)MAX_DIST(s) ? */ | ||
199 | ;/* s->strstart - (IPos)MAX_DIST(s) : NIL; */ | ||
200 | |||
201 | mov eax, [edx].ds_w_size | ||
202 | sub eax, MIN_LOOKAHEAD | ||
203 | sub ebp, eax | ||
204 | jg SHORT LimitPositive | ||
205 | xor ebp, ebp | ||
206 | LimitPositive: | ||
207 | |||
208 | ;/* int best_len = s->prev_length; */ | ||
209 | |||
210 | mov eax, [edx].ds_prev_length | ||
211 | mov [esp+bestlen], eax | ||
212 | |||
213 | ;/* Store the sum of s->window + best_len in %esi locally, and in %esi. */ | ||
214 | |||
215 | add esi, eax | ||
216 | mov [esp+windowbestlen], esi | ||
217 | |||
218 | ;/* register ush scan_start = *(ushf*)scan; */ | ||
219 | ;/* register ush scan_end = *(ushf*)(scan+best_len-1); */ | ||
220 | ;/* Posf *prev = s->prev; */ | ||
221 | |||
222 | movzx ebx, WORD PTR[edi] | ||
223 | mov [esp+scanstart], ebx | ||
224 | movzx ebx, WORD PTR[eax+edi-1] | ||
225 | mov [esp+scanend], ebx | ||
226 | mov edi, [edx].ds_prev | ||
227 | |||
228 | ;/* Jump into the main loop. */ | ||
229 | |||
230 | mov edx, [esp+chainlenwmask] | ||
231 | jmp SHORT LoopEntry | ||
232 | |||
233 | ;/* do { | ||
234 | ; * match = s->window + cur_match; | ||
235 | ; * if (*(ushf*)(match+best_len-1) != scan_end || | ||
236 | ; * *(ushf*)match != scan_start) continue; | ||
237 | ; * [...] | ||
238 | ; * } while ((cur_match = prev[cur_match & wmask]) > limit | ||
239 | ; * && --chain_length != 0); | ||
240 | ; * | ||
241 | ; * Here is the inner loop of the function. The function will spend the | ||
242 | ; * majority of its time in this loop, and majority of that time will | ||
243 | ; * be spent in the first ten instructions. | ||
244 | ; * | ||
245 | ; * Within this loop: | ||
246 | ; * %ebx = scanend | ||
247 | ; * %ecx = curmatch | ||
248 | ; * %edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) | ||
249 | ; * %esi = windowbestlen - i.e., (window + bestlen) | ||
250 | ; * %edi = prev | ||
251 | ; * %ebp = limit | ||
252 | ; */ | ||
253 | |||
254 | ALIGN 4 | ||
255 | LookupLoop: | ||
256 | and ecx, edx | ||
257 | movzx ecx, WORD PTR[edi+ecx*2] | ||
258 | cmp ecx, ebp | ||
259 | jbe LeaveNow | ||
260 | sub edx, 000010000H | ||
261 | js LeaveNow | ||
262 | |||
263 | LoopEntry: | ||
264 | movzx eax, WORD PTR[esi+ecx-1] | ||
265 | cmp eax, ebx | ||
266 | jnz SHORT LookupLoop | ||
267 | |||
268 | mov eax, [esp+window] | ||
269 | movzx eax, WORD PTR[eax+ecx] | ||
270 | cmp eax, [esp+scanstart] | ||
271 | jnz SHORT LookupLoop | ||
272 | |||
273 | ;/* Store the current value of chainlen. */ | ||
274 | |||
275 | mov [esp+chainlenwmask], edx | ||
276 | |||
277 | ;/* Point %edi to the string under scrutiny, and %esi to the string we */ | ||
278 | ;/* are hoping to match it up with. In actuality, %esi and %edi are */ | ||
279 | ;/* both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and %edx is */ | ||
280 | ;/* initialized to -(MAX_MATCH_8 - scanalign). */ | ||
281 | |||
282 | mov esi, [esp+window] | ||
283 | mov edi, [esp+scan] | ||
284 | add esi, ecx | ||
285 | mov eax, [esp+scanalign] | ||
286 | mov edx, -MAX_MATCH_8 | ||
287 | lea edi, [edi+eax+MAX_MATCH_8] | ||
288 | lea esi, [esi+eax+MAX_MATCH_8] | ||
289 | |||
290 | ;/* Test the strings for equality, 8 bytes at a time. At the end, | ||
291 | ; * adjust %edx so that it is offset to the exact byte that mismatched. | ||
292 | ; * | ||
293 | ; * We already know at this point that the first three bytes of the | ||
294 | ; * strings match each other, and they can be safely passed over before | ||
295 | ; * starting the compare loop. So what this code does is skip over 0-3 | ||
296 | ; * bytes, as much as necessary in order to dword-align the %edi | ||
297 | ; * pointer. (%esi will still be misaligned three times out of four.) | ||
298 | ; * | ||
299 | ; * It should be confessed that this loop usually does not represent | ||
300 | ; * much of the total running time. Replacing it with a more | ||
301 | ; * straightforward "rep cmpsb" would not drastically degrade | ||
302 | ; * performance. | ||
303 | ; */ | ||
304 | |||
305 | LoopCmps: | ||
306 | mov eax, DWORD PTR[esi+edx] | ||
307 | xor eax, DWORD PTR[edi+edx] | ||
308 | jnz SHORT LeaveLoopCmps | ||
309 | |||
310 | mov eax, DWORD PTR[esi+edx+4] | ||
311 | xor eax, DWORD PTR[edi+edx+4] | ||
312 | jnz SHORT LeaveLoopCmps4 | ||
313 | |||
314 | add edx, 8 | ||
315 | jnz SHORT LoopCmps | ||
316 | jmp LenMaximum | ||
317 | ALIGN 4 | ||
318 | |||
319 | LeaveLoopCmps4: | ||
320 | add edx, 4 | ||
321 | |||
322 | LeaveLoopCmps: | ||
323 | test eax, 00000FFFFH | ||
324 | jnz SHORT LenLower | ||
325 | |||
326 | add edx, 2 | ||
327 | shr eax, 16 | ||
328 | |||
329 | LenLower: | ||
330 | sub al, 1 | ||
331 | adc edx, 0 | ||
332 | |||
333 | ;/* Calculate the length of the match. If it is longer than MAX_MATCH, */ | ||
334 | ;/* then automatically accept it as the best possible match and leave. */ | ||
335 | |||
336 | lea eax, [edi+edx] | ||
337 | mov edi, [esp+scan] | ||
338 | sub eax, edi | ||
339 | cmp eax, MAX_MATCH | ||
340 | jge SHORT LenMaximum | ||
341 | |||
342 | ;/* If the length of the match is not longer than the best match we */ | ||
343 | ;/* have so far, then forget it and return to the lookup loop. */ | ||
344 | |||
345 | mov edx, [esp+deflatestate] | ||
346 | mov ebx, [esp+bestlen] | ||
347 | cmp eax, ebx | ||
348 | jg SHORT LongerMatch | ||
349 | mov esi, [esp+windowbestlen] | ||
350 | mov edi, [edx].ds_prev | ||
351 | mov ebx, [esp+scanend] | ||
352 | mov edx, [esp+chainlenwmask] | ||
353 | jmp LookupLoop | ||
354 | ALIGN 4 | ||
355 | |||
356 | ;/* s->match_start = cur_match; */ | ||
357 | ;/* best_len = len; */ | ||
358 | ;/* if (len >= nice_match) break; */ | ||
359 | ;/* scan_end = *(ushf*)(scan+best_len-1); */ | ||
360 | |||
361 | LongerMatch: | ||
362 | mov ebx, [esp+nicematch] | ||
363 | mov [esp+bestlen], eax | ||
364 | mov [edx].ds_match_start, ecx | ||
365 | cmp eax, ebx | ||
366 | jge SHORT LeaveNow | ||
367 | mov esi, [esp+window] | ||
368 | add esi, eax | ||
369 | mov [esp+windowbestlen], esi | ||
370 | movzx ebx, WORD PTR[edi+eax-1] | ||
371 | mov edi, [edx].ds_prev | ||
372 | mov [esp+scanend], ebx | ||
373 | mov edx, [esp+chainlenwmask] | ||
374 | jmp LookupLoop | ||
375 | ALIGN 4 | ||
376 | |||
377 | ;/* Accept the current string, with the maximum possible length. */ | ||
378 | |||
379 | LenMaximum: | ||
380 | mov edx, [esp+deflatestate] | ||
381 | mov DWORD PTR[esp+bestlen], MAX_MATCH | ||
382 | mov [edx].ds_match_start, ecx | ||
383 | |||
384 | ;/* if ((uInt)best_len <= s->lookahead) return (uInt)best_len; */ | ||
385 | ;/* return s->lookahead; */ | ||
386 | |||
387 | LeaveNow: | ||
388 | mov edx, [esp+deflatestate] | ||
389 | mov ebx, [esp+bestlen] | ||
390 | mov eax, [edx].ds_lookahead | ||
391 | cmp ebx, eax | ||
392 | jg SHORT LookaheadRet | ||
393 | mov eax, ebx | ||
394 | LookaheadRet: | ||
395 | |||
396 | ; Restore the stack and return from whence we came. | ||
397 | |||
398 | add esp, varsize | ||
399 | pop ebx | ||
400 | pop esi | ||
401 | pop edi | ||
402 | pop ebp | ||
403 | ret | ||
404 | |||
405 | _longest_match ENDP | ||
406 | |||
407 | _TEXT ENDS | ||
408 | END | ||
diff --git a/contrib/vstudio/vc70_32/gvmat32.asm b/contrib/masmx86/gvmat32.asm index 320348f..ec360e6 100644 --- a/contrib/vstudio/vc70_32/gvmat32.asm +++ b/contrib/masmx86/gvmat32.asm | |||
@@ -1,905 +1,905 @@ | |||
1 | ; | 1 | ; |
2 | ; gvmat32.asm -- Asm portion of the optimized longest_match for 32 bits x86 | 2 | ; gvmat32.asm -- Asm portion of the optimized longest_match for 32 bits x86 |
3 | ; Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. | 3 | ; Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. |
4 | ; File written by Gilles Vollant, by modifiying the longest_match | 4 | ; File written by Gilles Vollant, by modifiying the longest_match |
5 | ; from Jean-loup Gailly in deflate.c | 5 | ; from Jean-loup Gailly in deflate.c |
6 | ; It need wmask == 0x7fff | 6 | ; It need wmask == 0x7fff |
7 | ; (assembly code is faster with a fixed wmask) | 7 | ; (assembly code is faster with a fixed wmask) |
8 | ; | 8 | ; |
9 | ; For Visual C++ 4.2 and ML 6.11c (version in directory \MASM611C of Win95 DDK) | 9 | ; For Visual C++ 4.2 and ML 6.11c (version in directory \MASM611C of Win95 DDK) |
10 | ; I compile with : "ml /coff /Zi /c gvmat32.asm" | 10 | ; I compile with : "ml /coff /Zi /c gvmat32.asm" |
11 | ; | 11 | ; |
12 | 12 | ||
13 | ;uInt longest_match_7fff(s, cur_match) | 13 | ;uInt longest_match_7fff(s, cur_match) |
14 | ; deflate_state *s; | 14 | ; deflate_state *s; |
15 | ; IPos cur_match; /* current match */ | 15 | ; IPos cur_match; /* current match */ |
16 | 16 | ||
17 | NbStack equ 76 | 17 | NbStack equ 76 |
18 | cur_match equ dword ptr[esp+NbStack-0] | 18 | cur_match equ dword ptr[esp+NbStack-0] |
19 | str_s equ dword ptr[esp+NbStack-4] | 19 | str_s equ dword ptr[esp+NbStack-4] |
20 | ; 5 dword on top (ret,ebp,esi,edi,ebx) | 20 | ; 5 dword on top (ret,ebp,esi,edi,ebx) |
21 | adrret equ dword ptr[esp+NbStack-8] | 21 | adrret equ dword ptr[esp+NbStack-8] |
22 | pushebp equ dword ptr[esp+NbStack-12] | 22 | pushebp equ dword ptr[esp+NbStack-12] |
23 | pushedi equ dword ptr[esp+NbStack-16] | 23 | pushedi equ dword ptr[esp+NbStack-16] |
24 | pushesi equ dword ptr[esp+NbStack-20] | 24 | pushesi equ dword ptr[esp+NbStack-20] |
25 | pushebx equ dword ptr[esp+NbStack-24] | 25 | pushebx equ dword ptr[esp+NbStack-24] |
26 | 26 | ||
27 | chain_length equ dword ptr [esp+NbStack-28] | 27 | chain_length equ dword ptr [esp+NbStack-28] |
28 | limit equ dword ptr [esp+NbStack-32] | 28 | limit equ dword ptr [esp+NbStack-32] |
29 | best_len equ dword ptr [esp+NbStack-36] | 29 | best_len equ dword ptr [esp+NbStack-36] |
30 | window equ dword ptr [esp+NbStack-40] | 30 | window equ dword ptr [esp+NbStack-40] |
31 | prev equ dword ptr [esp+NbStack-44] | 31 | prev equ dword ptr [esp+NbStack-44] |
32 | scan_start equ word ptr [esp+NbStack-48] | 32 | scan_start equ word ptr [esp+NbStack-48] |
33 | wmask equ dword ptr [esp+NbStack-52] | 33 | wmask equ dword ptr [esp+NbStack-52] |
34 | match_start_ptr equ dword ptr [esp+NbStack-56] | 34 | match_start_ptr equ dword ptr [esp+NbStack-56] |
35 | nice_match equ dword ptr [esp+NbStack-60] | 35 | nice_match equ dword ptr [esp+NbStack-60] |
36 | scan equ dword ptr [esp+NbStack-64] | 36 | scan equ dword ptr [esp+NbStack-64] |
37 | 37 | ||
38 | windowlen equ dword ptr [esp+NbStack-68] | 38 | windowlen equ dword ptr [esp+NbStack-68] |
39 | match_start equ dword ptr [esp+NbStack-72] | 39 | match_start equ dword ptr [esp+NbStack-72] |
40 | strend equ dword ptr [esp+NbStack-76] | 40 | strend equ dword ptr [esp+NbStack-76] |
41 | NbStackAdd equ (NbStack-24) | 41 | NbStackAdd equ (NbStack-24) |
42 | 42 | ||
43 | .386p | 43 | .386p |
44 | 44 | ||
45 | name gvmatch | 45 | name gvmatch |
46 | .MODEL FLAT | 46 | .MODEL FLAT |
47 | 47 | ||
48 | 48 | ||
49 | 49 | ||
50 | ; all the +4 offsets are due to the addition of pending_buf_size (in zlib | 50 | ; all the +4 offsets are due to the addition of pending_buf_size (in zlib |
51 | ; in the deflate_state structure since the asm code was first written | 51 | ; in the deflate_state structure since the asm code was first written |
52 | ; (if you compile with zlib 1.0.4 or older, remove the +4). | 52 | ; (if you compile with zlib 1.0.4 or older, remove the +4). |
53 | ; Note : these value are good with a 8 bytes boundary pack structure | 53 | ; Note : these value are good with a 8 bytes boundary pack structure |
54 | dep_chain_length equ 70h+4 | 54 | dep_chain_length equ 70h+4 |
55 | dep_window equ 2ch+4 | 55 | dep_window equ 2ch+4 |
56 | dep_strstart equ 60h+4 | 56 | dep_strstart equ 60h+4 |
57 | dep_prev_length equ 6ch+4 | 57 | dep_prev_length equ 6ch+4 |
58 | dep_nice_match equ 84h+4 | 58 | dep_nice_match equ 84h+4 |
59 | dep_w_size equ 20h+4 | 59 | dep_w_size equ 20h+4 |
60 | dep_prev equ 34h+4 | 60 | dep_prev equ 34h+4 |
61 | dep_w_mask equ 28h+4 | 61 | dep_w_mask equ 28h+4 |
62 | dep_good_match equ 80h+4 | 62 | dep_good_match equ 80h+4 |
63 | dep_match_start equ 64h+4 | 63 | dep_match_start equ 64h+4 |
64 | dep_lookahead equ 68h+4 | 64 | dep_lookahead equ 68h+4 |
65 | 65 | ||
66 | 66 | ||
67 | _TEXT segment | 67 | _TEXT segment |
68 | 68 | ||
69 | IFDEF NOUNDERLINE | 69 | IFDEF NOUNDERLINE |
70 | public longest_match_7fff | 70 | public longest_match_7fff |
71 | public longest_match_686 | 71 | public longest_match_686 |
72 | ; public match_init | 72 | ; public match_init |
73 | ELSE | 73 | ELSE |
74 | public _longest_match_7fff | 74 | public _longest_match_7fff |
75 | public _longest_match_686 | 75 | public _longest_match_686 |
76 | ; public _match_init | 76 | ; public _match_init |
77 | ENDIF | 77 | ENDIF |
78 | 78 | ||
79 | MAX_MATCH equ 258 | 79 | MAX_MATCH equ 258 |
80 | MIN_MATCH equ 3 | 80 | MIN_MATCH equ 3 |
81 | MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) | 81 | MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1) |
82 | 82 | ||
83 | 83 | ||
84 | 84 | ||
85 | IFDEF NOUNDERLINE | 85 | IFDEF NOUNDERLINE |
86 | ;match_init proc near | 86 | ;match_init proc near |
87 | ; ret | 87 | ; ret |
88 | ;match_init endp | 88 | ;match_init endp |
89 | ELSE | 89 | ELSE |
90 | ;_match_init proc near | 90 | ;_match_init proc near |
91 | ; ret | 91 | ; ret |
92 | ;_match_init endp | 92 | ;_match_init endp |
93 | ENDIF | 93 | ENDIF |
94 | 94 | ||
95 | 95 | ||
96 | IFDEF NOUNDERLINE | 96 | IFDEF NOUNDERLINE |
97 | longest_match_7fff proc near | 97 | longest_match_7fff proc near |
98 | ELSE | 98 | ELSE |
99 | _longest_match_7fff proc near | 99 | _longest_match_7fff proc near |
100 | ENDIF | 100 | ENDIF |
101 | 101 | ||
102 | mov edx,[esp+4] | 102 | mov edx,[esp+4] |
103 | 103 | ||
104 | 104 | ||
105 | 105 | ||
106 | push ebp | 106 | push ebp |
107 | push edi | 107 | push edi |
108 | push esi | 108 | push esi |
109 | push ebx | 109 | push ebx |
110 | 110 | ||
111 | sub esp,NbStackAdd | 111 | sub esp,NbStackAdd |
112 | 112 | ||
113 | ; initialize or check the variables used in match.asm. | 113 | ; initialize or check the variables used in match.asm. |
114 | mov ebp,edx | 114 | mov ebp,edx |
115 | 115 | ||
116 | ; chain_length = s->max_chain_length | 116 | ; chain_length = s->max_chain_length |
117 | ; if (prev_length>=good_match) chain_length >>= 2 | 117 | ; if (prev_length>=good_match) chain_length >>= 2 |
118 | mov edx,[ebp+dep_chain_length] | 118 | mov edx,[ebp+dep_chain_length] |
119 | mov ebx,[ebp+dep_prev_length] | 119 | mov ebx,[ebp+dep_prev_length] |
120 | cmp [ebp+dep_good_match],ebx | 120 | cmp [ebp+dep_good_match],ebx |
121 | ja noshr | 121 | ja noshr |
122 | shr edx,2 | 122 | shr edx,2 |
123 | noshr: | 123 | noshr: |
124 | ; we increment chain_length because in the asm, the --chain_lenght is in the beginning of the loop | 124 | ; we increment chain_length because in the asm, the --chain_lenght is in the beginning of the loop |
125 | inc edx | 125 | inc edx |
126 | mov edi,[ebp+dep_nice_match] | 126 | mov edi,[ebp+dep_nice_match] |
127 | mov chain_length,edx | 127 | mov chain_length,edx |
128 | mov eax,[ebp+dep_lookahead] | 128 | mov eax,[ebp+dep_lookahead] |
129 | cmp eax,edi | 129 | cmp eax,edi |
130 | ; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; | 130 | ; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; |
131 | jae nolookaheadnicematch | 131 | jae nolookaheadnicematch |
132 | mov edi,eax | 132 | mov edi,eax |
133 | nolookaheadnicematch: | 133 | nolookaheadnicematch: |
134 | ; best_len = s->prev_length | 134 | ; best_len = s->prev_length |
135 | mov best_len,ebx | 135 | mov best_len,ebx |
136 | 136 | ||
137 | ; window = s->window | 137 | ; window = s->window |
138 | mov esi,[ebp+dep_window] | 138 | mov esi,[ebp+dep_window] |
139 | mov ecx,[ebp+dep_strstart] | 139 | mov ecx,[ebp+dep_strstart] |
140 | mov window,esi | 140 | mov window,esi |
141 | 141 | ||
142 | mov nice_match,edi | 142 | mov nice_match,edi |
143 | ; scan = window + strstart | 143 | ; scan = window + strstart |
144 | add esi,ecx | 144 | add esi,ecx |
145 | mov scan,esi | 145 | mov scan,esi |
146 | ; dx = *window | 146 | ; dx = *window |
147 | mov dx,word ptr [esi] | 147 | mov dx,word ptr [esi] |
148 | ; bx = *(window+best_len-1) | 148 | ; bx = *(window+best_len-1) |
149 | mov bx,word ptr [esi+ebx-1] | 149 | mov bx,word ptr [esi+ebx-1] |
150 | add esi,MAX_MATCH-1 | 150 | add esi,MAX_MATCH-1 |
151 | ; scan_start = *scan | 151 | ; scan_start = *scan |
152 | mov scan_start,dx | 152 | mov scan_start,dx |
153 | ; strend = scan + MAX_MATCH-1 | 153 | ; strend = scan + MAX_MATCH-1 |
154 | mov strend,esi | 154 | mov strend,esi |
155 | ; bx = scan_end = *(window+best_len-1) | 155 | ; bx = scan_end = *(window+best_len-1) |
156 | 156 | ||
157 | ; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? | 157 | ; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? |
158 | ; s->strstart - (IPos)MAX_DIST(s) : NIL; | 158 | ; s->strstart - (IPos)MAX_DIST(s) : NIL; |
159 | 159 | ||
160 | mov esi,[ebp+dep_w_size] | 160 | mov esi,[ebp+dep_w_size] |
161 | sub esi,MIN_LOOKAHEAD | 161 | sub esi,MIN_LOOKAHEAD |
162 | ; here esi = MAX_DIST(s) | 162 | ; here esi = MAX_DIST(s) |
163 | sub ecx,esi | 163 | sub ecx,esi |
164 | ja nodist | 164 | ja nodist |
165 | xor ecx,ecx | 165 | xor ecx,ecx |
166 | nodist: | 166 | nodist: |
167 | mov limit,ecx | 167 | mov limit,ecx |
168 | 168 | ||
169 | ; prev = s->prev | 169 | ; prev = s->prev |
170 | mov edx,[ebp+dep_prev] | 170 | mov edx,[ebp+dep_prev] |
171 | mov prev,edx | 171 | mov prev,edx |
172 | 172 | ||
173 | ; | 173 | ; |
174 | mov edx,dword ptr [ebp+dep_match_start] | 174 | mov edx,dword ptr [ebp+dep_match_start] |
175 | mov bp,scan_start | 175 | mov bp,scan_start |
176 | mov eax,cur_match | 176 | mov eax,cur_match |
177 | mov match_start,edx | 177 | mov match_start,edx |
178 | 178 | ||
179 | mov edx,window | 179 | mov edx,window |
180 | mov edi,edx | 180 | mov edi,edx |
181 | add edi,best_len | 181 | add edi,best_len |
182 | mov esi,prev | 182 | mov esi,prev |
183 | dec edi | 183 | dec edi |
184 | ; windowlen = window + best_len -1 | 184 | ; windowlen = window + best_len -1 |
185 | mov windowlen,edi | 185 | mov windowlen,edi |
186 | 186 | ||
187 | jmp beginloop2 | 187 | jmp beginloop2 |
188 | align 4 | 188 | align 4 |
189 | 189 | ||
190 | ; here, in the loop | 190 | ; here, in the loop |
191 | ; eax = ax = cur_match | 191 | ; eax = ax = cur_match |
192 | ; ecx = limit | 192 | ; ecx = limit |
193 | ; bx = scan_end | 193 | ; bx = scan_end |
194 | ; bp = scan_start | 194 | ; bp = scan_start |
195 | ; edi = windowlen (window + best_len -1) | 195 | ; edi = windowlen (window + best_len -1) |
196 | ; esi = prev | 196 | ; esi = prev |
197 | 197 | ||
198 | 198 | ||
199 | ;// here; chain_length <=16 | 199 | ;// here; chain_length <=16 |
200 | normalbeg0add16: | 200 | normalbeg0add16: |
201 | add chain_length,16 | 201 | add chain_length,16 |
202 | jz exitloop | 202 | jz exitloop |
203 | normalbeg0: | 203 | normalbeg0: |
204 | cmp word ptr[edi+eax],bx | 204 | cmp word ptr[edi+eax],bx |
205 | je normalbeg2noroll | 205 | je normalbeg2noroll |
206 | rcontlabnoroll: | 206 | rcontlabnoroll: |
207 | ; cur_match = prev[cur_match & wmask] | 207 | ; cur_match = prev[cur_match & wmask] |
208 | and eax,7fffh | 208 | and eax,7fffh |
209 | mov ax,word ptr[esi+eax*2] | 209 | mov ax,word ptr[esi+eax*2] |
210 | ; if cur_match > limit, go to exitloop | 210 | ; if cur_match > limit, go to exitloop |
211 | cmp ecx,eax | 211 | cmp ecx,eax |
212 | jnb exitloop | 212 | jnb exitloop |
213 | ; if --chain_length != 0, go to exitloop | 213 | ; if --chain_length != 0, go to exitloop |
214 | dec chain_length | 214 | dec chain_length |
215 | jnz normalbeg0 | 215 | jnz normalbeg0 |
216 | jmp exitloop | 216 | jmp exitloop |
217 | 217 | ||
218 | normalbeg2noroll: | 218 | normalbeg2noroll: |
219 | ; if (scan_start==*(cur_match+window)) goto normalbeg2 | 219 | ; if (scan_start==*(cur_match+window)) goto normalbeg2 |
220 | cmp bp,word ptr[edx+eax] | 220 | cmp bp,word ptr[edx+eax] |
221 | jne rcontlabnoroll | 221 | jne rcontlabnoroll |
222 | jmp normalbeg2 | 222 | jmp normalbeg2 |
223 | 223 | ||
224 | contloop3: | 224 | contloop3: |
225 | mov edi,windowlen | 225 | mov edi,windowlen |
226 | 226 | ||
227 | ; cur_match = prev[cur_match & wmask] | 227 | ; cur_match = prev[cur_match & wmask] |
228 | and eax,7fffh | 228 | and eax,7fffh |
229 | mov ax,word ptr[esi+eax*2] | 229 | mov ax,word ptr[esi+eax*2] |
230 | ; if cur_match > limit, go to exitloop | 230 | ; if cur_match > limit, go to exitloop |
231 | cmp ecx,eax | 231 | cmp ecx,eax |
232 | jnbexitloopshort1: | 232 | jnbexitloopshort1: |
233 | jnb exitloop | 233 | jnb exitloop |
234 | ; if --chain_length != 0, go to exitloop | 234 | ; if --chain_length != 0, go to exitloop |
235 | 235 | ||
236 | 236 | ||
237 | ; begin the main loop | 237 | ; begin the main loop |
238 | beginloop2: | 238 | beginloop2: |
239 | sub chain_length,16+1 | 239 | sub chain_length,16+1 |
240 | ; if chain_length <=16, don't use the unrolled loop | 240 | ; if chain_length <=16, don't use the unrolled loop |
241 | jna normalbeg0add16 | 241 | jna normalbeg0add16 |
242 | 242 | ||
243 | do16: | 243 | do16: |
244 | cmp word ptr[edi+eax],bx | 244 | cmp word ptr[edi+eax],bx |
245 | je normalbeg2dc0 | 245 | je normalbeg2dc0 |
246 | 246 | ||
247 | maccn MACRO lab | 247 | maccn MACRO lab |
248 | and eax,7fffh | 248 | and eax,7fffh |
249 | mov ax,word ptr[esi+eax*2] | 249 | mov ax,word ptr[esi+eax*2] |
250 | cmp ecx,eax | 250 | cmp ecx,eax |
251 | jnb exitloop | 251 | jnb exitloop |
252 | cmp word ptr[edi+eax],bx | 252 | cmp word ptr[edi+eax],bx |
253 | je lab | 253 | je lab |
254 | ENDM | 254 | ENDM |
255 | 255 | ||
256 | rcontloop0: | 256 | rcontloop0: |
257 | maccn normalbeg2dc1 | 257 | maccn normalbeg2dc1 |
258 | 258 | ||
259 | rcontloop1: | 259 | rcontloop1: |
260 | maccn normalbeg2dc2 | 260 | maccn normalbeg2dc2 |
261 | 261 | ||
262 | rcontloop2: | 262 | rcontloop2: |
263 | maccn normalbeg2dc3 | 263 | maccn normalbeg2dc3 |
264 | 264 | ||
265 | rcontloop3: | 265 | rcontloop3: |
266 | maccn normalbeg2dc4 | 266 | maccn normalbeg2dc4 |
267 | 267 | ||
268 | rcontloop4: | 268 | rcontloop4: |
269 | maccn normalbeg2dc5 | 269 | maccn normalbeg2dc5 |
270 | 270 | ||
271 | rcontloop5: | 271 | rcontloop5: |
272 | maccn normalbeg2dc6 | 272 | maccn normalbeg2dc6 |
273 | 273 | ||
274 | rcontloop6: | 274 | rcontloop6: |
275 | maccn normalbeg2dc7 | 275 | maccn normalbeg2dc7 |
276 | 276 | ||
277 | rcontloop7: | 277 | rcontloop7: |
278 | maccn normalbeg2dc8 | 278 | maccn normalbeg2dc8 |
279 | 279 | ||
280 | rcontloop8: | 280 | rcontloop8: |
281 | maccn normalbeg2dc9 | 281 | maccn normalbeg2dc9 |
282 | 282 | ||
283 | rcontloop9: | 283 | rcontloop9: |
284 | maccn normalbeg2dc10 | 284 | maccn normalbeg2dc10 |
285 | 285 | ||
286 | rcontloop10: | 286 | rcontloop10: |
287 | maccn short normalbeg2dc11 | 287 | maccn short normalbeg2dc11 |
288 | 288 | ||
289 | rcontloop11: | 289 | rcontloop11: |
290 | maccn short normalbeg2dc12 | 290 | maccn short normalbeg2dc12 |
291 | 291 | ||
292 | rcontloop12: | 292 | rcontloop12: |
293 | maccn short normalbeg2dc13 | 293 | maccn short normalbeg2dc13 |
294 | 294 | ||
295 | rcontloop13: | 295 | rcontloop13: |
296 | maccn short normalbeg2dc14 | 296 | maccn short normalbeg2dc14 |
297 | 297 | ||
298 | rcontloop14: | 298 | rcontloop14: |
299 | maccn short normalbeg2dc15 | 299 | maccn short normalbeg2dc15 |
300 | 300 | ||
301 | rcontloop15: | 301 | rcontloop15: |
302 | and eax,7fffh | 302 | and eax,7fffh |
303 | mov ax,word ptr[esi+eax*2] | 303 | mov ax,word ptr[esi+eax*2] |
304 | cmp ecx,eax | 304 | cmp ecx,eax |
305 | jnb exitloop | 305 | jnb exitloop |
306 | 306 | ||
307 | sub chain_length,16 | 307 | sub chain_length,16 |
308 | ja do16 | 308 | ja do16 |
309 | jmp normalbeg0add16 | 309 | jmp normalbeg0add16 |
310 | 310 | ||
311 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 311 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
312 | 312 | ||
313 | normbeg MACRO rcontlab,valsub | 313 | normbeg MACRO rcontlab,valsub |
314 | ; if we are here, we know that *(match+best_len-1) == scan_end | 314 | ; if we are here, we know that *(match+best_len-1) == scan_end |
315 | cmp bp,word ptr[edx+eax] | 315 | cmp bp,word ptr[edx+eax] |
316 | ; if (match != scan_start) goto rcontlab | 316 | ; if (match != scan_start) goto rcontlab |
317 | jne rcontlab | 317 | jne rcontlab |
318 | ; calculate the good chain_length, and we'll compare scan and match string | 318 | ; calculate the good chain_length, and we'll compare scan and match string |
319 | add chain_length,16-valsub | 319 | add chain_length,16-valsub |
320 | jmp iseq | 320 | jmp iseq |
321 | ENDM | 321 | ENDM |
322 | 322 | ||
323 | 323 | ||
324 | normalbeg2dc11: | 324 | normalbeg2dc11: |
325 | normbeg rcontloop11,11 | 325 | normbeg rcontloop11,11 |
326 | 326 | ||
327 | normalbeg2dc12: | 327 | normalbeg2dc12: |
328 | normbeg short rcontloop12,12 | 328 | normbeg short rcontloop12,12 |
329 | 329 | ||
330 | normalbeg2dc13: | 330 | normalbeg2dc13: |
331 | normbeg short rcontloop13,13 | 331 | normbeg short rcontloop13,13 |
332 | 332 | ||
333 | normalbeg2dc14: | 333 | normalbeg2dc14: |
334 | normbeg short rcontloop14,14 | 334 | normbeg short rcontloop14,14 |
335 | 335 | ||
336 | normalbeg2dc15: | 336 | normalbeg2dc15: |
337 | normbeg short rcontloop15,15 | 337 | normbeg short rcontloop15,15 |
338 | 338 | ||
339 | normalbeg2dc10: | 339 | normalbeg2dc10: |
340 | normbeg rcontloop10,10 | 340 | normbeg rcontloop10,10 |
341 | 341 | ||
342 | normalbeg2dc9: | 342 | normalbeg2dc9: |
343 | normbeg rcontloop9,9 | 343 | normbeg rcontloop9,9 |
344 | 344 | ||
345 | normalbeg2dc8: | 345 | normalbeg2dc8: |
346 | normbeg rcontloop8,8 | 346 | normbeg rcontloop8,8 |
347 | 347 | ||
348 | normalbeg2dc7: | 348 | normalbeg2dc7: |
349 | normbeg rcontloop7,7 | 349 | normbeg rcontloop7,7 |
350 | 350 | ||
351 | normalbeg2dc6: | 351 | normalbeg2dc6: |
352 | normbeg rcontloop6,6 | 352 | normbeg rcontloop6,6 |
353 | 353 | ||
354 | normalbeg2dc5: | 354 | normalbeg2dc5: |
355 | normbeg rcontloop5,5 | 355 | normbeg rcontloop5,5 |
356 | 356 | ||
357 | normalbeg2dc4: | 357 | normalbeg2dc4: |
358 | normbeg rcontloop4,4 | 358 | normbeg rcontloop4,4 |
359 | 359 | ||
360 | normalbeg2dc3: | 360 | normalbeg2dc3: |
361 | normbeg rcontloop3,3 | 361 | normbeg rcontloop3,3 |
362 | 362 | ||
363 | normalbeg2dc2: | 363 | normalbeg2dc2: |
364 | normbeg rcontloop2,2 | 364 | normbeg rcontloop2,2 |
365 | 365 | ||
366 | normalbeg2dc1: | 366 | normalbeg2dc1: |
367 | normbeg rcontloop1,1 | 367 | normbeg rcontloop1,1 |
368 | 368 | ||
369 | normalbeg2dc0: | 369 | normalbeg2dc0: |
370 | normbeg rcontloop0,0 | 370 | normbeg rcontloop0,0 |
371 | 371 | ||
372 | 372 | ||
373 | ; we go in normalbeg2 because *(ushf*)(match+best_len-1) == scan_end | 373 | ; we go in normalbeg2 because *(ushf*)(match+best_len-1) == scan_end |
374 | 374 | ||
375 | normalbeg2: | 375 | normalbeg2: |
376 | mov edi,window | 376 | mov edi,window |
377 | 377 | ||
378 | cmp bp,word ptr[edi+eax] | 378 | cmp bp,word ptr[edi+eax] |
379 | jne contloop3 ; if *(ushf*)match != scan_start, continue | 379 | jne contloop3 ; if *(ushf*)match != scan_start, continue |
380 | 380 | ||
381 | iseq: | 381 | iseq: |
382 | ; if we are here, we know that *(match+best_len-1) == scan_end | 382 | ; if we are here, we know that *(match+best_len-1) == scan_end |
383 | ; and (match == scan_start) | 383 | ; and (match == scan_start) |
384 | 384 | ||
385 | mov edi,edx | 385 | mov edi,edx |
386 | mov esi,scan ; esi = scan | 386 | mov esi,scan ; esi = scan |
387 | add edi,eax ; edi = window + cur_match = match | 387 | add edi,eax ; edi = window + cur_match = match |
388 | 388 | ||
389 | mov edx,[esi+3] ; compare manually dword at match+3 | 389 | mov edx,[esi+3] ; compare manually dword at match+3 |
390 | xor edx,[edi+3] ; and scan +3 | 390 | xor edx,[edi+3] ; and scan +3 |
391 | 391 | ||
392 | jz begincompare ; if equal, go to long compare | 392 | jz begincompare ; if equal, go to long compare |
393 | 393 | ||
394 | ; we will determine the unmatch byte and calculate len (in esi) | 394 | ; we will determine the unmatch byte and calculate len (in esi) |
395 | or dl,dl | 395 | or dl,dl |
396 | je eq1rr | 396 | je eq1rr |
397 | mov esi,3 | 397 | mov esi,3 |
398 | jmp trfinval | 398 | jmp trfinval |
399 | eq1rr: | 399 | eq1rr: |
400 | or dx,dx | 400 | or dx,dx |
401 | je eq1 | 401 | je eq1 |
402 | 402 | ||
403 | mov esi,4 | 403 | mov esi,4 |
404 | jmp trfinval | 404 | jmp trfinval |
405 | eq1: | 405 | eq1: |
406 | and edx,0ffffffh | 406 | and edx,0ffffffh |
407 | jz eq11 | 407 | jz eq11 |
408 | mov esi,5 | 408 | mov esi,5 |
409 | jmp trfinval | 409 | jmp trfinval |
410 | eq11: | 410 | eq11: |
411 | mov esi,6 | 411 | mov esi,6 |
412 | jmp trfinval | 412 | jmp trfinval |
413 | 413 | ||
414 | begincompare: | 414 | begincompare: |
415 | ; here we now scan and match begin same | 415 | ; here we now scan and match begin same |
416 | add edi,6 | 416 | add edi,6 |
417 | add esi,6 | 417 | add esi,6 |
418 | mov ecx,(MAX_MATCH-(2+4))/4 ; scan for at most MAX_MATCH bytes | 418 | mov ecx,(MAX_MATCH-(2+4))/4 ; scan for at most MAX_MATCH bytes |
419 | repe cmpsd ; loop until mismatch | 419 | repe cmpsd ; loop until mismatch |
420 | 420 | ||
421 | je trfin ; go to trfin if not unmatch | 421 | je trfin ; go to trfin if not unmatch |
422 | ; we determine the unmatch byte | 422 | ; we determine the unmatch byte |
423 | sub esi,4 | 423 | sub esi,4 |
424 | mov edx,[edi-4] | 424 | mov edx,[edi-4] |
425 | xor edx,[esi] | 425 | xor edx,[esi] |
426 | 426 | ||
427 | or dl,dl | 427 | or dl,dl |
428 | jnz trfin | 428 | jnz trfin |
429 | inc esi | 429 | inc esi |
430 | 430 | ||
431 | or dx,dx | 431 | or dx,dx |
432 | jnz trfin | 432 | jnz trfin |
433 | inc esi | 433 | inc esi |
434 | 434 | ||
435 | and edx,0ffffffh | 435 | and edx,0ffffffh |
436 | jnz trfin | 436 | jnz trfin |
437 | inc esi | 437 | inc esi |
438 | 438 | ||
439 | trfin: | 439 | trfin: |
440 | sub esi,scan ; esi = len | 440 | sub esi,scan ; esi = len |
441 | trfinval: | 441 | trfinval: |
442 | ; here we have finised compare, and esi contain len of equal string | 442 | ; here we have finised compare, and esi contain len of equal string |
443 | cmp esi,best_len ; if len > best_len, go newbestlen | 443 | cmp esi,best_len ; if len > best_len, go newbestlen |
444 | ja short newbestlen | 444 | ja short newbestlen |
445 | ; now we restore edx, ecx and esi, for the big loop | 445 | ; now we restore edx, ecx and esi, for the big loop |
446 | mov esi,prev | 446 | mov esi,prev |
447 | mov ecx,limit | 447 | mov ecx,limit |
448 | mov edx,window | 448 | mov edx,window |
449 | jmp contloop3 | 449 | jmp contloop3 |
450 | 450 | ||
451 | newbestlen: | 451 | newbestlen: |
452 | mov best_len,esi ; len become best_len | 452 | mov best_len,esi ; len become best_len |
453 | 453 | ||
454 | mov match_start,eax ; save new position as match_start | 454 | mov match_start,eax ; save new position as match_start |
455 | cmp esi,nice_match ; if best_len >= nice_match, exit | 455 | cmp esi,nice_match ; if best_len >= nice_match, exit |
456 | jae exitloop | 456 | jae exitloop |
457 | mov ecx,scan | 457 | mov ecx,scan |
458 | mov edx,window ; restore edx=window | 458 | mov edx,window ; restore edx=window |
459 | add ecx,esi | 459 | add ecx,esi |
460 | add esi,edx | 460 | add esi,edx |
461 | 461 | ||
462 | dec esi | 462 | dec esi |
463 | mov windowlen,esi ; windowlen = window + best_len-1 | 463 | mov windowlen,esi ; windowlen = window + best_len-1 |
464 | mov bx,[ecx-1] ; bx = *(scan+best_len-1) = scan_end | 464 | mov bx,[ecx-1] ; bx = *(scan+best_len-1) = scan_end |
465 | 465 | ||
466 | ; now we restore ecx and esi, for the big loop : | 466 | ; now we restore ecx and esi, for the big loop : |
467 | mov esi,prev | 467 | mov esi,prev |
468 | mov ecx,limit | 468 | mov ecx,limit |
469 | jmp contloop3 | 469 | jmp contloop3 |
470 | 470 | ||
471 | exitloop: | 471 | exitloop: |
472 | ; exit : s->match_start=match_start | 472 | ; exit : s->match_start=match_start |
473 | mov ebx,match_start | 473 | mov ebx,match_start |
474 | mov ebp,str_s | 474 | mov ebp,str_s |
475 | mov ecx,best_len | 475 | mov ecx,best_len |
476 | mov dword ptr [ebp+dep_match_start],ebx | 476 | mov dword ptr [ebp+dep_match_start],ebx |
477 | mov eax,dword ptr [ebp+dep_lookahead] | 477 | mov eax,dword ptr [ebp+dep_lookahead] |
478 | cmp ecx,eax | 478 | cmp ecx,eax |
479 | ja minexlo | 479 | ja minexlo |
480 | mov eax,ecx | 480 | mov eax,ecx |
481 | minexlo: | 481 | minexlo: |
482 | ; return min(best_len,s->lookahead) | 482 | ; return min(best_len,s->lookahead) |
483 | 483 | ||
484 | ; restore stack and register ebx,esi,edi,ebp | 484 | ; restore stack and register ebx,esi,edi,ebp |
485 | add esp,NbStackAdd | 485 | add esp,NbStackAdd |
486 | 486 | ||
487 | pop ebx | 487 | pop ebx |
488 | pop esi | 488 | pop esi |
489 | pop edi | 489 | pop edi |
490 | pop ebp | 490 | pop ebp |
491 | ret | 491 | ret |
492 | InfoAuthor: | 492 | InfoAuthor: |
493 | ; please don't remove this string ! | 493 | ; please don't remove this string ! |
494 | ; Your are free use gvmat32 in any fre or commercial apps if you don't remove the string in the binary! | 494 | ; Your are free use gvmat32 in any fre or commercial apps if you don't remove the string in the binary! |
495 | db 0dh,0ah,"GVMat32 optimised assembly code written 1996-98 by Gilles Vollant",0dh,0ah | 495 | db 0dh,0ah,"GVMat32 optimised assembly code written 1996-98 by Gilles Vollant",0dh,0ah |
496 | 496 | ||
497 | 497 | ||
498 | 498 | ||
499 | IFDEF NOUNDERLINE | 499 | IFDEF NOUNDERLINE |
500 | longest_match_7fff endp | 500 | longest_match_7fff endp |
501 | ELSE | 501 | ELSE |
502 | _longest_match_7fff endp | 502 | _longest_match_7fff endp |
503 | ENDIF | 503 | ENDIF |
504 | 504 | ||
505 | 505 | ||
506 | IFDEF NOUNDERLINE | 506 | IFDEF NOUNDERLINE |
507 | cpudetect32 proc near | 507 | cpudetect32 proc near |
508 | ELSE | 508 | ELSE |
509 | _cpudetect32 proc near | 509 | _cpudetect32 proc near |
510 | ENDIF | 510 | ENDIF |
511 | 511 | ||
512 | push ebx | 512 | push ebx |
513 | 513 | ||
514 | pushfd ; push original EFLAGS | 514 | pushfd ; push original EFLAGS |
515 | pop eax ; get original EFLAGS | 515 | pop eax ; get original EFLAGS |
516 | mov ecx, eax ; save original EFLAGS | 516 | mov ecx, eax ; save original EFLAGS |
517 | xor eax, 40000h ; flip AC bit in EFLAGS | 517 | xor eax, 40000h ; flip AC bit in EFLAGS |
518 | push eax ; save new EFLAGS value on stack | 518 | push eax ; save new EFLAGS value on stack |
519 | popfd ; replace current EFLAGS value | 519 | popfd ; replace current EFLAGS value |
520 | pushfd ; get new EFLAGS | 520 | pushfd ; get new EFLAGS |
521 | pop eax ; store new EFLAGS in EAX | 521 | pop eax ; store new EFLAGS in EAX |
522 | xor eax, ecx ; can’t toggle AC bit, processor=80386 | 522 | xor eax, ecx ; can’t toggle AC bit, processor=80386 |
523 | jz end_cpu_is_386 ; jump if 80386 processor | 523 | jz end_cpu_is_386 ; jump if 80386 processor |
524 | push ecx | 524 | push ecx |
525 | popfd ; restore AC bit in EFLAGS first | 525 | popfd ; restore AC bit in EFLAGS first |
526 | 526 | ||
527 | pushfd | 527 | pushfd |
528 | pushfd | 528 | pushfd |
529 | pop ecx | 529 | pop ecx |
530 | 530 | ||
531 | mov eax, ecx ; get original EFLAGS | 531 | mov eax, ecx ; get original EFLAGS |
532 | xor eax, 200000h ; flip ID bit in EFLAGS | 532 | xor eax, 200000h ; flip ID bit in EFLAGS |
533 | push eax ; save new EFLAGS value on stack | 533 | push eax ; save new EFLAGS value on stack |
534 | popfd ; replace current EFLAGS value | 534 | popfd ; replace current EFLAGS value |
535 | pushfd ; get new EFLAGS | 535 | pushfd ; get new EFLAGS |
536 | pop eax ; store new EFLAGS in EAX | 536 | pop eax ; store new EFLAGS in EAX |
537 | popfd ; restore original EFLAGS | 537 | popfd ; restore original EFLAGS |
538 | xor eax, ecx ; can’t toggle ID bit, | 538 | xor eax, ecx ; can’t toggle ID bit, |
539 | je is_old_486 ; processor=old | 539 | je is_old_486 ; processor=old |
540 | 540 | ||
541 | mov eax,1 | 541 | mov eax,1 |
542 | db 0fh,0a2h ;CPUID | 542 | db 0fh,0a2h ;CPUID |
543 | 543 | ||
544 | exitcpudetect: | 544 | exitcpudetect: |
545 | pop ebx | 545 | pop ebx |
546 | ret | 546 | ret |
547 | 547 | ||
548 | end_cpu_is_386: | 548 | end_cpu_is_386: |
549 | mov eax,0300h | 549 | mov eax,0300h |
550 | jmp exitcpudetect | 550 | jmp exitcpudetect |
551 | 551 | ||
552 | is_old_486: | 552 | is_old_486: |
553 | mov eax,0400h | 553 | mov eax,0400h |
554 | jmp exitcpudetect | 554 | jmp exitcpudetect |
555 | 555 | ||
556 | IFDEF NOUNDERLINE | 556 | IFDEF NOUNDERLINE |
557 | cpudetect32 endp | 557 | cpudetect32 endp |
558 | ELSE | 558 | ELSE |
559 | _cpudetect32 endp | 559 | _cpudetect32 endp |
560 | ENDIF | 560 | ENDIF |
561 | 561 | ||
562 | 562 | ||
563 | 563 | ||
564 | 564 | ||
565 | MAX_MATCH equ 258 | 565 | MAX_MATCH equ 258 |
566 | MIN_MATCH equ 3 | 566 | MIN_MATCH equ 3 |
567 | MIN_LOOKAHEAD equ (MAX_MATCH + MIN_MATCH + 1) | 567 | MIN_LOOKAHEAD equ (MAX_MATCH + MIN_MATCH + 1) |
568 | MAX_MATCH_8_ equ ((MAX_MATCH + 7) AND 0FFF0h) | 568 | MAX_MATCH_8_ equ ((MAX_MATCH + 7) AND 0FFF0h) |
569 | 569 | ||
570 | 570 | ||
571 | ;;; stack frame offsets | 571 | ;;; stack frame offsets |
572 | 572 | ||
573 | chainlenwmask equ esp + 0 ; high word: current chain len | 573 | chainlenwmask equ esp + 0 ; high word: current chain len |
574 | ; low word: s->wmask | 574 | ; low word: s->wmask |
575 | window equ esp + 4 ; local copy of s->window | 575 | window equ esp + 4 ; local copy of s->window |
576 | windowbestlen equ esp + 8 ; s->window + bestlen | 576 | windowbestlen equ esp + 8 ; s->window + bestlen |
577 | scanstart equ esp + 16 ; first two bytes of string | 577 | scanstart equ esp + 16 ; first two bytes of string |
578 | scanend equ esp + 12 ; last two bytes of string | 578 | scanend equ esp + 12 ; last two bytes of string |
579 | scanalign equ esp + 20 ; dword-misalignment of string | 579 | scanalign equ esp + 20 ; dword-misalignment of string |
580 | nicematch equ esp + 24 ; a good enough match size | 580 | nicematch equ esp + 24 ; a good enough match size |
581 | bestlen equ esp + 28 ; size of best match so far | 581 | bestlen equ esp + 28 ; size of best match so far |
582 | scan equ esp + 32 ; ptr to string wanting match | 582 | scan equ esp + 32 ; ptr to string wanting match |
583 | 583 | ||
584 | LocalVarsSize equ 36 | 584 | LocalVarsSize equ 36 |
585 | ; saved ebx byte esp + 36 | 585 | ; saved ebx byte esp + 36 |
586 | ; saved edi byte esp + 40 | 586 | ; saved edi byte esp + 40 |
587 | ; saved esi byte esp + 44 | 587 | ; saved esi byte esp + 44 |
588 | ; saved ebp byte esp + 48 | 588 | ; saved ebp byte esp + 48 |
589 | ; return address byte esp + 52 | 589 | ; return address byte esp + 52 |
590 | deflatestate equ esp + 56 ; the function arguments | 590 | deflatestate equ esp + 56 ; the function arguments |
591 | curmatch equ esp + 60 | 591 | curmatch equ esp + 60 |
592 | 592 | ||
593 | ;;; Offsets for fields in the deflate_state structure. These numbers | 593 | ;;; Offsets for fields in the deflate_state structure. These numbers |
594 | ;;; are calculated from the definition of deflate_state, with the | 594 | ;;; are calculated from the definition of deflate_state, with the |
595 | ;;; assumption that the compiler will dword-align the fields. (Thus, | 595 | ;;; assumption that the compiler will dword-align the fields. (Thus, |
596 | ;;; changing the definition of deflate_state could easily cause this | 596 | ;;; changing the definition of deflate_state could easily cause this |
597 | ;;; program to crash horribly, without so much as a warning at | 597 | ;;; program to crash horribly, without so much as a warning at |
598 | ;;; compile time. Sigh.) | 598 | ;;; compile time. Sigh.) |
599 | 599 | ||
600 | dsWSize equ 36 | 600 | dsWSize equ 36 |
601 | dsWMask equ 44 | 601 | dsWMask equ 44 |
602 | dsWindow equ 48 | 602 | dsWindow equ 48 |
603 | dsPrev equ 56 | 603 | dsPrev equ 56 |
604 | dsMatchLen equ 88 | 604 | dsMatchLen equ 88 |
605 | dsPrevMatch equ 92 | 605 | dsPrevMatch equ 92 |
606 | dsStrStart equ 100 | 606 | dsStrStart equ 100 |
607 | dsMatchStart equ 104 | 607 | dsMatchStart equ 104 |
608 | dsLookahead equ 108 | 608 | dsLookahead equ 108 |
609 | dsPrevLen equ 112 | 609 | dsPrevLen equ 112 |
610 | dsMaxChainLen equ 116 | 610 | dsMaxChainLen equ 116 |
611 | dsGoodMatch equ 132 | 611 | dsGoodMatch equ 132 |
612 | dsNiceMatch equ 136 | 612 | dsNiceMatch equ 136 |
613 | 613 | ||
614 | 614 | ||
615 | ;;; match.asm -- Pentium-Pro-optimized version of longest_match() | 615 | ;;; match.asm -- Pentium-Pro-optimized version of longest_match() |
616 | ;;; Written for zlib 1.1.2 | 616 | ;;; Written for zlib 1.1.2 |
617 | ;;; Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com> | 617 | ;;; Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com> |
618 | ;;; You can look at http://www.muppetlabs.com/~breadbox/software/assembly.html | 618 | ;;; You can look at http://www.muppetlabs.com/~breadbox/software/assembly.html |
619 | ;;; | 619 | ;;; |
620 | ;;; This is free software; you can redistribute it and/or modify it | 620 | ;;; This is free software; you can redistribute it and/or modify it |
621 | ;;; under the terms of the GNU General Public License. | 621 | ;;; under the terms of the GNU General Public License. |
622 | 622 | ||
623 | ;GLOBAL _longest_match, _match_init | 623 | ;GLOBAL _longest_match, _match_init |
624 | 624 | ||
625 | 625 | ||
626 | ;SECTION .text | 626 | ;SECTION .text |
627 | 627 | ||
628 | ;;; uInt longest_match(deflate_state *deflatestate, IPos curmatch) | 628 | ;;; uInt longest_match(deflate_state *deflatestate, IPos curmatch) |
629 | 629 | ||
630 | ;_longest_match: | 630 | ;_longest_match: |
631 | IFDEF NOUNDERLINE | 631 | IFDEF NOUNDERLINE |
632 | longest_match_686 proc near | 632 | longest_match_686 proc near |
633 | ELSE | 633 | ELSE |
634 | _longest_match_686 proc near | 634 | _longest_match_686 proc near |
635 | ENDIF | 635 | ENDIF |
636 | 636 | ||
637 | 637 | ||
638 | ;;; Save registers that the compiler may be using, and adjust esp to | 638 | ;;; Save registers that the compiler may be using, and adjust esp to |
639 | ;;; make room for our stack frame. | 639 | ;;; make room for our stack frame. |
640 | 640 | ||
641 | push ebp | 641 | push ebp |
642 | push edi | 642 | push edi |
643 | push esi | 643 | push esi |
644 | push ebx | 644 | push ebx |
645 | sub esp, LocalVarsSize | 645 | sub esp, LocalVarsSize |
646 | 646 | ||
647 | ;;; Retrieve the function arguments. ecx will hold cur_match | 647 | ;;; Retrieve the function arguments. ecx will hold cur_match |
648 | ;;; throughout the entire function. edx will hold the pointer to the | 648 | ;;; throughout the entire function. edx will hold the pointer to the |
649 | ;;; deflate_state structure during the function's setup (before | 649 | ;;; deflate_state structure during the function's setup (before |
650 | ;;; entering the main loop. | 650 | ;;; entering the main loop. |
651 | 651 | ||
652 | mov edx, [deflatestate] | 652 | mov edx, [deflatestate] |
653 | mov ecx, [curmatch] | 653 | mov ecx, [curmatch] |
654 | 654 | ||
655 | ;;; uInt wmask = s->w_mask; | 655 | ;;; uInt wmask = s->w_mask; |
656 | ;;; unsigned chain_length = s->max_chain_length; | 656 | ;;; unsigned chain_length = s->max_chain_length; |
657 | ;;; if (s->prev_length >= s->good_match) { | 657 | ;;; if (s->prev_length >= s->good_match) { |
658 | ;;; chain_length >>= 2; | 658 | ;;; chain_length >>= 2; |
659 | ;;; } | 659 | ;;; } |
660 | 660 | ||
661 | mov eax, [edx + dsPrevLen] | 661 | mov eax, [edx + dsPrevLen] |
662 | mov ebx, [edx + dsGoodMatch] | 662 | mov ebx, [edx + dsGoodMatch] |
663 | cmp eax, ebx | 663 | cmp eax, ebx |
664 | mov eax, [edx + dsWMask] | 664 | mov eax, [edx + dsWMask] |
665 | mov ebx, [edx + dsMaxChainLen] | 665 | mov ebx, [edx + dsMaxChainLen] |
666 | jl LastMatchGood | 666 | jl LastMatchGood |
667 | shr ebx, 2 | 667 | shr ebx, 2 |
668 | LastMatchGood: | 668 | LastMatchGood: |
669 | 669 | ||
670 | ;;; chainlen is decremented once beforehand so that the function can | 670 | ;;; chainlen is decremented once beforehand so that the function can |
671 | ;;; use the sign flag instead of the zero flag for the exit test. | 671 | ;;; use the sign flag instead of the zero flag for the exit test. |
672 | ;;; It is then shifted into the high word, to make room for the wmask | 672 | ;;; It is then shifted into the high word, to make room for the wmask |
673 | ;;; value, which it will always accompany. | 673 | ;;; value, which it will always accompany. |
674 | 674 | ||
675 | dec ebx | 675 | dec ebx |
676 | shl ebx, 16 | 676 | shl ebx, 16 |
677 | or ebx, eax | 677 | or ebx, eax |
678 | mov [chainlenwmask], ebx | 678 | mov [chainlenwmask], ebx |
679 | 679 | ||
680 | ;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; | 680 | ;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; |
681 | 681 | ||
682 | mov eax, [edx + dsNiceMatch] | 682 | mov eax, [edx + dsNiceMatch] |
683 | mov ebx, [edx + dsLookahead] | 683 | mov ebx, [edx + dsLookahead] |
684 | cmp ebx, eax | 684 | cmp ebx, eax |
685 | jl LookaheadLess | 685 | jl LookaheadLess |
686 | mov ebx, eax | 686 | mov ebx, eax |
687 | LookaheadLess: mov [nicematch], ebx | 687 | LookaheadLess: mov [nicematch], ebx |
688 | 688 | ||
689 | ;;; register Bytef *scan = s->window + s->strstart; | 689 | ;;; register Bytef *scan = s->window + s->strstart; |
690 | 690 | ||
691 | mov esi, [edx + dsWindow] | 691 | mov esi, [edx + dsWindow] |
692 | mov [window], esi | 692 | mov [window], esi |
693 | mov ebp, [edx + dsStrStart] | 693 | mov ebp, [edx + dsStrStart] |
694 | lea edi, [esi + ebp] | 694 | lea edi, [esi + ebp] |
695 | mov [scan], edi | 695 | mov [scan], edi |
696 | 696 | ||
697 | ;;; Determine how many bytes the scan ptr is off from being | 697 | ;;; Determine how many bytes the scan ptr is off from being |
698 | ;;; dword-aligned. | 698 | ;;; dword-aligned. |
699 | 699 | ||
700 | mov eax, edi | 700 | mov eax, edi |
701 | neg eax | 701 | neg eax |
702 | and eax, 3 | 702 | and eax, 3 |
703 | mov [scanalign], eax | 703 | mov [scanalign], eax |
704 | 704 | ||
705 | ;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? | 705 | ;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ? |
706 | ;;; s->strstart - (IPos)MAX_DIST(s) : NIL; | 706 | ;;; s->strstart - (IPos)MAX_DIST(s) : NIL; |
707 | 707 | ||
708 | mov eax, [edx + dsWSize] | 708 | mov eax, [edx + dsWSize] |
709 | sub eax, MIN_LOOKAHEAD | 709 | sub eax, MIN_LOOKAHEAD |
710 | sub ebp, eax | 710 | sub ebp, eax |
711 | jg LimitPositive | 711 | jg LimitPositive |
712 | xor ebp, ebp | 712 | xor ebp, ebp |
713 | LimitPositive: | 713 | LimitPositive: |
714 | 714 | ||
715 | ;;; int best_len = s->prev_length; | 715 | ;;; int best_len = s->prev_length; |
716 | 716 | ||
717 | mov eax, [edx + dsPrevLen] | 717 | mov eax, [edx + dsPrevLen] |
718 | mov [bestlen], eax | 718 | mov [bestlen], eax |
719 | 719 | ||
720 | ;;; Store the sum of s->window + best_len in esi locally, and in esi. | 720 | ;;; Store the sum of s->window + best_len in esi locally, and in esi. |
721 | 721 | ||
722 | add esi, eax | 722 | add esi, eax |
723 | mov [windowbestlen], esi | 723 | mov [windowbestlen], esi |
724 | 724 | ||
725 | ;;; register ush scan_start = *(ushf*)scan; | 725 | ;;; register ush scan_start = *(ushf*)scan; |
726 | ;;; register ush scan_end = *(ushf*)(scan+best_len-1); | 726 | ;;; register ush scan_end = *(ushf*)(scan+best_len-1); |
727 | ;;; Posf *prev = s->prev; | 727 | ;;; Posf *prev = s->prev; |
728 | 728 | ||
729 | movzx ebx, word ptr [edi] | 729 | movzx ebx, word ptr [edi] |
730 | mov [scanstart], ebx | 730 | mov [scanstart], ebx |
731 | movzx ebx, word ptr [edi + eax - 1] | 731 | movzx ebx, word ptr [edi + eax - 1] |
732 | mov [scanend], ebx | 732 | mov [scanend], ebx |
733 | mov edi, [edx + dsPrev] | 733 | mov edi, [edx + dsPrev] |
734 | 734 | ||
735 | ;;; Jump into the main loop. | 735 | ;;; Jump into the main loop. |
736 | 736 | ||
737 | mov edx, [chainlenwmask] | 737 | mov edx, [chainlenwmask] |
738 | jmp short LoopEntry | 738 | jmp short LoopEntry |
739 | 739 | ||
740 | align 4 | 740 | align 4 |
741 | 741 | ||
742 | ;;; do { | 742 | ;;; do { |
743 | ;;; match = s->window + cur_match; | 743 | ;;; match = s->window + cur_match; |
744 | ;;; if (*(ushf*)(match+best_len-1) != scan_end || | 744 | ;;; if (*(ushf*)(match+best_len-1) != scan_end || |
745 | ;;; *(ushf*)match != scan_start) continue; | 745 | ;;; *(ushf*)match != scan_start) continue; |
746 | ;;; [...] | 746 | ;;; [...] |
747 | ;;; } while ((cur_match = prev[cur_match & wmask]) > limit | 747 | ;;; } while ((cur_match = prev[cur_match & wmask]) > limit |
748 | ;;; && --chain_length != 0); | 748 | ;;; && --chain_length != 0); |
749 | ;;; | 749 | ;;; |
750 | ;;; Here is the inner loop of the function. The function will spend the | 750 | ;;; Here is the inner loop of the function. The function will spend the |
751 | ;;; majority of its time in this loop, and majority of that time will | 751 | ;;; majority of its time in this loop, and majority of that time will |
752 | ;;; be spent in the first ten instructions. | 752 | ;;; be spent in the first ten instructions. |
753 | ;;; | 753 | ;;; |
754 | ;;; Within this loop: | 754 | ;;; Within this loop: |
755 | ;;; ebx = scanend | 755 | ;;; ebx = scanend |
756 | ;;; ecx = curmatch | 756 | ;;; ecx = curmatch |
757 | ;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) | 757 | ;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask) |
758 | ;;; esi = windowbestlen - i.e., (window + bestlen) | 758 | ;;; esi = windowbestlen - i.e., (window + bestlen) |
759 | ;;; edi = prev | 759 | ;;; edi = prev |
760 | ;;; ebp = limit | 760 | ;;; ebp = limit |
761 | 761 | ||
762 | LookupLoop: | 762 | LookupLoop: |
763 | and ecx, edx | 763 | and ecx, edx |
764 | movzx ecx, word ptr [edi + ecx*2] | 764 | movzx ecx, word ptr [edi + ecx*2] |
765 | cmp ecx, ebp | 765 | cmp ecx, ebp |
766 | jbe LeaveNow | 766 | jbe LeaveNow |
767 | sub edx, 00010000h | 767 | sub edx, 00010000h |
768 | js LeaveNow | 768 | js LeaveNow |
769 | LoopEntry: movzx eax, word ptr [esi + ecx - 1] | 769 | LoopEntry: movzx eax, word ptr [esi + ecx - 1] |
770 | cmp eax, ebx | 770 | cmp eax, ebx |
771 | jnz LookupLoop | 771 | jnz LookupLoop |
772 | mov eax, [window] | 772 | mov eax, [window] |
773 | movzx eax, word ptr [eax + ecx] | 773 | movzx eax, word ptr [eax + ecx] |
774 | cmp eax, [scanstart] | 774 | cmp eax, [scanstart] |
775 | jnz LookupLoop | 775 | jnz LookupLoop |
776 | 776 | ||
777 | ;;; Store the current value of chainlen. | 777 | ;;; Store the current value of chainlen. |
778 | 778 | ||
779 | mov [chainlenwmask], edx | 779 | mov [chainlenwmask], edx |
780 | 780 | ||
781 | ;;; Point edi to the string under scrutiny, and esi to the string we | 781 | ;;; Point edi to the string under scrutiny, and esi to the string we |
782 | ;;; are hoping to match it up with. In actuality, esi and edi are | 782 | ;;; are hoping to match it up with. In actuality, esi and edi are |
783 | ;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is | 783 | ;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is |
784 | ;;; initialized to -(MAX_MATCH_8 - scanalign). | 784 | ;;; initialized to -(MAX_MATCH_8 - scanalign). |
785 | 785 | ||
786 | mov esi, [window] | 786 | mov esi, [window] |
787 | mov edi, [scan] | 787 | mov edi, [scan] |
788 | add esi, ecx | 788 | add esi, ecx |
789 | mov eax, [scanalign] | 789 | mov eax, [scanalign] |
790 | mov edx, 0fffffef8h; -(MAX_MATCH_8) | 790 | mov edx, 0fffffef8h; -(MAX_MATCH_8) |
791 | lea edi, [edi + eax + 0108h] ;MAX_MATCH_8] | 791 | lea edi, [edi + eax + 0108h] ;MAX_MATCH_8] |
792 | lea esi, [esi + eax + 0108h] ;MAX_MATCH_8] | 792 | lea esi, [esi + eax + 0108h] ;MAX_MATCH_8] |
793 | 793 | ||
794 | ;;; Test the strings for equality, 8 bytes at a time. At the end, | 794 | ;;; Test the strings for equality, 8 bytes at a time. At the end, |
795 | ;;; adjust edx so that it is offset to the exact byte that mismatched. | 795 | ;;; adjust edx so that it is offset to the exact byte that mismatched. |
796 | ;;; | 796 | ;;; |
797 | ;;; We already know at this point that the first three bytes of the | 797 | ;;; We already know at this point that the first three bytes of the |
798 | ;;; strings match each other, and they can be safely passed over before | 798 | ;;; strings match each other, and they can be safely passed over before |
799 | ;;; starting the compare loop. So what this code does is skip over 0-3 | 799 | ;;; starting the compare loop. So what this code does is skip over 0-3 |
800 | ;;; bytes, as much as necessary in order to dword-align the edi | 800 | ;;; bytes, as much as necessary in order to dword-align the edi |
801 | ;;; pointer. (esi will still be misaligned three times out of four.) | 801 | ;;; pointer. (esi will still be misaligned three times out of four.) |
802 | ;;; | 802 | ;;; |
803 | ;;; It should be confessed that this loop usually does not represent | 803 | ;;; It should be confessed that this loop usually does not represent |
804 | ;;; much of the total running time. Replacing it with a more | 804 | ;;; much of the total running time. Replacing it with a more |
805 | ;;; straightforward "rep cmpsb" would not drastically degrade | 805 | ;;; straightforward "rep cmpsb" would not drastically degrade |
806 | ;;; performance. | 806 | ;;; performance. |
807 | 807 | ||
808 | LoopCmps: | 808 | LoopCmps: |
809 | mov eax, [esi + edx] | 809 | mov eax, [esi + edx] |
810 | xor eax, [edi + edx] | 810 | xor eax, [edi + edx] |
811 | jnz LeaveLoopCmps | 811 | jnz LeaveLoopCmps |
812 | mov eax, [esi + edx + 4] | 812 | mov eax, [esi + edx + 4] |
813 | xor eax, [edi + edx + 4] | 813 | xor eax, [edi + edx + 4] |
814 | jnz LeaveLoopCmps4 | 814 | jnz LeaveLoopCmps4 |
815 | add edx, 8 | 815 | add edx, 8 |
816 | jnz LoopCmps | 816 | jnz LoopCmps |
817 | jmp short LenMaximum | 817 | jmp short LenMaximum |
818 | LeaveLoopCmps4: add edx, 4 | 818 | LeaveLoopCmps4: add edx, 4 |
819 | LeaveLoopCmps: test eax, 0000FFFFh | 819 | LeaveLoopCmps: test eax, 0000FFFFh |
820 | jnz LenLower | 820 | jnz LenLower |
821 | add edx, 2 | 821 | add edx, 2 |
822 | shr eax, 16 | 822 | shr eax, 16 |
823 | LenLower: sub al, 1 | 823 | LenLower: sub al, 1 |
824 | adc edx, 0 | 824 | adc edx, 0 |
825 | 825 | ||
826 | ;;; Calculate the length of the match. If it is longer than MAX_MATCH, | 826 | ;;; Calculate the length of the match. If it is longer than MAX_MATCH, |
827 | ;;; then automatically accept it as the best possible match and leave. | 827 | ;;; then automatically accept it as the best possible match and leave. |
828 | 828 | ||
829 | lea eax, [edi + edx] | 829 | lea eax, [edi + edx] |
830 | mov edi, [scan] | 830 | mov edi, [scan] |
831 | sub eax, edi | 831 | sub eax, edi |
832 | cmp eax, MAX_MATCH | 832 | cmp eax, MAX_MATCH |
833 | jge LenMaximum | 833 | jge LenMaximum |
834 | 834 | ||
835 | ;;; If the length of the match is not longer than the best match we | 835 | ;;; If the length of the match is not longer than the best match we |
836 | ;;; have so far, then forget it and return to the lookup loop. | 836 | ;;; have so far, then forget it and return to the lookup loop. |
837 | 837 | ||
838 | mov edx, [deflatestate] | 838 | mov edx, [deflatestate] |
839 | mov ebx, [bestlen] | 839 | mov ebx, [bestlen] |
840 | cmp eax, ebx | 840 | cmp eax, ebx |
841 | jg LongerMatch | 841 | jg LongerMatch |
842 | mov esi, [windowbestlen] | 842 | mov esi, [windowbestlen] |
843 | mov edi, [edx + dsPrev] | 843 | mov edi, [edx + dsPrev] |
844 | mov ebx, [scanend] | 844 | mov ebx, [scanend] |
845 | mov edx, [chainlenwmask] | 845 | mov edx, [chainlenwmask] |
846 | jmp LookupLoop | 846 | jmp LookupLoop |
847 | 847 | ||
848 | ;;; s->match_start = cur_match; | 848 | ;;; s->match_start = cur_match; |
849 | ;;; best_len = len; | 849 | ;;; best_len = len; |
850 | ;;; if (len >= nice_match) break; | 850 | ;;; if (len >= nice_match) break; |
851 | ;;; scan_end = *(ushf*)(scan+best_len-1); | 851 | ;;; scan_end = *(ushf*)(scan+best_len-1); |
852 | 852 | ||
853 | LongerMatch: mov ebx, [nicematch] | 853 | LongerMatch: mov ebx, [nicematch] |
854 | mov [bestlen], eax | 854 | mov [bestlen], eax |
855 | mov [edx + dsMatchStart], ecx | 855 | mov [edx + dsMatchStart], ecx |
856 | cmp eax, ebx | 856 | cmp eax, ebx |
857 | jge LeaveNow | 857 | jge LeaveNow |
858 | mov esi, [window] | 858 | mov esi, [window] |
859 | add esi, eax | 859 | add esi, eax |
860 | mov [windowbestlen], esi | 860 | mov [windowbestlen], esi |
861 | movzx ebx, word ptr [edi + eax - 1] | 861 | movzx ebx, word ptr [edi + eax - 1] |
862 | mov edi, [edx + dsPrev] | 862 | mov edi, [edx + dsPrev] |
863 | mov [scanend], ebx | 863 | mov [scanend], ebx |
864 | mov edx, [chainlenwmask] | 864 | mov edx, [chainlenwmask] |
865 | jmp LookupLoop | 865 | jmp LookupLoop |
866 | 866 | ||
867 | ;;; Accept the current string, with the maximum possible length. | 867 | ;;; Accept the current string, with the maximum possible length. |
868 | 868 | ||
869 | LenMaximum: mov edx, [deflatestate] | 869 | LenMaximum: mov edx, [deflatestate] |
870 | mov dword ptr [bestlen], MAX_MATCH | 870 | mov dword ptr [bestlen], MAX_MATCH |
871 | mov [edx + dsMatchStart], ecx | 871 | mov [edx + dsMatchStart], ecx |
872 | 872 | ||
873 | ;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; | 873 | ;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len; |
874 | ;;; return s->lookahead; | 874 | ;;; return s->lookahead; |
875 | 875 | ||
876 | LeaveNow: | 876 | LeaveNow: |
877 | mov edx, [deflatestate] | 877 | mov edx, [deflatestate] |
878 | mov ebx, [bestlen] | 878 | mov ebx, [bestlen] |
879 | mov eax, [edx + dsLookahead] | 879 | mov eax, [edx + dsLookahead] |
880 | cmp ebx, eax | 880 | cmp ebx, eax |
881 | jg LookaheadRet | 881 | jg LookaheadRet |
882 | mov eax, ebx | 882 | mov eax, ebx |
883 | LookaheadRet: | 883 | LookaheadRet: |
884 | 884 | ||
885 | ;;; Restore the stack and return from whence we came. | 885 | ;;; Restore the stack and return from whence we came. |
886 | 886 | ||
887 | add esp, LocalVarsSize | 887 | add esp, LocalVarsSize |
888 | pop ebx | 888 | pop ebx |
889 | pop esi | 889 | pop esi |
890 | pop edi | 890 | pop edi |
891 | pop ebp | 891 | pop ebp |
892 | 892 | ||
893 | ret | 893 | ret |
894 | ; please don't remove this string ! | 894 | ; please don't remove this string ! |
895 | ; Your are free use gvmat32 in any fre or commercial apps if you don't remove the string in the binary! | 895 | ; Your can freely use gvmat32 in any free or commercial app if you don't remove the string in the binary! |
896 | db 0dh,0ah,"asm686 with masm, code optimised assembly code from Brian Raiter, written 1998",0dh,0ah | 896 | db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998",0dh,0ah |
897 | 897 | ||
898 | IFDEF NOUNDERLINE | 898 | IFDEF NOUNDERLINE |
899 | longest_match_686 endp | 899 | longest_match_686 endp |
900 | ELSE | 900 | ELSE |
901 | _longest_match_686 endp | 901 | _longest_match_686 endp |
902 | ENDIF | 902 | ENDIF |
903 | 903 | ||
904 | _TEXT ends | 904 | _TEXT ends |
905 | end | 905 | end |
diff --git a/contrib/vstudio/vc70_32/gvmat32c.c b/contrib/masmx86/gvmat32c.c index 38be10b..9ed25f3 100644 --- a/contrib/vstudio/vc70_32/gvmat32c.c +++ b/contrib/masmx86/gvmat32c.c | |||
@@ -1,209 +1,206 @@ | |||
1 | /* gvmat32.c -- C portion of the optimized longest_match for 32 bits x86 | 1 | /* gvmat32.c -- C portion of the optimized longest_match for 32 bits x86 |
2 | * Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. | 2 | * Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant. |
3 | * File written by Gilles Vollant, by modifiying the longest_match | 3 | * File written by Gilles Vollant, by modifiying the longest_match |
4 | * from Jean-loup Gailly in deflate.c | 4 | * from Jean-loup Gailly in deflate.c |
5 | * it prepare all parameters and call the assembly longest_match_gvasm | 5 | * it prepare all parameters and call the assembly longest_match_gvasm |
6 | * longest_match execute standard C code is wmask != 0x7fff | 6 | * longest_match execute standard C code is wmask != 0x7fff |
7 | * (assembly code is faster with a fixed wmask) | 7 | * (assembly code is faster with a fixed wmask) |
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include "deflate.h" | 11 | #include "deflate.h" |
12 | 12 | ||
13 | #undef FAR | 13 | #ifdef ASMV |
14 | //#include <windows.h> | 14 | #define NIL 0 |
15 | 15 | ||
16 | #ifdef ASMV | 16 | #define UNALIGNED_OK |
17 | #define NIL 0 | 17 | |
18 | 18 | ||
19 | #define UNALIGNED_OK | 19 | /* if your C compiler don't add underline before function name, |
20 | 20 | define ADD_UNDERLINE_ASMFUNC */ | |
21 | 21 | #ifdef ADD_UNDERLINE_ASMFUNC | |
22 | /* if your C compiler don't add underline before function name, | 22 | #define longest_match_7fff _longest_match_7fff |
23 | define ADD_UNDERLINE_ASMFUNC */ | 23 | #define longest_match_686 _longest_match_686 |
24 | #ifdef ADD_UNDERLINE_ASMFUNC | 24 | #define cpudetect32 _cpudetect32 |
25 | #define longest_match_7fff _longest_match_7fff | 25 | #endif |
26 | #define longest_match_686 _longest_match_686 | 26 | |
27 | #define cpudetect32 _cpudetect32 | 27 | |
28 | #endif | 28 | |
29 | 29 | void match_init() | |
30 | 30 | { | |
31 | 31 | } | |
32 | void match_init() | 32 | |
33 | { | 33 | unsigned long cpudetect32(); |
34 | } | 34 | |
35 | 35 | uInt longest_match_c( | |
36 | unsigned long cpudetect32(); | 36 | deflate_state *s, |
37 | 37 | IPos cur_match); /* current match */ | |
38 | uInt longest_match_c( | 38 | |
39 | deflate_state *s, | 39 | |
40 | IPos cur_match); /* current match */ | 40 | uInt longest_match_7fff( |
41 | 41 | deflate_state *s, | |
42 | 42 | IPos cur_match); /* current match */ | |
43 | uInt longest_match_7fff( | 43 | |
44 | deflate_state *s, | 44 | uInt longest_match_686( |
45 | IPos cur_match); /* current match */ | 45 | deflate_state *s, |
46 | 46 | IPos cur_match); /* current match */ | |
47 | uInt longest_match_686( | 47 | |
48 | deflate_state *s, | 48 | uInt longest_match( |
49 | IPos cur_match); /* current match */ | 49 | deflate_state *s, |
50 | 50 | IPos cur_match) /* current match */ | |
51 | uInt longest_match( | 51 | { |
52 | deflate_state *s, | 52 | static uInt iIsPPro=2; |
53 | IPos cur_match) /* current match */ | 53 | |
54 | { | 54 | if ((s->w_mask == 0x7fff) && (iIsPPro==0)) |
55 | static uInt iIsPPro=2; | 55 | return longest_match_7fff(s,cur_match); |
56 | 56 | ||
57 | if ((s->w_mask == 0x7fff) && (iIsPPro==0)) | 57 | if (iIsPPro==1) |
58 | return longest_match_7fff(s,cur_match); | 58 | return longest_match_686(s,cur_match); |
59 | 59 | ||
60 | if (iIsPPro==1) | 60 | if (iIsPPro==2) |
61 | return longest_match_686(s,cur_match); | 61 | iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0; |
62 | 62 | ||
63 | if (iIsPPro==2) | 63 | return longest_match_c(s,cur_match); |
64 | iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0; | 64 | } |
65 | 65 | ||
66 | return longest_match_c(s,cur_match); | 66 | |
67 | } | 67 | |
68 | 68 | uInt longest_match_c(s, cur_match) | |
69 | 69 | deflate_state *s; | |
70 | 70 | IPos cur_match; /* current match */ | |
71 | uInt longest_match_c(s, cur_match) | 71 | { |
72 | deflate_state *s; | 72 | unsigned chain_length = s->max_chain_length;/* max hash chain length */ |
73 | IPos cur_match; /* current match */ | 73 | register Bytef *scan = s->window + s->strstart; /* current string */ |
74 | { | 74 | register Bytef *match; /* matched string */ |
75 | unsigned chain_length = s->max_chain_length;/* max hash chain length */ | 75 | register int len; /* length of current match */ |
76 | register Bytef *scan = s->window + s->strstart; /* current string */ | 76 | int best_len = s->prev_length; /* best match length so far */ |
77 | register Bytef *match; /* matched string */ | 77 | int nice_match = s->nice_match; /* stop if match long enough */ |
78 | register int len; /* length of current match */ | 78 | IPos limit = s->strstart > (IPos)MAX_DIST(s) ? |
79 | int best_len = s->prev_length; /* best match length so far */ | 79 | s->strstart - (IPos)MAX_DIST(s) : NIL; |
80 | int nice_match = s->nice_match; /* stop if match long enough */ | 80 | /* Stop when cur_match becomes <= limit. To simplify the code, |
81 | IPos limit = s->strstart > (IPos)MAX_DIST(s) ? | 81 | * we prevent matches with the string of window index 0. |
82 | s->strstart - (IPos)MAX_DIST(s) : NIL; | 82 | */ |
83 | /* Stop when cur_match becomes <= limit. To simplify the code, | 83 | Posf *prev = s->prev; |
84 | * we prevent matches with the string of window index 0. | 84 | uInt wmask = s->w_mask; |
85 | */ | 85 | |
86 | Posf *prev = s->prev; | 86 | #ifdef UNALIGNED_OK |
87 | uInt wmask = s->w_mask; | 87 | /* Compare two bytes at a time. Note: this is not always beneficial. |
88 | 88 | * Try with and without -DUNALIGNED_OK to check. | |
89 | #ifdef UNALIGNED_OK | 89 | */ |
90 | /* Compare two bytes at a time. Note: this is not always beneficial. | 90 | register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; |
91 | * Try with and without -DUNALIGNED_OK to check. | 91 | register ush scan_start = *(ushf*)scan; |
92 | */ | 92 | register ush scan_end = *(ushf*)(scan+best_len-1); |
93 | register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; | 93 | #else |
94 | register ush scan_start = *(ushf*)scan; | 94 | register Bytef *strend = s->window + s->strstart + MAX_MATCH; |
95 | register ush scan_end = *(ushf*)(scan+best_len-1); | 95 | register Byte scan_end1 = scan[best_len-1]; |
96 | #else | 96 | register Byte scan_end = scan[best_len]; |
97 | register Bytef *strend = s->window + s->strstart + MAX_MATCH; | 97 | #endif |
98 | register Byte scan_end1 = scan[best_len-1]; | 98 | |
99 | register Byte scan_end = scan[best_len]; | 99 | /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. |
100 | #endif | 100 | * It is easy to get rid of this optimization if necessary. |
101 | 101 | */ | |
102 | /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. | 102 | Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); |
103 | * It is easy to get rid of this optimization if necessary. | 103 | |
104 | */ | 104 | /* Do not waste too much time if we already have a good match: */ |
105 | Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); | 105 | if (s->prev_length >= s->good_match) { |
106 | 106 | chain_length >>= 2; | |
107 | /* Do not waste too much time if we already have a good match: */ | 107 | } |
108 | if (s->prev_length >= s->good_match) { | 108 | /* Do not look for matches beyond the end of the input. This is necessary |
109 | chain_length >>= 2; | 109 | * to make deflate deterministic. |
110 | } | 110 | */ |
111 | /* Do not look for matches beyond the end of the input. This is necessary | 111 | if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; |
112 | * to make deflate deterministic. | 112 | |
113 | */ | 113 | Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); |
114 | if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead; | 114 | |
115 | 115 | do { | |
116 | Assert((ulg)s->strstart <= s->window_size-MIN_LOOKAHEAD, "need lookahead"); | 116 | Assert(cur_match < s->strstart, "no future"); |
117 | 117 | match = s->window + cur_match; | |
118 | do { | 118 | |
119 | Assert(cur_match < s->strstart, "no future"); | 119 | /* Skip to next match if the match length cannot increase |
120 | match = s->window + cur_match; | 120 | * or if the match length is less than 2: |
121 | 121 | */ | |
122 | /* Skip to next match if the match length cannot increase | 122 | #if (defined(UNALIGNED_OK) && MAX_MATCH == 258) |
123 | * or if the match length is less than 2: | 123 | /* This code assumes sizeof(unsigned short) == 2. Do not use |
124 | */ | 124 | * UNALIGNED_OK if your compiler uses a different size. |
125 | #if (defined(UNALIGNED_OK) && MAX_MATCH == 258) | 125 | */ |
126 | /* This code assumes sizeof(unsigned short) == 2. Do not use | 126 | if (*(ushf*)(match+best_len-1) != scan_end || |
127 | * UNALIGNED_OK if your compiler uses a different size. | 127 | *(ushf*)match != scan_start) continue; |
128 | */ | 128 | |
129 | if (*(ushf*)(match+best_len-1) != scan_end || | 129 | /* It is not necessary to compare scan[2] and match[2] since they are |
130 | *(ushf*)match != scan_start) continue; | 130 | * always equal when the other bytes match, given that the hash keys |
131 | 131 | * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at | |
132 | /* It is not necessary to compare scan[2] and match[2] since they are | 132 | * strstart+3, +5, ... up to strstart+257. We check for insufficient |
133 | * always equal when the other bytes match, given that the hash keys | 133 | * lookahead only every 4th comparison; the 128th check will be made |
134 | * are equal and that HASH_BITS >= 8. Compare 2 bytes at a time at | 134 | * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is |
135 | * strstart+3, +5, ... up to strstart+257. We check for insufficient | 135 | * necessary to put more guard bytes at the end of the window, or |
136 | * lookahead only every 4th comparison; the 128th check will be made | 136 | * to check more often for insufficient lookahead. |
137 | * at strstart+257. If MAX_MATCH-2 is not a multiple of 8, it is | 137 | */ |
138 | * necessary to put more guard bytes at the end of the window, or | 138 | Assert(scan[2] == match[2], "scan[2]?"); |
139 | * to check more often for insufficient lookahead. | 139 | scan++, match++; |
140 | */ | 140 | do { |
141 | Assert(scan[2] == match[2], "scan[2]?"); | 141 | } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && |
142 | scan++, match++; | 142 | *(ushf*)(scan+=2) == *(ushf*)(match+=2) && |
143 | do { | 143 | *(ushf*)(scan+=2) == *(ushf*)(match+=2) && |
144 | } while (*(ushf*)(scan+=2) == *(ushf*)(match+=2) && | 144 | *(ushf*)(scan+=2) == *(ushf*)(match+=2) && |
145 | *(ushf*)(scan+=2) == *(ushf*)(match+=2) && | 145 | scan < strend); |
146 | *(ushf*)(scan+=2) == *(ushf*)(match+=2) && | 146 | /* The funny "do {}" generates better code on most compilers */ |
147 | *(ushf*)(scan+=2) == *(ushf*)(match+=2) && | 147 | |
148 | scan < strend); | 148 | /* Here, scan <= window+strstart+257 */ |
149 | /* The funny "do {}" generates better code on most compilers */ | 149 | Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); |
150 | 150 | if (*scan == *match) scan++; | |
151 | /* Here, scan <= window+strstart+257 */ | 151 | |
152 | Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); | 152 | len = (MAX_MATCH - 1) - (int)(strend-scan); |
153 | if (*scan == *match) scan++; | 153 | scan = strend - (MAX_MATCH-1); |
154 | 154 | ||
155 | len = (MAX_MATCH - 1) - (int)(strend-scan); | 155 | #else /* UNALIGNED_OK */ |
156 | scan = strend - (MAX_MATCH-1); | 156 | |
157 | 157 | if (match[best_len] != scan_end || | |
158 | #else /* UNALIGNED_OK */ | 158 | match[best_len-1] != scan_end1 || |
159 | 159 | *match != *scan || | |
160 | if (match[best_len] != scan_end || | 160 | *++match != scan[1]) continue; |
161 | match[best_len-1] != scan_end1 || | 161 | |
162 | *match != *scan || | 162 | /* The check at best_len-1 can be removed because it will be made |
163 | *++match != scan[1]) continue; | 163 | * again later. (This heuristic is not always a win.) |
164 | 164 | * It is not necessary to compare scan[2] and match[2] since they | |
165 | /* The check at best_len-1 can be removed because it will be made | 165 | * are always equal when the other bytes match, given that |
166 | * again later. (This heuristic is not always a win.) | 166 | * the hash keys are equal and that HASH_BITS >= 8. |
167 | * It is not necessary to compare scan[2] and match[2] since they | 167 | */ |
168 | * are always equal when the other bytes match, given that | 168 | scan += 2, match++; |
169 | * the hash keys are equal and that HASH_BITS >= 8. | 169 | Assert(*scan == *match, "match[2]?"); |
170 | */ | 170 | |
171 | scan += 2, match++; | 171 | /* We check for insufficient lookahead only every 8th comparison; |
172 | Assert(*scan == *match, "match[2]?"); | 172 | * the 256th check will be made at strstart+258. |
173 | 173 | */ | |
174 | /* We check for insufficient lookahead only every 8th comparison; | 174 | do { |
175 | * the 256th check will be made at strstart+258. | 175 | } while (*++scan == *++match && *++scan == *++match && |
176 | */ | 176 | *++scan == *++match && *++scan == *++match && |
177 | do { | 177 | *++scan == *++match && *++scan == *++match && |
178 | } while (*++scan == *++match && *++scan == *++match && | 178 | *++scan == *++match && *++scan == *++match && |
179 | *++scan == *++match && *++scan == *++match && | 179 | scan < strend); |
180 | *++scan == *++match && *++scan == *++match && | 180 | |
181 | *++scan == *++match && *++scan == *++match && | 181 | Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); |
182 | scan < strend); | 182 | |
183 | 183 | len = MAX_MATCH - (int)(strend - scan); | |
184 | Assert(scan <= s->window+(unsigned)(s->window_size-1), "wild scan"); | 184 | scan = strend - MAX_MATCH; |
185 | 185 | ||
186 | len = MAX_MATCH - (int)(strend - scan); | 186 | #endif /* UNALIGNED_OK */ |
187 | scan = strend - MAX_MATCH; | 187 | |
188 | 188 | if (len > best_len) { | |
189 | #endif /* UNALIGNED_OK */ | 189 | s->match_start = cur_match; |
190 | 190 | best_len = len; | |
191 | if (len > best_len) { | 191 | if (len >= nice_match) break; |
192 | s->match_start = cur_match; | 192 | #ifdef UNALIGNED_OK |
193 | best_len = len; | 193 | scan_end = *(ushf*)(scan+best_len-1); |
194 | if (len >= nice_match) break; | 194 | #else |
195 | #ifdef UNALIGNED_OK | 195 | scan_end1 = scan[best_len-1]; |
196 | scan_end = *(ushf*)(scan+best_len-1); | 196 | scan_end = scan[best_len]; |
197 | #else | 197 | #endif |
198 | scan_end1 = scan[best_len-1]; | 198 | } |
199 | scan_end = scan[best_len]; | 199 | } while ((cur_match = prev[cur_match & wmask]) > limit |
200 | #endif | 200 | && --chain_length != 0); |
201 | } | 201 | |
202 | } while ((cur_match = prev[cur_match & wmask]) > limit | 202 | if ((uInt)best_len <= s->lookahead) return (uInt)best_len; |
203 | && --chain_length != 0); | 203 | return s->lookahead; |
204 | 204 | } | |
205 | if ((uInt)best_len <= s->lookahead) return (uInt)best_len; | 205 | |
206 | return s->lookahead; | 206 | #endif /* ASMV */ |
207 | } | ||
208 | |||
209 | #endif /* ASMV */ | ||
diff --git a/contrib/masmx86/inffas32.asm b/contrib/masmx86/inffas32.asm new file mode 100644 index 0000000..7d76e1c --- /dev/null +++ b/contrib/masmx86/inffas32.asm | |||
@@ -0,0 +1,1033 @@ | |||
1 | ; 75 "inffast.S" | ||
2 | ;FILE "inffast.S" | ||
3 | |||
4 | ;;;GLOBAL _inflate_fast | ||
5 | |||
6 | ;;;SECTION .text | ||
7 | |||
8 | |||
9 | |||
10 | .586p | ||
11 | .mmx | ||
12 | |||
13 | name inflate_fast_x86 | ||
14 | .MODEL FLAT | ||
15 | |||
16 | _DATA segment | ||
17 | inflate_fast_use_mmx: | ||
18 | dd 1 | ||
19 | |||
20 | |||
21 | _TEXT segment | ||
22 | PUBLIC _inflate_fast | ||
23 | |||
24 | ALIGN 4 | ||
25 | _inflate_fast: | ||
26 | jmp inflate_fast_entry | ||
27 | |||
28 | |||
29 | |||
30 | ALIGN 4 | ||
31 | db 'Fast decoding Code from Chris Anderson' | ||
32 | db 0 | ||
33 | |||
34 | ALIGN 4 | ||
35 | invalid_literal_length_code_msg: | ||
36 | db 'invalid literal/length code' | ||
37 | db 0 | ||
38 | |||
39 | ALIGN 4 | ||
40 | invalid_distance_code_msg: | ||
41 | db 'invalid distance code' | ||
42 | db 0 | ||
43 | |||
44 | ALIGN 4 | ||
45 | invalid_distance_too_far_msg: | ||
46 | db 'invalid distance too far back' | ||
47 | db 0 | ||
48 | |||
49 | |||
50 | ALIGN 4 | ||
51 | inflate_fast_mask: | ||
52 | dd 0 | ||
53 | dd 1 | ||
54 | dd 3 | ||
55 | dd 7 | ||
56 | dd 15 | ||
57 | dd 31 | ||
58 | dd 63 | ||
59 | dd 127 | ||
60 | dd 255 | ||
61 | dd 511 | ||
62 | dd 1023 | ||
63 | dd 2047 | ||
64 | dd 4095 | ||
65 | dd 8191 | ||
66 | dd 16383 | ||
67 | dd 32767 | ||
68 | dd 65535 | ||
69 | dd 131071 | ||
70 | dd 262143 | ||
71 | dd 524287 | ||
72 | dd 1048575 | ||
73 | dd 2097151 | ||
74 | dd 4194303 | ||
75 | dd 8388607 | ||
76 | dd 16777215 | ||
77 | dd 33554431 | ||
78 | dd 67108863 | ||
79 | dd 134217727 | ||
80 | dd 268435455 | ||
81 | dd 536870911 | ||
82 | dd 1073741823 | ||
83 | dd 2147483647 | ||
84 | dd 4294967295 | ||
85 | |||
86 | |||
87 | |||
88 | mode_state equ 0 ;/* state->mode */ | ||
89 | wsize_state equ 32 ;/* state->wsize */ | ||
90 | write_state equ (36+4) ;/* state->write */ | ||
91 | window_state equ (40+4) ;/* state->window */ | ||
92 | hold_state equ (44+4) ;/* state->hold */ | ||
93 | bits_state equ (48+4) ;/* state->bits */ | ||
94 | lencode_state equ (64+4) ;/* state->lencode */ | ||
95 | distcode_state equ (68+4) ;/* state->distcode */ | ||
96 | lenbits_state equ (72+4) ;/* state->lenbits */ | ||
97 | distbits_state equ (76+4) ;/* state->distbits */ | ||
98 | |||
99 | |||
100 | ;;SECTION .text | ||
101 | ; 205 "inffast.S" | ||
102 | ;GLOBAL inflate_fast_use_mmx | ||
103 | |||
104 | ;SECTION .data | ||
105 | |||
106 | |||
107 | ; GLOBAL inflate_fast_use_mmx:object | ||
108 | ;.size inflate_fast_use_mmx, 4 | ||
109 | ; 226 "inffast.S" | ||
110 | ;SECTION .text | ||
111 | |||
112 | ALIGN 4 | ||
113 | inflate_fast_entry: | ||
114 | push edi | ||
115 | push esi | ||
116 | push ebp | ||
117 | push ebx | ||
118 | pushfd | ||
119 | sub esp,64 | ||
120 | cld | ||
121 | |||
122 | |||
123 | |||
124 | |||
125 | mov esi, [esp+88] | ||
126 | mov edi, [esi+28] | ||
127 | |||
128 | |||
129 | |||
130 | |||
131 | |||
132 | |||
133 | |||
134 | mov edx, [esi+4] | ||
135 | mov eax, [esi+0] | ||
136 | |||
137 | add edx,eax | ||
138 | sub edx,11 | ||
139 | |||
140 | mov [esp+44],eax | ||
141 | mov [esp+20],edx | ||
142 | |||
143 | mov ebp, [esp+92] | ||
144 | mov ecx, [esi+16] | ||
145 | mov ebx, [esi+12] | ||
146 | |||
147 | sub ebp,ecx | ||
148 | neg ebp | ||
149 | add ebp,ebx | ||
150 | |||
151 | sub ecx,257 | ||
152 | add ecx,ebx | ||
153 | |||
154 | mov [esp+60],ebx | ||
155 | mov [esp+40],ebp | ||
156 | mov [esp+16],ecx | ||
157 | ; 285 "inffast.S" | ||
158 | mov eax, [edi+lencode_state] | ||
159 | mov ecx, [edi+distcode_state] | ||
160 | |||
161 | mov [esp+8],eax | ||
162 | mov [esp+12],ecx | ||
163 | |||
164 | mov eax,1 | ||
165 | mov ecx, [edi+lenbits_state] | ||
166 | shl eax,cl | ||
167 | dec eax | ||
168 | mov [esp+0],eax | ||
169 | |||
170 | mov eax,1 | ||
171 | mov ecx, [edi+distbits_state] | ||
172 | shl eax,cl | ||
173 | dec eax | ||
174 | mov [esp+4],eax | ||
175 | |||
176 | mov eax, [edi+wsize_state] | ||
177 | mov ecx, [edi+write_state] | ||
178 | mov edx, [edi+window_state] | ||
179 | |||
180 | mov [esp+52],eax | ||
181 | mov [esp+48],ecx | ||
182 | mov [esp+56],edx | ||
183 | |||
184 | mov ebp, [edi+hold_state] | ||
185 | mov ebx, [edi+bits_state] | ||
186 | ; 321 "inffast.S" | ||
187 | mov esi, [esp+44] | ||
188 | mov ecx, [esp+20] | ||
189 | cmp ecx,esi | ||
190 | ja L_align_long | ||
191 | |||
192 | add ecx,11 | ||
193 | sub ecx,esi | ||
194 | mov eax,12 | ||
195 | sub eax,ecx | ||
196 | lea edi, [esp+28] | ||
197 | rep movsb | ||
198 | mov ecx,eax | ||
199 | xor eax,eax | ||
200 | rep stosb | ||
201 | lea esi, [esp+28] | ||
202 | mov [esp+20],esi | ||
203 | jmp L_is_aligned | ||
204 | |||
205 | |||
206 | L_align_long: | ||
207 | test esi,3 | ||
208 | jz L_is_aligned | ||
209 | xor eax,eax | ||
210 | mov al, [esi] | ||
211 | inc esi | ||
212 | mov ecx,ebx | ||
213 | add ebx,8 | ||
214 | shl eax,cl | ||
215 | or ebp,eax | ||
216 | jmp L_align_long | ||
217 | |||
218 | L_is_aligned: | ||
219 | mov edi, [esp+60] | ||
220 | ; 366 "inffast.S" | ||
221 | L_check_mmx: | ||
222 | cmp dword ptr [inflate_fast_use_mmx],2 | ||
223 | je L_init_mmx | ||
224 | ja L_do_loop | ||
225 | |||
226 | push eax | ||
227 | push ebx | ||
228 | push ecx | ||
229 | push edx | ||
230 | pushfd | ||
231 | mov eax, [esp] | ||
232 | xor dword ptr [esp],0200000h | ||
233 | |||
234 | |||
235 | |||
236 | |||
237 | popfd | ||
238 | pushfd | ||
239 | pop edx | ||
240 | xor edx,eax | ||
241 | jz L_dont_use_mmx | ||
242 | xor eax,eax | ||
243 | cpuid | ||
244 | cmp ebx,0756e6547h | ||
245 | jne L_dont_use_mmx | ||
246 | cmp ecx,06c65746eh | ||
247 | jne L_dont_use_mmx | ||
248 | cmp edx,049656e69h | ||
249 | jne L_dont_use_mmx | ||
250 | mov eax,1 | ||
251 | cpuid | ||
252 | shr eax,8 | ||
253 | and eax,15 | ||
254 | cmp eax,6 | ||
255 | jne L_dont_use_mmx | ||
256 | test edx,0800000h | ||
257 | jnz L_use_mmx | ||
258 | jmp L_dont_use_mmx | ||
259 | L_use_mmx: | ||
260 | mov dword ptr [inflate_fast_use_mmx],2 | ||
261 | jmp L_check_mmx_pop | ||
262 | L_dont_use_mmx: | ||
263 | mov dword ptr [inflate_fast_use_mmx],3 | ||
264 | L_check_mmx_pop: | ||
265 | pop edx | ||
266 | pop ecx | ||
267 | pop ebx | ||
268 | pop eax | ||
269 | jmp L_check_mmx | ||
270 | ; 426 "inffast.S" | ||
271 | ALIGN 4 | ||
272 | L_do_loop: | ||
273 | ; 437 "inffast.S" | ||
274 | cmp bl,15 | ||
275 | ja L_get_length_code | ||
276 | |||
277 | xor eax,eax | ||
278 | lodsw | ||
279 | mov cl,bl | ||
280 | add bl,16 | ||
281 | shl eax,cl | ||
282 | or ebp,eax | ||
283 | |||
284 | L_get_length_code: | ||
285 | mov edx, [esp+0] | ||
286 | mov ecx, [esp+8] | ||
287 | and edx,ebp | ||
288 | mov eax, [ecx+edx*4] | ||
289 | |||
290 | L_dolen: | ||
291 | |||
292 | |||
293 | |||
294 | |||
295 | |||
296 | |||
297 | mov cl,ah | ||
298 | sub bl,ah | ||
299 | shr ebp,cl | ||
300 | |||
301 | |||
302 | |||
303 | |||
304 | |||
305 | |||
306 | test al,al | ||
307 | jnz L_test_for_length_base | ||
308 | |||
309 | shr eax,16 | ||
310 | stosb | ||
311 | |||
312 | L_while_test: | ||
313 | |||
314 | |||
315 | cmp [esp+16],edi | ||
316 | jbe L_break_loop | ||
317 | |||
318 | cmp [esp+20],esi | ||
319 | ja L_do_loop | ||
320 | jmp L_break_loop | ||
321 | |||
322 | L_test_for_length_base: | ||
323 | ; 502 "inffast.S" | ||
324 | mov edx,eax | ||
325 | shr edx,16 | ||
326 | mov cl,al | ||
327 | |||
328 | test al,16 | ||
329 | jz L_test_for_second_level_length | ||
330 | and cl,15 | ||
331 | jz L_save_len | ||
332 | cmp bl,cl | ||
333 | jae L_add_bits_to_len | ||
334 | |||
335 | mov ch,cl | ||
336 | xor eax,eax | ||
337 | lodsw | ||
338 | mov cl,bl | ||
339 | add bl,16 | ||
340 | shl eax,cl | ||
341 | or ebp,eax | ||
342 | mov cl,ch | ||
343 | |||
344 | L_add_bits_to_len: | ||
345 | mov eax,1 | ||
346 | shl eax,cl | ||
347 | dec eax | ||
348 | sub bl,cl | ||
349 | and eax,ebp | ||
350 | shr ebp,cl | ||
351 | add edx,eax | ||
352 | |||
353 | L_save_len: | ||
354 | mov [esp+24],edx | ||
355 | |||
356 | |||
357 | L_decode_distance: | ||
358 | ; 549 "inffast.S" | ||
359 | cmp bl,15 | ||
360 | ja L_get_distance_code | ||
361 | |||
362 | xor eax,eax | ||
363 | lodsw | ||
364 | mov cl,bl | ||
365 | add bl,16 | ||
366 | shl eax,cl | ||
367 | or ebp,eax | ||
368 | |||
369 | L_get_distance_code: | ||
370 | mov edx, [esp+4] | ||
371 | mov ecx, [esp+12] | ||
372 | and edx,ebp | ||
373 | mov eax, [ecx+edx*4] | ||
374 | |||
375 | |||
376 | L_dodist: | ||
377 | mov edx,eax | ||
378 | shr edx,16 | ||
379 | mov cl,ah | ||
380 | sub bl,ah | ||
381 | shr ebp,cl | ||
382 | ; 584 "inffast.S" | ||
383 | mov cl,al | ||
384 | |||
385 | test al,16 | ||
386 | jz L_test_for_second_level_dist | ||
387 | and cl,15 | ||
388 | jz L_check_dist_one | ||
389 | cmp bl,cl | ||
390 | jae L_add_bits_to_dist | ||
391 | |||
392 | mov ch,cl | ||
393 | xor eax,eax | ||
394 | lodsw | ||
395 | mov cl,bl | ||
396 | add bl,16 | ||
397 | shl eax,cl | ||
398 | or ebp,eax | ||
399 | mov cl,ch | ||
400 | |||
401 | L_add_bits_to_dist: | ||
402 | mov eax,1 | ||
403 | shl eax,cl | ||
404 | dec eax | ||
405 | sub bl,cl | ||
406 | and eax,ebp | ||
407 | shr ebp,cl | ||
408 | add edx,eax | ||
409 | jmp L_check_window | ||
410 | |||
411 | L_check_window: | ||
412 | ; 625 "inffast.S" | ||
413 | mov [esp+44],esi | ||
414 | mov eax,edi | ||
415 | sub eax, [esp+40] | ||
416 | |||
417 | cmp eax,edx | ||
418 | jb L_clip_window | ||
419 | |||
420 | mov ecx, [esp+24] | ||
421 | mov esi,edi | ||
422 | sub esi,edx | ||
423 | |||
424 | sub ecx,3 | ||
425 | mov al, [esi] | ||
426 | mov [edi],al | ||
427 | mov al, [esi+1] | ||
428 | mov dl, [esi+2] | ||
429 | add esi,3 | ||
430 | mov [edi+1],al | ||
431 | mov [edi+2],dl | ||
432 | add edi,3 | ||
433 | rep movsb | ||
434 | |||
435 | mov esi, [esp+44] | ||
436 | jmp L_while_test | ||
437 | |||
438 | ALIGN 4 | ||
439 | L_check_dist_one: | ||
440 | cmp edx,1 | ||
441 | jne L_check_window | ||
442 | cmp [esp+40],edi | ||
443 | je L_check_window | ||
444 | |||
445 | dec edi | ||
446 | mov ecx, [esp+24] | ||
447 | mov al, [edi] | ||
448 | sub ecx,3 | ||
449 | |||
450 | mov [edi+1],al | ||
451 | mov [edi+2],al | ||
452 | mov [edi+3],al | ||
453 | add edi,4 | ||
454 | rep stosb | ||
455 | |||
456 | jmp L_while_test | ||
457 | |||
458 | ALIGN 4 | ||
459 | L_test_for_second_level_length: | ||
460 | |||
461 | |||
462 | |||
463 | |||
464 | test al,64 | ||
465 | jnz L_test_for_end_of_block | ||
466 | |||
467 | mov eax,1 | ||
468 | shl eax,cl | ||
469 | dec eax | ||
470 | and eax,ebp | ||
471 | add eax,edx | ||
472 | mov edx, [esp+8] | ||
473 | mov eax, [edx+eax*4] | ||
474 | jmp L_dolen | ||
475 | |||
476 | ALIGN 4 | ||
477 | L_test_for_second_level_dist: | ||
478 | |||
479 | |||
480 | |||
481 | |||
482 | test al,64 | ||
483 | jnz L_invalid_distance_code | ||
484 | |||
485 | mov eax,1 | ||
486 | shl eax,cl | ||
487 | dec eax | ||
488 | and eax,ebp | ||
489 | add eax,edx | ||
490 | mov edx, [esp+12] | ||
491 | mov eax, [edx+eax*4] | ||
492 | jmp L_dodist | ||
493 | |||
494 | ALIGN 4 | ||
495 | L_clip_window: | ||
496 | ; 721 "inffast.S" | ||
497 | mov ecx,eax | ||
498 | mov eax, [esp+52] | ||
499 | neg ecx | ||
500 | mov esi, [esp+56] | ||
501 | |||
502 | cmp eax,edx | ||
503 | jb L_invalid_distance_too_far | ||
504 | |||
505 | add ecx,edx | ||
506 | cmp dword ptr [esp+48],0 | ||
507 | jne L_wrap_around_window | ||
508 | |||
509 | sub eax,ecx | ||
510 | add esi,eax | ||
511 | ; 749 "inffast.S" | ||
512 | mov eax, [esp+24] | ||
513 | cmp eax,ecx | ||
514 | jbe L_do_copy1 | ||
515 | |||
516 | sub eax,ecx | ||
517 | rep movsb | ||
518 | mov esi,edi | ||
519 | sub esi,edx | ||
520 | jmp L_do_copy1 | ||
521 | |||
522 | cmp eax,ecx | ||
523 | jbe L_do_copy1 | ||
524 | |||
525 | sub eax,ecx | ||
526 | rep movsb | ||
527 | mov esi,edi | ||
528 | sub esi,edx | ||
529 | jmp L_do_copy1 | ||
530 | |||
531 | L_wrap_around_window: | ||
532 | ; 793 "inffast.S" | ||
533 | mov eax, [esp+48] | ||
534 | cmp ecx,eax | ||
535 | jbe L_contiguous_in_window | ||
536 | |||
537 | add esi, [esp+52] | ||
538 | add esi,eax | ||
539 | sub esi,ecx | ||
540 | sub ecx,eax | ||
541 | |||
542 | |||
543 | mov eax, [esp+24] | ||
544 | cmp eax,ecx | ||
545 | jbe L_do_copy1 | ||
546 | |||
547 | sub eax,ecx | ||
548 | rep movsb | ||
549 | mov esi, [esp+56] | ||
550 | mov ecx, [esp+48] | ||
551 | cmp eax,ecx | ||
552 | jbe L_do_copy1 | ||
553 | |||
554 | sub eax,ecx | ||
555 | rep movsb | ||
556 | mov esi,edi | ||
557 | sub esi,edx | ||
558 | jmp L_do_copy1 | ||
559 | |||
560 | L_contiguous_in_window: | ||
561 | ; 836 "inffast.S" | ||
562 | add esi,eax | ||
563 | sub esi,ecx | ||
564 | |||
565 | |||
566 | mov eax, [esp+24] | ||
567 | cmp eax,ecx | ||
568 | jbe L_do_copy1 | ||
569 | |||
570 | sub eax,ecx | ||
571 | rep movsb | ||
572 | mov esi,edi | ||
573 | sub esi,edx | ||
574 | |||
575 | L_do_copy1: | ||
576 | ; 862 "inffast.S" | ||
577 | mov ecx,eax | ||
578 | rep movsb | ||
579 | |||
580 | mov esi, [esp+44] | ||
581 | jmp L_while_test | ||
582 | ; 878 "inffast.S" | ||
583 | ALIGN 4 | ||
584 | L_init_mmx: | ||
585 | emms | ||
586 | |||
587 | |||
588 | |||
589 | |||
590 | |||
591 | movd mm0,ebp | ||
592 | mov ebp,ebx | ||
593 | ; 896 "inffast.S" | ||
594 | movd mm4,[esp+0] | ||
595 | movq mm3,mm4 | ||
596 | movd mm5,[esp+4] | ||
597 | movq mm2,mm5 | ||
598 | pxor mm1,mm1 | ||
599 | mov ebx, [esp+8] | ||
600 | jmp L_do_loop_mmx | ||
601 | |||
602 | ALIGN 4 | ||
603 | L_do_loop_mmx: | ||
604 | psrlq mm0,mm1 | ||
605 | |||
606 | cmp ebp,32 | ||
607 | ja L_get_length_code_mmx | ||
608 | |||
609 | movd mm6,ebp | ||
610 | movd mm7,[esi] | ||
611 | add esi,4 | ||
612 | psllq mm7,mm6 | ||
613 | add ebp,32 | ||
614 | por mm0,mm7 | ||
615 | |||
616 | L_get_length_code_mmx: | ||
617 | pand mm4,mm0 | ||
618 | movd eax,mm4 | ||
619 | movq mm4,mm3 | ||
620 | mov eax, [ebx+eax*4] | ||
621 | |||
622 | L_dolen_mmx: | ||
623 | movzx ecx,ah | ||
624 | movd mm1,ecx | ||
625 | sub ebp,ecx | ||
626 | |||
627 | test al,al | ||
628 | jnz L_test_for_length_base_mmx | ||
629 | |||
630 | shr eax,16 | ||
631 | stosb | ||
632 | |||
633 | L_while_test_mmx: | ||
634 | |||
635 | |||
636 | cmp [esp+16],edi | ||
637 | jbe L_break_loop | ||
638 | |||
639 | cmp [esp+20],esi | ||
640 | ja L_do_loop_mmx | ||
641 | jmp L_break_loop | ||
642 | |||
643 | L_test_for_length_base_mmx: | ||
644 | |||
645 | mov edx,eax | ||
646 | shr edx,16 | ||
647 | |||
648 | test al,16 | ||
649 | jz L_test_for_second_level_length_mmx | ||
650 | and eax,15 | ||
651 | jz L_decode_distance_mmx | ||
652 | |||
653 | psrlq mm0,mm1 | ||
654 | movd mm1,eax | ||
655 | movd ecx,mm0 | ||
656 | sub ebp,eax | ||
657 | and ecx, [inflate_fast_mask+eax*4] | ||
658 | add edx,ecx | ||
659 | |||
660 | L_decode_distance_mmx: | ||
661 | psrlq mm0,mm1 | ||
662 | |||
663 | cmp ebp,32 | ||
664 | ja L_get_dist_code_mmx | ||
665 | |||
666 | movd mm6,ebp | ||
667 | movd mm7,[esi] | ||
668 | add esi,4 | ||
669 | psllq mm7,mm6 | ||
670 | add ebp,32 | ||
671 | por mm0,mm7 | ||
672 | |||
673 | L_get_dist_code_mmx: | ||
674 | mov ebx, [esp+12] | ||
675 | pand mm5,mm0 | ||
676 | movd eax,mm5 | ||
677 | movq mm5,mm2 | ||
678 | mov eax, [ebx+eax*4] | ||
679 | |||
680 | L_dodist_mmx: | ||
681 | |||
682 | movzx ecx,ah | ||
683 | mov ebx,eax | ||
684 | shr ebx,16 | ||
685 | sub ebp,ecx | ||
686 | movd mm1,ecx | ||
687 | |||
688 | test al,16 | ||
689 | jz L_test_for_second_level_dist_mmx | ||
690 | and eax,15 | ||
691 | jz L_check_dist_one_mmx | ||
692 | |||
693 | L_add_bits_to_dist_mmx: | ||
694 | psrlq mm0,mm1 | ||
695 | movd mm1,eax | ||
696 | movd ecx,mm0 | ||
697 | sub ebp,eax | ||
698 | and ecx, [inflate_fast_mask+eax*4] | ||
699 | add ebx,ecx | ||
700 | |||
701 | L_check_window_mmx: | ||
702 | mov [esp+44],esi | ||
703 | mov eax,edi | ||
704 | sub eax, [esp+40] | ||
705 | |||
706 | cmp eax,ebx | ||
707 | jb L_clip_window_mmx | ||
708 | |||
709 | mov ecx,edx | ||
710 | mov esi,edi | ||
711 | sub esi,ebx | ||
712 | |||
713 | sub ecx,3 | ||
714 | mov al, [esi] | ||
715 | mov [edi],al | ||
716 | mov al, [esi+1] | ||
717 | mov dl, [esi+2] | ||
718 | add esi,3 | ||
719 | mov [edi+1],al | ||
720 | mov [edi+2],dl | ||
721 | add edi,3 | ||
722 | rep movsb | ||
723 | |||
724 | mov esi, [esp+44] | ||
725 | mov ebx, [esp+8] | ||
726 | jmp L_while_test_mmx | ||
727 | |||
728 | ALIGN 4 | ||
729 | L_check_dist_one_mmx: | ||
730 | cmp ebx,1 | ||
731 | jne L_check_window_mmx | ||
732 | cmp [esp+40],edi | ||
733 | je L_check_window_mmx | ||
734 | |||
735 | dec edi | ||
736 | mov ecx,edx | ||
737 | mov al, [edi] | ||
738 | sub ecx,3 | ||
739 | |||
740 | mov [edi+1],al | ||
741 | mov [edi+2],al | ||
742 | mov [edi+3],al | ||
743 | add edi,4 | ||
744 | rep stosb | ||
745 | |||
746 | mov ebx, [esp+8] | ||
747 | jmp L_while_test_mmx | ||
748 | |||
749 | ALIGN 4 | ||
750 | L_test_for_second_level_length_mmx: | ||
751 | test al,64 | ||
752 | jnz L_test_for_end_of_block | ||
753 | |||
754 | and eax,15 | ||
755 | psrlq mm0,mm1 | ||
756 | movd ecx,mm0 | ||
757 | and ecx, [inflate_fast_mask+eax*4] | ||
758 | add ecx,edx | ||
759 | mov eax, [ebx+ecx*4] | ||
760 | jmp L_dolen_mmx | ||
761 | |||
762 | ALIGN 4 | ||
763 | L_test_for_second_level_dist_mmx: | ||
764 | test al,64 | ||
765 | jnz L_invalid_distance_code | ||
766 | |||
767 | and eax,15 | ||
768 | psrlq mm0,mm1 | ||
769 | movd ecx,mm0 | ||
770 | and ecx, [inflate_fast_mask+eax*4] | ||
771 | mov eax, [esp+12] | ||
772 | add ecx,ebx | ||
773 | mov eax, [eax+ecx*4] | ||
774 | jmp L_dodist_mmx | ||
775 | |||
776 | ALIGN 4 | ||
777 | L_clip_window_mmx: | ||
778 | |||
779 | mov ecx,eax | ||
780 | mov eax, [esp+52] | ||
781 | neg ecx | ||
782 | mov esi, [esp+56] | ||
783 | |||
784 | cmp eax,ebx | ||
785 | jb L_invalid_distance_too_far | ||
786 | |||
787 | add ecx,ebx | ||
788 | cmp dword ptr [esp+48],0 | ||
789 | jne L_wrap_around_window_mmx | ||
790 | |||
791 | sub eax,ecx | ||
792 | add esi,eax | ||
793 | |||
794 | cmp edx,ecx | ||
795 | jbe L_do_copy1_mmx | ||
796 | |||
797 | sub edx,ecx | ||
798 | rep movsb | ||
799 | mov esi,edi | ||
800 | sub esi,ebx | ||
801 | jmp L_do_copy1_mmx | ||
802 | |||
803 | cmp edx,ecx | ||
804 | jbe L_do_copy1_mmx | ||
805 | |||
806 | sub edx,ecx | ||
807 | rep movsb | ||
808 | mov esi,edi | ||
809 | sub esi,ebx | ||
810 | jmp L_do_copy1_mmx | ||
811 | |||
812 | L_wrap_around_window_mmx: | ||
813 | |||
814 | mov eax, [esp+48] | ||
815 | cmp ecx,eax | ||
816 | jbe L_contiguous_in_window_mmx | ||
817 | |||
818 | add esi, [esp+52] | ||
819 | add esi,eax | ||
820 | sub esi,ecx | ||
821 | sub ecx,eax | ||
822 | |||
823 | |||
824 | cmp edx,ecx | ||
825 | jbe L_do_copy1_mmx | ||
826 | |||
827 | sub edx,ecx | ||
828 | rep movsb | ||
829 | mov esi, [esp+56] | ||
830 | mov ecx, [esp+48] | ||
831 | cmp edx,ecx | ||
832 | jbe L_do_copy1_mmx | ||
833 | |||
834 | sub edx,ecx | ||
835 | rep movsb | ||
836 | mov esi,edi | ||
837 | sub esi,ebx | ||
838 | jmp L_do_copy1_mmx | ||
839 | |||
840 | L_contiguous_in_window_mmx: | ||
841 | |||
842 | add esi,eax | ||
843 | sub esi,ecx | ||
844 | |||
845 | |||
846 | cmp edx,ecx | ||
847 | jbe L_do_copy1_mmx | ||
848 | |||
849 | sub edx,ecx | ||
850 | rep movsb | ||
851 | mov esi,edi | ||
852 | sub esi,ebx | ||
853 | |||
854 | L_do_copy1_mmx: | ||
855 | |||
856 | |||
857 | mov ecx,edx | ||
858 | rep movsb | ||
859 | |||
860 | mov esi, [esp+44] | ||
861 | mov ebx, [esp+8] | ||
862 | jmp L_while_test_mmx | ||
863 | ; 1174 "inffast.S" | ||
864 | L_invalid_distance_code: | ||
865 | |||
866 | |||
867 | |||
868 | |||
869 | |||
870 | mov ecx, invalid_distance_code_msg | ||
871 | mov edx,26 | ||
872 | jmp L_update_stream_state | ||
873 | |||
874 | L_test_for_end_of_block: | ||
875 | |||
876 | |||
877 | |||
878 | |||
879 | |||
880 | test al,32 | ||
881 | jz L_invalid_literal_length_code | ||
882 | |||
883 | mov ecx,0 | ||
884 | mov edx,11 | ||
885 | jmp L_update_stream_state | ||
886 | |||
887 | L_invalid_literal_length_code: | ||
888 | |||
889 | |||
890 | |||
891 | |||
892 | |||
893 | mov ecx, invalid_literal_length_code_msg | ||
894 | mov edx,26 | ||
895 | jmp L_update_stream_state | ||
896 | |||
897 | L_invalid_distance_too_far: | ||
898 | |||
899 | |||
900 | |||
901 | mov esi, [esp+44] | ||
902 | mov ecx, invalid_distance_too_far_msg | ||
903 | mov edx,26 | ||
904 | jmp L_update_stream_state | ||
905 | |||
906 | L_update_stream_state: | ||
907 | |||
908 | mov eax, [esp+88] | ||
909 | test ecx,ecx | ||
910 | jz L_skip_msg | ||
911 | mov [eax+24],ecx | ||
912 | L_skip_msg: | ||
913 | mov eax, [eax+28] | ||
914 | mov [eax+mode_state],edx | ||
915 | jmp L_break_loop | ||
916 | |||
917 | ALIGN 4 | ||
918 | L_break_loop: | ||
919 | ; 1243 "inffast.S" | ||
920 | cmp dword ptr [inflate_fast_use_mmx],2 | ||
921 | jne L_update_next_in | ||
922 | |||
923 | |||
924 | |||
925 | mov ebx,ebp | ||
926 | |||
927 | L_update_next_in: | ||
928 | ; 1266 "inffast.S" | ||
929 | mov eax, [esp+88] | ||
930 | mov ecx,ebx | ||
931 | mov edx, [eax+28] | ||
932 | shr ecx,3 | ||
933 | sub esi,ecx | ||
934 | shl ecx,3 | ||
935 | sub ebx,ecx | ||
936 | mov [eax+12],edi | ||
937 | mov [edx+bits_state],ebx | ||
938 | mov ecx,ebx | ||
939 | |||
940 | lea ebx, [esp+28] | ||
941 | cmp [esp+20],ebx | ||
942 | jne L_buf_not_used | ||
943 | |||
944 | sub esi,ebx | ||
945 | mov ebx, [eax+0] | ||
946 | mov [esp+20],ebx | ||
947 | add esi,ebx | ||
948 | mov ebx, [eax+4] | ||
949 | sub ebx,11 | ||
950 | add [esp+20],ebx | ||
951 | |||
952 | L_buf_not_used: | ||
953 | mov [eax+0],esi | ||
954 | |||
955 | mov ebx,1 | ||
956 | shl ebx,cl | ||
957 | dec ebx | ||
958 | |||
959 | |||
960 | |||
961 | |||
962 | |||
963 | cmp dword ptr [inflate_fast_use_mmx],2 | ||
964 | jne L_update_hold | ||
965 | |||
966 | |||
967 | |||
968 | psrlq mm0,mm1 | ||
969 | movd ebp,mm0 | ||
970 | |||
971 | emms | ||
972 | |||
973 | L_update_hold: | ||
974 | |||
975 | |||
976 | |||
977 | and ebp,ebx | ||
978 | mov [edx+hold_state],ebp | ||
979 | |||
980 | |||
981 | |||
982 | |||
983 | mov ebx, [esp+20] | ||
984 | cmp ebx,esi | ||
985 | jbe L_last_is_smaller | ||
986 | |||
987 | sub ebx,esi | ||
988 | add ebx,11 | ||
989 | mov [eax+4],ebx | ||
990 | jmp L_fixup_out | ||
991 | L_last_is_smaller: | ||
992 | sub esi,ebx | ||
993 | neg esi | ||
994 | add esi,11 | ||
995 | mov [eax+4],esi | ||
996 | |||
997 | |||
998 | |||
999 | |||
1000 | L_fixup_out: | ||
1001 | |||
1002 | mov ebx, [esp+16] | ||
1003 | cmp ebx,edi | ||
1004 | jbe L_end_is_smaller | ||
1005 | |||
1006 | sub ebx,edi | ||
1007 | add ebx,257 | ||
1008 | mov [eax+16],ebx | ||
1009 | jmp L_done | ||
1010 | L_end_is_smaller: | ||
1011 | sub edi,ebx | ||
1012 | neg edi | ||
1013 | add edi,257 | ||
1014 | mov [eax+16],edi | ||
1015 | |||
1016 | |||
1017 | |||
1018 | |||
1019 | |||
1020 | L_done: | ||
1021 | add esp,64 | ||
1022 | popfd | ||
1023 | pop ebx | ||
1024 | pop ebp | ||
1025 | pop esi | ||
1026 | pop edi | ||
1027 | ret | ||
1028 | |||
1029 | |||
1030 | |||
1031 | |||
1032 | _TEXT ends | ||
1033 | end | ||
diff --git a/contrib/masmx86/mkasm.bat b/contrib/masmx86/mkasm.bat new file mode 100755 index 0000000..f3fa0a0 --- /dev/null +++ b/contrib/masmx86/mkasm.bat | |||
@@ -0,0 +1,3 @@ | |||
1 | cl /I..\.. /O2 /c gvmat32c.c | ||
2 | ml /coff /Zi /c /Flgvmat32.lst gvmat32.asm | ||
3 | ml /coff /Zi /c /Flinffas32.lst inffas32.asm | ||
diff --git a/contrib/masmx86/readme.txt b/contrib/masmx86/readme.txt new file mode 100644 index 0000000..7b57167 --- /dev/null +++ b/contrib/masmx86/readme.txt | |||
@@ -0,0 +1,21 @@ | |||
1 | |||
2 | Summary | ||
3 | ------- | ||
4 | This directory contains ASM implementations of the functions | ||
5 | longest_match() and inflate_fast(). | ||
6 | |||
7 | |||
8 | Use instructions | ||
9 | ---------------- | ||
10 | Copy these files into the zlib source directory, then run the | ||
11 | appropriate makefile, as suggested below. | ||
12 | |||
13 | |||
14 | Build instructions | ||
15 | ------------------ | ||
16 | * With Microsoft C and MASM: | ||
17 | nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="gvmat32c.obj gvmat32.obj inffas32.obj" | ||
18 | |||
19 | * With Borland C and TASM: | ||
20 | make -f win32/Makefile.bor LOCAL_ZLIB="-DASMV -DASMINF" OBJA="gvmat32c.obj gvmat32.obj inffas32.obj" OBJPA="+gvmat32c.obj+gvmat32.obj+inffas32.obj" | ||
21 | |||
diff --git a/contrib/minizip/ChangeLogUnzip b/contrib/minizip/ChangeLogUnzip index 45fd099..cfabd61 100644 --- a/contrib/minizip/ChangeLogUnzip +++ b/contrib/minizip/ChangeLogUnzip | |||
@@ -1,51 +1,51 @@ | |||
1 | Change in 0.22: (19 May 03) | 1 | Change in 0.22: (19 May 03) |
2 | - crypting support (unless you define NOCRYPT) | 2 | - crypting support (unless you define NOCRYPT) |
3 | - append file in existing zipfile | 3 | - append file in existing zipfile |
4 | 4 | ||
5 | Change in 0.21: (10 Mar 03) | 5 | Change in 0.21: (10 Mar 03) |
6 | - bug fixes | 6 | - bug fixes |
7 | 7 | ||
8 | Change in 0.17: (27 Jan 02) | 8 | Change in 0.17: (27 Jan 02) |
9 | - bug fixes | 9 | - bug fixes |
10 | 10 | ||
11 | Change in 0.16: (19 Jan 02) | 11 | Change in 0.16: (19 Jan 02) |
12 | - Support of ioapi for virtualize zip file access | 12 | - Support of ioapi for virtualize zip file access |
13 | 13 | ||
14 | Change in 0.15: (19 Mar 98) | 14 | Change in 0.15: (19 Mar 98) |
15 | - fix memory leak in minizip.c | 15 | - fix memory leak in minizip.c |
16 | 16 | ||
17 | Change in 0.14: (10 Mar 98) | 17 | Change in 0.14: (10 Mar 98) |
18 | - fix bugs in minizip.c sample for zipping big file | 18 | - fix bugs in minizip.c sample for zipping big file |
19 | - fix problem in month in date handling | 19 | - fix problem in month in date handling |
20 | - fix bug in unzlocal_GetCurrentFileInfoInternal in unzip.c for | 20 | - fix bug in unzlocal_GetCurrentFileInfoInternal in unzip.c for |
21 | comment handling | 21 | comment handling |
22 | 22 | ||
23 | Change in 0.13: (6 Mar 98) | 23 | Change in 0.13: (6 Mar 98) |
24 | - fix bugs in zip.c | 24 | - fix bugs in zip.c |
25 | - add real minizip sample | 25 | - add real minizip sample |
26 | 26 | ||
27 | Change in 0.12: (4 Mar 98) | 27 | Change in 0.12: (4 Mar 98) |
28 | - add zip.c and zip.h for creates .zip file | 28 | - add zip.c and zip.h for creates .zip file |
29 | - fix change_file_date in miniunz.c for Unix (Jean-loup Gailly) | 29 | - fix change_file_date in miniunz.c for Unix (Jean-loup Gailly) |
30 | - fix miniunz.c for file without specific record for directory | 30 | - fix miniunz.c for file without specific record for directory |
31 | 31 | ||
32 | Change in 0.11: (3 Mar 98) | 32 | Change in 0.11: (3 Mar 98) |
33 | - fix bug in unzGetCurrentFileInfo for get extra field and comment | 33 | - fix bug in unzGetCurrentFileInfo for get extra field and comment |
34 | - enhance miniunz sample, remove the bad unztst.c sample | 34 | - enhance miniunz sample, remove the bad unztst.c sample |
35 | 35 | ||
36 | Change in 0.10: (2 Mar 98) | 36 | Change in 0.10: (2 Mar 98) |
37 | - fix bug in unzReadCurrentFile | 37 | - fix bug in unzReadCurrentFile |
38 | - rename unzip* to unz* function and structure | 38 | - rename unzip* to unz* function and structure |
39 | - remove Windows-like hungary notation variable name | 39 | - remove Windows-like hungary notation variable name |
40 | - modify some structure in unzip.h | 40 | - modify some structure in unzip.h |
41 | - add somes comment in source | 41 | - add somes comment in source |
42 | - remove unzipGetcCurrentFile function | 42 | - remove unzipGetcCurrentFile function |
43 | - replace ZUNZEXPORT by ZEXPORT | 43 | - replace ZUNZEXPORT by ZEXPORT |
44 | - add unzGetLocalExtrafield for get the local extrafield info | 44 | - add unzGetLocalExtrafield for get the local extrafield info |
45 | - add a new sample, miniunz.c | 45 | - add a new sample, miniunz.c |
46 | 46 | ||
47 | Change in 0.4: (25 Feb 98) | 47 | Change in 0.4: (25 Feb 98) |
48 | - suppress the type unzipFileInZip. | 48 | - suppress the type unzipFileInZip. |
49 | Only on file in the zipfile can be open at the same time | 49 | Only on file in the zipfile can be open at the same time |
50 | - fix somes typo in code | 50 | - fix somes typo in code |
51 | - added tm_unz structure in unzip_file_info (date/time in readable format) | 51 | - added tm_unz structure in unzip_file_info (date/time in readable format) |
diff --git a/contrib/minizip/Makefile b/contrib/minizip/Makefile index fbba3ac..84eaad2 100644 --- a/contrib/minizip/Makefile +++ b/contrib/minizip/Makefile | |||
@@ -1,25 +1,25 @@ | |||
1 | CC=cc | 1 | CC=cc |
2 | CFLAGS=-O -I../.. | 2 | CFLAGS=-O -I../.. |
3 | 3 | ||
4 | UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a | 4 | UNZ_OBJS = miniunz.o unzip.o ioapi.o ../../libz.a |
5 | ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a | 5 | ZIP_OBJS = minizip.o zip.o ioapi.o ../../libz.a |
6 | 6 | ||
7 | .c.o: | 7 | .c.o: |
8 | $(CC) -c $(CFLAGS) $*.c | 8 | $(CC) -c $(CFLAGS) $*.c |
9 | 9 | ||
10 | all: miniunz minizip | 10 | all: miniunz minizip |
11 | 11 | ||
12 | miniunz: $(UNZ_OBJS) | 12 | miniunz: $(UNZ_OBJS) |
13 | $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS) | 13 | $(CC) $(CFLAGS) -o $@ $(UNZ_OBJS) |
14 | 14 | ||
15 | minizip: $(ZIP_OBJS) | 15 | minizip: $(ZIP_OBJS) |
16 | $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS) | 16 | $(CC) $(CFLAGS) -o $@ $(ZIP_OBJS) |
17 | 17 | ||
18 | test: miniunz minizip | 18 | test: miniunz minizip |
19 | ./minizip test readme.txt | 19 | ./minizip test readme.txt |
20 | ./miniunz -l test.zip | 20 | ./miniunz -l test.zip |
21 | mv readme.txt readme.old | 21 | mv readme.txt readme.old |
22 | ./miniunz test.zip | 22 | ./miniunz test.zip |
23 | 23 | ||
24 | clean: | 24 | clean: |
25 | /bin/rm -f *.o *~ minizip miniunz | 25 | /bin/rm -f *.o *~ minizip miniunz |
diff --git a/contrib/minizip/crypt.h b/contrib/minizip/crypt.h index 83e763c..a02bf0b 100644 --- a/contrib/minizip/crypt.h +++ b/contrib/minizip/crypt.h | |||
@@ -1,104 +1,104 @@ | |||
1 | 1 | ||
2 | #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) | 2 | #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) |
3 | 3 | ||
4 | /*********************************************************************** | 4 | /*********************************************************************** |
5 | * Return the next byte in the pseudo-random sequence | 5 | * Return the next byte in the pseudo-random sequence |
6 | */ | 6 | */ |
7 | static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) | 7 | static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) |
8 | { | 8 | { |
9 | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an | 9 | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an |
10 | * unpredictable manner on 16-bit systems; not a problem | 10 | * unpredictable manner on 16-bit systems; not a problem |
11 | * with any known compiler so far, though */ | 11 | * with any known compiler so far, though */ |
12 | 12 | ||
13 | temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; | 13 | temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; |
14 | return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); | 14 | return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); |
15 | } | 15 | } |
16 | 16 | ||
17 | /*********************************************************************** | 17 | /*********************************************************************** |
18 | * Update the encryption keys with the next byte of plain text | 18 | * Update the encryption keys with the next byte of plain text |
19 | */ | 19 | */ |
20 | static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) | 20 | static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) |
21 | { | 21 | { |
22 | (*(pkeys+0)) = CRC32((*(pkeys+0)), c); | 22 | (*(pkeys+0)) = CRC32((*(pkeys+0)), c); |
23 | (*(pkeys+1)) += (*(pkeys+0)) & 0xff; | 23 | (*(pkeys+1)) += (*(pkeys+0)) & 0xff; |
24 | (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; | 24 | (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; |
25 | { | 25 | { |
26 | register int keyshift = (int)((*(pkeys+1)) >> 24); | 26 | register int keyshift = (int)((*(pkeys+1)) >> 24); |
27 | (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); | 27 | (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); |
28 | } | 28 | } |
29 | return c; | 29 | return c; |
30 | } | 30 | } |
31 | 31 | ||
32 | 32 | ||
33 | /*********************************************************************** | 33 | /*********************************************************************** |
34 | * Initialize the encryption keys and the random header according to | 34 | * Initialize the encryption keys and the random header according to |
35 | * the given password. | 35 | * the given password. |
36 | */ | 36 | */ |
37 | static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) | 37 | static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) |
38 | { | 38 | { |
39 | *(pkeys+0) = 305419896L; | 39 | *(pkeys+0) = 305419896L; |
40 | *(pkeys+1) = 591751049L; | 40 | *(pkeys+1) = 591751049L; |
41 | *(pkeys+2) = 878082192L; | 41 | *(pkeys+2) = 878082192L; |
42 | while (*passwd != '\0') { | 42 | while (*passwd != '\0') { |
43 | update_keys(pkeys,pcrc_32_tab,(int)*passwd); | 43 | update_keys(pkeys,pcrc_32_tab,(int)*passwd); |
44 | passwd++; | 44 | passwd++; |
45 | } | 45 | } |
46 | } | 46 | } |
47 | 47 | ||
48 | #define zdecode(pkeys,pcrc_32_tab,c) \ | 48 | #define zdecode(pkeys,pcrc_32_tab,c) \ |
49 | (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) | 49 | (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) |
50 | 50 | ||
51 | #define zencode(pkeys,pcrc_32_tab,c,t) \ | 51 | #define zencode(pkeys,pcrc_32_tab,c,t) \ |
52 | (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) | 52 | (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) |
53 | 53 | ||
54 | #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED | 54 | #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED |
55 | 55 | ||
56 | #define RAND_HEAD_LEN 12 | 56 | #define RAND_HEAD_LEN 12 |
57 | /* "last resort" source for second part of crypt seed pattern */ | 57 | /* "last resort" source for second part of crypt seed pattern */ |
58 | # ifndef ZCR_SEED2 | 58 | # ifndef ZCR_SEED2 |
59 | # define ZCR_SEED2 (unsigned long)3141592654L /* use PI as default pattern */ | 59 | # define ZCR_SEED2 3141592654UL /* use PI as default pattern */ |
60 | # endif | 60 | # endif |
61 | 61 | ||
62 | static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) | 62 | static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) |
63 | const char *passwd; /* password string */ | 63 | const char *passwd; /* password string */ |
64 | unsigned char *buf; /* where to write header */ | 64 | unsigned char *buf; /* where to write header */ |
65 | int bufSize; | 65 | int bufSize; |
66 | unsigned long* pkeys; | 66 | unsigned long* pkeys; |
67 | const unsigned long* pcrc_32_tab; | 67 | const unsigned long* pcrc_32_tab; |
68 | unsigned long crcForCrypting; | 68 | unsigned long crcForCrypting; |
69 | { | 69 | { |
70 | int n; /* index in random header */ | 70 | int n; /* index in random header */ |
71 | int t; /* temporary */ | 71 | int t; /* temporary */ |
72 | int c; /* random byte */ | 72 | int c; /* random byte */ |
73 | unsigned char header[RAND_HEAD_LEN-2]; /* random header */ | 73 | unsigned char header[RAND_HEAD_LEN-2]; /* random header */ |
74 | static unsigned calls = 0; /* ensure different random header each time */ | 74 | static unsigned calls = 0; /* ensure different random header each time */ |
75 | 75 | ||
76 | if (bufSize<RAND_HEAD_LEN) | 76 | if (bufSize<RAND_HEAD_LEN) |
77 | return 0; | 77 | return 0; |
78 | 78 | ||
79 | /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the | 79 | /* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the |
80 | * output of rand() to get less predictability, since rand() is | 80 | * output of rand() to get less predictability, since rand() is |
81 | * often poorly implemented. | 81 | * often poorly implemented. |
82 | */ | 82 | */ |
83 | if (++calls == 1) | 83 | if (++calls == 1) |
84 | { | 84 | { |
85 | srand((unsigned)(time(NULL) ^ ZCR_SEED2)); | 85 | srand((unsigned)(time(NULL) ^ ZCR_SEED2)); |
86 | } | 86 | } |
87 | init_keys(passwd, pkeys, pcrc_32_tab); | 87 | init_keys(passwd, pkeys, pcrc_32_tab); |
88 | for (n = 0; n < RAND_HEAD_LEN-2; n++) | 88 | for (n = 0; n < RAND_HEAD_LEN-2; n++) |
89 | { | 89 | { |
90 | c = (rand() >> 7) & 0xff; | 90 | c = (rand() >> 7) & 0xff; |
91 | header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); | 91 | header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); |
92 | } | 92 | } |
93 | /* Encrypt random header (last two bytes is high word of crc) */ | 93 | /* Encrypt random header (last two bytes is high word of crc) */ |
94 | init_keys(passwd, pkeys, pcrc_32_tab); | 94 | init_keys(passwd, pkeys, pcrc_32_tab); |
95 | for (n = 0; n < RAND_HEAD_LEN-2; n++) | 95 | for (n = 0; n < RAND_HEAD_LEN-2; n++) |
96 | { | 96 | { |
97 | buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); | 97 | buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); |
98 | } | 98 | } |
99 | buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); | 99 | buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); |
100 | buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); | 100 | buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); |
101 | return n; | 101 | return n; |
102 | } | 102 | } |
103 | 103 | ||
104 | #endif | 104 | #endif |
diff --git a/contrib/minizip/ioapi.c b/contrib/minizip/ioapi.c index 61c6e2b..ea9ee30 100644 --- a/contrib/minizip/ioapi.c +++ b/contrib/minizip/ioapi.c | |||
@@ -1,177 +1,177 @@ | |||
1 | /* ioapi.c -- IO base function header for compress/uncompress .zip | 1 | /* ioapi.c -- IO base function header for compress/uncompress .zip |
2 | files using zlib + zip or unzip API | 2 | files using zlib + zip or unzip API |
3 | 3 | ||
4 | Version 0.22, May 19th, 2003 | 4 | Version 0.22, May 19th, 2003 |
5 | 5 | ||
6 | Copyright (C) 1998-2003 Gilles Vollant | 6 | Copyright (C) 1998-2003 Gilles Vollant |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include <stdio.h> | 9 | #include <stdio.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <string.h> | 11 | #include <string.h> |
12 | 12 | ||
13 | #include "zlib.h" | 13 | #include "zlib.h" |
14 | #include "ioapi.h" | 14 | #include "ioapi.h" |
15 | 15 | ||
16 | 16 | ||
17 | 17 | ||
18 | /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ | 18 | /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ |
19 | 19 | ||
20 | #ifndef SEEK_CUR | 20 | #ifndef SEEK_CUR |
21 | #define SEEK_CUR 1 | 21 | #define SEEK_CUR 1 |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #ifndef SEEK_END | 24 | #ifndef SEEK_END |
25 | #define SEEK_END 2 | 25 | #define SEEK_END 2 |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | #ifndef SEEK_SET | 28 | #ifndef SEEK_SET |
29 | #define SEEK_SET 0 | 29 | #define SEEK_SET 0 |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | voidpf ZCALLBACK fopen_file_func OF(( | 32 | voidpf ZCALLBACK fopen_file_func OF(( |
33 | voidpf opaque, | 33 | voidpf opaque, |
34 | const char* filename, | 34 | const char* filename, |
35 | int mode)); | 35 | int mode)); |
36 | 36 | ||
37 | uLong ZCALLBACK fread_file_func OF(( | 37 | uLong ZCALLBACK fread_file_func OF(( |
38 | voidpf opaque, | 38 | voidpf opaque, |
39 | voidpf stream, | 39 | voidpf stream, |
40 | void* buf, | 40 | void* buf, |
41 | uLong size)); | 41 | uLong size)); |
42 | 42 | ||
43 | uLong ZCALLBACK fwrite_file_func OF(( | 43 | uLong ZCALLBACK fwrite_file_func OF(( |
44 | voidpf opaque, | 44 | voidpf opaque, |
45 | voidpf stream, | 45 | voidpf stream, |
46 | const void* buf, | 46 | const void* buf, |
47 | uLong size)); | 47 | uLong size)); |
48 | 48 | ||
49 | long ZCALLBACK ftell_file_func OF(( | 49 | long ZCALLBACK ftell_file_func OF(( |
50 | voidpf opaque, | 50 | voidpf opaque, |
51 | voidpf stream)); | 51 | voidpf stream)); |
52 | 52 | ||
53 | long ZCALLBACK fseek_file_func OF(( | 53 | long ZCALLBACK fseek_file_func OF(( |
54 | voidpf opaque, | 54 | voidpf opaque, |
55 | voidpf stream, | 55 | voidpf stream, |
56 | uLong offset, | 56 | uLong offset, |
57 | int origin)); | 57 | int origin)); |
58 | 58 | ||
59 | int ZCALLBACK fclose_file_func OF(( | 59 | int ZCALLBACK fclose_file_func OF(( |
60 | voidpf opaque, | 60 | voidpf opaque, |
61 | voidpf stream)); | 61 | voidpf stream)); |
62 | 62 | ||
63 | int ZCALLBACK ferror_file_func OF(( | 63 | int ZCALLBACK ferror_file_func OF(( |
64 | voidpf opaque, | 64 | voidpf opaque, |
65 | voidpf stream)); | 65 | voidpf stream)); |
66 | 66 | ||
67 | 67 | ||
68 | voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) | 68 | voidpf ZCALLBACK fopen_file_func (opaque, filename, mode) |
69 | voidpf opaque; | 69 | voidpf opaque; |
70 | const char* filename; | 70 | const char* filename; |
71 | int mode; | 71 | int mode; |
72 | { | 72 | { |
73 | FILE* file = NULL; | 73 | FILE* file = NULL; |
74 | const char* mode_fopen = NULL; | 74 | const char* mode_fopen = NULL; |
75 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) | 75 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) |
76 | mode_fopen = "rb"; | 76 | mode_fopen = "rb"; |
77 | else | 77 | else |
78 | if (mode & ZLIB_FILEFUNC_MODE_EXISTING) | 78 | if (mode & ZLIB_FILEFUNC_MODE_EXISTING) |
79 | mode_fopen = "r+b"; | 79 | mode_fopen = "r+b"; |
80 | else | 80 | else |
81 | if (mode & ZLIB_FILEFUNC_MODE_CREATE) | 81 | if (mode & ZLIB_FILEFUNC_MODE_CREATE) |
82 | mode_fopen = "wb"; | 82 | mode_fopen = "wb"; |
83 | 83 | ||
84 | if ((filename!=NULL) && (mode_fopen != NULL)) | 84 | if ((filename!=NULL) && (mode_fopen != NULL)) |
85 | file = fopen(filename, mode_fopen); | 85 | file = fopen(filename, mode_fopen); |
86 | return file; | 86 | return file; |
87 | } | 87 | } |
88 | 88 | ||
89 | 89 | ||
90 | uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) | 90 | uLong ZCALLBACK fread_file_func (opaque, stream, buf, size) |
91 | voidpf opaque; | 91 | voidpf opaque; |
92 | voidpf stream; | 92 | voidpf stream; |
93 | void* buf; | 93 | void* buf; |
94 | uLong size; | 94 | uLong size; |
95 | { | 95 | { |
96 | uLong ret; | 96 | uLong ret; |
97 | ret = fread(buf, 1, (size_t)size, (FILE *)stream); | 97 | ret = fread(buf, 1, (size_t)size, (FILE *)stream); |
98 | return ret; | 98 | return ret; |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) | 102 | uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size) |
103 | voidpf opaque; | 103 | voidpf opaque; |
104 | voidpf stream; | 104 | voidpf stream; |
105 | const void* buf; | 105 | const void* buf; |
106 | uLong size; | 106 | uLong size; |
107 | { | 107 | { |
108 | uLong ret; | 108 | uLong ret; |
109 | ret = fwrite(buf, 1, (size_t)size, (FILE *)stream); | 109 | ret = fwrite(buf, 1, (size_t)size, (FILE *)stream); |
110 | return ret; | 110 | return ret; |
111 | } | 111 | } |
112 | 112 | ||
113 | long ZCALLBACK ftell_file_func (opaque, stream) | 113 | long ZCALLBACK ftell_file_func (opaque, stream) |
114 | voidpf opaque; | 114 | voidpf opaque; |
115 | voidpf stream; | 115 | voidpf stream; |
116 | { | 116 | { |
117 | long ret; | 117 | long ret; |
118 | ret = ftell((FILE *)stream); | 118 | ret = ftell((FILE *)stream); |
119 | return ret; | 119 | return ret; |
120 | } | 120 | } |
121 | 121 | ||
122 | long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) | 122 | long ZCALLBACK fseek_file_func (opaque, stream, offset, origin) |
123 | voidpf opaque; | 123 | voidpf opaque; |
124 | voidpf stream; | 124 | voidpf stream; |
125 | uLong offset; | 125 | uLong offset; |
126 | int origin; | 126 | int origin; |
127 | { | 127 | { |
128 | int fseek_origin=0; | 128 | int fseek_origin=0; |
129 | long ret; | 129 | long ret; |
130 | switch (origin) | 130 | switch (origin) |
131 | { | 131 | { |
132 | case ZLIB_FILEFUNC_SEEK_CUR : | 132 | case ZLIB_FILEFUNC_SEEK_CUR : |
133 | fseek_origin = SEEK_CUR; | 133 | fseek_origin = SEEK_CUR; |
134 | break; | 134 | break; |
135 | case ZLIB_FILEFUNC_SEEK_END : | 135 | case ZLIB_FILEFUNC_SEEK_END : |
136 | fseek_origin = SEEK_END; | 136 | fseek_origin = SEEK_END; |
137 | break; | 137 | break; |
138 | case ZLIB_FILEFUNC_SEEK_SET : | 138 | case ZLIB_FILEFUNC_SEEK_SET : |
139 | fseek_origin = SEEK_SET; | 139 | fseek_origin = SEEK_SET; |
140 | break; | 140 | break; |
141 | default: return -1; | 141 | default: return -1; |
142 | } | 142 | } |
143 | ret = 0; | 143 | ret = 0; |
144 | fseek((FILE *)stream, offset, fseek_origin); | 144 | fseek((FILE *)stream, offset, fseek_origin); |
145 | return ret; | 145 | return ret; |
146 | } | 146 | } |
147 | 147 | ||
148 | int ZCALLBACK fclose_file_func (opaque, stream) | 148 | int ZCALLBACK fclose_file_func (opaque, stream) |
149 | voidpf opaque; | 149 | voidpf opaque; |
150 | voidpf stream; | 150 | voidpf stream; |
151 | { | 151 | { |
152 | int ret; | 152 | int ret; |
153 | ret = fclose((FILE *)stream); | 153 | ret = fclose((FILE *)stream); |
154 | return ret; | 154 | return ret; |
155 | } | 155 | } |
156 | 156 | ||
157 | int ZCALLBACK ferror_file_func (opaque, stream) | 157 | int ZCALLBACK ferror_file_func (opaque, stream) |
158 | voidpf opaque; | 158 | voidpf opaque; |
159 | voidpf stream; | 159 | voidpf stream; |
160 | { | 160 | { |
161 | int ret; | 161 | int ret; |
162 | ret = ferror((FILE *)stream); | 162 | ret = ferror((FILE *)stream); |
163 | return ret; | 163 | return ret; |
164 | } | 164 | } |
165 | 165 | ||
166 | void fill_fopen_filefunc (pzlib_filefunc_def) | 166 | void fill_fopen_filefunc (pzlib_filefunc_def) |
167 | zlib_filefunc_def* pzlib_filefunc_def; | 167 | zlib_filefunc_def* pzlib_filefunc_def; |
168 | { | 168 | { |
169 | pzlib_filefunc_def->zopen_file = fopen_file_func; | 169 | pzlib_filefunc_def->zopen_file = fopen_file_func; |
170 | pzlib_filefunc_def->zread_file = fread_file_func; | 170 | pzlib_filefunc_def->zread_file = fread_file_func; |
171 | pzlib_filefunc_def->zwrite_file = fwrite_file_func; | 171 | pzlib_filefunc_def->zwrite_file = fwrite_file_func; |
172 | pzlib_filefunc_def->ztell_file = ftell_file_func; | 172 | pzlib_filefunc_def->ztell_file = ftell_file_func; |
173 | pzlib_filefunc_def->zseek_file = fseek_file_func; | 173 | pzlib_filefunc_def->zseek_file = fseek_file_func; |
174 | pzlib_filefunc_def->zclose_file = fclose_file_func; | 174 | pzlib_filefunc_def->zclose_file = fclose_file_func; |
175 | pzlib_filefunc_def->zerror_file = ferror_file_func; | 175 | pzlib_filefunc_def->zerror_file = ferror_file_func; |
176 | pzlib_filefunc_def->opaque = NULL; | 176 | pzlib_filefunc_def->opaque = NULL; |
177 | } | 177 | } |
diff --git a/contrib/minizip/ioapi.h b/contrib/minizip/ioapi.h index 6b8f1f1..13f4f21 100644 --- a/contrib/minizip/ioapi.h +++ b/contrib/minizip/ioapi.h | |||
@@ -1,75 +1,75 @@ | |||
1 | /* ioapi.h -- IO base function header for compress/uncompress .zip | 1 | /* ioapi.h -- IO base function header for compress/uncompress .zip |
2 | files using zlib + zip or unzip API | 2 | files using zlib + zip or unzip API |
3 | 3 | ||
4 | Version 0.22, May 19th, 2003 | 4 | Version 0.22, May 19th, 2003 |
5 | 5 | ||
6 | Copyright (C) 1998-2003 Gilles Vollant | 6 | Copyright (C) 1998-2003 Gilles Vollant |
7 | */ | 7 | */ |
8 | 8 | ||
9 | #ifndef _ZLIBIOAPI_H | 9 | #ifndef _ZLIBIOAPI_H |
10 | #define _ZLIBIOAPI_H | 10 | #define _ZLIBIOAPI_H |
11 | 11 | ||
12 | 12 | ||
13 | #define ZLIB_FILEFUNC_SEEK_CUR (1) | 13 | #define ZLIB_FILEFUNC_SEEK_CUR (1) |
14 | #define ZLIB_FILEFUNC_SEEK_END (2) | 14 | #define ZLIB_FILEFUNC_SEEK_END (2) |
15 | #define ZLIB_FILEFUNC_SEEK_SET (0) | 15 | #define ZLIB_FILEFUNC_SEEK_SET (0) |
16 | 16 | ||
17 | #define ZLIB_FILEFUNC_MODE_READ (1) | 17 | #define ZLIB_FILEFUNC_MODE_READ (1) |
18 | #define ZLIB_FILEFUNC_MODE_WRITE (2) | 18 | #define ZLIB_FILEFUNC_MODE_WRITE (2) |
19 | #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) | 19 | #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) |
20 | 20 | ||
21 | #define ZLIB_FILEFUNC_MODE_EXISTING (4) | 21 | #define ZLIB_FILEFUNC_MODE_EXISTING (4) |
22 | #define ZLIB_FILEFUNC_MODE_CREATE (8) | 22 | #define ZLIB_FILEFUNC_MODE_CREATE (8) |
23 | 23 | ||
24 | 24 | ||
25 | #ifndef ZCALLBACK | 25 | #ifndef ZCALLBACK |
26 | 26 | ||
27 | #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) | 27 | #if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) |
28 | #define ZCALLBACK CALLBACK | 28 | #define ZCALLBACK CALLBACK |
29 | #else | 29 | #else |
30 | #define ZCALLBACK | 30 | #define ZCALLBACK |
31 | #endif | 31 | #endif |
32 | #endif | 32 | #endif |
33 | 33 | ||
34 | #ifdef __cplusplus | 34 | #ifdef __cplusplus |
35 | extern "C" { | 35 | extern "C" { |
36 | #endif | 36 | #endif |
37 | 37 | ||
38 | typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); | 38 | typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); |
39 | typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); | 39 | typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); |
40 | typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); | 40 | typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); |
41 | typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); | 41 | typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); |
42 | typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); | 42 | typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); |
43 | typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); | 43 | typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); |
44 | typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); | 44 | typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); |
45 | 45 | ||
46 | typedef struct zlib_filefunc_def_s | 46 | typedef struct zlib_filefunc_def_s |
47 | { | 47 | { |
48 | open_file_func zopen_file; | 48 | open_file_func zopen_file; |
49 | read_file_func zread_file; | 49 | read_file_func zread_file; |
50 | write_file_func zwrite_file; | 50 | write_file_func zwrite_file; |
51 | tell_file_func ztell_file; | 51 | tell_file_func ztell_file; |
52 | seek_file_func zseek_file; | 52 | seek_file_func zseek_file; |
53 | close_file_func zclose_file; | 53 | close_file_func zclose_file; |
54 | testerror_file_func zerror_file; | 54 | testerror_file_func zerror_file; |
55 | voidpf opaque; | 55 | voidpf opaque; |
56 | } zlib_filefunc_def; | 56 | } zlib_filefunc_def; |
57 | 57 | ||
58 | 58 | ||
59 | 59 | ||
60 | void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); | 60 | void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); |
61 | 61 | ||
62 | #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) | 62 | #define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size)) |
63 | #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) | 63 | #define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size)) |
64 | #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) | 64 | #define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream)) |
65 | #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) | 65 | #define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode)) |
66 | #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) | 66 | #define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream)) |
67 | #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) | 67 | #define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream)) |
68 | 68 | ||
69 | 69 | ||
70 | #ifdef __cplusplus | 70 | #ifdef __cplusplus |
71 | } | 71 | } |
72 | #endif | 72 | #endif |
73 | 73 | ||
74 | #endif | 74 | #endif |
75 | 75 | ||
diff --git a/contrib/minizip/iowin32.c b/contrib/minizip/iowin32.c index 53198b6..8e6d43d 100644 --- a/contrib/minizip/iowin32.c +++ b/contrib/minizip/iowin32.c | |||
@@ -1,271 +1,270 @@ | |||
1 | /* iowin32.c -- IO base function header for compress/uncompress .zip | 1 | /* iowin32.c -- IO base function header for compress/uncompress .zip |
2 | files using zlib + zip or unzip API | 2 | files using zlib + zip or unzip API |
3 | This IO API version uses the Win32 API (for Microsoft Windows) | 3 | This IO API version uses the Win32 API (for Microsoft Windows) |
4 | 4 | ||
5 | Version 0.22, May 19th, 2003 | 5 | Version 0.22, May 19th, 2003 |
6 | 6 | ||
7 | Copyright (C) 1998-2003 Gilles Vollant | 7 | Copyright (C) 1998-2003 Gilles Vollant |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <windows.h> | 10 | #include <stdlib.h> |
11 | #include <stdlib.h> | 11 | |
12 | 12 | #include "zlib.h" | |
13 | #include "zlib.h" | 13 | #include "ioapi.h" |
14 | #include "ioapi.h" | 14 | #include "iowin32.h" |
15 | #include "iowin32.h" | 15 | |
16 | 16 | #ifndef INVALID_HANDLE_VALUE | |
17 | #ifndef INVALID_HANDLE_VALUE | 17 | #define INVALID_HANDLE_VALUE (0xFFFFFFFF) |
18 | #define INVALID_HANDLE_VALUE (0xFFFFFFFF) | 18 | #endif |
19 | #endif | 19 | |
20 | 20 | #ifndef INVALID_SET_FILE_POINTER | |
21 | #ifndef INVALID_SET_FILE_POINTER | 21 | #define INVALID_SET_FILE_POINTER ((DWORD)-1) |
22 | #define INVALID_SET_FILE_POINTER ((DWORD)-1) | 22 | #endif |
23 | #endif | 23 | |
24 | 24 | voidpf ZCALLBACK win32_open_file_func OF(( | |
25 | voidpf ZCALLBACK win32_open_file_func OF(( | 25 | voidpf opaque, |
26 | voidpf opaque, | 26 | const char* filename, |
27 | const char* filename, | 27 | int mode)); |
28 | int mode)); | 28 | |
29 | 29 | uLong ZCALLBACK win32_read_file_func OF(( | |
30 | uLong ZCALLBACK win32_read_file_func OF(( | 30 | voidpf opaque, |
31 | voidpf opaque, | 31 | voidpf stream, |
32 | voidpf stream, | 32 | void* buf, |
33 | void* buf, | 33 | uLong size)); |
34 | uLong size)); | 34 | |
35 | 35 | uLong ZCALLBACK win32_write_file_func OF(( | |
36 | uLong ZCALLBACK win32_write_file_func OF(( | 36 | voidpf opaque, |
37 | voidpf opaque, | 37 | voidpf stream, |
38 | voidpf stream, | 38 | const void* buf, |
39 | const void* buf, | 39 | uLong size)); |
40 | uLong size)); | 40 | |
41 | 41 | long ZCALLBACK win32_tell_file_func OF(( | |
42 | long ZCALLBACK win32_tell_file_func OF(( | 42 | voidpf opaque, |
43 | voidpf opaque, | 43 | voidpf stream)); |
44 | voidpf stream)); | 44 | |
45 | 45 | long ZCALLBACK win32_seek_file_func OF(( | |
46 | long ZCALLBACK win32_seek_file_func OF(( | 46 | voidpf opaque, |
47 | voidpf opaque, | 47 | voidpf stream, |
48 | voidpf stream, | 48 | uLong offset, |
49 | uLong offset, | 49 | int origin)); |
50 | int origin)); | 50 | |
51 | 51 | int ZCALLBACK win32_close_file_func OF(( | |
52 | long ZCALLBACK win32_close_file_func OF(( | 52 | voidpf opaque, |
53 | voidpf opaque, | 53 | voidpf stream)); |
54 | voidpf stream)); | 54 | |
55 | 55 | int ZCALLBACK win32_error_file_func OF(( | |
56 | int ZCALLBACK win32_error_file_func OF(( | 56 | voidpf opaque, |
57 | voidpf opaque, | 57 | voidpf stream)); |
58 | voidpf stream)); | 58 | |
59 | 59 | typedef struct | |
60 | typedef struct | 60 | { |
61 | { | 61 | HANDLE hf; |
62 | HANDLE hf; | 62 | int error; |
63 | int error; | 63 | } WIN32FILE_IOWIN; |
64 | } WIN32FILE_IOWIN; | 64 | |
65 | 65 | voidpf ZCALLBACK win32_open_file_func (opaque, filename, mode) | |
66 | voidpf ZCALLBACK win32_open_file_func (opaque, filename, mode) | 66 | voidpf opaque; |
67 | voidpf opaque; | 67 | const char* filename; |
68 | const char* filename; | 68 | int mode; |
69 | int mode; | 69 | { |
70 | { | 70 | const char* mode_fopen = NULL; |
71 | const char* mode_fopen = NULL; | 71 | DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; |
72 | DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; | 72 | HANDLE hFile = 0; |
73 | HANDLE hFile = 0; | 73 | voidpf ret=NULL; |
74 | voidpf ret=NULL; | 74 | |
75 | 75 | dwDesiredAccess = dwShareMode = dwFlagsAndAttributes = 0; | |
76 | dwDesiredAccess = dwShareMode = dwFlagsAndAttributes = 0; | 76 | |
77 | 77 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) | |
78 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) | 78 | { |
79 | { | 79 | dwDesiredAccess = GENERIC_READ; |
80 | dwDesiredAccess = GENERIC_READ; | 80 | dwCreationDisposition = OPEN_EXISTING; |
81 | dwCreationDisposition = OPEN_EXISTING; | 81 | dwShareMode = FILE_SHARE_READ; |
82 | dwShareMode = FILE_SHARE_READ; | 82 | } |
83 | } | 83 | else |
84 | else | 84 | if (mode & ZLIB_FILEFUNC_MODE_EXISTING) |
85 | if (mode & ZLIB_FILEFUNC_MODE_EXISTING) | 85 | { |
86 | { | 86 | dwDesiredAccess = GENERIC_WRITE | GENERIC_READ; |
87 | dwDesiredAccess = GENERIC_WRITE | GENERIC_READ; | 87 | dwCreationDisposition = OPEN_EXISTING; |
88 | dwCreationDisposition = OPEN_EXISTING; | 88 | } |
89 | } | 89 | else |
90 | else | 90 | if (mode & ZLIB_FILEFUNC_MODE_CREATE) |
91 | if (mode & ZLIB_FILEFUNC_MODE_CREATE) | 91 | { |
92 | { | 92 | dwDesiredAccess = GENERIC_WRITE | GENERIC_READ; |
93 | dwDesiredAccess = GENERIC_WRITE | GENERIC_READ; | 93 | dwCreationDisposition = CREATE_ALWAYS; |
94 | dwCreationDisposition = CREATE_ALWAYS; | 94 | } |
95 | } | 95 | |
96 | 96 | if ((filename!=NULL) && (dwDesiredAccess != 0)) | |
97 | if ((filename!=NULL) && (dwDesiredAccess != 0)) | 97 | hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, |
98 | hFile = CreateFile((LPCTSTR)filename, dwDesiredAccess, dwShareMode, NULL, | 98 | dwCreationDisposition, dwFlagsAndAttributes, NULL); |
99 | dwCreationDisposition, dwFlagsAndAttributes, NULL); | 99 | |
100 | 100 | if (hFile == INVALID_HANDLE_VALUE) | |
101 | if (hFile == INVALID_HANDLE_VALUE) | 101 | hFile = NULL; |
102 | hFile = NULL; | 102 | |
103 | 103 | if (hFile != NULL) | |
104 | if (hFile != NULL) | 104 | { |
105 | { | 105 | WIN32FILE_IOWIN w32fiow; |
106 | WIN32FILE_IOWIN w32fiow; | 106 | w32fiow.hf = hFile; |
107 | w32fiow.hf = hFile; | 107 | w32fiow.error = 0; |
108 | w32fiow.error = 0; | 108 | ret = malloc(sizeof(WIN32FILE_IOWIN)); |
109 | ret = malloc(sizeof(WIN32FILE_IOWIN)); | 109 | if (ret==NULL) |
110 | if (ret==NULL) | 110 | CloseHandle(hFile); |
111 | CloseHandle(hFile); | 111 | else *((WIN32FILE_IOWIN*)ret) = w32fiow; |
112 | else *((WIN32FILE_IOWIN*)ret) = w32fiow; | 112 | } |
113 | } | 113 | return ret; |
114 | return ret; | 114 | } |
115 | } | 115 | |
116 | 116 | ||
117 | 117 | uLong ZCALLBACK win32_read_file_func (opaque, stream, buf, size) | |
118 | uLong ZCALLBACK win32_read_file_func (opaque, stream, buf, size) | 118 | voidpf opaque; |
119 | voidpf opaque; | 119 | voidpf stream; |
120 | voidpf stream; | 120 | void* buf; |
121 | void* buf; | 121 | uLong size; |
122 | uLong size; | 122 | { |
123 | { | 123 | uLong ret=0; |
124 | uLong ret=0; | 124 | HANDLE hFile = NULL; |
125 | HANDLE hFile = NULL; | 125 | if (stream!=NULL) |
126 | if (stream!=NULL) | 126 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
127 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; | 127 | if (hFile != NULL) |
128 | if (hFile != NULL) | 128 | if (!ReadFile(hFile, buf, size, &ret, NULL)) |
129 | if (!ReadFile(hFile, buf, size, &ret, NULL)) | 129 | { |
130 | { | 130 | DWORD dwErr = GetLastError(); |
131 | DWORD dwErr = GetLastError(); | 131 | if (dwErr == ERROR_HANDLE_EOF) |
132 | if (dwErr == ERROR_HANDLE_EOF) | 132 | dwErr = 0; |
133 | dwErr = 0; | 133 | ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; |
134 | ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; | 134 | } |
135 | } | 135 | |
136 | 136 | return ret; | |
137 | return ret; | 137 | } |
138 | } | 138 | |
139 | 139 | ||
140 | 140 | uLong ZCALLBACK win32_write_file_func (opaque, stream, buf, size) | |
141 | uLong ZCALLBACK win32_write_file_func (opaque, stream, buf, size) | 141 | voidpf opaque; |
142 | voidpf opaque; | 142 | voidpf stream; |
143 | voidpf stream; | 143 | const void* buf; |
144 | const void* buf; | 144 | uLong size; |
145 | uLong size; | 145 | { |
146 | { | 146 | uLong ret=0; |
147 | uLong ret=0; | 147 | HANDLE hFile = NULL; |
148 | HANDLE hFile = NULL; | 148 | if (stream!=NULL) |
149 | if (stream!=NULL) | 149 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
150 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; | 150 | |
151 | 151 | if (hFile !=NULL) | |
152 | if (hFile !=NULL) | 152 | if (!WriteFile(hFile, buf, size, &ret, NULL)) |
153 | if (!WriteFile(hFile, buf, size, &ret, NULL)) | 153 | { |
154 | { | 154 | DWORD dwErr = GetLastError(); |
155 | DWORD dwErr = GetLastError(); | 155 | if (dwErr == ERROR_HANDLE_EOF) |
156 | if (dwErr == ERROR_HANDLE_EOF) | 156 | dwErr = 0; |
157 | dwErr = 0; | 157 | ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; |
158 | ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; | 158 | } |
159 | } | 159 | |
160 | 160 | return ret; | |
161 | return ret; | 161 | } |
162 | } | 162 | |
163 | 163 | long ZCALLBACK win32_tell_file_func (opaque, stream) | |
164 | long ZCALLBACK win32_tell_file_func (opaque, stream) | 164 | voidpf opaque; |
165 | voidpf opaque; | 165 | voidpf stream; |
166 | voidpf stream; | 166 | { |
167 | { | 167 | long ret=-1; |
168 | long ret=-1; | 168 | HANDLE hFile = NULL; |
169 | HANDLE hFile = NULL; | 169 | if (stream!=NULL) |
170 | if (stream!=NULL) | 170 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
171 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; | 171 | if (hFile != NULL) |
172 | if (hFile != NULL) | 172 | { |
173 | { | 173 | DWORD dwSet = SetFilePointer(hFile, 0, NULL, FILE_CURRENT); |
174 | DWORD dwSet = SetFilePointer(hFile, 0, NULL, FILE_CURRENT); | 174 | if (dwSet == INVALID_SET_FILE_POINTER) |
175 | if (dwSet == INVALID_SET_FILE_POINTER) | 175 | { |
176 | { | 176 | DWORD dwErr = GetLastError(); |
177 | DWORD dwErr = GetLastError(); | 177 | ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; |
178 | ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; | 178 | ret = -1; |
179 | ret = -1; | 179 | } |
180 | } | 180 | else |
181 | else | 181 | ret=(long)dwSet; |
182 | ret=(long)dwSet; | 182 | } |
183 | } | 183 | return ret; |
184 | return ret; | 184 | } |
185 | } | 185 | |
186 | 186 | long ZCALLBACK win32_seek_file_func (opaque, stream, offset, origin) | |
187 | long ZCALLBACK win32_seek_file_func (opaque, stream, offset, origin) | 187 | voidpf opaque; |
188 | voidpf opaque; | 188 | voidpf stream; |
189 | voidpf stream; | 189 | uLong offset; |
190 | uLong offset; | 190 | int origin; |
191 | int origin; | 191 | { |
192 | { | 192 | DWORD dwMoveMethod=0xFFFFFFFF; |
193 | DWORD dwMoveMethod=0xFFFFFFFF; | 193 | HANDLE hFile = NULL; |
194 | HANDLE hFile = NULL; | 194 | |
195 | 195 | long ret=-1; | |
196 | long ret=-1; | 196 | if (stream!=NULL) |
197 | if (stream!=NULL) | 197 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
198 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; | 198 | switch (origin) |
199 | switch (origin) | 199 | { |
200 | { | 200 | case ZLIB_FILEFUNC_SEEK_CUR : |
201 | case ZLIB_FILEFUNC_SEEK_CUR : | 201 | dwMoveMethod = FILE_CURRENT; |
202 | dwMoveMethod = FILE_CURRENT; | 202 | break; |
203 | break; | 203 | case ZLIB_FILEFUNC_SEEK_END : |
204 | case ZLIB_FILEFUNC_SEEK_END : | 204 | dwMoveMethod = FILE_END; |
205 | dwMoveMethod = FILE_END; | 205 | break; |
206 | break; | 206 | case ZLIB_FILEFUNC_SEEK_SET : |
207 | case ZLIB_FILEFUNC_SEEK_SET : | 207 | dwMoveMethod = FILE_BEGIN; |
208 | dwMoveMethod = FILE_BEGIN; | 208 | break; |
209 | break; | 209 | default: return -1; |
210 | default: return -1; | 210 | } |
211 | } | 211 | |
212 | 212 | if (hFile != NULL) | |
213 | if (hFile != NULL) | 213 | { |
214 | { | 214 | DWORD dwSet = SetFilePointer(hFile, offset, NULL, dwMoveMethod); |
215 | DWORD dwSet = SetFilePointer(hFile, offset, NULL, dwMoveMethod); | 215 | if (dwSet == INVALID_SET_FILE_POINTER) |
216 | if (dwSet == INVALID_SET_FILE_POINTER) | 216 | { |
217 | { | 217 | DWORD dwErr = GetLastError(); |
218 | DWORD dwErr = GetLastError(); | 218 | ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; |
219 | ((WIN32FILE_IOWIN*)stream) -> error=(int)dwErr; | 219 | ret = -1; |
220 | ret = -1; | 220 | } |
221 | } | 221 | else |
222 | else | 222 | ret=0; |
223 | ret=0; | 223 | } |
224 | } | 224 | return ret; |
225 | return ret; | 225 | } |
226 | } | 226 | |
227 | 227 | int ZCALLBACK win32_close_file_func (opaque, stream) | |
228 | long ZCALLBACK win32_close_file_func (opaque, stream) | 228 | voidpf opaque; |
229 | voidpf opaque; | 229 | voidpf stream; |
230 | voidpf stream; | 230 | { |
231 | { | 231 | int ret=-1; |
232 | long ret=-1; | 232 | |
233 | 233 | if (stream!=NULL) | |
234 | if (stream!=NULL) | 234 | { |
235 | { | 235 | HANDLE hFile; |
236 | HANDLE hFile; | 236 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
237 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; | 237 | if (hFile != NULL) |
238 | if (hFile != NULL) | 238 | { |
239 | { | 239 | CloseHandle(hFile); |
240 | CloseHandle(hFile); | 240 | ret=0; |
241 | ret=0; | 241 | } |
242 | } | 242 | free(stream); |
243 | free(stream); | 243 | } |
244 | } | 244 | return ret; |
245 | return ret; | 245 | } |
246 | } | 246 | |
247 | 247 | int ZCALLBACK win32_error_file_func (opaque, stream) | |
248 | int ZCALLBACK win32_error_file_func (opaque, stream) | 248 | voidpf opaque; |
249 | voidpf opaque; | 249 | voidpf stream; |
250 | voidpf stream; | 250 | { |
251 | { | 251 | int ret=-1; |
252 | int ret=-1; | 252 | if (stream!=NULL) |
253 | if (stream!=NULL) | 253 | { |
254 | { | 254 | ret = ((WIN32FILE_IOWIN*)stream) -> error; |
255 | ret = ((WIN32FILE_IOWIN*)stream) -> error; | 255 | } |
256 | } | 256 | return ret; |
257 | return ret; | 257 | } |
258 | } | 258 | |
259 | 259 | void fill_win32_filefunc (pzlib_filefunc_def) | |
260 | void fill_win32_filefunc (pzlib_filefunc_def) | 260 | zlib_filefunc_def* pzlib_filefunc_def; |
261 | zlib_filefunc_def* pzlib_filefunc_def; | 261 | { |
262 | { | 262 | pzlib_filefunc_def->zopen_file = win32_open_file_func; |
263 | pzlib_filefunc_def->zopen_file = win32_open_file_func; | 263 | pzlib_filefunc_def->zread_file = win32_read_file_func; |
264 | pzlib_filefunc_def->zread_file = win32_read_file_func; | 264 | pzlib_filefunc_def->zwrite_file = win32_write_file_func; |
265 | pzlib_filefunc_def->zwrite_file = win32_write_file_func; | 265 | pzlib_filefunc_def->ztell_file = win32_tell_file_func; |
266 | pzlib_filefunc_def->ztell_file = win32_tell_file_func; | 266 | pzlib_filefunc_def->zseek_file = win32_seek_file_func; |
267 | pzlib_filefunc_def->zseek_file = win32_seek_file_func; | 267 | pzlib_filefunc_def->zclose_file = win32_close_file_func; |
268 | pzlib_filefunc_def->zclose_file = win32_close_file_func; | 268 | pzlib_filefunc_def->zerror_file = win32_error_file_func; |
269 | pzlib_filefunc_def->zerror_file = win32_error_file_func; | 269 | pzlib_filefunc_def->opaque=NULL; |
270 | pzlib_filefunc_def->opaque=NULL; | 270 | } |
271 | } | ||
diff --git a/contrib/minizip/iowin32.h b/contrib/minizip/iowin32.h index 713fc02..94aa1aa 100644 --- a/contrib/minizip/iowin32.h +++ b/contrib/minizip/iowin32.h | |||
@@ -1,19 +1,21 @@ | |||
1 | /* iowin32.h -- IO base function header for compress/uncompress .zip | 1 | /* iowin32.h -- IO base function header for compress/uncompress .zip |
2 | files using zlib + zip or unzip API | 2 | files using zlib + zip or unzip API |
3 | This IO API version uses the Win32 API (for Microsoft Windows) | 3 | This IO API version uses the Win32 API (for Microsoft Windows) |
4 | 4 | ||
5 | Version 0.22, May 19th, 2003 | 5 | Version 0.22, May 19th, 2003 |
6 | 6 | ||
7 | Copyright (C) 1998-2003 Gilles Vollant | 7 | Copyright (C) 1998-2003 Gilles Vollant |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #ifdef __cplusplus | 10 | #include <windows.h> |
11 | extern "C" { | 11 | |
12 | #endif | 12 | |
13 | 13 | #ifdef __cplusplus | |
14 | void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); | 14 | extern "C" { |
15 | 15 | #endif | |
16 | 16 | ||
17 | #ifdef __cplusplus | 17 | void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); |
18 | } | 18 | |
19 | #endif | 19 | #ifdef __cplusplus |
20 | } | ||
21 | #endif | ||
diff --git a/contrib/minizip/miniunz.c b/contrib/minizip/miniunz.c index ea23e40..57601e1 100644 --- a/contrib/minizip/miniunz.c +++ b/contrib/minizip/miniunz.c | |||
@@ -1,556 +1,556 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include <time.h> | 4 | #include <time.h> |
5 | #include <errno.h> | 5 | #include <errno.h> |
6 | #include <fcntl.h> | 6 | #include <fcntl.h> |
7 | 7 | ||
8 | #ifdef unix | 8 | #ifdef unix |
9 | # include <unistd.h> | 9 | # include <unistd.h> |
10 | # include <utime.h> | 10 | # include <utime.h> |
11 | #else | 11 | #else |
12 | # include <direct.h> | 12 | # include <direct.h> |
13 | # include <io.h> | 13 | # include <io.h> |
14 | #endif | 14 | #endif |
15 | 15 | ||
16 | #include "unzip.h" | 16 | #include "unzip.h" |
17 | 17 | ||
18 | #define CASESENSITIVITY (0) | 18 | #define CASESENSITIVITY (0) |
19 | #define WRITEBUFFERSIZE (8192) | 19 | #define WRITEBUFFERSIZE (8192) |
20 | #define MAXFILENAME (256) | 20 | #define MAXFILENAME (256) |
21 | 21 | ||
22 | #ifdef WIN32 | 22 | #ifdef WIN32 |
23 | #define USEWIN32IOAPI | 23 | #define USEWIN32IOAPI |
24 | #include "iowin32.h" | 24 | #include "iowin32.h" |
25 | #endif | 25 | #endif |
26 | /* | 26 | /* |
27 | mini unzip, demo of unzip package | 27 | mini unzip, demo of unzip package |
28 | 28 | ||
29 | usage : | 29 | usage : |
30 | Usage : miniunz [-exvlo] file.zip [file_to_extract] | 30 | Usage : miniunz [-exvlo] file.zip [file_to_extract] |
31 | 31 | ||
32 | list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT | 32 | list the file in the zipfile, and print the content of FILE_ID.ZIP or README.TXT |
33 | if it exists | 33 | if it exists |
34 | */ | 34 | */ |
35 | 35 | ||
36 | 36 | ||
37 | /* change_file_date : change the date/time of a file | 37 | /* change_file_date : change the date/time of a file |
38 | filename : the filename of the file where date/time must be modified | 38 | filename : the filename of the file where date/time must be modified |
39 | dosdate : the new date at the MSDos format (4 bytes) | 39 | dosdate : the new date at the MSDos format (4 bytes) |
40 | tmu_date : the SAME new date at the tm_unz format */ | 40 | tmu_date : the SAME new date at the tm_unz format */ |
41 | void change_file_date(filename,dosdate,tmu_date) | 41 | void change_file_date(filename,dosdate,tmu_date) |
42 | const char *filename; | 42 | const char *filename; |
43 | uLong dosdate; | 43 | uLong dosdate; |
44 | tm_unz tmu_date; | 44 | tm_unz tmu_date; |
45 | { | 45 | { |
46 | #ifdef WIN32 | 46 | #ifdef WIN32 |
47 | HANDLE hFile; | 47 | HANDLE hFile; |
48 | FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; | 48 | FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; |
49 | 49 | ||
50 | hFile = CreateFile(filename,GENERIC_READ | GENERIC_WRITE, | 50 | hFile = CreateFile(filename,GENERIC_READ | GENERIC_WRITE, |
51 | 0,NULL,OPEN_EXISTING,0,NULL); | 51 | 0,NULL,OPEN_EXISTING,0,NULL); |
52 | GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite); | 52 | GetFileTime(hFile,&ftCreate,&ftLastAcc,&ftLastWrite); |
53 | DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal); | 53 | DosDateTimeToFileTime((WORD)(dosdate>>16),(WORD)dosdate,&ftLocal); |
54 | LocalFileTimeToFileTime(&ftLocal,&ftm); | 54 | LocalFileTimeToFileTime(&ftLocal,&ftm); |
55 | SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); | 55 | SetFileTime(hFile,&ftm,&ftLastAcc,&ftm); |
56 | CloseHandle(hFile); | 56 | CloseHandle(hFile); |
57 | #else | 57 | #else |
58 | #ifdef unix | 58 | #ifdef unix |
59 | struct utimbuf ut; | 59 | struct utimbuf ut; |
60 | struct tm newdate; | 60 | struct tm newdate; |
61 | newdate.tm_sec = tmu_date.tm_sec; | 61 | newdate.tm_sec = tmu_date.tm_sec; |
62 | newdate.tm_min=tmu_date.tm_min; | 62 | newdate.tm_min=tmu_date.tm_min; |
63 | newdate.tm_hour=tmu_date.tm_hour; | 63 | newdate.tm_hour=tmu_date.tm_hour; |
64 | newdate.tm_mday=tmu_date.tm_mday; | 64 | newdate.tm_mday=tmu_date.tm_mday; |
65 | newdate.tm_mon=tmu_date.tm_mon; | 65 | newdate.tm_mon=tmu_date.tm_mon; |
66 | if (tmu_date.tm_year > 1900) | 66 | if (tmu_date.tm_year > 1900) |
67 | newdate.tm_year=tmu_date.tm_year - 1900; | 67 | newdate.tm_year=tmu_date.tm_year - 1900; |
68 | else | 68 | else |
69 | newdate.tm_year=tmu_date.tm_year ; | 69 | newdate.tm_year=tmu_date.tm_year ; |
70 | newdate.tm_isdst=-1; | 70 | newdate.tm_isdst=-1; |
71 | 71 | ||
72 | ut.actime=ut.modtime=mktime(&newdate); | 72 | ut.actime=ut.modtime=mktime(&newdate); |
73 | utime(filename,&ut); | 73 | utime(filename,&ut); |
74 | #endif | 74 | #endif |
75 | #endif | 75 | #endif |
76 | } | 76 | } |
77 | 77 | ||
78 | 78 | ||
79 | /* mymkdir and change_file_date are not 100 % portable | 79 | /* mymkdir and change_file_date are not 100 % portable |
80 | As I don't know well Unix, I wait feedback for the unix portion */ | 80 | As I don't know well Unix, I wait feedback for the unix portion */ |
81 | 81 | ||
82 | int mymkdir(dirname) | 82 | int mymkdir(dirname) |
83 | const char* dirname; | 83 | const char* dirname; |
84 | { | 84 | { |
85 | int ret=0; | 85 | int ret=0; |
86 | #ifdef WIN32 | 86 | #ifdef WIN32 |
87 | ret = mkdir(dirname); | 87 | ret = mkdir(dirname); |
88 | #else | 88 | #else |
89 | #ifdef unix | 89 | #ifdef unix |
90 | ret = mkdir (dirname,0775); | 90 | ret = mkdir (dirname,0775); |
91 | #endif | 91 | #endif |
92 | #endif | 92 | #endif |
93 | return ret; | 93 | return ret; |
94 | } | 94 | } |
95 | 95 | ||
96 | int makedir (newdir) | 96 | int makedir (newdir) |
97 | char *newdir; | 97 | char *newdir; |
98 | { | 98 | { |
99 | char *buffer ; | 99 | char *buffer ; |
100 | char *p; | 100 | char *p; |
101 | int len = (int)strlen(newdir); | 101 | int len = (int)strlen(newdir); |
102 | 102 | ||
103 | if (len <= 0) | 103 | if (len <= 0) |
104 | return 0; | 104 | return 0; |
105 | 105 | ||
106 | buffer = (char*)malloc(len+1); | 106 | buffer = (char*)malloc(len+1); |
107 | strcpy(buffer,newdir); | 107 | strcpy(buffer,newdir); |
108 | 108 | ||
109 | if (buffer[len-1] == '/') { | 109 | if (buffer[len-1] == '/') { |
110 | buffer[len-1] = '\0'; | 110 | buffer[len-1] = '\0'; |
111 | } | 111 | } |
112 | if (mymkdir(buffer) == 0) | 112 | if (mymkdir(buffer) == 0) |
113 | { | 113 | { |
114 | free(buffer); | 114 | free(buffer); |
115 | return 1; | 115 | return 1; |
116 | } | 116 | } |
117 | 117 | ||
118 | p = buffer+1; | 118 | p = buffer+1; |
119 | while (1) | 119 | while (1) |
120 | { | 120 | { |
121 | char hold; | 121 | char hold; |
122 | 122 | ||
123 | while(*p && *p != '\\' && *p != '/') | 123 | while(*p && *p != '\\' && *p != '/') |
124 | p++; | 124 | p++; |
125 | hold = *p; | 125 | hold = *p; |
126 | *p = 0; | 126 | *p = 0; |
127 | if ((mymkdir(buffer) == -1) && (errno == ENOENT)) | 127 | if ((mymkdir(buffer) == -1) && (errno == ENOENT)) |
128 | { | 128 | { |
129 | printf("couldn't create directory %s\n",buffer); | 129 | printf("couldn't create directory %s\n",buffer); |
130 | free(buffer); | 130 | free(buffer); |
131 | return 0; | 131 | return 0; |
132 | } | 132 | } |
133 | if (hold == 0) | 133 | if (hold == 0) |
134 | break; | 134 | break; |
135 | *p++ = hold; | 135 | *p++ = hold; |
136 | } | 136 | } |
137 | free(buffer); | 137 | free(buffer); |
138 | return 1; | 138 | return 1; |
139 | } | 139 | } |
140 | 140 | ||
141 | void do_banner() | 141 | void do_banner() |
142 | { | 142 | { |
143 | printf("MiniUnz 0.22, demo of zLib + Unz package written by Gilles Vollant\n"); | 143 | printf("MiniUnz 0.22, demo of zLib + Unz package written by Gilles Vollant\n"); |
144 | printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); | 144 | printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); |
145 | } | 145 | } |
146 | 146 | ||
147 | void do_help() | 147 | void do_help() |
148 | { | 148 | { |
149 | printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.]\n\n" \ | 149 | printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.]\n\n" \ |
150 | " -e Extract without pathname (junk paths)\n" \ | 150 | " -e Extract without pathname (junk paths)\n" \ |
151 | " -x Extract with pathname\n" \ | 151 | " -x Extract with pathname\n" \ |
152 | " -v list files\n" \ | 152 | " -v list files\n" \ |
153 | " -l list files\n" \ | 153 | " -l list files\n" \ |
154 | " -o overwrite files without prompting\n" \ | 154 | " -o overwrite files without prompting\n" \ |
155 | " -p extract crypted file using password\n\n"); | 155 | " -p extract crypted file using password\n\n"); |
156 | } | 156 | } |
157 | 157 | ||
158 | 158 | ||
159 | int do_list(uf) | 159 | int do_list(uf) |
160 | unzFile uf; | 160 | unzFile uf; |
161 | { | 161 | { |
162 | uLong i; | 162 | uLong i; |
163 | unz_global_info gi; | 163 | unz_global_info gi; |
164 | int err; | 164 | int err; |
165 | 165 | ||
166 | err = unzGetGlobalInfo (uf,&gi); | 166 | err = unzGetGlobalInfo (uf,&gi); |
167 | if (err!=UNZ_OK) | 167 | if (err!=UNZ_OK) |
168 | printf("error %d with zipfile in unzGetGlobalInfo \n",err); | 168 | printf("error %d with zipfile in unzGetGlobalInfo \n",err); |
169 | printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); | 169 | printf(" Length Method Size Ratio Date Time CRC-32 Name\n"); |
170 | printf(" ------ ------ ---- ----- ---- ---- ------ ----\n"); | 170 | printf(" ------ ------ ---- ----- ---- ---- ------ ----\n"); |
171 | for (i=0;i<gi.number_entry;i++) | 171 | for (i=0;i<gi.number_entry;i++) |
172 | { | 172 | { |
173 | char filename_inzip[256]; | 173 | char filename_inzip[256]; |
174 | unz_file_info file_info; | 174 | unz_file_info file_info; |
175 | uLong ratio=0; | 175 | uLong ratio=0; |
176 | const char *string_method; | 176 | const char *string_method; |
177 | char charCrypt=' '; | 177 | char charCrypt=' '; |
178 | err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); | 178 | err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); |
179 | if (err!=UNZ_OK) | 179 | if (err!=UNZ_OK) |
180 | { | 180 | { |
181 | printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); | 181 | printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); |
182 | break; | 182 | break; |
183 | } | 183 | } |
184 | if (file_info.uncompressed_size>0) | 184 | if (file_info.uncompressed_size>0) |
185 | ratio = (file_info.compressed_size*100)/file_info.uncompressed_size; | 185 | ratio = (file_info.compressed_size*100)/file_info.uncompressed_size; |
186 | 186 | ||
187 | /* display a '*' if the file is crypted */ | 187 | /* display a '*' if the file is crypted */ |
188 | if ((file_info.flag & 1) != 0) | 188 | if ((file_info.flag & 1) != 0) |
189 | charCrypt='*'; | 189 | charCrypt='*'; |
190 | 190 | ||
191 | if (file_info.compression_method==0) | 191 | if (file_info.compression_method==0) |
192 | string_method="Stored"; | 192 | string_method="Stored"; |
193 | else | 193 | else |
194 | if (file_info.compression_method==Z_DEFLATED) | 194 | if (file_info.compression_method==Z_DEFLATED) |
195 | { | 195 | { |
196 | uInt iLevel=(uInt)((file_info.flag & 0x6)/2); | 196 | uInt iLevel=(uInt)((file_info.flag & 0x6)/2); |
197 | if (iLevel==0) | 197 | if (iLevel==0) |
198 | string_method="Defl:N"; | 198 | string_method="Defl:N"; |
199 | else if (iLevel==1) | 199 | else if (iLevel==1) |
200 | string_method="Defl:X"; | 200 | string_method="Defl:X"; |
201 | else if ((iLevel==2) || (iLevel==3)) | 201 | else if ((iLevel==2) || (iLevel==3)) |
202 | string_method="Defl:F"; /* 2:fast , 3 : extra fast*/ | 202 | string_method="Defl:F"; /* 2:fast , 3 : extra fast*/ |
203 | } | 203 | } |
204 | else | 204 | else |
205 | string_method="Unkn. "; | 205 | string_method="Unkn. "; |
206 | 206 | ||
207 | printf("%7lu %6s%c%7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n", | 207 | printf("%7lu %6s%c%7lu %3lu%% %2.2lu-%2.2lu-%2.2lu %2.2lu:%2.2lu %8.8lx %s\n", |
208 | file_info.uncompressed_size,string_method, | 208 | file_info.uncompressed_size,string_method, |
209 | charCrypt, | 209 | charCrypt, |
210 | file_info.compressed_size, | 210 | file_info.compressed_size, |
211 | ratio, | 211 | ratio, |
212 | (uLong)file_info.tmu_date.tm_mon + 1, | 212 | (uLong)file_info.tmu_date.tm_mon + 1, |
213 | (uLong)file_info.tmu_date.tm_mday, | 213 | (uLong)file_info.tmu_date.tm_mday, |
214 | (uLong)file_info.tmu_date.tm_year % 100, | 214 | (uLong)file_info.tmu_date.tm_year % 100, |
215 | (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min, | 215 | (uLong)file_info.tmu_date.tm_hour,(uLong)file_info.tmu_date.tm_min, |
216 | (uLong)file_info.crc,filename_inzip); | 216 | (uLong)file_info.crc,filename_inzip); |
217 | if ((i+1)<gi.number_entry) | 217 | if ((i+1)<gi.number_entry) |
218 | { | 218 | { |
219 | err = unzGoToNextFile(uf); | 219 | err = unzGoToNextFile(uf); |
220 | if (err!=UNZ_OK) | 220 | if (err!=UNZ_OK) |
221 | { | 221 | { |
222 | printf("error %d with zipfile in unzGoToNextFile\n",err); | 222 | printf("error %d with zipfile in unzGoToNextFile\n",err); |
223 | break; | 223 | break; |
224 | } | 224 | } |
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | return 0; | 228 | return 0; |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password) | 232 | int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password) |
233 | unzFile uf; | 233 | unzFile uf; |
234 | const int* popt_extract_without_path; | 234 | const int* popt_extract_without_path; |
235 | int* popt_overwrite; | 235 | int* popt_overwrite; |
236 | const char* password; | 236 | const char* password; |
237 | { | 237 | { |
238 | char filename_inzip[256]; | 238 | char filename_inzip[256]; |
239 | char* filename_withoutpath; | 239 | char* filename_withoutpath; |
240 | char* p; | 240 | char* p; |
241 | int err=UNZ_OK; | 241 | int err=UNZ_OK; |
242 | FILE *fout=NULL; | 242 | FILE *fout=NULL; |
243 | void* buf; | 243 | void* buf; |
244 | uInt size_buf; | 244 | uInt size_buf; |
245 | 245 | ||
246 | unz_file_info file_info; | 246 | unz_file_info file_info; |
247 | uLong ratio=0; | 247 | uLong ratio=0; |
248 | err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); | 248 | err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); |
249 | 249 | ||
250 | if (err!=UNZ_OK) | 250 | if (err!=UNZ_OK) |
251 | { | 251 | { |
252 | printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); | 252 | printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); |
253 | return err; | 253 | return err; |
254 | } | 254 | } |
255 | 255 | ||
256 | size_buf = WRITEBUFFERSIZE; | 256 | size_buf = WRITEBUFFERSIZE; |
257 | buf = (void*)malloc(size_buf); | 257 | buf = (void*)malloc(size_buf); |
258 | if (buf==NULL) | 258 | if (buf==NULL) |
259 | { | 259 | { |
260 | printf("Error allocating memory\n"); | 260 | printf("Error allocating memory\n"); |
261 | return UNZ_INTERNALERROR; | 261 | return UNZ_INTERNALERROR; |
262 | } | 262 | } |
263 | 263 | ||
264 | p = filename_withoutpath = filename_inzip; | 264 | p = filename_withoutpath = filename_inzip; |
265 | while ((*p) != '\0') | 265 | while ((*p) != '\0') |
266 | { | 266 | { |
267 | if (((*p)=='/') || ((*p)=='\\')) | 267 | if (((*p)=='/') || ((*p)=='\\')) |
268 | filename_withoutpath = p+1; | 268 | filename_withoutpath = p+1; |
269 | p++; | 269 | p++; |
270 | } | 270 | } |
271 | 271 | ||
272 | if ((*filename_withoutpath)=='\0') | 272 | if ((*filename_withoutpath)=='\0') |
273 | { | 273 | { |
274 | if ((*popt_extract_without_path)==0) | 274 | if ((*popt_extract_without_path)==0) |
275 | { | 275 | { |
276 | printf("creating directory: %s\n",filename_inzip); | 276 | printf("creating directory: %s\n",filename_inzip); |
277 | mymkdir(filename_inzip); | 277 | mymkdir(filename_inzip); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | else | 280 | else |
281 | { | 281 | { |
282 | const char* write_filename; | 282 | const char* write_filename; |
283 | int skip=0; | 283 | int skip=0; |
284 | 284 | ||
285 | if ((*popt_extract_without_path)==0) | 285 | if ((*popt_extract_without_path)==0) |
286 | write_filename = filename_inzip; | 286 | write_filename = filename_inzip; |
287 | else | 287 | else |
288 | write_filename = filename_withoutpath; | 288 | write_filename = filename_withoutpath; |
289 | 289 | ||
290 | err = unzOpenCurrentFilePassword(uf,password); | 290 | err = unzOpenCurrentFilePassword(uf,password); |
291 | if (err!=UNZ_OK) | 291 | if (err!=UNZ_OK) |
292 | { | 292 | { |
293 | printf("error %d with zipfile in unzOpenCurrentFilePassword\n",err); | 293 | printf("error %d with zipfile in unzOpenCurrentFilePassword\n",err); |
294 | } | 294 | } |
295 | 295 | ||
296 | if (((*popt_overwrite)==0) && (err==UNZ_OK)) | 296 | if (((*popt_overwrite)==0) && (err==UNZ_OK)) |
297 | { | 297 | { |
298 | char rep=0; | 298 | char rep=0; |
299 | FILE* ftestexist; | 299 | FILE* ftestexist; |
300 | ftestexist = fopen(write_filename,"rb"); | 300 | ftestexist = fopen(write_filename,"rb"); |
301 | if (ftestexist!=NULL) | 301 | if (ftestexist!=NULL) |
302 | { | 302 | { |
303 | fclose(ftestexist); | 303 | fclose(ftestexist); |
304 | do | 304 | do |
305 | { | 305 | { |
306 | char answer[128]; | 306 | char answer[128]; |
307 | printf("The file %s exist. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename); | 307 | printf("The file %s exist. Overwrite ? [y]es, [n]o, [A]ll: ",write_filename); |
308 | scanf("%1s",answer); | 308 | scanf("%1s",answer); |
309 | rep = answer[0] ; | 309 | rep = answer[0] ; |
310 | if ((rep>='a') && (rep<='z')) | 310 | if ((rep>='a') && (rep<='z')) |
311 | rep -= 0x20; | 311 | rep -= 0x20; |
312 | } | 312 | } |
313 | while ((rep!='Y') && (rep!='N') && (rep!='A')); | 313 | while ((rep!='Y') && (rep!='N') && (rep!='A')); |
314 | } | 314 | } |
315 | 315 | ||
316 | if (rep == 'N') | 316 | if (rep == 'N') |
317 | skip = 1; | 317 | skip = 1; |
318 | 318 | ||
319 | if (rep == 'A') | 319 | if (rep == 'A') |
320 | *popt_overwrite=1; | 320 | *popt_overwrite=1; |
321 | } | 321 | } |
322 | 322 | ||
323 | if ((skip==0) && (err==UNZ_OK)) | 323 | if ((skip==0) && (err==UNZ_OK)) |
324 | { | 324 | { |
325 | fout=fopen(write_filename,"wb"); | 325 | fout=fopen(write_filename,"wb"); |
326 | 326 | ||
327 | /* some zipfile don't contain directory alone before file */ | 327 | /* some zipfile don't contain directory alone before file */ |
328 | if ((fout==NULL) && ((*popt_extract_without_path)==0) && | 328 | if ((fout==NULL) && ((*popt_extract_without_path)==0) && |
329 | (filename_withoutpath!=(char*)filename_inzip)) | 329 | (filename_withoutpath!=(char*)filename_inzip)) |
330 | { | 330 | { |
331 | char c=*(filename_withoutpath-1); | 331 | char c=*(filename_withoutpath-1); |
332 | *(filename_withoutpath-1)='\0'; | 332 | *(filename_withoutpath-1)='\0'; |
333 | makedir(write_filename); | 333 | makedir(write_filename); |
334 | *(filename_withoutpath-1)=c; | 334 | *(filename_withoutpath-1)=c; |
335 | fout=fopen(write_filename,"wb"); | 335 | fout=fopen(write_filename,"wb"); |
336 | } | 336 | } |
337 | 337 | ||
338 | if (fout==NULL) | 338 | if (fout==NULL) |
339 | { | 339 | { |
340 | printf("error opening %s\n",write_filename); | 340 | printf("error opening %s\n",write_filename); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | 343 | ||
344 | if (fout!=NULL) | 344 | if (fout!=NULL) |
345 | { | 345 | { |
346 | printf(" extracting: %s\n",write_filename); | 346 | printf(" extracting: %s\n",write_filename); |
347 | 347 | ||
348 | do | 348 | do |
349 | { | 349 | { |
350 | err = unzReadCurrentFile(uf,buf,size_buf); | 350 | err = unzReadCurrentFile(uf,buf,size_buf); |
351 | if (err<0) | 351 | if (err<0) |
352 | { | 352 | { |
353 | printf("error %d with zipfile in unzReadCurrentFile\n",err); | 353 | printf("error %d with zipfile in unzReadCurrentFile\n",err); |
354 | break; | 354 | break; |
355 | } | 355 | } |
356 | if (err>0) | 356 | if (err>0) |
357 | if (fwrite(buf,err,1,fout)!=1) | 357 | if (fwrite(buf,err,1,fout)!=1) |
358 | { | 358 | { |
359 | printf("error in writing extracted file\n"); | 359 | printf("error in writing extracted file\n"); |
360 | err=UNZ_ERRNO; | 360 | err=UNZ_ERRNO; |
361 | break; | 361 | break; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | while (err>0); | 364 | while (err>0); |
365 | if (fout) | 365 | if (fout) |
366 | fclose(fout); | 366 | fclose(fout); |
367 | 367 | ||
368 | if (err==0) | 368 | if (err==0) |
369 | change_file_date(write_filename,file_info.dosDate, | 369 | change_file_date(write_filename,file_info.dosDate, |
370 | file_info.tmu_date); | 370 | file_info.tmu_date); |
371 | } | 371 | } |
372 | 372 | ||
373 | if (err==UNZ_OK) | 373 | if (err==UNZ_OK) |
374 | { | 374 | { |
375 | err = unzCloseCurrentFile (uf); | 375 | err = unzCloseCurrentFile (uf); |
376 | if (err!=UNZ_OK) | 376 | if (err!=UNZ_OK) |
377 | { | 377 | { |
378 | printf("error %d with zipfile in unzCloseCurrentFile\n",err); | 378 | printf("error %d with zipfile in unzCloseCurrentFile\n",err); |
379 | } | 379 | } |
380 | } | 380 | } |
381 | else | 381 | else |
382 | unzCloseCurrentFile(uf); /* don't lose the error */ | 382 | unzCloseCurrentFile(uf); /* don't lose the error */ |
383 | } | 383 | } |
384 | 384 | ||
385 | free(buf); | 385 | free(buf); |
386 | return err; | 386 | return err; |
387 | } | 387 | } |
388 | 388 | ||
389 | 389 | ||
390 | int do_extract(uf,opt_extract_without_path,opt_overwrite,password) | 390 | int do_extract(uf,opt_extract_without_path,opt_overwrite,password) |
391 | unzFile uf; | 391 | unzFile uf; |
392 | int opt_extract_without_path; | 392 | int opt_extract_without_path; |
393 | int opt_overwrite; | 393 | int opt_overwrite; |
394 | const char* password; | 394 | const char* password; |
395 | { | 395 | { |
396 | uLong i; | 396 | uLong i; |
397 | unz_global_info gi; | 397 | unz_global_info gi; |
398 | int err; | 398 | int err; |
399 | FILE* fout=NULL; | 399 | FILE* fout=NULL; |
400 | 400 | ||
401 | err = unzGetGlobalInfo (uf,&gi); | 401 | err = unzGetGlobalInfo (uf,&gi); |
402 | if (err!=UNZ_OK) | 402 | if (err!=UNZ_OK) |
403 | printf("error %d with zipfile in unzGetGlobalInfo \n",err); | 403 | printf("error %d with zipfile in unzGetGlobalInfo \n",err); |
404 | 404 | ||
405 | for (i=0;i<gi.number_entry;i++) | 405 | for (i=0;i<gi.number_entry;i++) |
406 | { | 406 | { |
407 | if (do_extract_currentfile(uf,&opt_extract_without_path, | 407 | if (do_extract_currentfile(uf,&opt_extract_without_path, |
408 | &opt_overwrite, | 408 | &opt_overwrite, |
409 | password) != UNZ_OK) | 409 | password) != UNZ_OK) |
410 | break; | 410 | break; |
411 | 411 | ||
412 | if ((i+1)<gi.number_entry) | 412 | if ((i+1)<gi.number_entry) |
413 | { | 413 | { |
414 | err = unzGoToNextFile(uf); | 414 | err = unzGoToNextFile(uf); |
415 | if (err!=UNZ_OK) | 415 | if (err!=UNZ_OK) |
416 | { | 416 | { |
417 | printf("error %d with zipfile in unzGoToNextFile\n",err); | 417 | printf("error %d with zipfile in unzGoToNextFile\n",err); |
418 | break; | 418 | break; |
419 | } | 419 | } |
420 | } | 420 | } |
421 | } | 421 | } |
422 | 422 | ||
423 | return 0; | 423 | return 0; |
424 | } | 424 | } |
425 | 425 | ||
426 | int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password) | 426 | int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password) |
427 | unzFile uf; | 427 | unzFile uf; |
428 | const char* filename; | 428 | const char* filename; |
429 | int opt_extract_without_path; | 429 | int opt_extract_without_path; |
430 | int opt_overwrite; | 430 | int opt_overwrite; |
431 | const char* password; | 431 | const char* password; |
432 | { | 432 | { |
433 | int err = UNZ_OK; | 433 | int err = UNZ_OK; |
434 | if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK) | 434 | if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK) |
435 | { | 435 | { |
436 | printf("file %s not found in the zipfile\n",filename); | 436 | printf("file %s not found in the zipfile\n",filename); |
437 | return 2; | 437 | return 2; |
438 | } | 438 | } |
439 | 439 | ||
440 | if (do_extract_currentfile(uf,&opt_extract_without_path, | 440 | if (do_extract_currentfile(uf,&opt_extract_without_path, |
441 | &opt_overwrite, | 441 | &opt_overwrite, |
442 | password) == UNZ_OK) | 442 | password) == UNZ_OK) |
443 | return 0; | 443 | return 0; |
444 | else | 444 | else |
445 | return 1; | 445 | return 1; |
446 | } | 446 | } |
447 | 447 | ||
448 | 448 | ||
449 | int main(argc,argv) | 449 | int main(argc,argv) |
450 | int argc; | 450 | int argc; |
451 | char *argv[]; | 451 | char *argv[]; |
452 | { | 452 | { |
453 | const char *zipfilename=NULL; | 453 | const char *zipfilename=NULL; |
454 | const char *filename_to_extract=NULL; | 454 | const char *filename_to_extract=NULL; |
455 | const char *password=NULL; | 455 | const char *password=NULL; |
456 | char filename_try[MAXFILENAME+16] = ""; | 456 | char filename_try[MAXFILENAME+16] = ""; |
457 | int i; | 457 | int i; |
458 | int opt_do_list=0; | 458 | int opt_do_list=0; |
459 | int opt_do_extract=1; | 459 | int opt_do_extract=1; |
460 | int opt_do_extract_withoutpath=0; | 460 | int opt_do_extract_withoutpath=0; |
461 | int opt_overwrite=0; | 461 | int opt_overwrite=0; |
462 | unzFile uf=NULL; | 462 | unzFile uf=NULL; |
463 | 463 | ||
464 | do_banner(); | 464 | do_banner(); |
465 | if (argc==1) | 465 | if (argc==1) |
466 | { | 466 | { |
467 | do_help(); | 467 | do_help(); |
468 | return 0; | 468 | return 0; |
469 | } | 469 | } |
470 | else | 470 | else |
471 | { | 471 | { |
472 | for (i=1;i<argc;i++) | 472 | for (i=1;i<argc;i++) |
473 | { | 473 | { |
474 | if ((*argv[i])=='-') | 474 | if ((*argv[i])=='-') |
475 | { | 475 | { |
476 | const char *p=argv[i]+1; | 476 | const char *p=argv[i]+1; |
477 | 477 | ||
478 | while ((*p)!='\0') | 478 | while ((*p)!='\0') |
479 | { | 479 | { |
480 | char c=*(p++);; | 480 | char c=*(p++);; |
481 | if ((c=='l') || (c=='L')) | 481 | if ((c=='l') || (c=='L')) |
482 | opt_do_list = 1; | 482 | opt_do_list = 1; |
483 | if ((c=='v') || (c=='V')) | 483 | if ((c=='v') || (c=='V')) |
484 | opt_do_list = 1; | 484 | opt_do_list = 1; |
485 | if ((c=='x') || (c=='X')) | 485 | if ((c=='x') || (c=='X')) |
486 | opt_do_extract = 1; | 486 | opt_do_extract = 1; |
487 | if ((c=='e') || (c=='E')) | 487 | if ((c=='e') || (c=='E')) |
488 | opt_do_extract = opt_do_extract_withoutpath = 1; | 488 | opt_do_extract = opt_do_extract_withoutpath = 1; |
489 | if ((c=='o') || (c=='O')) | 489 | if ((c=='o') || (c=='O')) |
490 | opt_overwrite=1; | 490 | opt_overwrite=1; |
491 | if (((c=='p') || (c=='P')) && (i+1<argc)) | 491 | if (((c=='p') || (c=='P')) && (i+1<argc)) |
492 | { | 492 | { |
493 | password=argv[i+1]; | 493 | password=argv[i+1]; |
494 | i++; | 494 | i++; |
495 | } | 495 | } |
496 | } | 496 | } |
497 | } | 497 | } |
498 | else | 498 | else |
499 | { | 499 | { |
500 | if (zipfilename == NULL) | 500 | if (zipfilename == NULL) |
501 | zipfilename = argv[i]; | 501 | zipfilename = argv[i]; |
502 | else if (filename_to_extract==NULL) | 502 | else if (filename_to_extract==NULL) |
503 | filename_to_extract = argv[i] ; | 503 | filename_to_extract = argv[i] ; |
504 | } | 504 | } |
505 | } | 505 | } |
506 | } | 506 | } |
507 | 507 | ||
508 | if (zipfilename!=NULL) | 508 | if (zipfilename!=NULL) |
509 | { | 509 | { |
510 | 510 | ||
511 | #ifdef USEWIN32IOAPI | 511 | # ifdef USEWIN32IOAPI |
512 | zlib_filefunc_def ffunc; | 512 | zlib_filefunc_def ffunc; |
513 | #endif | 513 | # endif |
514 | 514 | ||
515 | strncpy(filename_try, zipfilename,MAXFILENAME-1); | 515 | strncpy(filename_try, zipfilename,MAXFILENAME-1); |
516 | /* strncpy doesnt append the trailing NULL, of the string is too long. */ | 516 | /* strncpy doesnt append the trailing NULL, of the string is too long. */ |
517 | filename_try[ MAXFILENAME ] = '\0'; | 517 | filename_try[ MAXFILENAME ] = '\0'; |
518 | 518 | ||
519 | #ifdef USEWIN32IOAPI | 519 | # ifdef USEWIN32IOAPI |
520 | fill_win32_filefunc(&ffunc); | 520 | fill_win32_filefunc(&ffunc); |
521 | uf = unzOpen2(zipfilename,&ffunc); | 521 | uf = unzOpen2(zipfilename,&ffunc); |
522 | #else | 522 | # else |
523 | uf = unzOpen(zipfilename); | 523 | uf = unzOpen(zipfilename); |
524 | #endif | 524 | # endif |
525 | if (uf==NULL) | 525 | if (uf==NULL) |
526 | { | 526 | { |
527 | strcat(filename_try,".zip"); | 527 | strcat(filename_try,".zip"); |
528 | #ifdef USEWIN32IOAPI | 528 | # ifdef USEWIN32IOAPI |
529 | uf = unzOpen2(filename_try,&ffunc); | 529 | uf = unzOpen2(filename_try,&ffunc); |
530 | #else | 530 | # else |
531 | uf = unzOpen(filename_try); | 531 | uf = unzOpen(filename_try); |
532 | #endif | 532 | # endif |
533 | } | 533 | } |
534 | } | 534 | } |
535 | 535 | ||
536 | if (uf==NULL) | 536 | if (uf==NULL) |
537 | { | 537 | { |
538 | printf("Cannot open %s or %s.zip\n",zipfilename,zipfilename); | 538 | printf("Cannot open %s or %s.zip\n",zipfilename,zipfilename); |
539 | return 1; | 539 | return 1; |
540 | } | 540 | } |
541 | printf("%s opened\n",filename_try); | 541 | printf("%s opened\n",filename_try); |
542 | 542 | ||
543 | if (opt_do_list==1) | 543 | if (opt_do_list==1) |
544 | return do_list(uf); | 544 | return do_list(uf); |
545 | else if (opt_do_extract==1) | 545 | else if (opt_do_extract==1) |
546 | { | 546 | { |
547 | if (filename_to_extract == NULL) | 547 | if (filename_to_extract == NULL) |
548 | return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,password); | 548 | return do_extract(uf,opt_do_extract_withoutpath,opt_overwrite,password); |
549 | else | 549 | else |
550 | return do_extract_onefile(uf,filename_to_extract, | 550 | return do_extract_onefile(uf,filename_to_extract, |
551 | opt_do_extract_withoutpath,opt_overwrite,password); | 551 | opt_do_extract_withoutpath,opt_overwrite,password); |
552 | } | 552 | } |
553 | unzCloseCurrentFile(uf); | 553 | unzCloseCurrentFile(uf); |
554 | 554 | ||
555 | return 0; | 555 | return 0; |
556 | } | 556 | } |
diff --git a/contrib/minizip/minizip.c b/contrib/minizip/minizip.c index 79e541d..7e2ce36 100644 --- a/contrib/minizip/minizip.c +++ b/contrib/minizip/minizip.c | |||
@@ -1,397 +1,397 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include <time.h> | 4 | #include <time.h> |
5 | #include <errno.h> | 5 | #include <errno.h> |
6 | #include <fcntl.h> | 6 | #include <fcntl.h> |
7 | 7 | ||
8 | #ifdef unix | 8 | #ifdef unix |
9 | # include <unistd.h> | 9 | # include <unistd.h> |
10 | # include <utime.h> | 10 | # include <utime.h> |
11 | # include <sys/types.h> | 11 | # include <sys/types.h> |
12 | # include <sys/stat.h> | 12 | # include <sys/stat.h> |
13 | #else | 13 | #else |
14 | # include <direct.h> | 14 | # include <direct.h> |
15 | # include <io.h> | 15 | # include <io.h> |
16 | #endif | 16 | #endif |
17 | 17 | ||
18 | #include "zip.h" | 18 | #include "zip.h" |
19 | 19 | ||
20 | #ifdef WIN32 | 20 | #ifdef WIN32 |
21 | #define USEWIN32IOAPI | 21 | #define USEWIN32IOAPI |
22 | #include "iowin32.h" | 22 | #include "iowin32.h" |
23 | #endif | 23 | #endif |
24 | 24 | ||
25 | 25 | ||
26 | 26 | ||
27 | #define WRITEBUFFERSIZE (16384) | 27 | #define WRITEBUFFERSIZE (16384) |
28 | #define MAXFILENAME (256) | 28 | #define MAXFILENAME (256) |
29 | 29 | ||
30 | #ifdef WIN32 | 30 | #ifdef WIN32 |
31 | uLong filetime(f, tmzip, dt) | 31 | uLong filetime(f, tmzip, dt) |
32 | char *f; /* name of file to get info on */ | 32 | char *f; /* name of file to get info on */ |
33 | tm_zip *tmzip; /* return value: access, modific. and creation times */ | 33 | tm_zip *tmzip; /* return value: access, modific. and creation times */ |
34 | uLong *dt; /* dostime */ | 34 | uLong *dt; /* dostime */ |
35 | { | 35 | { |
36 | int ret = 0; | 36 | int ret = 0; |
37 | { | 37 | { |
38 | FILETIME ftLocal; | 38 | FILETIME ftLocal; |
39 | HANDLE hFind; | 39 | HANDLE hFind; |
40 | WIN32_FIND_DATA ff32; | 40 | WIN32_FIND_DATA ff32; |
41 | 41 | ||
42 | hFind = FindFirstFile(f,&ff32); | 42 | hFind = FindFirstFile(f,&ff32); |
43 | if (hFind != INVALID_HANDLE_VALUE) | 43 | if (hFind != INVALID_HANDLE_VALUE) |
44 | { | 44 | { |
45 | FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal); | 45 | FileTimeToLocalFileTime(&(ff32.ftLastWriteTime),&ftLocal); |
46 | FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0); | 46 | FileTimeToDosDateTime(&ftLocal,((LPWORD)dt)+1,((LPWORD)dt)+0); |
47 | FindClose(hFind); | 47 | FindClose(hFind); |
48 | ret = 1; | 48 | ret = 1; |
49 | } | 49 | } |
50 | } | 50 | } |
51 | return ret; | 51 | return ret; |
52 | } | 52 | } |
53 | #else | 53 | #else |
54 | #ifdef unix | 54 | #ifdef unix |
55 | uLong filetime(f, tmzip, dt) | 55 | uLong filetime(f, tmzip, dt) |
56 | char *f; /* name of file to get info on */ | 56 | char *f; /* name of file to get info on */ |
57 | tm_zip *tmzip; /* return value: access, modific. and creation times */ | 57 | tm_zip *tmzip; /* return value: access, modific. and creation times */ |
58 | uLong *dt; /* dostime */ | 58 | uLong *dt; /* dostime */ |
59 | { | 59 | { |
60 | int ret=0; | 60 | int ret=0; |
61 | struct stat s; /* results of stat() */ | 61 | struct stat s; /* results of stat() */ |
62 | struct tm* filedate; | 62 | struct tm* filedate; |
63 | time_t tm_t=0; | 63 | time_t tm_t=0; |
64 | 64 | ||
65 | if (strcmp(f,"-")!=0) | 65 | if (strcmp(f,"-")!=0) |
66 | { | 66 | { |
67 | char name[MAXFILENAME+1]; | 67 | char name[MAXFILENAME+1]; |
68 | int len = strlen(f); | 68 | int len = strlen(f); |
69 | 69 | ||
70 | strncpy(name, f,MAXFILENAME-1); | 70 | strncpy(name, f,MAXFILENAME-1); |
71 | /* strncpy doesnt append the trailing NULL, of the string is too long. */ | 71 | /* strncpy doesnt append the trailing NULL, of the string is too long. */ |
72 | name[ MAXFILENAME ] = '\0'; | 72 | name[ MAXFILENAME ] = '\0'; |
73 | 73 | ||
74 | if (name[len - 1] == '/') | 74 | if (name[len - 1] == '/') |
75 | name[len - 1] = '\0'; | 75 | name[len - 1] = '\0'; |
76 | /* not all systems allow stat'ing a file with / appended */ | 76 | /* not all systems allow stat'ing a file with / appended */ |
77 | if (stat(name,&s)==0) | 77 | if (stat(name,&s)==0) |
78 | { | 78 | { |
79 | tm_t = s.st_mtime; | 79 | tm_t = s.st_mtime; |
80 | ret = 1; | 80 | ret = 1; |
81 | } | 81 | } |
82 | } | 82 | } |
83 | filedate = localtime(&tm_t); | 83 | filedate = localtime(&tm_t); |
84 | 84 | ||
85 | tmzip->tm_sec = filedate->tm_sec; | 85 | tmzip->tm_sec = filedate->tm_sec; |
86 | tmzip->tm_min = filedate->tm_min; | 86 | tmzip->tm_min = filedate->tm_min; |
87 | tmzip->tm_hour = filedate->tm_hour; | 87 | tmzip->tm_hour = filedate->tm_hour; |
88 | tmzip->tm_mday = filedate->tm_mday; | 88 | tmzip->tm_mday = filedate->tm_mday; |
89 | tmzip->tm_mon = filedate->tm_mon ; | 89 | tmzip->tm_mon = filedate->tm_mon ; |
90 | tmzip->tm_year = filedate->tm_year; | 90 | tmzip->tm_year = filedate->tm_year; |
91 | 91 | ||
92 | return ret; | 92 | return ret; |
93 | } | 93 | } |
94 | #else | 94 | #else |
95 | uLong filetime(f, tmzip, dt) | 95 | uLong filetime(f, tmzip, dt) |
96 | char *f; /* name of file to get info on */ | 96 | char *f; /* name of file to get info on */ |
97 | tm_zip *tmzip; /* return value: access, modific. and creation times */ | 97 | tm_zip *tmzip; /* return value: access, modific. and creation times */ |
98 | uLong *dt; /* dostime */ | 98 | uLong *dt; /* dostime */ |
99 | { | 99 | { |
100 | return 0; | 100 | return 0; |
101 | } | 101 | } |
102 | #endif | 102 | #endif |
103 | #endif | 103 | #endif |
104 | 104 | ||
105 | 105 | ||
106 | 106 | ||
107 | 107 | ||
108 | int check_exist_file(filename) | 108 | int check_exist_file(filename) |
109 | const char* filename; | 109 | const char* filename; |
110 | { | 110 | { |
111 | FILE* ftestexist; | 111 | FILE* ftestexist; |
112 | int ret = 1; | 112 | int ret = 1; |
113 | ftestexist = fopen(filename,"rb"); | 113 | ftestexist = fopen(filename,"rb"); |
114 | if (ftestexist==NULL) | 114 | if (ftestexist==NULL) |
115 | ret = 0; | 115 | ret = 0; |
116 | else | 116 | else |
117 | fclose(ftestexist); | 117 | fclose(ftestexist); |
118 | return ret; | 118 | return ret; |
119 | } | 119 | } |
120 | 120 | ||
121 | void do_banner() | 121 | void do_banner() |
122 | { | 122 | { |
123 | printf("MiniZip 0.22, demo of zLib + Zip package written by Gilles Vollant\n"); | 123 | printf("MiniZip 0.22, demo of zLib + Zip package written by Gilles Vollant\n"); |
124 | printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); | 124 | printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); |
125 | } | 125 | } |
126 | 126 | ||
127 | void do_help() | 127 | void do_help() |
128 | { | 128 | { |
129 | printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] file.zip [files_to_add]\n\n" \ | 129 | printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] file.zip [files_to_add]\n\n" \ |
130 | " -o Overwrite existing file.zip\n" \ | 130 | " -o Overwrite existing file.zip\n" \ |
131 | " -a Append to existing file.zip\n" \ | 131 | " -a Append to existing file.zip\n" \ |
132 | " -0 Store only\n" \ | 132 | " -0 Store only\n" \ |
133 | " -1 Compress faster\n" \ | 133 | " -1 Compress faster\n" \ |
134 | " -9 Compress better\n\n"); | 134 | " -9 Compress better\n\n"); |
135 | } | 135 | } |
136 | 136 | ||
137 | /* calculate the CRC32 of a file, | 137 | /* calculate the CRC32 of a file, |
138 | because to encrypt a file, we need known the CRC32 of the file before */ | 138 | because to encrypt a file, we need known the CRC32 of the file before */ |
139 | int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc) | 139 | int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc) |
140 | { | 140 | { |
141 | unsigned long calculate_crc=0; | 141 | unsigned long calculate_crc=0; |
142 | int err=ZIP_OK; | 142 | int err=ZIP_OK; |
143 | FILE * fin = fopen(filenameinzip,"rb"); | 143 | FILE * fin = fopen(filenameinzip,"rb"); |
144 | unsigned long size_read = 0; | 144 | unsigned long size_read = 0; |
145 | unsigned long total_read = 0; | 145 | unsigned long total_read = 0; |
146 | if (fin==NULL) | 146 | if (fin==NULL) |
147 | { | 147 | { |
148 | err = ZIP_ERRNO; | 148 | err = ZIP_ERRNO; |
149 | } | 149 | } |
150 | 150 | ||
151 | if (err == ZIP_OK) | 151 | if (err == ZIP_OK) |
152 | do | 152 | do |
153 | { | 153 | { |
154 | err = ZIP_OK; | 154 | err = ZIP_OK; |
155 | size_read = (int)fread(buf,1,size_buf,fin); | 155 | size_read = (int)fread(buf,1,size_buf,fin); |
156 | if (size_read < size_buf) | 156 | if (size_read < size_buf) |
157 | if (feof(fin)==0) | 157 | if (feof(fin)==0) |
158 | { | 158 | { |
159 | printf("error in reading %s\n",filenameinzip); | 159 | printf("error in reading %s\n",filenameinzip); |
160 | err = ZIP_ERRNO; | 160 | err = ZIP_ERRNO; |
161 | } | 161 | } |
162 | 162 | ||
163 | if (size_read>0) | 163 | if (size_read>0) |
164 | calculate_crc = crc32(calculate_crc,buf,size_read); | 164 | calculate_crc = crc32(calculate_crc,buf,size_read); |
165 | total_read += size_read; | 165 | total_read += size_read; |
166 | 166 | ||
167 | } while ((err == ZIP_OK) && (size_read>0)); | 167 | } while ((err == ZIP_OK) && (size_read>0)); |
168 | 168 | ||
169 | if (fin) | 169 | if (fin) |
170 | fclose(fin); | 170 | fclose(fin); |
171 | 171 | ||
172 | *result_crc=calculate_crc; | 172 | *result_crc=calculate_crc; |
173 | printf("file %s crc %x\n",filenameinzip,calculate_crc); | 173 | printf("file %s crc %x\n",filenameinzip,calculate_crc); |
174 | return err; | 174 | return err; |
175 | } | 175 | } |
176 | 176 | ||
177 | int main(argc,argv) | 177 | int main(argc,argv) |
178 | int argc; | 178 | int argc; |
179 | char *argv[]; | 179 | char *argv[]; |
180 | { | 180 | { |
181 | int i; | 181 | int i; |
182 | int opt_overwrite=0; | 182 | int opt_overwrite=0; |
183 | int opt_compress_level=Z_DEFAULT_COMPRESSION; | 183 | int opt_compress_level=Z_DEFAULT_COMPRESSION; |
184 | int zipfilenamearg = 0; | 184 | int zipfilenamearg = 0; |
185 | char filename_try[MAXFILENAME+16]; | 185 | char filename_try[MAXFILENAME+16]; |
186 | int zipok; | 186 | int zipok; |
187 | int err=0; | 187 | int err=0; |
188 | int size_buf=0; | 188 | int size_buf=0; |
189 | void* buf=NULL; | 189 | void* buf=NULL; |
190 | const char* password=NULL; | 190 | const char* password=NULL; |
191 | 191 | ||
192 | 192 | ||
193 | do_banner(); | 193 | do_banner(); |
194 | if (argc==1) | 194 | if (argc==1) |
195 | { | 195 | { |
196 | do_help(); | 196 | do_help(); |
197 | return 0; | 197 | return 0; |
198 | } | 198 | } |
199 | else | 199 | else |
200 | { | 200 | { |
201 | for (i=1;i<argc;i++) | 201 | for (i=1;i<argc;i++) |
202 | { | 202 | { |
203 | if ((*argv[i])=='-') | 203 | if ((*argv[i])=='-') |
204 | { | 204 | { |
205 | const char *p=argv[i]+1; | 205 | const char *p=argv[i]+1; |
206 | 206 | ||
207 | while ((*p)!='\0') | 207 | while ((*p)!='\0') |
208 | { | 208 | { |
209 | char c=*(p++);; | 209 | char c=*(p++);; |
210 | if ((c=='o') || (c=='O')) | 210 | if ((c=='o') || (c=='O')) |
211 | opt_overwrite = 1; | 211 | opt_overwrite = 1; |
212 | if ((c=='a') || (c=='A')) | 212 | if ((c=='a') || (c=='A')) |
213 | opt_overwrite = 2; | 213 | opt_overwrite = 2; |
214 | if ((c>='0') && (c<='9')) | 214 | if ((c>='0') && (c<='9')) |
215 | opt_compress_level = c-'0'; | 215 | opt_compress_level = c-'0'; |
216 | 216 | ||
217 | if (((c=='p') || (c=='P')) && (i+1<argc)) | 217 | if (((c=='p') || (c=='P')) && (i+1<argc)) |
218 | { | 218 | { |
219 | password=argv[i+1]; | 219 | password=argv[i+1]; |
220 | i++; | 220 | i++; |
221 | } | 221 | } |
222 | } | 222 | } |
223 | } | 223 | } |
224 | else | 224 | else |
225 | if (zipfilenamearg == 0) | 225 | if (zipfilenamearg == 0) |
226 | zipfilenamearg = i ; | 226 | zipfilenamearg = i ; |
227 | } | 227 | } |
228 | } | 228 | } |
229 | 229 | ||
230 | size_buf = WRITEBUFFERSIZE; | 230 | size_buf = WRITEBUFFERSIZE; |
231 | buf = (void*)malloc(size_buf); | 231 | buf = (void*)malloc(size_buf); |
232 | if (buf==NULL) | 232 | if (buf==NULL) |
233 | { | 233 | { |
234 | printf("Error allocating memory\n"); | 234 | printf("Error allocating memory\n"); |
235 | return ZIP_INTERNALERROR; | 235 | return ZIP_INTERNALERROR; |
236 | } | 236 | } |
237 | 237 | ||
238 | if (zipfilenamearg==0) | 238 | if (zipfilenamearg==0) |
239 | zipok=0; | 239 | zipok=0; |
240 | else | 240 | else |
241 | { | 241 | { |
242 | int i,len; | 242 | int i,len; |
243 | int dot_found=0; | 243 | int dot_found=0; |
244 | 244 | ||
245 | zipok = 1 ; | 245 | zipok = 1 ; |
246 | strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1); | 246 | strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1); |
247 | /* strncpy doesnt append the trailing NULL, of the string is too long. */ | 247 | /* strncpy doesnt append the trailing NULL, of the string is too long. */ |
248 | filename_try[ MAXFILENAME ] = '\0'; | 248 | filename_try[ MAXFILENAME ] = '\0'; |
249 | 249 | ||
250 | len=(int)strlen(filename_try); | 250 | len=(int)strlen(filename_try); |
251 | for (i=0;i<len;i++) | 251 | for (i=0;i<len;i++) |
252 | if (filename_try[i]=='.') | 252 | if (filename_try[i]=='.') |
253 | dot_found=1; | 253 | dot_found=1; |
254 | 254 | ||
255 | if (dot_found==0) | 255 | if (dot_found==0) |
256 | strcat(filename_try,".zip"); | 256 | strcat(filename_try,".zip"); |
257 | 257 | ||
258 | if (opt_overwrite==2) | 258 | if (opt_overwrite==2) |
259 | { | 259 | { |
260 | /* if the file don't exist, we not append file */ | 260 | /* if the file don't exist, we not append file */ |
261 | if (check_exist_file(filename_try)==0) | 261 | if (check_exist_file(filename_try)==0) |
262 | opt_overwrite=1; | 262 | opt_overwrite=1; |
263 | } | 263 | } |
264 | else | 264 | else |
265 | if (opt_overwrite==0) | 265 | if (opt_overwrite==0) |
266 | if (check_exist_file(filename_try)!=0) | 266 | if (check_exist_file(filename_try)!=0) |
267 | { | 267 | { |
268 | char rep=0; | 268 | char rep=0; |
269 | do | 269 | do |
270 | { | 270 | { |
271 | char answer[128]; | 271 | char answer[128]; |
272 | printf("The file %s exist. Overwrite ? [y]es, [n]o, [a]ppend : ",filename_try); | 272 | printf("The file %s exist. Overwrite ? [y]es, [n]o, [a]ppend : ",filename_try); |
273 | scanf("%1s",answer); | 273 | scanf("%1s",answer); |
274 | rep = answer[0] ; | 274 | rep = answer[0] ; |
275 | if ((rep>='a') && (rep<='z')) | 275 | if ((rep>='a') && (rep<='z')) |
276 | rep -= 0x20; | 276 | rep -= 0x20; |
277 | } | 277 | } |
278 | while ((rep!='Y') && (rep!='N') && (rep!='A')); | 278 | while ((rep!='Y') && (rep!='N') && (rep!='A')); |
279 | if (rep=='N') | 279 | if (rep=='N') |
280 | zipok = 0; | 280 | zipok = 0; |
281 | if (rep=='A') | 281 | if (rep=='A') |
282 | opt_overwrite = 2; | 282 | opt_overwrite = 2; |
283 | } | 283 | } |
284 | } | 284 | } |
285 | 285 | ||
286 | if (zipok==1) | 286 | if (zipok==1) |
287 | { | 287 | { |
288 | zipFile zf; | 288 | zipFile zf; |
289 | int errclose; | 289 | int errclose; |
290 | #ifdef USEWIN32IOAPI | 290 | # ifdef USEWIN32IOAPI |
291 | zlib_filefunc_def ffunc; | 291 | zlib_filefunc_def ffunc; |
292 | fill_win32_filefunc(&ffunc); | 292 | fill_win32_filefunc(&ffunc); |
293 | zf = zipOpen2(filename_try,(opt_overwrite==2) ? 2 : 0,NULL,&ffunc); | 293 | zf = zipOpen2(filename_try,(opt_overwrite==2) ? 2 : 0,NULL,&ffunc); |
294 | #else | 294 | # else |
295 | zf = zipOpen(filename_try,(opt_overwrite==2) ? 2 : 0); | 295 | zf = zipOpen(filename_try,(opt_overwrite==2) ? 2 : 0); |
296 | #endif | 296 | # endif |
297 | 297 | ||
298 | if (zf == NULL) | 298 | if (zf == NULL) |
299 | { | 299 | { |
300 | printf("error opening %s\n",filename_try); | 300 | printf("error opening %s\n",filename_try); |
301 | err= ZIP_ERRNO; | 301 | err= ZIP_ERRNO; |
302 | } | 302 | } |
303 | else | 303 | else |
304 | printf("creating %s\n",filename_try); | 304 | printf("creating %s\n",filename_try); |
305 | 305 | ||
306 | for (i=zipfilenamearg+1;(i<argc) && (err==ZIP_OK);i++) | 306 | for (i=zipfilenamearg+1;(i<argc) && (err==ZIP_OK);i++) |
307 | { | 307 | { |
308 | if (((*(argv[i]))!='-') && ((*(argv[i]))!='/')) | 308 | if (((*(argv[i]))!='-') && ((*(argv[i]))!='/')) |
309 | { | 309 | { |
310 | FILE * fin; | 310 | FILE * fin; |
311 | int size_read; | 311 | int size_read; |
312 | const char* filenameinzip = argv[i]; | 312 | const char* filenameinzip = argv[i]; |
313 | zip_fileinfo zi; | 313 | zip_fileinfo zi; |
314 | unsigned long crcFile=0; | 314 | unsigned long crcFile=0; |
315 | 315 | ||
316 | zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour = | 316 | zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour = |
317 | zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0; | 317 | zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0; |
318 | zi.dosDate = 0; | 318 | zi.dosDate = 0; |
319 | zi.internal_fa = 0; | 319 | zi.internal_fa = 0; |
320 | zi.external_fa = 0; | 320 | zi.external_fa = 0; |
321 | filetime(filenameinzip,&zi.tmz_date,&zi.dosDate); | 321 | filetime(filenameinzip,&zi.tmz_date,&zi.dosDate); |
322 | 322 | ||
323 | /* | 323 | /* |
324 | err = zipOpenNewFileInZip(zf,filenameinzip,&zi, | 324 | err = zipOpenNewFileInZip(zf,filenameinzip,&zi, |
325 | NULL,0,NULL,0,NULL / * comment * /, | 325 | NULL,0,NULL,0,NULL / * comment * /, |
326 | (opt_compress_level != 0) ? Z_DEFLATED : 0, | 326 | (opt_compress_level != 0) ? Z_DEFLATED : 0, |
327 | opt_compress_level); | 327 | opt_compress_level); |
328 | */ | 328 | */ |
329 | if ((password != NULL) && (err==ZIP_OK)) | 329 | if ((password != NULL) && (err==ZIP_OK)) |
330 | err = getFileCrc(filenameinzip,buf,size_buf,&crcFile); | 330 | err = getFileCrc(filenameinzip,buf,size_buf,&crcFile); |
331 | 331 | ||
332 | err = zipOpenNewFileInZip3(zf,filenameinzip,&zi, | 332 | err = zipOpenNewFileInZip3(zf,filenameinzip,&zi, |
333 | NULL,0,NULL,0,NULL /* comment*/, | 333 | NULL,0,NULL,0,NULL /* comment*/, |
334 | (opt_compress_level != 0) ? Z_DEFLATED : 0, | 334 | (opt_compress_level != 0) ? Z_DEFLATED : 0, |
335 | opt_compress_level,0, | 335 | opt_compress_level,0, |
336 | /* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, */ | 336 | /* -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, */ |
337 | -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, | 337 | -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, |
338 | password,crcFile); | 338 | password,crcFile); |
339 | 339 | ||
340 | if (err != ZIP_OK) | 340 | if (err != ZIP_OK) |
341 | printf("error in opening %s in zipfile\n",filenameinzip); | 341 | printf("error in opening %s in zipfile\n",filenameinzip); |
342 | else | 342 | else |
343 | { | 343 | { |
344 | fin = fopen(filenameinzip,"rb"); | 344 | fin = fopen(filenameinzip,"rb"); |
345 | if (fin==NULL) | 345 | if (fin==NULL) |
346 | { | 346 | { |
347 | err=ZIP_ERRNO; | 347 | err=ZIP_ERRNO; |
348 | printf("error in opening %s for reading\n",filenameinzip); | 348 | printf("error in opening %s for reading\n",filenameinzip); |
349 | } | 349 | } |
350 | } | 350 | } |
351 | 351 | ||
352 | if (err == ZIP_OK) | 352 | if (err == ZIP_OK) |
353 | do | 353 | do |
354 | { | 354 | { |
355 | err = ZIP_OK; | 355 | err = ZIP_OK; |
356 | size_read = (int)fread(buf,1,size_buf,fin); | 356 | size_read = (int)fread(buf,1,size_buf,fin); |
357 | if (size_read < size_buf) | 357 | if (size_read < size_buf) |
358 | if (feof(fin)==0) | 358 | if (feof(fin)==0) |
359 | { | 359 | { |
360 | printf("error in reading %s\n",filenameinzip); | 360 | printf("error in reading %s\n",filenameinzip); |
361 | err = ZIP_ERRNO; | 361 | err = ZIP_ERRNO; |
362 | } | 362 | } |
363 | 363 | ||
364 | if (size_read>0) | 364 | if (size_read>0) |
365 | { | 365 | { |
366 | err = zipWriteInFileInZip (zf,buf,size_read); | 366 | err = zipWriteInFileInZip (zf,buf,size_read); |
367 | if (err<0) | 367 | if (err<0) |
368 | { | 368 | { |
369 | printf("error in writing %s in the zipfile\n", | 369 | printf("error in writing %s in the zipfile\n", |
370 | filenameinzip); | 370 | filenameinzip); |
371 | } | 371 | } |
372 | 372 | ||
373 | } | 373 | } |
374 | } while ((err == ZIP_OK) && (size_read>0)); | 374 | } while ((err == ZIP_OK) && (size_read>0)); |
375 | 375 | ||
376 | if (fin) | 376 | if (fin) |
377 | fclose(fin); | 377 | fclose(fin); |
378 | 378 | ||
379 | if (err<0) | 379 | if (err<0) |
380 | err=ZIP_ERRNO; | 380 | err=ZIP_ERRNO; |
381 | else | 381 | else |
382 | { | 382 | { |
383 | err = zipCloseFileInZip(zf); | 383 | err = zipCloseFileInZip(zf); |
384 | if (err!=ZIP_OK) | 384 | if (err!=ZIP_OK) |
385 | printf("error in closing %s in the zipfile\n", | 385 | printf("error in closing %s in the zipfile\n", |
386 | filenameinzip); | 386 | filenameinzip); |
387 | } | 387 | } |
388 | } | 388 | } |
389 | } | 389 | } |
390 | errclose = zipClose(zf,NULL); | 390 | errclose = zipClose(zf,NULL); |
391 | if (errclose != ZIP_OK) | 391 | if (errclose != ZIP_OK) |
392 | printf("error in closing %s\n",filename_try); | 392 | printf("error in closing %s\n",filename_try); |
393 | } | 393 | } |
394 | 394 | ||
395 | free(buf); | 395 | free(buf); |
396 | return 0; | 396 | return 0; |
397 | } | 397 | } |
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c index 96f9f33..81c8c28 100644 --- a/contrib/minizip/unzip.c +++ b/contrib/minizip/unzip.c | |||
@@ -1,1546 +1,1546 @@ | |||
1 | /* unzip.c -- IO for uncompress .zip files using zlib | 1 | /* unzip.c -- IO for uncompress .zip files using zlib |
2 | Version 0.22, May 19th, 2003 | 2 | Version 0.22, May 19th, 2003 |
3 | 3 | ||
4 | Copyright (C) 1998-2003 Gilles Vollant | 4 | Copyright (C) 1998-2003 Gilles Vollant |
5 | 5 | ||
6 | Read unzip.h for more info | 6 | Read unzip.h for more info |
7 | */ | 7 | */ |
8 | 8 | ||
9 | /* Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of | 9 | /* Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of |
10 | compatibility with older software. The following is from the original crypt.c. Code | 10 | compatibility with older software. The following is from the original crypt.c. Code |
11 | woven in by Terry Thorsen 1/2003. | 11 | woven in by Terry Thorsen 1/2003. |
12 | */ | 12 | */ |
13 | /* | 13 | /* |
14 | Copyright (c) 1990-2000 Info-ZIP. All rights reserved. | 14 | Copyright (c) 1990-2000 Info-ZIP. All rights reserved. |
15 | 15 | ||
16 | See the accompanying file LICENSE, version 2000-Apr-09 or later | 16 | See the accompanying file LICENSE, version 2000-Apr-09 or later |
17 | (the contents of which are also included in zip.h) for terms of use. | 17 | (the contents of which are also included in zip.h) for terms of use. |
18 | If, for some reason, all these files are missing, the Info-ZIP license | 18 | If, for some reason, all these files are missing, the Info-ZIP license |
19 | also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html | 19 | also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html |
20 | */ | 20 | */ |
21 | /* | 21 | /* |
22 | crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] | 22 | crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] |
23 | 23 | ||
24 | The encryption/decryption parts of this source code (as opposed to the | 24 | The encryption/decryption parts of this source code (as opposed to the |
25 | non-echoing password parts) were originally written in Europe. The | 25 | non-echoing password parts) were originally written in Europe. The |
26 | whole source package can be freely distributed, including from the USA. | 26 | whole source package can be freely distributed, including from the USA. |
27 | (Prior to January 2000, re-export from the US was a violation of US law.) | 27 | (Prior to January 2000, re-export from the US was a violation of US law.) |
28 | */ | 28 | */ |
29 | 29 | ||
30 | /* | 30 | /* |
31 | This encryption code is a direct transcription of the algorithm from | 31 | This encryption code is a direct transcription of the algorithm from |
32 | Roger Schlafly, described by Phil Katz in the file appnote.txt. This | 32 | Roger Schlafly, described by Phil Katz in the file appnote.txt. This |
33 | file (appnote.txt) is distributed with the PKZIP program (even in the | 33 | file (appnote.txt) is distributed with the PKZIP program (even in the |
34 | version without encryption capabilities). | 34 | version without encryption capabilities). |
35 | */ | 35 | */ |
36 | 36 | ||
37 | 37 | ||
38 | #include <stdio.h> | 38 | #include <stdio.h> |
39 | #include <stdlib.h> | 39 | #include <stdlib.h> |
40 | #include <string.h> | 40 | #include <string.h> |
41 | #include "zlib.h" | 41 | #include "zlib.h" |
42 | #include "unzip.h" | 42 | #include "unzip.h" |
43 | 43 | ||
44 | #ifdef STDC | 44 | #ifdef STDC |
45 | # include <stddef.h> | 45 | # include <stddef.h> |
46 | # include <string.h> | 46 | # include <string.h> |
47 | # include <stdlib.h> | 47 | # include <stdlib.h> |
48 | #endif | 48 | #endif |
49 | #ifdef NO_ERRNO_H | 49 | #ifdef NO_ERRNO_H |
50 | extern int errno; | 50 | extern int errno; |
51 | #else | 51 | #else |
52 | # include <errno.h> | 52 | # include <errno.h> |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | 55 | ||
56 | #ifndef local | 56 | #ifndef local |
57 | # define local static | 57 | # define local static |
58 | #endif | 58 | #endif |
59 | /* compile with -Dlocal if your debugger can't find static symbols */ | 59 | /* compile with -Dlocal if your debugger can't find static symbols */ |
60 | 60 | ||
61 | 61 | ||
62 | 62 | #ifndef CASESENSITIVITYDEFAULT_NO | |
63 | #if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) && \ | 63 | # if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) |
64 | !defined(CASESENSITIVITYDEFAULT_NO) | 64 | # define CASESENSITIVITYDEFAULT_NO |
65 | #define CASESENSITIVITYDEFAULT_NO | 65 | # endif |
66 | #endif | 66 | #endif |
67 | 67 | ||
68 | 68 | ||
69 | #ifndef UNZ_BUFSIZE | 69 | #ifndef UNZ_BUFSIZE |
70 | #define UNZ_BUFSIZE (16384) | 70 | #define UNZ_BUFSIZE (16384) |
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | #ifndef UNZ_MAXFILENAMEINZIP | 73 | #ifndef UNZ_MAXFILENAMEINZIP |
74 | #define UNZ_MAXFILENAMEINZIP (256) | 74 | #define UNZ_MAXFILENAMEINZIP (256) |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | #ifndef ALLOC | 77 | #ifndef ALLOC |
78 | # define ALLOC(size) (malloc(size)) | 78 | # define ALLOC(size) (malloc(size)) |
79 | #endif | 79 | #endif |
80 | #ifndef TRYFREE | 80 | #ifndef TRYFREE |
81 | # define TRYFREE(p) {if (p) free(p);} | 81 | # define TRYFREE(p) {if (p) free(p);} |
82 | #endif | 82 | #endif |
83 | 83 | ||
84 | #define SIZECENTRALDIRITEM (0x2e) | 84 | #define SIZECENTRALDIRITEM (0x2e) |
85 | #define SIZEZIPLOCALHEADER (0x1e) | 85 | #define SIZEZIPLOCALHEADER (0x1e) |
86 | 86 | ||
87 | 87 | ||
88 | 88 | ||
89 | 89 | ||
90 | const char unz_copyright[] = | 90 | const char unz_copyright[] = |
91 | " unzip 0.22 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; | 91 | " unzip 0.22 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; |
92 | 92 | ||
93 | /* unz_file_info_interntal contain internal info about a file in zipfile*/ | 93 | /* unz_file_info_interntal contain internal info about a file in zipfile*/ |
94 | typedef struct unz_file_info_internal_s | 94 | typedef struct unz_file_info_internal_s |
95 | { | 95 | { |
96 | uLong offset_curfile;/* relative offset of local header 4 bytes */ | 96 | uLong offset_curfile;/* relative offset of local header 4 bytes */ |
97 | } unz_file_info_internal; | 97 | } unz_file_info_internal; |
98 | 98 | ||
99 | 99 | ||
100 | /* file_in_zip_read_info_s contain internal information about a file in zipfile, | 100 | /* file_in_zip_read_info_s contain internal information about a file in zipfile, |
101 | when reading and decompress it */ | 101 | when reading and decompress it */ |
102 | typedef struct | 102 | typedef struct |
103 | { | 103 | { |
104 | char *read_buffer; /* internal buffer for compressed data */ | 104 | char *read_buffer; /* internal buffer for compressed data */ |
105 | z_stream stream; /* zLib stream structure for inflate */ | 105 | z_stream stream; /* zLib stream structure for inflate */ |
106 | 106 | ||
107 | uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ | 107 | uLong pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ |
108 | uLong stream_initialised; /* flag set if stream structure is initialised*/ | 108 | uLong stream_initialised; /* flag set if stream structure is initialised*/ |
109 | 109 | ||
110 | uLong offset_local_extrafield;/* offset of the local extra field */ | 110 | uLong offset_local_extrafield;/* offset of the local extra field */ |
111 | uInt size_local_extrafield;/* size of the local extra field */ | 111 | uInt size_local_extrafield;/* size of the local extra field */ |
112 | uLong pos_local_extrafield; /* position in the local extra field in read*/ | 112 | uLong pos_local_extrafield; /* position in the local extra field in read*/ |
113 | 113 | ||
114 | uLong crc32; /* crc32 of all data uncompressed */ | 114 | uLong crc32; /* crc32 of all data uncompressed */ |
115 | uLong crc32_wait; /* crc32 we must obtain after decompress all */ | 115 | uLong crc32_wait; /* crc32 we must obtain after decompress all */ |
116 | uLong rest_read_compressed; /* number of byte to be decompressed */ | 116 | uLong rest_read_compressed; /* number of byte to be decompressed */ |
117 | uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ | 117 | uLong rest_read_uncompressed;/*number of byte to be obtained after decomp*/ |
118 | zlib_filefunc_def z_filefunc; | 118 | zlib_filefunc_def z_filefunc; |
119 | voidpf filestream; /* io structore of the zipfile */ | 119 | voidpf filestream; /* io structore of the zipfile */ |
120 | uLong compression_method; /* compression method (0==store) */ | 120 | uLong compression_method; /* compression method (0==store) */ |
121 | uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ | 121 | uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
122 | int raw; | 122 | int raw; |
123 | } file_in_zip_read_info_s; | 123 | } file_in_zip_read_info_s; |
124 | 124 | ||
125 | 125 | ||
126 | /* unz_s contain internal information about the zipfile | 126 | /* unz_s contain internal information about the zipfile |
127 | */ | 127 | */ |
128 | typedef struct | 128 | typedef struct |
129 | { | 129 | { |
130 | zlib_filefunc_def z_filefunc; | 130 | zlib_filefunc_def z_filefunc; |
131 | voidpf filestream; /* io structore of the zipfile */ | 131 | voidpf filestream; /* io structore of the zipfile */ |
132 | unz_global_info gi; /* public global information */ | 132 | unz_global_info gi; /* public global information */ |
133 | uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ | 133 | uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
134 | uLong num_file; /* number of the current file in the zipfile*/ | 134 | uLong num_file; /* number of the current file in the zipfile*/ |
135 | uLong pos_in_central_dir; /* pos of the current file in the central dir*/ | 135 | uLong pos_in_central_dir; /* pos of the current file in the central dir*/ |
136 | uLong current_file_ok; /* flag about the usability of the current file*/ | 136 | uLong current_file_ok; /* flag about the usability of the current file*/ |
137 | uLong central_pos; /* position of the beginning of the central dir*/ | 137 | uLong central_pos; /* position of the beginning of the central dir*/ |
138 | 138 | ||
139 | uLong size_central_dir; /* size of the central directory */ | 139 | uLong size_central_dir; /* size of the central directory */ |
140 | uLong offset_central_dir; /* offset of start of central directory with | 140 | uLong offset_central_dir; /* offset of start of central directory with |
141 | respect to the starting disk number */ | 141 | respect to the starting disk number */ |
142 | 142 | ||
143 | unz_file_info cur_file_info; /* public info about the current file in zip*/ | 143 | unz_file_info cur_file_info; /* public info about the current file in zip*/ |
144 | unz_file_info_internal cur_file_info_internal; /* private info about it*/ | 144 | unz_file_info_internal cur_file_info_internal; /* private info about it*/ |
145 | file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current | 145 | file_in_zip_read_info_s* pfile_in_zip_read; /* structure about the current |
146 | file if we are decompressing it */ | 146 | file if we are decompressing it */ |
147 | int encrypted; | 147 | int encrypted; |
148 | #ifndef NOUNCRYPT | 148 | # ifndef NOUNCRYPT |
149 | unsigned long keys[3]; /* keys defining the pseudo-random sequence */ | 149 | unsigned long keys[3]; /* keys defining the pseudo-random sequence */ |
150 | const unsigned long* pcrc_32_tab; | 150 | const unsigned long* pcrc_32_tab; |
151 | #endif | 151 | # endif |
152 | } unz_s; | 152 | } unz_s; |
153 | 153 | ||
154 | 154 | ||
155 | #ifndef NOUNCRYPT | 155 | #ifndef NOUNCRYPT |
156 | #include "crypt.h" | 156 | #include "crypt.h" |
157 | #endif | 157 | #endif |
158 | 158 | ||
159 | /* =========================================================================== | 159 | /* =========================================================================== |
160 | Read a byte from a gz_stream; update next_in and avail_in. Return EOF | 160 | Read a byte from a gz_stream; update next_in and avail_in. Return EOF |
161 | for end of file. | 161 | for end of file. |
162 | IN assertion: the stream s has been sucessfully opened for reading. | 162 | IN assertion: the stream s has been sucessfully opened for reading. |
163 | */ | 163 | */ |
164 | 164 | ||
165 | 165 | ||
166 | local int unzlocal_getByte OF(( | 166 | local int unzlocal_getByte OF(( |
167 | const zlib_filefunc_def* pzlib_filefunc_def, | 167 | const zlib_filefunc_def* pzlib_filefunc_def, |
168 | voidpf filestream, | 168 | voidpf filestream, |
169 | int *pi)); | 169 | int *pi)); |
170 | 170 | ||
171 | local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi) | 171 | local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi) |
172 | const zlib_filefunc_def* pzlib_filefunc_def; | 172 | const zlib_filefunc_def* pzlib_filefunc_def; |
173 | voidpf filestream; | 173 | voidpf filestream; |
174 | int *pi; | 174 | int *pi; |
175 | { | 175 | { |
176 | unsigned char c; | 176 | unsigned char c; |
177 | int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); | 177 | int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); |
178 | if (err==1) | 178 | if (err==1) |
179 | { | 179 | { |
180 | *pi = (int)c; | 180 | *pi = (int)c; |
181 | return UNZ_OK; | 181 | return UNZ_OK; |
182 | } | 182 | } |
183 | else | 183 | else |
184 | { | 184 | { |
185 | if (ZERROR(*pzlib_filefunc_def,filestream)) | 185 | if (ZERROR(*pzlib_filefunc_def,filestream)) |
186 | return UNZ_ERRNO; | 186 | return UNZ_ERRNO; |
187 | else | 187 | else |
188 | return UNZ_EOF; | 188 | return UNZ_EOF; |
189 | } | 189 | } |
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | ||
193 | /* =========================================================================== | 193 | /* =========================================================================== |
194 | Reads a long in LSB order from the given gz_stream. Sets | 194 | Reads a long in LSB order from the given gz_stream. Sets |
195 | */ | 195 | */ |
196 | local int unzlocal_getShort OF(( | 196 | local int unzlocal_getShort OF(( |
197 | const zlib_filefunc_def* pzlib_filefunc_def, | 197 | const zlib_filefunc_def* pzlib_filefunc_def, |
198 | voidpf filestream, | 198 | voidpf filestream, |
199 | uLong *pX)); | 199 | uLong *pX)); |
200 | 200 | ||
201 | local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX) | 201 | local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX) |
202 | const zlib_filefunc_def* pzlib_filefunc_def; | 202 | const zlib_filefunc_def* pzlib_filefunc_def; |
203 | voidpf filestream; | 203 | voidpf filestream; |
204 | uLong *pX; | 204 | uLong *pX; |
205 | { | 205 | { |
206 | uLong x ; | 206 | uLong x ; |
207 | int i; | 207 | int i; |
208 | int err; | 208 | int err; |
209 | 209 | ||
210 | err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); | 210 | err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); |
211 | x = (uLong)i; | 211 | x = (uLong)i; |
212 | 212 | ||
213 | if (err==UNZ_OK) | 213 | if (err==UNZ_OK) |
214 | err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); | 214 | err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); |
215 | x += ((uLong)i)<<8; | 215 | x += ((uLong)i)<<8; |
216 | 216 | ||
217 | if (err==UNZ_OK) | 217 | if (err==UNZ_OK) |
218 | *pX = x; | 218 | *pX = x; |
219 | else | 219 | else |
220 | *pX = 0; | 220 | *pX = 0; |
221 | return err; | 221 | return err; |
222 | } | 222 | } |
223 | 223 | ||
224 | local int unzlocal_getLong OF(( | 224 | local int unzlocal_getLong OF(( |
225 | const zlib_filefunc_def* pzlib_filefunc_def, | 225 | const zlib_filefunc_def* pzlib_filefunc_def, |
226 | voidpf filestream, | 226 | voidpf filestream, |
227 | uLong *pX)); | 227 | uLong *pX)); |
228 | 228 | ||
229 | local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX) | 229 | local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX) |
230 | const zlib_filefunc_def* pzlib_filefunc_def; | 230 | const zlib_filefunc_def* pzlib_filefunc_def; |
231 | voidpf filestream; | 231 | voidpf filestream; |
232 | uLong *pX; | 232 | uLong *pX; |
233 | { | 233 | { |
234 | uLong x ; | 234 | uLong x ; |
235 | int i; | 235 | int i; |
236 | int err; | 236 | int err; |
237 | 237 | ||
238 | err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); | 238 | err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); |
239 | x = (uLong)i; | 239 | x = (uLong)i; |
240 | 240 | ||
241 | if (err==UNZ_OK) | 241 | if (err==UNZ_OK) |
242 | err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); | 242 | err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); |
243 | x += ((uLong)i)<<8; | 243 | x += ((uLong)i)<<8; |
244 | 244 | ||
245 | if (err==UNZ_OK) | 245 | if (err==UNZ_OK) |
246 | err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); | 246 | err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); |
247 | x += ((uLong)i)<<16; | 247 | x += ((uLong)i)<<16; |
248 | 248 | ||
249 | if (err==UNZ_OK) | 249 | if (err==UNZ_OK) |
250 | err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); | 250 | err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); |
251 | x += ((uLong)i)<<24; | 251 | x += ((uLong)i)<<24; |
252 | 252 | ||
253 | if (err==UNZ_OK) | 253 | if (err==UNZ_OK) |
254 | *pX = x; | 254 | *pX = x; |
255 | else | 255 | else |
256 | *pX = 0; | 256 | *pX = 0; |
257 | return err; | 257 | return err; |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | /* My own strcmpi / strcasecmp */ | 261 | /* My own strcmpi / strcasecmp */ |
262 | local int strcmpcasenosensitive_internal (fileName1,fileName2) | 262 | local int strcmpcasenosensitive_internal (fileName1,fileName2) |
263 | const char* fileName1; | 263 | const char* fileName1; |
264 | const char* fileName2; | 264 | const char* fileName2; |
265 | { | 265 | { |
266 | for (;;) | 266 | for (;;) |
267 | { | 267 | { |
268 | char c1=*(fileName1++); | 268 | char c1=*(fileName1++); |
269 | char c2=*(fileName2++); | 269 | char c2=*(fileName2++); |
270 | if ((c1>='a') && (c1<='z')) | 270 | if ((c1>='a') && (c1<='z')) |
271 | c1 -= 0x20; | 271 | c1 -= 0x20; |
272 | if ((c2>='a') && (c2<='z')) | 272 | if ((c2>='a') && (c2<='z')) |
273 | c2 -= 0x20; | 273 | c2 -= 0x20; |
274 | if (c1=='\0') | 274 | if (c1=='\0') |
275 | return ((c2=='\0') ? 0 : -1); | 275 | return ((c2=='\0') ? 0 : -1); |
276 | if (c2=='\0') | 276 | if (c2=='\0') |
277 | return 1; | 277 | return 1; |
278 | if (c1<c2) | 278 | if (c1<c2) |
279 | return -1; | 279 | return -1; |
280 | if (c1>c2) | 280 | if (c1>c2) |
281 | return 1; | 281 | return 1; |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | 285 | ||
286 | #ifdef CASESENSITIVITYDEFAULT_NO | 286 | #ifdef CASESENSITIVITYDEFAULT_NO |
287 | #define CASESENSITIVITYDEFAULTVALUE 2 | 287 | #define CASESENSITIVITYDEFAULTVALUE 2 |
288 | #else | 288 | #else |
289 | #define CASESENSITIVITYDEFAULTVALUE 1 | 289 | #define CASESENSITIVITYDEFAULTVALUE 1 |
290 | #endif | 290 | #endif |
291 | 291 | ||
292 | #ifndef STRCMPCASENOSENTIVEFUNCTION | 292 | #ifndef STRCMPCASENOSENTIVEFUNCTION |
293 | #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal | 293 | #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal |
294 | #endif | 294 | #endif |
295 | 295 | ||
296 | /* | 296 | /* |
297 | Compare two filename (fileName1,fileName2). | 297 | Compare two filename (fileName1,fileName2). |
298 | If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) | 298 | If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) |
299 | If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi | 299 | If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi |
300 | or strcasecmp) | 300 | or strcasecmp) |
301 | If iCaseSenisivity = 0, case sensitivity is defaut of your operating system | 301 | If iCaseSenisivity = 0, case sensitivity is defaut of your operating system |
302 | (like 1 on Unix, 2 on Windows) | 302 | (like 1 on Unix, 2 on Windows) |
303 | 303 | ||
304 | */ | 304 | */ |
305 | extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) | 305 | extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity) |
306 | const char* fileName1; | 306 | const char* fileName1; |
307 | const char* fileName2; | 307 | const char* fileName2; |
308 | int iCaseSensitivity; | 308 | int iCaseSensitivity; |
309 | { | 309 | { |
310 | if (iCaseSensitivity==0) | 310 | if (iCaseSensitivity==0) |
311 | iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; | 311 | iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; |
312 | 312 | ||
313 | if (iCaseSensitivity==1) | 313 | if (iCaseSensitivity==1) |
314 | return strcmp(fileName1,fileName2); | 314 | return strcmp(fileName1,fileName2); |
315 | 315 | ||
316 | return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); | 316 | return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); |
317 | } | 317 | } |
318 | 318 | ||
319 | #ifndef BUFREADCOMMENT | 319 | #ifndef BUFREADCOMMENT |
320 | #define BUFREADCOMMENT (0x400) | 320 | #define BUFREADCOMMENT (0x400) |
321 | #endif | 321 | #endif |
322 | 322 | ||
323 | /* | 323 | /* |
324 | Locate the Central directory of a zipfile (at the end, just before | 324 | Locate the Central directory of a zipfile (at the end, just before |
325 | the global comment) | 325 | the global comment) |
326 | */ | 326 | */ |
327 | local uLong unzlocal_SearchCentralDir OF(( | 327 | local uLong unzlocal_SearchCentralDir OF(( |
328 | const zlib_filefunc_def* pzlib_filefunc_def, | 328 | const zlib_filefunc_def* pzlib_filefunc_def, |
329 | voidpf filestream)); | 329 | voidpf filestream)); |
330 | 330 | ||
331 | local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream) | 331 | local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream) |
332 | const zlib_filefunc_def* pzlib_filefunc_def; | 332 | const zlib_filefunc_def* pzlib_filefunc_def; |
333 | voidpf filestream; | 333 | voidpf filestream; |
334 | { | 334 | { |
335 | unsigned char* buf; | 335 | unsigned char* buf; |
336 | uLong uSizeFile; | 336 | uLong uSizeFile; |
337 | uLong uBackRead; | 337 | uLong uBackRead; |
338 | uLong uMaxBack=0xffff; /* maximum size of global comment */ | 338 | uLong uMaxBack=0xffff; /* maximum size of global comment */ |
339 | uLong uPosFound=0; | 339 | uLong uPosFound=0; |
340 | 340 | ||
341 | if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) | 341 | if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) |
342 | return 0; | 342 | return 0; |
343 | 343 | ||
344 | 344 | ||
345 | uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); | 345 | uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); |
346 | 346 | ||
347 | if (uMaxBack>uSizeFile) | 347 | if (uMaxBack>uSizeFile) |
348 | uMaxBack = uSizeFile; | 348 | uMaxBack = uSizeFile; |
349 | 349 | ||
350 | buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); | 350 | buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); |
351 | if (buf==NULL) | 351 | if (buf==NULL) |
352 | return 0; | 352 | return 0; |
353 | 353 | ||
354 | uBackRead = 4; | 354 | uBackRead = 4; |
355 | while (uBackRead<uMaxBack) | 355 | while (uBackRead<uMaxBack) |
356 | { | 356 | { |
357 | uLong uReadSize,uReadPos ; | 357 | uLong uReadSize,uReadPos ; |
358 | int i; | 358 | int i; |
359 | if (uBackRead+BUFREADCOMMENT>uMaxBack) | 359 | if (uBackRead+BUFREADCOMMENT>uMaxBack) |
360 | uBackRead = uMaxBack; | 360 | uBackRead = uMaxBack; |
361 | else | 361 | else |
362 | uBackRead+=BUFREADCOMMENT; | 362 | uBackRead+=BUFREADCOMMENT; |
363 | uReadPos = uSizeFile-uBackRead ; | 363 | uReadPos = uSizeFile-uBackRead ; |
364 | 364 | ||
365 | uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? | 365 | uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? |
366 | (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); | 366 | (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); |
367 | if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) | 367 | if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) |
368 | break; | 368 | break; |
369 | 369 | ||
370 | if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) | 370 | if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) |
371 | break; | 371 | break; |
372 | 372 | ||
373 | for (i=(int)uReadSize-3; (i--)>0;) | 373 | for (i=(int)uReadSize-3; (i--)>0;) |
374 | if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && | 374 | if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && |
375 | ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) | 375 | ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) |
376 | { | 376 | { |
377 | uPosFound = uReadPos+i; | 377 | uPosFound = uReadPos+i; |
378 | break; | 378 | break; |
379 | } | 379 | } |
380 | 380 | ||
381 | if (uPosFound!=0) | 381 | if (uPosFound!=0) |
382 | break; | 382 | break; |
383 | } | 383 | } |
384 | TRYFREE(buf); | 384 | TRYFREE(buf); |
385 | return uPosFound; | 385 | return uPosFound; |
386 | } | 386 | } |
387 | 387 | ||
388 | /* | 388 | /* |
389 | Open a Zip file. path contain the full pathname (by example, | 389 | Open a Zip file. path contain the full pathname (by example, |
390 | on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer | 390 | on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer |
391 | "zlib/zlib114.zip". | 391 | "zlib/zlib114.zip". |
392 | If the zipfile cannot be opened (file doesn't exist or in not valid), the | 392 | If the zipfile cannot be opened (file doesn't exist or in not valid), the |
393 | return value is NULL. | 393 | return value is NULL. |
394 | Else, the return value is a unzFile Handle, usable with other function | 394 | Else, the return value is a unzFile Handle, usable with other function |
395 | of this unzip package. | 395 | of this unzip package. |
396 | */ | 396 | */ |
397 | extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def) | 397 | extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def) |
398 | const char *path; | 398 | const char *path; |
399 | zlib_filefunc_def* pzlib_filefunc_def; | 399 | zlib_filefunc_def* pzlib_filefunc_def; |
400 | { | 400 | { |
401 | unz_s us; | 401 | unz_s us; |
402 | unz_s *s; | 402 | unz_s *s; |
403 | uLong central_pos,uL; | 403 | uLong central_pos,uL; |
404 | 404 | ||
405 | uLong number_disk; /* number of the current dist, used for | 405 | uLong number_disk; /* number of the current dist, used for |
406 | spaning ZIP, unsupported, always 0*/ | 406 | spaning ZIP, unsupported, always 0*/ |
407 | uLong number_disk_with_CD; /* number the the disk with central dir, used | 407 | uLong number_disk_with_CD; /* number the the disk with central dir, used |
408 | for spaning ZIP, unsupported, always 0*/ | 408 | for spaning ZIP, unsupported, always 0*/ |
409 | uLong number_entry_CD; /* total number of entries in | 409 | uLong number_entry_CD; /* total number of entries in |
410 | the central dir | 410 | the central dir |
411 | (same than number_entry on nospan) */ | 411 | (same than number_entry on nospan) */ |
412 | 412 | ||
413 | int err=UNZ_OK; | 413 | int err=UNZ_OK; |
414 | 414 | ||
415 | if (unz_copyright[0]!=' ') | 415 | if (unz_copyright[0]!=' ') |
416 | return NULL; | 416 | return NULL; |
417 | 417 | ||
418 | if (pzlib_filefunc_def==NULL) | 418 | if (pzlib_filefunc_def==NULL) |
419 | fill_fopen_filefunc(&us.z_filefunc); | 419 | fill_fopen_filefunc(&us.z_filefunc); |
420 | else | 420 | else |
421 | us.z_filefunc = *pzlib_filefunc_def; | 421 | us.z_filefunc = *pzlib_filefunc_def; |
422 | 422 | ||
423 | us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque, | 423 | us.filestream= (*(us.z_filefunc.zopen_file))(us.z_filefunc.opaque, |
424 | path, | 424 | path, |
425 | ZLIB_FILEFUNC_MODE_READ | | 425 | ZLIB_FILEFUNC_MODE_READ | |
426 | ZLIB_FILEFUNC_MODE_EXISTING); | 426 | ZLIB_FILEFUNC_MODE_EXISTING); |
427 | if (us.filestream==NULL) | 427 | if (us.filestream==NULL) |
428 | return NULL; | 428 | return NULL; |
429 | 429 | ||
430 | central_pos = unzlocal_SearchCentralDir(&us.z_filefunc,us.filestream); | 430 | central_pos = unzlocal_SearchCentralDir(&us.z_filefunc,us.filestream); |
431 | if (central_pos==0) | 431 | if (central_pos==0) |
432 | err=UNZ_ERRNO; | 432 | err=UNZ_ERRNO; |
433 | 433 | ||
434 | if (ZSEEK(us.z_filefunc, us.filestream, | 434 | if (ZSEEK(us.z_filefunc, us.filestream, |
435 | central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) | 435 | central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) |
436 | err=UNZ_ERRNO; | 436 | err=UNZ_ERRNO; |
437 | 437 | ||
438 | /* the signature, already checked */ | 438 | /* the signature, already checked */ |
439 | if (unzlocal_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) | 439 | if (unzlocal_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) |
440 | err=UNZ_ERRNO; | 440 | err=UNZ_ERRNO; |
441 | 441 | ||
442 | /* number of this disk */ | 442 | /* number of this disk */ |
443 | if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) | 443 | if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) |
444 | err=UNZ_ERRNO; | 444 | err=UNZ_ERRNO; |
445 | 445 | ||
446 | /* number of the disk with the start of the central directory */ | 446 | /* number of the disk with the start of the central directory */ |
447 | if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) | 447 | if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) |
448 | err=UNZ_ERRNO; | 448 | err=UNZ_ERRNO; |
449 | 449 | ||
450 | /* total number of entries in the central dir on this disk */ | 450 | /* total number of entries in the central dir on this disk */ |
451 | if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK) | 451 | if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK) |
452 | err=UNZ_ERRNO; | 452 | err=UNZ_ERRNO; |
453 | 453 | ||
454 | /* total number of entries in the central dir */ | 454 | /* total number of entries in the central dir */ |
455 | if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK) | 455 | if (unzlocal_getShort(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK) |
456 | err=UNZ_ERRNO; | 456 | err=UNZ_ERRNO; |
457 | 457 | ||
458 | if ((number_entry_CD!=us.gi.number_entry) || | 458 | if ((number_entry_CD!=us.gi.number_entry) || |
459 | (number_disk_with_CD!=0) || | 459 | (number_disk_with_CD!=0) || |
460 | (number_disk!=0)) | 460 | (number_disk!=0)) |
461 | err=UNZ_BADZIPFILE; | 461 | err=UNZ_BADZIPFILE; |
462 | 462 | ||
463 | /* size of the central directory */ | 463 | /* size of the central directory */ |
464 | if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK) | 464 | if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK) |
465 | err=UNZ_ERRNO; | 465 | err=UNZ_ERRNO; |
466 | 466 | ||
467 | /* offset of start of central directory with respect to the | 467 | /* offset of start of central directory with respect to the |
468 | starting disk number */ | 468 | starting disk number */ |
469 | if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK) | 469 | if (unzlocal_getLong(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK) |
470 | err=UNZ_ERRNO; | 470 | err=UNZ_ERRNO; |
471 | 471 | ||
472 | /* zipfile comment length */ | 472 | /* zipfile comment length */ |
473 | if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK) | 473 | if (unzlocal_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK) |
474 | err=UNZ_ERRNO; | 474 | err=UNZ_ERRNO; |
475 | 475 | ||
476 | if ((central_pos<us.offset_central_dir+us.size_central_dir) && | 476 | if ((central_pos<us.offset_central_dir+us.size_central_dir) && |
477 | (err==UNZ_OK)) | 477 | (err==UNZ_OK)) |
478 | err=UNZ_BADZIPFILE; | 478 | err=UNZ_BADZIPFILE; |
479 | 479 | ||
480 | if (err!=UNZ_OK) | 480 | if (err!=UNZ_OK) |
481 | { | 481 | { |
482 | ZCLOSE(us.z_filefunc, us.filestream); | 482 | ZCLOSE(us.z_filefunc, us.filestream); |
483 | return NULL; | 483 | return NULL; |
484 | } | 484 | } |
485 | 485 | ||
486 | us.byte_before_the_zipfile = central_pos - | 486 | us.byte_before_the_zipfile = central_pos - |
487 | (us.offset_central_dir+us.size_central_dir); | 487 | (us.offset_central_dir+us.size_central_dir); |
488 | us.central_pos = central_pos; | 488 | us.central_pos = central_pos; |
489 | us.pfile_in_zip_read = NULL; | 489 | us.pfile_in_zip_read = NULL; |
490 | us.encrypted = 0; | 490 | us.encrypted = 0; |
491 | 491 | ||
492 | 492 | ||
493 | s=(unz_s*)ALLOC(sizeof(unz_s)); | 493 | s=(unz_s*)ALLOC(sizeof(unz_s)); |
494 | *s=us; | 494 | *s=us; |
495 | unzGoToFirstFile((unzFile)s); | 495 | unzGoToFirstFile((unzFile)s); |
496 | return (unzFile)s; | 496 | return (unzFile)s; |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | ||
500 | extern unzFile ZEXPORT unzOpen (path) | 500 | extern unzFile ZEXPORT unzOpen (path) |
501 | const char *path; | 501 | const char *path; |
502 | { | 502 | { |
503 | return unzOpen2(path, NULL); | 503 | return unzOpen2(path, NULL); |
504 | } | 504 | } |
505 | 505 | ||
506 | /* | 506 | /* |
507 | Close a ZipFile opened with unzipOpen. | 507 | Close a ZipFile opened with unzipOpen. |
508 | If there is files inside the .Zip opened with unzipOpenCurrentFile (see later), | 508 | If there is files inside the .Zip opened with unzipOpenCurrentFile (see later), |
509 | these files MUST be closed with unzipCloseCurrentFile before call unzipClose. | 509 | these files MUST be closed with unzipCloseCurrentFile before call unzipClose. |
510 | return UNZ_OK if there is no problem. */ | 510 | return UNZ_OK if there is no problem. */ |
511 | extern int ZEXPORT unzClose (file) | 511 | extern int ZEXPORT unzClose (file) |
512 | unzFile file; | 512 | unzFile file; |
513 | { | 513 | { |
514 | unz_s* s; | 514 | unz_s* s; |
515 | if (file==NULL) | 515 | if (file==NULL) |
516 | return UNZ_PARAMERROR; | 516 | return UNZ_PARAMERROR; |
517 | s=(unz_s*)file; | 517 | s=(unz_s*)file; |
518 | 518 | ||
519 | if (s->pfile_in_zip_read!=NULL) | 519 | if (s->pfile_in_zip_read!=NULL) |
520 | unzCloseCurrentFile(file); | 520 | unzCloseCurrentFile(file); |
521 | 521 | ||
522 | ZCLOSE(s->z_filefunc, s->filestream); | 522 | ZCLOSE(s->z_filefunc, s->filestream); |
523 | TRYFREE(s); | 523 | TRYFREE(s); |
524 | return UNZ_OK; | 524 | return UNZ_OK; |
525 | } | 525 | } |
526 | 526 | ||
527 | 527 | ||
528 | /* | 528 | /* |
529 | Write info about the ZipFile in the *pglobal_info structure. | 529 | Write info about the ZipFile in the *pglobal_info structure. |
530 | No preparation of the structure is needed | 530 | No preparation of the structure is needed |
531 | return UNZ_OK if there is no problem. */ | 531 | return UNZ_OK if there is no problem. */ |
532 | extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) | 532 | extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info) |
533 | unzFile file; | 533 | unzFile file; |
534 | unz_global_info *pglobal_info; | 534 | unz_global_info *pglobal_info; |
535 | { | 535 | { |
536 | unz_s* s; | 536 | unz_s* s; |
537 | if (file==NULL) | 537 | if (file==NULL) |
538 | return UNZ_PARAMERROR; | 538 | return UNZ_PARAMERROR; |
539 | s=(unz_s*)file; | 539 | s=(unz_s*)file; |
540 | *pglobal_info=s->gi; | 540 | *pglobal_info=s->gi; |
541 | return UNZ_OK; | 541 | return UNZ_OK; |
542 | } | 542 | } |
543 | 543 | ||
544 | 544 | ||
545 | /* | 545 | /* |
546 | Translate date/time from Dos format to tm_unz (readable more easilty) | 546 | Translate date/time from Dos format to tm_unz (readable more easilty) |
547 | */ | 547 | */ |
548 | local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) | 548 | local void unzlocal_DosDateToTmuDate (ulDosDate, ptm) |
549 | uLong ulDosDate; | 549 | uLong ulDosDate; |
550 | tm_unz* ptm; | 550 | tm_unz* ptm; |
551 | { | 551 | { |
552 | uLong uDate; | 552 | uLong uDate; |
553 | uDate = (uLong)(ulDosDate>>16); | 553 | uDate = (uLong)(ulDosDate>>16); |
554 | ptm->tm_mday = (uInt)(uDate&0x1f) ; | 554 | ptm->tm_mday = (uInt)(uDate&0x1f) ; |
555 | ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; | 555 | ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ; |
556 | ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; | 556 | ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ; |
557 | 557 | ||
558 | ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); | 558 | ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800); |
559 | ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; | 559 | ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ; |
560 | ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; | 560 | ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ; |
561 | } | 561 | } |
562 | 562 | ||
563 | /* | 563 | /* |
564 | Get Info about the current file in the zipfile, with internal only info | 564 | Get Info about the current file in the zipfile, with internal only info |
565 | */ | 565 | */ |
566 | local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, | 566 | local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file, |
567 | unz_file_info *pfile_info, | 567 | unz_file_info *pfile_info, |
568 | unz_file_info_internal | 568 | unz_file_info_internal |
569 | *pfile_info_internal, | 569 | *pfile_info_internal, |
570 | char *szFileName, | 570 | char *szFileName, |
571 | uLong fileNameBufferSize, | 571 | uLong fileNameBufferSize, |
572 | void *extraField, | 572 | void *extraField, |
573 | uLong extraFieldBufferSize, | 573 | uLong extraFieldBufferSize, |
574 | char *szComment, | 574 | char *szComment, |
575 | uLong commentBufferSize)); | 575 | uLong commentBufferSize)); |
576 | 576 | ||
577 | local int unzlocal_GetCurrentFileInfoInternal (file, | 577 | local int unzlocal_GetCurrentFileInfoInternal (file, |
578 | pfile_info, | 578 | pfile_info, |
579 | pfile_info_internal, | 579 | pfile_info_internal, |
580 | szFileName, fileNameBufferSize, | 580 | szFileName, fileNameBufferSize, |
581 | extraField, extraFieldBufferSize, | 581 | extraField, extraFieldBufferSize, |
582 | szComment, commentBufferSize) | 582 | szComment, commentBufferSize) |
583 | unzFile file; | 583 | unzFile file; |
584 | unz_file_info *pfile_info; | 584 | unz_file_info *pfile_info; |
585 | unz_file_info_internal *pfile_info_internal; | 585 | unz_file_info_internal *pfile_info_internal; |
586 | char *szFileName; | 586 | char *szFileName; |
587 | uLong fileNameBufferSize; | 587 | uLong fileNameBufferSize; |
588 | void *extraField; | 588 | void *extraField; |
589 | uLong extraFieldBufferSize; | 589 | uLong extraFieldBufferSize; |
590 | char *szComment; | 590 | char *szComment; |
591 | uLong commentBufferSize; | 591 | uLong commentBufferSize; |
592 | { | 592 | { |
593 | unz_s* s; | 593 | unz_s* s; |
594 | unz_file_info file_info; | 594 | unz_file_info file_info; |
595 | unz_file_info_internal file_info_internal; | 595 | unz_file_info_internal file_info_internal; |
596 | int err=UNZ_OK; | 596 | int err=UNZ_OK; |
597 | uLong uMagic; | 597 | uLong uMagic; |
598 | long lSeek=0; | 598 | long lSeek=0; |
599 | 599 | ||
600 | if (file==NULL) | 600 | if (file==NULL) |
601 | return UNZ_PARAMERROR; | 601 | return UNZ_PARAMERROR; |
602 | s=(unz_s*)file; | 602 | s=(unz_s*)file; |
603 | if (ZSEEK(s->z_filefunc, s->filestream, | 603 | if (ZSEEK(s->z_filefunc, s->filestream, |
604 | s->pos_in_central_dir+s->byte_before_the_zipfile, | 604 | s->pos_in_central_dir+s->byte_before_the_zipfile, |
605 | ZLIB_FILEFUNC_SEEK_SET)!=0) | 605 | ZLIB_FILEFUNC_SEEK_SET)!=0) |
606 | err=UNZ_ERRNO; | 606 | err=UNZ_ERRNO; |
607 | 607 | ||
608 | 608 | ||
609 | /* we check the magic */ | 609 | /* we check the magic */ |
610 | if (err==UNZ_OK) | 610 | if (err==UNZ_OK) |
611 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) | 611 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) |
612 | err=UNZ_ERRNO; | 612 | err=UNZ_ERRNO; |
613 | else if (uMagic!=0x02014b50) | 613 | else if (uMagic!=0x02014b50) |
614 | err=UNZ_BADZIPFILE; | 614 | err=UNZ_BADZIPFILE; |
615 | 615 | ||
616 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) | 616 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) |
617 | err=UNZ_ERRNO; | 617 | err=UNZ_ERRNO; |
618 | 618 | ||
619 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK) | 619 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK) |
620 | err=UNZ_ERRNO; | 620 | err=UNZ_ERRNO; |
621 | 621 | ||
622 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK) | 622 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK) |
623 | err=UNZ_ERRNO; | 623 | err=UNZ_ERRNO; |
624 | 624 | ||
625 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK) | 625 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK) |
626 | err=UNZ_ERRNO; | 626 | err=UNZ_ERRNO; |
627 | 627 | ||
628 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK) | 628 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK) |
629 | err=UNZ_ERRNO; | 629 | err=UNZ_ERRNO; |
630 | 630 | ||
631 | unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); | 631 | unzlocal_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); |
632 | 632 | ||
633 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK) | 633 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK) |
634 | err=UNZ_ERRNO; | 634 | err=UNZ_ERRNO; |
635 | 635 | ||
636 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) | 636 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) |
637 | err=UNZ_ERRNO; | 637 | err=UNZ_ERRNO; |
638 | 638 | ||
639 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) | 639 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) |
640 | err=UNZ_ERRNO; | 640 | err=UNZ_ERRNO; |
641 | 641 | ||
642 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK) | 642 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK) |
643 | err=UNZ_ERRNO; | 643 | err=UNZ_ERRNO; |
644 | 644 | ||
645 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK) | 645 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK) |
646 | err=UNZ_ERRNO; | 646 | err=UNZ_ERRNO; |
647 | 647 | ||
648 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK) | 648 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK) |
649 | err=UNZ_ERRNO; | 649 | err=UNZ_ERRNO; |
650 | 650 | ||
651 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) | 651 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) |
652 | err=UNZ_ERRNO; | 652 | err=UNZ_ERRNO; |
653 | 653 | ||
654 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK) | 654 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK) |
655 | err=UNZ_ERRNO; | 655 | err=UNZ_ERRNO; |
656 | 656 | ||
657 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) | 657 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) |
658 | err=UNZ_ERRNO; | 658 | err=UNZ_ERRNO; |
659 | 659 | ||
660 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) | 660 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) |
661 | err=UNZ_ERRNO; | 661 | err=UNZ_ERRNO; |
662 | 662 | ||
663 | lSeek+=file_info.size_filename; | 663 | lSeek+=file_info.size_filename; |
664 | if ((err==UNZ_OK) && (szFileName!=NULL)) | 664 | if ((err==UNZ_OK) && (szFileName!=NULL)) |
665 | { | 665 | { |
666 | uLong uSizeRead ; | 666 | uLong uSizeRead ; |
667 | if (file_info.size_filename<fileNameBufferSize) | 667 | if (file_info.size_filename<fileNameBufferSize) |
668 | { | 668 | { |
669 | *(szFileName+file_info.size_filename)='\0'; | 669 | *(szFileName+file_info.size_filename)='\0'; |
670 | uSizeRead = file_info.size_filename; | 670 | uSizeRead = file_info.size_filename; |
671 | } | 671 | } |
672 | else | 672 | else |
673 | uSizeRead = fileNameBufferSize; | 673 | uSizeRead = fileNameBufferSize; |
674 | 674 | ||
675 | if ((file_info.size_filename>0) && (fileNameBufferSize>0)) | 675 | if ((file_info.size_filename>0) && (fileNameBufferSize>0)) |
676 | if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead) | 676 | if (ZREAD(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead) |
677 | err=UNZ_ERRNO; | 677 | err=UNZ_ERRNO; |
678 | lSeek -= uSizeRead; | 678 | lSeek -= uSizeRead; |
679 | } | 679 | } |
680 | 680 | ||
681 | 681 | ||
682 | if ((err==UNZ_OK) && (extraField!=NULL)) | 682 | if ((err==UNZ_OK) && (extraField!=NULL)) |
683 | { | 683 | { |
684 | uLong uSizeRead ; | 684 | uLong uSizeRead ; |
685 | if (file_info.size_file_extra<extraFieldBufferSize) | 685 | if (file_info.size_file_extra<extraFieldBufferSize) |
686 | uSizeRead = file_info.size_file_extra; | 686 | uSizeRead = file_info.size_file_extra; |
687 | else | 687 | else |
688 | uSizeRead = extraFieldBufferSize; | 688 | uSizeRead = extraFieldBufferSize; |
689 | 689 | ||
690 | if (lSeek!=0) | 690 | if (lSeek!=0) |
691 | if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) | 691 | if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) |
692 | lSeek=0; | 692 | lSeek=0; |
693 | else | 693 | else |
694 | err=UNZ_ERRNO; | 694 | err=UNZ_ERRNO; |
695 | if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) | 695 | if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) |
696 | if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead) | 696 | if (ZREAD(s->z_filefunc, s->filestream,extraField,uSizeRead)!=uSizeRead) |
697 | err=UNZ_ERRNO; | 697 | err=UNZ_ERRNO; |
698 | lSeek += file_info.size_file_extra - uSizeRead; | 698 | lSeek += file_info.size_file_extra - uSizeRead; |
699 | } | 699 | } |
700 | else | 700 | else |
701 | lSeek+=file_info.size_file_extra; | 701 | lSeek+=file_info.size_file_extra; |
702 | 702 | ||
703 | 703 | ||
704 | if ((err==UNZ_OK) && (szComment!=NULL)) | 704 | if ((err==UNZ_OK) && (szComment!=NULL)) |
705 | { | 705 | { |
706 | uLong uSizeRead ; | 706 | uLong uSizeRead ; |
707 | if (file_info.size_file_comment<commentBufferSize) | 707 | if (file_info.size_file_comment<commentBufferSize) |
708 | { | 708 | { |
709 | *(szComment+file_info.size_file_comment)='\0'; | 709 | *(szComment+file_info.size_file_comment)='\0'; |
710 | uSizeRead = file_info.size_file_comment; | 710 | uSizeRead = file_info.size_file_comment; |
711 | } | 711 | } |
712 | else | 712 | else |
713 | uSizeRead = commentBufferSize; | 713 | uSizeRead = commentBufferSize; |
714 | 714 | ||
715 | if (lSeek!=0) | 715 | if (lSeek!=0) |
716 | if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) | 716 | if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) |
717 | lSeek=0; | 717 | lSeek=0; |
718 | else | 718 | else |
719 | err=UNZ_ERRNO; | 719 | err=UNZ_ERRNO; |
720 | if ((file_info.size_file_comment>0) && (commentBufferSize>0)) | 720 | if ((file_info.size_file_comment>0) && (commentBufferSize>0)) |
721 | if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) | 721 | if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) |
722 | err=UNZ_ERRNO; | 722 | err=UNZ_ERRNO; |
723 | lSeek+=file_info.size_file_comment - uSizeRead; | 723 | lSeek+=file_info.size_file_comment - uSizeRead; |
724 | } | 724 | } |
725 | else | 725 | else |
726 | lSeek+=file_info.size_file_comment; | 726 | lSeek+=file_info.size_file_comment; |
727 | 727 | ||
728 | if ((err==UNZ_OK) && (pfile_info!=NULL)) | 728 | if ((err==UNZ_OK) && (pfile_info!=NULL)) |
729 | *pfile_info=file_info; | 729 | *pfile_info=file_info; |
730 | 730 | ||
731 | if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) | 731 | if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) |
732 | *pfile_info_internal=file_info_internal; | 732 | *pfile_info_internal=file_info_internal; |
733 | 733 | ||
734 | return err; | 734 | return err; |
735 | } | 735 | } |
736 | 736 | ||
737 | 737 | ||
738 | 738 | ||
739 | /* | 739 | /* |
740 | Write info about the ZipFile in the *pglobal_info structure. | 740 | Write info about the ZipFile in the *pglobal_info structure. |
741 | No preparation of the structure is needed | 741 | No preparation of the structure is needed |
742 | return UNZ_OK if there is no problem. | 742 | return UNZ_OK if there is no problem. |
743 | */ | 743 | */ |
744 | extern int ZEXPORT unzGetCurrentFileInfo (file, | 744 | extern int ZEXPORT unzGetCurrentFileInfo (file, |
745 | pfile_info, | 745 | pfile_info, |
746 | szFileName, fileNameBufferSize, | 746 | szFileName, fileNameBufferSize, |
747 | extraField, extraFieldBufferSize, | 747 | extraField, extraFieldBufferSize, |
748 | szComment, commentBufferSize) | 748 | szComment, commentBufferSize) |
749 | unzFile file; | 749 | unzFile file; |
750 | unz_file_info *pfile_info; | 750 | unz_file_info *pfile_info; |
751 | char *szFileName; | 751 | char *szFileName; |
752 | uLong fileNameBufferSize; | 752 | uLong fileNameBufferSize; |
753 | void *extraField; | 753 | void *extraField; |
754 | uLong extraFieldBufferSize; | 754 | uLong extraFieldBufferSize; |
755 | char *szComment; | 755 | char *szComment; |
756 | uLong commentBufferSize; | 756 | uLong commentBufferSize; |
757 | { | 757 | { |
758 | return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, | 758 | return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL, |
759 | szFileName,fileNameBufferSize, | 759 | szFileName,fileNameBufferSize, |
760 | extraField,extraFieldBufferSize, | 760 | extraField,extraFieldBufferSize, |
761 | szComment,commentBufferSize); | 761 | szComment,commentBufferSize); |
762 | } | 762 | } |
763 | 763 | ||
764 | /* | 764 | /* |
765 | Set the current file of the zipfile to the first file. | 765 | Set the current file of the zipfile to the first file. |
766 | return UNZ_OK if there is no problem | 766 | return UNZ_OK if there is no problem |
767 | */ | 767 | */ |
768 | extern int ZEXPORT unzGoToFirstFile (file) | 768 | extern int ZEXPORT unzGoToFirstFile (file) |
769 | unzFile file; | 769 | unzFile file; |
770 | { | 770 | { |
771 | int err=UNZ_OK; | 771 | int err=UNZ_OK; |
772 | unz_s* s; | 772 | unz_s* s; |
773 | if (file==NULL) | 773 | if (file==NULL) |
774 | return UNZ_PARAMERROR; | 774 | return UNZ_PARAMERROR; |
775 | s=(unz_s*)file; | 775 | s=(unz_s*)file; |
776 | s->pos_in_central_dir=s->offset_central_dir; | 776 | s->pos_in_central_dir=s->offset_central_dir; |
777 | s->num_file=0; | 777 | s->num_file=0; |
778 | err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, | 778 | err=unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, |
779 | &s->cur_file_info_internal, | 779 | &s->cur_file_info_internal, |
780 | NULL,0,NULL,0,NULL,0); | 780 | NULL,0,NULL,0,NULL,0); |
781 | s->current_file_ok = (err == UNZ_OK); | 781 | s->current_file_ok = (err == UNZ_OK); |
782 | return err; | 782 | return err; |
783 | } | 783 | } |
784 | 784 | ||
785 | /* | 785 | /* |
786 | Set the current file of the zipfile to the next file. | 786 | Set the current file of the zipfile to the next file. |
787 | return UNZ_OK if there is no problem | 787 | return UNZ_OK if there is no problem |
788 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. | 788 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. |
789 | */ | 789 | */ |
790 | extern int ZEXPORT unzGoToNextFile (file) | 790 | extern int ZEXPORT unzGoToNextFile (file) |
791 | unzFile file; | 791 | unzFile file; |
792 | { | 792 | { |
793 | unz_s* s; | 793 | unz_s* s; |
794 | int err; | 794 | int err; |
795 | 795 | ||
796 | if (file==NULL) | 796 | if (file==NULL) |
797 | return UNZ_PARAMERROR; | 797 | return UNZ_PARAMERROR; |
798 | s=(unz_s*)file; | 798 | s=(unz_s*)file; |
799 | if (!s->current_file_ok) | 799 | if (!s->current_file_ok) |
800 | return UNZ_END_OF_LIST_OF_FILE; | 800 | return UNZ_END_OF_LIST_OF_FILE; |
801 | if (s->num_file+1==s->gi.number_entry) | 801 | if (s->num_file+1==s->gi.number_entry) |
802 | return UNZ_END_OF_LIST_OF_FILE; | 802 | return UNZ_END_OF_LIST_OF_FILE; |
803 | 803 | ||
804 | s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + | 804 | s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + |
805 | s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; | 805 | s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; |
806 | s->num_file++; | 806 | s->num_file++; |
807 | err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, | 807 | err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, |
808 | &s->cur_file_info_internal, | 808 | &s->cur_file_info_internal, |
809 | NULL,0,NULL,0,NULL,0); | 809 | NULL,0,NULL,0,NULL,0); |
810 | s->current_file_ok = (err == UNZ_OK); | 810 | s->current_file_ok = (err == UNZ_OK); |
811 | return err; | 811 | return err; |
812 | } | 812 | } |
813 | 813 | ||
814 | 814 | ||
815 | /* | 815 | /* |
816 | Try locate the file szFileName in the zipfile. | 816 | Try locate the file szFileName in the zipfile. |
817 | For the iCaseSensitivity signification, see unzipStringFileNameCompare | 817 | For the iCaseSensitivity signification, see unzipStringFileNameCompare |
818 | 818 | ||
819 | return value : | 819 | return value : |
820 | UNZ_OK if the file is found. It becomes the current file. | 820 | UNZ_OK if the file is found. It becomes the current file. |
821 | UNZ_END_OF_LIST_OF_FILE if the file is not found | 821 | UNZ_END_OF_LIST_OF_FILE if the file is not found |
822 | */ | 822 | */ |
823 | extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) | 823 | extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity) |
824 | unzFile file; | 824 | unzFile file; |
825 | const char *szFileName; | 825 | const char *szFileName; |
826 | int iCaseSensitivity; | 826 | int iCaseSensitivity; |
827 | { | 827 | { |
828 | unz_s* s; | 828 | unz_s* s; |
829 | int err; | 829 | int err; |
830 | 830 | ||
831 | /* We remember the 'current' position in the file so that we can jump | 831 | /* We remember the 'current' position in the file so that we can jump |
832 | * back there if we fail. | 832 | * back there if we fail. |
833 | */ | 833 | */ |
834 | unz_file_info cur_file_infoSaved; | 834 | unz_file_info cur_file_infoSaved; |
835 | unz_file_info_internal cur_file_info_internalSaved; | 835 | unz_file_info_internal cur_file_info_internalSaved; |
836 | uLong num_fileSaved; | 836 | uLong num_fileSaved; |
837 | uLong pos_in_central_dirSaved; | 837 | uLong pos_in_central_dirSaved; |
838 | 838 | ||
839 | 839 | ||
840 | if (file==NULL) | 840 | if (file==NULL) |
841 | return UNZ_PARAMERROR; | 841 | return UNZ_PARAMERROR; |
842 | 842 | ||
843 | if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) | 843 | if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) |
844 | return UNZ_PARAMERROR; | 844 | return UNZ_PARAMERROR; |
845 | 845 | ||
846 | s=(unz_s*)file; | 846 | s=(unz_s*)file; |
847 | if (!s->current_file_ok) | 847 | if (!s->current_file_ok) |
848 | return UNZ_END_OF_LIST_OF_FILE; | 848 | return UNZ_END_OF_LIST_OF_FILE; |
849 | 849 | ||
850 | /* Save the current state */ | 850 | /* Save the current state */ |
851 | num_fileSaved = s->num_file; | 851 | num_fileSaved = s->num_file; |
852 | pos_in_central_dirSaved = s->pos_in_central_dir; | 852 | pos_in_central_dirSaved = s->pos_in_central_dir; |
853 | cur_file_infoSaved = s->cur_file_info; | 853 | cur_file_infoSaved = s->cur_file_info; |
854 | cur_file_info_internalSaved = s->cur_file_info_internal; | 854 | cur_file_info_internalSaved = s->cur_file_info_internal; |
855 | 855 | ||
856 | err = unzGoToFirstFile(file); | 856 | err = unzGoToFirstFile(file); |
857 | 857 | ||
858 | while (err == UNZ_OK) | 858 | while (err == UNZ_OK) |
859 | { | 859 | { |
860 | char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; | 860 | char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; |
861 | err = unzGetCurrentFileInfo(file,NULL, | 861 | err = unzGetCurrentFileInfo(file,NULL, |
862 | szCurrentFileName,sizeof(szCurrentFileName)-1, | 862 | szCurrentFileName,sizeof(szCurrentFileName)-1, |
863 | NULL,0,NULL,0); | 863 | NULL,0,NULL,0); |
864 | if (err == UNZ_OK) | 864 | if (err == UNZ_OK) |
865 | { | 865 | { |
866 | if (unzStringFileNameCompare(szCurrentFileName, | 866 | if (unzStringFileNameCompare(szCurrentFileName, |
867 | szFileName,iCaseSensitivity)==0) | 867 | szFileName,iCaseSensitivity)==0) |
868 | return UNZ_OK; | 868 | return UNZ_OK; |
869 | err = unzGoToNextFile(file); | 869 | err = unzGoToNextFile(file); |
870 | } | 870 | } |
871 | } | 871 | } |
872 | 872 | ||
873 | /* We failed, so restore the state of the 'current file' to where we | 873 | /* We failed, so restore the state of the 'current file' to where we |
874 | * were. | 874 | * were. |
875 | */ | 875 | */ |
876 | s->num_file = num_fileSaved ; | 876 | s->num_file = num_fileSaved ; |
877 | s->pos_in_central_dir = pos_in_central_dirSaved ; | 877 | s->pos_in_central_dir = pos_in_central_dirSaved ; |
878 | s->cur_file_info = cur_file_infoSaved; | 878 | s->cur_file_info = cur_file_infoSaved; |
879 | s->cur_file_info_internal = cur_file_info_internalSaved; | 879 | s->cur_file_info_internal = cur_file_info_internalSaved; |
880 | return err; | 880 | return err; |
881 | } | 881 | } |
882 | 882 | ||
883 | 883 | ||
884 | /* | 884 | /* |
885 | /////////////////////////////////////////// | 885 | /////////////////////////////////////////// |
886 | // Contributed by Ryan Haksi (mailto://cryogen@infoserve.net) | 886 | // Contributed by Ryan Haksi (mailto://cryogen@infoserve.net) |
887 | // I need random access | 887 | // I need random access |
888 | // | 888 | // |
889 | // Further optimization could be realized by adding an ability | 889 | // Further optimization could be realized by adding an ability |
890 | // to cache the directory in memory. The goal being a single | 890 | // to cache the directory in memory. The goal being a single |
891 | // comprehensive file read to put the file I need in a memory. | 891 | // comprehensive file read to put the file I need in a memory. |
892 | */ | 892 | */ |
893 | 893 | ||
894 | /* | 894 | /* |
895 | typedef struct unz_file_pos_s | 895 | typedef struct unz_file_pos_s |
896 | { | 896 | { |
897 | uLong pos_in_zip_directory; // offset in file | 897 | uLong pos_in_zip_directory; // offset in file |
898 | uLong num_of_file; // # of file | 898 | uLong num_of_file; // # of file |
899 | } unz_file_pos; | 899 | } unz_file_pos; |
900 | */ | 900 | */ |
901 | 901 | ||
902 | extern int ZEXPORT unzGetFilePos(file, file_pos) | 902 | extern int ZEXPORT unzGetFilePos(file, file_pos) |
903 | unzFile file; | 903 | unzFile file; |
904 | unz_file_pos* file_pos; | 904 | unz_file_pos* file_pos; |
905 | { | 905 | { |
906 | unz_s* s; | 906 | unz_s* s; |
907 | 907 | ||
908 | if (file==NULL || file_pos==NULL) | 908 | if (file==NULL || file_pos==NULL) |
909 | return UNZ_PARAMERROR; | 909 | return UNZ_PARAMERROR; |
910 | s=(unz_s*)file; | 910 | s=(unz_s*)file; |
911 | if (!s->current_file_ok) | 911 | if (!s->current_file_ok) |
912 | return UNZ_END_OF_LIST_OF_FILE; | 912 | return UNZ_END_OF_LIST_OF_FILE; |
913 | 913 | ||
914 | file_pos->pos_in_zip_directory = s->pos_in_central_dir; | 914 | file_pos->pos_in_zip_directory = s->pos_in_central_dir; |
915 | file_pos->num_of_file = s->num_file; | 915 | file_pos->num_of_file = s->num_file; |
916 | 916 | ||
917 | return UNZ_OK; | 917 | return UNZ_OK; |
918 | } | 918 | } |
919 | 919 | ||
920 | extern int ZEXPORT unzGoToFilePos(file, file_pos) | 920 | extern int ZEXPORT unzGoToFilePos(file, file_pos) |
921 | unzFile file; | 921 | unzFile file; |
922 | unz_file_pos* file_pos; | 922 | unz_file_pos* file_pos; |
923 | { | 923 | { |
924 | unz_s* s; | 924 | unz_s* s; |
925 | int err; | 925 | int err; |
926 | 926 | ||
927 | if (file==NULL || file_pos==NULL) | 927 | if (file==NULL || file_pos==NULL) |
928 | return UNZ_PARAMERROR; | 928 | return UNZ_PARAMERROR; |
929 | s=(unz_s*)file; | 929 | s=(unz_s*)file; |
930 | 930 | ||
931 | /* jump to the right spot */ | 931 | /* jump to the right spot */ |
932 | s->pos_in_central_dir = file_pos->pos_in_zip_directory; | 932 | s->pos_in_central_dir = file_pos->pos_in_zip_directory; |
933 | s->num_file = file_pos->num_of_file; | 933 | s->num_file = file_pos->num_of_file; |
934 | 934 | ||
935 | /* set the current file */ | 935 | /* set the current file */ |
936 | err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, | 936 | err = unzlocal_GetCurrentFileInfoInternal(file,&s->cur_file_info, |
937 | &s->cur_file_info_internal, | 937 | &s->cur_file_info_internal, |
938 | NULL,0,NULL,0,NULL,0); | 938 | NULL,0,NULL,0,NULL,0); |
939 | /* return results */ | 939 | /* return results */ |
940 | s->current_file_ok = (err == UNZ_OK); | 940 | s->current_file_ok = (err == UNZ_OK); |
941 | return err; | 941 | return err; |
942 | } | 942 | } |
943 | 943 | ||
944 | /* | 944 | /* |
945 | // Unzip Helper Functions - should be here? | 945 | // Unzip Helper Functions - should be here? |
946 | /////////////////////////////////////////// | 946 | /////////////////////////////////////////// |
947 | */ | 947 | */ |
948 | 948 | ||
949 | /* | 949 | /* |
950 | Read the local header of the current zipfile | 950 | Read the local header of the current zipfile |
951 | Check the coherency of the local header and info in the end of central | 951 | Check the coherency of the local header and info in the end of central |
952 | directory about this file | 952 | directory about this file |
953 | store in *piSizeVar the size of extra info in local header | 953 | store in *piSizeVar the size of extra info in local header |
954 | (filename and size of extra field data) | 954 | (filename and size of extra field data) |
955 | */ | 955 | */ |
956 | local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, | 956 | local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar, |
957 | poffset_local_extrafield, | 957 | poffset_local_extrafield, |
958 | psize_local_extrafield) | 958 | psize_local_extrafield) |
959 | unz_s* s; | 959 | unz_s* s; |
960 | uInt* piSizeVar; | 960 | uInt* piSizeVar; |
961 | uLong *poffset_local_extrafield; | 961 | uLong *poffset_local_extrafield; |
962 | uInt *psize_local_extrafield; | 962 | uInt *psize_local_extrafield; |
963 | { | 963 | { |
964 | uLong uMagic,uData,uFlags; | 964 | uLong uMagic,uData,uFlags; |
965 | uLong size_filename; | 965 | uLong size_filename; |
966 | uLong size_extra_field; | 966 | uLong size_extra_field; |
967 | int err=UNZ_OK; | 967 | int err=UNZ_OK; |
968 | 968 | ||
969 | *piSizeVar = 0; | 969 | *piSizeVar = 0; |
970 | *poffset_local_extrafield = 0; | 970 | *poffset_local_extrafield = 0; |
971 | *psize_local_extrafield = 0; | 971 | *psize_local_extrafield = 0; |
972 | 972 | ||
973 | if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + | 973 | if (ZSEEK(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + |
974 | s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) | 974 | s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) |
975 | return UNZ_ERRNO; | 975 | return UNZ_ERRNO; |
976 | 976 | ||
977 | 977 | ||
978 | if (err==UNZ_OK) | 978 | if (err==UNZ_OK) |
979 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) | 979 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) |
980 | err=UNZ_ERRNO; | 980 | err=UNZ_ERRNO; |
981 | else if (uMagic!=0x04034b50) | 981 | else if (uMagic!=0x04034b50) |
982 | err=UNZ_BADZIPFILE; | 982 | err=UNZ_BADZIPFILE; |
983 | 983 | ||
984 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) | 984 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) |
985 | err=UNZ_ERRNO; | 985 | err=UNZ_ERRNO; |
986 | /* | 986 | /* |
987 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) | 987 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) |
988 | err=UNZ_BADZIPFILE; | 988 | err=UNZ_BADZIPFILE; |
989 | */ | 989 | */ |
990 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) | 990 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) |
991 | err=UNZ_ERRNO; | 991 | err=UNZ_ERRNO; |
992 | 992 | ||
993 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) | 993 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) |
994 | err=UNZ_ERRNO; | 994 | err=UNZ_ERRNO; |
995 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) | 995 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) |
996 | err=UNZ_BADZIPFILE; | 996 | err=UNZ_BADZIPFILE; |
997 | 997 | ||
998 | if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && | 998 | if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && |
999 | (s->cur_file_info.compression_method!=Z_DEFLATED)) | 999 | (s->cur_file_info.compression_method!=Z_DEFLATED)) |
1000 | err=UNZ_BADZIPFILE; | 1000 | err=UNZ_BADZIPFILE; |
1001 | 1001 | ||
1002 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ | 1002 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ |
1003 | err=UNZ_ERRNO; | 1003 | err=UNZ_ERRNO; |
1004 | 1004 | ||
1005 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ | 1005 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ |
1006 | err=UNZ_ERRNO; | 1006 | err=UNZ_ERRNO; |
1007 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && | 1007 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && |
1008 | ((uFlags & 8)==0)) | 1008 | ((uFlags & 8)==0)) |
1009 | err=UNZ_BADZIPFILE; | 1009 | err=UNZ_BADZIPFILE; |
1010 | 1010 | ||
1011 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ | 1011 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ |
1012 | err=UNZ_ERRNO; | 1012 | err=UNZ_ERRNO; |
1013 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && | 1013 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && |
1014 | ((uFlags & 8)==0)) | 1014 | ((uFlags & 8)==0)) |
1015 | err=UNZ_BADZIPFILE; | 1015 | err=UNZ_BADZIPFILE; |
1016 | 1016 | ||
1017 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ | 1017 | if (unzlocal_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ |
1018 | err=UNZ_ERRNO; | 1018 | err=UNZ_ERRNO; |
1019 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && | 1019 | else if ((err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && |
1020 | ((uFlags & 8)==0)) | 1020 | ((uFlags & 8)==0)) |
1021 | err=UNZ_BADZIPFILE; | 1021 | err=UNZ_BADZIPFILE; |
1022 | 1022 | ||
1023 | 1023 | ||
1024 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK) | 1024 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK) |
1025 | err=UNZ_ERRNO; | 1025 | err=UNZ_ERRNO; |
1026 | else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) | 1026 | else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) |
1027 | err=UNZ_BADZIPFILE; | 1027 | err=UNZ_BADZIPFILE; |
1028 | 1028 | ||
1029 | *piSizeVar += (uInt)size_filename; | 1029 | *piSizeVar += (uInt)size_filename; |
1030 | 1030 | ||
1031 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) | 1031 | if (unzlocal_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) |
1032 | err=UNZ_ERRNO; | 1032 | err=UNZ_ERRNO; |
1033 | *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + | 1033 | *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + |
1034 | SIZEZIPLOCALHEADER + size_filename; | 1034 | SIZEZIPLOCALHEADER + size_filename; |
1035 | *psize_local_extrafield = (uInt)size_extra_field; | 1035 | *psize_local_extrafield = (uInt)size_extra_field; |
1036 | 1036 | ||
1037 | *piSizeVar += (uInt)size_extra_field; | 1037 | *piSizeVar += (uInt)size_extra_field; |
1038 | 1038 | ||
1039 | return err; | 1039 | return err; |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | /* | 1042 | /* |
1043 | Open for reading data the current file in the zipfile. | 1043 | Open for reading data the current file in the zipfile. |
1044 | If there is no error and the file is opened, the return value is UNZ_OK. | 1044 | If there is no error and the file is opened, the return value is UNZ_OK. |
1045 | */ | 1045 | */ |
1046 | extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) | 1046 | extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) |
1047 | unzFile file; | 1047 | unzFile file; |
1048 | int* method; | 1048 | int* method; |
1049 | int* level; | 1049 | int* level; |
1050 | int raw; | 1050 | int raw; |
1051 | const char* password; | 1051 | const char* password; |
1052 | { | 1052 | { |
1053 | int err=UNZ_OK; | 1053 | int err=UNZ_OK; |
1054 | uInt iSizeVar; | 1054 | uInt iSizeVar; |
1055 | unz_s* s; | 1055 | unz_s* s; |
1056 | file_in_zip_read_info_s* pfile_in_zip_read_info; | 1056 | file_in_zip_read_info_s* pfile_in_zip_read_info; |
1057 | uLong offset_local_extrafield; /* offset of the local extra field */ | 1057 | uLong offset_local_extrafield; /* offset of the local extra field */ |
1058 | uInt size_local_extrafield; /* size of the local extra field */ | 1058 | uInt size_local_extrafield; /* size of the local extra field */ |
1059 | #ifndef NOUNCRYPT | 1059 | # ifndef NOUNCRYPT |
1060 | char source[12]; | 1060 | char source[12]; |
1061 | #else | 1061 | # else |
1062 | if (password != NULL) | 1062 | if (password != NULL) |
1063 | return UNZ_PARAMERROR; | 1063 | return UNZ_PARAMERROR; |
1064 | #endif | 1064 | # endif |
1065 | 1065 | ||
1066 | if (file==NULL) | 1066 | if (file==NULL) |
1067 | return UNZ_PARAMERROR; | 1067 | return UNZ_PARAMERROR; |
1068 | s=(unz_s*)file; | 1068 | s=(unz_s*)file; |
1069 | if (!s->current_file_ok) | 1069 | if (!s->current_file_ok) |
1070 | return UNZ_PARAMERROR; | 1070 | return UNZ_PARAMERROR; |
1071 | 1071 | ||
1072 | if (s->pfile_in_zip_read != NULL) | 1072 | if (s->pfile_in_zip_read != NULL) |
1073 | unzCloseCurrentFile(file); | 1073 | unzCloseCurrentFile(file); |
1074 | 1074 | ||
1075 | if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, | 1075 | if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar, |
1076 | &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) | 1076 | &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) |
1077 | return UNZ_BADZIPFILE; | 1077 | return UNZ_BADZIPFILE; |
1078 | 1078 | ||
1079 | pfile_in_zip_read_info = (file_in_zip_read_info_s*) | 1079 | pfile_in_zip_read_info = (file_in_zip_read_info_s*) |
1080 | ALLOC(sizeof(file_in_zip_read_info_s)); | 1080 | ALLOC(sizeof(file_in_zip_read_info_s)); |
1081 | if (pfile_in_zip_read_info==NULL) | 1081 | if (pfile_in_zip_read_info==NULL) |
1082 | return UNZ_INTERNALERROR; | 1082 | return UNZ_INTERNALERROR; |
1083 | 1083 | ||
1084 | pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); | 1084 | pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); |
1085 | pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; | 1085 | pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; |
1086 | pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; | 1086 | pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; |
1087 | pfile_in_zip_read_info->pos_local_extrafield=0; | 1087 | pfile_in_zip_read_info->pos_local_extrafield=0; |
1088 | pfile_in_zip_read_info->raw=raw; | 1088 | pfile_in_zip_read_info->raw=raw; |
1089 | 1089 | ||
1090 | if (pfile_in_zip_read_info->read_buffer==NULL) | 1090 | if (pfile_in_zip_read_info->read_buffer==NULL) |
1091 | { | 1091 | { |
1092 | TRYFREE(pfile_in_zip_read_info); | 1092 | TRYFREE(pfile_in_zip_read_info); |
1093 | return UNZ_INTERNALERROR; | 1093 | return UNZ_INTERNALERROR; |
1094 | } | 1094 | } |
1095 | 1095 | ||
1096 | pfile_in_zip_read_info->stream_initialised=0; | 1096 | pfile_in_zip_read_info->stream_initialised=0; |
1097 | 1097 | ||
1098 | if (method!=NULL) | 1098 | if (method!=NULL) |
1099 | *method = (int)s->cur_file_info.compression_method; | 1099 | *method = (int)s->cur_file_info.compression_method; |
1100 | 1100 | ||
1101 | if (level!=NULL) | 1101 | if (level!=NULL) |
1102 | { | 1102 | { |
1103 | *level = 6; | 1103 | *level = 6; |
1104 | switch (s->cur_file_info.flag & 0x06) | 1104 | switch (s->cur_file_info.flag & 0x06) |
1105 | { | 1105 | { |
1106 | case 6 : *level = 1; break; | 1106 | case 6 : *level = 1; break; |
1107 | case 4 : *level = 2; break; | 1107 | case 4 : *level = 2; break; |
1108 | case 2 : *level = 9; break; | 1108 | case 2 : *level = 9; break; |
1109 | } | 1109 | } |
1110 | } | 1110 | } |
1111 | 1111 | ||
1112 | if ((s->cur_file_info.compression_method!=0) && | 1112 | if ((s->cur_file_info.compression_method!=0) && |
1113 | (s->cur_file_info.compression_method!=Z_DEFLATED)) | 1113 | (s->cur_file_info.compression_method!=Z_DEFLATED)) |
1114 | err=UNZ_BADZIPFILE; | 1114 | err=UNZ_BADZIPFILE; |
1115 | 1115 | ||
1116 | pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; | 1116 | pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; |
1117 | pfile_in_zip_read_info->crc32=0; | 1117 | pfile_in_zip_read_info->crc32=0; |
1118 | pfile_in_zip_read_info->compression_method = | 1118 | pfile_in_zip_read_info->compression_method = |
1119 | s->cur_file_info.compression_method; | 1119 | s->cur_file_info.compression_method; |
1120 | pfile_in_zip_read_info->filestream=s->filestream; | 1120 | pfile_in_zip_read_info->filestream=s->filestream; |
1121 | pfile_in_zip_read_info->z_filefunc=s->z_filefunc; | 1121 | pfile_in_zip_read_info->z_filefunc=s->z_filefunc; |
1122 | pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; | 1122 | pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; |
1123 | 1123 | ||
1124 | pfile_in_zip_read_info->stream.total_out = 0; | 1124 | pfile_in_zip_read_info->stream.total_out = 0; |
1125 | 1125 | ||
1126 | if ((s->cur_file_info.compression_method==Z_DEFLATED) && | 1126 | if ((s->cur_file_info.compression_method==Z_DEFLATED) && |
1127 | (!raw)) | 1127 | (!raw)) |
1128 | { | 1128 | { |
1129 | pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; | 1129 | pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; |
1130 | pfile_in_zip_read_info->stream.zfree = (free_func)0; | 1130 | pfile_in_zip_read_info->stream.zfree = (free_func)0; |
1131 | pfile_in_zip_read_info->stream.opaque = (voidpf)0; | 1131 | pfile_in_zip_read_info->stream.opaque = (voidpf)0; |
1132 | pfile_in_zip_read_info->stream.next_in = (voidpf)0; | 1132 | pfile_in_zip_read_info->stream.next_in = (voidpf)0; |
1133 | pfile_in_zip_read_info->stream.avail_in = 0; | 1133 | pfile_in_zip_read_info->stream.avail_in = 0; |
1134 | 1134 | ||
1135 | err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); | 1135 | err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); |
1136 | if (err == Z_OK) | 1136 | if (err == Z_OK) |
1137 | pfile_in_zip_read_info->stream_initialised=1; | 1137 | pfile_in_zip_read_info->stream_initialised=1; |
1138 | else | 1138 | else |
1139 | return err; | 1139 | return err; |
1140 | /* windowBits is passed < 0 to tell that there is no zlib header. | 1140 | /* windowBits is passed < 0 to tell that there is no zlib header. |
1141 | * Note that in this case inflate *requires* an extra "dummy" byte | 1141 | * Note that in this case inflate *requires* an extra "dummy" byte |
1142 | * after the compressed stream in order to complete decompression and | 1142 | * after the compressed stream in order to complete decompression and |
1143 | * return Z_STREAM_END. | 1143 | * return Z_STREAM_END. |
1144 | * In unzip, i don't wait absolutely Z_STREAM_END because I known the | 1144 | * In unzip, i don't wait absolutely Z_STREAM_END because I known the |
1145 | * size of both compressed and uncompressed data | 1145 | * size of both compressed and uncompressed data |
1146 | */ | 1146 | */ |
1147 | } | 1147 | } |
1148 | pfile_in_zip_read_info->rest_read_compressed = | 1148 | pfile_in_zip_read_info->rest_read_compressed = |
1149 | s->cur_file_info.compressed_size ; | 1149 | s->cur_file_info.compressed_size ; |
1150 | pfile_in_zip_read_info->rest_read_uncompressed = | 1150 | pfile_in_zip_read_info->rest_read_uncompressed = |
1151 | s->cur_file_info.uncompressed_size ; | 1151 | s->cur_file_info.uncompressed_size ; |
1152 | 1152 | ||
1153 | 1153 | ||
1154 | pfile_in_zip_read_info->pos_in_zipfile = | 1154 | pfile_in_zip_read_info->pos_in_zipfile = |
1155 | s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + | 1155 | s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + |
1156 | iSizeVar; | 1156 | iSizeVar; |
1157 | 1157 | ||
1158 | pfile_in_zip_read_info->stream.avail_in = (uInt)0; | 1158 | pfile_in_zip_read_info->stream.avail_in = (uInt)0; |
1159 | 1159 | ||
1160 | s->pfile_in_zip_read = pfile_in_zip_read_info; | 1160 | s->pfile_in_zip_read = pfile_in_zip_read_info; |
1161 | 1161 | ||
1162 | #ifndef NOUNCRYPT | 1162 | # ifndef NOUNCRYPT |
1163 | if (password != NULL) | 1163 | if (password != NULL) |
1164 | { | 1164 | { |
1165 | int i; | 1165 | int i; |
1166 | s->pcrc_32_tab = get_crc_table(); | 1166 | s->pcrc_32_tab = get_crc_table(); |
1167 | init_keys(password,s->keys,s->pcrc_32_tab); | 1167 | init_keys(password,s->keys,s->pcrc_32_tab); |
1168 | if (ZSEEK(s->z_filefunc, s->filestream, | 1168 | if (ZSEEK(s->z_filefunc, s->filestream, |
1169 | s->pfile_in_zip_read->pos_in_zipfile + | 1169 | s->pfile_in_zip_read->pos_in_zipfile + |
1170 | s->pfile_in_zip_read->byte_before_the_zipfile, | 1170 | s->pfile_in_zip_read->byte_before_the_zipfile, |
1171 | SEEK_SET)!=0) | 1171 | SEEK_SET)!=0) |
1172 | return UNZ_INTERNALERROR; | 1172 | return UNZ_INTERNALERROR; |
1173 | if(ZREAD(s->z_filefunc, s->filestream,source, 12)<12) | 1173 | if(ZREAD(s->z_filefunc, s->filestream,source, 12)<12) |
1174 | return UNZ_INTERNALERROR; | 1174 | return UNZ_INTERNALERROR; |
1175 | 1175 | ||
1176 | for (i = 0; i<12; i++) | 1176 | for (i = 0; i<12; i++) |
1177 | zdecode(s->keys,s->pcrc_32_tab,source[i]); | 1177 | zdecode(s->keys,s->pcrc_32_tab,source[i]); |
1178 | 1178 | ||
1179 | s->pfile_in_zip_read->pos_in_zipfile+=12; | 1179 | s->pfile_in_zip_read->pos_in_zipfile+=12; |
1180 | s->encrypted=1; | 1180 | s->encrypted=1; |
1181 | } | 1181 | } |
1182 | #endif | 1182 | # endif |
1183 | 1183 | ||
1184 | 1184 | ||
1185 | return UNZ_OK; | 1185 | return UNZ_OK; |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | extern int ZEXPORT unzOpenCurrentFile (file) | 1188 | extern int ZEXPORT unzOpenCurrentFile (file) |
1189 | unzFile file; | 1189 | unzFile file; |
1190 | { | 1190 | { |
1191 | return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); | 1191 | return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | extern int ZEXPORT unzOpenCurrentFilePassword (file, password) | 1194 | extern int ZEXPORT unzOpenCurrentFilePassword (file, password) |
1195 | unzFile file; | 1195 | unzFile file; |
1196 | const char* password; | 1196 | const char* password; |
1197 | { | 1197 | { |
1198 | return unzOpenCurrentFile3(file, NULL, NULL, 0, password); | 1198 | return unzOpenCurrentFile3(file, NULL, NULL, 0, password); |
1199 | } | 1199 | } |
1200 | 1200 | ||
1201 | extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw) | 1201 | extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw) |
1202 | unzFile file; | 1202 | unzFile file; |
1203 | int* method; | 1203 | int* method; |
1204 | int* level; | 1204 | int* level; |
1205 | int raw; | 1205 | int raw; |
1206 | { | 1206 | { |
1207 | return unzOpenCurrentFile3(file, method, level, raw, NULL); | 1207 | return unzOpenCurrentFile3(file, method, level, raw, NULL); |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | /* | 1210 | /* |
1211 | Read bytes from the current file. | 1211 | Read bytes from the current file. |
1212 | buf contain buffer where data must be copied | 1212 | buf contain buffer where data must be copied |
1213 | len the size of buf. | 1213 | len the size of buf. |
1214 | 1214 | ||
1215 | return the number of byte copied if somes bytes are copied | 1215 | return the number of byte copied if somes bytes are copied |
1216 | return 0 if the end of file was reached | 1216 | return 0 if the end of file was reached |
1217 | return <0 with error code if there is an error | 1217 | return <0 with error code if there is an error |
1218 | (UNZ_ERRNO for IO error, or zLib error for uncompress error) | 1218 | (UNZ_ERRNO for IO error, or zLib error for uncompress error) |
1219 | */ | 1219 | */ |
1220 | extern int ZEXPORT unzReadCurrentFile (file, buf, len) | 1220 | extern int ZEXPORT unzReadCurrentFile (file, buf, len) |
1221 | unzFile file; | 1221 | unzFile file; |
1222 | voidp buf; | 1222 | voidp buf; |
1223 | unsigned len; | 1223 | unsigned len; |
1224 | { | 1224 | { |
1225 | int err=UNZ_OK; | 1225 | int err=UNZ_OK; |
1226 | uInt iRead = 0; | 1226 | uInt iRead = 0; |
1227 | unz_s* s; | 1227 | unz_s* s; |
1228 | file_in_zip_read_info_s* pfile_in_zip_read_info; | 1228 | file_in_zip_read_info_s* pfile_in_zip_read_info; |
1229 | if (file==NULL) | 1229 | if (file==NULL) |
1230 | return UNZ_PARAMERROR; | 1230 | return UNZ_PARAMERROR; |
1231 | s=(unz_s*)file; | 1231 | s=(unz_s*)file; |
1232 | pfile_in_zip_read_info=s->pfile_in_zip_read; | 1232 | pfile_in_zip_read_info=s->pfile_in_zip_read; |
1233 | 1233 | ||
1234 | if (pfile_in_zip_read_info==NULL) | 1234 | if (pfile_in_zip_read_info==NULL) |
1235 | return UNZ_PARAMERROR; | 1235 | return UNZ_PARAMERROR; |
1236 | 1236 | ||
1237 | 1237 | ||
1238 | if ((pfile_in_zip_read_info->read_buffer == NULL)) | 1238 | if ((pfile_in_zip_read_info->read_buffer == NULL)) |
1239 | return UNZ_END_OF_LIST_OF_FILE; | 1239 | return UNZ_END_OF_LIST_OF_FILE; |
1240 | if (len==0) | 1240 | if (len==0) |
1241 | return 0; | 1241 | return 0; |
1242 | 1242 | ||
1243 | pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; | 1243 | pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; |
1244 | 1244 | ||
1245 | pfile_in_zip_read_info->stream.avail_out = (uInt)len; | 1245 | pfile_in_zip_read_info->stream.avail_out = (uInt)len; |
1246 | 1246 | ||
1247 | if (len>pfile_in_zip_read_info->rest_read_uncompressed) | 1247 | if (len>pfile_in_zip_read_info->rest_read_uncompressed) |
1248 | pfile_in_zip_read_info->stream.avail_out = | 1248 | pfile_in_zip_read_info->stream.avail_out = |
1249 | (uInt)pfile_in_zip_read_info->rest_read_uncompressed; | 1249 | (uInt)pfile_in_zip_read_info->rest_read_uncompressed; |
1250 | 1250 | ||
1251 | while (pfile_in_zip_read_info->stream.avail_out>0) | 1251 | while (pfile_in_zip_read_info->stream.avail_out>0) |
1252 | { | 1252 | { |
1253 | if ((pfile_in_zip_read_info->stream.avail_in==0) && | 1253 | if ((pfile_in_zip_read_info->stream.avail_in==0) && |
1254 | (pfile_in_zip_read_info->rest_read_compressed>0)) | 1254 | (pfile_in_zip_read_info->rest_read_compressed>0)) |
1255 | { | 1255 | { |
1256 | uInt uReadThis = UNZ_BUFSIZE; | 1256 | uInt uReadThis = UNZ_BUFSIZE; |
1257 | if (pfile_in_zip_read_info->rest_read_compressed<uReadThis) | 1257 | if (pfile_in_zip_read_info->rest_read_compressed<uReadThis) |
1258 | uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed; | 1258 | uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed; |
1259 | if (uReadThis == 0) | 1259 | if (uReadThis == 0) |
1260 | return UNZ_EOF; | 1260 | return UNZ_EOF; |
1261 | if (ZSEEK(pfile_in_zip_read_info->z_filefunc, | 1261 | if (ZSEEK(pfile_in_zip_read_info->z_filefunc, |
1262 | pfile_in_zip_read_info->filestream, | 1262 | pfile_in_zip_read_info->filestream, |
1263 | pfile_in_zip_read_info->pos_in_zipfile + | 1263 | pfile_in_zip_read_info->pos_in_zipfile + |
1264 | pfile_in_zip_read_info->byte_before_the_zipfile, | 1264 | pfile_in_zip_read_info->byte_before_the_zipfile, |
1265 | ZLIB_FILEFUNC_SEEK_SET)!=0) | 1265 | ZLIB_FILEFUNC_SEEK_SET)!=0) |
1266 | return UNZ_ERRNO; | 1266 | return UNZ_ERRNO; |
1267 | if (ZREAD(pfile_in_zip_read_info->z_filefunc, | 1267 | if (ZREAD(pfile_in_zip_read_info->z_filefunc, |
1268 | pfile_in_zip_read_info->filestream, | 1268 | pfile_in_zip_read_info->filestream, |
1269 | pfile_in_zip_read_info->read_buffer, | 1269 | pfile_in_zip_read_info->read_buffer, |
1270 | uReadThis)!=uReadThis) | 1270 | uReadThis)!=uReadThis) |
1271 | return UNZ_ERRNO; | 1271 | return UNZ_ERRNO; |
1272 | 1272 | ||
1273 | 1273 | ||
1274 | #ifndef NOUNCRYPT | 1274 | # ifndef NOUNCRYPT |
1275 | if(s->encrypted) | 1275 | if(s->encrypted) |
1276 | { | 1276 | { |
1277 | uInt i; | 1277 | uInt i; |
1278 | for(i=0;i<uReadThis;i++) | 1278 | for(i=0;i<uReadThis;i++) |
1279 | pfile_in_zip_read_info->read_buffer[i] = | 1279 | pfile_in_zip_read_info->read_buffer[i] = |
1280 | zdecode(s->keys,s->pcrc_32_tab, | 1280 | zdecode(s->keys,s->pcrc_32_tab, |
1281 | pfile_in_zip_read_info->read_buffer[i]); | 1281 | pfile_in_zip_read_info->read_buffer[i]); |
1282 | } | 1282 | } |
1283 | #endif | 1283 | # endif |
1284 | 1284 | ||
1285 | 1285 | ||
1286 | pfile_in_zip_read_info->pos_in_zipfile += uReadThis; | 1286 | pfile_in_zip_read_info->pos_in_zipfile += uReadThis; |
1287 | 1287 | ||
1288 | pfile_in_zip_read_info->rest_read_compressed-=uReadThis; | 1288 | pfile_in_zip_read_info->rest_read_compressed-=uReadThis; |
1289 | 1289 | ||
1290 | pfile_in_zip_read_info->stream.next_in = | 1290 | pfile_in_zip_read_info->stream.next_in = |
1291 | (Bytef*)pfile_in_zip_read_info->read_buffer; | 1291 | (Bytef*)pfile_in_zip_read_info->read_buffer; |
1292 | pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; | 1292 | pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; |
1293 | } | 1293 | } |
1294 | 1294 | ||
1295 | if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) | 1295 | if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) |
1296 | { | 1296 | { |
1297 | uInt uDoCopy,i ; | 1297 | uInt uDoCopy,i ; |
1298 | 1298 | ||
1299 | if ((pfile_in_zip_read_info->stream.avail_in == 0) && | 1299 | if ((pfile_in_zip_read_info->stream.avail_in == 0) && |
1300 | (pfile_in_zip_read_info->rest_read_compressed == 0)) | 1300 | (pfile_in_zip_read_info->rest_read_compressed == 0)) |
1301 | return (iRead==0) ? UNZ_EOF : iRead; | 1301 | return (iRead==0) ? UNZ_EOF : iRead; |
1302 | 1302 | ||
1303 | if (pfile_in_zip_read_info->stream.avail_out < | 1303 | if (pfile_in_zip_read_info->stream.avail_out < |
1304 | pfile_in_zip_read_info->stream.avail_in) | 1304 | pfile_in_zip_read_info->stream.avail_in) |
1305 | uDoCopy = pfile_in_zip_read_info->stream.avail_out ; | 1305 | uDoCopy = pfile_in_zip_read_info->stream.avail_out ; |
1306 | else | 1306 | else |
1307 | uDoCopy = pfile_in_zip_read_info->stream.avail_in ; | 1307 | uDoCopy = pfile_in_zip_read_info->stream.avail_in ; |
1308 | 1308 | ||
1309 | for (i=0;i<uDoCopy;i++) | 1309 | for (i=0;i<uDoCopy;i++) |
1310 | *(pfile_in_zip_read_info->stream.next_out+i) = | 1310 | *(pfile_in_zip_read_info->stream.next_out+i) = |
1311 | *(pfile_in_zip_read_info->stream.next_in+i); | 1311 | *(pfile_in_zip_read_info->stream.next_in+i); |
1312 | 1312 | ||
1313 | pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, | 1313 | pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, |
1314 | pfile_in_zip_read_info->stream.next_out, | 1314 | pfile_in_zip_read_info->stream.next_out, |
1315 | uDoCopy); | 1315 | uDoCopy); |
1316 | pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; | 1316 | pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; |
1317 | pfile_in_zip_read_info->stream.avail_in -= uDoCopy; | 1317 | pfile_in_zip_read_info->stream.avail_in -= uDoCopy; |
1318 | pfile_in_zip_read_info->stream.avail_out -= uDoCopy; | 1318 | pfile_in_zip_read_info->stream.avail_out -= uDoCopy; |
1319 | pfile_in_zip_read_info->stream.next_out += uDoCopy; | 1319 | pfile_in_zip_read_info->stream.next_out += uDoCopy; |
1320 | pfile_in_zip_read_info->stream.next_in += uDoCopy; | 1320 | pfile_in_zip_read_info->stream.next_in += uDoCopy; |
1321 | pfile_in_zip_read_info->stream.total_out += uDoCopy; | 1321 | pfile_in_zip_read_info->stream.total_out += uDoCopy; |
1322 | iRead += uDoCopy; | 1322 | iRead += uDoCopy; |
1323 | } | 1323 | } |
1324 | else | 1324 | else |
1325 | { | 1325 | { |
1326 | uLong uTotalOutBefore,uTotalOutAfter; | 1326 | uLong uTotalOutBefore,uTotalOutAfter; |
1327 | const Bytef *bufBefore; | 1327 | const Bytef *bufBefore; |
1328 | uLong uOutThis; | 1328 | uLong uOutThis; |
1329 | int flush=Z_SYNC_FLUSH; | 1329 | int flush=Z_SYNC_FLUSH; |
1330 | 1330 | ||
1331 | uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; | 1331 | uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; |
1332 | bufBefore = pfile_in_zip_read_info->stream.next_out; | 1332 | bufBefore = pfile_in_zip_read_info->stream.next_out; |
1333 | 1333 | ||
1334 | /* | 1334 | /* |
1335 | if ((pfile_in_zip_read_info->rest_read_uncompressed == | 1335 | if ((pfile_in_zip_read_info->rest_read_uncompressed == |
1336 | pfile_in_zip_read_info->stream.avail_out) && | 1336 | pfile_in_zip_read_info->stream.avail_out) && |
1337 | (pfile_in_zip_read_info->rest_read_compressed == 0)) | 1337 | (pfile_in_zip_read_info->rest_read_compressed == 0)) |
1338 | flush = Z_FINISH; | 1338 | flush = Z_FINISH; |
1339 | */ | 1339 | */ |
1340 | err=inflate(&pfile_in_zip_read_info->stream,flush); | 1340 | err=inflate(&pfile_in_zip_read_info->stream,flush); |
1341 | 1341 | ||
1342 | uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; | 1342 | uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; |
1343 | uOutThis = uTotalOutAfter-uTotalOutBefore; | 1343 | uOutThis = uTotalOutAfter-uTotalOutBefore; |
1344 | 1344 | ||
1345 | pfile_in_zip_read_info->crc32 = | 1345 | pfile_in_zip_read_info->crc32 = |
1346 | crc32(pfile_in_zip_read_info->crc32,bufBefore, | 1346 | crc32(pfile_in_zip_read_info->crc32,bufBefore, |
1347 | (uInt)(uOutThis)); | 1347 | (uInt)(uOutThis)); |
1348 | 1348 | ||
1349 | pfile_in_zip_read_info->rest_read_uncompressed -= | 1349 | pfile_in_zip_read_info->rest_read_uncompressed -= |
1350 | uOutThis; | 1350 | uOutThis; |
1351 | 1351 | ||
1352 | iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); | 1352 | iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); |
1353 | 1353 | ||
1354 | if (err==Z_STREAM_END) | 1354 | if (err==Z_STREAM_END) |
1355 | return (iRead==0) ? UNZ_EOF : iRead; | 1355 | return (iRead==0) ? UNZ_EOF : iRead; |
1356 | if (err!=Z_OK) | 1356 | if (err!=Z_OK) |
1357 | break; | 1357 | break; |
1358 | } | 1358 | } |
1359 | } | 1359 | } |
1360 | 1360 | ||
1361 | if (err==Z_OK) | 1361 | if (err==Z_OK) |
1362 | return iRead; | 1362 | return iRead; |
1363 | return err; | 1363 | return err; |
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | 1366 | ||
1367 | /* | 1367 | /* |
1368 | Give the current position in uncompressed data | 1368 | Give the current position in uncompressed data |
1369 | */ | 1369 | */ |
1370 | extern z_off_t ZEXPORT unztell (file) | 1370 | extern z_off_t ZEXPORT unztell (file) |
1371 | unzFile file; | 1371 | unzFile file; |
1372 | { | 1372 | { |
1373 | unz_s* s; | 1373 | unz_s* s; |
1374 | file_in_zip_read_info_s* pfile_in_zip_read_info; | 1374 | file_in_zip_read_info_s* pfile_in_zip_read_info; |
1375 | if (file==NULL) | 1375 | if (file==NULL) |
1376 | return UNZ_PARAMERROR; | 1376 | return UNZ_PARAMERROR; |
1377 | s=(unz_s*)file; | 1377 | s=(unz_s*)file; |
1378 | pfile_in_zip_read_info=s->pfile_in_zip_read; | 1378 | pfile_in_zip_read_info=s->pfile_in_zip_read; |
1379 | 1379 | ||
1380 | if (pfile_in_zip_read_info==NULL) | 1380 | if (pfile_in_zip_read_info==NULL) |
1381 | return UNZ_PARAMERROR; | 1381 | return UNZ_PARAMERROR; |
1382 | 1382 | ||
1383 | return (z_off_t)pfile_in_zip_read_info->stream.total_out; | 1383 | return (z_off_t)pfile_in_zip_read_info->stream.total_out; |
1384 | } | 1384 | } |
1385 | 1385 | ||
1386 | 1386 | ||
1387 | /* | 1387 | /* |
1388 | return 1 if the end of file was reached, 0 elsewhere | 1388 | return 1 if the end of file was reached, 0 elsewhere |
1389 | */ | 1389 | */ |
1390 | extern int ZEXPORT unzeof (file) | 1390 | extern int ZEXPORT unzeof (file) |
1391 | unzFile file; | 1391 | unzFile file; |
1392 | { | 1392 | { |
1393 | unz_s* s; | 1393 | unz_s* s; |
1394 | file_in_zip_read_info_s* pfile_in_zip_read_info; | 1394 | file_in_zip_read_info_s* pfile_in_zip_read_info; |
1395 | if (file==NULL) | 1395 | if (file==NULL) |
1396 | return UNZ_PARAMERROR; | 1396 | return UNZ_PARAMERROR; |
1397 | s=(unz_s*)file; | 1397 | s=(unz_s*)file; |
1398 | pfile_in_zip_read_info=s->pfile_in_zip_read; | 1398 | pfile_in_zip_read_info=s->pfile_in_zip_read; |
1399 | 1399 | ||
1400 | if (pfile_in_zip_read_info==NULL) | 1400 | if (pfile_in_zip_read_info==NULL) |
1401 | return UNZ_PARAMERROR; | 1401 | return UNZ_PARAMERROR; |
1402 | 1402 | ||
1403 | if (pfile_in_zip_read_info->rest_read_uncompressed == 0) | 1403 | if (pfile_in_zip_read_info->rest_read_uncompressed == 0) |
1404 | return 1; | 1404 | return 1; |
1405 | else | 1405 | else |
1406 | return 0; | 1406 | return 0; |
1407 | } | 1407 | } |
1408 | 1408 | ||
1409 | 1409 | ||
1410 | 1410 | ||
1411 | /* | 1411 | /* |
1412 | Read extra field from the current file (opened by unzOpenCurrentFile) | 1412 | Read extra field from the current file (opened by unzOpenCurrentFile) |
1413 | This is the local-header version of the extra field (sometimes, there is | 1413 | This is the local-header version of the extra field (sometimes, there is |
1414 | more info in the local-header version than in the central-header) | 1414 | more info in the local-header version than in the central-header) |
1415 | 1415 | ||
1416 | if buf==NULL, it return the size of the local extra field that can be read | 1416 | if buf==NULL, it return the size of the local extra field that can be read |
1417 | 1417 | ||
1418 | if buf!=NULL, len is the size of the buffer, the extra header is copied in | 1418 | if buf!=NULL, len is the size of the buffer, the extra header is copied in |
1419 | buf. | 1419 | buf. |
1420 | the return value is the number of bytes copied in buf, or (if <0) | 1420 | the return value is the number of bytes copied in buf, or (if <0) |
1421 | the error code | 1421 | the error code |
1422 | */ | 1422 | */ |
1423 | extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) | 1423 | extern int ZEXPORT unzGetLocalExtrafield (file,buf,len) |
1424 | unzFile file; | 1424 | unzFile file; |
1425 | voidp buf; | 1425 | voidp buf; |
1426 | unsigned len; | 1426 | unsigned len; |
1427 | { | 1427 | { |
1428 | unz_s* s; | 1428 | unz_s* s; |
1429 | file_in_zip_read_info_s* pfile_in_zip_read_info; | 1429 | file_in_zip_read_info_s* pfile_in_zip_read_info; |
1430 | uInt read_now; | 1430 | uInt read_now; |
1431 | uLong size_to_read; | 1431 | uLong size_to_read; |
1432 | 1432 | ||
1433 | if (file==NULL) | 1433 | if (file==NULL) |
1434 | return UNZ_PARAMERROR; | 1434 | return UNZ_PARAMERROR; |
1435 | s=(unz_s*)file; | 1435 | s=(unz_s*)file; |
1436 | pfile_in_zip_read_info=s->pfile_in_zip_read; | 1436 | pfile_in_zip_read_info=s->pfile_in_zip_read; |
1437 | 1437 | ||
1438 | if (pfile_in_zip_read_info==NULL) | 1438 | if (pfile_in_zip_read_info==NULL) |
1439 | return UNZ_PARAMERROR; | 1439 | return UNZ_PARAMERROR; |
1440 | 1440 | ||
1441 | size_to_read = (pfile_in_zip_read_info->size_local_extrafield - | 1441 | size_to_read = (pfile_in_zip_read_info->size_local_extrafield - |
1442 | pfile_in_zip_read_info->pos_local_extrafield); | 1442 | pfile_in_zip_read_info->pos_local_extrafield); |
1443 | 1443 | ||
1444 | if (buf==NULL) | 1444 | if (buf==NULL) |
1445 | return (int)size_to_read; | 1445 | return (int)size_to_read; |
1446 | 1446 | ||
1447 | if (len>size_to_read) | 1447 | if (len>size_to_read) |
1448 | read_now = (uInt)size_to_read; | 1448 | read_now = (uInt)size_to_read; |
1449 | else | 1449 | else |
1450 | read_now = (uInt)len ; | 1450 | read_now = (uInt)len ; |
1451 | 1451 | ||
1452 | if (read_now==0) | 1452 | if (read_now==0) |
1453 | return 0; | 1453 | return 0; |
1454 | 1454 | ||
1455 | if (ZSEEK(pfile_in_zip_read_info->z_filefunc, | 1455 | if (ZSEEK(pfile_in_zip_read_info->z_filefunc, |
1456 | pfile_in_zip_read_info->filestream, | 1456 | pfile_in_zip_read_info->filestream, |
1457 | pfile_in_zip_read_info->offset_local_extrafield + | 1457 | pfile_in_zip_read_info->offset_local_extrafield + |
1458 | pfile_in_zip_read_info->pos_local_extrafield, | 1458 | pfile_in_zip_read_info->pos_local_extrafield, |
1459 | ZLIB_FILEFUNC_SEEK_SET)!=0) | 1459 | ZLIB_FILEFUNC_SEEK_SET)!=0) |
1460 | return UNZ_ERRNO; | 1460 | return UNZ_ERRNO; |
1461 | 1461 | ||
1462 | if (ZREAD(pfile_in_zip_read_info->z_filefunc, | 1462 | if (ZREAD(pfile_in_zip_read_info->z_filefunc, |
1463 | pfile_in_zip_read_info->filestream, | 1463 | pfile_in_zip_read_info->filestream, |
1464 | buf,size_to_read)!=size_to_read) | 1464 | buf,size_to_read)!=size_to_read) |
1465 | return UNZ_ERRNO; | 1465 | return UNZ_ERRNO; |
1466 | 1466 | ||
1467 | return (int)read_now; | 1467 | return (int)read_now; |
1468 | } | 1468 | } |
1469 | 1469 | ||
1470 | /* | 1470 | /* |
1471 | Close the file in zip opened with unzipOpenCurrentFile | 1471 | Close the file in zip opened with unzipOpenCurrentFile |
1472 | Return UNZ_CRCERROR if all the file was read but the CRC is not good | 1472 | Return UNZ_CRCERROR if all the file was read but the CRC is not good |
1473 | */ | 1473 | */ |
1474 | extern int ZEXPORT unzCloseCurrentFile (file) | 1474 | extern int ZEXPORT unzCloseCurrentFile (file) |
1475 | unzFile file; | 1475 | unzFile file; |
1476 | { | 1476 | { |
1477 | int err=UNZ_OK; | 1477 | int err=UNZ_OK; |
1478 | 1478 | ||
1479 | unz_s* s; | 1479 | unz_s* s; |
1480 | file_in_zip_read_info_s* pfile_in_zip_read_info; | 1480 | file_in_zip_read_info_s* pfile_in_zip_read_info; |
1481 | if (file==NULL) | 1481 | if (file==NULL) |
1482 | return UNZ_PARAMERROR; | 1482 | return UNZ_PARAMERROR; |
1483 | s=(unz_s*)file; | 1483 | s=(unz_s*)file; |
1484 | pfile_in_zip_read_info=s->pfile_in_zip_read; | 1484 | pfile_in_zip_read_info=s->pfile_in_zip_read; |
1485 | 1485 | ||
1486 | if (pfile_in_zip_read_info==NULL) | 1486 | if (pfile_in_zip_read_info==NULL) |
1487 | return UNZ_PARAMERROR; | 1487 | return UNZ_PARAMERROR; |
1488 | 1488 | ||
1489 | 1489 | ||
1490 | if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) && | 1490 | if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) && |
1491 | (!pfile_in_zip_read_info->raw)) | 1491 | (!pfile_in_zip_read_info->raw)) |
1492 | { | 1492 | { |
1493 | if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) | 1493 | if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) |
1494 | err=UNZ_CRCERROR; | 1494 | err=UNZ_CRCERROR; |
1495 | } | 1495 | } |
1496 | 1496 | ||
1497 | 1497 | ||
1498 | TRYFREE(pfile_in_zip_read_info->read_buffer); | 1498 | TRYFREE(pfile_in_zip_read_info->read_buffer); |
1499 | pfile_in_zip_read_info->read_buffer = NULL; | 1499 | pfile_in_zip_read_info->read_buffer = NULL; |
1500 | if (pfile_in_zip_read_info->stream_initialised) | 1500 | if (pfile_in_zip_read_info->stream_initialised) |
1501 | inflateEnd(&pfile_in_zip_read_info->stream); | 1501 | inflateEnd(&pfile_in_zip_read_info->stream); |
1502 | 1502 | ||
1503 | pfile_in_zip_read_info->stream_initialised = 0; | 1503 | pfile_in_zip_read_info->stream_initialised = 0; |
1504 | TRYFREE(pfile_in_zip_read_info); | 1504 | TRYFREE(pfile_in_zip_read_info); |
1505 | 1505 | ||
1506 | s->pfile_in_zip_read=NULL; | 1506 | s->pfile_in_zip_read=NULL; |
1507 | 1507 | ||
1508 | return err; | 1508 | return err; |
1509 | } | 1509 | } |
1510 | 1510 | ||
1511 | 1511 | ||
1512 | /* | 1512 | /* |
1513 | Get the global comment string of the ZipFile, in the szComment buffer. | 1513 | Get the global comment string of the ZipFile, in the szComment buffer. |
1514 | uSizeBuf is the size of the szComment buffer. | 1514 | uSizeBuf is the size of the szComment buffer. |
1515 | return the number of byte copied or an error code <0 | 1515 | return the number of byte copied or an error code <0 |
1516 | */ | 1516 | */ |
1517 | extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) | 1517 | extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf) |
1518 | unzFile file; | 1518 | unzFile file; |
1519 | char *szComment; | 1519 | char *szComment; |
1520 | uLong uSizeBuf; | 1520 | uLong uSizeBuf; |
1521 | { | 1521 | { |
1522 | int err=UNZ_OK; | 1522 | int err=UNZ_OK; |
1523 | unz_s* s; | 1523 | unz_s* s; |
1524 | uLong uReadThis ; | 1524 | uLong uReadThis ; |
1525 | if (file==NULL) | 1525 | if (file==NULL) |
1526 | return UNZ_PARAMERROR; | 1526 | return UNZ_PARAMERROR; |
1527 | s=(unz_s*)file; | 1527 | s=(unz_s*)file; |
1528 | 1528 | ||
1529 | uReadThis = uSizeBuf; | 1529 | uReadThis = uSizeBuf; |
1530 | if (uReadThis>s->gi.size_comment) | 1530 | if (uReadThis>s->gi.size_comment) |
1531 | uReadThis = s->gi.size_comment; | 1531 | uReadThis = s->gi.size_comment; |
1532 | 1532 | ||
1533 | if (ZSEEK(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0) | 1533 | if (ZSEEK(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0) |
1534 | return UNZ_ERRNO; | 1534 | return UNZ_ERRNO; |
1535 | 1535 | ||
1536 | if (uReadThis>0) | 1536 | if (uReadThis>0) |
1537 | { | 1537 | { |
1538 | *szComment='\0'; | 1538 | *szComment='\0'; |
1539 | if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis) | 1539 | if (ZREAD(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis) |
1540 | return UNZ_ERRNO; | 1540 | return UNZ_ERRNO; |
1541 | } | 1541 | } |
1542 | 1542 | ||
1543 | if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) | 1543 | if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) |
1544 | *(szComment+s->gi.size_comment)='\0'; | 1544 | *(szComment+s->gi.size_comment)='\0'; |
1545 | return (int)uReadThis; | 1545 | return (int)uReadThis; |
1546 | } | 1546 | } |
diff --git a/contrib/minizip/unzip.h b/contrib/minizip/unzip.h index 48e6832..4c2f5e1 100644 --- a/contrib/minizip/unzip.h +++ b/contrib/minizip/unzip.h | |||
@@ -1,342 +1,342 @@ | |||
1 | /* unzip.h -- IO for uncompress .zip files using zlib | 1 | /* unzip.h -- IO for uncompress .zip files using zlib |
2 | Version 0.22, May 19th, 2003 | 2 | Version 0.22, May 19th, 2003 |
3 | 3 | ||
4 | Copyright (C) 1998-2003 Gilles Vollant | 4 | Copyright (C) 1998-2003 Gilles Vollant |
5 | 5 | ||
6 | This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g | 6 | This unzip package allow extract file from .ZIP file, compatible with PKZip 2.04g |
7 | WinZip, InfoZip tools and compatible. | 7 | WinZip, InfoZip tools and compatible. |
8 | Encryption and multi volume ZipFile (span) are not supported. | 8 | Encryption and multi volume ZipFile (span) are not supported. |
9 | Old compressions used by old PKZip 1.x are not supported | 9 | Old compressions used by old PKZip 1.x are not supported |
10 | 10 | ||
11 | 11 | ||
12 | I WAIT FEEDBACK at mail info@winimage.com | 12 | I WAIT FEEDBACK at mail info@winimage.com |
13 | Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution | 13 | Visit also http://www.winimage.com/zLibDll/unzip.htm for evolution |
14 | 14 | ||
15 | Condition of use and distribution are the same than zlib : | 15 | Condition of use and distribution are the same than zlib : |
16 | 16 | ||
17 | This software is provided 'as-is', without any express or implied | 17 | This software is provided 'as-is', without any express or implied |
18 | warranty. In no event will the authors be held liable for any damages | 18 | warranty. In no event will the authors be held liable for any damages |
19 | arising from the use of this software. | 19 | arising from the use of this software. |
20 | 20 | ||
21 | Permission is granted to anyone to use this software for any purpose, | 21 | Permission is granted to anyone to use this software for any purpose, |
22 | including commercial applications, and to alter it and redistribute it | 22 | including commercial applications, and to alter it and redistribute it |
23 | freely, subject to the following restrictions: | 23 | freely, subject to the following restrictions: |
24 | 24 | ||
25 | 1. The origin of this software must not be misrepresented; you must not | 25 | 1. The origin of this software must not be misrepresented; you must not |
26 | claim that you wrote the original software. If you use this software | 26 | claim that you wrote the original software. If you use this software |
27 | in a product, an acknowledgment in the product documentation would be | 27 | in a product, an acknowledgment in the product documentation would be |
28 | appreciated but is not required. | 28 | appreciated but is not required. |
29 | 2. Altered source versions must be plainly marked as such, and must not be | 29 | 2. Altered source versions must be plainly marked as such, and must not be |
30 | misrepresented as being the original software. | 30 | misrepresented as being the original software. |
31 | 3. This notice may not be removed or altered from any source distribution. | 31 | 3. This notice may not be removed or altered from any source distribution. |
32 | 32 | ||
33 | 33 | ||
34 | */ | 34 | */ |
35 | 35 | ||
36 | /* for more info about .ZIP format, see | 36 | /* for more info about .ZIP format, see |
37 | http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip | 37 | http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip |
38 | http://www.info-zip.org/pub/infozip/doc/ | 38 | http://www.info-zip.org/pub/infozip/doc/ |
39 | PkWare has also a specification at : | 39 | PkWare has also a specification at : |
40 | ftp://ftp.pkware.com/probdesc.zip | 40 | ftp://ftp.pkware.com/probdesc.zip |
41 | */ | 41 | */ |
42 | 42 | ||
43 | #ifndef _unz_H | 43 | #ifndef _unz_H |
44 | #define _unz_H | 44 | #define _unz_H |
45 | 45 | ||
46 | #ifdef __cplusplus | 46 | #ifdef __cplusplus |
47 | extern "C" { | 47 | extern "C" { |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #ifndef _ZLIB_H | 50 | #ifndef _ZLIB_H |
51 | #include "zlib.h" | 51 | #include "zlib.h" |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #ifndef _ZLIBIOAPI_H | 54 | #ifndef _ZLIBIOAPI_H |
55 | #include "ioapi.h" | 55 | #include "ioapi.h" |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) | 58 | #if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) |
59 | /* like the STRICT of WIN32, we define a pointer that cannot be converted | 59 | /* like the STRICT of WIN32, we define a pointer that cannot be converted |
60 | from (void*) without cast */ | 60 | from (void*) without cast */ |
61 | typedef struct TagunzFile__ { int unused; } unzFile__; | 61 | typedef struct TagunzFile__ { int unused; } unzFile__; |
62 | typedef unzFile__ *unzFile; | 62 | typedef unzFile__ *unzFile; |
63 | #else | 63 | #else |
64 | typedef voidp unzFile; | 64 | typedef voidp unzFile; |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | 67 | ||
68 | #define UNZ_OK (0) | 68 | #define UNZ_OK (0) |
69 | #define UNZ_END_OF_LIST_OF_FILE (-100) | 69 | #define UNZ_END_OF_LIST_OF_FILE (-100) |
70 | #define UNZ_ERRNO (Z_ERRNO) | 70 | #define UNZ_ERRNO (Z_ERRNO) |
71 | #define UNZ_EOF (0) | 71 | #define UNZ_EOF (0) |
72 | #define UNZ_PARAMERROR (-102) | 72 | #define UNZ_PARAMERROR (-102) |
73 | #define UNZ_BADZIPFILE (-103) | 73 | #define UNZ_BADZIPFILE (-103) |
74 | #define UNZ_INTERNALERROR (-104) | 74 | #define UNZ_INTERNALERROR (-104) |
75 | #define UNZ_CRCERROR (-105) | 75 | #define UNZ_CRCERROR (-105) |
76 | 76 | ||
77 | /* tm_unz contain date/time info */ | 77 | /* tm_unz contain date/time info */ |
78 | typedef struct tm_unz_s | 78 | typedef struct tm_unz_s |
79 | { | 79 | { |
80 | uInt tm_sec; /* seconds after the minute - [0,59] */ | 80 | uInt tm_sec; /* seconds after the minute - [0,59] */ |
81 | uInt tm_min; /* minutes after the hour - [0,59] */ | 81 | uInt tm_min; /* minutes after the hour - [0,59] */ |
82 | uInt tm_hour; /* hours since midnight - [0,23] */ | 82 | uInt tm_hour; /* hours since midnight - [0,23] */ |
83 | uInt tm_mday; /* day of the month - [1,31] */ | 83 | uInt tm_mday; /* day of the month - [1,31] */ |
84 | uInt tm_mon; /* months since January - [0,11] */ | 84 | uInt tm_mon; /* months since January - [0,11] */ |
85 | uInt tm_year; /* years - [1980..2044] */ | 85 | uInt tm_year; /* years - [1980..2044] */ |
86 | } tm_unz; | 86 | } tm_unz; |
87 | 87 | ||
88 | /* unz_global_info structure contain global data about the ZIPfile | 88 | /* unz_global_info structure contain global data about the ZIPfile |
89 | These data comes from the end of central dir */ | 89 | These data comes from the end of central dir */ |
90 | typedef struct unz_global_info_s | 90 | typedef struct unz_global_info_s |
91 | { | 91 | { |
92 | uLong number_entry; /* total number of entries in | 92 | uLong number_entry; /* total number of entries in |
93 | the central dir on this disk */ | 93 | the central dir on this disk */ |
94 | uLong size_comment; /* size of the global comment of the zipfile */ | 94 | uLong size_comment; /* size of the global comment of the zipfile */ |
95 | } unz_global_info; | 95 | } unz_global_info; |
96 | 96 | ||
97 | 97 | ||
98 | /* unz_file_info contain information about a file in the zipfile */ | 98 | /* unz_file_info contain information about a file in the zipfile */ |
99 | typedef struct unz_file_info_s | 99 | typedef struct unz_file_info_s |
100 | { | 100 | { |
101 | uLong version; /* version made by 2 bytes */ | 101 | uLong version; /* version made by 2 bytes */ |
102 | uLong version_needed; /* version needed to extract 2 bytes */ | 102 | uLong version_needed; /* version needed to extract 2 bytes */ |
103 | uLong flag; /* general purpose bit flag 2 bytes */ | 103 | uLong flag; /* general purpose bit flag 2 bytes */ |
104 | uLong compression_method; /* compression method 2 bytes */ | 104 | uLong compression_method; /* compression method 2 bytes */ |
105 | uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ | 105 | uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ |
106 | uLong crc; /* crc-32 4 bytes */ | 106 | uLong crc; /* crc-32 4 bytes */ |
107 | uLong compressed_size; /* compressed size 4 bytes */ | 107 | uLong compressed_size; /* compressed size 4 bytes */ |
108 | uLong uncompressed_size; /* uncompressed size 4 bytes */ | 108 | uLong uncompressed_size; /* uncompressed size 4 bytes */ |
109 | uLong size_filename; /* filename length 2 bytes */ | 109 | uLong size_filename; /* filename length 2 bytes */ |
110 | uLong size_file_extra; /* extra field length 2 bytes */ | 110 | uLong size_file_extra; /* extra field length 2 bytes */ |
111 | uLong size_file_comment; /* file comment length 2 bytes */ | 111 | uLong size_file_comment; /* file comment length 2 bytes */ |
112 | 112 | ||
113 | uLong disk_num_start; /* disk number start 2 bytes */ | 113 | uLong disk_num_start; /* disk number start 2 bytes */ |
114 | uLong internal_fa; /* internal file attributes 2 bytes */ | 114 | uLong internal_fa; /* internal file attributes 2 bytes */ |
115 | uLong external_fa; /* external file attributes 4 bytes */ | 115 | uLong external_fa; /* external file attributes 4 bytes */ |
116 | 116 | ||
117 | tm_unz tmu_date; | 117 | tm_unz tmu_date; |
118 | } unz_file_info; | 118 | } unz_file_info; |
119 | 119 | ||
120 | extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, | 120 | extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, |
121 | const char* fileName2, | 121 | const char* fileName2, |
122 | int iCaseSensitivity)); | 122 | int iCaseSensitivity)); |
123 | /* | 123 | /* |
124 | Compare two filename (fileName1,fileName2). | 124 | Compare two filename (fileName1,fileName2). |
125 | If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) | 125 | If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) |
126 | If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi | 126 | If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi |
127 | or strcasecmp) | 127 | or strcasecmp) |
128 | If iCaseSenisivity = 0, case sensitivity is defaut of your operating system | 128 | If iCaseSenisivity = 0, case sensitivity is defaut of your operating system |
129 | (like 1 on Unix, 2 on Windows) | 129 | (like 1 on Unix, 2 on Windows) |
130 | */ | 130 | */ |
131 | 131 | ||
132 | 132 | ||
133 | extern unzFile ZEXPORT unzOpen OF((const char *path)); | 133 | extern unzFile ZEXPORT unzOpen OF((const char *path)); |
134 | /* | 134 | /* |
135 | Open a Zip file. path contain the full pathname (by example, | 135 | Open a Zip file. path contain the full pathname (by example, |
136 | on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer | 136 | on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer |
137 | "zlib/zlib113.zip". | 137 | "zlib/zlib113.zip". |
138 | If the zipfile cannot be opened (file don't exist or in not valid), the | 138 | If the zipfile cannot be opened (file don't exist or in not valid), the |
139 | return value is NULL. | 139 | return value is NULL. |
140 | Else, the return value is a unzFile Handle, usable with other function | 140 | Else, the return value is a unzFile Handle, usable with other function |
141 | of this unzip package. | 141 | of this unzip package. |
142 | */ | 142 | */ |
143 | 143 | ||
144 | extern unzFile ZEXPORT unzOpen2 OF((const char *path, | 144 | extern unzFile ZEXPORT unzOpen2 OF((const char *path, |
145 | zlib_filefunc_def* pzlib_filefunc_def)); | 145 | zlib_filefunc_def* pzlib_filefunc_def)); |
146 | /* | 146 | /* |
147 | Open a Zip file, like unzOpen, but provide a set of file low level API | 147 | Open a Zip file, like unzOpen, but provide a set of file low level API |
148 | for read/write the zip file (see ioapi.h) | 148 | for read/write the zip file (see ioapi.h) |
149 | */ | 149 | */ |
150 | 150 | ||
151 | extern int ZEXPORT unzClose OF((unzFile file)); | 151 | extern int ZEXPORT unzClose OF((unzFile file)); |
152 | /* | 152 | /* |
153 | Close a ZipFile opened with unzipOpen. | 153 | Close a ZipFile opened with unzipOpen. |
154 | If there is files inside the .Zip opened with unzOpenCurrentFile (see later), | 154 | If there is files inside the .Zip opened with unzOpenCurrentFile (see later), |
155 | these files MUST be closed with unzipCloseCurrentFile before call unzipClose. | 155 | these files MUST be closed with unzipCloseCurrentFile before call unzipClose. |
156 | return UNZ_OK if there is no problem. */ | 156 | return UNZ_OK if there is no problem. */ |
157 | 157 | ||
158 | extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, | 158 | extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, |
159 | unz_global_info *pglobal_info)); | 159 | unz_global_info *pglobal_info)); |
160 | /* | 160 | /* |
161 | Write info about the ZipFile in the *pglobal_info structure. | 161 | Write info about the ZipFile in the *pglobal_info structure. |
162 | No preparation of the structure is needed | 162 | No preparation of the structure is needed |
163 | return UNZ_OK if there is no problem. */ | 163 | return UNZ_OK if there is no problem. */ |
164 | 164 | ||
165 | 165 | ||
166 | extern int ZEXPORT unzGetGlobalComment OF((unzFile file, | 166 | extern int ZEXPORT unzGetGlobalComment OF((unzFile file, |
167 | char *szComment, | 167 | char *szComment, |
168 | uLong uSizeBuf)); | 168 | uLong uSizeBuf)); |
169 | /* | 169 | /* |
170 | Get the global comment string of the ZipFile, in the szComment buffer. | 170 | Get the global comment string of the ZipFile, in the szComment buffer. |
171 | uSizeBuf is the size of the szComment buffer. | 171 | uSizeBuf is the size of the szComment buffer. |
172 | return the number of byte copied or an error code <0 | 172 | return the number of byte copied or an error code <0 |
173 | */ | 173 | */ |
174 | 174 | ||
175 | 175 | ||
176 | /***************************************************************************/ | 176 | /***************************************************************************/ |
177 | /* Unzip package allow you browse the directory of the zipfile */ | 177 | /* Unzip package allow you browse the directory of the zipfile */ |
178 | 178 | ||
179 | extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); | 179 | extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); |
180 | /* | 180 | /* |
181 | Set the current file of the zipfile to the first file. | 181 | Set the current file of the zipfile to the first file. |
182 | return UNZ_OK if there is no problem | 182 | return UNZ_OK if there is no problem |
183 | */ | 183 | */ |
184 | 184 | ||
185 | extern int ZEXPORT unzGoToNextFile OF((unzFile file)); | 185 | extern int ZEXPORT unzGoToNextFile OF((unzFile file)); |
186 | /* | 186 | /* |
187 | Set the current file of the zipfile to the next file. | 187 | Set the current file of the zipfile to the next file. |
188 | return UNZ_OK if there is no problem | 188 | return UNZ_OK if there is no problem |
189 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. | 189 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. |
190 | */ | 190 | */ |
191 | 191 | ||
192 | extern int ZEXPORT unzLocateFile OF((unzFile file, | 192 | extern int ZEXPORT unzLocateFile OF((unzFile file, |
193 | const char *szFileName, | 193 | const char *szFileName, |
194 | int iCaseSensitivity)); | 194 | int iCaseSensitivity)); |
195 | /* | 195 | /* |
196 | Try locate the file szFileName in the zipfile. | 196 | Try locate the file szFileName in the zipfile. |
197 | For the iCaseSensitivity signification, see unzStringFileNameCompare | 197 | For the iCaseSensitivity signification, see unzStringFileNameCompare |
198 | 198 | ||
199 | return value : | 199 | return value : |
200 | UNZ_OK if the file is found. It becomes the current file. | 200 | UNZ_OK if the file is found. It becomes the current file. |
201 | UNZ_END_OF_LIST_OF_FILE if the file is not found | 201 | UNZ_END_OF_LIST_OF_FILE if the file is not found |
202 | */ | 202 | */ |
203 | 203 | ||
204 | 204 | ||
205 | /* ****************************************** */ | 205 | /* ****************************************** */ |
206 | /* Ryan supplied functions */ | 206 | /* Ryan supplied functions */ |
207 | /* unz_file_info contain information about a file in the zipfile */ | 207 | /* unz_file_info contain information about a file in the zipfile */ |
208 | typedef struct unz_file_pos_s | 208 | typedef struct unz_file_pos_s |
209 | { | 209 | { |
210 | uLong pos_in_zip_directory; /* offset in zip file directory */ | 210 | uLong pos_in_zip_directory; /* offset in zip file directory */ |
211 | uLong num_of_file; /* # of file */ | 211 | uLong num_of_file; /* # of file */ |
212 | } unz_file_pos; | 212 | } unz_file_pos; |
213 | 213 | ||
214 | extern int ZEXPORT unzGetFilePos( | 214 | extern int ZEXPORT unzGetFilePos( |
215 | unzFile file, | 215 | unzFile file, |
216 | unz_file_pos* file_pos); | 216 | unz_file_pos* file_pos); |
217 | 217 | ||
218 | extern int ZEXPORT unzGoToFilePos( | 218 | extern int ZEXPORT unzGoToFilePos( |
219 | unzFile file, | 219 | unzFile file, |
220 | unz_file_pos* file_pos); | 220 | unz_file_pos* file_pos); |
221 | 221 | ||
222 | /* ****************************************** */ | 222 | /* ****************************************** */ |
223 | 223 | ||
224 | extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, | 224 | extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, |
225 | unz_file_info *pfile_info, | 225 | unz_file_info *pfile_info, |
226 | char *szFileName, | 226 | char *szFileName, |
227 | uLong fileNameBufferSize, | 227 | uLong fileNameBufferSize, |
228 | void *extraField, | 228 | void *extraField, |
229 | uLong extraFieldBufferSize, | 229 | uLong extraFieldBufferSize, |
230 | char *szComment, | 230 | char *szComment, |
231 | uLong commentBufferSize)); | 231 | uLong commentBufferSize)); |
232 | /* | 232 | /* |
233 | Get Info about the current file | 233 | Get Info about the current file |
234 | if pfile_info!=NULL, the *pfile_info structure will contain somes info about | 234 | if pfile_info!=NULL, the *pfile_info structure will contain somes info about |
235 | the current file | 235 | the current file |
236 | if szFileName!=NULL, the filemane string will be copied in szFileName | 236 | if szFileName!=NULL, the filemane string will be copied in szFileName |
237 | (fileNameBufferSize is the size of the buffer) | 237 | (fileNameBufferSize is the size of the buffer) |
238 | if extraField!=NULL, the extra field information will be copied in extraField | 238 | if extraField!=NULL, the extra field information will be copied in extraField |
239 | (extraFieldBufferSize is the size of the buffer). | 239 | (extraFieldBufferSize is the size of the buffer). |
240 | This is the Central-header version of the extra field | 240 | This is the Central-header version of the extra field |
241 | if szComment!=NULL, the comment string of the file will be copied in szComment | 241 | if szComment!=NULL, the comment string of the file will be copied in szComment |
242 | (commentBufferSize is the size of the buffer) | 242 | (commentBufferSize is the size of the buffer) |
243 | */ | 243 | */ |
244 | 244 | ||
245 | /***************************************************************************/ | 245 | /***************************************************************************/ |
246 | /* for reading the content of the current zipfile, you can open it, read data | 246 | /* for reading the content of the current zipfile, you can open it, read data |
247 | from it, and close it (you can close it before reading all the file) | 247 | from it, and close it (you can close it before reading all the file) |
248 | */ | 248 | */ |
249 | 249 | ||
250 | extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); | 250 | extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); |
251 | /* | 251 | /* |
252 | Open for reading data the current file in the zipfile. | 252 | Open for reading data the current file in the zipfile. |
253 | If there is no error, the return value is UNZ_OK. | 253 | If there is no error, the return value is UNZ_OK. |
254 | */ | 254 | */ |
255 | 255 | ||
256 | extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, | 256 | extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, |
257 | const char* password)); | 257 | const char* password)); |
258 | /* | 258 | /* |
259 | Open for reading data the current file in the zipfile. | 259 | Open for reading data the current file in the zipfile. |
260 | password is a crypting password | 260 | password is a crypting password |
261 | If there is no error, the return value is UNZ_OK. | 261 | If there is no error, the return value is UNZ_OK. |
262 | */ | 262 | */ |
263 | 263 | ||
264 | extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, | 264 | extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, |
265 | int* method, | 265 | int* method, |
266 | int* level, | 266 | int* level, |
267 | int raw)); | 267 | int raw)); |
268 | /* | 268 | /* |
269 | Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) | 269 | Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) |
270 | if raw==1 | 270 | if raw==1 |
271 | *method will receive method of compression, *level will receive level of | 271 | *method will receive method of compression, *level will receive level of |
272 | compression | 272 | compression |
273 | note : you can set level parameter as NULL (if you did not want known level, | 273 | note : you can set level parameter as NULL (if you did not want known level, |
274 | but you CANNOT set method parameter as NULL | 274 | but you CANNOT set method parameter as NULL |
275 | */ | 275 | */ |
276 | 276 | ||
277 | extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, | 277 | extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, |
278 | int* method, | 278 | int* method, |
279 | int* level, | 279 | int* level, |
280 | int raw, | 280 | int raw, |
281 | const char* password)); | 281 | const char* password)); |
282 | /* | 282 | /* |
283 | Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) | 283 | Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) |
284 | if raw==1 | 284 | if raw==1 |
285 | *method will receive method of compression, *level will receive level of | 285 | *method will receive method of compression, *level will receive level of |
286 | compression | 286 | compression |
287 | note : you can set level parameter as NULL (if you did not want known level, | 287 | note : you can set level parameter as NULL (if you did not want known level, |
288 | but you CANNOT set method parameter as NULL | 288 | but you CANNOT set method parameter as NULL |
289 | */ | 289 | */ |
290 | 290 | ||
291 | 291 | ||
292 | extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); | 292 | extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); |
293 | /* | 293 | /* |
294 | Close the file in zip opened with unzOpenCurrentFile | 294 | Close the file in zip opened with unzOpenCurrentFile |
295 | Return UNZ_CRCERROR if all the file was read but the CRC is not good | 295 | Return UNZ_CRCERROR if all the file was read but the CRC is not good |
296 | */ | 296 | */ |
297 | 297 | ||
298 | extern int ZEXPORT unzReadCurrentFile OF((unzFile file, | 298 | extern int ZEXPORT unzReadCurrentFile OF((unzFile file, |
299 | voidp buf, | 299 | voidp buf, |
300 | unsigned len)); | 300 | unsigned len)); |
301 | /* | 301 | /* |
302 | Read bytes from the current file (opened by unzOpenCurrentFile) | 302 | Read bytes from the current file (opened by unzOpenCurrentFile) |
303 | buf contain buffer where data must be copied | 303 | buf contain buffer where data must be copied |
304 | len the size of buf. | 304 | len the size of buf. |
305 | 305 | ||
306 | return the number of byte copied if somes bytes are copied | 306 | return the number of byte copied if somes bytes are copied |
307 | return 0 if the end of file was reached | 307 | return 0 if the end of file was reached |
308 | return <0 with error code if there is an error | 308 | return <0 with error code if there is an error |
309 | (UNZ_ERRNO for IO error, or zLib error for uncompress error) | 309 | (UNZ_ERRNO for IO error, or zLib error for uncompress error) |
310 | */ | 310 | */ |
311 | 311 | ||
312 | extern z_off_t ZEXPORT unztell OF((unzFile file)); | 312 | extern z_off_t ZEXPORT unztell OF((unzFile file)); |
313 | /* | 313 | /* |
314 | Give the current position in uncompressed data | 314 | Give the current position in uncompressed data |
315 | */ | 315 | */ |
316 | 316 | ||
317 | extern int ZEXPORT unzeof OF((unzFile file)); | 317 | extern int ZEXPORT unzeof OF((unzFile file)); |
318 | /* | 318 | /* |
319 | return 1 if the end of file was reached, 0 elsewhere | 319 | return 1 if the end of file was reached, 0 elsewhere |
320 | */ | 320 | */ |
321 | 321 | ||
322 | extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, | 322 | extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, |
323 | voidp buf, | 323 | voidp buf, |
324 | unsigned len)); | 324 | unsigned len)); |
325 | /* | 325 | /* |
326 | Read extra field from the current file (opened by unzOpenCurrentFile) | 326 | Read extra field from the current file (opened by unzOpenCurrentFile) |
327 | This is the local-header version of the extra field (sometimes, there is | 327 | This is the local-header version of the extra field (sometimes, there is |
328 | more info in the local-header version than in the central-header) | 328 | more info in the local-header version than in the central-header) |
329 | 329 | ||
330 | if buf==NULL, it return the size of the local extra field | 330 | if buf==NULL, it return the size of the local extra field |
331 | 331 | ||
332 | if buf!=NULL, len is the size of the buffer, the extra header is copied in | 332 | if buf!=NULL, len is the size of the buffer, the extra header is copied in |
333 | buf. | 333 | buf. |
334 | the return value is the number of bytes copied in buf, or (if <0) | 334 | the return value is the number of bytes copied in buf, or (if <0) |
335 | the error code | 335 | the error code |
336 | */ | 336 | */ |
337 | 337 | ||
338 | #ifdef __cplusplus | 338 | #ifdef __cplusplus |
339 | } | 339 | } |
340 | #endif | 340 | #endif |
341 | 341 | ||
342 | #endif /* _unz_H */ | 342 | #endif /* _unz_H */ |
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c index 00587fb..193c539 100644 --- a/contrib/minizip/zip.c +++ b/contrib/minizip/zip.c | |||
@@ -1,1168 +1,1168 @@ | |||
1 | /* zip.c -- IO on .zip files using zlib | 1 | /* zip.c -- IO on .zip files using zlib |
2 | Version 0.22, May 19th, 2003 | 2 | Version 0.22, May 19th, 2003 |
3 | 3 | ||
4 | Read zip.h for more info | 4 | Read zip.h for more info |
5 | */ | 5 | */ |
6 | 6 | ||
7 | 7 | ||
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
10 | #include <string.h> | 10 | #include <string.h> |
11 | #include <time.h> | 11 | #include <time.h> |
12 | #include "zlib.h" | 12 | #include "zlib.h" |
13 | #include "zip.h" | 13 | #include "zip.h" |
14 | 14 | ||
15 | #ifdef STDC | 15 | #ifdef STDC |
16 | # include <stddef.h> | 16 | # include <stddef.h> |
17 | # include <string.h> | 17 | # include <string.h> |
18 | # include <stdlib.h> | 18 | # include <stdlib.h> |
19 | #endif | 19 | #endif |
20 | #ifdef NO_ERRNO_H | 20 | #ifdef NO_ERRNO_H |
21 | extern int errno; | 21 | extern int errno; |
22 | #else | 22 | #else |
23 | # include <errno.h> | 23 | # include <errno.h> |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | 26 | ||
27 | #ifndef local | 27 | #ifndef local |
28 | # define local static | 28 | # define local static |
29 | #endif | 29 | #endif |
30 | /* compile with -Dlocal if your debugger can't find static symbols */ | 30 | /* compile with -Dlocal if your debugger can't find static symbols */ |
31 | 31 | ||
32 | #ifndef VERSIONMADEBY | 32 | #ifndef VERSIONMADEBY |
33 | # define VERSIONMADEBY (0x0) /* platform depedent */ | 33 | # define VERSIONMADEBY (0x0) /* platform depedent */ |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #ifndef Z_BUFSIZE | 36 | #ifndef Z_BUFSIZE |
37 | #define Z_BUFSIZE (16384) | 37 | #define Z_BUFSIZE (16384) |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #ifndef Z_MAXFILENAMEINZIP | 40 | #ifndef Z_MAXFILENAMEINZIP |
41 | #define Z_MAXFILENAMEINZIP (256) | 41 | #define Z_MAXFILENAMEINZIP (256) |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | #ifndef ALLOC | 44 | #ifndef ALLOC |
45 | # define ALLOC(size) (malloc(size)) | 45 | # define ALLOC(size) (malloc(size)) |
46 | #endif | 46 | #endif |
47 | #ifndef TRYFREE | 47 | #ifndef TRYFREE |
48 | # define TRYFREE(p) {if (p) free(p);} | 48 | # define TRYFREE(p) {if (p) free(p);} |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | /* | 51 | /* |
52 | #define SIZECENTRALDIRITEM (0x2e) | 52 | #define SIZECENTRALDIRITEM (0x2e) |
53 | #define SIZEZIPLOCALHEADER (0x1e) | 53 | #define SIZEZIPLOCALHEADER (0x1e) |
54 | */ | 54 | */ |
55 | 55 | ||
56 | /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ | 56 | /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ |
57 | 57 | ||
58 | #ifndef SEEK_CUR | 58 | #ifndef SEEK_CUR |
59 | #define SEEK_CUR 1 | 59 | #define SEEK_CUR 1 |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | #ifndef SEEK_END | 62 | #ifndef SEEK_END |
63 | #define SEEK_END 2 | 63 | #define SEEK_END 2 |
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | #ifndef SEEK_SET | 66 | #ifndef SEEK_SET |
67 | #define SEEK_SET 0 | 67 | #define SEEK_SET 0 |
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | #ifndef DEF_MEM_LEVEL | 70 | #ifndef DEF_MEM_LEVEL |
71 | #if MAX_MEM_LEVEL >= 8 | 71 | #if MAX_MEM_LEVEL >= 8 |
72 | # define DEF_MEM_LEVEL 8 | 72 | # define DEF_MEM_LEVEL 8 |
73 | #else | 73 | #else |
74 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL | 74 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL |
75 | #endif | 75 | #endif |
76 | #endif | 76 | #endif |
77 | const char zip_copyright[] = | 77 | const char zip_copyright[] = |
78 | " zip 0.22 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; | 78 | " zip 0.22 Copyright 1998-2003 Gilles Vollant - http://www.winimage.com/zLibDll"; |
79 | 79 | ||
80 | 80 | ||
81 | #define SIZEDATA_INDATABLOCK (4096-(4*4)) | 81 | #define SIZEDATA_INDATABLOCK (4096-(4*4)) |
82 | 82 | ||
83 | #define LOCALHEADERMAGIC (0x04034b50) | 83 | #define LOCALHEADERMAGIC (0x04034b50) |
84 | #define CENTRALHEADERMAGIC (0x02014b50) | 84 | #define CENTRALHEADERMAGIC (0x02014b50) |
85 | #define ENDHEADERMAGIC (0x06054b50) | 85 | #define ENDHEADERMAGIC (0x06054b50) |
86 | 86 | ||
87 | #define FLAG_LOCALHEADER_OFFSET (0x06) | 87 | #define FLAG_LOCALHEADER_OFFSET (0x06) |
88 | #define CRC_LOCALHEADER_OFFSET (0x0e) | 88 | #define CRC_LOCALHEADER_OFFSET (0x0e) |
89 | 89 | ||
90 | #define SIZECENTRALHEADER (0x2e) /* 46 */ | 90 | #define SIZECENTRALHEADER (0x2e) /* 46 */ |
91 | 91 | ||
92 | typedef struct linkedlist_datablock_internal_s | 92 | typedef struct linkedlist_datablock_internal_s |
93 | { | 93 | { |
94 | struct linkedlist_datablock_internal_s* next_datablock; | 94 | struct linkedlist_datablock_internal_s* next_datablock; |
95 | uLong avail_in_this_block; | 95 | uLong avail_in_this_block; |
96 | uLong filled_in_this_block; | 96 | uLong filled_in_this_block; |
97 | uLong unused; /* for future use and alignement */ | 97 | uLong unused; /* for future use and alignement */ |
98 | unsigned char data[SIZEDATA_INDATABLOCK]; | 98 | unsigned char data[SIZEDATA_INDATABLOCK]; |
99 | } linkedlist_datablock_internal; | 99 | } linkedlist_datablock_internal; |
100 | 100 | ||
101 | typedef struct linkedlist_data_s | 101 | typedef struct linkedlist_data_s |
102 | { | 102 | { |
103 | linkedlist_datablock_internal* first_block; | 103 | linkedlist_datablock_internal* first_block; |
104 | linkedlist_datablock_internal* last_block; | 104 | linkedlist_datablock_internal* last_block; |
105 | } linkedlist_data; | 105 | } linkedlist_data; |
106 | 106 | ||
107 | 107 | ||
108 | typedef struct | 108 | typedef struct |
109 | { | 109 | { |
110 | z_stream stream; /* zLib stream structure for inflate */ | 110 | z_stream stream; /* zLib stream structure for inflate */ |
111 | int stream_initialised; /* 1 is stream is initialised */ | 111 | int stream_initialised; /* 1 is stream is initialised */ |
112 | uInt pos_in_buffered_data; /* last written byte in buffered_data */ | 112 | uInt pos_in_buffered_data; /* last written byte in buffered_data */ |
113 | 113 | ||
114 | uLong pos_local_header; /* offset of the local header of the file | 114 | uLong pos_local_header; /* offset of the local header of the file |
115 | currenty writing */ | 115 | currenty writing */ |
116 | char* central_header; /* central header data for the current file */ | 116 | char* central_header; /* central header data for the current file */ |
117 | uLong size_centralheader; /* size of the central header for cur file */ | 117 | uLong size_centralheader; /* size of the central header for cur file */ |
118 | uLong flag; /* flag of the file currently writing */ | 118 | uLong flag; /* flag of the file currently writing */ |
119 | 119 | ||
120 | int method; /* compression method of file currenty wr.*/ | 120 | int method; /* compression method of file currenty wr.*/ |
121 | int raw; /* 1 for directly writing raw data */ | 121 | int raw; /* 1 for directly writing raw data */ |
122 | Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ | 122 | Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ |
123 | uLong dosDate; | 123 | uLong dosDate; |
124 | uLong crc32; | 124 | uLong crc32; |
125 | int encrypt; | 125 | int encrypt; |
126 | #ifndef NOCRYPT | 126 | #ifndef NOCRYPT |
127 | unsigned long keys[3]; /* keys defining the pseudo-random sequence */ | 127 | unsigned long keys[3]; /* keys defining the pseudo-random sequence */ |
128 | const unsigned long* pcrc_32_tab; | 128 | const unsigned long* pcrc_32_tab; |
129 | int crypt_header_size; | 129 | int crypt_header_size; |
130 | #endif | 130 | #endif |
131 | } curfile_info; | 131 | } curfile_info; |
132 | 132 | ||
133 | typedef struct | 133 | typedef struct |
134 | { | 134 | { |
135 | zlib_filefunc_def z_filefunc; | 135 | zlib_filefunc_def z_filefunc; |
136 | voidpf filestream; /* io structore of the zipfile */ | 136 | voidpf filestream; /* io structore of the zipfile */ |
137 | linkedlist_data central_dir;/* datablock with central dir in construction*/ | 137 | linkedlist_data central_dir;/* datablock with central dir in construction*/ |
138 | int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ | 138 | int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ |
139 | curfile_info ci; /* info on the file curretly writing */ | 139 | curfile_info ci; /* info on the file curretly writing */ |
140 | 140 | ||
141 | uLong begin_pos; /* position of the beginning of the zipfile */ | 141 | uLong begin_pos; /* position of the beginning of the zipfile */ |
142 | uLong add_position_when_writting_offset; | 142 | uLong add_position_when_writting_offset; |
143 | uLong number_entry; | 143 | uLong number_entry; |
144 | } zip_internal; | 144 | } zip_internal; |
145 | 145 | ||
146 | 146 | ||
147 | 147 | ||
148 | #ifndef NOCRYPT | 148 | #ifndef NOCRYPT |
149 | #define INCLUDECRYPTINGCODE_IFCRYPTALLOWED | 149 | #define INCLUDECRYPTINGCODE_IFCRYPTALLOWED |
150 | #include "crypt.h" | 150 | #include "crypt.h" |
151 | #endif | 151 | #endif |
152 | 152 | ||
153 | local linkedlist_datablock_internal* allocate_new_datablock() | 153 | local linkedlist_datablock_internal* allocate_new_datablock() |
154 | { | 154 | { |
155 | linkedlist_datablock_internal* ldi; | 155 | linkedlist_datablock_internal* ldi; |
156 | ldi = (linkedlist_datablock_internal*) | 156 | ldi = (linkedlist_datablock_internal*) |
157 | ALLOC(sizeof(linkedlist_datablock_internal)); | 157 | ALLOC(sizeof(linkedlist_datablock_internal)); |
158 | if (ldi!=NULL) | 158 | if (ldi!=NULL) |
159 | { | 159 | { |
160 | ldi->next_datablock = NULL ; | 160 | ldi->next_datablock = NULL ; |
161 | ldi->filled_in_this_block = 0 ; | 161 | ldi->filled_in_this_block = 0 ; |
162 | ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; | 162 | ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; |
163 | } | 163 | } |
164 | return ldi; | 164 | return ldi; |
165 | } | 165 | } |
166 | 166 | ||
167 | local void free_datablock(ldi) | 167 | local void free_datablock(ldi) |
168 | linkedlist_datablock_internal* ldi; | 168 | linkedlist_datablock_internal* ldi; |
169 | { | 169 | { |
170 | while (ldi!=NULL) | 170 | while (ldi!=NULL) |
171 | { | 171 | { |
172 | linkedlist_datablock_internal* ldinext = ldi->next_datablock; | 172 | linkedlist_datablock_internal* ldinext = ldi->next_datablock; |
173 | TRYFREE(ldi); | 173 | TRYFREE(ldi); |
174 | ldi = ldinext; | 174 | ldi = ldinext; |
175 | } | 175 | } |
176 | } | 176 | } |
177 | 177 | ||
178 | local void init_linkedlist(ll) | 178 | local void init_linkedlist(ll) |
179 | linkedlist_data* ll; | 179 | linkedlist_data* ll; |
180 | { | 180 | { |
181 | ll->first_block = ll->last_block = NULL; | 181 | ll->first_block = ll->last_block = NULL; |
182 | } | 182 | } |
183 | 183 | ||
184 | local void free_linkedlist(ll) | 184 | local void free_linkedlist(ll) |
185 | linkedlist_data* ll; | 185 | linkedlist_data* ll; |
186 | { | 186 | { |
187 | free_datablock(ll->first_block); | 187 | free_datablock(ll->first_block); |
188 | ll->first_block = ll->last_block = NULL; | 188 | ll->first_block = ll->last_block = NULL; |
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | local int add_data_in_datablock(ll,buf,len) | 192 | local int add_data_in_datablock(ll,buf,len) |
193 | linkedlist_data* ll; | 193 | linkedlist_data* ll; |
194 | const void* buf; | 194 | const void* buf; |
195 | uLong len; | 195 | uLong len; |
196 | { | 196 | { |
197 | linkedlist_datablock_internal* ldi; | 197 | linkedlist_datablock_internal* ldi; |
198 | const unsigned char* from_copy; | 198 | const unsigned char* from_copy; |
199 | 199 | ||
200 | if (ll==NULL) | 200 | if (ll==NULL) |
201 | return ZIP_INTERNALERROR; | 201 | return ZIP_INTERNALERROR; |
202 | 202 | ||
203 | if (ll->last_block == NULL) | 203 | if (ll->last_block == NULL) |
204 | { | 204 | { |
205 | ll->first_block = ll->last_block = allocate_new_datablock(); | 205 | ll->first_block = ll->last_block = allocate_new_datablock(); |
206 | if (ll->first_block == NULL) | 206 | if (ll->first_block == NULL) |
207 | return ZIP_INTERNALERROR; | 207 | return ZIP_INTERNALERROR; |
208 | } | 208 | } |
209 | 209 | ||
210 | ldi = ll->last_block; | 210 | ldi = ll->last_block; |
211 | from_copy = (unsigned char*)buf; | 211 | from_copy = (unsigned char*)buf; |
212 | 212 | ||
213 | while (len>0) | 213 | while (len>0) |
214 | { | 214 | { |
215 | uInt copy_this; | 215 | uInt copy_this; |
216 | uInt i; | 216 | uInt i; |
217 | unsigned char* to_copy; | 217 | unsigned char* to_copy; |
218 | 218 | ||
219 | if (ldi->avail_in_this_block==0) | 219 | if (ldi->avail_in_this_block==0) |
220 | { | 220 | { |
221 | ldi->next_datablock = allocate_new_datablock(); | 221 | ldi->next_datablock = allocate_new_datablock(); |
222 | if (ldi->next_datablock == NULL) | 222 | if (ldi->next_datablock == NULL) |
223 | return ZIP_INTERNALERROR; | 223 | return ZIP_INTERNALERROR; |
224 | ldi = ldi->next_datablock ; | 224 | ldi = ldi->next_datablock ; |
225 | ll->last_block = ldi; | 225 | ll->last_block = ldi; |
226 | } | 226 | } |
227 | 227 | ||
228 | if (ldi->avail_in_this_block < len) | 228 | if (ldi->avail_in_this_block < len) |
229 | copy_this = (uInt)ldi->avail_in_this_block; | 229 | copy_this = (uInt)ldi->avail_in_this_block; |
230 | else | 230 | else |
231 | copy_this = (uInt)len; | 231 | copy_this = (uInt)len; |
232 | 232 | ||
233 | to_copy = &(ldi->data[ldi->filled_in_this_block]); | 233 | to_copy = &(ldi->data[ldi->filled_in_this_block]); |
234 | 234 | ||
235 | for (i=0;i<copy_this;i++) | 235 | for (i=0;i<copy_this;i++) |
236 | *(to_copy+i)=*(from_copy+i); | 236 | *(to_copy+i)=*(from_copy+i); |
237 | 237 | ||
238 | ldi->filled_in_this_block += copy_this; | 238 | ldi->filled_in_this_block += copy_this; |
239 | ldi->avail_in_this_block -= copy_this; | 239 | ldi->avail_in_this_block -= copy_this; |
240 | from_copy += copy_this ; | 240 | from_copy += copy_this ; |
241 | len -= copy_this; | 241 | len -= copy_this; |
242 | } | 242 | } |
243 | return ZIP_OK; | 243 | return ZIP_OK; |
244 | } | 244 | } |
245 | 245 | ||
246 | 246 | ||
247 | 247 | ||
248 | /****************************************************************************/ | 248 | /****************************************************************************/ |
249 | 249 | ||
250 | #ifndef NO_ADDFILEINEXISTINGZIP | 250 | #ifndef NO_ADDFILEINEXISTINGZIP |
251 | /* =========================================================================== | 251 | /* =========================================================================== |
252 | Inputs a long in LSB order to the given file | 252 | Inputs a long in LSB order to the given file |
253 | nbByte == 1, 2 or 4 (byte, short or long) | 253 | nbByte == 1, 2 or 4 (byte, short or long) |
254 | */ | 254 | */ |
255 | 255 | ||
256 | local int ziplocal_putValue OF((const zlib_filefunc_def* pzlib_filefunc_def, | 256 | local int ziplocal_putValue OF((const zlib_filefunc_def* pzlib_filefunc_def, |
257 | voidpf filestream, uLong x, int nbByte)); | 257 | voidpf filestream, uLong x, int nbByte)); |
258 | local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte) | 258 | local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte) |
259 | const zlib_filefunc_def* pzlib_filefunc_def; | 259 | const zlib_filefunc_def* pzlib_filefunc_def; |
260 | voidpf filestream; | 260 | voidpf filestream; |
261 | uLong x; | 261 | uLong x; |
262 | int nbByte; | 262 | int nbByte; |
263 | { | 263 | { |
264 | unsigned char buf[4]; | 264 | unsigned char buf[4]; |
265 | int n; | 265 | int n; |
266 | for (n = 0; n < nbByte; n++) { | 266 | for (n = 0; n < nbByte; n++) { |
267 | buf[n] = (unsigned char)(x & 0xff); | 267 | buf[n] = (unsigned char)(x & 0xff); |
268 | x >>= 8; | 268 | x >>= 8; |
269 | } | 269 | } |
270 | if (ZWRITE(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte) | 270 | if (ZWRITE(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte) |
271 | return ZIP_ERRNO; | 271 | return ZIP_ERRNO; |
272 | else | 272 | else |
273 | return ZIP_OK; | 273 | return ZIP_OK; |
274 | } | 274 | } |
275 | 275 | ||
276 | local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte)); | 276 | local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte)); |
277 | local void ziplocal_putValue_inmemory (dest, x, nbByte) | 277 | local void ziplocal_putValue_inmemory (dest, x, nbByte) |
278 | void* dest; | 278 | void* dest; |
279 | uLong x; | 279 | uLong x; |
280 | int nbByte; | 280 | int nbByte; |
281 | { | 281 | { |
282 | unsigned char* buf=(unsigned char*)dest; | 282 | unsigned char* buf=(unsigned char*)dest; |
283 | int n; | 283 | int n; |
284 | for (n = 0; n < nbByte; n++) { | 284 | for (n = 0; n < nbByte; n++) { |
285 | buf[n] = (unsigned char)(x & 0xff); | 285 | buf[n] = (unsigned char)(x & 0xff); |
286 | x >>= 8; | 286 | x >>= 8; |
287 | } | 287 | } |
288 | } | 288 | } |
289 | /****************************************************************************/ | 289 | /****************************************************************************/ |
290 | 290 | ||
291 | 291 | ||
292 | local uLong ziplocal_TmzDateToDosDate(ptm,dosDate) | 292 | local uLong ziplocal_TmzDateToDosDate(ptm,dosDate) |
293 | const tm_zip* ptm; | 293 | const tm_zip* ptm; |
294 | uLong dosDate; | 294 | uLong dosDate; |
295 | { | 295 | { |
296 | uLong year = (uLong)ptm->tm_year; | 296 | uLong year = (uLong)ptm->tm_year; |
297 | if (year>1980) | 297 | if (year>1980) |
298 | year-=1980; | 298 | year-=1980; |
299 | else if (year>80) | 299 | else if (year>80) |
300 | year-=80; | 300 | year-=80; |
301 | return | 301 | return |
302 | (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | | 302 | (uLong) (((ptm->tm_mday) + (32 * (ptm->tm_mon+1)) + (512 * year)) << 16) | |
303 | ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); | 303 | ((ptm->tm_sec/2) + (32* ptm->tm_min) + (2048 * (uLong)ptm->tm_hour)); |
304 | } | 304 | } |
305 | 305 | ||
306 | 306 | ||
307 | /****************************************************************************/ | 307 | /****************************************************************************/ |
308 | 308 | ||
309 | local int ziplocal_getByte OF(( | 309 | local int ziplocal_getByte OF(( |
310 | const zlib_filefunc_def* pzlib_filefunc_def, | 310 | const zlib_filefunc_def* pzlib_filefunc_def, |
311 | voidpf filestream, | 311 | voidpf filestream, |
312 | int *pi)); | 312 | int *pi)); |
313 | 313 | ||
314 | local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi) | 314 | local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi) |
315 | const zlib_filefunc_def* pzlib_filefunc_def; | 315 | const zlib_filefunc_def* pzlib_filefunc_def; |
316 | voidpf filestream; | 316 | voidpf filestream; |
317 | int *pi; | 317 | int *pi; |
318 | { | 318 | { |
319 | unsigned char c; | 319 | unsigned char c; |
320 | int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); | 320 | int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1); |
321 | if (err==1) | 321 | if (err==1) |
322 | { | 322 | { |
323 | *pi = (int)c; | 323 | *pi = (int)c; |
324 | return ZIP_OK; | 324 | return ZIP_OK; |
325 | } | 325 | } |
326 | else | 326 | else |
327 | { | 327 | { |
328 | if (ZERROR(*pzlib_filefunc_def,filestream)) | 328 | if (ZERROR(*pzlib_filefunc_def,filestream)) |
329 | return ZIP_ERRNO; | 329 | return ZIP_ERRNO; |
330 | else | 330 | else |
331 | return ZIP_EOF; | 331 | return ZIP_EOF; |
332 | } | 332 | } |
333 | } | 333 | } |
334 | 334 | ||
335 | 335 | ||
336 | /* =========================================================================== | 336 | /* =========================================================================== |
337 | Reads a long in LSB order from the given gz_stream. Sets | 337 | Reads a long in LSB order from the given gz_stream. Sets |
338 | */ | 338 | */ |
339 | local int ziplocal_getShort OF(( | 339 | local int ziplocal_getShort OF(( |
340 | const zlib_filefunc_def* pzlib_filefunc_def, | 340 | const zlib_filefunc_def* pzlib_filefunc_def, |
341 | voidpf filestream, | 341 | voidpf filestream, |
342 | uLong *pX)); | 342 | uLong *pX)); |
343 | 343 | ||
344 | local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX) | 344 | local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX) |
345 | const zlib_filefunc_def* pzlib_filefunc_def; | 345 | const zlib_filefunc_def* pzlib_filefunc_def; |
346 | voidpf filestream; | 346 | voidpf filestream; |
347 | uLong *pX; | 347 | uLong *pX; |
348 | { | 348 | { |
349 | uLong x ; | 349 | uLong x ; |
350 | int i; | 350 | int i; |
351 | int err; | 351 | int err; |
352 | 352 | ||
353 | err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); | 353 | err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); |
354 | x = (uLong)i; | 354 | x = (uLong)i; |
355 | 355 | ||
356 | if (err==ZIP_OK) | 356 | if (err==ZIP_OK) |
357 | err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); | 357 | err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); |
358 | x += ((uLong)i)<<8; | 358 | x += ((uLong)i)<<8; |
359 | 359 | ||
360 | if (err==ZIP_OK) | 360 | if (err==ZIP_OK) |
361 | *pX = x; | 361 | *pX = x; |
362 | else | 362 | else |
363 | *pX = 0; | 363 | *pX = 0; |
364 | return err; | 364 | return err; |
365 | } | 365 | } |
366 | 366 | ||
367 | local int ziplocal_getLong OF(( | 367 | local int ziplocal_getLong OF(( |
368 | const zlib_filefunc_def* pzlib_filefunc_def, | 368 | const zlib_filefunc_def* pzlib_filefunc_def, |
369 | voidpf filestream, | 369 | voidpf filestream, |
370 | uLong *pX)); | 370 | uLong *pX)); |
371 | 371 | ||
372 | local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX) | 372 | local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX) |
373 | const zlib_filefunc_def* pzlib_filefunc_def; | 373 | const zlib_filefunc_def* pzlib_filefunc_def; |
374 | voidpf filestream; | 374 | voidpf filestream; |
375 | uLong *pX; | 375 | uLong *pX; |
376 | { | 376 | { |
377 | uLong x ; | 377 | uLong x ; |
378 | int i; | 378 | int i; |
379 | int err; | 379 | int err; |
380 | 380 | ||
381 | err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); | 381 | err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); |
382 | x = (uLong)i; | 382 | x = (uLong)i; |
383 | 383 | ||
384 | if (err==ZIP_OK) | 384 | if (err==ZIP_OK) |
385 | err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); | 385 | err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); |
386 | x += ((uLong)i)<<8; | 386 | x += ((uLong)i)<<8; |
387 | 387 | ||
388 | if (err==ZIP_OK) | 388 | if (err==ZIP_OK) |
389 | err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); | 389 | err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); |
390 | x += ((uLong)i)<<16; | 390 | x += ((uLong)i)<<16; |
391 | 391 | ||
392 | if (err==ZIP_OK) | 392 | if (err==ZIP_OK) |
393 | err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); | 393 | err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i); |
394 | x += ((uLong)i)<<24; | 394 | x += ((uLong)i)<<24; |
395 | 395 | ||
396 | if (err==ZIP_OK) | 396 | if (err==ZIP_OK) |
397 | *pX = x; | 397 | *pX = x; |
398 | else | 398 | else |
399 | *pX = 0; | 399 | *pX = 0; |
400 | return err; | 400 | return err; |
401 | } | 401 | } |
402 | 402 | ||
403 | #ifndef BUFREADCOMMENT | 403 | #ifndef BUFREADCOMMENT |
404 | #define BUFREADCOMMENT (0x400) | 404 | #define BUFREADCOMMENT (0x400) |
405 | #endif | 405 | #endif |
406 | /* | 406 | /* |
407 | Locate the Central directory of a zipfile (at the end, just before | 407 | Locate the Central directory of a zipfile (at the end, just before |
408 | the global comment) | 408 | the global comment) |
409 | */ | 409 | */ |
410 | local uLong ziplocal_SearchCentralDir OF(( | 410 | local uLong ziplocal_SearchCentralDir OF(( |
411 | const zlib_filefunc_def* pzlib_filefunc_def, | 411 | const zlib_filefunc_def* pzlib_filefunc_def, |
412 | voidpf filestream)); | 412 | voidpf filestream)); |
413 | 413 | ||
414 | local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream) | 414 | local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream) |
415 | const zlib_filefunc_def* pzlib_filefunc_def; | 415 | const zlib_filefunc_def* pzlib_filefunc_def; |
416 | voidpf filestream; | 416 | voidpf filestream; |
417 | { | 417 | { |
418 | unsigned char* buf; | 418 | unsigned char* buf; |
419 | uLong uSizeFile; | 419 | uLong uSizeFile; |
420 | uLong uBackRead; | 420 | uLong uBackRead; |
421 | uLong uMaxBack=0xffff; /* maximum size of global comment */ | 421 | uLong uMaxBack=0xffff; /* maximum size of global comment */ |
422 | uLong uPosFound=0; | 422 | uLong uPosFound=0; |
423 | 423 | ||
424 | if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) | 424 | if (ZSEEK(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) |
425 | return 0; | 425 | return 0; |
426 | 426 | ||
427 | 427 | ||
428 | uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); | 428 | uSizeFile = ZTELL(*pzlib_filefunc_def,filestream); |
429 | 429 | ||
430 | if (uMaxBack>uSizeFile) | 430 | if (uMaxBack>uSizeFile) |
431 | uMaxBack = uSizeFile; | 431 | uMaxBack = uSizeFile; |
432 | 432 | ||
433 | buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); | 433 | buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); |
434 | if (buf==NULL) | 434 | if (buf==NULL) |
435 | return 0; | 435 | return 0; |
436 | 436 | ||
437 | uBackRead = 4; | 437 | uBackRead = 4; |
438 | while (uBackRead<uMaxBack) | 438 | while (uBackRead<uMaxBack) |
439 | { | 439 | { |
440 | uLong uReadSize,uReadPos ; | 440 | uLong uReadSize,uReadPos ; |
441 | int i; | 441 | int i; |
442 | if (uBackRead+BUFREADCOMMENT>uMaxBack) | 442 | if (uBackRead+BUFREADCOMMENT>uMaxBack) |
443 | uBackRead = uMaxBack; | 443 | uBackRead = uMaxBack; |
444 | else | 444 | else |
445 | uBackRead+=BUFREADCOMMENT; | 445 | uBackRead+=BUFREADCOMMENT; |
446 | uReadPos = uSizeFile-uBackRead ; | 446 | uReadPos = uSizeFile-uBackRead ; |
447 | 447 | ||
448 | uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? | 448 | uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? |
449 | (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); | 449 | (BUFREADCOMMENT+4) : (uSizeFile-uReadPos); |
450 | if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) | 450 | if (ZSEEK(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) |
451 | break; | 451 | break; |
452 | 452 | ||
453 | if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) | 453 | if (ZREAD(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) |
454 | break; | 454 | break; |
455 | 455 | ||
456 | for (i=(int)uReadSize-3; (i--)>0;) | 456 | for (i=(int)uReadSize-3; (i--)>0;) |
457 | if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && | 457 | if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && |
458 | ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) | 458 | ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) |
459 | { | 459 | { |
460 | uPosFound = uReadPos+i; | 460 | uPosFound = uReadPos+i; |
461 | break; | 461 | break; |
462 | } | 462 | } |
463 | 463 | ||
464 | if (uPosFound!=0) | 464 | if (uPosFound!=0) |
465 | break; | 465 | break; |
466 | } | 466 | } |
467 | TRYFREE(buf); | 467 | TRYFREE(buf); |
468 | return uPosFound; | 468 | return uPosFound; |
469 | } | 469 | } |
470 | #endif /* !NO_ADDFILEINEXISTINGZIP*/ | 470 | #endif /* !NO_ADDFILEINEXISTINGZIP*/ |
471 | 471 | ||
472 | /************************************************************/ | 472 | /************************************************************/ |
473 | extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc_def) | 473 | extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc_def) |
474 | const char *pathname; | 474 | const char *pathname; |
475 | int append; | 475 | int append; |
476 | zipcharpc* globalcomment; | 476 | zipcharpc* globalcomment; |
477 | zlib_filefunc_def* pzlib_filefunc_def; | 477 | zlib_filefunc_def* pzlib_filefunc_def; |
478 | { | 478 | { |
479 | zip_internal ziinit; | 479 | zip_internal ziinit; |
480 | zip_internal* zi; | 480 | zip_internal* zi; |
481 | int err=ZIP_OK; | 481 | int err=ZIP_OK; |
482 | 482 | ||
483 | 483 | ||
484 | if (pzlib_filefunc_def==NULL) | 484 | if (pzlib_filefunc_def==NULL) |
485 | fill_fopen_filefunc(&ziinit.z_filefunc); | 485 | fill_fopen_filefunc(&ziinit.z_filefunc); |
486 | else | 486 | else |
487 | ziinit.z_filefunc = *pzlib_filefunc_def; | 487 | ziinit.z_filefunc = *pzlib_filefunc_def; |
488 | 488 | ||
489 | ziinit.filestream = (*(ziinit.z_filefunc.zopen_file)) | 489 | ziinit.filestream = (*(ziinit.z_filefunc.zopen_file)) |
490 | (ziinit.z_filefunc.opaque, | 490 | (ziinit.z_filefunc.opaque, |
491 | pathname, | 491 | pathname, |
492 | (append == APPEND_STATUS_CREATE) ? | 492 | (append == APPEND_STATUS_CREATE) ? |
493 | (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) : | 493 | (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_CREATE) : |
494 | (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING)); | 494 | (ZLIB_FILEFUNC_MODE_READ | ZLIB_FILEFUNC_MODE_WRITE | ZLIB_FILEFUNC_MODE_EXISTING)); |
495 | 495 | ||
496 | if (ziinit.filestream == NULL) | 496 | if (ziinit.filestream == NULL) |
497 | return NULL; | 497 | return NULL; |
498 | ziinit.begin_pos = ZTELL(ziinit.z_filefunc,ziinit.filestream); | 498 | ziinit.begin_pos = ZTELL(ziinit.z_filefunc,ziinit.filestream); |
499 | ziinit.in_opened_file_inzip = 0; | 499 | ziinit.in_opened_file_inzip = 0; |
500 | ziinit.ci.stream_initialised = 0; | 500 | ziinit.ci.stream_initialised = 0; |
501 | ziinit.number_entry = 0; | 501 | ziinit.number_entry = 0; |
502 | ziinit.add_position_when_writting_offset = 0; | 502 | ziinit.add_position_when_writting_offset = 0; |
503 | init_linkedlist(&(ziinit.central_dir)); | 503 | init_linkedlist(&(ziinit.central_dir)); |
504 | 504 | ||
505 | 505 | ||
506 | zi = (zip_internal*)ALLOC(sizeof(zip_internal)); | 506 | zi = (zip_internal*)ALLOC(sizeof(zip_internal)); |
507 | if (zi==NULL) | 507 | if (zi==NULL) |
508 | { | 508 | { |
509 | ZCLOSE(ziinit.z_filefunc,ziinit.filestream); | 509 | ZCLOSE(ziinit.z_filefunc,ziinit.filestream); |
510 | return NULL; | 510 | return NULL; |
511 | } | 511 | } |
512 | 512 | ||
513 | /* now we add file in a zipfile */ | 513 | /* now we add file in a zipfile */ |
514 | #ifndef NO_ADDFILEINEXISTINGZIP | 514 | # ifndef NO_ADDFILEINEXISTINGZIP |
515 | if (append == APPEND_STATUS_ADDINZIP) | 515 | if (append == APPEND_STATUS_ADDINZIP) |
516 | { | 516 | { |
517 | uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ | 517 | uLong byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
518 | 518 | ||
519 | uLong size_central_dir; /* size of the central directory */ | 519 | uLong size_central_dir; /* size of the central directory */ |
520 | uLong offset_central_dir; /* offset of start of central directory */ | 520 | uLong offset_central_dir; /* offset of start of central directory */ |
521 | uLong central_pos,uL; | 521 | uLong central_pos,uL; |
522 | 522 | ||
523 | uLong number_disk; /* number of the current dist, used for | 523 | uLong number_disk; /* number of the current dist, used for |
524 | spaning ZIP, unsupported, always 0*/ | 524 | spaning ZIP, unsupported, always 0*/ |
525 | uLong number_disk_with_CD; /* number the the disk with central dir, used | 525 | uLong number_disk_with_CD; /* number the the disk with central dir, used |
526 | for spaning ZIP, unsupported, always 0*/ | 526 | for spaning ZIP, unsupported, always 0*/ |
527 | uLong number_entry; | 527 | uLong number_entry; |
528 | uLong number_entry_CD; /* total number of entries in | 528 | uLong number_entry_CD; /* total number of entries in |
529 | the central dir | 529 | the central dir |
530 | (same than number_entry on nospan) */ | 530 | (same than number_entry on nospan) */ |
531 | uLong size_comment; | 531 | uLong size_comment; |
532 | 532 | ||
533 | central_pos = ziplocal_SearchCentralDir(&ziinit.z_filefunc,ziinit.filestream); | 533 | central_pos = ziplocal_SearchCentralDir(&ziinit.z_filefunc,ziinit.filestream); |
534 | if (central_pos==0) | 534 | if (central_pos==0) |
535 | err=ZIP_ERRNO; | 535 | err=ZIP_ERRNO; |
536 | 536 | ||
537 | if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, | 537 | if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, |
538 | central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) | 538 | central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) |
539 | err=ZIP_ERRNO; | 539 | err=ZIP_ERRNO; |
540 | 540 | ||
541 | /* the signature, already checked */ | 541 | /* the signature, already checked */ |
542 | if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&uL)!=ZIP_OK) | 542 | if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&uL)!=ZIP_OK) |
543 | err=ZIP_ERRNO; | 543 | err=ZIP_ERRNO; |
544 | 544 | ||
545 | /* number of this disk */ | 545 | /* number of this disk */ |
546 | if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk)!=ZIP_OK) | 546 | if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk)!=ZIP_OK) |
547 | err=ZIP_ERRNO; | 547 | err=ZIP_ERRNO; |
548 | 548 | ||
549 | /* number of the disk with the start of the central directory */ | 549 | /* number of the disk with the start of the central directory */ |
550 | if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk_with_CD)!=ZIP_OK) | 550 | if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_disk_with_CD)!=ZIP_OK) |
551 | err=ZIP_ERRNO; | 551 | err=ZIP_ERRNO; |
552 | 552 | ||
553 | /* total number of entries in the central dir on this disk */ | 553 | /* total number of entries in the central dir on this disk */ |
554 | if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry)!=ZIP_OK) | 554 | if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry)!=ZIP_OK) |
555 | err=ZIP_ERRNO; | 555 | err=ZIP_ERRNO; |
556 | 556 | ||
557 | /* total number of entries in the central dir */ | 557 | /* total number of entries in the central dir */ |
558 | if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry_CD)!=ZIP_OK) | 558 | if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&number_entry_CD)!=ZIP_OK) |
559 | err=ZIP_ERRNO; | 559 | err=ZIP_ERRNO; |
560 | 560 | ||
561 | if ((number_entry_CD!=number_entry) || | 561 | if ((number_entry_CD!=number_entry) || |
562 | (number_disk_with_CD!=0) || | 562 | (number_disk_with_CD!=0) || |
563 | (number_disk!=0)) | 563 | (number_disk!=0)) |
564 | err=ZIP_BADZIPFILE; | 564 | err=ZIP_BADZIPFILE; |
565 | 565 | ||
566 | /* size of the central directory */ | 566 | /* size of the central directory */ |
567 | if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&size_central_dir)!=ZIP_OK) | 567 | if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&size_central_dir)!=ZIP_OK) |
568 | err=ZIP_ERRNO; | 568 | err=ZIP_ERRNO; |
569 | 569 | ||
570 | /* offset of start of central directory with respect to the | 570 | /* offset of start of central directory with respect to the |
571 | starting disk number */ | 571 | starting disk number */ |
572 | if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&offset_central_dir)!=ZIP_OK) | 572 | if (ziplocal_getLong(&ziinit.z_filefunc, ziinit.filestream,&offset_central_dir)!=ZIP_OK) |
573 | err=ZIP_ERRNO; | 573 | err=ZIP_ERRNO; |
574 | 574 | ||
575 | /* zipfile comment length */ | 575 | /* zipfile comment length */ |
576 | if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&size_comment)!=ZIP_OK) | 576 | if (ziplocal_getShort(&ziinit.z_filefunc, ziinit.filestream,&size_comment)!=ZIP_OK) |
577 | err=ZIP_ERRNO; | 577 | err=ZIP_ERRNO; |
578 | 578 | ||
579 | if ((central_pos<offset_central_dir+size_central_dir) && | 579 | if ((central_pos<offset_central_dir+size_central_dir) && |
580 | (err==ZIP_OK)) | 580 | (err==ZIP_OK)) |
581 | err=ZIP_BADZIPFILE; | 581 | err=ZIP_BADZIPFILE; |
582 | 582 | ||
583 | if (err!=ZIP_OK) | 583 | if (err!=ZIP_OK) |
584 | { | 584 | { |
585 | ZCLOSE(ziinit.z_filefunc, ziinit.filestream); | 585 | ZCLOSE(ziinit.z_filefunc, ziinit.filestream); |
586 | return NULL; | 586 | return NULL; |
587 | } | 587 | } |
588 | 588 | ||
589 | byte_before_the_zipfile = central_pos - | 589 | byte_before_the_zipfile = central_pos - |
590 | (offset_central_dir+size_central_dir); | 590 | (offset_central_dir+size_central_dir); |
591 | ziinit.add_position_when_writting_offset = byte_before_the_zipfile ; | 591 | ziinit.add_position_when_writting_offset = byte_before_the_zipfile ; |
592 | 592 | ||
593 | { | 593 | { |
594 | uLong size_central_dir_to_read = size_central_dir; | 594 | uLong size_central_dir_to_read = size_central_dir; |
595 | size_t buf_size = SIZEDATA_INDATABLOCK; | 595 | size_t buf_size = SIZEDATA_INDATABLOCK; |
596 | void* buf_read = (void*)ALLOC(buf_size); | 596 | void* buf_read = (void*)ALLOC(buf_size); |
597 | if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, | 597 | if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, |
598 | offset_central_dir + byte_before_the_zipfile, | 598 | offset_central_dir + byte_before_the_zipfile, |
599 | ZLIB_FILEFUNC_SEEK_SET) != 0) | 599 | ZLIB_FILEFUNC_SEEK_SET) != 0) |
600 | err=ZIP_ERRNO; | 600 | err=ZIP_ERRNO; |
601 | 601 | ||
602 | while ((size_central_dir_to_read>0) && (err==ZIP_OK)) | 602 | while ((size_central_dir_to_read>0) && (err==ZIP_OK)) |
603 | { | 603 | { |
604 | uLong read_this = SIZEDATA_INDATABLOCK; | 604 | uLong read_this = SIZEDATA_INDATABLOCK; |
605 | if (read_this > size_central_dir_to_read) | 605 | if (read_this > size_central_dir_to_read) |
606 | read_this = size_central_dir_to_read; | 606 | read_this = size_central_dir_to_read; |
607 | if (ZREAD(ziinit.z_filefunc, ziinit.filestream,buf_read,read_this) != read_this) | 607 | if (ZREAD(ziinit.z_filefunc, ziinit.filestream,buf_read,read_this) != read_this) |
608 | err=ZIP_ERRNO; | 608 | err=ZIP_ERRNO; |
609 | 609 | ||
610 | if (err==ZIP_OK) | 610 | if (err==ZIP_OK) |
611 | err = add_data_in_datablock(&ziinit.central_dir,buf_read, | 611 | err = add_data_in_datablock(&ziinit.central_dir,buf_read, |
612 | (uLong)read_this); | 612 | (uLong)read_this); |
613 | size_central_dir_to_read-=read_this; | 613 | size_central_dir_to_read-=read_this; |
614 | } | 614 | } |
615 | TRYFREE(buf_read); | 615 | TRYFREE(buf_read); |
616 | } | 616 | } |
617 | ziinit.begin_pos = byte_before_the_zipfile; | 617 | ziinit.begin_pos = byte_before_the_zipfile; |
618 | ziinit.number_entry = number_entry_CD; | 618 | ziinit.number_entry = number_entry_CD; |
619 | 619 | ||
620 | if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, | 620 | if (ZSEEK(ziinit.z_filefunc, ziinit.filestream, |
621 | offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) | 621 | offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) |
622 | err=ZIP_ERRNO; | 622 | err=ZIP_ERRNO; |
623 | } | 623 | } |
624 | #endif /* !NO_ADDFILEINEXISTINGZIP*/ | 624 | # endif /* !NO_ADDFILEINEXISTINGZIP*/ |
625 | 625 | ||
626 | if (err != ZIP_OK) | 626 | if (err != ZIP_OK) |
627 | { | 627 | { |
628 | TRYFREE(zi); | 628 | TRYFREE(zi); |
629 | return NULL; | 629 | return NULL; |
630 | } | 630 | } |
631 | else | 631 | else |
632 | { | 632 | { |
633 | *zi = ziinit; | 633 | *zi = ziinit; |
634 | return (zipFile)zi; | 634 | return (zipFile)zi; |
635 | } | 635 | } |
636 | } | 636 | } |
637 | 637 | ||
638 | extern zipFile ZEXPORT zipOpen (pathname, append) | 638 | extern zipFile ZEXPORT zipOpen (pathname, append) |
639 | const char *pathname; | 639 | const char *pathname; |
640 | int append; | 640 | int append; |
641 | { | 641 | { |
642 | return zipOpen2(pathname,append,NULL,NULL); | 642 | return zipOpen2(pathname,append,NULL,NULL); |
643 | } | 643 | } |
644 | 644 | ||
645 | extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, | 645 | extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi, |
646 | extrafield_local, size_extrafield_local, | 646 | extrafield_local, size_extrafield_local, |
647 | extrafield_global, size_extrafield_global, | 647 | extrafield_global, size_extrafield_global, |
648 | comment, method, level, raw, | 648 | comment, method, level, raw, |
649 | windowBits, memLevel, strategy, | 649 | windowBits, memLevel, strategy, |
650 | password, crcForCrypting) | 650 | password, crcForCrypting) |
651 | zipFile file; | 651 | zipFile file; |
652 | const char* filename; | 652 | const char* filename; |
653 | const zip_fileinfo* zipfi; | 653 | const zip_fileinfo* zipfi; |
654 | const void* extrafield_local; | 654 | const void* extrafield_local; |
655 | uInt size_extrafield_local; | 655 | uInt size_extrafield_local; |
656 | const void* extrafield_global; | 656 | const void* extrafield_global; |
657 | uInt size_extrafield_global; | 657 | uInt size_extrafield_global; |
658 | const char* comment; | 658 | const char* comment; |
659 | int method; | 659 | int method; |
660 | int level; | 660 | int level; |
661 | int raw; | 661 | int raw; |
662 | int windowBits; | 662 | int windowBits; |
663 | int memLevel; | 663 | int memLevel; |
664 | int strategy; | 664 | int strategy; |
665 | const char* password; | 665 | const char* password; |
666 | uLong crcForCrypting; | 666 | uLong crcForCrypting; |
667 | { | 667 | { |
668 | zip_internal* zi; | 668 | zip_internal* zi; |
669 | uInt size_filename; | 669 | uInt size_filename; |
670 | uInt size_comment; | 670 | uInt size_comment; |
671 | uInt i; | 671 | uInt i; |
672 | int err = ZIP_OK; | 672 | int err = ZIP_OK; |
673 | 673 | ||
674 | #ifdef NOCRYPT | 674 | # ifdef NOCRYPT |
675 | if (password != NULL) | 675 | if (password != NULL) |
676 | return ZIP_PARAMERROR; | 676 | return ZIP_PARAMERROR; |
677 | #endif | 677 | # endif |
678 | 678 | ||
679 | if (file == NULL) | 679 | if (file == NULL) |
680 | return ZIP_PARAMERROR; | 680 | return ZIP_PARAMERROR; |
681 | if ((method!=0) && (method!=Z_DEFLATED)) | 681 | if ((method!=0) && (method!=Z_DEFLATED)) |
682 | return ZIP_PARAMERROR; | 682 | return ZIP_PARAMERROR; |
683 | 683 | ||
684 | zi = (zip_internal*)file; | 684 | zi = (zip_internal*)file; |
685 | 685 | ||
686 | if (zi->in_opened_file_inzip == 1) | 686 | if (zi->in_opened_file_inzip == 1) |
687 | { | 687 | { |
688 | err = zipCloseFileInZip (file); | 688 | err = zipCloseFileInZip (file); |
689 | if (err != ZIP_OK) | 689 | if (err != ZIP_OK) |
690 | return err; | 690 | return err; |
691 | } | 691 | } |
692 | 692 | ||
693 | 693 | ||
694 | if (filename==NULL) | 694 | if (filename==NULL) |
695 | filename="-"; | 695 | filename="-"; |
696 | 696 | ||
697 | if (comment==NULL) | 697 | if (comment==NULL) |
698 | size_comment = 0; | 698 | size_comment = 0; |
699 | else | 699 | else |
700 | size_comment = strlen(comment); | 700 | size_comment = strlen(comment); |
701 | 701 | ||
702 | size_filename = strlen(filename); | 702 | size_filename = strlen(filename); |
703 | 703 | ||
704 | if (zipfi == NULL) | 704 | if (zipfi == NULL) |
705 | zi->ci.dosDate = 0; | 705 | zi->ci.dosDate = 0; |
706 | else | 706 | else |
707 | { | 707 | { |
708 | if (zipfi->dosDate != 0) | 708 | if (zipfi->dosDate != 0) |
709 | zi->ci.dosDate = zipfi->dosDate; | 709 | zi->ci.dosDate = zipfi->dosDate; |
710 | else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate); | 710 | else zi->ci.dosDate = ziplocal_TmzDateToDosDate(&zipfi->tmz_date,zipfi->dosDate); |
711 | } | 711 | } |
712 | 712 | ||
713 | zi->ci.flag = 0; | 713 | zi->ci.flag = 0; |
714 | if ((level==8) || (level==9)) | 714 | if ((level==8) || (level==9)) |
715 | zi->ci.flag |= 2; | 715 | zi->ci.flag |= 2; |
716 | if ((level==2)) | 716 | if ((level==2)) |
717 | zi->ci.flag |= 4; | 717 | zi->ci.flag |= 4; |
718 | if ((level==1)) | 718 | if ((level==1)) |
719 | zi->ci.flag |= 6; | 719 | zi->ci.flag |= 6; |
720 | if (password != NULL) | 720 | if (password != NULL) |
721 | zi->ci.flag |= 1; | 721 | zi->ci.flag |= 1; |
722 | 722 | ||
723 | zi->ci.crc32 = 0; | 723 | zi->ci.crc32 = 0; |
724 | zi->ci.method = method; | 724 | zi->ci.method = method; |
725 | zi->ci.encrypt = 0; | 725 | zi->ci.encrypt = 0; |
726 | zi->ci.stream_initialised = 0; | 726 | zi->ci.stream_initialised = 0; |
727 | zi->ci.pos_in_buffered_data = 0; | 727 | zi->ci.pos_in_buffered_data = 0; |
728 | zi->ci.raw = raw; | 728 | zi->ci.raw = raw; |
729 | zi->ci.pos_local_header = ZTELL(zi->z_filefunc,zi->filestream) ; | 729 | zi->ci.pos_local_header = ZTELL(zi->z_filefunc,zi->filestream) ; |
730 | zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + | 730 | zi->ci.size_centralheader = SIZECENTRALHEADER + size_filename + |
731 | size_extrafield_global + size_comment; | 731 | size_extrafield_global + size_comment; |
732 | zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader); | 732 | zi->ci.central_header = (char*)ALLOC((uInt)zi->ci.size_centralheader); |
733 | 733 | ||
734 | ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); | 734 | ziplocal_putValue_inmemory(zi->ci.central_header,(uLong)CENTRALHEADERMAGIC,4); |
735 | /* version info */ | 735 | /* version info */ |
736 | ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2); | 736 | ziplocal_putValue_inmemory(zi->ci.central_header+4,(uLong)VERSIONMADEBY,2); |
737 | ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2); | 737 | ziplocal_putValue_inmemory(zi->ci.central_header+6,(uLong)20,2); |
738 | ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2); | 738 | ziplocal_putValue_inmemory(zi->ci.central_header+8,(uLong)zi->ci.flag,2); |
739 | ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2); | 739 | ziplocal_putValue_inmemory(zi->ci.central_header+10,(uLong)zi->ci.method,2); |
740 | ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4); | 740 | ziplocal_putValue_inmemory(zi->ci.central_header+12,(uLong)zi->ci.dosDate,4); |
741 | ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/ | 741 | ziplocal_putValue_inmemory(zi->ci.central_header+16,(uLong)0,4); /*crc*/ |
742 | ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/ | 742 | ziplocal_putValue_inmemory(zi->ci.central_header+20,(uLong)0,4); /*compr size*/ |
743 | ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/ | 743 | ziplocal_putValue_inmemory(zi->ci.central_header+24,(uLong)0,4); /*uncompr size*/ |
744 | ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2); | 744 | ziplocal_putValue_inmemory(zi->ci.central_header+28,(uLong)size_filename,2); |
745 | ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2); | 745 | ziplocal_putValue_inmemory(zi->ci.central_header+30,(uLong)size_extrafield_global,2); |
746 | ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2); | 746 | ziplocal_putValue_inmemory(zi->ci.central_header+32,(uLong)size_comment,2); |
747 | ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ | 747 | ziplocal_putValue_inmemory(zi->ci.central_header+34,(uLong)0,2); /*disk nm start*/ |
748 | 748 | ||
749 | if (zipfi==NULL) | 749 | if (zipfi==NULL) |
750 | ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); | 750 | ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)0,2); |
751 | else | 751 | else |
752 | ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); | 752 | ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)zipfi->internal_fa,2); |
753 | 753 | ||
754 | if (zipfi==NULL) | 754 | if (zipfi==NULL) |
755 | ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); | 755 | ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)0,4); |
756 | else | 756 | else |
757 | ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); | 757 | ziplocal_putValue_inmemory(zi->ci.central_header+38,(uLong)zipfi->external_fa,4); |
758 | 758 | ||
759 | ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header- zi->add_position_when_writting_offset,4); | 759 | ziplocal_putValue_inmemory(zi->ci.central_header+42,(uLong)zi->ci.pos_local_header- zi->add_position_when_writting_offset,4); |
760 | 760 | ||
761 | for (i=0;i<size_filename;i++) | 761 | for (i=0;i<size_filename;i++) |
762 | *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i); | 762 | *(zi->ci.central_header+SIZECENTRALHEADER+i) = *(filename+i); |
763 | 763 | ||
764 | for (i=0;i<size_extrafield_global;i++) | 764 | for (i=0;i<size_extrafield_global;i++) |
765 | *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+i) = | 765 | *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+i) = |
766 | *(((const char*)extrafield_global)+i); | 766 | *(((const char*)extrafield_global)+i); |
767 | 767 | ||
768 | for (i=0;i<size_comment;i++) | 768 | for (i=0;i<size_comment;i++) |
769 | *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+ | 769 | *(zi->ci.central_header+SIZECENTRALHEADER+size_filename+ |
770 | size_extrafield_global+i) = *(comment+i); | 770 | size_extrafield_global+i) = *(comment+i); |
771 | if (zi->ci.central_header == NULL) | 771 | if (zi->ci.central_header == NULL) |
772 | return ZIP_INTERNALERROR; | 772 | return ZIP_INTERNALERROR; |
773 | 773 | ||
774 | /* write the local header */ | 774 | /* write the local header */ |
775 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC,4); | 775 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)LOCALHEADERMAGIC,4); |
776 | 776 | ||
777 | if (err==ZIP_OK) | 777 | if (err==ZIP_OK) |
778 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */ | 778 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)20,2);/* version needed to extract */ |
779 | if (err==ZIP_OK) | 779 | if (err==ZIP_OK) |
780 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2); | 780 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.flag,2); |
781 | 781 | ||
782 | if (err==ZIP_OK) | 782 | if (err==ZIP_OK) |
783 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2); | 783 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.method,2); |
784 | 784 | ||
785 | if (err==ZIP_OK) | 785 | if (err==ZIP_OK) |
786 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4); | 786 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->ci.dosDate,4); |
787 | 787 | ||
788 | if (err==ZIP_OK) | 788 | if (err==ZIP_OK) |
789 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ | 789 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* crc 32, unknown */ |
790 | if (err==ZIP_OK) | 790 | if (err==ZIP_OK) |
791 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */ | 791 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* compressed size, unknown */ |
792 | if (err==ZIP_OK) | 792 | if (err==ZIP_OK) |
793 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */ | 793 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,4); /* uncompressed size, unknown */ |
794 | 794 | ||
795 | if (err==ZIP_OK) | 795 | if (err==ZIP_OK) |
796 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2); | 796 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_filename,2); |
797 | 797 | ||
798 | if (err==ZIP_OK) | 798 | if (err==ZIP_OK) |
799 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield_local,2); | 799 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_extrafield_local,2); |
800 | 800 | ||
801 | if ((err==ZIP_OK) && (size_filename>0)) | 801 | if ((err==ZIP_OK) && (size_filename>0)) |
802 | if (ZWRITE(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename) | 802 | if (ZWRITE(zi->z_filefunc,zi->filestream,filename,size_filename)!=size_filename) |
803 | err = ZIP_ERRNO; | 803 | err = ZIP_ERRNO; |
804 | 804 | ||
805 | if ((err==ZIP_OK) && (size_extrafield_local>0)) | 805 | if ((err==ZIP_OK) && (size_extrafield_local>0)) |
806 | if (ZWRITE(zi->z_filefunc,zi->filestream,extrafield_local,size_extrafield_local) | 806 | if (ZWRITE(zi->z_filefunc,zi->filestream,extrafield_local,size_extrafield_local) |
807 | !=size_extrafield_local) | 807 | !=size_extrafield_local) |
808 | err = ZIP_ERRNO; | 808 | err = ZIP_ERRNO; |
809 | 809 | ||
810 | zi->ci.stream.avail_in = (uInt)0; | 810 | zi->ci.stream.avail_in = (uInt)0; |
811 | zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; | 811 | zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; |
812 | zi->ci.stream.next_out = zi->ci.buffered_data; | 812 | zi->ci.stream.next_out = zi->ci.buffered_data; |
813 | zi->ci.stream.total_in = 0; | 813 | zi->ci.stream.total_in = 0; |
814 | zi->ci.stream.total_out = 0; | 814 | zi->ci.stream.total_out = 0; |
815 | 815 | ||
816 | if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) | 816 | if ((err==ZIP_OK) && (zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) |
817 | { | 817 | { |
818 | zi->ci.stream.zalloc = (alloc_func)0; | 818 | zi->ci.stream.zalloc = (alloc_func)0; |
819 | zi->ci.stream.zfree = (free_func)0; | 819 | zi->ci.stream.zfree = (free_func)0; |
820 | zi->ci.stream.opaque = (voidpf)0; | 820 | zi->ci.stream.opaque = (voidpf)0; |
821 | 821 | ||
822 | if (windowBits>0) | 822 | if (windowBits>0) |
823 | windowBits = -windowBits; | 823 | windowBits = -windowBits; |
824 | 824 | ||
825 | err = deflateInit2(&zi->ci.stream, level, | 825 | err = deflateInit2(&zi->ci.stream, level, |
826 | Z_DEFLATED, windowBits, memLevel, strategy); | 826 | Z_DEFLATED, windowBits, memLevel, strategy); |
827 | 827 | ||
828 | if (err==Z_OK) | 828 | if (err==Z_OK) |
829 | zi->ci.stream_initialised = 1; | 829 | zi->ci.stream_initialised = 1; |
830 | } | 830 | } |
831 | #ifndef NOCRYPT | 831 | # ifndef NOCRYPT |
832 | zi->ci.crypt_header_size = 0; | 832 | zi->ci.crypt_header_size = 0; |
833 | if ((err==Z_OK) && (password != NULL)) | 833 | if ((err==Z_OK) && (password != NULL)) |
834 | { | 834 | { |
835 | unsigned char bufHead[RAND_HEAD_LEN]; | 835 | unsigned char bufHead[RAND_HEAD_LEN]; |
836 | unsigned int sizeHead; | 836 | unsigned int sizeHead; |
837 | zi->ci.encrypt = 1; | 837 | zi->ci.encrypt = 1; |
838 | zi->ci.pcrc_32_tab = get_crc_table(); | 838 | zi->ci.pcrc_32_tab = get_crc_table(); |
839 | /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/ | 839 | /*init_keys(password,zi->ci.keys,zi->ci.pcrc_32_tab);*/ |
840 | 840 | ||
841 | sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting); | 841 | sizeHead=crypthead(password,bufHead,RAND_HEAD_LEN,zi->ci.keys,zi->ci.pcrc_32_tab,crcForCrypting); |
842 | zi->ci.crypt_header_size = sizeHead; | 842 | zi->ci.crypt_header_size = sizeHead; |
843 | 843 | ||
844 | if (ZWRITE(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead) | 844 | if (ZWRITE(zi->z_filefunc,zi->filestream,bufHead,sizeHead) != sizeHead) |
845 | err = ZIP_ERRNO; | 845 | err = ZIP_ERRNO; |
846 | } | 846 | } |
847 | #endif | 847 | # endif |
848 | 848 | ||
849 | if (err==Z_OK) | 849 | if (err==Z_OK) |
850 | zi->in_opened_file_inzip = 1; | 850 | zi->in_opened_file_inzip = 1; |
851 | return err; | 851 | return err; |
852 | } | 852 | } |
853 | 853 | ||
854 | extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi, | 854 | extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi, |
855 | extrafield_local, size_extrafield_local, | 855 | extrafield_local, size_extrafield_local, |
856 | extrafield_global, size_extrafield_global, | 856 | extrafield_global, size_extrafield_global, |
857 | comment, method, level, raw) | 857 | comment, method, level, raw) |
858 | zipFile file; | 858 | zipFile file; |
859 | const char* filename; | 859 | const char* filename; |
860 | const zip_fileinfo* zipfi; | 860 | const zip_fileinfo* zipfi; |
861 | const void* extrafield_local; | 861 | const void* extrafield_local; |
862 | uInt size_extrafield_local; | 862 | uInt size_extrafield_local; |
863 | const void* extrafield_global; | 863 | const void* extrafield_global; |
864 | uInt size_extrafield_global; | 864 | uInt size_extrafield_global; |
865 | const char* comment; | 865 | const char* comment; |
866 | int method; | 866 | int method; |
867 | int level; | 867 | int level; |
868 | int raw; | 868 | int raw; |
869 | { | 869 | { |
870 | return zipOpenNewFileInZip3 (file, filename, zipfi, | 870 | return zipOpenNewFileInZip3 (file, filename, zipfi, |
871 | extrafield_local, size_extrafield_local, | 871 | extrafield_local, size_extrafield_local, |
872 | extrafield_global, size_extrafield_global, | 872 | extrafield_global, size_extrafield_global, |
873 | comment, method, level, raw, | 873 | comment, method, level, raw, |
874 | -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, | 874 | -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, |
875 | NULL, 0); | 875 | NULL, 0); |
876 | } | 876 | } |
877 | 877 | ||
878 | extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, | 878 | extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi, |
879 | extrafield_local, size_extrafield_local, | 879 | extrafield_local, size_extrafield_local, |
880 | extrafield_global, size_extrafield_global, | 880 | extrafield_global, size_extrafield_global, |
881 | comment, method, level) | 881 | comment, method, level) |
882 | zipFile file; | 882 | zipFile file; |
883 | const char* filename; | 883 | const char* filename; |
884 | const zip_fileinfo* zipfi; | 884 | const zip_fileinfo* zipfi; |
885 | const void* extrafield_local; | 885 | const void* extrafield_local; |
886 | uInt size_extrafield_local; | 886 | uInt size_extrafield_local; |
887 | const void* extrafield_global; | 887 | const void* extrafield_global; |
888 | uInt size_extrafield_global; | 888 | uInt size_extrafield_global; |
889 | const char* comment; | 889 | const char* comment; |
890 | int method; | 890 | int method; |
891 | int level; | 891 | int level; |
892 | { | 892 | { |
893 | return zipOpenNewFileInZip2 (file, filename, zipfi, | 893 | return zipOpenNewFileInZip2 (file, filename, zipfi, |
894 | extrafield_local, size_extrafield_local, | 894 | extrafield_local, size_extrafield_local, |
895 | extrafield_global, size_extrafield_global, | 895 | extrafield_global, size_extrafield_global, |
896 | comment, method, level, 0); | 896 | comment, method, level, 0); |
897 | } | 897 | } |
898 | 898 | ||
899 | local int zipFlushWriteBuffer(zi) | 899 | local int zipFlushWriteBuffer(zi) |
900 | zip_internal* zi; | 900 | zip_internal* zi; |
901 | { | 901 | { |
902 | int err=ZIP_OK; | 902 | int err=ZIP_OK; |
903 | 903 | ||
904 | if (zi->ci.encrypt != 0) | 904 | if (zi->ci.encrypt != 0) |
905 | { | 905 | { |
906 | #ifndef NOCRYPT | 906 | #ifndef NOCRYPT |
907 | uInt i; | 907 | uInt i; |
908 | int t; | 908 | int t; |
909 | for (i=0;i<zi->ci.pos_in_buffered_data;i++) | 909 | for (i=0;i<zi->ci.pos_in_buffered_data;i++) |
910 | zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, | 910 | zi->ci.buffered_data[i] = zencode(zi->ci.keys, zi->ci.pcrc_32_tab, |
911 | zi->ci.buffered_data[i],t); | 911 | zi->ci.buffered_data[i],t); |
912 | #endif | 912 | #endif |
913 | } | 913 | } |
914 | if (ZWRITE(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) | 914 | if (ZWRITE(zi->z_filefunc,zi->filestream,zi->ci.buffered_data,zi->ci.pos_in_buffered_data) |
915 | !=zi->ci.pos_in_buffered_data) | 915 | !=zi->ci.pos_in_buffered_data) |
916 | err = ZIP_ERRNO; | 916 | err = ZIP_ERRNO; |
917 | zi->ci.pos_in_buffered_data = 0; | 917 | zi->ci.pos_in_buffered_data = 0; |
918 | return err; | 918 | return err; |
919 | } | 919 | } |
920 | 920 | ||
921 | extern int ZEXPORT zipWriteInFileInZip (file, buf, len) | 921 | extern int ZEXPORT zipWriteInFileInZip (file, buf, len) |
922 | zipFile file; | 922 | zipFile file; |
923 | const void* buf; | 923 | const void* buf; |
924 | unsigned len; | 924 | unsigned len; |
925 | { | 925 | { |
926 | zip_internal* zi; | 926 | zip_internal* zi; |
927 | int err=ZIP_OK; | 927 | int err=ZIP_OK; |
928 | 928 | ||
929 | if (file == NULL) | 929 | if (file == NULL) |
930 | return ZIP_PARAMERROR; | 930 | return ZIP_PARAMERROR; |
931 | zi = (zip_internal*)file; | 931 | zi = (zip_internal*)file; |
932 | 932 | ||
933 | if (zi->in_opened_file_inzip == 0) | 933 | if (zi->in_opened_file_inzip == 0) |
934 | return ZIP_PARAMERROR; | 934 | return ZIP_PARAMERROR; |
935 | 935 | ||
936 | zi->ci.stream.next_in = (void*)buf; | 936 | zi->ci.stream.next_in = (void*)buf; |
937 | zi->ci.stream.avail_in = len; | 937 | zi->ci.stream.avail_in = len; |
938 | zi->ci.crc32 = crc32(zi->ci.crc32,buf,len); | 938 | zi->ci.crc32 = crc32(zi->ci.crc32,buf,len); |
939 | 939 | ||
940 | while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) | 940 | while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) |
941 | { | 941 | { |
942 | if (zi->ci.stream.avail_out == 0) | 942 | if (zi->ci.stream.avail_out == 0) |
943 | { | 943 | { |
944 | if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) | 944 | if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) |
945 | err = ZIP_ERRNO; | 945 | err = ZIP_ERRNO; |
946 | zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; | 946 | zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; |
947 | zi->ci.stream.next_out = zi->ci.buffered_data; | 947 | zi->ci.stream.next_out = zi->ci.buffered_data; |
948 | } | 948 | } |
949 | 949 | ||
950 | 950 | ||
951 | if(err != ZIP_OK) | 951 | if(err != ZIP_OK) |
952 | break; | 952 | break; |
953 | 953 | ||
954 | if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) | 954 | if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) |
955 | { | 955 | { |
956 | uLong uTotalOutBefore = zi->ci.stream.total_out; | 956 | uLong uTotalOutBefore = zi->ci.stream.total_out; |
957 | err=deflate(&zi->ci.stream, Z_NO_FLUSH); | 957 | err=deflate(&zi->ci.stream, Z_NO_FLUSH); |
958 | zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; | 958 | zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; |
959 | 959 | ||
960 | } | 960 | } |
961 | else | 961 | else |
962 | { | 962 | { |
963 | uInt copy_this,i; | 963 | uInt copy_this,i; |
964 | if (zi->ci.stream.avail_in < zi->ci.stream.avail_out) | 964 | if (zi->ci.stream.avail_in < zi->ci.stream.avail_out) |
965 | copy_this = zi->ci.stream.avail_in; | 965 | copy_this = zi->ci.stream.avail_in; |
966 | else | 966 | else |
967 | copy_this = zi->ci.stream.avail_out; | 967 | copy_this = zi->ci.stream.avail_out; |
968 | for (i=0;i<copy_this;i++) | 968 | for (i=0;i<copy_this;i++) |
969 | *(((char*)zi->ci.stream.next_out)+i) = | 969 | *(((char*)zi->ci.stream.next_out)+i) = |
970 | *(((const char*)zi->ci.stream.next_in)+i); | 970 | *(((const char*)zi->ci.stream.next_in)+i); |
971 | { | 971 | { |
972 | zi->ci.stream.avail_in -= copy_this; | 972 | zi->ci.stream.avail_in -= copy_this; |
973 | zi->ci.stream.avail_out-= copy_this; | 973 | zi->ci.stream.avail_out-= copy_this; |
974 | zi->ci.stream.next_in+= copy_this; | 974 | zi->ci.stream.next_in+= copy_this; |
975 | zi->ci.stream.next_out+= copy_this; | 975 | zi->ci.stream.next_out+= copy_this; |
976 | zi->ci.stream.total_in+= copy_this; | 976 | zi->ci.stream.total_in+= copy_this; |
977 | zi->ci.stream.total_out+= copy_this; | 977 | zi->ci.stream.total_out+= copy_this; |
978 | zi->ci.pos_in_buffered_data += copy_this; | 978 | zi->ci.pos_in_buffered_data += copy_this; |
979 | } | 979 | } |
980 | } | 980 | } |
981 | } | 981 | } |
982 | 982 | ||
983 | return err; | 983 | return err; |
984 | } | 984 | } |
985 | 985 | ||
986 | extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32) | 986 | extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32) |
987 | zipFile file; | 987 | zipFile file; |
988 | uLong uncompressed_size; | 988 | uLong uncompressed_size; |
989 | uLong crc32; | 989 | uLong crc32; |
990 | { | 990 | { |
991 | zip_internal* zi; | 991 | zip_internal* zi; |
992 | uLong compressed_size; | 992 | uLong compressed_size; |
993 | int err=ZIP_OK; | 993 | int err=ZIP_OK; |
994 | 994 | ||
995 | if (file == NULL) | 995 | if (file == NULL) |
996 | return ZIP_PARAMERROR; | 996 | return ZIP_PARAMERROR; |
997 | zi = (zip_internal*)file; | 997 | zi = (zip_internal*)file; |
998 | 998 | ||
999 | if (zi->in_opened_file_inzip == 0) | 999 | if (zi->in_opened_file_inzip == 0) |
1000 | return ZIP_PARAMERROR; | 1000 | return ZIP_PARAMERROR; |
1001 | zi->ci.stream.avail_in = 0; | 1001 | zi->ci.stream.avail_in = 0; |
1002 | 1002 | ||
1003 | if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) | 1003 | if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) |
1004 | while (err==ZIP_OK) | 1004 | while (err==ZIP_OK) |
1005 | { | 1005 | { |
1006 | uLong uTotalOutBefore; | 1006 | uLong uTotalOutBefore; |
1007 | if (zi->ci.stream.avail_out == 0) | 1007 | if (zi->ci.stream.avail_out == 0) |
1008 | { | 1008 | { |
1009 | if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) | 1009 | if (zipFlushWriteBuffer(zi) == ZIP_ERRNO) |
1010 | err = ZIP_ERRNO; | 1010 | err = ZIP_ERRNO; |
1011 | zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; | 1011 | zi->ci.stream.avail_out = (uInt)Z_BUFSIZE; |
1012 | zi->ci.stream.next_out = zi->ci.buffered_data; | 1012 | zi->ci.stream.next_out = zi->ci.buffered_data; |
1013 | } | 1013 | } |
1014 | uTotalOutBefore = zi->ci.stream.total_out; | 1014 | uTotalOutBefore = zi->ci.stream.total_out; |
1015 | err=deflate(&zi->ci.stream, Z_FINISH); | 1015 | err=deflate(&zi->ci.stream, Z_FINISH); |
1016 | zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; | 1016 | zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ; |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | if (err==Z_STREAM_END) | 1019 | if (err==Z_STREAM_END) |
1020 | err=ZIP_OK; /* this is normal */ | 1020 | err=ZIP_OK; /* this is normal */ |
1021 | 1021 | ||
1022 | if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) | 1022 | if ((zi->ci.pos_in_buffered_data>0) && (err==ZIP_OK)) |
1023 | if (zipFlushWriteBuffer(zi)==ZIP_ERRNO) | 1023 | if (zipFlushWriteBuffer(zi)==ZIP_ERRNO) |
1024 | err = ZIP_ERRNO; | 1024 | err = ZIP_ERRNO; |
1025 | 1025 | ||
1026 | if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) | 1026 | if ((zi->ci.method == Z_DEFLATED) && (!zi->ci.raw)) |
1027 | { | 1027 | { |
1028 | err=deflateEnd(&zi->ci.stream); | 1028 | err=deflateEnd(&zi->ci.stream); |
1029 | zi->ci.stream_initialised = 0; | 1029 | zi->ci.stream_initialised = 0; |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | if (!zi->ci.raw) | 1032 | if (!zi->ci.raw) |
1033 | { | 1033 | { |
1034 | crc32 = (uLong)zi->ci.crc32; | 1034 | crc32 = (uLong)zi->ci.crc32; |
1035 | uncompressed_size = (uLong)zi->ci.stream.total_in; | 1035 | uncompressed_size = (uLong)zi->ci.stream.total_in; |
1036 | } | 1036 | } |
1037 | compressed_size = (uLong)zi->ci.stream.total_out; | 1037 | compressed_size = (uLong)zi->ci.stream.total_out; |
1038 | #ifndef NOCRYPT | 1038 | # ifndef NOCRYPT |
1039 | compressed_size += zi->ci.crypt_header_size; | 1039 | compressed_size += zi->ci.crypt_header_size; |
1040 | #endif | 1040 | # endif |
1041 | 1041 | ||
1042 | ziplocal_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/ | 1042 | ziplocal_putValue_inmemory(zi->ci.central_header+16,crc32,4); /*crc*/ |
1043 | ziplocal_putValue_inmemory(zi->ci.central_header+20, | 1043 | ziplocal_putValue_inmemory(zi->ci.central_header+20, |
1044 | compressed_size,4); /*compr size*/ | 1044 | compressed_size,4); /*compr size*/ |
1045 | if (zi->ci.stream.data_type == Z_ASCII) | 1045 | if (zi->ci.stream.data_type == Z_ASCII) |
1046 | ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2); | 1046 | ziplocal_putValue_inmemory(zi->ci.central_header+36,(uLong)Z_ASCII,2); |
1047 | ziplocal_putValue_inmemory(zi->ci.central_header+24, | 1047 | ziplocal_putValue_inmemory(zi->ci.central_header+24, |
1048 | uncompressed_size,4); /*uncompr size*/ | 1048 | uncompressed_size,4); /*uncompr size*/ |
1049 | 1049 | ||
1050 | if (err==ZIP_OK) | 1050 | if (err==ZIP_OK) |
1051 | err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, | 1051 | err = add_data_in_datablock(&zi->central_dir,zi->ci.central_header, |
1052 | (uLong)zi->ci.size_centralheader); | 1052 | (uLong)zi->ci.size_centralheader); |
1053 | free(zi->ci.central_header); | 1053 | free(zi->ci.central_header); |
1054 | 1054 | ||
1055 | if (err==ZIP_OK) | 1055 | if (err==ZIP_OK) |
1056 | { | 1056 | { |
1057 | long cur_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); | 1057 | long cur_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); |
1058 | if (ZSEEK(zi->z_filefunc,zi->filestream, | 1058 | if (ZSEEK(zi->z_filefunc,zi->filestream, |
1059 | zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0) | 1059 | zi->ci.pos_local_header + 14,ZLIB_FILEFUNC_SEEK_SET)!=0) |
1060 | err = ZIP_ERRNO; | 1060 | err = ZIP_ERRNO; |
1061 | 1061 | ||
1062 | if (err==ZIP_OK) | 1062 | if (err==ZIP_OK) |
1063 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */ | 1063 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,crc32,4); /* crc 32, unknown */ |
1064 | 1064 | ||
1065 | if (err==ZIP_OK) /* compressed size, unknown */ | 1065 | if (err==ZIP_OK) /* compressed size, unknown */ |
1066 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4); | 1066 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,compressed_size,4); |
1067 | 1067 | ||
1068 | if (err==ZIP_OK) /* uncompressed size, unknown */ | 1068 | if (err==ZIP_OK) /* uncompressed size, unknown */ |
1069 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4); | 1069 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,uncompressed_size,4); |
1070 | 1070 | ||
1071 | if (ZSEEK(zi->z_filefunc,zi->filestream, | 1071 | if (ZSEEK(zi->z_filefunc,zi->filestream, |
1072 | cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0) | 1072 | cur_pos_inzip,ZLIB_FILEFUNC_SEEK_SET)!=0) |
1073 | err = ZIP_ERRNO; | 1073 | err = ZIP_ERRNO; |
1074 | } | 1074 | } |
1075 | 1075 | ||
1076 | zi->number_entry ++; | 1076 | zi->number_entry ++; |
1077 | zi->in_opened_file_inzip = 0; | 1077 | zi->in_opened_file_inzip = 0; |
1078 | 1078 | ||
1079 | return err; | 1079 | return err; |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | extern int ZEXPORT zipCloseFileInZip (file) | 1082 | extern int ZEXPORT zipCloseFileInZip (file) |
1083 | zipFile file; | 1083 | zipFile file; |
1084 | { | 1084 | { |
1085 | return zipCloseFileInZipRaw (file,0,0); | 1085 | return zipCloseFileInZipRaw (file,0,0); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | extern int ZEXPORT zipClose (file, global_comment) | 1088 | extern int ZEXPORT zipClose (file, global_comment) |
1089 | zipFile file; | 1089 | zipFile file; |
1090 | const char* global_comment; | 1090 | const char* global_comment; |
1091 | { | 1091 | { |
1092 | zip_internal* zi; | 1092 | zip_internal* zi; |
1093 | int err = 0; | 1093 | int err = 0; |
1094 | uLong size_centraldir = 0; | 1094 | uLong size_centraldir = 0; |
1095 | uLong centraldir_pos_inzip ; | 1095 | uLong centraldir_pos_inzip ; |
1096 | uInt size_global_comment; | 1096 | uInt size_global_comment; |
1097 | if (file == NULL) | 1097 | if (file == NULL) |
1098 | return ZIP_PARAMERROR; | 1098 | return ZIP_PARAMERROR; |
1099 | zi = (zip_internal*)file; | 1099 | zi = (zip_internal*)file; |
1100 | 1100 | ||
1101 | if (zi->in_opened_file_inzip == 1) | 1101 | if (zi->in_opened_file_inzip == 1) |
1102 | { | 1102 | { |
1103 | err = zipCloseFileInZip (file); | 1103 | err = zipCloseFileInZip (file); |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | if (global_comment==NULL) | 1106 | if (global_comment==NULL) |
1107 | size_global_comment = 0; | 1107 | size_global_comment = 0; |
1108 | else | 1108 | else |
1109 | size_global_comment = strlen(global_comment); | 1109 | size_global_comment = strlen(global_comment); |
1110 | 1110 | ||
1111 | 1111 | ||
1112 | centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); | 1112 | centraldir_pos_inzip = ZTELL(zi->z_filefunc,zi->filestream); |
1113 | if (err==ZIP_OK) | 1113 | if (err==ZIP_OK) |
1114 | { | 1114 | { |
1115 | linkedlist_datablock_internal* ldi = zi->central_dir.first_block ; | 1115 | linkedlist_datablock_internal* ldi = zi->central_dir.first_block ; |
1116 | while (ldi!=NULL) | 1116 | while (ldi!=NULL) |
1117 | { | 1117 | { |
1118 | if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) | 1118 | if ((err==ZIP_OK) && (ldi->filled_in_this_block>0)) |
1119 | if (ZWRITE(zi->z_filefunc,zi->filestream, | 1119 | if (ZWRITE(zi->z_filefunc,zi->filestream, |
1120 | ldi->data,ldi->filled_in_this_block) | 1120 | ldi->data,ldi->filled_in_this_block) |
1121 | !=ldi->filled_in_this_block ) | 1121 | !=ldi->filled_in_this_block ) |
1122 | err = ZIP_ERRNO; | 1122 | err = ZIP_ERRNO; |
1123 | 1123 | ||
1124 | size_centraldir += ldi->filled_in_this_block; | 1124 | size_centraldir += ldi->filled_in_this_block; |
1125 | ldi = ldi->next_datablock; | 1125 | ldi = ldi->next_datablock; |
1126 | } | 1126 | } |
1127 | } | 1127 | } |
1128 | free_datablock(zi->central_dir.first_block); | 1128 | free_datablock(zi->central_dir.first_block); |
1129 | 1129 | ||
1130 | if (err==ZIP_OK) /* Magic End */ | 1130 | if (err==ZIP_OK) /* Magic End */ |
1131 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); | 1131 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); |
1132 | 1132 | ||
1133 | if (err==ZIP_OK) /* number of this disk */ | 1133 | if (err==ZIP_OK) /* number of this disk */ |
1134 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); | 1134 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); |
1135 | 1135 | ||
1136 | if (err==ZIP_OK) /* number of the disk with the start of the central directory */ | 1136 | if (err==ZIP_OK) /* number of the disk with the start of the central directory */ |
1137 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); | 1137 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)0,2); |
1138 | 1138 | ||
1139 | if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ | 1139 | if (err==ZIP_OK) /* total number of entries in the central dir on this disk */ |
1140 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); | 1140 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); |
1141 | 1141 | ||
1142 | if (err==ZIP_OK) /* total number of entries in the central dir */ | 1142 | if (err==ZIP_OK) /* total number of entries in the central dir */ |
1143 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); | 1143 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)zi->number_entry,2); |
1144 | 1144 | ||
1145 | if (err==ZIP_OK) /* size of the central directory */ | 1145 | if (err==ZIP_OK) /* size of the central directory */ |
1146 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4); | 1146 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_centraldir,4); |
1147 | 1147 | ||
1148 | if (err==ZIP_OK) /* offset of start of central directory with respect to the | 1148 | if (err==ZIP_OK) /* offset of start of central directory with respect to the |
1149 | starting disk number */ | 1149 | starting disk number */ |
1150 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream, | 1150 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream, |
1151 | (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4); | 1151 | (uLong)(centraldir_pos_inzip - zi->add_position_when_writting_offset),4); |
1152 | 1152 | ||
1153 | if (err==ZIP_OK) /* zipfile comment length */ | 1153 | if (err==ZIP_OK) /* zipfile comment length */ |
1154 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2); | 1154 | err = ziplocal_putValue(&zi->z_filefunc,zi->filestream,(uLong)size_global_comment,2); |
1155 | 1155 | ||
1156 | if ((err==ZIP_OK) && (size_global_comment>0)) | 1156 | if ((err==ZIP_OK) && (size_global_comment>0)) |
1157 | if (ZWRITE(zi->z_filefunc,zi->filestream, | 1157 | if (ZWRITE(zi->z_filefunc,zi->filestream, |
1158 | global_comment,size_global_comment) != size_global_comment) | 1158 | global_comment,size_global_comment) != size_global_comment) |
1159 | err = ZIP_ERRNO; | 1159 | err = ZIP_ERRNO; |
1160 | 1160 | ||
1161 | if (ZCLOSE(zi->z_filefunc,zi->filestream) != 0) | 1161 | if (ZCLOSE(zi->z_filefunc,zi->filestream) != 0) |
1162 | if (err == ZIP_OK) | 1162 | if (err == ZIP_OK) |
1163 | err = ZIP_ERRNO; | 1163 | err = ZIP_ERRNO; |
1164 | 1164 | ||
1165 | TRYFREE(zi); | 1165 | TRYFREE(zi); |
1166 | 1166 | ||
1167 | return err; | 1167 | return err; |
1168 | } | 1168 | } |
diff --git a/contrib/minizip/zip.h b/contrib/minizip/zip.h index d863e1a..5a75fc6 100644 --- a/contrib/minizip/zip.h +++ b/contrib/minizip/zip.h | |||
@@ -1,235 +1,235 @@ | |||
1 | /* zip.h -- IO for compress .zip files using zlib | 1 | /* zip.h -- IO for compress .zip files using zlib |
2 | Version 0.22, May 19th, 2003 | 2 | Version 0.22, May 19th, 2003 |
3 | 3 | ||
4 | Copyright (C) 1998-2003 Gilles Vollant | 4 | Copyright (C) 1998-2003 Gilles Vollant |
5 | 5 | ||
6 | This unzip package allow creates .ZIP file, compatible with PKZip 2.04g | 6 | This unzip package allow creates .ZIP file, compatible with PKZip 2.04g |
7 | WinZip, InfoZip tools and compatible. | 7 | WinZip, InfoZip tools and compatible. |
8 | Encryption and multi volume ZipFile (span) are not supported. | 8 | Encryption and multi volume ZipFile (span) are not supported. |
9 | Old compressions used by old PKZip 1.x are not supported | 9 | Old compressions used by old PKZip 1.x are not supported |
10 | 10 | ||
11 | For uncompress .zip file, look at unzip.h | 11 | For uncompress .zip file, look at unzip.h |
12 | 12 | ||
13 | 13 | ||
14 | I WAIT FEEDBACK at mail info@winimage.com | 14 | I WAIT FEEDBACK at mail info@winimage.com |
15 | Visit also http://www.winimage.com/zLibDll/unzip.html for evolution | 15 | Visit also http://www.winimage.com/zLibDll/unzip.html for evolution |
16 | 16 | ||
17 | Condition of use and distribution are the same than zlib : | 17 | Condition of use and distribution are the same than zlib : |
18 | 18 | ||
19 | This software is provided 'as-is', without any express or implied | 19 | This software is provided 'as-is', without any express or implied |
20 | warranty. In no event will the authors be held liable for any damages | 20 | warranty. In no event will the authors be held liable for any damages |
21 | arising from the use of this software. | 21 | arising from the use of this software. |
22 | 22 | ||
23 | Permission is granted to anyone to use this software for any purpose, | 23 | Permission is granted to anyone to use this software for any purpose, |
24 | including commercial applications, and to alter it and redistribute it | 24 | including commercial applications, and to alter it and redistribute it |
25 | freely, subject to the following restrictions: | 25 | freely, subject to the following restrictions: |
26 | 26 | ||
27 | 1. The origin of this software must not be misrepresented; you must not | 27 | 1. The origin of this software must not be misrepresented; you must not |
28 | claim that you wrote the original software. If you use this software | 28 | claim that you wrote the original software. If you use this software |
29 | in a product, an acknowledgment in the product documentation would be | 29 | in a product, an acknowledgment in the product documentation would be |
30 | appreciated but is not required. | 30 | appreciated but is not required. |
31 | 2. Altered source versions must be plainly marked as such, and must not be | 31 | 2. Altered source versions must be plainly marked as such, and must not be |
32 | misrepresented as being the original software. | 32 | misrepresented as being the original software. |
33 | 3. This notice may not be removed or altered from any source distribution. | 33 | 3. This notice may not be removed or altered from any source distribution. |
34 | 34 | ||
35 | 35 | ||
36 | */ | 36 | */ |
37 | 37 | ||
38 | /* for more info about .ZIP format, see | 38 | /* for more info about .ZIP format, see |
39 | http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip | 39 | http://www.info-zip.org/pub/infozip/doc/appnote-981119-iz.zip |
40 | http://www.info-zip.org/pub/infozip/doc/ | 40 | http://www.info-zip.org/pub/infozip/doc/ |
41 | PkWare has also a specification at : | 41 | PkWare has also a specification at : |
42 | ftp://ftp.pkware.com/probdesc.zip | 42 | ftp://ftp.pkware.com/probdesc.zip |
43 | */ | 43 | */ |
44 | 44 | ||
45 | #ifndef _zip_H | 45 | #ifndef _zip_H |
46 | #define _zip_H | 46 | #define _zip_H |
47 | 47 | ||
48 | #ifdef __cplusplus | 48 | #ifdef __cplusplus |
49 | extern "C" { | 49 | extern "C" { |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | #ifndef _ZLIB_H | 52 | #ifndef _ZLIB_H |
53 | #include "zlib.h" | 53 | #include "zlib.h" |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #ifndef _ZLIBIOAPI_H | 56 | #ifndef _ZLIBIOAPI_H |
57 | #include "ioapi.h" | 57 | #include "ioapi.h" |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #if defined(STRICTZIP) || defined(STRICTZIPUNZIP) | 60 | #if defined(STRICTZIP) || defined(STRICTZIPUNZIP) |
61 | /* like the STRICT of WIN32, we define a pointer that cannot be converted | 61 | /* like the STRICT of WIN32, we define a pointer that cannot be converted |
62 | from (void*) without cast */ | 62 | from (void*) without cast */ |
63 | typedef struct TagzipFile__ { int unused; } zipFile__; | 63 | typedef struct TagzipFile__ { int unused; } zipFile__; |
64 | typedef zipFile__ *zipFile; | 64 | typedef zipFile__ *zipFile; |
65 | #else | 65 | #else |
66 | typedef voidp zipFile; | 66 | typedef voidp zipFile; |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | #define ZIP_OK (0) | 69 | #define ZIP_OK (0) |
70 | #define ZIP_EOF (0) | 70 | #define ZIP_EOF (0) |
71 | #define ZIP_ERRNO (Z_ERRNO) | 71 | #define ZIP_ERRNO (Z_ERRNO) |
72 | #define ZIP_PARAMERROR (-102) | 72 | #define ZIP_PARAMERROR (-102) |
73 | #define ZIP_BADZIPFILE (-103) | 73 | #define ZIP_BADZIPFILE (-103) |
74 | #define ZIP_INTERNALERROR (-104) | 74 | #define ZIP_INTERNALERROR (-104) |
75 | 75 | ||
76 | #ifndef DEF_MEM_LEVEL | 76 | #ifndef DEF_MEM_LEVEL |
77 | # if MAX_MEM_LEVEL >= 8 | 77 | # if MAX_MEM_LEVEL >= 8 |
78 | # define DEF_MEM_LEVEL 8 | 78 | # define DEF_MEM_LEVEL 8 |
79 | # else | 79 | # else |
80 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL | 80 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL |
81 | # endif | 81 | # endif |
82 | #endif | 82 | #endif |
83 | /* default memLevel */ | 83 | /* default memLevel */ |
84 | 84 | ||
85 | /* tm_zip contain date/time info */ | 85 | /* tm_zip contain date/time info */ |
86 | typedef struct tm_zip_s | 86 | typedef struct tm_zip_s |
87 | { | 87 | { |
88 | uInt tm_sec; /* seconds after the minute - [0,59] */ | 88 | uInt tm_sec; /* seconds after the minute - [0,59] */ |
89 | uInt tm_min; /* minutes after the hour - [0,59] */ | 89 | uInt tm_min; /* minutes after the hour - [0,59] */ |
90 | uInt tm_hour; /* hours since midnight - [0,23] */ | 90 | uInt tm_hour; /* hours since midnight - [0,23] */ |
91 | uInt tm_mday; /* day of the month - [1,31] */ | 91 | uInt tm_mday; /* day of the month - [1,31] */ |
92 | uInt tm_mon; /* months since January - [0,11] */ | 92 | uInt tm_mon; /* months since January - [0,11] */ |
93 | uInt tm_year; /* years - [1980..2044] */ | 93 | uInt tm_year; /* years - [1980..2044] */ |
94 | } tm_zip; | 94 | } tm_zip; |
95 | 95 | ||
96 | typedef struct | 96 | typedef struct |
97 | { | 97 | { |
98 | tm_zip tmz_date; /* date in understandable format */ | 98 | tm_zip tmz_date; /* date in understandable format */ |
99 | uLong dosDate; /* if dos_date == 0, tmu_date is used */ | 99 | uLong dosDate; /* if dos_date == 0, tmu_date is used */ |
100 | /* uLong flag; */ /* general purpose bit flag 2 bytes */ | 100 | /* uLong flag; */ /* general purpose bit flag 2 bytes */ |
101 | 101 | ||
102 | uLong internal_fa; /* internal file attributes 2 bytes */ | 102 | uLong internal_fa; /* internal file attributes 2 bytes */ |
103 | uLong external_fa; /* external file attributes 4 bytes */ | 103 | uLong external_fa; /* external file attributes 4 bytes */ |
104 | } zip_fileinfo; | 104 | } zip_fileinfo; |
105 | 105 | ||
106 | typedef const char* zipcharpc; | 106 | typedef const char* zipcharpc; |
107 | 107 | ||
108 | 108 | ||
109 | #define APPEND_STATUS_CREATE (0) | 109 | #define APPEND_STATUS_CREATE (0) |
110 | #define APPEND_STATUS_CREATEAFTER (1) | 110 | #define APPEND_STATUS_CREATEAFTER (1) |
111 | #define APPEND_STATUS_ADDINZIP (2) | 111 | #define APPEND_STATUS_ADDINZIP (2) |
112 | 112 | ||
113 | extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); | 113 | extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); |
114 | /* | 114 | /* |
115 | Create a zipfile. | 115 | Create a zipfile. |
116 | pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on | 116 | pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on |
117 | an Unix computer "zlib/zlib113.zip". | 117 | an Unix computer "zlib/zlib113.zip". |
118 | if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip | 118 | if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip |
119 | will be created at the end of the file. | 119 | will be created at the end of the file. |
120 | (useful if the file contain a self extractor code) | 120 | (useful if the file contain a self extractor code) |
121 | if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will | 121 | if the file pathname exist and append==APPEND_STATUS_ADDINZIP, we will |
122 | add files in existing zip (be sure you don't add file that doesn't exist) | 122 | add files in existing zip (be sure you don't add file that doesn't exist) |
123 | If the zipfile cannot be opened, the return value is NULL. | 123 | If the zipfile cannot be opened, the return value is NULL. |
124 | Else, the return value is a zipFile Handle, usable with other function | 124 | Else, the return value is a zipFile Handle, usable with other function |
125 | of this zip package. | 125 | of this zip package. |
126 | */ | 126 | */ |
127 | 127 | ||
128 | /* Note : there is no delete function into a zipfile. | 128 | /* Note : there is no delete function into a zipfile. |
129 | If you want delete file into a zipfile, you must open a zipfile, and create another | 129 | If you want delete file into a zipfile, you must open a zipfile, and create another |
130 | Of couse, you can use RAW reading and writing to copy the file you did not want delte | 130 | Of couse, you can use RAW reading and writing to copy the file you did not want delte |
131 | */ | 131 | */ |
132 | 132 | ||
133 | extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, | 133 | extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, |
134 | int append, | 134 | int append, |
135 | zipcharpc* globalcomment, | 135 | zipcharpc* globalcomment, |
136 | zlib_filefunc_def* pzlib_filefunc_def)); | 136 | zlib_filefunc_def* pzlib_filefunc_def)); |
137 | 137 | ||
138 | extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, | 138 | extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, |
139 | const char* filename, | 139 | const char* filename, |
140 | const zip_fileinfo* zipfi, | 140 | const zip_fileinfo* zipfi, |
141 | const void* extrafield_local, | 141 | const void* extrafield_local, |
142 | uInt size_extrafield_local, | 142 | uInt size_extrafield_local, |
143 | const void* extrafield_global, | 143 | const void* extrafield_global, |
144 | uInt size_extrafield_global, | 144 | uInt size_extrafield_global, |
145 | const char* comment, | 145 | const char* comment, |
146 | int method, | 146 | int method, |
147 | int level)); | 147 | int level)); |
148 | /* | 148 | /* |
149 | Open a file in the ZIP for writing. | 149 | Open a file in the ZIP for writing. |
150 | filename : the filename in zip (if NULL, '-' without quote will be used | 150 | filename : the filename in zip (if NULL, '-' without quote will be used |
151 | *zipfi contain supplemental information | 151 | *zipfi contain supplemental information |
152 | if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local | 152 | if extrafield_local!=NULL and size_extrafield_local>0, extrafield_local |
153 | contains the extrafield data the the local header | 153 | contains the extrafield data the the local header |
154 | if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global | 154 | if extrafield_global!=NULL and size_extrafield_global>0, extrafield_global |
155 | contains the extrafield data the the local header | 155 | contains the extrafield data the the local header |
156 | if comment != NULL, comment contain the comment string | 156 | if comment != NULL, comment contain the comment string |
157 | method contain the compression method (0 for store, Z_DEFLATED for deflate) | 157 | method contain the compression method (0 for store, Z_DEFLATED for deflate) |
158 | level contain the level of compression (can be Z_DEFAULT_COMPRESSION) | 158 | level contain the level of compression (can be Z_DEFAULT_COMPRESSION) |
159 | */ | 159 | */ |
160 | 160 | ||
161 | 161 | ||
162 | extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, | 162 | extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, |
163 | const char* filename, | 163 | const char* filename, |
164 | const zip_fileinfo* zipfi, | 164 | const zip_fileinfo* zipfi, |
165 | const void* extrafield_local, | 165 | const void* extrafield_local, |
166 | uInt size_extrafield_local, | 166 | uInt size_extrafield_local, |
167 | const void* extrafield_global, | 167 | const void* extrafield_global, |
168 | uInt size_extrafield_global, | 168 | uInt size_extrafield_global, |
169 | const char* comment, | 169 | const char* comment, |
170 | int method, | 170 | int method, |
171 | int level, | 171 | int level, |
172 | int raw)); | 172 | int raw)); |
173 | 173 | ||
174 | /* | 174 | /* |
175 | Same than zipOpenNewFileInZip, except if raw=1, we write raw file | 175 | Same than zipOpenNewFileInZip, except if raw=1, we write raw file |
176 | */ | 176 | */ |
177 | 177 | ||
178 | extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, | 178 | extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, |
179 | const char* filename, | 179 | const char* filename, |
180 | const zip_fileinfo* zipfi, | 180 | const zip_fileinfo* zipfi, |
181 | const void* extrafield_local, | 181 | const void* extrafield_local, |
182 | uInt size_extrafield_local, | 182 | uInt size_extrafield_local, |
183 | const void* extrafield_global, | 183 | const void* extrafield_global, |
184 | uInt size_extrafield_global, | 184 | uInt size_extrafield_global, |
185 | const char* comment, | 185 | const char* comment, |
186 | int method, | 186 | int method, |
187 | int level, | 187 | int level, |
188 | int raw, | 188 | int raw, |
189 | int windowBits, | 189 | int windowBits, |
190 | int memLevel, | 190 | int memLevel, |
191 | int strategy, | 191 | int strategy, |
192 | const char* password, | 192 | const char* password, |
193 | uLong crcForCtypting)); | 193 | uLong crcForCtypting)); |
194 | 194 | ||
195 | /* | 195 | /* |
196 | Same than zipOpenNewFileInZip2, except | 196 | Same than zipOpenNewFileInZip2, except |
197 | windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 | 197 | windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 |
198 | password : crypting password (NULL for no crypting) | 198 | password : crypting password (NULL for no crypting) |
199 | crcForCtypting : crc of file to compress (needed for crypting) | 199 | crcForCtypting : crc of file to compress (needed for crypting) |
200 | */ | 200 | */ |
201 | 201 | ||
202 | 202 | ||
203 | extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, | 203 | extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, |
204 | const void* buf, | 204 | const void* buf, |
205 | unsigned len)); | 205 | unsigned len)); |
206 | /* | 206 | /* |
207 | Write data in the zipfile | 207 | Write data in the zipfile |
208 | */ | 208 | */ |
209 | 209 | ||
210 | extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); | 210 | extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); |
211 | /* | 211 | /* |
212 | Close the current file in the zipfile | 212 | Close the current file in the zipfile |
213 | */ | 213 | */ |
214 | 214 | ||
215 | 215 | ||
216 | extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, | 216 | extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, |
217 | uLong uncompressed_size, | 217 | uLong uncompressed_size, |
218 | uLong crc32)); | 218 | uLong crc32)); |
219 | /* | 219 | /* |
220 | Close the current file in the zipfile, for fiel opened with | 220 | Close the current file in the zipfile, for fiel opened with |
221 | parameter raw=1 in zipOpenNewFileInZip2 | 221 | parameter raw=1 in zipOpenNewFileInZip2 |
222 | uncompressed_size and crc32 are value for the uncompressed size | 222 | uncompressed_size and crc32 are value for the uncompressed size |
223 | */ | 223 | */ |
224 | 224 | ||
225 | extern int ZEXPORT zipClose OF((zipFile file, | 225 | extern int ZEXPORT zipClose OF((zipFile file, |
226 | const char* global_comment)); | 226 | const char* global_comment)); |
227 | /* | 227 | /* |
228 | Close the zipfile | 228 | Close the zipfile |
229 | */ | 229 | */ |
230 | 230 | ||
231 | #ifdef __cplusplus | 231 | #ifdef __cplusplus |
232 | } | 232 | } |
233 | #endif | 233 | #endif |
234 | 234 | ||
235 | #endif /* _zip_H */ | 235 | #endif /* _zip_H */ |
diff --git a/contrib/pascal/example.pas b/contrib/pascal/example.pas new file mode 100644 index 0000000..5518b36 --- /dev/null +++ b/contrib/pascal/example.pas | |||
@@ -0,0 +1,599 @@ | |||
1 | (* example.c -- usage example of the zlib compression library | ||
2 | * Copyright (C) 1995-2003 Jean-loup Gailly. | ||
3 | * For conditions of distribution and use, see copyright notice in zlib.h | ||
4 | * | ||
5 | * Pascal translation | ||
6 | * Copyright (C) 1998 by Jacques Nomssi Nzali. | ||
7 | * For conditions of distribution and use, see copyright notice in readme.txt | ||
8 | * | ||
9 | * Adaptation to the zlibpas interface | ||
10 | * Copyright (C) 2003 by Cosmin Truta. | ||
11 | * For conditions of distribution and use, see copyright notice in readme.txt | ||
12 | *) | ||
13 | |||
14 | program example; | ||
15 | |||
16 | {$DEFINE TEST_COMPRESS} | ||
17 | {DO NOT $DEFINE TEST_GZIO} | ||
18 | {$DEFINE TEST_DEFLATE} | ||
19 | {$DEFINE TEST_INFLATE} | ||
20 | {$DEFINE TEST_FLUSH} | ||
21 | {$DEFINE TEST_SYNC} | ||
22 | {$DEFINE TEST_DICT} | ||
23 | |||
24 | uses SysUtils, zlibpas; | ||
25 | |||
26 | const TESTFILE = 'foo.gz'; | ||
27 | |||
28 | (* "hello world" would be more standard, but the repeated "hello" | ||
29 | * stresses the compression code better, sorry... | ||
30 | *) | ||
31 | const hello: PChar = 'hello, hello!'; | ||
32 | |||
33 | const dictionary: PChar = 'hello'; | ||
34 | |||
35 | var dictId: LongInt; (* Adler32 value of the dictionary *) | ||
36 | |||
37 | procedure CHECK_ERR(err: Integer; msg: String); | ||
38 | begin | ||
39 | if err <> Z_OK then | ||
40 | begin | ||
41 | WriteLn(msg, ' error: ', err); | ||
42 | Halt(1); | ||
43 | end; | ||
44 | end; | ||
45 | |||
46 | procedure EXIT_ERR(const msg: String); | ||
47 | begin | ||
48 | WriteLn('Error: ', msg); | ||
49 | Halt(1); | ||
50 | end; | ||
51 | |||
52 | (* =========================================================================== | ||
53 | * Test compress and uncompress | ||
54 | *) | ||
55 | {$IFDEF TEST_COMPRESS} | ||
56 | procedure test_compress(compr: Pointer; comprLen: LongInt; | ||
57 | uncompr: Pointer; uncomprLen: LongInt); | ||
58 | var err: Integer; | ||
59 | len: LongInt; | ||
60 | begin | ||
61 | len := StrLen(hello)+1; | ||
62 | |||
63 | err := compress(compr, comprLen, hello, len); | ||
64 | CHECK_ERR(err, 'compress'); | ||
65 | |||
66 | StrCopy(PChar(uncompr), 'garbage'); | ||
67 | |||
68 | err := uncompress(uncompr, uncomprLen, compr, comprLen); | ||
69 | CHECK_ERR(err, 'uncompress'); | ||
70 | |||
71 | if StrComp(PChar(uncompr), hello) <> 0 then | ||
72 | EXIT_ERR('bad uncompress') | ||
73 | else | ||
74 | WriteLn('uncompress(): ', PChar(uncompr)); | ||
75 | end; | ||
76 | {$ENDIF} | ||
77 | |||
78 | (* =========================================================================== | ||
79 | * Test read/write of .gz files | ||
80 | *) | ||
81 | {$IFDEF TEST_GZIO} | ||
82 | procedure test_gzio(const fname: PChar; (* compressed file name *) | ||
83 | uncompr: Pointer; | ||
84 | uncomprLen: LongInt); | ||
85 | var err: Integer; | ||
86 | len: Integer; | ||
87 | zfile: gzFile; | ||
88 | pos: LongInt; | ||
89 | begin | ||
90 | len := StrLen(hello)+1; | ||
91 | |||
92 | zfile := gzopen(fname, 'wb'); | ||
93 | if zfile = NIL then | ||
94 | begin | ||
95 | WriteLn('gzopen error'); | ||
96 | Halt(1); | ||
97 | end; | ||
98 | gzputc(zfile, 'h'); | ||
99 | if gzputs(zfile, 'ello') <> 4 then | ||
100 | begin | ||
101 | WriteLn('gzputs err: ', gzerror(zfile, err)); | ||
102 | Halt(1); | ||
103 | end; | ||
104 | {$IFDEF GZ_FORMAT_STRING} | ||
105 | if gzprintf(zfile, ', %s!', 'hello') <> 8 then | ||
106 | begin | ||
107 | WriteLn('gzprintf err: ', gzerror(zfile, err)); | ||
108 | Halt(1); | ||
109 | end; | ||
110 | {$ELSE} | ||
111 | if gzputs(zfile, ', hello!') <> 8 then | ||
112 | begin | ||
113 | WriteLn('gzputs err: ', gzerror(zfile, err)); | ||
114 | Halt(1); | ||
115 | end; | ||
116 | {$ENDIF} | ||
117 | gzseek(zfile, 1, SEEK_CUR); (* add one zero byte *) | ||
118 | gzclose(zfile); | ||
119 | |||
120 | zfile := gzopen(fname, 'rb'); | ||
121 | if zfile = NIL then | ||
122 | begin | ||
123 | WriteLn('gzopen error'); | ||
124 | Halt(1); | ||
125 | end; | ||
126 | |||
127 | StrCopy(PChar(uncompr), 'garbage'); | ||
128 | |||
129 | if gzread(zfile, uncompr, uncomprLen) <> len then | ||
130 | begin | ||
131 | WriteLn('gzread err: ', gzerror(zfile, err)); | ||
132 | Halt(1); | ||
133 | end; | ||
134 | if StrComp(PChar(uncompr), hello) <> 0 then | ||
135 | begin | ||
136 | WriteLn('bad gzread: ', PChar(uncompr)); | ||
137 | Halt(1); | ||
138 | end | ||
139 | else | ||
140 | WriteLn('gzread(): ', PChar(uncompr)); | ||
141 | |||
142 | pos := gzseek(zfile, -8, SEEK_CUR); | ||
143 | if (pos <> 6) or (gztell(zfile) <> pos) then | ||
144 | begin | ||
145 | WriteLn('gzseek error, pos=', pos, ', gztell=', gztell(zfile)); | ||
146 | Halt(1); | ||
147 | end; | ||
148 | |||
149 | if gzgetc(zfile) <> ' ' then | ||
150 | begin | ||
151 | WriteLn('gzgetc error'); | ||
152 | Halt(1); | ||
153 | end; | ||
154 | |||
155 | if gzungetc(' ', zfile) <> ' ' then | ||
156 | begin | ||
157 | WriteLn('gzungetc error'); | ||
158 | Halt(1); | ||
159 | end; | ||
160 | |||
161 | gzgets(zfile, PChar(uncompr), uncomprLen); | ||
162 | uncomprLen := StrLen(PChar(uncompr)); | ||
163 | if uncomprLen <> 7 then (* " hello!" *) | ||
164 | begin | ||
165 | WriteLn('gzgets err after gzseek: ', gzerror(zfile, err)); | ||
166 | Halt(1); | ||
167 | end; | ||
168 | if StrComp(PChar(uncompr), hello + 6) <> 0 then | ||
169 | begin | ||
170 | WriteLn('bad gzgets after gzseek'); | ||
171 | Halt(1); | ||
172 | end | ||
173 | else | ||
174 | WriteLn('gzgets() after gzseek: ', PChar(uncompr)); | ||
175 | |||
176 | gzclose(zfile); | ||
177 | end; | ||
178 | {$ENDIF} | ||
179 | |||
180 | (* =========================================================================== | ||
181 | * Test deflate with small buffers | ||
182 | *) | ||
183 | {$IFDEF TEST_DEFLATE} | ||
184 | procedure test_deflate(compr: Pointer; comprLen: LongInt); | ||
185 | var c_stream: z_stream; (* compression stream *) | ||
186 | err: Integer; | ||
187 | len: LongInt; | ||
188 | begin | ||
189 | len := StrLen(hello)+1; | ||
190 | |||
191 | c_stream.zalloc := NIL; | ||
192 | c_stream.zfree := NIL; | ||
193 | c_stream.opaque := NIL; | ||
194 | |||
195 | err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION); | ||
196 | CHECK_ERR(err, 'deflateInit'); | ||
197 | |||
198 | c_stream.next_in := hello; | ||
199 | c_stream.next_out := compr; | ||
200 | |||
201 | while (c_stream.total_in <> len) and | ||
202 | (c_stream.total_out < comprLen) do | ||
203 | begin | ||
204 | c_stream.avail_out := 1; { force small buffers } | ||
205 | c_stream.avail_in := 1; | ||
206 | err := deflate(c_stream, Z_NO_FLUSH); | ||
207 | CHECK_ERR(err, 'deflate'); | ||
208 | end; | ||
209 | |||
210 | (* Finish the stream, still forcing small buffers: *) | ||
211 | while TRUE do | ||
212 | begin | ||
213 | c_stream.avail_out := 1; | ||
214 | err := deflate(c_stream, Z_FINISH); | ||
215 | if err = Z_STREAM_END then | ||
216 | break; | ||
217 | CHECK_ERR(err, 'deflate'); | ||
218 | end; | ||
219 | |||
220 | err := deflateEnd(c_stream); | ||
221 | CHECK_ERR(err, 'deflateEnd'); | ||
222 | end; | ||
223 | {$ENDIF} | ||
224 | |||
225 | (* =========================================================================== | ||
226 | * Test inflate with small buffers | ||
227 | *) | ||
228 | {$IFDEF TEST_INFLATE} | ||
229 | procedure test_inflate(compr: Pointer; comprLen : LongInt; | ||
230 | uncompr: Pointer; uncomprLen : LongInt); | ||
231 | var err: Integer; | ||
232 | d_stream: z_stream; (* decompression stream *) | ||
233 | begin | ||
234 | StrCopy(PChar(uncompr), 'garbage'); | ||
235 | |||
236 | d_stream.zalloc := NIL; | ||
237 | d_stream.zfree := NIL; | ||
238 | d_stream.opaque := NIL; | ||
239 | |||
240 | d_stream.next_in := compr; | ||
241 | d_stream.avail_in := 0; | ||
242 | d_stream.next_out := uncompr; | ||
243 | |||
244 | err := inflateInit(d_stream); | ||
245 | CHECK_ERR(err, 'inflateInit'); | ||
246 | |||
247 | while (d_stream.total_out < uncomprLen) and | ||
248 | (d_stream.total_in < comprLen) do | ||
249 | begin | ||
250 | d_stream.avail_out := 1; (* force small buffers *) | ||
251 | d_stream.avail_in := 1; | ||
252 | err := inflate(d_stream, Z_NO_FLUSH); | ||
253 | if err = Z_STREAM_END then | ||
254 | break; | ||
255 | CHECK_ERR(err, 'inflate'); | ||
256 | end; | ||
257 | |||
258 | err := inflateEnd(d_stream); | ||
259 | CHECK_ERR(err, 'inflateEnd'); | ||
260 | |||
261 | if StrComp(PChar(uncompr), hello) <> 0 then | ||
262 | EXIT_ERR('bad inflate') | ||
263 | else | ||
264 | WriteLn('inflate(): ', PChar(uncompr)); | ||
265 | end; | ||
266 | {$ENDIF} | ||
267 | |||
268 | (* =========================================================================== | ||
269 | * Test deflate with large buffers and dynamic change of compression level | ||
270 | *) | ||
271 | {$IFDEF TEST_DEFLATE} | ||
272 | procedure test_large_deflate(compr: Pointer; comprLen: LongInt; | ||
273 | uncompr: Pointer; uncomprLen: LongInt); | ||
274 | var c_stream: z_stream; (* compression stream *) | ||
275 | err: Integer; | ||
276 | begin | ||
277 | c_stream.zalloc := NIL; | ||
278 | c_stream.zfree := NIL; | ||
279 | c_stream.opaque := NIL; | ||
280 | |||
281 | err := deflateInit(c_stream, Z_BEST_SPEED); | ||
282 | CHECK_ERR(err, 'deflateInit'); | ||
283 | |||
284 | c_stream.next_out := compr; | ||
285 | c_stream.avail_out := Integer(comprLen); | ||
286 | |||
287 | (* At this point, uncompr is still mostly zeroes, so it should compress | ||
288 | * very well: | ||
289 | *) | ||
290 | c_stream.next_in := uncompr; | ||
291 | c_stream.avail_in := Integer(uncomprLen); | ||
292 | err := deflate(c_stream, Z_NO_FLUSH); | ||
293 | CHECK_ERR(err, 'deflate'); | ||
294 | if c_stream.avail_in <> 0 then | ||
295 | EXIT_ERR('deflate not greedy'); | ||
296 | |||
297 | (* Feed in already compressed data and switch to no compression: *) | ||
298 | deflateParams(c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); | ||
299 | c_stream.next_in := compr; | ||
300 | c_stream.avail_in := Integer(comprLen div 2); | ||
301 | err := deflate(c_stream, Z_NO_FLUSH); | ||
302 | CHECK_ERR(err, 'deflate'); | ||
303 | |||
304 | (* Switch back to compressing mode: *) | ||
305 | deflateParams(c_stream, Z_BEST_COMPRESSION, Z_FILTERED); | ||
306 | c_stream.next_in := uncompr; | ||
307 | c_stream.avail_in := Integer(uncomprLen); | ||
308 | err := deflate(c_stream, Z_NO_FLUSH); | ||
309 | CHECK_ERR(err, 'deflate'); | ||
310 | |||
311 | err := deflate(c_stream, Z_FINISH); | ||
312 | if err <> Z_STREAM_END then | ||
313 | EXIT_ERR('deflate should report Z_STREAM_END'); | ||
314 | |||
315 | err := deflateEnd(c_stream); | ||
316 | CHECK_ERR(err, 'deflateEnd'); | ||
317 | end; | ||
318 | {$ENDIF} | ||
319 | |||
320 | (* =========================================================================== | ||
321 | * Test inflate with large buffers | ||
322 | *) | ||
323 | {$IFDEF TEST_INFLATE} | ||
324 | procedure test_large_inflate(compr: Pointer; comprLen: LongInt; | ||
325 | uncompr: Pointer; uncomprLen: LongInt); | ||
326 | var err: Integer; | ||
327 | d_stream: z_stream; (* decompression stream *) | ||
328 | begin | ||
329 | StrCopy(PChar(uncompr), 'garbage'); | ||
330 | |||
331 | d_stream.zalloc := NIL; | ||
332 | d_stream.zfree := NIL; | ||
333 | d_stream.opaque := NIL; | ||
334 | |||
335 | d_stream.next_in := compr; | ||
336 | d_stream.avail_in := Integer(comprLen); | ||
337 | |||
338 | err := inflateInit(d_stream); | ||
339 | CHECK_ERR(err, 'inflateInit'); | ||
340 | |||
341 | while TRUE do | ||
342 | begin | ||
343 | d_stream.next_out := uncompr; (* discard the output *) | ||
344 | d_stream.avail_out := Integer(uncomprLen); | ||
345 | err := inflate(d_stream, Z_NO_FLUSH); | ||
346 | if err = Z_STREAM_END then | ||
347 | break; | ||
348 | CHECK_ERR(err, 'large inflate'); | ||
349 | end; | ||
350 | |||
351 | err := inflateEnd(d_stream); | ||
352 | CHECK_ERR(err, 'inflateEnd'); | ||
353 | |||
354 | if d_stream.total_out <> 2 * uncomprLen + comprLen div 2 then | ||
355 | begin | ||
356 | WriteLn('bad large inflate: ', d_stream.total_out); | ||
357 | Halt(1); | ||
358 | end | ||
359 | else | ||
360 | WriteLn('large_inflate(): OK'); | ||
361 | end; | ||
362 | {$ENDIF} | ||
363 | |||
364 | (* =========================================================================== | ||
365 | * Test deflate with full flush | ||
366 | *) | ||
367 | {$IFDEF TEST_FLUSH} | ||
368 | procedure test_flush(compr: Pointer; var comprLen : LongInt); | ||
369 | var c_stream: z_stream; (* compression stream *) | ||
370 | err: Integer; | ||
371 | len: Integer; | ||
372 | begin | ||
373 | len := StrLen(hello)+1; | ||
374 | |||
375 | c_stream.zalloc := NIL; | ||
376 | c_stream.zfree := NIL; | ||
377 | c_stream.opaque := NIL; | ||
378 | |||
379 | err := deflateInit(c_stream, Z_DEFAULT_COMPRESSION); | ||
380 | CHECK_ERR(err, 'deflateInit'); | ||
381 | |||
382 | c_stream.next_in := hello; | ||
383 | c_stream.next_out := compr; | ||
384 | c_stream.avail_in := 3; | ||
385 | c_stream.avail_out := Integer(comprLen); | ||
386 | err := deflate(c_stream, Z_FULL_FLUSH); | ||
387 | CHECK_ERR(err, 'deflate'); | ||
388 | |||
389 | Inc(PByteArray(compr)^[3]); (* force an error in first compressed block *) | ||
390 | c_stream.avail_in := len - 3; | ||
391 | |||
392 | err := deflate(c_stream, Z_FINISH); | ||
393 | if err <> Z_STREAM_END then | ||
394 | CHECK_ERR(err, 'deflate'); | ||
395 | |||
396 | err := deflateEnd(c_stream); | ||
397 | CHECK_ERR(err, 'deflateEnd'); | ||
398 | |||
399 | comprLen := c_stream.total_out; | ||
400 | end; | ||
401 | {$ENDIF} | ||
402 | |||
403 | (* =========================================================================== | ||
404 | * Test inflateSync() | ||
405 | *) | ||
406 | {$IFDEF TEST_SYNC} | ||
407 | procedure test_sync(compr: Pointer; comprLen: LongInt; | ||
408 | uncompr: Pointer; uncomprLen : LongInt); | ||
409 | var err: Integer; | ||
410 | d_stream: z_stream; (* decompression stream *) | ||
411 | begin | ||
412 | StrCopy(PChar(uncompr), 'garbage'); | ||
413 | |||
414 | d_stream.zalloc := NIL; | ||
415 | d_stream.zfree := NIL; | ||
416 | d_stream.opaque := NIL; | ||
417 | |||
418 | d_stream.next_in := compr; | ||
419 | d_stream.avail_in := 2; (* just read the zlib header *) | ||
420 | |||
421 | err := inflateInit(d_stream); | ||
422 | CHECK_ERR(err, 'inflateInit'); | ||
423 | |||
424 | d_stream.next_out := uncompr; | ||
425 | d_stream.avail_out := Integer(uncomprLen); | ||
426 | |||
427 | inflate(d_stream, Z_NO_FLUSH); | ||
428 | CHECK_ERR(err, 'inflate'); | ||
429 | |||
430 | d_stream.avail_in := Integer(comprLen-2); (* read all compressed data *) | ||
431 | err := inflateSync(d_stream); (* but skip the damaged part *) | ||
432 | CHECK_ERR(err, 'inflateSync'); | ||
433 | |||
434 | err := inflate(d_stream, Z_FINISH); | ||
435 | if err <> Z_DATA_ERROR then | ||
436 | EXIT_ERR('inflate should report DATA_ERROR'); | ||
437 | (* Because of incorrect adler32 *) | ||
438 | |||
439 | err := inflateEnd(d_stream); | ||
440 | CHECK_ERR(err, 'inflateEnd'); | ||
441 | |||
442 | WriteLn('after inflateSync(): hel', PChar(uncompr)); | ||
443 | end; | ||
444 | {$ENDIF} | ||
445 | |||
446 | (* =========================================================================== | ||
447 | * Test deflate with preset dictionary | ||
448 | *) | ||
449 | {$IFDEF TEST_DICT} | ||
450 | procedure test_dict_deflate(compr: Pointer; comprLen: LongInt); | ||
451 | var c_stream: z_stream; (* compression stream *) | ||
452 | err: Integer; | ||
453 | begin | ||
454 | c_stream.zalloc := NIL; | ||
455 | c_stream.zfree := NIL; | ||
456 | c_stream.opaque := NIL; | ||
457 | |||
458 | err := deflateInit(c_stream, Z_BEST_COMPRESSION); | ||
459 | CHECK_ERR(err, 'deflateInit'); | ||
460 | |||
461 | err := deflateSetDictionary(c_stream, dictionary, StrLen(dictionary)); | ||
462 | CHECK_ERR(err, 'deflateSetDictionary'); | ||
463 | |||
464 | dictId := c_stream.adler; | ||
465 | c_stream.next_out := compr; | ||
466 | c_stream.avail_out := Integer(comprLen); | ||
467 | |||
468 | c_stream.next_in := hello; | ||
469 | c_stream.avail_in := StrLen(hello)+1; | ||
470 | |||
471 | err := deflate(c_stream, Z_FINISH); | ||
472 | if err <> Z_STREAM_END then | ||
473 | EXIT_ERR('deflate should report Z_STREAM_END'); | ||
474 | |||
475 | err := deflateEnd(c_stream); | ||
476 | CHECK_ERR(err, 'deflateEnd'); | ||
477 | end; | ||
478 | {$ENDIF} | ||
479 | |||
480 | (* =========================================================================== | ||
481 | * Test inflate with a preset dictionary | ||
482 | *) | ||
483 | {$IFDEF TEST_DICT} | ||
484 | procedure test_dict_inflate(compr: Pointer; comprLen: LongInt; | ||
485 | uncompr: Pointer; uncomprLen: LongInt); | ||
486 | var err: Integer; | ||
487 | d_stream: z_stream; (* decompression stream *) | ||
488 | begin | ||
489 | StrCopy(PChar(uncompr), 'garbage'); | ||
490 | |||
491 | d_stream.zalloc := NIL; | ||
492 | d_stream.zfree := NIL; | ||
493 | d_stream.opaque := NIL; | ||
494 | |||
495 | d_stream.next_in := compr; | ||
496 | d_stream.avail_in := Integer(comprLen); | ||
497 | |||
498 | err := inflateInit(d_stream); | ||
499 | CHECK_ERR(err, 'inflateInit'); | ||
500 | |||
501 | d_stream.next_out := uncompr; | ||
502 | d_stream.avail_out := Integer(uncomprLen); | ||
503 | |||
504 | while TRUE do | ||
505 | begin | ||
506 | err := inflate(d_stream, Z_NO_FLUSH); | ||
507 | if err = Z_STREAM_END then | ||
508 | break; | ||
509 | if err = Z_NEED_DICT then | ||
510 | begin | ||
511 | if d_stream.adler <> dictId then | ||
512 | EXIT_ERR('unexpected dictionary'); | ||
513 | err := inflateSetDictionary(d_stream, dictionary, StrLen(dictionary)); | ||
514 | end; | ||
515 | CHECK_ERR(err, 'inflate with dict'); | ||
516 | end; | ||
517 | |||
518 | err := inflateEnd(d_stream); | ||
519 | CHECK_ERR(err, 'inflateEnd'); | ||
520 | |||
521 | if StrComp(PChar(uncompr), hello) <> 0 then | ||
522 | EXIT_ERR('bad inflate with dict') | ||
523 | else | ||
524 | WriteLn('inflate with dictionary: ', PChar(uncompr)); | ||
525 | end; | ||
526 | {$ENDIF} | ||
527 | |||
528 | var compr, uncompr: Pointer; | ||
529 | comprLen, uncomprLen: LongInt; | ||
530 | |||
531 | begin | ||
532 | if zlibVersion^ <> ZLIB_VERSION[1] then | ||
533 | EXIT_ERR('Incompatible zlib version'); | ||
534 | |||
535 | WriteLn('zlib version: ', zlibVersion); | ||
536 | WriteLn('zlib compile flags: ', Format('0x%x', [zlibCompileFlags])); | ||
537 | |||
538 | comprLen := 10000 * SizeOf(Integer); (* don't overflow on MSDOS *) | ||
539 | uncomprLen := comprLen; | ||
540 | GetMem(compr, comprLen); | ||
541 | GetMem(uncompr, uncomprLen); | ||
542 | if (compr = NIL) or (uncompr = NIL) then | ||
543 | EXIT_ERR('Out of memory'); | ||
544 | (* compr and uncompr are cleared to avoid reading uninitialized | ||
545 | * data and to ensure that uncompr compresses well. | ||
546 | *) | ||
547 | FillChar(compr^, comprLen, 0); | ||
548 | FillChar(uncompr^, uncomprLen, 0); | ||
549 | |||
550 | {$IFDEF TEST_COMPRESS} | ||
551 | WriteLn('** Testing compress'); | ||
552 | test_compress(compr, comprLen, uncompr, uncomprLen); | ||
553 | {$ENDIF} | ||
554 | |||
555 | {$IFDEF TEST_GZIO} | ||
556 | WriteLn('** Testing gzio'); | ||
557 | if ParamCount >= 1 then | ||
558 | test_gzio(ParamStr(1), uncompr, uncomprLen) | ||
559 | else | ||
560 | test_gzio(TESTFILE, uncompr, uncomprLen); | ||
561 | {$ENDIF} | ||
562 | |||
563 | {$IFDEF TEST_DEFLATE} | ||
564 | WriteLn('** Testing deflate with small buffers'); | ||
565 | test_deflate(compr, comprLen); | ||
566 | {$ENDIF} | ||
567 | {$IFDEF TEST_INFLATE} | ||
568 | WriteLn('** Testing inflate with small buffers'); | ||
569 | test_inflate(compr, comprLen, uncompr, uncomprLen); | ||
570 | {$ENDIF} | ||
571 | |||
572 | {$IFDEF TEST_DEFLATE} | ||
573 | WriteLn('** Testing deflate with large buffers'); | ||
574 | test_large_deflate(compr, comprLen, uncompr, uncomprLen); | ||
575 | {$ENDIF} | ||
576 | {$IFDEF TEST_INFLATE} | ||
577 | WriteLn('** Testing inflate with large buffers'); | ||
578 | test_large_inflate(compr, comprLen, uncompr, uncomprLen); | ||
579 | {$ENDIF} | ||
580 | |||
581 | {$IFDEF TEST_FLUSH} | ||
582 | WriteLn('** Testing deflate with full flush'); | ||
583 | test_flush(compr, comprLen); | ||
584 | {$ENDIF} | ||
585 | {$IFDEF TEST_SYNC} | ||
586 | WriteLn('** Testing inflateSync'); | ||
587 | test_sync(compr, comprLen, uncompr, uncomprLen); | ||
588 | {$ENDIF} | ||
589 | comprLen := uncomprLen; | ||
590 | |||
591 | {$IFDEF TEST_DICT} | ||
592 | WriteLn('** Testing deflate and inflate with preset dictionary'); | ||
593 | test_dict_deflate(compr, comprLen); | ||
594 | test_dict_inflate(compr, comprLen, uncompr, uncomprLen); | ||
595 | {$ENDIF} | ||
596 | |||
597 | FreeMem(compr, comprLen); | ||
598 | FreeMem(uncompr, uncomprLen); | ||
599 | end. | ||
diff --git a/contrib/pascal/readme.txt b/contrib/pascal/readme.txt new file mode 100644 index 0000000..60e87c8 --- /dev/null +++ b/contrib/pascal/readme.txt | |||
@@ -0,0 +1,76 @@ | |||
1 | |||
2 | This directory contains a Pascal (Delphi, Kylix) interface to the | ||
3 | zlib data compression library. | ||
4 | |||
5 | |||
6 | Directory listing | ||
7 | ================= | ||
8 | |||
9 | zlibd32.mak makefile for Borland C++ | ||
10 | example.pas usage example of zlib | ||
11 | zlibpas.pas the Pascal interface to zlib | ||
12 | readme.txt this file | ||
13 | |||
14 | |||
15 | Compatibility notes | ||
16 | =================== | ||
17 | |||
18 | - Although the name "zlib" would have been more normal for the | ||
19 | zlibpas unit, this name is already taken by Borland's ZLib unit. | ||
20 | This is somehow unfortunate, because that unit is not a genuine | ||
21 | interface to the full-fledged zlib functionality, but a suite of | ||
22 | class wrappers around zlib streams. Other essential features, | ||
23 | such as checksums, are missing. | ||
24 | It would have been more appropriate for that unit to have a name | ||
25 | like "ZStreams", or something similar. | ||
26 | |||
27 | - The C and zlib-supplied types int, uInt, long, uLong, etc. are | ||
28 | translated directly into Pascal types of similar sizes (Integer, | ||
29 | LongInt, etc.), to avoid namespace pollution. In particular, | ||
30 | there is no conversion of unsigned int into a Pascal unsigned | ||
31 | integer. The Word type is non-portable and has the same size | ||
32 | (16 bits) both in a 16-bit and in a 32-bit environment, unlike | ||
33 | Integer. Even if there is a 32-bit Cardinal type, there is no | ||
34 | real need for unsigned int in zlib under a 32-bit environment. | ||
35 | |||
36 | - Except for the callbacks, the zlib function interfaces are | ||
37 | assuming the calling convention normally used in Pascal | ||
38 | (__pascal for DOS and Windows16, __fastcall for Windows32). | ||
39 | Since the cdecl keyword is used, the old Turbo Pascal does | ||
40 | not work with this interface. | ||
41 | |||
42 | - The gz* function interfaces are not translated, to avoid | ||
43 | interfacing problems with the C runtime library. Besides, | ||
44 | gzprintf(gzFile file, const char *format, ...) | ||
45 | cannot be translated into Pascal. | ||
46 | |||
47 | |||
48 | Legal issues | ||
49 | ============ | ||
50 | |||
51 | The zlibpas interface is: | ||
52 | Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler. | ||
53 | Copyright (C) 1998 by Bob Dellaca. | ||
54 | Copyright (C) 2003 by Cosmin Truta. | ||
55 | |||
56 | The example program is: | ||
57 | Copyright (C) 1995-2003 by Jean-loup Gailly. | ||
58 | Copyright (C) 1998,1999,2000 by Jacques Nomssi Nzali. | ||
59 | Copyright (C) 2003 by Cosmin Truta. | ||
60 | |||
61 | This software is provided 'as-is', without any express or implied | ||
62 | warranty. In no event will the author be held liable for any damages | ||
63 | arising from the use of this software. | ||
64 | |||
65 | Permission is granted to anyone to use this software for any purpose, | ||
66 | including commercial applications, and to alter it and redistribute it | ||
67 | freely, subject to the following restrictions: | ||
68 | |||
69 | 1. The origin of this software must not be misrepresented; you must not | ||
70 | claim that you wrote the original software. If you use this software | ||
71 | in a product, an acknowledgment in the product documentation would be | ||
72 | appreciated but is not required. | ||
73 | 2. Altered source versions must be plainly marked as such, and must not be | ||
74 | misrepresented as being the original software. | ||
75 | 3. This notice may not be removed or altered from any source distribution. | ||
76 | |||
diff --git a/contrib/pascal/zlibd32.mak b/contrib/pascal/zlibd32.mak new file mode 100644 index 0000000..88fafa0 --- /dev/null +++ b/contrib/pascal/zlibd32.mak | |||
@@ -0,0 +1,93 @@ | |||
1 | # Makefile for zlib | ||
2 | # For use with Delphi and C++ Builder under Win32 | ||
3 | # Updated for zlib 1.2.x by Cosmin Truta | ||
4 | |||
5 | # ------------ Borland C++ ------------ | ||
6 | |||
7 | # This project uses the Delphi (fastcall/register) calling convention: | ||
8 | LOC = -DZEXPORT=__fastcall -DZEXPORTVA=__cdecl | ||
9 | |||
10 | CC = bcc32 | ||
11 | LD = bcc32 | ||
12 | AR = tlib | ||
13 | # do not use "-pr" in CFLAGS | ||
14 | CFLAGS = -a -d -k- -O2 $(LOC) | ||
15 | LDFLAGS = | ||
16 | |||
17 | |||
18 | # variables | ||
19 | ZLIB_LIB = zlib.lib | ||
20 | |||
21 | OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj | ||
22 | OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj | ||
23 | OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj | ||
24 | OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj | ||
25 | |||
26 | |||
27 | # targets | ||
28 | all: $(ZLIB_LIB) example.exe minigzip.exe | ||
29 | |||
30 | .c.obj: | ||
31 | $(CC) -c $(CFLAGS) $*.c | ||
32 | |||
33 | adler32.obj: adler32.c zlib.h zconf.h | ||
34 | |||
35 | compress.obj: compress.c zlib.h zconf.h | ||
36 | |||
37 | crc32.obj: crc32.c zlib.h zconf.h crc32.h | ||
38 | |||
39 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h | ||
40 | |||
41 | gzio.obj: gzio.c zutil.h zlib.h zconf.h | ||
42 | |||
43 | infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | ||
44 | inffast.h inffixed.h | ||
45 | |||
46 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | ||
47 | inffast.h | ||
48 | |||
49 | inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | ||
50 | inffast.h inffixed.h | ||
51 | |||
52 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h | ||
53 | |||
54 | trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h | ||
55 | |||
56 | uncompr.obj: uncompr.c zlib.h zconf.h | ||
57 | |||
58 | zutil.obj: zutil.c zutil.h zlib.h zconf.h | ||
59 | |||
60 | example.obj: example.c zlib.h zconf.h | ||
61 | |||
62 | minigzip.obj: minigzip.c zlib.h zconf.h | ||
63 | |||
64 | |||
65 | # For the sake of the old Borland make, | ||
66 | # the command line is cut to fit in the MS-DOS 128 byte limit: | ||
67 | $(ZLIB_LIB): $(OBJ1) $(OBJ2) | ||
68 | -del $(ZLIB_LIB) | ||
69 | $(AR) $(ZLIB_LIB) $(OBJP1) | ||
70 | $(AR) $(ZLIB_LIB) $(OBJP2) | ||
71 | |||
72 | |||
73 | # testing | ||
74 | test: example.exe minigzip.exe | ||
75 | example | ||
76 | echo hello world | minigzip | minigzip -d | ||
77 | |||
78 | example.exe: example.obj $(ZLIB_LIB) | ||
79 | $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) | ||
80 | |||
81 | minigzip.exe: minigzip.obj $(ZLIB_LIB) | ||
82 | $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) | ||
83 | |||
84 | |||
85 | # cleanup | ||
86 | clean: | ||
87 | -del *.obj | ||
88 | -del *.exe | ||
89 | -del *.lib | ||
90 | -del *.tds | ||
91 | -del zlib.bak | ||
92 | -del foo.gz | ||
93 | |||
diff --git a/contrib/pascal/zlibpas.pas b/contrib/pascal/zlibpas.pas new file mode 100644 index 0000000..f81893f --- /dev/null +++ b/contrib/pascal/zlibpas.pas | |||
@@ -0,0 +1,234 @@ | |||
1 | (* zlibpas -- Pascal interface to the zlib data compression library | ||
2 | * | ||
3 | * Copyright (C) 2003 Cosmin Truta. | ||
4 | * Derived from original sources by Bob Dellaca. | ||
5 | * For conditions of distribution and use, see copyright notice in readme.txt | ||
6 | *) | ||
7 | |||
8 | unit zlibpas; | ||
9 | |||
10 | interface | ||
11 | |||
12 | const | ||
13 | ZLIB_VERSION = '1.2.0'; | ||
14 | |||
15 | type | ||
16 | alloc_func = function(opaque: Pointer; items, size: Integer): Pointer; | ||
17 | cdecl; | ||
18 | free_func = procedure(opaque, address: Pointer); | ||
19 | cdecl; | ||
20 | |||
21 | in_func = function(opaque: Pointer; var buf: PByte): Integer; | ||
22 | cdecl; | ||
23 | out_func = function(opaque: Pointer; buf: PByte; size: Integer): Integer; | ||
24 | cdecl; | ||
25 | |||
26 | z_streamp = ^z_stream; | ||
27 | z_stream = packed record | ||
28 | next_in: PChar; (* next input byte *) | ||
29 | avail_in: Integer; (* number of bytes available at next_in *) | ||
30 | total_in: LongInt; (* total nb of input bytes read so far *) | ||
31 | |||
32 | next_out: PChar; (* next output byte should be put there *) | ||
33 | avail_out: Integer; (* remaining free space at next_out *) | ||
34 | total_out: LongInt; (* total nb of bytes output so far *) | ||
35 | |||
36 | msg: PChar; (* last error message, NULL if no error *) | ||
37 | state: Pointer; (* not visible by applications *) | ||
38 | |||
39 | zalloc: alloc_func; (* used to allocate the internal state *) | ||
40 | zfree: free_func; (* used to free the internal state *) | ||
41 | opaque: Pointer; (* private data object passed to zalloc and zfree *) | ||
42 | |||
43 | data_type: Integer; (* best guess about the data type: ascii or binary *) | ||
44 | adler: LongInt; (* adler32 value of the uncompressed data *) | ||
45 | reserved: LongInt; (* reserved for future use *) | ||
46 | end; | ||
47 | |||
48 | (* constants *) | ||
49 | const | ||
50 | Z_NO_FLUSH = 0; | ||
51 | Z_PARTIAL_FLUSH = 1; | ||
52 | Z_SYNC_FLUSH = 2; | ||
53 | Z_FULL_FLUSH = 3; | ||
54 | Z_FINISH = 4; | ||
55 | |||
56 | Z_OK = 0; | ||
57 | Z_STREAM_END = 1; | ||
58 | Z_NEED_DICT = 2; | ||
59 | Z_ERRNO = -1; | ||
60 | Z_STREAM_ERROR = -2; | ||
61 | Z_DATA_ERROR = -3; | ||
62 | Z_MEM_ERROR = -4; | ||
63 | Z_BUF_ERROR = -5; | ||
64 | Z_VERSION_ERROR = -6; | ||
65 | |||
66 | Z_NO_COMPRESSION = 0; | ||
67 | Z_BEST_SPEED = 1; | ||
68 | Z_BEST_COMPRESSION = 9; | ||
69 | Z_DEFAULT_COMPRESSION = -1; | ||
70 | |||
71 | Z_FILTERED = 1; | ||
72 | Z_HUFFMAN_ONLY = 2; | ||
73 | Z_RLE = 3; | ||
74 | Z_DEFAULT_STRATEGY = 0; | ||
75 | |||
76 | Z_BINARY = 0; | ||
77 | Z_ASCII = 1; | ||
78 | Z_UNKNOWN = 2; | ||
79 | |||
80 | Z_DEFLATED = 8; | ||
81 | |||
82 | (* basic functions *) | ||
83 | function zlibVersion: PChar; | ||
84 | function deflateInit(var strm: z_stream; level: Integer): Integer; | ||
85 | function deflate(var strm: z_stream; flush: Integer): Integer; | ||
86 | function deflateEnd(var strm: z_stream): Integer; | ||
87 | function inflateInit(var strm: z_stream): Integer; | ||
88 | function inflate(var strm: z_stream; flush: Integer): Integer; | ||
89 | function inflateEnd(var strm: z_stream): Integer; | ||
90 | |||
91 | (* advanced functions *) | ||
92 | function deflateInit2(var strm: z_stream; level, method, windowBits, | ||
93 | memLevel, strategy: Integer): Integer; | ||
94 | function deflateSetDictionary(var strm: z_stream; const dictionary: PChar; | ||
95 | dictLength: Integer): Integer; | ||
96 | function deflateCopy(var dest, source: z_stream): Integer; | ||
97 | function deflateReset(var strm: z_stream): Integer; | ||
98 | function deflateParams(var strm: z_stream; level, strategy: Integer): Integer; | ||
99 | function deflateBound(var strm: z_stream; sourceLen: LongInt): LongInt; | ||
100 | function inflateInit2(var strm: z_stream; windowBits: Integer): Integer; | ||
101 | function inflateSetDictionary(var strm: z_stream; const dictionary: PChar; | ||
102 | dictLength: Integer): Integer; | ||
103 | function inflateSync(var strm: z_stream): Integer; | ||
104 | function inflateCopy(var dest, source: z_stream): Integer; | ||
105 | function inflateReset(var strm: z_stream): Integer; | ||
106 | function inflateBackInit(var strm: z_stream; | ||
107 | windowBits: Integer; window: PChar): Integer; | ||
108 | function inflateBack(var strm: z_stream; in_fn: in_func; in_desc: Pointer; | ||
109 | out_fn: out_func; out_desc: Pointer): Integer; | ||
110 | function inflateBackEnd(var strm: z_stream): Integer; | ||
111 | function zlibCompileFlags: LongInt; | ||
112 | |||
113 | (* utility functions *) | ||
114 | function compress(dest: PChar; var destLen: LongInt; | ||
115 | const source: PChar; sourceLen: LongInt): Integer; | ||
116 | function compress2(dest: PChar; var destLen: LongInt; | ||
117 | const source: PChar; sourceLen: LongInt; | ||
118 | level: Integer): Integer; | ||
119 | function compressBound(sourceLen: LongInt): LongInt; | ||
120 | function uncompress(dest: PChar; var destLen: LongInt; | ||
121 | const source: PChar; sourceLen: LongInt): Integer; | ||
122 | |||
123 | (* checksum functions *) | ||
124 | function adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt; | ||
125 | function crc32(crc: LongInt; const buf: PChar; len: Integer): LongInt; | ||
126 | |||
127 | (* various hacks, don't look :) *) | ||
128 | function deflateInit_(var strm: z_stream; level: Integer; | ||
129 | const version: PChar; stream_size: Integer): Integer; | ||
130 | function inflateInit_(var strm: z_stream; const version: PChar; | ||
131 | stream_size: Integer): Integer; | ||
132 | function deflateInit2_(var strm: z_stream; | ||
133 | level, method, windowBits, memLevel, strategy: Integer; | ||
134 | const version: PChar; stream_size: Integer): Integer; | ||
135 | function inflateInit2_(var strm: z_stream; windowBits: Integer; | ||
136 | const version: PChar; stream_size: Integer): Integer; | ||
137 | function inflateBackInit_(var strm: z_stream; | ||
138 | windowBits: Integer; window: PChar; | ||
139 | const version: PChar; stream_size: Integer): Integer; | ||
140 | |||
141 | |||
142 | implementation | ||
143 | |||
144 | {$L adler32.obj} | ||
145 | {$L compress.obj} | ||
146 | {$L crc32.obj} | ||
147 | {$L deflate.obj} | ||
148 | {$L infback.obj} | ||
149 | {$L inffast.obj} | ||
150 | {$L inflate.obj} | ||
151 | {$L inftrees.obj} | ||
152 | {$L trees.obj} | ||
153 | {$L uncompr.obj} | ||
154 | {$L zutil.obj} | ||
155 | |||
156 | function adler32; external; | ||
157 | function compress; external; | ||
158 | function compress2; external; | ||
159 | function compressBound; external; | ||
160 | function crc32; external; | ||
161 | function deflate; external; | ||
162 | function deflateBound; external; | ||
163 | function deflateCopy; external; | ||
164 | function deflateEnd; external; | ||
165 | function deflateInit_; external; | ||
166 | function deflateInit2_; external; | ||
167 | function deflateParams; external; | ||
168 | function deflateReset; external; | ||
169 | function deflateSetDictionary; external; | ||
170 | function inflate; external; | ||
171 | function inflateBack; external; | ||
172 | function inflateBackEnd; external; | ||
173 | function inflateBackInit_; external; | ||
174 | function inflateCopy; external; | ||
175 | function inflateEnd; external; | ||
176 | function inflateInit_; external; | ||
177 | function inflateInit2_; external; | ||
178 | function inflateReset; external; | ||
179 | function inflateSetDictionary; external; | ||
180 | function inflateSync; external; | ||
181 | function uncompress; external; | ||
182 | function zlibCompileFlags; external; | ||
183 | function zlibVersion; external; | ||
184 | |||
185 | function deflateInit(var strm: z_stream; level: Integer): Integer; | ||
186 | begin | ||
187 | Result := deflateInit_(strm, level, ZLIB_VERSION, sizeof(z_stream)); | ||
188 | end; | ||
189 | |||
190 | function deflateInit2(var strm: z_stream; level, method, windowBits, memLevel, | ||
191 | strategy: Integer): Integer; | ||
192 | begin | ||
193 | Result := deflateInit2_(strm, level, method, windowBits, memLevel, strategy, | ||
194 | ZLIB_VERSION, sizeof(z_stream)); | ||
195 | end; | ||
196 | |||
197 | function inflateInit(var strm: z_stream): Integer; | ||
198 | begin | ||
199 | Result := inflateInit_(strm, ZLIB_VERSION, sizeof(z_stream)); | ||
200 | end; | ||
201 | |||
202 | function inflateInit2(var strm: z_stream; windowBits: Integer): Integer; | ||
203 | begin | ||
204 | Result := inflateInit2_(strm, windowBits, ZLIB_VERSION, sizeof(z_stream)); | ||
205 | end; | ||
206 | |||
207 | function inflateBackInit(var strm: z_stream; | ||
208 | windowBits: Integer; window: PChar): Integer; | ||
209 | begin | ||
210 | Result := inflateBackInit_(strm, windowBits, window, | ||
211 | ZLIB_VERSION, sizeof(z_stream)); | ||
212 | end; | ||
213 | |||
214 | function _malloc(Size: Integer): Pointer; cdecl; | ||
215 | begin | ||
216 | GetMem(Result, Size); | ||
217 | end; | ||
218 | |||
219 | procedure _free(Block: Pointer); cdecl; | ||
220 | begin | ||
221 | FreeMem(Block); | ||
222 | end; | ||
223 | |||
224 | procedure _memset(P: Pointer; B: Byte; count: Integer); cdecl; | ||
225 | begin | ||
226 | FillChar(P^, count, B); | ||
227 | end; | ||
228 | |||
229 | procedure _memcpy(dest, source: Pointer; count: Integer); cdecl; | ||
230 | begin | ||
231 | Move(source^, dest^, count); | ||
232 | end; | ||
233 | |||
234 | end. | ||
diff --git a/contrib/puff/README b/contrib/puff/README index 59b3533..bbc4cb5 100644 --- a/contrib/puff/README +++ b/contrib/puff/README | |||
@@ -14,7 +14,7 @@ Why I wrote this -- | |||
14 | puff.c was written to document the deflate format unambiguously, by virtue of | 14 | puff.c was written to document the deflate format unambiguously, by virtue of |
15 | being working C code. It is meant to supplement RFC 1951, which formally | 15 | being working C code. It is meant to supplement RFC 1951, which formally |
16 | describes the deflate format. I have received many questions on details of the | 16 | describes the deflate format. I have received many questions on details of the |
17 | deflate format, and I hope that reading this code will answer those questions. | 17 | deflate format, and I hope that reading this code will answer those questions. |
18 | puff.c is heavily commented with details of the deflate format, especially | 18 | puff.c is heavily commented with details of the deflate format, especially |
19 | those little nooks and cranies of the format that might not be obvious from a | 19 | those little nooks and cranies of the format that might not be obvious from a |
20 | specification. | 20 | specification. |
@@ -29,10 +29,10 @@ applications, but if you must ... | |||
29 | 29 | ||
30 | Include puff.h in your code, which provides this prototype: | 30 | Include puff.h in your code, which provides this prototype: |
31 | 31 | ||
32 | int puff(unsigned char *dest, /* pointer to destination pointer */ | 32 | int puff(unsigned char *dest, /* pointer to destination pointer */ |
33 | unsigned long *destlen, /* amount of output space */ | 33 | unsigned long *destlen, /* amount of output space */ |
34 | unsigned char *source, /* pointer to source data pointer */ | 34 | unsigned char *source, /* pointer to source data pointer */ |
35 | unsigned long *sourcelen); /* amount of input available */ | 35 | unsigned long *sourcelen); /* amount of input available */ |
36 | 36 | ||
37 | Then you can call puff() to decompress a deflate stream that is in memory in | 37 | Then you can call puff() to decompress a deflate stream that is in memory in |
38 | its entirety at source, to a sufficiently sized block of memory for the | 38 | its entirety at source, to a sufficiently sized block of memory for the |
diff --git a/contrib/puff/puff.c b/contrib/puff/puff.c index b6039dd..a30fb17 100644 --- a/contrib/puff/puff.c +++ b/contrib/puff/puff.c | |||
@@ -805,7 +805,7 @@ local unsigned char *yank(char *name, unsigned long *len) | |||
805 | buf = NULL; | 805 | buf = NULL; |
806 | } | 806 | } |
807 | fclose(in); | 807 | fclose(in); |
808 | *len = size; | 808 | *len = size; |
809 | return buf; | 809 | return buf; |
810 | } | 810 | } |
811 | 811 | ||
diff --git a/contrib/puff/puff.h b/contrib/puff/puff.h index 41ea7e1..ef61252 100644 --- a/contrib/puff/puff.h +++ b/contrib/puff/puff.h | |||
@@ -18,7 +18,7 @@ | |||
18 | misrepresented as being the original software. | 18 | misrepresented as being the original software. |
19 | 3. This notice may not be removed or altered from any source distribution. | 19 | 3. This notice may not be removed or altered from any source distribution. |
20 | 20 | ||
21 | Mark Adler madler@alumni.caltech.edu | 21 | Mark Adler madler@alumni.caltech.edu |
22 | */ | 22 | */ |
23 | 23 | ||
24 | 24 | ||
diff --git a/contrib/testzlib/testzlib.c b/contrib/testzlib/testzlib.c index caae4ef..fdabc5c 100644 --- a/contrib/testzlib/testzlib.c +++ b/contrib/testzlib/testzlib.c | |||
@@ -1,149 +1,149 @@ | |||
1 | 1 | ||
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <stdlib.h> | 3 | #include <stdlib.h> |
4 | #include <windows.h> | 4 | #include <windows.h> |
5 | #include "zlib.h" | 5 | #include "zlib.h" |
6 | 6 | ||
7 | int ReadFileMemory(const char* filename,long* plFileSize,void** pFilePtr) | 7 | int ReadFileMemory(const char* filename,long* plFileSize,void** pFilePtr) |
8 | { | 8 | { |
9 | FILE* stream; | 9 | FILE* stream; |
10 | void* ptr; | 10 | void* ptr; |
11 | int retVal=1; | 11 | int retVal=1; |
12 | stream=fopen(filename, "rb"); | 12 | stream=fopen(filename, "rb"); |
13 | if (stream==NULL) | 13 | if (stream==NULL) |
14 | return 0; | 14 | return 0; |
15 | 15 | ||
16 | fseek(stream,0,SEEK_END); | 16 | fseek(stream,0,SEEK_END); |
17 | 17 | ||
18 | *plFileSize=ftell(stream); | 18 | *plFileSize=ftell(stream); |
19 | fseek(stream,0,SEEK_SET); | 19 | fseek(stream,0,SEEK_SET); |
20 | ptr=malloc((*plFileSize)+1); | 20 | ptr=malloc((*plFileSize)+1); |
21 | if (ptr==NULL) | 21 | if (ptr==NULL) |
22 | retVal=0; | 22 | retVal=0; |
23 | else | 23 | else |
24 | { | 24 | { |
25 | if (fread(ptr, 1, *plFileSize,stream) != (*plFileSize)) | 25 | if (fread(ptr, 1, *plFileSize,stream) != (*plFileSize)) |
26 | retVal=0; | 26 | retVal=0; |
27 | } | 27 | } |
28 | fclose(stream); | 28 | fclose(stream); |
29 | *pFilePtr=ptr; | 29 | *pFilePtr=ptr; |
30 | return retVal; | 30 | return retVal; |
31 | } | 31 | } |
32 | 32 | ||
33 | int main(int argc, char *argv[]) | 33 | int main(int argc, char *argv[]) |
34 | { | 34 | { |
35 | int BlockSizeCompress=0x8000; | 35 | int BlockSizeCompress=0x8000; |
36 | int BlockSizeUncompress=0x8000; | 36 | int BlockSizeUncompress=0x8000; |
37 | int cprLevel=Z_DEFAULT_COMPRESSION ; | 37 | int cprLevel=Z_DEFAULT_COMPRESSION ; |
38 | long lFileSize; | 38 | long lFileSize; |
39 | unsigned char* FilePtr; | 39 | unsigned char* FilePtr; |
40 | long lBufferSizeCpr; | 40 | long lBufferSizeCpr; |
41 | long lBufferSizeUncpr; | 41 | long lBufferSizeUncpr; |
42 | long lCompressedSize=0; | 42 | long lCompressedSize=0; |
43 | unsigned char* CprPtr; | 43 | unsigned char* CprPtr; |
44 | unsigned char* UncprPtr; | 44 | unsigned char* UncprPtr; |
45 | long lSizeCpr,lSizeUncpr; | 45 | long lSizeCpr,lSizeUncpr; |
46 | DWORD dwGetTick; | 46 | DWORD dwGetTick; |
47 | 47 | ||
48 | if (argc<=1) | 48 | if (argc<=1) |
49 | { | 49 | { |
50 | printf("run TestZlib <File> [BlockSizeCompress] [BlockSizeUncompress] [compres. level]\n"); | 50 | printf("run TestZlib <File> [BlockSizeCompress] [BlockSizeUncompress] [compres. level]\n"); |
51 | return 0; | 51 | return 0; |
52 | } | 52 | } |
53 | 53 | ||
54 | if (ReadFileMemory(argv[1],&lFileSize,&FilePtr)==0) | 54 | if (ReadFileMemory(argv[1],&lFileSize,&FilePtr)==0) |
55 | { | 55 | { |
56 | printf("error reading %s\n",argv[1]); | 56 | printf("error reading %s\n",argv[1]); |
57 | return 1; | 57 | return 1; |
58 | } | 58 | } |
59 | else printf("file %s read, %u bytes\n",argv[1],lFileSize); | 59 | else printf("file %s read, %u bytes\n",argv[1],lFileSize); |
60 | 60 | ||
61 | if (argc>=3) | 61 | if (argc>=3) |
62 | BlockSizeCompress=atol(argv[2]); | 62 | BlockSizeCompress=atol(argv[2]); |
63 | 63 | ||
64 | if (argc>=4) | 64 | if (argc>=4) |
65 | BlockSizeUncompress=atol(argv[3]); | 65 | BlockSizeUncompress=atol(argv[3]); |
66 | 66 | ||
67 | if (argc>=5) | 67 | if (argc>=5) |
68 | cprLevel=(int)atol(argv[4]); | 68 | cprLevel=(int)atol(argv[4]); |
69 | 69 | ||
70 | lBufferSizeCpr = lFileSize + (lFileSize/0x10) + 0x200; | 70 | lBufferSizeCpr = lFileSize + (lFileSize/0x10) + 0x200; |
71 | lBufferSizeUncpr = lBufferSizeCpr; | 71 | lBufferSizeUncpr = lBufferSizeCpr; |
72 | 72 | ||
73 | CprPtr=(unsigned char*)malloc(lBufferSizeCpr + BlockSizeCompress); | 73 | CprPtr=(unsigned char*)malloc(lBufferSizeCpr + BlockSizeCompress); |
74 | UncprPtr=(unsigned char*)malloc(lBufferSizeUncpr + BlockSizeUncompress); | 74 | UncprPtr=(unsigned char*)malloc(lBufferSizeUncpr + BlockSizeUncompress); |
75 | 75 | ||
76 | dwGetTick=GetTickCount(); | 76 | dwGetTick=GetTickCount(); |
77 | { | 77 | { |
78 | z_stream zcpr; | 78 | z_stream zcpr; |
79 | int ret=Z_OK; | 79 | int ret=Z_OK; |
80 | long lOrigToDo = lFileSize; | 80 | long lOrigToDo = lFileSize; |
81 | long lOrigDone = 0; | 81 | long lOrigDone = 0; |
82 | int step=0; | 82 | int step=0; |
83 | memset(&zcpr,0,sizeof(z_stream)); | 83 | memset(&zcpr,0,sizeof(z_stream)); |
84 | deflateInit(&zcpr,cprLevel); | 84 | deflateInit(&zcpr,cprLevel); |
85 | 85 | ||
86 | zcpr.next_in = FilePtr; | 86 | zcpr.next_in = FilePtr; |
87 | zcpr.next_out = CprPtr; | 87 | zcpr.next_out = CprPtr; |
88 | 88 | ||
89 | 89 | ||
90 | do | 90 | do |
91 | { | 91 | { |
92 | long all_read_before = zcpr.total_in; | 92 | long all_read_before = zcpr.total_in; |
93 | zcpr.avail_in = min(lOrigToDo,BlockSizeCompress); | 93 | zcpr.avail_in = min(lOrigToDo,BlockSizeCompress); |
94 | zcpr.avail_out = BlockSizeCompress; | 94 | zcpr.avail_out = BlockSizeCompress; |
95 | ret=deflate(&zcpr,(zcpr.avail_in==lOrigToDo) ? Z_FINISH : Z_SYNC_FLUSH); | 95 | ret=deflate(&zcpr,(zcpr.avail_in==lOrigToDo) ? Z_FINISH : Z_SYNC_FLUSH); |
96 | lOrigDone += (zcpr.total_in-all_read_before); | 96 | lOrigDone += (zcpr.total_in-all_read_before); |
97 | lOrigToDo -= (zcpr.total_in-all_read_before); | 97 | lOrigToDo -= (zcpr.total_in-all_read_before); |
98 | step++; | 98 | step++; |
99 | } while (ret==Z_OK); | 99 | } while (ret==Z_OK); |
100 | 100 | ||
101 | lSizeCpr=zcpr.total_out; | 101 | lSizeCpr=zcpr.total_out; |
102 | deflateEnd(&zcpr); | 102 | deflateEnd(&zcpr); |
103 | dwGetTick=GetTickCount()-dwGetTick; | 103 | dwGetTick=GetTickCount()-dwGetTick; |
104 | printf("total compress size = %u, in %u step\n",lSizeCpr,step); | 104 | printf("total compress size = %u, in %u step\n",lSizeCpr,step); |
105 | printf("time = %u msec = %f sec\n\n",dwGetTick,dwGetTick/(double)1000.); | 105 | printf("time = %u msec = %f sec\n\n",dwGetTick,dwGetTick/(double)1000.); |
106 | } | 106 | } |
107 | 107 | ||
108 | dwGetTick=GetTickCount(); | 108 | dwGetTick=GetTickCount(); |
109 | { | 109 | { |
110 | z_stream zcpr; | 110 | z_stream zcpr; |
111 | int ret=Z_OK; | 111 | int ret=Z_OK; |
112 | long lOrigToDo = lSizeCpr; | 112 | long lOrigToDo = lSizeCpr; |
113 | long lOrigDone = 0; | 113 | long lOrigDone = 0; |
114 | int step=0; | 114 | int step=0; |
115 | memset(&zcpr,0,sizeof(z_stream)); | 115 | memset(&zcpr,0,sizeof(z_stream)); |
116 | inflateInit(&zcpr); | 116 | inflateInit(&zcpr); |
117 | 117 | ||
118 | zcpr.next_in = CprPtr; | 118 | zcpr.next_in = CprPtr; |
119 | zcpr.next_out = UncprPtr; | 119 | zcpr.next_out = UncprPtr; |
120 | 120 | ||
121 | 121 | ||
122 | do | 122 | do |
123 | { | 123 | { |
124 | long all_read_before = zcpr.total_in; | 124 | long all_read_before = zcpr.total_in; |
125 | zcpr.avail_in = min(lOrigToDo,BlockSizeUncompress); | 125 | zcpr.avail_in = min(lOrigToDo,BlockSizeUncompress); |
126 | zcpr.avail_out = BlockSizeUncompress; | 126 | zcpr.avail_out = BlockSizeUncompress; |
127 | ret=inflate(&zcpr,Z_SYNC_FLUSH); | 127 | ret=inflate(&zcpr,Z_SYNC_FLUSH); |
128 | lOrigDone += (zcpr.total_in-all_read_before); | 128 | lOrigDone += (zcpr.total_in-all_read_before); |
129 | lOrigToDo -= (zcpr.total_in-all_read_before); | 129 | lOrigToDo -= (zcpr.total_in-all_read_before); |
130 | step++; | 130 | step++; |
131 | } while (ret==Z_OK); | 131 | } while (ret==Z_OK); |
132 | 132 | ||
133 | lSizeUncpr=zcpr.total_out; | 133 | lSizeUncpr=zcpr.total_out; |
134 | inflateEnd(&zcpr); | 134 | inflateEnd(&zcpr); |
135 | dwGetTick=GetTickCount()-dwGetTick; | 135 | dwGetTick=GetTickCount()-dwGetTick; |
136 | printf("total uncompress size = %u, in %u step\n",lSizeUncpr,step); | 136 | printf("total uncompress size = %u, in %u step\n",lSizeUncpr,step); |
137 | printf("time = %u msec = %f sec\n\n",dwGetTick,dwGetTick/(double)1000.); | 137 | printf("time = %u msec = %f sec\n\n",dwGetTick,dwGetTick/(double)1000.); |
138 | } | 138 | } |
139 | 139 | ||
140 | if (lSizeUncpr==lFileSize) | 140 | if (lSizeUncpr==lFileSize) |
141 | { | 141 | { |
142 | if (memcmp(FilePtr,UncprPtr,lFileSize)==0) | 142 | if (memcmp(FilePtr,UncprPtr,lFileSize)==0) |
143 | printf("compare ok\n"); | 143 | printf("compare ok\n"); |
144 | 144 | ||
145 | } | 145 | } |
146 | 146 | ||
147 | return 0; | 147 | return 0; |
148 | 148 | ||
149 | } | 149 | } |
diff --git a/contrib/testzlib/testzlib.vcproj b/contrib/testzlib/testzlib.vcproj index 5165301..bd9b39b 100644 --- a/contrib/testzlib/testzlib.vcproj +++ b/contrib/testzlib/testzlib.vcproj | |||
@@ -19,7 +19,7 @@ | |||
19 | <Tool | 19 | <Tool |
20 | Name="VCCLCompilerTool" | 20 | Name="VCCLCompilerTool" |
21 | Optimization="0" | 21 | Optimization="0" |
22 | PreprocessorDefinitions="WIN32;ZLIB_DLL;_DEBUG;_CONSOLE" | 22 | PreprocessorDefinitions="WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE" |
23 | MinimalRebuild="TRUE" | 23 | MinimalRebuild="TRUE" |
24 | BasicRuntimeChecks="3" | 24 | BasicRuntimeChecks="3" |
25 | RuntimeLibrary="5" | 25 | RuntimeLibrary="5" |
@@ -63,7 +63,7 @@ | |||
63 | Optimization="2" | 63 | Optimization="2" |
64 | InlineFunctionExpansion="1" | 64 | InlineFunctionExpansion="1" |
65 | OmitFramePointers="TRUE" | 65 | OmitFramePointers="TRUE" |
66 | PreprocessorDefinitions="WIN32;ZLIB_DLL;NDEBUG;_CONSOLE" | 66 | PreprocessorDefinitions="WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE" |
67 | StringPooling="TRUE" | 67 | StringPooling="TRUE" |
68 | RuntimeLibrary="4" | 68 | RuntimeLibrary="4" |
69 | EnableFunctionLevelLinking="TRUE" | 69 | EnableFunctionLevelLinking="TRUE" |
@@ -116,7 +116,7 @@ | |||
116 | Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> | 116 | Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> |
117 | </Filter> | 117 | </Filter> |
118 | <File | 118 | <File |
119 | RelativePath="zlib.lib"> | 119 | RelativePath="zlibwapi.lib"> |
120 | </File> | 120 | </File> |
121 | </Files> | 121 | </Files> |
122 | <Globals> | 122 | <Globals> |
diff --git a/contrib/untgz/Makefile b/contrib/untgz/Makefile index 409b4bd..b54266f 100644 --- a/contrib/untgz/Makefile +++ b/contrib/untgz/Makefile | |||
@@ -1,14 +1,14 @@ | |||
1 | CC=cc | 1 | CC=cc |
2 | CFLAGS=-g | 2 | CFLAGS=-g |
3 | 3 | ||
4 | untgz: untgz.o ../../libz.a | 4 | untgz: untgz.o ../../libz.a |
5 | $(CC) $(CFLAGS) -o untgz untgz.o -L../.. -lz | 5 | $(CC) $(CFLAGS) -o untgz untgz.o -L../.. -lz |
6 | 6 | ||
7 | untgz.o: untgz.c ../../zlib.h | 7 | untgz.o: untgz.c ../../zlib.h |
8 | $(CC) $(CFLAGS) -c -I../.. untgz.c | 8 | $(CC) $(CFLAGS) -c -I../.. untgz.c |
9 | 9 | ||
10 | ../../libz.a: | 10 | ../../libz.a: |
11 | cd ../..; make | 11 | cd ../..; ./configure; make |
12 | 12 | ||
13 | clean: | 13 | clean: |
14 | rm -f untgz untgz.o *~ | 14 | rm -f untgz untgz.o *~ |
diff --git a/contrib/untgz/Makefile.msc b/contrib/untgz/Makefile.msc new file mode 100644 index 0000000..77b8602 --- /dev/null +++ b/contrib/untgz/Makefile.msc | |||
@@ -0,0 +1,17 @@ | |||
1 | CC=cl | ||
2 | CFLAGS=-MD | ||
3 | |||
4 | untgz.exe: untgz.obj ..\..\zlib.lib | ||
5 | $(CC) $(CFLAGS) untgz.obj ..\..\zlib.lib | ||
6 | |||
7 | untgz.obj: untgz.c ..\..\zlib.h | ||
8 | $(CC) $(CFLAGS) -c -I..\.. untgz.c | ||
9 | |||
10 | ..\..\zlib.lib: | ||
11 | cd ..\.. | ||
12 | $(MAKE) -f win32\makefile.msc | ||
13 | cd contrib\untgz | ||
14 | |||
15 | clean: | ||
16 | -del untgz.obj | ||
17 | -del untgz.exe | ||
diff --git a/contrib/untgz/makefile.w32 b/contrib/untgz/makefile.w32 deleted file mode 100644 index c99dc28..0000000 --- a/contrib/untgz/makefile.w32 +++ /dev/null | |||
@@ -1,63 +0,0 @@ | |||
1 | # Makefile for zlib. Modified for mingw32 | ||
2 | # For conditions of distribution and use, see copyright notice in zlib.h | ||
3 | |||
4 | # To compile, | ||
5 | # | ||
6 | # make -fmakefile.w32 | ||
7 | # | ||
8 | |||
9 | CC=gcc | ||
10 | |||
11 | # Generate dependencies (see end of the file) | ||
12 | |||
13 | CPPFLAGS=-MMD | ||
14 | |||
15 | #CFLAGS=-MMD -O | ||
16 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 | ||
17 | #CFLAGS=-MMD -g -DDEBUG | ||
18 | CFLAGS=-O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ | ||
19 | -Wstrict-prototypes -Wmissing-prototypes | ||
20 | |||
21 | # If cp.exe is not found, replace with copy /Y . | ||
22 | CP=cp -f | ||
23 | |||
24 | # The default value of RM is "rm -f." | ||
25 | # If "rm.exe" is not found, uncomment: | ||
26 | # RM=del | ||
27 | |||
28 | LD=gcc | ||
29 | LDLIBS=-L. -lz | ||
30 | LDFLAGS=-s | ||
31 | |||
32 | |||
33 | INCL=zlib.h zconf.h | ||
34 | LIBS=libz.a | ||
35 | |||
36 | AR=ar rcs | ||
37 | |||
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 \ | ||
40 | inffast.o | ||
41 | |||
42 | TEST_OBJS = minigzip.o untgz.o | ||
43 | |||
44 | all: minigzip.exe untgz.exe | ||
45 | |||
46 | rebuild: clean all | ||
47 | |||
48 | libz.a: $(OBJS) | ||
49 | $(AR) $@ $(OBJS) | ||
50 | |||
51 | %.exe : %.o $(LIBS) | ||
52 | $(LD) $(LDFLAGS) -o $@ $< $(LDLIBS) | ||
53 | |||
54 | .PHONY : clean | ||
55 | |||
56 | clean: | ||
57 | $(RM) *.d *.o *.exe libz.a foo.gz | ||
58 | |||
59 | DEPS := $(wildcard *.d) | ||
60 | ifneq ($(DEPS),) | ||
61 | include $(DEPS) | ||
62 | endif | ||
63 | |||
diff --git a/contrib/untgz/untgz.c b/contrib/untgz/untgz.c index 4a431ff..478d744 100644 --- a/contrib/untgz/untgz.c +++ b/contrib/untgz/untgz.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include "zlib.h" | 21 | #include "zlib.h" |
22 | 22 | ||
23 | #ifdef WIN32 | 23 | #ifdef WIN32 |
24 | #include <windows.h> | ||
24 | # ifndef F_OK | 25 | # ifndef F_OK |
25 | # define F_OK (0) | 26 | # define F_OK (0) |
26 | # endif | 27 | # endif |
@@ -39,37 +40,37 @@ | |||
39 | 40 | ||
40 | /* Values used in typeflag field. */ | 41 | /* Values used in typeflag field. */ |
41 | 42 | ||
42 | #define REGTYPE '0' /* regular file */ | 43 | #define REGTYPE '0' /* regular file */ |
43 | #define AREGTYPE '\0' /* regular file */ | 44 | #define AREGTYPE '\0' /* regular file */ |
44 | #define LNKTYPE '1' /* link */ | 45 | #define LNKTYPE '1' /* link */ |
45 | #define SYMTYPE '2' /* reserved */ | 46 | #define SYMTYPE '2' /* reserved */ |
46 | #define CHRTYPE '3' /* character special */ | 47 | #define CHRTYPE '3' /* character special */ |
47 | #define BLKTYPE '4' /* block special */ | 48 | #define BLKTYPE '4' /* block special */ |
48 | #define DIRTYPE '5' /* directory */ | 49 | #define DIRTYPE '5' /* directory */ |
49 | #define FIFOTYPE '6' /* FIFO special */ | 50 | #define FIFOTYPE '6' /* FIFO special */ |
50 | #define CONTTYPE '7' /* reserved */ | 51 | #define CONTTYPE '7' /* reserved */ |
51 | 52 | ||
52 | #define BLOCKSIZE 512 | 53 | #define BLOCKSIZE 512 |
53 | 54 | ||
54 | struct tar_header | 55 | struct tar_header |
55 | { /* byte offset */ | 56 | { /* byte offset */ |
56 | char name[100]; /* 0 */ | 57 | char name[100]; /* 0 */ |
57 | char mode[8]; /* 100 */ | 58 | char mode[8]; /* 100 */ |
58 | char uid[8]; /* 108 */ | 59 | char uid[8]; /* 108 */ |
59 | char gid[8]; /* 116 */ | 60 | char gid[8]; /* 116 */ |
60 | char size[12]; /* 124 */ | 61 | char size[12]; /* 124 */ |
61 | char mtime[12]; /* 136 */ | 62 | char mtime[12]; /* 136 */ |
62 | char chksum[8]; /* 148 */ | 63 | char chksum[8]; /* 148 */ |
63 | char typeflag; /* 156 */ | 64 | char typeflag; /* 156 */ |
64 | char linkname[100]; /* 157 */ | 65 | char linkname[100]; /* 157 */ |
65 | char magic[6]; /* 257 */ | 66 | char magic[6]; /* 257 */ |
66 | char version[2]; /* 263 */ | 67 | char version[2]; /* 263 */ |
67 | char uname[32]; /* 265 */ | 68 | char uname[32]; /* 265 */ |
68 | char gname[32]; /* 297 */ | 69 | char gname[32]; /* 297 */ |
69 | char devmajor[8]; /* 329 */ | 70 | char devmajor[8]; /* 329 */ |
70 | char devminor[8]; /* 337 */ | 71 | char devminor[8]; /* 337 */ |
71 | char prefix[155]; /* 345 */ | 72 | char prefix[155]; /* 345 */ |
72 | /* 500 */ | 73 | /* 500 */ |
73 | }; | 74 | }; |
74 | 75 | ||
75 | union tar_buffer { | 76 | union tar_buffer { |
@@ -79,42 +80,43 @@ union tar_buffer { | |||
79 | 80 | ||
80 | enum { TGZ_EXTRACT = 0, TGZ_LIST }; | 81 | enum { TGZ_EXTRACT = 0, TGZ_LIST }; |
81 | 82 | ||
82 | static char *TGZfname OF((const char *)); | 83 | static char *TGZfname OF((const char *)); |
83 | void TGZnotfound OF((const char *)); | 84 | void TGZnotfound OF((const char *)); |
84 | 85 | ||
85 | int getoct OF((char *, int)); | 86 | int getoct OF((char *, int)); |
86 | char *strtime OF((time_t *)); | 87 | char *strtime OF((time_t *)); |
87 | int ExprMatch OF((char *,char *)); | 88 | int setftime OF((char *, time_t)); |
89 | int ExprMatch OF((char *, char *)); | ||
88 | 90 | ||
89 | int makedir OF((char *)); | 91 | int makedir OF((char *)); |
90 | int matchname OF((int,int,char **,char *)); | 92 | int matchname OF((int, int, char **, char *)); |
91 | 93 | ||
92 | void error OF((const char *)); | 94 | void error OF((const char *)); |
93 | int tar OF((gzFile, int, int, int, char **)); | 95 | int tar OF((gzFile, int, int, int, char **)); |
94 | 96 | ||
95 | void help OF((int)); | 97 | void help OF((int)); |
96 | int main OF((int, char **)); | 98 | int main OF((int, char **)); |
97 | 99 | ||
98 | char *prog; | 100 | char *prog; |
99 | 101 | ||
100 | /* This will give a benign warning */ | 102 | /* This will give a benign warning */ |
101 | 103 | ||
102 | static char *TGZprefix[] = { "\0", ".tgz", ".tar.gz", ".tar", NULL }; | 104 | static char *TGZsuffix[] = { "\0", ".tar", ".tar.gz", ".taz", ".tgz", NULL }; |
103 | 105 | ||
104 | /* Return the real name of the TGZ archive */ | 106 | /* Return the real name of the TGZ archive */ |
105 | /* or NULL if it does not exist. */ | 107 | /* or NULL if it does not exist. */ |
106 | 108 | ||
107 | static char *TGZfname OF((const char *fname)) | 109 | static char *TGZfname (const char *fname) |
108 | { | 110 | { |
109 | static char buffer[1024]; | 111 | static char buffer[1024]; |
110 | int origlen,i; | 112 | int origlen,i; |
111 | 113 | ||
112 | strcpy(buffer,fname); | 114 | strcpy(buffer,fname); |
113 | origlen = strlen(buffer); | 115 | origlen = strlen(buffer); |
114 | 116 | ||
115 | for (i=0; TGZprefix[i]; i++) | 117 | for (i=0; TGZsuffix[i]; i++) |
116 | { | 118 | { |
117 | strcpy(buffer+origlen,TGZprefix[i]); | 119 | strcpy(buffer+origlen,TGZsuffix[i]); |
118 | if (access(buffer,F_OK) == 0) | 120 | if (access(buffer,F_OK) == 0) |
119 | return buffer; | 121 | return buffer; |
120 | } | 122 | } |
@@ -123,33 +125,33 @@ static char *TGZfname OF((const char *fname)) | |||
123 | 125 | ||
124 | /* error message for the filename */ | 126 | /* error message for the filename */ |
125 | 127 | ||
126 | void TGZnotfound OF((const char *fname)) | 128 | void TGZnotfound (const char *fname) |
127 | { | 129 | { |
128 | int i; | 130 | int i; |
129 | 131 | ||
130 | fprintf(stderr,"%s : couldn't find ",prog); | 132 | fprintf(stderr,"%s : couldn't find ",prog); |
131 | for (i=0;TGZprefix[i];i++) | 133 | for (i=0;TGZsuffix[i];i++) |
132 | fprintf(stderr,(TGZprefix[i+1]) ? "%s%s, " : "or %s%s\n", | 134 | fprintf(stderr,(TGZsuffix[i+1]) ? "%s%s, " : "or %s%s\n", |
133 | fname, | 135 | fname, |
134 | TGZprefix[i]); | 136 | TGZsuffix[i]); |
135 | exit(1); | 137 | exit(1); |
136 | } | 138 | } |
137 | 139 | ||
138 | 140 | ||
139 | /* help functions */ | 141 | /* help functions */ |
140 | 142 | ||
141 | int getoct(char *p,int width) | 143 | int getoct (char *p,int width) |
142 | { | 144 | { |
143 | int result = 0; | 145 | int result = 0; |
144 | char c; | 146 | char c; |
145 | 147 | ||
146 | while (width --) | 148 | while (width --) |
147 | { | 149 | { |
148 | c = *p++; | 150 | c = *p++; |
149 | if (c == ' ') | 151 | if (c == ' ') |
150 | continue; | 152 | continue; |
151 | if (c == 0) | 153 | if (c == 0) |
152 | break; | 154 | break; |
153 | result = result * 8 + (c - '0'); | 155 | result = result * 8 + (c - '0'); |
154 | } | 156 | } |
155 | return result; | 157 | return result; |
@@ -162,9 +164,49 @@ char *strtime (time_t *t) | |||
162 | 164 | ||
163 | local = localtime(t); | 165 | local = localtime(t); |
164 | sprintf(result,"%2d/%02d/%4d %02d:%02d:%02d", | 166 | sprintf(result,"%2d/%02d/%4d %02d:%02d:%02d", |
165 | local->tm_mday, local->tm_mon+1, local->tm_year+1900, | 167 | local->tm_mday, local->tm_mon+1, local->tm_year+1900, |
166 | local->tm_hour, local->tm_min, local->tm_sec); | 168 | local->tm_hour, local->tm_min, local->tm_sec); |
169 | return result; | ||
170 | } | ||
171 | |||
172 | int setftime (char *fname,time_t ftime) | ||
173 | { | ||
174 | #ifdef WIN32 | ||
175 | SYSTEMTIME st; | ||
176 | FILETIME locft, modft; | ||
177 | struct tm *loctm; | ||
178 | HANDLE hFile; | ||
179 | int result; | ||
180 | |||
181 | loctm = localtime(&ftime); | ||
182 | if (loctm == NULL) | ||
183 | return -1; | ||
184 | |||
185 | st.wYear = (WORD)loctm->tm_year + 1900; | ||
186 | st.wMonth = (WORD)loctm->tm_mon + 1; | ||
187 | st.wDayOfWeek = (WORD)loctm->tm_wday; | ||
188 | st.wDay = (WORD)loctm->tm_mday; | ||
189 | st.wHour = (WORD)loctm->tm_hour; | ||
190 | st.wMinute = (WORD)loctm->tm_min; | ||
191 | st.wSecond = (WORD)loctm->tm_sec; | ||
192 | st.wMilliseconds = 0; | ||
193 | if (!SystemTimeToFileTime(&st, &locft) || | ||
194 | !LocalFileTimeToFileTime(&locft, &modft)) | ||
195 | return -1; | ||
196 | |||
197 | hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE, | ||
198 | 0, NULL, OPEN_EXISTING, 0, 0); | ||
199 | if (hFile == INVALID_HANDLE_VALUE) | ||
200 | return -1; | ||
201 | result = SetFileTime(hFile, NULL, NULL, &modft) ? 0 : -1; | ||
202 | CloseHandle(hFile); | ||
167 | return result; | 203 | return result; |
204 | #else | ||
205 | struct utimbuf settime; | ||
206 | |||
207 | settime.actime = settime.modtime = ftime; | ||
208 | return utime(fname,&settime); | ||
209 | #endif | ||
168 | } | 210 | } |
169 | 211 | ||
170 | 212 | ||
@@ -172,35 +214,35 @@ char *strtime (time_t *t) | |||
172 | 214 | ||
173 | #define ISSPECIAL(c) (((c) == '*') || ((c) == '/')) | 215 | #define ISSPECIAL(c) (((c) == '*') || ((c) == '/')) |
174 | 216 | ||
175 | int ExprMatch(char *string,char *expr) | 217 | int ExprMatch (char *string,char *expr) |
176 | { | 218 | { |
177 | while (1) | 219 | while (1) |
178 | { | 220 | { |
179 | if (ISSPECIAL(*expr)) | 221 | if (ISSPECIAL(*expr)) |
180 | { | 222 | { |
181 | if (*expr == '/') | 223 | if (*expr == '/') |
182 | { | 224 | { |
183 | if (*string != '\\' && *string != '/') | 225 | if (*string != '\\' && *string != '/') |
184 | return 0; | 226 | return 0; |
185 | string ++; expr++; | 227 | string ++; expr++; |
186 | } | 228 | } |
187 | else if (*expr == '*') | 229 | else if (*expr == '*') |
188 | { | 230 | { |
189 | if (*expr ++ == 0) | 231 | if (*expr ++ == 0) |
190 | return 1; | 232 | return 1; |
191 | while (*++string != *expr) | 233 | while (*++string != *expr) |
192 | if (*string == 0) | 234 | if (*string == 0) |
193 | return 0; | 235 | return 0; |
194 | } | 236 | } |
195 | } | 237 | } |
196 | else | 238 | else |
197 | { | 239 | { |
198 | if (*string != *expr) | 240 | if (*string != *expr) |
199 | return 0; | 241 | return 0; |
200 | if (*expr++ == 0) | 242 | if (*expr++ == 0) |
201 | return 1; | 243 | return 1; |
202 | string++; | 244 | string++; |
203 | } | 245 | } |
204 | } | 246 | } |
205 | } | 247 | } |
206 | 248 | ||
@@ -216,7 +258,7 @@ int makedir (char *newdir) | |||
216 | char *buffer = strdup(newdir); | 258 | char *buffer = strdup(newdir); |
217 | char *p; | 259 | char *p; |
218 | int len = strlen(buffer); | 260 | int len = strlen(buffer); |
219 | 261 | ||
220 | if (len <= 0) { | 262 | if (len <= 0) { |
221 | free(buffer); | 263 | free(buffer); |
222 | return 0; | 264 | return 0; |
@@ -234,19 +276,19 @@ int makedir (char *newdir) | |||
234 | while (1) | 276 | while (1) |
235 | { | 277 | { |
236 | char hold; | 278 | char hold; |
237 | 279 | ||
238 | while(*p && *p != '\\' && *p != '/') | 280 | while(*p && *p != '\\' && *p != '/') |
239 | p++; | 281 | p++; |
240 | hold = *p; | 282 | hold = *p; |
241 | *p = 0; | 283 | *p = 0; |
242 | if ((mkdir(buffer, 0775) == -1) && (errno == ENOENT)) | 284 | if ((mkdir(buffer, 0775) == -1) && (errno == ENOENT)) |
243 | { | 285 | { |
244 | fprintf(stderr,"%s: couldn't create directory %s\n",prog,buffer); | 286 | fprintf(stderr,"%s: couldn't create directory %s\n",prog,buffer); |
245 | free(buffer); | 287 | free(buffer); |
246 | return 0; | 288 | return 0; |
247 | } | 289 | } |
248 | if (hold == 0) | 290 | if (hold == 0) |
249 | break; | 291 | break; |
250 | *p++ = hold; | 292 | *p++ = hold; |
251 | } | 293 | } |
252 | free(buffer); | 294 | free(buffer); |
@@ -255,7 +297,7 @@ int makedir (char *newdir) | |||
255 | 297 | ||
256 | int matchname (int arg,int argc,char **argv,char *fname) | 298 | int matchname (int arg,int argc,char **argv,char *fname) |
257 | { | 299 | { |
258 | if (arg == argc) /* no arguments given (untgz tgzarchive) */ | 300 | if (arg == argc) /* no arguments given (untgz tgzarchive) */ |
259 | return 1; | 301 | return 1; |
260 | 302 | ||
261 | while (arg < argc) | 303 | while (arg < argc) |
@@ -278,144 +320,111 @@ int tar (gzFile in,int action,int arg,int argc,char **argv) | |||
278 | FILE *outfile = NULL; | 320 | FILE *outfile = NULL; |
279 | char fname[BLOCKSIZE]; | 321 | char fname[BLOCKSIZE]; |
280 | time_t tartime; | 322 | time_t tartime; |
281 | 323 | ||
282 | if (action == TGZ_LIST) | 324 | if (action == TGZ_LIST) |
283 | printf(" day time size file\n" | 325 | printf(" day time size file\n" |
284 | " ---------- -------- --------- -------------------------------------\n"); | 326 | " ---------- -------- --------- -------------------------------------\n"); |
285 | while (1) | 327 | while (1) |
286 | { | 328 | { |
287 | len = gzread(in, &buffer, BLOCKSIZE); | 329 | len = gzread(in, &buffer, BLOCKSIZE); |
288 | if (len < 0) | 330 | if (len < 0) |
289 | error (gzerror(in, &err)); | 331 | error (gzerror(in, &err)); |
290 | /* | 332 | /* |
291 | * Always expect complete blocks to process | 333 | * Always expect complete blocks to process |
292 | * the tar information. | 334 | * the tar information. |
293 | */ | 335 | */ |
294 | if (len != BLOCKSIZE) | 336 | if (len != BLOCKSIZE) |
295 | error("gzread: incomplete block read"); | 337 | error("gzread: incomplete block read"); |
296 | 338 | ||
297 | /* | 339 | /* |
298 | * If we have to get a tar header | 340 | * If we have to get a tar header |
299 | */ | 341 | */ |
300 | if (getheader == 1) | 342 | if (getheader == 1) |
301 | { | 343 | { |
302 | /* | 344 | /* |
303 | * if we met the end of the tar | 345 | * if we met the end of the tar |
304 | * or the end-of-tar block, | 346 | * or the end-of-tar block, |
305 | * we are done | 347 | * we are done |
306 | */ | 348 | */ |
307 | if ((len == 0) || (buffer.header.name[0]== 0)) break; | 349 | if ((len == 0) || (buffer.header.name[0]== 0)) break; |
308 | 350 | ||
309 | tartime = (time_t)getoct(buffer.header.mtime,12); | 351 | tartime = (time_t)getoct(buffer.header.mtime,12); |
310 | strcpy(fname,buffer.header.name); | 352 | strcpy(fname,buffer.header.name); |
311 | 353 | ||
312 | switch (buffer.header.typeflag) | 354 | switch (buffer.header.typeflag) |
313 | { | 355 | { |
314 | case DIRTYPE: | 356 | case DIRTYPE: |
315 | if (action == TGZ_LIST) | 357 | if (action == TGZ_LIST) |
316 | printf(" %s <dir> %s\n",strtime(&tartime),fname); | 358 | printf(" %s <dir> %s\n",strtime(&tartime),fname); |
317 | if (action == TGZ_EXTRACT) | 359 | if (action == TGZ_EXTRACT) |
318 | makedir(fname); | 360 | makedir(fname); |
319 | break; | 361 | break; |
320 | case REGTYPE: | 362 | case REGTYPE: |
321 | case AREGTYPE: | 363 | case AREGTYPE: |
322 | remaining = getoct(buffer.header.size,12); | 364 | remaining = getoct(buffer.header.size,12); |
323 | if (action == TGZ_LIST) | 365 | if (action == TGZ_LIST) |
324 | printf(" %s %9d %s\n",strtime(&tartime),remaining,fname); | 366 | printf(" %s %9d %s\n",strtime(&tartime),remaining,fname); |
325 | if (action == TGZ_EXTRACT) | 367 | if (action == TGZ_EXTRACT) |
326 | { | 368 | { |
327 | if ((remaining) && (matchname(arg,argc,argv,fname))) | 369 | if ((remaining) && (matchname(arg,argc,argv,fname))) |
328 | { | 370 | { |
329 | outfile = fopen(fname,"wb"); | 371 | outfile = fopen(fname,"wb"); |
330 | if (outfile == NULL) { | 372 | if (outfile == NULL) { |
331 | /* try creating directory */ | 373 | /* try creating directory */ |
332 | char *p = strrchr(fname, '/'); | 374 | char *p = strrchr(fname, '/'); |
333 | if (p != NULL) { | 375 | if (p != NULL) { |
334 | *p = '\0'; | 376 | *p = '\0'; |
335 | makedir(fname); | 377 | makedir(fname); |
336 | *p = '/'; | 378 | *p = '/'; |
337 | outfile = fopen(fname,"wb"); | 379 | outfile = fopen(fname,"wb"); |
338 | } | 380 | } |
339 | } | 381 | } |
340 | fprintf(stderr, | 382 | fprintf(stderr, |
341 | "%s %s\n", | 383 | "%s %s\n", |
342 | (outfile) ? "Extracting" : "Couldn't create", | 384 | (outfile) ? "Extracting" : "Couldn't create", |
343 | fname); | 385 | fname); |
344 | } | 386 | } |
345 | else | 387 | else |
346 | outfile = NULL; | 388 | outfile = NULL; |
347 | } | 389 | } |
348 | /* | 390 | /* |
349 | * could have no contents | 391 | * could have no contents |
350 | */ | 392 | */ |
351 | getheader = (remaining) ? 0 : 1; | 393 | getheader = (remaining) ? 0 : 1; |
352 | break; | 394 | break; |
353 | default: | 395 | default: |
354 | if (action == TGZ_LIST) | 396 | if (action == TGZ_LIST) |
355 | printf(" %s <---> %s\n",strtime(&tartime),fname); | 397 | printf(" %s <---> %s\n",strtime(&tartime),fname); |
356 | break; | 398 | break; |
357 | } | 399 | } |
358 | } | 400 | } |
359 | else | 401 | else |
360 | { | 402 | { |
361 | unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining; | 403 | unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining; |
362 | 404 | ||
363 | if ((action == TGZ_EXTRACT) && (outfile != NULL)) | 405 | if ((action == TGZ_EXTRACT) && (outfile != NULL)) |
364 | { | 406 | { |
365 | if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes) | 407 | if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes) |
366 | { | 408 | { |
367 | fprintf(stderr,"%s : error writing %s skipping...\n",prog,fname); | 409 | fprintf(stderr,"%s : error writing %s skipping...\n",prog,fname); |
368 | fclose(outfile); | 410 | fclose(outfile); |
369 | unlink(fname); | 411 | unlink(fname); |
370 | } | 412 | } |
371 | } | 413 | } |
372 | remaining -= bytes; | 414 | remaining -= bytes; |
373 | if (remaining == 0) | 415 | if (remaining == 0) |
374 | { | 416 | { |
375 | getheader = 1; | 417 | getheader = 1; |
376 | if ((action == TGZ_EXTRACT) && (outfile != NULL)) | 418 | if ((action == TGZ_EXTRACT) && (outfile != NULL)) |
377 | { | 419 | { |
378 | #ifdef WIN32 | 420 | fclose(outfile); |
379 | HANDLE hFile; | 421 | outfile = NULL; |
380 | FILETIME ftm,ftLocal; | 422 | setftime(fname,tartime); |
381 | SYSTEMTIME st; | 423 | } |
382 | struct tm localt; | 424 | } |
383 | 425 | } | |
384 | fclose(outfile); | ||
385 | |||
386 | localt = *localtime(&tartime); | ||
387 | |||
388 | hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE, | ||
389 | 0, NULL, OPEN_EXISTING, 0, NULL); | ||
390 | |||
391 | st.wYear = (WORD)localt.tm_year+1900; | ||
392 | st.wMonth = (WORD)localt.tm_mon; | ||
393 | st.wDayOfWeek = (WORD)localt.tm_wday; | ||
394 | st.wDay = (WORD)localt.tm_mday; | ||
395 | st.wHour = (WORD)localt.tm_hour; | ||
396 | st.wMinute = (WORD)localt.tm_min; | ||
397 | st.wSecond = (WORD)localt.tm_sec; | ||
398 | st.wMilliseconds = 0; | ||
399 | SystemTimeToFileTime(&st,&ftLocal); | ||
400 | LocalFileTimeToFileTime(&ftLocal,&ftm); | ||
401 | SetFileTime(hFile,&ftm,NULL,&ftm); | ||
402 | CloseHandle(hFile); | ||
403 | |||
404 | outfile = NULL; | ||
405 | #else | ||
406 | struct utimbuf settime; | ||
407 | |||
408 | settime.actime = settime.modtime = tartime; | ||
409 | |||
410 | fclose(outfile); | ||
411 | outfile = NULL; | ||
412 | utime(fname,&settime); | ||
413 | #endif | ||
414 | } | ||
415 | } | ||
416 | } | ||
417 | } | 426 | } |
418 | 427 | ||
419 | if (gzclose(in) != Z_OK) | 428 | if (gzclose(in) != Z_OK) |
420 | error("failed gzclose"); | 429 | error("failed gzclose"); |
421 | 430 | ||
@@ -428,12 +437,12 @@ int tar (gzFile in,int action,int arg,int argc,char **argv) | |||
428 | void help(int exitval) | 437 | void help(int exitval) |
429 | { | 438 | { |
430 | fprintf(stderr, | 439 | fprintf(stderr, |
431 | "untgz v 0.1\n" | 440 | "untgz version 0.1\n" |
432 | " an sample application of zlib 1.0.4\n\n" | 441 | " a sample application of zlib\n\n" |
433 | "Usage : untgz TGZfile to extract all files\n" | 442 | "Usage : untgz file.tgz to extract all files\n" |
434 | " untgz TGZfile fname ... to extract selected files\n" | 443 | " untgz file.tgz fname ... to extract selected files\n" |
435 | " untgz -l TGZfile to list archive contents\n" | 444 | " untgz -l file.tgz to list archive contents\n" |
436 | " untgz -h to display this help\n\n"); | 445 | " untgz -h to display this help\n\n"); |
437 | exit(exitval); | 446 | exit(exitval); |
438 | } | 447 | } |
439 | 448 | ||
@@ -446,50 +455,50 @@ void error(const char *msg) | |||
446 | 455 | ||
447 | /* ====================================================================== */ | 456 | /* ====================================================================== */ |
448 | 457 | ||
449 | int _CRT_glob = 0; /* disable globbing of the arguments */ | 458 | int _CRT_glob = 0; /* disable globbing of the arguments */ |
450 | 459 | ||
451 | int main(int argc,char **argv) | 460 | int main(int argc,char **argv) |
452 | { | 461 | { |
453 | int action = TGZ_EXTRACT; | 462 | int action = TGZ_EXTRACT; |
454 | int arg = 1; | 463 | int arg = 1; |
455 | char *TGZfile; | 464 | char *TGZfile; |
456 | gzFile *f; | 465 | gzFile *f; |
457 | 466 | ||
458 | 467 | ||
459 | prog = strrchr(argv[0],'\\'); | 468 | prog = strrchr(argv[0],'\\'); |
460 | if (prog == NULL) | 469 | if (prog == NULL) |
461 | { | 470 | { |
462 | prog = strrchr(argv[0],'/'); | 471 | prog = strrchr(argv[0],'/'); |
463 | if (prog == NULL) | 472 | if (prog == NULL) |
464 | { | 473 | { |
465 | prog = strrchr(argv[0],':'); | 474 | prog = strrchr(argv[0],':'); |
466 | if (prog == NULL) | 475 | if (prog == NULL) |
467 | prog = argv[0]; | 476 | prog = argv[0]; |
468 | else | 477 | else |
469 | prog++; | 478 | prog++; |
470 | } | 479 | } |
471 | else | 480 | else |
472 | prog++; | 481 | prog++; |
473 | } | 482 | } |
474 | else | 483 | else |
475 | prog++; | 484 | prog++; |
476 | 485 | ||
477 | if (argc == 1) | 486 | if (argc == 1) |
478 | help(0); | 487 | help(0); |
479 | 488 | ||
480 | if (strcmp(argv[arg],"-l") == 0) | 489 | if (strcmp(argv[arg],"-l") == 0) |
481 | { | 490 | { |
482 | action = TGZ_LIST; | 491 | action = TGZ_LIST; |
483 | if (argc == ++arg) | 492 | if (argc == ++arg) |
484 | help(0); | 493 | help(0); |
485 | } | 494 | } |
486 | else if (strcmp(argv[arg],"-h") == 0) | 495 | else if (strcmp(argv[arg],"-h") == 0) |
487 | { | 496 | { |
488 | help(0); | 497 | help(0); |
489 | } | 498 | } |
490 | 499 | ||
491 | if ((TGZfile = TGZfname(argv[arg])) == NULL) | 500 | if ((TGZfile = TGZfname(argv[arg])) == NULL) |
492 | TGZnotfound(argv[arg]); | 501 | TGZnotfound(argv[arg]); |
493 | 502 | ||
494 | ++arg; | 503 | ++arg; |
495 | if ((action == TGZ_LIST) && (arg != argc)) | 504 | if ((action == TGZ_LIST) && (arg != argc)) |
@@ -502,20 +511,20 @@ int main(int argc,char **argv) | |||
502 | { | 511 | { |
503 | case TGZ_LIST: | 512 | case TGZ_LIST: |
504 | case TGZ_EXTRACT: | 513 | case TGZ_EXTRACT: |
505 | f = gzopen(TGZfile,"rb"); | 514 | f = gzopen(TGZfile,"rb"); |
506 | if (f == NULL) | 515 | if (f == NULL) |
507 | { | 516 | { |
508 | fprintf(stderr,"%s: Couldn't gzopen %s\n", | 517 | fprintf(stderr,"%s: Couldn't gzopen %s\n", |
509 | prog, | 518 | prog, |
510 | TGZfile); | 519 | TGZfile); |
511 | return 1; | 520 | return 1; |
512 | } | 521 | } |
513 | exit(tar(f, action, arg, argc, argv)); | 522 | exit(tar(f, action, arg, argc, argv)); |
514 | break; | 523 | break; |
515 | 524 | ||
516 | default: | 525 | default: |
517 | error("Unknown option!"); | 526 | error("Unknown option!"); |
518 | exit(1); | 527 | exit(1); |
519 | } | 528 | } |
520 | 529 | ||
521 | return 0; | 530 | return 0; |
diff --git a/contrib/vstudio/readme.txt b/contrib/vstudio/readme.txt index c22ec34..3a4b85c 100644 --- a/contrib/vstudio/readme.txt +++ b/contrib/vstudio/readme.txt | |||
@@ -1,21 +1,54 @@ | |||
1 | For create the 16 and 32 bits DLL of Zlib 1.20 | 1 | Building instructions for the DLL versions of Zlib 1.21 |
2 | ======================================================= | ||
2 | 3 | ||
3 | For the 16 bits : | 4 | This directory contains projects that build zlib and minizip using |
4 | unzip zlib120.zip and copy file from contrib\vstudio\vc15_16 and from contrib\minizip in the same directory | 5 | Microsoft Visual C++ 7.0/7.1. |
5 | open zlib16.mak with Microsoft Visual C++ 1.52 | ||
6 | 6 | ||
7 | You don't need to build these projects yourself. You can download the | ||
8 | binaries from: | ||
9 | http://www.winimage.com/zLibDll | ||
7 | 10 | ||
8 | For the 32 bits : | 11 | More information can be found at this site. |
9 | unzip zlib120.zip and copy file from contrib\vstudio\vc70_32 and from contrib\minizip in the same directory | ||
10 | You can also need unzip http://www.winimage.com/zLibDll/crtdll.zip | ||
11 | 12 | ||
12 | If you are using x86, use target Release | ||
13 | open zlibvc.sln with Microsoft Visual C++ 7.0 (Visual Studio .net) | ||
14 | 13 | ||
14 | Build instructions | ||
15 | ------------------ | ||
16 | - Unzip zlib*.zip and copy the files from contrib\vstudio\vc7, | ||
17 | from contrib\vstudio\masmx86 and from contrib\minizip into the same | ||
18 | directory. | ||
19 | - Download the crtdll library from | ||
20 | http://www.winimage.com/zLibDll/crtdll.zip | ||
21 | Unzip crtdll.zip to extract crtdll.lib. | ||
22 | - If you are using x86, use the Release target. | ||
23 | - Open zlibvc.sln with Microsoft Visual C++ 7.0 or 7.1 | ||
24 | (Visual Studio .Net 2002 or 2003). | ||
15 | 25 | ||
16 | Note : You don't need recompile yourself. There is compiled .LIB in | ||
17 | http://www.winimage.com/zLibDll . See this page for more information | ||
18 | 26 | ||
27 | Important | ||
28 | --------- | ||
29 | - To use zlibwapi.dll in your application, you must define the | ||
30 | macro ZLIB_WINAPI when compiling your application's source files. | ||
31 | |||
32 | |||
33 | Additional notes | ||
34 | ---------------- | ||
35 | - This DLL, named zlibwapi.dll, is compatible to the old zlib.dll built | ||
36 | by Gilles Vollant from the zlib 1.1.x sources, and distributed at | ||
37 | http://www.winimage.com/zLibDll | ||
38 | It uses the WINAPI calling convention for the exported functions, and | ||
39 | includes the minizip functionality. If your application needs that | ||
40 | particular build of zlib.dll, you can rename zlibwapi.dll to zlib.dll. | ||
41 | |||
42 | - The new DLL was renamed because there exist several incompatible | ||
43 | versions of zlib.dll on the Internet. | ||
44 | |||
45 | - There is also an official DLL build of zlib, named zlib1.dll. This one | ||
46 | is exporting the functions using the CDECL convention. See the file | ||
47 | win32\DLL_FAQ.txt found in this zlib distribution. | ||
48 | |||
49 | - There used to be a ZLIB_DLL macro in zlib 1.1.x, but now this symbol | ||
50 | has a slightly different effect. To avoid compatibility problems, do | ||
51 | not define it here. | ||
19 | 52 | ||
20 | 53 | ||
21 | Gilles Vollant | 54 | Gilles Vollant |
diff --git a/contrib/vstudio/vc15_16/zlib16.def b/contrib/vstudio/vc15_16/zlib16.def deleted file mode 100644 index fdae3d4..0000000 --- a/contrib/vstudio/vc15_16/zlib16.def +++ /dev/null | |||
@@ -1,94 +0,0 @@ | |||
1 | LIBRARY "zlib" | ||
2 | |||
3 | DESCRIPTION '"""zlib data compression library"""' | ||
4 | |||
5 | EXETYPE WINDOWS | ||
6 | |||
7 | VERSION 1.21 | ||
8 | |||
9 | CODE PRELOAD MOVEABLE DISCARDABLE | ||
10 | DATA PRELOAD MOVEABLE SINGLE | ||
11 | |||
12 | |||
13 | HEAPSIZE 32768,8192 | ||
14 | |||
15 | EXPORTS | ||
16 | adler32 @1 | ||
17 | compress @2 | ||
18 | crc32 @3 | ||
19 | deflate @4 | ||
20 | deflateCopy @5 | ||
21 | deflateEnd @6 | ||
22 | deflateInit2_ @7 | ||
23 | deflateInit_ @8 | ||
24 | deflateParams @9 | ||
25 | deflateReset @10 | ||
26 | deflateSetDictionary @11 | ||
27 | gzclose @12 | ||
28 | gzdopen @13 | ||
29 | gzerror @14 | ||
30 | gzflush @15 | ||
31 | gzopen @16 | ||
32 | gzread @17 | ||
33 | gzwrite @18 | ||
34 | inflate @19 | ||
35 | inflateEnd @20 | ||
36 | inflateInit2_ @21 | ||
37 | inflateInit_ @22 | ||
38 | inflateReset @23 | ||
39 | inflateSetDictionary @24 | ||
40 | inflateSync @25 | ||
41 | uncompress @26 | ||
42 | zlibVersion @27 | ||
43 | _gzprintf @28 | ||
44 | gzputc @29 | ||
45 | gzgetc @30 | ||
46 | gzseek @31 | ||
47 | gzrewind @32 | ||
48 | gztell @33 | ||
49 | gzeof @34 | ||
50 | gzsetparams @35 | ||
51 | zError @36 | ||
52 | inflateSyncPoint @37 | ||
53 | get_crc_table @38 | ||
54 | compress2 @39 | ||
55 | gzputs @40 | ||
56 | gzgets @41 | ||
57 | inflateCopy @42 | ||
58 | inflateBackInit_ @43 | ||
59 | inflateBack @44 | ||
60 | inflateBackEnd @45 | ||
61 | compressBound @46 | ||
62 | |||
63 | unzOpen @61 | ||
64 | unzClose @62 | ||
65 | unzGetGlobalInfo @63 | ||
66 | unzGetCurrentFileInfo @64 | ||
67 | unzGoToFirstFile @65 | ||
68 | unzGoToNextFile @66 | ||
69 | unzOpenCurrentFile @67 | ||
70 | unzReadCurrentFile @68 | ||
71 | unzOpenCurrentFile3 @69 | ||
72 | unztell @70 | ||
73 | unzeof @71 | ||
74 | unzCloseCurrentFile @72 | ||
75 | unzGetGlobalComment @73 | ||
76 | unzStringFileNameCompare @74 | ||
77 | unzLocateFile @75 | ||
78 | unzGetLocalExtrafield @76 | ||
79 | unzOpen2 @77 | ||
80 | unzOpenCurrentFile2 @78 | ||
81 | unzOpenCurrentFilePassword @79 | ||
82 | |||
83 | zipOpen @80 | ||
84 | zipOpenNewFileInZip @81 | ||
85 | zipWriteInFileInZip @82 | ||
86 | zipCloseFileInZip @83 | ||
87 | zipClose @84 | ||
88 | zipOpenNewFileInZip2 @86 | ||
89 | zipCloseFileInZipRaw @87 | ||
90 | zipOpen2 @88 | ||
91 | zipOpenNewFileInZip3 @89 | ||
92 | |||
93 | unzGetFilePos @100 | ||
94 | unzGoToFilePos @101 | ||
diff --git a/contrib/vstudio/vc15_16/zlib16.mak b/contrib/vstudio/vc15_16/zlib16.mak deleted file mode 100644 index cb65885..0000000 --- a/contrib/vstudio/vc15_16/zlib16.mak +++ /dev/null | |||
@@ -1,259 +0,0 @@ | |||
1 | # Microsoft Visual C++ generated build script - Do not modify | ||
2 | |||
3 | PROJ = ZLIB16 | ||
4 | DEBUG = 0 | ||
5 | PROGTYPE = 1 | ||
6 | CALLER = | ||
7 | ARGS = | ||
8 | DLLS = | ||
9 | D_RCDEFINES = -d_DEBUG | ||
10 | R_RCDEFINES = -dNDEBUG | ||
11 | ORIGIN = MSVC | ||
12 | ORIGIN_VER = 1.00 | ||
13 | PROJPATH = c:\zlib\ | ||
14 | USEMFC = 0 | ||
15 | CC = cl | ||
16 | CPP = cl | ||
17 | CXX = cl | ||
18 | CCREATEPCHFLAG = | ||
19 | CPPCREATEPCHFLAG = | ||
20 | CUSEPCHFLAG = | ||
21 | CPPUSEPCHFLAG = | ||
22 | FIRSTC = ADLER32.C | ||
23 | FIRSTCPP = | ||
24 | RC = rc | ||
25 | CFLAGS_D_WDLL = /nologo /G2 /W3 /Zi /ALw /Od /D "_DEBUG" /D "WINDOWS" /D "ZLIB_DLL" /D "ZLIB_INTERNAL" /FR /GD /Fd"ZLIB.PDB" | ||
26 | CFLAGS_R_WDLL = /nologo /W3 /ALw /O1 /D "NDEBUG" /D "WINDOWS" /D "ZLIB_DLL" /D "ZLIB_INTERNAL" /FR /GD | ||
27 | LFLAGS_D_WDLL = /NOLOGO /ONERROR:NOEXE /NOD /PACKC:61440 /CO /NOE /ALIGN:16 /MAP:FULL | ||
28 | LFLAGS_R_WDLL = /NOLOGO /ONERROR:NOEXE /NOD /PACKC:61440 /NOE /ALIGN:16 /MAP:FULL | ||
29 | LIBS_D_WDLL = oldnames libw commdlg shell olecli olesvr ldllcew | ||
30 | LIBS_R_WDLL = oldnames libw commdlg shell olecli olesvr ldllcew | ||
31 | RCFLAGS = /nologo | ||
32 | RESFLAGS = /nologo | ||
33 | RUNFLAGS = | ||
34 | DEFFILE = ZLIB16.DEF | ||
35 | OBJS_EXT = | ||
36 | LIBS_EXT = | ||
37 | !if "$(DEBUG)" == "1" | ||
38 | CFLAGS = $(CFLAGS_D_WDLL) | ||
39 | LFLAGS = $(LFLAGS_D_WDLL) | ||
40 | LIBS = $(LIBS_D_WDLL) | ||
41 | MAPFILE = nul | ||
42 | RCDEFINES = $(D_RCDEFINES) | ||
43 | !else | ||
44 | CFLAGS = $(CFLAGS_R_WDLL) | ||
45 | LFLAGS = $(LFLAGS_R_WDLL) | ||
46 | LIBS = $(LIBS_R_WDLL) | ||
47 | MAPFILE = nul | ||
48 | RCDEFINES = $(R_RCDEFINES) | ||
49 | !endif | ||
50 | !if [if exist MSVC.BND del MSVC.BND] | ||
51 | !endif | ||
52 | SBRS = ADLER32.SBR \ | ||
53 | COMPRESS.SBR \ | ||
54 | CRC32.SBR \ | ||
55 | DEFLATE.SBR \ | ||
56 | GZIO.SBR \ | ||
57 | INFFAST.SBR \ | ||
58 | INFLATE.SBR \ | ||
59 | TREES.SBR \ | ||
60 | UNCOMPR.SBR \ | ||
61 | ZUTIL.SBR \ | ||
62 | ZIP.SBR \ | ||
63 | UNZIP.SBR \ | ||
64 | INFBACK.SBR \ | ||
65 | IOAPI.SBR \ | ||
66 | INFTREES.SBR | ||
67 | |||
68 | |||
69 | ADLER32_DEP = c:\zlib\zlib.h \ | ||
70 | c:\zlib\zconf.h | ||
71 | |||
72 | |||
73 | COMPRESS_DEP = c:\zlib\zlib.h \ | ||
74 | c:\zlib\zconf.h | ||
75 | |||
76 | |||
77 | CRC32_DEP = c:\zlib\zutil.h \ | ||
78 | c:\zlib\zlib.h \ | ||
79 | c:\zlib\zconf.h \ | ||
80 | c:\zlib\crc32.h | ||
81 | |||
82 | |||
83 | DEFLATE_DEP = c:\zlib\deflate.h \ | ||
84 | c:\zlib\zutil.h \ | ||
85 | c:\zlib\zlib.h \ | ||
86 | c:\zlib\zconf.h | ||
87 | |||
88 | |||
89 | GZIO_DEP = c:\zlib\zutil.h \ | ||
90 | c:\zlib\zlib.h \ | ||
91 | c:\zlib\zconf.h | ||
92 | |||
93 | |||
94 | INFFAST_DEP = c:\zlib\zutil.h \ | ||
95 | c:\zlib\zlib.h \ | ||
96 | c:\zlib\zconf.h \ | ||
97 | c:\zlib\inftrees.h \ | ||
98 | c:\zlib\inflate.h \ | ||
99 | c:\zlib\inffast.h | ||
100 | |||
101 | |||
102 | INFLATE_DEP = c:\zlib\zutil.h \ | ||
103 | c:\zlib\zlib.h \ | ||
104 | c:\zlib\zconf.h \ | ||
105 | c:\zlib\inftrees.h \ | ||
106 | c:\zlib\inflate.h \ | ||
107 | c:\zlib\inffast.h \ | ||
108 | c:\zlib\inffixed.h | ||
109 | |||
110 | |||
111 | TREES_DEP = c:\zlib\deflate.h \ | ||
112 | c:\zlib\zutil.h \ | ||
113 | c:\zlib\zlib.h \ | ||
114 | c:\zlib\zconf.h \ | ||
115 | c:\zlib\trees.h | ||
116 | |||
117 | |||
118 | UNCOMPR_DEP = c:\zlib\zlib.h \ | ||
119 | c:\zlib\zconf.h | ||
120 | |||
121 | |||
122 | ZUTIL_DEP = c:\zlib\zutil.h \ | ||
123 | c:\zlib\zlib.h \ | ||
124 | c:\zlib\zconf.h | ||
125 | |||
126 | |||
127 | ZLIB16_RCDEP = | ||
128 | |||
129 | ZIP_DEP = c:\zlib\zlib.h \ | ||
130 | c:\zlib\zconf.h \ | ||
131 | c:\zlib\zip.h \ | ||
132 | c:\zlib\ioapi.h \ | ||
133 | c:\zlib\crypt.h | ||
134 | |||
135 | |||
136 | UNZIP_DEP = c:\zlib\zlib.h \ | ||
137 | c:\zlib\zconf.h \ | ||
138 | c:\zlib\unzip.h \ | ||
139 | c:\zlib\ioapi.h \ | ||
140 | c:\zlib\crypt.h | ||
141 | |||
142 | |||
143 | INFBACK_DEP = c:\zlib\zutil.h \ | ||
144 | c:\zlib\zlib.h \ | ||
145 | c:\zlib\zconf.h \ | ||
146 | c:\zlib\inftrees.h \ | ||
147 | c:\zlib\inflate.h \ | ||
148 | c:\zlib\inffast.h \ | ||
149 | c:\zlib\inffixed.h | ||
150 | |||
151 | |||
152 | IOAPI_DEP = c:\zlib\zlib.h \ | ||
153 | c:\zlib\zconf.h \ | ||
154 | c:\zlib\ioapi.h | ||
155 | |||
156 | |||
157 | INFTREES_DEP = c:\zlib\zutil.h \ | ||
158 | c:\zlib\zlib.h \ | ||
159 | c:\zlib\zconf.h \ | ||
160 | c:\zlib\inftrees.h | ||
161 | |||
162 | |||
163 | all: $(PROJ).DLL $(PROJ).BSC | ||
164 | |||
165 | ADLER32.OBJ: ADLER32.C $(ADLER32_DEP) | ||
166 | $(CC) $(CFLAGS) $(CCREATEPCHFLAG) /c ADLER32.C | ||
167 | |||
168 | COMPRESS.OBJ: COMPRESS.C $(COMPRESS_DEP) | ||
169 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c COMPRESS.C | ||
170 | |||
171 | CRC32.OBJ: CRC32.C $(CRC32_DEP) | ||
172 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c CRC32.C | ||
173 | |||
174 | DEFLATE.OBJ: DEFLATE.C $(DEFLATE_DEP) | ||
175 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c DEFLATE.C | ||
176 | |||
177 | GZIO.OBJ: GZIO.C $(GZIO_DEP) | ||
178 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c GZIO.C | ||
179 | |||
180 | INFFAST.OBJ: INFFAST.C $(INFFAST_DEP) | ||
181 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c INFFAST.C | ||
182 | |||
183 | INFLATE.OBJ: INFLATE.C $(INFLATE_DEP) | ||
184 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c INFLATE.C | ||
185 | |||
186 | TREES.OBJ: TREES.C $(TREES_DEP) | ||
187 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c TREES.C | ||
188 | |||
189 | UNCOMPR.OBJ: UNCOMPR.C $(UNCOMPR_DEP) | ||
190 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c UNCOMPR.C | ||
191 | |||
192 | ZUTIL.OBJ: ZUTIL.C $(ZUTIL_DEP) | ||
193 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c ZUTIL.C | ||
194 | |||
195 | ZLIB16.RES: ZLIB16.RC $(ZLIB16_RCDEP) | ||
196 | $(RC) $(RCFLAGS) $(RCDEFINES) -r ZLIB16.RC | ||
197 | |||
198 | ZIP.OBJ: ZIP.C $(ZIP_DEP) | ||
199 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c ZIP.C | ||
200 | |||
201 | UNZIP.OBJ: UNZIP.C $(UNZIP_DEP) | ||
202 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c UNZIP.C | ||
203 | |||
204 | INFBACK.OBJ: INFBACK.C $(INFBACK_DEP) | ||
205 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c INFBACK.C | ||
206 | |||
207 | IOAPI.OBJ: IOAPI.C $(IOAPI_DEP) | ||
208 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c IOAPI.C | ||
209 | |||
210 | INFTREES.OBJ: INFTREES.C $(INFTREES_DEP) | ||
211 | $(CC) $(CFLAGS) $(CUSEPCHFLAG) /c INFTREES.C | ||
212 | |||
213 | |||
214 | $(PROJ).DLL:: ZLIB16.RES | ||
215 | |||
216 | $(PROJ).DLL:: ADLER32.OBJ COMPRESS.OBJ CRC32.OBJ DEFLATE.OBJ GZIO.OBJ INFFAST.OBJ \ | ||
217 | INFLATE.OBJ TREES.OBJ UNCOMPR.OBJ ZUTIL.OBJ ZIP.OBJ UNZIP.OBJ INFBACK.OBJ IOAPI.OBJ \ | ||
218 | INFTREES.OBJ $(OBJS_EXT) $(DEFFILE) | ||
219 | echo >NUL @<<$(PROJ).CRF | ||
220 | ADLER32.OBJ + | ||
221 | COMPRESS.OBJ + | ||
222 | CRC32.OBJ + | ||
223 | DEFLATE.OBJ + | ||
224 | GZIO.OBJ + | ||
225 | INFFAST.OBJ + | ||
226 | INFLATE.OBJ + | ||
227 | TREES.OBJ + | ||
228 | UNCOMPR.OBJ + | ||
229 | ZUTIL.OBJ + | ||
230 | ZIP.OBJ + | ||
231 | UNZIP.OBJ + | ||
232 | INFBACK.OBJ + | ||
233 | IOAPI.OBJ + | ||
234 | INFTREES.OBJ + | ||
235 | $(OBJS_EXT) | ||
236 | $(PROJ).DLL | ||
237 | $(MAPFILE) | ||
238 | C:\MSVC\LIB\+ | ||
239 | C:\MSVC\MFC\LIB\+ | ||
240 | E:\PROGRAMFILES\MICROSOFTVISUALSTUDIO.NET\FRAMEWORKSDK\LIB\+ | ||
241 | $(LIBS) | ||
242 | $(DEFFILE); | ||
243 | << | ||
244 | link $(LFLAGS) @$(PROJ).CRF | ||
245 | $(RC) $(RESFLAGS) ZLIB16.RES $@ | ||
246 | @copy $(PROJ).CRF MSVC.BND | ||
247 | implib /nowep $(PROJ).LIB $(PROJ).DLL | ||
248 | |||
249 | $(PROJ).DLL:: ZLIB16.RES | ||
250 | if not exist MSVC.BND $(RC) $(RESFLAGS) ZLIB16.RES $@ | ||
251 | |||
252 | run: $(PROJ).DLL | ||
253 | $(PROJ) $(RUNFLAGS) | ||
254 | |||
255 | |||
256 | $(PROJ).BSC: $(SBRS) | ||
257 | bscmake @<< | ||
258 | /o$@ $(SBRS) | ||
259 | << | ||
diff --git a/contrib/vstudio/vc15_16/zlib16.rc b/contrib/vstudio/vc15_16/zlib16.rc deleted file mode 100644 index 514585c..0000000 --- a/contrib/vstudio/vc15_16/zlib16.rc +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | #include <windows.h> | ||
2 | #include <ver.h> | ||
3 | |||
4 | #define IDR_VERSION1 1 | ||
5 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE | ||
6 | FILEVERSION 1,2,1,0 | ||
7 | PRODUCTVERSION 1,2,1,0 | ||
8 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK | ||
9 | FILEFLAGS 0 | ||
10 | FILEOS VOS_DOS_WINDOWS16 | ||
11 | FILETYPE VFT_DLL | ||
12 | FILESUBTYPE 0 // not used | ||
13 | BEGIN | ||
14 | BLOCK "StringFileInfo" | ||
15 | BEGIN | ||
16 | BLOCK "040904E4" | ||
17 | //language ID = U.S. English, char set = Windows, Multilingual | ||
18 | |||
19 | BEGIN | ||
20 | VALUE "FileDescription", "zlib data compression library\0" | ||
21 | VALUE "FileVersion", "1.2.1\0" | ||
22 | VALUE "InternalName", "zlib16\0" | ||
23 | VALUE "OriginalFilename", "zlib16.dll\0" | ||
24 | VALUE "ProductName", "ZLib16.DLL\0" | ||
25 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" | ||
26 | VALUE "LegalCopyright", "(C) 1995-2003 Jean-loup Gailly & Mark Adler\0" | ||
27 | END | ||
28 | END | ||
29 | BLOCK "VarFileInfo" | ||
30 | BEGIN | ||
31 | VALUE "Translation", 0x0409, 1252 | ||
32 | END | ||
33 | END | ||
diff --git a/contrib/vstudio/vc70_32/gvmat32.obj b/contrib/vstudio/vc7/gvmat32.obj index 5b2f856..5b2f856 100644 --- a/contrib/vstudio/vc70_32/gvmat32.obj +++ b/contrib/vstudio/vc7/gvmat32.obj | |||
Binary files differ | |||
diff --git a/contrib/vstudio/vc7/inffas32.obj b/contrib/vstudio/vc7/inffas32.obj new file mode 100644 index 0000000..a541a5a --- /dev/null +++ b/contrib/vstudio/vc7/inffas32.obj | |||
Binary files differ | |||
diff --git a/contrib/vstudio/vc70_32/miniunz.vcproj b/contrib/vstudio/vc7/miniunz.vcproj index 1c6967f..935c250 100644 --- a/contrib/vstudio/vc70_32/miniunz.vcproj +++ b/contrib/vstudio/vc7/miniunz.vcproj | |||
@@ -19,7 +19,7 @@ | |||
19 | <Tool | 19 | <Tool |
20 | Name="VCCLCompilerTool" | 20 | Name="VCCLCompilerTool" |
21 | Optimization="0" | 21 | Optimization="0" |
22 | PreprocessorDefinitions="WIN32;ZLIB_DLL;_DEBUG;_CONSOLE" | 22 | PreprocessorDefinitions="WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE" |
23 | MinimalRebuild="TRUE" | 23 | MinimalRebuild="TRUE" |
24 | BasicRuntimeChecks="3" | 24 | BasicRuntimeChecks="3" |
25 | RuntimeLibrary="5" | 25 | RuntimeLibrary="5" |
@@ -63,7 +63,7 @@ | |||
63 | Optimization="2" | 63 | Optimization="2" |
64 | InlineFunctionExpansion="1" | 64 | InlineFunctionExpansion="1" |
65 | OmitFramePointers="TRUE" | 65 | OmitFramePointers="TRUE" |
66 | PreprocessorDefinitions="WIN32;ZLIB_DLL;NDEBUG;_CONSOLE" | 66 | PreprocessorDefinitions="WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE" |
67 | StringPooling="TRUE" | 67 | StringPooling="TRUE" |
68 | RuntimeLibrary="4" | 68 | RuntimeLibrary="4" |
69 | EnableFunctionLevelLinking="TRUE" | 69 | EnableFunctionLevelLinking="TRUE" |
@@ -116,7 +116,7 @@ | |||
116 | Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> | 116 | Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> |
117 | </Filter> | 117 | </Filter> |
118 | <File | 118 | <File |
119 | RelativePath="zlib.lib"> | 119 | RelativePath="zlibwapi.lib"> |
120 | </File> | 120 | </File> |
121 | </Files> | 121 | </Files> |
122 | <Globals> | 122 | <Globals> |
diff --git a/contrib/vstudio/vc70_32/minizip.vcproj b/contrib/vstudio/vc7/minizip.vcproj index 93e2a41..e6f9107 100644 --- a/contrib/vstudio/vc70_32/minizip.vcproj +++ b/contrib/vstudio/vc7/minizip.vcproj | |||
@@ -19,7 +19,7 @@ | |||
19 | <Tool | 19 | <Tool |
20 | Name="VCCLCompilerTool" | 20 | Name="VCCLCompilerTool" |
21 | Optimization="0" | 21 | Optimization="0" |
22 | PreprocessorDefinitions="WIN32;ZLIB_DLL;_DEBUG;_CONSOLE" | 22 | PreprocessorDefinitions="WIN32;ZLIB_WINAPI;_DEBUG;_CONSOLE" |
23 | MinimalRebuild="TRUE" | 23 | MinimalRebuild="TRUE" |
24 | BasicRuntimeChecks="3" | 24 | BasicRuntimeChecks="3" |
25 | RuntimeLibrary="5" | 25 | RuntimeLibrary="5" |
@@ -63,7 +63,7 @@ | |||
63 | Optimization="2" | 63 | Optimization="2" |
64 | InlineFunctionExpansion="1" | 64 | InlineFunctionExpansion="1" |
65 | OmitFramePointers="TRUE" | 65 | OmitFramePointers="TRUE" |
66 | PreprocessorDefinitions="WIN32;ZLIB_DLL;NDEBUG;_CONSOLE" | 66 | PreprocessorDefinitions="WIN32;ZLIB_WINAPI;NDEBUG;_CONSOLE" |
67 | StringPooling="TRUE" | 67 | StringPooling="TRUE" |
68 | RuntimeLibrary="4" | 68 | RuntimeLibrary="4" |
69 | EnableFunctionLevelLinking="TRUE" | 69 | EnableFunctionLevelLinking="TRUE" |
@@ -116,7 +116,7 @@ | |||
116 | Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> | 116 | Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"> |
117 | </Filter> | 117 | </Filter> |
118 | <File | 118 | <File |
119 | RelativePath="zlib.lib"> | 119 | RelativePath="zlibwapi.lib"> |
120 | </File> | 120 | </File> |
121 | </Files> | 121 | </Files> |
122 | <Globals> | 122 | <Globals> |
diff --git a/contrib/vstudio/vc70_32/zlib.rc b/contrib/vstudio/vc7/zlib.rc index 6c51679..6c51679 100644 --- a/contrib/vstudio/vc70_32/zlib.rc +++ b/contrib/vstudio/vc7/zlib.rc | |||
diff --git a/contrib/vstudio/vc70_32/zlibstat.vcproj b/contrib/vstudio/vc7/zlibstat.vcproj index 7470b58..eb182f7 100644 --- a/contrib/vstudio/vc70_32/zlibstat.vcproj +++ b/contrib/vstudio/vc7/zlibstat.vcproj | |||
@@ -20,7 +20,7 @@ | |||
20 | <Tool | 20 | <Tool |
21 | Name="VCCLCompilerTool" | 21 | Name="VCCLCompilerTool" |
22 | Optimization="0" | 22 | Optimization="0" |
23 | PreprocessorDefinitions="WIN32;ZLIB_DLL" | 23 | PreprocessorDefinitions="WIN32;ZLIB_WINAPI" |
24 | ExceptionHandling="FALSE" | 24 | ExceptionHandling="FALSE" |
25 | RuntimeLibrary="5" | 25 | RuntimeLibrary="5" |
26 | PrecompiledHeaderFile=".\zlibstatDebug/zlibstat.pch" | 26 | PrecompiledHeaderFile=".\zlibstatDebug/zlibstat.pch" |
@@ -61,7 +61,7 @@ | |||
61 | <Tool | 61 | <Tool |
62 | Name="VCCLCompilerTool" | 62 | Name="VCCLCompilerTool" |
63 | InlineFunctionExpansion="1" | 63 | InlineFunctionExpansion="1" |
64 | PreprocessorDefinitions="WIN32;ZLIB_DLL" | 64 | PreprocessorDefinitions="WIN32;ZLIB_WINAPI" |
65 | StringPooling="TRUE" | 65 | StringPooling="TRUE" |
66 | ExceptionHandling="FALSE" | 66 | ExceptionHandling="FALSE" |
67 | RuntimeLibrary="4" | 67 | RuntimeLibrary="4" |
@@ -102,7 +102,7 @@ | |||
102 | <Tool | 102 | <Tool |
103 | Name="VCCLCompilerTool" | 103 | Name="VCCLCompilerTool" |
104 | InlineFunctionExpansion="1" | 104 | InlineFunctionExpansion="1" |
105 | PreprocessorDefinitions="WIN32;ZLIB_DLL,ASMV" | 105 | PreprocessorDefinitions="WIN32;ZLIB_WINAPI;ASMV;ASMINF" |
106 | StringPooling="TRUE" | 106 | StringPooling="TRUE" |
107 | ExceptionHandling="FALSE" | 107 | ExceptionHandling="FALSE" |
108 | RuntimeLibrary="4" | 108 | RuntimeLibrary="4" |
@@ -117,7 +117,7 @@ | |||
117 | Name="VCCustomBuildTool"/> | 117 | Name="VCCustomBuildTool"/> |
118 | <Tool | 118 | <Tool |
119 | Name="VCLibrarianTool" | 119 | Name="VCLibrarianTool" |
120 | AdditionalOptions="gvmat32.obj inffastAsm.obj /NODEFAULTLIB " | 120 | AdditionalOptions="gvmat32.obj inffas32.obj /NODEFAULTLIB " |
121 | OutputFile=".\zlibstat\zlibstat.lib" | 121 | OutputFile=".\zlibstat\zlibstat.lib" |
122 | SuppressStartupBanner="TRUE"/> | 122 | SuppressStartupBanner="TRUE"/> |
123 | <Tool | 123 | <Tool |
@@ -144,7 +144,7 @@ | |||
144 | <Tool | 144 | <Tool |
145 | Name="VCCLCompilerTool" | 145 | Name="VCCLCompilerTool" |
146 | InlineFunctionExpansion="1" | 146 | InlineFunctionExpansion="1" |
147 | PreprocessorDefinitions="WIN32;ZLIB_DLL" | 147 | PreprocessorDefinitions="WIN32;ZLIB_WINAPI" |
148 | StringPooling="TRUE" | 148 | StringPooling="TRUE" |
149 | ExceptionHandling="FALSE" | 149 | ExceptionHandling="FALSE" |
150 | RuntimeLibrary="4" | 150 | RuntimeLibrary="4" |
@@ -204,17 +204,6 @@ | |||
204 | </File> | 204 | </File> |
205 | <File | 205 | <File |
206 | RelativePath=".\inffast.c"> | 206 | RelativePath=".\inffast.c"> |
207 | <FileConfiguration | ||
208 | Name="Release|Win32" | ||
209 | ExcludedFromBuild="TRUE"> | ||
210 | <Tool | ||
211 | Name="VCCLCompilerTool"/> | ||
212 | </FileConfiguration> | ||
213 | <FileConfiguration | ||
214 | Name="ReleaseWithoutAsm|Win32"> | ||
215 | <Tool | ||
216 | Name="VCCLCompilerTool"/> | ||
217 | </FileConfiguration> | ||
218 | </File> | 207 | </File> |
219 | <File | 208 | <File |
220 | RelativePath=".\inflate.c"> | 209 | RelativePath=".\inflate.c"> |
diff --git a/contrib/vstudio/vc70_32/zlibvc.def b/contrib/vstudio/vc7/zlibvc.def index c2804a8..63b3e6d 100644 --- a/contrib/vstudio/vc70_32/zlibvc.def +++ b/contrib/vstudio/vc7/zlibvc.def | |||
@@ -1,4 +1,3 @@ | |||
1 | LIBRARY "zlib" | ||
2 | 1 | ||
3 | VERSION 1.21 | 2 | VERSION 1.21 |
4 | 3 | ||
@@ -51,6 +50,10 @@ EXPORTS | |||
51 | inflateBack @44 | 50 | inflateBack @44 |
52 | inflateBackEnd @45 | 51 | inflateBackEnd @45 |
53 | compressBound @46 | 52 | compressBound @46 |
53 | deflateBound @47 | ||
54 | gzclearerr @48 | ||
55 | gzungetc @49 | ||
56 | zlibCompileFlags @50 | ||
54 | 57 | ||
55 | unzOpen @61 | 58 | unzOpen @61 |
56 | unzClose @62 | 59 | unzClose @62 |
diff --git a/contrib/vstudio/vc70_32/zlibvc.sln b/contrib/vstudio/vc7/zlibvc.sln index 5a007ff..5a007ff 100644 --- a/contrib/vstudio/vc70_32/zlibvc.sln +++ b/contrib/vstudio/vc7/zlibvc.sln | |||
diff --git a/contrib/vstudio/vc70_32/zlibvc.vcproj b/contrib/vstudio/vc7/zlibvc.vcproj index 7a9e83a..4e57bcd 100644 --- a/contrib/vstudio/vc70_32/zlibvc.vcproj +++ b/contrib/vstudio/vc7/zlibvc.vcproj | |||
@@ -20,7 +20,7 @@ | |||
20 | <Tool | 20 | <Tool |
21 | Name="VCCLCompilerTool" | 21 | Name="VCCLCompilerTool" |
22 | Optimization="0" | 22 | Optimization="0" |
23 | PreprocessorDefinitions="WIN32,ZLIB_DLL,ASMV" | 23 | PreprocessorDefinitions="WIN32,ZLIB_WINAPI,ASMV,ASMINF" |
24 | ExceptionHandling="FALSE" | 24 | ExceptionHandling="FALSE" |
25 | RuntimeLibrary="1" | 25 | RuntimeLibrary="1" |
26 | PrecompiledHeaderFile=".\DebugDll/zlibvc.pch" | 26 | PrecompiledHeaderFile=".\DebugDll/zlibvc.pch" |
@@ -35,15 +35,15 @@ | |||
35 | <Tool | 35 | <Tool |
36 | Name="VCLinkerTool" | 36 | Name="VCLinkerTool" |
37 | AdditionalOptions="/MACHINE:I386" | 37 | AdditionalOptions="/MACHINE:I386" |
38 | AdditionalDependencies="gvmat32.obj " | 38 | AdditionalDependencies="gvmat32.obj inffas32.obj" |
39 | OutputFile=".\DebugDll\zlib.dll" | 39 | OutputFile=".\DebugDll\zlibwapi.dll" |
40 | LinkIncremental="2" | 40 | LinkIncremental="2" |
41 | SuppressStartupBanner="TRUE" | 41 | SuppressStartupBanner="TRUE" |
42 | ModuleDefinitionFile=".\zlibvc.def" | 42 | ModuleDefinitionFile=".\zlibvc.def" |
43 | GenerateDebugInformation="TRUE" | 43 | GenerateDebugInformation="TRUE" |
44 | ProgramDatabaseFile=".\DebugDll/zlib.pdb" | 44 | ProgramDatabaseFile=".\DebugDll/zlibwapi.pdb" |
45 | SubSystem="2" | 45 | SubSystem="2" |
46 | ImportLibrary=".\DebugDll/zlib.lib"/> | 46 | ImportLibrary=".\DebugDll/zlibwapi.lib"/> |
47 | <Tool | 47 | <Tool |
48 | Name="VCMIDLTool" | 48 | Name="VCMIDLTool" |
49 | PreprocessorDefinitions="_DEBUG" | 49 | PreprocessorDefinitions="_DEBUG" |
@@ -76,7 +76,7 @@ | |||
76 | <Tool | 76 | <Tool |
77 | Name="VCCLCompilerTool" | 77 | Name="VCCLCompilerTool" |
78 | InlineFunctionExpansion="1" | 78 | InlineFunctionExpansion="1" |
79 | PreprocessorDefinitions="WIN32,ZLIB_DLL" | 79 | PreprocessorDefinitions="WIN32,ZLIB_WINAPI" |
80 | StringPooling="TRUE" | 80 | StringPooling="TRUE" |
81 | ExceptionHandling="FALSE" | 81 | ExceptionHandling="FALSE" |
82 | RuntimeLibrary="0" | 82 | RuntimeLibrary="0" |
@@ -95,17 +95,17 @@ | |||
95 | Name="VCLinkerTool" | 95 | Name="VCLinkerTool" |
96 | AdditionalOptions="/MACHINE:I386" | 96 | AdditionalOptions="/MACHINE:I386" |
97 | AdditionalDependencies="crtdll.lib" | 97 | AdditionalDependencies="crtdll.lib" |
98 | OutputFile=".\zlibDllWithoutAsm\zlib.dll" | 98 | OutputFile=".\zlibDllWithoutAsm\zlibwapi.dll" |
99 | LinkIncremental="1" | 99 | LinkIncremental="1" |
100 | SuppressStartupBanner="TRUE" | 100 | SuppressStartupBanner="TRUE" |
101 | IgnoreAllDefaultLibraries="TRUE" | 101 | IgnoreAllDefaultLibraries="TRUE" |
102 | ModuleDefinitionFile=".\zlibvc.def" | 102 | ModuleDefinitionFile=".\zlibvc.def" |
103 | ProgramDatabaseFile=".\zlibDllWithoutAsm/zlib.pdb" | 103 | ProgramDatabaseFile=".\zlibDllWithoutAsm/zlibwapi.pdb" |
104 | GenerateMapFile="TRUE" | 104 | GenerateMapFile="TRUE" |
105 | MapFileName=".\zlibDllWithoutAsm/zlib.map" | 105 | MapFileName=".\zlibDllWithoutAsm/zlibwapi.map" |
106 | SubSystem="2" | 106 | SubSystem="2" |
107 | OptimizeForWindows98="1" | 107 | OptimizeForWindows98="1" |
108 | ImportLibrary=".\zlibDllWithoutAsm/zlib.lib"/> | 108 | ImportLibrary=".\zlibDllWithoutAsm/zlibwapi.lib"/> |
109 | <Tool | 109 | <Tool |
110 | Name="VCMIDLTool" | 110 | Name="VCMIDLTool" |
111 | PreprocessorDefinitions="NDEBUG" | 111 | PreprocessorDefinitions="NDEBUG" |
@@ -138,7 +138,7 @@ | |||
138 | <Tool | 138 | <Tool |
139 | Name="VCCLCompilerTool" | 139 | Name="VCCLCompilerTool" |
140 | InlineFunctionExpansion="1" | 140 | InlineFunctionExpansion="1" |
141 | PreprocessorDefinitions="WIN32,ZLIB_DLL,ASMV" | 141 | PreprocessorDefinitions="WIN32,ZLIB_WINAPI,ASMV,ASMINF" |
142 | StringPooling="TRUE" | 142 | StringPooling="TRUE" |
143 | ExceptionHandling="FALSE" | 143 | ExceptionHandling="FALSE" |
144 | RuntimeLibrary="0" | 144 | RuntimeLibrary="0" |
@@ -156,18 +156,18 @@ | |||
156 | <Tool | 156 | <Tool |
157 | Name="VCLinkerTool" | 157 | Name="VCLinkerTool" |
158 | AdditionalOptions="/MACHINE:I386" | 158 | AdditionalOptions="/MACHINE:I386" |
159 | AdditionalDependencies="gvmat32.obj inffastAsm.obj " | 159 | AdditionalDependencies="gvmat32.obj inffas32.obj " |
160 | OutputFile=".\zlibDllWithoutCrtDll\zlib.dll" | 160 | OutputFile=".\zlibDllWithoutCrtDll\zlibwapi.dll" |
161 | LinkIncremental="1" | 161 | LinkIncremental="1" |
162 | SuppressStartupBanner="TRUE" | 162 | SuppressStartupBanner="TRUE" |
163 | IgnoreAllDefaultLibraries="FALSE" | 163 | IgnoreAllDefaultLibraries="FALSE" |
164 | ModuleDefinitionFile=".\zlibvc.def" | 164 | ModuleDefinitionFile=".\zlibvc.def" |
165 | ProgramDatabaseFile=".\zlibDllWithoutCrtDll/zlib.pdb" | 165 | ProgramDatabaseFile=".\zlibDllWithoutCrtDll/zlibwapi.pdb" |
166 | GenerateMapFile="TRUE" | 166 | GenerateMapFile="TRUE" |
167 | MapFileName=".\zlibDllWithoutCrtDll/zlib.map" | 167 | MapFileName=".\zlibDllWithoutCrtDll/zlibwapi.map" |
168 | SubSystem="2" | 168 | SubSystem="2" |
169 | OptimizeForWindows98="1" | 169 | OptimizeForWindows98="1" |
170 | ImportLibrary=".\zlibDllWithoutCrtDll/zlib.lib"/> | 170 | ImportLibrary=".\zlibDllWithoutCrtDll/zlibwapi.lib"/> |
171 | <Tool | 171 | <Tool |
172 | Name="VCMIDLTool" | 172 | Name="VCMIDLTool" |
173 | PreprocessorDefinitions="NDEBUG" | 173 | PreprocessorDefinitions="NDEBUG" |
@@ -200,7 +200,7 @@ | |||
200 | <Tool | 200 | <Tool |
201 | Name="VCCLCompilerTool" | 201 | Name="VCCLCompilerTool" |
202 | InlineFunctionExpansion="1" | 202 | InlineFunctionExpansion="1" |
203 | PreprocessorDefinitions="WIN32,ZLIB_DLL" | 203 | PreprocessorDefinitions="WIN32,ZLIB_WINAPI" |
204 | StringPooling="TRUE" | 204 | StringPooling="TRUE" |
205 | ExceptionHandling="FALSE" | 205 | ExceptionHandling="FALSE" |
206 | RuntimeLibrary="0" | 206 | RuntimeLibrary="0" |
@@ -218,16 +218,16 @@ | |||
218 | <Tool | 218 | <Tool |
219 | Name="VCLinkerTool" | 219 | Name="VCLinkerTool" |
220 | AdditionalDependencies="crtdll.lib" | 220 | AdditionalDependencies="crtdll.lib" |
221 | OutputFile="zlibvc__\zlib.dll" | 221 | OutputFile="zlibvc__\zlibwapi.dll" |
222 | LinkIncremental="1" | 222 | LinkIncremental="1" |
223 | SuppressStartupBanner="TRUE" | 223 | SuppressStartupBanner="TRUE" |
224 | IgnoreAllDefaultLibraries="TRUE" | 224 | IgnoreAllDefaultLibraries="TRUE" |
225 | ModuleDefinitionFile=".\zlibvc.def" | 225 | ModuleDefinitionFile=".\zlibvc.def" |
226 | ProgramDatabaseFile=".\zlibvc__/zlib.pdb" | 226 | ProgramDatabaseFile=".\zlibvc__/zlibwapi.pdb" |
227 | GenerateMapFile="TRUE" | 227 | GenerateMapFile="TRUE" |
228 | MapFileName=".\zlibvc__/zlib.map" | 228 | MapFileName=".\zlibvc__/zlibwapi.map" |
229 | SubSystem="2" | 229 | SubSystem="2" |
230 | ImportLibrary=".\zlibvc__/zlib.lib"/> | 230 | ImportLibrary=".\zlibvc__/zlibwapi.lib"/> |
231 | <Tool | 231 | <Tool |
232 | Name="VCMIDLTool" | 232 | Name="VCMIDLTool" |
233 | PreprocessorDefinitions="NDEBUG" | 233 | PreprocessorDefinitions="NDEBUG" |
@@ -260,7 +260,7 @@ | |||
260 | <Tool | 260 | <Tool |
261 | Name="VCCLCompilerTool" | 261 | Name="VCCLCompilerTool" |
262 | InlineFunctionExpansion="1" | 262 | InlineFunctionExpansion="1" |
263 | PreprocessorDefinitions="WIN32,ZLIB_DLL,ASMV" | 263 | PreprocessorDefinitions="WIN32,ZLIB_WINAPI,ASMV,ASMINF" |
264 | StringPooling="TRUE" | 264 | StringPooling="TRUE" |
265 | ExceptionHandling="FALSE" | 265 | ExceptionHandling="FALSE" |
266 | RuntimeLibrary="0" | 266 | RuntimeLibrary="0" |
@@ -278,18 +278,18 @@ | |||
278 | <Tool | 278 | <Tool |
279 | Name="VCLinkerTool" | 279 | Name="VCLinkerTool" |
280 | AdditionalOptions="/MACHINE:I386" | 280 | AdditionalOptions="/MACHINE:I386" |
281 | AdditionalDependencies="gvmat32.obj inffastAsm.obj crtdll.lib" | 281 | AdditionalDependencies="gvmat32.obj inffas32.obj crtdll.lib" |
282 | OutputFile=".\ReleaseDll\zlib.dll" | 282 | OutputFile=".\ReleaseDll\zlibwapi.dll" |
283 | LinkIncremental="1" | 283 | LinkIncremental="1" |
284 | SuppressStartupBanner="TRUE" | 284 | SuppressStartupBanner="TRUE" |
285 | IgnoreAllDefaultLibraries="TRUE" | 285 | IgnoreAllDefaultLibraries="TRUE" |
286 | ModuleDefinitionFile=".\zlibvc.def" | 286 | ModuleDefinitionFile=".\zlibvc.def" |
287 | ProgramDatabaseFile=".\ReleaseDll/zlib.pdb" | 287 | ProgramDatabaseFile=".\ReleaseDll/zlibwapi.pdb" |
288 | GenerateMapFile="TRUE" | 288 | GenerateMapFile="TRUE" |
289 | MapFileName=".\ReleaseDll/zlib.map" | 289 | MapFileName=".\ReleaseDll/zlibwapi.map" |
290 | SubSystem="2" | 290 | SubSystem="2" |
291 | OptimizeForWindows98="1" | 291 | OptimizeForWindows98="1" |
292 | ImportLibrary=".\ReleaseDll/zlib.lib"/> | 292 | ImportLibrary=".\ReleaseDll/zlibwapi.lib"/> |
293 | <Tool | 293 | <Tool |
294 | Name="VCMIDLTool" | 294 | Name="VCMIDLTool" |
295 | PreprocessorDefinitions="NDEBUG" | 295 | PreprocessorDefinitions="NDEBUG" |
@@ -346,18 +346,6 @@ | |||
346 | </File> | 346 | </File> |
347 | <File | 347 | <File |
348 | RelativePath=".\inffast.c"> | 348 | RelativePath=".\inffast.c"> |
349 | <FileConfiguration | ||
350 | Name="ReleaseWithoutCrtdll|Win32" | ||
351 | ExcludedFromBuild="TRUE"> | ||
352 | <Tool | ||
353 | Name="VCCLCompilerTool"/> | ||
354 | </FileConfiguration> | ||
355 | <FileConfiguration | ||
356 | Name="Release|Win32" | ||
357 | ExcludedFromBuild="TRUE"> | ||
358 | <Tool | ||
359 | Name="VCCLCompilerTool"/> | ||
360 | </FileConfiguration> | ||
361 | </File> | 349 | </File> |
362 | <File | 350 | <File |
363 | RelativePath=".\inflate.c"> | 351 | RelativePath=".\inflate.c"> |
diff --git a/contrib/vstudio/vc70_32/inffastAsm.asm b/contrib/vstudio/vc70_32/inffastAsm.asm deleted file mode 100644 index f4b6a56..0000000 --- a/contrib/vstudio/vc70_32/inffastAsm.asm +++ /dev/null | |||
@@ -1,1020 +0,0 @@ | |||
1 | ; 75 "inffast.S" | ||
2 | ;FILE "inffast.S" | ||
3 | |||
4 | ;;;GLOBAL _inflate_fast | ||
5 | |||
6 | ;;;SECTION .text | ||
7 | |||
8 | |||
9 | |||
10 | .586p | ||
11 | .mmx | ||
12 | |||
13 | name inflate_fast_x86 | ||
14 | .MODEL FLAT | ||
15 | |||
16 | _DATA segment | ||
17 | inflate_fast_use_mmx: | ||
18 | dd 1 | ||
19 | |||
20 | |||
21 | _TEXT segment | ||
22 | PUBLIC _inflate_fast | ||
23 | |||
24 | ALIGN 4 | ||
25 | _inflate_fast: | ||
26 | jmp inflate_fast_entry | ||
27 | |||
28 | |||
29 | |||
30 | ALIGN 4 | ||
31 | db 'Fast decoding Code from Chris Anderson' | ||
32 | db 0 | ||
33 | |||
34 | ALIGN 4 | ||
35 | invalid_literal_length_code_msg: | ||
36 | db 'invalid literal/length code' | ||
37 | db 0 | ||
38 | |||
39 | ALIGN 4 | ||
40 | invalid_distance_code_msg: | ||
41 | db 'invalid distance code' | ||
42 | db 0 | ||
43 | |||
44 | ALIGN 4 | ||
45 | invalid_distance_too_far_msg: | ||
46 | db 'invalid distance too far back' | ||
47 | db 0 | ||
48 | |||
49 | |||
50 | ALIGN 4 | ||
51 | inflate_fast_mask: | ||
52 | dd 0 | ||
53 | dd 1 | ||
54 | dd 3 | ||
55 | dd 7 | ||
56 | dd 15 | ||
57 | dd 31 | ||
58 | dd 63 | ||
59 | dd 127 | ||
60 | dd 255 | ||
61 | dd 511 | ||
62 | dd 1023 | ||
63 | dd 2047 | ||
64 | dd 4095 | ||
65 | dd 8191 | ||
66 | dd 16383 | ||
67 | dd 32767 | ||
68 | dd 65535 | ||
69 | dd 131071 | ||
70 | dd 262143 | ||
71 | dd 524287 | ||
72 | dd 1048575 | ||
73 | dd 2097151 | ||
74 | dd 4194303 | ||
75 | dd 8388607 | ||
76 | dd 16777215 | ||
77 | dd 33554431 | ||
78 | dd 67108863 | ||
79 | dd 134217727 | ||
80 | dd 268435455 | ||
81 | dd 536870911 | ||
82 | dd 1073741823 | ||
83 | dd 2147483647 | ||
84 | dd 4294967295 | ||
85 | |||
86 | |||
87 | ;;SECTION .text | ||
88 | ; 205 "inffast.S" | ||
89 | ;GLOBAL inflate_fast_use_mmx | ||
90 | |||
91 | ;SECTION .data | ||
92 | |||
93 | |||
94 | ; GLOBAL inflate_fast_use_mmx:object | ||
95 | ;.size inflate_fast_use_mmx, 4 | ||
96 | ; 226 "inffast.S" | ||
97 | ;SECTION .text | ||
98 | |||
99 | ALIGN 4 | ||
100 | inflate_fast_entry: | ||
101 | push edi | ||
102 | push esi | ||
103 | push ebp | ||
104 | push ebx | ||
105 | pushfd | ||
106 | sub esp,64 | ||
107 | cld | ||
108 | |||
109 | |||
110 | |||
111 | |||
112 | mov esi, [esp+88] | ||
113 | mov edi, [esi+28] | ||
114 | |||
115 | |||
116 | |||
117 | |||
118 | |||
119 | |||
120 | |||
121 | mov edx, [esi+4] | ||
122 | mov eax, [esi+0] | ||
123 | |||
124 | add edx,eax | ||
125 | sub edx,11 | ||
126 | |||
127 | mov [esp+44],eax | ||
128 | mov [esp+20],edx | ||
129 | |||
130 | mov ebp, [esp+92] | ||
131 | mov ecx, [esi+16] | ||
132 | mov ebx, [esi+12] | ||
133 | |||
134 | sub ebp,ecx | ||
135 | neg ebp | ||
136 | add ebp,ebx | ||
137 | |||
138 | sub ecx,257 | ||
139 | add ecx,ebx | ||
140 | |||
141 | mov [esp+60],ebx | ||
142 | mov [esp+40],ebp | ||
143 | mov [esp+16],ecx | ||
144 | ; 285 "inffast.S" | ||
145 | mov eax, [edi+64] | ||
146 | mov ecx, [edi+68] | ||
147 | |||
148 | mov [esp+8],eax | ||
149 | mov [esp+12],ecx | ||
150 | |||
151 | mov eax,1 | ||
152 | mov ecx, [edi+72] | ||
153 | shl eax,cl | ||
154 | dec eax | ||
155 | mov [esp+0],eax | ||
156 | |||
157 | mov eax,1 | ||
158 | mov ecx, [edi+76] | ||
159 | shl eax,cl | ||
160 | dec eax | ||
161 | mov [esp+4],eax | ||
162 | |||
163 | mov eax, [edi+32] | ||
164 | mov ecx, [edi+36] | ||
165 | mov edx, [edi+40] | ||
166 | |||
167 | mov [esp+52],eax | ||
168 | mov [esp+48],ecx | ||
169 | mov [esp+56],edx | ||
170 | |||
171 | mov ebp, [edi+44] | ||
172 | mov ebx, [edi+48] | ||
173 | ; 321 "inffast.S" | ||
174 | mov esi, [esp+44] | ||
175 | mov ecx, [esp+20] | ||
176 | cmp ecx,esi | ||
177 | ja L_align_long | ||
178 | |||
179 | add ecx,11 | ||
180 | sub ecx,esi | ||
181 | mov eax,12 | ||
182 | sub eax,ecx | ||
183 | lea edi, [esp+28] | ||
184 | rep movsb | ||
185 | mov ecx,eax | ||
186 | xor eax,eax | ||
187 | rep stosb | ||
188 | lea esi, [esp+28] | ||
189 | mov [esp+20],esi | ||
190 | jmp L_is_aligned | ||
191 | |||
192 | |||
193 | L_align_long: | ||
194 | test esi,3 | ||
195 | jz L_is_aligned | ||
196 | xor eax,eax | ||
197 | mov al, [esi] | ||
198 | inc esi | ||
199 | mov ecx,ebx | ||
200 | add ebx,8 | ||
201 | shl eax,cl | ||
202 | or ebp,eax | ||
203 | jmp L_align_long | ||
204 | |||
205 | L_is_aligned: | ||
206 | mov edi, [esp+60] | ||
207 | ; 366 "inffast.S" | ||
208 | L_check_mmx: | ||
209 | cmp dword ptr [inflate_fast_use_mmx],2 | ||
210 | je L_init_mmx | ||
211 | ja L_do_loop | ||
212 | |||
213 | push eax | ||
214 | push ebx | ||
215 | push ecx | ||
216 | push edx | ||
217 | pushfd | ||
218 | mov eax, [esp] | ||
219 | xor dword ptr [esp],0200000h | ||
220 | |||
221 | |||
222 | |||
223 | |||
224 | popfd | ||
225 | pushfd | ||
226 | pop edx | ||
227 | xor edx,eax | ||
228 | jz L_dont_use_mmx | ||
229 | xor eax,eax | ||
230 | cpuid | ||
231 | cmp ebx,0756e6547h | ||
232 | jne L_dont_use_mmx | ||
233 | cmp ecx,06c65746eh | ||
234 | jne L_dont_use_mmx | ||
235 | cmp edx,049656e69h | ||
236 | jne L_dont_use_mmx | ||
237 | mov eax,1 | ||
238 | cpuid | ||
239 | shr eax,8 | ||
240 | and eax,15 | ||
241 | cmp eax,6 | ||
242 | jne L_dont_use_mmx | ||
243 | test edx,0800000h | ||
244 | jnz L_use_mmx | ||
245 | jmp L_dont_use_mmx | ||
246 | L_use_mmx: | ||
247 | mov dword ptr [inflate_fast_use_mmx],2 | ||
248 | jmp L_check_mmx_pop | ||
249 | L_dont_use_mmx: | ||
250 | mov dword ptr [inflate_fast_use_mmx],3 | ||
251 | L_check_mmx_pop: | ||
252 | pop edx | ||
253 | pop ecx | ||
254 | pop ebx | ||
255 | pop eax | ||
256 | jmp L_check_mmx | ||
257 | ; 426 "inffast.S" | ||
258 | ALIGN 4 | ||
259 | L_do_loop: | ||
260 | ; 437 "inffast.S" | ||
261 | cmp bl,15 | ||
262 | ja L_get_length_code | ||
263 | |||
264 | xor eax,eax | ||
265 | lodsw | ||
266 | mov cl,bl | ||
267 | add bl,16 | ||
268 | shl eax,cl | ||
269 | or ebp,eax | ||
270 | |||
271 | L_get_length_code: | ||
272 | mov edx, [esp+0] | ||
273 | mov ecx, [esp+8] | ||
274 | and edx,ebp | ||
275 | mov eax, [ecx+edx*4] | ||
276 | |||
277 | L_dolen: | ||
278 | |||
279 | |||
280 | |||
281 | |||
282 | |||
283 | |||
284 | mov cl,ah | ||
285 | sub bl,ah | ||
286 | shr ebp,cl | ||
287 | |||
288 | |||
289 | |||
290 | |||
291 | |||
292 | |||
293 | test al,al | ||
294 | jnz L_test_for_length_base | ||
295 | |||
296 | shr eax,16 | ||
297 | stosb | ||
298 | |||
299 | L_while_test: | ||
300 | |||
301 | |||
302 | cmp [esp+16],edi | ||
303 | jbe L_break_loop | ||
304 | |||
305 | cmp [esp+20],esi | ||
306 | ja L_do_loop | ||
307 | jmp L_break_loop | ||
308 | |||
309 | L_test_for_length_base: | ||
310 | ; 502 "inffast.S" | ||
311 | mov edx,eax | ||
312 | shr edx,16 | ||
313 | mov cl,al | ||
314 | |||
315 | test al,16 | ||
316 | jz L_test_for_second_level_length | ||
317 | and cl,15 | ||
318 | jz L_save_len | ||
319 | cmp bl,cl | ||
320 | jae L_add_bits_to_len | ||
321 | |||
322 | mov ch,cl | ||
323 | xor eax,eax | ||
324 | lodsw | ||
325 | mov cl,bl | ||
326 | add bl,16 | ||
327 | shl eax,cl | ||
328 | or ebp,eax | ||
329 | mov cl,ch | ||
330 | |||
331 | L_add_bits_to_len: | ||
332 | mov eax,1 | ||
333 | shl eax,cl | ||
334 | dec eax | ||
335 | sub bl,cl | ||
336 | and eax,ebp | ||
337 | shr ebp,cl | ||
338 | add edx,eax | ||
339 | |||
340 | L_save_len: | ||
341 | mov [esp+24],edx | ||
342 | |||
343 | |||
344 | L_decode_distance: | ||
345 | ; 549 "inffast.S" | ||
346 | cmp bl,15 | ||
347 | ja L_get_distance_code | ||
348 | |||
349 | xor eax,eax | ||
350 | lodsw | ||
351 | mov cl,bl | ||
352 | add bl,16 | ||
353 | shl eax,cl | ||
354 | or ebp,eax | ||
355 | |||
356 | L_get_distance_code: | ||
357 | mov edx, [esp+4] | ||
358 | mov ecx, [esp+12] | ||
359 | and edx,ebp | ||
360 | mov eax, [ecx+edx*4] | ||
361 | |||
362 | |||
363 | L_dodist: | ||
364 | mov edx,eax | ||
365 | shr edx,16 | ||
366 | mov cl,ah | ||
367 | sub bl,ah | ||
368 | shr ebp,cl | ||
369 | ; 584 "inffast.S" | ||
370 | mov cl,al | ||
371 | |||
372 | test al,16 | ||
373 | jz L_test_for_second_level_dist | ||
374 | and cl,15 | ||
375 | jz L_check_dist_one | ||
376 | cmp bl,cl | ||
377 | jae L_add_bits_to_dist | ||
378 | |||
379 | mov ch,cl | ||
380 | xor eax,eax | ||
381 | lodsw | ||
382 | mov cl,bl | ||
383 | add bl,16 | ||
384 | shl eax,cl | ||
385 | or ebp,eax | ||
386 | mov cl,ch | ||
387 | |||
388 | L_add_bits_to_dist: | ||
389 | mov eax,1 | ||
390 | shl eax,cl | ||
391 | dec eax | ||
392 | sub bl,cl | ||
393 | and eax,ebp | ||
394 | shr ebp,cl | ||
395 | add edx,eax | ||
396 | jmp L_check_window | ||
397 | |||
398 | L_check_window: | ||
399 | ; 625 "inffast.S" | ||
400 | mov [esp+44],esi | ||
401 | mov eax,edi | ||
402 | sub eax, [esp+40] | ||
403 | |||
404 | cmp eax,edx | ||
405 | jb L_clip_window | ||
406 | |||
407 | mov ecx, [esp+24] | ||
408 | mov esi,edi | ||
409 | sub esi,edx | ||
410 | |||
411 | sub ecx,3 | ||
412 | mov al, [esi] | ||
413 | mov [edi],al | ||
414 | mov al, [esi+1] | ||
415 | mov dl, [esi+2] | ||
416 | add esi,3 | ||
417 | mov [edi+1],al | ||
418 | mov [edi+2],dl | ||
419 | add edi,3 | ||
420 | rep movsb | ||
421 | |||
422 | mov esi, [esp+44] | ||
423 | jmp L_while_test | ||
424 | |||
425 | ALIGN 4 | ||
426 | L_check_dist_one: | ||
427 | cmp edx,1 | ||
428 | jne L_check_window | ||
429 | cmp [esp+40],edi | ||
430 | je L_check_window | ||
431 | |||
432 | dec edi | ||
433 | mov ecx, [esp+24] | ||
434 | mov al, [edi] | ||
435 | sub ecx,3 | ||
436 | |||
437 | mov [edi+1],al | ||
438 | mov [edi+2],al | ||
439 | mov [edi+3],al | ||
440 | add edi,4 | ||
441 | rep stosb | ||
442 | |||
443 | jmp L_while_test | ||
444 | |||
445 | ALIGN 4 | ||
446 | L_test_for_second_level_length: | ||
447 | |||
448 | |||
449 | |||
450 | |||
451 | test al,64 | ||
452 | jnz L_test_for_end_of_block | ||
453 | |||
454 | mov eax,1 | ||
455 | shl eax,cl | ||
456 | dec eax | ||
457 | and eax,ebp | ||
458 | add eax,edx | ||
459 | mov edx, [esp+8] | ||
460 | mov eax, [edx+eax*4] | ||
461 | jmp L_dolen | ||
462 | |||
463 | ALIGN 4 | ||
464 | L_test_for_second_level_dist: | ||
465 | |||
466 | |||
467 | |||
468 | |||
469 | test al,64 | ||
470 | jnz L_invalid_distance_code | ||
471 | |||
472 | mov eax,1 | ||
473 | shl eax,cl | ||
474 | dec eax | ||
475 | and eax,ebp | ||
476 | add eax,edx | ||
477 | mov edx, [esp+12] | ||
478 | mov eax, [edx+eax*4] | ||
479 | jmp L_dodist | ||
480 | |||
481 | ALIGN 4 | ||
482 | L_clip_window: | ||
483 | ; 721 "inffast.S" | ||
484 | mov ecx,eax | ||
485 | mov eax, [esp+52] | ||
486 | neg ecx | ||
487 | mov esi, [esp+56] | ||
488 | |||
489 | cmp eax,edx | ||
490 | jb L_invalid_distance_too_far | ||
491 | |||
492 | add ecx,edx | ||
493 | cmp dword ptr [esp+48],0 | ||
494 | jne L_wrap_around_window | ||
495 | |||
496 | sub eax,ecx | ||
497 | add esi,eax | ||
498 | ; 749 "inffast.S" | ||
499 | mov eax, [esp+24] | ||
500 | cmp eax,ecx | ||
501 | jbe L_do_copy1 | ||
502 | |||
503 | sub eax,ecx | ||
504 | rep movsb | ||
505 | mov esi,edi | ||
506 | sub esi,edx | ||
507 | jmp L_do_copy1 | ||
508 | |||
509 | cmp eax,ecx | ||
510 | jbe L_do_copy1 | ||
511 | |||
512 | sub eax,ecx | ||
513 | rep movsb | ||
514 | mov esi,edi | ||
515 | sub esi,edx | ||
516 | jmp L_do_copy1 | ||
517 | |||
518 | L_wrap_around_window: | ||
519 | ; 793 "inffast.S" | ||
520 | mov eax, [esp+48] | ||
521 | cmp ecx,eax | ||
522 | jbe L_contiguous_in_window | ||
523 | |||
524 | add esi, [esp+52] | ||
525 | add esi,eax | ||
526 | sub esi,ecx | ||
527 | sub ecx,eax | ||
528 | |||
529 | |||
530 | mov eax, [esp+24] | ||
531 | cmp eax,ecx | ||
532 | jbe L_do_copy1 | ||
533 | |||
534 | sub eax,ecx | ||
535 | rep movsb | ||
536 | mov esi, [esp+56] | ||
537 | mov ecx, [esp+48] | ||
538 | cmp eax,ecx | ||
539 | jbe L_do_copy1 | ||
540 | |||
541 | sub eax,ecx | ||
542 | rep movsb | ||
543 | mov esi,edi | ||
544 | sub esi,edx | ||
545 | jmp L_do_copy1 | ||
546 | |||
547 | L_contiguous_in_window: | ||
548 | ; 836 "inffast.S" | ||
549 | add esi,eax | ||
550 | sub esi,ecx | ||
551 | |||
552 | |||
553 | mov eax, [esp+24] | ||
554 | cmp eax,ecx | ||
555 | jbe L_do_copy1 | ||
556 | |||
557 | sub eax,ecx | ||
558 | rep movsb | ||
559 | mov esi,edi | ||
560 | sub esi,edx | ||
561 | |||
562 | L_do_copy1: | ||
563 | ; 862 "inffast.S" | ||
564 | mov ecx,eax | ||
565 | rep movsb | ||
566 | |||
567 | mov esi, [esp+44] | ||
568 | jmp L_while_test | ||
569 | ; 878 "inffast.S" | ||
570 | ALIGN 4 | ||
571 | L_init_mmx: | ||
572 | emms | ||
573 | |||
574 | |||
575 | |||
576 | |||
577 | |||
578 | movd mm0,ebp | ||
579 | mov ebp,ebx | ||
580 | ; 896 "inffast.S" | ||
581 | movd mm4,[esp+0] | ||
582 | movq mm3,mm4 | ||
583 | movd mm5,[esp+4] | ||
584 | movq mm2,mm5 | ||
585 | pxor mm1,mm1 | ||
586 | mov ebx, [esp+8] | ||
587 | jmp L_do_loop_mmx | ||
588 | |||
589 | ALIGN 4 | ||
590 | L_do_loop_mmx: | ||
591 | psrlq mm0,mm1 | ||
592 | |||
593 | cmp ebp,32 | ||
594 | ja L_get_length_code_mmx | ||
595 | |||
596 | movd mm6,ebp | ||
597 | movd mm7,[esi] | ||
598 | add esi,4 | ||
599 | psllq mm7,mm6 | ||
600 | add ebp,32 | ||
601 | por mm0,mm7 | ||
602 | |||
603 | L_get_length_code_mmx: | ||
604 | pand mm4,mm0 | ||
605 | movd eax,mm4 | ||
606 | movq mm4,mm3 | ||
607 | mov eax, [ebx+eax*4] | ||
608 | |||
609 | L_dolen_mmx: | ||
610 | movzx ecx,ah | ||
611 | movd mm1,ecx | ||
612 | sub ebp,ecx | ||
613 | |||
614 | test al,al | ||
615 | jnz L_test_for_length_base_mmx | ||
616 | |||
617 | shr eax,16 | ||
618 | stosb | ||
619 | |||
620 | L_while_test_mmx: | ||
621 | |||
622 | |||
623 | cmp [esp+16],edi | ||
624 | jbe L_break_loop | ||
625 | |||
626 | cmp [esp+20],esi | ||
627 | ja L_do_loop_mmx | ||
628 | jmp L_break_loop | ||
629 | |||
630 | L_test_for_length_base_mmx: | ||
631 | |||
632 | mov edx,eax | ||
633 | shr edx,16 | ||
634 | |||
635 | test al,16 | ||
636 | jz L_test_for_second_level_length_mmx | ||
637 | and eax,15 | ||
638 | jz L_decode_distance_mmx | ||
639 | |||
640 | psrlq mm0,mm1 | ||
641 | movd mm1,eax | ||
642 | movd ecx,mm0 | ||
643 | sub ebp,eax | ||
644 | and ecx, [inflate_fast_mask+eax*4] | ||
645 | add edx,ecx | ||
646 | |||
647 | L_decode_distance_mmx: | ||
648 | psrlq mm0,mm1 | ||
649 | |||
650 | cmp ebp,32 | ||
651 | ja L_get_dist_code_mmx | ||
652 | |||
653 | movd mm6,ebp | ||
654 | movd mm7,[esi] | ||
655 | add esi,4 | ||
656 | psllq mm7,mm6 | ||
657 | add ebp,32 | ||
658 | por mm0,mm7 | ||
659 | |||
660 | L_get_dist_code_mmx: | ||
661 | mov ebx, [esp+12] | ||
662 | pand mm5,mm0 | ||
663 | movd eax,mm5 | ||
664 | movq mm5,mm2 | ||
665 | mov eax, [ebx+eax*4] | ||
666 | |||
667 | L_dodist_mmx: | ||
668 | |||
669 | movzx ecx,ah | ||
670 | mov ebx,eax | ||
671 | shr ebx,16 | ||
672 | sub ebp,ecx | ||
673 | movd mm1,ecx | ||
674 | |||
675 | test al,16 | ||
676 | jz L_test_for_second_level_dist_mmx | ||
677 | and eax,15 | ||
678 | jz L_check_dist_one_mmx | ||
679 | |||
680 | L_add_bits_to_dist_mmx: | ||
681 | psrlq mm0,mm1 | ||
682 | movd mm1,eax | ||
683 | movd ecx,mm0 | ||
684 | sub ebp,eax | ||
685 | and ecx, [inflate_fast_mask+eax*4] | ||
686 | add ebx,ecx | ||
687 | |||
688 | L_check_window_mmx: | ||
689 | mov [esp+44],esi | ||
690 | mov eax,edi | ||
691 | sub eax, [esp+40] | ||
692 | |||
693 | cmp eax,ebx | ||
694 | jb L_clip_window_mmx | ||
695 | |||
696 | mov ecx,edx | ||
697 | mov esi,edi | ||
698 | sub esi,ebx | ||
699 | |||
700 | sub ecx,3 | ||
701 | mov al, [esi] | ||
702 | mov [edi],al | ||
703 | mov al, [esi+1] | ||
704 | mov dl, [esi+2] | ||
705 | add esi,3 | ||
706 | mov [edi+1],al | ||
707 | mov [edi+2],dl | ||
708 | add edi,3 | ||
709 | rep movsb | ||
710 | |||
711 | mov esi, [esp+44] | ||
712 | mov ebx, [esp+8] | ||
713 | jmp L_while_test_mmx | ||
714 | |||
715 | ALIGN 4 | ||
716 | L_check_dist_one_mmx: | ||
717 | cmp ebx,1 | ||
718 | jne L_check_window_mmx | ||
719 | cmp [esp+40],edi | ||
720 | je L_check_window_mmx | ||
721 | |||
722 | dec edi | ||
723 | mov ecx,edx | ||
724 | mov al, [edi] | ||
725 | sub ecx,3 | ||
726 | |||
727 | mov [edi+1],al | ||
728 | mov [edi+2],al | ||
729 | mov [edi+3],al | ||
730 | add edi,4 | ||
731 | rep stosb | ||
732 | |||
733 | mov ebx, [esp+8] | ||
734 | jmp L_while_test_mmx | ||
735 | |||
736 | ALIGN 4 | ||
737 | L_test_for_second_level_length_mmx: | ||
738 | test al,64 | ||
739 | jnz L_test_for_end_of_block | ||
740 | |||
741 | and eax,15 | ||
742 | psrlq mm0,mm1 | ||
743 | movd ecx,mm0 | ||
744 | and ecx, [inflate_fast_mask+eax*4] | ||
745 | add ecx,edx | ||
746 | mov eax, [ebx+ecx*4] | ||
747 | jmp L_dolen_mmx | ||
748 | |||
749 | ALIGN 4 | ||
750 | L_test_for_second_level_dist_mmx: | ||
751 | test al,64 | ||
752 | jnz L_invalid_distance_code | ||
753 | |||
754 | and eax,15 | ||
755 | psrlq mm0,mm1 | ||
756 | movd ecx,mm0 | ||
757 | and ecx, [inflate_fast_mask+eax*4] | ||
758 | mov eax, [esp+12] | ||
759 | add ecx,ebx | ||
760 | mov eax, [eax+ecx*4] | ||
761 | jmp L_dodist_mmx | ||
762 | |||
763 | ALIGN 4 | ||
764 | L_clip_window_mmx: | ||
765 | |||
766 | mov ecx,eax | ||
767 | mov eax, [esp+52] | ||
768 | neg ecx | ||
769 | mov esi, [esp+56] | ||
770 | |||
771 | cmp eax,ebx | ||
772 | jb L_invalid_distance_too_far | ||
773 | |||
774 | add ecx,ebx | ||
775 | cmp dword ptr [esp+48],0 | ||
776 | jne L_wrap_around_window_mmx | ||
777 | |||
778 | sub eax,ecx | ||
779 | add esi,eax | ||
780 | |||
781 | cmp edx,ecx | ||
782 | jbe L_do_copy1_mmx | ||
783 | |||
784 | sub edx,ecx | ||
785 | rep movsb | ||
786 | mov esi,edi | ||
787 | sub esi,ebx | ||
788 | jmp L_do_copy1_mmx | ||
789 | |||
790 | cmp edx,ecx | ||
791 | jbe L_do_copy1_mmx | ||
792 | |||
793 | sub edx,ecx | ||
794 | rep movsb | ||
795 | mov esi,edi | ||
796 | sub esi,ebx | ||
797 | jmp L_do_copy1_mmx | ||
798 | |||
799 | L_wrap_around_window_mmx: | ||
800 | |||
801 | mov eax, [esp+48] | ||
802 | cmp ecx,eax | ||
803 | jbe L_contiguous_in_window_mmx | ||
804 | |||
805 | add esi, [esp+52] | ||
806 | add esi,eax | ||
807 | sub esi,ecx | ||
808 | sub ecx,eax | ||
809 | |||
810 | |||
811 | cmp edx,ecx | ||
812 | jbe L_do_copy1_mmx | ||
813 | |||
814 | sub edx,ecx | ||
815 | rep movsb | ||
816 | mov esi, [esp+56] | ||
817 | mov ecx, [esp+48] | ||
818 | cmp edx,ecx | ||
819 | jbe L_do_copy1_mmx | ||
820 | |||
821 | sub edx,ecx | ||
822 | rep movsb | ||
823 | mov esi,edi | ||
824 | sub esi,ebx | ||
825 | jmp L_do_copy1_mmx | ||
826 | |||
827 | L_contiguous_in_window_mmx: | ||
828 | |||
829 | add esi,eax | ||
830 | sub esi,ecx | ||
831 | |||
832 | |||
833 | cmp edx,ecx | ||
834 | jbe L_do_copy1_mmx | ||
835 | |||
836 | sub edx,ecx | ||
837 | rep movsb | ||
838 | mov esi,edi | ||
839 | sub esi,ebx | ||
840 | |||
841 | L_do_copy1_mmx: | ||
842 | |||
843 | |||
844 | mov ecx,edx | ||
845 | rep movsb | ||
846 | |||
847 | mov esi, [esp+44] | ||
848 | mov ebx, [esp+8] | ||
849 | jmp L_while_test_mmx | ||
850 | ; 1174 "inffast.S" | ||
851 | L_invalid_distance_code: | ||
852 | |||
853 | |||
854 | |||
855 | |||
856 | |||
857 | mov ecx, invalid_distance_code_msg | ||
858 | mov edx,26 | ||
859 | jmp L_update_stream_state | ||
860 | |||
861 | L_test_for_end_of_block: | ||
862 | |||
863 | |||
864 | |||
865 | |||
866 | |||
867 | test al,32 | ||
868 | jz L_invalid_literal_length_code | ||
869 | |||
870 | mov ecx,0 | ||
871 | mov edx,11 | ||
872 | jmp L_update_stream_state | ||
873 | |||
874 | L_invalid_literal_length_code: | ||
875 | |||
876 | |||
877 | |||
878 | |||
879 | |||
880 | mov ecx, invalid_literal_length_code_msg | ||
881 | mov edx,26 | ||
882 | jmp L_update_stream_state | ||
883 | |||
884 | L_invalid_distance_too_far: | ||
885 | |||
886 | |||
887 | |||
888 | mov esi, [esp+44] | ||
889 | mov ecx, invalid_distance_too_far_msg | ||
890 | mov edx,26 | ||
891 | jmp L_update_stream_state | ||
892 | |||
893 | L_update_stream_state: | ||
894 | |||
895 | mov eax, [esp+88] | ||
896 | test ecx,ecx | ||
897 | jz L_skip_msg | ||
898 | mov [eax+24],ecx | ||
899 | L_skip_msg: | ||
900 | mov eax, [eax+28] | ||
901 | mov [eax+0],edx | ||
902 | jmp L_break_loop | ||
903 | |||
904 | ALIGN 4 | ||
905 | L_break_loop: | ||
906 | ; 1243 "inffast.S" | ||
907 | cmp dword ptr [inflate_fast_use_mmx],2 | ||
908 | jne L_update_next_in | ||
909 | |||
910 | |||
911 | |||
912 | mov ebx,ebp | ||
913 | |||
914 | L_update_next_in: | ||
915 | ; 1266 "inffast.S" | ||
916 | mov eax, [esp+88] | ||
917 | mov ecx,ebx | ||
918 | mov edx, [eax+28] | ||
919 | shr ecx,3 | ||
920 | sub esi,ecx | ||
921 | shl ecx,3 | ||
922 | sub ebx,ecx | ||
923 | mov [eax+12],edi | ||
924 | mov [edx+48],ebx | ||
925 | mov ecx,ebx | ||
926 | |||
927 | lea ebx, [esp+28] | ||
928 | cmp [esp+20],ebx | ||
929 | jne L_buf_not_used | ||
930 | |||
931 | sub esi,ebx | ||
932 | mov ebx, [eax+0] | ||
933 | mov [esp+20],ebx | ||
934 | add esi,ebx | ||
935 | mov ebx, [eax+4] | ||
936 | sub ebx,11 | ||
937 | add [esp+20],ebx | ||
938 | |||
939 | L_buf_not_used: | ||
940 | mov [eax+0],esi | ||
941 | |||
942 | mov ebx,1 | ||
943 | shl ebx,cl | ||
944 | dec ebx | ||
945 | |||
946 | |||
947 | |||
948 | |||
949 | |||
950 | cmp dword ptr [inflate_fast_use_mmx],2 | ||
951 | jne L_update_hold | ||
952 | |||
953 | |||
954 | |||
955 | psrlq mm0,mm1 | ||
956 | movd ebp,mm0 | ||
957 | |||
958 | emms | ||
959 | |||
960 | L_update_hold: | ||
961 | |||
962 | |||
963 | |||
964 | and ebp,ebx | ||
965 | mov [edx+44],ebp | ||
966 | |||
967 | |||
968 | |||
969 | |||
970 | mov ebx, [esp+20] | ||
971 | cmp ebx,esi | ||
972 | jbe L_last_is_smaller | ||
973 | |||
974 | sub ebx,esi | ||
975 | add ebx,11 | ||
976 | mov [eax+4],ebx | ||
977 | jmp L_fixup_out | ||
978 | L_last_is_smaller: | ||
979 | sub esi,ebx | ||
980 | neg esi | ||
981 | add esi,11 | ||
982 | mov [eax+4],esi | ||
983 | |||
984 | |||
985 | |||
986 | |||
987 | L_fixup_out: | ||
988 | |||
989 | mov ebx, [esp+16] | ||
990 | cmp ebx,edi | ||
991 | jbe L_end_is_smaller | ||
992 | |||
993 | sub ebx,edi | ||
994 | add ebx,257 | ||
995 | mov [eax+16],ebx | ||
996 | jmp L_done | ||
997 | L_end_is_smaller: | ||
998 | sub edi,ebx | ||
999 | neg edi | ||
1000 | add edi,257 | ||
1001 | mov [eax+16],edi | ||
1002 | |||
1003 | |||
1004 | |||
1005 | |||
1006 | |||
1007 | L_done: | ||
1008 | add esp,64 | ||
1009 | popfd | ||
1010 | pop ebx | ||
1011 | pop ebp | ||
1012 | pop esi | ||
1013 | pop edi | ||
1014 | ret | ||
1015 | |||
1016 | |||
1017 | |||
1018 | |||
1019 | _TEXT ends | ||
1020 | end | ||
diff --git a/contrib/vstudio/vc70_32/inffastAsm.obj b/contrib/vstudio/vc70_32/inffastAsm.obj deleted file mode 100644 index 3855400..0000000 --- a/contrib/vstudio/vc70_32/inffastAsm.obj +++ /dev/null | |||
Binary files differ | |||
diff --git a/contrib/vstudio/vc70_32/mkgvmt32.bat b/contrib/vstudio/vc70_32/mkgvmt32.bat deleted file mode 100644 index 9c54db7..0000000 --- a/contrib/vstudio/vc70_32/mkgvmt32.bat +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | c:\masm611\bin\ml /coff /Zi /c /Flgvmat32.lst gvmat32.asm | ||
2 | c:\masm611\bin\ml /coff /Zi /c /FlinffastAsm.lst inffastAsm.asm | ||
diff --git a/contrib/zlib_dll_FAQ.txt b/contrib/zlib_dll_FAQ.txt deleted file mode 100644 index bc1fd59..0000000 --- a/contrib/zlib_dll_FAQ.txt +++ /dev/null | |||
@@ -1,257 +0,0 @@ | |||
1 | |||
2 | Frequently Asked Questions about ZLIB.DLL | ||
3 | |||
4 | |||
5 | This FAQ is about the design, the rationale, and the use of | ||
6 | ZLIB.DLL. If you have general questions about zlib, you should | ||
7 | check the file "FAQ" found in the zlib distribution, or at the | ||
8 | location http://www.gzip.org/zlib/zlib_faq.html | ||
9 | |||
10 | |||
11 | 1. Why am I having problems using ZLIB.DLL? My application works | ||
12 | with the static build of zlib just fine, and I didn't make any | ||
13 | modification when recompiling it for ZLIB.DLL. | ||
14 | |||
15 | - Make sure you define ZLIB_DLL before including "zlib.h". | ||
16 | Applications that link to ZLIB.DLL will work properly if | ||
17 | the source files are compiled in this (or in a compatible) | ||
18 | way, and the executables are linked to MSVCRT.DLL. | ||
19 | |||
20 | |||
21 | 2. Why do I have to do this? When I use other libraries, I can | ||
22 | link my code to their static or dynamic versions, without | ||
23 | needing any source code modification or recompilation. | ||
24 | |||
25 | - In order to preserve the backwards compatibility with the | ||
26 | older versions of ZLIB.DLL, and give the ability to use zlib | ||
27 | to the non-C programmers at the same time, we had to do this | ||
28 | compromise. | ||
29 | |||
30 | |||
31 | 3. What exactly is this mess about, and why is it happening? | ||
32 | |||
33 | - It's about the calling convention used for the zlib functions. | ||
34 | If linked in statically, zlib uses the C (CDECL) convention. | ||
35 | If linked in dynamically (via ZLIB.DLL), it uses the STDCALL | ||
36 | convention. The ZLIB_DLL macro switches on the use of STDCALL. | ||
37 | |||
38 | It happens because we need to preserve compatibility with the | ||
39 | old releases of ZLIB.DLL that use STDCALL, and, at the same | ||
40 | time, we must provide support for programmers who use other | ||
41 | programming languages with bindings that require CDECL. | ||
42 | |||
43 | |||
44 | 4. Why not use the STDCALL convention all the time? | ||
45 | It's the standard convention in Win32, and I need it in my | ||
46 | Visual Basic project! | ||
47 | |||
48 | - Most of the Win32 API functions (without varargs) use indeed | ||
49 | the STDCALL (WINAPI) convention, but the standard C functions | ||
50 | use the default CDECL. If one calls Win32 functions such as | ||
51 | CreateFile(), sometimes it makes sense to decorate one's own | ||
52 | functions with STDCALL. But if one is aiming at ANSI C or | ||
53 | POSIX portability, and calls functions such as fopen(), it is | ||
54 | not a sound decision to include <windows.h> or to use non-ANSI | ||
55 | constructs only to make one's functions STDCALL-able. This is | ||
56 | not the biggest problem, however. | ||
57 | |||
58 | Technically, STDCALL is not bad; it is even a little faster | ||
59 | than CDECL. The problem of using STDCALL is actually a problem | ||
60 | of using any explicit calling convention. FASTCALL falls into | ||
61 | the same category. | ||
62 | |||
63 | Explicit specification of calling conventions, whether it's | ||
64 | direct or indirect via a macro, happens commonly in Windows, | ||
65 | but it is regarded as a noisy, non-standard C quirk on other | ||
66 | platforms. It isn't possible to write an ANSI C -conforming | ||
67 | program, for example, if it is necessary to specify calling | ||
68 | conventions. Libraries can hide the dirty stuff in header | ||
69 | files, under macros, but callbacks will still remain exposed. | ||
70 | This is why the zlib callbacks will not be decorated. | ||
71 | (The old Windows callbacks, such as WndProc, are decorated, | ||
72 | but the newer ones are not.) | ||
73 | |||
74 | There is one more problem with explicit, non-default calling | ||
75 | conventions: the ability to use zlib in other programming | ||
76 | languages. Some of them, like Ada (GNAT) and Fortran (GNU G77) | ||
77 | have C bindings implemented initially on Unix, hence relying | ||
78 | on the C calling convention. | ||
79 | |||
80 | So we are decorating the functions using STDCALL in ZLIB.DLL | ||
81 | to maintain compatibility with the old versions, but we are | ||
82 | using the default CDECL in the static library, to allow other | ||
83 | programming languages to use zlib in a portable fashion, via | ||
84 | C bindings. | ||
85 | |||
86 | |||
87 | 5. Why not use the default (CDECL) convention all the time? | ||
88 | It's the standard convention in C, and I need it in my Ada | ||
89 | project! | ||
90 | |||
91 | - Originally, ZLIB.DLL was intended to run under Visual Basic, | ||
92 | and VB6 and earlier need STDCALL. | ||
93 | |||
94 | We admit that cluttering the main zlib sources, for the sake | ||
95 | of interfacing with Visual Basic and at the expense of other | ||
96 | programming languages, is not fair. It would have been better | ||
97 | to maintain a "VB-only" project in the contrib/ directory, and | ||
98 | to build a custom ZLIBVB.DLL, for example -- as we did with | ||
99 | the Delphi projects. Another possible solution would have been | ||
100 | to build STDCALL wrappers around the CDECL-exported functions. | ||
101 | |||
102 | But this was the accident that we have to live with, in order | ||
103 | to maintain binary compatibility with the older versions of | ||
104 | ZLIB.DLL. | ||
105 | |||
106 | |||
107 | 6. If my application uses ZLIB.DLL, do I have to link it to | ||
108 | MSVCRT.DLL? Why? | ||
109 | |||
110 | - The executables (.EXE, .DLL, etc.) that are involved in the | ||
111 | same process and are using the C run-time library (i.e. they | ||
112 | are calling any standard C function), must link to the same | ||
113 | library. There are several libraries in the Win32 system: | ||
114 | CRTDLL.DLL, MSVCRT.DLL, the static C libraries, etc. | ||
115 | Since ZLIB.DLL is linked to MSVCRT.DLL, the executables that | ||
116 | depend on it must also link to MSVCRT.DLL. | ||
117 | |||
118 | |||
119 | 7. Why are you saying that ZLIB.DLL and my application must be | ||
120 | linked to the same C run-time library (CRT)? I linked my | ||
121 | application and my DLLs to different C libraries (e.g. my | ||
122 | application to a static library, and my DLLs to MSVCRT.DLL), | ||
123 | and everything works fine. | ||
124 | |||
125 | - If a library invokes only pure Win32 API (i.e. accessible | ||
126 | via <windows.h>), its DLL build will work in any context. | ||
127 | But if a library invokes standard C functions, things get | ||
128 | more complicated. | ||
129 | |||
130 | There is a single Win32 library in a Win32 system. Every | ||
131 | function in this library resides in a single DLL module, that | ||
132 | is safe to call from anywhere. On the other hand, there are | ||
133 | multiple versions of the C library that are all at the same | ||
134 | time in the system, and all of them have internal states, | ||
135 | therefore it is dangerous to intermix them with each other. | ||
136 | |||
137 | Intermixing multiple C libraries is possible, as long as their | ||
138 | internal states are kept intact. The Microsoft Knowledge Base | ||
139 | article Q140584 "HOWTO: Link with the Correct C Run-Time (CRT) | ||
140 | Library" enumerates some of the potential problems raised by | ||
141 | intermixing, but does not offer a complete description of how | ||
142 | to avoid them, except by advising not to mix the C libraries. | ||
143 | If you can send us more information about this issue, we will | ||
144 | highly appreciate it. (But please do NOT send us source code | ||
145 | from Microsoft, even if it comes with your legitimate copy of | ||
146 | Visual C++!) | ||
147 | |||
148 | If this kind of intermixing works for you, it's because your | ||
149 | application and DLLs are avoiding the corruption of the CRT's | ||
150 | internal states, due to a fortunate accident. It's not because | ||
151 | those libraries really work together. | ||
152 | |||
153 | Also note that linking ZLIB.DLL to non-Microsoft C libraries | ||
154 | (such as Borland's) raises similar problems. | ||
155 | |||
156 | |||
157 | 8. Why are you linking ZLIB.DLL to MSVCRT.DLL? | ||
158 | |||
159 | - MSVCRT.DLL exists on every Windows 95 with a new service pack | ||
160 | installed, or with Microsoft Internet Explorer 4 or later, and | ||
161 | on all other Windows 4.x or later (Windows 98, Windows NT 4, | ||
162 | or later). It is freely distributable; if not present in the | ||
163 | system, it can be downloaded from Microsoft or from other | ||
164 | software provider for free. | ||
165 | |||
166 | The fact that MSVCRT.DLL does not exist on a virgin Windows 95 | ||
167 | is not so problematic. The number of Windows 95 installations | ||
168 | is rapidly decreasing, Microsoft stopped supporting it a long | ||
169 | time ago, and many recent applications from various vendors | ||
170 | including Microsoft, do not even run on it. Even without these | ||
171 | arguments, no serious user should run Windows 95 without a | ||
172 | proper update installed. | ||
173 | |||
174 | There is also the fact that the mainstream C compilers for | ||
175 | Windows are Microsoft Visual C++ 6.0, and gcc/MinGW. Both | ||
176 | are producing executables that link to MSVCRT.DLL by default, | ||
177 | without offering other dynamic CRTs as alternatives easy to | ||
178 | select by users. | ||
179 | |||
180 | |||
181 | 9. Why are you not linking ZLIB.DLL to | ||
182 | <<my favorite C run-time library>> ? | ||
183 | |||
184 | - We considered and abandoned the following alternatives: | ||
185 | |||
186 | * Linking ZLIB.DLL to a static C library (LIBC.LIB, or | ||
187 | LIBCMT.LIB) is not a good option. People are using ZLIB.DLL | ||
188 | mainly to save disk space. If you are linking your program | ||
189 | to a static C library, you may as well consider linking zlib | ||
190 | in statically, too. | ||
191 | |||
192 | * Linking ZLIB.DLL to CRTDLL.DLL looks very appealing, | ||
193 | because CRTDLL.DLL is present on every Win32 installation. | ||
194 | Unfortunately, it has a series of problems: it raises | ||
195 | difficulties when linking to the Microsoft C++ libraries, | ||
196 | it is not thread-safe, and Microsoft has discontinued its | ||
197 | support a long time ago. | ||
198 | |||
199 | * Linking ZLIB.DLL to MSVCRT70.DLL, supplied with the | ||
200 | Microsoft .NET platform and Visual C++ 7.0, is not a good | ||
201 | option. Although it can be downloaded and distributed | ||
202 | freely, it is hardly present on today's Win32 installations. | ||
203 | If it will become more popular than MSVCRT.DLL, and will be | ||
204 | pre-installed on the future Win32 systems, we will probably | ||
205 | think again about it. | ||
206 | |||
207 | * Linking ZLIB.DLL to NTDLL.DLL is not possible. | ||
208 | NTDLL.DLL exports only a part of the C library, and only | ||
209 | on Windows NT systems. | ||
210 | |||
211 | |||
212 | 10. I understand your reasons. However, my project needs ZLIB.DLL | ||
213 | linked to something different than MSVCRT.DLL. What can I do? | ||
214 | |||
215 | Feel free to rebuild this DLL from the zlib sources, and link | ||
216 | it the way you want. It is required, however, to clearly | ||
217 | state that your build is unofficial. Another thing that is not | ||
218 | required, but highly recommended, is to name that custom DLL | ||
219 | differently, and/or to install it in a private directory that | ||
220 | can be accessed by your application, but is not visible to the | ||
221 | others (e.g. it's not the SYSTEM or the SYSTEM32 directory, | ||
222 | and it's not in the PATH). Otherwise, your build may clash | ||
223 | with applications that link to the official build. | ||
224 | |||
225 | For example, in Cygwin, zlib is linked to their runtime | ||
226 | CYGWIN1.DLL, and it is distributed under the name CYGZ.DLL. | ||
227 | |||
228 | |||
229 | 11. My I include additional pieces of code that I find useful, | ||
230 | link them in ZLIB.DLL, and export them? | ||
231 | |||
232 | No. A legitimate build of ZLIB.DLL must not include code that | ||
233 | does not originate from the official zlib sources. But you can | ||
234 | make your own private build, and give it a different name, as | ||
235 | suggested in the previous answer. | ||
236 | |||
237 | For example, in Borland Delphi and C++ Builder, zlib is part | ||
238 | of the standard VCL library. If an application links to VCL | ||
239 | dynamically, the name of the distributable binary (VCLxx.DLL) | ||
240 | does not posess any danger of clashing with a legitimate but | ||
241 | incompatible ZLIB.DLL. | ||
242 | |||
243 | |||
244 | 12. I see that I may have all kinds of problems if I use ZLIB.DLL. | ||
245 | Do you recommend to link zlib in statically? Do I get rid of | ||
246 | problems? | ||
247 | |||
248 | - Yes, definitely. In fact, unless you are distributing a large | ||
249 | number of executables, each of them linking to zlib, you will | ||
250 | save space by linking zlib in statically (assuming that you | ||
251 | would otherwise distribute ZLIB.DLL with your application). | ||
252 | zlib is not a big library, and the space saved by ZLIB.DLL is | ||
253 | little. Much of the actual size of the DLL is due to the 4KB | ||
254 | alignment in the binary. | ||
255 | |||
256 | But you may have reasons, other than size, to use the DLL. | ||
257 | That is entirely up to you. | ||
@@ -5,8 +5,8 @@ | |||
5 | * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster | 5 | * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster |
6 | * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing | 6 | * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing |
7 | * tables for updating the shift register in one step with three exclusive-ors | 7 | * tables for updating the shift register in one step with three exclusive-ors |
8 | * instead of four steps with four exclusive-ors. This results about a 50% | 8 | * instead of four steps with four exclusive-ors. This results about a factor |
9 | * increase in speed on a Power PC using gcc -O3. | 9 | * of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | /* @(#) $Id$ */ | 12 | /* @(#) $Id$ */ |
@@ -18,7 +18,7 @@ | |||
18 | # endif /* !DYNAMIC_CRC_TABLE */ | 18 | # endif /* !DYNAMIC_CRC_TABLE */ |
19 | #endif /* MAKECRCH */ | 19 | #endif /* MAKECRCH */ |
20 | 20 | ||
21 | #include "zutil.h" /* for STDC and FAR definitions */ | 21 | #include "zutil.h" /* for STDC and FAR definitions */ |
22 | 22 | ||
23 | #define local static | 23 | #define local static |
24 | 24 | ||
@@ -203,7 +203,7 @@ unsigned long ZEXPORT crc32(crc, buf, len) | |||
203 | #endif /* DYNAMIC_CRC_TABLE */ | 203 | #endif /* DYNAMIC_CRC_TABLE */ |
204 | 204 | ||
205 | #ifdef BYFOUR | 205 | #ifdef BYFOUR |
206 | { | 206 | if (sizeof(void *) == sizeof(ptrdiff_t)) { |
207 | u4 endian; | 207 | u4 endian; |
208 | 208 | ||
209 | endian = 1; | 209 | endian = 1; |
@@ -212,7 +212,7 @@ unsigned long ZEXPORT crc32(crc, buf, len) | |||
212 | else | 212 | else |
213 | return crc32_big(crc, buf, len); | 213 | return crc32_big(crc, buf, len); |
214 | } | 214 | } |
215 | #else /* !BYFOUR */ | 215 | #endif /* BYFOUR */ |
216 | crc = crc ^ 0xffffffffUL; | 216 | crc = crc ^ 0xffffffffUL; |
217 | while (len >= 8) { | 217 | while (len >= 8) { |
218 | DO8; | 218 | DO8; |
@@ -222,7 +222,6 @@ unsigned long ZEXPORT crc32(crc, buf, len) | |||
222 | DO1; | 222 | DO1; |
223 | } while (--len); | 223 | } while (--len); |
224 | return crc ^ 0xffffffffUL; | 224 | return crc ^ 0xffffffffUL; |
225 | #endif /* BYFOUR */ | ||
226 | } | 225 | } |
227 | 226 | ||
228 | #ifdef BYFOUR | 227 | #ifdef BYFOUR |
@@ -244,7 +243,7 @@ local unsigned long crc32_little(crc, buf, len) | |||
244 | 243 | ||
245 | c = (u4)crc; | 244 | c = (u4)crc; |
246 | c = ~c; | 245 | c = ~c; |
247 | while (len && ((size_t)buf & 3)) { | 246 | while (len && ((ptrdiff_t)buf & 3)) { |
248 | c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); | 247 | c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); |
249 | len--; | 248 | len--; |
250 | } | 249 | } |
@@ -284,7 +283,7 @@ local unsigned long crc32_big(crc, buf, len) | |||
284 | 283 | ||
285 | c = REV((u4)crc); | 284 | c = REV((u4)crc); |
286 | c = ~c; | 285 | c = ~c; |
287 | while (len && ((size_t)buf & 3)) { | 286 | while (len && ((ptrdiff_t)buf & 3)) { |
288 | c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); | 287 | c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); |
289 | len--; | 288 | len--; |
290 | } | 289 | } |
@@ -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.2.0.4 Copyright 1995-2003 Jean-loup Gailly "; | 55 | " deflate 1.2.0.5 Copyright 1995-2003 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 |
@@ -188,7 +188,7 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ | |||
188 | #else | 188 | #else |
189 | #define INSERT_STRING(s, str, match_head) \ | 189 | #define INSERT_STRING(s, str, match_head) \ |
190 | (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ | 190 | (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ |
191 | s->prev[(str) & s->w_mask] = match_head = s->head[s->ins_h], \ | 191 | match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ |
192 | s->head[s->ins_h] = (Pos)(str)) | 192 | s->head[s->ins_h] = (Pos)(str)) |
193 | #endif | 193 | #endif |
194 | 194 | ||
@@ -240,11 +240,11 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, | |||
240 | if (strm == Z_NULL) return Z_STREAM_ERROR; | 240 | if (strm == Z_NULL) return Z_STREAM_ERROR; |
241 | 241 | ||
242 | strm->msg = Z_NULL; | 242 | strm->msg = Z_NULL; |
243 | if (strm->zalloc == Z_NULL) { | 243 | if (strm->zalloc == (alloc_func)0) { |
244 | strm->zalloc = zcalloc; | 244 | strm->zalloc = zcalloc; |
245 | strm->opaque = (voidpf)0; | 245 | strm->opaque = (voidpf)0; |
246 | } | 246 | } |
247 | if (strm->zfree == Z_NULL) strm->zfree = zcfree; | 247 | if (strm->zfree == (free_func)0) strm->zfree = zcfree; |
248 | 248 | ||
249 | #ifdef FASTEST | 249 | #ifdef FASTEST |
250 | if (level != 0) level = 1; | 250 | if (level != 0) level = 1; |
@@ -258,7 +258,7 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, | |||
258 | } | 258 | } |
259 | #ifdef GZIP | 259 | #ifdef GZIP |
260 | else if (windowBits > 15) { | 260 | else if (windowBits > 15) { |
261 | wrap = 2; /* write gzip wrapper instead */ | 261 | wrap = 2; /* write gzip wrapper instead */ |
262 | windowBits -= 16; | 262 | windowBits -= 16; |
263 | } | 263 | } |
264 | #endif | 264 | #endif |
@@ -361,7 +361,9 @@ int ZEXPORT deflateReset (strm) | |||
361 | deflate_state *s; | 361 | deflate_state *s; |
362 | 362 | ||
363 | if (strm == Z_NULL || strm->state == Z_NULL || | 363 | if (strm == Z_NULL || strm->state == Z_NULL || |
364 | strm->zalloc == Z_NULL || strm->zfree == Z_NULL) return Z_STREAM_ERROR; | 364 | strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) { |
365 | return Z_STREAM_ERROR; | ||
366 | } | ||
365 | 367 | ||
366 | strm->total_in = strm->total_out = 0; | 368 | strm->total_in = strm->total_out = 0; |
367 | strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ | 369 | strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ |
@@ -554,7 +556,7 @@ int ZEXPORT deflate (strm, flush) | |||
554 | { | 556 | { |
555 | uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; | 557 | uInt header = (Z_DEFLATED + ((s->w_bits-8)<<4)) << 8; |
556 | uInt level_flags; | 558 | uInt level_flags; |
557 | 559 | ||
558 | if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) | 560 | if (s->strategy >= Z_HUFFMAN_ONLY || s->level < 2) |
559 | level_flags = 0; | 561 | level_flags = 0; |
560 | else if (s->level < 6) | 562 | else if (s->level < 6) |
@@ -566,10 +568,10 @@ int ZEXPORT deflate (strm, flush) | |||
566 | header |= (level_flags << 6); | 568 | header |= (level_flags << 6); |
567 | if (s->strstart != 0) header |= PRESET_DICT; | 569 | if (s->strstart != 0) header |= PRESET_DICT; |
568 | header += 31 - (header % 31); | 570 | header += 31 - (header % 31); |
569 | 571 | ||
570 | s->status = BUSY_STATE; | 572 | s->status = BUSY_STATE; |
571 | putShortMSB(s, header); | 573 | putShortMSB(s, header); |
572 | 574 | ||
573 | /* Save the adler32 of the preset dictionary: */ | 575 | /* Save the adler32 of the preset dictionary: */ |
574 | if (s->strstart != 0) { | 576 | if (s->strstart != 0) { |
575 | putShortMSB(s, (uInt)(strm->adler >> 16)); | 577 | putShortMSB(s, (uInt)(strm->adler >> 16)); |
@@ -1092,7 +1094,7 @@ local void fill_window(s) | |||
1092 | if (sizeof(int) <= 2) { | 1094 | if (sizeof(int) <= 2) { |
1093 | if (more == 0 && s->strstart == 0 && s->lookahead == 0) { | 1095 | if (more == 0 && s->strstart == 0 && s->lookahead == 0) { |
1094 | more = wsize; | 1096 | more = wsize; |
1095 | 1097 | ||
1096 | } else if (more == (unsigned)(-1)) { | 1098 | } else if (more == (unsigned)(-1)) { |
1097 | /* Very unlikely, but possible on 16 bit machine if | 1099 | /* Very unlikely, but possible on 16 bit machine if |
1098 | * strstart == 0 && lookahead == 1 (input done a byte at time) | 1100 | * strstart == 0 && lookahead == 1 (input done a byte at time) |
@@ -1412,7 +1414,7 @@ local block_state deflate_slow(s, flush) | |||
1412 | /* longest_match() or longest_match_fast() sets match_start */ | 1414 | /* longest_match() or longest_match_fast() sets match_start */ |
1413 | 1415 | ||
1414 | if (s->match_length <= 5 && (s->strategy == Z_FILTERED | 1416 | if (s->match_length <= 5 && (s->strategy == Z_FILTERED |
1415 | #if TOO_FAR < 32768 | 1417 | #if TOO_FAR <= 32767 |
1416 | || (s->match_length == MIN_MATCH && | 1418 | || (s->match_length == MIN_MATCH && |
1417 | s->strstart - s->match_start > TOO_FAR) | 1419 | s->strstart - s->match_start > TOO_FAR) |
1418 | #endif | 1420 | #endif |
@@ -1,6 +1,6 @@ | |||
1 | /* deflate.h -- internal compression state | 1 | /* deflate.h -- internal compression state |
2 | * Copyright (C) 1995-2002 Jean-loup Gailly | 2 | * Copyright (C) 1995-2002 Jean-loup Gailly |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* WARNING: this file should *not* be used by applications. It is | 6 | /* WARNING: this file should *not* be used by applications. It is |
@@ -320,7 +320,7 @@ void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, | |||
320 | #else | 320 | #else |
321 | # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) | 321 | # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) |
322 | # define _tr_tally_dist(s, distance, length, flush) \ | 322 | # define _tr_tally_dist(s, distance, length, flush) \ |
323 | flush = _tr_tally(s, distance, length) | 323 | flush = _tr_tally(s, distance, length) |
324 | #endif | 324 | #endif |
325 | 325 | ||
326 | #endif /* DEFLATE_H */ | 326 | #endif /* DEFLATE_H */ |
@@ -38,8 +38,8 @@ uLong dictId; /* Adler32 value of the dictionary */ | |||
38 | 38 | ||
39 | void test_compress OF((Byte *compr, uLong comprLen, | 39 | void test_compress OF((Byte *compr, uLong comprLen, |
40 | Byte *uncompr, uLong uncomprLen)); | 40 | Byte *uncompr, uLong uncomprLen)); |
41 | void test_gzio OF((const char *out, const char *in, | 41 | void test_gzio OF((const char *fname, |
42 | Byte *uncompr, int uncomprLen)); | 42 | Byte *uncompr, uLong uncomprLen)); |
43 | void test_deflate OF((Byte *compr, uLong comprLen)); | 43 | void test_deflate OF((Byte *compr, uLong comprLen)); |
44 | void test_inflate OF((Byte *compr, uLong comprLen, | 44 | void test_inflate OF((Byte *compr, uLong comprLen, |
45 | Byte *uncompr, uLong uncomprLen)); | 45 | Byte *uncompr, uLong uncomprLen)); |
@@ -63,7 +63,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen) | |||
63 | uLong comprLen, uncomprLen; | 63 | uLong comprLen, uncomprLen; |
64 | { | 64 | { |
65 | int err; | 65 | int err; |
66 | uLong len = strlen(hello)+1; | 66 | uLong len = (uLong)strlen(hello)+1; |
67 | 67 | ||
68 | err = compress(compr, &comprLen, (const Bytef*)hello, len); | 68 | err = compress(compr, &comprLen, (const Bytef*)hello, len); |
69 | CHECK_ERR(err, "compress"); | 69 | CHECK_ERR(err, "compress"); |
@@ -84,18 +84,17 @@ void test_compress(compr, comprLen, uncompr, uncomprLen) | |||
84 | /* =========================================================================== | 84 | /* =========================================================================== |
85 | * Test read/write of .gz files | 85 | * Test read/write of .gz files |
86 | */ | 86 | */ |
87 | void test_gzio(out, in, uncompr, uncomprLen) | 87 | void test_gzio(fname, uncompr, uncomprLen) |
88 | const char *out; /* compressed output file */ | 88 | const char *fname; /* compressed file name */ |
89 | const char *in; /* compressed input file */ | ||
90 | Byte *uncompr; | 89 | Byte *uncompr; |
91 | int uncomprLen; | 90 | uLong uncomprLen; |
92 | { | 91 | { |
93 | int err; | 92 | int err; |
94 | int len = strlen(hello)+1; | 93 | int len = (int)strlen(hello)+1; |
95 | gzFile file; | 94 | gzFile file; |
96 | z_off_t pos; | 95 | z_off_t pos; |
97 | 96 | ||
98 | file = gzopen(out, "wb"); | 97 | file = gzopen(fname, "wb"); |
99 | if (file == NULL) { | 98 | if (file == NULL) { |
100 | fprintf(stderr, "gzopen error\n"); | 99 | fprintf(stderr, "gzopen error\n"); |
101 | exit(1); | 100 | exit(1); |
@@ -112,14 +111,14 @@ void test_gzio(out, in, uncompr, uncomprLen) | |||
112 | gzseek(file, 1L, SEEK_CUR); /* add one zero byte */ | 111 | gzseek(file, 1L, SEEK_CUR); /* add one zero byte */ |
113 | gzclose(file); | 112 | gzclose(file); |
114 | 113 | ||
115 | file = gzopen(in, "rb"); | 114 | file = gzopen(fname, "rb"); |
116 | if (file == NULL) { | 115 | if (file == NULL) { |
117 | fprintf(stderr, "gzopen error\n"); | 116 | fprintf(stderr, "gzopen error\n"); |
117 | exit(1); | ||
118 | } | 118 | } |
119 | strcpy((char*)uncompr, "garbage"); | 119 | strcpy((char*)uncompr, "garbage"); |
120 | 120 | ||
121 | uncomprLen = gzread(file, uncompr, (unsigned)uncomprLen); | 121 | if (gzread(file, uncompr, (unsigned)uncomprLen) != len) { |
122 | if (uncomprLen != len) { | ||
123 | fprintf(stderr, "gzread err: %s\n", gzerror(file, &err)); | 122 | fprintf(stderr, "gzread err: %s\n", gzerror(file, &err)); |
124 | exit(1); | 123 | exit(1); |
125 | } | 124 | } |
@@ -127,7 +126,7 @@ void test_gzio(out, in, uncompr, uncomprLen) | |||
127 | fprintf(stderr, "bad gzread: %s\n", (char*)uncompr); | 126 | fprintf(stderr, "bad gzread: %s\n", (char*)uncompr); |
128 | exit(1); | 127 | exit(1); |
129 | } else { | 128 | } else { |
130 | printf("gzread(): %s\n", (char *)uncompr); | 129 | printf("gzread(): %s\n", (char*)uncompr); |
131 | } | 130 | } |
132 | 131 | ||
133 | pos = gzseek(file, -8L, SEEK_CUR); | 132 | pos = gzseek(file, -8L, SEEK_CUR); |
@@ -147,17 +146,16 @@ void test_gzio(out, in, uncompr, uncomprLen) | |||
147 | exit(1); | 146 | exit(1); |
148 | } | 147 | } |
149 | 148 | ||
150 | gzgets(file, (char*)uncompr, uncomprLen); | 149 | gzgets(file, (char*)uncompr, (int)uncomprLen); |
151 | uncomprLen = strlen((char*)uncompr); | 150 | if (strlen((char*)uncompr) != 7) { /* " hello!" */ |
152 | if (uncomprLen != 7) { /* " hello!" */ | ||
153 | fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err)); | 151 | fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err)); |
154 | exit(1); | 152 | exit(1); |
155 | } | 153 | } |
156 | if (strcmp((char*)uncompr, hello+6)) { | 154 | if (strcmp((char*)uncompr, hello + 6)) { |
157 | fprintf(stderr, "bad gzgets after gzseek\n"); | 155 | fprintf(stderr, "bad gzgets after gzseek\n"); |
158 | exit(1); | 156 | exit(1); |
159 | } else { | 157 | } else { |
160 | printf("gzgets() after gzseek: %s\n", (char *)uncompr); | 158 | printf("gzgets() after gzseek: %s\n", (char*)uncompr); |
161 | } | 159 | } |
162 | 160 | ||
163 | gzclose(file); | 161 | gzclose(file); |
@@ -172,7 +170,7 @@ void test_deflate(compr, comprLen) | |||
172 | { | 170 | { |
173 | z_stream c_stream; /* compression stream */ | 171 | z_stream c_stream; /* compression stream */ |
174 | int err; | 172 | int err; |
175 | int len = strlen(hello)+1; | 173 | uLong len = (uLong)strlen(hello)+1; |
176 | 174 | ||
177 | c_stream.zalloc = (alloc_func)0; | 175 | c_stream.zalloc = (alloc_func)0; |
178 | c_stream.zfree = (free_func)0; | 176 | c_stream.zfree = (free_func)0; |
@@ -184,7 +182,7 @@ void test_deflate(compr, comprLen) | |||
184 | c_stream.next_in = (Bytef*)hello; | 182 | c_stream.next_in = (Bytef*)hello; |
185 | c_stream.next_out = compr; | 183 | c_stream.next_out = compr; |
186 | 184 | ||
187 | while (c_stream.total_in != (uLong)len && c_stream.total_out < comprLen) { | 185 | while (c_stream.total_in != len && c_stream.total_out < comprLen) { |
188 | c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ | 186 | c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ |
189 | err = deflate(&c_stream, Z_NO_FLUSH); | 187 | err = deflate(&c_stream, Z_NO_FLUSH); |
190 | CHECK_ERR(err, "deflate"); | 188 | CHECK_ERR(err, "deflate"); |
@@ -347,7 +345,7 @@ void test_flush(compr, comprLen) | |||
347 | { | 345 | { |
348 | z_stream c_stream; /* compression stream */ | 346 | z_stream c_stream; /* compression stream */ |
349 | int err; | 347 | int err; |
350 | int len = strlen(hello)+1; | 348 | uInt len = (uInt)strlen(hello)+1; |
351 | 349 | ||
352 | c_stream.zalloc = (alloc_func)0; | 350 | c_stream.zalloc = (alloc_func)0; |
353 | c_stream.zfree = (free_func)0; | 351 | c_stream.zfree = (free_func)0; |
@@ -543,8 +541,7 @@ int main(argc, argv) | |||
543 | test_compress(compr, comprLen, uncompr, uncomprLen); | 541 | test_compress(compr, comprLen, uncompr, uncomprLen); |
544 | 542 | ||
545 | test_gzio((argc > 1 ? argv[1] : TESTFILE), | 543 | test_gzio((argc > 1 ? argv[1] : TESTFILE), |
546 | (argc > 2 ? argv[2] : TESTFILE), | 544 | uncompr, uncomprLen); |
547 | uncompr, (int)uncomprLen); | ||
548 | 545 | ||
549 | test_deflate(compr, comprLen); | 546 | test_deflate(compr, comprLen); |
550 | test_inflate(compr, comprLen, uncompr, uncomprLen); | 547 | test_inflate(compr, comprLen, uncompr, uncomprLen); |
@@ -2,7 +2,7 @@ | |||
2 | * Copyright (C) 1995-2003 Jean-loup Gailly. | 2 | * Copyright (C) 1995-2003 Jean-loup Gailly. |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | * | 4 | * |
5 | * Compile this file with -DNO_DEFLATE to avoid the compression code. | 5 | * Compile this file with -DNO_GZCOMPRESS to avoid the compression code. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | /* @(#) $Id$ */ | 8 | /* @(#) $Id$ */ |
@@ -11,6 +11,10 @@ | |||
11 | 11 | ||
12 | #include "zutil.h" | 12 | #include "zutil.h" |
13 | 13 | ||
14 | #ifdef NO_DEFLATE /* for compatiblity with old definition */ | ||
15 | # define NO_GZCOMPRESS | ||
16 | #endif | ||
17 | |||
14 | #ifndef NO_DUMMY_DECL | 18 | #ifndef NO_DUMMY_DECL |
15 | struct internal_state {int dummy;}; /* for buggy compilers */ | 19 | struct internal_state {int dummy;}; /* for buggy compilers */ |
16 | #endif | 20 | #endif |
@@ -56,7 +60,9 @@ typedef struct gz_stream { | |||
56 | char *path; /* path name for debugging only */ | 60 | char *path; /* path name for debugging only */ |
57 | int transparent; /* 1 if input file is not a .gz file */ | 61 | int transparent; /* 1 if input file is not a .gz file */ |
58 | char mode; /* 'w' or 'r' */ | 62 | char mode; /* 'w' or 'r' */ |
59 | long startpos; /* start of compressed data in file (header skipped) */ | 63 | z_off_t start; /* start of compressed data in file (header skipped) */ |
64 | z_off_t in; /* bytes into deflate or inflate */ | ||
65 | z_off_t out; /* bytes out of deflate or inflate */ | ||
60 | int back; /* one character push-back */ | 66 | int back; /* one character push-back */ |
61 | int last; /* true if push-back is last character */ | 67 | int last; /* true if push-back is last character */ |
62 | } gz_stream; | 68 | } gz_stream; |
@@ -74,7 +80,7 @@ local uLong getLong OF((gz_stream *s)); | |||
74 | Opens a gzip (.gz) file for reading or writing. The mode parameter | 80 | Opens a gzip (.gz) file for reading or writing. The mode parameter |
75 | is as in fopen ("rb" or "wb"). The file is given either by file descriptor | 81 | is as in fopen ("rb" or "wb"). The file is given either by file descriptor |
76 | or path name (if fd == -1). | 82 | or path name (if fd == -1). |
77 | gz_open return NULL if the file could not be opened or if there was | 83 | gz_open returns NULL if the file could not be opened or if there was |
78 | insufficient memory to allocate the (de)compression state; errno | 84 | insufficient memory to allocate the (de)compression state; errno |
79 | can be checked to distinguish the two cases (if errno is zero, the | 85 | can be checked to distinguish the two cases (if errno is zero, the |
80 | zlib error is Z_MEM_ERROR). | 86 | zlib error is Z_MEM_ERROR). |
@@ -106,6 +112,8 @@ local gzFile gz_open (path, mode, fd) | |||
106 | s->file = NULL; | 112 | s->file = NULL; |
107 | s->z_err = Z_OK; | 113 | s->z_err = Z_OK; |
108 | s->z_eof = 0; | 114 | s->z_eof = 0; |
115 | s->in = 0; | ||
116 | s->out = 0; | ||
109 | s->back = EOF; | 117 | s->back = EOF; |
110 | s->crc = crc32(0L, Z_NULL, 0); | 118 | s->crc = crc32(0L, Z_NULL, 0); |
111 | s->msg = NULL; | 119 | s->msg = NULL; |
@@ -136,7 +144,7 @@ local gzFile gz_open (path, mode, fd) | |||
136 | if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; | 144 | if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; |
137 | 145 | ||
138 | if (s->mode == 'w') { | 146 | if (s->mode == 'w') { |
139 | #ifdef NO_DEFLATE | 147 | #ifdef NO_GZCOMPRESS |
140 | err = Z_STREAM_ERROR; | 148 | err = Z_STREAM_ERROR; |
141 | #else | 149 | #else |
142 | err = deflateInit2(&(s->stream), level, | 150 | err = deflateInit2(&(s->stream), level, |
@@ -175,15 +183,15 @@ local gzFile gz_open (path, mode, fd) | |||
175 | */ | 183 | */ |
176 | fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], | 184 | fprintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], |
177 | Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); | 185 | Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); |
178 | s->startpos = 10L; | 186 | s->start = 10L; |
179 | /* We use 10L instead of ftell(s->file) to because ftell causes an | 187 | /* We use 10L instead of ftell(s->file) to because ftell causes an |
180 | * fflush on some systems. This version of the library doesn't use | 188 | * fflush on some systems. This version of the library doesn't use |
181 | * startpos anyway in write mode, so this initialization is not | 189 | * start anyway in write mode, so this initialization is not |
182 | * necessary. | 190 | * necessary. |
183 | */ | 191 | */ |
184 | } else { | 192 | } else { |
185 | check_header(s); /* skip the .gz header */ | 193 | check_header(s); /* skip the .gz header */ |
186 | s->startpos = (ftell(s->file) - s->stream.avail_in); | 194 | s->start = ftell(s->file) - s->stream.avail_in; |
187 | } | 195 | } |
188 | 196 | ||
189 | return (gzFile)s; | 197 | return (gzFile)s; |
@@ -350,7 +358,7 @@ local int destroy (s) | |||
350 | 358 | ||
351 | if (s->stream.state != NULL) { | 359 | if (s->stream.state != NULL) { |
352 | if (s->mode == 'w') { | 360 | if (s->mode == 'w') { |
353 | #ifdef NO_DEFLATE | 361 | #ifdef NO_GZCOMPRESS |
354 | err = Z_STREAM_ERROR; | 362 | err = Z_STREAM_ERROR; |
355 | #else | 363 | #else |
356 | err = deflateEnd(&(s->stream)); | 364 | err = deflateEnd(&(s->stream)); |
@@ -401,7 +409,7 @@ int ZEXPORT gzread (file, buf, len) | |||
401 | s->stream.next_out++; | 409 | s->stream.next_out++; |
402 | s->stream.avail_out--; | 410 | s->stream.avail_out--; |
403 | s->back = EOF; | 411 | s->back = EOF; |
404 | s->stream.total_out++; | 412 | s->out++; |
405 | if (s->last) { | 413 | if (s->last) { |
406 | s->z_err = Z_STREAM_END; | 414 | s->z_err = Z_STREAM_END; |
407 | return 1; | 415 | return 1; |
@@ -427,8 +435,8 @@ int ZEXPORT gzread (file, buf, len) | |||
427 | s->file); | 435 | s->file); |
428 | } | 436 | } |
429 | len -= s->stream.avail_out; | 437 | len -= s->stream.avail_out; |
430 | s->stream.total_in += (uLong)len; | 438 | s->in += len; |
431 | s->stream.total_out += (uLong)len; | 439 | s->out += len; |
432 | if (len == 0) s->z_eof = 1; | 440 | if (len == 0) s->z_eof = 1; |
433 | return (int)len; | 441 | return (int)len; |
434 | } | 442 | } |
@@ -445,7 +453,11 @@ int ZEXPORT gzread (file, buf, len) | |||
445 | } | 453 | } |
446 | s->stream.next_in = s->inbuf; | 454 | s->stream.next_in = s->inbuf; |
447 | } | 455 | } |
456 | s->in += s->stream.avail_in; | ||
457 | s->out += s->stream.avail_out; | ||
448 | s->z_err = inflate(&(s->stream), Z_NO_FLUSH); | 458 | s->z_err = inflate(&(s->stream), Z_NO_FLUSH); |
459 | s->in -= s->stream.avail_in; | ||
460 | s->out -= s->stream.avail_out; | ||
449 | 461 | ||
450 | if (s->z_err == Z_STREAM_END) { | 462 | if (s->z_err == Z_STREAM_END) { |
451 | /* Check CRC and original size */ | 463 | /* Check CRC and original size */ |
@@ -456,18 +468,13 @@ int ZEXPORT gzread (file, buf, len) | |||
456 | s->z_err = Z_DATA_ERROR; | 468 | s->z_err = Z_DATA_ERROR; |
457 | } else { | 469 | } else { |
458 | (void)getLong(s); | 470 | (void)getLong(s); |
459 | /* The uncompressed length returned by above getlong() may | 471 | /* The uncompressed length returned by above getlong() may be |
460 | * be different from s->stream.total_out) in case of | 472 | * different from s->out in case of concatenated .gz files. |
461 | * concatenated .gz files. Check for such files: | 473 | * Check for such files: |
462 | */ | 474 | */ |
463 | check_header(s); | 475 | check_header(s); |
464 | if (s->z_err == Z_OK) { | 476 | if (s->z_err == Z_OK) { |
465 | uLong total_in = s->stream.total_in; | ||
466 | uLong total_out = s->stream.total_out; | ||
467 | |||
468 | inflateReset(&(s->stream)); | 477 | inflateReset(&(s->stream)); |
469 | s->stream.total_in = total_in; | ||
470 | s->stream.total_out = total_out; | ||
471 | s->crc = crc32(0L, Z_NULL, 0); | 478 | s->crc = crc32(0L, Z_NULL, 0); |
472 | } | 479 | } |
473 | } | 480 | } |
@@ -504,7 +511,7 @@ int ZEXPORT gzungetc(c, file) | |||
504 | 511 | ||
505 | if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF; | 512 | if (s == NULL || s->mode != 'r' || c == EOF || s->back != EOF) return EOF; |
506 | s->back = c; | 513 | s->back = c; |
507 | s->stream.total_out--; | 514 | s->out--; |
508 | s->last = (s->z_err == Z_STREAM_END); | 515 | s->last = (s->z_err == Z_STREAM_END); |
509 | if (s->last) s->z_err = Z_OK; | 516 | if (s->last) s->z_err = Z_OK; |
510 | s->z_eof = 0; | 517 | s->z_eof = 0; |
@@ -535,7 +542,7 @@ char * ZEXPORT gzgets(file, buf, len) | |||
535 | } | 542 | } |
536 | 543 | ||
537 | 544 | ||
538 | #ifndef NO_DEFLATE | 545 | #ifndef NO_GZCOMPRESS |
539 | /* =========================================================================== | 546 | /* =========================================================================== |
540 | Writes the given number of uncompressed bytes into the compressed file. | 547 | Writes the given number of uncompressed bytes into the compressed file. |
541 | gzwrite returns the number of bytes actually written (0 in case of error). | 548 | gzwrite returns the number of bytes actually written (0 in case of error). |
@@ -563,7 +570,11 @@ int ZEXPORT gzwrite (file, buf, len) | |||
563 | } | 570 | } |
564 | s->stream.avail_out = Z_BUFSIZE; | 571 | s->stream.avail_out = Z_BUFSIZE; |
565 | } | 572 | } |
573 | s->in += s->stream.avail_in; | ||
574 | s->out += s->stream.avail_out; | ||
566 | s->z_err = deflate(&(s->stream), Z_NO_FLUSH); | 575 | s->z_err = deflate(&(s->stream), Z_NO_FLUSH); |
576 | s->in -= s->stream.avail_in; | ||
577 | s->out -= s->stream.avail_out; | ||
567 | if (s->z_err != Z_OK) break; | 578 | if (s->z_err != Z_OK) break; |
568 | } | 579 | } |
569 | s->crc = crc32(s->crc, (const Bytef *)buf, len); | 580 | s->crc = crc32(s->crc, (const Bytef *)buf, len); |
@@ -706,7 +717,9 @@ local int do_flush (file, flush) | |||
706 | s->stream.avail_out = Z_BUFSIZE; | 717 | s->stream.avail_out = Z_BUFSIZE; |
707 | } | 718 | } |
708 | if (done) break; | 719 | if (done) break; |
720 | s->out += s->stream.avail_out; | ||
709 | s->z_err = deflate(&(s->stream), flush); | 721 | s->z_err = deflate(&(s->stream), flush); |
722 | s->out -= s->stream.avail_out; | ||
710 | 723 | ||
711 | /* Ignore the second of two consecutive flushes: */ | 724 | /* Ignore the second of two consecutive flushes: */ |
712 | if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; | 725 | if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; |
@@ -732,7 +745,7 @@ int ZEXPORT gzflush (file, flush) | |||
732 | fflush(s->file); | 745 | fflush(s->file); |
733 | return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; | 746 | return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; |
734 | } | 747 | } |
735 | #endif /* NO_DEFLATE */ | 748 | #endif /* NO_GZCOMPRESS */ |
736 | 749 | ||
737 | /* =========================================================================== | 750 | /* =========================================================================== |
738 | Sets the starting position for the next gzread or gzwrite on the given | 751 | Sets the starting position for the next gzread or gzwrite on the given |
@@ -755,11 +768,11 @@ z_off_t ZEXPORT gzseek (file, offset, whence) | |||
755 | } | 768 | } |
756 | 769 | ||
757 | if (s->mode == 'w') { | 770 | if (s->mode == 'w') { |
758 | #ifdef NO_DEFLATE | 771 | #ifdef NO_GZCOMPRESS |
759 | return -1L; | 772 | return -1L; |
760 | #else | 773 | #else |
761 | if (whence == SEEK_SET) { | 774 | if (whence == SEEK_SET) { |
762 | offset -= s->stream.total_in; | 775 | offset -= s->in; |
763 | } | 776 | } |
764 | if (offset < 0) return -1L; | 777 | if (offset < 0) return -1L; |
765 | 778 | ||
@@ -778,14 +791,14 @@ z_off_t ZEXPORT gzseek (file, offset, whence) | |||
778 | 791 | ||
779 | offset -= size; | 792 | offset -= size; |
780 | } | 793 | } |
781 | return (z_off_t)s->stream.total_in; | 794 | return s->in; |
782 | #endif | 795 | #endif |
783 | } | 796 | } |
784 | /* Rest of function is for reading only */ | 797 | /* Rest of function is for reading only */ |
785 | 798 | ||
786 | /* compute absolute position */ | 799 | /* compute absolute position */ |
787 | if (whence == SEEK_CUR) { | 800 | if (whence == SEEK_CUR) { |
788 | offset += s->stream.total_out; | 801 | offset += s->out; |
789 | } | 802 | } |
790 | if (offset < 0) return -1L; | 803 | if (offset < 0) return -1L; |
791 | 804 | ||
@@ -796,13 +809,13 @@ z_off_t ZEXPORT gzseek (file, offset, whence) | |||
796 | s->stream.next_in = s->inbuf; | 809 | s->stream.next_in = s->inbuf; |
797 | if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; | 810 | if (fseek(s->file, offset, SEEK_SET) < 0) return -1L; |
798 | 811 | ||
799 | s->stream.total_in = s->stream.total_out = (uLong)offset; | 812 | s->in = s->out = offset; |
800 | return offset; | 813 | return offset; |
801 | } | 814 | } |
802 | 815 | ||
803 | /* For a negative seek, rewind and use positive seek */ | 816 | /* For a negative seek, rewind and use positive seek */ |
804 | if ((uLong)offset >= s->stream.total_out) { | 817 | if (offset >= s->out) { |
805 | offset -= s->stream.total_out; | 818 | offset -= s->out; |
806 | } else if (gzrewind(file) < 0) { | 819 | } else if (gzrewind(file) < 0) { |
807 | return -1L; | 820 | return -1L; |
808 | } | 821 | } |
@@ -814,7 +827,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence) | |||
814 | } | 827 | } |
815 | if (offset && s->back != EOF) { | 828 | if (offset && s->back != EOF) { |
816 | s->back = EOF; | 829 | s->back = EOF; |
817 | s->stream.total_out++; | 830 | s->out++; |
818 | offset--; | 831 | offset--; |
819 | if (s->last) s->z_err = Z_STREAM_END; | 832 | if (s->last) s->z_err = Z_STREAM_END; |
820 | } | 833 | } |
@@ -826,7 +839,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence) | |||
826 | if (size <= 0) return -1L; | 839 | if (size <= 0) return -1L; |
827 | offset -= size; | 840 | offset -= size; |
828 | } | 841 | } |
829 | return (z_off_t)s->stream.total_out; | 842 | return s->out; |
830 | } | 843 | } |
831 | 844 | ||
832 | /* =========================================================================== | 845 | /* =========================================================================== |
@@ -845,14 +858,10 @@ int ZEXPORT gzrewind (file) | |||
845 | s->stream.avail_in = 0; | 858 | s->stream.avail_in = 0; |
846 | s->stream.next_in = s->inbuf; | 859 | s->stream.next_in = s->inbuf; |
847 | s->crc = crc32(0L, Z_NULL, 0); | 860 | s->crc = crc32(0L, Z_NULL, 0); |
848 | 861 | if (!s->transparent) (void)inflateReset(&s->stream); | |
849 | if (s->startpos == 0) { /* not a compressed file */ | 862 | s->in = 0; |
850 | fseek(s->file, 0L, SEEK_SET); /* rewind() is not always available */ | 863 | s->out = 0; |
851 | return 0; | 864 | return fseek(s->file, s->start, SEEK_SET); |
852 | } | ||
853 | |||
854 | (void) inflateReset(&s->stream); | ||
855 | return fseek(s->file, s->startpos, SEEK_SET); | ||
856 | } | 865 | } |
857 | 866 | ||
858 | /* =========================================================================== | 867 | /* =========================================================================== |
@@ -923,14 +932,14 @@ int ZEXPORT gzclose (file) | |||
923 | if (s == NULL) return Z_STREAM_ERROR; | 932 | if (s == NULL) return Z_STREAM_ERROR; |
924 | 933 | ||
925 | if (s->mode == 'w') { | 934 | if (s->mode == 'w') { |
926 | #ifdef NO_DEFLATE | 935 | #ifdef NO_GZCOMPRESS |
927 | return Z_STREAM_ERROR; | 936 | return Z_STREAM_ERROR; |
928 | #else | 937 | #else |
929 | err = do_flush (file, Z_FINISH); | 938 | err = do_flush (file, Z_FINISH); |
930 | if (err != Z_OK) return destroy((gz_stream*)file); | 939 | if (err != Z_OK) return destroy((gz_stream*)file); |
931 | 940 | ||
932 | putLong (s->file, s->crc); | 941 | putLong (s->file, s->crc); |
933 | putLong (s->file, s->stream.total_in); | 942 | putLong (s->file, (uLong)(s->in & 0xffffffff)); |
934 | #endif | 943 | #endif |
935 | } | 944 | } |
936 | return destroy((gz_stream*)file); | 945 | return destroy((gz_stream*)file); |
@@ -41,11 +41,11 @@ int stream_size; | |||
41 | windowBits < 8 || windowBits > 15) | 41 | windowBits < 8 || windowBits > 15) |
42 | return Z_STREAM_ERROR; | 42 | return Z_STREAM_ERROR; |
43 | strm->msg = Z_NULL; /* in case we return an error */ | 43 | strm->msg = Z_NULL; /* in case we return an error */ |
44 | if (strm->zalloc == Z_NULL) { | 44 | if (strm->zalloc == (alloc_func)0) { |
45 | strm->zalloc = zcalloc; | 45 | strm->zalloc = zcalloc; |
46 | strm->opaque = (voidpf)0; | 46 | strm->opaque = (voidpf)0; |
47 | } | 47 | } |
48 | if (strm->zfree == Z_NULL) strm->zfree = zcfree; | 48 | if (strm->zfree == (free_func)0) strm->zfree = zcfree; |
49 | state = (struct inflate_state FAR *)ZALLOC(strm, 1, | 49 | state = (struct inflate_state FAR *)ZALLOC(strm, 1, |
50 | sizeof(struct inflate_state)); | 50 | sizeof(struct inflate_state)); |
51 | if (state == Z_NULL) return Z_MEM_ERROR; | 51 | if (state == Z_NULL) return Z_MEM_ERROR; |
@@ -610,7 +610,7 @@ void FAR *out_desc; | |||
610 | int ZEXPORT inflateBackEnd(strm) | 610 | int ZEXPORT inflateBackEnd(strm) |
611 | z_stream FAR *strm; | 611 | z_stream FAR *strm; |
612 | { | 612 | { |
613 | if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == Z_NULL) | 613 | if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) |
614 | return Z_STREAM_ERROR; | 614 | return Z_STREAM_ERROR; |
615 | ZFREE(strm, strm->state); | 615 | ZFREE(strm, strm->state); |
616 | strm->state = Z_NULL; | 616 | strm->state = Z_NULL; |
@@ -8,6 +8,8 @@ | |||
8 | #include "inflate.h" | 8 | #include "inflate.h" |
9 | #include "inffast.h" | 9 | #include "inffast.h" |
10 | 10 | ||
11 | #ifndef ASMINF | ||
12 | |||
11 | /* Allow machine dependent optimization for post-increment or pre-increment. | 13 | /* Allow machine dependent optimization for post-increment or pre-increment. |
12 | Based on testing to date, | 14 | Based on testing to date, |
13 | Pre-increment preferred for: | 15 | Pre-increment preferred for: |
@@ -72,6 +74,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ | |||
72 | unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ | 74 | unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ |
73 | unsigned char FAR *end; /* while out < end, enough space available */ | 75 | unsigned char FAR *end; /* while out < end, enough space available */ |
74 | unsigned wsize; /* window size or zero if not using window */ | 76 | unsigned wsize; /* window size or zero if not using window */ |
77 | unsigned whave; /* valid bytes in the window */ | ||
75 | unsigned write; /* window write index */ | 78 | unsigned write; /* window write index */ |
76 | unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ | 79 | unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ |
77 | unsigned long hold; /* local strm->hold */ | 80 | unsigned long hold; /* local strm->hold */ |
@@ -95,6 +98,7 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ | |||
95 | beg = out - (start - strm->avail_out); | 98 | beg = out - (start - strm->avail_out); |
96 | end = out + (strm->avail_out - 257); | 99 | end = out + (strm->avail_out - 257); |
97 | wsize = state->wsize; | 100 | wsize = state->wsize; |
101 | whave = state->whave; | ||
98 | write = state->write; | 102 | write = state->write; |
99 | window = state->window; | 103 | window = state->window; |
100 | hold = state->hold; | 104 | hold = state->hold; |
@@ -167,13 +171,13 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ | |||
167 | Tracevv((stderr, "inflate: distance %u\n", dist)); | 171 | Tracevv((stderr, "inflate: distance %u\n", dist)); |
168 | op = (unsigned)(out - beg); /* max distance in output */ | 172 | op = (unsigned)(out - beg); /* max distance in output */ |
169 | if (dist > op) { /* see if copy from window */ | 173 | if (dist > op) { /* see if copy from window */ |
170 | if (dist > wsize) { | 174 | op = dist - op; /* distance back in window */ |
175 | if (op > whave) { | ||
171 | strm->msg = (char *)"invalid distance too far back"; | 176 | strm->msg = (char *)"invalid distance too far back"; |
172 | state->mode = BAD; | 177 | state->mode = BAD; |
173 | break; | 178 | break; |
174 | } | 179 | } |
175 | from = window - OFF; | 180 | from = window - OFF; |
176 | op = dist - op; /* distance back in window */ | ||
177 | if (write == 0) { /* very common case */ | 181 | if (write == 0) { /* very common case */ |
178 | from += wsize - op; | 182 | from += wsize - op; |
179 | if (op < len) { /* some from window */ | 183 | if (op < len) { /* some from window */ |
@@ -296,3 +300,5 @@ unsigned start; /* inflate()'s starting value for strm->avail_out */ | |||
296 | - Larger unrolled copy loops (three is about right) | 300 | - Larger unrolled copy loops (three is about right) |
297 | - Moving len -= 3 statement into middle of loop | 301 | - Moving len -= 3 statement into middle of loop |
298 | */ | 302 | */ |
303 | |||
304 | #endif /* !ASMINF */ | ||
@@ -1,6 +1,6 @@ | |||
1 | /* inffast.h -- header to use inffast.c | 1 | /* inffast.h -- header to use inffast.c |
2 | * Copyright (C) 1995-2003 Mark Adler | 2 | * Copyright (C) 1995-2003 Mark Adler |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* WARNING: this file should *not* be used by applications. It is | 6 | /* WARNING: this file should *not* be used by applications. It is |
@@ -97,7 +97,7 @@ local int updatewindow OF((z_streamp strm, unsigned out)); | |||
97 | #ifdef BUILDFIXED | 97 | #ifdef BUILDFIXED |
98 | void makefixed OF((void)); | 98 | void makefixed OF((void)); |
99 | #endif | 99 | #endif |
100 | local unsigned syncsearch OF((unsigned *have, unsigned char FAR *buf, | 100 | local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf, |
101 | unsigned len)); | 101 | unsigned len)); |
102 | 102 | ||
103 | int ZEXPORT inflateReset(strm) | 103 | int ZEXPORT inflateReset(strm) |
@@ -134,11 +134,11 @@ int stream_size; | |||
134 | return Z_VERSION_ERROR; | 134 | return Z_VERSION_ERROR; |
135 | if (strm == Z_NULL) return Z_STREAM_ERROR; | 135 | if (strm == Z_NULL) return Z_STREAM_ERROR; |
136 | strm->msg = Z_NULL; /* in case we return an error */ | 136 | strm->msg = Z_NULL; /* in case we return an error */ |
137 | if (strm->zalloc == Z_NULL) { | 137 | if (strm->zalloc == (alloc_func)0) { |
138 | strm->zalloc = zcalloc; | 138 | strm->zalloc = zcalloc; |
139 | strm->opaque = (voidpf)0; | 139 | strm->opaque = (voidpf)0; |
140 | } | 140 | } |
141 | if (strm->zfree == Z_NULL) strm->zfree = zcfree; | 141 | if (strm->zfree == (free_func)0) strm->zfree = zcfree; |
142 | state = (struct inflate_state FAR *) | 142 | state = (struct inflate_state FAR *) |
143 | ZALLOC(strm, 1, sizeof(struct inflate_state)); | 143 | ZALLOC(strm, 1, sizeof(struct inflate_state)); |
144 | if (state == Z_NULL) return Z_MEM_ERROR; | 144 | if (state == Z_NULL) return Z_MEM_ERROR; |
@@ -559,6 +559,7 @@ int flush; | |||
559 | return Z_STREAM_ERROR; | 559 | return Z_STREAM_ERROR; |
560 | 560 | ||
561 | state = (struct inflate_state FAR *)strm->state; | 561 | state = (struct inflate_state FAR *)strm->state; |
562 | if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ | ||
562 | LOAD(); | 563 | LOAD(); |
563 | in = have; | 564 | in = have; |
564 | out = left; | 565 | out = left; |
@@ -709,6 +710,8 @@ int flush; | |||
709 | strm->adler = state->check = adler32(0L, Z_NULL, 0); | 710 | strm->adler = state->check = adler32(0L, Z_NULL, 0); |
710 | state->mode = TYPE; | 711 | state->mode = TYPE; |
711 | case TYPE: | 712 | case TYPE: |
713 | if (flush == Z_BLOCK) goto inf_leave; | ||
714 | case TYPEDO: | ||
712 | if (state->last) { | 715 | if (state->last) { |
713 | BYTEBITS(); | 716 | BYTEBITS(); |
714 | state->mode = CHECK; | 717 | state->mode = CHECK; |
@@ -1071,6 +1074,8 @@ int flush; | |||
1071 | if (state->wrap && out) | 1074 | if (state->wrap && out) |
1072 | strm->adler = state->check = | 1075 | strm->adler = state->check = |
1073 | UPDATE(state->check, strm->next_out - out, out); | 1076 | UPDATE(state->check, strm->next_out - out, out); |
1077 | strm->data_type = state->bits + (state->last ? 8 : 0) + | ||
1078 | (state->mode == TYPE ? 16 : 0); | ||
1074 | if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) | 1079 | if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) |
1075 | ret = Z_BUF_ERROR; | 1080 | ret = Z_BUF_ERROR; |
1076 | return ret; | 1081 | return ret; |
@@ -1080,7 +1085,7 @@ int ZEXPORT inflateEnd(strm) | |||
1080 | z_streamp strm; | 1085 | z_streamp strm; |
1081 | { | 1086 | { |
1082 | struct inflate_state FAR *state; | 1087 | struct inflate_state FAR *state; |
1083 | if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == Z_NULL) | 1088 | if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) |
1084 | return Z_STREAM_ERROR; | 1089 | return Z_STREAM_ERROR; |
1085 | state = (struct inflate_state FAR *)strm->state; | 1090 | state = (struct inflate_state FAR *)strm->state; |
1086 | if (state->window != Z_NULL) ZFREE(strm, state->window); | 1091 | if (state->window != Z_NULL) ZFREE(strm, state->window); |
@@ -1233,7 +1238,7 @@ z_streamp source; | |||
1233 | 1238 | ||
1234 | /* check input */ | 1239 | /* check input */ |
1235 | if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || | 1240 | if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL || |
1236 | source->zalloc == Z_NULL || source->zfree == Z_NULL) | 1241 | source->zalloc == (alloc_func)0 || source->zfree == (free_func)0) |
1237 | return Z_STREAM_ERROR; | 1242 | return Z_STREAM_ERROR; |
1238 | state = (struct inflate_state FAR *)source->state; | 1243 | state = (struct inflate_state FAR *)source->state; |
1239 | 1244 | ||
@@ -32,6 +32,7 @@ typedef enum { | |||
32 | DICTID, /* i: waiting for dictionary check value */ | 32 | DICTID, /* i: waiting for dictionary check value */ |
33 | DICT, /* waiting for inflateSetDictionary() call */ | 33 | DICT, /* waiting for inflateSetDictionary() call */ |
34 | TYPE, /* i: waiting for type bits, including last-flag bit */ | 34 | TYPE, /* i: waiting for type bits, including last-flag bit */ |
35 | TYPEDO, /* i: same, but skip check to exit inflate on new block */ | ||
35 | STORED, /* i: waiting for stored size (length and complement) */ | 36 | STORED, /* i: waiting for stored size (length and complement) */ |
36 | COPY, /* i/o: waiting for input or output to copy stored block */ | 37 | COPY, /* i/o: waiting for input or output to copy stored block */ |
37 | TABLE, /* i: waiting for dynamic block table lengths */ | 38 | TABLE, /* i: waiting for dynamic block table lengths */ |
@@ -88,7 +89,7 @@ struct inflate_state { | |||
88 | /* sliding window */ | 89 | /* sliding window */ |
89 | unsigned wbits; /* log base 2 of requested window size */ | 90 | unsigned wbits; /* log base 2 of requested window size */ |
90 | unsigned wsize; /* window size or zero if not using window */ | 91 | unsigned wsize; /* window size or zero if not using window */ |
91 | unsigned whave; /* valid bytes in the window */ | 92 | unsigned whave; /* valid bytes in the window */ |
92 | unsigned write; /* window write index */ | 93 | unsigned write; /* window write index */ |
93 | unsigned char FAR *window; /* allocated sliding window, if needed */ | 94 | unsigned char FAR *window; /* allocated sliding window, if needed */ |
94 | /* bit accumulator */ | 95 | /* bit accumulator */ |
@@ -9,7 +9,7 @@ | |||
9 | #define MAXBITS 15 | 9 | #define MAXBITS 15 |
10 | 10 | ||
11 | const char inflate_copyright[] = | 11 | const char inflate_copyright[] = |
12 | " inflate 1.2.0.4 Copyright 1995-2003 Mark Adler "; | 12 | " inflate 1.2.0.5 Copyright 1995-2003 Mark Adler "; |
13 | /* | 13 | /* |
14 | If you use the zlib library in a product, an acknowledgment is welcome | 14 | If you use the zlib library in a product, an acknowledgment is welcome |
15 | in the documentation of your product. If for some reason you cannot | 15 | in the documentation of your product. If for some reason you cannot |
@@ -62,7 +62,7 @@ unsigned short FAR *work; | |||
62 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; | 62 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; |
63 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ | 63 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ |
64 | 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, | 64 | 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, |
65 | 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 192}; | 65 | 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 192, 78}; |
66 | static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ | 66 | static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ |
67 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, | 67 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, |
68 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, | 68 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, |
@@ -1,6 +1,5 @@ | |||
1 | /* minigzip.c -- simulate gzip using the zlib compression library | 1 | /* minigzip.c -- simulate gzip using the zlib compression library |
2 | * Copyright (C) 1995-2002 Jean-loup Gailly. | 2 | * Copyright (C) 1995-2002 Jean-loup Gailly. |
3 | * Adapted for Z_RLE by Cosmin Truta, 2003. | ||
4 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
5 | */ | 4 | */ |
6 | 5 | ||
@@ -60,7 +59,7 @@ | |||
60 | #ifndef GZ_SUFFIX | 59 | #ifndef GZ_SUFFIX |
61 | # define GZ_SUFFIX ".gz" | 60 | # define GZ_SUFFIX ".gz" |
62 | #endif | 61 | #endif |
63 | #define SUFFIX_LEN ((int)sizeof(GZ_SUFFIX)-1) | 62 | #define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1) |
64 | 63 | ||
65 | #define BUFLEN 16384 | 64 | #define BUFLEN 16384 |
66 | #define MAX_NAME_LEN 1024 | 65 | #define MAX_NAME_LEN 1024 |
@@ -230,7 +229,7 @@ void file_uncompress(file) | |||
230 | char *infile, *outfile; | 229 | char *infile, *outfile; |
231 | FILE *out; | 230 | FILE *out; |
232 | gzFile in; | 231 | gzFile in; |
233 | int len = (int)strlen(file); | 232 | uInt len = (uInt)strlen(file); |
234 | 233 | ||
235 | strcpy(buf, file); | 234 | strcpy(buf, file); |
236 | 235 | ||
diff --git a/msdos/Makefile.bor b/msdos/Makefile.bor index 4ad4061..8f8132d 100644 --- a/msdos/Makefile.bor +++ b/msdos/Makefile.bor | |||
@@ -1,6 +1,6 @@ | |||
1 | # Makefile for zlib | 1 | # Makefile for zlib |
2 | # Borland C++ | 2 | # Borland C++ |
3 | # Updated for zlib-1.2.x by Cosmin Truta, 15-Mar-2003. | 3 | # Last updated: 15-Mar-2003 |
4 | 4 | ||
5 | # To use, do "make -fmakefile.bor" | 5 | # To use, do "make -fmakefile.bor" |
6 | # To compile in small model, set below: MODEL=s | 6 | # To compile in small model, set below: MODEL=s |
@@ -103,7 +103,7 @@ test: example.exe minigzip.exe | |||
103 | 103 | ||
104 | clean: | 104 | clean: |
105 | -del *.obj | 105 | -del *.obj |
106 | -del *.exe | ||
107 | -del *.lib | 106 | -del *.lib |
108 | -del zlib_$(MODEL).bak | 107 | -del *.exe |
108 | -del zlib_*.bak | ||
109 | -del foo.gz | 109 | -del foo.gz |
diff --git a/old/msdos/Makefile.dj2 b/msdos/Makefile.dj2 index 0ab431c..283d1d9 100644 --- a/old/msdos/Makefile.dj2 +++ b/msdos/Makefile.dj2 | |||
@@ -1,15 +1,15 @@ | |||
1 | # Makefile for zlib. Modified for djgpp v2.0 by F. J. Donahoe, 3/15/96. | 1 | # Makefile for zlib. Modified for djgpp v2.0 by F. J. Donahoe, 3/15/96. |
2 | # Copyright (C) 1995-1998 Jean-loup Gailly. | 2 | # Copyright (C) 1995-1998 Jean-loup Gailly. |
3 | # For conditions of distribution and use, see copyright notice in zlib.h | 3 | # For conditions of distribution and use, see copyright notice in zlib.h |
4 | 4 | ||
5 | # To compile, or to compile and test, type: | 5 | # To compile, or to compile and test, type: |
6 | # | 6 | # |
7 | # make -fmakefile.dj2; make test -fmakefile.dj2 | 7 | # make -fmakefile.dj2; make test -fmakefile.dj2 |
8 | # | 8 | # |
9 | # To install libz.a, zconf.h and zlib.h in the djgpp directories, type: | 9 | # To install libz.a, zconf.h and zlib.h in the djgpp directories, type: |
10 | # | 10 | # |
11 | # make install -fmakefile.dj2 | 11 | # make install -fmakefile.dj2 |
12 | # | 12 | # |
13 | # after first defining LIBRARY_PATH and INCLUDE_PATH in djgpp.env as | 13 | # after first defining LIBRARY_PATH and INCLUDE_PATH in djgpp.env as |
14 | # in the sample below if the pattern of the DJGPP distribution is to | 14 | # in the sample below if the pattern of the DJGPP distribution is to |
15 | # be followed. Remember that, while <sp>'es around <=> are ignored in | 15 | # be followed. Remember that, while <sp>'es around <=> are ignored in |
@@ -52,21 +52,25 @@ prefix=/usr/local | |||
52 | exec_prefix = $(prefix) | 52 | exec_prefix = $(prefix) |
53 | 53 | ||
54 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | 54 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ |
55 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o | 55 | zutil.o inflate.o infback.o inftrees.o inffast.o |
56 | |||
57 | OBJA = | ||
58 | # to use the asm code: make OBJA=match.o | ||
56 | 59 | ||
57 | TEST_OBJS = example.o minigzip.o | 60 | TEST_OBJS = example.o minigzip.o |
58 | 61 | ||
59 | all: example.exe minigzip.exe | 62 | all: example.exe minigzip.exe |
60 | 63 | ||
64 | check: test | ||
61 | test: all | 65 | test: all |
62 | ./example | 66 | ./example |
63 | echo hello world | .\minigzip | .\minigzip -d | 67 | echo hello world | .\minigzip | .\minigzip -d |
64 | 68 | ||
65 | %.o : %.c | 69 | %.o : %.c |
66 | $(CC) $(CFLAGS) -c $< -o $@ | 70 | $(CC) $(CFLAGS) -c $< -o $@ |
67 | 71 | ||
68 | libz.a: $(OBJS) | 72 | libz.a: $(OBJS) $(OBJA) |
69 | $(AR) $@ $(OBJS) | 73 | $(AR) $@ $(OBJS) $(OBJA) |
70 | 74 | ||
71 | %.exe : %.o $(LIBS) | 75 | %.exe : %.o $(LIBS) |
72 | $(LD) $@ $< $(LDLIBS) | 76 | $(LD) $@ $< $(LDLIBS) |
diff --git a/old/msdos/Makefile.emx b/msdos/Makefile.emx index 0e5e5cc..ed4c31f 100644 --- a/old/msdos/Makefile.emx +++ b/msdos/Makefile.emx | |||
@@ -1,11 +1,11 @@ | |||
1 | # Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98. | 1 | # Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98. |
2 | # Copyright (C) 1995-1998 Jean-loup Gailly. | 2 | # Copyright (C) 1995-1998 Jean-loup Gailly. |
3 | # For conditions of distribution and use, see copyright notice in zlib.h | 3 | # For conditions of distribution and use, see copyright notice in zlib.h |
4 | 4 | ||
5 | # To compile, or to compile and test, type: | 5 | # To compile, or to compile and test, type: |
6 | # | 6 | # |
7 | # make -fmakefile.emx; make test -fmakefile.emx | 7 | # make -fmakefile.emx; make test -fmakefile.emx |
8 | # | 8 | # |
9 | 9 | ||
10 | CC=gcc | 10 | CC=gcc |
11 | 11 | ||
@@ -34,7 +34,7 @@ prefix=/usr/local | |||
34 | exec_prefix = $(prefix) | 34 | exec_prefix = $(prefix) |
35 | 35 | ||
36 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | 36 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ |
37 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o | 37 | zutil.o inflate.o infback.o inftrees.o inffast.o |
38 | 38 | ||
39 | TEST_OBJS = example.o minigzip.o | 39 | TEST_OBJS = example.o minigzip.o |
40 | 40 | ||
@@ -42,7 +42,7 @@ all: example.exe minigzip.exe | |||
42 | 42 | ||
43 | test: all | 43 | test: all |
44 | ./example | 44 | ./example |
45 | echo hello world | .\minigzip | .\minigzip -d | 45 | echo hello world | .\minigzip | .\minigzip -d |
46 | 46 | ||
47 | %.o : %.c | 47 | %.o : %.c |
48 | $(CC) $(CFLAGS) -c $< -o $@ | 48 | $(CC) $(CFLAGS) -c $< -o $@ |
diff --git a/msdos/Makefile.msc b/msdos/Makefile.msc new file mode 100644 index 0000000..b8fc665 --- /dev/null +++ b/msdos/Makefile.msc | |||
@@ -0,0 +1,106 @@ | |||
1 | # Makefile for zlib | ||
2 | # Microsoft C 5.1 or later | ||
3 | # Last updated: 19-Mar-2003 | ||
4 | |||
5 | # To use, do "make makefile.msc" | ||
6 | # To compile in small model, set below: MODEL=S | ||
7 | |||
8 | # If you wish to reduce the memory requirements (default 256K for big | ||
9 | # objects plus a few K), you can add to the LOC macro below: | ||
10 | # -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 | ||
11 | # See zconf.h for details about the memory requirements. | ||
12 | |||
13 | # ------------- Microsoft C 5.1 and later ------------- | ||
14 | |||
15 | # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) | ||
16 | # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added | ||
17 | # to the declaration of LOC here: | ||
18 | LOC = $(LOCAL_ZLIB) | ||
19 | |||
20 | # Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. | ||
21 | CPU_TYP = 0 | ||
22 | |||
23 | # Memory model: one of S, M, C, L (small, medium, compact, large) | ||
24 | MODEL=L | ||
25 | |||
26 | CC=cl | ||
27 | CFLAGS=-nologo -A$(MODEL) -G$(CPU_TYP) -W3 -Oait -Gs $(LOC) | ||
28 | #-Ox generates bad code with MSC 5.1 | ||
29 | LIB_CFLAGS=-Zl $(CFLAGS) | ||
30 | |||
31 | LD=link | ||
32 | LDFLAGS=/noi/e/st:0x1500/noe/farcall/packcode | ||
33 | # "/farcall/packcode" are only useful for `large code' memory models | ||
34 | # but should be a "no-op" for small code models. | ||
35 | |||
36 | |||
37 | # variables | ||
38 | ZLIB_LIB = zlib_$(MODEL).lib | ||
39 | |||
40 | OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj | ||
41 | OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj | ||
42 | |||
43 | |||
44 | # targets | ||
45 | all: $(ZLIB_LIB) example.exe minigzip.exe | ||
46 | |||
47 | .c.obj: | ||
48 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
49 | |||
50 | adler32.obj: adler32.c zlib.h zconf.h | ||
51 | |||
52 | compress.obj: compress.c zlib.h zconf.h | ||
53 | |||
54 | crc32.obj: crc32.c zlib.h zconf.h crc32.h | ||
55 | |||
56 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h | ||
57 | |||
58 | gzio.obj: gzio.c zutil.h zlib.h zconf.h | ||
59 | |||
60 | infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | ||
61 | inffast.h inffixed.h | ||
62 | |||
63 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | ||
64 | inffast.h | ||
65 | |||
66 | inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | ||
67 | inffast.h inffixed.h | ||
68 | |||
69 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h | ||
70 | |||
71 | trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h | ||
72 | |||
73 | uncompr.obj: uncompr.c zlib.h zconf.h | ||
74 | |||
75 | zutil.obj: zutil.c zutil.h zlib.h zconf.h | ||
76 | |||
77 | example.obj: example.c zlib.h zconf.h | ||
78 | $(CC) -c $(CFLAGS) $*.c | ||
79 | |||
80 | minigzip.obj: minigzip.c zlib.h zconf.h | ||
81 | $(CC) -c $(CFLAGS) $*.c | ||
82 | |||
83 | |||
84 | # the command line is cut to fit in the MS-DOS 128 byte limit: | ||
85 | $(ZLIB_LIB): $(OBJ1) $(OBJ2) | ||
86 | if exist $(ZLIB_LIB) del $(ZLIB_LIB) | ||
87 | lib $(ZLIB_LIB) $(OBJ1); | ||
88 | lib $(ZLIB_LIB) $(OBJ2); | ||
89 | |||
90 | example.exe: example.obj $(ZLIB_LIB) | ||
91 | $(LD) $(LDFLAGS) example.obj,,,$(ZLIB_LIB); | ||
92 | |||
93 | minigzip.exe: minigzip.obj $(ZLIB_LIB) | ||
94 | $(LD) $(LDFLAGS) minigzip.obj,,,$(ZLIB_LIB); | ||
95 | |||
96 | test: example.exe minigzip.exe | ||
97 | example | ||
98 | echo hello world | minigzip | minigzip -d | ||
99 | |||
100 | clean: | ||
101 | -del *.obj | ||
102 | -del *.lib | ||
103 | -del *.exe | ||
104 | -del *.map | ||
105 | -del zlib_*.bak | ||
106 | -del foo.gz | ||
diff --git a/msdos/Makefile.tc b/msdos/Makefile.tc index d0a7864..480750a 100644 --- a/msdos/Makefile.tc +++ b/msdos/Makefile.tc | |||
@@ -1,6 +1,6 @@ | |||
1 | # Makefile for zlib | 1 | # Makefile for zlib |
2 | # Turbo C 2.01, Turbo C++ 1.01 | 2 | # Turbo C 2.01, Turbo C++ 1.01 |
3 | # Updated for zlib-1.2.x by Cosmin Truta, 15-Mar-2003. | 3 | # Last updated: 15-Mar-2003 |
4 | 4 | ||
5 | # To use, do "make -fmakefile.tc" | 5 | # To use, do "make -fmakefile.tc" |
6 | # To compile in small model, set below: MODEL=s | 6 | # To compile in small model, set below: MODEL=s |
@@ -88,7 +88,7 @@ test: example.exe minigzip.exe | |||
88 | 88 | ||
89 | clean: | 89 | clean: |
90 | -del *.obj | 90 | -del *.obj |
91 | -del *.exe | ||
92 | -del *.lib | 91 | -del *.lib |
93 | -del zlib_$(MODEL).bak | 92 | -del *.exe |
93 | -del zlib_*.bak | ||
94 | -del foo.gz | 94 | -del foo.gz |
diff --git a/old/Make_vms.com b/old/Make_vms.com index 1c57e8f..4fe3013 100644..100755 --- a/old/Make_vms.com +++ b/old/Make_vms.com | |||
@@ -64,8 +64,8 @@ $ call make example.exe "LINK example,libz.olb/lib" example.obj libz.olb | |||
64 | $ write sys$output "Building minigzip..." | 64 | $ write sys$output "Building minigzip..." |
65 | $ CALL MAKE minigzip.OBJ "CC ''CCOPT' minigzip" - | 65 | $ CALL MAKE minigzip.OBJ "CC ''CCOPT' minigzip" - |
66 | minigzip.c zlib.h zconf.h | 66 | minigzip.c zlib.h zconf.h |
67 | $ call make minigzip.exe - | 67 | $ call make minigzip.exe - |
68 | "LINK minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib" - | 68 | "LINK minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib" - |
69 | minigzip.obj libz.olb | 69 | minigzip.obj libz.olb |
70 | $ else | 70 | $ else |
71 | $ mms/macro=('comp') | 71 | $ mms/macro=('comp') |
diff --git a/old/descrip.mms b/old/descrip.mms index 9d36459..7066da5 100644 --- a/old/descrip.mms +++ b/old/descrip.mms | |||
@@ -1,8 +1,8 @@ | |||
1 | # descrip.mms: MMS description file for building zlib on VMS | 1 | # descrip.mms: MMS description file for building zlib on VMS |
2 | # written by Martin P.J. Zinser <m.zinser@gsi.de> | 2 | # written by Martin P.J. Zinser <m.zinser@gsi.de> |
3 | 3 | ||
4 | cc_defs = | 4 | cc_defs = |
5 | c_deb = | 5 | c_deb = |
6 | 6 | ||
7 | .ifdef __DECC__ | 7 | .ifdef __DECC__ |
8 | pref = /prefix=all | 8 | pref = /prefix=all |
@@ -25,7 +25,7 @@ example.exe : example.obj libz.olb | |||
25 | minigzip.exe : minigzip.obj libz.olb | 25 | minigzip.exe : minigzip.obj libz.olb |
26 | link minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib | 26 | link minigzip,libz.olb/lib,x11vms:xvmsutils.olb/lib |
27 | 27 | ||
28 | clean : | 28 | clean : |
29 | delete *.obj;*,libz.olb;* | 29 | delete *.obj;*,libz.olb;* |
30 | 30 | ||
31 | 31 | ||
diff --git a/old/msdos/Makefile.b32 b/old/msdos/Makefile.b32 index f476da9..3802ea4 100644 --- a/old/msdos/Makefile.b32 +++ b/old/msdos/Makefile.b32 | |||
@@ -1,5 +1,5 @@ | |||
1 | # Makefile for zlib | 1 | # Makefile for zlib |
2 | # Borland C++ | 2 | # Borland C++ |
3 | 3 | ||
4 | # This version of the zlib makefile was adapted by Chris Young for use | 4 | # This version of the zlib makefile was adapted by Chris Young for use |
5 | # with Borland C 4.5x with the Dos Power Pack for a 32-bit protected mode | 5 | # with Borland C 4.5x with the Dos Power Pack for a 32-bit protected mode |
@@ -13,7 +13,7 @@ | |||
13 | # See zconf.h for details about the memory requirements. | 13 | # See zconf.h for details about the memory requirements. |
14 | 14 | ||
15 | # ------------- Borland C++ ------------- | 15 | # ------------- Borland C++ ------------- |
16 | MODEL=-WX | 16 | MODEL=-WX |
17 | CFLAGS= $(MODEL) -P-C -K -N- -k- -d -3 -r- -v- -f -DMSDOS | 17 | CFLAGS= $(MODEL) -P-C -K -N- -k- -d -3 -r- -v- -f -DMSDOS |
18 | CC=bcc32 | 18 | CC=bcc32 |
19 | LD=bcc32 | 19 | LD=bcc32 |
@@ -97,7 +97,7 @@ minigzip.exe: minigzip.obj zlib.lib | |||
97 | 97 | ||
98 | test: example.exe minigzip.exe | 98 | test: example.exe minigzip.exe |
99 | example | 99 | example |
100 | echo hello world | minigzip | minigzip -d | 100 | echo hello world | minigzip | minigzip -d |
101 | 101 | ||
102 | #clean: | 102 | #clean: |
103 | # del *.obj | 103 | # del *.obj |
diff --git a/old/msdos/Makefile.msc b/old/msdos/Makefile.msc deleted file mode 100644 index 562201d..0000000 --- a/old/msdos/Makefile.msc +++ /dev/null | |||
@@ -1,121 +0,0 @@ | |||
1 | # Makefile for zlib | ||
2 | # Microsoft C 5.1 or later | ||
3 | |||
4 | # To use, do "make makefile.msc" | ||
5 | # To compile in small model, set below: MODEL=S | ||
6 | |||
7 | # If you wish to reduce the memory requirements (default 256K for big | ||
8 | # objects plus a few K), you can add to the LOC macro below: | ||
9 | # -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 | ||
10 | # See zconf.h for details about the memory requirements. | ||
11 | |||
12 | # ------------- Microsoft C 5.1 and later ------------- | ||
13 | |||
14 | # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) | ||
15 | # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added | ||
16 | # to the declaration of LOC here: | ||
17 | LOC = $(LOCAL_ZLIB) | ||
18 | |||
19 | # Type for CPU required: 0: 8086, 1: 80186, 2: 80286, 3: 80386, etc. | ||
20 | CPU_TYP = 0 | ||
21 | |||
22 | # Memory model: one of S, M, C, L (small, medium, compact, large) | ||
23 | MODEL=L | ||
24 | |||
25 | CC=cl | ||
26 | CFLAGS=-nologo -A$(MODEL) -G$(CPU_TYP) -W3 -Oait -Gs $(LOC) | ||
27 | #-Ox generates bad code with MSC 5.1 | ||
28 | LIB_CFLAGS=-Zl $(CFLAGS) | ||
29 | |||
30 | LD=link | ||
31 | LDFLAGS=/noi/e/st:0x1500/noe/farcall/packcode | ||
32 | # "/farcall/packcode" are only useful for `large code' memory models | ||
33 | # but should be a "no-op" for small code models. | ||
34 | |||
35 | O=.obj | ||
36 | |||
37 | # variables | ||
38 | OBJ1 = adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) \ | ||
39 | trees$(O) | ||
40 | OBJP1 = adler32$(O)+compress$(O)+crc32$(O)+gzio$(O)+uncompr$(O)+deflate$(O)+\ | ||
41 | trees$(O) | ||
42 | OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \ | ||
43 | infutil$(O) inffast$(O) | ||
44 | OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ | ||
45 | infutil$(O)+inffast$(O) | ||
46 | |||
47 | ZLIB_H = zlib.h zconf.h | ||
48 | ZUTIL_H = zutil.h $(ZLIB_H) | ||
49 | |||
50 | ZLIB_LIB = zlib_$(MODEL).lib | ||
51 | |||
52 | all: $(ZLIB_LIB) example.exe minigzip.exe | ||
53 | |||
54 | # individual dependencies and action rules: | ||
55 | adler32.obj: adler32.c $(ZLIB_H) | ||
56 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
57 | |||
58 | compress.obj: compress.c $(ZLIB_H) | ||
59 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
60 | |||
61 | crc32.obj: crc32.c $(ZLIB_H) | ||
62 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
63 | |||
64 | deflate.obj: deflate.c deflate.h $(ZUTIL_H) | ||
65 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
66 | |||
67 | gzio.obj: gzio.c $(ZUTIL_H) | ||
68 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
69 | |||
70 | infblock.obj: infblock.c $(ZUTIL_H) infblock.h inftrees.h infcodes.h infutil.h | ||
71 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
72 | |||
73 | infcodes.obj: infcodes.c $(ZUTIL_H) inftrees.h infutil.h infcodes.h inffast.h | ||
74 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
75 | |||
76 | inflate.obj: inflate.c $(ZUTIL_H) infblock.h | ||
77 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
78 | |||
79 | inftrees.obj: inftrees.c $(ZUTIL_H) inftrees.h | ||
80 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
81 | |||
82 | infutil.obj: infutil.c $(ZUTIL_H) inftrees.h infutil.h | ||
83 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
84 | |||
85 | inffast.obj: inffast.c $(ZUTIL_H) inftrees.h infutil.h inffast.h | ||
86 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
87 | |||
88 | trees.obj: trees.c deflate.h $(ZUTIL_H) | ||
89 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
90 | |||
91 | uncompr.obj: uncompr.c $(ZLIB_H) | ||
92 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
93 | |||
94 | zutil.obj: zutil.c $(ZUTIL_H) | ||
95 | $(CC) -c $(LIB_CFLAGS) $*.c | ||
96 | |||
97 | example.obj: example.c $(ZLIB_H) | ||
98 | $(CC) -c $(CFLAGS) $*.c | ||
99 | |||
100 | minigzip.obj: minigzip.c $(ZLIB_H) | ||
101 | $(CC) -c $(CFLAGS) $*.c | ||
102 | |||
103 | # we must cut the command line to fit in the MS/DOS 128 byte limit: | ||
104 | $(ZLIB_LIB): $(OBJ1) $(OBJ2) | ||
105 | if exist $(ZLIB_LIB) del $(ZLIB_LIB) | ||
106 | lib $(ZLIB_LIB) $(OBJ1); | ||
107 | lib $(ZLIB_LIB) $(OBJ2); | ||
108 | |||
109 | example.exe: example.obj $(ZLIB_LIB) | ||
110 | $(LD) $(LDFLAGS) example.obj,,,$(ZLIB_LIB); | ||
111 | |||
112 | minigzip.exe: minigzip.obj $(ZLIB_LIB) | ||
113 | $(LD) $(LDFLAGS) minigzip.obj,,,$(ZLIB_LIB); | ||
114 | |||
115 | test: example.exe minigzip.exe | ||
116 | example | ||
117 | echo hello world | minigzip | minigzip -d | ||
118 | |||
119 | #clean: | ||
120 | # del *.obj | ||
121 | # del *.exe | ||
diff --git a/old/msdos/Makefile.w32 b/old/msdos/Makefile.w32 deleted file mode 100644 index 0a05fa9..0000000 --- a/old/msdos/Makefile.w32 +++ /dev/null | |||
@@ -1,97 +0,0 @@ | |||
1 | # Makefile for zlib | ||
2 | # Microsoft 32-bit Visual C++ 4.0 or later (may work on earlier versions) | ||
3 | |||
4 | # To use, do "nmake /f makefile.w32" | ||
5 | |||
6 | # If you wish to reduce the memory requirements (default 256K for big | ||
7 | # objects plus a few K), you can add to CFLAGS below: | ||
8 | # -DMAX_MEM_LEVEL=7 -DMAX_WBITS=14 | ||
9 | # See zconf.h for details about the memory requirements. | ||
10 | |||
11 | # ------------- Microsoft Visual C++ 4.0 and later ------------- | ||
12 | MODEL= | ||
13 | CFLAGS=-Ox -GA3s -nologo -W3 | ||
14 | CC=cl | ||
15 | LD=link | ||
16 | LDFLAGS= | ||
17 | O=.obj | ||
18 | |||
19 | # variables | ||
20 | OBJ1 = adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) \ | ||
21 | trees$(O) | ||
22 | OBJP1 = adler32$(O)+compress$(O)+crc32$(O)+gzio$(O)+uncompr$(O)+deflate$(O)+\ | ||
23 | trees$(O) | ||
24 | OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \ | ||
25 | infutil$(O) inffast$(O) | ||
26 | OBJP2 = zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O)+\ | ||
27 | infutil$(O)+inffast$(O) | ||
28 | |||
29 | all: zlib.lib example.exe minigzip.exe | ||
30 | |||
31 | adler32.obj: adler32.c zlib.h zconf.h | ||
32 | $(CC) -c $(CFLAGS) $*.c | ||
33 | |||
34 | compress.obj: compress.c zlib.h zconf.h | ||
35 | $(CC) -c $(CFLAGS) $*.c | ||
36 | |||
37 | crc32.obj: crc32.c zlib.h zconf.h | ||
38 | $(CC) -c $(CFLAGS) $*.c | ||
39 | |||
40 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h | ||
41 | $(CC) -c $(CFLAGS) $*.c | ||
42 | |||
43 | gzio.obj: gzio.c zutil.h zlib.h zconf.h | ||
44 | $(CC) -c $(CFLAGS) $*.c | ||
45 | |||
46 | infblock.obj: infblock.c zutil.h zlib.h zconf.h infblock.h inftrees.h\ | ||
47 | infcodes.h infutil.h | ||
48 | $(CC) -c $(CFLAGS) $*.c | ||
49 | |||
50 | infcodes.obj: infcodes.c zutil.h zlib.h zconf.h inftrees.h infutil.h\ | ||
51 | infcodes.h inffast.h | ||
52 | $(CC) -c $(CFLAGS) $*.c | ||
53 | |||
54 | inflate.obj: inflate.c zutil.h zlib.h zconf.h infblock.h | ||
55 | $(CC) -c $(CFLAGS) $*.c | ||
56 | |||
57 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h | ||
58 | $(CC) -c $(CFLAGS) $*.c | ||
59 | |||
60 | infutil.obj: infutil.c zutil.h zlib.h zconf.h inftrees.h infutil.h | ||
61 | $(CC) -c $(CFLAGS) $*.c | ||
62 | |||
63 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h | ||
64 | $(CC) -c $(CFLAGS) $*.c | ||
65 | |||
66 | trees.obj: trees.c deflate.h zutil.h zlib.h zconf.h | ||
67 | $(CC) -c $(CFLAGS) $*.c | ||
68 | |||
69 | uncompr.obj: uncompr.c zlib.h zconf.h | ||
70 | $(CC) -c $(CFLAGS) $*.c | ||
71 | |||
72 | zutil.obj: zutil.c zutil.h zlib.h zconf.h | ||
73 | $(CC) -c $(CFLAGS) $*.c | ||
74 | |||
75 | example.obj: example.c zlib.h zconf.h | ||
76 | $(CC) -c $(CFLAGS) $*.c | ||
77 | |||
78 | minigzip.obj: minigzip.c zlib.h zconf.h | ||
79 | $(CC) -c $(CFLAGS) $*.c | ||
80 | |||
81 | zlib.lib: $(OBJ1) $(OBJ2) | ||
82 | if exist zlib.lib del zlib.lib | ||
83 | lib /OUT:zlib.lib $(OBJ1) $(OBJ2) | ||
84 | |||
85 | example.exe: example.obj zlib.lib | ||
86 | $(LD) $(LDFLAGS) example.obj zlib.lib /OUT:example.exe /SUBSYSTEM:CONSOLE | ||
87 | |||
88 | minigzip.exe: minigzip.obj zlib.lib | ||
89 | $(LD) $(LDFLAGS) minigzip.obj zlib.lib /OUT:minigzip.exe /SUBSYSTEM:CONSOLE | ||
90 | |||
91 | test: example.exe minigzip.exe | ||
92 | example | ||
93 | echo hello world | minigzip | minigzip -d | ||
94 | |||
95 | #clean: | ||
96 | # del *.obj | ||
97 | # del *.exe | ||
diff --git a/old/msdos/Makefile.wat b/old/msdos/Makefile.wat index 44bf860..065fe4c 100644 --- a/old/msdos/Makefile.wat +++ b/old/msdos/Makefile.wat | |||
@@ -2,8 +2,8 @@ | |||
2 | # Watcom 10a | 2 | # Watcom 10a |
3 | 3 | ||
4 | # This version of the zlib makefile was adapted by Chris Young for use | 4 | # This version of the zlib makefile was adapted by Chris Young for use |
5 | # with Watcom 10a 32-bit protected mode flat memory model. It was created | 5 | # with Watcom 10a 32-bit protected mode flat memory model. It was created |
6 | # for use with POV-Ray ray tracer and you may choose to edit the CFLAGS to | 6 | # for use with POV-Ray ray tracer and you may choose to edit the CFLAGS to |
7 | # suit your needs but the -DMSDOS is required. | 7 | # suit your needs but the -DMSDOS is required. |
8 | # -- Chris Young 76702.1655@compuserve.com | 8 | # -- Chris Young 76702.1655@compuserve.com |
9 | 9 | ||
@@ -12,17 +12,17 @@ | |||
12 | # See zconf.h for details about the memory requirements. | 12 | # See zconf.h for details about the memory requirements. |
13 | 13 | ||
14 | # ------------- Watcom 10a ------------- | 14 | # ------------- Watcom 10a ------------- |
15 | MODEL=-mf | 15 | MODEL=-mf |
16 | CFLAGS= $(MODEL) -fpi87 -fp5 -zp4 -5r -w5 -oneatx -DMSDOS | 16 | CFLAGS= $(MODEL) -fpi87 -fp5 -zp4 -5r -w5 -oneatx -DMSDOS |
17 | CC=wcc386 | 17 | CC=wcc386 |
18 | LD=wcl386 | 18 | LD=wcl386 |
19 | LIB=wlib -b -c | 19 | LIB=wlib -b -c |
20 | LDFLAGS= | 20 | LDFLAGS= |
21 | O=.obj | 21 | O=.obj |
22 | 22 | ||
23 | # variables | 23 | # variables |
24 | OBJ1=adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) | 24 | OBJ1=adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) |
25 | OBJ2=trees$(O) zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) | 25 | OBJ2=trees$(O) zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) |
26 | OBJ3=infutil$(O) inffast$(O) | 26 | OBJ3=infutil$(O) inffast$(O) |
27 | OBJP1=adler32$(O)+compress$(O)+crc32$(O)+gzio$(O)+uncompr$(O)+deflate$(O) | 27 | OBJP1=adler32$(O)+compress$(O)+crc32$(O)+gzio$(O)+uncompr$(O)+deflate$(O) |
28 | OBJP2=trees$(O)+zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O) | 28 | OBJP2=trees$(O)+zutil$(O)+inflate$(O)+infblock$(O)+inftrees$(O)+infcodes$(O) |
@@ -81,7 +81,7 @@ minigzip.obj: minigzip.c zlib.h zconf.h | |||
81 | $(CC) $(CFLAGS) $*.c | 81 | $(CC) $(CFLAGS) $*.c |
82 | 82 | ||
83 | # we must cut the command line to fit in the MS/DOS 128 byte limit: | 83 | # we must cut the command line to fit in the MS/DOS 128 byte limit: |
84 | zlib.lib: $(OBJ1) $(OBJ2) $(OBJ3) | 84 | zlib.lib: $(OBJ1) $(OBJ2) $(OBJ3) |
85 | del zlib.lib | 85 | del zlib.lib |
86 | $(LIB) zlib.lib +$(OBJP1) | 86 | $(LIB) zlib.lib +$(OBJP1) |
87 | $(LIB) zlib.lib +$(OBJP2) | 87 | $(LIB) zlib.lib +$(OBJP2) |
diff --git a/old/msdos/zlib.def b/old/msdos/zlib.def deleted file mode 100644 index 6c04412..0000000 --- a/old/msdos/zlib.def +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | LIBRARY "zlib" | ||
2 | |||
3 | DESCRIPTION '"""zlib data compression library"""' | ||
4 | |||
5 | EXETYPE NT | ||
6 | |||
7 | SUBSYSTEM WINDOWS | ||
8 | |||
9 | STUB 'WINSTUB.EXE' | ||
10 | |||
11 | VERSION 1.13 | ||
12 | |||
13 | CODE EXECUTE READ | ||
14 | |||
15 | DATA READ WRITE | ||
16 | |||
17 | HEAPSIZE 1048576,4096 | ||
18 | |||
19 | EXPORTS | ||
20 | adler32 @1 | ||
21 | compress @2 | ||
22 | crc32 @3 | ||
23 | deflate @4 | ||
24 | deflateCopy @5 | ||
25 | deflateEnd @6 | ||
26 | deflateInit2_ @7 | ||
27 | deflateInit_ @8 | ||
28 | deflateParams @9 | ||
29 | deflateReset @10 | ||
30 | deflateSetDictionary @11 | ||
31 | gzclose @12 | ||
32 | gzdopen @13 | ||
33 | gzerror @14 | ||
34 | gzflush @15 | ||
35 | gzopen @16 | ||
36 | gzread @17 | ||
37 | gzwrite @18 | ||
38 | inflate @19 | ||
39 | inflateEnd @20 | ||
40 | inflateInit2_ @21 | ||
41 | inflateInit_ @22 | ||
42 | inflateReset @23 | ||
43 | inflateSetDictionary @24 | ||
44 | inflateSync @25 | ||
45 | uncompress @26 | ||
46 | zlibVersion @27 | ||
47 | gzprintf @28 | ||
48 | gzputc @29 | ||
49 | gzgetc @30 | ||
50 | gzseek @31 | ||
51 | gzrewind @32 | ||
52 | gztell @33 | ||
53 | gzeof @34 | ||
54 | gzsetparams @35 | ||
55 | zError @36 | ||
56 | inflateSyncPoint @37 | ||
57 | get_crc_table @38 | ||
58 | compress2 @39 | ||
59 | gzputs @40 | ||
60 | gzgets @41 | ||
diff --git a/old/msdos/zlib.rc b/old/msdos/zlib.rc deleted file mode 100644 index 556d4ff..0000000 --- a/old/msdos/zlib.rc +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | #include <windows.h> | ||
2 | |||
3 | #define IDR_VERSION1 1 | ||
4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE | ||
5 | FILEVERSION 1,1,3,0 | ||
6 | PRODUCTVERSION 1,1,3,0 | ||
7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK | ||
8 | FILEFLAGS 0 | ||
9 | FILEOS VOS_DOS_WINDOWS32 | ||
10 | FILETYPE VFT_DLL | ||
11 | FILESUBTYPE 0 // not used | ||
12 | BEGIN | ||
13 | BLOCK "StringFileInfo" | ||
14 | BEGIN | ||
15 | BLOCK "040904E4" | ||
16 | //language ID = U.S. English, char set = Windows, Multilingual | ||
17 | |||
18 | BEGIN | ||
19 | VALUE "FileDescription", "zlib data compression library\0" | ||
20 | VALUE "FileVersion", "1.1.3\0" | ||
21 | VALUE "InternalName", "zlib\0" | ||
22 | VALUE "OriginalFilename", "zlib.dll\0" | ||
23 | VALUE "ProductName", "ZLib.DLL\0" | ||
24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" | ||
25 | VALUE "LegalCopyright", "(C) 1995-1998 Jean-loup Gailly & Mark Adler\0" | ||
26 | END | ||
27 | END | ||
28 | BLOCK "VarFileInfo" | ||
29 | BEGIN | ||
30 | VALUE "Translation", 0x0409, 1252 | ||
31 | END | ||
32 | END | ||
diff --git a/old/nt/Makefile.emx b/old/nt/Makefile.emx deleted file mode 100644 index 2d475b1..0000000 --- a/old/nt/Makefile.emx +++ /dev/null | |||
@@ -1,138 +0,0 @@ | |||
1 | # Makefile for zlib. Modified for emx/rsxnt by Chr. Spieler, 6/16/98. | ||
2 | # Copyright (C) 1995-1998 Jean-loup Gailly. | ||
3 | # For conditions of distribution and use, see copyright notice in zlib.h | ||
4 | |||
5 | # To compile, or to compile and test, type: | ||
6 | # | ||
7 | # make -fmakefile.emx; make test -fmakefile.emx | ||
8 | # | ||
9 | |||
10 | CC=gcc -Zwin32 | ||
11 | |||
12 | #CFLAGS=-MMD -O | ||
13 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 | ||
14 | #CFLAGS=-MMD -g -DDEBUG | ||
15 | CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ | ||
16 | -Wstrict-prototypes -Wmissing-prototypes | ||
17 | |||
18 | # If cp.exe is available, replace "copy /Y" with "cp -fp" . | ||
19 | CP=copy /Y | ||
20 | # If gnu install.exe is available, replace $(CP) with ginstall. | ||
21 | INSTALL=$(CP) | ||
22 | # The default value of RM is "rm -f." If "rm.exe" is found, comment out: | ||
23 | RM=del | ||
24 | LDLIBS=-L. -lzlib | ||
25 | LD=$(CC) -s -o | ||
26 | LDSHARED=$(CC) | ||
27 | |||
28 | INCL=zlib.h zconf.h | ||
29 | LIBS=zlib.a | ||
30 | |||
31 | AR=ar rcs | ||
32 | |||
33 | prefix=/usr/local | ||
34 | exec_prefix = $(prefix) | ||
35 | |||
36 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | ||
37 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o | ||
38 | |||
39 | TEST_OBJS = example.o minigzip.o | ||
40 | |||
41 | all: example.exe minigzip.exe | ||
42 | |||
43 | test: all | ||
44 | ./example | ||
45 | echo hello world | .\minigzip | .\minigzip -d | ||
46 | |||
47 | %.o : %.c | ||
48 | $(CC) $(CFLAGS) -c $< -o $@ | ||
49 | |||
50 | zlib.a: $(OBJS) | ||
51 | $(AR) $@ $(OBJS) | ||
52 | |||
53 | %.exe : %.o $(LIBS) | ||
54 | $(LD) $@ $< $(LDLIBS) | ||
55 | |||
56 | |||
57 | .PHONY : clean | ||
58 | |||
59 | clean: | ||
60 | $(RM) *.d | ||
61 | $(RM) *.o | ||
62 | $(RM) *.exe | ||
63 | $(RM) zlib.a | ||
64 | $(RM) foo.gz | ||
65 | |||
66 | DEPS := $(wildcard *.d) | ||
67 | ifneq ($(DEPS),) | ||
68 | include $(DEPS) | ||
69 | endif | ||
70 | # Makefile for zlib. Modified for emx 0.9c by Chr. Spieler, 6/17/98. | ||
71 | # Copyright (C) 1995-1998 Jean-loup Gailly. | ||
72 | # For conditions of distribution and use, see copyright notice in zlib.h | ||
73 | |||
74 | # To compile, or to compile and test, type: | ||
75 | # | ||
76 | # make -fmakefile.emx; make test -fmakefile.emx | ||
77 | # | ||
78 | |||
79 | CC=gcc | ||
80 | |||
81 | #CFLAGS=-MMD -O | ||
82 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 | ||
83 | #CFLAGS=-MMD -g -DDEBUG | ||
84 | CFLAGS=-MMD -O3 $(BUTT) -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ | ||
85 | -Wstrict-prototypes -Wmissing-prototypes | ||
86 | |||
87 | # If cp.exe is available, replace "copy /Y" with "cp -fp" . | ||
88 | CP=copy /Y | ||
89 | # If gnu install.exe is available, replace $(CP) with ginstall. | ||
90 | INSTALL=$(CP) | ||
91 | # The default value of RM is "rm -f." If "rm.exe" is found, comment out: | ||
92 | RM=del | ||
93 | LDLIBS=-L. -lzlib | ||
94 | LD=$(CC) -s -o | ||
95 | LDSHARED=$(CC) | ||
96 | |||
97 | INCL=zlib.h zconf.h | ||
98 | LIBS=zlib.a | ||
99 | |||
100 | AR=ar rcs | ||
101 | |||
102 | prefix=/usr/local | ||
103 | exec_prefix = $(prefix) | ||
104 | |||
105 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | ||
106 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o | ||
107 | |||
108 | TEST_OBJS = example.o minigzip.o | ||
109 | |||
110 | all: example.exe minigzip.exe | ||
111 | |||
112 | test: all | ||
113 | ./example | ||
114 | echo hello world | .\minigzip | .\minigzip -d | ||
115 | |||
116 | %.o : %.c | ||
117 | $(CC) $(CFLAGS) -c $< -o $@ | ||
118 | |||
119 | zlib.a: $(OBJS) | ||
120 | $(AR) $@ $(OBJS) | ||
121 | |||
122 | %.exe : %.o $(LIBS) | ||
123 | $(LD) $@ $< $(LDLIBS) | ||
124 | |||
125 | |||
126 | .PHONY : clean | ||
127 | |||
128 | clean: | ||
129 | $(RM) *.d | ||
130 | $(RM) *.o | ||
131 | $(RM) *.exe | ||
132 | $(RM) zlib.a | ||
133 | $(RM) foo.gz | ||
134 | |||
135 | DEPS := $(wildcard *.d) | ||
136 | ifneq ($(DEPS),) | ||
137 | include $(DEPS) | ||
138 | endif | ||
diff --git a/old/nt/Makefile.nt b/old/nt/Makefile.nt deleted file mode 100644 index b250f2a..0000000 --- a/old/nt/Makefile.nt +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | # Makefile for zlib | ||
2 | |||
3 | !include <ntwin32.mak> | ||
4 | |||
5 | CC=cl | ||
6 | LD=link | ||
7 | CFLAGS=-O -nologo | ||
8 | LDFLAGS= | ||
9 | O=.obj | ||
10 | |||
11 | # variables | ||
12 | OBJ1 = adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) \ | ||
13 | trees$(O) | ||
14 | OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \ | ||
15 | infutil$(O) inffast$(O) | ||
16 | |||
17 | all: zlib.dll example.exe minigzip.exe | ||
18 | |||
19 | adler32.obj: adler32.c zutil.h zlib.h zconf.h | ||
20 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
21 | |||
22 | compress.obj: compress.c zlib.h zconf.h | ||
23 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
24 | |||
25 | crc32.obj: crc32.c zutil.h zlib.h zconf.h | ||
26 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
27 | |||
28 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h | ||
29 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
30 | |||
31 | gzio.obj: gzio.c zutil.h zlib.h zconf.h | ||
32 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
33 | |||
34 | infblock.obj: infblock.c zutil.h zlib.h zconf.h infblock.h inftrees.h\ | ||
35 | infcodes.h infutil.h | ||
36 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
37 | |||
38 | infcodes.obj: infcodes.c zutil.h zlib.h zconf.h inftrees.h infutil.h\ | ||
39 | infcodes.h inffast.h | ||
40 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
41 | |||
42 | inflate.obj: inflate.c zutil.h zlib.h zconf.h infblock.h | ||
43 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
44 | |||
45 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h | ||
46 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
47 | |||
48 | infutil.obj: infutil.c zutil.h zlib.h zconf.h inftrees.h infutil.h | ||
49 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
50 | |||
51 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h infutil.h inffast.h | ||
52 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
53 | |||
54 | trees.obj: trees.c deflate.h zutil.h zlib.h zconf.h | ||
55 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
56 | |||
57 | uncompr.obj: uncompr.c zlib.h zconf.h | ||
58 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
59 | |||
60 | zutil.obj: zutil.c zutil.h zlib.h zconf.h | ||
61 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
62 | |||
63 | example.obj: example.c zlib.h zconf.h | ||
64 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
65 | |||
66 | minigzip.obj: minigzip.c zlib.h zconf.h | ||
67 | $(CC) -c $(cvarsdll) $(CFLAGS) $*.c | ||
68 | |||
69 | zlib.dll: $(OBJ1) $(OBJ2) zlib.dnt | ||
70 | link $(dlllflags) -out:$@ -def:zlib.dnt $(OBJ1) $(OBJ2) $(guilibsdll) | ||
71 | |||
72 | zlib.lib: zlib.dll | ||
73 | |||
74 | example.exe: example.obj zlib.lib | ||
75 | $(LD) $(LDFLAGS) example.obj zlib.lib | ||
76 | |||
77 | minigzip.exe: minigzip.obj zlib.lib | ||
78 | $(LD) $(LDFLAGS) minigzip.obj zlib.lib | ||
79 | |||
80 | test: example.exe minigzip.exe | ||
81 | example | ||
82 | echo hello world | minigzip | minigzip -d | ||
83 | |||
84 | clean: | ||
85 | del *.obj | ||
86 | del *.exe | ||
87 | del *.dll | ||
88 | del *.lib | ||
diff --git a/old/nt/zlib.dnt b/old/nt/zlib.dnt deleted file mode 100644 index 7f9475c..0000000 --- a/old/nt/zlib.dnt +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | LIBRARY zlib.dll | ||
2 | EXETYPE WINDOWS | ||
3 | CODE PRELOAD MOVEABLE DISCARDABLE | ||
4 | DATA PRELOAD MOVEABLE MULTIPLE | ||
5 | |||
6 | EXPORTS | ||
7 | adler32 @1 | ||
8 | compress @2 | ||
9 | crc32 @3 | ||
10 | deflate @4 | ||
11 | deflateCopy @5 | ||
12 | deflateEnd @6 | ||
13 | deflateInit2_ @7 | ||
14 | deflateInit_ @8 | ||
15 | deflateParams @9 | ||
16 | deflateReset @10 | ||
17 | deflateSetDictionary @11 | ||
18 | gzclose @12 | ||
19 | gzdopen @13 | ||
20 | gzerror @14 | ||
21 | gzflush @15 | ||
22 | gzopen @16 | ||
23 | gzread @17 | ||
24 | gzwrite @18 | ||
25 | inflate @19 | ||
26 | inflateEnd @20 | ||
27 | inflateInit2_ @21 | ||
28 | inflateInit_ @22 | ||
29 | inflateReset @23 | ||
30 | inflateSetDictionary @24 | ||
31 | inflateSync @25 | ||
32 | uncompress @26 | ||
33 | zlibVersion @27 | ||
34 | gzprintf @28 | ||
35 | gzputc @29 | ||
36 | gzgetc @30 | ||
37 | gzseek @31 | ||
38 | gzrewind @32 | ||
39 | gztell @33 | ||
40 | gzeof @34 | ||
41 | gzsetparams @35 | ||
42 | zError @36 | ||
43 | inflateSyncPoint @37 | ||
44 | get_crc_table @38 | ||
45 | compress2 @39 | ||
46 | gzputs @40 | ||
47 | gzgets @41 | ||
diff --git a/old/os2/Makefile.os2 b/old/os2/Makefile.os2 index 4f56947..a105aaa 100644 --- a/old/os2/Makefile.os2 +++ b/old/os2/Makefile.os2 | |||
@@ -1,5 +1,5 @@ | |||
1 | # Makefile for zlib under OS/2 using GCC (PGCC) | 1 | # Makefile for zlib under OS/2 using GCC (PGCC) |
2 | # For conditions of distribution and use, see copyright notice in zlib.h | 2 | # For conditions of distribution and use, see copyright notice in zlib.h |
3 | 3 | ||
4 | # To compile and test, type: | 4 | # To compile and test, type: |
5 | # cp Makefile.os2 .. | 5 | # cp Makefile.os2 .. |
@@ -108,7 +108,7 @@ dist: | |||
108 | if test ! -d $$d; then rm -f $$d; fi | 108 | if test ! -d $$d; then rm -f $$d; fi |
109 | mv Makefile~ Makefile | 109 | mv Makefile~ Makefile |
110 | 110 | ||
111 | tags: | 111 | tags: |
112 | etags *.[ch] | 112 | etags *.[ch] |
113 | 113 | ||
114 | depend: | 114 | depend: |
@@ -130,7 +130,7 @@ inffast.o: infblock.h infcodes.h infutil.h inffast.h | |||
130 | inflate.o: zutil.h zlib.h zconf.h infblock.h | 130 | inflate.o: zutil.h zlib.h zconf.h infblock.h |
131 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h | 131 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h |
132 | infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h | 132 | infutil.o: zutil.h zlib.h zconf.h infblock.h inftrees.h infcodes.h infutil.h |
133 | minigzip.o: zlib.h zconf.h | 133 | minigzip.o: zlib.h zconf.h |
134 | trees.o: deflate.h zutil.h zlib.h zconf.h trees.h | 134 | trees.o: deflate.h zutil.h zlib.h zconf.h trees.h |
135 | uncompr.o: zlib.h zconf.h | 135 | uncompr.o: zlib.h zconf.h |
136 | zutil.o: zutil.h zlib.h zconf.h | 136 | zutil.o: zutil.h zlib.h zconf.h |
diff --git a/old/zlib.html b/old/zlib.html index c343703..8c1b190 100644 --- a/old/zlib.html +++ b/old/zlib.html | |||
@@ -45,7 +45,7 @@ | |||
45 | </ol> | 45 | </ol> |
46 | 46 | ||
47 | <dl> | 47 | <dl> |
48 | <dt>Jean-loup Gailly | 48 | <dt>Jean-loup Gailly |
49 | <dd><a href="mailto:jloup@gzip.org">jloup@gzip.org</a> | 49 | <dd><a href="mailto:jloup@gzip.org">jloup@gzip.org</a> |
50 | <dt>Mark Adler | 50 | <dt>Mark Adler |
51 | <dd><a href="mailto:madler@alumni.caltech.edu">madler@alumni.caltech.edu</a> | 51 | <dd><a href="mailto:madler@alumni.caltech.edu">madler@alumni.caltech.edu</a> |
@@ -55,19 +55,19 @@ | |||
55 | Comments) 1950 to 1952 in the files | 55 | Comments) 1950 to 1952 in the files |
56 | <a href="ftp://ds.internic.net/rfc/rfc1950.txt"> | 56 | <a href="ftp://ds.internic.net/rfc/rfc1950.txt"> |
57 | ftp://ds.internic.net/rfc/rfc1950.txt </a> | 57 | ftp://ds.internic.net/rfc/rfc1950.txt </a> |
58 | (zlib format), | 58 | (zlib format), |
59 | <a href="ftp://ds.internic.net/rfc/rfc1951.txt"> | 59 | <a href="ftp://ds.internic.net/rfc/rfc1951.txt"> |
60 | rfc1951.txt </a> | 60 | rfc1951.txt </a> |
61 | (<a href="#deflate">deflate</a> format) and | 61 | (<a href="#deflate">deflate</a> format) and |
62 | <a href="ftp://ds.internic.net/rfc/rfc1952.txt"> | 62 | <a href="ftp://ds.internic.net/rfc/rfc1952.txt"> |
63 | rfc1952.txt </a> | 63 | rfc1952.txt </a> |
64 | (gzip format). | 64 | (gzip format). |
65 | <p> | 65 | <p> |
66 | This manual is converted from zlib.h by | 66 | This manual is converted from zlib.h by |
67 | <a href="mailto:piaip@csie.ntu.edu.tw"> piaip </a> | 67 | <a href="mailto:piaip@csie.ntu.edu.tw"> piaip </a> |
68 | <p> | 68 | <p> |
69 | Visit <a href="http://ftp.cdrom.com/pub/infozip/zlib/"> | 69 | Visit <a href="http://ftp.cdrom.com/pub/infozip/zlib/"> |
70 | http://ftp.cdrom.com/pub/infozip/zlib/</a> | 70 | http://ftp.cdrom.com/pub/infozip/zlib/</a> |
71 | for the official zlib web page. | 71 | for the official zlib web page. |
72 | <p> | 72 | <p> |
73 | 73 | ||
@@ -99,7 +99,7 @@ | |||
99 | <hr> | 99 | <hr> |
100 | <a name="Utility functions"><h2> Utility functions </h2> | 100 | <a name="Utility functions"><h2> Utility functions </h2> |
101 | The following utility functions are implemented on top of the | 101 | The following utility functions are implemented on top of the |
102 | <a href="#Basic functions">basic stream-oriented functions</a>. | 102 | <a href="#Basic functions">basic stream-oriented functions</a>. |
103 | To simplify the interface, some | 103 | To simplify the interface, some |
104 | default options are assumed (compression level and memory usage, | 104 | default options are assumed (compression level and memory usage, |
105 | standard memory allocation functions). The source code of these | 105 | standard memory allocation functions). The source code of these |
@@ -406,7 +406,7 @@ | |||
406 | enough room in the output buffer), <a href="#next_in">next_in</a> and <a href="#avail_in">avail_in</a> are updated and | 406 | enough room in the output buffer), <a href="#next_in">next_in</a> and <a href="#avail_in">avail_in</a> are updated and |
407 | processing will resume at this point for the next call of <a href="#deflate">deflate</a>(). | 407 | processing will resume at this point for the next call of <a href="#deflate">deflate</a>(). |
408 | 408 | ||
409 | <li> | 409 | <li> |
410 | Provide more output starting at <a href="#next_out">next_out</a> and update <a href="#next_out">next_out</a> and <a href="#avail_out">avail_out</a> | 410 | Provide more output starting at <a href="#next_out">next_out</a> and update <a href="#next_out">next_out</a> and <a href="#avail_out">avail_out</a> |
411 | accordingly. This action is forced if the parameter flush is non zero. | 411 | accordingly. This action is forced if the parameter flush is non zero. |
412 | Forcing flush frequently degrades the compression ratio, so this parameter | 412 | Forcing flush frequently degrades the compression ratio, so this parameter |
@@ -453,7 +453,7 @@ | |||
453 | <a href="#deflate">deflate</a> has returned <a href="#Z_STREAM_END">Z_STREAM_END</a>, the only possible operations on the | 453 | <a href="#deflate">deflate</a> has returned <a href="#Z_STREAM_END">Z_STREAM_END</a>, the only possible operations on the |
454 | stream are <a href="#deflateReset">deflateReset</a> or <a href="#deflateEnd">deflateEnd</a>. | 454 | stream are <a href="#deflateReset">deflateReset</a> or <a href="#deflateEnd">deflateEnd</a>. |
455 | <p> | 455 | <p> |
456 | 456 | ||
457 | <a href="#Z_FINISH">Z_FINISH</a> can be used immediately after <a href="#deflateInit">deflateInit</a> if all the compression | 457 | <a href="#Z_FINISH">Z_FINISH</a> can be used immediately after <a href="#deflateInit">deflateInit</a> if all the compression |
458 | is to be done in a single step. In this case, <a href="#avail_out">avail_out</a> must be at least | 458 | is to be done in a single step. In this case, <a href="#avail_out">avail_out</a> must be at least |
459 | 0.1% larger than <a href="#avail_in">avail_in</a> plus 12 bytes. If <a href="#deflate">deflate</a> does not return | 459 | 0.1% larger than <a href="#avail_in">avail_in</a> plus 12 bytes. If <a href="#deflate">deflate</a> does not return |
@@ -493,7 +493,7 @@ | |||
493 | <p> | 493 | <p> |
494 | 494 | ||
495 | <font color="Blue"><dt> int <a name="inflateInit">inflateInit</a> (<a href="#z_streamp">z_streamp</a> strm);</font> | 495 | <font color="Blue"><dt> int <a name="inflateInit">inflateInit</a> (<a href="#z_streamp">z_streamp</a> strm);</font> |
496 | <dd> | 496 | <dd> |
497 | Initializes the internal stream <a href="#state">state</a> for decompression. The fields | 497 | Initializes the internal stream <a href="#state">state</a> for decompression. The fields |
498 | <a href="#next_in">next_in</a>, <a href="#avail_in">avail_in</a>, <a href="#zalloc">zalloc</a>, <a href="#zfree">zfree</a> and <a href="#opaque">opaque</a> must be initialized before by | 498 | <a href="#next_in">next_in</a>, <a href="#avail_in">avail_in</a>, <a href="#zalloc">zalloc</a>, <a href="#zfree">zfree</a> and <a href="#opaque">opaque</a> must be initialized before by |
499 | the caller. If <a href="#next_in">next_in</a> is not <a href="#Z_NULL">Z_NULL</a> and <a href="#avail_in">avail_in</a> is large enough (the exact | 499 | the caller. If <a href="#next_in">next_in</a> is not <a href="#Z_NULL">Z_NULL</a> and <a href="#avail_in">avail_in</a> is large enough (the exact |
@@ -529,9 +529,9 @@ | |||
529 | enough room in the output buffer), <a href="#next_in">next_in</a> is updated and processing | 529 | enough room in the output buffer), <a href="#next_in">next_in</a> is updated and processing |
530 | will resume at this point for the next call of <a href="#inflate">inflate</a>(). | 530 | will resume at this point for the next call of <a href="#inflate">inflate</a>(). |
531 | 531 | ||
532 | <li> Provide more output starting at <a href="#next_out">next_out</a> and update <a href="#next_out">next_out</a> and | 532 | <li> Provide more output starting at <a href="#next_out">next_out</a> and update <a href="#next_out">next_out</a> and |
533 | <a href="#avail_out">avail_out</a> accordingly. <a href="#inflate">inflate</a>() provides as much output as possible, | 533 | <a href="#avail_out">avail_out</a> accordingly. <a href="#inflate">inflate</a>() provides as much output as possible, |
534 | until there is no more input data or no more space in the output buffer | 534 | until there is no more input data or no more space in the output buffer |
535 | (see below about the flush parameter). | 535 | (see below about the flush parameter). |
536 | </ul> <p> | 536 | </ul> <p> |
537 | 537 | ||
@@ -566,7 +566,7 @@ | |||
566 | 566 | ||
567 | If a preset dictionary is needed at this point (see <a href="#inflateSetDictionary">inflateSetDictionary</a> | 567 | If a preset dictionary is needed at this point (see <a href="#inflateSetDictionary">inflateSetDictionary</a> |
568 | below), <a href="#inflate">inflate</a> sets strm-<a href="#adler">adler</a> to the <a href="#adler32">adler32</a> checksum of the | 568 | below), <a href="#inflate">inflate</a> sets strm-<a href="#adler">adler</a> to the <a href="#adler32">adler32</a> checksum of the |
569 | dictionary chosen by the compressor and returns <a href="#Z_NEED_DICT">Z_NEED_DICT</a> ; otherwise | 569 | dictionary chosen by the compressor and returns <a href="#Z_NEED_DICT">Z_NEED_DICT</a> ; otherwise |
570 | it sets strm-> <a href="#adler">adler</a> to the <a href="#adler32">adler32</a> checksum of all output produced | 570 | it sets strm-> <a href="#adler">adler</a> to the <a href="#adler32">adler32</a> checksum of all output produced |
571 | so far (that is, <a href="#total_out">total_out</a> bytes) and returns <a href="#Z_OK">Z_OK</a>, <a href="#Z_STREAM_END">Z_STREAM_END</a> or | 571 | so far (that is, <a href="#total_out">total_out</a> bytes) and returns <a href="#Z_OK">Z_OK</a>, <a href="#Z_STREAM_END">Z_STREAM_END</a> or |
572 | an error code as described below. At the end of the stream, <a href="#inflate">inflate</a>() | 572 | an error code as described below. At the end of the stream, <a href="#inflate">inflate</a>() |
@@ -652,7 +652,7 @@ | |||
652 | memory, <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if a parameter is invalid (such as an invalid | 652 | memory, <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if a parameter is invalid (such as an invalid |
653 | method). <a href="#msg">msg</a> is set to null if there is no error message. <a href="#deflateInit2">deflateInit2</a> does | 653 | method). <a href="#msg">msg</a> is set to null if there is no error message. <a href="#deflateInit2">deflateInit2</a> does |
654 | not perform any compression: this will be done by <a href="#deflate">deflate</a>().<p> | 654 | not perform any compression: this will be done by <a href="#deflate">deflate</a>().<p> |
655 | 655 | ||
656 | <font color="Blue"><dt> int <a name="deflateSetDictionary">deflateSetDictionary</a> (<a href="#z_streamp">z_streamp</a> strm, const Bytef *dictionary, uInt dictLength);</font> | 656 | <font color="Blue"><dt> int <a name="deflateSetDictionary">deflateSetDictionary</a> (<a href="#z_streamp">z_streamp</a> strm, const Bytef *dictionary, uInt dictLength);</font> |
657 | <dd> | 657 | <dd> |
658 | Initializes the compression dictionary from the given byte sequence | 658 | Initializes the compression dictionary from the given byte sequence |
@@ -723,7 +723,7 @@ | |||
723 | 723 | ||
724 | Before the call of <a href="#deflateParams">deflateParams</a>, the stream <a href="#state">state</a> must be set as for | 724 | Before the call of <a href="#deflateParams">deflateParams</a>, the stream <a href="#state">state</a> must be set as for |
725 | a call of <a href="#deflate">deflate</a>(), since the currently available input may have to | 725 | a call of <a href="#deflate">deflate</a>(), since the currently available input may have to |
726 | be compressed and flushed. In particular, strm-> <a href="#avail_out">avail_out</a> must be | 726 | be compressed and flushed. In particular, strm-> <a href="#avail_out">avail_out</a> must be |
727 | non-zero.<p> | 727 | non-zero.<p> |
728 | 728 | ||
729 | <a href="#deflateParams">deflateParams</a> returns <a href="#Z_OK">Z_OK</a> if success, <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if the source | 729 | <a href="#deflateParams">deflateParams</a> returns <a href="#Z_OK">Z_OK</a> if success, <a href="#Z_STREAM_ERROR">Z_STREAM_ERROR</a> if the source |
@@ -865,7 +865,7 @@ typedef struct z_stream_s { | |||
865 | uLong <a name="reserved">reserved</a>; /* <a href="#reserved">reserved</a> for future use */ | 865 | uLong <a name="reserved">reserved</a>; /* <a href="#reserved">reserved</a> for future use */ |
866 | } <a href="#z_stream_s">z_stream</a> ; | 866 | } <a href="#z_stream_s">z_stream</a> ; |
867 | 867 | ||
868 | typedef <a href="#z_stream_s">z_stream</a> FAR * <a name="z_streamp">z_streamp</a>; ÿ | 868 | typedef <a href="#z_stream_s">z_stream</a> FAR * <a name="z_streamp">z_streamp</a>; ÿ |
869 | </pre> | 869 | </pre> |
870 | </font> | 870 | </font> |
871 | The application must update <a href="#next_in">next_in</a> and <a href="#avail_in">avail_in</a> when <a href="#avail_in">avail_in</a> has | 871 | The application must update <a href="#next_in">next_in</a> and <a href="#avail_in">avail_in</a> when <a href="#avail_in">avail_in</a> has |
@@ -904,7 +904,7 @@ typedef <a href="#z_stream_s">z_stream</a> FAR * <a name="z_streamp">z_streamp</ | |||
904 | <font color="Blue"> | 904 | <font color="Blue"> |
905 | <pre> | 905 | <pre> |
906 | #define <a name="Z_NO_FLUSH">Z_NO_FLUSH</a> 0 | 906 | #define <a name="Z_NO_FLUSH">Z_NO_FLUSH</a> 0 |
907 | #define <a name="Z_PARTIAL_FLUSH">Z_PARTIAL_FLUSH</a> 1 | 907 | #define <a name="Z_PARTIAL_FLUSH">Z_PARTIAL_FLUSH</a> 1 |
908 | /* will be removed, use <a href="#Z_SYNC_FLUSH">Z_SYNC_FLUSH</a> instead */ | 908 | /* will be removed, use <a href="#Z_SYNC_FLUSH">Z_SYNC_FLUSH</a> instead */ |
909 | #define <a name="Z_SYNC_FLUSH">Z_SYNC_FLUSH</a> 2 | 909 | #define <a name="Z_SYNC_FLUSH">Z_SYNC_FLUSH</a> 2 |
910 | #define <a name="Z_FULL_FLUSH">Z_FULL_FLUSH</a> 3 | 910 | #define <a name="Z_FULL_FLUSH">Z_FULL_FLUSH</a> 3 |
diff --git a/qnx/package.qpg b/qnx/package.qpg index 951f6fa..26c42c3 100644 --- a/qnx/package.qpg +++ b/qnx/package.qpg | |||
@@ -25,10 +25,10 @@ | |||
25 | <QPG:Files> | 25 | <QPG:Files> |
26 | <QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/> | 26 | <QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/> |
27 | <QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/> | 27 | <QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/> |
28 | <QPG:Add file="../libz.so.1.2.0.4" install="/opt/lib/" user="root:bin" permission="644"/> | 28 | <QPG:Add file="../libz.so.1.2.0.5" install="/opt/lib/" user="root:bin" permission="644"/> |
29 | <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.0.4"/> | 29 | <QPG:Add file="libz.so" install="/opt/lib/" component="dev" filetype="symlink" linkto="libz.so.1.2.0.5"/> |
30 | <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.0.4"/> | 30 | <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.0.5"/> |
31 | <QPG:Add file="../libz.so.1.2.0.4" install="/opt/lib/" component="slib"/> | 31 | <QPG:Add file="../libz.so.1.2.0.5" install="/opt/lib/" component="slib"/> |
32 | </QPG:Files> | 32 | </QPG:Files> |
33 | 33 | ||
34 | <QPG:PackageFilter> | 34 | <QPG:PackageFilter> |
@@ -63,7 +63,7 @@ | |||
63 | </QPM:ProductDescription> | 63 | </QPM:ProductDescription> |
64 | 64 | ||
65 | <QPM:ReleaseDescription> | 65 | <QPM:ReleaseDescription> |
66 | <QPM:ReleaseVersion>1.2.0.4</QPM:ReleaseVersion> | 66 | <QPM:ReleaseVersion>1.2.0.5</QPM:ReleaseVersion> |
67 | <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency> | 67 | <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency> |
68 | <QPM:ReleaseStability>Stable</QPM:ReleaseStability> | 68 | <QPM:ReleaseStability>Stable</QPM:ReleaseStability> |
69 | <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor> | 69 | <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor> |
@@ -1,6 +1,6 @@ | |||
1 | /* uncompr.c -- decompress a memory buffer | 1 | /* uncompr.c -- decompress a memory buffer |
2 | * Copyright (C) 1995-2003 Jean-loup Gailly. | 2 | * Copyright (C) 1995-2003 Jean-loup Gailly. |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* @(#) $Id$ */ | 6 | /* @(#) $Id$ */ |
diff --git a/win32/DLL_FAQ.txt b/win32/DLL_FAQ.txt new file mode 100644 index 0000000..c44bce5 --- /dev/null +++ b/win32/DLL_FAQ.txt | |||
@@ -0,0 +1,358 @@ | |||
1 | |||
2 | Frequently Asked Questions about ZLIB1.DLL | ||
3 | |||
4 | |||
5 | This document describes the design, the rationale, and the usage | ||
6 | of the official DLL build of zlib, named ZLIB1.DLL. If you have | ||
7 | general questions about zlib, you should see the file "FAQ" found | ||
8 | in the zlib distribution, or at the following location: | ||
9 | http://www.gzip.org/zlib/zlib_faq.html | ||
10 | |||
11 | |||
12 | 1. What is ZLIB1.DLL, and how can I get it? | ||
13 | |||
14 | - ZLIB1.DLL is the official build of zlib as a DLL. | ||
15 | (Please remark the symbol '1' in the name.) | ||
16 | |||
17 | Pointers to a precompiled ZLIB1.DLL can be found in the zlib | ||
18 | web site at: | ||
19 | http://www.zlib.org/ | ||
20 | |||
21 | Applications that link to ZLIB1.DLL can rely on the following | ||
22 | specification: | ||
23 | |||
24 | * The exported symbols are exclusively defined in the source | ||
25 | files "zlib.h" and "zlib.def", found in an official zlib | ||
26 | source distribution. | ||
27 | * The symbols are exported by name, not by ordinal. | ||
28 | * The exported names are undecorated. | ||
29 | * The calling convention of functions is "C" (CDECL). | ||
30 | * The ZLIB1.DLL binary is linked to MSVCRT.DLL. | ||
31 | |||
32 | The archive in which ZLIB1.DLL is bundled contains compiled | ||
33 | test programs that must run with a valid build of ZLIB1.DLL. | ||
34 | It is recommended to download the prebuilt DLL from the zlib | ||
35 | web site, instead of building it yourself, to avoid potential | ||
36 | incompatibilities that could be introduced by your compiler | ||
37 | and build settings. If you do build the DLL yourself, please | ||
38 | make sure that it complies with all the above requirements, | ||
39 | and it runs with the precompiled test programs, bundled with | ||
40 | the original ZLIB1.DLL distribution and available at the zlib | ||
41 | web site. | ||
42 | |||
43 | If, for any reason, you need to build an incompatible DLL, | ||
44 | please use a different name. | ||
45 | |||
46 | |||
47 | 2. Why did you change the name of the DLL to ZLIB1.DLL? | ||
48 | What happened to the old ZLIB.DLL? | ||
49 | |||
50 | - The old ZLIB.DLL, built from zlib-1.1.x and earlier, required | ||
51 | compilation settings that were incompatible to those used by a | ||
52 | static build. The DLL settings were supposed to be enabled by | ||
53 | defining the macro ZLIB_DLL, before including "zlib.h". | ||
54 | Incorrect handling of this macro was silently accepted at | ||
55 | build time, resulting in two major problems: | ||
56 | |||
57 | * ZLIB_DLL was missing from the old makefile. When building | ||
58 | the DLL, not all people added it to the build options. In | ||
59 | consequence, incompatible incarnations of ZLIB.DLL started | ||
60 | to circulate around the net. | ||
61 | |||
62 | * When switching from using the static library to using the | ||
63 | DLL, applications had to define the ZLIB_DLL macro and | ||
64 | to recompile all the sources that contained calls to zlib | ||
65 | functions. Failure to do so resulted in creating binaries | ||
66 | that were unable to run with the official ZLIB.DLL build. | ||
67 | |||
68 | The only possible solution that we could foresee was to make a | ||
69 | binary-incompatible change in the DLL interfacing, in order to | ||
70 | remove the dependency on the ZLIB_DLL macro, and to release | ||
71 | the new DLL under a different name. | ||
72 | |||
73 | We chose the name ZLIB1.DLL, where '1' indicates the major | ||
74 | zlib version number. We hope that we will not have to break | ||
75 | the binary compatibility again, at least not as long as the | ||
76 | zlib-1.x series will last. | ||
77 | |||
78 | There is still a ZLIB_DLL macro, that can trigger a more | ||
79 | efficient build and use of the DLL, but compatibility no | ||
80 | longer dependents on it. | ||
81 | |||
82 | |||
83 | 3. Can I build ZLIB.DLL from the new zlib sources, and replace | ||
84 | an old ZLIB.DLL, that was built from zlib-1.1.4 or earlier? | ||
85 | |||
86 | - In principle, you can do it by assigning calling convention | ||
87 | keywords to the macros ZEXPORT and ZEXPORTVA. In practice, | ||
88 | it depends on what you mean by "an old ZLIB.DLL", because | ||
89 | the old DLL exists in several mutually-incompatible versions. | ||
90 | |||
91 | If you have a compiled application that works with a certain | ||
92 | ZLIB.DLL without any known security issues, there is hardly | ||
93 | a need to rebuild the DLL from new sources only to link it to | ||
94 | the old app binary. But if you really want to do it, you have | ||
95 | to find out first what kind of calling convention uses your | ||
96 | particular ZLIB.DLL build, and to use the same one in the new | ||
97 | build. If you don't know what this is all about, you might be | ||
98 | better off if you would just forget it. | ||
99 | |||
100 | |||
101 | 4. Can I compile my application using the new zlib interface, and | ||
102 | link it to an old ZLIB.DLL, that was built from zlib-1.1.4 or | ||
103 | earlier? | ||
104 | |||
105 | - The official answer is "no"; the real answer depends again on | ||
106 | what kind of ZLIB.DLL you have. Even if you are lucky, this | ||
107 | course of action is unreliable. | ||
108 | |||
109 | If you rebuild your application and you intend to use a newer | ||
110 | version of zlib (post- 1.1.4), it is strongly recommended to | ||
111 | link it to the new ZLIB1.DLL. | ||
112 | |||
113 | |||
114 | 5. Why are the zlib symbols exported by name, and not by ordinal? | ||
115 | |||
116 | - Although exporting symbols by ordinal is a little faster, it | ||
117 | is risky. Any single glitch in the maintenance or use of the | ||
118 | DEF file that contains the ordinals can result in incompatible | ||
119 | builds and frustrating crashes. Simply put, the benefits of | ||
120 | exporting symbols by ordinal do not justify the risks. | ||
121 | |||
122 | Technically, it should be possible to maintain ordinals in | ||
123 | the DEF file, and still export the symbols by name. Ordinals | ||
124 | exist in every DLL, and even if the dynamic linking performed | ||
125 | at the DLL startup is searching for names, ordinals serve as | ||
126 | hints, for a faster name lookup. However, if the DEF file | ||
127 | contains ordinals, the Microsoft linker automatically builds | ||
128 | an implib that will cause the executables linked to it to use | ||
129 | those ordinals, and not the names. It is interesting to | ||
130 | notice that the GNU linker for Win32 does not suffer from this | ||
131 | problem. | ||
132 | |||
133 | It is possible to avoid the DEF file if the exported symbols | ||
134 | are accompanied by a "__declspec(dllexport)" attribute in the | ||
135 | source files. You can do this in zlib by predefining the | ||
136 | ZLIB_DLL macro. | ||
137 | |||
138 | |||
139 | 6. I see that the ZLIB1.DLL functions use the "C" (CDECL) calling | ||
140 | convention. Why not use the STDCALL convention? | ||
141 | STDCALL is the standard convention in Win32, and I need it in | ||
142 | my Visual Basic project! | ||
143 | |||
144 | (For readability, we use CDECL to refer to the convention | ||
145 | triggered by the "__cdecl" keyword, STDCALL to refer to | ||
146 | the convention triggered by "__stdcall", and FASTCALL to | ||
147 | refer to the convention triggered by "__fastcall".) | ||
148 | |||
149 | - Most of the native Windows API functions (without varargs) use | ||
150 | indeed the WINAPI convention (which translates to STDCALL in | ||
151 | Win32), but the standard C functions use CDECL. If a user | ||
152 | application is intrinsically tied to the Windows API (e.g. | ||
153 | it calls native Windows API functions such as CreateFile()), | ||
154 | sometimes it makes sense to decorate its own functions with | ||
155 | WINAPI. But if ANSI C or POSIX portability is a goal (e.g. | ||
156 | it calls standard C functions such as fopen()), it is not a | ||
157 | sound decision to request the inclusion of <windows.h>, or to | ||
158 | use non-ANSI constructs, for the sole purpose to make the user | ||
159 | functions STDCALL-able. | ||
160 | |||
161 | The functionality offered by zlib is not in the category of | ||
162 | "Windows functionality", but is more like "C functionality". | ||
163 | |||
164 | Technically, STDCALL is not bad; in fact, it is slightly | ||
165 | faster than CDECL, and it works with variable-argument | ||
166 | functions, just like CDECL. It is unfortunate that, in spite | ||
167 | of using STDCALL in the Windows API, it is not the default | ||
168 | convention used by the C compilers that run under Windows. | ||
169 | The roots of the problem reside deep inside the unsafety of | ||
170 | the K&R-style function prototypes, where the argument types | ||
171 | are not specified; but that is another story for another day. | ||
172 | |||
173 | The fact that remains is that CDECL is the default convention. | ||
174 | Even if an explicit convention (such as STDCALL or FASTCALL) | ||
175 | is hard-coded into the function prototypes inside C headers, | ||
176 | problems may appear. One problem, for example, deals with the | ||
177 | necessity to expose the convention in users' callbacks. | ||
178 | |||
179 | The calling convention issues are also important when using | ||
180 | zlib in other programming languages. Some of them, like Ada | ||
181 | (GNAT) and Fortran (GNU G77), have C bindings implemented | ||
182 | initially on Unix, and relying on the C calling convention. | ||
183 | On the other hand, the pre- .NET versions of Microsoft Visual | ||
184 | Basic require STDCALL, while Borland Delphi prefers (although | ||
185 | it does not require) FASTCALL. | ||
186 | |||
187 | In fairness to all possible uses of zlib outside the C | ||
188 | programming language, we choose the default "C" convention. | ||
189 | Anyone interested in different bindings or conventions is | ||
190 | encouraged to maintain specialized projects. The "contrib/" | ||
191 | directory from the zlib distribution already holds a couple | ||
192 | of foreign bindings, such as Ada, C++, and Delphi. | ||
193 | |||
194 | |||
195 | 7. I need a DLL for my Visual Basic project. What can I do? | ||
196 | |||
197 | - Define the ZLIB_WINAPI macro before including "zlib.h", when | ||
198 | building both the DLL and the user application (except that | ||
199 | you don't need to define anything when using the DLL in Visual | ||
200 | Basic). The ZLIB_WINAPI macro will switch on the WINAPI | ||
201 | (STDCALL) convention. The name of this DLL must be different | ||
202 | than the official ZLIB1.DLL. | ||
203 | |||
204 | Gilles Vollant has contributed a build named ZLIBWAPI.DLL, | ||
205 | with the ZLIB_WINAPI macro turned on, and with the minizip | ||
206 | functionality built in. For more information, please read | ||
207 | the notes inside "contrib/vstudio/readme.txt", found in the | ||
208 | zlib distribution. | ||
209 | |||
210 | |||
211 | 8. If my application uses ZLIB1.DLL, should I link it to | ||
212 | MSVCRT.DLL? Why? | ||
213 | |||
214 | - It is not required, but it is recommended to link your | ||
215 | application to MSVCRT.DLL, if it uses ZLIB1.DLL. | ||
216 | |||
217 | The executables (.EXE, .DLL, etc.) that are involved in the | ||
218 | same process and are using the C run-time library (i.e. they | ||
219 | are calling standard C functions), must link to the same | ||
220 | library. There are several libraries in the Win32 system: | ||
221 | CRTDLL.DLL, MSVCRT.DLL, the static C libraries, etc. | ||
222 | Since ZLIB1.DLL is linked to MSVCRT.DLL, the executables that | ||
223 | depend on it should also be linked to MSVCRT.DLL. | ||
224 | |||
225 | |||
226 | 9. Why are you saying that ZLIB1.DLL and my application must be | ||
227 | linked to the same C run-time (CRT) library? I linked my | ||
228 | application and my DLLs to different C libraries (e.g. my | ||
229 | application to a static library, and my DLLs to MSVCRT.DLL), | ||
230 | and everything works fine. | ||
231 | |||
232 | - If a user library invokes only pure Win32 API (accessible via | ||
233 | <windows.h> and the related headers), its DLL build will work | ||
234 | in any context. But if this library invokes standard C API, | ||
235 | things get more complicated. | ||
236 | |||
237 | There is a single Win32 library in a Win32 system. Every | ||
238 | function in this library resides in a single DLL module, that | ||
239 | is safe to call from anywhere. On the other hand, there are | ||
240 | multiple versions of the C library, and each of them has its | ||
241 | own separate internal state. Standalone executables and user | ||
242 | DLLs that call standard C functions must link to a C run-time | ||
243 | (CRT) library, be it static or shared (DLL). Intermixing | ||
244 | occurs when an executable (not necessarily standalone) and a | ||
245 | DLL are linked to different CRTs, and both are running in the | ||
246 | same process. | ||
247 | |||
248 | Intermixing multiple CRTs is possible, as long as their | ||
249 | internal states are kept intact. The Microsoft Knowledge Base | ||
250 | articles KB94248 "HOWTO: Use the C Run-Time" and KB140584 | ||
251 | "HOWTO: Link with the Correct C Run-Time (CRT) Library" | ||
252 | mention the potential problems raised by intermixing. | ||
253 | |||
254 | If intermixing works for you, it's because your application | ||
255 | and DLLs are avoiding the corruption of each of the CRTs' | ||
256 | internal states, maybe by careful design, or maybe by fortune. | ||
257 | |||
258 | Also note that linking ZLIB1.DLL to non-Microsoft CRTs (such | ||
259 | as those provided by Borland) raises similar problems. | ||
260 | |||
261 | |||
262 | 10. Why are you linking ZLIB1.DLL to MSVCRT.DLL? | ||
263 | |||
264 | - MSVCRT.DLL exists on every Windows 95 with a new service pack | ||
265 | installed, or with Microsoft Internet Explorer 4 or later, and | ||
266 | on all other Windows 4.x or later (Windows 98, Windows NT 4, | ||
267 | or later). It is freely distributable; if not present in the | ||
268 | system, it can be downloaded from Microsoft or from other | ||
269 | software provider for free. | ||
270 | |||
271 | The fact that MSVCRT.DLL does not exist on a virgin Windows 95 | ||
272 | is not so problematic. The number of Windows 95 installations | ||
273 | is rapidly decreasing, Microsoft stopped supporting it a long | ||
274 | time ago, and many recent applications from various vendors, | ||
275 | including Microsoft, do not even run on it. Furthermore, no | ||
276 | serious user should run Windows 95 without a proper update | ||
277 | installed. | ||
278 | |||
279 | There is also the fact that the mainstream C compilers for | ||
280 | Windows are Microsoft Visual C++ 6.0, and gcc/MinGW. Both | ||
281 | are producing executables that link to MSVCRT.DLL by default, | ||
282 | without offering other dynamic CRTs as alternatives easy to | ||
283 | select by users. | ||
284 | |||
285 | |||
286 | 11. Why are you not linking ZLIB1.DLL to | ||
287 | <<my favorite C run-time library>> ? | ||
288 | |||
289 | - We considered and abandoned the following alternatives: | ||
290 | |||
291 | * Linking ZLIB1.DLL to a static C library (LIBC.LIB, or | ||
292 | LIBCMT.LIB) is not a good option. People are using the DLL | ||
293 | mainly to save disk space. If you are linking your program | ||
294 | to a static C library, you may as well consider linking zlib | ||
295 | in statically, too. | ||
296 | |||
297 | * Linking ZLIB1.DLL to CRTDLL.DLL looks very appealing, | ||
298 | because CRTDLL.DLL is present on every Win32 installation. | ||
299 | Unfortunately, it has a series of problems: it raises | ||
300 | difficulties when using it with C++ code, it does not work | ||
301 | with 64-bit file offsets, (and so on...), and Microsoft | ||
302 | discontinued its support a long time ago. | ||
303 | |||
304 | * Linking ZLIB1.DLL to MSVCR70.DLL, supplied with the | ||
305 | Microsoft .NET platform and Visual C++ 7.0 or newer, is not | ||
306 | a good option. Although it is available for free download | ||
307 | and distribution, its presence is scarce on today's Win32 | ||
308 | installations. If it will ever become more popular than | ||
309 | MSVCRT.DLL and will be pre-installed on the future Win32 | ||
310 | systems, we will probably think again about it. | ||
311 | |||
312 | * Linking ZLIB1.DLL to NTDLL.DLL is not possible. | ||
313 | NTDLL.DLL exports only a part of the C library, and only on | ||
314 | Windows NT systems. | ||
315 | |||
316 | |||
317 | 12. I need to link my own DLL build to a CRT different than | ||
318 | MSVCRT.DLL. What can I do? | ||
319 | |||
320 | - Feel free to rebuild the DLL from the zlib sources, and link | ||
321 | it the way you want. You should, however, clearly state that | ||
322 | your build is unofficial. You should give it a different file | ||
323 | name, and/or install it in a private directory that can be | ||
324 | accessed by your application only, and is not visible to the | ||
325 | others (e.g. it's not in the SYSTEM or the SYSTEM32 directory, | ||
326 | and it's not in the PATH). Otherwise, your build may clash | ||
327 | with applications that link to the official build. | ||
328 | |||
329 | For example, in Cygwin, zlib is linked to the Cygwin runtime | ||
330 | CYGWIN1.DLL, and it is distributed under the name CYGZ.DLL. | ||
331 | |||
332 | |||
333 | 13. May I include additional pieces of code that I find useful, | ||
334 | link them in ZLIB1.DLL, and export them? | ||
335 | |||
336 | - No. A legitimate build of ZLIB1.DLL must not include code | ||
337 | that does not originate from the official zlib sources. But | ||
338 | you can make your own private build, and give it a different | ||
339 | name, as suggested in the previous answer. | ||
340 | |||
341 | For example, in Borland Delphi and C++ Builder, zlib is a part | ||
342 | of the standard VCL library. If an application links to VCL | ||
343 | dynamically, the name of the distributable binary (VCLxx.DLL) | ||
344 | does not posess any danger of clashing with a legitimate but | ||
345 | incompatible ZLIB1.DLL. | ||
346 | |||
347 | |||
348 | 14. I made my own ZLIB1.DLL build. Can I test it for compliance? | ||
349 | |||
350 | - We prefer that you download the official DLL from the zlib | ||
351 | web site. If you need something peculiar from this DLL, you | ||
352 | can send your suggestion to the zlib mailing list. | ||
353 | |||
354 | However, in case you do rebuild the DLL yourself, you can run | ||
355 | it with the test programs found in the DLL distribution. | ||
356 | Running these test programs is not a guarantee of compliance, | ||
357 | but a failure can imply a detected problem. | ||
358 | |||
diff --git a/win32/Makefile-dll.msc b/win32/Makefile-dll.msc deleted file mode 100644 index 516f4cf..0000000 --- a/win32/Makefile-dll.msc +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | # Makefile for zlib.dll -- Microsoft (Visual) C. | ||
2 | # Author: Cosmin Truta, 11-Mar-2003. | ||
3 | # | ||
4 | # Usage: nmake -f win32/Makefile-dll.msc | ||
5 | |||
6 | CC = cl | ||
7 | LD = cl | ||
8 | CFLAGS = -nologo -MD -O2 | ||
9 | LDFLAGS = -nologo | ||
10 | |||
11 | OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj \ | ||
12 | inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj | ||
13 | |||
14 | # targets | ||
15 | all: zlib.dll zlib.lib example.exe minigzip.exe | ||
16 | |||
17 | zlib.lib: $(OBJS) | ||
18 | lib -out:$@ $(OBJS) | ||
19 | |||
20 | zlib.dll: $(OBJS) win32/zlib.def | ||
21 | link -release -def:win32/zlib.def -dll -out:$@ $(OBJS) | ||
22 | |||
23 | zlib.lib: zlib.dll | ||
24 | |||
25 | example.exe: example.obj zlib.lib | ||
26 | $(LD) $(LDFLAGS) example.obj zlib.lib | ||
27 | |||
28 | minigzip.exe: minigzip.obj zlib.lib | ||
29 | $(LD) $(LDFLAGS) minigzip.obj zlib.lib | ||
30 | |||
31 | .c.obj: | ||
32 | $(CC) -c $(CFLAGS) $*.c | ||
33 | |||
34 | adler32.obj: adler32.c zlib.h zconf.h | ||
35 | |||
36 | compress.obj: compress.c zlib.h zconf.h | ||
37 | |||
38 | crc32.obj: crc32.c zlib.h zconf.h crc32.h | ||
39 | |||
40 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h | ||
41 | |||
42 | gzio.obj: gzio.c zutil.h zlib.h zconf.h | ||
43 | |||
44 | infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | ||
45 | inffast.h inffixed.h | ||
46 | |||
47 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | ||
48 | inffast.h | ||
49 | |||
50 | inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | ||
51 | inffast.h inffixed.h | ||
52 | |||
53 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h | ||
54 | |||
55 | trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h | ||
56 | |||
57 | uncompr.obj: uncompr.c zlib.h zconf.h | ||
58 | |||
59 | zutil.obj: zutil.c zutil.h zlib.h zconf.h | ||
60 | |||
61 | example.obj: example.c zlib.h zconf.h | ||
62 | |||
63 | minigzip.obj: minigzip.c zlib.h zconf.h | ||
64 | |||
65 | # testing | ||
66 | test: example.exe minigzip.exe | ||
67 | example | ||
68 | echo hello world | minigzip | minigzip -d | ||
69 | |||
70 | # cleanup | ||
71 | clean: | ||
72 | del *.obj | ||
73 | del *.dll | ||
74 | del *.lib | ||
75 | del *.exp | ||
76 | del *.exe | ||
diff --git a/win32/Makefile.bor b/win32/Makefile.bor index f1a1c46..b802519 100644 --- a/win32/Makefile.bor +++ b/win32/Makefile.bor | |||
@@ -1,37 +1,48 @@ | |||
1 | # Makefile for zlib | 1 | # Makefile for zlib |
2 | # Borland C++ for Win32 | 2 | # Borland C++ for Win32 |
3 | # Updated for zlib-1.2.x by Cosmin Truta, 11-Mar-2003. | 3 | # |
4 | 4 | # Updated for zlib 1.2.x by Cosmin Truta, 11-Mar-2003 | |
5 | # Usage: "make -f win32/makefile.bor" | 5 | # Last updated: 28-Aug-2003 |
6 | 6 | # | |
7 | # ------------ Borland C++ for Win32 ------------ | 7 | # Usage: |
8 | 8 | # make -f win32/Makefile.bor | |
9 | # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) | 9 | # make -f win32/Makefile.bor LOCAL_ZLIB=-DASMV OBJA=match.obj OBJPA=+match.obj |
10 | # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or added | 10 | |
11 | # to the declaration of LOC here: | 11 | # ------------ Borland C++ ------------ |
12 | |||
13 | # Optional nonstandard preprocessor flags (e.g. -DMAX_MEM_LEVEL=7) | ||
14 | # should be added to the environment via "set LOCAL_ZLIB=-DFOO" or | ||
15 | # added to the declaration of LOC here: | ||
12 | LOC = $(LOCAL_ZLIB) | 16 | LOC = $(LOCAL_ZLIB) |
13 | 17 | ||
14 | CC = bcc32 | 18 | CC = bcc32 |
19 | AS = bcc32 | ||
15 | LD = bcc32 | 20 | LD = bcc32 |
16 | AR = tlib | 21 | AR = tlib |
17 | CFLAGS = -O2 -d -k- $(LOC) | 22 | CFLAGS = -a -d -k- -O2 $(LOC) |
23 | ASFLAGS = $(LOC) | ||
18 | LDFLAGS = $(LOC) | 24 | LDFLAGS = $(LOC) |
19 | 25 | ||
20 | 26 | ||
21 | # variables | 27 | # variables |
22 | ZLIB_LIB = zlib.lib | 28 | ZLIB_LIB = zlib.lib |
23 | 29 | ||
24 | OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj | 30 | OBJ1 = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj |
25 | OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj | 31 | OBJ2 = inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj |
32 | #OBJA = | ||
26 | OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj | 33 | OBJP1 = +adler32.obj+compress.obj+crc32.obj+deflate.obj+gzio.obj+infback.obj |
27 | OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj | 34 | OBJP2 = +inffast.obj+inflate.obj+inftrees.obj+trees.obj+uncompr.obj+zutil.obj |
35 | #OBJPA= | ||
28 | 36 | ||
29 | 37 | ||
30 | # targets | 38 | # targets |
31 | all: $(ZLIB_LIB) example.exe minigzip.exe | 39 | all: $(ZLIB_LIB) example.exe minigzip.exe |
32 | 40 | ||
33 | .c.obj: | 41 | .c.obj: |
34 | $(CC) -c $(CFLAGS) $*.c | 42 | $(CC) -c $(CFLAGS) $< |
43 | |||
44 | .asm.obj: | ||
45 | $(AS) -c $(ASFLAGS) $< | ||
35 | 46 | ||
36 | adler32.obj: adler32.c zlib.h zconf.h | 47 | adler32.obj: adler32.c zlib.h zconf.h |
37 | 48 | ||
@@ -67,10 +78,17 @@ minigzip.obj: minigzip.c zlib.h zconf.h | |||
67 | 78 | ||
68 | # For the sake of the old Borland make, | 79 | # For the sake of the old Borland make, |
69 | # the command line is cut to fit in the MS-DOS 128 byte limit: | 80 | # the command line is cut to fit in the MS-DOS 128 byte limit: |
70 | $(ZLIB_LIB): $(OBJ1) $(OBJ2) | 81 | $(ZLIB_LIB): $(OBJ1) $(OBJ2) $(OBJA) |
71 | -del $(ZLIB_LIB) | 82 | -del $(ZLIB_LIB) |
72 | $(AR) $(ZLIB_LIB) $(OBJP1) | 83 | $(AR) $(ZLIB_LIB) $(OBJP1) |
73 | $(AR) $(ZLIB_LIB) $(OBJP2) | 84 | $(AR) $(ZLIB_LIB) $(OBJP2) |
85 | $(AR) $(ZLIB_LIB) $(OBJPA) | ||
86 | |||
87 | |||
88 | # testing | ||
89 | test: example.exe minigzip.exe | ||
90 | example | ||
91 | echo hello world | minigzip | minigzip -d | ||
74 | 92 | ||
75 | example.exe: example.obj $(ZLIB_LIB) | 93 | example.exe: example.obj $(ZLIB_LIB) |
76 | $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) | 94 | $(LD) $(LDFLAGS) example.obj $(ZLIB_LIB) |
@@ -78,14 +96,12 @@ example.exe: example.obj $(ZLIB_LIB) | |||
78 | minigzip.exe: minigzip.obj $(ZLIB_LIB) | 96 | minigzip.exe: minigzip.obj $(ZLIB_LIB) |
79 | $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) | 97 | $(LD) $(LDFLAGS) minigzip.obj $(ZLIB_LIB) |
80 | 98 | ||
81 | test: example.exe minigzip.exe | ||
82 | example | ||
83 | echo hello world | minigzip | minigzip -d | ||
84 | 99 | ||
100 | # cleanup | ||
85 | clean: | 101 | clean: |
86 | -del *.obj | 102 | -del *.obj |
87 | -del *.exe | ||
88 | -del *.lib | 103 | -del *.lib |
104 | -del *.exe | ||
89 | -del *.tds | 105 | -del *.tds |
90 | -del zlib.bak | 106 | -del zlib.bak |
91 | -del foo.gz | 107 | -del foo.gz |
diff --git a/old/nt/Makefile.gcc b/win32/Makefile.emx index cdd652f..7b08424 100644 --- a/old/nt/Makefile.gcc +++ b/win32/Makefile.emx | |||
@@ -1,18 +1,13 @@ | |||
1 | # Makefile for zlib. Modified for mingw32 by C. Spieler, 6/16/98. | 1 | # Makefile for zlib. Modified for emx/rsxnt by Chr. Spieler, 6/16/98. |
2 | # (This Makefile is directly derived from Makefile.dj2) | ||
3 | # Copyright (C) 1995-1998 Jean-loup Gailly. | 2 | # Copyright (C) 1995-1998 Jean-loup Gailly. |
4 | # For conditions of distribution and use, see copyright notice in zlib.h | 3 | # For conditions of distribution and use, see copyright notice in zlib.h |
5 | 4 | ||
6 | # To compile, or to compile and test, type: | 5 | # To compile, or to compile and test, type: |
7 | # | 6 | # |
8 | # make -fmakefile.gcc; make test -fmakefile.gcc | 7 | # make -fmakefile.emx; make test -fmakefile.emx |
9 | # | 8 | # |
10 | # To install libz.a, zconf.h and zlib.h in the mingw32 directories, type: | ||
11 | # | ||
12 | # make install -fmakefile.gcc | ||
13 | # | ||
14 | 9 | ||
15 | CC=gcc | 10 | CC=gcc -Zwin32 |
16 | 11 | ||
17 | #CFLAGS=-MMD -O | 12 | #CFLAGS=-MMD -O |
18 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 | 13 | #CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7 |
@@ -26,12 +21,12 @@ CP=copy /Y | |||
26 | INSTALL=$(CP) | 21 | INSTALL=$(CP) |
27 | # The default value of RM is "rm -f." If "rm.exe" is found, comment out: | 22 | # The default value of RM is "rm -f." If "rm.exe" is found, comment out: |
28 | RM=del | 23 | RM=del |
29 | LDLIBS=-L. -lz | 24 | LDLIBS=-L. -lzlib |
30 | LD=$(CC) -s -o | 25 | LD=$(CC) -s -o |
31 | LDSHARED=$(CC) | 26 | LDSHARED=$(CC) |
32 | 27 | ||
33 | INCL=zlib.h zconf.h | 28 | INCL=zlib.h zconf.h |
34 | LIBS=libz.a | 29 | LIBS=zlib.a |
35 | 30 | ||
36 | AR=ar rcs | 31 | AR=ar rcs |
37 | 32 | ||
@@ -39,7 +34,7 @@ prefix=/usr/local | |||
39 | exec_prefix = $(prefix) | 34 | exec_prefix = $(prefix) |
40 | 35 | ||
41 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ | 36 | OBJS = adler32.o compress.o crc32.o gzio.o uncompr.o deflate.o trees.o \ |
42 | zutil.o inflate.o infblock.o inftrees.o infcodes.o infutil.o inffast.o | 37 | zutil.o inflate.o infback.o inftrees.o inffast.o |
43 | 38 | ||
44 | TEST_OBJS = example.o minigzip.o | 39 | TEST_OBJS = example.o minigzip.o |
45 | 40 | ||
@@ -47,38 +42,25 @@ all: example.exe minigzip.exe | |||
47 | 42 | ||
48 | test: all | 43 | test: all |
49 | ./example | 44 | ./example |
50 | echo hello world | .\minigzip | .\minigzip -d | 45 | echo hello world | .\minigzip | .\minigzip -d |
51 | 46 | ||
52 | %.o : %.c | 47 | %.o : %.c |
53 | $(CC) $(CFLAGS) -c $< -o $@ | 48 | $(CC) $(CFLAGS) -c $< -o $@ |
54 | 49 | ||
55 | libz.a: $(OBJS) | 50 | zlib.a: $(OBJS) |
56 | $(AR) $@ $(OBJS) | 51 | $(AR) $@ $(OBJS) |
57 | 52 | ||
58 | %.exe : %.o $(LIBS) | 53 | %.exe : %.o $(LIBS) |
59 | $(LD) $@ $< $(LDLIBS) | 54 | $(LD) $@ $< $(LDLIBS) |
60 | 55 | ||
61 | # INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env . | ||
62 | 56 | ||
63 | .PHONY : uninstall clean | 57 | .PHONY : clean |
64 | |||
65 | install: $(INCL) $(LIBS) | ||
66 | -@if not exist $(INCLUDE_PATH)\nul mkdir $(INCLUDE_PATH) | ||
67 | -@if not exist $(LIBRARY_PATH)\nul mkdir $(LIBRARY_PATH) | ||
68 | $(INSTALL) zlib.h $(INCLUDE_PATH) | ||
69 | $(INSTALL) zconf.h $(INCLUDE_PATH) | ||
70 | $(INSTALL) libz.a $(LIBRARY_PATH) | ||
71 | |||
72 | uninstall: | ||
73 | $(RM) $(INCLUDE_PATH)\zlib.h | ||
74 | $(RM) $(INCLUDE_PATH)\zconf.h | ||
75 | $(RM) $(LIBRARY_PATH)\libz.a | ||
76 | 58 | ||
77 | clean: | 59 | clean: |
78 | $(RM) *.d | 60 | $(RM) *.d |
79 | $(RM) *.o | 61 | $(RM) *.o |
80 | $(RM) *.exe | 62 | $(RM) *.exe |
81 | $(RM) libz.a | 63 | $(RM) zlib.a |
82 | $(RM) foo.gz | 64 | $(RM) foo.gz |
83 | 65 | ||
84 | DEPS := $(wildcard *.d) | 66 | DEPS := $(wildcard *.d) |
diff --git a/win32/Makefile.gcc b/win32/Makefile.gcc index da32859..62a8430 100644 --- a/win32/Makefile.gcc +++ b/win32/Makefile.gcc | |||
@@ -1,26 +1,36 @@ | |||
1 | # Makefile for zlib, derived from Makefile.dj2. | 1 | # Makefile for zlib, derived from Makefile.dj2. |
2 | # Modified for mingw32 by C. Spieler, 6/16/98. | 2 | # Modified for mingw32 by C. Spieler, 6/16/98. |
3 | # Updated for zlib-1.2.x by Cosmin Truta, 11-Mar-2003. | 3 | # Updated for zlib 1.2.x by Christian Spieler and Cosmin Truta, Mar-2003. |
4 | # Last updated: 1-Aug-2003. | ||
4 | # Tested under Cygwin and MinGW. | 5 | # Tested under Cygwin and MinGW. |
5 | 6 | ||
6 | # Copyright (C) 1995-1998 Jean-loup Gailly. | 7 | # Copyright (C) 1995-2003 Jean-loup Gailly. |
7 | # For conditions of distribution and use, see copyright notice in zlib.h | 8 | # For conditions of distribution and use, see copyright notice in zlib.h |
8 | 9 | ||
9 | # To compile, or to compile and test, type: | 10 | # To compile, or to compile and test, type: |
10 | # | 11 | # |
11 | # make -fmakefile.gcc; make test -fmakefile.gcc | 12 | # make -fmakefile.gcc; make test testdll -fmakefile.gcc |
12 | # | 13 | # |
14 | # To use the asm code, type: | ||
15 | # cp contrib/asm?86/match.S ./match.S | ||
16 | # make LOC=-DASMV OBJA=match.o -fmakefile.gcc | ||
17 | # | ||
13 | # To install libz.a, zconf.h and zlib.h in the system directories, type: | 18 | # To install libz.a, zconf.h and zlib.h in the system directories, type: |
14 | # | 19 | # |
15 | # make install -fmakefile.gcc | 20 | # make install -fmakefile.gcc |
16 | # | ||
17 | 21 | ||
18 | LIB = libz.a | 22 | # Note: |
19 | SHAREDLIB = zlib.dll | 23 | # If the platform is *not* MinGW (e.g. it is Cygwin or UWIN), |
20 | VER = 1.2.0 | 24 | # the DLL name should be changed from "zlib1.dll". |
25 | |||
26 | STATICLIB = libz.a | ||
27 | SHAREDLIB = zlib1.dll | ||
28 | IMPLIB = libzdll.a | ||
29 | |||
30 | #LOC = -DASMV | ||
31 | #LOC = -DDEBUG -g | ||
21 | 32 | ||
22 | CC = gcc | 33 | CC = gcc |
23 | #CFLAGS = -DDEBUG -MMD -g | ||
24 | CFLAGS = $(LOC) -O3 -Wall | 34 | CFLAGS = $(LOC) -O3 -Wall |
25 | 35 | ||
26 | AS = $(CC) | 36 | AS = $(CC) |
@@ -33,6 +43,7 @@ AR = ar | |||
33 | ARFLAGS = rcs | 43 | ARFLAGS = rcs |
34 | 44 | ||
35 | RC = windres | 45 | RC = windres |
46 | RCFLAGS = --define GCC_WINDRES | ||
36 | 47 | ||
37 | CP = cp -fp | 48 | CP = cp -fp |
38 | # If GNU install is available, replace $(CP) with install. | 49 | # If GNU install is available, replace $(CP) with install. |
@@ -44,61 +55,75 @@ exec_prefix = $(prefix) | |||
44 | 55 | ||
45 | OBJS = adler32.o compress.o crc32.o deflate.o gzio.o infback.o \ | 56 | OBJS = adler32.o compress.o crc32.o deflate.o gzio.o infback.o \ |
46 | inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o | 57 | inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o |
47 | |||
48 | DLLDEF = win32/zlibgcc.def | ||
49 | |||
50 | # to use the asm code: make OBJA=match.o | ||
51 | OBJA = | 58 | OBJA = |
52 | 59 | ||
53 | TEST_OBJS = example.o minigzip.o | 60 | all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) example minigzip example_d minigzip_d |
54 | |||
55 | all: $(LIB) $(SHAREDLIB) example minigzip | ||
56 | 61 | ||
57 | test: all | 62 | test: example minigzip |
58 | ./example | 63 | ./example |
59 | echo hello world | ./minigzip | ./minigzip -d | 64 | echo hello world | ./minigzip | ./minigzip -d |
65 | |||
66 | testdll: example_d minigzip_d | ||
67 | ./example_d | ||
68 | echo hello world | ./minigzip_d | ./minigzip_d -d | ||
60 | 69 | ||
61 | .c.o: | 70 | .c.o: |
62 | $(CC) $(CFLAGS) -c -o $@ $< | 71 | $(CC) $(CFLAGS) -c -o $@ $< |
63 | 72 | ||
64 | libz.a: $(OBJS) | 73 | .S.o: |
65 | $(AR) $(ARFLAGS) $@ $(OBJS) | 74 | $(AS) $(ASFLAGS) -c -o $@ $< |
75 | |||
76 | $(STATICLIB): $(OBJS) $(OBJA) | ||
77 | $(AR) $(ARFLAGS) $@ $(OBJS) $(OBJA) | ||
78 | |||
79 | $(IMPLIB): $(SHAREDLIB) | ||
80 | |||
81 | $(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlibrc.o | ||
82 | dllwrap --driver-name $(CC) --def win32/zlib.def \ | ||
83 | --implib $(IMPLIB) -o $@ $(OBJS) $(OBJA) zlibrc.o | ||
84 | strip $@ | ||
85 | |||
86 | example: example.o $(STATICLIB) | ||
87 | $(LD) $(LDFLAGS) -o $@ example.o $(STATICLIB) | ||
66 | 88 | ||
67 | $(SHAREDLIB): $(OBJS) $(DLLDEF) zlibrc.o | 89 | minigzip: minigzip.o $(STATICLIB) |
68 | dllwrap --driver-name $(CC) --def $(DLLDEF) -o $@ $(OBJS) zlibrc.o | 90 | $(LD) $(LDFLAGS) -o $@ minigzip.o $(STATICLIB) |
69 | 91 | ||
70 | example: example.o $(LIB) | 92 | example_d: example.o $(IMPLIB) |
71 | $(LD) -o $@ $< $(LIB) | 93 | $(LD) $(LDFLAGS) -o $@ example.o $(IMPLIB) |
72 | 94 | ||
73 | minigzip: minigzip.o $(LIB) | 95 | minigzip_d: minigzip.o $(IMPLIB) |
74 | $(LD) -o $@ $< $(LIB) | 96 | $(LD) $(LDFLAGS) -o $@ minigzip.o $(IMPLIB) |
75 | 97 | ||
76 | zlibrc.o: win32/zlib.rc | 98 | zlibrc.o: win32/zlib1.rc |
77 | -$(RC) -o $@ --define GCC_WINDRES win32/zlib.rc | 99 | $(RC) $(RCFLAGS) -o $@ win32/zlib1.rc |
78 | 100 | ||
79 | 101 | ||
80 | # INCLUDE_PATH and LIBRARY_PATH were set for [make] in djgpp.env . | 102 | # INCLUDE_PATH and LIBRARY_PATH must be set. |
81 | 103 | ||
82 | .PHONY : uninstall clean | 104 | .PHONY: install uninstall clean |
83 | 105 | ||
84 | install: zlib.h zconf.h $(LIB) | 106 | install: zlib.h zconf.h $(LIB) |
85 | -@if not exist $(INCLUDE_PATH)/nul mkdir $(INCLUDE_PATH) | 107 | -@if not exist $(INCLUDE_PATH)/nul mkdir $(INCLUDE_PATH) |
86 | -@if not exist $(LIBRARY_PATH)/nul mkdir $(LIBRARY_PATH) | 108 | -@if not exist $(LIBRARY_PATH)/nul mkdir $(LIBRARY_PATH) |
87 | $(INSTALL) zlib.h $(INCLUDE_PATH) | 109 | -$(INSTALL) zlib.h $(INCLUDE_PATH) |
88 | $(INSTALL) zconf.h $(INCLUDE_PATH) | 110 | -$(INSTALL) zconf.h $(INCLUDE_PATH) |
89 | $(INSTALL) $(LIB) $(LIBRARY_PATH) | 111 | -$(INSTALL) $(STATICLIB) $(LIBRARY_PATH) |
112 | -$(INSTALL) $(IMPLIB) $(LIBRARY_PATH) | ||
90 | 113 | ||
91 | uninstall: | 114 | uninstall: |
92 | $(RM) $(INCLUDE_PATH)/zlib.h | 115 | -$(RM) $(INCLUDE_PATH)/zlib.h |
93 | $(RM) $(INCLUDE_PATH)/zconf.h | 116 | -$(RM) $(INCLUDE_PATH)/zconf.h |
94 | $(RM) $(LIBRARY_PATH)/libz.a | 117 | -$(RM) $(LIBRARY_PATH)/$(STATICLIB) |
118 | -$(RM) $(LIBRARY_PATH)/$(IMPLIB) | ||
95 | 119 | ||
96 | clean: | 120 | clean: |
97 | $(RM) *.o | 121 | -$(RM) $(STATICLIB) |
98 | $(RM) *.exe | 122 | -$(RM) $(SHAREDLIB) |
99 | $(RM) libz.a | 123 | -$(RM) $(IMPLIB) |
100 | $(RM) zlib.dll | 124 | -$(RM) *.o |
101 | $(RM) foo.gz | 125 | -$(RM) *.exe |
126 | -$(RM) foo.gz | ||
102 | 127 | ||
103 | adler32.o: zlib.h zconf.h | 128 | adler32.o: zlib.h zconf.h |
104 | compress.o: zlib.h zconf.h | 129 | compress.o: zlib.h zconf.h |
@@ -110,7 +135,7 @@ inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h | |||
110 | inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h | 135 | inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h |
111 | infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h | 136 | infback.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h |
112 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h | 137 | inftrees.o: zutil.h zlib.h zconf.h inftrees.h |
113 | minigzip.o: zlib.h zconf.h | 138 | minigzip.o: zlib.h zconf.h |
114 | trees.o: deflate.h zutil.h zlib.h zconf.h trees.h | 139 | trees.o: deflate.h zutil.h zlib.h zconf.h trees.h |
115 | uncompr.o: zlib.h zconf.h | 140 | uncompr.o: zlib.h zconf.h |
116 | zutil.o: zutil.h zlib.h zconf.h | 141 | zutil.o: zutil.h zlib.h zconf.h |
diff --git a/win32/Makefile.msc b/win32/Makefile.msc index 4dc8819..528ecaa 100644 --- a/win32/Makefile.msc +++ b/win32/Makefile.msc | |||
@@ -1,92 +1,126 @@ | |||
1 | # Makefile for Win32 zlib.dll and the static library zlibstat.lib | 1 | # Makefile for zlib -- Microsoft (Visual) C |
2 | # -- Microsoft (Visual) C. | 2 | # |
3 | # Author: Cosmin Truta, 11-Mar-2003 | 3 | # Authors: |
4 | # Christian Spieler, 19-Mar-2003 | 4 | # Cosmin Truta, 11-Mar-2003 |
5 | # | 5 | # Christian Spieler, 19-Mar-2003 |
6 | # Usage: nmake -f win32/Makefile.msc | 6 | # |
7 | 7 | # Last updated: | |
8 | CC = cl | 8 | # Cosmin Truta, 27-Aug-2003 |
9 | LD = cl | 9 | # |
10 | RC = rc | 10 | # Usage: |
11 | CFLAGS = -nologo -MD -O2 | 11 | # nmake -f win32/Makefile.msc (standard build) |
12 | LDFLAGS = -nologo | 12 | # nmake -f win32/Makefile.msc LOC=-DFOO (nonstandard build) |
13 | 13 | # nmake -f win32/Makefile.msc LOC=-DASMV OBJA=match.obj (use ASM code) | |
14 | OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj \ | 14 | |
15 | inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj | 15 | |
16 | 16 | # optional build flags | |
17 | # targets | 17 | LOC = |
18 | all: zlib.dll zlibstat.lib example.exe minigzip.exe exampl_s.exe minigz_s.exe | 18 | |
19 | 19 | ||
20 | zlibstat.lib: $(OBJS) | 20 | # variables |
21 | lib -out:$@ $(OBJS) | 21 | STATICLIB = zlib.lib |
22 | 22 | SHAREDLIB = zlib1.dll | |
23 | zlib.dll: $(OBJS) zlib.res win32/zlib.def | 23 | IMPLIB = zdll.lib |
24 | link -release -def:win32/zlib.def -dll -out:$@ $(OBJS) zlib.res | 24 | |
25 | 25 | CC = cl | |
26 | zlib.lib: zlib.dll | 26 | AS = ml |
27 | 27 | LD = link | |
28 | example.exe: example.obj zlib.lib | 28 | AR = lib |
29 | $(LD) $(LDFLAGS) example.obj zlib.lib | 29 | RC = rc |
30 | 30 | CFLAGS = -nologo -MD -O2 $(LOC) | |
31 | minigzip.exe: minigzip.obj zlib.lib | 31 | ASFLAGS = -coff |
32 | $(LD) $(LDFLAGS) minigzip.obj zlib.lib | 32 | LDFLAGS = -nologo -release |
33 | 33 | ARFLAGS = -nologo | |
34 | exampl_s.exe: example.obj zlibstat.lib | 34 | RCFLAGS = /dWIN32 /r |
35 | $(LD) $(LDFLAGS) -o $@ example.obj zlibstat.lib | 35 | |
36 | 36 | OBJS = adler32.obj compress.obj crc32.obj deflate.obj gzio.obj infback.obj \ | |
37 | minigz_s.exe: minigzip.obj zlibstat.lib | 37 | inffast.obj inflate.obj inftrees.obj trees.obj uncompr.obj zutil.obj |
38 | $(LD) $(LDFLAGS) -o $@ minigzip.obj zlibstat.lib | 38 | OBJA = |
39 | 39 | ||
40 | .c.obj: | 40 | |
41 | $(CC) -c $(CFLAGS) $< | 41 | # targets |
42 | 42 | all: $(STATICLIB) $(SHAREDLIB) $(IMPLIB) \ | |
43 | zlib.res: win32/zlib.rc | 43 | example.exe minigzip.exe example_d.exe minigzip_d.exe |
44 | $(RC) /l 0x409 /fo$@ /d WIN32 win32/zlib.rc | 44 | |
45 | 45 | $(STATICLIB): $(OBJS) $(OBJA) | |
46 | adler32.obj: adler32.c zlib.h zconf.h | 46 | $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(OBJA) |
47 | 47 | ||
48 | compress.obj: compress.c zlib.h zconf.h | 48 | $(IMPLIB): $(SHAREDLIB) |
49 | 49 | ||
50 | crc32.obj: crc32.c zlib.h zconf.h crc32.h | 50 | $(SHAREDLIB): win32/zlib.def $(OBJS) $(OBJA) zlib1.res |
51 | 51 | $(LD) $(LDFLAGS) -def:win32/zlib.def -dll -implib:$(IMPLIB) \ | |
52 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h | 52 | -out:$@ $(OBJS) $(OBJA) zlib1.res |
53 | 53 | ||
54 | gzio.obj: gzio.c zutil.h zlib.h zconf.h | 54 | example.exe: example.obj $(STATICLIB) |
55 | 55 | $(LD) $(LDFLAGS) example.obj $(STATICLIB) | |
56 | infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | 56 | |
57 | inffast.h inffixed.h | 57 | minigzip.exe: minigzip.obj $(STATICLIB) |
58 | 58 | $(LD) $(LDFLAGS) minigzip.obj $(STATICLIB) | |
59 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | 59 | |
60 | inffast.h | 60 | example_d.exe: example.obj $(IMPLIB) |
61 | 61 | $(LD) $(LDFLAGS) -out:$@ example.obj $(IMPLIB) | |
62 | inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | 62 | |
63 | inffast.h inffixed.h | 63 | minigzip_d.exe: minigzip.obj $(IMPLIB) |
64 | 64 | $(LD) $(LDFLAGS) -out:$@ minigzip.obj $(IMPLIB) | |
65 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h | 65 | |
66 | 66 | .c.obj: | |
67 | trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h | 67 | $(CC) -c $(CFLAGS) $< |
68 | 68 | ||
69 | uncompr.obj: uncompr.c zlib.h zconf.h | 69 | .asm.obj: |
70 | 70 | $(AS) -c $(ASFLAGS) $< | |
71 | zutil.obj: zutil.c zutil.h zlib.h zconf.h | 71 | |
72 | 72 | adler32.obj: adler32.c zlib.h zconf.h | |
73 | example.obj: example.c zlib.h zconf.h | 73 | |
74 | 74 | compress.obj: compress.c zlib.h zconf.h | |
75 | minigzip.obj: minigzip.c zlib.h zconf.h | 75 | |
76 | 76 | crc32.obj: crc32.c zlib.h zconf.h crc32.h | |
77 | # testing | 77 | |
78 | test: example.exe minigzip.exe | 78 | deflate.obj: deflate.c deflate.h zutil.h zlib.h zconf.h |
79 | example | 79 | |
80 | echo hello world | minigzip | minigzip -d | 80 | gzio.obj: gzio.c zutil.h zlib.h zconf.h |
81 | 81 | ||
82 | teststat: exampl_s.exe minigz_s.exe | 82 | infback.obj: infback.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ |
83 | exampl_s | 83 | inffast.h inffixed.h |
84 | echo hello world | minigz_s | minigz_s -d | 84 | |
85 | 85 | inffast.obj: inffast.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ | |
86 | # cleanup | 86 | inffast.h |
87 | clean: | 87 | |
88 | del *.obj | 88 | inflate.obj: inflate.c zutil.h zlib.h zconf.h inftrees.h inflate.h \ |
89 | del *.dll | 89 | inffast.h inffixed.h |
90 | del *.lib | 90 | |
91 | del *.exp | 91 | inftrees.obj: inftrees.c zutil.h zlib.h zconf.h inftrees.h |
92 | del *.exe | 92 | |
93 | trees.obj: trees.c zutil.h zlib.h zconf.h deflate.h trees.h | ||
94 | |||
95 | uncompr.obj: uncompr.c zlib.h zconf.h | ||
96 | |||
97 | zutil.obj: zutil.c zutil.h zlib.h zconf.h | ||
98 | |||
99 | example.obj: example.c zlib.h zconf.h | ||
100 | |||
101 | minigzip.obj: minigzip.c zlib.h zconf.h | ||
102 | |||
103 | zlib1.res: win32/zlib1.rc | ||
104 | $(RC) $(RCFLAGS) /fo$@ win32/zlib1.rc | ||
105 | |||
106 | |||
107 | # testing | ||
108 | test: example.exe minigzip.exe | ||
109 | example | ||
110 | echo hello world | minigzip | minigzip -d | ||
111 | |||
112 | testdll: example_d.exe minigzip_d.exe | ||
113 | example_d | ||
114 | echo hello world | minigzip_d | minigzip_d -d | ||
115 | |||
116 | |||
117 | # cleanup | ||
118 | clean: | ||
119 | -del $(STATICLIB) | ||
120 | -del $(SHAREDLIB) | ||
121 | -del $(IMPLIB) | ||
122 | -del *.obj | ||
123 | -del *.res | ||
124 | -del *.exp | ||
125 | -del *.exe | ||
126 | -del foo.gz | ||
diff --git a/win32/zlib.def b/win32/zlib.def index d299ed5..5688a1c 100644 --- a/win32/zlib.def +++ b/win32/zlib.def | |||
@@ -1,52 +1,59 @@ | |||
1 | LIBRARY zlib.dll | 1 | LIBRARY |
2 | DESCRIPTION "zlib data compression library" | 2 | ; zlib data compression library |
3 | 3 | ||
4 | EXPORTS | 4 | EXPORTS |
5 | adler32 @1 | 5 | ; basic functions |
6 | compress @2 | 6 | zlibVersion |
7 | crc32 @3 | 7 | deflate |
8 | deflate @4 | 8 | deflateEnd |
9 | deflateCopy @5 | 9 | inflate |
10 | deflateEnd @6 | 10 | inflateEnd |
11 | deflateInit2_ @7 | 11 | ; advanced functions |
12 | deflateInit_ @8 | 12 | deflateSetDictionary |
13 | deflateParams @9 | 13 | deflateCopy |
14 | deflateReset @10 | 14 | deflateReset |
15 | deflateSetDictionary @11 | 15 | deflateParams |
16 | gzclose @12 | 16 | deflateBound |
17 | gzdopen @13 | 17 | inflateSetDictionary |
18 | gzerror @14 | 18 | inflateSync |
19 | gzflush @15 | 19 | inflateCopy |
20 | gzopen @16 | 20 | inflateReset |
21 | gzread @17 | 21 | inflateBack |
22 | gzwrite @18 | 22 | inflateBackEnd |
23 | inflate @19 | 23 | zlibCompileFlags |
24 | inflateEnd @20 | 24 | ; utility functions |
25 | inflateInit2_ @21 | 25 | compress |
26 | inflateInit_ @22 | 26 | compress2 |
27 | inflateReset @23 | 27 | compressBound |
28 | inflateSetDictionary @24 | 28 | uncompress |
29 | inflateSync @25 | 29 | gzopen |
30 | uncompress @26 | 30 | gzdopen |
31 | zlibVersion @27 | 31 | gzsetparams |
32 | gzprintf @28 | 32 | gzread |
33 | gzputc @29 | 33 | gzwrite |
34 | gzgetc @30 | 34 | gzprintf |
35 | gzseek @31 | 35 | gzputs |
36 | gzrewind @32 | 36 | gzgets |
37 | gztell @33 | 37 | gzputc |
38 | gzeof @34 | 38 | gzgetc |
39 | gzsetparams @35 | 39 | gzungetc |
40 | zError @36 | 40 | gzflush |
41 | inflateSyncPoint @37 | 41 | gzseek |
42 | get_crc_table @38 | 42 | gzrewind |
43 | compress2 @39 | 43 | gztell |
44 | gzputs @40 | 44 | gzeof |
45 | gzgets @41 | 45 | gzclose |
46 | ; since zlib-1.2.0: | 46 | gzerror |
47 | inflateCopy @42 | 47 | gzclearerr |
48 | inflateBackInit_ @43 | 48 | ; checksum functions |
49 | inflateBack @44 | 49 | adler32 |
50 | inflateBackEnd @45 | 50 | crc32 |
51 | compressBound @46 | 51 | ; various hacks, don't look :) |
52 | deflateBound @47 | 52 | deflateInit_ |
53 | deflateInit2_ | ||
54 | inflateInit_ | ||
55 | inflateInit2_ | ||
56 | inflateBackInit_ | ||
57 | inflateSyncPoint | ||
58 | get_crc_table | ||
59 | zError | ||
diff --git a/win32/zlib1.rc b/win32/zlib1.rc new file mode 100644 index 0000000..138d30c --- /dev/null +++ b/win32/zlib1.rc | |||
@@ -0,0 +1,39 @@ | |||
1 | #include <windows.h> | ||
2 | |||
3 | #ifdef GCC_WINDRES | ||
4 | VS_VERSION_INFO VERSIONINFO | ||
5 | #else | ||
6 | VS_VERSION_INFO VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE | ||
7 | #endif | ||
8 | FILEVERSION 1,2,0,5 | ||
9 | PRODUCTVERSION 1,2,0,5 | ||
10 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK | ||
11 | #ifdef _DEBUG | ||
12 | FILEFLAGS 1 | ||
13 | #else | ||
14 | FILEFLAGS 0 | ||
15 | #endif | ||
16 | FILEOS VOS_DOS_WINDOWS32 | ||
17 | FILETYPE VFT_DLL | ||
18 | FILESUBTYPE 0 // not used | ||
19 | BEGIN | ||
20 | BLOCK "StringFileInfo" | ||
21 | BEGIN | ||
22 | BLOCK "040904E4" | ||
23 | //language ID = U.S. English, char set = Windows, Multilingual | ||
24 | BEGIN | ||
25 | VALUE "FileDescription", "zlib data compression library\0" | ||
26 | VALUE "FileVersion", "1.2.0.5\0" | ||
27 | VALUE "InternalName", "zlib1.dll\0" | ||
28 | VALUE "LegalCopyright", "(C) 1995-2003 Jean-loup Gailly & Mark Adler\0" | ||
29 | VALUE "OriginalFilename", "zlib1.dll\0" | ||
30 | VALUE "ProductName", "zlib\0" | ||
31 | VALUE "ProductVersion", "1.2.0.5\0" | ||
32 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" | ||
33 | END | ||
34 | END | ||
35 | BLOCK "VarFileInfo" | ||
36 | BEGIN | ||
37 | VALUE "Translation", 0x0409, 1252 | ||
38 | END | ||
39 | END | ||
@@ -51,43 +51,59 @@ | |||
51 | # define voidp z_voidp | 51 | # define voidp z_voidp |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #if defined(__MSDOS__) && !defined(MSDOS) | ||
55 | # define MSDOS | ||
56 | #endif | ||
57 | #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) | ||
58 | # define OS2 | ||
59 | #endif | ||
60 | #if defined(_WINDOWS) && !defined(WINDOWS) | ||
61 | # define WINDOWS | ||
62 | #endif | ||
54 | #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) | 63 | #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) |
55 | # define WIN32 | 64 | # define WIN32 |
56 | #endif | 65 | #endif |
57 | #if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) | 66 | #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) |
58 | # ifndef __32BIT__ | 67 | # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) |
59 | # define __32BIT__ | 68 | # ifndef SYS16BIT |
69 | # define SYS16BIT | ||
70 | # endif | ||
60 | # endif | 71 | # endif |
61 | #endif | 72 | #endif |
62 | #if defined(__MSDOS__) && !defined(MSDOS) | ||
63 | # define MSDOS | ||
64 | #endif | ||
65 | 73 | ||
66 | /* | 74 | /* |
67 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more | 75 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more |
68 | * than 64k bytes at a time (needed on systems with 16-bit int). | 76 | * than 64k bytes at a time (needed on systems with 16-bit int). |
69 | */ | 77 | */ |
70 | #if defined(MSDOS) && !defined(__32BIT__) | 78 | #ifdef SYS16BIT |
71 | # define MAXSEG_64K | 79 | # define MAXSEG_64K |
72 | #endif | 80 | #endif |
73 | #ifdef MSDOS | 81 | #ifdef MSDOS |
74 | # define UNALIGNED_OK | 82 | # define UNALIGNED_OK |
75 | #endif | 83 | #endif |
76 | 84 | ||
77 | #if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) | 85 | #ifdef __STDC_VERSION__ |
78 | # define STDC | ||
79 | #endif | ||
80 | #if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) | ||
81 | # ifndef STDC | 86 | # ifndef STDC |
82 | # define STDC | 87 | # define STDC |
83 | # endif | 88 | # endif |
84 | #endif | 89 | # if __STDC_VERSION__ >= 199901L |
85 | 90 | # ifndef STDC99 | |
86 | #if defined __HOS_AIX__ | 91 | # define STDC99 |
87 | # ifndef STDC | 92 | # endif |
88 | # define STDC | ||
89 | # endif | 93 | # endif |
90 | #endif | 94 | #endif |
95 | #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) | ||
96 | # define STDC | ||
97 | #endif | ||
98 | #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) | ||
99 | # define STDC | ||
100 | #endif | ||
101 | #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) | ||
102 | # define STDC | ||
103 | #endif | ||
104 | #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) | ||
105 | # define STDC | ||
106 | #endif | ||
91 | 107 | ||
92 | #ifndef STDC | 108 | #ifndef STDC |
93 | # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ | 109 | # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ |
@@ -96,7 +112,7 @@ | |||
96 | #endif | 112 | #endif |
97 | 113 | ||
98 | /* Some Mac compilers merge all .h files incorrectly: */ | 114 | /* Some Mac compilers merge all .h files incorrectly: */ |
99 | #if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) | 115 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) |
100 | # define NO_DUMMY_DECL | 116 | # define NO_DUMMY_DECL |
101 | #endif | 117 | #endif |
102 | 118 | ||
@@ -147,58 +163,56 @@ | |||
147 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, | 163 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, |
148 | * just define FAR to be empty. | 164 | * just define FAR to be empty. |
149 | */ | 165 | */ |
150 | #if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) | 166 | #ifdef SYS16BIT |
151 | /* MSC small or medium model */ | 167 | # if defined(M_I86SM) || defined(M_I86MM) |
152 | # define SMALL_MEDIUM | 168 | /* MSC small or medium model */ |
153 | # ifdef _MSC_VER | 169 | # define SMALL_MEDIUM |
154 | # define FAR _far | 170 | # ifdef _MSC_VER |
155 | # else | 171 | # define FAR _far |
156 | # define FAR far | 172 | # else |
173 | # define FAR far | ||
174 | # endif | ||
157 | # endif | 175 | # endif |
158 | #endif | 176 | # if (defined(__SMALL__) || defined(__MEDIUM__)) |
159 | #if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) | 177 | /* Turbo C small or medium model */ |
160 | # ifndef __32BIT__ | ||
161 | # define SMALL_MEDIUM | 178 | # define SMALL_MEDIUM |
162 | # define FAR _far | 179 | # ifdef __BORLANDC__ |
180 | # define FAR _far | ||
181 | # else | ||
182 | # define FAR far | ||
183 | # endif | ||
163 | # endif | 184 | # endif |
164 | #endif | 185 | #endif |
165 | 186 | ||
166 | /* If building or using a Windows DLL, compile with -DZLIB_DLL. | 187 | #if defined(WINDOWS) || defined(WIN32) |
167 | * The calls to ZEXTERN functions will be more efficient this way. | 188 | /* If building or using zlib as a DLL, define ZLIB_DLL. |
168 | */ | 189 | * This is not mandatory, but it offers a little performance increase. |
169 | #if defined(_WINDOWS) || defined(WINDOWS) || defined(WIN32) | ||
170 | # ifdef FAR | ||
171 | # undef FAR | ||
172 | # endif | ||
173 | /* For zlib, the basic Win32 API declarations are sufficient. Whenever | ||
174 | * a program that uses zlib requires the full Win32 API set, it has | ||
175 | * to include <windows.h> prior to "zlib.h". | ||
176 | */ | 190 | */ |
177 | # if defined(WIN32) && (!defined(WIN32_LEAN_AND_MEAN)) | 191 | # ifdef ZLIB_DLL |
178 | # define WIN32_LEAN_AND_MEAN | 192 | # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) |
179 | # endif | ||
180 | # include <windows.h> | ||
181 | # if !defined(WIN32) || (defined(__BORLANDC__) && (__BORLANDC__ < 0x500)) | ||
182 | # if defined(ZLIB_DLL) && defined(ZLIB_INTERNAL) | ||
183 | # define ZEXPORT WINAPI _export | ||
184 | # define ZEXPORTVA FAR _cdecl _export | ||
185 | # else | ||
186 | # define ZEXPORT FAR _cdecl | ||
187 | # define ZEXPORTVA FAR _cdecl | ||
188 | # endif | ||
189 | # else | ||
190 | /* a fully Win32-compliant compiler */ | ||
191 | # define ZEXPORTVA CDECL | ||
192 | # ifdef ZLIB_DLL | ||
193 | # define ZEXPORT WINAPI | ||
194 | # ifdef ZLIB_INTERNAL | 193 | # ifdef ZLIB_INTERNAL |
195 | # define ZEXTERN extern __declspec(dllexport) | 194 | # define ZEXTERN extern __declspec(dllexport) |
196 | # else | 195 | # else |
197 | # define ZEXTERN extern __declspec(dllimport) | 196 | # define ZEXTERN extern __declspec(dllimport) |
198 | # endif | 197 | # endif |
198 | # endif | ||
199 | # endif /* ZLIB_DLL */ | ||
200 | /* If building or using zlib with the WINAPI/WINAPIV calling convention, | ||
201 | * define ZLIB_WINAPI. | ||
202 | * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. | ||
203 | */ | ||
204 | # ifdef ZLIB_WINAPI | ||
205 | # ifdef FAR | ||
206 | # undef FAR | ||
207 | # endif | ||
208 | # include <windows.h> | ||
209 | /* No need for _export, use ZLIB.DEF instead. */ | ||
210 | /* For complete Windows compatibility, use WINAPI, not __stdcall. */ | ||
211 | # define ZEXPORT WINAPI | ||
212 | # ifdef WIN32 | ||
213 | # define ZEXPORTVA WINAPIV | ||
199 | # else | 214 | # else |
200 | # define ZEXPORT CDECL | 215 | # define ZEXPORTVA FAR CDECL |
201 | # define ZEXTERN extern | ||
202 | # endif | 216 | # endif |
203 | # endif | 217 | # endif |
204 | #endif | 218 | #endif |
@@ -215,15 +229,15 @@ | |||
215 | # endif | 229 | # endif |
216 | #endif | 230 | #endif |
217 | 231 | ||
232 | #ifndef ZEXTERN | ||
233 | # define ZEXTERN extern | ||
234 | #endif | ||
218 | #ifndef ZEXPORT | 235 | #ifndef ZEXPORT |
219 | # define ZEXPORT | 236 | # define ZEXPORT |
220 | #endif | 237 | #endif |
221 | #ifndef ZEXPORTVA | 238 | #ifndef ZEXPORTVA |
222 | # define ZEXPORTVA | 239 | # define ZEXPORTVA |
223 | #endif | 240 | #endif |
224 | #ifndef ZEXTERN | ||
225 | # define ZEXTERN extern | ||
226 | #endif | ||
227 | 241 | ||
228 | #ifndef FAR | 242 | #ifndef FAR |
229 | # define FAR | 243 | # define FAR |
@@ -248,12 +262,12 @@ typedef uLong FAR uLongf; | |||
248 | 262 | ||
249 | #ifdef STDC | 263 | #ifdef STDC |
250 | typedef void const *voidpc; | 264 | typedef void const *voidpc; |
251 | typedef void FAR *voidpf; | 265 | typedef void FAR *voidpf; |
252 | typedef void *voidp; | 266 | typedef void *voidp; |
253 | #else | 267 | #else |
254 | typedef Byte const *voidpc; | 268 | typedef Byte const *voidpc; |
255 | typedef Byte FAR *voidpf; | 269 | typedef Byte FAR *voidpf; |
256 | typedef Byte *voidp; | 270 | typedef Byte *voidp; |
257 | #endif | 271 | #endif |
258 | 272 | ||
259 | #if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ | 273 | #if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ |
@@ -51,43 +51,59 @@ | |||
51 | # define voidp z_voidp | 51 | # define voidp z_voidp |
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | #if defined(__MSDOS__) && !defined(MSDOS) | ||
55 | # define MSDOS | ||
56 | #endif | ||
57 | #if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) | ||
58 | # define OS2 | ||
59 | #endif | ||
60 | #if defined(_WINDOWS) && !defined(WINDOWS) | ||
61 | # define WINDOWS | ||
62 | #endif | ||
54 | #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) | 63 | #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) |
55 | # define WIN32 | 64 | # define WIN32 |
56 | #endif | 65 | #endif |
57 | #if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) | 66 | #if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) |
58 | # ifndef __32BIT__ | 67 | # if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) |
59 | # define __32BIT__ | 68 | # ifndef SYS16BIT |
69 | # define SYS16BIT | ||
70 | # endif | ||
60 | # endif | 71 | # endif |
61 | #endif | 72 | #endif |
62 | #if defined(__MSDOS__) && !defined(MSDOS) | ||
63 | # define MSDOS | ||
64 | #endif | ||
65 | 73 | ||
66 | /* | 74 | /* |
67 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more | 75 | * Compile with -DMAXSEG_64K if the alloc function cannot allocate more |
68 | * than 64k bytes at a time (needed on systems with 16-bit int). | 76 | * than 64k bytes at a time (needed on systems with 16-bit int). |
69 | */ | 77 | */ |
70 | #if defined(MSDOS) && !defined(__32BIT__) | 78 | #ifdef SYS16BIT |
71 | # define MAXSEG_64K | 79 | # define MAXSEG_64K |
72 | #endif | 80 | #endif |
73 | #ifdef MSDOS | 81 | #ifdef MSDOS |
74 | # define UNALIGNED_OK | 82 | # define UNALIGNED_OK |
75 | #endif | 83 | #endif |
76 | 84 | ||
77 | #if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) | 85 | #ifdef __STDC_VERSION__ |
78 | # define STDC | ||
79 | #endif | ||
80 | #if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) | ||
81 | # ifndef STDC | 86 | # ifndef STDC |
82 | # define STDC | 87 | # define STDC |
83 | # endif | 88 | # endif |
84 | #endif | 89 | # if __STDC_VERSION__ >= 199901L |
85 | 90 | # ifndef STDC99 | |
86 | #if defined __HOS_AIX__ | 91 | # define STDC99 |
87 | # ifndef STDC | 92 | # endif |
88 | # define STDC | ||
89 | # endif | 93 | # endif |
90 | #endif | 94 | #endif |
95 | #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) | ||
96 | # define STDC | ||
97 | #endif | ||
98 | #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) | ||
99 | # define STDC | ||
100 | #endif | ||
101 | #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) | ||
102 | # define STDC | ||
103 | #endif | ||
104 | #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) | ||
105 | # define STDC | ||
106 | #endif | ||
91 | 107 | ||
92 | #ifndef STDC | 108 | #ifndef STDC |
93 | # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ | 109 | # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ |
@@ -96,7 +112,7 @@ | |||
96 | #endif | 112 | #endif |
97 | 113 | ||
98 | /* Some Mac compilers merge all .h files incorrectly: */ | 114 | /* Some Mac compilers merge all .h files incorrectly: */ |
99 | #if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) | 115 | #if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) |
100 | # define NO_DUMMY_DECL | 116 | # define NO_DUMMY_DECL |
101 | #endif | 117 | #endif |
102 | 118 | ||
@@ -147,58 +163,56 @@ | |||
147 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, | 163 | * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, |
148 | * just define FAR to be empty. | 164 | * just define FAR to be empty. |
149 | */ | 165 | */ |
150 | #if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) | 166 | #ifdef SYS16BIT |
151 | /* MSC small or medium model */ | 167 | # if defined(M_I86SM) || defined(M_I86MM) |
152 | # define SMALL_MEDIUM | 168 | /* MSC small or medium model */ |
153 | # ifdef _MSC_VER | 169 | # define SMALL_MEDIUM |
154 | # define FAR _far | 170 | # ifdef _MSC_VER |
155 | # else | 171 | # define FAR _far |
156 | # define FAR far | 172 | # else |
173 | # define FAR far | ||
174 | # endif | ||
157 | # endif | 175 | # endif |
158 | #endif | 176 | # if (defined(__SMALL__) || defined(__MEDIUM__)) |
159 | #if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) | 177 | /* Turbo C small or medium model */ |
160 | # ifndef __32BIT__ | ||
161 | # define SMALL_MEDIUM | 178 | # define SMALL_MEDIUM |
162 | # define FAR _far | 179 | # ifdef __BORLANDC__ |
180 | # define FAR _far | ||
181 | # else | ||
182 | # define FAR far | ||
183 | # endif | ||
163 | # endif | 184 | # endif |
164 | #endif | 185 | #endif |
165 | 186 | ||
166 | /* If building or using a Windows DLL, compile with -DZLIB_DLL. | 187 | #if defined(WINDOWS) || defined(WIN32) |
167 | * The calls to ZEXTERN functions will be more efficient this way. | 188 | /* If building or using zlib as a DLL, define ZLIB_DLL. |
168 | */ | 189 | * This is not mandatory, but it offers a little performance increase. |
169 | #if defined(_WINDOWS) || defined(WINDOWS) || defined(WIN32) | ||
170 | # ifdef FAR | ||
171 | # undef FAR | ||
172 | # endif | ||
173 | /* For zlib, the basic Win32 API declarations are sufficient. Whenever | ||
174 | * a program that uses zlib requires the full Win32 API set, it has | ||
175 | * to include <windows.h> prior to "zlib.h". | ||
176 | */ | 190 | */ |
177 | # if defined(WIN32) && (!defined(WIN32_LEAN_AND_MEAN)) | 191 | # ifdef ZLIB_DLL |
178 | # define WIN32_LEAN_AND_MEAN | 192 | # if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) |
179 | # endif | ||
180 | # include <windows.h> | ||
181 | # if !defined(WIN32) || (defined(__BORLANDC__) && (__BORLANDC__ < 0x500)) | ||
182 | # if defined(ZLIB_DLL) && defined(ZLIB_INTERNAL) | ||
183 | # define ZEXPORT WINAPI _export | ||
184 | # define ZEXPORTVA FAR _cdecl _export | ||
185 | # else | ||
186 | # define ZEXPORT FAR _cdecl | ||
187 | # define ZEXPORTVA FAR _cdecl | ||
188 | # endif | ||
189 | # else | ||
190 | /* a fully Win32-compliant compiler */ | ||
191 | # define ZEXPORTVA CDECL | ||
192 | # ifdef ZLIB_DLL | ||
193 | # define ZEXPORT WINAPI | ||
194 | # ifdef ZLIB_INTERNAL | 193 | # ifdef ZLIB_INTERNAL |
195 | # define ZEXTERN extern __declspec(dllexport) | 194 | # define ZEXTERN extern __declspec(dllexport) |
196 | # else | 195 | # else |
197 | # define ZEXTERN extern __declspec(dllimport) | 196 | # define ZEXTERN extern __declspec(dllimport) |
198 | # endif | 197 | # endif |
198 | # endif | ||
199 | # endif /* ZLIB_DLL */ | ||
200 | /* If building or using zlib with the WINAPI/WINAPIV calling convention, | ||
201 | * define ZLIB_WINAPI. | ||
202 | * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. | ||
203 | */ | ||
204 | # ifdef ZLIB_WINAPI | ||
205 | # ifdef FAR | ||
206 | # undef FAR | ||
207 | # endif | ||
208 | # include <windows.h> | ||
209 | /* No need for _export, use ZLIB.DEF instead. */ | ||
210 | /* For complete Windows compatibility, use WINAPI, not __stdcall. */ | ||
211 | # define ZEXPORT WINAPI | ||
212 | # ifdef WIN32 | ||
213 | # define ZEXPORTVA WINAPIV | ||
199 | # else | 214 | # else |
200 | # define ZEXPORT CDECL | 215 | # define ZEXPORTVA FAR CDECL |
201 | # define ZEXTERN extern | ||
202 | # endif | 216 | # endif |
203 | # endif | 217 | # endif |
204 | #endif | 218 | #endif |
@@ -215,15 +229,15 @@ | |||
215 | # endif | 229 | # endif |
216 | #endif | 230 | #endif |
217 | 231 | ||
232 | #ifndef ZEXTERN | ||
233 | # define ZEXTERN extern | ||
234 | #endif | ||
218 | #ifndef ZEXPORT | 235 | #ifndef ZEXPORT |
219 | # define ZEXPORT | 236 | # define ZEXPORT |
220 | #endif | 237 | #endif |
221 | #ifndef ZEXPORTVA | 238 | #ifndef ZEXPORTVA |
222 | # define ZEXPORTVA | 239 | # define ZEXPORTVA |
223 | #endif | 240 | #endif |
224 | #ifndef ZEXTERN | ||
225 | # define ZEXTERN extern | ||
226 | #endif | ||
227 | 241 | ||
228 | #ifndef FAR | 242 | #ifndef FAR |
229 | # define FAR | 243 | # define FAR |
@@ -248,12 +262,12 @@ typedef uLong FAR uLongf; | |||
248 | 262 | ||
249 | #ifdef STDC | 263 | #ifdef STDC |
250 | typedef void const *voidpc; | 264 | typedef void const *voidpc; |
251 | typedef void FAR *voidpf; | 265 | typedef void FAR *voidpf; |
252 | typedef void *voidp; | 266 | typedef void *voidp; |
253 | #else | 267 | #else |
254 | typedef Byte const *voidpc; | 268 | typedef Byte const *voidpc; |
255 | typedef Byte FAR *voidpf; | 269 | typedef Byte FAR *voidpf; |
256 | typedef Byte *voidp; | 270 | typedef Byte *voidp; |
257 | #endif | 271 | #endif |
258 | 272 | ||
259 | #if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ | 273 | #if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */ |
@@ -1,4 +1,4 @@ | |||
1 | .TH ZLIB 3 "xx July 2003" | 1 | .TH ZLIB 3 "8 September 2003" |
2 | .SH NAME | 2 | .SH NAME |
3 | zlib \- compression/decompression library | 3 | zlib \- compression/decompression library |
4 | .SH SYNOPSIS | 4 | .SH SYNOPSIS |
@@ -97,7 +97,7 @@ http://www.zlib.org | |||
97 | http://www.gzip.org/zlib/ | 97 | http://www.gzip.org/zlib/ |
98 | .LP | 98 | .LP |
99 | The data format used by the zlib library is described by RFC | 99 | The data format used by the zlib library is described by RFC |
100 | (Request for Comments) 1950 to 1952 in the files: | 100 | (Request for Comments) 1950 to 1952 in the files: |
101 | .IP | 101 | .IP |
102 | http://www.ietf.org/rfc/rfc1950.txt (concerning zlib format) | 102 | http://www.ietf.org/rfc/rfc1950.txt (concerning zlib format) |
103 | .br | 103 | .br |
@@ -133,7 +133,7 @@ before asking for help. | |||
133 | Send questions and/or comments to zlib@gzip.org, | 133 | Send questions and/or comments to zlib@gzip.org, |
134 | or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). | 134 | or (for the Windows DLL version) to Gilles Vollant (info@winimage.com). |
135 | .SH AUTHORS | 135 | .SH AUTHORS |
136 | Version 1.2.0.4 | 136 | Version 1.2.0.5 |
137 | Copyright (C) 1995-2003 Jean-loup Gailly (jloup@gzip.org) | 137 | Copyright (C) 1995-2003 Jean-loup Gailly (jloup@gzip.org) |
138 | and Mark Adler (madler@alumni.caltech.edu). | 138 | and Mark Adler (madler@alumni.caltech.edu). |
139 | .LP | 139 | .LP |
@@ -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.2.0.4, August 10th, 2003 | 2 | version 1.2.0.5, September 8th, 2003 |
3 | 3 | ||
4 | Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler | 4 | Copyright (C) 1995-2003 Jean-loup Gailly and Mark Adler |
5 | 5 | ||
@@ -37,10 +37,10 @@ | |||
37 | extern "C" { | 37 | extern "C" { |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #define ZLIB_VERSION "1.2.0.4" | 40 | #define ZLIB_VERSION "1.2.0.5" |
41 | #define ZLIB_VERNUM 0x1204 | 41 | #define ZLIB_VERNUM 0x1205 |
42 | 42 | ||
43 | /* | 43 | /* |
44 | The 'zlib' compression library provides in-memory compression and | 44 | The 'zlib' compression library provides in-memory compression and |
45 | decompression functions, including integrity checks of the uncompressed | 45 | decompression functions, including integrity checks of the uncompressed |
46 | data. This version of the library supports only one compression method | 46 | data. This version of the library supports only one compression method |
@@ -143,7 +143,8 @@ typedef z_stream FAR *z_streamp; | |||
143 | #define Z_SYNC_FLUSH 2 | 143 | #define Z_SYNC_FLUSH 2 |
144 | #define Z_FULL_FLUSH 3 | 144 | #define Z_FULL_FLUSH 3 |
145 | #define Z_FINISH 4 | 145 | #define Z_FINISH 4 |
146 | /* Allowed flush values; see deflate() below for details */ | 146 | #define Z_BLOCK 5 |
147 | /* Allowed flush values; see deflate() and inflate() below for details */ | ||
147 | 148 | ||
148 | #define Z_OK 0 | 149 | #define Z_OK 0 |
149 | #define Z_STREAM_END 1 | 150 | #define Z_STREAM_END 1 |
@@ -192,7 +193,7 @@ ZEXTERN const char * ZEXPORT zlibVersion OF((void)); | |||
192 | This check is automatically made by deflateInit and inflateInit. | 193 | This check is automatically made by deflateInit and inflateInit. |
193 | */ | 194 | */ |
194 | 195 | ||
195 | /* | 196 | /* |
196 | ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); | 197 | ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); |
197 | 198 | ||
198 | Initializes the internal stream state for compression. The fields | 199 | Initializes the internal stream state for compression. The fields |
@@ -272,7 +273,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); | |||
272 | more input data, until it returns with Z_STREAM_END or an error. After | 273 | more input data, until it returns with Z_STREAM_END or an error. After |
273 | deflate has returned Z_STREAM_END, the only possible operations on the | 274 | deflate has returned Z_STREAM_END, the only possible operations on the |
274 | stream are deflateReset or deflateEnd. | 275 | stream are deflateReset or deflateEnd. |
275 | 276 | ||
276 | Z_FINISH can be used immediately after deflateInit if all the compression | 277 | Z_FINISH can be used immediately after deflateInit if all the compression |
277 | is to be done in a single step. In this case, avail_out must be at least | 278 | is to be done in a single step. In this case, avail_out must be at least |
278 | the value returned by deflateBound (see below). If deflate does not return | 279 | the value returned by deflateBound (see below). If deflate does not return |
@@ -311,7 +312,7 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); | |||
311 | */ | 312 | */ |
312 | 313 | ||
313 | 314 | ||
314 | /* | 315 | /* |
315 | ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); | 316 | ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); |
316 | 317 | ||
317 | Initializes the internal stream state for decompression. The fields | 318 | Initializes the internal stream state for decompression. The fields |
@@ -361,9 +362,23 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); | |||
361 | must be called again after making room in the output buffer because there | 362 | must be called again after making room in the output buffer because there |
362 | might be more output pending. | 363 | might be more output pending. |
363 | 364 | ||
364 | The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, or | 365 | The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, |
365 | Z_FINISH. Z_SYNC_FLUSH requests that inflate() flush as much output as | 366 | Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much |
366 | possible to the output buffer. | 367 | output as possible to the output buffer. Z_BLOCK requests that inflate() stop |
368 | if and when it get to the next deflate block boundary. When decoding the zlib | ||
369 | or gzip format, this will cause inflate() to return immediately after the | ||
370 | header and before the first block. When doing a raw inflate, inflate() will | ||
371 | go ahead and process the first block, and will return when it gets to the end | ||
372 | of that block, or when it runs out of data. | ||
373 | |||
374 | The Z_BLOCK option assists in appending to or combining deflate streams. | ||
375 | Also to assist in this, on return inflate() will set strm->data_type to the | ||
376 | number of unused bits in the last byte taken from strm->next_in, plus eight | ||
377 | if inflate() is currently decoding the last block in the deflate stream, | ||
378 | plus 16 if inflate() returned immediately after decoding an end-of-block | ||
379 | code or decoding the complete header up just before the first byte of the | ||
380 | deflate stream. The end-of-block will not be indicated until all of the | ||
381 | uncompressed data from that block has been written to strm->next_out. | ||
367 | 382 | ||
368 | inflate() should normally be called until it returns Z_STREAM_END or an | 383 | inflate() should normally be called until it returns Z_STREAM_END or an |
369 | error. However if all decompression is to be performed in a single step | 384 | error. However if all decompression is to be performed in a single step |
@@ -379,7 +394,8 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); | |||
379 | In this implementation, inflate() always flushes as much output as | 394 | In this implementation, inflate() always flushes as much output as |
380 | possible to the output buffer, and always uses the faster approach on the | 395 | possible to the output buffer, and always uses the faster approach on the |
381 | first call. So the only effect of the flush parameter in this implementation | 396 | first call. So the only effect of the flush parameter in this implementation |
382 | is on the return value of inflate(), as noted below. | 397 | is on the return value of inflate(), as noted below, or when it returns early |
398 | because Z_BLOCK is used. | ||
383 | 399 | ||
384 | If a preset dictionary is needed after this call (see inflateSetDictionary | 400 | If a preset dictionary is needed after this call (see inflateSetDictionary |
385 | below), inflate sets strm-adler to the adler32 checksum of the dictionary | 401 | below), inflate sets strm-adler to the adler32 checksum of the dictionary |
@@ -430,7 +446,7 @@ ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); | |||
430 | The following functions are needed only in some special applications. | 446 | The following functions are needed only in some special applications. |
431 | */ | 447 | */ |
432 | 448 | ||
433 | /* | 449 | /* |
434 | ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, | 450 | ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, |
435 | int level, | 451 | int level, |
436 | int method, | 452 | int method, |
@@ -485,7 +501,7 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, | |||
485 | method). msg is set to null if there is no error message. deflateInit2 does | 501 | method). msg is set to null if there is no error message. deflateInit2 does |
486 | not perform any compression: this will be done by deflate(). | 502 | not perform any compression: this will be done by deflate(). |
487 | */ | 503 | */ |
488 | 504 | ||
489 | ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, | 505 | ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, |
490 | const Bytef *dictionary, | 506 | const Bytef *dictionary, |
491 | uInt dictLength)); | 507 | uInt dictLength)); |
@@ -582,7 +598,7 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, | |||
582 | for deflation in a single pass, and so would be called before deflate(). | 598 | for deflation in a single pass, and so would be called before deflate(). |
583 | */ | 599 | */ |
584 | 600 | ||
585 | /* | 601 | /* |
586 | ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, | 602 | ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, |
587 | int windowBits)); | 603 | int windowBits)); |
588 | 604 | ||
@@ -644,7 +660,7 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, | |||
644 | */ | 660 | */ |
645 | 661 | ||
646 | ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); | 662 | ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); |
647 | /* | 663 | /* |
648 | Skips invalid compressed data until a full flush point (see above the | 664 | Skips invalid compressed data until a full flush point (see above the |
649 | description of deflate with Z_FULL_FLUSH) can be found, or until all | 665 | description of deflate with Z_FULL_FLUSH) can be found, or until all |
650 | available input is skipped. No output is provided. | 666 | available input is skipped. No output is provided. |
@@ -778,7 +794,7 @@ ZEXTERN int ZEXPORT inflateBack OF((z_stream FAR *strm, | |||
778 | that inflateBack() cannot return Z_OK. | 794 | that inflateBack() cannot return Z_OK. |
779 | */ | 795 | */ |
780 | 796 | ||
781 | ZEXTERN int ZEXPORT inflateBackEnd(z_stream FAR *strm); | 797 | ZEXTERN int ZEXPORT inflateBackEnd OF((z_stream FAR *strm)); |
782 | /* | 798 | /* |
783 | All memory allocated by inflateBackInit() is freed. | 799 | All memory allocated by inflateBackInit() is freed. |
784 | 800 | ||
@@ -792,12 +808,14 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); | |||
792 | Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: | 808 | Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: |
793 | 1.0: size of uInt | 809 | 1.0: size of uInt |
794 | 3.2: size of uLong | 810 | 3.2: size of uLong |
795 | 5.4: size of voidpf (pointers) | 811 | 5.4: size of voidpf (pointer) |
796 | 7.6: size of z_off_t | 812 | 7.6: size of z_off_t |
797 | 813 | ||
798 | Debug options: | 814 | Compiler, assembler, and debug options: |
799 | 8: DEBUG | 815 | 8: DEBUG |
800 | 9-11: 0 (reserved) | 816 | 9: ASMV or ASMINF -- use ASM code |
817 | 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention | ||
818 | 11: 0 (reserved) | ||
801 | 819 | ||
802 | One-time table building (smaller code, but not thread-safe if true): | 820 | One-time table building (smaller code, but not thread-safe if true): |
803 | 12: BUILDFIXED -- build static block decoding tables when needed | 821 | 12: BUILDFIXED -- build static block decoding tables when needed |
@@ -805,8 +823,8 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); | |||
805 | 14,15: 0 (reserved) | 823 | 14,15: 0 (reserved) |
806 | 824 | ||
807 | Library content (indicates missing functionality): | 825 | Library content (indicates missing functionality): |
808 | 16: NO_DEFLATE -- gz* functions cannot compress (to avoid linking deflate | 826 | 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking |
809 | code when not needed) | 827 | deflate code when not needed) |
810 | 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect | 828 | 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect |
811 | and decode gzip streams (to avoid linking crc code) | 829 | and decode gzip streams (to avoid linking crc code) |
812 | 18-19: 0 (reserved) | 830 | 18-19: 0 (reserved) |
@@ -941,7 +959,7 @@ ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); | |||
941 | gzread returns the number of uncompressed bytes actually read (0 for | 959 | gzread returns the number of uncompressed bytes actually read (0 for |
942 | end of file, -1 for error). */ | 960 | end of file, -1 for error). */ |
943 | 961 | ||
944 | ZEXTERN int ZEXPORT gzwrite OF((gzFile file, | 962 | ZEXTERN int ZEXPORT gzwrite OF((gzFile file, |
945 | voidpc buf, unsigned len)); | 963 | voidpc buf, unsigned len)); |
946 | /* | 964 | /* |
947 | Writes the given number of uncompressed bytes into the compressed file. | 965 | Writes the given number of uncompressed bytes into the compressed file. |
@@ -1012,7 +1030,7 @@ ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); | |||
1012 | 1030 | ||
1013 | ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, | 1031 | ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, |
1014 | z_off_t offset, int whence)); | 1032 | z_off_t offset, int whence)); |
1015 | /* | 1033 | /* |
1016 | Sets the starting position for the next gzread or gzwrite on the | 1034 | Sets the starting position for the next gzread or gzwrite on the |
1017 | given compressed file. The offset represents a number of bytes in the | 1035 | given compressed file. The offset represents a number of bytes in the |
1018 | uncompressed data stream. The whence parameter is defined as in lseek(2); | 1036 | uncompressed data stream. The whence parameter is defined as in lseek(2); |
@@ -1,6 +1,6 @@ | |||
1 | /* zutil.c -- target dependent utility functions for the compression library | 1 | /* zutil.c -- target dependent utility functions for the compression library |
2 | * Copyright (C) 1995-2003 Jean-loup Gailly. | 2 | * Copyright (C) 1995-2003 Jean-loup Gailly. |
3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
4 | */ | 4 | */ |
5 | 5 | ||
6 | /* @(#) $Id$ */ | 6 | /* @(#) $Id$ */ |
@@ -65,13 +65,19 @@ uLong ZEXPORT zlibCompileFlags() | |||
65 | #ifdef DEBUG | 65 | #ifdef DEBUG |
66 | flags += 1 << 8; | 66 | flags += 1 << 8; |
67 | #endif | 67 | #endif |
68 | #if defined(ASMV) || defined(ASMINF) | ||
69 | flags += 1 << 9; | ||
70 | #endif | ||
71 | #ifdef ZLIB_WINAPI | ||
72 | flags += 1 << 10; | ||
73 | #endif | ||
68 | #ifdef BUILDFIXED | 74 | #ifdef BUILDFIXED |
69 | flags += 1 << 12; | 75 | flags += 1 << 12; |
70 | #endif | 76 | #endif |
71 | #ifdef DYNAMIC_CRC_TABLE | 77 | #ifdef DYNAMIC_CRC_TABLE |
72 | flags += 1 << 13; | 78 | flags += 1 << 13; |
73 | #endif | 79 | #endif |
74 | #ifdef NO_DEFLATE | 80 | #ifdef NO_GZCOMPRESS |
75 | flags += 1 << 16; | 81 | flags += 1 << 16; |
76 | #endif | 82 | #endif |
77 | #ifdef NO_GZIP | 83 | #ifdef NO_GZIP |
@@ -176,12 +182,12 @@ void zmemzero(dest, len) | |||
176 | } | 182 | } |
177 | #endif | 183 | #endif |
178 | 184 | ||
185 | |||
186 | #ifdef SYS16BIT | ||
187 | |||
179 | #ifdef __TURBOC__ | 188 | #ifdef __TURBOC__ |
180 | #if (defined( __BORLANDC__) || !defined(SMALL_MEDIUM)) && !defined(__32BIT__) | 189 | /* Turbo C in 16-bit mode */ |
181 | #if !defined(__linux) | 190 | |
182 | /* Small and medium model in Turbo C are for now limited to near allocation | ||
183 | * with reduced MAX_WBITS and MAX_MEM_LEVEL | ||
184 | */ | ||
185 | # define MY_ZCALLOC | 191 | # define MY_ZCALLOC |
186 | 192 | ||
187 | /* Turbo C malloc() does not allow dynamic allocation of 64K bytes | 193 | /* Turbo C malloc() does not allow dynamic allocation of 64K bytes |
@@ -253,12 +259,11 @@ void zcfree (voidpf opaque, voidpf ptr) | |||
253 | ptr = opaque; /* just to make some compilers happy */ | 259 | ptr = opaque; /* just to make some compilers happy */ |
254 | Assert(0, "zcfree: ptr not found"); | 260 | Assert(0, "zcfree: ptr not found"); |
255 | } | 261 | } |
256 | #endif | 262 | |
257 | #endif | ||
258 | #endif /* __TURBOC__ */ | 263 | #endif /* __TURBOC__ */ |
259 | 264 | ||
260 | 265 | ||
261 | #if defined(M_I86) && !defined(__32BIT__) | 266 | #ifdef M_I86 |
262 | /* Microsoft C in 16-bit mode */ | 267 | /* Microsoft C in 16-bit mode */ |
263 | 268 | ||
264 | # define MY_ZCALLOC | 269 | # define MY_ZCALLOC |
@@ -280,7 +285,9 @@ void zcfree (voidpf opaque, voidpf ptr) | |||
280 | _hfree(ptr); | 285 | _hfree(ptr); |
281 | } | 286 | } |
282 | 287 | ||
283 | #endif /* MSC */ | 288 | #endif /* M_I86 */ |
289 | |||
290 | #endif /* SYS16BIT */ | ||
284 | 291 | ||
285 | 292 | ||
286 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ | 293 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ |
@@ -74,7 +74,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
74 | 74 | ||
75 | /* target dependencies */ | 75 | /* target dependencies */ |
76 | 76 | ||
77 | #ifdef MSDOS | 77 | #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) |
78 | # define OS_CODE 0x00 | 78 | # define OS_CODE 0x00 |
79 | # if defined(__TURBOC__) || defined(__BORLANDC__) | 79 | # if defined(__TURBOC__) || defined(__BORLANDC__) |
80 | # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) | 80 | # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) |
@@ -82,19 +82,15 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
82 | void _Cdecl farfree( void *block ); | 82 | void _Cdecl farfree( void *block ); |
83 | void *_Cdecl farmalloc( unsigned long nbytes ); | 83 | void *_Cdecl farmalloc( unsigned long nbytes ); |
84 | # else | 84 | # else |
85 | # include <alloc.h> | 85 | # include <alloc.h> |
86 | # endif | 86 | # endif |
87 | # else /* MSC or DJGPP */ | 87 | # else /* MSC or DJGPP */ |
88 | # include <malloc.h> | 88 | # include <malloc.h> |
89 | # endif | 89 | # endif |
90 | #endif | 90 | #endif |
91 | 91 | ||
92 | #ifdef OS2 | 92 | #ifdef AMIGA |
93 | # define OS_CODE 0x06 | 93 | # define OS_CODE 0x01 |
94 | #endif | ||
95 | |||
96 | #ifdef WIN32 /* Window 95 & Windows NT */ | ||
97 | # define OS_CODE 0x0b | ||
98 | #endif | 94 | #endif |
99 | 95 | ||
100 | #if defined(VAXC) || defined(VMS) | 96 | #if defined(VAXC) || defined(VMS) |
@@ -103,14 +99,14 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
103 | fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") | 99 | fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") |
104 | #endif | 100 | #endif |
105 | 101 | ||
106 | #ifdef AMIGA | ||
107 | # define OS_CODE 0x01 | ||
108 | #endif | ||
109 | |||
110 | #if defined(ATARI) || defined(atarist) | 102 | #if defined(ATARI) || defined(atarist) |
111 | # define OS_CODE 0x05 | 103 | # define OS_CODE 0x05 |
112 | #endif | 104 | #endif |
113 | 105 | ||
106 | #ifdef OS2 | ||
107 | # define OS_CODE 0x06 | ||
108 | #endif | ||
109 | |||
114 | #if defined(MACOS) || defined(TARGET_OS_MAC) | 110 | #if defined(MACOS) || defined(TARGET_OS_MAC) |
115 | # define OS_CODE 0x07 | 111 | # define OS_CODE 0x07 |
116 | # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os | 112 | # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os |
@@ -122,14 +118,20 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
122 | # endif | 118 | # endif |
123 | #endif | 119 | #endif |
124 | 120 | ||
125 | #ifdef __50SERIES /* Prime/PRIMOS */ | ||
126 | # define OS_CODE 0x0F | ||
127 | #endif | ||
128 | |||
129 | #ifdef TOPS20 | 121 | #ifdef TOPS20 |
130 | # define OS_CODE 0x0a | 122 | # define OS_CODE 0x0a |
131 | #endif | 123 | #endif |
132 | 124 | ||
125 | #ifdef WIN32 | ||
126 | # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ | ||
127 | # define OS_CODE 0x0b | ||
128 | # endif | ||
129 | #endif | ||
130 | |||
131 | #ifdef __50SERIES /* Prime/PRIMOS */ | ||
132 | # define OS_CODE 0x0f | ||
133 | #endif | ||
134 | |||
133 | #if defined(_BEOS_) || defined(RISCOS) | 135 | #if defined(_BEOS_) || defined(RISCOS) |
134 | # define fdopen(fd,mode) NULL /* No fdopen() */ | 136 | # define fdopen(fd,mode) NULL /* No fdopen() */ |
135 | #endif | 137 | #endif |
@@ -142,8 +144,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
142 | # endif | 144 | # endif |
143 | #endif | 145 | #endif |
144 | 146 | ||
145 | 147 | /* common defaults */ | |
146 | /* Common defaults */ | ||
147 | 148 | ||
148 | #ifndef OS_CODE | 149 | #ifndef OS_CODE |
149 | # define OS_CODE 0x03 /* assume Unix */ | 150 | # define OS_CODE 0x03 /* assume Unix */ |
@@ -155,28 +156,31 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ | |||
155 | 156 | ||
156 | /* functions */ | 157 | /* functions */ |
157 | 158 | ||
158 | #ifdef __STDC_VERSION__ | 159 | #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) |
159 | # if __STDC_VERSION__ >= 199901L | 160 | # ifndef HAVE_VSNPRINTF |
160 | # ifndef STDC99 | 161 | # define HAVE_VSNPRINTF |
161 | # define STDC99 | ||
162 | # endif | ||
163 | # endif | 162 | # endif |
164 | #endif | 163 | #endif |
165 | #if !defined(STDC99) && !(defined(__TURBOC__) && __TURBOC__ >= 0x550) && !defined(HAVE_VSNPRINTF) | 164 | #if defined(__CYGWIN__) |
165 | # ifndef HAVE_VSNPRINTF | ||
166 | # define HAVE_VSNPRINTF | ||
167 | # endif | ||
168 | #endif | ||
169 | #ifndef HAVE_VSNPRINTF | ||
166 | # ifdef MSDOS | 170 | # ifdef MSDOS |
167 | /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), | 171 | /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), |
168 | but for now we just assume it doesn't. */ | 172 | but for now we just assume it doesn't. */ |
169 | # define NO_vsnprintf | 173 | # define NO_vsnprintf |
170 | # endif | 174 | # endif |
175 | # ifdef __TURBOC__ | ||
176 | # define NO_vsnprintf | ||
177 | # endif | ||
171 | # ifdef WIN32 | 178 | # ifdef WIN32 |
172 | /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ | 179 | /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ |
173 | # if !defined(vsnprintf) && !defined(__TURBOC__) | 180 | # if !defined(vsnprintf) && !defined(NO_vsnprintf) |
174 | # define vsnprintf _vsnprintf | 181 | # define vsnprintf _vsnprintf |
175 | # endif | 182 | # endif |
176 | # endif | 183 | # endif |
177 | # ifdef __TURBOC__ | ||
178 | # define NO_vsnprintf | ||
179 | # endif | ||
180 | #endif | 184 | #endif |
181 | 185 | ||
182 | #ifdef HAVE_STRERROR | 186 | #ifdef HAVE_STRERROR |