Fossil SCM
Update the built-in zlib library to version 1.3.
Commit
f1f1d6c4eb530fd3eb08663fdc0ab70f59b50fdee651ce0d844ebcdf38f10acb
Parent
b5aa9f8ab41a5f7…
83 files changed
+2
-2
+19
-1
+1
-1
+8
-2
+9
-10
+5
-27
+5
-16
+16
-10
+1
-1
+1
-1
+2
-2
+3
-3
+1
-1
+1
-1
+6
-18
+8
-8
+6
-11
+3
-3
+1
-1
+1
-1
+4
-8
+18
-44
+19
-19
+19
-46
+4
-4
+22
-48
+24
-36
+1
-7
+196
-341
+68
-68
+137
-194
+153
-156
+1
-1
+1
-1
+28
-35
+1
-1
+4
-4
+1
-1
+4
-4
+1
-1
+4
-4
+1
-1
+4
-4
+1
-1
+4
-4
+1
-1
+86
-162
+234
-337
+8
-8
+1
-1
+15
-11
+439
-385
+41
-30
+1
-3
+11
-12
+26
-83
+20
-68
+19
-65
+7
-23
+1
-4
+1
-1
+30
-99
+6
-11
+3
-3
+1
-1
+4
-4
+5
-5
+23
-80
+3
-2
+50
-122
+2
-2
+225
-303
+4
-12
+2
-2
+6
-2
+6
-2
+6
-2
+3
-3
+191
-188
-152
+16
-44
+10
-10
~
compat/zlib/CMakeLists.txt
~
compat/zlib/ChangeLog
~
compat/zlib/FAQ
~
compat/zlib/Makefile.in
~
compat/zlib/README
~
compat/zlib/adler32.c
~
compat/zlib/compress.c
~
compat/zlib/configure
~
compat/zlib/contrib/delphi/ZLib.pas
~
compat/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs
~
compat/zlib/contrib/dotzlib/DotZLib/CodecBase.cs
~
compat/zlib/contrib/dotzlib/DotZLib/GZipStream.cs
~
compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
~
compat/zlib/contrib/dotzlib/readme.txt
~
compat/zlib/contrib/infback9/infback9.c
~
compat/zlib/contrib/infback9/infback9.h
~
compat/zlib/contrib/infback9/inftree9.c
~
compat/zlib/contrib/infback9/inftree9.h
~
compat/zlib/contrib/minizip/MiniZip64_Changes.txt
~
compat/zlib/contrib/minizip/configure.ac
~
compat/zlib/contrib/minizip/crypt.h
~
compat/zlib/contrib/minizip/ioapi.c
~
compat/zlib/contrib/minizip/ioapi.h
~
compat/zlib/contrib/minizip/iowin32.c
~
compat/zlib/contrib/minizip/iowin32.h
~
compat/zlib/contrib/minizip/miniunz.c
~
compat/zlib/contrib/minizip/minizip.c
~
compat/zlib/contrib/minizip/mztools.c
~
compat/zlib/contrib/minizip/unzip.c
~
compat/zlib/contrib/minizip/unzip.h
~
compat/zlib/contrib/minizip/zip.c
~
compat/zlib/contrib/minizip/zip.h
~
compat/zlib/contrib/pascal/zlibpas.pas
~
compat/zlib/contrib/testzlib/testzlib.c
~
compat/zlib/contrib/untgz/untgz.c
~
compat/zlib/contrib/vstudio/readme.txt
~
compat/zlib/contrib/vstudio/vc10/zlib.rc
~
compat/zlib/contrib/vstudio/vc10/zlibvc.def
~
compat/zlib/contrib/vstudio/vc11/zlib.rc
~
compat/zlib/contrib/vstudio/vc11/zlibvc.def
~
compat/zlib/contrib/vstudio/vc12/zlib.rc
~
compat/zlib/contrib/vstudio/vc12/zlibvc.def
~
compat/zlib/contrib/vstudio/vc14/zlib.rc
~
compat/zlib/contrib/vstudio/vc14/zlibvc.def
~
compat/zlib/contrib/vstudio/vc9/zlib.rc
~
compat/zlib/contrib/vstudio/vc9/zlibvc.def
~
compat/zlib/crc32.c
~
compat/zlib/deflate.c
~
compat/zlib/deflate.h
~
compat/zlib/examples/fitblk.c
~
compat/zlib/examples/zlib_how.html
~
compat/zlib/examples/zran.c
~
compat/zlib/examples/zran.h
~
compat/zlib/gzclose.c
~
compat/zlib/gzguts.h
~
compat/zlib/gzlib.c
~
compat/zlib/gzread.c
~
compat/zlib/gzwrite.c
~
compat/zlib/infback.c
~
compat/zlib/inffast.c
~
compat/zlib/inffast.h
~
compat/zlib/inflate.c
~
compat/zlib/inftrees.c
~
compat/zlib/inftrees.h
~
compat/zlib/os400/README400
~
compat/zlib/os400/zlib.inc
~
compat/zlib/qnx/package.qpg
~
compat/zlib/test/example.c
~
compat/zlib/test/infcover.c
~
compat/zlib/test/minigzip.c
~
compat/zlib/treebuild.xml
~
compat/zlib/trees.c
~
compat/zlib/uncompr.c
~
compat/zlib/win32/README-WIN32.txt
~
compat/zlib/zconf.h
~
compat/zlib/zconf.h.cmakein
~
compat/zlib/zconf.h.in
~
compat/zlib/zlib.3
~
compat/zlib/zlib.3.pdf
~
compat/zlib/zlib.h
-
compat/zlib/zlib2ansi
~
compat/zlib/zutil.c
~
compat/zlib/zutil.h
+2
-2
| --- compat/zlib/CMakeLists.txt | ||
| +++ compat/zlib/CMakeLists.txt | ||
| @@ -1,11 +1,11 @@ | ||
| 1 | -cmake_minimum_required(VERSION 2.4.4) | |
| 1 | +cmake_minimum_required(VERSION 2.4.4...3.15.0) | |
| 2 | 2 | set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) |
| 3 | 3 | |
| 4 | 4 | project(zlib C) |
| 5 | 5 | |
| 6 | -set(VERSION "1.2.13") | |
| 6 | +set(VERSION "1.3") | |
| 7 | 7 | |
| 8 | 8 | set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") |
| 9 | 9 | set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") |
| 10 | 10 | set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") |
| 11 | 11 | set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") |
| 12 | 12 |
| --- compat/zlib/CMakeLists.txt | |
| +++ compat/zlib/CMakeLists.txt | |
| @@ -1,11 +1,11 @@ | |
| 1 | cmake_minimum_required(VERSION 2.4.4) |
| 2 | set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) |
| 3 | |
| 4 | project(zlib C) |
| 5 | |
| 6 | set(VERSION "1.2.13") |
| 7 | |
| 8 | set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") |
| 9 | set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") |
| 10 | set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") |
| 11 | set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") |
| 12 |
| --- compat/zlib/CMakeLists.txt | |
| +++ compat/zlib/CMakeLists.txt | |
| @@ -1,11 +1,11 @@ | |
| 1 | cmake_minimum_required(VERSION 2.4.4...3.15.0) |
| 2 | set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) |
| 3 | |
| 4 | project(zlib C) |
| 5 | |
| 6 | set(VERSION "1.3") |
| 7 | |
| 8 | set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") |
| 9 | set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") |
| 10 | set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") |
| 11 | set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") |
| 12 |
+19
-1
| --- compat/zlib/ChangeLog | ||
| +++ compat/zlib/ChangeLog | ||
| @@ -1,8 +1,26 @@ | ||
| 1 | 1 | |
| 2 | 2 | ChangeLog file for zlib |
| 3 | 3 | |
| 4 | +Changes in 1.3 (18 Aug 2023) | |
| 5 | +- Remove K&R function definitions and zlib2ansi | |
| 6 | +- Fix bug in deflateBound() for level 0 and memLevel 9 | |
| 7 | +- Fix bug when gzungetc() is used immediately after gzopen() | |
| 8 | +- Fix bug when using gzflush() with a very small buffer | |
| 9 | +- Fix crash when gzsetparams() attempted for transparent write | |
| 10 | +- Fix test/example.c to work with FORCE_STORED | |
| 11 | +- Rewrite of zran in examples (see zran.c version history) | |
| 12 | +- Fix minizip to allow it to open an empty zip file | |
| 13 | +- Fix reading disk number start on zip64 files in minizip | |
| 14 | +- Fix logic error in minizip argument processing | |
| 15 | +- Add minizip testing to Makefile | |
| 16 | +- Read multiple bytes instead of byte-by-byte in minizip unzip.c | |
| 17 | +- Add memory sanitizer to configure (--memory) | |
| 18 | +- Various portability improvements | |
| 19 | +- Various documentation improvements | |
| 20 | +- Various spelling and typo corrections | |
| 21 | + | |
| 4 | 22 | Changes in 1.2.13 (13 Oct 2022) |
| 5 | 23 | - Fix configure issue that discarded provided CC definition |
| 6 | 24 | - Correct incorrect inputs provided to the CRC functions |
| 7 | 25 | - Repair prototypes and exporting of new CRC functions |
| 8 | 26 | - Fix inflateBack to detect invalid input with distances too far |
| @@ -1443,11 +1461,11 @@ | ||
| 1443 | 1461 | - fixed typo in zconf.h (_GNUC__ => __GNUC__) |
| 1444 | 1462 | - check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode) |
| 1445 | 1463 | - fix typo in Make_vms.com (f$trnlnm -> f$getsyi) |
| 1446 | 1464 | - in fcalloc, normalize pointer if size > 65520 bytes |
| 1447 | 1465 | - don't use special fcalloc for 32 bit Borland C++ |
| 1448 | -- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc... | |
| 1466 | +- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc. | |
| 1449 | 1467 | - use Z_BINARY instead of BINARY |
| 1450 | 1468 | - document that gzclose after gzdopen will close the file |
| 1451 | 1469 | - allow "a" as mode in gzopen |
| 1452 | 1470 | - fix error checking in gzread |
| 1453 | 1471 | - allow skipping .gz extra-field on pipes |
| 1454 | 1472 |
| --- compat/zlib/ChangeLog | |
| +++ compat/zlib/ChangeLog | |
| @@ -1,8 +1,26 @@ | |
| 1 | |
| 2 | ChangeLog file for zlib |
| 3 | |
| 4 | Changes in 1.2.13 (13 Oct 2022) |
| 5 | - Fix configure issue that discarded provided CC definition |
| 6 | - Correct incorrect inputs provided to the CRC functions |
| 7 | - Repair prototypes and exporting of new CRC functions |
| 8 | - Fix inflateBack to detect invalid input with distances too far |
| @@ -1443,11 +1461,11 @@ | |
| 1443 | - fixed typo in zconf.h (_GNUC__ => __GNUC__) |
| 1444 | - check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode) |
| 1445 | - fix typo in Make_vms.com (f$trnlnm -> f$getsyi) |
| 1446 | - in fcalloc, normalize pointer if size > 65520 bytes |
| 1447 | - don't use special fcalloc for 32 bit Borland C++ |
| 1448 | - use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc... |
| 1449 | - use Z_BINARY instead of BINARY |
| 1450 | - document that gzclose after gzdopen will close the file |
| 1451 | - allow "a" as mode in gzopen |
| 1452 | - fix error checking in gzread |
| 1453 | - allow skipping .gz extra-field on pipes |
| 1454 |
| --- compat/zlib/ChangeLog | |
| +++ compat/zlib/ChangeLog | |
| @@ -1,8 +1,26 @@ | |
| 1 | |
| 2 | ChangeLog file for zlib |
| 3 | |
| 4 | Changes in 1.3 (18 Aug 2023) |
| 5 | - Remove K&R function definitions and zlib2ansi |
| 6 | - Fix bug in deflateBound() for level 0 and memLevel 9 |
| 7 | - Fix bug when gzungetc() is used immediately after gzopen() |
| 8 | - Fix bug when using gzflush() with a very small buffer |
| 9 | - Fix crash when gzsetparams() attempted for transparent write |
| 10 | - Fix test/example.c to work with FORCE_STORED |
| 11 | - Rewrite of zran in examples (see zran.c version history) |
| 12 | - Fix minizip to allow it to open an empty zip file |
| 13 | - Fix reading disk number start on zip64 files in minizip |
| 14 | - Fix logic error in minizip argument processing |
| 15 | - Add minizip testing to Makefile |
| 16 | - Read multiple bytes instead of byte-by-byte in minizip unzip.c |
| 17 | - Add memory sanitizer to configure (--memory) |
| 18 | - Various portability improvements |
| 19 | - Various documentation improvements |
| 20 | - Various spelling and typo corrections |
| 21 | |
| 22 | Changes in 1.2.13 (13 Oct 2022) |
| 23 | - Fix configure issue that discarded provided CC definition |
| 24 | - Correct incorrect inputs provided to the CRC functions |
| 25 | - Repair prototypes and exporting of new CRC functions |
| 26 | - Fix inflateBack to detect invalid input with distances too far |
| @@ -1443,11 +1461,11 @@ | |
| 1461 | - fixed typo in zconf.h (_GNUC__ => __GNUC__) |
| 1462 | - check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode) |
| 1463 | - fix typo in Make_vms.com (f$trnlnm -> f$getsyi) |
| 1464 | - in fcalloc, normalize pointer if size > 65520 bytes |
| 1465 | - don't use special fcalloc for 32 bit Borland C++ |
| 1466 | - use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc. |
| 1467 | - use Z_BINARY instead of BINARY |
| 1468 | - document that gzclose after gzdopen will close the file |
| 1469 | - allow "a" as mode in gzopen |
| 1470 | - fix error checking in gzread |
| 1471 | - allow skipping .gz extra-field on pipes |
| 1472 |
+1
-1
| --- compat/zlib/FAQ | ||
| +++ compat/zlib/FAQ | ||
| @@ -2,11 +2,11 @@ | ||
| 2 | 2 | Frequently Asked Questions about zlib |
| 3 | 3 | |
| 4 | 4 | |
| 5 | 5 | If your question is not there, please check the zlib home page |
| 6 | 6 | http://zlib.net/ which may have more recent information. |
| 7 | -The lastest zlib FAQ is at http://zlib.net/zlib_faq.html | |
| 7 | +The latest zlib FAQ is at http://zlib.net/zlib_faq.html | |
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | 1. Is zlib Y2K-compliant? |
| 11 | 11 | |
| 12 | 12 | Yes. zlib doesn't handle dates. |
| 13 | 13 |
| --- compat/zlib/FAQ | |
| +++ compat/zlib/FAQ | |
| @@ -2,11 +2,11 @@ | |
| 2 | Frequently Asked Questions about zlib |
| 3 | |
| 4 | |
| 5 | If your question is not there, please check the zlib home page |
| 6 | http://zlib.net/ which may have more recent information. |
| 7 | The lastest zlib FAQ is at http://zlib.net/zlib_faq.html |
| 8 | |
| 9 | |
| 10 | 1. Is zlib Y2K-compliant? |
| 11 | |
| 12 | Yes. zlib doesn't handle dates. |
| 13 |
| --- compat/zlib/FAQ | |
| +++ compat/zlib/FAQ | |
| @@ -2,11 +2,11 @@ | |
| 2 | Frequently Asked Questions about zlib |
| 3 | |
| 4 | |
| 5 | If your question is not there, please check the zlib home page |
| 6 | http://zlib.net/ which may have more recent information. |
| 7 | The latest zlib FAQ is at http://zlib.net/zlib_faq.html |
| 8 | |
| 9 | |
| 10 | 1. Is zlib Y2K-compliant? |
| 11 | |
| 12 | Yes. zlib doesn't handle dates. |
| 13 |
+8
-2
| --- compat/zlib/Makefile.in | ||
| +++ compat/zlib/Makefile.in | ||
| @@ -26,11 +26,11 @@ | ||
| 26 | 26 | LDSHARED=$(CC) |
| 27 | 27 | CPP=$(CC) -E |
| 28 | 28 | |
| 29 | 29 | STATICLIB=libz.a |
| 30 | 30 | SHAREDLIB=libz.so |
| 31 | -SHAREDLIBV=libz.so.1.2.13 | |
| 31 | +SHAREDLIBV=libz.so.1.3 | |
| 32 | 32 | SHAREDLIBM=libz.so.1 |
| 33 | 33 | LIBS=$(STATICLIB) $(SHAREDLIBV) |
| 34 | 34 | |
| 35 | 35 | AR=ar |
| 36 | 36 | ARFLAGS=rc |
| @@ -357,12 +357,18 @@ | ||
| 357 | 357 | rm $$TEMPFILE |
| 358 | 358 | |
| 359 | 359 | zconf: $(SRCDIR)zconf.h.in |
| 360 | 360 | cp -p $(SRCDIR)zconf.h.in zconf.h |
| 361 | 361 | |
| 362 | +minizip-test: static | |
| 363 | + cd contrib/minizip && { CFLAGS="$(CFLAGS)" $(MAKE) test ; cd ../.. ; } | |
| 364 | + | |
| 365 | +minizip-clean: | |
| 366 | + cd contrib/minizip && { $(MAKE) clean ; cd ../.. ; } | |
| 367 | + | |
| 362 | 368 | mostlyclean: clean |
| 363 | -clean: | |
| 369 | +clean: minizip-clean | |
| 364 | 370 | rm -f *.o *.lo *~ \ |
| 365 | 371 | example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \ |
| 366 | 372 | example64$(EXE) minigzip64$(EXE) \ |
| 367 | 373 | infcover \ |
| 368 | 374 | libz.* foo.gz so_locations \ |
| 369 | 375 |
| --- compat/zlib/Makefile.in | |
| +++ compat/zlib/Makefile.in | |
| @@ -26,11 +26,11 @@ | |
| 26 | LDSHARED=$(CC) |
| 27 | CPP=$(CC) -E |
| 28 | |
| 29 | STATICLIB=libz.a |
| 30 | SHAREDLIB=libz.so |
| 31 | SHAREDLIBV=libz.so.1.2.13 |
| 32 | SHAREDLIBM=libz.so.1 |
| 33 | LIBS=$(STATICLIB) $(SHAREDLIBV) |
| 34 | |
| 35 | AR=ar |
| 36 | ARFLAGS=rc |
| @@ -357,12 +357,18 @@ | |
| 357 | rm $$TEMPFILE |
| 358 | |
| 359 | zconf: $(SRCDIR)zconf.h.in |
| 360 | cp -p $(SRCDIR)zconf.h.in zconf.h |
| 361 | |
| 362 | mostlyclean: clean |
| 363 | clean: |
| 364 | rm -f *.o *.lo *~ \ |
| 365 | example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \ |
| 366 | example64$(EXE) minigzip64$(EXE) \ |
| 367 | infcover \ |
| 368 | libz.* foo.gz so_locations \ |
| 369 |
| --- compat/zlib/Makefile.in | |
| +++ compat/zlib/Makefile.in | |
| @@ -26,11 +26,11 @@ | |
| 26 | LDSHARED=$(CC) |
| 27 | CPP=$(CC) -E |
| 28 | |
| 29 | STATICLIB=libz.a |
| 30 | SHAREDLIB=libz.so |
| 31 | SHAREDLIBV=libz.so.1.3 |
| 32 | SHAREDLIBM=libz.so.1 |
| 33 | LIBS=$(STATICLIB) $(SHAREDLIBV) |
| 34 | |
| 35 | AR=ar |
| 36 | ARFLAGS=rc |
| @@ -357,12 +357,18 @@ | |
| 357 | rm $$TEMPFILE |
| 358 | |
| 359 | zconf: $(SRCDIR)zconf.h.in |
| 360 | cp -p $(SRCDIR)zconf.h.in zconf.h |
| 361 | |
| 362 | minizip-test: static |
| 363 | cd contrib/minizip && { CFLAGS="$(CFLAGS)" $(MAKE) test ; cd ../.. ; } |
| 364 | |
| 365 | minizip-clean: |
| 366 | cd contrib/minizip && { $(MAKE) clean ; cd ../.. ; } |
| 367 | |
| 368 | mostlyclean: clean |
| 369 | clean: minizip-clean |
| 370 | rm -f *.o *.lo *~ \ |
| 371 | example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \ |
| 372 | example64$(EXE) minigzip64$(EXE) \ |
| 373 | infcover \ |
| 374 | libz.* foo.gz so_locations \ |
| 375 |
+9
-10
| --- compat/zlib/README | ||
| +++ compat/zlib/README | ||
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | ZLIB DATA COMPRESSION LIBRARY |
| 2 | 2 | |
| 3 | -zlib 1.2.13 is a general purpose data compression library. All the code is | |
| 3 | +zlib 1.3 is a general purpose data compression library. All the code is | |
| 4 | 4 | thread safe. The data format used by the zlib library is described by RFCs |
| 5 | 5 | (Request for Comments) 1950 to 1952 in the files |
| 6 | 6 | http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and |
| 7 | 7 | rfc1952 (gzip format). |
| 8 | 8 | |
| @@ -27,22 +27,21 @@ | ||
| 27 | 27 | |
| 28 | 28 | PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. |
| 29 | 29 | |
| 30 | 30 | Mark Nelson <[email protected]> wrote an article about zlib for the Jan. 1997 |
| 31 | 31 | issue of Dr. Dobb's Journal; a copy of the article is available at |
| 32 | -http://marknelson.us/1997/01/01/zlib-engine/ . | |
| 32 | +https://marknelson.us/posts/1997/01/01/zlib-engine.html . | |
| 33 | 33 | |
| 34 | -The changes made in version 1.2.13 are documented in the file ChangeLog. | |
| 34 | +The changes made in version 1.3 are documented in the file ChangeLog. | |
| 35 | 35 | |
| 36 | 36 | Unsupported third party contributions are provided in directory contrib/ . |
| 37 | 37 | |
| 38 | -zlib is available in Java using the java.util.zip package, documented at | |
| 39 | -http://java.sun.com/developer/technicalArticles/Programming/compression/ . | |
| 38 | +zlib is available in Java using the java.util.zip package. Follow the API | |
| 39 | +Documentation link at: https://docs.oracle.com/search/?q=java.util.zip . | |
| 40 | 40 | |
| 41 | -A Perl interface to zlib written by Paul Marquess <[email protected]> is available | |
| 42 | -at CPAN (Comprehensive Perl Archive Network) sites, including | |
| 43 | -http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . | |
| 41 | +A Perl interface to zlib and bzip2 written by Paul Marquess <[email protected]> | |
| 42 | +can be found at https://github.com/pmqs/IO-Compress . | |
| 44 | 43 | |
| 45 | 44 | A Python interface to zlib written by A.M. Kuchling <[email protected]> is |
| 46 | 45 | available in Python 1.5 and later versions, see |
| 47 | 46 | http://docs.python.org/library/zlib.html . |
| 48 | 47 | |
| @@ -62,11 +61,11 @@ | ||
| 62 | 61 | compiler flag). The compiler bug has been reported to SGI. |
| 63 | 62 | |
| 64 | 63 | - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works |
| 65 | 64 | when compiled with cc. |
| 66 | 65 | |
| 67 | -- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is | |
| 66 | +- On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is | |
| 68 | 67 | necessary to get gzprintf working correctly. This is done by configure. |
| 69 | 68 | |
| 70 | 69 | - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with |
| 71 | 70 | other compilers. Use "make test" to check your compiler. |
| 72 | 71 | |
| @@ -82,11 +81,11 @@ | ||
| 82 | 81 | people who reported problems and suggested various improvements in zlib; they |
| 83 | 82 | are too numerous to cite here. |
| 84 | 83 | |
| 85 | 84 | Copyright notice: |
| 86 | 85 | |
| 87 | - (C) 1995-2022 Jean-loup Gailly and Mark Adler | |
| 86 | + (C) 1995-2023 Jean-loup Gailly and Mark Adler | |
| 88 | 87 | |
| 89 | 88 | This software is provided 'as-is', without any express or implied |
| 90 | 89 | warranty. In no event will the authors be held liable for any damages |
| 91 | 90 | arising from the use of this software. |
| 92 | 91 | |
| 93 | 92 |
| --- compat/zlib/README | |
| +++ compat/zlib/README | |
| @@ -1,8 +1,8 @@ | |
| 1 | ZLIB DATA COMPRESSION LIBRARY |
| 2 | |
| 3 | zlib 1.2.13 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 |
| 5 | (Request for Comments) 1950 to 1952 in the files |
| 6 | http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and |
| 7 | rfc1952 (gzip format). |
| 8 | |
| @@ -27,22 +27,21 @@ | |
| 27 | |
| 28 | PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. |
| 29 | |
| 30 | Mark Nelson <[email protected]> wrote an article about zlib for the Jan. 1997 |
| 31 | issue of Dr. Dobb's Journal; a copy of the article is available at |
| 32 | http://marknelson.us/1997/01/01/zlib-engine/ . |
| 33 | |
| 34 | The changes made in version 1.2.13 are documented in the file ChangeLog. |
| 35 | |
| 36 | Unsupported third party contributions are provided in directory contrib/ . |
| 37 | |
| 38 | zlib is available in Java using the java.util.zip package, documented at |
| 39 | http://java.sun.com/developer/technicalArticles/Programming/compression/ . |
| 40 | |
| 41 | A Perl interface to zlib written by Paul Marquess <[email protected]> is available |
| 42 | at CPAN (Comprehensive Perl Archive Network) sites, including |
| 43 | http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . |
| 44 | |
| 45 | A Python interface to zlib written by A.M. Kuchling <[email protected]> is |
| 46 | available in Python 1.5 and later versions, see |
| 47 | http://docs.python.org/library/zlib.html . |
| 48 | |
| @@ -62,11 +61,11 @@ | |
| 62 | compiler flag). The compiler bug has been reported to SGI. |
| 63 | |
| 64 | - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works |
| 65 | when compiled with cc. |
| 66 | |
| 67 | - On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is |
| 68 | necessary to get gzprintf working correctly. This is done by configure. |
| 69 | |
| 70 | - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with |
| 71 | other compilers. Use "make test" to check your compiler. |
| 72 | |
| @@ -82,11 +81,11 @@ | |
| 82 | people who reported problems and suggested various improvements in zlib; they |
| 83 | are too numerous to cite here. |
| 84 | |
| 85 | Copyright notice: |
| 86 | |
| 87 | (C) 1995-2022 Jean-loup Gailly and Mark Adler |
| 88 | |
| 89 | This software is provided 'as-is', without any express or implied |
| 90 | warranty. In no event will the authors be held liable for any damages |
| 91 | arising from the use of this software. |
| 92 | |
| 93 |
| --- compat/zlib/README | |
| +++ compat/zlib/README | |
| @@ -1,8 +1,8 @@ | |
| 1 | ZLIB DATA COMPRESSION LIBRARY |
| 2 | |
| 3 | zlib 1.3 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 |
| 5 | (Request for Comments) 1950 to 1952 in the files |
| 6 | http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and |
| 7 | rfc1952 (gzip format). |
| 8 | |
| @@ -27,22 +27,21 @@ | |
| 27 | |
| 28 | PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. |
| 29 | |
| 30 | Mark Nelson <[email protected]> wrote an article about zlib for the Jan. 1997 |
| 31 | issue of Dr. Dobb's Journal; a copy of the article is available at |
| 32 | https://marknelson.us/posts/1997/01/01/zlib-engine.html . |
| 33 | |
| 34 | The changes made in version 1.3 are documented in the file ChangeLog. |
| 35 | |
| 36 | Unsupported third party contributions are provided in directory contrib/ . |
| 37 | |
| 38 | zlib is available in Java using the java.util.zip package. Follow the API |
| 39 | Documentation link at: https://docs.oracle.com/search/?q=java.util.zip . |
| 40 | |
| 41 | A Perl interface to zlib and bzip2 written by Paul Marquess <[email protected]> |
| 42 | can be found at https://github.com/pmqs/IO-Compress . |
| 43 | |
| 44 | A Python interface to zlib written by A.M. Kuchling <[email protected]> is |
| 45 | available in Python 1.5 and later versions, see |
| 46 | http://docs.python.org/library/zlib.html . |
| 47 | |
| @@ -62,11 +61,11 @@ | |
| 61 | compiler flag). The compiler bug has been reported to SGI. |
| 62 | |
| 63 | - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works |
| 64 | when compiled with cc. |
| 65 | |
| 66 | - On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is |
| 67 | necessary to get gzprintf working correctly. This is done by configure. |
| 68 | |
| 69 | - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with |
| 70 | other compilers. Use "make test" to check your compiler. |
| 71 | |
| @@ -82,11 +81,11 @@ | |
| 81 | people who reported problems and suggested various improvements in zlib; they |
| 82 | are too numerous to cite here. |
| 83 | |
| 84 | Copyright notice: |
| 85 | |
| 86 | (C) 1995-2023 Jean-loup Gailly and Mark Adler |
| 87 | |
| 88 | This software is provided 'as-is', without any express or implied |
| 89 | warranty. In no event will the authors be held liable for any damages |
| 90 | arising from the use of this software. |
| 91 | |
| 92 |
+5
-27
| --- compat/zlib/adler32.c | ||
| +++ compat/zlib/adler32.c | ||
| @@ -5,12 +5,10 @@ | ||
| 5 | 5 | |
| 6 | 6 | /* @(#) $Id$ */ |
| 7 | 7 | |
| 8 | 8 | #include "zutil.h" |
| 9 | 9 | |
| 10 | -local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); | |
| 11 | - | |
| 12 | 10 | #define BASE 65521U /* largest prime smaller than 65536 */ |
| 13 | 11 | #define NMAX 5552 |
| 14 | 12 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ |
| 15 | 13 | |
| 16 | 14 | #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} |
| @@ -58,15 +56,11 @@ | ||
| 58 | 56 | # define MOD28(a) a %= BASE |
| 59 | 57 | # define MOD63(a) a %= BASE |
| 60 | 58 | #endif |
| 61 | 59 | |
| 62 | 60 | /* ========================================================================= */ |
| 63 | -uLong ZEXPORT adler32_z(adler, buf, len) | |
| 64 | - uLong adler; | |
| 65 | - const Bytef *buf; | |
| 66 | - z_size_t len; | |
| 67 | -{ | |
| 61 | +uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) { | |
| 68 | 62 | unsigned long sum2; |
| 69 | 63 | unsigned n; |
| 70 | 64 | |
| 71 | 65 | /* split Adler-32 into component sums */ |
| 72 | 66 | sum2 = (adler >> 16) & 0xffff; |
| @@ -129,24 +123,16 @@ | ||
| 129 | 123 | /* return recombined sums */ |
| 130 | 124 | return adler | (sum2 << 16); |
| 131 | 125 | } |
| 132 | 126 | |
| 133 | 127 | /* ========================================================================= */ |
| 134 | -uLong ZEXPORT adler32(adler, buf, len) | |
| 135 | - uLong adler; | |
| 136 | - const Bytef *buf; | |
| 137 | - uInt len; | |
| 138 | -{ | |
| 128 | +uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) { | |
| 139 | 129 | return adler32_z(adler, buf, len); |
| 140 | 130 | } |
| 141 | 131 | |
| 142 | 132 | /* ========================================================================= */ |
| 143 | -local uLong adler32_combine_(adler1, adler2, len2) | |
| 144 | - uLong adler1; | |
| 145 | - uLong adler2; | |
| 146 | - z_off64_t len2; | |
| 147 | -{ | |
| 133 | +local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) { | |
| 148 | 134 | unsigned long sum1; |
| 149 | 135 | unsigned long sum2; |
| 150 | 136 | unsigned rem; |
| 151 | 137 | |
| 152 | 138 | /* for negative len, return invalid adler32 as a clue for debugging */ |
| @@ -167,20 +153,12 @@ | ||
| 167 | 153 | if (sum2 >= BASE) sum2 -= BASE; |
| 168 | 154 | return sum1 | (sum2 << 16); |
| 169 | 155 | } |
| 170 | 156 | |
| 171 | 157 | /* ========================================================================= */ |
| 172 | -uLong ZEXPORT adler32_combine(adler1, adler2, len2) | |
| 173 | - uLong adler1; | |
| 174 | - uLong adler2; | |
| 175 | - z_off_t len2; | |
| 176 | -{ | |
| 158 | +uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) { | |
| 177 | 159 | return adler32_combine_(adler1, adler2, len2); |
| 178 | 160 | } |
| 179 | 161 | |
| 180 | -uLong ZEXPORT adler32_combine64(adler1, adler2, len2) | |
| 181 | - uLong adler1; | |
| 182 | - uLong adler2; | |
| 183 | - z_off64_t len2; | |
| 184 | -{ | |
| 162 | +uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) { | |
| 185 | 163 | return adler32_combine_(adler1, adler2, len2); |
| 186 | 164 | } |
| 187 | 165 |
| --- compat/zlib/adler32.c | |
| +++ compat/zlib/adler32.c | |
| @@ -5,12 +5,10 @@ | |
| 5 | |
| 6 | /* @(#) $Id$ */ |
| 7 | |
| 8 | #include "zutil.h" |
| 9 | |
| 10 | local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); |
| 11 | |
| 12 | #define BASE 65521U /* largest prime smaller than 65536 */ |
| 13 | #define NMAX 5552 |
| 14 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ |
| 15 | |
| 16 | #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} |
| @@ -58,15 +56,11 @@ | |
| 58 | # define MOD28(a) a %= BASE |
| 59 | # define MOD63(a) a %= BASE |
| 60 | #endif |
| 61 | |
| 62 | /* ========================================================================= */ |
| 63 | uLong ZEXPORT adler32_z(adler, buf, len) |
| 64 | uLong adler; |
| 65 | const Bytef *buf; |
| 66 | z_size_t len; |
| 67 | { |
| 68 | unsigned long sum2; |
| 69 | unsigned n; |
| 70 | |
| 71 | /* split Adler-32 into component sums */ |
| 72 | sum2 = (adler >> 16) & 0xffff; |
| @@ -129,24 +123,16 @@ | |
| 129 | /* return recombined sums */ |
| 130 | return adler | (sum2 << 16); |
| 131 | } |
| 132 | |
| 133 | /* ========================================================================= */ |
| 134 | uLong ZEXPORT adler32(adler, buf, len) |
| 135 | uLong adler; |
| 136 | const Bytef *buf; |
| 137 | uInt len; |
| 138 | { |
| 139 | return adler32_z(adler, buf, len); |
| 140 | } |
| 141 | |
| 142 | /* ========================================================================= */ |
| 143 | local uLong adler32_combine_(adler1, adler2, len2) |
| 144 | uLong adler1; |
| 145 | uLong adler2; |
| 146 | z_off64_t len2; |
| 147 | { |
| 148 | unsigned long sum1; |
| 149 | unsigned long sum2; |
| 150 | unsigned rem; |
| 151 | |
| 152 | /* for negative len, return invalid adler32 as a clue for debugging */ |
| @@ -167,20 +153,12 @@ | |
| 167 | if (sum2 >= BASE) sum2 -= BASE; |
| 168 | return sum1 | (sum2 << 16); |
| 169 | } |
| 170 | |
| 171 | /* ========================================================================= */ |
| 172 | uLong ZEXPORT adler32_combine(adler1, adler2, len2) |
| 173 | uLong adler1; |
| 174 | uLong adler2; |
| 175 | z_off_t len2; |
| 176 | { |
| 177 | return adler32_combine_(adler1, adler2, len2); |
| 178 | } |
| 179 | |
| 180 | uLong ZEXPORT adler32_combine64(adler1, adler2, len2) |
| 181 | uLong adler1; |
| 182 | uLong adler2; |
| 183 | z_off64_t len2; |
| 184 | { |
| 185 | return adler32_combine_(adler1, adler2, len2); |
| 186 | } |
| 187 |
| --- compat/zlib/adler32.c | |
| +++ compat/zlib/adler32.c | |
| @@ -5,12 +5,10 @@ | |
| 5 | |
| 6 | /* @(#) $Id$ */ |
| 7 | |
| 8 | #include "zutil.h" |
| 9 | |
| 10 | #define BASE 65521U /* largest prime smaller than 65536 */ |
| 11 | #define NMAX 5552 |
| 12 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ |
| 13 | |
| 14 | #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} |
| @@ -58,15 +56,11 @@ | |
| 56 | # define MOD28(a) a %= BASE |
| 57 | # define MOD63(a) a %= BASE |
| 58 | #endif |
| 59 | |
| 60 | /* ========================================================================= */ |
| 61 | uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) { |
| 62 | unsigned long sum2; |
| 63 | unsigned n; |
| 64 | |
| 65 | /* split Adler-32 into component sums */ |
| 66 | sum2 = (adler >> 16) & 0xffff; |
| @@ -129,24 +123,16 @@ | |
| 123 | /* return recombined sums */ |
| 124 | return adler | (sum2 << 16); |
| 125 | } |
| 126 | |
| 127 | /* ========================================================================= */ |
| 128 | uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) { |
| 129 | return adler32_z(adler, buf, len); |
| 130 | } |
| 131 | |
| 132 | /* ========================================================================= */ |
| 133 | local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) { |
| 134 | unsigned long sum1; |
| 135 | unsigned long sum2; |
| 136 | unsigned rem; |
| 137 | |
| 138 | /* for negative len, return invalid adler32 as a clue for debugging */ |
| @@ -167,20 +153,12 @@ | |
| 153 | if (sum2 >= BASE) sum2 -= BASE; |
| 154 | return sum1 | (sum2 << 16); |
| 155 | } |
| 156 | |
| 157 | /* ========================================================================= */ |
| 158 | uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) { |
| 159 | return adler32_combine_(adler1, adler2, len2); |
| 160 | } |
| 161 | |
| 162 | uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) { |
| 163 | return adler32_combine_(adler1, adler2, len2); |
| 164 | } |
| 165 |
+5
-16
| --- compat/zlib/compress.c | ||
| +++ compat/zlib/compress.c | ||
| @@ -17,17 +17,12 @@ | ||
| 17 | 17 | |
| 18 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 19 | 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, |
| 20 | 20 | Z_STREAM_ERROR if the level parameter is invalid. |
| 21 | 21 | */ |
| 22 | -int ZEXPORT compress2(dest, destLen, source, sourceLen, level) | |
| 23 | - Bytef *dest; | |
| 24 | - uLongf *destLen; | |
| 25 | - const Bytef *source; | |
| 26 | - uLong sourceLen; | |
| 27 | - int level; | |
| 28 | -{ | |
| 22 | +int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, | |
| 23 | + uLong sourceLen, int level) { | |
| 29 | 24 | z_stream stream; |
| 30 | 25 | int err; |
| 31 | 26 | const uInt max = (uInt)-1; |
| 32 | 27 | uLong left; |
| 33 | 28 | |
| @@ -63,24 +58,18 @@ | ||
| 63 | 58 | return err == Z_STREAM_END ? Z_OK : err; |
| 64 | 59 | } |
| 65 | 60 | |
| 66 | 61 | /* =========================================================================== |
| 67 | 62 | */ |
| 68 | -int ZEXPORT compress(dest, destLen, source, sourceLen) | |
| 69 | - Bytef *dest; | |
| 70 | - uLongf *destLen; | |
| 71 | - const Bytef *source; | |
| 72 | - uLong sourceLen; | |
| 73 | -{ | |
| 63 | +int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, | |
| 64 | + uLong sourceLen) { | |
| 74 | 65 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); |
| 75 | 66 | } |
| 76 | 67 | |
| 77 | 68 | /* =========================================================================== |
| 78 | 69 | If the default memLevel or windowBits for deflateInit() is changed, then |
| 79 | 70 | this function needs to be updated. |
| 80 | 71 | */ |
| 81 | -uLong ZEXPORT compressBound(sourceLen) | |
| 82 | - uLong sourceLen; | |
| 83 | -{ | |
| 72 | +uLong ZEXPORT compressBound(uLong sourceLen) { | |
| 84 | 73 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + |
| 85 | 74 | (sourceLen >> 25) + 13; |
| 86 | 75 | } |
| 87 | 76 |
| --- compat/zlib/compress.c | |
| +++ compat/zlib/compress.c | |
| @@ -17,17 +17,12 @@ | |
| 17 | |
| 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, |
| 20 | Z_STREAM_ERROR if the level parameter is invalid. |
| 21 | */ |
| 22 | int ZEXPORT compress2(dest, destLen, source, sourceLen, level) |
| 23 | Bytef *dest; |
| 24 | uLongf *destLen; |
| 25 | const Bytef *source; |
| 26 | uLong sourceLen; |
| 27 | int level; |
| 28 | { |
| 29 | z_stream stream; |
| 30 | int err; |
| 31 | const uInt max = (uInt)-1; |
| 32 | uLong left; |
| 33 | |
| @@ -63,24 +58,18 @@ | |
| 63 | return err == Z_STREAM_END ? Z_OK : err; |
| 64 | } |
| 65 | |
| 66 | /* =========================================================================== |
| 67 | */ |
| 68 | int ZEXPORT compress(dest, destLen, source, sourceLen) |
| 69 | Bytef *dest; |
| 70 | uLongf *destLen; |
| 71 | const Bytef *source; |
| 72 | uLong sourceLen; |
| 73 | { |
| 74 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); |
| 75 | } |
| 76 | |
| 77 | /* =========================================================================== |
| 78 | If the default memLevel or windowBits for deflateInit() is changed, then |
| 79 | this function needs to be updated. |
| 80 | */ |
| 81 | uLong ZEXPORT compressBound(sourceLen) |
| 82 | uLong sourceLen; |
| 83 | { |
| 84 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + |
| 85 | (sourceLen >> 25) + 13; |
| 86 | } |
| 87 |
| --- compat/zlib/compress.c | |
| +++ compat/zlib/compress.c | |
| @@ -17,17 +17,12 @@ | |
| 17 | |
| 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, |
| 20 | Z_STREAM_ERROR if the level parameter is invalid. |
| 21 | */ |
| 22 | int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, |
| 23 | uLong sourceLen, int level) { |
| 24 | z_stream stream; |
| 25 | int err; |
| 26 | const uInt max = (uInt)-1; |
| 27 | uLong left; |
| 28 | |
| @@ -63,24 +58,18 @@ | |
| 58 | return err == Z_STREAM_END ? Z_OK : err; |
| 59 | } |
| 60 | |
| 61 | /* =========================================================================== |
| 62 | */ |
| 63 | int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, |
| 64 | uLong sourceLen) { |
| 65 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); |
| 66 | } |
| 67 | |
| 68 | /* =========================================================================== |
| 69 | If the default memLevel or windowBits for deflateInit() is changed, then |
| 70 | this function needs to be updated. |
| 71 | */ |
| 72 | uLong ZEXPORT compressBound(uLong sourceLen) { |
| 73 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + |
| 74 | (sourceLen >> 25) + 13; |
| 75 | } |
| 76 |
+16
-10
| --- compat/zlib/configure | ||
| +++ compat/zlib/configure | ||
| @@ -42,12 +42,10 @@ | ||
| 42 | 42 | # destination name for static library |
| 43 | 43 | STATICLIB=libz.a |
| 44 | 44 | |
| 45 | 45 | # extract zlib version numbers from zlib.h |
| 46 | 46 | VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h` |
| 47 | -VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h` | |
| 48 | -VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h` | |
| 49 | 47 | VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h` |
| 50 | 48 | |
| 51 | 49 | # establish commands for library building |
| 52 | 50 | if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then |
| 53 | 51 | AR=${AR-"${CROSS_PREFIX}ar"} |
| @@ -88,11 +86,12 @@ | ||
| 88 | 86 | zconst=0 |
| 89 | 87 | build64=0 |
| 90 | 88 | gcc=0 |
| 91 | 89 | warn=0 |
| 92 | 90 | debug=0 |
| 93 | -sanitize=0 | |
| 91 | +address=0 | |
| 92 | +memory=0 | |
| 94 | 93 | old_cc="$CC" |
| 95 | 94 | old_cflags="$CFLAGS" |
| 96 | 95 | OBJC='$(OBJZ) $(OBJG)' |
| 97 | 96 | PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)' |
| 98 | 97 | |
| @@ -100,11 +99,11 @@ | ||
| 100 | 99 | leave() |
| 101 | 100 | { |
| 102 | 101 | if test "$*" != "0"; then |
| 103 | 102 | echo "** $0 aborting." | tee -a configure.log |
| 104 | 103 | fi |
| 105 | - rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version | |
| 104 | + rm -rf $test.[co] $test $test$shared_ext $test.gcno $test.dSYM ./--version | |
| 106 | 105 | echo -------------------- >> configure.log |
| 107 | 106 | echo >> configure.log |
| 108 | 107 | echo >> configure.log |
| 109 | 108 | exit $1 |
| 110 | 109 | } |
| @@ -139,11 +138,13 @@ | ||
| 139 | 138 | --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;; |
| 140 | 139 | --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;; |
| 141 | 140 | -c* | --const) zconst=1; shift ;; |
| 142 | 141 | -w* | --warn) warn=1; shift ;; |
| 143 | 142 | -d* | --debug) debug=1; shift ;; |
| 144 | - --sanitize) sanitize=1; shift ;; | |
| 143 | + --sanitize) address=1; shift ;; | |
| 144 | + --address) address=1; shift ;; | |
| 145 | + --memory) memory=1; shift ;; | |
| 145 | 146 | *) |
| 146 | 147 | echo "unknown option: $1" | tee -a configure.log |
| 147 | 148 | echo "$0 --help for help" | tee -a configure.log |
| 148 | 149 | leave 1;; |
| 149 | 150 | esac |
| @@ -209,12 +210,15 @@ | ||
| 209 | 210 | CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -DZLIB_CONST" |
| 210 | 211 | else |
| 211 | 212 | CFLAGS="${CFLAGS} -Wall -Wextra" |
| 212 | 213 | fi |
| 213 | 214 | fi |
| 214 | - if test $sanitize -eq 1; then | |
| 215 | - CFLAGS="${CFLAGS} -g -fsanitize=address" | |
| 215 | + if test $address -eq 1; then | |
| 216 | + CFLAGS="${CFLAGS} -g -fsanitize=address -fno-omit-frame-pointer" | |
| 217 | + fi | |
| 218 | + if test $memory -eq 1; then | |
| 219 | + CFLAGS="${CFLAGS} -g -fsanitize=memory -fno-omit-frame-pointer" | |
| 216 | 220 | fi |
| 217 | 221 | if test $debug -eq 1; then |
| 218 | 222 | CFLAGS="${CFLAGS} -DZLIB_DEBUG" |
| 219 | 223 | SFLAGS="${SFLAGS} -DZLIB_DEBUG" |
| 220 | 224 | fi |
| @@ -257,12 +261,14 @@ | ||
| 257 | 261 | Darwin* | darwin* | *-darwin*) |
| 258 | 262 | shared_ext='.dylib' |
| 259 | 263 | SHAREDLIB=libz$shared_ext |
| 260 | 264 | SHAREDLIBV=libz.$VER$shared_ext |
| 261 | 265 | SHAREDLIBM=libz.$VER1$shared_ext |
| 262 | - LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} | |
| 263 | - if libtool -V 2>&1 | grep Apple > /dev/null; then | |
| 266 | + LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER"} | |
| 267 | + if "${CROSS_PREFIX}libtool" -V 2>&1 | grep Apple > /dev/null; then | |
| 268 | + AR="${CROSS_PREFIX}libtool" | |
| 269 | + elif libtool -V 2>&1 | grep Apple > /dev/null; then | |
| 264 | 270 | AR="libtool" |
| 265 | 271 | else |
| 266 | 272 | AR="/usr/bin/libtool" |
| 267 | 273 | fi |
| 268 | 274 | ARFLAGS="-o" ;; |
| @@ -858,11 +864,11 @@ | ||
| 858 | 864 | echo mandir = $mandir >> configure.log |
| 859 | 865 | echo prefix = $prefix >> configure.log |
| 860 | 866 | echo sharedlibdir = $sharedlibdir >> configure.log |
| 861 | 867 | echo uname = $uname >> configure.log |
| 862 | 868 | |
| 863 | -# udpate Makefile with the configure results | |
| 869 | +# update Makefile with the configure results | |
| 864 | 870 | sed < ${SRCDIR}Makefile.in " |
| 865 | 871 | /^CC *=/s#=.*#=$CC# |
| 866 | 872 | /^CFLAGS *=/s#=.*#=$CFLAGS# |
| 867 | 873 | /^SFLAGS *=/s#=.*#=$SFLAGS# |
| 868 | 874 | /^LDFLAGS *=/s#=.*#=$LDFLAGS# |
| 869 | 875 |
| --- compat/zlib/configure | |
| +++ compat/zlib/configure | |
| @@ -42,12 +42,10 @@ | |
| 42 | # destination name for static library |
| 43 | STATICLIB=libz.a |
| 44 | |
| 45 | # extract zlib version numbers from zlib.h |
| 46 | VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h` |
| 47 | VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h` |
| 48 | VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h` |
| 49 | VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h` |
| 50 | |
| 51 | # establish commands for library building |
| 52 | if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then |
| 53 | AR=${AR-"${CROSS_PREFIX}ar"} |
| @@ -88,11 +86,12 @@ | |
| 88 | zconst=0 |
| 89 | build64=0 |
| 90 | gcc=0 |
| 91 | warn=0 |
| 92 | debug=0 |
| 93 | sanitize=0 |
| 94 | old_cc="$CC" |
| 95 | old_cflags="$CFLAGS" |
| 96 | OBJC='$(OBJZ) $(OBJG)' |
| 97 | PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)' |
| 98 | |
| @@ -100,11 +99,11 @@ | |
| 100 | leave() |
| 101 | { |
| 102 | if test "$*" != "0"; then |
| 103 | echo "** $0 aborting." | tee -a configure.log |
| 104 | fi |
| 105 | rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version |
| 106 | echo -------------------- >> configure.log |
| 107 | echo >> configure.log |
| 108 | echo >> configure.log |
| 109 | exit $1 |
| 110 | } |
| @@ -139,11 +138,13 @@ | |
| 139 | --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;; |
| 140 | --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;; |
| 141 | -c* | --const) zconst=1; shift ;; |
| 142 | -w* | --warn) warn=1; shift ;; |
| 143 | -d* | --debug) debug=1; shift ;; |
| 144 | --sanitize) sanitize=1; shift ;; |
| 145 | *) |
| 146 | echo "unknown option: $1" | tee -a configure.log |
| 147 | echo "$0 --help for help" | tee -a configure.log |
| 148 | leave 1;; |
| 149 | esac |
| @@ -209,12 +210,15 @@ | |
| 209 | CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -DZLIB_CONST" |
| 210 | else |
| 211 | CFLAGS="${CFLAGS} -Wall -Wextra" |
| 212 | fi |
| 213 | fi |
| 214 | if test $sanitize -eq 1; then |
| 215 | CFLAGS="${CFLAGS} -g -fsanitize=address" |
| 216 | fi |
| 217 | if test $debug -eq 1; then |
| 218 | CFLAGS="${CFLAGS} -DZLIB_DEBUG" |
| 219 | SFLAGS="${SFLAGS} -DZLIB_DEBUG" |
| 220 | fi |
| @@ -257,12 +261,14 @@ | |
| 257 | Darwin* | darwin* | *-darwin*) |
| 258 | shared_ext='.dylib' |
| 259 | SHAREDLIB=libz$shared_ext |
| 260 | SHAREDLIBV=libz.$VER$shared_ext |
| 261 | SHAREDLIBM=libz.$VER1$shared_ext |
| 262 | LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"} |
| 263 | if libtool -V 2>&1 | grep Apple > /dev/null; then |
| 264 | AR="libtool" |
| 265 | else |
| 266 | AR="/usr/bin/libtool" |
| 267 | fi |
| 268 | ARFLAGS="-o" ;; |
| @@ -858,11 +864,11 @@ | |
| 858 | echo mandir = $mandir >> configure.log |
| 859 | echo prefix = $prefix >> configure.log |
| 860 | echo sharedlibdir = $sharedlibdir >> configure.log |
| 861 | echo uname = $uname >> configure.log |
| 862 | |
| 863 | # udpate Makefile with the configure results |
| 864 | sed < ${SRCDIR}Makefile.in " |
| 865 | /^CC *=/s#=.*#=$CC# |
| 866 | /^CFLAGS *=/s#=.*#=$CFLAGS# |
| 867 | /^SFLAGS *=/s#=.*#=$SFLAGS# |
| 868 | /^LDFLAGS *=/s#=.*#=$LDFLAGS# |
| 869 |
| --- compat/zlib/configure | |
| +++ compat/zlib/configure | |
| @@ -42,12 +42,10 @@ | |
| 42 | # destination name for static library |
| 43 | STATICLIB=libz.a |
| 44 | |
| 45 | # extract zlib version numbers from zlib.h |
| 46 | VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h` |
| 47 | VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h` |
| 48 | |
| 49 | # establish commands for library building |
| 50 | if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then |
| 51 | AR=${AR-"${CROSS_PREFIX}ar"} |
| @@ -88,11 +86,12 @@ | |
| 86 | zconst=0 |
| 87 | build64=0 |
| 88 | gcc=0 |
| 89 | warn=0 |
| 90 | debug=0 |
| 91 | address=0 |
| 92 | memory=0 |
| 93 | old_cc="$CC" |
| 94 | old_cflags="$CFLAGS" |
| 95 | OBJC='$(OBJZ) $(OBJG)' |
| 96 | PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)' |
| 97 | |
| @@ -100,11 +99,11 @@ | |
| 99 | leave() |
| 100 | { |
| 101 | if test "$*" != "0"; then |
| 102 | echo "** $0 aborting." | tee -a configure.log |
| 103 | fi |
| 104 | rm -rf $test.[co] $test $test$shared_ext $test.gcno $test.dSYM ./--version |
| 105 | echo -------------------- >> configure.log |
| 106 | echo >> configure.log |
| 107 | echo >> configure.log |
| 108 | exit $1 |
| 109 | } |
| @@ -139,11 +138,13 @@ | |
| 138 | --sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;; |
| 139 | --localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;; |
| 140 | -c* | --const) zconst=1; shift ;; |
| 141 | -w* | --warn) warn=1; shift ;; |
| 142 | -d* | --debug) debug=1; shift ;; |
| 143 | --sanitize) address=1; shift ;; |
| 144 | --address) address=1; shift ;; |
| 145 | --memory) memory=1; shift ;; |
| 146 | *) |
| 147 | echo "unknown option: $1" | tee -a configure.log |
| 148 | echo "$0 --help for help" | tee -a configure.log |
| 149 | leave 1;; |
| 150 | esac |
| @@ -209,12 +210,15 @@ | |
| 210 | CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -DZLIB_CONST" |
| 211 | else |
| 212 | CFLAGS="${CFLAGS} -Wall -Wextra" |
| 213 | fi |
| 214 | fi |
| 215 | if test $address -eq 1; then |
| 216 | CFLAGS="${CFLAGS} -g -fsanitize=address -fno-omit-frame-pointer" |
| 217 | fi |
| 218 | if test $memory -eq 1; then |
| 219 | CFLAGS="${CFLAGS} -g -fsanitize=memory -fno-omit-frame-pointer" |
| 220 | fi |
| 221 | if test $debug -eq 1; then |
| 222 | CFLAGS="${CFLAGS} -DZLIB_DEBUG" |
| 223 | SFLAGS="${SFLAGS} -DZLIB_DEBUG" |
| 224 | fi |
| @@ -257,12 +261,14 @@ | |
| 261 | Darwin* | darwin* | *-darwin*) |
| 262 | shared_ext='.dylib' |
| 263 | SHAREDLIB=libz$shared_ext |
| 264 | SHAREDLIBV=libz.$VER$shared_ext |
| 265 | SHAREDLIBM=libz.$VER1$shared_ext |
| 266 | LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER"} |
| 267 | if "${CROSS_PREFIX}libtool" -V 2>&1 | grep Apple > /dev/null; then |
| 268 | AR="${CROSS_PREFIX}libtool" |
| 269 | elif libtool -V 2>&1 | grep Apple > /dev/null; then |
| 270 | AR="libtool" |
| 271 | else |
| 272 | AR="/usr/bin/libtool" |
| 273 | fi |
| 274 | ARFLAGS="-o" ;; |
| @@ -858,11 +864,11 @@ | |
| 864 | echo mandir = $mandir >> configure.log |
| 865 | echo prefix = $prefix >> configure.log |
| 866 | echo sharedlibdir = $sharedlibdir >> configure.log |
| 867 | echo uname = $uname >> configure.log |
| 868 | |
| 869 | # update Makefile with the configure results |
| 870 | sed < ${SRCDIR}Makefile.in " |
| 871 | /^CC *=/s#=.*#=$CC# |
| 872 | /^CFLAGS *=/s#=.*#=$CFLAGS# |
| 873 | /^SFLAGS *=/s#=.*#=$SFLAGS# |
| 874 | /^LDFLAGS *=/s#=.*#=$LDFLAGS# |
| 875 |
| --- compat/zlib/contrib/delphi/ZLib.pas | ||
| +++ compat/zlib/contrib/delphi/ZLib.pas | ||
| @@ -150,11 +150,11 @@ | ||
| 150 | 150 | BufSize = number of bytes in OutBuf } |
| 151 | 151 | procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer; |
| 152 | 152 | const OutBuf: Pointer; BufSize: Integer); |
| 153 | 153 | |
| 154 | 154 | const |
| 155 | - zlib_version = '1.2.13'; | |
| 155 | + zlib_version = '1.3.0'; | |
| 156 | 156 | |
| 157 | 157 | type |
| 158 | 158 | EZlibError = class(Exception); |
| 159 | 159 | ECompressionError = class(EZlibError); |
| 160 | 160 | EDecompressionError = class(EZlibError); |
| 161 | 161 |
| --- compat/zlib/contrib/delphi/ZLib.pas | |
| +++ compat/zlib/contrib/delphi/ZLib.pas | |
| @@ -150,11 +150,11 @@ | |
| 150 | BufSize = number of bytes in OutBuf } |
| 151 | procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer; |
| 152 | const OutBuf: Pointer; BufSize: Integer); |
| 153 | |
| 154 | const |
| 155 | zlib_version = '1.2.13'; |
| 156 | |
| 157 | type |
| 158 | EZlibError = class(Exception); |
| 159 | ECompressionError = class(EZlibError); |
| 160 | EDecompressionError = class(EZlibError); |
| 161 |
| --- compat/zlib/contrib/delphi/ZLib.pas | |
| +++ compat/zlib/contrib/delphi/ZLib.pas | |
| @@ -150,11 +150,11 @@ | |
| 150 | BufSize = number of bytes in OutBuf } |
| 151 | procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer; |
| 152 | const OutBuf: Pointer; BufSize: Integer); |
| 153 | |
| 154 | const |
| 155 | zlib_version = '1.3.0'; |
| 156 | |
| 157 | type |
| 158 | EZlibError = class(Exception); |
| 159 | ECompressionError = class(EZlibError); |
| 160 | EDecompressionError = class(EZlibError); |
| 161 |
| --- compat/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs | ||
| +++ compat/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs | ||
| @@ -59,11 +59,11 @@ | ||
| 59 | 59 | /// <param name="offset">Where in <c>data</c> to start updating</param> |
| 60 | 60 | /// <param name="count">The number of bytes from <c>data</c> to use</param> |
| 61 | 61 | /// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception> |
| 62 | 62 | /// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception> |
| 63 | 63 | /// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception> |
| 64 | - /// <remarks>All the other <c>Update</c> methods are implmeneted in terms of this one. | |
| 64 | + /// <remarks>All the other <c>Update</c> methods are implemented in terms of this one. | |
| 65 | 65 | /// This is therefore the only method a derived class has to implement</remarks> |
| 66 | 66 | public abstract void Update(byte[] data, int offset, int count); |
| 67 | 67 | |
| 68 | 68 | /// <summary> |
| 69 | 69 | /// Updates the current checksum with an array of bytes. |
| 70 | 70 |
| --- compat/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs | |
| +++ compat/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs | |
| @@ -59,11 +59,11 @@ | |
| 59 | /// <param name="offset">Where in <c>data</c> to start updating</param> |
| 60 | /// <param name="count">The number of bytes from <c>data</c> to use</param> |
| 61 | /// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception> |
| 62 | /// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception> |
| 63 | /// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception> |
| 64 | /// <remarks>All the other <c>Update</c> methods are implmeneted in terms of this one. |
| 65 | /// This is therefore the only method a derived class has to implement</remarks> |
| 66 | public abstract void Update(byte[] data, int offset, int count); |
| 67 | |
| 68 | /// <summary> |
| 69 | /// Updates the current checksum with an array of bytes. |
| 70 |
| --- compat/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs | |
| +++ compat/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs | |
| @@ -59,11 +59,11 @@ | |
| 59 | /// <param name="offset">Where in <c>data</c> to start updating</param> |
| 60 | /// <param name="count">The number of bytes from <c>data</c> to use</param> |
| 61 | /// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception> |
| 62 | /// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception> |
| 63 | /// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception> |
| 64 | /// <remarks>All the other <c>Update</c> methods are implemented in terms of this one. |
| 65 | /// This is therefore the only method a derived class has to implement</remarks> |
| 66 | public abstract void Update(byte[] data, int offset, int count); |
| 67 | |
| 68 | /// <summary> |
| 69 | /// Updates the current checksum with an array of bytes. |
| 70 |
| --- compat/zlib/contrib/dotzlib/DotZLib/CodecBase.cs | ||
| +++ compat/zlib/contrib/dotzlib/DotZLib/CodecBase.cs | ||
| @@ -137,11 +137,11 @@ | ||
| 137 | 137 | /// Performs any codec specific cleanup |
| 138 | 138 | /// </summary> |
| 139 | 139 | /// <remarks>This must be implemented by a derived class</remarks> |
| 140 | 140 | protected abstract void CleanUp(); |
| 141 | 141 | |
| 142 | - // performs the release of the handles and calls the dereived CleanUp() | |
| 142 | + // performs the release of the handles and calls the derived CleanUp() | |
| 143 | 143 | private void CleanUp(bool isDisposing) |
| 144 | 144 | { |
| 145 | 145 | if (!_isDisposed) |
| 146 | 146 | { |
| 147 | 147 | CleanUp(); |
| @@ -158,11 +158,11 @@ | ||
| 158 | 158 | #endregion |
| 159 | 159 | |
| 160 | 160 | #region Helper methods |
| 161 | 161 | |
| 162 | 162 | /// <summary> |
| 163 | - /// Copies a number of bytes to the internal codec buffer - ready for proccesing | |
| 163 | + /// Copies a number of bytes to the internal codec buffer - ready for processing | |
| 164 | 164 | /// </summary> |
| 165 | 165 | /// <param name="data">The byte array that contains the data to copy</param> |
| 166 | 166 | /// <param name="startIndex">The index of the first byte to copy</param> |
| 167 | 167 | /// <param name="count">The number of bytes to copy from <c>data</c></param> |
| 168 | 168 | protected void copyInput(byte[] data, int startIndex, int count) |
| 169 | 169 |
| --- compat/zlib/contrib/dotzlib/DotZLib/CodecBase.cs | |
| +++ compat/zlib/contrib/dotzlib/DotZLib/CodecBase.cs | |
| @@ -137,11 +137,11 @@ | |
| 137 | /// Performs any codec specific cleanup |
| 138 | /// </summary> |
| 139 | /// <remarks>This must be implemented by a derived class</remarks> |
| 140 | protected abstract void CleanUp(); |
| 141 | |
| 142 | // performs the release of the handles and calls the dereived CleanUp() |
| 143 | private void CleanUp(bool isDisposing) |
| 144 | { |
| 145 | if (!_isDisposed) |
| 146 | { |
| 147 | CleanUp(); |
| @@ -158,11 +158,11 @@ | |
| 158 | #endregion |
| 159 | |
| 160 | #region Helper methods |
| 161 | |
| 162 | /// <summary> |
| 163 | /// Copies a number of bytes to the internal codec buffer - ready for proccesing |
| 164 | /// </summary> |
| 165 | /// <param name="data">The byte array that contains the data to copy</param> |
| 166 | /// <param name="startIndex">The index of the first byte to copy</param> |
| 167 | /// <param name="count">The number of bytes to copy from <c>data</c></param> |
| 168 | protected void copyInput(byte[] data, int startIndex, int count) |
| 169 |
| --- compat/zlib/contrib/dotzlib/DotZLib/CodecBase.cs | |
| +++ compat/zlib/contrib/dotzlib/DotZLib/CodecBase.cs | |
| @@ -137,11 +137,11 @@ | |
| 137 | /// Performs any codec specific cleanup |
| 138 | /// </summary> |
| 139 | /// <remarks>This must be implemented by a derived class</remarks> |
| 140 | protected abstract void CleanUp(); |
| 141 | |
| 142 | // performs the release of the handles and calls the derived CleanUp() |
| 143 | private void CleanUp(bool isDisposing) |
| 144 | { |
| 145 | if (!_isDisposed) |
| 146 | { |
| 147 | CleanUp(); |
| @@ -158,11 +158,11 @@ | |
| 158 | #endregion |
| 159 | |
| 160 | #region Helper methods |
| 161 | |
| 162 | /// <summary> |
| 163 | /// Copies a number of bytes to the internal codec buffer - ready for processing |
| 164 | /// </summary> |
| 165 | /// <param name="data">The byte array that contains the data to copy</param> |
| 166 | /// <param name="startIndex">The index of the first byte to copy</param> |
| 167 | /// <param name="count">The number of bytes to copy from <c>data</c></param> |
| 168 | protected void copyInput(byte[] data, int startIndex, int count) |
| 169 |
| --- compat/zlib/contrib/dotzlib/DotZLib/GZipStream.cs | ||
| +++ compat/zlib/contrib/dotzlib/DotZLib/GZipStream.cs | ||
| @@ -244,11 +244,11 @@ | ||
| 244 | 244 | { |
| 245 | 245 | throw new NotSupportedException(); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /// <summary> |
| 249 | - /// Not suppported. | |
| 249 | + /// Not supported. | |
| 250 | 250 | /// </summary> |
| 251 | 251 | /// <param name="offset"></param> |
| 252 | 252 | /// <param name="origin"></param> |
| 253 | 253 | /// <returns></returns> |
| 254 | 254 | /// <exception cref="NotSupportedException">Always thrown</exception> |
| @@ -266,11 +266,11 @@ | ||
| 266 | 266 | { |
| 267 | 267 | // left empty on purpose |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /// <summary> |
| 271 | - /// Gets/sets the current position in the <c>GZipStream</c>. Not suppported. | |
| 271 | + /// Gets/sets the current position in the <c>GZipStream</c>. Not supported. | |
| 272 | 272 | /// </summary> |
| 273 | 273 | /// <remarks>In this implementation this property is not supported</remarks> |
| 274 | 274 | /// <exception cref="NotSupportedException">Always thrown</exception> |
| 275 | 275 | public override long Position |
| 276 | 276 | { |
| @@ -283,11 +283,11 @@ | ||
| 283 | 283 | throw new NotSupportedException(); |
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | /// <summary> |
| 288 | - /// Gets the size of the stream. Not suppported. | |
| 288 | + /// Gets the size of the stream. Not supported. | |
| 289 | 289 | /// </summary> |
| 290 | 290 | /// <remarks>In this implementation this property is not supported</remarks> |
| 291 | 291 | /// <exception cref="NotSupportedException">Always thrown</exception> |
| 292 | 292 | public override long Length |
| 293 | 293 | { |
| 294 | 294 |
| --- compat/zlib/contrib/dotzlib/DotZLib/GZipStream.cs | |
| +++ compat/zlib/contrib/dotzlib/DotZLib/GZipStream.cs | |
| @@ -244,11 +244,11 @@ | |
| 244 | { |
| 245 | throw new NotSupportedException(); |
| 246 | } |
| 247 | |
| 248 | /// <summary> |
| 249 | /// Not suppported. |
| 250 | /// </summary> |
| 251 | /// <param name="offset"></param> |
| 252 | /// <param name="origin"></param> |
| 253 | /// <returns></returns> |
| 254 | /// <exception cref="NotSupportedException">Always thrown</exception> |
| @@ -266,11 +266,11 @@ | |
| 266 | { |
| 267 | // left empty on purpose |
| 268 | } |
| 269 | |
| 270 | /// <summary> |
| 271 | /// Gets/sets the current position in the <c>GZipStream</c>. Not suppported. |
| 272 | /// </summary> |
| 273 | /// <remarks>In this implementation this property is not supported</remarks> |
| 274 | /// <exception cref="NotSupportedException">Always thrown</exception> |
| 275 | public override long Position |
| 276 | { |
| @@ -283,11 +283,11 @@ | |
| 283 | throw new NotSupportedException(); |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | /// <summary> |
| 288 | /// Gets the size of the stream. Not suppported. |
| 289 | /// </summary> |
| 290 | /// <remarks>In this implementation this property is not supported</remarks> |
| 291 | /// <exception cref="NotSupportedException">Always thrown</exception> |
| 292 | public override long Length |
| 293 | { |
| 294 |
| --- compat/zlib/contrib/dotzlib/DotZLib/GZipStream.cs | |
| +++ compat/zlib/contrib/dotzlib/DotZLib/GZipStream.cs | |
| @@ -244,11 +244,11 @@ | |
| 244 | { |
| 245 | throw new NotSupportedException(); |
| 246 | } |
| 247 | |
| 248 | /// <summary> |
| 249 | /// Not supported. |
| 250 | /// </summary> |
| 251 | /// <param name="offset"></param> |
| 252 | /// <param name="origin"></param> |
| 253 | /// <returns></returns> |
| 254 | /// <exception cref="NotSupportedException">Always thrown</exception> |
| @@ -266,11 +266,11 @@ | |
| 266 | { |
| 267 | // left empty on purpose |
| 268 | } |
| 269 | |
| 270 | /// <summary> |
| 271 | /// Gets/sets the current position in the <c>GZipStream</c>. Not supported. |
| 272 | /// </summary> |
| 273 | /// <remarks>In this implementation this property is not supported</remarks> |
| 274 | /// <exception cref="NotSupportedException">Always thrown</exception> |
| 275 | public override long Position |
| 276 | { |
| @@ -283,11 +283,11 @@ | |
| 283 | throw new NotSupportedException(); |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | /// <summary> |
| 288 | /// Gets the size of the stream. Not supported. |
| 289 | /// </summary> |
| 290 | /// <remarks>In this implementation this property is not supported</remarks> |
| 291 | /// <exception cref="NotSupportedException">Always thrown</exception> |
| 292 | public override long Length |
| 293 | { |
| 294 |
| --- compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs | ||
| +++ compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs | ||
| @@ -154,11 +154,11 @@ | ||
| 154 | 154 | #region Info tests |
| 155 | 155 | [Test] |
| 156 | 156 | public void Info_Version() |
| 157 | 157 | { |
| 158 | 158 | Info info = new Info(); |
| 159 | - Assert.AreEqual("1.2.13", Info.Version); | |
| 159 | + Assert.AreEqual("1.3.0", Info.Version); | |
| 160 | 160 | Assert.AreEqual(32, info.SizeOfUInt); |
| 161 | 161 | Assert.AreEqual(32, info.SizeOfULong); |
| 162 | 162 | Assert.AreEqual(32, info.SizeOfPointer); |
| 163 | 163 | Assert.AreEqual(32, info.SizeOfOffset); |
| 164 | 164 | } |
| 165 | 165 |
| --- compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs | |
| +++ compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs | |
| @@ -154,11 +154,11 @@ | |
| 154 | #region Info tests |
| 155 | [Test] |
| 156 | public void Info_Version() |
| 157 | { |
| 158 | Info info = new Info(); |
| 159 | Assert.AreEqual("1.2.13", Info.Version); |
| 160 | Assert.AreEqual(32, info.SizeOfUInt); |
| 161 | Assert.AreEqual(32, info.SizeOfULong); |
| 162 | Assert.AreEqual(32, info.SizeOfPointer); |
| 163 | Assert.AreEqual(32, info.SizeOfOffset); |
| 164 | } |
| 165 |
| --- compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs | |
| +++ compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs | |
| @@ -154,11 +154,11 @@ | |
| 154 | #region Info tests |
| 155 | [Test] |
| 156 | public void Info_Version() |
| 157 | { |
| 158 | Info info = new Info(); |
| 159 | Assert.AreEqual("1.3.0", Info.Version); |
| 160 | Assert.AreEqual(32, info.SizeOfUInt); |
| 161 | Assert.AreEqual(32, info.SizeOfULong); |
| 162 | Assert.AreEqual(32, info.SizeOfPointer); |
| 163 | Assert.AreEqual(32, info.SizeOfOffset); |
| 164 | } |
| 165 |
| --- compat/zlib/contrib/dotzlib/readme.txt | ||
| +++ compat/zlib/contrib/dotzlib/readme.txt | ||
| @@ -34,11 +34,11 @@ | ||
| 34 | 34 | 2. Using NAnt: |
| 35 | 35 | Open a command prompt with access to the build environment and run nant |
| 36 | 36 | in the same directory as the DotZLib.build file. |
| 37 | 37 | You can define 2 properties on the nant command-line to control the build: |
| 38 | 38 | debug={true|false} to toggle between release/debug builds (default=true). |
| 39 | - nunit={true|false} to include or esclude unit tests (default=true). | |
| 39 | + nunit={true|false} to include or exclude unit tests (default=true). | |
| 40 | 40 | Also the target clean will remove binaries. |
| 41 | 41 | Output file (DotZLib.dll) will be found in either ./DotZLib/bin/release |
| 42 | 42 | or ./DotZLib/bin/debug, depending on whether you are building the release |
| 43 | 43 | or debug version of the library. |
| 44 | 44 | |
| 45 | 45 |
| --- compat/zlib/contrib/dotzlib/readme.txt | |
| +++ compat/zlib/contrib/dotzlib/readme.txt | |
| @@ -34,11 +34,11 @@ | |
| 34 | 2. Using NAnt: |
| 35 | Open a command prompt with access to the build environment and run nant |
| 36 | in the same directory as the DotZLib.build file. |
| 37 | You can define 2 properties on the nant command-line to control the build: |
| 38 | debug={true|false} to toggle between release/debug builds (default=true). |
| 39 | nunit={true|false} to include or esclude unit tests (default=true). |
| 40 | Also the target clean will remove binaries. |
| 41 | Output file (DotZLib.dll) will be found in either ./DotZLib/bin/release |
| 42 | or ./DotZLib/bin/debug, depending on whether you are building the release |
| 43 | or debug version of the library. |
| 44 | |
| 45 |
| --- compat/zlib/contrib/dotzlib/readme.txt | |
| +++ compat/zlib/contrib/dotzlib/readme.txt | |
| @@ -34,11 +34,11 @@ | |
| 34 | 2. Using NAnt: |
| 35 | Open a command prompt with access to the build environment and run nant |
| 36 | in the same directory as the DotZLib.build file. |
| 37 | You can define 2 properties on the nant command-line to control the build: |
| 38 | debug={true|false} to toggle between release/debug builds (default=true). |
| 39 | nunit={true|false} to include or exclude unit tests (default=true). |
| 40 | Also the target clean will remove binaries. |
| 41 | Output file (DotZLib.dll) will be found in either ./DotZLib/bin/release |
| 42 | or ./DotZLib/bin/debug, depending on whether you are building the release |
| 43 | or debug version of the library. |
| 44 | |
| 45 |
| --- compat/zlib/contrib/infback9/infback9.c | ||
| +++ compat/zlib/contrib/infback9/infback9.c | ||
| @@ -14,16 +14,12 @@ | ||
| 14 | 14 | strm provides memory allocation functions in zalloc and zfree, or |
| 15 | 15 | Z_NULL to use the library memory allocation functions. |
| 16 | 16 | |
| 17 | 17 | window is a user-supplied window and output buffer that is 64K bytes. |
| 18 | 18 | */ |
| 19 | -int ZEXPORT inflateBack9Init_(strm, window, version, stream_size) | |
| 20 | -z_stream FAR *strm; | |
| 21 | -unsigned char FAR *window; | |
| 22 | -const char *version; | |
| 23 | -int stream_size; | |
| 24 | -{ | |
| 19 | +int ZEXPORT inflateBack9Init_(z_stream FAR *strm, unsigned char FAR *window, | |
| 20 | + const char *version, int stream_size) { | |
| 25 | 21 | struct inflate_state FAR *state; |
| 26 | 22 | |
| 27 | 23 | if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || |
| 28 | 24 | stream_size != (int)(sizeof(z_stream))) |
| 29 | 25 | return Z_VERSION_ERROR; |
| @@ -49,12 +45,11 @@ | ||
| 49 | 45 | decoding. |
| 50 | 46 | */ |
| 51 | 47 | #ifdef MAKEFIXED |
| 52 | 48 | #include <stdio.h> |
| 53 | 49 | |
| 54 | -void makefixed9(void) | |
| 55 | -{ | |
| 50 | +void makefixed9(void) { | |
| 56 | 51 | unsigned sym, bits, low, size; |
| 57 | 52 | code *next, *lenfix, *distfix; |
| 58 | 53 | struct inflate_state state; |
| 59 | 54 | code fixed[544]; |
| 60 | 55 | |
| @@ -212,17 +207,12 @@ | ||
| 212 | 207 | returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format |
| 213 | 208 | error, or Z_MEM_ERROR if it could not allocate memory for the state. |
| 214 | 209 | inflateBack() can also return Z_STREAM_ERROR if the input parameters |
| 215 | 210 | are not correct, i.e. strm is Z_NULL or the state was not initialized. |
| 216 | 211 | */ |
| 217 | -int ZEXPORT inflateBack9(strm, in, in_desc, out, out_desc) | |
| 218 | -z_stream FAR *strm; | |
| 219 | -in_func in; | |
| 220 | -void FAR *in_desc; | |
| 221 | -out_func out; | |
| 222 | -void FAR *out_desc; | |
| 223 | -{ | |
| 212 | +int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc, | |
| 213 | + out_func out, void FAR *out_desc) { | |
| 224 | 214 | struct inflate_state FAR *state; |
| 225 | 215 | z_const unsigned char FAR *next; /* next input */ |
| 226 | 216 | unsigned char FAR *put; /* next output */ |
| 227 | 217 | unsigned have; /* available input */ |
| 228 | 218 | unsigned long left; /* available output */ |
| @@ -601,15 +591,13 @@ | ||
| 601 | 591 | strm->next_in = next; |
| 602 | 592 | strm->avail_in = have; |
| 603 | 593 | return ret; |
| 604 | 594 | } |
| 605 | 595 | |
| 606 | -int ZEXPORT inflateBack9End(strm) | |
| 607 | -z_stream FAR *strm; | |
| 608 | -{ | |
| 596 | +int ZEXPORT inflateBack9End(z_stream FAR *strm) { | |
| 609 | 597 | if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) |
| 610 | 598 | return Z_STREAM_ERROR; |
| 611 | 599 | ZFREE(strm, strm->state); |
| 612 | 600 | strm->state = Z_NULL; |
| 613 | 601 | Tracev((stderr, "inflate: end\n")); |
| 614 | 602 | return Z_OK; |
| 615 | 603 | } |
| 616 | 604 |
| --- compat/zlib/contrib/infback9/infback9.c | |
| +++ compat/zlib/contrib/infback9/infback9.c | |
| @@ -14,16 +14,12 @@ | |
| 14 | strm provides memory allocation functions in zalloc and zfree, or |
| 15 | Z_NULL to use the library memory allocation functions. |
| 16 | |
| 17 | window is a user-supplied window and output buffer that is 64K bytes. |
| 18 | */ |
| 19 | int ZEXPORT inflateBack9Init_(strm, window, version, stream_size) |
| 20 | z_stream FAR *strm; |
| 21 | unsigned char FAR *window; |
| 22 | const char *version; |
| 23 | int stream_size; |
| 24 | { |
| 25 | struct inflate_state FAR *state; |
| 26 | |
| 27 | if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || |
| 28 | stream_size != (int)(sizeof(z_stream))) |
| 29 | return Z_VERSION_ERROR; |
| @@ -49,12 +45,11 @@ | |
| 49 | decoding. |
| 50 | */ |
| 51 | #ifdef MAKEFIXED |
| 52 | #include <stdio.h> |
| 53 | |
| 54 | void makefixed9(void) |
| 55 | { |
| 56 | unsigned sym, bits, low, size; |
| 57 | code *next, *lenfix, *distfix; |
| 58 | struct inflate_state state; |
| 59 | code fixed[544]; |
| 60 | |
| @@ -212,17 +207,12 @@ | |
| 212 | returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format |
| 213 | error, or Z_MEM_ERROR if it could not allocate memory for the state. |
| 214 | inflateBack() can also return Z_STREAM_ERROR if the input parameters |
| 215 | are not correct, i.e. strm is Z_NULL or the state was not initialized. |
| 216 | */ |
| 217 | int ZEXPORT inflateBack9(strm, in, in_desc, out, out_desc) |
| 218 | z_stream FAR *strm; |
| 219 | in_func in; |
| 220 | void FAR *in_desc; |
| 221 | out_func out; |
| 222 | void FAR *out_desc; |
| 223 | { |
| 224 | struct inflate_state FAR *state; |
| 225 | z_const unsigned char FAR *next; /* next input */ |
| 226 | unsigned char FAR *put; /* next output */ |
| 227 | unsigned have; /* available input */ |
| 228 | unsigned long left; /* available output */ |
| @@ -601,15 +591,13 @@ | |
| 601 | strm->next_in = next; |
| 602 | strm->avail_in = have; |
| 603 | return ret; |
| 604 | } |
| 605 | |
| 606 | int ZEXPORT inflateBack9End(strm) |
| 607 | z_stream FAR *strm; |
| 608 | { |
| 609 | if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) |
| 610 | return Z_STREAM_ERROR; |
| 611 | ZFREE(strm, strm->state); |
| 612 | strm->state = Z_NULL; |
| 613 | Tracev((stderr, "inflate: end\n")); |
| 614 | return Z_OK; |
| 615 | } |
| 616 |
| --- compat/zlib/contrib/infback9/infback9.c | |
| +++ compat/zlib/contrib/infback9/infback9.c | |
| @@ -14,16 +14,12 @@ | |
| 14 | strm provides memory allocation functions in zalloc and zfree, or |
| 15 | Z_NULL to use the library memory allocation functions. |
| 16 | |
| 17 | window is a user-supplied window and output buffer that is 64K bytes. |
| 18 | */ |
| 19 | int ZEXPORT inflateBack9Init_(z_stream FAR *strm, unsigned char FAR *window, |
| 20 | const char *version, int stream_size) { |
| 21 | struct inflate_state FAR *state; |
| 22 | |
| 23 | if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || |
| 24 | stream_size != (int)(sizeof(z_stream))) |
| 25 | return Z_VERSION_ERROR; |
| @@ -49,12 +45,11 @@ | |
| 45 | decoding. |
| 46 | */ |
| 47 | #ifdef MAKEFIXED |
| 48 | #include <stdio.h> |
| 49 | |
| 50 | void makefixed9(void) { |
| 51 | unsigned sym, bits, low, size; |
| 52 | code *next, *lenfix, *distfix; |
| 53 | struct inflate_state state; |
| 54 | code fixed[544]; |
| 55 | |
| @@ -212,17 +207,12 @@ | |
| 207 | returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format |
| 208 | error, or Z_MEM_ERROR if it could not allocate memory for the state. |
| 209 | inflateBack() can also return Z_STREAM_ERROR if the input parameters |
| 210 | are not correct, i.e. strm is Z_NULL or the state was not initialized. |
| 211 | */ |
| 212 | int ZEXPORT inflateBack9(z_stream FAR *strm, in_func in, void FAR *in_desc, |
| 213 | out_func out, void FAR *out_desc) { |
| 214 | struct inflate_state FAR *state; |
| 215 | z_const unsigned char FAR *next; /* next input */ |
| 216 | unsigned char FAR *put; /* next output */ |
| 217 | unsigned have; /* available input */ |
| 218 | unsigned long left; /* available output */ |
| @@ -601,15 +591,13 @@ | |
| 591 | strm->next_in = next; |
| 592 | strm->avail_in = have; |
| 593 | return ret; |
| 594 | } |
| 595 | |
| 596 | int ZEXPORT inflateBack9End(z_stream FAR *strm) { |
| 597 | if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) |
| 598 | return Z_STREAM_ERROR; |
| 599 | ZFREE(strm, strm->state); |
| 600 | strm->state = Z_NULL; |
| 601 | Tracev((stderr, "inflate: end\n")); |
| 602 | return Z_OK; |
| 603 | } |
| 604 |
| --- compat/zlib/contrib/infback9/infback9.h | ||
| +++ compat/zlib/contrib/infback9/infback9.h | ||
| @@ -18,18 +18,18 @@ | ||
| 18 | 18 | |
| 19 | 19 | #ifdef __cplusplus |
| 20 | 20 | extern "C" { |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | -ZEXTERN int ZEXPORT inflateBack9 OF((z_stream FAR *strm, | |
| 24 | - in_func in, void FAR *in_desc, | |
| 25 | - out_func out, void FAR *out_desc)); | |
| 26 | -ZEXTERN int ZEXPORT inflateBack9End OF((z_stream FAR *strm)); | |
| 27 | -ZEXTERN int ZEXPORT inflateBack9Init_ OF((z_stream FAR *strm, | |
| 28 | - unsigned char FAR *window, | |
| 29 | - const char *version, | |
| 30 | - int stream_size)); | |
| 23 | +ZEXTERN int ZEXPORT inflateBack9(z_stream FAR *strm, | |
| 24 | + in_func in, void FAR *in_desc, | |
| 25 | + out_func out, void FAR *out_desc); | |
| 26 | +ZEXTERN int ZEXPORT inflateBack9End(z_stream FAR *strm); | |
| 27 | +ZEXTERN int ZEXPORT inflateBack9Init_(z_stream FAR *strm, | |
| 28 | + unsigned char FAR *window, | |
| 29 | + const char *version, | |
| 30 | + int stream_size); | |
| 31 | 31 | #define inflateBack9Init(strm, window) \ |
| 32 | 32 | inflateBack9Init_((strm), (window), \ |
| 33 | 33 | ZLIB_VERSION, sizeof(z_stream)) |
| 34 | 34 | |
| 35 | 35 | #ifdef __cplusplus |
| 36 | 36 |
| --- compat/zlib/contrib/infback9/infback9.h | |
| +++ compat/zlib/contrib/infback9/infback9.h | |
| @@ -18,18 +18,18 @@ | |
| 18 | |
| 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
| 23 | ZEXTERN int ZEXPORT inflateBack9 OF((z_stream FAR *strm, |
| 24 | in_func in, void FAR *in_desc, |
| 25 | out_func out, void FAR *out_desc)); |
| 26 | ZEXTERN int ZEXPORT inflateBack9End OF((z_stream FAR *strm)); |
| 27 | ZEXTERN int ZEXPORT inflateBack9Init_ OF((z_stream FAR *strm, |
| 28 | unsigned char FAR *window, |
| 29 | const char *version, |
| 30 | int stream_size)); |
| 31 | #define inflateBack9Init(strm, window) \ |
| 32 | inflateBack9Init_((strm), (window), \ |
| 33 | ZLIB_VERSION, sizeof(z_stream)) |
| 34 | |
| 35 | #ifdef __cplusplus |
| 36 |
| --- compat/zlib/contrib/infback9/infback9.h | |
| +++ compat/zlib/contrib/infback9/infback9.h | |
| @@ -18,18 +18,18 @@ | |
| 18 | |
| 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
| 23 | ZEXTERN int ZEXPORT inflateBack9(z_stream FAR *strm, |
| 24 | in_func in, void FAR *in_desc, |
| 25 | out_func out, void FAR *out_desc); |
| 26 | ZEXTERN int ZEXPORT inflateBack9End(z_stream FAR *strm); |
| 27 | ZEXTERN int ZEXPORT inflateBack9Init_(z_stream FAR *strm, |
| 28 | unsigned char FAR *window, |
| 29 | const char *version, |
| 30 | int stream_size); |
| 31 | #define inflateBack9Init(strm, window) \ |
| 32 | inflateBack9Init_((strm), (window), \ |
| 33 | ZLIB_VERSION, sizeof(z_stream)) |
| 34 | |
| 35 | #ifdef __cplusplus |
| 36 |
| --- compat/zlib/contrib/infback9/inftree9.c | ||
| +++ compat/zlib/contrib/infback9/inftree9.c | ||
| @@ -1,17 +1,17 @@ | ||
| 1 | 1 | /* inftree9.c -- generate Huffman trees for efficient decoding |
| 2 | - * Copyright (C) 1995-2022 Mark Adler | |
| 2 | + * Copyright (C) 1995-2023 Mark Adler | |
| 3 | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | #include "zutil.h" |
| 7 | 7 | #include "inftree9.h" |
| 8 | 8 | |
| 9 | 9 | #define MAXBITS 15 |
| 10 | 10 | |
| 11 | 11 | const char inflate9_copyright[] = |
| 12 | - " inflate9 1.2.13 Copyright 1995-2022 Mark Adler "; | |
| 12 | + " inflate9 1.3 Copyright 1995-2023 Mark Adler "; | |
| 13 | 13 | /* |
| 14 | 14 | If you use the zlib library in a product, an acknowledgment is welcome |
| 15 | 15 | in the documentation of your product. If for some reason you cannot |
| 16 | 16 | include such an acknowledgment, I would appreciate that you keep this |
| 17 | 17 | copyright string in the executable of your product. |
| @@ -27,18 +27,13 @@ | ||
| 27 | 27 | on return points to the next available entry's address. bits is the |
| 28 | 28 | requested root table index bits, and on return it is the actual root |
| 29 | 29 | table index bits. It will differ if the request is greater than the |
| 30 | 30 | longest code or if it is less than the shortest code. |
| 31 | 31 | */ |
| 32 | -int inflate_table9(type, lens, codes, table, bits, work) | |
| 33 | -codetype type; | |
| 34 | -unsigned short FAR *lens; | |
| 35 | -unsigned codes; | |
| 36 | -code FAR * FAR *table; | |
| 37 | -unsigned FAR *bits; | |
| 38 | -unsigned short FAR *work; | |
| 39 | -{ | |
| 32 | +int inflate_table9(codetype type, unsigned short FAR *lens, unsigned codes, | |
| 33 | + code FAR * FAR *table, unsigned FAR *bits, | |
| 34 | + unsigned short FAR *work) { | |
| 40 | 35 | unsigned len; /* a code's length in bits */ |
| 41 | 36 | unsigned sym; /* index of code symbols */ |
| 42 | 37 | unsigned min, max; /* minimum and maximum code lengths */ |
| 43 | 38 | unsigned root; /* number of index bits for root table */ |
| 44 | 39 | unsigned curr; /* number of index bits for current table */ |
| @@ -62,11 +57,11 @@ | ||
| 62 | 57 | 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, |
| 63 | 58 | 131, 163, 195, 227, 3, 0, 0}; |
| 64 | 59 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ |
| 65 | 60 | 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, |
| 66 | 61 | 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, |
| 67 | - 133, 133, 133, 133, 144, 194, 65}; | |
| 62 | + 133, 133, 133, 133, 144, 198, 203}; | |
| 68 | 63 | static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ |
| 69 | 64 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, |
| 70 | 65 | 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, |
| 71 | 66 | 4097, 6145, 8193, 12289, 16385, 24577, 32769, 49153}; |
| 72 | 67 | static const unsigned short dext[32] = { /* Distance codes 0..31 extra */ |
| 73 | 68 |
| --- compat/zlib/contrib/infback9/inftree9.c | |
| +++ compat/zlib/contrib/infback9/inftree9.c | |
| @@ -1,17 +1,17 @@ | |
| 1 | /* inftree9.c -- generate Huffman trees for efficient decoding |
| 2 | * Copyright (C) 1995-2022 Mark Adler |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ |
| 5 | |
| 6 | #include "zutil.h" |
| 7 | #include "inftree9.h" |
| 8 | |
| 9 | #define MAXBITS 15 |
| 10 | |
| 11 | const char inflate9_copyright[] = |
| 12 | " inflate9 1.2.13 Copyright 1995-2022 Mark Adler "; |
| 13 | /* |
| 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 |
| 16 | include such an acknowledgment, I would appreciate that you keep this |
| 17 | copyright string in the executable of your product. |
| @@ -27,18 +27,13 @@ | |
| 27 | on return points to the next available entry's address. bits is the |
| 28 | requested root table index bits, and on return it is the actual root |
| 29 | table index bits. It will differ if the request is greater than the |
| 30 | longest code or if it is less than the shortest code. |
| 31 | */ |
| 32 | int inflate_table9(type, lens, codes, table, bits, work) |
| 33 | codetype type; |
| 34 | unsigned short FAR *lens; |
| 35 | unsigned codes; |
| 36 | code FAR * FAR *table; |
| 37 | unsigned FAR *bits; |
| 38 | unsigned short FAR *work; |
| 39 | { |
| 40 | unsigned len; /* a code's length in bits */ |
| 41 | unsigned sym; /* index of code symbols */ |
| 42 | unsigned min, max; /* minimum and maximum code lengths */ |
| 43 | unsigned root; /* number of index bits for root table */ |
| 44 | unsigned curr; /* number of index bits for current table */ |
| @@ -62,11 +57,11 @@ | |
| 62 | 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, |
| 63 | 131, 163, 195, 227, 3, 0, 0}; |
| 64 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ |
| 65 | 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, |
| 66 | 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, |
| 67 | 133, 133, 133, 133, 144, 194, 65}; |
| 68 | static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ |
| 69 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, |
| 70 | 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, |
| 71 | 4097, 6145, 8193, 12289, 16385, 24577, 32769, 49153}; |
| 72 | static const unsigned short dext[32] = { /* Distance codes 0..31 extra */ |
| 73 |
| --- compat/zlib/contrib/infback9/inftree9.c | |
| +++ compat/zlib/contrib/infback9/inftree9.c | |
| @@ -1,17 +1,17 @@ | |
| 1 | /* inftree9.c -- generate Huffman trees for efficient decoding |
| 2 | * Copyright (C) 1995-2023 Mark Adler |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ |
| 5 | |
| 6 | #include "zutil.h" |
| 7 | #include "inftree9.h" |
| 8 | |
| 9 | #define MAXBITS 15 |
| 10 | |
| 11 | const char inflate9_copyright[] = |
| 12 | " inflate9 1.3 Copyright 1995-2023 Mark Adler "; |
| 13 | /* |
| 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 |
| 16 | include such an acknowledgment, I would appreciate that you keep this |
| 17 | copyright string in the executable of your product. |
| @@ -27,18 +27,13 @@ | |
| 27 | on return points to the next available entry's address. bits is the |
| 28 | requested root table index bits, and on return it is the actual root |
| 29 | table index bits. It will differ if the request is greater than the |
| 30 | longest code or if it is less than the shortest code. |
| 31 | */ |
| 32 | int inflate_table9(codetype type, unsigned short FAR *lens, unsigned codes, |
| 33 | code FAR * FAR *table, unsigned FAR *bits, |
| 34 | unsigned short FAR *work) { |
| 35 | unsigned len; /* a code's length in bits */ |
| 36 | unsigned sym; /* index of code symbols */ |
| 37 | unsigned min, max; /* minimum and maximum code lengths */ |
| 38 | unsigned root; /* number of index bits for root table */ |
| 39 | unsigned curr; /* number of index bits for current table */ |
| @@ -62,11 +57,11 @@ | |
| 57 | 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, |
| 58 | 131, 163, 195, 227, 3, 0, 0}; |
| 59 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ |
| 60 | 128, 128, 128, 128, 128, 128, 128, 128, 129, 129, 129, 129, |
| 61 | 130, 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, 132, |
| 62 | 133, 133, 133, 133, 144, 198, 203}; |
| 63 | static const unsigned short dbase[32] = { /* Distance codes 0..31 base */ |
| 64 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, |
| 65 | 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, |
| 66 | 4097, 6145, 8193, 12289, 16385, 24577, 32769, 49153}; |
| 67 | static const unsigned short dext[32] = { /* Distance codes 0..31 extra */ |
| 68 |
| --- compat/zlib/contrib/infback9/inftree9.h | ||
| +++ compat/zlib/contrib/infback9/inftree9.h | ||
| @@ -54,8 +54,8 @@ | ||
| 54 | 54 | CODES, |
| 55 | 55 | LENS, |
| 56 | 56 | DISTS |
| 57 | 57 | } codetype; |
| 58 | 58 | |
| 59 | -extern int inflate_table9 OF((codetype type, unsigned short FAR *lens, | |
| 60 | - unsigned codes, code FAR * FAR *table, | |
| 61 | - unsigned FAR *bits, unsigned short FAR *work)); | |
| 59 | +extern int inflate_table9(codetype type, unsigned short FAR *lens, | |
| 60 | + unsigned codes, code FAR * FAR *table, | |
| 61 | + unsigned FAR *bits, unsigned short FAR *work); | |
| 62 | 62 |
| --- compat/zlib/contrib/infback9/inftree9.h | |
| +++ compat/zlib/contrib/infback9/inftree9.h | |
| @@ -54,8 +54,8 @@ | |
| 54 | CODES, |
| 55 | LENS, |
| 56 | DISTS |
| 57 | } codetype; |
| 58 | |
| 59 | extern int inflate_table9 OF((codetype type, unsigned short FAR *lens, |
| 60 | unsigned codes, code FAR * FAR *table, |
| 61 | unsigned FAR *bits, unsigned short FAR *work)); |
| 62 |
| --- compat/zlib/contrib/infback9/inftree9.h | |
| +++ compat/zlib/contrib/infback9/inftree9.h | |
| @@ -54,8 +54,8 @@ | |
| 54 | CODES, |
| 55 | LENS, |
| 56 | DISTS |
| 57 | } codetype; |
| 58 | |
| 59 | extern int inflate_table9(codetype type, unsigned short FAR *lens, |
| 60 | unsigned codes, code FAR * FAR *table, |
| 61 | unsigned FAR *bits, unsigned short FAR *work); |
| 62 |
| --- compat/zlib/contrib/minizip/MiniZip64_Changes.txt | ||
| +++ compat/zlib/contrib/minizip/MiniZip64_Changes.txt | ||
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | |
| 2 | -MiniZip 1.1 was derrived from MiniZip at version 1.01f | |
| 2 | +MiniZip 1.1 was derived from MiniZip at version 1.01f | |
| 3 | 3 | |
| 4 | 4 | Change in 1.0 (Okt 2009) |
| 5 | 5 | - **TODO - Add history** |
| 6 | 6 | |
| 7 | 7 |
| --- compat/zlib/contrib/minizip/MiniZip64_Changes.txt | |
| +++ compat/zlib/contrib/minizip/MiniZip64_Changes.txt | |
| @@ -1,6 +1,6 @@ | |
| 1 | |
| 2 | MiniZip 1.1 was derrived from MiniZip at version 1.01f |
| 3 | |
| 4 | Change in 1.0 (Okt 2009) |
| 5 | - **TODO - Add history** |
| 6 | |
| 7 |
| --- compat/zlib/contrib/minizip/MiniZip64_Changes.txt | |
| +++ compat/zlib/contrib/minizip/MiniZip64_Changes.txt | |
| @@ -1,6 +1,6 @@ | |
| 1 | |
| 2 | MiniZip 1.1 was derived from MiniZip at version 1.01f |
| 3 | |
| 4 | Change in 1.0 (Okt 2009) |
| 5 | - **TODO - Add history** |
| 6 | |
| 7 |
| --- compat/zlib/contrib/minizip/configure.ac | ||
| +++ compat/zlib/contrib/minizip/configure.ac | ||
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | # -*- Autoconf -*- |
| 2 | 2 | # Process this file with autoconf to produce a configure script. |
| 3 | 3 | |
| 4 | -AC_INIT([minizip], [1.2.13], [bugzilla.redhat.com]) | |
| 4 | +AC_INIT([minizip], [1.3.0], [bugzilla.redhat.com]) | |
| 5 | 5 | AC_CONFIG_SRCDIR([minizip.c]) |
| 6 | 6 | AM_INIT_AUTOMAKE([foreign]) |
| 7 | 7 | LT_INIT |
| 8 | 8 | |
| 9 | 9 | AC_MSG_CHECKING([whether to build example programs]) |
| 10 | 10 |
| --- compat/zlib/contrib/minizip/configure.ac | |
| +++ compat/zlib/contrib/minizip/configure.ac | |
| @@ -1,9 +1,9 @@ | |
| 1 | # -*- Autoconf -*- |
| 2 | # Process this file with autoconf to produce a configure script. |
| 3 | |
| 4 | AC_INIT([minizip], [1.2.13], [bugzilla.redhat.com]) |
| 5 | AC_CONFIG_SRCDIR([minizip.c]) |
| 6 | AM_INIT_AUTOMAKE([foreign]) |
| 7 | LT_INIT |
| 8 | |
| 9 | AC_MSG_CHECKING([whether to build example programs]) |
| 10 |
| --- compat/zlib/contrib/minizip/configure.ac | |
| +++ compat/zlib/contrib/minizip/configure.ac | |
| @@ -1,9 +1,9 @@ | |
| 1 | # -*- Autoconf -*- |
| 2 | # Process this file with autoconf to produce a configure script. |
| 3 | |
| 4 | AC_INIT([minizip], [1.3.0], [bugzilla.redhat.com]) |
| 5 | AC_CONFIG_SRCDIR([minizip.c]) |
| 6 | AM_INIT_AUTOMAKE([foreign]) |
| 7 | LT_INIT |
| 8 | |
| 9 | AC_MSG_CHECKING([whether to build example programs]) |
| 10 |
| --- compat/zlib/contrib/minizip/crypt.h | ||
| +++ compat/zlib/contrib/minizip/crypt.h | ||
| @@ -30,12 +30,11 @@ | ||
| 30 | 30 | #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) |
| 31 | 31 | |
| 32 | 32 | /*********************************************************************** |
| 33 | 33 | * Return the next byte in the pseudo-random sequence |
| 34 | 34 | */ |
| 35 | -static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) | |
| 36 | -{ | |
| 35 | +static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) { | |
| 37 | 36 | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an |
| 38 | 37 | * unpredictable manner on 16-bit systems; not a problem |
| 39 | 38 | * with any known compiler so far, though */ |
| 40 | 39 | |
| 41 | 40 | (void)pcrc_32_tab; |
| @@ -44,12 +43,11 @@ | ||
| 44 | 43 | } |
| 45 | 44 | |
| 46 | 45 | /*********************************************************************** |
| 47 | 46 | * Update the encryption keys with the next byte of plain text |
| 48 | 47 | */ |
| 49 | -static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c) | |
| 50 | -{ | |
| 48 | +static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab, int c) { | |
| 51 | 49 | (*(pkeys+0)) = CRC32((*(pkeys+0)), c); |
| 52 | 50 | (*(pkeys+1)) += (*(pkeys+0)) & 0xff; |
| 53 | 51 | (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; |
| 54 | 52 | { |
| 55 | 53 | register int keyshift = (int)((*(pkeys+1)) >> 24); |
| @@ -61,12 +59,11 @@ | ||
| 61 | 59 | |
| 62 | 60 | /*********************************************************************** |
| 63 | 61 | * Initialize the encryption keys and the random header according to |
| 64 | 62 | * the given password. |
| 65 | 63 | */ |
| 66 | -static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab) | |
| 67 | -{ | |
| 64 | +static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab) { | |
| 68 | 65 | *(pkeys+0) = 305419896L; |
| 69 | 66 | *(pkeys+1) = 591751049L; |
| 70 | 67 | *(pkeys+2) = 878082192L; |
| 71 | 68 | while (*passwd != '\0') { |
| 72 | 69 | update_keys(pkeys,pcrc_32_tab,(int)*passwd); |
| @@ -91,12 +88,11 @@ | ||
| 91 | 88 | static unsigned crypthead(const char* passwd, /* password string */ |
| 92 | 89 | unsigned char* buf, /* where to write header */ |
| 93 | 90 | int bufSize, |
| 94 | 91 | unsigned long* pkeys, |
| 95 | 92 | const z_crc_t* pcrc_32_tab, |
| 96 | - unsigned long crcForCrypting) | |
| 97 | -{ | |
| 93 | + unsigned long crcForCrypting) { | |
| 98 | 94 | unsigned n; /* index in random header */ |
| 99 | 95 | int t; /* temporary */ |
| 100 | 96 | int c; /* random byte */ |
| 101 | 97 | unsigned char header[RAND_HEAD_LEN-2]; /* random header */ |
| 102 | 98 | static unsigned calls = 0; /* ensure different random header each time */ |
| 103 | 99 |
| --- compat/zlib/contrib/minizip/crypt.h | |
| +++ compat/zlib/contrib/minizip/crypt.h | |
| @@ -30,12 +30,11 @@ | |
| 30 | #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) |
| 31 | |
| 32 | /*********************************************************************** |
| 33 | * Return the next byte in the pseudo-random sequence |
| 34 | */ |
| 35 | static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) |
| 36 | { |
| 37 | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an |
| 38 | * unpredictable manner on 16-bit systems; not a problem |
| 39 | * with any known compiler so far, though */ |
| 40 | |
| 41 | (void)pcrc_32_tab; |
| @@ -44,12 +43,11 @@ | |
| 44 | } |
| 45 | |
| 46 | /*********************************************************************** |
| 47 | * Update the encryption keys with the next byte of plain text |
| 48 | */ |
| 49 | static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c) |
| 50 | { |
| 51 | (*(pkeys+0)) = CRC32((*(pkeys+0)), c); |
| 52 | (*(pkeys+1)) += (*(pkeys+0)) & 0xff; |
| 53 | (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; |
| 54 | { |
| 55 | register int keyshift = (int)((*(pkeys+1)) >> 24); |
| @@ -61,12 +59,11 @@ | |
| 61 | |
| 62 | /*********************************************************************** |
| 63 | * Initialize the encryption keys and the random header according to |
| 64 | * the given password. |
| 65 | */ |
| 66 | static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab) |
| 67 | { |
| 68 | *(pkeys+0) = 305419896L; |
| 69 | *(pkeys+1) = 591751049L; |
| 70 | *(pkeys+2) = 878082192L; |
| 71 | while (*passwd != '\0') { |
| 72 | update_keys(pkeys,pcrc_32_tab,(int)*passwd); |
| @@ -91,12 +88,11 @@ | |
| 91 | static unsigned crypthead(const char* passwd, /* password string */ |
| 92 | unsigned char* buf, /* where to write header */ |
| 93 | int bufSize, |
| 94 | unsigned long* pkeys, |
| 95 | const z_crc_t* pcrc_32_tab, |
| 96 | unsigned long crcForCrypting) |
| 97 | { |
| 98 | unsigned n; /* index in random header */ |
| 99 | int t; /* temporary */ |
| 100 | int c; /* random byte */ |
| 101 | unsigned char header[RAND_HEAD_LEN-2]; /* random header */ |
| 102 | static unsigned calls = 0; /* ensure different random header each time */ |
| 103 |
| --- compat/zlib/contrib/minizip/crypt.h | |
| +++ compat/zlib/contrib/minizip/crypt.h | |
| @@ -30,12 +30,11 @@ | |
| 30 | #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) |
| 31 | |
| 32 | /*********************************************************************** |
| 33 | * Return the next byte in the pseudo-random sequence |
| 34 | */ |
| 35 | static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) { |
| 36 | unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an |
| 37 | * unpredictable manner on 16-bit systems; not a problem |
| 38 | * with any known compiler so far, though */ |
| 39 | |
| 40 | (void)pcrc_32_tab; |
| @@ -44,12 +43,11 @@ | |
| 43 | } |
| 44 | |
| 45 | /*********************************************************************** |
| 46 | * Update the encryption keys with the next byte of plain text |
| 47 | */ |
| 48 | static int update_keys(unsigned long* pkeys, const z_crc_t* pcrc_32_tab, int c) { |
| 49 | (*(pkeys+0)) = CRC32((*(pkeys+0)), c); |
| 50 | (*(pkeys+1)) += (*(pkeys+0)) & 0xff; |
| 51 | (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; |
| 52 | { |
| 53 | register int keyshift = (int)((*(pkeys+1)) >> 24); |
| @@ -61,12 +59,11 @@ | |
| 59 | |
| 60 | /*********************************************************************** |
| 61 | * Initialize the encryption keys and the random header according to |
| 62 | * the given password. |
| 63 | */ |
| 64 | static void init_keys(const char* passwd, unsigned long* pkeys, const z_crc_t* pcrc_32_tab) { |
| 65 | *(pkeys+0) = 305419896L; |
| 66 | *(pkeys+1) = 591751049L; |
| 67 | *(pkeys+2) = 878082192L; |
| 68 | while (*passwd != '\0') { |
| 69 | update_keys(pkeys,pcrc_32_tab,(int)*passwd); |
| @@ -91,12 +88,11 @@ | |
| 88 | static unsigned crypthead(const char* passwd, /* password string */ |
| 89 | unsigned char* buf, /* where to write header */ |
| 90 | int bufSize, |
| 91 | unsigned long* pkeys, |
| 92 | const z_crc_t* pcrc_32_tab, |
| 93 | unsigned long crcForCrypting) { |
| 94 | unsigned n; /* index in random header */ |
| 95 | int t; /* temporary */ |
| 96 | int c; /* random byte */ |
| 97 | unsigned char header[RAND_HEAD_LEN-2]; /* random header */ |
| 98 | static unsigned calls = 0; /* ensure different random header each time */ |
| 99 |
+18
-44
| --- compat/zlib/contrib/minizip/ioapi.c | ||
| +++ compat/zlib/contrib/minizip/ioapi.c | ||
| @@ -12,11 +12,11 @@ | ||
| 12 | 12 | |
| 13 | 13 | #if defined(_WIN32) && (!(defined(_CRT_SECURE_NO_WARNINGS))) |
| 14 | 14 | #define _CRT_SECURE_NO_WARNINGS |
| 15 | 15 | #endif |
| 16 | 16 | |
| 17 | -#if defined(__APPLE__) || defined(IOAPI_NO_64) | |
| 17 | +#if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) | |
| 18 | 18 | // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions |
| 19 | 19 | #define FOPEN_FUNC(filename, mode) fopen(filename, mode) |
| 20 | 20 | #define FTELLO_FUNC(stream) ftello(stream) |
| 21 | 21 | #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) |
| 22 | 22 | #else |
| @@ -26,22 +26,20 @@ | ||
| 26 | 26 | #endif |
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | #include "ioapi.h" |
| 30 | 30 | |
| 31 | -voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) | |
| 32 | -{ | |
| 31 | +voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc, const void*filename, int mode) { | |
| 33 | 32 | if (pfilefunc->zfile_func64.zopen64_file != NULL) |
| 34 | 33 | return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode); |
| 35 | 34 | else |
| 36 | 35 | { |
| 37 | 36 | return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode); |
| 38 | 37 | } |
| 39 | 38 | } |
| 40 | 39 | |
| 41 | -long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) | |
| 42 | -{ | |
| 40 | +long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) { | |
| 43 | 41 | if (pfilefunc->zfile_func64.zseek64_file != NULL) |
| 44 | 42 | return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin); |
| 45 | 43 | else |
| 46 | 44 | { |
| 47 | 45 | uLong offsetTruncated = (uLong)offset; |
| @@ -50,12 +48,11 @@ | ||
| 50 | 48 | else |
| 51 | 49 | return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin); |
| 52 | 50 | } |
| 53 | 51 | } |
| 54 | 52 | |
| 55 | -ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream) | |
| 56 | -{ | |
| 53 | +ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc, voidpf filestream) { | |
| 57 | 54 | if (pfilefunc->zfile_func64.zseek64_file != NULL) |
| 58 | 55 | return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream); |
| 59 | 56 | else |
| 60 | 57 | { |
| 61 | 58 | uLong tell_uLong = (uLong)(*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream); |
| @@ -64,15 +61,13 @@ | ||
| 64 | 61 | else |
| 65 | 62 | return tell_uLong; |
| 66 | 63 | } |
| 67 | 64 | } |
| 68 | 65 | |
| 69 | -void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32) | |
| 70 | -{ | |
| 66 | +void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32, const zlib_filefunc_def* p_filefunc32) { | |
| 71 | 67 | p_filefunc64_32->zfile_func64.zopen64_file = NULL; |
| 72 | 68 | p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file; |
| 73 | - p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; | |
| 74 | 69 | p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file; |
| 75 | 70 | p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file; |
| 76 | 71 | p_filefunc64_32->zfile_func64.ztell64_file = NULL; |
| 77 | 72 | p_filefunc64_32->zfile_func64.zseek64_file = NULL; |
| 78 | 73 | p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file; |
| @@ -82,20 +77,11 @@ | ||
| 82 | 77 | p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file; |
| 83 | 78 | } |
| 84 | 79 | |
| 85 | 80 | |
| 86 | 81 | |
| 87 | -static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode)); | |
| 88 | -static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); | |
| 89 | -static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size)); | |
| 90 | -static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream)); | |
| 91 | -static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); | |
| 92 | -static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream)); | |
| 93 | -static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream)); | |
| 94 | - | |
| 95 | -static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) | |
| 96 | -{ | |
| 82 | +static voidpf ZCALLBACK fopen_file_func(voidpf opaque, const char* filename, int mode) { | |
| 97 | 83 | FILE* file = NULL; |
| 98 | 84 | const char* mode_fopen = NULL; |
| 99 | 85 | (void)opaque; |
| 100 | 86 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) |
| 101 | 87 | mode_fopen = "rb"; |
| @@ -109,12 +95,11 @@ | ||
| 109 | 95 | if ((filename!=NULL) && (mode_fopen != NULL)) |
| 110 | 96 | file = fopen(filename, mode_fopen); |
| 111 | 97 | return file; |
| 112 | 98 | } |
| 113 | 99 | |
| 114 | -static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) | |
| 115 | -{ | |
| 100 | +static voidpf ZCALLBACK fopen64_file_func(voidpf opaque, const void* filename, int mode) { | |
| 116 | 101 | FILE* file = NULL; |
| 117 | 102 | const char* mode_fopen = NULL; |
| 118 | 103 | (void)opaque; |
| 119 | 104 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) |
| 120 | 105 | mode_fopen = "rb"; |
| @@ -129,45 +114,40 @@ | ||
| 129 | 114 | file = FOPEN_FUNC((const char*)filename, mode_fopen); |
| 130 | 115 | return file; |
| 131 | 116 | } |
| 132 | 117 | |
| 133 | 118 | |
| 134 | -static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) | |
| 135 | -{ | |
| 119 | +static uLong ZCALLBACK fread_file_func(voidpf opaque, voidpf stream, void* buf, uLong size) { | |
| 136 | 120 | uLong ret; |
| 137 | 121 | (void)opaque; |
| 138 | 122 | ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); |
| 139 | 123 | return ret; |
| 140 | 124 | } |
| 141 | 125 | |
| 142 | -static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) | |
| 143 | -{ | |
| 126 | +static uLong ZCALLBACK fwrite_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) { | |
| 144 | 127 | uLong ret; |
| 145 | 128 | (void)opaque; |
| 146 | 129 | ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); |
| 147 | 130 | return ret; |
| 148 | 131 | } |
| 149 | 132 | |
| 150 | -static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) | |
| 151 | -{ | |
| 133 | +static long ZCALLBACK ftell_file_func(voidpf opaque, voidpf stream) { | |
| 152 | 134 | long ret; |
| 153 | 135 | (void)opaque; |
| 154 | 136 | ret = ftell((FILE *)stream); |
| 155 | 137 | return ret; |
| 156 | 138 | } |
| 157 | 139 | |
| 158 | 140 | |
| 159 | -static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) | |
| 160 | -{ | |
| 141 | +static ZPOS64_T ZCALLBACK ftell64_file_func(voidpf opaque, voidpf stream) { | |
| 161 | 142 | ZPOS64_T ret; |
| 162 | 143 | (void)opaque; |
| 163 | 144 | ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream); |
| 164 | 145 | return ret; |
| 165 | 146 | } |
| 166 | 147 | |
| 167 | -static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) | |
| 168 | -{ | |
| 148 | +static long ZCALLBACK fseek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) { | |
| 169 | 149 | int fseek_origin=0; |
| 170 | 150 | long ret; |
| 171 | 151 | (void)opaque; |
| 172 | 152 | switch (origin) |
| 173 | 153 | { |
| @@ -186,12 +166,11 @@ | ||
| 186 | 166 | if (fseek((FILE *)stream, (long)offset, fseek_origin) != 0) |
| 187 | 167 | ret = -1; |
| 188 | 168 | return ret; |
| 189 | 169 | } |
| 190 | 170 | |
| 191 | -static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) | |
| 192 | -{ | |
| 171 | +static long ZCALLBACK fseek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) { | |
| 193 | 172 | int fseek_origin=0; |
| 194 | 173 | long ret; |
| 195 | 174 | (void)opaque; |
| 196 | 175 | switch (origin) |
| 197 | 176 | { |
| @@ -206,36 +185,32 @@ | ||
| 206 | 185 | break; |
| 207 | 186 | default: return -1; |
| 208 | 187 | } |
| 209 | 188 | ret = 0; |
| 210 | 189 | |
| 211 | - if(FSEEKO_FUNC((FILE *)stream, (z_off_t)offset, fseek_origin) != 0) | |
| 190 | + if(FSEEKO_FUNC((FILE *)stream, (z_off64_t)offset, fseek_origin) != 0) | |
| 212 | 191 | ret = -1; |
| 213 | 192 | |
| 214 | 193 | return ret; |
| 215 | 194 | } |
| 216 | 195 | |
| 217 | 196 | |
| 218 | -static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) | |
| 219 | -{ | |
| 197 | +static int ZCALLBACK fclose_file_func(voidpf opaque, voidpf stream) { | |
| 220 | 198 | int ret; |
| 221 | 199 | (void)opaque; |
| 222 | 200 | ret = fclose((FILE *)stream); |
| 223 | 201 | return ret; |
| 224 | 202 | } |
| 225 | 203 | |
| 226 | -static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) | |
| 227 | -{ | |
| 204 | +static int ZCALLBACK ferror_file_func(voidpf opaque, voidpf stream) { | |
| 228 | 205 | int ret; |
| 229 | 206 | (void)opaque; |
| 230 | 207 | ret = ferror((FILE *)stream); |
| 231 | 208 | return ret; |
| 232 | 209 | } |
| 233 | 210 | |
| 234 | -void fill_fopen_filefunc (pzlib_filefunc_def) | |
| 235 | - zlib_filefunc_def* pzlib_filefunc_def; | |
| 236 | -{ | |
| 211 | +void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def) { | |
| 237 | 212 | pzlib_filefunc_def->zopen_file = fopen_file_func; |
| 238 | 213 | pzlib_filefunc_def->zread_file = fread_file_func; |
| 239 | 214 | pzlib_filefunc_def->zwrite_file = fwrite_file_func; |
| 240 | 215 | pzlib_filefunc_def->ztell_file = ftell_file_func; |
| 241 | 216 | pzlib_filefunc_def->zseek_file = fseek_file_func; |
| @@ -242,16 +217,15 @@ | ||
| 242 | 217 | pzlib_filefunc_def->zclose_file = fclose_file_func; |
| 243 | 218 | pzlib_filefunc_def->zerror_file = ferror_file_func; |
| 244 | 219 | pzlib_filefunc_def->opaque = NULL; |
| 245 | 220 | } |
| 246 | 221 | |
| 247 | -void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def) | |
| 248 | -{ | |
| 222 | +void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def) { | |
| 249 | 223 | pzlib_filefunc_def->zopen64_file = fopen64_file_func; |
| 250 | 224 | pzlib_filefunc_def->zread_file = fread_file_func; |
| 251 | 225 | pzlib_filefunc_def->zwrite_file = fwrite_file_func; |
| 252 | 226 | pzlib_filefunc_def->ztell64_file = ftell64_file_func; |
| 253 | 227 | pzlib_filefunc_def->zseek64_file = fseek64_file_func; |
| 254 | 228 | pzlib_filefunc_def->zclose_file = fclose_file_func; |
| 255 | 229 | pzlib_filefunc_def->zerror_file = ferror_file_func; |
| 256 | 230 | pzlib_filefunc_def->opaque = NULL; |
| 257 | 231 | } |
| 258 | 232 |
| --- compat/zlib/contrib/minizip/ioapi.c | |
| +++ compat/zlib/contrib/minizip/ioapi.c | |
| @@ -12,11 +12,11 @@ | |
| 12 | |
| 13 | #if defined(_WIN32) && (!(defined(_CRT_SECURE_NO_WARNINGS))) |
| 14 | #define _CRT_SECURE_NO_WARNINGS |
| 15 | #endif |
| 16 | |
| 17 | #if defined(__APPLE__) || defined(IOAPI_NO_64) |
| 18 | // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions |
| 19 | #define FOPEN_FUNC(filename, mode) fopen(filename, mode) |
| 20 | #define FTELLO_FUNC(stream) ftello(stream) |
| 21 | #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) |
| 22 | #else |
| @@ -26,22 +26,20 @@ | |
| 26 | #endif |
| 27 | |
| 28 | |
| 29 | #include "ioapi.h" |
| 30 | |
| 31 | voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) |
| 32 | { |
| 33 | if (pfilefunc->zfile_func64.zopen64_file != NULL) |
| 34 | return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode); |
| 35 | else |
| 36 | { |
| 37 | return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) |
| 42 | { |
| 43 | if (pfilefunc->zfile_func64.zseek64_file != NULL) |
| 44 | return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin); |
| 45 | else |
| 46 | { |
| 47 | uLong offsetTruncated = (uLong)offset; |
| @@ -50,12 +48,11 @@ | |
| 50 | else |
| 51 | return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream) |
| 56 | { |
| 57 | if (pfilefunc->zfile_func64.zseek64_file != NULL) |
| 58 | return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream); |
| 59 | else |
| 60 | { |
| 61 | uLong tell_uLong = (uLong)(*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream); |
| @@ -64,15 +61,13 @@ | |
| 64 | else |
| 65 | return tell_uLong; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32) |
| 70 | { |
| 71 | p_filefunc64_32->zfile_func64.zopen64_file = NULL; |
| 72 | p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file; |
| 73 | p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; |
| 74 | p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file; |
| 75 | p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file; |
| 76 | p_filefunc64_32->zfile_func64.ztell64_file = NULL; |
| 77 | p_filefunc64_32->zfile_func64.zseek64_file = NULL; |
| 78 | p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file; |
| @@ -82,20 +77,11 @@ | |
| 82 | p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file; |
| 83 | } |
| 84 | |
| 85 | |
| 86 | |
| 87 | static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode)); |
| 88 | static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); |
| 89 | static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size)); |
| 90 | static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream)); |
| 91 | static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); |
| 92 | static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream)); |
| 93 | static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream)); |
| 94 | |
| 95 | static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) |
| 96 | { |
| 97 | FILE* file = NULL; |
| 98 | const char* mode_fopen = NULL; |
| 99 | (void)opaque; |
| 100 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) |
| 101 | mode_fopen = "rb"; |
| @@ -109,12 +95,11 @@ | |
| 109 | if ((filename!=NULL) && (mode_fopen != NULL)) |
| 110 | file = fopen(filename, mode_fopen); |
| 111 | return file; |
| 112 | } |
| 113 | |
| 114 | static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) |
| 115 | { |
| 116 | FILE* file = NULL; |
| 117 | const char* mode_fopen = NULL; |
| 118 | (void)opaque; |
| 119 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) |
| 120 | mode_fopen = "rb"; |
| @@ -129,45 +114,40 @@ | |
| 129 | file = FOPEN_FUNC((const char*)filename, mode_fopen); |
| 130 | return file; |
| 131 | } |
| 132 | |
| 133 | |
| 134 | static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) |
| 135 | { |
| 136 | uLong ret; |
| 137 | (void)opaque; |
| 138 | ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); |
| 139 | return ret; |
| 140 | } |
| 141 | |
| 142 | static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) |
| 143 | { |
| 144 | uLong ret; |
| 145 | (void)opaque; |
| 146 | ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); |
| 147 | return ret; |
| 148 | } |
| 149 | |
| 150 | static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) |
| 151 | { |
| 152 | long ret; |
| 153 | (void)opaque; |
| 154 | ret = ftell((FILE *)stream); |
| 155 | return ret; |
| 156 | } |
| 157 | |
| 158 | |
| 159 | static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) |
| 160 | { |
| 161 | ZPOS64_T ret; |
| 162 | (void)opaque; |
| 163 | ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream); |
| 164 | return ret; |
| 165 | } |
| 166 | |
| 167 | static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) |
| 168 | { |
| 169 | int fseek_origin=0; |
| 170 | long ret; |
| 171 | (void)opaque; |
| 172 | switch (origin) |
| 173 | { |
| @@ -186,12 +166,11 @@ | |
| 186 | if (fseek((FILE *)stream, (long)offset, fseek_origin) != 0) |
| 187 | ret = -1; |
| 188 | return ret; |
| 189 | } |
| 190 | |
| 191 | static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) |
| 192 | { |
| 193 | int fseek_origin=0; |
| 194 | long ret; |
| 195 | (void)opaque; |
| 196 | switch (origin) |
| 197 | { |
| @@ -206,36 +185,32 @@ | |
| 206 | break; |
| 207 | default: return -1; |
| 208 | } |
| 209 | ret = 0; |
| 210 | |
| 211 | if(FSEEKO_FUNC((FILE *)stream, (z_off_t)offset, fseek_origin) != 0) |
| 212 | ret = -1; |
| 213 | |
| 214 | return ret; |
| 215 | } |
| 216 | |
| 217 | |
| 218 | static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) |
| 219 | { |
| 220 | int ret; |
| 221 | (void)opaque; |
| 222 | ret = fclose((FILE *)stream); |
| 223 | return ret; |
| 224 | } |
| 225 | |
| 226 | static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) |
| 227 | { |
| 228 | int ret; |
| 229 | (void)opaque; |
| 230 | ret = ferror((FILE *)stream); |
| 231 | return ret; |
| 232 | } |
| 233 | |
| 234 | void fill_fopen_filefunc (pzlib_filefunc_def) |
| 235 | zlib_filefunc_def* pzlib_filefunc_def; |
| 236 | { |
| 237 | pzlib_filefunc_def->zopen_file = fopen_file_func; |
| 238 | pzlib_filefunc_def->zread_file = fread_file_func; |
| 239 | pzlib_filefunc_def->zwrite_file = fwrite_file_func; |
| 240 | pzlib_filefunc_def->ztell_file = ftell_file_func; |
| 241 | pzlib_filefunc_def->zseek_file = fseek_file_func; |
| @@ -242,16 +217,15 @@ | |
| 242 | pzlib_filefunc_def->zclose_file = fclose_file_func; |
| 243 | pzlib_filefunc_def->zerror_file = ferror_file_func; |
| 244 | pzlib_filefunc_def->opaque = NULL; |
| 245 | } |
| 246 | |
| 247 | void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def) |
| 248 | { |
| 249 | pzlib_filefunc_def->zopen64_file = fopen64_file_func; |
| 250 | pzlib_filefunc_def->zread_file = fread_file_func; |
| 251 | pzlib_filefunc_def->zwrite_file = fwrite_file_func; |
| 252 | pzlib_filefunc_def->ztell64_file = ftell64_file_func; |
| 253 | pzlib_filefunc_def->zseek64_file = fseek64_file_func; |
| 254 | pzlib_filefunc_def->zclose_file = fclose_file_func; |
| 255 | pzlib_filefunc_def->zerror_file = ferror_file_func; |
| 256 | pzlib_filefunc_def->opaque = NULL; |
| 257 | } |
| 258 |
| --- compat/zlib/contrib/minizip/ioapi.c | |
| +++ compat/zlib/contrib/minizip/ioapi.c | |
| @@ -12,11 +12,11 @@ | |
| 12 | |
| 13 | #if defined(_WIN32) && (!(defined(_CRT_SECURE_NO_WARNINGS))) |
| 14 | #define _CRT_SECURE_NO_WARNINGS |
| 15 | #endif |
| 16 | |
| 17 | #if defined(__APPLE__) || defined(IOAPI_NO_64) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) |
| 18 | // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions |
| 19 | #define FOPEN_FUNC(filename, mode) fopen(filename, mode) |
| 20 | #define FTELLO_FUNC(stream) ftello(stream) |
| 21 | #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) |
| 22 | #else |
| @@ -26,22 +26,20 @@ | |
| 26 | #endif |
| 27 | |
| 28 | |
| 29 | #include "ioapi.h" |
| 30 | |
| 31 | voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc, const void*filename, int mode) { |
| 32 | if (pfilefunc->zfile_func64.zopen64_file != NULL) |
| 33 | return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode); |
| 34 | else |
| 35 | { |
| 36 | return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) { |
| 41 | if (pfilefunc->zfile_func64.zseek64_file != NULL) |
| 42 | return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin); |
| 43 | else |
| 44 | { |
| 45 | uLong offsetTruncated = (uLong)offset; |
| @@ -50,12 +48,11 @@ | |
| 48 | else |
| 49 | return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc, voidpf filestream) { |
| 54 | if (pfilefunc->zfile_func64.zseek64_file != NULL) |
| 55 | return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream); |
| 56 | else |
| 57 | { |
| 58 | uLong tell_uLong = (uLong)(*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream); |
| @@ -64,15 +61,13 @@ | |
| 61 | else |
| 62 | return tell_uLong; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32, const zlib_filefunc_def* p_filefunc32) { |
| 67 | p_filefunc64_32->zfile_func64.zopen64_file = NULL; |
| 68 | p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file; |
| 69 | p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file; |
| 70 | p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file; |
| 71 | p_filefunc64_32->zfile_func64.ztell64_file = NULL; |
| 72 | p_filefunc64_32->zfile_func64.zseek64_file = NULL; |
| 73 | p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file; |
| @@ -82,20 +77,11 @@ | |
| 77 | p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file; |
| 78 | } |
| 79 | |
| 80 | |
| 81 | |
| 82 | static voidpf ZCALLBACK fopen_file_func(voidpf opaque, const char* filename, int mode) { |
| 83 | FILE* file = NULL; |
| 84 | const char* mode_fopen = NULL; |
| 85 | (void)opaque; |
| 86 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) |
| 87 | mode_fopen = "rb"; |
| @@ -109,12 +95,11 @@ | |
| 95 | if ((filename!=NULL) && (mode_fopen != NULL)) |
| 96 | file = fopen(filename, mode_fopen); |
| 97 | return file; |
| 98 | } |
| 99 | |
| 100 | static voidpf ZCALLBACK fopen64_file_func(voidpf opaque, const void* filename, int mode) { |
| 101 | FILE* file = NULL; |
| 102 | const char* mode_fopen = NULL; |
| 103 | (void)opaque; |
| 104 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) |
| 105 | mode_fopen = "rb"; |
| @@ -129,45 +114,40 @@ | |
| 114 | file = FOPEN_FUNC((const char*)filename, mode_fopen); |
| 115 | return file; |
| 116 | } |
| 117 | |
| 118 | |
| 119 | static uLong ZCALLBACK fread_file_func(voidpf opaque, voidpf stream, void* buf, uLong size) { |
| 120 | uLong ret; |
| 121 | (void)opaque; |
| 122 | ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); |
| 123 | return ret; |
| 124 | } |
| 125 | |
| 126 | static uLong ZCALLBACK fwrite_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) { |
| 127 | uLong ret; |
| 128 | (void)opaque; |
| 129 | ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); |
| 130 | return ret; |
| 131 | } |
| 132 | |
| 133 | static long ZCALLBACK ftell_file_func(voidpf opaque, voidpf stream) { |
| 134 | long ret; |
| 135 | (void)opaque; |
| 136 | ret = ftell((FILE *)stream); |
| 137 | return ret; |
| 138 | } |
| 139 | |
| 140 | |
| 141 | static ZPOS64_T ZCALLBACK ftell64_file_func(voidpf opaque, voidpf stream) { |
| 142 | ZPOS64_T ret; |
| 143 | (void)opaque; |
| 144 | ret = (ZPOS64_T)FTELLO_FUNC((FILE *)stream); |
| 145 | return ret; |
| 146 | } |
| 147 | |
| 148 | static long ZCALLBACK fseek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) { |
| 149 | int fseek_origin=0; |
| 150 | long ret; |
| 151 | (void)opaque; |
| 152 | switch (origin) |
| 153 | { |
| @@ -186,12 +166,11 @@ | |
| 166 | if (fseek((FILE *)stream, (long)offset, fseek_origin) != 0) |
| 167 | ret = -1; |
| 168 | return ret; |
| 169 | } |
| 170 | |
| 171 | static long ZCALLBACK fseek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) { |
| 172 | int fseek_origin=0; |
| 173 | long ret; |
| 174 | (void)opaque; |
| 175 | switch (origin) |
| 176 | { |
| @@ -206,36 +185,32 @@ | |
| 185 | break; |
| 186 | default: return -1; |
| 187 | } |
| 188 | ret = 0; |
| 189 | |
| 190 | if(FSEEKO_FUNC((FILE *)stream, (z_off64_t)offset, fseek_origin) != 0) |
| 191 | ret = -1; |
| 192 | |
| 193 | return ret; |
| 194 | } |
| 195 | |
| 196 | |
| 197 | static int ZCALLBACK fclose_file_func(voidpf opaque, voidpf stream) { |
| 198 | int ret; |
| 199 | (void)opaque; |
| 200 | ret = fclose((FILE *)stream); |
| 201 | return ret; |
| 202 | } |
| 203 | |
| 204 | static int ZCALLBACK ferror_file_func(voidpf opaque, voidpf stream) { |
| 205 | int ret; |
| 206 | (void)opaque; |
| 207 | ret = ferror((FILE *)stream); |
| 208 | return ret; |
| 209 | } |
| 210 | |
| 211 | void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def) { |
| 212 | pzlib_filefunc_def->zopen_file = fopen_file_func; |
| 213 | pzlib_filefunc_def->zread_file = fread_file_func; |
| 214 | pzlib_filefunc_def->zwrite_file = fwrite_file_func; |
| 215 | pzlib_filefunc_def->ztell_file = ftell_file_func; |
| 216 | pzlib_filefunc_def->zseek_file = fseek_file_func; |
| @@ -242,16 +217,15 @@ | |
| 217 | pzlib_filefunc_def->zclose_file = fclose_file_func; |
| 218 | pzlib_filefunc_def->zerror_file = ferror_file_func; |
| 219 | pzlib_filefunc_def->opaque = NULL; |
| 220 | } |
| 221 | |
| 222 | void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def) { |
| 223 | pzlib_filefunc_def->zopen64_file = fopen64_file_func; |
| 224 | pzlib_filefunc_def->zread_file = fread_file_func; |
| 225 | pzlib_filefunc_def->zwrite_file = fwrite_file_func; |
| 226 | pzlib_filefunc_def->ztell64_file = ftell64_file_func; |
| 227 | pzlib_filefunc_def->zseek64_file = fseek64_file_func; |
| 228 | pzlib_filefunc_def->zclose_file = fclose_file_func; |
| 229 | pzlib_filefunc_def->zerror_file = ferror_file_func; |
| 230 | pzlib_filefunc_def->opaque = NULL; |
| 231 | } |
| 232 |
+19
-19
| --- compat/zlib/contrib/minizip/ioapi.h | ||
| +++ compat/zlib/contrib/minizip/ioapi.h | ||
| @@ -48,11 +48,11 @@ | ||
| 48 | 48 | #if defined(USE_FILE32API) |
| 49 | 49 | #define fopen64 fopen |
| 50 | 50 | #define ftello64 ftell |
| 51 | 51 | #define fseeko64 fseek |
| 52 | 52 | #else |
| 53 | -#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) | |
| 53 | +#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) | |
| 54 | 54 | #define fopen64 fopen |
| 55 | 55 | #define ftello64 ftello |
| 56 | 56 | #define fseeko64 fseeko |
| 57 | 57 | #endif |
| 58 | 58 | #ifdef _MSC_VER |
| @@ -80,11 +80,11 @@ | ||
| 80 | 80 | |
| 81 | 81 | #ifdef HAVE_MINIZIP64_CONF_H |
| 82 | 82 | #include "mz64conf.h" |
| 83 | 83 | #endif |
| 84 | 84 | |
| 85 | -/* a type choosen by DEFINE */ | |
| 85 | +/* a type chosen by DEFINE */ | |
| 86 | 86 | #ifdef HAVE_64BIT_INT_CUSTOM |
| 87 | 87 | typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; |
| 88 | 88 | #else |
| 89 | 89 | #ifdef HAS_STDINT_H |
| 90 | 90 | #include "stdint.h" |
| @@ -132,18 +132,18 @@ | ||
| 132 | 132 | #endif |
| 133 | 133 | |
| 134 | 134 | |
| 135 | 135 | |
| 136 | 136 | |
| 137 | -typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); | |
| 138 | -typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); | |
| 139 | -typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); | |
| 140 | -typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); | |
| 141 | -typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); | |
| 142 | - | |
| 143 | -typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); | |
| 144 | -typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); | |
| 137 | +typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode); | |
| 138 | +typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size); | |
| 139 | +typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size); | |
| 140 | +typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream); | |
| 141 | +typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream); | |
| 142 | + | |
| 143 | +typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream); | |
| 144 | +typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin); | |
| 145 | 145 | |
| 146 | 146 | |
| 147 | 147 | /* here is the "old" 32 bits structure structure */ |
| 148 | 148 | typedef struct zlib_filefunc_def_s |
| 149 | 149 | { |
| @@ -155,13 +155,13 @@ | ||
| 155 | 155 | close_file_func zclose_file; |
| 156 | 156 | testerror_file_func zerror_file; |
| 157 | 157 | voidpf opaque; |
| 158 | 158 | } zlib_filefunc_def; |
| 159 | 159 | |
| 160 | -typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); | |
| 161 | -typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); | |
| 162 | -typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); | |
| 160 | +typedef ZPOS64_T (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream); | |
| 161 | +typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin); | |
| 162 | +typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void* filename, int mode); | |
| 163 | 163 | |
| 164 | 164 | typedef struct zlib_filefunc64_def_s |
| 165 | 165 | { |
| 166 | 166 | open64_file_func zopen64_file; |
| 167 | 167 | read_file_func zread_file; |
| @@ -171,12 +171,12 @@ | ||
| 171 | 171 | close_file_func zclose_file; |
| 172 | 172 | testerror_file_func zerror_file; |
| 173 | 173 | voidpf opaque; |
| 174 | 174 | } zlib_filefunc64_def; |
| 175 | 175 | |
| 176 | -void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); | |
| 177 | -void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); | |
| 176 | +void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def); | |
| 177 | +void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def); | |
| 178 | 178 | |
| 179 | 179 | /* now internal definition, only for zip.c and unzip.h */ |
| 180 | 180 | typedef struct zlib_filefunc64_32_def_s |
| 181 | 181 | { |
| 182 | 182 | zlib_filefunc64_def zfile_func64; |
| @@ -191,15 +191,15 @@ | ||
| 191 | 191 | //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) |
| 192 | 192 | //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) |
| 193 | 193 | #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) |
| 194 | 194 | #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) |
| 195 | 195 | |
| 196 | -voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); | |
| 197 | -long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); | |
| 198 | -ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); | |
| 196 | +voidpf call_zopen64(const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode); | |
| 197 | +long call_zseek64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin); | |
| 198 | +ZPOS64_T call_ztell64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream); | |
| 199 | 199 | |
| 200 | -void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); | |
| 200 | +void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); | |
| 201 | 201 | |
| 202 | 202 | #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) |
| 203 | 203 | #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) |
| 204 | 204 | #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) |
| 205 | 205 | |
| 206 | 206 |
| --- compat/zlib/contrib/minizip/ioapi.h | |
| +++ compat/zlib/contrib/minizip/ioapi.h | |
| @@ -48,11 +48,11 @@ | |
| 48 | #if defined(USE_FILE32API) |
| 49 | #define fopen64 fopen |
| 50 | #define ftello64 ftell |
| 51 | #define fseeko64 fseek |
| 52 | #else |
| 53 | #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) |
| 54 | #define fopen64 fopen |
| 55 | #define ftello64 ftello |
| 56 | #define fseeko64 fseeko |
| 57 | #endif |
| 58 | #ifdef _MSC_VER |
| @@ -80,11 +80,11 @@ | |
| 80 | |
| 81 | #ifdef HAVE_MINIZIP64_CONF_H |
| 82 | #include "mz64conf.h" |
| 83 | #endif |
| 84 | |
| 85 | /* a type choosen by DEFINE */ |
| 86 | #ifdef HAVE_64BIT_INT_CUSTOM |
| 87 | typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; |
| 88 | #else |
| 89 | #ifdef HAS_STDINT_H |
| 90 | #include "stdint.h" |
| @@ -132,18 +132,18 @@ | |
| 132 | #endif |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); |
| 138 | typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); |
| 139 | typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); |
| 140 | typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); |
| 141 | typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); |
| 142 | |
| 143 | typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); |
| 144 | typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); |
| 145 | |
| 146 | |
| 147 | /* here is the "old" 32 bits structure structure */ |
| 148 | typedef struct zlib_filefunc_def_s |
| 149 | { |
| @@ -155,13 +155,13 @@ | |
| 155 | close_file_func zclose_file; |
| 156 | testerror_file_func zerror_file; |
| 157 | voidpf opaque; |
| 158 | } zlib_filefunc_def; |
| 159 | |
| 160 | typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); |
| 161 | typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); |
| 162 | typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); |
| 163 | |
| 164 | typedef struct zlib_filefunc64_def_s |
| 165 | { |
| 166 | open64_file_func zopen64_file; |
| 167 | read_file_func zread_file; |
| @@ -171,12 +171,12 @@ | |
| 171 | close_file_func zclose_file; |
| 172 | testerror_file_func zerror_file; |
| 173 | voidpf opaque; |
| 174 | } zlib_filefunc64_def; |
| 175 | |
| 176 | void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); |
| 177 | void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); |
| 178 | |
| 179 | /* now internal definition, only for zip.c and unzip.h */ |
| 180 | typedef struct zlib_filefunc64_32_def_s |
| 181 | { |
| 182 | zlib_filefunc64_def zfile_func64; |
| @@ -191,15 +191,15 @@ | |
| 191 | //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) |
| 192 | //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) |
| 193 | #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) |
| 194 | #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) |
| 195 | |
| 196 | voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); |
| 197 | long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); |
| 198 | ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); |
| 199 | |
| 200 | void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); |
| 201 | |
| 202 | #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) |
| 203 | #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) |
| 204 | #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) |
| 205 | |
| 206 |
| --- compat/zlib/contrib/minizip/ioapi.h | |
| +++ compat/zlib/contrib/minizip/ioapi.h | |
| @@ -48,11 +48,11 @@ | |
| 48 | #if defined(USE_FILE32API) |
| 49 | #define fopen64 fopen |
| 50 | #define ftello64 ftell |
| 51 | #define fseeko64 fseek |
| 52 | #else |
| 53 | #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) |
| 54 | #define fopen64 fopen |
| 55 | #define ftello64 ftello |
| 56 | #define fseeko64 fseeko |
| 57 | #endif |
| 58 | #ifdef _MSC_VER |
| @@ -80,11 +80,11 @@ | |
| 80 | |
| 81 | #ifdef HAVE_MINIZIP64_CONF_H |
| 82 | #include "mz64conf.h" |
| 83 | #endif |
| 84 | |
| 85 | /* a type chosen by DEFINE */ |
| 86 | #ifdef HAVE_64BIT_INT_CUSTOM |
| 87 | typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; |
| 88 | #else |
| 89 | #ifdef HAS_STDINT_H |
| 90 | #include "stdint.h" |
| @@ -132,18 +132,18 @@ | |
| 132 | #endif |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode); |
| 138 | typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size); |
| 139 | typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size); |
| 140 | typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream); |
| 141 | typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream); |
| 142 | |
| 143 | typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream); |
| 144 | typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin); |
| 145 | |
| 146 | |
| 147 | /* here is the "old" 32 bits structure structure */ |
| 148 | typedef struct zlib_filefunc_def_s |
| 149 | { |
| @@ -155,13 +155,13 @@ | |
| 155 | close_file_func zclose_file; |
| 156 | testerror_file_func zerror_file; |
| 157 | voidpf opaque; |
| 158 | } zlib_filefunc_def; |
| 159 | |
| 160 | typedef ZPOS64_T (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream); |
| 161 | typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin); |
| 162 | typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void* filename, int mode); |
| 163 | |
| 164 | typedef struct zlib_filefunc64_def_s |
| 165 | { |
| 166 | open64_file_func zopen64_file; |
| 167 | read_file_func zread_file; |
| @@ -171,12 +171,12 @@ | |
| 171 | close_file_func zclose_file; |
| 172 | testerror_file_func zerror_file; |
| 173 | voidpf opaque; |
| 174 | } zlib_filefunc64_def; |
| 175 | |
| 176 | void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def); |
| 177 | void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def); |
| 178 | |
| 179 | /* now internal definition, only for zip.c and unzip.h */ |
| 180 | typedef struct zlib_filefunc64_32_def_s |
| 181 | { |
| 182 | zlib_filefunc64_def zfile_func64; |
| @@ -191,15 +191,15 @@ | |
| 191 | //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) |
| 192 | //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) |
| 193 | #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) |
| 194 | #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) |
| 195 | |
| 196 | voidpf call_zopen64(const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode); |
| 197 | long call_zseek64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin); |
| 198 | ZPOS64_T call_ztell64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream); |
| 199 | |
| 200 | void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); |
| 201 | |
| 202 | #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) |
| 203 | #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) |
| 204 | #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) |
| 205 | |
| 206 |
+19
-46
| --- compat/zlib/contrib/minizip/iowin32.c | ||
| +++ compat/zlib/contrib/minizip/iowin32.c | ||
| @@ -36,18 +36,10 @@ | ||
| 36 | 36 | #if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP) |
| 37 | 37 | #define IOWIN32_USING_WINRT_API 1 |
| 38 | 38 | #endif |
| 39 | 39 | #endif |
| 40 | 40 | |
| 41 | -voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode)); | |
| 42 | -uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); | |
| 43 | -uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); | |
| 44 | -ZPOS64_T ZCALLBACK win32_tell64_file_func OF((voidpf opaque, voidpf stream)); | |
| 45 | -long ZCALLBACK win32_seek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); | |
| 46 | -int ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream)); | |
| 47 | -int ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream)); | |
| 48 | - | |
| 49 | 41 | typedef struct |
| 50 | 42 | { |
| 51 | 43 | HANDLE hf; |
| 52 | 44 | int error; |
| 53 | 45 | } WIN32FILE_IOWIN; |
| @@ -55,12 +47,11 @@ | ||
| 55 | 47 | |
| 56 | 48 | static void win32_translate_open_mode(int mode, |
| 57 | 49 | DWORD* lpdwDesiredAccess, |
| 58 | 50 | DWORD* lpdwCreationDisposition, |
| 59 | 51 | DWORD* lpdwShareMode, |
| 60 | - DWORD* lpdwFlagsAndAttributes) | |
| 61 | -{ | |
| 52 | + DWORD* lpdwFlagsAndAttributes) { | |
| 62 | 53 | *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0; |
| 63 | 54 | |
| 64 | 55 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) |
| 65 | 56 | { |
| 66 | 57 | *lpdwDesiredAccess = GENERIC_READ; |
| @@ -77,12 +68,11 @@ | ||
| 77 | 68 | *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ; |
| 78 | 69 | *lpdwCreationDisposition = CREATE_ALWAYS; |
| 79 | 70 | } |
| 80 | 71 | } |
| 81 | 72 | |
| 82 | -static voidpf win32_build_iowin(HANDLE hFile) | |
| 83 | -{ | |
| 73 | +static voidpf win32_build_iowin(HANDLE hFile) { | |
| 84 | 74 | voidpf ret=NULL; |
| 85 | 75 | |
| 86 | 76 | if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE)) |
| 87 | 77 | { |
| 88 | 78 | WIN32FILE_IOWIN w32fiow; |
| @@ -96,12 +86,11 @@ | ||
| 96 | 86 | *((WIN32FILE_IOWIN*)ret) = w32fiow; |
| 97 | 87 | } |
| 98 | 88 | return ret; |
| 99 | 89 | } |
| 100 | 90 | |
| 101 | -voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode) | |
| 102 | -{ | |
| 91 | +voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int mode) { | |
| 103 | 92 | const char* mode_fopen = NULL; |
| 104 | 93 | DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; |
| 105 | 94 | HANDLE hFile = NULL; |
| 106 | 95 | |
| 107 | 96 | win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
| @@ -125,12 +114,11 @@ | ||
| 125 | 114 | |
| 126 | 115 | return win32_build_iowin(hFile); |
| 127 | 116 | } |
| 128 | 117 | |
| 129 | 118 | |
| 130 | -voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode) | |
| 131 | -{ | |
| 119 | +voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, int mode) { | |
| 132 | 120 | const char* mode_fopen = NULL; |
| 133 | 121 | DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; |
| 134 | 122 | HANDLE hFile = NULL; |
| 135 | 123 | |
| 136 | 124 | win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
| @@ -149,12 +137,11 @@ | ||
| 149 | 137 | |
| 150 | 138 | return win32_build_iowin(hFile); |
| 151 | 139 | } |
| 152 | 140 | |
| 153 | 141 | |
| 154 | -voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode) | |
| 155 | -{ | |
| 142 | +voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, int mode) { | |
| 156 | 143 | const char* mode_fopen = NULL; |
| 157 | 144 | DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; |
| 158 | 145 | HANDLE hFile = NULL; |
| 159 | 146 | |
| 160 | 147 | win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
| @@ -169,12 +156,11 @@ | ||
| 169 | 156 | |
| 170 | 157 | return win32_build_iowin(hFile); |
| 171 | 158 | } |
| 172 | 159 | |
| 173 | 160 | |
| 174 | -voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode) | |
| 175 | -{ | |
| 161 | +voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int mode) { | |
| 176 | 162 | const char* mode_fopen = NULL; |
| 177 | 163 | DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; |
| 178 | 164 | HANDLE hFile = NULL; |
| 179 | 165 | |
| 180 | 166 | win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
| @@ -198,12 +184,11 @@ | ||
| 198 | 184 | |
| 199 | 185 | return win32_build_iowin(hFile); |
| 200 | 186 | } |
| 201 | 187 | |
| 202 | 188 | |
| 203 | -uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size) | |
| 204 | -{ | |
| 189 | +uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLong size) { | |
| 205 | 190 | uLong ret=0; |
| 206 | 191 | HANDLE hFile = NULL; |
| 207 | 192 | if (stream!=NULL) |
| 208 | 193 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
| 209 | 194 | |
| @@ -220,12 +205,11 @@ | ||
| 220 | 205 | |
| 221 | 206 | return ret; |
| 222 | 207 | } |
| 223 | 208 | |
| 224 | 209 | |
| 225 | -uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size) | |
| 226 | -{ | |
| 210 | +uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) { | |
| 227 | 211 | uLong ret=0; |
| 228 | 212 | HANDLE hFile = NULL; |
| 229 | 213 | if (stream!=NULL) |
| 230 | 214 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
| 231 | 215 | |
| @@ -241,12 +225,11 @@ | ||
| 241 | 225 | } |
| 242 | 226 | |
| 243 | 227 | return ret; |
| 244 | 228 | } |
| 245 | 229 | |
| 246 | -static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) | |
| 247 | -{ | |
| 230 | +static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) { | |
| 248 | 231 | #ifdef IOWIN32_USING_WINRT_API |
| 249 | 232 | return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod); |
| 250 | 233 | #else |
| 251 | 234 | LONG lHigh = pos.HighPart; |
| 252 | 235 | DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, dwMoveMethod); |
| @@ -261,12 +244,11 @@ | ||
| 261 | 244 | } |
| 262 | 245 | return fOk; |
| 263 | 246 | #endif |
| 264 | 247 | } |
| 265 | 248 | |
| 266 | -long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream) | |
| 267 | -{ | |
| 249 | +long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) { | |
| 268 | 250 | long ret=-1; |
| 269 | 251 | HANDLE hFile = NULL; |
| 270 | 252 | if (stream!=NULL) |
| 271 | 253 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
| 272 | 254 | if (hFile != NULL) |
| @@ -284,12 +266,11 @@ | ||
| 284 | 266 | ret=(long)pos.LowPart; |
| 285 | 267 | } |
| 286 | 268 | return ret; |
| 287 | 269 | } |
| 288 | 270 | |
| 289 | -ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream) | |
| 290 | -{ | |
| 271 | +ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) { | |
| 291 | 272 | ZPOS64_T ret= (ZPOS64_T)-1; |
| 292 | 273 | HANDLE hFile = NULL; |
| 293 | 274 | if (stream!=NULL) |
| 294 | 275 | hFile = ((WIN32FILE_IOWIN*)stream)->hf; |
| 295 | 276 | |
| @@ -309,12 +290,11 @@ | ||
| 309 | 290 | } |
| 310 | 291 | return ret; |
| 311 | 292 | } |
| 312 | 293 | |
| 313 | 294 | |
| 314 | -long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin) | |
| 315 | -{ | |
| 295 | +long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) { | |
| 316 | 296 | DWORD dwMoveMethod=0xFFFFFFFF; |
| 317 | 297 | HANDLE hFile = NULL; |
| 318 | 298 | |
| 319 | 299 | long ret=-1; |
| 320 | 300 | if (stream!=NULL) |
| @@ -347,12 +327,11 @@ | ||
| 347 | 327 | ret=0; |
| 348 | 328 | } |
| 349 | 329 | return ret; |
| 350 | 330 | } |
| 351 | 331 | |
| 352 | -long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin) | |
| 353 | -{ | |
| 332 | +long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) { | |
| 354 | 333 | DWORD dwMoveMethod=0xFFFFFFFF; |
| 355 | 334 | HANDLE hFile = NULL; |
| 356 | 335 | long ret=-1; |
| 357 | 336 | |
| 358 | 337 | if (stream!=NULL) |
| @@ -386,12 +365,11 @@ | ||
| 386 | 365 | ret=0; |
| 387 | 366 | } |
| 388 | 367 | return ret; |
| 389 | 368 | } |
| 390 | 369 | |
| 391 | -int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream) | |
| 392 | -{ | |
| 370 | +int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) { | |
| 393 | 371 | int ret=-1; |
| 394 | 372 | |
| 395 | 373 | if (stream!=NULL) |
| 396 | 374 | { |
| 397 | 375 | HANDLE hFile; |
| @@ -404,22 +382,20 @@ | ||
| 404 | 382 | free(stream); |
| 405 | 383 | } |
| 406 | 384 | return ret; |
| 407 | 385 | } |
| 408 | 386 | |
| 409 | -int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream) | |
| 410 | -{ | |
| 387 | +int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) { | |
| 411 | 388 | int ret=-1; |
| 412 | 389 | if (stream!=NULL) |
| 413 | 390 | { |
| 414 | 391 | ret = ((WIN32FILE_IOWIN*)stream) -> error; |
| 415 | 392 | } |
| 416 | 393 | return ret; |
| 417 | 394 | } |
| 418 | 395 | |
| 419 | -void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def) | |
| 420 | -{ | |
| 396 | +void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def) { | |
| 421 | 397 | pzlib_filefunc_def->zopen_file = win32_open_file_func; |
| 422 | 398 | pzlib_filefunc_def->zread_file = win32_read_file_func; |
| 423 | 399 | pzlib_filefunc_def->zwrite_file = win32_write_file_func; |
| 424 | 400 | pzlib_filefunc_def->ztell_file = win32_tell_file_func; |
| 425 | 401 | pzlib_filefunc_def->zseek_file = win32_seek_file_func; |
| @@ -426,12 +402,11 @@ | ||
| 426 | 402 | pzlib_filefunc_def->zclose_file = win32_close_file_func; |
| 427 | 403 | pzlib_filefunc_def->zerror_file = win32_error_file_func; |
| 428 | 404 | pzlib_filefunc_def->opaque = NULL; |
| 429 | 405 | } |
| 430 | 406 | |
| 431 | -void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) | |
| 432 | -{ | |
| 407 | +void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) { | |
| 433 | 408 | pzlib_filefunc_def->zopen64_file = win32_open64_file_func; |
| 434 | 409 | pzlib_filefunc_def->zread_file = win32_read_file_func; |
| 435 | 410 | pzlib_filefunc_def->zwrite_file = win32_write_file_func; |
| 436 | 411 | pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; |
| 437 | 412 | pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; |
| @@ -439,12 +414,11 @@ | ||
| 439 | 414 | pzlib_filefunc_def->zerror_file = win32_error_file_func; |
| 440 | 415 | pzlib_filefunc_def->opaque = NULL; |
| 441 | 416 | } |
| 442 | 417 | |
| 443 | 418 | |
| 444 | -void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) | |
| 445 | -{ | |
| 419 | +void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) { | |
| 446 | 420 | pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA; |
| 447 | 421 | pzlib_filefunc_def->zread_file = win32_read_file_func; |
| 448 | 422 | pzlib_filefunc_def->zwrite_file = win32_write_file_func; |
| 449 | 423 | pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; |
| 450 | 424 | pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; |
| @@ -452,16 +426,15 @@ | ||
| 452 | 426 | pzlib_filefunc_def->zerror_file = win32_error_file_func; |
| 453 | 427 | pzlib_filefunc_def->opaque = NULL; |
| 454 | 428 | } |
| 455 | 429 | |
| 456 | 430 | |
| 457 | -void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) | |
| 458 | -{ | |
| 431 | +void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) { | |
| 459 | 432 | pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW; |
| 460 | 433 | pzlib_filefunc_def->zread_file = win32_read_file_func; |
| 461 | 434 | pzlib_filefunc_def->zwrite_file = win32_write_file_func; |
| 462 | 435 | pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; |
| 463 | 436 | pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; |
| 464 | 437 | pzlib_filefunc_def->zclose_file = win32_close_file_func; |
| 465 | 438 | pzlib_filefunc_def->zerror_file = win32_error_file_func; |
| 466 | 439 | pzlib_filefunc_def->opaque = NULL; |
| 467 | 440 | } |
| 468 | 441 |
| --- compat/zlib/contrib/minizip/iowin32.c | |
| +++ compat/zlib/contrib/minizip/iowin32.c | |
| @@ -36,18 +36,10 @@ | |
| 36 | #if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP) |
| 37 | #define IOWIN32_USING_WINRT_API 1 |
| 38 | #endif |
| 39 | #endif |
| 40 | |
| 41 | voidpf ZCALLBACK win32_open_file_func OF((voidpf opaque, const char* filename, int mode)); |
| 42 | uLong ZCALLBACK win32_read_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); |
| 43 | uLong ZCALLBACK win32_write_file_func OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); |
| 44 | ZPOS64_T ZCALLBACK win32_tell64_file_func OF((voidpf opaque, voidpf stream)); |
| 45 | long ZCALLBACK win32_seek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); |
| 46 | int ZCALLBACK win32_close_file_func OF((voidpf opaque, voidpf stream)); |
| 47 | int ZCALLBACK win32_error_file_func OF((voidpf opaque, voidpf stream)); |
| 48 | |
| 49 | typedef struct |
| 50 | { |
| 51 | HANDLE hf; |
| 52 | int error; |
| 53 | } WIN32FILE_IOWIN; |
| @@ -55,12 +47,11 @@ | |
| 55 | |
| 56 | static void win32_translate_open_mode(int mode, |
| 57 | DWORD* lpdwDesiredAccess, |
| 58 | DWORD* lpdwCreationDisposition, |
| 59 | DWORD* lpdwShareMode, |
| 60 | DWORD* lpdwFlagsAndAttributes) |
| 61 | { |
| 62 | *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0; |
| 63 | |
| 64 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) |
| 65 | { |
| 66 | *lpdwDesiredAccess = GENERIC_READ; |
| @@ -77,12 +68,11 @@ | |
| 77 | *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ; |
| 78 | *lpdwCreationDisposition = CREATE_ALWAYS; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | static voidpf win32_build_iowin(HANDLE hFile) |
| 83 | { |
| 84 | voidpf ret=NULL; |
| 85 | |
| 86 | if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE)) |
| 87 | { |
| 88 | WIN32FILE_IOWIN w32fiow; |
| @@ -96,12 +86,11 @@ | |
| 96 | *((WIN32FILE_IOWIN*)ret) = w32fiow; |
| 97 | } |
| 98 | return ret; |
| 99 | } |
| 100 | |
| 101 | voidpf ZCALLBACK win32_open64_file_func (voidpf opaque,const void* filename,int mode) |
| 102 | { |
| 103 | const char* mode_fopen = NULL; |
| 104 | DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; |
| 105 | HANDLE hFile = NULL; |
| 106 | |
| 107 | win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
| @@ -125,12 +114,11 @@ | |
| 125 | |
| 126 | return win32_build_iowin(hFile); |
| 127 | } |
| 128 | |
| 129 | |
| 130 | voidpf ZCALLBACK win32_open64_file_funcA (voidpf opaque,const void* filename,int mode) |
| 131 | { |
| 132 | const char* mode_fopen = NULL; |
| 133 | DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; |
| 134 | HANDLE hFile = NULL; |
| 135 | |
| 136 | win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
| @@ -149,12 +137,11 @@ | |
| 149 | |
| 150 | return win32_build_iowin(hFile); |
| 151 | } |
| 152 | |
| 153 | |
| 154 | voidpf ZCALLBACK win32_open64_file_funcW (voidpf opaque,const void* filename,int mode) |
| 155 | { |
| 156 | const char* mode_fopen = NULL; |
| 157 | DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; |
| 158 | HANDLE hFile = NULL; |
| 159 | |
| 160 | win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
| @@ -169,12 +156,11 @@ | |
| 169 | |
| 170 | return win32_build_iowin(hFile); |
| 171 | } |
| 172 | |
| 173 | |
| 174 | voidpf ZCALLBACK win32_open_file_func (voidpf opaque,const char* filename,int mode) |
| 175 | { |
| 176 | const char* mode_fopen = NULL; |
| 177 | DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; |
| 178 | HANDLE hFile = NULL; |
| 179 | |
| 180 | win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
| @@ -198,12 +184,11 @@ | |
| 198 | |
| 199 | return win32_build_iowin(hFile); |
| 200 | } |
| 201 | |
| 202 | |
| 203 | uLong ZCALLBACK win32_read_file_func (voidpf opaque, voidpf stream, void* buf,uLong size) |
| 204 | { |
| 205 | uLong ret=0; |
| 206 | HANDLE hFile = NULL; |
| 207 | if (stream!=NULL) |
| 208 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
| 209 | |
| @@ -220,12 +205,11 @@ | |
| 220 | |
| 221 | return ret; |
| 222 | } |
| 223 | |
| 224 | |
| 225 | uLong ZCALLBACK win32_write_file_func (voidpf opaque,voidpf stream,const void* buf,uLong size) |
| 226 | { |
| 227 | uLong ret=0; |
| 228 | HANDLE hFile = NULL; |
| 229 | if (stream!=NULL) |
| 230 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
| 231 | |
| @@ -241,12 +225,11 @@ | |
| 241 | } |
| 242 | |
| 243 | return ret; |
| 244 | } |
| 245 | |
| 246 | static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) |
| 247 | { |
| 248 | #ifdef IOWIN32_USING_WINRT_API |
| 249 | return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod); |
| 250 | #else |
| 251 | LONG lHigh = pos.HighPart; |
| 252 | DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, dwMoveMethod); |
| @@ -261,12 +244,11 @@ | |
| 261 | } |
| 262 | return fOk; |
| 263 | #endif |
| 264 | } |
| 265 | |
| 266 | long ZCALLBACK win32_tell_file_func (voidpf opaque,voidpf stream) |
| 267 | { |
| 268 | long ret=-1; |
| 269 | HANDLE hFile = NULL; |
| 270 | if (stream!=NULL) |
| 271 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
| 272 | if (hFile != NULL) |
| @@ -284,12 +266,11 @@ | |
| 284 | ret=(long)pos.LowPart; |
| 285 | } |
| 286 | return ret; |
| 287 | } |
| 288 | |
| 289 | ZPOS64_T ZCALLBACK win32_tell64_file_func (voidpf opaque, voidpf stream) |
| 290 | { |
| 291 | ZPOS64_T ret= (ZPOS64_T)-1; |
| 292 | HANDLE hFile = NULL; |
| 293 | if (stream!=NULL) |
| 294 | hFile = ((WIN32FILE_IOWIN*)stream)->hf; |
| 295 | |
| @@ -309,12 +290,11 @@ | |
| 309 | } |
| 310 | return ret; |
| 311 | } |
| 312 | |
| 313 | |
| 314 | long ZCALLBACK win32_seek_file_func (voidpf opaque,voidpf stream,uLong offset,int origin) |
| 315 | { |
| 316 | DWORD dwMoveMethod=0xFFFFFFFF; |
| 317 | HANDLE hFile = NULL; |
| 318 | |
| 319 | long ret=-1; |
| 320 | if (stream!=NULL) |
| @@ -347,12 +327,11 @@ | |
| 347 | ret=0; |
| 348 | } |
| 349 | return ret; |
| 350 | } |
| 351 | |
| 352 | long ZCALLBACK win32_seek64_file_func (voidpf opaque, voidpf stream,ZPOS64_T offset,int origin) |
| 353 | { |
| 354 | DWORD dwMoveMethod=0xFFFFFFFF; |
| 355 | HANDLE hFile = NULL; |
| 356 | long ret=-1; |
| 357 | |
| 358 | if (stream!=NULL) |
| @@ -386,12 +365,11 @@ | |
| 386 | ret=0; |
| 387 | } |
| 388 | return ret; |
| 389 | } |
| 390 | |
| 391 | int ZCALLBACK win32_close_file_func (voidpf opaque, voidpf stream) |
| 392 | { |
| 393 | int ret=-1; |
| 394 | |
| 395 | if (stream!=NULL) |
| 396 | { |
| 397 | HANDLE hFile; |
| @@ -404,22 +382,20 @@ | |
| 404 | free(stream); |
| 405 | } |
| 406 | return ret; |
| 407 | } |
| 408 | |
| 409 | int ZCALLBACK win32_error_file_func (voidpf opaque,voidpf stream) |
| 410 | { |
| 411 | int ret=-1; |
| 412 | if (stream!=NULL) |
| 413 | { |
| 414 | ret = ((WIN32FILE_IOWIN*)stream) -> error; |
| 415 | } |
| 416 | return ret; |
| 417 | } |
| 418 | |
| 419 | void fill_win32_filefunc (zlib_filefunc_def* pzlib_filefunc_def) |
| 420 | { |
| 421 | pzlib_filefunc_def->zopen_file = win32_open_file_func; |
| 422 | pzlib_filefunc_def->zread_file = win32_read_file_func; |
| 423 | pzlib_filefunc_def->zwrite_file = win32_write_file_func; |
| 424 | pzlib_filefunc_def->ztell_file = win32_tell_file_func; |
| 425 | pzlib_filefunc_def->zseek_file = win32_seek_file_func; |
| @@ -426,12 +402,11 @@ | |
| 426 | pzlib_filefunc_def->zclose_file = win32_close_file_func; |
| 427 | pzlib_filefunc_def->zerror_file = win32_error_file_func; |
| 428 | pzlib_filefunc_def->opaque = NULL; |
| 429 | } |
| 430 | |
| 431 | void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) |
| 432 | { |
| 433 | pzlib_filefunc_def->zopen64_file = win32_open64_file_func; |
| 434 | pzlib_filefunc_def->zread_file = win32_read_file_func; |
| 435 | pzlib_filefunc_def->zwrite_file = win32_write_file_func; |
| 436 | pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; |
| 437 | pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; |
| @@ -439,12 +414,11 @@ | |
| 439 | pzlib_filefunc_def->zerror_file = win32_error_file_func; |
| 440 | pzlib_filefunc_def->opaque = NULL; |
| 441 | } |
| 442 | |
| 443 | |
| 444 | void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) |
| 445 | { |
| 446 | pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA; |
| 447 | pzlib_filefunc_def->zread_file = win32_read_file_func; |
| 448 | pzlib_filefunc_def->zwrite_file = win32_write_file_func; |
| 449 | pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; |
| 450 | pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; |
| @@ -452,16 +426,15 @@ | |
| 452 | pzlib_filefunc_def->zerror_file = win32_error_file_func; |
| 453 | pzlib_filefunc_def->opaque = NULL; |
| 454 | } |
| 455 | |
| 456 | |
| 457 | void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) |
| 458 | { |
| 459 | pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW; |
| 460 | pzlib_filefunc_def->zread_file = win32_read_file_func; |
| 461 | pzlib_filefunc_def->zwrite_file = win32_write_file_func; |
| 462 | pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; |
| 463 | pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; |
| 464 | pzlib_filefunc_def->zclose_file = win32_close_file_func; |
| 465 | pzlib_filefunc_def->zerror_file = win32_error_file_func; |
| 466 | pzlib_filefunc_def->opaque = NULL; |
| 467 | } |
| 468 |
| --- compat/zlib/contrib/minizip/iowin32.c | |
| +++ compat/zlib/contrib/minizip/iowin32.c | |
| @@ -36,18 +36,10 @@ | |
| 36 | #if WINAPI_FAMILY_ONE_PARTITION(WINAPI_FAMILY, WINAPI_PARTITION_APP) |
| 37 | #define IOWIN32_USING_WINRT_API 1 |
| 38 | #endif |
| 39 | #endif |
| 40 | |
| 41 | typedef struct |
| 42 | { |
| 43 | HANDLE hf; |
| 44 | int error; |
| 45 | } WIN32FILE_IOWIN; |
| @@ -55,12 +47,11 @@ | |
| 47 | |
| 48 | static void win32_translate_open_mode(int mode, |
| 49 | DWORD* lpdwDesiredAccess, |
| 50 | DWORD* lpdwCreationDisposition, |
| 51 | DWORD* lpdwShareMode, |
| 52 | DWORD* lpdwFlagsAndAttributes) { |
| 53 | *lpdwDesiredAccess = *lpdwShareMode = *lpdwFlagsAndAttributes = *lpdwCreationDisposition = 0; |
| 54 | |
| 55 | if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) |
| 56 | { |
| 57 | *lpdwDesiredAccess = GENERIC_READ; |
| @@ -77,12 +68,11 @@ | |
| 68 | *lpdwDesiredAccess = GENERIC_WRITE | GENERIC_READ; |
| 69 | *lpdwCreationDisposition = CREATE_ALWAYS; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | static voidpf win32_build_iowin(HANDLE hFile) { |
| 74 | voidpf ret=NULL; |
| 75 | |
| 76 | if ((hFile != NULL) && (hFile != INVALID_HANDLE_VALUE)) |
| 77 | { |
| 78 | WIN32FILE_IOWIN w32fiow; |
| @@ -96,12 +86,11 @@ | |
| 86 | *((WIN32FILE_IOWIN*)ret) = w32fiow; |
| 87 | } |
| 88 | return ret; |
| 89 | } |
| 90 | |
| 91 | voidpf ZCALLBACK win32_open64_file_func(voidpf opaque, const void* filename, int mode) { |
| 92 | const char* mode_fopen = NULL; |
| 93 | DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; |
| 94 | HANDLE hFile = NULL; |
| 95 | |
| 96 | win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
| @@ -125,12 +114,11 @@ | |
| 114 | |
| 115 | return win32_build_iowin(hFile); |
| 116 | } |
| 117 | |
| 118 | |
| 119 | voidpf ZCALLBACK win32_open64_file_funcA(voidpf opaque, const void* filename, int mode) { |
| 120 | const char* mode_fopen = NULL; |
| 121 | DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; |
| 122 | HANDLE hFile = NULL; |
| 123 | |
| 124 | win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
| @@ -149,12 +137,11 @@ | |
| 137 | |
| 138 | return win32_build_iowin(hFile); |
| 139 | } |
| 140 | |
| 141 | |
| 142 | voidpf ZCALLBACK win32_open64_file_funcW(voidpf opaque, const void* filename, int mode) { |
| 143 | const char* mode_fopen = NULL; |
| 144 | DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; |
| 145 | HANDLE hFile = NULL; |
| 146 | |
| 147 | win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
| @@ -169,12 +156,11 @@ | |
| 156 | |
| 157 | return win32_build_iowin(hFile); |
| 158 | } |
| 159 | |
| 160 | |
| 161 | voidpf ZCALLBACK win32_open_file_func(voidpf opaque, const char* filename, int mode) { |
| 162 | const char* mode_fopen = NULL; |
| 163 | DWORD dwDesiredAccess,dwCreationDisposition,dwShareMode,dwFlagsAndAttributes ; |
| 164 | HANDLE hFile = NULL; |
| 165 | |
| 166 | win32_translate_open_mode(mode,&dwDesiredAccess,&dwCreationDisposition,&dwShareMode,&dwFlagsAndAttributes); |
| @@ -198,12 +184,11 @@ | |
| 184 | |
| 185 | return win32_build_iowin(hFile); |
| 186 | } |
| 187 | |
| 188 | |
| 189 | uLong ZCALLBACK win32_read_file_func(voidpf opaque, voidpf stream, void* buf,uLong size) { |
| 190 | uLong ret=0; |
| 191 | HANDLE hFile = NULL; |
| 192 | if (stream!=NULL) |
| 193 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
| 194 | |
| @@ -220,12 +205,11 @@ | |
| 205 | |
| 206 | return ret; |
| 207 | } |
| 208 | |
| 209 | |
| 210 | uLong ZCALLBACK win32_write_file_func(voidpf opaque, voidpf stream, const void* buf, uLong size) { |
| 211 | uLong ret=0; |
| 212 | HANDLE hFile = NULL; |
| 213 | if (stream!=NULL) |
| 214 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
| 215 | |
| @@ -241,12 +225,11 @@ | |
| 225 | } |
| 226 | |
| 227 | return ret; |
| 228 | } |
| 229 | |
| 230 | static BOOL MySetFilePointerEx(HANDLE hFile, LARGE_INTEGER pos, LARGE_INTEGER *newPos, DWORD dwMoveMethod) { |
| 231 | #ifdef IOWIN32_USING_WINRT_API |
| 232 | return SetFilePointerEx(hFile, pos, newPos, dwMoveMethod); |
| 233 | #else |
| 234 | LONG lHigh = pos.HighPart; |
| 235 | DWORD dwNewPos = SetFilePointer(hFile, pos.LowPart, &lHigh, dwMoveMethod); |
| @@ -261,12 +244,11 @@ | |
| 244 | } |
| 245 | return fOk; |
| 246 | #endif |
| 247 | } |
| 248 | |
| 249 | long ZCALLBACK win32_tell_file_func(voidpf opaque, voidpf stream) { |
| 250 | long ret=-1; |
| 251 | HANDLE hFile = NULL; |
| 252 | if (stream!=NULL) |
| 253 | hFile = ((WIN32FILE_IOWIN*)stream) -> hf; |
| 254 | if (hFile != NULL) |
| @@ -284,12 +266,11 @@ | |
| 266 | ret=(long)pos.LowPart; |
| 267 | } |
| 268 | return ret; |
| 269 | } |
| 270 | |
| 271 | ZPOS64_T ZCALLBACK win32_tell64_file_func(voidpf opaque, voidpf stream) { |
| 272 | ZPOS64_T ret= (ZPOS64_T)-1; |
| 273 | HANDLE hFile = NULL; |
| 274 | if (stream!=NULL) |
| 275 | hFile = ((WIN32FILE_IOWIN*)stream)->hf; |
| 276 | |
| @@ -309,12 +290,11 @@ | |
| 290 | } |
| 291 | return ret; |
| 292 | } |
| 293 | |
| 294 | |
| 295 | long ZCALLBACK win32_seek_file_func(voidpf opaque, voidpf stream, uLong offset, int origin) { |
| 296 | DWORD dwMoveMethod=0xFFFFFFFF; |
| 297 | HANDLE hFile = NULL; |
| 298 | |
| 299 | long ret=-1; |
| 300 | if (stream!=NULL) |
| @@ -347,12 +327,11 @@ | |
| 327 | ret=0; |
| 328 | } |
| 329 | return ret; |
| 330 | } |
| 331 | |
| 332 | long ZCALLBACK win32_seek64_file_func(voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) { |
| 333 | DWORD dwMoveMethod=0xFFFFFFFF; |
| 334 | HANDLE hFile = NULL; |
| 335 | long ret=-1; |
| 336 | |
| 337 | if (stream!=NULL) |
| @@ -386,12 +365,11 @@ | |
| 365 | ret=0; |
| 366 | } |
| 367 | return ret; |
| 368 | } |
| 369 | |
| 370 | int ZCALLBACK win32_close_file_func(voidpf opaque, voidpf stream) { |
| 371 | int ret=-1; |
| 372 | |
| 373 | if (stream!=NULL) |
| 374 | { |
| 375 | HANDLE hFile; |
| @@ -404,22 +382,20 @@ | |
| 382 | free(stream); |
| 383 | } |
| 384 | return ret; |
| 385 | } |
| 386 | |
| 387 | int ZCALLBACK win32_error_file_func(voidpf opaque, voidpf stream) { |
| 388 | int ret=-1; |
| 389 | if (stream!=NULL) |
| 390 | { |
| 391 | ret = ((WIN32FILE_IOWIN*)stream) -> error; |
| 392 | } |
| 393 | return ret; |
| 394 | } |
| 395 | |
| 396 | void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def) { |
| 397 | pzlib_filefunc_def->zopen_file = win32_open_file_func; |
| 398 | pzlib_filefunc_def->zread_file = win32_read_file_func; |
| 399 | pzlib_filefunc_def->zwrite_file = win32_write_file_func; |
| 400 | pzlib_filefunc_def->ztell_file = win32_tell_file_func; |
| 401 | pzlib_filefunc_def->zseek_file = win32_seek_file_func; |
| @@ -426,12 +402,11 @@ | |
| 402 | pzlib_filefunc_def->zclose_file = win32_close_file_func; |
| 403 | pzlib_filefunc_def->zerror_file = win32_error_file_func; |
| 404 | pzlib_filefunc_def->opaque = NULL; |
| 405 | } |
| 406 | |
| 407 | void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def) { |
| 408 | pzlib_filefunc_def->zopen64_file = win32_open64_file_func; |
| 409 | pzlib_filefunc_def->zread_file = win32_read_file_func; |
| 410 | pzlib_filefunc_def->zwrite_file = win32_write_file_func; |
| 411 | pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; |
| 412 | pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; |
| @@ -439,12 +414,11 @@ | |
| 414 | pzlib_filefunc_def->zerror_file = win32_error_file_func; |
| 415 | pzlib_filefunc_def->opaque = NULL; |
| 416 | } |
| 417 | |
| 418 | |
| 419 | void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def) { |
| 420 | pzlib_filefunc_def->zopen64_file = win32_open64_file_funcA; |
| 421 | pzlib_filefunc_def->zread_file = win32_read_file_func; |
| 422 | pzlib_filefunc_def->zwrite_file = win32_write_file_func; |
| 423 | pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; |
| 424 | pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; |
| @@ -452,16 +426,15 @@ | |
| 426 | pzlib_filefunc_def->zerror_file = win32_error_file_func; |
| 427 | pzlib_filefunc_def->opaque = NULL; |
| 428 | } |
| 429 | |
| 430 | |
| 431 | void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def) { |
| 432 | pzlib_filefunc_def->zopen64_file = win32_open64_file_funcW; |
| 433 | pzlib_filefunc_def->zread_file = win32_read_file_func; |
| 434 | pzlib_filefunc_def->zwrite_file = win32_write_file_func; |
| 435 | pzlib_filefunc_def->ztell64_file = win32_tell64_file_func; |
| 436 | pzlib_filefunc_def->zseek64_file = win32_seek64_file_func; |
| 437 | pzlib_filefunc_def->zclose_file = win32_close_file_func; |
| 438 | pzlib_filefunc_def->zerror_file = win32_error_file_func; |
| 439 | pzlib_filefunc_def->opaque = NULL; |
| 440 | } |
| 441 |
| --- compat/zlib/contrib/minizip/iowin32.h | ||
| +++ compat/zlib/contrib/minizip/iowin32.h | ||
| @@ -16,13 +16,13 @@ | ||
| 16 | 16 | |
| 17 | 17 | #ifdef __cplusplus |
| 18 | 18 | extern "C" { |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | -void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); | |
| 22 | -void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def)); | |
| 23 | -void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def)); | |
| 24 | -void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def)); | |
| 21 | +void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def); | |
| 22 | +void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def); | |
| 23 | +void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def); | |
| 24 | +void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def); | |
| 25 | 25 | |
| 26 | 26 | #ifdef __cplusplus |
| 27 | 27 | } |
| 28 | 28 | #endif |
| 29 | 29 |
| --- compat/zlib/contrib/minizip/iowin32.h | |
| +++ compat/zlib/contrib/minizip/iowin32.h | |
| @@ -16,13 +16,13 @@ | |
| 16 | |
| 17 | #ifdef __cplusplus |
| 18 | extern "C" { |
| 19 | #endif |
| 20 | |
| 21 | void fill_win32_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); |
| 22 | void fill_win32_filefunc64 OF((zlib_filefunc64_def* pzlib_filefunc_def)); |
| 23 | void fill_win32_filefunc64A OF((zlib_filefunc64_def* pzlib_filefunc_def)); |
| 24 | void fill_win32_filefunc64W OF((zlib_filefunc64_def* pzlib_filefunc_def)); |
| 25 | |
| 26 | #ifdef __cplusplus |
| 27 | } |
| 28 | #endif |
| 29 |
| --- compat/zlib/contrib/minizip/iowin32.h | |
| +++ compat/zlib/contrib/minizip/iowin32.h | |
| @@ -16,13 +16,13 @@ | |
| 16 | |
| 17 | #ifdef __cplusplus |
| 18 | extern "C" { |
| 19 | #endif |
| 20 | |
| 21 | void fill_win32_filefunc(zlib_filefunc_def* pzlib_filefunc_def); |
| 22 | void fill_win32_filefunc64(zlib_filefunc64_def* pzlib_filefunc_def); |
| 23 | void fill_win32_filefunc64A(zlib_filefunc64_def* pzlib_filefunc_def); |
| 24 | void fill_win32_filefunc64W(zlib_filefunc64_def* pzlib_filefunc_def); |
| 25 | |
| 26 | #ifdef __cplusplus |
| 27 | } |
| 28 | #endif |
| 29 |
+22
-48
| --- compat/zlib/contrib/minizip/miniunz.c | ||
| +++ compat/zlib/contrib/minizip/miniunz.c | ||
| @@ -25,11 +25,11 @@ | ||
| 25 | 25 | #ifndef _FILE_OFFSET_BIT |
| 26 | 26 | #define _FILE_OFFSET_BIT 64 |
| 27 | 27 | #endif |
| 28 | 28 | #endif |
| 29 | 29 | |
| 30 | -#ifdef __APPLE__ | |
| 30 | +#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) | |
| 31 | 31 | // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions |
| 32 | 32 | #define FOPEN_FUNC(filename, mode) fopen(filename, mode) |
| 33 | 33 | #define FTELLO_FUNC(stream) ftello(stream) |
| 34 | 34 | #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) |
| 35 | 35 | #else |
| @@ -79,15 +79,11 @@ | ||
| 79 | 79 | |
| 80 | 80 | /* change_file_date : change the date/time of a file |
| 81 | 81 | filename : the filename of the file where date/time must be modified |
| 82 | 82 | dosdate : the new date at the MSDos format (4 bytes) |
| 83 | 83 | tmu_date : the SAME new date at the tm_unz format */ |
| 84 | -static void change_file_date(filename,dosdate,tmu_date) | |
| 85 | - const char *filename; | |
| 86 | - uLong dosdate; | |
| 87 | - tm_unz tmu_date; | |
| 88 | -{ | |
| 84 | +static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) { | |
| 89 | 85 | #ifdef _WIN32 |
| 90 | 86 | HANDLE hFile; |
| 91 | 87 | FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; |
| 92 | 88 | |
| 93 | 89 | hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE, |
| @@ -113,35 +109,37 @@ | ||
| 113 | 109 | newdate.tm_year=tmu_date.tm_year ; |
| 114 | 110 | newdate.tm_isdst=-1; |
| 115 | 111 | |
| 116 | 112 | ut.actime=ut.modtime=mktime(&newdate); |
| 117 | 113 | utime(filename,&ut); |
| 114 | +#else | |
| 115 | + (void)filename; | |
| 116 | + (void)dosdate; | |
| 117 | + (void)tmu_date; | |
| 118 | 118 | #endif |
| 119 | 119 | #endif |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | |
| 123 | 123 | /* mymkdir and change_file_date are not 100 % portable |
| 124 | 124 | As I don't know well Unix, I wait feedback for the unix portion */ |
| 125 | 125 | |
| 126 | -static int mymkdir(dirname) | |
| 127 | - const char* dirname; | |
| 128 | -{ | |
| 126 | +static int mymkdir(const char* dirname) { | |
| 129 | 127 | int ret=0; |
| 130 | 128 | #ifdef _WIN32 |
| 131 | 129 | ret = _mkdir(dirname); |
| 132 | 130 | #elif unix |
| 133 | 131 | ret = mkdir (dirname,0775); |
| 134 | 132 | #elif __APPLE__ |
| 135 | 133 | ret = mkdir (dirname,0775); |
| 134 | +#else | |
| 135 | + (void)dirname; | |
| 136 | 136 | #endif |
| 137 | 137 | return ret; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | -static int makedir (newdir) | |
| 141 | - const char *newdir; | |
| 142 | -{ | |
| 140 | +static int makedir(const char *newdir) { | |
| 143 | 141 | char *buffer ; |
| 144 | 142 | char *p; |
| 145 | 143 | size_t len = strlen(newdir); |
| 146 | 144 | |
| 147 | 145 | if (len == 0) |
| @@ -185,30 +183,27 @@ | ||
| 185 | 183 | } |
| 186 | 184 | free(buffer); |
| 187 | 185 | return 1; |
| 188 | 186 | } |
| 189 | 187 | |
| 190 | -static void do_banner() | |
| 191 | -{ | |
| 188 | +static void do_banner(void) { | |
| 192 | 189 | printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n"); |
| 193 | 190 | printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); |
| 194 | 191 | } |
| 195 | 192 | |
| 196 | -static void do_help() | |
| 197 | -{ | |
| 193 | +static void do_help(void) { | |
| 198 | 194 | printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \ |
| 199 | 195 | " -e Extract without pathname (junk paths)\n" \ |
| 200 | 196 | " -x Extract with pathname\n" \ |
| 201 | 197 | " -v list files\n" \ |
| 202 | 198 | " -l list files\n" \ |
| 203 | 199 | " -d directory to extract into\n" \ |
| 204 | 200 | " -o overwrite files without prompting\n" \ |
| 205 | - " -p extract crypted file using password\n\n"); | |
| 201 | + " -p extract encrypted file using password\n\n"); | |
| 206 | 202 | } |
| 207 | 203 | |
| 208 | -static void Display64BitsSize(ZPOS64_T n, int size_char) | |
| 209 | -{ | |
| 204 | +static void Display64BitsSize(ZPOS64_T n, int size_char) { | |
| 210 | 205 | /* to avoid compatibility problem , we do here the conversion */ |
| 211 | 206 | char number[21]; |
| 212 | 207 | int offset=19; |
| 213 | 208 | int pos_string = 19; |
| 214 | 209 | number[20]=0; |
| @@ -231,13 +226,11 @@ | ||
| 231 | 226 | } |
| 232 | 227 | |
| 233 | 228 | printf("%s",&number[pos_string]); |
| 234 | 229 | } |
| 235 | 230 | |
| 236 | -static int do_list(uf) | |
| 237 | - unzFile uf; | |
| 238 | -{ | |
| 231 | +static int do_list(unzFile uf) { | |
| 239 | 232 | uLong i; |
| 240 | 233 | unz_global_info64 gi; |
| 241 | 234 | int err; |
| 242 | 235 | |
| 243 | 236 | err = unzGetGlobalInfo64(uf,&gi); |
| @@ -248,11 +241,11 @@ | ||
| 248 | 241 | for (i=0;i<gi.number_entry;i++) |
| 249 | 242 | { |
| 250 | 243 | char filename_inzip[256]; |
| 251 | 244 | unz_file_info64 file_info; |
| 252 | 245 | uLong ratio=0; |
| 253 | - const char *string_method; | |
| 246 | + const char *string_method = ""; | |
| 254 | 247 | char charCrypt=' '; |
| 255 | 248 | err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); |
| 256 | 249 | if (err!=UNZ_OK) |
| 257 | 250 | { |
| 258 | 251 | printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); |
| @@ -259,11 +252,11 @@ | ||
| 259 | 252 | break; |
| 260 | 253 | } |
| 261 | 254 | if (file_info.uncompressed_size>0) |
| 262 | 255 | ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size); |
| 263 | 256 | |
| 264 | - /* display a '*' if the file is crypted */ | |
| 257 | + /* display a '*' if the file is encrypted */ | |
| 265 | 258 | if ((file_info.flag & 1) != 0) |
| 266 | 259 | charCrypt='*'; |
| 267 | 260 | |
| 268 | 261 | if (file_info.compression_method==0) |
| 269 | 262 | string_method="Stored"; |
| @@ -309,16 +302,11 @@ | ||
| 309 | 302 | |
| 310 | 303 | return 0; |
| 311 | 304 | } |
| 312 | 305 | |
| 313 | 306 | |
| 314 | -static int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password) | |
| 315 | - unzFile uf; | |
| 316 | - const int* popt_extract_without_path; | |
| 317 | - int* popt_overwrite; | |
| 318 | - const char* password; | |
| 319 | -{ | |
| 307 | +static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password) { | |
| 320 | 308 | char filename_inzip[256]; |
| 321 | 309 | char* filename_withoutpath; |
| 322 | 310 | char* p; |
| 323 | 311 | int err=UNZ_OK; |
| 324 | 312 | FILE *fout=NULL; |
| @@ -471,16 +459,11 @@ | ||
| 471 | 459 | free(buf); |
| 472 | 460 | return err; |
| 473 | 461 | } |
| 474 | 462 | |
| 475 | 463 | |
| 476 | -static int do_extract(uf,opt_extract_without_path,opt_overwrite,password) | |
| 477 | - unzFile uf; | |
| 478 | - int opt_extract_without_path; | |
| 479 | - int opt_overwrite; | |
| 480 | - const char* password; | |
| 481 | -{ | |
| 464 | +static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password) { | |
| 482 | 465 | uLong i; |
| 483 | 466 | unz_global_info64 gi; |
| 484 | 467 | int err; |
| 485 | 468 | |
| 486 | 469 | err = unzGetGlobalInfo64(uf,&gi); |
| @@ -506,17 +489,11 @@ | ||
| 506 | 489 | } |
| 507 | 490 | |
| 508 | 491 | return 0; |
| 509 | 492 | } |
| 510 | 493 | |
| 511 | -static int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password) | |
| 512 | - unzFile uf; | |
| 513 | - const char* filename; | |
| 514 | - int opt_extract_without_path; | |
| 515 | - int opt_overwrite; | |
| 516 | - const char* password; | |
| 517 | -{ | |
| 494 | +static int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_without_path, int opt_overwrite, const char* password) { | |
| 518 | 495 | if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK) |
| 519 | 496 | { |
| 520 | 497 | printf("file %s not found in the zipfile\n",filename); |
| 521 | 498 | return 2; |
| 522 | 499 | } |
| @@ -528,14 +505,11 @@ | ||
| 528 | 505 | else |
| 529 | 506 | return 1; |
| 530 | 507 | } |
| 531 | 508 | |
| 532 | 509 | |
| 533 | -int main(argc,argv) | |
| 534 | - int argc; | |
| 535 | - char *argv[]; | |
| 536 | -{ | |
| 510 | +int main(int argc, char *argv[]) { | |
| 537 | 511 | const char *zipfilename=NULL; |
| 538 | 512 | const char *filename_to_extract=NULL; |
| 539 | 513 | const char *password=NULL; |
| 540 | 514 | char filename_try[MAXFILENAME+16] = ""; |
| 541 | 515 | int i; |
| @@ -604,11 +578,11 @@ | ||
| 604 | 578 | # ifdef USEWIN32IOAPI |
| 605 | 579 | zlib_filefunc64_def ffunc; |
| 606 | 580 | # endif |
| 607 | 581 | |
| 608 | 582 | strncpy(filename_try, zipfilename,MAXFILENAME-1); |
| 609 | - /* strncpy doesnt append the trailing NULL, of the string is too long. */ | |
| 583 | + /* strncpy doesn't append the trailing NULL, of the string is too long. */ | |
| 610 | 584 | filename_try[ MAXFILENAME ] = '\0'; |
| 611 | 585 | |
| 612 | 586 | # ifdef USEWIN32IOAPI |
| 613 | 587 | fill_win32_filefunc64A(&ffunc); |
| 614 | 588 | uf = unzOpen2_64(zipfilename,&ffunc); |
| 615 | 589 |
| --- compat/zlib/contrib/minizip/miniunz.c | |
| +++ compat/zlib/contrib/minizip/miniunz.c | |
| @@ -25,11 +25,11 @@ | |
| 25 | #ifndef _FILE_OFFSET_BIT |
| 26 | #define _FILE_OFFSET_BIT 64 |
| 27 | #endif |
| 28 | #endif |
| 29 | |
| 30 | #ifdef __APPLE__ |
| 31 | // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions |
| 32 | #define FOPEN_FUNC(filename, mode) fopen(filename, mode) |
| 33 | #define FTELLO_FUNC(stream) ftello(stream) |
| 34 | #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) |
| 35 | #else |
| @@ -79,15 +79,11 @@ | |
| 79 | |
| 80 | /* change_file_date : change the date/time of a file |
| 81 | filename : the filename of the file where date/time must be modified |
| 82 | dosdate : the new date at the MSDos format (4 bytes) |
| 83 | tmu_date : the SAME new date at the tm_unz format */ |
| 84 | static void change_file_date(filename,dosdate,tmu_date) |
| 85 | const char *filename; |
| 86 | uLong dosdate; |
| 87 | tm_unz tmu_date; |
| 88 | { |
| 89 | #ifdef _WIN32 |
| 90 | HANDLE hFile; |
| 91 | FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; |
| 92 | |
| 93 | hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE, |
| @@ -113,35 +109,37 @@ | |
| 113 | newdate.tm_year=tmu_date.tm_year ; |
| 114 | newdate.tm_isdst=-1; |
| 115 | |
| 116 | ut.actime=ut.modtime=mktime(&newdate); |
| 117 | utime(filename,&ut); |
| 118 | #endif |
| 119 | #endif |
| 120 | } |
| 121 | |
| 122 | |
| 123 | /* mymkdir and change_file_date are not 100 % portable |
| 124 | As I don't know well Unix, I wait feedback for the unix portion */ |
| 125 | |
| 126 | static int mymkdir(dirname) |
| 127 | const char* dirname; |
| 128 | { |
| 129 | int ret=0; |
| 130 | #ifdef _WIN32 |
| 131 | ret = _mkdir(dirname); |
| 132 | #elif unix |
| 133 | ret = mkdir (dirname,0775); |
| 134 | #elif __APPLE__ |
| 135 | ret = mkdir (dirname,0775); |
| 136 | #endif |
| 137 | return ret; |
| 138 | } |
| 139 | |
| 140 | static int makedir (newdir) |
| 141 | const char *newdir; |
| 142 | { |
| 143 | char *buffer ; |
| 144 | char *p; |
| 145 | size_t len = strlen(newdir); |
| 146 | |
| 147 | if (len == 0) |
| @@ -185,30 +183,27 @@ | |
| 185 | } |
| 186 | free(buffer); |
| 187 | return 1; |
| 188 | } |
| 189 | |
| 190 | static void do_banner() |
| 191 | { |
| 192 | printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n"); |
| 193 | printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); |
| 194 | } |
| 195 | |
| 196 | static void do_help() |
| 197 | { |
| 198 | printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \ |
| 199 | " -e Extract without pathname (junk paths)\n" \ |
| 200 | " -x Extract with pathname\n" \ |
| 201 | " -v list files\n" \ |
| 202 | " -l list files\n" \ |
| 203 | " -d directory to extract into\n" \ |
| 204 | " -o overwrite files without prompting\n" \ |
| 205 | " -p extract crypted file using password\n\n"); |
| 206 | } |
| 207 | |
| 208 | static void Display64BitsSize(ZPOS64_T n, int size_char) |
| 209 | { |
| 210 | /* to avoid compatibility problem , we do here the conversion */ |
| 211 | char number[21]; |
| 212 | int offset=19; |
| 213 | int pos_string = 19; |
| 214 | number[20]=0; |
| @@ -231,13 +226,11 @@ | |
| 231 | } |
| 232 | |
| 233 | printf("%s",&number[pos_string]); |
| 234 | } |
| 235 | |
| 236 | static int do_list(uf) |
| 237 | unzFile uf; |
| 238 | { |
| 239 | uLong i; |
| 240 | unz_global_info64 gi; |
| 241 | int err; |
| 242 | |
| 243 | err = unzGetGlobalInfo64(uf,&gi); |
| @@ -248,11 +241,11 @@ | |
| 248 | for (i=0;i<gi.number_entry;i++) |
| 249 | { |
| 250 | char filename_inzip[256]; |
| 251 | unz_file_info64 file_info; |
| 252 | uLong ratio=0; |
| 253 | const char *string_method; |
| 254 | char charCrypt=' '; |
| 255 | err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); |
| 256 | if (err!=UNZ_OK) |
| 257 | { |
| 258 | printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); |
| @@ -259,11 +252,11 @@ | |
| 259 | break; |
| 260 | } |
| 261 | if (file_info.uncompressed_size>0) |
| 262 | ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size); |
| 263 | |
| 264 | /* display a '*' if the file is crypted */ |
| 265 | if ((file_info.flag & 1) != 0) |
| 266 | charCrypt='*'; |
| 267 | |
| 268 | if (file_info.compression_method==0) |
| 269 | string_method="Stored"; |
| @@ -309,16 +302,11 @@ | |
| 309 | |
| 310 | return 0; |
| 311 | } |
| 312 | |
| 313 | |
| 314 | static int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password) |
| 315 | unzFile uf; |
| 316 | const int* popt_extract_without_path; |
| 317 | int* popt_overwrite; |
| 318 | const char* password; |
| 319 | { |
| 320 | char filename_inzip[256]; |
| 321 | char* filename_withoutpath; |
| 322 | char* p; |
| 323 | int err=UNZ_OK; |
| 324 | FILE *fout=NULL; |
| @@ -471,16 +459,11 @@ | |
| 471 | free(buf); |
| 472 | return err; |
| 473 | } |
| 474 | |
| 475 | |
| 476 | static int do_extract(uf,opt_extract_without_path,opt_overwrite,password) |
| 477 | unzFile uf; |
| 478 | int opt_extract_without_path; |
| 479 | int opt_overwrite; |
| 480 | const char* password; |
| 481 | { |
| 482 | uLong i; |
| 483 | unz_global_info64 gi; |
| 484 | int err; |
| 485 | |
| 486 | err = unzGetGlobalInfo64(uf,&gi); |
| @@ -506,17 +489,11 @@ | |
| 506 | } |
| 507 | |
| 508 | return 0; |
| 509 | } |
| 510 | |
| 511 | static int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password) |
| 512 | unzFile uf; |
| 513 | const char* filename; |
| 514 | int opt_extract_without_path; |
| 515 | int opt_overwrite; |
| 516 | const char* password; |
| 517 | { |
| 518 | if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK) |
| 519 | { |
| 520 | printf("file %s not found in the zipfile\n",filename); |
| 521 | return 2; |
| 522 | } |
| @@ -528,14 +505,11 @@ | |
| 528 | else |
| 529 | return 1; |
| 530 | } |
| 531 | |
| 532 | |
| 533 | int main(argc,argv) |
| 534 | int argc; |
| 535 | char *argv[]; |
| 536 | { |
| 537 | const char *zipfilename=NULL; |
| 538 | const char *filename_to_extract=NULL; |
| 539 | const char *password=NULL; |
| 540 | char filename_try[MAXFILENAME+16] = ""; |
| 541 | int i; |
| @@ -604,11 +578,11 @@ | |
| 604 | # ifdef USEWIN32IOAPI |
| 605 | zlib_filefunc64_def ffunc; |
| 606 | # endif |
| 607 | |
| 608 | strncpy(filename_try, zipfilename,MAXFILENAME-1); |
| 609 | /* strncpy doesnt append the trailing NULL, of the string is too long. */ |
| 610 | filename_try[ MAXFILENAME ] = '\0'; |
| 611 | |
| 612 | # ifdef USEWIN32IOAPI |
| 613 | fill_win32_filefunc64A(&ffunc); |
| 614 | uf = unzOpen2_64(zipfilename,&ffunc); |
| 615 |
| --- compat/zlib/contrib/minizip/miniunz.c | |
| +++ compat/zlib/contrib/minizip/miniunz.c | |
| @@ -25,11 +25,11 @@ | |
| 25 | #ifndef _FILE_OFFSET_BIT |
| 26 | #define _FILE_OFFSET_BIT 64 |
| 27 | #endif |
| 28 | #endif |
| 29 | |
| 30 | #if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) |
| 31 | // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions |
| 32 | #define FOPEN_FUNC(filename, mode) fopen(filename, mode) |
| 33 | #define FTELLO_FUNC(stream) ftello(stream) |
| 34 | #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) |
| 35 | #else |
| @@ -79,15 +79,11 @@ | |
| 79 | |
| 80 | /* change_file_date : change the date/time of a file |
| 81 | filename : the filename of the file where date/time must be modified |
| 82 | dosdate : the new date at the MSDos format (4 bytes) |
| 83 | tmu_date : the SAME new date at the tm_unz format */ |
| 84 | static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) { |
| 85 | #ifdef _WIN32 |
| 86 | HANDLE hFile; |
| 87 | FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite; |
| 88 | |
| 89 | hFile = CreateFileA(filename,GENERIC_READ | GENERIC_WRITE, |
| @@ -113,35 +109,37 @@ | |
| 109 | newdate.tm_year=tmu_date.tm_year ; |
| 110 | newdate.tm_isdst=-1; |
| 111 | |
| 112 | ut.actime=ut.modtime=mktime(&newdate); |
| 113 | utime(filename,&ut); |
| 114 | #else |
| 115 | (void)filename; |
| 116 | (void)dosdate; |
| 117 | (void)tmu_date; |
| 118 | #endif |
| 119 | #endif |
| 120 | } |
| 121 | |
| 122 | |
| 123 | /* mymkdir and change_file_date are not 100 % portable |
| 124 | As I don't know well Unix, I wait feedback for the unix portion */ |
| 125 | |
| 126 | static int mymkdir(const char* dirname) { |
| 127 | int ret=0; |
| 128 | #ifdef _WIN32 |
| 129 | ret = _mkdir(dirname); |
| 130 | #elif unix |
| 131 | ret = mkdir (dirname,0775); |
| 132 | #elif __APPLE__ |
| 133 | ret = mkdir (dirname,0775); |
| 134 | #else |
| 135 | (void)dirname; |
| 136 | #endif |
| 137 | return ret; |
| 138 | } |
| 139 | |
| 140 | static int makedir(const char *newdir) { |
| 141 | char *buffer ; |
| 142 | char *p; |
| 143 | size_t len = strlen(newdir); |
| 144 | |
| 145 | if (len == 0) |
| @@ -185,30 +183,27 @@ | |
| 183 | } |
| 184 | free(buffer); |
| 185 | return 1; |
| 186 | } |
| 187 | |
| 188 | static void do_banner(void) { |
| 189 | printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n"); |
| 190 | printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n"); |
| 191 | } |
| 192 | |
| 193 | static void do_help(void) { |
| 194 | printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \ |
| 195 | " -e Extract without pathname (junk paths)\n" \ |
| 196 | " -x Extract with pathname\n" \ |
| 197 | " -v list files\n" \ |
| 198 | " -l list files\n" \ |
| 199 | " -d directory to extract into\n" \ |
| 200 | " -o overwrite files without prompting\n" \ |
| 201 | " -p extract encrypted file using password\n\n"); |
| 202 | } |
| 203 | |
| 204 | static void Display64BitsSize(ZPOS64_T n, int size_char) { |
| 205 | /* to avoid compatibility problem , we do here the conversion */ |
| 206 | char number[21]; |
| 207 | int offset=19; |
| 208 | int pos_string = 19; |
| 209 | number[20]=0; |
| @@ -231,13 +226,11 @@ | |
| 226 | } |
| 227 | |
| 228 | printf("%s",&number[pos_string]); |
| 229 | } |
| 230 | |
| 231 | static int do_list(unzFile uf) { |
| 232 | uLong i; |
| 233 | unz_global_info64 gi; |
| 234 | int err; |
| 235 | |
| 236 | err = unzGetGlobalInfo64(uf,&gi); |
| @@ -248,11 +241,11 @@ | |
| 241 | for (i=0;i<gi.number_entry;i++) |
| 242 | { |
| 243 | char filename_inzip[256]; |
| 244 | unz_file_info64 file_info; |
| 245 | uLong ratio=0; |
| 246 | const char *string_method = ""; |
| 247 | char charCrypt=' '; |
| 248 | err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0); |
| 249 | if (err!=UNZ_OK) |
| 250 | { |
| 251 | printf("error %d with zipfile in unzGetCurrentFileInfo\n",err); |
| @@ -259,11 +252,11 @@ | |
| 252 | break; |
| 253 | } |
| 254 | if (file_info.uncompressed_size>0) |
| 255 | ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size); |
| 256 | |
| 257 | /* display a '*' if the file is encrypted */ |
| 258 | if ((file_info.flag & 1) != 0) |
| 259 | charCrypt='*'; |
| 260 | |
| 261 | if (file_info.compression_method==0) |
| 262 | string_method="Stored"; |
| @@ -309,16 +302,11 @@ | |
| 302 | |
| 303 | return 0; |
| 304 | } |
| 305 | |
| 306 | |
| 307 | static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password) { |
| 308 | char filename_inzip[256]; |
| 309 | char* filename_withoutpath; |
| 310 | char* p; |
| 311 | int err=UNZ_OK; |
| 312 | FILE *fout=NULL; |
| @@ -471,16 +459,11 @@ | |
| 459 | free(buf); |
| 460 | return err; |
| 461 | } |
| 462 | |
| 463 | |
| 464 | static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password) { |
| 465 | uLong i; |
| 466 | unz_global_info64 gi; |
| 467 | int err; |
| 468 | |
| 469 | err = unzGetGlobalInfo64(uf,&gi); |
| @@ -506,17 +489,11 @@ | |
| 489 | } |
| 490 | |
| 491 | return 0; |
| 492 | } |
| 493 | |
| 494 | static int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_without_path, int opt_overwrite, const char* password) { |
| 495 | if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK) |
| 496 | { |
| 497 | printf("file %s not found in the zipfile\n",filename); |
| 498 | return 2; |
| 499 | } |
| @@ -528,14 +505,11 @@ | |
| 505 | else |
| 506 | return 1; |
| 507 | } |
| 508 | |
| 509 | |
| 510 | int main(int argc, char *argv[]) { |
| 511 | const char *zipfilename=NULL; |
| 512 | const char *filename_to_extract=NULL; |
| 513 | const char *password=NULL; |
| 514 | char filename_try[MAXFILENAME+16] = ""; |
| 515 | int i; |
| @@ -604,11 +578,11 @@ | |
| 578 | # ifdef USEWIN32IOAPI |
| 579 | zlib_filefunc64_def ffunc; |
| 580 | # endif |
| 581 | |
| 582 | strncpy(filename_try, zipfilename,MAXFILENAME-1); |
| 583 | /* strncpy doesn't append the trailing NULL, of the string is too long. */ |
| 584 | filename_try[ MAXFILENAME ] = '\0'; |
| 585 | |
| 586 | # ifdef USEWIN32IOAPI |
| 587 | fill_win32_filefunc64A(&ffunc); |
| 588 | uf = unzOpen2_64(zipfilename,&ffunc); |
| 589 |
+24
-36
| --- compat/zlib/contrib/minizip/minizip.c | ||
| +++ compat/zlib/contrib/minizip/minizip.c | ||
| @@ -26,11 +26,11 @@ | ||
| 26 | 26 | #ifndef _FILE_OFFSET_BIT |
| 27 | 27 | #define _FILE_OFFSET_BIT 64 |
| 28 | 28 | #endif |
| 29 | 29 | #endif |
| 30 | 30 | |
| 31 | -#ifdef __APPLE__ | |
| 31 | +#if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) | |
| 32 | 32 | // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions |
| 33 | 33 | #define FOPEN_FUNC(filename, mode) fopen(filename, mode) |
| 34 | 34 | #define FTELLO_FUNC(stream) ftello(stream) |
| 35 | 35 | #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) |
| 36 | 36 | #else |
| @@ -69,15 +69,13 @@ | ||
| 69 | 69 | |
| 70 | 70 | #define WRITEBUFFERSIZE (16384) |
| 71 | 71 | #define MAXFILENAME (256) |
| 72 | 72 | |
| 73 | 73 | #ifdef _WIN32 |
| 74 | -static int filetime(f, tmzip, dt) | |
| 75 | - const char *f; /* name of file to get info on */ | |
| 76 | - tm_zip *tmzip; /* return value: access, modific. and creation times */ | |
| 77 | - uLong *dt; /* dostime */ | |
| 78 | -{ | |
| 74 | +/* f: name of file to get info on, tmzip: return value: access, | |
| 75 | + modification and creation times, dt: dostime */ | |
| 76 | +static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { | |
| 79 | 77 | int ret = 0; |
| 80 | 78 | { |
| 81 | 79 | FILETIME ftLocal; |
| 82 | 80 | HANDLE hFind; |
| 83 | 81 | WIN32_FIND_DATAA ff32; |
| @@ -93,15 +91,13 @@ | ||
| 93 | 91 | } |
| 94 | 92 | return ret; |
| 95 | 93 | } |
| 96 | 94 | #else |
| 97 | 95 | #if defined(unix) || defined(__APPLE__) |
| 98 | -static int filetime(f, tmzip, dt) | |
| 99 | - const char *f; /* name of file to get info on */ | |
| 100 | - tm_zip *tmzip; /* return value: access, modific. and creation times */ | |
| 101 | - uLong *dt; /* dostime */ | |
| 102 | -{ | |
| 96 | +/* f: name of file to get info on, tmzip: return value: access, | |
| 97 | + modification and creation times, dt: dostime */ | |
| 98 | +static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { | |
| 103 | 99 | (void)dt; |
| 104 | 100 | int ret=0; |
| 105 | 101 | struct stat s; /* results of stat() */ |
| 106 | 102 | struct tm* filedate; |
| 107 | 103 | time_t tm_t=0; |
| @@ -112,11 +108,11 @@ | ||
| 112 | 108 | size_t len = strlen(f); |
| 113 | 109 | if (len > MAXFILENAME) |
| 114 | 110 | len = MAXFILENAME; |
| 115 | 111 | |
| 116 | 112 | strncpy(name, f,MAXFILENAME-1); |
| 117 | - /* strncpy doesnt append the trailing NULL, of the string is too long. */ | |
| 113 | + /* strncpy doesn't append the trailing NULL, of the string is too long. */ | |
| 118 | 114 | name[ MAXFILENAME ] = '\0'; |
| 119 | 115 | |
| 120 | 116 | if (name[len - 1] == '/') |
| 121 | 117 | name[len - 1] = '\0'; |
| 122 | 118 | /* not all systems allow stat'ing a file with / appended */ |
| @@ -136,26 +132,25 @@ | ||
| 136 | 132 | tmzip->tm_year = filedate->tm_year; |
| 137 | 133 | |
| 138 | 134 | return ret; |
| 139 | 135 | } |
| 140 | 136 | #else |
| 141 | -uLong filetime(f, tmzip, dt) | |
| 142 | - const char *f; /* name of file to get info on */ | |
| 143 | - tm_zip *tmzip; /* return value: access, modific. and creation times */ | |
| 144 | - uLong *dt; /* dostime */ | |
| 145 | -{ | |
| 137 | +/* f: name of file to get info on, tmzip: return value: access, | |
| 138 | + modification and creation times, dt: dostime */ | |
| 139 | +static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { | |
| 140 | + (void)f; | |
| 141 | + (void)tmzip; | |
| 142 | + (void)dt; | |
| 146 | 143 | return 0; |
| 147 | 144 | } |
| 148 | 145 | #endif |
| 149 | 146 | #endif |
| 150 | 147 | |
| 151 | 148 | |
| 152 | 149 | |
| 153 | 150 | |
| 154 | -static int check_exist_file(filename) | |
| 155 | - const char* filename; | |
| 156 | -{ | |
| 151 | +static int check_exist_file(const char* filename) { | |
| 157 | 152 | FILE* ftestexist; |
| 158 | 153 | int ret = 1; |
| 159 | 154 | ftestexist = FOPEN_FUNC(filename,"rb"); |
| 160 | 155 | if (ftestexist==NULL) |
| 161 | 156 | ret = 0; |
| @@ -162,18 +157,16 @@ | ||
| 162 | 157 | else |
| 163 | 158 | fclose(ftestexist); |
| 164 | 159 | return ret; |
| 165 | 160 | } |
| 166 | 161 | |
| 167 | -static void do_banner() | |
| 168 | -{ | |
| 162 | +static void do_banner(void) { | |
| 169 | 163 | printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n"); |
| 170 | 164 | printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n"); |
| 171 | 165 | } |
| 172 | 166 | |
| 173 | -static void do_help() | |
| 174 | -{ | |
| 167 | +static void do_help(void) { | |
| 175 | 168 | printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \ |
| 176 | 169 | " -o Overwrite existing file.zip\n" \ |
| 177 | 170 | " -a Append to existing file.zip\n" \ |
| 178 | 171 | " -0 Store only\n" \ |
| 179 | 172 | " -1 Compress faster\n" \ |
| @@ -181,12 +174,11 @@ | ||
| 181 | 174 | " -j exclude path. store only the file name.\n\n"); |
| 182 | 175 | } |
| 183 | 176 | |
| 184 | 177 | /* calculate the CRC32 of a file, |
| 185 | 178 | because to encrypt a file, we need known the CRC32 of the file before */ |
| 186 | -static int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc) | |
| 187 | -{ | |
| 179 | +static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_buf, unsigned long* result_crc) { | |
| 188 | 180 | unsigned long calculate_crc=0; |
| 189 | 181 | int err=ZIP_OK; |
| 190 | 182 | FILE * fin = FOPEN_FUNC(filenameinzip,"rb"); |
| 191 | 183 | |
| 192 | 184 | unsigned long size_read = 0; |
| @@ -220,22 +212,21 @@ | ||
| 220 | 212 | *result_crc=calculate_crc; |
| 221 | 213 | printf("file %s crc %lx\n", filenameinzip, calculate_crc); |
| 222 | 214 | return err; |
| 223 | 215 | } |
| 224 | 216 | |
| 225 | -static int isLargeFile(const char* filename) | |
| 226 | -{ | |
| 217 | +static int isLargeFile(const char* filename) { | |
| 227 | 218 | int largeFile = 0; |
| 228 | 219 | ZPOS64_T pos = 0; |
| 229 | 220 | FILE* pFile = FOPEN_FUNC(filename, "rb"); |
| 230 | 221 | |
| 231 | 222 | if(pFile != NULL) |
| 232 | 223 | { |
| 233 | 224 | FSEEKO_FUNC(pFile, 0, SEEK_END); |
| 234 | 225 | pos = (ZPOS64_T)FTELLO_FUNC(pFile); |
| 235 | 226 | |
| 236 | - printf("File : %s is %lld bytes\n", filename, pos); | |
| 227 | + printf("File : %s is %llu bytes\n", filename, pos); | |
| 237 | 228 | |
| 238 | 229 | if(pos >= 0xffffffff) |
| 239 | 230 | largeFile = 1; |
| 240 | 231 | |
| 241 | 232 | fclose(pFile); |
| @@ -242,14 +233,11 @@ | ||
| 242 | 233 | } |
| 243 | 234 | |
| 244 | 235 | return largeFile; |
| 245 | 236 | } |
| 246 | 237 | |
| 247 | -int main(argc,argv) | |
| 248 | - int argc; | |
| 249 | - char *argv[]; | |
| 250 | -{ | |
| 238 | +int main(int argc, char *argv[]) { | |
| 251 | 239 | int i; |
| 252 | 240 | int opt_overwrite=0; |
| 253 | 241 | int opt_compress_level=Z_DEFAULT_COMPRESSION; |
| 254 | 242 | int opt_exclude_path=0; |
| 255 | 243 | int zipfilenamearg = 0; |
| @@ -321,11 +309,11 @@ | ||
| 321 | 309 | int i,len; |
| 322 | 310 | int dot_found=0; |
| 323 | 311 | |
| 324 | 312 | zipok = 1 ; |
| 325 | 313 | strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1); |
| 326 | - /* strncpy doesnt append the trailing NULL, of the string is too long. */ | |
| 314 | + /* strncpy doesn't append the trailing NULL, of the string is too long. */ | |
| 327 | 315 | filename_try[ MAXFILENAME ] = '\0'; |
| 328 | 316 | |
| 329 | 317 | len=(int)strlen(filename_try); |
| 330 | 318 | for (i=0;i<len;i++) |
| 331 | 319 | if (filename_try[i]=='.') |
| @@ -391,14 +379,14 @@ | ||
| 391 | 379 | { |
| 392 | 380 | if (!((((*(argv[i]))=='-') || ((*(argv[i]))=='/')) && |
| 393 | 381 | ((argv[i][1]=='o') || (argv[i][1]=='O') || |
| 394 | 382 | (argv[i][1]=='a') || (argv[i][1]=='A') || |
| 395 | 383 | (argv[i][1]=='p') || (argv[i][1]=='P') || |
| 396 | - ((argv[i][1]>='0') || (argv[i][1]<='9'))) && | |
| 384 | + ((argv[i][1]>='0') && (argv[i][1]<='9'))) && | |
| 397 | 385 | (strlen(argv[i]) == 2))) |
| 398 | 386 | { |
| 399 | - FILE * fin; | |
| 387 | + FILE * fin = NULL; | |
| 400 | 388 | size_t size_read; |
| 401 | 389 | const char* filenameinzip = argv[i]; |
| 402 | 390 | const char *savefilenameinzip; |
| 403 | 391 | zip_fileinfo zi; |
| 404 | 392 | unsigned long crcFile=0; |
| 405 | 393 |
| --- compat/zlib/contrib/minizip/minizip.c | |
| +++ compat/zlib/contrib/minizip/minizip.c | |
| @@ -26,11 +26,11 @@ | |
| 26 | #ifndef _FILE_OFFSET_BIT |
| 27 | #define _FILE_OFFSET_BIT 64 |
| 28 | #endif |
| 29 | #endif |
| 30 | |
| 31 | #ifdef __APPLE__ |
| 32 | // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions |
| 33 | #define FOPEN_FUNC(filename, mode) fopen(filename, mode) |
| 34 | #define FTELLO_FUNC(stream) ftello(stream) |
| 35 | #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) |
| 36 | #else |
| @@ -69,15 +69,13 @@ | |
| 69 | |
| 70 | #define WRITEBUFFERSIZE (16384) |
| 71 | #define MAXFILENAME (256) |
| 72 | |
| 73 | #ifdef _WIN32 |
| 74 | static int filetime(f, tmzip, dt) |
| 75 | const char *f; /* name of file to get info on */ |
| 76 | tm_zip *tmzip; /* return value: access, modific. and creation times */ |
| 77 | uLong *dt; /* dostime */ |
| 78 | { |
| 79 | int ret = 0; |
| 80 | { |
| 81 | FILETIME ftLocal; |
| 82 | HANDLE hFind; |
| 83 | WIN32_FIND_DATAA ff32; |
| @@ -93,15 +91,13 @@ | |
| 93 | } |
| 94 | return ret; |
| 95 | } |
| 96 | #else |
| 97 | #if defined(unix) || defined(__APPLE__) |
| 98 | static int filetime(f, tmzip, dt) |
| 99 | const char *f; /* name of file to get info on */ |
| 100 | tm_zip *tmzip; /* return value: access, modific. and creation times */ |
| 101 | uLong *dt; /* dostime */ |
| 102 | { |
| 103 | (void)dt; |
| 104 | int ret=0; |
| 105 | struct stat s; /* results of stat() */ |
| 106 | struct tm* filedate; |
| 107 | time_t tm_t=0; |
| @@ -112,11 +108,11 @@ | |
| 112 | size_t len = strlen(f); |
| 113 | if (len > MAXFILENAME) |
| 114 | len = MAXFILENAME; |
| 115 | |
| 116 | strncpy(name, f,MAXFILENAME-1); |
| 117 | /* strncpy doesnt append the trailing NULL, of the string is too long. */ |
| 118 | name[ MAXFILENAME ] = '\0'; |
| 119 | |
| 120 | if (name[len - 1] == '/') |
| 121 | name[len - 1] = '\0'; |
| 122 | /* not all systems allow stat'ing a file with / appended */ |
| @@ -136,26 +132,25 @@ | |
| 136 | tmzip->tm_year = filedate->tm_year; |
| 137 | |
| 138 | return ret; |
| 139 | } |
| 140 | #else |
| 141 | uLong filetime(f, tmzip, dt) |
| 142 | const char *f; /* name of file to get info on */ |
| 143 | tm_zip *tmzip; /* return value: access, modific. and creation times */ |
| 144 | uLong *dt; /* dostime */ |
| 145 | { |
| 146 | return 0; |
| 147 | } |
| 148 | #endif |
| 149 | #endif |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | static int check_exist_file(filename) |
| 155 | const char* filename; |
| 156 | { |
| 157 | FILE* ftestexist; |
| 158 | int ret = 1; |
| 159 | ftestexist = FOPEN_FUNC(filename,"rb"); |
| 160 | if (ftestexist==NULL) |
| 161 | ret = 0; |
| @@ -162,18 +157,16 @@ | |
| 162 | else |
| 163 | fclose(ftestexist); |
| 164 | return ret; |
| 165 | } |
| 166 | |
| 167 | static void do_banner() |
| 168 | { |
| 169 | printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n"); |
| 170 | printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n"); |
| 171 | } |
| 172 | |
| 173 | static void do_help() |
| 174 | { |
| 175 | printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \ |
| 176 | " -o Overwrite existing file.zip\n" \ |
| 177 | " -a Append to existing file.zip\n" \ |
| 178 | " -0 Store only\n" \ |
| 179 | " -1 Compress faster\n" \ |
| @@ -181,12 +174,11 @@ | |
| 181 | " -j exclude path. store only the file name.\n\n"); |
| 182 | } |
| 183 | |
| 184 | /* calculate the CRC32 of a file, |
| 185 | because to encrypt a file, we need known the CRC32 of the file before */ |
| 186 | static int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc) |
| 187 | { |
| 188 | unsigned long calculate_crc=0; |
| 189 | int err=ZIP_OK; |
| 190 | FILE * fin = FOPEN_FUNC(filenameinzip,"rb"); |
| 191 | |
| 192 | unsigned long size_read = 0; |
| @@ -220,22 +212,21 @@ | |
| 220 | *result_crc=calculate_crc; |
| 221 | printf("file %s crc %lx\n", filenameinzip, calculate_crc); |
| 222 | return err; |
| 223 | } |
| 224 | |
| 225 | static int isLargeFile(const char* filename) |
| 226 | { |
| 227 | int largeFile = 0; |
| 228 | ZPOS64_T pos = 0; |
| 229 | FILE* pFile = FOPEN_FUNC(filename, "rb"); |
| 230 | |
| 231 | if(pFile != NULL) |
| 232 | { |
| 233 | FSEEKO_FUNC(pFile, 0, SEEK_END); |
| 234 | pos = (ZPOS64_T)FTELLO_FUNC(pFile); |
| 235 | |
| 236 | printf("File : %s is %lld bytes\n", filename, pos); |
| 237 | |
| 238 | if(pos >= 0xffffffff) |
| 239 | largeFile = 1; |
| 240 | |
| 241 | fclose(pFile); |
| @@ -242,14 +233,11 @@ | |
| 242 | } |
| 243 | |
| 244 | return largeFile; |
| 245 | } |
| 246 | |
| 247 | int main(argc,argv) |
| 248 | int argc; |
| 249 | char *argv[]; |
| 250 | { |
| 251 | int i; |
| 252 | int opt_overwrite=0; |
| 253 | int opt_compress_level=Z_DEFAULT_COMPRESSION; |
| 254 | int opt_exclude_path=0; |
| 255 | int zipfilenamearg = 0; |
| @@ -321,11 +309,11 @@ | |
| 321 | int i,len; |
| 322 | int dot_found=0; |
| 323 | |
| 324 | zipok = 1 ; |
| 325 | strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1); |
| 326 | /* strncpy doesnt append the trailing NULL, of the string is too long. */ |
| 327 | filename_try[ MAXFILENAME ] = '\0'; |
| 328 | |
| 329 | len=(int)strlen(filename_try); |
| 330 | for (i=0;i<len;i++) |
| 331 | if (filename_try[i]=='.') |
| @@ -391,14 +379,14 @@ | |
| 391 | { |
| 392 | if (!((((*(argv[i]))=='-') || ((*(argv[i]))=='/')) && |
| 393 | ((argv[i][1]=='o') || (argv[i][1]=='O') || |
| 394 | (argv[i][1]=='a') || (argv[i][1]=='A') || |
| 395 | (argv[i][1]=='p') || (argv[i][1]=='P') || |
| 396 | ((argv[i][1]>='0') || (argv[i][1]<='9'))) && |
| 397 | (strlen(argv[i]) == 2))) |
| 398 | { |
| 399 | FILE * fin; |
| 400 | size_t size_read; |
| 401 | const char* filenameinzip = argv[i]; |
| 402 | const char *savefilenameinzip; |
| 403 | zip_fileinfo zi; |
| 404 | unsigned long crcFile=0; |
| 405 |
| --- compat/zlib/contrib/minizip/minizip.c | |
| +++ compat/zlib/contrib/minizip/minizip.c | |
| @@ -26,11 +26,11 @@ | |
| 26 | #ifndef _FILE_OFFSET_BIT |
| 27 | #define _FILE_OFFSET_BIT 64 |
| 28 | #endif |
| 29 | #endif |
| 30 | |
| 31 | #if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) |
| 32 | // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions |
| 33 | #define FOPEN_FUNC(filename, mode) fopen(filename, mode) |
| 34 | #define FTELLO_FUNC(stream) ftello(stream) |
| 35 | #define FSEEKO_FUNC(stream, offset, origin) fseeko(stream, offset, origin) |
| 36 | #else |
| @@ -69,15 +69,13 @@ | |
| 69 | |
| 70 | #define WRITEBUFFERSIZE (16384) |
| 71 | #define MAXFILENAME (256) |
| 72 | |
| 73 | #ifdef _WIN32 |
| 74 | /* f: name of file to get info on, tmzip: return value: access, |
| 75 | modification and creation times, dt: dostime */ |
| 76 | static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { |
| 77 | int ret = 0; |
| 78 | { |
| 79 | FILETIME ftLocal; |
| 80 | HANDLE hFind; |
| 81 | WIN32_FIND_DATAA ff32; |
| @@ -93,15 +91,13 @@ | |
| 91 | } |
| 92 | return ret; |
| 93 | } |
| 94 | #else |
| 95 | #if defined(unix) || defined(__APPLE__) |
| 96 | /* f: name of file to get info on, tmzip: return value: access, |
| 97 | modification and creation times, dt: dostime */ |
| 98 | static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { |
| 99 | (void)dt; |
| 100 | int ret=0; |
| 101 | struct stat s; /* results of stat() */ |
| 102 | struct tm* filedate; |
| 103 | time_t tm_t=0; |
| @@ -112,11 +108,11 @@ | |
| 108 | size_t len = strlen(f); |
| 109 | if (len > MAXFILENAME) |
| 110 | len = MAXFILENAME; |
| 111 | |
| 112 | strncpy(name, f,MAXFILENAME-1); |
| 113 | /* strncpy doesn't append the trailing NULL, of the string is too long. */ |
| 114 | name[ MAXFILENAME ] = '\0'; |
| 115 | |
| 116 | if (name[len - 1] == '/') |
| 117 | name[len - 1] = '\0'; |
| 118 | /* not all systems allow stat'ing a file with / appended */ |
| @@ -136,26 +132,25 @@ | |
| 132 | tmzip->tm_year = filedate->tm_year; |
| 133 | |
| 134 | return ret; |
| 135 | } |
| 136 | #else |
| 137 | /* f: name of file to get info on, tmzip: return value: access, |
| 138 | modification and creation times, dt: dostime */ |
| 139 | static int filetime(const char *f, tm_zip *tmzip, uLong *dt) { |
| 140 | (void)f; |
| 141 | (void)tmzip; |
| 142 | (void)dt; |
| 143 | return 0; |
| 144 | } |
| 145 | #endif |
| 146 | #endif |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | static int check_exist_file(const char* filename) { |
| 152 | FILE* ftestexist; |
| 153 | int ret = 1; |
| 154 | ftestexist = FOPEN_FUNC(filename,"rb"); |
| 155 | if (ftestexist==NULL) |
| 156 | ret = 0; |
| @@ -162,18 +157,16 @@ | |
| 157 | else |
| 158 | fclose(ftestexist); |
| 159 | return ret; |
| 160 | } |
| 161 | |
| 162 | static void do_banner(void) { |
| 163 | printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n"); |
| 164 | printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n"); |
| 165 | } |
| 166 | |
| 167 | static void do_help(void) { |
| 168 | printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \ |
| 169 | " -o Overwrite existing file.zip\n" \ |
| 170 | " -a Append to existing file.zip\n" \ |
| 171 | " -0 Store only\n" \ |
| 172 | " -1 Compress faster\n" \ |
| @@ -181,12 +174,11 @@ | |
| 174 | " -j exclude path. store only the file name.\n\n"); |
| 175 | } |
| 176 | |
| 177 | /* calculate the CRC32 of a file, |
| 178 | because to encrypt a file, we need known the CRC32 of the file before */ |
| 179 | static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_buf, unsigned long* result_crc) { |
| 180 | unsigned long calculate_crc=0; |
| 181 | int err=ZIP_OK; |
| 182 | FILE * fin = FOPEN_FUNC(filenameinzip,"rb"); |
| 183 | |
| 184 | unsigned long size_read = 0; |
| @@ -220,22 +212,21 @@ | |
| 212 | *result_crc=calculate_crc; |
| 213 | printf("file %s crc %lx\n", filenameinzip, calculate_crc); |
| 214 | return err; |
| 215 | } |
| 216 | |
| 217 | static int isLargeFile(const char* filename) { |
| 218 | int largeFile = 0; |
| 219 | ZPOS64_T pos = 0; |
| 220 | FILE* pFile = FOPEN_FUNC(filename, "rb"); |
| 221 | |
| 222 | if(pFile != NULL) |
| 223 | { |
| 224 | FSEEKO_FUNC(pFile, 0, SEEK_END); |
| 225 | pos = (ZPOS64_T)FTELLO_FUNC(pFile); |
| 226 | |
| 227 | printf("File : %s is %llu bytes\n", filename, pos); |
| 228 | |
| 229 | if(pos >= 0xffffffff) |
| 230 | largeFile = 1; |
| 231 | |
| 232 | fclose(pFile); |
| @@ -242,14 +233,11 @@ | |
| 233 | } |
| 234 | |
| 235 | return largeFile; |
| 236 | } |
| 237 | |
| 238 | int main(int argc, char *argv[]) { |
| 239 | int i; |
| 240 | int opt_overwrite=0; |
| 241 | int opt_compress_level=Z_DEFAULT_COMPRESSION; |
| 242 | int opt_exclude_path=0; |
| 243 | int zipfilenamearg = 0; |
| @@ -321,11 +309,11 @@ | |
| 309 | int i,len; |
| 310 | int dot_found=0; |
| 311 | |
| 312 | zipok = 1 ; |
| 313 | strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1); |
| 314 | /* strncpy doesn't append the trailing NULL, of the string is too long. */ |
| 315 | filename_try[ MAXFILENAME ] = '\0'; |
| 316 | |
| 317 | len=(int)strlen(filename_try); |
| 318 | for (i=0;i<len;i++) |
| 319 | if (filename_try[i]=='.') |
| @@ -391,14 +379,14 @@ | |
| 379 | { |
| 380 | if (!((((*(argv[i]))=='-') || ((*(argv[i]))=='/')) && |
| 381 | ((argv[i][1]=='o') || (argv[i][1]=='O') || |
| 382 | (argv[i][1]=='a') || (argv[i][1]=='A') || |
| 383 | (argv[i][1]=='p') || (argv[i][1]=='P') || |
| 384 | ((argv[i][1]>='0') && (argv[i][1]<='9'))) && |
| 385 | (strlen(argv[i]) == 2))) |
| 386 | { |
| 387 | FILE * fin = NULL; |
| 388 | size_t size_read; |
| 389 | const char* filenameinzip = argv[i]; |
| 390 | const char *savefilenameinzip; |
| 391 | zip_fileinfo zi; |
| 392 | unsigned long crcFile=0; |
| 393 |
| --- compat/zlib/contrib/minizip/mztools.c | ||
| +++ compat/zlib/contrib/minizip/mztools.c | ||
| @@ -25,17 +25,11 @@ | ||
| 25 | 25 | #define WRITE_32(buff, n) do { \ |
| 26 | 26 | WRITE_16((unsigned char*)(buff), (n) & 0xffff); \ |
| 27 | 27 | WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \ |
| 28 | 28 | } while(0) |
| 29 | 29 | |
| 30 | -extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered) | |
| 31 | -const char* file; | |
| 32 | -const char* fileOut; | |
| 33 | -const char* fileOutTmp; | |
| 34 | -uLong* nRecovered; | |
| 35 | -uLong* bytesRecovered; | |
| 36 | -{ | |
| 30 | +extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered) { | |
| 37 | 31 | int err = Z_OK; |
| 38 | 32 | FILE* fpZip = fopen(file, "rb"); |
| 39 | 33 | FILE* fpOut = fopen(fileOut, "wb"); |
| 40 | 34 | FILE* fpOutCD = fopen(fileOutTmp, "wb"); |
| 41 | 35 | if (fpZip != NULL && fpOut != NULL) { |
| 42 | 36 |
| --- compat/zlib/contrib/minizip/mztools.c | |
| +++ compat/zlib/contrib/minizip/mztools.c | |
| @@ -25,17 +25,11 @@ | |
| 25 | #define WRITE_32(buff, n) do { \ |
| 26 | WRITE_16((unsigned char*)(buff), (n) & 0xffff); \ |
| 27 | WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \ |
| 28 | } while(0) |
| 29 | |
| 30 | extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered) |
| 31 | const char* file; |
| 32 | const char* fileOut; |
| 33 | const char* fileOutTmp; |
| 34 | uLong* nRecovered; |
| 35 | uLong* bytesRecovered; |
| 36 | { |
| 37 | int err = Z_OK; |
| 38 | FILE* fpZip = fopen(file, "rb"); |
| 39 | FILE* fpOut = fopen(fileOut, "wb"); |
| 40 | FILE* fpOutCD = fopen(fileOutTmp, "wb"); |
| 41 | if (fpZip != NULL && fpOut != NULL) { |
| 42 |
| --- compat/zlib/contrib/minizip/mztools.c | |
| +++ compat/zlib/contrib/minizip/mztools.c | |
| @@ -25,17 +25,11 @@ | |
| 25 | #define WRITE_32(buff, n) do { \ |
| 26 | WRITE_16((unsigned char*)(buff), (n) & 0xffff); \ |
| 27 | WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \ |
| 28 | } while(0) |
| 29 | |
| 30 | extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered) { |
| 31 | int err = Z_OK; |
| 32 | FILE* fpZip = fopen(file, "rb"); |
| 33 | FILE* fpOut = fopen(fileOut, "wb"); |
| 34 | FILE* fpOutCD = fopen(fileOutTmp, "wb"); |
| 35 | if (fpZip != NULL && fpOut != NULL) { |
| 36 |
+196
-341
| --- compat/zlib/contrib/minizip/unzip.c | ||
| +++ compat/zlib/contrib/minizip/unzip.c | ||
| @@ -47,16 +47,16 @@ | ||
| 47 | 47 | 2007-2008 - Even Rouault - Add unzip support for ZIP64 |
| 48 | 48 | |
| 49 | 49 | Copyright (C) 2007-2008 Even Rouault |
| 50 | 50 | |
| 51 | 51 | |
| 52 | - Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again). | |
| 52 | + Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again). | |
| 53 | 53 | Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G |
| 54 | 54 | should only read the compressed/uncompressed size from the Zip64 format if |
| 55 | 55 | the size from normal header was 0xFFFFFFFF |
| 56 | - Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant | |
| 57 | - Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required) | |
| 56 | + Oct-2009 - Mathias Svensson - Applied some bug fixes from patches received from Gilles Vollant | |
| 57 | + Oct-2009 - Mathias Svensson - Applied support to unzip files with compression method BZIP2 (bzip2 lib is required) | |
| 58 | 58 | Patch created by Daniel Borca |
| 59 | 59 | |
| 60 | 60 | Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer |
| 61 | 61 | |
| 62 | 62 | Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson |
| @@ -75,12 +75,10 @@ | ||
| 75 | 75 | #include "zlib.h" |
| 76 | 76 | #include "unzip.h" |
| 77 | 77 | |
| 78 | 78 | #ifdef STDC |
| 79 | 79 | # include <stddef.h> |
| 80 | -# include <string.h> | |
| 81 | -# include <stdlib.h> | |
| 82 | 80 | #endif |
| 83 | 81 | #ifdef NO_ERRNO_H |
| 84 | 82 | extern int errno; |
| 85 | 83 | #else |
| 86 | 84 | # include <errno.h> |
| @@ -109,13 +107,10 @@ | ||
| 109 | 107 | #endif |
| 110 | 108 | |
| 111 | 109 | #ifndef ALLOC |
| 112 | 110 | # define ALLOC(size) (malloc(size)) |
| 113 | 111 | #endif |
| 114 | -#ifndef TRYFREE | |
| 115 | -# define TRYFREE(p) { free(p);} | |
| 116 | -#endif | |
| 117 | 112 | |
| 118 | 113 | #define SIZECENTRALDIRITEM (0x2e) |
| 119 | 114 | #define SIZEZIPLOCALHEADER (0x1e) |
| 120 | 115 | |
| 121 | 116 | |
| @@ -151,11 +146,11 @@ | ||
| 151 | 146 | uLong crc32; /* crc32 of all data uncompressed */ |
| 152 | 147 | uLong crc32_wait; /* crc32 we must obtain after decompress all */ |
| 153 | 148 | ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */ |
| 154 | 149 | ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/ |
| 155 | 150 | zlib_filefunc64_32_def z_filefunc; |
| 156 | - voidpf filestream; /* io structore of the zipfile */ | |
| 151 | + voidpf filestream; /* io structure of the zipfile */ | |
| 157 | 152 | uLong compression_method; /* compression method (0==store) */ |
| 158 | 153 | ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
| 159 | 154 | int raw; |
| 160 | 155 | } file_in_zip64_read_info_s; |
| 161 | 156 | |
| @@ -164,11 +159,11 @@ | ||
| 164 | 159 | */ |
| 165 | 160 | typedef struct |
| 166 | 161 | { |
| 167 | 162 | zlib_filefunc64_32_def z_filefunc; |
| 168 | 163 | int is64bitOpenFunction; |
| 169 | - voidpf filestream; /* io structore of the zipfile */ | |
| 164 | + voidpf filestream; /* io structure of the zipfile */ | |
| 170 | 165 | unz_global_info64 gi; /* public global information */ |
| 171 | 166 | ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
| 172 | 167 | ZPOS64_T num_file; /* number of the current file in the zipfile*/ |
| 173 | 168 | ZPOS64_T pos_in_central_dir; /* pos of the current file in the central dir*/ |
| 174 | 169 | ZPOS64_T current_file_ok; /* flag about the usability of the current file*/ |
| @@ -194,162 +189,80 @@ | ||
| 194 | 189 | |
| 195 | 190 | |
| 196 | 191 | #ifndef NOUNCRYPT |
| 197 | 192 | #include "crypt.h" |
| 198 | 193 | #endif |
| 194 | + | |
| 199 | 195 | |
| 200 | 196 | /* =========================================================================== |
| 201 | - Read a byte from a gz_stream; update next_in and avail_in. Return EOF | |
| 202 | - for end of file. | |
| 203 | - IN assertion: the stream s has been successfully opened for reading. | |
| 197 | + Reads a long in LSB order from the given gz_stream. Sets | |
| 204 | 198 | */ |
| 205 | 199 | |
| 206 | - | |
| 207 | -local int unz64local_getByte OF(( | |
| 208 | - const zlib_filefunc64_32_def* pzlib_filefunc_def, | |
| 209 | - voidpf filestream, | |
| 210 | - int *pi)); | |
| 211 | - | |
| 212 | -local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi) | |
| 213 | -{ | |
| 214 | - unsigned char c; | |
| 215 | - int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); | |
| 216 | - if (err==1) | |
| 217 | - { | |
| 218 | - *pi = (int)c; | |
| 200 | +local int unz64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def, | |
| 201 | + voidpf filestream, | |
| 202 | + uLong *pX) { | |
| 203 | + unsigned char c[2]; | |
| 204 | + int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,2); | |
| 205 | + if (err==2) | |
| 206 | + { | |
| 207 | + *pX = c[0] | ((uLong)c[1] << 8); | |
| 208 | + return UNZ_OK; | |
| 209 | + } | |
| 210 | + else | |
| 211 | + { | |
| 212 | + *pX = 0; | |
| 213 | + if (ZERROR64(*pzlib_filefunc_def,filestream)) | |
| 214 | + return UNZ_ERRNO; | |
| 215 | + else | |
| 216 | + return UNZ_EOF; | |
| 217 | + } | |
| 218 | +} | |
| 219 | + | |
| 220 | +local int unz64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def, | |
| 221 | + voidpf filestream, | |
| 222 | + uLong *pX) { | |
| 223 | + unsigned char c[4]; | |
| 224 | + int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,4); | |
| 225 | + if (err==4) | |
| 226 | + { | |
| 227 | + *pX = c[0] | ((uLong)c[1] << 8) | ((uLong)c[2] << 16) | ((uLong)c[3] << 24); | |
| 228 | + return UNZ_OK; | |
| 229 | + } | |
| 230 | + else | |
| 231 | + { | |
| 232 | + *pX = 0; | |
| 233 | + if (ZERROR64(*pzlib_filefunc_def,filestream)) | |
| 234 | + return UNZ_ERRNO; | |
| 235 | + else | |
| 236 | + return UNZ_EOF; | |
| 237 | + } | |
| 238 | +} | |
| 239 | + | |
| 240 | + | |
| 241 | +local int unz64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def, | |
| 242 | + voidpf filestream, | |
| 243 | + ZPOS64_T *pX) { | |
| 244 | + unsigned char c[8]; | |
| 245 | + int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,8); | |
| 246 | + if (err==8) | |
| 247 | + { | |
| 248 | + *pX = c[0] | ((ZPOS64_T)c[1] << 8) | ((ZPOS64_T)c[2] << 16) | ((ZPOS64_T)c[3] << 24) | |
| 249 | + | ((ZPOS64_T)c[4] << 32) | ((ZPOS64_T)c[5] << 40) | ((ZPOS64_T)c[6] << 48) | ((ZPOS64_T)c[7] << 56); | |
| 219 | 250 | return UNZ_OK; |
| 220 | 251 | } |
| 221 | 252 | else |
| 222 | 253 | { |
| 254 | + *pX = 0; | |
| 223 | 255 | if (ZERROR64(*pzlib_filefunc_def,filestream)) |
| 224 | 256 | return UNZ_ERRNO; |
| 225 | 257 | else |
| 226 | 258 | return UNZ_EOF; |
| 227 | 259 | } |
| 228 | 260 | } |
| 229 | 261 | |
| 230 | - | |
| 231 | -/* =========================================================================== | |
| 232 | - Reads a long in LSB order from the given gz_stream. Sets | |
| 233 | -*/ | |
| 234 | -local int unz64local_getShort OF(( | |
| 235 | - const zlib_filefunc64_32_def* pzlib_filefunc_def, | |
| 236 | - voidpf filestream, | |
| 237 | - uLong *pX)); | |
| 238 | - | |
| 239 | -local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, | |
| 240 | - voidpf filestream, | |
| 241 | - uLong *pX) | |
| 242 | -{ | |
| 243 | - uLong x ; | |
| 244 | - int i = 0; | |
| 245 | - int err; | |
| 246 | - | |
| 247 | - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); | |
| 248 | - x = (uLong)i; | |
| 249 | - | |
| 250 | - if (err==UNZ_OK) | |
| 251 | - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); | |
| 252 | - x |= ((uLong)i)<<8; | |
| 253 | - | |
| 254 | - if (err==UNZ_OK) | |
| 255 | - *pX = x; | |
| 256 | - else | |
| 257 | - *pX = 0; | |
| 258 | - return err; | |
| 259 | -} | |
| 260 | - | |
| 261 | -local int unz64local_getLong OF(( | |
| 262 | - const zlib_filefunc64_32_def* pzlib_filefunc_def, | |
| 263 | - voidpf filestream, | |
| 264 | - uLong *pX)); | |
| 265 | - | |
| 266 | -local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, | |
| 267 | - voidpf filestream, | |
| 268 | - uLong *pX) | |
| 269 | -{ | |
| 270 | - uLong x ; | |
| 271 | - int i = 0; | |
| 272 | - int err; | |
| 273 | - | |
| 274 | - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); | |
| 275 | - x = (uLong)i; | |
| 276 | - | |
| 277 | - if (err==UNZ_OK) | |
| 278 | - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); | |
| 279 | - x |= ((uLong)i)<<8; | |
| 280 | - | |
| 281 | - if (err==UNZ_OK) | |
| 282 | - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); | |
| 283 | - x |= ((uLong)i)<<16; | |
| 284 | - | |
| 285 | - if (err==UNZ_OK) | |
| 286 | - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); | |
| 287 | - x += ((uLong)i)<<24; | |
| 288 | - | |
| 289 | - if (err==UNZ_OK) | |
| 290 | - *pX = x; | |
| 291 | - else | |
| 292 | - *pX = 0; | |
| 293 | - return err; | |
| 294 | -} | |
| 295 | - | |
| 296 | -local int unz64local_getLong64 OF(( | |
| 297 | - const zlib_filefunc64_32_def* pzlib_filefunc_def, | |
| 298 | - voidpf filestream, | |
| 299 | - ZPOS64_T *pX)); | |
| 300 | - | |
| 301 | - | |
| 302 | -local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, | |
| 303 | - voidpf filestream, | |
| 304 | - ZPOS64_T *pX) | |
| 305 | -{ | |
| 306 | - ZPOS64_T x ; | |
| 307 | - int i = 0; | |
| 308 | - int err; | |
| 309 | - | |
| 310 | - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); | |
| 311 | - x = (ZPOS64_T)i; | |
| 312 | - | |
| 313 | - if (err==UNZ_OK) | |
| 314 | - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); | |
| 315 | - x |= ((ZPOS64_T)i)<<8; | |
| 316 | - | |
| 317 | - if (err==UNZ_OK) | |
| 318 | - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); | |
| 319 | - x |= ((ZPOS64_T)i)<<16; | |
| 320 | - | |
| 321 | - if (err==UNZ_OK) | |
| 322 | - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); | |
| 323 | - x |= ((ZPOS64_T)i)<<24; | |
| 324 | - | |
| 325 | - if (err==UNZ_OK) | |
| 326 | - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); | |
| 327 | - x |= ((ZPOS64_T)i)<<32; | |
| 328 | - | |
| 329 | - if (err==UNZ_OK) | |
| 330 | - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); | |
| 331 | - x |= ((ZPOS64_T)i)<<40; | |
| 332 | - | |
| 333 | - if (err==UNZ_OK) | |
| 334 | - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); | |
| 335 | - x |= ((ZPOS64_T)i)<<48; | |
| 336 | - | |
| 337 | - if (err==UNZ_OK) | |
| 338 | - err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); | |
| 339 | - x |= ((ZPOS64_T)i)<<56; | |
| 340 | - | |
| 341 | - if (err==UNZ_OK) | |
| 342 | - *pX = x; | |
| 343 | - else | |
| 344 | - *pX = 0; | |
| 345 | - return err; | |
| 346 | -} | |
| 347 | - | |
| 348 | 262 | /* My own strcmpi / strcasecmp */ |
| 349 | -local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2) | |
| 350 | -{ | |
| 263 | +local int strcmpcasenosensitive_internal(const char* fileName1, const char* fileName2) { | |
| 351 | 264 | for (;;) |
| 352 | 265 | { |
| 353 | 266 | char c1=*(fileName1++); |
| 354 | 267 | char c2=*(fileName2++); |
| 355 | 268 | if ((c1>='a') && (c1<='z')) |
| @@ -377,23 +290,21 @@ | ||
| 377 | 290 | #ifndef STRCMPCASENOSENTIVEFUNCTION |
| 378 | 291 | #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal |
| 379 | 292 | #endif |
| 380 | 293 | |
| 381 | 294 | /* |
| 382 | - Compare two filename (fileName1,fileName2). | |
| 383 | - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) | |
| 384 | - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi | |
| 295 | + Compare two filenames (fileName1,fileName2). | |
| 296 | + If iCaseSensitivity = 1, comparison is case sensitive (like strcmp) | |
| 297 | + If iCaseSensitivity = 2, comparison is not case sensitive (like strcmpi | |
| 385 | 298 | or strcasecmp) |
| 386 | - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system | |
| 299 | + If iCaseSensitivity = 0, case sensitivity is default of your operating system | |
| 387 | 300 | (like 1 on Unix, 2 on Windows) |
| 388 | 301 | |
| 389 | 302 | */ |
| 390 | 303 | extern int ZEXPORT unzStringFileNameCompare (const char* fileName1, |
| 391 | - const char* fileName2, | |
| 392 | - int iCaseSensitivity) | |
| 393 | - | |
| 394 | -{ | |
| 304 | + const char* fileName2, | |
| 305 | + int iCaseSensitivity) { | |
| 395 | 306 | if (iCaseSensitivity==0) |
| 396 | 307 | iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; |
| 397 | 308 | |
| 398 | 309 | if (iCaseSensitivity==1) |
| 399 | 310 | return strcmp(fileName1,fileName2); |
| @@ -403,35 +314,37 @@ | ||
| 403 | 314 | |
| 404 | 315 | #ifndef BUFREADCOMMENT |
| 405 | 316 | #define BUFREADCOMMENT (0x400) |
| 406 | 317 | #endif |
| 407 | 318 | |
| 319 | +#ifndef CENTRALDIRINVALID | |
| 320 | +#define CENTRALDIRINVALID ((ZPOS64_T)(-1)) | |
| 321 | +#endif | |
| 322 | + | |
| 408 | 323 | /* |
| 409 | 324 | Locate the Central directory of a zipfile (at the end, just before |
| 410 | 325 | the global comment) |
| 411 | 326 | */ |
| 412 | -local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); | |
| 413 | -local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) | |
| 414 | -{ | |
| 327 | +local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { | |
| 415 | 328 | unsigned char* buf; |
| 416 | 329 | ZPOS64_T uSizeFile; |
| 417 | 330 | ZPOS64_T uBackRead; |
| 418 | 331 | ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
| 419 | - ZPOS64_T uPosFound=0; | |
| 332 | + ZPOS64_T uPosFound=CENTRALDIRINVALID; | |
| 420 | 333 | |
| 421 | 334 | if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) |
| 422 | - return 0; | |
| 335 | + return CENTRALDIRINVALID; | |
| 423 | 336 | |
| 424 | 337 | |
| 425 | 338 | uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); |
| 426 | 339 | |
| 427 | 340 | if (uMaxBack>uSizeFile) |
| 428 | 341 | uMaxBack = uSizeFile; |
| 429 | 342 | |
| 430 | 343 | buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); |
| 431 | 344 | if (buf==NULL) |
| 432 | - return 0; | |
| 345 | + return CENTRALDIRINVALID; | |
| 433 | 346 | |
| 434 | 347 | uBackRead = 4; |
| 435 | 348 | while (uBackRead<uMaxBack) |
| 436 | 349 | { |
| 437 | 350 | uLong uReadSize; |
| @@ -457,49 +370,44 @@ | ||
| 457 | 370 | { |
| 458 | 371 | uPosFound = uReadPos+(unsigned)i; |
| 459 | 372 | break; |
| 460 | 373 | } |
| 461 | 374 | |
| 462 | - if (uPosFound!=0) | |
| 375 | + if (uPosFound!=CENTRALDIRINVALID) | |
| 463 | 376 | break; |
| 464 | 377 | } |
| 465 | - TRYFREE(buf); | |
| 378 | + free(buf); | |
| 466 | 379 | return uPosFound; |
| 467 | 380 | } |
| 468 | 381 | |
| 469 | 382 | |
| 470 | 383 | /* |
| 471 | 384 | Locate the Central directory 64 of a zipfile (at the end, just before |
| 472 | 385 | the global comment) |
| 473 | 386 | */ |
| 474 | -local ZPOS64_T unz64local_SearchCentralDir64 OF(( | |
| 475 | - const zlib_filefunc64_32_def* pzlib_filefunc_def, | |
| 476 | - voidpf filestream)); | |
| 477 | - | |
| 478 | 387 | local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, |
| 479 | - voidpf filestream) | |
| 480 | -{ | |
| 388 | + voidpf filestream) { | |
| 481 | 389 | unsigned char* buf; |
| 482 | 390 | ZPOS64_T uSizeFile; |
| 483 | 391 | ZPOS64_T uBackRead; |
| 484 | 392 | ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
| 485 | - ZPOS64_T uPosFound=0; | |
| 393 | + ZPOS64_T uPosFound=CENTRALDIRINVALID; | |
| 486 | 394 | uLong uL; |
| 487 | 395 | ZPOS64_T relativeOffset; |
| 488 | 396 | |
| 489 | 397 | if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) |
| 490 | - return 0; | |
| 398 | + return CENTRALDIRINVALID; | |
| 491 | 399 | |
| 492 | 400 | |
| 493 | 401 | uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); |
| 494 | 402 | |
| 495 | 403 | if (uMaxBack>uSizeFile) |
| 496 | 404 | uMaxBack = uSizeFile; |
| 497 | 405 | |
| 498 | 406 | buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); |
| 499 | 407 | if (buf==NULL) |
| 500 | - return 0; | |
| 408 | + return CENTRALDIRINVALID; | |
| 501 | 409 | |
| 502 | 410 | uBackRead = 4; |
| 503 | 411 | while (uBackRead<uMaxBack) |
| 504 | 412 | { |
| 505 | 413 | uLong uReadSize; |
| @@ -525,51 +433,51 @@ | ||
| 525 | 433 | { |
| 526 | 434 | uPosFound = uReadPos+(unsigned)i; |
| 527 | 435 | break; |
| 528 | 436 | } |
| 529 | 437 | |
| 530 | - if (uPosFound!=0) | |
| 438 | + if (uPosFound!=CENTRALDIRINVALID) | |
| 531 | 439 | break; |
| 532 | 440 | } |
| 533 | - TRYFREE(buf); | |
| 534 | - if (uPosFound == 0) | |
| 535 | - return 0; | |
| 441 | + free(buf); | |
| 442 | + if (uPosFound == CENTRALDIRINVALID) | |
| 443 | + return CENTRALDIRINVALID; | |
| 536 | 444 | |
| 537 | 445 | /* Zip64 end of central directory locator */ |
| 538 | 446 | if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0) |
| 539 | - return 0; | |
| 447 | + return CENTRALDIRINVALID; | |
| 540 | 448 | |
| 541 | 449 | /* the signature, already checked */ |
| 542 | 450 | if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
| 543 | - return 0; | |
| 451 | + return CENTRALDIRINVALID; | |
| 544 | 452 | |
| 545 | 453 | /* number of the disk with the start of the zip64 end of central directory */ |
| 546 | 454 | if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
| 547 | - return 0; | |
| 455 | + return CENTRALDIRINVALID; | |
| 548 | 456 | if (uL != 0) |
| 549 | - return 0; | |
| 457 | + return CENTRALDIRINVALID; | |
| 550 | 458 | |
| 551 | 459 | /* relative offset of the zip64 end of central directory record */ |
| 552 | 460 | if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK) |
| 553 | - return 0; | |
| 461 | + return CENTRALDIRINVALID; | |
| 554 | 462 | |
| 555 | 463 | /* total number of disks */ |
| 556 | 464 | if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
| 557 | - return 0; | |
| 465 | + return CENTRALDIRINVALID; | |
| 558 | 466 | if (uL != 1) |
| 559 | - return 0; | |
| 467 | + return CENTRALDIRINVALID; | |
| 560 | 468 | |
| 561 | 469 | /* Goto end of central directory record */ |
| 562 | 470 | if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0) |
| 563 | - return 0; | |
| 471 | + return CENTRALDIRINVALID; | |
| 564 | 472 | |
| 565 | 473 | /* the signature */ |
| 566 | 474 | if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
| 567 | - return 0; | |
| 475 | + return CENTRALDIRINVALID; | |
| 568 | 476 | |
| 569 | 477 | if (uL != 0x06064b50) |
| 570 | - return 0; | |
| 478 | + return CENTRALDIRINVALID; | |
| 571 | 479 | |
| 572 | 480 | return relativeOffset; |
| 573 | 481 | } |
| 574 | 482 | |
| 575 | 483 | /* |
| @@ -579,23 +487,22 @@ | ||
| 579 | 487 | If the zipfile cannot be opened (file doesn't exist or in not valid), the |
| 580 | 488 | return value is NULL. |
| 581 | 489 | Else, the return value is a unzFile Handle, usable with other function |
| 582 | 490 | of this unzip package. |
| 583 | 491 | */ |
| 584 | -local unzFile unzOpenInternal (const void *path, | |
| 585 | - zlib_filefunc64_32_def* pzlib_filefunc64_32_def, | |
| 586 | - int is64bitOpenFunction) | |
| 587 | -{ | |
| 492 | +local unzFile unzOpenInternal(const void *path, | |
| 493 | + zlib_filefunc64_32_def* pzlib_filefunc64_32_def, | |
| 494 | + int is64bitOpenFunction) { | |
| 588 | 495 | unz64_s us; |
| 589 | 496 | unz64_s *s; |
| 590 | 497 | ZPOS64_T central_pos; |
| 591 | 498 | uLong uL; |
| 592 | 499 | |
| 593 | 500 | uLong number_disk; /* number of the current dist, used for |
| 594 | - spaning ZIP, unsupported, always 0*/ | |
| 501 | + spanning ZIP, unsupported, always 0*/ | |
| 595 | 502 | uLong number_disk_with_CD; /* number the the disk with central dir, used |
| 596 | - for spaning ZIP, unsupported, always 0*/ | |
| 503 | + for spanning ZIP, unsupported, always 0*/ | |
| 597 | 504 | ZPOS64_T number_entry_CD; /* total number of entries in |
| 598 | 505 | the central dir |
| 599 | 506 | (same than number_entry on nospan) */ |
| 600 | 507 | |
| 601 | 508 | int err=UNZ_OK; |
| @@ -619,11 +526,11 @@ | ||
| 619 | 526 | ZLIB_FILEFUNC_MODE_EXISTING); |
| 620 | 527 | if (us.filestream==NULL) |
| 621 | 528 | return NULL; |
| 622 | 529 | |
| 623 | 530 | central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream); |
| 624 | - if (central_pos) | |
| 531 | + if (central_pos!=CENTRALDIRINVALID) | |
| 625 | 532 | { |
| 626 | 533 | uLong uS; |
| 627 | 534 | ZPOS64_T uL64; |
| 628 | 535 | |
| 629 | 536 | us.isZip64 = 1; |
| @@ -681,11 +588,11 @@ | ||
| 681 | 588 | us.gi.size_comment = 0; |
| 682 | 589 | } |
| 683 | 590 | else |
| 684 | 591 | { |
| 685 | 592 | central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream); |
| 686 | - if (central_pos==0) | |
| 593 | + if (central_pos==CENTRALDIRINVALID) | |
| 687 | 594 | err=UNZ_ERRNO; |
| 688 | 595 | |
| 689 | 596 | us.isZip64 = 0; |
| 690 | 597 | |
| 691 | 598 | if (ZSEEK64(us.z_filefunc, us.filestream, |
| @@ -760,13 +667,12 @@ | ||
| 760 | 667 | } |
| 761 | 668 | return (unzFile)s; |
| 762 | 669 | } |
| 763 | 670 | |
| 764 | 671 | |
| 765 | -extern unzFile ZEXPORT unzOpen2 (const char *path, | |
| 766 | - zlib_filefunc_def* pzlib_filefunc32_def) | |
| 767 | -{ | |
| 672 | +extern unzFile ZEXPORT unzOpen2(const char *path, | |
| 673 | + zlib_filefunc_def* pzlib_filefunc32_def) { | |
| 768 | 674 | if (pzlib_filefunc32_def != NULL) |
| 769 | 675 | { |
| 770 | 676 | zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; |
| 771 | 677 | fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def); |
| 772 | 678 | return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 0); |
| @@ -773,13 +679,12 @@ | ||
| 773 | 679 | } |
| 774 | 680 | else |
| 775 | 681 | return unzOpenInternal(path, NULL, 0); |
| 776 | 682 | } |
| 777 | 683 | |
| 778 | -extern unzFile ZEXPORT unzOpen2_64 (const void *path, | |
| 779 | - zlib_filefunc64_def* pzlib_filefunc_def) | |
| 780 | -{ | |
| 684 | +extern unzFile ZEXPORT unzOpen2_64(const void *path, | |
| 685 | + zlib_filefunc64_def* pzlib_filefunc_def) { | |
| 781 | 686 | if (pzlib_filefunc_def != NULL) |
| 782 | 687 | { |
| 783 | 688 | zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; |
| 784 | 689 | zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def; |
| 785 | 690 | zlib_filefunc64_32_def_fill.ztell32_file = NULL; |
| @@ -788,57 +693,52 @@ | ||
| 788 | 693 | } |
| 789 | 694 | else |
| 790 | 695 | return unzOpenInternal(path, NULL, 1); |
| 791 | 696 | } |
| 792 | 697 | |
| 793 | -extern unzFile ZEXPORT unzOpen (const char *path) | |
| 794 | -{ | |
| 698 | +extern unzFile ZEXPORT unzOpen(const char *path) { | |
| 795 | 699 | return unzOpenInternal(path, NULL, 0); |
| 796 | 700 | } |
| 797 | 701 | |
| 798 | -extern unzFile ZEXPORT unzOpen64 (const void *path) | |
| 799 | -{ | |
| 702 | +extern unzFile ZEXPORT unzOpen64(const void *path) { | |
| 800 | 703 | return unzOpenInternal(path, NULL, 1); |
| 801 | 704 | } |
| 802 | 705 | |
| 803 | 706 | /* |
| 804 | 707 | Close a ZipFile opened with unzOpen. |
| 805 | 708 | If there is files inside the .Zip opened with unzOpenCurrentFile (see later), |
| 806 | 709 | these files MUST be closed with unzCloseCurrentFile before call unzClose. |
| 807 | 710 | return UNZ_OK if there is no problem. */ |
| 808 | -extern int ZEXPORT unzClose (unzFile file) | |
| 809 | -{ | |
| 711 | +extern int ZEXPORT unzClose(unzFile file) { | |
| 810 | 712 | unz64_s* s; |
| 811 | 713 | if (file==NULL) |
| 812 | 714 | return UNZ_PARAMERROR; |
| 813 | 715 | s=(unz64_s*)file; |
| 814 | 716 | |
| 815 | 717 | if (s->pfile_in_zip_read!=NULL) |
| 816 | 718 | unzCloseCurrentFile(file); |
| 817 | 719 | |
| 818 | 720 | ZCLOSE64(s->z_filefunc, s->filestream); |
| 819 | - TRYFREE(s); | |
| 721 | + free(s); | |
| 820 | 722 | return UNZ_OK; |
| 821 | 723 | } |
| 822 | 724 | |
| 823 | 725 | |
| 824 | 726 | /* |
| 825 | 727 | Write info about the ZipFile in the *pglobal_info structure. |
| 826 | 728 | No preparation of the structure is needed |
| 827 | 729 | return UNZ_OK if there is no problem. */ |
| 828 | -extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info) | |
| 829 | -{ | |
| 730 | +extern int ZEXPORT unzGetGlobalInfo64(unzFile file, unz_global_info64* pglobal_info) { | |
| 830 | 731 | unz64_s* s; |
| 831 | 732 | if (file==NULL) |
| 832 | 733 | return UNZ_PARAMERROR; |
| 833 | 734 | s=(unz64_s*)file; |
| 834 | 735 | *pglobal_info=s->gi; |
| 835 | 736 | return UNZ_OK; |
| 836 | 737 | } |
| 837 | 738 | |
| 838 | -extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32) | |
| 839 | -{ | |
| 739 | +extern int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info* pglobal_info32) { | |
| 840 | 740 | unz64_s* s; |
| 841 | 741 | if (file==NULL) |
| 842 | 742 | return UNZ_PARAMERROR; |
| 843 | 743 | s=(unz64_s*)file; |
| 844 | 744 | /* to do : check if number_entry is not truncated */ |
| @@ -845,14 +745,13 @@ | ||
| 845 | 745 | pglobal_info32->number_entry = (uLong)s->gi.number_entry; |
| 846 | 746 | pglobal_info32->size_comment = s->gi.size_comment; |
| 847 | 747 | return UNZ_OK; |
| 848 | 748 | } |
| 849 | 749 | /* |
| 850 | - Translate date/time from Dos format to tm_unz (readable more easilty) | |
| 750 | + Translate date/time from Dos format to tm_unz (readable more easily) | |
| 851 | 751 | */ |
| 852 | -local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm) | |
| 853 | -{ | |
| 752 | +local void unz64local_DosDateToTmuDate(ZPOS64_T ulDosDate, tm_unz* ptm) { | |
| 854 | 753 | ZPOS64_T uDate; |
| 855 | 754 | uDate = (ZPOS64_T)(ulDosDate>>16); |
| 856 | 755 | ptm->tm_mday = (int)(uDate&0x1f) ; |
| 857 | 756 | ptm->tm_mon = (int)((((uDate)&0x1E0)/0x20)-1) ; |
| 858 | 757 | ptm->tm_year = (int)(((uDate&0x0FE00)/0x0200)+1980) ; |
| @@ -863,32 +762,20 @@ | ||
| 863 | 762 | } |
| 864 | 763 | |
| 865 | 764 | /* |
| 866 | 765 | Get Info about the current file in the zipfile, with internal only info |
| 867 | 766 | */ |
| 868 | -local int unz64local_GetCurrentFileInfoInternal OF((unzFile file, | |
| 869 | - unz_file_info64 *pfile_info, | |
| 870 | - unz_file_info64_internal | |
| 871 | - *pfile_info_internal, | |
| 872 | - char *szFileName, | |
| 873 | - uLong fileNameBufferSize, | |
| 874 | - void *extraField, | |
| 875 | - uLong extraFieldBufferSize, | |
| 876 | - char *szComment, | |
| 877 | - uLong commentBufferSize)); | |
| 878 | - | |
| 879 | -local int unz64local_GetCurrentFileInfoInternal (unzFile file, | |
| 880 | - unz_file_info64 *pfile_info, | |
| 881 | - unz_file_info64_internal | |
| 882 | - *pfile_info_internal, | |
| 883 | - char *szFileName, | |
| 884 | - uLong fileNameBufferSize, | |
| 885 | - void *extraField, | |
| 886 | - uLong extraFieldBufferSize, | |
| 887 | - char *szComment, | |
| 888 | - uLong commentBufferSize) | |
| 889 | -{ | |
| 767 | +local int unz64local_GetCurrentFileInfoInternal(unzFile file, | |
| 768 | + unz_file_info64 *pfile_info, | |
| 769 | + unz_file_info64_internal | |
| 770 | + *pfile_info_internal, | |
| 771 | + char *szFileName, | |
| 772 | + uLong fileNameBufferSize, | |
| 773 | + void *extraField, | |
| 774 | + uLong extraFieldBufferSize, | |
| 775 | + char *szComment, | |
| 776 | + uLong commentBufferSize) { | |
| 890 | 777 | unz64_s* s; |
| 891 | 778 | unz_file_info64 file_info; |
| 892 | 779 | unz_file_info64_internal file_info_internal; |
| 893 | 780 | int err=UNZ_OK; |
| 894 | 781 | uLong uMagic; |
| @@ -1036,37 +923,35 @@ | ||
| 1036 | 923 | err=UNZ_ERRNO; |
| 1037 | 924 | |
| 1038 | 925 | /* ZIP64 extra fields */ |
| 1039 | 926 | if (headerId == 0x0001) |
| 1040 | 927 | { |
| 1041 | - uLong uL; | |
| 1042 | - | |
| 1043 | - if(file_info.uncompressed_size == MAXU32) | |
| 1044 | - { | |
| 1045 | - if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) | |
| 1046 | - err=UNZ_ERRNO; | |
| 1047 | - } | |
| 1048 | - | |
| 1049 | - if(file_info.compressed_size == MAXU32) | |
| 1050 | - { | |
| 1051 | - if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) | |
| 1052 | - err=UNZ_ERRNO; | |
| 1053 | - } | |
| 1054 | - | |
| 1055 | - if(file_info_internal.offset_curfile == MAXU32) | |
| 1056 | - { | |
| 1057 | - /* Relative Header offset */ | |
| 1058 | - if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) | |
| 1059 | - err=UNZ_ERRNO; | |
| 1060 | - } | |
| 1061 | - | |
| 1062 | - if(file_info.disk_num_start == MAXU32) | |
| 1063 | - { | |
| 1064 | - /* Disk Start Number */ | |
| 1065 | - if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) | |
| 1066 | - err=UNZ_ERRNO; | |
| 1067 | - } | |
| 928 | + if(file_info.uncompressed_size == MAXU32) | |
| 929 | + { | |
| 930 | + if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) | |
| 931 | + err=UNZ_ERRNO; | |
| 932 | + } | |
| 933 | + | |
| 934 | + if(file_info.compressed_size == MAXU32) | |
| 935 | + { | |
| 936 | + if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) | |
| 937 | + err=UNZ_ERRNO; | |
| 938 | + } | |
| 939 | + | |
| 940 | + if(file_info_internal.offset_curfile == MAXU32) | |
| 941 | + { | |
| 942 | + /* Relative Header offset */ | |
| 943 | + if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) | |
| 944 | + err=UNZ_ERRNO; | |
| 945 | + } | |
| 946 | + | |
| 947 | + if(file_info.disk_num_start == 0xffff) | |
| 948 | + { | |
| 949 | + /* Disk Start Number */ | |
| 950 | + if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) | |
| 951 | + err=UNZ_ERRNO; | |
| 952 | + } | |
| 1068 | 953 | |
| 1069 | 954 | } |
| 1070 | 955 | else |
| 1071 | 956 | { |
| 1072 | 957 | if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0) |
| @@ -1119,28 +1004,26 @@ | ||
| 1119 | 1004 | /* |
| 1120 | 1005 | Write info about the ZipFile in the *pglobal_info structure. |
| 1121 | 1006 | No preparation of the structure is needed |
| 1122 | 1007 | return UNZ_OK if there is no problem. |
| 1123 | 1008 | */ |
| 1124 | -extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file, | |
| 1125 | - unz_file_info64 * pfile_info, | |
| 1126 | - char * szFileName, uLong fileNameBufferSize, | |
| 1127 | - void *extraField, uLong extraFieldBufferSize, | |
| 1128 | - char* szComment, uLong commentBufferSize) | |
| 1129 | -{ | |
| 1009 | +extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file, | |
| 1010 | + unz_file_info64 * pfile_info, | |
| 1011 | + char * szFileName, uLong fileNameBufferSize, | |
| 1012 | + void *extraField, uLong extraFieldBufferSize, | |
| 1013 | + char* szComment, uLong commentBufferSize) { | |
| 1130 | 1014 | return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL, |
| 1131 | - szFileName,fileNameBufferSize, | |
| 1132 | - extraField,extraFieldBufferSize, | |
| 1133 | - szComment,commentBufferSize); | |
| 1015 | + szFileName,fileNameBufferSize, | |
| 1016 | + extraField,extraFieldBufferSize, | |
| 1017 | + szComment,commentBufferSize); | |
| 1134 | 1018 | } |
| 1135 | 1019 | |
| 1136 | -extern int ZEXPORT unzGetCurrentFileInfo (unzFile file, | |
| 1137 | - unz_file_info * pfile_info, | |
| 1138 | - char * szFileName, uLong fileNameBufferSize, | |
| 1139 | - void *extraField, uLong extraFieldBufferSize, | |
| 1140 | - char* szComment, uLong commentBufferSize) | |
| 1141 | -{ | |
| 1020 | +extern int ZEXPORT unzGetCurrentFileInfo(unzFile file, | |
| 1021 | + unz_file_info * pfile_info, | |
| 1022 | + char * szFileName, uLong fileNameBufferSize, | |
| 1023 | + void *extraField, uLong extraFieldBufferSize, | |
| 1024 | + char* szComment, uLong commentBufferSize) { | |
| 1142 | 1025 | int err; |
| 1143 | 1026 | unz_file_info64 file_info64; |
| 1144 | 1027 | err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL, |
| 1145 | 1028 | szFileName,fileNameBufferSize, |
| 1146 | 1029 | extraField,extraFieldBufferSize, |
| @@ -1160,11 +1043,11 @@ | ||
| 1160 | 1043 | |
| 1161 | 1044 | pfile_info->disk_num_start = file_info64.disk_num_start; |
| 1162 | 1045 | pfile_info->internal_fa = file_info64.internal_fa; |
| 1163 | 1046 | pfile_info->external_fa = file_info64.external_fa; |
| 1164 | 1047 | |
| 1165 | - pfile_info->tmu_date = file_info64.tmu_date, | |
| 1048 | + pfile_info->tmu_date = file_info64.tmu_date; | |
| 1166 | 1049 | |
| 1167 | 1050 | |
| 1168 | 1051 | pfile_info->compressed_size = (uLong)file_info64.compressed_size; |
| 1169 | 1052 | pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size; |
| 1170 | 1053 | |
| @@ -1173,12 +1056,11 @@ | ||
| 1173 | 1056 | } |
| 1174 | 1057 | /* |
| 1175 | 1058 | Set the current file of the zipfile to the first file. |
| 1176 | 1059 | return UNZ_OK if there is no problem |
| 1177 | 1060 | */ |
| 1178 | -extern int ZEXPORT unzGoToFirstFile (unzFile file) | |
| 1179 | -{ | |
| 1061 | +extern int ZEXPORT unzGoToFirstFile(unzFile file) { | |
| 1180 | 1062 | int err=UNZ_OK; |
| 1181 | 1063 | unz64_s* s; |
| 1182 | 1064 | if (file==NULL) |
| 1183 | 1065 | return UNZ_PARAMERROR; |
| 1184 | 1066 | s=(unz64_s*)file; |
| @@ -1194,12 +1076,11 @@ | ||
| 1194 | 1076 | /* |
| 1195 | 1077 | Set the current file of the zipfile to the next file. |
| 1196 | 1078 | return UNZ_OK if there is no problem |
| 1197 | 1079 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. |
| 1198 | 1080 | */ |
| 1199 | -extern int ZEXPORT unzGoToNextFile (unzFile file) | |
| 1200 | -{ | |
| 1081 | +extern int ZEXPORT unzGoToNextFile(unzFile file) { | |
| 1201 | 1082 | unz64_s* s; |
| 1202 | 1083 | int err; |
| 1203 | 1084 | |
| 1204 | 1085 | if (file==NULL) |
| 1205 | 1086 | return UNZ_PARAMERROR; |
| @@ -1227,12 +1108,11 @@ | ||
| 1227 | 1108 | |
| 1228 | 1109 | return value : |
| 1229 | 1110 | UNZ_OK if the file is found. It becomes the current file. |
| 1230 | 1111 | UNZ_END_OF_LIST_OF_FILE if the file is not found |
| 1231 | 1112 | */ |
| 1232 | -extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity) | |
| 1233 | -{ | |
| 1113 | +extern int ZEXPORT unzLocateFile(unzFile file, const char *szFileName, int iCaseSensitivity) { | |
| 1234 | 1114 | unz64_s* s; |
| 1235 | 1115 | int err; |
| 1236 | 1116 | |
| 1237 | 1117 | /* We remember the 'current' position in the file so that we can jump |
| 1238 | 1118 | * back there if we fail. |
| @@ -1303,12 +1183,11 @@ | ||
| 1303 | 1183 | ZPOS64_T pos_in_zip_directory; // offset in file |
| 1304 | 1184 | ZPOS64_T num_of_file; // # of file |
| 1305 | 1185 | } unz_file_pos; |
| 1306 | 1186 | */ |
| 1307 | 1187 | |
| 1308 | -extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) | |
| 1309 | -{ | |
| 1188 | +extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) { | |
| 1310 | 1189 | unz64_s* s; |
| 1311 | 1190 | |
| 1312 | 1191 | if (file==NULL || file_pos==NULL) |
| 1313 | 1192 | return UNZ_PARAMERROR; |
| 1314 | 1193 | s=(unz64_s*)file; |
| @@ -1319,14 +1198,11 @@ | ||
| 1319 | 1198 | file_pos->num_of_file = s->num_file; |
| 1320 | 1199 | |
| 1321 | 1200 | return UNZ_OK; |
| 1322 | 1201 | } |
| 1323 | 1202 | |
| 1324 | -extern int ZEXPORT unzGetFilePos( | |
| 1325 | - unzFile file, | |
| 1326 | - unz_file_pos* file_pos) | |
| 1327 | -{ | |
| 1203 | +extern int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos* file_pos) { | |
| 1328 | 1204 | unz64_file_pos file_pos64; |
| 1329 | 1205 | int err = unzGetFilePos64(file,&file_pos64); |
| 1330 | 1206 | if (err==UNZ_OK) |
| 1331 | 1207 | { |
| 1332 | 1208 | file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory; |
| @@ -1333,12 +1209,11 @@ | ||
| 1333 | 1209 | file_pos->num_of_file = (uLong)file_pos64.num_of_file; |
| 1334 | 1210 | } |
| 1335 | 1211 | return err; |
| 1336 | 1212 | } |
| 1337 | 1213 | |
| 1338 | -extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos) | |
| 1339 | -{ | |
| 1214 | +extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos) { | |
| 1340 | 1215 | unz64_s* s; |
| 1341 | 1216 | int err; |
| 1342 | 1217 | |
| 1343 | 1218 | if (file==NULL || file_pos==NULL) |
| 1344 | 1219 | return UNZ_PARAMERROR; |
| @@ -1355,14 +1230,11 @@ | ||
| 1355 | 1230 | /* return results */ |
| 1356 | 1231 | s->current_file_ok = (err == UNZ_OK); |
| 1357 | 1232 | return err; |
| 1358 | 1233 | } |
| 1359 | 1234 | |
| 1360 | -extern int ZEXPORT unzGoToFilePos( | |
| 1361 | - unzFile file, | |
| 1362 | - unz_file_pos* file_pos) | |
| 1363 | -{ | |
| 1235 | +extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos* file_pos) { | |
| 1364 | 1236 | unz64_file_pos file_pos64; |
| 1365 | 1237 | if (file_pos == NULL) |
| 1366 | 1238 | return UNZ_PARAMERROR; |
| 1367 | 1239 | |
| 1368 | 1240 | file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory; |
| @@ -1380,14 +1252,13 @@ | ||
| 1380 | 1252 | Check the coherency of the local header and info in the end of central |
| 1381 | 1253 | directory about this file |
| 1382 | 1254 | store in *piSizeVar the size of extra info in local header |
| 1383 | 1255 | (filename and size of extra field data) |
| 1384 | 1256 | */ |
| 1385 | -local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar, | |
| 1386 | - ZPOS64_T * poffset_local_extrafield, | |
| 1387 | - uInt * psize_local_extrafield) | |
| 1388 | -{ | |
| 1257 | +local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* piSizeVar, | |
| 1258 | + ZPOS64_T * poffset_local_extrafield, | |
| 1259 | + uInt * psize_local_extrafield) { | |
| 1389 | 1260 | uLong uMagic,uData,uFlags; |
| 1390 | 1261 | uLong size_filename; |
| 1391 | 1262 | uLong size_extra_field; |
| 1392 | 1263 | int err=UNZ_OK; |
| 1393 | 1264 | |
| @@ -1467,13 +1338,12 @@ | ||
| 1467 | 1338 | |
| 1468 | 1339 | /* |
| 1469 | 1340 | Open for reading data the current file in the zipfile. |
| 1470 | 1341 | If there is no error and the file is opened, the return value is UNZ_OK. |
| 1471 | 1342 | */ |
| 1472 | -extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, | |
| 1473 | - int* level, int raw, const char* password) | |
| 1474 | -{ | |
| 1343 | +extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method, | |
| 1344 | + int* level, int raw, const char* password) { | |
| 1475 | 1345 | int err=UNZ_OK; |
| 1476 | 1346 | uInt iSizeVar; |
| 1477 | 1347 | unz64_s* s; |
| 1478 | 1348 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1479 | 1349 | ZPOS64_T offset_local_extrafield; /* offset of the local extra field */ |
| @@ -1507,11 +1377,11 @@ | ||
| 1507 | 1377 | pfile_in_zip_read_info->pos_local_extrafield=0; |
| 1508 | 1378 | pfile_in_zip_read_info->raw=raw; |
| 1509 | 1379 | |
| 1510 | 1380 | if (pfile_in_zip_read_info->read_buffer==NULL) |
| 1511 | 1381 | { |
| 1512 | - TRYFREE(pfile_in_zip_read_info); | |
| 1382 | + free(pfile_in_zip_read_info); | |
| 1513 | 1383 | return UNZ_INTERNALERROR; |
| 1514 | 1384 | } |
| 1515 | 1385 | |
| 1516 | 1386 | pfile_in_zip_read_info->stream_initialised=0; |
| 1517 | 1387 | |
| @@ -1564,12 +1434,12 @@ | ||
| 1564 | 1434 | err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0); |
| 1565 | 1435 | if (err == Z_OK) |
| 1566 | 1436 | pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED; |
| 1567 | 1437 | else |
| 1568 | 1438 | { |
| 1569 | - TRYFREE(pfile_in_zip_read_info->read_buffer); | |
| 1570 | - TRYFREE(pfile_in_zip_read_info); | |
| 1439 | + free(pfile_in_zip_read_info->read_buffer); | |
| 1440 | + free(pfile_in_zip_read_info); | |
| 1571 | 1441 | return err; |
| 1572 | 1442 | } |
| 1573 | 1443 | #else |
| 1574 | 1444 | pfile_in_zip_read_info->raw=1; |
| 1575 | 1445 | #endif |
| @@ -1585,12 +1455,12 @@ | ||
| 1585 | 1455 | err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); |
| 1586 | 1456 | if (err == Z_OK) |
| 1587 | 1457 | pfile_in_zip_read_info->stream_initialised=Z_DEFLATED; |
| 1588 | 1458 | else |
| 1589 | 1459 | { |
| 1590 | - TRYFREE(pfile_in_zip_read_info->read_buffer); | |
| 1591 | - TRYFREE(pfile_in_zip_read_info); | |
| 1460 | + free(pfile_in_zip_read_info->read_buffer); | |
| 1461 | + free(pfile_in_zip_read_info); | |
| 1592 | 1462 | return err; |
| 1593 | 1463 | } |
| 1594 | 1464 | /* windowBits is passed < 0 to tell that there is no zlib header. |
| 1595 | 1465 | * Note that in this case inflate *requires* an extra "dummy" byte |
| 1596 | 1466 | * after the compressed stream in order to complete decompression and |
| @@ -1638,29 +1508,25 @@ | ||
| 1638 | 1508 | |
| 1639 | 1509 | |
| 1640 | 1510 | return UNZ_OK; |
| 1641 | 1511 | } |
| 1642 | 1512 | |
| 1643 | -extern int ZEXPORT unzOpenCurrentFile (unzFile file) | |
| 1644 | -{ | |
| 1513 | +extern int ZEXPORT unzOpenCurrentFile(unzFile file) { | |
| 1645 | 1514 | return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); |
| 1646 | 1515 | } |
| 1647 | 1516 | |
| 1648 | -extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char* password) | |
| 1649 | -{ | |
| 1517 | +extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file, const char* password) { | |
| 1650 | 1518 | return unzOpenCurrentFile3(file, NULL, NULL, 0, password); |
| 1651 | 1519 | } |
| 1652 | 1520 | |
| 1653 | -extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw) | |
| 1654 | -{ | |
| 1521 | +extern int ZEXPORT unzOpenCurrentFile2(unzFile file, int* method, int* level, int raw) { | |
| 1655 | 1522 | return unzOpenCurrentFile3(file, method, level, raw, NULL); |
| 1656 | 1523 | } |
| 1657 | 1524 | |
| 1658 | 1525 | /** Addition for GDAL : START */ |
| 1659 | 1526 | |
| 1660 | -extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file) | |
| 1661 | -{ | |
| 1527 | +extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file) { | |
| 1662 | 1528 | unz64_s* s; |
| 1663 | 1529 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1664 | 1530 | s=(unz64_s*)file; |
| 1665 | 1531 | if (file==NULL) |
| 1666 | 1532 | return 0; //UNZ_PARAMERROR; |
| @@ -1676,17 +1542,16 @@ | ||
| 1676 | 1542 | /* |
| 1677 | 1543 | Read bytes from the current file. |
| 1678 | 1544 | buf contain buffer where data must be copied |
| 1679 | 1545 | len the size of buf. |
| 1680 | 1546 | |
| 1681 | - return the number of byte copied if somes bytes are copied | |
| 1547 | + return the number of byte copied if some bytes are copied | |
| 1682 | 1548 | return 0 if the end of file was reached |
| 1683 | 1549 | return <0 with error code if there is an error |
| 1684 | 1550 | (UNZ_ERRNO for IO error, or zLib error for uncompress error) |
| 1685 | 1551 | */ |
| 1686 | -extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) | |
| 1687 | -{ | |
| 1552 | +extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) { | |
| 1688 | 1553 | int err=UNZ_OK; |
| 1689 | 1554 | uInt iRead = 0; |
| 1690 | 1555 | unz64_s* s; |
| 1691 | 1556 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1692 | 1557 | if (file==NULL) |
| @@ -1889,12 +1754,11 @@ | ||
| 1889 | 1754 | |
| 1890 | 1755 | |
| 1891 | 1756 | /* |
| 1892 | 1757 | Give the current position in uncompressed data |
| 1893 | 1758 | */ |
| 1894 | -extern z_off_t ZEXPORT unztell (unzFile file) | |
| 1895 | -{ | |
| 1759 | +extern z_off_t ZEXPORT unztell(unzFile file) { | |
| 1896 | 1760 | unz64_s* s; |
| 1897 | 1761 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1898 | 1762 | if (file==NULL) |
| 1899 | 1763 | return UNZ_PARAMERROR; |
| 1900 | 1764 | s=(unz64_s*)file; |
| @@ -1904,12 +1768,11 @@ | ||
| 1904 | 1768 | return UNZ_PARAMERROR; |
| 1905 | 1769 | |
| 1906 | 1770 | return (z_off_t)pfile_in_zip_read_info->stream.total_out; |
| 1907 | 1771 | } |
| 1908 | 1772 | |
| 1909 | -extern ZPOS64_T ZEXPORT unztell64 (unzFile file) | |
| 1910 | -{ | |
| 1773 | +extern ZPOS64_T ZEXPORT unztell64(unzFile file) { | |
| 1911 | 1774 | |
| 1912 | 1775 | unz64_s* s; |
| 1913 | 1776 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1914 | 1777 | if (file==NULL) |
| 1915 | 1778 | return (ZPOS64_T)-1; |
| @@ -1924,12 +1787,11 @@ | ||
| 1924 | 1787 | |
| 1925 | 1788 | |
| 1926 | 1789 | /* |
| 1927 | 1790 | return 1 if the end of file was reached, 0 elsewhere |
| 1928 | 1791 | */ |
| 1929 | -extern int ZEXPORT unzeof (unzFile file) | |
| 1930 | -{ | |
| 1792 | +extern int ZEXPORT unzeof(unzFile file) { | |
| 1931 | 1793 | unz64_s* s; |
| 1932 | 1794 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1933 | 1795 | if (file==NULL) |
| 1934 | 1796 | return UNZ_PARAMERROR; |
| 1935 | 1797 | s=(unz64_s*)file; |
| @@ -1956,12 +1818,11 @@ | ||
| 1956 | 1818 | if buf!=NULL, len is the size of the buffer, the extra header is copied in |
| 1957 | 1819 | buf. |
| 1958 | 1820 | the return value is the number of bytes copied in buf, or (if <0) |
| 1959 | 1821 | the error code |
| 1960 | 1822 | */ |
| 1961 | -extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len) | |
| 1962 | -{ | |
| 1823 | +extern int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len) { | |
| 1963 | 1824 | unz64_s* s; |
| 1964 | 1825 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1965 | 1826 | uInt read_now; |
| 1966 | 1827 | ZPOS64_T size_to_read; |
| 1967 | 1828 | |
| @@ -2004,12 +1865,11 @@ | ||
| 2004 | 1865 | |
| 2005 | 1866 | /* |
| 2006 | 1867 | Close the file in zip opened with unzOpenCurrentFile |
| 2007 | 1868 | Return UNZ_CRCERROR if all the file was read but the CRC is not good |
| 2008 | 1869 | */ |
| 2009 | -extern int ZEXPORT unzCloseCurrentFile (unzFile file) | |
| 2010 | -{ | |
| 1870 | +extern int ZEXPORT unzCloseCurrentFile(unzFile file) { | |
| 2011 | 1871 | int err=UNZ_OK; |
| 2012 | 1872 | |
| 2013 | 1873 | unz64_s* s; |
| 2014 | 1874 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 2015 | 1875 | if (file==NULL) |
| @@ -2027,11 +1887,11 @@ | ||
| 2027 | 1887 | if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) |
| 2028 | 1888 | err=UNZ_CRCERROR; |
| 2029 | 1889 | } |
| 2030 | 1890 | |
| 2031 | 1891 | |
| 2032 | - TRYFREE(pfile_in_zip_read_info->read_buffer); | |
| 1892 | + free(pfile_in_zip_read_info->read_buffer); | |
| 2033 | 1893 | pfile_in_zip_read_info->read_buffer = NULL; |
| 2034 | 1894 | if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED) |
| 2035 | 1895 | inflateEnd(&pfile_in_zip_read_info->stream); |
| 2036 | 1896 | #ifdef HAVE_BZIP2 |
| 2037 | 1897 | else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED) |
| @@ -2038,11 +1898,11 @@ | ||
| 2038 | 1898 | BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream); |
| 2039 | 1899 | #endif |
| 2040 | 1900 | |
| 2041 | 1901 | |
| 2042 | 1902 | pfile_in_zip_read_info->stream_initialised = 0; |
| 2043 | - TRYFREE(pfile_in_zip_read_info); | |
| 1903 | + free(pfile_in_zip_read_info); | |
| 2044 | 1904 | |
| 2045 | 1905 | s->pfile_in_zip_read=NULL; |
| 2046 | 1906 | |
| 2047 | 1907 | return err; |
| 2048 | 1908 | } |
| @@ -2051,12 +1911,11 @@ | ||
| 2051 | 1911 | /* |
| 2052 | 1912 | Get the global comment string of the ZipFile, in the szComment buffer. |
| 2053 | 1913 | uSizeBuf is the size of the szComment buffer. |
| 2054 | 1914 | return the number of byte copied or an error code <0 |
| 2055 | 1915 | */ |
| 2056 | -extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf) | |
| 2057 | -{ | |
| 1916 | +extern int ZEXPORT unzGetGlobalComment(unzFile file, char * szComment, uLong uSizeBuf) { | |
| 2058 | 1917 | unz64_s* s; |
| 2059 | 1918 | uLong uReadThis ; |
| 2060 | 1919 | if (file==NULL) |
| 2061 | 1920 | return (int)UNZ_PARAMERROR; |
| 2062 | 1921 | s=(unz64_s*)file; |
| @@ -2079,12 +1938,11 @@ | ||
| 2079 | 1938 | *(szComment+s->gi.size_comment)='\0'; |
| 2080 | 1939 | return (int)uReadThis; |
| 2081 | 1940 | } |
| 2082 | 1941 | |
| 2083 | 1942 | /* Additions by RX '2004 */ |
| 2084 | -extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) | |
| 2085 | -{ | |
| 1943 | +extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) { | |
| 2086 | 1944 | unz64_s* s; |
| 2087 | 1945 | |
| 2088 | 1946 | if (file==NULL) |
| 2089 | 1947 | return 0; //UNZ_PARAMERROR; |
| 2090 | 1948 | s=(unz64_s*)file; |
| @@ -2094,22 +1952,20 @@ | ||
| 2094 | 1952 | if (s->num_file==s->gi.number_entry) |
| 2095 | 1953 | return 0; |
| 2096 | 1954 | return s->pos_in_central_dir; |
| 2097 | 1955 | } |
| 2098 | 1956 | |
| 2099 | -extern uLong ZEXPORT unzGetOffset (unzFile file) | |
| 2100 | -{ | |
| 1957 | +extern uLong ZEXPORT unzGetOffset(unzFile file) { | |
| 2101 | 1958 | ZPOS64_T offset64; |
| 2102 | 1959 | |
| 2103 | 1960 | if (file==NULL) |
| 2104 | 1961 | return 0; //UNZ_PARAMERROR; |
| 2105 | 1962 | offset64 = unzGetOffset64(file); |
| 2106 | 1963 | return (uLong)offset64; |
| 2107 | 1964 | } |
| 2108 | 1965 | |
| 2109 | -extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) | |
| 2110 | -{ | |
| 1966 | +extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) { | |
| 2111 | 1967 | unz64_s* s; |
| 2112 | 1968 | int err; |
| 2113 | 1969 | |
| 2114 | 1970 | if (file==NULL) |
| 2115 | 1971 | return UNZ_PARAMERROR; |
| @@ -2122,9 +1978,8 @@ | ||
| 2122 | 1978 | NULL,0,NULL,0,NULL,0); |
| 2123 | 1979 | s->current_file_ok = (err == UNZ_OK); |
| 2124 | 1980 | return err; |
| 2125 | 1981 | } |
| 2126 | 1982 | |
| 2127 | -extern int ZEXPORT unzSetOffset (unzFile file, uLong pos) | |
| 2128 | -{ | |
| 1983 | +extern int ZEXPORT unzSetOffset (unzFile file, uLong pos) { | |
| 2129 | 1984 | return unzSetOffset64(file,pos); |
| 2130 | 1985 | } |
| 2131 | 1986 |
| --- compat/zlib/contrib/minizip/unzip.c | |
| +++ compat/zlib/contrib/minizip/unzip.c | |
| @@ -47,16 +47,16 @@ | |
| 47 | 2007-2008 - Even Rouault - Add unzip support for ZIP64 |
| 48 | |
| 49 | Copyright (C) 2007-2008 Even Rouault |
| 50 | |
| 51 | |
| 52 | Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again). |
| 53 | Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G |
| 54 | should only read the compressed/uncompressed size from the Zip64 format if |
| 55 | the size from normal header was 0xFFFFFFFF |
| 56 | Oct-2009 - Mathias Svensson - Applied some bug fixes from paches recived from Gilles Vollant |
| 57 | Oct-2009 - Mathias Svensson - Applied support to unzip files with compression mathod BZIP2 (bzip2 lib is required) |
| 58 | Patch created by Daniel Borca |
| 59 | |
| 60 | Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer |
| 61 | |
| 62 | Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson |
| @@ -75,12 +75,10 @@ | |
| 75 | #include "zlib.h" |
| 76 | #include "unzip.h" |
| 77 | |
| 78 | #ifdef STDC |
| 79 | # include <stddef.h> |
| 80 | # include <string.h> |
| 81 | # include <stdlib.h> |
| 82 | #endif |
| 83 | #ifdef NO_ERRNO_H |
| 84 | extern int errno; |
| 85 | #else |
| 86 | # include <errno.h> |
| @@ -109,13 +107,10 @@ | |
| 109 | #endif |
| 110 | |
| 111 | #ifndef ALLOC |
| 112 | # define ALLOC(size) (malloc(size)) |
| 113 | #endif |
| 114 | #ifndef TRYFREE |
| 115 | # define TRYFREE(p) { free(p);} |
| 116 | #endif |
| 117 | |
| 118 | #define SIZECENTRALDIRITEM (0x2e) |
| 119 | #define SIZEZIPLOCALHEADER (0x1e) |
| 120 | |
| 121 | |
| @@ -151,11 +146,11 @@ | |
| 151 | uLong crc32; /* crc32 of all data uncompressed */ |
| 152 | uLong crc32_wait; /* crc32 we must obtain after decompress all */ |
| 153 | ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */ |
| 154 | ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/ |
| 155 | zlib_filefunc64_32_def z_filefunc; |
| 156 | voidpf filestream; /* io structore of the zipfile */ |
| 157 | uLong compression_method; /* compression method (0==store) */ |
| 158 | ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
| 159 | int raw; |
| 160 | } file_in_zip64_read_info_s; |
| 161 | |
| @@ -164,11 +159,11 @@ | |
| 164 | */ |
| 165 | typedef struct |
| 166 | { |
| 167 | zlib_filefunc64_32_def z_filefunc; |
| 168 | int is64bitOpenFunction; |
| 169 | voidpf filestream; /* io structore of the zipfile */ |
| 170 | unz_global_info64 gi; /* public global information */ |
| 171 | ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
| 172 | ZPOS64_T num_file; /* number of the current file in the zipfile*/ |
| 173 | ZPOS64_T pos_in_central_dir; /* pos of the current file in the central dir*/ |
| 174 | ZPOS64_T current_file_ok; /* flag about the usability of the current file*/ |
| @@ -194,162 +189,80 @@ | |
| 194 | |
| 195 | |
| 196 | #ifndef NOUNCRYPT |
| 197 | #include "crypt.h" |
| 198 | #endif |
| 199 | |
| 200 | /* =========================================================================== |
| 201 | Read a byte from a gz_stream; update next_in and avail_in. Return EOF |
| 202 | for end of file. |
| 203 | IN assertion: the stream s has been successfully opened for reading. |
| 204 | */ |
| 205 | |
| 206 | |
| 207 | local int unz64local_getByte OF(( |
| 208 | const zlib_filefunc64_32_def* pzlib_filefunc_def, |
| 209 | voidpf filestream, |
| 210 | int *pi)); |
| 211 | |
| 212 | local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi) |
| 213 | { |
| 214 | unsigned char c; |
| 215 | int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); |
| 216 | if (err==1) |
| 217 | { |
| 218 | *pi = (int)c; |
| 219 | return UNZ_OK; |
| 220 | } |
| 221 | else |
| 222 | { |
| 223 | if (ZERROR64(*pzlib_filefunc_def,filestream)) |
| 224 | return UNZ_ERRNO; |
| 225 | else |
| 226 | return UNZ_EOF; |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | |
| 231 | /* =========================================================================== |
| 232 | Reads a long in LSB order from the given gz_stream. Sets |
| 233 | */ |
| 234 | local int unz64local_getShort OF(( |
| 235 | const zlib_filefunc64_32_def* pzlib_filefunc_def, |
| 236 | voidpf filestream, |
| 237 | uLong *pX)); |
| 238 | |
| 239 | local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, |
| 240 | voidpf filestream, |
| 241 | uLong *pX) |
| 242 | { |
| 243 | uLong x ; |
| 244 | int i = 0; |
| 245 | int err; |
| 246 | |
| 247 | err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); |
| 248 | x = (uLong)i; |
| 249 | |
| 250 | if (err==UNZ_OK) |
| 251 | err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); |
| 252 | x |= ((uLong)i)<<8; |
| 253 | |
| 254 | if (err==UNZ_OK) |
| 255 | *pX = x; |
| 256 | else |
| 257 | *pX = 0; |
| 258 | return err; |
| 259 | } |
| 260 | |
| 261 | local int unz64local_getLong OF(( |
| 262 | const zlib_filefunc64_32_def* pzlib_filefunc_def, |
| 263 | voidpf filestream, |
| 264 | uLong *pX)); |
| 265 | |
| 266 | local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, |
| 267 | voidpf filestream, |
| 268 | uLong *pX) |
| 269 | { |
| 270 | uLong x ; |
| 271 | int i = 0; |
| 272 | int err; |
| 273 | |
| 274 | err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); |
| 275 | x = (uLong)i; |
| 276 | |
| 277 | if (err==UNZ_OK) |
| 278 | err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); |
| 279 | x |= ((uLong)i)<<8; |
| 280 | |
| 281 | if (err==UNZ_OK) |
| 282 | err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); |
| 283 | x |= ((uLong)i)<<16; |
| 284 | |
| 285 | if (err==UNZ_OK) |
| 286 | err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); |
| 287 | x += ((uLong)i)<<24; |
| 288 | |
| 289 | if (err==UNZ_OK) |
| 290 | *pX = x; |
| 291 | else |
| 292 | *pX = 0; |
| 293 | return err; |
| 294 | } |
| 295 | |
| 296 | local int unz64local_getLong64 OF(( |
| 297 | const zlib_filefunc64_32_def* pzlib_filefunc_def, |
| 298 | voidpf filestream, |
| 299 | ZPOS64_T *pX)); |
| 300 | |
| 301 | |
| 302 | local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, |
| 303 | voidpf filestream, |
| 304 | ZPOS64_T *pX) |
| 305 | { |
| 306 | ZPOS64_T x ; |
| 307 | int i = 0; |
| 308 | int err; |
| 309 | |
| 310 | err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); |
| 311 | x = (ZPOS64_T)i; |
| 312 | |
| 313 | if (err==UNZ_OK) |
| 314 | err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); |
| 315 | x |= ((ZPOS64_T)i)<<8; |
| 316 | |
| 317 | if (err==UNZ_OK) |
| 318 | err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); |
| 319 | x |= ((ZPOS64_T)i)<<16; |
| 320 | |
| 321 | if (err==UNZ_OK) |
| 322 | err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); |
| 323 | x |= ((ZPOS64_T)i)<<24; |
| 324 | |
| 325 | if (err==UNZ_OK) |
| 326 | err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); |
| 327 | x |= ((ZPOS64_T)i)<<32; |
| 328 | |
| 329 | if (err==UNZ_OK) |
| 330 | err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); |
| 331 | x |= ((ZPOS64_T)i)<<40; |
| 332 | |
| 333 | if (err==UNZ_OK) |
| 334 | err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); |
| 335 | x |= ((ZPOS64_T)i)<<48; |
| 336 | |
| 337 | if (err==UNZ_OK) |
| 338 | err = unz64local_getByte(pzlib_filefunc_def,filestream,&i); |
| 339 | x |= ((ZPOS64_T)i)<<56; |
| 340 | |
| 341 | if (err==UNZ_OK) |
| 342 | *pX = x; |
| 343 | else |
| 344 | *pX = 0; |
| 345 | return err; |
| 346 | } |
| 347 | |
| 348 | /* My own strcmpi / strcasecmp */ |
| 349 | local int strcmpcasenosensitive_internal (const char* fileName1, const char* fileName2) |
| 350 | { |
| 351 | for (;;) |
| 352 | { |
| 353 | char c1=*(fileName1++); |
| 354 | char c2=*(fileName2++); |
| 355 | if ((c1>='a') && (c1<='z')) |
| @@ -377,23 +290,21 @@ | |
| 377 | #ifndef STRCMPCASENOSENTIVEFUNCTION |
| 378 | #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal |
| 379 | #endif |
| 380 | |
| 381 | /* |
| 382 | Compare two filename (fileName1,fileName2). |
| 383 | If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) |
| 384 | If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi |
| 385 | or strcasecmp) |
| 386 | If iCaseSenisivity = 0, case sensitivity is defaut of your operating system |
| 387 | (like 1 on Unix, 2 on Windows) |
| 388 | |
| 389 | */ |
| 390 | extern int ZEXPORT unzStringFileNameCompare (const char* fileName1, |
| 391 | const char* fileName2, |
| 392 | int iCaseSensitivity) |
| 393 | |
| 394 | { |
| 395 | if (iCaseSensitivity==0) |
| 396 | iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; |
| 397 | |
| 398 | if (iCaseSensitivity==1) |
| 399 | return strcmp(fileName1,fileName2); |
| @@ -403,35 +314,37 @@ | |
| 403 | |
| 404 | #ifndef BUFREADCOMMENT |
| 405 | #define BUFREADCOMMENT (0x400) |
| 406 | #endif |
| 407 | |
| 408 | /* |
| 409 | Locate the Central directory of a zipfile (at the end, just before |
| 410 | the global comment) |
| 411 | */ |
| 412 | local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); |
| 413 | local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) |
| 414 | { |
| 415 | unsigned char* buf; |
| 416 | ZPOS64_T uSizeFile; |
| 417 | ZPOS64_T uBackRead; |
| 418 | ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
| 419 | ZPOS64_T uPosFound=0; |
| 420 | |
| 421 | if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) |
| 422 | return 0; |
| 423 | |
| 424 | |
| 425 | uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); |
| 426 | |
| 427 | if (uMaxBack>uSizeFile) |
| 428 | uMaxBack = uSizeFile; |
| 429 | |
| 430 | buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); |
| 431 | if (buf==NULL) |
| 432 | return 0; |
| 433 | |
| 434 | uBackRead = 4; |
| 435 | while (uBackRead<uMaxBack) |
| 436 | { |
| 437 | uLong uReadSize; |
| @@ -457,49 +370,44 @@ | |
| 457 | { |
| 458 | uPosFound = uReadPos+(unsigned)i; |
| 459 | break; |
| 460 | } |
| 461 | |
| 462 | if (uPosFound!=0) |
| 463 | break; |
| 464 | } |
| 465 | TRYFREE(buf); |
| 466 | return uPosFound; |
| 467 | } |
| 468 | |
| 469 | |
| 470 | /* |
| 471 | Locate the Central directory 64 of a zipfile (at the end, just before |
| 472 | the global comment) |
| 473 | */ |
| 474 | local ZPOS64_T unz64local_SearchCentralDir64 OF(( |
| 475 | const zlib_filefunc64_32_def* pzlib_filefunc_def, |
| 476 | voidpf filestream)); |
| 477 | |
| 478 | local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, |
| 479 | voidpf filestream) |
| 480 | { |
| 481 | unsigned char* buf; |
| 482 | ZPOS64_T uSizeFile; |
| 483 | ZPOS64_T uBackRead; |
| 484 | ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
| 485 | ZPOS64_T uPosFound=0; |
| 486 | uLong uL; |
| 487 | ZPOS64_T relativeOffset; |
| 488 | |
| 489 | if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) |
| 490 | return 0; |
| 491 | |
| 492 | |
| 493 | uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); |
| 494 | |
| 495 | if (uMaxBack>uSizeFile) |
| 496 | uMaxBack = uSizeFile; |
| 497 | |
| 498 | buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); |
| 499 | if (buf==NULL) |
| 500 | return 0; |
| 501 | |
| 502 | uBackRead = 4; |
| 503 | while (uBackRead<uMaxBack) |
| 504 | { |
| 505 | uLong uReadSize; |
| @@ -525,51 +433,51 @@ | |
| 525 | { |
| 526 | uPosFound = uReadPos+(unsigned)i; |
| 527 | break; |
| 528 | } |
| 529 | |
| 530 | if (uPosFound!=0) |
| 531 | break; |
| 532 | } |
| 533 | TRYFREE(buf); |
| 534 | if (uPosFound == 0) |
| 535 | return 0; |
| 536 | |
| 537 | /* Zip64 end of central directory locator */ |
| 538 | if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0) |
| 539 | return 0; |
| 540 | |
| 541 | /* the signature, already checked */ |
| 542 | if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
| 543 | return 0; |
| 544 | |
| 545 | /* number of the disk with the start of the zip64 end of central directory */ |
| 546 | if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
| 547 | return 0; |
| 548 | if (uL != 0) |
| 549 | return 0; |
| 550 | |
| 551 | /* relative offset of the zip64 end of central directory record */ |
| 552 | if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK) |
| 553 | return 0; |
| 554 | |
| 555 | /* total number of disks */ |
| 556 | if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
| 557 | return 0; |
| 558 | if (uL != 1) |
| 559 | return 0; |
| 560 | |
| 561 | /* Goto end of central directory record */ |
| 562 | if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0) |
| 563 | return 0; |
| 564 | |
| 565 | /* the signature */ |
| 566 | if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
| 567 | return 0; |
| 568 | |
| 569 | if (uL != 0x06064b50) |
| 570 | return 0; |
| 571 | |
| 572 | return relativeOffset; |
| 573 | } |
| 574 | |
| 575 | /* |
| @@ -579,23 +487,22 @@ | |
| 579 | If the zipfile cannot be opened (file doesn't exist or in not valid), the |
| 580 | return value is NULL. |
| 581 | Else, the return value is a unzFile Handle, usable with other function |
| 582 | of this unzip package. |
| 583 | */ |
| 584 | local unzFile unzOpenInternal (const void *path, |
| 585 | zlib_filefunc64_32_def* pzlib_filefunc64_32_def, |
| 586 | int is64bitOpenFunction) |
| 587 | { |
| 588 | unz64_s us; |
| 589 | unz64_s *s; |
| 590 | ZPOS64_T central_pos; |
| 591 | uLong uL; |
| 592 | |
| 593 | uLong number_disk; /* number of the current dist, used for |
| 594 | spaning ZIP, unsupported, always 0*/ |
| 595 | uLong number_disk_with_CD; /* number the the disk with central dir, used |
| 596 | for spaning ZIP, unsupported, always 0*/ |
| 597 | ZPOS64_T number_entry_CD; /* total number of entries in |
| 598 | the central dir |
| 599 | (same than number_entry on nospan) */ |
| 600 | |
| 601 | int err=UNZ_OK; |
| @@ -619,11 +526,11 @@ | |
| 619 | ZLIB_FILEFUNC_MODE_EXISTING); |
| 620 | if (us.filestream==NULL) |
| 621 | return NULL; |
| 622 | |
| 623 | central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream); |
| 624 | if (central_pos) |
| 625 | { |
| 626 | uLong uS; |
| 627 | ZPOS64_T uL64; |
| 628 | |
| 629 | us.isZip64 = 1; |
| @@ -681,11 +588,11 @@ | |
| 681 | us.gi.size_comment = 0; |
| 682 | } |
| 683 | else |
| 684 | { |
| 685 | central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream); |
| 686 | if (central_pos==0) |
| 687 | err=UNZ_ERRNO; |
| 688 | |
| 689 | us.isZip64 = 0; |
| 690 | |
| 691 | if (ZSEEK64(us.z_filefunc, us.filestream, |
| @@ -760,13 +667,12 @@ | |
| 760 | } |
| 761 | return (unzFile)s; |
| 762 | } |
| 763 | |
| 764 | |
| 765 | extern unzFile ZEXPORT unzOpen2 (const char *path, |
| 766 | zlib_filefunc_def* pzlib_filefunc32_def) |
| 767 | { |
| 768 | if (pzlib_filefunc32_def != NULL) |
| 769 | { |
| 770 | zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; |
| 771 | fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def); |
| 772 | return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 0); |
| @@ -773,13 +679,12 @@ | |
| 773 | } |
| 774 | else |
| 775 | return unzOpenInternal(path, NULL, 0); |
| 776 | } |
| 777 | |
| 778 | extern unzFile ZEXPORT unzOpen2_64 (const void *path, |
| 779 | zlib_filefunc64_def* pzlib_filefunc_def) |
| 780 | { |
| 781 | if (pzlib_filefunc_def != NULL) |
| 782 | { |
| 783 | zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; |
| 784 | zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def; |
| 785 | zlib_filefunc64_32_def_fill.ztell32_file = NULL; |
| @@ -788,57 +693,52 @@ | |
| 788 | } |
| 789 | else |
| 790 | return unzOpenInternal(path, NULL, 1); |
| 791 | } |
| 792 | |
| 793 | extern unzFile ZEXPORT unzOpen (const char *path) |
| 794 | { |
| 795 | return unzOpenInternal(path, NULL, 0); |
| 796 | } |
| 797 | |
| 798 | extern unzFile ZEXPORT unzOpen64 (const void *path) |
| 799 | { |
| 800 | return unzOpenInternal(path, NULL, 1); |
| 801 | } |
| 802 | |
| 803 | /* |
| 804 | Close a ZipFile opened with unzOpen. |
| 805 | If there is files inside the .Zip opened with unzOpenCurrentFile (see later), |
| 806 | these files MUST be closed with unzCloseCurrentFile before call unzClose. |
| 807 | return UNZ_OK if there is no problem. */ |
| 808 | extern int ZEXPORT unzClose (unzFile file) |
| 809 | { |
| 810 | unz64_s* s; |
| 811 | if (file==NULL) |
| 812 | return UNZ_PARAMERROR; |
| 813 | s=(unz64_s*)file; |
| 814 | |
| 815 | if (s->pfile_in_zip_read!=NULL) |
| 816 | unzCloseCurrentFile(file); |
| 817 | |
| 818 | ZCLOSE64(s->z_filefunc, s->filestream); |
| 819 | TRYFREE(s); |
| 820 | return UNZ_OK; |
| 821 | } |
| 822 | |
| 823 | |
| 824 | /* |
| 825 | Write info about the ZipFile in the *pglobal_info structure. |
| 826 | No preparation of the structure is needed |
| 827 | return UNZ_OK if there is no problem. */ |
| 828 | extern int ZEXPORT unzGetGlobalInfo64 (unzFile file, unz_global_info64* pglobal_info) |
| 829 | { |
| 830 | unz64_s* s; |
| 831 | if (file==NULL) |
| 832 | return UNZ_PARAMERROR; |
| 833 | s=(unz64_s*)file; |
| 834 | *pglobal_info=s->gi; |
| 835 | return UNZ_OK; |
| 836 | } |
| 837 | |
| 838 | extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info* pglobal_info32) |
| 839 | { |
| 840 | unz64_s* s; |
| 841 | if (file==NULL) |
| 842 | return UNZ_PARAMERROR; |
| 843 | s=(unz64_s*)file; |
| 844 | /* to do : check if number_entry is not truncated */ |
| @@ -845,14 +745,13 @@ | |
| 845 | pglobal_info32->number_entry = (uLong)s->gi.number_entry; |
| 846 | pglobal_info32->size_comment = s->gi.size_comment; |
| 847 | return UNZ_OK; |
| 848 | } |
| 849 | /* |
| 850 | Translate date/time from Dos format to tm_unz (readable more easilty) |
| 851 | */ |
| 852 | local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm) |
| 853 | { |
| 854 | ZPOS64_T uDate; |
| 855 | uDate = (ZPOS64_T)(ulDosDate>>16); |
| 856 | ptm->tm_mday = (int)(uDate&0x1f) ; |
| 857 | ptm->tm_mon = (int)((((uDate)&0x1E0)/0x20)-1) ; |
| 858 | ptm->tm_year = (int)(((uDate&0x0FE00)/0x0200)+1980) ; |
| @@ -863,32 +762,20 @@ | |
| 863 | } |
| 864 | |
| 865 | /* |
| 866 | Get Info about the current file in the zipfile, with internal only info |
| 867 | */ |
| 868 | local int unz64local_GetCurrentFileInfoInternal OF((unzFile file, |
| 869 | unz_file_info64 *pfile_info, |
| 870 | unz_file_info64_internal |
| 871 | *pfile_info_internal, |
| 872 | char *szFileName, |
| 873 | uLong fileNameBufferSize, |
| 874 | void *extraField, |
| 875 | uLong extraFieldBufferSize, |
| 876 | char *szComment, |
| 877 | uLong commentBufferSize)); |
| 878 | |
| 879 | local int unz64local_GetCurrentFileInfoInternal (unzFile file, |
| 880 | unz_file_info64 *pfile_info, |
| 881 | unz_file_info64_internal |
| 882 | *pfile_info_internal, |
| 883 | char *szFileName, |
| 884 | uLong fileNameBufferSize, |
| 885 | void *extraField, |
| 886 | uLong extraFieldBufferSize, |
| 887 | char *szComment, |
| 888 | uLong commentBufferSize) |
| 889 | { |
| 890 | unz64_s* s; |
| 891 | unz_file_info64 file_info; |
| 892 | unz_file_info64_internal file_info_internal; |
| 893 | int err=UNZ_OK; |
| 894 | uLong uMagic; |
| @@ -1036,37 +923,35 @@ | |
| 1036 | err=UNZ_ERRNO; |
| 1037 | |
| 1038 | /* ZIP64 extra fields */ |
| 1039 | if (headerId == 0x0001) |
| 1040 | { |
| 1041 | uLong uL; |
| 1042 | |
| 1043 | if(file_info.uncompressed_size == MAXU32) |
| 1044 | { |
| 1045 | if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) |
| 1046 | err=UNZ_ERRNO; |
| 1047 | } |
| 1048 | |
| 1049 | if(file_info.compressed_size == MAXU32) |
| 1050 | { |
| 1051 | if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) |
| 1052 | err=UNZ_ERRNO; |
| 1053 | } |
| 1054 | |
| 1055 | if(file_info_internal.offset_curfile == MAXU32) |
| 1056 | { |
| 1057 | /* Relative Header offset */ |
| 1058 | if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) |
| 1059 | err=UNZ_ERRNO; |
| 1060 | } |
| 1061 | |
| 1062 | if(file_info.disk_num_start == MAXU32) |
| 1063 | { |
| 1064 | /* Disk Start Number */ |
| 1065 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) |
| 1066 | err=UNZ_ERRNO; |
| 1067 | } |
| 1068 | |
| 1069 | } |
| 1070 | else |
| 1071 | { |
| 1072 | if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0) |
| @@ -1119,28 +1004,26 @@ | |
| 1119 | /* |
| 1120 | Write info about the ZipFile in the *pglobal_info structure. |
| 1121 | No preparation of the structure is needed |
| 1122 | return UNZ_OK if there is no problem. |
| 1123 | */ |
| 1124 | extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file, |
| 1125 | unz_file_info64 * pfile_info, |
| 1126 | char * szFileName, uLong fileNameBufferSize, |
| 1127 | void *extraField, uLong extraFieldBufferSize, |
| 1128 | char* szComment, uLong commentBufferSize) |
| 1129 | { |
| 1130 | return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL, |
| 1131 | szFileName,fileNameBufferSize, |
| 1132 | extraField,extraFieldBufferSize, |
| 1133 | szComment,commentBufferSize); |
| 1134 | } |
| 1135 | |
| 1136 | extern int ZEXPORT unzGetCurrentFileInfo (unzFile file, |
| 1137 | unz_file_info * pfile_info, |
| 1138 | char * szFileName, uLong fileNameBufferSize, |
| 1139 | void *extraField, uLong extraFieldBufferSize, |
| 1140 | char* szComment, uLong commentBufferSize) |
| 1141 | { |
| 1142 | int err; |
| 1143 | unz_file_info64 file_info64; |
| 1144 | err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL, |
| 1145 | szFileName,fileNameBufferSize, |
| 1146 | extraField,extraFieldBufferSize, |
| @@ -1160,11 +1043,11 @@ | |
| 1160 | |
| 1161 | pfile_info->disk_num_start = file_info64.disk_num_start; |
| 1162 | pfile_info->internal_fa = file_info64.internal_fa; |
| 1163 | pfile_info->external_fa = file_info64.external_fa; |
| 1164 | |
| 1165 | pfile_info->tmu_date = file_info64.tmu_date, |
| 1166 | |
| 1167 | |
| 1168 | pfile_info->compressed_size = (uLong)file_info64.compressed_size; |
| 1169 | pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size; |
| 1170 | |
| @@ -1173,12 +1056,11 @@ | |
| 1173 | } |
| 1174 | /* |
| 1175 | Set the current file of the zipfile to the first file. |
| 1176 | return UNZ_OK if there is no problem |
| 1177 | */ |
| 1178 | extern int ZEXPORT unzGoToFirstFile (unzFile file) |
| 1179 | { |
| 1180 | int err=UNZ_OK; |
| 1181 | unz64_s* s; |
| 1182 | if (file==NULL) |
| 1183 | return UNZ_PARAMERROR; |
| 1184 | s=(unz64_s*)file; |
| @@ -1194,12 +1076,11 @@ | |
| 1194 | /* |
| 1195 | Set the current file of the zipfile to the next file. |
| 1196 | return UNZ_OK if there is no problem |
| 1197 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. |
| 1198 | */ |
| 1199 | extern int ZEXPORT unzGoToNextFile (unzFile file) |
| 1200 | { |
| 1201 | unz64_s* s; |
| 1202 | int err; |
| 1203 | |
| 1204 | if (file==NULL) |
| 1205 | return UNZ_PARAMERROR; |
| @@ -1227,12 +1108,11 @@ | |
| 1227 | |
| 1228 | return value : |
| 1229 | UNZ_OK if the file is found. It becomes the current file. |
| 1230 | UNZ_END_OF_LIST_OF_FILE if the file is not found |
| 1231 | */ |
| 1232 | extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity) |
| 1233 | { |
| 1234 | unz64_s* s; |
| 1235 | int err; |
| 1236 | |
| 1237 | /* We remember the 'current' position in the file so that we can jump |
| 1238 | * back there if we fail. |
| @@ -1303,12 +1183,11 @@ | |
| 1303 | ZPOS64_T pos_in_zip_directory; // offset in file |
| 1304 | ZPOS64_T num_of_file; // # of file |
| 1305 | } unz_file_pos; |
| 1306 | */ |
| 1307 | |
| 1308 | extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) |
| 1309 | { |
| 1310 | unz64_s* s; |
| 1311 | |
| 1312 | if (file==NULL || file_pos==NULL) |
| 1313 | return UNZ_PARAMERROR; |
| 1314 | s=(unz64_s*)file; |
| @@ -1319,14 +1198,11 @@ | |
| 1319 | file_pos->num_of_file = s->num_file; |
| 1320 | |
| 1321 | return UNZ_OK; |
| 1322 | } |
| 1323 | |
| 1324 | extern int ZEXPORT unzGetFilePos( |
| 1325 | unzFile file, |
| 1326 | unz_file_pos* file_pos) |
| 1327 | { |
| 1328 | unz64_file_pos file_pos64; |
| 1329 | int err = unzGetFilePos64(file,&file_pos64); |
| 1330 | if (err==UNZ_OK) |
| 1331 | { |
| 1332 | file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory; |
| @@ -1333,12 +1209,11 @@ | |
| 1333 | file_pos->num_of_file = (uLong)file_pos64.num_of_file; |
| 1334 | } |
| 1335 | return err; |
| 1336 | } |
| 1337 | |
| 1338 | extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos) |
| 1339 | { |
| 1340 | unz64_s* s; |
| 1341 | int err; |
| 1342 | |
| 1343 | if (file==NULL || file_pos==NULL) |
| 1344 | return UNZ_PARAMERROR; |
| @@ -1355,14 +1230,11 @@ | |
| 1355 | /* return results */ |
| 1356 | s->current_file_ok = (err == UNZ_OK); |
| 1357 | return err; |
| 1358 | } |
| 1359 | |
| 1360 | extern int ZEXPORT unzGoToFilePos( |
| 1361 | unzFile file, |
| 1362 | unz_file_pos* file_pos) |
| 1363 | { |
| 1364 | unz64_file_pos file_pos64; |
| 1365 | if (file_pos == NULL) |
| 1366 | return UNZ_PARAMERROR; |
| 1367 | |
| 1368 | file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory; |
| @@ -1380,14 +1252,13 @@ | |
| 1380 | Check the coherency of the local header and info in the end of central |
| 1381 | directory about this file |
| 1382 | store in *piSizeVar the size of extra info in local header |
| 1383 | (filename and size of extra field data) |
| 1384 | */ |
| 1385 | local int unz64local_CheckCurrentFileCoherencyHeader (unz64_s* s, uInt* piSizeVar, |
| 1386 | ZPOS64_T * poffset_local_extrafield, |
| 1387 | uInt * psize_local_extrafield) |
| 1388 | { |
| 1389 | uLong uMagic,uData,uFlags; |
| 1390 | uLong size_filename; |
| 1391 | uLong size_extra_field; |
| 1392 | int err=UNZ_OK; |
| 1393 | |
| @@ -1467,13 +1338,12 @@ | |
| 1467 | |
| 1468 | /* |
| 1469 | Open for reading data the current file in the zipfile. |
| 1470 | If there is no error and the file is opened, the return value is UNZ_OK. |
| 1471 | */ |
| 1472 | extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method, |
| 1473 | int* level, int raw, const char* password) |
| 1474 | { |
| 1475 | int err=UNZ_OK; |
| 1476 | uInt iSizeVar; |
| 1477 | unz64_s* s; |
| 1478 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1479 | ZPOS64_T offset_local_extrafield; /* offset of the local extra field */ |
| @@ -1507,11 +1377,11 @@ | |
| 1507 | pfile_in_zip_read_info->pos_local_extrafield=0; |
| 1508 | pfile_in_zip_read_info->raw=raw; |
| 1509 | |
| 1510 | if (pfile_in_zip_read_info->read_buffer==NULL) |
| 1511 | { |
| 1512 | TRYFREE(pfile_in_zip_read_info); |
| 1513 | return UNZ_INTERNALERROR; |
| 1514 | } |
| 1515 | |
| 1516 | pfile_in_zip_read_info->stream_initialised=0; |
| 1517 | |
| @@ -1564,12 +1434,12 @@ | |
| 1564 | err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0); |
| 1565 | if (err == Z_OK) |
| 1566 | pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED; |
| 1567 | else |
| 1568 | { |
| 1569 | TRYFREE(pfile_in_zip_read_info->read_buffer); |
| 1570 | TRYFREE(pfile_in_zip_read_info); |
| 1571 | return err; |
| 1572 | } |
| 1573 | #else |
| 1574 | pfile_in_zip_read_info->raw=1; |
| 1575 | #endif |
| @@ -1585,12 +1455,12 @@ | |
| 1585 | err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); |
| 1586 | if (err == Z_OK) |
| 1587 | pfile_in_zip_read_info->stream_initialised=Z_DEFLATED; |
| 1588 | else |
| 1589 | { |
| 1590 | TRYFREE(pfile_in_zip_read_info->read_buffer); |
| 1591 | TRYFREE(pfile_in_zip_read_info); |
| 1592 | return err; |
| 1593 | } |
| 1594 | /* windowBits is passed < 0 to tell that there is no zlib header. |
| 1595 | * Note that in this case inflate *requires* an extra "dummy" byte |
| 1596 | * after the compressed stream in order to complete decompression and |
| @@ -1638,29 +1508,25 @@ | |
| 1638 | |
| 1639 | |
| 1640 | return UNZ_OK; |
| 1641 | } |
| 1642 | |
| 1643 | extern int ZEXPORT unzOpenCurrentFile (unzFile file) |
| 1644 | { |
| 1645 | return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); |
| 1646 | } |
| 1647 | |
| 1648 | extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char* password) |
| 1649 | { |
| 1650 | return unzOpenCurrentFile3(file, NULL, NULL, 0, password); |
| 1651 | } |
| 1652 | |
| 1653 | extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int* method, int* level, int raw) |
| 1654 | { |
| 1655 | return unzOpenCurrentFile3(file, method, level, raw, NULL); |
| 1656 | } |
| 1657 | |
| 1658 | /** Addition for GDAL : START */ |
| 1659 | |
| 1660 | extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64( unzFile file) |
| 1661 | { |
| 1662 | unz64_s* s; |
| 1663 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1664 | s=(unz64_s*)file; |
| 1665 | if (file==NULL) |
| 1666 | return 0; //UNZ_PARAMERROR; |
| @@ -1676,17 +1542,16 @@ | |
| 1676 | /* |
| 1677 | Read bytes from the current file. |
| 1678 | buf contain buffer where data must be copied |
| 1679 | len the size of buf. |
| 1680 | |
| 1681 | return the number of byte copied if somes bytes are copied |
| 1682 | return 0 if the end of file was reached |
| 1683 | return <0 with error code if there is an error |
| 1684 | (UNZ_ERRNO for IO error, or zLib error for uncompress error) |
| 1685 | */ |
| 1686 | extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len) |
| 1687 | { |
| 1688 | int err=UNZ_OK; |
| 1689 | uInt iRead = 0; |
| 1690 | unz64_s* s; |
| 1691 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1692 | if (file==NULL) |
| @@ -1889,12 +1754,11 @@ | |
| 1889 | |
| 1890 | |
| 1891 | /* |
| 1892 | Give the current position in uncompressed data |
| 1893 | */ |
| 1894 | extern z_off_t ZEXPORT unztell (unzFile file) |
| 1895 | { |
| 1896 | unz64_s* s; |
| 1897 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1898 | if (file==NULL) |
| 1899 | return UNZ_PARAMERROR; |
| 1900 | s=(unz64_s*)file; |
| @@ -1904,12 +1768,11 @@ | |
| 1904 | return UNZ_PARAMERROR; |
| 1905 | |
| 1906 | return (z_off_t)pfile_in_zip_read_info->stream.total_out; |
| 1907 | } |
| 1908 | |
| 1909 | extern ZPOS64_T ZEXPORT unztell64 (unzFile file) |
| 1910 | { |
| 1911 | |
| 1912 | unz64_s* s; |
| 1913 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1914 | if (file==NULL) |
| 1915 | return (ZPOS64_T)-1; |
| @@ -1924,12 +1787,11 @@ | |
| 1924 | |
| 1925 | |
| 1926 | /* |
| 1927 | return 1 if the end of file was reached, 0 elsewhere |
| 1928 | */ |
| 1929 | extern int ZEXPORT unzeof (unzFile file) |
| 1930 | { |
| 1931 | unz64_s* s; |
| 1932 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1933 | if (file==NULL) |
| 1934 | return UNZ_PARAMERROR; |
| 1935 | s=(unz64_s*)file; |
| @@ -1956,12 +1818,11 @@ | |
| 1956 | if buf!=NULL, len is the size of the buffer, the extra header is copied in |
| 1957 | buf. |
| 1958 | the return value is the number of bytes copied in buf, or (if <0) |
| 1959 | the error code |
| 1960 | */ |
| 1961 | extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len) |
| 1962 | { |
| 1963 | unz64_s* s; |
| 1964 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1965 | uInt read_now; |
| 1966 | ZPOS64_T size_to_read; |
| 1967 | |
| @@ -2004,12 +1865,11 @@ | |
| 2004 | |
| 2005 | /* |
| 2006 | Close the file in zip opened with unzOpenCurrentFile |
| 2007 | Return UNZ_CRCERROR if all the file was read but the CRC is not good |
| 2008 | */ |
| 2009 | extern int ZEXPORT unzCloseCurrentFile (unzFile file) |
| 2010 | { |
| 2011 | int err=UNZ_OK; |
| 2012 | |
| 2013 | unz64_s* s; |
| 2014 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 2015 | if (file==NULL) |
| @@ -2027,11 +1887,11 @@ | |
| 2027 | if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) |
| 2028 | err=UNZ_CRCERROR; |
| 2029 | } |
| 2030 | |
| 2031 | |
| 2032 | TRYFREE(pfile_in_zip_read_info->read_buffer); |
| 2033 | pfile_in_zip_read_info->read_buffer = NULL; |
| 2034 | if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED) |
| 2035 | inflateEnd(&pfile_in_zip_read_info->stream); |
| 2036 | #ifdef HAVE_BZIP2 |
| 2037 | else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED) |
| @@ -2038,11 +1898,11 @@ | |
| 2038 | BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream); |
| 2039 | #endif |
| 2040 | |
| 2041 | |
| 2042 | pfile_in_zip_read_info->stream_initialised = 0; |
| 2043 | TRYFREE(pfile_in_zip_read_info); |
| 2044 | |
| 2045 | s->pfile_in_zip_read=NULL; |
| 2046 | |
| 2047 | return err; |
| 2048 | } |
| @@ -2051,12 +1911,11 @@ | |
| 2051 | /* |
| 2052 | Get the global comment string of the ZipFile, in the szComment buffer. |
| 2053 | uSizeBuf is the size of the szComment buffer. |
| 2054 | return the number of byte copied or an error code <0 |
| 2055 | */ |
| 2056 | extern int ZEXPORT unzGetGlobalComment (unzFile file, char * szComment, uLong uSizeBuf) |
| 2057 | { |
| 2058 | unz64_s* s; |
| 2059 | uLong uReadThis ; |
| 2060 | if (file==NULL) |
| 2061 | return (int)UNZ_PARAMERROR; |
| 2062 | s=(unz64_s*)file; |
| @@ -2079,12 +1938,11 @@ | |
| 2079 | *(szComment+s->gi.size_comment)='\0'; |
| 2080 | return (int)uReadThis; |
| 2081 | } |
| 2082 | |
| 2083 | /* Additions by RX '2004 */ |
| 2084 | extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) |
| 2085 | { |
| 2086 | unz64_s* s; |
| 2087 | |
| 2088 | if (file==NULL) |
| 2089 | return 0; //UNZ_PARAMERROR; |
| 2090 | s=(unz64_s*)file; |
| @@ -2094,22 +1952,20 @@ | |
| 2094 | if (s->num_file==s->gi.number_entry) |
| 2095 | return 0; |
| 2096 | return s->pos_in_central_dir; |
| 2097 | } |
| 2098 | |
| 2099 | extern uLong ZEXPORT unzGetOffset (unzFile file) |
| 2100 | { |
| 2101 | ZPOS64_T offset64; |
| 2102 | |
| 2103 | if (file==NULL) |
| 2104 | return 0; //UNZ_PARAMERROR; |
| 2105 | offset64 = unzGetOffset64(file); |
| 2106 | return (uLong)offset64; |
| 2107 | } |
| 2108 | |
| 2109 | extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) |
| 2110 | { |
| 2111 | unz64_s* s; |
| 2112 | int err; |
| 2113 | |
| 2114 | if (file==NULL) |
| 2115 | return UNZ_PARAMERROR; |
| @@ -2122,9 +1978,8 @@ | |
| 2122 | NULL,0,NULL,0,NULL,0); |
| 2123 | s->current_file_ok = (err == UNZ_OK); |
| 2124 | return err; |
| 2125 | } |
| 2126 | |
| 2127 | extern int ZEXPORT unzSetOffset (unzFile file, uLong pos) |
| 2128 | { |
| 2129 | return unzSetOffset64(file,pos); |
| 2130 | } |
| 2131 |
| --- compat/zlib/contrib/minizip/unzip.c | |
| +++ compat/zlib/contrib/minizip/unzip.c | |
| @@ -47,16 +47,16 @@ | |
| 47 | 2007-2008 - Even Rouault - Add unzip support for ZIP64 |
| 48 | |
| 49 | Copyright (C) 2007-2008 Even Rouault |
| 50 | |
| 51 | |
| 52 | Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again). |
| 53 | Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G |
| 54 | should only read the compressed/uncompressed size from the Zip64 format if |
| 55 | the size from normal header was 0xFFFFFFFF |
| 56 | Oct-2009 - Mathias Svensson - Applied some bug fixes from patches received from Gilles Vollant |
| 57 | Oct-2009 - Mathias Svensson - Applied support to unzip files with compression method BZIP2 (bzip2 lib is required) |
| 58 | Patch created by Daniel Borca |
| 59 | |
| 60 | Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer |
| 61 | |
| 62 | Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson |
| @@ -75,12 +75,10 @@ | |
| 75 | #include "zlib.h" |
| 76 | #include "unzip.h" |
| 77 | |
| 78 | #ifdef STDC |
| 79 | # include <stddef.h> |
| 80 | #endif |
| 81 | #ifdef NO_ERRNO_H |
| 82 | extern int errno; |
| 83 | #else |
| 84 | # include <errno.h> |
| @@ -109,13 +107,10 @@ | |
| 107 | #endif |
| 108 | |
| 109 | #ifndef ALLOC |
| 110 | # define ALLOC(size) (malloc(size)) |
| 111 | #endif |
| 112 | |
| 113 | #define SIZECENTRALDIRITEM (0x2e) |
| 114 | #define SIZEZIPLOCALHEADER (0x1e) |
| 115 | |
| 116 | |
| @@ -151,11 +146,11 @@ | |
| 146 | uLong crc32; /* crc32 of all data uncompressed */ |
| 147 | uLong crc32_wait; /* crc32 we must obtain after decompress all */ |
| 148 | ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */ |
| 149 | ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/ |
| 150 | zlib_filefunc64_32_def z_filefunc; |
| 151 | voidpf filestream; /* io structure of the zipfile */ |
| 152 | uLong compression_method; /* compression method (0==store) */ |
| 153 | ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
| 154 | int raw; |
| 155 | } file_in_zip64_read_info_s; |
| 156 | |
| @@ -164,11 +159,11 @@ | |
| 159 | */ |
| 160 | typedef struct |
| 161 | { |
| 162 | zlib_filefunc64_32_def z_filefunc; |
| 163 | int is64bitOpenFunction; |
| 164 | voidpf filestream; /* io structure of the zipfile */ |
| 165 | unz_global_info64 gi; /* public global information */ |
| 166 | ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
| 167 | ZPOS64_T num_file; /* number of the current file in the zipfile*/ |
| 168 | ZPOS64_T pos_in_central_dir; /* pos of the current file in the central dir*/ |
| 169 | ZPOS64_T current_file_ok; /* flag about the usability of the current file*/ |
| @@ -194,162 +189,80 @@ | |
| 189 | |
| 190 | |
| 191 | #ifndef NOUNCRYPT |
| 192 | #include "crypt.h" |
| 193 | #endif |
| 194 | |
| 195 | |
| 196 | /* =========================================================================== |
| 197 | Reads a long in LSB order from the given gz_stream. Sets |
| 198 | */ |
| 199 | |
| 200 | local int unz64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def, |
| 201 | voidpf filestream, |
| 202 | uLong *pX) { |
| 203 | unsigned char c[2]; |
| 204 | int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,2); |
| 205 | if (err==2) |
| 206 | { |
| 207 | *pX = c[0] | ((uLong)c[1] << 8); |
| 208 | return UNZ_OK; |
| 209 | } |
| 210 | else |
| 211 | { |
| 212 | *pX = 0; |
| 213 | if (ZERROR64(*pzlib_filefunc_def,filestream)) |
| 214 | return UNZ_ERRNO; |
| 215 | else |
| 216 | return UNZ_EOF; |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | local int unz64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def, |
| 221 | voidpf filestream, |
| 222 | uLong *pX) { |
| 223 | unsigned char c[4]; |
| 224 | int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,4); |
| 225 | if (err==4) |
| 226 | { |
| 227 | *pX = c[0] | ((uLong)c[1] << 8) | ((uLong)c[2] << 16) | ((uLong)c[3] << 24); |
| 228 | return UNZ_OK; |
| 229 | } |
| 230 | else |
| 231 | { |
| 232 | *pX = 0; |
| 233 | if (ZERROR64(*pzlib_filefunc_def,filestream)) |
| 234 | return UNZ_ERRNO; |
| 235 | else |
| 236 | return UNZ_EOF; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | |
| 241 | local int unz64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def, |
| 242 | voidpf filestream, |
| 243 | ZPOS64_T *pX) { |
| 244 | unsigned char c[8]; |
| 245 | int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,8); |
| 246 | if (err==8) |
| 247 | { |
| 248 | *pX = c[0] | ((ZPOS64_T)c[1] << 8) | ((ZPOS64_T)c[2] << 16) | ((ZPOS64_T)c[3] << 24) |
| 249 | | ((ZPOS64_T)c[4] << 32) | ((ZPOS64_T)c[5] << 40) | ((ZPOS64_T)c[6] << 48) | ((ZPOS64_T)c[7] << 56); |
| 250 | return UNZ_OK; |
| 251 | } |
| 252 | else |
| 253 | { |
| 254 | *pX = 0; |
| 255 | if (ZERROR64(*pzlib_filefunc_def,filestream)) |
| 256 | return UNZ_ERRNO; |
| 257 | else |
| 258 | return UNZ_EOF; |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | /* My own strcmpi / strcasecmp */ |
| 263 | local int strcmpcasenosensitive_internal(const char* fileName1, const char* fileName2) { |
| 264 | for (;;) |
| 265 | { |
| 266 | char c1=*(fileName1++); |
| 267 | char c2=*(fileName2++); |
| 268 | if ((c1>='a') && (c1<='z')) |
| @@ -377,23 +290,21 @@ | |
| 290 | #ifndef STRCMPCASENOSENTIVEFUNCTION |
| 291 | #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal |
| 292 | #endif |
| 293 | |
| 294 | /* |
| 295 | Compare two filenames (fileName1,fileName2). |
| 296 | If iCaseSensitivity = 1, comparison is case sensitive (like strcmp) |
| 297 | If iCaseSensitivity = 2, comparison is not case sensitive (like strcmpi |
| 298 | or strcasecmp) |
| 299 | If iCaseSensitivity = 0, case sensitivity is default of your operating system |
| 300 | (like 1 on Unix, 2 on Windows) |
| 301 | |
| 302 | */ |
| 303 | extern int ZEXPORT unzStringFileNameCompare (const char* fileName1, |
| 304 | const char* fileName2, |
| 305 | int iCaseSensitivity) { |
| 306 | if (iCaseSensitivity==0) |
| 307 | iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; |
| 308 | |
| 309 | if (iCaseSensitivity==1) |
| 310 | return strcmp(fileName1,fileName2); |
| @@ -403,35 +314,37 @@ | |
| 314 | |
| 315 | #ifndef BUFREADCOMMENT |
| 316 | #define BUFREADCOMMENT (0x400) |
| 317 | #endif |
| 318 | |
| 319 | #ifndef CENTRALDIRINVALID |
| 320 | #define CENTRALDIRINVALID ((ZPOS64_T)(-1)) |
| 321 | #endif |
| 322 | |
| 323 | /* |
| 324 | Locate the Central directory of a zipfile (at the end, just before |
| 325 | the global comment) |
| 326 | */ |
| 327 | local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { |
| 328 | unsigned char* buf; |
| 329 | ZPOS64_T uSizeFile; |
| 330 | ZPOS64_T uBackRead; |
| 331 | ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
| 332 | ZPOS64_T uPosFound=CENTRALDIRINVALID; |
| 333 | |
| 334 | if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) |
| 335 | return CENTRALDIRINVALID; |
| 336 | |
| 337 | |
| 338 | uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); |
| 339 | |
| 340 | if (uMaxBack>uSizeFile) |
| 341 | uMaxBack = uSizeFile; |
| 342 | |
| 343 | buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); |
| 344 | if (buf==NULL) |
| 345 | return CENTRALDIRINVALID; |
| 346 | |
| 347 | uBackRead = 4; |
| 348 | while (uBackRead<uMaxBack) |
| 349 | { |
| 350 | uLong uReadSize; |
| @@ -457,49 +370,44 @@ | |
| 370 | { |
| 371 | uPosFound = uReadPos+(unsigned)i; |
| 372 | break; |
| 373 | } |
| 374 | |
| 375 | if (uPosFound!=CENTRALDIRINVALID) |
| 376 | break; |
| 377 | } |
| 378 | free(buf); |
| 379 | return uPosFound; |
| 380 | } |
| 381 | |
| 382 | |
| 383 | /* |
| 384 | Locate the Central directory 64 of a zipfile (at the end, just before |
| 385 | the global comment) |
| 386 | */ |
| 387 | local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, |
| 388 | voidpf filestream) { |
| 389 | unsigned char* buf; |
| 390 | ZPOS64_T uSizeFile; |
| 391 | ZPOS64_T uBackRead; |
| 392 | ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
| 393 | ZPOS64_T uPosFound=CENTRALDIRINVALID; |
| 394 | uLong uL; |
| 395 | ZPOS64_T relativeOffset; |
| 396 | |
| 397 | if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) |
| 398 | return CENTRALDIRINVALID; |
| 399 | |
| 400 | |
| 401 | uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); |
| 402 | |
| 403 | if (uMaxBack>uSizeFile) |
| 404 | uMaxBack = uSizeFile; |
| 405 | |
| 406 | buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); |
| 407 | if (buf==NULL) |
| 408 | return CENTRALDIRINVALID; |
| 409 | |
| 410 | uBackRead = 4; |
| 411 | while (uBackRead<uMaxBack) |
| 412 | { |
| 413 | uLong uReadSize; |
| @@ -525,51 +433,51 @@ | |
| 433 | { |
| 434 | uPosFound = uReadPos+(unsigned)i; |
| 435 | break; |
| 436 | } |
| 437 | |
| 438 | if (uPosFound!=CENTRALDIRINVALID) |
| 439 | break; |
| 440 | } |
| 441 | free(buf); |
| 442 | if (uPosFound == CENTRALDIRINVALID) |
| 443 | return CENTRALDIRINVALID; |
| 444 | |
| 445 | /* Zip64 end of central directory locator */ |
| 446 | if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0) |
| 447 | return CENTRALDIRINVALID; |
| 448 | |
| 449 | /* the signature, already checked */ |
| 450 | if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
| 451 | return CENTRALDIRINVALID; |
| 452 | |
| 453 | /* number of the disk with the start of the zip64 end of central directory */ |
| 454 | if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
| 455 | return CENTRALDIRINVALID; |
| 456 | if (uL != 0) |
| 457 | return CENTRALDIRINVALID; |
| 458 | |
| 459 | /* relative offset of the zip64 end of central directory record */ |
| 460 | if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK) |
| 461 | return CENTRALDIRINVALID; |
| 462 | |
| 463 | /* total number of disks */ |
| 464 | if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
| 465 | return CENTRALDIRINVALID; |
| 466 | if (uL != 1) |
| 467 | return CENTRALDIRINVALID; |
| 468 | |
| 469 | /* Goto end of central directory record */ |
| 470 | if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0) |
| 471 | return CENTRALDIRINVALID; |
| 472 | |
| 473 | /* the signature */ |
| 474 | if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
| 475 | return CENTRALDIRINVALID; |
| 476 | |
| 477 | if (uL != 0x06064b50) |
| 478 | return CENTRALDIRINVALID; |
| 479 | |
| 480 | return relativeOffset; |
| 481 | } |
| 482 | |
| 483 | /* |
| @@ -579,23 +487,22 @@ | |
| 487 | If the zipfile cannot be opened (file doesn't exist or in not valid), the |
| 488 | return value is NULL. |
| 489 | Else, the return value is a unzFile Handle, usable with other function |
| 490 | of this unzip package. |
| 491 | */ |
| 492 | local unzFile unzOpenInternal(const void *path, |
| 493 | zlib_filefunc64_32_def* pzlib_filefunc64_32_def, |
| 494 | int is64bitOpenFunction) { |
| 495 | unz64_s us; |
| 496 | unz64_s *s; |
| 497 | ZPOS64_T central_pos; |
| 498 | uLong uL; |
| 499 | |
| 500 | uLong number_disk; /* number of the current dist, used for |
| 501 | spanning ZIP, unsupported, always 0*/ |
| 502 | uLong number_disk_with_CD; /* number the the disk with central dir, used |
| 503 | for spanning ZIP, unsupported, always 0*/ |
| 504 | ZPOS64_T number_entry_CD; /* total number of entries in |
| 505 | the central dir |
| 506 | (same than number_entry on nospan) */ |
| 507 | |
| 508 | int err=UNZ_OK; |
| @@ -619,11 +526,11 @@ | |
| 526 | ZLIB_FILEFUNC_MODE_EXISTING); |
| 527 | if (us.filestream==NULL) |
| 528 | return NULL; |
| 529 | |
| 530 | central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream); |
| 531 | if (central_pos!=CENTRALDIRINVALID) |
| 532 | { |
| 533 | uLong uS; |
| 534 | ZPOS64_T uL64; |
| 535 | |
| 536 | us.isZip64 = 1; |
| @@ -681,11 +588,11 @@ | |
| 588 | us.gi.size_comment = 0; |
| 589 | } |
| 590 | else |
| 591 | { |
| 592 | central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream); |
| 593 | if (central_pos==CENTRALDIRINVALID) |
| 594 | err=UNZ_ERRNO; |
| 595 | |
| 596 | us.isZip64 = 0; |
| 597 | |
| 598 | if (ZSEEK64(us.z_filefunc, us.filestream, |
| @@ -760,13 +667,12 @@ | |
| 667 | } |
| 668 | return (unzFile)s; |
| 669 | } |
| 670 | |
| 671 | |
| 672 | extern unzFile ZEXPORT unzOpen2(const char *path, |
| 673 | zlib_filefunc_def* pzlib_filefunc32_def) { |
| 674 | if (pzlib_filefunc32_def != NULL) |
| 675 | { |
| 676 | zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; |
| 677 | fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def); |
| 678 | return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 0); |
| @@ -773,13 +679,12 @@ | |
| 679 | } |
| 680 | else |
| 681 | return unzOpenInternal(path, NULL, 0); |
| 682 | } |
| 683 | |
| 684 | extern unzFile ZEXPORT unzOpen2_64(const void *path, |
| 685 | zlib_filefunc64_def* pzlib_filefunc_def) { |
| 686 | if (pzlib_filefunc_def != NULL) |
| 687 | { |
| 688 | zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; |
| 689 | zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def; |
| 690 | zlib_filefunc64_32_def_fill.ztell32_file = NULL; |
| @@ -788,57 +693,52 @@ | |
| 693 | } |
| 694 | else |
| 695 | return unzOpenInternal(path, NULL, 1); |
| 696 | } |
| 697 | |
| 698 | extern unzFile ZEXPORT unzOpen(const char *path) { |
| 699 | return unzOpenInternal(path, NULL, 0); |
| 700 | } |
| 701 | |
| 702 | extern unzFile ZEXPORT unzOpen64(const void *path) { |
| 703 | return unzOpenInternal(path, NULL, 1); |
| 704 | } |
| 705 | |
| 706 | /* |
| 707 | Close a ZipFile opened with unzOpen. |
| 708 | If there is files inside the .Zip opened with unzOpenCurrentFile (see later), |
| 709 | these files MUST be closed with unzCloseCurrentFile before call unzClose. |
| 710 | return UNZ_OK if there is no problem. */ |
| 711 | extern int ZEXPORT unzClose(unzFile file) { |
| 712 | unz64_s* s; |
| 713 | if (file==NULL) |
| 714 | return UNZ_PARAMERROR; |
| 715 | s=(unz64_s*)file; |
| 716 | |
| 717 | if (s->pfile_in_zip_read!=NULL) |
| 718 | unzCloseCurrentFile(file); |
| 719 | |
| 720 | ZCLOSE64(s->z_filefunc, s->filestream); |
| 721 | free(s); |
| 722 | return UNZ_OK; |
| 723 | } |
| 724 | |
| 725 | |
| 726 | /* |
| 727 | Write info about the ZipFile in the *pglobal_info structure. |
| 728 | No preparation of the structure is needed |
| 729 | return UNZ_OK if there is no problem. */ |
| 730 | extern int ZEXPORT unzGetGlobalInfo64(unzFile file, unz_global_info64* pglobal_info) { |
| 731 | unz64_s* s; |
| 732 | if (file==NULL) |
| 733 | return UNZ_PARAMERROR; |
| 734 | s=(unz64_s*)file; |
| 735 | *pglobal_info=s->gi; |
| 736 | return UNZ_OK; |
| 737 | } |
| 738 | |
| 739 | extern int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info* pglobal_info32) { |
| 740 | unz64_s* s; |
| 741 | if (file==NULL) |
| 742 | return UNZ_PARAMERROR; |
| 743 | s=(unz64_s*)file; |
| 744 | /* to do : check if number_entry is not truncated */ |
| @@ -845,14 +745,13 @@ | |
| 745 | pglobal_info32->number_entry = (uLong)s->gi.number_entry; |
| 746 | pglobal_info32->size_comment = s->gi.size_comment; |
| 747 | return UNZ_OK; |
| 748 | } |
| 749 | /* |
| 750 | Translate date/time from Dos format to tm_unz (readable more easily) |
| 751 | */ |
| 752 | local void unz64local_DosDateToTmuDate(ZPOS64_T ulDosDate, tm_unz* ptm) { |
| 753 | ZPOS64_T uDate; |
| 754 | uDate = (ZPOS64_T)(ulDosDate>>16); |
| 755 | ptm->tm_mday = (int)(uDate&0x1f) ; |
| 756 | ptm->tm_mon = (int)((((uDate)&0x1E0)/0x20)-1) ; |
| 757 | ptm->tm_year = (int)(((uDate&0x0FE00)/0x0200)+1980) ; |
| @@ -863,32 +762,20 @@ | |
| 762 | } |
| 763 | |
| 764 | /* |
| 765 | Get Info about the current file in the zipfile, with internal only info |
| 766 | */ |
| 767 | local int unz64local_GetCurrentFileInfoInternal(unzFile file, |
| 768 | unz_file_info64 *pfile_info, |
| 769 | unz_file_info64_internal |
| 770 | *pfile_info_internal, |
| 771 | char *szFileName, |
| 772 | uLong fileNameBufferSize, |
| 773 | void *extraField, |
| 774 | uLong extraFieldBufferSize, |
| 775 | char *szComment, |
| 776 | uLong commentBufferSize) { |
| 777 | unz64_s* s; |
| 778 | unz_file_info64 file_info; |
| 779 | unz_file_info64_internal file_info_internal; |
| 780 | int err=UNZ_OK; |
| 781 | uLong uMagic; |
| @@ -1036,37 +923,35 @@ | |
| 923 | err=UNZ_ERRNO; |
| 924 | |
| 925 | /* ZIP64 extra fields */ |
| 926 | if (headerId == 0x0001) |
| 927 | { |
| 928 | if(file_info.uncompressed_size == MAXU32) |
| 929 | { |
| 930 | if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) |
| 931 | err=UNZ_ERRNO; |
| 932 | } |
| 933 | |
| 934 | if(file_info.compressed_size == MAXU32) |
| 935 | { |
| 936 | if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) |
| 937 | err=UNZ_ERRNO; |
| 938 | } |
| 939 | |
| 940 | if(file_info_internal.offset_curfile == MAXU32) |
| 941 | { |
| 942 | /* Relative Header offset */ |
| 943 | if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) |
| 944 | err=UNZ_ERRNO; |
| 945 | } |
| 946 | |
| 947 | if(file_info.disk_num_start == 0xffff) |
| 948 | { |
| 949 | /* Disk Start Number */ |
| 950 | if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) |
| 951 | err=UNZ_ERRNO; |
| 952 | } |
| 953 | |
| 954 | } |
| 955 | else |
| 956 | { |
| 957 | if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0) |
| @@ -1119,28 +1004,26 @@ | |
| 1004 | /* |
| 1005 | Write info about the ZipFile in the *pglobal_info structure. |
| 1006 | No preparation of the structure is needed |
| 1007 | return UNZ_OK if there is no problem. |
| 1008 | */ |
| 1009 | extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file, |
| 1010 | unz_file_info64 * pfile_info, |
| 1011 | char * szFileName, uLong fileNameBufferSize, |
| 1012 | void *extraField, uLong extraFieldBufferSize, |
| 1013 | char* szComment, uLong commentBufferSize) { |
| 1014 | return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL, |
| 1015 | szFileName,fileNameBufferSize, |
| 1016 | extraField,extraFieldBufferSize, |
| 1017 | szComment,commentBufferSize); |
| 1018 | } |
| 1019 | |
| 1020 | extern int ZEXPORT unzGetCurrentFileInfo(unzFile file, |
| 1021 | unz_file_info * pfile_info, |
| 1022 | char * szFileName, uLong fileNameBufferSize, |
| 1023 | void *extraField, uLong extraFieldBufferSize, |
| 1024 | char* szComment, uLong commentBufferSize) { |
| 1025 | int err; |
| 1026 | unz_file_info64 file_info64; |
| 1027 | err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL, |
| 1028 | szFileName,fileNameBufferSize, |
| 1029 | extraField,extraFieldBufferSize, |
| @@ -1160,11 +1043,11 @@ | |
| 1043 | |
| 1044 | pfile_info->disk_num_start = file_info64.disk_num_start; |
| 1045 | pfile_info->internal_fa = file_info64.internal_fa; |
| 1046 | pfile_info->external_fa = file_info64.external_fa; |
| 1047 | |
| 1048 | pfile_info->tmu_date = file_info64.tmu_date; |
| 1049 | |
| 1050 | |
| 1051 | pfile_info->compressed_size = (uLong)file_info64.compressed_size; |
| 1052 | pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size; |
| 1053 | |
| @@ -1173,12 +1056,11 @@ | |
| 1056 | } |
| 1057 | /* |
| 1058 | Set the current file of the zipfile to the first file. |
| 1059 | return UNZ_OK if there is no problem |
| 1060 | */ |
| 1061 | extern int ZEXPORT unzGoToFirstFile(unzFile file) { |
| 1062 | int err=UNZ_OK; |
| 1063 | unz64_s* s; |
| 1064 | if (file==NULL) |
| 1065 | return UNZ_PARAMERROR; |
| 1066 | s=(unz64_s*)file; |
| @@ -1194,12 +1076,11 @@ | |
| 1076 | /* |
| 1077 | Set the current file of the zipfile to the next file. |
| 1078 | return UNZ_OK if there is no problem |
| 1079 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. |
| 1080 | */ |
| 1081 | extern int ZEXPORT unzGoToNextFile(unzFile file) { |
| 1082 | unz64_s* s; |
| 1083 | int err; |
| 1084 | |
| 1085 | if (file==NULL) |
| 1086 | return UNZ_PARAMERROR; |
| @@ -1227,12 +1108,11 @@ | |
| 1108 | |
| 1109 | return value : |
| 1110 | UNZ_OK if the file is found. It becomes the current file. |
| 1111 | UNZ_END_OF_LIST_OF_FILE if the file is not found |
| 1112 | */ |
| 1113 | extern int ZEXPORT unzLocateFile(unzFile file, const char *szFileName, int iCaseSensitivity) { |
| 1114 | unz64_s* s; |
| 1115 | int err; |
| 1116 | |
| 1117 | /* We remember the 'current' position in the file so that we can jump |
| 1118 | * back there if we fail. |
| @@ -1303,12 +1183,11 @@ | |
| 1183 | ZPOS64_T pos_in_zip_directory; // offset in file |
| 1184 | ZPOS64_T num_of_file; // # of file |
| 1185 | } unz_file_pos; |
| 1186 | */ |
| 1187 | |
| 1188 | extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) { |
| 1189 | unz64_s* s; |
| 1190 | |
| 1191 | if (file==NULL || file_pos==NULL) |
| 1192 | return UNZ_PARAMERROR; |
| 1193 | s=(unz64_s*)file; |
| @@ -1319,14 +1198,11 @@ | |
| 1198 | file_pos->num_of_file = s->num_file; |
| 1199 | |
| 1200 | return UNZ_OK; |
| 1201 | } |
| 1202 | |
| 1203 | extern int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos* file_pos) { |
| 1204 | unz64_file_pos file_pos64; |
| 1205 | int err = unzGetFilePos64(file,&file_pos64); |
| 1206 | if (err==UNZ_OK) |
| 1207 | { |
| 1208 | file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory; |
| @@ -1333,12 +1209,11 @@ | |
| 1209 | file_pos->num_of_file = (uLong)file_pos64.num_of_file; |
| 1210 | } |
| 1211 | return err; |
| 1212 | } |
| 1213 | |
| 1214 | extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos) { |
| 1215 | unz64_s* s; |
| 1216 | int err; |
| 1217 | |
| 1218 | if (file==NULL || file_pos==NULL) |
| 1219 | return UNZ_PARAMERROR; |
| @@ -1355,14 +1230,11 @@ | |
| 1230 | /* return results */ |
| 1231 | s->current_file_ok = (err == UNZ_OK); |
| 1232 | return err; |
| 1233 | } |
| 1234 | |
| 1235 | extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos* file_pos) { |
| 1236 | unz64_file_pos file_pos64; |
| 1237 | if (file_pos == NULL) |
| 1238 | return UNZ_PARAMERROR; |
| 1239 | |
| 1240 | file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory; |
| @@ -1380,14 +1252,13 @@ | |
| 1252 | Check the coherency of the local header and info in the end of central |
| 1253 | directory about this file |
| 1254 | store in *piSizeVar the size of extra info in local header |
| 1255 | (filename and size of extra field data) |
| 1256 | */ |
| 1257 | local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* piSizeVar, |
| 1258 | ZPOS64_T * poffset_local_extrafield, |
| 1259 | uInt * psize_local_extrafield) { |
| 1260 | uLong uMagic,uData,uFlags; |
| 1261 | uLong size_filename; |
| 1262 | uLong size_extra_field; |
| 1263 | int err=UNZ_OK; |
| 1264 | |
| @@ -1467,13 +1338,12 @@ | |
| 1338 | |
| 1339 | /* |
| 1340 | Open for reading data the current file in the zipfile. |
| 1341 | If there is no error and the file is opened, the return value is UNZ_OK. |
| 1342 | */ |
| 1343 | extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method, |
| 1344 | int* level, int raw, const char* password) { |
| 1345 | int err=UNZ_OK; |
| 1346 | uInt iSizeVar; |
| 1347 | unz64_s* s; |
| 1348 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1349 | ZPOS64_T offset_local_extrafield; /* offset of the local extra field */ |
| @@ -1507,11 +1377,11 @@ | |
| 1377 | pfile_in_zip_read_info->pos_local_extrafield=0; |
| 1378 | pfile_in_zip_read_info->raw=raw; |
| 1379 | |
| 1380 | if (pfile_in_zip_read_info->read_buffer==NULL) |
| 1381 | { |
| 1382 | free(pfile_in_zip_read_info); |
| 1383 | return UNZ_INTERNALERROR; |
| 1384 | } |
| 1385 | |
| 1386 | pfile_in_zip_read_info->stream_initialised=0; |
| 1387 | |
| @@ -1564,12 +1434,12 @@ | |
| 1434 | err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0); |
| 1435 | if (err == Z_OK) |
| 1436 | pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED; |
| 1437 | else |
| 1438 | { |
| 1439 | free(pfile_in_zip_read_info->read_buffer); |
| 1440 | free(pfile_in_zip_read_info); |
| 1441 | return err; |
| 1442 | } |
| 1443 | #else |
| 1444 | pfile_in_zip_read_info->raw=1; |
| 1445 | #endif |
| @@ -1585,12 +1455,12 @@ | |
| 1455 | err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); |
| 1456 | if (err == Z_OK) |
| 1457 | pfile_in_zip_read_info->stream_initialised=Z_DEFLATED; |
| 1458 | else |
| 1459 | { |
| 1460 | free(pfile_in_zip_read_info->read_buffer); |
| 1461 | free(pfile_in_zip_read_info); |
| 1462 | return err; |
| 1463 | } |
| 1464 | /* windowBits is passed < 0 to tell that there is no zlib header. |
| 1465 | * Note that in this case inflate *requires* an extra "dummy" byte |
| 1466 | * after the compressed stream in order to complete decompression and |
| @@ -1638,29 +1508,25 @@ | |
| 1508 | |
| 1509 | |
| 1510 | return UNZ_OK; |
| 1511 | } |
| 1512 | |
| 1513 | extern int ZEXPORT unzOpenCurrentFile(unzFile file) { |
| 1514 | return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); |
| 1515 | } |
| 1516 | |
| 1517 | extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file, const char* password) { |
| 1518 | return unzOpenCurrentFile3(file, NULL, NULL, 0, password); |
| 1519 | } |
| 1520 | |
| 1521 | extern int ZEXPORT unzOpenCurrentFile2(unzFile file, int* method, int* level, int raw) { |
| 1522 | return unzOpenCurrentFile3(file, method, level, raw, NULL); |
| 1523 | } |
| 1524 | |
| 1525 | /** Addition for GDAL : START */ |
| 1526 | |
| 1527 | extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file) { |
| 1528 | unz64_s* s; |
| 1529 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1530 | s=(unz64_s*)file; |
| 1531 | if (file==NULL) |
| 1532 | return 0; //UNZ_PARAMERROR; |
| @@ -1676,17 +1542,16 @@ | |
| 1542 | /* |
| 1543 | Read bytes from the current file. |
| 1544 | buf contain buffer where data must be copied |
| 1545 | len the size of buf. |
| 1546 | |
| 1547 | return the number of byte copied if some bytes are copied |
| 1548 | return 0 if the end of file was reached |
| 1549 | return <0 with error code if there is an error |
| 1550 | (UNZ_ERRNO for IO error, or zLib error for uncompress error) |
| 1551 | */ |
| 1552 | extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) { |
| 1553 | int err=UNZ_OK; |
| 1554 | uInt iRead = 0; |
| 1555 | unz64_s* s; |
| 1556 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1557 | if (file==NULL) |
| @@ -1889,12 +1754,11 @@ | |
| 1754 | |
| 1755 | |
| 1756 | /* |
| 1757 | Give the current position in uncompressed data |
| 1758 | */ |
| 1759 | extern z_off_t ZEXPORT unztell(unzFile file) { |
| 1760 | unz64_s* s; |
| 1761 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1762 | if (file==NULL) |
| 1763 | return UNZ_PARAMERROR; |
| 1764 | s=(unz64_s*)file; |
| @@ -1904,12 +1768,11 @@ | |
| 1768 | return UNZ_PARAMERROR; |
| 1769 | |
| 1770 | return (z_off_t)pfile_in_zip_read_info->stream.total_out; |
| 1771 | } |
| 1772 | |
| 1773 | extern ZPOS64_T ZEXPORT unztell64(unzFile file) { |
| 1774 | |
| 1775 | unz64_s* s; |
| 1776 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1777 | if (file==NULL) |
| 1778 | return (ZPOS64_T)-1; |
| @@ -1924,12 +1787,11 @@ | |
| 1787 | |
| 1788 | |
| 1789 | /* |
| 1790 | return 1 if the end of file was reached, 0 elsewhere |
| 1791 | */ |
| 1792 | extern int ZEXPORT unzeof(unzFile file) { |
| 1793 | unz64_s* s; |
| 1794 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1795 | if (file==NULL) |
| 1796 | return UNZ_PARAMERROR; |
| 1797 | s=(unz64_s*)file; |
| @@ -1956,12 +1818,11 @@ | |
| 1818 | if buf!=NULL, len is the size of the buffer, the extra header is copied in |
| 1819 | buf. |
| 1820 | the return value is the number of bytes copied in buf, or (if <0) |
| 1821 | the error code |
| 1822 | */ |
| 1823 | extern int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len) { |
| 1824 | unz64_s* s; |
| 1825 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1826 | uInt read_now; |
| 1827 | ZPOS64_T size_to_read; |
| 1828 | |
| @@ -2004,12 +1865,11 @@ | |
| 1865 | |
| 1866 | /* |
| 1867 | Close the file in zip opened with unzOpenCurrentFile |
| 1868 | Return UNZ_CRCERROR if all the file was read but the CRC is not good |
| 1869 | */ |
| 1870 | extern int ZEXPORT unzCloseCurrentFile(unzFile file) { |
| 1871 | int err=UNZ_OK; |
| 1872 | |
| 1873 | unz64_s* s; |
| 1874 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 1875 | if (file==NULL) |
| @@ -2027,11 +1887,11 @@ | |
| 1887 | if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) |
| 1888 | err=UNZ_CRCERROR; |
| 1889 | } |
| 1890 | |
| 1891 | |
| 1892 | free(pfile_in_zip_read_info->read_buffer); |
| 1893 | pfile_in_zip_read_info->read_buffer = NULL; |
| 1894 | if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED) |
| 1895 | inflateEnd(&pfile_in_zip_read_info->stream); |
| 1896 | #ifdef HAVE_BZIP2 |
| 1897 | else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED) |
| @@ -2038,11 +1898,11 @@ | |
| 1898 | BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream); |
| 1899 | #endif |
| 1900 | |
| 1901 | |
| 1902 | pfile_in_zip_read_info->stream_initialised = 0; |
| 1903 | free(pfile_in_zip_read_info); |
| 1904 | |
| 1905 | s->pfile_in_zip_read=NULL; |
| 1906 | |
| 1907 | return err; |
| 1908 | } |
| @@ -2051,12 +1911,11 @@ | |
| 1911 | /* |
| 1912 | Get the global comment string of the ZipFile, in the szComment buffer. |
| 1913 | uSizeBuf is the size of the szComment buffer. |
| 1914 | return the number of byte copied or an error code <0 |
| 1915 | */ |
| 1916 | extern int ZEXPORT unzGetGlobalComment(unzFile file, char * szComment, uLong uSizeBuf) { |
| 1917 | unz64_s* s; |
| 1918 | uLong uReadThis ; |
| 1919 | if (file==NULL) |
| 1920 | return (int)UNZ_PARAMERROR; |
| 1921 | s=(unz64_s*)file; |
| @@ -2079,12 +1938,11 @@ | |
| 1938 | *(szComment+s->gi.size_comment)='\0'; |
| 1939 | return (int)uReadThis; |
| 1940 | } |
| 1941 | |
| 1942 | /* Additions by RX '2004 */ |
| 1943 | extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) { |
| 1944 | unz64_s* s; |
| 1945 | |
| 1946 | if (file==NULL) |
| 1947 | return 0; //UNZ_PARAMERROR; |
| 1948 | s=(unz64_s*)file; |
| @@ -2094,22 +1952,20 @@ | |
| 1952 | if (s->num_file==s->gi.number_entry) |
| 1953 | return 0; |
| 1954 | return s->pos_in_central_dir; |
| 1955 | } |
| 1956 | |
| 1957 | extern uLong ZEXPORT unzGetOffset(unzFile file) { |
| 1958 | ZPOS64_T offset64; |
| 1959 | |
| 1960 | if (file==NULL) |
| 1961 | return 0; //UNZ_PARAMERROR; |
| 1962 | offset64 = unzGetOffset64(file); |
| 1963 | return (uLong)offset64; |
| 1964 | } |
| 1965 | |
| 1966 | extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) { |
| 1967 | unz64_s* s; |
| 1968 | int err; |
| 1969 | |
| 1970 | if (file==NULL) |
| 1971 | return UNZ_PARAMERROR; |
| @@ -2122,9 +1978,8 @@ | |
| 1978 | NULL,0,NULL,0,NULL,0); |
| 1979 | s->current_file_ok = (err == UNZ_OK); |
| 1980 | return err; |
| 1981 | } |
| 1982 | |
| 1983 | extern int ZEXPORT unzSetOffset (unzFile file, uLong pos) { |
| 1984 | return unzSetOffset64(file,pos); |
| 1985 | } |
| 1986 |
+68
-68
| --- compat/zlib/contrib/minizip/unzip.h | ||
| +++ compat/zlib/contrib/minizip/unzip.h | ||
| @@ -148,25 +148,25 @@ | ||
| 148 | 148 | uLong external_fa; /* external file attributes 4 bytes */ |
| 149 | 149 | |
| 150 | 150 | tm_unz tmu_date; |
| 151 | 151 | } unz_file_info; |
| 152 | 152 | |
| 153 | -extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, | |
| 154 | - const char* fileName2, | |
| 155 | - int iCaseSensitivity)); | |
| 153 | +extern int ZEXPORT unzStringFileNameCompare(const char* fileName1, | |
| 154 | + const char* fileName2, | |
| 155 | + int iCaseSensitivity); | |
| 156 | 156 | /* |
| 157 | - Compare two filename (fileName1,fileName2). | |
| 158 | - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) | |
| 159 | - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi | |
| 157 | + Compare two filenames (fileName1,fileName2). | |
| 158 | + If iCaseSensitivity = 1, comparison is case sensitive (like strcmp) | |
| 159 | + If iCaseSensitivity = 2, comparison is not case sensitive (like strcmpi | |
| 160 | 160 | or strcasecmp) |
| 161 | - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system | |
| 161 | + If iCaseSensitivity = 0, case sensitivity is default of your operating system | |
| 162 | 162 | (like 1 on Unix, 2 on Windows) |
| 163 | 163 | */ |
| 164 | 164 | |
| 165 | 165 | |
| 166 | -extern unzFile ZEXPORT unzOpen OF((const char *path)); | |
| 167 | -extern unzFile ZEXPORT unzOpen64 OF((const void *path)); | |
| 166 | +extern unzFile ZEXPORT unzOpen(const char *path); | |
| 167 | +extern unzFile ZEXPORT unzOpen64(const void *path); | |
| 168 | 168 | /* |
| 169 | 169 | Open a Zip file. path contain the full pathname (by example, |
| 170 | 170 | on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer |
| 171 | 171 | "zlib/zlib113.zip". |
| 172 | 172 | If the zipfile cannot be opened (file don't exist or in not valid), the |
| @@ -179,45 +179,45 @@ | ||
| 179 | 179 | is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char* |
| 180 | 180 | does not describe the reality |
| 181 | 181 | */ |
| 182 | 182 | |
| 183 | 183 | |
| 184 | -extern unzFile ZEXPORT unzOpen2 OF((const char *path, | |
| 185 | - zlib_filefunc_def* pzlib_filefunc_def)); | |
| 184 | +extern unzFile ZEXPORT unzOpen2(const char *path, | |
| 185 | + zlib_filefunc_def* pzlib_filefunc_def); | |
| 186 | 186 | /* |
| 187 | 187 | Open a Zip file, like unzOpen, but provide a set of file low level API |
| 188 | 188 | for read/write the zip file (see ioapi.h) |
| 189 | 189 | */ |
| 190 | 190 | |
| 191 | -extern unzFile ZEXPORT unzOpen2_64 OF((const void *path, | |
| 192 | - zlib_filefunc64_def* pzlib_filefunc_def)); | |
| 191 | +extern unzFile ZEXPORT unzOpen2_64(const void *path, | |
| 192 | + zlib_filefunc64_def* pzlib_filefunc_def); | |
| 193 | 193 | /* |
| 194 | 194 | Open a Zip file, like unz64Open, but provide a set of file low level API |
| 195 | 195 | for read/write the zip file (see ioapi.h) |
| 196 | 196 | */ |
| 197 | 197 | |
| 198 | -extern int ZEXPORT unzClose OF((unzFile file)); | |
| 198 | +extern int ZEXPORT unzClose(unzFile file); | |
| 199 | 199 | /* |
| 200 | 200 | Close a ZipFile opened with unzOpen. |
| 201 | 201 | If there is files inside the .Zip opened with unzOpenCurrentFile (see later), |
| 202 | 202 | these files MUST be closed with unzCloseCurrentFile before call unzClose. |
| 203 | 203 | return UNZ_OK if there is no problem. */ |
| 204 | 204 | |
| 205 | -extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, | |
| 206 | - unz_global_info *pglobal_info)); | |
| 205 | +extern int ZEXPORT unzGetGlobalInfo(unzFile file, | |
| 206 | + unz_global_info *pglobal_info); | |
| 207 | 207 | |
| 208 | -extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, | |
| 209 | - unz_global_info64 *pglobal_info)); | |
| 208 | +extern int ZEXPORT unzGetGlobalInfo64(unzFile file, | |
| 209 | + unz_global_info64 *pglobal_info); | |
| 210 | 210 | /* |
| 211 | 211 | Write info about the ZipFile in the *pglobal_info structure. |
| 212 | 212 | No preparation of the structure is needed |
| 213 | 213 | return UNZ_OK if there is no problem. */ |
| 214 | 214 | |
| 215 | 215 | |
| 216 | -extern int ZEXPORT unzGetGlobalComment OF((unzFile file, | |
| 217 | - char *szComment, | |
| 218 | - uLong uSizeBuf)); | |
| 216 | +extern int ZEXPORT unzGetGlobalComment(unzFile file, | |
| 217 | + char *szComment, | |
| 218 | + uLong uSizeBuf); | |
| 219 | 219 | /* |
| 220 | 220 | Get the global comment string of the ZipFile, in the szComment buffer. |
| 221 | 221 | uSizeBuf is the size of the szComment buffer. |
| 222 | 222 | return the number of byte copied or an error code <0 |
| 223 | 223 | */ |
| @@ -224,26 +224,26 @@ | ||
| 224 | 224 | |
| 225 | 225 | |
| 226 | 226 | /***************************************************************************/ |
| 227 | 227 | /* Unzip package allow you browse the directory of the zipfile */ |
| 228 | 228 | |
| 229 | -extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); | |
| 229 | +extern int ZEXPORT unzGoToFirstFile(unzFile file); | |
| 230 | 230 | /* |
| 231 | 231 | Set the current file of the zipfile to the first file. |
| 232 | 232 | return UNZ_OK if there is no problem |
| 233 | 233 | */ |
| 234 | 234 | |
| 235 | -extern int ZEXPORT unzGoToNextFile OF((unzFile file)); | |
| 235 | +extern int ZEXPORT unzGoToNextFile(unzFile file); | |
| 236 | 236 | /* |
| 237 | 237 | Set the current file of the zipfile to the next file. |
| 238 | 238 | return UNZ_OK if there is no problem |
| 239 | 239 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. |
| 240 | 240 | */ |
| 241 | 241 | |
| 242 | -extern int ZEXPORT unzLocateFile OF((unzFile file, | |
| 243 | - const char *szFileName, | |
| 244 | - int iCaseSensitivity)); | |
| 242 | +extern int ZEXPORT unzLocateFile(unzFile file, | |
| 243 | + const char *szFileName, | |
| 244 | + int iCaseSensitivity); | |
| 245 | 245 | /* |
| 246 | 246 | Try locate the file szFileName in the zipfile. |
| 247 | 247 | For the iCaseSensitivity signification, see unzStringFileNameCompare |
| 248 | 248 | |
| 249 | 249 | return value : |
| @@ -283,30 +283,30 @@ | ||
| 283 | 283 | unzFile file, |
| 284 | 284 | const unz64_file_pos* file_pos); |
| 285 | 285 | |
| 286 | 286 | /* ****************************************** */ |
| 287 | 287 | |
| 288 | -extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file, | |
| 289 | - unz_file_info64 *pfile_info, | |
| 290 | - char *szFileName, | |
| 291 | - uLong fileNameBufferSize, | |
| 292 | - void *extraField, | |
| 293 | - uLong extraFieldBufferSize, | |
| 294 | - char *szComment, | |
| 295 | - uLong commentBufferSize)); | |
| 296 | - | |
| 297 | -extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, | |
| 298 | - unz_file_info *pfile_info, | |
| 299 | - char *szFileName, | |
| 300 | - uLong fileNameBufferSize, | |
| 301 | - void *extraField, | |
| 302 | - uLong extraFieldBufferSize, | |
| 303 | - char *szComment, | |
| 304 | - uLong commentBufferSize)); | |
| 288 | +extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file, | |
| 289 | + unz_file_info64 *pfile_info, | |
| 290 | + char *szFileName, | |
| 291 | + uLong fileNameBufferSize, | |
| 292 | + void *extraField, | |
| 293 | + uLong extraFieldBufferSize, | |
| 294 | + char *szComment, | |
| 295 | + uLong commentBufferSize); | |
| 296 | + | |
| 297 | +extern int ZEXPORT unzGetCurrentFileInfo(unzFile file, | |
| 298 | + unz_file_info *pfile_info, | |
| 299 | + char *szFileName, | |
| 300 | + uLong fileNameBufferSize, | |
| 301 | + void *extraField, | |
| 302 | + uLong extraFieldBufferSize, | |
| 303 | + char *szComment, | |
| 304 | + uLong commentBufferSize); | |
| 305 | 305 | /* |
| 306 | 306 | Get Info about the current file |
| 307 | - if pfile_info!=NULL, the *pfile_info structure will contain somes info about | |
| 307 | + if pfile_info!=NULL, the *pfile_info structure will contain some info about | |
| 308 | 308 | the current file |
| 309 | 309 | if szFileName!=NULL, the filemane string will be copied in szFileName |
| 310 | 310 | (fileNameBufferSize is the size of the buffer) |
| 311 | 311 | if extraField!=NULL, the extra field information will be copied in extraField |
| 312 | 312 | (extraFieldBufferSize is the size of the buffer). |
| @@ -316,52 +316,52 @@ | ||
| 316 | 316 | */ |
| 317 | 317 | |
| 318 | 318 | |
| 319 | 319 | /** Addition for GDAL : START */ |
| 320 | 320 | |
| 321 | -extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file)); | |
| 321 | +extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file); | |
| 322 | 322 | |
| 323 | 323 | /** Addition for GDAL : END */ |
| 324 | 324 | |
| 325 | 325 | |
| 326 | 326 | /***************************************************************************/ |
| 327 | 327 | /* for reading the content of the current zipfile, you can open it, read data |
| 328 | 328 | from it, and close it (you can close it before reading all the file) |
| 329 | 329 | */ |
| 330 | 330 | |
| 331 | -extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); | |
| 331 | +extern int ZEXPORT unzOpenCurrentFile(unzFile file); | |
| 332 | 332 | /* |
| 333 | 333 | Open for reading data the current file in the zipfile. |
| 334 | 334 | If there is no error, the return value is UNZ_OK. |
| 335 | 335 | */ |
| 336 | 336 | |
| 337 | -extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, | |
| 338 | - const char* password)); | |
| 337 | +extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file, | |
| 338 | + const char* password); | |
| 339 | 339 | /* |
| 340 | 340 | Open for reading data the current file in the zipfile. |
| 341 | 341 | password is a crypting password |
| 342 | 342 | If there is no error, the return value is UNZ_OK. |
| 343 | 343 | */ |
| 344 | 344 | |
| 345 | -extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, | |
| 346 | - int* method, | |
| 347 | - int* level, | |
| 348 | - int raw)); | |
| 345 | +extern int ZEXPORT unzOpenCurrentFile2(unzFile file, | |
| 346 | + int* method, | |
| 347 | + int* level, | |
| 348 | + int raw); | |
| 349 | 349 | /* |
| 350 | 350 | Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) |
| 351 | 351 | if raw==1 |
| 352 | 352 | *method will receive method of compression, *level will receive level of |
| 353 | 353 | compression |
| 354 | 354 | note : you can set level parameter as NULL (if you did not want known level, |
| 355 | 355 | but you CANNOT set method parameter as NULL |
| 356 | 356 | */ |
| 357 | 357 | |
| 358 | -extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, | |
| 359 | - int* method, | |
| 360 | - int* level, | |
| 361 | - int raw, | |
| 362 | - const char* password)); | |
| 358 | +extern int ZEXPORT unzOpenCurrentFile3(unzFile file, | |
| 359 | + int* method, | |
| 360 | + int* level, | |
| 361 | + int raw, | |
| 362 | + const char* password); | |
| 363 | 363 | /* |
| 364 | 364 | Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) |
| 365 | 365 | if raw==1 |
| 366 | 366 | *method will receive method of compression, *level will receive level of |
| 367 | 367 | compression |
| @@ -368,45 +368,45 @@ | ||
| 368 | 368 | note : you can set level parameter as NULL (if you did not want known level, |
| 369 | 369 | but you CANNOT set method parameter as NULL |
| 370 | 370 | */ |
| 371 | 371 | |
| 372 | 372 | |
| 373 | -extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); | |
| 373 | +extern int ZEXPORT unzCloseCurrentFile(unzFile file); | |
| 374 | 374 | /* |
| 375 | 375 | Close the file in zip opened with unzOpenCurrentFile |
| 376 | 376 | Return UNZ_CRCERROR if all the file was read but the CRC is not good |
| 377 | 377 | */ |
| 378 | 378 | |
| 379 | -extern int ZEXPORT unzReadCurrentFile OF((unzFile file, | |
| 380 | - voidp buf, | |
| 381 | - unsigned len)); | |
| 379 | +extern int ZEXPORT unzReadCurrentFile(unzFile file, | |
| 380 | + voidp buf, | |
| 381 | + unsigned len); | |
| 382 | 382 | /* |
| 383 | 383 | Read bytes from the current file (opened by unzOpenCurrentFile) |
| 384 | 384 | buf contain buffer where data must be copied |
| 385 | 385 | len the size of buf. |
| 386 | 386 | |
| 387 | - return the number of byte copied if somes bytes are copied | |
| 387 | + return the number of byte copied if some bytes are copied | |
| 388 | 388 | return 0 if the end of file was reached |
| 389 | 389 | return <0 with error code if there is an error |
| 390 | 390 | (UNZ_ERRNO for IO error, or zLib error for uncompress error) |
| 391 | 391 | */ |
| 392 | 392 | |
| 393 | -extern z_off_t ZEXPORT unztell OF((unzFile file)); | |
| 393 | +extern z_off_t ZEXPORT unztell(unzFile file); | |
| 394 | 394 | |
| 395 | -extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file)); | |
| 395 | +extern ZPOS64_T ZEXPORT unztell64(unzFile file); | |
| 396 | 396 | /* |
| 397 | 397 | Give the current position in uncompressed data |
| 398 | 398 | */ |
| 399 | 399 | |
| 400 | -extern int ZEXPORT unzeof OF((unzFile file)); | |
| 400 | +extern int ZEXPORT unzeof(unzFile file); | |
| 401 | 401 | /* |
| 402 | 402 | return 1 if the end of file was reached, 0 elsewhere |
| 403 | 403 | */ |
| 404 | 404 | |
| 405 | -extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, | |
| 406 | - voidp buf, | |
| 407 | - unsigned len)); | |
| 405 | +extern int ZEXPORT unzGetLocalExtrafield(unzFile file, | |
| 406 | + voidp buf, | |
| 407 | + unsigned len); | |
| 408 | 408 | /* |
| 409 | 409 | Read extra field from the current file (opened by unzOpenCurrentFile) |
| 410 | 410 | This is the local-header version of the extra field (sometimes, there is |
| 411 | 411 | more info in the local-header version than in the central-header) |
| 412 | 412 | |
| 413 | 413 |
| --- compat/zlib/contrib/minizip/unzip.h | |
| +++ compat/zlib/contrib/minizip/unzip.h | |
| @@ -148,25 +148,25 @@ | |
| 148 | uLong external_fa; /* external file attributes 4 bytes */ |
| 149 | |
| 150 | tm_unz tmu_date; |
| 151 | } unz_file_info; |
| 152 | |
| 153 | extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, |
| 154 | const char* fileName2, |
| 155 | int iCaseSensitivity)); |
| 156 | /* |
| 157 | Compare two filename (fileName1,fileName2). |
| 158 | If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) |
| 159 | If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi |
| 160 | or strcasecmp) |
| 161 | If iCaseSenisivity = 0, case sensitivity is defaut of your operating system |
| 162 | (like 1 on Unix, 2 on Windows) |
| 163 | */ |
| 164 | |
| 165 | |
| 166 | extern unzFile ZEXPORT unzOpen OF((const char *path)); |
| 167 | extern unzFile ZEXPORT unzOpen64 OF((const void *path)); |
| 168 | /* |
| 169 | Open a Zip file. path contain the full pathname (by example, |
| 170 | on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer |
| 171 | "zlib/zlib113.zip". |
| 172 | If the zipfile cannot be opened (file don't exist or in not valid), the |
| @@ -179,45 +179,45 @@ | |
| 179 | is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char* |
| 180 | does not describe the reality |
| 181 | */ |
| 182 | |
| 183 | |
| 184 | extern unzFile ZEXPORT unzOpen2 OF((const char *path, |
| 185 | zlib_filefunc_def* pzlib_filefunc_def)); |
| 186 | /* |
| 187 | Open a Zip file, like unzOpen, but provide a set of file low level API |
| 188 | for read/write the zip file (see ioapi.h) |
| 189 | */ |
| 190 | |
| 191 | extern unzFile ZEXPORT unzOpen2_64 OF((const void *path, |
| 192 | zlib_filefunc64_def* pzlib_filefunc_def)); |
| 193 | /* |
| 194 | Open a Zip file, like unz64Open, but provide a set of file low level API |
| 195 | for read/write the zip file (see ioapi.h) |
| 196 | */ |
| 197 | |
| 198 | extern int ZEXPORT unzClose OF((unzFile file)); |
| 199 | /* |
| 200 | Close a ZipFile opened with unzOpen. |
| 201 | If there is files inside the .Zip opened with unzOpenCurrentFile (see later), |
| 202 | these files MUST be closed with unzCloseCurrentFile before call unzClose. |
| 203 | return UNZ_OK if there is no problem. */ |
| 204 | |
| 205 | extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, |
| 206 | unz_global_info *pglobal_info)); |
| 207 | |
| 208 | extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, |
| 209 | unz_global_info64 *pglobal_info)); |
| 210 | /* |
| 211 | Write info about the ZipFile in the *pglobal_info structure. |
| 212 | No preparation of the structure is needed |
| 213 | return UNZ_OK if there is no problem. */ |
| 214 | |
| 215 | |
| 216 | extern int ZEXPORT unzGetGlobalComment OF((unzFile file, |
| 217 | char *szComment, |
| 218 | uLong uSizeBuf)); |
| 219 | /* |
| 220 | Get the global comment string of the ZipFile, in the szComment buffer. |
| 221 | uSizeBuf is the size of the szComment buffer. |
| 222 | return the number of byte copied or an error code <0 |
| 223 | */ |
| @@ -224,26 +224,26 @@ | |
| 224 | |
| 225 | |
| 226 | /***************************************************************************/ |
| 227 | /* Unzip package allow you browse the directory of the zipfile */ |
| 228 | |
| 229 | extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); |
| 230 | /* |
| 231 | Set the current file of the zipfile to the first file. |
| 232 | return UNZ_OK if there is no problem |
| 233 | */ |
| 234 | |
| 235 | extern int ZEXPORT unzGoToNextFile OF((unzFile file)); |
| 236 | /* |
| 237 | Set the current file of the zipfile to the next file. |
| 238 | return UNZ_OK if there is no problem |
| 239 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. |
| 240 | */ |
| 241 | |
| 242 | extern int ZEXPORT unzLocateFile OF((unzFile file, |
| 243 | const char *szFileName, |
| 244 | int iCaseSensitivity)); |
| 245 | /* |
| 246 | Try locate the file szFileName in the zipfile. |
| 247 | For the iCaseSensitivity signification, see unzStringFileNameCompare |
| 248 | |
| 249 | return value : |
| @@ -283,30 +283,30 @@ | |
| 283 | unzFile file, |
| 284 | const unz64_file_pos* file_pos); |
| 285 | |
| 286 | /* ****************************************** */ |
| 287 | |
| 288 | extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file, |
| 289 | unz_file_info64 *pfile_info, |
| 290 | char *szFileName, |
| 291 | uLong fileNameBufferSize, |
| 292 | void *extraField, |
| 293 | uLong extraFieldBufferSize, |
| 294 | char *szComment, |
| 295 | uLong commentBufferSize)); |
| 296 | |
| 297 | extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, |
| 298 | unz_file_info *pfile_info, |
| 299 | char *szFileName, |
| 300 | uLong fileNameBufferSize, |
| 301 | void *extraField, |
| 302 | uLong extraFieldBufferSize, |
| 303 | char *szComment, |
| 304 | uLong commentBufferSize)); |
| 305 | /* |
| 306 | Get Info about the current file |
| 307 | if pfile_info!=NULL, the *pfile_info structure will contain somes info about |
| 308 | the current file |
| 309 | if szFileName!=NULL, the filemane string will be copied in szFileName |
| 310 | (fileNameBufferSize is the size of the buffer) |
| 311 | if extraField!=NULL, the extra field information will be copied in extraField |
| 312 | (extraFieldBufferSize is the size of the buffer). |
| @@ -316,52 +316,52 @@ | |
| 316 | */ |
| 317 | |
| 318 | |
| 319 | /** Addition for GDAL : START */ |
| 320 | |
| 321 | extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file)); |
| 322 | |
| 323 | /** Addition for GDAL : END */ |
| 324 | |
| 325 | |
| 326 | /***************************************************************************/ |
| 327 | /* for reading the content of the current zipfile, you can open it, read data |
| 328 | from it, and close it (you can close it before reading all the file) |
| 329 | */ |
| 330 | |
| 331 | extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); |
| 332 | /* |
| 333 | Open for reading data the current file in the zipfile. |
| 334 | If there is no error, the return value is UNZ_OK. |
| 335 | */ |
| 336 | |
| 337 | extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, |
| 338 | const char* password)); |
| 339 | /* |
| 340 | Open for reading data the current file in the zipfile. |
| 341 | password is a crypting password |
| 342 | If there is no error, the return value is UNZ_OK. |
| 343 | */ |
| 344 | |
| 345 | extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, |
| 346 | int* method, |
| 347 | int* level, |
| 348 | int raw)); |
| 349 | /* |
| 350 | Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) |
| 351 | if raw==1 |
| 352 | *method will receive method of compression, *level will receive level of |
| 353 | compression |
| 354 | note : you can set level parameter as NULL (if you did not want known level, |
| 355 | but you CANNOT set method parameter as NULL |
| 356 | */ |
| 357 | |
| 358 | extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, |
| 359 | int* method, |
| 360 | int* level, |
| 361 | int raw, |
| 362 | const char* password)); |
| 363 | /* |
| 364 | Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) |
| 365 | if raw==1 |
| 366 | *method will receive method of compression, *level will receive level of |
| 367 | compression |
| @@ -368,45 +368,45 @@ | |
| 368 | note : you can set level parameter as NULL (if you did not want known level, |
| 369 | but you CANNOT set method parameter as NULL |
| 370 | */ |
| 371 | |
| 372 | |
| 373 | extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); |
| 374 | /* |
| 375 | Close the file in zip opened with unzOpenCurrentFile |
| 376 | Return UNZ_CRCERROR if all the file was read but the CRC is not good |
| 377 | */ |
| 378 | |
| 379 | extern int ZEXPORT unzReadCurrentFile OF((unzFile file, |
| 380 | voidp buf, |
| 381 | unsigned len)); |
| 382 | /* |
| 383 | Read bytes from the current file (opened by unzOpenCurrentFile) |
| 384 | buf contain buffer where data must be copied |
| 385 | len the size of buf. |
| 386 | |
| 387 | return the number of byte copied if somes bytes are copied |
| 388 | return 0 if the end of file was reached |
| 389 | return <0 with error code if there is an error |
| 390 | (UNZ_ERRNO for IO error, or zLib error for uncompress error) |
| 391 | */ |
| 392 | |
| 393 | extern z_off_t ZEXPORT unztell OF((unzFile file)); |
| 394 | |
| 395 | extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file)); |
| 396 | /* |
| 397 | Give the current position in uncompressed data |
| 398 | */ |
| 399 | |
| 400 | extern int ZEXPORT unzeof OF((unzFile file)); |
| 401 | /* |
| 402 | return 1 if the end of file was reached, 0 elsewhere |
| 403 | */ |
| 404 | |
| 405 | extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, |
| 406 | voidp buf, |
| 407 | unsigned len)); |
| 408 | /* |
| 409 | Read extra field from the current file (opened by unzOpenCurrentFile) |
| 410 | This is the local-header version of the extra field (sometimes, there is |
| 411 | more info in the local-header version than in the central-header) |
| 412 | |
| 413 |
| --- compat/zlib/contrib/minizip/unzip.h | |
| +++ compat/zlib/contrib/minizip/unzip.h | |
| @@ -148,25 +148,25 @@ | |
| 148 | uLong external_fa; /* external file attributes 4 bytes */ |
| 149 | |
| 150 | tm_unz tmu_date; |
| 151 | } unz_file_info; |
| 152 | |
| 153 | extern int ZEXPORT unzStringFileNameCompare(const char* fileName1, |
| 154 | const char* fileName2, |
| 155 | int iCaseSensitivity); |
| 156 | /* |
| 157 | Compare two filenames (fileName1,fileName2). |
| 158 | If iCaseSensitivity = 1, comparison is case sensitive (like strcmp) |
| 159 | If iCaseSensitivity = 2, comparison is not case sensitive (like strcmpi |
| 160 | or strcasecmp) |
| 161 | If iCaseSensitivity = 0, case sensitivity is default of your operating system |
| 162 | (like 1 on Unix, 2 on Windows) |
| 163 | */ |
| 164 | |
| 165 | |
| 166 | extern unzFile ZEXPORT unzOpen(const char *path); |
| 167 | extern unzFile ZEXPORT unzOpen64(const void *path); |
| 168 | /* |
| 169 | Open a Zip file. path contain the full pathname (by example, |
| 170 | on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer |
| 171 | "zlib/zlib113.zip". |
| 172 | If the zipfile cannot be opened (file don't exist or in not valid), the |
| @@ -179,45 +179,45 @@ | |
| 179 | is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char* |
| 180 | does not describe the reality |
| 181 | */ |
| 182 | |
| 183 | |
| 184 | extern unzFile ZEXPORT unzOpen2(const char *path, |
| 185 | zlib_filefunc_def* pzlib_filefunc_def); |
| 186 | /* |
| 187 | Open a Zip file, like unzOpen, but provide a set of file low level API |
| 188 | for read/write the zip file (see ioapi.h) |
| 189 | */ |
| 190 | |
| 191 | extern unzFile ZEXPORT unzOpen2_64(const void *path, |
| 192 | zlib_filefunc64_def* pzlib_filefunc_def); |
| 193 | /* |
| 194 | Open a Zip file, like unz64Open, but provide a set of file low level API |
| 195 | for read/write the zip file (see ioapi.h) |
| 196 | */ |
| 197 | |
| 198 | extern int ZEXPORT unzClose(unzFile file); |
| 199 | /* |
| 200 | Close a ZipFile opened with unzOpen. |
| 201 | If there is files inside the .Zip opened with unzOpenCurrentFile (see later), |
| 202 | these files MUST be closed with unzCloseCurrentFile before call unzClose. |
| 203 | return UNZ_OK if there is no problem. */ |
| 204 | |
| 205 | extern int ZEXPORT unzGetGlobalInfo(unzFile file, |
| 206 | unz_global_info *pglobal_info); |
| 207 | |
| 208 | extern int ZEXPORT unzGetGlobalInfo64(unzFile file, |
| 209 | unz_global_info64 *pglobal_info); |
| 210 | /* |
| 211 | Write info about the ZipFile in the *pglobal_info structure. |
| 212 | No preparation of the structure is needed |
| 213 | return UNZ_OK if there is no problem. */ |
| 214 | |
| 215 | |
| 216 | extern int ZEXPORT unzGetGlobalComment(unzFile file, |
| 217 | char *szComment, |
| 218 | uLong uSizeBuf); |
| 219 | /* |
| 220 | Get the global comment string of the ZipFile, in the szComment buffer. |
| 221 | uSizeBuf is the size of the szComment buffer. |
| 222 | return the number of byte copied or an error code <0 |
| 223 | */ |
| @@ -224,26 +224,26 @@ | |
| 224 | |
| 225 | |
| 226 | /***************************************************************************/ |
| 227 | /* Unzip package allow you browse the directory of the zipfile */ |
| 228 | |
| 229 | extern int ZEXPORT unzGoToFirstFile(unzFile file); |
| 230 | /* |
| 231 | Set the current file of the zipfile to the first file. |
| 232 | return UNZ_OK if there is no problem |
| 233 | */ |
| 234 | |
| 235 | extern int ZEXPORT unzGoToNextFile(unzFile file); |
| 236 | /* |
| 237 | Set the current file of the zipfile to the next file. |
| 238 | return UNZ_OK if there is no problem |
| 239 | return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. |
| 240 | */ |
| 241 | |
| 242 | extern int ZEXPORT unzLocateFile(unzFile file, |
| 243 | const char *szFileName, |
| 244 | int iCaseSensitivity); |
| 245 | /* |
| 246 | Try locate the file szFileName in the zipfile. |
| 247 | For the iCaseSensitivity signification, see unzStringFileNameCompare |
| 248 | |
| 249 | return value : |
| @@ -283,30 +283,30 @@ | |
| 283 | unzFile file, |
| 284 | const unz64_file_pos* file_pos); |
| 285 | |
| 286 | /* ****************************************** */ |
| 287 | |
| 288 | extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file, |
| 289 | unz_file_info64 *pfile_info, |
| 290 | char *szFileName, |
| 291 | uLong fileNameBufferSize, |
| 292 | void *extraField, |
| 293 | uLong extraFieldBufferSize, |
| 294 | char *szComment, |
| 295 | uLong commentBufferSize); |
| 296 | |
| 297 | extern int ZEXPORT unzGetCurrentFileInfo(unzFile file, |
| 298 | unz_file_info *pfile_info, |
| 299 | char *szFileName, |
| 300 | uLong fileNameBufferSize, |
| 301 | void *extraField, |
| 302 | uLong extraFieldBufferSize, |
| 303 | char *szComment, |
| 304 | uLong commentBufferSize); |
| 305 | /* |
| 306 | Get Info about the current file |
| 307 | if pfile_info!=NULL, the *pfile_info structure will contain some info about |
| 308 | the current file |
| 309 | if szFileName!=NULL, the filemane string will be copied in szFileName |
| 310 | (fileNameBufferSize is the size of the buffer) |
| 311 | if extraField!=NULL, the extra field information will be copied in extraField |
| 312 | (extraFieldBufferSize is the size of the buffer). |
| @@ -316,52 +316,52 @@ | |
| 316 | */ |
| 317 | |
| 318 | |
| 319 | /** Addition for GDAL : START */ |
| 320 | |
| 321 | extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file); |
| 322 | |
| 323 | /** Addition for GDAL : END */ |
| 324 | |
| 325 | |
| 326 | /***************************************************************************/ |
| 327 | /* for reading the content of the current zipfile, you can open it, read data |
| 328 | from it, and close it (you can close it before reading all the file) |
| 329 | */ |
| 330 | |
| 331 | extern int ZEXPORT unzOpenCurrentFile(unzFile file); |
| 332 | /* |
| 333 | Open for reading data the current file in the zipfile. |
| 334 | If there is no error, the return value is UNZ_OK. |
| 335 | */ |
| 336 | |
| 337 | extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file, |
| 338 | const char* password); |
| 339 | /* |
| 340 | Open for reading data the current file in the zipfile. |
| 341 | password is a crypting password |
| 342 | If there is no error, the return value is UNZ_OK. |
| 343 | */ |
| 344 | |
| 345 | extern int ZEXPORT unzOpenCurrentFile2(unzFile file, |
| 346 | int* method, |
| 347 | int* level, |
| 348 | int raw); |
| 349 | /* |
| 350 | Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) |
| 351 | if raw==1 |
| 352 | *method will receive method of compression, *level will receive level of |
| 353 | compression |
| 354 | note : you can set level parameter as NULL (if you did not want known level, |
| 355 | but you CANNOT set method parameter as NULL |
| 356 | */ |
| 357 | |
| 358 | extern int ZEXPORT unzOpenCurrentFile3(unzFile file, |
| 359 | int* method, |
| 360 | int* level, |
| 361 | int raw, |
| 362 | const char* password); |
| 363 | /* |
| 364 | Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) |
| 365 | if raw==1 |
| 366 | *method will receive method of compression, *level will receive level of |
| 367 | compression |
| @@ -368,45 +368,45 @@ | |
| 368 | note : you can set level parameter as NULL (if you did not want known level, |
| 369 | but you CANNOT set method parameter as NULL |
| 370 | */ |
| 371 | |
| 372 | |
| 373 | extern int ZEXPORT unzCloseCurrentFile(unzFile file); |
| 374 | /* |
| 375 | Close the file in zip opened with unzOpenCurrentFile |
| 376 | Return UNZ_CRCERROR if all the file was read but the CRC is not good |
| 377 | */ |
| 378 | |
| 379 | extern int ZEXPORT unzReadCurrentFile(unzFile file, |
| 380 | voidp buf, |
| 381 | unsigned len); |
| 382 | /* |
| 383 | Read bytes from the current file (opened by unzOpenCurrentFile) |
| 384 | buf contain buffer where data must be copied |
| 385 | len the size of buf. |
| 386 | |
| 387 | return the number of byte copied if some bytes are copied |
| 388 | return 0 if the end of file was reached |
| 389 | return <0 with error code if there is an error |
| 390 | (UNZ_ERRNO for IO error, or zLib error for uncompress error) |
| 391 | */ |
| 392 | |
| 393 | extern z_off_t ZEXPORT unztell(unzFile file); |
| 394 | |
| 395 | extern ZPOS64_T ZEXPORT unztell64(unzFile file); |
| 396 | /* |
| 397 | Give the current position in uncompressed data |
| 398 | */ |
| 399 | |
| 400 | extern int ZEXPORT unzeof(unzFile file); |
| 401 | /* |
| 402 | return 1 if the end of file was reached, 0 elsewhere |
| 403 | */ |
| 404 | |
| 405 | extern int ZEXPORT unzGetLocalExtrafield(unzFile file, |
| 406 | voidp buf, |
| 407 | unsigned len); |
| 408 | /* |
| 409 | Read extra field from the current file (opened by unzOpenCurrentFile) |
| 410 | This is the local-header version of the extra field (sometimes, there is |
| 411 | more info in the local-header version than in the central-header) |
| 412 | |
| 413 |
+137
-194
| --- compat/zlib/contrib/minizip/zip.c | ||
| +++ compat/zlib/contrib/minizip/zip.c | ||
| @@ -12,11 +12,11 @@ | ||
| 12 | 12 | Changes |
| 13 | 13 | Oct-2009 - Mathias Svensson - Remove old C style function prototypes |
| 14 | 14 | Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives |
| 15 | 15 | Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions. |
| 16 | 16 | Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data |
| 17 | - It is used when recreting zip archive with RAW when deleting items from a zip. | |
| 17 | + It is used when recreating zip archive with RAW when deleting items from a zip. | |
| 18 | 18 | ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed. |
| 19 | 19 | Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required) |
| 20 | 20 | Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer |
| 21 | 21 | |
| 22 | 22 | */ |
| @@ -23,18 +23,17 @@ | ||
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | #include <stdio.h> |
| 26 | 26 | #include <stdlib.h> |
| 27 | 27 | #include <string.h> |
| 28 | +#include <stdint.h> | |
| 28 | 29 | #include <time.h> |
| 29 | 30 | #include "zlib.h" |
| 30 | 31 | #include "zip.h" |
| 31 | 32 | |
| 32 | 33 | #ifdef STDC |
| 33 | 34 | # include <stddef.h> |
| 34 | -# include <string.h> | |
| 35 | -# include <stdlib.h> | |
| 36 | 35 | #endif |
| 37 | 36 | #ifdef NO_ERRNO_H |
| 38 | 37 | extern int errno; |
| 39 | 38 | #else |
| 40 | 39 | # include <errno.h> |
| @@ -45,11 +44,11 @@ | ||
| 45 | 44 | # define local static |
| 46 | 45 | #endif |
| 47 | 46 | /* compile with -Dlocal if your debugger can't find static symbols */ |
| 48 | 47 | |
| 49 | 48 | #ifndef VERSIONMADEBY |
| 50 | -# define VERSIONMADEBY (0x0) /* platform depedent */ | |
| 49 | +# define VERSIONMADEBY (0x0) /* platform dependent */ | |
| 51 | 50 | #endif |
| 52 | 51 | |
| 53 | 52 | #ifndef Z_BUFSIZE |
| 54 | 53 | #define Z_BUFSIZE (64*1024) //(16384) |
| 55 | 54 | #endif |
| @@ -59,13 +58,10 @@ | ||
| 59 | 58 | #endif |
| 60 | 59 | |
| 61 | 60 | #ifndef ALLOC |
| 62 | 61 | # define ALLOC(size) (malloc(size)) |
| 63 | 62 | #endif |
| 64 | -#ifndef TRYFREE | |
| 65 | -# define TRYFREE(p) {if (p) free(p);} | |
| 66 | -#endif | |
| 67 | 63 | |
| 68 | 64 | /* |
| 69 | 65 | #define SIZECENTRALDIRITEM (0x2e) |
| 70 | 66 | #define SIZEZIPLOCALHEADER (0x1e) |
| 71 | 67 | */ |
| @@ -136,24 +132,24 @@ | ||
| 136 | 132 | |
| 137 | 133 | int stream_initialised; /* 1 is stream is initialised */ |
| 138 | 134 | uInt pos_in_buffered_data; /* last written byte in buffered_data */ |
| 139 | 135 | |
| 140 | 136 | ZPOS64_T pos_local_header; /* offset of the local header of the file |
| 141 | - currenty writing */ | |
| 137 | + currently writing */ | |
| 142 | 138 | char* central_header; /* central header data for the current file */ |
| 143 | 139 | uLong size_centralExtra; |
| 144 | 140 | uLong size_centralheader; /* size of the central header for cur file */ |
| 145 | 141 | uLong size_centralExtraFree; /* Extra bytes allocated to the centralheader but that are not used */ |
| 146 | 142 | uLong flag; /* flag of the file currently writing */ |
| 147 | 143 | |
| 148 | - int method; /* compression method of file currenty wr.*/ | |
| 144 | + int method; /* compression method of file currently wr.*/ | |
| 149 | 145 | int raw; /* 1 for directly writing raw data */ |
| 150 | 146 | Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ |
| 151 | 147 | uLong dosDate; |
| 152 | 148 | uLong crc32; |
| 153 | 149 | int encrypt; |
| 154 | - int zip64; /* Add ZIP64 extened information in the extra field */ | |
| 150 | + int zip64; /* Add ZIP64 extended information in the extra field */ | |
| 155 | 151 | ZPOS64_T pos_zip64extrainfo; |
| 156 | 152 | ZPOS64_T totalCompressedData; |
| 157 | 153 | ZPOS64_T totalUncompressedData; |
| 158 | 154 | #ifndef NOCRYPT |
| 159 | 155 | unsigned long keys[3]; /* keys defining the pseudo-random sequence */ |
| @@ -163,14 +159,14 @@ | ||
| 163 | 159 | } curfile64_info; |
| 164 | 160 | |
| 165 | 161 | typedef struct |
| 166 | 162 | { |
| 167 | 163 | zlib_filefunc64_32_def z_filefunc; |
| 168 | - voidpf filestream; /* io structore of the zipfile */ | |
| 164 | + voidpf filestream; /* io structure of the zipfile */ | |
| 169 | 165 | linkedlist_data central_dir;/* datablock with central dir in construction*/ |
| 170 | 166 | int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ |
| 171 | - curfile64_info ci; /* info on the file curretly writing */ | |
| 167 | + curfile64_info ci; /* info on the file currently writing */ | |
| 172 | 168 | |
| 173 | 169 | ZPOS64_T begin_pos; /* position of the beginning of the zipfile */ |
| 174 | 170 | ZPOS64_T add_position_when_writing_offset; |
| 175 | 171 | ZPOS64_T number_entry; |
| 176 | 172 | |
| @@ -184,12 +180,11 @@ | ||
| 184 | 180 | #ifndef NOCRYPT |
| 185 | 181 | #define INCLUDECRYPTINGCODE_IFCRYPTALLOWED |
| 186 | 182 | #include "crypt.h" |
| 187 | 183 | #endif |
| 188 | 184 | |
| 189 | -local linkedlist_datablock_internal* allocate_new_datablock() | |
| 190 | -{ | |
| 185 | +local linkedlist_datablock_internal* allocate_new_datablock(void) { | |
| 191 | 186 | linkedlist_datablock_internal* ldi; |
| 192 | 187 | ldi = (linkedlist_datablock_internal*) |
| 193 | 188 | ALLOC(sizeof(linkedlist_datablock_internal)); |
| 194 | 189 | if (ldi!=NULL) |
| 195 | 190 | { |
| @@ -198,34 +193,30 @@ | ||
| 198 | 193 | ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; |
| 199 | 194 | } |
| 200 | 195 | return ldi; |
| 201 | 196 | } |
| 202 | 197 | |
| 203 | -local void free_datablock(linkedlist_datablock_internal* ldi) | |
| 204 | -{ | |
| 198 | +local void free_datablock(linkedlist_datablock_internal* ldi) { | |
| 205 | 199 | while (ldi!=NULL) |
| 206 | 200 | { |
| 207 | 201 | linkedlist_datablock_internal* ldinext = ldi->next_datablock; |
| 208 | - TRYFREE(ldi); | |
| 202 | + free(ldi); | |
| 209 | 203 | ldi = ldinext; |
| 210 | 204 | } |
| 211 | 205 | } |
| 212 | 206 | |
| 213 | -local void init_linkedlist(linkedlist_data* ll) | |
| 214 | -{ | |
| 207 | +local void init_linkedlist(linkedlist_data* ll) { | |
| 215 | 208 | ll->first_block = ll->last_block = NULL; |
| 216 | 209 | } |
| 217 | 210 | |
| 218 | -local void free_linkedlist(linkedlist_data* ll) | |
| 219 | -{ | |
| 211 | +local void free_linkedlist(linkedlist_data* ll) { | |
| 220 | 212 | free_datablock(ll->first_block); |
| 221 | 213 | ll->first_block = ll->last_block = NULL; |
| 222 | 214 | } |
| 223 | 215 | |
| 224 | 216 | |
| 225 | -local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) | |
| 226 | -{ | |
| 217 | +local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) { | |
| 227 | 218 | linkedlist_datablock_internal* ldi; |
| 228 | 219 | const unsigned char* from_copy; |
| 229 | 220 | |
| 230 | 221 | if (ll==NULL) |
| 231 | 222 | return ZIP_INTERNALERROR; |
| @@ -236,11 +227,11 @@ | ||
| 236 | 227 | if (ll->first_block == NULL) |
| 237 | 228 | return ZIP_INTERNALERROR; |
| 238 | 229 | } |
| 239 | 230 | |
| 240 | 231 | ldi = ll->last_block; |
| 241 | - from_copy = (unsigned char*)buf; | |
| 232 | + from_copy = (const unsigned char*)buf; | |
| 242 | 233 | |
| 243 | 234 | while (len>0) |
| 244 | 235 | { |
| 245 | 236 | uInt copy_this; |
| 246 | 237 | uInt i; |
| @@ -281,13 +272,11 @@ | ||
| 281 | 272 | /* =========================================================================== |
| 282 | 273 | Inputs a long in LSB order to the given file |
| 283 | 274 | nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T) |
| 284 | 275 | */ |
| 285 | 276 | |
| 286 | -local int zip64local_putValue OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)); | |
| 287 | -local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) | |
| 288 | -{ | |
| 277 | +local int zip64local_putValue(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) { | |
| 289 | 278 | unsigned char buf[8]; |
| 290 | 279 | int n; |
| 291 | 280 | for (n = 0; n < nbByte; n++) |
| 292 | 281 | { |
| 293 | 282 | buf[n] = (unsigned char)(x & 0xff); |
| @@ -305,13 +294,11 @@ | ||
| 305 | 294 | return ZIP_ERRNO; |
| 306 | 295 | else |
| 307 | 296 | return ZIP_OK; |
| 308 | 297 | } |
| 309 | 298 | |
| 310 | -local void zip64local_putValue_inmemory OF((void* dest, ZPOS64_T x, int nbByte)); | |
| 311 | -local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) | |
| 312 | -{ | |
| 299 | +local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) { | |
| 313 | 300 | unsigned char* buf=(unsigned char*)dest; |
| 314 | 301 | int n; |
| 315 | 302 | for (n = 0; n < nbByte; n++) { |
| 316 | 303 | buf[n] = (unsigned char)(x & 0xff); |
| 317 | 304 | x >>= 8; |
| @@ -327,12 +314,11 @@ | ||
| 327 | 314 | } |
| 328 | 315 | |
| 329 | 316 | /****************************************************************************/ |
| 330 | 317 | |
| 331 | 318 | |
| 332 | -local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) | |
| 333 | -{ | |
| 319 | +local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) { | |
| 334 | 320 | uLong year = (uLong)ptm->tm_year; |
| 335 | 321 | if (year>=1980) |
| 336 | 322 | year-=1980; |
| 337 | 323 | else if (year>=80) |
| 338 | 324 | year-=80; |
| @@ -342,14 +328,11 @@ | ||
| 342 | 328 | } |
| 343 | 329 | |
| 344 | 330 | |
| 345 | 331 | /****************************************************************************/ |
| 346 | 332 | |
| 347 | -local int zip64local_getByte OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)); | |
| 348 | - | |
| 349 | -local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,voidpf filestream,int* pi) | |
| 350 | -{ | |
| 333 | +local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int* pi) { | |
| 351 | 334 | unsigned char c; |
| 352 | 335 | int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); |
| 353 | 336 | if (err==1) |
| 354 | 337 | { |
| 355 | 338 | *pi = (int)c; |
| @@ -366,14 +349,11 @@ | ||
| 366 | 349 | |
| 367 | 350 | |
| 368 | 351 | /* =========================================================================== |
| 369 | 352 | Reads a long in LSB order from the given gz_stream. Sets |
| 370 | 353 | */ |
| 371 | -local int zip64local_getShort OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); | |
| 372 | - | |
| 373 | -local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) | |
| 374 | -{ | |
| 354 | +local int zip64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) { | |
| 375 | 355 | uLong x ; |
| 376 | 356 | int i = 0; |
| 377 | 357 | int err; |
| 378 | 358 | |
| 379 | 359 | err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); |
| @@ -388,14 +368,11 @@ | ||
| 388 | 368 | else |
| 389 | 369 | *pX = 0; |
| 390 | 370 | return err; |
| 391 | 371 | } |
| 392 | 372 | |
| 393 | -local int zip64local_getLong OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); | |
| 394 | - | |
| 395 | -local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) | |
| 396 | -{ | |
| 373 | +local int zip64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) { | |
| 397 | 374 | uLong x ; |
| 398 | 375 | int i = 0; |
| 399 | 376 | int err; |
| 400 | 377 | |
| 401 | 378 | err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); |
| @@ -418,15 +395,12 @@ | ||
| 418 | 395 | else |
| 419 | 396 | *pX = 0; |
| 420 | 397 | return err; |
| 421 | 398 | } |
| 422 | 399 | |
| 423 | -local int zip64local_getLong64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)); | |
| 424 | 400 | |
| 425 | - | |
| 426 | -local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) | |
| 427 | -{ | |
| 401 | +local int zip64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) { | |
| 428 | 402 | ZPOS64_T x; |
| 429 | 403 | int i = 0; |
| 430 | 404 | int err; |
| 431 | 405 | |
| 432 | 406 | err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); |
| @@ -473,14 +447,11 @@ | ||
| 473 | 447 | #endif |
| 474 | 448 | /* |
| 475 | 449 | Locate the Central directory of a zipfile (at the end, just before |
| 476 | 450 | the global comment) |
| 477 | 451 | */ |
| 478 | -local ZPOS64_T zip64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); | |
| 479 | - | |
| 480 | -local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) | |
| 481 | -{ | |
| 452 | +local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { | |
| 482 | 453 | unsigned char* buf; |
| 483 | 454 | ZPOS64_T uSizeFile; |
| 484 | 455 | ZPOS64_T uBackRead; |
| 485 | 456 | ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
| 486 | 457 | ZPOS64_T uPosFound=0; |
| @@ -527,22 +498,19 @@ | ||
| 527 | 498 | } |
| 528 | 499 | |
| 529 | 500 | if (uPosFound!=0) |
| 530 | 501 | break; |
| 531 | 502 | } |
| 532 | - TRYFREE(buf); | |
| 503 | + free(buf); | |
| 533 | 504 | return uPosFound; |
| 534 | 505 | } |
| 535 | 506 | |
| 536 | 507 | /* |
| 537 | 508 | Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before |
| 538 | 509 | the global comment) |
| 539 | 510 | */ |
| 540 | -local ZPOS64_T zip64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); | |
| 541 | - | |
| 542 | -local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) | |
| 543 | -{ | |
| 511 | +local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { | |
| 544 | 512 | unsigned char* buf; |
| 545 | 513 | ZPOS64_T uSizeFile; |
| 546 | 514 | ZPOS64_T uBackRead; |
| 547 | 515 | ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
| 548 | 516 | ZPOS64_T uPosFound=0; |
| @@ -593,11 +561,11 @@ | ||
| 593 | 561 | |
| 594 | 562 | if (uPosFound!=0) |
| 595 | 563 | break; |
| 596 | 564 | } |
| 597 | 565 | |
| 598 | - TRYFREE(buf); | |
| 566 | + free(buf); | |
| 599 | 567 | if (uPosFound == 0) |
| 600 | 568 | return 0; |
| 601 | 569 | |
| 602 | 570 | /* Zip64 end of central directory locator */ |
| 603 | 571 | if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0) |
| @@ -635,24 +603,23 @@ | ||
| 635 | 603 | return 0; |
| 636 | 604 | |
| 637 | 605 | return relativeOffset; |
| 638 | 606 | } |
| 639 | 607 | |
| 640 | -local int LoadCentralDirectoryRecord(zip64_internal* pziinit) | |
| 641 | -{ | |
| 608 | +local int LoadCentralDirectoryRecord(zip64_internal* pziinit) { | |
| 642 | 609 | int err=ZIP_OK; |
| 643 | 610 | ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
| 644 | 611 | |
| 645 | 612 | ZPOS64_T size_central_dir; /* size of the central directory */ |
| 646 | 613 | ZPOS64_T offset_central_dir; /* offset of start of central directory */ |
| 647 | 614 | ZPOS64_T central_pos; |
| 648 | 615 | uLong uL; |
| 649 | 616 | |
| 650 | 617 | uLong number_disk; /* number of the current dist, used for |
| 651 | - spaning ZIP, unsupported, always 0*/ | |
| 618 | + spanning ZIP, unsupported, always 0*/ | |
| 652 | 619 | uLong number_disk_with_CD; /* number the the disk with central dir, used |
| 653 | - for spaning ZIP, unsupported, always 0*/ | |
| 620 | + for spanning ZIP, unsupported, always 0*/ | |
| 654 | 621 | ZPOS64_T number_entry; |
| 655 | 622 | ZPOS64_T number_entry_CD; /* total number of entries in |
| 656 | 623 | the central dir |
| 657 | 624 | (same than number_entry on nospan) */ |
| 658 | 625 | uLong VersionMadeBy; |
| @@ -828,11 +795,11 @@ | ||
| 828 | 795 | if (err==ZIP_OK) |
| 829 | 796 | err = add_data_in_datablock(&pziinit->central_dir,buf_read, (uLong)read_this); |
| 830 | 797 | |
| 831 | 798 | size_central_dir_to_read-=read_this; |
| 832 | 799 | } |
| 833 | - TRYFREE(buf_read); | |
| 800 | + free(buf_read); | |
| 834 | 801 | } |
| 835 | 802 | pziinit->begin_pos = byte_before_the_zipfile; |
| 836 | 803 | pziinit->number_entry = number_entry_CD; |
| 837 | 804 | |
| 838 | 805 | if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET) != 0) |
| @@ -844,12 +811,11 @@ | ||
| 844 | 811 | |
| 845 | 812 | #endif /* !NO_ADDFILEINEXISTINGZIP*/ |
| 846 | 813 | |
| 847 | 814 | |
| 848 | 815 | /************************************************************/ |
| 849 | -extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) | |
| 850 | -{ | |
| 816 | +extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) { | |
| 851 | 817 | zip64_internal ziinit; |
| 852 | 818 | zip64_internal* zi; |
| 853 | 819 | int err=ZIP_OK; |
| 854 | 820 | |
| 855 | 821 | ziinit.z_filefunc.zseek32_file = NULL; |
| @@ -903,24 +869,23 @@ | ||
| 903 | 869 | # endif /* !NO_ADDFILEINEXISTINGZIP*/ |
| 904 | 870 | |
| 905 | 871 | if (err != ZIP_OK) |
| 906 | 872 | { |
| 907 | 873 | # ifndef NO_ADDFILEINEXISTINGZIP |
| 908 | - TRYFREE(ziinit.globalcomment); | |
| 874 | + free(ziinit.globalcomment); | |
| 909 | 875 | # endif /* !NO_ADDFILEINEXISTINGZIP*/ |
| 910 | - TRYFREE(zi); | |
| 876 | + free(zi); | |
| 911 | 877 | return NULL; |
| 912 | 878 | } |
| 913 | 879 | else |
| 914 | 880 | { |
| 915 | 881 | *zi = ziinit; |
| 916 | 882 | return (zipFile)zi; |
| 917 | 883 | } |
| 918 | 884 | } |
| 919 | 885 | |
| 920 | -extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) | |
| 921 | -{ | |
| 886 | +extern zipFile ZEXPORT zipOpen2(const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) { | |
| 922 | 887 | if (pzlib_filefunc32_def != NULL) |
| 923 | 888 | { |
| 924 | 889 | zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; |
| 925 | 890 | fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def); |
| 926 | 891 | return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill); |
| @@ -927,12 +892,11 @@ | ||
| 927 | 892 | } |
| 928 | 893 | else |
| 929 | 894 | return zipOpen3(pathname, append, globalcomment, NULL); |
| 930 | 895 | } |
| 931 | 896 | |
| 932 | -extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) | |
| 933 | -{ | |
| 897 | +extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) { | |
| 934 | 898 | if (pzlib_filefunc_def != NULL) |
| 935 | 899 | { |
| 936 | 900 | zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; |
| 937 | 901 | zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def; |
| 938 | 902 | zlib_filefunc64_32_def_fill.ztell32_file = NULL; |
| @@ -943,22 +907,19 @@ | ||
| 943 | 907 | return zipOpen3(pathname, append, globalcomment, NULL); |
| 944 | 908 | } |
| 945 | 909 | |
| 946 | 910 | |
| 947 | 911 | |
| 948 | -extern zipFile ZEXPORT zipOpen (const char* pathname, int append) | |
| 949 | -{ | |
| 912 | +extern zipFile ZEXPORT zipOpen(const char* pathname, int append) { | |
| 950 | 913 | return zipOpen3((const void*)pathname,append,NULL,NULL); |
| 951 | 914 | } |
| 952 | 915 | |
| 953 | -extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append) | |
| 954 | -{ | |
| 916 | +extern zipFile ZEXPORT zipOpen64(const void* pathname, int append) { | |
| 955 | 917 | return zipOpen3(pathname,append,NULL,NULL); |
| 956 | 918 | } |
| 957 | 919 | |
| 958 | -local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) | |
| 959 | -{ | |
| 920 | +local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) { | |
| 960 | 921 | /* write the local header */ |
| 961 | 922 | int err; |
| 962 | 923 | uInt size_filename = (uInt)strlen(filename); |
| 963 | 924 | uInt size_extrafield = size_extrafield_local; |
| 964 | 925 | |
| @@ -1050,18 +1011,17 @@ | ||
| 1050 | 1011 | before calling this function it can be done with zipRemoveExtraInfoBlock |
| 1051 | 1012 | |
| 1052 | 1013 | It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize |
| 1053 | 1014 | unnecessary allocations. |
| 1054 | 1015 | */ |
| 1055 | -extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, | |
| 1056 | - const void* extrafield_local, uInt size_extrafield_local, | |
| 1057 | - const void* extrafield_global, uInt size_extrafield_global, | |
| 1058 | - const char* comment, int method, int level, int raw, | |
| 1059 | - int windowBits,int memLevel, int strategy, | |
| 1060 | - const char* password, uLong crcForCrypting, | |
| 1061 | - uLong versionMadeBy, uLong flagBase, int zip64) | |
| 1062 | -{ | |
| 1016 | +extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, | |
| 1017 | + const void* extrafield_local, uInt size_extrafield_local, | |
| 1018 | + const void* extrafield_global, uInt size_extrafield_global, | |
| 1019 | + const char* comment, int method, int level, int raw, | |
| 1020 | + int windowBits,int memLevel, int strategy, | |
| 1021 | + const char* password, uLong crcForCrypting, | |
| 1022 | + uLong versionMadeBy, uLong flagBase, int zip64) { | |
| 1063 | 1023 | zip64_internal* zi; |
| 1064 | 1024 | uInt size_filename; |
| 1065 | 1025 | uInt size_comment; |
| 1066 | 1026 | uInt i; |
| 1067 | 1027 | int err = ZIP_OK; |
| @@ -1260,110 +1220,102 @@ | ||
| 1260 | 1220 | if (err==Z_OK) |
| 1261 | 1221 | zi->in_opened_file_inzip = 1; |
| 1262 | 1222 | return err; |
| 1263 | 1223 | } |
| 1264 | 1224 | |
| 1265 | -extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file, const char* filename, const zip_fileinfo* zipfi, | |
| 1266 | - const void* extrafield_local, uInt size_extrafield_local, | |
| 1267 | - const void* extrafield_global, uInt size_extrafield_global, | |
| 1268 | - const char* comment, int method, int level, int raw, | |
| 1269 | - int windowBits,int memLevel, int strategy, | |
| 1270 | - const char* password, uLong crcForCrypting, | |
| 1271 | - uLong versionMadeBy, uLong flagBase) | |
| 1272 | -{ | |
| 1273 | - return zipOpenNewFileInZip4_64 (file, filename, zipfi, | |
| 1274 | - extrafield_local, size_extrafield_local, | |
| 1275 | - extrafield_global, size_extrafield_global, | |
| 1276 | - comment, method, level, raw, | |
| 1277 | - windowBits, memLevel, strategy, | |
| 1278 | - password, crcForCrypting, versionMadeBy, flagBase, 0); | |
| 1279 | -} | |
| 1280 | - | |
| 1281 | -extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char* filename, const zip_fileinfo* zipfi, | |
| 1282 | - const void* extrafield_local, uInt size_extrafield_local, | |
| 1283 | - const void* extrafield_global, uInt size_extrafield_global, | |
| 1284 | - const char* comment, int method, int level, int raw, | |
| 1285 | - int windowBits,int memLevel, int strategy, | |
| 1286 | - const char* password, uLong crcForCrypting) | |
| 1287 | -{ | |
| 1288 | - return zipOpenNewFileInZip4_64 (file, filename, zipfi, | |
| 1289 | - extrafield_local, size_extrafield_local, | |
| 1290 | - extrafield_global, size_extrafield_global, | |
| 1291 | - comment, method, level, raw, | |
| 1292 | - windowBits, memLevel, strategy, | |
| 1293 | - password, crcForCrypting, VERSIONMADEBY, 0, 0); | |
| 1225 | +extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char* filename, const zip_fileinfo* zipfi, | |
| 1226 | + const void* extrafield_local, uInt size_extrafield_local, | |
| 1227 | + const void* extrafield_global, uInt size_extrafield_global, | |
| 1228 | + const char* comment, int method, int level, int raw, | |
| 1229 | + int windowBits,int memLevel, int strategy, | |
| 1230 | + const char* password, uLong crcForCrypting, | |
| 1231 | + uLong versionMadeBy, uLong flagBase) { | |
| 1232 | + return zipOpenNewFileInZip4_64(file, filename, zipfi, | |
| 1233 | + extrafield_local, size_extrafield_local, | |
| 1234 | + extrafield_global, size_extrafield_global, | |
| 1235 | + comment, method, level, raw, | |
| 1236 | + windowBits, memLevel, strategy, | |
| 1237 | + password, crcForCrypting, versionMadeBy, flagBase, 0); | |
| 1238 | +} | |
| 1239 | + | |
| 1240 | +extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char* filename, const zip_fileinfo* zipfi, | |
| 1241 | + const void* extrafield_local, uInt size_extrafield_local, | |
| 1242 | + const void* extrafield_global, uInt size_extrafield_global, | |
| 1243 | + const char* comment, int method, int level, int raw, | |
| 1244 | + int windowBits,int memLevel, int strategy, | |
| 1245 | + const char* password, uLong crcForCrypting) { | |
| 1246 | + return zipOpenNewFileInZip4_64(file, filename, zipfi, | |
| 1247 | + extrafield_local, size_extrafield_local, | |
| 1248 | + extrafield_global, size_extrafield_global, | |
| 1249 | + comment, method, level, raw, | |
| 1250 | + windowBits, memLevel, strategy, | |
| 1251 | + password, crcForCrypting, VERSIONMADEBY, 0, 0); | |
| 1294 | 1252 | } |
| 1295 | 1253 | |
| 1296 | 1254 | extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1297 | 1255 | const void* extrafield_local, uInt size_extrafield_local, |
| 1298 | 1256 | const void* extrafield_global, uInt size_extrafield_global, |
| 1299 | 1257 | const char* comment, int method, int level, int raw, |
| 1300 | 1258 | int windowBits,int memLevel, int strategy, |
| 1301 | - const char* password, uLong crcForCrypting, int zip64) | |
| 1302 | -{ | |
| 1303 | - return zipOpenNewFileInZip4_64 (file, filename, zipfi, | |
| 1304 | - extrafield_local, size_extrafield_local, | |
| 1305 | - extrafield_global, size_extrafield_global, | |
| 1306 | - comment, method, level, raw, | |
| 1307 | - windowBits, memLevel, strategy, | |
| 1308 | - password, crcForCrypting, VERSIONMADEBY, 0, zip64); | |
| 1259 | + const char* password, uLong crcForCrypting, int zip64) { | |
| 1260 | + return zipOpenNewFileInZip4_64(file, filename, zipfi, | |
| 1261 | + extrafield_local, size_extrafield_local, | |
| 1262 | + extrafield_global, size_extrafield_global, | |
| 1263 | + comment, method, level, raw, | |
| 1264 | + windowBits, memLevel, strategy, | |
| 1265 | + password, crcForCrypting, VERSIONMADEBY, 0, zip64); | |
| 1309 | 1266 | } |
| 1310 | 1267 | |
| 1311 | 1268 | extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1312 | 1269 | const void* extrafield_local, uInt size_extrafield_local, |
| 1313 | 1270 | const void* extrafield_global, uInt size_extrafield_global, |
| 1314 | - const char* comment, int method, int level, int raw) | |
| 1315 | -{ | |
| 1316 | - return zipOpenNewFileInZip4_64 (file, filename, zipfi, | |
| 1317 | - extrafield_local, size_extrafield_local, | |
| 1318 | - extrafield_global, size_extrafield_global, | |
| 1319 | - comment, method, level, raw, | |
| 1320 | - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, | |
| 1321 | - NULL, 0, VERSIONMADEBY, 0, 0); | |
| 1271 | + const char* comment, int method, int level, int raw) { | |
| 1272 | + return zipOpenNewFileInZip4_64(file, filename, zipfi, | |
| 1273 | + extrafield_local, size_extrafield_local, | |
| 1274 | + extrafield_global, size_extrafield_global, | |
| 1275 | + comment, method, level, raw, | |
| 1276 | + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, | |
| 1277 | + NULL, 0, VERSIONMADEBY, 0, 0); | |
| 1322 | 1278 | } |
| 1323 | 1279 | |
| 1324 | 1280 | extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1325 | - const void* extrafield_local, uInt size_extrafield_local, | |
| 1326 | - const void* extrafield_global, uInt size_extrafield_global, | |
| 1327 | - const char* comment, int method, int level, int raw, int zip64) | |
| 1328 | -{ | |
| 1329 | - return zipOpenNewFileInZip4_64 (file, filename, zipfi, | |
| 1330 | - extrafield_local, size_extrafield_local, | |
| 1331 | - extrafield_global, size_extrafield_global, | |
| 1332 | - comment, method, level, raw, | |
| 1333 | - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, | |
| 1334 | - NULL, 0, VERSIONMADEBY, 0, zip64); | |
| 1335 | -} | |
| 1336 | - | |
| 1337 | -extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, | |
| 1338 | - const void* extrafield_local, uInt size_extrafield_local, | |
| 1339 | - const void*extrafield_global, uInt size_extrafield_global, | |
| 1340 | - const char* comment, int method, int level, int zip64) | |
| 1341 | -{ | |
| 1342 | - return zipOpenNewFileInZip4_64 (file, filename, zipfi, | |
| 1343 | - extrafield_local, size_extrafield_local, | |
| 1344 | - extrafield_global, size_extrafield_global, | |
| 1345 | - comment, method, level, 0, | |
| 1346 | - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, | |
| 1347 | - NULL, 0, VERSIONMADEBY, 0, zip64); | |
| 1348 | -} | |
| 1349 | - | |
| 1350 | -extern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char* filename, const zip_fileinfo* zipfi, | |
| 1351 | - const void* extrafield_local, uInt size_extrafield_local, | |
| 1352 | - const void*extrafield_global, uInt size_extrafield_global, | |
| 1353 | - const char* comment, int method, int level) | |
| 1354 | -{ | |
| 1355 | - return zipOpenNewFileInZip4_64 (file, filename, zipfi, | |
| 1356 | - extrafield_local, size_extrafield_local, | |
| 1357 | - extrafield_global, size_extrafield_global, | |
| 1358 | - comment, method, level, 0, | |
| 1359 | - -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, | |
| 1360 | - NULL, 0, VERSIONMADEBY, 0, 0); | |
| 1361 | -} | |
| 1362 | - | |
| 1363 | -local int zip64FlushWriteBuffer(zip64_internal* zi) | |
| 1364 | -{ | |
| 1281 | + const void* extrafield_local, uInt size_extrafield_local, | |
| 1282 | + const void* extrafield_global, uInt size_extrafield_global, | |
| 1283 | + const char* comment, int method, int level, int raw, int zip64) { | |
| 1284 | + return zipOpenNewFileInZip4_64(file, filename, zipfi, | |
| 1285 | + extrafield_local, size_extrafield_local, | |
| 1286 | + extrafield_global, size_extrafield_global, | |
| 1287 | + comment, method, level, raw, | |
| 1288 | + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, | |
| 1289 | + NULL, 0, VERSIONMADEBY, 0, zip64); | |
| 1290 | +} | |
| 1291 | + | |
| 1292 | +extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char* filename, const zip_fileinfo* zipfi, | |
| 1293 | + const void* extrafield_local, uInt size_extrafield_local, | |
| 1294 | + const void*extrafield_global, uInt size_extrafield_global, | |
| 1295 | + const char* comment, int method, int level, int zip64) { | |
| 1296 | + return zipOpenNewFileInZip4_64(file, filename, zipfi, | |
| 1297 | + extrafield_local, size_extrafield_local, | |
| 1298 | + extrafield_global, size_extrafield_global, | |
| 1299 | + comment, method, level, 0, | |
| 1300 | + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, | |
| 1301 | + NULL, 0, VERSIONMADEBY, 0, zip64); | |
| 1302 | +} | |
| 1303 | + | |
| 1304 | +extern int ZEXPORT zipOpenNewFileInZip(zipFile file, const char* filename, const zip_fileinfo* zipfi, | |
| 1305 | + const void* extrafield_local, uInt size_extrafield_local, | |
| 1306 | + const void*extrafield_global, uInt size_extrafield_global, | |
| 1307 | + const char* comment, int method, int level) { | |
| 1308 | + return zipOpenNewFileInZip4_64(file, filename, zipfi, | |
| 1309 | + extrafield_local, size_extrafield_local, | |
| 1310 | + extrafield_global, size_extrafield_global, | |
| 1311 | + comment, method, level, 0, | |
| 1312 | + -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, | |
| 1313 | + NULL, 0, VERSIONMADEBY, 0, 0); | |
| 1314 | +} | |
| 1315 | + | |
| 1316 | +local int zip64FlushWriteBuffer(zip64_internal* zi) { | |
| 1365 | 1317 | int err=ZIP_OK; |
| 1366 | 1318 | |
| 1367 | 1319 | if (zi->ci.encrypt != 0) |
| 1368 | 1320 | { |
| 1369 | 1321 | #ifndef NOCRYPT |
| @@ -1397,12 +1349,11 @@ | ||
| 1397 | 1349 | zi->ci.pos_in_buffered_data = 0; |
| 1398 | 1350 | |
| 1399 | 1351 | return err; |
| 1400 | 1352 | } |
| 1401 | 1353 | |
| 1402 | -extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned int len) | |
| 1403 | -{ | |
| 1354 | +extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned int len) { | |
| 1404 | 1355 | zip64_internal* zi; |
| 1405 | 1356 | int err=ZIP_OK; |
| 1406 | 1357 | |
| 1407 | 1358 | if (file == NULL) |
| 1408 | 1359 | return ZIP_PARAMERROR; |
| @@ -1448,11 +1399,11 @@ | ||
| 1448 | 1399 | err = ZIP_OK; |
| 1449 | 1400 | } |
| 1450 | 1401 | else |
| 1451 | 1402 | #endif |
| 1452 | 1403 | { |
| 1453 | - zi->ci.stream.next_in = (Bytef*)buf; | |
| 1404 | + zi->ci.stream.next_in = (Bytef*)(uintptr_t)buf; | |
| 1454 | 1405 | zi->ci.stream.avail_in = len; |
| 1455 | 1406 | |
| 1456 | 1407 | while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) |
| 1457 | 1408 | { |
| 1458 | 1409 | if (zi->ci.stream.avail_out == 0) |
| @@ -1499,17 +1450,15 @@ | ||
| 1499 | 1450 | } |
| 1500 | 1451 | |
| 1501 | 1452 | return err; |
| 1502 | 1453 | } |
| 1503 | 1454 | |
| 1504 | -extern int ZEXPORT zipCloseFileInZipRaw (zipFile file, uLong uncompressed_size, uLong crc32) | |
| 1505 | -{ | |
| 1455 | +extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, uLong uncompressed_size, uLong crc32) { | |
| 1506 | 1456 | return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32); |
| 1507 | 1457 | } |
| 1508 | 1458 | |
| 1509 | -extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_size, uLong crc32) | |
| 1510 | -{ | |
| 1459 | +extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_size, uLong crc32) { | |
| 1511 | 1460 | zip64_internal* zi; |
| 1512 | 1461 | ZPOS64_T compressed_size; |
| 1513 | 1462 | uLong invalidValue = 0xffffffff; |
| 1514 | 1463 | unsigned datasize = 0; |
| 1515 | 1464 | int err=ZIP_OK; |
| @@ -1740,17 +1689,15 @@ | ||
| 1740 | 1689 | zi->in_opened_file_inzip = 0; |
| 1741 | 1690 | |
| 1742 | 1691 | return err; |
| 1743 | 1692 | } |
| 1744 | 1693 | |
| 1745 | -extern int ZEXPORT zipCloseFileInZip (zipFile file) | |
| 1746 | -{ | |
| 1694 | +extern int ZEXPORT zipCloseFileInZip(zipFile file) { | |
| 1747 | 1695 | return zipCloseFileInZipRaw (file,0,0); |
| 1748 | 1696 | } |
| 1749 | 1697 | |
| 1750 | -local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) | |
| 1751 | -{ | |
| 1698 | +local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) { | |
| 1752 | 1699 | int err = ZIP_OK; |
| 1753 | 1700 | ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset; |
| 1754 | 1701 | |
| 1755 | 1702 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEADERMAGIC,4); |
| 1756 | 1703 | |
| @@ -1767,12 +1714,11 @@ | ||
| 1767 | 1714 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)1,4); |
| 1768 | 1715 | |
| 1769 | 1716 | return err; |
| 1770 | 1717 | } |
| 1771 | 1718 | |
| 1772 | -local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) | |
| 1773 | -{ | |
| 1719 | +local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) { | |
| 1774 | 1720 | int err = ZIP_OK; |
| 1775 | 1721 | |
| 1776 | 1722 | uLong Zip64DataSize = 44; |
| 1777 | 1723 | |
| 1778 | 1724 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDHEADERMAGIC,4); |
| @@ -1806,12 +1752,12 @@ | ||
| 1806 | 1752 | ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; |
| 1807 | 1753 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8); |
| 1808 | 1754 | } |
| 1809 | 1755 | return err; |
| 1810 | 1756 | } |
| 1811 | -local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) | |
| 1812 | -{ | |
| 1757 | + | |
| 1758 | +local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) { | |
| 1813 | 1759 | int err = ZIP_OK; |
| 1814 | 1760 | |
| 1815 | 1761 | /*signature*/ |
| 1816 | 1762 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); |
| 1817 | 1763 | |
| @@ -1854,12 +1800,11 @@ | ||
| 1854 | 1800 | } |
| 1855 | 1801 | |
| 1856 | 1802 | return err; |
| 1857 | 1803 | } |
| 1858 | 1804 | |
| 1859 | -local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) | |
| 1860 | -{ | |
| 1805 | +local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) { | |
| 1861 | 1806 | int err = ZIP_OK; |
| 1862 | 1807 | uInt size_global_comment = 0; |
| 1863 | 1808 | |
| 1864 | 1809 | if(global_comment != NULL) |
| 1865 | 1810 | size_global_comment = (uInt)strlen(global_comment); |
| @@ -1872,12 +1817,11 @@ | ||
| 1872 | 1817 | err = ZIP_ERRNO; |
| 1873 | 1818 | } |
| 1874 | 1819 | return err; |
| 1875 | 1820 | } |
| 1876 | 1821 | |
| 1877 | -extern int ZEXPORT zipClose (zipFile file, const char* global_comment) | |
| 1878 | -{ | |
| 1822 | +extern int ZEXPORT zipClose(zipFile file, const char* global_comment) { | |
| 1879 | 1823 | zip64_internal* zi; |
| 1880 | 1824 | int err = 0; |
| 1881 | 1825 | uLong size_centraldir = 0; |
| 1882 | 1826 | ZPOS64_T centraldir_pos_inzip; |
| 1883 | 1827 | ZPOS64_T pos; |
| @@ -1934,19 +1878,18 @@ | ||
| 1934 | 1878 | if (ZCLOSE64(zi->z_filefunc,zi->filestream) != 0) |
| 1935 | 1879 | if (err == ZIP_OK) |
| 1936 | 1880 | err = ZIP_ERRNO; |
| 1937 | 1881 | |
| 1938 | 1882 | #ifndef NO_ADDFILEINEXISTINGZIP |
| 1939 | - TRYFREE(zi->globalcomment); | |
| 1883 | + free(zi->globalcomment); | |
| 1940 | 1884 | #endif |
| 1941 | - TRYFREE(zi); | |
| 1885 | + free(zi); | |
| 1942 | 1886 | |
| 1943 | 1887 | return err; |
| 1944 | 1888 | } |
| 1945 | 1889 | |
| 1946 | -extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHeader) | |
| 1947 | -{ | |
| 1890 | +extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader) { | |
| 1948 | 1891 | char* p = pData; |
| 1949 | 1892 | int size = 0; |
| 1950 | 1893 | char* pNewHeader; |
| 1951 | 1894 | char* pTmp; |
| 1952 | 1895 | short header; |
| @@ -1994,9 +1937,9 @@ | ||
| 1994 | 1937 | retVal = ZIP_OK; |
| 1995 | 1938 | } |
| 1996 | 1939 | else |
| 1997 | 1940 | retVal = ZIP_ERRNO; |
| 1998 | 1941 | |
| 1999 | - TRYFREE(pNewHeader); | |
| 1942 | + free(pNewHeader); | |
| 2000 | 1943 | |
| 2001 | 1944 | return retVal; |
| 2002 | 1945 | } |
| 2003 | 1946 |
| --- compat/zlib/contrib/minizip/zip.c | |
| +++ compat/zlib/contrib/minizip/zip.c | |
| @@ -12,11 +12,11 @@ | |
| 12 | Changes |
| 13 | Oct-2009 - Mathias Svensson - Remove old C style function prototypes |
| 14 | Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives |
| 15 | Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions. |
| 16 | Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data |
| 17 | It is used when recreting zip archive with RAW when deleting items from a zip. |
| 18 | ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed. |
| 19 | Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required) |
| 20 | Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer |
| 21 | |
| 22 | */ |
| @@ -23,18 +23,17 @@ | |
| 23 | |
| 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| 28 | #include <time.h> |
| 29 | #include "zlib.h" |
| 30 | #include "zip.h" |
| 31 | |
| 32 | #ifdef STDC |
| 33 | # include <stddef.h> |
| 34 | # include <string.h> |
| 35 | # include <stdlib.h> |
| 36 | #endif |
| 37 | #ifdef NO_ERRNO_H |
| 38 | extern int errno; |
| 39 | #else |
| 40 | # include <errno.h> |
| @@ -45,11 +44,11 @@ | |
| 45 | # define local static |
| 46 | #endif |
| 47 | /* compile with -Dlocal if your debugger can't find static symbols */ |
| 48 | |
| 49 | #ifndef VERSIONMADEBY |
| 50 | # define VERSIONMADEBY (0x0) /* platform depedent */ |
| 51 | #endif |
| 52 | |
| 53 | #ifndef Z_BUFSIZE |
| 54 | #define Z_BUFSIZE (64*1024) //(16384) |
| 55 | #endif |
| @@ -59,13 +58,10 @@ | |
| 59 | #endif |
| 60 | |
| 61 | #ifndef ALLOC |
| 62 | # define ALLOC(size) (malloc(size)) |
| 63 | #endif |
| 64 | #ifndef TRYFREE |
| 65 | # define TRYFREE(p) {if (p) free(p);} |
| 66 | #endif |
| 67 | |
| 68 | /* |
| 69 | #define SIZECENTRALDIRITEM (0x2e) |
| 70 | #define SIZEZIPLOCALHEADER (0x1e) |
| 71 | */ |
| @@ -136,24 +132,24 @@ | |
| 136 | |
| 137 | int stream_initialised; /* 1 is stream is initialised */ |
| 138 | uInt pos_in_buffered_data; /* last written byte in buffered_data */ |
| 139 | |
| 140 | ZPOS64_T pos_local_header; /* offset of the local header of the file |
| 141 | currenty writing */ |
| 142 | char* central_header; /* central header data for the current file */ |
| 143 | uLong size_centralExtra; |
| 144 | uLong size_centralheader; /* size of the central header for cur file */ |
| 145 | uLong size_centralExtraFree; /* Extra bytes allocated to the centralheader but that are not used */ |
| 146 | uLong flag; /* flag of the file currently writing */ |
| 147 | |
| 148 | int method; /* compression method of file currenty wr.*/ |
| 149 | int raw; /* 1 for directly writing raw data */ |
| 150 | Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ |
| 151 | uLong dosDate; |
| 152 | uLong crc32; |
| 153 | int encrypt; |
| 154 | int zip64; /* Add ZIP64 extened information in the extra field */ |
| 155 | ZPOS64_T pos_zip64extrainfo; |
| 156 | ZPOS64_T totalCompressedData; |
| 157 | ZPOS64_T totalUncompressedData; |
| 158 | #ifndef NOCRYPT |
| 159 | unsigned long keys[3]; /* keys defining the pseudo-random sequence */ |
| @@ -163,14 +159,14 @@ | |
| 163 | } curfile64_info; |
| 164 | |
| 165 | typedef struct |
| 166 | { |
| 167 | zlib_filefunc64_32_def z_filefunc; |
| 168 | voidpf filestream; /* io structore of the zipfile */ |
| 169 | linkedlist_data central_dir;/* datablock with central dir in construction*/ |
| 170 | int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ |
| 171 | curfile64_info ci; /* info on the file curretly writing */ |
| 172 | |
| 173 | ZPOS64_T begin_pos; /* position of the beginning of the zipfile */ |
| 174 | ZPOS64_T add_position_when_writing_offset; |
| 175 | ZPOS64_T number_entry; |
| 176 | |
| @@ -184,12 +180,11 @@ | |
| 184 | #ifndef NOCRYPT |
| 185 | #define INCLUDECRYPTINGCODE_IFCRYPTALLOWED |
| 186 | #include "crypt.h" |
| 187 | #endif |
| 188 | |
| 189 | local linkedlist_datablock_internal* allocate_new_datablock() |
| 190 | { |
| 191 | linkedlist_datablock_internal* ldi; |
| 192 | ldi = (linkedlist_datablock_internal*) |
| 193 | ALLOC(sizeof(linkedlist_datablock_internal)); |
| 194 | if (ldi!=NULL) |
| 195 | { |
| @@ -198,34 +193,30 @@ | |
| 198 | ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; |
| 199 | } |
| 200 | return ldi; |
| 201 | } |
| 202 | |
| 203 | local void free_datablock(linkedlist_datablock_internal* ldi) |
| 204 | { |
| 205 | while (ldi!=NULL) |
| 206 | { |
| 207 | linkedlist_datablock_internal* ldinext = ldi->next_datablock; |
| 208 | TRYFREE(ldi); |
| 209 | ldi = ldinext; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | local void init_linkedlist(linkedlist_data* ll) |
| 214 | { |
| 215 | ll->first_block = ll->last_block = NULL; |
| 216 | } |
| 217 | |
| 218 | local void free_linkedlist(linkedlist_data* ll) |
| 219 | { |
| 220 | free_datablock(ll->first_block); |
| 221 | ll->first_block = ll->last_block = NULL; |
| 222 | } |
| 223 | |
| 224 | |
| 225 | local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) |
| 226 | { |
| 227 | linkedlist_datablock_internal* ldi; |
| 228 | const unsigned char* from_copy; |
| 229 | |
| 230 | if (ll==NULL) |
| 231 | return ZIP_INTERNALERROR; |
| @@ -236,11 +227,11 @@ | |
| 236 | if (ll->first_block == NULL) |
| 237 | return ZIP_INTERNALERROR; |
| 238 | } |
| 239 | |
| 240 | ldi = ll->last_block; |
| 241 | from_copy = (unsigned char*)buf; |
| 242 | |
| 243 | while (len>0) |
| 244 | { |
| 245 | uInt copy_this; |
| 246 | uInt i; |
| @@ -281,13 +272,11 @@ | |
| 281 | /* =========================================================================== |
| 282 | Inputs a long in LSB order to the given file |
| 283 | nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T) |
| 284 | */ |
| 285 | |
| 286 | local int zip64local_putValue OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)); |
| 287 | local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) |
| 288 | { |
| 289 | unsigned char buf[8]; |
| 290 | int n; |
| 291 | for (n = 0; n < nbByte; n++) |
| 292 | { |
| 293 | buf[n] = (unsigned char)(x & 0xff); |
| @@ -305,13 +294,11 @@ | |
| 305 | return ZIP_ERRNO; |
| 306 | else |
| 307 | return ZIP_OK; |
| 308 | } |
| 309 | |
| 310 | local void zip64local_putValue_inmemory OF((void* dest, ZPOS64_T x, int nbByte)); |
| 311 | local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) |
| 312 | { |
| 313 | unsigned char* buf=(unsigned char*)dest; |
| 314 | int n; |
| 315 | for (n = 0; n < nbByte; n++) { |
| 316 | buf[n] = (unsigned char)(x & 0xff); |
| 317 | x >>= 8; |
| @@ -327,12 +314,11 @@ | |
| 327 | } |
| 328 | |
| 329 | /****************************************************************************/ |
| 330 | |
| 331 | |
| 332 | local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) |
| 333 | { |
| 334 | uLong year = (uLong)ptm->tm_year; |
| 335 | if (year>=1980) |
| 336 | year-=1980; |
| 337 | else if (year>=80) |
| 338 | year-=80; |
| @@ -342,14 +328,11 @@ | |
| 342 | } |
| 343 | |
| 344 | |
| 345 | /****************************************************************************/ |
| 346 | |
| 347 | local int zip64local_getByte OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)); |
| 348 | |
| 349 | local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,voidpf filestream,int* pi) |
| 350 | { |
| 351 | unsigned char c; |
| 352 | int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); |
| 353 | if (err==1) |
| 354 | { |
| 355 | *pi = (int)c; |
| @@ -366,14 +349,11 @@ | |
| 366 | |
| 367 | |
| 368 | /* =========================================================================== |
| 369 | Reads a long in LSB order from the given gz_stream. Sets |
| 370 | */ |
| 371 | local int zip64local_getShort OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); |
| 372 | |
| 373 | local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) |
| 374 | { |
| 375 | uLong x ; |
| 376 | int i = 0; |
| 377 | int err; |
| 378 | |
| 379 | err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); |
| @@ -388,14 +368,11 @@ | |
| 388 | else |
| 389 | *pX = 0; |
| 390 | return err; |
| 391 | } |
| 392 | |
| 393 | local int zip64local_getLong OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX)); |
| 394 | |
| 395 | local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) |
| 396 | { |
| 397 | uLong x ; |
| 398 | int i = 0; |
| 399 | int err; |
| 400 | |
| 401 | err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); |
| @@ -418,15 +395,12 @@ | |
| 418 | else |
| 419 | *pX = 0; |
| 420 | return err; |
| 421 | } |
| 422 | |
| 423 | local int zip64local_getLong64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)); |
| 424 | |
| 425 | |
| 426 | local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) |
| 427 | { |
| 428 | ZPOS64_T x; |
| 429 | int i = 0; |
| 430 | int err; |
| 431 | |
| 432 | err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); |
| @@ -473,14 +447,11 @@ | |
| 473 | #endif |
| 474 | /* |
| 475 | Locate the Central directory of a zipfile (at the end, just before |
| 476 | the global comment) |
| 477 | */ |
| 478 | local ZPOS64_T zip64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); |
| 479 | |
| 480 | local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) |
| 481 | { |
| 482 | unsigned char* buf; |
| 483 | ZPOS64_T uSizeFile; |
| 484 | ZPOS64_T uBackRead; |
| 485 | ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
| 486 | ZPOS64_T uPosFound=0; |
| @@ -527,22 +498,19 @@ | |
| 527 | } |
| 528 | |
| 529 | if (uPosFound!=0) |
| 530 | break; |
| 531 | } |
| 532 | TRYFREE(buf); |
| 533 | return uPosFound; |
| 534 | } |
| 535 | |
| 536 | /* |
| 537 | Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before |
| 538 | the global comment) |
| 539 | */ |
| 540 | local ZPOS64_T zip64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)); |
| 541 | |
| 542 | local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) |
| 543 | { |
| 544 | unsigned char* buf; |
| 545 | ZPOS64_T uSizeFile; |
| 546 | ZPOS64_T uBackRead; |
| 547 | ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
| 548 | ZPOS64_T uPosFound=0; |
| @@ -593,11 +561,11 @@ | |
| 593 | |
| 594 | if (uPosFound!=0) |
| 595 | break; |
| 596 | } |
| 597 | |
| 598 | TRYFREE(buf); |
| 599 | if (uPosFound == 0) |
| 600 | return 0; |
| 601 | |
| 602 | /* Zip64 end of central directory locator */ |
| 603 | if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0) |
| @@ -635,24 +603,23 @@ | |
| 635 | return 0; |
| 636 | |
| 637 | return relativeOffset; |
| 638 | } |
| 639 | |
| 640 | local int LoadCentralDirectoryRecord(zip64_internal* pziinit) |
| 641 | { |
| 642 | int err=ZIP_OK; |
| 643 | ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
| 644 | |
| 645 | ZPOS64_T size_central_dir; /* size of the central directory */ |
| 646 | ZPOS64_T offset_central_dir; /* offset of start of central directory */ |
| 647 | ZPOS64_T central_pos; |
| 648 | uLong uL; |
| 649 | |
| 650 | uLong number_disk; /* number of the current dist, used for |
| 651 | spaning ZIP, unsupported, always 0*/ |
| 652 | uLong number_disk_with_CD; /* number the the disk with central dir, used |
| 653 | for spaning ZIP, unsupported, always 0*/ |
| 654 | ZPOS64_T number_entry; |
| 655 | ZPOS64_T number_entry_CD; /* total number of entries in |
| 656 | the central dir |
| 657 | (same than number_entry on nospan) */ |
| 658 | uLong VersionMadeBy; |
| @@ -828,11 +795,11 @@ | |
| 828 | if (err==ZIP_OK) |
| 829 | err = add_data_in_datablock(&pziinit->central_dir,buf_read, (uLong)read_this); |
| 830 | |
| 831 | size_central_dir_to_read-=read_this; |
| 832 | } |
| 833 | TRYFREE(buf_read); |
| 834 | } |
| 835 | pziinit->begin_pos = byte_before_the_zipfile; |
| 836 | pziinit->number_entry = number_entry_CD; |
| 837 | |
| 838 | if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET) != 0) |
| @@ -844,12 +811,11 @@ | |
| 844 | |
| 845 | #endif /* !NO_ADDFILEINEXISTINGZIP*/ |
| 846 | |
| 847 | |
| 848 | /************************************************************/ |
| 849 | extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) |
| 850 | { |
| 851 | zip64_internal ziinit; |
| 852 | zip64_internal* zi; |
| 853 | int err=ZIP_OK; |
| 854 | |
| 855 | ziinit.z_filefunc.zseek32_file = NULL; |
| @@ -903,24 +869,23 @@ | |
| 903 | # endif /* !NO_ADDFILEINEXISTINGZIP*/ |
| 904 | |
| 905 | if (err != ZIP_OK) |
| 906 | { |
| 907 | # ifndef NO_ADDFILEINEXISTINGZIP |
| 908 | TRYFREE(ziinit.globalcomment); |
| 909 | # endif /* !NO_ADDFILEINEXISTINGZIP*/ |
| 910 | TRYFREE(zi); |
| 911 | return NULL; |
| 912 | } |
| 913 | else |
| 914 | { |
| 915 | *zi = ziinit; |
| 916 | return (zipFile)zi; |
| 917 | } |
| 918 | } |
| 919 | |
| 920 | extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) |
| 921 | { |
| 922 | if (pzlib_filefunc32_def != NULL) |
| 923 | { |
| 924 | zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; |
| 925 | fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def); |
| 926 | return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill); |
| @@ -927,12 +892,11 @@ | |
| 927 | } |
| 928 | else |
| 929 | return zipOpen3(pathname, append, globalcomment, NULL); |
| 930 | } |
| 931 | |
| 932 | extern zipFile ZEXPORT zipOpen2_64 (const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) |
| 933 | { |
| 934 | if (pzlib_filefunc_def != NULL) |
| 935 | { |
| 936 | zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; |
| 937 | zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def; |
| 938 | zlib_filefunc64_32_def_fill.ztell32_file = NULL; |
| @@ -943,22 +907,19 @@ | |
| 943 | return zipOpen3(pathname, append, globalcomment, NULL); |
| 944 | } |
| 945 | |
| 946 | |
| 947 | |
| 948 | extern zipFile ZEXPORT zipOpen (const char* pathname, int append) |
| 949 | { |
| 950 | return zipOpen3((const void*)pathname,append,NULL,NULL); |
| 951 | } |
| 952 | |
| 953 | extern zipFile ZEXPORT zipOpen64 (const void* pathname, int append) |
| 954 | { |
| 955 | return zipOpen3(pathname,append,NULL,NULL); |
| 956 | } |
| 957 | |
| 958 | local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) |
| 959 | { |
| 960 | /* write the local header */ |
| 961 | int err; |
| 962 | uInt size_filename = (uInt)strlen(filename); |
| 963 | uInt size_extrafield = size_extrafield_local; |
| 964 | |
| @@ -1050,18 +1011,17 @@ | |
| 1050 | before calling this function it can be done with zipRemoveExtraInfoBlock |
| 1051 | |
| 1052 | It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize |
| 1053 | unnecessary allocations. |
| 1054 | */ |
| 1055 | extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1056 | const void* extrafield_local, uInt size_extrafield_local, |
| 1057 | const void* extrafield_global, uInt size_extrafield_global, |
| 1058 | const char* comment, int method, int level, int raw, |
| 1059 | int windowBits,int memLevel, int strategy, |
| 1060 | const char* password, uLong crcForCrypting, |
| 1061 | uLong versionMadeBy, uLong flagBase, int zip64) |
| 1062 | { |
| 1063 | zip64_internal* zi; |
| 1064 | uInt size_filename; |
| 1065 | uInt size_comment; |
| 1066 | uInt i; |
| 1067 | int err = ZIP_OK; |
| @@ -1260,110 +1220,102 @@ | |
| 1260 | if (err==Z_OK) |
| 1261 | zi->in_opened_file_inzip = 1; |
| 1262 | return err; |
| 1263 | } |
| 1264 | |
| 1265 | extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1266 | const void* extrafield_local, uInt size_extrafield_local, |
| 1267 | const void* extrafield_global, uInt size_extrafield_global, |
| 1268 | const char* comment, int method, int level, int raw, |
| 1269 | int windowBits,int memLevel, int strategy, |
| 1270 | const char* password, uLong crcForCrypting, |
| 1271 | uLong versionMadeBy, uLong flagBase) |
| 1272 | { |
| 1273 | return zipOpenNewFileInZip4_64 (file, filename, zipfi, |
| 1274 | extrafield_local, size_extrafield_local, |
| 1275 | extrafield_global, size_extrafield_global, |
| 1276 | comment, method, level, raw, |
| 1277 | windowBits, memLevel, strategy, |
| 1278 | password, crcForCrypting, versionMadeBy, flagBase, 0); |
| 1279 | } |
| 1280 | |
| 1281 | extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1282 | const void* extrafield_local, uInt size_extrafield_local, |
| 1283 | const void* extrafield_global, uInt size_extrafield_global, |
| 1284 | const char* comment, int method, int level, int raw, |
| 1285 | int windowBits,int memLevel, int strategy, |
| 1286 | const char* password, uLong crcForCrypting) |
| 1287 | { |
| 1288 | return zipOpenNewFileInZip4_64 (file, filename, zipfi, |
| 1289 | extrafield_local, size_extrafield_local, |
| 1290 | extrafield_global, size_extrafield_global, |
| 1291 | comment, method, level, raw, |
| 1292 | windowBits, memLevel, strategy, |
| 1293 | password, crcForCrypting, VERSIONMADEBY, 0, 0); |
| 1294 | } |
| 1295 | |
| 1296 | extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1297 | const void* extrafield_local, uInt size_extrafield_local, |
| 1298 | const void* extrafield_global, uInt size_extrafield_global, |
| 1299 | const char* comment, int method, int level, int raw, |
| 1300 | int windowBits,int memLevel, int strategy, |
| 1301 | const char* password, uLong crcForCrypting, int zip64) |
| 1302 | { |
| 1303 | return zipOpenNewFileInZip4_64 (file, filename, zipfi, |
| 1304 | extrafield_local, size_extrafield_local, |
| 1305 | extrafield_global, size_extrafield_global, |
| 1306 | comment, method, level, raw, |
| 1307 | windowBits, memLevel, strategy, |
| 1308 | password, crcForCrypting, VERSIONMADEBY, 0, zip64); |
| 1309 | } |
| 1310 | |
| 1311 | extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1312 | const void* extrafield_local, uInt size_extrafield_local, |
| 1313 | const void* extrafield_global, uInt size_extrafield_global, |
| 1314 | const char* comment, int method, int level, int raw) |
| 1315 | { |
| 1316 | return zipOpenNewFileInZip4_64 (file, filename, zipfi, |
| 1317 | extrafield_local, size_extrafield_local, |
| 1318 | extrafield_global, size_extrafield_global, |
| 1319 | comment, method, level, raw, |
| 1320 | -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, |
| 1321 | NULL, 0, VERSIONMADEBY, 0, 0); |
| 1322 | } |
| 1323 | |
| 1324 | extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1325 | const void* extrafield_local, uInt size_extrafield_local, |
| 1326 | const void* extrafield_global, uInt size_extrafield_global, |
| 1327 | const char* comment, int method, int level, int raw, int zip64) |
| 1328 | { |
| 1329 | return zipOpenNewFileInZip4_64 (file, filename, zipfi, |
| 1330 | extrafield_local, size_extrafield_local, |
| 1331 | extrafield_global, size_extrafield_global, |
| 1332 | comment, method, level, raw, |
| 1333 | -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, |
| 1334 | NULL, 0, VERSIONMADEBY, 0, zip64); |
| 1335 | } |
| 1336 | |
| 1337 | extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1338 | const void* extrafield_local, uInt size_extrafield_local, |
| 1339 | const void*extrafield_global, uInt size_extrafield_global, |
| 1340 | const char* comment, int method, int level, int zip64) |
| 1341 | { |
| 1342 | return zipOpenNewFileInZip4_64 (file, filename, zipfi, |
| 1343 | extrafield_local, size_extrafield_local, |
| 1344 | extrafield_global, size_extrafield_global, |
| 1345 | comment, method, level, 0, |
| 1346 | -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, |
| 1347 | NULL, 0, VERSIONMADEBY, 0, zip64); |
| 1348 | } |
| 1349 | |
| 1350 | extern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1351 | const void* extrafield_local, uInt size_extrafield_local, |
| 1352 | const void*extrafield_global, uInt size_extrafield_global, |
| 1353 | const char* comment, int method, int level) |
| 1354 | { |
| 1355 | return zipOpenNewFileInZip4_64 (file, filename, zipfi, |
| 1356 | extrafield_local, size_extrafield_local, |
| 1357 | extrafield_global, size_extrafield_global, |
| 1358 | comment, method, level, 0, |
| 1359 | -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, |
| 1360 | NULL, 0, VERSIONMADEBY, 0, 0); |
| 1361 | } |
| 1362 | |
| 1363 | local int zip64FlushWriteBuffer(zip64_internal* zi) |
| 1364 | { |
| 1365 | int err=ZIP_OK; |
| 1366 | |
| 1367 | if (zi->ci.encrypt != 0) |
| 1368 | { |
| 1369 | #ifndef NOCRYPT |
| @@ -1397,12 +1349,11 @@ | |
| 1397 | zi->ci.pos_in_buffered_data = 0; |
| 1398 | |
| 1399 | return err; |
| 1400 | } |
| 1401 | |
| 1402 | extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned int len) |
| 1403 | { |
| 1404 | zip64_internal* zi; |
| 1405 | int err=ZIP_OK; |
| 1406 | |
| 1407 | if (file == NULL) |
| 1408 | return ZIP_PARAMERROR; |
| @@ -1448,11 +1399,11 @@ | |
| 1448 | err = ZIP_OK; |
| 1449 | } |
| 1450 | else |
| 1451 | #endif |
| 1452 | { |
| 1453 | zi->ci.stream.next_in = (Bytef*)buf; |
| 1454 | zi->ci.stream.avail_in = len; |
| 1455 | |
| 1456 | while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) |
| 1457 | { |
| 1458 | if (zi->ci.stream.avail_out == 0) |
| @@ -1499,17 +1450,15 @@ | |
| 1499 | } |
| 1500 | |
| 1501 | return err; |
| 1502 | } |
| 1503 | |
| 1504 | extern int ZEXPORT zipCloseFileInZipRaw (zipFile file, uLong uncompressed_size, uLong crc32) |
| 1505 | { |
| 1506 | return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32); |
| 1507 | } |
| 1508 | |
| 1509 | extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file, ZPOS64_T uncompressed_size, uLong crc32) |
| 1510 | { |
| 1511 | zip64_internal* zi; |
| 1512 | ZPOS64_T compressed_size; |
| 1513 | uLong invalidValue = 0xffffffff; |
| 1514 | unsigned datasize = 0; |
| 1515 | int err=ZIP_OK; |
| @@ -1740,17 +1689,15 @@ | |
| 1740 | zi->in_opened_file_inzip = 0; |
| 1741 | |
| 1742 | return err; |
| 1743 | } |
| 1744 | |
| 1745 | extern int ZEXPORT zipCloseFileInZip (zipFile file) |
| 1746 | { |
| 1747 | return zipCloseFileInZipRaw (file,0,0); |
| 1748 | } |
| 1749 | |
| 1750 | local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) |
| 1751 | { |
| 1752 | int err = ZIP_OK; |
| 1753 | ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset; |
| 1754 | |
| 1755 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEADERMAGIC,4); |
| 1756 | |
| @@ -1767,12 +1714,11 @@ | |
| 1767 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)1,4); |
| 1768 | |
| 1769 | return err; |
| 1770 | } |
| 1771 | |
| 1772 | local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) |
| 1773 | { |
| 1774 | int err = ZIP_OK; |
| 1775 | |
| 1776 | uLong Zip64DataSize = 44; |
| 1777 | |
| 1778 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDHEADERMAGIC,4); |
| @@ -1806,12 +1752,12 @@ | |
| 1806 | ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; |
| 1807 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8); |
| 1808 | } |
| 1809 | return err; |
| 1810 | } |
| 1811 | local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) |
| 1812 | { |
| 1813 | int err = ZIP_OK; |
| 1814 | |
| 1815 | /*signature*/ |
| 1816 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); |
| 1817 | |
| @@ -1854,12 +1800,11 @@ | |
| 1854 | } |
| 1855 | |
| 1856 | return err; |
| 1857 | } |
| 1858 | |
| 1859 | local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) |
| 1860 | { |
| 1861 | int err = ZIP_OK; |
| 1862 | uInt size_global_comment = 0; |
| 1863 | |
| 1864 | if(global_comment != NULL) |
| 1865 | size_global_comment = (uInt)strlen(global_comment); |
| @@ -1872,12 +1817,11 @@ | |
| 1872 | err = ZIP_ERRNO; |
| 1873 | } |
| 1874 | return err; |
| 1875 | } |
| 1876 | |
| 1877 | extern int ZEXPORT zipClose (zipFile file, const char* global_comment) |
| 1878 | { |
| 1879 | zip64_internal* zi; |
| 1880 | int err = 0; |
| 1881 | uLong size_centraldir = 0; |
| 1882 | ZPOS64_T centraldir_pos_inzip; |
| 1883 | ZPOS64_T pos; |
| @@ -1934,19 +1878,18 @@ | |
| 1934 | if (ZCLOSE64(zi->z_filefunc,zi->filestream) != 0) |
| 1935 | if (err == ZIP_OK) |
| 1936 | err = ZIP_ERRNO; |
| 1937 | |
| 1938 | #ifndef NO_ADDFILEINEXISTINGZIP |
| 1939 | TRYFREE(zi->globalcomment); |
| 1940 | #endif |
| 1941 | TRYFREE(zi); |
| 1942 | |
| 1943 | return err; |
| 1944 | } |
| 1945 | |
| 1946 | extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHeader) |
| 1947 | { |
| 1948 | char* p = pData; |
| 1949 | int size = 0; |
| 1950 | char* pNewHeader; |
| 1951 | char* pTmp; |
| 1952 | short header; |
| @@ -1994,9 +1937,9 @@ | |
| 1994 | retVal = ZIP_OK; |
| 1995 | } |
| 1996 | else |
| 1997 | retVal = ZIP_ERRNO; |
| 1998 | |
| 1999 | TRYFREE(pNewHeader); |
| 2000 | |
| 2001 | return retVal; |
| 2002 | } |
| 2003 |
| --- compat/zlib/contrib/minizip/zip.c | |
| +++ compat/zlib/contrib/minizip/zip.c | |
| @@ -12,11 +12,11 @@ | |
| 12 | Changes |
| 13 | Oct-2009 - Mathias Svensson - Remove old C style function prototypes |
| 14 | Oct-2009 - Mathias Svensson - Added Zip64 Support when creating new file archives |
| 15 | Oct-2009 - Mathias Svensson - Did some code cleanup and refactoring to get better overview of some functions. |
| 16 | Oct-2009 - Mathias Svensson - Added zipRemoveExtraInfoBlock to strip extra field data from its ZIP64 data |
| 17 | It is used when recreating zip archive with RAW when deleting items from a zip. |
| 18 | ZIP64 data is automatically added to items that needs it, and existing ZIP64 data need to be removed. |
| 19 | Oct-2009 - Mathias Svensson - Added support for BZIP2 as compression mode (bzip2 lib is required) |
| 20 | Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer |
| 21 | |
| 22 | */ |
| @@ -23,18 +23,17 @@ | |
| 23 | |
| 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| 28 | #include <stdint.h> |
| 29 | #include <time.h> |
| 30 | #include "zlib.h" |
| 31 | #include "zip.h" |
| 32 | |
| 33 | #ifdef STDC |
| 34 | # include <stddef.h> |
| 35 | #endif |
| 36 | #ifdef NO_ERRNO_H |
| 37 | extern int errno; |
| 38 | #else |
| 39 | # include <errno.h> |
| @@ -45,11 +44,11 @@ | |
| 44 | # define local static |
| 45 | #endif |
| 46 | /* compile with -Dlocal if your debugger can't find static symbols */ |
| 47 | |
| 48 | #ifndef VERSIONMADEBY |
| 49 | # define VERSIONMADEBY (0x0) /* platform dependent */ |
| 50 | #endif |
| 51 | |
| 52 | #ifndef Z_BUFSIZE |
| 53 | #define Z_BUFSIZE (64*1024) //(16384) |
| 54 | #endif |
| @@ -59,13 +58,10 @@ | |
| 58 | #endif |
| 59 | |
| 60 | #ifndef ALLOC |
| 61 | # define ALLOC(size) (malloc(size)) |
| 62 | #endif |
| 63 | |
| 64 | /* |
| 65 | #define SIZECENTRALDIRITEM (0x2e) |
| 66 | #define SIZEZIPLOCALHEADER (0x1e) |
| 67 | */ |
| @@ -136,24 +132,24 @@ | |
| 132 | |
| 133 | int stream_initialised; /* 1 is stream is initialised */ |
| 134 | uInt pos_in_buffered_data; /* last written byte in buffered_data */ |
| 135 | |
| 136 | ZPOS64_T pos_local_header; /* offset of the local header of the file |
| 137 | currently writing */ |
| 138 | char* central_header; /* central header data for the current file */ |
| 139 | uLong size_centralExtra; |
| 140 | uLong size_centralheader; /* size of the central header for cur file */ |
| 141 | uLong size_centralExtraFree; /* Extra bytes allocated to the centralheader but that are not used */ |
| 142 | uLong flag; /* flag of the file currently writing */ |
| 143 | |
| 144 | int method; /* compression method of file currently wr.*/ |
| 145 | int raw; /* 1 for directly writing raw data */ |
| 146 | Byte buffered_data[Z_BUFSIZE];/* buffer contain compressed data to be writ*/ |
| 147 | uLong dosDate; |
| 148 | uLong crc32; |
| 149 | int encrypt; |
| 150 | int zip64; /* Add ZIP64 extended information in the extra field */ |
| 151 | ZPOS64_T pos_zip64extrainfo; |
| 152 | ZPOS64_T totalCompressedData; |
| 153 | ZPOS64_T totalUncompressedData; |
| 154 | #ifndef NOCRYPT |
| 155 | unsigned long keys[3]; /* keys defining the pseudo-random sequence */ |
| @@ -163,14 +159,14 @@ | |
| 159 | } curfile64_info; |
| 160 | |
| 161 | typedef struct |
| 162 | { |
| 163 | zlib_filefunc64_32_def z_filefunc; |
| 164 | voidpf filestream; /* io structure of the zipfile */ |
| 165 | linkedlist_data central_dir;/* datablock with central dir in construction*/ |
| 166 | int in_opened_file_inzip; /* 1 if a file in the zip is currently writ.*/ |
| 167 | curfile64_info ci; /* info on the file currently writing */ |
| 168 | |
| 169 | ZPOS64_T begin_pos; /* position of the beginning of the zipfile */ |
| 170 | ZPOS64_T add_position_when_writing_offset; |
| 171 | ZPOS64_T number_entry; |
| 172 | |
| @@ -184,12 +180,11 @@ | |
| 180 | #ifndef NOCRYPT |
| 181 | #define INCLUDECRYPTINGCODE_IFCRYPTALLOWED |
| 182 | #include "crypt.h" |
| 183 | #endif |
| 184 | |
| 185 | local linkedlist_datablock_internal* allocate_new_datablock(void) { |
| 186 | linkedlist_datablock_internal* ldi; |
| 187 | ldi = (linkedlist_datablock_internal*) |
| 188 | ALLOC(sizeof(linkedlist_datablock_internal)); |
| 189 | if (ldi!=NULL) |
| 190 | { |
| @@ -198,34 +193,30 @@ | |
| 193 | ldi->avail_in_this_block = SIZEDATA_INDATABLOCK ; |
| 194 | } |
| 195 | return ldi; |
| 196 | } |
| 197 | |
| 198 | local void free_datablock(linkedlist_datablock_internal* ldi) { |
| 199 | while (ldi!=NULL) |
| 200 | { |
| 201 | linkedlist_datablock_internal* ldinext = ldi->next_datablock; |
| 202 | free(ldi); |
| 203 | ldi = ldinext; |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | local void init_linkedlist(linkedlist_data* ll) { |
| 208 | ll->first_block = ll->last_block = NULL; |
| 209 | } |
| 210 | |
| 211 | local void free_linkedlist(linkedlist_data* ll) { |
| 212 | free_datablock(ll->first_block); |
| 213 | ll->first_block = ll->last_block = NULL; |
| 214 | } |
| 215 | |
| 216 | |
| 217 | local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len) { |
| 218 | linkedlist_datablock_internal* ldi; |
| 219 | const unsigned char* from_copy; |
| 220 | |
| 221 | if (ll==NULL) |
| 222 | return ZIP_INTERNALERROR; |
| @@ -236,11 +227,11 @@ | |
| 227 | if (ll->first_block == NULL) |
| 228 | return ZIP_INTERNALERROR; |
| 229 | } |
| 230 | |
| 231 | ldi = ll->last_block; |
| 232 | from_copy = (const unsigned char*)buf; |
| 233 | |
| 234 | while (len>0) |
| 235 | { |
| 236 | uInt copy_this; |
| 237 | uInt i; |
| @@ -281,13 +272,11 @@ | |
| 272 | /* =========================================================================== |
| 273 | Inputs a long in LSB order to the given file |
| 274 | nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T) |
| 275 | */ |
| 276 | |
| 277 | local int zip64local_putValue(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte) { |
| 278 | unsigned char buf[8]; |
| 279 | int n; |
| 280 | for (n = 0; n < nbByte; n++) |
| 281 | { |
| 282 | buf[n] = (unsigned char)(x & 0xff); |
| @@ -305,13 +294,11 @@ | |
| 294 | return ZIP_ERRNO; |
| 295 | else |
| 296 | return ZIP_OK; |
| 297 | } |
| 298 | |
| 299 | local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte) { |
| 300 | unsigned char* buf=(unsigned char*)dest; |
| 301 | int n; |
| 302 | for (n = 0; n < nbByte; n++) { |
| 303 | buf[n] = (unsigned char)(x & 0xff); |
| 304 | x >>= 8; |
| @@ -327,12 +314,11 @@ | |
| 314 | } |
| 315 | |
| 316 | /****************************************************************************/ |
| 317 | |
| 318 | |
| 319 | local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm) { |
| 320 | uLong year = (uLong)ptm->tm_year; |
| 321 | if (year>=1980) |
| 322 | year-=1980; |
| 323 | else if (year>=80) |
| 324 | year-=80; |
| @@ -342,14 +328,11 @@ | |
| 328 | } |
| 329 | |
| 330 | |
| 331 | /****************************************************************************/ |
| 332 | |
| 333 | local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int* pi) { |
| 334 | unsigned char c; |
| 335 | int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,&c,1); |
| 336 | if (err==1) |
| 337 | { |
| 338 | *pi = (int)c; |
| @@ -366,14 +349,11 @@ | |
| 349 | |
| 350 | |
| 351 | /* =========================================================================== |
| 352 | Reads a long in LSB order from the given gz_stream. Sets |
| 353 | */ |
| 354 | local int zip64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) { |
| 355 | uLong x ; |
| 356 | int i = 0; |
| 357 | int err; |
| 358 | |
| 359 | err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); |
| @@ -388,14 +368,11 @@ | |
| 368 | else |
| 369 | *pX = 0; |
| 370 | return err; |
| 371 | } |
| 372 | |
| 373 | local int zip64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX) { |
| 374 | uLong x ; |
| 375 | int i = 0; |
| 376 | int err; |
| 377 | |
| 378 | err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); |
| @@ -418,15 +395,12 @@ | |
| 395 | else |
| 396 | *pX = 0; |
| 397 | return err; |
| 398 | } |
| 399 | |
| 400 | |
| 401 | local int zip64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX) { |
| 402 | ZPOS64_T x; |
| 403 | int i = 0; |
| 404 | int err; |
| 405 | |
| 406 | err = zip64local_getByte(pzlib_filefunc_def,filestream,&i); |
| @@ -473,14 +447,11 @@ | |
| 447 | #endif |
| 448 | /* |
| 449 | Locate the Central directory of a zipfile (at the end, just before |
| 450 | the global comment) |
| 451 | */ |
| 452 | local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { |
| 453 | unsigned char* buf; |
| 454 | ZPOS64_T uSizeFile; |
| 455 | ZPOS64_T uBackRead; |
| 456 | ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
| 457 | ZPOS64_T uPosFound=0; |
| @@ -527,22 +498,19 @@ | |
| 498 | } |
| 499 | |
| 500 | if (uPosFound!=0) |
| 501 | break; |
| 502 | } |
| 503 | free(buf); |
| 504 | return uPosFound; |
| 505 | } |
| 506 | |
| 507 | /* |
| 508 | Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before |
| 509 | the global comment) |
| 510 | */ |
| 511 | local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { |
| 512 | unsigned char* buf; |
| 513 | ZPOS64_T uSizeFile; |
| 514 | ZPOS64_T uBackRead; |
| 515 | ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
| 516 | ZPOS64_T uPosFound=0; |
| @@ -593,11 +561,11 @@ | |
| 561 | |
| 562 | if (uPosFound!=0) |
| 563 | break; |
| 564 | } |
| 565 | |
| 566 | free(buf); |
| 567 | if (uPosFound == 0) |
| 568 | return 0; |
| 569 | |
| 570 | /* Zip64 end of central directory locator */ |
| 571 | if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0) |
| @@ -635,24 +603,23 @@ | |
| 603 | return 0; |
| 604 | |
| 605 | return relativeOffset; |
| 606 | } |
| 607 | |
| 608 | local int LoadCentralDirectoryRecord(zip64_internal* pziinit) { |
| 609 | int err=ZIP_OK; |
| 610 | ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
| 611 | |
| 612 | ZPOS64_T size_central_dir; /* size of the central directory */ |
| 613 | ZPOS64_T offset_central_dir; /* offset of start of central directory */ |
| 614 | ZPOS64_T central_pos; |
| 615 | uLong uL; |
| 616 | |
| 617 | uLong number_disk; /* number of the current dist, used for |
| 618 | spanning ZIP, unsupported, always 0*/ |
| 619 | uLong number_disk_with_CD; /* number the the disk with central dir, used |
| 620 | for spanning ZIP, unsupported, always 0*/ |
| 621 | ZPOS64_T number_entry; |
| 622 | ZPOS64_T number_entry_CD; /* total number of entries in |
| 623 | the central dir |
| 624 | (same than number_entry on nospan) */ |
| 625 | uLong VersionMadeBy; |
| @@ -828,11 +795,11 @@ | |
| 795 | if (err==ZIP_OK) |
| 796 | err = add_data_in_datablock(&pziinit->central_dir,buf_read, (uLong)read_this); |
| 797 | |
| 798 | size_central_dir_to_read-=read_this; |
| 799 | } |
| 800 | free(buf_read); |
| 801 | } |
| 802 | pziinit->begin_pos = byte_before_the_zipfile; |
| 803 | pziinit->number_entry = number_entry_CD; |
| 804 | |
| 805 | if (ZSEEK64(pziinit->z_filefunc, pziinit->filestream, offset_central_dir+byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET) != 0) |
| @@ -844,12 +811,11 @@ | |
| 811 | |
| 812 | #endif /* !NO_ADDFILEINEXISTINGZIP*/ |
| 813 | |
| 814 | |
| 815 | /************************************************************/ |
| 816 | extern zipFile ZEXPORT zipOpen3(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_32_def* pzlib_filefunc64_32_def) { |
| 817 | zip64_internal ziinit; |
| 818 | zip64_internal* zi; |
| 819 | int err=ZIP_OK; |
| 820 | |
| 821 | ziinit.z_filefunc.zseek32_file = NULL; |
| @@ -903,24 +869,23 @@ | |
| 869 | # endif /* !NO_ADDFILEINEXISTINGZIP*/ |
| 870 | |
| 871 | if (err != ZIP_OK) |
| 872 | { |
| 873 | # ifndef NO_ADDFILEINEXISTINGZIP |
| 874 | free(ziinit.globalcomment); |
| 875 | # endif /* !NO_ADDFILEINEXISTINGZIP*/ |
| 876 | free(zi); |
| 877 | return NULL; |
| 878 | } |
| 879 | else |
| 880 | { |
| 881 | *zi = ziinit; |
| 882 | return (zipFile)zi; |
| 883 | } |
| 884 | } |
| 885 | |
| 886 | extern zipFile ZEXPORT zipOpen2(const char *pathname, int append, zipcharpc* globalcomment, zlib_filefunc_def* pzlib_filefunc32_def) { |
| 887 | if (pzlib_filefunc32_def != NULL) |
| 888 | { |
| 889 | zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; |
| 890 | fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def); |
| 891 | return zipOpen3(pathname, append, globalcomment, &zlib_filefunc64_32_def_fill); |
| @@ -927,12 +892,11 @@ | |
| 892 | } |
| 893 | else |
| 894 | return zipOpen3(pathname, append, globalcomment, NULL); |
| 895 | } |
| 896 | |
| 897 | extern zipFile ZEXPORT zipOpen2_64(const void *pathname, int append, zipcharpc* globalcomment, zlib_filefunc64_def* pzlib_filefunc_def) { |
| 898 | if (pzlib_filefunc_def != NULL) |
| 899 | { |
| 900 | zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; |
| 901 | zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def; |
| 902 | zlib_filefunc64_32_def_fill.ztell32_file = NULL; |
| @@ -943,22 +907,19 @@ | |
| 907 | return zipOpen3(pathname, append, globalcomment, NULL); |
| 908 | } |
| 909 | |
| 910 | |
| 911 | |
| 912 | extern zipFile ZEXPORT zipOpen(const char* pathname, int append) { |
| 913 | return zipOpen3((const void*)pathname,append,NULL,NULL); |
| 914 | } |
| 915 | |
| 916 | extern zipFile ZEXPORT zipOpen64(const void* pathname, int append) { |
| 917 | return zipOpen3(pathname,append,NULL,NULL); |
| 918 | } |
| 919 | |
| 920 | local int Write_LocalFileHeader(zip64_internal* zi, const char* filename, uInt size_extrafield_local, const void* extrafield_local) { |
| 921 | /* write the local header */ |
| 922 | int err; |
| 923 | uInt size_filename = (uInt)strlen(filename); |
| 924 | uInt size_extrafield = size_extrafield_local; |
| 925 | |
| @@ -1050,18 +1011,17 @@ | |
| 1011 | before calling this function it can be done with zipRemoveExtraInfoBlock |
| 1012 | |
| 1013 | It is not done here because then we need to realloc a new buffer since parameters are 'const' and I want to minimize |
| 1014 | unnecessary allocations. |
| 1015 | */ |
| 1016 | extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1017 | const void* extrafield_local, uInt size_extrafield_local, |
| 1018 | const void* extrafield_global, uInt size_extrafield_global, |
| 1019 | const char* comment, int method, int level, int raw, |
| 1020 | int windowBits,int memLevel, int strategy, |
| 1021 | const char* password, uLong crcForCrypting, |
| 1022 | uLong versionMadeBy, uLong flagBase, int zip64) { |
| 1023 | zip64_internal* zi; |
| 1024 | uInt size_filename; |
| 1025 | uInt size_comment; |
| 1026 | uInt i; |
| 1027 | int err = ZIP_OK; |
| @@ -1260,110 +1220,102 @@ | |
| 1220 | if (err==Z_OK) |
| 1221 | zi->in_opened_file_inzip = 1; |
| 1222 | return err; |
| 1223 | } |
| 1224 | |
| 1225 | extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1226 | const void* extrafield_local, uInt size_extrafield_local, |
| 1227 | const void* extrafield_global, uInt size_extrafield_global, |
| 1228 | const char* comment, int method, int level, int raw, |
| 1229 | int windowBits,int memLevel, int strategy, |
| 1230 | const char* password, uLong crcForCrypting, |
| 1231 | uLong versionMadeBy, uLong flagBase) { |
| 1232 | return zipOpenNewFileInZip4_64(file, filename, zipfi, |
| 1233 | extrafield_local, size_extrafield_local, |
| 1234 | extrafield_global, size_extrafield_global, |
| 1235 | comment, method, level, raw, |
| 1236 | windowBits, memLevel, strategy, |
| 1237 | password, crcForCrypting, versionMadeBy, flagBase, 0); |
| 1238 | } |
| 1239 | |
| 1240 | extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1241 | const void* extrafield_local, uInt size_extrafield_local, |
| 1242 | const void* extrafield_global, uInt size_extrafield_global, |
| 1243 | const char* comment, int method, int level, int raw, |
| 1244 | int windowBits,int memLevel, int strategy, |
| 1245 | const char* password, uLong crcForCrypting) { |
| 1246 | return zipOpenNewFileInZip4_64(file, filename, zipfi, |
| 1247 | extrafield_local, size_extrafield_local, |
| 1248 | extrafield_global, size_extrafield_global, |
| 1249 | comment, method, level, raw, |
| 1250 | windowBits, memLevel, strategy, |
| 1251 | password, crcForCrypting, VERSIONMADEBY, 0, 0); |
| 1252 | } |
| 1253 | |
| 1254 | extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1255 | const void* extrafield_local, uInt size_extrafield_local, |
| 1256 | const void* extrafield_global, uInt size_extrafield_global, |
| 1257 | const char* comment, int method, int level, int raw, |
| 1258 | int windowBits,int memLevel, int strategy, |
| 1259 | const char* password, uLong crcForCrypting, int zip64) { |
| 1260 | return zipOpenNewFileInZip4_64(file, filename, zipfi, |
| 1261 | extrafield_local, size_extrafield_local, |
| 1262 | extrafield_global, size_extrafield_global, |
| 1263 | comment, method, level, raw, |
| 1264 | windowBits, memLevel, strategy, |
| 1265 | password, crcForCrypting, VERSIONMADEBY, 0, zip64); |
| 1266 | } |
| 1267 | |
| 1268 | extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1269 | const void* extrafield_local, uInt size_extrafield_local, |
| 1270 | const void* extrafield_global, uInt size_extrafield_global, |
| 1271 | const char* comment, int method, int level, int raw) { |
| 1272 | return zipOpenNewFileInZip4_64(file, filename, zipfi, |
| 1273 | extrafield_local, size_extrafield_local, |
| 1274 | extrafield_global, size_extrafield_global, |
| 1275 | comment, method, level, raw, |
| 1276 | -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, |
| 1277 | NULL, 0, VERSIONMADEBY, 0, 0); |
| 1278 | } |
| 1279 | |
| 1280 | extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1281 | const void* extrafield_local, uInt size_extrafield_local, |
| 1282 | const void* extrafield_global, uInt size_extrafield_global, |
| 1283 | const char* comment, int method, int level, int raw, int zip64) { |
| 1284 | return zipOpenNewFileInZip4_64(file, filename, zipfi, |
| 1285 | extrafield_local, size_extrafield_local, |
| 1286 | extrafield_global, size_extrafield_global, |
| 1287 | comment, method, level, raw, |
| 1288 | -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, |
| 1289 | NULL, 0, VERSIONMADEBY, 0, zip64); |
| 1290 | } |
| 1291 | |
| 1292 | extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1293 | const void* extrafield_local, uInt size_extrafield_local, |
| 1294 | const void*extrafield_global, uInt size_extrafield_global, |
| 1295 | const char* comment, int method, int level, int zip64) { |
| 1296 | return zipOpenNewFileInZip4_64(file, filename, zipfi, |
| 1297 | extrafield_local, size_extrafield_local, |
| 1298 | extrafield_global, size_extrafield_global, |
| 1299 | comment, method, level, 0, |
| 1300 | -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, |
| 1301 | NULL, 0, VERSIONMADEBY, 0, zip64); |
| 1302 | } |
| 1303 | |
| 1304 | extern int ZEXPORT zipOpenNewFileInZip(zipFile file, const char* filename, const zip_fileinfo* zipfi, |
| 1305 | const void* extrafield_local, uInt size_extrafield_local, |
| 1306 | const void*extrafield_global, uInt size_extrafield_global, |
| 1307 | const char* comment, int method, int level) { |
| 1308 | return zipOpenNewFileInZip4_64(file, filename, zipfi, |
| 1309 | extrafield_local, size_extrafield_local, |
| 1310 | extrafield_global, size_extrafield_global, |
| 1311 | comment, method, level, 0, |
| 1312 | -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, |
| 1313 | NULL, 0, VERSIONMADEBY, 0, 0); |
| 1314 | } |
| 1315 | |
| 1316 | local int zip64FlushWriteBuffer(zip64_internal* zi) { |
| 1317 | int err=ZIP_OK; |
| 1318 | |
| 1319 | if (zi->ci.encrypt != 0) |
| 1320 | { |
| 1321 | #ifndef NOCRYPT |
| @@ -1397,12 +1349,11 @@ | |
| 1349 | zi->ci.pos_in_buffered_data = 0; |
| 1350 | |
| 1351 | return err; |
| 1352 | } |
| 1353 | |
| 1354 | extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned int len) { |
| 1355 | zip64_internal* zi; |
| 1356 | int err=ZIP_OK; |
| 1357 | |
| 1358 | if (file == NULL) |
| 1359 | return ZIP_PARAMERROR; |
| @@ -1448,11 +1399,11 @@ | |
| 1399 | err = ZIP_OK; |
| 1400 | } |
| 1401 | else |
| 1402 | #endif |
| 1403 | { |
| 1404 | zi->ci.stream.next_in = (Bytef*)(uintptr_t)buf; |
| 1405 | zi->ci.stream.avail_in = len; |
| 1406 | |
| 1407 | while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0)) |
| 1408 | { |
| 1409 | if (zi->ci.stream.avail_out == 0) |
| @@ -1499,17 +1450,15 @@ | |
| 1450 | } |
| 1451 | |
| 1452 | return err; |
| 1453 | } |
| 1454 | |
| 1455 | extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, uLong uncompressed_size, uLong crc32) { |
| 1456 | return zipCloseFileInZipRaw64 (file, uncompressed_size, crc32); |
| 1457 | } |
| 1458 | |
| 1459 | extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, ZPOS64_T uncompressed_size, uLong crc32) { |
| 1460 | zip64_internal* zi; |
| 1461 | ZPOS64_T compressed_size; |
| 1462 | uLong invalidValue = 0xffffffff; |
| 1463 | unsigned datasize = 0; |
| 1464 | int err=ZIP_OK; |
| @@ -1740,17 +1689,15 @@ | |
| 1689 | zi->in_opened_file_inzip = 0; |
| 1690 | |
| 1691 | return err; |
| 1692 | } |
| 1693 | |
| 1694 | extern int ZEXPORT zipCloseFileInZip(zipFile file) { |
| 1695 | return zipCloseFileInZipRaw (file,0,0); |
| 1696 | } |
| 1697 | |
| 1698 | local int Write_Zip64EndOfCentralDirectoryLocator(zip64_internal* zi, ZPOS64_T zip64eocd_pos_inzip) { |
| 1699 | int err = ZIP_OK; |
| 1700 | ZPOS64_T pos = zip64eocd_pos_inzip - zi->add_position_when_writing_offset; |
| 1701 | |
| 1702 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDLOCHEADERMAGIC,4); |
| 1703 | |
| @@ -1767,12 +1714,11 @@ | |
| 1714 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)1,4); |
| 1715 | |
| 1716 | return err; |
| 1717 | } |
| 1718 | |
| 1719 | local int Write_Zip64EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) { |
| 1720 | int err = ZIP_OK; |
| 1721 | |
| 1722 | uLong Zip64DataSize = 44; |
| 1723 | |
| 1724 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ZIP64ENDHEADERMAGIC,4); |
| @@ -1806,12 +1752,12 @@ | |
| 1752 | ZPOS64_T pos = centraldir_pos_inzip - zi->add_position_when_writing_offset; |
| 1753 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream, (ZPOS64_T)pos,8); |
| 1754 | } |
| 1755 | return err; |
| 1756 | } |
| 1757 | |
| 1758 | local int Write_EndOfCentralDirectoryRecord(zip64_internal* zi, uLong size_centraldir, ZPOS64_T centraldir_pos_inzip) { |
| 1759 | int err = ZIP_OK; |
| 1760 | |
| 1761 | /*signature*/ |
| 1762 | err = zip64local_putValue(&zi->z_filefunc,zi->filestream,(uLong)ENDHEADERMAGIC,4); |
| 1763 | |
| @@ -1854,12 +1800,11 @@ | |
| 1800 | } |
| 1801 | |
| 1802 | return err; |
| 1803 | } |
| 1804 | |
| 1805 | local int Write_GlobalComment(zip64_internal* zi, const char* global_comment) { |
| 1806 | int err = ZIP_OK; |
| 1807 | uInt size_global_comment = 0; |
| 1808 | |
| 1809 | if(global_comment != NULL) |
| 1810 | size_global_comment = (uInt)strlen(global_comment); |
| @@ -1872,12 +1817,11 @@ | |
| 1817 | err = ZIP_ERRNO; |
| 1818 | } |
| 1819 | return err; |
| 1820 | } |
| 1821 | |
| 1822 | extern int ZEXPORT zipClose(zipFile file, const char* global_comment) { |
| 1823 | zip64_internal* zi; |
| 1824 | int err = 0; |
| 1825 | uLong size_centraldir = 0; |
| 1826 | ZPOS64_T centraldir_pos_inzip; |
| 1827 | ZPOS64_T pos; |
| @@ -1934,19 +1878,18 @@ | |
| 1878 | if (ZCLOSE64(zi->z_filefunc,zi->filestream) != 0) |
| 1879 | if (err == ZIP_OK) |
| 1880 | err = ZIP_ERRNO; |
| 1881 | |
| 1882 | #ifndef NO_ADDFILEINEXISTINGZIP |
| 1883 | free(zi->globalcomment); |
| 1884 | #endif |
| 1885 | free(zi); |
| 1886 | |
| 1887 | return err; |
| 1888 | } |
| 1889 | |
| 1890 | extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader) { |
| 1891 | char* p = pData; |
| 1892 | int size = 0; |
| 1893 | char* pNewHeader; |
| 1894 | char* pTmp; |
| 1895 | short header; |
| @@ -1994,9 +1937,9 @@ | |
| 1937 | retVal = ZIP_OK; |
| 1938 | } |
| 1939 | else |
| 1940 | retVal = ZIP_ERRNO; |
| 1941 | |
| 1942 | free(pNewHeader); |
| 1943 | |
| 1944 | return retVal; |
| 1945 | } |
| 1946 |
+153
-156
| --- compat/zlib/contrib/minizip/zip.h | ||
| +++ compat/zlib/contrib/minizip/zip.h | ||
| @@ -111,12 +111,12 @@ | ||
| 111 | 111 | |
| 112 | 112 | #define APPEND_STATUS_CREATE (0) |
| 113 | 113 | #define APPEND_STATUS_CREATEAFTER (1) |
| 114 | 114 | #define APPEND_STATUS_ADDINZIP (2) |
| 115 | 115 | |
| 116 | -extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); | |
| 117 | -extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append)); | |
| 116 | +extern zipFile ZEXPORT zipOpen(const char *pathname, int append); | |
| 117 | +extern zipFile ZEXPORT zipOpen64(const void *pathname, int append); | |
| 118 | 118 | /* |
| 119 | 119 | Create a zipfile. |
| 120 | 120 | pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on |
| 121 | 121 | an Unix computer "zlib/zlib113.zip". |
| 122 | 122 | if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip |
| @@ -129,50 +129,50 @@ | ||
| 129 | 129 | of this zip package. |
| 130 | 130 | */ |
| 131 | 131 | |
| 132 | 132 | /* Note : there is no delete function into a zipfile. |
| 133 | 133 | If you want delete file into a zipfile, you must open a zipfile, and create another |
| 134 | - Of couse, you can use RAW reading and writing to copy the file you did not want delte | |
| 135 | -*/ | |
| 136 | - | |
| 137 | -extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, | |
| 138 | - int append, | |
| 139 | - zipcharpc* globalcomment, | |
| 140 | - zlib_filefunc_def* pzlib_filefunc_def)); | |
| 141 | - | |
| 142 | -extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, | |
| 143 | - int append, | |
| 144 | - zipcharpc* globalcomment, | |
| 145 | - zlib_filefunc64_def* pzlib_filefunc_def)); | |
| 146 | - | |
| 147 | -extern zipFile ZEXPORT zipOpen3 OF((const void *pathname, | |
| 148 | - int append, | |
| 149 | - zipcharpc* globalcomment, | |
| 150 | - zlib_filefunc64_32_def* pzlib_filefunc64_32_def)); | |
| 151 | - | |
| 152 | -extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, | |
| 153 | - const char* filename, | |
| 154 | - const zip_fileinfo* zipfi, | |
| 155 | - const void* extrafield_local, | |
| 156 | - uInt size_extrafield_local, | |
| 157 | - const void* extrafield_global, | |
| 158 | - uInt size_extrafield_global, | |
| 159 | - const char* comment, | |
| 160 | - int method, | |
| 161 | - int level)); | |
| 162 | - | |
| 163 | -extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, | |
| 164 | - const char* filename, | |
| 165 | - const zip_fileinfo* zipfi, | |
| 166 | - const void* extrafield_local, | |
| 167 | - uInt size_extrafield_local, | |
| 168 | - const void* extrafield_global, | |
| 169 | - uInt size_extrafield_global, | |
| 170 | - const char* comment, | |
| 171 | - int method, | |
| 172 | - int level, | |
| 173 | - int zip64)); | |
| 134 | + Of course, you can use RAW reading and writing to copy the file you did not want delete | |
| 135 | +*/ | |
| 136 | + | |
| 137 | +extern zipFile ZEXPORT zipOpen2(const char *pathname, | |
| 138 | + int append, | |
| 139 | + zipcharpc* globalcomment, | |
| 140 | + zlib_filefunc_def* pzlib_filefunc_def); | |
| 141 | + | |
| 142 | +extern zipFile ZEXPORT zipOpen2_64(const void *pathname, | |
| 143 | + int append, | |
| 144 | + zipcharpc* globalcomment, | |
| 145 | + zlib_filefunc64_def* pzlib_filefunc_def); | |
| 146 | + | |
| 147 | +extern zipFile ZEXPORT zipOpen3(const void *pathname, | |
| 148 | + int append, | |
| 149 | + zipcharpc* globalcomment, | |
| 150 | + zlib_filefunc64_32_def* pzlib_filefunc64_32_def); | |
| 151 | + | |
| 152 | +extern int ZEXPORT zipOpenNewFileInZip(zipFile file, | |
| 153 | + const char* filename, | |
| 154 | + const zip_fileinfo* zipfi, | |
| 155 | + const void* extrafield_local, | |
| 156 | + uInt size_extrafield_local, | |
| 157 | + const void* extrafield_global, | |
| 158 | + uInt size_extrafield_global, | |
| 159 | + const char* comment, | |
| 160 | + int method, | |
| 161 | + int level); | |
| 162 | + | |
| 163 | +extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, | |
| 164 | + const char* filename, | |
| 165 | + const zip_fileinfo* zipfi, | |
| 166 | + const void* extrafield_local, | |
| 167 | + uInt size_extrafield_local, | |
| 168 | + const void* extrafield_global, | |
| 169 | + uInt size_extrafield_global, | |
| 170 | + const char* comment, | |
| 171 | + int method, | |
| 172 | + int level, | |
| 173 | + int zip64); | |
| 174 | 174 | |
| 175 | 175 | /* |
| 176 | 176 | Open a file in the ZIP for writing. |
| 177 | 177 | filename : the filename in zip (if NULL, '-' without quote will be used |
| 178 | 178 | *zipfi contain supplemental information |
| @@ -187,164 +187,161 @@ | ||
| 187 | 187 | this MUST be '1' if the uncompressed size is >= 0xffffffff. |
| 188 | 188 | |
| 189 | 189 | */ |
| 190 | 190 | |
| 191 | 191 | |
| 192 | -extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, | |
| 193 | - const char* filename, | |
| 194 | - const zip_fileinfo* zipfi, | |
| 195 | - const void* extrafield_local, | |
| 196 | - uInt size_extrafield_local, | |
| 197 | - const void* extrafield_global, | |
| 198 | - uInt size_extrafield_global, | |
| 199 | - const char* comment, | |
| 200 | - int method, | |
| 201 | - int level, | |
| 202 | - int raw)); | |
| 203 | - | |
| 204 | - | |
| 205 | -extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, | |
| 206 | - const char* filename, | |
| 207 | - const zip_fileinfo* zipfi, | |
| 208 | - const void* extrafield_local, | |
| 209 | - uInt size_extrafield_local, | |
| 210 | - const void* extrafield_global, | |
| 211 | - uInt size_extrafield_global, | |
| 212 | - const char* comment, | |
| 213 | - int method, | |
| 214 | - int level, | |
| 215 | - int raw, | |
| 216 | - int zip64)); | |
| 192 | +extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, | |
| 193 | + const char* filename, | |
| 194 | + const zip_fileinfo* zipfi, | |
| 195 | + const void* extrafield_local, | |
| 196 | + uInt size_extrafield_local, | |
| 197 | + const void* extrafield_global, | |
| 198 | + uInt size_extrafield_global, | |
| 199 | + const char* comment, | |
| 200 | + int method, | |
| 201 | + int level, | |
| 202 | + int raw); | |
| 203 | + | |
| 204 | + | |
| 205 | +extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, | |
| 206 | + const char* filename, | |
| 207 | + const zip_fileinfo* zipfi, | |
| 208 | + const void* extrafield_local, | |
| 209 | + uInt size_extrafield_local, | |
| 210 | + const void* extrafield_global, | |
| 211 | + uInt size_extrafield_global, | |
| 212 | + const char* comment, | |
| 213 | + int method, | |
| 214 | + int level, | |
| 215 | + int raw, | |
| 216 | + int zip64); | |
| 217 | 217 | /* |
| 218 | 218 | Same than zipOpenNewFileInZip, except if raw=1, we write raw file |
| 219 | 219 | */ |
| 220 | 220 | |
| 221 | -extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, | |
| 222 | - const char* filename, | |
| 223 | - const zip_fileinfo* zipfi, | |
| 224 | - const void* extrafield_local, | |
| 225 | - uInt size_extrafield_local, | |
| 226 | - const void* extrafield_global, | |
| 227 | - uInt size_extrafield_global, | |
| 228 | - const char* comment, | |
| 229 | - int method, | |
| 230 | - int level, | |
| 231 | - int raw, | |
| 232 | - int windowBits, | |
| 233 | - int memLevel, | |
| 234 | - int strategy, | |
| 235 | - const char* password, | |
| 236 | - uLong crcForCrypting)); | |
| 237 | - | |
| 238 | -extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, | |
| 239 | - const char* filename, | |
| 240 | - const zip_fileinfo* zipfi, | |
| 241 | - const void* extrafield_local, | |
| 242 | - uInt size_extrafield_local, | |
| 243 | - const void* extrafield_global, | |
| 244 | - uInt size_extrafield_global, | |
| 245 | - const char* comment, | |
| 246 | - int method, | |
| 247 | - int level, | |
| 248 | - int raw, | |
| 249 | - int windowBits, | |
| 250 | - int memLevel, | |
| 251 | - int strategy, | |
| 252 | - const char* password, | |
| 253 | - uLong crcForCrypting, | |
| 254 | - int zip64 | |
| 255 | - )); | |
| 221 | +extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, | |
| 222 | + const char* filename, | |
| 223 | + const zip_fileinfo* zipfi, | |
| 224 | + const void* extrafield_local, | |
| 225 | + uInt size_extrafield_local, | |
| 226 | + const void* extrafield_global, | |
| 227 | + uInt size_extrafield_global, | |
| 228 | + const char* comment, | |
| 229 | + int method, | |
| 230 | + int level, | |
| 231 | + int raw, | |
| 232 | + int windowBits, | |
| 233 | + int memLevel, | |
| 234 | + int strategy, | |
| 235 | + const char* password, | |
| 236 | + uLong crcForCrypting); | |
| 237 | + | |
| 238 | +extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, | |
| 239 | + const char* filename, | |
| 240 | + const zip_fileinfo* zipfi, | |
| 241 | + const void* extrafield_local, | |
| 242 | + uInt size_extrafield_local, | |
| 243 | + const void* extrafield_global, | |
| 244 | + uInt size_extrafield_global, | |
| 245 | + const char* comment, | |
| 246 | + int method, | |
| 247 | + int level, | |
| 248 | + int raw, | |
| 249 | + int windowBits, | |
| 250 | + int memLevel, | |
| 251 | + int strategy, | |
| 252 | + const char* password, | |
| 253 | + uLong crcForCrypting, | |
| 254 | + int zip64); | |
| 256 | 255 | |
| 257 | 256 | /* |
| 258 | 257 | Same than zipOpenNewFileInZip2, except |
| 259 | 258 | windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 |
| 260 | 259 | password : crypting password (NULL for no crypting) |
| 261 | 260 | crcForCrypting : crc of file to compress (needed for crypting) |
| 262 | 261 | */ |
| 263 | 262 | |
| 264 | -extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, | |
| 265 | - const char* filename, | |
| 266 | - const zip_fileinfo* zipfi, | |
| 267 | - const void* extrafield_local, | |
| 268 | - uInt size_extrafield_local, | |
| 269 | - const void* extrafield_global, | |
| 270 | - uInt size_extrafield_global, | |
| 271 | - const char* comment, | |
| 272 | - int method, | |
| 273 | - int level, | |
| 274 | - int raw, | |
| 275 | - int windowBits, | |
| 276 | - int memLevel, | |
| 277 | - int strategy, | |
| 278 | - const char* password, | |
| 279 | - uLong crcForCrypting, | |
| 280 | - uLong versionMadeBy, | |
| 281 | - uLong flagBase | |
| 282 | - )); | |
| 283 | - | |
| 284 | - | |
| 285 | -extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, | |
| 286 | - const char* filename, | |
| 287 | - const zip_fileinfo* zipfi, | |
| 288 | - const void* extrafield_local, | |
| 289 | - uInt size_extrafield_local, | |
| 290 | - const void* extrafield_global, | |
| 291 | - uInt size_extrafield_global, | |
| 292 | - const char* comment, | |
| 293 | - int method, | |
| 294 | - int level, | |
| 295 | - int raw, | |
| 296 | - int windowBits, | |
| 297 | - int memLevel, | |
| 298 | - int strategy, | |
| 299 | - const char* password, | |
| 300 | - uLong crcForCrypting, | |
| 301 | - uLong versionMadeBy, | |
| 302 | - uLong flagBase, | |
| 303 | - int zip64 | |
| 304 | - )); | |
| 263 | +extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, | |
| 264 | + const char* filename, | |
| 265 | + const zip_fileinfo* zipfi, | |
| 266 | + const void* extrafield_local, | |
| 267 | + uInt size_extrafield_local, | |
| 268 | + const void* extrafield_global, | |
| 269 | + uInt size_extrafield_global, | |
| 270 | + const char* comment, | |
| 271 | + int method, | |
| 272 | + int level, | |
| 273 | + int raw, | |
| 274 | + int windowBits, | |
| 275 | + int memLevel, | |
| 276 | + int strategy, | |
| 277 | + const char* password, | |
| 278 | + uLong crcForCrypting, | |
| 279 | + uLong versionMadeBy, | |
| 280 | + uLong flagBase); | |
| 281 | + | |
| 282 | + | |
| 283 | +extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, | |
| 284 | + const char* filename, | |
| 285 | + const zip_fileinfo* zipfi, | |
| 286 | + const void* extrafield_local, | |
| 287 | + uInt size_extrafield_local, | |
| 288 | + const void* extrafield_global, | |
| 289 | + uInt size_extrafield_global, | |
| 290 | + const char* comment, | |
| 291 | + int method, | |
| 292 | + int level, | |
| 293 | + int raw, | |
| 294 | + int windowBits, | |
| 295 | + int memLevel, | |
| 296 | + int strategy, | |
| 297 | + const char* password, | |
| 298 | + uLong crcForCrypting, | |
| 299 | + uLong versionMadeBy, | |
| 300 | + uLong flagBase, | |
| 301 | + int zip64); | |
| 305 | 302 | /* |
| 306 | 303 | Same than zipOpenNewFileInZip4, except |
| 307 | 304 | versionMadeBy : value for Version made by field |
| 308 | 305 | flag : value for flag field (compression level info will be added) |
| 309 | 306 | */ |
| 310 | 307 | |
| 311 | 308 | |
| 312 | -extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, | |
| 313 | - const void* buf, | |
| 314 | - unsigned len)); | |
| 309 | +extern int ZEXPORT zipWriteInFileInZip(zipFile file, | |
| 310 | + const void* buf, | |
| 311 | + unsigned len); | |
| 315 | 312 | /* |
| 316 | 313 | Write data in the zipfile |
| 317 | 314 | */ |
| 318 | 315 | |
| 319 | -extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); | |
| 316 | +extern int ZEXPORT zipCloseFileInZip(zipFile file); | |
| 320 | 317 | /* |
| 321 | 318 | Close the current file in the zipfile |
| 322 | 319 | */ |
| 323 | 320 | |
| 324 | -extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, | |
| 325 | - uLong uncompressed_size, | |
| 326 | - uLong crc32)); | |
| 321 | +extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, | |
| 322 | + uLong uncompressed_size, | |
| 323 | + uLong crc32); | |
| 327 | 324 | |
| 328 | -extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, | |
| 329 | - ZPOS64_T uncompressed_size, | |
| 330 | - uLong crc32)); | |
| 325 | +extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, | |
| 326 | + ZPOS64_T uncompressed_size, | |
| 327 | + uLong crc32); | |
| 331 | 328 | |
| 332 | 329 | /* |
| 333 | 330 | Close the current file in the zipfile, for file opened with |
| 334 | 331 | parameter raw=1 in zipOpenNewFileInZip2 |
| 335 | 332 | uncompressed_size and crc32 are value for the uncompressed size |
| 336 | 333 | */ |
| 337 | 334 | |
| 338 | -extern int ZEXPORT zipClose OF((zipFile file, | |
| 339 | - const char* global_comment)); | |
| 335 | +extern int ZEXPORT zipClose(zipFile file, | |
| 336 | + const char* global_comment); | |
| 340 | 337 | /* |
| 341 | 338 | Close the zipfile |
| 342 | 339 | */ |
| 343 | 340 | |
| 344 | 341 | |
| 345 | -extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader)); | |
| 342 | +extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader); | |
| 346 | 343 | /* |
| 347 | 344 | zipRemoveExtraInfoBlock - Added by Mathias Svensson |
| 348 | 345 | |
| 349 | 346 | Remove extra information block from a extra information data for the local file header or central directory header |
| 350 | 347 | |
| 351 | 348 |
| --- compat/zlib/contrib/minizip/zip.h | |
| +++ compat/zlib/contrib/minizip/zip.h | |
| @@ -111,12 +111,12 @@ | |
| 111 | |
| 112 | #define APPEND_STATUS_CREATE (0) |
| 113 | #define APPEND_STATUS_CREATEAFTER (1) |
| 114 | #define APPEND_STATUS_ADDINZIP (2) |
| 115 | |
| 116 | extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append)); |
| 117 | extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append)); |
| 118 | /* |
| 119 | Create a zipfile. |
| 120 | pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on |
| 121 | an Unix computer "zlib/zlib113.zip". |
| 122 | if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip |
| @@ -129,50 +129,50 @@ | |
| 129 | of this zip package. |
| 130 | */ |
| 131 | |
| 132 | /* Note : there is no delete function into a zipfile. |
| 133 | If you want delete file into a zipfile, you must open a zipfile, and create another |
| 134 | Of couse, you can use RAW reading and writing to copy the file you did not want delte |
| 135 | */ |
| 136 | |
| 137 | extern zipFile ZEXPORT zipOpen2 OF((const char *pathname, |
| 138 | int append, |
| 139 | zipcharpc* globalcomment, |
| 140 | zlib_filefunc_def* pzlib_filefunc_def)); |
| 141 | |
| 142 | extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname, |
| 143 | int append, |
| 144 | zipcharpc* globalcomment, |
| 145 | zlib_filefunc64_def* pzlib_filefunc_def)); |
| 146 | |
| 147 | extern zipFile ZEXPORT zipOpen3 OF((const void *pathname, |
| 148 | int append, |
| 149 | zipcharpc* globalcomment, |
| 150 | zlib_filefunc64_32_def* pzlib_filefunc64_32_def)); |
| 151 | |
| 152 | extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file, |
| 153 | const char* filename, |
| 154 | const zip_fileinfo* zipfi, |
| 155 | const void* extrafield_local, |
| 156 | uInt size_extrafield_local, |
| 157 | const void* extrafield_global, |
| 158 | uInt size_extrafield_global, |
| 159 | const char* comment, |
| 160 | int method, |
| 161 | int level)); |
| 162 | |
| 163 | extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file, |
| 164 | const char* filename, |
| 165 | const zip_fileinfo* zipfi, |
| 166 | const void* extrafield_local, |
| 167 | uInt size_extrafield_local, |
| 168 | const void* extrafield_global, |
| 169 | uInt size_extrafield_global, |
| 170 | const char* comment, |
| 171 | int method, |
| 172 | int level, |
| 173 | int zip64)); |
| 174 | |
| 175 | /* |
| 176 | Open a file in the ZIP for writing. |
| 177 | filename : the filename in zip (if NULL, '-' without quote will be used |
| 178 | *zipfi contain supplemental information |
| @@ -187,164 +187,161 @@ | |
| 187 | this MUST be '1' if the uncompressed size is >= 0xffffffff. |
| 188 | |
| 189 | */ |
| 190 | |
| 191 | |
| 192 | extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file, |
| 193 | const char* filename, |
| 194 | const zip_fileinfo* zipfi, |
| 195 | const void* extrafield_local, |
| 196 | uInt size_extrafield_local, |
| 197 | const void* extrafield_global, |
| 198 | uInt size_extrafield_global, |
| 199 | const char* comment, |
| 200 | int method, |
| 201 | int level, |
| 202 | int raw)); |
| 203 | |
| 204 | |
| 205 | extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file, |
| 206 | const char* filename, |
| 207 | const zip_fileinfo* zipfi, |
| 208 | const void* extrafield_local, |
| 209 | uInt size_extrafield_local, |
| 210 | const void* extrafield_global, |
| 211 | uInt size_extrafield_global, |
| 212 | const char* comment, |
| 213 | int method, |
| 214 | int level, |
| 215 | int raw, |
| 216 | int zip64)); |
| 217 | /* |
| 218 | Same than zipOpenNewFileInZip, except if raw=1, we write raw file |
| 219 | */ |
| 220 | |
| 221 | extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file, |
| 222 | const char* filename, |
| 223 | const zip_fileinfo* zipfi, |
| 224 | const void* extrafield_local, |
| 225 | uInt size_extrafield_local, |
| 226 | const void* extrafield_global, |
| 227 | uInt size_extrafield_global, |
| 228 | const char* comment, |
| 229 | int method, |
| 230 | int level, |
| 231 | int raw, |
| 232 | int windowBits, |
| 233 | int memLevel, |
| 234 | int strategy, |
| 235 | const char* password, |
| 236 | uLong crcForCrypting)); |
| 237 | |
| 238 | extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file, |
| 239 | const char* filename, |
| 240 | const zip_fileinfo* zipfi, |
| 241 | const void* extrafield_local, |
| 242 | uInt size_extrafield_local, |
| 243 | const void* extrafield_global, |
| 244 | uInt size_extrafield_global, |
| 245 | const char* comment, |
| 246 | int method, |
| 247 | int level, |
| 248 | int raw, |
| 249 | int windowBits, |
| 250 | int memLevel, |
| 251 | int strategy, |
| 252 | const char* password, |
| 253 | uLong crcForCrypting, |
| 254 | int zip64 |
| 255 | )); |
| 256 | |
| 257 | /* |
| 258 | Same than zipOpenNewFileInZip2, except |
| 259 | windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 |
| 260 | password : crypting password (NULL for no crypting) |
| 261 | crcForCrypting : crc of file to compress (needed for crypting) |
| 262 | */ |
| 263 | |
| 264 | extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file, |
| 265 | const char* filename, |
| 266 | const zip_fileinfo* zipfi, |
| 267 | const void* extrafield_local, |
| 268 | uInt size_extrafield_local, |
| 269 | const void* extrafield_global, |
| 270 | uInt size_extrafield_global, |
| 271 | const char* comment, |
| 272 | int method, |
| 273 | int level, |
| 274 | int raw, |
| 275 | int windowBits, |
| 276 | int memLevel, |
| 277 | int strategy, |
| 278 | const char* password, |
| 279 | uLong crcForCrypting, |
| 280 | uLong versionMadeBy, |
| 281 | uLong flagBase |
| 282 | )); |
| 283 | |
| 284 | |
| 285 | extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file, |
| 286 | const char* filename, |
| 287 | const zip_fileinfo* zipfi, |
| 288 | const void* extrafield_local, |
| 289 | uInt size_extrafield_local, |
| 290 | const void* extrafield_global, |
| 291 | uInt size_extrafield_global, |
| 292 | const char* comment, |
| 293 | int method, |
| 294 | int level, |
| 295 | int raw, |
| 296 | int windowBits, |
| 297 | int memLevel, |
| 298 | int strategy, |
| 299 | const char* password, |
| 300 | uLong crcForCrypting, |
| 301 | uLong versionMadeBy, |
| 302 | uLong flagBase, |
| 303 | int zip64 |
| 304 | )); |
| 305 | /* |
| 306 | Same than zipOpenNewFileInZip4, except |
| 307 | versionMadeBy : value for Version made by field |
| 308 | flag : value for flag field (compression level info will be added) |
| 309 | */ |
| 310 | |
| 311 | |
| 312 | extern int ZEXPORT zipWriteInFileInZip OF((zipFile file, |
| 313 | const void* buf, |
| 314 | unsigned len)); |
| 315 | /* |
| 316 | Write data in the zipfile |
| 317 | */ |
| 318 | |
| 319 | extern int ZEXPORT zipCloseFileInZip OF((zipFile file)); |
| 320 | /* |
| 321 | Close the current file in the zipfile |
| 322 | */ |
| 323 | |
| 324 | extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file, |
| 325 | uLong uncompressed_size, |
| 326 | uLong crc32)); |
| 327 | |
| 328 | extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file, |
| 329 | ZPOS64_T uncompressed_size, |
| 330 | uLong crc32)); |
| 331 | |
| 332 | /* |
| 333 | Close the current file in the zipfile, for file opened with |
| 334 | parameter raw=1 in zipOpenNewFileInZip2 |
| 335 | uncompressed_size and crc32 are value for the uncompressed size |
| 336 | */ |
| 337 | |
| 338 | extern int ZEXPORT zipClose OF((zipFile file, |
| 339 | const char* global_comment)); |
| 340 | /* |
| 341 | Close the zipfile |
| 342 | */ |
| 343 | |
| 344 | |
| 345 | extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader)); |
| 346 | /* |
| 347 | zipRemoveExtraInfoBlock - Added by Mathias Svensson |
| 348 | |
| 349 | Remove extra information block from a extra information data for the local file header or central directory header |
| 350 | |
| 351 |
| --- compat/zlib/contrib/minizip/zip.h | |
| +++ compat/zlib/contrib/minizip/zip.h | |
| @@ -111,12 +111,12 @@ | |
| 111 | |
| 112 | #define APPEND_STATUS_CREATE (0) |
| 113 | #define APPEND_STATUS_CREATEAFTER (1) |
| 114 | #define APPEND_STATUS_ADDINZIP (2) |
| 115 | |
| 116 | extern zipFile ZEXPORT zipOpen(const char *pathname, int append); |
| 117 | extern zipFile ZEXPORT zipOpen64(const void *pathname, int append); |
| 118 | /* |
| 119 | Create a zipfile. |
| 120 | pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on |
| 121 | an Unix computer "zlib/zlib113.zip". |
| 122 | if the file pathname exist and append==APPEND_STATUS_CREATEAFTER, the zip |
| @@ -129,50 +129,50 @@ | |
| 129 | of this zip package. |
| 130 | */ |
| 131 | |
| 132 | /* Note : there is no delete function into a zipfile. |
| 133 | If you want delete file into a zipfile, you must open a zipfile, and create another |
| 134 | Of course, you can use RAW reading and writing to copy the file you did not want delete |
| 135 | */ |
| 136 | |
| 137 | extern zipFile ZEXPORT zipOpen2(const char *pathname, |
| 138 | int append, |
| 139 | zipcharpc* globalcomment, |
| 140 | zlib_filefunc_def* pzlib_filefunc_def); |
| 141 | |
| 142 | extern zipFile ZEXPORT zipOpen2_64(const void *pathname, |
| 143 | int append, |
| 144 | zipcharpc* globalcomment, |
| 145 | zlib_filefunc64_def* pzlib_filefunc_def); |
| 146 | |
| 147 | extern zipFile ZEXPORT zipOpen3(const void *pathname, |
| 148 | int append, |
| 149 | zipcharpc* globalcomment, |
| 150 | zlib_filefunc64_32_def* pzlib_filefunc64_32_def); |
| 151 | |
| 152 | extern int ZEXPORT zipOpenNewFileInZip(zipFile file, |
| 153 | const char* filename, |
| 154 | const zip_fileinfo* zipfi, |
| 155 | const void* extrafield_local, |
| 156 | uInt size_extrafield_local, |
| 157 | const void* extrafield_global, |
| 158 | uInt size_extrafield_global, |
| 159 | const char* comment, |
| 160 | int method, |
| 161 | int level); |
| 162 | |
| 163 | extern int ZEXPORT zipOpenNewFileInZip64(zipFile file, |
| 164 | const char* filename, |
| 165 | const zip_fileinfo* zipfi, |
| 166 | const void* extrafield_local, |
| 167 | uInt size_extrafield_local, |
| 168 | const void* extrafield_global, |
| 169 | uInt size_extrafield_global, |
| 170 | const char* comment, |
| 171 | int method, |
| 172 | int level, |
| 173 | int zip64); |
| 174 | |
| 175 | /* |
| 176 | Open a file in the ZIP for writing. |
| 177 | filename : the filename in zip (if NULL, '-' without quote will be used |
| 178 | *zipfi contain supplemental information |
| @@ -187,164 +187,161 @@ | |
| 187 | this MUST be '1' if the uncompressed size is >= 0xffffffff. |
| 188 | |
| 189 | */ |
| 190 | |
| 191 | |
| 192 | extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, |
| 193 | const char* filename, |
| 194 | const zip_fileinfo* zipfi, |
| 195 | const void* extrafield_local, |
| 196 | uInt size_extrafield_local, |
| 197 | const void* extrafield_global, |
| 198 | uInt size_extrafield_global, |
| 199 | const char* comment, |
| 200 | int method, |
| 201 | int level, |
| 202 | int raw); |
| 203 | |
| 204 | |
| 205 | extern int ZEXPORT zipOpenNewFileInZip2_64(zipFile file, |
| 206 | const char* filename, |
| 207 | const zip_fileinfo* zipfi, |
| 208 | const void* extrafield_local, |
| 209 | uInt size_extrafield_local, |
| 210 | const void* extrafield_global, |
| 211 | uInt size_extrafield_global, |
| 212 | const char* comment, |
| 213 | int method, |
| 214 | int level, |
| 215 | int raw, |
| 216 | int zip64); |
| 217 | /* |
| 218 | Same than zipOpenNewFileInZip, except if raw=1, we write raw file |
| 219 | */ |
| 220 | |
| 221 | extern int ZEXPORT zipOpenNewFileInZip3(zipFile file, |
| 222 | const char* filename, |
| 223 | const zip_fileinfo* zipfi, |
| 224 | const void* extrafield_local, |
| 225 | uInt size_extrafield_local, |
| 226 | const void* extrafield_global, |
| 227 | uInt size_extrafield_global, |
| 228 | const char* comment, |
| 229 | int method, |
| 230 | int level, |
| 231 | int raw, |
| 232 | int windowBits, |
| 233 | int memLevel, |
| 234 | int strategy, |
| 235 | const char* password, |
| 236 | uLong crcForCrypting); |
| 237 | |
| 238 | extern int ZEXPORT zipOpenNewFileInZip3_64(zipFile file, |
| 239 | const char* filename, |
| 240 | const zip_fileinfo* zipfi, |
| 241 | const void* extrafield_local, |
| 242 | uInt size_extrafield_local, |
| 243 | const void* extrafield_global, |
| 244 | uInt size_extrafield_global, |
| 245 | const char* comment, |
| 246 | int method, |
| 247 | int level, |
| 248 | int raw, |
| 249 | int windowBits, |
| 250 | int memLevel, |
| 251 | int strategy, |
| 252 | const char* password, |
| 253 | uLong crcForCrypting, |
| 254 | int zip64); |
| 255 | |
| 256 | /* |
| 257 | Same than zipOpenNewFileInZip2, except |
| 258 | windowBits,memLevel,,strategy : see parameter strategy in deflateInit2 |
| 259 | password : crypting password (NULL for no crypting) |
| 260 | crcForCrypting : crc of file to compress (needed for crypting) |
| 261 | */ |
| 262 | |
| 263 | extern int ZEXPORT zipOpenNewFileInZip4(zipFile file, |
| 264 | const char* filename, |
| 265 | const zip_fileinfo* zipfi, |
| 266 | const void* extrafield_local, |
| 267 | uInt size_extrafield_local, |
| 268 | const void* extrafield_global, |
| 269 | uInt size_extrafield_global, |
| 270 | const char* comment, |
| 271 | int method, |
| 272 | int level, |
| 273 | int raw, |
| 274 | int windowBits, |
| 275 | int memLevel, |
| 276 | int strategy, |
| 277 | const char* password, |
| 278 | uLong crcForCrypting, |
| 279 | uLong versionMadeBy, |
| 280 | uLong flagBase); |
| 281 | |
| 282 | |
| 283 | extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, |
| 284 | const char* filename, |
| 285 | const zip_fileinfo* zipfi, |
| 286 | const void* extrafield_local, |
| 287 | uInt size_extrafield_local, |
| 288 | const void* extrafield_global, |
| 289 | uInt size_extrafield_global, |
| 290 | const char* comment, |
| 291 | int method, |
| 292 | int level, |
| 293 | int raw, |
| 294 | int windowBits, |
| 295 | int memLevel, |
| 296 | int strategy, |
| 297 | const char* password, |
| 298 | uLong crcForCrypting, |
| 299 | uLong versionMadeBy, |
| 300 | uLong flagBase, |
| 301 | int zip64); |
| 302 | /* |
| 303 | Same than zipOpenNewFileInZip4, except |
| 304 | versionMadeBy : value for Version made by field |
| 305 | flag : value for flag field (compression level info will be added) |
| 306 | */ |
| 307 | |
| 308 | |
| 309 | extern int ZEXPORT zipWriteInFileInZip(zipFile file, |
| 310 | const void* buf, |
| 311 | unsigned len); |
| 312 | /* |
| 313 | Write data in the zipfile |
| 314 | */ |
| 315 | |
| 316 | extern int ZEXPORT zipCloseFileInZip(zipFile file); |
| 317 | /* |
| 318 | Close the current file in the zipfile |
| 319 | */ |
| 320 | |
| 321 | extern int ZEXPORT zipCloseFileInZipRaw(zipFile file, |
| 322 | uLong uncompressed_size, |
| 323 | uLong crc32); |
| 324 | |
| 325 | extern int ZEXPORT zipCloseFileInZipRaw64(zipFile file, |
| 326 | ZPOS64_T uncompressed_size, |
| 327 | uLong crc32); |
| 328 | |
| 329 | /* |
| 330 | Close the current file in the zipfile, for file opened with |
| 331 | parameter raw=1 in zipOpenNewFileInZip2 |
| 332 | uncompressed_size and crc32 are value for the uncompressed size |
| 333 | */ |
| 334 | |
| 335 | extern int ZEXPORT zipClose(zipFile file, |
| 336 | const char* global_comment); |
| 337 | /* |
| 338 | Close the zipfile |
| 339 | */ |
| 340 | |
| 341 | |
| 342 | extern int ZEXPORT zipRemoveExtraInfoBlock(char* pData, int* dataLen, short sHeader); |
| 343 | /* |
| 344 | zipRemoveExtraInfoBlock - Added by Mathias Svensson |
| 345 | |
| 346 | Remove extra information block from a extra information data for the local file header or central directory header |
| 347 | |
| 348 |
| --- compat/zlib/contrib/pascal/zlibpas.pas | ||
| +++ compat/zlib/contrib/pascal/zlibpas.pas | ||
| @@ -8,11 +8,11 @@ | ||
| 8 | 8 | unit zlibpas; |
| 9 | 9 | |
| 10 | 10 | interface |
| 11 | 11 | |
| 12 | 12 | const |
| 13 | - ZLIB_VERSION = '1.2.13'; | |
| 13 | + ZLIB_VERSION = '1.3.0'; | |
| 14 | 14 | ZLIB_VERNUM = $12a0; |
| 15 | 15 | |
| 16 | 16 | type |
| 17 | 17 | alloc_func = function(opaque: Pointer; items, size: Integer): Pointer; |
| 18 | 18 | cdecl; |
| 19 | 19 |
| --- compat/zlib/contrib/pascal/zlibpas.pas | |
| +++ compat/zlib/contrib/pascal/zlibpas.pas | |
| @@ -8,11 +8,11 @@ | |
| 8 | unit zlibpas; |
| 9 | |
| 10 | interface |
| 11 | |
| 12 | const |
| 13 | ZLIB_VERSION = '1.2.13'; |
| 14 | ZLIB_VERNUM = $12a0; |
| 15 | |
| 16 | type |
| 17 | alloc_func = function(opaque: Pointer; items, size: Integer): Pointer; |
| 18 | cdecl; |
| 19 |
| --- compat/zlib/contrib/pascal/zlibpas.pas | |
| +++ compat/zlib/contrib/pascal/zlibpas.pas | |
| @@ -8,11 +8,11 @@ | |
| 8 | unit zlibpas; |
| 9 | |
| 10 | interface |
| 11 | |
| 12 | const |
| 13 | ZLIB_VERSION = '1.3.0'; |
| 14 | ZLIB_VERNUM = $12a0; |
| 15 | |
| 16 | type |
| 17 | alloc_func = function(opaque: Pointer; items, size: Integer): Pointer; |
| 18 | cdecl; |
| 19 |
| --- compat/zlib/contrib/testzlib/testzlib.c | ||
| +++ compat/zlib/contrib/testzlib/testzlib.c | ||
| @@ -167,11 +167,11 @@ | ||
| 167 | 167 | if (ReadFileMemory(argv[1],&lFileSize,&FilePtr)==0) |
| 168 | 168 | { |
| 169 | 169 | printf("error reading %s\n",argv[1]); |
| 170 | 170 | return 1; |
| 171 | 171 | } |
| 172 | - else printf("file %s read, %u bytes\n",argv[1],lFileSize); | |
| 172 | + else printf("file %s read, %ld bytes\n",argv[1],lFileSize); | |
| 173 | 173 | |
| 174 | 174 | if (argc>=3) |
| 175 | 175 | BlockSizeCompress=atol(argv[2]); |
| 176 | 176 | |
| 177 | 177 | if (argc>=4) |
| 178 | 178 |
| --- compat/zlib/contrib/testzlib/testzlib.c | |
| +++ compat/zlib/contrib/testzlib/testzlib.c | |
| @@ -167,11 +167,11 @@ | |
| 167 | if (ReadFileMemory(argv[1],&lFileSize,&FilePtr)==0) |
| 168 | { |
| 169 | printf("error reading %s\n",argv[1]); |
| 170 | return 1; |
| 171 | } |
| 172 | else printf("file %s read, %u bytes\n",argv[1],lFileSize); |
| 173 | |
| 174 | if (argc>=3) |
| 175 | BlockSizeCompress=atol(argv[2]); |
| 176 | |
| 177 | if (argc>=4) |
| 178 |
| --- compat/zlib/contrib/testzlib/testzlib.c | |
| +++ compat/zlib/contrib/testzlib/testzlib.c | |
| @@ -167,11 +167,11 @@ | |
| 167 | if (ReadFileMemory(argv[1],&lFileSize,&FilePtr)==0) |
| 168 | { |
| 169 | printf("error reading %s\n",argv[1]); |
| 170 | return 1; |
| 171 | } |
| 172 | else printf("file %s read, %ld bytes\n",argv[1],lFileSize); |
| 173 | |
| 174 | if (argc>=3) |
| 175 | BlockSizeCompress=atol(argv[2]); |
| 176 | |
| 177 | if (argc>=4) |
| 178 |
+28
-35
| --- compat/zlib/contrib/untgz/untgz.c | ||
| +++ compat/zlib/contrib/untgz/untgz.c | ||
| @@ -2,10 +2,26 @@ | ||
| 2 | 2 | * untgz.c -- Display contents and extract files from a gzip'd TAR file |
| 3 | 3 | * |
| 4 | 4 | * written by Pedro A. Aranda Gutierrez <[email protected]> |
| 5 | 5 | * adaptation to Unix by Jean-loup Gailly <[email protected]> |
| 6 | 6 | * various fixes by Cosmin Truta <[email protected]> |
| 7 | + * | |
| 8 | + * This software is provided 'as-is', without any express or implied | |
| 9 | + * warranty. In no event will the authors be held liable for any damages | |
| 10 | + * arising from the use of this software. | |
| 11 | + * | |
| 12 | + * Permission is granted to anyone to use this software for any purpose, | |
| 13 | + * including commercial applications, and to alter it and redistribute it | |
| 14 | + * freely, subject to the following restrictions: | |
| 15 | + * | |
| 16 | + * 1. The origin of this software must not be misrepresented; you must not | |
| 17 | + * claim that you wrote the original software. If you use this software | |
| 18 | + * in a product, an acknowledgment in the product documentation would be | |
| 19 | + * appreciated but is not required. | |
| 20 | + * 2. Altered source versions must be plainly marked as such, and must not be | |
| 21 | + * misrepresented as being the original software. | |
| 22 | + * 3. This notice may not be removed or altered from any source distribution. | |
| 7 | 23 | */ |
| 8 | 24 | |
| 9 | 25 | #include <stdio.h> |
| 10 | 26 | #include <stdlib.h> |
| 11 | 27 | #include <string.h> |
| @@ -12,19 +28,14 @@ | ||
| 12 | 28 | #include <time.h> |
| 13 | 29 | #include <errno.h> |
| 14 | 30 | |
| 15 | 31 | #include "zlib.h" |
| 16 | 32 | |
| 17 | -#ifdef unix | |
| 18 | -# include <unistd.h> | |
| 19 | -#else | |
| 33 | +#ifdef _WIN32 | |
| 20 | 34 | # include <direct.h> |
| 21 | 35 | # include <io.h> |
| 22 | -#endif | |
| 23 | - | |
| 24 | -#ifdef WIN32 | |
| 25 | -#include <windows.h> | |
| 36 | +# include <windows.h> | |
| 26 | 37 | # ifndef F_OK |
| 27 | 38 | # define F_OK 0 |
| 28 | 39 | # endif |
| 29 | 40 | # define mkdir(dirname,mode) _mkdir(dirname) |
| 30 | 41 | # ifdef _MSC_VER |
| @@ -31,10 +42,12 @@ | ||
| 31 | 42 | # define access(path,mode) _access(path,mode) |
| 32 | 43 | # define chmod(path,mode) _chmod(path,mode) |
| 33 | 44 | # define strdup(str) _strdup(str) |
| 34 | 45 | # endif |
| 35 | 46 | #else |
| 47 | +# include <sys/stat.h> | |
| 48 | +# include <unistd.h> | |
| 36 | 49 | # include <utime.h> |
| 37 | 50 | #endif |
| 38 | 51 | |
| 39 | 52 | |
| 40 | 53 | /* values used in typeflag field */ |
| @@ -100,31 +113,17 @@ | ||
| 100 | 113 | time_t time; |
| 101 | 114 | }; |
| 102 | 115 | |
| 103 | 116 | enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID }; |
| 104 | 117 | |
| 105 | -char *TGZfname OF((const char *)); | |
| 106 | -void TGZnotfound OF((const char *)); | |
| 107 | - | |
| 108 | -int getoct OF((char *, int)); | |
| 109 | -char *strtime OF((time_t *)); | |
| 110 | -int setfiletime OF((char *, time_t)); | |
| 111 | -void push_attr OF((struct attr_item **, char *, int, time_t)); | |
| 112 | -void restore_attr OF((struct attr_item **)); | |
| 113 | - | |
| 114 | -int ExprMatch OF((char *, char *)); | |
| 115 | - | |
| 116 | -int makedir OF((char *)); | |
| 117 | -int matchname OF((int, int, char **, char *)); | |
| 118 | - | |
| 119 | -void error OF((const char *)); | |
| 120 | -int tar OF((gzFile, int, int, int, char **)); | |
| 121 | - | |
| 122 | -void help OF((int)); | |
| 123 | -int main OF((int, char **)); | |
| 124 | - | |
| 125 | 118 | char *prog; |
| 119 | + | |
| 120 | +void error(const char *msg) | |
| 121 | +{ | |
| 122 | + fprintf(stderr, "%s: %s\n", prog, msg); | |
| 123 | + exit(1); | |
| 124 | +} | |
| 126 | 125 | |
| 127 | 126 | const char *TGZsuffix[] = { "\0", ".tar", ".tar.gz", ".taz", ".tgz", NULL }; |
| 128 | 127 | |
| 129 | 128 | /* return the file name of the TGZ archive */ |
| 130 | 129 | /* or NULL if it does not exist */ |
| @@ -203,11 +202,11 @@ | ||
| 203 | 202 | |
| 204 | 203 | /* set file time */ |
| 205 | 204 | |
| 206 | 205 | int setfiletime (char *fname,time_t ftime) |
| 207 | 206 | { |
| 208 | -#ifdef WIN32 | |
| 207 | +#ifdef _WIN32 | |
| 209 | 208 | static int isWinNT = -1; |
| 210 | 209 | SYSTEMTIME st; |
| 211 | 210 | FILETIME locft, modft; |
| 212 | 211 | struct tm *loctm; |
| 213 | 212 | HANDLE hFile; |
| @@ -588,16 +587,10 @@ | ||
| 588 | 587 | " untgz -l file.tgz list archive contents\n" |
| 589 | 588 | " untgz -h display this help\n"); |
| 590 | 589 | exit(exitval); |
| 591 | 590 | } |
| 592 | 591 | |
| 593 | -void error(const char *msg) | |
| 594 | -{ | |
| 595 | - fprintf(stderr, "%s: %s\n", prog, msg); | |
| 596 | - exit(1); | |
| 597 | -} | |
| 598 | - | |
| 599 | 592 | |
| 600 | 593 | /* ============================================================ */ |
| 601 | 594 | |
| 602 | 595 | #if defined(WIN32) && defined(__GNUC__) |
| 603 | 596 | int _CRT_glob = 0; /* disable argument globbing in MinGW */ |
| @@ -606,11 +599,11 @@ | ||
| 606 | 599 | int main(int argc,char **argv) |
| 607 | 600 | { |
| 608 | 601 | int action = TGZ_EXTRACT; |
| 609 | 602 | int arg = 1; |
| 610 | 603 | char *TGZfile; |
| 611 | - gzFile *f; | |
| 604 | + gzFile f; | |
| 612 | 605 | |
| 613 | 606 | prog = strrchr(argv[0],'\\'); |
| 614 | 607 | if (prog == NULL) |
| 615 | 608 | { |
| 616 | 609 | prog = strrchr(argv[0],'/'); |
| 617 | 610 |
| --- compat/zlib/contrib/untgz/untgz.c | |
| +++ compat/zlib/contrib/untgz/untgz.c | |
| @@ -2,10 +2,26 @@ | |
| 2 | * untgz.c -- Display contents and extract files from a gzip'd TAR file |
| 3 | * |
| 4 | * written by Pedro A. Aranda Gutierrez <[email protected]> |
| 5 | * adaptation to Unix by Jean-loup Gailly <[email protected]> |
| 6 | * various fixes by Cosmin Truta <[email protected]> |
| 7 | */ |
| 8 | |
| 9 | #include <stdio.h> |
| 10 | #include <stdlib.h> |
| 11 | #include <string.h> |
| @@ -12,19 +28,14 @@ | |
| 12 | #include <time.h> |
| 13 | #include <errno.h> |
| 14 | |
| 15 | #include "zlib.h" |
| 16 | |
| 17 | #ifdef unix |
| 18 | # include <unistd.h> |
| 19 | #else |
| 20 | # include <direct.h> |
| 21 | # include <io.h> |
| 22 | #endif |
| 23 | |
| 24 | #ifdef WIN32 |
| 25 | #include <windows.h> |
| 26 | # ifndef F_OK |
| 27 | # define F_OK 0 |
| 28 | # endif |
| 29 | # define mkdir(dirname,mode) _mkdir(dirname) |
| 30 | # ifdef _MSC_VER |
| @@ -31,10 +42,12 @@ | |
| 31 | # define access(path,mode) _access(path,mode) |
| 32 | # define chmod(path,mode) _chmod(path,mode) |
| 33 | # define strdup(str) _strdup(str) |
| 34 | # endif |
| 35 | #else |
| 36 | # include <utime.h> |
| 37 | #endif |
| 38 | |
| 39 | |
| 40 | /* values used in typeflag field */ |
| @@ -100,31 +113,17 @@ | |
| 100 | time_t time; |
| 101 | }; |
| 102 | |
| 103 | enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID }; |
| 104 | |
| 105 | char *TGZfname OF((const char *)); |
| 106 | void TGZnotfound OF((const char *)); |
| 107 | |
| 108 | int getoct OF((char *, int)); |
| 109 | char *strtime OF((time_t *)); |
| 110 | int setfiletime OF((char *, time_t)); |
| 111 | void push_attr OF((struct attr_item **, char *, int, time_t)); |
| 112 | void restore_attr OF((struct attr_item **)); |
| 113 | |
| 114 | int ExprMatch OF((char *, char *)); |
| 115 | |
| 116 | int makedir OF((char *)); |
| 117 | int matchname OF((int, int, char **, char *)); |
| 118 | |
| 119 | void error OF((const char *)); |
| 120 | int tar OF((gzFile, int, int, int, char **)); |
| 121 | |
| 122 | void help OF((int)); |
| 123 | int main OF((int, char **)); |
| 124 | |
| 125 | char *prog; |
| 126 | |
| 127 | const char *TGZsuffix[] = { "\0", ".tar", ".tar.gz", ".taz", ".tgz", NULL }; |
| 128 | |
| 129 | /* return the file name of the TGZ archive */ |
| 130 | /* or NULL if it does not exist */ |
| @@ -203,11 +202,11 @@ | |
| 203 | |
| 204 | /* set file time */ |
| 205 | |
| 206 | int setfiletime (char *fname,time_t ftime) |
| 207 | { |
| 208 | #ifdef WIN32 |
| 209 | static int isWinNT = -1; |
| 210 | SYSTEMTIME st; |
| 211 | FILETIME locft, modft; |
| 212 | struct tm *loctm; |
| 213 | HANDLE hFile; |
| @@ -588,16 +587,10 @@ | |
| 588 | " untgz -l file.tgz list archive contents\n" |
| 589 | " untgz -h display this help\n"); |
| 590 | exit(exitval); |
| 591 | } |
| 592 | |
| 593 | void error(const char *msg) |
| 594 | { |
| 595 | fprintf(stderr, "%s: %s\n", prog, msg); |
| 596 | exit(1); |
| 597 | } |
| 598 | |
| 599 | |
| 600 | /* ============================================================ */ |
| 601 | |
| 602 | #if defined(WIN32) && defined(__GNUC__) |
| 603 | int _CRT_glob = 0; /* disable argument globbing in MinGW */ |
| @@ -606,11 +599,11 @@ | |
| 606 | int main(int argc,char **argv) |
| 607 | { |
| 608 | int action = TGZ_EXTRACT; |
| 609 | int arg = 1; |
| 610 | char *TGZfile; |
| 611 | gzFile *f; |
| 612 | |
| 613 | prog = strrchr(argv[0],'\\'); |
| 614 | if (prog == NULL) |
| 615 | { |
| 616 | prog = strrchr(argv[0],'/'); |
| 617 |
| --- compat/zlib/contrib/untgz/untgz.c | |
| +++ compat/zlib/contrib/untgz/untgz.c | |
| @@ -2,10 +2,26 @@ | |
| 2 | * untgz.c -- Display contents and extract files from a gzip'd TAR file |
| 3 | * |
| 4 | * written by Pedro A. Aranda Gutierrez <[email protected]> |
| 5 | * adaptation to Unix by Jean-loup Gailly <[email protected]> |
| 6 | * various fixes by Cosmin Truta <[email protected]> |
| 7 | * |
| 8 | * This software is provided 'as-is', without any express or implied |
| 9 | * warranty. In no event will the authors be held liable for any damages |
| 10 | * arising from the use of this software. |
| 11 | * |
| 12 | * Permission is granted to anyone to use this software for any purpose, |
| 13 | * including commercial applications, and to alter it and redistribute it |
| 14 | * freely, subject to the following restrictions: |
| 15 | * |
| 16 | * 1. The origin of this software must not be misrepresented; you must not |
| 17 | * claim that you wrote the original software. If you use this software |
| 18 | * in a product, an acknowledgment in the product documentation would be |
| 19 | * appreciated but is not required. |
| 20 | * 2. Altered source versions must be plainly marked as such, and must not be |
| 21 | * misrepresented as being the original software. |
| 22 | * 3. This notice may not be removed or altered from any source distribution. |
| 23 | */ |
| 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <stdlib.h> |
| 27 | #include <string.h> |
| @@ -12,19 +28,14 @@ | |
| 28 | #include <time.h> |
| 29 | #include <errno.h> |
| 30 | |
| 31 | #include "zlib.h" |
| 32 | |
| 33 | #ifdef _WIN32 |
| 34 | # include <direct.h> |
| 35 | # include <io.h> |
| 36 | # include <windows.h> |
| 37 | # ifndef F_OK |
| 38 | # define F_OK 0 |
| 39 | # endif |
| 40 | # define mkdir(dirname,mode) _mkdir(dirname) |
| 41 | # ifdef _MSC_VER |
| @@ -31,10 +42,12 @@ | |
| 42 | # define access(path,mode) _access(path,mode) |
| 43 | # define chmod(path,mode) _chmod(path,mode) |
| 44 | # define strdup(str) _strdup(str) |
| 45 | # endif |
| 46 | #else |
| 47 | # include <sys/stat.h> |
| 48 | # include <unistd.h> |
| 49 | # include <utime.h> |
| 50 | #endif |
| 51 | |
| 52 | |
| 53 | /* values used in typeflag field */ |
| @@ -100,31 +113,17 @@ | |
| 113 | time_t time; |
| 114 | }; |
| 115 | |
| 116 | enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID }; |
| 117 | |
| 118 | char *prog; |
| 119 | |
| 120 | void error(const char *msg) |
| 121 | { |
| 122 | fprintf(stderr, "%s: %s\n", prog, msg); |
| 123 | exit(1); |
| 124 | } |
| 125 | |
| 126 | const char *TGZsuffix[] = { "\0", ".tar", ".tar.gz", ".taz", ".tgz", NULL }; |
| 127 | |
| 128 | /* return the file name of the TGZ archive */ |
| 129 | /* or NULL if it does not exist */ |
| @@ -203,11 +202,11 @@ | |
| 202 | |
| 203 | /* set file time */ |
| 204 | |
| 205 | int setfiletime (char *fname,time_t ftime) |
| 206 | { |
| 207 | #ifdef _WIN32 |
| 208 | static int isWinNT = -1; |
| 209 | SYSTEMTIME st; |
| 210 | FILETIME locft, modft; |
| 211 | struct tm *loctm; |
| 212 | HANDLE hFile; |
| @@ -588,16 +587,10 @@ | |
| 587 | " untgz -l file.tgz list archive contents\n" |
| 588 | " untgz -h display this help\n"); |
| 589 | exit(exitval); |
| 590 | } |
| 591 | |
| 592 | |
| 593 | /* ============================================================ */ |
| 594 | |
| 595 | #if defined(WIN32) && defined(__GNUC__) |
| 596 | int _CRT_glob = 0; /* disable argument globbing in MinGW */ |
| @@ -606,11 +599,11 @@ | |
| 599 | int main(int argc,char **argv) |
| 600 | { |
| 601 | int action = TGZ_EXTRACT; |
| 602 | int arg = 1; |
| 603 | char *TGZfile; |
| 604 | gzFile f; |
| 605 | |
| 606 | prog = strrchr(argv[0],'\\'); |
| 607 | if (prog == NULL) |
| 608 | { |
| 609 | prog = strrchr(argv[0],'/'); |
| 610 |
| --- compat/zlib/contrib/vstudio/readme.txt | ||
| +++ compat/zlib/contrib/vstudio/readme.txt | ||
| @@ -1,6 +1,6 @@ | ||
| 1 | -Building instructions for the DLL versions of Zlib 1.2.13 | |
| 1 | +Building instructions for the DLL versions of Zlib 1.3.0 | |
| 2 | 2 | ======================================================== |
| 3 | 3 | |
| 4 | 4 | This directory contains projects that build zlib and minizip using |
| 5 | 5 | Microsoft Visual C++ 9.0/10.0. |
| 6 | 6 | |
| 7 | 7 |
| --- compat/zlib/contrib/vstudio/readme.txt | |
| +++ compat/zlib/contrib/vstudio/readme.txt | |
| @@ -1,6 +1,6 @@ | |
| 1 | Building instructions for the DLL versions of Zlib 1.2.13 |
| 2 | ======================================================== |
| 3 | |
| 4 | This directory contains projects that build zlib and minizip using |
| 5 | Microsoft Visual C++ 9.0/10.0. |
| 6 | |
| 7 |
| --- compat/zlib/contrib/vstudio/readme.txt | |
| +++ compat/zlib/contrib/vstudio/readme.txt | |
| @@ -1,6 +1,6 @@ | |
| 1 | Building instructions for the DLL versions of Zlib 1.3.0 |
| 2 | ======================================================== |
| 3 | |
| 4 | This directory contains projects that build zlib and minizip using |
| 5 | Microsoft Visual C++ 9.0/10.0. |
| 6 | |
| 7 |
| --- compat/zlib/contrib/vstudio/vc10/zlib.rc | ||
| +++ compat/zlib/contrib/vstudio/vc10/zlib.rc | ||
| @@ -1,11 +1,11 @@ | ||
| 1 | 1 | #include <windows.h> |
| 2 | 2 | |
| 3 | 3 | #define IDR_VERSION1 1 |
| 4 | 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | - FILEVERSION 1, 2, 13, 0 | |
| 6 | - PRODUCTVERSION 1, 2, 13, 0 | |
| 5 | + FILEVERSION 1, 3, 0, 0 | |
| 6 | + PRODUCTVERSION 1, 3, 0, 0 | |
| 7 | 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | 8 | FILEFLAGS 0 |
| 9 | 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | 10 | FILETYPE VFT_DLL |
| 11 | 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | ||
| 15 | 15 | BLOCK "040904E4" |
| 16 | 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | 17 | |
| 18 | 18 | BEGIN |
| 19 | 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | - VALUE "FileVersion", "1.2.13\0" | |
| 20 | + VALUE "FileVersion", "1.3.0\0" | |
| 21 | 21 | VALUE "InternalName", "zlib\0" |
| 22 | 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | - VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" | |
| 25 | + VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" | |
| 26 | 26 | END |
| 27 | 27 | END |
| 28 | 28 | BLOCK "VarFileInfo" |
| 29 | 29 | BEGIN |
| 30 | 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | 31 | END |
| 32 | 32 | END |
| 33 | 33 |
| --- compat/zlib/contrib/vstudio/vc10/zlib.rc | |
| +++ compat/zlib/contrib/vstudio/vc10/zlib.rc | |
| @@ -1,11 +1,11 @@ | |
| 1 | #include <windows.h> |
| 2 | |
| 3 | #define IDR_VERSION1 1 |
| 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | FILEVERSION 1, 2, 13, 0 |
| 6 | PRODUCTVERSION 1, 2, 13, 0 |
| 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | FILEFLAGS 0 |
| 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | FILETYPE VFT_DLL |
| 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | |
| 15 | BLOCK "040904E4" |
| 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | |
| 18 | BEGIN |
| 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | VALUE "FileVersion", "1.2.13\0" |
| 21 | VALUE "InternalName", "zlib\0" |
| 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" |
| 26 | END |
| 27 | END |
| 28 | BLOCK "VarFileInfo" |
| 29 | BEGIN |
| 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | END |
| 32 | END |
| 33 |
| --- compat/zlib/contrib/vstudio/vc10/zlib.rc | |
| +++ compat/zlib/contrib/vstudio/vc10/zlib.rc | |
| @@ -1,11 +1,11 @@ | |
| 1 | #include <windows.h> |
| 2 | |
| 3 | #define IDR_VERSION1 1 |
| 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | FILEVERSION 1, 3, 0, 0 |
| 6 | PRODUCTVERSION 1, 3, 0, 0 |
| 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | FILEFLAGS 0 |
| 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | FILETYPE VFT_DLL |
| 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | |
| 15 | BLOCK "040904E4" |
| 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | |
| 18 | BEGIN |
| 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | VALUE "FileVersion", "1.3.0\0" |
| 21 | VALUE "InternalName", "zlib\0" |
| 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" |
| 26 | END |
| 27 | END |
| 28 | BLOCK "VarFileInfo" |
| 29 | BEGIN |
| 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | END |
| 32 | END |
| 33 |
| --- compat/zlib/contrib/vstudio/vc10/zlibvc.def | ||
| +++ compat/zlib/contrib/vstudio/vc10/zlibvc.def | ||
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | LIBRARY |
| 2 | 2 | ; zlib data compression and ZIP file I/O library |
| 3 | 3 | |
| 4 | -VERSION 1.2 | |
| 4 | +VERSION 1.3 | |
| 5 | 5 | |
| 6 | 6 | EXPORTS |
| 7 | 7 | adler32 @1 |
| 8 | 8 | compress @2 |
| 9 | 9 | crc32 @3 |
| 10 | 10 |
| --- compat/zlib/contrib/vstudio/vc10/zlibvc.def | |
| +++ compat/zlib/contrib/vstudio/vc10/zlibvc.def | |
| @@ -1,9 +1,9 @@ | |
| 1 | LIBRARY |
| 2 | ; zlib data compression and ZIP file I/O library |
| 3 | |
| 4 | VERSION 1.2 |
| 5 | |
| 6 | EXPORTS |
| 7 | adler32 @1 |
| 8 | compress @2 |
| 9 | crc32 @3 |
| 10 |
| --- compat/zlib/contrib/vstudio/vc10/zlibvc.def | |
| +++ compat/zlib/contrib/vstudio/vc10/zlibvc.def | |
| @@ -1,9 +1,9 @@ | |
| 1 | LIBRARY |
| 2 | ; zlib data compression and ZIP file I/O library |
| 3 | |
| 4 | VERSION 1.3 |
| 5 | |
| 6 | EXPORTS |
| 7 | adler32 @1 |
| 8 | compress @2 |
| 9 | crc32 @3 |
| 10 |
| --- compat/zlib/contrib/vstudio/vc11/zlib.rc | ||
| +++ compat/zlib/contrib/vstudio/vc11/zlib.rc | ||
| @@ -1,11 +1,11 @@ | ||
| 1 | 1 | #include <windows.h> |
| 2 | 2 | |
| 3 | 3 | #define IDR_VERSION1 1 |
| 4 | 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | - FILEVERSION 1, 2, 13, 0 | |
| 6 | - PRODUCTVERSION 1, 2, 13, 0 | |
| 5 | + FILEVERSION 1, 3, 0, 0 | |
| 6 | + PRODUCTVERSION 1, 3, 0, 0 | |
| 7 | 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | 8 | FILEFLAGS 0 |
| 9 | 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | 10 | FILETYPE VFT_DLL |
| 11 | 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | ||
| 15 | 15 | BLOCK "040904E4" |
| 16 | 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | 17 | |
| 18 | 18 | BEGIN |
| 19 | 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | - VALUE "FileVersion", "1.2.13\0" | |
| 20 | + VALUE "FileVersion", "1.3.0\0" | |
| 21 | 21 | VALUE "InternalName", "zlib\0" |
| 22 | 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | - VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" | |
| 25 | + VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" | |
| 26 | 26 | END |
| 27 | 27 | END |
| 28 | 28 | BLOCK "VarFileInfo" |
| 29 | 29 | BEGIN |
| 30 | 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | 31 | END |
| 32 | 32 | END |
| 33 | 33 |
| --- compat/zlib/contrib/vstudio/vc11/zlib.rc | |
| +++ compat/zlib/contrib/vstudio/vc11/zlib.rc | |
| @@ -1,11 +1,11 @@ | |
| 1 | #include <windows.h> |
| 2 | |
| 3 | #define IDR_VERSION1 1 |
| 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | FILEVERSION 1, 2, 13, 0 |
| 6 | PRODUCTVERSION 1, 2, 13, 0 |
| 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | FILEFLAGS 0 |
| 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | FILETYPE VFT_DLL |
| 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | |
| 15 | BLOCK "040904E4" |
| 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | |
| 18 | BEGIN |
| 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | VALUE "FileVersion", "1.2.13\0" |
| 21 | VALUE "InternalName", "zlib\0" |
| 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" |
| 26 | END |
| 27 | END |
| 28 | BLOCK "VarFileInfo" |
| 29 | BEGIN |
| 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | END |
| 32 | END |
| 33 |
| --- compat/zlib/contrib/vstudio/vc11/zlib.rc | |
| +++ compat/zlib/contrib/vstudio/vc11/zlib.rc | |
| @@ -1,11 +1,11 @@ | |
| 1 | #include <windows.h> |
| 2 | |
| 3 | #define IDR_VERSION1 1 |
| 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | FILEVERSION 1, 3, 0, 0 |
| 6 | PRODUCTVERSION 1, 3, 0, 0 |
| 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | FILEFLAGS 0 |
| 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | FILETYPE VFT_DLL |
| 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | |
| 15 | BLOCK "040904E4" |
| 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | |
| 18 | BEGIN |
| 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | VALUE "FileVersion", "1.3.0\0" |
| 21 | VALUE "InternalName", "zlib\0" |
| 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" |
| 26 | END |
| 27 | END |
| 28 | BLOCK "VarFileInfo" |
| 29 | BEGIN |
| 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | END |
| 32 | END |
| 33 |
| --- compat/zlib/contrib/vstudio/vc11/zlibvc.def | ||
| +++ compat/zlib/contrib/vstudio/vc11/zlibvc.def | ||
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | LIBRARY |
| 2 | 2 | ; zlib data compression and ZIP file I/O library |
| 3 | 3 | |
| 4 | -VERSION 1.2 | |
| 4 | +VERSION 1.3 | |
| 5 | 5 | |
| 6 | 6 | EXPORTS |
| 7 | 7 | adler32 @1 |
| 8 | 8 | compress @2 |
| 9 | 9 | crc32 @3 |
| 10 | 10 |
| --- compat/zlib/contrib/vstudio/vc11/zlibvc.def | |
| +++ compat/zlib/contrib/vstudio/vc11/zlibvc.def | |
| @@ -1,9 +1,9 @@ | |
| 1 | LIBRARY |
| 2 | ; zlib data compression and ZIP file I/O library |
| 3 | |
| 4 | VERSION 1.2 |
| 5 | |
| 6 | EXPORTS |
| 7 | adler32 @1 |
| 8 | compress @2 |
| 9 | crc32 @3 |
| 10 |
| --- compat/zlib/contrib/vstudio/vc11/zlibvc.def | |
| +++ compat/zlib/contrib/vstudio/vc11/zlibvc.def | |
| @@ -1,9 +1,9 @@ | |
| 1 | LIBRARY |
| 2 | ; zlib data compression and ZIP file I/O library |
| 3 | |
| 4 | VERSION 1.3 |
| 5 | |
| 6 | EXPORTS |
| 7 | adler32 @1 |
| 8 | compress @2 |
| 9 | crc32 @3 |
| 10 |
| --- compat/zlib/contrib/vstudio/vc12/zlib.rc | ||
| +++ compat/zlib/contrib/vstudio/vc12/zlib.rc | ||
| @@ -1,11 +1,11 @@ | ||
| 1 | 1 | #include <windows.h> |
| 2 | 2 | |
| 3 | 3 | #define IDR_VERSION1 1 |
| 4 | 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | - FILEVERSION 1, 2, 13, 0 | |
| 6 | - PRODUCTVERSION 1, 2, 13, 0 | |
| 5 | + FILEVERSION 1, 3, 0, 0 | |
| 6 | + PRODUCTVERSION 1, 3, 0, 0 | |
| 7 | 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | 8 | FILEFLAGS 0 |
| 9 | 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | 10 | FILETYPE VFT_DLL |
| 11 | 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | ||
| 15 | 15 | BLOCK "040904E4" |
| 16 | 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | 17 | |
| 18 | 18 | BEGIN |
| 19 | 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | - VALUE "FileVersion", "1.2.13\0" | |
| 20 | + VALUE "FileVersion", "1.3.0\0" | |
| 21 | 21 | VALUE "InternalName", "zlib\0" |
| 22 | 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | - VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" | |
| 25 | + VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" | |
| 26 | 26 | END |
| 27 | 27 | END |
| 28 | 28 | BLOCK "VarFileInfo" |
| 29 | 29 | BEGIN |
| 30 | 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | 31 | END |
| 32 | 32 | END |
| 33 | 33 |
| --- compat/zlib/contrib/vstudio/vc12/zlib.rc | |
| +++ compat/zlib/contrib/vstudio/vc12/zlib.rc | |
| @@ -1,11 +1,11 @@ | |
| 1 | #include <windows.h> |
| 2 | |
| 3 | #define IDR_VERSION1 1 |
| 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | FILEVERSION 1, 2, 13, 0 |
| 6 | PRODUCTVERSION 1, 2, 13, 0 |
| 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | FILEFLAGS 0 |
| 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | FILETYPE VFT_DLL |
| 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | |
| 15 | BLOCK "040904E4" |
| 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | |
| 18 | BEGIN |
| 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | VALUE "FileVersion", "1.2.13\0" |
| 21 | VALUE "InternalName", "zlib\0" |
| 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" |
| 26 | END |
| 27 | END |
| 28 | BLOCK "VarFileInfo" |
| 29 | BEGIN |
| 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | END |
| 32 | END |
| 33 |
| --- compat/zlib/contrib/vstudio/vc12/zlib.rc | |
| +++ compat/zlib/contrib/vstudio/vc12/zlib.rc | |
| @@ -1,11 +1,11 @@ | |
| 1 | #include <windows.h> |
| 2 | |
| 3 | #define IDR_VERSION1 1 |
| 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | FILEVERSION 1, 3, 0, 0 |
| 6 | PRODUCTVERSION 1, 3, 0, 0 |
| 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | FILEFLAGS 0 |
| 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | FILETYPE VFT_DLL |
| 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | |
| 15 | BLOCK "040904E4" |
| 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | |
| 18 | BEGIN |
| 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | VALUE "FileVersion", "1.3.0\0" |
| 21 | VALUE "InternalName", "zlib\0" |
| 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" |
| 26 | END |
| 27 | END |
| 28 | BLOCK "VarFileInfo" |
| 29 | BEGIN |
| 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | END |
| 32 | END |
| 33 |
| --- compat/zlib/contrib/vstudio/vc12/zlibvc.def | ||
| +++ compat/zlib/contrib/vstudio/vc12/zlibvc.def | ||
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | LIBRARY |
| 2 | 2 | ; zlib data compression and ZIP file I/O library |
| 3 | 3 | |
| 4 | -VERSION 1.2 | |
| 4 | +VERSION 1.3 | |
| 5 | 5 | |
| 6 | 6 | EXPORTS |
| 7 | 7 | adler32 @1 |
| 8 | 8 | compress @2 |
| 9 | 9 | crc32 @3 |
| 10 | 10 |
| --- compat/zlib/contrib/vstudio/vc12/zlibvc.def | |
| +++ compat/zlib/contrib/vstudio/vc12/zlibvc.def | |
| @@ -1,9 +1,9 @@ | |
| 1 | LIBRARY |
| 2 | ; zlib data compression and ZIP file I/O library |
| 3 | |
| 4 | VERSION 1.2 |
| 5 | |
| 6 | EXPORTS |
| 7 | adler32 @1 |
| 8 | compress @2 |
| 9 | crc32 @3 |
| 10 |
| --- compat/zlib/contrib/vstudio/vc12/zlibvc.def | |
| +++ compat/zlib/contrib/vstudio/vc12/zlibvc.def | |
| @@ -1,9 +1,9 @@ | |
| 1 | LIBRARY |
| 2 | ; zlib data compression and ZIP file I/O library |
| 3 | |
| 4 | VERSION 1.3 |
| 5 | |
| 6 | EXPORTS |
| 7 | adler32 @1 |
| 8 | compress @2 |
| 9 | crc32 @3 |
| 10 |
| --- compat/zlib/contrib/vstudio/vc14/zlib.rc | ||
| +++ compat/zlib/contrib/vstudio/vc14/zlib.rc | ||
| @@ -1,11 +1,11 @@ | ||
| 1 | 1 | #include <windows.h> |
| 2 | 2 | |
| 3 | 3 | #define IDR_VERSION1 1 |
| 4 | 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | - FILEVERSION 1, 2, 13, 0 | |
| 6 | - PRODUCTVERSION 1, 2, 13, 0 | |
| 5 | + FILEVERSION 1, 3, 0, 0 | |
| 6 | + PRODUCTVERSION 1, 3, 0, 0 | |
| 7 | 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | 8 | FILEFLAGS 0 |
| 9 | 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | 10 | FILETYPE VFT_DLL |
| 11 | 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | ||
| 15 | 15 | BLOCK "040904E4" |
| 16 | 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | 17 | |
| 18 | 18 | BEGIN |
| 19 | 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | - VALUE "FileVersion", "1.2.13\0" | |
| 20 | + VALUE "FileVersion", "1.3.0\0" | |
| 21 | 21 | VALUE "InternalName", "zlib\0" |
| 22 | 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | - VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" | |
| 25 | + VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" | |
| 26 | 26 | END |
| 27 | 27 | END |
| 28 | 28 | BLOCK "VarFileInfo" |
| 29 | 29 | BEGIN |
| 30 | 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | 31 | END |
| 32 | 32 | END |
| 33 | 33 |
| --- compat/zlib/contrib/vstudio/vc14/zlib.rc | |
| +++ compat/zlib/contrib/vstudio/vc14/zlib.rc | |
| @@ -1,11 +1,11 @@ | |
| 1 | #include <windows.h> |
| 2 | |
| 3 | #define IDR_VERSION1 1 |
| 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | FILEVERSION 1, 2, 13, 0 |
| 6 | PRODUCTVERSION 1, 2, 13, 0 |
| 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | FILEFLAGS 0 |
| 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | FILETYPE VFT_DLL |
| 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | |
| 15 | BLOCK "040904E4" |
| 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | |
| 18 | BEGIN |
| 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | VALUE "FileVersion", "1.2.13\0" |
| 21 | VALUE "InternalName", "zlib\0" |
| 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" |
| 26 | END |
| 27 | END |
| 28 | BLOCK "VarFileInfo" |
| 29 | BEGIN |
| 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | END |
| 32 | END |
| 33 |
| --- compat/zlib/contrib/vstudio/vc14/zlib.rc | |
| +++ compat/zlib/contrib/vstudio/vc14/zlib.rc | |
| @@ -1,11 +1,11 @@ | |
| 1 | #include <windows.h> |
| 2 | |
| 3 | #define IDR_VERSION1 1 |
| 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | FILEVERSION 1, 3, 0, 0 |
| 6 | PRODUCTVERSION 1, 3, 0, 0 |
| 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | FILEFLAGS 0 |
| 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | FILETYPE VFT_DLL |
| 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | |
| 15 | BLOCK "040904E4" |
| 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | |
| 18 | BEGIN |
| 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | VALUE "FileVersion", "1.3.0\0" |
| 21 | VALUE "InternalName", "zlib\0" |
| 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" |
| 26 | END |
| 27 | END |
| 28 | BLOCK "VarFileInfo" |
| 29 | BEGIN |
| 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | END |
| 32 | END |
| 33 |
| --- compat/zlib/contrib/vstudio/vc14/zlibvc.def | ||
| +++ compat/zlib/contrib/vstudio/vc14/zlibvc.def | ||
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | LIBRARY |
| 2 | 2 | ; zlib data compression and ZIP file I/O library |
| 3 | 3 | |
| 4 | -VERSION 1.2 | |
| 4 | +VERSION 1.3 | |
| 5 | 5 | |
| 6 | 6 | EXPORTS |
| 7 | 7 | adler32 @1 |
| 8 | 8 | compress @2 |
| 9 | 9 | crc32 @3 |
| 10 | 10 |
| --- compat/zlib/contrib/vstudio/vc14/zlibvc.def | |
| +++ compat/zlib/contrib/vstudio/vc14/zlibvc.def | |
| @@ -1,9 +1,9 @@ | |
| 1 | LIBRARY |
| 2 | ; zlib data compression and ZIP file I/O library |
| 3 | |
| 4 | VERSION 1.2 |
| 5 | |
| 6 | EXPORTS |
| 7 | adler32 @1 |
| 8 | compress @2 |
| 9 | crc32 @3 |
| 10 |
| --- compat/zlib/contrib/vstudio/vc14/zlibvc.def | |
| +++ compat/zlib/contrib/vstudio/vc14/zlibvc.def | |
| @@ -1,9 +1,9 @@ | |
| 1 | LIBRARY |
| 2 | ; zlib data compression and ZIP file I/O library |
| 3 | |
| 4 | VERSION 1.3 |
| 5 | |
| 6 | EXPORTS |
| 7 | adler32 @1 |
| 8 | compress @2 |
| 9 | crc32 @3 |
| 10 |
| --- compat/zlib/contrib/vstudio/vc9/zlib.rc | ||
| +++ compat/zlib/contrib/vstudio/vc9/zlib.rc | ||
| @@ -1,11 +1,11 @@ | ||
| 1 | 1 | #include <windows.h> |
| 2 | 2 | |
| 3 | 3 | #define IDR_VERSION1 1 |
| 4 | 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | - FILEVERSION 1, 2, 13, 0 | |
| 6 | - PRODUCTVERSION 1, 2, 13, 0 | |
| 5 | + FILEVERSION 1, 3, 0, 0 | |
| 6 | + PRODUCTVERSION 1, 3, 0, 0 | |
| 7 | 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | 8 | FILEFLAGS 0 |
| 9 | 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | 10 | FILETYPE VFT_DLL |
| 11 | 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | ||
| 15 | 15 | BLOCK "040904E4" |
| 16 | 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | 17 | |
| 18 | 18 | BEGIN |
| 19 | 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | - VALUE "FileVersion", "1.2.13\0" | |
| 20 | + VALUE "FileVersion", "1.3.0\0" | |
| 21 | 21 | VALUE "InternalName", "zlib\0" |
| 22 | 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | - VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" | |
| 25 | + VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" | |
| 26 | 26 | END |
| 27 | 27 | END |
| 28 | 28 | BLOCK "VarFileInfo" |
| 29 | 29 | BEGIN |
| 30 | 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | 31 | END |
| 32 | 32 | END |
| 33 | 33 |
| --- compat/zlib/contrib/vstudio/vc9/zlib.rc | |
| +++ compat/zlib/contrib/vstudio/vc9/zlib.rc | |
| @@ -1,11 +1,11 @@ | |
| 1 | #include <windows.h> |
| 2 | |
| 3 | #define IDR_VERSION1 1 |
| 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | FILEVERSION 1, 2, 13, 0 |
| 6 | PRODUCTVERSION 1, 2, 13, 0 |
| 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | FILEFLAGS 0 |
| 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | FILETYPE VFT_DLL |
| 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | |
| 15 | BLOCK "040904E4" |
| 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | |
| 18 | BEGIN |
| 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | VALUE "FileVersion", "1.2.13\0" |
| 21 | VALUE "InternalName", "zlib\0" |
| 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | VALUE "LegalCopyright", "(C) 1995-2022 Jean-loup Gailly & Mark Adler\0" |
| 26 | END |
| 27 | END |
| 28 | BLOCK "VarFileInfo" |
| 29 | BEGIN |
| 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | END |
| 32 | END |
| 33 |
| --- compat/zlib/contrib/vstudio/vc9/zlib.rc | |
| +++ compat/zlib/contrib/vstudio/vc9/zlib.rc | |
| @@ -1,11 +1,11 @@ | |
| 1 | #include <windows.h> |
| 2 | |
| 3 | #define IDR_VERSION1 1 |
| 4 | IDR_VERSION1 VERSIONINFO MOVEABLE IMPURE LOADONCALL DISCARDABLE |
| 5 | FILEVERSION 1, 3, 0, 0 |
| 6 | PRODUCTVERSION 1, 3, 0, 0 |
| 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK |
| 8 | FILEFLAGS 0 |
| 9 | FILEOS VOS_DOS_WINDOWS32 |
| 10 | FILETYPE VFT_DLL |
| 11 | FILESUBTYPE 0 // not used |
| @@ -15,18 +15,18 @@ | |
| 15 | BLOCK "040904E4" |
| 16 | //language ID = U.S. English, char set = Windows, Multilingual |
| 17 | |
| 18 | BEGIN |
| 19 | VALUE "FileDescription", "zlib data compression and ZIP file I/O library\0" |
| 20 | VALUE "FileVersion", "1.3.0\0" |
| 21 | VALUE "InternalName", "zlib\0" |
| 22 | VALUE "OriginalFilename", "zlibwapi.dll\0" |
| 23 | VALUE "ProductName", "ZLib.DLL\0" |
| 24 | VALUE "Comments","DLL support by Alessandro Iacopetti & Gilles Vollant\0" |
| 25 | VALUE "LegalCopyright", "(C) 1995-2023 Jean-loup Gailly & Mark Adler\0" |
| 26 | END |
| 27 | END |
| 28 | BLOCK "VarFileInfo" |
| 29 | BEGIN |
| 30 | VALUE "Translation", 0x0409, 1252 |
| 31 | END |
| 32 | END |
| 33 |
| --- compat/zlib/contrib/vstudio/vc9/zlibvc.def | ||
| +++ compat/zlib/contrib/vstudio/vc9/zlibvc.def | ||
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | LIBRARY |
| 2 | 2 | ; zlib data compression and ZIP file I/O library |
| 3 | 3 | |
| 4 | -VERSION 1.2 | |
| 4 | +VERSION 1.3 | |
| 5 | 5 | |
| 6 | 6 | EXPORTS |
| 7 | 7 | adler32 @1 |
| 8 | 8 | compress @2 |
| 9 | 9 | crc32 @3 |
| 10 | 10 |
| --- compat/zlib/contrib/vstudio/vc9/zlibvc.def | |
| +++ compat/zlib/contrib/vstudio/vc9/zlibvc.def | |
| @@ -1,9 +1,9 @@ | |
| 1 | LIBRARY |
| 2 | ; zlib data compression and ZIP file I/O library |
| 3 | |
| 4 | VERSION 1.2 |
| 5 | |
| 6 | EXPORTS |
| 7 | adler32 @1 |
| 8 | compress @2 |
| 9 | crc32 @3 |
| 10 |
| --- compat/zlib/contrib/vstudio/vc9/zlibvc.def | |
| +++ compat/zlib/contrib/vstudio/vc9/zlibvc.def | |
| @@ -1,9 +1,9 @@ | |
| 1 | LIBRARY |
| 2 | ; zlib data compression and ZIP file I/O library |
| 3 | |
| 4 | VERSION 1.3 |
| 5 | |
| 6 | EXPORTS |
| 7 | adler32 @1 |
| 8 | compress @2 |
| 9 | crc32 @3 |
| 10 |
+86
-162
| --- compat/zlib/crc32.c | ||
| +++ compat/zlib/crc32.c | ||
| @@ -101,33 +101,18 @@ | ||
| 101 | 101 | /* If available, use the ARM processor CRC32 instruction. */ |
| 102 | 102 | #if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8 |
| 103 | 103 | # define ARMCRC32 |
| 104 | 104 | #endif |
| 105 | 105 | |
| 106 | -/* Local functions. */ | |
| 107 | -local z_crc_t multmodp OF((z_crc_t a, z_crc_t b)); | |
| 108 | -local z_crc_t x2nmodp OF((z_off64_t n, unsigned k)); | |
| 109 | - | |
| 110 | -#if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) | |
| 111 | - local z_word_t byte_swap OF((z_word_t word)); | |
| 112 | -#endif | |
| 113 | - | |
| 114 | -#if defined(W) && !defined(ARMCRC32) | |
| 115 | - local z_crc_t crc_word OF((z_word_t data)); | |
| 116 | - local z_word_t crc_word_big OF((z_word_t data)); | |
| 117 | -#endif | |
| 118 | - | |
| 119 | 106 | #if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) |
| 120 | 107 | /* |
| 121 | 108 | Swap the bytes in a z_word_t to convert between little and big endian. Any |
| 122 | 109 | self-respecting compiler will optimize this to a single machine byte-swap |
| 123 | 110 | instruction, if one is available. This assumes that word_t is either 32 bits |
| 124 | 111 | or 64 bits. |
| 125 | 112 | */ |
| 126 | -local z_word_t byte_swap(word) | |
| 127 | - z_word_t word; | |
| 128 | -{ | |
| 113 | +local z_word_t byte_swap(z_word_t word) { | |
| 129 | 114 | # if W == 8 |
| 130 | 115 | return |
| 131 | 116 | (word & 0xff00000000000000) >> 56 | |
| 132 | 117 | (word & 0xff000000000000) >> 40 | |
| 133 | 118 | (word & 0xff0000000000) >> 24 | |
| @@ -143,29 +128,82 @@ | ||
| 143 | 128 | (word & 0xff00) << 8 | |
| 144 | 129 | (word & 0xff) << 24; |
| 145 | 130 | # endif |
| 146 | 131 | } |
| 147 | 132 | #endif |
| 133 | + | |
| 134 | +#ifdef DYNAMIC_CRC_TABLE | |
| 135 | +/* ========================================================================= | |
| 136 | + * Table of powers of x for combining CRC-32s, filled in by make_crc_table() | |
| 137 | + * below. | |
| 138 | + */ | |
| 139 | + local z_crc_t FAR x2n_table[32]; | |
| 140 | +#else | |
| 141 | +/* ========================================================================= | |
| 142 | + * Tables for byte-wise and braided CRC-32 calculations, and a table of powers | |
| 143 | + * of x for combining CRC-32s, all made by make_crc_table(). | |
| 144 | + */ | |
| 145 | +# include "crc32.h" | |
| 146 | +#endif | |
| 148 | 147 | |
| 149 | 148 | /* CRC polynomial. */ |
| 150 | 149 | #define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */ |
| 150 | + | |
| 151 | +/* | |
| 152 | + Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, | |
| 153 | + reflected. For speed, this requires that a not be zero. | |
| 154 | + */ | |
| 155 | +local z_crc_t multmodp(z_crc_t a, z_crc_t b) { | |
| 156 | + z_crc_t m, p; | |
| 157 | + | |
| 158 | + m = (z_crc_t)1 << 31; | |
| 159 | + p = 0; | |
| 160 | + for (;;) { | |
| 161 | + if (a & m) { | |
| 162 | + p ^= b; | |
| 163 | + if ((a & (m - 1)) == 0) | |
| 164 | + break; | |
| 165 | + } | |
| 166 | + m >>= 1; | |
| 167 | + b = b & 1 ? (b >> 1) ^ POLY : b >> 1; | |
| 168 | + } | |
| 169 | + return p; | |
| 170 | +} | |
| 171 | + | |
| 172 | +/* | |
| 173 | + Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been | |
| 174 | + initialized. | |
| 175 | + */ | |
| 176 | +local z_crc_t x2nmodp(z_off64_t n, unsigned k) { | |
| 177 | + z_crc_t p; | |
| 178 | + | |
| 179 | + p = (z_crc_t)1 << 31; /* x^0 == 1 */ | |
| 180 | + while (n) { | |
| 181 | + if (n & 1) | |
| 182 | + p = multmodp(x2n_table[k & 31], p); | |
| 183 | + n >>= 1; | |
| 184 | + k++; | |
| 185 | + } | |
| 186 | + return p; | |
| 187 | +} | |
| 151 | 188 | |
| 152 | 189 | #ifdef DYNAMIC_CRC_TABLE |
| 153 | - | |
| 190 | +/* ========================================================================= | |
| 191 | + * Build the tables for byte-wise and braided CRC-32 calculations, and a table | |
| 192 | + * of powers of x for combining CRC-32s. | |
| 193 | + */ | |
| 154 | 194 | local z_crc_t FAR crc_table[256]; |
| 155 | -local z_crc_t FAR x2n_table[32]; | |
| 156 | -local void make_crc_table OF((void)); | |
| 157 | 195 | #ifdef W |
| 158 | 196 | local z_word_t FAR crc_big_table[256]; |
| 159 | 197 | local z_crc_t FAR crc_braid_table[W][256]; |
| 160 | 198 | local z_word_t FAR crc_braid_big_table[W][256]; |
| 161 | - local void braid OF((z_crc_t [][256], z_word_t [][256], int, int)); | |
| 199 | + local void braid(z_crc_t [][256], z_word_t [][256], int, int); | |
| 162 | 200 | #endif |
| 163 | 201 | #ifdef MAKECRCH |
| 164 | - local void write_table OF((FILE *, const z_crc_t FAR *, int)); | |
| 165 | - local void write_table32hi OF((FILE *, const z_word_t FAR *, int)); | |
| 166 | - local void write_table64 OF((FILE *, const z_word_t FAR *, int)); | |
| 202 | + local void write_table(FILE *, const z_crc_t FAR *, int); | |
| 203 | + local void write_table32hi(FILE *, const z_word_t FAR *, int); | |
| 204 | + local void write_table64(FILE *, const z_word_t FAR *, int); | |
| 167 | 205 | #endif /* MAKECRCH */ |
| 168 | 206 | |
| 169 | 207 | /* |
| 170 | 208 | Define a once() function depending on the availability of atomics. If this is |
| 171 | 209 | compiled with DYNAMIC_CRC_TABLE defined, and if CRCs will be computed in |
| @@ -174,11 +212,10 @@ | ||
| 174 | 212 | allowed to compute or combine CRCs. |
| 175 | 213 | */ |
| 176 | 214 | |
| 177 | 215 | /* Definition of once functionality. */ |
| 178 | 216 | typedef struct once_s once_t; |
| 179 | -local void once OF((once_t *, void (*)(void))); | |
| 180 | 217 | |
| 181 | 218 | /* Check for the availability of atomics. */ |
| 182 | 219 | #if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \ |
| 183 | 220 | !defined(__STDC_NO_ATOMICS__) |
| 184 | 221 | |
| @@ -194,14 +231,11 @@ | ||
| 194 | 231 | /* |
| 195 | 232 | Run the provided init() function exactly once, even if multiple threads |
| 196 | 233 | invoke once() at the same time. The state must be a once_t initialized with |
| 197 | 234 | ONCE_INIT. |
| 198 | 235 | */ |
| 199 | -local void once(state, init) | |
| 200 | - once_t *state; | |
| 201 | - void (*init)(void); | |
| 202 | -{ | |
| 236 | +local void once(once_t *state, void (*init)(void)) { | |
| 203 | 237 | if (!atomic_load(&state->done)) { |
| 204 | 238 | if (atomic_flag_test_and_set(&state->begun)) |
| 205 | 239 | while (!atomic_load(&state->done)) |
| 206 | 240 | ; |
| 207 | 241 | else { |
| @@ -220,26 +254,20 @@ | ||
| 220 | 254 | }; |
| 221 | 255 | #define ONCE_INIT {0, 0} |
| 222 | 256 | |
| 223 | 257 | /* Test and set. Alas, not atomic, but tries to minimize the period of |
| 224 | 258 | vulnerability. */ |
| 225 | -local int test_and_set OF((int volatile *)); | |
| 226 | -local int test_and_set(flag) | |
| 227 | - int volatile *flag; | |
| 228 | -{ | |
| 259 | +local int test_and_set(int volatile *flag) { | |
| 229 | 260 | int was; |
| 230 | 261 | |
| 231 | 262 | was = *flag; |
| 232 | 263 | *flag = 1; |
| 233 | 264 | return was; |
| 234 | 265 | } |
| 235 | 266 | |
| 236 | 267 | /* Run the provided init() function once. This is not thread-safe. */ |
| 237 | -local void once(state, init) | |
| 238 | - once_t *state; | |
| 239 | - void (*init)(void); | |
| 240 | -{ | |
| 268 | +local void once(once_t *state, void (*init)(void)) { | |
| 241 | 269 | if (!state->done) { |
| 242 | 270 | if (test_and_set(&state->begun)) |
| 243 | 271 | while (!state->done) |
| 244 | 272 | ; |
| 245 | 273 | else { |
| @@ -277,12 +305,11 @@ | ||
| 277 | 305 | The table is simply the CRC of all possible eight bit values. This is all the |
| 278 | 306 | information needed to generate CRCs on data a byte at a time for all |
| 279 | 307 | combinations of CRC register values and incoming bytes. |
| 280 | 308 | */ |
| 281 | 309 | |
| 282 | -local void make_crc_table() | |
| 283 | -{ | |
| 310 | +local void make_crc_table(void) { | |
| 284 | 311 | unsigned i, j, n; |
| 285 | 312 | z_crc_t p; |
| 286 | 313 | |
| 287 | 314 | /* initialize the CRC of bytes tables */ |
| 288 | 315 | for (i = 0; i < 256; i++) { |
| @@ -445,15 +472,11 @@ | ||
| 445 | 472 | |
| 446 | 473 | /* |
| 447 | 474 | Write the 32-bit values in table[0..k-1] to out, five per line in |
| 448 | 475 | hexadecimal separated by commas. |
| 449 | 476 | */ |
| 450 | -local void write_table(out, table, k) | |
| 451 | - FILE *out; | |
| 452 | - const z_crc_t FAR *table; | |
| 453 | - int k; | |
| 454 | -{ | |
| 477 | +local void write_table(FILE *out, const z_crc_t FAR *table, int k) { | |
| 455 | 478 | int n; |
| 456 | 479 | |
| 457 | 480 | for (n = 0; n < k; n++) |
| 458 | 481 | fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : " ", |
| 459 | 482 | (unsigned long)(table[n]), |
| @@ -462,15 +485,11 @@ | ||
| 462 | 485 | |
| 463 | 486 | /* |
| 464 | 487 | Write the high 32-bits of each value in table[0..k-1] to out, five per line |
| 465 | 488 | in hexadecimal separated by commas. |
| 466 | 489 | */ |
| 467 | -local void write_table32hi(out, table, k) | |
| 468 | -FILE *out; | |
| 469 | -const z_word_t FAR *table; | |
| 470 | -int k; | |
| 471 | -{ | |
| 490 | +local void write_table32hi(FILE *out, const z_word_t FAR *table, int k) { | |
| 472 | 491 | int n; |
| 473 | 492 | |
| 474 | 493 | for (n = 0; n < k; n++) |
| 475 | 494 | fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : " ", |
| 476 | 495 | (unsigned long)(table[n] >> 32), |
| @@ -482,26 +501,21 @@ | ||
| 482 | 501 | hexadecimal separated by commas. This assumes that if there is a 64-bit |
| 483 | 502 | type, then there is also a long long integer type, and it is at least 64 |
| 484 | 503 | bits. If not, then the type cast and format string can be adjusted |
| 485 | 504 | accordingly. |
| 486 | 505 | */ |
| 487 | -local void write_table64(out, table, k) | |
| 488 | - FILE *out; | |
| 489 | - const z_word_t FAR *table; | |
| 490 | - int k; | |
| 491 | -{ | |
| 506 | +local void write_table64(FILE *out, const z_word_t FAR *table, int k) { | |
| 492 | 507 | int n; |
| 493 | 508 | |
| 494 | 509 | for (n = 0; n < k; n++) |
| 495 | 510 | fprintf(out, "%s0x%016llx%s", n == 0 || n % 3 ? "" : " ", |
| 496 | 511 | (unsigned long long)(table[n]), |
| 497 | 512 | n == k - 1 ? "" : (n % 3 == 2 ? ",\n" : ", ")); |
| 498 | 513 | } |
| 499 | 514 | |
| 500 | 515 | /* Actually do the deed. */ |
| 501 | -int main() | |
| 502 | -{ | |
| 516 | +int main(void) { | |
| 503 | 517 | make_crc_table(); |
| 504 | 518 | return 0; |
| 505 | 519 | } |
| 506 | 520 | |
| 507 | 521 | #endif /* MAKECRCH */ |
| @@ -509,16 +523,11 @@ | ||
| 509 | 523 | #ifdef W |
| 510 | 524 | /* |
| 511 | 525 | Generate the little and big-endian braid tables for the given n and z_word_t |
| 512 | 526 | size w. Each array must have room for w blocks of 256 elements. |
| 513 | 527 | */ |
| 514 | -local void braid(ltl, big, n, w) | |
| 515 | - z_crc_t ltl[][256]; | |
| 516 | - z_word_t big[][256]; | |
| 517 | - int n; | |
| 518 | - int w; | |
| 519 | -{ | |
| 528 | +local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) { | |
| 520 | 529 | int k; |
| 521 | 530 | z_crc_t i, p, q; |
| 522 | 531 | for (k = 0; k < w; k++) { |
| 523 | 532 | p = x2nmodp((n * w + 3 - k) << 3, 0); |
| 524 | 533 | ltl[k][0] = 0; |
| @@ -529,73 +538,17 @@ | ||
| 529 | 538 | } |
| 530 | 539 | } |
| 531 | 540 | } |
| 532 | 541 | #endif |
| 533 | 542 | |
| 534 | -#else /* !DYNAMIC_CRC_TABLE */ | |
| 535 | -/* ======================================================================== | |
| 536 | - * Tables for byte-wise and braided CRC-32 calculations, and a table of powers | |
| 537 | - * of x for combining CRC-32s, all made by make_crc_table(). | |
| 538 | - */ | |
| 539 | -#include "crc32.h" | |
| 540 | 543 | #endif /* DYNAMIC_CRC_TABLE */ |
| 541 | 544 | |
| 542 | -/* ======================================================================== | |
| 543 | - * Routines used for CRC calculation. Some are also required for the table | |
| 544 | - * generation above. | |
| 545 | - */ | |
| 546 | - | |
| 547 | -/* | |
| 548 | - Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, | |
| 549 | - reflected. For speed, this requires that a not be zero. | |
| 550 | - */ | |
| 551 | -local z_crc_t multmodp(a, b) | |
| 552 | - z_crc_t a; | |
| 553 | - z_crc_t b; | |
| 554 | -{ | |
| 555 | - z_crc_t m, p; | |
| 556 | - | |
| 557 | - m = (z_crc_t)1 << 31; | |
| 558 | - p = 0; | |
| 559 | - for (;;) { | |
| 560 | - if (a & m) { | |
| 561 | - p ^= b; | |
| 562 | - if ((a & (m - 1)) == 0) | |
| 563 | - break; | |
| 564 | - } | |
| 565 | - m >>= 1; | |
| 566 | - b = b & 1 ? (b >> 1) ^ POLY : b >> 1; | |
| 567 | - } | |
| 568 | - return p; | |
| 569 | -} | |
| 570 | - | |
| 571 | -/* | |
| 572 | - Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been | |
| 573 | - initialized. | |
| 574 | - */ | |
| 575 | -local z_crc_t x2nmodp(n, k) | |
| 576 | - z_off64_t n; | |
| 577 | - unsigned k; | |
| 578 | -{ | |
| 579 | - z_crc_t p; | |
| 580 | - | |
| 581 | - p = (z_crc_t)1 << 31; /* x^0 == 1 */ | |
| 582 | - while (n) { | |
| 583 | - if (n & 1) | |
| 584 | - p = multmodp(x2n_table[k & 31], p); | |
| 585 | - n >>= 1; | |
| 586 | - k++; | |
| 587 | - } | |
| 588 | - return p; | |
| 589 | -} | |
| 590 | - | |
| 591 | 545 | /* ========================================================================= |
| 592 | 546 | * This function can be used by asm versions of crc32(), and to force the |
| 593 | 547 | * generation of the CRC tables in a threaded application. |
| 594 | 548 | */ |
| 595 | -const z_crc_t FAR * ZEXPORT get_crc_table() | |
| 596 | -{ | |
| 549 | +const z_crc_t FAR * ZEXPORT get_crc_table(void) { | |
| 597 | 550 | #ifdef DYNAMIC_CRC_TABLE |
| 598 | 551 | once(&made, make_crc_table); |
| 599 | 552 | #endif /* DYNAMIC_CRC_TABLE */ |
| 600 | 553 | return (const z_crc_t FAR *)crc_table; |
| 601 | 554 | } |
| @@ -617,15 +570,12 @@ | ||
| 617 | 570 | */ |
| 618 | 571 | #define Z_BATCH 3990 /* number of words in a batch */ |
| 619 | 572 | #define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */ |
| 620 | 573 | #define Z_BATCH_MIN 800 /* fewest words in a final batch */ |
| 621 | 574 | |
| 622 | -unsigned long ZEXPORT crc32_z(crc, buf, len) | |
| 623 | - unsigned long crc; | |
| 624 | - const unsigned char FAR *buf; | |
| 625 | - z_size_t len; | |
| 626 | -{ | |
| 575 | +unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, | |
| 576 | + z_size_t len) { | |
| 627 | 577 | z_crc_t val; |
| 628 | 578 | z_word_t crc1, crc2; |
| 629 | 579 | const z_word_t *word; |
| 630 | 580 | z_word_t val0, val1, val2; |
| 631 | 581 | z_size_t last, last2, i; |
| @@ -721,22 +671,18 @@ | ||
| 721 | 671 | /* |
| 722 | 672 | Return the CRC of the W bytes in the word_t data, taking the |
| 723 | 673 | least-significant byte of the word as the first byte of data, without any pre |
| 724 | 674 | or post conditioning. This is used to combine the CRCs of each braid. |
| 725 | 675 | */ |
| 726 | -local z_crc_t crc_word(data) | |
| 727 | - z_word_t data; | |
| 728 | -{ | |
| 676 | +local z_crc_t crc_word(z_word_t data) { | |
| 729 | 677 | int k; |
| 730 | 678 | for (k = 0; k < W; k++) |
| 731 | 679 | data = (data >> 8) ^ crc_table[data & 0xff]; |
| 732 | 680 | return (z_crc_t)data; |
| 733 | 681 | } |
| 734 | 682 | |
| 735 | -local z_word_t crc_word_big(data) | |
| 736 | - z_word_t data; | |
| 737 | -{ | |
| 683 | +local z_word_t crc_word_big(z_word_t data) { | |
| 738 | 684 | int k; |
| 739 | 685 | for (k = 0; k < W; k++) |
| 740 | 686 | data = (data << 8) ^ |
| 741 | 687 | crc_big_table[(data >> ((W - 1) << 3)) & 0xff]; |
| 742 | 688 | return data; |
| @@ -743,15 +689,12 @@ | ||
| 743 | 689 | } |
| 744 | 690 | |
| 745 | 691 | #endif |
| 746 | 692 | |
| 747 | 693 | /* ========================================================================= */ |
| 748 | -unsigned long ZEXPORT crc32_z(crc, buf, len) | |
| 749 | - unsigned long crc; | |
| 750 | - const unsigned char FAR *buf; | |
| 751 | - z_size_t len; | |
| 752 | -{ | |
| 694 | +unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, | |
| 695 | + z_size_t len) { | |
| 753 | 696 | /* Return initial CRC, if requested. */ |
| 754 | 697 | if (buf == Z_NULL) return 0; |
| 755 | 698 | |
| 756 | 699 | #ifdef DYNAMIC_CRC_TABLE |
| 757 | 700 | once(&made, make_crc_table); |
| @@ -779,12 +722,12 @@ | ||
| 779 | 722 | blks = len / (N * W); |
| 780 | 723 | len -= blks * N * W; |
| 781 | 724 | words = (z_word_t const *)buf; |
| 782 | 725 | |
| 783 | 726 | /* Do endian check at execution time instead of compile time, since ARM |
| 784 | - processors can change the endianess at execution time. If the | |
| 785 | - compiler knows what the endianess will be, it can optimize out the | |
| 727 | + processors can change the endianness at execution time. If the | |
| 728 | + compiler knows what the endianness will be, it can optimize out the | |
| 786 | 729 | check and the unused branch. */ |
| 787 | 730 | endian = 1; |
| 788 | 731 | if (*(unsigned char *)&endian) { |
| 789 | 732 | /* Little endian. */ |
| 790 | 733 | |
| @@ -1067,59 +1010,40 @@ | ||
| 1067 | 1010 | } |
| 1068 | 1011 | |
| 1069 | 1012 | #endif |
| 1070 | 1013 | |
| 1071 | 1014 | /* ========================================================================= */ |
| 1072 | -unsigned long ZEXPORT crc32(crc, buf, len) | |
| 1073 | - unsigned long crc; | |
| 1074 | - const unsigned char FAR *buf; | |
| 1075 | - uInt len; | |
| 1076 | -{ | |
| 1015 | +unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, | |
| 1016 | + uInt len) { | |
| 1077 | 1017 | return crc32_z(crc, buf, len); |
| 1078 | 1018 | } |
| 1079 | 1019 | |
| 1080 | 1020 | /* ========================================================================= */ |
| 1081 | -uLong ZEXPORT crc32_combine64(crc1, crc2, len2) | |
| 1082 | - uLong crc1; | |
| 1083 | - uLong crc2; | |
| 1084 | - z_off64_t len2; | |
| 1085 | -{ | |
| 1021 | +uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) { | |
| 1086 | 1022 | #ifdef DYNAMIC_CRC_TABLE |
| 1087 | 1023 | once(&made, make_crc_table); |
| 1088 | 1024 | #endif /* DYNAMIC_CRC_TABLE */ |
| 1089 | 1025 | return multmodp(x2nmodp(len2, 3), crc1) ^ (crc2 & 0xffffffff); |
| 1090 | 1026 | } |
| 1091 | 1027 | |
| 1092 | 1028 | /* ========================================================================= */ |
| 1093 | -uLong ZEXPORT crc32_combine(crc1, crc2, len2) | |
| 1094 | - uLong crc1; | |
| 1095 | - uLong crc2; | |
| 1096 | - z_off_t len2; | |
| 1097 | -{ | |
| 1029 | +uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) { | |
| 1098 | 1030 | return crc32_combine64(crc1, crc2, (z_off64_t)len2); |
| 1099 | 1031 | } |
| 1100 | 1032 | |
| 1101 | 1033 | /* ========================================================================= */ |
| 1102 | -uLong ZEXPORT crc32_combine_gen64(len2) | |
| 1103 | - z_off64_t len2; | |
| 1104 | -{ | |
| 1034 | +uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) { | |
| 1105 | 1035 | #ifdef DYNAMIC_CRC_TABLE |
| 1106 | 1036 | once(&made, make_crc_table); |
| 1107 | 1037 | #endif /* DYNAMIC_CRC_TABLE */ |
| 1108 | 1038 | return x2nmodp(len2, 3); |
| 1109 | 1039 | } |
| 1110 | 1040 | |
| 1111 | 1041 | /* ========================================================================= */ |
| 1112 | -uLong ZEXPORT crc32_combine_gen(len2) | |
| 1113 | - z_off_t len2; | |
| 1114 | -{ | |
| 1042 | +uLong ZEXPORT crc32_combine_gen(z_off_t len2) { | |
| 1115 | 1043 | return crc32_combine_gen64((z_off64_t)len2); |
| 1116 | 1044 | } |
| 1117 | 1045 | |
| 1118 | 1046 | /* ========================================================================= */ |
| 1119 | -uLong ZEXPORT crc32_combine_op(crc1, crc2, op) | |
| 1120 | - uLong crc1; | |
| 1121 | - uLong crc2; | |
| 1122 | - uLong op; | |
| 1123 | -{ | |
| 1047 | +uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op) { | |
| 1124 | 1048 | return multmodp(op, crc1) ^ (crc2 & 0xffffffff); |
| 1125 | 1049 | } |
| 1126 | 1050 |
| --- compat/zlib/crc32.c | |
| +++ compat/zlib/crc32.c | |
| @@ -101,33 +101,18 @@ | |
| 101 | /* If available, use the ARM processor CRC32 instruction. */ |
| 102 | #if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8 |
| 103 | # define ARMCRC32 |
| 104 | #endif |
| 105 | |
| 106 | /* Local functions. */ |
| 107 | local z_crc_t multmodp OF((z_crc_t a, z_crc_t b)); |
| 108 | local z_crc_t x2nmodp OF((z_off64_t n, unsigned k)); |
| 109 | |
| 110 | #if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) |
| 111 | local z_word_t byte_swap OF((z_word_t word)); |
| 112 | #endif |
| 113 | |
| 114 | #if defined(W) && !defined(ARMCRC32) |
| 115 | local z_crc_t crc_word OF((z_word_t data)); |
| 116 | local z_word_t crc_word_big OF((z_word_t data)); |
| 117 | #endif |
| 118 | |
| 119 | #if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) |
| 120 | /* |
| 121 | Swap the bytes in a z_word_t to convert between little and big endian. Any |
| 122 | self-respecting compiler will optimize this to a single machine byte-swap |
| 123 | instruction, if one is available. This assumes that word_t is either 32 bits |
| 124 | or 64 bits. |
| 125 | */ |
| 126 | local z_word_t byte_swap(word) |
| 127 | z_word_t word; |
| 128 | { |
| 129 | # if W == 8 |
| 130 | return |
| 131 | (word & 0xff00000000000000) >> 56 | |
| 132 | (word & 0xff000000000000) >> 40 | |
| 133 | (word & 0xff0000000000) >> 24 | |
| @@ -143,29 +128,82 @@ | |
| 143 | (word & 0xff00) << 8 | |
| 144 | (word & 0xff) << 24; |
| 145 | # endif |
| 146 | } |
| 147 | #endif |
| 148 | |
| 149 | /* CRC polynomial. */ |
| 150 | #define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */ |
| 151 | |
| 152 | #ifdef DYNAMIC_CRC_TABLE |
| 153 | |
| 154 | local z_crc_t FAR crc_table[256]; |
| 155 | local z_crc_t FAR x2n_table[32]; |
| 156 | local void make_crc_table OF((void)); |
| 157 | #ifdef W |
| 158 | local z_word_t FAR crc_big_table[256]; |
| 159 | local z_crc_t FAR crc_braid_table[W][256]; |
| 160 | local z_word_t FAR crc_braid_big_table[W][256]; |
| 161 | local void braid OF((z_crc_t [][256], z_word_t [][256], int, int)); |
| 162 | #endif |
| 163 | #ifdef MAKECRCH |
| 164 | local void write_table OF((FILE *, const z_crc_t FAR *, int)); |
| 165 | local void write_table32hi OF((FILE *, const z_word_t FAR *, int)); |
| 166 | local void write_table64 OF((FILE *, const z_word_t FAR *, int)); |
| 167 | #endif /* MAKECRCH */ |
| 168 | |
| 169 | /* |
| 170 | Define a once() function depending on the availability of atomics. If this is |
| 171 | compiled with DYNAMIC_CRC_TABLE defined, and if CRCs will be computed in |
| @@ -174,11 +212,10 @@ | |
| 174 | allowed to compute or combine CRCs. |
| 175 | */ |
| 176 | |
| 177 | /* Definition of once functionality. */ |
| 178 | typedef struct once_s once_t; |
| 179 | local void once OF((once_t *, void (*)(void))); |
| 180 | |
| 181 | /* Check for the availability of atomics. */ |
| 182 | #if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \ |
| 183 | !defined(__STDC_NO_ATOMICS__) |
| 184 | |
| @@ -194,14 +231,11 @@ | |
| 194 | /* |
| 195 | Run the provided init() function exactly once, even if multiple threads |
| 196 | invoke once() at the same time. The state must be a once_t initialized with |
| 197 | ONCE_INIT. |
| 198 | */ |
| 199 | local void once(state, init) |
| 200 | once_t *state; |
| 201 | void (*init)(void); |
| 202 | { |
| 203 | if (!atomic_load(&state->done)) { |
| 204 | if (atomic_flag_test_and_set(&state->begun)) |
| 205 | while (!atomic_load(&state->done)) |
| 206 | ; |
| 207 | else { |
| @@ -220,26 +254,20 @@ | |
| 220 | }; |
| 221 | #define ONCE_INIT {0, 0} |
| 222 | |
| 223 | /* Test and set. Alas, not atomic, but tries to minimize the period of |
| 224 | vulnerability. */ |
| 225 | local int test_and_set OF((int volatile *)); |
| 226 | local int test_and_set(flag) |
| 227 | int volatile *flag; |
| 228 | { |
| 229 | int was; |
| 230 | |
| 231 | was = *flag; |
| 232 | *flag = 1; |
| 233 | return was; |
| 234 | } |
| 235 | |
| 236 | /* Run the provided init() function once. This is not thread-safe. */ |
| 237 | local void once(state, init) |
| 238 | once_t *state; |
| 239 | void (*init)(void); |
| 240 | { |
| 241 | if (!state->done) { |
| 242 | if (test_and_set(&state->begun)) |
| 243 | while (!state->done) |
| 244 | ; |
| 245 | else { |
| @@ -277,12 +305,11 @@ | |
| 277 | The table is simply the CRC of all possible eight bit values. This is all the |
| 278 | information needed to generate CRCs on data a byte at a time for all |
| 279 | combinations of CRC register values and incoming bytes. |
| 280 | */ |
| 281 | |
| 282 | local void make_crc_table() |
| 283 | { |
| 284 | unsigned i, j, n; |
| 285 | z_crc_t p; |
| 286 | |
| 287 | /* initialize the CRC of bytes tables */ |
| 288 | for (i = 0; i < 256; i++) { |
| @@ -445,15 +472,11 @@ | |
| 445 | |
| 446 | /* |
| 447 | Write the 32-bit values in table[0..k-1] to out, five per line in |
| 448 | hexadecimal separated by commas. |
| 449 | */ |
| 450 | local void write_table(out, table, k) |
| 451 | FILE *out; |
| 452 | const z_crc_t FAR *table; |
| 453 | int k; |
| 454 | { |
| 455 | int n; |
| 456 | |
| 457 | for (n = 0; n < k; n++) |
| 458 | fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : " ", |
| 459 | (unsigned long)(table[n]), |
| @@ -462,15 +485,11 @@ | |
| 462 | |
| 463 | /* |
| 464 | Write the high 32-bits of each value in table[0..k-1] to out, five per line |
| 465 | in hexadecimal separated by commas. |
| 466 | */ |
| 467 | local void write_table32hi(out, table, k) |
| 468 | FILE *out; |
| 469 | const z_word_t FAR *table; |
| 470 | int k; |
| 471 | { |
| 472 | int n; |
| 473 | |
| 474 | for (n = 0; n < k; n++) |
| 475 | fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : " ", |
| 476 | (unsigned long)(table[n] >> 32), |
| @@ -482,26 +501,21 @@ | |
| 482 | hexadecimal separated by commas. This assumes that if there is a 64-bit |
| 483 | type, then there is also a long long integer type, and it is at least 64 |
| 484 | bits. If not, then the type cast and format string can be adjusted |
| 485 | accordingly. |
| 486 | */ |
| 487 | local void write_table64(out, table, k) |
| 488 | FILE *out; |
| 489 | const z_word_t FAR *table; |
| 490 | int k; |
| 491 | { |
| 492 | int n; |
| 493 | |
| 494 | for (n = 0; n < k; n++) |
| 495 | fprintf(out, "%s0x%016llx%s", n == 0 || n % 3 ? "" : " ", |
| 496 | (unsigned long long)(table[n]), |
| 497 | n == k - 1 ? "" : (n % 3 == 2 ? ",\n" : ", ")); |
| 498 | } |
| 499 | |
| 500 | /* Actually do the deed. */ |
| 501 | int main() |
| 502 | { |
| 503 | make_crc_table(); |
| 504 | return 0; |
| 505 | } |
| 506 | |
| 507 | #endif /* MAKECRCH */ |
| @@ -509,16 +523,11 @@ | |
| 509 | #ifdef W |
| 510 | /* |
| 511 | Generate the little and big-endian braid tables for the given n and z_word_t |
| 512 | size w. Each array must have room for w blocks of 256 elements. |
| 513 | */ |
| 514 | local void braid(ltl, big, n, w) |
| 515 | z_crc_t ltl[][256]; |
| 516 | z_word_t big[][256]; |
| 517 | int n; |
| 518 | int w; |
| 519 | { |
| 520 | int k; |
| 521 | z_crc_t i, p, q; |
| 522 | for (k = 0; k < w; k++) { |
| 523 | p = x2nmodp((n * w + 3 - k) << 3, 0); |
| 524 | ltl[k][0] = 0; |
| @@ -529,73 +538,17 @@ | |
| 529 | } |
| 530 | } |
| 531 | } |
| 532 | #endif |
| 533 | |
| 534 | #else /* !DYNAMIC_CRC_TABLE */ |
| 535 | /* ======================================================================== |
| 536 | * Tables for byte-wise and braided CRC-32 calculations, and a table of powers |
| 537 | * of x for combining CRC-32s, all made by make_crc_table(). |
| 538 | */ |
| 539 | #include "crc32.h" |
| 540 | #endif /* DYNAMIC_CRC_TABLE */ |
| 541 | |
| 542 | /* ======================================================================== |
| 543 | * Routines used for CRC calculation. Some are also required for the table |
| 544 | * generation above. |
| 545 | */ |
| 546 | |
| 547 | /* |
| 548 | Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, |
| 549 | reflected. For speed, this requires that a not be zero. |
| 550 | */ |
| 551 | local z_crc_t multmodp(a, b) |
| 552 | z_crc_t a; |
| 553 | z_crc_t b; |
| 554 | { |
| 555 | z_crc_t m, p; |
| 556 | |
| 557 | m = (z_crc_t)1 << 31; |
| 558 | p = 0; |
| 559 | for (;;) { |
| 560 | if (a & m) { |
| 561 | p ^= b; |
| 562 | if ((a & (m - 1)) == 0) |
| 563 | break; |
| 564 | } |
| 565 | m >>= 1; |
| 566 | b = b & 1 ? (b >> 1) ^ POLY : b >> 1; |
| 567 | } |
| 568 | return p; |
| 569 | } |
| 570 | |
| 571 | /* |
| 572 | Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been |
| 573 | initialized. |
| 574 | */ |
| 575 | local z_crc_t x2nmodp(n, k) |
| 576 | z_off64_t n; |
| 577 | unsigned k; |
| 578 | { |
| 579 | z_crc_t p; |
| 580 | |
| 581 | p = (z_crc_t)1 << 31; /* x^0 == 1 */ |
| 582 | while (n) { |
| 583 | if (n & 1) |
| 584 | p = multmodp(x2n_table[k & 31], p); |
| 585 | n >>= 1; |
| 586 | k++; |
| 587 | } |
| 588 | return p; |
| 589 | } |
| 590 | |
| 591 | /* ========================================================================= |
| 592 | * This function can be used by asm versions of crc32(), and to force the |
| 593 | * generation of the CRC tables in a threaded application. |
| 594 | */ |
| 595 | const z_crc_t FAR * ZEXPORT get_crc_table() |
| 596 | { |
| 597 | #ifdef DYNAMIC_CRC_TABLE |
| 598 | once(&made, make_crc_table); |
| 599 | #endif /* DYNAMIC_CRC_TABLE */ |
| 600 | return (const z_crc_t FAR *)crc_table; |
| 601 | } |
| @@ -617,15 +570,12 @@ | |
| 617 | */ |
| 618 | #define Z_BATCH 3990 /* number of words in a batch */ |
| 619 | #define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */ |
| 620 | #define Z_BATCH_MIN 800 /* fewest words in a final batch */ |
| 621 | |
| 622 | unsigned long ZEXPORT crc32_z(crc, buf, len) |
| 623 | unsigned long crc; |
| 624 | const unsigned char FAR *buf; |
| 625 | z_size_t len; |
| 626 | { |
| 627 | z_crc_t val; |
| 628 | z_word_t crc1, crc2; |
| 629 | const z_word_t *word; |
| 630 | z_word_t val0, val1, val2; |
| 631 | z_size_t last, last2, i; |
| @@ -721,22 +671,18 @@ | |
| 721 | /* |
| 722 | Return the CRC of the W bytes in the word_t data, taking the |
| 723 | least-significant byte of the word as the first byte of data, without any pre |
| 724 | or post conditioning. This is used to combine the CRCs of each braid. |
| 725 | */ |
| 726 | local z_crc_t crc_word(data) |
| 727 | z_word_t data; |
| 728 | { |
| 729 | int k; |
| 730 | for (k = 0; k < W; k++) |
| 731 | data = (data >> 8) ^ crc_table[data & 0xff]; |
| 732 | return (z_crc_t)data; |
| 733 | } |
| 734 | |
| 735 | local z_word_t crc_word_big(data) |
| 736 | z_word_t data; |
| 737 | { |
| 738 | int k; |
| 739 | for (k = 0; k < W; k++) |
| 740 | data = (data << 8) ^ |
| 741 | crc_big_table[(data >> ((W - 1) << 3)) & 0xff]; |
| 742 | return data; |
| @@ -743,15 +689,12 @@ | |
| 743 | } |
| 744 | |
| 745 | #endif |
| 746 | |
| 747 | /* ========================================================================= */ |
| 748 | unsigned long ZEXPORT crc32_z(crc, buf, len) |
| 749 | unsigned long crc; |
| 750 | const unsigned char FAR *buf; |
| 751 | z_size_t len; |
| 752 | { |
| 753 | /* Return initial CRC, if requested. */ |
| 754 | if (buf == Z_NULL) return 0; |
| 755 | |
| 756 | #ifdef DYNAMIC_CRC_TABLE |
| 757 | once(&made, make_crc_table); |
| @@ -779,12 +722,12 @@ | |
| 779 | blks = len / (N * W); |
| 780 | len -= blks * N * W; |
| 781 | words = (z_word_t const *)buf; |
| 782 | |
| 783 | /* Do endian check at execution time instead of compile time, since ARM |
| 784 | processors can change the endianess at execution time. If the |
| 785 | compiler knows what the endianess will be, it can optimize out the |
| 786 | check and the unused branch. */ |
| 787 | endian = 1; |
| 788 | if (*(unsigned char *)&endian) { |
| 789 | /* Little endian. */ |
| 790 | |
| @@ -1067,59 +1010,40 @@ | |
| 1067 | } |
| 1068 | |
| 1069 | #endif |
| 1070 | |
| 1071 | /* ========================================================================= */ |
| 1072 | unsigned long ZEXPORT crc32(crc, buf, len) |
| 1073 | unsigned long crc; |
| 1074 | const unsigned char FAR *buf; |
| 1075 | uInt len; |
| 1076 | { |
| 1077 | return crc32_z(crc, buf, len); |
| 1078 | } |
| 1079 | |
| 1080 | /* ========================================================================= */ |
| 1081 | uLong ZEXPORT crc32_combine64(crc1, crc2, len2) |
| 1082 | uLong crc1; |
| 1083 | uLong crc2; |
| 1084 | z_off64_t len2; |
| 1085 | { |
| 1086 | #ifdef DYNAMIC_CRC_TABLE |
| 1087 | once(&made, make_crc_table); |
| 1088 | #endif /* DYNAMIC_CRC_TABLE */ |
| 1089 | return multmodp(x2nmodp(len2, 3), crc1) ^ (crc2 & 0xffffffff); |
| 1090 | } |
| 1091 | |
| 1092 | /* ========================================================================= */ |
| 1093 | uLong ZEXPORT crc32_combine(crc1, crc2, len2) |
| 1094 | uLong crc1; |
| 1095 | uLong crc2; |
| 1096 | z_off_t len2; |
| 1097 | { |
| 1098 | return crc32_combine64(crc1, crc2, (z_off64_t)len2); |
| 1099 | } |
| 1100 | |
| 1101 | /* ========================================================================= */ |
| 1102 | uLong ZEXPORT crc32_combine_gen64(len2) |
| 1103 | z_off64_t len2; |
| 1104 | { |
| 1105 | #ifdef DYNAMIC_CRC_TABLE |
| 1106 | once(&made, make_crc_table); |
| 1107 | #endif /* DYNAMIC_CRC_TABLE */ |
| 1108 | return x2nmodp(len2, 3); |
| 1109 | } |
| 1110 | |
| 1111 | /* ========================================================================= */ |
| 1112 | uLong ZEXPORT crc32_combine_gen(len2) |
| 1113 | z_off_t len2; |
| 1114 | { |
| 1115 | return crc32_combine_gen64((z_off64_t)len2); |
| 1116 | } |
| 1117 | |
| 1118 | /* ========================================================================= */ |
| 1119 | uLong ZEXPORT crc32_combine_op(crc1, crc2, op) |
| 1120 | uLong crc1; |
| 1121 | uLong crc2; |
| 1122 | uLong op; |
| 1123 | { |
| 1124 | return multmodp(op, crc1) ^ (crc2 & 0xffffffff); |
| 1125 | } |
| 1126 |
| --- compat/zlib/crc32.c | |
| +++ compat/zlib/crc32.c | |
| @@ -101,33 +101,18 @@ | |
| 101 | /* If available, use the ARM processor CRC32 instruction. */ |
| 102 | #if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8 |
| 103 | # define ARMCRC32 |
| 104 | #endif |
| 105 | |
| 106 | #if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) |
| 107 | /* |
| 108 | Swap the bytes in a z_word_t to convert between little and big endian. Any |
| 109 | self-respecting compiler will optimize this to a single machine byte-swap |
| 110 | instruction, if one is available. This assumes that word_t is either 32 bits |
| 111 | or 64 bits. |
| 112 | */ |
| 113 | local z_word_t byte_swap(z_word_t word) { |
| 114 | # if W == 8 |
| 115 | return |
| 116 | (word & 0xff00000000000000) >> 56 | |
| 117 | (word & 0xff000000000000) >> 40 | |
| 118 | (word & 0xff0000000000) >> 24 | |
| @@ -143,29 +128,82 @@ | |
| 128 | (word & 0xff00) << 8 | |
| 129 | (word & 0xff) << 24; |
| 130 | # endif |
| 131 | } |
| 132 | #endif |
| 133 | |
| 134 | #ifdef DYNAMIC_CRC_TABLE |
| 135 | /* ========================================================================= |
| 136 | * Table of powers of x for combining CRC-32s, filled in by make_crc_table() |
| 137 | * below. |
| 138 | */ |
| 139 | local z_crc_t FAR x2n_table[32]; |
| 140 | #else |
| 141 | /* ========================================================================= |
| 142 | * Tables for byte-wise and braided CRC-32 calculations, and a table of powers |
| 143 | * of x for combining CRC-32s, all made by make_crc_table(). |
| 144 | */ |
| 145 | # include "crc32.h" |
| 146 | #endif |
| 147 | |
| 148 | /* CRC polynomial. */ |
| 149 | #define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */ |
| 150 | |
| 151 | /* |
| 152 | Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, |
| 153 | reflected. For speed, this requires that a not be zero. |
| 154 | */ |
| 155 | local z_crc_t multmodp(z_crc_t a, z_crc_t b) { |
| 156 | z_crc_t m, p; |
| 157 | |
| 158 | m = (z_crc_t)1 << 31; |
| 159 | p = 0; |
| 160 | for (;;) { |
| 161 | if (a & m) { |
| 162 | p ^= b; |
| 163 | if ((a & (m - 1)) == 0) |
| 164 | break; |
| 165 | } |
| 166 | m >>= 1; |
| 167 | b = b & 1 ? (b >> 1) ^ POLY : b >> 1; |
| 168 | } |
| 169 | return p; |
| 170 | } |
| 171 | |
| 172 | /* |
| 173 | Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been |
| 174 | initialized. |
| 175 | */ |
| 176 | local z_crc_t x2nmodp(z_off64_t n, unsigned k) { |
| 177 | z_crc_t p; |
| 178 | |
| 179 | p = (z_crc_t)1 << 31; /* x^0 == 1 */ |
| 180 | while (n) { |
| 181 | if (n & 1) |
| 182 | p = multmodp(x2n_table[k & 31], p); |
| 183 | n >>= 1; |
| 184 | k++; |
| 185 | } |
| 186 | return p; |
| 187 | } |
| 188 | |
| 189 | #ifdef DYNAMIC_CRC_TABLE |
| 190 | /* ========================================================================= |
| 191 | * Build the tables for byte-wise and braided CRC-32 calculations, and a table |
| 192 | * of powers of x for combining CRC-32s. |
| 193 | */ |
| 194 | local z_crc_t FAR crc_table[256]; |
| 195 | #ifdef W |
| 196 | local z_word_t FAR crc_big_table[256]; |
| 197 | local z_crc_t FAR crc_braid_table[W][256]; |
| 198 | local z_word_t FAR crc_braid_big_table[W][256]; |
| 199 | local void braid(z_crc_t [][256], z_word_t [][256], int, int); |
| 200 | #endif |
| 201 | #ifdef MAKECRCH |
| 202 | local void write_table(FILE *, const z_crc_t FAR *, int); |
| 203 | local void write_table32hi(FILE *, const z_word_t FAR *, int); |
| 204 | local void write_table64(FILE *, const z_word_t FAR *, int); |
| 205 | #endif /* MAKECRCH */ |
| 206 | |
| 207 | /* |
| 208 | Define a once() function depending on the availability of atomics. If this is |
| 209 | compiled with DYNAMIC_CRC_TABLE defined, and if CRCs will be computed in |
| @@ -174,11 +212,10 @@ | |
| 212 | allowed to compute or combine CRCs. |
| 213 | */ |
| 214 | |
| 215 | /* Definition of once functionality. */ |
| 216 | typedef struct once_s once_t; |
| 217 | |
| 218 | /* Check for the availability of atomics. */ |
| 219 | #if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \ |
| 220 | !defined(__STDC_NO_ATOMICS__) |
| 221 | |
| @@ -194,14 +231,11 @@ | |
| 231 | /* |
| 232 | Run the provided init() function exactly once, even if multiple threads |
| 233 | invoke once() at the same time. The state must be a once_t initialized with |
| 234 | ONCE_INIT. |
| 235 | */ |
| 236 | local void once(once_t *state, void (*init)(void)) { |
| 237 | if (!atomic_load(&state->done)) { |
| 238 | if (atomic_flag_test_and_set(&state->begun)) |
| 239 | while (!atomic_load(&state->done)) |
| 240 | ; |
| 241 | else { |
| @@ -220,26 +254,20 @@ | |
| 254 | }; |
| 255 | #define ONCE_INIT {0, 0} |
| 256 | |
| 257 | /* Test and set. Alas, not atomic, but tries to minimize the period of |
| 258 | vulnerability. */ |
| 259 | local int test_and_set(int volatile *flag) { |
| 260 | int was; |
| 261 | |
| 262 | was = *flag; |
| 263 | *flag = 1; |
| 264 | return was; |
| 265 | } |
| 266 | |
| 267 | /* Run the provided init() function once. This is not thread-safe. */ |
| 268 | local void once(once_t *state, void (*init)(void)) { |
| 269 | if (!state->done) { |
| 270 | if (test_and_set(&state->begun)) |
| 271 | while (!state->done) |
| 272 | ; |
| 273 | else { |
| @@ -277,12 +305,11 @@ | |
| 305 | The table is simply the CRC of all possible eight bit values. This is all the |
| 306 | information needed to generate CRCs on data a byte at a time for all |
| 307 | combinations of CRC register values and incoming bytes. |
| 308 | */ |
| 309 | |
| 310 | local void make_crc_table(void) { |
| 311 | unsigned i, j, n; |
| 312 | z_crc_t p; |
| 313 | |
| 314 | /* initialize the CRC of bytes tables */ |
| 315 | for (i = 0; i < 256; i++) { |
| @@ -445,15 +472,11 @@ | |
| 472 | |
| 473 | /* |
| 474 | Write the 32-bit values in table[0..k-1] to out, five per line in |
| 475 | hexadecimal separated by commas. |
| 476 | */ |
| 477 | local void write_table(FILE *out, const z_crc_t FAR *table, int k) { |
| 478 | int n; |
| 479 | |
| 480 | for (n = 0; n < k; n++) |
| 481 | fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : " ", |
| 482 | (unsigned long)(table[n]), |
| @@ -462,15 +485,11 @@ | |
| 485 | |
| 486 | /* |
| 487 | Write the high 32-bits of each value in table[0..k-1] to out, five per line |
| 488 | in hexadecimal separated by commas. |
| 489 | */ |
| 490 | local void write_table32hi(FILE *out, const z_word_t FAR *table, int k) { |
| 491 | int n; |
| 492 | |
| 493 | for (n = 0; n < k; n++) |
| 494 | fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : " ", |
| 495 | (unsigned long)(table[n] >> 32), |
| @@ -482,26 +501,21 @@ | |
| 501 | hexadecimal separated by commas. This assumes that if there is a 64-bit |
| 502 | type, then there is also a long long integer type, and it is at least 64 |
| 503 | bits. If not, then the type cast and format string can be adjusted |
| 504 | accordingly. |
| 505 | */ |
| 506 | local void write_table64(FILE *out, const z_word_t FAR *table, int k) { |
| 507 | int n; |
| 508 | |
| 509 | for (n = 0; n < k; n++) |
| 510 | fprintf(out, "%s0x%016llx%s", n == 0 || n % 3 ? "" : " ", |
| 511 | (unsigned long long)(table[n]), |
| 512 | n == k - 1 ? "" : (n % 3 == 2 ? ",\n" : ", ")); |
| 513 | } |
| 514 | |
| 515 | /* Actually do the deed. */ |
| 516 | int main(void) { |
| 517 | make_crc_table(); |
| 518 | return 0; |
| 519 | } |
| 520 | |
| 521 | #endif /* MAKECRCH */ |
| @@ -509,16 +523,11 @@ | |
| 523 | #ifdef W |
| 524 | /* |
| 525 | Generate the little and big-endian braid tables for the given n and z_word_t |
| 526 | size w. Each array must have room for w blocks of 256 elements. |
| 527 | */ |
| 528 | local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) { |
| 529 | int k; |
| 530 | z_crc_t i, p, q; |
| 531 | for (k = 0; k < w; k++) { |
| 532 | p = x2nmodp((n * w + 3 - k) << 3, 0); |
| 533 | ltl[k][0] = 0; |
| @@ -529,73 +538,17 @@ | |
| 538 | } |
| 539 | } |
| 540 | } |
| 541 | #endif |
| 542 | |
| 543 | #endif /* DYNAMIC_CRC_TABLE */ |
| 544 | |
| 545 | /* ========================================================================= |
| 546 | * This function can be used by asm versions of crc32(), and to force the |
| 547 | * generation of the CRC tables in a threaded application. |
| 548 | */ |
| 549 | const z_crc_t FAR * ZEXPORT get_crc_table(void) { |
| 550 | #ifdef DYNAMIC_CRC_TABLE |
| 551 | once(&made, make_crc_table); |
| 552 | #endif /* DYNAMIC_CRC_TABLE */ |
| 553 | return (const z_crc_t FAR *)crc_table; |
| 554 | } |
| @@ -617,15 +570,12 @@ | |
| 570 | */ |
| 571 | #define Z_BATCH 3990 /* number of words in a batch */ |
| 572 | #define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */ |
| 573 | #define Z_BATCH_MIN 800 /* fewest words in a final batch */ |
| 574 | |
| 575 | unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, |
| 576 | z_size_t len) { |
| 577 | z_crc_t val; |
| 578 | z_word_t crc1, crc2; |
| 579 | const z_word_t *word; |
| 580 | z_word_t val0, val1, val2; |
| 581 | z_size_t last, last2, i; |
| @@ -721,22 +671,18 @@ | |
| 671 | /* |
| 672 | Return the CRC of the W bytes in the word_t data, taking the |
| 673 | least-significant byte of the word as the first byte of data, without any pre |
| 674 | or post conditioning. This is used to combine the CRCs of each braid. |
| 675 | */ |
| 676 | local z_crc_t crc_word(z_word_t data) { |
| 677 | int k; |
| 678 | for (k = 0; k < W; k++) |
| 679 | data = (data >> 8) ^ crc_table[data & 0xff]; |
| 680 | return (z_crc_t)data; |
| 681 | } |
| 682 | |
| 683 | local z_word_t crc_word_big(z_word_t data) { |
| 684 | int k; |
| 685 | for (k = 0; k < W; k++) |
| 686 | data = (data << 8) ^ |
| 687 | crc_big_table[(data >> ((W - 1) << 3)) & 0xff]; |
| 688 | return data; |
| @@ -743,15 +689,12 @@ | |
| 689 | } |
| 690 | |
| 691 | #endif |
| 692 | |
| 693 | /* ========================================================================= */ |
| 694 | unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, |
| 695 | z_size_t len) { |
| 696 | /* Return initial CRC, if requested. */ |
| 697 | if (buf == Z_NULL) return 0; |
| 698 | |
| 699 | #ifdef DYNAMIC_CRC_TABLE |
| 700 | once(&made, make_crc_table); |
| @@ -779,12 +722,12 @@ | |
| 722 | blks = len / (N * W); |
| 723 | len -= blks * N * W; |
| 724 | words = (z_word_t const *)buf; |
| 725 | |
| 726 | /* Do endian check at execution time instead of compile time, since ARM |
| 727 | processors can change the endianness at execution time. If the |
| 728 | compiler knows what the endianness will be, it can optimize out the |
| 729 | check and the unused branch. */ |
| 730 | endian = 1; |
| 731 | if (*(unsigned char *)&endian) { |
| 732 | /* Little endian. */ |
| 733 | |
| @@ -1067,59 +1010,40 @@ | |
| 1010 | } |
| 1011 | |
| 1012 | #endif |
| 1013 | |
| 1014 | /* ========================================================================= */ |
| 1015 | unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, |
| 1016 | uInt len) { |
| 1017 | return crc32_z(crc, buf, len); |
| 1018 | } |
| 1019 | |
| 1020 | /* ========================================================================= */ |
| 1021 | uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) { |
| 1022 | #ifdef DYNAMIC_CRC_TABLE |
| 1023 | once(&made, make_crc_table); |
| 1024 | #endif /* DYNAMIC_CRC_TABLE */ |
| 1025 | return multmodp(x2nmodp(len2, 3), crc1) ^ (crc2 & 0xffffffff); |
| 1026 | } |
| 1027 | |
| 1028 | /* ========================================================================= */ |
| 1029 | uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) { |
| 1030 | return crc32_combine64(crc1, crc2, (z_off64_t)len2); |
| 1031 | } |
| 1032 | |
| 1033 | /* ========================================================================= */ |
| 1034 | uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) { |
| 1035 | #ifdef DYNAMIC_CRC_TABLE |
| 1036 | once(&made, make_crc_table); |
| 1037 | #endif /* DYNAMIC_CRC_TABLE */ |
| 1038 | return x2nmodp(len2, 3); |
| 1039 | } |
| 1040 | |
| 1041 | /* ========================================================================= */ |
| 1042 | uLong ZEXPORT crc32_combine_gen(z_off_t len2) { |
| 1043 | return crc32_combine_gen64((z_off64_t)len2); |
| 1044 | } |
| 1045 | |
| 1046 | /* ========================================================================= */ |
| 1047 | uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op) { |
| 1048 | return multmodp(op, crc1) ^ (crc2 & 0xffffffff); |
| 1049 | } |
| 1050 |
+234
-337
| --- compat/zlib/deflate.c | ||
| +++ compat/zlib/deflate.c | ||
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | /* deflate.c -- compress data using the deflation algorithm |
| 2 | - * Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler | |
| 2 | + * Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler | |
| 3 | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | /* |
| 7 | 7 | * ALGORITHM |
| @@ -50,51 +50,35 @@ | ||
| 50 | 50 | /* @(#) $Id$ */ |
| 51 | 51 | |
| 52 | 52 | #include "deflate.h" |
| 53 | 53 | |
| 54 | 54 | const char deflate_copyright[] = |
| 55 | - " deflate 1.2.13 Copyright 1995-2022 Jean-loup Gailly and Mark Adler "; | |
| 55 | + " deflate 1.3 Copyright 1995-2023 Jean-loup Gailly and Mark Adler "; | |
| 56 | 56 | /* |
| 57 | 57 | If you use the zlib library in a product, an acknowledgment is welcome |
| 58 | 58 | in the documentation of your product. If for some reason you cannot |
| 59 | 59 | include such an acknowledgment, I would appreciate that you keep this |
| 60 | 60 | copyright string in the executable of your product. |
| 61 | 61 | */ |
| 62 | 62 | |
| 63 | -/* =========================================================================== | |
| 64 | - * Function prototypes. | |
| 65 | - */ | |
| 66 | 63 | typedef enum { |
| 67 | 64 | need_more, /* block not completed, need more input or more output */ |
| 68 | 65 | block_done, /* block flush performed */ |
| 69 | 66 | finish_started, /* finish started, need only more output at next deflate */ |
| 70 | 67 | finish_done /* finish done, accept no more input or output */ |
| 71 | 68 | } block_state; |
| 72 | 69 | |
| 73 | -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); | |
| 70 | +typedef block_state (*compress_func)(deflate_state *s, int flush); | |
| 74 | 71 | /* Compression function. Returns the block state after the call. */ |
| 75 | 72 | |
| 76 | -local int deflateStateCheck OF((z_streamp strm)); | |
| 77 | -local void slide_hash OF((deflate_state *s)); | |
| 78 | -local void fill_window OF((deflate_state *s)); | |
| 79 | -local block_state deflate_stored OF((deflate_state *s, int flush)); | |
| 80 | -local block_state deflate_fast OF((deflate_state *s, int flush)); | |
| 73 | +local block_state deflate_stored(deflate_state *s, int flush); | |
| 74 | +local block_state deflate_fast(deflate_state *s, int flush); | |
| 81 | 75 | #ifndef FASTEST |
| 82 | -local block_state deflate_slow OF((deflate_state *s, int flush)); | |
| 83 | -#endif | |
| 84 | -local block_state deflate_rle OF((deflate_state *s, int flush)); | |
| 85 | -local block_state deflate_huff OF((deflate_state *s, int flush)); | |
| 86 | -local void lm_init OF((deflate_state *s)); | |
| 87 | -local void putShortMSB OF((deflate_state *s, uInt b)); | |
| 88 | -local void flush_pending OF((z_streamp strm)); | |
| 89 | -local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); | |
| 90 | -local uInt longest_match OF((deflate_state *s, IPos cur_match)); | |
| 91 | - | |
| 92 | -#ifdef ZLIB_DEBUG | |
| 93 | -local void check_match OF((deflate_state *s, IPos start, IPos match, | |
| 94 | - int length)); | |
| 95 | -#endif | |
| 76 | +local block_state deflate_slow(deflate_state *s, int flush); | |
| 77 | +#endif | |
| 78 | +local block_state deflate_rle(deflate_state *s, int flush); | |
| 79 | +local block_state deflate_huff(deflate_state *s, int flush); | |
| 96 | 80 | |
| 97 | 81 | /* =========================================================================== |
| 98 | 82 | * Local data |
| 99 | 83 | */ |
| 100 | 84 | |
| @@ -193,13 +177,16 @@ | ||
| 193 | 177 | /* =========================================================================== |
| 194 | 178 | * Slide the hash table when sliding the window down (could be avoided with 32 |
| 195 | 179 | * bit values at the expense of memory usage). We slide even when level == 0 to |
| 196 | 180 | * keep the hash table consistent if we switch back to level > 0 later. |
| 197 | 181 | */ |
| 198 | -local void slide_hash(s) | |
| 199 | - deflate_state *s; | |
| 200 | -{ | |
| 182 | +#if defined(__has_feature) | |
| 183 | +# if __has_feature(memory_sanitizer) | |
| 184 | + __attribute__((no_sanitize("memory"))) | |
| 185 | +# endif | |
| 186 | +#endif | |
| 187 | +local void slide_hash(deflate_state *s) { | |
| 201 | 188 | unsigned n, m; |
| 202 | 189 | Posf *p; |
| 203 | 190 | uInt wsize = s->w_size; |
| 204 | 191 | |
| 205 | 192 | n = s->hash_size; |
| @@ -218,35 +205,182 @@ | ||
| 218 | 205 | * its value will never be used. |
| 219 | 206 | */ |
| 220 | 207 | } while (--n); |
| 221 | 208 | #endif |
| 222 | 209 | } |
| 210 | + | |
| 211 | +/* =========================================================================== | |
| 212 | + * Read a new buffer from the current input stream, update the adler32 | |
| 213 | + * and total number of bytes read. All deflate() input goes through | |
| 214 | + * this function so some applications may wish to modify it to avoid | |
| 215 | + * allocating a large strm->next_in buffer and copying from it. | |
| 216 | + * (See also flush_pending()). | |
| 217 | + */ | |
| 218 | +local unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size) { | |
| 219 | + unsigned len = strm->avail_in; | |
| 220 | + | |
| 221 | + if (len > size) len = size; | |
| 222 | + if (len == 0) return 0; | |
| 223 | + | |
| 224 | + strm->avail_in -= len; | |
| 225 | + | |
| 226 | + zmemcpy(buf, strm->next_in, len); | |
| 227 | + if (strm->state->wrap == 1) { | |
| 228 | + strm->adler = adler32(strm->adler, buf, len); | |
| 229 | + } | |
| 230 | +#ifdef GZIP | |
| 231 | + else if (strm->state->wrap == 2) { | |
| 232 | + strm->adler = crc32(strm->adler, buf, len); | |
| 233 | + } | |
| 234 | +#endif | |
| 235 | + strm->next_in += len; | |
| 236 | + strm->total_in += len; | |
| 237 | + | |
| 238 | + return len; | |
| 239 | +} | |
| 240 | + | |
| 241 | +/* =========================================================================== | |
| 242 | + * Fill the window when the lookahead becomes insufficient. | |
| 243 | + * Updates strstart and lookahead. | |
| 244 | + * | |
| 245 | + * IN assertion: lookahead < MIN_LOOKAHEAD | |
| 246 | + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD | |
| 247 | + * At least one byte has been read, or avail_in == 0; reads are | |
| 248 | + * performed for at least two bytes (required for the zip translate_eol | |
| 249 | + * option -- not supported here). | |
| 250 | + */ | |
| 251 | +local void fill_window(deflate_state *s) { | |
| 252 | + unsigned n; | |
| 253 | + unsigned more; /* Amount of free space at the end of the window. */ | |
| 254 | + uInt wsize = s->w_size; | |
| 255 | + | |
| 256 | + Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); | |
| 257 | + | |
| 258 | + do { | |
| 259 | + more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); | |
| 260 | + | |
| 261 | + /* Deal with !@#$% 64K limit: */ | |
| 262 | + if (sizeof(int) <= 2) { | |
| 263 | + if (more == 0 && s->strstart == 0 && s->lookahead == 0) { | |
| 264 | + more = wsize; | |
| 265 | + | |
| 266 | + } else if (more == (unsigned)(-1)) { | |
| 267 | + /* Very unlikely, but possible on 16 bit machine if | |
| 268 | + * strstart == 0 && lookahead == 1 (input done a byte at time) | |
| 269 | + */ | |
| 270 | + more--; | |
| 271 | + } | |
| 272 | + } | |
| 273 | + | |
| 274 | + /* If the window is almost full and there is insufficient lookahead, | |
| 275 | + * move the upper half to the lower one to make room in the upper half. | |
| 276 | + */ | |
| 277 | + if (s->strstart >= wsize + MAX_DIST(s)) { | |
| 278 | + | |
| 279 | + zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more); | |
| 280 | + s->match_start -= wsize; | |
| 281 | + s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ | |
| 282 | + s->block_start -= (long) wsize; | |
| 283 | + if (s->insert > s->strstart) | |
| 284 | + s->insert = s->strstart; | |
| 285 | + slide_hash(s); | |
| 286 | + more += wsize; | |
| 287 | + } | |
| 288 | + if (s->strm->avail_in == 0) break; | |
| 289 | + | |
| 290 | + /* If there was no sliding: | |
| 291 | + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && | |
| 292 | + * more == window_size - lookahead - strstart | |
| 293 | + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) | |
| 294 | + * => more >= window_size - 2*WSIZE + 2 | |
| 295 | + * In the BIG_MEM or MMAP case (not yet supported), | |
| 296 | + * window_size == input_size + MIN_LOOKAHEAD && | |
| 297 | + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. | |
| 298 | + * Otherwise, window_size == 2*WSIZE so more >= 2. | |
| 299 | + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. | |
| 300 | + */ | |
| 301 | + Assert(more >= 2, "more < 2"); | |
| 302 | + | |
| 303 | + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); | |
| 304 | + s->lookahead += n; | |
| 305 | + | |
| 306 | + /* Initialize the hash value now that we have some input: */ | |
| 307 | + if (s->lookahead + s->insert >= MIN_MATCH) { | |
| 308 | + uInt str = s->strstart - s->insert; | |
| 309 | + s->ins_h = s->window[str]; | |
| 310 | + UPDATE_HASH(s, s->ins_h, s->window[str + 1]); | |
| 311 | +#if MIN_MATCH != 3 | |
| 312 | + Call UPDATE_HASH() MIN_MATCH-3 more times | |
| 313 | +#endif | |
| 314 | + while (s->insert) { | |
| 315 | + UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); | |
| 316 | +#ifndef FASTEST | |
| 317 | + s->prev[str & s->w_mask] = s->head[s->ins_h]; | |
| 318 | +#endif | |
| 319 | + s->head[s->ins_h] = (Pos)str; | |
| 320 | + str++; | |
| 321 | + s->insert--; | |
| 322 | + if (s->lookahead + s->insert < MIN_MATCH) | |
| 323 | + break; | |
| 324 | + } | |
| 325 | + } | |
| 326 | + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, | |
| 327 | + * but this is not important since only literal bytes will be emitted. | |
| 328 | + */ | |
| 329 | + | |
| 330 | + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); | |
| 331 | + | |
| 332 | + /* If the WIN_INIT bytes after the end of the current data have never been | |
| 333 | + * written, then zero those bytes in order to avoid memory check reports of | |
| 334 | + * the use of uninitialized (or uninitialised as Julian writes) bytes by | |
| 335 | + * the longest match routines. Update the high water mark for the next | |
| 336 | + * time through here. WIN_INIT is set to MAX_MATCH since the longest match | |
| 337 | + * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. | |
| 338 | + */ | |
| 339 | + if (s->high_water < s->window_size) { | |
| 340 | + ulg curr = s->strstart + (ulg)(s->lookahead); | |
| 341 | + ulg init; | |
| 342 | + | |
| 343 | + if (s->high_water < curr) { | |
| 344 | + /* Previous high water mark below current data -- zero WIN_INIT | |
| 345 | + * bytes or up to end of window, whichever is less. | |
| 346 | + */ | |
| 347 | + init = s->window_size - curr; | |
| 348 | + if (init > WIN_INIT) | |
| 349 | + init = WIN_INIT; | |
| 350 | + zmemzero(s->window + curr, (unsigned)init); | |
| 351 | + s->high_water = curr + init; | |
| 352 | + } | |
| 353 | + else if (s->high_water < (ulg)curr + WIN_INIT) { | |
| 354 | + /* High water mark at or above current data, but below current data | |
| 355 | + * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up | |
| 356 | + * to end of window, whichever is less. | |
| 357 | + */ | |
| 358 | + init = (ulg)curr + WIN_INIT - s->high_water; | |
| 359 | + if (init > s->window_size - s->high_water) | |
| 360 | + init = s->window_size - s->high_water; | |
| 361 | + zmemzero(s->window + s->high_water, (unsigned)init); | |
| 362 | + s->high_water += init; | |
| 363 | + } | |
| 364 | + } | |
| 365 | + | |
| 366 | + Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, | |
| 367 | + "not enough room for search"); | |
| 368 | +} | |
| 223 | 369 | |
| 224 | 370 | /* ========================================================================= */ |
| 225 | -int ZEXPORT deflateInit_(strm, level, version, stream_size) | |
| 226 | - z_streamp strm; | |
| 227 | - int level; | |
| 228 | - const char *version; | |
| 229 | - int stream_size; | |
| 230 | -{ | |
| 371 | +int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, | |
| 372 | + int stream_size) { | |
| 231 | 373 | return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, |
| 232 | 374 | Z_DEFAULT_STRATEGY, version, stream_size); |
| 233 | 375 | /* To do: ignore strm->next_in if we use it as window */ |
| 234 | 376 | } |
| 235 | 377 | |
| 236 | 378 | /* ========================================================================= */ |
| 237 | -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, | |
| 238 | - version, stream_size) | |
| 239 | - z_streamp strm; | |
| 240 | - int level; | |
| 241 | - int method; | |
| 242 | - int windowBits; | |
| 243 | - int memLevel; | |
| 244 | - int strategy; | |
| 245 | - const char *version; | |
| 246 | - int stream_size; | |
| 247 | -{ | |
| 379 | +int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, | |
| 380 | + int windowBits, int memLevel, int strategy, | |
| 381 | + const char *version, int stream_size) { | |
| 248 | 382 | deflate_state *s; |
| 249 | 383 | int wrap = 1; |
| 250 | 384 | static const char my_version[] = ZLIB_VERSION; |
| 251 | 385 | |
| 252 | 386 | if (version == Z_NULL || version[0] != my_version[0] || |
| @@ -384,13 +518,11 @@ | ||
| 384 | 518 | } |
| 385 | 519 | |
| 386 | 520 | /* ========================================================================= |
| 387 | 521 | * Check for a valid deflate stream state. Return 0 if ok, 1 if not. |
| 388 | 522 | */ |
| 389 | -local int deflateStateCheck(strm) | |
| 390 | - z_streamp strm; | |
| 391 | -{ | |
| 523 | +local int deflateStateCheck(z_streamp strm) { | |
| 392 | 524 | deflate_state *s; |
| 393 | 525 | if (strm == Z_NULL || |
| 394 | 526 | strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) |
| 395 | 527 | return 1; |
| 396 | 528 | s = strm->state; |
| @@ -407,15 +539,12 @@ | ||
| 407 | 539 | return 1; |
| 408 | 540 | return 0; |
| 409 | 541 | } |
| 410 | 542 | |
| 411 | 543 | /* ========================================================================= */ |
| 412 | -int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength) | |
| 413 | - z_streamp strm; | |
| 414 | - const Bytef *dictionary; | |
| 415 | - uInt dictLength; | |
| 416 | -{ | |
| 544 | +int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary, | |
| 545 | + uInt dictLength) { | |
| 417 | 546 | deflate_state *s; |
| 418 | 547 | uInt str, n; |
| 419 | 548 | int wrap; |
| 420 | 549 | unsigned avail; |
| 421 | 550 | z_const unsigned char *next; |
| @@ -476,15 +605,12 @@ | ||
| 476 | 605 | s->wrap = wrap; |
| 477 | 606 | return Z_OK; |
| 478 | 607 | } |
| 479 | 608 | |
| 480 | 609 | /* ========================================================================= */ |
| 481 | -int ZEXPORT deflateGetDictionary(strm, dictionary, dictLength) | |
| 482 | - z_streamp strm; | |
| 483 | - Bytef *dictionary; | |
| 484 | - uInt *dictLength; | |
| 485 | -{ | |
| 610 | +int ZEXPORT deflateGetDictionary(z_streamp strm, Bytef *dictionary, | |
| 611 | + uInt *dictLength) { | |
| 486 | 612 | deflate_state *s; |
| 487 | 613 | uInt len; |
| 488 | 614 | |
| 489 | 615 | if (deflateStateCheck(strm)) |
| 490 | 616 | return Z_STREAM_ERROR; |
| @@ -498,13 +624,11 @@ | ||
| 498 | 624 | *dictLength = len; |
| 499 | 625 | return Z_OK; |
| 500 | 626 | } |
| 501 | 627 | |
| 502 | 628 | /* ========================================================================= */ |
| 503 | -int ZEXPORT deflateResetKeep(strm) | |
| 504 | - z_streamp strm; | |
| 505 | -{ | |
| 629 | +int ZEXPORT deflateResetKeep(z_streamp strm) { | |
| 506 | 630 | deflate_state *s; |
| 507 | 631 | |
| 508 | 632 | if (deflateStateCheck(strm)) { |
| 509 | 633 | return Z_STREAM_ERROR; |
| 510 | 634 | } |
| @@ -534,54 +658,65 @@ | ||
| 534 | 658 | |
| 535 | 659 | _tr_init(s); |
| 536 | 660 | |
| 537 | 661 | return Z_OK; |
| 538 | 662 | } |
| 663 | + | |
| 664 | +/* =========================================================================== | |
| 665 | + * Initialize the "longest match" routines for a new zlib stream | |
| 666 | + */ | |
| 667 | +local void lm_init(deflate_state *s) { | |
| 668 | + s->window_size = (ulg)2L*s->w_size; | |
| 669 | + | |
| 670 | + CLEAR_HASH(s); | |
| 671 | + | |
| 672 | + /* Set the default configuration parameters: | |
| 673 | + */ | |
| 674 | + s->max_lazy_match = configuration_table[s->level].max_lazy; | |
| 675 | + s->good_match = configuration_table[s->level].good_length; | |
| 676 | + s->nice_match = configuration_table[s->level].nice_length; | |
| 677 | + s->max_chain_length = configuration_table[s->level].max_chain; | |
| 678 | + | |
| 679 | + s->strstart = 0; | |
| 680 | + s->block_start = 0L; | |
| 681 | + s->lookahead = 0; | |
| 682 | + s->insert = 0; | |
| 683 | + s->match_length = s->prev_length = MIN_MATCH-1; | |
| 684 | + s->match_available = 0; | |
| 685 | + s->ins_h = 0; | |
| 686 | +} | |
| 539 | 687 | |
| 540 | 688 | /* ========================================================================= */ |
| 541 | -int ZEXPORT deflateReset(strm) | |
| 542 | - z_streamp strm; | |
| 543 | -{ | |
| 689 | +int ZEXPORT deflateReset(z_streamp strm) { | |
| 544 | 690 | int ret; |
| 545 | 691 | |
| 546 | 692 | ret = deflateResetKeep(strm); |
| 547 | 693 | if (ret == Z_OK) |
| 548 | 694 | lm_init(strm->state); |
| 549 | 695 | return ret; |
| 550 | 696 | } |
| 551 | 697 | |
| 552 | 698 | /* ========================================================================= */ |
| 553 | -int ZEXPORT deflateSetHeader(strm, head) | |
| 554 | - z_streamp strm; | |
| 555 | - gz_headerp head; | |
| 556 | -{ | |
| 699 | +int ZEXPORT deflateSetHeader(z_streamp strm, gz_headerp head) { | |
| 557 | 700 | if (deflateStateCheck(strm) || strm->state->wrap != 2) |
| 558 | 701 | return Z_STREAM_ERROR; |
| 559 | 702 | strm->state->gzhead = head; |
| 560 | 703 | return Z_OK; |
| 561 | 704 | } |
| 562 | 705 | |
| 563 | 706 | /* ========================================================================= */ |
| 564 | -int ZEXPORT deflatePending(strm, pending, bits) | |
| 565 | - unsigned *pending; | |
| 566 | - int *bits; | |
| 567 | - z_streamp strm; | |
| 568 | -{ | |
| 707 | +int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) { | |
| 569 | 708 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 570 | 709 | if (pending != Z_NULL) |
| 571 | 710 | *pending = strm->state->pending; |
| 572 | 711 | if (bits != Z_NULL) |
| 573 | 712 | *bits = strm->state->bi_valid; |
| 574 | 713 | return Z_OK; |
| 575 | 714 | } |
| 576 | 715 | |
| 577 | 716 | /* ========================================================================= */ |
| 578 | -int ZEXPORT deflatePrime(strm, bits, value) | |
| 579 | - z_streamp strm; | |
| 580 | - int bits; | |
| 581 | - int value; | |
| 582 | -{ | |
| 717 | +int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) { | |
| 583 | 718 | deflate_state *s; |
| 584 | 719 | int put; |
| 585 | 720 | |
| 586 | 721 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 587 | 722 | s = strm->state; |
| @@ -600,15 +735,11 @@ | ||
| 600 | 735 | } while (bits); |
| 601 | 736 | return Z_OK; |
| 602 | 737 | } |
| 603 | 738 | |
| 604 | 739 | /* ========================================================================= */ |
| 605 | -int ZEXPORT deflateParams(strm, level, strategy) | |
| 606 | - z_streamp strm; | |
| 607 | - int level; | |
| 608 | - int strategy; | |
| 609 | -{ | |
| 740 | +int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) { | |
| 610 | 741 | deflate_state *s; |
| 611 | 742 | compress_func func; |
| 612 | 743 | |
| 613 | 744 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 614 | 745 | s = strm->state; |
| @@ -649,17 +780,12 @@ | ||
| 649 | 780 | s->strategy = strategy; |
| 650 | 781 | return Z_OK; |
| 651 | 782 | } |
| 652 | 783 | |
| 653 | 784 | /* ========================================================================= */ |
| 654 | -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) | |
| 655 | - z_streamp strm; | |
| 656 | - int good_length; | |
| 657 | - int max_lazy; | |
| 658 | - int nice_length; | |
| 659 | - int max_chain; | |
| 660 | -{ | |
| 785 | +int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy, | |
| 786 | + int nice_length, int max_chain) { | |
| 661 | 787 | deflate_state *s; |
| 662 | 788 | |
| 663 | 789 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 664 | 790 | s = strm->state; |
| 665 | 791 | s->good_match = (uInt)good_length; |
| @@ -691,14 +817,11 @@ | ||
| 691 | 817 | * per 8-bit byte, plus 10 bits for every block. The smallest block size for |
| 692 | 818 | * which this can occur is 255 (memLevel == 2). |
| 693 | 819 | * |
| 694 | 820 | * Shifts are used to approximate divisions, for speed. |
| 695 | 821 | */ |
| 696 | -uLong ZEXPORT deflateBound(strm, sourceLen) | |
| 697 | - z_streamp strm; | |
| 698 | - uLong sourceLen; | |
| 699 | -{ | |
| 822 | +uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) { | |
| 700 | 823 | deflate_state *s; |
| 701 | 824 | uLong fixedlen, storelen, wraplen; |
| 702 | 825 | |
| 703 | 826 | /* upper bound for fixed blocks with 9-bit literals and length 255 |
| 704 | 827 | (memLevel == 2, which is the lowest that may not use stored blocks) -- |
| @@ -750,11 +873,12 @@ | ||
| 750 | 873 | wraplen = 6; |
| 751 | 874 | } |
| 752 | 875 | |
| 753 | 876 | /* if not default parameters, return one of the conservative bounds */ |
| 754 | 877 | if (s->w_bits != 15 || s->hash_bits != 8 + 7) |
| 755 | - return (s->w_bits <= s->hash_bits ? fixedlen : storelen) + wraplen; | |
| 878 | + return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) + | |
| 879 | + wraplen; | |
| 756 | 880 | |
| 757 | 881 | /* default settings: return tight bound for that case -- ~0.03% overhead |
| 758 | 882 | plus a small constant */ |
| 759 | 883 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + |
| 760 | 884 | (sourceLen >> 25) + 13 - 6 + wraplen; |
| @@ -763,14 +887,11 @@ | ||
| 763 | 887 | /* ========================================================================= |
| 764 | 888 | * Put a short in the pending buffer. The 16-bit value is put in MSB order. |
| 765 | 889 | * IN assertion: the stream state is correct and there is enough room in |
| 766 | 890 | * pending_buf. |
| 767 | 891 | */ |
| 768 | -local void putShortMSB(s, b) | |
| 769 | - deflate_state *s; | |
| 770 | - uInt b; | |
| 771 | -{ | |
| 892 | +local void putShortMSB(deflate_state *s, uInt b) { | |
| 772 | 893 | put_byte(s, (Byte)(b >> 8)); |
| 773 | 894 | put_byte(s, (Byte)(b & 0xff)); |
| 774 | 895 | } |
| 775 | 896 | |
| 776 | 897 | /* ========================================================================= |
| @@ -777,13 +898,11 @@ | ||
| 777 | 898 | * Flush as much pending output as possible. All deflate() output, except for |
| 778 | 899 | * some deflate_stored() output, goes through this function so some |
| 779 | 900 | * applications may wish to modify it to avoid allocating a large |
| 780 | 901 | * strm->next_out buffer and copying into it. (See also read_buf()). |
| 781 | 902 | */ |
| 782 | -local void flush_pending(strm) | |
| 783 | - z_streamp strm; | |
| 784 | -{ | |
| 903 | +local void flush_pending(z_streamp strm) { | |
| 785 | 904 | unsigned len; |
| 786 | 905 | deflate_state *s = strm->state; |
| 787 | 906 | |
| 788 | 907 | _tr_flush_bits(s); |
| 789 | 908 | len = s->pending; |
| @@ -810,14 +929,11 @@ | ||
| 810 | 929 | strm->adler = crc32(strm->adler, s->pending_buf + (beg), \ |
| 811 | 930 | s->pending - (beg)); \ |
| 812 | 931 | } while (0) |
| 813 | 932 | |
| 814 | 933 | /* ========================================================================= */ |
| 815 | -int ZEXPORT deflate(strm, flush) | |
| 816 | - z_streamp strm; | |
| 817 | - int flush; | |
| 818 | -{ | |
| 934 | +int ZEXPORT deflate(z_streamp strm, int flush) { | |
| 819 | 935 | int old_flush; /* value of flush param for previous deflate call */ |
| 820 | 936 | deflate_state *s; |
| 821 | 937 | |
| 822 | 938 | if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) { |
| 823 | 939 | return Z_STREAM_ERROR; |
| @@ -1125,13 +1241,11 @@ | ||
| 1125 | 1241 | if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ |
| 1126 | 1242 | return s->pending != 0 ? Z_OK : Z_STREAM_END; |
| 1127 | 1243 | } |
| 1128 | 1244 | |
| 1129 | 1245 | /* ========================================================================= */ |
| 1130 | -int ZEXPORT deflateEnd(strm) | |
| 1131 | - z_streamp strm; | |
| 1132 | -{ | |
| 1246 | +int ZEXPORT deflateEnd(z_streamp strm) { | |
| 1133 | 1247 | int status; |
| 1134 | 1248 | |
| 1135 | 1249 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1136 | 1250 | |
| 1137 | 1251 | status = strm->state->status; |
| @@ -1151,15 +1265,14 @@ | ||
| 1151 | 1265 | /* ========================================================================= |
| 1152 | 1266 | * Copy the source state to the destination state. |
| 1153 | 1267 | * To simplify the source, this is not supported for 16-bit MSDOS (which |
| 1154 | 1268 | * doesn't have enough memory anyway to duplicate compression states). |
| 1155 | 1269 | */ |
| 1156 | -int ZEXPORT deflateCopy(dest, source) | |
| 1157 | - z_streamp dest; | |
| 1158 | - z_streamp source; | |
| 1159 | -{ | |
| 1270 | +int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) { | |
| 1160 | 1271 | #ifdef MAXSEG_64K |
| 1272 | + (void)dest; | |
| 1273 | + (void)source; | |
| 1161 | 1274 | return Z_STREAM_ERROR; |
| 1162 | 1275 | #else |
| 1163 | 1276 | deflate_state *ds; |
| 1164 | 1277 | deflate_state *ss; |
| 1165 | 1278 | |
| @@ -1203,70 +1316,10 @@ | ||
| 1203 | 1316 | |
| 1204 | 1317 | return Z_OK; |
| 1205 | 1318 | #endif /* MAXSEG_64K */ |
| 1206 | 1319 | } |
| 1207 | 1320 | |
| 1208 | -/* =========================================================================== | |
| 1209 | - * Read a new buffer from the current input stream, update the adler32 | |
| 1210 | - * and total number of bytes read. All deflate() input goes through | |
| 1211 | - * this function so some applications may wish to modify it to avoid | |
| 1212 | - * allocating a large strm->next_in buffer and copying from it. | |
| 1213 | - * (See also flush_pending()). | |
| 1214 | - */ | |
| 1215 | -local unsigned read_buf(strm, buf, size) | |
| 1216 | - z_streamp strm; | |
| 1217 | - Bytef *buf; | |
| 1218 | - unsigned size; | |
| 1219 | -{ | |
| 1220 | - unsigned len = strm->avail_in; | |
| 1221 | - | |
| 1222 | - if (len > size) len = size; | |
| 1223 | - if (len == 0) return 0; | |
| 1224 | - | |
| 1225 | - strm->avail_in -= len; | |
| 1226 | - | |
| 1227 | - zmemcpy(buf, strm->next_in, len); | |
| 1228 | - if (strm->state->wrap == 1) { | |
| 1229 | - strm->adler = adler32(strm->adler, buf, len); | |
| 1230 | - } | |
| 1231 | -#ifdef GZIP | |
| 1232 | - else if (strm->state->wrap == 2) { | |
| 1233 | - strm->adler = crc32(strm->adler, buf, len); | |
| 1234 | - } | |
| 1235 | -#endif | |
| 1236 | - strm->next_in += len; | |
| 1237 | - strm->total_in += len; | |
| 1238 | - | |
| 1239 | - return len; | |
| 1240 | -} | |
| 1241 | - | |
| 1242 | -/* =========================================================================== | |
| 1243 | - * Initialize the "longest match" routines for a new zlib stream | |
| 1244 | - */ | |
| 1245 | -local void lm_init(s) | |
| 1246 | - deflate_state *s; | |
| 1247 | -{ | |
| 1248 | - s->window_size = (ulg)2L*s->w_size; | |
| 1249 | - | |
| 1250 | - CLEAR_HASH(s); | |
| 1251 | - | |
| 1252 | - /* Set the default configuration parameters: | |
| 1253 | - */ | |
| 1254 | - s->max_lazy_match = configuration_table[s->level].max_lazy; | |
| 1255 | - s->good_match = configuration_table[s->level].good_length; | |
| 1256 | - s->nice_match = configuration_table[s->level].nice_length; | |
| 1257 | - s->max_chain_length = configuration_table[s->level].max_chain; | |
| 1258 | - | |
| 1259 | - s->strstart = 0; | |
| 1260 | - s->block_start = 0L; | |
| 1261 | - s->lookahead = 0; | |
| 1262 | - s->insert = 0; | |
| 1263 | - s->match_length = s->prev_length = MIN_MATCH-1; | |
| 1264 | - s->match_available = 0; | |
| 1265 | - s->ins_h = 0; | |
| 1266 | -} | |
| 1267 | - | |
| 1268 | 1321 | #ifndef FASTEST |
| 1269 | 1322 | /* =========================================================================== |
| 1270 | 1323 | * Set match_start to the longest match starting at the given string and |
| 1271 | 1324 | * return its length. Matches shorter or equal to prev_length are discarded, |
| 1272 | 1325 | * in which case the result is equal to prev_length and match_start is |
| @@ -1273,14 +1326,11 @@ | ||
| 1273 | 1326 | * garbage. |
| 1274 | 1327 | * IN assertions: cur_match is the head of the hash chain for the current |
| 1275 | 1328 | * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 |
| 1276 | 1329 | * OUT assertion: the match length is not greater than s->lookahead. |
| 1277 | 1330 | */ |
| 1278 | -local uInt longest_match(s, cur_match) | |
| 1279 | - deflate_state *s; | |
| 1280 | - IPos cur_match; /* current match */ | |
| 1281 | -{ | |
| 1331 | +local uInt longest_match(deflate_state *s, IPos cur_match) { | |
| 1282 | 1332 | unsigned chain_length = s->max_chain_length;/* max hash chain length */ |
| 1283 | 1333 | register Bytef *scan = s->window + s->strstart; /* current string */ |
| 1284 | 1334 | register Bytef *match; /* matched string */ |
| 1285 | 1335 | register int len; /* length of current match */ |
| 1286 | 1336 | int best_len = (int)s->prev_length; /* best match length so far */ |
| @@ -1424,14 +1474,11 @@ | ||
| 1424 | 1474 | #else /* FASTEST */ |
| 1425 | 1475 | |
| 1426 | 1476 | /* --------------------------------------------------------------------------- |
| 1427 | 1477 | * Optimized version for FASTEST only |
| 1428 | 1478 | */ |
| 1429 | -local uInt longest_match(s, cur_match) | |
| 1430 | - deflate_state *s; | |
| 1431 | - IPos cur_match; /* current match */ | |
| 1432 | -{ | |
| 1479 | +local uInt longest_match(deflate_state *s, IPos cur_match) { | |
| 1433 | 1480 | register Bytef *scan = s->window + s->strstart; /* current string */ |
| 1434 | 1481 | register Bytef *match; /* matched string */ |
| 1435 | 1482 | register int len; /* length of current match */ |
| 1436 | 1483 | register Bytef *strend = s->window + s->strstart + MAX_MATCH; |
| 1437 | 1484 | |
| @@ -1488,15 +1535,11 @@ | ||
| 1488 | 1535 | /* result of memcmp for equal strings */ |
| 1489 | 1536 | |
| 1490 | 1537 | /* =========================================================================== |
| 1491 | 1538 | * Check that the match at match_start is indeed a match. |
| 1492 | 1539 | */ |
| 1493 | -local void check_match(s, start, match, length) | |
| 1494 | - deflate_state *s; | |
| 1495 | - IPos start, match; | |
| 1496 | - int length; | |
| 1497 | -{ | |
| 1540 | +local void check_match(deflate_state *s, IPos start, IPos match, int length) { | |
| 1498 | 1541 | /* check that the match is indeed a match */ |
| 1499 | 1542 | if (zmemcmp(s->window + match, |
| 1500 | 1543 | s->window + start, length) != EQUAL) { |
| 1501 | 1544 | fprintf(stderr, " start %u, match %u, length %d\n", |
| 1502 | 1545 | start, match, length); |
| @@ -1512,141 +1555,10 @@ | ||
| 1512 | 1555 | } |
| 1513 | 1556 | #else |
| 1514 | 1557 | # define check_match(s, start, match, length) |
| 1515 | 1558 | #endif /* ZLIB_DEBUG */ |
| 1516 | 1559 | |
| 1517 | -/* =========================================================================== | |
| 1518 | - * Fill the window when the lookahead becomes insufficient. | |
| 1519 | - * Updates strstart and lookahead. | |
| 1520 | - * | |
| 1521 | - * IN assertion: lookahead < MIN_LOOKAHEAD | |
| 1522 | - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD | |
| 1523 | - * At least one byte has been read, or avail_in == 0; reads are | |
| 1524 | - * performed for at least two bytes (required for the zip translate_eol | |
| 1525 | - * option -- not supported here). | |
| 1526 | - */ | |
| 1527 | -local void fill_window(s) | |
| 1528 | - deflate_state *s; | |
| 1529 | -{ | |
| 1530 | - unsigned n; | |
| 1531 | - unsigned more; /* Amount of free space at the end of the window. */ | |
| 1532 | - uInt wsize = s->w_size; | |
| 1533 | - | |
| 1534 | - Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); | |
| 1535 | - | |
| 1536 | - do { | |
| 1537 | - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); | |
| 1538 | - | |
| 1539 | - /* Deal with !@#$% 64K limit: */ | |
| 1540 | - if (sizeof(int) <= 2) { | |
| 1541 | - if (more == 0 && s->strstart == 0 && s->lookahead == 0) { | |
| 1542 | - more = wsize; | |
| 1543 | - | |
| 1544 | - } else if (more == (unsigned)(-1)) { | |
| 1545 | - /* Very unlikely, but possible on 16 bit machine if | |
| 1546 | - * strstart == 0 && lookahead == 1 (input done a byte at time) | |
| 1547 | - */ | |
| 1548 | - more--; | |
| 1549 | - } | |
| 1550 | - } | |
| 1551 | - | |
| 1552 | - /* If the window is almost full and there is insufficient lookahead, | |
| 1553 | - * move the upper half to the lower one to make room in the upper half. | |
| 1554 | - */ | |
| 1555 | - if (s->strstart >= wsize + MAX_DIST(s)) { | |
| 1556 | - | |
| 1557 | - zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more); | |
| 1558 | - s->match_start -= wsize; | |
| 1559 | - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ | |
| 1560 | - s->block_start -= (long) wsize; | |
| 1561 | - if (s->insert > s->strstart) | |
| 1562 | - s->insert = s->strstart; | |
| 1563 | - slide_hash(s); | |
| 1564 | - more += wsize; | |
| 1565 | - } | |
| 1566 | - if (s->strm->avail_in == 0) break; | |
| 1567 | - | |
| 1568 | - /* If there was no sliding: | |
| 1569 | - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && | |
| 1570 | - * more == window_size - lookahead - strstart | |
| 1571 | - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) | |
| 1572 | - * => more >= window_size - 2*WSIZE + 2 | |
| 1573 | - * In the BIG_MEM or MMAP case (not yet supported), | |
| 1574 | - * window_size == input_size + MIN_LOOKAHEAD && | |
| 1575 | - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. | |
| 1576 | - * Otherwise, window_size == 2*WSIZE so more >= 2. | |
| 1577 | - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. | |
| 1578 | - */ | |
| 1579 | - Assert(more >= 2, "more < 2"); | |
| 1580 | - | |
| 1581 | - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); | |
| 1582 | - s->lookahead += n; | |
| 1583 | - | |
| 1584 | - /* Initialize the hash value now that we have some input: */ | |
| 1585 | - if (s->lookahead + s->insert >= MIN_MATCH) { | |
| 1586 | - uInt str = s->strstart - s->insert; | |
| 1587 | - s->ins_h = s->window[str]; | |
| 1588 | - UPDATE_HASH(s, s->ins_h, s->window[str + 1]); | |
| 1589 | -#if MIN_MATCH != 3 | |
| 1590 | - Call UPDATE_HASH() MIN_MATCH-3 more times | |
| 1591 | -#endif | |
| 1592 | - while (s->insert) { | |
| 1593 | - UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); | |
| 1594 | -#ifndef FASTEST | |
| 1595 | - s->prev[str & s->w_mask] = s->head[s->ins_h]; | |
| 1596 | -#endif | |
| 1597 | - s->head[s->ins_h] = (Pos)str; | |
| 1598 | - str++; | |
| 1599 | - s->insert--; | |
| 1600 | - if (s->lookahead + s->insert < MIN_MATCH) | |
| 1601 | - break; | |
| 1602 | - } | |
| 1603 | - } | |
| 1604 | - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, | |
| 1605 | - * but this is not important since only literal bytes will be emitted. | |
| 1606 | - */ | |
| 1607 | - | |
| 1608 | - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); | |
| 1609 | - | |
| 1610 | - /* If the WIN_INIT bytes after the end of the current data have never been | |
| 1611 | - * written, then zero those bytes in order to avoid memory check reports of | |
| 1612 | - * the use of uninitialized (or uninitialised as Julian writes) bytes by | |
| 1613 | - * the longest match routines. Update the high water mark for the next | |
| 1614 | - * time through here. WIN_INIT is set to MAX_MATCH since the longest match | |
| 1615 | - * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. | |
| 1616 | - */ | |
| 1617 | - if (s->high_water < s->window_size) { | |
| 1618 | - ulg curr = s->strstart + (ulg)(s->lookahead); | |
| 1619 | - ulg init; | |
| 1620 | - | |
| 1621 | - if (s->high_water < curr) { | |
| 1622 | - /* Previous high water mark below current data -- zero WIN_INIT | |
| 1623 | - * bytes or up to end of window, whichever is less. | |
| 1624 | - */ | |
| 1625 | - init = s->window_size - curr; | |
| 1626 | - if (init > WIN_INIT) | |
| 1627 | - init = WIN_INIT; | |
| 1628 | - zmemzero(s->window + curr, (unsigned)init); | |
| 1629 | - s->high_water = curr + init; | |
| 1630 | - } | |
| 1631 | - else if (s->high_water < (ulg)curr + WIN_INIT) { | |
| 1632 | - /* High water mark at or above current data, but below current data | |
| 1633 | - * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up | |
| 1634 | - * to end of window, whichever is less. | |
| 1635 | - */ | |
| 1636 | - init = (ulg)curr + WIN_INIT - s->high_water; | |
| 1637 | - if (init > s->window_size - s->high_water) | |
| 1638 | - init = s->window_size - s->high_water; | |
| 1639 | - zmemzero(s->window + s->high_water, (unsigned)init); | |
| 1640 | - s->high_water += init; | |
| 1641 | - } | |
| 1642 | - } | |
| 1643 | - | |
| 1644 | - Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, | |
| 1645 | - "not enough room for search"); | |
| 1646 | -} | |
| 1647 | - | |
| 1648 | 1560 | /* =========================================================================== |
| 1649 | 1561 | * Flush the current block, with given end-of-file flag. |
| 1650 | 1562 | * IN assertion: strstart is set to the end of the current match. |
| 1651 | 1563 | */ |
| 1652 | 1564 | #define FLUSH_BLOCK_ONLY(s, last) { \ |
| @@ -1685,14 +1597,11 @@ | ||
| 1685 | 1597 | * |
| 1686 | 1598 | * deflate_stored() is written to minimize the number of times an input byte is |
| 1687 | 1599 | * copied. It is most efficient with large input and output buffers, which |
| 1688 | 1600 | * maximizes the opportunities to have a single copy from next_in to next_out. |
| 1689 | 1601 | */ |
| 1690 | -local block_state deflate_stored(s, flush) | |
| 1691 | - deflate_state *s; | |
| 1692 | - int flush; | |
| 1693 | -{ | |
| 1602 | +local block_state deflate_stored(deflate_state *s, int flush) { | |
| 1694 | 1603 | /* Smallest worthy block size when not flushing or finishing. By default |
| 1695 | 1604 | * this is 32K. This can be as small as 507 bytes for memLevel == 1. For |
| 1696 | 1605 | * large input and output buffers, the stored block size will be larger. |
| 1697 | 1606 | */ |
| 1698 | 1607 | unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size); |
| @@ -1872,14 +1781,11 @@ | ||
| 1872 | 1781 | * block state. |
| 1873 | 1782 | * This function does not perform lazy evaluation of matches and inserts |
| 1874 | 1783 | * new strings in the dictionary only for unmatched strings or for short |
| 1875 | 1784 | * matches. It is used only for the fast compression options. |
| 1876 | 1785 | */ |
| 1877 | -local block_state deflate_fast(s, flush) | |
| 1878 | - deflate_state *s; | |
| 1879 | - int flush; | |
| 1880 | -{ | |
| 1786 | +local block_state deflate_fast(deflate_state *s, int flush) { | |
| 1881 | 1787 | IPos hash_head; /* head of the hash chain */ |
| 1882 | 1788 | int bflush; /* set if current block must be flushed */ |
| 1883 | 1789 | |
| 1884 | 1790 | for (;;) { |
| 1885 | 1791 | /* Make sure that we always have enough lookahead, except |
| @@ -1974,14 +1880,11 @@ | ||
| 1974 | 1880 | /* =========================================================================== |
| 1975 | 1881 | * Same as above, but achieves better compression. We use a lazy |
| 1976 | 1882 | * evaluation for matches: a match is finally adopted only if there is |
| 1977 | 1883 | * no better match at the next window position. |
| 1978 | 1884 | */ |
| 1979 | -local block_state deflate_slow(s, flush) | |
| 1980 | - deflate_state *s; | |
| 1981 | - int flush; | |
| 1982 | -{ | |
| 1885 | +local block_state deflate_slow(deflate_state *s, int flush) { | |
| 1983 | 1886 | IPos hash_head; /* head of hash chain */ |
| 1984 | 1887 | int bflush; /* set if current block must be flushed */ |
| 1985 | 1888 | |
| 1986 | 1889 | /* Process the input block. */ |
| 1987 | 1890 | for (;;) { |
| @@ -2105,14 +2008,11 @@ | ||
| 2105 | 2008 | /* =========================================================================== |
| 2106 | 2009 | * For Z_RLE, simply look for runs of bytes, generate matches only of distance |
| 2107 | 2010 | * one. Do not maintain a hash table. (It will be regenerated if this run of |
| 2108 | 2011 | * deflate switches away from Z_RLE.) |
| 2109 | 2012 | */ |
| 2110 | -local block_state deflate_rle(s, flush) | |
| 2111 | - deflate_state *s; | |
| 2112 | - int flush; | |
| 2113 | -{ | |
| 2013 | +local block_state deflate_rle(deflate_state *s, int flush) { | |
| 2114 | 2014 | int bflush; /* set if current block must be flushed */ |
| 2115 | 2015 | uInt prev; /* byte at distance one to match */ |
| 2116 | 2016 | Bytef *scan, *strend; /* scan goes up to strend for length of run */ |
| 2117 | 2017 | |
| 2118 | 2018 | for (;;) { |
| @@ -2179,14 +2079,11 @@ | ||
| 2179 | 2079 | |
| 2180 | 2080 | /* =========================================================================== |
| 2181 | 2081 | * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. |
| 2182 | 2082 | * (It will be regenerated if this run of deflate switches away from Huffman.) |
| 2183 | 2083 | */ |
| 2184 | -local block_state deflate_huff(s, flush) | |
| 2185 | - deflate_state *s; | |
| 2186 | - int flush; | |
| 2187 | -{ | |
| 2084 | +local block_state deflate_huff(deflate_state *s, int flush) { | |
| 2188 | 2085 | int bflush; /* set if current block must be flushed */ |
| 2189 | 2086 | |
| 2190 | 2087 | for (;;) { |
| 2191 | 2088 | /* Make sure that we have a literal to write. */ |
| 2192 | 2089 | if (s->lookahead == 0) { |
| 2193 | 2090 |
| --- compat/zlib/deflate.c | |
| +++ compat/zlib/deflate.c | |
| @@ -1,7 +1,7 @@ | |
| 1 | /* deflate.c -- compress data using the deflation algorithm |
| 2 | * Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * ALGORITHM |
| @@ -50,51 +50,35 @@ | |
| 50 | /* @(#) $Id$ */ |
| 51 | |
| 52 | #include "deflate.h" |
| 53 | |
| 54 | const char deflate_copyright[] = |
| 55 | " deflate 1.2.13 Copyright 1995-2022 Jean-loup Gailly and Mark Adler "; |
| 56 | /* |
| 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 |
| 59 | include such an acknowledgment, I would appreciate that you keep this |
| 60 | copyright string in the executable of your product. |
| 61 | */ |
| 62 | |
| 63 | /* =========================================================================== |
| 64 | * Function prototypes. |
| 65 | */ |
| 66 | typedef enum { |
| 67 | need_more, /* block not completed, need more input or more output */ |
| 68 | block_done, /* block flush performed */ |
| 69 | finish_started, /* finish started, need only more output at next deflate */ |
| 70 | finish_done /* finish done, accept no more input or output */ |
| 71 | } block_state; |
| 72 | |
| 73 | typedef block_state (*compress_func) OF((deflate_state *s, int flush)); |
| 74 | /* Compression function. Returns the block state after the call. */ |
| 75 | |
| 76 | local int deflateStateCheck OF((z_streamp strm)); |
| 77 | local void slide_hash OF((deflate_state *s)); |
| 78 | local void fill_window OF((deflate_state *s)); |
| 79 | local block_state deflate_stored OF((deflate_state *s, int flush)); |
| 80 | local block_state deflate_fast OF((deflate_state *s, int flush)); |
| 81 | #ifndef FASTEST |
| 82 | local block_state deflate_slow OF((deflate_state *s, int flush)); |
| 83 | #endif |
| 84 | local block_state deflate_rle OF((deflate_state *s, int flush)); |
| 85 | local block_state deflate_huff OF((deflate_state *s, int flush)); |
| 86 | local void lm_init OF((deflate_state *s)); |
| 87 | local void putShortMSB OF((deflate_state *s, uInt b)); |
| 88 | local void flush_pending OF((z_streamp strm)); |
| 89 | local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); |
| 90 | local uInt longest_match OF((deflate_state *s, IPos cur_match)); |
| 91 | |
| 92 | #ifdef ZLIB_DEBUG |
| 93 | local void check_match OF((deflate_state *s, IPos start, IPos match, |
| 94 | int length)); |
| 95 | #endif |
| 96 | |
| 97 | /* =========================================================================== |
| 98 | * Local data |
| 99 | */ |
| 100 | |
| @@ -193,13 +177,16 @@ | |
| 193 | /* =========================================================================== |
| 194 | * Slide the hash table when sliding the window down (could be avoided with 32 |
| 195 | * bit values at the expense of memory usage). We slide even when level == 0 to |
| 196 | * keep the hash table consistent if we switch back to level > 0 later. |
| 197 | */ |
| 198 | local void slide_hash(s) |
| 199 | deflate_state *s; |
| 200 | { |
| 201 | unsigned n, m; |
| 202 | Posf *p; |
| 203 | uInt wsize = s->w_size; |
| 204 | |
| 205 | n = s->hash_size; |
| @@ -218,35 +205,182 @@ | |
| 218 | * its value will never be used. |
| 219 | */ |
| 220 | } while (--n); |
| 221 | #endif |
| 222 | } |
| 223 | |
| 224 | /* ========================================================================= */ |
| 225 | int ZEXPORT deflateInit_(strm, level, version, stream_size) |
| 226 | z_streamp strm; |
| 227 | int level; |
| 228 | const char *version; |
| 229 | int stream_size; |
| 230 | { |
| 231 | return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, |
| 232 | Z_DEFAULT_STRATEGY, version, stream_size); |
| 233 | /* To do: ignore strm->next_in if we use it as window */ |
| 234 | } |
| 235 | |
| 236 | /* ========================================================================= */ |
| 237 | int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, |
| 238 | version, stream_size) |
| 239 | z_streamp strm; |
| 240 | int level; |
| 241 | int method; |
| 242 | int windowBits; |
| 243 | int memLevel; |
| 244 | int strategy; |
| 245 | const char *version; |
| 246 | int stream_size; |
| 247 | { |
| 248 | deflate_state *s; |
| 249 | int wrap = 1; |
| 250 | static const char my_version[] = ZLIB_VERSION; |
| 251 | |
| 252 | if (version == Z_NULL || version[0] != my_version[0] || |
| @@ -384,13 +518,11 @@ | |
| 384 | } |
| 385 | |
| 386 | /* ========================================================================= |
| 387 | * Check for a valid deflate stream state. Return 0 if ok, 1 if not. |
| 388 | */ |
| 389 | local int deflateStateCheck(strm) |
| 390 | z_streamp strm; |
| 391 | { |
| 392 | deflate_state *s; |
| 393 | if (strm == Z_NULL || |
| 394 | strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) |
| 395 | return 1; |
| 396 | s = strm->state; |
| @@ -407,15 +539,12 @@ | |
| 407 | return 1; |
| 408 | return 0; |
| 409 | } |
| 410 | |
| 411 | /* ========================================================================= */ |
| 412 | int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength) |
| 413 | z_streamp strm; |
| 414 | const Bytef *dictionary; |
| 415 | uInt dictLength; |
| 416 | { |
| 417 | deflate_state *s; |
| 418 | uInt str, n; |
| 419 | int wrap; |
| 420 | unsigned avail; |
| 421 | z_const unsigned char *next; |
| @@ -476,15 +605,12 @@ | |
| 476 | s->wrap = wrap; |
| 477 | return Z_OK; |
| 478 | } |
| 479 | |
| 480 | /* ========================================================================= */ |
| 481 | int ZEXPORT deflateGetDictionary(strm, dictionary, dictLength) |
| 482 | z_streamp strm; |
| 483 | Bytef *dictionary; |
| 484 | uInt *dictLength; |
| 485 | { |
| 486 | deflate_state *s; |
| 487 | uInt len; |
| 488 | |
| 489 | if (deflateStateCheck(strm)) |
| 490 | return Z_STREAM_ERROR; |
| @@ -498,13 +624,11 @@ | |
| 498 | *dictLength = len; |
| 499 | return Z_OK; |
| 500 | } |
| 501 | |
| 502 | /* ========================================================================= */ |
| 503 | int ZEXPORT deflateResetKeep(strm) |
| 504 | z_streamp strm; |
| 505 | { |
| 506 | deflate_state *s; |
| 507 | |
| 508 | if (deflateStateCheck(strm)) { |
| 509 | return Z_STREAM_ERROR; |
| 510 | } |
| @@ -534,54 +658,65 @@ | |
| 534 | |
| 535 | _tr_init(s); |
| 536 | |
| 537 | return Z_OK; |
| 538 | } |
| 539 | |
| 540 | /* ========================================================================= */ |
| 541 | int ZEXPORT deflateReset(strm) |
| 542 | z_streamp strm; |
| 543 | { |
| 544 | int ret; |
| 545 | |
| 546 | ret = deflateResetKeep(strm); |
| 547 | if (ret == Z_OK) |
| 548 | lm_init(strm->state); |
| 549 | return ret; |
| 550 | } |
| 551 | |
| 552 | /* ========================================================================= */ |
| 553 | int ZEXPORT deflateSetHeader(strm, head) |
| 554 | z_streamp strm; |
| 555 | gz_headerp head; |
| 556 | { |
| 557 | if (deflateStateCheck(strm) || strm->state->wrap != 2) |
| 558 | return Z_STREAM_ERROR; |
| 559 | strm->state->gzhead = head; |
| 560 | return Z_OK; |
| 561 | } |
| 562 | |
| 563 | /* ========================================================================= */ |
| 564 | int ZEXPORT deflatePending(strm, pending, bits) |
| 565 | unsigned *pending; |
| 566 | int *bits; |
| 567 | z_streamp strm; |
| 568 | { |
| 569 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 570 | if (pending != Z_NULL) |
| 571 | *pending = strm->state->pending; |
| 572 | if (bits != Z_NULL) |
| 573 | *bits = strm->state->bi_valid; |
| 574 | return Z_OK; |
| 575 | } |
| 576 | |
| 577 | /* ========================================================================= */ |
| 578 | int ZEXPORT deflatePrime(strm, bits, value) |
| 579 | z_streamp strm; |
| 580 | int bits; |
| 581 | int value; |
| 582 | { |
| 583 | deflate_state *s; |
| 584 | int put; |
| 585 | |
| 586 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 587 | s = strm->state; |
| @@ -600,15 +735,11 @@ | |
| 600 | } while (bits); |
| 601 | return Z_OK; |
| 602 | } |
| 603 | |
| 604 | /* ========================================================================= */ |
| 605 | int ZEXPORT deflateParams(strm, level, strategy) |
| 606 | z_streamp strm; |
| 607 | int level; |
| 608 | int strategy; |
| 609 | { |
| 610 | deflate_state *s; |
| 611 | compress_func func; |
| 612 | |
| 613 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 614 | s = strm->state; |
| @@ -649,17 +780,12 @@ | |
| 649 | s->strategy = strategy; |
| 650 | return Z_OK; |
| 651 | } |
| 652 | |
| 653 | /* ========================================================================= */ |
| 654 | int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) |
| 655 | z_streamp strm; |
| 656 | int good_length; |
| 657 | int max_lazy; |
| 658 | int nice_length; |
| 659 | int max_chain; |
| 660 | { |
| 661 | deflate_state *s; |
| 662 | |
| 663 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 664 | s = strm->state; |
| 665 | s->good_match = (uInt)good_length; |
| @@ -691,14 +817,11 @@ | |
| 691 | * per 8-bit byte, plus 10 bits for every block. The smallest block size for |
| 692 | * which this can occur is 255 (memLevel == 2). |
| 693 | * |
| 694 | * Shifts are used to approximate divisions, for speed. |
| 695 | */ |
| 696 | uLong ZEXPORT deflateBound(strm, sourceLen) |
| 697 | z_streamp strm; |
| 698 | uLong sourceLen; |
| 699 | { |
| 700 | deflate_state *s; |
| 701 | uLong fixedlen, storelen, wraplen; |
| 702 | |
| 703 | /* upper bound for fixed blocks with 9-bit literals and length 255 |
| 704 | (memLevel == 2, which is the lowest that may not use stored blocks) -- |
| @@ -750,11 +873,12 @@ | |
| 750 | wraplen = 6; |
| 751 | } |
| 752 | |
| 753 | /* if not default parameters, return one of the conservative bounds */ |
| 754 | if (s->w_bits != 15 || s->hash_bits != 8 + 7) |
| 755 | return (s->w_bits <= s->hash_bits ? fixedlen : storelen) + wraplen; |
| 756 | |
| 757 | /* default settings: return tight bound for that case -- ~0.03% overhead |
| 758 | plus a small constant */ |
| 759 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + |
| 760 | (sourceLen >> 25) + 13 - 6 + wraplen; |
| @@ -763,14 +887,11 @@ | |
| 763 | /* ========================================================================= |
| 764 | * Put a short in the pending buffer. The 16-bit value is put in MSB order. |
| 765 | * IN assertion: the stream state is correct and there is enough room in |
| 766 | * pending_buf. |
| 767 | */ |
| 768 | local void putShortMSB(s, b) |
| 769 | deflate_state *s; |
| 770 | uInt b; |
| 771 | { |
| 772 | put_byte(s, (Byte)(b >> 8)); |
| 773 | put_byte(s, (Byte)(b & 0xff)); |
| 774 | } |
| 775 | |
| 776 | /* ========================================================================= |
| @@ -777,13 +898,11 @@ | |
| 777 | * Flush as much pending output as possible. All deflate() output, except for |
| 778 | * some deflate_stored() output, goes through this function so some |
| 779 | * applications may wish to modify it to avoid allocating a large |
| 780 | * strm->next_out buffer and copying into it. (See also read_buf()). |
| 781 | */ |
| 782 | local void flush_pending(strm) |
| 783 | z_streamp strm; |
| 784 | { |
| 785 | unsigned len; |
| 786 | deflate_state *s = strm->state; |
| 787 | |
| 788 | _tr_flush_bits(s); |
| 789 | len = s->pending; |
| @@ -810,14 +929,11 @@ | |
| 810 | strm->adler = crc32(strm->adler, s->pending_buf + (beg), \ |
| 811 | s->pending - (beg)); \ |
| 812 | } while (0) |
| 813 | |
| 814 | /* ========================================================================= */ |
| 815 | int ZEXPORT deflate(strm, flush) |
| 816 | z_streamp strm; |
| 817 | int flush; |
| 818 | { |
| 819 | int old_flush; /* value of flush param for previous deflate call */ |
| 820 | deflate_state *s; |
| 821 | |
| 822 | if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) { |
| 823 | return Z_STREAM_ERROR; |
| @@ -1125,13 +1241,11 @@ | |
| 1125 | if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ |
| 1126 | return s->pending != 0 ? Z_OK : Z_STREAM_END; |
| 1127 | } |
| 1128 | |
| 1129 | /* ========================================================================= */ |
| 1130 | int ZEXPORT deflateEnd(strm) |
| 1131 | z_streamp strm; |
| 1132 | { |
| 1133 | int status; |
| 1134 | |
| 1135 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1136 | |
| 1137 | status = strm->state->status; |
| @@ -1151,15 +1265,14 @@ | |
| 1151 | /* ========================================================================= |
| 1152 | * Copy the source state to the destination state. |
| 1153 | * To simplify the source, this is not supported for 16-bit MSDOS (which |
| 1154 | * doesn't have enough memory anyway to duplicate compression states). |
| 1155 | */ |
| 1156 | int ZEXPORT deflateCopy(dest, source) |
| 1157 | z_streamp dest; |
| 1158 | z_streamp source; |
| 1159 | { |
| 1160 | #ifdef MAXSEG_64K |
| 1161 | return Z_STREAM_ERROR; |
| 1162 | #else |
| 1163 | deflate_state *ds; |
| 1164 | deflate_state *ss; |
| 1165 | |
| @@ -1203,70 +1316,10 @@ | |
| 1203 | |
| 1204 | return Z_OK; |
| 1205 | #endif /* MAXSEG_64K */ |
| 1206 | } |
| 1207 | |
| 1208 | /* =========================================================================== |
| 1209 | * Read a new buffer from the current input stream, update the adler32 |
| 1210 | * and total number of bytes read. All deflate() input goes through |
| 1211 | * this function so some applications may wish to modify it to avoid |
| 1212 | * allocating a large strm->next_in buffer and copying from it. |
| 1213 | * (See also flush_pending()). |
| 1214 | */ |
| 1215 | local unsigned read_buf(strm, buf, size) |
| 1216 | z_streamp strm; |
| 1217 | Bytef *buf; |
| 1218 | unsigned size; |
| 1219 | { |
| 1220 | unsigned len = strm->avail_in; |
| 1221 | |
| 1222 | if (len > size) len = size; |
| 1223 | if (len == 0) return 0; |
| 1224 | |
| 1225 | strm->avail_in -= len; |
| 1226 | |
| 1227 | zmemcpy(buf, strm->next_in, len); |
| 1228 | if (strm->state->wrap == 1) { |
| 1229 | strm->adler = adler32(strm->adler, buf, len); |
| 1230 | } |
| 1231 | #ifdef GZIP |
| 1232 | else if (strm->state->wrap == 2) { |
| 1233 | strm->adler = crc32(strm->adler, buf, len); |
| 1234 | } |
| 1235 | #endif |
| 1236 | strm->next_in += len; |
| 1237 | strm->total_in += len; |
| 1238 | |
| 1239 | return len; |
| 1240 | } |
| 1241 | |
| 1242 | /* =========================================================================== |
| 1243 | * Initialize the "longest match" routines for a new zlib stream |
| 1244 | */ |
| 1245 | local void lm_init(s) |
| 1246 | deflate_state *s; |
| 1247 | { |
| 1248 | s->window_size = (ulg)2L*s->w_size; |
| 1249 | |
| 1250 | CLEAR_HASH(s); |
| 1251 | |
| 1252 | /* Set the default configuration parameters: |
| 1253 | */ |
| 1254 | s->max_lazy_match = configuration_table[s->level].max_lazy; |
| 1255 | s->good_match = configuration_table[s->level].good_length; |
| 1256 | s->nice_match = configuration_table[s->level].nice_length; |
| 1257 | s->max_chain_length = configuration_table[s->level].max_chain; |
| 1258 | |
| 1259 | s->strstart = 0; |
| 1260 | s->block_start = 0L; |
| 1261 | s->lookahead = 0; |
| 1262 | s->insert = 0; |
| 1263 | s->match_length = s->prev_length = MIN_MATCH-1; |
| 1264 | s->match_available = 0; |
| 1265 | s->ins_h = 0; |
| 1266 | } |
| 1267 | |
| 1268 | #ifndef FASTEST |
| 1269 | /* =========================================================================== |
| 1270 | * Set match_start to the longest match starting at the given string and |
| 1271 | * return its length. Matches shorter or equal to prev_length are discarded, |
| 1272 | * in which case the result is equal to prev_length and match_start is |
| @@ -1273,14 +1326,11 @@ | |
| 1273 | * garbage. |
| 1274 | * IN assertions: cur_match is the head of the hash chain for the current |
| 1275 | * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 |
| 1276 | * OUT assertion: the match length is not greater than s->lookahead. |
| 1277 | */ |
| 1278 | local uInt longest_match(s, cur_match) |
| 1279 | deflate_state *s; |
| 1280 | IPos cur_match; /* current match */ |
| 1281 | { |
| 1282 | unsigned chain_length = s->max_chain_length;/* max hash chain length */ |
| 1283 | register Bytef *scan = s->window + s->strstart; /* current string */ |
| 1284 | register Bytef *match; /* matched string */ |
| 1285 | register int len; /* length of current match */ |
| 1286 | int best_len = (int)s->prev_length; /* best match length so far */ |
| @@ -1424,14 +1474,11 @@ | |
| 1424 | #else /* FASTEST */ |
| 1425 | |
| 1426 | /* --------------------------------------------------------------------------- |
| 1427 | * Optimized version for FASTEST only |
| 1428 | */ |
| 1429 | local uInt longest_match(s, cur_match) |
| 1430 | deflate_state *s; |
| 1431 | IPos cur_match; /* current match */ |
| 1432 | { |
| 1433 | register Bytef *scan = s->window + s->strstart; /* current string */ |
| 1434 | register Bytef *match; /* matched string */ |
| 1435 | register int len; /* length of current match */ |
| 1436 | register Bytef *strend = s->window + s->strstart + MAX_MATCH; |
| 1437 | |
| @@ -1488,15 +1535,11 @@ | |
| 1488 | /* result of memcmp for equal strings */ |
| 1489 | |
| 1490 | /* =========================================================================== |
| 1491 | * Check that the match at match_start is indeed a match. |
| 1492 | */ |
| 1493 | local void check_match(s, start, match, length) |
| 1494 | deflate_state *s; |
| 1495 | IPos start, match; |
| 1496 | int length; |
| 1497 | { |
| 1498 | /* check that the match is indeed a match */ |
| 1499 | if (zmemcmp(s->window + match, |
| 1500 | s->window + start, length) != EQUAL) { |
| 1501 | fprintf(stderr, " start %u, match %u, length %d\n", |
| 1502 | start, match, length); |
| @@ -1512,141 +1555,10 @@ | |
| 1512 | } |
| 1513 | #else |
| 1514 | # define check_match(s, start, match, length) |
| 1515 | #endif /* ZLIB_DEBUG */ |
| 1516 | |
| 1517 | /* =========================================================================== |
| 1518 | * Fill the window when the lookahead becomes insufficient. |
| 1519 | * Updates strstart and lookahead. |
| 1520 | * |
| 1521 | * IN assertion: lookahead < MIN_LOOKAHEAD |
| 1522 | * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD |
| 1523 | * At least one byte has been read, or avail_in == 0; reads are |
| 1524 | * performed for at least two bytes (required for the zip translate_eol |
| 1525 | * option -- not supported here). |
| 1526 | */ |
| 1527 | local void fill_window(s) |
| 1528 | deflate_state *s; |
| 1529 | { |
| 1530 | unsigned n; |
| 1531 | unsigned more; /* Amount of free space at the end of the window. */ |
| 1532 | uInt wsize = s->w_size; |
| 1533 | |
| 1534 | Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); |
| 1535 | |
| 1536 | do { |
| 1537 | more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); |
| 1538 | |
| 1539 | /* Deal with !@#$% 64K limit: */ |
| 1540 | if (sizeof(int) <= 2) { |
| 1541 | if (more == 0 && s->strstart == 0 && s->lookahead == 0) { |
| 1542 | more = wsize; |
| 1543 | |
| 1544 | } else if (more == (unsigned)(-1)) { |
| 1545 | /* Very unlikely, but possible on 16 bit machine if |
| 1546 | * strstart == 0 && lookahead == 1 (input done a byte at time) |
| 1547 | */ |
| 1548 | more--; |
| 1549 | } |
| 1550 | } |
| 1551 | |
| 1552 | /* If the window is almost full and there is insufficient lookahead, |
| 1553 | * move the upper half to the lower one to make room in the upper half. |
| 1554 | */ |
| 1555 | if (s->strstart >= wsize + MAX_DIST(s)) { |
| 1556 | |
| 1557 | zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more); |
| 1558 | s->match_start -= wsize; |
| 1559 | s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ |
| 1560 | s->block_start -= (long) wsize; |
| 1561 | if (s->insert > s->strstart) |
| 1562 | s->insert = s->strstart; |
| 1563 | slide_hash(s); |
| 1564 | more += wsize; |
| 1565 | } |
| 1566 | if (s->strm->avail_in == 0) break; |
| 1567 | |
| 1568 | /* If there was no sliding: |
| 1569 | * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && |
| 1570 | * more == window_size - lookahead - strstart |
| 1571 | * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) |
| 1572 | * => more >= window_size - 2*WSIZE + 2 |
| 1573 | * In the BIG_MEM or MMAP case (not yet supported), |
| 1574 | * window_size == input_size + MIN_LOOKAHEAD && |
| 1575 | * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. |
| 1576 | * Otherwise, window_size == 2*WSIZE so more >= 2. |
| 1577 | * If there was sliding, more >= WSIZE. So in all cases, more >= 2. |
| 1578 | */ |
| 1579 | Assert(more >= 2, "more < 2"); |
| 1580 | |
| 1581 | n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); |
| 1582 | s->lookahead += n; |
| 1583 | |
| 1584 | /* Initialize the hash value now that we have some input: */ |
| 1585 | if (s->lookahead + s->insert >= MIN_MATCH) { |
| 1586 | uInt str = s->strstart - s->insert; |
| 1587 | s->ins_h = s->window[str]; |
| 1588 | UPDATE_HASH(s, s->ins_h, s->window[str + 1]); |
| 1589 | #if MIN_MATCH != 3 |
| 1590 | Call UPDATE_HASH() MIN_MATCH-3 more times |
| 1591 | #endif |
| 1592 | while (s->insert) { |
| 1593 | UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); |
| 1594 | #ifndef FASTEST |
| 1595 | s->prev[str & s->w_mask] = s->head[s->ins_h]; |
| 1596 | #endif |
| 1597 | s->head[s->ins_h] = (Pos)str; |
| 1598 | str++; |
| 1599 | s->insert--; |
| 1600 | if (s->lookahead + s->insert < MIN_MATCH) |
| 1601 | break; |
| 1602 | } |
| 1603 | } |
| 1604 | /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, |
| 1605 | * but this is not important since only literal bytes will be emitted. |
| 1606 | */ |
| 1607 | |
| 1608 | } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); |
| 1609 | |
| 1610 | /* If the WIN_INIT bytes after the end of the current data have never been |
| 1611 | * written, then zero those bytes in order to avoid memory check reports of |
| 1612 | * the use of uninitialized (or uninitialised as Julian writes) bytes by |
| 1613 | * the longest match routines. Update the high water mark for the next |
| 1614 | * time through here. WIN_INIT is set to MAX_MATCH since the longest match |
| 1615 | * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. |
| 1616 | */ |
| 1617 | if (s->high_water < s->window_size) { |
| 1618 | ulg curr = s->strstart + (ulg)(s->lookahead); |
| 1619 | ulg init; |
| 1620 | |
| 1621 | if (s->high_water < curr) { |
| 1622 | /* Previous high water mark below current data -- zero WIN_INIT |
| 1623 | * bytes or up to end of window, whichever is less. |
| 1624 | */ |
| 1625 | init = s->window_size - curr; |
| 1626 | if (init > WIN_INIT) |
| 1627 | init = WIN_INIT; |
| 1628 | zmemzero(s->window + curr, (unsigned)init); |
| 1629 | s->high_water = curr + init; |
| 1630 | } |
| 1631 | else if (s->high_water < (ulg)curr + WIN_INIT) { |
| 1632 | /* High water mark at or above current data, but below current data |
| 1633 | * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up |
| 1634 | * to end of window, whichever is less. |
| 1635 | */ |
| 1636 | init = (ulg)curr + WIN_INIT - s->high_water; |
| 1637 | if (init > s->window_size - s->high_water) |
| 1638 | init = s->window_size - s->high_water; |
| 1639 | zmemzero(s->window + s->high_water, (unsigned)init); |
| 1640 | s->high_water += init; |
| 1641 | } |
| 1642 | } |
| 1643 | |
| 1644 | Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, |
| 1645 | "not enough room for search"); |
| 1646 | } |
| 1647 | |
| 1648 | /* =========================================================================== |
| 1649 | * Flush the current block, with given end-of-file flag. |
| 1650 | * IN assertion: strstart is set to the end of the current match. |
| 1651 | */ |
| 1652 | #define FLUSH_BLOCK_ONLY(s, last) { \ |
| @@ -1685,14 +1597,11 @@ | |
| 1685 | * |
| 1686 | * deflate_stored() is written to minimize the number of times an input byte is |
| 1687 | * copied. It is most efficient with large input and output buffers, which |
| 1688 | * maximizes the opportunities to have a single copy from next_in to next_out. |
| 1689 | */ |
| 1690 | local block_state deflate_stored(s, flush) |
| 1691 | deflate_state *s; |
| 1692 | int flush; |
| 1693 | { |
| 1694 | /* Smallest worthy block size when not flushing or finishing. By default |
| 1695 | * this is 32K. This can be as small as 507 bytes for memLevel == 1. For |
| 1696 | * large input and output buffers, the stored block size will be larger. |
| 1697 | */ |
| 1698 | unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size); |
| @@ -1872,14 +1781,11 @@ | |
| 1872 | * block state. |
| 1873 | * This function does not perform lazy evaluation of matches and inserts |
| 1874 | * new strings in the dictionary only for unmatched strings or for short |
| 1875 | * matches. It is used only for the fast compression options. |
| 1876 | */ |
| 1877 | local block_state deflate_fast(s, flush) |
| 1878 | deflate_state *s; |
| 1879 | int flush; |
| 1880 | { |
| 1881 | IPos hash_head; /* head of the hash chain */ |
| 1882 | int bflush; /* set if current block must be flushed */ |
| 1883 | |
| 1884 | for (;;) { |
| 1885 | /* Make sure that we always have enough lookahead, except |
| @@ -1974,14 +1880,11 @@ | |
| 1974 | /* =========================================================================== |
| 1975 | * Same as above, but achieves better compression. We use a lazy |
| 1976 | * evaluation for matches: a match is finally adopted only if there is |
| 1977 | * no better match at the next window position. |
| 1978 | */ |
| 1979 | local block_state deflate_slow(s, flush) |
| 1980 | deflate_state *s; |
| 1981 | int flush; |
| 1982 | { |
| 1983 | IPos hash_head; /* head of hash chain */ |
| 1984 | int bflush; /* set if current block must be flushed */ |
| 1985 | |
| 1986 | /* Process the input block. */ |
| 1987 | for (;;) { |
| @@ -2105,14 +2008,11 @@ | |
| 2105 | /* =========================================================================== |
| 2106 | * For Z_RLE, simply look for runs of bytes, generate matches only of distance |
| 2107 | * one. Do not maintain a hash table. (It will be regenerated if this run of |
| 2108 | * deflate switches away from Z_RLE.) |
| 2109 | */ |
| 2110 | local block_state deflate_rle(s, flush) |
| 2111 | deflate_state *s; |
| 2112 | int flush; |
| 2113 | { |
| 2114 | int bflush; /* set if current block must be flushed */ |
| 2115 | uInt prev; /* byte at distance one to match */ |
| 2116 | Bytef *scan, *strend; /* scan goes up to strend for length of run */ |
| 2117 | |
| 2118 | for (;;) { |
| @@ -2179,14 +2079,11 @@ | |
| 2179 | |
| 2180 | /* =========================================================================== |
| 2181 | * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. |
| 2182 | * (It will be regenerated if this run of deflate switches away from Huffman.) |
| 2183 | */ |
| 2184 | local block_state deflate_huff(s, flush) |
| 2185 | deflate_state *s; |
| 2186 | int flush; |
| 2187 | { |
| 2188 | int bflush; /* set if current block must be flushed */ |
| 2189 | |
| 2190 | for (;;) { |
| 2191 | /* Make sure that we have a literal to write. */ |
| 2192 | if (s->lookahead == 0) { |
| 2193 |
| --- compat/zlib/deflate.c | |
| +++ compat/zlib/deflate.c | |
| @@ -1,7 +1,7 @@ | |
| 1 | /* deflate.c -- compress data using the deflation algorithm |
| 2 | * Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ |
| 5 | |
| 6 | /* |
| 7 | * ALGORITHM |
| @@ -50,51 +50,35 @@ | |
| 50 | /* @(#) $Id$ */ |
| 51 | |
| 52 | #include "deflate.h" |
| 53 | |
| 54 | const char deflate_copyright[] = |
| 55 | " deflate 1.3 Copyright 1995-2023 Jean-loup Gailly and Mark Adler "; |
| 56 | /* |
| 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 |
| 59 | include such an acknowledgment, I would appreciate that you keep this |
| 60 | copyright string in the executable of your product. |
| 61 | */ |
| 62 | |
| 63 | typedef enum { |
| 64 | need_more, /* block not completed, need more input or more output */ |
| 65 | block_done, /* block flush performed */ |
| 66 | finish_started, /* finish started, need only more output at next deflate */ |
| 67 | finish_done /* finish done, accept no more input or output */ |
| 68 | } block_state; |
| 69 | |
| 70 | typedef block_state (*compress_func)(deflate_state *s, int flush); |
| 71 | /* Compression function. Returns the block state after the call. */ |
| 72 | |
| 73 | local block_state deflate_stored(deflate_state *s, int flush); |
| 74 | local block_state deflate_fast(deflate_state *s, int flush); |
| 75 | #ifndef FASTEST |
| 76 | local block_state deflate_slow(deflate_state *s, int flush); |
| 77 | #endif |
| 78 | local block_state deflate_rle(deflate_state *s, int flush); |
| 79 | local block_state deflate_huff(deflate_state *s, int flush); |
| 80 | |
| 81 | /* =========================================================================== |
| 82 | * Local data |
| 83 | */ |
| 84 | |
| @@ -193,13 +177,16 @@ | |
| 177 | /* =========================================================================== |
| 178 | * Slide the hash table when sliding the window down (could be avoided with 32 |
| 179 | * bit values at the expense of memory usage). We slide even when level == 0 to |
| 180 | * keep the hash table consistent if we switch back to level > 0 later. |
| 181 | */ |
| 182 | #if defined(__has_feature) |
| 183 | # if __has_feature(memory_sanitizer) |
| 184 | __attribute__((no_sanitize("memory"))) |
| 185 | # endif |
| 186 | #endif |
| 187 | local void slide_hash(deflate_state *s) { |
| 188 | unsigned n, m; |
| 189 | Posf *p; |
| 190 | uInt wsize = s->w_size; |
| 191 | |
| 192 | n = s->hash_size; |
| @@ -218,35 +205,182 @@ | |
| 205 | * its value will never be used. |
| 206 | */ |
| 207 | } while (--n); |
| 208 | #endif |
| 209 | } |
| 210 | |
| 211 | /* =========================================================================== |
| 212 | * Read a new buffer from the current input stream, update the adler32 |
| 213 | * and total number of bytes read. All deflate() input goes through |
| 214 | * this function so some applications may wish to modify it to avoid |
| 215 | * allocating a large strm->next_in buffer and copying from it. |
| 216 | * (See also flush_pending()). |
| 217 | */ |
| 218 | local unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size) { |
| 219 | unsigned len = strm->avail_in; |
| 220 | |
| 221 | if (len > size) len = size; |
| 222 | if (len == 0) return 0; |
| 223 | |
| 224 | strm->avail_in -= len; |
| 225 | |
| 226 | zmemcpy(buf, strm->next_in, len); |
| 227 | if (strm->state->wrap == 1) { |
| 228 | strm->adler = adler32(strm->adler, buf, len); |
| 229 | } |
| 230 | #ifdef GZIP |
| 231 | else if (strm->state->wrap == 2) { |
| 232 | strm->adler = crc32(strm->adler, buf, len); |
| 233 | } |
| 234 | #endif |
| 235 | strm->next_in += len; |
| 236 | strm->total_in += len; |
| 237 | |
| 238 | return len; |
| 239 | } |
| 240 | |
| 241 | /* =========================================================================== |
| 242 | * Fill the window when the lookahead becomes insufficient. |
| 243 | * Updates strstart and lookahead. |
| 244 | * |
| 245 | * IN assertion: lookahead < MIN_LOOKAHEAD |
| 246 | * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD |
| 247 | * At least one byte has been read, or avail_in == 0; reads are |
| 248 | * performed for at least two bytes (required for the zip translate_eol |
| 249 | * option -- not supported here). |
| 250 | */ |
| 251 | local void fill_window(deflate_state *s) { |
| 252 | unsigned n; |
| 253 | unsigned more; /* Amount of free space at the end of the window. */ |
| 254 | uInt wsize = s->w_size; |
| 255 | |
| 256 | Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); |
| 257 | |
| 258 | do { |
| 259 | more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); |
| 260 | |
| 261 | /* Deal with !@#$% 64K limit: */ |
| 262 | if (sizeof(int) <= 2) { |
| 263 | if (more == 0 && s->strstart == 0 && s->lookahead == 0) { |
| 264 | more = wsize; |
| 265 | |
| 266 | } else if (more == (unsigned)(-1)) { |
| 267 | /* Very unlikely, but possible on 16 bit machine if |
| 268 | * strstart == 0 && lookahead == 1 (input done a byte at time) |
| 269 | */ |
| 270 | more--; |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | /* If the window is almost full and there is insufficient lookahead, |
| 275 | * move the upper half to the lower one to make room in the upper half. |
| 276 | */ |
| 277 | if (s->strstart >= wsize + MAX_DIST(s)) { |
| 278 | |
| 279 | zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more); |
| 280 | s->match_start -= wsize; |
| 281 | s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ |
| 282 | s->block_start -= (long) wsize; |
| 283 | if (s->insert > s->strstart) |
| 284 | s->insert = s->strstart; |
| 285 | slide_hash(s); |
| 286 | more += wsize; |
| 287 | } |
| 288 | if (s->strm->avail_in == 0) break; |
| 289 | |
| 290 | /* If there was no sliding: |
| 291 | * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && |
| 292 | * more == window_size - lookahead - strstart |
| 293 | * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) |
| 294 | * => more >= window_size - 2*WSIZE + 2 |
| 295 | * In the BIG_MEM or MMAP case (not yet supported), |
| 296 | * window_size == input_size + MIN_LOOKAHEAD && |
| 297 | * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. |
| 298 | * Otherwise, window_size == 2*WSIZE so more >= 2. |
| 299 | * If there was sliding, more >= WSIZE. So in all cases, more >= 2. |
| 300 | */ |
| 301 | Assert(more >= 2, "more < 2"); |
| 302 | |
| 303 | n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); |
| 304 | s->lookahead += n; |
| 305 | |
| 306 | /* Initialize the hash value now that we have some input: */ |
| 307 | if (s->lookahead + s->insert >= MIN_MATCH) { |
| 308 | uInt str = s->strstart - s->insert; |
| 309 | s->ins_h = s->window[str]; |
| 310 | UPDATE_HASH(s, s->ins_h, s->window[str + 1]); |
| 311 | #if MIN_MATCH != 3 |
| 312 | Call UPDATE_HASH() MIN_MATCH-3 more times |
| 313 | #endif |
| 314 | while (s->insert) { |
| 315 | UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); |
| 316 | #ifndef FASTEST |
| 317 | s->prev[str & s->w_mask] = s->head[s->ins_h]; |
| 318 | #endif |
| 319 | s->head[s->ins_h] = (Pos)str; |
| 320 | str++; |
| 321 | s->insert--; |
| 322 | if (s->lookahead + s->insert < MIN_MATCH) |
| 323 | break; |
| 324 | } |
| 325 | } |
| 326 | /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, |
| 327 | * but this is not important since only literal bytes will be emitted. |
| 328 | */ |
| 329 | |
| 330 | } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); |
| 331 | |
| 332 | /* If the WIN_INIT bytes after the end of the current data have never been |
| 333 | * written, then zero those bytes in order to avoid memory check reports of |
| 334 | * the use of uninitialized (or uninitialised as Julian writes) bytes by |
| 335 | * the longest match routines. Update the high water mark for the next |
| 336 | * time through here. WIN_INIT is set to MAX_MATCH since the longest match |
| 337 | * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. |
| 338 | */ |
| 339 | if (s->high_water < s->window_size) { |
| 340 | ulg curr = s->strstart + (ulg)(s->lookahead); |
| 341 | ulg init; |
| 342 | |
| 343 | if (s->high_water < curr) { |
| 344 | /* Previous high water mark below current data -- zero WIN_INIT |
| 345 | * bytes or up to end of window, whichever is less. |
| 346 | */ |
| 347 | init = s->window_size - curr; |
| 348 | if (init > WIN_INIT) |
| 349 | init = WIN_INIT; |
| 350 | zmemzero(s->window + curr, (unsigned)init); |
| 351 | s->high_water = curr + init; |
| 352 | } |
| 353 | else if (s->high_water < (ulg)curr + WIN_INIT) { |
| 354 | /* High water mark at or above current data, but below current data |
| 355 | * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up |
| 356 | * to end of window, whichever is less. |
| 357 | */ |
| 358 | init = (ulg)curr + WIN_INIT - s->high_water; |
| 359 | if (init > s->window_size - s->high_water) |
| 360 | init = s->window_size - s->high_water; |
| 361 | zmemzero(s->window + s->high_water, (unsigned)init); |
| 362 | s->high_water += init; |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, |
| 367 | "not enough room for search"); |
| 368 | } |
| 369 | |
| 370 | /* ========================================================================= */ |
| 371 | int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, |
| 372 | int stream_size) { |
| 373 | return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, |
| 374 | Z_DEFAULT_STRATEGY, version, stream_size); |
| 375 | /* To do: ignore strm->next_in if we use it as window */ |
| 376 | } |
| 377 | |
| 378 | /* ========================================================================= */ |
| 379 | int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, |
| 380 | int windowBits, int memLevel, int strategy, |
| 381 | const char *version, int stream_size) { |
| 382 | deflate_state *s; |
| 383 | int wrap = 1; |
| 384 | static const char my_version[] = ZLIB_VERSION; |
| 385 | |
| 386 | if (version == Z_NULL || version[0] != my_version[0] || |
| @@ -384,13 +518,11 @@ | |
| 518 | } |
| 519 | |
| 520 | /* ========================================================================= |
| 521 | * Check for a valid deflate stream state. Return 0 if ok, 1 if not. |
| 522 | */ |
| 523 | local int deflateStateCheck(z_streamp strm) { |
| 524 | deflate_state *s; |
| 525 | if (strm == Z_NULL || |
| 526 | strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) |
| 527 | return 1; |
| 528 | s = strm->state; |
| @@ -407,15 +539,12 @@ | |
| 539 | return 1; |
| 540 | return 0; |
| 541 | } |
| 542 | |
| 543 | /* ========================================================================= */ |
| 544 | int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary, |
| 545 | uInt dictLength) { |
| 546 | deflate_state *s; |
| 547 | uInt str, n; |
| 548 | int wrap; |
| 549 | unsigned avail; |
| 550 | z_const unsigned char *next; |
| @@ -476,15 +605,12 @@ | |
| 605 | s->wrap = wrap; |
| 606 | return Z_OK; |
| 607 | } |
| 608 | |
| 609 | /* ========================================================================= */ |
| 610 | int ZEXPORT deflateGetDictionary(z_streamp strm, Bytef *dictionary, |
| 611 | uInt *dictLength) { |
| 612 | deflate_state *s; |
| 613 | uInt len; |
| 614 | |
| 615 | if (deflateStateCheck(strm)) |
| 616 | return Z_STREAM_ERROR; |
| @@ -498,13 +624,11 @@ | |
| 624 | *dictLength = len; |
| 625 | return Z_OK; |
| 626 | } |
| 627 | |
| 628 | /* ========================================================================= */ |
| 629 | int ZEXPORT deflateResetKeep(z_streamp strm) { |
| 630 | deflate_state *s; |
| 631 | |
| 632 | if (deflateStateCheck(strm)) { |
| 633 | return Z_STREAM_ERROR; |
| 634 | } |
| @@ -534,54 +658,65 @@ | |
| 658 | |
| 659 | _tr_init(s); |
| 660 | |
| 661 | return Z_OK; |
| 662 | } |
| 663 | |
| 664 | /* =========================================================================== |
| 665 | * Initialize the "longest match" routines for a new zlib stream |
| 666 | */ |
| 667 | local void lm_init(deflate_state *s) { |
| 668 | s->window_size = (ulg)2L*s->w_size; |
| 669 | |
| 670 | CLEAR_HASH(s); |
| 671 | |
| 672 | /* Set the default configuration parameters: |
| 673 | */ |
| 674 | s->max_lazy_match = configuration_table[s->level].max_lazy; |
| 675 | s->good_match = configuration_table[s->level].good_length; |
| 676 | s->nice_match = configuration_table[s->level].nice_length; |
| 677 | s->max_chain_length = configuration_table[s->level].max_chain; |
| 678 | |
| 679 | s->strstart = 0; |
| 680 | s->block_start = 0L; |
| 681 | s->lookahead = 0; |
| 682 | s->insert = 0; |
| 683 | s->match_length = s->prev_length = MIN_MATCH-1; |
| 684 | s->match_available = 0; |
| 685 | s->ins_h = 0; |
| 686 | } |
| 687 | |
| 688 | /* ========================================================================= */ |
| 689 | int ZEXPORT deflateReset(z_streamp strm) { |
| 690 | int ret; |
| 691 | |
| 692 | ret = deflateResetKeep(strm); |
| 693 | if (ret == Z_OK) |
| 694 | lm_init(strm->state); |
| 695 | return ret; |
| 696 | } |
| 697 | |
| 698 | /* ========================================================================= */ |
| 699 | int ZEXPORT deflateSetHeader(z_streamp strm, gz_headerp head) { |
| 700 | if (deflateStateCheck(strm) || strm->state->wrap != 2) |
| 701 | return Z_STREAM_ERROR; |
| 702 | strm->state->gzhead = head; |
| 703 | return Z_OK; |
| 704 | } |
| 705 | |
| 706 | /* ========================================================================= */ |
| 707 | int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) { |
| 708 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 709 | if (pending != Z_NULL) |
| 710 | *pending = strm->state->pending; |
| 711 | if (bits != Z_NULL) |
| 712 | *bits = strm->state->bi_valid; |
| 713 | return Z_OK; |
| 714 | } |
| 715 | |
| 716 | /* ========================================================================= */ |
| 717 | int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) { |
| 718 | deflate_state *s; |
| 719 | int put; |
| 720 | |
| 721 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 722 | s = strm->state; |
| @@ -600,15 +735,11 @@ | |
| 735 | } while (bits); |
| 736 | return Z_OK; |
| 737 | } |
| 738 | |
| 739 | /* ========================================================================= */ |
| 740 | int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) { |
| 741 | deflate_state *s; |
| 742 | compress_func func; |
| 743 | |
| 744 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 745 | s = strm->state; |
| @@ -649,17 +780,12 @@ | |
| 780 | s->strategy = strategy; |
| 781 | return Z_OK; |
| 782 | } |
| 783 | |
| 784 | /* ========================================================================= */ |
| 785 | int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy, |
| 786 | int nice_length, int max_chain) { |
| 787 | deflate_state *s; |
| 788 | |
| 789 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 790 | s = strm->state; |
| 791 | s->good_match = (uInt)good_length; |
| @@ -691,14 +817,11 @@ | |
| 817 | * per 8-bit byte, plus 10 bits for every block. The smallest block size for |
| 818 | * which this can occur is 255 (memLevel == 2). |
| 819 | * |
| 820 | * Shifts are used to approximate divisions, for speed. |
| 821 | */ |
| 822 | uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) { |
| 823 | deflate_state *s; |
| 824 | uLong fixedlen, storelen, wraplen; |
| 825 | |
| 826 | /* upper bound for fixed blocks with 9-bit literals and length 255 |
| 827 | (memLevel == 2, which is the lowest that may not use stored blocks) -- |
| @@ -750,11 +873,12 @@ | |
| 873 | wraplen = 6; |
| 874 | } |
| 875 | |
| 876 | /* if not default parameters, return one of the conservative bounds */ |
| 877 | if (s->w_bits != 15 || s->hash_bits != 8 + 7) |
| 878 | return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) + |
| 879 | wraplen; |
| 880 | |
| 881 | /* default settings: return tight bound for that case -- ~0.03% overhead |
| 882 | plus a small constant */ |
| 883 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + |
| 884 | (sourceLen >> 25) + 13 - 6 + wraplen; |
| @@ -763,14 +887,11 @@ | |
| 887 | /* ========================================================================= |
| 888 | * Put a short in the pending buffer. The 16-bit value is put in MSB order. |
| 889 | * IN assertion: the stream state is correct and there is enough room in |
| 890 | * pending_buf. |
| 891 | */ |
| 892 | local void putShortMSB(deflate_state *s, uInt b) { |
| 893 | put_byte(s, (Byte)(b >> 8)); |
| 894 | put_byte(s, (Byte)(b & 0xff)); |
| 895 | } |
| 896 | |
| 897 | /* ========================================================================= |
| @@ -777,13 +898,11 @@ | |
| 898 | * Flush as much pending output as possible. All deflate() output, except for |
| 899 | * some deflate_stored() output, goes through this function so some |
| 900 | * applications may wish to modify it to avoid allocating a large |
| 901 | * strm->next_out buffer and copying into it. (See also read_buf()). |
| 902 | */ |
| 903 | local void flush_pending(z_streamp strm) { |
| 904 | unsigned len; |
| 905 | deflate_state *s = strm->state; |
| 906 | |
| 907 | _tr_flush_bits(s); |
| 908 | len = s->pending; |
| @@ -810,14 +929,11 @@ | |
| 929 | strm->adler = crc32(strm->adler, s->pending_buf + (beg), \ |
| 930 | s->pending - (beg)); \ |
| 931 | } while (0) |
| 932 | |
| 933 | /* ========================================================================= */ |
| 934 | int ZEXPORT deflate(z_streamp strm, int flush) { |
| 935 | int old_flush; /* value of flush param for previous deflate call */ |
| 936 | deflate_state *s; |
| 937 | |
| 938 | if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) { |
| 939 | return Z_STREAM_ERROR; |
| @@ -1125,13 +1241,11 @@ | |
| 1241 | if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ |
| 1242 | return s->pending != 0 ? Z_OK : Z_STREAM_END; |
| 1243 | } |
| 1244 | |
| 1245 | /* ========================================================================= */ |
| 1246 | int ZEXPORT deflateEnd(z_streamp strm) { |
| 1247 | int status; |
| 1248 | |
| 1249 | if (deflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1250 | |
| 1251 | status = strm->state->status; |
| @@ -1151,15 +1265,14 @@ | |
| 1265 | /* ========================================================================= |
| 1266 | * Copy the source state to the destination state. |
| 1267 | * To simplify the source, this is not supported for 16-bit MSDOS (which |
| 1268 | * doesn't have enough memory anyway to duplicate compression states). |
| 1269 | */ |
| 1270 | int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) { |
| 1271 | #ifdef MAXSEG_64K |
| 1272 | (void)dest; |
| 1273 | (void)source; |
| 1274 | return Z_STREAM_ERROR; |
| 1275 | #else |
| 1276 | deflate_state *ds; |
| 1277 | deflate_state *ss; |
| 1278 | |
| @@ -1203,70 +1316,10 @@ | |
| 1316 | |
| 1317 | return Z_OK; |
| 1318 | #endif /* MAXSEG_64K */ |
| 1319 | } |
| 1320 | |
| 1321 | #ifndef FASTEST |
| 1322 | /* =========================================================================== |
| 1323 | * Set match_start to the longest match starting at the given string and |
| 1324 | * return its length. Matches shorter or equal to prev_length are discarded, |
| 1325 | * in which case the result is equal to prev_length and match_start is |
| @@ -1273,14 +1326,11 @@ | |
| 1326 | * garbage. |
| 1327 | * IN assertions: cur_match is the head of the hash chain for the current |
| 1328 | * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 |
| 1329 | * OUT assertion: the match length is not greater than s->lookahead. |
| 1330 | */ |
| 1331 | local uInt longest_match(deflate_state *s, IPos cur_match) { |
| 1332 | unsigned chain_length = s->max_chain_length;/* max hash chain length */ |
| 1333 | register Bytef *scan = s->window + s->strstart; /* current string */ |
| 1334 | register Bytef *match; /* matched string */ |
| 1335 | register int len; /* length of current match */ |
| 1336 | int best_len = (int)s->prev_length; /* best match length so far */ |
| @@ -1424,14 +1474,11 @@ | |
| 1474 | #else /* FASTEST */ |
| 1475 | |
| 1476 | /* --------------------------------------------------------------------------- |
| 1477 | * Optimized version for FASTEST only |
| 1478 | */ |
| 1479 | local uInt longest_match(deflate_state *s, IPos cur_match) { |
| 1480 | register Bytef *scan = s->window + s->strstart; /* current string */ |
| 1481 | register Bytef *match; /* matched string */ |
| 1482 | register int len; /* length of current match */ |
| 1483 | register Bytef *strend = s->window + s->strstart + MAX_MATCH; |
| 1484 | |
| @@ -1488,15 +1535,11 @@ | |
| 1535 | /* result of memcmp for equal strings */ |
| 1536 | |
| 1537 | /* =========================================================================== |
| 1538 | * Check that the match at match_start is indeed a match. |
| 1539 | */ |
| 1540 | local void check_match(deflate_state *s, IPos start, IPos match, int length) { |
| 1541 | /* check that the match is indeed a match */ |
| 1542 | if (zmemcmp(s->window + match, |
| 1543 | s->window + start, length) != EQUAL) { |
| 1544 | fprintf(stderr, " start %u, match %u, length %d\n", |
| 1545 | start, match, length); |
| @@ -1512,141 +1555,10 @@ | |
| 1555 | } |
| 1556 | #else |
| 1557 | # define check_match(s, start, match, length) |
| 1558 | #endif /* ZLIB_DEBUG */ |
| 1559 | |
| 1560 | /* =========================================================================== |
| 1561 | * Flush the current block, with given end-of-file flag. |
| 1562 | * IN assertion: strstart is set to the end of the current match. |
| 1563 | */ |
| 1564 | #define FLUSH_BLOCK_ONLY(s, last) { \ |
| @@ -1685,14 +1597,11 @@ | |
| 1597 | * |
| 1598 | * deflate_stored() is written to minimize the number of times an input byte is |
| 1599 | * copied. It is most efficient with large input and output buffers, which |
| 1600 | * maximizes the opportunities to have a single copy from next_in to next_out. |
| 1601 | */ |
| 1602 | local block_state deflate_stored(deflate_state *s, int flush) { |
| 1603 | /* Smallest worthy block size when not flushing or finishing. By default |
| 1604 | * this is 32K. This can be as small as 507 bytes for memLevel == 1. For |
| 1605 | * large input and output buffers, the stored block size will be larger. |
| 1606 | */ |
| 1607 | unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size); |
| @@ -1872,14 +1781,11 @@ | |
| 1781 | * block state. |
| 1782 | * This function does not perform lazy evaluation of matches and inserts |
| 1783 | * new strings in the dictionary only for unmatched strings or for short |
| 1784 | * matches. It is used only for the fast compression options. |
| 1785 | */ |
| 1786 | local block_state deflate_fast(deflate_state *s, int flush) { |
| 1787 | IPos hash_head; /* head of the hash chain */ |
| 1788 | int bflush; /* set if current block must be flushed */ |
| 1789 | |
| 1790 | for (;;) { |
| 1791 | /* Make sure that we always have enough lookahead, except |
| @@ -1974,14 +1880,11 @@ | |
| 1880 | /* =========================================================================== |
| 1881 | * Same as above, but achieves better compression. We use a lazy |
| 1882 | * evaluation for matches: a match is finally adopted only if there is |
| 1883 | * no better match at the next window position. |
| 1884 | */ |
| 1885 | local block_state deflate_slow(deflate_state *s, int flush) { |
| 1886 | IPos hash_head; /* head of hash chain */ |
| 1887 | int bflush; /* set if current block must be flushed */ |
| 1888 | |
| 1889 | /* Process the input block. */ |
| 1890 | for (;;) { |
| @@ -2105,14 +2008,11 @@ | |
| 2008 | /* =========================================================================== |
| 2009 | * For Z_RLE, simply look for runs of bytes, generate matches only of distance |
| 2010 | * one. Do not maintain a hash table. (It will be regenerated if this run of |
| 2011 | * deflate switches away from Z_RLE.) |
| 2012 | */ |
| 2013 | local block_state deflate_rle(deflate_state *s, int flush) { |
| 2014 | int bflush; /* set if current block must be flushed */ |
| 2015 | uInt prev; /* byte at distance one to match */ |
| 2016 | Bytef *scan, *strend; /* scan goes up to strend for length of run */ |
| 2017 | |
| 2018 | for (;;) { |
| @@ -2179,14 +2079,11 @@ | |
| 2079 | |
| 2080 | /* =========================================================================== |
| 2081 | * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. |
| 2082 | * (It will be regenerated if this run of deflate switches away from Huffman.) |
| 2083 | */ |
| 2084 | local block_state deflate_huff(deflate_state *s, int flush) { |
| 2085 | int bflush; /* set if current block must be flushed */ |
| 2086 | |
| 2087 | for (;;) { |
| 2088 | /* Make sure that we have a literal to write. */ |
| 2089 | if (s->lookahead == 0) { |
| 2090 |
+8
-8
| --- compat/zlib/deflate.h | ||
| +++ compat/zlib/deflate.h | ||
| @@ -289,18 +289,18 @@ | ||
| 289 | 289 | #define WIN_INIT MAX_MATCH |
| 290 | 290 | /* Number of bytes after end of data in window to initialize in order to avoid |
| 291 | 291 | memory checker errors from longest match routines */ |
| 292 | 292 | |
| 293 | 293 | /* in trees.c */ |
| 294 | -void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); | |
| 295 | -int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); | |
| 296 | -void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, | |
| 297 | - ulg stored_len, int last)); | |
| 298 | -void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); | |
| 299 | -void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); | |
| 300 | -void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, | |
| 301 | - ulg stored_len, int last)); | |
| 294 | +void ZLIB_INTERNAL _tr_init(deflate_state *s); | |
| 295 | +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc); | |
| 296 | +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, | |
| 297 | + ulg stored_len, int last); | |
| 298 | +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s); | |
| 299 | +void ZLIB_INTERNAL _tr_align(deflate_state *s); | |
| 300 | +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, | |
| 301 | + ulg stored_len, int last); | |
| 302 | 302 | |
| 303 | 303 | #define d_code(dist) \ |
| 304 | 304 | ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) |
| 305 | 305 | /* Mapping from a distance to a distance code. dist is the distance - 1 and |
| 306 | 306 | * must not have side effects. _dist_code[256] and _dist_code[257] are never |
| 307 | 307 |
| --- compat/zlib/deflate.h | |
| +++ compat/zlib/deflate.h | |
| @@ -289,18 +289,18 @@ | |
| 289 | #define WIN_INIT MAX_MATCH |
| 290 | /* Number of bytes after end of data in window to initialize in order to avoid |
| 291 | memory checker errors from longest match routines */ |
| 292 | |
| 293 | /* in trees.c */ |
| 294 | void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); |
| 295 | int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); |
| 296 | void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, |
| 297 | ulg stored_len, int last)); |
| 298 | void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); |
| 299 | void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); |
| 300 | void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, |
| 301 | ulg stored_len, int last)); |
| 302 | |
| 303 | #define d_code(dist) \ |
| 304 | ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) |
| 305 | /* Mapping from a distance to a distance code. dist is the distance - 1 and |
| 306 | * must not have side effects. _dist_code[256] and _dist_code[257] are never |
| 307 |
| --- compat/zlib/deflate.h | |
| +++ compat/zlib/deflate.h | |
| @@ -289,18 +289,18 @@ | |
| 289 | #define WIN_INIT MAX_MATCH |
| 290 | /* Number of bytes after end of data in window to initialize in order to avoid |
| 291 | memory checker errors from longest match routines */ |
| 292 | |
| 293 | /* in trees.c */ |
| 294 | void ZLIB_INTERNAL _tr_init(deflate_state *s); |
| 295 | int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc); |
| 296 | void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, |
| 297 | ulg stored_len, int last); |
| 298 | void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s); |
| 299 | void ZLIB_INTERNAL _tr_align(deflate_state *s); |
| 300 | void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, |
| 301 | ulg stored_len, int last); |
| 302 | |
| 303 | #define d_code(dist) \ |
| 304 | ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) |
| 305 | /* Mapping from a distance to a distance code. dist is the distance - 1 and |
| 306 | * must not have side effects. _dist_code[256] and _dist_code[257] are never |
| 307 |
+1
-1
| --- compat/zlib/examples/fitblk.c | ||
| +++ compat/zlib/examples/fitblk.c | ||
| @@ -196,11 +196,11 @@ | ||
| 196 | 196 | def.next_out = tmp; |
| 197 | 197 | ret = recompress(&inf, &def); |
| 198 | 198 | if (ret == Z_MEM_ERROR) |
| 199 | 199 | quit("out of memory"); |
| 200 | 200 | |
| 201 | - /* set up for next reocmpression */ | |
| 201 | + /* set up for next recompression */ | |
| 202 | 202 | ret = inflateReset(&inf); |
| 203 | 203 | assert(ret != Z_STREAM_ERROR); |
| 204 | 204 | ret = deflateReset(&def); |
| 205 | 205 | assert(ret != Z_STREAM_ERROR); |
| 206 | 206 | |
| 207 | 207 |
| --- compat/zlib/examples/fitblk.c | |
| +++ compat/zlib/examples/fitblk.c | |
| @@ -196,11 +196,11 @@ | |
| 196 | def.next_out = tmp; |
| 197 | ret = recompress(&inf, &def); |
| 198 | if (ret == Z_MEM_ERROR) |
| 199 | quit("out of memory"); |
| 200 | |
| 201 | /* set up for next reocmpression */ |
| 202 | ret = inflateReset(&inf); |
| 203 | assert(ret != Z_STREAM_ERROR); |
| 204 | ret = deflateReset(&def); |
| 205 | assert(ret != Z_STREAM_ERROR); |
| 206 | |
| 207 |
| --- compat/zlib/examples/fitblk.c | |
| +++ compat/zlib/examples/fitblk.c | |
| @@ -196,11 +196,11 @@ | |
| 196 | def.next_out = tmp; |
| 197 | ret = recompress(&inf, &def); |
| 198 | if (ret == Z_MEM_ERROR) |
| 199 | quit("out of memory"); |
| 200 | |
| 201 | /* set up for next recompression */ |
| 202 | ret = inflateReset(&inf); |
| 203 | assert(ret != Z_STREAM_ERROR); |
| 204 | ret = deflateReset(&def); |
| 205 | assert(ret != Z_STREAM_ERROR); |
| 206 | |
| 207 |
+15
-11
| --- compat/zlib/examples/zlib_how.html | ||
| +++ compat/zlib/examples/zlib_how.html | ||
| @@ -1,12 +1,12 @@ | ||
| 1 | -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" | |
| 2 | - "http://www.w3.org/TR/REC-html40/loose.dtd"> | |
| 1 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
| 2 | + "http://www.w3.org/TR/html4/loose.dtd"> | |
| 3 | 3 | <html> |
| 4 | 4 | <head> |
| 5 | 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| 6 | 6 | <title>zlib Usage Example</title> |
| 7 | -<!-- Copyright (c) 2004, 2005 Mark Adler. --> | |
| 7 | +<!-- Copyright (c) 2004-2023 Mark Adler. --> | |
| 8 | 8 | </head> |
| 9 | 9 | <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#00A000"> |
| 10 | 10 | <h2 align="center"> zlib Usage Example </h2> |
| 11 | 11 | We often get questions about how the <tt>deflate()</tt> and <tt>inflate()</tt> functions should be used. |
| 12 | 12 | Users wonder when they should provide more input, when they should use more output, |
| @@ -15,11 +15,11 @@ | ||
| 15 | 15 | would like further edification, below is an annotated example in C of simple routines to compress and decompress |
| 16 | 16 | from an input file to an output file using <tt>deflate()</tt> and <tt>inflate()</tt> respectively. The |
| 17 | 17 | annotations are interspersed between lines of the code. So please read between the lines. |
| 18 | 18 | We hope this helps explain some of the intricacies of <em>zlib</em>. |
| 19 | 19 | <p> |
| 20 | -Without further adieu, here is the program <a href="zpipe.c"><tt>zpipe.c</tt></a>: | |
| 20 | +Without further ado, here is the program <a href="zpipe.c"><tt>zpipe.c</tt></a>: | |
| 21 | 21 | <pre><b> |
| 22 | 22 | /* zpipe.c: example of proper use of zlib's inflate() and deflate() |
| 23 | 23 | Not copyrighted -- provided to the public domain |
| 24 | 24 | Version 1.4 11 December 2005 Mark Adler */ |
| 25 | 25 | |
| @@ -153,17 +153,15 @@ | ||
| 153 | 153 | /* compress until end of file */ |
| 154 | 154 | do { |
| 155 | 155 | </b></pre> |
| 156 | 156 | We start off by reading data from the input file. The number of bytes read is put directly |
| 157 | 157 | into <tt>avail_in</tt>, and a pointer to those bytes is put into <tt>next_in</tt>. We also |
| 158 | -check to see if end-of-file on the input has been reached. If we are at the end of file, then <tt>flush</tt> is set to the | |
| 158 | +check to see if end-of-file on the input has been reached using feof(). | |
| 159 | +If we are at the end of file, then <tt>flush</tt> is set to the | |
| 159 | 160 | <em>zlib</em> constant <tt>Z_FINISH</tt>, which is later passed to <tt>deflate()</tt> to |
| 160 | -indicate that this is the last chunk of input data to compress. We need to use <tt>feof()</tt> | |
| 161 | -to check for end-of-file as opposed to seeing if fewer than <tt>CHUNK</tt> bytes have been read. The | |
| 162 | -reason is that if the input file length is an exact multiple of <tt>CHUNK</tt>, we will miss | |
| 163 | -the fact that we got to the end-of-file, and not know to tell <tt>deflate()</tt> to finish | |
| 164 | -up the compressed stream. If we are not yet at the end of the input, then the <em>zlib</em> | |
| 161 | +indicate that this is the last chunk of input data to compress. | |
| 162 | +If we are not yet at the end of the input, then the <em>zlib</em> | |
| 165 | 163 | constant <tt>Z_NO_FLUSH</tt> will be passed to <tt>deflate</tt> to indicate that we are still |
| 166 | 164 | in the middle of the uncompressed data. |
| 167 | 165 | <p> |
| 168 | 166 | If there is an error in reading from the input file, the process is aborted with |
| 169 | 167 | <tt>deflateEnd()</tt> being called to free the allocated <em>zlib</em> state before returning |
| @@ -538,8 +536,14 @@ | ||
| 538 | 536 | return 1; |
| 539 | 537 | } |
| 540 | 538 | } |
| 541 | 539 | </b></pre> |
| 542 | 540 | <hr> |
| 543 | -<i>Copyright (c) 2004, 2005 by Mark Adler<br>Last modified 11 December 2005</i> | |
| 541 | +<i>Last modified 24 January 2023<br> | |
| 542 | +Copyright © 2004-2023 Mark Adler</i><br> | |
| 543 | +<a rel="license" href="http://creativecommons.org/licenses/by-nd/4.0/"> | |
| 544 | +<img alt="Creative Commons License" style="border-width:0" | |
| 545 | +src="https://i.creativecommons.org/l/by-nd/4.0/88x31.png"></a> | |
| 546 | +<a rel="license" href="http://creativecommons.org/licenses/by-nd/4.0/"> | |
| 547 | +Creative Commons Attribution-NoDerivatives 4.0 International License</a>. | |
| 544 | 548 | </body> |
| 545 | 549 | </html> |
| 546 | 550 |
| --- compat/zlib/examples/zlib_how.html | |
| +++ compat/zlib/examples/zlib_how.html | |
| @@ -1,12 +1,12 @@ | |
| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" |
| 2 | "http://www.w3.org/TR/REC-html40/loose.dtd"> |
| 3 | <html> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| 6 | <title>zlib Usage Example</title> |
| 7 | <!-- Copyright (c) 2004, 2005 Mark Adler. --> |
| 8 | </head> |
| 9 | <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#00A000"> |
| 10 | <h2 align="center"> zlib Usage Example </h2> |
| 11 | We often get questions about how the <tt>deflate()</tt> and <tt>inflate()</tt> functions should be used. |
| 12 | Users wonder when they should provide more input, when they should use more output, |
| @@ -15,11 +15,11 @@ | |
| 15 | would like further edification, below is an annotated example in C of simple routines to compress and decompress |
| 16 | from an input file to an output file using <tt>deflate()</tt> and <tt>inflate()</tt> respectively. The |
| 17 | annotations are interspersed between lines of the code. So please read between the lines. |
| 18 | We hope this helps explain some of the intricacies of <em>zlib</em>. |
| 19 | <p> |
| 20 | Without further adieu, here is the program <a href="zpipe.c"><tt>zpipe.c</tt></a>: |
| 21 | <pre><b> |
| 22 | /* zpipe.c: example of proper use of zlib's inflate() and deflate() |
| 23 | Not copyrighted -- provided to the public domain |
| 24 | Version 1.4 11 December 2005 Mark Adler */ |
| 25 | |
| @@ -153,17 +153,15 @@ | |
| 153 | /* compress until end of file */ |
| 154 | do { |
| 155 | </b></pre> |
| 156 | We start off by reading data from the input file. The number of bytes read is put directly |
| 157 | into <tt>avail_in</tt>, and a pointer to those bytes is put into <tt>next_in</tt>. We also |
| 158 | check to see if end-of-file on the input has been reached. If we are at the end of file, then <tt>flush</tt> is set to the |
| 159 | <em>zlib</em> constant <tt>Z_FINISH</tt>, which is later passed to <tt>deflate()</tt> to |
| 160 | indicate that this is the last chunk of input data to compress. We need to use <tt>feof()</tt> |
| 161 | to check for end-of-file as opposed to seeing if fewer than <tt>CHUNK</tt> bytes have been read. The |
| 162 | reason is that if the input file length is an exact multiple of <tt>CHUNK</tt>, we will miss |
| 163 | the fact that we got to the end-of-file, and not know to tell <tt>deflate()</tt> to finish |
| 164 | up the compressed stream. If we are not yet at the end of the input, then the <em>zlib</em> |
| 165 | constant <tt>Z_NO_FLUSH</tt> will be passed to <tt>deflate</tt> to indicate that we are still |
| 166 | in the middle of the uncompressed data. |
| 167 | <p> |
| 168 | If there is an error in reading from the input file, the process is aborted with |
| 169 | <tt>deflateEnd()</tt> being called to free the allocated <em>zlib</em> state before returning |
| @@ -538,8 +536,14 @@ | |
| 538 | return 1; |
| 539 | } |
| 540 | } |
| 541 | </b></pre> |
| 542 | <hr> |
| 543 | <i>Copyright (c) 2004, 2005 by Mark Adler<br>Last modified 11 December 2005</i> |
| 544 | </body> |
| 545 | </html> |
| 546 |
| --- compat/zlib/examples/zlib_how.html | |
| +++ compat/zlib/examples/zlib_how.html | |
| @@ -1,12 +1,12 @@ | |
| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
| 2 | "http://www.w3.org/TR/html4/loose.dtd"> |
| 3 | <html> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| 6 | <title>zlib Usage Example</title> |
| 7 | <!-- Copyright (c) 2004-2023 Mark Adler. --> |
| 8 | </head> |
| 9 | <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#00A000"> |
| 10 | <h2 align="center"> zlib Usage Example </h2> |
| 11 | We often get questions about how the <tt>deflate()</tt> and <tt>inflate()</tt> functions should be used. |
| 12 | Users wonder when they should provide more input, when they should use more output, |
| @@ -15,11 +15,11 @@ | |
| 15 | would like further edification, below is an annotated example in C of simple routines to compress and decompress |
| 16 | from an input file to an output file using <tt>deflate()</tt> and <tt>inflate()</tt> respectively. The |
| 17 | annotations are interspersed between lines of the code. So please read between the lines. |
| 18 | We hope this helps explain some of the intricacies of <em>zlib</em>. |
| 19 | <p> |
| 20 | Without further ado, here is the program <a href="zpipe.c"><tt>zpipe.c</tt></a>: |
| 21 | <pre><b> |
| 22 | /* zpipe.c: example of proper use of zlib's inflate() and deflate() |
| 23 | Not copyrighted -- provided to the public domain |
| 24 | Version 1.4 11 December 2005 Mark Adler */ |
| 25 | |
| @@ -153,17 +153,15 @@ | |
| 153 | /* compress until end of file */ |
| 154 | do { |
| 155 | </b></pre> |
| 156 | We start off by reading data from the input file. The number of bytes read is put directly |
| 157 | into <tt>avail_in</tt>, and a pointer to those bytes is put into <tt>next_in</tt>. We also |
| 158 | check to see if end-of-file on the input has been reached using feof(). |
| 159 | If we are at the end of file, then <tt>flush</tt> is set to the |
| 160 | <em>zlib</em> constant <tt>Z_FINISH</tt>, which is later passed to <tt>deflate()</tt> to |
| 161 | indicate that this is the last chunk of input data to compress. |
| 162 | If we are not yet at the end of the input, then the <em>zlib</em> |
| 163 | constant <tt>Z_NO_FLUSH</tt> will be passed to <tt>deflate</tt> to indicate that we are still |
| 164 | in the middle of the uncompressed data. |
| 165 | <p> |
| 166 | If there is an error in reading from the input file, the process is aborted with |
| 167 | <tt>deflateEnd()</tt> being called to free the allocated <em>zlib</em> state before returning |
| @@ -538,8 +536,14 @@ | |
| 536 | return 1; |
| 537 | } |
| 538 | } |
| 539 | </b></pre> |
| 540 | <hr> |
| 541 | <i>Last modified 24 January 2023<br> |
| 542 | Copyright © 2004-2023 Mark Adler</i><br> |
| 543 | <a rel="license" href="http://creativecommons.org/licenses/by-nd/4.0/"> |
| 544 | <img alt="Creative Commons License" style="border-width:0" |
| 545 | src="https://i.creativecommons.org/l/by-nd/4.0/88x31.png"></a> |
| 546 | <a rel="license" href="http://creativecommons.org/licenses/by-nd/4.0/"> |
| 547 | Creative Commons Attribution-NoDerivatives 4.0 International License</a>. |
| 548 | </body> |
| 549 | </html> |
| 550 |
+439
-385
| --- compat/zlib/examples/zran.c | ||
| +++ compat/zlib/examples/zran.c | ||
| @@ -1,452 +1,505 @@ | ||
| 1 | -/* zran.c -- example of zlib/gzip stream indexing and random access | |
| 2 | - * Copyright (C) 2005, 2012, 2018 Mark Adler | |
| 1 | +/* zran.c -- example of deflate stream indexing and random access | |
| 2 | + * Copyright (C) 2005, 2012, 2018, 2023 Mark Adler | |
| 3 | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | - * Version 1.2 14 Oct 2018 Mark Adler */ | |
| 4 | + * Version 1.4 13 Apr 2023 Mark Adler */ | |
| 5 | 5 | |
| 6 | 6 | /* Version History: |
| 7 | 7 | 1.0 29 May 2005 First version |
| 8 | 8 | 1.1 29 Sep 2012 Fix memory reallocation error |
| 9 | 9 | 1.2 14 Oct 2018 Handle gzip streams with multiple members |
| 10 | 10 | Add a header file to facilitate usage in applications |
| 11 | - */ | |
| 12 | - | |
| 13 | -/* Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary() | |
| 14 | - for random access of a compressed file. A file containing a zlib or gzip | |
| 15 | - stream is provided on the command line. The compressed stream is decoded in | |
| 16 | - its entirety, and an index built with access points about every SPAN bytes | |
| 17 | - in the uncompressed output. The compressed file is left open, and can then | |
| 18 | - be read randomly, having to decompress on the average SPAN/2 uncompressed | |
| 19 | - bytes before getting to the desired block of data. | |
| 20 | - | |
| 21 | - An access point can be created at the start of any deflate block, by saving | |
| 22 | - the starting file offset and bit of that block, and the 32K bytes of | |
| 23 | - uncompressed data that precede that block. Also the uncompressed offset of | |
| 24 | - that block is saved to provide a reference for locating a desired starting | |
| 25 | - point in the uncompressed stream. deflate_index_build() works by | |
| 26 | - decompressing the input zlib or gzip stream a block at a time, and at the | |
| 27 | - end of each block deciding if enough uncompressed data has gone by to | |
| 28 | - justify the creation of a new access point. If so, that point is saved in a | |
| 29 | - data structure that grows as needed to accommodate the points. | |
| 30 | - | |
| 31 | - To use the index, an offset in the uncompressed data is provided, for which | |
| 32 | - the latest access point at or preceding that offset is located in the index. | |
| 33 | - The input file is positioned to the specified location in the index, and if | |
| 34 | - necessary the first few bits of the compressed data is read from the file. | |
| 35 | - inflate is initialized with those bits and the 32K of uncompressed data, and | |
| 36 | - the decompression then proceeds until the desired offset in the file is | |
| 37 | - reached. Then the decompression continues to read the desired uncompressed | |
| 38 | - data from the file. | |
| 39 | - | |
| 40 | - Another approach would be to generate the index on demand. In that case, | |
| 41 | - requests for random access reads from the compressed data would try to use | |
| 42 | - the index, but if a read far enough past the end of the index is required, | |
| 43 | - then further index entries would be generated and added. | |
| 44 | - | |
| 45 | - There is some fair bit of overhead to starting inflation for the random | |
| 46 | - access, mainly copying the 32K byte dictionary. So if small pieces of the | |
| 47 | - file are being accessed, it would make sense to implement a cache to hold | |
| 48 | - some lookahead and avoid many calls to deflate_index_extract() for small | |
| 49 | - lengths. | |
| 50 | - | |
| 51 | - Another way to build an index would be to use inflateCopy(). That would | |
| 52 | - not be constrained to have access points at block boundaries, but requires | |
| 53 | - more memory per access point, and also cannot be saved to file due to the | |
| 54 | - use of pointers in the state. The approach here allows for storage of the | |
| 55 | - index in a file. | |
| 56 | - */ | |
| 11 | + 1.3 18 Feb 2023 Permit raw deflate streams as well as zlib and gzip | |
| 12 | + Permit crossing gzip member boundaries when extracting | |
| 13 | + Support a size_t size when extracting (was an int) | |
| 14 | + Do a binary search over the index for an access point | |
| 15 | + Expose the access point type to enable save and load | |
| 16 | + 1.4 13 Apr 2023 Add a NOPRIME define to not use inflatePrime() | |
| 17 | + */ | |
| 18 | + | |
| 19 | +// Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary() | |
| 20 | +// for random access of a compressed file. A file containing a raw deflate | |
| 21 | +// stream is provided on the command line. The compressed stream is decoded in | |
| 22 | +// its entirety, and an index built with access points about every SPAN bytes | |
| 23 | +// in the uncompressed output. The compressed file is left open, and can then | |
| 24 | +// be read randomly, having to decompress on the average SPAN/2 uncompressed | |
| 25 | +// bytes before getting to the desired block of data. | |
| 26 | +// | |
| 27 | +// An access point can be created at the start of any deflate block, by saving | |
| 28 | +// the starting file offset and bit of that block, and the 32K bytes of | |
| 29 | +// uncompressed data that precede that block. Also the uncompressed offset of | |
| 30 | +// that block is saved to provide a reference for locating a desired starting | |
| 31 | +// point in the uncompressed stream. deflate_index_build() decompresses the | |
| 32 | +// input raw deflate stream a block at a time, and at the end of each block | |
| 33 | +// decides if enough uncompressed data has gone by to justify the creation of a | |
| 34 | +// new access point. If so, that point is saved in a data structure that grows | |
| 35 | +// as needed to accommodate the points. | |
| 36 | +// | |
| 37 | +// To use the index, an offset in the uncompressed data is provided, for which | |
| 38 | +// the latest access point at or preceding that offset is located in the index. | |
| 39 | +// The input file is positioned to the specified location in the index, and if | |
| 40 | +// necessary the first few bits of the compressed data is read from the file. | |
| 41 | +// inflate is initialized with those bits and the 32K of uncompressed data, and | |
| 42 | +// decompression then proceeds until the desired offset in the file is reached. | |
| 43 | +// Then decompression continues to read the requested uncompressed data from | |
| 44 | +// the file. | |
| 45 | +// | |
| 46 | +// There is some fair bit of overhead to starting inflation for the random | |
| 47 | +// access, mainly copying the 32K byte dictionary. If small pieces of the file | |
| 48 | +// are being accessed, it would make sense to implement a cache to hold some | |
| 49 | +// lookahead to avoid many calls to deflate_index_extract() for small lengths. | |
| 50 | +// | |
| 51 | +// Another way to build an index would be to use inflateCopy(). That would not | |
| 52 | +// be constrained to have access points at block boundaries, but would require | |
| 53 | +// more memory per access point, and could not be saved to a file due to the | |
| 54 | +// use of pointers in the state. The approach here allows for storage of the | |
| 55 | +// index in a file. | |
| 57 | 56 | |
| 58 | 57 | #include <stdio.h> |
| 59 | 58 | #include <stdlib.h> |
| 60 | 59 | #include <string.h> |
| 60 | +#include <limits.h> | |
| 61 | 61 | #include "zlib.h" |
| 62 | 62 | #include "zran.h" |
| 63 | 63 | |
| 64 | -#define WINSIZE 32768U /* sliding window size */ | |
| 65 | -#define CHUNK 16384 /* file input buffer size */ | |
| 66 | - | |
| 67 | -/* Access point entry. */ | |
| 68 | -struct point { | |
| 69 | - off_t out; /* corresponding offset in uncompressed data */ | |
| 70 | - off_t in; /* offset in input file of first full byte */ | |
| 71 | - int bits; /* number of bits (1-7) from byte at in-1, or 0 */ | |
| 72 | - unsigned char window[WINSIZE]; /* preceding 32K of uncompressed data */ | |
| 73 | -}; | |
| 74 | - | |
| 75 | -/* See comments in zran.h. */ | |
| 76 | -void deflate_index_free(struct deflate_index *index) | |
| 77 | -{ | |
| 64 | +#define WINSIZE 32768U // sliding window size | |
| 65 | +#define CHUNK 16384 // file input buffer size | |
| 66 | + | |
| 67 | +// See comments in zran.h. | |
| 68 | +void deflate_index_free(struct deflate_index *index) { | |
| 78 | 69 | if (index != NULL) { |
| 79 | 70 | free(index->list); |
| 80 | 71 | free(index); |
| 81 | 72 | } |
| 82 | 73 | } |
| 83 | 74 | |
| 84 | -/* Add an entry to the access point list. If out of memory, deallocate the | |
| 85 | - existing list and return NULL. index->gzip is the allocated size of the | |
| 86 | - index in point entries, until it is time for deflate_index_build() to | |
| 87 | - return, at which point gzip is set to indicate a gzip file or not. | |
| 88 | - */ | |
| 89 | -static struct deflate_index *addpoint(struct deflate_index *index, int bits, | |
| 90 | - off_t in, off_t out, unsigned left, | |
| 91 | - unsigned char *window) | |
| 92 | -{ | |
| 93 | - struct point *next; | |
| 94 | - | |
| 95 | - /* if list is empty, create it (start with eight points) */ | |
| 75 | +// Add an access point to the list. If out of memory, deallocate the existing | |
| 76 | +// list and return NULL. index->mode is temporarily the allocated number of | |
| 77 | +// access points, until it is time for deflate_index_build() to return. Then | |
| 78 | +// index->mode is set to the mode of inflation. | |
| 79 | +static struct deflate_index *add_point(struct deflate_index *index, int bits, | |
| 80 | + off_t in, off_t out, unsigned left, | |
| 81 | + unsigned char *window) { | |
| 96 | 82 | if (index == NULL) { |
| 83 | + // The list is empty. Create it, starting with eight access points. | |
| 97 | 84 | index = malloc(sizeof(struct deflate_index)); |
| 98 | - if (index == NULL) return NULL; | |
| 99 | - index->list = malloc(sizeof(struct point) << 3); | |
| 85 | + if (index == NULL) | |
| 86 | + return NULL; | |
| 87 | + index->have = 0; | |
| 88 | + index->mode = 8; | |
| 89 | + index->list = malloc(sizeof(point_t) * index->mode); | |
| 100 | 90 | if (index->list == NULL) { |
| 101 | 91 | free(index); |
| 102 | 92 | return NULL; |
| 103 | 93 | } |
| 104 | - index->gzip = 8; | |
| 105 | - index->have = 0; | |
| 106 | 94 | } |
| 107 | 95 | |
| 108 | - /* if list is full, make it bigger */ | |
| 109 | - else if (index->have == index->gzip) { | |
| 110 | - index->gzip <<= 1; | |
| 111 | - next = realloc(index->list, sizeof(struct point) * index->gzip); | |
| 96 | + else if (index->have == index->mode) { | |
| 97 | + // The list is full. Make it bigger. | |
| 98 | + index->mode <<= 1; | |
| 99 | + point_t *next = realloc(index->list, sizeof(point_t) * index->mode); | |
| 112 | 100 | if (next == NULL) { |
| 113 | 101 | deflate_index_free(index); |
| 114 | 102 | return NULL; |
| 115 | 103 | } |
| 116 | 104 | index->list = next; |
| 117 | 105 | } |
| 118 | 106 | |
| 119 | - /* fill in entry and increment how many we have */ | |
| 120 | - next = (struct point *)(index->list) + index->have; | |
| 121 | - next->bits = bits; | |
| 122 | - next->in = in; | |
| 107 | + // Fill in the access point and increment how many we have. | |
| 108 | + point_t *next = (point_t *)(index->list) + index->have++; | |
| 109 | + if (index->have < 0) { | |
| 110 | + // Overflowed the int! | |
| 111 | + deflate_index_free(index); | |
| 112 | + return NULL; | |
| 113 | + } | |
| 123 | 114 | next->out = out; |
| 115 | + next->in = in; | |
| 116 | + next->bits = bits; | |
| 124 | 117 | if (left) |
| 125 | 118 | memcpy(next->window, window + WINSIZE - left, left); |
| 126 | 119 | if (left < WINSIZE) |
| 127 | 120 | memcpy(next->window + left, window, WINSIZE - left); |
| 128 | - index->have++; | |
| 129 | 121 | |
| 130 | - /* return list, possibly reallocated */ | |
| 122 | + // Return the index, which may have been newly allocated or destroyed. | |
| 131 | 123 | return index; |
| 132 | 124 | } |
| 133 | 125 | |
| 134 | -/* See comments in zran.h. */ | |
| 135 | -int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) | |
| 136 | -{ | |
| 137 | - int ret; | |
| 138 | - int gzip = 0; /* true if reading a gzip file */ | |
| 139 | - off_t totin, totout; /* our own total counters to avoid 4GB limit */ | |
| 140 | - off_t last; /* totout value of last access point */ | |
| 141 | - struct deflate_index *index; /* access points being generated */ | |
| 142 | - z_stream strm; | |
| 143 | - unsigned char input[CHUNK]; | |
| 144 | - unsigned char window[WINSIZE]; | |
| 145 | - | |
| 146 | - /* initialize inflate */ | |
| 147 | - strm.zalloc = Z_NULL; | |
| 148 | - strm.zfree = Z_NULL; | |
| 149 | - strm.opaque = Z_NULL; | |
| 150 | - strm.avail_in = 0; | |
| 151 | - strm.next_in = Z_NULL; | |
| 152 | - ret = inflateInit2(&strm, 47); /* automatic zlib or gzip decoding */ | |
| 153 | - if (ret != Z_OK) | |
| 154 | - return ret; | |
| 155 | - | |
| 156 | - /* inflate the input, maintain a sliding window, and build an index -- this | |
| 157 | - also validates the integrity of the compressed data using the check | |
| 158 | - information in the gzip or zlib stream */ | |
| 159 | - totin = totout = last = 0; | |
| 160 | - index = NULL; /* will be allocated by first addpoint() */ | |
| 161 | - strm.avail_out = 0; | |
| 162 | - do { | |
| 163 | - /* get some compressed data from input file */ | |
| 164 | - strm.avail_in = fread(input, 1, CHUNK, in); | |
| 165 | - if (ferror(in)) { | |
| 166 | - ret = Z_ERRNO; | |
| 167 | - goto deflate_index_build_error; | |
| 168 | - } | |
| 169 | - if (strm.avail_in == 0) { | |
| 170 | - ret = Z_DATA_ERROR; | |
| 171 | - goto deflate_index_build_error; | |
| 172 | - } | |
| 173 | - strm.next_in = input; | |
| 174 | - | |
| 175 | - /* check for a gzip stream */ | |
| 176 | - if (totin == 0 && strm.avail_in >= 3 && | |
| 177 | - input[0] == 31 && input[1] == 139 && input[2] == 8) | |
| 178 | - gzip = 1; | |
| 179 | - | |
| 180 | - /* process all of that, or until end of stream */ | |
| 181 | - do { | |
| 182 | - /* reset sliding window if necessary */ | |
| 183 | - if (strm.avail_out == 0) { | |
| 184 | - strm.avail_out = WINSIZE; | |
| 185 | - strm.next_out = window; | |
| 186 | - } | |
| 187 | - | |
| 188 | - /* inflate until out of input, output, or at end of block -- | |
| 189 | - update the total input and output counters */ | |
| 190 | - totin += strm.avail_in; | |
| 191 | - totout += strm.avail_out; | |
| 192 | - ret = inflate(&strm, Z_BLOCK); /* return at end of block */ | |
| 193 | - totin -= strm.avail_in; | |
| 194 | - totout -= strm.avail_out; | |
| 195 | - if (ret == Z_NEED_DICT) | |
| 196 | - ret = Z_DATA_ERROR; | |
| 197 | - if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR) | |
| 198 | - goto deflate_index_build_error; | |
| 199 | - if (ret == Z_STREAM_END) { | |
| 200 | - if (gzip && | |
| 201 | - (strm.avail_in || ungetc(getc(in), in) != EOF)) { | |
| 202 | - ret = inflateReset(&strm); | |
| 203 | - if (ret != Z_OK) | |
| 204 | - goto deflate_index_build_error; | |
| 205 | - continue; | |
| 206 | - } | |
| 207 | - break; | |
| 208 | - } | |
| 209 | - | |
| 210 | - /* if at end of block, consider adding an index entry (note that if | |
| 211 | - data_type indicates an end-of-block, then all of the | |
| 212 | - uncompressed data from that block has been delivered, and none | |
| 213 | - of the compressed data after that block has been consumed, | |
| 214 | - except for up to seven bits) -- the totout == 0 provides an | |
| 215 | - entry point after the zlib or gzip header, and assures that the | |
| 216 | - index always has at least one access point; we avoid creating an | |
| 217 | - access point after the last block by checking bit 6 of data_type | |
| 218 | - */ | |
| 219 | - if ((strm.data_type & 128) && !(strm.data_type & 64) && | |
| 220 | - (totout == 0 || totout - last > span)) { | |
| 221 | - index = addpoint(index, strm.data_type & 7, totin, | |
| 222 | - totout, strm.avail_out, window); | |
| 223 | - if (index == NULL) { | |
| 224 | - ret = Z_MEM_ERROR; | |
| 225 | - goto deflate_index_build_error; | |
| 226 | - } | |
| 227 | - last = totout; | |
| 228 | - } | |
| 229 | - } while (strm.avail_in != 0); | |
| 230 | - } while (ret != Z_STREAM_END); | |
| 231 | - | |
| 232 | - /* clean up and return index (release unused entries in list) */ | |
| 233 | - (void)inflateEnd(&strm); | |
| 234 | - index->list = realloc(index->list, sizeof(struct point) * index->have); | |
| 235 | - index->gzip = gzip; | |
| 236 | - index->length = totout; | |
| 237 | - *built = index; | |
| 238 | - return index->have; | |
| 239 | - | |
| 240 | - /* return error */ | |
| 241 | - deflate_index_build_error: | |
| 242 | - (void)inflateEnd(&strm); | |
| 243 | - deflate_index_free(index); | |
| 244 | - return ret; | |
| 245 | -} | |
| 246 | - | |
| 247 | -/* See comments in zran.h. */ | |
| 248 | -int deflate_index_extract(FILE *in, struct deflate_index *index, off_t offset, | |
| 249 | - unsigned char *buf, int len) | |
| 250 | -{ | |
| 251 | - int ret, skip; | |
| 252 | - z_stream strm; | |
| 253 | - struct point *here; | |
| 254 | - unsigned char input[CHUNK]; | |
| 255 | - unsigned char discard[WINSIZE]; | |
| 256 | - | |
| 257 | - /* proceed only if something reasonable to do */ | |
| 258 | - if (len < 0) | |
| 259 | - return 0; | |
| 260 | - | |
| 261 | - /* find where in stream to start */ | |
| 262 | - here = index->list; | |
| 263 | - ret = index->have; | |
| 264 | - while (--ret && here[1].out <= offset) | |
| 265 | - here++; | |
| 266 | - | |
| 267 | - /* initialize file and inflate state to start there */ | |
| 268 | - strm.zalloc = Z_NULL; | |
| 269 | - strm.zfree = Z_NULL; | |
| 270 | - strm.opaque = Z_NULL; | |
| 271 | - strm.avail_in = 0; | |
| 272 | - strm.next_in = Z_NULL; | |
| 273 | - ret = inflateInit2(&strm, -15); /* raw inflate */ | |
| 274 | - if (ret != Z_OK) | |
| 275 | - return ret; | |
| 276 | - ret = fseeko(in, here->in - (here->bits ? 1 : 0), SEEK_SET); | |
| 277 | - if (ret == -1) | |
| 278 | - goto deflate_index_extract_ret; | |
| 279 | - if (here->bits) { | |
| 280 | - ret = getc(in); | |
| 281 | - if (ret == -1) { | |
| 282 | - ret = ferror(in) ? Z_ERRNO : Z_DATA_ERROR; | |
| 283 | - goto deflate_index_extract_ret; | |
| 284 | - } | |
| 285 | - (void)inflatePrime(&strm, here->bits, ret >> (8 - here->bits)); | |
| 286 | - } | |
| 287 | - (void)inflateSetDictionary(&strm, here->window, WINSIZE); | |
| 288 | - | |
| 289 | - /* skip uncompressed bytes until offset reached, then satisfy request */ | |
| 290 | - offset -= here->out; | |
| 291 | - strm.avail_in = 0; | |
| 292 | - skip = 1; /* while skipping to offset */ | |
| 293 | - do { | |
| 294 | - /* define where to put uncompressed data, and how much */ | |
| 295 | - if (offset > WINSIZE) { /* skip WINSIZE bytes */ | |
| 296 | - strm.avail_out = WINSIZE; | |
| 297 | - strm.next_out = discard; | |
| 298 | - offset -= WINSIZE; | |
| 299 | - } | |
| 300 | - else if (offset > 0) { /* last skip */ | |
| 301 | - strm.avail_out = (unsigned)offset; | |
| 302 | - strm.next_out = discard; | |
| 303 | - offset = 0; | |
| 304 | - } | |
| 305 | - else if (skip) { /* at offset now */ | |
| 306 | - strm.avail_out = len; | |
| 307 | - strm.next_out = buf; | |
| 308 | - skip = 0; /* only do this once */ | |
| 309 | - } | |
| 310 | - | |
| 311 | - /* uncompress until avail_out filled, or end of stream */ | |
| 312 | - do { | |
| 313 | - if (strm.avail_in == 0) { | |
| 314 | - strm.avail_in = fread(input, 1, CHUNK, in); | |
| 315 | - if (ferror(in)) { | |
| 316 | - ret = Z_ERRNO; | |
| 317 | - goto deflate_index_extract_ret; | |
| 318 | - } | |
| 319 | - if (strm.avail_in == 0) { | |
| 320 | - ret = Z_DATA_ERROR; | |
| 321 | - goto deflate_index_extract_ret; | |
| 322 | - } | |
| 323 | - strm.next_in = input; | |
| 324 | - } | |
| 325 | - ret = inflate(&strm, Z_NO_FLUSH); /* normal inflate */ | |
| 326 | - if (ret == Z_NEED_DICT) | |
| 327 | - ret = Z_DATA_ERROR; | |
| 328 | - if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR) | |
| 329 | - goto deflate_index_extract_ret; | |
| 330 | - if (ret == Z_STREAM_END) { | |
| 331 | - /* the raw deflate stream has ended */ | |
| 332 | - if (index->gzip == 0) | |
| 333 | - /* this is a zlib stream that has ended -- done */ | |
| 334 | - break; | |
| 335 | - | |
| 336 | - /* near the end of a gzip member, which might be followed by | |
| 337 | - another gzip member -- skip the gzip trailer and see if | |
| 338 | - there is more input after it */ | |
| 339 | - if (strm.avail_in < 8) { | |
| 340 | - fseeko(in, 8 - strm.avail_in, SEEK_CUR); | |
| 341 | - strm.avail_in = 0; | |
| 342 | - } | |
| 343 | - else { | |
| 344 | - strm.avail_in -= 8; | |
| 345 | - strm.next_in += 8; | |
| 346 | - } | |
| 347 | - if (strm.avail_in == 0 && ungetc(getc(in), in) == EOF) | |
| 348 | - /* the input ended after the gzip trailer -- done */ | |
| 349 | - break; | |
| 350 | - | |
| 351 | - /* there is more input, so another gzip member should follow -- | |
| 352 | - validate and skip the gzip header */ | |
| 353 | - ret = inflateReset2(&strm, 31); | |
| 354 | - if (ret != Z_OK) | |
| 355 | - goto deflate_index_extract_ret; | |
| 356 | - do { | |
| 357 | - if (strm.avail_in == 0) { | |
| 358 | - strm.avail_in = fread(input, 1, CHUNK, in); | |
| 359 | - if (ferror(in)) { | |
| 360 | - ret = Z_ERRNO; | |
| 361 | - goto deflate_index_extract_ret; | |
| 362 | - } | |
| 363 | - if (strm.avail_in == 0) { | |
| 364 | - ret = Z_DATA_ERROR; | |
| 365 | - goto deflate_index_extract_ret; | |
| 366 | - } | |
| 367 | - strm.next_in = input; | |
| 368 | - } | |
| 369 | - ret = inflate(&strm, Z_BLOCK); | |
| 370 | - if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR) | |
| 371 | - goto deflate_index_extract_ret; | |
| 372 | - } while ((strm.data_type & 128) == 0); | |
| 373 | - | |
| 374 | - /* set up to continue decompression of the raw deflate stream | |
| 375 | - that follows the gzip header */ | |
| 376 | - ret = inflateReset2(&strm, -15); | |
| 377 | - if (ret != Z_OK) | |
| 378 | - goto deflate_index_extract_ret; | |
| 379 | - } | |
| 380 | - | |
| 381 | - /* continue to process the available input before reading more */ | |
| 382 | - } while (strm.avail_out != 0); | |
| 383 | - | |
| 384 | - if (ret == Z_STREAM_END) | |
| 385 | - /* reached the end of the compressed data -- return the data that | |
| 386 | - was available, possibly less than requested */ | |
| 387 | - break; | |
| 388 | - | |
| 389 | - /* do until offset reached and requested data read */ | |
| 390 | - } while (skip); | |
| 391 | - | |
| 392 | - /* compute the number of uncompressed bytes read after the offset */ | |
| 393 | - ret = skip ? 0 : len - strm.avail_out; | |
| 394 | - | |
| 395 | - /* clean up and return the bytes read, or the negative error */ | |
| 396 | - deflate_index_extract_ret: | |
| 397 | - (void)inflateEnd(&strm); | |
| 398 | - return ret; | |
| 126 | +// Decompression modes. These are the inflateInit2() windowBits parameter. | |
| 127 | +#define RAW -15 | |
| 128 | +#define ZLIB 15 | |
| 129 | +#define GZIP 31 | |
| 130 | + | |
| 131 | +// See comments in zran.h. | |
| 132 | +int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) { | |
| 133 | + // Set up inflation state. | |
| 134 | + z_stream strm = {0}; // inflate engine (gets fired up later) | |
| 135 | + unsigned char buf[CHUNK]; // input buffer | |
| 136 | + unsigned char win[WINSIZE] = {0}; // output sliding window | |
| 137 | + off_t totin = 0; // total bytes read from input | |
| 138 | + off_t totout = 0; // total bytes uncompressed | |
| 139 | + int mode = 0; // mode: RAW, ZLIB, or GZIP (0 => not set yet) | |
| 140 | + | |
| 141 | + // Decompress from in, generating access points along the way. | |
| 142 | + int ret; // the return value from zlib, or Z_ERRNO | |
| 143 | + off_t last; // last access point uncompressed offset | |
| 144 | + struct deflate_index *index = NULL; // list of access points | |
| 145 | + do { | |
| 146 | + // Assure available input, at least until reaching EOF. | |
| 147 | + if (strm.avail_in == 0) { | |
| 148 | + strm.avail_in = fread(buf, 1, sizeof(buf), in); | |
| 149 | + totin += strm.avail_in; | |
| 150 | + strm.next_in = buf; | |
| 151 | + if (strm.avail_in < sizeof(buf) && ferror(in)) { | |
| 152 | + ret = Z_ERRNO; | |
| 153 | + break; | |
| 154 | + } | |
| 155 | + | |
| 156 | + if (mode == 0) { | |
| 157 | + // At the start of the input -- determine the type. Assume raw | |
| 158 | + // if it is neither zlib nor gzip. This could in theory result | |
| 159 | + // in a false positive for zlib, but in practice the fill bits | |
| 160 | + // after a stored block are always zeros, so a raw stream won't | |
| 161 | + // start with an 8 in the low nybble. | |
| 162 | + mode = strm.avail_in == 0 ? RAW : // empty -- will fail | |
| 163 | + (strm.next_in[0] & 0xf) == 8 ? ZLIB : | |
| 164 | + strm.next_in[0] == 0x1f ? GZIP : | |
| 165 | + /* else */ RAW; | |
| 166 | + ret = inflateInit2(&strm, mode); | |
| 167 | + if (ret != Z_OK) | |
| 168 | + break; | |
| 169 | + } | |
| 170 | + } | |
| 171 | + | |
| 172 | + // Assure available output. This rotates the output through, for use as | |
| 173 | + // a sliding window on the uncompressed data. | |
| 174 | + if (strm.avail_out == 0) { | |
| 175 | + strm.avail_out = sizeof(win); | |
| 176 | + strm.next_out = win; | |
| 177 | + } | |
| 178 | + | |
| 179 | + if (mode == RAW && index == NULL) | |
| 180 | + // We skip the inflate() call at the start of raw deflate data in | |
| 181 | + // order generate an access point there. Set data_type to imitate | |
| 182 | + // the end of a header. | |
| 183 | + strm.data_type = 0x80; | |
| 184 | + else { | |
| 185 | + // Inflate and update the number of uncompressed bytes. | |
| 186 | + unsigned before = strm.avail_out; | |
| 187 | + ret = inflate(&strm, Z_BLOCK); | |
| 188 | + totout += before - strm.avail_out; | |
| 189 | + } | |
| 190 | + | |
| 191 | + if ((strm.data_type & 0xc0) == 0x80 && | |
| 192 | + (index == NULL || totout - last >= span)) { | |
| 193 | + // We are at the end of a header or a non-last deflate block, so we | |
| 194 | + // can add an access point here. Furthermore, we are either at the | |
| 195 | + // very start for the first access point, or there has been span or | |
| 196 | + // more uncompressed bytes since the last access point, so we want | |
| 197 | + // to add an access point here. | |
| 198 | + index = add_point(index, strm.data_type & 7, totin - strm.avail_in, | |
| 199 | + totout, strm.avail_out, win); | |
| 200 | + if (index == NULL) { | |
| 201 | + ret = Z_MEM_ERROR; | |
| 202 | + break; | |
| 203 | + } | |
| 204 | + last = totout; | |
| 205 | + } | |
| 206 | + | |
| 207 | + if (ret == Z_STREAM_END && mode == GZIP && | |
| 208 | + (strm.avail_in || ungetc(getc(in), in) != EOF)) | |
| 209 | + // There is more input after the end of a gzip member. Reset the | |
| 210 | + // inflate state to read another gzip member. On success, this will | |
| 211 | + // set ret to Z_OK to continue decompressing. | |
| 212 | + ret = inflateReset2(&strm, GZIP); | |
| 213 | + | |
| 214 | + // Keep going until Z_STREAM_END or error. If the compressed data ends | |
| 215 | + // prematurely without a file read error, Z_BUF_ERROR is returned. | |
| 216 | + } while (ret == Z_OK); | |
| 217 | + inflateEnd(&strm); | |
| 218 | + | |
| 219 | + if (ret != Z_STREAM_END) { | |
| 220 | + // An error was encountered. Discard the index and return a negative | |
| 221 | + // error code. | |
| 222 | + deflate_index_free(index); | |
| 223 | + return ret == Z_NEED_DICT ? Z_DATA_ERROR : ret; | |
| 224 | + } | |
| 225 | + | |
| 226 | + // Shrink the index to only the occupied access points and return it. | |
| 227 | + index->mode = mode; | |
| 228 | + index->length = totout; | |
| 229 | + point_t *list = realloc(index->list, sizeof(point_t) * index->have); | |
| 230 | + if (list == NULL) { | |
| 231 | + // Seems like a realloc() to make something smaller should always work, | |
| 232 | + // but just in case. | |
| 233 | + deflate_index_free(index); | |
| 234 | + return Z_MEM_ERROR; | |
| 235 | + } | |
| 236 | + index->list = list; | |
| 237 | + *built = index; | |
| 238 | + return index->have; | |
| 239 | +} | |
| 240 | + | |
| 241 | +#ifdef NOPRIME | |
| 242 | +// Support zlib versions before 1.2.3 (July 2005), or incomplete zlib clones | |
| 243 | +// that do not have inflatePrime(). | |
| 244 | + | |
| 245 | +# define INFLATEPRIME inflatePreface | |
| 246 | + | |
| 247 | +// Append the low bits bits of value to in[] at bit position *have, updating | |
| 248 | +// *have. value must be zero above its low bits bits. bits must be positive. | |
| 249 | +// This assumes that any bits above the *have bits in the last byte are zeros. | |
| 250 | +// That assumption is preserved on return, as any bits above *have + bits in | |
| 251 | +// the last byte written will be set to zeros. | |
| 252 | +static inline void append_bits(unsigned value, int bits, | |
| 253 | + unsigned char *in, int *have) { | |
| 254 | + in += *have >> 3; // where the first bits from value will go | |
| 255 | + int k = *have & 7; // the number of bits already there | |
| 256 | + *have += bits; | |
| 257 | + if (k) | |
| 258 | + *in |= value << k; // write value above the low k bits | |
| 259 | + else | |
| 260 | + *in = value; | |
| 261 | + k = 8 - k; // the number of bits just appended | |
| 262 | + while (bits > k) { | |
| 263 | + value >>= k; // drop the bits appended | |
| 264 | + bits -= k; | |
| 265 | + k = 8; // now at a byte boundary | |
| 266 | + *++in = value; | |
| 267 | + } | |
| 268 | +} | |
| 269 | + | |
| 270 | +// Insert enough bits in the form of empty deflate blocks in front of the the | |
| 271 | +// low bits bits of value, in order to bring the sequence to a byte boundary. | |
| 272 | +// Then feed that to inflate(). This does what inflatePrime() does, except that | |
| 273 | +// a negative value of bits is not supported. bits must be in 0..16. If the | |
| 274 | +// arguments are invalid, Z_STREAM_ERROR is returned. Otherwise the return | |
| 275 | +// value from inflate() is returned. | |
| 276 | +static int inflatePreface(z_stream *strm, int bits, int value) { | |
| 277 | + // Check input. | |
| 278 | + if (strm == Z_NULL || bits < 0 || bits > 16) | |
| 279 | + return Z_STREAM_ERROR; | |
| 280 | + if (bits == 0) | |
| 281 | + return Z_OK; | |
| 282 | + value &= (2 << (bits - 1)) - 1; | |
| 283 | + | |
| 284 | + // An empty dynamic block with an odd number of bits (95). The high bit of | |
| 285 | + // the last byte is unused. | |
| 286 | + static const unsigned char dyn[] = { | |
| 287 | + 4, 0xe0, 0x81, 8, 0, 0, 0, 0, 0x20, 0xa8, 0xab, 0x1f | |
| 288 | + }; | |
| 289 | + const int dynlen = 95; // number of bits in the block | |
| 290 | + | |
| 291 | + // Build an input buffer for inflate that is a multiple of eight bits in | |
| 292 | + // length, and that ends with the low bits bits of value. | |
| 293 | + unsigned char in[(dynlen + 3 * 10 + 16 + 7) / 8]; | |
| 294 | + int have = 0; | |
| 295 | + if (bits & 1) { | |
| 296 | + // Insert an empty dynamic block to get to an odd number of bits, so | |
| 297 | + // when bits bits from value are appended, we are at an even number of | |
| 298 | + // bits. | |
| 299 | + memcpy(in, dyn, sizeof(dyn)); | |
| 300 | + have = dynlen; | |
| 301 | + } | |
| 302 | + while ((have + bits) & 7) | |
| 303 | + // Insert empty fixed blocks until appending bits bits would put us on | |
| 304 | + // a byte boundary. This will insert at most three fixed blocks. | |
| 305 | + append_bits(2, 10, in, &have); | |
| 306 | + | |
| 307 | + // Append the bits bits from value, which takes us to a byte boundary. | |
| 308 | + append_bits(value, bits, in, &have); | |
| 309 | + | |
| 310 | + // Deliver the input to inflate(). There is no output space provided, but | |
| 311 | + // inflate() can't get stuck waiting on output not ingesting all of the | |
| 312 | + // provided input. The reason is that there will be at most 16 bits of | |
| 313 | + // input from value after the empty deflate blocks (which themselves | |
| 314 | + // generate no output). At least ten bits are needed to generate the first | |
| 315 | + // output byte from a fixed block. The last two bytes of the buffer have to | |
| 316 | + // be ingested in order to get ten bits, which is the most that value can | |
| 317 | + // occupy. | |
| 318 | + strm->avail_in = have >> 3; | |
| 319 | + strm->next_in = in; | |
| 320 | + strm->avail_out = 0; | |
| 321 | + strm->next_out = in; // not used, but can't be NULL | |
| 322 | + return inflate(strm, Z_NO_FLUSH); | |
| 323 | +} | |
| 324 | + | |
| 325 | +#else | |
| 326 | +# define INFLATEPRIME inflatePrime | |
| 327 | +#endif | |
| 328 | + | |
| 329 | +// See comments in zran.h. | |
| 330 | +ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index, | |
| 331 | + off_t offset, unsigned char *buf, size_t len) { | |
| 332 | + // Do a quick sanity check on the index. | |
| 333 | + if (index == NULL || index->have < 1 || index->list[0].out != 0) | |
| 334 | + return Z_STREAM_ERROR; | |
| 335 | + | |
| 336 | + // If nothing to extract, return zero bytes extracted. | |
| 337 | + if (len == 0 || offset < 0 || offset >= index->length) | |
| 338 | + return 0; | |
| 339 | + | |
| 340 | + // Find the access point closest to but not after offset. | |
| 341 | + int lo = -1, hi = index->have; | |
| 342 | + point_t *point = index->list; | |
| 343 | + while (hi - lo > 1) { | |
| 344 | + int mid = (lo + hi) >> 1; | |
| 345 | + if (offset < point[mid].out) | |
| 346 | + hi = mid; | |
| 347 | + else | |
| 348 | + lo = mid; | |
| 349 | + } | |
| 350 | + point += lo; | |
| 351 | + | |
| 352 | + // Initialize the input file and prime the inflate engine to start there. | |
| 353 | + int ret = fseeko(in, point->in - (point->bits ? 1 : 0), SEEK_SET); | |
| 354 | + if (ret == -1) | |
| 355 | + return Z_ERRNO; | |
| 356 | + int ch = 0; | |
| 357 | + if (point->bits && (ch = getc(in)) == EOF) | |
| 358 | + return ferror(in) ? Z_ERRNO : Z_BUF_ERROR; | |
| 359 | + z_stream strm = {0}; | |
| 360 | + ret = inflateInit2(&strm, RAW); | |
| 361 | + if (ret != Z_OK) | |
| 362 | + return ret; | |
| 363 | + if (point->bits) | |
| 364 | + INFLATEPRIME(&strm, point->bits, ch >> (8 - point->bits)); | |
| 365 | + inflateSetDictionary(&strm, point->window, WINSIZE); | |
| 366 | + | |
| 367 | + // Skip uncompressed bytes until offset reached, then satisfy request. | |
| 368 | + unsigned char input[CHUNK]; | |
| 369 | + unsigned char discard[WINSIZE]; | |
| 370 | + offset -= point->out; // number of bytes to skip to get to offset | |
| 371 | + size_t left = len; // number of bytes left to read after offset | |
| 372 | + do { | |
| 373 | + if (offset) { | |
| 374 | + // Discard up to offset uncompressed bytes. | |
| 375 | + strm.avail_out = offset < WINSIZE ? (unsigned)offset : WINSIZE; | |
| 376 | + strm.next_out = discard; | |
| 377 | + } | |
| 378 | + else { | |
| 379 | + // Uncompress up to left bytes into buf. | |
| 380 | + strm.avail_out = left < UINT_MAX ? (unsigned)left : UINT_MAX; | |
| 381 | + strm.next_out = buf + len - left; | |
| 382 | + } | |
| 383 | + | |
| 384 | + // Uncompress, setting got to the number of bytes uncompressed. | |
| 385 | + if (strm.avail_in == 0) { | |
| 386 | + // Assure available input. | |
| 387 | + strm.avail_in = fread(input, 1, CHUNK, in); | |
| 388 | + if (strm.avail_in < CHUNK && ferror(in)) { | |
| 389 | + ret = Z_ERRNO; | |
| 390 | + break; | |
| 391 | + } | |
| 392 | + strm.next_in = input; | |
| 393 | + } | |
| 394 | + unsigned got = strm.avail_out; | |
| 395 | + ret = inflate(&strm, Z_NO_FLUSH); | |
| 396 | + got -= strm.avail_out; | |
| 397 | + | |
| 398 | + // Update the appropriate count. | |
| 399 | + if (offset) | |
| 400 | + offset -= got; | |
| 401 | + else | |
| 402 | + left -= got; | |
| 403 | + | |
| 404 | + // If we're at the end of a gzip member and there's more to read, | |
| 405 | + // continue to the next gzip member. | |
| 406 | + if (ret == Z_STREAM_END && index->mode == GZIP) { | |
| 407 | + // Discard the gzip trailer. | |
| 408 | + unsigned drop = 8; // length of gzip trailer | |
| 409 | + if (strm.avail_in >= drop) { | |
| 410 | + strm.avail_in -= drop; | |
| 411 | + strm.next_in += drop; | |
| 412 | + } | |
| 413 | + else { | |
| 414 | + // Read and discard the remainder of the gzip trailer. | |
| 415 | + drop -= strm.avail_in; | |
| 416 | + strm.avail_in = 0; | |
| 417 | + do { | |
| 418 | + if (getc(in) == EOF) | |
| 419 | + // The input does not have a complete trailer. | |
| 420 | + return ferror(in) ? Z_ERRNO : Z_BUF_ERROR; | |
| 421 | + } while (--drop); | |
| 422 | + } | |
| 423 | + | |
| 424 | + if (strm.avail_in || ungetc(getc(in), in) != EOF) { | |
| 425 | + // There's more after the gzip trailer. Use inflate to skip the | |
| 426 | + // gzip header and resume the raw inflate there. | |
| 427 | + inflateReset2(&strm, GZIP); | |
| 428 | + do { | |
| 429 | + if (strm.avail_in == 0) { | |
| 430 | + strm.avail_in = fread(input, 1, CHUNK, in); | |
| 431 | + if (strm.avail_in < CHUNK && ferror(in)) { | |
| 432 | + ret = Z_ERRNO; | |
| 433 | + break; | |
| 434 | + } | |
| 435 | + strm.next_in = input; | |
| 436 | + } | |
| 437 | + strm.avail_out = WINSIZE; | |
| 438 | + strm.next_out = discard; | |
| 439 | + ret = inflate(&strm, Z_BLOCK); // stop at end of header | |
| 440 | + } while (ret == Z_OK && (strm.data_type & 0x80) == 0); | |
| 441 | + if (ret != Z_OK) | |
| 442 | + break; | |
| 443 | + inflateReset2(&strm, RAW); | |
| 444 | + } | |
| 445 | + } | |
| 446 | + | |
| 447 | + // Continue until we have the requested data, the deflate data has | |
| 448 | + // ended, or an error is encountered. | |
| 449 | + } while (ret == Z_OK && left); | |
| 450 | + inflateEnd(&strm); | |
| 451 | + | |
| 452 | + // Return the number of uncompressed bytes read into buf, or the error. | |
| 453 | + return ret == Z_OK || ret == Z_STREAM_END ? len - left : ret; | |
| 399 | 454 | } |
| 400 | 455 | |
| 401 | 456 | #ifdef TEST |
| 402 | 457 | |
| 403 | -#define SPAN 1048576L /* desired distance between access points */ | |
| 404 | -#define LEN 16384 /* number of bytes to extract */ | |
| 405 | - | |
| 406 | -/* Demonstrate the use of deflate_index_build() and deflate_index_extract() by | |
| 407 | - processing the file provided on the command line, and extracting LEN bytes | |
| 408 | - from 2/3rds of the way through the uncompressed output, writing that to | |
| 409 | - stdout. An offset can be provided as the second argument, in which case the | |
| 410 | - data is extracted from there instead. */ | |
| 411 | -int main(int argc, char **argv) | |
| 412 | -{ | |
| 413 | - int len; | |
| 414 | - off_t offset = -1; | |
| 415 | - FILE *in; | |
| 416 | - struct deflate_index *index = NULL; | |
| 417 | - unsigned char buf[LEN]; | |
| 418 | - | |
| 419 | - /* open input file */ | |
| 420 | - if (argc < 2 || argc > 3) { | |
| 421 | - fprintf(stderr, "usage: zran file.gz [offset]\n"); | |
| 458 | +#define SPAN 1048576L // desired distance between access points | |
| 459 | +#define LEN 16384 // number of bytes to extract | |
| 460 | + | |
| 461 | +// Demonstrate the use of deflate_index_build() and deflate_index_extract() by | |
| 462 | +// processing the file provided on the command line, and extracting LEN bytes | |
| 463 | +// from 2/3rds of the way through the uncompressed output, writing that to | |
| 464 | +// stdout. An offset can be provided as the second argument, in which case the | |
| 465 | +// data is extracted from there instead. | |
| 466 | +int main(int argc, char **argv) { | |
| 467 | + // Open the input file. | |
| 468 | + if (argc < 2 || argc > 3) { | |
| 469 | + fprintf(stderr, "usage: zran file.raw [offset]\n"); | |
| 422 | 470 | return 1; |
| 423 | 471 | } |
| 424 | - in = fopen(argv[1], "rb"); | |
| 472 | + FILE *in = fopen(argv[1], "rb"); | |
| 425 | 473 | if (in == NULL) { |
| 426 | 474 | fprintf(stderr, "zran: could not open %s for reading\n", argv[1]); |
| 427 | 475 | return 1; |
| 428 | 476 | } |
| 429 | 477 | |
| 430 | - /* get optional offset */ | |
| 478 | + // Get optional offset. | |
| 479 | + off_t offset = -1; | |
| 431 | 480 | if (argc == 3) { |
| 432 | 481 | char *end; |
| 433 | 482 | offset = strtoll(argv[2], &end, 10); |
| 434 | 483 | if (*end || offset < 0) { |
| 435 | 484 | fprintf(stderr, "zran: %s is not a valid offset\n", argv[2]); |
| 436 | 485 | return 1; |
| 437 | 486 | } |
| 438 | 487 | } |
| 439 | 488 | |
| 440 | - /* build index */ | |
| 441 | - len = deflate_index_build(in, SPAN, &index); | |
| 489 | + // Build index. | |
| 490 | + struct deflate_index *index = NULL; | |
| 491 | + int len = deflate_index_build(in, SPAN, &index); | |
| 442 | 492 | if (len < 0) { |
| 443 | 493 | fclose(in); |
| 444 | 494 | switch (len) { |
| 445 | 495 | case Z_MEM_ERROR: |
| 446 | 496 | fprintf(stderr, "zran: out of memory\n"); |
| 447 | 497 | break; |
| 498 | + case Z_BUF_ERROR: | |
| 499 | + fprintf(stderr, "zran: %s ended prematurely\n", argv[1]); | |
| 500 | + break; | |
| 448 | 501 | case Z_DATA_ERROR: |
| 449 | 502 | fprintf(stderr, "zran: compressed data error in %s\n", argv[1]); |
| 450 | 503 | break; |
| 451 | 504 | case Z_ERRNO: |
| 452 | 505 | fprintf(stderr, "zran: read error on %s\n", argv[1]); |
| @@ -456,24 +509,25 @@ | ||
| 456 | 509 | } |
| 457 | 510 | return 1; |
| 458 | 511 | } |
| 459 | 512 | fprintf(stderr, "zran: built index with %d access points\n", len); |
| 460 | 513 | |
| 461 | - /* use index by reading some bytes from an arbitrary offset */ | |
| 514 | + // Use index by reading some bytes from an arbitrary offset. | |
| 515 | + unsigned char buf[LEN]; | |
| 462 | 516 | if (offset == -1) |
| 463 | - offset = (index->length << 1) / 3; | |
| 464 | - len = deflate_index_extract(in, index, offset, buf, LEN); | |
| 465 | - if (len < 0) | |
| 517 | + offset = ((index->length + 1) << 1) / 3; | |
| 518 | + ptrdiff_t got = deflate_index_extract(in, index, offset, buf, LEN); | |
| 519 | + if (got < 0) | |
| 466 | 520 | fprintf(stderr, "zran: extraction failed: %s error\n", |
| 467 | - len == Z_MEM_ERROR ? "out of memory" : "input corrupted"); | |
| 521 | + got == Z_MEM_ERROR ? "out of memory" : "input corrupted"); | |
| 468 | 522 | else { |
| 469 | - fwrite(buf, 1, len, stdout); | |
| 470 | - fprintf(stderr, "zran: extracted %d bytes at %llu\n", len, offset); | |
| 523 | + fwrite(buf, 1, got, stdout); | |
| 524 | + fprintf(stderr, "zran: extracted %ld bytes at %lld\n", got, offset); | |
| 471 | 525 | } |
| 472 | 526 | |
| 473 | - /* clean up and exit */ | |
| 527 | + // Clean up and exit. | |
| 474 | 528 | deflate_index_free(index); |
| 475 | 529 | fclose(in); |
| 476 | 530 | return 0; |
| 477 | 531 | } |
| 478 | 532 | |
| 479 | 533 | #endif |
| 480 | 534 |
| --- compat/zlib/examples/zran.c | |
| +++ compat/zlib/examples/zran.c | |
| @@ -1,452 +1,505 @@ | |
| 1 | /* zran.c -- example of zlib/gzip stream indexing and random access |
| 2 | * Copyright (C) 2005, 2012, 2018 Mark Adler |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | * Version 1.2 14 Oct 2018 Mark Adler */ |
| 5 | |
| 6 | /* Version History: |
| 7 | 1.0 29 May 2005 First version |
| 8 | 1.1 29 Sep 2012 Fix memory reallocation error |
| 9 | 1.2 14 Oct 2018 Handle gzip streams with multiple members |
| 10 | Add a header file to facilitate usage in applications |
| 11 | */ |
| 12 | |
| 13 | /* Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary() |
| 14 | for random access of a compressed file. A file containing a zlib or gzip |
| 15 | stream is provided on the command line. The compressed stream is decoded in |
| 16 | its entirety, and an index built with access points about every SPAN bytes |
| 17 | in the uncompressed output. The compressed file is left open, and can then |
| 18 | be read randomly, having to decompress on the average SPAN/2 uncompressed |
| 19 | bytes before getting to the desired block of data. |
| 20 | |
| 21 | An access point can be created at the start of any deflate block, by saving |
| 22 | the starting file offset and bit of that block, and the 32K bytes of |
| 23 | uncompressed data that precede that block. Also the uncompressed offset of |
| 24 | that block is saved to provide a reference for locating a desired starting |
| 25 | point in the uncompressed stream. deflate_index_build() works by |
| 26 | decompressing the input zlib or gzip stream a block at a time, and at the |
| 27 | end of each block deciding if enough uncompressed data has gone by to |
| 28 | justify the creation of a new access point. If so, that point is saved in a |
| 29 | data structure that grows as needed to accommodate the points. |
| 30 | |
| 31 | To use the index, an offset in the uncompressed data is provided, for which |
| 32 | the latest access point at or preceding that offset is located in the index. |
| 33 | The input file is positioned to the specified location in the index, and if |
| 34 | necessary the first few bits of the compressed data is read from the file. |
| 35 | inflate is initialized with those bits and the 32K of uncompressed data, and |
| 36 | the decompression then proceeds until the desired offset in the file is |
| 37 | reached. Then the decompression continues to read the desired uncompressed |
| 38 | data from the file. |
| 39 | |
| 40 | Another approach would be to generate the index on demand. In that case, |
| 41 | requests for random access reads from the compressed data would try to use |
| 42 | the index, but if a read far enough past the end of the index is required, |
| 43 | then further index entries would be generated and added. |
| 44 | |
| 45 | There is some fair bit of overhead to starting inflation for the random |
| 46 | access, mainly copying the 32K byte dictionary. So if small pieces of the |
| 47 | file are being accessed, it would make sense to implement a cache to hold |
| 48 | some lookahead and avoid many calls to deflate_index_extract() for small |
| 49 | lengths. |
| 50 | |
| 51 | Another way to build an index would be to use inflateCopy(). That would |
| 52 | not be constrained to have access points at block boundaries, but requires |
| 53 | more memory per access point, and also cannot be saved to file due to the |
| 54 | use of pointers in the state. The approach here allows for storage of the |
| 55 | index in a file. |
| 56 | */ |
| 57 | |
| 58 | #include <stdio.h> |
| 59 | #include <stdlib.h> |
| 60 | #include <string.h> |
| 61 | #include "zlib.h" |
| 62 | #include "zran.h" |
| 63 | |
| 64 | #define WINSIZE 32768U /* sliding window size */ |
| 65 | #define CHUNK 16384 /* file input buffer size */ |
| 66 | |
| 67 | /* Access point entry. */ |
| 68 | struct point { |
| 69 | off_t out; /* corresponding offset in uncompressed data */ |
| 70 | off_t in; /* offset in input file of first full byte */ |
| 71 | int bits; /* number of bits (1-7) from byte at in-1, or 0 */ |
| 72 | unsigned char window[WINSIZE]; /* preceding 32K of uncompressed data */ |
| 73 | }; |
| 74 | |
| 75 | /* See comments in zran.h. */ |
| 76 | void deflate_index_free(struct deflate_index *index) |
| 77 | { |
| 78 | if (index != NULL) { |
| 79 | free(index->list); |
| 80 | free(index); |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /* Add an entry to the access point list. If out of memory, deallocate the |
| 85 | existing list and return NULL. index->gzip is the allocated size of the |
| 86 | index in point entries, until it is time for deflate_index_build() to |
| 87 | return, at which point gzip is set to indicate a gzip file or not. |
| 88 | */ |
| 89 | static struct deflate_index *addpoint(struct deflate_index *index, int bits, |
| 90 | off_t in, off_t out, unsigned left, |
| 91 | unsigned char *window) |
| 92 | { |
| 93 | struct point *next; |
| 94 | |
| 95 | /* if list is empty, create it (start with eight points) */ |
| 96 | if (index == NULL) { |
| 97 | index = malloc(sizeof(struct deflate_index)); |
| 98 | if (index == NULL) return NULL; |
| 99 | index->list = malloc(sizeof(struct point) << 3); |
| 100 | if (index->list == NULL) { |
| 101 | free(index); |
| 102 | return NULL; |
| 103 | } |
| 104 | index->gzip = 8; |
| 105 | index->have = 0; |
| 106 | } |
| 107 | |
| 108 | /* if list is full, make it bigger */ |
| 109 | else if (index->have == index->gzip) { |
| 110 | index->gzip <<= 1; |
| 111 | next = realloc(index->list, sizeof(struct point) * index->gzip); |
| 112 | if (next == NULL) { |
| 113 | deflate_index_free(index); |
| 114 | return NULL; |
| 115 | } |
| 116 | index->list = next; |
| 117 | } |
| 118 | |
| 119 | /* fill in entry and increment how many we have */ |
| 120 | next = (struct point *)(index->list) + index->have; |
| 121 | next->bits = bits; |
| 122 | next->in = in; |
| 123 | next->out = out; |
| 124 | if (left) |
| 125 | memcpy(next->window, window + WINSIZE - left, left); |
| 126 | if (left < WINSIZE) |
| 127 | memcpy(next->window + left, window, WINSIZE - left); |
| 128 | index->have++; |
| 129 | |
| 130 | /* return list, possibly reallocated */ |
| 131 | return index; |
| 132 | } |
| 133 | |
| 134 | /* See comments in zran.h. */ |
| 135 | int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) |
| 136 | { |
| 137 | int ret; |
| 138 | int gzip = 0; /* true if reading a gzip file */ |
| 139 | off_t totin, totout; /* our own total counters to avoid 4GB limit */ |
| 140 | off_t last; /* totout value of last access point */ |
| 141 | struct deflate_index *index; /* access points being generated */ |
| 142 | z_stream strm; |
| 143 | unsigned char input[CHUNK]; |
| 144 | unsigned char window[WINSIZE]; |
| 145 | |
| 146 | /* initialize inflate */ |
| 147 | strm.zalloc = Z_NULL; |
| 148 | strm.zfree = Z_NULL; |
| 149 | strm.opaque = Z_NULL; |
| 150 | strm.avail_in = 0; |
| 151 | strm.next_in = Z_NULL; |
| 152 | ret = inflateInit2(&strm, 47); /* automatic zlib or gzip decoding */ |
| 153 | if (ret != Z_OK) |
| 154 | return ret; |
| 155 | |
| 156 | /* inflate the input, maintain a sliding window, and build an index -- this |
| 157 | also validates the integrity of the compressed data using the check |
| 158 | information in the gzip or zlib stream */ |
| 159 | totin = totout = last = 0; |
| 160 | index = NULL; /* will be allocated by first addpoint() */ |
| 161 | strm.avail_out = 0; |
| 162 | do { |
| 163 | /* get some compressed data from input file */ |
| 164 | strm.avail_in = fread(input, 1, CHUNK, in); |
| 165 | if (ferror(in)) { |
| 166 | ret = Z_ERRNO; |
| 167 | goto deflate_index_build_error; |
| 168 | } |
| 169 | if (strm.avail_in == 0) { |
| 170 | ret = Z_DATA_ERROR; |
| 171 | goto deflate_index_build_error; |
| 172 | } |
| 173 | strm.next_in = input; |
| 174 | |
| 175 | /* check for a gzip stream */ |
| 176 | if (totin == 0 && strm.avail_in >= 3 && |
| 177 | input[0] == 31 && input[1] == 139 && input[2] == 8) |
| 178 | gzip = 1; |
| 179 | |
| 180 | /* process all of that, or until end of stream */ |
| 181 | do { |
| 182 | /* reset sliding window if necessary */ |
| 183 | if (strm.avail_out == 0) { |
| 184 | strm.avail_out = WINSIZE; |
| 185 | strm.next_out = window; |
| 186 | } |
| 187 | |
| 188 | /* inflate until out of input, output, or at end of block -- |
| 189 | update the total input and output counters */ |
| 190 | totin += strm.avail_in; |
| 191 | totout += strm.avail_out; |
| 192 | ret = inflate(&strm, Z_BLOCK); /* return at end of block */ |
| 193 | totin -= strm.avail_in; |
| 194 | totout -= strm.avail_out; |
| 195 | if (ret == Z_NEED_DICT) |
| 196 | ret = Z_DATA_ERROR; |
| 197 | if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR) |
| 198 | goto deflate_index_build_error; |
| 199 | if (ret == Z_STREAM_END) { |
| 200 | if (gzip && |
| 201 | (strm.avail_in || ungetc(getc(in), in) != EOF)) { |
| 202 | ret = inflateReset(&strm); |
| 203 | if (ret != Z_OK) |
| 204 | goto deflate_index_build_error; |
| 205 | continue; |
| 206 | } |
| 207 | break; |
| 208 | } |
| 209 | |
| 210 | /* if at end of block, consider adding an index entry (note that if |
| 211 | data_type indicates an end-of-block, then all of the |
| 212 | uncompressed data from that block has been delivered, and none |
| 213 | of the compressed data after that block has been consumed, |
| 214 | except for up to seven bits) -- the totout == 0 provides an |
| 215 | entry point after the zlib or gzip header, and assures that the |
| 216 | index always has at least one access point; we avoid creating an |
| 217 | access point after the last block by checking bit 6 of data_type |
| 218 | */ |
| 219 | if ((strm.data_type & 128) && !(strm.data_type & 64) && |
| 220 | (totout == 0 || totout - last > span)) { |
| 221 | index = addpoint(index, strm.data_type & 7, totin, |
| 222 | totout, strm.avail_out, window); |
| 223 | if (index == NULL) { |
| 224 | ret = Z_MEM_ERROR; |
| 225 | goto deflate_index_build_error; |
| 226 | } |
| 227 | last = totout; |
| 228 | } |
| 229 | } while (strm.avail_in != 0); |
| 230 | } while (ret != Z_STREAM_END); |
| 231 | |
| 232 | /* clean up and return index (release unused entries in list) */ |
| 233 | (void)inflateEnd(&strm); |
| 234 | index->list = realloc(index->list, sizeof(struct point) * index->have); |
| 235 | index->gzip = gzip; |
| 236 | index->length = totout; |
| 237 | *built = index; |
| 238 | return index->have; |
| 239 | |
| 240 | /* return error */ |
| 241 | deflate_index_build_error: |
| 242 | (void)inflateEnd(&strm); |
| 243 | deflate_index_free(index); |
| 244 | return ret; |
| 245 | } |
| 246 | |
| 247 | /* See comments in zran.h. */ |
| 248 | int deflate_index_extract(FILE *in, struct deflate_index *index, off_t offset, |
| 249 | unsigned char *buf, int len) |
| 250 | { |
| 251 | int ret, skip; |
| 252 | z_stream strm; |
| 253 | struct point *here; |
| 254 | unsigned char input[CHUNK]; |
| 255 | unsigned char discard[WINSIZE]; |
| 256 | |
| 257 | /* proceed only if something reasonable to do */ |
| 258 | if (len < 0) |
| 259 | return 0; |
| 260 | |
| 261 | /* find where in stream to start */ |
| 262 | here = index->list; |
| 263 | ret = index->have; |
| 264 | while (--ret && here[1].out <= offset) |
| 265 | here++; |
| 266 | |
| 267 | /* initialize file and inflate state to start there */ |
| 268 | strm.zalloc = Z_NULL; |
| 269 | strm.zfree = Z_NULL; |
| 270 | strm.opaque = Z_NULL; |
| 271 | strm.avail_in = 0; |
| 272 | strm.next_in = Z_NULL; |
| 273 | ret = inflateInit2(&strm, -15); /* raw inflate */ |
| 274 | if (ret != Z_OK) |
| 275 | return ret; |
| 276 | ret = fseeko(in, here->in - (here->bits ? 1 : 0), SEEK_SET); |
| 277 | if (ret == -1) |
| 278 | goto deflate_index_extract_ret; |
| 279 | if (here->bits) { |
| 280 | ret = getc(in); |
| 281 | if (ret == -1) { |
| 282 | ret = ferror(in) ? Z_ERRNO : Z_DATA_ERROR; |
| 283 | goto deflate_index_extract_ret; |
| 284 | } |
| 285 | (void)inflatePrime(&strm, here->bits, ret >> (8 - here->bits)); |
| 286 | } |
| 287 | (void)inflateSetDictionary(&strm, here->window, WINSIZE); |
| 288 | |
| 289 | /* skip uncompressed bytes until offset reached, then satisfy request */ |
| 290 | offset -= here->out; |
| 291 | strm.avail_in = 0; |
| 292 | skip = 1; /* while skipping to offset */ |
| 293 | do { |
| 294 | /* define where to put uncompressed data, and how much */ |
| 295 | if (offset > WINSIZE) { /* skip WINSIZE bytes */ |
| 296 | strm.avail_out = WINSIZE; |
| 297 | strm.next_out = discard; |
| 298 | offset -= WINSIZE; |
| 299 | } |
| 300 | else if (offset > 0) { /* last skip */ |
| 301 | strm.avail_out = (unsigned)offset; |
| 302 | strm.next_out = discard; |
| 303 | offset = 0; |
| 304 | } |
| 305 | else if (skip) { /* at offset now */ |
| 306 | strm.avail_out = len; |
| 307 | strm.next_out = buf; |
| 308 | skip = 0; /* only do this once */ |
| 309 | } |
| 310 | |
| 311 | /* uncompress until avail_out filled, or end of stream */ |
| 312 | do { |
| 313 | if (strm.avail_in == 0) { |
| 314 | strm.avail_in = fread(input, 1, CHUNK, in); |
| 315 | if (ferror(in)) { |
| 316 | ret = Z_ERRNO; |
| 317 | goto deflate_index_extract_ret; |
| 318 | } |
| 319 | if (strm.avail_in == 0) { |
| 320 | ret = Z_DATA_ERROR; |
| 321 | goto deflate_index_extract_ret; |
| 322 | } |
| 323 | strm.next_in = input; |
| 324 | } |
| 325 | ret = inflate(&strm, Z_NO_FLUSH); /* normal inflate */ |
| 326 | if (ret == Z_NEED_DICT) |
| 327 | ret = Z_DATA_ERROR; |
| 328 | if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR) |
| 329 | goto deflate_index_extract_ret; |
| 330 | if (ret == Z_STREAM_END) { |
| 331 | /* the raw deflate stream has ended */ |
| 332 | if (index->gzip == 0) |
| 333 | /* this is a zlib stream that has ended -- done */ |
| 334 | break; |
| 335 | |
| 336 | /* near the end of a gzip member, which might be followed by |
| 337 | another gzip member -- skip the gzip trailer and see if |
| 338 | there is more input after it */ |
| 339 | if (strm.avail_in < 8) { |
| 340 | fseeko(in, 8 - strm.avail_in, SEEK_CUR); |
| 341 | strm.avail_in = 0; |
| 342 | } |
| 343 | else { |
| 344 | strm.avail_in -= 8; |
| 345 | strm.next_in += 8; |
| 346 | } |
| 347 | if (strm.avail_in == 0 && ungetc(getc(in), in) == EOF) |
| 348 | /* the input ended after the gzip trailer -- done */ |
| 349 | break; |
| 350 | |
| 351 | /* there is more input, so another gzip member should follow -- |
| 352 | validate and skip the gzip header */ |
| 353 | ret = inflateReset2(&strm, 31); |
| 354 | if (ret != Z_OK) |
| 355 | goto deflate_index_extract_ret; |
| 356 | do { |
| 357 | if (strm.avail_in == 0) { |
| 358 | strm.avail_in = fread(input, 1, CHUNK, in); |
| 359 | if (ferror(in)) { |
| 360 | ret = Z_ERRNO; |
| 361 | goto deflate_index_extract_ret; |
| 362 | } |
| 363 | if (strm.avail_in == 0) { |
| 364 | ret = Z_DATA_ERROR; |
| 365 | goto deflate_index_extract_ret; |
| 366 | } |
| 367 | strm.next_in = input; |
| 368 | } |
| 369 | ret = inflate(&strm, Z_BLOCK); |
| 370 | if (ret == Z_MEM_ERROR || ret == Z_DATA_ERROR) |
| 371 | goto deflate_index_extract_ret; |
| 372 | } while ((strm.data_type & 128) == 0); |
| 373 | |
| 374 | /* set up to continue decompression of the raw deflate stream |
| 375 | that follows the gzip header */ |
| 376 | ret = inflateReset2(&strm, -15); |
| 377 | if (ret != Z_OK) |
| 378 | goto deflate_index_extract_ret; |
| 379 | } |
| 380 | |
| 381 | /* continue to process the available input before reading more */ |
| 382 | } while (strm.avail_out != 0); |
| 383 | |
| 384 | if (ret == Z_STREAM_END) |
| 385 | /* reached the end of the compressed data -- return the data that |
| 386 | was available, possibly less than requested */ |
| 387 | break; |
| 388 | |
| 389 | /* do until offset reached and requested data read */ |
| 390 | } while (skip); |
| 391 | |
| 392 | /* compute the number of uncompressed bytes read after the offset */ |
| 393 | ret = skip ? 0 : len - strm.avail_out; |
| 394 | |
| 395 | /* clean up and return the bytes read, or the negative error */ |
| 396 | deflate_index_extract_ret: |
| 397 | (void)inflateEnd(&strm); |
| 398 | return ret; |
| 399 | } |
| 400 | |
| 401 | #ifdef TEST |
| 402 | |
| 403 | #define SPAN 1048576L /* desired distance between access points */ |
| 404 | #define LEN 16384 /* number of bytes to extract */ |
| 405 | |
| 406 | /* Demonstrate the use of deflate_index_build() and deflate_index_extract() by |
| 407 | processing the file provided on the command line, and extracting LEN bytes |
| 408 | from 2/3rds of the way through the uncompressed output, writing that to |
| 409 | stdout. An offset can be provided as the second argument, in which case the |
| 410 | data is extracted from there instead. */ |
| 411 | int main(int argc, char **argv) |
| 412 | { |
| 413 | int len; |
| 414 | off_t offset = -1; |
| 415 | FILE *in; |
| 416 | struct deflate_index *index = NULL; |
| 417 | unsigned char buf[LEN]; |
| 418 | |
| 419 | /* open input file */ |
| 420 | if (argc < 2 || argc > 3) { |
| 421 | fprintf(stderr, "usage: zran file.gz [offset]\n"); |
| 422 | return 1; |
| 423 | } |
| 424 | in = fopen(argv[1], "rb"); |
| 425 | if (in == NULL) { |
| 426 | fprintf(stderr, "zran: could not open %s for reading\n", argv[1]); |
| 427 | return 1; |
| 428 | } |
| 429 | |
| 430 | /* get optional offset */ |
| 431 | if (argc == 3) { |
| 432 | char *end; |
| 433 | offset = strtoll(argv[2], &end, 10); |
| 434 | if (*end || offset < 0) { |
| 435 | fprintf(stderr, "zran: %s is not a valid offset\n", argv[2]); |
| 436 | return 1; |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | /* build index */ |
| 441 | len = deflate_index_build(in, SPAN, &index); |
| 442 | if (len < 0) { |
| 443 | fclose(in); |
| 444 | switch (len) { |
| 445 | case Z_MEM_ERROR: |
| 446 | fprintf(stderr, "zran: out of memory\n"); |
| 447 | break; |
| 448 | case Z_DATA_ERROR: |
| 449 | fprintf(stderr, "zran: compressed data error in %s\n", argv[1]); |
| 450 | break; |
| 451 | case Z_ERRNO: |
| 452 | fprintf(stderr, "zran: read error on %s\n", argv[1]); |
| @@ -456,24 +509,25 @@ | |
| 456 | } |
| 457 | return 1; |
| 458 | } |
| 459 | fprintf(stderr, "zran: built index with %d access points\n", len); |
| 460 | |
| 461 | /* use index by reading some bytes from an arbitrary offset */ |
| 462 | if (offset == -1) |
| 463 | offset = (index->length << 1) / 3; |
| 464 | len = deflate_index_extract(in, index, offset, buf, LEN); |
| 465 | if (len < 0) |
| 466 | fprintf(stderr, "zran: extraction failed: %s error\n", |
| 467 | len == Z_MEM_ERROR ? "out of memory" : "input corrupted"); |
| 468 | else { |
| 469 | fwrite(buf, 1, len, stdout); |
| 470 | fprintf(stderr, "zran: extracted %d bytes at %llu\n", len, offset); |
| 471 | } |
| 472 | |
| 473 | /* clean up and exit */ |
| 474 | deflate_index_free(index); |
| 475 | fclose(in); |
| 476 | return 0; |
| 477 | } |
| 478 | |
| 479 | #endif |
| 480 |
| --- compat/zlib/examples/zran.c | |
| +++ compat/zlib/examples/zran.c | |
| @@ -1,452 +1,505 @@ | |
| 1 | /* zran.c -- example of deflate stream indexing and random access |
| 2 | * Copyright (C) 2005, 2012, 2018, 2023 Mark Adler |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | * Version 1.4 13 Apr 2023 Mark Adler */ |
| 5 | |
| 6 | /* Version History: |
| 7 | 1.0 29 May 2005 First version |
| 8 | 1.1 29 Sep 2012 Fix memory reallocation error |
| 9 | 1.2 14 Oct 2018 Handle gzip streams with multiple members |
| 10 | Add a header file to facilitate usage in applications |
| 11 | 1.3 18 Feb 2023 Permit raw deflate streams as well as zlib and gzip |
| 12 | Permit crossing gzip member boundaries when extracting |
| 13 | Support a size_t size when extracting (was an int) |
| 14 | Do a binary search over the index for an access point |
| 15 | Expose the access point type to enable save and load |
| 16 | 1.4 13 Apr 2023 Add a NOPRIME define to not use inflatePrime() |
| 17 | */ |
| 18 | |
| 19 | // Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary() |
| 20 | // for random access of a compressed file. A file containing a raw deflate |
| 21 | // stream is provided on the command line. The compressed stream is decoded in |
| 22 | // its entirety, and an index built with access points about every SPAN bytes |
| 23 | // in the uncompressed output. The compressed file is left open, and can then |
| 24 | // be read randomly, having to decompress on the average SPAN/2 uncompressed |
| 25 | // bytes before getting to the desired block of data. |
| 26 | // |
| 27 | // An access point can be created at the start of any deflate block, by saving |
| 28 | // the starting file offset and bit of that block, and the 32K bytes of |
| 29 | // uncompressed data that precede that block. Also the uncompressed offset of |
| 30 | // that block is saved to provide a reference for locating a desired starting |
| 31 | // point in the uncompressed stream. deflate_index_build() decompresses the |
| 32 | // input raw deflate stream a block at a time, and at the end of each block |
| 33 | // decides if enough uncompressed data has gone by to justify the creation of a |
| 34 | // new access point. If so, that point is saved in a data structure that grows |
| 35 | // as needed to accommodate the points. |
| 36 | // |
| 37 | // To use the index, an offset in the uncompressed data is provided, for which |
| 38 | // the latest access point at or preceding that offset is located in the index. |
| 39 | // The input file is positioned to the specified location in the index, and if |
| 40 | // necessary the first few bits of the compressed data is read from the file. |
| 41 | // inflate is initialized with those bits and the 32K of uncompressed data, and |
| 42 | // decompression then proceeds until the desired offset in the file is reached. |
| 43 | // Then decompression continues to read the requested uncompressed data from |
| 44 | // the file. |
| 45 | // |
| 46 | // There is some fair bit of overhead to starting inflation for the random |
| 47 | // access, mainly copying the 32K byte dictionary. If small pieces of the file |
| 48 | // are being accessed, it would make sense to implement a cache to hold some |
| 49 | // lookahead to avoid many calls to deflate_index_extract() for small lengths. |
| 50 | // |
| 51 | // Another way to build an index would be to use inflateCopy(). That would not |
| 52 | // be constrained to have access points at block boundaries, but would require |
| 53 | // more memory per access point, and could not be saved to a file due to the |
| 54 | // use of pointers in the state. The approach here allows for storage of the |
| 55 | // index in a file. |
| 56 | |
| 57 | #include <stdio.h> |
| 58 | #include <stdlib.h> |
| 59 | #include <string.h> |
| 60 | #include <limits.h> |
| 61 | #include "zlib.h" |
| 62 | #include "zran.h" |
| 63 | |
| 64 | #define WINSIZE 32768U // sliding window size |
| 65 | #define CHUNK 16384 // file input buffer size |
| 66 | |
| 67 | // See comments in zran.h. |
| 68 | void deflate_index_free(struct deflate_index *index) { |
| 69 | if (index != NULL) { |
| 70 | free(index->list); |
| 71 | free(index); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // Add an access point to the list. If out of memory, deallocate the existing |
| 76 | // list and return NULL. index->mode is temporarily the allocated number of |
| 77 | // access points, until it is time for deflate_index_build() to return. Then |
| 78 | // index->mode is set to the mode of inflation. |
| 79 | static struct deflate_index *add_point(struct deflate_index *index, int bits, |
| 80 | off_t in, off_t out, unsigned left, |
| 81 | unsigned char *window) { |
| 82 | if (index == NULL) { |
| 83 | // The list is empty. Create it, starting with eight access points. |
| 84 | index = malloc(sizeof(struct deflate_index)); |
| 85 | if (index == NULL) |
| 86 | return NULL; |
| 87 | index->have = 0; |
| 88 | index->mode = 8; |
| 89 | index->list = malloc(sizeof(point_t) * index->mode); |
| 90 | if (index->list == NULL) { |
| 91 | free(index); |
| 92 | return NULL; |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | else if (index->have == index->mode) { |
| 97 | // The list is full. Make it bigger. |
| 98 | index->mode <<= 1; |
| 99 | point_t *next = realloc(index->list, sizeof(point_t) * index->mode); |
| 100 | if (next == NULL) { |
| 101 | deflate_index_free(index); |
| 102 | return NULL; |
| 103 | } |
| 104 | index->list = next; |
| 105 | } |
| 106 | |
| 107 | // Fill in the access point and increment how many we have. |
| 108 | point_t *next = (point_t *)(index->list) + index->have++; |
| 109 | if (index->have < 0) { |
| 110 | // Overflowed the int! |
| 111 | deflate_index_free(index); |
| 112 | return NULL; |
| 113 | } |
| 114 | next->out = out; |
| 115 | next->in = in; |
| 116 | next->bits = bits; |
| 117 | if (left) |
| 118 | memcpy(next->window, window + WINSIZE - left, left); |
| 119 | if (left < WINSIZE) |
| 120 | memcpy(next->window + left, window, WINSIZE - left); |
| 121 | |
| 122 | // Return the index, which may have been newly allocated or destroyed. |
| 123 | return index; |
| 124 | } |
| 125 | |
| 126 | // Decompression modes. These are the inflateInit2() windowBits parameter. |
| 127 | #define RAW -15 |
| 128 | #define ZLIB 15 |
| 129 | #define GZIP 31 |
| 130 | |
| 131 | // See comments in zran.h. |
| 132 | int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) { |
| 133 | // Set up inflation state. |
| 134 | z_stream strm = {0}; // inflate engine (gets fired up later) |
| 135 | unsigned char buf[CHUNK]; // input buffer |
| 136 | unsigned char win[WINSIZE] = {0}; // output sliding window |
| 137 | off_t totin = 0; // total bytes read from input |
| 138 | off_t totout = 0; // total bytes uncompressed |
| 139 | int mode = 0; // mode: RAW, ZLIB, or GZIP (0 => not set yet) |
| 140 | |
| 141 | // Decompress from in, generating access points along the way. |
| 142 | int ret; // the return value from zlib, or Z_ERRNO |
| 143 | off_t last; // last access point uncompressed offset |
| 144 | struct deflate_index *index = NULL; // list of access points |
| 145 | do { |
| 146 | // Assure available input, at least until reaching EOF. |
| 147 | if (strm.avail_in == 0) { |
| 148 | strm.avail_in = fread(buf, 1, sizeof(buf), in); |
| 149 | totin += strm.avail_in; |
| 150 | strm.next_in = buf; |
| 151 | if (strm.avail_in < sizeof(buf) && ferror(in)) { |
| 152 | ret = Z_ERRNO; |
| 153 | break; |
| 154 | } |
| 155 | |
| 156 | if (mode == 0) { |
| 157 | // At the start of the input -- determine the type. Assume raw |
| 158 | // if it is neither zlib nor gzip. This could in theory result |
| 159 | // in a false positive for zlib, but in practice the fill bits |
| 160 | // after a stored block are always zeros, so a raw stream won't |
| 161 | // start with an 8 in the low nybble. |
| 162 | mode = strm.avail_in == 0 ? RAW : // empty -- will fail |
| 163 | (strm.next_in[0] & 0xf) == 8 ? ZLIB : |
| 164 | strm.next_in[0] == 0x1f ? GZIP : |
| 165 | /* else */ RAW; |
| 166 | ret = inflateInit2(&strm, mode); |
| 167 | if (ret != Z_OK) |
| 168 | break; |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | // Assure available output. This rotates the output through, for use as |
| 173 | // a sliding window on the uncompressed data. |
| 174 | if (strm.avail_out == 0) { |
| 175 | strm.avail_out = sizeof(win); |
| 176 | strm.next_out = win; |
| 177 | } |
| 178 | |
| 179 | if (mode == RAW && index == NULL) |
| 180 | // We skip the inflate() call at the start of raw deflate data in |
| 181 | // order generate an access point there. Set data_type to imitate |
| 182 | // the end of a header. |
| 183 | strm.data_type = 0x80; |
| 184 | else { |
| 185 | // Inflate and update the number of uncompressed bytes. |
| 186 | unsigned before = strm.avail_out; |
| 187 | ret = inflate(&strm, Z_BLOCK); |
| 188 | totout += before - strm.avail_out; |
| 189 | } |
| 190 | |
| 191 | if ((strm.data_type & 0xc0) == 0x80 && |
| 192 | (index == NULL || totout - last >= span)) { |
| 193 | // We are at the end of a header or a non-last deflate block, so we |
| 194 | // can add an access point here. Furthermore, we are either at the |
| 195 | // very start for the first access point, or there has been span or |
| 196 | // more uncompressed bytes since the last access point, so we want |
| 197 | // to add an access point here. |
| 198 | index = add_point(index, strm.data_type & 7, totin - strm.avail_in, |
| 199 | totout, strm.avail_out, win); |
| 200 | if (index == NULL) { |
| 201 | ret = Z_MEM_ERROR; |
| 202 | break; |
| 203 | } |
| 204 | last = totout; |
| 205 | } |
| 206 | |
| 207 | if (ret == Z_STREAM_END && mode == GZIP && |
| 208 | (strm.avail_in || ungetc(getc(in), in) != EOF)) |
| 209 | // There is more input after the end of a gzip member. Reset the |
| 210 | // inflate state to read another gzip member. On success, this will |
| 211 | // set ret to Z_OK to continue decompressing. |
| 212 | ret = inflateReset2(&strm, GZIP); |
| 213 | |
| 214 | // Keep going until Z_STREAM_END or error. If the compressed data ends |
| 215 | // prematurely without a file read error, Z_BUF_ERROR is returned. |
| 216 | } while (ret == Z_OK); |
| 217 | inflateEnd(&strm); |
| 218 | |
| 219 | if (ret != Z_STREAM_END) { |
| 220 | // An error was encountered. Discard the index and return a negative |
| 221 | // error code. |
| 222 | deflate_index_free(index); |
| 223 | return ret == Z_NEED_DICT ? Z_DATA_ERROR : ret; |
| 224 | } |
| 225 | |
| 226 | // Shrink the index to only the occupied access points and return it. |
| 227 | index->mode = mode; |
| 228 | index->length = totout; |
| 229 | point_t *list = realloc(index->list, sizeof(point_t) * index->have); |
| 230 | if (list == NULL) { |
| 231 | // Seems like a realloc() to make something smaller should always work, |
| 232 | // but just in case. |
| 233 | deflate_index_free(index); |
| 234 | return Z_MEM_ERROR; |
| 235 | } |
| 236 | index->list = list; |
| 237 | *built = index; |
| 238 | return index->have; |
| 239 | } |
| 240 | |
| 241 | #ifdef NOPRIME |
| 242 | // Support zlib versions before 1.2.3 (July 2005), or incomplete zlib clones |
| 243 | // that do not have inflatePrime(). |
| 244 | |
| 245 | # define INFLATEPRIME inflatePreface |
| 246 | |
| 247 | // Append the low bits bits of value to in[] at bit position *have, updating |
| 248 | // *have. value must be zero above its low bits bits. bits must be positive. |
| 249 | // This assumes that any bits above the *have bits in the last byte are zeros. |
| 250 | // That assumption is preserved on return, as any bits above *have + bits in |
| 251 | // the last byte written will be set to zeros. |
| 252 | static inline void append_bits(unsigned value, int bits, |
| 253 | unsigned char *in, int *have) { |
| 254 | in += *have >> 3; // where the first bits from value will go |
| 255 | int k = *have & 7; // the number of bits already there |
| 256 | *have += bits; |
| 257 | if (k) |
| 258 | *in |= value << k; // write value above the low k bits |
| 259 | else |
| 260 | *in = value; |
| 261 | k = 8 - k; // the number of bits just appended |
| 262 | while (bits > k) { |
| 263 | value >>= k; // drop the bits appended |
| 264 | bits -= k; |
| 265 | k = 8; // now at a byte boundary |
| 266 | *++in = value; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | // Insert enough bits in the form of empty deflate blocks in front of the the |
| 271 | // low bits bits of value, in order to bring the sequence to a byte boundary. |
| 272 | // Then feed that to inflate(). This does what inflatePrime() does, except that |
| 273 | // a negative value of bits is not supported. bits must be in 0..16. If the |
| 274 | // arguments are invalid, Z_STREAM_ERROR is returned. Otherwise the return |
| 275 | // value from inflate() is returned. |
| 276 | static int inflatePreface(z_stream *strm, int bits, int value) { |
| 277 | // Check input. |
| 278 | if (strm == Z_NULL || bits < 0 || bits > 16) |
| 279 | return Z_STREAM_ERROR; |
| 280 | if (bits == 0) |
| 281 | return Z_OK; |
| 282 | value &= (2 << (bits - 1)) - 1; |
| 283 | |
| 284 | // An empty dynamic block with an odd number of bits (95). The high bit of |
| 285 | // the last byte is unused. |
| 286 | static const unsigned char dyn[] = { |
| 287 | 4, 0xe0, 0x81, 8, 0, 0, 0, 0, 0x20, 0xa8, 0xab, 0x1f |
| 288 | }; |
| 289 | const int dynlen = 95; // number of bits in the block |
| 290 | |
| 291 | // Build an input buffer for inflate that is a multiple of eight bits in |
| 292 | // length, and that ends with the low bits bits of value. |
| 293 | unsigned char in[(dynlen + 3 * 10 + 16 + 7) / 8]; |
| 294 | int have = 0; |
| 295 | if (bits & 1) { |
| 296 | // Insert an empty dynamic block to get to an odd number of bits, so |
| 297 | // when bits bits from value are appended, we are at an even number of |
| 298 | // bits. |
| 299 | memcpy(in, dyn, sizeof(dyn)); |
| 300 | have = dynlen; |
| 301 | } |
| 302 | while ((have + bits) & 7) |
| 303 | // Insert empty fixed blocks until appending bits bits would put us on |
| 304 | // a byte boundary. This will insert at most three fixed blocks. |
| 305 | append_bits(2, 10, in, &have); |
| 306 | |
| 307 | // Append the bits bits from value, which takes us to a byte boundary. |
| 308 | append_bits(value, bits, in, &have); |
| 309 | |
| 310 | // Deliver the input to inflate(). There is no output space provided, but |
| 311 | // inflate() can't get stuck waiting on output not ingesting all of the |
| 312 | // provided input. The reason is that there will be at most 16 bits of |
| 313 | // input from value after the empty deflate blocks (which themselves |
| 314 | // generate no output). At least ten bits are needed to generate the first |
| 315 | // output byte from a fixed block. The last two bytes of the buffer have to |
| 316 | // be ingested in order to get ten bits, which is the most that value can |
| 317 | // occupy. |
| 318 | strm->avail_in = have >> 3; |
| 319 | strm->next_in = in; |
| 320 | strm->avail_out = 0; |
| 321 | strm->next_out = in; // not used, but can't be NULL |
| 322 | return inflate(strm, Z_NO_FLUSH); |
| 323 | } |
| 324 | |
| 325 | #else |
| 326 | # define INFLATEPRIME inflatePrime |
| 327 | #endif |
| 328 | |
| 329 | // See comments in zran.h. |
| 330 | ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index, |
| 331 | off_t offset, unsigned char *buf, size_t len) { |
| 332 | // Do a quick sanity check on the index. |
| 333 | if (index == NULL || index->have < 1 || index->list[0].out != 0) |
| 334 | return Z_STREAM_ERROR; |
| 335 | |
| 336 | // If nothing to extract, return zero bytes extracted. |
| 337 | if (len == 0 || offset < 0 || offset >= index->length) |
| 338 | return 0; |
| 339 | |
| 340 | // Find the access point closest to but not after offset. |
| 341 | int lo = -1, hi = index->have; |
| 342 | point_t *point = index->list; |
| 343 | while (hi - lo > 1) { |
| 344 | int mid = (lo + hi) >> 1; |
| 345 | if (offset < point[mid].out) |
| 346 | hi = mid; |
| 347 | else |
| 348 | lo = mid; |
| 349 | } |
| 350 | point += lo; |
| 351 | |
| 352 | // Initialize the input file and prime the inflate engine to start there. |
| 353 | int ret = fseeko(in, point->in - (point->bits ? 1 : 0), SEEK_SET); |
| 354 | if (ret == -1) |
| 355 | return Z_ERRNO; |
| 356 | int ch = 0; |
| 357 | if (point->bits && (ch = getc(in)) == EOF) |
| 358 | return ferror(in) ? Z_ERRNO : Z_BUF_ERROR; |
| 359 | z_stream strm = {0}; |
| 360 | ret = inflateInit2(&strm, RAW); |
| 361 | if (ret != Z_OK) |
| 362 | return ret; |
| 363 | if (point->bits) |
| 364 | INFLATEPRIME(&strm, point->bits, ch >> (8 - point->bits)); |
| 365 | inflateSetDictionary(&strm, point->window, WINSIZE); |
| 366 | |
| 367 | // Skip uncompressed bytes until offset reached, then satisfy request. |
| 368 | unsigned char input[CHUNK]; |
| 369 | unsigned char discard[WINSIZE]; |
| 370 | offset -= point->out; // number of bytes to skip to get to offset |
| 371 | size_t left = len; // number of bytes left to read after offset |
| 372 | do { |
| 373 | if (offset) { |
| 374 | // Discard up to offset uncompressed bytes. |
| 375 | strm.avail_out = offset < WINSIZE ? (unsigned)offset : WINSIZE; |
| 376 | strm.next_out = discard; |
| 377 | } |
| 378 | else { |
| 379 | // Uncompress up to left bytes into buf. |
| 380 | strm.avail_out = left < UINT_MAX ? (unsigned)left : UINT_MAX; |
| 381 | strm.next_out = buf + len - left; |
| 382 | } |
| 383 | |
| 384 | // Uncompress, setting got to the number of bytes uncompressed. |
| 385 | if (strm.avail_in == 0) { |
| 386 | // Assure available input. |
| 387 | strm.avail_in = fread(input, 1, CHUNK, in); |
| 388 | if (strm.avail_in < CHUNK && ferror(in)) { |
| 389 | ret = Z_ERRNO; |
| 390 | break; |
| 391 | } |
| 392 | strm.next_in = input; |
| 393 | } |
| 394 | unsigned got = strm.avail_out; |
| 395 | ret = inflate(&strm, Z_NO_FLUSH); |
| 396 | got -= strm.avail_out; |
| 397 | |
| 398 | // Update the appropriate count. |
| 399 | if (offset) |
| 400 | offset -= got; |
| 401 | else |
| 402 | left -= got; |
| 403 | |
| 404 | // If we're at the end of a gzip member and there's more to read, |
| 405 | // continue to the next gzip member. |
| 406 | if (ret == Z_STREAM_END && index->mode == GZIP) { |
| 407 | // Discard the gzip trailer. |
| 408 | unsigned drop = 8; // length of gzip trailer |
| 409 | if (strm.avail_in >= drop) { |
| 410 | strm.avail_in -= drop; |
| 411 | strm.next_in += drop; |
| 412 | } |
| 413 | else { |
| 414 | // Read and discard the remainder of the gzip trailer. |
| 415 | drop -= strm.avail_in; |
| 416 | strm.avail_in = 0; |
| 417 | do { |
| 418 | if (getc(in) == EOF) |
| 419 | // The input does not have a complete trailer. |
| 420 | return ferror(in) ? Z_ERRNO : Z_BUF_ERROR; |
| 421 | } while (--drop); |
| 422 | } |
| 423 | |
| 424 | if (strm.avail_in || ungetc(getc(in), in) != EOF) { |
| 425 | // There's more after the gzip trailer. Use inflate to skip the |
| 426 | // gzip header and resume the raw inflate there. |
| 427 | inflateReset2(&strm, GZIP); |
| 428 | do { |
| 429 | if (strm.avail_in == 0) { |
| 430 | strm.avail_in = fread(input, 1, CHUNK, in); |
| 431 | if (strm.avail_in < CHUNK && ferror(in)) { |
| 432 | ret = Z_ERRNO; |
| 433 | break; |
| 434 | } |
| 435 | strm.next_in = input; |
| 436 | } |
| 437 | strm.avail_out = WINSIZE; |
| 438 | strm.next_out = discard; |
| 439 | ret = inflate(&strm, Z_BLOCK); // stop at end of header |
| 440 | } while (ret == Z_OK && (strm.data_type & 0x80) == 0); |
| 441 | if (ret != Z_OK) |
| 442 | break; |
| 443 | inflateReset2(&strm, RAW); |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | // Continue until we have the requested data, the deflate data has |
| 448 | // ended, or an error is encountered. |
| 449 | } while (ret == Z_OK && left); |
| 450 | inflateEnd(&strm); |
| 451 | |
| 452 | // Return the number of uncompressed bytes read into buf, or the error. |
| 453 | return ret == Z_OK || ret == Z_STREAM_END ? len - left : ret; |
| 454 | } |
| 455 | |
| 456 | #ifdef TEST |
| 457 | |
| 458 | #define SPAN 1048576L // desired distance between access points |
| 459 | #define LEN 16384 // number of bytes to extract |
| 460 | |
| 461 | // Demonstrate the use of deflate_index_build() and deflate_index_extract() by |
| 462 | // processing the file provided on the command line, and extracting LEN bytes |
| 463 | // from 2/3rds of the way through the uncompressed output, writing that to |
| 464 | // stdout. An offset can be provided as the second argument, in which case the |
| 465 | // data is extracted from there instead. |
| 466 | int main(int argc, char **argv) { |
| 467 | // Open the input file. |
| 468 | if (argc < 2 || argc > 3) { |
| 469 | fprintf(stderr, "usage: zran file.raw [offset]\n"); |
| 470 | return 1; |
| 471 | } |
| 472 | FILE *in = fopen(argv[1], "rb"); |
| 473 | if (in == NULL) { |
| 474 | fprintf(stderr, "zran: could not open %s for reading\n", argv[1]); |
| 475 | return 1; |
| 476 | } |
| 477 | |
| 478 | // Get optional offset. |
| 479 | off_t offset = -1; |
| 480 | if (argc == 3) { |
| 481 | char *end; |
| 482 | offset = strtoll(argv[2], &end, 10); |
| 483 | if (*end || offset < 0) { |
| 484 | fprintf(stderr, "zran: %s is not a valid offset\n", argv[2]); |
| 485 | return 1; |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | // Build index. |
| 490 | struct deflate_index *index = NULL; |
| 491 | int len = deflate_index_build(in, SPAN, &index); |
| 492 | if (len < 0) { |
| 493 | fclose(in); |
| 494 | switch (len) { |
| 495 | case Z_MEM_ERROR: |
| 496 | fprintf(stderr, "zran: out of memory\n"); |
| 497 | break; |
| 498 | case Z_BUF_ERROR: |
| 499 | fprintf(stderr, "zran: %s ended prematurely\n", argv[1]); |
| 500 | break; |
| 501 | case Z_DATA_ERROR: |
| 502 | fprintf(stderr, "zran: compressed data error in %s\n", argv[1]); |
| 503 | break; |
| 504 | case Z_ERRNO: |
| 505 | fprintf(stderr, "zran: read error on %s\n", argv[1]); |
| @@ -456,24 +509,25 @@ | |
| 509 | } |
| 510 | return 1; |
| 511 | } |
| 512 | fprintf(stderr, "zran: built index with %d access points\n", len); |
| 513 | |
| 514 | // Use index by reading some bytes from an arbitrary offset. |
| 515 | unsigned char buf[LEN]; |
| 516 | if (offset == -1) |
| 517 | offset = ((index->length + 1) << 1) / 3; |
| 518 | ptrdiff_t got = deflate_index_extract(in, index, offset, buf, LEN); |
| 519 | if (got < 0) |
| 520 | fprintf(stderr, "zran: extraction failed: %s error\n", |
| 521 | got == Z_MEM_ERROR ? "out of memory" : "input corrupted"); |
| 522 | else { |
| 523 | fwrite(buf, 1, got, stdout); |
| 524 | fprintf(stderr, "zran: extracted %ld bytes at %lld\n", got, offset); |
| 525 | } |
| 526 | |
| 527 | // Clean up and exit. |
| 528 | deflate_index_free(index); |
| 529 | fclose(in); |
| 530 | return 0; |
| 531 | } |
| 532 | |
| 533 | #endif |
| 534 |
+41
-30
| --- compat/zlib/examples/zran.h | ||
| +++ compat/zlib/examples/zran.h | ||
| @@ -1,40 +1,51 @@ | ||
| 1 | -/* zran.h -- example of zlib/gzip stream indexing and random access | |
| 2 | - * Copyright (C) 2005, 2012, 2018 Mark Adler | |
| 1 | +/* zran.h -- example of deflated stream indexing and random access | |
| 2 | + * Copyright (C) 2005, 2012, 2018, 2023 Mark Adler | |
| 3 | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | - * Version 1.2 14 Oct 2018 Mark Adler */ | |
| 4 | + * Version 1.3 18 Feb 2023 Mark Adler */ | |
| 5 | 5 | |
| 6 | 6 | #include <stdio.h> |
| 7 | 7 | #include "zlib.h" |
| 8 | 8 | |
| 9 | -/* Access point list. */ | |
| 9 | +// Access point. | |
| 10 | +typedef struct point { | |
| 11 | + off_t out; // offset in uncompressed data | |
| 12 | + off_t in; // offset in compressed file of first full byte | |
| 13 | + int bits; // 0, or number of bits (1-7) from byte at in-1 | |
| 14 | + unsigned char window[32768]; // preceding 32K of uncompressed data | |
| 15 | +} point_t; | |
| 16 | + | |
| 17 | +// Access point list. | |
| 10 | 18 | struct deflate_index { |
| 11 | - int have; /* number of list entries */ | |
| 12 | - int gzip; /* 1 if the index is of a gzip file, 0 if it is of a | |
| 13 | - zlib stream */ | |
| 14 | - off_t length; /* total length of uncompressed data */ | |
| 15 | - void *list; /* allocated list of entries */ | |
| 19 | + int have; // number of access points in list | |
| 20 | + int mode; // -15 for raw, 15 for zlib, or 31 for gzip | |
| 21 | + off_t length; // total length of uncompressed data | |
| 22 | + point_t *list; // allocated list of access points | |
| 16 | 23 | }; |
| 17 | 24 | |
| 18 | -/* Make one entire pass through a zlib or gzip compressed stream and build an | |
| 19 | - index, with access points about every span bytes of uncompressed output. | |
| 20 | - gzip files with multiple members are indexed in their entirety. span should | |
| 21 | - be chosen to balance the speed of random access against the memory | |
| 22 | - requirements of the list, about 32K bytes per access point. The return value | |
| 23 | - is the number of access points on success (>= 1), Z_MEM_ERROR for out of | |
| 24 | - memory, Z_DATA_ERROR for an error in the input file, or Z_ERRNO for a file | |
| 25 | - read error. On success, *built points to the resulting index. */ | |
| 25 | +// Make one pass through a zlib, gzip, or raw deflate compressed stream and | |
| 26 | +// build an index, with access points about every span bytes of uncompressed | |
| 27 | +// output. gzip files with multiple members are fully indexed. span should be | |
| 28 | +// chosen to balance the speed of random access against the memory requirements | |
| 29 | +// of the list, which is about 32K bytes per access point. The return value is | |
| 30 | +// the number of access points on success (>= 1), Z_MEM_ERROR for out of | |
| 31 | +// memory, Z_BUF_ERROR for a premature end of input, Z_DATA_ERROR for a format | |
| 32 | +// or verification error in the input file, or Z_ERRNO for a file read error. | |
| 33 | +// On success, *built points to the resulting index. | |
| 26 | 34 | int deflate_index_build(FILE *in, off_t span, struct deflate_index **built); |
| 27 | 35 | |
| 28 | -/* Deallocate an index built by deflate_index_build() */ | |
| 29 | -void deflate_index_free(struct deflate_index *index); | |
| 30 | - | |
| 31 | -/* Use the index to read len bytes from offset into buf. Return bytes read or | |
| 32 | - negative for error (Z_DATA_ERROR or Z_MEM_ERROR). If data is requested past | |
| 33 | - the end of the uncompressed data, then deflate_index_extract() will return a | |
| 34 | - value less than len, indicating how much was actually read into buf. This | |
| 35 | - function should not return a data error unless the file was modified since | |
| 36 | - the index was generated, since deflate_index_build() validated all of the | |
| 37 | - input. deflate_index_extract() will return Z_ERRNO if there is an error on | |
| 38 | - reading or seeking the input file. */ | |
| 39 | -int deflate_index_extract(FILE *in, struct deflate_index *index, off_t offset, | |
| 40 | - unsigned char *buf, int len); | |
| 36 | +// Use the index to read len bytes from offset into buf. Return the number of | |
| 37 | +// bytes read or a negative error code. If data is requested past the end of | |
| 38 | +// the uncompressed data, then deflate_index_extract() will return a value less | |
| 39 | +// than len, indicating how much was actually read into buf. If given a valid | |
| 40 | +// index, this function should not return an error unless the file was modified | |
| 41 | +// somehow since the index was generated, given that deflate_index_build() had | |
| 42 | +// validated all of the input. If nevertheless there is a failure, Z_BUF_ERROR | |
| 43 | +// is returned if the compressed data ends prematurely, Z_DATA_ERROR if the | |
| 44 | +// deflate compressed data is not valid, Z_MEM_ERROR if out of memory, | |
| 45 | +// Z_STREAM_ERROR if the index is not valid, or Z_ERRNO if there is an error | |
| 46 | +// reading or seeking on the input file. | |
| 47 | +ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index, | |
| 48 | + off_t offset, unsigned char *buf, size_t len); | |
| 49 | + | |
| 50 | +// Deallocate an index built by deflate_index_build(). | |
| 51 | +void deflate_index_free(struct deflate_index *index); | |
| 41 | 52 |
| --- compat/zlib/examples/zran.h | |
| +++ compat/zlib/examples/zran.h | |
| @@ -1,40 +1,51 @@ | |
| 1 | /* zran.h -- example of zlib/gzip stream indexing and random access |
| 2 | * Copyright (C) 2005, 2012, 2018 Mark Adler |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | * Version 1.2 14 Oct 2018 Mark Adler */ |
| 5 | |
| 6 | #include <stdio.h> |
| 7 | #include "zlib.h" |
| 8 | |
| 9 | /* Access point list. */ |
| 10 | struct deflate_index { |
| 11 | int have; /* number of list entries */ |
| 12 | int gzip; /* 1 if the index is of a gzip file, 0 if it is of a |
| 13 | zlib stream */ |
| 14 | off_t length; /* total length of uncompressed data */ |
| 15 | void *list; /* allocated list of entries */ |
| 16 | }; |
| 17 | |
| 18 | /* Make one entire pass through a zlib or gzip compressed stream and build an |
| 19 | index, with access points about every span bytes of uncompressed output. |
| 20 | gzip files with multiple members are indexed in their entirety. span should |
| 21 | be chosen to balance the speed of random access against the memory |
| 22 | requirements of the list, about 32K bytes per access point. The return value |
| 23 | is the number of access points on success (>= 1), Z_MEM_ERROR for out of |
| 24 | memory, Z_DATA_ERROR for an error in the input file, or Z_ERRNO for a file |
| 25 | read error. On success, *built points to the resulting index. */ |
| 26 | int deflate_index_build(FILE *in, off_t span, struct deflate_index **built); |
| 27 | |
| 28 | /* Deallocate an index built by deflate_index_build() */ |
| 29 | void deflate_index_free(struct deflate_index *index); |
| 30 | |
| 31 | /* Use the index to read len bytes from offset into buf. Return bytes read or |
| 32 | negative for error (Z_DATA_ERROR or Z_MEM_ERROR). If data is requested past |
| 33 | the end of the uncompressed data, then deflate_index_extract() will return a |
| 34 | value less than len, indicating how much was actually read into buf. This |
| 35 | function should not return a data error unless the file was modified since |
| 36 | the index was generated, since deflate_index_build() validated all of the |
| 37 | input. deflate_index_extract() will return Z_ERRNO if there is an error on |
| 38 | reading or seeking the input file. */ |
| 39 | int deflate_index_extract(FILE *in, struct deflate_index *index, off_t offset, |
| 40 | unsigned char *buf, int len); |
| 41 |
| --- compat/zlib/examples/zran.h | |
| +++ compat/zlib/examples/zran.h | |
| @@ -1,40 +1,51 @@ | |
| 1 | /* zran.h -- example of deflated stream indexing and random access |
| 2 | * Copyright (C) 2005, 2012, 2018, 2023 Mark Adler |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | * Version 1.3 18 Feb 2023 Mark Adler */ |
| 5 | |
| 6 | #include <stdio.h> |
| 7 | #include "zlib.h" |
| 8 | |
| 9 | // Access point. |
| 10 | typedef struct point { |
| 11 | off_t out; // offset in uncompressed data |
| 12 | off_t in; // offset in compressed file of first full byte |
| 13 | int bits; // 0, or number of bits (1-7) from byte at in-1 |
| 14 | unsigned char window[32768]; // preceding 32K of uncompressed data |
| 15 | } point_t; |
| 16 | |
| 17 | // Access point list. |
| 18 | struct deflate_index { |
| 19 | int have; // number of access points in list |
| 20 | int mode; // -15 for raw, 15 for zlib, or 31 for gzip |
| 21 | off_t length; // total length of uncompressed data |
| 22 | point_t *list; // allocated list of access points |
| 23 | }; |
| 24 | |
| 25 | // Make one pass through a zlib, gzip, or raw deflate compressed stream and |
| 26 | // build an index, with access points about every span bytes of uncompressed |
| 27 | // output. gzip files with multiple members are fully indexed. span should be |
| 28 | // chosen to balance the speed of random access against the memory requirements |
| 29 | // of the list, which is about 32K bytes per access point. The return value is |
| 30 | // the number of access points on success (>= 1), Z_MEM_ERROR for out of |
| 31 | // memory, Z_BUF_ERROR for a premature end of input, Z_DATA_ERROR for a format |
| 32 | // or verification error in the input file, or Z_ERRNO for a file read error. |
| 33 | // On success, *built points to the resulting index. |
| 34 | int deflate_index_build(FILE *in, off_t span, struct deflate_index **built); |
| 35 | |
| 36 | // Use the index to read len bytes from offset into buf. Return the number of |
| 37 | // bytes read or a negative error code. If data is requested past the end of |
| 38 | // the uncompressed data, then deflate_index_extract() will return a value less |
| 39 | // than len, indicating how much was actually read into buf. If given a valid |
| 40 | // index, this function should not return an error unless the file was modified |
| 41 | // somehow since the index was generated, given that deflate_index_build() had |
| 42 | // validated all of the input. If nevertheless there is a failure, Z_BUF_ERROR |
| 43 | // is returned if the compressed data ends prematurely, Z_DATA_ERROR if the |
| 44 | // deflate compressed data is not valid, Z_MEM_ERROR if out of memory, |
| 45 | // Z_STREAM_ERROR if the index is not valid, or Z_ERRNO if there is an error |
| 46 | // reading or seeking on the input file. |
| 47 | ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index, |
| 48 | off_t offset, unsigned char *buf, size_t len); |
| 49 | |
| 50 | // Deallocate an index built by deflate_index_build(). |
| 51 | void deflate_index_free(struct deflate_index *index); |
| 52 |
+1
-3
| --- compat/zlib/gzclose.c | ||
| +++ compat/zlib/gzclose.c | ||
| @@ -6,13 +6,11 @@ | ||
| 6 | 6 | #include "gzguts.h" |
| 7 | 7 | |
| 8 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. |
| 9 | 9 | That way the other gzclose functions can be used instead to avoid linking in |
| 10 | 10 | unneeded compression or decompression routines. */ |
| 11 | -int ZEXPORT gzclose(file) | |
| 12 | - gzFile file; | |
| 13 | -{ | |
| 11 | +int ZEXPORT gzclose(gzFile file) { | |
| 14 | 12 | #ifndef NO_GZCOMPRESS |
| 15 | 13 | gz_statep state; |
| 16 | 14 | |
| 17 | 15 | if (file == NULL) |
| 18 | 16 | return Z_STREAM_ERROR; |
| 19 | 17 |
| --- compat/zlib/gzclose.c | |
| +++ compat/zlib/gzclose.c | |
| @@ -6,13 +6,11 @@ | |
| 6 | #include "gzguts.h" |
| 7 | |
| 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. |
| 9 | That way the other gzclose functions can be used instead to avoid linking in |
| 10 | unneeded compression or decompression routines. */ |
| 11 | int ZEXPORT gzclose(file) |
| 12 | gzFile file; |
| 13 | { |
| 14 | #ifndef NO_GZCOMPRESS |
| 15 | gz_statep state; |
| 16 | |
| 17 | if (file == NULL) |
| 18 | return Z_STREAM_ERROR; |
| 19 |
| --- compat/zlib/gzclose.c | |
| +++ compat/zlib/gzclose.c | |
| @@ -6,13 +6,11 @@ | |
| 6 | #include "gzguts.h" |
| 7 | |
| 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. |
| 9 | That way the other gzclose functions can be used instead to avoid linking in |
| 10 | unneeded compression or decompression routines. */ |
| 11 | int ZEXPORT gzclose(gzFile file) { |
| 12 | #ifndef NO_GZCOMPRESS |
| 13 | gz_statep state; |
| 14 | |
| 15 | if (file == NULL) |
| 16 | return Z_STREAM_ERROR; |
| 17 |
+11
-12
| --- compat/zlib/gzguts.h | ||
| +++ compat/zlib/gzguts.h | ||
| @@ -5,13 +5,12 @@ | ||
| 5 | 5 | |
| 6 | 6 | #ifdef _LARGEFILE64_SOURCE |
| 7 | 7 | # ifndef _LARGEFILE_SOURCE |
| 8 | 8 | # define _LARGEFILE_SOURCE 1 |
| 9 | 9 | # endif |
| 10 | -# ifdef _FILE_OFFSET_BITS | |
| 11 | -# undef _FILE_OFFSET_BITS | |
| 12 | -# endif | |
| 10 | +# undef _FILE_OFFSET_BITS | |
| 11 | +# undef _TIME_BITS | |
| 13 | 12 | #endif |
| 14 | 13 | |
| 15 | 14 | #ifdef HAVE_HIDDEN |
| 16 | 15 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) |
| 17 | 16 | #else |
| @@ -117,12 +116,12 @@ | ||
| 117 | 116 | define "local" for the non-static meaning of "static", for readability |
| 118 | 117 | (compile with -Dlocal if your debugger can't find static symbols) */ |
| 119 | 118 | |
| 120 | 119 | /* gz* functions always use library allocation functions */ |
| 121 | 120 | #ifndef STDC |
| 122 | - extern voidp malloc OF((uInt size)); | |
| 123 | - extern void free OF((voidpf ptr)); | |
| 121 | + extern voidp malloc(uInt size); | |
| 122 | + extern void free(voidpf ptr); | |
| 124 | 123 | #endif |
| 125 | 124 | |
| 126 | 125 | /* get errno and strerror definition */ |
| 127 | 126 | #if defined UNDER_CE |
| 128 | 127 | # include <windows.h> |
| @@ -136,14 +135,14 @@ | ||
| 136 | 135 | # endif |
| 137 | 136 | #endif |
| 138 | 137 | |
| 139 | 138 | /* provide prototypes for these when building zlib without LFS */ |
| 140 | 139 | #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 |
| 141 | - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); | |
| 142 | - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); | |
| 143 | - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); | |
| 144 | - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); | |
| 140 | + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); | |
| 141 | + ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); | |
| 142 | + ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); | |
| 143 | + ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); | |
| 145 | 144 | #endif |
| 146 | 145 | |
| 147 | 146 | /* default memLevel */ |
| 148 | 147 | #if MAX_MEM_LEVEL >= 8 |
| 149 | 148 | # define DEF_MEM_LEVEL 8 |
| @@ -201,19 +200,19 @@ | ||
| 201 | 200 | z_stream strm; /* stream structure in-place (not a pointer) */ |
| 202 | 201 | } gz_state; |
| 203 | 202 | typedef gz_state FAR *gz_statep; |
| 204 | 203 | |
| 205 | 204 | /* shared functions */ |
| 206 | -void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); | |
| 205 | +void ZLIB_INTERNAL gz_error(gz_statep, int, const char *); | |
| 207 | 206 | #if defined UNDER_CE |
| 208 | -char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); | |
| 207 | +char ZLIB_INTERNAL *gz_strwinerror(DWORD error); | |
| 209 | 208 | #endif |
| 210 | 209 | |
| 211 | 210 | /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t |
| 212 | 211 | value -- needed when comparing unsigned to z_off64_t, which is signed |
| 213 | 212 | (possible z_off64_t types off_t, off64_t, and long are all signed) */ |
| 214 | 213 | #ifdef INT_MAX |
| 215 | 214 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) |
| 216 | 215 | #else |
| 217 | -unsigned ZLIB_INTERNAL gz_intmax OF((void)); | |
| 216 | +unsigned ZLIB_INTERNAL gz_intmax(void); | |
| 218 | 217 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) |
| 219 | 218 | #endif |
| 220 | 219 |
| --- compat/zlib/gzguts.h | |
| +++ compat/zlib/gzguts.h | |
| @@ -5,13 +5,12 @@ | |
| 5 | |
| 6 | #ifdef _LARGEFILE64_SOURCE |
| 7 | # ifndef _LARGEFILE_SOURCE |
| 8 | # define _LARGEFILE_SOURCE 1 |
| 9 | # endif |
| 10 | # ifdef _FILE_OFFSET_BITS |
| 11 | # undef _FILE_OFFSET_BITS |
| 12 | # endif |
| 13 | #endif |
| 14 | |
| 15 | #ifdef HAVE_HIDDEN |
| 16 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) |
| 17 | #else |
| @@ -117,12 +116,12 @@ | |
| 117 | define "local" for the non-static meaning of "static", for readability |
| 118 | (compile with -Dlocal if your debugger can't find static symbols) */ |
| 119 | |
| 120 | /* gz* functions always use library allocation functions */ |
| 121 | #ifndef STDC |
| 122 | extern voidp malloc OF((uInt size)); |
| 123 | extern void free OF((voidpf ptr)); |
| 124 | #endif |
| 125 | |
| 126 | /* get errno and strerror definition */ |
| 127 | #if defined UNDER_CE |
| 128 | # include <windows.h> |
| @@ -136,14 +135,14 @@ | |
| 136 | # endif |
| 137 | #endif |
| 138 | |
| 139 | /* provide prototypes for these when building zlib without LFS */ |
| 140 | #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 |
| 141 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); |
| 142 | ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); |
| 143 | ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); |
| 144 | ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); |
| 145 | #endif |
| 146 | |
| 147 | /* default memLevel */ |
| 148 | #if MAX_MEM_LEVEL >= 8 |
| 149 | # define DEF_MEM_LEVEL 8 |
| @@ -201,19 +200,19 @@ | |
| 201 | z_stream strm; /* stream structure in-place (not a pointer) */ |
| 202 | } gz_state; |
| 203 | typedef gz_state FAR *gz_statep; |
| 204 | |
| 205 | /* shared functions */ |
| 206 | void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); |
| 207 | #if defined UNDER_CE |
| 208 | char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); |
| 209 | #endif |
| 210 | |
| 211 | /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t |
| 212 | value -- needed when comparing unsigned to z_off64_t, which is signed |
| 213 | (possible z_off64_t types off_t, off64_t, and long are all signed) */ |
| 214 | #ifdef INT_MAX |
| 215 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) |
| 216 | #else |
| 217 | unsigned ZLIB_INTERNAL gz_intmax OF((void)); |
| 218 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) |
| 219 | #endif |
| 220 |
| --- compat/zlib/gzguts.h | |
| +++ compat/zlib/gzguts.h | |
| @@ -5,13 +5,12 @@ | |
| 5 | |
| 6 | #ifdef _LARGEFILE64_SOURCE |
| 7 | # ifndef _LARGEFILE_SOURCE |
| 8 | # define _LARGEFILE_SOURCE 1 |
| 9 | # endif |
| 10 | # undef _FILE_OFFSET_BITS |
| 11 | # undef _TIME_BITS |
| 12 | #endif |
| 13 | |
| 14 | #ifdef HAVE_HIDDEN |
| 15 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) |
| 16 | #else |
| @@ -117,12 +116,12 @@ | |
| 116 | define "local" for the non-static meaning of "static", for readability |
| 117 | (compile with -Dlocal if your debugger can't find static symbols) */ |
| 118 | |
| 119 | /* gz* functions always use library allocation functions */ |
| 120 | #ifndef STDC |
| 121 | extern voidp malloc(uInt size); |
| 122 | extern void free(voidpf ptr); |
| 123 | #endif |
| 124 | |
| 125 | /* get errno and strerror definition */ |
| 126 | #if defined UNDER_CE |
| 127 | # include <windows.h> |
| @@ -136,14 +135,14 @@ | |
| 135 | # endif |
| 136 | #endif |
| 137 | |
| 138 | /* provide prototypes for these when building zlib without LFS */ |
| 139 | #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 |
| 140 | ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); |
| 141 | ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); |
| 142 | ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); |
| 143 | ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); |
| 144 | #endif |
| 145 | |
| 146 | /* default memLevel */ |
| 147 | #if MAX_MEM_LEVEL >= 8 |
| 148 | # define DEF_MEM_LEVEL 8 |
| @@ -201,19 +200,19 @@ | |
| 200 | z_stream strm; /* stream structure in-place (not a pointer) */ |
| 201 | } gz_state; |
| 202 | typedef gz_state FAR *gz_statep; |
| 203 | |
| 204 | /* shared functions */ |
| 205 | void ZLIB_INTERNAL gz_error(gz_statep, int, const char *); |
| 206 | #if defined UNDER_CE |
| 207 | char ZLIB_INTERNAL *gz_strwinerror(DWORD error); |
| 208 | #endif |
| 209 | |
| 210 | /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t |
| 211 | value -- needed when comparing unsigned to z_off64_t, which is signed |
| 212 | (possible z_off64_t types off_t, off64_t, and long are all signed) */ |
| 213 | #ifdef INT_MAX |
| 214 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) |
| 215 | #else |
| 216 | unsigned ZLIB_INTERNAL gz_intmax(void); |
| 217 | # define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) |
| 218 | #endif |
| 219 |
+26
-83
| --- compat/zlib/gzlib.c | ||
| +++ compat/zlib/gzlib.c | ||
| @@ -13,14 +13,10 @@ | ||
| 13 | 13 | #else |
| 14 | 14 | # define LSEEK lseek |
| 15 | 15 | #endif |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | -/* Local functions */ | |
| 19 | -local void gz_reset OF((gz_statep)); | |
| 20 | -local gzFile gz_open OF((const void *, int, const char *)); | |
| 21 | - | |
| 22 | 18 | #if defined UNDER_CE |
| 23 | 19 | |
| 24 | 20 | /* Map the Windows error number in ERROR to a locale-dependent error message |
| 25 | 21 | string and return a pointer to it. Typically, the values for ERROR come |
| 26 | 22 | from GetLastError. |
| @@ -28,13 +24,11 @@ | ||
| 28 | 24 | The string pointed to shall not be modified by the application, but may be |
| 29 | 25 | overwritten by a subsequent call to gz_strwinerror |
| 30 | 26 | |
| 31 | 27 | The gz_strwinerror function does not change the current setting of |
| 32 | 28 | GetLastError. */ |
| 33 | -char ZLIB_INTERNAL *gz_strwinerror(error) | |
| 34 | - DWORD error; | |
| 35 | -{ | |
| 29 | +char ZLIB_INTERNAL *gz_strwinerror(DWORD error) { | |
| 36 | 30 | static char buf[1024]; |
| 37 | 31 | |
| 38 | 32 | wchar_t *msgbuf; |
| 39 | 33 | DWORD lasterr = GetLastError(); |
| 40 | 34 | DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
| @@ -70,13 +64,11 @@ | ||
| 70 | 64 | } |
| 71 | 65 | |
| 72 | 66 | #endif /* UNDER_CE */ |
| 73 | 67 | |
| 74 | 68 | /* Reset gzip file state */ |
| 75 | -local void gz_reset(state) | |
| 76 | - gz_statep state; | |
| 77 | -{ | |
| 69 | +local void gz_reset(gz_statep state) { | |
| 78 | 70 | state->x.have = 0; /* no output data available */ |
| 79 | 71 | if (state->mode == GZ_READ) { /* for reading ... */ |
| 80 | 72 | state->eof = 0; /* not at end of file */ |
| 81 | 73 | state->past = 0; /* have not read past end yet */ |
| 82 | 74 | state->how = LOOK; /* look for gzip header */ |
| @@ -88,15 +80,11 @@ | ||
| 88 | 80 | state->x.pos = 0; /* no uncompressed data yet */ |
| 89 | 81 | state->strm.avail_in = 0; /* no input data yet */ |
| 90 | 82 | } |
| 91 | 83 | |
| 92 | 84 | /* Open a gzip file either by name or file descriptor. */ |
| 93 | -local gzFile gz_open(path, fd, mode) | |
| 94 | - const void *path; | |
| 95 | - int fd; | |
| 96 | - const char *mode; | |
| 97 | -{ | |
| 85 | +local gzFile gz_open(const void *path, int fd, const char *mode) { | |
| 98 | 86 | gz_statep state; |
| 99 | 87 | z_size_t len; |
| 100 | 88 | int oflag; |
| 101 | 89 | #ifdef O_CLOEXEC |
| 102 | 90 | int cloexec = 0; |
| @@ -267,30 +255,21 @@ | ||
| 267 | 255 | /* return stream */ |
| 268 | 256 | return (gzFile)state; |
| 269 | 257 | } |
| 270 | 258 | |
| 271 | 259 | /* -- see zlib.h -- */ |
| 272 | -gzFile ZEXPORT gzopen(path, mode) | |
| 273 | - const char *path; | |
| 274 | - const char *mode; | |
| 275 | -{ | |
| 260 | +gzFile ZEXPORT gzopen(const char *path, const char *mode) { | |
| 261 | + return gz_open(path, -1, mode); | |
| 262 | +} | |
| 263 | + | |
| 264 | +/* -- see zlib.h -- */ | |
| 265 | +gzFile ZEXPORT gzopen64(const char *path, const char *mode) { | |
| 276 | 266 | return gz_open(path, -1, mode); |
| 277 | 267 | } |
| 278 | 268 | |
| 279 | 269 | /* -- see zlib.h -- */ |
| 280 | -gzFile ZEXPORT gzopen64(path, mode) | |
| 281 | - const char *path; | |
| 282 | - const char *mode; | |
| 283 | -{ | |
| 284 | - return gz_open(path, -1, mode); | |
| 285 | -} | |
| 286 | - | |
| 287 | -/* -- see zlib.h -- */ | |
| 288 | -gzFile ZEXPORT gzdopen(fd, mode) | |
| 289 | - int fd; | |
| 290 | - const char *mode; | |
| 291 | -{ | |
| 270 | +gzFile ZEXPORT gzdopen(int fd, const char *mode) { | |
| 292 | 271 | char *path; /* identifier for error messages */ |
| 293 | 272 | gzFile gz; |
| 294 | 273 | |
| 295 | 274 | if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL) |
| 296 | 275 | return NULL; |
| @@ -304,23 +283,17 @@ | ||
| 304 | 283 | return gz; |
| 305 | 284 | } |
| 306 | 285 | |
| 307 | 286 | /* -- see zlib.h -- */ |
| 308 | 287 | #ifdef WIDECHAR |
| 309 | -gzFile ZEXPORT gzopen_w(path, mode) | |
| 310 | - const wchar_t *path; | |
| 311 | - const char *mode; | |
| 312 | -{ | |
| 288 | +gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) { | |
| 313 | 289 | return gz_open(path, -2, mode); |
| 314 | 290 | } |
| 315 | 291 | #endif |
| 316 | 292 | |
| 317 | 293 | /* -- see zlib.h -- */ |
| 318 | -int ZEXPORT gzbuffer(file, size) | |
| 319 | - gzFile file; | |
| 320 | - unsigned size; | |
| 321 | -{ | |
| 294 | +int ZEXPORT gzbuffer(gzFile file, unsigned size) { | |
| 322 | 295 | gz_statep state; |
| 323 | 296 | |
| 324 | 297 | /* get internal structure and check integrity */ |
| 325 | 298 | if (file == NULL) |
| 326 | 299 | return -1; |
| @@ -333,20 +306,18 @@ | ||
| 333 | 306 | return -1; |
| 334 | 307 | |
| 335 | 308 | /* check and set requested size */ |
| 336 | 309 | if ((size << 1) < size) |
| 337 | 310 | return -1; /* need to be able to double it */ |
| 338 | - if (size < 2) | |
| 339 | - size = 2; /* need two bytes to check magic header */ | |
| 311 | + if (size < 8) | |
| 312 | + size = 8; /* needed to behave well with flushing */ | |
| 340 | 313 | state->want = size; |
| 341 | 314 | return 0; |
| 342 | 315 | } |
| 343 | 316 | |
| 344 | 317 | /* -- see zlib.h -- */ |
| 345 | -int ZEXPORT gzrewind(file) | |
| 346 | - gzFile file; | |
| 347 | -{ | |
| 318 | +int ZEXPORT gzrewind(gzFile file) { | |
| 348 | 319 | gz_statep state; |
| 349 | 320 | |
| 350 | 321 | /* get internal structure */ |
| 351 | 322 | if (file == NULL) |
| 352 | 323 | return -1; |
| @@ -363,15 +334,11 @@ | ||
| 363 | 334 | gz_reset(state); |
| 364 | 335 | return 0; |
| 365 | 336 | } |
| 366 | 337 | |
| 367 | 338 | /* -- see zlib.h -- */ |
| 368 | -z_off64_t ZEXPORT gzseek64(file, offset, whence) | |
| 369 | - gzFile file; | |
| 370 | - z_off64_t offset; | |
| 371 | - int whence; | |
| 372 | -{ | |
| 339 | +z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) { | |
| 373 | 340 | unsigned n; |
| 374 | 341 | z_off64_t ret; |
| 375 | 342 | gz_statep state; |
| 376 | 343 | |
| 377 | 344 | /* get internal structure and check integrity */ |
| @@ -440,25 +407,19 @@ | ||
| 440 | 407 | } |
| 441 | 408 | return state->x.pos + offset; |
| 442 | 409 | } |
| 443 | 410 | |
| 444 | 411 | /* -- see zlib.h -- */ |
| 445 | -z_off_t ZEXPORT gzseek(file, offset, whence) | |
| 446 | - gzFile file; | |
| 447 | - z_off_t offset; | |
| 448 | - int whence; | |
| 449 | -{ | |
| 412 | +z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) { | |
| 450 | 413 | z_off64_t ret; |
| 451 | 414 | |
| 452 | 415 | ret = gzseek64(file, (z_off64_t)offset, whence); |
| 453 | 416 | return ret == (z_off_t)ret ? (z_off_t)ret : -1; |
| 454 | 417 | } |
| 455 | 418 | |
| 456 | 419 | /* -- see zlib.h -- */ |
| 457 | -z_off64_t ZEXPORT gztell64(file) | |
| 458 | - gzFile file; | |
| 459 | -{ | |
| 420 | +z_off64_t ZEXPORT gztell64(gzFile file) { | |
| 460 | 421 | gz_statep state; |
| 461 | 422 | |
| 462 | 423 | /* get internal structure and check integrity */ |
| 463 | 424 | if (file == NULL) |
| 464 | 425 | return -1; |
| @@ -469,23 +430,19 @@ | ||
| 469 | 430 | /* return position */ |
| 470 | 431 | return state->x.pos + (state->seek ? state->skip : 0); |
| 471 | 432 | } |
| 472 | 433 | |
| 473 | 434 | /* -- see zlib.h -- */ |
| 474 | -z_off_t ZEXPORT gztell(file) | |
| 475 | - gzFile file; | |
| 476 | -{ | |
| 435 | +z_off_t ZEXPORT gztell(gzFile file) { | |
| 477 | 436 | z_off64_t ret; |
| 478 | 437 | |
| 479 | 438 | ret = gztell64(file); |
| 480 | 439 | return ret == (z_off_t)ret ? (z_off_t)ret : -1; |
| 481 | 440 | } |
| 482 | 441 | |
| 483 | 442 | /* -- see zlib.h -- */ |
| 484 | -z_off64_t ZEXPORT gzoffset64(file) | |
| 485 | - gzFile file; | |
| 486 | -{ | |
| 443 | +z_off64_t ZEXPORT gzoffset64(gzFile file) { | |
| 487 | 444 | z_off64_t offset; |
| 488 | 445 | gz_statep state; |
| 489 | 446 | |
| 490 | 447 | /* get internal structure and check integrity */ |
| 491 | 448 | if (file == NULL) |
| @@ -502,23 +459,19 @@ | ||
| 502 | 459 | offset -= state->strm.avail_in; /* don't count buffered input */ |
| 503 | 460 | return offset; |
| 504 | 461 | } |
| 505 | 462 | |
| 506 | 463 | /* -- see zlib.h -- */ |
| 507 | -z_off_t ZEXPORT gzoffset(file) | |
| 508 | - gzFile file; | |
| 509 | -{ | |
| 464 | +z_off_t ZEXPORT gzoffset(gzFile file) { | |
| 510 | 465 | z_off64_t ret; |
| 511 | 466 | |
| 512 | 467 | ret = gzoffset64(file); |
| 513 | 468 | return ret == (z_off_t)ret ? (z_off_t)ret : -1; |
| 514 | 469 | } |
| 515 | 470 | |
| 516 | 471 | /* -- see zlib.h -- */ |
| 517 | -int ZEXPORT gzeof(file) | |
| 518 | - gzFile file; | |
| 519 | -{ | |
| 472 | +int ZEXPORT gzeof(gzFile file) { | |
| 520 | 473 | gz_statep state; |
| 521 | 474 | |
| 522 | 475 | /* get internal structure and check integrity */ |
| 523 | 476 | if (file == NULL) |
| 524 | 477 | return 0; |
| @@ -529,14 +482,11 @@ | ||
| 529 | 482 | /* return end-of-file state */ |
| 530 | 483 | return state->mode == GZ_READ ? state->past : 0; |
| 531 | 484 | } |
| 532 | 485 | |
| 533 | 486 | /* -- see zlib.h -- */ |
| 534 | -const char * ZEXPORT gzerror(file, errnum) | |
| 535 | - gzFile file; | |
| 536 | - int *errnum; | |
| 537 | -{ | |
| 487 | +const char * ZEXPORT gzerror(gzFile file, int *errnum) { | |
| 538 | 488 | gz_statep state; |
| 539 | 489 | |
| 540 | 490 | /* get internal structure and check integrity */ |
| 541 | 491 | if (file == NULL) |
| 542 | 492 | return NULL; |
| @@ -550,13 +500,11 @@ | ||
| 550 | 500 | return state->err == Z_MEM_ERROR ? "out of memory" : |
| 551 | 501 | (state->msg == NULL ? "" : state->msg); |
| 552 | 502 | } |
| 553 | 503 | |
| 554 | 504 | /* -- see zlib.h -- */ |
| 555 | -void ZEXPORT gzclearerr(file) | |
| 556 | - gzFile file; | |
| 557 | -{ | |
| 505 | +void ZEXPORT gzclearerr(gzFile file) { | |
| 558 | 506 | gz_statep state; |
| 559 | 507 | |
| 560 | 508 | /* get internal structure and check integrity */ |
| 561 | 509 | if (file == NULL) |
| 562 | 510 | return; |
| @@ -576,15 +524,11 @@ | ||
| 576 | 524 | state->msg accordingly. Free any previous error message already there. Do |
| 577 | 525 | not try to free or allocate space if the error is Z_MEM_ERROR (out of |
| 578 | 526 | memory). Simply save the error message as a static string. If there is an |
| 579 | 527 | allocation failure constructing the error message, then convert the error to |
| 580 | 528 | out of memory. */ |
| 581 | -void ZLIB_INTERNAL gz_error(state, err, msg) | |
| 582 | - gz_statep state; | |
| 583 | - int err; | |
| 584 | - const char *msg; | |
| 585 | -{ | |
| 529 | +void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) { | |
| 586 | 530 | /* free previously allocated message and clear */ |
| 587 | 531 | if (state->msg != NULL) { |
| 588 | 532 | if (state->err != Z_MEM_ERROR) |
| 589 | 533 | free(state->msg); |
| 590 | 534 | state->msg = NULL; |
| @@ -622,12 +566,11 @@ | ||
| 622 | 566 | #ifndef INT_MAX |
| 623 | 567 | /* portably return maximum value for an int (when limits.h presumed not |
| 624 | 568 | available) -- we need to do this to cover cases where 2's complement not |
| 625 | 569 | used, since C standard permits 1's complement and sign-bit representations, |
| 626 | 570 | otherwise we could just use ((unsigned)-1) >> 1 */ |
| 627 | -unsigned ZLIB_INTERNAL gz_intmax() | |
| 628 | -{ | |
| 571 | +unsigned ZLIB_INTERNAL gz_intmax(void) { | |
| 629 | 572 | unsigned p, q; |
| 630 | 573 | |
| 631 | 574 | p = 1; |
| 632 | 575 | do { |
| 633 | 576 | q = p; |
| 634 | 577 |
| --- compat/zlib/gzlib.c | |
| +++ compat/zlib/gzlib.c | |
| @@ -13,14 +13,10 @@ | |
| 13 | #else |
| 14 | # define LSEEK lseek |
| 15 | #endif |
| 16 | #endif |
| 17 | |
| 18 | /* Local functions */ |
| 19 | local void gz_reset OF((gz_statep)); |
| 20 | local gzFile gz_open OF((const void *, int, const char *)); |
| 21 | |
| 22 | #if defined UNDER_CE |
| 23 | |
| 24 | /* Map the Windows error number in ERROR to a locale-dependent error message |
| 25 | string and return a pointer to it. Typically, the values for ERROR come |
| 26 | from GetLastError. |
| @@ -28,13 +24,11 @@ | |
| 28 | The string pointed to shall not be modified by the application, but may be |
| 29 | overwritten by a subsequent call to gz_strwinerror |
| 30 | |
| 31 | The gz_strwinerror function does not change the current setting of |
| 32 | GetLastError. */ |
| 33 | char ZLIB_INTERNAL *gz_strwinerror(error) |
| 34 | DWORD error; |
| 35 | { |
| 36 | static char buf[1024]; |
| 37 | |
| 38 | wchar_t *msgbuf; |
| 39 | DWORD lasterr = GetLastError(); |
| 40 | DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
| @@ -70,13 +64,11 @@ | |
| 70 | } |
| 71 | |
| 72 | #endif /* UNDER_CE */ |
| 73 | |
| 74 | /* Reset gzip file state */ |
| 75 | local void gz_reset(state) |
| 76 | gz_statep state; |
| 77 | { |
| 78 | state->x.have = 0; /* no output data available */ |
| 79 | if (state->mode == GZ_READ) { /* for reading ... */ |
| 80 | state->eof = 0; /* not at end of file */ |
| 81 | state->past = 0; /* have not read past end yet */ |
| 82 | state->how = LOOK; /* look for gzip header */ |
| @@ -88,15 +80,11 @@ | |
| 88 | state->x.pos = 0; /* no uncompressed data yet */ |
| 89 | state->strm.avail_in = 0; /* no input data yet */ |
| 90 | } |
| 91 | |
| 92 | /* Open a gzip file either by name or file descriptor. */ |
| 93 | local gzFile gz_open(path, fd, mode) |
| 94 | const void *path; |
| 95 | int fd; |
| 96 | const char *mode; |
| 97 | { |
| 98 | gz_statep state; |
| 99 | z_size_t len; |
| 100 | int oflag; |
| 101 | #ifdef O_CLOEXEC |
| 102 | int cloexec = 0; |
| @@ -267,30 +255,21 @@ | |
| 267 | /* return stream */ |
| 268 | return (gzFile)state; |
| 269 | } |
| 270 | |
| 271 | /* -- see zlib.h -- */ |
| 272 | gzFile ZEXPORT gzopen(path, mode) |
| 273 | const char *path; |
| 274 | const char *mode; |
| 275 | { |
| 276 | return gz_open(path, -1, mode); |
| 277 | } |
| 278 | |
| 279 | /* -- see zlib.h -- */ |
| 280 | gzFile ZEXPORT gzopen64(path, mode) |
| 281 | const char *path; |
| 282 | const char *mode; |
| 283 | { |
| 284 | return gz_open(path, -1, mode); |
| 285 | } |
| 286 | |
| 287 | /* -- see zlib.h -- */ |
| 288 | gzFile ZEXPORT gzdopen(fd, mode) |
| 289 | int fd; |
| 290 | const char *mode; |
| 291 | { |
| 292 | char *path; /* identifier for error messages */ |
| 293 | gzFile gz; |
| 294 | |
| 295 | if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL) |
| 296 | return NULL; |
| @@ -304,23 +283,17 @@ | |
| 304 | return gz; |
| 305 | } |
| 306 | |
| 307 | /* -- see zlib.h -- */ |
| 308 | #ifdef WIDECHAR |
| 309 | gzFile ZEXPORT gzopen_w(path, mode) |
| 310 | const wchar_t *path; |
| 311 | const char *mode; |
| 312 | { |
| 313 | return gz_open(path, -2, mode); |
| 314 | } |
| 315 | #endif |
| 316 | |
| 317 | /* -- see zlib.h -- */ |
| 318 | int ZEXPORT gzbuffer(file, size) |
| 319 | gzFile file; |
| 320 | unsigned size; |
| 321 | { |
| 322 | gz_statep state; |
| 323 | |
| 324 | /* get internal structure and check integrity */ |
| 325 | if (file == NULL) |
| 326 | return -1; |
| @@ -333,20 +306,18 @@ | |
| 333 | return -1; |
| 334 | |
| 335 | /* check and set requested size */ |
| 336 | if ((size << 1) < size) |
| 337 | return -1; /* need to be able to double it */ |
| 338 | if (size < 2) |
| 339 | size = 2; /* need two bytes to check magic header */ |
| 340 | state->want = size; |
| 341 | return 0; |
| 342 | } |
| 343 | |
| 344 | /* -- see zlib.h -- */ |
| 345 | int ZEXPORT gzrewind(file) |
| 346 | gzFile file; |
| 347 | { |
| 348 | gz_statep state; |
| 349 | |
| 350 | /* get internal structure */ |
| 351 | if (file == NULL) |
| 352 | return -1; |
| @@ -363,15 +334,11 @@ | |
| 363 | gz_reset(state); |
| 364 | return 0; |
| 365 | } |
| 366 | |
| 367 | /* -- see zlib.h -- */ |
| 368 | z_off64_t ZEXPORT gzseek64(file, offset, whence) |
| 369 | gzFile file; |
| 370 | z_off64_t offset; |
| 371 | int whence; |
| 372 | { |
| 373 | unsigned n; |
| 374 | z_off64_t ret; |
| 375 | gz_statep state; |
| 376 | |
| 377 | /* get internal structure and check integrity */ |
| @@ -440,25 +407,19 @@ | |
| 440 | } |
| 441 | return state->x.pos + offset; |
| 442 | } |
| 443 | |
| 444 | /* -- see zlib.h -- */ |
| 445 | z_off_t ZEXPORT gzseek(file, offset, whence) |
| 446 | gzFile file; |
| 447 | z_off_t offset; |
| 448 | int whence; |
| 449 | { |
| 450 | z_off64_t ret; |
| 451 | |
| 452 | ret = gzseek64(file, (z_off64_t)offset, whence); |
| 453 | return ret == (z_off_t)ret ? (z_off_t)ret : -1; |
| 454 | } |
| 455 | |
| 456 | /* -- see zlib.h -- */ |
| 457 | z_off64_t ZEXPORT gztell64(file) |
| 458 | gzFile file; |
| 459 | { |
| 460 | gz_statep state; |
| 461 | |
| 462 | /* get internal structure and check integrity */ |
| 463 | if (file == NULL) |
| 464 | return -1; |
| @@ -469,23 +430,19 @@ | |
| 469 | /* return position */ |
| 470 | return state->x.pos + (state->seek ? state->skip : 0); |
| 471 | } |
| 472 | |
| 473 | /* -- see zlib.h -- */ |
| 474 | z_off_t ZEXPORT gztell(file) |
| 475 | gzFile file; |
| 476 | { |
| 477 | z_off64_t ret; |
| 478 | |
| 479 | ret = gztell64(file); |
| 480 | return ret == (z_off_t)ret ? (z_off_t)ret : -1; |
| 481 | } |
| 482 | |
| 483 | /* -- see zlib.h -- */ |
| 484 | z_off64_t ZEXPORT gzoffset64(file) |
| 485 | gzFile file; |
| 486 | { |
| 487 | z_off64_t offset; |
| 488 | gz_statep state; |
| 489 | |
| 490 | /* get internal structure and check integrity */ |
| 491 | if (file == NULL) |
| @@ -502,23 +459,19 @@ | |
| 502 | offset -= state->strm.avail_in; /* don't count buffered input */ |
| 503 | return offset; |
| 504 | } |
| 505 | |
| 506 | /* -- see zlib.h -- */ |
| 507 | z_off_t ZEXPORT gzoffset(file) |
| 508 | gzFile file; |
| 509 | { |
| 510 | z_off64_t ret; |
| 511 | |
| 512 | ret = gzoffset64(file); |
| 513 | return ret == (z_off_t)ret ? (z_off_t)ret : -1; |
| 514 | } |
| 515 | |
| 516 | /* -- see zlib.h -- */ |
| 517 | int ZEXPORT gzeof(file) |
| 518 | gzFile file; |
| 519 | { |
| 520 | gz_statep state; |
| 521 | |
| 522 | /* get internal structure and check integrity */ |
| 523 | if (file == NULL) |
| 524 | return 0; |
| @@ -529,14 +482,11 @@ | |
| 529 | /* return end-of-file state */ |
| 530 | return state->mode == GZ_READ ? state->past : 0; |
| 531 | } |
| 532 | |
| 533 | /* -- see zlib.h -- */ |
| 534 | const char * ZEXPORT gzerror(file, errnum) |
| 535 | gzFile file; |
| 536 | int *errnum; |
| 537 | { |
| 538 | gz_statep state; |
| 539 | |
| 540 | /* get internal structure and check integrity */ |
| 541 | if (file == NULL) |
| 542 | return NULL; |
| @@ -550,13 +500,11 @@ | |
| 550 | return state->err == Z_MEM_ERROR ? "out of memory" : |
| 551 | (state->msg == NULL ? "" : state->msg); |
| 552 | } |
| 553 | |
| 554 | /* -- see zlib.h -- */ |
| 555 | void ZEXPORT gzclearerr(file) |
| 556 | gzFile file; |
| 557 | { |
| 558 | gz_statep state; |
| 559 | |
| 560 | /* get internal structure and check integrity */ |
| 561 | if (file == NULL) |
| 562 | return; |
| @@ -576,15 +524,11 @@ | |
| 576 | state->msg accordingly. Free any previous error message already there. Do |
| 577 | not try to free or allocate space if the error is Z_MEM_ERROR (out of |
| 578 | memory). Simply save the error message as a static string. If there is an |
| 579 | allocation failure constructing the error message, then convert the error to |
| 580 | out of memory. */ |
| 581 | void ZLIB_INTERNAL gz_error(state, err, msg) |
| 582 | gz_statep state; |
| 583 | int err; |
| 584 | const char *msg; |
| 585 | { |
| 586 | /* free previously allocated message and clear */ |
| 587 | if (state->msg != NULL) { |
| 588 | if (state->err != Z_MEM_ERROR) |
| 589 | free(state->msg); |
| 590 | state->msg = NULL; |
| @@ -622,12 +566,11 @@ | |
| 622 | #ifndef INT_MAX |
| 623 | /* portably return maximum value for an int (when limits.h presumed not |
| 624 | available) -- we need to do this to cover cases where 2's complement not |
| 625 | used, since C standard permits 1's complement and sign-bit representations, |
| 626 | otherwise we could just use ((unsigned)-1) >> 1 */ |
| 627 | unsigned ZLIB_INTERNAL gz_intmax() |
| 628 | { |
| 629 | unsigned p, q; |
| 630 | |
| 631 | p = 1; |
| 632 | do { |
| 633 | q = p; |
| 634 |
| --- compat/zlib/gzlib.c | |
| +++ compat/zlib/gzlib.c | |
| @@ -13,14 +13,10 @@ | |
| 13 | #else |
| 14 | # define LSEEK lseek |
| 15 | #endif |
| 16 | #endif |
| 17 | |
| 18 | #if defined UNDER_CE |
| 19 | |
| 20 | /* Map the Windows error number in ERROR to a locale-dependent error message |
| 21 | string and return a pointer to it. Typically, the values for ERROR come |
| 22 | from GetLastError. |
| @@ -28,13 +24,11 @@ | |
| 24 | The string pointed to shall not be modified by the application, but may be |
| 25 | overwritten by a subsequent call to gz_strwinerror |
| 26 | |
| 27 | The gz_strwinerror function does not change the current setting of |
| 28 | GetLastError. */ |
| 29 | char ZLIB_INTERNAL *gz_strwinerror(DWORD error) { |
| 30 | static char buf[1024]; |
| 31 | |
| 32 | wchar_t *msgbuf; |
| 33 | DWORD lasterr = GetLastError(); |
| 34 | DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
| @@ -70,13 +64,11 @@ | |
| 64 | } |
| 65 | |
| 66 | #endif /* UNDER_CE */ |
| 67 | |
| 68 | /* Reset gzip file state */ |
| 69 | local void gz_reset(gz_statep state) { |
| 70 | state->x.have = 0; /* no output data available */ |
| 71 | if (state->mode == GZ_READ) { /* for reading ... */ |
| 72 | state->eof = 0; /* not at end of file */ |
| 73 | state->past = 0; /* have not read past end yet */ |
| 74 | state->how = LOOK; /* look for gzip header */ |
| @@ -88,15 +80,11 @@ | |
| 80 | state->x.pos = 0; /* no uncompressed data yet */ |
| 81 | state->strm.avail_in = 0; /* no input data yet */ |
| 82 | } |
| 83 | |
| 84 | /* Open a gzip file either by name or file descriptor. */ |
| 85 | local gzFile gz_open(const void *path, int fd, const char *mode) { |
| 86 | gz_statep state; |
| 87 | z_size_t len; |
| 88 | int oflag; |
| 89 | #ifdef O_CLOEXEC |
| 90 | int cloexec = 0; |
| @@ -267,30 +255,21 @@ | |
| 255 | /* return stream */ |
| 256 | return (gzFile)state; |
| 257 | } |
| 258 | |
| 259 | /* -- see zlib.h -- */ |
| 260 | gzFile ZEXPORT gzopen(const char *path, const char *mode) { |
| 261 | return gz_open(path, -1, mode); |
| 262 | } |
| 263 | |
| 264 | /* -- see zlib.h -- */ |
| 265 | gzFile ZEXPORT gzopen64(const char *path, const char *mode) { |
| 266 | return gz_open(path, -1, mode); |
| 267 | } |
| 268 | |
| 269 | /* -- see zlib.h -- */ |
| 270 | gzFile ZEXPORT gzdopen(int fd, const char *mode) { |
| 271 | char *path; /* identifier for error messages */ |
| 272 | gzFile gz; |
| 273 | |
| 274 | if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL) |
| 275 | return NULL; |
| @@ -304,23 +283,17 @@ | |
| 283 | return gz; |
| 284 | } |
| 285 | |
| 286 | /* -- see zlib.h -- */ |
| 287 | #ifdef WIDECHAR |
| 288 | gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) { |
| 289 | return gz_open(path, -2, mode); |
| 290 | } |
| 291 | #endif |
| 292 | |
| 293 | /* -- see zlib.h -- */ |
| 294 | int ZEXPORT gzbuffer(gzFile file, unsigned size) { |
| 295 | gz_statep state; |
| 296 | |
| 297 | /* get internal structure and check integrity */ |
| 298 | if (file == NULL) |
| 299 | return -1; |
| @@ -333,20 +306,18 @@ | |
| 306 | return -1; |
| 307 | |
| 308 | /* check and set requested size */ |
| 309 | if ((size << 1) < size) |
| 310 | return -1; /* need to be able to double it */ |
| 311 | if (size < 8) |
| 312 | size = 8; /* needed to behave well with flushing */ |
| 313 | state->want = size; |
| 314 | return 0; |
| 315 | } |
| 316 | |
| 317 | /* -- see zlib.h -- */ |
| 318 | int ZEXPORT gzrewind(gzFile file) { |
| 319 | gz_statep state; |
| 320 | |
| 321 | /* get internal structure */ |
| 322 | if (file == NULL) |
| 323 | return -1; |
| @@ -363,15 +334,11 @@ | |
| 334 | gz_reset(state); |
| 335 | return 0; |
| 336 | } |
| 337 | |
| 338 | /* -- see zlib.h -- */ |
| 339 | z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) { |
| 340 | unsigned n; |
| 341 | z_off64_t ret; |
| 342 | gz_statep state; |
| 343 | |
| 344 | /* get internal structure and check integrity */ |
| @@ -440,25 +407,19 @@ | |
| 407 | } |
| 408 | return state->x.pos + offset; |
| 409 | } |
| 410 | |
| 411 | /* -- see zlib.h -- */ |
| 412 | z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) { |
| 413 | z_off64_t ret; |
| 414 | |
| 415 | ret = gzseek64(file, (z_off64_t)offset, whence); |
| 416 | return ret == (z_off_t)ret ? (z_off_t)ret : -1; |
| 417 | } |
| 418 | |
| 419 | /* -- see zlib.h -- */ |
| 420 | z_off64_t ZEXPORT gztell64(gzFile file) { |
| 421 | gz_statep state; |
| 422 | |
| 423 | /* get internal structure and check integrity */ |
| 424 | if (file == NULL) |
| 425 | return -1; |
| @@ -469,23 +430,19 @@ | |
| 430 | /* return position */ |
| 431 | return state->x.pos + (state->seek ? state->skip : 0); |
| 432 | } |
| 433 | |
| 434 | /* -- see zlib.h -- */ |
| 435 | z_off_t ZEXPORT gztell(gzFile file) { |
| 436 | z_off64_t ret; |
| 437 | |
| 438 | ret = gztell64(file); |
| 439 | return ret == (z_off_t)ret ? (z_off_t)ret : -1; |
| 440 | } |
| 441 | |
| 442 | /* -- see zlib.h -- */ |
| 443 | z_off64_t ZEXPORT gzoffset64(gzFile file) { |
| 444 | z_off64_t offset; |
| 445 | gz_statep state; |
| 446 | |
| 447 | /* get internal structure and check integrity */ |
| 448 | if (file == NULL) |
| @@ -502,23 +459,19 @@ | |
| 459 | offset -= state->strm.avail_in; /* don't count buffered input */ |
| 460 | return offset; |
| 461 | } |
| 462 | |
| 463 | /* -- see zlib.h -- */ |
| 464 | z_off_t ZEXPORT gzoffset(gzFile file) { |
| 465 | z_off64_t ret; |
| 466 | |
| 467 | ret = gzoffset64(file); |
| 468 | return ret == (z_off_t)ret ? (z_off_t)ret : -1; |
| 469 | } |
| 470 | |
| 471 | /* -- see zlib.h -- */ |
| 472 | int ZEXPORT gzeof(gzFile file) { |
| 473 | gz_statep state; |
| 474 | |
| 475 | /* get internal structure and check integrity */ |
| 476 | if (file == NULL) |
| 477 | return 0; |
| @@ -529,14 +482,11 @@ | |
| 482 | /* return end-of-file state */ |
| 483 | return state->mode == GZ_READ ? state->past : 0; |
| 484 | } |
| 485 | |
| 486 | /* -- see zlib.h -- */ |
| 487 | const char * ZEXPORT gzerror(gzFile file, int *errnum) { |
| 488 | gz_statep state; |
| 489 | |
| 490 | /* get internal structure and check integrity */ |
| 491 | if (file == NULL) |
| 492 | return NULL; |
| @@ -550,13 +500,11 @@ | |
| 500 | return state->err == Z_MEM_ERROR ? "out of memory" : |
| 501 | (state->msg == NULL ? "" : state->msg); |
| 502 | } |
| 503 | |
| 504 | /* -- see zlib.h -- */ |
| 505 | void ZEXPORT gzclearerr(gzFile file) { |
| 506 | gz_statep state; |
| 507 | |
| 508 | /* get internal structure and check integrity */ |
| 509 | if (file == NULL) |
| 510 | return; |
| @@ -576,15 +524,11 @@ | |
| 524 | state->msg accordingly. Free any previous error message already there. Do |
| 525 | not try to free or allocate space if the error is Z_MEM_ERROR (out of |
| 526 | memory). Simply save the error message as a static string. If there is an |
| 527 | allocation failure constructing the error message, then convert the error to |
| 528 | out of memory. */ |
| 529 | void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) { |
| 530 | /* free previously allocated message and clear */ |
| 531 | if (state->msg != NULL) { |
| 532 | if (state->err != Z_MEM_ERROR) |
| 533 | free(state->msg); |
| 534 | state->msg = NULL; |
| @@ -622,12 +566,11 @@ | |
| 566 | #ifndef INT_MAX |
| 567 | /* portably return maximum value for an int (when limits.h presumed not |
| 568 | available) -- we need to do this to cover cases where 2's complement not |
| 569 | used, since C standard permits 1's complement and sign-bit representations, |
| 570 | otherwise we could just use ((unsigned)-1) >> 1 */ |
| 571 | unsigned ZLIB_INTERNAL gz_intmax(void) { |
| 572 | unsigned p, q; |
| 573 | |
| 574 | p = 1; |
| 575 | do { |
| 576 | q = p; |
| 577 |
+20
-68
| --- compat/zlib/gzread.c | ||
| +++ compat/zlib/gzread.c | ||
| @@ -3,29 +3,16 @@ | ||
| 3 | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | #include "gzguts.h" |
| 7 | 7 | |
| 8 | -/* Local functions */ | |
| 9 | -local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); | |
| 10 | -local int gz_avail OF((gz_statep)); | |
| 11 | -local int gz_look OF((gz_statep)); | |
| 12 | -local int gz_decomp OF((gz_statep)); | |
| 13 | -local int gz_fetch OF((gz_statep)); | |
| 14 | -local int gz_skip OF((gz_statep, z_off64_t)); | |
| 15 | -local z_size_t gz_read OF((gz_statep, voidp, z_size_t)); | |
| 16 | - | |
| 17 | 8 | /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from |
| 18 | 9 | state->fd, and update state->eof, state->err, and state->msg as appropriate. |
| 19 | 10 | This function needs to loop on read(), since read() is not guaranteed to |
| 20 | 11 | read the number of bytes requested, depending on the type of descriptor. */ |
| 21 | -local int gz_load(state, buf, len, have) | |
| 22 | - gz_statep state; | |
| 23 | - unsigned char *buf; | |
| 24 | - unsigned len; | |
| 25 | - unsigned *have; | |
| 26 | -{ | |
| 12 | +local int gz_load(gz_statep state, unsigned char *buf, unsigned len, | |
| 13 | + unsigned *have) { | |
| 27 | 14 | int ret; |
| 28 | 15 | unsigned get, max = ((unsigned)-1 >> 2) + 1; |
| 29 | 16 | |
| 30 | 17 | *have = 0; |
| 31 | 18 | do { |
| @@ -51,13 +38,11 @@ | ||
| 51 | 38 | file is reached, even though there may be unused data in the buffer. Once |
| 52 | 39 | that data has been used, no more attempts will be made to read the file. |
| 53 | 40 | If strm->avail_in != 0, then the current data is moved to the beginning of |
| 54 | 41 | the input buffer, and then the remainder of the buffer is loaded with the |
| 55 | 42 | available data from the input file. */ |
| 56 | -local int gz_avail(state) | |
| 57 | - gz_statep state; | |
| 58 | -{ | |
| 43 | +local int gz_avail(gz_statep state) { | |
| 59 | 44 | unsigned got; |
| 60 | 45 | z_streamp strm = &(state->strm); |
| 61 | 46 | |
| 62 | 47 | if (state->err != Z_OK && state->err != Z_BUF_ERROR) |
| 63 | 48 | return -1; |
| @@ -86,13 +71,11 @@ | ||
| 86 | 71 | be set to GZIP for decompression. If direct copying, then leftover input |
| 87 | 72 | data from the input buffer will be copied to the output buffer. In that |
| 88 | 73 | case, all further file reads will be directly to either the output buffer or |
| 89 | 74 | a user buffer. If decompressing, the inflate state will be initialized. |
| 90 | 75 | gz_look() will return 0 on success or -1 on failure. */ |
| 91 | -local int gz_look(state) | |
| 92 | - gz_statep state; | |
| 93 | -{ | |
| 76 | +local int gz_look(gz_statep state) { | |
| 94 | 77 | z_streamp strm = &(state->strm); |
| 95 | 78 | |
| 96 | 79 | /* allocate read buffers and inflate memory */ |
| 97 | 80 | if (state->size == 0) { |
| 98 | 81 | /* allocate buffers */ |
| @@ -168,13 +151,11 @@ | ||
| 168 | 151 | /* Decompress from input to the provided next_out and avail_out in the state. |
| 169 | 152 | On return, state->x.have and state->x.next point to the just decompressed |
| 170 | 153 | data. If the gzip stream completes, state->how is reset to LOOK to look for |
| 171 | 154 | the next gzip stream or raw data, once state->x.have is depleted. Returns 0 |
| 172 | 155 | on success, -1 on failure. */ |
| 173 | -local int gz_decomp(state) | |
| 174 | - gz_statep state; | |
| 175 | -{ | |
| 156 | +local int gz_decomp(gz_statep state) { | |
| 176 | 157 | int ret = Z_OK; |
| 177 | 158 | unsigned had; |
| 178 | 159 | z_streamp strm = &(state->strm); |
| 179 | 160 | |
| 180 | 161 | /* fill output buffer up to end of deflate stream */ |
| @@ -222,13 +203,11 @@ | ||
| 222 | 203 | Data is either copied from the input file or decompressed from the input |
| 223 | 204 | file depending on state->how. If state->how is LOOK, then a gzip header is |
| 224 | 205 | looked for to determine whether to copy or decompress. Returns -1 on error, |
| 225 | 206 | otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the |
| 226 | 207 | end of the input file has been reached and all data has been processed. */ |
| 227 | -local int gz_fetch(state) | |
| 228 | - gz_statep state; | |
| 229 | -{ | |
| 208 | +local int gz_fetch(gz_statep state) { | |
| 230 | 209 | z_streamp strm = &(state->strm); |
| 231 | 210 | |
| 232 | 211 | do { |
| 233 | 212 | switch(state->how) { |
| 234 | 213 | case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */ |
| @@ -252,14 +231,11 @@ | ||
| 252 | 231 | } while (state->x.have == 0 && (!state->eof || strm->avail_in)); |
| 253 | 232 | return 0; |
| 254 | 233 | } |
| 255 | 234 | |
| 256 | 235 | /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ |
| 257 | -local int gz_skip(state, len) | |
| 258 | - gz_statep state; | |
| 259 | - z_off64_t len; | |
| 260 | -{ | |
| 236 | +local int gz_skip(gz_statep state, z_off64_t len) { | |
| 261 | 237 | unsigned n; |
| 262 | 238 | |
| 263 | 239 | /* skip over len bytes or reach end-of-file, whichever comes first */ |
| 264 | 240 | while (len) |
| 265 | 241 | /* skip over whatever is in output buffer */ |
| @@ -287,15 +263,11 @@ | ||
| 287 | 263 | |
| 288 | 264 | /* Read len bytes into buf from file, or less than len up to the end of the |
| 289 | 265 | input. Return the number of bytes read. If zero is returned, either the |
| 290 | 266 | end of file was reached, or there was an error. state->err must be |
| 291 | 267 | consulted in that case to determine which. */ |
| 292 | -local z_size_t gz_read(state, buf, len) | |
| 293 | - gz_statep state; | |
| 294 | - voidp buf; | |
| 295 | - z_size_t len; | |
| 296 | -{ | |
| 268 | +local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) { | |
| 297 | 269 | z_size_t got; |
| 298 | 270 | unsigned n; |
| 299 | 271 | |
| 300 | 272 | /* if len is zero, avoid unnecessary operations */ |
| 301 | 273 | if (len == 0) |
| @@ -368,15 +340,11 @@ | ||
| 368 | 340 | /* return number of bytes read into user buffer */ |
| 369 | 341 | return got; |
| 370 | 342 | } |
| 371 | 343 | |
| 372 | 344 | /* -- see zlib.h -- */ |
| 373 | -int ZEXPORT gzread(file, buf, len) | |
| 374 | - gzFile file; | |
| 375 | - voidp buf; | |
| 376 | - unsigned len; | |
| 377 | -{ | |
| 345 | +int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) { | |
| 378 | 346 | gz_statep state; |
| 379 | 347 | |
| 380 | 348 | /* get internal structure */ |
| 381 | 349 | if (file == NULL) |
| 382 | 350 | return -1; |
| @@ -404,16 +372,11 @@ | ||
| 404 | 372 | /* return the number of bytes read (this is assured to fit in an int) */ |
| 405 | 373 | return (int)len; |
| 406 | 374 | } |
| 407 | 375 | |
| 408 | 376 | /* -- see zlib.h -- */ |
| 409 | -z_size_t ZEXPORT gzfread(buf, size, nitems, file) | |
| 410 | - voidp buf; | |
| 411 | - z_size_t size; | |
| 412 | - z_size_t nitems; | |
| 413 | - gzFile file; | |
| 414 | -{ | |
| 377 | +z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) { | |
| 415 | 378 | z_size_t len; |
| 416 | 379 | gz_statep state; |
| 417 | 380 | |
| 418 | 381 | /* get internal structure */ |
| 419 | 382 | if (file == NULL) |
| @@ -440,13 +403,11 @@ | ||
| 440 | 403 | #ifdef Z_PREFIX_SET |
| 441 | 404 | # undef z_gzgetc |
| 442 | 405 | #else |
| 443 | 406 | # undef gzgetc |
| 444 | 407 | #endif |
| 445 | -int ZEXPORT gzgetc(file) | |
| 446 | - gzFile file; | |
| 447 | -{ | |
| 408 | +int ZEXPORT gzgetc(gzFile file) { | |
| 448 | 409 | unsigned char buf[1]; |
| 449 | 410 | gz_statep state; |
| 450 | 411 | |
| 451 | 412 | /* get internal structure */ |
| 452 | 413 | if (file == NULL) |
| @@ -467,27 +428,26 @@ | ||
| 467 | 428 | |
| 468 | 429 | /* nothing there -- try gz_read() */ |
| 469 | 430 | return gz_read(state, buf, 1) < 1 ? -1 : buf[0]; |
| 470 | 431 | } |
| 471 | 432 | |
| 472 | -int ZEXPORT gzgetc_(file) | |
| 473 | -gzFile file; | |
| 474 | -{ | |
| 433 | +int ZEXPORT gzgetc_(gzFile file) { | |
| 475 | 434 | return gzgetc(file); |
| 476 | 435 | } |
| 477 | 436 | |
| 478 | 437 | /* -- see zlib.h -- */ |
| 479 | -int ZEXPORT gzungetc(c, file) | |
| 480 | - int c; | |
| 481 | - gzFile file; | |
| 482 | -{ | |
| 438 | +int ZEXPORT gzungetc(int c, gzFile file) { | |
| 483 | 439 | gz_statep state; |
| 484 | 440 | |
| 485 | 441 | /* get internal structure */ |
| 486 | 442 | if (file == NULL) |
| 487 | 443 | return -1; |
| 488 | 444 | state = (gz_statep)file; |
| 445 | + | |
| 446 | + /* in case this was just opened, set up the input buffer */ | |
| 447 | + if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) | |
| 448 | + (void)gz_look(state); | |
| 489 | 449 | |
| 490 | 450 | /* check that we're reading and that there's no (serious) error */ |
| 491 | 451 | if (state->mode != GZ_READ || |
| 492 | 452 | (state->err != Z_OK && state->err != Z_BUF_ERROR)) |
| 493 | 453 | return -1; |
| @@ -534,15 +494,11 @@ | ||
| 534 | 494 | state->past = 0; |
| 535 | 495 | return c; |
| 536 | 496 | } |
| 537 | 497 | |
| 538 | 498 | /* -- see zlib.h -- */ |
| 539 | -char * ZEXPORT gzgets(file, buf, len) | |
| 540 | - gzFile file; | |
| 541 | - char *buf; | |
| 542 | - int len; | |
| 543 | -{ | |
| 499 | +char * ZEXPORT gzgets(gzFile file, char *buf, int len) { | |
| 544 | 500 | unsigned left, n; |
| 545 | 501 | char *str; |
| 546 | 502 | unsigned char *eol; |
| 547 | 503 | gz_statep state; |
| 548 | 504 | |
| @@ -598,13 +554,11 @@ | ||
| 598 | 554 | buf[0] = 0; |
| 599 | 555 | return str; |
| 600 | 556 | } |
| 601 | 557 | |
| 602 | 558 | /* -- see zlib.h -- */ |
| 603 | -int ZEXPORT gzdirect(file) | |
| 604 | - gzFile file; | |
| 605 | -{ | |
| 559 | +int ZEXPORT gzdirect(gzFile file) { | |
| 606 | 560 | gz_statep state; |
| 607 | 561 | |
| 608 | 562 | /* get internal structure */ |
| 609 | 563 | if (file == NULL) |
| 610 | 564 | return 0; |
| @@ -618,13 +572,11 @@ | ||
| 618 | 572 | /* return 1 if transparent, 0 if processing a gzip stream */ |
| 619 | 573 | return state->direct; |
| 620 | 574 | } |
| 621 | 575 | |
| 622 | 576 | /* -- see zlib.h -- */ |
| 623 | -int ZEXPORT gzclose_r(file) | |
| 624 | - gzFile file; | |
| 625 | -{ | |
| 577 | +int ZEXPORT gzclose_r(gzFile file) { | |
| 626 | 578 | int ret, err; |
| 627 | 579 | gz_statep state; |
| 628 | 580 | |
| 629 | 581 | /* get internal structure */ |
| 630 | 582 | if (file == NULL) |
| 631 | 583 |
| --- compat/zlib/gzread.c | |
| +++ compat/zlib/gzread.c | |
| @@ -3,29 +3,16 @@ | |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ |
| 5 | |
| 6 | #include "gzguts.h" |
| 7 | |
| 8 | /* Local functions */ |
| 9 | local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); |
| 10 | local int gz_avail OF((gz_statep)); |
| 11 | local int gz_look OF((gz_statep)); |
| 12 | local int gz_decomp OF((gz_statep)); |
| 13 | local int gz_fetch OF((gz_statep)); |
| 14 | local int gz_skip OF((gz_statep, z_off64_t)); |
| 15 | local z_size_t gz_read OF((gz_statep, voidp, z_size_t)); |
| 16 | |
| 17 | /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from |
| 18 | state->fd, and update state->eof, state->err, and state->msg as appropriate. |
| 19 | This function needs to loop on read(), since read() is not guaranteed to |
| 20 | read the number of bytes requested, depending on the type of descriptor. */ |
| 21 | local int gz_load(state, buf, len, have) |
| 22 | gz_statep state; |
| 23 | unsigned char *buf; |
| 24 | unsigned len; |
| 25 | unsigned *have; |
| 26 | { |
| 27 | int ret; |
| 28 | unsigned get, max = ((unsigned)-1 >> 2) + 1; |
| 29 | |
| 30 | *have = 0; |
| 31 | do { |
| @@ -51,13 +38,11 @@ | |
| 51 | file is reached, even though there may be unused data in the buffer. Once |
| 52 | that data has been used, no more attempts will be made to read the file. |
| 53 | If strm->avail_in != 0, then the current data is moved to the beginning of |
| 54 | the input buffer, and then the remainder of the buffer is loaded with the |
| 55 | available data from the input file. */ |
| 56 | local int gz_avail(state) |
| 57 | gz_statep state; |
| 58 | { |
| 59 | unsigned got; |
| 60 | z_streamp strm = &(state->strm); |
| 61 | |
| 62 | if (state->err != Z_OK && state->err != Z_BUF_ERROR) |
| 63 | return -1; |
| @@ -86,13 +71,11 @@ | |
| 86 | be set to GZIP for decompression. If direct copying, then leftover input |
| 87 | data from the input buffer will be copied to the output buffer. In that |
| 88 | case, all further file reads will be directly to either the output buffer or |
| 89 | a user buffer. If decompressing, the inflate state will be initialized. |
| 90 | gz_look() will return 0 on success or -1 on failure. */ |
| 91 | local int gz_look(state) |
| 92 | gz_statep state; |
| 93 | { |
| 94 | z_streamp strm = &(state->strm); |
| 95 | |
| 96 | /* allocate read buffers and inflate memory */ |
| 97 | if (state->size == 0) { |
| 98 | /* allocate buffers */ |
| @@ -168,13 +151,11 @@ | |
| 168 | /* Decompress from input to the provided next_out and avail_out in the state. |
| 169 | On return, state->x.have and state->x.next point to the just decompressed |
| 170 | data. If the gzip stream completes, state->how is reset to LOOK to look for |
| 171 | the next gzip stream or raw data, once state->x.have is depleted. Returns 0 |
| 172 | on success, -1 on failure. */ |
| 173 | local int gz_decomp(state) |
| 174 | gz_statep state; |
| 175 | { |
| 176 | int ret = Z_OK; |
| 177 | unsigned had; |
| 178 | z_streamp strm = &(state->strm); |
| 179 | |
| 180 | /* fill output buffer up to end of deflate stream */ |
| @@ -222,13 +203,11 @@ | |
| 222 | Data is either copied from the input file or decompressed from the input |
| 223 | file depending on state->how. If state->how is LOOK, then a gzip header is |
| 224 | looked for to determine whether to copy or decompress. Returns -1 on error, |
| 225 | otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the |
| 226 | end of the input file has been reached and all data has been processed. */ |
| 227 | local int gz_fetch(state) |
| 228 | gz_statep state; |
| 229 | { |
| 230 | z_streamp strm = &(state->strm); |
| 231 | |
| 232 | do { |
| 233 | switch(state->how) { |
| 234 | case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */ |
| @@ -252,14 +231,11 @@ | |
| 252 | } while (state->x.have == 0 && (!state->eof || strm->avail_in)); |
| 253 | return 0; |
| 254 | } |
| 255 | |
| 256 | /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ |
| 257 | local int gz_skip(state, len) |
| 258 | gz_statep state; |
| 259 | z_off64_t len; |
| 260 | { |
| 261 | unsigned n; |
| 262 | |
| 263 | /* skip over len bytes or reach end-of-file, whichever comes first */ |
| 264 | while (len) |
| 265 | /* skip over whatever is in output buffer */ |
| @@ -287,15 +263,11 @@ | |
| 287 | |
| 288 | /* Read len bytes into buf from file, or less than len up to the end of the |
| 289 | input. Return the number of bytes read. If zero is returned, either the |
| 290 | end of file was reached, or there was an error. state->err must be |
| 291 | consulted in that case to determine which. */ |
| 292 | local z_size_t gz_read(state, buf, len) |
| 293 | gz_statep state; |
| 294 | voidp buf; |
| 295 | z_size_t len; |
| 296 | { |
| 297 | z_size_t got; |
| 298 | unsigned n; |
| 299 | |
| 300 | /* if len is zero, avoid unnecessary operations */ |
| 301 | if (len == 0) |
| @@ -368,15 +340,11 @@ | |
| 368 | /* return number of bytes read into user buffer */ |
| 369 | return got; |
| 370 | } |
| 371 | |
| 372 | /* -- see zlib.h -- */ |
| 373 | int ZEXPORT gzread(file, buf, len) |
| 374 | gzFile file; |
| 375 | voidp buf; |
| 376 | unsigned len; |
| 377 | { |
| 378 | gz_statep state; |
| 379 | |
| 380 | /* get internal structure */ |
| 381 | if (file == NULL) |
| 382 | return -1; |
| @@ -404,16 +372,11 @@ | |
| 404 | /* return the number of bytes read (this is assured to fit in an int) */ |
| 405 | return (int)len; |
| 406 | } |
| 407 | |
| 408 | /* -- see zlib.h -- */ |
| 409 | z_size_t ZEXPORT gzfread(buf, size, nitems, file) |
| 410 | voidp buf; |
| 411 | z_size_t size; |
| 412 | z_size_t nitems; |
| 413 | gzFile file; |
| 414 | { |
| 415 | z_size_t len; |
| 416 | gz_statep state; |
| 417 | |
| 418 | /* get internal structure */ |
| 419 | if (file == NULL) |
| @@ -440,13 +403,11 @@ | |
| 440 | #ifdef Z_PREFIX_SET |
| 441 | # undef z_gzgetc |
| 442 | #else |
| 443 | # undef gzgetc |
| 444 | #endif |
| 445 | int ZEXPORT gzgetc(file) |
| 446 | gzFile file; |
| 447 | { |
| 448 | unsigned char buf[1]; |
| 449 | gz_statep state; |
| 450 | |
| 451 | /* get internal structure */ |
| 452 | if (file == NULL) |
| @@ -467,27 +428,26 @@ | |
| 467 | |
| 468 | /* nothing there -- try gz_read() */ |
| 469 | return gz_read(state, buf, 1) < 1 ? -1 : buf[0]; |
| 470 | } |
| 471 | |
| 472 | int ZEXPORT gzgetc_(file) |
| 473 | gzFile file; |
| 474 | { |
| 475 | return gzgetc(file); |
| 476 | } |
| 477 | |
| 478 | /* -- see zlib.h -- */ |
| 479 | int ZEXPORT gzungetc(c, file) |
| 480 | int c; |
| 481 | gzFile file; |
| 482 | { |
| 483 | gz_statep state; |
| 484 | |
| 485 | /* get internal structure */ |
| 486 | if (file == NULL) |
| 487 | return -1; |
| 488 | state = (gz_statep)file; |
| 489 | |
| 490 | /* check that we're reading and that there's no (serious) error */ |
| 491 | if (state->mode != GZ_READ || |
| 492 | (state->err != Z_OK && state->err != Z_BUF_ERROR)) |
| 493 | return -1; |
| @@ -534,15 +494,11 @@ | |
| 534 | state->past = 0; |
| 535 | return c; |
| 536 | } |
| 537 | |
| 538 | /* -- see zlib.h -- */ |
| 539 | char * ZEXPORT gzgets(file, buf, len) |
| 540 | gzFile file; |
| 541 | char *buf; |
| 542 | int len; |
| 543 | { |
| 544 | unsigned left, n; |
| 545 | char *str; |
| 546 | unsigned char *eol; |
| 547 | gz_statep state; |
| 548 | |
| @@ -598,13 +554,11 @@ | |
| 598 | buf[0] = 0; |
| 599 | return str; |
| 600 | } |
| 601 | |
| 602 | /* -- see zlib.h -- */ |
| 603 | int ZEXPORT gzdirect(file) |
| 604 | gzFile file; |
| 605 | { |
| 606 | gz_statep state; |
| 607 | |
| 608 | /* get internal structure */ |
| 609 | if (file == NULL) |
| 610 | return 0; |
| @@ -618,13 +572,11 @@ | |
| 618 | /* return 1 if transparent, 0 if processing a gzip stream */ |
| 619 | return state->direct; |
| 620 | } |
| 621 | |
| 622 | /* -- see zlib.h -- */ |
| 623 | int ZEXPORT gzclose_r(file) |
| 624 | gzFile file; |
| 625 | { |
| 626 | int ret, err; |
| 627 | gz_statep state; |
| 628 | |
| 629 | /* get internal structure */ |
| 630 | if (file == NULL) |
| 631 |
| --- compat/zlib/gzread.c | |
| +++ compat/zlib/gzread.c | |
| @@ -3,29 +3,16 @@ | |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ |
| 5 | |
| 6 | #include "gzguts.h" |
| 7 | |
| 8 | /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from |
| 9 | state->fd, and update state->eof, state->err, and state->msg as appropriate. |
| 10 | This function needs to loop on read(), since read() is not guaranteed to |
| 11 | read the number of bytes requested, depending on the type of descriptor. */ |
| 12 | local int gz_load(gz_statep state, unsigned char *buf, unsigned len, |
| 13 | unsigned *have) { |
| 14 | int ret; |
| 15 | unsigned get, max = ((unsigned)-1 >> 2) + 1; |
| 16 | |
| 17 | *have = 0; |
| 18 | do { |
| @@ -51,13 +38,11 @@ | |
| 38 | file is reached, even though there may be unused data in the buffer. Once |
| 39 | that data has been used, no more attempts will be made to read the file. |
| 40 | If strm->avail_in != 0, then the current data is moved to the beginning of |
| 41 | the input buffer, and then the remainder of the buffer is loaded with the |
| 42 | available data from the input file. */ |
| 43 | local int gz_avail(gz_statep state) { |
| 44 | unsigned got; |
| 45 | z_streamp strm = &(state->strm); |
| 46 | |
| 47 | if (state->err != Z_OK && state->err != Z_BUF_ERROR) |
| 48 | return -1; |
| @@ -86,13 +71,11 @@ | |
| 71 | be set to GZIP for decompression. If direct copying, then leftover input |
| 72 | data from the input buffer will be copied to the output buffer. In that |
| 73 | case, all further file reads will be directly to either the output buffer or |
| 74 | a user buffer. If decompressing, the inflate state will be initialized. |
| 75 | gz_look() will return 0 on success or -1 on failure. */ |
| 76 | local int gz_look(gz_statep state) { |
| 77 | z_streamp strm = &(state->strm); |
| 78 | |
| 79 | /* allocate read buffers and inflate memory */ |
| 80 | if (state->size == 0) { |
| 81 | /* allocate buffers */ |
| @@ -168,13 +151,11 @@ | |
| 151 | /* Decompress from input to the provided next_out and avail_out in the state. |
| 152 | On return, state->x.have and state->x.next point to the just decompressed |
| 153 | data. If the gzip stream completes, state->how is reset to LOOK to look for |
| 154 | the next gzip stream or raw data, once state->x.have is depleted. Returns 0 |
| 155 | on success, -1 on failure. */ |
| 156 | local int gz_decomp(gz_statep state) { |
| 157 | int ret = Z_OK; |
| 158 | unsigned had; |
| 159 | z_streamp strm = &(state->strm); |
| 160 | |
| 161 | /* fill output buffer up to end of deflate stream */ |
| @@ -222,13 +203,11 @@ | |
| 203 | Data is either copied from the input file or decompressed from the input |
| 204 | file depending on state->how. If state->how is LOOK, then a gzip header is |
| 205 | looked for to determine whether to copy or decompress. Returns -1 on error, |
| 206 | otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the |
| 207 | end of the input file has been reached and all data has been processed. */ |
| 208 | local int gz_fetch(gz_statep state) { |
| 209 | z_streamp strm = &(state->strm); |
| 210 | |
| 211 | do { |
| 212 | switch(state->how) { |
| 213 | case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */ |
| @@ -252,14 +231,11 @@ | |
| 231 | } while (state->x.have == 0 && (!state->eof || strm->avail_in)); |
| 232 | return 0; |
| 233 | } |
| 234 | |
| 235 | /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ |
| 236 | local int gz_skip(gz_statep state, z_off64_t len) { |
| 237 | unsigned n; |
| 238 | |
| 239 | /* skip over len bytes or reach end-of-file, whichever comes first */ |
| 240 | while (len) |
| 241 | /* skip over whatever is in output buffer */ |
| @@ -287,15 +263,11 @@ | |
| 263 | |
| 264 | /* Read len bytes into buf from file, or less than len up to the end of the |
| 265 | input. Return the number of bytes read. If zero is returned, either the |
| 266 | end of file was reached, or there was an error. state->err must be |
| 267 | consulted in that case to determine which. */ |
| 268 | local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) { |
| 269 | z_size_t got; |
| 270 | unsigned n; |
| 271 | |
| 272 | /* if len is zero, avoid unnecessary operations */ |
| 273 | if (len == 0) |
| @@ -368,15 +340,11 @@ | |
| 340 | /* return number of bytes read into user buffer */ |
| 341 | return got; |
| 342 | } |
| 343 | |
| 344 | /* -- see zlib.h -- */ |
| 345 | int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) { |
| 346 | gz_statep state; |
| 347 | |
| 348 | /* get internal structure */ |
| 349 | if (file == NULL) |
| 350 | return -1; |
| @@ -404,16 +372,11 @@ | |
| 372 | /* return the number of bytes read (this is assured to fit in an int) */ |
| 373 | return (int)len; |
| 374 | } |
| 375 | |
| 376 | /* -- see zlib.h -- */ |
| 377 | z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) { |
| 378 | z_size_t len; |
| 379 | gz_statep state; |
| 380 | |
| 381 | /* get internal structure */ |
| 382 | if (file == NULL) |
| @@ -440,13 +403,11 @@ | |
| 403 | #ifdef Z_PREFIX_SET |
| 404 | # undef z_gzgetc |
| 405 | #else |
| 406 | # undef gzgetc |
| 407 | #endif |
| 408 | int ZEXPORT gzgetc(gzFile file) { |
| 409 | unsigned char buf[1]; |
| 410 | gz_statep state; |
| 411 | |
| 412 | /* get internal structure */ |
| 413 | if (file == NULL) |
| @@ -467,27 +428,26 @@ | |
| 428 | |
| 429 | /* nothing there -- try gz_read() */ |
| 430 | return gz_read(state, buf, 1) < 1 ? -1 : buf[0]; |
| 431 | } |
| 432 | |
| 433 | int ZEXPORT gzgetc_(gzFile file) { |
| 434 | return gzgetc(file); |
| 435 | } |
| 436 | |
| 437 | /* -- see zlib.h -- */ |
| 438 | int ZEXPORT gzungetc(int c, gzFile file) { |
| 439 | gz_statep state; |
| 440 | |
| 441 | /* get internal structure */ |
| 442 | if (file == NULL) |
| 443 | return -1; |
| 444 | state = (gz_statep)file; |
| 445 | |
| 446 | /* in case this was just opened, set up the input buffer */ |
| 447 | if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) |
| 448 | (void)gz_look(state); |
| 449 | |
| 450 | /* check that we're reading and that there's no (serious) error */ |
| 451 | if (state->mode != GZ_READ || |
| 452 | (state->err != Z_OK && state->err != Z_BUF_ERROR)) |
| 453 | return -1; |
| @@ -534,15 +494,11 @@ | |
| 494 | state->past = 0; |
| 495 | return c; |
| 496 | } |
| 497 | |
| 498 | /* -- see zlib.h -- */ |
| 499 | char * ZEXPORT gzgets(gzFile file, char *buf, int len) { |
| 500 | unsigned left, n; |
| 501 | char *str; |
| 502 | unsigned char *eol; |
| 503 | gz_statep state; |
| 504 | |
| @@ -598,13 +554,11 @@ | |
| 554 | buf[0] = 0; |
| 555 | return str; |
| 556 | } |
| 557 | |
| 558 | /* -- see zlib.h -- */ |
| 559 | int ZEXPORT gzdirect(gzFile file) { |
| 560 | gz_statep state; |
| 561 | |
| 562 | /* get internal structure */ |
| 563 | if (file == NULL) |
| 564 | return 0; |
| @@ -618,13 +572,11 @@ | |
| 572 | /* return 1 if transparent, 0 if processing a gzip stream */ |
| 573 | return state->direct; |
| 574 | } |
| 575 | |
| 576 | /* -- see zlib.h -- */ |
| 577 | int ZEXPORT gzclose_r(gzFile file) { |
| 578 | int ret, err; |
| 579 | gz_statep state; |
| 580 | |
| 581 | /* get internal structure */ |
| 582 | if (file == NULL) |
| 583 |
+19
-65
| --- compat/zlib/gzwrite.c | ||
| +++ compat/zlib/gzwrite.c | ||
| @@ -3,22 +3,14 @@ | ||
| 3 | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | #include "gzguts.h" |
| 7 | 7 | |
| 8 | -/* Local functions */ | |
| 9 | -local int gz_init OF((gz_statep)); | |
| 10 | -local int gz_comp OF((gz_statep, int)); | |
| 11 | -local int gz_zero OF((gz_statep, z_off64_t)); | |
| 12 | -local z_size_t gz_write OF((gz_statep, voidpc, z_size_t)); | |
| 13 | - | |
| 14 | 8 | /* Initialize state for writing a gzip file. Mark initialization by setting |
| 15 | 9 | state->size to non-zero. Return -1 on a memory allocation failure, or 0 on |
| 16 | 10 | success. */ |
| 17 | -local int gz_init(state) | |
| 18 | - gz_statep state; | |
| 19 | -{ | |
| 11 | +local int gz_init(gz_statep state) { | |
| 20 | 12 | int ret; |
| 21 | 13 | z_streamp strm = &(state->strm); |
| 22 | 14 | |
| 23 | 15 | /* allocate input buffer (double size for gzprintf) */ |
| 24 | 16 | state->in = (unsigned char *)malloc(state->want << 1); |
| @@ -68,14 +60,11 @@ | ||
| 68 | 60 | Return -1 if there is an error writing to the output file or if gz_init() |
| 69 | 61 | fails to allocate memory, otherwise 0. flush is assumed to be a valid |
| 70 | 62 | deflate() flush value. If flush is Z_FINISH, then the deflate() state is |
| 71 | 63 | reset to start a new gzip stream. If gz->direct is true, then simply write |
| 72 | 64 | to the output file without compressing, and ignore flush. */ |
| 73 | -local int gz_comp(state, flush) | |
| 74 | - gz_statep state; | |
| 75 | - int flush; | |
| 76 | -{ | |
| 65 | +local int gz_comp(gz_statep state, int flush) { | |
| 77 | 66 | int ret, writ; |
| 78 | 67 | unsigned have, put, max = ((unsigned)-1 >> 2) + 1; |
| 79 | 68 | z_streamp strm = &(state->strm); |
| 80 | 69 | |
| 81 | 70 | /* allocate memory if this is the first time through */ |
| @@ -149,14 +138,11 @@ | ||
| 149 | 138 | return 0; |
| 150 | 139 | } |
| 151 | 140 | |
| 152 | 141 | /* Compress len zeros to output. Return -1 on a write error or memory |
| 153 | 142 | allocation failure by gz_comp(), or 0 on success. */ |
| 154 | -local int gz_zero(state, len) | |
| 155 | - gz_statep state; | |
| 156 | - z_off64_t len; | |
| 157 | -{ | |
| 143 | +local int gz_zero(gz_statep state, z_off64_t len) { | |
| 158 | 144 | int first; |
| 159 | 145 | unsigned n; |
| 160 | 146 | z_streamp strm = &(state->strm); |
| 161 | 147 | |
| 162 | 148 | /* consume whatever's left in the input buffer */ |
| @@ -182,15 +168,11 @@ | ||
| 182 | 168 | return 0; |
| 183 | 169 | } |
| 184 | 170 | |
| 185 | 171 | /* Write len bytes from buf to file. Return the number of bytes written. If |
| 186 | 172 | the returned value is less than len, then there was an error. */ |
| 187 | -local z_size_t gz_write(state, buf, len) | |
| 188 | - gz_statep state; | |
| 189 | - voidpc buf; | |
| 190 | - z_size_t len; | |
| 191 | -{ | |
| 173 | +local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) { | |
| 192 | 174 | z_size_t put = len; |
| 193 | 175 | |
| 194 | 176 | /* if len is zero, avoid unnecessary operations */ |
| 195 | 177 | if (len == 0) |
| 196 | 178 | return 0; |
| @@ -250,15 +232,11 @@ | ||
| 250 | 232 | /* input was all buffered or compressed */ |
| 251 | 233 | return put; |
| 252 | 234 | } |
| 253 | 235 | |
| 254 | 236 | /* -- see zlib.h -- */ |
| 255 | -int ZEXPORT gzwrite(file, buf, len) | |
| 256 | - gzFile file; | |
| 257 | - voidpc buf; | |
| 258 | - unsigned len; | |
| 259 | -{ | |
| 237 | +int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) { | |
| 260 | 238 | gz_statep state; |
| 261 | 239 | |
| 262 | 240 | /* get internal structure */ |
| 263 | 241 | if (file == NULL) |
| 264 | 242 | return 0; |
| @@ -278,16 +256,12 @@ | ||
| 278 | 256 | /* write len bytes from buf (the return value will fit in an int) */ |
| 279 | 257 | return (int)gz_write(state, buf, len); |
| 280 | 258 | } |
| 281 | 259 | |
| 282 | 260 | /* -- see zlib.h -- */ |
| 283 | -z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) | |
| 284 | - voidpc buf; | |
| 285 | - z_size_t size; | |
| 286 | - z_size_t nitems; | |
| 287 | - gzFile file; | |
| 288 | -{ | |
| 261 | +z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems, | |
| 262 | + gzFile file) { | |
| 289 | 263 | z_size_t len; |
| 290 | 264 | gz_statep state; |
| 291 | 265 | |
| 292 | 266 | /* get internal structure */ |
| 293 | 267 | if (file == NULL) |
| @@ -308,14 +282,11 @@ | ||
| 308 | 282 | /* write len bytes to buf, return the number of full items written */ |
| 309 | 283 | return len ? gz_write(state, buf, len) / size : 0; |
| 310 | 284 | } |
| 311 | 285 | |
| 312 | 286 | /* -- see zlib.h -- */ |
| 313 | -int ZEXPORT gzputc(file, c) | |
| 314 | - gzFile file; | |
| 315 | - int c; | |
| 316 | -{ | |
| 287 | +int ZEXPORT gzputc(gzFile file, int c) { | |
| 317 | 288 | unsigned have; |
| 318 | 289 | unsigned char buf[1]; |
| 319 | 290 | gz_statep state; |
| 320 | 291 | z_streamp strm; |
| 321 | 292 | |
| @@ -356,14 +327,11 @@ | ||
| 356 | 327 | return -1; |
| 357 | 328 | return c & 0xff; |
| 358 | 329 | } |
| 359 | 330 | |
| 360 | 331 | /* -- see zlib.h -- */ |
| 361 | -int ZEXPORT gzputs(file, s) | |
| 362 | - gzFile file; | |
| 363 | - const char *s; | |
| 364 | -{ | |
| 332 | +int ZEXPORT gzputs(gzFile file, const char *s) { | |
| 365 | 333 | z_size_t len, put; |
| 366 | 334 | gz_statep state; |
| 367 | 335 | |
| 368 | 336 | /* get internal structure */ |
| 369 | 337 | if (file == NULL) |
| @@ -386,12 +354,11 @@ | ||
| 386 | 354 | |
| 387 | 355 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) |
| 388 | 356 | #include <stdarg.h> |
| 389 | 357 | |
| 390 | 358 | /* -- see zlib.h -- */ |
| 391 | -int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) | |
| 392 | -{ | |
| 359 | +int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) { | |
| 393 | 360 | int len; |
| 394 | 361 | unsigned left; |
| 395 | 362 | char *next; |
| 396 | 363 | gz_statep state; |
| 397 | 364 | z_streamp strm; |
| @@ -458,12 +425,11 @@ | ||
| 458 | 425 | strm->avail_in = left; |
| 459 | 426 | } |
| 460 | 427 | return len; |
| 461 | 428 | } |
| 462 | 429 | |
| 463 | -int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) | |
| 464 | -{ | |
| 430 | +int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) { | |
| 465 | 431 | va_list va; |
| 466 | 432 | int ret; |
| 467 | 433 | |
| 468 | 434 | va_start(va, format); |
| 469 | 435 | ret = gzvprintf(file, format, va); |
| @@ -472,17 +438,14 @@ | ||
| 472 | 438 | } |
| 473 | 439 | |
| 474 | 440 | #else /* !STDC && !Z_HAVE_STDARG_H */ |
| 475 | 441 | |
| 476 | 442 | /* -- see zlib.h -- */ |
| 477 | -int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, | |
| 478 | - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) | |
| 479 | - gzFile file; | |
| 480 | - const char *format; | |
| 481 | - int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, | |
| 482 | - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; | |
| 483 | -{ | |
| 443 | +int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3, | |
| 444 | + int a4, int a5, int a6, int a7, int a8, int a9, int a10, | |
| 445 | + int a11, int a12, int a13, int a14, int a15, int a16, | |
| 446 | + int a17, int a18, int a19, int a20) { | |
| 484 | 447 | unsigned len, left; |
| 485 | 448 | char *next; |
| 486 | 449 | gz_statep state; |
| 487 | 450 | z_streamp strm; |
| 488 | 451 | |
| @@ -560,14 +523,11 @@ | ||
| 560 | 523 | } |
| 561 | 524 | |
| 562 | 525 | #endif |
| 563 | 526 | |
| 564 | 527 | /* -- see zlib.h -- */ |
| 565 | -int ZEXPORT gzflush(file, flush) | |
| 566 | - gzFile file; | |
| 567 | - int flush; | |
| 568 | -{ | |
| 528 | +int ZEXPORT gzflush(gzFile file, int flush) { | |
| 569 | 529 | gz_statep state; |
| 570 | 530 | |
| 571 | 531 | /* get internal structure */ |
| 572 | 532 | if (file == NULL) |
| 573 | 533 | return Z_STREAM_ERROR; |
| @@ -592,15 +552,11 @@ | ||
| 592 | 552 | (void)gz_comp(state, flush); |
| 593 | 553 | return state->err; |
| 594 | 554 | } |
| 595 | 555 | |
| 596 | 556 | /* -- see zlib.h -- */ |
| 597 | -int ZEXPORT gzsetparams(file, level, strategy) | |
| 598 | - gzFile file; | |
| 599 | - int level; | |
| 600 | - int strategy; | |
| 601 | -{ | |
| 557 | +int ZEXPORT gzsetparams(gzFile file, int level, int strategy) { | |
| 602 | 558 | gz_statep state; |
| 603 | 559 | z_streamp strm; |
| 604 | 560 | |
| 605 | 561 | /* get internal structure */ |
| 606 | 562 | if (file == NULL) |
| @@ -607,11 +563,11 @@ | ||
| 607 | 563 | return Z_STREAM_ERROR; |
| 608 | 564 | state = (gz_statep)file; |
| 609 | 565 | strm = &(state->strm); |
| 610 | 566 | |
| 611 | 567 | /* check that we're writing and that there's no error */ |
| 612 | - if (state->mode != GZ_WRITE || state->err != Z_OK) | |
| 568 | + if (state->mode != GZ_WRITE || state->err != Z_OK || state->direct) | |
| 613 | 569 | return Z_STREAM_ERROR; |
| 614 | 570 | |
| 615 | 571 | /* if no change is requested, then do nothing */ |
| 616 | 572 | if (level == state->level && strategy == state->strategy) |
| 617 | 573 | return Z_OK; |
| @@ -634,13 +590,11 @@ | ||
| 634 | 590 | state->strategy = strategy; |
| 635 | 591 | return Z_OK; |
| 636 | 592 | } |
| 637 | 593 | |
| 638 | 594 | /* -- see zlib.h -- */ |
| 639 | -int ZEXPORT gzclose_w(file) | |
| 640 | - gzFile file; | |
| 641 | -{ | |
| 595 | +int ZEXPORT gzclose_w(gzFile file) { | |
| 642 | 596 | int ret = Z_OK; |
| 643 | 597 | gz_statep state; |
| 644 | 598 | |
| 645 | 599 | /* get internal structure */ |
| 646 | 600 | if (file == NULL) |
| 647 | 601 |
| --- compat/zlib/gzwrite.c | |
| +++ compat/zlib/gzwrite.c | |
| @@ -3,22 +3,14 @@ | |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ |
| 5 | |
| 6 | #include "gzguts.h" |
| 7 | |
| 8 | /* Local functions */ |
| 9 | local int gz_init OF((gz_statep)); |
| 10 | local int gz_comp OF((gz_statep, int)); |
| 11 | local int gz_zero OF((gz_statep, z_off64_t)); |
| 12 | local z_size_t gz_write OF((gz_statep, voidpc, z_size_t)); |
| 13 | |
| 14 | /* Initialize state for writing a gzip file. Mark initialization by setting |
| 15 | state->size to non-zero. Return -1 on a memory allocation failure, or 0 on |
| 16 | success. */ |
| 17 | local int gz_init(state) |
| 18 | gz_statep state; |
| 19 | { |
| 20 | int ret; |
| 21 | z_streamp strm = &(state->strm); |
| 22 | |
| 23 | /* allocate input buffer (double size for gzprintf) */ |
| 24 | state->in = (unsigned char *)malloc(state->want << 1); |
| @@ -68,14 +60,11 @@ | |
| 68 | Return -1 if there is an error writing to the output file or if gz_init() |
| 69 | fails to allocate memory, otherwise 0. flush is assumed to be a valid |
| 70 | deflate() flush value. If flush is Z_FINISH, then the deflate() state is |
| 71 | reset to start a new gzip stream. If gz->direct is true, then simply write |
| 72 | to the output file without compressing, and ignore flush. */ |
| 73 | local int gz_comp(state, flush) |
| 74 | gz_statep state; |
| 75 | int flush; |
| 76 | { |
| 77 | int ret, writ; |
| 78 | unsigned have, put, max = ((unsigned)-1 >> 2) + 1; |
| 79 | z_streamp strm = &(state->strm); |
| 80 | |
| 81 | /* allocate memory if this is the first time through */ |
| @@ -149,14 +138,11 @@ | |
| 149 | return 0; |
| 150 | } |
| 151 | |
| 152 | /* Compress len zeros to output. Return -1 on a write error or memory |
| 153 | allocation failure by gz_comp(), or 0 on success. */ |
| 154 | local int gz_zero(state, len) |
| 155 | gz_statep state; |
| 156 | z_off64_t len; |
| 157 | { |
| 158 | int first; |
| 159 | unsigned n; |
| 160 | z_streamp strm = &(state->strm); |
| 161 | |
| 162 | /* consume whatever's left in the input buffer */ |
| @@ -182,15 +168,11 @@ | |
| 182 | return 0; |
| 183 | } |
| 184 | |
| 185 | /* Write len bytes from buf to file. Return the number of bytes written. If |
| 186 | the returned value is less than len, then there was an error. */ |
| 187 | local z_size_t gz_write(state, buf, len) |
| 188 | gz_statep state; |
| 189 | voidpc buf; |
| 190 | z_size_t len; |
| 191 | { |
| 192 | z_size_t put = len; |
| 193 | |
| 194 | /* if len is zero, avoid unnecessary operations */ |
| 195 | if (len == 0) |
| 196 | return 0; |
| @@ -250,15 +232,11 @@ | |
| 250 | /* input was all buffered or compressed */ |
| 251 | return put; |
| 252 | } |
| 253 | |
| 254 | /* -- see zlib.h -- */ |
| 255 | int ZEXPORT gzwrite(file, buf, len) |
| 256 | gzFile file; |
| 257 | voidpc buf; |
| 258 | unsigned len; |
| 259 | { |
| 260 | gz_statep state; |
| 261 | |
| 262 | /* get internal structure */ |
| 263 | if (file == NULL) |
| 264 | return 0; |
| @@ -278,16 +256,12 @@ | |
| 278 | /* write len bytes from buf (the return value will fit in an int) */ |
| 279 | return (int)gz_write(state, buf, len); |
| 280 | } |
| 281 | |
| 282 | /* -- see zlib.h -- */ |
| 283 | z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) |
| 284 | voidpc buf; |
| 285 | z_size_t size; |
| 286 | z_size_t nitems; |
| 287 | gzFile file; |
| 288 | { |
| 289 | z_size_t len; |
| 290 | gz_statep state; |
| 291 | |
| 292 | /* get internal structure */ |
| 293 | if (file == NULL) |
| @@ -308,14 +282,11 @@ | |
| 308 | /* write len bytes to buf, return the number of full items written */ |
| 309 | return len ? gz_write(state, buf, len) / size : 0; |
| 310 | } |
| 311 | |
| 312 | /* -- see zlib.h -- */ |
| 313 | int ZEXPORT gzputc(file, c) |
| 314 | gzFile file; |
| 315 | int c; |
| 316 | { |
| 317 | unsigned have; |
| 318 | unsigned char buf[1]; |
| 319 | gz_statep state; |
| 320 | z_streamp strm; |
| 321 | |
| @@ -356,14 +327,11 @@ | |
| 356 | return -1; |
| 357 | return c & 0xff; |
| 358 | } |
| 359 | |
| 360 | /* -- see zlib.h -- */ |
| 361 | int ZEXPORT gzputs(file, s) |
| 362 | gzFile file; |
| 363 | const char *s; |
| 364 | { |
| 365 | z_size_t len, put; |
| 366 | gz_statep state; |
| 367 | |
| 368 | /* get internal structure */ |
| 369 | if (file == NULL) |
| @@ -386,12 +354,11 @@ | |
| 386 | |
| 387 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) |
| 388 | #include <stdarg.h> |
| 389 | |
| 390 | /* -- see zlib.h -- */ |
| 391 | int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) |
| 392 | { |
| 393 | int len; |
| 394 | unsigned left; |
| 395 | char *next; |
| 396 | gz_statep state; |
| 397 | z_streamp strm; |
| @@ -458,12 +425,11 @@ | |
| 458 | strm->avail_in = left; |
| 459 | } |
| 460 | return len; |
| 461 | } |
| 462 | |
| 463 | int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) |
| 464 | { |
| 465 | va_list va; |
| 466 | int ret; |
| 467 | |
| 468 | va_start(va, format); |
| 469 | ret = gzvprintf(file, format, va); |
| @@ -472,17 +438,14 @@ | |
| 472 | } |
| 473 | |
| 474 | #else /* !STDC && !Z_HAVE_STDARG_H */ |
| 475 | |
| 476 | /* -- see zlib.h -- */ |
| 477 | int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, |
| 478 | a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) |
| 479 | gzFile file; |
| 480 | const char *format; |
| 481 | int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, |
| 482 | a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; |
| 483 | { |
| 484 | unsigned len, left; |
| 485 | char *next; |
| 486 | gz_statep state; |
| 487 | z_streamp strm; |
| 488 | |
| @@ -560,14 +523,11 @@ | |
| 560 | } |
| 561 | |
| 562 | #endif |
| 563 | |
| 564 | /* -- see zlib.h -- */ |
| 565 | int ZEXPORT gzflush(file, flush) |
| 566 | gzFile file; |
| 567 | int flush; |
| 568 | { |
| 569 | gz_statep state; |
| 570 | |
| 571 | /* get internal structure */ |
| 572 | if (file == NULL) |
| 573 | return Z_STREAM_ERROR; |
| @@ -592,15 +552,11 @@ | |
| 592 | (void)gz_comp(state, flush); |
| 593 | return state->err; |
| 594 | } |
| 595 | |
| 596 | /* -- see zlib.h -- */ |
| 597 | int ZEXPORT gzsetparams(file, level, strategy) |
| 598 | gzFile file; |
| 599 | int level; |
| 600 | int strategy; |
| 601 | { |
| 602 | gz_statep state; |
| 603 | z_streamp strm; |
| 604 | |
| 605 | /* get internal structure */ |
| 606 | if (file == NULL) |
| @@ -607,11 +563,11 @@ | |
| 607 | return Z_STREAM_ERROR; |
| 608 | state = (gz_statep)file; |
| 609 | strm = &(state->strm); |
| 610 | |
| 611 | /* check that we're writing and that there's no error */ |
| 612 | if (state->mode != GZ_WRITE || state->err != Z_OK) |
| 613 | return Z_STREAM_ERROR; |
| 614 | |
| 615 | /* if no change is requested, then do nothing */ |
| 616 | if (level == state->level && strategy == state->strategy) |
| 617 | return Z_OK; |
| @@ -634,13 +590,11 @@ | |
| 634 | state->strategy = strategy; |
| 635 | return Z_OK; |
| 636 | } |
| 637 | |
| 638 | /* -- see zlib.h -- */ |
| 639 | int ZEXPORT gzclose_w(file) |
| 640 | gzFile file; |
| 641 | { |
| 642 | int ret = Z_OK; |
| 643 | gz_statep state; |
| 644 | |
| 645 | /* get internal structure */ |
| 646 | if (file == NULL) |
| 647 |
| --- compat/zlib/gzwrite.c | |
| +++ compat/zlib/gzwrite.c | |
| @@ -3,22 +3,14 @@ | |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ |
| 5 | |
| 6 | #include "gzguts.h" |
| 7 | |
| 8 | /* Initialize state for writing a gzip file. Mark initialization by setting |
| 9 | state->size to non-zero. Return -1 on a memory allocation failure, or 0 on |
| 10 | success. */ |
| 11 | local int gz_init(gz_statep state) { |
| 12 | int ret; |
| 13 | z_streamp strm = &(state->strm); |
| 14 | |
| 15 | /* allocate input buffer (double size for gzprintf) */ |
| 16 | state->in = (unsigned char *)malloc(state->want << 1); |
| @@ -68,14 +60,11 @@ | |
| 60 | Return -1 if there is an error writing to the output file or if gz_init() |
| 61 | fails to allocate memory, otherwise 0. flush is assumed to be a valid |
| 62 | deflate() flush value. If flush is Z_FINISH, then the deflate() state is |
| 63 | reset to start a new gzip stream. If gz->direct is true, then simply write |
| 64 | to the output file without compressing, and ignore flush. */ |
| 65 | local int gz_comp(gz_statep state, int flush) { |
| 66 | int ret, writ; |
| 67 | unsigned have, put, max = ((unsigned)-1 >> 2) + 1; |
| 68 | z_streamp strm = &(state->strm); |
| 69 | |
| 70 | /* allocate memory if this is the first time through */ |
| @@ -149,14 +138,11 @@ | |
| 138 | return 0; |
| 139 | } |
| 140 | |
| 141 | /* Compress len zeros to output. Return -1 on a write error or memory |
| 142 | allocation failure by gz_comp(), or 0 on success. */ |
| 143 | local int gz_zero(gz_statep state, z_off64_t len) { |
| 144 | int first; |
| 145 | unsigned n; |
| 146 | z_streamp strm = &(state->strm); |
| 147 | |
| 148 | /* consume whatever's left in the input buffer */ |
| @@ -182,15 +168,11 @@ | |
| 168 | return 0; |
| 169 | } |
| 170 | |
| 171 | /* Write len bytes from buf to file. Return the number of bytes written. If |
| 172 | the returned value is less than len, then there was an error. */ |
| 173 | local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) { |
| 174 | z_size_t put = len; |
| 175 | |
| 176 | /* if len is zero, avoid unnecessary operations */ |
| 177 | if (len == 0) |
| 178 | return 0; |
| @@ -250,15 +232,11 @@ | |
| 232 | /* input was all buffered or compressed */ |
| 233 | return put; |
| 234 | } |
| 235 | |
| 236 | /* -- see zlib.h -- */ |
| 237 | int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) { |
| 238 | gz_statep state; |
| 239 | |
| 240 | /* get internal structure */ |
| 241 | if (file == NULL) |
| 242 | return 0; |
| @@ -278,16 +256,12 @@ | |
| 256 | /* write len bytes from buf (the return value will fit in an int) */ |
| 257 | return (int)gz_write(state, buf, len); |
| 258 | } |
| 259 | |
| 260 | /* -- see zlib.h -- */ |
| 261 | z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems, |
| 262 | gzFile file) { |
| 263 | z_size_t len; |
| 264 | gz_statep state; |
| 265 | |
| 266 | /* get internal structure */ |
| 267 | if (file == NULL) |
| @@ -308,14 +282,11 @@ | |
| 282 | /* write len bytes to buf, return the number of full items written */ |
| 283 | return len ? gz_write(state, buf, len) / size : 0; |
| 284 | } |
| 285 | |
| 286 | /* -- see zlib.h -- */ |
| 287 | int ZEXPORT gzputc(gzFile file, int c) { |
| 288 | unsigned have; |
| 289 | unsigned char buf[1]; |
| 290 | gz_statep state; |
| 291 | z_streamp strm; |
| 292 | |
| @@ -356,14 +327,11 @@ | |
| 327 | return -1; |
| 328 | return c & 0xff; |
| 329 | } |
| 330 | |
| 331 | /* -- see zlib.h -- */ |
| 332 | int ZEXPORT gzputs(gzFile file, const char *s) { |
| 333 | z_size_t len, put; |
| 334 | gz_statep state; |
| 335 | |
| 336 | /* get internal structure */ |
| 337 | if (file == NULL) |
| @@ -386,12 +354,11 @@ | |
| 354 | |
| 355 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) |
| 356 | #include <stdarg.h> |
| 357 | |
| 358 | /* -- see zlib.h -- */ |
| 359 | int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) { |
| 360 | int len; |
| 361 | unsigned left; |
| 362 | char *next; |
| 363 | gz_statep state; |
| 364 | z_streamp strm; |
| @@ -458,12 +425,11 @@ | |
| 425 | strm->avail_in = left; |
| 426 | } |
| 427 | return len; |
| 428 | } |
| 429 | |
| 430 | int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) { |
| 431 | va_list va; |
| 432 | int ret; |
| 433 | |
| 434 | va_start(va, format); |
| 435 | ret = gzvprintf(file, format, va); |
| @@ -472,17 +438,14 @@ | |
| 438 | } |
| 439 | |
| 440 | #else /* !STDC && !Z_HAVE_STDARG_H */ |
| 441 | |
| 442 | /* -- see zlib.h -- */ |
| 443 | int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3, |
| 444 | int a4, int a5, int a6, int a7, int a8, int a9, int a10, |
| 445 | int a11, int a12, int a13, int a14, int a15, int a16, |
| 446 | int a17, int a18, int a19, int a20) { |
| 447 | unsigned len, left; |
| 448 | char *next; |
| 449 | gz_statep state; |
| 450 | z_streamp strm; |
| 451 | |
| @@ -560,14 +523,11 @@ | |
| 523 | } |
| 524 | |
| 525 | #endif |
| 526 | |
| 527 | /* -- see zlib.h -- */ |
| 528 | int ZEXPORT gzflush(gzFile file, int flush) { |
| 529 | gz_statep state; |
| 530 | |
| 531 | /* get internal structure */ |
| 532 | if (file == NULL) |
| 533 | return Z_STREAM_ERROR; |
| @@ -592,15 +552,11 @@ | |
| 552 | (void)gz_comp(state, flush); |
| 553 | return state->err; |
| 554 | } |
| 555 | |
| 556 | /* -- see zlib.h -- */ |
| 557 | int ZEXPORT gzsetparams(gzFile file, int level, int strategy) { |
| 558 | gz_statep state; |
| 559 | z_streamp strm; |
| 560 | |
| 561 | /* get internal structure */ |
| 562 | if (file == NULL) |
| @@ -607,11 +563,11 @@ | |
| 563 | return Z_STREAM_ERROR; |
| 564 | state = (gz_statep)file; |
| 565 | strm = &(state->strm); |
| 566 | |
| 567 | /* check that we're writing and that there's no error */ |
| 568 | if (state->mode != GZ_WRITE || state->err != Z_OK || state->direct) |
| 569 | return Z_STREAM_ERROR; |
| 570 | |
| 571 | /* if no change is requested, then do nothing */ |
| 572 | if (level == state->level && strategy == state->strategy) |
| 573 | return Z_OK; |
| @@ -634,13 +590,11 @@ | |
| 590 | state->strategy = strategy; |
| 591 | return Z_OK; |
| 592 | } |
| 593 | |
| 594 | /* -- see zlib.h -- */ |
| 595 | int ZEXPORT gzclose_w(gzFile file) { |
| 596 | int ret = Z_OK; |
| 597 | gz_statep state; |
| 598 | |
| 599 | /* get internal structure */ |
| 600 | if (file == NULL) |
| 601 |
+7
-23
| --- compat/zlib/infback.c | ||
| +++ compat/zlib/infback.c | ||
| @@ -13,27 +13,20 @@ | ||
| 13 | 13 | #include "zutil.h" |
| 14 | 14 | #include "inftrees.h" |
| 15 | 15 | #include "inflate.h" |
| 16 | 16 | #include "inffast.h" |
| 17 | 17 | |
| 18 | -/* function prototypes */ | |
| 19 | -local void fixedtables OF((struct inflate_state FAR *state)); | |
| 20 | - | |
| 21 | 18 | /* |
| 22 | 19 | strm provides memory allocation functions in zalloc and zfree, or |
| 23 | 20 | Z_NULL to use the library memory allocation functions. |
| 24 | 21 | |
| 25 | 22 | windowBits is in the range 8..15, and window is a user-supplied |
| 26 | 23 | window and output buffer that is 2**windowBits bytes. |
| 27 | 24 | */ |
| 28 | -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) | |
| 29 | -z_streamp strm; | |
| 30 | -int windowBits; | |
| 31 | -unsigned char FAR *window; | |
| 32 | -const char *version; | |
| 33 | -int stream_size; | |
| 34 | -{ | |
| 25 | +int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, | |
| 26 | + unsigned char FAR *window, const char *version, | |
| 27 | + int stream_size) { | |
| 35 | 28 | struct inflate_state FAR *state; |
| 36 | 29 | |
| 37 | 30 | if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || |
| 38 | 31 | stream_size != (int)(sizeof(z_stream))) |
| 39 | 32 | return Z_VERSION_ERROR; |
| @@ -78,13 +71,11 @@ | ||
| 78 | 71 | thereafter. This reduces the size of the code by about 2K bytes, in |
| 79 | 72 | exchange for a little execution time. However, BUILDFIXED should not be |
| 80 | 73 | used for threaded applications, since the rewriting of the tables and virgin |
| 81 | 74 | may not be thread-safe. |
| 82 | 75 | */ |
| 83 | -local void fixedtables(state) | |
| 84 | -struct inflate_state FAR *state; | |
| 85 | -{ | |
| 76 | +local void fixedtables(struct inflate_state FAR *state) { | |
| 86 | 77 | #ifdef BUILDFIXED |
| 87 | 78 | static int virgin = 1; |
| 88 | 79 | static code *lenfix, *distfix; |
| 89 | 80 | static code fixed[544]; |
| 90 | 81 | |
| @@ -246,17 +237,12 @@ | ||
| 246 | 237 | returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format |
| 247 | 238 | error, or Z_MEM_ERROR if it could not allocate memory for the state. |
| 248 | 239 | inflateBack() can also return Z_STREAM_ERROR if the input parameters |
| 249 | 240 | are not correct, i.e. strm is Z_NULL or the state was not initialized. |
| 250 | 241 | */ |
| 251 | -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) | |
| 252 | -z_streamp strm; | |
| 253 | -in_func in; | |
| 254 | -void FAR *in_desc; | |
| 255 | -out_func out; | |
| 256 | -void FAR *out_desc; | |
| 257 | -{ | |
| 242 | +int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, | |
| 243 | + out_func out, void FAR *out_desc) { | |
| 258 | 244 | struct inflate_state FAR *state; |
| 259 | 245 | z_const unsigned char FAR *next; /* next input */ |
| 260 | 246 | unsigned char FAR *put; /* next output */ |
| 261 | 247 | unsigned have, left; /* available input and output */ |
| 262 | 248 | unsigned long hold; /* bit buffer */ |
| @@ -630,15 +616,13 @@ | ||
| 630 | 616 | strm->next_in = next; |
| 631 | 617 | strm->avail_in = have; |
| 632 | 618 | return ret; |
| 633 | 619 | } |
| 634 | 620 | |
| 635 | -int ZEXPORT inflateBackEnd(strm) | |
| 636 | -z_streamp strm; | |
| 637 | -{ | |
| 621 | +int ZEXPORT inflateBackEnd(z_streamp strm) { | |
| 638 | 622 | if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) |
| 639 | 623 | return Z_STREAM_ERROR; |
| 640 | 624 | ZFREE(strm, strm->state); |
| 641 | 625 | strm->state = Z_NULL; |
| 642 | 626 | Tracev((stderr, "inflate: end\n")); |
| 643 | 627 | return Z_OK; |
| 644 | 628 | } |
| 645 | 629 |
| --- compat/zlib/infback.c | |
| +++ compat/zlib/infback.c | |
| @@ -13,27 +13,20 @@ | |
| 13 | #include "zutil.h" |
| 14 | #include "inftrees.h" |
| 15 | #include "inflate.h" |
| 16 | #include "inffast.h" |
| 17 | |
| 18 | /* function prototypes */ |
| 19 | local void fixedtables OF((struct inflate_state FAR *state)); |
| 20 | |
| 21 | /* |
| 22 | strm provides memory allocation functions in zalloc and zfree, or |
| 23 | Z_NULL to use the library memory allocation functions. |
| 24 | |
| 25 | windowBits is in the range 8..15, and window is a user-supplied |
| 26 | window and output buffer that is 2**windowBits bytes. |
| 27 | */ |
| 28 | int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) |
| 29 | z_streamp strm; |
| 30 | int windowBits; |
| 31 | unsigned char FAR *window; |
| 32 | const char *version; |
| 33 | int stream_size; |
| 34 | { |
| 35 | struct inflate_state FAR *state; |
| 36 | |
| 37 | if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || |
| 38 | stream_size != (int)(sizeof(z_stream))) |
| 39 | return Z_VERSION_ERROR; |
| @@ -78,13 +71,11 @@ | |
| 78 | thereafter. This reduces the size of the code by about 2K bytes, in |
| 79 | exchange for a little execution time. However, BUILDFIXED should not be |
| 80 | used for threaded applications, since the rewriting of the tables and virgin |
| 81 | may not be thread-safe. |
| 82 | */ |
| 83 | local void fixedtables(state) |
| 84 | struct inflate_state FAR *state; |
| 85 | { |
| 86 | #ifdef BUILDFIXED |
| 87 | static int virgin = 1; |
| 88 | static code *lenfix, *distfix; |
| 89 | static code fixed[544]; |
| 90 | |
| @@ -246,17 +237,12 @@ | |
| 246 | returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format |
| 247 | error, or Z_MEM_ERROR if it could not allocate memory for the state. |
| 248 | inflateBack() can also return Z_STREAM_ERROR if the input parameters |
| 249 | are not correct, i.e. strm is Z_NULL or the state was not initialized. |
| 250 | */ |
| 251 | int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) |
| 252 | z_streamp strm; |
| 253 | in_func in; |
| 254 | void FAR *in_desc; |
| 255 | out_func out; |
| 256 | void FAR *out_desc; |
| 257 | { |
| 258 | struct inflate_state FAR *state; |
| 259 | z_const unsigned char FAR *next; /* next input */ |
| 260 | unsigned char FAR *put; /* next output */ |
| 261 | unsigned have, left; /* available input and output */ |
| 262 | unsigned long hold; /* bit buffer */ |
| @@ -630,15 +616,13 @@ | |
| 630 | strm->next_in = next; |
| 631 | strm->avail_in = have; |
| 632 | return ret; |
| 633 | } |
| 634 | |
| 635 | int ZEXPORT inflateBackEnd(strm) |
| 636 | z_streamp strm; |
| 637 | { |
| 638 | if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) |
| 639 | return Z_STREAM_ERROR; |
| 640 | ZFREE(strm, strm->state); |
| 641 | strm->state = Z_NULL; |
| 642 | Tracev((stderr, "inflate: end\n")); |
| 643 | return Z_OK; |
| 644 | } |
| 645 |
| --- compat/zlib/infback.c | |
| +++ compat/zlib/infback.c | |
| @@ -13,27 +13,20 @@ | |
| 13 | #include "zutil.h" |
| 14 | #include "inftrees.h" |
| 15 | #include "inflate.h" |
| 16 | #include "inffast.h" |
| 17 | |
| 18 | /* |
| 19 | strm provides memory allocation functions in zalloc and zfree, or |
| 20 | Z_NULL to use the library memory allocation functions. |
| 21 | |
| 22 | windowBits is in the range 8..15, and window is a user-supplied |
| 23 | window and output buffer that is 2**windowBits bytes. |
| 24 | */ |
| 25 | int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, |
| 26 | unsigned char FAR *window, const char *version, |
| 27 | int stream_size) { |
| 28 | struct inflate_state FAR *state; |
| 29 | |
| 30 | if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || |
| 31 | stream_size != (int)(sizeof(z_stream))) |
| 32 | return Z_VERSION_ERROR; |
| @@ -78,13 +71,11 @@ | |
| 71 | thereafter. This reduces the size of the code by about 2K bytes, in |
| 72 | exchange for a little execution time. However, BUILDFIXED should not be |
| 73 | used for threaded applications, since the rewriting of the tables and virgin |
| 74 | may not be thread-safe. |
| 75 | */ |
| 76 | local void fixedtables(struct inflate_state FAR *state) { |
| 77 | #ifdef BUILDFIXED |
| 78 | static int virgin = 1; |
| 79 | static code *lenfix, *distfix; |
| 80 | static code fixed[544]; |
| 81 | |
| @@ -246,17 +237,12 @@ | |
| 237 | returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format |
| 238 | error, or Z_MEM_ERROR if it could not allocate memory for the state. |
| 239 | inflateBack() can also return Z_STREAM_ERROR if the input parameters |
| 240 | are not correct, i.e. strm is Z_NULL or the state was not initialized. |
| 241 | */ |
| 242 | int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, |
| 243 | out_func out, void FAR *out_desc) { |
| 244 | struct inflate_state FAR *state; |
| 245 | z_const unsigned char FAR *next; /* next input */ |
| 246 | unsigned char FAR *put; /* next output */ |
| 247 | unsigned have, left; /* available input and output */ |
| 248 | unsigned long hold; /* bit buffer */ |
| @@ -630,15 +616,13 @@ | |
| 616 | strm->next_in = next; |
| 617 | strm->avail_in = have; |
| 618 | return ret; |
| 619 | } |
| 620 | |
| 621 | int ZEXPORT inflateBackEnd(z_streamp strm) { |
| 622 | if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) |
| 623 | return Z_STREAM_ERROR; |
| 624 | ZFREE(strm, strm->state); |
| 625 | strm->state = Z_NULL; |
| 626 | Tracev((stderr, "inflate: end\n")); |
| 627 | return Z_OK; |
| 628 | } |
| 629 |
+1
-4
| --- compat/zlib/inffast.c | ||
| +++ compat/zlib/inffast.c | ||
| @@ -45,14 +45,11 @@ | ||
| 45 | 45 | - The maximum bytes that a single length/distance pair can output is 258 |
| 46 | 46 | bytes, which is the maximum length that can be coded. inflate_fast() |
| 47 | 47 | requires strm->avail_out >= 258 for each loop to avoid checking for |
| 48 | 48 | output space. |
| 49 | 49 | */ |
| 50 | -void ZLIB_INTERNAL inflate_fast(strm, start) | |
| 51 | -z_streamp strm; | |
| 52 | -unsigned start; /* inflate()'s starting value for strm->avail_out */ | |
| 53 | -{ | |
| 50 | +void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) { | |
| 54 | 51 | struct inflate_state FAR *state; |
| 55 | 52 | z_const unsigned char FAR *in; /* local strm->next_in */ |
| 56 | 53 | z_const unsigned char FAR *last; /* have enough input while in < last */ |
| 57 | 54 | unsigned char FAR *out; /* local strm->next_out */ |
| 58 | 55 | unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ |
| 59 | 56 |
| --- compat/zlib/inffast.c | |
| +++ compat/zlib/inffast.c | |
| @@ -45,14 +45,11 @@ | |
| 45 | - The maximum bytes that a single length/distance pair can output is 258 |
| 46 | bytes, which is the maximum length that can be coded. inflate_fast() |
| 47 | requires strm->avail_out >= 258 for each loop to avoid checking for |
| 48 | output space. |
| 49 | */ |
| 50 | void ZLIB_INTERNAL inflate_fast(strm, start) |
| 51 | z_streamp strm; |
| 52 | unsigned start; /* inflate()'s starting value for strm->avail_out */ |
| 53 | { |
| 54 | struct inflate_state FAR *state; |
| 55 | z_const unsigned char FAR *in; /* local strm->next_in */ |
| 56 | z_const unsigned char FAR *last; /* have enough input while in < last */ |
| 57 | unsigned char FAR *out; /* local strm->next_out */ |
| 58 | unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ |
| 59 |
| --- compat/zlib/inffast.c | |
| +++ compat/zlib/inffast.c | |
| @@ -45,14 +45,11 @@ | |
| 45 | - The maximum bytes that a single length/distance pair can output is 258 |
| 46 | bytes, which is the maximum length that can be coded. inflate_fast() |
| 47 | requires strm->avail_out >= 258 for each loop to avoid checking for |
| 48 | output space. |
| 49 | */ |
| 50 | void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) { |
| 51 | struct inflate_state FAR *state; |
| 52 | z_const unsigned char FAR *in; /* local strm->next_in */ |
| 53 | z_const unsigned char FAR *last; /* have enough input while in < last */ |
| 54 | unsigned char FAR *out; /* local strm->next_out */ |
| 55 | unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ |
| 56 |
+1
-1
| --- compat/zlib/inffast.h | ||
| +++ compat/zlib/inffast.h | ||
| @@ -6,6 +6,6 @@ | ||
| 6 | 6 | /* WARNING: this file should *not* be used by applications. It is |
| 7 | 7 | part of the implementation of the compression library and is |
| 8 | 8 | subject to change. Applications should only use zlib.h. |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); | |
| 11 | +void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start); | |
| 12 | 12 |
| --- compat/zlib/inffast.h | |
| +++ compat/zlib/inffast.h | |
| @@ -6,6 +6,6 @@ | |
| 6 | /* WARNING: this file should *not* be used by applications. It is |
| 7 | part of the implementation of the compression library and is |
| 8 | subject to change. Applications should only use zlib.h. |
| 9 | */ |
| 10 | |
| 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); |
| 12 |
| --- compat/zlib/inffast.h | |
| +++ compat/zlib/inffast.h | |
| @@ -6,6 +6,6 @@ | |
| 6 | /* WARNING: this file should *not* be used by applications. It is |
| 7 | part of the implementation of the compression library and is |
| 8 | subject to change. Applications should only use zlib.h. |
| 9 | */ |
| 10 | |
| 11 | void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start); |
| 12 |
+30
-99
| --- compat/zlib/inflate.c | ||
| +++ compat/zlib/inflate.c | ||
| @@ -89,24 +89,11 @@ | ||
| 89 | 89 | # ifndef BUILDFIXED |
| 90 | 90 | # define BUILDFIXED |
| 91 | 91 | # endif |
| 92 | 92 | #endif |
| 93 | 93 | |
| 94 | -/* function prototypes */ | |
| 95 | -local int inflateStateCheck OF((z_streamp strm)); | |
| 96 | -local void fixedtables OF((struct inflate_state FAR *state)); | |
| 97 | -local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, | |
| 98 | - unsigned copy)); | |
| 99 | -#ifdef BUILDFIXED | |
| 100 | - void makefixed OF((void)); | |
| 101 | -#endif | |
| 102 | -local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, | |
| 103 | - unsigned len)); | |
| 104 | - | |
| 105 | -local int inflateStateCheck(strm) | |
| 106 | -z_streamp strm; | |
| 107 | -{ | |
| 94 | +local int inflateStateCheck(z_streamp strm) { | |
| 108 | 95 | struct inflate_state FAR *state; |
| 109 | 96 | if (strm == Z_NULL || |
| 110 | 97 | strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) |
| 111 | 98 | return 1; |
| 112 | 99 | state = (struct inflate_state FAR *)strm->state; |
| @@ -114,13 +101,11 @@ | ||
| 114 | 101 | state->mode < HEAD || state->mode > SYNC) |
| 115 | 102 | return 1; |
| 116 | 103 | return 0; |
| 117 | 104 | } |
| 118 | 105 | |
| 119 | -int ZEXPORT inflateResetKeep(strm) | |
| 120 | -z_streamp strm; | |
| 121 | -{ | |
| 106 | +int ZEXPORT inflateResetKeep(z_streamp strm) { | |
| 122 | 107 | struct inflate_state FAR *state; |
| 123 | 108 | |
| 124 | 109 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 125 | 110 | state = (struct inflate_state FAR *)strm->state; |
| 126 | 111 | strm->total_in = strm->total_out = state->total = 0; |
| @@ -140,13 +125,11 @@ | ||
| 140 | 125 | state->back = -1; |
| 141 | 126 | Tracev((stderr, "inflate: reset\n")); |
| 142 | 127 | return Z_OK; |
| 143 | 128 | } |
| 144 | 129 | |
| 145 | -int ZEXPORT inflateReset(strm) | |
| 146 | -z_streamp strm; | |
| 147 | -{ | |
| 130 | +int ZEXPORT inflateReset(z_streamp strm) { | |
| 148 | 131 | struct inflate_state FAR *state; |
| 149 | 132 | |
| 150 | 133 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 151 | 134 | state = (struct inflate_state FAR *)strm->state; |
| 152 | 135 | state->wsize = 0; |
| @@ -153,14 +136,11 @@ | ||
| 153 | 136 | state->whave = 0; |
| 154 | 137 | state->wnext = 0; |
| 155 | 138 | return inflateResetKeep(strm); |
| 156 | 139 | } |
| 157 | 140 | |
| 158 | -int ZEXPORT inflateReset2(strm, windowBits) | |
| 159 | -z_streamp strm; | |
| 160 | -int windowBits; | |
| 161 | -{ | |
| 141 | +int ZEXPORT inflateReset2(z_streamp strm, int windowBits) { | |
| 162 | 142 | int wrap; |
| 163 | 143 | struct inflate_state FAR *state; |
| 164 | 144 | |
| 165 | 145 | /* get the state */ |
| 166 | 146 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| @@ -193,16 +173,12 @@ | ||
| 193 | 173 | state->wrap = wrap; |
| 194 | 174 | state->wbits = (unsigned)windowBits; |
| 195 | 175 | return inflateReset(strm); |
| 196 | 176 | } |
| 197 | 177 | |
| 198 | -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) | |
| 199 | -z_streamp strm; | |
| 200 | -int windowBits; | |
| 201 | -const char *version; | |
| 202 | -int stream_size; | |
| 203 | -{ | |
| 178 | +int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, | |
| 179 | + const char *version, int stream_size) { | |
| 204 | 180 | int ret; |
| 205 | 181 | struct inflate_state FAR *state; |
| 206 | 182 | |
| 207 | 183 | if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || |
| 208 | 184 | stream_size != (int)(sizeof(z_stream))) |
| @@ -237,26 +213,21 @@ | ||
| 237 | 213 | strm->state = Z_NULL; |
| 238 | 214 | } |
| 239 | 215 | return ret; |
| 240 | 216 | } |
| 241 | 217 | |
| 242 | -int ZEXPORT inflateInit_(strm, version, stream_size) | |
| 243 | -z_streamp strm; | |
| 244 | -const char *version; | |
| 245 | -int stream_size; | |
| 246 | -{ | |
| 218 | +int ZEXPORT inflateInit_(z_streamp strm, const char *version, | |
| 219 | + int stream_size) { | |
| 247 | 220 | return inflateInit2_(strm, DEF_WBITS, version, stream_size); |
| 248 | 221 | } |
| 249 | 222 | |
| 250 | -int ZEXPORT inflatePrime(strm, bits, value) | |
| 251 | -z_streamp strm; | |
| 252 | -int bits; | |
| 253 | -int value; | |
| 254 | -{ | |
| 223 | +int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) { | |
| 255 | 224 | struct inflate_state FAR *state; |
| 256 | 225 | |
| 257 | 226 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 227 | + if (bits == 0) | |
| 228 | + return Z_OK; | |
| 258 | 229 | state = (struct inflate_state FAR *)strm->state; |
| 259 | 230 | if (bits < 0) { |
| 260 | 231 | state->hold = 0; |
| 261 | 232 | state->bits = 0; |
| 262 | 233 | return Z_OK; |
| @@ -276,13 +247,11 @@ | ||
| 276 | 247 | thereafter. This reduces the size of the code by about 2K bytes, in |
| 277 | 248 | exchange for a little execution time. However, BUILDFIXED should not be |
| 278 | 249 | used for threaded applications, since the rewriting of the tables and virgin |
| 279 | 250 | may not be thread-safe. |
| 280 | 251 | */ |
| 281 | -local void fixedtables(state) | |
| 282 | -struct inflate_state FAR *state; | |
| 283 | -{ | |
| 252 | +local void fixedtables(struct inflate_state FAR *state) { | |
| 284 | 253 | #ifdef BUILDFIXED |
| 285 | 254 | static int virgin = 1; |
| 286 | 255 | static code *lenfix, *distfix; |
| 287 | 256 | static code fixed[544]; |
| 288 | 257 | |
| @@ -340,11 +309,11 @@ | ||
| 340 | 309 | |
| 341 | 310 | Then that can be linked with zlib built with MAKEFIXED defined and run: |
| 342 | 311 | |
| 343 | 312 | a.out > inffixed.h |
| 344 | 313 | */ |
| 345 | -void makefixed() | |
| 314 | +void makefixed(void) | |
| 346 | 315 | { |
| 347 | 316 | unsigned low, size; |
| 348 | 317 | struct inflate_state state; |
| 349 | 318 | |
| 350 | 319 | fixedtables(&state); |
| @@ -394,15 +363,11 @@ | ||
| 394 | 363 | advantage, since only the last 32K of output is copied to the sliding window |
| 395 | 364 | upon return from inflate(), and since all distances after the first 32K of |
| 396 | 365 | output will fall in the output data, making match copies simpler and faster. |
| 397 | 366 | The advantage may be dependent on the size of the processor's data caches. |
| 398 | 367 | */ |
| 399 | -local int updatewindow(strm, end, copy) | |
| 400 | -z_streamp strm; | |
| 401 | -const Bytef *end; | |
| 402 | -unsigned copy; | |
| 403 | -{ | |
| 368 | +local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) { | |
| 404 | 369 | struct inflate_state FAR *state; |
| 405 | 370 | unsigned dist; |
| 406 | 371 | |
| 407 | 372 | state = (struct inflate_state FAR *)strm->state; |
| 408 | 373 | |
| @@ -620,14 +585,11 @@ | ||
| 620 | 585 | stream available. So the only thing the flush parameter actually does is: |
| 621 | 586 | when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it |
| 622 | 587 | will return Z_BUF_ERROR if it has not reached the end of the stream. |
| 623 | 588 | */ |
| 624 | 589 | |
| 625 | -int ZEXPORT inflate(strm, flush) | |
| 626 | -z_streamp strm; | |
| 627 | -int flush; | |
| 628 | -{ | |
| 590 | +int ZEXPORT inflate(z_streamp strm, int flush) { | |
| 629 | 591 | struct inflate_state FAR *state; |
| 630 | 592 | z_const unsigned char FAR *next; /* next input */ |
| 631 | 593 | unsigned char FAR *put; /* next output */ |
| 632 | 594 | unsigned have, left; /* available input and output */ |
| 633 | 595 | unsigned long hold; /* bit buffer */ |
| @@ -1299,13 +1261,11 @@ | ||
| 1299 | 1261 | if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) |
| 1300 | 1262 | ret = Z_BUF_ERROR; |
| 1301 | 1263 | return ret; |
| 1302 | 1264 | } |
| 1303 | 1265 | |
| 1304 | -int ZEXPORT inflateEnd(strm) | |
| 1305 | -z_streamp strm; | |
| 1306 | -{ | |
| 1266 | +int ZEXPORT inflateEnd(z_streamp strm) { | |
| 1307 | 1267 | struct inflate_state FAR *state; |
| 1308 | 1268 | if (inflateStateCheck(strm)) |
| 1309 | 1269 | return Z_STREAM_ERROR; |
| 1310 | 1270 | state = (struct inflate_state FAR *)strm->state; |
| 1311 | 1271 | if (state->window != Z_NULL) ZFREE(strm, state->window); |
| @@ -1313,15 +1273,12 @@ | ||
| 1313 | 1273 | strm->state = Z_NULL; |
| 1314 | 1274 | Tracev((stderr, "inflate: end\n")); |
| 1315 | 1275 | return Z_OK; |
| 1316 | 1276 | } |
| 1317 | 1277 | |
| 1318 | -int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) | |
| 1319 | -z_streamp strm; | |
| 1320 | -Bytef *dictionary; | |
| 1321 | -uInt *dictLength; | |
| 1322 | -{ | |
| 1278 | +int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, | |
| 1279 | + uInt *dictLength) { | |
| 1323 | 1280 | struct inflate_state FAR *state; |
| 1324 | 1281 | |
| 1325 | 1282 | /* check state */ |
| 1326 | 1283 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1327 | 1284 | state = (struct inflate_state FAR *)strm->state; |
| @@ -1336,15 +1293,12 @@ | ||
| 1336 | 1293 | if (dictLength != Z_NULL) |
| 1337 | 1294 | *dictLength = state->whave; |
| 1338 | 1295 | return Z_OK; |
| 1339 | 1296 | } |
| 1340 | 1297 | |
| 1341 | -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) | |
| 1342 | -z_streamp strm; | |
| 1343 | -const Bytef *dictionary; | |
| 1344 | -uInt dictLength; | |
| 1345 | -{ | |
| 1298 | +int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, | |
| 1299 | + uInt dictLength) { | |
| 1346 | 1300 | struct inflate_state FAR *state; |
| 1347 | 1301 | unsigned long dictid; |
| 1348 | 1302 | int ret; |
| 1349 | 1303 | |
| 1350 | 1304 | /* check state */ |
| @@ -1371,14 +1325,11 @@ | ||
| 1371 | 1325 | state->havedict = 1; |
| 1372 | 1326 | Tracev((stderr, "inflate: dictionary set\n")); |
| 1373 | 1327 | return Z_OK; |
| 1374 | 1328 | } |
| 1375 | 1329 | |
| 1376 | -int ZEXPORT inflateGetHeader(strm, head) | |
| 1377 | -z_streamp strm; | |
| 1378 | -gz_headerp head; | |
| 1379 | -{ | |
| 1330 | +int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) { | |
| 1380 | 1331 | struct inflate_state FAR *state; |
| 1381 | 1332 | |
| 1382 | 1333 | /* check state */ |
| 1383 | 1334 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1384 | 1335 | state = (struct inflate_state FAR *)strm->state; |
| @@ -1399,15 +1350,12 @@ | ||
| 1399 | 1350 | pattern. If *have is less than four, then the pattern has not been found |
| 1400 | 1351 | yet and the return value is len. In the latter case, syncsearch() can be |
| 1401 | 1352 | called again with more data and the *have state. *have is initialized to |
| 1402 | 1353 | zero for the first call. |
| 1403 | 1354 | */ |
| 1404 | -local unsigned syncsearch(have, buf, len) | |
| 1405 | -unsigned FAR *have; | |
| 1406 | -const unsigned char FAR *buf; | |
| 1407 | -unsigned len; | |
| 1408 | -{ | |
| 1355 | +local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf, | |
| 1356 | + unsigned len) { | |
| 1409 | 1357 | unsigned got; |
| 1410 | 1358 | unsigned next; |
| 1411 | 1359 | |
| 1412 | 1360 | got = *have; |
| 1413 | 1361 | next = 0; |
| @@ -1422,13 +1370,11 @@ | ||
| 1422 | 1370 | } |
| 1423 | 1371 | *have = got; |
| 1424 | 1372 | return next; |
| 1425 | 1373 | } |
| 1426 | 1374 | |
| 1427 | -int ZEXPORT inflateSync(strm) | |
| 1428 | -z_streamp strm; | |
| 1429 | -{ | |
| 1375 | +int ZEXPORT inflateSync(z_streamp strm) { | |
| 1430 | 1376 | unsigned len; /* number of bytes to look at or looked at */ |
| 1431 | 1377 | int flags; /* temporary to save header status */ |
| 1432 | 1378 | unsigned long in, out; /* temporary to save total_in and total_out */ |
| 1433 | 1379 | unsigned char buf[4]; /* to restore bit buffer to byte string */ |
| 1434 | 1380 | struct inflate_state FAR *state; |
| @@ -1480,24 +1426,19 @@ | ||
| 1480 | 1426 | implementation to provide an additional safety check. PPP uses |
| 1481 | 1427 | Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored |
| 1482 | 1428 | block. When decompressing, PPP checks that at the end of input packet, |
| 1483 | 1429 | inflate is waiting for these length bytes. |
| 1484 | 1430 | */ |
| 1485 | -int ZEXPORT inflateSyncPoint(strm) | |
| 1486 | -z_streamp strm; | |
| 1487 | -{ | |
| 1431 | +int ZEXPORT inflateSyncPoint(z_streamp strm) { | |
| 1488 | 1432 | struct inflate_state FAR *state; |
| 1489 | 1433 | |
| 1490 | 1434 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1491 | 1435 | state = (struct inflate_state FAR *)strm->state; |
| 1492 | 1436 | return state->mode == STORED && state->bits == 0; |
| 1493 | 1437 | } |
| 1494 | 1438 | |
| 1495 | -int ZEXPORT inflateCopy(dest, source) | |
| 1496 | -z_streamp dest; | |
| 1497 | -z_streamp source; | |
| 1498 | -{ | |
| 1439 | +int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) { | |
| 1499 | 1440 | struct inflate_state FAR *state; |
| 1500 | 1441 | struct inflate_state FAR *copy; |
| 1501 | 1442 | unsigned char FAR *window; |
| 1502 | 1443 | unsigned wsize; |
| 1503 | 1444 | |
| @@ -1537,14 +1478,11 @@ | ||
| 1537 | 1478 | copy->window = window; |
| 1538 | 1479 | dest->state = (struct internal_state FAR *)copy; |
| 1539 | 1480 | return Z_OK; |
| 1540 | 1481 | } |
| 1541 | 1482 | |
| 1542 | -int ZEXPORT inflateUndermine(strm, subvert) | |
| 1543 | -z_streamp strm; | |
| 1544 | -int subvert; | |
| 1545 | -{ | |
| 1483 | +int ZEXPORT inflateUndermine(z_streamp strm, int subvert) { | |
| 1546 | 1484 | struct inflate_state FAR *state; |
| 1547 | 1485 | |
| 1548 | 1486 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1549 | 1487 | state = (struct inflate_state FAR *)strm->state; |
| 1550 | 1488 | #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR |
| @@ -1555,14 +1493,11 @@ | ||
| 1555 | 1493 | state->sane = 1; |
| 1556 | 1494 | return Z_DATA_ERROR; |
| 1557 | 1495 | #endif |
| 1558 | 1496 | } |
| 1559 | 1497 | |
| 1560 | -int ZEXPORT inflateValidate(strm, check) | |
| 1561 | -z_streamp strm; | |
| 1562 | -int check; | |
| 1563 | -{ | |
| 1498 | +int ZEXPORT inflateValidate(z_streamp strm, int check) { | |
| 1564 | 1499 | struct inflate_state FAR *state; |
| 1565 | 1500 | |
| 1566 | 1501 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1567 | 1502 | state = (struct inflate_state FAR *)strm->state; |
| 1568 | 1503 | if (check && state->wrap) |
| @@ -1570,13 +1505,11 @@ | ||
| 1570 | 1505 | else |
| 1571 | 1506 | state->wrap &= ~4; |
| 1572 | 1507 | return Z_OK; |
| 1573 | 1508 | } |
| 1574 | 1509 | |
| 1575 | -long ZEXPORT inflateMark(strm) | |
| 1576 | -z_streamp strm; | |
| 1577 | -{ | |
| 1510 | +long ZEXPORT inflateMark(z_streamp strm) { | |
| 1578 | 1511 | struct inflate_state FAR *state; |
| 1579 | 1512 | |
| 1580 | 1513 | if (inflateStateCheck(strm)) |
| 1581 | 1514 | return -(1L << 16); |
| 1582 | 1515 | state = (struct inflate_state FAR *)strm->state; |
| @@ -1583,13 +1516,11 @@ | ||
| 1583 | 1516 | return (long)(((unsigned long)((long)state->back)) << 16) + |
| 1584 | 1517 | (state->mode == COPY ? state->length : |
| 1585 | 1518 | (state->mode == MATCH ? state->was - state->length : 0)); |
| 1586 | 1519 | } |
| 1587 | 1520 | |
| 1588 | -unsigned long ZEXPORT inflateCodesUsed(strm) | |
| 1589 | -z_streamp strm; | |
| 1590 | -{ | |
| 1521 | +unsigned long ZEXPORT inflateCodesUsed(z_streamp strm) { | |
| 1591 | 1522 | struct inflate_state FAR *state; |
| 1592 | 1523 | if (inflateStateCheck(strm)) return (unsigned long)-1; |
| 1593 | 1524 | state = (struct inflate_state FAR *)strm->state; |
| 1594 | 1525 | return (unsigned long)(state->next - state->codes); |
| 1595 | 1526 | } |
| 1596 | 1527 |
| --- compat/zlib/inflate.c | |
| +++ compat/zlib/inflate.c | |
| @@ -89,24 +89,11 @@ | |
| 89 | # ifndef BUILDFIXED |
| 90 | # define BUILDFIXED |
| 91 | # endif |
| 92 | #endif |
| 93 | |
| 94 | /* function prototypes */ |
| 95 | local int inflateStateCheck OF((z_streamp strm)); |
| 96 | local void fixedtables OF((struct inflate_state FAR *state)); |
| 97 | local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, |
| 98 | unsigned copy)); |
| 99 | #ifdef BUILDFIXED |
| 100 | void makefixed OF((void)); |
| 101 | #endif |
| 102 | local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, |
| 103 | unsigned len)); |
| 104 | |
| 105 | local int inflateStateCheck(strm) |
| 106 | z_streamp strm; |
| 107 | { |
| 108 | struct inflate_state FAR *state; |
| 109 | if (strm == Z_NULL || |
| 110 | strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) |
| 111 | return 1; |
| 112 | state = (struct inflate_state FAR *)strm->state; |
| @@ -114,13 +101,11 @@ | |
| 114 | state->mode < HEAD || state->mode > SYNC) |
| 115 | return 1; |
| 116 | return 0; |
| 117 | } |
| 118 | |
| 119 | int ZEXPORT inflateResetKeep(strm) |
| 120 | z_streamp strm; |
| 121 | { |
| 122 | struct inflate_state FAR *state; |
| 123 | |
| 124 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 125 | state = (struct inflate_state FAR *)strm->state; |
| 126 | strm->total_in = strm->total_out = state->total = 0; |
| @@ -140,13 +125,11 @@ | |
| 140 | state->back = -1; |
| 141 | Tracev((stderr, "inflate: reset\n")); |
| 142 | return Z_OK; |
| 143 | } |
| 144 | |
| 145 | int ZEXPORT inflateReset(strm) |
| 146 | z_streamp strm; |
| 147 | { |
| 148 | struct inflate_state FAR *state; |
| 149 | |
| 150 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 151 | state = (struct inflate_state FAR *)strm->state; |
| 152 | state->wsize = 0; |
| @@ -153,14 +136,11 @@ | |
| 153 | state->whave = 0; |
| 154 | state->wnext = 0; |
| 155 | return inflateResetKeep(strm); |
| 156 | } |
| 157 | |
| 158 | int ZEXPORT inflateReset2(strm, windowBits) |
| 159 | z_streamp strm; |
| 160 | int windowBits; |
| 161 | { |
| 162 | int wrap; |
| 163 | struct inflate_state FAR *state; |
| 164 | |
| 165 | /* get the state */ |
| 166 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| @@ -193,16 +173,12 @@ | |
| 193 | state->wrap = wrap; |
| 194 | state->wbits = (unsigned)windowBits; |
| 195 | return inflateReset(strm); |
| 196 | } |
| 197 | |
| 198 | int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) |
| 199 | z_streamp strm; |
| 200 | int windowBits; |
| 201 | const char *version; |
| 202 | int stream_size; |
| 203 | { |
| 204 | int ret; |
| 205 | struct inflate_state FAR *state; |
| 206 | |
| 207 | if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || |
| 208 | stream_size != (int)(sizeof(z_stream))) |
| @@ -237,26 +213,21 @@ | |
| 237 | strm->state = Z_NULL; |
| 238 | } |
| 239 | return ret; |
| 240 | } |
| 241 | |
| 242 | int ZEXPORT inflateInit_(strm, version, stream_size) |
| 243 | z_streamp strm; |
| 244 | const char *version; |
| 245 | int stream_size; |
| 246 | { |
| 247 | return inflateInit2_(strm, DEF_WBITS, version, stream_size); |
| 248 | } |
| 249 | |
| 250 | int ZEXPORT inflatePrime(strm, bits, value) |
| 251 | z_streamp strm; |
| 252 | int bits; |
| 253 | int value; |
| 254 | { |
| 255 | struct inflate_state FAR *state; |
| 256 | |
| 257 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 258 | state = (struct inflate_state FAR *)strm->state; |
| 259 | if (bits < 0) { |
| 260 | state->hold = 0; |
| 261 | state->bits = 0; |
| 262 | return Z_OK; |
| @@ -276,13 +247,11 @@ | |
| 276 | thereafter. This reduces the size of the code by about 2K bytes, in |
| 277 | exchange for a little execution time. However, BUILDFIXED should not be |
| 278 | used for threaded applications, since the rewriting of the tables and virgin |
| 279 | may not be thread-safe. |
| 280 | */ |
| 281 | local void fixedtables(state) |
| 282 | struct inflate_state FAR *state; |
| 283 | { |
| 284 | #ifdef BUILDFIXED |
| 285 | static int virgin = 1; |
| 286 | static code *lenfix, *distfix; |
| 287 | static code fixed[544]; |
| 288 | |
| @@ -340,11 +309,11 @@ | |
| 340 | |
| 341 | Then that can be linked with zlib built with MAKEFIXED defined and run: |
| 342 | |
| 343 | a.out > inffixed.h |
| 344 | */ |
| 345 | void makefixed() |
| 346 | { |
| 347 | unsigned low, size; |
| 348 | struct inflate_state state; |
| 349 | |
| 350 | fixedtables(&state); |
| @@ -394,15 +363,11 @@ | |
| 394 | advantage, since only the last 32K of output is copied to the sliding window |
| 395 | upon return from inflate(), and since all distances after the first 32K of |
| 396 | output will fall in the output data, making match copies simpler and faster. |
| 397 | The advantage may be dependent on the size of the processor's data caches. |
| 398 | */ |
| 399 | local int updatewindow(strm, end, copy) |
| 400 | z_streamp strm; |
| 401 | const Bytef *end; |
| 402 | unsigned copy; |
| 403 | { |
| 404 | struct inflate_state FAR *state; |
| 405 | unsigned dist; |
| 406 | |
| 407 | state = (struct inflate_state FAR *)strm->state; |
| 408 | |
| @@ -620,14 +585,11 @@ | |
| 620 | stream available. So the only thing the flush parameter actually does is: |
| 621 | when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it |
| 622 | will return Z_BUF_ERROR if it has not reached the end of the stream. |
| 623 | */ |
| 624 | |
| 625 | int ZEXPORT inflate(strm, flush) |
| 626 | z_streamp strm; |
| 627 | int flush; |
| 628 | { |
| 629 | struct inflate_state FAR *state; |
| 630 | z_const unsigned char FAR *next; /* next input */ |
| 631 | unsigned char FAR *put; /* next output */ |
| 632 | unsigned have, left; /* available input and output */ |
| 633 | unsigned long hold; /* bit buffer */ |
| @@ -1299,13 +1261,11 @@ | |
| 1299 | if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) |
| 1300 | ret = Z_BUF_ERROR; |
| 1301 | return ret; |
| 1302 | } |
| 1303 | |
| 1304 | int ZEXPORT inflateEnd(strm) |
| 1305 | z_streamp strm; |
| 1306 | { |
| 1307 | struct inflate_state FAR *state; |
| 1308 | if (inflateStateCheck(strm)) |
| 1309 | return Z_STREAM_ERROR; |
| 1310 | state = (struct inflate_state FAR *)strm->state; |
| 1311 | if (state->window != Z_NULL) ZFREE(strm, state->window); |
| @@ -1313,15 +1273,12 @@ | |
| 1313 | strm->state = Z_NULL; |
| 1314 | Tracev((stderr, "inflate: end\n")); |
| 1315 | return Z_OK; |
| 1316 | } |
| 1317 | |
| 1318 | int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) |
| 1319 | z_streamp strm; |
| 1320 | Bytef *dictionary; |
| 1321 | uInt *dictLength; |
| 1322 | { |
| 1323 | struct inflate_state FAR *state; |
| 1324 | |
| 1325 | /* check state */ |
| 1326 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1327 | state = (struct inflate_state FAR *)strm->state; |
| @@ -1336,15 +1293,12 @@ | |
| 1336 | if (dictLength != Z_NULL) |
| 1337 | *dictLength = state->whave; |
| 1338 | return Z_OK; |
| 1339 | } |
| 1340 | |
| 1341 | int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) |
| 1342 | z_streamp strm; |
| 1343 | const Bytef *dictionary; |
| 1344 | uInt dictLength; |
| 1345 | { |
| 1346 | struct inflate_state FAR *state; |
| 1347 | unsigned long dictid; |
| 1348 | int ret; |
| 1349 | |
| 1350 | /* check state */ |
| @@ -1371,14 +1325,11 @@ | |
| 1371 | state->havedict = 1; |
| 1372 | Tracev((stderr, "inflate: dictionary set\n")); |
| 1373 | return Z_OK; |
| 1374 | } |
| 1375 | |
| 1376 | int ZEXPORT inflateGetHeader(strm, head) |
| 1377 | z_streamp strm; |
| 1378 | gz_headerp head; |
| 1379 | { |
| 1380 | struct inflate_state FAR *state; |
| 1381 | |
| 1382 | /* check state */ |
| 1383 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1384 | state = (struct inflate_state FAR *)strm->state; |
| @@ -1399,15 +1350,12 @@ | |
| 1399 | pattern. If *have is less than four, then the pattern has not been found |
| 1400 | yet and the return value is len. In the latter case, syncsearch() can be |
| 1401 | called again with more data and the *have state. *have is initialized to |
| 1402 | zero for the first call. |
| 1403 | */ |
| 1404 | local unsigned syncsearch(have, buf, len) |
| 1405 | unsigned FAR *have; |
| 1406 | const unsigned char FAR *buf; |
| 1407 | unsigned len; |
| 1408 | { |
| 1409 | unsigned got; |
| 1410 | unsigned next; |
| 1411 | |
| 1412 | got = *have; |
| 1413 | next = 0; |
| @@ -1422,13 +1370,11 @@ | |
| 1422 | } |
| 1423 | *have = got; |
| 1424 | return next; |
| 1425 | } |
| 1426 | |
| 1427 | int ZEXPORT inflateSync(strm) |
| 1428 | z_streamp strm; |
| 1429 | { |
| 1430 | unsigned len; /* number of bytes to look at or looked at */ |
| 1431 | int flags; /* temporary to save header status */ |
| 1432 | unsigned long in, out; /* temporary to save total_in and total_out */ |
| 1433 | unsigned char buf[4]; /* to restore bit buffer to byte string */ |
| 1434 | struct inflate_state FAR *state; |
| @@ -1480,24 +1426,19 @@ | |
| 1480 | implementation to provide an additional safety check. PPP uses |
| 1481 | Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored |
| 1482 | block. When decompressing, PPP checks that at the end of input packet, |
| 1483 | inflate is waiting for these length bytes. |
| 1484 | */ |
| 1485 | int ZEXPORT inflateSyncPoint(strm) |
| 1486 | z_streamp strm; |
| 1487 | { |
| 1488 | struct inflate_state FAR *state; |
| 1489 | |
| 1490 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1491 | state = (struct inflate_state FAR *)strm->state; |
| 1492 | return state->mode == STORED && state->bits == 0; |
| 1493 | } |
| 1494 | |
| 1495 | int ZEXPORT inflateCopy(dest, source) |
| 1496 | z_streamp dest; |
| 1497 | z_streamp source; |
| 1498 | { |
| 1499 | struct inflate_state FAR *state; |
| 1500 | struct inflate_state FAR *copy; |
| 1501 | unsigned char FAR *window; |
| 1502 | unsigned wsize; |
| 1503 | |
| @@ -1537,14 +1478,11 @@ | |
| 1537 | copy->window = window; |
| 1538 | dest->state = (struct internal_state FAR *)copy; |
| 1539 | return Z_OK; |
| 1540 | } |
| 1541 | |
| 1542 | int ZEXPORT inflateUndermine(strm, subvert) |
| 1543 | z_streamp strm; |
| 1544 | int subvert; |
| 1545 | { |
| 1546 | struct inflate_state FAR *state; |
| 1547 | |
| 1548 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1549 | state = (struct inflate_state FAR *)strm->state; |
| 1550 | #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR |
| @@ -1555,14 +1493,11 @@ | |
| 1555 | state->sane = 1; |
| 1556 | return Z_DATA_ERROR; |
| 1557 | #endif |
| 1558 | } |
| 1559 | |
| 1560 | int ZEXPORT inflateValidate(strm, check) |
| 1561 | z_streamp strm; |
| 1562 | int check; |
| 1563 | { |
| 1564 | struct inflate_state FAR *state; |
| 1565 | |
| 1566 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1567 | state = (struct inflate_state FAR *)strm->state; |
| 1568 | if (check && state->wrap) |
| @@ -1570,13 +1505,11 @@ | |
| 1570 | else |
| 1571 | state->wrap &= ~4; |
| 1572 | return Z_OK; |
| 1573 | } |
| 1574 | |
| 1575 | long ZEXPORT inflateMark(strm) |
| 1576 | z_streamp strm; |
| 1577 | { |
| 1578 | struct inflate_state FAR *state; |
| 1579 | |
| 1580 | if (inflateStateCheck(strm)) |
| 1581 | return -(1L << 16); |
| 1582 | state = (struct inflate_state FAR *)strm->state; |
| @@ -1583,13 +1516,11 @@ | |
| 1583 | return (long)(((unsigned long)((long)state->back)) << 16) + |
| 1584 | (state->mode == COPY ? state->length : |
| 1585 | (state->mode == MATCH ? state->was - state->length : 0)); |
| 1586 | } |
| 1587 | |
| 1588 | unsigned long ZEXPORT inflateCodesUsed(strm) |
| 1589 | z_streamp strm; |
| 1590 | { |
| 1591 | struct inflate_state FAR *state; |
| 1592 | if (inflateStateCheck(strm)) return (unsigned long)-1; |
| 1593 | state = (struct inflate_state FAR *)strm->state; |
| 1594 | return (unsigned long)(state->next - state->codes); |
| 1595 | } |
| 1596 |
| --- compat/zlib/inflate.c | |
| +++ compat/zlib/inflate.c | |
| @@ -89,24 +89,11 @@ | |
| 89 | # ifndef BUILDFIXED |
| 90 | # define BUILDFIXED |
| 91 | # endif |
| 92 | #endif |
| 93 | |
| 94 | local int inflateStateCheck(z_streamp strm) { |
| 95 | struct inflate_state FAR *state; |
| 96 | if (strm == Z_NULL || |
| 97 | strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) |
| 98 | return 1; |
| 99 | state = (struct inflate_state FAR *)strm->state; |
| @@ -114,13 +101,11 @@ | |
| 101 | state->mode < HEAD || state->mode > SYNC) |
| 102 | return 1; |
| 103 | return 0; |
| 104 | } |
| 105 | |
| 106 | int ZEXPORT inflateResetKeep(z_streamp strm) { |
| 107 | struct inflate_state FAR *state; |
| 108 | |
| 109 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 110 | state = (struct inflate_state FAR *)strm->state; |
| 111 | strm->total_in = strm->total_out = state->total = 0; |
| @@ -140,13 +125,11 @@ | |
| 125 | state->back = -1; |
| 126 | Tracev((stderr, "inflate: reset\n")); |
| 127 | return Z_OK; |
| 128 | } |
| 129 | |
| 130 | int ZEXPORT inflateReset(z_streamp strm) { |
| 131 | struct inflate_state FAR *state; |
| 132 | |
| 133 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 134 | state = (struct inflate_state FAR *)strm->state; |
| 135 | state->wsize = 0; |
| @@ -153,14 +136,11 @@ | |
| 136 | state->whave = 0; |
| 137 | state->wnext = 0; |
| 138 | return inflateResetKeep(strm); |
| 139 | } |
| 140 | |
| 141 | int ZEXPORT inflateReset2(z_streamp strm, int windowBits) { |
| 142 | int wrap; |
| 143 | struct inflate_state FAR *state; |
| 144 | |
| 145 | /* get the state */ |
| 146 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| @@ -193,16 +173,12 @@ | |
| 173 | state->wrap = wrap; |
| 174 | state->wbits = (unsigned)windowBits; |
| 175 | return inflateReset(strm); |
| 176 | } |
| 177 | |
| 178 | int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, |
| 179 | const char *version, int stream_size) { |
| 180 | int ret; |
| 181 | struct inflate_state FAR *state; |
| 182 | |
| 183 | if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || |
| 184 | stream_size != (int)(sizeof(z_stream))) |
| @@ -237,26 +213,21 @@ | |
| 213 | strm->state = Z_NULL; |
| 214 | } |
| 215 | return ret; |
| 216 | } |
| 217 | |
| 218 | int ZEXPORT inflateInit_(z_streamp strm, const char *version, |
| 219 | int stream_size) { |
| 220 | return inflateInit2_(strm, DEF_WBITS, version, stream_size); |
| 221 | } |
| 222 | |
| 223 | int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) { |
| 224 | struct inflate_state FAR *state; |
| 225 | |
| 226 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 227 | if (bits == 0) |
| 228 | return Z_OK; |
| 229 | state = (struct inflate_state FAR *)strm->state; |
| 230 | if (bits < 0) { |
| 231 | state->hold = 0; |
| 232 | state->bits = 0; |
| 233 | return Z_OK; |
| @@ -276,13 +247,11 @@ | |
| 247 | thereafter. This reduces the size of the code by about 2K bytes, in |
| 248 | exchange for a little execution time. However, BUILDFIXED should not be |
| 249 | used for threaded applications, since the rewriting of the tables and virgin |
| 250 | may not be thread-safe. |
| 251 | */ |
| 252 | local void fixedtables(struct inflate_state FAR *state) { |
| 253 | #ifdef BUILDFIXED |
| 254 | static int virgin = 1; |
| 255 | static code *lenfix, *distfix; |
| 256 | static code fixed[544]; |
| 257 | |
| @@ -340,11 +309,11 @@ | |
| 309 | |
| 310 | Then that can be linked with zlib built with MAKEFIXED defined and run: |
| 311 | |
| 312 | a.out > inffixed.h |
| 313 | */ |
| 314 | void makefixed(void) |
| 315 | { |
| 316 | unsigned low, size; |
| 317 | struct inflate_state state; |
| 318 | |
| 319 | fixedtables(&state); |
| @@ -394,15 +363,11 @@ | |
| 363 | advantage, since only the last 32K of output is copied to the sliding window |
| 364 | upon return from inflate(), and since all distances after the first 32K of |
| 365 | output will fall in the output data, making match copies simpler and faster. |
| 366 | The advantage may be dependent on the size of the processor's data caches. |
| 367 | */ |
| 368 | local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) { |
| 369 | struct inflate_state FAR *state; |
| 370 | unsigned dist; |
| 371 | |
| 372 | state = (struct inflate_state FAR *)strm->state; |
| 373 | |
| @@ -620,14 +585,11 @@ | |
| 585 | stream available. So the only thing the flush parameter actually does is: |
| 586 | when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it |
| 587 | will return Z_BUF_ERROR if it has not reached the end of the stream. |
| 588 | */ |
| 589 | |
| 590 | int ZEXPORT inflate(z_streamp strm, int flush) { |
| 591 | struct inflate_state FAR *state; |
| 592 | z_const unsigned char FAR *next; /* next input */ |
| 593 | unsigned char FAR *put; /* next output */ |
| 594 | unsigned have, left; /* available input and output */ |
| 595 | unsigned long hold; /* bit buffer */ |
| @@ -1299,13 +1261,11 @@ | |
| 1261 | if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) |
| 1262 | ret = Z_BUF_ERROR; |
| 1263 | return ret; |
| 1264 | } |
| 1265 | |
| 1266 | int ZEXPORT inflateEnd(z_streamp strm) { |
| 1267 | struct inflate_state FAR *state; |
| 1268 | if (inflateStateCheck(strm)) |
| 1269 | return Z_STREAM_ERROR; |
| 1270 | state = (struct inflate_state FAR *)strm->state; |
| 1271 | if (state->window != Z_NULL) ZFREE(strm, state->window); |
| @@ -1313,15 +1273,12 @@ | |
| 1273 | strm->state = Z_NULL; |
| 1274 | Tracev((stderr, "inflate: end\n")); |
| 1275 | return Z_OK; |
| 1276 | } |
| 1277 | |
| 1278 | int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, |
| 1279 | uInt *dictLength) { |
| 1280 | struct inflate_state FAR *state; |
| 1281 | |
| 1282 | /* check state */ |
| 1283 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1284 | state = (struct inflate_state FAR *)strm->state; |
| @@ -1336,15 +1293,12 @@ | |
| 1293 | if (dictLength != Z_NULL) |
| 1294 | *dictLength = state->whave; |
| 1295 | return Z_OK; |
| 1296 | } |
| 1297 | |
| 1298 | int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, |
| 1299 | uInt dictLength) { |
| 1300 | struct inflate_state FAR *state; |
| 1301 | unsigned long dictid; |
| 1302 | int ret; |
| 1303 | |
| 1304 | /* check state */ |
| @@ -1371,14 +1325,11 @@ | |
| 1325 | state->havedict = 1; |
| 1326 | Tracev((stderr, "inflate: dictionary set\n")); |
| 1327 | return Z_OK; |
| 1328 | } |
| 1329 | |
| 1330 | int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) { |
| 1331 | struct inflate_state FAR *state; |
| 1332 | |
| 1333 | /* check state */ |
| 1334 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1335 | state = (struct inflate_state FAR *)strm->state; |
| @@ -1399,15 +1350,12 @@ | |
| 1350 | pattern. If *have is less than four, then the pattern has not been found |
| 1351 | yet and the return value is len. In the latter case, syncsearch() can be |
| 1352 | called again with more data and the *have state. *have is initialized to |
| 1353 | zero for the first call. |
| 1354 | */ |
| 1355 | local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf, |
| 1356 | unsigned len) { |
| 1357 | unsigned got; |
| 1358 | unsigned next; |
| 1359 | |
| 1360 | got = *have; |
| 1361 | next = 0; |
| @@ -1422,13 +1370,11 @@ | |
| 1370 | } |
| 1371 | *have = got; |
| 1372 | return next; |
| 1373 | } |
| 1374 | |
| 1375 | int ZEXPORT inflateSync(z_streamp strm) { |
| 1376 | unsigned len; /* number of bytes to look at or looked at */ |
| 1377 | int flags; /* temporary to save header status */ |
| 1378 | unsigned long in, out; /* temporary to save total_in and total_out */ |
| 1379 | unsigned char buf[4]; /* to restore bit buffer to byte string */ |
| 1380 | struct inflate_state FAR *state; |
| @@ -1480,24 +1426,19 @@ | |
| 1426 | implementation to provide an additional safety check. PPP uses |
| 1427 | Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored |
| 1428 | block. When decompressing, PPP checks that at the end of input packet, |
| 1429 | inflate is waiting for these length bytes. |
| 1430 | */ |
| 1431 | int ZEXPORT inflateSyncPoint(z_streamp strm) { |
| 1432 | struct inflate_state FAR *state; |
| 1433 | |
| 1434 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1435 | state = (struct inflate_state FAR *)strm->state; |
| 1436 | return state->mode == STORED && state->bits == 0; |
| 1437 | } |
| 1438 | |
| 1439 | int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) { |
| 1440 | struct inflate_state FAR *state; |
| 1441 | struct inflate_state FAR *copy; |
| 1442 | unsigned char FAR *window; |
| 1443 | unsigned wsize; |
| 1444 | |
| @@ -1537,14 +1478,11 @@ | |
| 1478 | copy->window = window; |
| 1479 | dest->state = (struct internal_state FAR *)copy; |
| 1480 | return Z_OK; |
| 1481 | } |
| 1482 | |
| 1483 | int ZEXPORT inflateUndermine(z_streamp strm, int subvert) { |
| 1484 | struct inflate_state FAR *state; |
| 1485 | |
| 1486 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1487 | state = (struct inflate_state FAR *)strm->state; |
| 1488 | #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR |
| @@ -1555,14 +1493,11 @@ | |
| 1493 | state->sane = 1; |
| 1494 | return Z_DATA_ERROR; |
| 1495 | #endif |
| 1496 | } |
| 1497 | |
| 1498 | int ZEXPORT inflateValidate(z_streamp strm, int check) { |
| 1499 | struct inflate_state FAR *state; |
| 1500 | |
| 1501 | if (inflateStateCheck(strm)) return Z_STREAM_ERROR; |
| 1502 | state = (struct inflate_state FAR *)strm->state; |
| 1503 | if (check && state->wrap) |
| @@ -1570,13 +1505,11 @@ | |
| 1505 | else |
| 1506 | state->wrap &= ~4; |
| 1507 | return Z_OK; |
| 1508 | } |
| 1509 | |
| 1510 | long ZEXPORT inflateMark(z_streamp strm) { |
| 1511 | struct inflate_state FAR *state; |
| 1512 | |
| 1513 | if (inflateStateCheck(strm)) |
| 1514 | return -(1L << 16); |
| 1515 | state = (struct inflate_state FAR *)strm->state; |
| @@ -1583,13 +1516,11 @@ | |
| 1516 | return (long)(((unsigned long)((long)state->back)) << 16) + |
| 1517 | (state->mode == COPY ? state->length : |
| 1518 | (state->mode == MATCH ? state->was - state->length : 0)); |
| 1519 | } |
| 1520 | |
| 1521 | unsigned long ZEXPORT inflateCodesUsed(z_streamp strm) { |
| 1522 | struct inflate_state FAR *state; |
| 1523 | if (inflateStateCheck(strm)) return (unsigned long)-1; |
| 1524 | state = (struct inflate_state FAR *)strm->state; |
| 1525 | return (unsigned long)(state->next - state->codes); |
| 1526 | } |
| 1527 |
+6
-11
| --- compat/zlib/inftrees.c | ||
| +++ compat/zlib/inftrees.c | ||
| @@ -1,17 +1,17 @@ | ||
| 1 | 1 | /* inftrees.c -- generate Huffman trees for efficient decoding |
| 2 | - * Copyright (C) 1995-2022 Mark Adler | |
| 2 | + * Copyright (C) 1995-2023 Mark Adler | |
| 3 | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | #include "zutil.h" |
| 7 | 7 | #include "inftrees.h" |
| 8 | 8 | |
| 9 | 9 | #define MAXBITS 15 |
| 10 | 10 | |
| 11 | 11 | const char inflate_copyright[] = |
| 12 | - " inflate 1.2.13 Copyright 1995-2022 Mark Adler "; | |
| 12 | + " inflate 1.3 Copyright 1995-2023 Mark Adler "; | |
| 13 | 13 | /* |
| 14 | 14 | If you use the zlib library in a product, an acknowledgment is welcome |
| 15 | 15 | in the documentation of your product. If for some reason you cannot |
| 16 | 16 | include such an acknowledgment, I would appreciate that you keep this |
| 17 | 17 | copyright string in the executable of your product. |
| @@ -27,18 +27,13 @@ | ||
| 27 | 27 | on return points to the next available entry's address. bits is the |
| 28 | 28 | requested root table index bits, and on return it is the actual root |
| 29 | 29 | table index bits. It will differ if the request is greater than the |
| 30 | 30 | longest code or if it is less than the shortest code. |
| 31 | 31 | */ |
| 32 | -int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) | |
| 33 | -codetype type; | |
| 34 | -unsigned short FAR *lens; | |
| 35 | -unsigned codes; | |
| 36 | -code FAR * FAR *table; | |
| 37 | -unsigned FAR *bits; | |
| 38 | -unsigned short FAR *work; | |
| 39 | -{ | |
| 32 | +int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, | |
| 33 | + unsigned codes, code FAR * FAR *table, | |
| 34 | + unsigned FAR *bits, unsigned short FAR *work) { | |
| 40 | 35 | unsigned len; /* a code's length in bits */ |
| 41 | 36 | unsigned sym; /* index of code symbols */ |
| 42 | 37 | unsigned min, max; /* minimum and maximum code lengths */ |
| 43 | 38 | unsigned root; /* number of index bits for root table */ |
| 44 | 39 | unsigned curr; /* number of index bits for current table */ |
| @@ -60,11 +55,11 @@ | ||
| 60 | 55 | static const unsigned short lbase[31] = { /* Length codes 257..285 base */ |
| 61 | 56 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, |
| 62 | 57 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; |
| 63 | 58 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ |
| 64 | 59 | 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, 194, 65}; | |
| 60 | + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 198, 203}; | |
| 66 | 61 | static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ |
| 67 | 62 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, |
| 68 | 63 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, |
| 69 | 64 | 8193, 12289, 16385, 24577, 0, 0}; |
| 70 | 65 | static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ |
| 71 | 66 |
| --- compat/zlib/inftrees.c | |
| +++ compat/zlib/inftrees.c | |
| @@ -1,17 +1,17 @@ | |
| 1 | /* inftrees.c -- generate Huffman trees for efficient decoding |
| 2 | * Copyright (C) 1995-2022 Mark Adler |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ |
| 5 | |
| 6 | #include "zutil.h" |
| 7 | #include "inftrees.h" |
| 8 | |
| 9 | #define MAXBITS 15 |
| 10 | |
| 11 | const char inflate_copyright[] = |
| 12 | " inflate 1.2.13 Copyright 1995-2022 Mark Adler "; |
| 13 | /* |
| 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 |
| 16 | include such an acknowledgment, I would appreciate that you keep this |
| 17 | copyright string in the executable of your product. |
| @@ -27,18 +27,13 @@ | |
| 27 | on return points to the next available entry's address. bits is the |
| 28 | requested root table index bits, and on return it is the actual root |
| 29 | table index bits. It will differ if the request is greater than the |
| 30 | longest code or if it is less than the shortest code. |
| 31 | */ |
| 32 | int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) |
| 33 | codetype type; |
| 34 | unsigned short FAR *lens; |
| 35 | unsigned codes; |
| 36 | code FAR * FAR *table; |
| 37 | unsigned FAR *bits; |
| 38 | unsigned short FAR *work; |
| 39 | { |
| 40 | unsigned len; /* a code's length in bits */ |
| 41 | unsigned sym; /* index of code symbols */ |
| 42 | unsigned min, max; /* minimum and maximum code lengths */ |
| 43 | unsigned root; /* number of index bits for root table */ |
| 44 | unsigned curr; /* number of index bits for current table */ |
| @@ -60,11 +55,11 @@ | |
| 60 | static const unsigned short lbase[31] = { /* Length codes 257..285 base */ |
| 61 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, |
| 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 */ |
| 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, 194, 65}; |
| 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, |
| 68 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, |
| 69 | 8193, 12289, 16385, 24577, 0, 0}; |
| 70 | static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ |
| 71 |
| --- compat/zlib/inftrees.c | |
| +++ compat/zlib/inftrees.c | |
| @@ -1,17 +1,17 @@ | |
| 1 | /* inftrees.c -- generate Huffman trees for efficient decoding |
| 2 | * Copyright (C) 1995-2023 Mark Adler |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ |
| 5 | |
| 6 | #include "zutil.h" |
| 7 | #include "inftrees.h" |
| 8 | |
| 9 | #define MAXBITS 15 |
| 10 | |
| 11 | const char inflate_copyright[] = |
| 12 | " inflate 1.3 Copyright 1995-2023 Mark Adler "; |
| 13 | /* |
| 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 |
| 16 | include such an acknowledgment, I would appreciate that you keep this |
| 17 | copyright string in the executable of your product. |
| @@ -27,18 +27,13 @@ | |
| 27 | on return points to the next available entry's address. bits is the |
| 28 | requested root table index bits, and on return it is the actual root |
| 29 | table index bits. It will differ if the request is greater than the |
| 30 | longest code or if it is less than the shortest code. |
| 31 | */ |
| 32 | int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, |
| 33 | unsigned codes, code FAR * FAR *table, |
| 34 | unsigned FAR *bits, unsigned short FAR *work) { |
| 35 | unsigned len; /* a code's length in bits */ |
| 36 | unsigned sym; /* index of code symbols */ |
| 37 | unsigned min, max; /* minimum and maximum code lengths */ |
| 38 | unsigned root; /* number of index bits for root table */ |
| 39 | unsigned curr; /* number of index bits for current table */ |
| @@ -60,11 +55,11 @@ | |
| 55 | static const unsigned short lbase[31] = { /* Length codes 257..285 base */ |
| 56 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, |
| 57 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; |
| 58 | static const unsigned short lext[31] = { /* Length codes 257..285 extra */ |
| 59 | 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, |
| 60 | 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 198, 203}; |
| 61 | static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ |
| 62 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, |
| 63 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, |
| 64 | 8193, 12289, 16385, 24577, 0, 0}; |
| 65 | static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ |
| 66 |
+3
-3
| --- compat/zlib/inftrees.h | ||
| +++ compat/zlib/inftrees.h | ||
| @@ -55,8 +55,8 @@ | ||
| 55 | 55 | CODES, |
| 56 | 56 | LENS, |
| 57 | 57 | DISTS |
| 58 | 58 | } codetype; |
| 59 | 59 | |
| 60 | -int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, | |
| 61 | - unsigned codes, code FAR * FAR *table, | |
| 62 | - unsigned FAR *bits, unsigned short FAR *work)); | |
| 60 | +int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, | |
| 61 | + unsigned codes, code FAR * FAR *table, | |
| 62 | + unsigned FAR *bits, unsigned short FAR *work); | |
| 63 | 63 |
| --- compat/zlib/inftrees.h | |
| +++ compat/zlib/inftrees.h | |
| @@ -55,8 +55,8 @@ | |
| 55 | CODES, |
| 56 | LENS, |
| 57 | DISTS |
| 58 | } codetype; |
| 59 | |
| 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, |
| 61 | unsigned codes, code FAR * FAR *table, |
| 62 | unsigned FAR *bits, unsigned short FAR *work)); |
| 63 |
| --- compat/zlib/inftrees.h | |
| +++ compat/zlib/inftrees.h | |
| @@ -55,8 +55,8 @@ | |
| 55 | CODES, |
| 56 | LENS, |
| 57 | DISTS |
| 58 | } codetype; |
| 59 | |
| 60 | int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, |
| 61 | unsigned codes, code FAR * FAR *table, |
| 62 | unsigned FAR *bits, unsigned short FAR *work); |
| 63 |
+1
-1
| --- compat/zlib/os400/README400 | ||
| +++ compat/zlib/os400/README400 | ||
| @@ -1,6 +1,6 @@ | ||
| 1 | - ZLIB version 1.2.13 for OS/400 installation instructions | |
| 1 | + ZLIB version 1.3.0 for OS/400 installation instructions | |
| 2 | 2 | |
| 3 | 3 | 1) Download and unpack the zlib tarball to some IFS directory. |
| 4 | 4 | (i.e.: /path/to/the/zlib/ifs/source/directory) |
| 5 | 5 | |
| 6 | 6 | If the installed IFS command supports gzip format, this is straightforward, |
| 7 | 7 |
| --- compat/zlib/os400/README400 | |
| +++ compat/zlib/os400/README400 | |
| @@ -1,6 +1,6 @@ | |
| 1 | ZLIB version 1.2.13 for OS/400 installation instructions |
| 2 | |
| 3 | 1) Download and unpack the zlib tarball to some IFS directory. |
| 4 | (i.e.: /path/to/the/zlib/ifs/source/directory) |
| 5 | |
| 6 | If the installed IFS command supports gzip format, this is straightforward, |
| 7 |
| --- compat/zlib/os400/README400 | |
| +++ compat/zlib/os400/README400 | |
| @@ -1,6 +1,6 @@ | |
| 1 | ZLIB version 1.3.0 for OS/400 installation instructions |
| 2 | |
| 3 | 1) Download and unpack the zlib tarball to some IFS directory. |
| 4 | (i.e.: /path/to/the/zlib/ifs/source/directory) |
| 5 | |
| 6 | If the installed IFS command supports gzip format, this is straightforward, |
| 7 |
+4
-4
| --- compat/zlib/os400/zlib.inc | ||
| +++ compat/zlib/os400/zlib.inc | ||
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | * ZLIB.INC - Interface to the general purpose compression library |
| 2 | 2 | * |
| 3 | 3 | * ILE RPG400 version by Patrick Monnerat, DATASPHERE. |
| 4 | - * Version 1.2.13 | |
| 4 | + * Version 1.3.0 | |
| 5 | 5 | * |
| 6 | 6 | * |
| 7 | 7 | * WARNING: |
| 8 | 8 | * Procedures inflateInit(), inflateInit2(), deflateInit(), |
| 9 | 9 | * deflateInit2() and inflateBackInit() need to be called with |
| @@ -20,16 +20,16 @@ | ||
| 20 | 20 | * Constants |
| 21 | 21 | ************************************************************************** |
| 22 | 22 | * |
| 23 | 23 | * Versioning information. |
| 24 | 24 | * |
| 25 | - D ZLIB_VERSION C '1.2.13' | |
| 25 | + D ZLIB_VERSION C '1.3.0' | |
| 26 | 26 | D ZLIB_VERNUM C X'12a0' |
| 27 | 27 | D ZLIB_VER_MAJOR C 1 |
| 28 | - D ZLIB_VER_MINOR C 2 | |
| 28 | + D ZLIB_VER_MINOR C 3 | |
| 29 | 29 | D ZLIB_VER_REVISION... |
| 30 | - D C 13 | |
| 30 | + D C 0 | |
| 31 | 31 | D ZLIB_VER_SUBREVISION... |
| 32 | 32 | D C 0 |
| 33 | 33 | * |
| 34 | 34 | * Other equates. |
| 35 | 35 | * |
| 36 | 36 |
| --- compat/zlib/os400/zlib.inc | |
| +++ compat/zlib/os400/zlib.inc | |
| @@ -1,9 +1,9 @@ | |
| 1 | * ZLIB.INC - Interface to the general purpose compression library |
| 2 | * |
| 3 | * ILE RPG400 version by Patrick Monnerat, DATASPHERE. |
| 4 | * Version 1.2.13 |
| 5 | * |
| 6 | * |
| 7 | * WARNING: |
| 8 | * Procedures inflateInit(), inflateInit2(), deflateInit(), |
| 9 | * deflateInit2() and inflateBackInit() need to be called with |
| @@ -20,16 +20,16 @@ | |
| 20 | * Constants |
| 21 | ************************************************************************** |
| 22 | * |
| 23 | * Versioning information. |
| 24 | * |
| 25 | D ZLIB_VERSION C '1.2.13' |
| 26 | D ZLIB_VERNUM C X'12a0' |
| 27 | D ZLIB_VER_MAJOR C 1 |
| 28 | D ZLIB_VER_MINOR C 2 |
| 29 | D ZLIB_VER_REVISION... |
| 30 | D C 13 |
| 31 | D ZLIB_VER_SUBREVISION... |
| 32 | D C 0 |
| 33 | * |
| 34 | * Other equates. |
| 35 | * |
| 36 |
| --- compat/zlib/os400/zlib.inc | |
| +++ compat/zlib/os400/zlib.inc | |
| @@ -1,9 +1,9 @@ | |
| 1 | * ZLIB.INC - Interface to the general purpose compression library |
| 2 | * |
| 3 | * ILE RPG400 version by Patrick Monnerat, DATASPHERE. |
| 4 | * Version 1.3.0 |
| 5 | * |
| 6 | * |
| 7 | * WARNING: |
| 8 | * Procedures inflateInit(), inflateInit2(), deflateInit(), |
| 9 | * deflateInit2() and inflateBackInit() need to be called with |
| @@ -20,16 +20,16 @@ | |
| 20 | * Constants |
| 21 | ************************************************************************** |
| 22 | * |
| 23 | * Versioning information. |
| 24 | * |
| 25 | D ZLIB_VERSION C '1.3.0' |
| 26 | D ZLIB_VERNUM C X'12a0' |
| 27 | D ZLIB_VER_MAJOR C 1 |
| 28 | D ZLIB_VER_MINOR C 3 |
| 29 | D ZLIB_VER_REVISION... |
| 30 | D C 0 |
| 31 | D ZLIB_VER_SUBREVISION... |
| 32 | D C 0 |
| 33 | * |
| 34 | * Other equates. |
| 35 | * |
| 36 |
+5
-5
| --- compat/zlib/qnx/package.qpg | ||
| +++ compat/zlib/qnx/package.qpg | ||
| @@ -23,14 +23,14 @@ | ||
| 23 | 23 | |
| 24 | 24 | <QPG:Values> |
| 25 | 25 | <QPG:Files> |
| 26 | 26 | <QPG:Add file="../zconf.h" install="/opt/include/" user="root:sys" permission="644"/> |
| 27 | 27 | <QPG:Add file="../zlib.h" install="/opt/include/" user="root:sys" permission="644"/> |
| 28 | - <QPG:Add file="../libz.so.1.2.13" 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.13"/> | |
| 30 | - <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.13"/> | |
| 31 | - <QPG:Add file="../libz.so.1.2.13" install="/opt/lib/" component="slib"/> | |
| 28 | + <QPG:Add file="../libz.so.1.3.0" 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.3.0"/> | |
| 30 | + <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.3.0"/> | |
| 31 | + <QPG:Add file="../libz.so.1.3.0" install="/opt/lib/" component="slib"/> | |
| 32 | 32 | </QPG:Files> |
| 33 | 33 | |
| 34 | 34 | <QPG:PackageFilter> |
| 35 | 35 | <QPM:PackageManifest> |
| 36 | 36 | <QPM:PackageDescription> |
| @@ -61,11 +61,11 @@ | ||
| 61 | 61 | <QPM:ProductDescriptionURL>http://www.gzip.org/zlib</QPM:ProductDescriptionURL> |
| 62 | 62 | <QPM:ProductDescriptionEmbedURL></QPM:ProductDescriptionEmbedURL> |
| 63 | 63 | </QPM:ProductDescription> |
| 64 | 64 | |
| 65 | 65 | <QPM:ReleaseDescription> |
| 66 | - <QPM:ReleaseVersion>1.2.13</QPM:ReleaseVersion> | |
| 66 | + <QPM:ReleaseVersion>1.3.0</QPM:ReleaseVersion> | |
| 67 | 67 | <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency> |
| 68 | 68 | <QPM:ReleaseStability>Stable</QPM:ReleaseStability> |
| 69 | 69 | <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor> |
| 70 | 70 | <QPM:ReleaseNoteMajor></QPM:ReleaseNoteMajor> |
| 71 | 71 | <QPM:ExcludeCountries> |
| 72 | 72 |
| --- compat/zlib/qnx/package.qpg | |
| +++ compat/zlib/qnx/package.qpg | |
| @@ -23,14 +23,14 @@ | |
| 23 | |
| 24 | <QPG:Values> |
| 25 | <QPG:Files> |
| 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"/> |
| 28 | <QPG:Add file="../libz.so.1.2.13" 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.13"/> |
| 30 | <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.2.13"/> |
| 31 | <QPG:Add file="../libz.so.1.2.13" install="/opt/lib/" component="slib"/> |
| 32 | </QPG:Files> |
| 33 | |
| 34 | <QPG:PackageFilter> |
| 35 | <QPM:PackageManifest> |
| 36 | <QPM:PackageDescription> |
| @@ -61,11 +61,11 @@ | |
| 61 | <QPM:ProductDescriptionURL>http://www.gzip.org/zlib</QPM:ProductDescriptionURL> |
| 62 | <QPM:ProductDescriptionEmbedURL></QPM:ProductDescriptionEmbedURL> |
| 63 | </QPM:ProductDescription> |
| 64 | |
| 65 | <QPM:ReleaseDescription> |
| 66 | <QPM:ReleaseVersion>1.2.13</QPM:ReleaseVersion> |
| 67 | <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency> |
| 68 | <QPM:ReleaseStability>Stable</QPM:ReleaseStability> |
| 69 | <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor> |
| 70 | <QPM:ReleaseNoteMajor></QPM:ReleaseNoteMajor> |
| 71 | <QPM:ExcludeCountries> |
| 72 |
| --- compat/zlib/qnx/package.qpg | |
| +++ compat/zlib/qnx/package.qpg | |
| @@ -23,14 +23,14 @@ | |
| 23 | |
| 24 | <QPG:Values> |
| 25 | <QPG:Files> |
| 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"/> |
| 28 | <QPG:Add file="../libz.so.1.3.0" 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.3.0"/> |
| 30 | <QPG:Add file="libz.so.1" install="/opt/lib/" filetype="symlink" linkto="libz.so.1.3.0"/> |
| 31 | <QPG:Add file="../libz.so.1.3.0" install="/opt/lib/" component="slib"/> |
| 32 | </QPG:Files> |
| 33 | |
| 34 | <QPG:PackageFilter> |
| 35 | <QPM:PackageManifest> |
| 36 | <QPM:PackageDescription> |
| @@ -61,11 +61,11 @@ | |
| 61 | <QPM:ProductDescriptionURL>http://www.gzip.org/zlib</QPM:ProductDescriptionURL> |
| 62 | <QPM:ProductDescriptionEmbedURL></QPM:ProductDescriptionEmbedURL> |
| 63 | </QPM:ProductDescription> |
| 64 | |
| 65 | <QPM:ReleaseDescription> |
| 66 | <QPM:ReleaseVersion>1.3.0</QPM:ReleaseVersion> |
| 67 | <QPM:ReleaseUrgency>Medium</QPM:ReleaseUrgency> |
| 68 | <QPM:ReleaseStability>Stable</QPM:ReleaseStability> |
| 69 | <QPM:ReleaseNoteMinor></QPM:ReleaseNoteMinor> |
| 70 | <QPM:ReleaseNoteMajor></QPM:ReleaseNoteMajor> |
| 71 | <QPM:ExcludeCountries> |
| 72 |
+23
-80
| --- compat/zlib/test/example.c | ||
| +++ compat/zlib/test/example.c | ||
| @@ -31,42 +31,19 @@ | ||
| 31 | 31 | * stresses the compression code better, sorry... |
| 32 | 32 | */ |
| 33 | 33 | |
| 34 | 34 | static const char dictionary[] = "hello"; |
| 35 | 35 | static uLong dictId; /* Adler32 value of the dictionary */ |
| 36 | - | |
| 37 | -void test_deflate OF((Byte *compr, uLong comprLen)); | |
| 38 | -void test_inflate OF((Byte *compr, uLong comprLen, | |
| 39 | - Byte *uncompr, uLong uncomprLen)); | |
| 40 | -void test_large_deflate OF((Byte *compr, uLong comprLen, | |
| 41 | - Byte *uncompr, uLong uncomprLen)); | |
| 42 | -void test_large_inflate OF((Byte *compr, uLong comprLen, | |
| 43 | - Byte *uncompr, uLong uncomprLen)); | |
| 44 | -void test_flush OF((Byte *compr, uLong *comprLen)); | |
| 45 | -void test_sync OF((Byte *compr, uLong comprLen, | |
| 46 | - Byte *uncompr, uLong uncomprLen)); | |
| 47 | -void test_dict_deflate OF((Byte *compr, uLong comprLen)); | |
| 48 | -void test_dict_inflate OF((Byte *compr, uLong comprLen, | |
| 49 | - Byte *uncompr, uLong uncomprLen)); | |
| 50 | -int main OF((int argc, char *argv[])); | |
| 51 | - | |
| 52 | 36 | |
| 53 | 37 | #ifdef Z_SOLO |
| 54 | 38 | |
| 55 | -void *myalloc OF((void *, unsigned, unsigned)); | |
| 56 | -void myfree OF((void *, void *)); | |
| 57 | - | |
| 58 | -void *myalloc(q, n, m) | |
| 59 | - void *q; | |
| 60 | - unsigned n, m; | |
| 61 | -{ | |
| 39 | +void *myalloc(void *q, unsigned n, unsigned m) { | |
| 62 | 40 | (void)q; |
| 63 | 41 | return calloc(n, m); |
| 64 | 42 | } |
| 65 | 43 | |
| 66 | -void myfree(void *q, void *p) | |
| 67 | -{ | |
| 44 | +void myfree(void *q, void *p) { | |
| 68 | 45 | (void)q; |
| 69 | 46 | free(p); |
| 70 | 47 | } |
| 71 | 48 | |
| 72 | 49 | static alloc_func zalloc = myalloc; |
| @@ -75,22 +52,15 @@ | ||
| 75 | 52 | #else /* !Z_SOLO */ |
| 76 | 53 | |
| 77 | 54 | static alloc_func zalloc = (alloc_func)0; |
| 78 | 55 | static free_func zfree = (free_func)0; |
| 79 | 56 | |
| 80 | -void test_compress OF((Byte *compr, uLong comprLen, | |
| 81 | - Byte *uncompr, uLong uncomprLen)); | |
| 82 | -void test_gzio OF((const char *fname, | |
| 83 | - Byte *uncompr, uLong uncomprLen)); | |
| 84 | - | |
| 85 | 57 | /* =========================================================================== |
| 86 | 58 | * Test compress() and uncompress() |
| 87 | 59 | */ |
| 88 | -void test_compress(compr, comprLen, uncompr, uncomprLen) | |
| 89 | - Byte *compr, *uncompr; | |
| 90 | - uLong comprLen, uncomprLen; | |
| 91 | -{ | |
| 60 | +void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, | |
| 61 | + uLong uncomprLen) { | |
| 92 | 62 | int err; |
| 93 | 63 | uLong len = (uLong)strlen(hello)+1; |
| 94 | 64 | |
| 95 | 65 | err = compress(compr, &comprLen, (const Bytef*)hello, len); |
| 96 | 66 | CHECK_ERR(err, "compress"); |
| @@ -109,15 +79,11 @@ | ||
| 109 | 79 | } |
| 110 | 80 | |
| 111 | 81 | /* =========================================================================== |
| 112 | 82 | * Test read/write of .gz files |
| 113 | 83 | */ |
| 114 | -void test_gzio(fname, uncompr, uncomprLen) | |
| 115 | - const char *fname; /* compressed file name */ | |
| 116 | - Byte *uncompr; | |
| 117 | - uLong uncomprLen; | |
| 118 | -{ | |
| 84 | +void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) { | |
| 119 | 85 | #ifdef NO_GZCOMPRESS |
| 120 | 86 | fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); |
| 121 | 87 | #else |
| 122 | 88 | int err; |
| 123 | 89 | int len = (int)strlen(hello)+1; |
| @@ -195,14 +161,11 @@ | ||
| 195 | 161 | #endif /* Z_SOLO */ |
| 196 | 162 | |
| 197 | 163 | /* =========================================================================== |
| 198 | 164 | * Test deflate() with small buffers |
| 199 | 165 | */ |
| 200 | -void test_deflate(compr, comprLen) | |
| 201 | - Byte *compr; | |
| 202 | - uLong comprLen; | |
| 203 | -{ | |
| 166 | +void test_deflate(Byte *compr, uLong comprLen) { | |
| 204 | 167 | z_stream c_stream; /* compression stream */ |
| 205 | 168 | int err; |
| 206 | 169 | uLong len = (uLong)strlen(hello)+1; |
| 207 | 170 | |
| 208 | 171 | c_stream.zalloc = zalloc; |
| @@ -233,14 +196,12 @@ | ||
| 233 | 196 | } |
| 234 | 197 | |
| 235 | 198 | /* =========================================================================== |
| 236 | 199 | * Test inflate() with small buffers |
| 237 | 200 | */ |
| 238 | -void test_inflate(compr, comprLen, uncompr, uncomprLen) | |
| 239 | - Byte *compr, *uncompr; | |
| 240 | - uLong comprLen, uncomprLen; | |
| 241 | -{ | |
| 201 | +void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, | |
| 202 | + uLong uncomprLen) { | |
| 242 | 203 | int err; |
| 243 | 204 | z_stream d_stream; /* decompression stream */ |
| 244 | 205 | |
| 245 | 206 | strcpy((char*)uncompr, "garbage"); |
| 246 | 207 | |
| @@ -274,14 +235,12 @@ | ||
| 274 | 235 | } |
| 275 | 236 | |
| 276 | 237 | /* =========================================================================== |
| 277 | 238 | * Test deflate() with large buffers and dynamic change of compression level |
| 278 | 239 | */ |
| 279 | -void test_large_deflate(compr, comprLen, uncompr, uncomprLen) | |
| 280 | - Byte *compr, *uncompr; | |
| 281 | - uLong comprLen, uncomprLen; | |
| 282 | -{ | |
| 240 | +void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, | |
| 241 | + uLong uncomprLen) { | |
| 283 | 242 | z_stream c_stream; /* compression stream */ |
| 284 | 243 | int err; |
| 285 | 244 | |
| 286 | 245 | c_stream.zalloc = zalloc; |
| 287 | 246 | c_stream.zfree = zfree; |
| @@ -306,11 +265,11 @@ | ||
| 306 | 265 | } |
| 307 | 266 | |
| 308 | 267 | /* Feed in already compressed data and switch to no compression: */ |
| 309 | 268 | deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); |
| 310 | 269 | c_stream.next_in = compr; |
| 311 | - c_stream.avail_in = (uInt)comprLen/2; | |
| 270 | + c_stream.avail_in = (uInt)uncomprLen/2; | |
| 312 | 271 | err = deflate(&c_stream, Z_NO_FLUSH); |
| 313 | 272 | CHECK_ERR(err, "deflate"); |
| 314 | 273 | |
| 315 | 274 | /* Switch back to compressing mode: */ |
| 316 | 275 | deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); |
| @@ -329,14 +288,12 @@ | ||
| 329 | 288 | } |
| 330 | 289 | |
| 331 | 290 | /* =========================================================================== |
| 332 | 291 | * Test inflate() with large buffers |
| 333 | 292 | */ |
| 334 | -void test_large_inflate(compr, comprLen, uncompr, uncomprLen) | |
| 335 | - Byte *compr, *uncompr; | |
| 336 | - uLong comprLen, uncomprLen; | |
| 337 | -{ | |
| 293 | +void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, | |
| 294 | + uLong uncomprLen) { | |
| 338 | 295 | int err; |
| 339 | 296 | z_stream d_stream; /* decompression stream */ |
| 340 | 297 | |
| 341 | 298 | strcpy((char*)uncompr, "garbage"); |
| 342 | 299 | |
| @@ -359,11 +316,11 @@ | ||
| 359 | 316 | } |
| 360 | 317 | |
| 361 | 318 | err = inflateEnd(&d_stream); |
| 362 | 319 | CHECK_ERR(err, "inflateEnd"); |
| 363 | 320 | |
| 364 | - if (d_stream.total_out != 2*uncomprLen + comprLen/2) { | |
| 321 | + if (d_stream.total_out != 2*uncomprLen + uncomprLen/2) { | |
| 365 | 322 | fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); |
| 366 | 323 | exit(1); |
| 367 | 324 | } else { |
| 368 | 325 | printf("large_inflate(): OK\n"); |
| 369 | 326 | } |
| @@ -370,14 +327,11 @@ | ||
| 370 | 327 | } |
| 371 | 328 | |
| 372 | 329 | /* =========================================================================== |
| 373 | 330 | * Test deflate() with full flush |
| 374 | 331 | */ |
| 375 | -void test_flush(compr, comprLen) | |
| 376 | - Byte *compr; | |
| 377 | - uLong *comprLen; | |
| 378 | -{ | |
| 332 | +void test_flush(Byte *compr, uLong *comprLen) { | |
| 379 | 333 | z_stream c_stream; /* compression stream */ |
| 380 | 334 | int err; |
| 381 | 335 | uInt len = (uInt)strlen(hello)+1; |
| 382 | 336 | |
| 383 | 337 | c_stream.zalloc = zalloc; |
| @@ -408,14 +362,11 @@ | ||
| 408 | 362 | } |
| 409 | 363 | |
| 410 | 364 | /* =========================================================================== |
| 411 | 365 | * Test inflateSync() |
| 412 | 366 | */ |
| 413 | -void test_sync(compr, comprLen, uncompr, uncomprLen) | |
| 414 | - Byte *compr, *uncompr; | |
| 415 | - uLong comprLen, uncomprLen; | |
| 416 | -{ | |
| 367 | +void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) { | |
| 417 | 368 | int err; |
| 418 | 369 | z_stream d_stream; /* decompression stream */ |
| 419 | 370 | |
| 420 | 371 | strcpy((char*)uncompr, "garbage"); |
| 421 | 372 | |
| @@ -451,14 +402,11 @@ | ||
| 451 | 402 | } |
| 452 | 403 | |
| 453 | 404 | /* =========================================================================== |
| 454 | 405 | * Test deflate() with preset dictionary |
| 455 | 406 | */ |
| 456 | -void test_dict_deflate(compr, comprLen) | |
| 457 | - Byte *compr; | |
| 458 | - uLong comprLen; | |
| 459 | -{ | |
| 407 | +void test_dict_deflate(Byte *compr, uLong comprLen) { | |
| 460 | 408 | z_stream c_stream; /* compression stream */ |
| 461 | 409 | int err; |
| 462 | 410 | |
| 463 | 411 | c_stream.zalloc = zalloc; |
| 464 | 412 | c_stream.zfree = zfree; |
| @@ -488,14 +436,12 @@ | ||
| 488 | 436 | } |
| 489 | 437 | |
| 490 | 438 | /* =========================================================================== |
| 491 | 439 | * Test inflate() with a preset dictionary |
| 492 | 440 | */ |
| 493 | -void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) | |
| 494 | - Byte *compr, *uncompr; | |
| 495 | - uLong comprLen, uncomprLen; | |
| 496 | -{ | |
| 441 | +void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, | |
| 442 | + uLong uncomprLen) { | |
| 497 | 443 | int err; |
| 498 | 444 | z_stream d_stream; /* decompression stream */ |
| 499 | 445 | |
| 500 | 446 | strcpy((char*)uncompr, "garbage"); |
| 501 | 447 | |
| @@ -539,17 +485,14 @@ | ||
| 539 | 485 | |
| 540 | 486 | /* =========================================================================== |
| 541 | 487 | * Usage: example [output.gz [input.gz]] |
| 542 | 488 | */ |
| 543 | 489 | |
| 544 | -int main(argc, argv) | |
| 545 | - int argc; | |
| 546 | - char *argv[]; | |
| 547 | -{ | |
| 490 | +int main(int argc, char *argv[]) { | |
| 548 | 491 | Byte *compr, *uncompr; |
| 549 | - uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ | |
| 550 | - uLong uncomprLen = comprLen; | |
| 492 | + uLong uncomprLen = 20000; | |
| 493 | + uLong comprLen = 3 * uncomprLen; | |
| 551 | 494 | static const char* myVersion = ZLIB_VERSION; |
| 552 | 495 | |
| 553 | 496 | if (zlibVersion()[0] != myVersion[0]) { |
| 554 | 497 | fprintf(stderr, "incompatible zlib version\n"); |
| 555 | 498 | exit(1); |
| @@ -588,15 +531,15 @@ | ||
| 588 | 531 | test_large_deflate(compr, comprLen, uncompr, uncomprLen); |
| 589 | 532 | test_large_inflate(compr, comprLen, uncompr, uncomprLen); |
| 590 | 533 | |
| 591 | 534 | test_flush(compr, &comprLen); |
| 592 | 535 | test_sync(compr, comprLen, uncompr, uncomprLen); |
| 593 | - comprLen = uncomprLen; | |
| 536 | + comprLen = 3 * uncomprLen; | |
| 594 | 537 | |
| 595 | 538 | test_dict_deflate(compr, comprLen); |
| 596 | 539 | test_dict_inflate(compr, comprLen, uncompr, uncomprLen); |
| 597 | 540 | |
| 598 | 541 | free(compr); |
| 599 | 542 | free(uncompr); |
| 600 | 543 | |
| 601 | 544 | return 0; |
| 602 | 545 | } |
| 603 | 546 |
| --- compat/zlib/test/example.c | |
| +++ compat/zlib/test/example.c | |
| @@ -31,42 +31,19 @@ | |
| 31 | * stresses the compression code better, sorry... |
| 32 | */ |
| 33 | |
| 34 | static const char dictionary[] = "hello"; |
| 35 | static uLong dictId; /* Adler32 value of the dictionary */ |
| 36 | |
| 37 | void test_deflate OF((Byte *compr, uLong comprLen)); |
| 38 | void test_inflate OF((Byte *compr, uLong comprLen, |
| 39 | Byte *uncompr, uLong uncomprLen)); |
| 40 | void test_large_deflate OF((Byte *compr, uLong comprLen, |
| 41 | Byte *uncompr, uLong uncomprLen)); |
| 42 | void test_large_inflate OF((Byte *compr, uLong comprLen, |
| 43 | Byte *uncompr, uLong uncomprLen)); |
| 44 | void test_flush OF((Byte *compr, uLong *comprLen)); |
| 45 | void test_sync OF((Byte *compr, uLong comprLen, |
| 46 | Byte *uncompr, uLong uncomprLen)); |
| 47 | void test_dict_deflate OF((Byte *compr, uLong comprLen)); |
| 48 | void test_dict_inflate OF((Byte *compr, uLong comprLen, |
| 49 | Byte *uncompr, uLong uncomprLen)); |
| 50 | int main OF((int argc, char *argv[])); |
| 51 | |
| 52 | |
| 53 | #ifdef Z_SOLO |
| 54 | |
| 55 | void *myalloc OF((void *, unsigned, unsigned)); |
| 56 | void myfree OF((void *, void *)); |
| 57 | |
| 58 | void *myalloc(q, n, m) |
| 59 | void *q; |
| 60 | unsigned n, m; |
| 61 | { |
| 62 | (void)q; |
| 63 | return calloc(n, m); |
| 64 | } |
| 65 | |
| 66 | void myfree(void *q, void *p) |
| 67 | { |
| 68 | (void)q; |
| 69 | free(p); |
| 70 | } |
| 71 | |
| 72 | static alloc_func zalloc = myalloc; |
| @@ -75,22 +52,15 @@ | |
| 75 | #else /* !Z_SOLO */ |
| 76 | |
| 77 | static alloc_func zalloc = (alloc_func)0; |
| 78 | static free_func zfree = (free_func)0; |
| 79 | |
| 80 | void test_compress OF((Byte *compr, uLong comprLen, |
| 81 | Byte *uncompr, uLong uncomprLen)); |
| 82 | void test_gzio OF((const char *fname, |
| 83 | Byte *uncompr, uLong uncomprLen)); |
| 84 | |
| 85 | /* =========================================================================== |
| 86 | * Test compress() and uncompress() |
| 87 | */ |
| 88 | void test_compress(compr, comprLen, uncompr, uncomprLen) |
| 89 | Byte *compr, *uncompr; |
| 90 | uLong comprLen, uncomprLen; |
| 91 | { |
| 92 | int err; |
| 93 | uLong len = (uLong)strlen(hello)+1; |
| 94 | |
| 95 | err = compress(compr, &comprLen, (const Bytef*)hello, len); |
| 96 | CHECK_ERR(err, "compress"); |
| @@ -109,15 +79,11 @@ | |
| 109 | } |
| 110 | |
| 111 | /* =========================================================================== |
| 112 | * Test read/write of .gz files |
| 113 | */ |
| 114 | void test_gzio(fname, uncompr, uncomprLen) |
| 115 | const char *fname; /* compressed file name */ |
| 116 | Byte *uncompr; |
| 117 | uLong uncomprLen; |
| 118 | { |
| 119 | #ifdef NO_GZCOMPRESS |
| 120 | fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); |
| 121 | #else |
| 122 | int err; |
| 123 | int len = (int)strlen(hello)+1; |
| @@ -195,14 +161,11 @@ | |
| 195 | #endif /* Z_SOLO */ |
| 196 | |
| 197 | /* =========================================================================== |
| 198 | * Test deflate() with small buffers |
| 199 | */ |
| 200 | void test_deflate(compr, comprLen) |
| 201 | Byte *compr; |
| 202 | uLong comprLen; |
| 203 | { |
| 204 | z_stream c_stream; /* compression stream */ |
| 205 | int err; |
| 206 | uLong len = (uLong)strlen(hello)+1; |
| 207 | |
| 208 | c_stream.zalloc = zalloc; |
| @@ -233,14 +196,12 @@ | |
| 233 | } |
| 234 | |
| 235 | /* =========================================================================== |
| 236 | * Test inflate() with small buffers |
| 237 | */ |
| 238 | void test_inflate(compr, comprLen, uncompr, uncomprLen) |
| 239 | Byte *compr, *uncompr; |
| 240 | uLong comprLen, uncomprLen; |
| 241 | { |
| 242 | int err; |
| 243 | z_stream d_stream; /* decompression stream */ |
| 244 | |
| 245 | strcpy((char*)uncompr, "garbage"); |
| 246 | |
| @@ -274,14 +235,12 @@ | |
| 274 | } |
| 275 | |
| 276 | /* =========================================================================== |
| 277 | * Test deflate() with large buffers and dynamic change of compression level |
| 278 | */ |
| 279 | void test_large_deflate(compr, comprLen, uncompr, uncomprLen) |
| 280 | Byte *compr, *uncompr; |
| 281 | uLong comprLen, uncomprLen; |
| 282 | { |
| 283 | z_stream c_stream; /* compression stream */ |
| 284 | int err; |
| 285 | |
| 286 | c_stream.zalloc = zalloc; |
| 287 | c_stream.zfree = zfree; |
| @@ -306,11 +265,11 @@ | |
| 306 | } |
| 307 | |
| 308 | /* Feed in already compressed data and switch to no compression: */ |
| 309 | deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); |
| 310 | c_stream.next_in = compr; |
| 311 | c_stream.avail_in = (uInt)comprLen/2; |
| 312 | err = deflate(&c_stream, Z_NO_FLUSH); |
| 313 | CHECK_ERR(err, "deflate"); |
| 314 | |
| 315 | /* Switch back to compressing mode: */ |
| 316 | deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); |
| @@ -329,14 +288,12 @@ | |
| 329 | } |
| 330 | |
| 331 | /* =========================================================================== |
| 332 | * Test inflate() with large buffers |
| 333 | */ |
| 334 | void test_large_inflate(compr, comprLen, uncompr, uncomprLen) |
| 335 | Byte *compr, *uncompr; |
| 336 | uLong comprLen, uncomprLen; |
| 337 | { |
| 338 | int err; |
| 339 | z_stream d_stream; /* decompression stream */ |
| 340 | |
| 341 | strcpy((char*)uncompr, "garbage"); |
| 342 | |
| @@ -359,11 +316,11 @@ | |
| 359 | } |
| 360 | |
| 361 | err = inflateEnd(&d_stream); |
| 362 | CHECK_ERR(err, "inflateEnd"); |
| 363 | |
| 364 | if (d_stream.total_out != 2*uncomprLen + comprLen/2) { |
| 365 | fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); |
| 366 | exit(1); |
| 367 | } else { |
| 368 | printf("large_inflate(): OK\n"); |
| 369 | } |
| @@ -370,14 +327,11 @@ | |
| 370 | } |
| 371 | |
| 372 | /* =========================================================================== |
| 373 | * Test deflate() with full flush |
| 374 | */ |
| 375 | void test_flush(compr, comprLen) |
| 376 | Byte *compr; |
| 377 | uLong *comprLen; |
| 378 | { |
| 379 | z_stream c_stream; /* compression stream */ |
| 380 | int err; |
| 381 | uInt len = (uInt)strlen(hello)+1; |
| 382 | |
| 383 | c_stream.zalloc = zalloc; |
| @@ -408,14 +362,11 @@ | |
| 408 | } |
| 409 | |
| 410 | /* =========================================================================== |
| 411 | * Test inflateSync() |
| 412 | */ |
| 413 | void test_sync(compr, comprLen, uncompr, uncomprLen) |
| 414 | Byte *compr, *uncompr; |
| 415 | uLong comprLen, uncomprLen; |
| 416 | { |
| 417 | int err; |
| 418 | z_stream d_stream; /* decompression stream */ |
| 419 | |
| 420 | strcpy((char*)uncompr, "garbage"); |
| 421 | |
| @@ -451,14 +402,11 @@ | |
| 451 | } |
| 452 | |
| 453 | /* =========================================================================== |
| 454 | * Test deflate() with preset dictionary |
| 455 | */ |
| 456 | void test_dict_deflate(compr, comprLen) |
| 457 | Byte *compr; |
| 458 | uLong comprLen; |
| 459 | { |
| 460 | z_stream c_stream; /* compression stream */ |
| 461 | int err; |
| 462 | |
| 463 | c_stream.zalloc = zalloc; |
| 464 | c_stream.zfree = zfree; |
| @@ -488,14 +436,12 @@ | |
| 488 | } |
| 489 | |
| 490 | /* =========================================================================== |
| 491 | * Test inflate() with a preset dictionary |
| 492 | */ |
| 493 | void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) |
| 494 | Byte *compr, *uncompr; |
| 495 | uLong comprLen, uncomprLen; |
| 496 | { |
| 497 | int err; |
| 498 | z_stream d_stream; /* decompression stream */ |
| 499 | |
| 500 | strcpy((char*)uncompr, "garbage"); |
| 501 | |
| @@ -539,17 +485,14 @@ | |
| 539 | |
| 540 | /* =========================================================================== |
| 541 | * Usage: example [output.gz [input.gz]] |
| 542 | */ |
| 543 | |
| 544 | int main(argc, argv) |
| 545 | int argc; |
| 546 | char *argv[]; |
| 547 | { |
| 548 | Byte *compr, *uncompr; |
| 549 | uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ |
| 550 | uLong uncomprLen = comprLen; |
| 551 | static const char* myVersion = ZLIB_VERSION; |
| 552 | |
| 553 | if (zlibVersion()[0] != myVersion[0]) { |
| 554 | fprintf(stderr, "incompatible zlib version\n"); |
| 555 | exit(1); |
| @@ -588,15 +531,15 @@ | |
| 588 | test_large_deflate(compr, comprLen, uncompr, uncomprLen); |
| 589 | test_large_inflate(compr, comprLen, uncompr, uncomprLen); |
| 590 | |
| 591 | test_flush(compr, &comprLen); |
| 592 | test_sync(compr, comprLen, uncompr, uncomprLen); |
| 593 | comprLen = uncomprLen; |
| 594 | |
| 595 | test_dict_deflate(compr, comprLen); |
| 596 | test_dict_inflate(compr, comprLen, uncompr, uncomprLen); |
| 597 | |
| 598 | free(compr); |
| 599 | free(uncompr); |
| 600 | |
| 601 | return 0; |
| 602 | } |
| 603 |
| --- compat/zlib/test/example.c | |
| +++ compat/zlib/test/example.c | |
| @@ -31,42 +31,19 @@ | |
| 31 | * stresses the compression code better, sorry... |
| 32 | */ |
| 33 | |
| 34 | static const char dictionary[] = "hello"; |
| 35 | static uLong dictId; /* Adler32 value of the dictionary */ |
| 36 | |
| 37 | #ifdef Z_SOLO |
| 38 | |
| 39 | void *myalloc(void *q, unsigned n, unsigned m) { |
| 40 | (void)q; |
| 41 | return calloc(n, m); |
| 42 | } |
| 43 | |
| 44 | void myfree(void *q, void *p) { |
| 45 | (void)q; |
| 46 | free(p); |
| 47 | } |
| 48 | |
| 49 | static alloc_func zalloc = myalloc; |
| @@ -75,22 +52,15 @@ | |
| 52 | #else /* !Z_SOLO */ |
| 53 | |
| 54 | static alloc_func zalloc = (alloc_func)0; |
| 55 | static free_func zfree = (free_func)0; |
| 56 | |
| 57 | /* =========================================================================== |
| 58 | * Test compress() and uncompress() |
| 59 | */ |
| 60 | void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, |
| 61 | uLong uncomprLen) { |
| 62 | int err; |
| 63 | uLong len = (uLong)strlen(hello)+1; |
| 64 | |
| 65 | err = compress(compr, &comprLen, (const Bytef*)hello, len); |
| 66 | CHECK_ERR(err, "compress"); |
| @@ -109,15 +79,11 @@ | |
| 79 | } |
| 80 | |
| 81 | /* =========================================================================== |
| 82 | * Test read/write of .gz files |
| 83 | */ |
| 84 | void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) { |
| 85 | #ifdef NO_GZCOMPRESS |
| 86 | fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); |
| 87 | #else |
| 88 | int err; |
| 89 | int len = (int)strlen(hello)+1; |
| @@ -195,14 +161,11 @@ | |
| 161 | #endif /* Z_SOLO */ |
| 162 | |
| 163 | /* =========================================================================== |
| 164 | * Test deflate() with small buffers |
| 165 | */ |
| 166 | void test_deflate(Byte *compr, uLong comprLen) { |
| 167 | z_stream c_stream; /* compression stream */ |
| 168 | int err; |
| 169 | uLong len = (uLong)strlen(hello)+1; |
| 170 | |
| 171 | c_stream.zalloc = zalloc; |
| @@ -233,14 +196,12 @@ | |
| 196 | } |
| 197 | |
| 198 | /* =========================================================================== |
| 199 | * Test inflate() with small buffers |
| 200 | */ |
| 201 | void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, |
| 202 | uLong uncomprLen) { |
| 203 | int err; |
| 204 | z_stream d_stream; /* decompression stream */ |
| 205 | |
| 206 | strcpy((char*)uncompr, "garbage"); |
| 207 | |
| @@ -274,14 +235,12 @@ | |
| 235 | } |
| 236 | |
| 237 | /* =========================================================================== |
| 238 | * Test deflate() with large buffers and dynamic change of compression level |
| 239 | */ |
| 240 | void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, |
| 241 | uLong uncomprLen) { |
| 242 | z_stream c_stream; /* compression stream */ |
| 243 | int err; |
| 244 | |
| 245 | c_stream.zalloc = zalloc; |
| 246 | c_stream.zfree = zfree; |
| @@ -306,11 +265,11 @@ | |
| 265 | } |
| 266 | |
| 267 | /* Feed in already compressed data and switch to no compression: */ |
| 268 | deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); |
| 269 | c_stream.next_in = compr; |
| 270 | c_stream.avail_in = (uInt)uncomprLen/2; |
| 271 | err = deflate(&c_stream, Z_NO_FLUSH); |
| 272 | CHECK_ERR(err, "deflate"); |
| 273 | |
| 274 | /* Switch back to compressing mode: */ |
| 275 | deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); |
| @@ -329,14 +288,12 @@ | |
| 288 | } |
| 289 | |
| 290 | /* =========================================================================== |
| 291 | * Test inflate() with large buffers |
| 292 | */ |
| 293 | void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, |
| 294 | uLong uncomprLen) { |
| 295 | int err; |
| 296 | z_stream d_stream; /* decompression stream */ |
| 297 | |
| 298 | strcpy((char*)uncompr, "garbage"); |
| 299 | |
| @@ -359,11 +316,11 @@ | |
| 316 | } |
| 317 | |
| 318 | err = inflateEnd(&d_stream); |
| 319 | CHECK_ERR(err, "inflateEnd"); |
| 320 | |
| 321 | if (d_stream.total_out != 2*uncomprLen + uncomprLen/2) { |
| 322 | fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); |
| 323 | exit(1); |
| 324 | } else { |
| 325 | printf("large_inflate(): OK\n"); |
| 326 | } |
| @@ -370,14 +327,11 @@ | |
| 327 | } |
| 328 | |
| 329 | /* =========================================================================== |
| 330 | * Test deflate() with full flush |
| 331 | */ |
| 332 | void test_flush(Byte *compr, uLong *comprLen) { |
| 333 | z_stream c_stream; /* compression stream */ |
| 334 | int err; |
| 335 | uInt len = (uInt)strlen(hello)+1; |
| 336 | |
| 337 | c_stream.zalloc = zalloc; |
| @@ -408,14 +362,11 @@ | |
| 362 | } |
| 363 | |
| 364 | /* =========================================================================== |
| 365 | * Test inflateSync() |
| 366 | */ |
| 367 | void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) { |
| 368 | int err; |
| 369 | z_stream d_stream; /* decompression stream */ |
| 370 | |
| 371 | strcpy((char*)uncompr, "garbage"); |
| 372 | |
| @@ -451,14 +402,11 @@ | |
| 402 | } |
| 403 | |
| 404 | /* =========================================================================== |
| 405 | * Test deflate() with preset dictionary |
| 406 | */ |
| 407 | void test_dict_deflate(Byte *compr, uLong comprLen) { |
| 408 | z_stream c_stream; /* compression stream */ |
| 409 | int err; |
| 410 | |
| 411 | c_stream.zalloc = zalloc; |
| 412 | c_stream.zfree = zfree; |
| @@ -488,14 +436,12 @@ | |
| 436 | } |
| 437 | |
| 438 | /* =========================================================================== |
| 439 | * Test inflate() with a preset dictionary |
| 440 | */ |
| 441 | void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, |
| 442 | uLong uncomprLen) { |
| 443 | int err; |
| 444 | z_stream d_stream; /* decompression stream */ |
| 445 | |
| 446 | strcpy((char*)uncompr, "garbage"); |
| 447 | |
| @@ -539,17 +485,14 @@ | |
| 485 | |
| 486 | /* =========================================================================== |
| 487 | * Usage: example [output.gz [input.gz]] |
| 488 | */ |
| 489 | |
| 490 | int main(int argc, char *argv[]) { |
| 491 | Byte *compr, *uncompr; |
| 492 | uLong uncomprLen = 20000; |
| 493 | uLong comprLen = 3 * uncomprLen; |
| 494 | static const char* myVersion = ZLIB_VERSION; |
| 495 | |
| 496 | if (zlibVersion()[0] != myVersion[0]) { |
| 497 | fprintf(stderr, "incompatible zlib version\n"); |
| 498 | exit(1); |
| @@ -588,15 +531,15 @@ | |
| 531 | test_large_deflate(compr, comprLen, uncompr, uncomprLen); |
| 532 | test_large_inflate(compr, comprLen, uncompr, uncomprLen); |
| 533 | |
| 534 | test_flush(compr, &comprLen); |
| 535 | test_sync(compr, comprLen, uncompr, uncomprLen); |
| 536 | comprLen = 3 * uncomprLen; |
| 537 | |
| 538 | test_dict_deflate(compr, comprLen); |
| 539 | test_dict_inflate(compr, comprLen, uncompr, uncomprLen); |
| 540 | |
| 541 | free(compr); |
| 542 | free(uncompr); |
| 543 | |
| 544 | return 0; |
| 545 | } |
| 546 |
+3
-2
| --- compat/zlib/test/infcover.c | ||
| +++ compat/zlib/test/infcover.c | ||
| @@ -371,11 +371,11 @@ | ||
| 371 | 371 | inf("", "bad window size", 0, 1, 0, Z_STREAM_ERROR); |
| 372 | 372 | |
| 373 | 373 | mem_setup(&strm); |
| 374 | 374 | strm.avail_in = 0; |
| 375 | 375 | strm.next_in = Z_NULL; |
| 376 | - ret = inflateInit_(&strm, ZLIB_VERSION - 1, (int)sizeof(z_stream)); | |
| 376 | + ret = inflateInit_(&strm, "!", (int)sizeof(z_stream)); | |
| 377 | 377 | assert(ret == Z_VERSION_ERROR); |
| 378 | 378 | mem_done(&strm, "wrong version"); |
| 379 | 379 | |
| 380 | 380 | strm.avail_in = 0; |
| 381 | 381 | strm.next_in = Z_NULL; |
| @@ -460,11 +460,12 @@ | ||
| 460 | 460 | return next < sizeof(dat) ? (*buf = dat + next++, 1) : 0; |
| 461 | 461 | } |
| 462 | 462 | |
| 463 | 463 | local int push(void *desc, unsigned char *buf, unsigned len) |
| 464 | 464 | { |
| 465 | - buf += len; | |
| 465 | + (void)buf; | |
| 466 | + (void)len; | |
| 466 | 467 | return desc != Z_NULL; /* force error if desc not null */ |
| 467 | 468 | } |
| 468 | 469 | |
| 469 | 470 | /* cover inflateBack() up to common deflate data cases and after those */ |
| 470 | 471 | local void cover_back(void) |
| 471 | 472 |
| --- compat/zlib/test/infcover.c | |
| +++ compat/zlib/test/infcover.c | |
| @@ -371,11 +371,11 @@ | |
| 371 | inf("", "bad window size", 0, 1, 0, Z_STREAM_ERROR); |
| 372 | |
| 373 | mem_setup(&strm); |
| 374 | strm.avail_in = 0; |
| 375 | strm.next_in = Z_NULL; |
| 376 | ret = inflateInit_(&strm, ZLIB_VERSION - 1, (int)sizeof(z_stream)); |
| 377 | assert(ret == Z_VERSION_ERROR); |
| 378 | mem_done(&strm, "wrong version"); |
| 379 | |
| 380 | strm.avail_in = 0; |
| 381 | strm.next_in = Z_NULL; |
| @@ -460,11 +460,12 @@ | |
| 460 | return next < sizeof(dat) ? (*buf = dat + next++, 1) : 0; |
| 461 | } |
| 462 | |
| 463 | local int push(void *desc, unsigned char *buf, unsigned len) |
| 464 | { |
| 465 | buf += len; |
| 466 | return desc != Z_NULL; /* force error if desc not null */ |
| 467 | } |
| 468 | |
| 469 | /* cover inflateBack() up to common deflate data cases and after those */ |
| 470 | local void cover_back(void) |
| 471 |
| --- compat/zlib/test/infcover.c | |
| +++ compat/zlib/test/infcover.c | |
| @@ -371,11 +371,11 @@ | |
| 371 | inf("", "bad window size", 0, 1, 0, Z_STREAM_ERROR); |
| 372 | |
| 373 | mem_setup(&strm); |
| 374 | strm.avail_in = 0; |
| 375 | strm.next_in = Z_NULL; |
| 376 | ret = inflateInit_(&strm, "!", (int)sizeof(z_stream)); |
| 377 | assert(ret == Z_VERSION_ERROR); |
| 378 | mem_done(&strm, "wrong version"); |
| 379 | |
| 380 | strm.avail_in = 0; |
| 381 | strm.next_in = Z_NULL; |
| @@ -460,11 +460,12 @@ | |
| 460 | return next < sizeof(dat) ? (*buf = dat + next++, 1) : 0; |
| 461 | } |
| 462 | |
| 463 | local int push(void *desc, unsigned char *buf, unsigned len) |
| 464 | { |
| 465 | (void)buf; |
| 466 | (void)len; |
| 467 | return desc != Z_NULL; /* force error if desc not null */ |
| 468 | } |
| 469 | |
| 470 | /* cover inflateBack() up to common deflate data cases and after those */ |
| 471 | local void cover_back(void) |
| 472 |
+50
-122
| --- compat/zlib/test/minigzip.c | ||
| +++ compat/zlib/test/minigzip.c | ||
| @@ -57,11 +57,11 @@ | ||
| 57 | 57 | # include <unix.h> /* for fileno */ |
| 58 | 58 | #endif |
| 59 | 59 | |
| 60 | 60 | #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) |
| 61 | 61 | #ifndef WIN32 /* unlink already in stdio.h for WIN32 */ |
| 62 | - extern int unlink OF((const char *)); | |
| 62 | + extern int unlink(const char *); | |
| 63 | 63 | #endif |
| 64 | 64 | #endif |
| 65 | 65 | |
| 66 | 66 | #if defined(UNDER_CE) |
| 67 | 67 | # include <windows.h> |
| @@ -147,24 +147,16 @@ | ||
| 147 | 147 | |
| 148 | 148 | #if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE) |
| 149 | 149 | # include <unistd.h> /* for unlink() */ |
| 150 | 150 | #endif |
| 151 | 151 | |
| 152 | -void *myalloc OF((void *, unsigned, unsigned)); | |
| 153 | -void myfree OF((void *, void *)); | |
| 154 | - | |
| 155 | -void *myalloc(q, n, m) | |
| 156 | - void *q; | |
| 157 | - unsigned n, m; | |
| 158 | -{ | |
| 152 | +void *myalloc(void *q, unsigned n, unsigned m) { | |
| 159 | 153 | (void)q; |
| 160 | 154 | return calloc(n, m); |
| 161 | 155 | } |
| 162 | 156 | |
| 163 | -void myfree(q, p) | |
| 164 | - void *q, *p; | |
| 165 | -{ | |
| 157 | +void myfree(void *q, void *p) { | |
| 166 | 158 | (void)q; |
| 167 | 159 | free(p); |
| 168 | 160 | } |
| 169 | 161 | |
| 170 | 162 | typedef struct gzFile_s { |
| @@ -173,33 +165,11 @@ | ||
| 173 | 165 | int err; |
| 174 | 166 | char *msg; |
| 175 | 167 | z_stream strm; |
| 176 | 168 | } *gzFile; |
| 177 | 169 | |
| 178 | -gzFile gzopen OF((const char *, const char *)); | |
| 179 | -gzFile gzdopen OF((int, const char *)); | |
| 180 | -gzFile gz_open OF((const char *, int, const char *)); | |
| 181 | - | |
| 182 | -gzFile gzopen(path, mode) | |
| 183 | -const char *path; | |
| 184 | -const char *mode; | |
| 185 | -{ | |
| 186 | - return gz_open(path, -1, mode); | |
| 187 | -} | |
| 188 | - | |
| 189 | -gzFile gzdopen(fd, mode) | |
| 190 | -int fd; | |
| 191 | -const char *mode; | |
| 192 | -{ | |
| 193 | - return gz_open(NULL, fd, mode); | |
| 194 | -} | |
| 195 | - | |
| 196 | -gzFile gz_open(path, fd, mode) | |
| 197 | - const char *path; | |
| 198 | - int fd; | |
| 199 | - const char *mode; | |
| 200 | -{ | |
| 170 | +gzFile gz_open(const char *path, int fd, const char *mode) { | |
| 201 | 171 | gzFile gz; |
| 202 | 172 | int ret; |
| 203 | 173 | |
| 204 | 174 | gz = malloc(sizeof(struct gzFile_s)); |
| 205 | 175 | if (gz == NULL) |
| @@ -229,17 +199,19 @@ | ||
| 229 | 199 | gz->err = 0; |
| 230 | 200 | gz->msg = ""; |
| 231 | 201 | return gz; |
| 232 | 202 | } |
| 233 | 203 | |
| 234 | -int gzwrite OF((gzFile, const void *, unsigned)); | |
| 204 | +gzFile gzopen(const char *path, const char *mode) { | |
| 205 | + return gz_open(path, -1, mode); | |
| 206 | +} | |
| 207 | + | |
| 208 | +gzFile gzdopen(int fd, const char *mode) { | |
| 209 | + return gz_open(NULL, fd, mode); | |
| 210 | +} | |
| 235 | 211 | |
| 236 | -int gzwrite(gz, buf, len) | |
| 237 | - gzFile gz; | |
| 238 | - const void *buf; | |
| 239 | - unsigned len; | |
| 240 | -{ | |
| 212 | +int gzwrite(gzFile gz, const void *buf, unsigned len) { | |
| 241 | 213 | z_stream *strm; |
| 242 | 214 | unsigned char out[BUFLEN]; |
| 243 | 215 | |
| 244 | 216 | if (gz == NULL || !gz->write) |
| 245 | 217 | return 0; |
| @@ -253,17 +225,11 @@ | ||
| 253 | 225 | fwrite(out, 1, BUFLEN - strm->avail_out, gz->file); |
| 254 | 226 | } while (strm->avail_out == 0); |
| 255 | 227 | return len; |
| 256 | 228 | } |
| 257 | 229 | |
| 258 | -int gzread OF((gzFile, void *, unsigned)); | |
| 259 | - | |
| 260 | -int gzread(gz, buf, len) | |
| 261 | - gzFile gz; | |
| 262 | - void *buf; | |
| 263 | - unsigned len; | |
| 264 | -{ | |
| 230 | +int gzread(gzFile gz, void *buf, unsigned len) { | |
| 265 | 231 | int ret; |
| 266 | 232 | unsigned got; |
| 267 | 233 | unsigned char in[1]; |
| 268 | 234 | z_stream *strm; |
| 269 | 235 | |
| @@ -290,15 +256,11 @@ | ||
| 290 | 256 | inflateReset(strm); |
| 291 | 257 | } while (strm->avail_out); |
| 292 | 258 | return len - strm->avail_out; |
| 293 | 259 | } |
| 294 | 260 | |
| 295 | -int gzclose OF((gzFile)); | |
| 296 | - | |
| 297 | -int gzclose(gz) | |
| 298 | - gzFile gz; | |
| 299 | -{ | |
| 261 | +int gzclose(gzFile gz) { | |
| 300 | 262 | z_stream *strm; |
| 301 | 263 | unsigned char out[BUFLEN]; |
| 302 | 264 | |
| 303 | 265 | if (gz == NULL) |
| 304 | 266 | return Z_STREAM_ERROR; |
| @@ -319,85 +281,33 @@ | ||
| 319 | 281 | fclose(gz->file); |
| 320 | 282 | free(gz); |
| 321 | 283 | return Z_OK; |
| 322 | 284 | } |
| 323 | 285 | |
| 324 | -const char *gzerror OF((gzFile, int *)); | |
| 325 | - | |
| 326 | -const char *gzerror(gz, err) | |
| 327 | - gzFile gz; | |
| 328 | - int *err; | |
| 329 | -{ | |
| 286 | +const char *gzerror(gzFile gz, int *err) { | |
| 330 | 287 | *err = gz->err; |
| 331 | 288 | return gz->msg; |
| 332 | 289 | } |
| 333 | 290 | |
| 334 | 291 | #endif |
| 335 | 292 | |
| 336 | 293 | static char *prog; |
| 337 | 294 | |
| 338 | -void error OF((const char *msg)); | |
| 339 | -void gz_compress OF((FILE *in, gzFile out)); | |
| 340 | -#ifdef USE_MMAP | |
| 341 | -int gz_compress_mmap OF((FILE *in, gzFile out)); | |
| 342 | -#endif | |
| 343 | -void gz_uncompress OF((gzFile in, FILE *out)); | |
| 344 | -void file_compress OF((char *file, char *mode)); | |
| 345 | -void file_uncompress OF((char *file)); | |
| 346 | -int main OF((int argc, char *argv[])); | |
| 347 | - | |
| 348 | 295 | /* =========================================================================== |
| 349 | 296 | * Display error message and exit |
| 350 | 297 | */ |
| 351 | -void error(msg) | |
| 352 | - const char *msg; | |
| 353 | -{ | |
| 298 | +void error(const char *msg) { | |
| 354 | 299 | fprintf(stderr, "%s: %s\n", prog, msg); |
| 355 | 300 | exit(1); |
| 356 | 301 | } |
| 357 | 302 | |
| 358 | -/* =========================================================================== | |
| 359 | - * Compress input to output then close both files. | |
| 360 | - */ | |
| 361 | - | |
| 362 | -void gz_compress(in, out) | |
| 363 | - FILE *in; | |
| 364 | - gzFile out; | |
| 365 | -{ | |
| 366 | - local char buf[BUFLEN]; | |
| 367 | - int len; | |
| 368 | - int err; | |
| 369 | - | |
| 370 | -#ifdef USE_MMAP | |
| 371 | - /* Try first compressing with mmap. If mmap fails (minigzip used in a | |
| 372 | - * pipe), use the normal fread loop. | |
| 373 | - */ | |
| 374 | - if (gz_compress_mmap(in, out) == Z_OK) return; | |
| 375 | -#endif | |
| 376 | - for (;;) { | |
| 377 | - len = (int)fread(buf, 1, sizeof(buf), in); | |
| 378 | - if (ferror(in)) { | |
| 379 | - perror("fread"); | |
| 380 | - exit(1); | |
| 381 | - } | |
| 382 | - if (len == 0) break; | |
| 383 | - | |
| 384 | - if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); | |
| 385 | - } | |
| 386 | - fclose(in); | |
| 387 | - if (gzclose(out) != Z_OK) error("failed gzclose"); | |
| 388 | -} | |
| 389 | - | |
| 390 | 303 | #ifdef USE_MMAP /* MMAP version, Miguel Albrecht <[email protected]> */ |
| 391 | 304 | |
| 392 | 305 | /* Try compressing the input file at once using mmap. Return Z_OK if |
| 393 | 306 | * if success, Z_ERRNO otherwise. |
| 394 | 307 | */ |
| 395 | -int gz_compress_mmap(in, out) | |
| 396 | - FILE *in; | |
| 397 | - gzFile out; | |
| 398 | -{ | |
| 308 | +int gz_compress_mmap(FILE *in, gzFile out) { | |
| 399 | 309 | int len; |
| 400 | 310 | int err; |
| 401 | 311 | int ifd = fileno(in); |
| 402 | 312 | caddr_t buf; /* mmap'ed buffer for the entire input file */ |
| 403 | 313 | off_t buf_len; /* length of the input file */ |
| @@ -421,18 +331,44 @@ | ||
| 421 | 331 | fclose(in); |
| 422 | 332 | if (gzclose(out) != Z_OK) error("failed gzclose"); |
| 423 | 333 | return Z_OK; |
| 424 | 334 | } |
| 425 | 335 | #endif /* USE_MMAP */ |
| 336 | + | |
| 337 | +/* =========================================================================== | |
| 338 | + * Compress input to output then close both files. | |
| 339 | + */ | |
| 340 | + | |
| 341 | +void gz_compress(FILE *in, gzFile out) { | |
| 342 | + local char buf[BUFLEN]; | |
| 343 | + int len; | |
| 344 | + int err; | |
| 345 | + | |
| 346 | +#ifdef USE_MMAP | |
| 347 | + /* Try first compressing with mmap. If mmap fails (minigzip used in a | |
| 348 | + * pipe), use the normal fread loop. | |
| 349 | + */ | |
| 350 | + if (gz_compress_mmap(in, out) == Z_OK) return; | |
| 351 | +#endif | |
| 352 | + for (;;) { | |
| 353 | + len = (int)fread(buf, 1, sizeof(buf), in); | |
| 354 | + if (ferror(in)) { | |
| 355 | + perror("fread"); | |
| 356 | + exit(1); | |
| 357 | + } | |
| 358 | + if (len == 0) break; | |
| 359 | + | |
| 360 | + if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); | |
| 361 | + } | |
| 362 | + fclose(in); | |
| 363 | + if (gzclose(out) != Z_OK) error("failed gzclose"); | |
| 364 | +} | |
| 426 | 365 | |
| 427 | 366 | /* =========================================================================== |
| 428 | 367 | * Uncompress input to output then close both files. |
| 429 | 368 | */ |
| 430 | -void gz_uncompress(in, out) | |
| 431 | - gzFile in; | |
| 432 | - FILE *out; | |
| 433 | -{ | |
| 369 | +void gz_uncompress(gzFile in, FILE *out) { | |
| 434 | 370 | local char buf[BUFLEN]; |
| 435 | 371 | int len; |
| 436 | 372 | int err; |
| 437 | 373 | |
| 438 | 374 | for (;;) { |
| @@ -452,14 +388,11 @@ | ||
| 452 | 388 | |
| 453 | 389 | /* =========================================================================== |
| 454 | 390 | * Compress the given file: create a corresponding .gz file and remove the |
| 455 | 391 | * original. |
| 456 | 392 | */ |
| 457 | -void file_compress(file, mode) | |
| 458 | - char *file; | |
| 459 | - char *mode; | |
| 460 | -{ | |
| 393 | +void file_compress(char *file, char *mode) { | |
| 461 | 394 | local char outfile[MAX_NAME_LEN]; |
| 462 | 395 | FILE *in; |
| 463 | 396 | gzFile out; |
| 464 | 397 | |
| 465 | 398 | if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) { |
| @@ -491,13 +424,11 @@ | ||
| 491 | 424 | |
| 492 | 425 | |
| 493 | 426 | /* =========================================================================== |
| 494 | 427 | * Uncompress the given file and remove the original. |
| 495 | 428 | */ |
| 496 | -void file_uncompress(file) | |
| 497 | - char *file; | |
| 498 | -{ | |
| 429 | +void file_uncompress(char *file) { | |
| 499 | 430 | local char buf[MAX_NAME_LEN]; |
| 500 | 431 | char *infile, *outfile; |
| 501 | 432 | FILE *out; |
| 502 | 433 | gzFile in; |
| 503 | 434 | z_size_t len = strlen(file); |
| @@ -551,14 +482,11 @@ | ||
| 551 | 482 | * -h : compress with Z_HUFFMAN_ONLY |
| 552 | 483 | * -r : compress with Z_RLE |
| 553 | 484 | * -1 to -9 : compression level |
| 554 | 485 | */ |
| 555 | 486 | |
| 556 | -int main(argc, argv) | |
| 557 | - int argc; | |
| 558 | - char *argv[]; | |
| 559 | -{ | |
| 487 | +int main(int argc, char *argv[]) { | |
| 560 | 488 | int copyout = 0; |
| 561 | 489 | int uncompr = 0; |
| 562 | 490 | gzFile file; |
| 563 | 491 | char *bname, outmode[20]; |
| 564 | 492 | |
| 565 | 493 |
| --- compat/zlib/test/minigzip.c | |
| +++ compat/zlib/test/minigzip.c | |
| @@ -57,11 +57,11 @@ | |
| 57 | # include <unix.h> /* for fileno */ |
| 58 | #endif |
| 59 | |
| 60 | #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) |
| 61 | #ifndef WIN32 /* unlink already in stdio.h for WIN32 */ |
| 62 | extern int unlink OF((const char *)); |
| 63 | #endif |
| 64 | #endif |
| 65 | |
| 66 | #if defined(UNDER_CE) |
| 67 | # include <windows.h> |
| @@ -147,24 +147,16 @@ | |
| 147 | |
| 148 | #if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE) |
| 149 | # include <unistd.h> /* for unlink() */ |
| 150 | #endif |
| 151 | |
| 152 | void *myalloc OF((void *, unsigned, unsigned)); |
| 153 | void myfree OF((void *, void *)); |
| 154 | |
| 155 | void *myalloc(q, n, m) |
| 156 | void *q; |
| 157 | unsigned n, m; |
| 158 | { |
| 159 | (void)q; |
| 160 | return calloc(n, m); |
| 161 | } |
| 162 | |
| 163 | void myfree(q, p) |
| 164 | void *q, *p; |
| 165 | { |
| 166 | (void)q; |
| 167 | free(p); |
| 168 | } |
| 169 | |
| 170 | typedef struct gzFile_s { |
| @@ -173,33 +165,11 @@ | |
| 173 | int err; |
| 174 | char *msg; |
| 175 | z_stream strm; |
| 176 | } *gzFile; |
| 177 | |
| 178 | gzFile gzopen OF((const char *, const char *)); |
| 179 | gzFile gzdopen OF((int, const char *)); |
| 180 | gzFile gz_open OF((const char *, int, const char *)); |
| 181 | |
| 182 | gzFile gzopen(path, mode) |
| 183 | const char *path; |
| 184 | const char *mode; |
| 185 | { |
| 186 | return gz_open(path, -1, mode); |
| 187 | } |
| 188 | |
| 189 | gzFile gzdopen(fd, mode) |
| 190 | int fd; |
| 191 | const char *mode; |
| 192 | { |
| 193 | return gz_open(NULL, fd, mode); |
| 194 | } |
| 195 | |
| 196 | gzFile gz_open(path, fd, mode) |
| 197 | const char *path; |
| 198 | int fd; |
| 199 | const char *mode; |
| 200 | { |
| 201 | gzFile gz; |
| 202 | int ret; |
| 203 | |
| 204 | gz = malloc(sizeof(struct gzFile_s)); |
| 205 | if (gz == NULL) |
| @@ -229,17 +199,19 @@ | |
| 229 | gz->err = 0; |
| 230 | gz->msg = ""; |
| 231 | return gz; |
| 232 | } |
| 233 | |
| 234 | int gzwrite OF((gzFile, const void *, unsigned)); |
| 235 | |
| 236 | int gzwrite(gz, buf, len) |
| 237 | gzFile gz; |
| 238 | const void *buf; |
| 239 | unsigned len; |
| 240 | { |
| 241 | z_stream *strm; |
| 242 | unsigned char out[BUFLEN]; |
| 243 | |
| 244 | if (gz == NULL || !gz->write) |
| 245 | return 0; |
| @@ -253,17 +225,11 @@ | |
| 253 | fwrite(out, 1, BUFLEN - strm->avail_out, gz->file); |
| 254 | } while (strm->avail_out == 0); |
| 255 | return len; |
| 256 | } |
| 257 | |
| 258 | int gzread OF((gzFile, void *, unsigned)); |
| 259 | |
| 260 | int gzread(gz, buf, len) |
| 261 | gzFile gz; |
| 262 | void *buf; |
| 263 | unsigned len; |
| 264 | { |
| 265 | int ret; |
| 266 | unsigned got; |
| 267 | unsigned char in[1]; |
| 268 | z_stream *strm; |
| 269 | |
| @@ -290,15 +256,11 @@ | |
| 290 | inflateReset(strm); |
| 291 | } while (strm->avail_out); |
| 292 | return len - strm->avail_out; |
| 293 | } |
| 294 | |
| 295 | int gzclose OF((gzFile)); |
| 296 | |
| 297 | int gzclose(gz) |
| 298 | gzFile gz; |
| 299 | { |
| 300 | z_stream *strm; |
| 301 | unsigned char out[BUFLEN]; |
| 302 | |
| 303 | if (gz == NULL) |
| 304 | return Z_STREAM_ERROR; |
| @@ -319,85 +281,33 @@ | |
| 319 | fclose(gz->file); |
| 320 | free(gz); |
| 321 | return Z_OK; |
| 322 | } |
| 323 | |
| 324 | const char *gzerror OF((gzFile, int *)); |
| 325 | |
| 326 | const char *gzerror(gz, err) |
| 327 | gzFile gz; |
| 328 | int *err; |
| 329 | { |
| 330 | *err = gz->err; |
| 331 | return gz->msg; |
| 332 | } |
| 333 | |
| 334 | #endif |
| 335 | |
| 336 | static char *prog; |
| 337 | |
| 338 | void error OF((const char *msg)); |
| 339 | void gz_compress OF((FILE *in, gzFile out)); |
| 340 | #ifdef USE_MMAP |
| 341 | int gz_compress_mmap OF((FILE *in, gzFile out)); |
| 342 | #endif |
| 343 | void gz_uncompress OF((gzFile in, FILE *out)); |
| 344 | void file_compress OF((char *file, char *mode)); |
| 345 | void file_uncompress OF((char *file)); |
| 346 | int main OF((int argc, char *argv[])); |
| 347 | |
| 348 | /* =========================================================================== |
| 349 | * Display error message and exit |
| 350 | */ |
| 351 | void error(msg) |
| 352 | const char *msg; |
| 353 | { |
| 354 | fprintf(stderr, "%s: %s\n", prog, msg); |
| 355 | exit(1); |
| 356 | } |
| 357 | |
| 358 | /* =========================================================================== |
| 359 | * Compress input to output then close both files. |
| 360 | */ |
| 361 | |
| 362 | void gz_compress(in, out) |
| 363 | FILE *in; |
| 364 | gzFile out; |
| 365 | { |
| 366 | local char buf[BUFLEN]; |
| 367 | int len; |
| 368 | int err; |
| 369 | |
| 370 | #ifdef USE_MMAP |
| 371 | /* Try first compressing with mmap. If mmap fails (minigzip used in a |
| 372 | * pipe), use the normal fread loop. |
| 373 | */ |
| 374 | if (gz_compress_mmap(in, out) == Z_OK) return; |
| 375 | #endif |
| 376 | for (;;) { |
| 377 | len = (int)fread(buf, 1, sizeof(buf), in); |
| 378 | if (ferror(in)) { |
| 379 | perror("fread"); |
| 380 | exit(1); |
| 381 | } |
| 382 | if (len == 0) break; |
| 383 | |
| 384 | if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); |
| 385 | } |
| 386 | fclose(in); |
| 387 | if (gzclose(out) != Z_OK) error("failed gzclose"); |
| 388 | } |
| 389 | |
| 390 | #ifdef USE_MMAP /* MMAP version, Miguel Albrecht <[email protected]> */ |
| 391 | |
| 392 | /* Try compressing the input file at once using mmap. Return Z_OK if |
| 393 | * if success, Z_ERRNO otherwise. |
| 394 | */ |
| 395 | int gz_compress_mmap(in, out) |
| 396 | FILE *in; |
| 397 | gzFile out; |
| 398 | { |
| 399 | int len; |
| 400 | int err; |
| 401 | int ifd = fileno(in); |
| 402 | caddr_t buf; /* mmap'ed buffer for the entire input file */ |
| 403 | off_t buf_len; /* length of the input file */ |
| @@ -421,18 +331,44 @@ | |
| 421 | fclose(in); |
| 422 | if (gzclose(out) != Z_OK) error("failed gzclose"); |
| 423 | return Z_OK; |
| 424 | } |
| 425 | #endif /* USE_MMAP */ |
| 426 | |
| 427 | /* =========================================================================== |
| 428 | * Uncompress input to output then close both files. |
| 429 | */ |
| 430 | void gz_uncompress(in, out) |
| 431 | gzFile in; |
| 432 | FILE *out; |
| 433 | { |
| 434 | local char buf[BUFLEN]; |
| 435 | int len; |
| 436 | int err; |
| 437 | |
| 438 | for (;;) { |
| @@ -452,14 +388,11 @@ | |
| 452 | |
| 453 | /* =========================================================================== |
| 454 | * Compress the given file: create a corresponding .gz file and remove the |
| 455 | * original. |
| 456 | */ |
| 457 | void file_compress(file, mode) |
| 458 | char *file; |
| 459 | char *mode; |
| 460 | { |
| 461 | local char outfile[MAX_NAME_LEN]; |
| 462 | FILE *in; |
| 463 | gzFile out; |
| 464 | |
| 465 | if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) { |
| @@ -491,13 +424,11 @@ | |
| 491 | |
| 492 | |
| 493 | /* =========================================================================== |
| 494 | * Uncompress the given file and remove the original. |
| 495 | */ |
| 496 | void file_uncompress(file) |
| 497 | char *file; |
| 498 | { |
| 499 | local char buf[MAX_NAME_LEN]; |
| 500 | char *infile, *outfile; |
| 501 | FILE *out; |
| 502 | gzFile in; |
| 503 | z_size_t len = strlen(file); |
| @@ -551,14 +482,11 @@ | |
| 551 | * -h : compress with Z_HUFFMAN_ONLY |
| 552 | * -r : compress with Z_RLE |
| 553 | * -1 to -9 : compression level |
| 554 | */ |
| 555 | |
| 556 | int main(argc, argv) |
| 557 | int argc; |
| 558 | char *argv[]; |
| 559 | { |
| 560 | int copyout = 0; |
| 561 | int uncompr = 0; |
| 562 | gzFile file; |
| 563 | char *bname, outmode[20]; |
| 564 | |
| 565 |
| --- compat/zlib/test/minigzip.c | |
| +++ compat/zlib/test/minigzip.c | |
| @@ -57,11 +57,11 @@ | |
| 57 | # include <unix.h> /* for fileno */ |
| 58 | #endif |
| 59 | |
| 60 | #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) |
| 61 | #ifndef WIN32 /* unlink already in stdio.h for WIN32 */ |
| 62 | extern int unlink(const char *); |
| 63 | #endif |
| 64 | #endif |
| 65 | |
| 66 | #if defined(UNDER_CE) |
| 67 | # include <windows.h> |
| @@ -147,24 +147,16 @@ | |
| 147 | |
| 148 | #if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE) |
| 149 | # include <unistd.h> /* for unlink() */ |
| 150 | #endif |
| 151 | |
| 152 | void *myalloc(void *q, unsigned n, unsigned m) { |
| 153 | (void)q; |
| 154 | return calloc(n, m); |
| 155 | } |
| 156 | |
| 157 | void myfree(void *q, void *p) { |
| 158 | (void)q; |
| 159 | free(p); |
| 160 | } |
| 161 | |
| 162 | typedef struct gzFile_s { |
| @@ -173,33 +165,11 @@ | |
| 165 | int err; |
| 166 | char *msg; |
| 167 | z_stream strm; |
| 168 | } *gzFile; |
| 169 | |
| 170 | gzFile gz_open(const char *path, int fd, const char *mode) { |
| 171 | gzFile gz; |
| 172 | int ret; |
| 173 | |
| 174 | gz = malloc(sizeof(struct gzFile_s)); |
| 175 | if (gz == NULL) |
| @@ -229,17 +199,19 @@ | |
| 199 | gz->err = 0; |
| 200 | gz->msg = ""; |
| 201 | return gz; |
| 202 | } |
| 203 | |
| 204 | gzFile gzopen(const char *path, const char *mode) { |
| 205 | return gz_open(path, -1, mode); |
| 206 | } |
| 207 | |
| 208 | gzFile gzdopen(int fd, const char *mode) { |
| 209 | return gz_open(NULL, fd, mode); |
| 210 | } |
| 211 | |
| 212 | int gzwrite(gzFile gz, const void *buf, unsigned len) { |
| 213 | z_stream *strm; |
| 214 | unsigned char out[BUFLEN]; |
| 215 | |
| 216 | if (gz == NULL || !gz->write) |
| 217 | return 0; |
| @@ -253,17 +225,11 @@ | |
| 225 | fwrite(out, 1, BUFLEN - strm->avail_out, gz->file); |
| 226 | } while (strm->avail_out == 0); |
| 227 | return len; |
| 228 | } |
| 229 | |
| 230 | int gzread(gzFile gz, void *buf, unsigned len) { |
| 231 | int ret; |
| 232 | unsigned got; |
| 233 | unsigned char in[1]; |
| 234 | z_stream *strm; |
| 235 | |
| @@ -290,15 +256,11 @@ | |
| 256 | inflateReset(strm); |
| 257 | } while (strm->avail_out); |
| 258 | return len - strm->avail_out; |
| 259 | } |
| 260 | |
| 261 | int gzclose(gzFile gz) { |
| 262 | z_stream *strm; |
| 263 | unsigned char out[BUFLEN]; |
| 264 | |
| 265 | if (gz == NULL) |
| 266 | return Z_STREAM_ERROR; |
| @@ -319,85 +281,33 @@ | |
| 281 | fclose(gz->file); |
| 282 | free(gz); |
| 283 | return Z_OK; |
| 284 | } |
| 285 | |
| 286 | const char *gzerror(gzFile gz, int *err) { |
| 287 | *err = gz->err; |
| 288 | return gz->msg; |
| 289 | } |
| 290 | |
| 291 | #endif |
| 292 | |
| 293 | static char *prog; |
| 294 | |
| 295 | /* =========================================================================== |
| 296 | * Display error message and exit |
| 297 | */ |
| 298 | void error(const char *msg) { |
| 299 | fprintf(stderr, "%s: %s\n", prog, msg); |
| 300 | exit(1); |
| 301 | } |
| 302 | |
| 303 | #ifdef USE_MMAP /* MMAP version, Miguel Albrecht <[email protected]> */ |
| 304 | |
| 305 | /* Try compressing the input file at once using mmap. Return Z_OK if |
| 306 | * if success, Z_ERRNO otherwise. |
| 307 | */ |
| 308 | int gz_compress_mmap(FILE *in, gzFile out) { |
| 309 | int len; |
| 310 | int err; |
| 311 | int ifd = fileno(in); |
| 312 | caddr_t buf; /* mmap'ed buffer for the entire input file */ |
| 313 | off_t buf_len; /* length of the input file */ |
| @@ -421,18 +331,44 @@ | |
| 331 | fclose(in); |
| 332 | if (gzclose(out) != Z_OK) error("failed gzclose"); |
| 333 | return Z_OK; |
| 334 | } |
| 335 | #endif /* USE_MMAP */ |
| 336 | |
| 337 | /* =========================================================================== |
| 338 | * Compress input to output then close both files. |
| 339 | */ |
| 340 | |
| 341 | void gz_compress(FILE *in, gzFile out) { |
| 342 | local char buf[BUFLEN]; |
| 343 | int len; |
| 344 | int err; |
| 345 | |
| 346 | #ifdef USE_MMAP |
| 347 | /* Try first compressing with mmap. If mmap fails (minigzip used in a |
| 348 | * pipe), use the normal fread loop. |
| 349 | */ |
| 350 | if (gz_compress_mmap(in, out) == Z_OK) return; |
| 351 | #endif |
| 352 | for (;;) { |
| 353 | len = (int)fread(buf, 1, sizeof(buf), in); |
| 354 | if (ferror(in)) { |
| 355 | perror("fread"); |
| 356 | exit(1); |
| 357 | } |
| 358 | if (len == 0) break; |
| 359 | |
| 360 | if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); |
| 361 | } |
| 362 | fclose(in); |
| 363 | if (gzclose(out) != Z_OK) error("failed gzclose"); |
| 364 | } |
| 365 | |
| 366 | /* =========================================================================== |
| 367 | * Uncompress input to output then close both files. |
| 368 | */ |
| 369 | void gz_uncompress(gzFile in, FILE *out) { |
| 370 | local char buf[BUFLEN]; |
| 371 | int len; |
| 372 | int err; |
| 373 | |
| 374 | for (;;) { |
| @@ -452,14 +388,11 @@ | |
| 388 | |
| 389 | /* =========================================================================== |
| 390 | * Compress the given file: create a corresponding .gz file and remove the |
| 391 | * original. |
| 392 | */ |
| 393 | void file_compress(char *file, char *mode) { |
| 394 | local char outfile[MAX_NAME_LEN]; |
| 395 | FILE *in; |
| 396 | gzFile out; |
| 397 | |
| 398 | if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) { |
| @@ -491,13 +424,11 @@ | |
| 424 | |
| 425 | |
| 426 | /* =========================================================================== |
| 427 | * Uncompress the given file and remove the original. |
| 428 | */ |
| 429 | void file_uncompress(char *file) { |
| 430 | local char buf[MAX_NAME_LEN]; |
| 431 | char *infile, *outfile; |
| 432 | FILE *out; |
| 433 | gzFile in; |
| 434 | z_size_t len = strlen(file); |
| @@ -551,14 +482,11 @@ | |
| 482 | * -h : compress with Z_HUFFMAN_ONLY |
| 483 | * -r : compress with Z_RLE |
| 484 | * -1 to -9 : compression level |
| 485 | */ |
| 486 | |
| 487 | int main(int argc, char *argv[]) { |
| 488 | int copyout = 0; |
| 489 | int uncompr = 0; |
| 490 | gzFile file; |
| 491 | char *bname, outmode[20]; |
| 492 | |
| 493 |
+2
-2
| --- compat/zlib/treebuild.xml | ||
| +++ compat/zlib/treebuild.xml | ||
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?xml version="1.0" ?> |
| 2 | -<package name="zlib" version="1.2.13"> | |
| 3 | - <library name="zlib" dlversion="1.2.13" dlname="z"> | |
| 2 | +<package name="zlib" version="1.3"> | |
| 3 | + <library name="zlib" dlversion="1.3" dlname="z"> | |
| 4 | 4 | <property name="description"> zip compression library </property> |
| 5 | 5 | <property name="include-target-dir" value="$(@PACKAGE/install-includedir)" /> |
| 6 | 6 | |
| 7 | 7 | <!-- fixme: not implemented yet --> |
| 8 | 8 | <property name="compiler/c/inline" value="yes" /> |
| 9 | 9 |
| --- compat/zlib/treebuild.xml | |
| +++ compat/zlib/treebuild.xml | |
| @@ -1,8 +1,8 @@ | |
| 1 | <?xml version="1.0" ?> |
| 2 | <package name="zlib" version="1.2.13"> |
| 3 | <library name="zlib" dlversion="1.2.13" dlname="z"> |
| 4 | <property name="description"> zip compression library </property> |
| 5 | <property name="include-target-dir" value="$(@PACKAGE/install-includedir)" /> |
| 6 | |
| 7 | <!-- fixme: not implemented yet --> |
| 8 | <property name="compiler/c/inline" value="yes" /> |
| 9 |
| --- compat/zlib/treebuild.xml | |
| +++ compat/zlib/treebuild.xml | |
| @@ -1,8 +1,8 @@ | |
| 1 | <?xml version="1.0" ?> |
| 2 | <package name="zlib" version="1.3"> |
| 3 | <library name="zlib" dlversion="1.3" dlname="z"> |
| 4 | <property name="description"> zip compression library </property> |
| 5 | <property name="include-target-dir" value="$(@PACKAGE/install-includedir)" /> |
| 6 | |
| 7 | <!-- fixme: not implemented yet --> |
| 8 | <property name="compiler/c/inline" value="yes" /> |
| 9 |
+225
-303
| --- compat/zlib/trees.c | ||
| +++ compat/zlib/trees.c | ||
| @@ -120,43 +120,120 @@ | ||
| 120 | 120 | int extra_base; /* base index for extra_bits */ |
| 121 | 121 | int elems; /* max number of elements in the tree */ |
| 122 | 122 | int max_length; /* max bit length for the codes */ |
| 123 | 123 | }; |
| 124 | 124 | |
| 125 | -local const static_tree_desc static_l_desc = | |
| 125 | +#ifdef NO_INIT_GLOBAL_POINTERS | |
| 126 | +# define TCONST | |
| 127 | +#else | |
| 128 | +# define TCONST const | |
| 129 | +#endif | |
| 130 | + | |
| 131 | +local TCONST static_tree_desc static_l_desc = | |
| 126 | 132 | {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; |
| 127 | 133 | |
| 128 | -local const static_tree_desc static_d_desc = | |
| 134 | +local TCONST static_tree_desc static_d_desc = | |
| 129 | 135 | {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; |
| 130 | 136 | |
| 131 | -local const static_tree_desc static_bl_desc = | |
| 137 | +local TCONST static_tree_desc static_bl_desc = | |
| 132 | 138 | {(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; |
| 133 | 139 | |
| 134 | 140 | /* =========================================================================== |
| 135 | - * Local (static) routines in this file. | |
| 141 | + * Output a short LSB first on the stream. | |
| 142 | + * IN assertion: there is enough room in pendingBuf. | |
| 143 | + */ | |
| 144 | +#define put_short(s, w) { \ | |
| 145 | + put_byte(s, (uch)((w) & 0xff)); \ | |
| 146 | + put_byte(s, (uch)((ush)(w) >> 8)); \ | |
| 147 | +} | |
| 148 | + | |
| 149 | +/* =========================================================================== | |
| 150 | + * Reverse the first len bits of a code, using straightforward code (a faster | |
| 151 | + * method would use a table) | |
| 152 | + * IN assertion: 1 <= len <= 15 | |
| 153 | + */ | |
| 154 | +local unsigned bi_reverse(unsigned code, int len) { | |
| 155 | + register unsigned res = 0; | |
| 156 | + do { | |
| 157 | + res |= code & 1; | |
| 158 | + code >>= 1, res <<= 1; | |
| 159 | + } while (--len > 0); | |
| 160 | + return res >> 1; | |
| 161 | +} | |
| 162 | + | |
| 163 | +/* =========================================================================== | |
| 164 | + * Flush the bit buffer, keeping at most 7 bits in it. | |
| 165 | + */ | |
| 166 | +local void bi_flush(deflate_state *s) { | |
| 167 | + if (s->bi_valid == 16) { | |
| 168 | + put_short(s, s->bi_buf); | |
| 169 | + s->bi_buf = 0; | |
| 170 | + s->bi_valid = 0; | |
| 171 | + } else if (s->bi_valid >= 8) { | |
| 172 | + put_byte(s, (Byte)s->bi_buf); | |
| 173 | + s->bi_buf >>= 8; | |
| 174 | + s->bi_valid -= 8; | |
| 175 | + } | |
| 176 | +} | |
| 177 | + | |
| 178 | +/* =========================================================================== | |
| 179 | + * Flush the bit buffer and align the output on a byte boundary | |
| 180 | + */ | |
| 181 | +local void bi_windup(deflate_state *s) { | |
| 182 | + if (s->bi_valid > 8) { | |
| 183 | + put_short(s, s->bi_buf); | |
| 184 | + } else if (s->bi_valid > 0) { | |
| 185 | + put_byte(s, (Byte)s->bi_buf); | |
| 186 | + } | |
| 187 | + s->bi_buf = 0; | |
| 188 | + s->bi_valid = 0; | |
| 189 | +#ifdef ZLIB_DEBUG | |
| 190 | + s->bits_sent = (s->bits_sent + 7) & ~7; | |
| 191 | +#endif | |
| 192 | +} | |
| 193 | + | |
| 194 | +/* =========================================================================== | |
| 195 | + * Generate the codes for a given tree and bit counts (which need not be | |
| 196 | + * optimal). | |
| 197 | + * IN assertion: the array bl_count contains the bit length statistics for | |
| 198 | + * the given tree and the field len is set for all tree elements. | |
| 199 | + * OUT assertion: the field code is set for all tree elements of non | |
| 200 | + * zero code length. | |
| 136 | 201 | */ |
| 137 | - | |
| 138 | -local void tr_static_init OF((void)); | |
| 139 | -local void init_block OF((deflate_state *s)); | |
| 140 | -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); | |
| 141 | -local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); | |
| 142 | -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); | |
| 143 | -local void build_tree OF((deflate_state *s, tree_desc *desc)); | |
| 144 | -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); | |
| 145 | -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); | |
| 146 | -local int build_bl_tree OF((deflate_state *s)); | |
| 147 | -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, | |
| 148 | - int blcodes)); | |
| 149 | -local void compress_block OF((deflate_state *s, const ct_data *ltree, | |
| 150 | - const ct_data *dtree)); | |
| 151 | -local int detect_data_type OF((deflate_state *s)); | |
| 152 | -local unsigned bi_reverse OF((unsigned code, int len)); | |
| 153 | -local void bi_windup OF((deflate_state *s)); | |
| 154 | -local void bi_flush OF((deflate_state *s)); | |
| 202 | +local void gen_codes(ct_data *tree, int max_code, ushf *bl_count) { | |
| 203 | + ush next_code[MAX_BITS+1]; /* next code value for each bit length */ | |
| 204 | + unsigned code = 0; /* running code value */ | |
| 205 | + int bits; /* bit index */ | |
| 206 | + int n; /* code index */ | |
| 207 | + | |
| 208 | + /* The distribution counts are first used to generate the code values | |
| 209 | + * without bit reversal. | |
| 210 | + */ | |
| 211 | + for (bits = 1; bits <= MAX_BITS; bits++) { | |
| 212 | + code = (code + bl_count[bits - 1]) << 1; | |
| 213 | + next_code[bits] = (ush)code; | |
| 214 | + } | |
| 215 | + /* Check that the bit counts in bl_count are consistent. The last code | |
| 216 | + * must be all ones. | |
| 217 | + */ | |
| 218 | + Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, | |
| 219 | + "inconsistent bit counts"); | |
| 220 | + Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); | |
| 221 | + | |
| 222 | + for (n = 0; n <= max_code; n++) { | |
| 223 | + int len = tree[n].Len; | |
| 224 | + if (len == 0) continue; | |
| 225 | + /* Now reverse the bits */ | |
| 226 | + tree[n].Code = (ush)bi_reverse(next_code[len]++, len); | |
| 227 | + | |
| 228 | + Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", | |
| 229 | + n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1)); | |
| 230 | + } | |
| 231 | +} | |
| 155 | 232 | |
| 156 | 233 | #ifdef GEN_TREES_H |
| 157 | -local void gen_trees_header OF((void)); | |
| 234 | +local void gen_trees_header(void); | |
| 158 | 235 | #endif |
| 159 | 236 | |
| 160 | 237 | #ifndef ZLIB_DEBUG |
| 161 | 238 | # define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) |
| 162 | 239 | /* Send a code of the given tree. c and tree must not have side effects */ |
| @@ -165,31 +242,16 @@ | ||
| 165 | 242 | # define send_code(s, c, tree) \ |
| 166 | 243 | { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ |
| 167 | 244 | send_bits(s, tree[c].Code, tree[c].Len); } |
| 168 | 245 | #endif |
| 169 | 246 | |
| 170 | -/* =========================================================================== | |
| 171 | - * Output a short LSB first on the stream. | |
| 172 | - * IN assertion: there is enough room in pendingBuf. | |
| 173 | - */ | |
| 174 | -#define put_short(s, w) { \ | |
| 175 | - put_byte(s, (uch)((w) & 0xff)); \ | |
| 176 | - put_byte(s, (uch)((ush)(w) >> 8)); \ | |
| 177 | -} | |
| 178 | - | |
| 179 | 247 | /* =========================================================================== |
| 180 | 248 | * Send a value on a given number of bits. |
| 181 | 249 | * IN assertion: length <= 16 and value fits in length bits. |
| 182 | 250 | */ |
| 183 | 251 | #ifdef ZLIB_DEBUG |
| 184 | -local void send_bits OF((deflate_state *s, int value, int length)); | |
| 185 | - | |
| 186 | -local void send_bits(s, value, length) | |
| 187 | - deflate_state *s; | |
| 188 | - int value; /* value to send */ | |
| 189 | - int length; /* number of bits */ | |
| 190 | -{ | |
| 252 | +local void send_bits(deflate_state *s, int value, int length) { | |
| 191 | 253 | Tracevv((stderr," l %2d v %4x ", length, value)); |
| 192 | 254 | Assert(length > 0 && length <= 15, "invalid length"); |
| 193 | 255 | s->bits_sent += (ulg)length; |
| 194 | 256 | |
| 195 | 257 | /* If not enough room in bi_buf, use (valid) bits from bi_buf and |
| @@ -227,12 +289,11 @@ | ||
| 227 | 289 | /* the arguments must not have side effects */ |
| 228 | 290 | |
| 229 | 291 | /* =========================================================================== |
| 230 | 292 | * Initialize the various 'constant' tables. |
| 231 | 293 | */ |
| 232 | -local void tr_static_init() | |
| 233 | -{ | |
| 294 | +local void tr_static_init(void) { | |
| 234 | 295 | #if defined(GEN_TREES_H) || !defined(STDC) |
| 235 | 296 | static int static_init_done = 0; |
| 236 | 297 | int n; /* iterates over tree elements */ |
| 237 | 298 | int bits; /* bit counter */ |
| 238 | 299 | int length; /* length value */ |
| @@ -321,12 +382,11 @@ | ||
| 321 | 382 | |
| 322 | 383 | # define SEPARATOR(i, last, width) \ |
| 323 | 384 | ((i) == (last)? "\n};\n\n" : \ |
| 324 | 385 | ((i) % (width) == (width) - 1 ? ",\n" : ", ")) |
| 325 | 386 | |
| 326 | -void gen_trees_header() | |
| 327 | -{ | |
| 387 | +void gen_trees_header(void) { | |
| 328 | 388 | FILE *header = fopen("trees.h", "w"); |
| 329 | 389 | int i; |
| 330 | 390 | |
| 331 | 391 | Assert (header != NULL, "Can't open trees.h"); |
| 332 | 392 | fprintf(header, |
| @@ -370,17 +430,31 @@ | ||
| 370 | 430 | } |
| 371 | 431 | |
| 372 | 432 | fclose(header); |
| 373 | 433 | } |
| 374 | 434 | #endif /* GEN_TREES_H */ |
| 435 | + | |
| 436 | +/* =========================================================================== | |
| 437 | + * Initialize a new block. | |
| 438 | + */ | |
| 439 | +local void init_block(deflate_state *s) { | |
| 440 | + int n; /* iterates over tree elements */ | |
| 441 | + | |
| 442 | + /* Initialize the trees. */ | |
| 443 | + for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; | |
| 444 | + for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; | |
| 445 | + for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; | |
| 446 | + | |
| 447 | + s->dyn_ltree[END_BLOCK].Freq = 1; | |
| 448 | + s->opt_len = s->static_len = 0L; | |
| 449 | + s->sym_next = s->matches = 0; | |
| 450 | +} | |
| 375 | 451 | |
| 376 | 452 | /* =========================================================================== |
| 377 | 453 | * Initialize the tree data structures for a new zlib stream. |
| 378 | 454 | */ |
| 379 | -void ZLIB_INTERNAL _tr_init(s) | |
| 380 | - deflate_state *s; | |
| 381 | -{ | |
| 455 | +void ZLIB_INTERNAL _tr_init(deflate_state *s) { | |
| 382 | 456 | tr_static_init(); |
| 383 | 457 | |
| 384 | 458 | s->l_desc.dyn_tree = s->dyn_ltree; |
| 385 | 459 | s->l_desc.stat_desc = &static_l_desc; |
| 386 | 460 | |
| @@ -399,28 +473,10 @@ | ||
| 399 | 473 | |
| 400 | 474 | /* Initialize the first block of the first file: */ |
| 401 | 475 | init_block(s); |
| 402 | 476 | } |
| 403 | 477 | |
| 404 | -/* =========================================================================== | |
| 405 | - * Initialize a new block. | |
| 406 | - */ | |
| 407 | -local void init_block(s) | |
| 408 | - deflate_state *s; | |
| 409 | -{ | |
| 410 | - int n; /* iterates over tree elements */ | |
| 411 | - | |
| 412 | - /* Initialize the trees. */ | |
| 413 | - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; | |
| 414 | - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; | |
| 415 | - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; | |
| 416 | - | |
| 417 | - s->dyn_ltree[END_BLOCK].Freq = 1; | |
| 418 | - s->opt_len = s->static_len = 0L; | |
| 419 | - s->sym_next = s->matches = 0; | |
| 420 | -} | |
| 421 | - | |
| 422 | 478 | #define SMALLEST 1 |
| 423 | 479 | /* Index within the heap array of least frequent node in the Huffman tree */ |
| 424 | 480 | |
| 425 | 481 | |
| 426 | 482 | /* =========================================================================== |
| @@ -446,15 +502,11 @@ | ||
| 446 | 502 | * Restore the heap property by moving down the tree starting at node k, |
| 447 | 503 | * exchanging a node with the smallest of its two sons if necessary, stopping |
| 448 | 504 | * when the heap property is re-established (each father smaller than its |
| 449 | 505 | * two sons). |
| 450 | 506 | */ |
| 451 | -local void pqdownheap(s, tree, k) | |
| 452 | - deflate_state *s; | |
| 453 | - ct_data *tree; /* the tree to restore */ | |
| 454 | - int k; /* node to move down */ | |
| 455 | -{ | |
| 507 | +local void pqdownheap(deflate_state *s, ct_data *tree, int k) { | |
| 456 | 508 | int v = s->heap[k]; |
| 457 | 509 | int j = k << 1; /* left son of k */ |
| 458 | 510 | while (j <= s->heap_len) { |
| 459 | 511 | /* Set j to the smallest of the two sons: */ |
| 460 | 512 | if (j < s->heap_len && |
| @@ -481,14 +533,11 @@ | ||
| 481 | 533 | * OUT assertions: the field len is set to the optimal bit length, the |
| 482 | 534 | * array bl_count contains the frequencies for each bit length. |
| 483 | 535 | * The length opt_len is updated; static_len is also updated if stree is |
| 484 | 536 | * not null. |
| 485 | 537 | */ |
| 486 | -local void gen_bitlen(s, desc) | |
| 487 | - deflate_state *s; | |
| 488 | - tree_desc *desc; /* the tree descriptor */ | |
| 489 | -{ | |
| 538 | +local void gen_bitlen(deflate_state *s, tree_desc *desc) { | |
| 490 | 539 | ct_data *tree = desc->dyn_tree; |
| 491 | 540 | int max_code = desc->max_code; |
| 492 | 541 | const ct_data *stree = desc->stat_desc->static_tree; |
| 493 | 542 | const intf *extra = desc->stat_desc->extra_bits; |
| 494 | 543 | int base = desc->stat_desc->extra_base; |
| @@ -559,65 +608,23 @@ | ||
| 559 | 608 | n--; |
| 560 | 609 | } |
| 561 | 610 | } |
| 562 | 611 | } |
| 563 | 612 | |
| 564 | -/* =========================================================================== | |
| 565 | - * Generate the codes for a given tree and bit counts (which need not be | |
| 566 | - * optimal). | |
| 567 | - * IN assertion: the array bl_count contains the bit length statistics for | |
| 568 | - * the given tree and the field len is set for all tree elements. | |
| 569 | - * OUT assertion: the field code is set for all tree elements of non | |
| 570 | - * zero code length. | |
| 571 | - */ | |
| 572 | -local void gen_codes(tree, max_code, bl_count) | |
| 573 | - ct_data *tree; /* the tree to decorate */ | |
| 574 | - int max_code; /* largest code with non zero frequency */ | |
| 575 | - ushf *bl_count; /* number of codes at each bit length */ | |
| 576 | -{ | |
| 577 | - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ | |
| 578 | - unsigned code = 0; /* running code value */ | |
| 579 | - int bits; /* bit index */ | |
| 580 | - int n; /* code index */ | |
| 581 | - | |
| 582 | - /* The distribution counts are first used to generate the code values | |
| 583 | - * without bit reversal. | |
| 584 | - */ | |
| 585 | - for (bits = 1; bits <= MAX_BITS; bits++) { | |
| 586 | - code = (code + bl_count[bits - 1]) << 1; | |
| 587 | - next_code[bits] = (ush)code; | |
| 588 | - } | |
| 589 | - /* Check that the bit counts in bl_count are consistent. The last code | |
| 590 | - * must be all ones. | |
| 591 | - */ | |
| 592 | - Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, | |
| 593 | - "inconsistent bit counts"); | |
| 594 | - Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); | |
| 595 | - | |
| 596 | - for (n = 0; n <= max_code; n++) { | |
| 597 | - int len = tree[n].Len; | |
| 598 | - if (len == 0) continue; | |
| 599 | - /* Now reverse the bits */ | |
| 600 | - tree[n].Code = (ush)bi_reverse(next_code[len]++, len); | |
| 601 | - | |
| 602 | - Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", | |
| 603 | - n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1)); | |
| 604 | - } | |
| 605 | -} | |
| 613 | +#ifdef DUMP_BL_TREE | |
| 614 | +# include <stdio.h> | |
| 615 | +#endif | |
| 606 | 616 | |
| 607 | 617 | /* =========================================================================== |
| 608 | 618 | * Construct one Huffman tree and assigns the code bit strings and lengths. |
| 609 | 619 | * Update the total bit length for the current block. |
| 610 | 620 | * IN assertion: the field freq is set for all tree elements. |
| 611 | 621 | * OUT assertions: the fields len and code are set to the optimal bit length |
| 612 | 622 | * and corresponding code. The length opt_len is updated; static_len is |
| 613 | 623 | * also updated if stree is not null. The field max_code is set. |
| 614 | 624 | */ |
| 615 | -local void build_tree(s, desc) | |
| 616 | - deflate_state *s; | |
| 617 | - tree_desc *desc; /* the tree descriptor */ | |
| 618 | -{ | |
| 625 | +local void build_tree(deflate_state *s, tree_desc *desc) { | |
| 619 | 626 | ct_data *tree = desc->dyn_tree; |
| 620 | 627 | const ct_data *stree = desc->stat_desc->static_tree; |
| 621 | 628 | int elems = desc->stat_desc->elems; |
| 622 | 629 | int n, m; /* iterate over heap elements */ |
| 623 | 630 | int max_code = -1; /* largest code with non zero frequency */ |
| @@ -698,15 +705,11 @@ | ||
| 698 | 705 | |
| 699 | 706 | /* =========================================================================== |
| 700 | 707 | * Scan a literal or distance tree to determine the frequencies of the codes |
| 701 | 708 | * in the bit length tree. |
| 702 | 709 | */ |
| 703 | -local void scan_tree(s, tree, max_code) | |
| 704 | - deflate_state *s; | |
| 705 | - ct_data *tree; /* the tree to be scanned */ | |
| 706 | - int max_code; /* and its largest code of non zero frequency */ | |
| 707 | -{ | |
| 710 | +local void scan_tree(deflate_state *s, ct_data *tree, int max_code) { | |
| 708 | 711 | int n; /* iterates over all tree elements */ |
| 709 | 712 | int prevlen = -1; /* last emitted length */ |
| 710 | 713 | int curlen; /* length of current code */ |
| 711 | 714 | int nextlen = tree[0].Len; /* length of next code */ |
| 712 | 715 | int count = 0; /* repeat count of the current code */ |
| @@ -743,15 +746,11 @@ | ||
| 743 | 746 | |
| 744 | 747 | /* =========================================================================== |
| 745 | 748 | * Send a literal or distance tree in compressed form, using the codes in |
| 746 | 749 | * bl_tree. |
| 747 | 750 | */ |
| 748 | -local void send_tree(s, tree, max_code) | |
| 749 | - deflate_state *s; | |
| 750 | - ct_data *tree; /* the tree to be scanned */ | |
| 751 | - int max_code; /* and its largest code of non zero frequency */ | |
| 752 | -{ | |
| 751 | +local void send_tree(deflate_state *s, ct_data *tree, int max_code) { | |
| 753 | 752 | int n; /* iterates over all tree elements */ |
| 754 | 753 | int prevlen = -1; /* last emitted length */ |
| 755 | 754 | int curlen; /* length of current code */ |
| 756 | 755 | int nextlen = tree[0].Len; /* length of next code */ |
| 757 | 756 | int count = 0; /* repeat count of the current code */ |
| @@ -794,13 +793,11 @@ | ||
| 794 | 793 | |
| 795 | 794 | /* =========================================================================== |
| 796 | 795 | * Construct the Huffman tree for the bit lengths and return the index in |
| 797 | 796 | * bl_order of the last bit length code to send. |
| 798 | 797 | */ |
| 799 | -local int build_bl_tree(s) | |
| 800 | - deflate_state *s; | |
| 801 | -{ | |
| 798 | +local int build_bl_tree(deflate_state *s) { | |
| 802 | 799 | int max_blindex; /* index of last bit length code of non zero freq */ |
| 803 | 800 | |
| 804 | 801 | /* Determine the bit length frequencies for literal and distance trees */ |
| 805 | 802 | scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); |
| 806 | 803 | scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); |
| @@ -829,14 +826,12 @@ | ||
| 829 | 826 | /* =========================================================================== |
| 830 | 827 | * Send the header for a block using dynamic Huffman trees: the counts, the |
| 831 | 828 | * lengths of the bit length codes, the literal tree and the distance tree. |
| 832 | 829 | * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. |
| 833 | 830 | */ |
| 834 | -local void send_all_trees(s, lcodes, dcodes, blcodes) | |
| 835 | - deflate_state *s; | |
| 836 | - int lcodes, dcodes, blcodes; /* number of codes for each tree */ | |
| 837 | -{ | |
| 831 | +local void send_all_trees(deflate_state *s, int lcodes, int dcodes, | |
| 832 | + int blcodes) { | |
| 838 | 833 | int rank; /* index in bl_order */ |
| 839 | 834 | |
| 840 | 835 | Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); |
| 841 | 836 | Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, |
| 842 | 837 | "too many codes"); |
| @@ -858,16 +853,12 @@ | ||
| 858 | 853 | } |
| 859 | 854 | |
| 860 | 855 | /* =========================================================================== |
| 861 | 856 | * Send a stored block |
| 862 | 857 | */ |
| 863 | -void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) | |
| 864 | - deflate_state *s; | |
| 865 | - charf *buf; /* input block */ | |
| 866 | - ulg stored_len; /* length of input block */ | |
| 867 | - int last; /* one if this is the last block for a file */ | |
| 868 | -{ | |
| 858 | +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, | |
| 859 | + ulg stored_len, int last) { | |
| 869 | 860 | send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */ |
| 870 | 861 | bi_windup(s); /* align on byte boundary */ |
| 871 | 862 | put_short(s, (ush)stored_len); |
| 872 | 863 | put_short(s, (ush)~stored_len); |
| 873 | 864 | if (stored_len) |
| @@ -882,41 +873,120 @@ | ||
| 882 | 873 | } |
| 883 | 874 | |
| 884 | 875 | /* =========================================================================== |
| 885 | 876 | * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) |
| 886 | 877 | */ |
| 887 | -void ZLIB_INTERNAL _tr_flush_bits(s) | |
| 888 | - deflate_state *s; | |
| 889 | -{ | |
| 878 | +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s) { | |
| 890 | 879 | bi_flush(s); |
| 891 | 880 | } |
| 892 | 881 | |
| 893 | 882 | /* =========================================================================== |
| 894 | 883 | * Send one empty static block to give enough lookahead for inflate. |
| 895 | 884 | * This takes 10 bits, of which 7 may remain in the bit buffer. |
| 896 | 885 | */ |
| 897 | -void ZLIB_INTERNAL _tr_align(s) | |
| 898 | - deflate_state *s; | |
| 899 | -{ | |
| 886 | +void ZLIB_INTERNAL _tr_align(deflate_state *s) { | |
| 900 | 887 | send_bits(s, STATIC_TREES<<1, 3); |
| 901 | 888 | send_code(s, END_BLOCK, static_ltree); |
| 902 | 889 | #ifdef ZLIB_DEBUG |
| 903 | 890 | s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ |
| 904 | 891 | #endif |
| 905 | 892 | bi_flush(s); |
| 906 | 893 | } |
| 894 | + | |
| 895 | +/* =========================================================================== | |
| 896 | + * Send the block data compressed using the given Huffman trees | |
| 897 | + */ | |
| 898 | +local void compress_block(deflate_state *s, const ct_data *ltree, | |
| 899 | + const ct_data *dtree) { | |
| 900 | + unsigned dist; /* distance of matched string */ | |
| 901 | + int lc; /* match length or unmatched char (if dist == 0) */ | |
| 902 | + unsigned sx = 0; /* running index in sym_buf */ | |
| 903 | + unsigned code; /* the code to send */ | |
| 904 | + int extra; /* number of extra bits to send */ | |
| 905 | + | |
| 906 | + if (s->sym_next != 0) do { | |
| 907 | + dist = s->sym_buf[sx++] & 0xff; | |
| 908 | + dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; | |
| 909 | + lc = s->sym_buf[sx++]; | |
| 910 | + if (dist == 0) { | |
| 911 | + send_code(s, lc, ltree); /* send a literal byte */ | |
| 912 | + Tracecv(isgraph(lc), (stderr," '%c' ", lc)); | |
| 913 | + } else { | |
| 914 | + /* Here, lc is the match length - MIN_MATCH */ | |
| 915 | + code = _length_code[lc]; | |
| 916 | + send_code(s, code + LITERALS + 1, ltree); /* send length code */ | |
| 917 | + extra = extra_lbits[code]; | |
| 918 | + if (extra != 0) { | |
| 919 | + lc -= base_length[code]; | |
| 920 | + send_bits(s, lc, extra); /* send the extra length bits */ | |
| 921 | + } | |
| 922 | + dist--; /* dist is now the match distance - 1 */ | |
| 923 | + code = d_code(dist); | |
| 924 | + Assert (code < D_CODES, "bad d_code"); | |
| 925 | + | |
| 926 | + send_code(s, code, dtree); /* send the distance code */ | |
| 927 | + extra = extra_dbits[code]; | |
| 928 | + if (extra != 0) { | |
| 929 | + dist -= (unsigned)base_dist[code]; | |
| 930 | + send_bits(s, dist, extra); /* send the extra distance bits */ | |
| 931 | + } | |
| 932 | + } /* literal or match pair ? */ | |
| 933 | + | |
| 934 | + /* Check that the overlay between pending_buf and sym_buf is ok: */ | |
| 935 | + Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); | |
| 936 | + | |
| 937 | + } while (sx < s->sym_next); | |
| 938 | + | |
| 939 | + send_code(s, END_BLOCK, ltree); | |
| 940 | +} | |
| 941 | + | |
| 942 | +/* =========================================================================== | |
| 943 | + * Check if the data type is TEXT or BINARY, using the following algorithm: | |
| 944 | + * - TEXT if the two conditions below are satisfied: | |
| 945 | + * a) There are no non-portable control characters belonging to the | |
| 946 | + * "block list" (0..6, 14..25, 28..31). | |
| 947 | + * b) There is at least one printable character belonging to the | |
| 948 | + * "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). | |
| 949 | + * - BINARY otherwise. | |
| 950 | + * - The following partially-portable control characters form a | |
| 951 | + * "gray list" that is ignored in this detection algorithm: | |
| 952 | + * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). | |
| 953 | + * IN assertion: the fields Freq of dyn_ltree are set. | |
| 954 | + */ | |
| 955 | +local int detect_data_type(deflate_state *s) { | |
| 956 | + /* block_mask is the bit mask of block-listed bytes | |
| 957 | + * set bits 0..6, 14..25, and 28..31 | |
| 958 | + * 0xf3ffc07f = binary 11110011111111111100000001111111 | |
| 959 | + */ | |
| 960 | + unsigned long block_mask = 0xf3ffc07fUL; | |
| 961 | + int n; | |
| 962 | + | |
| 963 | + /* Check for non-textual ("block-listed") bytes. */ | |
| 964 | + for (n = 0; n <= 31; n++, block_mask >>= 1) | |
| 965 | + if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0)) | |
| 966 | + return Z_BINARY; | |
| 967 | + | |
| 968 | + /* Check for textual ("allow-listed") bytes. */ | |
| 969 | + if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 | |
| 970 | + || s->dyn_ltree[13].Freq != 0) | |
| 971 | + return Z_TEXT; | |
| 972 | + for (n = 32; n < LITERALS; n++) | |
| 973 | + if (s->dyn_ltree[n].Freq != 0) | |
| 974 | + return Z_TEXT; | |
| 975 | + | |
| 976 | + /* There are no "block-listed" or "allow-listed" bytes: | |
| 977 | + * this stream either is empty or has tolerated ("gray-listed") bytes only. | |
| 978 | + */ | |
| 979 | + return Z_BINARY; | |
| 980 | +} | |
| 907 | 981 | |
| 908 | 982 | /* =========================================================================== |
| 909 | 983 | * Determine the best encoding for the current block: dynamic trees, static |
| 910 | 984 | * trees or store, and write out the encoded block. |
| 911 | 985 | */ |
| 912 | -void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) | |
| 913 | - deflate_state *s; | |
| 914 | - charf *buf; /* input block, or NULL if too old */ | |
| 915 | - ulg stored_len; /* length of input block */ | |
| 916 | - int last; /* one if this is the last block for a file */ | |
| 917 | -{ | |
| 986 | +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, | |
| 987 | + ulg stored_len, int last) { | |
| 918 | 988 | ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ |
| 919 | 989 | int max_blindex = 0; /* index of last bit length code of non zero freq */ |
| 920 | 990 | |
| 921 | 991 | /* Build the Huffman trees unless a stored block is forced */ |
| 922 | 992 | if (s->level > 0) { |
| @@ -1009,15 +1079,11 @@ | ||
| 1009 | 1079 | |
| 1010 | 1080 | /* =========================================================================== |
| 1011 | 1081 | * Save the match info and tally the frequency counts. Return true if |
| 1012 | 1082 | * the current block must be flushed. |
| 1013 | 1083 | */ |
| 1014 | -int ZLIB_INTERNAL _tr_tally(s, dist, lc) | |
| 1015 | - deflate_state *s; | |
| 1016 | - unsigned dist; /* distance of matched string */ | |
| 1017 | - unsigned lc; /* match length - MIN_MATCH or unmatched char (dist==0) */ | |
| 1018 | -{ | |
| 1084 | +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) { | |
| 1019 | 1085 | s->sym_buf[s->sym_next++] = (uch)dist; |
| 1020 | 1086 | s->sym_buf[s->sym_next++] = (uch)(dist >> 8); |
| 1021 | 1087 | s->sym_buf[s->sym_next++] = (uch)lc; |
| 1022 | 1088 | if (dist == 0) { |
| 1023 | 1089 | /* lc is the unmatched char */ |
| @@ -1033,149 +1099,5 @@ | ||
| 1033 | 1099 | s->dyn_ltree[_length_code[lc] + LITERALS + 1].Freq++; |
| 1034 | 1100 | s->dyn_dtree[d_code(dist)].Freq++; |
| 1035 | 1101 | } |
| 1036 | 1102 | return (s->sym_next == s->sym_end); |
| 1037 | 1103 | } |
| 1038 | - | |
| 1039 | -/* =========================================================================== | |
| 1040 | - * Send the block data compressed using the given Huffman trees | |
| 1041 | - */ | |
| 1042 | -local void compress_block(s, ltree, dtree) | |
| 1043 | - deflate_state *s; | |
| 1044 | - const ct_data *ltree; /* literal tree */ | |
| 1045 | - const ct_data *dtree; /* distance tree */ | |
| 1046 | -{ | |
| 1047 | - unsigned dist; /* distance of matched string */ | |
| 1048 | - int lc; /* match length or unmatched char (if dist == 0) */ | |
| 1049 | - unsigned sx = 0; /* running index in sym_buf */ | |
| 1050 | - unsigned code; /* the code to send */ | |
| 1051 | - int extra; /* number of extra bits to send */ | |
| 1052 | - | |
| 1053 | - if (s->sym_next != 0) do { | |
| 1054 | - dist = s->sym_buf[sx++] & 0xff; | |
| 1055 | - dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; | |
| 1056 | - lc = s->sym_buf[sx++]; | |
| 1057 | - if (dist == 0) { | |
| 1058 | - send_code(s, lc, ltree); /* send a literal byte */ | |
| 1059 | - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); | |
| 1060 | - } else { | |
| 1061 | - /* Here, lc is the match length - MIN_MATCH */ | |
| 1062 | - code = _length_code[lc]; | |
| 1063 | - send_code(s, code + LITERALS + 1, ltree); /* send length code */ | |
| 1064 | - extra = extra_lbits[code]; | |
| 1065 | - if (extra != 0) { | |
| 1066 | - lc -= base_length[code]; | |
| 1067 | - send_bits(s, lc, extra); /* send the extra length bits */ | |
| 1068 | - } | |
| 1069 | - dist--; /* dist is now the match distance - 1 */ | |
| 1070 | - code = d_code(dist); | |
| 1071 | - Assert (code < D_CODES, "bad d_code"); | |
| 1072 | - | |
| 1073 | - send_code(s, code, dtree); /* send the distance code */ | |
| 1074 | - extra = extra_dbits[code]; | |
| 1075 | - if (extra != 0) { | |
| 1076 | - dist -= (unsigned)base_dist[code]; | |
| 1077 | - send_bits(s, dist, extra); /* send the extra distance bits */ | |
| 1078 | - } | |
| 1079 | - } /* literal or match pair ? */ | |
| 1080 | - | |
| 1081 | - /* Check that the overlay between pending_buf and sym_buf is ok: */ | |
| 1082 | - Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); | |
| 1083 | - | |
| 1084 | - } while (sx < s->sym_next); | |
| 1085 | - | |
| 1086 | - send_code(s, END_BLOCK, ltree); | |
| 1087 | -} | |
| 1088 | - | |
| 1089 | -/* =========================================================================== | |
| 1090 | - * Check if the data type is TEXT or BINARY, using the following algorithm: | |
| 1091 | - * - TEXT if the two conditions below are satisfied: | |
| 1092 | - * a) There are no non-portable control characters belonging to the | |
| 1093 | - * "block list" (0..6, 14..25, 28..31). | |
| 1094 | - * b) There is at least one printable character belonging to the | |
| 1095 | - * "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). | |
| 1096 | - * - BINARY otherwise. | |
| 1097 | - * - The following partially-portable control characters form a | |
| 1098 | - * "gray list" that is ignored in this detection algorithm: | |
| 1099 | - * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). | |
| 1100 | - * IN assertion: the fields Freq of dyn_ltree are set. | |
| 1101 | - */ | |
| 1102 | -local int detect_data_type(s) | |
| 1103 | - deflate_state *s; | |
| 1104 | -{ | |
| 1105 | - /* block_mask is the bit mask of block-listed bytes | |
| 1106 | - * set bits 0..6, 14..25, and 28..31 | |
| 1107 | - * 0xf3ffc07f = binary 11110011111111111100000001111111 | |
| 1108 | - */ | |
| 1109 | - unsigned long block_mask = 0xf3ffc07fUL; | |
| 1110 | - int n; | |
| 1111 | - | |
| 1112 | - /* Check for non-textual ("block-listed") bytes. */ | |
| 1113 | - for (n = 0; n <= 31; n++, block_mask >>= 1) | |
| 1114 | - if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0)) | |
| 1115 | - return Z_BINARY; | |
| 1116 | - | |
| 1117 | - /* Check for textual ("allow-listed") bytes. */ | |
| 1118 | - if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 | |
| 1119 | - || s->dyn_ltree[13].Freq != 0) | |
| 1120 | - return Z_TEXT; | |
| 1121 | - for (n = 32; n < LITERALS; n++) | |
| 1122 | - if (s->dyn_ltree[n].Freq != 0) | |
| 1123 | - return Z_TEXT; | |
| 1124 | - | |
| 1125 | - /* There are no "block-listed" or "allow-listed" bytes: | |
| 1126 | - * this stream either is empty or has tolerated ("gray-listed") bytes only. | |
| 1127 | - */ | |
| 1128 | - return Z_BINARY; | |
| 1129 | -} | |
| 1130 | - | |
| 1131 | -/* =========================================================================== | |
| 1132 | - * Reverse the first len bits of a code, using straightforward code (a faster | |
| 1133 | - * method would use a table) | |
| 1134 | - * IN assertion: 1 <= len <= 15 | |
| 1135 | - */ | |
| 1136 | -local unsigned bi_reverse(code, len) | |
| 1137 | - unsigned code; /* the value to invert */ | |
| 1138 | - int len; /* its bit length */ | |
| 1139 | -{ | |
| 1140 | - register unsigned res = 0; | |
| 1141 | - do { | |
| 1142 | - res |= code & 1; | |
| 1143 | - code >>= 1, res <<= 1; | |
| 1144 | - } while (--len > 0); | |
| 1145 | - return res >> 1; | |
| 1146 | -} | |
| 1147 | - | |
| 1148 | -/* =========================================================================== | |
| 1149 | - * Flush the bit buffer, keeping at most 7 bits in it. | |
| 1150 | - */ | |
| 1151 | -local void bi_flush(s) | |
| 1152 | - deflate_state *s; | |
| 1153 | -{ | |
| 1154 | - if (s->bi_valid == 16) { | |
| 1155 | - put_short(s, s->bi_buf); | |
| 1156 | - s->bi_buf = 0; | |
| 1157 | - s->bi_valid = 0; | |
| 1158 | - } else if (s->bi_valid >= 8) { | |
| 1159 | - put_byte(s, (Byte)s->bi_buf); | |
| 1160 | - s->bi_buf >>= 8; | |
| 1161 | - s->bi_valid -= 8; | |
| 1162 | - } | |
| 1163 | -} | |
| 1164 | - | |
| 1165 | -/* =========================================================================== | |
| 1166 | - * Flush the bit buffer and align the output on a byte boundary | |
| 1167 | - */ | |
| 1168 | -local void bi_windup(s) | |
| 1169 | - deflate_state *s; | |
| 1170 | -{ | |
| 1171 | - if (s->bi_valid > 8) { | |
| 1172 | - put_short(s, s->bi_buf); | |
| 1173 | - } else if (s->bi_valid > 0) { | |
| 1174 | - put_byte(s, (Byte)s->bi_buf); | |
| 1175 | - } | |
| 1176 | - s->bi_buf = 0; | |
| 1177 | - s->bi_valid = 0; | |
| 1178 | -#ifdef ZLIB_DEBUG | |
| 1179 | - s->bits_sent = (s->bits_sent + 7) & ~7; | |
| 1180 | -#endif | |
| 1181 | -} | |
| 1182 | 1104 |
| --- compat/zlib/trees.c | |
| +++ compat/zlib/trees.c | |
| @@ -120,43 +120,120 @@ | |
| 120 | int extra_base; /* base index for extra_bits */ |
| 121 | int elems; /* max number of elements in the tree */ |
| 122 | int max_length; /* max bit length for the codes */ |
| 123 | }; |
| 124 | |
| 125 | local const static_tree_desc static_l_desc = |
| 126 | {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; |
| 127 | |
| 128 | local const static_tree_desc static_d_desc = |
| 129 | {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; |
| 130 | |
| 131 | local const static_tree_desc static_bl_desc = |
| 132 | {(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; |
| 133 | |
| 134 | /* =========================================================================== |
| 135 | * Local (static) routines in this file. |
| 136 | */ |
| 137 | |
| 138 | local void tr_static_init OF((void)); |
| 139 | local void init_block OF((deflate_state *s)); |
| 140 | local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); |
| 141 | local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); |
| 142 | local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); |
| 143 | local void build_tree OF((deflate_state *s, tree_desc *desc)); |
| 144 | local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); |
| 145 | local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); |
| 146 | local int build_bl_tree OF((deflate_state *s)); |
| 147 | local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, |
| 148 | int blcodes)); |
| 149 | local void compress_block OF((deflate_state *s, const ct_data *ltree, |
| 150 | const ct_data *dtree)); |
| 151 | local int detect_data_type OF((deflate_state *s)); |
| 152 | local unsigned bi_reverse OF((unsigned code, int len)); |
| 153 | local void bi_windup OF((deflate_state *s)); |
| 154 | local void bi_flush OF((deflate_state *s)); |
| 155 | |
| 156 | #ifdef GEN_TREES_H |
| 157 | local void gen_trees_header OF((void)); |
| 158 | #endif |
| 159 | |
| 160 | #ifndef ZLIB_DEBUG |
| 161 | # define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) |
| 162 | /* Send a code of the given tree. c and tree must not have side effects */ |
| @@ -165,31 +242,16 @@ | |
| 165 | # define send_code(s, c, tree) \ |
| 166 | { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ |
| 167 | send_bits(s, tree[c].Code, tree[c].Len); } |
| 168 | #endif |
| 169 | |
| 170 | /* =========================================================================== |
| 171 | * Output a short LSB first on the stream. |
| 172 | * IN assertion: there is enough room in pendingBuf. |
| 173 | */ |
| 174 | #define put_short(s, w) { \ |
| 175 | put_byte(s, (uch)((w) & 0xff)); \ |
| 176 | put_byte(s, (uch)((ush)(w) >> 8)); \ |
| 177 | } |
| 178 | |
| 179 | /* =========================================================================== |
| 180 | * Send a value on a given number of bits. |
| 181 | * IN assertion: length <= 16 and value fits in length bits. |
| 182 | */ |
| 183 | #ifdef ZLIB_DEBUG |
| 184 | local void send_bits OF((deflate_state *s, int value, int length)); |
| 185 | |
| 186 | local void send_bits(s, value, length) |
| 187 | deflate_state *s; |
| 188 | int value; /* value to send */ |
| 189 | int length; /* number of bits */ |
| 190 | { |
| 191 | Tracevv((stderr," l %2d v %4x ", length, value)); |
| 192 | Assert(length > 0 && length <= 15, "invalid length"); |
| 193 | s->bits_sent += (ulg)length; |
| 194 | |
| 195 | /* If not enough room in bi_buf, use (valid) bits from bi_buf and |
| @@ -227,12 +289,11 @@ | |
| 227 | /* the arguments must not have side effects */ |
| 228 | |
| 229 | /* =========================================================================== |
| 230 | * Initialize the various 'constant' tables. |
| 231 | */ |
| 232 | local void tr_static_init() |
| 233 | { |
| 234 | #if defined(GEN_TREES_H) || !defined(STDC) |
| 235 | static int static_init_done = 0; |
| 236 | int n; /* iterates over tree elements */ |
| 237 | int bits; /* bit counter */ |
| 238 | int length; /* length value */ |
| @@ -321,12 +382,11 @@ | |
| 321 | |
| 322 | # define SEPARATOR(i, last, width) \ |
| 323 | ((i) == (last)? "\n};\n\n" : \ |
| 324 | ((i) % (width) == (width) - 1 ? ",\n" : ", ")) |
| 325 | |
| 326 | void gen_trees_header() |
| 327 | { |
| 328 | FILE *header = fopen("trees.h", "w"); |
| 329 | int i; |
| 330 | |
| 331 | Assert (header != NULL, "Can't open trees.h"); |
| 332 | fprintf(header, |
| @@ -370,17 +430,31 @@ | |
| 370 | } |
| 371 | |
| 372 | fclose(header); |
| 373 | } |
| 374 | #endif /* GEN_TREES_H */ |
| 375 | |
| 376 | /* =========================================================================== |
| 377 | * Initialize the tree data structures for a new zlib stream. |
| 378 | */ |
| 379 | void ZLIB_INTERNAL _tr_init(s) |
| 380 | deflate_state *s; |
| 381 | { |
| 382 | tr_static_init(); |
| 383 | |
| 384 | s->l_desc.dyn_tree = s->dyn_ltree; |
| 385 | s->l_desc.stat_desc = &static_l_desc; |
| 386 | |
| @@ -399,28 +473,10 @@ | |
| 399 | |
| 400 | /* Initialize the first block of the first file: */ |
| 401 | init_block(s); |
| 402 | } |
| 403 | |
| 404 | /* =========================================================================== |
| 405 | * Initialize a new block. |
| 406 | */ |
| 407 | local void init_block(s) |
| 408 | deflate_state *s; |
| 409 | { |
| 410 | int n; /* iterates over tree elements */ |
| 411 | |
| 412 | /* Initialize the trees. */ |
| 413 | for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; |
| 414 | for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; |
| 415 | for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; |
| 416 | |
| 417 | s->dyn_ltree[END_BLOCK].Freq = 1; |
| 418 | s->opt_len = s->static_len = 0L; |
| 419 | s->sym_next = s->matches = 0; |
| 420 | } |
| 421 | |
| 422 | #define SMALLEST 1 |
| 423 | /* Index within the heap array of least frequent node in the Huffman tree */ |
| 424 | |
| 425 | |
| 426 | /* =========================================================================== |
| @@ -446,15 +502,11 @@ | |
| 446 | * Restore the heap property by moving down the tree starting at node k, |
| 447 | * exchanging a node with the smallest of its two sons if necessary, stopping |
| 448 | * when the heap property is re-established (each father smaller than its |
| 449 | * two sons). |
| 450 | */ |
| 451 | local void pqdownheap(s, tree, k) |
| 452 | deflate_state *s; |
| 453 | ct_data *tree; /* the tree to restore */ |
| 454 | int k; /* node to move down */ |
| 455 | { |
| 456 | int v = s->heap[k]; |
| 457 | int j = k << 1; /* left son of k */ |
| 458 | while (j <= s->heap_len) { |
| 459 | /* Set j to the smallest of the two sons: */ |
| 460 | if (j < s->heap_len && |
| @@ -481,14 +533,11 @@ | |
| 481 | * OUT assertions: the field len is set to the optimal bit length, the |
| 482 | * array bl_count contains the frequencies for each bit length. |
| 483 | * The length opt_len is updated; static_len is also updated if stree is |
| 484 | * not null. |
| 485 | */ |
| 486 | local void gen_bitlen(s, desc) |
| 487 | deflate_state *s; |
| 488 | tree_desc *desc; /* the tree descriptor */ |
| 489 | { |
| 490 | ct_data *tree = desc->dyn_tree; |
| 491 | int max_code = desc->max_code; |
| 492 | const ct_data *stree = desc->stat_desc->static_tree; |
| 493 | const intf *extra = desc->stat_desc->extra_bits; |
| 494 | int base = desc->stat_desc->extra_base; |
| @@ -559,65 +608,23 @@ | |
| 559 | n--; |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | /* =========================================================================== |
| 565 | * Generate the codes for a given tree and bit counts (which need not be |
| 566 | * optimal). |
| 567 | * IN assertion: the array bl_count contains the bit length statistics for |
| 568 | * the given tree and the field len is set for all tree elements. |
| 569 | * OUT assertion: the field code is set for all tree elements of non |
| 570 | * zero code length. |
| 571 | */ |
| 572 | local void gen_codes(tree, max_code, bl_count) |
| 573 | ct_data *tree; /* the tree to decorate */ |
| 574 | int max_code; /* largest code with non zero frequency */ |
| 575 | ushf *bl_count; /* number of codes at each bit length */ |
| 576 | { |
| 577 | ush next_code[MAX_BITS+1]; /* next code value for each bit length */ |
| 578 | unsigned code = 0; /* running code value */ |
| 579 | int bits; /* bit index */ |
| 580 | int n; /* code index */ |
| 581 | |
| 582 | /* The distribution counts are first used to generate the code values |
| 583 | * without bit reversal. |
| 584 | */ |
| 585 | for (bits = 1; bits <= MAX_BITS; bits++) { |
| 586 | code = (code + bl_count[bits - 1]) << 1; |
| 587 | next_code[bits] = (ush)code; |
| 588 | } |
| 589 | /* Check that the bit counts in bl_count are consistent. The last code |
| 590 | * must be all ones. |
| 591 | */ |
| 592 | Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, |
| 593 | "inconsistent bit counts"); |
| 594 | Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); |
| 595 | |
| 596 | for (n = 0; n <= max_code; n++) { |
| 597 | int len = tree[n].Len; |
| 598 | if (len == 0) continue; |
| 599 | /* Now reverse the bits */ |
| 600 | tree[n].Code = (ush)bi_reverse(next_code[len]++, len); |
| 601 | |
| 602 | Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", |
| 603 | n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1)); |
| 604 | } |
| 605 | } |
| 606 | |
| 607 | /* =========================================================================== |
| 608 | * Construct one Huffman tree and assigns the code bit strings and lengths. |
| 609 | * Update the total bit length for the current block. |
| 610 | * IN assertion: the field freq is set for all tree elements. |
| 611 | * OUT assertions: the fields len and code are set to the optimal bit length |
| 612 | * and corresponding code. The length opt_len is updated; static_len is |
| 613 | * also updated if stree is not null. The field max_code is set. |
| 614 | */ |
| 615 | local void build_tree(s, desc) |
| 616 | deflate_state *s; |
| 617 | tree_desc *desc; /* the tree descriptor */ |
| 618 | { |
| 619 | ct_data *tree = desc->dyn_tree; |
| 620 | const ct_data *stree = desc->stat_desc->static_tree; |
| 621 | int elems = desc->stat_desc->elems; |
| 622 | int n, m; /* iterate over heap elements */ |
| 623 | int max_code = -1; /* largest code with non zero frequency */ |
| @@ -698,15 +705,11 @@ | |
| 698 | |
| 699 | /* =========================================================================== |
| 700 | * Scan a literal or distance tree to determine the frequencies of the codes |
| 701 | * in the bit length tree. |
| 702 | */ |
| 703 | local void scan_tree(s, tree, max_code) |
| 704 | deflate_state *s; |
| 705 | ct_data *tree; /* the tree to be scanned */ |
| 706 | int max_code; /* and its largest code of non zero frequency */ |
| 707 | { |
| 708 | int n; /* iterates over all tree elements */ |
| 709 | int prevlen = -1; /* last emitted length */ |
| 710 | int curlen; /* length of current code */ |
| 711 | int nextlen = tree[0].Len; /* length of next code */ |
| 712 | int count = 0; /* repeat count of the current code */ |
| @@ -743,15 +746,11 @@ | |
| 743 | |
| 744 | /* =========================================================================== |
| 745 | * Send a literal or distance tree in compressed form, using the codes in |
| 746 | * bl_tree. |
| 747 | */ |
| 748 | local void send_tree(s, tree, max_code) |
| 749 | deflate_state *s; |
| 750 | ct_data *tree; /* the tree to be scanned */ |
| 751 | int max_code; /* and its largest code of non zero frequency */ |
| 752 | { |
| 753 | int n; /* iterates over all tree elements */ |
| 754 | int prevlen = -1; /* last emitted length */ |
| 755 | int curlen; /* length of current code */ |
| 756 | int nextlen = tree[0].Len; /* length of next code */ |
| 757 | int count = 0; /* repeat count of the current code */ |
| @@ -794,13 +793,11 @@ | |
| 794 | |
| 795 | /* =========================================================================== |
| 796 | * Construct the Huffman tree for the bit lengths and return the index in |
| 797 | * bl_order of the last bit length code to send. |
| 798 | */ |
| 799 | local int build_bl_tree(s) |
| 800 | deflate_state *s; |
| 801 | { |
| 802 | int max_blindex; /* index of last bit length code of non zero freq */ |
| 803 | |
| 804 | /* Determine the bit length frequencies for literal and distance trees */ |
| 805 | scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); |
| 806 | scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); |
| @@ -829,14 +826,12 @@ | |
| 829 | /* =========================================================================== |
| 830 | * Send the header for a block using dynamic Huffman trees: the counts, the |
| 831 | * lengths of the bit length codes, the literal tree and the distance tree. |
| 832 | * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. |
| 833 | */ |
| 834 | local void send_all_trees(s, lcodes, dcodes, blcodes) |
| 835 | deflate_state *s; |
| 836 | int lcodes, dcodes, blcodes; /* number of codes for each tree */ |
| 837 | { |
| 838 | int rank; /* index in bl_order */ |
| 839 | |
| 840 | Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); |
| 841 | Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, |
| 842 | "too many codes"); |
| @@ -858,16 +853,12 @@ | |
| 858 | } |
| 859 | |
| 860 | /* =========================================================================== |
| 861 | * Send a stored block |
| 862 | */ |
| 863 | void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) |
| 864 | deflate_state *s; |
| 865 | charf *buf; /* input block */ |
| 866 | ulg stored_len; /* length of input block */ |
| 867 | int last; /* one if this is the last block for a file */ |
| 868 | { |
| 869 | send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */ |
| 870 | bi_windup(s); /* align on byte boundary */ |
| 871 | put_short(s, (ush)stored_len); |
| 872 | put_short(s, (ush)~stored_len); |
| 873 | if (stored_len) |
| @@ -882,41 +873,120 @@ | |
| 882 | } |
| 883 | |
| 884 | /* =========================================================================== |
| 885 | * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) |
| 886 | */ |
| 887 | void ZLIB_INTERNAL _tr_flush_bits(s) |
| 888 | deflate_state *s; |
| 889 | { |
| 890 | bi_flush(s); |
| 891 | } |
| 892 | |
| 893 | /* =========================================================================== |
| 894 | * Send one empty static block to give enough lookahead for inflate. |
| 895 | * This takes 10 bits, of which 7 may remain in the bit buffer. |
| 896 | */ |
| 897 | void ZLIB_INTERNAL _tr_align(s) |
| 898 | deflate_state *s; |
| 899 | { |
| 900 | send_bits(s, STATIC_TREES<<1, 3); |
| 901 | send_code(s, END_BLOCK, static_ltree); |
| 902 | #ifdef ZLIB_DEBUG |
| 903 | s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ |
| 904 | #endif |
| 905 | bi_flush(s); |
| 906 | } |
| 907 | |
| 908 | /* =========================================================================== |
| 909 | * Determine the best encoding for the current block: dynamic trees, static |
| 910 | * trees or store, and write out the encoded block. |
| 911 | */ |
| 912 | void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) |
| 913 | deflate_state *s; |
| 914 | charf *buf; /* input block, or NULL if too old */ |
| 915 | ulg stored_len; /* length of input block */ |
| 916 | int last; /* one if this is the last block for a file */ |
| 917 | { |
| 918 | ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ |
| 919 | int max_blindex = 0; /* index of last bit length code of non zero freq */ |
| 920 | |
| 921 | /* Build the Huffman trees unless a stored block is forced */ |
| 922 | if (s->level > 0) { |
| @@ -1009,15 +1079,11 @@ | |
| 1009 | |
| 1010 | /* =========================================================================== |
| 1011 | * Save the match info and tally the frequency counts. Return true if |
| 1012 | * the current block must be flushed. |
| 1013 | */ |
| 1014 | int ZLIB_INTERNAL _tr_tally(s, dist, lc) |
| 1015 | deflate_state *s; |
| 1016 | unsigned dist; /* distance of matched string */ |
| 1017 | unsigned lc; /* match length - MIN_MATCH or unmatched char (dist==0) */ |
| 1018 | { |
| 1019 | s->sym_buf[s->sym_next++] = (uch)dist; |
| 1020 | s->sym_buf[s->sym_next++] = (uch)(dist >> 8); |
| 1021 | s->sym_buf[s->sym_next++] = (uch)lc; |
| 1022 | if (dist == 0) { |
| 1023 | /* lc is the unmatched char */ |
| @@ -1033,149 +1099,5 @@ | |
| 1033 | s->dyn_ltree[_length_code[lc] + LITERALS + 1].Freq++; |
| 1034 | s->dyn_dtree[d_code(dist)].Freq++; |
| 1035 | } |
| 1036 | return (s->sym_next == s->sym_end); |
| 1037 | } |
| 1038 | |
| 1039 | /* =========================================================================== |
| 1040 | * Send the block data compressed using the given Huffman trees |
| 1041 | */ |
| 1042 | local void compress_block(s, ltree, dtree) |
| 1043 | deflate_state *s; |
| 1044 | const ct_data *ltree; /* literal tree */ |
| 1045 | const ct_data *dtree; /* distance tree */ |
| 1046 | { |
| 1047 | unsigned dist; /* distance of matched string */ |
| 1048 | int lc; /* match length or unmatched char (if dist == 0) */ |
| 1049 | unsigned sx = 0; /* running index in sym_buf */ |
| 1050 | unsigned code; /* the code to send */ |
| 1051 | int extra; /* number of extra bits to send */ |
| 1052 | |
| 1053 | if (s->sym_next != 0) do { |
| 1054 | dist = s->sym_buf[sx++] & 0xff; |
| 1055 | dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; |
| 1056 | lc = s->sym_buf[sx++]; |
| 1057 | if (dist == 0) { |
| 1058 | send_code(s, lc, ltree); /* send a literal byte */ |
| 1059 | Tracecv(isgraph(lc), (stderr," '%c' ", lc)); |
| 1060 | } else { |
| 1061 | /* Here, lc is the match length - MIN_MATCH */ |
| 1062 | code = _length_code[lc]; |
| 1063 | send_code(s, code + LITERALS + 1, ltree); /* send length code */ |
| 1064 | extra = extra_lbits[code]; |
| 1065 | if (extra != 0) { |
| 1066 | lc -= base_length[code]; |
| 1067 | send_bits(s, lc, extra); /* send the extra length bits */ |
| 1068 | } |
| 1069 | dist--; /* dist is now the match distance - 1 */ |
| 1070 | code = d_code(dist); |
| 1071 | Assert (code < D_CODES, "bad d_code"); |
| 1072 | |
| 1073 | send_code(s, code, dtree); /* send the distance code */ |
| 1074 | extra = extra_dbits[code]; |
| 1075 | if (extra != 0) { |
| 1076 | dist -= (unsigned)base_dist[code]; |
| 1077 | send_bits(s, dist, extra); /* send the extra distance bits */ |
| 1078 | } |
| 1079 | } /* literal or match pair ? */ |
| 1080 | |
| 1081 | /* Check that the overlay between pending_buf and sym_buf is ok: */ |
| 1082 | Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); |
| 1083 | |
| 1084 | } while (sx < s->sym_next); |
| 1085 | |
| 1086 | send_code(s, END_BLOCK, ltree); |
| 1087 | } |
| 1088 | |
| 1089 | /* =========================================================================== |
| 1090 | * Check if the data type is TEXT or BINARY, using the following algorithm: |
| 1091 | * - TEXT if the two conditions below are satisfied: |
| 1092 | * a) There are no non-portable control characters belonging to the |
| 1093 | * "block list" (0..6, 14..25, 28..31). |
| 1094 | * b) There is at least one printable character belonging to the |
| 1095 | * "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). |
| 1096 | * - BINARY otherwise. |
| 1097 | * - The following partially-portable control characters form a |
| 1098 | * "gray list" that is ignored in this detection algorithm: |
| 1099 | * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). |
| 1100 | * IN assertion: the fields Freq of dyn_ltree are set. |
| 1101 | */ |
| 1102 | local int detect_data_type(s) |
| 1103 | deflate_state *s; |
| 1104 | { |
| 1105 | /* block_mask is the bit mask of block-listed bytes |
| 1106 | * set bits 0..6, 14..25, and 28..31 |
| 1107 | * 0xf3ffc07f = binary 11110011111111111100000001111111 |
| 1108 | */ |
| 1109 | unsigned long block_mask = 0xf3ffc07fUL; |
| 1110 | int n; |
| 1111 | |
| 1112 | /* Check for non-textual ("block-listed") bytes. */ |
| 1113 | for (n = 0; n <= 31; n++, block_mask >>= 1) |
| 1114 | if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0)) |
| 1115 | return Z_BINARY; |
| 1116 | |
| 1117 | /* Check for textual ("allow-listed") bytes. */ |
| 1118 | if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 |
| 1119 | || s->dyn_ltree[13].Freq != 0) |
| 1120 | return Z_TEXT; |
| 1121 | for (n = 32; n < LITERALS; n++) |
| 1122 | if (s->dyn_ltree[n].Freq != 0) |
| 1123 | return Z_TEXT; |
| 1124 | |
| 1125 | /* There are no "block-listed" or "allow-listed" bytes: |
| 1126 | * this stream either is empty or has tolerated ("gray-listed") bytes only. |
| 1127 | */ |
| 1128 | return Z_BINARY; |
| 1129 | } |
| 1130 | |
| 1131 | /* =========================================================================== |
| 1132 | * Reverse the first len bits of a code, using straightforward code (a faster |
| 1133 | * method would use a table) |
| 1134 | * IN assertion: 1 <= len <= 15 |
| 1135 | */ |
| 1136 | local unsigned bi_reverse(code, len) |
| 1137 | unsigned code; /* the value to invert */ |
| 1138 | int len; /* its bit length */ |
| 1139 | { |
| 1140 | register unsigned res = 0; |
| 1141 | do { |
| 1142 | res |= code & 1; |
| 1143 | code >>= 1, res <<= 1; |
| 1144 | } while (--len > 0); |
| 1145 | return res >> 1; |
| 1146 | } |
| 1147 | |
| 1148 | /* =========================================================================== |
| 1149 | * Flush the bit buffer, keeping at most 7 bits in it. |
| 1150 | */ |
| 1151 | local void bi_flush(s) |
| 1152 | deflate_state *s; |
| 1153 | { |
| 1154 | if (s->bi_valid == 16) { |
| 1155 | put_short(s, s->bi_buf); |
| 1156 | s->bi_buf = 0; |
| 1157 | s->bi_valid = 0; |
| 1158 | } else if (s->bi_valid >= 8) { |
| 1159 | put_byte(s, (Byte)s->bi_buf); |
| 1160 | s->bi_buf >>= 8; |
| 1161 | s->bi_valid -= 8; |
| 1162 | } |
| 1163 | } |
| 1164 | |
| 1165 | /* =========================================================================== |
| 1166 | * Flush the bit buffer and align the output on a byte boundary |
| 1167 | */ |
| 1168 | local void bi_windup(s) |
| 1169 | deflate_state *s; |
| 1170 | { |
| 1171 | if (s->bi_valid > 8) { |
| 1172 | put_short(s, s->bi_buf); |
| 1173 | } else if (s->bi_valid > 0) { |
| 1174 | put_byte(s, (Byte)s->bi_buf); |
| 1175 | } |
| 1176 | s->bi_buf = 0; |
| 1177 | s->bi_valid = 0; |
| 1178 | #ifdef ZLIB_DEBUG |
| 1179 | s->bits_sent = (s->bits_sent + 7) & ~7; |
| 1180 | #endif |
| 1181 | } |
| 1182 |
| --- compat/zlib/trees.c | |
| +++ compat/zlib/trees.c | |
| @@ -120,43 +120,120 @@ | |
| 120 | int extra_base; /* base index for extra_bits */ |
| 121 | int elems; /* max number of elements in the tree */ |
| 122 | int max_length; /* max bit length for the codes */ |
| 123 | }; |
| 124 | |
| 125 | #ifdef NO_INIT_GLOBAL_POINTERS |
| 126 | # define TCONST |
| 127 | #else |
| 128 | # define TCONST const |
| 129 | #endif |
| 130 | |
| 131 | local TCONST static_tree_desc static_l_desc = |
| 132 | {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; |
| 133 | |
| 134 | local TCONST static_tree_desc static_d_desc = |
| 135 | {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; |
| 136 | |
| 137 | local TCONST static_tree_desc static_bl_desc = |
| 138 | {(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; |
| 139 | |
| 140 | /* =========================================================================== |
| 141 | * Output a short LSB first on the stream. |
| 142 | * IN assertion: there is enough room in pendingBuf. |
| 143 | */ |
| 144 | #define put_short(s, w) { \ |
| 145 | put_byte(s, (uch)((w) & 0xff)); \ |
| 146 | put_byte(s, (uch)((ush)(w) >> 8)); \ |
| 147 | } |
| 148 | |
| 149 | /* =========================================================================== |
| 150 | * Reverse the first len bits of a code, using straightforward code (a faster |
| 151 | * method would use a table) |
| 152 | * IN assertion: 1 <= len <= 15 |
| 153 | */ |
| 154 | local unsigned bi_reverse(unsigned code, int len) { |
| 155 | register unsigned res = 0; |
| 156 | do { |
| 157 | res |= code & 1; |
| 158 | code >>= 1, res <<= 1; |
| 159 | } while (--len > 0); |
| 160 | return res >> 1; |
| 161 | } |
| 162 | |
| 163 | /* =========================================================================== |
| 164 | * Flush the bit buffer, keeping at most 7 bits in it. |
| 165 | */ |
| 166 | local void bi_flush(deflate_state *s) { |
| 167 | if (s->bi_valid == 16) { |
| 168 | put_short(s, s->bi_buf); |
| 169 | s->bi_buf = 0; |
| 170 | s->bi_valid = 0; |
| 171 | } else if (s->bi_valid >= 8) { |
| 172 | put_byte(s, (Byte)s->bi_buf); |
| 173 | s->bi_buf >>= 8; |
| 174 | s->bi_valid -= 8; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | /* =========================================================================== |
| 179 | * Flush the bit buffer and align the output on a byte boundary |
| 180 | */ |
| 181 | local void bi_windup(deflate_state *s) { |
| 182 | if (s->bi_valid > 8) { |
| 183 | put_short(s, s->bi_buf); |
| 184 | } else if (s->bi_valid > 0) { |
| 185 | put_byte(s, (Byte)s->bi_buf); |
| 186 | } |
| 187 | s->bi_buf = 0; |
| 188 | s->bi_valid = 0; |
| 189 | #ifdef ZLIB_DEBUG |
| 190 | s->bits_sent = (s->bits_sent + 7) & ~7; |
| 191 | #endif |
| 192 | } |
| 193 | |
| 194 | /* =========================================================================== |
| 195 | * Generate the codes for a given tree and bit counts (which need not be |
| 196 | * optimal). |
| 197 | * IN assertion: the array bl_count contains the bit length statistics for |
| 198 | * the given tree and the field len is set for all tree elements. |
| 199 | * OUT assertion: the field code is set for all tree elements of non |
| 200 | * zero code length. |
| 201 | */ |
| 202 | local void gen_codes(ct_data *tree, int max_code, ushf *bl_count) { |
| 203 | ush next_code[MAX_BITS+1]; /* next code value for each bit length */ |
| 204 | unsigned code = 0; /* running code value */ |
| 205 | int bits; /* bit index */ |
| 206 | int n; /* code index */ |
| 207 | |
| 208 | /* The distribution counts are first used to generate the code values |
| 209 | * without bit reversal. |
| 210 | */ |
| 211 | for (bits = 1; bits <= MAX_BITS; bits++) { |
| 212 | code = (code + bl_count[bits - 1]) << 1; |
| 213 | next_code[bits] = (ush)code; |
| 214 | } |
| 215 | /* Check that the bit counts in bl_count are consistent. The last code |
| 216 | * must be all ones. |
| 217 | */ |
| 218 | Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, |
| 219 | "inconsistent bit counts"); |
| 220 | Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); |
| 221 | |
| 222 | for (n = 0; n <= max_code; n++) { |
| 223 | int len = tree[n].Len; |
| 224 | if (len == 0) continue; |
| 225 | /* Now reverse the bits */ |
| 226 | tree[n].Code = (ush)bi_reverse(next_code[len]++, len); |
| 227 | |
| 228 | Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", |
| 229 | n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1)); |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | #ifdef GEN_TREES_H |
| 234 | local void gen_trees_header(void); |
| 235 | #endif |
| 236 | |
| 237 | #ifndef ZLIB_DEBUG |
| 238 | # define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) |
| 239 | /* Send a code of the given tree. c and tree must not have side effects */ |
| @@ -165,31 +242,16 @@ | |
| 242 | # define send_code(s, c, tree) \ |
| 243 | { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ |
| 244 | send_bits(s, tree[c].Code, tree[c].Len); } |
| 245 | #endif |
| 246 | |
| 247 | /* =========================================================================== |
| 248 | * Send a value on a given number of bits. |
| 249 | * IN assertion: length <= 16 and value fits in length bits. |
| 250 | */ |
| 251 | #ifdef ZLIB_DEBUG |
| 252 | local void send_bits(deflate_state *s, int value, int length) { |
| 253 | Tracevv((stderr," l %2d v %4x ", length, value)); |
| 254 | Assert(length > 0 && length <= 15, "invalid length"); |
| 255 | s->bits_sent += (ulg)length; |
| 256 | |
| 257 | /* If not enough room in bi_buf, use (valid) bits from bi_buf and |
| @@ -227,12 +289,11 @@ | |
| 289 | /* the arguments must not have side effects */ |
| 290 | |
| 291 | /* =========================================================================== |
| 292 | * Initialize the various 'constant' tables. |
| 293 | */ |
| 294 | local void tr_static_init(void) { |
| 295 | #if defined(GEN_TREES_H) || !defined(STDC) |
| 296 | static int static_init_done = 0; |
| 297 | int n; /* iterates over tree elements */ |
| 298 | int bits; /* bit counter */ |
| 299 | int length; /* length value */ |
| @@ -321,12 +382,11 @@ | |
| 382 | |
| 383 | # define SEPARATOR(i, last, width) \ |
| 384 | ((i) == (last)? "\n};\n\n" : \ |
| 385 | ((i) % (width) == (width) - 1 ? ",\n" : ", ")) |
| 386 | |
| 387 | void gen_trees_header(void) { |
| 388 | FILE *header = fopen("trees.h", "w"); |
| 389 | int i; |
| 390 | |
| 391 | Assert (header != NULL, "Can't open trees.h"); |
| 392 | fprintf(header, |
| @@ -370,17 +430,31 @@ | |
| 430 | } |
| 431 | |
| 432 | fclose(header); |
| 433 | } |
| 434 | #endif /* GEN_TREES_H */ |
| 435 | |
| 436 | /* =========================================================================== |
| 437 | * Initialize a new block. |
| 438 | */ |
| 439 | local void init_block(deflate_state *s) { |
| 440 | int n; /* iterates over tree elements */ |
| 441 | |
| 442 | /* Initialize the trees. */ |
| 443 | for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; |
| 444 | for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; |
| 445 | for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; |
| 446 | |
| 447 | s->dyn_ltree[END_BLOCK].Freq = 1; |
| 448 | s->opt_len = s->static_len = 0L; |
| 449 | s->sym_next = s->matches = 0; |
| 450 | } |
| 451 | |
| 452 | /* =========================================================================== |
| 453 | * Initialize the tree data structures for a new zlib stream. |
| 454 | */ |
| 455 | void ZLIB_INTERNAL _tr_init(deflate_state *s) { |
| 456 | tr_static_init(); |
| 457 | |
| 458 | s->l_desc.dyn_tree = s->dyn_ltree; |
| 459 | s->l_desc.stat_desc = &static_l_desc; |
| 460 | |
| @@ -399,28 +473,10 @@ | |
| 473 | |
| 474 | /* Initialize the first block of the first file: */ |
| 475 | init_block(s); |
| 476 | } |
| 477 | |
| 478 | #define SMALLEST 1 |
| 479 | /* Index within the heap array of least frequent node in the Huffman tree */ |
| 480 | |
| 481 | |
| 482 | /* =========================================================================== |
| @@ -446,15 +502,11 @@ | |
| 502 | * Restore the heap property by moving down the tree starting at node k, |
| 503 | * exchanging a node with the smallest of its two sons if necessary, stopping |
| 504 | * when the heap property is re-established (each father smaller than its |
| 505 | * two sons). |
| 506 | */ |
| 507 | local void pqdownheap(deflate_state *s, ct_data *tree, int k) { |
| 508 | int v = s->heap[k]; |
| 509 | int j = k << 1; /* left son of k */ |
| 510 | while (j <= s->heap_len) { |
| 511 | /* Set j to the smallest of the two sons: */ |
| 512 | if (j < s->heap_len && |
| @@ -481,14 +533,11 @@ | |
| 533 | * OUT assertions: the field len is set to the optimal bit length, the |
| 534 | * array bl_count contains the frequencies for each bit length. |
| 535 | * The length opt_len is updated; static_len is also updated if stree is |
| 536 | * not null. |
| 537 | */ |
| 538 | local void gen_bitlen(deflate_state *s, tree_desc *desc) { |
| 539 | ct_data *tree = desc->dyn_tree; |
| 540 | int max_code = desc->max_code; |
| 541 | const ct_data *stree = desc->stat_desc->static_tree; |
| 542 | const intf *extra = desc->stat_desc->extra_bits; |
| 543 | int base = desc->stat_desc->extra_base; |
| @@ -559,65 +608,23 @@ | |
| 608 | n--; |
| 609 | } |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | #ifdef DUMP_BL_TREE |
| 614 | # include <stdio.h> |
| 615 | #endif |
| 616 | |
| 617 | /* =========================================================================== |
| 618 | * Construct one Huffman tree and assigns the code bit strings and lengths. |
| 619 | * Update the total bit length for the current block. |
| 620 | * IN assertion: the field freq is set for all tree elements. |
| 621 | * OUT assertions: the fields len and code are set to the optimal bit length |
| 622 | * and corresponding code. The length opt_len is updated; static_len is |
| 623 | * also updated if stree is not null. The field max_code is set. |
| 624 | */ |
| 625 | local void build_tree(deflate_state *s, tree_desc *desc) { |
| 626 | ct_data *tree = desc->dyn_tree; |
| 627 | const ct_data *stree = desc->stat_desc->static_tree; |
| 628 | int elems = desc->stat_desc->elems; |
| 629 | int n, m; /* iterate over heap elements */ |
| 630 | int max_code = -1; /* largest code with non zero frequency */ |
| @@ -698,15 +705,11 @@ | |
| 705 | |
| 706 | /* =========================================================================== |
| 707 | * Scan a literal or distance tree to determine the frequencies of the codes |
| 708 | * in the bit length tree. |
| 709 | */ |
| 710 | local void scan_tree(deflate_state *s, ct_data *tree, int max_code) { |
| 711 | int n; /* iterates over all tree elements */ |
| 712 | int prevlen = -1; /* last emitted length */ |
| 713 | int curlen; /* length of current code */ |
| 714 | int nextlen = tree[0].Len; /* length of next code */ |
| 715 | int count = 0; /* repeat count of the current code */ |
| @@ -743,15 +746,11 @@ | |
| 746 | |
| 747 | /* =========================================================================== |
| 748 | * Send a literal or distance tree in compressed form, using the codes in |
| 749 | * bl_tree. |
| 750 | */ |
| 751 | local void send_tree(deflate_state *s, ct_data *tree, int max_code) { |
| 752 | int n; /* iterates over all tree elements */ |
| 753 | int prevlen = -1; /* last emitted length */ |
| 754 | int curlen; /* length of current code */ |
| 755 | int nextlen = tree[0].Len; /* length of next code */ |
| 756 | int count = 0; /* repeat count of the current code */ |
| @@ -794,13 +793,11 @@ | |
| 793 | |
| 794 | /* =========================================================================== |
| 795 | * Construct the Huffman tree for the bit lengths and return the index in |
| 796 | * bl_order of the last bit length code to send. |
| 797 | */ |
| 798 | local int build_bl_tree(deflate_state *s) { |
| 799 | int max_blindex; /* index of last bit length code of non zero freq */ |
| 800 | |
| 801 | /* Determine the bit length frequencies for literal and distance trees */ |
| 802 | scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); |
| 803 | scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); |
| @@ -829,14 +826,12 @@ | |
| 826 | /* =========================================================================== |
| 827 | * Send the header for a block using dynamic Huffman trees: the counts, the |
| 828 | * lengths of the bit length codes, the literal tree and the distance tree. |
| 829 | * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. |
| 830 | */ |
| 831 | local void send_all_trees(deflate_state *s, int lcodes, int dcodes, |
| 832 | int blcodes) { |
| 833 | int rank; /* index in bl_order */ |
| 834 | |
| 835 | Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); |
| 836 | Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, |
| 837 | "too many codes"); |
| @@ -858,16 +853,12 @@ | |
| 853 | } |
| 854 | |
| 855 | /* =========================================================================== |
| 856 | * Send a stored block |
| 857 | */ |
| 858 | void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, |
| 859 | ulg stored_len, int last) { |
| 860 | send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */ |
| 861 | bi_windup(s); /* align on byte boundary */ |
| 862 | put_short(s, (ush)stored_len); |
| 863 | put_short(s, (ush)~stored_len); |
| 864 | if (stored_len) |
| @@ -882,41 +873,120 @@ | |
| 873 | } |
| 874 | |
| 875 | /* =========================================================================== |
| 876 | * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) |
| 877 | */ |
| 878 | void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s) { |
| 879 | bi_flush(s); |
| 880 | } |
| 881 | |
| 882 | /* =========================================================================== |
| 883 | * Send one empty static block to give enough lookahead for inflate. |
| 884 | * This takes 10 bits, of which 7 may remain in the bit buffer. |
| 885 | */ |
| 886 | void ZLIB_INTERNAL _tr_align(deflate_state *s) { |
| 887 | send_bits(s, STATIC_TREES<<1, 3); |
| 888 | send_code(s, END_BLOCK, static_ltree); |
| 889 | #ifdef ZLIB_DEBUG |
| 890 | s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ |
| 891 | #endif |
| 892 | bi_flush(s); |
| 893 | } |
| 894 | |
| 895 | /* =========================================================================== |
| 896 | * Send the block data compressed using the given Huffman trees |
| 897 | */ |
| 898 | local void compress_block(deflate_state *s, const ct_data *ltree, |
| 899 | const ct_data *dtree) { |
| 900 | unsigned dist; /* distance of matched string */ |
| 901 | int lc; /* match length or unmatched char (if dist == 0) */ |
| 902 | unsigned sx = 0; /* running index in sym_buf */ |
| 903 | unsigned code; /* the code to send */ |
| 904 | int extra; /* number of extra bits to send */ |
| 905 | |
| 906 | if (s->sym_next != 0) do { |
| 907 | dist = s->sym_buf[sx++] & 0xff; |
| 908 | dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; |
| 909 | lc = s->sym_buf[sx++]; |
| 910 | if (dist == 0) { |
| 911 | send_code(s, lc, ltree); /* send a literal byte */ |
| 912 | Tracecv(isgraph(lc), (stderr," '%c' ", lc)); |
| 913 | } else { |
| 914 | /* Here, lc is the match length - MIN_MATCH */ |
| 915 | code = _length_code[lc]; |
| 916 | send_code(s, code + LITERALS + 1, ltree); /* send length code */ |
| 917 | extra = extra_lbits[code]; |
| 918 | if (extra != 0) { |
| 919 | lc -= base_length[code]; |
| 920 | send_bits(s, lc, extra); /* send the extra length bits */ |
| 921 | } |
| 922 | dist--; /* dist is now the match distance - 1 */ |
| 923 | code = d_code(dist); |
| 924 | Assert (code < D_CODES, "bad d_code"); |
| 925 | |
| 926 | send_code(s, code, dtree); /* send the distance code */ |
| 927 | extra = extra_dbits[code]; |
| 928 | if (extra != 0) { |
| 929 | dist -= (unsigned)base_dist[code]; |
| 930 | send_bits(s, dist, extra); /* send the extra distance bits */ |
| 931 | } |
| 932 | } /* literal or match pair ? */ |
| 933 | |
| 934 | /* Check that the overlay between pending_buf and sym_buf is ok: */ |
| 935 | Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); |
| 936 | |
| 937 | } while (sx < s->sym_next); |
| 938 | |
| 939 | send_code(s, END_BLOCK, ltree); |
| 940 | } |
| 941 | |
| 942 | /* =========================================================================== |
| 943 | * Check if the data type is TEXT or BINARY, using the following algorithm: |
| 944 | * - TEXT if the two conditions below are satisfied: |
| 945 | * a) There are no non-portable control characters belonging to the |
| 946 | * "block list" (0..6, 14..25, 28..31). |
| 947 | * b) There is at least one printable character belonging to the |
| 948 | * "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). |
| 949 | * - BINARY otherwise. |
| 950 | * - The following partially-portable control characters form a |
| 951 | * "gray list" that is ignored in this detection algorithm: |
| 952 | * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). |
| 953 | * IN assertion: the fields Freq of dyn_ltree are set. |
| 954 | */ |
| 955 | local int detect_data_type(deflate_state *s) { |
| 956 | /* block_mask is the bit mask of block-listed bytes |
| 957 | * set bits 0..6, 14..25, and 28..31 |
| 958 | * 0xf3ffc07f = binary 11110011111111111100000001111111 |
| 959 | */ |
| 960 | unsigned long block_mask = 0xf3ffc07fUL; |
| 961 | int n; |
| 962 | |
| 963 | /* Check for non-textual ("block-listed") bytes. */ |
| 964 | for (n = 0; n <= 31; n++, block_mask >>= 1) |
| 965 | if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0)) |
| 966 | return Z_BINARY; |
| 967 | |
| 968 | /* Check for textual ("allow-listed") bytes. */ |
| 969 | if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 |
| 970 | || s->dyn_ltree[13].Freq != 0) |
| 971 | return Z_TEXT; |
| 972 | for (n = 32; n < LITERALS; n++) |
| 973 | if (s->dyn_ltree[n].Freq != 0) |
| 974 | return Z_TEXT; |
| 975 | |
| 976 | /* There are no "block-listed" or "allow-listed" bytes: |
| 977 | * this stream either is empty or has tolerated ("gray-listed") bytes only. |
| 978 | */ |
| 979 | return Z_BINARY; |
| 980 | } |
| 981 | |
| 982 | /* =========================================================================== |
| 983 | * Determine the best encoding for the current block: dynamic trees, static |
| 984 | * trees or store, and write out the encoded block. |
| 985 | */ |
| 986 | void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, |
| 987 | ulg stored_len, int last) { |
| 988 | ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ |
| 989 | int max_blindex = 0; /* index of last bit length code of non zero freq */ |
| 990 | |
| 991 | /* Build the Huffman trees unless a stored block is forced */ |
| 992 | if (s->level > 0) { |
| @@ -1009,15 +1079,11 @@ | |
| 1079 | |
| 1080 | /* =========================================================================== |
| 1081 | * Save the match info and tally the frequency counts. Return true if |
| 1082 | * the current block must be flushed. |
| 1083 | */ |
| 1084 | int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) { |
| 1085 | s->sym_buf[s->sym_next++] = (uch)dist; |
| 1086 | s->sym_buf[s->sym_next++] = (uch)(dist >> 8); |
| 1087 | s->sym_buf[s->sym_next++] = (uch)lc; |
| 1088 | if (dist == 0) { |
| 1089 | /* lc is the unmatched char */ |
| @@ -1033,149 +1099,5 @@ | |
| 1099 | s->dyn_ltree[_length_code[lc] + LITERALS + 1].Freq++; |
| 1100 | s->dyn_dtree[d_code(dist)].Freq++; |
| 1101 | } |
| 1102 | return (s->sym_next == s->sym_end); |
| 1103 | } |
| 1104 |
+4
-12
| --- compat/zlib/uncompr.c | ||
| +++ compat/zlib/uncompr.c | ||
| @@ -22,16 +22,12 @@ | ||
| 22 | 22 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 23 | 23 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, or |
| 24 | 24 | Z_DATA_ERROR if the input data was corrupted, including if the input data is |
| 25 | 25 | an incomplete zlib stream. |
| 26 | 26 | */ |
| 27 | -int ZEXPORT uncompress2(dest, destLen, source, sourceLen) | |
| 28 | - Bytef *dest; | |
| 29 | - uLongf *destLen; | |
| 30 | - const Bytef *source; | |
| 31 | - uLong *sourceLen; | |
| 32 | -{ | |
| 27 | +int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source, | |
| 28 | + uLong *sourceLen) { | |
| 33 | 29 | z_stream stream; |
| 34 | 30 | int err; |
| 35 | 31 | const uInt max = (uInt)-1; |
| 36 | 32 | uLong len, left; |
| 37 | 33 | Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */ |
| @@ -81,13 +77,9 @@ | ||
| 81 | 77 | err == Z_NEED_DICT ? Z_DATA_ERROR : |
| 82 | 78 | err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR : |
| 83 | 79 | err; |
| 84 | 80 | } |
| 85 | 81 | |
| 86 | -int ZEXPORT uncompress(dest, destLen, source, sourceLen) | |
| 87 | - Bytef *dest; | |
| 88 | - uLongf *destLen; | |
| 89 | - const Bytef *source; | |
| 90 | - uLong sourceLen; | |
| 91 | -{ | |
| 82 | +int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, | |
| 83 | + uLong sourceLen) { | |
| 92 | 84 | return uncompress2(dest, destLen, source, &sourceLen); |
| 93 | 85 | } |
| 94 | 86 |
| --- compat/zlib/uncompr.c | |
| +++ compat/zlib/uncompr.c | |
| @@ -22,16 +22,12 @@ | |
| 22 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 23 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, or |
| 24 | Z_DATA_ERROR if the input data was corrupted, including if the input data is |
| 25 | an incomplete zlib stream. |
| 26 | */ |
| 27 | int ZEXPORT uncompress2(dest, destLen, source, sourceLen) |
| 28 | Bytef *dest; |
| 29 | uLongf *destLen; |
| 30 | const Bytef *source; |
| 31 | uLong *sourceLen; |
| 32 | { |
| 33 | z_stream stream; |
| 34 | int err; |
| 35 | const uInt max = (uInt)-1; |
| 36 | uLong len, left; |
| 37 | Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */ |
| @@ -81,13 +77,9 @@ | |
| 81 | err == Z_NEED_DICT ? Z_DATA_ERROR : |
| 82 | err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR : |
| 83 | err; |
| 84 | } |
| 85 | |
| 86 | int ZEXPORT uncompress(dest, destLen, source, sourceLen) |
| 87 | Bytef *dest; |
| 88 | uLongf *destLen; |
| 89 | const Bytef *source; |
| 90 | uLong sourceLen; |
| 91 | { |
| 92 | return uncompress2(dest, destLen, source, &sourceLen); |
| 93 | } |
| 94 |
| --- compat/zlib/uncompr.c | |
| +++ compat/zlib/uncompr.c | |
| @@ -22,16 +22,12 @@ | |
| 22 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 23 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, or |
| 24 | Z_DATA_ERROR if the input data was corrupted, including if the input data is |
| 25 | an incomplete zlib stream. |
| 26 | */ |
| 27 | int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source, |
| 28 | uLong *sourceLen) { |
| 29 | z_stream stream; |
| 30 | int err; |
| 31 | const uInt max = (uInt)-1; |
| 32 | uLong len, left; |
| 33 | Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */ |
| @@ -81,13 +77,9 @@ | |
| 77 | err == Z_NEED_DICT ? Z_DATA_ERROR : |
| 78 | err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR : |
| 79 | err; |
| 80 | } |
| 81 | |
| 82 | int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, |
| 83 | uLong sourceLen) { |
| 84 | return uncompress2(dest, destLen, source, &sourceLen); |
| 85 | } |
| 86 |
| --- compat/zlib/win32/README-WIN32.txt | ||
| +++ compat/zlib/win32/README-WIN32.txt | ||
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | ZLIB DATA COMPRESSION LIBRARY |
| 2 | 2 | |
| 3 | -zlib 1.2.13 is a general purpose data compression library. All the code is | |
| 3 | +zlib 1.3.0 is a general purpose data compression library. All the code is | |
| 4 | 4 | thread safe. The data format used by the zlib library is described by RFCs |
| 5 | 5 | (Request for Comments) 1950 to 1952 in the files |
| 6 | 6 | http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) |
| 7 | 7 | and rfc1952.txt (gzip format). |
| 8 | 8 | |
| @@ -20,11 +20,11 @@ | ||
| 20 | 20 | before asking for help. |
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | Manifest: |
| 24 | 24 | |
| 25 | -The package zlib-1.2.13-win32-x86.zip will contain the following files: | |
| 25 | +The package zlib-1.3.0-win32-x86.zip will contain the following files: | |
| 26 | 26 | |
| 27 | 27 | README-WIN32.txt This document |
| 28 | 28 | ChangeLog Changes since previous zlib packages |
| 29 | 29 | DLL_FAQ.txt Frequently asked questions about zlib1.dll |
| 30 | 30 | zlib.3.pdf Documentation of this library in Adobe Acrobat format |
| 31 | 31 |
| --- compat/zlib/win32/README-WIN32.txt | |
| +++ compat/zlib/win32/README-WIN32.txt | |
| @@ -1,8 +1,8 @@ | |
| 1 | ZLIB DATA COMPRESSION LIBRARY |
| 2 | |
| 3 | zlib 1.2.13 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 |
| 5 | (Request for Comments) 1950 to 1952 in the files |
| 6 | http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) |
| 7 | and rfc1952.txt (gzip format). |
| 8 | |
| @@ -20,11 +20,11 @@ | |
| 20 | before asking for help. |
| 21 | |
| 22 | |
| 23 | Manifest: |
| 24 | |
| 25 | The package zlib-1.2.13-win32-x86.zip will contain the following files: |
| 26 | |
| 27 | README-WIN32.txt This document |
| 28 | ChangeLog Changes since previous zlib packages |
| 29 | DLL_FAQ.txt Frequently asked questions about zlib1.dll |
| 30 | zlib.3.pdf Documentation of this library in Adobe Acrobat format |
| 31 |
| --- compat/zlib/win32/README-WIN32.txt | |
| +++ compat/zlib/win32/README-WIN32.txt | |
| @@ -1,8 +1,8 @@ | |
| 1 | ZLIB DATA COMPRESSION LIBRARY |
| 2 | |
| 3 | zlib 1.3.0 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 |
| 5 | (Request for Comments) 1950 to 1952 in the files |
| 6 | http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) |
| 7 | and rfc1952.txt (gzip format). |
| 8 | |
| @@ -20,11 +20,11 @@ | |
| 20 | before asking for help. |
| 21 | |
| 22 | |
| 23 | Manifest: |
| 24 | |
| 25 | The package zlib-1.3.0-win32-x86.zip will contain the following files: |
| 26 | |
| 27 | README-WIN32.txt This document |
| 28 | ChangeLog Changes since previous zlib packages |
| 29 | DLL_FAQ.txt Frequently asked questions about zlib1.dll |
| 30 | zlib.3.pdf Documentation of this library in Adobe Acrobat format |
| 31 |
+6
-2
| --- compat/zlib/zconf.h | ||
| +++ compat/zlib/zconf.h | ||
| @@ -239,11 +239,15 @@ | ||
| 239 | 239 | #else |
| 240 | 240 | # define z_const |
| 241 | 241 | #endif |
| 242 | 242 | |
| 243 | 243 | #ifdef Z_SOLO |
| 244 | - typedef unsigned long z_size_t; | |
| 244 | +# ifdef _WIN64 | |
| 245 | + typedef unsigned long long z_size_t; | |
| 246 | +# else | |
| 247 | + typedef unsigned long z_size_t; | |
| 248 | +# endif | |
| 245 | 249 | #else |
| 246 | 250 | # define z_longlong long long |
| 247 | 251 | # if defined(NO_SIZE_T) |
| 248 | 252 | typedef unsigned NO_SIZE_T z_size_t; |
| 249 | 253 | # elif defined(STDC) |
| @@ -518,11 +522,11 @@ | ||
| 518 | 522 | #endif |
| 519 | 523 | |
| 520 | 524 | #if !defined(_WIN32) && defined(Z_LARGE64) |
| 521 | 525 | # define z_off64_t off64_t |
| 522 | 526 | #else |
| 523 | -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) | |
| 527 | +# if defined(_WIN32) && !defined(__GNUC__) | |
| 524 | 528 | # define z_off64_t __int64 |
| 525 | 529 | # else |
| 526 | 530 | # define z_off64_t z_off_t |
| 527 | 531 | # endif |
| 528 | 532 | #endif |
| 529 | 533 |
| --- compat/zlib/zconf.h | |
| +++ compat/zlib/zconf.h | |
| @@ -239,11 +239,15 @@ | |
| 239 | #else |
| 240 | # define z_const |
| 241 | #endif |
| 242 | |
| 243 | #ifdef Z_SOLO |
| 244 | typedef unsigned long z_size_t; |
| 245 | #else |
| 246 | # define z_longlong long long |
| 247 | # if defined(NO_SIZE_T) |
| 248 | typedef unsigned NO_SIZE_T z_size_t; |
| 249 | # elif defined(STDC) |
| @@ -518,11 +522,11 @@ | |
| 518 | #endif |
| 519 | |
| 520 | #if !defined(_WIN32) && defined(Z_LARGE64) |
| 521 | # define z_off64_t off64_t |
| 522 | #else |
| 523 | # if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) |
| 524 | # define z_off64_t __int64 |
| 525 | # else |
| 526 | # define z_off64_t z_off_t |
| 527 | # endif |
| 528 | #endif |
| 529 |
| --- compat/zlib/zconf.h | |
| +++ compat/zlib/zconf.h | |
| @@ -239,11 +239,15 @@ | |
| 239 | #else |
| 240 | # define z_const |
| 241 | #endif |
| 242 | |
| 243 | #ifdef Z_SOLO |
| 244 | # ifdef _WIN64 |
| 245 | typedef unsigned long long z_size_t; |
| 246 | # else |
| 247 | typedef unsigned long z_size_t; |
| 248 | # endif |
| 249 | #else |
| 250 | # define z_longlong long long |
| 251 | # if defined(NO_SIZE_T) |
| 252 | typedef unsigned NO_SIZE_T z_size_t; |
| 253 | # elif defined(STDC) |
| @@ -518,11 +522,11 @@ | |
| 522 | #endif |
| 523 | |
| 524 | #if !defined(_WIN32) && defined(Z_LARGE64) |
| 525 | # define z_off64_t off64_t |
| 526 | #else |
| 527 | # if defined(_WIN32) && !defined(__GNUC__) |
| 528 | # define z_off64_t __int64 |
| 529 | # else |
| 530 | # define z_off64_t z_off_t |
| 531 | # endif |
| 532 | #endif |
| 533 |
+6
-2
| --- compat/zlib/zconf.h.cmakein | ||
| +++ compat/zlib/zconf.h.cmakein | ||
| @@ -241,11 +241,15 @@ | ||
| 241 | 241 | #else |
| 242 | 242 | # define z_const |
| 243 | 243 | #endif |
| 244 | 244 | |
| 245 | 245 | #ifdef Z_SOLO |
| 246 | - typedef unsigned long z_size_t; | |
| 246 | +# ifdef _WIN64 | |
| 247 | + typedef unsigned long long z_size_t; | |
| 248 | +# else | |
| 249 | + typedef unsigned long z_size_t; | |
| 250 | +# endif | |
| 247 | 251 | #else |
| 248 | 252 | # define z_longlong long long |
| 249 | 253 | # if defined(NO_SIZE_T) |
| 250 | 254 | typedef unsigned NO_SIZE_T z_size_t; |
| 251 | 255 | # elif defined(STDC) |
| @@ -520,11 +524,11 @@ | ||
| 520 | 524 | #endif |
| 521 | 525 | |
| 522 | 526 | #if !defined(_WIN32) && defined(Z_LARGE64) |
| 523 | 527 | # define z_off64_t off64_t |
| 524 | 528 | #else |
| 525 | -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) | |
| 529 | +# if defined(_WIN32) && !defined(__GNUC__) | |
| 526 | 530 | # define z_off64_t __int64 |
| 527 | 531 | # else |
| 528 | 532 | # define z_off64_t z_off_t |
| 529 | 533 | # endif |
| 530 | 534 | #endif |
| 531 | 535 |
| --- compat/zlib/zconf.h.cmakein | |
| +++ compat/zlib/zconf.h.cmakein | |
| @@ -241,11 +241,15 @@ | |
| 241 | #else |
| 242 | # define z_const |
| 243 | #endif |
| 244 | |
| 245 | #ifdef Z_SOLO |
| 246 | typedef unsigned long z_size_t; |
| 247 | #else |
| 248 | # define z_longlong long long |
| 249 | # if defined(NO_SIZE_T) |
| 250 | typedef unsigned NO_SIZE_T z_size_t; |
| 251 | # elif defined(STDC) |
| @@ -520,11 +524,11 @@ | |
| 520 | #endif |
| 521 | |
| 522 | #if !defined(_WIN32) && defined(Z_LARGE64) |
| 523 | # define z_off64_t off64_t |
| 524 | #else |
| 525 | # if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) |
| 526 | # define z_off64_t __int64 |
| 527 | # else |
| 528 | # define z_off64_t z_off_t |
| 529 | # endif |
| 530 | #endif |
| 531 |
| --- compat/zlib/zconf.h.cmakein | |
| +++ compat/zlib/zconf.h.cmakein | |
| @@ -241,11 +241,15 @@ | |
| 241 | #else |
| 242 | # define z_const |
| 243 | #endif |
| 244 | |
| 245 | #ifdef Z_SOLO |
| 246 | # ifdef _WIN64 |
| 247 | typedef unsigned long long z_size_t; |
| 248 | # else |
| 249 | typedef unsigned long z_size_t; |
| 250 | # endif |
| 251 | #else |
| 252 | # define z_longlong long long |
| 253 | # if defined(NO_SIZE_T) |
| 254 | typedef unsigned NO_SIZE_T z_size_t; |
| 255 | # elif defined(STDC) |
| @@ -520,11 +524,11 @@ | |
| 524 | #endif |
| 525 | |
| 526 | #if !defined(_WIN32) && defined(Z_LARGE64) |
| 527 | # define z_off64_t off64_t |
| 528 | #else |
| 529 | # if defined(_WIN32) && !defined(__GNUC__) |
| 530 | # define z_off64_t __int64 |
| 531 | # else |
| 532 | # define z_off64_t z_off_t |
| 533 | # endif |
| 534 | #endif |
| 535 |
+6
-2
| --- compat/zlib/zconf.h.in | ||
| +++ compat/zlib/zconf.h.in | ||
| @@ -239,11 +239,15 @@ | ||
| 239 | 239 | #else |
| 240 | 240 | # define z_const |
| 241 | 241 | #endif |
| 242 | 242 | |
| 243 | 243 | #ifdef Z_SOLO |
| 244 | - typedef unsigned long z_size_t; | |
| 244 | +# ifdef _WIN64 | |
| 245 | + typedef unsigned long long z_size_t; | |
| 246 | +# else | |
| 247 | + typedef unsigned long z_size_t; | |
| 248 | +# endif | |
| 245 | 249 | #else |
| 246 | 250 | # define z_longlong long long |
| 247 | 251 | # if defined(NO_SIZE_T) |
| 248 | 252 | typedef unsigned NO_SIZE_T z_size_t; |
| 249 | 253 | # elif defined(STDC) |
| @@ -518,11 +522,11 @@ | ||
| 518 | 522 | #endif |
| 519 | 523 | |
| 520 | 524 | #if !defined(_WIN32) && defined(Z_LARGE64) |
| 521 | 525 | # define z_off64_t off64_t |
| 522 | 526 | #else |
| 523 | -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) | |
| 527 | +# if defined(_WIN32) && !defined(__GNUC__) | |
| 524 | 528 | # define z_off64_t __int64 |
| 525 | 529 | # else |
| 526 | 530 | # define z_off64_t z_off_t |
| 527 | 531 | # endif |
| 528 | 532 | #endif |
| 529 | 533 |
| --- compat/zlib/zconf.h.in | |
| +++ compat/zlib/zconf.h.in | |
| @@ -239,11 +239,15 @@ | |
| 239 | #else |
| 240 | # define z_const |
| 241 | #endif |
| 242 | |
| 243 | #ifdef Z_SOLO |
| 244 | typedef unsigned long z_size_t; |
| 245 | #else |
| 246 | # define z_longlong long long |
| 247 | # if defined(NO_SIZE_T) |
| 248 | typedef unsigned NO_SIZE_T z_size_t; |
| 249 | # elif defined(STDC) |
| @@ -518,11 +522,11 @@ | |
| 518 | #endif |
| 519 | |
| 520 | #if !defined(_WIN32) && defined(Z_LARGE64) |
| 521 | # define z_off64_t off64_t |
| 522 | #else |
| 523 | # if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) |
| 524 | # define z_off64_t __int64 |
| 525 | # else |
| 526 | # define z_off64_t z_off_t |
| 527 | # endif |
| 528 | #endif |
| 529 |
| --- compat/zlib/zconf.h.in | |
| +++ compat/zlib/zconf.h.in | |
| @@ -239,11 +239,15 @@ | |
| 239 | #else |
| 240 | # define z_const |
| 241 | #endif |
| 242 | |
| 243 | #ifdef Z_SOLO |
| 244 | # ifdef _WIN64 |
| 245 | typedef unsigned long long z_size_t; |
| 246 | # else |
| 247 | typedef unsigned long z_size_t; |
| 248 | # endif |
| 249 | #else |
| 250 | # define z_longlong long long |
| 251 | # if defined(NO_SIZE_T) |
| 252 | typedef unsigned NO_SIZE_T z_size_t; |
| 253 | # elif defined(STDC) |
| @@ -518,11 +522,11 @@ | |
| 522 | #endif |
| 523 | |
| 524 | #if !defined(_WIN32) && defined(Z_LARGE64) |
| 525 | # define z_off64_t off64_t |
| 526 | #else |
| 527 | # if defined(_WIN32) && !defined(__GNUC__) |
| 528 | # define z_off64_t __int64 |
| 529 | # else |
| 530 | # define z_off64_t z_off_t |
| 531 | # endif |
| 532 | #endif |
| 533 |
+3
-3
| --- compat/zlib/zlib.3 | ||
| +++ compat/zlib/zlib.3 | ||
| @@ -1,6 +1,6 @@ | ||
| 1 | -.TH ZLIB 3 "13 Oct 2022" | |
| 1 | +.TH ZLIB 3 "18 Aug 2023" | |
| 2 | 2 | .SH NAME |
| 3 | 3 | zlib \- compression/decompression library |
| 4 | 4 | .SH SYNOPSIS |
| 5 | 5 | [see |
| 6 | 6 | .I zlib.h |
| @@ -103,13 +103,13 @@ | ||
| 103 | 103 | .LP |
| 104 | 104 | before asking for help. |
| 105 | 105 | Send questions and/or comments to [email protected], |
| 106 | 106 | or (for the Windows DLL version) to Gilles Vollant ([email protected]). |
| 107 | 107 | .SH AUTHORS AND LICENSE |
| 108 | -Version 1.2.13 | |
| 108 | +Version 1.3 | |
| 109 | 109 | .LP |
| 110 | -Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler | |
| 110 | +Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler | |
| 111 | 111 | .LP |
| 112 | 112 | This software is provided 'as-is', without any express or implied |
| 113 | 113 | warranty. In no event will the authors be held liable for any damages |
| 114 | 114 | arising from the use of this software. |
| 115 | 115 | .LP |
| 116 | 116 |
| --- compat/zlib/zlib.3 | |
| +++ compat/zlib/zlib.3 | |
| @@ -1,6 +1,6 @@ | |
| 1 | .TH ZLIB 3 "13 Oct 2022" |
| 2 | .SH NAME |
| 3 | zlib \- compression/decompression library |
| 4 | .SH SYNOPSIS |
| 5 | [see |
| 6 | .I zlib.h |
| @@ -103,13 +103,13 @@ | |
| 103 | .LP |
| 104 | before asking for help. |
| 105 | Send questions and/or comments to [email protected], |
| 106 | or (for the Windows DLL version) to Gilles Vollant ([email protected]). |
| 107 | .SH AUTHORS AND LICENSE |
| 108 | Version 1.2.13 |
| 109 | .LP |
| 110 | Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler |
| 111 | .LP |
| 112 | This software is provided 'as-is', without any express or implied |
| 113 | warranty. In no event will the authors be held liable for any damages |
| 114 | arising from the use of this software. |
| 115 | .LP |
| 116 |
| --- compat/zlib/zlib.3 | |
| +++ compat/zlib/zlib.3 | |
| @@ -1,6 +1,6 @@ | |
| 1 | .TH ZLIB 3 "18 Aug 2023" |
| 2 | .SH NAME |
| 3 | zlib \- compression/decompression library |
| 4 | .SH SYNOPSIS |
| 5 | [see |
| 6 | .I zlib.h |
| @@ -103,13 +103,13 @@ | |
| 103 | .LP |
| 104 | before asking for help. |
| 105 | Send questions and/or comments to [email protected], |
| 106 | or (for the Windows DLL version) to Gilles Vollant ([email protected]). |
| 107 | .SH AUTHORS AND LICENSE |
| 108 | Version 1.3 |
| 109 | .LP |
| 110 | Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler |
| 111 | .LP |
| 112 | This software is provided 'as-is', without any express or implied |
| 113 | warranty. In no event will the authors be held liable for any damages |
| 114 | arising from the use of this software. |
| 115 | .LP |
| 116 |
| --- compat/zlib/zlib.3.pdf | ||
| +++ compat/zlib/zlib.3.pdf | ||
| cannot compute difference between binary files | ||
| 1 | 1 |
| --- compat/zlib/zlib.3.pdf | |
| +++ compat/zlib/zlib.3.pdf | |
| 0 | annot compute difference between binary files |
| 1 |
| --- compat/zlib/zlib.3.pdf | |
| +++ compat/zlib/zlib.3.pdf | |
| 0 | annot compute difference between binary files |
| 1 |
+191
-188
| --- compat/zlib/zlib.h | ||
| +++ compat/zlib/zlib.h | ||
| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | /* zlib.h -- interface of the 'zlib' general purpose compression library |
| 2 | - version 1.2.13, October 13th, 2022 | |
| 2 | + version 1.3, August 18th, 2023 | |
| 3 | 3 | |
| 4 | - Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler | |
| 4 | + Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler | |
| 5 | 5 | |
| 6 | 6 | This software is provided 'as-is', without any express or implied |
| 7 | 7 | warranty. In no event will the authors be held liable for any damages |
| 8 | 8 | arising from the use of this software. |
| 9 | 9 | |
| @@ -35,15 +35,15 @@ | ||
| 35 | 35 | |
| 36 | 36 | #ifdef __cplusplus |
| 37 | 37 | extern "C" { |
| 38 | 38 | #endif |
| 39 | 39 | |
| 40 | -#define ZLIB_VERSION "1.2.13" | |
| 41 | -#define ZLIB_VERNUM 0x12d0 | |
| 40 | +#define ZLIB_VERSION "1.3" | |
| 41 | +#define ZLIB_VERNUM 0x1300 | |
| 42 | 42 | #define ZLIB_VER_MAJOR 1 |
| 43 | -#define ZLIB_VER_MINOR 2 | |
| 44 | -#define ZLIB_VER_REVISION 13 | |
| 43 | +#define ZLIB_VER_MINOR 3 | |
| 44 | +#define ZLIB_VER_REVISION 0 | |
| 45 | 45 | #define ZLIB_VER_SUBREVISION 0 |
| 46 | 46 | |
| 47 | 47 | /* |
| 48 | 48 | The 'zlib' compression library provides in-memory compression and |
| 49 | 49 | decompression functions, including integrity checks of the uncompressed data. |
| @@ -76,12 +76,12 @@ | ||
| 76 | 76 | The library does not install any signal handler. The decoder checks |
| 77 | 77 | the consistency of the compressed data, so the library should never crash |
| 78 | 78 | even in the case of corrupted input. |
| 79 | 79 | */ |
| 80 | 80 | |
| 81 | -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); | |
| 82 | -typedef void (*free_func) OF((voidpf opaque, voidpf address)); | |
| 81 | +typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size); | |
| 82 | +typedef void (*free_func)(voidpf opaque, voidpf address); | |
| 83 | 83 | |
| 84 | 84 | struct internal_state; |
| 85 | 85 | |
| 86 | 86 | typedef struct z_stream_s { |
| 87 | 87 | z_const Bytef *next_in; /* next input byte */ |
| @@ -215,24 +215,24 @@ | ||
| 215 | 215 | /* for compatibility with versions < 1.0.2 */ |
| 216 | 216 | |
| 217 | 217 | |
| 218 | 218 | /* basic functions */ |
| 219 | 219 | |
| 220 | -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); | |
| 220 | +ZEXTERN const char * ZEXPORT zlibVersion(void); | |
| 221 | 221 | /* The application can compare zlibVersion and ZLIB_VERSION for consistency. |
| 222 | 222 | If the first character differs, the library code actually used is not |
| 223 | 223 | compatible with the zlib.h header file used by the application. This check |
| 224 | 224 | is automatically made by deflateInit and inflateInit. |
| 225 | 225 | */ |
| 226 | 226 | |
| 227 | 227 | /* |
| 228 | -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); | |
| 228 | +ZEXTERN int ZEXPORT deflateInit(z_streamp strm, int level); | |
| 229 | 229 | |
| 230 | 230 | Initializes the internal stream state for compression. The fields |
| 231 | 231 | zalloc, zfree and opaque must be initialized before by the caller. If |
| 232 | 232 | zalloc and zfree are set to Z_NULL, deflateInit updates them to use default |
| 233 | - allocation functions. | |
| 233 | + allocation functions. total_in, total_out, adler, and msg are initialized. | |
| 234 | 234 | |
| 235 | 235 | The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: |
| 236 | 236 | 1 gives best speed, 9 gives best compression, 0 gives no compression at all |
| 237 | 237 | (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION |
| 238 | 238 | requests a default compromise between speed and compression (currently |
| @@ -245,11 +245,11 @@ | ||
| 245 | 245 | if there is no error message. deflateInit does not perform any compression: |
| 246 | 246 | this will be done by deflate(). |
| 247 | 247 | */ |
| 248 | 248 | |
| 249 | 249 | |
| 250 | -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); | |
| 250 | +ZEXTERN int ZEXPORT deflate(z_streamp strm, int flush); | |
| 251 | 251 | /* |
| 252 | 252 | deflate compresses as much data as possible, and stops when the input |
| 253 | 253 | buffer becomes empty or the output buffer becomes full. It may introduce |
| 254 | 254 | some output latency (reading input without producing any output) except when |
| 255 | 255 | forced to flush. |
| @@ -318,12 +318,12 @@ | ||
| 318 | 318 | |
| 319 | 319 | If deflate returns with avail_out == 0, this function must be called again |
| 320 | 320 | with the same value of the flush parameter and more output space (updated |
| 321 | 321 | avail_out), until the flush is complete (deflate returns with non-zero |
| 322 | 322 | avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that |
| 323 | - avail_out is greater than six to avoid repeated flush markers due to | |
| 324 | - avail_out == 0 on return. | |
| 323 | + avail_out is greater than six when the flush marker begins, in order to avoid | |
| 324 | + repeated flush markers upon calling deflate() again when avail_out == 0. | |
| 325 | 325 | |
| 326 | 326 | If the parameter flush is set to Z_FINISH, pending input is processed, |
| 327 | 327 | pending output is flushed and deflate returns with Z_STREAM_END if there was |
| 328 | 328 | enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this |
| 329 | 329 | function must be called again with Z_FINISH and more output space (updated |
| @@ -358,11 +358,11 @@ | ||
| 358 | 358 | deflate() can be called again with more input and more output space to |
| 359 | 359 | continue compressing. |
| 360 | 360 | */ |
| 361 | 361 | |
| 362 | 362 | |
| 363 | -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); | |
| 363 | +ZEXTERN int ZEXPORT deflateEnd(z_streamp strm); | |
| 364 | 364 | /* |
| 365 | 365 | All dynamically allocated data structures for this stream are freed. |
| 366 | 366 | This function discards any unprocessed input and does not flush any pending |
| 367 | 367 | output. |
| 368 | 368 | |
| @@ -373,19 +373,20 @@ | ||
| 373 | 373 | deallocated). |
| 374 | 374 | */ |
| 375 | 375 | |
| 376 | 376 | |
| 377 | 377 | /* |
| 378 | -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); | |
| 378 | +ZEXTERN int ZEXPORT inflateInit(z_streamp strm); | |
| 379 | 379 | |
| 380 | 380 | Initializes the internal stream state for decompression. The fields |
| 381 | 381 | next_in, avail_in, zalloc, zfree and opaque must be initialized before by |
| 382 | 382 | the caller. In the current version of inflate, the provided input is not |
| 383 | 383 | read or consumed. The allocation of a sliding window will be deferred to |
| 384 | 384 | the first call of inflate (if the decompression does not complete on the |
| 385 | 385 | first call). If zalloc and zfree are set to Z_NULL, inflateInit updates |
| 386 | - them to use default allocation functions. | |
| 386 | + them to use default allocation functions. total_in, total_out, adler, and | |
| 387 | + msg are initialized. | |
| 387 | 388 | |
| 388 | 389 | inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 389 | 390 | memory, Z_VERSION_ERROR if the zlib library version is incompatible with the |
| 390 | 391 | version assumed by the caller, or Z_STREAM_ERROR if the parameters are |
| 391 | 392 | invalid, such as a null pointer to the structure. msg is set to null if |
| @@ -395,11 +396,11 @@ | ||
| 395 | 396 | implementation of inflateInit() does not process any header information -- |
| 396 | 397 | that is deferred until inflate() is called. |
| 397 | 398 | */ |
| 398 | 399 | |
| 399 | 400 | |
| 400 | -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); | |
| 401 | +ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush); | |
| 401 | 402 | /* |
| 402 | 403 | inflate decompresses as much data as possible, and stops when the input |
| 403 | 404 | buffer becomes empty or the output buffer becomes full. It may introduce |
| 404 | 405 | some output latency (reading input without producing any output) except when |
| 405 | 406 | forced to flush. |
| @@ -515,11 +516,11 @@ | ||
| 515 | 516 | then call inflateSync() to look for a good compression block if a partial |
| 516 | 517 | recovery of the data is to be attempted. |
| 517 | 518 | */ |
| 518 | 519 | |
| 519 | 520 | |
| 520 | -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); | |
| 521 | +ZEXTERN int ZEXPORT inflateEnd(z_streamp strm); | |
| 521 | 522 | /* |
| 522 | 523 | All dynamically allocated data structures for this stream are freed. |
| 523 | 524 | This function discards any unprocessed input and does not flush any pending |
| 524 | 525 | output. |
| 525 | 526 | |
| @@ -533,16 +534,16 @@ | ||
| 533 | 534 | /* |
| 534 | 535 | The following functions are needed only in some special applications. |
| 535 | 536 | */ |
| 536 | 537 | |
| 537 | 538 | /* |
| 538 | -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, | |
| 539 | - int level, | |
| 540 | - int method, | |
| 541 | - int windowBits, | |
| 542 | - int memLevel, | |
| 543 | - int strategy)); | |
| 539 | +ZEXTERN int ZEXPORT deflateInit2(z_streamp strm, | |
| 540 | + int level, | |
| 541 | + int method, | |
| 542 | + int windowBits, | |
| 543 | + int memLevel, | |
| 544 | + int strategy); | |
| 544 | 545 | |
| 545 | 546 | This is another version of deflateInit with more compression options. The |
| 546 | 547 | fields zalloc, zfree and opaque must be initialized before by the caller. |
| 547 | 548 | |
| 548 | 549 | The method parameter is the compression method. It must be Z_DEFLATED in |
| @@ -605,13 +606,13 @@ | ||
| 605 | 606 | incompatible with the version assumed by the caller (ZLIB_VERSION). msg is |
| 606 | 607 | set to null if there is no error message. deflateInit2 does not perform any |
| 607 | 608 | compression: this will be done by deflate(). |
| 608 | 609 | */ |
| 609 | 610 | |
| 610 | -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, | |
| 611 | - const Bytef *dictionary, | |
| 612 | - uInt dictLength)); | |
| 611 | +ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm, | |
| 612 | + const Bytef *dictionary, | |
| 613 | + uInt dictLength); | |
| 613 | 614 | /* |
| 614 | 615 | Initializes the compression dictionary from the given byte sequence |
| 615 | 616 | without producing any compressed output. When using the zlib format, this |
| 616 | 617 | function must be called immediately after deflateInit, deflateInit2 or |
| 617 | 618 | deflateReset, and before any call of deflate. When doing raw deflate, this |
| @@ -649,13 +650,13 @@ | ||
| 649 | 650 | inconsistent (for example if deflate has already been called for this stream |
| 650 | 651 | or if not at a block boundary for raw deflate). deflateSetDictionary does |
| 651 | 652 | not perform any compression: this will be done by deflate(). |
| 652 | 653 | */ |
| 653 | 654 | |
| 654 | -ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, | |
| 655 | - Bytef *dictionary, | |
| 656 | - uInt *dictLength)); | |
| 655 | +ZEXTERN int ZEXPORT deflateGetDictionary(z_streamp strm, | |
| 656 | + Bytef *dictionary, | |
| 657 | + uInt *dictLength); | |
| 657 | 658 | /* |
| 658 | 659 | Returns the sliding dictionary being maintained by deflate. dictLength is |
| 659 | 660 | set to the number of bytes in the dictionary, and that many bytes are copied |
| 660 | 661 | to dictionary. dictionary must have enough space, where 32768 bytes is |
| 661 | 662 | always enough. If deflateGetDictionary() is called with dictionary equal to |
| @@ -671,12 +672,12 @@ | ||
| 671 | 672 | |
| 672 | 673 | deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the |
| 673 | 674 | stream state is inconsistent. |
| 674 | 675 | */ |
| 675 | 676 | |
| 676 | -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, | |
| 677 | - z_streamp source)); | |
| 677 | +ZEXTERN int ZEXPORT deflateCopy(z_streamp dest, | |
| 678 | + z_streamp source); | |
| 678 | 679 | /* |
| 679 | 680 | Sets the destination stream as a complete copy of the source stream. |
| 680 | 681 | |
| 681 | 682 | This function can be useful when several compression strategies will be |
| 682 | 683 | tried, for example when there are several ways of pre-processing the input |
| @@ -689,24 +690,24 @@ | ||
| 689 | 690 | enough memory, Z_STREAM_ERROR if the source stream state was inconsistent |
| 690 | 691 | (such as zalloc being Z_NULL). msg is left unchanged in both source and |
| 691 | 692 | destination. |
| 692 | 693 | */ |
| 693 | 694 | |
| 694 | -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); | |
| 695 | +ZEXTERN int ZEXPORT deflateReset(z_streamp strm); | |
| 695 | 696 | /* |
| 696 | 697 | This function is equivalent to deflateEnd followed by deflateInit, but |
| 697 | 698 | does not free and reallocate the internal compression state. The stream |
| 698 | 699 | will leave the compression level and any other attributes that may have been |
| 699 | - set unchanged. | |
| 700 | + set unchanged. total_in, total_out, adler, and msg are initialized. | |
| 700 | 701 | |
| 701 | 702 | deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 702 | 703 | stream state was inconsistent (such as zalloc or state being Z_NULL). |
| 703 | 704 | */ |
| 704 | 705 | |
| 705 | -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, | |
| 706 | - int level, | |
| 707 | - int strategy)); | |
| 706 | +ZEXTERN int ZEXPORT deflateParams(z_streamp strm, | |
| 707 | + int level, | |
| 708 | + int strategy); | |
| 708 | 709 | /* |
| 709 | 710 | Dynamically update the compression level and compression strategy. The |
| 710 | 711 | interpretation of level and strategy is as in deflateInit2(). This can be |
| 711 | 712 | used to switch between compression and straight copy of the input data, or |
| 712 | 713 | to switch to a different kind of input data requiring a different strategy. |
| @@ -727,11 +728,11 @@ | ||
| 727 | 728 | deflate stream should be flushed using deflate() with Z_BLOCK or other flush |
| 728 | 729 | request until strm.avail_out is not zero, before calling deflateParams(). |
| 729 | 730 | Then no more input data should be provided before the deflateParams() call. |
| 730 | 731 | If this is done, the old level and strategy will be applied to the data |
| 731 | 732 | compressed before deflateParams(), and the new level and strategy will be |
| 732 | - applied to the the data compressed after deflateParams(). | |
| 733 | + applied to the data compressed after deflateParams(). | |
| 733 | 734 | |
| 734 | 735 | deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream |
| 735 | 736 | state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if |
| 736 | 737 | there was not enough output space to complete the compression of the |
| 737 | 738 | available input data before a change in the strategy or approach. Note that |
| @@ -738,15 +739,15 @@ | ||
| 738 | 739 | in the case of a Z_BUF_ERROR, the parameters are not changed. A return |
| 739 | 740 | value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be |
| 740 | 741 | retried with more output space. |
| 741 | 742 | */ |
| 742 | 743 | |
| 743 | -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, | |
| 744 | - int good_length, | |
| 745 | - int max_lazy, | |
| 746 | - int nice_length, | |
| 747 | - int max_chain)); | |
| 744 | +ZEXTERN int ZEXPORT deflateTune(z_streamp strm, | |
| 745 | + int good_length, | |
| 746 | + int max_lazy, | |
| 747 | + int nice_length, | |
| 748 | + int max_chain); | |
| 748 | 749 | /* |
| 749 | 750 | Fine tune deflate's internal compression parameters. This should only be |
| 750 | 751 | used by someone who understands the algorithm used by zlib's deflate for |
| 751 | 752 | searching for the best matching string, and even then only by the most |
| 752 | 753 | fanatic optimizer trying to squeeze out the last compressed bit for their |
| @@ -755,12 +756,12 @@ | ||
| 755 | 756 | |
| 756 | 757 | deflateTune() can be called after deflateInit() or deflateInit2(), and |
| 757 | 758 | returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. |
| 758 | 759 | */ |
| 759 | 760 | |
| 760 | -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, | |
| 761 | - uLong sourceLen)); | |
| 761 | +ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, | |
| 762 | + uLong sourceLen); | |
| 762 | 763 | /* |
| 763 | 764 | deflateBound() returns an upper bound on the compressed size after |
| 764 | 765 | deflation of sourceLen bytes. It must be called after deflateInit() or |
| 765 | 766 | deflateInit2(), and after deflateSetHeader(), if used. This would be used |
| 766 | 767 | to allocate an output buffer for deflation in a single pass, and so would be |
| @@ -770,13 +771,13 @@ | ||
| 770 | 771 | to return Z_STREAM_END. Note that it is possible for the compressed size to |
| 771 | 772 | be larger than the value returned by deflateBound() if flush options other |
| 772 | 773 | than Z_FINISH or Z_NO_FLUSH are used. |
| 773 | 774 | */ |
| 774 | 775 | |
| 775 | -ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, | |
| 776 | - unsigned *pending, | |
| 777 | - int *bits)); | |
| 776 | +ZEXTERN int ZEXPORT deflatePending(z_streamp strm, | |
| 777 | + unsigned *pending, | |
| 778 | + int *bits); | |
| 778 | 779 | /* |
| 779 | 780 | deflatePending() returns the number of bytes and bits of output that have |
| 780 | 781 | been generated, but not yet provided in the available output. The bytes not |
| 781 | 782 | provided would be due to the available output space having being consumed. |
| 782 | 783 | The number of bits of output not provided are between 0 and 7, where they |
| @@ -785,13 +786,13 @@ | ||
| 785 | 786 | |
| 786 | 787 | deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 787 | 788 | stream state was inconsistent. |
| 788 | 789 | */ |
| 789 | 790 | |
| 790 | -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, | |
| 791 | - int bits, | |
| 792 | - int value)); | |
| 791 | +ZEXTERN int ZEXPORT deflatePrime(z_streamp strm, | |
| 792 | + int bits, | |
| 793 | + int value); | |
| 793 | 794 | /* |
| 794 | 795 | deflatePrime() inserts bits in the deflate output stream. The intent |
| 795 | 796 | is that this function is used to start off the deflate output with the bits |
| 796 | 797 | leftover from a previous deflate stream when appending to it. As such, this |
| 797 | 798 | function can only be used for raw deflate, and must be used before the first |
| @@ -802,12 +803,12 @@ | ||
| 802 | 803 | deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough |
| 803 | 804 | room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the |
| 804 | 805 | source stream state was inconsistent. |
| 805 | 806 | */ |
| 806 | 807 | |
| 807 | -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, | |
| 808 | - gz_headerp head)); | |
| 808 | +ZEXTERN int ZEXPORT deflateSetHeader(z_streamp strm, | |
| 809 | + gz_headerp head); | |
| 809 | 810 | /* |
| 810 | 811 | deflateSetHeader() provides gzip header information for when a gzip |
| 811 | 812 | stream is requested by deflateInit2(). deflateSetHeader() may be called |
| 812 | 813 | after deflateInit2() or deflateReset() and before the first call of |
| 813 | 814 | deflate(). The text, time, os, extra field, name, and comment information |
| @@ -819,20 +820,21 @@ | ||
| 819 | 820 | the current versions of the command-line version of gzip (up through version |
| 820 | 821 | 1.3.x) do not support header crc's, and will report that it is a "multi-part |
| 821 | 822 | gzip file" and give up. |
| 822 | 823 | |
| 823 | 824 | If deflateSetHeader is not used, the default gzip header has text false, |
| 824 | - the time set to zero, and os set to 255, with no extra, name, or comment | |
| 825 | - fields. The gzip header is returned to the default state by deflateReset(). | |
| 825 | + the time set to zero, and os set to the current operating system, with no | |
| 826 | + extra, name, or comment fields. The gzip header is returned to the default | |
| 827 | + state by deflateReset(). | |
| 826 | 828 | |
| 827 | 829 | deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 828 | 830 | stream state was inconsistent. |
| 829 | 831 | */ |
| 830 | 832 | |
| 831 | 833 | /* |
| 832 | -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, | |
| 833 | - int windowBits)); | |
| 834 | +ZEXTERN int ZEXPORT inflateInit2(z_streamp strm, | |
| 835 | + int windowBits); | |
| 834 | 836 | |
| 835 | 837 | This is another version of inflateInit with an extra parameter. The |
| 836 | 838 | fields next_in, avail_in, zalloc, zfree and opaque must be initialized |
| 837 | 839 | before by the caller. |
| 838 | 840 | |
| @@ -881,13 +883,13 @@ | ||
| 881 | 883 | next_out and avail_out are unused and unchanged.) The current implementation |
| 882 | 884 | of inflateInit2() does not process any header information -- that is |
| 883 | 885 | deferred until inflate() is called. |
| 884 | 886 | */ |
| 885 | 887 | |
| 886 | -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, | |
| 887 | - const Bytef *dictionary, | |
| 888 | - uInt dictLength)); | |
| 888 | +ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm, | |
| 889 | + const Bytef *dictionary, | |
| 890 | + uInt dictLength); | |
| 889 | 891 | /* |
| 890 | 892 | Initializes the decompression dictionary from the given uncompressed byte |
| 891 | 893 | sequence. This function must be called immediately after a call of inflate, |
| 892 | 894 | if that call returned Z_NEED_DICT. The dictionary chosen by the compressor |
| 893 | 895 | can be determined from the Adler-32 value returned by that call of inflate. |
| @@ -904,13 +906,13 @@ | ||
| 904 | 906 | expected one (incorrect Adler-32 value). inflateSetDictionary does not |
| 905 | 907 | perform any decompression: this will be done by subsequent calls of |
| 906 | 908 | inflate(). |
| 907 | 909 | */ |
| 908 | 910 | |
| 909 | -ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, | |
| 910 | - Bytef *dictionary, | |
| 911 | - uInt *dictLength)); | |
| 911 | +ZEXTERN int ZEXPORT inflateGetDictionary(z_streamp strm, | |
| 912 | + Bytef *dictionary, | |
| 913 | + uInt *dictLength); | |
| 912 | 914 | /* |
| 913 | 915 | Returns the sliding dictionary being maintained by inflate. dictLength is |
| 914 | 916 | set to the number of bytes in the dictionary, and that many bytes are copied |
| 915 | 917 | to dictionary. dictionary must have enough space, where 32768 bytes is |
| 916 | 918 | always enough. If inflateGetDictionary() is called with dictionary equal to |
| @@ -919,11 +921,11 @@ | ||
| 919 | 921 | |
| 920 | 922 | inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the |
| 921 | 923 | stream state is inconsistent. |
| 922 | 924 | */ |
| 923 | 925 | |
| 924 | -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); | |
| 926 | +ZEXTERN int ZEXPORT inflateSync(z_streamp strm); | |
| 925 | 927 | /* |
| 926 | 928 | Skips invalid compressed data until a possible full flush point (see above |
| 927 | 929 | for the description of deflate with Z_FULL_FLUSH) can be found, or until all |
| 928 | 930 | available input is skipped. No output is provided. |
| 929 | 931 | |
| @@ -938,12 +940,12 @@ | ||
| 938 | 940 | total_in which indicates where valid compressed data was found. In the |
| 939 | 941 | error case, the application may repeatedly call inflateSync, providing more |
| 940 | 942 | input each time, until success or end of the input data. |
| 941 | 943 | */ |
| 942 | 944 | |
| 943 | -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, | |
| 944 | - z_streamp source)); | |
| 945 | +ZEXTERN int ZEXPORT inflateCopy(z_streamp dest, | |
| 946 | + z_streamp source); | |
| 945 | 947 | /* |
| 946 | 948 | Sets the destination stream as a complete copy of the source stream. |
| 947 | 949 | |
| 948 | 950 | This function can be useful when randomly accessing a large stream. The |
| 949 | 951 | first pass through the stream can periodically record the inflate state, |
| @@ -954,22 +956,23 @@ | ||
| 954 | 956 | enough memory, Z_STREAM_ERROR if the source stream state was inconsistent |
| 955 | 957 | (such as zalloc being Z_NULL). msg is left unchanged in both source and |
| 956 | 958 | destination. |
| 957 | 959 | */ |
| 958 | 960 | |
| 959 | -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); | |
| 961 | +ZEXTERN int ZEXPORT inflateReset(z_streamp strm); | |
| 960 | 962 | /* |
| 961 | 963 | This function is equivalent to inflateEnd followed by inflateInit, |
| 962 | 964 | but does not free and reallocate the internal decompression state. The |
| 963 | 965 | stream will keep attributes that may have been set by inflateInit2. |
| 966 | + total_in, total_out, adler, and msg are initialized. | |
| 964 | 967 | |
| 965 | 968 | inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 966 | 969 | stream state was inconsistent (such as zalloc or state being Z_NULL). |
| 967 | 970 | */ |
| 968 | 971 | |
| 969 | -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, | |
| 970 | - int windowBits)); | |
| 972 | +ZEXTERN int ZEXPORT inflateReset2(z_streamp strm, | |
| 973 | + int windowBits); | |
| 971 | 974 | /* |
| 972 | 975 | This function is the same as inflateReset, but it also permits changing |
| 973 | 976 | the wrap and window size requests. The windowBits parameter is interpreted |
| 974 | 977 | the same as it is for inflateInit2. If the window size is changed, then the |
| 975 | 978 | memory allocated for the window is freed, and the window will be reallocated |
| @@ -978,13 +981,13 @@ | ||
| 978 | 981 | inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 979 | 982 | stream state was inconsistent (such as zalloc or state being Z_NULL), or if |
| 980 | 983 | the windowBits parameter is invalid. |
| 981 | 984 | */ |
| 982 | 985 | |
| 983 | -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, | |
| 984 | - int bits, | |
| 985 | - int value)); | |
| 986 | +ZEXTERN int ZEXPORT inflatePrime(z_streamp strm, | |
| 987 | + int bits, | |
| 988 | + int value); | |
| 986 | 989 | /* |
| 987 | 990 | This function inserts bits in the inflate input stream. The intent is |
| 988 | 991 | that this function is used to start inflating at a bit position in the |
| 989 | 992 | middle of a byte. The provided bits will be used before any bytes are used |
| 990 | 993 | from next_in. This function should only be used with raw inflate, and |
| @@ -999,11 +1002,11 @@ | ||
| 999 | 1002 | |
| 1000 | 1003 | inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 1001 | 1004 | stream state was inconsistent. |
| 1002 | 1005 | */ |
| 1003 | 1006 | |
| 1004 | -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); | |
| 1007 | +ZEXTERN long ZEXPORT inflateMark(z_streamp strm); | |
| 1005 | 1008 | /* |
| 1006 | 1009 | This function returns two values, one in the lower 16 bits of the return |
| 1007 | 1010 | value, and the other in the remaining upper bits, obtained by shifting the |
| 1008 | 1011 | return value down 16 bits. If the upper value is -1 and the lower value is |
| 1009 | 1012 | zero, then inflate() is currently decoding information outside of a block. |
| @@ -1027,12 +1030,12 @@ | ||
| 1027 | 1030 | |
| 1028 | 1031 | inflateMark returns the value noted above, or -65536 if the provided |
| 1029 | 1032 | source stream state was inconsistent. |
| 1030 | 1033 | */ |
| 1031 | 1034 | |
| 1032 | -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, | |
| 1033 | - gz_headerp head)); | |
| 1035 | +ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm, | |
| 1036 | + gz_headerp head); | |
| 1034 | 1037 | /* |
| 1035 | 1038 | inflateGetHeader() requests that gzip header information be stored in the |
| 1036 | 1039 | provided gz_header structure. inflateGetHeader() may be called after |
| 1037 | 1040 | inflateInit2() or inflateReset(), and before the first call of inflate(). |
| 1038 | 1041 | As inflate() processes the gzip stream, head->done is zero until the header |
| @@ -1068,12 +1071,12 @@ | ||
| 1068 | 1071 | inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 1069 | 1072 | stream state was inconsistent. |
| 1070 | 1073 | */ |
| 1071 | 1074 | |
| 1072 | 1075 | /* |
| 1073 | -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, | |
| 1074 | - unsigned char FAR *window)); | |
| 1076 | +ZEXTERN int ZEXPORT inflateBackInit(z_streamp strm, int windowBits, | |
| 1077 | + unsigned char FAR *window); | |
| 1075 | 1078 | |
| 1076 | 1079 | Initialize the internal stream state for decompression using inflateBack() |
| 1077 | 1080 | calls. The fields zalloc, zfree and opaque in strm must be initialized |
| 1078 | 1081 | before the call. If zalloc and zfree are Z_NULL, then the default library- |
| 1079 | 1082 | derived memory allocation routines are used. windowBits is the base two |
| @@ -1089,17 +1092,17 @@ | ||
| 1089 | 1092 | the parameters are invalid, Z_MEM_ERROR if the internal state could not be |
| 1090 | 1093 | allocated, or Z_VERSION_ERROR if the version of the library does not match |
| 1091 | 1094 | the version of the header file. |
| 1092 | 1095 | */ |
| 1093 | 1096 | |
| 1094 | -typedef unsigned (*in_func) OF((void FAR *, | |
| 1095 | - z_const unsigned char FAR * FAR *)); | |
| 1096 | -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); | |
| 1097 | +typedef unsigned (*in_func)(void FAR *, | |
| 1098 | + z_const unsigned char FAR * FAR *); | |
| 1099 | +typedef int (*out_func)(void FAR *, unsigned char FAR *, unsigned); | |
| 1097 | 1100 | |
| 1098 | -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, | |
| 1099 | - in_func in, void FAR *in_desc, | |
| 1100 | - out_func out, void FAR *out_desc)); | |
| 1101 | +ZEXTERN int ZEXPORT inflateBack(z_streamp strm, | |
| 1102 | + in_func in, void FAR *in_desc, | |
| 1103 | + out_func out, void FAR *out_desc); | |
| 1101 | 1104 | /* |
| 1102 | 1105 | inflateBack() does a raw inflate with a single call using a call-back |
| 1103 | 1106 | interface for input and output. This is potentially more efficient than |
| 1104 | 1107 | inflate() for file i/o applications, in that it avoids copying between the |
| 1105 | 1108 | output and the sliding window by simply making the window itself the output |
| @@ -1163,19 +1166,19 @@ | ||
| 1163 | 1166 | non-zero. (in() will always be called before out(), so strm->next_in is |
| 1164 | 1167 | assured to be defined if out() returns non-zero.) Note that inflateBack() |
| 1165 | 1168 | cannot return Z_OK. |
| 1166 | 1169 | */ |
| 1167 | 1170 | |
| 1168 | -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); | |
| 1171 | +ZEXTERN int ZEXPORT inflateBackEnd(z_streamp strm); | |
| 1169 | 1172 | /* |
| 1170 | 1173 | All memory allocated by inflateBackInit() is freed. |
| 1171 | 1174 | |
| 1172 | 1175 | inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream |
| 1173 | 1176 | state was inconsistent. |
| 1174 | 1177 | */ |
| 1175 | 1178 | |
| 1176 | -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); | |
| 1179 | +ZEXTERN uLong ZEXPORT zlibCompileFlags(void); | |
| 1177 | 1180 | /* Return flags indicating compile-time options. |
| 1178 | 1181 | |
| 1179 | 1182 | Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: |
| 1180 | 1183 | 1.0: size of uInt |
| 1181 | 1184 | 3.2: size of uLong |
| @@ -1224,12 +1227,12 @@ | ||
| 1224 | 1227 | are assumed (compression level and memory usage, standard memory allocation |
| 1225 | 1228 | functions). The source code of these utility functions can be modified if |
| 1226 | 1229 | you need special options. |
| 1227 | 1230 | */ |
| 1228 | 1231 | |
| 1229 | -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, | |
| 1230 | - const Bytef *source, uLong sourceLen)); | |
| 1232 | +ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen, | |
| 1233 | + const Bytef *source, uLong sourceLen); | |
| 1231 | 1234 | /* |
| 1232 | 1235 | Compresses the source buffer into the destination buffer. sourceLen is |
| 1233 | 1236 | the byte length of the source buffer. Upon entry, destLen is the total size |
| 1234 | 1237 | of the destination buffer, which must be at least the value returned by |
| 1235 | 1238 | compressBound(sourceLen). Upon exit, destLen is the actual size of the |
| @@ -1239,13 +1242,13 @@ | ||
| 1239 | 1242 | compress returns Z_OK if success, Z_MEM_ERROR if there was not |
| 1240 | 1243 | enough memory, Z_BUF_ERROR if there was not enough room in the output |
| 1241 | 1244 | buffer. |
| 1242 | 1245 | */ |
| 1243 | 1246 | |
| 1244 | -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, | |
| 1245 | - const Bytef *source, uLong sourceLen, | |
| 1246 | - int level)); | |
| 1247 | +ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen, | |
| 1248 | + const Bytef *source, uLong sourceLen, | |
| 1249 | + int level); | |
| 1247 | 1250 | /* |
| 1248 | 1251 | Compresses the source buffer into the destination buffer. The level |
| 1249 | 1252 | parameter has the same meaning as in deflateInit. sourceLen is the byte |
| 1250 | 1253 | length of the source buffer. Upon entry, destLen is the total size of the |
| 1251 | 1254 | destination buffer, which must be at least the value returned by |
| @@ -1255,19 +1258,19 @@ | ||
| 1255 | 1258 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 1256 | 1259 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, |
| 1257 | 1260 | Z_STREAM_ERROR if the level parameter is invalid. |
| 1258 | 1261 | */ |
| 1259 | 1262 | |
| 1260 | -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); | |
| 1263 | +ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen); | |
| 1261 | 1264 | /* |
| 1262 | 1265 | compressBound() returns an upper bound on the compressed size after |
| 1263 | 1266 | compress() or compress2() on sourceLen bytes. It would be used before a |
| 1264 | 1267 | compress() or compress2() call to allocate the destination buffer. |
| 1265 | 1268 | */ |
| 1266 | 1269 | |
| 1267 | -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, | |
| 1268 | - const Bytef *source, uLong sourceLen)); | |
| 1270 | +ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, | |
| 1271 | + const Bytef *source, uLong sourceLen); | |
| 1269 | 1272 | /* |
| 1270 | 1273 | Decompresses the source buffer into the destination buffer. sourceLen is |
| 1271 | 1274 | the byte length of the source buffer. Upon entry, destLen is the total size |
| 1272 | 1275 | of the destination buffer, which must be large enough to hold the entire |
| 1273 | 1276 | uncompressed data. (The size of the uncompressed data must have been saved |
| @@ -1280,12 +1283,12 @@ | ||
| 1280 | 1283 | buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In |
| 1281 | 1284 | the case where there is not enough room, uncompress() will fill the output |
| 1282 | 1285 | buffer with the uncompressed data up to that point. |
| 1283 | 1286 | */ |
| 1284 | 1287 | |
| 1285 | -ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, | |
| 1286 | - const Bytef *source, uLong *sourceLen)); | |
| 1288 | +ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, | |
| 1289 | + const Bytef *source, uLong *sourceLen); | |
| 1287 | 1290 | /* |
| 1288 | 1291 | Same as uncompress, except that sourceLen is a pointer, where the |
| 1289 | 1292 | length of the source is *sourceLen. On return, *sourceLen is the number of |
| 1290 | 1293 | source bytes consumed. |
| 1291 | 1294 | */ |
| @@ -1300,11 +1303,11 @@ | ||
| 1300 | 1303 | */ |
| 1301 | 1304 | |
| 1302 | 1305 | typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ |
| 1303 | 1306 | |
| 1304 | 1307 | /* |
| 1305 | -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); | |
| 1308 | +ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode); | |
| 1306 | 1309 | |
| 1307 | 1310 | Open the gzip (.gz) file at path for reading and decompressing, or |
| 1308 | 1311 | compressing and writing. The mode parameter is as in fopen ("rb" or "wb") |
| 1309 | 1312 | but can also include a compression level ("wb9") or a strategy: 'f' for |
| 1310 | 1313 | filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", |
| @@ -1337,11 +1340,11 @@ | ||
| 1337 | 1340 | specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). |
| 1338 | 1341 | errno can be checked to determine if the reason gzopen failed was that the |
| 1339 | 1342 | file could not be opened. |
| 1340 | 1343 | */ |
| 1341 | 1344 | |
| 1342 | -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); | |
| 1345 | +ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode); | |
| 1343 | 1346 | /* |
| 1344 | 1347 | Associate a gzFile with the file descriptor fd. File descriptors are |
| 1345 | 1348 | obtained from calls like open, dup, creat, pipe or fileno (if the file has |
| 1346 | 1349 | been previously opened with fopen). The mode parameter is as in gzopen. |
| 1347 | 1350 | |
| @@ -1360,11 +1363,11 @@ | ||
| 1360 | 1363 | provided, or '+' was provided), or if fd is -1. The file descriptor is not |
| 1361 | 1364 | used until the next gz* read, write, seek, or close operation, so gzdopen |
| 1362 | 1365 | will not detect if fd is invalid (unless fd is -1). |
| 1363 | 1366 | */ |
| 1364 | 1367 | |
| 1365 | -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); | |
| 1368 | +ZEXTERN int ZEXPORT gzbuffer(gzFile file, unsigned size); | |
| 1366 | 1369 | /* |
| 1367 | 1370 | Set the internal buffer size used by this library's functions for file to |
| 1368 | 1371 | size. The default buffer size is 8192 bytes. This function must be called |
| 1369 | 1372 | after gzopen() or gzdopen(), and before any other calls that read or write |
| 1370 | 1373 | the file. The buffer memory allocation is always deferred to the first read |
| @@ -1376,11 +1379,11 @@ | ||
| 1376 | 1379 | |
| 1377 | 1380 | gzbuffer() returns 0 on success, or -1 on failure, such as being called |
| 1378 | 1381 | too late. |
| 1379 | 1382 | */ |
| 1380 | 1383 | |
| 1381 | -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); | |
| 1384 | +ZEXTERN int ZEXPORT gzsetparams(gzFile file, int level, int strategy); | |
| 1382 | 1385 | /* |
| 1383 | 1386 | Dynamically update the compression level and strategy for file. See the |
| 1384 | 1387 | description of deflateInit2 for the meaning of these parameters. Previously |
| 1385 | 1388 | provided data is flushed before applying the parameter changes. |
| 1386 | 1389 | |
| @@ -1387,11 +1390,11 @@ | ||
| 1387 | 1390 | gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not |
| 1388 | 1391 | opened for writing, Z_ERRNO if there is an error writing the flushed data, |
| 1389 | 1392 | or Z_MEM_ERROR if there is a memory allocation error. |
| 1390 | 1393 | */ |
| 1391 | 1394 | |
| 1392 | -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); | |
| 1395 | +ZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len); | |
| 1393 | 1396 | /* |
| 1394 | 1397 | Read and decompress up to len uncompressed bytes from file into buf. If |
| 1395 | 1398 | the input file is not in gzip format, gzread copies the given number of |
| 1396 | 1399 | bytes into the buffer directly from the file. |
| 1397 | 1400 | |
| @@ -1417,12 +1420,12 @@ | ||
| 1417 | 1420 | len for end of file, or -1 for error. If len is too large to fit in an int, |
| 1418 | 1421 | then nothing is read, -1 is returned, and the error state is set to |
| 1419 | 1422 | Z_STREAM_ERROR. |
| 1420 | 1423 | */ |
| 1421 | 1424 | |
| 1422 | -ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, | |
| 1423 | - gzFile file)); | |
| 1425 | +ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, | |
| 1426 | + gzFile file); | |
| 1424 | 1427 | /* |
| 1425 | 1428 | Read and decompress up to nitems items of size size from file into buf, |
| 1426 | 1429 | otherwise operating as gzread() does. This duplicates the interface of |
| 1427 | 1430 | stdio's fread(), with size_t request and return types. If the library |
| 1428 | 1431 | defines size_t, then z_size_t is identical to size_t. If not, then z_size_t |
| @@ -1443,18 +1446,18 @@ | ||
| 1443 | 1446 | is the same as the behavior of fread() implementations in common libraries, |
| 1444 | 1447 | but it prevents the direct use of gzfread() to read a concurrently written |
| 1445 | 1448 | file, resetting and retrying on end-of-file, when size is not 1. |
| 1446 | 1449 | */ |
| 1447 | 1450 | |
| 1448 | -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len)); | |
| 1451 | +ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len); | |
| 1449 | 1452 | /* |
| 1450 | 1453 | Compress and write the len uncompressed bytes at buf to file. gzwrite |
| 1451 | 1454 | returns the number of uncompressed bytes written or 0 in case of error. |
| 1452 | 1455 | */ |
| 1453 | 1456 | |
| 1454 | -ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, | |
| 1455 | - z_size_t nitems, gzFile file)); | |
| 1457 | +ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, | |
| 1458 | + z_size_t nitems, gzFile file); | |
| 1456 | 1459 | /* |
| 1457 | 1460 | Compress and write nitems items of size size from buf to file, duplicating |
| 1458 | 1461 | the interface of stdio's fwrite(), with size_t request and return types. If |
| 1459 | 1462 | the library defines size_t, then z_size_t is identical to size_t. If not, |
| 1460 | 1463 | then z_size_t is an unsigned integer type that can contain a pointer. |
| @@ -1463,11 +1466,11 @@ | ||
| 1463 | 1466 | if there was an error. If the multiplication of size and nitems overflows, |
| 1464 | 1467 | i.e. the product does not fit in a z_size_t, then nothing is written, zero |
| 1465 | 1468 | is returned, and the error state is set to Z_STREAM_ERROR. |
| 1466 | 1469 | */ |
| 1467 | 1470 | |
| 1468 | -ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); | |
| 1471 | +ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...); | |
| 1469 | 1472 | /* |
| 1470 | 1473 | Convert, format, compress, and write the arguments (...) to file under |
| 1471 | 1474 | control of the string format, as in fprintf. gzprintf returns the number of |
| 1472 | 1475 | uncompressed bytes actually written, or a negative zlib error code in case |
| 1473 | 1476 | of error. The number of uncompressed bytes written is limited to 8191, or |
| @@ -1478,19 +1481,19 @@ | ||
| 1478 | 1481 | zlib was compiled with the insecure functions sprintf() or vsprintf(), |
| 1479 | 1482 | because the secure snprintf() or vsnprintf() functions were not available. |
| 1480 | 1483 | This can be determined using zlibCompileFlags(). |
| 1481 | 1484 | */ |
| 1482 | 1485 | |
| 1483 | -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); | |
| 1486 | +ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s); | |
| 1484 | 1487 | /* |
| 1485 | 1488 | Compress and write the given null-terminated string s to file, excluding |
| 1486 | 1489 | the terminating null character. |
| 1487 | 1490 | |
| 1488 | 1491 | gzputs returns the number of characters written, or -1 in case of error. |
| 1489 | 1492 | */ |
| 1490 | 1493 | |
| 1491 | -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); | |
| 1494 | +ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len); | |
| 1492 | 1495 | /* |
| 1493 | 1496 | Read and decompress bytes from file into buf, until len-1 characters are |
| 1494 | 1497 | read, or until a newline character is read and transferred to buf, or an |
| 1495 | 1498 | end-of-file condition is encountered. If any characters are read or if len |
| 1496 | 1499 | is one, the string is terminated with a null character. If no characters |
| @@ -1500,26 +1503,26 @@ | ||
| 1500 | 1503 | gzgets returns buf which is a null-terminated string, or it returns NULL |
| 1501 | 1504 | for end-of-file or in case of error. If there was an error, the contents at |
| 1502 | 1505 | buf are indeterminate. |
| 1503 | 1506 | */ |
| 1504 | 1507 | |
| 1505 | -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); | |
| 1508 | +ZEXTERN int ZEXPORT gzputc(gzFile file, int c); | |
| 1506 | 1509 | /* |
| 1507 | 1510 | Compress and write c, converted to an unsigned char, into file. gzputc |
| 1508 | 1511 | returns the value that was written, or -1 in case of error. |
| 1509 | 1512 | */ |
| 1510 | 1513 | |
| 1511 | -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); | |
| 1514 | +ZEXTERN int ZEXPORT gzgetc(gzFile file); | |
| 1512 | 1515 | /* |
| 1513 | 1516 | Read and decompress one byte from file. gzgetc returns this byte or -1 |
| 1514 | 1517 | in case of end of file or error. This is implemented as a macro for speed. |
| 1515 | 1518 | As such, it does not do all of the checking the other functions do. I.e. |
| 1516 | 1519 | it does not check to see if file is NULL, nor whether the structure file |
| 1517 | 1520 | points to has been clobbered or not. |
| 1518 | 1521 | */ |
| 1519 | 1522 | |
| 1520 | -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); | |
| 1523 | +ZEXTERN int ZEXPORT gzungetc(int c, gzFile file); | |
| 1521 | 1524 | /* |
| 1522 | 1525 | Push c back onto the stream for file to be read as the first character on |
| 1523 | 1526 | the next read. At least one character of push-back is always allowed. |
| 1524 | 1527 | gzungetc() returns the character pushed, or -1 on failure. gzungetc() will |
| 1525 | 1528 | fail if c is -1, and may fail if a character has been pushed but not read |
| @@ -1527,11 +1530,11 @@ | ||
| 1527 | 1530 | output buffer size of pushed characters is allowed. (See gzbuffer above.) |
| 1528 | 1531 | The pushed character will be discarded if the stream is repositioned with |
| 1529 | 1532 | gzseek() or gzrewind(). |
| 1530 | 1533 | */ |
| 1531 | 1534 | |
| 1532 | -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); | |
| 1535 | +ZEXTERN int ZEXPORT gzflush(gzFile file, int flush); | |
| 1533 | 1536 | /* |
| 1534 | 1537 | Flush all pending output to file. The parameter flush is as in the |
| 1535 | 1538 | deflate() function. The return value is the zlib error number (see function |
| 1536 | 1539 | gzerror below). gzflush is only permitted when writing. |
| 1537 | 1540 | |
| @@ -1543,12 +1546,12 @@ | ||
| 1543 | 1546 | gzflush should be called only when strictly necessary because it will |
| 1544 | 1547 | degrade compression if called too often. |
| 1545 | 1548 | */ |
| 1546 | 1549 | |
| 1547 | 1550 | /* |
| 1548 | -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, | |
| 1549 | - z_off_t offset, int whence)); | |
| 1551 | +ZEXTERN z_off_t ZEXPORT gzseek(gzFile file, | |
| 1552 | + z_off_t offset, int whence); | |
| 1550 | 1553 | |
| 1551 | 1554 | Set the starting position to offset relative to whence for the next gzread |
| 1552 | 1555 | or gzwrite on file. The offset represents a number of bytes in the |
| 1553 | 1556 | uncompressed data stream. The whence parameter is defined as in lseek(2); |
| 1554 | 1557 | the value SEEK_END is not supported. |
| @@ -1562,19 +1565,19 @@ | ||
| 1562 | 1565 | the beginning of the uncompressed stream, or -1 in case of error, in |
| 1563 | 1566 | particular if the file is opened for writing and the new starting position |
| 1564 | 1567 | would be before the current position. |
| 1565 | 1568 | */ |
| 1566 | 1569 | |
| 1567 | -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); | |
| 1570 | +ZEXTERN int ZEXPORT gzrewind(gzFile file); | |
| 1568 | 1571 | /* |
| 1569 | 1572 | Rewind file. This function is supported only for reading. |
| 1570 | 1573 | |
| 1571 | 1574 | gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET). |
| 1572 | 1575 | */ |
| 1573 | 1576 | |
| 1574 | 1577 | /* |
| 1575 | -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); | |
| 1578 | +ZEXTERN z_off_t ZEXPORT gztell(gzFile file); | |
| 1576 | 1579 | |
| 1577 | 1580 | Return the starting position for the next gzread or gzwrite on file. |
| 1578 | 1581 | This position represents a number of bytes in the uncompressed data stream, |
| 1579 | 1582 | and is zero when starting, even if appending or reading a gzip stream from |
| 1580 | 1583 | the middle of a file using gzdopen(). |
| @@ -1581,20 +1584,20 @@ | ||
| 1581 | 1584 | |
| 1582 | 1585 | gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) |
| 1583 | 1586 | */ |
| 1584 | 1587 | |
| 1585 | 1588 | /* |
| 1586 | -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); | |
| 1589 | +ZEXTERN z_off_t ZEXPORT gzoffset(gzFile file); | |
| 1587 | 1590 | |
| 1588 | 1591 | Return the current compressed (actual) read or write offset of file. This |
| 1589 | 1592 | offset includes the count of bytes that precede the gzip stream, for example |
| 1590 | 1593 | when appending or when using gzdopen() for reading. When reading, the |
| 1591 | 1594 | offset does not include as yet unused buffered input. This information can |
| 1592 | 1595 | be used for a progress indicator. On error, gzoffset() returns -1. |
| 1593 | 1596 | */ |
| 1594 | 1597 | |
| 1595 | -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); | |
| 1598 | +ZEXTERN int ZEXPORT gzeof(gzFile file); | |
| 1596 | 1599 | /* |
| 1597 | 1600 | Return true (1) if the end-of-file indicator for file has been set while |
| 1598 | 1601 | reading, false (0) otherwise. Note that the end-of-file indicator is set |
| 1599 | 1602 | only if the read tried to go past the end of the input, but came up short. |
| 1600 | 1603 | Therefore, just like feof(), gzeof() may return false even if there is no |
| @@ -1605,11 +1608,11 @@ | ||
| 1605 | 1608 | If gzeof() returns true, then the read functions will return no more data, |
| 1606 | 1609 | unless the end-of-file indicator is reset by gzclearerr() and the input file |
| 1607 | 1610 | has grown since the previous end of file was detected. |
| 1608 | 1611 | */ |
| 1609 | 1612 | |
| 1610 | -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); | |
| 1613 | +ZEXTERN int ZEXPORT gzdirect(gzFile file); | |
| 1611 | 1614 | /* |
| 1612 | 1615 | Return true (1) if file is being copied directly while reading, or false |
| 1613 | 1616 | (0) if file is a gzip stream being decompressed. |
| 1614 | 1617 | |
| 1615 | 1618 | If the input file is empty, gzdirect() will return true, since the input |
| @@ -1626,11 +1629,11 @@ | ||
| 1626 | 1629 | explicitly requested, so the application already knows the answer. When |
| 1627 | 1630 | linking statically, using gzdirect() will include all of the zlib code for |
| 1628 | 1631 | gzip file reading and decompression, which may not be desired.) |
| 1629 | 1632 | */ |
| 1630 | 1633 | |
| 1631 | -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); | |
| 1634 | +ZEXTERN int ZEXPORT gzclose(gzFile file); | |
| 1632 | 1635 | /* |
| 1633 | 1636 | Flush all pending output for file, if necessary, close file and |
| 1634 | 1637 | deallocate the (de)compression state. Note that once file is closed, you |
| 1635 | 1638 | cannot call gzerror with file, since its structures have been deallocated. |
| 1636 | 1639 | gzclose must not be called more than once on the same file, just as free |
| @@ -1639,12 +1642,12 @@ | ||
| 1639 | 1642 | gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a |
| 1640 | 1643 | file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the |
| 1641 | 1644 | last read ended in the middle of a gzip stream, or Z_OK on success. |
| 1642 | 1645 | */ |
| 1643 | 1646 | |
| 1644 | -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); | |
| 1645 | -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); | |
| 1647 | +ZEXTERN int ZEXPORT gzclose_r(gzFile file); | |
| 1648 | +ZEXTERN int ZEXPORT gzclose_w(gzFile file); | |
| 1646 | 1649 | /* |
| 1647 | 1650 | Same as gzclose(), but gzclose_r() is only for use when reading, and |
| 1648 | 1651 | gzclose_w() is only for use when writing or appending. The advantage to |
| 1649 | 1652 | using these instead of gzclose() is that they avoid linking in zlib |
| 1650 | 1653 | compression or decompression code that is not used when only reading or only |
| @@ -1651,11 +1654,11 @@ | ||
| 1651 | 1654 | writing respectively. If gzclose() is used, then both compression and |
| 1652 | 1655 | decompression code will be included the application when linking to a static |
| 1653 | 1656 | zlib library. |
| 1654 | 1657 | */ |
| 1655 | 1658 | |
| 1656 | -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); | |
| 1659 | +ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum); | |
| 1657 | 1660 | /* |
| 1658 | 1661 | Return the error message for the last error which occurred on file. |
| 1659 | 1662 | errnum is set to zlib error number. If an error occurred in the file system |
| 1660 | 1663 | and not in the compression library, errnum is set to Z_ERRNO and the |
| 1661 | 1664 | application may consult errno to get the exact error code. |
| @@ -1667,11 +1670,11 @@ | ||
| 1667 | 1670 | |
| 1668 | 1671 | gzerror() should be used to distinguish errors from end-of-file for those |
| 1669 | 1672 | functions above that do not distinguish those cases in their return values. |
| 1670 | 1673 | */ |
| 1671 | 1674 | |
| 1672 | -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); | |
| 1675 | +ZEXTERN void ZEXPORT gzclearerr(gzFile file); | |
| 1673 | 1676 | /* |
| 1674 | 1677 | Clear the error and end-of-file flags for file. This is analogous to the |
| 1675 | 1678 | clearerr() function in stdio. This is useful for continuing to read a gzip |
| 1676 | 1679 | file that is being written concurrently. |
| 1677 | 1680 | */ |
| @@ -1684,11 +1687,11 @@ | ||
| 1684 | 1687 | These functions are not related to compression but are exported |
| 1685 | 1688 | anyway because they might be useful in applications using the compression |
| 1686 | 1689 | library. |
| 1687 | 1690 | */ |
| 1688 | 1691 | |
| 1689 | -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); | |
| 1692 | +ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len); | |
| 1690 | 1693 | /* |
| 1691 | 1694 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and |
| 1692 | 1695 | return the updated checksum. An Adler-32 value is in the range of a 32-bit |
| 1693 | 1696 | unsigned integer. If buf is Z_NULL, this function returns the required |
| 1694 | 1697 | initial value for the checksum. |
| @@ -1704,29 +1707,29 @@ | ||
| 1704 | 1707 | adler = adler32(adler, buffer, length); |
| 1705 | 1708 | } |
| 1706 | 1709 | if (adler != original_adler) error(); |
| 1707 | 1710 | */ |
| 1708 | 1711 | |
| 1709 | -ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, | |
| 1710 | - z_size_t len)); | |
| 1712 | +ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, | |
| 1713 | + z_size_t len); | |
| 1711 | 1714 | /* |
| 1712 | 1715 | Same as adler32(), but with a size_t length. |
| 1713 | 1716 | */ |
| 1714 | 1717 | |
| 1715 | 1718 | /* |
| 1716 | -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, | |
| 1717 | - z_off_t len2)); | |
| 1719 | +ZEXTERN uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, | |
| 1720 | + z_off_t len2); | |
| 1718 | 1721 | |
| 1719 | 1722 | Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 |
| 1720 | 1723 | and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for |
| 1721 | 1724 | each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of |
| 1722 | 1725 | seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note |
| 1723 | 1726 | that the z_off_t type (like off_t) is a signed integer. If len2 is |
| 1724 | 1727 | negative, the result has no meaning or utility. |
| 1725 | 1728 | */ |
| 1726 | 1729 | |
| 1727 | -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); | |
| 1730 | +ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len); | |
| 1728 | 1731 | /* |
| 1729 | 1732 | Update a running CRC-32 with the bytes buf[0..len-1] and return the |
| 1730 | 1733 | updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. |
| 1731 | 1734 | If buf is Z_NULL, this function returns the required initial value for the |
| 1732 | 1735 | crc. Pre- and post-conditioning (one's complement) is performed within this |
| @@ -1740,34 +1743,34 @@ | ||
| 1740 | 1743 | crc = crc32(crc, buffer, length); |
| 1741 | 1744 | } |
| 1742 | 1745 | if (crc != original_crc) error(); |
| 1743 | 1746 | */ |
| 1744 | 1747 | |
| 1745 | -ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf, | |
| 1746 | - z_size_t len)); | |
| 1748 | +ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf, | |
| 1749 | + z_size_t len); | |
| 1747 | 1750 | /* |
| 1748 | 1751 | Same as crc32(), but with a size_t length. |
| 1749 | 1752 | */ |
| 1750 | 1753 | |
| 1751 | 1754 | /* |
| 1752 | -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); | |
| 1755 | +ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2); | |
| 1753 | 1756 | |
| 1754 | 1757 | Combine two CRC-32 check values into one. For two sequences of bytes, |
| 1755 | 1758 | seq1 and seq2 with lengths len1 and len2, CRC-32 check values were |
| 1756 | 1759 | calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 |
| 1757 | 1760 | check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and |
| 1758 | 1761 | len2. |
| 1759 | 1762 | */ |
| 1760 | 1763 | |
| 1761 | 1764 | /* |
| 1762 | -ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2)); | |
| 1765 | +ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2); | |
| 1763 | 1766 | |
| 1764 | 1767 | Return the operator corresponding to length len2, to be used with |
| 1765 | 1768 | crc32_combine_op(). |
| 1766 | 1769 | */ |
| 1767 | 1770 | |
| 1768 | -ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op)); | |
| 1771 | +ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op); | |
| 1769 | 1772 | /* |
| 1770 | 1773 | Give the same result as crc32_combine(), using op in place of len2. op is |
| 1771 | 1774 | is generated from len2 by crc32_combine_gen(). This will be faster than |
| 1772 | 1775 | crc32_combine() if the generated op is used more than once. |
| 1773 | 1776 | */ |
| @@ -1776,24 +1779,24 @@ | ||
| 1776 | 1779 | /* various hacks, don't look :) */ |
| 1777 | 1780 | |
| 1778 | 1781 | /* deflateInit and inflateInit are macros to allow checking the zlib version |
| 1779 | 1782 | * and the compiler's view of z_stream: |
| 1780 | 1783 | */ |
| 1781 | -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, | |
| 1782 | - const char *version, int stream_size)); | |
| 1783 | -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, | |
| 1784 | - const char *version, int stream_size)); | |
| 1785 | -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, | |
| 1786 | - int windowBits, int memLevel, | |
| 1787 | - int strategy, const char *version, | |
| 1788 | - int stream_size)); | |
| 1789 | -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, | |
| 1790 | - const char *version, int stream_size)); | |
| 1791 | -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, | |
| 1792 | - unsigned char FAR *window, | |
| 1793 | - const char *version, | |
| 1794 | - int stream_size)); | |
| 1784 | +ZEXTERN int ZEXPORT deflateInit_(z_streamp strm, int level, | |
| 1785 | + const char *version, int stream_size); | |
| 1786 | +ZEXTERN int ZEXPORT inflateInit_(z_streamp strm, | |
| 1787 | + const char *version, int stream_size); | |
| 1788 | +ZEXTERN int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, | |
| 1789 | + int windowBits, int memLevel, | |
| 1790 | + int strategy, const char *version, | |
| 1791 | + int stream_size); | |
| 1792 | +ZEXTERN int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, | |
| 1793 | + const char *version, int stream_size); | |
| 1794 | +ZEXTERN int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, | |
| 1795 | + unsigned char FAR *window, | |
| 1796 | + const char *version, | |
| 1797 | + int stream_size); | |
| 1795 | 1798 | #ifdef Z_PREFIX_SET |
| 1796 | 1799 | # define z_deflateInit(strm, level) \ |
| 1797 | 1800 | deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) |
| 1798 | 1801 | # define z_inflateInit(strm) \ |
| 1799 | 1802 | inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) |
| @@ -1834,11 +1837,11 @@ | ||
| 1834 | 1837 | struct gzFile_s { |
| 1835 | 1838 | unsigned have; |
| 1836 | 1839 | unsigned char *next; |
| 1837 | 1840 | z_off64_t pos; |
| 1838 | 1841 | }; |
| 1839 | -ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ | |
| 1842 | +ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */ | |
| 1840 | 1843 | #ifdef Z_PREFIX_SET |
| 1841 | 1844 | # undef z_gzgetc |
| 1842 | 1845 | # define z_gzgetc(g) \ |
| 1843 | 1846 | ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) |
| 1844 | 1847 | #else |
| @@ -1851,17 +1854,17 @@ | ||
| 1851 | 1854 | * both are true, the application gets the *64 functions, and the regular |
| 1852 | 1855 | * functions are changed to 64 bits) -- in case these are set on systems |
| 1853 | 1856 | * without large file support, _LFS64_LARGEFILE must also be true |
| 1854 | 1857 | */ |
| 1855 | 1858 | #ifdef Z_LARGE64 |
| 1856 | - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); | |
| 1857 | - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); | |
| 1858 | - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); | |
| 1859 | - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); | |
| 1860 | - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); | |
| 1861 | - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); | |
| 1862 | - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t)); | |
| 1859 | + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); | |
| 1860 | + ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); | |
| 1861 | + ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); | |
| 1862 | + ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); | |
| 1863 | + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t); | |
| 1864 | + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t); | |
| 1865 | + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t); | |
| 1863 | 1866 | #endif |
| 1864 | 1867 | |
| 1865 | 1868 | #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) |
| 1866 | 1869 | # ifdef Z_PREFIX_SET |
| 1867 | 1870 | # define z_gzopen z_gzopen64 |
| @@ -1879,57 +1882,57 @@ | ||
| 1879 | 1882 | # define adler32_combine adler32_combine64 |
| 1880 | 1883 | # define crc32_combine crc32_combine64 |
| 1881 | 1884 | # define crc32_combine_gen crc32_combine_gen64 |
| 1882 | 1885 | # endif |
| 1883 | 1886 | # ifndef Z_LARGE64 |
| 1884 | - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); | |
| 1885 | - ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); | |
| 1886 | - ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); | |
| 1887 | - ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); | |
| 1888 | - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); | |
| 1889 | - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); | |
| 1890 | - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); | |
| 1887 | + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); | |
| 1888 | + ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int); | |
| 1889 | + ZEXTERN z_off_t ZEXPORT gztell64(gzFile); | |
| 1890 | + ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile); | |
| 1891 | + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); | |
| 1892 | + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); | |
| 1893 | + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); | |
| 1891 | 1894 | # endif |
| 1892 | 1895 | #else |
| 1893 | - ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); | |
| 1894 | - ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); | |
| 1895 | - ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); | |
| 1896 | - ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); | |
| 1897 | - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); | |
| 1898 | - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); | |
| 1899 | - ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); | |
| 1896 | + ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *); | |
| 1897 | + ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int); | |
| 1898 | + ZEXTERN z_off_t ZEXPORT gztell(gzFile); | |
| 1899 | + ZEXTERN z_off_t ZEXPORT gzoffset(gzFile); | |
| 1900 | + ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); | |
| 1901 | + ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); | |
| 1902 | + ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); | |
| 1900 | 1903 | #endif |
| 1901 | 1904 | |
| 1902 | 1905 | #else /* Z_SOLO */ |
| 1903 | 1906 | |
| 1904 | - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); | |
| 1905 | - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); | |
| 1906 | - ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); | |
| 1907 | + ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); | |
| 1908 | + ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); | |
| 1909 | + ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); | |
| 1907 | 1910 | |
| 1908 | 1911 | #endif /* !Z_SOLO */ |
| 1909 | 1912 | |
| 1910 | 1913 | /* undocumented functions */ |
| 1911 | -ZEXTERN const char * ZEXPORT zError OF((int)); | |
| 1912 | -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); | |
| 1913 | -ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); | |
| 1914 | -ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); | |
| 1915 | -ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); | |
| 1916 | -ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF((z_streamp)); | |
| 1917 | -ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); | |
| 1918 | -ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); | |
| 1914 | +ZEXTERN const char * ZEXPORT zError(int); | |
| 1915 | +ZEXTERN int ZEXPORT inflateSyncPoint(z_streamp); | |
| 1916 | +ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void); | |
| 1917 | +ZEXTERN int ZEXPORT inflateUndermine(z_streamp, int); | |
| 1918 | +ZEXTERN int ZEXPORT inflateValidate(z_streamp, int); | |
| 1919 | +ZEXTERN unsigned long ZEXPORT inflateCodesUsed(z_streamp); | |
| 1920 | +ZEXTERN int ZEXPORT inflateResetKeep(z_streamp); | |
| 1921 | +ZEXTERN int ZEXPORT deflateResetKeep(z_streamp); | |
| 1919 | 1922 | #if defined(_WIN32) && !defined(Z_SOLO) |
| 1920 | -ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, | |
| 1921 | - const char *mode)); | |
| 1923 | +ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path, | |
| 1924 | + const char *mode); | |
| 1922 | 1925 | #endif |
| 1923 | 1926 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) |
| 1924 | 1927 | # ifndef Z_SOLO |
| 1925 | -ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, | |
| 1926 | - const char *format, | |
| 1927 | - va_list va)); | |
| 1928 | +ZEXTERN int ZEXPORTVA gzvprintf(gzFile file, | |
| 1929 | + const char *format, | |
| 1930 | + va_list va); | |
| 1928 | 1931 | # endif |
| 1929 | 1932 | #endif |
| 1930 | 1933 | |
| 1931 | 1934 | #ifdef __cplusplus |
| 1932 | 1935 | } |
| 1933 | 1936 | #endif |
| 1934 | 1937 | |
| 1935 | 1938 | #endif /* ZLIB_H */ |
| 1936 | 1939 | |
| 1937 | 1940 | DELETED compat/zlib/zlib2ansi |
| --- compat/zlib/zlib.h | |
| +++ compat/zlib/zlib.h | |
| @@ -1,9 +1,9 @@ | |
| 1 | /* zlib.h -- interface of the 'zlib' general purpose compression library |
| 2 | version 1.2.13, October 13th, 2022 |
| 3 | |
| 4 | Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler |
| 5 | |
| 6 | This software is provided 'as-is', without any express or implied |
| 7 | warranty. In no event will the authors be held liable for any damages |
| 8 | arising from the use of this software. |
| 9 | |
| @@ -35,15 +35,15 @@ | |
| 35 | |
| 36 | #ifdef __cplusplus |
| 37 | extern "C" { |
| 38 | #endif |
| 39 | |
| 40 | #define ZLIB_VERSION "1.2.13" |
| 41 | #define ZLIB_VERNUM 0x12d0 |
| 42 | #define ZLIB_VER_MAJOR 1 |
| 43 | #define ZLIB_VER_MINOR 2 |
| 44 | #define ZLIB_VER_REVISION 13 |
| 45 | #define ZLIB_VER_SUBREVISION 0 |
| 46 | |
| 47 | /* |
| 48 | The 'zlib' compression library provides in-memory compression and |
| 49 | decompression functions, including integrity checks of the uncompressed data. |
| @@ -76,12 +76,12 @@ | |
| 76 | The library does not install any signal handler. The decoder checks |
| 77 | the consistency of the compressed data, so the library should never crash |
| 78 | even in the case of corrupted input. |
| 79 | */ |
| 80 | |
| 81 | typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); |
| 82 | typedef void (*free_func) OF((voidpf opaque, voidpf address)); |
| 83 | |
| 84 | struct internal_state; |
| 85 | |
| 86 | typedef struct z_stream_s { |
| 87 | z_const Bytef *next_in; /* next input byte */ |
| @@ -215,24 +215,24 @@ | |
| 215 | /* for compatibility with versions < 1.0.2 */ |
| 216 | |
| 217 | |
| 218 | /* basic functions */ |
| 219 | |
| 220 | ZEXTERN const char * ZEXPORT zlibVersion OF((void)); |
| 221 | /* The application can compare zlibVersion and ZLIB_VERSION for consistency. |
| 222 | If the first character differs, the library code actually used is not |
| 223 | compatible with the zlib.h header file used by the application. This check |
| 224 | is automatically made by deflateInit and inflateInit. |
| 225 | */ |
| 226 | |
| 227 | /* |
| 228 | ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); |
| 229 | |
| 230 | Initializes the internal stream state for compression. The fields |
| 231 | zalloc, zfree and opaque must be initialized before by the caller. If |
| 232 | zalloc and zfree are set to Z_NULL, deflateInit updates them to use default |
| 233 | allocation functions. |
| 234 | |
| 235 | The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: |
| 236 | 1 gives best speed, 9 gives best compression, 0 gives no compression at all |
| 237 | (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION |
| 238 | requests a default compromise between speed and compression (currently |
| @@ -245,11 +245,11 @@ | |
| 245 | if there is no error message. deflateInit does not perform any compression: |
| 246 | this will be done by deflate(). |
| 247 | */ |
| 248 | |
| 249 | |
| 250 | ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); |
| 251 | /* |
| 252 | deflate compresses as much data as possible, and stops when the input |
| 253 | buffer becomes empty or the output buffer becomes full. It may introduce |
| 254 | some output latency (reading input without producing any output) except when |
| 255 | forced to flush. |
| @@ -318,12 +318,12 @@ | |
| 318 | |
| 319 | If deflate returns with avail_out == 0, this function must be called again |
| 320 | with the same value of the flush parameter and more output space (updated |
| 321 | avail_out), until the flush is complete (deflate returns with non-zero |
| 322 | avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that |
| 323 | avail_out is greater than six to avoid repeated flush markers due to |
| 324 | avail_out == 0 on return. |
| 325 | |
| 326 | If the parameter flush is set to Z_FINISH, pending input is processed, |
| 327 | pending output is flushed and deflate returns with Z_STREAM_END if there was |
| 328 | enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this |
| 329 | function must be called again with Z_FINISH and more output space (updated |
| @@ -358,11 +358,11 @@ | |
| 358 | deflate() can be called again with more input and more output space to |
| 359 | continue compressing. |
| 360 | */ |
| 361 | |
| 362 | |
| 363 | ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); |
| 364 | /* |
| 365 | All dynamically allocated data structures for this stream are freed. |
| 366 | This function discards any unprocessed input and does not flush any pending |
| 367 | output. |
| 368 | |
| @@ -373,19 +373,20 @@ | |
| 373 | deallocated). |
| 374 | */ |
| 375 | |
| 376 | |
| 377 | /* |
| 378 | ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); |
| 379 | |
| 380 | Initializes the internal stream state for decompression. The fields |
| 381 | next_in, avail_in, zalloc, zfree and opaque must be initialized before by |
| 382 | the caller. In the current version of inflate, the provided input is not |
| 383 | read or consumed. The allocation of a sliding window will be deferred to |
| 384 | the first call of inflate (if the decompression does not complete on the |
| 385 | first call). If zalloc and zfree are set to Z_NULL, inflateInit updates |
| 386 | them to use default allocation functions. |
| 387 | |
| 388 | inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 389 | memory, Z_VERSION_ERROR if the zlib library version is incompatible with the |
| 390 | version assumed by the caller, or Z_STREAM_ERROR if the parameters are |
| 391 | invalid, such as a null pointer to the structure. msg is set to null if |
| @@ -395,11 +396,11 @@ | |
| 395 | implementation of inflateInit() does not process any header information -- |
| 396 | that is deferred until inflate() is called. |
| 397 | */ |
| 398 | |
| 399 | |
| 400 | ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); |
| 401 | /* |
| 402 | inflate decompresses as much data as possible, and stops when the input |
| 403 | buffer becomes empty or the output buffer becomes full. It may introduce |
| 404 | some output latency (reading input without producing any output) except when |
| 405 | forced to flush. |
| @@ -515,11 +516,11 @@ | |
| 515 | then call inflateSync() to look for a good compression block if a partial |
| 516 | recovery of the data is to be attempted. |
| 517 | */ |
| 518 | |
| 519 | |
| 520 | ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); |
| 521 | /* |
| 522 | All dynamically allocated data structures for this stream are freed. |
| 523 | This function discards any unprocessed input and does not flush any pending |
| 524 | output. |
| 525 | |
| @@ -533,16 +534,16 @@ | |
| 533 | /* |
| 534 | The following functions are needed only in some special applications. |
| 535 | */ |
| 536 | |
| 537 | /* |
| 538 | ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, |
| 539 | int level, |
| 540 | int method, |
| 541 | int windowBits, |
| 542 | int memLevel, |
| 543 | int strategy)); |
| 544 | |
| 545 | This is another version of deflateInit with more compression options. The |
| 546 | fields zalloc, zfree and opaque must be initialized before by the caller. |
| 547 | |
| 548 | The method parameter is the compression method. It must be Z_DEFLATED in |
| @@ -605,13 +606,13 @@ | |
| 605 | incompatible with the version assumed by the caller (ZLIB_VERSION). msg is |
| 606 | set to null if there is no error message. deflateInit2 does not perform any |
| 607 | compression: this will be done by deflate(). |
| 608 | */ |
| 609 | |
| 610 | ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, |
| 611 | const Bytef *dictionary, |
| 612 | uInt dictLength)); |
| 613 | /* |
| 614 | Initializes the compression dictionary from the given byte sequence |
| 615 | without producing any compressed output. When using the zlib format, this |
| 616 | function must be called immediately after deflateInit, deflateInit2 or |
| 617 | deflateReset, and before any call of deflate. When doing raw deflate, this |
| @@ -649,13 +650,13 @@ | |
| 649 | inconsistent (for example if deflate has already been called for this stream |
| 650 | or if not at a block boundary for raw deflate). deflateSetDictionary does |
| 651 | not perform any compression: this will be done by deflate(). |
| 652 | */ |
| 653 | |
| 654 | ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, |
| 655 | Bytef *dictionary, |
| 656 | uInt *dictLength)); |
| 657 | /* |
| 658 | Returns the sliding dictionary being maintained by deflate. dictLength is |
| 659 | set to the number of bytes in the dictionary, and that many bytes are copied |
| 660 | to dictionary. dictionary must have enough space, where 32768 bytes is |
| 661 | always enough. If deflateGetDictionary() is called with dictionary equal to |
| @@ -671,12 +672,12 @@ | |
| 671 | |
| 672 | deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the |
| 673 | stream state is inconsistent. |
| 674 | */ |
| 675 | |
| 676 | ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, |
| 677 | z_streamp source)); |
| 678 | /* |
| 679 | Sets the destination stream as a complete copy of the source stream. |
| 680 | |
| 681 | This function can be useful when several compression strategies will be |
| 682 | tried, for example when there are several ways of pre-processing the input |
| @@ -689,24 +690,24 @@ | |
| 689 | enough memory, Z_STREAM_ERROR if the source stream state was inconsistent |
| 690 | (such as zalloc being Z_NULL). msg is left unchanged in both source and |
| 691 | destination. |
| 692 | */ |
| 693 | |
| 694 | ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); |
| 695 | /* |
| 696 | This function is equivalent to deflateEnd followed by deflateInit, but |
| 697 | does not free and reallocate the internal compression state. The stream |
| 698 | will leave the compression level and any other attributes that may have been |
| 699 | set unchanged. |
| 700 | |
| 701 | deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 702 | stream state was inconsistent (such as zalloc or state being Z_NULL). |
| 703 | */ |
| 704 | |
| 705 | ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, |
| 706 | int level, |
| 707 | int strategy)); |
| 708 | /* |
| 709 | Dynamically update the compression level and compression strategy. The |
| 710 | interpretation of level and strategy is as in deflateInit2(). This can be |
| 711 | used to switch between compression and straight copy of the input data, or |
| 712 | to switch to a different kind of input data requiring a different strategy. |
| @@ -727,11 +728,11 @@ | |
| 727 | deflate stream should be flushed using deflate() with Z_BLOCK or other flush |
| 728 | request until strm.avail_out is not zero, before calling deflateParams(). |
| 729 | Then no more input data should be provided before the deflateParams() call. |
| 730 | If this is done, the old level and strategy will be applied to the data |
| 731 | compressed before deflateParams(), and the new level and strategy will be |
| 732 | applied to the the data compressed after deflateParams(). |
| 733 | |
| 734 | deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream |
| 735 | state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if |
| 736 | there was not enough output space to complete the compression of the |
| 737 | available input data before a change in the strategy or approach. Note that |
| @@ -738,15 +739,15 @@ | |
| 738 | in the case of a Z_BUF_ERROR, the parameters are not changed. A return |
| 739 | value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be |
| 740 | retried with more output space. |
| 741 | */ |
| 742 | |
| 743 | ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, |
| 744 | int good_length, |
| 745 | int max_lazy, |
| 746 | int nice_length, |
| 747 | int max_chain)); |
| 748 | /* |
| 749 | Fine tune deflate's internal compression parameters. This should only be |
| 750 | used by someone who understands the algorithm used by zlib's deflate for |
| 751 | searching for the best matching string, and even then only by the most |
| 752 | fanatic optimizer trying to squeeze out the last compressed bit for their |
| @@ -755,12 +756,12 @@ | |
| 755 | |
| 756 | deflateTune() can be called after deflateInit() or deflateInit2(), and |
| 757 | returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. |
| 758 | */ |
| 759 | |
| 760 | ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, |
| 761 | uLong sourceLen)); |
| 762 | /* |
| 763 | deflateBound() returns an upper bound on the compressed size after |
| 764 | deflation of sourceLen bytes. It must be called after deflateInit() or |
| 765 | deflateInit2(), and after deflateSetHeader(), if used. This would be used |
| 766 | to allocate an output buffer for deflation in a single pass, and so would be |
| @@ -770,13 +771,13 @@ | |
| 770 | to return Z_STREAM_END. Note that it is possible for the compressed size to |
| 771 | be larger than the value returned by deflateBound() if flush options other |
| 772 | than Z_FINISH or Z_NO_FLUSH are used. |
| 773 | */ |
| 774 | |
| 775 | ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, |
| 776 | unsigned *pending, |
| 777 | int *bits)); |
| 778 | /* |
| 779 | deflatePending() returns the number of bytes and bits of output that have |
| 780 | been generated, but not yet provided in the available output. The bytes not |
| 781 | provided would be due to the available output space having being consumed. |
| 782 | The number of bits of output not provided are between 0 and 7, where they |
| @@ -785,13 +786,13 @@ | |
| 785 | |
| 786 | deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 787 | stream state was inconsistent. |
| 788 | */ |
| 789 | |
| 790 | ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, |
| 791 | int bits, |
| 792 | int value)); |
| 793 | /* |
| 794 | deflatePrime() inserts bits in the deflate output stream. The intent |
| 795 | is that this function is used to start off the deflate output with the bits |
| 796 | leftover from a previous deflate stream when appending to it. As such, this |
| 797 | function can only be used for raw deflate, and must be used before the first |
| @@ -802,12 +803,12 @@ | |
| 802 | deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough |
| 803 | room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the |
| 804 | source stream state was inconsistent. |
| 805 | */ |
| 806 | |
| 807 | ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, |
| 808 | gz_headerp head)); |
| 809 | /* |
| 810 | deflateSetHeader() provides gzip header information for when a gzip |
| 811 | stream is requested by deflateInit2(). deflateSetHeader() may be called |
| 812 | after deflateInit2() or deflateReset() and before the first call of |
| 813 | deflate(). The text, time, os, extra field, name, and comment information |
| @@ -819,20 +820,21 @@ | |
| 819 | the current versions of the command-line version of gzip (up through version |
| 820 | 1.3.x) do not support header crc's, and will report that it is a "multi-part |
| 821 | gzip file" and give up. |
| 822 | |
| 823 | If deflateSetHeader is not used, the default gzip header has text false, |
| 824 | the time set to zero, and os set to 255, with no extra, name, or comment |
| 825 | fields. The gzip header is returned to the default state by deflateReset(). |
| 826 | |
| 827 | deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 828 | stream state was inconsistent. |
| 829 | */ |
| 830 | |
| 831 | /* |
| 832 | ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, |
| 833 | int windowBits)); |
| 834 | |
| 835 | This is another version of inflateInit with an extra parameter. The |
| 836 | fields next_in, avail_in, zalloc, zfree and opaque must be initialized |
| 837 | before by the caller. |
| 838 | |
| @@ -881,13 +883,13 @@ | |
| 881 | next_out and avail_out are unused and unchanged.) The current implementation |
| 882 | of inflateInit2() does not process any header information -- that is |
| 883 | deferred until inflate() is called. |
| 884 | */ |
| 885 | |
| 886 | ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, |
| 887 | const Bytef *dictionary, |
| 888 | uInt dictLength)); |
| 889 | /* |
| 890 | Initializes the decompression dictionary from the given uncompressed byte |
| 891 | sequence. This function must be called immediately after a call of inflate, |
| 892 | if that call returned Z_NEED_DICT. The dictionary chosen by the compressor |
| 893 | can be determined from the Adler-32 value returned by that call of inflate. |
| @@ -904,13 +906,13 @@ | |
| 904 | expected one (incorrect Adler-32 value). inflateSetDictionary does not |
| 905 | perform any decompression: this will be done by subsequent calls of |
| 906 | inflate(). |
| 907 | */ |
| 908 | |
| 909 | ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, |
| 910 | Bytef *dictionary, |
| 911 | uInt *dictLength)); |
| 912 | /* |
| 913 | Returns the sliding dictionary being maintained by inflate. dictLength is |
| 914 | set to the number of bytes in the dictionary, and that many bytes are copied |
| 915 | to dictionary. dictionary must have enough space, where 32768 bytes is |
| 916 | always enough. If inflateGetDictionary() is called with dictionary equal to |
| @@ -919,11 +921,11 @@ | |
| 919 | |
| 920 | inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the |
| 921 | stream state is inconsistent. |
| 922 | */ |
| 923 | |
| 924 | ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); |
| 925 | /* |
| 926 | Skips invalid compressed data until a possible full flush point (see above |
| 927 | for the description of deflate with Z_FULL_FLUSH) can be found, or until all |
| 928 | available input is skipped. No output is provided. |
| 929 | |
| @@ -938,12 +940,12 @@ | |
| 938 | total_in which indicates where valid compressed data was found. In the |
| 939 | error case, the application may repeatedly call inflateSync, providing more |
| 940 | input each time, until success or end of the input data. |
| 941 | */ |
| 942 | |
| 943 | ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, |
| 944 | z_streamp source)); |
| 945 | /* |
| 946 | Sets the destination stream as a complete copy of the source stream. |
| 947 | |
| 948 | This function can be useful when randomly accessing a large stream. The |
| 949 | first pass through the stream can periodically record the inflate state, |
| @@ -954,22 +956,23 @@ | |
| 954 | enough memory, Z_STREAM_ERROR if the source stream state was inconsistent |
| 955 | (such as zalloc being Z_NULL). msg is left unchanged in both source and |
| 956 | destination. |
| 957 | */ |
| 958 | |
| 959 | ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); |
| 960 | /* |
| 961 | This function is equivalent to inflateEnd followed by inflateInit, |
| 962 | but does not free and reallocate the internal decompression state. The |
| 963 | stream will keep attributes that may have been set by inflateInit2. |
| 964 | |
| 965 | inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 966 | stream state was inconsistent (such as zalloc or state being Z_NULL). |
| 967 | */ |
| 968 | |
| 969 | ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, |
| 970 | int windowBits)); |
| 971 | /* |
| 972 | This function is the same as inflateReset, but it also permits changing |
| 973 | the wrap and window size requests. The windowBits parameter is interpreted |
| 974 | the same as it is for inflateInit2. If the window size is changed, then the |
| 975 | memory allocated for the window is freed, and the window will be reallocated |
| @@ -978,13 +981,13 @@ | |
| 978 | inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 979 | stream state was inconsistent (such as zalloc or state being Z_NULL), or if |
| 980 | the windowBits parameter is invalid. |
| 981 | */ |
| 982 | |
| 983 | ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, |
| 984 | int bits, |
| 985 | int value)); |
| 986 | /* |
| 987 | This function inserts bits in the inflate input stream. The intent is |
| 988 | that this function is used to start inflating at a bit position in the |
| 989 | middle of a byte. The provided bits will be used before any bytes are used |
| 990 | from next_in. This function should only be used with raw inflate, and |
| @@ -999,11 +1002,11 @@ | |
| 999 | |
| 1000 | inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 1001 | stream state was inconsistent. |
| 1002 | */ |
| 1003 | |
| 1004 | ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); |
| 1005 | /* |
| 1006 | This function returns two values, one in the lower 16 bits of the return |
| 1007 | value, and the other in the remaining upper bits, obtained by shifting the |
| 1008 | return value down 16 bits. If the upper value is -1 and the lower value is |
| 1009 | zero, then inflate() is currently decoding information outside of a block. |
| @@ -1027,12 +1030,12 @@ | |
| 1027 | |
| 1028 | inflateMark returns the value noted above, or -65536 if the provided |
| 1029 | source stream state was inconsistent. |
| 1030 | */ |
| 1031 | |
| 1032 | ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, |
| 1033 | gz_headerp head)); |
| 1034 | /* |
| 1035 | inflateGetHeader() requests that gzip header information be stored in the |
| 1036 | provided gz_header structure. inflateGetHeader() may be called after |
| 1037 | inflateInit2() or inflateReset(), and before the first call of inflate(). |
| 1038 | As inflate() processes the gzip stream, head->done is zero until the header |
| @@ -1068,12 +1071,12 @@ | |
| 1068 | inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 1069 | stream state was inconsistent. |
| 1070 | */ |
| 1071 | |
| 1072 | /* |
| 1073 | ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, |
| 1074 | unsigned char FAR *window)); |
| 1075 | |
| 1076 | Initialize the internal stream state for decompression using inflateBack() |
| 1077 | calls. The fields zalloc, zfree and opaque in strm must be initialized |
| 1078 | before the call. If zalloc and zfree are Z_NULL, then the default library- |
| 1079 | derived memory allocation routines are used. windowBits is the base two |
| @@ -1089,17 +1092,17 @@ | |
| 1089 | the parameters are invalid, Z_MEM_ERROR if the internal state could not be |
| 1090 | allocated, or Z_VERSION_ERROR if the version of the library does not match |
| 1091 | the version of the header file. |
| 1092 | */ |
| 1093 | |
| 1094 | typedef unsigned (*in_func) OF((void FAR *, |
| 1095 | z_const unsigned char FAR * FAR *)); |
| 1096 | typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); |
| 1097 | |
| 1098 | ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, |
| 1099 | in_func in, void FAR *in_desc, |
| 1100 | out_func out, void FAR *out_desc)); |
| 1101 | /* |
| 1102 | inflateBack() does a raw inflate with a single call using a call-back |
| 1103 | interface for input and output. This is potentially more efficient than |
| 1104 | inflate() for file i/o applications, in that it avoids copying between the |
| 1105 | output and the sliding window by simply making the window itself the output |
| @@ -1163,19 +1166,19 @@ | |
| 1163 | non-zero. (in() will always be called before out(), so strm->next_in is |
| 1164 | assured to be defined if out() returns non-zero.) Note that inflateBack() |
| 1165 | cannot return Z_OK. |
| 1166 | */ |
| 1167 | |
| 1168 | ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); |
| 1169 | /* |
| 1170 | All memory allocated by inflateBackInit() is freed. |
| 1171 | |
| 1172 | inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream |
| 1173 | state was inconsistent. |
| 1174 | */ |
| 1175 | |
| 1176 | ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); |
| 1177 | /* Return flags indicating compile-time options. |
| 1178 | |
| 1179 | Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: |
| 1180 | 1.0: size of uInt |
| 1181 | 3.2: size of uLong |
| @@ -1224,12 +1227,12 @@ | |
| 1224 | are assumed (compression level and memory usage, standard memory allocation |
| 1225 | functions). The source code of these utility functions can be modified if |
| 1226 | you need special options. |
| 1227 | */ |
| 1228 | |
| 1229 | ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, |
| 1230 | const Bytef *source, uLong sourceLen)); |
| 1231 | /* |
| 1232 | Compresses the source buffer into the destination buffer. sourceLen is |
| 1233 | the byte length of the source buffer. Upon entry, destLen is the total size |
| 1234 | of the destination buffer, which must be at least the value returned by |
| 1235 | compressBound(sourceLen). Upon exit, destLen is the actual size of the |
| @@ -1239,13 +1242,13 @@ | |
| 1239 | compress returns Z_OK if success, Z_MEM_ERROR if there was not |
| 1240 | enough memory, Z_BUF_ERROR if there was not enough room in the output |
| 1241 | buffer. |
| 1242 | */ |
| 1243 | |
| 1244 | ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, |
| 1245 | const Bytef *source, uLong sourceLen, |
| 1246 | int level)); |
| 1247 | /* |
| 1248 | Compresses the source buffer into the destination buffer. The level |
| 1249 | parameter has the same meaning as in deflateInit. sourceLen is the byte |
| 1250 | length of the source buffer. Upon entry, destLen is the total size of the |
| 1251 | destination buffer, which must be at least the value returned by |
| @@ -1255,19 +1258,19 @@ | |
| 1255 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 1256 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, |
| 1257 | Z_STREAM_ERROR if the level parameter is invalid. |
| 1258 | */ |
| 1259 | |
| 1260 | ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); |
| 1261 | /* |
| 1262 | compressBound() returns an upper bound on the compressed size after |
| 1263 | compress() or compress2() on sourceLen bytes. It would be used before a |
| 1264 | compress() or compress2() call to allocate the destination buffer. |
| 1265 | */ |
| 1266 | |
| 1267 | ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, |
| 1268 | const Bytef *source, uLong sourceLen)); |
| 1269 | /* |
| 1270 | Decompresses the source buffer into the destination buffer. sourceLen is |
| 1271 | the byte length of the source buffer. Upon entry, destLen is the total size |
| 1272 | of the destination buffer, which must be large enough to hold the entire |
| 1273 | uncompressed data. (The size of the uncompressed data must have been saved |
| @@ -1280,12 +1283,12 @@ | |
| 1280 | buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In |
| 1281 | the case where there is not enough room, uncompress() will fill the output |
| 1282 | buffer with the uncompressed data up to that point. |
| 1283 | */ |
| 1284 | |
| 1285 | ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, |
| 1286 | const Bytef *source, uLong *sourceLen)); |
| 1287 | /* |
| 1288 | Same as uncompress, except that sourceLen is a pointer, where the |
| 1289 | length of the source is *sourceLen. On return, *sourceLen is the number of |
| 1290 | source bytes consumed. |
| 1291 | */ |
| @@ -1300,11 +1303,11 @@ | |
| 1300 | */ |
| 1301 | |
| 1302 | typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ |
| 1303 | |
| 1304 | /* |
| 1305 | ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); |
| 1306 | |
| 1307 | Open the gzip (.gz) file at path for reading and decompressing, or |
| 1308 | compressing and writing. The mode parameter is as in fopen ("rb" or "wb") |
| 1309 | but can also include a compression level ("wb9") or a strategy: 'f' for |
| 1310 | filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", |
| @@ -1337,11 +1340,11 @@ | |
| 1337 | specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). |
| 1338 | errno can be checked to determine if the reason gzopen failed was that the |
| 1339 | file could not be opened. |
| 1340 | */ |
| 1341 | |
| 1342 | ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); |
| 1343 | /* |
| 1344 | Associate a gzFile with the file descriptor fd. File descriptors are |
| 1345 | obtained from calls like open, dup, creat, pipe or fileno (if the file has |
| 1346 | been previously opened with fopen). The mode parameter is as in gzopen. |
| 1347 | |
| @@ -1360,11 +1363,11 @@ | |
| 1360 | provided, or '+' was provided), or if fd is -1. The file descriptor is not |
| 1361 | used until the next gz* read, write, seek, or close operation, so gzdopen |
| 1362 | will not detect if fd is invalid (unless fd is -1). |
| 1363 | */ |
| 1364 | |
| 1365 | ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); |
| 1366 | /* |
| 1367 | Set the internal buffer size used by this library's functions for file to |
| 1368 | size. The default buffer size is 8192 bytes. This function must be called |
| 1369 | after gzopen() or gzdopen(), and before any other calls that read or write |
| 1370 | the file. The buffer memory allocation is always deferred to the first read |
| @@ -1376,11 +1379,11 @@ | |
| 1376 | |
| 1377 | gzbuffer() returns 0 on success, or -1 on failure, such as being called |
| 1378 | too late. |
| 1379 | */ |
| 1380 | |
| 1381 | ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); |
| 1382 | /* |
| 1383 | Dynamically update the compression level and strategy for file. See the |
| 1384 | description of deflateInit2 for the meaning of these parameters. Previously |
| 1385 | provided data is flushed before applying the parameter changes. |
| 1386 | |
| @@ -1387,11 +1390,11 @@ | |
| 1387 | gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not |
| 1388 | opened for writing, Z_ERRNO if there is an error writing the flushed data, |
| 1389 | or Z_MEM_ERROR if there is a memory allocation error. |
| 1390 | */ |
| 1391 | |
| 1392 | ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); |
| 1393 | /* |
| 1394 | Read and decompress up to len uncompressed bytes from file into buf. If |
| 1395 | the input file is not in gzip format, gzread copies the given number of |
| 1396 | bytes into the buffer directly from the file. |
| 1397 | |
| @@ -1417,12 +1420,12 @@ | |
| 1417 | len for end of file, or -1 for error. If len is too large to fit in an int, |
| 1418 | then nothing is read, -1 is returned, and the error state is set to |
| 1419 | Z_STREAM_ERROR. |
| 1420 | */ |
| 1421 | |
| 1422 | ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, |
| 1423 | gzFile file)); |
| 1424 | /* |
| 1425 | Read and decompress up to nitems items of size size from file into buf, |
| 1426 | otherwise operating as gzread() does. This duplicates the interface of |
| 1427 | stdio's fread(), with size_t request and return types. If the library |
| 1428 | defines size_t, then z_size_t is identical to size_t. If not, then z_size_t |
| @@ -1443,18 +1446,18 @@ | |
| 1443 | is the same as the behavior of fread() implementations in common libraries, |
| 1444 | but it prevents the direct use of gzfread() to read a concurrently written |
| 1445 | file, resetting and retrying on end-of-file, when size is not 1. |
| 1446 | */ |
| 1447 | |
| 1448 | ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len)); |
| 1449 | /* |
| 1450 | Compress and write the len uncompressed bytes at buf to file. gzwrite |
| 1451 | returns the number of uncompressed bytes written or 0 in case of error. |
| 1452 | */ |
| 1453 | |
| 1454 | ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, |
| 1455 | z_size_t nitems, gzFile file)); |
| 1456 | /* |
| 1457 | Compress and write nitems items of size size from buf to file, duplicating |
| 1458 | the interface of stdio's fwrite(), with size_t request and return types. If |
| 1459 | the library defines size_t, then z_size_t is identical to size_t. If not, |
| 1460 | then z_size_t is an unsigned integer type that can contain a pointer. |
| @@ -1463,11 +1466,11 @@ | |
| 1463 | if there was an error. If the multiplication of size and nitems overflows, |
| 1464 | i.e. the product does not fit in a z_size_t, then nothing is written, zero |
| 1465 | is returned, and the error state is set to Z_STREAM_ERROR. |
| 1466 | */ |
| 1467 | |
| 1468 | ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); |
| 1469 | /* |
| 1470 | Convert, format, compress, and write the arguments (...) to file under |
| 1471 | control of the string format, as in fprintf. gzprintf returns the number of |
| 1472 | uncompressed bytes actually written, or a negative zlib error code in case |
| 1473 | of error. The number of uncompressed bytes written is limited to 8191, or |
| @@ -1478,19 +1481,19 @@ | |
| 1478 | zlib was compiled with the insecure functions sprintf() or vsprintf(), |
| 1479 | because the secure snprintf() or vsnprintf() functions were not available. |
| 1480 | This can be determined using zlibCompileFlags(). |
| 1481 | */ |
| 1482 | |
| 1483 | ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); |
| 1484 | /* |
| 1485 | Compress and write the given null-terminated string s to file, excluding |
| 1486 | the terminating null character. |
| 1487 | |
| 1488 | gzputs returns the number of characters written, or -1 in case of error. |
| 1489 | */ |
| 1490 | |
| 1491 | ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); |
| 1492 | /* |
| 1493 | Read and decompress bytes from file into buf, until len-1 characters are |
| 1494 | read, or until a newline character is read and transferred to buf, or an |
| 1495 | end-of-file condition is encountered. If any characters are read or if len |
| 1496 | is one, the string is terminated with a null character. If no characters |
| @@ -1500,26 +1503,26 @@ | |
| 1500 | gzgets returns buf which is a null-terminated string, or it returns NULL |
| 1501 | for end-of-file or in case of error. If there was an error, the contents at |
| 1502 | buf are indeterminate. |
| 1503 | */ |
| 1504 | |
| 1505 | ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); |
| 1506 | /* |
| 1507 | Compress and write c, converted to an unsigned char, into file. gzputc |
| 1508 | returns the value that was written, or -1 in case of error. |
| 1509 | */ |
| 1510 | |
| 1511 | ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); |
| 1512 | /* |
| 1513 | Read and decompress one byte from file. gzgetc returns this byte or -1 |
| 1514 | in case of end of file or error. This is implemented as a macro for speed. |
| 1515 | As such, it does not do all of the checking the other functions do. I.e. |
| 1516 | it does not check to see if file is NULL, nor whether the structure file |
| 1517 | points to has been clobbered or not. |
| 1518 | */ |
| 1519 | |
| 1520 | ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); |
| 1521 | /* |
| 1522 | Push c back onto the stream for file to be read as the first character on |
| 1523 | the next read. At least one character of push-back is always allowed. |
| 1524 | gzungetc() returns the character pushed, or -1 on failure. gzungetc() will |
| 1525 | fail if c is -1, and may fail if a character has been pushed but not read |
| @@ -1527,11 +1530,11 @@ | |
| 1527 | output buffer size of pushed characters is allowed. (See gzbuffer above.) |
| 1528 | The pushed character will be discarded if the stream is repositioned with |
| 1529 | gzseek() or gzrewind(). |
| 1530 | */ |
| 1531 | |
| 1532 | ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); |
| 1533 | /* |
| 1534 | Flush all pending output to file. The parameter flush is as in the |
| 1535 | deflate() function. The return value is the zlib error number (see function |
| 1536 | gzerror below). gzflush is only permitted when writing. |
| 1537 | |
| @@ -1543,12 +1546,12 @@ | |
| 1543 | gzflush should be called only when strictly necessary because it will |
| 1544 | degrade compression if called too often. |
| 1545 | */ |
| 1546 | |
| 1547 | /* |
| 1548 | ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, |
| 1549 | z_off_t offset, int whence)); |
| 1550 | |
| 1551 | Set the starting position to offset relative to whence for the next gzread |
| 1552 | or gzwrite on file. The offset represents a number of bytes in the |
| 1553 | uncompressed data stream. The whence parameter is defined as in lseek(2); |
| 1554 | the value SEEK_END is not supported. |
| @@ -1562,19 +1565,19 @@ | |
| 1562 | the beginning of the uncompressed stream, or -1 in case of error, in |
| 1563 | particular if the file is opened for writing and the new starting position |
| 1564 | would be before the current position. |
| 1565 | */ |
| 1566 | |
| 1567 | ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); |
| 1568 | /* |
| 1569 | Rewind file. This function is supported only for reading. |
| 1570 | |
| 1571 | gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET). |
| 1572 | */ |
| 1573 | |
| 1574 | /* |
| 1575 | ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); |
| 1576 | |
| 1577 | Return the starting position for the next gzread or gzwrite on file. |
| 1578 | This position represents a number of bytes in the uncompressed data stream, |
| 1579 | and is zero when starting, even if appending or reading a gzip stream from |
| 1580 | the middle of a file using gzdopen(). |
| @@ -1581,20 +1584,20 @@ | |
| 1581 | |
| 1582 | gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) |
| 1583 | */ |
| 1584 | |
| 1585 | /* |
| 1586 | ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); |
| 1587 | |
| 1588 | Return the current compressed (actual) read or write offset of file. This |
| 1589 | offset includes the count of bytes that precede the gzip stream, for example |
| 1590 | when appending or when using gzdopen() for reading. When reading, the |
| 1591 | offset does not include as yet unused buffered input. This information can |
| 1592 | be used for a progress indicator. On error, gzoffset() returns -1. |
| 1593 | */ |
| 1594 | |
| 1595 | ZEXTERN int ZEXPORT gzeof OF((gzFile file)); |
| 1596 | /* |
| 1597 | Return true (1) if the end-of-file indicator for file has been set while |
| 1598 | reading, false (0) otherwise. Note that the end-of-file indicator is set |
| 1599 | only if the read tried to go past the end of the input, but came up short. |
| 1600 | Therefore, just like feof(), gzeof() may return false even if there is no |
| @@ -1605,11 +1608,11 @@ | |
| 1605 | If gzeof() returns true, then the read functions will return no more data, |
| 1606 | unless the end-of-file indicator is reset by gzclearerr() and the input file |
| 1607 | has grown since the previous end of file was detected. |
| 1608 | */ |
| 1609 | |
| 1610 | ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); |
| 1611 | /* |
| 1612 | Return true (1) if file is being copied directly while reading, or false |
| 1613 | (0) if file is a gzip stream being decompressed. |
| 1614 | |
| 1615 | If the input file is empty, gzdirect() will return true, since the input |
| @@ -1626,11 +1629,11 @@ | |
| 1626 | explicitly requested, so the application already knows the answer. When |
| 1627 | linking statically, using gzdirect() will include all of the zlib code for |
| 1628 | gzip file reading and decompression, which may not be desired.) |
| 1629 | */ |
| 1630 | |
| 1631 | ZEXTERN int ZEXPORT gzclose OF((gzFile file)); |
| 1632 | /* |
| 1633 | Flush all pending output for file, if necessary, close file and |
| 1634 | deallocate the (de)compression state. Note that once file is closed, you |
| 1635 | cannot call gzerror with file, since its structures have been deallocated. |
| 1636 | gzclose must not be called more than once on the same file, just as free |
| @@ -1639,12 +1642,12 @@ | |
| 1639 | gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a |
| 1640 | file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the |
| 1641 | last read ended in the middle of a gzip stream, or Z_OK on success. |
| 1642 | */ |
| 1643 | |
| 1644 | ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); |
| 1645 | ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); |
| 1646 | /* |
| 1647 | Same as gzclose(), but gzclose_r() is only for use when reading, and |
| 1648 | gzclose_w() is only for use when writing or appending. The advantage to |
| 1649 | using these instead of gzclose() is that they avoid linking in zlib |
| 1650 | compression or decompression code that is not used when only reading or only |
| @@ -1651,11 +1654,11 @@ | |
| 1651 | writing respectively. If gzclose() is used, then both compression and |
| 1652 | decompression code will be included the application when linking to a static |
| 1653 | zlib library. |
| 1654 | */ |
| 1655 | |
| 1656 | ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); |
| 1657 | /* |
| 1658 | Return the error message for the last error which occurred on file. |
| 1659 | errnum is set to zlib error number. If an error occurred in the file system |
| 1660 | and not in the compression library, errnum is set to Z_ERRNO and the |
| 1661 | application may consult errno to get the exact error code. |
| @@ -1667,11 +1670,11 @@ | |
| 1667 | |
| 1668 | gzerror() should be used to distinguish errors from end-of-file for those |
| 1669 | functions above that do not distinguish those cases in their return values. |
| 1670 | */ |
| 1671 | |
| 1672 | ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); |
| 1673 | /* |
| 1674 | Clear the error and end-of-file flags for file. This is analogous to the |
| 1675 | clearerr() function in stdio. This is useful for continuing to read a gzip |
| 1676 | file that is being written concurrently. |
| 1677 | */ |
| @@ -1684,11 +1687,11 @@ | |
| 1684 | These functions are not related to compression but are exported |
| 1685 | anyway because they might be useful in applications using the compression |
| 1686 | library. |
| 1687 | */ |
| 1688 | |
| 1689 | ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); |
| 1690 | /* |
| 1691 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and |
| 1692 | return the updated checksum. An Adler-32 value is in the range of a 32-bit |
| 1693 | unsigned integer. If buf is Z_NULL, this function returns the required |
| 1694 | initial value for the checksum. |
| @@ -1704,29 +1707,29 @@ | |
| 1704 | adler = adler32(adler, buffer, length); |
| 1705 | } |
| 1706 | if (adler != original_adler) error(); |
| 1707 | */ |
| 1708 | |
| 1709 | ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, |
| 1710 | z_size_t len)); |
| 1711 | /* |
| 1712 | Same as adler32(), but with a size_t length. |
| 1713 | */ |
| 1714 | |
| 1715 | /* |
| 1716 | ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, |
| 1717 | z_off_t len2)); |
| 1718 | |
| 1719 | Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 |
| 1720 | and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for |
| 1721 | each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of |
| 1722 | seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note |
| 1723 | that the z_off_t type (like off_t) is a signed integer. If len2 is |
| 1724 | negative, the result has no meaning or utility. |
| 1725 | */ |
| 1726 | |
| 1727 | ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); |
| 1728 | /* |
| 1729 | Update a running CRC-32 with the bytes buf[0..len-1] and return the |
| 1730 | updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. |
| 1731 | If buf is Z_NULL, this function returns the required initial value for the |
| 1732 | crc. Pre- and post-conditioning (one's complement) is performed within this |
| @@ -1740,34 +1743,34 @@ | |
| 1740 | crc = crc32(crc, buffer, length); |
| 1741 | } |
| 1742 | if (crc != original_crc) error(); |
| 1743 | */ |
| 1744 | |
| 1745 | ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf, |
| 1746 | z_size_t len)); |
| 1747 | /* |
| 1748 | Same as crc32(), but with a size_t length. |
| 1749 | */ |
| 1750 | |
| 1751 | /* |
| 1752 | ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); |
| 1753 | |
| 1754 | Combine two CRC-32 check values into one. For two sequences of bytes, |
| 1755 | seq1 and seq2 with lengths len1 and len2, CRC-32 check values were |
| 1756 | calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 |
| 1757 | check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and |
| 1758 | len2. |
| 1759 | */ |
| 1760 | |
| 1761 | /* |
| 1762 | ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2)); |
| 1763 | |
| 1764 | Return the operator corresponding to length len2, to be used with |
| 1765 | crc32_combine_op(). |
| 1766 | */ |
| 1767 | |
| 1768 | ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op)); |
| 1769 | /* |
| 1770 | Give the same result as crc32_combine(), using op in place of len2. op is |
| 1771 | is generated from len2 by crc32_combine_gen(). This will be faster than |
| 1772 | crc32_combine() if the generated op is used more than once. |
| 1773 | */ |
| @@ -1776,24 +1779,24 @@ | |
| 1776 | /* various hacks, don't look :) */ |
| 1777 | |
| 1778 | /* deflateInit and inflateInit are macros to allow checking the zlib version |
| 1779 | * and the compiler's view of z_stream: |
| 1780 | */ |
| 1781 | ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, |
| 1782 | const char *version, int stream_size)); |
| 1783 | ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, |
| 1784 | const char *version, int stream_size)); |
| 1785 | ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, |
| 1786 | int windowBits, int memLevel, |
| 1787 | int strategy, const char *version, |
| 1788 | int stream_size)); |
| 1789 | ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, |
| 1790 | const char *version, int stream_size)); |
| 1791 | ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, |
| 1792 | unsigned char FAR *window, |
| 1793 | const char *version, |
| 1794 | int stream_size)); |
| 1795 | #ifdef Z_PREFIX_SET |
| 1796 | # define z_deflateInit(strm, level) \ |
| 1797 | deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) |
| 1798 | # define z_inflateInit(strm) \ |
| 1799 | inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) |
| @@ -1834,11 +1837,11 @@ | |
| 1834 | struct gzFile_s { |
| 1835 | unsigned have; |
| 1836 | unsigned char *next; |
| 1837 | z_off64_t pos; |
| 1838 | }; |
| 1839 | ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ |
| 1840 | #ifdef Z_PREFIX_SET |
| 1841 | # undef z_gzgetc |
| 1842 | # define z_gzgetc(g) \ |
| 1843 | ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) |
| 1844 | #else |
| @@ -1851,17 +1854,17 @@ | |
| 1851 | * both are true, the application gets the *64 functions, and the regular |
| 1852 | * functions are changed to 64 bits) -- in case these are set on systems |
| 1853 | * without large file support, _LFS64_LARGEFILE must also be true |
| 1854 | */ |
| 1855 | #ifdef Z_LARGE64 |
| 1856 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); |
| 1857 | ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); |
| 1858 | ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); |
| 1859 | ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); |
| 1860 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); |
| 1861 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); |
| 1862 | ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t)); |
| 1863 | #endif |
| 1864 | |
| 1865 | #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) |
| 1866 | # ifdef Z_PREFIX_SET |
| 1867 | # define z_gzopen z_gzopen64 |
| @@ -1879,57 +1882,57 @@ | |
| 1879 | # define adler32_combine adler32_combine64 |
| 1880 | # define crc32_combine crc32_combine64 |
| 1881 | # define crc32_combine_gen crc32_combine_gen64 |
| 1882 | # endif |
| 1883 | # ifndef Z_LARGE64 |
| 1884 | ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); |
| 1885 | ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); |
| 1886 | ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); |
| 1887 | ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); |
| 1888 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); |
| 1889 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); |
| 1890 | ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); |
| 1891 | # endif |
| 1892 | #else |
| 1893 | ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); |
| 1894 | ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); |
| 1895 | ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); |
| 1896 | ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); |
| 1897 | ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); |
| 1898 | ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); |
| 1899 | ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); |
| 1900 | #endif |
| 1901 | |
| 1902 | #else /* Z_SOLO */ |
| 1903 | |
| 1904 | ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); |
| 1905 | ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); |
| 1906 | ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); |
| 1907 | |
| 1908 | #endif /* !Z_SOLO */ |
| 1909 | |
| 1910 | /* undocumented functions */ |
| 1911 | ZEXTERN const char * ZEXPORT zError OF((int)); |
| 1912 | ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); |
| 1913 | ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); |
| 1914 | ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); |
| 1915 | ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); |
| 1916 | ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF((z_streamp)); |
| 1917 | ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); |
| 1918 | ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); |
| 1919 | #if defined(_WIN32) && !defined(Z_SOLO) |
| 1920 | ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, |
| 1921 | const char *mode)); |
| 1922 | #endif |
| 1923 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) |
| 1924 | # ifndef Z_SOLO |
| 1925 | ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, |
| 1926 | const char *format, |
| 1927 | va_list va)); |
| 1928 | # endif |
| 1929 | #endif |
| 1930 | |
| 1931 | #ifdef __cplusplus |
| 1932 | } |
| 1933 | #endif |
| 1934 | |
| 1935 | #endif /* ZLIB_H */ |
| 1936 | |
| 1937 | ELETED compat/zlib/zlib2ansi |
| --- compat/zlib/zlib.h | |
| +++ compat/zlib/zlib.h | |
| @@ -1,9 +1,9 @@ | |
| 1 | /* zlib.h -- interface of the 'zlib' general purpose compression library |
| 2 | version 1.3, August 18th, 2023 |
| 3 | |
| 4 | Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler |
| 5 | |
| 6 | This software is provided 'as-is', without any express or implied |
| 7 | warranty. In no event will the authors be held liable for any damages |
| 8 | arising from the use of this software. |
| 9 | |
| @@ -35,15 +35,15 @@ | |
| 35 | |
| 36 | #ifdef __cplusplus |
| 37 | extern "C" { |
| 38 | #endif |
| 39 | |
| 40 | #define ZLIB_VERSION "1.3" |
| 41 | #define ZLIB_VERNUM 0x1300 |
| 42 | #define ZLIB_VER_MAJOR 1 |
| 43 | #define ZLIB_VER_MINOR 3 |
| 44 | #define ZLIB_VER_REVISION 0 |
| 45 | #define ZLIB_VER_SUBREVISION 0 |
| 46 | |
| 47 | /* |
| 48 | The 'zlib' compression library provides in-memory compression and |
| 49 | decompression functions, including integrity checks of the uncompressed data. |
| @@ -76,12 +76,12 @@ | |
| 76 | The library does not install any signal handler. The decoder checks |
| 77 | the consistency of the compressed data, so the library should never crash |
| 78 | even in the case of corrupted input. |
| 79 | */ |
| 80 | |
| 81 | typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size); |
| 82 | typedef void (*free_func)(voidpf opaque, voidpf address); |
| 83 | |
| 84 | struct internal_state; |
| 85 | |
| 86 | typedef struct z_stream_s { |
| 87 | z_const Bytef *next_in; /* next input byte */ |
| @@ -215,24 +215,24 @@ | |
| 215 | /* for compatibility with versions < 1.0.2 */ |
| 216 | |
| 217 | |
| 218 | /* basic functions */ |
| 219 | |
| 220 | ZEXTERN const char * ZEXPORT zlibVersion(void); |
| 221 | /* The application can compare zlibVersion and ZLIB_VERSION for consistency. |
| 222 | If the first character differs, the library code actually used is not |
| 223 | compatible with the zlib.h header file used by the application. This check |
| 224 | is automatically made by deflateInit and inflateInit. |
| 225 | */ |
| 226 | |
| 227 | /* |
| 228 | ZEXTERN int ZEXPORT deflateInit(z_streamp strm, int level); |
| 229 | |
| 230 | Initializes the internal stream state for compression. The fields |
| 231 | zalloc, zfree and opaque must be initialized before by the caller. If |
| 232 | zalloc and zfree are set to Z_NULL, deflateInit updates them to use default |
| 233 | allocation functions. total_in, total_out, adler, and msg are initialized. |
| 234 | |
| 235 | The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: |
| 236 | 1 gives best speed, 9 gives best compression, 0 gives no compression at all |
| 237 | (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION |
| 238 | requests a default compromise between speed and compression (currently |
| @@ -245,11 +245,11 @@ | |
| 245 | if there is no error message. deflateInit does not perform any compression: |
| 246 | this will be done by deflate(). |
| 247 | */ |
| 248 | |
| 249 | |
| 250 | ZEXTERN int ZEXPORT deflate(z_streamp strm, int flush); |
| 251 | /* |
| 252 | deflate compresses as much data as possible, and stops when the input |
| 253 | buffer becomes empty or the output buffer becomes full. It may introduce |
| 254 | some output latency (reading input without producing any output) except when |
| 255 | forced to flush. |
| @@ -318,12 +318,12 @@ | |
| 318 | |
| 319 | If deflate returns with avail_out == 0, this function must be called again |
| 320 | with the same value of the flush parameter and more output space (updated |
| 321 | avail_out), until the flush is complete (deflate returns with non-zero |
| 322 | avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that |
| 323 | avail_out is greater than six when the flush marker begins, in order to avoid |
| 324 | repeated flush markers upon calling deflate() again when avail_out == 0. |
| 325 | |
| 326 | If the parameter flush is set to Z_FINISH, pending input is processed, |
| 327 | pending output is flushed and deflate returns with Z_STREAM_END if there was |
| 328 | enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this |
| 329 | function must be called again with Z_FINISH and more output space (updated |
| @@ -358,11 +358,11 @@ | |
| 358 | deflate() can be called again with more input and more output space to |
| 359 | continue compressing. |
| 360 | */ |
| 361 | |
| 362 | |
| 363 | ZEXTERN int ZEXPORT deflateEnd(z_streamp strm); |
| 364 | /* |
| 365 | All dynamically allocated data structures for this stream are freed. |
| 366 | This function discards any unprocessed input and does not flush any pending |
| 367 | output. |
| 368 | |
| @@ -373,19 +373,20 @@ | |
| 373 | deallocated). |
| 374 | */ |
| 375 | |
| 376 | |
| 377 | /* |
| 378 | ZEXTERN int ZEXPORT inflateInit(z_streamp strm); |
| 379 | |
| 380 | Initializes the internal stream state for decompression. The fields |
| 381 | next_in, avail_in, zalloc, zfree and opaque must be initialized before by |
| 382 | the caller. In the current version of inflate, the provided input is not |
| 383 | read or consumed. The allocation of a sliding window will be deferred to |
| 384 | the first call of inflate (if the decompression does not complete on the |
| 385 | first call). If zalloc and zfree are set to Z_NULL, inflateInit updates |
| 386 | them to use default allocation functions. total_in, total_out, adler, and |
| 387 | msg are initialized. |
| 388 | |
| 389 | inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 390 | memory, Z_VERSION_ERROR if the zlib library version is incompatible with the |
| 391 | version assumed by the caller, or Z_STREAM_ERROR if the parameters are |
| 392 | invalid, such as a null pointer to the structure. msg is set to null if |
| @@ -395,11 +396,11 @@ | |
| 396 | implementation of inflateInit() does not process any header information -- |
| 397 | that is deferred until inflate() is called. |
| 398 | */ |
| 399 | |
| 400 | |
| 401 | ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush); |
| 402 | /* |
| 403 | inflate decompresses as much data as possible, and stops when the input |
| 404 | buffer becomes empty or the output buffer becomes full. It may introduce |
| 405 | some output latency (reading input without producing any output) except when |
| 406 | forced to flush. |
| @@ -515,11 +516,11 @@ | |
| 516 | then call inflateSync() to look for a good compression block if a partial |
| 517 | recovery of the data is to be attempted. |
| 518 | */ |
| 519 | |
| 520 | |
| 521 | ZEXTERN int ZEXPORT inflateEnd(z_streamp strm); |
| 522 | /* |
| 523 | All dynamically allocated data structures for this stream are freed. |
| 524 | This function discards any unprocessed input and does not flush any pending |
| 525 | output. |
| 526 | |
| @@ -533,16 +534,16 @@ | |
| 534 | /* |
| 535 | The following functions are needed only in some special applications. |
| 536 | */ |
| 537 | |
| 538 | /* |
| 539 | ZEXTERN int ZEXPORT deflateInit2(z_streamp strm, |
| 540 | int level, |
| 541 | int method, |
| 542 | int windowBits, |
| 543 | int memLevel, |
| 544 | int strategy); |
| 545 | |
| 546 | This is another version of deflateInit with more compression options. The |
| 547 | fields zalloc, zfree and opaque must be initialized before by the caller. |
| 548 | |
| 549 | The method parameter is the compression method. It must be Z_DEFLATED in |
| @@ -605,13 +606,13 @@ | |
| 606 | incompatible with the version assumed by the caller (ZLIB_VERSION). msg is |
| 607 | set to null if there is no error message. deflateInit2 does not perform any |
| 608 | compression: this will be done by deflate(). |
| 609 | */ |
| 610 | |
| 611 | ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm, |
| 612 | const Bytef *dictionary, |
| 613 | uInt dictLength); |
| 614 | /* |
| 615 | Initializes the compression dictionary from the given byte sequence |
| 616 | without producing any compressed output. When using the zlib format, this |
| 617 | function must be called immediately after deflateInit, deflateInit2 or |
| 618 | deflateReset, and before any call of deflate. When doing raw deflate, this |
| @@ -649,13 +650,13 @@ | |
| 650 | inconsistent (for example if deflate has already been called for this stream |
| 651 | or if not at a block boundary for raw deflate). deflateSetDictionary does |
| 652 | not perform any compression: this will be done by deflate(). |
| 653 | */ |
| 654 | |
| 655 | ZEXTERN int ZEXPORT deflateGetDictionary(z_streamp strm, |
| 656 | Bytef *dictionary, |
| 657 | uInt *dictLength); |
| 658 | /* |
| 659 | Returns the sliding dictionary being maintained by deflate. dictLength is |
| 660 | set to the number of bytes in the dictionary, and that many bytes are copied |
| 661 | to dictionary. dictionary must have enough space, where 32768 bytes is |
| 662 | always enough. If deflateGetDictionary() is called with dictionary equal to |
| @@ -671,12 +672,12 @@ | |
| 672 | |
| 673 | deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the |
| 674 | stream state is inconsistent. |
| 675 | */ |
| 676 | |
| 677 | ZEXTERN int ZEXPORT deflateCopy(z_streamp dest, |
| 678 | z_streamp source); |
| 679 | /* |
| 680 | Sets the destination stream as a complete copy of the source stream. |
| 681 | |
| 682 | This function can be useful when several compression strategies will be |
| 683 | tried, for example when there are several ways of pre-processing the input |
| @@ -689,24 +690,24 @@ | |
| 690 | enough memory, Z_STREAM_ERROR if the source stream state was inconsistent |
| 691 | (such as zalloc being Z_NULL). msg is left unchanged in both source and |
| 692 | destination. |
| 693 | */ |
| 694 | |
| 695 | ZEXTERN int ZEXPORT deflateReset(z_streamp strm); |
| 696 | /* |
| 697 | This function is equivalent to deflateEnd followed by deflateInit, but |
| 698 | does not free and reallocate the internal compression state. The stream |
| 699 | will leave the compression level and any other attributes that may have been |
| 700 | set unchanged. total_in, total_out, adler, and msg are initialized. |
| 701 | |
| 702 | deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 703 | stream state was inconsistent (such as zalloc or state being Z_NULL). |
| 704 | */ |
| 705 | |
| 706 | ZEXTERN int ZEXPORT deflateParams(z_streamp strm, |
| 707 | int level, |
| 708 | int strategy); |
| 709 | /* |
| 710 | Dynamically update the compression level and compression strategy. The |
| 711 | interpretation of level and strategy is as in deflateInit2(). This can be |
| 712 | used to switch between compression and straight copy of the input data, or |
| 713 | to switch to a different kind of input data requiring a different strategy. |
| @@ -727,11 +728,11 @@ | |
| 728 | deflate stream should be flushed using deflate() with Z_BLOCK or other flush |
| 729 | request until strm.avail_out is not zero, before calling deflateParams(). |
| 730 | Then no more input data should be provided before the deflateParams() call. |
| 731 | If this is done, the old level and strategy will be applied to the data |
| 732 | compressed before deflateParams(), and the new level and strategy will be |
| 733 | applied to the data compressed after deflateParams(). |
| 734 | |
| 735 | deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream |
| 736 | state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if |
| 737 | there was not enough output space to complete the compression of the |
| 738 | available input data before a change in the strategy or approach. Note that |
| @@ -738,15 +739,15 @@ | |
| 739 | in the case of a Z_BUF_ERROR, the parameters are not changed. A return |
| 740 | value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be |
| 741 | retried with more output space. |
| 742 | */ |
| 743 | |
| 744 | ZEXTERN int ZEXPORT deflateTune(z_streamp strm, |
| 745 | int good_length, |
| 746 | int max_lazy, |
| 747 | int nice_length, |
| 748 | int max_chain); |
| 749 | /* |
| 750 | Fine tune deflate's internal compression parameters. This should only be |
| 751 | used by someone who understands the algorithm used by zlib's deflate for |
| 752 | searching for the best matching string, and even then only by the most |
| 753 | fanatic optimizer trying to squeeze out the last compressed bit for their |
| @@ -755,12 +756,12 @@ | |
| 756 | |
| 757 | deflateTune() can be called after deflateInit() or deflateInit2(), and |
| 758 | returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. |
| 759 | */ |
| 760 | |
| 761 | ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, |
| 762 | uLong sourceLen); |
| 763 | /* |
| 764 | deflateBound() returns an upper bound on the compressed size after |
| 765 | deflation of sourceLen bytes. It must be called after deflateInit() or |
| 766 | deflateInit2(), and after deflateSetHeader(), if used. This would be used |
| 767 | to allocate an output buffer for deflation in a single pass, and so would be |
| @@ -770,13 +771,13 @@ | |
| 771 | to return Z_STREAM_END. Note that it is possible for the compressed size to |
| 772 | be larger than the value returned by deflateBound() if flush options other |
| 773 | than Z_FINISH or Z_NO_FLUSH are used. |
| 774 | */ |
| 775 | |
| 776 | ZEXTERN int ZEXPORT deflatePending(z_streamp strm, |
| 777 | unsigned *pending, |
| 778 | int *bits); |
| 779 | /* |
| 780 | deflatePending() returns the number of bytes and bits of output that have |
| 781 | been generated, but not yet provided in the available output. The bytes not |
| 782 | provided would be due to the available output space having being consumed. |
| 783 | The number of bits of output not provided are between 0 and 7, where they |
| @@ -785,13 +786,13 @@ | |
| 786 | |
| 787 | deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 788 | stream state was inconsistent. |
| 789 | */ |
| 790 | |
| 791 | ZEXTERN int ZEXPORT deflatePrime(z_streamp strm, |
| 792 | int bits, |
| 793 | int value); |
| 794 | /* |
| 795 | deflatePrime() inserts bits in the deflate output stream. The intent |
| 796 | is that this function is used to start off the deflate output with the bits |
| 797 | leftover from a previous deflate stream when appending to it. As such, this |
| 798 | function can only be used for raw deflate, and must be used before the first |
| @@ -802,12 +803,12 @@ | |
| 803 | deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough |
| 804 | room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the |
| 805 | source stream state was inconsistent. |
| 806 | */ |
| 807 | |
| 808 | ZEXTERN int ZEXPORT deflateSetHeader(z_streamp strm, |
| 809 | gz_headerp head); |
| 810 | /* |
| 811 | deflateSetHeader() provides gzip header information for when a gzip |
| 812 | stream is requested by deflateInit2(). deflateSetHeader() may be called |
| 813 | after deflateInit2() or deflateReset() and before the first call of |
| 814 | deflate(). The text, time, os, extra field, name, and comment information |
| @@ -819,20 +820,21 @@ | |
| 820 | the current versions of the command-line version of gzip (up through version |
| 821 | 1.3.x) do not support header crc's, and will report that it is a "multi-part |
| 822 | gzip file" and give up. |
| 823 | |
| 824 | If deflateSetHeader is not used, the default gzip header has text false, |
| 825 | the time set to zero, and os set to the current operating system, with no |
| 826 | extra, name, or comment fields. The gzip header is returned to the default |
| 827 | state by deflateReset(). |
| 828 | |
| 829 | deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 830 | stream state was inconsistent. |
| 831 | */ |
| 832 | |
| 833 | /* |
| 834 | ZEXTERN int ZEXPORT inflateInit2(z_streamp strm, |
| 835 | int windowBits); |
| 836 | |
| 837 | This is another version of inflateInit with an extra parameter. The |
| 838 | fields next_in, avail_in, zalloc, zfree and opaque must be initialized |
| 839 | before by the caller. |
| 840 | |
| @@ -881,13 +883,13 @@ | |
| 883 | next_out and avail_out are unused and unchanged.) The current implementation |
| 884 | of inflateInit2() does not process any header information -- that is |
| 885 | deferred until inflate() is called. |
| 886 | */ |
| 887 | |
| 888 | ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm, |
| 889 | const Bytef *dictionary, |
| 890 | uInt dictLength); |
| 891 | /* |
| 892 | Initializes the decompression dictionary from the given uncompressed byte |
| 893 | sequence. This function must be called immediately after a call of inflate, |
| 894 | if that call returned Z_NEED_DICT. The dictionary chosen by the compressor |
| 895 | can be determined from the Adler-32 value returned by that call of inflate. |
| @@ -904,13 +906,13 @@ | |
| 906 | expected one (incorrect Adler-32 value). inflateSetDictionary does not |
| 907 | perform any decompression: this will be done by subsequent calls of |
| 908 | inflate(). |
| 909 | */ |
| 910 | |
| 911 | ZEXTERN int ZEXPORT inflateGetDictionary(z_streamp strm, |
| 912 | Bytef *dictionary, |
| 913 | uInt *dictLength); |
| 914 | /* |
| 915 | Returns the sliding dictionary being maintained by inflate. dictLength is |
| 916 | set to the number of bytes in the dictionary, and that many bytes are copied |
| 917 | to dictionary. dictionary must have enough space, where 32768 bytes is |
| 918 | always enough. If inflateGetDictionary() is called with dictionary equal to |
| @@ -919,11 +921,11 @@ | |
| 921 | |
| 922 | inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the |
| 923 | stream state is inconsistent. |
| 924 | */ |
| 925 | |
| 926 | ZEXTERN int ZEXPORT inflateSync(z_streamp strm); |
| 927 | /* |
| 928 | Skips invalid compressed data until a possible full flush point (see above |
| 929 | for the description of deflate with Z_FULL_FLUSH) can be found, or until all |
| 930 | available input is skipped. No output is provided. |
| 931 | |
| @@ -938,12 +940,12 @@ | |
| 940 | total_in which indicates where valid compressed data was found. In the |
| 941 | error case, the application may repeatedly call inflateSync, providing more |
| 942 | input each time, until success or end of the input data. |
| 943 | */ |
| 944 | |
| 945 | ZEXTERN int ZEXPORT inflateCopy(z_streamp dest, |
| 946 | z_streamp source); |
| 947 | /* |
| 948 | Sets the destination stream as a complete copy of the source stream. |
| 949 | |
| 950 | This function can be useful when randomly accessing a large stream. The |
| 951 | first pass through the stream can periodically record the inflate state, |
| @@ -954,22 +956,23 @@ | |
| 956 | enough memory, Z_STREAM_ERROR if the source stream state was inconsistent |
| 957 | (such as zalloc being Z_NULL). msg is left unchanged in both source and |
| 958 | destination. |
| 959 | */ |
| 960 | |
| 961 | ZEXTERN int ZEXPORT inflateReset(z_streamp strm); |
| 962 | /* |
| 963 | This function is equivalent to inflateEnd followed by inflateInit, |
| 964 | but does not free and reallocate the internal decompression state. The |
| 965 | stream will keep attributes that may have been set by inflateInit2. |
| 966 | total_in, total_out, adler, and msg are initialized. |
| 967 | |
| 968 | inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 969 | stream state was inconsistent (such as zalloc or state being Z_NULL). |
| 970 | */ |
| 971 | |
| 972 | ZEXTERN int ZEXPORT inflateReset2(z_streamp strm, |
| 973 | int windowBits); |
| 974 | /* |
| 975 | This function is the same as inflateReset, but it also permits changing |
| 976 | the wrap and window size requests. The windowBits parameter is interpreted |
| 977 | the same as it is for inflateInit2. If the window size is changed, then the |
| 978 | memory allocated for the window is freed, and the window will be reallocated |
| @@ -978,13 +981,13 @@ | |
| 981 | inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 982 | stream state was inconsistent (such as zalloc or state being Z_NULL), or if |
| 983 | the windowBits parameter is invalid. |
| 984 | */ |
| 985 | |
| 986 | ZEXTERN int ZEXPORT inflatePrime(z_streamp strm, |
| 987 | int bits, |
| 988 | int value); |
| 989 | /* |
| 990 | This function inserts bits in the inflate input stream. The intent is |
| 991 | that this function is used to start inflating at a bit position in the |
| 992 | middle of a byte. The provided bits will be used before any bytes are used |
| 993 | from next_in. This function should only be used with raw inflate, and |
| @@ -999,11 +1002,11 @@ | |
| 1002 | |
| 1003 | inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 1004 | stream state was inconsistent. |
| 1005 | */ |
| 1006 | |
| 1007 | ZEXTERN long ZEXPORT inflateMark(z_streamp strm); |
| 1008 | /* |
| 1009 | This function returns two values, one in the lower 16 bits of the return |
| 1010 | value, and the other in the remaining upper bits, obtained by shifting the |
| 1011 | return value down 16 bits. If the upper value is -1 and the lower value is |
| 1012 | zero, then inflate() is currently decoding information outside of a block. |
| @@ -1027,12 +1030,12 @@ | |
| 1030 | |
| 1031 | inflateMark returns the value noted above, or -65536 if the provided |
| 1032 | source stream state was inconsistent. |
| 1033 | */ |
| 1034 | |
| 1035 | ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm, |
| 1036 | gz_headerp head); |
| 1037 | /* |
| 1038 | inflateGetHeader() requests that gzip header information be stored in the |
| 1039 | provided gz_header structure. inflateGetHeader() may be called after |
| 1040 | inflateInit2() or inflateReset(), and before the first call of inflate(). |
| 1041 | As inflate() processes the gzip stream, head->done is zero until the header |
| @@ -1068,12 +1071,12 @@ | |
| 1071 | inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 1072 | stream state was inconsistent. |
| 1073 | */ |
| 1074 | |
| 1075 | /* |
| 1076 | ZEXTERN int ZEXPORT inflateBackInit(z_streamp strm, int windowBits, |
| 1077 | unsigned char FAR *window); |
| 1078 | |
| 1079 | Initialize the internal stream state for decompression using inflateBack() |
| 1080 | calls. The fields zalloc, zfree and opaque in strm must be initialized |
| 1081 | before the call. If zalloc and zfree are Z_NULL, then the default library- |
| 1082 | derived memory allocation routines are used. windowBits is the base two |
| @@ -1089,17 +1092,17 @@ | |
| 1092 | the parameters are invalid, Z_MEM_ERROR if the internal state could not be |
| 1093 | allocated, or Z_VERSION_ERROR if the version of the library does not match |
| 1094 | the version of the header file. |
| 1095 | */ |
| 1096 | |
| 1097 | typedef unsigned (*in_func)(void FAR *, |
| 1098 | z_const unsigned char FAR * FAR *); |
| 1099 | typedef int (*out_func)(void FAR *, unsigned char FAR *, unsigned); |
| 1100 | |
| 1101 | ZEXTERN int ZEXPORT inflateBack(z_streamp strm, |
| 1102 | in_func in, void FAR *in_desc, |
| 1103 | out_func out, void FAR *out_desc); |
| 1104 | /* |
| 1105 | inflateBack() does a raw inflate with a single call using a call-back |
| 1106 | interface for input and output. This is potentially more efficient than |
| 1107 | inflate() for file i/o applications, in that it avoids copying between the |
| 1108 | output and the sliding window by simply making the window itself the output |
| @@ -1163,19 +1166,19 @@ | |
| 1166 | non-zero. (in() will always be called before out(), so strm->next_in is |
| 1167 | assured to be defined if out() returns non-zero.) Note that inflateBack() |
| 1168 | cannot return Z_OK. |
| 1169 | */ |
| 1170 | |
| 1171 | ZEXTERN int ZEXPORT inflateBackEnd(z_streamp strm); |
| 1172 | /* |
| 1173 | All memory allocated by inflateBackInit() is freed. |
| 1174 | |
| 1175 | inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream |
| 1176 | state was inconsistent. |
| 1177 | */ |
| 1178 | |
| 1179 | ZEXTERN uLong ZEXPORT zlibCompileFlags(void); |
| 1180 | /* Return flags indicating compile-time options. |
| 1181 | |
| 1182 | Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: |
| 1183 | 1.0: size of uInt |
| 1184 | 3.2: size of uLong |
| @@ -1224,12 +1227,12 @@ | |
| 1227 | are assumed (compression level and memory usage, standard memory allocation |
| 1228 | functions). The source code of these utility functions can be modified if |
| 1229 | you need special options. |
| 1230 | */ |
| 1231 | |
| 1232 | ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen, |
| 1233 | const Bytef *source, uLong sourceLen); |
| 1234 | /* |
| 1235 | Compresses the source buffer into the destination buffer. sourceLen is |
| 1236 | the byte length of the source buffer. Upon entry, destLen is the total size |
| 1237 | of the destination buffer, which must be at least the value returned by |
| 1238 | compressBound(sourceLen). Upon exit, destLen is the actual size of the |
| @@ -1239,13 +1242,13 @@ | |
| 1242 | compress returns Z_OK if success, Z_MEM_ERROR if there was not |
| 1243 | enough memory, Z_BUF_ERROR if there was not enough room in the output |
| 1244 | buffer. |
| 1245 | */ |
| 1246 | |
| 1247 | ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen, |
| 1248 | const Bytef *source, uLong sourceLen, |
| 1249 | int level); |
| 1250 | /* |
| 1251 | Compresses the source buffer into the destination buffer. The level |
| 1252 | parameter has the same meaning as in deflateInit. sourceLen is the byte |
| 1253 | length of the source buffer. Upon entry, destLen is the total size of the |
| 1254 | destination buffer, which must be at least the value returned by |
| @@ -1255,19 +1258,19 @@ | |
| 1258 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough |
| 1259 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, |
| 1260 | Z_STREAM_ERROR if the level parameter is invalid. |
| 1261 | */ |
| 1262 | |
| 1263 | ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen); |
| 1264 | /* |
| 1265 | compressBound() returns an upper bound on the compressed size after |
| 1266 | compress() or compress2() on sourceLen bytes. It would be used before a |
| 1267 | compress() or compress2() call to allocate the destination buffer. |
| 1268 | */ |
| 1269 | |
| 1270 | ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, |
| 1271 | const Bytef *source, uLong sourceLen); |
| 1272 | /* |
| 1273 | Decompresses the source buffer into the destination buffer. sourceLen is |
| 1274 | the byte length of the source buffer. Upon entry, destLen is the total size |
| 1275 | of the destination buffer, which must be large enough to hold the entire |
| 1276 | uncompressed data. (The size of the uncompressed data must have been saved |
| @@ -1280,12 +1283,12 @@ | |
| 1283 | buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In |
| 1284 | the case where there is not enough room, uncompress() will fill the output |
| 1285 | buffer with the uncompressed data up to that point. |
| 1286 | */ |
| 1287 | |
| 1288 | ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, |
| 1289 | const Bytef *source, uLong *sourceLen); |
| 1290 | /* |
| 1291 | Same as uncompress, except that sourceLen is a pointer, where the |
| 1292 | length of the source is *sourceLen. On return, *sourceLen is the number of |
| 1293 | source bytes consumed. |
| 1294 | */ |
| @@ -1300,11 +1303,11 @@ | |
| 1303 | */ |
| 1304 | |
| 1305 | typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ |
| 1306 | |
| 1307 | /* |
| 1308 | ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode); |
| 1309 | |
| 1310 | Open the gzip (.gz) file at path for reading and decompressing, or |
| 1311 | compressing and writing. The mode parameter is as in fopen ("rb" or "wb") |
| 1312 | but can also include a compression level ("wb9") or a strategy: 'f' for |
| 1313 | filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", |
| @@ -1337,11 +1340,11 @@ | |
| 1340 | specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). |
| 1341 | errno can be checked to determine if the reason gzopen failed was that the |
| 1342 | file could not be opened. |
| 1343 | */ |
| 1344 | |
| 1345 | ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode); |
| 1346 | /* |
| 1347 | Associate a gzFile with the file descriptor fd. File descriptors are |
| 1348 | obtained from calls like open, dup, creat, pipe or fileno (if the file has |
| 1349 | been previously opened with fopen). The mode parameter is as in gzopen. |
| 1350 | |
| @@ -1360,11 +1363,11 @@ | |
| 1363 | provided, or '+' was provided), or if fd is -1. The file descriptor is not |
| 1364 | used until the next gz* read, write, seek, or close operation, so gzdopen |
| 1365 | will not detect if fd is invalid (unless fd is -1). |
| 1366 | */ |
| 1367 | |
| 1368 | ZEXTERN int ZEXPORT gzbuffer(gzFile file, unsigned size); |
| 1369 | /* |
| 1370 | Set the internal buffer size used by this library's functions for file to |
| 1371 | size. The default buffer size is 8192 bytes. This function must be called |
| 1372 | after gzopen() or gzdopen(), and before any other calls that read or write |
| 1373 | the file. The buffer memory allocation is always deferred to the first read |
| @@ -1376,11 +1379,11 @@ | |
| 1379 | |
| 1380 | gzbuffer() returns 0 on success, or -1 on failure, such as being called |
| 1381 | too late. |
| 1382 | */ |
| 1383 | |
| 1384 | ZEXTERN int ZEXPORT gzsetparams(gzFile file, int level, int strategy); |
| 1385 | /* |
| 1386 | Dynamically update the compression level and strategy for file. See the |
| 1387 | description of deflateInit2 for the meaning of these parameters. Previously |
| 1388 | provided data is flushed before applying the parameter changes. |
| 1389 | |
| @@ -1387,11 +1390,11 @@ | |
| 1390 | gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not |
| 1391 | opened for writing, Z_ERRNO if there is an error writing the flushed data, |
| 1392 | or Z_MEM_ERROR if there is a memory allocation error. |
| 1393 | */ |
| 1394 | |
| 1395 | ZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len); |
| 1396 | /* |
| 1397 | Read and decompress up to len uncompressed bytes from file into buf. If |
| 1398 | the input file is not in gzip format, gzread copies the given number of |
| 1399 | bytes into the buffer directly from the file. |
| 1400 | |
| @@ -1417,12 +1420,12 @@ | |
| 1420 | len for end of file, or -1 for error. If len is too large to fit in an int, |
| 1421 | then nothing is read, -1 is returned, and the error state is set to |
| 1422 | Z_STREAM_ERROR. |
| 1423 | */ |
| 1424 | |
| 1425 | ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, |
| 1426 | gzFile file); |
| 1427 | /* |
| 1428 | Read and decompress up to nitems items of size size from file into buf, |
| 1429 | otherwise operating as gzread() does. This duplicates the interface of |
| 1430 | stdio's fread(), with size_t request and return types. If the library |
| 1431 | defines size_t, then z_size_t is identical to size_t. If not, then z_size_t |
| @@ -1443,18 +1446,18 @@ | |
| 1446 | is the same as the behavior of fread() implementations in common libraries, |
| 1447 | but it prevents the direct use of gzfread() to read a concurrently written |
| 1448 | file, resetting and retrying on end-of-file, when size is not 1. |
| 1449 | */ |
| 1450 | |
| 1451 | ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len); |
| 1452 | /* |
| 1453 | Compress and write the len uncompressed bytes at buf to file. gzwrite |
| 1454 | returns the number of uncompressed bytes written or 0 in case of error. |
| 1455 | */ |
| 1456 | |
| 1457 | ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, |
| 1458 | z_size_t nitems, gzFile file); |
| 1459 | /* |
| 1460 | Compress and write nitems items of size size from buf to file, duplicating |
| 1461 | the interface of stdio's fwrite(), with size_t request and return types. If |
| 1462 | the library defines size_t, then z_size_t is identical to size_t. If not, |
| 1463 | then z_size_t is an unsigned integer type that can contain a pointer. |
| @@ -1463,11 +1466,11 @@ | |
| 1466 | if there was an error. If the multiplication of size and nitems overflows, |
| 1467 | i.e. the product does not fit in a z_size_t, then nothing is written, zero |
| 1468 | is returned, and the error state is set to Z_STREAM_ERROR. |
| 1469 | */ |
| 1470 | |
| 1471 | ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...); |
| 1472 | /* |
| 1473 | Convert, format, compress, and write the arguments (...) to file under |
| 1474 | control of the string format, as in fprintf. gzprintf returns the number of |
| 1475 | uncompressed bytes actually written, or a negative zlib error code in case |
| 1476 | of error. The number of uncompressed bytes written is limited to 8191, or |
| @@ -1478,19 +1481,19 @@ | |
| 1481 | zlib was compiled with the insecure functions sprintf() or vsprintf(), |
| 1482 | because the secure snprintf() or vsnprintf() functions were not available. |
| 1483 | This can be determined using zlibCompileFlags(). |
| 1484 | */ |
| 1485 | |
| 1486 | ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s); |
| 1487 | /* |
| 1488 | Compress and write the given null-terminated string s to file, excluding |
| 1489 | the terminating null character. |
| 1490 | |
| 1491 | gzputs returns the number of characters written, or -1 in case of error. |
| 1492 | */ |
| 1493 | |
| 1494 | ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len); |
| 1495 | /* |
| 1496 | Read and decompress bytes from file into buf, until len-1 characters are |
| 1497 | read, or until a newline character is read and transferred to buf, or an |
| 1498 | end-of-file condition is encountered. If any characters are read or if len |
| 1499 | is one, the string is terminated with a null character. If no characters |
| @@ -1500,26 +1503,26 @@ | |
| 1503 | gzgets returns buf which is a null-terminated string, or it returns NULL |
| 1504 | for end-of-file or in case of error. If there was an error, the contents at |
| 1505 | buf are indeterminate. |
| 1506 | */ |
| 1507 | |
| 1508 | ZEXTERN int ZEXPORT gzputc(gzFile file, int c); |
| 1509 | /* |
| 1510 | Compress and write c, converted to an unsigned char, into file. gzputc |
| 1511 | returns the value that was written, or -1 in case of error. |
| 1512 | */ |
| 1513 | |
| 1514 | ZEXTERN int ZEXPORT gzgetc(gzFile file); |
| 1515 | /* |
| 1516 | Read and decompress one byte from file. gzgetc returns this byte or -1 |
| 1517 | in case of end of file or error. This is implemented as a macro for speed. |
| 1518 | As such, it does not do all of the checking the other functions do. I.e. |
| 1519 | it does not check to see if file is NULL, nor whether the structure file |
| 1520 | points to has been clobbered or not. |
| 1521 | */ |
| 1522 | |
| 1523 | ZEXTERN int ZEXPORT gzungetc(int c, gzFile file); |
| 1524 | /* |
| 1525 | Push c back onto the stream for file to be read as the first character on |
| 1526 | the next read. At least one character of push-back is always allowed. |
| 1527 | gzungetc() returns the character pushed, or -1 on failure. gzungetc() will |
| 1528 | fail if c is -1, and may fail if a character has been pushed but not read |
| @@ -1527,11 +1530,11 @@ | |
| 1530 | output buffer size of pushed characters is allowed. (See gzbuffer above.) |
| 1531 | The pushed character will be discarded if the stream is repositioned with |
| 1532 | gzseek() or gzrewind(). |
| 1533 | */ |
| 1534 | |
| 1535 | ZEXTERN int ZEXPORT gzflush(gzFile file, int flush); |
| 1536 | /* |
| 1537 | Flush all pending output to file. The parameter flush is as in the |
| 1538 | deflate() function. The return value is the zlib error number (see function |
| 1539 | gzerror below). gzflush is only permitted when writing. |
| 1540 | |
| @@ -1543,12 +1546,12 @@ | |
| 1546 | gzflush should be called only when strictly necessary because it will |
| 1547 | degrade compression if called too often. |
| 1548 | */ |
| 1549 | |
| 1550 | /* |
| 1551 | ZEXTERN z_off_t ZEXPORT gzseek(gzFile file, |
| 1552 | z_off_t offset, int whence); |
| 1553 | |
| 1554 | Set the starting position to offset relative to whence for the next gzread |
| 1555 | or gzwrite on file. The offset represents a number of bytes in the |
| 1556 | uncompressed data stream. The whence parameter is defined as in lseek(2); |
| 1557 | the value SEEK_END is not supported. |
| @@ -1562,19 +1565,19 @@ | |
| 1565 | the beginning of the uncompressed stream, or -1 in case of error, in |
| 1566 | particular if the file is opened for writing and the new starting position |
| 1567 | would be before the current position. |
| 1568 | */ |
| 1569 | |
| 1570 | ZEXTERN int ZEXPORT gzrewind(gzFile file); |
| 1571 | /* |
| 1572 | Rewind file. This function is supported only for reading. |
| 1573 | |
| 1574 | gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET). |
| 1575 | */ |
| 1576 | |
| 1577 | /* |
| 1578 | ZEXTERN z_off_t ZEXPORT gztell(gzFile file); |
| 1579 | |
| 1580 | Return the starting position for the next gzread or gzwrite on file. |
| 1581 | This position represents a number of bytes in the uncompressed data stream, |
| 1582 | and is zero when starting, even if appending or reading a gzip stream from |
| 1583 | the middle of a file using gzdopen(). |
| @@ -1581,20 +1584,20 @@ | |
| 1584 | |
| 1585 | gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) |
| 1586 | */ |
| 1587 | |
| 1588 | /* |
| 1589 | ZEXTERN z_off_t ZEXPORT gzoffset(gzFile file); |
| 1590 | |
| 1591 | Return the current compressed (actual) read or write offset of file. This |
| 1592 | offset includes the count of bytes that precede the gzip stream, for example |
| 1593 | when appending or when using gzdopen() for reading. When reading, the |
| 1594 | offset does not include as yet unused buffered input. This information can |
| 1595 | be used for a progress indicator. On error, gzoffset() returns -1. |
| 1596 | */ |
| 1597 | |
| 1598 | ZEXTERN int ZEXPORT gzeof(gzFile file); |
| 1599 | /* |
| 1600 | Return true (1) if the end-of-file indicator for file has been set while |
| 1601 | reading, false (0) otherwise. Note that the end-of-file indicator is set |
| 1602 | only if the read tried to go past the end of the input, but came up short. |
| 1603 | Therefore, just like feof(), gzeof() may return false even if there is no |
| @@ -1605,11 +1608,11 @@ | |
| 1608 | If gzeof() returns true, then the read functions will return no more data, |
| 1609 | unless the end-of-file indicator is reset by gzclearerr() and the input file |
| 1610 | has grown since the previous end of file was detected. |
| 1611 | */ |
| 1612 | |
| 1613 | ZEXTERN int ZEXPORT gzdirect(gzFile file); |
| 1614 | /* |
| 1615 | Return true (1) if file is being copied directly while reading, or false |
| 1616 | (0) if file is a gzip stream being decompressed. |
| 1617 | |
| 1618 | If the input file is empty, gzdirect() will return true, since the input |
| @@ -1626,11 +1629,11 @@ | |
| 1629 | explicitly requested, so the application already knows the answer. When |
| 1630 | linking statically, using gzdirect() will include all of the zlib code for |
| 1631 | gzip file reading and decompression, which may not be desired.) |
| 1632 | */ |
| 1633 | |
| 1634 | ZEXTERN int ZEXPORT gzclose(gzFile file); |
| 1635 | /* |
| 1636 | Flush all pending output for file, if necessary, close file and |
| 1637 | deallocate the (de)compression state. Note that once file is closed, you |
| 1638 | cannot call gzerror with file, since its structures have been deallocated. |
| 1639 | gzclose must not be called more than once on the same file, just as free |
| @@ -1639,12 +1642,12 @@ | |
| 1642 | gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a |
| 1643 | file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the |
| 1644 | last read ended in the middle of a gzip stream, or Z_OK on success. |
| 1645 | */ |
| 1646 | |
| 1647 | ZEXTERN int ZEXPORT gzclose_r(gzFile file); |
| 1648 | ZEXTERN int ZEXPORT gzclose_w(gzFile file); |
| 1649 | /* |
| 1650 | Same as gzclose(), but gzclose_r() is only for use when reading, and |
| 1651 | gzclose_w() is only for use when writing or appending. The advantage to |
| 1652 | using these instead of gzclose() is that they avoid linking in zlib |
| 1653 | compression or decompression code that is not used when only reading or only |
| @@ -1651,11 +1654,11 @@ | |
| 1654 | writing respectively. If gzclose() is used, then both compression and |
| 1655 | decompression code will be included the application when linking to a static |
| 1656 | zlib library. |
| 1657 | */ |
| 1658 | |
| 1659 | ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum); |
| 1660 | /* |
| 1661 | Return the error message for the last error which occurred on file. |
| 1662 | errnum is set to zlib error number. If an error occurred in the file system |
| 1663 | and not in the compression library, errnum is set to Z_ERRNO and the |
| 1664 | application may consult errno to get the exact error code. |
| @@ -1667,11 +1670,11 @@ | |
| 1670 | |
| 1671 | gzerror() should be used to distinguish errors from end-of-file for those |
| 1672 | functions above that do not distinguish those cases in their return values. |
| 1673 | */ |
| 1674 | |
| 1675 | ZEXTERN void ZEXPORT gzclearerr(gzFile file); |
| 1676 | /* |
| 1677 | Clear the error and end-of-file flags for file. This is analogous to the |
| 1678 | clearerr() function in stdio. This is useful for continuing to read a gzip |
| 1679 | file that is being written concurrently. |
| 1680 | */ |
| @@ -1684,11 +1687,11 @@ | |
| 1687 | These functions are not related to compression but are exported |
| 1688 | anyway because they might be useful in applications using the compression |
| 1689 | library. |
| 1690 | */ |
| 1691 | |
| 1692 | ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len); |
| 1693 | /* |
| 1694 | Update a running Adler-32 checksum with the bytes buf[0..len-1] and |
| 1695 | return the updated checksum. An Adler-32 value is in the range of a 32-bit |
| 1696 | unsigned integer. If buf is Z_NULL, this function returns the required |
| 1697 | initial value for the checksum. |
| @@ -1704,29 +1707,29 @@ | |
| 1707 | adler = adler32(adler, buffer, length); |
| 1708 | } |
| 1709 | if (adler != original_adler) error(); |
| 1710 | */ |
| 1711 | |
| 1712 | ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, |
| 1713 | z_size_t len); |
| 1714 | /* |
| 1715 | Same as adler32(), but with a size_t length. |
| 1716 | */ |
| 1717 | |
| 1718 | /* |
| 1719 | ZEXTERN uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, |
| 1720 | z_off_t len2); |
| 1721 | |
| 1722 | Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 |
| 1723 | and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for |
| 1724 | each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of |
| 1725 | seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note |
| 1726 | that the z_off_t type (like off_t) is a signed integer. If len2 is |
| 1727 | negative, the result has no meaning or utility. |
| 1728 | */ |
| 1729 | |
| 1730 | ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len); |
| 1731 | /* |
| 1732 | Update a running CRC-32 with the bytes buf[0..len-1] and return the |
| 1733 | updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. |
| 1734 | If buf is Z_NULL, this function returns the required initial value for the |
| 1735 | crc. Pre- and post-conditioning (one's complement) is performed within this |
| @@ -1740,34 +1743,34 @@ | |
| 1743 | crc = crc32(crc, buffer, length); |
| 1744 | } |
| 1745 | if (crc != original_crc) error(); |
| 1746 | */ |
| 1747 | |
| 1748 | ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf, |
| 1749 | z_size_t len); |
| 1750 | /* |
| 1751 | Same as crc32(), but with a size_t length. |
| 1752 | */ |
| 1753 | |
| 1754 | /* |
| 1755 | ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2); |
| 1756 | |
| 1757 | Combine two CRC-32 check values into one. For two sequences of bytes, |
| 1758 | seq1 and seq2 with lengths len1 and len2, CRC-32 check values were |
| 1759 | calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 |
| 1760 | check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and |
| 1761 | len2. |
| 1762 | */ |
| 1763 | |
| 1764 | /* |
| 1765 | ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2); |
| 1766 | |
| 1767 | Return the operator corresponding to length len2, to be used with |
| 1768 | crc32_combine_op(). |
| 1769 | */ |
| 1770 | |
| 1771 | ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op); |
| 1772 | /* |
| 1773 | Give the same result as crc32_combine(), using op in place of len2. op is |
| 1774 | is generated from len2 by crc32_combine_gen(). This will be faster than |
| 1775 | crc32_combine() if the generated op is used more than once. |
| 1776 | */ |
| @@ -1776,24 +1779,24 @@ | |
| 1779 | /* various hacks, don't look :) */ |
| 1780 | |
| 1781 | /* deflateInit and inflateInit are macros to allow checking the zlib version |
| 1782 | * and the compiler's view of z_stream: |
| 1783 | */ |
| 1784 | ZEXTERN int ZEXPORT deflateInit_(z_streamp strm, int level, |
| 1785 | const char *version, int stream_size); |
| 1786 | ZEXTERN int ZEXPORT inflateInit_(z_streamp strm, |
| 1787 | const char *version, int stream_size); |
| 1788 | ZEXTERN int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, |
| 1789 | int windowBits, int memLevel, |
| 1790 | int strategy, const char *version, |
| 1791 | int stream_size); |
| 1792 | ZEXTERN int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, |
| 1793 | const char *version, int stream_size); |
| 1794 | ZEXTERN int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, |
| 1795 | unsigned char FAR *window, |
| 1796 | const char *version, |
| 1797 | int stream_size); |
| 1798 | #ifdef Z_PREFIX_SET |
| 1799 | # define z_deflateInit(strm, level) \ |
| 1800 | deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) |
| 1801 | # define z_inflateInit(strm) \ |
| 1802 | inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) |
| @@ -1834,11 +1837,11 @@ | |
| 1837 | struct gzFile_s { |
| 1838 | unsigned have; |
| 1839 | unsigned char *next; |
| 1840 | z_off64_t pos; |
| 1841 | }; |
| 1842 | ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */ |
| 1843 | #ifdef Z_PREFIX_SET |
| 1844 | # undef z_gzgetc |
| 1845 | # define z_gzgetc(g) \ |
| 1846 | ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) |
| 1847 | #else |
| @@ -1851,17 +1854,17 @@ | |
| 1854 | * both are true, the application gets the *64 functions, and the regular |
| 1855 | * functions are changed to 64 bits) -- in case these are set on systems |
| 1856 | * without large file support, _LFS64_LARGEFILE must also be true |
| 1857 | */ |
| 1858 | #ifdef Z_LARGE64 |
| 1859 | ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); |
| 1860 | ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); |
| 1861 | ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); |
| 1862 | ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); |
| 1863 | ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t); |
| 1864 | ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t); |
| 1865 | ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t); |
| 1866 | #endif |
| 1867 | |
| 1868 | #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) |
| 1869 | # ifdef Z_PREFIX_SET |
| 1870 | # define z_gzopen z_gzopen64 |
| @@ -1879,57 +1882,57 @@ | |
| 1882 | # define adler32_combine adler32_combine64 |
| 1883 | # define crc32_combine crc32_combine64 |
| 1884 | # define crc32_combine_gen crc32_combine_gen64 |
| 1885 | # endif |
| 1886 | # ifndef Z_LARGE64 |
| 1887 | ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); |
| 1888 | ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int); |
| 1889 | ZEXTERN z_off_t ZEXPORT gztell64(gzFile); |
| 1890 | ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile); |
| 1891 | ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); |
| 1892 | ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); |
| 1893 | ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); |
| 1894 | # endif |
| 1895 | #else |
| 1896 | ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *); |
| 1897 | ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int); |
| 1898 | ZEXTERN z_off_t ZEXPORT gztell(gzFile); |
| 1899 | ZEXTERN z_off_t ZEXPORT gzoffset(gzFile); |
| 1900 | ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); |
| 1901 | ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); |
| 1902 | ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); |
| 1903 | #endif |
| 1904 | |
| 1905 | #else /* Z_SOLO */ |
| 1906 | |
| 1907 | ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); |
| 1908 | ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); |
| 1909 | ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); |
| 1910 | |
| 1911 | #endif /* !Z_SOLO */ |
| 1912 | |
| 1913 | /* undocumented functions */ |
| 1914 | ZEXTERN const char * ZEXPORT zError(int); |
| 1915 | ZEXTERN int ZEXPORT inflateSyncPoint(z_streamp); |
| 1916 | ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void); |
| 1917 | ZEXTERN int ZEXPORT inflateUndermine(z_streamp, int); |
| 1918 | ZEXTERN int ZEXPORT inflateValidate(z_streamp, int); |
| 1919 | ZEXTERN unsigned long ZEXPORT inflateCodesUsed(z_streamp); |
| 1920 | ZEXTERN int ZEXPORT inflateResetKeep(z_streamp); |
| 1921 | ZEXTERN int ZEXPORT deflateResetKeep(z_streamp); |
| 1922 | #if defined(_WIN32) && !defined(Z_SOLO) |
| 1923 | ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path, |
| 1924 | const char *mode); |
| 1925 | #endif |
| 1926 | #if defined(STDC) || defined(Z_HAVE_STDARG_H) |
| 1927 | # ifndef Z_SOLO |
| 1928 | ZEXTERN int ZEXPORTVA gzvprintf(gzFile file, |
| 1929 | const char *format, |
| 1930 | va_list va); |
| 1931 | # endif |
| 1932 | #endif |
| 1933 | |
| 1934 | #ifdef __cplusplus |
| 1935 | } |
| 1936 | #endif |
| 1937 | |
| 1938 | #endif /* ZLIB_H */ |
| 1939 | |
| 1940 | ELETED compat/zlib/zlib2ansi |
D
compat/zlib/zlib2ansi
-152
| --- a/compat/zlib/zlib2ansi | ||
| +++ b/compat/zlib/zlib2ansi | ||
| @@ -1,152 +0,0 @@ | ||
| 1 | -#!/usr/bin/perl | |
| 2 | - | |
| 3 | -# Transform K&R C function definitions into ANSI equivalent. | |
| 4 | -# | |
| 5 | -# Author: Paul Marquess | |
| 6 | -# Version: 1.0 | |
| 7 | -# Date: 3 October 2006 | |
| 8 | - | |
| 9 | -# TODO | |
| 10 | -# | |
| 11 | -# Assumes no function pointer parameters. unless they are typedefed. | |
| 12 | -# Assumes no literal strings that look like function definitions | |
| 13 | -# Assumes functions start at the beginning of a line | |
| 14 | - | |
| 15 | -use strict; | |
| 16 | -use warnings; | |
| 17 | - | |
| 18 | -local $/; | |
| 19 | -$_ = <>; | |
| 20 | - | |
| 21 | -my $sp = qr{ \s* (?: /\* .*? \*/ )? \s* }x; # assume no nested comments | |
| 22 | - | |
| 23 | -my $d1 = qr{ $sp (?: [\w\*\s]+ $sp)* $sp \w+ $sp [\[\]\s]* $sp }x ; | |
| 24 | -my $decl = qr{ $sp (?: \w+ $sp )+ $d1 }xo ; | |
| 25 | -my $dList = qr{ $sp $decl (?: $sp , $d1 )* $sp ; $sp }xo ; | |
| 26 | - | |
| 27 | - | |
| 28 | -while (s/^ | |
| 29 | - ( # Start $1 | |
| 30 | - ( # Start $2 | |
| 31 | - .*? # Minimal eat content | |
| 32 | - ( ^ \w [\w\s\*]+ ) # $3 -- function name | |
| 33 | - \s* # optional whitespace | |
| 34 | - ) # $2 - Matched up to before parameter list | |
| 35 | - | |
| 36 | - \( \s* # Literal "(" + optional whitespace | |
| 37 | - ( [^\)]+ ) # $4 - one or more anythings except ")" | |
| 38 | - \s* \) # optional whitespace surrounding a Literal ")" | |
| 39 | - | |
| 40 | - ( (?: $dList )+ ) # $5 | |
| 41 | - | |
| 42 | - $sp ^ { # literal "{" at start of line | |
| 43 | - ) # Remember to $1 | |
| 44 | - //xsom | |
| 45 | - ) | |
| 46 | -{ | |
| 47 | - my $all = $1 ; | |
| 48 | - my $prefix = $2; | |
| 49 | - my $param_list = $4 ; | |
| 50 | - my $params = $5; | |
| 51 | - | |
| 52 | - StripComments($params); | |
| 53 | - StripComments($param_list); | |
| 54 | - $param_list =~ s/^\s+//; | |
| 55 | - $param_list =~ s/\s+$//; | |
| 56 | - | |
| 57 | - my $i = 0 ; | |
| 58 | - my %pList = map { $_ => $i++ } | |
| 59 | - split /\s*,\s*/, $param_list; | |
| 60 | - my $pMatch = '(\b' . join('|', keys %pList) . '\b)\W*$' ; | |
| 61 | - | |
| 62 | - my @params = split /\s*;\s*/, $params; | |
| 63 | - my @outParams = (); | |
| 64 | - foreach my $p (@params) | |
| 65 | - { | |
| 66 | - if ($p =~ /,/) | |
| 67 | - { | |
| 68 | - my @bits = split /\s*,\s*/, $p; | |
| 69 | - my $first = shift @bits; | |
| 70 | - $first =~ s/^\s*//; | |
| 71 | - push @outParams, $first; | |
| 72 | - $first =~ /^(\w+\s*)/; | |
| 73 | - my $type = $1 ; | |
| 74 | - push @outParams, map { $type . $_ } @bits; | |
| 75 | - } | |
| 76 | - else | |
| 77 | - { | |
| 78 | - $p =~ s/^\s+//; | |
| 79 | - push @outParams, $p; | |
| 80 | - } | |
| 81 | - } | |
| 82 | - | |
| 83 | - | |
| 84 | - my %tmp = map { /$pMatch/; $_ => $pList{$1} } | |
| 85 | - @outParams ; | |
| 86 | - | |
| 87 | - @outParams = map { " $_" } | |
| 88 | - sort { $tmp{$a} <=> $tmp{$b} } | |
| 89 | - @outParams ; | |
| 90 | - | |
| 91 | - print $prefix ; | |
| 92 | - print "(\n" . join(",\n", @outParams) . ")\n"; | |
| 93 | - print "{" ; | |
| 94 | - | |
| 95 | -} | |
| 96 | - | |
| 97 | -# Output any trailing code. | |
| 98 | -print ; | |
| 99 | -exit 0; | |
| 100 | - | |
| 101 | - | |
| 102 | -sub StripComments | |
| 103 | -{ | |
| 104 | - | |
| 105 | - no warnings; | |
| 106 | - | |
| 107 | - # Strip C & C++ comments | |
| 108 | - # From the perlfaq | |
| 109 | - $_[0] =~ | |
| 110 | - | |
| 111 | - s{ | |
| 112 | - /\* ## Start of /* ... */ comment | |
| 113 | - [^*]*\*+ ## Non-* followed by 1-or-more *'s | |
| 114 | - ( | |
| 115 | - [^/*][^*]*\*+ | |
| 116 | - )* ## 0-or-more things which don't start with / | |
| 117 | - ## but do end with '*' | |
| 118 | - / ## End of /* ... */ comment | |
| 119 | - | |
| 120 | - | ## OR C++ Comment | |
| 121 | - // ## Start of C++ comment // | |
| 122 | - [^\n]* ## followed by 0-or-more non end of line characters | |
| 123 | - | |
| 124 | - | ## OR various things which aren't comments: | |
| 125 | - | |
| 126 | - ( | |
| 127 | - " ## Start of " ... " string | |
| 128 | - ( | |
| 129 | - \\. ## Escaped char | |
| 130 | - | ## OR | |
| 131 | - [^"\\] ## Non "\ | |
| 132 | - )* | |
| 133 | - " ## End of " ... " string | |
| 134 | - | |
| 135 | - | ## OR | |
| 136 | - | |
| 137 | - ' ## Start of ' ... ' string | |
| 138 | - ( | |
| 139 | - \\. ## Escaped char | |
| 140 | - | ## OR | |
| 141 | - [^'\\] ## Non '\ | |
| 142 | - )* | |
| 143 | - ' ## End of ' ... ' string | |
| 144 | - | |
| 145 | - | ## OR | |
| 146 | - | |
| 147 | - . ## Anything other char | |
| 148 | - [^/"'\\]* ## Chars which doesn't start a comment, string or escape | |
| 149 | - ) | |
| 150 | - }{$2}gxs; | |
| 151 | - | |
| 152 | -} |
| --- a/compat/zlib/zlib2ansi | |
| +++ b/compat/zlib/zlib2ansi | |
| @@ -1,152 +0,0 @@ | |
| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | # Transform K&R C function definitions into ANSI equivalent. |
| 4 | # |
| 5 | # Author: Paul Marquess |
| 6 | # Version: 1.0 |
| 7 | # Date: 3 October 2006 |
| 8 | |
| 9 | # TODO |
| 10 | # |
| 11 | # Assumes no function pointer parameters. unless they are typedefed. |
| 12 | # Assumes no literal strings that look like function definitions |
| 13 | # Assumes functions start at the beginning of a line |
| 14 | |
| 15 | use strict; |
| 16 | use warnings; |
| 17 | |
| 18 | local $/; |
| 19 | $_ = <>; |
| 20 | |
| 21 | my $sp = qr{ \s* (?: /\* .*? \*/ )? \s* }x; # assume no nested comments |
| 22 | |
| 23 | my $d1 = qr{ $sp (?: [\w\*\s]+ $sp)* $sp \w+ $sp [\[\]\s]* $sp }x ; |
| 24 | my $decl = qr{ $sp (?: \w+ $sp )+ $d1 }xo ; |
| 25 | my $dList = qr{ $sp $decl (?: $sp , $d1 )* $sp ; $sp }xo ; |
| 26 | |
| 27 | |
| 28 | while (s/^ |
| 29 | ( # Start $1 |
| 30 | ( # Start $2 |
| 31 | .*? # Minimal eat content |
| 32 | ( ^ \w [\w\s\*]+ ) # $3 -- function name |
| 33 | \s* # optional whitespace |
| 34 | ) # $2 - Matched up to before parameter list |
| 35 | |
| 36 | \( \s* # Literal "(" + optional whitespace |
| 37 | ( [^\)]+ ) # $4 - one or more anythings except ")" |
| 38 | \s* \) # optional whitespace surrounding a Literal ")" |
| 39 | |
| 40 | ( (?: $dList )+ ) # $5 |
| 41 | |
| 42 | $sp ^ { # literal "{" at start of line |
| 43 | ) # Remember to $1 |
| 44 | //xsom |
| 45 | ) |
| 46 | { |
| 47 | my $all = $1 ; |
| 48 | my $prefix = $2; |
| 49 | my $param_list = $4 ; |
| 50 | my $params = $5; |
| 51 | |
| 52 | StripComments($params); |
| 53 | StripComments($param_list); |
| 54 | $param_list =~ s/^\s+//; |
| 55 | $param_list =~ s/\s+$//; |
| 56 | |
| 57 | my $i = 0 ; |
| 58 | my %pList = map { $_ => $i++ } |
| 59 | split /\s*,\s*/, $param_list; |
| 60 | my $pMatch = '(\b' . join('|', keys %pList) . '\b)\W*$' ; |
| 61 | |
| 62 | my @params = split /\s*;\s*/, $params; |
| 63 | my @outParams = (); |
| 64 | foreach my $p (@params) |
| 65 | { |
| 66 | if ($p =~ /,/) |
| 67 | { |
| 68 | my @bits = split /\s*,\s*/, $p; |
| 69 | my $first = shift @bits; |
| 70 | $first =~ s/^\s*//; |
| 71 | push @outParams, $first; |
| 72 | $first =~ /^(\w+\s*)/; |
| 73 | my $type = $1 ; |
| 74 | push @outParams, map { $type . $_ } @bits; |
| 75 | } |
| 76 | else |
| 77 | { |
| 78 | $p =~ s/^\s+//; |
| 79 | push @outParams, $p; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | |
| 84 | my %tmp = map { /$pMatch/; $_ => $pList{$1} } |
| 85 | @outParams ; |
| 86 | |
| 87 | @outParams = map { " $_" } |
| 88 | sort { $tmp{$a} <=> $tmp{$b} } |
| 89 | @outParams ; |
| 90 | |
| 91 | print $prefix ; |
| 92 | print "(\n" . join(",\n", @outParams) . ")\n"; |
| 93 | print "{" ; |
| 94 | |
| 95 | } |
| 96 | |
| 97 | # Output any trailing code. |
| 98 | print ; |
| 99 | exit 0; |
| 100 | |
| 101 | |
| 102 | sub StripComments |
| 103 | { |
| 104 | |
| 105 | no warnings; |
| 106 | |
| 107 | # Strip C & C++ comments |
| 108 | # From the perlfaq |
| 109 | $_[0] =~ |
| 110 | |
| 111 | s{ |
| 112 | /\* ## Start of /* ... */ comment |
| 113 | [^*]*\*+ ## Non-* followed by 1-or-more *'s |
| 114 | ( |
| 115 | [^/*][^*]*\*+ |
| 116 | )* ## 0-or-more things which don't start with / |
| 117 | ## but do end with '*' |
| 118 | / ## End of /* ... */ comment |
| 119 | |
| 120 | | ## OR C++ Comment |
| 121 | // ## Start of C++ comment // |
| 122 | [^\n]* ## followed by 0-or-more non end of line characters |
| 123 | |
| 124 | | ## OR various things which aren't comments: |
| 125 | |
| 126 | ( |
| 127 | " ## Start of " ... " string |
| 128 | ( |
| 129 | \\. ## Escaped char |
| 130 | | ## OR |
| 131 | [^"\\] ## Non "\ |
| 132 | )* |
| 133 | " ## End of " ... " string |
| 134 | |
| 135 | | ## OR |
| 136 | |
| 137 | ' ## Start of ' ... ' string |
| 138 | ( |
| 139 | \\. ## Escaped char |
| 140 | | ## OR |
| 141 | [^'\\] ## Non '\ |
| 142 | )* |
| 143 | ' ## End of ' ... ' string |
| 144 | |
| 145 | | ## OR |
| 146 | |
| 147 | . ## Anything other char |
| 148 | [^/"'\\]* ## Chars which doesn't start a comment, string or escape |
| 149 | ) |
| 150 | }{$2}gxs; |
| 151 | |
| 152 | } |
| --- a/compat/zlib/zlib2ansi | |
| +++ b/compat/zlib/zlib2ansi | |
| @@ -1,152 +0,0 @@ | |
+16
-44
| --- compat/zlib/zutil.c | ||
| +++ compat/zlib/zutil.c | ||
| @@ -22,17 +22,15 @@ | ||
| 22 | 22 | (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ |
| 23 | 23 | (z_const char *)"" |
| 24 | 24 | }; |
| 25 | 25 | |
| 26 | 26 | |
| 27 | -const char * ZEXPORT zlibVersion() | |
| 28 | -{ | |
| 27 | +const char * ZEXPORT zlibVersion(void) { | |
| 29 | 28 | return ZLIB_VERSION; |
| 30 | 29 | } |
| 31 | 30 | |
| 32 | -uLong ZEXPORT zlibCompileFlags() | |
| 33 | -{ | |
| 31 | +uLong ZEXPORT zlibCompileFlags(void) { | |
| 34 | 32 | uLong flags; |
| 35 | 33 | |
| 36 | 34 | flags = 0; |
| 37 | 35 | switch ((int)(sizeof(uInt))) { |
| 38 | 36 | case 2: break; |
| @@ -119,24 +117,20 @@ | ||
| 119 | 117 | # ifndef verbose |
| 120 | 118 | # define verbose 0 |
| 121 | 119 | # endif |
| 122 | 120 | int ZLIB_INTERNAL z_verbose = verbose; |
| 123 | 121 | |
| 124 | -void ZLIB_INTERNAL z_error(m) | |
| 125 | - char *m; | |
| 126 | -{ | |
| 122 | +void ZLIB_INTERNAL z_error(char *m) { | |
| 127 | 123 | fprintf(stderr, "%s\n", m); |
| 128 | 124 | exit(1); |
| 129 | 125 | } |
| 130 | 126 | #endif |
| 131 | 127 | |
| 132 | 128 | /* exported to allow conversion of error code to string for compress() and |
| 133 | 129 | * uncompress() |
| 134 | 130 | */ |
| 135 | -const char * ZEXPORT zError(err) | |
| 136 | - int err; | |
| 137 | -{ | |
| 131 | +const char * ZEXPORT zError(int err) { | |
| 138 | 132 | return ERR_MSG(err); |
| 139 | 133 | } |
| 140 | 134 | |
| 141 | 135 | #if defined(_WIN32_WCE) && _WIN32_WCE < 0x800 |
| 142 | 136 | /* The older Microsoft C Run-Time Library for Windows CE doesn't have |
| @@ -146,38 +140,27 @@ | ||
| 146 | 140 | int errno = 0; |
| 147 | 141 | #endif |
| 148 | 142 | |
| 149 | 143 | #ifndef HAVE_MEMCPY |
| 150 | 144 | |
| 151 | -void ZLIB_INTERNAL zmemcpy(dest, source, len) | |
| 152 | - Bytef* dest; | |
| 153 | - const Bytef* source; | |
| 154 | - uInt len; | |
| 155 | -{ | |
| 145 | +void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) { | |
| 156 | 146 | if (len == 0) return; |
| 157 | 147 | do { |
| 158 | 148 | *dest++ = *source++; /* ??? to be unrolled */ |
| 159 | 149 | } while (--len != 0); |
| 160 | 150 | } |
| 161 | 151 | |
| 162 | -int ZLIB_INTERNAL zmemcmp(s1, s2, len) | |
| 163 | - const Bytef* s1; | |
| 164 | - const Bytef* s2; | |
| 165 | - uInt len; | |
| 166 | -{ | |
| 152 | +int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) { | |
| 167 | 153 | uInt j; |
| 168 | 154 | |
| 169 | 155 | for (j = 0; j < len; j++) { |
| 170 | 156 | if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; |
| 171 | 157 | } |
| 172 | 158 | return 0; |
| 173 | 159 | } |
| 174 | 160 | |
| 175 | -void ZLIB_INTERNAL zmemzero(dest, len) | |
| 176 | - Bytef* dest; | |
| 177 | - uInt len; | |
| 178 | -{ | |
| 161 | +void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) { | |
| 179 | 162 | if (len == 0) return; |
| 180 | 163 | do { |
| 181 | 164 | *dest++ = 0; /* ??? to be unrolled */ |
| 182 | 165 | } while (--len != 0); |
| 183 | 166 | } |
| @@ -214,12 +197,11 @@ | ||
| 214 | 197 | * Since MSDOS is not a preemptive multitasking OS, this table is not |
| 215 | 198 | * protected from concurrent access. This hack doesn't work anyway on |
| 216 | 199 | * a protected system like OS/2. Use Microsoft C instead. |
| 217 | 200 | */ |
| 218 | 201 | |
| 219 | -voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) | |
| 220 | -{ | |
| 202 | +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { | |
| 221 | 203 | voidpf buf; |
| 222 | 204 | ulg bsize = (ulg)items*size; |
| 223 | 205 | |
| 224 | 206 | (void)opaque; |
| 225 | 207 | |
| @@ -240,12 +222,11 @@ | ||
| 240 | 222 | *(ush*)&buf = 0; |
| 241 | 223 | table[next_ptr++].new_ptr = buf; |
| 242 | 224 | return buf; |
| 243 | 225 | } |
| 244 | 226 | |
| 245 | -void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) | |
| 246 | -{ | |
| 227 | +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { | |
| 247 | 228 | int n; |
| 248 | 229 | |
| 249 | 230 | (void)opaque; |
| 250 | 231 | |
| 251 | 232 | if (*(ush*)&ptr != 0) { /* object < 64K */ |
| @@ -277,18 +258,16 @@ | ||
| 277 | 258 | #if (!defined(_MSC_VER) || (_MSC_VER <= 600)) |
| 278 | 259 | # define _halloc halloc |
| 279 | 260 | # define _hfree hfree |
| 280 | 261 | #endif |
| 281 | 262 | |
| 282 | -voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) | |
| 283 | -{ | |
| 263 | +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) { | |
| 284 | 264 | (void)opaque; |
| 285 | 265 | return _halloc((long)items, size); |
| 286 | 266 | } |
| 287 | 267 | |
| 288 | -void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) | |
| 289 | -{ | |
| 268 | +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { | |
| 290 | 269 | (void)opaque; |
| 291 | 270 | _hfree(ptr); |
| 292 | 271 | } |
| 293 | 272 | |
| 294 | 273 | #endif /* M_I86 */ |
| @@ -297,31 +276,24 @@ | ||
| 297 | 276 | |
| 298 | 277 | |
| 299 | 278 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ |
| 300 | 279 | |
| 301 | 280 | #ifndef STDC |
| 302 | -extern voidp malloc OF((uInt size)); | |
| 303 | -extern voidp calloc OF((uInt items, uInt size)); | |
| 304 | -extern void free OF((voidpf ptr)); | |
| 281 | +extern voidp malloc(uInt size); | |
| 282 | +extern voidp calloc(uInt items, uInt size); | |
| 283 | +extern void free(voidpf ptr); | |
| 305 | 284 | #endif |
| 306 | 285 | |
| 307 | -voidpf ZLIB_INTERNAL zcalloc(opaque, items, size) | |
| 308 | - voidpf opaque; | |
| 309 | - unsigned items; | |
| 310 | - unsigned size; | |
| 311 | -{ | |
| 286 | +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { | |
| 312 | 287 | (void)opaque; |
| 313 | 288 | return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : |
| 314 | 289 | (voidpf)calloc(items, size); |
| 315 | 290 | } |
| 316 | 291 | |
| 317 | -void ZLIB_INTERNAL zcfree(opaque, ptr) | |
| 318 | - voidpf opaque; | |
| 319 | - voidpf ptr; | |
| 320 | -{ | |
| 292 | +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { | |
| 321 | 293 | (void)opaque; |
| 322 | 294 | free(ptr); |
| 323 | 295 | } |
| 324 | 296 | |
| 325 | 297 | #endif /* MY_ZCALLOC */ |
| 326 | 298 | |
| 327 | 299 | #endif /* !Z_SOLO */ |
| 328 | 300 |
| --- compat/zlib/zutil.c | |
| +++ compat/zlib/zutil.c | |
| @@ -22,17 +22,15 @@ | |
| 22 | (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ |
| 23 | (z_const char *)"" |
| 24 | }; |
| 25 | |
| 26 | |
| 27 | const char * ZEXPORT zlibVersion() |
| 28 | { |
| 29 | return ZLIB_VERSION; |
| 30 | } |
| 31 | |
| 32 | uLong ZEXPORT zlibCompileFlags() |
| 33 | { |
| 34 | uLong flags; |
| 35 | |
| 36 | flags = 0; |
| 37 | switch ((int)(sizeof(uInt))) { |
| 38 | case 2: break; |
| @@ -119,24 +117,20 @@ | |
| 119 | # ifndef verbose |
| 120 | # define verbose 0 |
| 121 | # endif |
| 122 | int ZLIB_INTERNAL z_verbose = verbose; |
| 123 | |
| 124 | void ZLIB_INTERNAL z_error(m) |
| 125 | char *m; |
| 126 | { |
| 127 | fprintf(stderr, "%s\n", m); |
| 128 | exit(1); |
| 129 | } |
| 130 | #endif |
| 131 | |
| 132 | /* exported to allow conversion of error code to string for compress() and |
| 133 | * uncompress() |
| 134 | */ |
| 135 | const char * ZEXPORT zError(err) |
| 136 | int err; |
| 137 | { |
| 138 | return ERR_MSG(err); |
| 139 | } |
| 140 | |
| 141 | #if defined(_WIN32_WCE) && _WIN32_WCE < 0x800 |
| 142 | /* The older Microsoft C Run-Time Library for Windows CE doesn't have |
| @@ -146,38 +140,27 @@ | |
| 146 | int errno = 0; |
| 147 | #endif |
| 148 | |
| 149 | #ifndef HAVE_MEMCPY |
| 150 | |
| 151 | void ZLIB_INTERNAL zmemcpy(dest, source, len) |
| 152 | Bytef* dest; |
| 153 | const Bytef* source; |
| 154 | uInt len; |
| 155 | { |
| 156 | if (len == 0) return; |
| 157 | do { |
| 158 | *dest++ = *source++; /* ??? to be unrolled */ |
| 159 | } while (--len != 0); |
| 160 | } |
| 161 | |
| 162 | int ZLIB_INTERNAL zmemcmp(s1, s2, len) |
| 163 | const Bytef* s1; |
| 164 | const Bytef* s2; |
| 165 | uInt len; |
| 166 | { |
| 167 | uInt j; |
| 168 | |
| 169 | for (j = 0; j < len; j++) { |
| 170 | if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; |
| 171 | } |
| 172 | return 0; |
| 173 | } |
| 174 | |
| 175 | void ZLIB_INTERNAL zmemzero(dest, len) |
| 176 | Bytef* dest; |
| 177 | uInt len; |
| 178 | { |
| 179 | if (len == 0) return; |
| 180 | do { |
| 181 | *dest++ = 0; /* ??? to be unrolled */ |
| 182 | } while (--len != 0); |
| 183 | } |
| @@ -214,12 +197,11 @@ | |
| 214 | * Since MSDOS is not a preemptive multitasking OS, this table is not |
| 215 | * protected from concurrent access. This hack doesn't work anyway on |
| 216 | * a protected system like OS/2. Use Microsoft C instead. |
| 217 | */ |
| 218 | |
| 219 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) |
| 220 | { |
| 221 | voidpf buf; |
| 222 | ulg bsize = (ulg)items*size; |
| 223 | |
| 224 | (void)opaque; |
| 225 | |
| @@ -240,12 +222,11 @@ | |
| 240 | *(ush*)&buf = 0; |
| 241 | table[next_ptr++].new_ptr = buf; |
| 242 | return buf; |
| 243 | } |
| 244 | |
| 245 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) |
| 246 | { |
| 247 | int n; |
| 248 | |
| 249 | (void)opaque; |
| 250 | |
| 251 | if (*(ush*)&ptr != 0) { /* object < 64K */ |
| @@ -277,18 +258,16 @@ | |
| 277 | #if (!defined(_MSC_VER) || (_MSC_VER <= 600)) |
| 278 | # define _halloc halloc |
| 279 | # define _hfree hfree |
| 280 | #endif |
| 281 | |
| 282 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) |
| 283 | { |
| 284 | (void)opaque; |
| 285 | return _halloc((long)items, size); |
| 286 | } |
| 287 | |
| 288 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) |
| 289 | { |
| 290 | (void)opaque; |
| 291 | _hfree(ptr); |
| 292 | } |
| 293 | |
| 294 | #endif /* M_I86 */ |
| @@ -297,31 +276,24 @@ | |
| 297 | |
| 298 | |
| 299 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ |
| 300 | |
| 301 | #ifndef STDC |
| 302 | extern voidp malloc OF((uInt size)); |
| 303 | extern voidp calloc OF((uInt items, uInt size)); |
| 304 | extern void free OF((voidpf ptr)); |
| 305 | #endif |
| 306 | |
| 307 | voidpf ZLIB_INTERNAL zcalloc(opaque, items, size) |
| 308 | voidpf opaque; |
| 309 | unsigned items; |
| 310 | unsigned size; |
| 311 | { |
| 312 | (void)opaque; |
| 313 | return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : |
| 314 | (voidpf)calloc(items, size); |
| 315 | } |
| 316 | |
| 317 | void ZLIB_INTERNAL zcfree(opaque, ptr) |
| 318 | voidpf opaque; |
| 319 | voidpf ptr; |
| 320 | { |
| 321 | (void)opaque; |
| 322 | free(ptr); |
| 323 | } |
| 324 | |
| 325 | #endif /* MY_ZCALLOC */ |
| 326 | |
| 327 | #endif /* !Z_SOLO */ |
| 328 |
| --- compat/zlib/zutil.c | |
| +++ compat/zlib/zutil.c | |
| @@ -22,17 +22,15 @@ | |
| 22 | (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ |
| 23 | (z_const char *)"" |
| 24 | }; |
| 25 | |
| 26 | |
| 27 | const char * ZEXPORT zlibVersion(void) { |
| 28 | return ZLIB_VERSION; |
| 29 | } |
| 30 | |
| 31 | uLong ZEXPORT zlibCompileFlags(void) { |
| 32 | uLong flags; |
| 33 | |
| 34 | flags = 0; |
| 35 | switch ((int)(sizeof(uInt))) { |
| 36 | case 2: break; |
| @@ -119,24 +117,20 @@ | |
| 117 | # ifndef verbose |
| 118 | # define verbose 0 |
| 119 | # endif |
| 120 | int ZLIB_INTERNAL z_verbose = verbose; |
| 121 | |
| 122 | void ZLIB_INTERNAL z_error(char *m) { |
| 123 | fprintf(stderr, "%s\n", m); |
| 124 | exit(1); |
| 125 | } |
| 126 | #endif |
| 127 | |
| 128 | /* exported to allow conversion of error code to string for compress() and |
| 129 | * uncompress() |
| 130 | */ |
| 131 | const char * ZEXPORT zError(int err) { |
| 132 | return ERR_MSG(err); |
| 133 | } |
| 134 | |
| 135 | #if defined(_WIN32_WCE) && _WIN32_WCE < 0x800 |
| 136 | /* The older Microsoft C Run-Time Library for Windows CE doesn't have |
| @@ -146,38 +140,27 @@ | |
| 140 | int errno = 0; |
| 141 | #endif |
| 142 | |
| 143 | #ifndef HAVE_MEMCPY |
| 144 | |
| 145 | void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) { |
| 146 | if (len == 0) return; |
| 147 | do { |
| 148 | *dest++ = *source++; /* ??? to be unrolled */ |
| 149 | } while (--len != 0); |
| 150 | } |
| 151 | |
| 152 | int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) { |
| 153 | uInt j; |
| 154 | |
| 155 | for (j = 0; j < len; j++) { |
| 156 | if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; |
| 157 | } |
| 158 | return 0; |
| 159 | } |
| 160 | |
| 161 | void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) { |
| 162 | if (len == 0) return; |
| 163 | do { |
| 164 | *dest++ = 0; /* ??? to be unrolled */ |
| 165 | } while (--len != 0); |
| 166 | } |
| @@ -214,12 +197,11 @@ | |
| 197 | * Since MSDOS is not a preemptive multitasking OS, this table is not |
| 198 | * protected from concurrent access. This hack doesn't work anyway on |
| 199 | * a protected system like OS/2. Use Microsoft C instead. |
| 200 | */ |
| 201 | |
| 202 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { |
| 203 | voidpf buf; |
| 204 | ulg bsize = (ulg)items*size; |
| 205 | |
| 206 | (void)opaque; |
| 207 | |
| @@ -240,12 +222,11 @@ | |
| 222 | *(ush*)&buf = 0; |
| 223 | table[next_ptr++].new_ptr = buf; |
| 224 | return buf; |
| 225 | } |
| 226 | |
| 227 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { |
| 228 | int n; |
| 229 | |
| 230 | (void)opaque; |
| 231 | |
| 232 | if (*(ush*)&ptr != 0) { /* object < 64K */ |
| @@ -277,18 +258,16 @@ | |
| 258 | #if (!defined(_MSC_VER) || (_MSC_VER <= 600)) |
| 259 | # define _halloc halloc |
| 260 | # define _hfree hfree |
| 261 | #endif |
| 262 | |
| 263 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) { |
| 264 | (void)opaque; |
| 265 | return _halloc((long)items, size); |
| 266 | } |
| 267 | |
| 268 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { |
| 269 | (void)opaque; |
| 270 | _hfree(ptr); |
| 271 | } |
| 272 | |
| 273 | #endif /* M_I86 */ |
| @@ -297,31 +276,24 @@ | |
| 276 | |
| 277 | |
| 278 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ |
| 279 | |
| 280 | #ifndef STDC |
| 281 | extern voidp malloc(uInt size); |
| 282 | extern voidp calloc(uInt items, uInt size); |
| 283 | extern void free(voidpf ptr); |
| 284 | #endif |
| 285 | |
| 286 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { |
| 287 | (void)opaque; |
| 288 | return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : |
| 289 | (voidpf)calloc(items, size); |
| 290 | } |
| 291 | |
| 292 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { |
| 293 | (void)opaque; |
| 294 | free(ptr); |
| 295 | } |
| 296 | |
| 297 | #endif /* MY_ZCALLOC */ |
| 298 | |
| 299 | #endif /* !Z_SOLO */ |
| 300 |
+10
-10
| --- compat/zlib/zutil.h | ||
| +++ compat/zlib/zutil.h | ||
| @@ -189,13 +189,13 @@ | ||
| 189 | 189 | #endif |
| 190 | 190 | |
| 191 | 191 | /* provide prototypes for these when building zlib without LFS */ |
| 192 | 192 | #if !defined(_WIN32) && \ |
| 193 | 193 | (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) |
| 194 | - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); | |
| 195 | - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); | |
| 196 | - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); | |
| 194 | + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); | |
| 195 | + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); | |
| 196 | + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); | |
| 197 | 197 | #endif |
| 198 | 198 | |
| 199 | 199 | /* common defaults */ |
| 200 | 200 | |
| 201 | 201 | #ifndef OS_CODE |
| @@ -230,20 +230,20 @@ | ||
| 230 | 230 | # define zmemcpy memcpy |
| 231 | 231 | # define zmemcmp memcmp |
| 232 | 232 | # define zmemzero(dest, len) memset(dest, 0, len) |
| 233 | 233 | # endif |
| 234 | 234 | #else |
| 235 | - void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); | |
| 236 | - int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); | |
| 237 | - void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); | |
| 235 | + void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len); | |
| 236 | + int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len); | |
| 237 | + void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len); | |
| 238 | 238 | #endif |
| 239 | 239 | |
| 240 | 240 | /* Diagnostic functions */ |
| 241 | 241 | #ifdef ZLIB_DEBUG |
| 242 | 242 | # include <stdio.h> |
| 243 | 243 | extern int ZLIB_INTERNAL z_verbose; |
| 244 | - extern void ZLIB_INTERNAL z_error OF((char *m)); | |
| 244 | + extern void ZLIB_INTERNAL z_error(char *m); | |
| 245 | 245 | # define Assert(cond,msg) {if(!(cond)) z_error(msg);} |
| 246 | 246 | # define Trace(x) {if (z_verbose>=0) fprintf x ;} |
| 247 | 247 | # define Tracev(x) {if (z_verbose>0) fprintf x ;} |
| 248 | 248 | # define Tracevv(x) {if (z_verbose>1) fprintf x ;} |
| 249 | 249 | # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} |
| @@ -256,13 +256,13 @@ | ||
| 256 | 256 | # define Tracec(c,x) |
| 257 | 257 | # define Tracecv(c,x) |
| 258 | 258 | #endif |
| 259 | 259 | |
| 260 | 260 | #ifndef Z_SOLO |
| 261 | - voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, | |
| 262 | - unsigned size)); | |
| 263 | - void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); | |
| 261 | + voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, | |
| 262 | + unsigned size); | |
| 263 | + void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr); | |
| 264 | 264 | #endif |
| 265 | 265 | |
| 266 | 266 | #define ZALLOC(strm, items, size) \ |
| 267 | 267 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) |
| 268 | 268 | #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) |
| 269 | 269 |
| --- compat/zlib/zutil.h | |
| +++ compat/zlib/zutil.h | |
| @@ -189,13 +189,13 @@ | |
| 189 | #endif |
| 190 | |
| 191 | /* provide prototypes for these when building zlib without LFS */ |
| 192 | #if !defined(_WIN32) && \ |
| 193 | (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) |
| 194 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); |
| 195 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); |
| 196 | ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); |
| 197 | #endif |
| 198 | |
| 199 | /* common defaults */ |
| 200 | |
| 201 | #ifndef OS_CODE |
| @@ -230,20 +230,20 @@ | |
| 230 | # define zmemcpy memcpy |
| 231 | # define zmemcmp memcmp |
| 232 | # define zmemzero(dest, len) memset(dest, 0, len) |
| 233 | # endif |
| 234 | #else |
| 235 | void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); |
| 236 | int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); |
| 237 | void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); |
| 238 | #endif |
| 239 | |
| 240 | /* Diagnostic functions */ |
| 241 | #ifdef ZLIB_DEBUG |
| 242 | # include <stdio.h> |
| 243 | extern int ZLIB_INTERNAL z_verbose; |
| 244 | extern void ZLIB_INTERNAL z_error OF((char *m)); |
| 245 | # define Assert(cond,msg) {if(!(cond)) z_error(msg);} |
| 246 | # define Trace(x) {if (z_verbose>=0) fprintf x ;} |
| 247 | # define Tracev(x) {if (z_verbose>0) fprintf x ;} |
| 248 | # define Tracevv(x) {if (z_verbose>1) fprintf x ;} |
| 249 | # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} |
| @@ -256,13 +256,13 @@ | |
| 256 | # define Tracec(c,x) |
| 257 | # define Tracecv(c,x) |
| 258 | #endif |
| 259 | |
| 260 | #ifndef Z_SOLO |
| 261 | voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, |
| 262 | unsigned size)); |
| 263 | void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); |
| 264 | #endif |
| 265 | |
| 266 | #define ZALLOC(strm, items, size) \ |
| 267 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) |
| 268 | #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) |
| 269 |
| --- compat/zlib/zutil.h | |
| +++ compat/zlib/zutil.h | |
| @@ -189,13 +189,13 @@ | |
| 189 | #endif |
| 190 | |
| 191 | /* provide prototypes for these when building zlib without LFS */ |
| 192 | #if !defined(_WIN32) && \ |
| 193 | (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) |
| 194 | ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); |
| 195 | ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); |
| 196 | ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); |
| 197 | #endif |
| 198 | |
| 199 | /* common defaults */ |
| 200 | |
| 201 | #ifndef OS_CODE |
| @@ -230,20 +230,20 @@ | |
| 230 | # define zmemcpy memcpy |
| 231 | # define zmemcmp memcmp |
| 232 | # define zmemzero(dest, len) memset(dest, 0, len) |
| 233 | # endif |
| 234 | #else |
| 235 | void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len); |
| 236 | int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len); |
| 237 | void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len); |
| 238 | #endif |
| 239 | |
| 240 | /* Diagnostic functions */ |
| 241 | #ifdef ZLIB_DEBUG |
| 242 | # include <stdio.h> |
| 243 | extern int ZLIB_INTERNAL z_verbose; |
| 244 | extern void ZLIB_INTERNAL z_error(char *m); |
| 245 | # define Assert(cond,msg) {if(!(cond)) z_error(msg);} |
| 246 | # define Trace(x) {if (z_verbose>=0) fprintf x ;} |
| 247 | # define Tracev(x) {if (z_verbose>0) fprintf x ;} |
| 248 | # define Tracevv(x) {if (z_verbose>1) fprintf x ;} |
| 249 | # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} |
| @@ -256,13 +256,13 @@ | |
| 256 | # define Tracec(c,x) |
| 257 | # define Tracecv(c,x) |
| 258 | #endif |
| 259 | |
| 260 | #ifndef Z_SOLO |
| 261 | voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, |
| 262 | unsigned size); |
| 263 | void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr); |
| 264 | #endif |
| 265 | |
| 266 | #define ZALLOC(strm, items, size) \ |
| 267 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) |
| 268 | #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) |
| 269 |