libwz 0.1.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/LICENSE +21 -0
- package/README.md +165 -0
- package/binding.gyp +149 -0
- package/deps/tiny-aes/.github/workflows/c-cpp.yml +27 -0
- package/deps/tiny-aes/CMakeLists.txt +17 -0
- package/deps/tiny-aes/Makefile +61 -0
- package/deps/tiny-aes/README.md +83 -0
- package/deps/tiny-aes/aes.c +572 -0
- package/deps/tiny-aes/aes.h +91 -0
- package/deps/tiny-aes/aes.hpp +12 -0
- package/deps/tiny-aes/conanfile.py +73 -0
- package/deps/tiny-aes/library.json +19 -0
- package/deps/tiny-aes/library.properties +11 -0
- package/deps/tiny-aes/test.c +316 -0
- package/deps/tiny-aes/test.cpp +2 -0
- package/deps/tiny-aes/test_package/CMakeLists.txt +11 -0
- package/deps/tiny-aes/test_package/conanfile.py +17 -0
- package/deps/tiny-aes/unlicense.txt +24 -0
- package/deps/zlib/.cmake-format.yaml +245 -0
- package/deps/zlib/.github/workflows/c-std.yml +268 -0
- package/deps/zlib/.github/workflows/cmake.yml +147 -0
- package/deps/zlib/.github/workflows/configure.yml +146 -0
- package/deps/zlib/.github/workflows/contribs.yml +64 -0
- package/deps/zlib/.github/workflows/fuzz.yml +25 -0
- package/deps/zlib/.github/workflows/msys-cygwin.yml +92 -0
- package/deps/zlib/.github/workflows/others.yml +153 -0
- package/deps/zlib/BUILD.bazel +134 -0
- package/deps/zlib/CMakeLists.txt +310 -0
- package/deps/zlib/ChangeLog +1669 -0
- package/deps/zlib/FAQ +371 -0
- package/deps/zlib/INDEX +67 -0
- package/deps/zlib/LICENSE +22 -0
- package/deps/zlib/MODULE.bazel +9 -0
- package/deps/zlib/Makefile.in +426 -0
- package/deps/zlib/README +115 -0
- package/deps/zlib/README-cmake.md +79 -0
- package/deps/zlib/adler32.c +164 -0
- package/deps/zlib/amiga/Makefile.pup +69 -0
- package/deps/zlib/amiga/Makefile.sas +68 -0
- package/deps/zlib/compress.c +99 -0
- package/deps/zlib/configure +1078 -0
- package/deps/zlib/contrib/CMakeLists.txt +61 -0
- package/deps/zlib/contrib/README.contrib +57 -0
- package/deps/zlib/contrib/ada/CMakeLists.txt +217 -0
- package/deps/zlib/contrib/ada/buffer_demo.adb +106 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeADACompiler.cmake.in +23 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeADAInformation.cmake +133 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeDetermineADACompiler.cmake +33 -0
- package/deps/zlib/contrib/ada/cmake/Modules/CMakeTestADACompiler.cmake +46 -0
- package/deps/zlib/contrib/ada/cmake/binder_helper.cmake +47 -0
- package/deps/zlib/contrib/ada/cmake/compile_helper.cmake +32 -0
- package/deps/zlib/contrib/ada/cmake/exe_link_helper.cmake +53 -0
- package/deps/zlib/contrib/ada/cmake/shared_link_helper.cmake +52 -0
- package/deps/zlib/contrib/ada/cmake/static_link_helper.cmake +25 -0
- package/deps/zlib/contrib/ada/mtest.adb +156 -0
- package/deps/zlib/contrib/ada/read.adb +156 -0
- package/deps/zlib/contrib/ada/readme.txt +65 -0
- package/deps/zlib/contrib/ada/test.adb +463 -0
- package/deps/zlib/contrib/ada/zlib-streams.adb +225 -0
- package/deps/zlib/contrib/ada/zlib-streams.ads +114 -0
- package/deps/zlib/contrib/ada/zlib-thin.adb +142 -0
- package/deps/zlib/contrib/ada/zlib-thin.ads +450 -0
- package/deps/zlib/contrib/ada/zlib.adb +701 -0
- package/deps/zlib/contrib/ada/zlib.ads +328 -0
- package/deps/zlib/contrib/ada/zlib.gpr +20 -0
- package/deps/zlib/contrib/blast/CMakeLists.txt +166 -0
- package/deps/zlib/contrib/blast/Makefile +14 -0
- package/deps/zlib/contrib/blast/README +4 -0
- package/deps/zlib/contrib/blast/blast-test.c +42 -0
- package/deps/zlib/contrib/blast/blast.c +422 -0
- package/deps/zlib/contrib/blast/blast.h +84 -0
- package/deps/zlib/contrib/blast/blastConfig.cmake.in +18 -0
- package/deps/zlib/contrib/blast/test/CMakeLists.txt +193 -0
- package/deps/zlib/contrib/blast/test/add_subdirectory_exclude_test.cmake.in +27 -0
- package/deps/zlib/contrib/blast/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/blast/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/blast/test.pk +0 -0
- package/deps/zlib/contrib/blast/test.txt +1 -0
- package/deps/zlib/contrib/blast/tester.cmake +28 -0
- package/deps/zlib/contrib/crc32vx/CMakeLists.txt +67 -0
- package/deps/zlib/contrib/crc32vx/README +9 -0
- package/deps/zlib/contrib/crc32vx/crc32_vx.c +254 -0
- package/deps/zlib/contrib/crc32vx/crc32_vx_hooks.h +9 -0
- package/deps/zlib/contrib/delphi/ZLib.pas +557 -0
- package/deps/zlib/contrib/delphi/ZLibConst.pas +11 -0
- package/deps/zlib/contrib/delphi/readme.txt +76 -0
- package/deps/zlib/contrib/delphi/zlibd32.mak +99 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/AssemblyInfo.cs +58 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/ChecksumImpl.cs +202 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/CircularBuffer.cs +83 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/CodecBase.cs +198 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/Deflater.cs +106 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/DotZLib.cs +288 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/DotZLib.csproj +141 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/GZipStream.cs +301 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/Inflater.cs +105 -0
- package/deps/zlib/contrib/dotzlib/DotZLib/UnitTests.cs +274 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.build +33 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.chm +0 -0
- package/deps/zlib/contrib/dotzlib/DotZLib.sln +21 -0
- package/deps/zlib/contrib/dotzlib/LICENSE_1_0.txt +23 -0
- package/deps/zlib/contrib/dotzlib/readme.txt +58 -0
- package/deps/zlib/contrib/gcc_gvmat64/CMakeLists.txt +19 -0
- package/deps/zlib/contrib/gcc_gvmat64/gvmat64.S +570 -0
- package/deps/zlib/contrib/infback9/CMakeLists.txt +19 -0
- package/deps/zlib/contrib/infback9/README +1 -0
- package/deps/zlib/contrib/infback9/infback9.c +603 -0
- package/deps/zlib/contrib/infback9/infback9.h +37 -0
- package/deps/zlib/contrib/infback9/inffix9.h +107 -0
- package/deps/zlib/contrib/infback9/inflate9.h +47 -0
- package/deps/zlib/contrib/infback9/inftree9.c +319 -0
- package/deps/zlib/contrib/infback9/inftree9.h +61 -0
- package/deps/zlib/contrib/iostream/test.cpp +24 -0
- package/deps/zlib/contrib/iostream/zfstream.cpp +329 -0
- package/deps/zlib/contrib/iostream/zfstream.h +128 -0
- package/deps/zlib/contrib/iostream2/zstream.h +306 -0
- package/deps/zlib/contrib/iostream2/zstream_test.cpp +25 -0
- package/deps/zlib/contrib/iostream3/CMakeLists.txt +200 -0
- package/deps/zlib/contrib/iostream3/README +35 -0
- package/deps/zlib/contrib/iostream3/TODO +17 -0
- package/deps/zlib/contrib/iostream3/iostream3Config.cmake.in +23 -0
- package/deps/zlib/contrib/iostream3/test/CMakeLists.txt +191 -0
- package/deps/zlib/contrib/iostream3/test/add_subdirectory_exclude_test.cmake.in +27 -0
- package/deps/zlib/contrib/iostream3/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/iostream3/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/iostream3/test.cc +50 -0
- package/deps/zlib/contrib/iostream3/zfstream.cc +479 -0
- package/deps/zlib/contrib/iostream3/zfstream.h +466 -0
- package/deps/zlib/contrib/minizip/CMakeLists.txt +387 -0
- package/deps/zlib/contrib/minizip/LICENSE.Info-Zip +58 -0
- package/deps/zlib/contrib/minizip/Makefile +33 -0
- package/deps/zlib/contrib/minizip/Makefile.am +45 -0
- package/deps/zlib/contrib/minizip/MiniZip64_Changes.txt +6 -0
- package/deps/zlib/contrib/minizip/MiniZip64_info.txt +69 -0
- package/deps/zlib/contrib/minizip/configure.ac +32 -0
- package/deps/zlib/contrib/minizip/crypt.h +125 -0
- package/deps/zlib/contrib/minizip/ints.h +57 -0
- package/deps/zlib/contrib/minizip/ioapi.c +231 -0
- package/deps/zlib/contrib/minizip/ioapi.h +183 -0
- package/deps/zlib/contrib/minizip/iowin32.c +447 -0
- package/deps/zlib/contrib/minizip/iowin32.h +27 -0
- package/deps/zlib/contrib/minizip/make_vms.com +25 -0
- package/deps/zlib/contrib/minizip/miniunz.c +647 -0
- package/deps/zlib/contrib/minizip/miniunzip.1 +63 -0
- package/deps/zlib/contrib/minizip/minizip.1 +46 -0
- package/deps/zlib/contrib/minizip/minizip.c +511 -0
- package/deps/zlib/contrib/minizip/minizip.pc.in +13 -0
- package/deps/zlib/contrib/minizip/minizip.pc.txt +13 -0
- package/deps/zlib/contrib/minizip/minizipConfig.cmake.in +27 -0
- package/deps/zlib/contrib/minizip/mztools.c +294 -0
- package/deps/zlib/contrib/minizip/mztools.h +37 -0
- package/deps/zlib/contrib/minizip/skipset.h +366 -0
- package/deps/zlib/contrib/minizip/test/CMakeLists.txt +176 -0
- package/deps/zlib/contrib/minizip/test/add_subdirectory_exclude_test.cmake.in +29 -0
- package/deps/zlib/contrib/minizip/test/add_subdirectory_test.cmake.in +28 -0
- package/deps/zlib/contrib/minizip/test/find_package_no_components_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/find_package_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/find_package_wrong_components_test.cmake.in +26 -0
- package/deps/zlib/contrib/minizip/test/test_helper.cm +32 -0
- package/deps/zlib/contrib/minizip/unzip.c +1984 -0
- package/deps/zlib/contrib/minizip/unzip.h +442 -0
- package/deps/zlib/contrib/minizip/zip.c +2246 -0
- package/deps/zlib/contrib/minizip/zip.h +371 -0
- package/deps/zlib/contrib/nuget/nuget.csproj +45 -0
- package/deps/zlib/contrib/nuget/nuget.sln +22 -0
- package/deps/zlib/contrib/pascal/example.pas +599 -0
- package/deps/zlib/contrib/pascal/readme.txt +76 -0
- package/deps/zlib/contrib/pascal/zlibd32.mak +99 -0
- package/deps/zlib/contrib/pascal/zlibpas.pas +276 -0
- package/deps/zlib/contrib/puff/CMakeLists.txt +154 -0
- package/deps/zlib/contrib/puff/Makefile +42 -0
- package/deps/zlib/contrib/puff/README +63 -0
- package/deps/zlib/contrib/puff/bin-writer.c +26 -0
- package/deps/zlib/contrib/puff/puff.c +840 -0
- package/deps/zlib/contrib/puff/puff.h +35 -0
- package/deps/zlib/contrib/puff/puffConfig.cmake.in +18 -0
- package/deps/zlib/contrib/puff/pufftest.c +168 -0
- package/deps/zlib/contrib/puff/test/CMakeLists.txt +262 -0
- package/deps/zlib/contrib/puff/test/add_subdirectory_exclude_test.cmake.in +26 -0
- package/deps/zlib/contrib/puff/test/add_subdirectory_test.cmake.in +25 -0
- package/deps/zlib/contrib/puff/test/find_package_no_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/find_package_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/find_package_wrong_components_test.cmake.in +24 -0
- package/deps/zlib/contrib/puff/test/tester-cov.cmake +58 -0
- package/deps/zlib/contrib/puff/test/tester.cmake +16 -0
- package/deps/zlib/contrib/puff/zeros.raw +0 -0
- package/deps/zlib/contrib/testzlib/CMakeLists.txt +44 -0
- package/deps/zlib/contrib/testzlib/testzlib.c +275 -0
- package/deps/zlib/contrib/testzlib/testzlib.txt +10 -0
- package/deps/zlib/contrib/vstudio/readme.txt +22 -0
- package/deps/zlib/contrib/zlib1-dll/CMakeLists.txt +196 -0
- package/deps/zlib/contrib/zlib1-dll/readme.txt +21 -0
- package/deps/zlib/crc32.c +983 -0
- package/deps/zlib/crc32.h +9446 -0
- package/deps/zlib/deflate.c +2185 -0
- package/deps/zlib/deflate.h +383 -0
- package/deps/zlib/doc/algorithm.txt +209 -0
- package/deps/zlib/doc/crc-doc.1.0.pdf +0 -0
- package/deps/zlib/doc/rfc1950.txt +619 -0
- package/deps/zlib/doc/rfc1951.txt +955 -0
- package/deps/zlib/doc/rfc1952.txt +675 -0
- package/deps/zlib/doc/txtvsbin.txt +107 -0
- package/deps/zlib/examples/README.examples +54 -0
- package/deps/zlib/examples/enough.c +597 -0
- package/deps/zlib/examples/fitblk.c +233 -0
- package/deps/zlib/examples/gun.c +702 -0
- package/deps/zlib/examples/gzappend.c +504 -0
- package/deps/zlib/examples/gzjoin.c +449 -0
- package/deps/zlib/examples/gzlog.c +1061 -0
- package/deps/zlib/examples/gzlog.h +91 -0
- package/deps/zlib/examples/gznorm.c +474 -0
- package/deps/zlib/examples/zlib_how.html +550 -0
- package/deps/zlib/examples/zpipe.c +206 -0
- package/deps/zlib/examples/zran.c +546 -0
- package/deps/zlib/examples/zran.h +53 -0
- package/deps/zlib/gzclose.c +23 -0
- package/deps/zlib/gzguts.h +216 -0
- package/deps/zlib/gzlib.c +609 -0
- package/deps/zlib/gzread.c +668 -0
- package/deps/zlib/gzwrite.c +700 -0
- package/deps/zlib/infback.c +581 -0
- package/deps/zlib/inffast.c +321 -0
- package/deps/zlib/inffast.h +11 -0
- package/deps/zlib/inffixed.h +94 -0
- package/deps/zlib/inflate.c +1413 -0
- package/deps/zlib/inflate.h +126 -0
- package/deps/zlib/inftrees.c +424 -0
- package/deps/zlib/inftrees.h +64 -0
- package/deps/zlib/make_vms.com +867 -0
- package/deps/zlib/msdos/Makefile.bor +115 -0
- package/deps/zlib/msdos/Makefile.dj2 +104 -0
- package/deps/zlib/msdos/Makefile.emx +69 -0
- package/deps/zlib/msdos/Makefile.msc +112 -0
- package/deps/zlib/msdos/Makefile.tc +100 -0
- package/deps/zlib/os400/README400 +48 -0
- package/deps/zlib/os400/bndsrc +144 -0
- package/deps/zlib/os400/make.sh +383 -0
- package/deps/zlib/os400/zlibfixed.rpgle +578 -0
- package/deps/zlib/os400/zlibfree.rpgle +634 -0
- package/deps/zlib/qnx/package.qpg +141 -0
- package/deps/zlib/test/CMakeLists.txt +318 -0
- package/deps/zlib/test/add_subdirectory_exclude_test.cmake.in +29 -0
- package/deps/zlib/test/add_subdirectory_test.cmake.in +28 -0
- package/deps/zlib/test/example.c +552 -0
- package/deps/zlib/test/find_package_no_components_test.cmake.in +27 -0
- package/deps/zlib/test/find_package_test.cmake.in +27 -0
- package/deps/zlib/test/find_package_wrong_components_test.cmake.in +27 -0
- package/deps/zlib/test/infcover.c +672 -0
- package/deps/zlib/test/minigzip.c +592 -0
- package/deps/zlib/treebuild.xml +116 -0
- package/deps/zlib/trees.c +1119 -0
- package/deps/zlib/trees.h +128 -0
- package/deps/zlib/uncompr.c +101 -0
- package/deps/zlib/watcom/watcom_f.mak +43 -0
- package/deps/zlib/watcom/watcom_l.mak +43 -0
- package/deps/zlib/win32/DLL_FAQ.txt +381 -0
- package/deps/zlib/win32/Makefile.bor +109 -0
- package/deps/zlib/win32/Makefile.gcc +177 -0
- package/deps/zlib/win32/Makefile.msc +159 -0
- package/deps/zlib/win32/README-WIN32.txt +103 -0
- package/deps/zlib/win32/VisualC.txt +3 -0
- package/deps/zlib/win32/zlib.def +104 -0
- package/deps/zlib/win32/zlib1.rc +37 -0
- package/deps/zlib/zconf.h.in +551 -0
- package/deps/zlib/zlib.3 +149 -0
- package/deps/zlib/zlib.3.pdf +0 -0
- package/deps/zlib/zlib.h +2057 -0
- package/deps/zlib/zlib.map +116 -0
- package/deps/zlib/zlib.pc.cmakein +14 -0
- package/deps/zlib/zlib.pc.in +14 -0
- package/deps/zlib/zlibConfig.cmake.in +18 -0
- package/deps/zlib/zutil.c +313 -0
- package/deps/zlib/zutil.h +331 -0
- package/dist/index.d.ts +266 -0
- package/dist/index.js +1146 -0
- package/dist/libwz.js +5632 -0
- package/dist/libwz.wasm +0 -0
- package/include/wz/CRC32.h +182 -0
- package/include/wz/PngUtility.h +72 -0
- package/include/wz/PortalType.h +124 -0
- package/include/wz/Properties/WzBinaryProperty.h +70 -0
- package/include/wz/Properties/WzCanvasProperty.h +55 -0
- package/include/wz/Properties/WzConvexProperty.h +34 -0
- package/include/wz/Properties/WzDoubleProperty.h +32 -0
- package/include/wz/Properties/WzFloatProperty.h +30 -0
- package/include/wz/Properties/WzIntProperty.h +30 -0
- package/include/wz/Properties/WzLongProperty.h +30 -0
- package/include/wz/Properties/WzLuaProperty.h +31 -0
- package/include/wz/Properties/WzNullProperty.h +15 -0
- package/include/wz/Properties/WzPngProperty.h +53 -0
- package/include/wz/Properties/WzRawDataProperty.h +46 -0
- package/include/wz/Properties/WzShortProperty.h +31 -0
- package/include/wz/Properties/WzStringProperty.h +32 -0
- package/include/wz/Properties/WzSubProperty.h +35 -0
- package/include/wz/Properties/WzUOLProperty.h +44 -0
- package/include/wz/Properties/WzVectorProperty.h +40 -0
- package/include/wz/Properties/WzVideoProperty.h +43 -0
- package/include/wz/Result.h +58 -0
- package/include/wz/Util/Defines.h +16 -0
- package/include/wz/Util/ListFileParser.h +20 -0
- package/include/wz/Util/WzBinaryReader.h +95 -0
- package/include/wz/Util/WzBinaryWriter.h +72 -0
- package/include/wz/Util/WzBlobDataSource.h +30 -0
- package/include/wz/Util/WzDataSource.h +49 -0
- package/include/wz/Util/WzKeyGenerator.h +28 -0
- package/include/wz/Util/WzMutableKey.h +39 -0
- package/include/wz/Util/WzPath.h +37 -0
- package/include/wz/Util/WzStream.h +86 -0
- package/include/wz/Util/WzTool.h +42 -0
- package/include/wz/WzAESConstant.h +17 -0
- package/include/wz/WzDirectory.h +97 -0
- package/include/wz/WzEnums.h +76 -0
- package/include/wz/WzFile.h +99 -0
- package/include/wz/WzHeader.h +47 -0
- package/include/wz/WzImage.h +97 -0
- package/include/wz/WzImageProperty.h +92 -0
- package/include/wz/WzObject.h +55 -0
- package/include/wz/WzPropertyCollection.h +115 -0
- package/include/wz/wz.h +41 -0
- package/include/wz/wz_api.h +432 -0
- package/package.json +93 -0
- package/src/PngUtility.cpp +328 -0
- package/src/Properties/WzBinaryProperty.cpp +183 -0
- package/src/Properties/WzCanvasProperty.cpp +262 -0
- package/src/Properties/WzConvexProperty.cpp +159 -0
- package/src/Properties/WzDoubleProperty.cpp +12 -0
- package/src/Properties/WzFloatProperty.cpp +17 -0
- package/src/Properties/WzIntProperty.cpp +12 -0
- package/src/Properties/WzLongProperty.cpp +12 -0
- package/src/Properties/WzLuaProperty.cpp +37 -0
- package/src/Properties/WzNullProperty.cpp +11 -0
- package/src/Properties/WzPngProperty.cpp +637 -0
- package/src/Properties/WzRawDataProperty.cpp +116 -0
- package/src/Properties/WzShortProperty.cpp +12 -0
- package/src/Properties/WzStringProperty.cpp +44 -0
- package/src/Properties/WzSubProperty.cpp +129 -0
- package/src/Properties/WzUOLProperty.cpp +136 -0
- package/src/Properties/WzVectorProperty.cpp +22 -0
- package/src/Properties/WzVideoProperty.cpp +115 -0
- package/src/Util/ListFileParser.cpp +48 -0
- package/src/Util/WzBinaryReader.cpp +368 -0
- package/src/Util/WzBinaryWriter.cpp +305 -0
- package/src/Util/WzBlobDataSource.cpp +47 -0
- package/src/Util/WzDataSource.cpp +61 -0
- package/src/Util/WzKeyGenerator.cpp +43 -0
- package/src/Util/WzMutableKey.cpp +59 -0
- package/src/Util/WzStream.cpp +196 -0
- package/src/Util/WzTool.cpp +266 -0
- package/src/WzAESConstant.cpp +12 -0
- package/src/WzDirectory.cpp +669 -0
- package/src/WzEnums.cpp +20 -0
- package/src/WzFile.cpp +450 -0
- package/src/WzImage.cpp +350 -0
- package/src/WzImageProperty.cpp +469 -0
- package/src/WzObject.cpp +174 -0
- package/src/WzPropertyCollection.cpp +84 -0
- package/src/capi/wz_api.cpp +1996 -0
- package/src/node/binding.cpp +1776 -0
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
/* example.c -- usage example of the zlib compression library
|
|
2
|
+
* Copyright (C) 1995-2026 Jean-loup Gailly
|
|
3
|
+
* For conditions of distribution and use, see copyright notice in zlib.h
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* @(#) $Id$ */
|
|
7
|
+
|
|
8
|
+
#if defined(_WIN32) && !defined(_CRT_SECURE_NO_WARNINGS)
|
|
9
|
+
# define _CRT_SECURE_NO_WARNINGS
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#include "zlib.h"
|
|
13
|
+
#include <stdio.h>
|
|
14
|
+
|
|
15
|
+
#ifdef STDC
|
|
16
|
+
# include <string.h>
|
|
17
|
+
# include <stdlib.h>
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
#if defined(VMS)
|
|
21
|
+
# define TESTFILE "foo-gz"
|
|
22
|
+
#elif defined(__riscos) && !defined(__TARGET_UNIXLIB__)
|
|
23
|
+
# define TESTFILE "foo/gz"
|
|
24
|
+
#else
|
|
25
|
+
# define TESTFILE "foo.gz"
|
|
26
|
+
#endif
|
|
27
|
+
|
|
28
|
+
#define CHECK_ERR(err, msg) { \
|
|
29
|
+
if (err != Z_OK) { \
|
|
30
|
+
fprintf(stderr, "%s error: %d\n", msg, err); \
|
|
31
|
+
exit(1); \
|
|
32
|
+
} \
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static z_const char hello[] = "hello, hello!";
|
|
36
|
+
/* "hello world" would be more standard, but the repeated "hello"
|
|
37
|
+
* stresses the compression code better, sorry...
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
static const char dictionary[] = "hello";
|
|
41
|
+
static uLong dictId; /* Adler32 value of the dictionary */
|
|
42
|
+
|
|
43
|
+
#ifdef Z_SOLO
|
|
44
|
+
|
|
45
|
+
static void *myalloc(void *q, unsigned n, unsigned m) {
|
|
46
|
+
(void)q;
|
|
47
|
+
return calloc(n, m);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static void myfree(void *q, void *p) {
|
|
51
|
+
(void)q;
|
|
52
|
+
free(p);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static alloc_func zalloc = myalloc;
|
|
56
|
+
static free_func zfree = myfree;
|
|
57
|
+
|
|
58
|
+
#else /* !Z_SOLO */
|
|
59
|
+
|
|
60
|
+
static alloc_func zalloc = (alloc_func)0;
|
|
61
|
+
static free_func zfree = (free_func)0;
|
|
62
|
+
|
|
63
|
+
/* ===========================================================================
|
|
64
|
+
* Test compress() and uncompress()
|
|
65
|
+
*/
|
|
66
|
+
static void test_compress(Byte *compr, uLong comprLen, Byte *uncompr,
|
|
67
|
+
uLong uncomprLen) {
|
|
68
|
+
int err;
|
|
69
|
+
uLong len = (uLong)strlen(hello)+1;
|
|
70
|
+
|
|
71
|
+
err = compress(compr, &comprLen, (const Bytef*)hello, len);
|
|
72
|
+
CHECK_ERR(err, "compress");
|
|
73
|
+
|
|
74
|
+
strcpy((char*)uncompr, "garbage");
|
|
75
|
+
|
|
76
|
+
err = uncompress(uncompr, &uncomprLen, compr, comprLen);
|
|
77
|
+
CHECK_ERR(err, "uncompress");
|
|
78
|
+
|
|
79
|
+
if (strcmp((char*)uncompr, hello)) {
|
|
80
|
+
fprintf(stderr, "bad uncompress\n");
|
|
81
|
+
exit(1);
|
|
82
|
+
} else {
|
|
83
|
+
printf("uncompress(): %s\n", (char *)uncompr);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* ===========================================================================
|
|
88
|
+
* Test read/write of .gz files
|
|
89
|
+
*/
|
|
90
|
+
static void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) {
|
|
91
|
+
#ifdef NO_GZCOMPRESS
|
|
92
|
+
fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
|
|
93
|
+
#else
|
|
94
|
+
int err;
|
|
95
|
+
int len = (int)strlen(hello)+1;
|
|
96
|
+
gzFile file;
|
|
97
|
+
z_off_t pos;
|
|
98
|
+
|
|
99
|
+
file = gzopen(fname, "wb");
|
|
100
|
+
if (file == NULL) {
|
|
101
|
+
fprintf(stderr, "gzopen error\n");
|
|
102
|
+
exit(1);
|
|
103
|
+
}
|
|
104
|
+
gzputc(file, 'h');
|
|
105
|
+
if (gzputs(file, "ello") != 4) {
|
|
106
|
+
fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err));
|
|
107
|
+
exit(1);
|
|
108
|
+
}
|
|
109
|
+
if (gzprintf(file, ", %s!", "hello") != 8) {
|
|
110
|
+
fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err));
|
|
111
|
+
exit(1);
|
|
112
|
+
}
|
|
113
|
+
gzseek(file, 1L, SEEK_CUR); /* add one zero byte */
|
|
114
|
+
gzclose(file);
|
|
115
|
+
|
|
116
|
+
file = gzopen(fname, "rb");
|
|
117
|
+
if (file == NULL) {
|
|
118
|
+
fprintf(stderr, "gzopen error\n");
|
|
119
|
+
exit(1);
|
|
120
|
+
}
|
|
121
|
+
strcpy((char*)uncompr, "garbage");
|
|
122
|
+
|
|
123
|
+
if (gzread(file, uncompr, (unsigned)uncomprLen) != len) {
|
|
124
|
+
fprintf(stderr, "gzread err: %s\n", gzerror(file, &err));
|
|
125
|
+
exit(1);
|
|
126
|
+
}
|
|
127
|
+
if (strcmp((char*)uncompr, hello)) {
|
|
128
|
+
fprintf(stderr, "bad gzread: %s\n", (char*)uncompr);
|
|
129
|
+
exit(1);
|
|
130
|
+
} else {
|
|
131
|
+
printf("gzread(): %s\n", (char*)uncompr);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
pos = gzseek(file, -8L, SEEK_CUR);
|
|
135
|
+
if (pos != 6 || gztell(file) != pos) {
|
|
136
|
+
fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
|
|
137
|
+
(long)pos, (long)gztell(file));
|
|
138
|
+
exit(1);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (gzgetc(file) != ' ') {
|
|
142
|
+
fprintf(stderr, "gzgetc error\n");
|
|
143
|
+
exit(1);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (gzungetc(' ', file) != ' ') {
|
|
147
|
+
fprintf(stderr, "gzungetc error\n");
|
|
148
|
+
exit(1);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
gzgets(file, (char*)uncompr, (int)uncomprLen);
|
|
152
|
+
if (strlen((char*)uncompr) != 7) { /* " hello!" */
|
|
153
|
+
fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err));
|
|
154
|
+
exit(1);
|
|
155
|
+
}
|
|
156
|
+
if (strcmp((char*)uncompr, hello + 6)) {
|
|
157
|
+
fprintf(stderr, "bad gzgets after gzseek\n");
|
|
158
|
+
exit(1);
|
|
159
|
+
} else {
|
|
160
|
+
printf("gzgets() after gzseek: %s\n", (char*)uncompr);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
gzclose(file);
|
|
164
|
+
#endif
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
#endif /* Z_SOLO */
|
|
168
|
+
|
|
169
|
+
/* ===========================================================================
|
|
170
|
+
* Test deflate() with small buffers
|
|
171
|
+
*/
|
|
172
|
+
static void test_deflate(Byte *compr, uLong comprLen) {
|
|
173
|
+
z_stream c_stream; /* compression stream */
|
|
174
|
+
int err;
|
|
175
|
+
uLong len = (uLong)strlen(hello)+1;
|
|
176
|
+
|
|
177
|
+
c_stream.zalloc = zalloc;
|
|
178
|
+
c_stream.zfree = zfree;
|
|
179
|
+
c_stream.opaque = (voidpf)0;
|
|
180
|
+
|
|
181
|
+
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
|
|
182
|
+
CHECK_ERR(err, "deflateInit");
|
|
183
|
+
|
|
184
|
+
c_stream.next_in = (z_const unsigned char *)hello;
|
|
185
|
+
c_stream.next_out = compr;
|
|
186
|
+
|
|
187
|
+
while (c_stream.total_in != len && c_stream.total_out < comprLen) {
|
|
188
|
+
c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */
|
|
189
|
+
err = deflate(&c_stream, Z_NO_FLUSH);
|
|
190
|
+
CHECK_ERR(err, "deflate");
|
|
191
|
+
}
|
|
192
|
+
/* Finish the stream, still forcing small buffers: */
|
|
193
|
+
for (;;) {
|
|
194
|
+
c_stream.avail_out = 1;
|
|
195
|
+
err = deflate(&c_stream, Z_FINISH);
|
|
196
|
+
if (err == Z_STREAM_END) break;
|
|
197
|
+
CHECK_ERR(err, "deflate");
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
err = deflateEnd(&c_stream);
|
|
201
|
+
CHECK_ERR(err, "deflateEnd");
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* ===========================================================================
|
|
205
|
+
* Test inflate() with small buffers
|
|
206
|
+
*/
|
|
207
|
+
static void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
|
|
208
|
+
uLong uncomprLen) {
|
|
209
|
+
int err;
|
|
210
|
+
z_stream d_stream; /* decompression stream */
|
|
211
|
+
|
|
212
|
+
strcpy((char*)uncompr, "garbage");
|
|
213
|
+
|
|
214
|
+
d_stream.zalloc = zalloc;
|
|
215
|
+
d_stream.zfree = zfree;
|
|
216
|
+
d_stream.opaque = (voidpf)0;
|
|
217
|
+
|
|
218
|
+
d_stream.next_in = compr;
|
|
219
|
+
d_stream.avail_in = 0;
|
|
220
|
+
d_stream.next_out = uncompr;
|
|
221
|
+
|
|
222
|
+
err = inflateInit(&d_stream);
|
|
223
|
+
CHECK_ERR(err, "inflateInit");
|
|
224
|
+
|
|
225
|
+
while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) {
|
|
226
|
+
d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */
|
|
227
|
+
err = inflate(&d_stream, Z_NO_FLUSH);
|
|
228
|
+
if (err == Z_STREAM_END) break;
|
|
229
|
+
CHECK_ERR(err, "inflate");
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
err = inflateEnd(&d_stream);
|
|
233
|
+
CHECK_ERR(err, "inflateEnd");
|
|
234
|
+
|
|
235
|
+
if (strcmp((char*)uncompr, hello)) {
|
|
236
|
+
fprintf(stderr, "bad inflate\n");
|
|
237
|
+
exit(1);
|
|
238
|
+
} else {
|
|
239
|
+
printf("inflate(): %s\n", (char *)uncompr);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* ===========================================================================
|
|
244
|
+
* Test deflate() with large buffers and dynamic change of compression level
|
|
245
|
+
*/
|
|
246
|
+
static void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
|
|
247
|
+
uLong uncomprLen) {
|
|
248
|
+
z_stream c_stream; /* compression stream */
|
|
249
|
+
int err;
|
|
250
|
+
|
|
251
|
+
c_stream.zalloc = zalloc;
|
|
252
|
+
c_stream.zfree = zfree;
|
|
253
|
+
c_stream.opaque = (voidpf)0;
|
|
254
|
+
|
|
255
|
+
err = deflateInit(&c_stream, Z_BEST_SPEED);
|
|
256
|
+
CHECK_ERR(err, "deflateInit");
|
|
257
|
+
|
|
258
|
+
c_stream.next_out = compr;
|
|
259
|
+
c_stream.avail_out = (uInt)comprLen;
|
|
260
|
+
|
|
261
|
+
/* At this point, uncompr is still mostly zeroes, so it should compress
|
|
262
|
+
* very well:
|
|
263
|
+
*/
|
|
264
|
+
c_stream.next_in = uncompr;
|
|
265
|
+
c_stream.avail_in = (uInt)uncomprLen;
|
|
266
|
+
err = deflate(&c_stream, Z_NO_FLUSH);
|
|
267
|
+
CHECK_ERR(err, "deflate");
|
|
268
|
+
if (c_stream.avail_in != 0) {
|
|
269
|
+
fprintf(stderr, "deflate not greedy\n");
|
|
270
|
+
exit(1);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/* Feed in already compressed data and switch to no compression: */
|
|
274
|
+
deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
|
|
275
|
+
c_stream.next_in = compr;
|
|
276
|
+
c_stream.avail_in = (uInt)uncomprLen/2;
|
|
277
|
+
err = deflate(&c_stream, Z_NO_FLUSH);
|
|
278
|
+
CHECK_ERR(err, "deflate");
|
|
279
|
+
|
|
280
|
+
/* Switch back to compressing mode: */
|
|
281
|
+
deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
|
|
282
|
+
c_stream.next_in = uncompr;
|
|
283
|
+
c_stream.avail_in = (uInt)uncomprLen;
|
|
284
|
+
err = deflate(&c_stream, Z_NO_FLUSH);
|
|
285
|
+
CHECK_ERR(err, "deflate");
|
|
286
|
+
|
|
287
|
+
err = deflate(&c_stream, Z_FINISH);
|
|
288
|
+
if (err != Z_STREAM_END) {
|
|
289
|
+
fprintf(stderr, "deflate should report Z_STREAM_END\n");
|
|
290
|
+
exit(1);
|
|
291
|
+
}
|
|
292
|
+
err = deflateEnd(&c_stream);
|
|
293
|
+
CHECK_ERR(err, "deflateEnd");
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/* ===========================================================================
|
|
297
|
+
* Test inflate() with large buffers
|
|
298
|
+
*/
|
|
299
|
+
static void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
|
|
300
|
+
uLong uncomprLen) {
|
|
301
|
+
int err;
|
|
302
|
+
z_stream d_stream; /* decompression stream */
|
|
303
|
+
|
|
304
|
+
strcpy((char*)uncompr, "garbage");
|
|
305
|
+
|
|
306
|
+
d_stream.zalloc = zalloc;
|
|
307
|
+
d_stream.zfree = zfree;
|
|
308
|
+
d_stream.opaque = (voidpf)0;
|
|
309
|
+
|
|
310
|
+
d_stream.next_in = compr;
|
|
311
|
+
d_stream.avail_in = (uInt)comprLen;
|
|
312
|
+
|
|
313
|
+
err = inflateInit(&d_stream);
|
|
314
|
+
CHECK_ERR(err, "inflateInit");
|
|
315
|
+
|
|
316
|
+
for (;;) {
|
|
317
|
+
d_stream.next_out = uncompr; /* discard the output */
|
|
318
|
+
d_stream.avail_out = (uInt)uncomprLen;
|
|
319
|
+
err = inflate(&d_stream, Z_NO_FLUSH);
|
|
320
|
+
if (err == Z_STREAM_END) break;
|
|
321
|
+
CHECK_ERR(err, "large inflate");
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
err = inflateEnd(&d_stream);
|
|
325
|
+
CHECK_ERR(err, "inflateEnd");
|
|
326
|
+
|
|
327
|
+
if (d_stream.total_out != 2*uncomprLen + uncomprLen/2) {
|
|
328
|
+
fprintf(stderr, "bad large inflate: %lu\n", d_stream.total_out);
|
|
329
|
+
exit(1);
|
|
330
|
+
} else {
|
|
331
|
+
printf("large_inflate(): OK\n");
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/* ===========================================================================
|
|
336
|
+
* Test deflate() with full flush
|
|
337
|
+
*/
|
|
338
|
+
static void test_flush(Byte *compr, uLong *comprLen) {
|
|
339
|
+
z_stream c_stream; /* compression stream */
|
|
340
|
+
int err;
|
|
341
|
+
uInt len = (uInt)strlen(hello)+1;
|
|
342
|
+
|
|
343
|
+
c_stream.zalloc = zalloc;
|
|
344
|
+
c_stream.zfree = zfree;
|
|
345
|
+
c_stream.opaque = (voidpf)0;
|
|
346
|
+
|
|
347
|
+
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
|
|
348
|
+
CHECK_ERR(err, "deflateInit");
|
|
349
|
+
|
|
350
|
+
c_stream.next_in = (z_const unsigned char *)hello;
|
|
351
|
+
c_stream.next_out = compr;
|
|
352
|
+
c_stream.avail_in = 3;
|
|
353
|
+
c_stream.avail_out = (uInt)*comprLen;
|
|
354
|
+
err = deflate(&c_stream, Z_FULL_FLUSH);
|
|
355
|
+
CHECK_ERR(err, "deflate");
|
|
356
|
+
|
|
357
|
+
compr[3]++; /* force an error in first compressed block */
|
|
358
|
+
c_stream.avail_in = len - 3;
|
|
359
|
+
|
|
360
|
+
err = deflate(&c_stream, Z_FINISH);
|
|
361
|
+
if (err != Z_STREAM_END) {
|
|
362
|
+
CHECK_ERR(err, "deflate");
|
|
363
|
+
}
|
|
364
|
+
err = deflateEnd(&c_stream);
|
|
365
|
+
CHECK_ERR(err, "deflateEnd");
|
|
366
|
+
|
|
367
|
+
*comprLen = c_stream.total_out;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/* ===========================================================================
|
|
371
|
+
* Test inflateSync()
|
|
372
|
+
*/
|
|
373
|
+
static void test_sync(Byte *compr, uLong comprLen, Byte *uncompr,
|
|
374
|
+
uLong uncomprLen) {
|
|
375
|
+
int err;
|
|
376
|
+
z_stream d_stream; /* decompression stream */
|
|
377
|
+
|
|
378
|
+
strcpy((char*)uncompr, "garbage");
|
|
379
|
+
|
|
380
|
+
d_stream.zalloc = zalloc;
|
|
381
|
+
d_stream.zfree = zfree;
|
|
382
|
+
d_stream.opaque = (voidpf)0;
|
|
383
|
+
|
|
384
|
+
d_stream.next_in = compr;
|
|
385
|
+
d_stream.avail_in = 2; /* just read the zlib header */
|
|
386
|
+
|
|
387
|
+
err = inflateInit(&d_stream);
|
|
388
|
+
CHECK_ERR(err, "inflateInit");
|
|
389
|
+
|
|
390
|
+
d_stream.next_out = uncompr;
|
|
391
|
+
d_stream.avail_out = (uInt)uncomprLen;
|
|
392
|
+
|
|
393
|
+
err = inflate(&d_stream, Z_NO_FLUSH);
|
|
394
|
+
CHECK_ERR(err, "inflate");
|
|
395
|
+
|
|
396
|
+
d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */
|
|
397
|
+
err = inflateSync(&d_stream); /* but skip the damaged part */
|
|
398
|
+
CHECK_ERR(err, "inflateSync");
|
|
399
|
+
|
|
400
|
+
err = inflate(&d_stream, Z_FINISH);
|
|
401
|
+
if (err != Z_STREAM_END) {
|
|
402
|
+
fprintf(stderr, "inflate should report Z_STREAM_END\n");
|
|
403
|
+
exit(1);
|
|
404
|
+
}
|
|
405
|
+
err = inflateEnd(&d_stream);
|
|
406
|
+
CHECK_ERR(err, "inflateEnd");
|
|
407
|
+
|
|
408
|
+
printf("after inflateSync(): hel%s\n", (char *)uncompr);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/* ===========================================================================
|
|
412
|
+
* Test deflate() with preset dictionary
|
|
413
|
+
*/
|
|
414
|
+
static void test_dict_deflate(Byte *compr, uLong comprLen) {
|
|
415
|
+
z_stream c_stream; /* compression stream */
|
|
416
|
+
int err;
|
|
417
|
+
|
|
418
|
+
c_stream.zalloc = zalloc;
|
|
419
|
+
c_stream.zfree = zfree;
|
|
420
|
+
c_stream.opaque = (voidpf)0;
|
|
421
|
+
|
|
422
|
+
err = deflateInit(&c_stream, Z_BEST_COMPRESSION);
|
|
423
|
+
CHECK_ERR(err, "deflateInit");
|
|
424
|
+
|
|
425
|
+
err = deflateSetDictionary(&c_stream,
|
|
426
|
+
(const Bytef*)dictionary, (int)sizeof(dictionary));
|
|
427
|
+
CHECK_ERR(err, "deflateSetDictionary");
|
|
428
|
+
|
|
429
|
+
dictId = c_stream.adler;
|
|
430
|
+
c_stream.next_out = compr;
|
|
431
|
+
c_stream.avail_out = (uInt)comprLen;
|
|
432
|
+
|
|
433
|
+
c_stream.next_in = (z_const unsigned char *)hello;
|
|
434
|
+
c_stream.avail_in = (uInt)strlen(hello)+1;
|
|
435
|
+
|
|
436
|
+
err = deflate(&c_stream, Z_FINISH);
|
|
437
|
+
if (err != Z_STREAM_END) {
|
|
438
|
+
fprintf(stderr, "deflate should report Z_STREAM_END\n");
|
|
439
|
+
exit(1);
|
|
440
|
+
}
|
|
441
|
+
err = deflateEnd(&c_stream);
|
|
442
|
+
CHECK_ERR(err, "deflateEnd");
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/* ===========================================================================
|
|
446
|
+
* Test inflate() with a preset dictionary
|
|
447
|
+
*/
|
|
448
|
+
static void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
|
|
449
|
+
uLong uncomprLen) {
|
|
450
|
+
int err;
|
|
451
|
+
z_stream d_stream; /* decompression stream */
|
|
452
|
+
|
|
453
|
+
strcpy((char*)uncompr, "garbage");
|
|
454
|
+
|
|
455
|
+
d_stream.zalloc = zalloc;
|
|
456
|
+
d_stream.zfree = zfree;
|
|
457
|
+
d_stream.opaque = (voidpf)0;
|
|
458
|
+
|
|
459
|
+
d_stream.next_in = compr;
|
|
460
|
+
d_stream.avail_in = (uInt)comprLen;
|
|
461
|
+
|
|
462
|
+
err = inflateInit(&d_stream);
|
|
463
|
+
CHECK_ERR(err, "inflateInit");
|
|
464
|
+
|
|
465
|
+
d_stream.next_out = uncompr;
|
|
466
|
+
d_stream.avail_out = (uInt)uncomprLen;
|
|
467
|
+
|
|
468
|
+
for (;;) {
|
|
469
|
+
err = inflate(&d_stream, Z_NO_FLUSH);
|
|
470
|
+
if (err == Z_STREAM_END) break;
|
|
471
|
+
if (err == Z_NEED_DICT) {
|
|
472
|
+
if (d_stream.adler != dictId) {
|
|
473
|
+
fprintf(stderr, "unexpected dictionary");
|
|
474
|
+
exit(1);
|
|
475
|
+
}
|
|
476
|
+
err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary,
|
|
477
|
+
(int)sizeof(dictionary));
|
|
478
|
+
}
|
|
479
|
+
CHECK_ERR(err, "inflate with dict");
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
err = inflateEnd(&d_stream);
|
|
483
|
+
CHECK_ERR(err, "inflateEnd");
|
|
484
|
+
|
|
485
|
+
if (strcmp((char*)uncompr, hello)) {
|
|
486
|
+
fprintf(stderr, "bad inflate with dict\n");
|
|
487
|
+
exit(1);
|
|
488
|
+
} else {
|
|
489
|
+
printf("inflate with dictionary: %s\n", (char *)uncompr);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/* ===========================================================================
|
|
494
|
+
* Usage: example [output.gz [input.gz]]
|
|
495
|
+
*/
|
|
496
|
+
|
|
497
|
+
int main(int argc, char *argv[]) {
|
|
498
|
+
Byte *compr, *uncompr;
|
|
499
|
+
uLong uncomprLen = 20000;
|
|
500
|
+
uLong comprLen = 3 * uncomprLen;
|
|
501
|
+
static const char* myVersion = ZLIB_VERSION;
|
|
502
|
+
|
|
503
|
+
if (zlibVersion()[0] != myVersion[0]) {
|
|
504
|
+
fprintf(stderr, "incompatible zlib version\n");
|
|
505
|
+
exit(1);
|
|
506
|
+
|
|
507
|
+
} else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) {
|
|
508
|
+
fprintf(stderr, "warning: different zlib version linked: %s\n",
|
|
509
|
+
zlibVersion());
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n",
|
|
513
|
+
ZLIB_VERSION, (unsigned)ZLIB_VERNUM, zlibCompileFlags());
|
|
514
|
+
|
|
515
|
+
compr = (Byte*)calloc((uInt)comprLen, 1);
|
|
516
|
+
uncompr = (Byte*)calloc((uInt)uncomprLen, 1);
|
|
517
|
+
/* compr and uncompr are cleared to avoid reading uninitialized
|
|
518
|
+
* data and to ensure that uncompr compresses well.
|
|
519
|
+
*/
|
|
520
|
+
if (compr == Z_NULL || uncompr == Z_NULL) {
|
|
521
|
+
printf("out of memory\n");
|
|
522
|
+
exit(1);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
#ifdef Z_SOLO
|
|
526
|
+
(void)argc;
|
|
527
|
+
(void)argv;
|
|
528
|
+
#else
|
|
529
|
+
test_compress(compr, comprLen, uncompr, uncomprLen);
|
|
530
|
+
|
|
531
|
+
test_gzio((argc > 1 ? argv[1] : TESTFILE),
|
|
532
|
+
uncompr, uncomprLen);
|
|
533
|
+
#endif
|
|
534
|
+
|
|
535
|
+
test_deflate(compr, comprLen);
|
|
536
|
+
test_inflate(compr, comprLen, uncompr, uncomprLen);
|
|
537
|
+
|
|
538
|
+
test_large_deflate(compr, comprLen, uncompr, uncomprLen);
|
|
539
|
+
test_large_inflate(compr, comprLen, uncompr, uncomprLen);
|
|
540
|
+
|
|
541
|
+
test_flush(compr, &comprLen);
|
|
542
|
+
test_sync(compr, comprLen, uncompr, uncomprLen);
|
|
543
|
+
comprLen = 3 * uncomprLen;
|
|
544
|
+
|
|
545
|
+
test_dict_deflate(compr, comprLen);
|
|
546
|
+
test_dict_inflate(compr, comprLen, uncompr, uncomprLen);
|
|
547
|
+
|
|
548
|
+
free(compr);
|
|
549
|
+
free(uncompr);
|
|
550
|
+
|
|
551
|
+
return 0;
|
|
552
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.12...3.31)
|
|
2
|
+
|
|
3
|
+
project(
|
|
4
|
+
zlib_find_package_test
|
|
5
|
+
LANGUAGES C
|
|
6
|
+
VERSION @zlib_VERSION@)
|
|
7
|
+
|
|
8
|
+
enable_testing()
|
|
9
|
+
option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
|
|
10
|
+
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
|
|
11
|
+
|
|
12
|
+
find_package(ZLIB @zlib_VERSION@ CONFIG REQUIRED)
|
|
13
|
+
|
|
14
|
+
if(ZLIB_BUILD_SHARED)
|
|
15
|
+
add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
|
|
16
|
+
target_link_libraries(test_example ZLIB::ZLIB)
|
|
17
|
+
|
|
18
|
+
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
|
|
19
|
+
add_test(NAME zlib_test_example_shared COMMAND test_example)
|
|
20
|
+
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
|
|
21
|
+
endif(ZLIB_BUILD_SHARED)
|
|
22
|
+
|
|
23
|
+
if(ZLIB_BUILD_STATIC)
|
|
24
|
+
add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
|
|
25
|
+
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
|
|
26
|
+
add_test(NAME zlib_test_example_static COMMAND test_example_static)
|
|
27
|
+
endif(ZLIB_BUILD_STATIC)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.12...3.31)
|
|
2
|
+
|
|
3
|
+
project(
|
|
4
|
+
zlib_find_package_test
|
|
5
|
+
LANGUAGES C
|
|
6
|
+
VERSION @zlib_VERSION@)
|
|
7
|
+
|
|
8
|
+
enable_testing()
|
|
9
|
+
option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
|
|
10
|
+
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
|
|
11
|
+
|
|
12
|
+
if(ZLIB_BUILD_SHARED)
|
|
13
|
+
find_package(ZLIB @zlib_VERSION@ CONFIG COMPONENTS shared REQUIRED)
|
|
14
|
+
add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
|
|
15
|
+
target_link_libraries(test_example ZLIB::ZLIB)
|
|
16
|
+
|
|
17
|
+
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
|
|
18
|
+
add_test(NAME zlib_test_example_shared COMMAND test_example)
|
|
19
|
+
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
|
|
20
|
+
endif(ZLIB_BUILD_SHARED)
|
|
21
|
+
|
|
22
|
+
if(ZLIB_BUILD_STATIC)
|
|
23
|
+
find_package(ZLIB @zlib_VERSION@ CONFIG COMPONENTS static REQUIRED)
|
|
24
|
+
add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
|
|
25
|
+
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
|
|
26
|
+
add_test(NAME zlib_test_example_static COMMAND test_example_static)
|
|
27
|
+
endif(ZLIB_BUILD_STATIC)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.12...3.31)
|
|
2
|
+
|
|
3
|
+
project(
|
|
4
|
+
zlib_find_package_test
|
|
5
|
+
LANGUAGES C
|
|
6
|
+
VERSION @zlib_VERSION@)
|
|
7
|
+
|
|
8
|
+
enable_testing()
|
|
9
|
+
option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
|
|
10
|
+
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
|
|
11
|
+
|
|
12
|
+
find_package(ZLIB @zlib_VERSION@ CONFIG COMPONENTS wrong REQUIRED)
|
|
13
|
+
|
|
14
|
+
if(ZLIB_BUILD_SHARED)
|
|
15
|
+
add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
|
|
16
|
+
target_link_libraries(test_example ZLIB::ZLIB)
|
|
17
|
+
|
|
18
|
+
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
|
|
19
|
+
add_test(NAME zlib_test_example_shared COMMAND test_example)
|
|
20
|
+
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
|
|
21
|
+
endif(ZLIB_BUILD_SHARED)
|
|
22
|
+
|
|
23
|
+
if(ZLIB_BUILD_STATIC)
|
|
24
|
+
add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
|
|
25
|
+
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
|
|
26
|
+
add_test(NAME zlib_test_example_static COMMAND test_example_static)
|
|
27
|
+
endif(ZLIB_BUILD_STATIC)
|