hane 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/binding.gyp +87 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +1 -0
- package/package.json +33 -0
- package/src/native/addon.cc +231 -0
- package/src/native/zsign_driver.cc +87 -0
- package/src/native/zsign_driver.h +38 -0
- package/vendor/zlib/.cmake-format.yaml +245 -0
- package/vendor/zlib/.github/workflows/c-std.yml +230 -0
- package/vendor/zlib/.github/workflows/cmake.yml +112 -0
- package/vendor/zlib/.github/workflows/configure.yml +136 -0
- package/vendor/zlib/.github/workflows/fuzz.yml +25 -0
- package/vendor/zlib/.github/workflows/msys-cygwin.yml +77 -0
- package/vendor/zlib/BUILD.bazel +134 -0
- package/vendor/zlib/CMakeLists.txt +330 -0
- package/vendor/zlib/ChangeLog +1621 -0
- package/vendor/zlib/FAQ +367 -0
- package/vendor/zlib/INDEX +68 -0
- package/vendor/zlib/LICENSE +22 -0
- package/vendor/zlib/MODULE.bazel +9 -0
- package/vendor/zlib/Makefile.in +419 -0
- package/vendor/zlib/README +115 -0
- package/vendor/zlib/README-cmake.md +83 -0
- package/vendor/zlib/adler32.c +164 -0
- package/vendor/zlib/amiga/Makefile.pup +69 -0
- package/vendor/zlib/amiga/Makefile.sas +68 -0
- package/vendor/zlib/compress.c +75 -0
- package/vendor/zlib/configure +966 -0
- package/vendor/zlib/contrib/README.contrib +57 -0
- package/vendor/zlib/contrib/ada/buffer_demo.adb +106 -0
- package/vendor/zlib/contrib/ada/mtest.adb +156 -0
- package/vendor/zlib/contrib/ada/read.adb +156 -0
- package/vendor/zlib/contrib/ada/readme.txt +65 -0
- package/vendor/zlib/contrib/ada/test.adb +463 -0
- package/vendor/zlib/contrib/ada/zlib-streams.adb +225 -0
- package/vendor/zlib/contrib/ada/zlib-streams.ads +114 -0
- package/vendor/zlib/contrib/ada/zlib-thin.adb +142 -0
- package/vendor/zlib/contrib/ada/zlib-thin.ads +450 -0
- package/vendor/zlib/contrib/ada/zlib.adb +701 -0
- package/vendor/zlib/contrib/ada/zlib.ads +328 -0
- package/vendor/zlib/contrib/ada/zlib.gpr +20 -0
- package/vendor/zlib/contrib/blast/Makefile +8 -0
- package/vendor/zlib/contrib/blast/README +4 -0
- package/vendor/zlib/contrib/blast/blast.c +466 -0
- package/vendor/zlib/contrib/blast/blast.h +83 -0
- package/vendor/zlib/contrib/blast/test.pk +0 -0
- package/vendor/zlib/contrib/blast/test.txt +1 -0
- package/vendor/zlib/contrib/delphi/ZLib.pas +557 -0
- package/vendor/zlib/contrib/delphi/ZLibConst.pas +11 -0
- package/vendor/zlib/contrib/delphi/readme.txt +76 -0
- package/vendor/zlib/contrib/delphi/zlibd32.mak +99 -0
- package/vendor/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs +58 -0
- package/vendor/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs +202 -0
- package/vendor/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs +83 -0
- package/vendor/zlib/contrib/dotzlib/DotZLib/CodecBase.cs +198 -0
- package/vendor/zlib/contrib/dotzlib/DotZLib/Deflater.cs +106 -0
- package/vendor/zlib/contrib/dotzlib/DotZLib/DotZLib.cs +288 -0
- package/vendor/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj +141 -0
- package/vendor/zlib/contrib/dotzlib/DotZLib/GZipStream.cs +301 -0
- package/vendor/zlib/contrib/dotzlib/DotZLib/Inflater.cs +105 -0
- package/vendor/zlib/contrib/dotzlib/DotZLib/UnitTests.cs +274 -0
- package/vendor/zlib/contrib/dotzlib/DotZLib.build +33 -0
- package/vendor/zlib/contrib/dotzlib/DotZLib.chm +0 -0
- package/vendor/zlib/contrib/dotzlib/DotZLib.sln +21 -0
- package/vendor/zlib/contrib/dotzlib/LICENSE_1_0.txt +23 -0
- package/vendor/zlib/contrib/dotzlib/readme.txt +58 -0
- package/vendor/zlib/contrib/gcc_gvmat64/gvmat64.S +574 -0
- package/vendor/zlib/contrib/infback9/README +1 -0
- package/vendor/zlib/contrib/infback9/infback9.c +603 -0
- package/vendor/zlib/contrib/infback9/infback9.h +37 -0
- package/vendor/zlib/contrib/infback9/inffix9.h +107 -0
- package/vendor/zlib/contrib/infback9/inflate9.h +47 -0
- package/vendor/zlib/contrib/infback9/inftree9.c +319 -0
- package/vendor/zlib/contrib/infback9/inftree9.h +61 -0
- package/vendor/zlib/contrib/iostream/test.cpp +24 -0
- package/vendor/zlib/contrib/iostream/zfstream.cpp +329 -0
- package/vendor/zlib/contrib/iostream/zfstream.h +128 -0
- package/vendor/zlib/contrib/iostream2/zstream.h +307 -0
- package/vendor/zlib/contrib/iostream2/zstream_test.cpp +25 -0
- package/vendor/zlib/contrib/iostream3/README +35 -0
- package/vendor/zlib/contrib/iostream3/TODO +17 -0
- package/vendor/zlib/contrib/iostream3/test.cc +50 -0
- package/vendor/zlib/contrib/iostream3/zfstream.cc +479 -0
- package/vendor/zlib/contrib/iostream3/zfstream.h +466 -0
- package/vendor/zlib/contrib/minizip/CMakeLists.txt +380 -0
- package/vendor/zlib/contrib/minizip/Makefile +37 -0
- package/vendor/zlib/contrib/minizip/Makefile.am +45 -0
- package/vendor/zlib/contrib/minizip/MiniZip64_Changes.txt +6 -0
- package/vendor/zlib/contrib/minizip/MiniZip64_info.txt +74 -0
- package/vendor/zlib/contrib/minizip/configure.ac +32 -0
- package/vendor/zlib/contrib/minizip/crypt.h +128 -0
- package/vendor/zlib/contrib/minizip/ints.h +57 -0
- package/vendor/zlib/contrib/minizip/ioapi.c +231 -0
- package/vendor/zlib/contrib/minizip/ioapi.h +183 -0
- package/vendor/zlib/contrib/minizip/iowin32.c +448 -0
- package/vendor/zlib/contrib/minizip/iowin32.h +28 -0
- package/vendor/zlib/contrib/minizip/make_vms.com +25 -0
- package/vendor/zlib/contrib/minizip/miniunz.c +647 -0
- package/vendor/zlib/contrib/minizip/miniunzip.1 +63 -0
- package/vendor/zlib/contrib/minizip/minizip.1 +46 -0
- package/vendor/zlib/contrib/minizip/minizip.c +512 -0
- package/vendor/zlib/contrib/minizip/minizip.pc.in +12 -0
- package/vendor/zlib/contrib/minizip/minizip.pc.txt +13 -0
- package/vendor/zlib/contrib/minizip/minizipConfig.cmake.in +35 -0
- package/vendor/zlib/contrib/minizip/mztools.c +288 -0
- package/vendor/zlib/contrib/minizip/mztools.h +37 -0
- package/vendor/zlib/contrib/minizip/skipset.h +361 -0
- package/vendor/zlib/contrib/minizip/test/CMakeLists.txt +121 -0
- package/vendor/zlib/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in +29 -0
- package/vendor/zlib/contrib/minizip/test/add_subdirectory_test.cmake.in +28 -0
- package/vendor/zlib/contrib/minizip/test/find_package_test.cmake.in +25 -0
- package/vendor/zlib/contrib/minizip/test/test_helper.cm +32 -0
- package/vendor/zlib/contrib/minizip/unzip.c +1981 -0
- package/vendor/zlib/contrib/minizip/unzip.h +441 -0
- package/vendor/zlib/contrib/minizip/zip.c +2199 -0
- package/vendor/zlib/contrib/minizip/zip.h +370 -0
- package/vendor/zlib/contrib/nuget/nuget.csproj +43 -0
- package/vendor/zlib/contrib/nuget/nuget.sln +22 -0
- package/vendor/zlib/contrib/pascal/example.pas +599 -0
- package/vendor/zlib/contrib/pascal/readme.txt +76 -0
- package/vendor/zlib/contrib/pascal/zlibd32.mak +99 -0
- package/vendor/zlib/contrib/pascal/zlibpas.pas +276 -0
- package/vendor/zlib/contrib/puff/Makefile +42 -0
- package/vendor/zlib/contrib/puff/README +63 -0
- package/vendor/zlib/contrib/puff/puff.c +840 -0
- package/vendor/zlib/contrib/puff/puff.h +35 -0
- package/vendor/zlib/contrib/puff/pufftest.c +169 -0
- package/vendor/zlib/contrib/puff/zeros.raw +0 -0
- package/vendor/zlib/contrib/testzlib/testzlib.c +275 -0
- package/vendor/zlib/contrib/testzlib/testzlib.txt +10 -0
- package/vendor/zlib/contrib/untgz/Makefile +14 -0
- package/vendor/zlib/contrib/untgz/Makefile.msc +17 -0
- package/vendor/zlib/contrib/untgz/untgz.c +667 -0
- package/vendor/zlib/contrib/vstudio/readme.txt +81 -0
- package/vendor/zlib/contrib/vstudio/vc10/miniunz.vcxproj +310 -0
- package/vendor/zlib/contrib/vstudio/vc10/miniunz.vcxproj.filters +22 -0
- package/vendor/zlib/contrib/vstudio/vc10/minizip.vcxproj +307 -0
- package/vendor/zlib/contrib/vstudio/vc10/minizip.vcxproj.filters +22 -0
- package/vendor/zlib/contrib/vstudio/vc10/testzlib.vcxproj +412 -0
- package/vendor/zlib/contrib/vstudio/vc10/testzlib.vcxproj.filters +55 -0
- package/vendor/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj +310 -0
- package/vendor/zlib/contrib/vstudio/vc10/testzlibdll.vcxproj.filters +22 -0
- package/vendor/zlib/contrib/vstudio/vc10/zlib.rc +32 -0
- package/vendor/zlib/contrib/vstudio/vc10/zlibstat.vcxproj +449 -0
- package/vendor/zlib/contrib/vstudio/vc10/zlibstat.vcxproj.filters +74 -0
- package/vendor/zlib/contrib/vstudio/vc10/zlibvc.def +161 -0
- package/vendor/zlib/contrib/vstudio/vc10/zlibvc.sln +135 -0
- package/vendor/zlib/contrib/vstudio/vc10/zlibvc.vcxproj +633 -0
- package/vendor/zlib/contrib/vstudio/vc10/zlibvc.vcxproj.filters +115 -0
- package/vendor/zlib/contrib/vstudio/vc11/miniunz.vcxproj +314 -0
- package/vendor/zlib/contrib/vstudio/vc11/minizip.vcxproj +311 -0
- package/vendor/zlib/contrib/vstudio/vc11/testzlib.vcxproj +418 -0
- package/vendor/zlib/contrib/vstudio/vc11/testzlibdll.vcxproj +314 -0
- package/vendor/zlib/contrib/vstudio/vc11/zlib.rc +32 -0
- package/vendor/zlib/contrib/vstudio/vc11/zlibstat.vcxproj +456 -0
- package/vendor/zlib/contrib/vstudio/vc11/zlibvc.def +161 -0
- package/vendor/zlib/contrib/vstudio/vc11/zlibvc.sln +117 -0
- package/vendor/zlib/contrib/vstudio/vc11/zlibvc.vcxproj +664 -0
- package/vendor/zlib/contrib/vstudio/vc12/miniunz.vcxproj +316 -0
- package/vendor/zlib/contrib/vstudio/vc12/minizip.vcxproj +313 -0
- package/vendor/zlib/contrib/vstudio/vc12/testzlib.vcxproj +422 -0
- package/vendor/zlib/contrib/vstudio/vc12/testzlibdll.vcxproj +316 -0
- package/vendor/zlib/contrib/vstudio/vc12/zlib.rc +32 -0
- package/vendor/zlib/contrib/vstudio/vc12/zlibstat.vcxproj +459 -0
- package/vendor/zlib/contrib/vstudio/vc12/zlibvc.def +161 -0
- package/vendor/zlib/contrib/vstudio/vc12/zlibvc.sln +119 -0
- package/vendor/zlib/contrib/vstudio/vc12/zlibvc.vcxproj +668 -0
- package/vendor/zlib/contrib/vstudio/vc14/miniunz.vcxproj +316 -0
- package/vendor/zlib/contrib/vstudio/vc14/minizip.vcxproj +313 -0
- package/vendor/zlib/contrib/vstudio/vc14/testzlib.vcxproj +422 -0
- package/vendor/zlib/contrib/vstudio/vc14/testzlibdll.vcxproj +316 -0
- package/vendor/zlib/contrib/vstudio/vc14/zlib.rc +32 -0
- package/vendor/zlib/contrib/vstudio/vc14/zlibstat.vcxproj +459 -0
- package/vendor/zlib/contrib/vstudio/vc14/zlibvc.def +161 -0
- package/vendor/zlib/contrib/vstudio/vc14/zlibvc.sln +119 -0
- package/vendor/zlib/contrib/vstudio/vc14/zlibvc.vcxproj +668 -0
- package/vendor/zlib/contrib/vstudio/vc17/miniunz.vcxproj +409 -0
- package/vendor/zlib/contrib/vstudio/vc17/minizip.vcxproj +405 -0
- package/vendor/zlib/contrib/vstudio/vc17/testzlib.vcxproj +473 -0
- package/vendor/zlib/contrib/vstudio/vc17/testzlibdll.vcxproj +409 -0
- package/vendor/zlib/contrib/vstudio/vc17/zlib.rc +32 -0
- package/vendor/zlib/contrib/vstudio/vc17/zlibstat.vcxproj +602 -0
- package/vendor/zlib/contrib/vstudio/vc17/zlibvc.def +161 -0
- package/vendor/zlib/contrib/vstudio/vc17/zlibvc.sln +179 -0
- package/vendor/zlib/contrib/vstudio/vc17/zlibvc.vcxproj +875 -0
- package/vendor/zlib/contrib/vstudio/vc9/miniunz.vcproj +565 -0
- package/vendor/zlib/contrib/vstudio/vc9/minizip.vcproj +562 -0
- package/vendor/zlib/contrib/vstudio/vc9/testzlib.vcproj +796 -0
- package/vendor/zlib/contrib/vstudio/vc9/testzlibdll.vcproj +565 -0
- package/vendor/zlib/contrib/vstudio/vc9/zlib.rc +32 -0
- package/vendor/zlib/contrib/vstudio/vc9/zlibstat.vcproj +781 -0
- package/vendor/zlib/contrib/vstudio/vc9/zlibvc.def +161 -0
- package/vendor/zlib/contrib/vstudio/vc9/zlibvc.sln +144 -0
- package/vendor/zlib/contrib/vstudio/vc9/zlibvc.vcproj +1100 -0
- package/vendor/zlib/crc32.c +1049 -0
- package/vendor/zlib/crc32.h +9446 -0
- package/vendor/zlib/deflate.c +2152 -0
- package/vendor/zlib/deflate.h +380 -0
- package/vendor/zlib/doc/algorithm.txt +209 -0
- package/vendor/zlib/doc/crc-doc.1.0.pdf +0 -0
- package/vendor/zlib/doc/rfc1950.txt +619 -0
- package/vendor/zlib/doc/rfc1951.txt +955 -0
- package/vendor/zlib/doc/rfc1952.txt +675 -0
- package/vendor/zlib/doc/txtvsbin.txt +107 -0
- package/vendor/zlib/examples/README.examples +54 -0
- package/vendor/zlib/examples/enough.c +597 -0
- package/vendor/zlib/examples/fitblk.c +233 -0
- package/vendor/zlib/examples/gun.c +702 -0
- package/vendor/zlib/examples/gzappend.c +504 -0
- package/vendor/zlib/examples/gzjoin.c +449 -0
- package/vendor/zlib/examples/gzlog.c +1061 -0
- package/vendor/zlib/examples/gzlog.h +91 -0
- package/vendor/zlib/examples/gznorm.c +474 -0
- package/vendor/zlib/examples/zlib_how.html +549 -0
- package/vendor/zlib/examples/zpipe.c +209 -0
- package/vendor/zlib/examples/zran.c +550 -0
- package/vendor/zlib/examples/zran.h +53 -0
- package/vendor/zlib/gzclose.c +23 -0
- package/vendor/zlib/gzguts.h +215 -0
- package/vendor/zlib/gzlib.c +585 -0
- package/vendor/zlib/gzread.c +603 -0
- package/vendor/zlib/gzwrite.c +631 -0
- package/vendor/zlib/infback.c +628 -0
- package/vendor/zlib/inffast.c +320 -0
- package/vendor/zlib/inffast.h +11 -0
- package/vendor/zlib/inffixed.h +94 -0
- package/vendor/zlib/inflate.c +1526 -0
- package/vendor/zlib/inflate.h +126 -0
- package/vendor/zlib/inftrees.c +299 -0
- package/vendor/zlib/inftrees.h +62 -0
- package/vendor/zlib/make_vms.com +867 -0
- package/vendor/zlib/msdos/Makefile.bor +115 -0
- package/vendor/zlib/msdos/Makefile.dj2 +104 -0
- package/vendor/zlib/msdos/Makefile.emx +69 -0
- package/vendor/zlib/msdos/Makefile.msc +112 -0
- package/vendor/zlib/msdos/Makefile.tc +100 -0
- package/vendor/zlib/nintendods/Makefile +126 -0
- package/vendor/zlib/nintendods/README +5 -0
- package/vendor/zlib/old/Makefile.emx +69 -0
- package/vendor/zlib/old/Makefile.riscos +151 -0
- package/vendor/zlib/old/README +3 -0
- package/vendor/zlib/old/descrip.mms +48 -0
- package/vendor/zlib/old/os2/Makefile.os2 +136 -0
- package/vendor/zlib/old/os2/zlib.def +51 -0
- package/vendor/zlib/old/visual-basic.txt +160 -0
- package/vendor/zlib/os400/README400 +48 -0
- package/vendor/zlib/os400/bndsrc +133 -0
- package/vendor/zlib/os400/make.sh +366 -0
- package/vendor/zlib/os400/zlib.inc +531 -0
- package/vendor/zlib/qnx/package.qpg +141 -0
- package/vendor/zlib/test/CMakeLists.txt +265 -0
- package/vendor/zlib/test/add_subdirectory_exclude_test.cmake.in +29 -0
- package/vendor/zlib/test/add_subdirectory_test.cmake.in +28 -0
- package/vendor/zlib/test/example.c +552 -0
- package/vendor/zlib/test/find_package_test.cmake.in +26 -0
- package/vendor/zlib/test/infcover.c +672 -0
- package/vendor/zlib/test/minigzip.c +590 -0
- package/vendor/zlib/treebuild.xml +116 -0
- package/vendor/zlib/trees.c +1119 -0
- package/vendor/zlib/trees.h +128 -0
- package/vendor/zlib/uncompr.c +85 -0
- package/vendor/zlib/watcom/watcom_f.mak +43 -0
- package/vendor/zlib/watcom/watcom_l.mak +43 -0
- package/vendor/zlib/win32/DLL_FAQ.txt +381 -0
- package/vendor/zlib/win32/Makefile.bor +109 -0
- package/vendor/zlib/win32/Makefile.gcc +177 -0
- package/vendor/zlib/win32/Makefile.msc +159 -0
- package/vendor/zlib/win32/README-WIN32.txt +103 -0
- package/vendor/zlib/win32/VisualC.txt +3 -0
- package/vendor/zlib/win32/zlib.def +98 -0
- package/vendor/zlib/win32/zlib1.rc +37 -0
- package/vendor/zlib/zconf.h.in +544 -0
- package/vendor/zlib/zlib.3 +149 -0
- package/vendor/zlib/zlib.3.pdf +0 -0
- package/vendor/zlib/zlib.h +1957 -0
- package/vendor/zlib/zlib.map +104 -0
- package/vendor/zlib/zlib.pc.cmakein +13 -0
- package/vendor/zlib/zlib.pc.in +13 -0
- package/vendor/zlib/zlibConfig.cmake.in +26 -0
- package/vendor/zlib/zutil.c +299 -0
- package/vendor/zlib/zutil.h +257 -0
- package/vendor/zsign/.gitattributes +4 -0
- package/vendor/zsign/LICENSE +21 -0
- package/vendor/zsign/README.md +142 -0
- package/vendor/zsign/build/linux/Makefile +43 -0
- package/vendor/zsign/build/macos/Makefile +43 -0
- package/vendor/zsign/build/windows/vs2022/include/minizip/crypt.h +128 -0
- package/vendor/zsign/build/windows/vs2022/include/minizip/ioapi.h +216 -0
- package/vendor/zsign/build/windows/vs2022/include/minizip/iowin32.h +28 -0
- package/vendor/zsign/build/windows/vs2022/include/minizip/mztools.h +37 -0
- package/vendor/zsign/build/windows/vs2022/include/minizip/unzip.h +437 -0
- package/vendor/zsign/build/windows/vs2022/include/minizip/zip.h +364 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/__DECC_INCLUDE_EPILOGUE.H +22 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/__DECC_INCLUDE_PROLOGUE.H +26 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/aes.h +111 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/applink.c +153 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/asn1.h +1133 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/asn1_mac.h +10 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/asn1err.h +142 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/asn1t.h +946 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/async.h +104 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/asyncerr.h +29 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/bio.h +1015 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/bioerr.h +72 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/blowfish.h +78 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/bn.h +590 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/bnerr.h +47 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/buffer.h +62 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/buffererr.h +25 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/camellia.h +117 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/cast.h +71 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/cmac.h +52 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/cmp.h +727 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/cmp_util.h +56 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/cmperr.h +131 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/cms.h +508 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/cmserr.h +125 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/comp.h +98 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/comperr.h +38 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/conf.h +214 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/conf_api.h +46 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/conferr.h +52 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/configuration.h +188 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/conftypes.h +44 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/core.h +236 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/core_dispatch.h +1022 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/core_names.h +545 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/core_object.h +41 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/crmf.h +260 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/crmferr.h +50 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/crypto.h +580 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/cryptoerr.h +56 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/cryptoerr_legacy.h +1466 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ct.h +573 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/cterr.h +45 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/decoder.h +133 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/decodererr.h +28 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/des.h +211 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/dh.h +339 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/dherr.h +59 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/dsa.h +280 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/dsaerr.h +44 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/dtls1.h +57 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/e_os2.h +310 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/e_ostime.h +38 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ebcdic.h +39 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ec.h +1588 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ecdh.h +10 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ecdsa.h +10 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ecerr.h +104 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/encoder.h +124 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/encodererr.h +28 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/engine.h +833 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/engineerr.h +63 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/err.h +512 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ess.h +128 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/esserr.h +32 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/evp.h +2231 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/evperr.h +140 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/fips_names.h +50 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/fipskey.h +41 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/hmac.h +62 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/hpke.h +169 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/http.h +118 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/httperr.h +56 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/idea.h +82 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/indicator.h +31 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/kdf.h +138 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/kdferr.h +16 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/lhash.h +398 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/macros.h +338 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/md2.h +56 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/md4.h +63 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/md5.h +62 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/mdc2.h +55 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/modes.h +219 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/obj_mac.h +5820 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/objects.h +184 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/objectserr.h +28 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ocsp.h +483 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ocsperr.h +53 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/opensslconf.h +17 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/opensslv.h +114 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ossl_typ.h +16 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/param_build.h +63 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/params.h +160 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/pem.h +543 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/pem2.h +19 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/pemerr.h +58 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/pkcs12.h +366 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/pkcs12err.h +46 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/pkcs7.h +430 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/pkcs7err.h +63 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/prov_ssl.h +38 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/proverr.h +162 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/provider.h +66 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/quic.h +70 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/rand.h +125 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/randerr.h +69 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/rc2.h +68 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/rc4.h +47 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/rc5.h +79 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ripemd.h +59 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/rsa.h +615 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/rsaerr.h +107 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/safestack.h +297 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/seed.h +113 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/self_test.h +98 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/sha.h +139 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/srp.h +285 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/srtp.h +68 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ssl.h +2878 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ssl2.h +30 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ssl3.h +357 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/sslerr.h +379 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/sslerr_legacy.h +467 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/stack.h +90 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/store.h +377 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/storeerr.h +49 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/symhacks.h +39 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/thread.h +31 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/tls1.h +1220 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/trace.h +320 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ts.h +522 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/tserr.h +67 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/txt_db.h +63 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/types.h +245 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/ui.h +407 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/uierr.h +38 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/whrlpool.h +62 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/x509.h +1304 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/x509_acert.h +263 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/x509_vfy.h +902 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/x509err.h +70 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/x509v3.h +1500 -0
- package/vendor/zsign/build/windows/vs2022/include/openssl/x509v3err.h +96 -0
- package/vendor/zsign/build/windows/vs2022/include/zlib/zconf.h +553 -0
- package/vendor/zsign/build/windows/vs2022/include/zlib/zlib.h +1938 -0
- package/vendor/zsign/build/windows/vs2022/lib/minizip/x64/mt/minizip.lib +0 -0
- package/vendor/zsign/build/windows/vs2022/lib/openssl/x64/mt/libcrypto.lib +0 -0
- package/vendor/zsign/build/windows/vs2022/lib/openssl/x64/mt/libssl.lib +0 -0
- package/vendor/zsign/build/windows/vs2022/lib/zlib/x64/mt/zlib.lib +0 -0
- package/vendor/zsign/build/windows/vs2022/zsign/src/common_win32.h +44 -0
- package/vendor/zsign/build/windows/vs2022/zsign/src/getopt.cpp +69 -0
- package/vendor/zsign/build/windows/vs2022/zsign/src/getopt.h +20 -0
- package/vendor/zsign/build/windows/vs2022/zsign/src/iconv.cpp +138 -0
- package/vendor/zsign/build/windows/vs2022/zsign/src/iconv.h +38 -0
- package/vendor/zsign/build/windows/vs2022/zsign/zsign.vcxproj +177 -0
- package/vendor/zsign/build/windows/vs2022/zsign/zsign.vcxproj.filters +120 -0
- package/vendor/zsign/build/windows/vs2022/zsign.sln +28 -0
- package/vendor/zsign/src/archo.cpp +742 -0
- package/vendor/zsign/src/archo.h +61 -0
- package/vendor/zsign/src/bundle.cpp +589 -0
- package/vendor/zsign/src/bundle.h +46 -0
- package/vendor/zsign/src/common/archive.cpp +246 -0
- package/vendor/zsign/src/common/archive.h +22 -0
- package/vendor/zsign/src/common/base64.cpp +166 -0
- package/vendor/zsign/src/common/base64.h +30 -0
- package/vendor/zsign/src/common/common.h +56 -0
- package/vendor/zsign/src/common/fs.cpp +573 -0
- package/vendor/zsign/src/common/fs.h +50 -0
- package/vendor/zsign/src/common/json.cpp +3380 -0
- package/vendor/zsign/src/common/json.h +530 -0
- package/vendor/zsign/src/common/log.cpp +145 -0
- package/vendor/zsign/src/common/log.h +37 -0
- package/vendor/zsign/src/common/mach-o.h +585 -0
- package/vendor/zsign/src/common/sha.cpp +133 -0
- package/vendor/zsign/src/common/sha.h +24 -0
- package/vendor/zsign/src/common/timer.cpp +28 -0
- package/vendor/zsign/src/common/timer.h +17 -0
- package/vendor/zsign/src/common/util.cpp +185 -0
- package/vendor/zsign/src/common/util.h +25 -0
- package/vendor/zsign/src/macho.cpp +273 -0
- package/vendor/zsign/src/macho.h +38 -0
- package/vendor/zsign/src/openssl.cpp +698 -0
- package/vendor/zsign/src/openssl.h +71 -0
- package/vendor/zsign/src/signing.cpp +745 -0
- package/vendor/zsign/src/signing.h +59 -0
- package/vendor/zsign/src/zsign.cpp +317 -0
- package/vendor/zsign/test/dylib/bin/demo1.dylib +0 -0
- package/vendor/zsign/test/dylib/bin/demo2.dylib +0 -0
- package/vendor/zsign/test/dylib/demo/Makefile +12 -0
- package/vendor/zsign/test/dylib/demo/control +9 -0
- package/vendor/zsign/test/dylib/demo/demo.m +21 -0
- package/vendor/zsign/test/linux/test.sh +19 -0
- package/vendor/zsign/test/macos/test.sh +19 -0
- package/vendor/zsign/test/windows/test.ps1 +17 -0
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
/* zran.c -- example of deflate stream indexing and random access
|
|
2
|
+
* Copyright (C) 2005, 2012, 2018, 2023, 2024 Mark Adler
|
|
3
|
+
* For conditions of distribution and use, see copyright notice in zlib.h
|
|
4
|
+
* Version 1.6 2 Aug 2024 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
|
+
1.5 4 Feb 2024 Set returned index to NULL on an index build error
|
|
18
|
+
Stop decoding once request is satisfied
|
|
19
|
+
Provide a reusable inflate engine in the index
|
|
20
|
+
Allocate the dictionaries to reduce memory usage
|
|
21
|
+
1.6 2 Aug 2024 Remove unneeded dependency on limits.h
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
// Illustrate the use of Z_BLOCK, inflatePrime(), and inflateSetDictionary()
|
|
25
|
+
// for random access of a compressed file. A file containing a raw deflate
|
|
26
|
+
// stream is provided on the command line. The compressed stream is decoded in
|
|
27
|
+
// its entirety, and an index built with access points about every SPAN bytes
|
|
28
|
+
// in the uncompressed output. The compressed file is left open, and can then
|
|
29
|
+
// be read randomly, having to decompress on the average SPAN/2 uncompressed
|
|
30
|
+
// bytes before getting to the desired block of data.
|
|
31
|
+
//
|
|
32
|
+
// An access point can be created at the start of any deflate block, by saving
|
|
33
|
+
// the starting file offset and bit of that block, and the 32K bytes of
|
|
34
|
+
// uncompressed data that precede that block. Also the uncompressed offset of
|
|
35
|
+
// that block is saved to provide a reference for locating a desired starting
|
|
36
|
+
// point in the uncompressed stream. deflate_index_build() decompresses the
|
|
37
|
+
// input raw deflate stream a block at a time, and at the end of each block
|
|
38
|
+
// decides if enough uncompressed data has gone by to justify the creation of a
|
|
39
|
+
// new access point. If so, that point is saved in a data structure that grows
|
|
40
|
+
// as needed to accommodate the points.
|
|
41
|
+
//
|
|
42
|
+
// To use the index, an offset in the uncompressed data is provided, for which
|
|
43
|
+
// the latest access point at or preceding that offset is located in the index.
|
|
44
|
+
// The input file is positioned to the specified location in the index, and if
|
|
45
|
+
// necessary the first few bits of the compressed data is read from the file.
|
|
46
|
+
// inflate is initialized with those bits and the 32K of uncompressed data, and
|
|
47
|
+
// decompression then proceeds until the desired offset in the file is reached.
|
|
48
|
+
// Then decompression continues to read the requested uncompressed data from
|
|
49
|
+
// the file.
|
|
50
|
+
//
|
|
51
|
+
// There is some fair bit of overhead to starting inflation for the random
|
|
52
|
+
// access, mainly copying the 32K byte dictionary. If small pieces of the file
|
|
53
|
+
// are being accessed, it would make sense to implement a cache to hold some
|
|
54
|
+
// lookahead to avoid many calls to deflate_index_extract() for small lengths.
|
|
55
|
+
//
|
|
56
|
+
// Another way to build an index would be to use inflateCopy(). That would not
|
|
57
|
+
// be constrained to have access points at block boundaries, but would require
|
|
58
|
+
// more memory per access point, and could not be saved to a file due to the
|
|
59
|
+
// use of pointers in the state. The approach here allows for storage of the
|
|
60
|
+
// index in a file.
|
|
61
|
+
|
|
62
|
+
#include <stdio.h>
|
|
63
|
+
#include <stdlib.h>
|
|
64
|
+
#include <string.h>
|
|
65
|
+
#include "zlib.h"
|
|
66
|
+
#include "zran.h"
|
|
67
|
+
|
|
68
|
+
#define WINSIZE 32768U // sliding window size
|
|
69
|
+
#define CHUNK 16384 // file input buffer size
|
|
70
|
+
|
|
71
|
+
// See comments in zran.h.
|
|
72
|
+
void deflate_index_free(struct deflate_index *index) {
|
|
73
|
+
if (index != NULL) {
|
|
74
|
+
size_t i = index->have;
|
|
75
|
+
while (i)
|
|
76
|
+
free(index->list[--i].window);
|
|
77
|
+
free(index->list);
|
|
78
|
+
inflateEnd(&index->strm);
|
|
79
|
+
free(index);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Add an access point to the list. If out of memory, deallocate the existing
|
|
84
|
+
// list and return NULL. index->mode is temporarily the allocated number of
|
|
85
|
+
// access points, until it is time for deflate_index_build() to return. Then
|
|
86
|
+
// index->mode is set to the mode of inflation.
|
|
87
|
+
static struct deflate_index *add_point(struct deflate_index *index, off_t in,
|
|
88
|
+
off_t out, off_t beg,
|
|
89
|
+
unsigned char *window) {
|
|
90
|
+
if (index->have == index->mode) {
|
|
91
|
+
// The list is full. Make it bigger.
|
|
92
|
+
index->mode = index->mode ? index->mode << 1 : 8;
|
|
93
|
+
point_t *next = realloc(index->list, sizeof(point_t) * index->mode);
|
|
94
|
+
if (next == NULL) {
|
|
95
|
+
deflate_index_free(index);
|
|
96
|
+
return NULL;
|
|
97
|
+
}
|
|
98
|
+
index->list = next;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Fill in the access point and increment how many we have.
|
|
102
|
+
point_t *next = (point_t *)(index->list) + index->have++;
|
|
103
|
+
if (index->have < 0) {
|
|
104
|
+
// Overflowed the int!
|
|
105
|
+
deflate_index_free(index);
|
|
106
|
+
return NULL;
|
|
107
|
+
}
|
|
108
|
+
next->out = out;
|
|
109
|
+
next->in = in;
|
|
110
|
+
next->bits = index->strm.data_type & 7;
|
|
111
|
+
next->dict = out - beg > WINSIZE ? WINSIZE : (unsigned)(out - beg);
|
|
112
|
+
next->window = malloc(next->dict);
|
|
113
|
+
if (next->window == NULL) {
|
|
114
|
+
deflate_index_free(index);
|
|
115
|
+
return NULL;
|
|
116
|
+
}
|
|
117
|
+
unsigned recent = WINSIZE - index->strm.avail_out;
|
|
118
|
+
unsigned copy = recent > next->dict ? next->dict : recent;
|
|
119
|
+
memcpy(next->window + next->dict - copy, window + recent - copy, copy);
|
|
120
|
+
copy = next->dict - copy;
|
|
121
|
+
memcpy(next->window, window + WINSIZE - copy, copy);
|
|
122
|
+
|
|
123
|
+
// Return the index, which may have been newly allocated or destroyed.
|
|
124
|
+
return index;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Decompression modes. These are the inflateInit2() windowBits parameter.
|
|
128
|
+
#define RAW -15
|
|
129
|
+
#define ZLIB 15
|
|
130
|
+
#define GZIP 31
|
|
131
|
+
|
|
132
|
+
// See comments in zran.h.
|
|
133
|
+
int deflate_index_build(FILE *in, off_t span, struct deflate_index **built) {
|
|
134
|
+
// If this returns with an error, any attempt to use the index will cleanly
|
|
135
|
+
// return an error.
|
|
136
|
+
*built = NULL;
|
|
137
|
+
|
|
138
|
+
// Create and initialize the index list.
|
|
139
|
+
struct deflate_index *index = malloc(sizeof(struct deflate_index));
|
|
140
|
+
if (index == NULL)
|
|
141
|
+
return Z_MEM_ERROR;
|
|
142
|
+
index->have = 0;
|
|
143
|
+
index->mode = 0; // entries in index->list allocation
|
|
144
|
+
index->list = NULL;
|
|
145
|
+
index->strm.state = Z_NULL; // so inflateEnd() can work
|
|
146
|
+
|
|
147
|
+
// Set up the inflation state.
|
|
148
|
+
index->strm.avail_in = 0;
|
|
149
|
+
index->strm.avail_out = 0;
|
|
150
|
+
unsigned char buf[CHUNK]; // input buffer
|
|
151
|
+
unsigned char win[WINSIZE] = {0}; // output sliding window
|
|
152
|
+
off_t totin = 0; // total bytes read from input
|
|
153
|
+
off_t totout = 0; // total bytes uncompressed
|
|
154
|
+
off_t beg = 0; // starting offset of last history reset
|
|
155
|
+
int mode = 0; // mode: RAW, ZLIB, or GZIP (0 => not set yet)
|
|
156
|
+
|
|
157
|
+
// Decompress from in, generating access points along the way.
|
|
158
|
+
int ret; // the return value from zlib, or Z_ERRNO
|
|
159
|
+
off_t last; // last access point uncompressed offset
|
|
160
|
+
do {
|
|
161
|
+
// Assure available input, at least until reaching EOF.
|
|
162
|
+
if (index->strm.avail_in == 0) {
|
|
163
|
+
index->strm.avail_in = fread(buf, 1, sizeof(buf), in);
|
|
164
|
+
totin += index->strm.avail_in;
|
|
165
|
+
index->strm.next_in = buf;
|
|
166
|
+
if (index->strm.avail_in < sizeof(buf) && ferror(in)) {
|
|
167
|
+
ret = Z_ERRNO;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (mode == 0) {
|
|
172
|
+
// At the start of the input -- determine the type. Assume raw
|
|
173
|
+
// if it is neither zlib nor gzip. This could in theory result
|
|
174
|
+
// in a false positive for zlib, but in practice the fill bits
|
|
175
|
+
// after a stored block are always zeros, so a raw stream won't
|
|
176
|
+
// start with an 8 in the low nybble.
|
|
177
|
+
mode = index->strm.avail_in == 0 ? RAW : // will fail
|
|
178
|
+
(index->strm.next_in[0] & 0xf) == 8 ? ZLIB :
|
|
179
|
+
index->strm.next_in[0] == 0x1f ? GZIP :
|
|
180
|
+
/* else */ RAW;
|
|
181
|
+
index->strm.zalloc = Z_NULL;
|
|
182
|
+
index->strm.zfree = Z_NULL;
|
|
183
|
+
index->strm.opaque = Z_NULL;
|
|
184
|
+
ret = inflateInit2(&index->strm, mode);
|
|
185
|
+
if (ret != Z_OK)
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Assure available output. This rotates the output through, for use as
|
|
191
|
+
// a sliding window on the uncompressed data.
|
|
192
|
+
if (index->strm.avail_out == 0) {
|
|
193
|
+
index->strm.avail_out = sizeof(win);
|
|
194
|
+
index->strm.next_out = win;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (mode == RAW && index->have == 0)
|
|
198
|
+
// We skip the inflate() call at the start of raw deflate data in
|
|
199
|
+
// order generate an access point there. Set data_type to imitate
|
|
200
|
+
// the end of a header.
|
|
201
|
+
index->strm.data_type = 0x80;
|
|
202
|
+
else {
|
|
203
|
+
// Inflate and update the number of uncompressed bytes.
|
|
204
|
+
unsigned before = index->strm.avail_out;
|
|
205
|
+
ret = inflate(&index->strm, Z_BLOCK);
|
|
206
|
+
totout += before - index->strm.avail_out;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if ((index->strm.data_type & 0xc0) == 0x80 &&
|
|
210
|
+
(index->have == 0 || totout - last >= span)) {
|
|
211
|
+
// We are at the end of a header or a non-last deflate block, so we
|
|
212
|
+
// can add an access point here. Furthermore, we are either at the
|
|
213
|
+
// very start for the first access point, or there has been span or
|
|
214
|
+
// more uncompressed bytes since the last access point, so we want
|
|
215
|
+
// to add an access point here.
|
|
216
|
+
index = add_point(index, totin - index->strm.avail_in, totout, beg,
|
|
217
|
+
win);
|
|
218
|
+
if (index == NULL) {
|
|
219
|
+
ret = Z_MEM_ERROR;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
last = totout;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (ret == Z_STREAM_END && mode == GZIP &&
|
|
226
|
+
(index->strm.avail_in || ungetc(getc(in), in) != EOF)) {
|
|
227
|
+
// There is more input after the end of a gzip member. Reset the
|
|
228
|
+
// inflate state to read another gzip member. On success, this will
|
|
229
|
+
// set ret to Z_OK to continue decompressing.
|
|
230
|
+
ret = inflateReset2(&index->strm, GZIP);
|
|
231
|
+
beg = totout; // reset history
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Keep going until Z_STREAM_END or error. If the compressed data ends
|
|
235
|
+
// prematurely without a file read error, Z_BUF_ERROR is returned.
|
|
236
|
+
} while (ret == Z_OK);
|
|
237
|
+
|
|
238
|
+
if (ret != Z_STREAM_END) {
|
|
239
|
+
// An error was encountered. Discard the index and return a negative
|
|
240
|
+
// error code.
|
|
241
|
+
deflate_index_free(index);
|
|
242
|
+
return ret == Z_NEED_DICT ? Z_DATA_ERROR : ret;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Return the index.
|
|
246
|
+
index->mode = mode;
|
|
247
|
+
index->length = totout;
|
|
248
|
+
*built = index;
|
|
249
|
+
return index->have;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
#ifdef NOPRIME
|
|
253
|
+
// Support zlib versions before 1.2.3 (July 2005), or incomplete zlib clones
|
|
254
|
+
// that do not have inflatePrime().
|
|
255
|
+
|
|
256
|
+
# define INFLATEPRIME inflatePreface
|
|
257
|
+
|
|
258
|
+
// Append the low bits bits of value to in[] at bit position *have, updating
|
|
259
|
+
// *have. value must be zero above its low bits bits. bits must be positive.
|
|
260
|
+
// This assumes that any bits above the *have bits in the last byte are zeros.
|
|
261
|
+
// That assumption is preserved on return, as any bits above *have + bits in
|
|
262
|
+
// the last byte written will be set to zeros.
|
|
263
|
+
static inline void append_bits(unsigned value, int bits,
|
|
264
|
+
unsigned char *in, int *have) {
|
|
265
|
+
in += *have >> 3; // where the first bits from value will go
|
|
266
|
+
int k = *have & 7; // the number of bits already there
|
|
267
|
+
*have += bits;
|
|
268
|
+
if (k)
|
|
269
|
+
*in |= value << k; // write value above the low k bits
|
|
270
|
+
else
|
|
271
|
+
*in = value;
|
|
272
|
+
k = 8 - k; // the number of bits just appended
|
|
273
|
+
while (bits > k) {
|
|
274
|
+
value >>= k; // drop the bits appended
|
|
275
|
+
bits -= k;
|
|
276
|
+
k = 8; // now at a byte boundary
|
|
277
|
+
*++in = value;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Insert enough bits in the form of empty deflate blocks in front of the
|
|
282
|
+
// low bits bits of value, in order to bring the sequence to a byte boundary.
|
|
283
|
+
// Then feed that to inflate(). This does what inflatePrime() does, except that
|
|
284
|
+
// a negative value of bits is not supported. bits must be in 0..16. If the
|
|
285
|
+
// arguments are invalid, Z_STREAM_ERROR is returned. Otherwise the return
|
|
286
|
+
// value from inflate() is returned.
|
|
287
|
+
static int inflatePreface(z_stream *strm, int bits, int value) {
|
|
288
|
+
// Check input.
|
|
289
|
+
if (strm == Z_NULL || bits < 0 || bits > 16)
|
|
290
|
+
return Z_STREAM_ERROR;
|
|
291
|
+
if (bits == 0)
|
|
292
|
+
return Z_OK;
|
|
293
|
+
value &= (2 << (bits - 1)) - 1;
|
|
294
|
+
|
|
295
|
+
// An empty dynamic block with an odd number of bits (95). The high bit of
|
|
296
|
+
// the last byte is unused.
|
|
297
|
+
static const unsigned char dyn[] = {
|
|
298
|
+
4, 0xe0, 0x81, 8, 0, 0, 0, 0, 0x20, 0xa8, 0xab, 0x1f
|
|
299
|
+
};
|
|
300
|
+
const int dynlen = 95; // number of bits in the block
|
|
301
|
+
|
|
302
|
+
// Build an input buffer for inflate that is a multiple of eight bits in
|
|
303
|
+
// length, and that ends with the low bits bits of value.
|
|
304
|
+
unsigned char in[(dynlen + 3 * 10 + 16 + 7) / 8];
|
|
305
|
+
int have = 0;
|
|
306
|
+
if (bits & 1) {
|
|
307
|
+
// Insert an empty dynamic block to get to an odd number of bits, so
|
|
308
|
+
// when bits bits from value are appended, we are at an even number of
|
|
309
|
+
// bits.
|
|
310
|
+
memcpy(in, dyn, sizeof(dyn));
|
|
311
|
+
have = dynlen;
|
|
312
|
+
}
|
|
313
|
+
while ((have + bits) & 7)
|
|
314
|
+
// Insert empty fixed blocks until appending bits bits would put us on
|
|
315
|
+
// a byte boundary. This will insert at most three fixed blocks.
|
|
316
|
+
append_bits(2, 10, in, &have);
|
|
317
|
+
|
|
318
|
+
// Append the bits bits from value, which takes us to a byte boundary.
|
|
319
|
+
append_bits(value, bits, in, &have);
|
|
320
|
+
|
|
321
|
+
// Deliver the input to inflate(). There is no output space provided, but
|
|
322
|
+
// inflate() can't get stuck waiting on output not ingesting all of the
|
|
323
|
+
// provided input. The reason is that there will be at most 16 bits of
|
|
324
|
+
// input from value after the empty deflate blocks (which themselves
|
|
325
|
+
// generate no output). At least ten bits are needed to generate the first
|
|
326
|
+
// output byte from a fixed block. The last two bytes of the buffer have to
|
|
327
|
+
// be ingested in order to get ten bits, which is the most that value can
|
|
328
|
+
// occupy.
|
|
329
|
+
strm->avail_in = have >> 3;
|
|
330
|
+
strm->next_in = in;
|
|
331
|
+
strm->avail_out = 0;
|
|
332
|
+
strm->next_out = in; // not used, but can't be NULL
|
|
333
|
+
return inflate(strm, Z_NO_FLUSH);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
#else
|
|
337
|
+
# define INFLATEPRIME inflatePrime
|
|
338
|
+
#endif
|
|
339
|
+
|
|
340
|
+
// See comments in zran.h.
|
|
341
|
+
ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index,
|
|
342
|
+
off_t offset, unsigned char *buf, size_t len) {
|
|
343
|
+
// Do a quick sanity check on the index.
|
|
344
|
+
if (index == NULL || index->have < 1 || index->list[0].out != 0 ||
|
|
345
|
+
index->strm.state == Z_NULL)
|
|
346
|
+
return Z_STREAM_ERROR;
|
|
347
|
+
|
|
348
|
+
// If nothing to extract, return zero bytes extracted.
|
|
349
|
+
if (len == 0 || offset < 0 || offset >= index->length)
|
|
350
|
+
return 0;
|
|
351
|
+
|
|
352
|
+
// Find the access point closest to but not after offset.
|
|
353
|
+
int lo = -1, hi = index->have;
|
|
354
|
+
point_t *point = index->list;
|
|
355
|
+
while (hi - lo > 1) {
|
|
356
|
+
int mid = (lo + hi) >> 1;
|
|
357
|
+
if (offset < point[mid].out)
|
|
358
|
+
hi = mid;
|
|
359
|
+
else
|
|
360
|
+
lo = mid;
|
|
361
|
+
}
|
|
362
|
+
point += lo;
|
|
363
|
+
|
|
364
|
+
// Initialize the input file and prime the inflate engine to start there.
|
|
365
|
+
int ret = fseeko(in, point->in - (point->bits ? 1 : 0), SEEK_SET);
|
|
366
|
+
if (ret == -1)
|
|
367
|
+
return Z_ERRNO;
|
|
368
|
+
int ch = 0;
|
|
369
|
+
if (point->bits && (ch = getc(in)) == EOF)
|
|
370
|
+
return ferror(in) ? Z_ERRNO : Z_BUF_ERROR;
|
|
371
|
+
index->strm.avail_in = 0;
|
|
372
|
+
ret = inflateReset2(&index->strm, RAW);
|
|
373
|
+
if (ret != Z_OK)
|
|
374
|
+
return ret;
|
|
375
|
+
if (point->bits)
|
|
376
|
+
INFLATEPRIME(&index->strm, point->bits, ch >> (8 - point->bits));
|
|
377
|
+
inflateSetDictionary(&index->strm, point->window, point->dict);
|
|
378
|
+
|
|
379
|
+
// Skip uncompressed bytes until offset reached, then satisfy request.
|
|
380
|
+
unsigned char input[CHUNK];
|
|
381
|
+
unsigned char discard[WINSIZE];
|
|
382
|
+
offset -= point->out; // number of bytes to skip to get to offset
|
|
383
|
+
size_t left = len; // number of bytes left to read after offset
|
|
384
|
+
do {
|
|
385
|
+
if (offset) {
|
|
386
|
+
// Discard up to offset uncompressed bytes.
|
|
387
|
+
index->strm.avail_out = offset < WINSIZE ? (unsigned)offset :
|
|
388
|
+
WINSIZE;
|
|
389
|
+
index->strm.next_out = discard;
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
// Uncompress up to left bytes into buf.
|
|
393
|
+
index->strm.avail_out = left < (unsigned)-1 ? (unsigned)left :
|
|
394
|
+
(unsigned)-1;
|
|
395
|
+
index->strm.next_out = buf + len - left;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// Uncompress, setting got to the number of bytes uncompressed.
|
|
399
|
+
if (index->strm.avail_in == 0) {
|
|
400
|
+
// Assure available input.
|
|
401
|
+
index->strm.avail_in = fread(input, 1, CHUNK, in);
|
|
402
|
+
if (index->strm.avail_in < CHUNK && ferror(in)) {
|
|
403
|
+
ret = Z_ERRNO;
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
index->strm.next_in = input;
|
|
407
|
+
}
|
|
408
|
+
unsigned got = index->strm.avail_out;
|
|
409
|
+
ret = inflate(&index->strm, Z_NO_FLUSH);
|
|
410
|
+
got -= index->strm.avail_out;
|
|
411
|
+
|
|
412
|
+
// Update the appropriate count.
|
|
413
|
+
if (offset)
|
|
414
|
+
offset -= got;
|
|
415
|
+
else {
|
|
416
|
+
left -= got;
|
|
417
|
+
if (left == 0)
|
|
418
|
+
// Request satisfied.
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// If we're at the end of a gzip member and there's more to read,
|
|
423
|
+
// continue to the next gzip member.
|
|
424
|
+
if (ret == Z_STREAM_END && index->mode == GZIP) {
|
|
425
|
+
// Discard the gzip trailer.
|
|
426
|
+
unsigned drop = 8; // length of gzip trailer
|
|
427
|
+
if (index->strm.avail_in >= drop) {
|
|
428
|
+
index->strm.avail_in -= drop;
|
|
429
|
+
index->strm.next_in += drop;
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
// Read and discard the remainder of the gzip trailer.
|
|
433
|
+
drop -= index->strm.avail_in;
|
|
434
|
+
index->strm.avail_in = 0;
|
|
435
|
+
do {
|
|
436
|
+
if (getc(in) == EOF)
|
|
437
|
+
// The input does not have a complete trailer.
|
|
438
|
+
return ferror(in) ? Z_ERRNO : Z_BUF_ERROR;
|
|
439
|
+
} while (--drop);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if (index->strm.avail_in || ungetc(getc(in), in) != EOF) {
|
|
443
|
+
// There's more after the gzip trailer. Use inflate to skip the
|
|
444
|
+
// gzip header and resume the raw inflate there.
|
|
445
|
+
inflateReset2(&index->strm, GZIP);
|
|
446
|
+
do {
|
|
447
|
+
if (index->strm.avail_in == 0) {
|
|
448
|
+
index->strm.avail_in = fread(input, 1, CHUNK, in);
|
|
449
|
+
if (index->strm.avail_in < CHUNK && ferror(in)) {
|
|
450
|
+
ret = Z_ERRNO;
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
index->strm.next_in = input;
|
|
454
|
+
}
|
|
455
|
+
index->strm.avail_out = WINSIZE;
|
|
456
|
+
index->strm.next_out = discard;
|
|
457
|
+
ret = inflate(&index->strm, Z_BLOCK); // stop after header
|
|
458
|
+
} while (ret == Z_OK && (index->strm.data_type & 0x80) == 0);
|
|
459
|
+
if (ret != Z_OK)
|
|
460
|
+
break;
|
|
461
|
+
inflateReset2(&index->strm, RAW);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Continue until we have the requested data, the deflate data has
|
|
466
|
+
// ended, or an error is encountered.
|
|
467
|
+
} while (ret == Z_OK);
|
|
468
|
+
|
|
469
|
+
// Return the number of uncompressed bytes read into buf, or the error.
|
|
470
|
+
return ret == Z_OK || ret == Z_STREAM_END ? len - left : ret;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
#ifdef TEST
|
|
474
|
+
|
|
475
|
+
#define SPAN 1048576L // desired distance between access points
|
|
476
|
+
#define LEN 16384 // number of bytes to extract
|
|
477
|
+
|
|
478
|
+
// Demonstrate the use of deflate_index_build() and deflate_index_extract() by
|
|
479
|
+
// processing the file provided on the command line, and extracting LEN bytes
|
|
480
|
+
// from 2/3rds of the way through the uncompressed output, writing that to
|
|
481
|
+
// stdout. An offset can be provided as the second argument, in which case the
|
|
482
|
+
// data is extracted from there instead.
|
|
483
|
+
int main(int argc, char **argv) {
|
|
484
|
+
// Open the input file.
|
|
485
|
+
if (argc < 2 || argc > 3) {
|
|
486
|
+
fprintf(stderr, "usage: zran file.raw [offset]\n");
|
|
487
|
+
return 1;
|
|
488
|
+
}
|
|
489
|
+
FILE *in = fopen(argv[1], "rb");
|
|
490
|
+
if (in == NULL) {
|
|
491
|
+
fprintf(stderr, "zran: could not open %s for reading\n", argv[1]);
|
|
492
|
+
return 1;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// Get optional offset.
|
|
496
|
+
off_t offset = -1;
|
|
497
|
+
if (argc == 3) {
|
|
498
|
+
char *end;
|
|
499
|
+
offset = strtoll(argv[2], &end, 10);
|
|
500
|
+
if (*end || offset < 0) {
|
|
501
|
+
fprintf(stderr, "zran: %s is not a valid offset\n", argv[2]);
|
|
502
|
+
return 1;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// Build index.
|
|
507
|
+
struct deflate_index *index = NULL;
|
|
508
|
+
int len = deflate_index_build(in, SPAN, &index);
|
|
509
|
+
if (len < 0) {
|
|
510
|
+
fclose(in);
|
|
511
|
+
switch (len) {
|
|
512
|
+
case Z_MEM_ERROR:
|
|
513
|
+
fprintf(stderr, "zran: out of memory\n");
|
|
514
|
+
break;
|
|
515
|
+
case Z_BUF_ERROR:
|
|
516
|
+
fprintf(stderr, "zran: %s ended prematurely\n", argv[1]);
|
|
517
|
+
break;
|
|
518
|
+
case Z_DATA_ERROR:
|
|
519
|
+
fprintf(stderr, "zran: compressed data error in %s\n", argv[1]);
|
|
520
|
+
break;
|
|
521
|
+
case Z_ERRNO:
|
|
522
|
+
fprintf(stderr, "zran: read error on %s\n", argv[1]);
|
|
523
|
+
break;
|
|
524
|
+
default:
|
|
525
|
+
fprintf(stderr, "zran: error %d while building index\n", len);
|
|
526
|
+
}
|
|
527
|
+
return 1;
|
|
528
|
+
}
|
|
529
|
+
fprintf(stderr, "zran: built index with %d access points\n", len);
|
|
530
|
+
|
|
531
|
+
// Use index by reading some bytes from an arbitrary offset.
|
|
532
|
+
unsigned char buf[LEN];
|
|
533
|
+
if (offset == -1)
|
|
534
|
+
offset = ((index->length + 1) << 1) / 3;
|
|
535
|
+
ptrdiff_t got = deflate_index_extract(in, index, offset, buf, LEN);
|
|
536
|
+
if (got < 0)
|
|
537
|
+
fprintf(stderr, "zran: extraction failed: %s error\n",
|
|
538
|
+
got == Z_MEM_ERROR ? "out of memory" : "input corrupted");
|
|
539
|
+
else {
|
|
540
|
+
fwrite(buf, 1, got, stdout);
|
|
541
|
+
fprintf(stderr, "zran: extracted %ld bytes at %lld\n", got, offset);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// Clean up and exit.
|
|
545
|
+
deflate_index_free(index);
|
|
546
|
+
fclose(in);
|
|
547
|
+
return 0;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
#endif
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* zran.h -- example of deflated stream indexing and random access
|
|
2
|
+
* Copyright (C) 2005, 2012, 2018, 2023, 2024 Mark Adler
|
|
3
|
+
* For conditions of distribution and use, see copyright notice in zlib.h
|
|
4
|
+
* Version 1.5 4 Feb 2024 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 dict; // number of bytes in window to use as a dictionary
|
|
15
|
+
unsigned char *window; // preceding 32K (or less) of uncompressed data
|
|
16
|
+
} point_t;
|
|
17
|
+
|
|
18
|
+
// Access point list.
|
|
19
|
+
struct deflate_index {
|
|
20
|
+
int have; // number of access points in list
|
|
21
|
+
int mode; // -15 for raw, 15 for zlib, or 31 for gzip
|
|
22
|
+
off_t length; // total length of uncompressed data
|
|
23
|
+
point_t *list; // allocated list of access points
|
|
24
|
+
z_stream strm; // re-usable inflate engine for extraction
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// Make one pass through a zlib, gzip, or raw deflate compressed stream and
|
|
28
|
+
// build an index, with access points about every span bytes of uncompressed
|
|
29
|
+
// output. gzip files with multiple members are fully indexed. span should be
|
|
30
|
+
// chosen to balance the speed of random access against the memory requirements
|
|
31
|
+
// of the list, which is about 32K bytes per access point. The return value is
|
|
32
|
+
// the number of access points on success (>= 1), Z_MEM_ERROR for out of
|
|
33
|
+
// memory, Z_BUF_ERROR for a premature end of input, Z_DATA_ERROR for a format
|
|
34
|
+
// or verification error in the input file, or Z_ERRNO for a file read error.
|
|
35
|
+
// On success, *built points to the resulting index, otherwise it's NULL.
|
|
36
|
+
int deflate_index_build(FILE *in, off_t span, struct deflate_index **built);
|
|
37
|
+
|
|
38
|
+
// Use the index to read len bytes from offset into buf. Return the number of
|
|
39
|
+
// bytes read or a negative error code. If data is requested past the end of
|
|
40
|
+
// the uncompressed data, then deflate_index_extract() will return a value less
|
|
41
|
+
// than len, indicating how much was actually read into buf. If given a valid
|
|
42
|
+
// index, this function should not return an error unless the file was modified
|
|
43
|
+
// somehow since the index was generated, given that deflate_index_build() had
|
|
44
|
+
// validated all of the input. If nevertheless there is a failure, Z_BUF_ERROR
|
|
45
|
+
// is returned if the compressed data ends prematurely, Z_DATA_ERROR if the
|
|
46
|
+
// deflate compressed data is not valid, Z_MEM_ERROR if out of memory,
|
|
47
|
+
// Z_STREAM_ERROR if the index is not valid, or Z_ERRNO if there is an error
|
|
48
|
+
// reading or seeking on the input file.
|
|
49
|
+
ptrdiff_t deflate_index_extract(FILE *in, struct deflate_index *index,
|
|
50
|
+
off_t offset, unsigned char *buf, size_t len);
|
|
51
|
+
|
|
52
|
+
// Deallocate an index built by deflate_index_build().
|
|
53
|
+
void deflate_index_free(struct deflate_index *index);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* gzclose.c -- zlib gzclose() function
|
|
2
|
+
* Copyright (C) 2004, 2010 Mark Adler
|
|
3
|
+
* For conditions of distribution and use, see copyright notice in zlib.h
|
|
4
|
+
*/
|
|
5
|
+
|
|
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
|
+
state = (gz_statep)file;
|
|
18
|
+
|
|
19
|
+
return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file);
|
|
20
|
+
#else
|
|
21
|
+
return gzclose_r(file);
|
|
22
|
+
#endif
|
|
23
|
+
}
|