diff --git a/.gitignore b/.gitignore index 9ac6d88..fc93efe 100755 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,7 @@ # Mono auto generated files mono_crash.* - +......................................................................... # Build results [Dd]ebug/ [Dd]ebugPublic/ @@ -394,4 +394,7 @@ sdl_app *.sln.iml images.zip -script.py \ No newline at end of file +script.py + +jumpingbird.* +build \ No newline at end of file diff --git a/BoneAnimatedModel.cpp b/BoneAnimatedModel.cpp index 5e51a46..9b8efca 100644 --- a/BoneAnimatedModel.cpp +++ b/BoneAnimatedModel.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace ZL { diff --git a/Readme.md b/Readme.md index 0120310..20e4a13 100644 --- a/Readme.md +++ b/Readme.md @@ -45,7 +45,27 @@ $(pkg-config --cflags --libs vorbis vorbisfile ogg) \ -lopenal ``` +# Emscripten new + +``` + +cd build-emcmake/ + +emcmake cmake .. + + emcmake cmake -DCMAKE_INSTALL_PREFIX=install .. + cmake --build . + + cmake --install . + + +emcc main.cpp Game.cpp Environment.cpp GameObjectManager.cpp BoneAnimatedModel.cpp GameWorld.cpp InputManager.cpp Inventory.cpp ObjLoader.cpp QuestScripts.cpp RenderSystem.cpp Math.cpp Physics.cpp Renderer.cpp TextModel.cpp ShaderManager.cpp TextureManager.cpp Utils.cpp OpenGlExtensions.cpp -O2 -std=c++14 -IC:\Users\ASUS\Desktop\fishrungame2\ZeptoLabTest1\thirdparty\libzip-1.11.3\build-emcmake\install\include -LC:\Users\ASUS\Desktop\fishrungame2\ZeptoLabTest1\thirdparty\libzip-1.11.3\build-emcmake\install\lib -lzip -sTOTAL_MEMORY=33554432 -sUSE_SDL_IMAGE=2 -sSDL2_IMAGE_FORMATS="[""png""]" -sUSE_SDL=2 --preload-file background.bmp --preload-file bird.bmp32 --preload-file default.fragment --preload-file default.vertex --preload-file game_over.bmp32 --preload-file pipe.bmp32 -o jumpingbird.html + +``` + # License Code: MIT Art: CC-BY + + diff --git a/TextModel.cpp b/TextModel.cpp index 19589b8..2acd919 100644 --- a/TextModel.cpp +++ b/TextModel.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace ZL { diff --git a/main.cpp b/main.cpp index d20823f..ff56a4a 100755 --- a/main.cpp +++ b/main.cpp @@ -1,6 +1,9 @@ #include "Game.h" #include "Environment.h" - +ZL::Game game; +void MainLoop() { + game.update(); +} int main(int argc, char* argv[]) { constexpr int CONST_WIDTH = 1280; constexpr int CONST_HEIGHT = 720; @@ -8,11 +11,10 @@ int main(int argc, char* argv[]) { ZL::Environment::width = CONST_WIDTH; ZL::Environment::height = CONST_HEIGHT; - ZL::Game game; game.setup(); #ifdef EMSCRIPTEN - emscripten_set_main_loop([](){ game.update(); }, 0, 1); + emscripten_set_main_loop(MainLoop, 0, 1); #else while (!game.shouldExit()) { game.update(); diff --git a/thirdparty/libzip-1.11.3/.clang-format b/thirdparty/libzip-1.11.3/.clang-format new file mode 100644 index 0000000..8bb62b8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/.clang-format @@ -0,0 +1,12 @@ +BasedOnStyle: LLVM +IndentWidth: 4 +ColumnLimit: 2000 +AlwaysBreakAfterReturnType: TopLevelDefinitions +KeepEmptyLinesAtTheStartOfBlocks: false +MaxEmptyLinesToKeep: 2 +BreakBeforeBraces: Custom +BraceWrapping: + BeforeElse: true +AlignEscapedNewlines: Left +UseTab: Never +#PPDirectiveIndentStyle: AfterHash diff --git a/thirdparty/libzip-1.11.3/.github/ISSUE_TEMPLATE/bug-report.md b/thirdparty/libzip-1.11.3/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 0000000..86c1078 --- /dev/null +++ b/thirdparty/libzip-1.11.3/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,32 @@ +--- +name: Bug Report +about: Report where libzip didn't behave like you expected. +title: '' +labels: bug +assignees: '' + +--- + +**Describe the Bug** +A clear and concise description of what the bug is. + +**Expected Behavior** +A clear and concise description of what you expected to happen. + +**Observed Behavior** +A clear and concise description of what actually happened. + +**To Reproduce** +Short program or code snippet that reproduces the problem. + +**libzip Version** +Version of libzip or revision repository used. + +**Operating System** +Operating system and version, used compiler. + +**Test Files** +If applicable, attach and describe zip archives that trigger the problem. + +**Additional context** +Add any other context about the problem here. diff --git a/thirdparty/libzip-1.11.3/.github/ISSUE_TEMPLATE/compile-error.md b/thirdparty/libzip-1.11.3/.github/ISSUE_TEMPLATE/compile-error.md new file mode 100644 index 0000000..45c8a7a --- /dev/null +++ b/thirdparty/libzip-1.11.3/.github/ISSUE_TEMPLATE/compile-error.md @@ -0,0 +1,25 @@ +--- +name: Compile Error +about: Report when libzip does not compile. +title: '' +labels: compile +assignees: '' + +--- + +**Compiler Error** +Output from the compiler, including exact and complete error message, file name and line number. + +**libzip Version** +Version of libzip or revision repository used. + +**Operating System and Compiler** +The operating system and compiler used, including version number. + +Also, any flags passed to `cmake`. + +**Autodetected Configuration** +Attach `CmakeCache.txt` from your build directory. This list everything `cmake` detected on your system. + +**Additional context** +Add any other context about the problem here. diff --git a/thirdparty/libzip-1.11.3/.github/ISSUE_TEMPLATE/feature-request.md b/thirdparty/libzip-1.11.3/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 0000000..c23381e --- /dev/null +++ b/thirdparty/libzip-1.11.3/.github/ISSUE_TEMPLATE/feature-request.md @@ -0,0 +1,22 @@ +--- +name: Feature Request +about: Suggest an idea for this project. +title: '' +labels: enhancement +assignees: '' + +--- + +**Description** +A clear and concise description of what you want to achieve, why the current features are insufficient, and why you think it is generally useful. + +Also, have you checked whether the feature is already mentioned in TODO.md? If so, only submit a new issue if you expand on it. + +**Solution** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context about the feature request here. diff --git a/thirdparty/libzip-1.11.3/.github/ISSUE_TEMPLATE/other.md b/thirdparty/libzip-1.11.3/.github/ISSUE_TEMPLATE/other.md new file mode 100644 index 0000000..c33ef01 --- /dev/null +++ b/thirdparty/libzip-1.11.3/.github/ISSUE_TEMPLATE/other.md @@ -0,0 +1,10 @@ +--- +name: Other +about: If you have a question about libzip , consider using Discussions instead. +title: '' +labels: '' +assignees: '' + +--- + + diff --git a/thirdparty/libzip-1.11.3/.github/workflows/CIFuzz.yml b/thirdparty/libzip-1.11.3/.github/workflows/CIFuzz.yml new file mode 100644 index 0000000..8d181e2 --- /dev/null +++ b/thirdparty/libzip-1.11.3/.github/workflows/CIFuzz.yml @@ -0,0 +1,25 @@ +name: CIFuzz +on: [pull_request] +permissions: + contents: read +jobs: + Fuzzing: + runs-on: ubuntu-latest + steps: + - name: Build Fuzzers + uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master + with: + oss-fuzz-project-name: 'libzip' + dry-run: false + - name: Run Fuzzers + uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master + with: + oss-fuzz-project-name: 'libzip' + fuzz-seconds: 600 + dry-run: false + - name: Upload Crash + uses: actions/upload-artifact@v4 + if: failure() + with: + name: artifacts + path: ./out/artifacts diff --git a/thirdparty/libzip-1.11.3/.github/workflows/bsd.yml b/thirdparty/libzip-1.11.3/.github/workflows/bsd.yml new file mode 100644 index 0000000..258f656 --- /dev/null +++ b/thirdparty/libzip-1.11.3/.github/workflows/bsd.yml @@ -0,0 +1,23 @@ +name: BSD +on: [push] +jobs: + NetBSD: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + - name: NetBSD test + uses: vmactions/netbsd-vm@v1 + with: + usesh: true + copyback: false + prepare: | + /usr/sbin/pkg_add cmake zstd py313-pip + /usr/pkg/bin/pip-3.13 install nihtest + # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-system-path + echo "/usr/pkg/bin" >> "$GITHUB_PATH" + run: | + cmake -E make_directory ${{runner.workspace}}/build + cmake ${{ matrix.cmake_extra }} ${{github.workspace}} + cmake --build . --config Release + ctest --output-on-failure -V -C Release diff --git a/thirdparty/libzip-1.11.3/.github/workflows/build.yml b/thirdparty/libzip-1.11.3/.github/workflows/build.yml new file mode 100644 index 0000000..ff3f15c --- /dev/null +++ b/thirdparty/libzip-1.11.3/.github/workflows/build.yml @@ -0,0 +1,65 @@ +name: build +on: [push] +permissions: + contents: read +jobs: + all: + runs-on: ${{ matrix.os }} + name: ${{ matrix.os }}${{ matrix.name_extra }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + cmake_extra: [""] + name_extra: [""] + include: + - os: windows-latest + cmake_extra: "-T ClangCl" + name_extra: " clang-cl" + steps: + - name: checkout + uses: actions/checkout@v4 + - name: install python and pip + uses: actions/setup-python@v5 + with: + python-version: '3.11' + - name: install dependencies (Linux) + if: ${{ runner.os == 'Linux' }} + run: | + sudo apt-get install libzstd-dev + - name: install latest CMake and Ninja for lukka/run-vcpkg (Windows) + if: ${{ runner.os == 'Windows' }} + uses: lukka/get-cmake@latest + - name: install dependencies (Windows) + if: ${{ runner.os == 'Windows' }} + uses: lukka/run-vcpkg@v11 + with: + vcpkgGitCommitId: 2cf957350da28ad032178a974607f59f961217d9 + - name: prepare build directory and install nihtest + run: | + cmake -E make_directory ${{runner.workspace}}/build + pip install nihtest + - name: configure (Unix) + if: ${{ runner.os != 'Windows' }} + working-directory: ${{runner.workspace}}/build + run: | + cmake ${{ matrix.cmake_extra }} ${{github.workspace}} + - name: configure (Windows) + if: ${{ runner.os == 'Windows' }} + working-directory: ${{runner.workspace}}/build + run: | + cmake ${{ matrix.cmake_extra }} -DCMAKE_TOOLCHAIN_FILE=${{env.VCPKG_ROOT}}/scripts/buildsystems/vcpkg.cmake ${{github.workspace}} + - name: build + working-directory: ${{runner.workspace}}/build + run: | + cmake --build . --config Release + - name: Archive production artifacts + uses: actions/upload-artifact@v4 + with: + name: regress-directory-${{ matrix.os }}-${{ matrix.name_extra }} + path: | + ${{runner.workspace}}/build/regress + - name: test + working-directory: ${{runner.workspace}}/build + run: | + ctest --output-on-failure -V -C Release diff --git a/thirdparty/libzip-1.11.3/.github/workflows/codeql-analysis.yml b/thirdparty/libzip-1.11.3/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..de54490 --- /dev/null +++ b/thirdparty/libzip-1.11.3/.github/workflows/codeql-analysis.yml @@ -0,0 +1,74 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +name: "CodeQL" + +on: + push: + branches: [master] + pull_request: + # The branches below must be a subset of the branches above + branches: [master] + schedule: + - cron: '0 10 * * 4' + +permissions: + contents: read + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + # Override automatic language detection by changing the below list + # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] + language: ['cpp'] + # Learn more... + # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + # We must fetch at least the immediate parents so that if this is + # a pull request then we can checkout the head. + fetch-depth: 2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 diff --git a/thirdparty/libzip-1.11.3/.github/workflows/coverity.yml b/thirdparty/libzip-1.11.3/.github/workflows/coverity.yml new file mode 100644 index 0000000..cddbfc9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/.github/workflows/coverity.yml @@ -0,0 +1,80 @@ +name: Coverity + +on: + schedule: + - cron: '0 3 * * 1' + # Mondays at 03:00 + workflow_dispatch: + +jobs: + build: + name: Coverity + runs-on: ubuntu-latest + environment: coverity + + env: + TOKEN: ${{ secrets.COVERITY_TOKEN }} + PROJECT: libzip + SHORT_PROJECT: libzip + EMAIL: wiz@gatalith.at + COV_TOOLS: cov-tools + COV_RESULTS: cov-int + + steps: + - name: Check Secret + run: | + [ -n "${{ secrets.COVERITY_TOKEN }}" ] + + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Install Dependencies + run: | + sudo apt-get install libzstd-dev + + - name: Configure + run: | + cmake -E make_directory ${{runner.workspace}}/build + cmake ${{ matrix.cmake_extra }} ${{github.workspace}} + + - name: Download Coverity + run: | + wget --quiet https://scan.coverity.com/download/linux64 --post-data "token=$TOKEN&project=$PROJECT" -O "$COV_TOOLS.tar.gz" + mkdir "$COV_TOOLS" + tar xzf "$COV_TOOLS.tar.gz" --strip 1 -C "$COV_TOOLS" + ls -l "$COV_TOOLS" + + - name: Build with Coverity + run: | + export PATH="$(pwd)/$COV_TOOLS/bin:$PATH" + cov-build --dir $COV_RESULTS make -j ${{steps.cpu-cores.outputs.count}} + # Filter out private info + sed -E -i 's/TOKEN=([-_A-Za-z0-9]+)/TOKEN=XXX/g' cov-int/build-log.txt + + - name: Upload build log + uses: actions/upload-artifact@v4 + with: + name: build-log + path: cov-int/build-log.txt + retention-days: 10 + + - name: Submit Results + run: | + tar -czf $SHORT_PROJECT.tgz $COV_RESULTS + ls -lh $SHORT_PROJECT.tgz + git config --global --add safe.directory "$GITHUB_WORKSPACE" + GIT_HASH="$(git rev-parse --short HEAD)" + echo "HASH: $GIT_HASH" + GIT_DESC="$(git log -n1 --format="%s" $GIT_HASH)" + echo "DESC: $GIT_DESC" + curl --fail --output curl.log \ + --form token=$TOKEN \ + --form email=$EMAIL \ + --form file=@$SHORT_PROJECT.tgz \ + --form version="$GIT_HASH" \ + --form description="$GIT_DESC" \ + https://scan.coverity.com/builds?project=$PROJECT + # If we go over quota, alert the user + cat curl.log + grep -qv "quota.*reached" curl.log || false + diff --git a/thirdparty/libzip-1.11.3/API-CHANGES.md b/thirdparty/libzip-1.11.3/API-CHANGES.md new file mode 100644 index 0000000..4bfb7b2 --- /dev/null +++ b/thirdparty/libzip-1.11.3/API-CHANGES.md @@ -0,0 +1,174 @@ +# libzip API changes + +This file describes changes in the libzip API and how to adapt your +code for them. + +You can define `ZIP_DISABLE_DEPRECATED` before including `` to hide +prototypes for deprecated functions, to find out about functions that +might be removed at some point. + +## Changed in libzip-1.10.0 + +### deprecated `zip_source_zip` and `zip_source_zip_create` + +These functions were replaced with `zip_source_zip_file` and `zip_source_zip_file_create`. The implicit handling of the flag `ZIP_FL_COMPRESSED` was removed, the flag can now be specified explicitly. + +If you want to get the compressed data for the whole file, use + +```C +zip_source_zip_file(za, source_archive, source_index, ZIP_FL_COMPRESSED, 0, -1, NULL) +``` + +## Changed in libzip-1.0 + +### new type `zip_error_t` + +Error information is stored in the newly public type `zip_error_t`. Use +this to access information about an error, instead of the deprecated +functions that operated on two ints. + +deprecated functions: +- `zip_error_get_sys_type()` +- `zip_error_get()` +- `zip_error_to_str()` +- `zip_file_error_get()` + +See their man pages for instructions on how to replace them. + +The most common affected use is `zip_open`. The new recommended usage +is: + +```c +int err; +if ((za = zip_open(archive, flags, &err)) == NULL) { + zip_error_t error; + zip_error_init_with_code(&error, err); + fprintf(stderr, "can't open zip archive '%s': %s\n", archive, zip_error_strerror(&error)); + zip_error_fini(&error); +} +``` + +### more typedefs + +The following typedefs have been added for better readability: + +```c +typedef struct zip zip_t; +typedef struct zip_file zip_file_t; +typedef struct zip_source zip_source_t; +typedef struct zip_stat zip_stat_t; +``` + +This means you can use "`zip_t`" instead of "`struct zip`", etc. + + +### torrentzip support removed + +torrentzip depends on a particular zlib version which is by now quite +old. + +## Changed in libzip-0.11 + +### new type `zip_flags_t` + +The functions which have flags now use the `zip_flags_t` type for this. +All old flags fit; you need only to adapt code if you were saving flags in a +local variable. Use `zip_flags_t` for such a variable. +This affects: +- `zip_fopen()` +- `zip_fopen_encrypted()` +- `zip_fopen_index()` +- `zip_fopen_index_encrypted()` +- `zip_get_archive_comment()` +- `zip_get_archive_flag()` +- `zip_get_num_entries()` +- `zip_get_name()` +- `zip_name_locate()` +- `zip_set_archive_flag()` +- `zip_source_zip()` +- `zip_stat()` +- `zip_stat_index()` + +#### `ZIP_FL_*`, `ZIP_AFL_*`, `ZIP_STAT_*` are now unsigned constants + +To match the new `zip_flags_t` type. + +#### `zip_add()`, `zip_add_dir()` + +These functions were replaced with `zip_file_add()` and `zip_dir_add()`, respectively, +to add a flags argument. + +#### `zip_rename()`, `zip_replace()` + +These functions were replaced with `zip_file_rename()` and `zip_file_replace()`, +respectively, to add a flags argument. + +#### `zip_get_file_comment()` + +This function was replaced with `zip_file_get_comment()`; one argument was promoted from +`int` to `zip_uint32_t`, the other is now a `zip_flags_t`. + +#### `zip_set_file_comment()` + +This function was replaced with `zip_file_set_comment()`; an argument was promoted from +`int` to `zip_uint16_t`, and a `zip_flags_t` argument was added. + +### integer type size changes + +Some argument and return values were not the right size or sign. + +#### `zip_name_locate()` + +The return value was `int`, which can be too small. The function now returns `zip_int64_t`. + + +#### `zip_get_num_entries()` + +The return type is now signed, to allow signaling errors. + +#### `zip_set_archive_comment()` + +The last argument changed from `int` to `zip_uint16_t`. + +### extra field handling rewritten + +The `zip_get_file_extra()` and `zip_set_file_extra()` functions were removed. +They only worked on the whole extra field set. + +Instead, you can now set, get, count, and delete each extra field separately, +using the functions: +- `zip_file_extra_field_delete()` +- `zip_file_extra_field_delete_by_id()` +- `zip_file_extra_field_get()` +- `zip_file_extra_field_get_by_id()` +- `zip_file_extra_fields_count()` +- `zip_file_extra_fields_count_by_id()` +- `zip_file_extra_field_set()` + +Please read the corresponding man pages for details. + +### new functions + +#### `zip_discard()` + +The new `zip_discard()` function closes an archive without committing the +scheduled changes. + +#### `zip_set_file_compression()` + +The new `zip_set_file_compression()` function allows setting compression +levels for files. + +### argument changes + +#### file names + +File names arguments are now allowed to be `NULL` to have an empty file name. +This mostly affects `zip_file_add()`, `zip_dir_add()`, and `zip_file_rename()`. + +For `zip_get_name()`, `zip_file_get_comment()`, and `zip_get_archive_comment()`, if +the file name or comment is empty, a string of length 0 is returned. +`NULL` is returned for errors only. + +Previously, `NULL` was returned for empty/unset file names and comments and +errors, leaving no way to differentiate between the two. diff --git a/thirdparty/libzip-1.11.3/AUTHORS b/thirdparty/libzip-1.11.3/AUTHORS new file mode 100644 index 0000000..12f7a88 --- /dev/null +++ b/thirdparty/libzip-1.11.3/AUTHORS @@ -0,0 +1,2 @@ +Dieter Baron +Thomas Klausner diff --git a/thirdparty/libzip-1.11.3/CMakeLists.txt b/thirdparty/libzip-1.11.3/CMakeLists.txt new file mode 100644 index 0000000..472a7a2 --- /dev/null +++ b/thirdparty/libzip-1.11.3/CMakeLists.txt @@ -0,0 +1,498 @@ +cmake_minimum_required(VERSION 3.10) + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) +if (${CMAKE_VERSION} VERSION_LESS "3.17.0") + list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake-compat) +endif() + +project(libzip + VERSION 1.11.3 + LANGUAGES C) + +if(NOT libzip_VERSION_PATCH) + set(libzip_VERSION_PATCH 0) +endif() + +option(ENABLE_COMMONCRYPTO "Enable use of CommonCrypto" ON) +option(ENABLE_GNUTLS "Enable use of GnuTLS" ON) +option(ENABLE_MBEDTLS "Enable use of mbed TLS" ON) +option(ENABLE_OPENSSL "Enable use of OpenSSL" ON) +option(ENABLE_WINDOWS_CRYPTO "Enable use of Windows cryptography libraries" ON) + +option(ENABLE_BZIP2 "Enable use of BZip2" ON) +option(ENABLE_LZMA "Enable use of LZMA" ON) +option(ENABLE_ZSTD "Enable use of Zstandard" ON) + +option(ENABLE_FDOPEN "Enable zip_fdopen, which is not allowed in Microsoft CRT secure libraries" ON) + +option(BUILD_TOOLS "Build tools in the src directory (zipcmp, zipmerge, ziptool)" ON) +option(BUILD_REGRESS "Build regression tests" ON) +option(BUILD_OSSFUZZ "Build fuzzers for ossfuzz" ON) +option(BUILD_EXAMPLES "Build examples" ON) +option(BUILD_DOC "Build documentation" ON) + +include(CheckFunctionExists) +include(CheckIncludeFiles) +include(CheckLibraryExists) +include(CheckSymbolExists) +include(CheckTypeSize) +include(CheckCSourceRuns) +include(CheckCSourceCompiles) +include(CheckStructHasMember) +include(TestBigEndian) +include(GNUInstallDirs) + +if(ENABLE_COMMONCRYPTO) + check_include_files(CommonCrypto/CommonCrypto.h COMMONCRYPTO_FOUND) +endif() +if(ENABLE_GNUTLS) + find_package(Nettle 3.0) + find_package(GnuTLS) +endif() +if(ENABLE_MBEDTLS) + find_package(MbedTLS 1.0) +endif() +if(ENABLE_OPENSSL) + find_package(OpenSSL) +endif() +if(WIN32) + if(ENABLE_WINDOWS_CRYPTO) + set(WINDOWS_CRYPTO_FOUND TRUE) + endif() +endif() + +option(BUILD_SHARED_LIBS "Build shared libraries" ON) +option(LIBZIP_DO_INSTALL "Install libzip and the related files" ON) + +option(SHARED_LIB_VERSIONNING "Add SO version in .so build" ON) + +find_program(MDOCTOOL NAMES mandoc groff) +if (MDOCTOOL) + set(DOCUMENTATION_FORMAT "mdoc" CACHE STRING "Documentation format") +else() + find_program(MANTOOL NAMES nroff) + if (MANTOOL) + set(DOCUMENTATION_FORMAT "man" CACHE STRING "Documentation format") + else() + set(DOCUMENTATION_FORMAT "html" CACHE STRING "Documentation format") + endif() +endif() + +include(Dist) +Dist(${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}) + +#ADD_CUSTOM_TARGET(uninstall +# COMMAND cat ${PROJECT_BINARY_DIR}/install_manifest.txt | xargs rm +# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +# ) + +if(BUILD_SHARED_LIBS) + set(HAVE_SHARED TRUE) +else() + set(ZIP_STATIC TRUE) +endif() + +# Checks + +# Request ISO C secure library functions (memcpy_s &c) +list(APPEND CMAKE_REQUIRED_DEFINITIONS -D__STDC_WANT_LIB_EXT1__=1) + +check_function_exists(_close HAVE__CLOSE) +check_function_exists(_dup HAVE__DUP) +check_function_exists(_fdopen HAVE__FDOPEN) +check_function_exists(_fileno HAVE__FILENO) +check_function_exists(_fseeki64 HAVE__FSEEKI64) +check_function_exists(_fstat64 HAVE__FSTAT64) +check_function_exists(_setmode HAVE__SETMODE) +check_function_exists(_stat64 HAVE__STAT64) +check_symbol_exists(_snprintf stdio.h HAVE__SNPRINTF) +check_symbol_exists(_snprintf_s stdio.h HAVE__SNPRINTF_S) +check_symbol_exists(_snwprintf_s stdio.h HAVE__SNWPRINTF_S) +check_function_exists(_strdup HAVE__STRDUP) +check_symbol_exists(_stricmp string.h HAVE__STRICMP) +check_function_exists(_strtoi64 HAVE__STRTOI64) +check_function_exists(_strtoui64 HAVE__STRTOUI64) +check_function_exists(_unlink HAVE__UNLINK) +check_function_exists(arc4random HAVE_ARC4RANDOM) +check_function_exists(clonefile HAVE_CLONEFILE) +check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO) +check_function_exists(explicit_memset HAVE_EXPLICIT_MEMSET) +check_function_exists(fchmod HAVE_FCHMOD) +check_function_exists(fileno HAVE_FILENO) +check_function_exists(fseeko HAVE_FSEEKO) +check_function_exists(ftello HAVE_FTELLO) +check_function_exists(getprogname HAVE_GETPROGNAME) +check_function_exists(GetSecurityInfo HAVE_GETSECURITYINFO) +check_symbol_exists(localtime_r time.h HAVE_LOCALTIME_R) +check_symbol_exists(localtime_s time.h HAVE_LOCALTIME_S) +check_function_exists(memcpy_s HAVE_MEMCPY_S) +check_function_exists(random HAVE_RANDOM) +check_function_exists(setmode HAVE_SETMODE) +check_symbol_exists(snprintf stdio.h HAVE_SNPRINTF) +check_symbol_exists(snprintf_s stdio.h HAVE_SNPRINTF_S) +check_symbol_exists(strcasecmp strings.h HAVE_STRCASECMP) +check_function_exists(strdup HAVE_STRDUP) +check_function_exists(strerror_s HAVE_STRERROR_S) +check_function_exists(strerrorlen_s HAVE_STRERRORLEN_S) +check_function_exists(stricmp HAVE_STRICMP) +check_function_exists(strncpy_s HAVE_STRNCPY_S) +check_function_exists(strtoll HAVE_STRTOLL) +check_function_exists(strtoull HAVE_STRTOULL) + +check_include_files("sys/types.h;sys/stat.h;fts.h" HAVE_FTS_H) +# fts functions may be in external library +if(HAVE_FTS_H) + check_function_exists(fts_open HAVE_FTS_OPEN) + if(NOT HAVE_FTS_OPEN) + check_library_exists(fts fts_open "" HAVE_LIB_FTS) + else(NOT HAVE_FTS_OPEN) + set(HAVE_LIB_FTS "" CACHE INTERNAL "") + endif(NOT HAVE_FTS_OPEN) +else(HAVE_FTS_H) + set(HAVE_LIB_FTS "" CACHE INTERNAL "") +endif(HAVE_FTS_H) + +if(HAVE_LIB_FTS) + set(FTS_LIB fts CACHE INTERNAL "") +else() + set(FTS_LIB "" CACHE INTERNAL "") +endif() + +check_include_files(stdbool.h HAVE_STDBOOL_H) +check_include_files(strings.h HAVE_STRINGS_H) +check_include_files(unistd.h HAVE_UNISTD_H) + +check_include_files(inttypes.h HAVE_INTTYPES_H_LIBZIP) +check_include_files(stdint.h HAVE_STDINT_H_LIBZIP) +check_include_files(sys/types.h HAVE_SYS_TYPES_H_LIBZIP) + +# TODO: fix test +# this test does not find __progname even when it exists +#check_symbol_exists(__progname stdlib.h HAVE___PROGNAME) + +check_type_size(__int8 __INT8_LIBZIP) +check_type_size(int8_t INT8_T_LIBZIP) +check_type_size(uint8_t UINT8_T_LIBZIP) +check_type_size(__int16 __INT16_LIBZIP) +check_type_size(int16_t INT16_T_LIBZIP) +check_type_size(uint16_t UINT16_T_LIBZIP) +check_type_size(__int32 __INT32_LIBZIP) +check_type_size(int32_t INT32_T_LIBZIP) +check_type_size(uint32_t UINT32_T_LIBZIP) +check_type_size(__int64 __INT64_LIBZIP) +check_type_size(int64_t INT64_T_LIBZIP) +check_type_size(uint64_t UINT64_T_LIBZIP) +check_type_size("short" SHORT_LIBZIP) +check_type_size("int" INT_LIBZIP) +check_type_size("long" LONG_LIBZIP) +check_type_size("long long" LONG_LONG_LIBZIP) +check_type_size("off_t" SIZEOF_OFF_T) +check_type_size("size_t" SIZEOF_SIZE_T) + +check_c_source_compiles("#include +#include +int main(int argc, char *argv[]) { unsigned long x = FICLONERANGE; }" HAVE_FICLONERANGE) + +test_big_endian(WORDS_BIGENDIAN) + +find_package(ZLIB 1.1.2 REQUIRED) +# so developers on systems where zlib is named differently (Windows, sometimes) +# can override the name used in the pkg-config file +if (NOT ZLIB_LINK_LIBRARY_NAME) + set(ZLIB_LINK_LIBRARY_NAME "z") + + # Get the correct name in common cases + list(LENGTH ZLIB_LIBRARIES N_ZLIB_LIBRARIES) + if(N_ZLIB_LIBRARIES EQUAL 1) + set(ZLIB_FILENAME ${ZLIB_LIBRARIES}) + elseif(N_ZLIB_LIBRARIES EQUAL 4) + # ZLIB_LIBRARIES might have the target_link_library() format like + # "optimized;path/to/zlib.lib;debug;path/to/zlibd.lib". Use the 'optimized' + # case unless we know we are in a Debug build. + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + list(FIND ZLIB_LIBRARIES "debug" ZLIB_LIBRARIES_INDEX_OF_CONFIG) + else() + list(FIND ZLIB_LIBRARIES "optimized" ZLIB_LIBRARIES_INDEX_OF_CONFIG) + endif() + if(ZLIB_LIBRARIES_INDEX_OF_CONFIG GREATER_EQUAL 0) + math(EXPR ZLIB_FILENAME_INDEX "${ZLIB_LIBRARIES_INDEX_OF_CONFIG}+1") + list(GET ZLIB_LIBRARIES ${ZLIB_FILENAME_INDEX} ZLIB_FILENAME) + endif() + endif() + if(ZLIB_FILENAME) + get_filename_component(ZLIB_FILENAME ${ZLIB_FILENAME} NAME_WE) + string(REGEX REPLACE "^lib" "" ZLIB_LINK_LIBRARY_NAME ${ZLIB_FILENAME}) + endif() +endif(NOT ZLIB_LINK_LIBRARY_NAME) + +if(ENABLE_BZIP2) + find_package(BZip2) + if(BZIP2_FOUND) + set(HAVE_LIBBZ2 1) + else() + message(WARNING "-- bzip2 library not found; bzip2 support disabled") + endif(BZIP2_FOUND) +endif(ENABLE_BZIP2) + +if(ENABLE_LZMA) + find_package(LibLZMA 5.2) + if(LIBLZMA_FOUND) + set(HAVE_LIBLZMA 1) + else() + message(WARNING "-- lzma library not found; lzma/xz support disabled") + endif(LIBLZMA_FOUND) +endif(ENABLE_LZMA) + +if(ENABLE_ZSTD) + find_package(zstd 1.4.0) + if(zstd_FOUND) + set(HAVE_LIBZSTD 1) + if(TARGET zstd::libzstd_shared AND BUILD_SHARED_LIBS) + set(zstd_TARGET zstd::libzstd_shared) + else() + set(zstd_TARGET zstd::libzstd_static) + endif() + else() + message(WARNING "-- zstd library not found; zstandard support disabled") + endif(zstd_FOUND) +endif(ENABLE_ZSTD) + +if (COMMONCRYPTO_FOUND) + set(HAVE_CRYPTO 1) + set(HAVE_COMMONCRYPTO 1) +elseif (WINDOWS_CRYPTO_FOUND) + set(HAVE_CRYPTO 1) + set(HAVE_WINDOWS_CRYPTO 1) +elseif (OPENSSL_FOUND) + set(HAVE_CRYPTO 1) + set(HAVE_OPENSSL 1) +elseif (GNUTLS_FOUND AND NETTLE_FOUND) + set(HAVE_CRYPTO 1) + set(HAVE_GNUTLS 1) +elseif (MBEDTLS_FOUND) + set(HAVE_CRYPTO 1) + set(HAVE_MBEDTLS 1) +endif() + +if ((ENABLE_COMMONCRYPTO OR ENABLE_GNUTLS OR ENABLE_MBEDTLS OR ENABLE_OPENSSL OR ENABLE_WINDOWS_CRYPTO) AND NOT HAVE_CRYPTO) + message(WARNING "-- neither Common Crypto, GnuTLS, mbed TLS, OpenSSL, nor Windows Cryptography found; AES support disabled") +endif() + +if(MSVC) + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) + add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE) +endif(MSVC) + +if(WIN32) + if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore) + add_compile_definitions(MS_UWP) + endif(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore) +endif(WIN32) + +# rpath handling: use rpath in installed binaries +if(NOT CMAKE_SYSTEM_NAME MATCHES Linux) + set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) + set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +endif() + +# for code completion frameworks +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# Testing +ENABLE_TESTING() + +# Targets +ADD_SUBDIRECTORY(lib) + +if(BUILD_DOC) + ADD_SUBDIRECTORY(man) +endif() + +if(BUILD_TOOLS) + ADD_SUBDIRECTORY(src) +else(BUILD_TOOLS) + if(BUILD_REGRESS) + message(WARNING "-- tools build has been disabled, but they are needed for regression tests; regression testing disabled") + set(BUILD_REGRESS OFF) + endif(BUILD_REGRESS) +endif() + +find_program(NIHTEST nihtest) + +if(BUILD_REGRESS AND NOT NIHTEST) + message(WARNING "-- nihtest not found, regression testing disabled") + set(BUILD_REGRESS OFF) +endif() + +if(BUILD_REGRESS) + add_subdirectory(regress) +endif() + +if(BUILD_OSSFUZZ) + add_subdirectory(ossfuzz) +endif() + +if(BUILD_EXAMPLES) + add_subdirectory(examples) +endif() + + +# pkgconfig file +file(RELATIVE_PATH pc_relative_bindir ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_FULL_BINDIR}) +set(bindir "\${prefix}/${pc_relative_bindir}") +file(RELATIVE_PATH pc_relative_libdir ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_FULL_LIBDIR}) +set(libdir "\${prefix}/${pc_relative_libdir}") +file(RELATIVE_PATH pc_relative_includedir ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_FULL_INCLUDEDIR}) +set(includedir "\${prefix}/${pc_relative_includedir}") +if(CMAKE_SYSTEM_NAME MATCHES BSD) + set(PKG_CONFIG_RPATH "-Wl,-R\${libdir}") +endif(CMAKE_SYSTEM_NAME MATCHES BSD) +get_target_property(LIBS_PRIVATE zip LINK_LIBRARIES) +foreach(LIB ${LIBS_PRIVATE}) + if(LIB MATCHES "^/") + get_filename_component(LIB ${LIB} NAME_WE) + string(REGEX REPLACE "^lib" "" LIB ${LIB}) + endif() + set(LIBS "${LIBS} -l${LIB}") +endforeach() +STRING(CONCAT zlib_link_name "-l" ${ZLIB_LINK_LIBRARY_NAME}) +string(REGEX REPLACE "-lBZip2::BZip2" "-lbz2" LIBS ${LIBS}) +string(REGEX REPLACE "-lLibLZMA::LibLZMA" "-llzma" LIBS ${LIBS}) +if(zstd_TARGET) + string(REGEX REPLACE "-l${zstd_TARGET}" "-lzstd" LIBS ${LIBS}) +endif() +string(REGEX REPLACE "-lOpenSSL::Crypto" "-lssl -lcrypto" LIBS ${LIBS}) +string(REGEX REPLACE "-lZLIB::ZLIB" ${zlib_link_name} LIBS ${LIBS}) +string(REGEX REPLACE "-lGnuTLS::GnuTLS" "-lgnutls" LIBS ${LIBS}) +string(REGEX REPLACE "-lNettle::Nettle" "-lnettle" LIBS ${LIBS}) +configure_file(libzip.pc.in libzip.pc @ONLY) +if(LIBZIP_DO_INSTALL) + install(FILES ${PROJECT_BINARY_DIR}/libzip.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif() + +# fixed size integral types + +if(HAVE_INTTYPES_H_LIBZIP) + set(LIBZIP_TYPES_INCLUDE "#if !defined(__STDC_FORMAT_MACROS) +#define __STDC_FORMAT_MACROS 1 +#endif +#include ") +elseif(HAVE_STDINT_H_LIBZIP) + set(LIBZIP_TYPES_INCLUDE "#include ") +elseif(HAVE_SYS_TYPES_H_LIBZIP) + set(LIBZIP_TYPES_INCLUDE "#include ") +endif() + +if(HAVE_INT8_T_LIBZIP) + set(ZIP_INT8_T int8_t) +elseif(HAVE___INT8_LIBZIP) + set(ZIP_INT8_T __int8) +else() + set(ZIP_INT8_T "signed char") +endif() + +if(HAVE_UINT8_T_LIBZIP) + set(ZIP_UINT8_T uint8_t) +elseif(HAVE___INT8_LIBZIP) + set(ZIP_UINT8_T "unsigned __int8") +else() + set(ZIP_UINT8_T "unsigned char") +endif() + +if(HAVE_INT16_T_LIBZIP) + set(ZIP_INT16_T int16_t) +elseif(HAVE___INT16_LIBZIP) + set(INT16_T_LIBZIP __int16) +elseif(SHORT_LIBZIP EQUAL 2) + set(INT16_T_LIBZIP short) +endif() + +if(HAVE_UINT16_T_LIBZIP) + set(ZIP_UINT16_T uint16_t) +elseif(HAVE___INT16_LIBZIP) + set(UINT16_T_LIBZIP "unsigned __int16") +elseif(SHORT_LIBZIP EQUAL 2) + set(UINT16_T_LIBZIP "unsigned short") +endif() + +if(HAVE_INT32_T_LIBZIP) + set(ZIP_INT32_T int32_t) +elseif(HAVE___INT32_LIBZIP) + set(ZIP_INT32_T __int32) +elseif(INT_LIBZIP EQUAL 4) + set(ZIP_INT32_T int) +elseif(LONG_LIBZIP EQUAL 4) + set(ZIP_INT32_T long) +endif() + +if(HAVE_UINT32_T_LIBZIP) + set(ZIP_UINT32_T uint32_t) +elseif(HAVE___INT32_LIBZIP) + set(ZIP_UINT32_T "unsigned __int32") +elseif(INT_LIBZIP EQUAL 4) + set(ZIP_UINT32_T "unsigned int") +elseif(LONG_LIBZIP EQUAL 4) + set(ZIP_UINT32_T "unsigned long") +endif() + +if(HAVE_INT64_T_LIBZIP) + set(ZIP_INT64_T int64_t) +elseif(HAVE___INT64_LIBZIP) + set(ZIP_INT64_T __int64) +elseif(LONG_LIBZIP EQUAL 8) + set(ZIP_INT64_T long) +elseif(LONG_LONG_LIBZIP EQUAL 8) + set(ZIP_INT64_T "long long") +endif() + +if(HAVE_UINT64_T_LIBZIP) + set(ZIP_UINT64_T uint64_t) +elseif(HAVE___INT64_LIBZIP) + set(ZIP_UINT64_T "unsigned __int64") +elseif(LONG_LIBZIP EQUAL 8) + set(ZIP_UINT64_T "unsigned long") +elseif(LONG_LONG_LIBZIP EQUAL 8) + set(ZIP_UINT64_T "unsigned long long") +endif() + +# write out config file +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${PROJECT_BINARY_DIR}/config.h) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zipconf.h.in ${PROJECT_BINARY_DIR}/zipconf.h) + +# for tests + +set(srcdir ${CMAKE_CURRENT_SOURCE_DIR}/regress) +set(abs_srcdir ${CMAKE_CURRENT_SOURCE_DIR}/regress) +set(top_builddir ${PROJECT_BINARY_DIR}) # used to find config.h + +# create package config file +include(CMakePackageConfigHelpers) +write_basic_package_version_file("${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake" + COMPATIBILITY AnyNewerVersion) + +if(LIBZIP_DO_INSTALL) + configure_package_config_file("${PROJECT_NAME}-config.cmake.in" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake" + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libzip) + + # Install Find* modules, they are required by libzip-config.cmake to resolve dependencies + install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindNettle.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Findzstd.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindMbedTLS.cmake + DESTINATION + ${CMAKE_INSTALL_LIBDIR}/cmake/libzip/modules + ) + + # Add targets to the build-tree export set + export(TARGETS zip + FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}-targets.cmake") + + # installation + install(FILES ${PROJECT_BINARY_DIR}/zipconf.h DESTINATION include) + install(FILES ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config.cmake ${PROJECT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} + ) + install(EXPORT ${PROJECT_NAME}-targets NAMESPACE libzip:: FILE ${PROJECT_NAME}-targets.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} + ) +endif() diff --git a/thirdparty/libzip-1.11.3/INSTALL.md b/thirdparty/libzip-1.11.3/INSTALL.md new file mode 100644 index 0000000..83f1d97 --- /dev/null +++ b/thirdparty/libzip-1.11.3/INSTALL.md @@ -0,0 +1,71 @@ +libzip uses [cmake](https://cmake.org) to build. + +You'll need [zlib](http://www.zlib.net/) (at least version 1.1.2). It +comes with most operating systems. + +For supporting bzip2-compressed zip archives, you need +[bzip2](http://bzip.org/). + +For supporting lzma- and xz-compressed zip archives, you need +[liblzma](https://tukaani.org/xz/) which is part of xz, at least version 5.2. + +For supporting zstd-compressed zip archives, you need +[zstd](https://github.com/facebook/zstd/). + +For AES (encryption) support, you need one of these cryptographic libraries, +listed in order of preference: + +- Apple's CommonCrypto (available on macOS and iOS) +- Microsoft Windows Cryptography Framework +- [OpenSSL](https://www.openssl.org/) >= 1.0. +- [GnuTLS](https://www.gnutls.org/) and [Nettle](https://www.lysator.liu.se/~nisse/nettle/) (at least nettle 3.0) +- [mbed TLS](https://tls.mbed.org/) + +If you don't want a library even if it is installed, you can +pass `-DENABLE_=OFF` to cmake, where `` is one of +`COMMONCRYPTO`, `GNUTLS`, `MBEDTLS`, or `OPENSSL`. + +For running the tests, you need to have +[Python](https://www.python.org/) and +[nihtest](https://pypi.org/project/nihtest/) installed. + +The basic usage is +```sh +mkdir build +cd build +cmake .. +make +make test +make install +``` + +Some useful parameters you can pass to `cmake` with `-Dparameter=value`: + +- `BUILD_SHARED_LIBS`: set to `ON` or `OFF` to enable/disable building + of shared libraries, defaults to `ON` +- `CMAKE_INSTALL_PREFIX`: for setting the installation path +- `DOCUMENTATION_FORMAT`: choose one of `man`, `mdoc`, and `html` for + the installed documentation (default: decided by cmake depending on + available tools) +- `LIBZIP_DO_INSTALL`: If you include libzip as a subproject, link it + statically and do not want to let it install its files, set this + variable to `OFF`. Defaults to `ON`. + +If you want to compile with custom `CFLAGS`, set them in the environment +before running `cmake`: +```sh +CFLAGS=-DMY_CUSTOM_FLAG cmake .. +``` + +If you are compiling on a system with a small stack size, add +`-DZIP_ALLOCATE_BUFFER` to `CFLAGS`. + +If you are building on a 32-bit Linux system it might be necessary +to define `_FILE_OFFSET_BITS` to `64`. Your distro will need to provide +a `fts.h` file that is new enough to support this, or the build +will break in `zipcmp`. + +You can get verbose build output with by passing `VERBOSE=1` to +`make`. + +You can also check the [cmake FAQ](https://gitlab.kitware.com/cmake/community/-/wikis/FAQ). diff --git a/thirdparty/libzip-1.11.3/LICENSE b/thirdparty/libzip-1.11.3/LICENSE new file mode 100644 index 0000000..fa70609 --- /dev/null +++ b/thirdparty/libzip-1.11.3/LICENSE @@ -0,0 +1,31 @@ +Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner + +The authors can be contacted at + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/thirdparty/libzip-1.11.3/NEWS.md b/thirdparty/libzip-1.11.3/NEWS.md new file mode 100644 index 0000000..b3bf108 --- /dev/null +++ b/thirdparty/libzip-1.11.3/NEWS.md @@ -0,0 +1,354 @@ +# 1.11.3 [2025-01-20] + +* Report read error for corrupted encrypted file data. +* Avoid unnecessary seeks when writing archive. +* Don't hardcode `_Nullable` support in `zip.h` to allow it to be used with different compilers. +* Improve check for GetSecurityInformation availability on Windows. + +# 1.11.2 [2024-10-31] + +* Fix performance regression in `zip_stat` introduced in 1.11. + +# 1.11.1 [2024-09-19] + +* Fix zipconf.h for version number with missing third component. + +# 1.11 [2024-09-19] + +* Stop searching after finding acceptable central directory, even if it contains inconsistencies. +* Only write Zip64 EOCD if fields don't fit in normal EOCD. Previously libzip also wrote it when any directory entry required Zip64. +* Allow bytes from 0x00-0x1F as UTF-8. +* Add new error code `ZIP_ER_TRUNCATED_ZIP` for files that start with a valid local header signature. +* `zipcmp`: add `-T` option for comparing timestamps. +* `zip_file_replace` now removes the target's extra field information. + +# 1.10.1 [2023-08-23] + +* Add `ZIP_LENGTH_TO_END` and `ZIP_LENGTH_UNCHECKED`. Unless `ZIP_LENGTH_UNCHECKED` is used as `length`, it is an error for a file to shrink between the time when the source is created and when its data is read. +* Fix test on Windows. + +# 1.10.0 [2023-06-23] + +* Make support for layered sources public. +* Add `zip_source_zip_file` and `zip_source_zip_file_create`, deprecate `zip_source_zip` and `zip_source_zip_create`. +* Allow reading changed file data. +* Fix handling of files of size 4294967295. +* `zipmerge`: copy extra fields. +* `zipmerge`: add option to keep files uncompressed. +* Switch test framework to use nihtest instead of Perl. +* Fix reading/writing compressed data with buffers > 4GiB. +* Restore support for torrentzip. +* Add warnings when using deprecated functions. +* Allow keeping files for empty archives. +* Support mbedTLS>=3.3.0. +* Support OpenSSL 3. +* Use ISO C secure library functions, if available. + + +# 1.9.2 [2022-06-28] + +* Fix version number in header file. + + +# 1.9.1 [2022-06-28] + +* Fix `zip_file_is_seekable()`. + + +# 1.9.0 [2022-06-13] + +* Add `zip_file_is_seekable()`. +* Improve compatibility with WinAES. +* Fix encoding handling in `zip_name_locate()`. +* Add option to `zipcmp` to output summary of changes. +* Various bug fixes and documentation improvements. + + +# 1.8.0 [2021-06-18] + +* Add support for zstd (Zstandard) compression. +* Add support for lzma (ID 14) compression. +* Add `zip_source_window_create()`. +* Add `zip_source_zip_create()` variant to `zip_source_zip()`. +* Allow method specific `comp_flags` in `zip_set_file_compression()`. +* Allow `zip_source_tell()` on sources that don't support seeking and `zip_ftell()` on compressed data. +* Provide more details for consistency check errors. +* Improve output of `zipcmp`. +* In `zipcmp`, don’t ignore empty directories when comparing directory listing. +* Treat empty string as no password given in `zip_file_set_encryption()`, `zip_fopen_encrypted()`, and `zip_set_default_password()`. + + +# 1.7.3 [2020-07-15] + +* Support cmake < 3.17 again. +* Fix pkgconfig file (regression in 1.7.2). + + +# 1.7.2 [2020-07-11] + +* Fixes for the CMake `find_project()` files. +* libzip moved to the CMake `libzip::` `NAMESPACE`. +* CMake usage best practice cleanups. + + +# 1.7.1 [2020-06-13] + +* Restore `LIBZIP_VERSION_{MAJOR,MINOR,MICRO}` symbols. +* Fixes warnings reported by PVS-Studio. +* Add `LIBZIP_DO_INSTALL` build setting to make it easier to use + libzip as subproject. + + +# 1.7.0 [2020-06-05] + +* Add support for encrypting using traditional PKWare encryption. +* Add `zip_compression_method_supported()`. +* Add `zip_encryption_method_supported()`. +* Add the `ZIP_SOURCE_GET_FILE_ATTRIBUTES` source command. +* Refactor stdio file backend. +* Add CMake find_project() support. + + +# 1.6.1 [2020-02-03] + +* Bugfix for double-free in `zipcmp(1)` during cleanup. + + +# 1.6.0 [2020-01-24] + +* Avoid using `umask()` since it's not thread-safe. +* Set close-on-exec flag when opening files. +* Do not accept empty files as valid zip archives any longer. +* Add support for XZ compressed files (using liblzma). +* Add support for cancelling while closing zip archives. +* Add support for setting the time in the on-disk format. + + +# 1.5.2 [2019-03-12] + +* Fix bug in AES encryption affecting certain file sizes +* Keep file permissions when modifying zip archives +* Support systems with small stack size. +* Support mbed TLS as crypto backend. +* Add nullability annotations. + + +# 1.5.1 [2018-04-11] + +* Choose format of installed documentation based on available tools. +* Fix visibility of symbols. +* Fix zipcmp directory support. +* Don't set RPATH on Linux. +* Use Libs.private for link dependencies in pkg-config file. +* Fix build with LibreSSL. +* Various bugfixes. + + +# 1.5.0 [2018-03-11] + +* Use standard cryptographic library instead of custom AES implementation. + This also simplifies the license. +* Use `clang-format` to format the source code. +* More Windows improvements. + + +# 1.4.0 [2017-12-29] + +* Improve build with cmake +* Retire autoconf/automake build system +* Add `zip_source_buffer_fragment()`. +* Add support to clone unchanged beginning of archive (instead of rewriting it). + Supported for buffer sources and on Apple File System. +* Add support for Microsoft Universal Windows Platform. + + +# 1.3.2 [2017-11-20] + +* Fix bug introduced in last: zip_t was erroneously freed if zip_close() failed. + + +# 1.3.1 [2017-11-19] + +* Install zipconf.h into ${PREFIX}/include +* Add zip_libzip_version() +* Fix AES tests on Linux + + +# 1.3.0 [2017-09-02] + +* Support bzip2 compressed zip archives +* Improve file progress callback code +* Fix zip_fdopen() +* CVE-2017-12858: Fix double free() +* CVE-2017-14107: Improve EOCD64 parsing + + +# 1.2.0 [2017-02-19] + +* Support for AES encryption (Winzip version), both encryption + and decryption +* Support legacy zip files with >64k entries +* Fix seeking in zip_source_file if start > 0 +* Add zip_fseek() for seeking in uncompressed data +* Add zip_ftell() for telling position in uncompressed data +* Add zip_register_progress_callback() for UI updates during zip_close() + + +# 1.1.3 [2016-05-28] + +* Fix build on Windows when using autoconf + + +# 1.1.2 [2016-02-19] + +* Improve support for 3MF files + + +# 1.1.1 [2016-02-07] + +* Build fixes for Linux +* Fix some warnings reported by PVS-Studio + + +# 1.1 [2016-01-26] + +* ziptool(1): command line tool to modify zip archives +* Speedups for archives with many entries +* Coverity fixes +* Better APK support +* Support for running tests on Windows +* More build fixes for Windows +* Portability fixes +* Documentation improvements + + +# 1.0.1 [2015-05-04] + +* Build fixes for Windows + + +# 1.0 [2015-05-03] + +* Implemented an I/O abstraction layer +* Added support for native Windows API for files +* Added support for setting the last modification time for a file +* Added a new type zip_error_t for errors +* Added more typedefs for structs +* Torrentzip support was removed +* CVE-2015-2331 was fixed +* Addressed all Coverity CIDs + + +# 0.11.2 [2013-12-19] + +* Support querying/setting operating system and external attributes +* For newly added files, set operating system to UNIX, permissions + to 0666 (0777 for directories) +* Fix bug when writing zip archives containing files bigger than 4GB + + +# 0.11.1 [2013-04-27] + +* Fix bugs in zip_set_file_compression() +* Include Xcode build infrastructure + + +# 0.11 [2013-03-23] + +* Added Zip64 support (large file support) +* Added UTF-8 support for file names, file comments, and archive comments +* Changed API for name and comment related functions for UTF-8 support +* Added zip_discard() +* Added ZIP_TRUNCATE for zip_open() +* Added zip_set_file_compression() +* Added API for accessing and modifying extra fields +* Improved API type consistency +* Use gcc4's visibility __attribute__ +* More changes for Windows support +* Additional test cases + + +# 0.10.1 [2012-03-20] + +* Fixed CVE-2012-1162 +* Fixed CVE-2012-1163 + + +# 0.10 [2010-03-18] + +* Added zip_get_num_entries(), deprecated zip_get_num_files() +* Better windows support +* Support for traditional PKWARE encryption added +* Fix opening archives with more than 65535 entries +* Fix some memory leaks +* Fix cmake build and installation +* Fix memory leak in error case in zip_open() +* Fixed CVE-2011-0421 (no security implications though) +* More documentation + + +# 0.9.3 [2010-02-01] + +* Include m4/ directory in distribution; some packagers need it + + +# 0.9.2 [2010-01-31] + +* Avoid passing uninitialized data to deflate() +* Fix memory leak when closing zip archives + + +# 0.9.1 [2010-01-24] + +* Fix infinite loop on reading some broken files +* Optimization in time conversion (don't call localtime()) +* Clear data descriptor flag in central directory, fixing Open Office files +* Allow more than 64k entries + + +# 0.9 [2008-07-25] + +* on Windows, explicitly set dllimport/dllexport +* remove erroneous references to GPL +* add support for torrentzip +* new functions: zip_get_archive_flag, zip_set_archive_flag +* zip_source_zip: add flag to force recompression +* zip_sorce_file: only keep file open while reading from it + + +# 0.8 [2007-06-06] + +* fix for zip archives larger than 2GiB +* fix zip_error_strerror to include libzip error string +* add support for reading streamed zip files +* new functions: zip_add_dir, zip_error_clear, zip_file_error_clear +* add basic support for building with CMake (incomplete) + + +# 0.7.1 [2006-05-18] + +* bugfix for zip_close + + +# 0.7 [2006-05-06] + +* struct zip_stat increased for future encryption support +* zip_add return value changed (now returns new index of added file) +* shared library major bump because of previous two +* added functions for reading and writing file and archive comments + New functions: zip_get_archive_comment, zip_get_file_comment, + zip_set_archive_comment, zip_set_file_comment, zip_unchange_archive + + +# 0.6.1 [2005-07-14] + +* various bug fixes + + +# 0.6 [2005-06-09] + +* first standalone release +* changed license to three-clause BSD +* overhauled API +* added man pages +* install zipcmp and zipmerge diff --git a/thirdparty/libzip-1.11.3/README.md b/thirdparty/libzip-1.11.3/README.md new file mode 100644 index 0000000..c0051e4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/README.md @@ -0,0 +1,35 @@ +This is libzip, a C library for reading, creating, and modifying +zip and zip64 archives. Files can be added from data buffers, files, +or compressed data copied directly from other zip archives. Changes +made without closing the archive can be reverted. Decryption and +encryption of Winzip AES and legacy PKware encrypted files is +supported. + +libzip is fully documented via man pages. HTML versions of the man +pages are on [libzip.org](https://libzip.org/documentation/) and +in the [man](man) directory. You can start with +[libzip(3)](https://libzip.org/documentation/libzip.html), which +lists +all others. Example source code is in the [examples](examples) and +[src](src) subdirectories. + +See the [INSTALL.md](INSTALL.md) file for installation instructions and +dependencies. + +If you have developed an application using libzip, you can find out +about API changes and how to adapt your code for them in the included +file [API-CHANGES.md](API-CHANGES.md). + +If you make a binary distribution, please include a pointer to the +distribution site: +> https://libzip.org/ + +The latest version can always be found there. The official repository +is at [github](https://github.com/nih-at/libzip/). + +If you want to reach the authors in private, use . + +[![Github Actions Build Status](https://github.com/nih-at/libzip/workflows/build/badge.svg)](https://github.com/nih-at/libzip/actions?query=workflow%3Abuild) +[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/f1bqqt9djvf22f5g?svg=true)](https://ci.appveyor.com/project/nih-at/libzip) +[![Coverity Status](https://scan.coverity.com/projects/127/badge.svg)](https://scan.coverity.com/projects/libzip) +[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/libzip.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:libzip) diff --git a/thirdparty/libzip-1.11.3/SECURITY.md b/thirdparty/libzip-1.11.3/SECURITY.md new file mode 100644 index 0000000..67c84eb --- /dev/null +++ b/thirdparty/libzip-1.11.3/SECURITY.md @@ -0,0 +1,13 @@ +# Security Policy + +## Supported Versions + +We are not maintaining multiple branches, so all fixes will be committed to head and included in the next release. + +We take great care to maintain backwards compatibility, so we expect our users to use the latest version. + +## Reporting a Vulnerability + +You can reach us per email at info@libzip.org. + +For less sensitive reports, you can also open an issue or pull request on GitHub. diff --git a/thirdparty/libzip-1.11.3/THANKS b/thirdparty/libzip-1.11.3/THANKS new file mode 100644 index 0000000..d36809c --- /dev/null +++ b/thirdparty/libzip-1.11.3/THANKS @@ -0,0 +1,173 @@ +Thanks to Info-ZIP for info on the DOS-time/date conversion code, +and some other general information gathered from their sources. + +Thanks to these people for suggestions, testing, and bug reports: + +ag2s20150909 +Agostino Sarubbo +Alberto Spin +Alexander Galanin +Alexandr Shadchin +Alexey Bykov +Andreas Deininger +Andreas Falkenhahn +Andrew Brampton +Andrew Molyneux +Ankur Kothari +Antonin Décimo +Arseniy Terekhin +BALATON Zoltan +Benjamin Gilbert +Beuc +Boaz Stolk +Bogdan +Brian 'geeknik' Carpenter +BruceFan +Carl Mastrangelo +Cédric Tabin +celan69 +chaoticgd +Charlie Li +ChrisAm1224 +Chris Nehren +Christoph Cullmann +Christoph M. Becker +Corentin Schreiber +Coverity +cryi +ctenter-scs +Dane Springmeyer +Daniel Russel +Ларионов Даниил +David Demelier +Dean Ellis +Declan Moran +Del Merritt +Devin Davila +Dmytro Rybachenko +Dylan T. +Eelco Dolstra +Elvis Angelaccio +Erin Melucci +Erwin Haid +Eun-cheol Joo +Fabrice Fontaine +Filip Niksic +Florian Delizy +Force Charlie +François Simon +Frederik Ramm +Gabriela Gutierrez +Gerard ODonnell +Giovanni +gk7huki +Hanno Böck +HeeMyung +Heiko Becker +Heiko Hund +hongjunwang +Ilya Voronin +Info-ZIP group +Ivan Kolesnikov +Jan Weiß +Jay Freeman (saurik) +jloqfjgk@github +Joachim Reichel +João Custódio +Joel Ebrahimi +Jono Spiro +Julien Matthey +Julien Schueller +Justin Cohen +kensington +Kei Takahashi +Keith Jones +Khaled Mardam-Bey +Kohei Yoshida +Krzesimir Nowak +Leith Bade +Lubomir I. Ivanov +Lucas Bustamante +Ludovic LANGE +M. Reiningħaus +Maël Nison +Manuel Massing +Marcin Kowalczyk +Mark A. Tsuchida +Martin Buchholz +Martin Herkt +Martin Szulecki +Michael Balzer +Michael Beck +Michael Heimpold +Michał Janiszewski +Michal Vyskocil +Mikhail Gusarov . +Miklos Vajna +Morris Hafner +Muhammad Arslan Kabeer +Mykyta Mudryi +nieder +Oliver Kaiser +Oliver Kuckertz +OSS-Fuzz Team +Ørjan Malde +Pascal Terjan +Patrick Spendrin +Paul Harris +Paul Sheppard +Pavel Raiskup +Pierre Joye +Pierre Wendling +Pierre-Louis Cabelguen +PW Hu +Rafał Mikrut +ralfjunker +Randy +Remi Collet +rezso +Richard Schütz +Rick Carback +Rikard Falkeborn +Robert Norris +Roberto Tirabassi +robhz786 +Roland Ortloff +Rosen Penev +Rudi Heitbaum +Ryan Burns +Sam James +Sam Sappenfield +Sandro Mani +scribam +Sebastian Kemper +Sebastian Schmitt +Sergei Ozerov +shenlebantongying +Shimi +Simon Talbot +SpaceIm +Stephen Bryant +sxkan +Tabata Shintaro +takase1121 +Tarmo Pikaro +Taylor C. Richberger +TC +Thomas Debesse +Tim Lunn +Timo Warns +Timofey +Tom Callaway +Tomas Hoger +Tomáš Malý +Torsten Paul +Transporter +Vassili Courzakis +Vinpasso +Vitaly Murashev +William Lee +William Ouwehand +Wojciech Michalski +Wolfgang Glunz +Yufan You diff --git a/thirdparty/libzip-1.11.3/TODO.md b/thirdparty/libzip-1.11.3/TODO.md new file mode 100644 index 0000000..6989b44 --- /dev/null +++ b/thirdparty/libzip-1.11.3/TODO.md @@ -0,0 +1,189 @@ +## Fuzzing + +- improve AES and PKWARE encryption tests +- add more +- review memset() uses + +### Torrentzip + +- Handle data sources with unknown uncompressed size: if we forced ZIP64 and don't need it, return specific error (so calling code can decide what to do (e. g. clear torrentzip flag and call `zip_close()` again)). + +## Other + +- split `zip_source_t` in main part and reference so we can keep track which reference called open and we can invalidate references if the underlying source gets invalidated (e. g. by `zip_close`). + +## Prefixes + +For example for adding extractors for self-extracting zip archives. +````c +zip_set_archive_prefix(struct zip *za, const zip_uint8_t *data, zip_uint64_t length); +const zip_uint8_t *zip_get_archive_prefix(struct zip *za, zip_uint64_t *lengthp); +```` + +## Compression + +* add lzma2 support +* add deflate64 support (https://github.com/madler/zlib/blob/master/contrib/infback9/infback9.h) + +## API Issues + +* Add `zip_file_use_password` to set per-file password to use if libzip needs to decrypt the file (e.g. when changing encryption or compression method). + +* `zip_get_archive_comment` has `int *lenp` argument. Cleaner would be `zip_uint32_t *`. + rename and fix. which other functions for naming consistency? +* rename remaining `zip_XXX_{file,archive}_*` to `zip_{file,archive}_XXX_*`? +* compression/crypt implementations: how to set error code on failure +* compression/crypt error messages a la `ZIP_ER_ZLIB` (no detailed info passing) + +## Features + +* consistently use `_zip_crypto_clear()` for passwords +* support setting extra fields from `zip_source` + * introduce layers of extra fields: + * original + * from `zip_source` + * manually set + * when querying extra fields, search all of them in reverse order + * add whiteout (deleted) flag + * allow invalid data flag, used when computing extra field size before writing data + * new command `ZIP_SOURCE_EXTRA_FIELDS` + * no support for multiple copies of same extra field +* function to copy file from one archive to another +* set `O_CLOEXEC` flag after fopen and mkstemp +* support streaming output (creating new archive to e.g. stdout) +* add function to read/set ASCII file flag +* `zip_commit()` (to finish changes without closing archive) +* add custom compression function support +* `zip_source_zip()`: allow rewinding +* `zipcmp`: add option for file content comparison +* `zipcmp`: add more paranoid checks: + * external attributes/opsys + * version needed/made by + * general purpose bit flags +* add more consistency checks: + * for stored files, test compressed = uncompressed + * data descriptor + * local headers come before central dir +* support for old compression methods? + +## Bugs + +* ensure that nentries is small enough not to cause overflow (size_t for entry, uint64 for CD on disk) +* check for limits imposed by format (central dir size, file size, extra fields, ...) +* `_zip_u2d_time()`: handle `localtime(3)` failure +* POSIX: `zip_open()`: check whether file can be created and fail if not +* fix inconsistent usage of valid flags (not checked in many places) +* `cdr == NULL` -> `ER_NOENT` vs. `idx > cdir->nentry` -> `ER_INVAL` inconsistent (still there?) + +## Cleanup + +* go over cdir parser and rename various offset/size variables to make it clearer +* use bool +* use `ZIP_SOURCE_SUPPORTS_{READABLE,SEEKABLE,WRITABLE}` +* use `zip_source_seek_compute_offset()` +* get rid of `zip_get_encryption_implementation()` +* use `zip_*int*_t` internally +* `zip_source_file()`: don't allow write if start/len specify a part of the file + +## Documentation + +* document valid file paths +* document: `zip_source_write()`: length can't be > `ZIP_INT64_MAX` +* document: `ZIP_SOURCE_CLOSE` implementation can't return error +* keep error codes in man pages in sync +* document error codes in new man pages + +## Infrastructure + +* add coverage reports, e.g. using gcovr or https://github.com/eddyxu/cpp-coveralls (coveralls.io) +* review guidelines/community standards + - [Linux Foundation Core Infrastructure Initiative Best Practices](https://bestpractices.coreinfrastructure.org/) + - [Readme Maturity Level](https://github.com/LappleApple/feedmereadmes/blob/master/README-maturity-model.md) + - [Github Community Profile](https://github.com/nih-at/libzip/community) +* test different crypto backends with GitHub actions. +* improve man page formatting of tagged lists on webpage (`
`) +* rewrite `make_zip_errors.sh` in cmake +* script to check if all exported symbols are marked with `ZIP_EXTERN`, add to `make distcheck` + +## macOS / iOS framework + +* get cmake to optionally build frameworks + +## Test Case Issues + +* add test cases for all `ZIP_INCONS` detail errors +* `incons-local-filename-short.zzip` doesn't test short filename, since extra fields fail to parse. +* test error cases with special source + - tell it which command should fail + - use it both as source for `zip_add` and `zip_open_from_source` + - `ziptool_regress`: + - `-e error_spec`: source containing zip fails depending on `error_spec` + - `add_with_error name content error_spec`: add content to archive, where source fails depending on `error_spec` + - `add_file_with_error name file_to_add offset len error_spec`: add file to archive, len bytes starting from offset, where source fails depending on `error_spec` + - `error_spec`: + - source command that fails + - error code that source returns + - conditions that must be met for error to trigger + - Nth call of command + - read/write: total byte count so far + - state of source (opened, EOF reached, ...) +* test for zipcmp reading directory (requires fts) +* add test case for clone with files > 4k +* consider testing for `malloc`/`realloc` failures +* Winzip AES support + * test cases decryption: <=20, >20, stat for both + * test cases encryption: no password, default password, file-specific password, 128/192/256, <=20, >20 + * support testing on macOS +* add test cases for lots of files (including too many) +* add test cases for holes (between files, between files and cdir, between cdir and eocd, + zip64 where appropriate) +* test seek in `zip_source_crc_create()` +* test cases for `set_extra*`, `delete_extra*`, `*extra_field*` +* test cases for in memory archives + * add + * delete + * delete all + * modify +* use gcov output to increase test coverage +* add test case to change values for newly added files (name, compression method, comment, mtime, . . .) +* `zip_open()` file less than `EOCDLEN` bytes long +* test calls against old API +* rename file to dir/ and vice versa (fails) +* fix comment test to be newline insensitive +* check if http://bugs.python.org/issue20078 provides ideas for new tests + +* (`add`, `replace`) + * add to empty zip + * add to existing zip + * add w/ existing file name [E] + * replace ok + * replace w/ illegal index [E] + * replace w/ deleted name [E] + * unchange added/replaced file +* (`close`) + * copy zip file + * open copy + * rename, delete, replace, add w/ new name, add w/ deleted name + * close + * zipcmp copy expected + * remove copy +* (`error_get`) +* (`error_get_sys_type`) +* (`error_to_str`) +* (`extra_fields`) +* (`file_error_get`) +* (`file_strerror`) +* (`replace`) +* (`source_buffer`) +* (`source_file`) +* (`source_filep`) +* (`source_free`) +* (`source_function`) +* (`source_zip`) +* (`strerror`) +* (`unchange`) +* (`unchange_all`) +* `open(ZIP_RDONLY)` +* I/O abstraction layer + * `zip_open_from_source` +* read two zip entries interleaved +* test `zip_file_is_seekable` (via `ziptool`?) diff --git a/thirdparty/libzip-1.11.3/android/do.sh b/thirdparty/libzip-1.11.3/android/do.sh new file mode 100644 index 0000000..0c72242 --- /dev/null +++ b/thirdparty/libzip-1.11.3/android/do.sh @@ -0,0 +1,63 @@ + +# Author: Declan Moran +# www.silverglint.com +# Thanks to damaex (https://github.com/damaex), for significant contributions + +ANDROID_NDK_ROOT=/home/android/android-ndk-r19c + +INSTALL_DIR=install +BUILD_DIR=build +START_DIR=$(pwd) + +rm -rf $INSTALL_DIR +rm -rf $BUILD_DIR +mkdir -p $BUILD_DIR #"${ANDROID_TARGET_PLATFORM}" + +#-------------------------------------------------------------------- +build_it() +{ + # builds either a static or shared lib depending on parm passed (ON or OFF) + want_shared=$1 + + cmake -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake \ + -DCMAKE_INSTALL_PREFIX:PATH=$(pwd)/../../${INSTALL_DIR}/${ANDROID_TARGET_PLATFORM} \ + -DANDROID_ABI=${ANDROID_TARGET_PLATFORM} \ + -DENABLE_OPENSSL:BOOL=OFF \ + -DENABLE_COMMONCRYPTO:BOOL=OFF \ + -DENABLE_GNUTLS:BOOL=OFF \ + -DENABLE_MBEDTLS:BOOL=OFF \ + -DENABLE_OPENSSL:BOOL=OFF \ + -DENABLE_WINDOWS_CRYPTO:BOOL=OFF \ + -DBUILD_TOOLS:BOOL=OFF \ + -DBUILD_REGRESS:BOOL=OFF \ + -DBUILD_EXAMPLES:BOOL=OFF \ + -DBUILD_SHARED_LIBS:BOOL=$want_shared \ + -DBUILD_DOC:BOOL=OFF \ + -DANDROID_TOOLCHAIN=clang cmake -H.. -B$BUILD_DIR/${ANDROID_TARGET_PLATFORM} + + #run make with all system threads and install + cd $BUILD_DIR/${ANDROID_TARGET_PLATFORM} + make install -j$(nproc --all) + cd $START_DIR + } + +#-------------------------------------------------------------------- +for ANDROID_TARGET_PLATFORM in armeabi-v7a arm64-v8a x86 x86_64 +do + echo "Building libzip for ${ANDROID_TARGET_PLATFORM}" + + build_it ON + build_it OFF + + if [ $? -ne 0 ]; then + echo "Error executing: cmake" + exit 1 + fi + + + if [ $? -ne 0 ]; then + echo "Error executing make install for platform: ${ANDROID_TARGET_PLATFORM}" + exit 1 + fi + +done diff --git a/thirdparty/libzip-1.11.3/android/docker/Dockerfile b/thirdparty/libzip-1.11.3/android/docker/Dockerfile new file mode 100644 index 0000000..5532bde --- /dev/null +++ b/thirdparty/libzip-1.11.3/android/docker/Dockerfile @@ -0,0 +1,122 @@ +# Version: 1.0 + +# Dockerfile for building libzip for android +# https://github.com/dec1/libzip.git +# creates docker container with all tools, libraries and sources required to build libzip for android. + +# Author: Declan Moran +# www.silverglint.com + + +# Usage: +#--------- +# download the libzip repository +# > git clone https://github.com/dec1/libzip.git +# > cd libzip +# +# build docker image "my_img_zip" from the dockerfile in "docker" dir +# > docker build -t my_img_zip ./android/docker +# +# run docker container "my_ctr_zip" from this image, mounting the current dir. (Need to pass absolute host paths to mount volume- hence "pwd") +# > docker run -v $(pwd):/home/docker-share/libzip -it --entrypoint=/bin/bash --name my_ctr_zip my_img_zip +# +# Now inside docker container +# $ cd /home/docker-share/libzip/android +# +# Modify ./do.sh (on host), to match the boost and android ndk versions/paths in the "Configure here" section below +# Build from running docker container. +# $./do.sh +# +# "./build" dir contains required build, but owned by root. chown to your username/group +# > sudo chown -R : ./build +# > sudo chown -R : ./install +# +# Exit container, when build is finished. +# $ exit +# + + + + +FROM ubuntu:18.04 + + +## -------------------------------------------------------------------- +## Configure here +# --------------------------------------------------------------------- +# --------------------------------------------------------------------- +# Here you can speciofy exactly what android ndk (and sdk) version you want to use. + + + +# (2) Android SDK +# https://developer.android.com/studio#downloads +ARG SDK_URL_BASE=https://dl.google.com/android/repository +ARG SDK_FILE=sdk-tools-linux-4333796.zip + +# the sdk platform to use +# https://developer.android.com/guide/topics/manifest/uses-sdk-element +ARG ANDROID_SDK_PLATFORM_VERS="platforms;android-28" + + + +# (3) Android NDK +# https://developer.android.com/ndk/downloads +ARG NDK_URL_BASE=https://dl.google.com/android/repository +ARG NDK_FILE=android-ndk-r19c-linux-x86_64.zip +# --------------------------------------------------------------------- +## -------------------------------------------------------------------- + +RUN apt-get update +RUN apt-get -y dist-upgrade + + +# for downloading archives +RUN apt-get -y install wget + +# for unzipping downloaded android archives +RUN apt-get -y install zip +RUN apt-get -y install cmake + +RUN apt-get -y install lib32z1 + + +# need this this to install some (32 bit) prerequisites for android builds +RUN dpkg --add-architecture i386 +RUN apt-get update +RUN apt-get -y dist-upgrade +RUN apt-get install -y libc6:i386 libncurses5:i386 libstdc++6:i386 libbz2-1.0:i386 + + +# need c compiler to set up create boost build system (before building boost with it and android toolchain) +RUN apt-get -y install build-essential +RUN apt-get -y install libc6-dev-i386 +RUN apt-get -y install clang + +RUN apt-get -y install openjdk-8-jdk +#-------------------------------------- + +ARG ANDROID_HOME=/home/android +WORKDIR ${ANDROID_HOME} + + +# SDK +# ---- +# download android sdk command line tools +RUN wget ${SDK_URL_BASE}/$SDK_FILE +RUN unzip $SDK_FILE + +ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/platform-tools + + +RUN yes | sdkmanager --licenses + +RUN sdkmanager "platform-tools" $ANDROID_SDK_PLATFORM_VERS +#RUN sdkmanager "platform-tools" "platforms;android-28" + + +# NDK +# ---- +RUN wget ${NDK_URL_BASE}/$NDK_FILE +RUN unzip $NDK_FILE + diff --git a/thirdparty/libzip-1.11.3/android/readme.txt b/thirdparty/libzip-1.11.3/android/readme.txt new file mode 100644 index 0000000..dadc4b4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/android/readme.txt @@ -0,0 +1,13 @@ + +Cross compile libzip for android. +-------------------------------- +Modify "do.sh" as appropriate if you need to specify a different ndk dir or wish to specify different build parameters + +Prerequisites for the development machine - see docker/Dockerfile + +You can either set you host machine up with these prerequisites or simply use docker (in which case you need not install anything on your host machine except docker itself). + +See "Usage" in docker/Dockerfile for detailed instructions. + + +Please note: The libzip development team does not use Android, so this script is provided as is, as we cannot properly maintain it. We will, however, gladly accept fixes and try to work with users to resolve any issues they may have. diff --git a/thirdparty/libzip-1.11.3/appveyor.yml b/thirdparty/libzip-1.11.3/appveyor.yml new file mode 100644 index 0000000..06e2443 --- /dev/null +++ b/thirdparty/libzip-1.11.3/appveyor.yml @@ -0,0 +1,92 @@ +os: +- Visual Studio 2019 + +environment: + PATH: C:\Python311-x64\Scripts;C:\Python311-arm\Scripts;$(PATH) + VCPKG_BINARY_SOURCES: clear;files,C:\vcpkg.cache,readwrite + matrix: + - GENERATOR: "Visual Studio 16 2019" + PLATFORM: x64 + TRIPLET: x64-windows + CMAKE_OPTS: "-DBUILD_SHARED_LIBS=off" + CMAKE_CONFIG: Release + RUN_TESTS: yes + TOXENV: py311 + - GENERATOR: "Visual Studio 16 2019" + PLATFORM: x64 + TRIPLET: x64-uwp + CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0" + CMAKE_CONFIG: Release + RUN_TESTS: no + TOXENV: py311 + - GENERATOR: "Visual Studio 16 2019" + PLATFORM: Win32 + TRIPLET: x86-windows + CMAKE_OPTS: "-DBUILD_SHARED_LIBS=off" + CMAKE_CONFIG: Release + RUN_TESTS: yes + TOXENV: py311 + - GENERATOR: "Visual Studio 16 2019" + PLATFORM: Win32 + TRIPLET: x86-uwp + CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0" + CMAKE_CONFIG: Release + RUN_TESTS: no + TOXENV: py311 + - GENERATOR: "Visual Studio 16 2019" + PLATFORM: ARM + TRIPLET: arm-windows + CMAKE_OPTS: "-DENABLE_OPENSSL=off" + CMAKE_CONFIG: Release + RUN_TESTS: no + TOXENV: py311 + - GENERATOR: "Visual Studio 16 2019" + PLATFORM: ARM + TRIPLET: arm-uwp + CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DENABLE_OPENSSL=off" + CMAKE_CONFIG: Release + RUN_TESTS: no + TOXENV: py311 + - GENERATOR: "Visual Studio 16 2019" + PLATFORM: ARM64 + TRIPLET: arm64-windows + CMAKE_OPTS: "-DENABLE_OPENSSL=off" + CMAKE_CONFIG: Release + RUN_TESTS: no + TOXENV: py311 + - GENERATOR: "Visual Studio 16 2019" + PLATFORM: ARM64 + TRIPLET: arm64-uwp + CMAKE_OPTS: "-DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DENABLE_OPENSSL=off" + CMAKE_CONFIG: Release + RUN_TESTS: no + TOXENV: py311 + +before_build: + cmd: >- + py -m pip install nihtest + + mkdir build + + cd build + + cmake -DCMAKE_TOOLCHAIN_FILE=C:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake .. -G "%GENERATOR%" -A "%PLATFORM%" %CMAKE_OPTS% + + appveyor PushArtifact config.h + + appveyor PushArtifact CMakeCache.txt + +build_script: + cmd: >- + cmake --build . --config %CMAKE_CONFIG% --target INSTALL + + cmake --build . --config %CMAKE_CONFIG% + +test_script: + cmd: >- + set VERBOSE=yes + + IF %RUN_TESTS%==yes ( ctest -C %CMAKE_CONFIG% --output-on-failure ) + +cache: + - c:\vcpkg.cache -> vcpkg.json diff --git a/thirdparty/libzip-1.11.3/cmake-compat/CMakePushCheckState.cmake b/thirdparty/libzip-1.11.3/cmake-compat/CMakePushCheckState.cmake new file mode 100644 index 0000000..3e519ee --- /dev/null +++ b/thirdparty/libzip-1.11.3/cmake-compat/CMakePushCheckState.cmake @@ -0,0 +1,91 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +CMakePushCheckState +------------------- + + + +This module defines three macros: ``CMAKE_PUSH_CHECK_STATE()`` +``CMAKE_POP_CHECK_STATE()`` and ``CMAKE_RESET_CHECK_STATE()`` These macros can +be used to save, restore and reset (i.e., clear contents) the state of +the variables ``CMAKE_REQUIRED_FLAGS``, ``CMAKE_REQUIRED_DEFINITIONS``, +``CMAKE_REQUIRED_LINK_OPTIONS``, ``CMAKE_REQUIRED_LIBRARIES``, +``CMAKE_REQUIRED_INCLUDES`` and ``CMAKE_EXTRA_INCLUDE_FILES`` used by the +various Check-files coming with CMake, like e.g. ``check_function_exists()`` +etc. +The variable contents are pushed on a stack, pushing multiple times is +supported. This is useful e.g. when executing such tests in a Find-module, +where they have to be set, but after the Find-module has been executed they +should have the same value as they had before. + +``CMAKE_PUSH_CHECK_STATE()`` macro receives optional argument ``RESET``. +Whether it's specified, ``CMAKE_PUSH_CHECK_STATE()`` will set all +``CMAKE_REQUIRED_*`` variables to empty values, same as +``CMAKE_RESET_CHECK_STATE()`` call will do. + +Usage: + +.. code-block:: cmake + + cmake_push_check_state(RESET) + set(CMAKE_REQUIRED_DEFINITIONS -DSOME_MORE_DEF) + check_function_exists(...) + cmake_reset_check_state() + set(CMAKE_REQUIRED_DEFINITIONS -DANOTHER_DEF) + check_function_exists(...) + cmake_pop_check_state() +#]=======================================================================] + +macro(CMAKE_RESET_CHECK_STATE) + + set(CMAKE_EXTRA_INCLUDE_FILES) + set(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_REQUIRED_DEFINITIONS) + set(CMAKE_REQUIRED_LINK_OPTIONS) + set(CMAKE_REQUIRED_LIBRARIES) + set(CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_QUIET) + +endmacro() + +macro(CMAKE_PUSH_CHECK_STATE) + + if(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER) + set(_CMAKE_PUSH_CHECK_STATE_COUNTER 0) + endif() + + math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1") + + set(_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_EXTRA_INCLUDE_FILES}) + set(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES}) + set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS}) + set(_CMAKE_REQUIRED_LINK_OPTIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LINK_OPTIONS}) + set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES}) + set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS}) + set(_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_QUIET}) + + if (${ARGC} GREATER 0 AND "${ARGV0}" STREQUAL "RESET") + cmake_reset_check_state() + endif() + +endmacro() + +macro(CMAKE_POP_CHECK_STATE) + +# don't pop more than we pushed + if("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0") + + set(CMAKE_EXTRA_INCLUDE_FILES ${_CMAKE_EXTRA_INCLUDE_FILES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_LINK_OPTIONS ${_CMAKE_REQUIRED_LINK_OPTIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + set(CMAKE_REQUIRED_QUIET ${_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}}) + + math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1") + endif() + +endmacro() diff --git a/thirdparty/libzip-1.11.3/cmake-compat/CheckLibraryExists.cmake b/thirdparty/libzip-1.11.3/cmake-compat/CheckLibraryExists.cmake new file mode 100644 index 0000000..76901ab --- /dev/null +++ b/thirdparty/libzip-1.11.3/cmake-compat/CheckLibraryExists.cmake @@ -0,0 +1,102 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +CheckLibraryExists +------------------ + +Check if the function exists. + +.. command:: CHECK_LIBRARY_EXISTS + + .. code-block:: cmake + + CHECK_LIBRARY_EXISTS(LIBRARY FUNCTION LOCATION VARIABLE) + + :: + + LIBRARY - the name of the library you are looking for + FUNCTION - the name of the function + LOCATION - location where the library should be found + VARIABLE - variable to store the result + Will be created as an internal cache variable. + + + +The following variables may be set before calling this macro to modify +the way the check is run: + +:: + + CMAKE_REQUIRED_FLAGS = string of compile command line flags + CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) + CMAKE_REQUIRED_LINK_OPTIONS = list of options to pass to link command + CMAKE_REQUIRED_LIBRARIES = list of libraries to link + CMAKE_REQUIRED_QUIET = execute quietly without messages +#]=======================================================================] + +if(__CheckLibraryExists_cmake__) + return() +endif() +set(__CheckLibraryExists_cmake__ TRUE) + +macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) + if(NOT DEFINED "${VARIABLE}") + set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION + "-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}") + if(NOT CMAKE_REQUIRED_QUIET) + message(CHECK_START "Looking for ${FUNCTION} in ${LIBRARY}") + endif() + set(CHECK_LIBRARY_EXISTS_LINK_OPTIONS) + if(CMAKE_REQUIRED_LINK_OPTIONS) + set(CHECK_LIBRARY_EXISTS_LINK_OPTIONS + LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) + endif() + set(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY}) + if(CMAKE_REQUIRED_LIBRARIES) + set(CHECK_LIBRARY_EXISTS_LIBRARIES + ${CHECK_LIBRARY_EXISTS_LIBRARIES} ${CMAKE_REQUIRED_LIBRARIES}) + endif() + + if(CMAKE_C_COMPILER_LOADED) + set(_cle_source ${CMAKE_ROOT}/Modules/CheckFunctionExists.c) + elseif(CMAKE_CXX_COMPILER_LOADED) + set(_cle_source ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckLibraryExists/CheckFunctionExists.cxx) + configure_file(${CMAKE_ROOT}/Modules/CheckFunctionExists.c "${_cle_source}" COPYONLY) + else() + message(FATAL_ERROR "CHECK_FUNCTION_EXISTS needs either C or CXX language enabled") + endif() + + try_compile(${VARIABLE} + ${CMAKE_BINARY_DIR} + ${_cle_source} + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + ${CHECK_LIBRARY_EXISTS_LINK_OPTIONS} + LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES} + CMAKE_FLAGS + -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_LIBRARY_EXISTS_DEFINITION} + -DLINK_DIRECTORIES:STRING=${LOCATION} + OUTPUT_VARIABLE OUTPUT) + unset(_cle_source) + + if(${VARIABLE}) + if(NOT CMAKE_REQUIRED_QUIET) + message(CHECK_PASS "found") + endif() + set(${VARIABLE} 1 CACHE INTERNAL "Have library ${LIBRARY}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the function ${FUNCTION} exists in the ${LIBRARY} " + "passed with the following output:\n" + "${OUTPUT}\n\n") + else() + if(NOT CMAKE_REQUIRED_QUIET) + message(CHECK_FAIL "not found") + endif() + set(${VARIABLE} "" CACHE INTERNAL "Have library ${LIBRARY}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the function ${FUNCTION} exists in the ${LIBRARY} " + "failed with the following output:\n" + "${OUTPUT}\n\n") + endif() + endif() +endmacro() diff --git a/thirdparty/libzip-1.11.3/cmake-compat/CheckSymbolExists.cmake b/thirdparty/libzip-1.11.3/cmake-compat/CheckSymbolExists.cmake new file mode 100644 index 0000000..79d3d7d --- /dev/null +++ b/thirdparty/libzip-1.11.3/cmake-compat/CheckSymbolExists.cmake @@ -0,0 +1,169 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +CheckSymbolExists +----------------- + +Provides a macro to check if a symbol exists as a function, variable, +or macro in ``C``. + +.. command:: check_symbol_exists + + .. code-block:: cmake + + check_symbol_exists( ) + + Check that the ```` is available after including given header + ```` and store the result in a ````. Specify the list + of files in one argument as a semicolon-separated list. + ```` will be created as an internal cache variable. + +If the header files define the symbol as a macro it is considered +available and assumed to work. If the header files declare the symbol +as a function or variable then the symbol must also be available for +linking (so intrinsics may not be detected). +If the symbol is a type, enum value, or intrinsic it will not be recognized +(consider using :module:`CheckTypeSize` or :module:`CheckCSourceCompiles`). +If the check needs to be done in C++, consider using +:module:`CheckCXXSymbolExists` instead. + +The following variables may be set before calling this macro to modify +the way the check is run: + +``CMAKE_REQUIRED_FLAGS`` + string of compile command line flags. +``CMAKE_REQUIRED_DEFINITIONS`` + a :ref:`;-list ` of macros to define (-DFOO=bar). +``CMAKE_REQUIRED_INCLUDES`` + a :ref:`;-list ` of header search paths to pass to + the compiler. +``CMAKE_REQUIRED_LINK_OPTIONS`` + a :ref:`;-list ` of options to add to the link command. +``CMAKE_REQUIRED_LIBRARIES`` + a :ref:`;-list ` of libraries to add to the link + command. See policy :policy:`CMP0075`. +``CMAKE_REQUIRED_QUIET`` + execute quietly without messages. + +For example: + +.. code-block:: cmake + + include(CheckSymbolExists) + + # Check for macro SEEK_SET + check_symbol_exists(SEEK_SET "stdio.h" HAVE_SEEK_SET) + # Check for function fopen + check_symbol_exists(fopen "stdio.h" HAVE_FOPEN) +#]=======================================================================] + +if(__CheckSymbolExists_cmake__) + return() +endif() +set(__CheckSymbolExists_cmake__ TRUE) + +cmake_policy(PUSH) +cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced + +macro(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE) + if(CMAKE_C_COMPILER_LOADED) + __CHECK_SYMBOL_EXISTS_IMPL("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c" "${SYMBOL}" "${FILES}" "${VARIABLE}" ) + elseif(CMAKE_CXX_COMPILER_LOADED) + __CHECK_SYMBOL_EXISTS_IMPL("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.cxx" "${SYMBOL}" "${FILES}" "${VARIABLE}" ) + else() + message(FATAL_ERROR "CHECK_SYMBOL_EXISTS needs either C or CXX language enabled") + endif() +endmacro() + +macro(__CHECK_SYMBOL_EXISTS_IMPL SOURCEFILE SYMBOL FILES VARIABLE) + if(NOT DEFINED "${VARIABLE}" OR "x${${VARIABLE}}" STREQUAL "x${VARIABLE}") + set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n") + set(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS}) + if(CMAKE_REQUIRED_LINK_OPTIONS) + set(CHECK_SYMBOL_EXISTS_LINK_OPTIONS + LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS}) + else() + set(CHECK_SYMBOL_EXISTS_LINK_OPTIONS) + endif() + if(CMAKE_REQUIRED_LIBRARIES) + set(CHECK_SYMBOL_EXISTS_LIBS + LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + else() + set(CHECK_SYMBOL_EXISTS_LIBS) + endif() + if(CMAKE_REQUIRED_INCLUDES) + set(CMAKE_SYMBOL_EXISTS_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + else() + set(CMAKE_SYMBOL_EXISTS_INCLUDES) + endif() + foreach(FILE ${FILES}) + string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT + "#include <${FILE}>\n") + endforeach() + string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT " +int main(int argc, char** argv) +{ + (void)argv;") + set(_CSE_CHECK_NON_MACRO "return ((int*)(&${SYMBOL}))[argc];") + if("${SYMBOL}" MATCHES "^[a-zA-Z_][a-zA-Z0-9_]*$") + # The SYMBOL has a legal macro name. Test whether it exists as a macro. + string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT " +#ifndef ${SYMBOL} + ${_CSE_CHECK_NON_MACRO} +#else + (void)argc; + return 0; +#endif") + else() + # The SYMBOL cannot be a macro (e.g., a template function). + string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT " + ${_CSE_CHECK_NON_MACRO}") + endif() + string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT " +}") + unset(_CSE_CHECK_NON_MACRO) + + configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" + "${SOURCEFILE}" @ONLY) + + if(NOT CMAKE_REQUIRED_QUIET) + message(CHECK_START "Looking for ${SYMBOL}") + endif() + try_compile(${VARIABLE} + ${CMAKE_BINARY_DIR} + "${SOURCEFILE}" + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + ${CHECK_SYMBOL_EXISTS_LINK_OPTIONS} + ${CHECK_SYMBOL_EXISTS_LIBS} + CMAKE_FLAGS + -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_SYMBOL_EXISTS_FLAGS} + "${CMAKE_SYMBOL_EXISTS_INCLUDES}" + OUTPUT_VARIABLE OUTPUT) + if(${VARIABLE}) + if(NOT CMAKE_REQUIRED_QUIET) + message(CHECK_PASS "found") + endif() + set(${VARIABLE} 1 CACHE INTERNAL "Have symbol ${SYMBOL}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the ${SYMBOL} " + "exist passed with the following output:\n" + "${OUTPUT}\nFile ${SOURCEFILE}:\n" + "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") + else() + if(NOT CMAKE_REQUIRED_QUIET) + message(CHECK_FAIL "not found") + endif() + set(${VARIABLE} "" CACHE INTERNAL "Have symbol ${SYMBOL}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the ${SYMBOL} " + "exist failed with the following output:\n" + "${OUTPUT}\nFile ${SOURCEFILE}:\n" + "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") + endif() + unset(CMAKE_CONFIGURABLE_FILE_CONTENT) + endif() +endmacro() + +cmake_policy(POP) diff --git a/thirdparty/libzip-1.11.3/cmake-compat/FindBZip2.cmake b/thirdparty/libzip-1.11.3/cmake-compat/FindBZip2.cmake new file mode 100644 index 0000000..98ab72c --- /dev/null +++ b/thirdparty/libzip-1.11.3/cmake-compat/FindBZip2.cmake @@ -0,0 +1,104 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindBZip2 +--------- + +Try to find BZip2 + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``BZip2::BZip2``, if +BZip2 has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +``BZIP2_FOUND`` + system has BZip2 +``BZIP2_INCLUDE_DIRS`` + the BZip2 include directories +``BZIP2_LIBRARIES`` + Link these to use BZip2 +``BZIP2_NEED_PREFIX`` + this is set if the functions are prefixed with ``BZ2_`` +``BZIP2_VERSION_STRING`` + the version of BZip2 found + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``BZIP2_INCLUDE_DIR`` + the BZip2 include directory +#]=======================================================================] + +set(_BZIP2_PATHS PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Bzip2;InstallPath]" + ) + +find_path(BZIP2_INCLUDE_DIR bzlib.h ${_BZIP2_PATHS} PATH_SUFFIXES include) + +if (NOT BZIP2_LIBRARIES) + find_library(BZIP2_LIBRARY_RELEASE NAMES bz2 bzip2 libbz2 libbzip2 ${_BZIP2_PATHS} PATH_SUFFIXES lib) + find_library(BZIP2_LIBRARY_DEBUG NAMES bz2d bzip2d libbz2d libbzip2d ${_BZIP2_PATHS} PATH_SUFFIXES lib) + + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + SELECT_LIBRARY_CONFIGURATIONS(BZIP2) +else () + file(TO_CMAKE_PATH "${BZIP2_LIBRARIES}" BZIP2_LIBRARIES) +endif () + +if (BZIP2_INCLUDE_DIR AND EXISTS "${BZIP2_INCLUDE_DIR}/bzlib.h") + file(STRINGS "${BZIP2_INCLUDE_DIR}/bzlib.h" BZLIB_H REGEX "bzip2/libbzip2 version [0-9]+\\.[^ ]+ of [0-9]+ ") + string(REGEX REPLACE ".* bzip2/libbzip2 version ([0-9]+\\.[^ ]+) of [0-9]+ .*" "\\1" BZIP2_VERSION_STRING "${BZLIB_H}") +endif () + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2 + REQUIRED_VARS BZIP2_LIBRARIES BZIP2_INCLUDE_DIR + VERSION_VAR BZIP2_VERSION_STRING) + +if (BZIP2_FOUND) + set(BZIP2_INCLUDE_DIRS ${BZIP2_INCLUDE_DIR}) + include(${CMAKE_CURRENT_LIST_DIR}/CheckSymbolExists.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake) + cmake_push_check_state() + set(CMAKE_REQUIRED_QUIET ${BZip2_FIND_QUIETLY}) + set(CMAKE_REQUIRED_INCLUDES ${BZIP2_INCLUDE_DIR}) + set(CMAKE_REQUIRED_LIBRARIES ${BZIP2_LIBRARIES}) + CHECK_SYMBOL_EXISTS(BZ2_bzCompressInit "bzlib.h" BZIP2_NEED_PREFIX) + cmake_pop_check_state() + + if(NOT TARGET BZip2::BZip2) + add_library(BZip2::BZip2 UNKNOWN IMPORTED) + set_target_properties(BZip2::BZip2 PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${BZIP2_INCLUDE_DIRS}") + + if(BZIP2_LIBRARY_RELEASE) + set_property(TARGET BZip2::BZip2 APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(BZip2::BZip2 PROPERTIES + IMPORTED_LOCATION_RELEASE "${BZIP2_LIBRARY_RELEASE}") + endif() + + if(BZIP2_LIBRARY_DEBUG) + set_property(TARGET BZip2::BZip2 APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(BZip2::BZip2 PROPERTIES + IMPORTED_LOCATION_DEBUG "${BZIP2_LIBRARY_DEBUG}") + endif() + + if(NOT BZIP2_LIBRARY_RELEASE AND NOT BZIP2_LIBRARY_DEBUG) + set_property(TARGET BZip2::BZip2 APPEND PROPERTY + IMPORTED_LOCATION "${BZIP2_LIBRARY}") + endif() + endif() +endif () + +mark_as_advanced(BZIP2_INCLUDE_DIR) diff --git a/thirdparty/libzip-1.11.3/cmake-compat/FindGnuTLS.cmake b/thirdparty/libzip-1.11.3/cmake-compat/FindGnuTLS.cmake new file mode 100644 index 0000000..819f000 --- /dev/null +++ b/thirdparty/libzip-1.11.3/cmake-compat/FindGnuTLS.cmake @@ -0,0 +1,82 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindGnuTLS +---------- + +Find the GNU Transport Layer Security library (gnutls) + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``GnuTLS::GnuTLS``, if +gnutls has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +``GNUTLS_FOUND`` + System has gnutls +``GNUTLS_INCLUDE_DIR`` + The gnutls include directory +``GNUTLS_LIBRARIES`` + The libraries needed to use gnutls +``GNUTLS_DEFINITIONS`` + Compiler switches required for using gnutls +``GNUTLS_VERSION`` + version of gnutls. +#]=======================================================================] + +# Note that this doesn't try to find the gnutls-extra package. + + +if (GNUTLS_INCLUDE_DIR AND GNUTLS_LIBRARY) + # in cache already + set(gnutls_FIND_QUIETLY TRUE) +endif () + +if (NOT WIN32) + # try using pkg-config to get the directories and then use these values + # in the find_path() and find_library() calls + # also fills in GNUTLS_DEFINITIONS, although that isn't normally useful + find_package(PkgConfig QUIET) + PKG_CHECK_MODULES(PC_GNUTLS QUIET gnutls) + set(GNUTLS_DEFINITIONS ${PC_GNUTLS_CFLAGS_OTHER}) + set(GNUTLS_VERSION ${PC_GNUTLS_VERSION}) + # keep for backward compatibility + set(GNUTLS_VERSION_STRING ${PC_GNUTLS_VERSION}) +endif () + +find_path(GNUTLS_INCLUDE_DIR gnutls/gnutls.h + HINTS + ${PC_GNUTLS_INCLUDEDIR} + ${PC_GNUTLS_INCLUDE_DIRS} + ) + +find_library(GNUTLS_LIBRARY NAMES gnutls libgnutls + HINTS + ${PC_GNUTLS_LIBDIR} + ${PC_GNUTLS_LIBRARY_DIRS} + ) + +mark_as_advanced(GNUTLS_INCLUDE_DIR GNUTLS_LIBRARY) + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS + REQUIRED_VARS GNUTLS_LIBRARY GNUTLS_INCLUDE_DIR + VERSION_VAR GNUTLS_VERSION_STRING) + +if(GNUTLS_FOUND) + set(GNUTLS_LIBRARIES ${GNUTLS_LIBRARY}) + set(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR}) + + if(NOT TARGET GnuTLS::GnuTLS) + add_library(GnuTLS::GnuTLS UNKNOWN IMPORTED) + set_target_properties(GnuTLS::GnuTLS PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${GNUTLS_INCLUDE_DIRS}" + INTERFACE_COMPILE_DEFINITIONS "${GNUTLS_DEFINITIONS}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${GNUTLS_LIBRARIES}") + endif() +endif() diff --git a/thirdparty/libzip-1.11.3/cmake-compat/FindLibLZMA.cmake b/thirdparty/libzip-1.11.3/cmake-compat/FindLibLZMA.cmake new file mode 100644 index 0000000..200d6bf --- /dev/null +++ b/thirdparty/libzip-1.11.3/cmake-compat/FindLibLZMA.cmake @@ -0,0 +1,124 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindLibLZMA +----------- + +Find LZMA compression algorithm headers and library. + + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module defines :prop_tgt:`IMPORTED` target ``LibLZMA::LibLZMA``, if +liblzma has been found. + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``LIBLZMA_FOUND`` + True if liblzma headers and library were found. +``LIBLZMA_INCLUDE_DIRS`` + Directory where liblzma headers are located. +``LIBLZMA_LIBRARIES`` + Lzma libraries to link against. +``LIBLZMA_HAS_AUTO_DECODER`` + True if lzma_auto_decoder() is found (required). +``LIBLZMA_HAS_EASY_ENCODER`` + True if lzma_easy_encoder() is found (required). +``LIBLZMA_HAS_LZMA_PRESET`` + True if lzma_lzma_preset() is found (required). +``LIBLZMA_VERSION_MAJOR`` + The major version of lzma +``LIBLZMA_VERSION_MINOR`` + The minor version of lzma +``LIBLZMA_VERSION_PATCH`` + The patch version of lzma +``LIBLZMA_VERSION_STRING`` + version number as a string (ex: "5.0.3") +#]=======================================================================] + +find_path(LIBLZMA_INCLUDE_DIR lzma.h ) +if(NOT LIBLZMA_LIBRARY) + find_library(LIBLZMA_LIBRARY_RELEASE NAMES lzma liblzma PATH_SUFFIXES lib) + find_library(LIBLZMA_LIBRARY_DEBUG NAMES lzmad liblzmad PATH_SUFFIXES lib) + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(LIBLZMA) +else() + file(TO_CMAKE_PATH "${LIBLZMA_LIBRARY}" LIBLZMA_LIBRARY) +endif() + +if(LIBLZMA_INCLUDE_DIR AND EXISTS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h") + file(STRINGS "${LIBLZMA_INCLUDE_DIR}/lzma/version.h" LIBLZMA_HEADER_CONTENTS REGEX "#define LZMA_VERSION_[A-Z]+ [0-9]+") + + string(REGEX REPLACE ".*#define LZMA_VERSION_MAJOR ([0-9]+).*" "\\1" LIBLZMA_VERSION_MAJOR "${LIBLZMA_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define LZMA_VERSION_MINOR ([0-9]+).*" "\\1" LIBLZMA_VERSION_MINOR "${LIBLZMA_HEADER_CONTENTS}") + string(REGEX REPLACE ".*#define LZMA_VERSION_PATCH ([0-9]+).*" "\\1" LIBLZMA_VERSION_PATCH "${LIBLZMA_HEADER_CONTENTS}") + + set(LIBLZMA_VERSION_STRING "${LIBLZMA_VERSION_MAJOR}.${LIBLZMA_VERSION_MINOR}.${LIBLZMA_VERSION_PATCH}") + unset(LIBLZMA_HEADER_CONTENTS) +endif() + +# We're using new code known now as XZ, even library still been called LZMA +# it can be found in http://tukaani.org/xz/ +# Avoid using old codebase +if (LIBLZMA_LIBRARY) + include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake) + set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) + set(CMAKE_REQUIRED_QUIET ${LibLZMA_FIND_QUIETLY}) + if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG) + set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY}) + elseif(LIBLZMA_LIBRARY_RELEASE) + set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY_RELEASE}) + elseif(LIBLZMA_LIBRARY_DEBUG) + set(LIBLZMA_LIBRARY_check ${LIBLZMA_LIBRARY_DEBUG}) + endif() + CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_auto_decoder "" LIBLZMA_HAS_AUTO_DECODER) + CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_easy_encoder "" LIBLZMA_HAS_EASY_ENCODER) + CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY_check} lzma_lzma_preset "" LIBLZMA_HAS_LZMA_PRESET) + unset(LIBLZMA_LIBRARY_check) + set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) +endif () + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) +find_package_handle_standard_args(LibLZMA REQUIRED_VARS LIBLZMA_LIBRARY + LIBLZMA_INCLUDE_DIR + LIBLZMA_HAS_AUTO_DECODER + LIBLZMA_HAS_EASY_ENCODER + LIBLZMA_HAS_LZMA_PRESET + VERSION_VAR LIBLZMA_VERSION_STRING + ) +mark_as_advanced( LIBLZMA_INCLUDE_DIR LIBLZMA_LIBRARY ) + +if (LIBLZMA_FOUND) + set(LIBLZMA_LIBRARIES ${LIBLZMA_LIBRARY}) + set(LIBLZMA_INCLUDE_DIRS ${LIBLZMA_INCLUDE_DIR}) + if(NOT TARGET LibLZMA::LibLZMA) + add_library(LibLZMA::LibLZMA UNKNOWN IMPORTED) + set_target_properties(LibLZMA::LibLZMA PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${LIBLZMA_INCLUDE_DIR} + IMPORTED_LINK_INTERFACE_LANGUAGES C) + + if(LIBLZMA_LIBRARY_RELEASE) + set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(LibLZMA::LibLZMA PROPERTIES + IMPORTED_LOCATION_RELEASE "${LIBLZMA_LIBRARY_RELEASE}") + endif() + + if(LIBLZMA_LIBRARY_DEBUG) + set_property(TARGET LibLZMA::LibLZMA APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(LibLZMA::LibLZMA PROPERTIES + IMPORTED_LOCATION_DEBUG "${LIBLZMA_LIBRARY_DEBUG}") + endif() + + if(NOT LIBLZMA_LIBRARY_RELEASE AND NOT LIBLZMA_LIBRARY_DEBUG) + set_target_properties(LibLZMA::LibLZMA PROPERTIES + IMPORTED_LOCATION "${LIBLZMA_LIBRARY}") + endif() + endif() +endif () diff --git a/thirdparty/libzip-1.11.3/cmake-compat/FindPackageHandleStandardArgs.cmake b/thirdparty/libzip-1.11.3/cmake-compat/FindPackageHandleStandardArgs.cmake new file mode 100644 index 0000000..a078049 --- /dev/null +++ b/thirdparty/libzip-1.11.3/cmake-compat/FindPackageHandleStandardArgs.cmake @@ -0,0 +1,453 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindPackageHandleStandardArgs +----------------------------- + +This module provides a function intended to be used in :ref:`Find Modules` +implementing :command:`find_package()` calls. It handles the +``REQUIRED``, ``QUIET`` and version-related arguments of ``find_package``. +It also sets the ``_FOUND`` variable. The package is +considered found if all variables listed contain valid results, e.g. +valid filepaths. + +.. command:: find_package_handle_standard_args + + There are two signatures:: + + find_package_handle_standard_args( + (DEFAULT_MSG|) + ... + ) + + find_package_handle_standard_args( + [FOUND_VAR ] + [REQUIRED_VARS ...] + [VERSION_VAR ] + [HANDLE_COMPONENTS] + [CONFIG_MODE] + [NAME_MISMATCHED] + [REASON_FAILURE_MESSAGE ] + [FAIL_MESSAGE ] + ) + + The ``_FOUND`` variable will be set to ``TRUE`` if all + the variables ``...`` are valid and any optional + constraints are satisfied, and ``FALSE`` otherwise. A success or + failure message may be displayed based on the results and on + whether the ``REQUIRED`` and/or ``QUIET`` option was given to + the :command:`find_package` call. + + The options are: + + ``(DEFAULT_MSG|)`` + In the simple signature this specifies the failure message. + Use ``DEFAULT_MSG`` to ask for a default message to be computed + (recommended). Not valid in the full signature. + + ``FOUND_VAR `` + Obsolete. Specifies either ``_FOUND`` or + ``_FOUND`` as the result variable. This exists only + for compatibility with older versions of CMake and is now ignored. + Result variables of both names are always set for compatibility. + + ``REQUIRED_VARS ...`` + Specify the variables which are required for this package. + These may be named in the generated failure message asking the + user to set the missing variable values. Therefore these should + typically be cache entries such as ``FOO_LIBRARY`` and not output + variables like ``FOO_LIBRARIES``. + + ``VERSION_VAR `` + Specify the name of a variable that holds the version of the package + that has been found. This version will be checked against the + (potentially) specified required version given to the + :command:`find_package` call, including its ``EXACT`` option. + The default messages include information about the required + version and the version which has been actually found, both + if the version is ok or not. + + ``HANDLE_COMPONENTS`` + Enable handling of package components. In this case, the command + will report which components have been found and which are missing, + and the ``_FOUND`` variable will be set to ``FALSE`` + if any of the required components (i.e. not the ones listed after + the ``OPTIONAL_COMPONENTS`` option of :command:`find_package`) are + missing. + + ``CONFIG_MODE`` + Specify that the calling find module is a wrapper around a + call to ``find_package( NO_MODULE)``. This implies + a ``VERSION_VAR`` value of ``_VERSION``. The command + will automatically check whether the package configuration file + was found. + + ``REASON_FAILURE_MESSAGE `` + Specify a custom message of the reason for the failure which will be + appended to the default generated message. + + ``FAIL_MESSAGE `` + Specify a custom failure message instead of using the default + generated message. Not recommended. + + ``NAME_MISMATCHED`` + Indicate that the ```` does not match + ``${CMAKE_FIND_PACKAGE_NAME}``. This is usually a mistake and raises a + warning, but it may be intentional for usage of the command for components + of a larger package. + +Example for the simple signature: + +.. code-block:: cmake + + find_package_handle_standard_args(LibXml2 DEFAULT_MSG + LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) + +The ``LibXml2`` package is considered to be found if both +``LIBXML2_LIBRARY`` and ``LIBXML2_INCLUDE_DIR`` are valid. +Then also ``LibXml2_FOUND`` is set to ``TRUE``. If it is not found +and ``REQUIRED`` was used, it fails with a +:command:`message(FATAL_ERROR)`, independent whether ``QUIET`` was +used or not. If it is found, success will be reported, including +the content of the first ````. On repeated CMake runs, +the same message will not be printed again. + +.. note:: + + If ```` does not match ``CMAKE_FIND_PACKAGE_NAME`` for the + calling module, a warning that there is a mismatch is given. The + ``FPHSA_NAME_MISMATCHED`` variable may be set to bypass the warning if using + the old signature and the ``NAME_MISMATCHED`` argument using the new + signature. To avoid forcing the caller to require newer versions of CMake for + usage, the variable's value will be used if defined when the + ``NAME_MISMATCHED`` argument is not passed for the new signature (but using + both is an error).. + +Example for the full signature: + +.. code-block:: cmake + + find_package_handle_standard_args(LibArchive + REQUIRED_VARS LibArchive_LIBRARY LibArchive_INCLUDE_DIR + VERSION_VAR LibArchive_VERSION) + +In this case, the ``LibArchive`` package is considered to be found if +both ``LibArchive_LIBRARY`` and ``LibArchive_INCLUDE_DIR`` are valid. +Also the version of ``LibArchive`` will be checked by using the version +contained in ``LibArchive_VERSION``. Since no ``FAIL_MESSAGE`` is given, +the default messages will be printed. + +Another example for the full signature: + +.. code-block:: cmake + + find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) + find_package_handle_standard_args(Automoc4 CONFIG_MODE) + +In this case, a ``FindAutmoc4.cmake`` module wraps a call to +``find_package(Automoc4 NO_MODULE)`` and adds an additional search +directory for ``automoc4``. Then the call to +``find_package_handle_standard_args`` produces a proper success/failure +message. +#]=======================================================================] + +include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) + +# internal helper macro +macro(_FPHSA_FAILURE_MESSAGE _msg) + set (__msg "${_msg}") + if (FPHSA_REASON_FAILURE_MESSAGE) + string(APPEND __msg "\n Reason given by package: ${FPHSA_REASON_FAILURE_MESSAGE}\n") + endif() + if (${_NAME}_FIND_REQUIRED) + message(FATAL_ERROR "${__msg}") + else () + if (NOT ${_NAME}_FIND_QUIETLY) + message(STATUS "${__msg}") + endif () + endif () +endmacro() + + +# internal helper macro to generate the failure message when used in CONFIG_MODE: +macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) + # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: + if(${_NAME}_CONFIG) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing:${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") + else() + # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. + # List them all in the error message: + if(${_NAME}_CONSIDERED_CONFIGS) + set(configsText "") + list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) + math(EXPR configsCount "${configsCount} - 1") + foreach(currentConfigIndex RANGE ${configsCount}) + list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) + list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) + string(APPEND configsText "\n ${filename} (version ${version})") + endforeach() + if (${_NAME}_NOT_FOUND_MESSAGE) + if (FPHSA_REASON_FAILURE_MESSAGE) + string(PREPEND FPHSA_REASON_FAILURE_MESSAGE "${${_NAME}_NOT_FOUND_MESSAGE}\n ") + else() + set(FPHSA_REASON_FAILURE_MESSAGE "${${_NAME}_NOT_FOUND_MESSAGE}") + endif() + else() + string(APPEND configsText "\n") + endif() + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:${configsText}") + + else() + # Simple case: No Config-file was found at all: + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") + endif() + endif() +endmacro() + + +function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) + + # Set up the arguments for `cmake_parse_arguments`. + set(options CONFIG_MODE HANDLE_COMPONENTS NAME_MISMATCHED) + set(oneValueArgs FAIL_MESSAGE REASON_FAILURE_MESSAGE VERSION_VAR FOUND_VAR) + set(multiValueArgs REQUIRED_VARS) + + # Check whether we are in 'simple' or 'extended' mode: + set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) + list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) + + unset(FPHSA_NAME_MISMATCHED_override) + if (DEFINED FPHSA_NAME_MISMATCHED) + # If the variable NAME_MISMATCHED variable is set, error if it is passed as + # an argument. The former is for old signatures, the latter is for new + # signatures. + list(FIND ARGN "NAME_MISMATCHED" name_mismatched_idx) + if (NOT name_mismatched_idx EQUAL "-1") + message(FATAL_ERROR + "The `NAME_MISMATCHED` argument may only be specified by the argument or " + "the variable, not both.") + endif () + + # But use the variable if it is not an argument to avoid forcing minimum + # CMake version bumps for calling modules. + set(FPHSA_NAME_MISMATCHED_override "${FPHSA_NAME_MISMATCHED}") + endif () + + if(${INDEX} EQUAL -1) + set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) + set(FPHSA_REQUIRED_VARS ${ARGN}) + set(FPHSA_VERSION_VAR) + else() + cmake_parse_arguments(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) + + if(FPHSA_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") + endif() + + if(NOT FPHSA_FAIL_MESSAGE) + set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") + endif() + + # In config-mode, we rely on the variable _CONFIG, which is set by find_package() + # when it successfully found the config-file, including version checking: + if(FPHSA_CONFIG_MODE) + list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) + list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) + set(FPHSA_VERSION_VAR ${_NAME}_VERSION) + endif() + + if(NOT FPHSA_REQUIRED_VARS) + message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") + endif() + endif() + + if (DEFINED FPHSA_NAME_MISMATCHED_override) + set(FPHSA_NAME_MISMATCHED "${FPHSA_NAME_MISMATCHED_override}") + endif () + + if (DEFINED CMAKE_FIND_PACKAGE_NAME + AND NOT FPHSA_NAME_MISMATCHED + AND NOT _NAME STREQUAL CMAKE_FIND_PACKAGE_NAME) + message(AUTHOR_WARNING + "The package name passed to `find_package_handle_standard_args` " + "(${_NAME}) does not match the name of the calling package " + "(${CMAKE_FIND_PACKAGE_NAME}). This can lead to problems in calling " + "code that expects `find_package` result variables (e.g., `_FOUND`) " + "to follow a certain pattern.") + endif () + +# now that we collected all arguments, process them + + if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG") + set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") + endif() + + list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) + + string(TOUPPER ${_NAME} _NAME_UPPER) + string(TOLOWER ${_NAME} _NAME_LOWER) + + if(FPHSA_FOUND_VAR) + set(_FOUND_VAR_UPPER ${_NAME_UPPER}_FOUND) + set(_FOUND_VAR_MIXED ${_NAME}_FOUND) + if(FPHSA_FOUND_VAR STREQUAL _FOUND_VAR_MIXED OR FPHSA_FOUND_VAR STREQUAL _FOUND_VAR_UPPER) + set(_FOUND_VAR ${FPHSA_FOUND_VAR}) + else() + message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_FOUND_VAR_MIXED}\" and \"${_FOUND_VAR_UPPER}\" are valid names.") + endif() + else() + set(_FOUND_VAR ${_NAME_UPPER}_FOUND) + endif() + + # collect all variables which were not found, so they can be printed, so the + # user knows better what went wrong (#6375) + set(MISSING_VARS "") + set(DETAILS "") + # check if all passed variables are valid + set(FPHSA_FOUND_${_NAME} TRUE) + foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) + if(NOT ${_CURRENT_VAR}) + set(FPHSA_FOUND_${_NAME} FALSE) + string(APPEND MISSING_VARS " ${_CURRENT_VAR}") + else() + string(APPEND DETAILS "[${${_CURRENT_VAR}}]") + endif() + endforeach() + if(FPHSA_FOUND_${_NAME}) + set(${_NAME}_FOUND TRUE) + set(${_NAME_UPPER}_FOUND TRUE) + else() + set(${_NAME}_FOUND FALSE) + set(${_NAME_UPPER}_FOUND FALSE) + endif() + + # component handling + unset(FOUND_COMPONENTS_MSG) + unset(MISSING_COMPONENTS_MSG) + + if(FPHSA_HANDLE_COMPONENTS) + foreach(comp ${${_NAME}_FIND_COMPONENTS}) + if(${_NAME}_${comp}_FOUND) + + if(NOT DEFINED FOUND_COMPONENTS_MSG) + set(FOUND_COMPONENTS_MSG "found components:") + endif() + string(APPEND FOUND_COMPONENTS_MSG " ${comp}") + + else() + + if(NOT DEFINED MISSING_COMPONENTS_MSG) + set(MISSING_COMPONENTS_MSG "missing components:") + endif() + string(APPEND MISSING_COMPONENTS_MSG " ${comp}") + + if(${_NAME}_FIND_REQUIRED_${comp}) + set(${_NAME}_FOUND FALSE) + string(APPEND MISSING_VARS " ${comp}") + endif() + + endif() + endforeach() + set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}") + string(APPEND DETAILS "[c${COMPONENT_MSG}]") + endif() + + # version handling: + set(VERSION_MSG "") + set(VERSION_OK TRUE) + + # check with DEFINED here as the requested or found version may be "0" + if (DEFINED ${_NAME}_FIND_VERSION) + if(DEFINED ${FPHSA_VERSION_VAR}) + set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}}) + + if(${_NAME}_FIND_VERSION_EXACT) # exact version required + # count the dots in the version string + string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${_FOUND_VERSION}") + # add one dot because there is one dot more than there are components + string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS) + if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT) + # Because of the C++ implementation of find_package() ${_NAME}_FIND_VERSION_COUNT + # is at most 4 here. Therefore a simple lookup table is used. + if (${_NAME}_FIND_VERSION_COUNT EQUAL 1) + set(_VERSION_REGEX "[^.]*") + elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 2) + set(_VERSION_REGEX "[^.]*\\.[^.]*") + elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 3) + set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*") + else () + set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*") + endif () + string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${_FOUND_VERSION}") + unset(_VERSION_REGEX) + if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD) + set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") + set(VERSION_OK FALSE) + else () + set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")") + endif () + unset(_VERSION_HEAD) + else () + if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _FOUND_VERSION) + set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") + set(VERSION_OK FALSE) + else () + set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")") + endif () + endif () + unset(_VERSION_DOTS) + + else() # minimum version specified: + if (${_NAME}_FIND_VERSION VERSION_GREATER _FOUND_VERSION) + set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") + set(VERSION_OK FALSE) + else () + set(VERSION_MSG "(found suitable version \"${_FOUND_VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")") + endif () + endif() + + else() + + # if the package was not found, but a version was given, add that to the output: + if(${_NAME}_FIND_VERSION_EXACT) + set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") + else() + set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") + endif() + + endif() + else () + # Check with DEFINED as the found version may be 0. + if(DEFINED ${FPHSA_VERSION_VAR}) + set(VERSION_MSG "(found version \"${${FPHSA_VERSION_VAR}}\")") + endif() + endif () + + if(VERSION_OK) + string(APPEND DETAILS "[v${${FPHSA_VERSION_VAR}}(${${_NAME}_FIND_VERSION})]") + else() + set(${_NAME}_FOUND FALSE) + endif() + + + # print the result: + if (${_NAME}_FOUND) + FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}") + else () + + if(FPHSA_CONFIG_MODE) + _FPHSA_HANDLE_FAILURE_CONFIG_MODE() + else() + if(NOT VERSION_OK) + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") + else() + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing:${MISSING_VARS}) ${VERSION_MSG}") + endif() + endif() + + endif () + + set(${_NAME}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) + set(${_NAME_UPPER}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) +endfunction() diff --git a/thirdparty/libzip-1.11.3/cmake-compat/FindPackageMessage.cmake b/thirdparty/libzip-1.11.3/cmake-compat/FindPackageMessage.cmake new file mode 100644 index 0000000..0628b98 --- /dev/null +++ b/thirdparty/libzip-1.11.3/cmake-compat/FindPackageMessage.cmake @@ -0,0 +1,48 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindPackageMessage +------------------ + +.. code-block:: cmake + + find_package_message( "message for user" "find result details") + +This function is intended to be used in FindXXX.cmake modules files. +It will print a message once for each unique find result. This is +useful for telling the user where a package was found. The first +argument specifies the name (XXX) of the package. The second argument +specifies the message to display. The third argument lists details +about the find result so that if they change the message will be +displayed again. The macro also obeys the QUIET argument to the +find_package command. + +Example: + +.. code-block:: cmake + + if(X11_FOUND) + find_package_message(X11 "Found X11: ${X11_X11_LIB}" + "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") + else() + ... + endif() +#]=======================================================================] + +function(find_package_message pkg msg details) + # Avoid printing a message repeatedly for the same find result. + if(NOT ${pkg}_FIND_QUIETLY) + string(REPLACE "\n" "" details "${details}") + set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) + if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") + # The message has not yet been printed. + message(STATUS "${msg}") + + # Save the find details in the cache to avoid printing the same + # message again. + set("${DETAILS_VAR}" "${details}" + CACHE INTERNAL "Details about finding ${pkg}") + endif() + endif() +endfunction() diff --git a/thirdparty/libzip-1.11.3/cmake-compat/SelectLibraryConfigurations.cmake b/thirdparty/libzip-1.11.3/cmake-compat/SelectLibraryConfigurations.cmake new file mode 100644 index 0000000..4c0e9a8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/cmake-compat/SelectLibraryConfigurations.cmake @@ -0,0 +1,80 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +SelectLibraryConfigurations +--------------------------- + +.. code-block:: cmake + + select_library_configurations(basename) + +This macro takes a library base name as an argument, and will choose +good values for the variables + +:: + + basename_LIBRARY + basename_LIBRARIES + basename_LIBRARY_DEBUG + basename_LIBRARY_RELEASE + +depending on what has been found and set. + +If only ``basename_LIBRARY_RELEASE`` is defined, ``basename_LIBRARY`` will +be set to the release value, and ``basename_LIBRARY_DEBUG`` will be set +to ``basename_LIBRARY_DEBUG-NOTFOUND``. If only ``basename_LIBRARY_DEBUG`` +is defined, then ``basename_LIBRARY`` will take the debug value, and +``basename_LIBRARY_RELEASE`` will be set to ``basename_LIBRARY_RELEASE-NOTFOUND``. + +If the generator supports configuration types, then ``basename_LIBRARY`` +and ``basename_LIBRARIES`` will be set with debug and optimized flags +specifying the library to be used for the given configuration. If no +build type has been set or the generator in use does not support +configuration types, then ``basename_LIBRARY`` and ``basename_LIBRARIES`` +will take only the release value, or the debug value if the release one +is not set. +#]=======================================================================] + +# This macro was adapted from the FindQt4 CMake module and is maintained by Will +# Dicharry . + +macro(select_library_configurations basename) + if(NOT ${basename}_LIBRARY_RELEASE) + set(${basename}_LIBRARY_RELEASE "${basename}_LIBRARY_RELEASE-NOTFOUND" CACHE FILEPATH "Path to a library.") + endif() + if(NOT ${basename}_LIBRARY_DEBUG) + set(${basename}_LIBRARY_DEBUG "${basename}_LIBRARY_DEBUG-NOTFOUND" CACHE FILEPATH "Path to a library.") + endif() + + get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE AND + NOT ${basename}_LIBRARY_DEBUG STREQUAL ${basename}_LIBRARY_RELEASE AND + ( _isMultiConfig OR CMAKE_BUILD_TYPE ) ) + # if the generator is multi-config or if CMAKE_BUILD_TYPE is set for + # single-config generators, set optimized and debug libraries + set( ${basename}_LIBRARY "" ) + foreach( _libname IN LISTS ${basename}_LIBRARY_RELEASE ) + list( APPEND ${basename}_LIBRARY optimized "${_libname}" ) + endforeach() + foreach( _libname IN LISTS ${basename}_LIBRARY_DEBUG ) + list( APPEND ${basename}_LIBRARY debug "${_libname}" ) + endforeach() + elseif( ${basename}_LIBRARY_RELEASE ) + set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} ) + elseif( ${basename}_LIBRARY_DEBUG ) + set( ${basename}_LIBRARY ${${basename}_LIBRARY_DEBUG} ) + else() + set( ${basename}_LIBRARY "${basename}_LIBRARY-NOTFOUND") + endif() + + set( ${basename}_LIBRARIES "${${basename}_LIBRARY}" ) + + if( ${basename}_LIBRARY ) + set( ${basename}_FOUND TRUE ) + endif() + + mark_as_advanced( ${basename}_LIBRARY_RELEASE + ${basename}_LIBRARY_DEBUG + ) +endmacro() diff --git a/thirdparty/libzip-1.11.3/cmake/Dist.cmake b/thirdparty/libzip-1.11.3/cmake/Dist.cmake new file mode 100644 index 0000000..d2adf9f --- /dev/null +++ b/thirdparty/libzip-1.11.3/cmake/Dist.cmake @@ -0,0 +1,83 @@ +# Copyright (C) 2020 Dieter Baron and Thomas Klausner +# +# The authors can be contacted at +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# 3. The names of the authors may not be used to endorse or promote +# products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#[=======================================================================[.rst: +Dist +------- + +Provide ``dist`` and ``distcheck`` targets similar to +autoconf/automake functionality. + +The ``dist`` target creates tarballs of the project in ``.tar.gz`` and +``.tar.xz`` formats. + +The ``distcheck`` target extracts one of created tarballs, builds the +software using its defaults, and runs the tests. + +Both targets use Unix shell commands. + +The Dist target takes one argument, the file name (before the extension). + +The ``distcheck`` target creates (and removes) ``${ARCHIVE_NAME}-build`` +and ``${ARCHIVE_NAME}-dest``. + +#]=======================================================================] +function(Dist ARCHIVE_NAME) + if(NOT TARGET dist AND NOT TARGET distcheck) + add_custom_target(dist + COMMAND git config tar.tar.xz.command "xz -c" + COMMAND git archive --prefix=${ARCHIVE_NAME}/ -o ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.gz HEAD + COMMAND git archive --prefix=${ARCHIVE_NAME}/ -o ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.xz HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + add_custom_target(distcheck + COMMAND chmod -R u+w ${ARCHIVE_NAME} ${ARCHIVE_NAME}-build ${ARCHIVE_NAME}-dest 2>/dev/null || true + COMMAND rm -rf ${ARCHIVE_NAME} ${ARCHIVE_NAME}-build ${ARCHIVE_NAME}-dest + COMMAND ${CMAKE_COMMAND} -E tar xf ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.gz + COMMAND chmod -R u-w ${ARCHIVE_NAME} + COMMAND mkdir ${ARCHIVE_NAME}-build + COMMAND mkdir ${ARCHIVE_NAME}-dest + COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${ARCHIVE_NAME}-dest ${ARCHIVE_NAME} -B ${ARCHIVE_NAME}-build + COMMAND make -C ${ARCHIVE_NAME}-build -j4 + COMMAND make -C ${ARCHIVE_NAME}-build test + COMMAND make -C ${ARCHIVE_NAME}-build install + # COMMAND make -C ${ARCHIVE_NAME}-build uninstall + # COMMAND if [ `find ${ARCHIVE_NAME}-dest ! -type d | wc -l` -ne 0 ]; then echo leftover files in ${ARCHIVE_NAME}-dest; false; fi + COMMAND make -C ${ARCHIVE_NAME}-build clean + COMMAND chmod -R u+w ${ARCHIVE_NAME} ${ARCHIVE_NAME}-build ${ARCHIVE_NAME}-dest + COMMAND rm -rf ${ARCHIVE_NAME} ${ARCHIVE_NAME}-build ${ARCHIVE_NAME}-dest + COMMAND echo "${ARCHIVE_NAME}.tar.gz is ready for distribution." + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + add_dependencies(distcheck dist) + endif() +endfunction() diff --git a/thirdparty/libzip-1.11.3/cmake/FindMbedTLS.cmake b/thirdparty/libzip-1.11.3/cmake/FindMbedTLS.cmake new file mode 100644 index 0000000..5a6ef9d --- /dev/null +++ b/thirdparty/libzip-1.11.3/cmake/FindMbedTLS.cmake @@ -0,0 +1,141 @@ +# Copyright (C) 2020 Dieter Baron and Thomas Klausner +# +# The authors can be contacted at +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# 3. The names of the authors may not be used to endorse or promote +# products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#[=======================================================================[.rst: +FindMbedTLS +------- + +Finds the Mbed TLS library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``MbedTLS::MbedTLS`` + The Mbed TLS library + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``MbedTLS_FOUND`` + True if the system has the Mbed TLS library. +``MbedTLS_VERSION`` + The version of the Mbed TLS library which was found. +``MbedTLS_INCLUDE_DIRS`` + Include directories needed to use Mbed TLS. +``MbedTLS_LIBRARIES`` + Libraries needed to link to Mbed TLS. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``MbedTLS_INCLUDE_DIR`` + The directory containing ``mbedtls/aes.h``. +``MbedTLS_LIBRARY`` + The path to the Mbed TLS library. + +#]=======================================================================] + +# I'm not aware of a pkg-config file for mbedtls as of 2020/07/08. +#find_package(PkgConfig) +#pkg_check_modules(PC_MbedTLS QUIET mbedtls) + +find_path(MbedTLS_INCLUDE_DIR + NAMES mbedtls/aes.h +# PATHS ${PC_MbedTLS_INCLUDE_DIRS} +) +find_library(MbedTLS_LIBRARY + NAMES mbedcrypto +# PATHS ${PC_MbedTLS_LIBRARY_DIRS} +) + +# Extract version information from the header file +if(MbedTLS_INCLUDE_DIR) + # for major version 3 + if(EXISTS ${MbedTLS_INCLUDE_DIR}/mbedtls/build_info.h) + file(STRINGS ${MbedTLS_INCLUDE_DIR}/mbedtls/build_info.h _ver_line + REGEX "^#define MBEDTLS_VERSION_STRING *\"[0-9]+\\.[0-9]+\\.[0-9]+\"" + LIMIT_COUNT 1) + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" + MbedTLS_VERSION "${_ver_line}") + unset(_ver_line) + # for major version 2 + elseif(EXISTS ${MbedTLS_INCLUDE_DIR}/mbedtls/version.h) + file(STRINGS ${MbedTLS_INCLUDE_DIR}/mbedtls/version.h _ver_line + REGEX "^#define MBEDTLS_VERSION_STRING *\"[0-9]+\\.[0-9]+\\.[0-9]+\"" + LIMIT_COUNT 1) + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" + MbedTLS_VERSION "${_ver_line}") + unset(_ver_line) + else() + if(PC_MbedTLS_VERSION) + set(MbedTLS_VERSION ${PC_MbedTLS_VERSION}) + else() + # version unknown + set(MbedTLS_VERSION "0.0") + endif() + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(MbedTLS + FOUND_VAR MbedTLS_FOUND + REQUIRED_VARS + MbedTLS_LIBRARY + MbedTLS_INCLUDE_DIR + VERSION_VAR MbedTLS_VERSION +) + +if(MbedTLS_FOUND) + set(MbedTLS_LIBRARIES ${MbedTLS_LIBRARY}) + set(MbedTLS_INCLUDE_DIRS ${MbedTLS_INCLUDE_DIR}) +# set(MbedTLS_DEFINITIONS ${PC_MbedTLS_CFLAGS_OTHER}) +endif() + +if(MbedTLS_FOUND AND NOT TARGET MbedTLS::MbedTLS) + add_library(MbedTLS::MbedTLS UNKNOWN IMPORTED) + set_target_properties(MbedTLS::MbedTLS PROPERTIES + IMPORTED_LOCATION "${MbedTLS_LIBRARY}" +# INTERFACE_COMPILE_OPTIONS "${PC_MbedTLS_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${MbedTLS_INCLUDE_DIR}" + ) +endif() + +mark_as_advanced( + MbedTLS_INCLUDE_DIR + MbedTLS_LIBRARY + ) diff --git a/thirdparty/libzip-1.11.3/cmake/FindNettle.cmake b/thirdparty/libzip-1.11.3/cmake/FindNettle.cmake new file mode 100644 index 0000000..8f0deb0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/cmake/FindNettle.cmake @@ -0,0 +1,141 @@ +# Copyright (C) 2020 Dieter Baron and Thomas Klausner +# +# The authors can be contacted at +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# 3. The names of the authors may not be used to endorse or promote +# products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#[=======================================================================[.rst: +FindNettle +------- + +Finds the Nettle library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``Nettle::Nettle`` + The Nettle library + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``Nettle_FOUND`` + True if the system has the Nettle library. +``Nettle_VERSION`` + The version of the Nettle library which was found. +``Nettle_INCLUDE_DIRS`` + Include directories needed to use Nettle. +``Nettle_LIBRARIES`` + Libraries needed to link to Nettle. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Nettle_INCLUDE_DIR`` + The directory containing ``nettle/aes.h``. +``Nettle_LIBRARY`` + The path to the Nettle library. + +#]=======================================================================] + +find_package(PkgConfig) +pkg_check_modules(PC_Nettle QUIET nettle) + +find_path(Nettle_INCLUDE_DIR + NAMES nettle/aes.h nettle/md5.h nettle/pbkdf2.h nettle/ripemd160.h nettle/sha.h + PATHS ${PC_Nettle_INCLUDE_DIRS} +) +find_library(Nettle_LIBRARY + NAMES nettle + PATHS ${PC_Nettle_LIBRARY_DIRS} +) + +# Extract version information from the header file +if(Nettle_INCLUDE_DIR) + # This file only exists in nettle>=3.0 + if(EXISTS ${Nettle_INCLUDE_DIR}/nettle/version.h) + file(STRINGS ${Nettle_INCLUDE_DIR}/nettle/version.h _ver_major_line + REGEX "^#define NETTLE_VERSION_MAJOR *[0-9]+" + LIMIT_COUNT 1) + string(REGEX MATCH "[0-9]+" + Nettle_MAJOR_VERSION "${_ver_major_line}") + file(STRINGS ${Nettle_INCLUDE_DIR}/nettle/version.h _ver_minor_line + REGEX "^#define NETTLE_VERSION_MINOR *[0-9]+" + LIMIT_COUNT 1) + string(REGEX MATCH "[0-9]+" + Nettle_MINOR_VERSION "${_ver_minor_line}") + set(Nettle_VERSION "${Nettle_MAJOR_VERSION}.${Nettle_MINOR_VERSION}") + unset(_ver_major_line) + unset(_ver_minor_line) + else() + if(PC_Nettle_VERSION) + set(Nettle_VERSION ${PC_Nettle_VERSION}) + else() + set(Nettle_VERSION "1.0") + endif() + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Nettle + FOUND_VAR Nettle_FOUND + REQUIRED_VARS + Nettle_LIBRARY + Nettle_INCLUDE_DIR + VERSION_VAR Nettle_VERSION +) + +if(Nettle_FOUND) + set(Nettle_LIBRARIES ${Nettle_LIBRARY}) + set(Nettle_INCLUDE_DIRS ${Nettle_INCLUDE_DIR}) + set(Nettle_DEFINITIONS ${PC_Nettle_CFLAGS_OTHER}) +endif() + +if(Nettle_FOUND AND NOT TARGET Nettle::Nettle) + add_library(Nettle::Nettle UNKNOWN IMPORTED) + set_target_properties(Nettle::Nettle PROPERTIES + IMPORTED_LOCATION "${Nettle_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_Nettle_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Nettle_INCLUDE_DIR}" + ) +endif() + +mark_as_advanced( + Nettle_INCLUDE_DIR + Nettle_LIBRARY +) + +# compatibility variables +set(Nettle_VERSION_STRING ${Nettle_VERSION}) diff --git a/thirdparty/libzip-1.11.3/cmake/Findzstd.cmake b/thirdparty/libzip-1.11.3/cmake/Findzstd.cmake new file mode 100644 index 0000000..b389c6b --- /dev/null +++ b/thirdparty/libzip-1.11.3/cmake/Findzstd.cmake @@ -0,0 +1,186 @@ +# Copyright (C) 2020 Dieter Baron and Thomas Klausner +# +# The authors can be contacted at +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# 3. The names of the authors may not be used to endorse or promote +# products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#[=======================================================================[.rst: +Findzstd +------- + +Finds the Zstandard (zstd) library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``zstd::libzstd_shared`` + The shared Zstandard library +``zstd::libzstd_static`` + The shared Zstandard library + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``zstd_FOUND`` + True if the system has the Zstandard library. +``zstd_VERSION`` + The version of the Zstandard library which was found. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``zstd_INCLUDE_DIR`` + The directory containing ``zstd.h``. +``zstd_STATIC_LIBRARY`` + The path to the Zstandard static library. +``zstd_SHARED_LIBRARY`` + The path to the Zstandard shared library. +``zstd_DLL`` + The path to the Zstandard DLL. + +#]=======================================================================] + +find_package(PkgConfig) +pkg_check_modules(PC_zstd QUIET libzstd) + +find_path(zstd_INCLUDE_DIR + NAMES zstd.h + HINTS ${PC_zstd_INCLUDE_DIRS} +) + +find_file(zstd_DLL + NAMES libzstd.dll zstd.dll + PATH_SUFFIXES bin + HINTS ${PC_zstd_PREFIX} +) + +# On Windows, we manually define the library names to avoid mistaking the +# implib for the static library +if(zstd_DLL) + set(_zstd_win_static_name zstd-static) + set(_zstd_win_shared_name zstd) +else() + # vcpkg removes the -static suffix in static builds + set(_zstd_win_static_name zstd zstd_static) + set(_zstd_win_shared_name) +endif() + +set(_previous_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES}) +set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".dylib" ".dll.a" ".lib") +find_library(zstd_SHARED_LIBRARY + NAMES zstd ${_zstd_win_shared_name} + HINTS ${PC_zstd_LIBDIR} +) + +set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".lib") +find_library(zstd_STATIC_LIBRARY + NAMES zstd ${_zstd_win_static_name} + HINTS ${PC_zstd_LIBDIR} +) +set(CMAKE_FIND_LIBRARY_SUFFIXES ${_previous_suffixes}) + +# Set zstd_LIBRARY to the shared library or fall back to the static library +if(zstd_SHARED_LIBRARY) + set(_zstd_LIBRARY ${zstd_SHARED_LIBRARY}) +else() + set(_zstd_LIBRARY ${zstd_STATIC_LIBRARY}) +endif() + +# Extract version information from the header file +if(zstd_INCLUDE_DIR) + file(STRINGS ${zstd_INCLUDE_DIR}/zstd.h _ver_major_line + REGEX "^#define ZSTD_VERSION_MAJOR *[0-9]+" + LIMIT_COUNT 1) + string(REGEX MATCH "[0-9]+" + zstd_MAJOR_VERSION "${_ver_major_line}") + file(STRINGS ${zstd_INCLUDE_DIR}/zstd.h _ver_minor_line + REGEX "^#define ZSTD_VERSION_MINOR *[0-9]+" + LIMIT_COUNT 1) + string(REGEX MATCH "[0-9]+" + zstd_MINOR_VERSION "${_ver_minor_line}") + file(STRINGS ${zstd_INCLUDE_DIR}/zstd.h _ver_release_line + REGEX "^#define ZSTD_VERSION_RELEASE *[0-9]+" + LIMIT_COUNT 1) + string(REGEX MATCH "[0-9]+" + zstd_RELEASE_VERSION "${_ver_release_line}") + set(Zstd_VERSION "${zstd_MAJOR_VERSION}.${zstd_MINOR_VERSION}.${zstd_RELEASE_VERSION}") + unset(_ver_major_line) + unset(_ver_minor_line) + unset(_ver_release_line) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(zstd + FOUND_VAR zstd_FOUND + REQUIRED_VARS + _zstd_LIBRARY + zstd_INCLUDE_DIR + VERSION_VAR zstd_VERSION +) + +if(zstd_FOUND AND zstd_SHARED_LIBRARY AND NOT TARGET zstd::libzstd_shared) + add_library(zstd::libzstd_shared SHARED IMPORTED) + if(WIN32) + set_target_properties(zstd::libzstd_shared PROPERTIES + IMPORTED_LOCATION "${zstd_DLL}" + IMPORTED_IMPLIB "${zstd_SHARED_LIBRARY}" + ) + else() + set_target_properties(zstd::libzstd_shared PROPERTIES + IMPORTED_LOCATION "${zstd_SHARED_LIBRARY}" + ) + endif() + + set_target_properties(zstd::libzstd_shared PROPERTIES + INTERFACE_COMPILE_OPTIONS "${PC_zstd_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}" + ) +endif() + +if(zstd_FOUND AND zstd_STATIC_LIBRARY AND NOT TARGET zstd::libzstd_static) + add_library(zstd::libzstd_static STATIC IMPORTED) + set_target_properties(zstd::libzstd_static PROPERTIES + IMPORTED_LOCATION "${zstd_STATIC_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_zstd_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}" + ) +endif() + +mark_as_advanced( + zstd_INCLUDE_DIR + zstd_DLL + zstd_SHARED_LIBRARY + zstd_STATIC_LIBRARY +) diff --git a/thirdparty/libzip-1.11.3/cmake/GenerateZipErrorStrings.cmake b/thirdparty/libzip-1.11.3/cmake/GenerateZipErrorStrings.cmake new file mode 100644 index 0000000..550412b --- /dev/null +++ b/thirdparty/libzip-1.11.3/cmake/GenerateZipErrorStrings.cmake @@ -0,0 +1,47 @@ +# create zip_err_str.c from zip.h and zipint.h +file(READ ${PROJECT_SOURCE_DIR}/lib/zip.h zip_h) +string(REGEX MATCHALL "#define ZIP_ER_([A-Z0-9_]+) ([0-9]+)[ \t]+/([-*0-9a-zA-Z, ']*)/" zip_h_err ${zip_h}) +file(READ ${PROJECT_SOURCE_DIR}/lib/zipint.h zipint_h) +string(REGEX MATCHALL "#define ZIP_ER_DETAIL_([A-Z0-9_]+) ([0-9]+)[ \t]+/([-*0-9a-zA-Z, ']*)/" zipint_h_err ${zipint_h}) +set(zip_err_str [=[ +/* + This file was generated automatically by CMake + from zip.h and zipint.h\; make changes there. +*/ + +#include "zipint.h" + +#define L ZIP_ET_LIBZIP +#define N ZIP_ET_NONE +#define S ZIP_ET_SYS +#define Z ZIP_ET_ZLIB + +#define E ZIP_DETAIL_ET_ENTRY +#define G ZIP_DETAIL_ET_GLOBAL + +const struct _zip_err_info _zip_err_str[] = { +]=]) +set(zip_err_type) +foreach(errln ${zip_h_err}) + string(REGEX MATCH "#define ZIP_ER_([A-Z0-9_]+) ([0-9]+)[ \t]+/([-*0-9a-zA-Z, ']*)/" err_t_tt ${errln}) + string(REGEX MATCH "([L|N|S|Z]+) ([-0-9a-zA-Z,, ']*)" err_t_tt "${CMAKE_MATCH_3}") + string(STRIP "${CMAKE_MATCH_2}" err_t_tt) + string(APPEND zip_err_str " { ${CMAKE_MATCH_1}, \"${err_t_tt}\" },\n") +endforeach() +string(APPEND zip_err_str [=[}\; + +const int _zip_err_str_count = sizeof(_zip_err_str)/sizeof(_zip_err_str[0])\; + +const struct _zip_err_info _zip_err_details[] = { +]=]) +foreach(errln ${zipint_h_err}) + string(REGEX MATCH "#define ZIP_ER_DETAIL_([A-Z0-9_]+) ([0-9]+)[ \t]+/([-*0-9a-zA-Z, ']*)/" err_t_tt ${errln}) + string(REGEX MATCH "([E|G]+) ([-0-9a-zA-Z, ']*)" err_t_tt "${CMAKE_MATCH_3}") + string(STRIP "${CMAKE_MATCH_2}" err_t_tt) + string(APPEND zip_err_str " { ${CMAKE_MATCH_1}, \"${err_t_tt}\" },\n") +endforeach() +string(APPEND zip_err_str [=[}\; + +const int _zip_err_details_count = sizeof(_zip_err_details)/sizeof(_zip_err_details[0])\; +]=]) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/zip_err_str.c ${zip_err_str}) diff --git a/thirdparty/libzip-1.11.3/config.h.in b/thirdparty/libzip-1.11.3/config.h.in new file mode 100644 index 0000000..07242da --- /dev/null +++ b/thirdparty/libzip-1.11.3/config.h.in @@ -0,0 +1,75 @@ +#ifndef HAD_CONFIG_H +#define HAD_CONFIG_H +#ifndef _HAD_ZIPCONF_H +#include "zipconf.h" +#endif +/* BEGIN DEFINES */ +#cmakedefine ENABLE_FDOPEN +#cmakedefine HAVE___PROGNAME +#cmakedefine HAVE__CLOSE +#cmakedefine HAVE__DUP +#cmakedefine HAVE__FDOPEN +#cmakedefine HAVE__FILENO +#cmakedefine HAVE__FSEEKI64 +#cmakedefine HAVE__FSTAT64 +#cmakedefine HAVE__SETMODE +#cmakedefine HAVE__SNPRINTF +#cmakedefine HAVE__SNPRINTF_S +#cmakedefine HAVE__SNWPRINTF_S +#cmakedefine HAVE__STAT64 +#cmakedefine HAVE__STRDUP +#cmakedefine HAVE__STRICMP +#cmakedefine HAVE__STRTOI64 +#cmakedefine HAVE__STRTOUI64 +#cmakedefine HAVE__UNLINK +#cmakedefine HAVE_ARC4RANDOM +#cmakedefine HAVE_CLONEFILE +#cmakedefine HAVE_COMMONCRYPTO +#cmakedefine HAVE_CRYPTO +#cmakedefine HAVE_FICLONERANGE +#cmakedefine HAVE_FILENO +#cmakedefine HAVE_FCHMOD +#cmakedefine HAVE_FSEEKO +#cmakedefine HAVE_FTELLO +#cmakedefine HAVE_GETPROGNAME +#cmakedefine HAVE_GETSECURITYINFO +#cmakedefine HAVE_GNUTLS +#cmakedefine HAVE_LIBBZ2 +#cmakedefine HAVE_LIBLZMA +#cmakedefine HAVE_LIBZSTD +#cmakedefine HAVE_LOCALTIME_R +#cmakedefine HAVE_LOCALTIME_S +#cmakedefine HAVE_MEMCPY_S +#cmakedefine HAVE_MBEDTLS +#cmakedefine HAVE_MKSTEMP +#cmakedefine HAVE_OPENSSL +#cmakedefine HAVE_SETMODE +#cmakedefine HAVE_SNPRINTF +#cmakedefine HAVE_SNPRINTF_S +#cmakedefine HAVE_STRCASECMP +#cmakedefine HAVE_STRDUP +#cmakedefine HAVE_STRERROR_S +#cmakedefine HAVE_STRERRORLEN_S +#cmakedefine HAVE_STRICMP +#cmakedefine HAVE_STRNCPY_S +#cmakedefine HAVE_STRTOLL +#cmakedefine HAVE_STRTOULL +#cmakedefine HAVE_STRUCT_TM_TM_ZONE +#cmakedefine HAVE_STDBOOL_H +#cmakedefine HAVE_STRINGS_H +#cmakedefine HAVE_UNISTD_H +#cmakedefine HAVE_WINDOWS_CRYPTO +#cmakedefine SIZEOF_OFF_T ${SIZEOF_OFF_T} +#cmakedefine SIZEOF_SIZE_T ${SIZEOF_SIZE_T} +#cmakedefine HAVE_DIRENT_H +#cmakedefine HAVE_FTS_H +#cmakedefine HAVE_NDIR_H +#cmakedefine HAVE_SYS_DIR_H +#cmakedefine HAVE_SYS_NDIR_H +#cmakedefine WORDS_BIGENDIAN +#cmakedefine HAVE_SHARED +/* END DEFINES */ +#define PACKAGE "@CMAKE_PROJECT_NAME@" +#define VERSION "@CMAKE_PROJECT_VERSION@" + +#endif /* HAD_CONFIG_H */ diff --git a/thirdparty/libzip-1.11.3/examples/CMakeLists.txt b/thirdparty/libzip-1.11.3/examples/CMakeLists.txt new file mode 100644 index 0000000..0083232 --- /dev/null +++ b/thirdparty/libzip-1.11.3/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +foreach(PROGRAM add-compressed-data autoclose-archive in-memory) + add_executable(${PROGRAM} ${PROGRAM}.c) + target_link_libraries(${PROGRAM} zip) + target_include_directories(${PROGRAM} PRIVATE BEFORE ${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}) +endforeach() diff --git a/thirdparty/libzip-1.11.3/examples/add-compressed-data.c b/thirdparty/libzip-1.11.3/examples/add-compressed-data.c new file mode 100644 index 0000000..5db37a3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/examples/add-compressed-data.c @@ -0,0 +1,171 @@ +/* + add-compressed-data.c -- add already compressed file to zip archive + Copyright (C) 2022-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + This layered source can be used to add pre-compressed data to a zip archive. + The data is taken from the lower layer source. + Metadata (uncompressed size, crc, compression method) must be provided by the caller. +*/ + +#include +#include +#include + +#include + +struct ctx { + zip_uint64_t uncompressed_size; + zip_uint32_t crc; + zip_uint32_t compression_method; +}; + +zip_int64_t callback(zip_source_t* src, void *ud, void* data, zip_uint64_t length, zip_source_cmd_t command) { + struct ctx* ctx = (struct ctx*)ud; + + switch (command) { + case ZIP_SOURCE_FREE: + /* Free our context. */ + free(ctx); + return 0; + + case ZIP_SOURCE_STAT: { + zip_stat_t *st = (zip_stat_t *)data; + /* Fix metadata with provided values. */ + if (st->valid & ZIP_STAT_SIZE) { + st->comp_size = st->size; + st->valid |= ZIP_STAT_COMP_SIZE; + } + st->size = ctx->uncompressed_size; + st->crc = ctx->crc; + st->comp_method = ctx->compression_method; + st->valid |= ZIP_STAT_COMP_METHOD | ZIP_STAT_SIZE | ZIP_STAT_CRC; + + return 0; + } + + default: + /* For all other commands, use default implementation */ + return zip_source_pass_to_lower_layer(src, data, length, command); + } +} + +zip_source_t* create_layered_compressed_source(zip_source_t* source, zip_uint64_t uncompressed_size, zip_uint32_t crc, zip_uint32_t compression_method, zip_error_t *error) { + struct ctx* ctx = (struct ctx*)malloc(sizeof(*ctx)); + zip_source_t *compressed_source; + + /* Allocate context. */ + if (ctx == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + /* Initialize context */ + ctx->compression_method = compression_method; + ctx->uncompressed_size = uncompressed_size; + ctx->crc = crc; + + /* Create layered source using our callback and context. */ + compressed_source = zip_source_layered_create(source, callback, ctx, error); + + /* In case of error, free context. */ + if (compressed_source == NULL) { + free(ctx); + } + + return compressed_source; +} + + +/* This is the information needed to add pre-compressed data to a zip archive. data must be compressed in a format compatible with Zip (e.g. no gzip header for deflate). */ + +zip_uint16_t compression_method = ZIP_CM_DEFLATE; +zip_uint64_t uncompressed_size = 60; +zip_uint32_t crc = 0xb0354048; +zip_uint8_t data[] = { + 0x4B, 0x4C, 0x44, 0x06, 0x5C, 0x49, 0x28, 0x80, + 0x2B, 0x11, 0x55 ,0x36, 0x19, 0x05, 0x70, 0x01, + 0x00 +}; + + +int +main(int argc, char *argv[]) { + const char *archive; + zip_source_t *src, *src_comp; + zip_t *za; + int err; + + if (argc != 2) { + fprintf(stderr, "usage: %s archive\n", argv[0]); + return 1; + } + archive = argv[1]; + + if ((za = zip_open(archive, ZIP_CREATE, &err)) == NULL) { + zip_error_t error; + zip_error_init_with_code(&error, err); + fprintf(stderr, "%s: cannot open zip archive '%s': %s\n", argv[0], archive, zip_error_strerror(&error)); + zip_error_fini(&error); + exit(1); + } + + /* The data can come from any source. To keep the example simple, it is provided in a static buffer here. */ + if ((src = zip_source_buffer(za, data, sizeof(data), 0)) == NULL) { + fprintf(stderr, "%s: cannot create buffer source: %s\n", argv[0], zip_strerror(za)); + zip_discard(za); + exit(1); + } + + zip_error_t error; + if ((src_comp = create_layered_compressed_source(src, uncompressed_size, crc, compression_method, &error)) == NULL) { + fprintf(stderr, "%s: cannot create layered source: %s\n", argv[0], zip_error_strerror(&error)); + zip_source_free(src); + zip_discard(za); + exit(1); + } + + if ((zip_file_add(za, "precompressed", src_comp, 0)) < 0) { + fprintf(stderr, "%s: cannot add precompressed file: %s\n", argv[0], zip_strerror(za)); + zip_source_free(src_comp); + zip_discard(za); + exit(1); + } + + if ((zip_close(za)) < 0) { + fprintf(stderr, "%s: cannot close archive '%s': %s\n", argv[0], archive, zip_strerror(za)); + zip_discard(za); + exit(1); + } + + exit(0); +} diff --git a/thirdparty/libzip-1.11.3/examples/autoclose-archive.c b/thirdparty/libzip-1.11.3/examples/autoclose-archive.c new file mode 100644 index 0000000..d236f0a --- /dev/null +++ b/thirdparty/libzip-1.11.3/examples/autoclose-archive.c @@ -0,0 +1,160 @@ +/* + autoclose-archive.c -- automatically close archive when source is closed + Copyright (C) 2022-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + This example layered source takes ownership of a zip archive and discards it when the source is freed. + It can be used to add files from various zip archives without having to keep track of them yourself. +*/ + + +#include +#include +#include + +#include + +struct ctx { + zip_t* archive; +}; + +zip_int64_t callback(zip_source_t* src, void *ud, void* data, zip_uint64_t length, zip_source_cmd_t command) { + struct ctx* ctx = (struct ctx*)ud; + + switch (command) { + case ZIP_SOURCE_FREE: + /* Close zip archive we took ownership of */ + zip_discard(ctx->archive); + /* Free our own context */ + free(ctx); + return 0; + + default: + /* For all other commands, use default implementation */ + return zip_source_pass_to_lower_layer(src, data, length, command); + } +} + +zip_source_t* create_layered_autoclose(zip_source_t* source, zip_t *archive, zip_error_t *error) { + struct ctx* ctx = (struct ctx*)malloc(sizeof(*ctx)); + zip_source_t *autoclose_source; + + /* Allocate context. */ + if (ctx == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + /* Initialize context */ + ctx->archive = archive; + + /* Create layered source using our callback and context. */ + autoclose_source = zip_source_layered_create(source, callback, ctx, error); + + /* In case of error, free context. */ + if (autoclose_source == NULL) { + free(ctx); + } + + return autoclose_source; +} + + +int +main(int argc, char *argv[]) { + const char *destination_archive, *source_archive, *source_file; + zip_int64_t index; + zip_source_t *src, *src_autoclose; + zip_t *z_source, *z_destination; + int err; + + if (argc != 4) { + fprintf(stderr, "usage: %s destination-archive source-archive source-file\n", argv[0]); + return 1; + } + destination_archive = argv[1]; + source_archive = argv[2]; + source_file = argv[3]; + + + if ((z_source = zip_open(source_archive, 0, &err)) == NULL) { + zip_error_t error; + zip_error_init_with_code(&error, err); + fprintf(stderr, "%s: cannot open zip archive '%s': %s\n", argv[0], source_archive, zip_error_strerror(&error)); + zip_error_fini(&error); + exit(1); + } + + if ((index = zip_name_locate(z_source, source_file, 0)) < 0) { + fprintf(stderr, "%s: cannot find file '%s' in '%s': %s\n", argv[0], source_file, source_archive, zip_strerror(z_source)); + zip_discard(z_source); + exit(1); + + } + if ((src = zip_source_zip_file(z_source, z_source, index, 0, 0, -1, NULL)) == NULL) { + fprintf(stderr, "%s: cannot open file '%s' in '%s': %s\n", argv[0], source_file, source_archive, zip_strerror(z_source)); + zip_discard(z_source); + exit(1); + } + + zip_error_t error; + if ((src_autoclose = create_layered_autoclose(src, z_source, &error)) == NULL) { + fprintf(stderr, "%s: cannot create layered source: %s\n", argv[0], zip_error_strerror(&error)); + zip_source_free(src); + zip_discard(z_source); + exit(1); + } + + if ((z_destination = zip_open(destination_archive, ZIP_CREATE, &err)) == NULL) { + zip_error_init_with_code(&error, err); + fprintf(stderr, "%s: cannot open zip archive '%s': %s\n", argv[0], destination_archive, zip_error_strerror(&error)); + zip_error_fini(&error); + zip_source_free(src_autoclose); /* freeing src_autoclose closes z_source */ + exit(1); + } + + + if ((zip_file_add(z_destination, source_file, src_autoclose, 0)) < 0) { + fprintf(stderr, "%s: cannot add file: %s\n", argv[0], zip_strerror(z_source)); + zip_source_free(src_autoclose); + zip_discard(z_destination); + exit(1); + } + + if ((zip_close(z_destination)) < 0) { + fprintf(stderr, "%s: cannot close archive '%s': %s\n", argv[0], destination_archive, zip_strerror(z_source)); + zip_discard(z_destination); + exit(1); + } + + exit(0); +} diff --git a/thirdparty/libzip-1.11.3/examples/cmake-project/CMakeLists.txt b/thirdparty/libzip-1.11.3/examples/cmake-project/CMakeLists.txt new file mode 100644 index 0000000..14d5c4d --- /dev/null +++ b/thirdparty/libzip-1.11.3/examples/cmake-project/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.5) + +project(cmake-example + VERSION 1.0 + LANGUAGES C) + +find_package(libzip 1.10 REQUIRED) + +add_executable(cmake-example cmake-example.c) +target_link_libraries(cmake-example PRIVATE libzip::zip) diff --git a/thirdparty/libzip-1.11.3/examples/cmake-project/cmake-example.c b/thirdparty/libzip-1.11.3/examples/cmake-project/cmake-example.c new file mode 100644 index 0000000..fdc7be8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/examples/cmake-project/cmake-example.c @@ -0,0 +1,39 @@ +/* + cmake-example.c -- mininmal code using libzip for CMake example + Copyright (C) 2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +int +main(int argc, char *argv[]) { + printf("libzip version is %s\n", zip_libzip_version()); +} diff --git a/thirdparty/libzip-1.11.3/examples/in-memory.c b/thirdparty/libzip-1.11.3/examples/in-memory.c new file mode 100644 index 0000000..e022a0b --- /dev/null +++ b/thirdparty/libzip-1.11.3/examples/in-memory.c @@ -0,0 +1,217 @@ +/* + in-memory.c -- modify zip file in memory + Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include +#include + +#include + +static int +get_data(void **datap, size_t *sizep, const char *archive) { + /* example implementation that reads data from file */ + struct stat st; + FILE *fp; + + if ((fp = fopen(archive, "rb")) == NULL) { + if (errno != ENOENT) { + fprintf(stderr, "can't open %s: %s\n", archive, strerror(errno)); + return -1; + } + + *datap = NULL; + *sizep = 0; + + return 0; + } + + if (fstat(fileno(fp), &st) < 0) { + fprintf(stderr, "can't stat %s: %s\n", archive, strerror(errno)); + fclose(fp); + return -1; + } + + if ((*datap = malloc((size_t)st.st_size)) == NULL) { + fprintf(stderr, "can't allocate buffer\n"); + fclose(fp); + return -1; + } + + if (fread(*datap, 1, (size_t)st.st_size, fp) < (size_t)st.st_size) { + fprintf(stderr, "can't read %s: %s\n", archive, strerror(errno)); + free(*datap); + fclose(fp); + return -1; + } + + fclose(fp); + + *sizep = (size_t)st.st_size; + return 0; +} + +static int +modify_archive(zip_t *za) { + /* modify the archive */ + return 0; +} + + +static int +use_data(void *data, size_t size, const char *archive) { + /* example implementation that writes data to file */ + FILE *fp; + + if (data == NULL) { + if (remove(archive) < 0 && errno != ENOENT) { + fprintf(stderr, "can't remove %s: %s\n", archive, strerror(errno)); + return -1; + } + return 0; + } + + if ((fp = fopen(archive, "wb")) == NULL) { + fprintf(stderr, "can't open %s: %s\n", archive, strerror(errno)); + return -1; + } + if (fwrite(data, 1, size, fp) < size) { + fprintf(stderr, "can't write %s: %s\n", archive, strerror(errno)); + fclose(fp); + return -1; + } + if (fclose(fp) < 0) { + fprintf(stderr, "can't write %s: %s\n", archive, strerror(errno)); + return -1; + } + + return 0; +} + + +int +main(int argc, char *argv[]) { + const char *archive; + zip_source_t *src; + zip_t *za; + zip_error_t error; + void *data; + size_t size; + + if (argc < 2) { + fprintf(stderr, "usage: %s archive\n", argv[0]); + return 1; + } + archive = argv[1]; + + /* get buffer with zip archive inside */ + if (get_data(&data, &size, archive) < 0) { + return 1; + } + + zip_error_init(&error); + /* create source from buffer */ + if ((src = zip_source_buffer_create(data, size, 1, &error)) == NULL) { + fprintf(stderr, "can't create source: %s\n", zip_error_strerror(&error)); + free(data); + zip_error_fini(&error); + return 1; + } + + /* open zip archive from source */ + if ((za = zip_open_from_source(src, 0, &error)) == NULL) { + fprintf(stderr, "can't open zip from source: %s\n", zip_error_strerror(&error)); + zip_source_free(src); + zip_error_fini(&error); + return 1; + } + zip_error_fini(&error); + + /* we'll want to read the data back after zip_close */ + zip_source_keep(src); + + /* modify archive */ + modify_archive(za); + + /* close archive */ + if (zip_close(za) < 0) { + fprintf(stderr, "can't close zip archive '%s': %s\n", archive, zip_strerror(za)); + return 1; + } + + + /* copy new archive to buffer */ + + if (zip_source_is_deleted(src)) { + /* new archive is empty, thus no data */ + data = NULL; + } + else { + zip_stat_t zst; + + if (zip_source_stat(src, &zst) < 0) { + fprintf(stderr, "can't stat source: %s\n", zip_error_strerror(zip_source_error(src))); + return 1; + } + + size = zst.size; + + if (zip_source_open(src) < 0) { + fprintf(stderr, "can't open source: %s\n", zip_error_strerror(zip_source_error(src))); + return 1; + } + if ((data = malloc(size)) == NULL) { + fprintf(stderr, "malloc failed: %s\n", strerror(errno)); + zip_source_close(src); + return 1; + } + if ((zip_uint64_t)zip_source_read(src, data, size) < size) { + fprintf(stderr, "can't read data from source: %s\n", zip_error_strerror(zip_source_error(src))); + zip_source_close(src); + free(data); + return 1; + } + zip_source_close(src); + } + + /* we're done with src */ + zip_source_free(src); + + /* use new data */ + use_data(data, size, archive); + + free(data); + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/examples/windows-open.c b/thirdparty/libzip-1.11.3/examples/windows-open.c new file mode 100644 index 0000000..6790248 --- /dev/null +++ b/thirdparty/libzip-1.11.3/examples/windows-open.c @@ -0,0 +1,60 @@ +/* + windows-open.c -- open zip archive using Windows UTF-16/Unicode file name + Copyright (C) 2015-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +zip_t * +windows_open(const wchar_t *name, int flags) { + zip_source_t *src; + zip_t *za; + zip_error_t error; + + zip_error_init(&error); + /* create source from buffer */ + if ((src = zip_source_win32w_create(name, 0, -1, &error)) == NULL) { + fprintf(stderr, "can't create source: %s\n", zip_error_strerror(&error)); + zip_error_fini(&error); + return NULL; + } + + /* open zip archive from source */ + if ((za = zip_open_from_source(src, flags, &error)) == NULL) { + fprintf(stderr, "can't open zip from source: %s\n", zip_error_strerror(&error)); + zip_source_free(src); + zip_error_fini(&error); + return NULL; + } + zip_error_fini(&error); + + return za; +} diff --git a/thirdparty/libzip-1.11.3/lib/CMakeLists.txt b/thirdparty/libzip-1.11.3/lib/CMakeLists.txt new file mode 100644 index 0000000..5f95ace --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/CMakeLists.txt @@ -0,0 +1,211 @@ +include(CheckFunctionExists) + +set(CMAKE_C_VISIBILITY_PRESET hidden) + +add_library(zip + zip_add.c + zip_add_dir.c + zip_add_entry.c + zip_algorithm_deflate.c + zip_buffer.c + zip_close.c + zip_delete.c + zip_dir_add.c + zip_dirent.c + zip_discard.c + zip_entry.c + zip_error.c + zip_error_clear.c + zip_error_get.c + zip_error_get_sys_type.c + zip_error_strerror.c + zip_error_to_str.c + zip_extra_field.c + zip_extra_field_api.c + zip_fclose.c + zip_fdopen.c + zip_file_add.c + zip_file_error_clear.c + zip_file_error_get.c + zip_file_get_comment.c + zip_file_get_external_attributes.c + zip_file_get_offset.c + zip_file_rename.c + zip_file_replace.c + zip_file_set_comment.c + zip_file_set_encryption.c + zip_file_set_external_attributes.c + zip_file_set_mtime.c + zip_file_strerror.c + zip_fopen.c + zip_fopen_encrypted.c + zip_fopen_index.c + zip_fopen_index_encrypted.c + zip_fread.c + zip_fseek.c + zip_ftell.c + zip_get_archive_comment.c + zip_get_archive_flag.c + zip_get_encryption_implementation.c + zip_get_file_comment.c + zip_get_name.c + zip_get_num_entries.c + zip_get_num_files.c + zip_hash.c + zip_io_util.c + zip_libzip_version.c + zip_memdup.c + zip_name_locate.c + zip_new.c + zip_open.c + zip_pkware.c + zip_progress.c + zip_rename.c + zip_replace.c + zip_set_archive_comment.c + zip_set_archive_flag.c + zip_set_default_password.c + zip_set_file_comment.c + zip_set_file_compression.c + zip_set_name.c + zip_source_accept_empty.c + zip_source_begin_write.c + zip_source_begin_write_cloning.c + zip_source_buffer.c + zip_source_call.c + zip_source_close.c + zip_source_commit_write.c + zip_source_compress.c + zip_source_crc.c + zip_source_error.c + zip_source_file_common.c + zip_source_file_stdio.c + zip_source_free.c + zip_source_function.c + zip_source_get_dostime.c + zip_source_get_file_attributes.c + zip_source_is_deleted.c + zip_source_layered.c + zip_source_open.c + zip_source_pass_to_lower_layer.c + zip_source_pkware_decode.c + zip_source_pkware_encode.c + zip_source_read.c + zip_source_remove.c + zip_source_rollback_write.c + zip_source_seek.c + zip_source_seek_write.c + zip_source_stat.c + zip_source_supports.c + zip_source_tell.c + zip_source_tell_write.c + zip_source_window.c + zip_source_write.c + zip_source_zip.c + zip_source_zip_new.c + zip_stat.c + zip_stat_index.c + zip_stat_init.c + zip_strerror.c + zip_string.c + zip_unchange.c + zip_unchange_all.c + zip_unchange_archive.c + zip_unchange_data.c + zip_utf-8.c + ${CMAKE_CURRENT_BINARY_DIR}/zip_err_str.c + ) +add_library(libzip::zip ALIAS zip) + +if(WIN32) + target_compile_definitions(zip PRIVATE WIN32_LEAN_AND_MEAN) + target_sources(zip PRIVATE + zip_source_file_win32.c + zip_source_file_win32_named.c + zip_source_file_win32_utf16.c + zip_source_file_win32_utf8.c + ) + if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore) + target_sources(zip PRIVATE zip_random_uwp.c) + else() + target_sources(zip PRIVATE zip_source_file_win32_ansi.c zip_random_win32.c) + target_link_libraries(zip PRIVATE advapi32) + endif() +else(WIN32) + target_sources(zip PRIVATE + zip_source_file_stdio_named.c + zip_random_unix.c + ) +endif(WIN32) + +if(HAVE_LIBBZ2) + target_sources(zip PRIVATE zip_algorithm_bzip2.c) + target_link_libraries(zip PRIVATE BZip2::BZip2) +endif() + +if(HAVE_LIBLZMA) + target_sources(zip PRIVATE zip_algorithm_xz.c) + target_link_libraries(zip PRIVATE LibLZMA::LibLZMA) +endif() + +if(HAVE_LIBZSTD) + target_sources(zip PRIVATE zip_algorithm_zstd.c) + target_link_libraries(zip PRIVATE ${zstd_TARGET}) +endif() + +if(HAVE_COMMONCRYPTO) + target_sources(zip PRIVATE zip_crypto_commoncrypto.c) +elseif(HAVE_WINDOWS_CRYPTO) + target_sources(zip PRIVATE zip_crypto_win.c) + target_link_libraries(zip PRIVATE bcrypt) +elseif(HAVE_GNUTLS) + target_sources(zip PRIVATE zip_crypto_gnutls.c) + target_link_libraries(zip PRIVATE GnuTLS::GnuTLS Nettle::Nettle) +elseif(HAVE_OPENSSL) + target_sources(zip PRIVATE zip_crypto_openssl.c) + target_link_libraries(zip PRIVATE OpenSSL::Crypto) +elseif(HAVE_MBEDTLS) + target_sources(zip PRIVATE zip_crypto_mbedtls.c) + target_link_libraries(zip PRIVATE MbedTLS::MbedTLS) +endif() + +if(HAVE_CRYPTO) + target_sources(zip PRIVATE zip_winzip_aes.c zip_source_winzip_aes_decode.c zip_source_winzip_aes_encode.c) +endif() + +if(SHARED_LIB_VERSIONNING) + # MACHO_*_VERSION can be removed when SOVERSION gets increased. Cf #405 + set_target_properties(zip PROPERTIES VERSION 5.5 SOVERSION 5 MACHO_CURRENT_VERSION 6.5 MACHO_COMPATIBILITY_VERSION 6) +endif() + +target_link_libraries(zip PRIVATE ZLIB::ZLIB) +target_include_directories(zip + PUBLIC + $ + $ + $ + ) + +if(LIBZIP_DO_INSTALL) + install(TARGETS zip + EXPORT ${PROJECT_NAME}-targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(FILES zip.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +endif() + +# create zip_err_str.c from zip.h and zipint.h +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zip_err_str.c + COMMAND "${CMAKE_COMMAND}" + "-DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}" + "-DCMAKE_CURRENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}" + "-P" "${PROJECT_SOURCE_DIR}/cmake/GenerateZipErrorStrings.cmake" + DEPENDS + ${PROJECT_SOURCE_DIR}/cmake/GenerateZipErrorStrings.cmake + ${PROJECT_SOURCE_DIR}/lib/zip.h + ${PROJECT_SOURCE_DIR}/lib/zipint.h + COMMENT "Generating zip_err_str.c" +) diff --git a/thirdparty/libzip-1.11.3/lib/compat.h b/thirdparty/libzip-1.11.3/lib/compat.h new file mode 100644 index 0000000..49d3aa3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/compat.h @@ -0,0 +1,269 @@ +#ifndef _HAD_LIBZIP_COMPAT_H +#define _HAD_LIBZIP_COMPAT_H + +/* + compat.h -- compatibility defines. + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipconf.h" + +#include "config.h" + +/* to have *_MAX definitions for all types when compiling with g++ */ +#define __STDC_LIMIT_MACROS + +/* to have ISO C secure library functions */ +#define __STDC_WANT_LIB_EXT1__ 1 + +#ifdef _WIN32 +#ifndef ZIP_EXTERN +#ifndef ZIP_STATIC +#define ZIP_EXTERN __declspec(dllexport) +#endif +#endif +/* for dup(), close(), etc. */ +#include +#endif + +#ifdef HAVE_STDBOOL_H +#include +#else +typedef char bool; +#define true 1 +#define false 0 +#endif + +#include + +/* at least MinGW does not provide EOPNOTSUPP, see + * http://sourceforge.net/p/mingw/bugs/263/ + */ +#ifndef EOPNOTSUPP +#define EOPNOTSUPP EINVAL +#endif + +/* at least MinGW does not provide EOVERFLOW, see + * http://sourceforge.net/p/mingw/bugs/242/ + */ +#ifndef EOVERFLOW +#define EOVERFLOW EFBIG +#endif + +/* not supported on at least Windows */ +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif + +#ifdef _WIN32 +#if defined(HAVE__CLOSE) +#define close _close +#endif +#if defined(HAVE__DUP) +#define dup _dup +#endif +/* crashes reported when using fdopen instead of _fdopen on Windows/Visual Studio 10/Win64 */ +#if defined(HAVE__FDOPEN) +#define fdopen _fdopen +#endif +#if !defined(HAVE_FILENO) && defined(HAVE__FILENO) +#define fileno _fileno +#endif +#if !defined(HAVE_SNPRINTF) && defined(HAVE__SNPRINTF) +#define snprintf _snprintf +#endif +#if !defined(HAVE__SNWPRINTF_S) +#define _snwprintf_s(buf, bufsz, len, fmt, ...) (_snwprintf((buf), (len), (fmt), __VA_ARGS__)) +#endif +#if defined(HAVE__STRDUP) +#if !defined(HAVE_STRDUP) || defined(_WIN32) +#undef strdup +#define strdup _strdup +#endif +#endif +#if !defined(HAVE__SETMODE) && defined(HAVE_SETMODE) +#define _setmode setmode +#endif +#if !defined(HAVE_STRTOLL) && defined(HAVE__STRTOI64) +#define strtoll _strtoi64 +#endif +#if !defined(HAVE_STRTOULL) && defined(HAVE__STRTOUI64) +#define strtoull _strtoui64 +#endif +#if defined(HAVE__UNLINK) +#define unlink _unlink +#endif +#endif + + +#if defined(HAVE__FSEEKI64) && defined(HAVE__FSTAT64) && defined(HAVE__SEEK64) +/* Windows API using int64 */ +typedef zip_int64_t zip_off_t; +typedef struct _stat64 zip_os_stat_t; +#define zip_os_stat _stat64 +#define zip_os_fstat _fstat64 +#define zip_os_seek _fseeki64 +#define ZIP_FSEEK_MAX ZIP_INT64_MAX +#define ZIP_FSEEK_MIN ZIP_INT64_MIN +#else + +/* Normal API */ +#include +typedef struct stat zip_os_stat_t; +#define zip_os_fstat fstat +#define zip_os_stat stat + +#if defined(HAVE_FTELLO) && defined(HAVE_FSEEKO) +/* Using off_t */ +typedef off_t zip_off_t; +#if SIZEOF_OFF_T == 8 +#define ZIP_OFF_MAX ZIP_INT64_MAX +#define ZIP_OFF_MIN ZIP_INT64_MIN +#elif SIZEOF_OFF_T == 4 +#define ZIP_OFF_MAX ZIP_INT32_MAX +#define ZIP_OFF_MIN ZIP_INT32_MIN +#elif SIZEOF_OFF_T == 2 +#define ZIP_OFF_MAX ZIP_INT16_MAX +#define ZIP_OFF_MIN ZIP_INT16_MIN +#else +#error unsupported size of off_t +#endif + +#define ZIP_FSEEK_MAX ZIP_OFF_MAX +#define ZIP_FSEEK_MIN ZIP_OFF_MIN + +#define zip_os_fseek fseeko +#define zip_os_ftell ftello +#else + +/* Using long */ +typedef long zip_off_t; +#include +#define ZIP_FSEEK_MAX LONG_MAX +#define ZIP_FSEEK_MIN LONG_MIN + +#define zip_os_fseek fseek +#define zip_os_ftell ftell +#endif + +#endif + +#ifndef HAVE_FTELLO +#define ftello(s) ((long)ftell((s))) +#endif + + +#ifdef HAVE_LOCALTIME_S +#ifdef _WIN32 +/* Windows is incompatible to the C11 standard, hurray! */ +#define zip_localtime(t, tm) (localtime_s((tm), (t)) == 0 ? tm : NULL) +#else +#define zip_localtime localtime_s +#endif +#else +#ifdef HAVE_LOCALTIME_R +#define zip_localtime localtime_r +#else +#define zip_localtime(t, tm) (localtime(t)) +#endif +#endif + +#ifndef HAVE_MEMCPY_S +#define memcpy_s(dest, destsz, src, count) (memcpy((dest), (src), (count)) == NULL) +#endif + +#ifndef HAVE_SNPRINTF_S +#ifdef HAVE__SNPRINTF_S +#define snprintf_s(buf, bufsz, fmt, ...) (_snprintf_s((buf), (bufsz), (bufsz), (fmt), __VA_ARGS__)) +#else +#define snprintf_s snprintf +#endif +#endif + +#if !defined(HAVE_STRCASECMP) +#if defined(HAVE__STRICMP) +#define strcasecmp _stricmp +#elif defined(HAVE_STRICMP) +#define strcasecmp stricmp +#endif +#endif + +#ifndef HAVE_STRNCPY_S +#define strncpy_s(dest, destsz, src, count) (strncpy((dest), (src), (count)), 0) +#endif + +#ifndef HAVE_STRERROR_S +#define strerrorlen_s(errnum) (strlen(strerror(errnum))) +#define strerror_s(buf, bufsz, errnum) ((void)strncpy_s((buf), (bufsz), strerror(errnum), (bufsz)), (buf)[(bufsz)-1] = '\0', strerrorlen_s(errnum) >= (bufsz)) +#else +#ifndef HAVE_STRERRORLEN_S +#define strerrorlen_s(errnum) 8192 +#endif +#endif + + +#ifndef SIZE_MAX +#if SIZEOF_SIZE_T == 8 +#define SIZE_MAX ZIP_INT64_MAX +#elif SIZEOF_SIZE_T == 4 +#define SIZE_MAX ZIP_INT32_MAX +#elif SIZEOF_SIZE_T == 2 +#define SIZE_MAX ZIP_INT16_MAX +#else +#error unsupported size of size_t +#endif +#endif + +#ifndef PRId64 +#ifdef _MSC_VER +#define PRId64 "I64d" +#else +#define PRId64 "lld" +#endif +#endif + +#ifndef PRIu64 +#ifdef _MSC_VER +#define PRIu64 "I64u" +#else +#define PRIu64 "llu" +#endif +#endif + +#ifndef S_ISDIR +#define S_ISDIR(mode) (((mode)&S_IFMT) == S_IFDIR) +#endif + +#ifndef S_ISREG +#define S_ISREG(mode) (((mode)&S_IFMT) == S_IFREG) +#endif + +#endif /* compat.h */ diff --git a/thirdparty/libzip-1.11.3/lib/zip.h b/thirdparty/libzip-1.11.3/lib/zip.h new file mode 100644 index 0000000..c2a8a8b --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip.h @@ -0,0 +1,528 @@ +#ifndef _HAD_ZIP_H +#define _HAD_ZIP_H + +/* + zip.h -- exported declarations. + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#if defined(__has_feature) + #if !__has_feature(nullability) + #define _Nullable + #define _Nonnull + #endif +#else + #define _Nullable + #define _Nonnull +#endif + +#ifdef __cplusplus +extern "C" { +#if 0 +} /* fix autoindent */ +#endif +#endif + +#include + +#ifndef ZIP_EXTERN +#ifndef ZIP_STATIC +#ifdef _WIN32 +#define ZIP_EXTERN __declspec(dllimport) +#elif defined(__GNUC__) && __GNUC__ >= 4 +#define ZIP_EXTERN __attribute__((visibility("default"))) +#else +#define ZIP_EXTERN +#endif +#else +#define ZIP_EXTERN +#endif +#endif + +#ifndef ZIP_DEPRECATED +#if defined(__GNUC__) || defined(__clang__) +#define ZIP_DEPRECATED(x) __attribute__((deprecated(x))) +#elif defined(_MSC_VER) +#define ZIP_DEPRECATED(x) __declspec(deprecated(x)) +#else +#define ZIP_DEPRECATED(x) +#endif +#endif + +#include +#include +#include + +/* flags for zip_open */ + +#define ZIP_CREATE 1 +#define ZIP_EXCL 2 +#define ZIP_CHECKCONS 4 +#define ZIP_TRUNCATE 8 +#define ZIP_RDONLY 16 + + +/* flags for zip_name_locate, zip_fopen, zip_stat, ... */ + +#define ZIP_FL_NOCASE 1u /* ignore case on name lookup */ +#define ZIP_FL_NODIR 2u /* ignore directory component */ +#define ZIP_FL_COMPRESSED 4u /* read compressed data */ +#define ZIP_FL_UNCHANGED 8u /* use original data, ignoring changes */ +/* 16u was ZIP_FL_RECOMPRESS, which is deprecated */ +#define ZIP_FL_ENCRYPTED 32u /* read encrypted data (implies ZIP_FL_COMPRESSED) */ +#define ZIP_FL_ENC_GUESS 0u /* guess string encoding (is default) */ +#define ZIP_FL_ENC_RAW 64u /* get unmodified string */ +#define ZIP_FL_ENC_STRICT 128u /* follow specification strictly */ +#define ZIP_FL_LOCAL 256u /* in local header */ +#define ZIP_FL_CENTRAL 512u /* in central directory */ +/* 1024u reserved for internal use */ +#define ZIP_FL_ENC_UTF_8 2048u /* string is UTF-8 encoded */ +#define ZIP_FL_ENC_CP437 4096u /* string is CP437 encoded */ +#define ZIP_FL_OVERWRITE 8192u /* zip_file_add: if file with name exists, overwrite (replace) it */ + +/* archive global flags flags */ + +#define ZIP_AFL_RDONLY 2u /* read only -- cannot be cleared */ +#define ZIP_AFL_IS_TORRENTZIP 4u /* current archive is torrentzipped */ +#define ZIP_AFL_WANT_TORRENTZIP 8u /* write archive in torrentzip format */ +#define ZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE 16u /* don't remove file if archive is empty */ + + +/* create a new extra field */ + +#define ZIP_EXTRA_FIELD_ALL ZIP_UINT16_MAX +#define ZIP_EXTRA_FIELD_NEW ZIP_UINT16_MAX + +/* length parameter to various functions */ + +#define ZIP_LENGTH_TO_END 0 +#define ZIP_LENGTH_UNCHECKED (-2) /* only supported by zip_source_file and its variants */ + +/* libzip error codes */ + +#define ZIP_ER_OK 0 /* N No error */ +#define ZIP_ER_MULTIDISK 1 /* N Multi-disk zip archives not supported */ +#define ZIP_ER_RENAME 2 /* S Renaming temporary file failed */ +#define ZIP_ER_CLOSE 3 /* S Closing zip archive failed */ +#define ZIP_ER_SEEK 4 /* S Seek error */ +#define ZIP_ER_READ 5 /* S Read error */ +#define ZIP_ER_WRITE 6 /* S Write error */ +#define ZIP_ER_CRC 7 /* N CRC error */ +#define ZIP_ER_ZIPCLOSED 8 /* N Containing zip archive was closed */ +#define ZIP_ER_NOENT 9 /* N No such file */ +#define ZIP_ER_EXISTS 10 /* N File already exists */ +#define ZIP_ER_OPEN 11 /* S Can't open file */ +#define ZIP_ER_TMPOPEN 12 /* S Failure to create temporary file */ +#define ZIP_ER_ZLIB 13 /* Z Zlib error */ +#define ZIP_ER_MEMORY 14 /* N Malloc failure */ +#define ZIP_ER_CHANGED 15 /* N Entry has been changed */ +#define ZIP_ER_COMPNOTSUPP 16 /* N Compression method not supported */ +#define ZIP_ER_EOF 17 /* N Premature end of file */ +#define ZIP_ER_INVAL 18 /* N Invalid argument */ +#define ZIP_ER_NOZIP 19 /* N Not a zip archive */ +#define ZIP_ER_INTERNAL 20 /* N Internal error */ +#define ZIP_ER_INCONS 21 /* L Zip archive inconsistent */ +#define ZIP_ER_REMOVE 22 /* S Can't remove file */ +#define ZIP_ER_DELETED 23 /* N Entry has been deleted */ +#define ZIP_ER_ENCRNOTSUPP 24 /* N Encryption method not supported */ +#define ZIP_ER_RDONLY 25 /* N Read-only archive */ +#define ZIP_ER_NOPASSWD 26 /* N No password provided */ +#define ZIP_ER_WRONGPASSWD 27 /* N Wrong password provided */ +#define ZIP_ER_OPNOTSUPP 28 /* N Operation not supported */ +#define ZIP_ER_INUSE 29 /* N Resource still in use */ +#define ZIP_ER_TELL 30 /* S Tell error */ +#define ZIP_ER_COMPRESSED_DATA 31 /* N Compressed data invalid */ +#define ZIP_ER_CANCELLED 32 /* N Operation cancelled */ +#define ZIP_ER_DATA_LENGTH 33 /* N Unexpected length of data */ +#define ZIP_ER_NOT_ALLOWED 34 /* N Not allowed in torrentzip */ +#define ZIP_ER_TRUNCATED_ZIP 35 /* N Possibly truncated or corrupted zip archive */ + +/* type of system error value */ + +#define ZIP_ET_NONE 0 /* sys_err unused */ +#define ZIP_ET_SYS 1 /* sys_err is errno */ +#define ZIP_ET_ZLIB 2 /* sys_err is zlib error code */ +#define ZIP_ET_LIBZIP 3 /* sys_err is libzip error code */ + +/* compression methods */ + +#define ZIP_CM_DEFAULT -1 /* better of deflate or store */ +#define ZIP_CM_STORE 0 /* stored (uncompressed) */ +#define ZIP_CM_SHRINK 1 /* shrunk */ +#define ZIP_CM_REDUCE_1 2 /* reduced with factor 1 */ +#define ZIP_CM_REDUCE_2 3 /* reduced with factor 2 */ +#define ZIP_CM_REDUCE_3 4 /* reduced with factor 3 */ +#define ZIP_CM_REDUCE_4 5 /* reduced with factor 4 */ +#define ZIP_CM_IMPLODE 6 /* imploded */ +/* 7 - Reserved for Tokenizing compression algorithm */ +#define ZIP_CM_DEFLATE 8 /* deflated */ +#define ZIP_CM_DEFLATE64 9 /* deflate64 */ +#define ZIP_CM_PKWARE_IMPLODE 10 /* PKWARE imploding */ +/* 11 - Reserved by PKWARE */ +#define ZIP_CM_BZIP2 12 /* compressed using BZIP2 algorithm */ +/* 13 - Reserved by PKWARE */ +#define ZIP_CM_LZMA 14 /* LZMA (EFS) */ +/* 15-17 - Reserved by PKWARE */ +#define ZIP_CM_TERSE 18 /* compressed using IBM TERSE (new) */ +#define ZIP_CM_LZ77 19 /* IBM LZ77 z Architecture (PFS) */ +/* 20 - old value for Zstandard */ +#define ZIP_CM_LZMA2 33 +#define ZIP_CM_ZSTD 93 /* Zstandard compressed data */ +#define ZIP_CM_XZ 95 /* XZ compressed data */ +#define ZIP_CM_JPEG 96 /* Compressed Jpeg data */ +#define ZIP_CM_WAVPACK 97 /* WavPack compressed data */ +#define ZIP_CM_PPMD 98 /* PPMd version I, Rev 1 */ + +/* encryption methods */ + +#define ZIP_EM_NONE 0 /* not encrypted */ +#define ZIP_EM_TRAD_PKWARE 1 /* traditional PKWARE encryption */ +#if 0 /* Strong Encryption Header not parsed yet */ +#define ZIP_EM_DES 0x6601 /* strong encryption: DES */ +#define ZIP_EM_RC2_OLD 0x6602 /* strong encryption: RC2, version < 5.2 */ +#define ZIP_EM_3DES_168 0x6603 +#define ZIP_EM_3DES_112 0x6609 +#define ZIP_EM_PKZIP_AES_128 0x660e +#define ZIP_EM_PKZIP_AES_192 0x660f +#define ZIP_EM_PKZIP_AES_256 0x6610 +#define ZIP_EM_RC2 0x6702 /* strong encryption: RC2, version >= 5.2 */ +#define ZIP_EM_RC4 0x6801 +#endif +#define ZIP_EM_AES_128 0x0101 /* Winzip AES encryption */ +#define ZIP_EM_AES_192 0x0102 +#define ZIP_EM_AES_256 0x0103 +#define ZIP_EM_UNKNOWN 0xffff /* unknown algorithm */ + +#define ZIP_OPSYS_DOS 0x00u +#define ZIP_OPSYS_AMIGA 0x01u +#define ZIP_OPSYS_OPENVMS 0x02u +#define ZIP_OPSYS_UNIX 0x03u +#define ZIP_OPSYS_VM_CMS 0x04u +#define ZIP_OPSYS_ATARI_ST 0x05u +#define ZIP_OPSYS_OS_2 0x06u +#define ZIP_OPSYS_MACINTOSH 0x07u +#define ZIP_OPSYS_Z_SYSTEM 0x08u +#define ZIP_OPSYS_CPM 0x09u +#define ZIP_OPSYS_WINDOWS_NTFS 0x0au +#define ZIP_OPSYS_MVS 0x0bu +#define ZIP_OPSYS_VSE 0x0cu +#define ZIP_OPSYS_ACORN_RISC 0x0du +#define ZIP_OPSYS_VFAT 0x0eu +#define ZIP_OPSYS_ALTERNATE_MVS 0x0fu +#define ZIP_OPSYS_BEOS 0x10u +#define ZIP_OPSYS_TANDEM 0x11u +#define ZIP_OPSYS_OS_400 0x12u +#define ZIP_OPSYS_OS_X 0x13u + +#define ZIP_OPSYS_DEFAULT ZIP_OPSYS_UNIX + + +enum zip_source_cmd { + ZIP_SOURCE_OPEN, /* prepare for reading */ + ZIP_SOURCE_READ, /* read data */ + ZIP_SOURCE_CLOSE, /* reading is done */ + ZIP_SOURCE_STAT, /* get meta information */ + ZIP_SOURCE_ERROR, /* get error information */ + ZIP_SOURCE_FREE, /* cleanup and free resources */ + ZIP_SOURCE_SEEK, /* set position for reading */ + ZIP_SOURCE_TELL, /* get read position */ + ZIP_SOURCE_BEGIN_WRITE, /* prepare for writing */ + ZIP_SOURCE_COMMIT_WRITE, /* writing is done */ + ZIP_SOURCE_ROLLBACK_WRITE, /* discard written changes */ + ZIP_SOURCE_WRITE, /* write data */ + ZIP_SOURCE_SEEK_WRITE, /* set position for writing */ + ZIP_SOURCE_TELL_WRITE, /* get write position */ + ZIP_SOURCE_SUPPORTS, /* check whether source supports command */ + ZIP_SOURCE_REMOVE, /* remove file */ + ZIP_SOURCE_RESERVED_1, /* previously used internally */ + ZIP_SOURCE_BEGIN_WRITE_CLONING, /* like ZIP_SOURCE_BEGIN_WRITE, but keep part of original file */ + ZIP_SOURCE_ACCEPT_EMPTY, /* whether empty files are valid archives */ + ZIP_SOURCE_GET_FILE_ATTRIBUTES, /* get additional file attributes */ + ZIP_SOURCE_SUPPORTS_REOPEN, /* allow reading from changed entry */ + ZIP_SOURCE_GET_DOS_TIME /* get last modification time in DOS format */ +}; +typedef enum zip_source_cmd zip_source_cmd_t; + +#define ZIP_SOURCE_MAKE_COMMAND_BITMASK(cmd) (((zip_int64_t)1) << (cmd)) + +#define ZIP_SOURCE_CHECK_SUPPORTED(supported, cmd) (((supported) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(cmd)) != 0) + +/* clang-format off */ + +#define ZIP_SOURCE_SUPPORTS_READABLE (ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_OPEN) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_READ) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_CLOSE) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_STAT) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ERROR) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_FREE)) + +#define ZIP_SOURCE_SUPPORTS_SEEKABLE (ZIP_SOURCE_SUPPORTS_READABLE \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_TELL) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SUPPORTS)) + +#define ZIP_SOURCE_SUPPORTS_WRITABLE (ZIP_SOURCE_SUPPORTS_SEEKABLE \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_BEGIN_WRITE) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_COMMIT_WRITE) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ROLLBACK_WRITE) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_WRITE) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK_WRITE) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_TELL_WRITE) \ + | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_REMOVE)) + +/* clang-format on */ + +/* for use by sources */ +struct zip_source_args_seek { + zip_int64_t offset; + int whence; +}; + +typedef struct zip_source_args_seek zip_source_args_seek_t; +#define ZIP_SOURCE_GET_ARGS(type, data, len, error) ((len) < sizeof(type) ? zip_error_set((error), ZIP_ER_INVAL, 0), (type *)NULL : (type *)(data)) + + +/* error information */ +/* use zip_error_*() to access */ +struct zip_error { + int zip_err; /* libzip error code (ZIP_ER_*) */ + int sys_err; /* copy of errno (E*) or zlib error code */ + char *_Nullable str; /* string representation or NULL */ +}; + +#define ZIP_STAT_NAME 0x0001u +#define ZIP_STAT_INDEX 0x0002u +#define ZIP_STAT_SIZE 0x0004u +#define ZIP_STAT_COMP_SIZE 0x0008u +#define ZIP_STAT_MTIME 0x0010u +#define ZIP_STAT_CRC 0x0020u +#define ZIP_STAT_COMP_METHOD 0x0040u +#define ZIP_STAT_ENCRYPTION_METHOD 0x0080u +#define ZIP_STAT_FLAGS 0x0100u + +struct zip_stat { + zip_uint64_t valid; /* which fields have valid values */ + const char *_Nullable name; /* name of the file */ + zip_uint64_t index; /* index within archive */ + zip_uint64_t size; /* size of file (uncompressed) */ + zip_uint64_t comp_size; /* size of file (compressed) */ + time_t mtime; /* modification time */ + zip_uint32_t crc; /* crc of file data */ + zip_uint16_t comp_method; /* compression method used */ + zip_uint16_t encryption_method; /* encryption method used */ + zip_uint32_t flags; /* reserved for future use */ +}; + +struct zip_buffer_fragment { + zip_uint8_t *_Nonnull data; + zip_uint64_t length; +}; + +struct zip_file_attributes { + zip_uint64_t valid; /* which fields have valid values */ + zip_uint8_t version; /* version of this struct, currently 1 */ + zip_uint8_t host_system; /* host system on which file was created */ + zip_uint8_t ascii; /* flag whether file is ASCII text */ + zip_uint8_t version_needed; /* minimum version needed to extract file */ + zip_uint32_t external_file_attributes; /* external file attributes (host-system specific) */ + zip_uint16_t general_purpose_bit_flags; /* general purpose big flags, only some bits are honored */ + zip_uint16_t general_purpose_bit_mask; /* which bits in general_purpose_bit_flags are valid */ +}; + +#define ZIP_FILE_ATTRIBUTES_HOST_SYSTEM 0x0001u +#define ZIP_FILE_ATTRIBUTES_ASCII 0x0002u +#define ZIP_FILE_ATTRIBUTES_VERSION_NEEDED 0x0004u +#define ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES 0x0008u +#define ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS 0x0010u + +struct zip; +struct zip_file; +struct zip_source; + +typedef struct zip zip_t; +typedef struct zip_error zip_error_t; +typedef struct zip_file zip_file_t; +typedef struct zip_file_attributes zip_file_attributes_t; +typedef struct zip_source zip_source_t; +typedef struct zip_stat zip_stat_t; +typedef struct zip_buffer_fragment zip_buffer_fragment_t; + +typedef zip_uint32_t zip_flags_t; + +typedef zip_int64_t (*zip_source_callback)(void *_Nullable, void *_Nullable, zip_uint64_t, zip_source_cmd_t); +typedef zip_int64_t (*zip_source_layered_callback)(zip_source_t *_Nonnull, void *_Nullable, void *_Nullable, zip_uint64_t, enum zip_source_cmd); +typedef void (*zip_progress_callback)(zip_t *_Nonnull, double, void *_Nullable); +typedef int (*zip_cancel_callback)(zip_t *_Nonnull, void *_Nullable); + +#ifndef ZIP_DISABLE_DEPRECATED +#define ZIP_FL_RECOMPRESS 16u /* force recompression of data */ + +typedef void (*zip_progress_callback_t)(double); +ZIP_DEPRECATED("use 'zip_register_progress_callback_with_state' instead") ZIP_EXTERN void zip_register_progress_callback(zip_t *_Nonnull, zip_progress_callback_t _Nullable); + +ZIP_DEPRECATED("use 'zip_file_add' instead") ZIP_EXTERN zip_int64_t zip_add(zip_t *_Nonnull, const char *_Nonnull, zip_source_t *_Nonnull); +ZIP_DEPRECATED("use 'zip_dir_add' instead") ZIP_EXTERN zip_int64_t zip_add_dir(zip_t *_Nonnull, const char *_Nonnull); +ZIP_DEPRECATED("use 'zip_file_get_comment' instead") ZIP_EXTERN const char *_Nullable zip_get_file_comment(zip_t *_Nonnull, zip_uint64_t, int *_Nullable, int); +ZIP_DEPRECATED("use 'zip_get_num_entries' instead") ZIP_EXTERN int zip_get_num_files(zip_t *_Nonnull); +ZIP_DEPRECATED("use 'zip_file_rename' instead") ZIP_EXTERN int zip_rename(zip_t *_Nonnull, zip_uint64_t, const char *_Nonnull); +ZIP_DEPRECATED("use 'zip_file_replace' instead") ZIP_EXTERN int zip_replace(zip_t *_Nonnull, zip_uint64_t, zip_source_t *_Nonnull); +ZIP_DEPRECATED("use 'zip_file_set_comment' instead") ZIP_EXTERN int zip_set_file_comment(zip_t *_Nonnull, zip_uint64_t, const char *_Nullable, int); +ZIP_DEPRECATED("use 'zip_error_init_with_code' and 'zip_error_system_type' instead") ZIP_EXTERN int zip_error_get_sys_type(int); +ZIP_DEPRECATED("use 'zip_get_error' instead") ZIP_EXTERN void zip_error_get(zip_t *_Nonnull, int *_Nullable, int *_Nullable); +ZIP_DEPRECATED("use 'zip_error_strerror' instead") ZIP_EXTERN int zip_error_to_str(char *_Nonnull, zip_uint64_t, int, int); +ZIP_DEPRECATED("use 'zip_file_get_error' instead") ZIP_EXTERN void zip_file_error_get(zip_file_t *_Nonnull, int *_Nullable, int *_Nullable); +ZIP_DEPRECATED("use 'zip_source_zip_file' instead") ZIP_EXTERN zip_source_t *_Nullable zip_source_zip(zip_t *_Nonnull, zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_int64_t); +ZIP_DEPRECATED("use 'zip_source_zip_file_create' instead") ZIP_EXTERN zip_source_t *_Nullable zip_source_zip_create(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable); +#endif + +ZIP_EXTERN int zip_close(zip_t *_Nonnull); +ZIP_EXTERN int zip_delete(zip_t *_Nonnull, zip_uint64_t); +ZIP_EXTERN zip_int64_t zip_dir_add(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t); +ZIP_EXTERN void zip_discard(zip_t *_Nonnull); + +ZIP_EXTERN zip_error_t *_Nonnull zip_get_error(zip_t *_Nonnull); +ZIP_EXTERN void zip_error_clear(zip_t *_Nonnull); +ZIP_EXTERN int zip_error_code_zip(const zip_error_t *_Nonnull); +ZIP_EXTERN int zip_error_code_system(const zip_error_t *_Nonnull); +ZIP_EXTERN void zip_error_fini(zip_error_t *_Nonnull); +ZIP_EXTERN void zip_error_init(zip_error_t *_Nonnull); +ZIP_EXTERN void zip_error_init_with_code(zip_error_t *_Nonnull, int); +ZIP_EXTERN void zip_error_set(zip_error_t *_Nullable, int, int); +ZIP_EXTERN void zip_error_set_from_source(zip_error_t *_Nonnull, zip_source_t *_Nullable); +ZIP_EXTERN const char *_Nonnull zip_error_strerror(zip_error_t *_Nonnull); +ZIP_EXTERN int zip_error_system_type(const zip_error_t *_Nonnull); +ZIP_EXTERN zip_int64_t zip_error_to_data(const zip_error_t *_Nonnull, void *_Nonnull, zip_uint64_t); + +ZIP_EXTERN int zip_fclose(zip_file_t *_Nonnull); +ZIP_EXTERN zip_t *_Nullable zip_fdopen(int, int, int *_Nullable); +ZIP_EXTERN zip_int64_t zip_file_add(zip_t *_Nonnull, const char *_Nonnull, zip_source_t *_Nonnull, zip_flags_t); +ZIP_EXTERN void zip_file_attributes_init(zip_file_attributes_t *_Nonnull); +ZIP_EXTERN void zip_file_error_clear(zip_file_t *_Nonnull); +ZIP_EXTERN int zip_file_extra_field_delete(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_flags_t); +ZIP_EXTERN int zip_file_extra_field_delete_by_id(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_flags_t); +ZIP_EXTERN int zip_file_extra_field_set(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, const zip_uint8_t *_Nullable, zip_uint16_t, zip_flags_t); +ZIP_EXTERN zip_int16_t zip_file_extra_fields_count(zip_t *_Nonnull, zip_uint64_t, zip_flags_t); +ZIP_EXTERN zip_int16_t zip_file_extra_fields_count_by_id(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_flags_t); +ZIP_EXTERN const zip_uint8_t *_Nullable zip_file_extra_field_get(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t *_Nullable, zip_uint16_t *_Nullable, zip_flags_t); +ZIP_EXTERN const zip_uint8_t *_Nullable zip_file_extra_field_get_by_id(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_uint16_t *_Nullable, zip_flags_t); +ZIP_EXTERN const char *_Nullable zip_file_get_comment(zip_t *_Nonnull, zip_uint64_t, zip_uint32_t *_Nullable, zip_flags_t); +ZIP_EXTERN zip_error_t *_Nonnull zip_file_get_error(zip_file_t *_Nonnull); +ZIP_EXTERN int zip_file_get_external_attributes(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint8_t *_Nullable, zip_uint32_t *_Nullable); +ZIP_EXTERN int zip_file_is_seekable(zip_file_t *_Nonnull); +ZIP_EXTERN int zip_file_rename(zip_t *_Nonnull, zip_uint64_t, const char *_Nonnull, zip_flags_t); +ZIP_EXTERN int zip_file_replace(zip_t *_Nonnull, zip_uint64_t, zip_source_t *_Nonnull, zip_flags_t); +ZIP_EXTERN int zip_file_set_comment(zip_t *_Nonnull, zip_uint64_t, const char *_Nullable, zip_uint16_t, zip_flags_t); +ZIP_EXTERN int zip_file_set_dostime(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_flags_t); +ZIP_EXTERN int zip_file_set_encryption(zip_t *_Nonnull, zip_uint64_t, zip_uint16_t, const char *_Nullable); +ZIP_EXTERN int zip_file_set_external_attributes(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint8_t, zip_uint32_t); +ZIP_EXTERN int zip_file_set_mtime(zip_t *_Nonnull, zip_uint64_t, time_t, zip_flags_t); +ZIP_EXTERN const char *_Nonnull zip_file_strerror(zip_file_t *_Nonnull); +ZIP_EXTERN zip_file_t *_Nullable zip_fopen(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t); +ZIP_EXTERN zip_file_t *_Nullable zip_fopen_encrypted(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t, const char *_Nullable); +ZIP_EXTERN zip_file_t *_Nullable zip_fopen_index(zip_t *_Nonnull, zip_uint64_t, zip_flags_t); +ZIP_EXTERN zip_file_t *_Nullable zip_fopen_index_encrypted(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, const char *_Nullable); +ZIP_EXTERN zip_int64_t zip_fread(zip_file_t *_Nonnull, void *_Nonnull, zip_uint64_t); +ZIP_EXTERN zip_int8_t zip_fseek(zip_file_t *_Nonnull, zip_int64_t, int); +ZIP_EXTERN zip_int64_t zip_ftell(zip_file_t *_Nonnull); +ZIP_EXTERN const char *_Nullable zip_get_archive_comment(zip_t *_Nonnull, int *_Nullable, zip_flags_t); +ZIP_EXTERN int zip_get_archive_flag(zip_t *_Nonnull, zip_flags_t, zip_flags_t); +ZIP_EXTERN const char *_Nullable zip_get_name(zip_t *_Nonnull, zip_uint64_t, zip_flags_t); +ZIP_EXTERN zip_int64_t zip_get_num_entries(zip_t *_Nonnull, zip_flags_t); +ZIP_EXTERN const char *_Nonnull zip_libzip_version(void); +ZIP_EXTERN zip_int64_t zip_name_locate(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t); +ZIP_EXTERN zip_t *_Nullable zip_open(const char *_Nonnull, int, int *_Nullable); +ZIP_EXTERN zip_t *_Nullable zip_open_from_source(zip_source_t *_Nonnull, int, zip_error_t *_Nullable); +ZIP_EXTERN int zip_register_progress_callback_with_state(zip_t *_Nonnull, double, zip_progress_callback _Nullable, void (*_Nullable)(void *_Nullable), void *_Nullable); +ZIP_EXTERN int zip_register_cancel_callback_with_state(zip_t *_Nonnull, zip_cancel_callback _Nullable, void (*_Nullable)(void *_Nullable), void *_Nullable); +ZIP_EXTERN int zip_set_archive_comment(zip_t *_Nonnull, const char *_Nullable, zip_uint16_t); +ZIP_EXTERN int zip_set_archive_flag(zip_t *_Nonnull, zip_flags_t, int); +ZIP_EXTERN int zip_set_default_password(zip_t *_Nonnull, const char *_Nullable); +ZIP_EXTERN int zip_set_file_compression(zip_t *_Nonnull, zip_uint64_t, zip_int32_t, zip_uint32_t); +ZIP_EXTERN int zip_source_begin_write(zip_source_t *_Nonnull); +ZIP_EXTERN int zip_source_begin_write_cloning(zip_source_t *_Nonnull, zip_uint64_t); +ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer(zip_t *_Nonnull, const void *_Nullable, zip_uint64_t, int); +ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_create(const void *_Nullable, zip_uint64_t, int, zip_error_t *_Nullable); +ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_fragment(zip_t *_Nonnull, const zip_buffer_fragment_t *_Nonnull, zip_uint64_t, int); +ZIP_EXTERN zip_source_t *_Nullable zip_source_buffer_fragment_create(const zip_buffer_fragment_t *_Nullable, zip_uint64_t, int, zip_error_t *_Nullable); +ZIP_EXTERN int zip_source_close(zip_source_t *_Nonnull); +ZIP_EXTERN int zip_source_commit_write(zip_source_t *_Nonnull); +ZIP_EXTERN zip_error_t *_Nonnull zip_source_error(zip_source_t *_Nonnull); +ZIP_EXTERN zip_source_t *_Nullable zip_source_file(zip_t *_Nonnull, const char *_Nonnull, zip_uint64_t, zip_int64_t); +ZIP_EXTERN zip_source_t *_Nullable zip_source_file_create(const char *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable); +ZIP_EXTERN zip_source_t *_Nullable zip_source_filep(zip_t *_Nonnull, FILE *_Nonnull, zip_uint64_t, zip_int64_t); +ZIP_EXTERN zip_source_t *_Nullable zip_source_filep_create(FILE *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable); +ZIP_EXTERN void zip_source_free(zip_source_t *_Nullable); +ZIP_EXTERN zip_source_t *_Nullable zip_source_function(zip_t *_Nonnull, zip_source_callback _Nonnull, void *_Nullable); +ZIP_EXTERN zip_source_t *_Nullable zip_source_function_create(zip_source_callback _Nonnull, void *_Nullable, zip_error_t *_Nullable); +ZIP_EXTERN int zip_source_get_file_attributes(zip_source_t *_Nonnull, zip_file_attributes_t *_Nonnull); +ZIP_EXTERN int zip_source_is_deleted(zip_source_t *_Nonnull); +ZIP_EXTERN int zip_source_is_seekable(zip_source_t *_Nonnull); +ZIP_EXTERN void zip_source_keep(zip_source_t *_Nonnull); +ZIP_EXTERN zip_source_t *_Nullable zip_source_layered(zip_t *_Nullable, zip_source_t *_Nonnull, zip_source_layered_callback _Nonnull, void *_Nullable); +ZIP_EXTERN zip_source_t *_Nullable zip_source_layered_create(zip_source_t *_Nonnull, zip_source_layered_callback _Nonnull, void *_Nullable, zip_error_t *_Nullable); +ZIP_EXTERN zip_int64_t zip_source_make_command_bitmap(zip_source_cmd_t, ...); +ZIP_EXTERN int zip_source_open(zip_source_t *_Nonnull); +ZIP_EXTERN zip_int64_t zip_source_pass_to_lower_layer(zip_source_t *_Nonnull, void *_Nullable, zip_uint64_t, zip_source_cmd_t); +ZIP_EXTERN zip_int64_t zip_source_read(zip_source_t *_Nonnull, void *_Nonnull, zip_uint64_t); +ZIP_EXTERN void zip_source_rollback_write(zip_source_t *_Nonnull); +ZIP_EXTERN int zip_source_seek(zip_source_t *_Nonnull, zip_int64_t, int); +ZIP_EXTERN zip_int64_t zip_source_seek_compute_offset(zip_uint64_t, zip_uint64_t, void *_Nonnull, zip_uint64_t, zip_error_t *_Nullable); +ZIP_EXTERN int zip_source_seek_write(zip_source_t *_Nonnull, zip_int64_t, int); +ZIP_EXTERN int zip_source_stat(zip_source_t *_Nonnull, zip_stat_t *_Nonnull); +ZIP_EXTERN zip_int64_t zip_source_tell(zip_source_t *_Nonnull); +ZIP_EXTERN zip_int64_t zip_source_tell_write(zip_source_t *_Nonnull); +#ifdef _WIN32 +ZIP_EXTERN zip_source_t *_Nullable zip_source_win32a(zip_t *_Nonnull, const char *_Nonnull, zip_uint64_t, zip_int64_t); +ZIP_EXTERN zip_source_t *_Nullable zip_source_win32a_create(const char *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable); +ZIP_EXTERN zip_source_t *_Nullable zip_source_win32handle(zip_t *_Nonnull, void *_Nonnull, zip_uint64_t, zip_int64_t); +ZIP_EXTERN zip_source_t *_Nullable zip_source_win32handle_create(void *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable); +ZIP_EXTERN zip_source_t *_Nullable zip_source_win32w(zip_t *_Nonnull, const wchar_t *_Nonnull, zip_uint64_t, zip_int64_t); +ZIP_EXTERN zip_source_t *_Nullable zip_source_win32w_create(const wchar_t *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable); +#endif +ZIP_EXTERN zip_source_t *_Nullable zip_source_window_create(zip_source_t *_Nonnull, zip_uint64_t, zip_int64_t, zip_error_t *_Nullable); +ZIP_EXTERN zip_int64_t zip_source_write(zip_source_t *_Nonnull, const void *_Nullable, zip_uint64_t); +ZIP_EXTERN zip_source_t *_Nullable zip_source_zip_file(zip_t *_Nonnull, zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_int64_t, const char *_Nullable); +ZIP_EXTERN zip_source_t *_Nullable zip_source_zip_file_create(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_uint64_t, zip_int64_t, const char *_Nullable, zip_error_t *_Nullable); +ZIP_EXTERN int zip_stat(zip_t *_Nonnull, const char *_Nonnull, zip_flags_t, zip_stat_t *_Nonnull); +ZIP_EXTERN int zip_stat_index(zip_t *_Nonnull, zip_uint64_t, zip_flags_t, zip_stat_t *_Nonnull); +ZIP_EXTERN void zip_stat_init(zip_stat_t *_Nonnull); +ZIP_EXTERN const char *_Nonnull zip_strerror(zip_t *_Nonnull); +ZIP_EXTERN int zip_unchange(zip_t *_Nonnull, zip_uint64_t); +ZIP_EXTERN int zip_unchange_all(zip_t *_Nonnull); +ZIP_EXTERN int zip_unchange_archive(zip_t *_Nonnull); +ZIP_EXTERN int zip_compression_method_supported(zip_int32_t method, int compress); +ZIP_EXTERN int zip_encryption_method_supported(zip_uint16_t method, int encode); + +#ifdef __cplusplus +} +#endif + +#endif /* _HAD_ZIP_H */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_add.c b/thirdparty/libzip-1.11.3/lib/zip_add.c new file mode 100644 index 0000000..a426a57 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_add.c @@ -0,0 +1,49 @@ +/* + zip_add.c -- add file via callback function + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#define _ZIP_COMPILING_DEPRECATED +#include "zipint.h" + + +/* + NOTE: Return type is signed so we can return -1 on error. + The index can not be larger than ZIP_INT64_MAX since the size + of the central directory cannot be larger than + ZIP_UINT64_MAX, and each entry is larger than 2 bytes. +*/ + +ZIP_EXTERN zip_int64_t +zip_add(zip_t *za, const char *name, zip_source_t *source) { + return zip_file_add(za, name, source, 0); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_add_dir.c b/thirdparty/libzip-1.11.3/lib/zip_add_dir.c new file mode 100644 index 0000000..2faaa1a --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_add_dir.c @@ -0,0 +1,44 @@ +/* + zip_add_dir.c -- add directory + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#define _ZIP_COMPILING_DEPRECATED +#include "zipint.h" + + +/* NOTE: Signed due to -1 on error. See zip_add.c for more details. */ + +ZIP_EXTERN zip_int64_t +zip_add_dir(zip_t *za, const char *name) { + return zip_dir_add(za, name, 0); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_add_entry.c b/thirdparty/libzip-1.11.3/lib/zip_add_entry.c new file mode 100644 index 0000000..e8beaa8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_add_entry.c @@ -0,0 +1,80 @@ +/* + zip_add_entry.c -- create and init struct zip_entry + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +/* NOTE: Signed due to -1 on error. See zip_add.c for more details. */ + +zip_int64_t +_zip_add_entry(zip_t *za) { + zip_uint64_t idx; + + if (za->nentry + 1 >= za->nentry_alloc) { + zip_entry_t *rentries; + zip_uint64_t nalloc = za->nentry_alloc; + zip_uint64_t additional_entries = 2 * nalloc; + zip_uint64_t realloc_size; + + if (additional_entries < 16) { + additional_entries = 16; + } + else if (additional_entries > 1024) { + additional_entries = 1024; + } + /* neither + nor * overflows can happen: nentry_alloc * sizeof(struct zip_entry) < UINT64_MAX */ + nalloc += additional_entries; + realloc_size = sizeof(struct zip_entry) * (size_t)nalloc; + + if (sizeof(struct zip_entry) * (size_t)za->nentry_alloc > realloc_size) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + rentries = (zip_entry_t *)realloc(za->entry, sizeof(struct zip_entry) * (size_t)nalloc); + if (rentries == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + za->entry = rentries; + za->nentry_alloc = nalloc; + } + + idx = za->nentry++; + + _zip_entry_init(za->entry + idx); + + return (zip_int64_t)idx; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_algorithm_bzip2.c b/thirdparty/libzip-1.11.3/lib/zip_algorithm_bzip2.c new file mode 100644 index 0000000..d5311a7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_algorithm_bzip2.c @@ -0,0 +1,293 @@ +/* + zip_algorithm_bzip2.c -- bzip2 (de)compression routines + Copyright (C) 2017-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +#include +#include +#include + +struct ctx { + zip_error_t *error; + bool compress; + int compression_flags; + bool end_of_input; + bz_stream zstr; +}; + + +static zip_uint64_t +maximum_compressed_size(zip_uint64_t uncompressed_size) { + zip_uint64_t compressed_size = (zip_uint64_t)((double)uncompressed_size * 1.006); + + if (compressed_size < uncompressed_size) { + return ZIP_UINT64_MAX; + } + return compressed_size; +} + + +static void * +allocate(bool compress, zip_uint32_t compression_flags, zip_error_t *error) { + struct ctx *ctx; + + if ((ctx = (struct ctx *)malloc(sizeof(*ctx))) == NULL) { + return NULL; + } + + ctx->error = error; + ctx->compress = compress; + if (compression_flags >= 1 && compression_flags <= 9) { + ctx->compression_flags = (int)compression_flags; + } + else { + ctx->compression_flags = 9; + } + ctx->end_of_input = false; + + ctx->zstr.bzalloc = NULL; + ctx->zstr.bzfree = NULL; + ctx->zstr.opaque = NULL; + + return ctx; +} + + +static void * +compress_allocate(zip_uint16_t method, zip_uint32_t compression_flags, zip_error_t *error) { + (void)method; + return allocate(true, compression_flags, error); +} + + +static void * +decompress_allocate(zip_uint16_t method, zip_uint32_t compression_flags, zip_error_t *error) { + (void)method; + return allocate(false, compression_flags, error); +} + + +static void +deallocate(void *ud) { + struct ctx *ctx = (struct ctx *)ud; + + free(ctx); +} + + +static zip_uint16_t +general_purpose_bit_flags(void *ud) { + (void)ud; + return 0; +} + + +static int +map_error(int ret) { + switch (ret) { + case BZ_FINISH_OK: + case BZ_FLUSH_OK: + case BZ_OK: + case BZ_RUN_OK: + case BZ_STREAM_END: + return ZIP_ER_OK; + + case BZ_DATA_ERROR: + case BZ_DATA_ERROR_MAGIC: + case BZ_UNEXPECTED_EOF: + return ZIP_ER_COMPRESSED_DATA; + + case BZ_MEM_ERROR: + return ZIP_ER_MEMORY; + + case BZ_PARAM_ERROR: + return ZIP_ER_INVAL; + + case BZ_CONFIG_ERROR: /* actually, bzip2 miscompiled */ + case BZ_IO_ERROR: + case BZ_OUTBUFF_FULL: + case BZ_SEQUENCE_ERROR: + default: + return ZIP_ER_INTERNAL; + } +} + +static bool +start(void *ud, zip_stat_t *st, zip_file_attributes_t *attributes) { + struct ctx *ctx = (struct ctx *)ud; + int ret; + + (void)st; + (void)attributes; + + ctx->zstr.avail_in = 0; + ctx->zstr.next_in = NULL; + ctx->zstr.avail_out = 0; + ctx->zstr.next_out = NULL; + + if (ctx->compress) { + ret = BZ2_bzCompressInit(&ctx->zstr, ctx->compression_flags, 0, 30); + } + else { + ret = BZ2_bzDecompressInit(&ctx->zstr, 0, 0); + } + + if (ret != BZ_OK) { + zip_error_set(ctx->error, map_error(ret), 0); + return false; + } + + return true; +} + + +static bool +end(void *ud) { + struct ctx *ctx = (struct ctx *)ud; + int err; + + if (ctx->compress) { + err = BZ2_bzCompressEnd(&ctx->zstr); + } + else { + err = BZ2_bzDecompressEnd(&ctx->zstr); + } + + if (err != BZ_OK) { + zip_error_set(ctx->error, map_error(err), 0); + return false; + } + + return true; +} + + +static bool +input(void *ud, zip_uint8_t *data, zip_uint64_t length) { + struct ctx *ctx = (struct ctx *)ud; + + if (length > UINT_MAX || ctx->zstr.avail_in > 0) { + zip_error_set(ctx->error, ZIP_ER_INVAL, 0); + return false; + } + + ctx->zstr.avail_in = (unsigned int)length; + ctx->zstr.next_in = (char *)data; + + return true; +} + + +static bool end_of_input(void *ud) { + struct ctx *ctx = (struct ctx *)ud; + + ctx->end_of_input = true; + return ctx->zstr.avail_in != 0; +} + + +static zip_compression_status_t +process(void *ud, zip_uint8_t *data, zip_uint64_t *length) { + struct ctx *ctx = (struct ctx *)ud; + unsigned int avail_out; + + int ret; + + if (ctx->zstr.avail_in == 0 && !ctx->end_of_input) { + *length = 0; + return ZIP_COMPRESSION_NEED_DATA; + } + + avail_out = (unsigned int)ZIP_MIN(UINT_MAX, *length); + ctx->zstr.avail_out = avail_out; + ctx->zstr.next_out = (char *)data; + + if (ctx->compress) { + ret = BZ2_bzCompress(&ctx->zstr, ctx->end_of_input ? BZ_FINISH : BZ_RUN); + } + else { + ret = BZ2_bzDecompress(&ctx->zstr); + } + + *length = avail_out - ctx->zstr.avail_out; + + switch (ret) { + case BZ_FINISH_OK: /* compression */ + return ZIP_COMPRESSION_OK; + + case BZ_OK: /* decompression */ + case BZ_RUN_OK: /* compression */ + if (ctx->zstr.avail_in == 0) { + return ZIP_COMPRESSION_NEED_DATA; + } + return ZIP_COMPRESSION_OK; + + case BZ_STREAM_END: + return ZIP_COMPRESSION_END; + + default: + zip_error_set(ctx->error, map_error(ret), 0); + return ZIP_COMPRESSION_ERROR; + } +} + +/* clang-format off */ + +zip_compression_algorithm_t zip_algorithm_bzip2_compress = { + maximum_compressed_size, + compress_allocate, + deallocate, + general_purpose_bit_flags, + 46, + start, + end, + input, + end_of_input, + process +}; + + +zip_compression_algorithm_t zip_algorithm_bzip2_decompress = { + maximum_compressed_size, + decompress_allocate, + deallocate, + general_purpose_bit_flags, + 46, + start, + end, + input, + end_of_input, + process +}; + +/* clang-format on */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_algorithm_deflate.c b/thirdparty/libzip-1.11.3/lib/zip_algorithm_deflate.c new file mode 100644 index 0000000..402b7e8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_algorithm_deflate.c @@ -0,0 +1,276 @@ +/* + zip_algorithm_deflate.c -- deflate (de)compression routines + Copyright (C) 2017-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +#include +#include +#include + +struct ctx { + zip_error_t *error; + bool compress; + int level; + int mem_level; + bool end_of_input; + z_stream zstr; +}; + + +static zip_uint64_t +maximum_compressed_size(zip_uint64_t uncompressed_size) { + /* max deflate size increase: size + ceil(size/16k)*5+6 */ + + zip_uint64_t compressed_size = uncompressed_size + (uncompressed_size + 16383) / 16384 * 5 + 6; + + if (compressed_size < uncompressed_size) { + return ZIP_UINT64_MAX; + } + return compressed_size; +} + + +static void * +allocate(bool compress, zip_uint32_t compression_flags, zip_error_t *error) { + struct ctx *ctx; + + if ((ctx = (struct ctx *)malloc(sizeof(*ctx))) == NULL) { + zip_error_set(error, ZIP_ET_SYS, errno); + return NULL; + } + + ctx->error = error; + ctx->compress = compress; + if (compression_flags >= 1 && compression_flags <= 9) { + ctx->level = (int)compression_flags; + } + else { + ctx->level = Z_BEST_COMPRESSION; + } + ctx->mem_level = compression_flags == TORRENTZIP_COMPRESSION_FLAGS ? TORRENTZIP_MEM_LEVEL : MAX_MEM_LEVEL; + ctx->end_of_input = false; + + ctx->zstr.zalloc = Z_NULL; + ctx->zstr.zfree = Z_NULL; + ctx->zstr.opaque = NULL; + + return ctx; +} + + +static void * +compress_allocate(zip_uint16_t method, zip_uint32_t compression_flags, zip_error_t *error) { + (void)method; + return allocate(true, compression_flags, error); +} + + +static void * +decompress_allocate(zip_uint16_t method, zip_uint32_t compression_flags, zip_error_t *error) { + (void)method; + return allocate(false, compression_flags, error); +} + + +static void +deallocate(void *ud) { + struct ctx *ctx = (struct ctx *)ud; + + free(ctx); +} + + +static zip_uint16_t +general_purpose_bit_flags(void *ud) { + struct ctx *ctx = (struct ctx *)ud; + + if (!ctx->compress) { + return 0; + } + + if (ctx->level < 3) { + return 2 << 1; + } + else if (ctx->level > 7) { + return 1 << 1; + } + return 0; +} + + +static bool +start(void *ud, zip_stat_t *st, zip_file_attributes_t *attributes) { + struct ctx *ctx = (struct ctx *)ud; + int ret; + + (void)st; + (void)attributes; + + ctx->zstr.avail_in = 0; + ctx->zstr.next_in = NULL; + ctx->zstr.avail_out = 0; + ctx->zstr.next_out = NULL; + + if (ctx->compress) { + /* negative value to tell zlib not to write a header */ + ret = deflateInit2(&ctx->zstr, ctx->level, Z_DEFLATED, -MAX_WBITS, ctx->mem_level, Z_DEFAULT_STRATEGY); + } + else { + ret = inflateInit2(&ctx->zstr, -MAX_WBITS); + } + + if (ret != Z_OK) { + zip_error_set(ctx->error, ZIP_ER_ZLIB, ret); + return false; + } + + + return true; +} + + +static bool +end(void *ud) { + struct ctx *ctx = (struct ctx *)ud; + int err; + + if (ctx->compress) { + err = deflateEnd(&ctx->zstr); + } + else { + err = inflateEnd(&ctx->zstr); + } + + if (err != Z_OK) { + zip_error_set(ctx->error, ZIP_ER_ZLIB, err); + return false; + } + + return true; +} + + +static bool +input(void *ud, zip_uint8_t *data, zip_uint64_t length) { + struct ctx *ctx = (struct ctx *)ud; + + if (length > UINT_MAX || ctx->zstr.avail_in > 0) { + zip_error_set(ctx->error, ZIP_ER_INVAL, 0); + return false; + } + + ctx->zstr.avail_in = (uInt)length; + ctx->zstr.next_in = (Bytef *)data; + + return true; +} + + +static bool end_of_input(void *ud) { + struct ctx *ctx = (struct ctx *)ud; + + ctx->end_of_input = true; + return ctx->zstr.avail_in != 0; +} + + +static zip_compression_status_t +process(void *ud, zip_uint8_t *data, zip_uint64_t *length) { + struct ctx *ctx = (struct ctx *)ud; + uInt avail_out; + + int ret; + + avail_out = (uInt)ZIP_MIN(UINT_MAX, *length); + ctx->zstr.avail_out = avail_out; + ctx->zstr.next_out = (Bytef *)data; + + if (ctx->compress) { + ret = deflate(&ctx->zstr, ctx->end_of_input ? Z_FINISH : 0); + } + else { + ret = inflate(&ctx->zstr, Z_SYNC_FLUSH); + } + + *length = avail_out - ctx->zstr.avail_out; + + switch (ret) { + case Z_OK: + return ZIP_COMPRESSION_OK; + + case Z_STREAM_END: + return ZIP_COMPRESSION_END; + + case Z_BUF_ERROR: + if (ctx->zstr.avail_in == 0) { + return ZIP_COMPRESSION_NEED_DATA; + } + + /* fallthrough */ + + default: + zip_error_set(ctx->error, ZIP_ER_ZLIB, ret); + return ZIP_COMPRESSION_ERROR; + } +} + +/* clang-format off */ + +zip_compression_algorithm_t zip_algorithm_deflate_compress = { + maximum_compressed_size, + compress_allocate, + deallocate, + general_purpose_bit_flags, + 20, + start, + end, + input, + end_of_input, + process +}; + + +zip_compression_algorithm_t zip_algorithm_deflate_decompress = { + maximum_compressed_size, + decompress_allocate, + deallocate, + general_purpose_bit_flags, + 20, + start, + end, + input, + end_of_input, + process +}; + +/* clang-format on */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_algorithm_xz.c b/thirdparty/libzip-1.11.3/lib/zip_algorithm_xz.c new file mode 100644 index 0000000..adadc1c --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_algorithm_xz.c @@ -0,0 +1,408 @@ +/* + zip_algorithm_xz.c -- LZMA/XZ (de)compression routines + Bazed on zip_algorithm_deflate.c -- deflate (de)compression routines + Copyright (C) 2017-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +#include +#include +#include +#include + +enum header_state { INCOMPLETE, OUTPUT, DONE }; + +#define HEADER_BYTES_ZIP 9 +#define HEADER_MAGIC_LENGTH 4 +#define HEADER_MAGIC1_OFFSET 0 +#define HEADER_MAGIC2_OFFSET 2 +#define HEADER_SIZE_OFFSET 9 +#define HEADER_SIZE_LENGTH 8 +#define HEADER_PARAMETERS_LENGTH 5 +#define HEADER_LZMA_ALONE_LENGTH (HEADER_PARAMETERS_LENGTH + HEADER_SIZE_LENGTH) + +struct ctx { + zip_error_t *error; + bool compress; + zip_uint32_t compression_flags; + bool end_of_input; + lzma_stream zstr; + zip_uint16_t method; + /* header member is used for converting from zip to "lzma alone" + * format + * + * "lzma alone" file format starts with: + * 5 bytes lzma parameters + * 8 bytes uncompressed size + * compressed data + * + * zip archive on-disk format starts with + * 4 bytes magic (first two bytes vary, e.g. 0x0914 or 0x1002, next bytes are 0x0500) + * 5 bytes lzma parameters + * compressed data + * + * we read the data into a header of the form + * 4 bytes magic + * 5 bytes lzma parameters + * 8 bytes uncompressed size + */ + zip_uint8_t header[HEADER_MAGIC_LENGTH + HEADER_LZMA_ALONE_LENGTH]; + zip_uint8_t header_bytes_offset; + enum header_state header_state; + zip_uint64_t uncompresssed_size; +}; + + +static zip_uint64_t +maximum_compressed_size(zip_uint64_t uncompressed_size) { + /* + According to https://sourceforge.net/p/sevenzip/discussion/45797/thread/b6bd62f8/ + + 1) you can use + outSize = 1.10 * originalSize + 64 KB. + in most cases outSize is less then 1.02 from originalSize. + 2) You can try LZMA2, where + outSize can be = 1.001 * originalSize + 1 KB. + */ + /* 13 bytes added for lzma alone header */ + zip_uint64_t compressed_size = (zip_uint64_t)((double)uncompressed_size * 1.1) + 64 * 1024 + 13; + + if (compressed_size < uncompressed_size) { + return ZIP_UINT64_MAX; + } + return compressed_size; +} + + +static void * +allocate(bool compress, zip_uint32_t compression_flags, zip_error_t *error, zip_uint16_t method) { + struct ctx *ctx; + + if ((ctx = (struct ctx *)malloc(sizeof(*ctx))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + ctx->error = error; + ctx->compress = compress; + if (compression_flags <= 9) { + ctx->compression_flags = compression_flags; + } else { + ctx->compression_flags = 6; /* default value */ + } + ctx->compression_flags |= LZMA_PRESET_EXTREME; + ctx->end_of_input = false; + memset(ctx->header, 0, sizeof(ctx->header)); + ctx->header_bytes_offset = 0; + if (method == ZIP_CM_LZMA) { + ctx->header_state = INCOMPLETE; + } + else { + ctx->header_state = DONE; + } + memset(&ctx->zstr, 0, sizeof(ctx->zstr)); + ctx->method = method; + return ctx; +} + + +static void * +compress_allocate(zip_uint16_t method, zip_uint32_t compression_flags, zip_error_t *error) { + return allocate(true, compression_flags, error, method); +} + + +static void * +decompress_allocate(zip_uint16_t method, zip_uint32_t compression_flags, zip_error_t *error) { + return allocate(false, compression_flags, error, method); +} + + +static void +deallocate(void *ud) { + struct ctx *ctx = (struct ctx *)ud; + free(ctx); +} + + +static zip_uint16_t +general_purpose_bit_flags(void *ud) { + struct ctx *ctx = (struct ctx *)ud; + + if (!ctx->compress) { + return 0; + } + + if (ctx->method == ZIP_CM_LZMA) { + /* liblzma always returns an EOS/EOPM marker, see + * https://sourceforge.net/p/lzmautils/discussion/708858/thread/84c5dbb9/#a5e4/3764 */ + return 1 << 1; + } + return 0; +} + +static int +map_error(lzma_ret ret) { + switch (ret) { + case LZMA_DATA_ERROR: + case LZMA_UNSUPPORTED_CHECK: + return ZIP_ER_COMPRESSED_DATA; + + case LZMA_MEM_ERROR: + return ZIP_ER_MEMORY; + + case LZMA_OPTIONS_ERROR: + return ZIP_ER_INVAL; + + default: + return ZIP_ER_INTERNAL; + } +} + + +static bool +start(void *ud, zip_stat_t *st, zip_file_attributes_t *attributes) { + struct ctx *ctx = (struct ctx *)ud; + lzma_ret ret; + + lzma_options_lzma opt_lzma; + lzma_lzma_preset(&opt_lzma, ctx->compression_flags); + lzma_filter filters[] = { + {.id = (ctx->method == ZIP_CM_LZMA ? LZMA_FILTER_LZMA1 : LZMA_FILTER_LZMA2), .options = &opt_lzma}, + {.id = LZMA_VLI_UNKNOWN, .options = NULL}, + }; + + ctx->zstr.avail_in = 0; + ctx->zstr.next_in = NULL; + ctx->zstr.avail_out = 0; + ctx->zstr.next_out = NULL; + + if (ctx->compress) { + if (ctx->method == ZIP_CM_LZMA) + ret = lzma_alone_encoder(&ctx->zstr, filters[0].options); + else + ret = lzma_stream_encoder(&ctx->zstr, filters, LZMA_CHECK_CRC64); + } + else { + if (ctx->method == ZIP_CM_LZMA) + ret = lzma_alone_decoder(&ctx->zstr, UINT64_MAX); + else + ret = lzma_stream_decoder(&ctx->zstr, UINT64_MAX, LZMA_CONCATENATED); + } + + if (ret != LZMA_OK) { + zip_error_set(ctx->error, map_error(ret), 0); + return false; + } + + /* If general purpose bits 1 & 2 are both zero, write real uncompressed size in header. */ + if ((attributes->valid & ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS) && (attributes->general_purpose_bit_mask & 0x6) == 0x6 && (attributes->general_purpose_bit_flags & 0x06) == 0 && (st->valid & ZIP_STAT_SIZE)) { + ctx->uncompresssed_size = st->size; + } + else { + ctx->uncompresssed_size = ZIP_UINT64_MAX; + } + + return true; +} + + +static bool +end(void *ud) { + struct ctx *ctx = (struct ctx *)ud; + + lzma_end(&ctx->zstr); + return true; +} + + +static bool +input(void *ud, zip_uint8_t *data, zip_uint64_t length) { + struct ctx *ctx = (struct ctx *)ud; + + if (length > UINT_MAX || ctx->zstr.avail_in > 0) { + zip_error_set(ctx->error, ZIP_ER_INVAL, 0); + return false; + } + + /* For decompression of LZMA1: Have we read the full "lzma alone" header yet? */ + if (ctx->method == ZIP_CM_LZMA && !ctx->compress && ctx->header_state == INCOMPLETE) { + /* if not, get more of the data */ + zip_uint8_t got = (zip_uint8_t)ZIP_MIN(HEADER_BYTES_ZIP - ctx->header_bytes_offset, length); + (void)memcpy_s(ctx->header + ctx->header_bytes_offset, sizeof(ctx->header) - ctx->header_bytes_offset, data, got); + ctx->header_bytes_offset += got; + length -= got; + data += got; + /* Do we have a complete header now? */ + if (ctx->header_bytes_offset == HEADER_BYTES_ZIP) { + Bytef empty_buffer[1]; + zip_buffer_t *buffer; + /* check magic */ + if (ctx->header[HEADER_MAGIC2_OFFSET] != 0x05 || ctx->header[HEADER_MAGIC2_OFFSET + 1] != 0x00) { + /* magic does not match */ + zip_error_set(ctx->error, ZIP_ER_COMPRESSED_DATA, 0); + return false; + } + /* set size of uncompressed data in "lzma alone" header to "unknown" */ + if ((buffer = _zip_buffer_new(ctx->header + HEADER_SIZE_OFFSET, HEADER_SIZE_LENGTH)) == NULL) { + zip_error_set(ctx->error, ZIP_ER_MEMORY, 0); + return false; + } + _zip_buffer_put_64(buffer, ctx->uncompresssed_size); + _zip_buffer_free(buffer); + /* Feed header into "lzma alone" decoder, for + * initialization; this should not produce output. */ + ctx->zstr.next_in = (void *)(ctx->header + HEADER_MAGIC_LENGTH); + ctx->zstr.avail_in = HEADER_LZMA_ALONE_LENGTH; + ctx->zstr.total_in = 0; + ctx->zstr.next_out = empty_buffer; + ctx->zstr.avail_out = sizeof(*empty_buffer); + ctx->zstr.total_out = 0; + /* this just initializes the decoder and does not produce output, so it consumes the complete header */ + if (lzma_code(&ctx->zstr, LZMA_RUN) != LZMA_OK || ctx->zstr.total_out > 0) { + zip_error_set(ctx->error, ZIP_ER_COMPRESSED_DATA, 0); + return false; + } + ctx->header_state = DONE; + } + } + ctx->zstr.avail_in = (uInt)length; + ctx->zstr.next_in = (Bytef *)data; + + return true; +} + + +static bool end_of_input(void *ud) { + struct ctx *ctx = (struct ctx *)ud; + + ctx->end_of_input = true; + return ctx->zstr.avail_in != 0; +} + + +static zip_compression_status_t +process(void *ud, zip_uint8_t *data, zip_uint64_t *length) { + struct ctx *ctx = (struct ctx *)ud; + uInt avail_out; + lzma_ret ret; + /* for compression of LZMA1 */ + if (ctx->method == ZIP_CM_LZMA && ctx->compress) { + if (ctx->header_state == INCOMPLETE) { + /* write magic to output buffer */ + ctx->header[0] = 0x09; + ctx->header[1] = 0x14; + ctx->header[2] = 0x05; + ctx->header[3] = 0x00; + /* generate lzma parameters into output buffer */ + ctx->zstr.avail_out = HEADER_LZMA_ALONE_LENGTH; + ctx->zstr.next_out = ctx->header + HEADER_MAGIC_LENGTH; + ret = lzma_code(&ctx->zstr, LZMA_RUN); + if (ret != LZMA_OK || ctx->zstr.avail_out != 0) { + /* assume that the whole header will be provided with the first call to lzma_code */ + return ZIP_COMPRESSION_ERROR; + } + ctx->header_state = OUTPUT; + } + if (ctx->header_state == OUTPUT) { + /* write header */ + zip_uint8_t write_len = (zip_uint8_t)ZIP_MIN(HEADER_BYTES_ZIP - ctx->header_bytes_offset, *length); + (void)memcpy_s(data, *length, ctx->header + ctx->header_bytes_offset, write_len); + ctx->header_bytes_offset += write_len; + *length = write_len; + if (ctx->header_bytes_offset == HEADER_BYTES_ZIP) { + ctx->header_state = DONE; + } + return ZIP_COMPRESSION_OK; + } + } + + avail_out = (uInt)ZIP_MIN(UINT_MAX, *length); + ctx->zstr.avail_out = avail_out; + ctx->zstr.next_out = (Bytef *)data; + + ret = lzma_code(&ctx->zstr, ctx->end_of_input ? LZMA_FINISH : LZMA_RUN); + *length = avail_out - ctx->zstr.avail_out; + + switch (ret) { + case LZMA_OK: + return ZIP_COMPRESSION_OK; + + case LZMA_STREAM_END: + return ZIP_COMPRESSION_END; + + case LZMA_BUF_ERROR: + if (ctx->zstr.avail_in == 0) { + return ZIP_COMPRESSION_NEED_DATA; + } + + /* fallthrough */ + default: + zip_error_set(ctx->error, map_error(ret), 0); + return ZIP_COMPRESSION_ERROR; + } +} + +/* Version Required should be set to 63 (6.3) because this compression + method was only defined in appnote.txt version 6.3.8, but Winzip + does not unpack it if the value is not 20. */ + +/* clang-format off */ + +zip_compression_algorithm_t zip_algorithm_xz_compress = { + maximum_compressed_size, + compress_allocate, + deallocate, + general_purpose_bit_flags, + 20, + start, + end, + input, + end_of_input, + process +}; + + +zip_compression_algorithm_t zip_algorithm_xz_decompress = { + maximum_compressed_size, + decompress_allocate, + deallocate, + general_purpose_bit_flags, + 20, + start, + end, + input, + end_of_input, + process +}; + +/* clang-format on */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_algorithm_zstd.c b/thirdparty/libzip-1.11.3/lib/zip_algorithm_zstd.c new file mode 100644 index 0000000..21bb249 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_algorithm_zstd.c @@ -0,0 +1,298 @@ +/* + zip_algorithm_zstd.c -- zstd (de)compression routines + Copyright (C) 2020-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +#include +#include +#include + +struct ctx { + zip_error_t *error; + bool compress; + int compression_flags; + bool end_of_input; + ZSTD_DStream *zdstream; + ZSTD_CStream *zcstream; + ZSTD_outBuffer out; + ZSTD_inBuffer in; +}; + +static zip_uint64_t +maximum_compressed_size(zip_uint64_t uncompressed_size) { + return ZSTD_compressBound(uncompressed_size); +} + + +static void * +allocate(bool compress, zip_uint32_t compression_flags, zip_error_t *error) { + struct ctx *ctx; + + if ((ctx = (struct ctx *)malloc(sizeof(*ctx))) == NULL) { + return NULL; + } + + ctx->compression_flags = (zip_int32_t)compression_flags; + if (ctx->compression_flags < ZSTD_minCLevel() || ctx->compression_flags > ZSTD_maxCLevel()) { + ctx->compression_flags = 0; /* let zstd choose */ + } + + ctx->error = error; + ctx->compress = compress; + ctx->end_of_input = false; + + ctx->zdstream = NULL; + ctx->zcstream = NULL; + ctx->in.src = NULL; + ctx->in.pos = 0; + ctx->in.size = 0; + ctx->out.dst = NULL; + ctx->out.pos = 0; + ctx->out.size = 0; + + return ctx; +} + + +static void * +compress_allocate(zip_uint16_t method, zip_uint32_t compression_flags, zip_error_t *error) { + (void)method; + return allocate(true, compression_flags, error); +} + + +static void * +decompress_allocate(zip_uint16_t method, zip_uint32_t compression_flags, zip_error_t *error) { + (void)method; + return allocate(false, compression_flags, error); +} + + +static void +deallocate(void *ud) { + struct ctx *ctx = (struct ctx *)ud; + free(ctx); +} + + +static zip_uint16_t +general_purpose_bit_flags(void *ud) { + (void)ud; + return 0; +} + +static int +map_error(size_t ret) { + switch (ret) { + case ZSTD_error_no_error: + return ZIP_ER_OK; + + case ZSTD_error_corruption_detected: + case ZSTD_error_checksum_wrong: + case ZSTD_error_dictionary_corrupted: + case ZSTD_error_dictionary_wrong: + return ZIP_ER_COMPRESSED_DATA; + + case ZSTD_error_memory_allocation: + return ZIP_ER_MEMORY; + + case ZSTD_error_parameter_unsupported: + case ZSTD_error_parameter_outOfBound: + return ZIP_ER_INVAL; + + default: + return ZIP_ER_INTERNAL; + } +} + + +static bool +start(void *ud, zip_stat_t *st, zip_file_attributes_t *attributes) { + struct ctx *ctx = (struct ctx *)ud; + + (void)st; + (void)attributes; + + ctx->in.src = NULL; + ctx->in.pos = 0; + ctx->in.size = 0; + ctx->out.dst = NULL; + ctx->out.pos = 0; + ctx->out.size = 0; + if (ctx->compress) { + size_t ret; + ctx->zcstream = ZSTD_createCStream(); + if (ctx->zcstream == NULL) { + zip_error_set(ctx->error, ZIP_ER_MEMORY, 0); + return false; + } + ret = ZSTD_initCStream(ctx->zcstream, ctx->compression_flags); + if (ZSTD_isError(ret)) { + zip_error_set(ctx->error, ZIP_ER_ZLIB, map_error(ret)); + return false; + } + } + else { + ctx->zdstream = ZSTD_createDStream(); + if (ctx->zdstream == NULL) { + zip_error_set(ctx->error, ZIP_ER_MEMORY, 0); + return false; + } + } + + return true; +} + + +static bool +end(void *ud) { + struct ctx *ctx = (struct ctx *)ud; + size_t ret; + + if (ctx->compress) { + ret = ZSTD_freeCStream(ctx->zcstream); + ctx->zcstream = NULL; + } + else { + ret = ZSTD_freeDStream(ctx->zdstream); + ctx->zdstream = NULL; + } + + if (ZSTD_isError(ret)) { + zip_error_set(ctx->error, map_error(ret), 0); + return false; + } + + return true; +} + + +static bool +input(void *ud, zip_uint8_t *data, zip_uint64_t length) { + struct ctx *ctx = (struct ctx *)ud; + if (length > SIZE_MAX || ctx->in.pos != ctx->in.size) { + zip_error_set(ctx->error, ZIP_ER_INVAL, 0); + return false; + } + ctx->in.src = (const void *)data; + ctx->in.size = (size_t)length; + ctx->in.pos = 0; + return true; +} + + +static bool end_of_input(void *ud) { + struct ctx *ctx = (struct ctx *)ud; + + ctx->end_of_input = true; + return ctx->in.pos != ctx->in.size; +} + + +static zip_compression_status_t +process(void *ud, zip_uint8_t *data, zip_uint64_t *length) { + struct ctx *ctx = (struct ctx *)ud; + + size_t ret; + + if (ctx->in.pos == ctx->in.size && !ctx->end_of_input) { + *length = 0; + return ZIP_COMPRESSION_NEED_DATA; + } + + ctx->out.dst = data; + ctx->out.pos = 0; + ctx->out.size = ZIP_MIN(SIZE_MAX, *length); + + if (ctx->compress) { + if (ctx->in.pos == ctx->in.size && ctx->end_of_input) { + ret = ZSTD_endStream(ctx->zcstream, &ctx->out); + if (ret == 0) { + *length = ctx->out.pos; + return ZIP_COMPRESSION_END; + } + } + else { + ret = ZSTD_compressStream(ctx->zcstream, &ctx->out, &ctx->in); + } + } + else { + ret = ZSTD_decompressStream(ctx->zdstream, &ctx->out, &ctx->in); + } + if (ZSTD_isError(ret)) { + zip_error_set(ctx->error, map_error(ret), 0); + return ZIP_COMPRESSION_ERROR; + } + + *length = ctx->out.pos; + if (ctx->in.pos == ctx->in.size) { + return ZIP_COMPRESSION_NEED_DATA; + } + + return ZIP_COMPRESSION_OK; +} + +/* Version Required should be set to 63 (6.3) because this compression + method was only defined in appnote.txt version 6.3.7, but Winzip + does not unpack it if the value is not 20. */ + +/* clang-format off */ + +zip_compression_algorithm_t zip_algorithm_zstd_compress = { + maximum_compressed_size, + compress_allocate, + deallocate, + general_purpose_bit_flags, + 20, + start, + end, + input, + end_of_input, + process +}; + + +zip_compression_algorithm_t zip_algorithm_zstd_decompress = { + maximum_compressed_size, + decompress_allocate, + deallocate, + general_purpose_bit_flags, + 20, + start, + end, + input, + end_of_input, + process +}; + +/* clang-format on */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_buffer.c b/thirdparty/libzip-1.11.3/lib/zip_buffer.c new file mode 100644 index 0000000..de22bab --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_buffer.c @@ -0,0 +1,336 @@ +/* + zip_buffer.c -- bounds checked access to memory buffer + Copyright (C) 2014-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include + +#include "zipint.h" + +zip_uint8_t * +_zip_buffer_data(zip_buffer_t *buffer) { + return buffer->data; +} + + +void +_zip_buffer_free(zip_buffer_t *buffer) { + if (buffer == NULL) { + return; + } + + if (buffer->free_data) { + free(buffer->data); + } + + free(buffer); +} + + +bool +_zip_buffer_eof(zip_buffer_t *buffer) { + return buffer->ok && buffer->offset == buffer->size; +} + + +zip_uint8_t * +_zip_buffer_get(zip_buffer_t *buffer, zip_uint64_t length) { + zip_uint8_t *data; + + data = _zip_buffer_peek(buffer, length); + + if (data != NULL) { + buffer->offset += length; + } + + return data; +} + + +zip_uint16_t +_zip_buffer_get_16(zip_buffer_t *buffer) { + zip_uint8_t *data = _zip_buffer_get(buffer, 2); + + if (data == NULL) { + return 0; + } + + return (zip_uint16_t)(data[0] + (data[1] << 8)); +} + + +zip_uint32_t +_zip_buffer_get_32(zip_buffer_t *buffer) { + zip_uint8_t *data = _zip_buffer_get(buffer, 4); + + if (data == NULL) { + return 0; + } + + return ((((((zip_uint32_t)data[3] << 8) + data[2]) << 8) + data[1]) << 8) + data[0]; +} + + +zip_uint64_t +_zip_buffer_get_64(zip_buffer_t *buffer) { + zip_uint8_t *data = _zip_buffer_get(buffer, 8); + + if (data == NULL) { + return 0; + } + + return ((zip_uint64_t)data[7] << 56) + ((zip_uint64_t)data[6] << 48) + ((zip_uint64_t)data[5] << 40) + ((zip_uint64_t)data[4] << 32) + ((zip_uint64_t)data[3] << 24) + ((zip_uint64_t)data[2] << 16) + ((zip_uint64_t)data[1] << 8) + (zip_uint64_t)data[0]; +} + + +zip_uint8_t +_zip_buffer_get_8(zip_buffer_t *buffer) { + zip_uint8_t *data = _zip_buffer_get(buffer, 1); + + if (data == NULL) { + return 0; + } + + return data[0]; +} + + +zip_uint64_t +_zip_buffer_left(zip_buffer_t *buffer) { + return buffer->ok ? buffer->size - buffer->offset : 0; +} + + +zip_uint64_t +_zip_buffer_read(zip_buffer_t *buffer, zip_uint8_t *data, zip_uint64_t length) { + zip_uint64_t copied; + + if (_zip_buffer_left(buffer) < length) { + length = _zip_buffer_left(buffer); + } + + copied = 0; + while (copied < length) { + size_t n = ZIP_MIN(length - copied, SIZE_MAX); + (void)memcpy_s(data + copied, n, _zip_buffer_get(buffer, n), n); + copied += n; + } + + return copied; +} + + +zip_buffer_t * +_zip_buffer_new(zip_uint8_t *data, zip_uint64_t size) { + bool free_data = (data == NULL); + zip_buffer_t *buffer; + +#if ZIP_UINT64_MAX > SIZE_MAX + if (size > SIZE_MAX) { + return NULL; + } +#endif + + if (data == NULL) { + if ((data = (zip_uint8_t *)malloc((size_t)size)) == NULL) { + return NULL; + } + } + + if ((buffer = (zip_buffer_t *)malloc(sizeof(*buffer))) == NULL) { + if (free_data) { + free(data); + } + return NULL; + } + + buffer->ok = true; + buffer->data = data; + buffer->size = size; + buffer->offset = 0; + buffer->free_data = free_data; + + return buffer; +} + + +zip_buffer_t * +_zip_buffer_new_from_source(zip_source_t *src, zip_uint64_t size, zip_uint8_t *buf, zip_error_t *error) { + zip_buffer_t *buffer; + + if ((buffer = _zip_buffer_new(buf, size)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if (_zip_read(src, buffer->data, size, error) < 0) { + _zip_buffer_free(buffer); + return NULL; + } + + return buffer; +} + + +zip_uint64_t +_zip_buffer_offset(zip_buffer_t *buffer) { + return buffer->ok ? buffer->offset : 0; +} + + +bool +_zip_buffer_ok(zip_buffer_t *buffer) { + return buffer->ok; +} + + +zip_uint8_t * +_zip_buffer_peek(zip_buffer_t *buffer, zip_uint64_t length) { + zip_uint8_t *data; + + if (!buffer->ok || buffer->offset + length < length || buffer->offset + length > buffer->size) { + buffer->ok = false; + return NULL; + } + + data = buffer->data + buffer->offset; + return data; +} + +int +_zip_buffer_put(zip_buffer_t *buffer, const void *src, size_t length) { + zip_uint8_t *dst = _zip_buffer_get(buffer, length); + + if (dst == NULL) { + return -1; + } + + (void)memcpy_s(dst, length, src, length); + return 0; +} + + +int +_zip_buffer_put_16(zip_buffer_t *buffer, zip_uint16_t i) { + zip_uint8_t *data = _zip_buffer_get(buffer, 2); + + if (data == NULL) { + return -1; + } + + data[0] = (zip_uint8_t)(i & 0xff); + data[1] = (zip_uint8_t)((i >> 8) & 0xff); + + return 0; +} + + +int +_zip_buffer_put_32(zip_buffer_t *buffer, zip_uint32_t i) { + zip_uint8_t *data = _zip_buffer_get(buffer, 4); + + if (data == NULL) { + return -1; + } + + data[0] = (zip_uint8_t)(i & 0xff); + data[1] = (zip_uint8_t)((i >> 8) & 0xff); + data[2] = (zip_uint8_t)((i >> 16) & 0xff); + data[3] = (zip_uint8_t)((i >> 24) & 0xff); + + return 0; +} + + +int +_zip_buffer_put_64(zip_buffer_t *buffer, zip_uint64_t i) { + zip_uint8_t *data = _zip_buffer_get(buffer, 8); + + if (data == NULL) { + return -1; + } + + data[0] = (zip_uint8_t)(i & 0xff); + data[1] = (zip_uint8_t)((i >> 8) & 0xff); + data[2] = (zip_uint8_t)((i >> 16) & 0xff); + data[3] = (zip_uint8_t)((i >> 24) & 0xff); + data[4] = (zip_uint8_t)((i >> 32) & 0xff); + data[5] = (zip_uint8_t)((i >> 40) & 0xff); + data[6] = (zip_uint8_t)((i >> 48) & 0xff); + data[7] = (zip_uint8_t)((i >> 56) & 0xff); + + return 0; +} + + +int +_zip_buffer_put_8(zip_buffer_t *buffer, zip_uint8_t i) { + zip_uint8_t *data = _zip_buffer_get(buffer, 1); + + if (data == NULL) { + return -1; + } + + data[0] = i; + + return 0; +} + + +int _zip_buffer_set_offset(zip_buffer_t *buffer, zip_uint64_t offset) { + if (offset > buffer->size) { + buffer->ok = false; + return -1; + } + + buffer->ok = true; + buffer->offset = offset; + + return 0; +} + + +int +_zip_buffer_skip(zip_buffer_t *buffer, zip_uint64_t length) { + zip_uint64_t offset = buffer->offset + length; + + if (offset < buffer->offset) { + buffer->ok = false; + return -1; + } + return _zip_buffer_set_offset(buffer, offset); +} + +zip_uint64_t +_zip_buffer_size(zip_buffer_t *buffer) { + return buffer->size; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_close.c b/thirdparty/libzip-1.11.3/lib/zip_close.c new file mode 100644 index 0000000..6948c0e --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_close.c @@ -0,0 +1,791 @@ +/* + zip_close.c -- close zip archive and update changes + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + +#include +#include +#ifdef _WIN32 +#include +#include +#endif + + +static int add_data(zip_t *, zip_source_t *, zip_dirent_t *, zip_uint32_t); +static int copy_data(zip_t *, zip_uint64_t); +static int copy_source(zip_t *, zip_source_t *, zip_source_t *, zip_int64_t); +static int torrentzip_compare_names(const void *a, const void *b); +static int write_cdir(zip_t *, const zip_filelist_t *, zip_uint64_t); +static int write_data_descriptor(zip_t *za, const zip_dirent_t *dirent, int is_zip64); + +ZIP_EXTERN int +zip_close(zip_t *za) { + zip_uint64_t i, j, survivors, unchanged_offset; + zip_int64_t off; + int error; + zip_filelist_t *filelist; + int changed; + + if (za == NULL) + return -1; + + changed = _zip_changed(za, &survivors); + + if (survivors == 0 && !(za->ch_flags & ZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE)) { + /* don't create zip files with no entries */ + if ((za->open_flags & ZIP_TRUNCATE) || changed) { + if (zip_source_remove(za->src) < 0) { + if (!((zip_error_code_zip(zip_source_error(za->src)) == ZIP_ER_REMOVE) && (zip_error_code_system(zip_source_error(za->src)) == ENOENT))) { + zip_error_set_from_source(&za->error, za->src); + return -1; + } + } + } + zip_discard(za); + return 0; + } + + /* Always write empty archive if we are told to keep it, otherwise it wouldn't be created if the file doesn't already exist. */ + if (!changed && survivors > 0) { + zip_discard(za); + return 0; + } + + if (survivors > za->nentry) { + zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); + return -1; + } + + if ((filelist = (zip_filelist_t *)malloc(sizeof(filelist[0]) * (size_t)survivors)) == NULL) + return -1; + + unchanged_offset = ZIP_UINT64_MAX; + /* create list of files with index into original archive */ + for (i = j = 0; i < za->nentry; i++) { + if (za->entry[i].orig != NULL && ZIP_ENTRY_HAS_CHANGES(&za->entry[i])) { + unchanged_offset = ZIP_MIN(unchanged_offset, za->entry[i].orig->offset); + } + if (za->entry[i].deleted) { + continue; + } + + if (j >= survivors) { + free(filelist); + zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); + return -1; + } + + filelist[j].idx = i; + filelist[j].name = zip_get_name(za, i, 0); + j++; + } + if (j < survivors) { + free(filelist); + zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); + return -1; + } + + if (ZIP_WANT_TORRENTZIP(za)) { + qsort(filelist, (size_t)survivors, sizeof(filelist[0]), torrentzip_compare_names); + } + + if (ZIP_WANT_TORRENTZIP(za) || (zip_source_supports(za->src) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_BEGIN_WRITE_CLONING)) == 0) { + unchanged_offset = 0; + } + else { + if (unchanged_offset == ZIP_UINT64_MAX) { + /* we're keeping all file data, find the end of the last one */ + zip_uint64_t last_index = ZIP_UINT64_MAX; + unchanged_offset = 0; + + for (i = 0; i < za->nentry; i++) { + if (za->entry[i].orig != NULL) { + if (za->entry[i].orig->offset >= unchanged_offset) { + unchanged_offset = za->entry[i].orig->offset; + last_index = i; + } + } + } + if (last_index != ZIP_UINT64_MAX) { + if ((unchanged_offset = _zip_file_get_end(za, last_index, &za->error)) == 0) { + free(filelist); + return -1; + } + } + } + if (unchanged_offset > 0) { + if (zip_source_begin_write_cloning(za->src, unchanged_offset) < 0) { + /* cloning not supported, need to copy everything */ + unchanged_offset = 0; + } + } + } + if (unchanged_offset == 0) { + if (zip_source_begin_write(za->src) < 0) { + zip_error_set_from_source(&za->error, za->src); + free(filelist); + return -1; + } + } + + if (_zip_progress_start(za->progress) != 0) { + zip_error_set(&za->error, ZIP_ER_CANCELLED, 0); + zip_source_rollback_write(za->src); + free(filelist); + return -1; + } + error = 0; + for (j = 0; j < survivors; j++) { + int new_data; + zip_entry_t *entry; + zip_dirent_t *de; + + if (_zip_progress_subrange(za->progress, (double)j / (double)survivors, (double)(j + 1) / (double)survivors) != 0) { + zip_error_set(&za->error, ZIP_ER_CANCELLED, 0); + error = 1; + break; + } + + i = filelist[j].idx; + entry = za->entry + i; + + if (entry->orig != NULL && entry->orig->offset < unchanged_offset) { + /* already implicitly copied by cloning */ + continue; + } + + new_data = (ZIP_ENTRY_DATA_CHANGED(entry) || ZIP_ENTRY_CHANGED(entry, ZIP_DIRENT_COMP_METHOD) || ZIP_ENTRY_CHANGED(entry, ZIP_DIRENT_ENCRYPTION_METHOD)) || (ZIP_WANT_TORRENTZIP(za) && !ZIP_IS_TORRENTZIP(za)); + + /* create new local directory entry */ + if (entry->changes == NULL) { + if ((entry->changes = _zip_dirent_clone(entry->orig)) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + error = 1; + break; + } + } + de = entry->changes; + + if (_zip_read_local_ef(za, i) < 0) { + error = 1; + break; + } + + if (ZIP_WANT_TORRENTZIP(za)) { + zip_dirent_torrentzip_normalize(entry->changes); + } + + if ((off = zip_source_tell_write(za->src)) < 0) { + zip_error_set_from_source(&za->error, za->src); + error = 1; + break; + } + de->offset = (zip_uint64_t)off; + + if (new_data) { + zip_source_t *zs; + + zs = NULL; + if (!ZIP_ENTRY_DATA_CHANGED(entry)) { + if ((zs = zip_source_zip_file_create(za, i, ZIP_FL_UNCHANGED, 0, -1, NULL, &za->error)) == NULL) { + error = 1; + break; + } + } + + /* add_data writes dirent */ + if (add_data(za, zs ? zs : entry->source, de, entry->changes ? entry->changes->changed : 0) < 0) { + error = 1; + if (zs) + zip_source_free(zs); + break; + } + if (zs) + zip_source_free(zs); + } + else { + zip_uint64_t offset; + + if (de->encryption_method != ZIP_EM_TRAD_PKWARE) { + /* when copying data, all sizes are known -> no data descriptor needed */ + /* except for PKWare encryption, where removing the data descriptor breaks password validation */ + de->bitflags &= (zip_uint16_t)~ZIP_GPBF_DATA_DESCRIPTOR; + } + if (_zip_dirent_write(za, de, ZIP_FL_LOCAL) < 0) { + error = 1; + break; + } + if ((offset = _zip_file_get_offset(za, i, &za->error)) == 0) { + error = 1; + break; + } + if (zip_source_seek(za->src, (zip_int64_t)offset, SEEK_SET) < 0) { + zip_error_set_from_source(&za->error, za->src); + error = 1; + break; + } + if (copy_data(za, de->comp_size) < 0) { + error = 1; + break; + } + + if (de->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) { + if (write_data_descriptor(za, de, _zip_dirent_needs_zip64(de, 0)) < 0) { + error = 1; + break; + } + } + } + } + + if (!error) { + if (write_cdir(za, filelist, survivors) < 0) + error = 1; + } + + free(filelist); + + if (!error) { + if (zip_source_commit_write(za->src) != 0) { + zip_error_set_from_source(&za->error, za->src); + error = 1; + } + _zip_progress_end(za->progress); + } + + if (error) { + zip_source_rollback_write(za->src); + return -1; + } + + zip_discard(za); + + return 0; +} + + +static int add_data(zip_t *za, zip_source_t *src, zip_dirent_t *de, zip_uint32_t changed) { + zip_int64_t offstart, offdata, offend, data_length; + zip_stat_t st; + zip_file_attributes_t attributes; + zip_source_t *src_final, *src_tmp; + int ret; + int is_zip64; + zip_flags_t flags; + bool needs_recompress, needs_decompress, needs_crc, needs_compress, needs_reencrypt, needs_decrypt, needs_encrypt; + bool have_dos_time, dirent_changed; + time_t mtime_before_copy; + + if (zip_source_stat(src, &st) < 0) { + zip_error_set_from_source(&za->error, src); + return -1; + } + + de->bitflags &= ~ZIP_GPBF_DATA_DESCRIPTOR; + + if ((st.valid & ZIP_STAT_COMP_METHOD) == 0) { + st.valid |= ZIP_STAT_COMP_METHOD; + st.comp_method = ZIP_CM_STORE; + } + + if (ZIP_CM_IS_DEFAULT(de->comp_method) && st.comp_method != ZIP_CM_STORE) { + de->comp_method = st.comp_method; + } + else if (de->comp_method == ZIP_CM_STORE && (st.valid & ZIP_STAT_SIZE)) { + st.valid |= ZIP_STAT_COMP_SIZE; + st.comp_size = st.size; + } + else { + /* we'll recompress */ + st.valid &= ~ZIP_STAT_COMP_SIZE; + } + + if ((st.valid & ZIP_STAT_ENCRYPTION_METHOD) == 0) { + st.valid |= ZIP_STAT_ENCRYPTION_METHOD; + st.encryption_method = ZIP_EM_NONE; + } + + flags = ZIP_EF_LOCAL; + + if ((st.valid & ZIP_STAT_SIZE) == 0) { + /* TODO: not valid for torrentzip */ + flags |= ZIP_FL_FORCE_ZIP64; + data_length = -1; + } + else { + de->uncomp_size = st.size; + /* this is technically incorrect (copy_source counts compressed data), but it's the best we have */ + data_length = (zip_int64_t)st.size; + + if ((st.valid & ZIP_STAT_COMP_SIZE) == 0) { + zip_uint64_t max_compressed_size; + zip_uint16_t compression_method = ZIP_CM_ACTUAL(de->comp_method); + + if (compression_method == ZIP_CM_STORE) { + max_compressed_size = st.size; + } + else { + zip_compression_algorithm_t *algorithm = _zip_get_compression_algorithm(compression_method, true); + if (algorithm == NULL) { + max_compressed_size = ZIP_UINT64_MAX; + } + else { + max_compressed_size = algorithm->maximum_compressed_size(st.size); + } + } + + if (max_compressed_size > 0xffffffffu) { + /* TODO: not valid for torrentzip */ + flags |= ZIP_FL_FORCE_ZIP64; + } + } + else { + de->comp_size = st.comp_size; + data_length = (zip_int64_t)st.comp_size; + } + } + + if ((de->changed & ZIP_DIRENT_LAST_MOD) == 0) { + int ret2 = zip_source_get_dos_time(src, &de->last_mod); + if (ret2 < 0) { + zip_error_set_from_source(&za->error, src); + return -1; + } + if (ret2 == 1) { + have_dos_time = true; + } + else { + if (st.valid & ZIP_STAT_MTIME) { + mtime_before_copy = st.mtime; + } + else { + time(&mtime_before_copy); + } + if (_zip_u2d_time(mtime_before_copy, &de->last_mod, &za->error) < 0) { + return -1; + } + } + } + + if ((offstart = zip_source_tell_write(za->src)) < 0) { + zip_error_set_from_source(&za->error, za->src); + return -1; + } + + needs_recompress = ZIP_WANT_TORRENTZIP(za) || st.comp_method != ZIP_CM_ACTUAL(de->comp_method); + needs_decompress = needs_recompress && (st.comp_method != ZIP_CM_STORE); + /* in these cases we can compute the CRC ourselves, so we do */ + needs_crc = (st.comp_method == ZIP_CM_STORE) || needs_decompress; + needs_compress = needs_recompress && (de->comp_method != ZIP_CM_STORE); + + needs_reencrypt = needs_recompress || (de->changed & ZIP_DIRENT_PASSWORD) || (de->encryption_method != st.encryption_method); + needs_decrypt = needs_reencrypt && (st.encryption_method != ZIP_EM_NONE); + needs_encrypt = needs_reencrypt && (de->encryption_method != ZIP_EM_NONE); + + src_final = src; + zip_source_keep(src_final); + + if (!needs_decrypt && st.encryption_method == ZIP_EM_TRAD_PKWARE && (de->changed & ZIP_DIRENT_LAST_MOD)) { + /* PKWare encryption uses the last modification time for password verification, therefore we can't change it without re-encrypting. Ignoring the requested modification time change seems more sensible than failing to close the archive. */ + de->changed &= ~ZIP_DIRENT_LAST_MOD; + } + + if (needs_decrypt) { + zip_encryption_implementation impl; + + if ((impl = _zip_get_encryption_implementation(st.encryption_method, ZIP_CODEC_DECODE)) == NULL) { + zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0); + zip_source_free(src_final); + return -1; + } + if ((src_tmp = impl(za, src_final, st.encryption_method, ZIP_CODEC_DECODE, za->default_password)) == NULL) { + /* error set by impl */ + zip_source_free(src_final); + return -1; + } + + src_final = src_tmp; + } + + if (needs_decompress) { + if ((src_tmp = zip_source_decompress(za, src_final, st.comp_method)) == NULL) { + zip_source_free(src_final); + return -1; + } + + src_final = src_tmp; + } + + if (needs_crc) { + if ((src_tmp = zip_source_crc_create(src_final, 0, &za->error)) == NULL) { + zip_source_free(src_final); + return -1; + } + + src_final = src_tmp; + } + + if (needs_compress) { + if ((src_tmp = zip_source_compress(za, src_final, de->comp_method, de->compression_level)) == NULL) { + zip_source_free(src_final); + return -1; + } + + src_final = src_tmp; + } + + + if (needs_encrypt) { + zip_encryption_implementation impl; + const char *password = NULL; + + if (de->password) { + password = de->password; + } + else if (za->default_password) { + password = za->default_password; + } + + if ((impl = _zip_get_encryption_implementation(de->encryption_method, ZIP_CODEC_ENCODE)) == NULL) { + zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0); + zip_source_free(src_final); + return -1; + } + + if (de->encryption_method == ZIP_EM_TRAD_PKWARE) { + de->bitflags |= ZIP_GPBF_DATA_DESCRIPTOR; + + /* PKWare encryption uses last_mod, make sure it gets the right value. */ + if (de->changed & ZIP_DIRENT_LAST_MOD) { + if ((src_tmp = _zip_source_window_new(src_final, 0, -1, NULL, 0, NULL, &de->last_mod, NULL, 0, true, &za->error)) == NULL) { + zip_source_free(src_final); + return -1; + } + src_final = src_tmp; + } + } + + if ((src_tmp = impl(za, src_final, de->encryption_method, ZIP_CODEC_ENCODE, password)) == NULL) { + /* error set by impl */ + zip_source_free(src_final); + return -1; + } + + src_final = src_tmp; + } + + if (!ZIP_WANT_TORRENTZIP(za)) { + if (zip_source_get_file_attributes(src_final, &attributes) != 0) { + zip_error_set_from_source(&za->error, src_final); + zip_source_free(src_final); + return -1; + } + _zip_dirent_apply_attributes(de, &attributes, (flags & ZIP_FL_FORCE_ZIP64) != 0, changed); + } + + /* as long as we don't support non-seekable output, clear data descriptor bit */ + if ((is_zip64 = _zip_dirent_write(za, de, flags)) < 0) { + zip_source_free(src_final); + return -1; + } + + if ((offdata = zip_source_tell_write(za->src)) < 0) { + zip_error_set_from_source(&za->error, za->src); + zip_source_free(src_final); + return -1; + } + + ret = copy_source(za, src_final, src, data_length); + + if (zip_source_stat(src_final, &st) < 0) { + zip_error_set_from_source(&za->error, src_final); + ret = -1; + } + + if (!ZIP_WANT_TORRENTZIP(za)) { + if (zip_source_get_file_attributes(src_final, &attributes) != 0) { + zip_error_set_from_source(&za->error, src_final); + ret = -1; + } + } + + zip_source_free(src_final); + + if (ret < 0) { + return -1; + } + + if ((offend = zip_source_tell_write(za->src)) < 0) { + zip_error_set_from_source(&za->error, za->src); + return -1; + } + + if ((st.valid & (ZIP_STAT_COMP_METHOD | ZIP_STAT_CRC | ZIP_STAT_SIZE)) != (ZIP_STAT_COMP_METHOD | ZIP_STAT_CRC | ZIP_STAT_SIZE)) { + zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); + return -1; + } + + dirent_changed = ZIP_CM_ACTUAL(de->comp_method) != st.comp_method || de->crc != st.crc || de->uncomp_size != st.size || de->comp_size != (zip_uint64_t)(offend - offdata); + de->comp_method = st.comp_method; + de->crc = st.crc; + de->uncomp_size = st.size; + de->comp_size = (zip_uint64_t)(offend - offdata); + + if (!ZIP_WANT_TORRENTZIP(za)) { + dirent_changed |= _zip_dirent_apply_attributes(de, &attributes, (flags & ZIP_FL_FORCE_ZIP64) != 0, changed); + + if ((de->changed & ZIP_DIRENT_LAST_MOD) == 0 && !have_dos_time) { + if (st.valid & ZIP_STAT_MTIME) { + if (st.mtime != mtime_before_copy) { + if (_zip_u2d_time(st.mtime, &de->last_mod, &za->error) < 0) { + return -1; + } + dirent_changed = true; + } + } + } + } + + if (dirent_changed) { + if (zip_source_seek_write(za->src, offstart, SEEK_SET) < 0) { + zip_error_set_from_source(&za->error, za->src); + return -1; + } + + if ((ret = _zip_dirent_write(za, de, flags)) < 0) + return -1; + + if (is_zip64 != ret) { + /* Zip64 mismatch between preliminary file header written before data and final file header written afterwards */ + zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); + return -1; + } + + if (zip_source_seek_write(za->src, offend, SEEK_SET) < 0) { + zip_error_set_from_source(&za->error, za->src); + return -1; + } + } + + if (de->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) { + if (write_data_descriptor(za, de, is_zip64) < 0) { + return -1; + } + } + + return 0; +} + + +static int +copy_data(zip_t *za, zip_uint64_t len) { + DEFINE_BYTE_ARRAY(buf, BUFSIZE); + double total = (double)len; + + if (!byte_array_init(buf, BUFSIZE)) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + + while (len > 0) { + zip_uint64_t n = ZIP_MIN(len, BUFSIZE); + + if (_zip_read(za->src, buf, n, &za->error) < 0) { + byte_array_fini(buf); + return -1; + } + + if (_zip_write(za, buf, n) < 0) { + byte_array_fini(buf); + return -1; + } + + len -= n; + + if (_zip_progress_update(za->progress, (total - (double)len) / total) != 0) { + zip_error_set(&za->error, ZIP_ER_CANCELLED, 0); + return -1; + } + } + + byte_array_fini(buf); + return 0; +} + + +static int +copy_source(zip_t *za, zip_source_t *src, zip_source_t *src_for_length, zip_int64_t data_length) { + DEFINE_BYTE_ARRAY(buf, BUFSIZE); + zip_int64_t n, current; + int ret; + + if (zip_source_open(src) < 0) { + zip_error_set_from_source(&za->error, src); + return -1; + } + + if (!byte_array_init(buf, BUFSIZE)) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + + ret = 0; + current = 0; + while ((n = zip_source_read(src, buf, BUFSIZE)) > 0) { + if (_zip_write(za, buf, (zip_uint64_t)n) < 0) { + ret = -1; + break; + } + if (n == BUFSIZE && za->progress && data_length > 0) { + zip_int64_t t; + t = zip_source_tell(src_for_length); + if (t >= 0) { + current = t; + } else { + current += n; + } + if (_zip_progress_update(za->progress, (double)current / (double)data_length) != 0) { + zip_error_set(&za->error, ZIP_ER_CANCELLED, 0); + ret = -1; + break; + } + } + } + + if (n < 0) { + zip_error_set_from_source(&za->error, src); + ret = -1; + } + + byte_array_fini(buf); + + zip_source_close(src); + + return ret; +} + +static int +write_cdir(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivors) { + if (zip_source_tell_write(za->src) < 0) { + return -1; + } + + if (_zip_cdir_write(za, filelist, survivors) < 0) { + return -1; + } + + if (zip_source_tell_write(za->src) < 0) { + return -1; + } + + return 0; +} + + +int +_zip_changed(const zip_t *za, zip_uint64_t *survivorsp) { + int changed; + zip_uint64_t i, survivors; + + changed = 0; + survivors = 0; + + if (za->comment_changed || (ZIP_WANT_TORRENTZIP(za) && !ZIP_IS_TORRENTZIP(za))) { + changed = 1; + } + + for (i = 0; i < za->nentry; i++) { + if (ZIP_ENTRY_HAS_CHANGES(&za->entry[i])) { + changed = 1; + } + if (!za->entry[i].deleted) { + survivors++; + } + } + + if (survivorsp) { + *survivorsp = survivors; + } + + return changed; +} + +static int +write_data_descriptor(zip_t *za, const zip_dirent_t *de, int is_zip64) { + zip_buffer_t *buffer = _zip_buffer_new(NULL, MAX_DATA_DESCRIPTOR_LENGTH); + int ret = 0; + + if (buffer == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + + _zip_buffer_put(buffer, DATADES_MAGIC, 4); + _zip_buffer_put_32(buffer, de->crc); + if (is_zip64) { + _zip_buffer_put_64(buffer, de->comp_size); + _zip_buffer_put_64(buffer, de->uncomp_size); + } + else { + _zip_buffer_put_32(buffer, (zip_uint32_t)de->comp_size); + _zip_buffer_put_32(buffer, (zip_uint32_t)de->uncomp_size); + } + + if (!_zip_buffer_ok(buffer)) { + zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); + ret = -1; + } + else { + ret = _zip_write(za, _zip_buffer_data(buffer), _zip_buffer_offset(buffer)); + } + + _zip_buffer_free(buffer); + + return ret; +} + + +static int torrentzip_compare_names(const void *a, const void *b) { + const char *aname = ((const zip_filelist_t *)a)->name; + const char *bname = ((const zip_filelist_t *)b)->name; + + if (aname == NULL) { + return (bname != NULL) * -1; + } + else if (bname == NULL) { + return 1; + } + + return strcasecmp(aname, bname); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_crypto.h b/thirdparty/libzip-1.11.3/lib/zip_crypto.h new file mode 100644 index 0000000..805af52 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_crypto.h @@ -0,0 +1,54 @@ +/* + zip_crypto.h -- crypto definitions + Copyright (C) 2017-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef HAD_ZIP_CRYPTO_H +#define HAD_ZIP_CRYPTO_H + +#define ZIP_CRYPTO_SHA1_LENGTH 20 +#define ZIP_CRYPTO_AES_BLOCK_LENGTH 16 + +#if defined(HAVE_WINDOWS_CRYPTO) +#include "zip_crypto_win.h" +#elif defined(HAVE_COMMONCRYPTO) +#include "zip_crypto_commoncrypto.h" +#elif defined(HAVE_GNUTLS) +#include "zip_crypto_gnutls.h" +#elif defined(HAVE_OPENSSL) +#include "zip_crypto_openssl.h" +#elif defined(HAVE_MBEDTLS) +#include "zip_crypto_mbedtls.h" +#else +#error "no crypto backend found" +#endif + +#endif /* HAD_ZIP_CRYPTO_H */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_crypto_commoncrypto.c b/thirdparty/libzip-1.11.3/lib/zip_crypto_commoncrypto.c new file mode 100644 index 0000000..e6cb72d --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_crypto_commoncrypto.c @@ -0,0 +1,110 @@ +/* + zip_crypto_commoncrypto.c -- CommonCrypto wrapper. + Copyright (C) 2018-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include "zipint.h" + +#include "zip_crypto.h" + +#include +#include + +void +_zip_crypto_aes_free(_zip_crypto_aes_t *aes) { + if (aes == NULL) { + return; + } + + CCCryptorRelease(aes); +} + + +bool +_zip_crypto_aes_encrypt_block(_zip_crypto_aes_t *aes, const zip_uint8_t *in, zip_uint8_t *out) { + size_t len; + CCCryptorUpdate(aes, in, ZIP_CRYPTO_AES_BLOCK_LENGTH, out, ZIP_CRYPTO_AES_BLOCK_LENGTH, &len); + return true; +} + + +_zip_crypto_aes_t * +_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error) { + _zip_crypto_aes_t *aes; + CCCryptorStatus ret; + + ret = CCCryptorCreate(kCCEncrypt, kCCAlgorithmAES, kCCOptionECBMode, key, key_size / 8, NULL, &aes); + + switch (ret) { + case kCCSuccess: + return aes; + + case kCCMemoryFailure: + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + + case kCCParamError: + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + + default: + zip_error_set(error, ZIP_ER_INTERNAL, 0); + return NULL; + } +} + + +void +_zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac) { + if (hmac == NULL) { + return; + } + + _zip_crypto_clear(hmac, sizeof(*hmac)); + free(hmac); +} + + +_zip_crypto_hmac_t * +_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error) { + _zip_crypto_hmac_t *hmac; + + if ((hmac = (_zip_crypto_hmac_t *)malloc(sizeof(*hmac))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + CCHmacInit(hmac, kCCHmacAlgSHA1, secret, secret_length); + + return hmac; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_crypto_commoncrypto.h b/thirdparty/libzip-1.11.3/lib/zip_crypto_commoncrypto.h new file mode 100644 index 0000000..82dafdb --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_crypto_commoncrypto.h @@ -0,0 +1,53 @@ +/* + zip_crypto_commoncrypto.h -- definitions for CommonCrypto wrapper. + Copyright (C) 2018-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef HAD_ZIP_CRYPTO_COMMONCRYPTO_H +#define HAD_ZIP_CRYPTO_COMMONCRYPTO_H + +#include + +#define _zip_crypto_aes_t struct _CCCryptor +#define _zip_crypto_hmac_t CCHmacContext + +void _zip_crypto_aes_free(_zip_crypto_aes_t *aes); +bool _zip_crypto_aes_encrypt_block(_zip_crypto_aes_t *aes, const zip_uint8_t *in, zip_uint8_t *out); +_zip_crypto_aes_t *_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error); + +#define _zip_crypto_hmac(hmac, data, length) (CCHmacUpdate((hmac), (data), (length)), true) +void _zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac); +_zip_crypto_hmac_t *_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error); +#define _zip_crypto_hmac_output(hmac, data) (CCHmacFinal((hmac), (data)), true) + +#define _zip_crypto_pbkdf2(key, key_length, salt, salt_length, iterations, output, output_length) (CCKeyDerivationPBKDF(kCCPBKDF2, (const char *)(key), (key_length), (salt), (salt_length), kCCPRFHmacAlgSHA1, (iterations), (output), (output_length)) == kCCSuccess) + +#endif /* HAD_ZIP_CRYPTO_COMMONCRYPTO_H */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_crypto_gnutls.c b/thirdparty/libzip-1.11.3/lib/zip_crypto_gnutls.c new file mode 100644 index 0000000..fcc7fdf --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_crypto_gnutls.c @@ -0,0 +1,134 @@ +/* + zip_crypto_gnutls.c -- GnuTLS wrapper. + Copyright (C) 2018-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include "zipint.h" + +#include "zip_crypto.h" + +_zip_crypto_aes_t * +_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error) { + _zip_crypto_aes_t *aes; + + if ((aes = (_zip_crypto_aes_t *)malloc(sizeof(*aes))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + aes->key_size = key_size; + + switch (aes->key_size) { + case 128: + nettle_aes128_set_encrypt_key(&aes->ctx.ctx_128, key); + break; + case 192: + nettle_aes192_set_encrypt_key(&aes->ctx.ctx_192, key); + break; + case 256: + nettle_aes256_set_encrypt_key(&aes->ctx.ctx_256, key); + break; + default: + zip_error_set(error, ZIP_ER_INVAL, 0); + free(aes); + return NULL; + } + + return aes; +} + +bool +_zip_crypto_aes_encrypt_block(_zip_crypto_aes_t *aes, const zip_uint8_t *in, zip_uint8_t *out) { + switch (aes->key_size) { + case 128: + nettle_aes128_encrypt(&aes->ctx.ctx_128, ZIP_CRYPTO_AES_BLOCK_LENGTH, out, in); + break; + case 192: + nettle_aes192_encrypt(&aes->ctx.ctx_192, ZIP_CRYPTO_AES_BLOCK_LENGTH, out, in); + break; + case 256: + nettle_aes256_encrypt(&aes->ctx.ctx_256, ZIP_CRYPTO_AES_BLOCK_LENGTH, out, in); + break; + } + + return true; +} + +void +_zip_crypto_aes_free(_zip_crypto_aes_t *aes) { + if (aes == NULL) { + return; + } + + _zip_crypto_clear(aes, sizeof(*aes)); + free(aes); +} + + +_zip_crypto_hmac_t * +_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error) { + _zip_crypto_hmac_t *hmac; + + if ((hmac = (_zip_crypto_hmac_t *)malloc(sizeof(*hmac))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if (gnutls_hmac_init(hmac, GNUTLS_MAC_SHA1, secret, secret_length) < 0) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + free(hmac); + return NULL; + } + + return hmac; +} + + +void +_zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac) { + zip_uint8_t buf[ZIP_CRYPTO_SHA1_LENGTH]; + + if (hmac == NULL) { + return; + } + + gnutls_hmac_deinit(*hmac, buf); + _zip_crypto_clear(hmac, sizeof(*hmac)); + free(hmac); +} + + +ZIP_EXTERN bool +zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { + return gnutls_rnd(GNUTLS_RND_KEY, buffer, length) == 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_crypto_gnutls.h b/thirdparty/libzip-1.11.3/lib/zip_crypto_gnutls.h new file mode 100644 index 0000000..a6fa508 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_crypto_gnutls.h @@ -0,0 +1,68 @@ +/* + zip_crypto_gnutls.h -- definitions for GnuTLS wrapper. + Copyright (C) 2018-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef HAD_ZIP_CRYPTO_GNUTLS_H +#define HAD_ZIP_CRYPTO_GNUTLS_H + +#define HAVE_SECURE_RANDOM + +#include +#include + +#include + +#include + +typedef struct { + union { + struct aes128_ctx ctx_128; + struct aes192_ctx ctx_192; + struct aes256_ctx ctx_256; + } ctx; + zip_uint16_t key_size; +} _zip_crypto_aes_t; + +#define _zip_crypto_hmac_t gnutls_hmac_hd_t + +void _zip_crypto_aes_free(_zip_crypto_aes_t *aes); +bool _zip_crypto_aes_encrypt_block(_zip_crypto_aes_t *aes, const zip_uint8_t *in, zip_uint8_t *out); +_zip_crypto_aes_t *_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error); + +#define _zip_crypto_hmac(hmac, data, length) (gnutls_hmac(*(hmac), (data), (length)) == 0) +void _zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac); +_zip_crypto_hmac_t *_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error); +#define _zip_crypto_hmac_output(hmac, data) (gnutls_hmac_output(*(hmac), (data)), true) + +#define _zip_crypto_pbkdf2(key, key_length, salt, salt_length, iterations, output, output_length) (pbkdf2_hmac_sha1((key_length), (key), (iterations), (salt_length), (salt), (output_length), (output)), true) + +#endif /* HAD_ZIP_CRYPTO_GNUTLS_H */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_crypto_mbedtls.c b/thirdparty/libzip-1.11.3/lib/zip_crypto_mbedtls.c new file mode 100644 index 0000000..0ed66c0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_crypto_mbedtls.c @@ -0,0 +1,171 @@ +/* + zip_crypto_mbedtls.c -- mbed TLS wrapper + Copyright (C) 2018-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include "zipint.h" + +#include "zip_crypto.h" + +#include +#include +#include + +#include + +_zip_crypto_aes_t * +_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error) { + _zip_crypto_aes_t *aes; + + if ((aes = (_zip_crypto_aes_t *)malloc(sizeof(*aes))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + mbedtls_aes_init(aes); + mbedtls_aes_setkey_enc(aes, (const unsigned char *)key, (unsigned int)key_size); + + return aes; +} + +void +_zip_crypto_aes_free(_zip_crypto_aes_t *aes) { + if (aes == NULL) { + return; + } + + mbedtls_aes_free(aes); + free(aes); +} + + +_zip_crypto_hmac_t * +_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error) { + _zip_crypto_hmac_t *hmac; + + if (secret_length > INT_MAX) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((hmac = (_zip_crypto_hmac_t *)malloc(sizeof(*hmac))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + mbedtls_md_init(hmac); + + if (mbedtls_md_setup(hmac, mbedtls_md_info_from_type(MBEDTLS_MD_SHA1), 1) != 0) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + free(hmac); + return NULL; + } + + if (mbedtls_md_hmac_starts(hmac, (const unsigned char *)secret, (size_t)secret_length) != 0) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + free(hmac); + return NULL; + } + + return hmac; +} + + +void +_zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac) { + if (hmac == NULL) { + return; + } + + mbedtls_md_free(hmac); + free(hmac); +} + + +bool +_zip_crypto_pbkdf2(const zip_uint8_t *key, zip_uint64_t key_length, const zip_uint8_t *salt, zip_uint16_t salt_length, int iterations, zip_uint8_t *output, zip_uint64_t output_length) { + mbedtls_md_context_t sha1_ctx; + bool ok = true; + +#if MBEDTLS_VERSION_NUMBER < 0x03030000 + + mbedtls_md_init(&sha1_ctx); + + if (mbedtls_md_setup(&sha1_ctx, mbedtls_md_info_from_type(MBEDTLS_MD_SHA1), 1) != 0) { + ok = false; + } + + if (ok && mbedtls_pkcs5_pbkdf2_hmac(&sha1_ctx, (const unsigned char *)key, (size_t)key_length, (const unsigned char *)salt, (size_t)salt_length, (unsigned int)iterations, (uint32_t)output_length, (unsigned char *)output) != 0) { + ok = false; + } + + mbedtls_md_free(&sha1_ctx); + +#else + + ok = mbedtls_pkcs5_pbkdf2_hmac_ext(MBEDTLS_MD_SHA1, (const unsigned char *)key, (size_t)key_length, (const unsigned char *)salt, (size_t)salt_length, (unsigned int)iterations, (uint32_t)output_length, (unsigned char *)output) == 0; + +#endif // !defined(MBEDTLS_DEPRECATED_REMOVED) || MBEDTLS_VERSION_NUMBER < 0x03030000 + + return ok; +} + + +typedef struct { + mbedtls_entropy_context entropy; + mbedtls_ctr_drbg_context ctr_drbg; +} zip_random_context_t; + +ZIP_EXTERN bool +zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { + static zip_random_context_t *ctx = NULL; + const unsigned char *pers = "zip_crypto_mbedtls"; + + if (!ctx) { + ctx = (zip_random_context_t *)malloc(sizeof(zip_random_context_t)); + if (!ctx) { + return false; + } + mbedtls_entropy_init(&ctx->entropy); + mbedtls_ctr_drbg_init(&ctx->ctr_drbg); + if (mbedtls_ctr_drbg_seed(&ctx->ctr_drbg, mbedtls_entropy_func, &ctx->entropy, pers, strlen(pers)) != 0) { + mbedtls_ctr_drbg_free(&ctx->ctr_drbg); + mbedtls_entropy_free(&ctx->entropy); + free(ctx); + ctx = NULL; + return false; + } + } + + return mbedtls_ctr_drbg_random(&ctx->ctr_drbg, (unsigned char *)buffer, (size_t)length) == 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_crypto_mbedtls.h b/thirdparty/libzip-1.11.3/lib/zip_crypto_mbedtls.h new file mode 100644 index 0000000..30ce21c --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_crypto_mbedtls.h @@ -0,0 +1,56 @@ +/* + zip_crypto_mbedtls.h -- definitions for mbedtls wrapper + Copyright (C) 2018-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef HAD_ZIP_CRYPTO_MBEDTLS_H +#define HAD_ZIP_CRYPTO_MBEDTLS_H + +#define HAVE_SECURE_RANDOM + +#include +#include + +#define _zip_crypto_aes_t mbedtls_aes_context +#define _zip_crypto_hmac_t mbedtls_md_context_t + +_zip_crypto_aes_t *_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error); +#define _zip_crypto_aes_encrypt_block(aes, in, out) (mbedtls_aes_crypt_ecb((aes), MBEDTLS_AES_ENCRYPT, (in), (out)) == 0) +void _zip_crypto_aes_free(_zip_crypto_aes_t *aes); + +_zip_crypto_hmac_t *_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error); +#define _zip_crypto_hmac(hmac, data, length) (mbedtls_md_hmac_update((hmac), (data), (length)) == 0) +#define _zip_crypto_hmac_output(hmac, data) (mbedtls_md_hmac_finish((hmac), (data)) == 0) +void _zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac); + +bool _zip_crypto_pbkdf2(const zip_uint8_t *key, zip_uint64_t key_length, const zip_uint8_t *salt, zip_uint16_t salt_length, int iterations, zip_uint8_t *output, zip_uint64_t output_length); + +#endif /* HAD_ZIP_CRYPTO_MBEDTLS_H */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_crypto_openssl.c b/thirdparty/libzip-1.11.3/lib/zip_crypto_openssl.c new file mode 100644 index 0000000..9e9e8e7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_crypto_openssl.c @@ -0,0 +1,230 @@ +/* + zip_crypto_openssl.c -- OpenSSL wrapper. + Copyright (C) 2018-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include "zipint.h" + +#include "zip_crypto.h" + +#include +#include + +#ifdef USE_OPENSSL_3_API +static _zip_crypto_hmac_t* hmac_new() { + _zip_crypto_hmac_t *hmac = (_zip_crypto_hmac_t*)malloc(sizeof(*hmac)); + if (hmac != NULL) { + hmac->mac = NULL; + hmac->ctx = NULL; + } + return hmac; +} +static void hmac_free(_zip_crypto_hmac_t* hmac) { + if (hmac != NULL) { + if (hmac->ctx != NULL) { + EVP_MAC_CTX_free(hmac->ctx); + } + if (hmac->mac != NULL) { + EVP_MAC_free(hmac->mac); + } + free(hmac); + } +} +#endif + +_zip_crypto_aes_t * +_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error) { + _zip_crypto_aes_t *aes; + const EVP_CIPHER* cipher_type; + + switch (key_size) { + case 128: + cipher_type = EVP_aes_128_ecb(); + break; + case 192: + cipher_type = EVP_aes_192_ecb(); + break; + case 256: + cipher_type = EVP_aes_256_ecb(); + break; + default: + zip_error_set(error, ZIP_ER_INTERNAL, 0); + return NULL; + } + +#ifdef USE_OPENSSL_1_0_API + if ((aes = (_zip_crypto_aes_t *)malloc(sizeof(*aes))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + memset(aes, 0, sizeof(*aes)); +#else + if ((aes = EVP_CIPHER_CTX_new()) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } +#endif + + if (EVP_EncryptInit_ex(aes, cipher_type, NULL, key, NULL) != 1) { +#ifdef USE_OPENSSL_1_0_API + free(aes); +#else + EVP_CIPHER_CTX_free(aes); +#endif + zip_error_set(error, ZIP_ER_INTERNAL, 0); + return NULL; + } + + return aes; +} + +void +_zip_crypto_aes_free(_zip_crypto_aes_t *aes) { + if (aes == NULL) { + return; + } + +#ifdef USE_OPENSSL_1_0_API + EVP_CIPHER_CTX_cleanup(aes); + _zip_crypto_clear(aes, sizeof(*aes)); + free(aes); +#else + EVP_CIPHER_CTX_free(aes); +#endif +} + + +bool +_zip_crypto_aes_encrypt_block(_zip_crypto_aes_t *aes, const zip_uint8_t *in, zip_uint8_t *out) { + int len = 0; + if (EVP_EncryptUpdate(aes, out, &len, in, ZIP_CRYPTO_AES_BLOCK_LENGTH) != 1 + || len != ZIP_CRYPTO_AES_BLOCK_LENGTH) { + return false; + } + return true; +} + + +_zip_crypto_hmac_t * +_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error) { + _zip_crypto_hmac_t *hmac; + + if (secret_length > INT_MAX) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + +#ifdef USE_OPENSSL_3_API + if ((hmac = hmac_new()) == NULL + || (hmac->mac = EVP_MAC_fetch(NULL, "HMAC", "provider=default")) == NULL + || (hmac->ctx = EVP_MAC_CTX_new(hmac->mac)) == NULL) { + hmac_free(hmac); + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + { + OSSL_PARAM params[2]; + params[0] = OSSL_PARAM_construct_utf8_string("digest", "SHA1", 0); + params[1] = OSSL_PARAM_construct_end(); + + if (!EVP_MAC_init(hmac->ctx, (const unsigned char *)secret, secret_length, params)) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + hmac_free(hmac); + return NULL; + } + } +#else +#ifdef USE_OPENSSL_1_0_API + if ((hmac = (_zip_crypto_hmac_t *)malloc(sizeof(*hmac))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + HMAC_CTX_init(hmac); +#else + if ((hmac = HMAC_CTX_new()) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } +#endif + + if (HMAC_Init_ex(hmac, secret, (int)secret_length, EVP_sha1(), NULL) != 1) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); +#ifdef USE_OPENSSL_1_0_API + free(hmac); +#else + HMAC_CTX_free(hmac); +#endif + return NULL; + } +#endif + + return hmac; +} + + +void +_zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac) { + if (hmac == NULL) { + return; + } + +#if defined(USE_OPENSSL_3_API) + hmac_free(hmac); +#elif defined(USE_OPENSSL_1_0_API) + HMAC_CTX_cleanup(hmac); + _zip_crypto_clear(hmac, sizeof(*hmac)); + free(hmac); +#else + HMAC_CTX_free(hmac); +#endif +} + + +bool +_zip_crypto_hmac_output(_zip_crypto_hmac_t *hmac, zip_uint8_t *data) { +#ifdef USE_OPENSSL_3_API + size_t length = 0; + return EVP_MAC_final(hmac->ctx, data, &length, ZIP_CRYPTO_SHA1_LENGTH) == 1 && length == ZIP_CRYPTO_SHA1_LENGTH; +#else + unsigned int length = 0; + return HMAC_Final(hmac, data, &length) == 1 && length == ZIP_CRYPTO_SHA1_LENGTH; +#endif +} + + +ZIP_EXTERN bool +zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { + return RAND_bytes(buffer, length) == 1; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_crypto_openssl.h b/thirdparty/libzip-1.11.3/lib/zip_crypto_openssl.h new file mode 100644 index 0000000..e593ec5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_crypto_openssl.h @@ -0,0 +1,73 @@ +/* + zip_crypto_openssl.h -- definitions for OpenSSL wrapper. + Copyright (C) 2018-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef HAD_ZIP_CRYPTO_OPENSSL_H +#define HAD_ZIP_CRYPTO_OPENSSL_H + +#define HAVE_SECURE_RANDOM + +#include +#include + +#if OPENSSL_VERSION_NUMBER < 0x1010000fL || (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x02070000fL) +#define USE_OPENSSL_1_0_API +#elif OPENSSL_VERSION_NUMBER < 0x3000000fL +#define USE_OPENSSL_1_1_API +#else +#define USE_OPENSSL_3_API +#endif + +#define _zip_crypto_aes_t EVP_CIPHER_CTX +#ifdef USE_OPENSSL_3_API +struct _zip_crypto_hmac_t { + EVP_MAC *mac; + EVP_MAC_CTX *ctx; +}; +typedef struct _zip_crypto_hmac_t _zip_crypto_hmac_t; +#define _zip_crypto_hmac(hmac, data, length) (EVP_MAC_update((hmac->ctx), (data), (length)) == 1) +#else +#define _zip_crypto_hmac_t HMAC_CTX +#define _zip_crypto_hmac(hmac, data, length) (HMAC_Update((hmac), (data), (length)) == 1) +#endif + +void _zip_crypto_aes_free(_zip_crypto_aes_t *aes); +bool _zip_crypto_aes_encrypt_block(_zip_crypto_aes_t *aes, const zip_uint8_t *in, zip_uint8_t *out); +_zip_crypto_aes_t *_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error); + +void _zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac); +_zip_crypto_hmac_t *_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error); +bool _zip_crypto_hmac_output(_zip_crypto_hmac_t *hmac, zip_uint8_t *data); + +#define _zip_crypto_pbkdf2(key, key_length, salt, salt_length, iterations, output, output_length) (PKCS5_PBKDF2_HMAC_SHA1((const char *)(key), (key_length), (salt), (salt_length), (iterations), (output_length), (output))) + +#endif /* HAD_ZIP_CRYPTO_OPENSSL_H */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_crypto_win.c b/thirdparty/libzip-1.11.3/lib/zip_crypto_win.c new file mode 100644 index 0000000..6d92303 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_crypto_win.c @@ -0,0 +1,492 @@ +/* + zip_crypto_win.c -- Windows Crypto API wrapper. + Copyright (C) 2018-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include +#include + +#include "zipint.h" + +#include "zip_crypto.h" + +#include + +#include + +#pragma comment(lib, "bcrypt.lib") + +/* + +This code is using the Cryptography API: Next Generation (CNG) +https://docs.microsoft.com/en-us/windows/desktop/seccng/cng-portal + +This API is supported on + - Windows Vista or later (client OS) + - Windows Server 2008 (server OS) + - Windows Embedded Compact 2013 (don't know about Windows Embedded Compact 7) + +The code was developed for Windows Embedded Compact 2013 (WEC2013), +but should be working for all of the above mentioned OSes. + +There are 2 restrictions for WEC2013, Windows Vista and Windows Server 2008: + +1.) The function "BCryptDeriveKeyPBKDF2" is not available + +I found some code which is implementing this function using the deprecated Crypto API here: +https://www.idrix.fr/Root/content/view/37/54/ + +I took this code and converted it to the newer CNG API. The original code was more +flexible, but this is not needed here so i refactored it a bit and just kept what is needed. + +The define "HAS_BCRYPTDERIVEKEYPBKDF2" controls whether "BCryptDeriveKeyPBKDF2" +of the CNG API is used or not. This define must not be set if you are compiling for WEC2013 or Windows Vista. + + +2.) "BCryptCreateHash" can't manage the memory needed for the hash object internally + +On Windows 7 or later it is possible to pass NULL for the hash object buffer. +This is not supported on WEC2013, so we have to handle the memory allocation/deallocation ourselves. +There is no #ifdef to control that, because this is working for all supported OSes. + +*/ + +#if !defined(WINCE) && !defined(__MINGW32__) +#define HAS_BCRYPTDERIVEKEYPBKDF2 +#endif + +#ifdef HAS_BCRYPTDERIVEKEYPBKDF2 + +bool +_zip_crypto_pbkdf2(const zip_uint8_t *key, zip_uint64_t key_length, const zip_uint8_t *salt, zip_uint16_t salt_length, zip_uint16_t iterations, zip_uint8_t *output, zip_uint16_t output_length) { + BCRYPT_ALG_HANDLE hAlgorithm = NULL; + bool result; + + if (!BCRYPT_SUCCESS(BCryptOpenAlgorithmProvider(&hAlgorithm, BCRYPT_SHA1_ALGORITHM, NULL, BCRYPT_ALG_HANDLE_HMAC_FLAG))) { + return false; + } + + result = BCRYPT_SUCCESS(BCryptDeriveKeyPBKDF2(hAlgorithm, (PUCHAR)key, (ULONG)key_length, (PUCHAR)salt, salt_length, iterations, output, output_length, 0)); + + BCryptCloseAlgorithmProvider(hAlgorithm, 0); + + return result; +} + +#else + +#include + +#define DIGEST_SIZE 20 +#define BLOCK_SIZE 64 + +typedef struct { + BCRYPT_ALG_HANDLE hAlgorithm; + BCRYPT_HASH_HANDLE hInnerHash; + BCRYPT_HASH_HANDLE hOuterHash; + ULONG cbHashObject; + PUCHAR pbInnerHash; + PUCHAR pbOuterHash; +} PRF_CTX; + +static void +hmacFree(PRF_CTX *pContext) { + if (pContext->hOuterHash) + BCryptDestroyHash(pContext->hOuterHash); + if (pContext->hInnerHash) + BCryptDestroyHash(pContext->hInnerHash); + free(pContext->pbOuterHash); + free(pContext->pbInnerHash); + if (pContext->hAlgorithm) + BCryptCloseAlgorithmProvider(pContext->hAlgorithm, 0); +} + +static BOOL +hmacPrecomputeDigest(BCRYPT_HASH_HANDLE hHash, PUCHAR pbPassword, DWORD cbPassword, BYTE mask) { + BYTE buffer[BLOCK_SIZE]; + DWORD i; + + if (cbPassword > BLOCK_SIZE) { + return FALSE; + } + + memset(buffer, mask, sizeof(buffer)); + + for (i = 0; i < cbPassword; ++i) { + buffer[i] = (char)(pbPassword[i] ^ mask); + } + + return BCRYPT_SUCCESS(BCryptHashData(hHash, buffer, sizeof(buffer), 0)); +} + +static BOOL +hmacInit(PRF_CTX *pContext, PUCHAR pbPassword, DWORD cbPassword) { + BOOL bStatus = FALSE; + ULONG cbResult; + BYTE key[DIGEST_SIZE]; + + if (!BCRYPT_SUCCESS(BCryptOpenAlgorithmProvider(&pContext->hAlgorithm, BCRYPT_SHA1_ALGORITHM, NULL, 0)) || !BCRYPT_SUCCESS(BCryptGetProperty(pContext->hAlgorithm, BCRYPT_OBJECT_LENGTH, (PUCHAR)&pContext->cbHashObject, sizeof(pContext->cbHashObject), &cbResult, 0)) || ((pContext->pbInnerHash = malloc(pContext->cbHashObject)) == NULL) || ((pContext->pbOuterHash = malloc(pContext->cbHashObject)) == NULL) || !BCRYPT_SUCCESS(BCryptCreateHash(pContext->hAlgorithm, &pContext->hInnerHash, pContext->pbInnerHash, pContext->cbHashObject, NULL, 0, 0)) || !BCRYPT_SUCCESS(BCryptCreateHash(pContext->hAlgorithm, &pContext->hOuterHash, pContext->pbOuterHash, pContext->cbHashObject, NULL, 0, 0))) { + goto hmacInit_end; + } + + if (cbPassword > BLOCK_SIZE) { + BCRYPT_HASH_HANDLE hHash = NULL; + PUCHAR pbHashObject = malloc(pContext->cbHashObject); + if (pbHashObject == NULL) { + goto hmacInit_end; + } + + bStatus = BCRYPT_SUCCESS(BCryptCreateHash(pContext->hAlgorithm, &hHash, pbHashObject, pContext->cbHashObject, NULL, 0, 0)) && BCRYPT_SUCCESS(BCryptHashData(hHash, pbPassword, cbPassword, 0)) && BCRYPT_SUCCESS(BCryptGetProperty(hHash, BCRYPT_HASH_LENGTH, (PUCHAR)&cbPassword, sizeof(cbPassword), &cbResult, 0)) && BCRYPT_SUCCESS(BCryptFinishHash(hHash, key, cbPassword, 0)); + + if (hHash) + BCryptDestroyHash(hHash); + free(pbHashObject); + + if (!bStatus) { + goto hmacInit_end; + } + + pbPassword = key; + } + + bStatus = hmacPrecomputeDigest(pContext->hInnerHash, pbPassword, cbPassword, 0x36) && hmacPrecomputeDigest(pContext->hOuterHash, pbPassword, cbPassword, 0x5C); + +hmacInit_end: + + if (bStatus == FALSE) + hmacFree(pContext); + + return bStatus; +} + +static BOOL +hmacCalculateInternal(BCRYPT_HASH_HANDLE hHashTemplate, PUCHAR pbData, DWORD cbData, PUCHAR pbOutput, DWORD cbOutput, DWORD cbHashObject) { + BOOL success = FALSE; + BCRYPT_HASH_HANDLE hHash = NULL; + PUCHAR pbHashObject = malloc(cbHashObject); + + if (pbHashObject == NULL) { + return FALSE; + } + + if (BCRYPT_SUCCESS(BCryptDuplicateHash(hHashTemplate, &hHash, pbHashObject, cbHashObject, 0))) { + success = BCRYPT_SUCCESS(BCryptHashData(hHash, pbData, cbData, 0)) && BCRYPT_SUCCESS(BCryptFinishHash(hHash, pbOutput, cbOutput, 0)); + + BCryptDestroyHash(hHash); + } + + free(pbHashObject); + + return success; +} + +static BOOL +hmacCalculate(PRF_CTX *pContext, PUCHAR pbData, DWORD cbData, PUCHAR pbDigest) { + DWORD cbResult; + DWORD cbHashObject; + + return BCRYPT_SUCCESS(BCryptGetProperty(pContext->hAlgorithm, BCRYPT_OBJECT_LENGTH, (PUCHAR)&cbHashObject, sizeof(cbHashObject), &cbResult, 0)) && hmacCalculateInternal(pContext->hInnerHash, pbData, cbData, pbDigest, DIGEST_SIZE, cbHashObject) && hmacCalculateInternal(pContext->hOuterHash, pbDigest, DIGEST_SIZE, pbDigest, DIGEST_SIZE, cbHashObject); +} + +static void +myxor(LPBYTE ptr1, LPBYTE ptr2, DWORD dwLen) { + while (dwLen--) + *ptr1++ ^= *ptr2++; +} + +BOOL +pbkdf2(PUCHAR pbPassword, ULONG cbPassword, PUCHAR pbSalt, ULONG cbSalt, DWORD cIterations, PUCHAR pbDerivedKey, ULONG cbDerivedKey) { + BOOL bStatus = FALSE; + DWORD l, r, dwULen, i, j; + BYTE Ti[DIGEST_SIZE]; + BYTE V[DIGEST_SIZE]; + LPBYTE U = malloc(max((cbSalt + 4), DIGEST_SIZE)); + PRF_CTX prfCtx = {0}; + + if (U == NULL) { + return FALSE; + } + + if (pbPassword == NULL || cbPassword == 0 || pbSalt == NULL || cbSalt == 0 || cIterations == 0 || pbDerivedKey == NULL || cbDerivedKey == 0) { + free(U); + return FALSE; + } + + if (!hmacInit(&prfCtx, pbPassword, cbPassword)) { + goto PBKDF2_end; + } + + l = (DWORD)ceil((double)cbDerivedKey / (double)DIGEST_SIZE); + r = cbDerivedKey - (l - 1) * DIGEST_SIZE; + + for (i = 1; i <= l; i++) { + ZeroMemory(Ti, DIGEST_SIZE); + for (j = 0; j < cIterations; j++) { + if (j == 0) { + /* construct first input for PRF */ + (void)memcpy_s(U, cbSalt, pbSalt, cbSalt); + U[cbSalt] = (BYTE)((i & 0xFF000000) >> 24); + U[cbSalt + 1] = (BYTE)((i & 0x00FF0000) >> 16); + U[cbSalt + 2] = (BYTE)((i & 0x0000FF00) >> 8); + U[cbSalt + 3] = (BYTE)((i & 0x000000FF)); + dwULen = cbSalt + 4; + } + else { + (void)memcpy_s(U, DIGEST_SIZE, V, DIGEST_SIZE); + dwULen = DIGEST_SIZE; + } + + if (!hmacCalculate(&prfCtx, U, dwULen, V)) { + goto PBKDF2_end; + } + + myxor(Ti, V, DIGEST_SIZE); + } + + if (i != l) { + (void)memcpy_s(&pbDerivedKey[(i - 1) * DIGEST_SIZE], cbDerivedKey - (i - 1) * DIGEST_SIZE, Ti, DIGEST_SIZE); + } + else { + /* Take only the first r bytes */ + (void)memcpy_s(&pbDerivedKey[(i - 1) * DIGEST_SIZE], cbDerivedKey - (i - 1) * DIGEST_SIZE, Ti, r); + } + } + + bStatus = TRUE; + +PBKDF2_end: + + hmacFree(&prfCtx); + free(U); + return bStatus; +} + +bool +_zip_crypto_pbkdf2(const zip_uint8_t *key, zip_uint64_t key_length, const zip_uint8_t *salt, zip_uint16_t salt_length, zip_uint16_t iterations, zip_uint8_t *output, zip_uint16_t output_length) { + return (key_length <= ZIP_UINT32_MAX) && pbkdf2((PUCHAR)key, (ULONG)key_length, (PUCHAR)salt, salt_length, iterations, output, output_length); +} + +#endif + + +struct _zip_crypto_aes_s { + BCRYPT_ALG_HANDLE hAlgorithm; + BCRYPT_KEY_HANDLE hKey; + ULONG cbKeyObject; + PUCHAR pbKeyObject; +}; + +_zip_crypto_aes_t * +_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error) { + _zip_crypto_aes_t *aes = (_zip_crypto_aes_t *)calloc(1, sizeof(*aes)); + + ULONG cbResult; + ULONG key_length = key_size / 8; + + if (aes == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if (!BCRYPT_SUCCESS(BCryptOpenAlgorithmProvider(&aes->hAlgorithm, BCRYPT_AES_ALGORITHM, NULL, 0))) { + _zip_crypto_aes_free(aes); + return NULL; + } + + if (!BCRYPT_SUCCESS(BCryptSetProperty(aes->hAlgorithm, BCRYPT_CHAINING_MODE, (PUCHAR)BCRYPT_CHAIN_MODE_ECB, sizeof(BCRYPT_CHAIN_MODE_ECB), 0))) { + _zip_crypto_aes_free(aes); + return NULL; + } + + if (!BCRYPT_SUCCESS(BCryptGetProperty(aes->hAlgorithm, BCRYPT_OBJECT_LENGTH, (PUCHAR)&aes->cbKeyObject, sizeof(aes->cbKeyObject), &cbResult, 0))) { + _zip_crypto_aes_free(aes); + return NULL; + } + + aes->pbKeyObject = malloc(aes->cbKeyObject); + if (aes->pbKeyObject == NULL) { + _zip_crypto_aes_free(aes); + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if (!BCRYPT_SUCCESS(BCryptGenerateSymmetricKey(aes->hAlgorithm, &aes->hKey, aes->pbKeyObject, aes->cbKeyObject, (PUCHAR)key, key_length, 0))) { + _zip_crypto_aes_free(aes); + return NULL; + } + + return aes; +} + +void +_zip_crypto_aes_free(_zip_crypto_aes_t *aes) { + if (aes == NULL) { + return; + } + + if (aes->hKey != NULL) { + BCryptDestroyKey(aes->hKey); + } + + if (aes->pbKeyObject != NULL) { + free(aes->pbKeyObject); + } + + if (aes->hAlgorithm != NULL) { + BCryptCloseAlgorithmProvider(aes->hAlgorithm, 0); + } + + free(aes); +} + +bool +_zip_crypto_aes_encrypt_block(_zip_crypto_aes_t *aes, const zip_uint8_t *in, zip_uint8_t *out) { + ULONG cbResult; + NTSTATUS status = BCryptEncrypt(aes->hKey, (PUCHAR)in, ZIP_CRYPTO_AES_BLOCK_LENGTH, NULL, NULL, 0, (PUCHAR)out, ZIP_CRYPTO_AES_BLOCK_LENGTH, &cbResult, 0); + return BCRYPT_SUCCESS(status); +} + +struct _zip_crypto_hmac_s { + BCRYPT_ALG_HANDLE hAlgorithm; + BCRYPT_HASH_HANDLE hHash; + DWORD cbHashObject; + PUCHAR pbHashObject; + DWORD cbHash; + PUCHAR pbHash; +}; + +/* https://code.msdn.microsoft.com/windowsdesktop/Hmac-Computation-Sample-11fe8ec1/sourcecode?fileId=42820&pathId=283874677 */ + +_zip_crypto_hmac_t * +_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error) { + NTSTATUS status; + ULONG cbResult; + _zip_crypto_hmac_t *hmac; + + if (secret_length > INT_MAX) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + hmac = (_zip_crypto_hmac_t *)calloc(1, sizeof(*hmac)); + + if (hmac == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + status = BCryptOpenAlgorithmProvider(&hmac->hAlgorithm, BCRYPT_SHA1_ALGORITHM, NULL, BCRYPT_ALG_HANDLE_HMAC_FLAG); + if (!BCRYPT_SUCCESS(status)) { + _zip_crypto_hmac_free(hmac); + return NULL; + } + + status = BCryptGetProperty(hmac->hAlgorithm, BCRYPT_OBJECT_LENGTH, (PUCHAR)&hmac->cbHashObject, sizeof(hmac->cbHashObject), &cbResult, 0); + if (!BCRYPT_SUCCESS(status)) { + _zip_crypto_hmac_free(hmac); + return NULL; + } + + hmac->pbHashObject = malloc(hmac->cbHashObject); + if (hmac->pbHashObject == NULL) { + _zip_crypto_hmac_free(hmac); + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + status = BCryptGetProperty(hmac->hAlgorithm, BCRYPT_HASH_LENGTH, (PUCHAR)&hmac->cbHash, sizeof(hmac->cbHash), &cbResult, 0); + if (!BCRYPT_SUCCESS(status)) { + _zip_crypto_hmac_free(hmac); + return NULL; + } + + hmac->pbHash = malloc(hmac->cbHash); + if (hmac->pbHash == NULL) { + _zip_crypto_hmac_free(hmac); + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + status = BCryptCreateHash(hmac->hAlgorithm, &hmac->hHash, hmac->pbHashObject, hmac->cbHashObject, (PUCHAR)secret, (ULONG)secret_length, 0); + if (!BCRYPT_SUCCESS(status)) { + _zip_crypto_hmac_free(hmac); + return NULL; + } + + return hmac; +} + +void +_zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac) { + if (hmac == NULL) { + return; + } + + if (hmac->hHash != NULL) { + BCryptDestroyHash(hmac->hHash); + } + + if (hmac->pbHash != NULL) { + free(hmac->pbHash); + } + + if (hmac->pbHashObject != NULL) { + free(hmac->pbHashObject); + } + + if (hmac->hAlgorithm) { + BCryptCloseAlgorithmProvider(hmac->hAlgorithm, 0); + } + + free(hmac); +} + +bool +_zip_crypto_hmac(_zip_crypto_hmac_t *hmac, zip_uint8_t *data, zip_uint64_t length) { + if (hmac == NULL || length > ULONG_MAX) { + return false; + } + + return BCRYPT_SUCCESS(BCryptHashData(hmac->hHash, data, (ULONG)length, 0)); +} + +bool +_zip_crypto_hmac_output(_zip_crypto_hmac_t *hmac, zip_uint8_t *data) { + if (hmac == NULL) { + return false; + } + + return BCRYPT_SUCCESS(BCryptFinishHash(hmac->hHash, data, hmac->cbHash, 0)); +} + +ZIP_EXTERN bool +zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { + return BCRYPT_SUCCESS(BCryptGenRandom(NULL, buffer, length, BCRYPT_USE_SYSTEM_PREFERRED_RNG)); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_crypto_win.h b/thirdparty/libzip-1.11.3/lib/zip_crypto_win.h new file mode 100644 index 0000000..3f05b62 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_crypto_win.h @@ -0,0 +1,53 @@ +/* + zip_crypto_win.h -- Windows Crypto API wrapper. + Copyright (C) 2018-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef HAD_ZIP_CRYPTO_WIN_H +#define HAD_ZIP_CRYPTO_WIN_H + +#define HAVE_SECURE_RANDOM + +typedef struct _zip_crypto_aes_s _zip_crypto_aes_t; +typedef struct _zip_crypto_hmac_s _zip_crypto_hmac_t; + +void _zip_crypto_aes_free(_zip_crypto_aes_t *aes); +_zip_crypto_aes_t *_zip_crypto_aes_new(const zip_uint8_t *key, zip_uint16_t key_size, zip_error_t *error); +bool _zip_crypto_aes_encrypt_block(_zip_crypto_aes_t *aes, const zip_uint8_t *in, zip_uint8_t *out); + +bool _zip_crypto_pbkdf2(const zip_uint8_t *key, zip_uint64_t key_length, const zip_uint8_t *salt, zip_uint16_t salt_length, zip_uint16_t iterations, zip_uint8_t *output, zip_uint16_t output_length); + +_zip_crypto_hmac_t *_zip_crypto_hmac_new(const zip_uint8_t *secret, zip_uint64_t secret_length, zip_error_t *error); +void _zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac); +bool _zip_crypto_hmac(_zip_crypto_hmac_t *hmac, zip_uint8_t *data, zip_uint64_t length); +bool _zip_crypto_hmac_output(_zip_crypto_hmac_t *hmac, zip_uint8_t *data); + +#endif /* HAD_ZIP_CRYPTO_WIN_H */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_delete.c b/thirdparty/libzip-1.11.3/lib/zip_delete.c new file mode 100644 index 0000000..4eefdd9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_delete.c @@ -0,0 +1,68 @@ +/* + zip_delete.c -- delete file from zip archive + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_delete(zip_t *za, zip_uint64_t idx) { + const char *name; + + if (idx >= za->nentry) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (ZIP_IS_RDONLY(za)) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + + if ((name = _zip_get_name(za, idx, 0, &za->error)) == NULL) { + return -1; + } + + if (!_zip_hash_delete(za->names, (const zip_uint8_t *)name, &za->error)) { + return -1; + } + + /* allow duplicate file names, because the file will + * be removed directly afterwards */ + if (_zip_unchange(za, idx, 1) != 0) + return -1; + + za->entry[idx].deleted = 1; + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_dir_add.c b/thirdparty/libzip-1.11.3/lib/zip_dir_add.c new file mode 100644 index 0000000..01d8ec9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_dir_add.c @@ -0,0 +1,92 @@ +/* + zip_dir_add.c -- add directory + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include + +#include "zipint.h" + + +/* NOTE: Signed due to -1 on error. See zip_add.c for more details. */ + +ZIP_EXTERN zip_int64_t +zip_dir_add(zip_t *za, const char *name, zip_flags_t flags) { + size_t len; + zip_int64_t idx; + char *s; + zip_source_t *source; + + if (ZIP_IS_RDONLY(za)) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + + if (name == NULL) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + s = NULL; + len = strlen(name); + + if (name[len - 1] != '/') { + if (len > SIZE_MAX - 2 || (s = (char *)malloc(len + 2)) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + (void)strncpy_s(s, len + 2, name, len); + s[len] = '/'; + s[len + 1] = '\0'; + } + + if ((source = zip_source_buffer(za, NULL, 0, 0)) == NULL) { + free(s); + return -1; + } + + idx = _zip_file_replace(za, ZIP_UINT64_MAX, s ? s : name, source, flags); + + free(s); + + if (idx < 0) + zip_source_free(source); + else { + if (zip_file_set_external_attributes(za, (zip_uint64_t)idx, 0, ZIP_OPSYS_DEFAULT, ZIP_EXT_ATTRIB_DEFAULT_DIR) < 0) { + zip_delete(za, (zip_uint64_t)idx); + return -1; + } + } + + return idx; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_dirent.c b/thirdparty/libzip-1.11.3/lib/zip_dirent.c new file mode 100644 index 0000000..7476ac0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_dirent.c @@ -0,0 +1,1320 @@ +/* + zip_dirent.c -- read directory entry (local or central), clean dirent + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include +#include +#include +#include +#include + +#include "zipint.h" + +static zip_string_t *_zip_dirent_process_ef_utf_8(const zip_dirent_t *de, zip_uint16_t id, zip_string_t *str, bool check_consistency); +static zip_extra_field_t *_zip_ef_utf8(zip_uint16_t, zip_string_t *, zip_error_t *); +static bool _zip_dirent_process_winzip_aes(zip_dirent_t *de, zip_error_t *error); + + +void +_zip_cdir_free(zip_cdir_t *cd) { + zip_uint64_t i; + + if (cd == NULL) { + return; + } + + for (i = 0; i < cd->nentry; i++) + _zip_entry_finalize(cd->entry + i); + free(cd->entry); + _zip_string_free(cd->comment); + free(cd); +} + + +zip_cdir_t * +_zip_cdir_new(zip_error_t *error) { + zip_cdir_t *cd; + + if ((cd = (zip_cdir_t *)malloc(sizeof(*cd))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + cd->entry = NULL; + cd->nentry = cd->nentry_alloc = 0; + cd->size = cd->offset = 0; + cd->comment = NULL; + cd->is_zip64 = false; + + return cd; +} + + +bool +_zip_cdir_grow(zip_cdir_t *cd, zip_uint64_t additional_entries, zip_error_t *error) { + zip_uint64_t i, new_alloc; + zip_entry_t *new_entry; + + if (additional_entries == 0) { + return true; + } + + new_alloc = cd->nentry_alloc + additional_entries; + + if (new_alloc < additional_entries || new_alloc > SIZE_MAX / sizeof(*(cd->entry))) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return false; + } + + if ((new_entry = (zip_entry_t *)realloc(cd->entry, sizeof(*(cd->entry)) * (size_t)new_alloc)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return false; + } + + cd->entry = new_entry; + + for (i = cd->nentry; i < new_alloc; i++) { + _zip_entry_init(cd->entry + i); + } + + cd->nentry = cd->nentry_alloc = new_alloc; + + return true; +} + + +zip_int64_t +_zip_cdir_write(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivors) { + zip_uint64_t offset, size; + zip_string_t *comment; + zip_uint8_t buf[EOCDLEN + EOCD64LEN + EOCD64LOCLEN]; + zip_buffer_t *buffer; + zip_int64_t off; + zip_uint64_t i; + zip_uint32_t cdir_crc; + + if ((off = zip_source_tell_write(za->src)) < 0) { + zip_error_set_from_source(&za->error, za->src); + return -1; + } + offset = (zip_uint64_t)off; + + if (ZIP_WANT_TORRENTZIP(za)) { + cdir_crc = (zip_uint32_t)crc32(0, NULL, 0); + za->write_crc = &cdir_crc; + } + + for (i = 0; i < survivors; i++) { + zip_entry_t *entry = za->entry + filelist[i].idx; + + if (_zip_dirent_write(za, entry->changes ? entry->changes : entry->orig, ZIP_FL_CENTRAL) < 0) { + za->write_crc = NULL; + return -1; + } + } + + za->write_crc = NULL; + + if ((off = zip_source_tell_write(za->src)) < 0) { + zip_error_set_from_source(&za->error, za->src); + return -1; + } + size = (zip_uint64_t)off - offset; + + if ((buffer = _zip_buffer_new(buf, sizeof(buf))) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + + if (survivors > ZIP_UINT16_MAX || offset > ZIP_UINT32_MAX || size > ZIP_UINT32_MAX) { + _zip_buffer_put(buffer, EOCD64_MAGIC, 4); + _zip_buffer_put_64(buffer, EOCD64LEN - 12); + _zip_buffer_put_16(buffer, 45); + _zip_buffer_put_16(buffer, 45); + _zip_buffer_put_32(buffer, 0); + _zip_buffer_put_32(buffer, 0); + _zip_buffer_put_64(buffer, survivors); + _zip_buffer_put_64(buffer, survivors); + _zip_buffer_put_64(buffer, size); + _zip_buffer_put_64(buffer, offset); + _zip_buffer_put(buffer, EOCD64LOC_MAGIC, 4); + _zip_buffer_put_32(buffer, 0); + _zip_buffer_put_64(buffer, offset + size); + _zip_buffer_put_32(buffer, 1); + } + + _zip_buffer_put(buffer, EOCD_MAGIC, 4); + _zip_buffer_put_32(buffer, 0); + _zip_buffer_put_16(buffer, (zip_uint16_t)(survivors >= ZIP_UINT16_MAX ? ZIP_UINT16_MAX : survivors)); + _zip_buffer_put_16(buffer, (zip_uint16_t)(survivors >= ZIP_UINT16_MAX ? ZIP_UINT16_MAX : survivors)); + _zip_buffer_put_32(buffer, size >= ZIP_UINT32_MAX ? ZIP_UINT32_MAX : (zip_uint32_t)size); + _zip_buffer_put_32(buffer, offset >= ZIP_UINT32_MAX ? ZIP_UINT32_MAX : (zip_uint32_t)offset); + + comment = za->comment_changed ? za->comment_changes : za->comment_orig; + + if (ZIP_WANT_TORRENTZIP(za)) { + _zip_buffer_put_16(buffer, TORRENTZIP_SIGNATURE_LENGTH + TORRENTZIP_CRC_LENGTH); + } + else { + _zip_buffer_put_16(buffer, (zip_uint16_t)(comment ? comment->length : 0)); + } + + + if (!_zip_buffer_ok(buffer)) { + zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); + _zip_buffer_free(buffer); + return -1; + } + + if (_zip_write(za, _zip_buffer_data(buffer), _zip_buffer_offset(buffer)) < 0) { + _zip_buffer_free(buffer); + return -1; + } + + _zip_buffer_free(buffer); + + if (ZIP_WANT_TORRENTZIP(za)) { + char torrentzip_comment[TORRENTZIP_SIGNATURE_LENGTH + TORRENTZIP_CRC_LENGTH + 1]; + snprintf(torrentzip_comment, sizeof(torrentzip_comment), TORRENTZIP_SIGNATURE "%08X", cdir_crc); + + if (_zip_write(za, torrentzip_comment, strlen(torrentzip_comment)) < 0) { + return -1; + } + } + else if (comment != NULL) { + if (_zip_write(za, comment->raw, comment->length) < 0) { + return -1; + } + } + + return (zip_int64_t)size; +} + + +zip_dirent_t * +_zip_dirent_clone(const zip_dirent_t *sde) { + zip_dirent_t *tde; + + if ((tde = (zip_dirent_t *)malloc(sizeof(*tde))) == NULL) + return NULL; + + if (sde) + (void)memcpy_s(tde, sizeof(*tde), sde, sizeof(*sde)); + else + _zip_dirent_init(tde); + + tde->changed = 0; + tde->cloned = 1; + + return tde; +} + + +void +_zip_dirent_finalize(zip_dirent_t *zde) { + if (!zde->cloned || zde->changed & ZIP_DIRENT_FILENAME) { + _zip_string_free(zde->filename); + zde->filename = NULL; + } + if (!zde->cloned || zde->changed & ZIP_DIRENT_EXTRA_FIELD) { + _zip_ef_free(zde->extra_fields); + zde->extra_fields = NULL; + } + if (!zde->cloned || zde->changed & ZIP_DIRENT_COMMENT) { + _zip_string_free(zde->comment); + zde->comment = NULL; + } + if (!zde->cloned || zde->changed & ZIP_DIRENT_PASSWORD) { + if (zde->password) { + _zip_crypto_clear(zde->password, strlen(zde->password)); + } + free(zde->password); + zde->password = NULL; + } +} + + +void +_zip_dirent_free(zip_dirent_t *zde) { + if (zde == NULL) + return; + + _zip_dirent_finalize(zde); + free(zde); +} + + +void +_zip_dirent_init(zip_dirent_t *de) { + de->changed = 0; + de->local_extra_fields_read = 0; + de->cloned = 0; + + de->crc_valid = true; + de->last_mod_mtime_valid = false; + de->version_madeby = 63 | (ZIP_OPSYS_DEFAULT << 8); + de->version_needed = 10; /* 1.0 */ + de->bitflags = 0; + de->comp_method = ZIP_CM_DEFAULT; + de->last_mod.date = 0; + de->last_mod.time = 0; + de->crc = 0; + de->comp_size = 0; + de->uncomp_size = 0; + de->filename = NULL; + de->extra_fields = NULL; + de->comment = NULL; + de->disk_number = 0; + de->int_attrib = 0; + de->ext_attrib = ZIP_EXT_ATTRIB_DEFAULT; + de->offset = 0; + de->compression_level = 0; + de->encryption_method = ZIP_EM_NONE; + de->password = NULL; +} + + +bool +_zip_dirent_needs_zip64(const zip_dirent_t *de, zip_flags_t flags) { + if (de->uncomp_size >= ZIP_UINT32_MAX || de->comp_size >= ZIP_UINT32_MAX || ((flags & ZIP_FL_CENTRAL) && de->offset >= ZIP_UINT32_MAX)) + return true; + + return false; +} + + +zip_dirent_t * +_zip_dirent_new(void) { + zip_dirent_t *de; + + if ((de = (zip_dirent_t *)malloc(sizeof(*de))) == NULL) + return NULL; + + _zip_dirent_init(de); + return de; +} + + +/* + Fills the zip directory entry zde. + + If buffer is non-NULL, data is taken from there; otherwise data is read from fp as needed. + + If local is true, it reads a local header instead of a central directory entry. + + Returns size of dirent read if successful. On error, error is filled in and -1 is returned. +*/ + +zip_int64_t +_zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, bool local, zip_uint64_t central_compressed_size, bool check_consistency, zip_error_t *error) { + zip_uint8_t buf[CDENTRYSIZE]; + zip_uint32_t size, variable_size; + zip_uint16_t filename_len, comment_len, ef_len; + zip_string_t *utf8_string; + bool is_zip64 = false; + + bool from_buffer = (buffer != NULL); + + size = local ? LENTRYSIZE : CDENTRYSIZE; + + if (buffer) { + if (_zip_buffer_left(buffer) < size) { + zip_error_set(error, ZIP_ER_NOZIP, 0); + return -1; + } + } + else { + if ((buffer = _zip_buffer_new_from_source(src, size, buf, error)) == NULL) { + return -1; + } + } + + if (memcmp(_zip_buffer_get(buffer, 4), (local ? LOCAL_MAGIC : CENTRAL_MAGIC), 4) != 0) { + zip_error_set(error, ZIP_ER_NOZIP, 0); + if (!from_buffer) { + _zip_buffer_free(buffer); + } + return -1; + } + + /* convert buffercontents to zip_dirent */ + + _zip_dirent_init(zde); + if (!local) + zde->version_madeby = _zip_buffer_get_16(buffer); + else + zde->version_madeby = 0; + zde->version_needed = _zip_buffer_get_16(buffer); + zde->bitflags = _zip_buffer_get_16(buffer); + zde->comp_method = _zip_buffer_get_16(buffer); + + /* convert to time_t */ + zde->last_mod.time = _zip_buffer_get_16(buffer); + zde->last_mod.date = _zip_buffer_get_16(buffer); + + zde->crc = _zip_buffer_get_32(buffer); + zde->comp_size = _zip_buffer_get_32(buffer); + zde->uncomp_size = _zip_buffer_get_32(buffer); + + filename_len = _zip_buffer_get_16(buffer); + ef_len = _zip_buffer_get_16(buffer); + + if (local) { + comment_len = 0; + zde->disk_number = 0; + zde->int_attrib = 0; + zde->ext_attrib = 0; + zde->offset = 0; + } + else { + comment_len = _zip_buffer_get_16(buffer); + zde->disk_number = _zip_buffer_get_16(buffer); + zde->int_attrib = _zip_buffer_get_16(buffer); + zde->ext_attrib = _zip_buffer_get_32(buffer); + zde->offset = _zip_buffer_get_32(buffer); + } + + if (!_zip_buffer_ok(buffer)) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + if (!from_buffer) { + _zip_buffer_free(buffer); + } + return -1; + } + + if (zde->bitflags & ZIP_GPBF_ENCRYPTED) { + if (zde->bitflags & ZIP_GPBF_STRONG_ENCRYPTION) { + /* TODO */ + zde->encryption_method = ZIP_EM_UNKNOWN; + } + else { + zde->encryption_method = ZIP_EM_TRAD_PKWARE; + } + } + else { + zde->encryption_method = ZIP_EM_NONE; + } + + zde->filename = NULL; + zde->extra_fields = NULL; + zde->comment = NULL; + + variable_size = (zip_uint32_t)filename_len + (zip_uint32_t)ef_len + (zip_uint32_t)comment_len; + + if (from_buffer) { + if (_zip_buffer_left(buffer) < variable_size) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_VARIABLE_SIZE_OVERFLOW); + return -1; + } + } + else { + _zip_buffer_free(buffer); + + if ((buffer = _zip_buffer_new_from_source(src, variable_size, NULL, error)) == NULL) { + return -1; + } + } + + if (filename_len) { + zde->filename = _zip_read_string(buffer, src, filename_len, 1, error); + if (zde->filename == NULL) { + if (zip_error_code_zip(error) == ZIP_ER_EOF) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_VARIABLE_SIZE_OVERFLOW); + } + if (!from_buffer) { + _zip_buffer_free(buffer); + } + return -1; + } + + if (zde->bitflags & ZIP_GPBF_ENCODING_UTF_8) { + if (_zip_guess_encoding(zde->filename, ZIP_ENCODING_UTF8_KNOWN) == ZIP_ENCODING_ERROR) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_INVALID_UTF8_IN_FILENAME); + if (!from_buffer) { + _zip_buffer_free(buffer); + } + return -1; + } + } + } + + if (ef_len) { + zip_uint8_t *ef = _zip_read_data(buffer, src, ef_len, 0, error); + + if (ef == NULL) { + if (!from_buffer) { + _zip_buffer_free(buffer); + } + return -1; + } + if (!_zip_ef_parse(ef, ef_len, local ? ZIP_EF_LOCAL : ZIP_EF_CENTRAL, &zde->extra_fields, error)) { + free(ef); + if (!from_buffer) { + _zip_buffer_free(buffer); + } + return -1; + } + free(ef); + if (local) + zde->local_extra_fields_read = 1; + } + + if (comment_len) { + zde->comment = _zip_read_string(buffer, src, comment_len, 0, error); + if (zde->comment == NULL) { + if (!from_buffer) { + _zip_buffer_free(buffer); + } + return -1; + } + if (zde->bitflags & ZIP_GPBF_ENCODING_UTF_8) { + if (_zip_guess_encoding(zde->comment, ZIP_ENCODING_UTF8_KNOWN) == ZIP_ENCODING_ERROR) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_INVALID_UTF8_IN_COMMENT); + if (!from_buffer) { + _zip_buffer_free(buffer); + } + return -1; + } + } + } + + if ((utf8_string = _zip_dirent_process_ef_utf_8(zde, ZIP_EF_UTF_8_NAME, zde->filename, check_consistency)) == NULL && zde->filename != NULL) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_UTF8_FILENAME_MISMATCH); + if (!from_buffer) { + _zip_buffer_free(buffer); + } + return -1; + } + zde->filename = utf8_string; + if (!local) { + if ((utf8_string = _zip_dirent_process_ef_utf_8(zde, ZIP_EF_UTF_8_COMMENT, zde->comment, check_consistency)) == NULL && zde->comment != NULL) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_UTF8_COMMENT_MISMATCH); + if (!from_buffer) { + _zip_buffer_free(buffer); + } + return -1; + } + zde->comment = utf8_string; + } + + /* Zip64 */ + + if (zde->uncomp_size == ZIP_UINT32_MAX || zde->comp_size == ZIP_UINT32_MAX || zde->offset == ZIP_UINT32_MAX) { + zip_uint16_t got_len; + const zip_uint8_t *ef = _zip_ef_get_by_id(zde->extra_fields, &got_len, ZIP_EF_ZIP64, 0, local ? ZIP_EF_LOCAL : ZIP_EF_CENTRAL, error); + if (ef != NULL) { + if (!zip_dirent_process_ef_zip64(zde, ef, got_len, local, error)) { + if (!from_buffer) { + _zip_buffer_free(buffer); + } + return -1; + } + } + is_zip64 = true; + } + + + if (!_zip_buffer_ok(buffer)) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + if (!from_buffer) { + _zip_buffer_free(buffer); + } + return -1; + } + + if (!from_buffer) { + _zip_buffer_free(buffer); + } + + if (local && zde->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) { + zip_uint32_t df_crc; + zip_uint64_t df_comp_size, df_uncomp_size; + if (zip_source_seek(src, central_compressed_size, SEEK_CUR) != 0 || (buffer = _zip_buffer_new_from_source(src, MAX_DATA_DESCRIPTOR_LENGTH, buf, error)) == NULL) { + return -1; + } + if (memcmp(_zip_buffer_peek(buffer, MAGIC_LEN), DATADES_MAGIC, MAGIC_LEN) == 0) { + _zip_buffer_skip(buffer, MAGIC_LEN); + } + df_crc = _zip_buffer_get_32(buffer); + df_comp_size = is_zip64 ? _zip_buffer_get_64(buffer) : _zip_buffer_get_32(buffer); + df_uncomp_size = is_zip64 ? _zip_buffer_get_64(buffer) : _zip_buffer_get_32(buffer); + + if (!_zip_buffer_ok(buffer)) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + _zip_buffer_free(buffer); + return -1; + } + _zip_buffer_free(buffer); + + if ((zde->crc != 0 && zde->crc != df_crc) || (zde->comp_size != 0 && zde->comp_size != df_comp_size) || (zde->uncomp_size != 0 && zde->uncomp_size != df_uncomp_size)) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_DATA_DESCRIPTOR_MISMATCH); + return -1; + } + zde->crc = df_crc; + zde->comp_size = df_comp_size; + zde->uncomp_size = df_uncomp_size; + } + + /* zip_source_seek / zip_source_tell don't support values > ZIP_INT64_MAX */ + if (zde->offset > ZIP_INT64_MAX) { + zip_error_set(error, ZIP_ER_SEEK, EFBIG); + return -1; + } + + if (!_zip_dirent_process_winzip_aes(zde, error)) { + return -1; + } + + zde->extra_fields = _zip_ef_remove_internal(zde->extra_fields); + + return (zip_int64_t)size + (zip_int64_t)variable_size; +} + +bool +zip_dirent_process_ef_zip64(zip_dirent_t *zde, const zip_uint8_t *ef, zip_uint64_t got_len, bool local, zip_error_t *error) { + zip_buffer_t *ef_buffer; + + if ((ef_buffer = _zip_buffer_new((zip_uint8_t *)ef, got_len)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return false; + } + + if (zde->uncomp_size == ZIP_UINT32_MAX) { + zde->uncomp_size = _zip_buffer_get_64(ef_buffer); + } + else if (local) { + /* From appnote.txt: This entry in the Local header MUST + include BOTH original and compressed file size fields. */ + (void)_zip_buffer_skip(ef_buffer, 8); /* error is caught by _zip_buffer_eof() call */ + } + if (zde->comp_size == ZIP_UINT32_MAX) { + zde->comp_size = _zip_buffer_get_64(ef_buffer); + } + if (!local) { + if (zde->offset == ZIP_UINT32_MAX) { + zde->offset = _zip_buffer_get_64(ef_buffer); + } + if (zde->disk_number == ZIP_UINT16_MAX) { + zde->disk_number = _zip_buffer_get_32(ef_buffer); + } + } + + if (!_zip_buffer_eof(ef_buffer)) { + /* accept additional fields if values match */ + bool ok = true; + switch (got_len) { + case 28: + _zip_buffer_set_offset(ef_buffer, 24); + if (zde->disk_number != _zip_buffer_get_32(ef_buffer)) { + ok = false; + } + /* fallthrough */ + case 24: + _zip_buffer_set_offset(ef_buffer, 0); + if ((zde->uncomp_size != _zip_buffer_get_64(ef_buffer)) || (zde->comp_size != _zip_buffer_get_64(ef_buffer)) || (zde->offset != _zip_buffer_get_64(ef_buffer))) { + ok = false; + } + break; + + default: + ok = false; + } + if (!ok) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_INVALID_ZIP64_EF); + _zip_buffer_free(ef_buffer); + return false; + } + } + _zip_buffer_free(ef_buffer); + + return true; +} + + +static zip_string_t * +_zip_dirent_process_ef_utf_8(const zip_dirent_t *de, zip_uint16_t id, zip_string_t *str, bool check_consistency) { + zip_uint16_t ef_len; + zip_uint32_t ef_crc; + zip_buffer_t *buffer; + + const zip_uint8_t *ef = _zip_ef_get_by_id(de->extra_fields, &ef_len, id, 0, ZIP_EF_BOTH, NULL); + + if (ef == NULL || ef_len < 5 || ef[0] != 1) { + return str; + } + + if ((buffer = _zip_buffer_new((zip_uint8_t *)ef, ef_len)) == NULL) { + return str; + } + + _zip_buffer_get_8(buffer); + ef_crc = _zip_buffer_get_32(buffer); + + if (_zip_string_crc32(str) == ef_crc) { + zip_uint16_t len = (zip_uint16_t)_zip_buffer_left(buffer); + zip_string_t *ef_str = _zip_string_new(_zip_buffer_get(buffer, len), len, ZIP_FL_ENC_UTF_8, NULL); + + if (ef_str != NULL) { + if (check_consistency) { + if (!_zip_string_equal(str, ef_str) && _zip_string_is_ascii(ef_str)) { + _zip_string_free(ef_str); + _zip_buffer_free(buffer); + return NULL; + } + } + + _zip_string_free(str); + str = ef_str; + } + } + + _zip_buffer_free(buffer); + + return str; +} + + +static bool +_zip_dirent_process_winzip_aes(zip_dirent_t *de, zip_error_t *error) { + zip_uint16_t ef_len; + zip_buffer_t *buffer; + const zip_uint8_t *ef; + bool crc_valid; + zip_uint16_t enc_method; + + + if (de->comp_method != ZIP_CM_WINZIP_AES) { + return true; + } + + ef = _zip_ef_get_by_id(de->extra_fields, &ef_len, ZIP_EF_WINZIP_AES, 0, ZIP_EF_BOTH, NULL); + + if (ef == NULL || ef_len < 7) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_INVALID_WINZIPAES_EF); + return false; + } + + if ((buffer = _zip_buffer_new((zip_uint8_t *)ef, ef_len)) == NULL) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + return false; + } + + /* version */ + + crc_valid = true; + switch (_zip_buffer_get_16(buffer)) { + case 1: + break; + + case 2: + crc_valid = false; + /* TODO: When checking consistency, check that crc is 0. */ + break; + + default: + zip_error_set(error, ZIP_ER_ENCRNOTSUPP, 0); + _zip_buffer_free(buffer); + return false; + } + + /* vendor */ + if (memcmp(_zip_buffer_get(buffer, 2), "AE", 2) != 0) { + zip_error_set(error, ZIP_ER_ENCRNOTSUPP, 0); + _zip_buffer_free(buffer); + return false; + } + + /* mode */ + switch (_zip_buffer_get_8(buffer)) { + case 1: + enc_method = ZIP_EM_AES_128; + break; + case 2: + enc_method = ZIP_EM_AES_192; + break; + case 3: + enc_method = ZIP_EM_AES_256; + break; + default: + zip_error_set(error, ZIP_ER_ENCRNOTSUPP, 0); + _zip_buffer_free(buffer); + return false; + } + + if (ef_len != 7) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_INVALID_WINZIPAES_EF); + _zip_buffer_free(buffer); + return false; + } + + de->crc_valid = crc_valid; + de->encryption_method = enc_method; + de->comp_method = _zip_buffer_get_16(buffer); + + _zip_buffer_free(buffer); + return true; +} + + +zip_int32_t +_zip_dirent_size(zip_source_t *src, zip_uint16_t flags, zip_error_t *error) { + zip_int32_t size; + bool local = (flags & ZIP_EF_LOCAL) != 0; + int i; + zip_uint8_t b[6]; + zip_buffer_t *buffer; + + size = local ? LENTRYSIZE : CDENTRYSIZE; + + if (zip_source_seek(src, local ? 26 : 28, SEEK_CUR) < 0) { + zip_error_set_from_source(error, src); + return -1; + } + + if ((buffer = _zip_buffer_new_from_source(src, local ? 4 : 6, b, error)) == NULL) { + return -1; + } + + for (i = 0; i < (local ? 2 : 3); i++) { + size += _zip_buffer_get_16(buffer); + } + + if (!_zip_buffer_eof(buffer)) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + _zip_buffer_free(buffer); + return -1; + } + + _zip_buffer_free(buffer); + return size; +} + + +/* _zip_dirent_write + Writes zip directory entry. + + If flags & ZIP_EF_LOCAL, it writes a local header instead of a central + directory entry. If flags & ZIP_EF_FORCE_ZIP64, a ZIP64 extra field is written, even if not needed. + + Returns 0 if successful, 1 if successful and wrote ZIP64 extra field. On error, error is filled in and -1 is + returned. +*/ + +int +_zip_dirent_write(zip_t *za, zip_dirent_t *de, zip_flags_t flags) { + zip_dostime_t dostime; + zip_encoding_type_t com_enc, name_enc; + zip_extra_field_t *ef; + zip_extra_field_t *ef64; + zip_uint32_t ef_total_size; + bool is_zip64; + bool is_really_zip64; + bool is_winzip_aes; + zip_uint8_t buf[CDENTRYSIZE]; + zip_buffer_t *buffer; + + ef = NULL; + + name_enc = _zip_guess_encoding(de->filename, ZIP_ENCODING_UNKNOWN); + com_enc = _zip_guess_encoding(de->comment, ZIP_ENCODING_UNKNOWN); + + if ((name_enc == ZIP_ENCODING_UTF8_KNOWN && com_enc == ZIP_ENCODING_ASCII) || (name_enc == ZIP_ENCODING_ASCII && com_enc == ZIP_ENCODING_UTF8_KNOWN) || (name_enc == ZIP_ENCODING_UTF8_KNOWN && com_enc == ZIP_ENCODING_UTF8_KNOWN)) + de->bitflags |= ZIP_GPBF_ENCODING_UTF_8; + else { + de->bitflags &= (zip_uint16_t)~ZIP_GPBF_ENCODING_UTF_8; + if (name_enc == ZIP_ENCODING_UTF8_KNOWN) { + ef = _zip_ef_utf8(ZIP_EF_UTF_8_NAME, de->filename, &za->error); + if (ef == NULL) + return -1; + } + if ((flags & ZIP_FL_LOCAL) == 0 && com_enc == ZIP_ENCODING_UTF8_KNOWN) { + zip_extra_field_t *ef2 = _zip_ef_utf8(ZIP_EF_UTF_8_COMMENT, de->comment, &za->error); + if (ef2 == NULL) { + _zip_ef_free(ef); + return -1; + } + ef2->next = ef; + ef = ef2; + } + } + + if (de->encryption_method == ZIP_EM_NONE) { + de->bitflags &= (zip_uint16_t)~ZIP_GPBF_ENCRYPTED; + } + else { + de->bitflags |= (zip_uint16_t)ZIP_GPBF_ENCRYPTED; + } + + is_really_zip64 = _zip_dirent_needs_zip64(de, flags); + is_zip64 = (flags & (ZIP_FL_LOCAL | ZIP_FL_FORCE_ZIP64)) == (ZIP_FL_LOCAL | ZIP_FL_FORCE_ZIP64) || is_really_zip64; + is_winzip_aes = de->encryption_method == ZIP_EM_AES_128 || de->encryption_method == ZIP_EM_AES_192 || de->encryption_method == ZIP_EM_AES_256; + + if (is_zip64) { + zip_uint8_t ef_zip64[EFZIP64SIZE]; + zip_buffer_t *ef_buffer = _zip_buffer_new(ef_zip64, sizeof(ef_zip64)); + if (ef_buffer == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + _zip_ef_free(ef); + return -1; + } + + if (flags & ZIP_FL_LOCAL) { + if ((flags & ZIP_FL_FORCE_ZIP64) || de->comp_size > ZIP_UINT32_MAX || de->uncomp_size > ZIP_UINT32_MAX) { + _zip_buffer_put_64(ef_buffer, de->uncomp_size); + _zip_buffer_put_64(ef_buffer, de->comp_size); + } + } + else { + if ((flags & ZIP_FL_FORCE_ZIP64) || de->comp_size > ZIP_UINT32_MAX || de->uncomp_size > ZIP_UINT32_MAX || de->offset > ZIP_UINT32_MAX) { + if (de->uncomp_size >= ZIP_UINT32_MAX) { + _zip_buffer_put_64(ef_buffer, de->uncomp_size); + } + if (de->comp_size >= ZIP_UINT32_MAX) { + _zip_buffer_put_64(ef_buffer, de->comp_size); + } + if (de->offset >= ZIP_UINT32_MAX) { + _zip_buffer_put_64(ef_buffer, de->offset); + } + } + } + + if (!_zip_buffer_ok(ef_buffer)) { + zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); + _zip_buffer_free(ef_buffer); + _zip_ef_free(ef); + return -1; + } + + ef64 = _zip_ef_new(ZIP_EF_ZIP64, (zip_uint16_t)(_zip_buffer_offset(ef_buffer)), ef_zip64, ZIP_EF_BOTH); + _zip_buffer_free(ef_buffer); + ef64->next = ef; + ef = ef64; + } + + if (is_winzip_aes) { + zip_uint8_t data[EF_WINZIP_AES_SIZE]; + zip_buffer_t *ef_buffer = _zip_buffer_new(data, sizeof(data)); + zip_extra_field_t *ef_winzip; + + if (ef_buffer == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + _zip_ef_free(ef); + return -1; + } + + _zip_buffer_put_16(ef_buffer, 2); + _zip_buffer_put(ef_buffer, "AE", 2); + _zip_buffer_put_8(ef_buffer, (zip_uint8_t)(de->encryption_method & 0xff)); + _zip_buffer_put_16(ef_buffer, (zip_uint16_t)de->comp_method); + + if (!_zip_buffer_ok(ef_buffer)) { + zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); + _zip_buffer_free(ef_buffer); + _zip_ef_free(ef); + return -1; + } + + ef_winzip = _zip_ef_new(ZIP_EF_WINZIP_AES, EF_WINZIP_AES_SIZE, data, ZIP_EF_BOTH); + _zip_buffer_free(ef_buffer); + ef_winzip->next = ef; + ef = ef_winzip; + } + + if ((buffer = _zip_buffer_new(buf, sizeof(buf))) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + _zip_ef_free(ef); + return -1; + } + + _zip_buffer_put(buffer, (flags & ZIP_FL_LOCAL) ? LOCAL_MAGIC : CENTRAL_MAGIC, 4); + + if ((flags & ZIP_FL_LOCAL) == 0) { + _zip_buffer_put_16(buffer, de->version_madeby); + } + _zip_buffer_put_16(buffer, ZIP_MAX(is_really_zip64 ? 45 : 0, de->version_needed)); + _zip_buffer_put_16(buffer, de->bitflags); + if (is_winzip_aes) { + _zip_buffer_put_16(buffer, ZIP_CM_WINZIP_AES); + } + else { + _zip_buffer_put_16(buffer, (zip_uint16_t)ZIP_CM_ACTUAL(de->comp_method)); + } + + if (ZIP_WANT_TORRENTZIP(za)) { + dostime.time = 0xbc00; + dostime.date = 0x2198; + } + else { + dostime = de->last_mod; + } + _zip_buffer_put_16(buffer, dostime.time); + _zip_buffer_put_16(buffer, dostime.date); + + if (is_winzip_aes && de->uncomp_size < 20) { + _zip_buffer_put_32(buffer, 0); + } + else { + _zip_buffer_put_32(buffer, de->crc); + } + + if (((flags & ZIP_FL_LOCAL) == ZIP_FL_LOCAL) && ((de->comp_size >= ZIP_UINT32_MAX) || (de->uncomp_size >= ZIP_UINT32_MAX))) { + /* In local headers, if a ZIP64 EF is written, it MUST contain + * both compressed and uncompressed sizes (even if one of the + * two is smaller than 0xFFFFFFFF); on the other hand, those + * may only appear when the corresponding standard entry is + * 0xFFFFFFFF. (appnote.txt 4.5.3) */ + _zip_buffer_put_32(buffer, ZIP_UINT32_MAX); + _zip_buffer_put_32(buffer, ZIP_UINT32_MAX); + } + else { + if (de->comp_size < ZIP_UINT32_MAX) { + _zip_buffer_put_32(buffer, (zip_uint32_t)de->comp_size); + } + else { + _zip_buffer_put_32(buffer, ZIP_UINT32_MAX); + } + if (de->uncomp_size < ZIP_UINT32_MAX) { + _zip_buffer_put_32(buffer, (zip_uint32_t)de->uncomp_size); + } + else { + _zip_buffer_put_32(buffer, ZIP_UINT32_MAX); + } + } + + _zip_buffer_put_16(buffer, _zip_string_length(de->filename)); + ef_total_size = (zip_uint32_t)_zip_ef_size(ef, ZIP_EF_BOTH); + if (!ZIP_WANT_TORRENTZIP(za)) { + /* TODO: check for overflow */ + ef_total_size += (zip_uint32_t)_zip_ef_size(de->extra_fields, flags); + } + _zip_buffer_put_16(buffer, (zip_uint16_t)ef_total_size); + + if ((flags & ZIP_FL_LOCAL) == 0) { + _zip_buffer_put_16(buffer, ZIP_WANT_TORRENTZIP(za) ? 0 : _zip_string_length(de->comment)); + _zip_buffer_put_16(buffer, (zip_uint16_t)de->disk_number); + _zip_buffer_put_16(buffer, de->int_attrib); + _zip_buffer_put_32(buffer, de->ext_attrib); + if (de->offset < ZIP_UINT32_MAX) + _zip_buffer_put_32(buffer, (zip_uint32_t)de->offset); + else + _zip_buffer_put_32(buffer, ZIP_UINT32_MAX); + } + + if (!_zip_buffer_ok(buffer)) { + zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); + _zip_buffer_free(buffer); + _zip_ef_free(ef); + return -1; + } + + if (_zip_write(za, buf, _zip_buffer_offset(buffer)) < 0) { + _zip_buffer_free(buffer); + _zip_ef_free(ef); + return -1; + } + + _zip_buffer_free(buffer); + + if (de->filename) { + if (_zip_string_write(za, de->filename) < 0) { + _zip_ef_free(ef); + return -1; + } + } + + if (ef) { + if (_zip_ef_write(za, ef, ZIP_EF_BOTH) < 0) { + _zip_ef_free(ef); + return -1; + } + } + _zip_ef_free(ef); + if (de->extra_fields && !ZIP_WANT_TORRENTZIP(za)) { + if (_zip_ef_write(za, de->extra_fields, flags) < 0) { + return -1; + } + } + + if ((flags & ZIP_FL_LOCAL) == 0 && !ZIP_WANT_TORRENTZIP(za)) { + if (de->comment) { + if (_zip_string_write(za, de->comment) < 0) { + return -1; + } + } + } + + + return is_zip64; +} + + +time_t +_zip_d2u_time(const zip_dostime_t *dtime) { + struct tm tm; + + memset(&tm, 0, sizeof(tm)); + + /* let mktime decide if DST is in effect */ + tm.tm_isdst = -1; + + tm.tm_year = ((dtime->date >> 9) & 127) + 1980 - 1900; + tm.tm_mon = ((dtime->date >> 5) & 15) - 1; + tm.tm_mday = dtime->date & 31; + + tm.tm_hour = (dtime->time >> 11) & 31; + tm.tm_min = (dtime->time >> 5) & 63; + tm.tm_sec = (dtime->time << 1) & 62; + + return mktime(&tm); +} + + +static zip_extra_field_t * +_zip_ef_utf8(zip_uint16_t id, zip_string_t *str, zip_error_t *error) { + const zip_uint8_t *raw; + zip_uint32_t len; + zip_buffer_t *buffer; + zip_extra_field_t *ef; + + if ((raw = _zip_string_get(str, &len, ZIP_FL_ENC_RAW, NULL)) == NULL) { + /* error already set */ + return NULL; + } + + if (len + 5 > ZIP_UINT16_MAX) { + zip_error_set(error, ZIP_ER_INVAL, 0); /* TODO: better error code? */ + return NULL; + } + + if ((buffer = _zip_buffer_new(NULL, len + 5)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + _zip_buffer_put_8(buffer, 1); + _zip_buffer_put_32(buffer, _zip_string_crc32(str)); + _zip_buffer_put(buffer, raw, len); + + if (!_zip_buffer_ok(buffer)) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + _zip_buffer_free(buffer); + return NULL; + } + + ef = _zip_ef_new(id, (zip_uint16_t)(_zip_buffer_offset(buffer)), _zip_buffer_data(buffer), ZIP_EF_BOTH); + _zip_buffer_free(buffer); + + return ef; +} + + +zip_dirent_t * +_zip_get_dirent(zip_t *za, zip_uint64_t idx, zip_flags_t flags, zip_error_t *error) { + if (error == NULL) + error = &za->error; + + if (idx >= za->nentry) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((flags & ZIP_FL_UNCHANGED) || za->entry[idx].changes == NULL) { + if (za->entry[idx].orig == NULL) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + if (za->entry[idx].deleted && (flags & ZIP_FL_UNCHANGED) == 0) { + zip_error_set(error, ZIP_ER_DELETED, 0); + return NULL; + } + return za->entry[idx].orig; + } + else + return za->entry[idx].changes; +} + + +int +_zip_u2d_time(time_t intime, zip_dostime_t *dtime, zip_error_t *ze) { + struct tm *tpm; + struct tm tm; + tpm = zip_localtime(&intime, &tm); + if (tpm == NULL) { + /* if localtime fails, return an arbitrary date (1980-01-01 00:00:00) */ + dtime->date = (1 << 5) + 1; + dtime->time = 0; + if (ze) { + zip_error_set(ze, ZIP_ER_INVAL, errno); + } + return -1; + } + if (tpm->tm_year < 80) { + tpm->tm_year = 80; + } + + dtime->date = (zip_uint16_t)(((tpm->tm_year + 1900 - 1980) << 9) + ((tpm->tm_mon + 1) << 5) + tpm->tm_mday); + dtime->time = (zip_uint16_t)(((tpm->tm_hour) << 11) + ((tpm->tm_min) << 5) + ((tpm->tm_sec) >> 1)); + + return 0; +} + + +bool _zip_dirent_apply_attributes(zip_dirent_t *de, zip_file_attributes_t *attributes, bool force_zip64, zip_uint32_t changed) { + zip_uint16_t length; + bool has_changed = false; + + if (attributes->valid & ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS) { + zip_uint16_t mask = attributes->general_purpose_bit_mask & ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS_ALLOWED_MASK; + zip_uint16_t bitflags = (de->bitflags & ~mask) | (attributes->general_purpose_bit_flags & mask); + if (de->bitflags != bitflags) { + de->bitflags = bitflags; + has_changed = true; + } + } + if (attributes->valid & ZIP_FILE_ATTRIBUTES_ASCII) { + zip_uint16_t int_attrib = (de->int_attrib & ~0x1) | (attributes->ascii ? 1 : 0); + if (de->int_attrib != int_attrib) { + de->int_attrib = int_attrib; + has_changed = true; + } + } + /* manually set attributes are preferred over attributes provided by source */ + if ((changed & ZIP_DIRENT_ATTRIBUTES) == 0 && (attributes->valid & ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES)) { + if (de->ext_attrib != attributes->external_file_attributes) { + de->ext_attrib = attributes->external_file_attributes; + has_changed = true; + } + } + + zip_uint16_t version_needed; + if (de->comp_method == ZIP_CM_LZMA) { + version_needed = 63; + } + else if (de->encryption_method == ZIP_EM_AES_128 || de->encryption_method == ZIP_EM_AES_192 || de->encryption_method == ZIP_EM_AES_256) { + version_needed = 51; + } + else if (de->comp_method == ZIP_CM_BZIP2) { + version_needed = 46; + } + else if (force_zip64 || _zip_dirent_needs_zip64(de, 0)) { + version_needed = 45; + } + else if (de->comp_method == ZIP_CM_DEFLATE || de->encryption_method == ZIP_EM_TRAD_PKWARE) { + version_needed = 20; + } + else if ((length = _zip_string_length(de->filename)) > 0 && de->filename->raw[length - 1] == '/') { + version_needed = 20; + } + else { + version_needed = 10; + } + + if (attributes->valid & ZIP_FILE_ATTRIBUTES_VERSION_NEEDED) { + version_needed = ZIP_MAX(version_needed, attributes->version_needed); + } + + if (de->version_needed != version_needed) { + de->version_needed = version_needed; + has_changed = true; + } + + zip_int16_t version_madeby = 63 | (de->version_madeby & 0xff00); + if ((changed & ZIP_DIRENT_ATTRIBUTES) == 0 && (attributes->valid & ZIP_FILE_ATTRIBUTES_HOST_SYSTEM)) { + version_madeby = (version_madeby & 0xff) | (zip_uint16_t)(attributes->host_system << 8); + } + if (de->version_madeby != version_madeby) { + de->version_madeby = version_madeby; + has_changed = true; + } + + return has_changed; +} + + +/* _zip_dirent_torrent_normalize(de); + Set values suitable for torrentzip. +*/ + +void +zip_dirent_torrentzip_normalize(zip_dirent_t *de) { + de->version_madeby = 0; + de->version_needed = 20; /* 2.0 */ + de->bitflags = 2; /* maximum compression */ + de->comp_method = ZIP_CM_DEFLATE; + de->compression_level = TORRENTZIP_COMPRESSION_FLAGS; + de->disk_number = 0; + de->int_attrib = 0; + de->ext_attrib = 0; + + /* last_mod, extra_fields, and comment are normalized in zip_dirent_write() directly */ +} + +int zip_dirent_check_consistency(zip_dirent_t *dirent) { + if (dirent->comp_method == ZIP_CM_STORE) { + zip_uint64_t header_size = 0; + switch (dirent->encryption_method) { + case ZIP_EM_NONE: + break; + case ZIP_EM_TRAD_PKWARE: + header_size = 12; + break; + case ZIP_EM_AES_128: + header_size = 20; + break; + case ZIP_EM_AES_192: + header_size = 24; + break; + case ZIP_EM_AES_256: + header_size = 28; + break; + + default: + return 0; + } + if (dirent->uncomp_size + header_size < dirent->uncomp_size || dirent->comp_size != dirent->uncomp_size + header_size) { + return ZIP_ER_DETAIL_STORED_SIZE_MISMATCH; + } + } + return 0; +} + +time_t +zip_dirent_get_last_mod_mtime(zip_dirent_t *de) { + if (!de->last_mod_mtime_valid) { + de->last_mod_mtime = _zip_d2u_time(&de->last_mod); + de->last_mod_mtime_valid = true; + } + + return de->last_mod_mtime; +} \ No newline at end of file diff --git a/thirdparty/libzip-1.11.3/lib/zip_discard.c b/thirdparty/libzip-1.11.3/lib/zip_discard.c new file mode 100644 index 0000000..841a80e --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_discard.c @@ -0,0 +1,80 @@ +/* + zip_discard.c -- discard and free struct zip + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +/* zip_discard: + frees the space allocated to a zipfile struct, and closes the + corresponding file. */ + +void +zip_discard(zip_t *za) { + zip_uint64_t i; + + if (za == NULL) + return; + + if (za->src) { + zip_source_close(za->src); + zip_source_free(za->src); + } + + free(za->default_password); + _zip_string_free(za->comment_orig); + _zip_string_free(za->comment_changes); + + _zip_hash_free(za->names); + + if (za->entry) { + for (i = 0; i < za->nentry; i++) + _zip_entry_finalize(za->entry + i); + free(za->entry); + } + + for (i = 0; i < za->nopen_source; i++) { + _zip_source_invalidate(za->open_source[i]); + } + free(za->open_source); + + _zip_progress_free(za->progress); + + zip_error_fini(&za->error); + + free(za); + + return; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_entry.c b/thirdparty/libzip-1.11.3/lib/zip_entry.c new file mode 100644 index 0000000..dd25e61 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_entry.c @@ -0,0 +1,51 @@ +/* + zip_entry.c -- struct zip_entry helper functions + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + +void +_zip_entry_finalize(zip_entry_t *e) { + _zip_unchange_data(e); + _zip_dirent_free(e->orig); + _zip_dirent_free(e->changes); +} + + +void +_zip_entry_init(zip_entry_t *e) { + e->orig = NULL; + e->changes = NULL; + e->source = NULL; + e->deleted = 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_error.c b/thirdparty/libzip-1.11.3/lib/zip_error.c new file mode 100644 index 0000000..da910d4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_error.c @@ -0,0 +1,156 @@ +/* + zip_error.c -- zip_error_t helper functions + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include "zipint.h" + + +ZIP_EXTERN int +zip_error_code_system(const zip_error_t *error) { + return error->sys_err; +} + + +ZIP_EXTERN int +zip_error_code_zip(const zip_error_t *error) { + return error->zip_err; +} + + +ZIP_EXTERN void +zip_error_fini(zip_error_t *err) { + free(err->str); + err->str = NULL; +} + + +ZIP_EXTERN void +zip_error_init(zip_error_t *err) { + err->zip_err = ZIP_ER_OK; + err->sys_err = 0; + err->str = NULL; +} + +ZIP_EXTERN void +zip_error_init_with_code(zip_error_t *error, int ze) { + zip_error_init(error); + error->zip_err = ze; + switch (zip_error_system_type(error)) { + case ZIP_ET_SYS: + case ZIP_ET_LIBZIP: + error->sys_err = errno; + break; + + default: + error->sys_err = 0; + break; + } +} + + +ZIP_EXTERN int +zip_error_system_type(const zip_error_t *error) { + if (error->zip_err < 0 || error->zip_err >= _zip_err_str_count) + return ZIP_ET_NONE; + + return _zip_err_str[error->zip_err].type; +} + + +void +_zip_error_clear(zip_error_t *err) { + if (err == NULL) + return; + + err->zip_err = ZIP_ER_OK; + err->sys_err = 0; +} + + +void +_zip_error_copy(zip_error_t *dst, const zip_error_t *src) { + if (dst == NULL) { + return; + } + + dst->zip_err = src->zip_err; + dst->sys_err = src->sys_err; +} + + +void +_zip_error_get(const zip_error_t *err, int *zep, int *sep) { + if (zep) + *zep = err->zip_err; + if (sep) { + if (zip_error_system_type(err) != ZIP_ET_NONE) + *sep = err->sys_err; + else + *sep = 0; + } +} + + +void +zip_error_set(zip_error_t *err, int ze, int se) { + if (err) { + err->zip_err = ze; + err->sys_err = se; + } +} + + +void +zip_error_set_from_source(zip_error_t *err, zip_source_t *src) { + if (src == NULL) { + zip_error_set(err, ZIP_ER_INVAL, 0); + return; + } + + _zip_error_copy(err, zip_source_error(src)); +} + + +zip_int64_t +zip_error_to_data(const zip_error_t *error, void *data, zip_uint64_t length) { + int *e = (int *)data; + + if (length < sizeof(int) * 2) { + return -1; + } + + e[0] = zip_error_code_zip(error); + e[1] = zip_error_code_system(error); + return sizeof(int) * 2; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_error_clear.c b/thirdparty/libzip-1.11.3/lib/zip_error_clear.c new file mode 100644 index 0000000..0406271 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_error_clear.c @@ -0,0 +1,44 @@ +/* + zip_error_clear.c -- clear zip error + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN void +zip_error_clear(zip_t *za) { + if (za == NULL) + return; + + _zip_error_clear(&za->error); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_error_get.c b/thirdparty/libzip-1.11.3/lib/zip_error_get.c new file mode 100644 index 0000000..2a5b3ea --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_error_get.c @@ -0,0 +1,54 @@ +/* + zip_error_get.c -- get zip error + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#define _ZIP_COMPILING_DEPRECATED +#include "zipint.h" + + +ZIP_EXTERN void +zip_error_get(zip_t *za, int *zep, int *sep) { + _zip_error_get(&za->error, zep, sep); +} + + +ZIP_EXTERN zip_error_t * +zip_get_error(zip_t *za) { + return &za->error; +} + + +ZIP_EXTERN zip_error_t * +zip_file_get_error(zip_file_t *f) { + return &f->error; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_error_get_sys_type.c b/thirdparty/libzip-1.11.3/lib/zip_error_get_sys_type.c new file mode 100644 index 0000000..973d26c --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_error_get_sys_type.c @@ -0,0 +1,45 @@ +/* + zip_error_get_sys_type.c -- return type of system error code + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _ZIP_COMPILING_DEPRECATED +#include "zipint.h" + + +ZIP_EXTERN int +zip_error_get_sys_type(int ze) { + if (ze < 0 || ze >= _zip_err_str_count) { + return 0; + } + + return _zip_err_str[ze].type; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_error_strerror.c b/thirdparty/libzip-1.11.3/lib/zip_error_strerror.c new file mode 100644 index 0000000..5be54b3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_error_strerror.c @@ -0,0 +1,140 @@ +/* + zip_error_sterror.c -- get string representation of struct zip_error + Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include +#include +#include + +#include "zipint.h" + +ZIP_EXTERN const char * +zip_error_strerror(zip_error_t *err) { + const char *zip_error_string, *system_error_string; + char *s; + char *system_error_buffer = NULL; + + zip_error_fini(err); + + if (err->zip_err < 0 || err->zip_err >= _zip_err_str_count) { + system_error_buffer = (char *)malloc(128); + if (system_error_buffer == NULL) { + return _zip_err_str[ZIP_ER_MEMORY].description; + } + snprintf_s(system_error_buffer, 128, "Unknown error %d", err->zip_err); + system_error_buffer[128 - 1] = '\0'; /* make sure string is NUL-terminated */ + zip_error_string = NULL; + system_error_string = system_error_buffer; + } + else { + zip_error_string = _zip_err_str[err->zip_err].description; + + switch (_zip_err_str[err->zip_err].type) { + case ZIP_ET_SYS: { + size_t len = strerrorlen_s(err->sys_err) + 1; + system_error_buffer = malloc(len); + if (system_error_buffer == NULL) { + return _zip_err_str[ZIP_ER_MEMORY].description; + } + strerror_s(system_error_buffer, len, err->sys_err); + system_error_string = system_error_buffer; + break; + } + + case ZIP_ET_ZLIB: + system_error_string = zError(err->sys_err); + break; + + case ZIP_ET_LIBZIP: { + zip_uint8_t error = GET_ERROR_FROM_DETAIL(err->sys_err); + int index = GET_INDEX_FROM_DETAIL(err->sys_err); + + if (error == 0) { + system_error_string = NULL; + } + else if (error >= _zip_err_details_count) { + system_error_buffer = (char *)malloc(128); + if (system_error_buffer == NULL) { + return _zip_err_str[ZIP_ER_MEMORY].description; + } + snprintf_s(system_error_buffer, 128, "invalid detail error %u", error); + system_error_buffer[128 - 1] = '\0'; /* make sure string is NUL-terminated */ + system_error_string = system_error_buffer; + } + else if (_zip_err_details[error].type == ZIP_DETAIL_ET_ENTRY && index < MAX_DETAIL_INDEX) { + system_error_buffer = (char *)malloc(128); + if (system_error_buffer == NULL) { + return _zip_err_str[ZIP_ER_MEMORY].description; + } + snprintf_s(system_error_buffer, 128, "entry %d: %s", index, _zip_err_details[error].description); + system_error_buffer[128 - 1] = '\0'; /* make sure string is NUL-terminated */ + system_error_string = system_error_buffer; + } + else { + system_error_string = _zip_err_details[error].description; + } + break; + } + + default: + system_error_string = NULL; + } + } + + if (system_error_string == NULL) { + free(system_error_buffer); + return zip_error_string; + } + else { + size_t length = strlen(system_error_string); + if (zip_error_string) { + size_t length_error = strlen(zip_error_string); + if (length + length_error + 2 < length) { + free(system_error_buffer); + return _zip_err_str[ZIP_ER_MEMORY].description; + } + length += length_error + 2; + } + if (length == SIZE_MAX || (s = (char *)malloc(length + 1)) == NULL) { + free(system_error_buffer); + return _zip_err_str[ZIP_ER_MEMORY].description; + } + + snprintf_s(s, length + 1, "%s%s%s", (zip_error_string ? zip_error_string : ""), (zip_error_string ? ": " : ""), system_error_string); + err->str = s; + + free(system_error_buffer); + return s; + } +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_error_to_str.c b/thirdparty/libzip-1.11.3/lib/zip_error_to_str.c new file mode 100644 index 0000000..4186e3a --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_error_to_str.c @@ -0,0 +1,58 @@ +/* + zip_error_to_str.c -- get string representation of zip error code + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include + +#define _ZIP_COMPILING_DEPRECATED +#include "zipint.h" + + +ZIP_EXTERN int +zip_error_to_str(char *buf, zip_uint64_t len, int ze, int se) { + zip_error_t error; + const char *error_string; + int ret; + + zip_error_init(&error); + zip_error_set(&error, ze, se); + + error_string = zip_error_strerror(&error); + + ret = snprintf_s(buf, ZIP_MIN(len, SIZE_MAX), error_string, strlen(error_string)); + + zip_error_fini(&error); + + return ret; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_extra_field.c b/thirdparty/libzip-1.11.3/lib/zip_extra_field.c new file mode 100644 index 0000000..5283704 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_extra_field.c @@ -0,0 +1,427 @@ +/* + zip_extra_field.c -- manipulate extra fields + Copyright (C) 2012-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include + +#include "zipint.h" + + +zip_extra_field_t * +_zip_ef_clone(const zip_extra_field_t *ef, zip_error_t *error) { + zip_extra_field_t *head, *prev, *def; + + head = prev = NULL; + + while (ef) { + if ((def = _zip_ef_new(ef->id, ef->size, ef->data, ef->flags)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + _zip_ef_free(head); + return NULL; + } + + if (head == NULL) + head = def; + if (prev) + prev->next = def; + prev = def; + + ef = ef->next; + } + + return head; +} + + +zip_extra_field_t * +_zip_ef_delete_by_id(zip_extra_field_t *ef, zip_uint16_t id, zip_uint16_t id_idx, zip_flags_t flags) { + zip_extra_field_t *head, *prev; + int i; + + i = 0; + head = ef; + prev = NULL; + for (; ef; ef = (prev ? prev->next : head)) { + if ((ef->flags & flags & ZIP_EF_BOTH) && ((ef->id == id) || (id == ZIP_EXTRA_FIELD_ALL))) { + if (id_idx == ZIP_EXTRA_FIELD_ALL || i == id_idx) { + ef->flags &= ~(flags & ZIP_EF_BOTH); + if ((ef->flags & ZIP_EF_BOTH) == 0) { + if (prev) + prev->next = ef->next; + else + head = ef->next; + ef->next = NULL; + _zip_ef_free(ef); + + if (id_idx == ZIP_EXTRA_FIELD_ALL) + continue; + } + } + + i++; + if (i > id_idx) + break; + } + prev = ef; + } + + return head; +} + + +void +_zip_ef_free(zip_extra_field_t *ef) { + zip_extra_field_t *ef2; + + while (ef) { + ef2 = ef->next; + free(ef->data); + free(ef); + ef = ef2; + } +} + + +const zip_uint8_t * +_zip_ef_get_by_id(const zip_extra_field_t *ef, zip_uint16_t *lenp, zip_uint16_t id, zip_uint16_t id_idx, zip_flags_t flags, zip_error_t *error) { + static const zip_uint8_t empty[1] = {'\0'}; + + int i; + + i = 0; + for (; ef; ef = ef->next) { + if (ef->id == id && (ef->flags & flags & ZIP_EF_BOTH)) { + if (i < id_idx) { + i++; + continue; + } + + if (lenp) + *lenp = ef->size; + if (ef->size > 0) + return ef->data; + else + return empty; + } + } + + zip_error_set(error, ZIP_ER_NOENT, 0); + return NULL; +} + + +zip_extra_field_t * +_zip_ef_merge(zip_extra_field_t *to, zip_extra_field_t *from) { + zip_extra_field_t *ef2, *tt, *tail; + int duplicate; + + if (to == NULL) + return from; + + for (tail = to; tail->next; tail = tail->next) + ; + + for (; from; from = ef2) { + ef2 = from->next; + + duplicate = 0; + for (tt = to; tt; tt = tt->next) { + if (tt->id == from->id && tt->size == from->size && (tt->size == 0 || memcmp(tt->data, from->data, tt->size) == 0)) { + tt->flags |= (from->flags & ZIP_EF_BOTH); + duplicate = 1; + break; + } + } + + from->next = NULL; + if (duplicate) + _zip_ef_free(from); + else + tail = tail->next = from; + } + + return to; +} + + +zip_extra_field_t * +_zip_ef_new(zip_uint16_t id, zip_uint16_t size, const zip_uint8_t *data, zip_flags_t flags) { + zip_extra_field_t *ef; + + if ((ef = (zip_extra_field_t *)malloc(sizeof(*ef))) == NULL) + return NULL; + + ef->next = NULL; + ef->flags = flags; + ef->id = id; + ef->size = size; + if (size > 0) { + if ((ef->data = (zip_uint8_t *)_zip_memdup(data, size, NULL)) == NULL) { + free(ef); + return NULL; + } + } + else + ef->data = NULL; + + return ef; +} + + +bool +_zip_ef_parse(const zip_uint8_t *data, zip_uint16_t len, zip_flags_t flags, zip_extra_field_t **ef_head_p, zip_error_t *error) { + zip_buffer_t *buffer; + zip_extra_field_t *ef, *ef2, *ef_head; + + if ((buffer = _zip_buffer_new((zip_uint8_t *)data, len)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return false; + } + + ef_head = ef = NULL; + + while (_zip_buffer_ok(buffer) && _zip_buffer_left(buffer) >= 4) { + zip_uint16_t fid, flen; + zip_uint8_t *ef_data; + + fid = _zip_buffer_get_16(buffer); + flen = _zip_buffer_get_16(buffer); + ef_data = _zip_buffer_get(buffer, flen); + + if (ef_data == NULL) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_INVALID_EF_LENGTH); + _zip_buffer_free(buffer); + _zip_ef_free(ef_head); + return false; + } + + if ((ef2 = _zip_ef_new(fid, flen, ef_data, flags)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + _zip_buffer_free(buffer); + _zip_ef_free(ef_head); + return false; + } + + if (ef_head) { + ef->next = ef2; + ef = ef2; + } + else + ef_head = ef = ef2; + } + + if (!_zip_buffer_eof(buffer)) { + /* Android APK files align stored file data with padding in extra fields; ignore. */ + /* see https://android.googlesource.com/platform/build/+/master/tools/zipalign/ZipAlign.cpp */ + /* buffer is at most 64k long, so this can't overflow. */ + size_t glen = _zip_buffer_left(buffer); + zip_uint8_t *garbage; + garbage = _zip_buffer_get(buffer, glen); + if (glen >= 4 || garbage == NULL || memcmp(garbage, "\0\0\0", (size_t)glen) != 0) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_EF_TRAILING_GARBAGE); + _zip_buffer_free(buffer); + _zip_ef_free(ef_head); + return false; + } + } + + _zip_buffer_free(buffer); + + if (ef_head_p) { + *ef_head_p = ef_head; + } + else { + _zip_ef_free(ef_head); + } + + return true; +} + + +zip_extra_field_t * +_zip_ef_remove_internal(zip_extra_field_t *ef) { + zip_extra_field_t *ef_head; + zip_extra_field_t *prev, *next; + + ef_head = ef; + prev = NULL; + + while (ef) { + if (ZIP_EF_IS_INTERNAL(ef->id)) { + next = ef->next; + if (ef_head == ef) + ef_head = next; + ef->next = NULL; + _zip_ef_free(ef); + if (prev) + prev->next = next; + ef = next; + } + else { + prev = ef; + ef = ef->next; + } + } + + return ef_head; +} + + +zip_uint16_t +_zip_ef_size(const zip_extra_field_t *ef, zip_flags_t flags) { + zip_uint16_t size; + + size = 0; + for (; ef; ef = ef->next) { + if (ef->flags & flags & ZIP_EF_BOTH) + size = (zip_uint16_t)(size + 4 + ef->size); + } + + return size; +} + + +int +_zip_ef_write(zip_t *za, const zip_extra_field_t *ef, zip_flags_t flags) { + zip_uint8_t b[4]; + zip_buffer_t *buffer = _zip_buffer_new(b, sizeof(b)); + + if (buffer == NULL) { + return -1; + } + + for (; ef; ef = ef->next) { + if (ef->flags & flags & ZIP_EF_BOTH) { + _zip_buffer_set_offset(buffer, 0); + _zip_buffer_put_16(buffer, ef->id); + _zip_buffer_put_16(buffer, ef->size); + if (!_zip_buffer_ok(buffer)) { + zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); + _zip_buffer_free(buffer); + return -1; + } + if (_zip_write(za, b, 4) < 0) { + _zip_buffer_free(buffer); + return -1; + } + if (ef->size > 0) { + if (_zip_write(za, ef->data, ef->size) < 0) { + _zip_buffer_free(buffer); + return -1; + } + } + } + } + + _zip_buffer_free(buffer); + return 0; +} + + +int +_zip_read_local_ef(zip_t *za, zip_uint64_t idx) { + zip_entry_t *e; + unsigned char b[4]; + zip_buffer_t *buffer; + zip_uint16_t fname_len, ef_len; + + if (idx >= za->nentry) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + e = za->entry + idx; + + if (e->orig == NULL || e->orig->local_extra_fields_read) + return 0; + + if (e->orig->offset + 26 > ZIP_INT64_MAX) { + zip_error_set(&za->error, ZIP_ER_SEEK, EFBIG); + return -1; + } + + if (zip_source_seek(za->src, (zip_int64_t)(e->orig->offset + 26), SEEK_SET) < 0) { + zip_error_set_from_source(&za->error, za->src); + return -1; + } + + if ((buffer = _zip_buffer_new_from_source(za->src, sizeof(b), b, &za->error)) == NULL) { + return -1; + } + + fname_len = _zip_buffer_get_16(buffer); + ef_len = _zip_buffer_get_16(buffer); + + if (!_zip_buffer_eof(buffer)) { + _zip_buffer_free(buffer); + zip_error_set(&za->error, ZIP_ER_INTERNAL, 0); + return -1; + } + + _zip_buffer_free(buffer); + + if (ef_len > 0) { + zip_extra_field_t *ef; + zip_uint8_t *ef_raw; + + if (zip_source_seek(za->src, fname_len, SEEK_CUR) < 0) { + zip_error_set(&za->error, ZIP_ER_SEEK, errno); + return -1; + } + + ef_raw = _zip_read_data(NULL, za->src, ef_len, 0, &za->error); + + if (ef_raw == NULL) + return -1; + + if (!_zip_ef_parse(ef_raw, ef_len, ZIP_EF_LOCAL, &ef, &za->error)) { + free(ef_raw); + return -1; + } + free(ef_raw); + + if (ef) { + ef = _zip_ef_remove_internal(ef); + e->orig->extra_fields = _zip_ef_merge(e->orig->extra_fields, ef); + } + } + + e->orig->local_extra_fields_read = 1; + + if (e->changes && e->changes->local_extra_fields_read == 0) { + e->changes->extra_fields = e->orig->extra_fields; + e->changes->local_extra_fields_read = 1; + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_extra_field_api.c b/thirdparty/libzip-1.11.3/lib/zip_extra_field_api.c new file mode 100644 index 0000000..6f2b459 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_extra_field_api.c @@ -0,0 +1,363 @@ +/* + zip_extra_field_api.c -- public extra fields API functions + Copyright (C) 2012-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_file_extra_field_delete(zip_t *za, zip_uint64_t idx, zip_uint16_t ef_idx, zip_flags_t flags) { + zip_dirent_t *de; + + if ((flags & ZIP_EF_BOTH) == 0) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (((flags & ZIP_EF_BOTH) == ZIP_EF_BOTH) && (ef_idx != ZIP_EXTRA_FIELD_ALL)) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (_zip_get_dirent(za, idx, 0, NULL) == NULL) + return -1; + + if (ZIP_IS_RDONLY(za)) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + + if (_zip_file_extra_field_prepare_for_change(za, idx) < 0) + return -1; + + de = za->entry[idx].changes; + + de->extra_fields = _zip_ef_delete_by_id(de->extra_fields, ZIP_EXTRA_FIELD_ALL, ef_idx, flags); + return 0; +} + + +ZIP_EXTERN int +zip_file_extra_field_delete_by_id(zip_t *za, zip_uint64_t idx, zip_uint16_t ef_id, zip_uint16_t ef_idx, zip_flags_t flags) { + zip_dirent_t *de; + + if ((flags & ZIP_EF_BOTH) == 0) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (((flags & ZIP_EF_BOTH) == ZIP_EF_BOTH) && (ef_idx != ZIP_EXTRA_FIELD_ALL)) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (_zip_get_dirent(za, idx, 0, NULL) == NULL) + return -1; + + if (ZIP_IS_RDONLY(za)) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + if (ZIP_WANT_TORRENTZIP(za)) { + zip_error_set(&za->error, ZIP_ER_NOT_ALLOWED, 0); + return -1; + } + + if (_zip_file_extra_field_prepare_for_change(za, idx) < 0) + return -1; + + de = za->entry[idx].changes; + + de->extra_fields = _zip_ef_delete_by_id(de->extra_fields, ef_id, ef_idx, flags); + return 0; +} + + +ZIP_EXTERN const zip_uint8_t * +zip_file_extra_field_get(zip_t *za, zip_uint64_t idx, zip_uint16_t ef_idx, zip_uint16_t *idp, zip_uint16_t *lenp, zip_flags_t flags) { + static const zip_uint8_t empty[1] = {'\0'}; + + zip_dirent_t *de; + zip_extra_field_t *ef; + int i; + + if ((flags & ZIP_EF_BOTH) == 0) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((de = _zip_get_dirent(za, idx, flags, &za->error)) == NULL) + return NULL; + + if (flags & ZIP_FL_LOCAL) + if (_zip_read_local_ef(za, idx) < 0) + return NULL; + + i = 0; + for (ef = de->extra_fields; ef; ef = ef->next) { + if (ef->flags & flags & ZIP_EF_BOTH) { + if (i < ef_idx) { + i++; + continue; + } + + if (idp) + *idp = ef->id; + if (lenp) + *lenp = ef->size; + if (ef->size > 0) + return ef->data; + else + return empty; + } + } + + zip_error_set(&za->error, ZIP_ER_NOENT, 0); + return NULL; +} + + +ZIP_EXTERN const zip_uint8_t * +zip_file_extra_field_get_by_id(zip_t *za, zip_uint64_t idx, zip_uint16_t ef_id, zip_uint16_t ef_idx, zip_uint16_t *lenp, zip_flags_t flags) { + zip_dirent_t *de; + + if ((flags & ZIP_EF_BOTH) == 0) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((de = _zip_get_dirent(za, idx, flags, &za->error)) == NULL) + return NULL; + + if (flags & ZIP_FL_LOCAL) + if (_zip_read_local_ef(za, idx) < 0) + return NULL; + + return _zip_ef_get_by_id(de->extra_fields, lenp, ef_id, ef_idx, flags, &za->error); +} + + +ZIP_EXTERN zip_int16_t +zip_file_extra_fields_count(zip_t *za, zip_uint64_t idx, zip_flags_t flags) { + zip_dirent_t *de; + zip_extra_field_t *ef; + zip_uint16_t n; + + if ((flags & ZIP_EF_BOTH) == 0) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if ((de = _zip_get_dirent(za, idx, flags, &za->error)) == NULL) + return -1; + + if (flags & ZIP_FL_LOCAL) + if (_zip_read_local_ef(za, idx) < 0) + return -1; + + n = 0; + for (ef = de->extra_fields; ef; ef = ef->next) + if (ef->flags & flags & ZIP_EF_BOTH) + n++; + + return (zip_int16_t)n; +} + + +ZIP_EXTERN zip_int16_t +zip_file_extra_fields_count_by_id(zip_t *za, zip_uint64_t idx, zip_uint16_t ef_id, zip_flags_t flags) { + zip_dirent_t *de; + zip_extra_field_t *ef; + zip_uint16_t n; + + if ((flags & ZIP_EF_BOTH) == 0) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if ((de = _zip_get_dirent(za, idx, flags, &za->error)) == NULL) + return -1; + + if (flags & ZIP_FL_LOCAL) + if (_zip_read_local_ef(za, idx) < 0) + return -1; + + n = 0; + for (ef = de->extra_fields; ef; ef = ef->next) + if (ef->id == ef_id && (ef->flags & flags & ZIP_EF_BOTH)) + n++; + + return (zip_int16_t)n; +} + + +ZIP_EXTERN int +zip_file_extra_field_set(zip_t *za, zip_uint64_t idx, zip_uint16_t ef_id, zip_uint16_t ef_idx, const zip_uint8_t *data, zip_uint16_t len, zip_flags_t flags) { + zip_dirent_t *de; + zip_uint16_t ls, cs; + zip_extra_field_t *ef, *ef_prev, *ef_new; + int i, found, new_len; + + if ((flags & ZIP_EF_BOTH) == 0) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (_zip_get_dirent(za, idx, 0, NULL) == NULL) + return -1; + + if (ZIP_IS_RDONLY(za)) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + if (ZIP_WANT_TORRENTZIP(za)) { + zip_error_set(&za->error, ZIP_ER_NOT_ALLOWED, 0); + return -1; + } + + if (ZIP_EF_IS_INTERNAL(ef_id)) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (_zip_file_extra_field_prepare_for_change(za, idx) < 0) + return -1; + + de = za->entry[idx].changes; + + ef = de->extra_fields; + ef_prev = NULL; + i = 0; + found = 0; + + for (; ef; ef = ef->next) { + if (ef->id == ef_id && (ef->flags & flags & ZIP_EF_BOTH)) { + if (i == ef_idx) { + found = 1; + break; + } + i++; + } + ef_prev = ef; + } + + if (i < ef_idx && ef_idx != ZIP_EXTRA_FIELD_NEW) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (flags & ZIP_EF_LOCAL) + ls = _zip_ef_size(de->extra_fields, ZIP_EF_LOCAL); + else + ls = 0; + if (flags & ZIP_EF_CENTRAL) + cs = _zip_ef_size(de->extra_fields, ZIP_EF_CENTRAL); + else + cs = 0; + + new_len = ls > cs ? ls : cs; + if (found) + new_len -= ef->size + 4; + new_len += len + 4; + + if (new_len > ZIP_UINT16_MAX) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if ((ef_new = _zip_ef_new(ef_id, len, data, flags)) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + + if (found) { + if ((ef->flags & ZIP_EF_BOTH) == (flags & ZIP_EF_BOTH)) { + ef_new->next = ef->next; + ef->next = NULL; + _zip_ef_free(ef); + if (ef_prev) + ef_prev->next = ef_new; + else + de->extra_fields = ef_new; + } + else { + ef->flags &= ~(flags & ZIP_EF_BOTH); + ef_new->next = ef->next; + ef->next = ef_new; + } + } + else if (ef_prev) { + ef_new->next = ef_prev->next; + ef_prev->next = ef_new; + } + else + de->extra_fields = ef_new; + + return 0; +} + + +int +_zip_file_extra_field_prepare_for_change(zip_t *za, zip_uint64_t idx) { + zip_entry_t *e; + + if (idx >= za->nentry) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + e = za->entry + idx; + + if (e->changes && (e->changes->changed & ZIP_DIRENT_EXTRA_FIELD)) + return 0; + + if (e->orig) { + if (_zip_read_local_ef(za, idx) < 0) + return -1; + } + + if (e->changes == NULL) { + if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + } + + if (e->orig && e->orig->extra_fields) { + if ((e->changes->extra_fields = _zip_ef_clone(e->orig->extra_fields, &za->error)) == NULL) + return -1; + } + e->changes->changed |= ZIP_DIRENT_EXTRA_FIELD; + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_fclose.c b/thirdparty/libzip-1.11.3/lib/zip_fclose.c new file mode 100644 index 0000000..2ef579a --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_fclose.c @@ -0,0 +1,54 @@ +/* + zip_fclose.c -- close file in zip archive + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +ZIP_EXTERN int +zip_fclose(zip_file_t *zf) { + int ret; + + if (zf->src) + zip_source_free(zf->src); + + ret = 0; + if (zf->error.zip_err) + ret = zf->error.zip_err; + + zip_error_fini(&zf->error); + free(zf); + return ret; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_fdopen.c b/thirdparty/libzip-1.11.3/lib/zip_fdopen.c new file mode 100644 index 0000000..94fe6c7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_fdopen.c @@ -0,0 +1,91 @@ +/* + zip_fdopen.c -- open read-only archive from file descriptor + Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" +#ifdef HAVE_UNISTD_H +#include +#endif + + +ZIP_EXTERN zip_t * +zip_fdopen(int fd_orig, int _flags, int *zep) { + int fd; + FILE *fp; + zip_t *za; + zip_source_t *src; + struct zip_error error; + + if (_flags < 0 || (_flags & ~(ZIP_CHECKCONS | ZIP_RDONLY))) { + _zip_set_open_error(zep, NULL, ZIP_ER_INVAL); + return NULL; + } + +#ifndef ENABLE_FDOPEN + _zip_set_open_error(zep, NULL, ZIP_ER_OPNOTSUPP); + return NULL; +#else + /* We dup() here to avoid messing with the passed in fd. + We could not restore it to the original state in case of error. */ + + if ((fd = dup(fd_orig)) < 0) { + _zip_set_open_error(zep, NULL, ZIP_ER_OPEN); + return NULL; + } + + if ((fp = fdopen(fd, "rb")) == NULL) { + close(fd); + _zip_set_open_error(zep, NULL, ZIP_ER_OPEN); + return NULL; + } + + zip_error_init(&error); + if ((src = zip_source_filep_create(fp, 0, -1, &error)) == NULL) { + fclose(fp); + _zip_set_open_error(zep, &error, 0); + zip_error_fini(&error); + return NULL; + } + + if ((za = zip_open_from_source(src, _flags, &error)) == NULL) { + zip_source_free(src); + _zip_set_open_error(zep, &error, 0); + zip_error_fini(&error); + return NULL; + } + + zip_error_fini(&error); + close(fd_orig); + return za; +#endif +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_file_add.c b/thirdparty/libzip-1.11.3/lib/zip_file_add.c new file mode 100644 index 0000000..5959d50 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_file_add.c @@ -0,0 +1,52 @@ +/* + zip_file_add.c -- add file via callback function + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + +/* + NOTE: Return type is signed so we can return -1 on error. + The index can not be larger than ZIP_INT64_MAX since the size + of the central directory cannot be larger than + ZIP_UINT64_MAX, and each entry is larger than 2 bytes. +*/ + +ZIP_EXTERN zip_int64_t +zip_file_add(zip_t *za, const char *name, zip_source_t *source, zip_flags_t flags) { + if (name == NULL || source == NULL) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + return _zip_file_replace(za, ZIP_UINT64_MAX, name, source, flags); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_file_error_clear.c b/thirdparty/libzip-1.11.3/lib/zip_file_error_clear.c new file mode 100644 index 0000000..eb9a614 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_file_error_clear.c @@ -0,0 +1,44 @@ +/* + zip_file_error_clear.c -- clear zip file error + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN void +zip_file_error_clear(zip_file_t *zf) { + if (zf == NULL) + return; + + _zip_error_clear(&zf->error); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_file_error_get.c b/thirdparty/libzip-1.11.3/lib/zip_file_error_get.c new file mode 100644 index 0000000..679aeef --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_file_error_get.c @@ -0,0 +1,41 @@ +/* + zip_file_error_get.c -- get zip file error + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#define _ZIP_COMPILING_DEPRECATED +#include "zipint.h" + + +ZIP_EXTERN void +zip_file_error_get(zip_file_t *zf, int *zep, int *sep) { + _zip_error_get(&zf->error, zep, sep); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_file_get_comment.c b/thirdparty/libzip-1.11.3/lib/zip_file_get_comment.c new file mode 100644 index 0000000..ca04042 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_file_get_comment.c @@ -0,0 +1,55 @@ +/* + zip_file_get_comment.c -- get file comment + Copyright (C) 2006-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + +/* lenp is 32 bit because converted comment can be longer than ZIP_UINT16_MAX */ + +ZIP_EXTERN const char * +zip_file_get_comment(zip_t *za, zip_uint64_t idx, zip_uint32_t *lenp, zip_flags_t flags) { + zip_dirent_t *de; + zip_uint32_t len; + const zip_uint8_t *str; + + if ((de = _zip_get_dirent(za, idx, flags, NULL)) == NULL) + return NULL; + + if ((str = _zip_string_get(de->comment, &len, flags, &za->error)) == NULL) + return NULL; + + if (lenp) + *lenp = len; + + return (const char *)str; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_file_get_external_attributes.c b/thirdparty/libzip-1.11.3/lib/zip_file_get_external_attributes.c new file mode 100644 index 0000000..483557f --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_file_get_external_attributes.c @@ -0,0 +1,50 @@ +/* + zip_file_get_external_attributes.c -- get opsys/external attributes + Copyright (C) 2013-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +int +zip_file_get_external_attributes(zip_t *za, zip_uint64_t idx, zip_flags_t flags, zip_uint8_t *opsys, zip_uint32_t *attributes) { + zip_dirent_t *de; + + if ((de = _zip_get_dirent(za, idx, flags, NULL)) == NULL) + return -1; + + if (opsys) + *opsys = (zip_uint8_t)((de->version_madeby >> 8) & 0xff); + + if (attributes) + *attributes = de->ext_attrib; + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_file_get_offset.c b/thirdparty/libzip-1.11.3/lib/zip_file_get_offset.c new file mode 100644 index 0000000..c50def5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_file_get_offset.c @@ -0,0 +1,117 @@ +/* + zip_file_get_offset.c -- get offset of file data in archive. + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include + +#include "zipint.h" + + +/* _zip_file_get_offset(za, ze): + Returns the offset of the file data for entry ze. + + On error, fills in za->error and returns 0. +*/ + +zip_uint64_t +_zip_file_get_offset(const zip_t *za, zip_uint64_t idx, zip_error_t *error) { + zip_uint64_t offset; + zip_int32_t size; + + if (za->entry[idx].orig == NULL) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + return 0; + } + + offset = za->entry[idx].orig->offset; + + if (zip_source_seek(za->src, (zip_int64_t)offset, SEEK_SET) < 0) { + zip_error_set_from_source(error, za->src); + return 0; + } + + /* TODO: cache? */ + if ((size = _zip_dirent_size(za->src, ZIP_EF_LOCAL, error)) < 0) + return 0; + + if (offset + (zip_uint32_t)size > ZIP_INT64_MAX) { + zip_error_set(error, ZIP_ER_SEEK, EFBIG); + return 0; + } + + return offset + (zip_uint32_t)size; +} + +zip_uint64_t +_zip_file_get_end(const zip_t *za, zip_uint64_t index, zip_error_t *error) { + zip_uint64_t offset; + zip_dirent_t *entry; + + if ((offset = _zip_file_get_offset(za, index, error)) == 0) { + return 0; + } + + entry = za->entry[index].orig; + + if (offset + entry->comp_size < offset || offset + entry->comp_size > ZIP_INT64_MAX) { + zip_error_set(error, ZIP_ER_SEEK, EFBIG); + return 0; + } + offset += entry->comp_size; + + if (entry->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) { + zip_uint8_t buf[4]; + if (zip_source_seek(za->src, (zip_int64_t)offset, SEEK_SET) < 0) { + zip_error_set_from_source(error, za->src); + return 0; + } + if (zip_source_read(za->src, buf, 4) != 4) { + zip_error_set_from_source(error, za->src); + return 0; + } + if (memcmp(buf, DATADES_MAGIC, 4) == 0) { + offset += 4; + } + offset += 12; + if (_zip_dirent_needs_zip64(entry, 0)) { + offset += 8; + } + if (offset > ZIP_INT64_MAX) { + zip_error_set(error, ZIP_ER_SEEK, EFBIG); + return 0; + } + } + + return offset; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_file_rename.c b/thirdparty/libzip-1.11.3/lib/zip_file_rename.c new file mode 100644 index 0000000..03101e4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_file_rename.c @@ -0,0 +1,67 @@ +/* + zip_file_rename.c -- rename file in zip archive + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +ZIP_EXTERN int +zip_file_rename(zip_t *za, zip_uint64_t idx, const char *name, zip_flags_t flags) { + const char *old_name; + int old_is_dir, new_is_dir; + + if (idx >= za->nentry || (name != NULL && strlen(name) > ZIP_UINT16_MAX)) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (ZIP_IS_RDONLY(za)) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + + if ((old_name = zip_get_name(za, idx, 0)) == NULL) + return -1; + + new_is_dir = (name != NULL && name[strlen(name) - 1] == '/'); + old_is_dir = (old_name[strlen(old_name) - 1] == '/'); + + if (new_is_dir != old_is_dir) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + return _zip_set_name(za, idx, name, flags); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_file_replace.c b/thirdparty/libzip-1.11.3/lib/zip_file_replace.c new file mode 100644 index 0000000..ce457ed --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_file_replace.c @@ -0,0 +1,111 @@ +/* + zip_file_replace.c -- replace file via callback function + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_file_replace(zip_t *za, zip_uint64_t idx, zip_source_t *source, zip_flags_t flags) { + if (idx >= za->nentry || source == NULL) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (_zip_file_replace(za, idx, NULL, source, flags) == -1) + return -1; + + return 0; +} + + +/* NOTE: Signed due to -1 on error. See zip_add.c for more details. */ + +zip_int64_t +_zip_file_replace(zip_t *za, zip_uint64_t idx, const char *name, zip_source_t *source, zip_flags_t flags) { + zip_uint64_t za_nentry_prev; + + if (ZIP_IS_RDONLY(za)) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + + za_nentry_prev = za->nentry; + if (idx == ZIP_UINT64_MAX) { + zip_int64_t i = -1; + + if (flags & ZIP_FL_OVERWRITE) + i = _zip_name_locate(za, name, flags, NULL); + + if (i == -1) { + /* create and use new entry, used by zip_add */ + if ((i = _zip_add_entry(za)) < 0) + return -1; + } + idx = (zip_uint64_t)i; + } + + if (name && _zip_set_name(za, idx, name, flags) != 0) { + if (za->nentry != za_nentry_prev) { + _zip_entry_finalize(za->entry + idx); + za->nentry = za_nentry_prev; + } + return -1; + } + + /* delete all extra fields - these are usually data that are + * strongly coupled with the original data */ + if (zip_file_extra_field_delete(za, idx, ZIP_EXTRA_FIELD_ALL, ZIP_FL_CENTRAL | ZIP_FL_LOCAL) < 0) { + return -1; + } + + /* does not change any name related data, so we can do it here; + * needed for a double add of the same file name */ + _zip_unchange_data(za->entry + idx); + + if (za->entry[idx].orig != NULL && (za->entry[idx].changes == NULL || (za->entry[idx].changes->changed & ZIP_DIRENT_COMP_METHOD) == 0)) { + if (za->entry[idx].changes == NULL) { + if ((za->entry[idx].changes = _zip_dirent_clone(za->entry[idx].orig)) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + } + + za->entry[idx].changes->comp_method = ZIP_CM_REPLACED_DEFAULT; + za->entry[idx].changes->changed |= ZIP_DIRENT_COMP_METHOD; + } + + za->entry[idx].source = source; + + return (zip_int64_t)idx; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_file_set_comment.c b/thirdparty/libzip-1.11.3/lib/zip_file_set_comment.c new file mode 100644 index 0000000..fb7b9ed --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_file_set_comment.c @@ -0,0 +1,105 @@ +/* + zip_file_set_comment.c -- set comment for file in archive + Copyright (C) 2006-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +ZIP_EXTERN int +zip_file_set_comment(zip_t *za, zip_uint64_t idx, const char *comment, zip_uint16_t len, zip_flags_t flags) { + zip_entry_t *e; + zip_string_t *cstr; + int changed; + + if (_zip_get_dirent(za, idx, 0, NULL) == NULL) + return -1; + + if (ZIP_IS_RDONLY(za)) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + if (ZIP_WANT_TORRENTZIP(za)) { + zip_error_set(&za->error, ZIP_ER_NOT_ALLOWED, 0); + return -1; + } + + if (len > 0 && comment == NULL) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (len > 0) { + if ((cstr = _zip_string_new((const zip_uint8_t *)comment, len, flags, &za->error)) == NULL) + return -1; + if ((flags & ZIP_FL_ENCODING_ALL) == ZIP_FL_ENC_GUESS && _zip_guess_encoding(cstr, ZIP_ENCODING_UNKNOWN) == ZIP_ENCODING_UTF8_GUESSED) + cstr->encoding = ZIP_ENCODING_UTF8_KNOWN; + } + else + cstr = NULL; + + e = za->entry + idx; + + if (e->changes) { + _zip_string_free(e->changes->comment); + e->changes->comment = NULL; + e->changes->changed &= ~ZIP_DIRENT_COMMENT; + } + + if (e->orig && e->orig->comment) + changed = !_zip_string_equal(e->orig->comment, cstr); + else + changed = (cstr != NULL); + + if (changed) { + if (e->changes == NULL) { + if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + _zip_string_free(cstr); + return -1; + } + } + e->changes->comment = cstr; + e->changes->changed |= ZIP_DIRENT_COMMENT; + } + else { + _zip_string_free(cstr); + if (e->changes && e->changes->changed == 0) { + _zip_dirent_free(e->changes); + e->changes = NULL; + } + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_file_set_encryption.c b/thirdparty/libzip-1.11.3/lib/zip_file_set_encryption.c new file mode 100644 index 0000000..7bb6cdc --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_file_set_encryption.c @@ -0,0 +1,120 @@ +/* + zip_file_set_encryption.c -- set encryption for file in archive + Copyright (C) 2016-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + +#include +#include + +ZIP_EXTERN int +zip_file_set_encryption(zip_t *za, zip_uint64_t idx, zip_uint16_t method, const char *password) { + zip_entry_t *e; + zip_uint16_t old_method; + + if (idx >= za->nentry) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (ZIP_IS_RDONLY(za)) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + if (ZIP_WANT_TORRENTZIP(za)) { + zip_error_set(&za->error, ZIP_ER_NOT_ALLOWED, 0); + return -1; + } + + if (method != ZIP_EM_NONE && _zip_get_encryption_implementation(method, ZIP_CODEC_ENCODE) == NULL) { + zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0); + return -1; + } + + e = za->entry + idx; + + old_method = (e->orig == NULL ? ZIP_EM_NONE : e->orig->encryption_method); + + if (method == old_method && password == NULL) { + if (e->changes) { + if (e->changes->changed & ZIP_DIRENT_PASSWORD) { + _zip_crypto_clear(e->changes->password, strlen(e->changes->password)); + free(e->changes->password); + e->changes->password = (e->orig == NULL ? NULL : e->orig->password); + } + e->changes->changed &= ~(ZIP_DIRENT_ENCRYPTION_METHOD | ZIP_DIRENT_PASSWORD); + if (e->changes->changed == 0) { + _zip_dirent_free(e->changes); + e->changes = NULL; + } + } + } + else { + char *our_password = NULL; + + if (password) { + if ((our_password = strdup(password)) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + } + + if (e->changes == NULL) { + if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) { + if (our_password) { + _zip_crypto_clear(our_password, strlen(our_password)); + } + free(our_password); + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + } + + e->changes->encryption_method = method; + e->changes->changed |= ZIP_DIRENT_ENCRYPTION_METHOD; + if (password) { + e->changes->password = our_password; + e->changes->changed |= ZIP_DIRENT_PASSWORD; + } + else { + if (e->changes->changed & ZIP_DIRENT_PASSWORD) { + _zip_crypto_clear(e->changes->password, strlen(e->changes->password)); + free(e->changes->password); + e->changes->password = e->orig ? e->orig->password : NULL; + e->changes->changed &= ~ZIP_DIRENT_PASSWORD; + } + } + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_file_set_external_attributes.c b/thirdparty/libzip-1.11.3/lib/zip_file_set_external_attributes.c new file mode 100644 index 0000000..2f9d30f --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_file_set_external_attributes.c @@ -0,0 +1,86 @@ +/* + zip_file_set_external_attributes.c -- set external attributes for entry + Copyright (C) 2013-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +ZIP_EXTERN int +zip_file_set_external_attributes(zip_t *za, zip_uint64_t idx, zip_flags_t flags, zip_uint8_t opsys, zip_uint32_t attributes) { + zip_entry_t *e; + int changed; + zip_uint8_t unchanged_opsys; + zip_uint32_t unchanged_attributes; + + if (_zip_get_dirent(za, idx, 0, NULL) == NULL) + return -1; + + if (ZIP_IS_RDONLY(za)) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + if (ZIP_WANT_TORRENTZIP(za)) { + zip_error_set(&za->error, ZIP_ER_NOT_ALLOWED, 0); + return -1; + } + + e = za->entry + idx; + + unchanged_opsys = (e->orig ? (zip_uint8_t)(e->orig->version_madeby >> 8) : (zip_uint8_t)ZIP_OPSYS_DEFAULT); + unchanged_attributes = e->orig ? e->orig->ext_attrib : ZIP_EXT_ATTRIB_DEFAULT; + + changed = (opsys != unchanged_opsys || attributes != unchanged_attributes); + + if (changed) { + if (e->changes == NULL) { + if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + } + e->changes->version_madeby = (zip_uint16_t)((opsys << 8) | (e->changes->version_madeby & 0xff)); + e->changes->ext_attrib = attributes; + e->changes->changed |= ZIP_DIRENT_ATTRIBUTES; + } + else if (e->changes) { + e->changes->changed &= ~ZIP_DIRENT_ATTRIBUTES; + if (e->changes->changed == 0) { + _zip_dirent_free(e->changes); + e->changes = NULL; + } + else { + e->changes->version_madeby = (zip_uint16_t)((unchanged_opsys << 8) | (e->changes->version_madeby & 0xff)); + e->changes->ext_attrib = unchanged_attributes; + } + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_file_set_mtime.c b/thirdparty/libzip-1.11.3/lib/zip_file_set_mtime.c new file mode 100644 index 0000000..e60f7a9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_file_set_mtime.c @@ -0,0 +1,93 @@ +/* + zip_file_set_mtime.c -- set modification time of entry. + Copyright (C) 2014-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "zipint.h" + +static int zip_file_set_time(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16_t ddate, zip_flags_t flags, time_t *mtime) { + zip_entry_t *e; + + if (_zip_get_dirent(za, idx, 0, NULL) == NULL) { + return -1; + } + + if (ZIP_IS_RDONLY(za)) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + if (ZIP_WANT_TORRENTZIP(za)) { + zip_error_set(&za->error, ZIP_ER_NOT_ALLOWED, 0); + return -1; + } + + e = za->entry + idx; + + if (e->orig != NULL && e->orig->encryption_method == ZIP_EM_TRAD_PKWARE && !ZIP_ENTRY_CHANGED(e, ZIP_DIRENT_ENCRYPTION_METHOD) && !ZIP_ENTRY_DATA_CHANGED(e)) { + zip_error_set(&za->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + } + + if (e->changes == NULL) { + if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + } + + e->changes->last_mod.time = dtime; + e->changes->last_mod.date = ddate; + if (mtime != NULL) { + e->changes->last_mod_mtime = *mtime; + e->changes->last_mod_mtime_valid = true; + } + else { + e->changes->last_mod_mtime_valid = false; + } + e->changes->changed |= ZIP_DIRENT_LAST_MOD; + + return 0; +} + +ZIP_EXTERN int zip_file_set_dostime(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16_t ddate, zip_flags_t flags) { + return zip_file_set_time(za, idx, dtime, ddate, flags, NULL); +} + + +ZIP_EXTERN int zip_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags) { + zip_dostime_t dostime; + + if (_zip_u2d_time(mtime, &dostime, &za->error) < 0) { + return -1; + } + + return zip_file_set_time(za, idx, dostime.time, dostime.date, flags, &mtime); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_file_strerror.c b/thirdparty/libzip-1.11.3/lib/zip_file_strerror.c new file mode 100644 index 0000000..5e896b4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_file_strerror.c @@ -0,0 +1,41 @@ +/* + zip_file_sterror.c -- get string representation of zip file error + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN const char * +zip_file_strerror(zip_file_t *zf) { + return zip_error_strerror(&zf->error); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_fopen.c b/thirdparty/libzip-1.11.3/lib/zip_fopen.c new file mode 100644 index 0000000..93217f3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_fopen.c @@ -0,0 +1,46 @@ +/* + zip_fopen.c -- open file in zip archive for reading + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN zip_file_t * +zip_fopen(zip_t *za, const char *fname, zip_flags_t flags) { + zip_int64_t idx; + + if ((idx = zip_name_locate(za, fname, flags)) < 0) + return NULL; + + return zip_fopen_index_encrypted(za, (zip_uint64_t)idx, flags, za->default_password); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_fopen_encrypted.c b/thirdparty/libzip-1.11.3/lib/zip_fopen_encrypted.c new file mode 100644 index 0000000..78143af --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_fopen_encrypted.c @@ -0,0 +1,46 @@ +/* + zip_fopen_encrypted.c -- open file for reading with password + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN zip_file_t * +zip_fopen_encrypted(zip_t *za, const char *fname, zip_flags_t flags, const char *password) { + zip_int64_t idx; + + if ((idx = zip_name_locate(za, fname, flags)) < 0) + return NULL; + + return zip_fopen_index_encrypted(za, (zip_uint64_t)idx, flags, password); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_fopen_index.c b/thirdparty/libzip-1.11.3/lib/zip_fopen_index.c new file mode 100644 index 0000000..b6676b7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_fopen_index.c @@ -0,0 +1,41 @@ +/* + zip_fopen_index.c -- open file in zip archive for reading by index + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN zip_file_t * +zip_fopen_index(zip_t *za, zip_uint64_t index, zip_flags_t flags) { + return zip_fopen_index_encrypted(za, index, flags, za->default_password); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_fopen_index_encrypted.c b/thirdparty/libzip-1.11.3/lib/zip_fopen_index_encrypted.c new file mode 100644 index 0000000..86d6977 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_fopen_index_encrypted.c @@ -0,0 +1,85 @@ +/* + zip_fopen_index_encrypted.c -- open file for reading by index w/ password + Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include + +#include "zipint.h" + +static zip_file_t *_zip_file_new(zip_t *za); + + +ZIP_EXTERN zip_file_t * +zip_fopen_index_encrypted(zip_t *za, zip_uint64_t index, zip_flags_t flags, const char *password) { + zip_file_t *zf; + zip_source_t *src; + + if (password != NULL && password[0] == '\0') { + password = NULL; + } + + if ((src = zip_source_zip_file_create(za, index, flags, 0, -1, password, &za->error)) == NULL) + return NULL; + + if (zip_source_open(src) < 0) { + zip_error_set_from_source(&za->error, src); + zip_source_free(src); + return NULL; + } + + if ((zf = _zip_file_new(za)) == NULL) { + zip_source_free(src); + return NULL; + } + + zf->src = src; + + return zf; +} + + +static zip_file_t * +_zip_file_new(zip_t *za) { + zip_file_t *zf; + + if ((zf = (zip_file_t *)malloc(sizeof(struct zip_file))) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return NULL; + } + + zip_error_init(&zf->error); + zf->src = NULL; + + return zf; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_fread.c b/thirdparty/libzip-1.11.3/lib/zip_fread.c new file mode 100644 index 0000000..17cec4f --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_fread.c @@ -0,0 +1,65 @@ +/* + zip_fread.c -- read from file + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN zip_int64_t +zip_fread(zip_file_t *zf, void *outbuf, zip_uint64_t toread) { + zip_int64_t n; + + if (zf == NULL) { + return -1; + } + + if (zf->error.zip_err != 0) { + return -1; + } + + if (toread > ZIP_INT64_MAX) { + zip_error_set(&zf->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (toread == 0) { + return 0; + } + + if ((n = zip_source_read(zf->src, outbuf, toread)) < 0) { + zip_error_set_from_source(&zf->error, zf->src); + return -1; + } + + return n; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_fseek.c b/thirdparty/libzip-1.11.3/lib/zip_fseek.c new file mode 100644 index 0000000..107a6f7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_fseek.c @@ -0,0 +1,63 @@ +/* + zip_fseek.c -- seek in file + Copyright (C) 2016-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + +ZIP_EXTERN zip_int8_t +zip_fseek(zip_file_t *zf, zip_int64_t offset, int whence) { + if (zf == NULL) { + return -1; + } + + if (zf->error.zip_err != 0) { + return -1; + } + + if (zip_source_seek(zf->src, offset, whence) < 0) { + zip_error_set_from_source(&zf->error, zf->src); + return -1; + } + + return 0; +} + + +ZIP_EXTERN int +zip_file_is_seekable(zip_file_t *zfile) { + if (zfile == NULL) { + return -1; + } + + return zip_source_is_seekable(zfile->src); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_ftell.c b/thirdparty/libzip-1.11.3/lib/zip_ftell.c new file mode 100644 index 0000000..6299b2d --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_ftell.c @@ -0,0 +1,56 @@ +/* + zip_ftell.c -- tell position in file + Copyright (C) 2016-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + +ZIP_EXTERN zip_int64_t +zip_ftell(zip_file_t *zf) { + zip_int64_t res; + + if (zf == NULL) { + return -1; + } + + if (zf->error.zip_err != 0) { + return -1; + } + + res = zip_source_tell(zf->src); + if (res < 0) { + zip_error_set_from_source(&zf->error, zf->src); + return -1; + } + + return res; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_get_archive_comment.c b/thirdparty/libzip-1.11.3/lib/zip_get_archive_comment.c new file mode 100644 index 0000000..b83e6bc --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_get_archive_comment.c @@ -0,0 +1,58 @@ +/* + zip_get_archive_comment.c -- get archive comment + Copyright (C) 2006-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +ZIP_EXTERN const char * +zip_get_archive_comment(zip_t *za, int *lenp, zip_flags_t flags) { + zip_string_t *comment; + zip_uint32_t len; + const zip_uint8_t *str; + + if ((flags & ZIP_FL_UNCHANGED) || (za->comment_changes == NULL)) + comment = za->comment_orig; + else + comment = za->comment_changes; + + if ((str = _zip_string_get(comment, &len, flags, &za->error)) == NULL) + return NULL; + + if (lenp) + *lenp = (int)len; + + return (const char *)str; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_get_archive_flag.c b/thirdparty/libzip-1.11.3/lib/zip_get_archive_flag.c new file mode 100644 index 0000000..80d5991 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_get_archive_flag.c @@ -0,0 +1,45 @@ +/* + zip_get_archive_flag.c -- get archive global flag + Copyright (C) 2008-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_get_archive_flag(zip_t *za, zip_flags_t flag, zip_flags_t flags) { + unsigned int fl; + + fl = (flags & ZIP_FL_UNCHANGED) ? za->flags : za->ch_flags; + + return (fl & flag) ? 1 : 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_get_encryption_implementation.c b/thirdparty/libzip-1.11.3/lib/zip_get_encryption_implementation.c new file mode 100644 index 0000000..28ad329 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_get_encryption_implementation.c @@ -0,0 +1,62 @@ +/* + zip_get_encryption_implementation.c -- get encryption implementation + Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +zip_encryption_implementation +_zip_get_encryption_implementation(zip_uint16_t em, int operation) { + switch (em) { + case ZIP_EM_TRAD_PKWARE: + return operation == ZIP_CODEC_DECODE ? zip_source_pkware_decode : zip_source_pkware_encode; + +#if defined(HAVE_CRYPTO) + case ZIP_EM_AES_128: + case ZIP_EM_AES_192: + case ZIP_EM_AES_256: + return operation == ZIP_CODEC_DECODE ? zip_source_winzip_aes_decode : zip_source_winzip_aes_encode; +#endif + + default: + return NULL; + } +} + +ZIP_EXTERN int +zip_encryption_method_supported(zip_uint16_t method, int encode) { + if (method == ZIP_EM_NONE) { + return 1; + } + return _zip_get_encryption_implementation(method, encode ? ZIP_CODEC_ENCODE : ZIP_CODEC_DECODE) != NULL; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_get_file_comment.c b/thirdparty/libzip-1.11.3/lib/zip_get_file_comment.c new file mode 100644 index 0000000..0284aec --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_get_file_comment.c @@ -0,0 +1,50 @@ +/* + zip_get_file_comment.c -- get file comment + Copyright (C) 2006-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#define _ZIP_COMPILING_DEPRECATED +#include "zipint.h" + + +ZIP_EXTERN const char * +zip_get_file_comment(zip_t *za, zip_uint64_t idx, int *lenp, int flags) { + zip_uint32_t len; + const char *s; + + if ((s = zip_file_get_comment(za, idx, &len, (zip_flags_t)flags)) != NULL) { + if (lenp) + *lenp = (int)len; + } + + return s; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_get_name.c b/thirdparty/libzip-1.11.3/lib/zip_get_name.c new file mode 100644 index 0000000..d1c9453 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_get_name.c @@ -0,0 +1,58 @@ +/* + zip_get_name.c -- get filename for a file in zip file + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +ZIP_EXTERN const char * +zip_get_name(zip_t *za, zip_uint64_t idx, zip_flags_t flags) { + return _zip_get_name(za, idx, flags, &za->error); +} + + +const char * +_zip_get_name(zip_t *za, zip_uint64_t idx, zip_flags_t flags, zip_error_t *error) { + zip_dirent_t *de; + const zip_uint8_t *str; + + if ((de = _zip_get_dirent(za, idx, flags, error)) == NULL) + return NULL; + + if ((str = _zip_string_get(de->filename, NULL, flags, error)) == NULL) + return NULL; + + return (const char *)str; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_get_num_entries.c b/thirdparty/libzip-1.11.3/lib/zip_get_num_entries.c new file mode 100644 index 0000000..b2595de --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_get_num_entries.c @@ -0,0 +1,52 @@ +/* + zip_get_num_entries.c -- get number of entries in archive + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN zip_int64_t +zip_get_num_entries(zip_t *za, zip_flags_t flags) { + zip_uint64_t n; + + if (za == NULL) + return -1; + + if (flags & ZIP_FL_UNCHANGED) { + n = za->nentry; + while (n > 0 && za->entry[n - 1].orig == NULL) + --n; + return (zip_int64_t)n; + } + return (zip_int64_t)za->nentry; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_get_num_files.c b/thirdparty/libzip-1.11.3/lib/zip_get_num_files.c new file mode 100644 index 0000000..16d7754 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_get_num_files.c @@ -0,0 +1,51 @@ +/* + zip_get_num_files.c -- get number of files in archive + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#define _ZIP_COMPILING_DEPRECATED +#include "zipint.h" +#include + + +ZIP_EXTERN int +zip_get_num_files(zip_t *za) { + if (za == NULL) + return -1; + + if (za->nentry > INT_MAX) { + zip_error_set(&za->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + } + + return (int)za->nentry; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_hash.c b/thirdparty/libzip-1.11.3/lib/zip_hash.c new file mode 100644 index 0000000..8479bec --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_hash.c @@ -0,0 +1,410 @@ +/* + zip_hash.c -- hash table string -> uint64 + Copyright (C) 2015-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" +#include +#include + +/* parameter for the string hash function */ +#define HASH_MULTIPLIER 33 +#define HASH_START 5381 + +/* hash table's fill ratio is kept between these by doubling/halfing its size as necessary */ +#define HASH_MAX_FILL .75 +#define HASH_MIN_FILL .01 + +/* but hash table size is kept between these */ +#define HASH_MIN_SIZE 256 +#define HASH_MAX_SIZE 0x80000000ul + +struct zip_hash_entry { + const zip_uint8_t *name; + zip_int64_t orig_index; + zip_int64_t current_index; + struct zip_hash_entry *next; + zip_uint32_t hash_value; +}; +typedef struct zip_hash_entry zip_hash_entry_t; + +struct zip_hash { + zip_uint32_t table_size; + zip_uint64_t nentries; + zip_hash_entry_t **table; +}; + + +/* free list of entries */ +static void +free_list(zip_hash_entry_t *entry) { + while (entry != NULL) { + zip_hash_entry_t *next = entry->next; + free(entry); + entry = next; + } +} + + +/* compute hash of string, full 32 bit value */ +static zip_uint32_t +hash_string(const zip_uint8_t *name) { + zip_uint64_t value = HASH_START; + + if (name == NULL) { + return 0; + } + + while (*name != 0) { + value = (zip_uint64_t)(((value * HASH_MULTIPLIER) + (zip_uint8_t)*name) % 0x100000000ul); + name++; + } + + return (zip_uint32_t)value; +} + + +/* resize hash table; new_size must be a power of 2, can be larger or smaller than current size */ +static bool +hash_resize(zip_hash_t *hash, zip_uint32_t new_size, zip_error_t *error) { + zip_hash_entry_t **new_table; + + if (new_size == hash->table_size) { + return true; + } + + if ((new_table = (zip_hash_entry_t **)calloc(new_size, sizeof(zip_hash_entry_t *))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return false; + } + + if (hash->nentries > 0) { + zip_uint32_t i; + + for (i = 0; i < hash->table_size; i++) { + zip_hash_entry_t *entry = hash->table[i]; + while (entry) { + zip_hash_entry_t *next = entry->next; + + zip_uint32_t new_index = entry->hash_value % new_size; + + entry->next = new_table[new_index]; + new_table[new_index] = entry; + + entry = next; + } + } + } + + free(hash->table); + hash->table = new_table; + hash->table_size = new_size; + + return true; +} + + +static zip_uint32_t +size_for_capacity(zip_uint64_t capacity) { + double needed_size = capacity / HASH_MAX_FILL; + zip_uint32_t v; + + if (needed_size > ZIP_UINT32_MAX) { + v = ZIP_UINT32_MAX; + } + else { + v = (zip_uint32_t)needed_size; + } + + if (v > HASH_MAX_SIZE) { + return HASH_MAX_SIZE; + } + + /* From Bit Twiddling Hacks by Sean Eron Anderson + (http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2). */ + + v--; + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + v++; + + return v; +} + + +zip_hash_t * +_zip_hash_new(zip_error_t *error) { + zip_hash_t *hash; + + if ((hash = (zip_hash_t *)malloc(sizeof(zip_hash_t))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + hash->table_size = 0; + hash->nentries = 0; + hash->table = NULL; + + return hash; +} + + +void +_zip_hash_free(zip_hash_t *hash) { + zip_uint32_t i; + + if (hash == NULL) { + return; + } + + if (hash->table != NULL) { + for (i = 0; i < hash->table_size; i++) { + if (hash->table[i] != NULL) { + free_list(hash->table[i]); + } + } + free(hash->table); + } + free(hash); +} + + +/* insert into hash, return error on existence or memory issues */ +bool +_zip_hash_add(zip_hash_t *hash, const zip_uint8_t *name, zip_uint64_t index, zip_flags_t flags, zip_error_t *error) { + zip_uint32_t hash_value, table_index; + zip_hash_entry_t *entry; + + if (hash == NULL || name == NULL || index > ZIP_INT64_MAX) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return false; + } + + if (hash->table_size == 0) { + if (!hash_resize(hash, HASH_MIN_SIZE, error)) { + return false; + } + } + + hash_value = hash_string(name); + table_index = hash_value % hash->table_size; + + for (entry = hash->table[table_index]; entry != NULL; entry = entry->next) { + if (entry->hash_value == hash_value && strcmp((const char *)name, (const char *)entry->name) == 0) { + if (((flags & ZIP_FL_UNCHANGED) && entry->orig_index != -1) || entry->current_index != -1) { + zip_error_set(error, ZIP_ER_EXISTS, 0); + return false; + } + else { + break; + } + } + } + + if (entry == NULL) { + if ((entry = (zip_hash_entry_t *)malloc(sizeof(zip_hash_entry_t))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return false; + } + entry->name = name; + entry->next = hash->table[table_index]; + hash->table[table_index] = entry; + entry->hash_value = hash_value; + entry->orig_index = -1; + hash->nentries++; + if (hash->nentries > hash->table_size * HASH_MAX_FILL && hash->table_size < HASH_MAX_SIZE) { + if (!hash_resize(hash, hash->table_size * 2, error)) { + return false; + } + } + } + + if (flags & ZIP_FL_UNCHANGED) { + entry->orig_index = (zip_int64_t)index; + } + entry->current_index = (zip_int64_t)index; + + return true; +} + + +/* remove entry from hash, error if not found */ +bool +_zip_hash_delete(zip_hash_t *hash, const zip_uint8_t *name, zip_error_t *error) { + zip_uint32_t hash_value, index; + zip_hash_entry_t *entry, *previous; + + if (hash == NULL || name == NULL) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return false; + } + + if (hash->nentries > 0) { + hash_value = hash_string(name); + index = hash_value % hash->table_size; + previous = NULL; + entry = hash->table[index]; + while (entry) { + if (entry->hash_value == hash_value && strcmp((const char *)name, (const char *)entry->name) == 0) { + if (entry->orig_index == -1) { + if (previous) { + previous->next = entry->next; + } + else { + hash->table[index] = entry->next; + } + free(entry); + hash->nentries--; + if (hash->nentries < hash->table_size * HASH_MIN_FILL && hash->table_size > HASH_MIN_SIZE) { + if (!hash_resize(hash, hash->table_size / 2, error)) { + return false; + } + } + } + else { + entry->current_index = -1; + } + return true; + } + previous = entry; + entry = entry->next; + } + } + + zip_error_set(error, ZIP_ER_NOENT, 0); + return false; +} + + +/* find value for entry in hash, -1 if not found */ +zip_int64_t +_zip_hash_lookup(zip_hash_t *hash, const zip_uint8_t *name, zip_flags_t flags, zip_error_t *error) { + zip_uint32_t hash_value, index; + zip_hash_entry_t *entry; + + if (hash == NULL || name == NULL) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return -1; + } + + if (hash->nentries > 0) { + hash_value = hash_string(name); + index = hash_value % hash->table_size; + for (entry = hash->table[index]; entry != NULL; entry = entry->next) { + if (strcmp((const char *)name, (const char *)entry->name) == 0) { + if (flags & ZIP_FL_UNCHANGED) { + if (entry->orig_index != -1) { + return entry->orig_index; + } + } + else { + if (entry->current_index != -1) { + return entry->current_index; + } + } + break; + } + } + } + + zip_error_set(error, ZIP_ER_NOENT, 0); + return -1; +} + + +bool +_zip_hash_reserve_capacity(zip_hash_t *hash, zip_uint64_t capacity, zip_error_t *error) { + zip_uint32_t new_size; + + if (capacity == 0) { + return true; + } + + new_size = size_for_capacity(capacity); + + if (new_size <= hash->table_size) { + return true; + } + + if (!hash_resize(hash, new_size, error)) { + return false; + } + + return true; +} + + +bool +_zip_hash_revert(zip_hash_t *hash, zip_error_t *error) { + zip_uint32_t i; + zip_hash_entry_t *entry, *previous; + + for (i = 0; i < hash->table_size; i++) { + previous = NULL; + entry = hash->table[i]; + while (entry) { + if (entry->orig_index == -1) { + zip_hash_entry_t *p; + if (previous) { + previous->next = entry->next; + } + else { + hash->table[i] = entry->next; + } + p = entry; + entry = entry->next; + /* previous does not change */ + free(p); + hash->nentries--; + } + else { + entry->current_index = entry->orig_index; + previous = entry; + entry = entry->next; + } + } + } + + if (hash->nentries < hash->table_size * HASH_MIN_FILL && hash->table_size > HASH_MIN_SIZE) { + zip_uint32_t new_size = hash->table_size / 2; + while (hash->nentries < new_size * HASH_MIN_FILL && new_size > HASH_MIN_SIZE) { + new_size /= 2; + } + if (!hash_resize(hash, new_size, error)) { + return false; + } + } + + return true; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_io_util.c b/thirdparty/libzip-1.11.3/lib/zip_io_util.c new file mode 100644 index 0000000..e346246 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_io_util.c @@ -0,0 +1,146 @@ +/* + zip_io_util.c -- I/O helper functions + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include + +#include "zipint.h" + +int +_zip_read(zip_source_t *src, zip_uint8_t *b, zip_uint64_t length, zip_error_t *error) { + zip_int64_t n; + + if (length > ZIP_INT64_MAX) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + return -1; + } + + if ((n = zip_source_read(src, b, length)) < 0) { + zip_error_set_from_source(error, src); + return -1; + } + + if (n < (zip_int64_t)length) { + zip_error_set(error, ZIP_ER_EOF, 0); + return -1; + } + + return 0; +} + + +zip_uint8_t * +_zip_read_data(zip_buffer_t *buffer, zip_source_t *src, size_t length, bool nulp, zip_error_t *error) { + zip_uint8_t *r; + + if (length == 0 && !nulp) { + return NULL; + } + + r = (zip_uint8_t *)malloc(length + (nulp ? 1 : 0)); + if (r == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if (buffer) { + zip_uint8_t *data = _zip_buffer_get(buffer, length); + + if (data == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + free(r); + return NULL; + } + (void)memcpy_s(r, length, data, length); + } + else { + if (_zip_read(src, r, length, error) < 0) { + free(r); + return NULL; + } + } + + if (nulp) { + zip_uint8_t *o; + /* replace any in-string NUL characters with spaces */ + r[length] = 0; + for (o = r; o < r + length; o++) + if (*o == '\0') + *o = ' '; + } + + return r; +} + + +zip_string_t * +_zip_read_string(zip_buffer_t *buffer, zip_source_t *src, zip_uint16_t len, bool nulp, zip_error_t *error) { + zip_uint8_t *raw; + zip_string_t *s; + + if ((raw = _zip_read_data(buffer, src, len, nulp, error)) == NULL) + return NULL; + + s = _zip_string_new(raw, len, ZIP_FL_ENC_GUESS, error); + free(raw); + return s; +} + + +int +_zip_write(zip_t *za, const void *data, zip_uint64_t length) { + zip_int64_t n; + + if ((n = zip_source_write(za->src, data, length)) < 0) { + zip_error_set_from_source(&za->error, za->src); + return -1; + } + if ((zip_uint64_t)n != length) { + zip_error_set(&za->error, ZIP_ER_WRITE, EINTR); + return -1; + } + + if (za->write_crc != NULL) { + zip_uint64_t position = 0; + while (position < length) { + zip_uint64_t nn = ZIP_MIN(UINT_MAX, length - position); + + *za->write_crc = (zip_uint32_t)crc32(*za->write_crc, (const Bytef *)data + position, (uInt)nn); + position += nn; + } + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_libzip_version.c b/thirdparty/libzip-1.11.3/lib/zip_libzip_version.c new file mode 100644 index 0000000..139b250 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_libzip_version.c @@ -0,0 +1,41 @@ +/* + zip_libzip_version.c -- return run-time version of library + Copyright (C) 2017-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN const char * +zip_libzip_version(void) { + return LIBZIP_VERSION; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_memdup.c b/thirdparty/libzip-1.11.3/lib/zip_memdup.c new file mode 100644 index 0000000..6ac9a5a --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_memdup.c @@ -0,0 +1,56 @@ +/* + zip_memdup.c -- internal zip function, "strdup" with len + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include + +#include "zipint.h" + + +void * +_zip_memdup(const void *mem, size_t len, zip_error_t *error) { + void *ret; + + if (len == 0) + return NULL; + + ret = malloc(len); + if (ret == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + (void)memcpy_s(ret, len, mem, len); + + return ret; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_name_locate.c b/thirdparty/libzip-1.11.3/lib/zip_name_locate.c new file mode 100644 index 0000000..4248dc2 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_name_locate.c @@ -0,0 +1,116 @@ +/* + zip_name_locate.c -- get index by name + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#ifdef HAVE_STRINGS_H +#include +#endif + +#include "zipint.h" + + +ZIP_EXTERN zip_int64_t +zip_name_locate(zip_t *za, const char *fname, zip_flags_t flags) { + return _zip_name_locate(za, fname, flags, &za->error); +} + + +zip_int64_t +_zip_name_locate(zip_t *za, const char *fname, zip_flags_t flags, zip_error_t *error) { + int (*cmp)(const char *, const char *); + size_t fname_length; + zip_string_t *str = NULL; + const char *fn, *p; + zip_uint64_t i; + + if (za == NULL) { + return -1; + } + + if (fname == NULL) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return -1; + } + + fname_length = strlen(fname); + + if (fname_length > ZIP_UINT16_MAX) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return -1; + } + + if ((flags & (ZIP_FL_ENC_UTF_8 | ZIP_FL_ENC_RAW)) == 0 && fname[0] != '\0') { + if ((str = _zip_string_new((const zip_uint8_t *)fname, (zip_uint16_t)strlen(fname), flags, error)) == NULL) { + return -1; + } + if ((fname = (const char *)_zip_string_get(str, NULL, 0, error)) == NULL) { + _zip_string_free(str); + return -1; + } + } + + if (flags & (ZIP_FL_NOCASE | ZIP_FL_NODIR | ZIP_FL_ENC_RAW | ZIP_FL_ENC_STRICT)) { + /* can't use hash table */ + cmp = (flags & ZIP_FL_NOCASE) ? strcasecmp : strcmp; + + for (i = 0; i < za->nentry; i++) { + fn = _zip_get_name(za, i, flags, error); + + /* newly added (partially filled) entry or error */ + if (fn == NULL) + continue; + + if (flags & ZIP_FL_NODIR) { + p = strrchr(fn, '/'); + if (p) + fn = p + 1; + } + + if (cmp(fname, fn) == 0) { + _zip_error_clear(error); + _zip_string_free(str); + return (zip_int64_t)i; + } + } + + zip_error_set(error, ZIP_ER_NOENT, 0); + _zip_string_free(str); + return -1; + } + else { + zip_int64_t ret = _zip_hash_lookup(za->names, (const zip_uint8_t *)fname, flags, error); + _zip_string_free(str); + return ret; + } +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_new.c b/thirdparty/libzip-1.11.3/lib/zip_new.c new file mode 100644 index 0000000..68e1588 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_new.c @@ -0,0 +1,74 @@ +/* + zip_new.c -- create and init struct zip + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +/* _zip_new: + creates a new zipfile struct, and sets the contents to zero; returns + the new struct. */ + +zip_t * +_zip_new(zip_error_t *error) { + zip_t *za; + + za = (zip_t *)malloc(sizeof(struct zip)); + if (za == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if ((za->names = _zip_hash_new(error)) == NULL) { + free(za); + return NULL; + } + + za->src = NULL; + za->open_flags = 0; + zip_error_init(&za->error); + za->flags = za->ch_flags = 0; + za->default_password = NULL; + za->comment_orig = za->comment_changes = NULL; + za->comment_changed = 0; + za->nentry = za->nentry_alloc = 0; + za->entry = NULL; + za->nopen_source = za->nopen_source_alloc = 0; + za->open_source = NULL; + za->progress = NULL; + za->torrent_mtime = 0; + + return za; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_open.c b/thirdparty/libzip-1.11.3/lib/zip_open.c new file mode 100644 index 0000000..aee0da0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_open.c @@ -0,0 +1,1022 @@ +/* + zip_open.c -- open zip archive by name + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include +#include + +#include "zipint.h" + +typedef enum { + EXISTS_ERROR = -1, + EXISTS_NOT = 0, + EXISTS_OK +} exists_t; +typedef enum { + CDIR_OK, + CDIR_INVALID, + CDIR_NOT_FOUND + +} cdir_status_t; + +static bool check_eocd(zip_cdir_t *cd, unsigned int flags, zip_error_t *error); +static bool check_magic(zip_uint64_t offset, zip_buffer_t *buffer, zip_uint64_t buffer_offset, zip_source_t *src, const char* magic); +static zip_t *_zip_allocate_new(zip_source_t *src, unsigned int flags, zip_error_t *error); +static zip_int64_t _zip_checkcons(zip_t *za, zip_cdir_t *cdir, zip_error_t *error); +static void zip_check_torrentzip(zip_t *za, const zip_cdir_t *cdir); +static zip_cdir_t *_zip_find_central_dir(zip_t *za, zip_uint64_t len); +static exists_t _zip_file_exists(zip_source_t *src, zip_error_t *error); +static int _zip_headercomp(const zip_dirent_t *, const zip_dirent_t *); +static bool _zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_cdir_t **cdirp, zip_error_t *error); +static zip_cdir_t *_zip_read_eocd(zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_error_t *error); +static cdir_status_t _zip_read_eocd64(zip_cdir_t *cdir, zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error); +static const unsigned char *find_eocd(zip_buffer_t *buffer, const unsigned char *last); + + +ZIP_EXTERN zip_t * +zip_open(const char *fn, int _flags, int *zep) { + zip_t *za; + zip_source_t *src; + struct zip_error error; + + zip_error_init(&error); + if ((src = zip_source_file_create(fn, 0, -1, &error)) == NULL) { + _zip_set_open_error(zep, &error, 0); + zip_error_fini(&error); + return NULL; + } + + if ((za = zip_open_from_source(src, _flags, &error)) == NULL) { + zip_source_free(src); + _zip_set_open_error(zep, &error, 0); + zip_error_fini(&error); + return NULL; + } + + zip_error_fini(&error); + return za; +} + + +ZIP_EXTERN zip_t * +zip_open_from_source(zip_source_t *src, int _flags, zip_error_t *error) { + unsigned int flags; + zip_int64_t supported; + exists_t exists; + + if (_flags < 0 || src == NULL) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + flags = (unsigned int)_flags; + + supported = zip_source_supports(src); + if ((supported & ZIP_SOURCE_SUPPORTS_SEEKABLE) != ZIP_SOURCE_SUPPORTS_SEEKABLE) { + zip_error_set(error, ZIP_ER_OPNOTSUPP, 0); + return NULL; + } + if ((supported & ZIP_SOURCE_SUPPORTS_WRITABLE) != ZIP_SOURCE_SUPPORTS_WRITABLE) { + flags |= ZIP_RDONLY; + } + + if ((flags & (ZIP_RDONLY | ZIP_TRUNCATE)) == (ZIP_RDONLY | ZIP_TRUNCATE)) { + zip_error_set(error, ZIP_ER_RDONLY, 0); + return NULL; + } + + exists = _zip_file_exists(src, error); + switch (exists) { + case EXISTS_ERROR: + return NULL; + + case EXISTS_NOT: + if ((flags & ZIP_CREATE) == 0) { + zip_error_set(error, ZIP_ER_NOENT, 0); + return NULL; + } + return _zip_allocate_new(src, flags, error); + + default: { + zip_t *za; + if (flags & ZIP_EXCL) { + zip_error_set(error, ZIP_ER_EXISTS, 0); + return NULL; + } + if (zip_source_open(src) < 0) { + zip_error_set_from_source(error, src); + return NULL; + } + + if (flags & ZIP_TRUNCATE) { + za = _zip_allocate_new(src, flags, error); + } + else { + /* ZIP_CREATE gets ignored if file exists and not ZIP_EXCL, just like open() */ + za = _zip_open(src, flags, error); + } + + if (za == NULL) { + zip_source_close(src); + return NULL; + } + return za; + } + } +} + + +static bool +_is_truncated_zip(zip_source_t *src) { + unsigned char data[4]; + /* check if the source is a truncated zip archive: true if yes, no + if not or can't be determined */ + if (zip_source_seek(src, 0, SEEK_SET) < 0) { + return false; + } + + if (zip_source_read(src, data, 4) != 4) { + return false; + } + + if (memcmp(data, LOCAL_MAGIC, 4) == 0) { + /* file starts with a ZIP local header signature */ + return true; + } + return false; +} + + +zip_t * +_zip_open(zip_source_t *src, unsigned int flags, zip_error_t *error) { + zip_t *za; + zip_cdir_t *cdir; + struct zip_stat st; + zip_uint64_t len, idx; + + zip_stat_init(&st); + if (zip_source_stat(src, &st) < 0) { + zip_error_set_from_source(error, src); + return NULL; + } + if ((st.valid & ZIP_STAT_SIZE) == 0) { + zip_error_set(error, ZIP_ER_SEEK, EOPNOTSUPP); + return NULL; + } + len = st.size; + + + if ((za = _zip_allocate_new(src, flags, error)) == NULL) { + return NULL; + } + + /* treat empty files as empty archives */ + if (len == 0 && zip_source_accept_empty(src)) { + return za; + } + + if ((cdir = _zip_find_central_dir(za, len)) == NULL) { + _zip_error_copy(error, &za->error); + if (zip_error_code_zip(&za->error) == ZIP_ER_NOZIP) { + /* not a zip - find out if it's truncated */ + if (_is_truncated_zip(src)) { + zip_error_set(error, ZIP_ER_TRUNCATED_ZIP, 0); + } + } + /* keep src so discard does not get rid of it */ + zip_source_keep(src); + zip_discard(za); + return NULL; + } + + za->entry = cdir->entry; + za->nentry = cdir->nentry; + za->nentry_alloc = cdir->nentry_alloc; + + zip_check_torrentzip(za, cdir); + + if (ZIP_IS_TORRENTZIP(za)) { + /* Torrentzip uses the archive comment to detect changes by tools that are not torrentzip aware. */ + _zip_string_free(cdir->comment); + } + else { + za->comment_orig = cdir->comment; + } + + free(cdir); + + _zip_hash_reserve_capacity(za->names, za->nentry, &za->error); + + for (idx = 0; idx < za->nentry; idx++) { + const zip_uint8_t *name = _zip_string_get(za->entry[idx].orig->filename, NULL, 0, error); + if (name == NULL) { + /* keep src so discard does not get rid of it */ + zip_source_keep(src); + zip_discard(za); + return NULL; + } + + if (_zip_hash_add(za->names, name, idx, ZIP_FL_UNCHANGED, &za->error) == false) { + if (za->error.zip_err != ZIP_ER_EXISTS || (flags & ZIP_CHECKCONS)) { + _zip_error_copy(error, &za->error); + /* keep src so discard does not get rid of it */ + zip_source_keep(src); + zip_discard(za); + return NULL; + } + } + } + + za->ch_flags = za->flags; + + return za; +} + + +void +_zip_set_open_error(int *zep, const zip_error_t *err, int ze) { + if (err) { + ze = zip_error_code_zip(err); + switch (zip_error_system_type(err)) { + case ZIP_ET_SYS: + case ZIP_ET_LIBZIP: + errno = zip_error_code_system(err); + break; + + default: + break; + } + } + + if (zep) + *zep = ze; +} + + +/* _zip_readcdir: + tries to find a valid end-of-central-directory at the beginning of + buf, and then the corresponding central directory entries. + Returns a struct zip_cdir which contains the central directory + entries, or NULL if unsuccessful. */ + +static bool _zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_cdir_t **cdirp, zip_error_t *error) { + zip_cdir_t *cd; + zip_uint16_t comment_len; + zip_uint64_t i, left; + zip_uint64_t eocd_offset = _zip_buffer_offset(buffer); + zip_buffer_t *cd_buffer; + bool eocd64_found = false; + + *cdirp = NULL; + + if ((cd = _zip_read_eocd(buffer, buf_offset, error)) == NULL) { + return false; + } + + if (eocd_offset >= EOCD64LOCLEN && memcmp(_zip_buffer_data(buffer) + eocd_offset - EOCD64LOCLEN, EOCD64LOC_MAGIC, 4) == 0) { + eocd64_found = true; + _zip_buffer_set_offset(buffer, eocd_offset - EOCD64LOCLEN); + switch (_zip_read_eocd64(cd, za->src, buffer, buf_offset, za->flags, error)) { + case CDIR_OK: + break; + + case CDIR_INVALID: + _zip_cdir_free(cd); + return true; + + case CDIR_NOT_FOUND: + _zip_cdir_free(cd); + return false; + } + } + + if ((cd->eocd_disk != 0 || cd->this_disk != 0) && !eocd64_found && cd->eocd_disk != cd->this_disk) { + /* If the central directory doesn't start on this disk, we can't check that offset is valid. Check as much as we can instead. */ + if (cd->this_disk < cd->eocd_disk) { + /* Disks before the start of the central directory don't contain an EOCD. */ + _zip_cdir_free(cd); + return false; + } + if (cd->size <= cd->eocd_offset) { + /* The complete central directory would fit on this disk. */ + _zip_cdir_free(cd); + return false; + } + } + + if (!eocd64_found) { + if (cd->this_disk == 0 && cd->eocd_disk == 0 && cd->eocd_offset == 0 && cd->offset == 0 && cd->num_entries == 0) { + /* An empty archive doesn't contain central directory entries. */ + } + else if (!check_magic(cd->offset, buffer, buf_offset, za->src, CENTRAL_MAGIC)) { + _zip_cdir_free(cd); + return false; + } + } + + /* We accept this EOCD as valid and won't search for an earlier one if it is unusable. */ + + if (!check_eocd(cd, za->flags, error)) { + _zip_cdir_free(cd); + return true; + } + + _zip_buffer_set_offset(buffer, eocd_offset + 20); + comment_len = _zip_buffer_get_16(buffer); + + if (cd->offset + cd->size > buf_offset + eocd_offset) { + /* cdir spans past EOCD record */ + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_OVERLAPS_EOCD); + _zip_cdir_free(cd); + return true; + } + + if (comment_len || (za->open_flags & ZIP_CHECKCONS)) { + zip_uint64_t tail_len; + + _zip_buffer_set_offset(buffer, eocd_offset + EOCDLEN); + tail_len = _zip_buffer_left(buffer); + + if (tail_len != comment_len) { + if (za->open_flags & ZIP_CHECKCONS) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_COMMENT_LENGTH_INVALID); + _zip_cdir_free(cd); + return true; + } + if (tail_len < comment_len) { + comment_len = tail_len; + } + } + + if (comment_len) { + if ((cd->comment = _zip_string_new(_zip_buffer_get(buffer, comment_len), comment_len, ZIP_FL_ENC_GUESS, error)) == NULL) { + _zip_cdir_free(cd); + return true; + } + } + } + + if (cd->offset >= buf_offset) { + zip_uint8_t *data; + /* if buffer already read in, use it */ + _zip_buffer_set_offset(buffer, cd->offset - buf_offset); + + if ((data = _zip_buffer_get(buffer, cd->size)) == NULL) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_LENGTH_INVALID); + _zip_cdir_free(cd); + return true; + } + if ((cd_buffer = _zip_buffer_new(data, cd->size)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + _zip_cdir_free(cd); + return true; + } + } + else { + cd_buffer = NULL; + + if (zip_source_seek(za->src, (zip_int64_t)cd->offset, SEEK_SET) < 0) { + zip_error_set_from_source(error, za->src); + _zip_cdir_free(cd); + return true; + } + + /* possible consistency check: cd->offset = len-(cd->size+cd->comment_len+EOCDLEN) ? */ + if (zip_source_tell(za->src) != (zip_int64_t)cd->offset) { + zip_error_set(error, ZIP_ER_NOZIP, 0); + _zip_cdir_free(cd); + return true; + } + } + + if (!_zip_cdir_grow(cd, cd->num_entries, error)) { + _zip_cdir_free(cd); + _zip_buffer_free(cd_buffer); + return true; + } + left = (zip_uint64_t)cd->size; + i = 0; + while (left > 0) { + bool grown = false; + zip_int64_t entry_size; + + if (i == cd->nentry) { + /* InfoZIP has a hack to avoid using Zip64: it stores nentries % 0x10000 */ + /* This hack isn't applicable if we're using Zip64, or if there is no central directory entry following. */ + + if (cd->is_zip64 || left < CDENTRYSIZE) { + break; + } + + if (!_zip_cdir_grow(cd, 0x10000, error)) { + _zip_cdir_free(cd); + _zip_buffer_free(cd_buffer); + return true; + } + grown = true; + } + + if ((cd->entry[i].orig = _zip_dirent_new()) == NULL || (entry_size = _zip_dirent_read(cd->entry[i].orig, za->src, cd_buffer, false, 0, za->open_flags & ZIP_CHECKCONS, error)) < 0) { + if (zip_error_code_zip(error) == ZIP_ER_INCONS) { + zip_error_set(error, ZIP_ER_INCONS, ADD_INDEX_TO_DETAIL(zip_error_code_system(error), i)); + } + else if (grown && zip_error_code_zip(error) == ZIP_ER_NOZIP) { + zip_error_set(error, ZIP_ER_INCONS, MAKE_DETAIL_WITH_INDEX(ZIP_ER_DETAIL_CDIR_ENTRY_INVALID, i)); + } + _zip_cdir_free(cd); + _zip_buffer_free(cd_buffer); + return true; + } + i++; + left -= (zip_uint64_t)entry_size; + } + + /* If we didn't fill all we grew, cd->num_entries was wrong. */ + if (i != cd->nentry || left > 0) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_WRONG_ENTRIES_COUNT); + _zip_buffer_free(cd_buffer); + _zip_cdir_free(cd); + return true; + } + + if (za->open_flags & ZIP_CHECKCONS) { + bool ok; + + if (cd_buffer) { + ok = _zip_buffer_eof(cd_buffer); + } + else { + zip_int64_t offset = zip_source_tell(za->src); + + if (offset < 0) { + zip_error_set_from_source(error, za->src); + _zip_cdir_free(cd); + return true; + } + ok = ((zip_uint64_t)offset == cd->offset + cd->size); + } + + if (!ok) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_LENGTH_INVALID); + _zip_buffer_free(cd_buffer); + _zip_cdir_free(cd); + return true; + } + } + + _zip_buffer_free(cd_buffer); + *cdirp = cd; + return true; +} + + +static bool check_magic(zip_uint64_t offset, zip_buffer_t *buffer, zip_uint64_t buffer_offset, zip_source_t *src, const char* magic) { + if (buffer_offset <= offset) { + zip_uint8_t* data; + if (_zip_buffer_set_offset(buffer, offset - buffer_offset) < 0 || (data = _zip_buffer_get(buffer, MAGIC_LEN)) == NULL) { + return false; + } + return memcmp(data, magic, MAGIC_LEN) == 0; + } + else { + zip_uint8_t data[MAGIC_LEN]; + + if (zip_source_seek(src, offset, SEEK_SET) < 0 || zip_source_read(src, data, MAGIC_LEN) != MAGIC_LEN) { + return false; + } + return memcmp(data, magic, MAGIC_LEN) == 0; + } +} + + +/* _zip_checkcons: + Checks the consistency of the central directory by comparing central + directory entries with local headers and checking for plausible + file and header offsets. Returns -1 if not plausible, else the + difference between the lowest and the highest fileposition reached */ + +static zip_int64_t +_zip_checkcons(zip_t *za, zip_cdir_t *cd, zip_error_t *error) { + zip_uint64_t i; + zip_uint64_t min, max, j; + struct zip_dirent temp; + int detail; + + _zip_dirent_init(&temp); + if (cd->nentry) { + max = cd->entry[0].orig->offset; + min = cd->entry[0].orig->offset; + } + else + min = max = 0; + + for (i = 0; i < cd->nentry; i++) { + if (cd->entry[i].orig->offset < min) + min = cd->entry[i].orig->offset; + if (min > (zip_uint64_t)cd->offset) { + zip_error_set(error, ZIP_ER_NOZIP, 0); + return -1; + } + + j = cd->entry[i].orig->offset + cd->entry[i].orig->comp_size + _zip_string_length(cd->entry[i].orig->filename) + LENTRYSIZE; + if (j > max) + max = j; + if (max > (zip_uint64_t)cd->offset) { + zip_error_set(error, ZIP_ER_NOZIP, 0); + return -1; + } + + if (zip_source_seek(za->src, (zip_int64_t)cd->entry[i].orig->offset, SEEK_SET) < 0) { + zip_error_set_from_source(error, za->src); + return -1; + } + + if (_zip_dirent_read(&temp, za->src, NULL, true, cd->entry[i].orig->comp_size, true, error) == -1) { + if (zip_error_code_zip(error) == ZIP_ER_INCONS) { + zip_error_set(error, ZIP_ER_INCONS, ADD_INDEX_TO_DETAIL(zip_error_code_system(error), i)); + } + _zip_dirent_finalize(&temp); + return -1; + } + + if (_zip_headercomp(cd->entry[i].orig, &temp) != 0) { + zip_error_set(error, ZIP_ER_INCONS, MAKE_DETAIL_WITH_INDEX(ZIP_ER_DETAIL_ENTRY_HEADER_MISMATCH, i)); + _zip_dirent_finalize(&temp); + return -1; + } + + cd->entry[i].orig->extra_fields = _zip_ef_merge(cd->entry[i].orig->extra_fields, temp.extra_fields); + cd->entry[i].orig->local_extra_fields_read = 1; + temp.extra_fields = NULL; + + _zip_dirent_finalize(&temp); + + if ((detail = zip_dirent_check_consistency(cd->entry[i].orig)) != 0) { + zip_error_set(error, ZIP_ER_INCONS, MAKE_DETAIL_WITH_INDEX(detail, i)); + return -1; + } + } + + return (max - min) < ZIP_INT64_MAX ? (zip_int64_t)(max - min) : ZIP_INT64_MAX; +} + + +/* _zip_headercomp: + compares a central directory entry and a local file header + Return 0 if they are consistent, -1 if not. */ + +static int +_zip_headercomp(const zip_dirent_t *central, const zip_dirent_t *local) { + if ((central->version_needed < local->version_needed) +#if 0 + /* some zip-files have different values in local + and global headers for the bitflags */ + || (central->bitflags != local->bitflags) +#endif + || (central->comp_method != local->comp_method) || (central->last_mod.time != local->last_mod.time) || (central->last_mod.date != local->last_mod.date) || !_zip_string_equal(central->filename, local->filename)) + return -1; + + if ((central->crc != local->crc) || (central->comp_size != local->comp_size) || (central->uncomp_size != local->uncomp_size)) { + /* InfoZip stores valid values in local header even when data descriptor is used. + This is in violation of the appnote. + macOS Archive sets the compressed size even when data descriptor is used ( but not the others), + also in violation of the appnote. + */ + /* if data descriptor is not used, the values must match */ + if ((local->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) == 0) { + return -1; + } + /* when using a data descriptor, the local header value must be zero or match */ + if ((local->crc != 0 && central->crc != local->crc) || (local->comp_size != 0 && central->comp_size != local->comp_size) || (local->uncomp_size != 0 && central->uncomp_size != local->uncomp_size)) { + return -1; + } + } + + return 0; +} + + +static zip_t * +_zip_allocate_new(zip_source_t *src, unsigned int flags, zip_error_t *error) { + zip_t *za; + + if ((za = _zip_new(error)) == NULL) { + return NULL; + } + + za->src = src; + za->open_flags = flags; + za->flags = 0; + za->ch_flags = 0; + za->write_crc = NULL; + + if (flags & ZIP_RDONLY) { + za->flags |= ZIP_AFL_RDONLY; + za->ch_flags |= ZIP_AFL_RDONLY; + } + + return za; +} + + +/* + * tests for file existence + */ +static exists_t +_zip_file_exists(zip_source_t *src, zip_error_t *error) { + struct zip_stat st; + + zip_stat_init(&st); + if (zip_source_stat(src, &st) != 0) { + zip_error_t *src_error = zip_source_error(src); + if (zip_error_code_zip(src_error) == ZIP_ER_READ && zip_error_code_system(src_error) == ENOENT) { + return EXISTS_NOT; + } + _zip_error_copy(error, src_error); + return EXISTS_ERROR; + } + + return EXISTS_OK; +} + + +static zip_cdir_t * +_zip_find_central_dir(zip_t *za, zip_uint64_t len) { + zip_cdir_t *cdir; + const zip_uint8_t *match; + zip_int64_t buf_offset; + zip_uint64_t buflen; + zip_error_t error; + zip_buffer_t *buffer; + + if (len < EOCDLEN) { + zip_error_set(&za->error, ZIP_ER_NOZIP, 0); + return NULL; + } + + buflen = (len < CDBUFSIZE ? len : CDBUFSIZE); + if (zip_source_seek(za->src, -(zip_int64_t)buflen, SEEK_END) < 0) { + zip_error_t *src_error = zip_source_error(za->src); + if (zip_error_code_zip(src_error) != ZIP_ER_SEEK || zip_error_code_system(src_error) != EFBIG) { + /* seek before start of file on my machine */ + _zip_error_copy(&za->error, src_error); + return NULL; + } + } + if ((buf_offset = zip_source_tell(za->src)) < 0) { + zip_error_set_from_source(&za->error, za->src); + return NULL; + } + + if ((buffer = _zip_buffer_new_from_source(za->src, buflen, NULL, &za->error)) == NULL) { + return NULL; + } + + cdir = NULL; + if (buflen >= CDBUFSIZE) { + /* EOCD64 locator is before EOCD, so leave place for it */ + _zip_buffer_set_offset(buffer, EOCD64LOCLEN); + } + zip_error_set(&error, ZIP_ER_NOZIP, 0); + + match = NULL; + while ((match = find_eocd(buffer, match)) != NULL) { + _zip_buffer_set_offset(buffer, (zip_uint64_t)(match - _zip_buffer_data(buffer))); + if (_zip_read_cdir(za, buffer, (zip_uint64_t)buf_offset, &cdir, &error)) { + if (cdir != NULL && (za->open_flags & ZIP_CHECKCONS) && _zip_checkcons(za, cdir, &error) < 0) { + _zip_cdir_free(cdir); + cdir = NULL; + } + break; + } + } + + _zip_buffer_free(buffer); + + if (cdir == NULL) { + _zip_error_copy(&za->error, &error); + } + return cdir; +} + + +static const unsigned char * +find_eocd(zip_buffer_t *buffer, const unsigned char *last) { + const unsigned char *data = _zip_buffer_data(buffer); + const unsigned char *p; + + if (last == NULL) { + last = data + _zip_buffer_size(buffer) - MAGIC_LEN; + } + else if (last == _zip_buffer_data(buffer)) { + return NULL; + } + else { + last -= 1; + } + + for (p = last; p >= data; p -= 1) { + if (*p == EOCD_MAGIC[0]) { + if (memcmp(p, EOCD_MAGIC, MAGIC_LEN) == 0) { + return p; + } + } + } + + return NULL; +} + + +static zip_cdir_t * +_zip_read_eocd(zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_error_t *error) { + zip_cdir_t *cd; + + if (_zip_buffer_left(buffer) < EOCDLEN) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_EOCD_LENGTH_INVALID); + return NULL; + } + + if ((cd = _zip_cdir_new(error)) == NULL) { + return NULL; + } + + cd->eocd_offset = buf_offset + _zip_buffer_offset(buffer); + /* This function is only called where EOCD magic was found, so no need to check that here. */ + _zip_buffer_skip(buffer, MAGIC_LEN); + cd->is_zip64 = false; + cd->this_disk = _zip_buffer_get_16(buffer); + cd->eocd_disk = _zip_buffer_get_16(buffer); + + /* number of cdir-entries on this disk */ + cd->disk_entries = _zip_buffer_get_16(buffer); + /* number of cdir-entries */ + cd->num_entries = _zip_buffer_get_16(buffer); + cd->size = _zip_buffer_get_32(buffer); + cd->offset = _zip_buffer_get_32(buffer); + + return cd; +} + +static bool +check_eocd(zip_cdir_t *cd, unsigned int flags, zip_error_t *error) { + if (cd->disk_entries != cd->num_entries || cd->this_disk != 0 || cd->eocd_disk != 0) { + zip_error_set(error, ZIP_ER_MULTIDISK, 0); + return false; + } + + if (cd->offset + cd->size < cd->offset) { + zip_error_set(error, ZIP_ER_SEEK, EFBIG); + return false; + } + if ((flags & ZIP_CHECKCONS) && cd->offset + cd->size != cd->eocd_offset) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_LENGTH_INVALID); + return false; + } + + return true; +} + + +cdir_status_t _zip_read_eocd64(zip_cdir_t *cdir, zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error) { + zip_uint64_t offset; + zip_uint8_t eocd[EOCD64LEN]; + zip_uint64_t eocd_offset; + zip_uint64_t size, nentry, i, eocdloc_offset; + bool free_buffer; + zip_uint32_t num_disks, eocd_disk, this_disk; + + eocdloc_offset = _zip_buffer_offset(buffer); + + _zip_buffer_get(buffer, 4); /* magic already verified */ + + eocd_disk = _zip_buffer_get_32(buffer); + eocd_offset = _zip_buffer_get_64(buffer); + num_disks = _zip_buffer_get_32(buffer); + + if (!check_magic(eocd_offset, buffer, buf_offset, src, EOCD64_MAGIC)) { + return CDIR_NOT_FOUND; + } + + if (num_disks != 1) { + zip_error_set(error, ZIP_ER_MULTIDISK, 0); + return CDIR_INVALID; + } + + /* valid seek value for start of EOCD */ + if (eocd_offset > ZIP_INT64_MAX) { + zip_error_set(error, ZIP_ER_SEEK, EFBIG); + return CDIR_INVALID; + } + + /* does EOCD fit before EOCD locator? */ + if (eocd_offset + EOCD64LEN > eocdloc_offset + buf_offset) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_EOCD64_OVERLAPS_EOCD); + return CDIR_INVALID; + } + + /* make sure current position of buffer is beginning of EOCD */ + if (eocd_offset >= buf_offset && eocd_offset + EOCD64LEN <= buf_offset + _zip_buffer_size(buffer)) { + _zip_buffer_set_offset(buffer, eocd_offset - buf_offset); + free_buffer = false; + } + else { + if (zip_source_seek(src, (zip_int64_t)eocd_offset, SEEK_SET) < 0) { + zip_error_set_from_source(error, src); + return CDIR_INVALID; + } + if ((buffer = _zip_buffer_new_from_source(src, EOCD64LEN, eocd, error)) == NULL) { + return CDIR_INVALID; + } + free_buffer = true; + } + + if (memcmp(_zip_buffer_get(buffer, 4), EOCD64_MAGIC, 4) != 0) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_EOCD64_WRONG_MAGIC); + if (free_buffer) { + _zip_buffer_free(buffer); + } + return CDIR_INVALID; + } + + /* size of EOCD */ + size = _zip_buffer_get_64(buffer); + + /* is there a hole between EOCD and EOCD locator, or do they overlap? */ + if ((flags & ZIP_CHECKCONS) && size + eocd_offset + 12 != buf_offset + eocdloc_offset) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_EOCD64_OVERLAPS_EOCD); + if (free_buffer) { + _zip_buffer_free(buffer); + } + return CDIR_INVALID; + } + + _zip_buffer_get(buffer, 4); /* skip version made by/needed */ + + this_disk = _zip_buffer_get_32(buffer); + if (_zip_buffer_get_32(buffer) != eocd_disk) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_EOCD64_LOCATOR_MISMATCH); + if (free_buffer) { + _zip_buffer_free(buffer); + } + return CDIR_INVALID; + } + + i = _zip_buffer_get_64(buffer); + nentry = _zip_buffer_get_64(buffer); + + if (nentry != i) { + zip_error_set(error, ZIP_ER_MULTIDISK, 0); + if (free_buffer) { + _zip_buffer_free(buffer); + } + return CDIR_INVALID; + } + + size = _zip_buffer_get_64(buffer); + offset = _zip_buffer_get_64(buffer); + + /* did we read past the end of the buffer? */ + if (!_zip_buffer_ok(buffer)) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + if (free_buffer) { + _zip_buffer_free(buffer); + } + return CDIR_INVALID; + } + + if (free_buffer) { + _zip_buffer_free(buffer); + } + + if (offset > ZIP_INT64_MAX || offset + size < offset) { + zip_error_set(error, ZIP_ER_SEEK, EFBIG); + return CDIR_INVALID; + } + + if (nentry > size / CDENTRYSIZE) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_INVALID); + return CDIR_INVALID; + } + + if ((cdir->size != 0xffffffff && cdir->size != size) || (cdir->offset != 0xffffffff && cdir->offset != offset) || (cdir->num_entries != 0xffff && cdir->num_entries != nentry) || (cdir->disk_entries != 0xffff && cdir->disk_entries != i) || (cdir->this_disk != 0xffff && cdir->this_disk != this_disk) || (cdir->eocd_disk != 0xffff && cdir->eocd_disk != eocd_disk)) { + zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_EOCD64_MISMATCH); + return CDIR_INVALID; + } + + cdir->is_zip64 = true; + cdir->size = size; + cdir->offset = offset; + cdir->disk_entries = i; + cdir->num_entries = nentry; + cdir->this_disk = this_disk; + cdir->eocd_disk = eocd_disk; + + return CDIR_OK; +} + + +static int +decode_hex(char c) { + if (c >= '0' && c <= '9') { + return c - '0'; + } + else if (c >= 'A' && c <= 'F') { + return c - 'A' + 10; + } + else { + return -1; + } +} + +/* _zip_check_torrentzip: + check whether ZA has a valid TORRENTZIP comment, i.e. is torrentzipped */ + +static void +zip_check_torrentzip(zip_t *za, const zip_cdir_t *cdir) { + zip_uint32_t crc_should; + char buf[8 + 1]; + size_t i; + + if (cdir == NULL) { + return; + } + + if (_zip_string_length(cdir->comment) != TORRENTZIP_SIGNATURE_LENGTH + TORRENTZIP_CRC_LENGTH || strncmp((const char *)cdir->comment->raw, TORRENTZIP_SIGNATURE, TORRENTZIP_SIGNATURE_LENGTH) != 0) + return; + + memcpy(buf, cdir->comment->raw + TORRENTZIP_SIGNATURE_LENGTH, TORRENTZIP_CRC_LENGTH); + buf[TORRENTZIP_CRC_LENGTH] = '\0'; + crc_should = 0; + for (i = 0; i < TORRENTZIP_CRC_LENGTH; i += 2) { + int low, high; + high = decode_hex((buf[i])); + low = decode_hex(buf[i + 1]); + if (high < 0 || low < 0) { + return; + } + crc_should = (crc_should << 8) + (high << 4) + low; + } + + { + zip_stat_t st; + zip_source_t *src_window; + zip_source_t *src_crc; + zip_uint8_t buffer[512]; + zip_int64_t ret; + + zip_stat_init(&st); + st.valid |= ZIP_STAT_SIZE | ZIP_STAT_CRC; + st.size = cdir->size; + st.crc = crc_should; + if ((src_window = _zip_source_window_new(za->src, cdir->offset, cdir->size, &st, 0, NULL, NULL, NULL, 0, false, NULL)) == NULL) { + return; + } + if ((src_crc = zip_source_crc_create(src_window, 1, NULL)) == NULL) { + zip_source_free(src_window); + return; + } + if (zip_source_open(src_crc) != 0) { + zip_source_free(src_crc); + return; + } + while ((ret = zip_source_read(src_crc, buffer, sizeof(buffer))) > 0) { + } + zip_source_free(src_crc); + if (ret < 0) { + return; + } + } + + /* TODO: if check consistency, check cdir entries for valid values */ + za->flags |= ZIP_AFL_IS_TORRENTZIP; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_pkware.c b/thirdparty/libzip-1.11.3/lib/zip_pkware.c new file mode 100644 index 0000000..ef3a30b --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_pkware.c @@ -0,0 +1,112 @@ +/* + zip_pkware.c -- Traditional PKWARE de/encryption backend routines + Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include + +#include "zipint.h" + +#define PKWARE_KEY0 305419896 +#define PKWARE_KEY1 591751049 +#define PKWARE_KEY2 878082192 + + +static void +update_keys(zip_pkware_keys_t *keys, zip_uint8_t b) { + keys->key[0] = (zip_uint32_t)crc32(keys->key[0] ^ 0xffffffffUL, &b, 1) ^ 0xffffffffUL; + keys->key[1] = (keys->key[1] + (keys->key[0] & 0xff)) * 134775813 + 1; + b = (zip_uint8_t)(keys->key[1] >> 24); + keys->key[2] = (zip_uint32_t)crc32(keys->key[2] ^ 0xffffffffUL, &b, 1) ^ 0xffffffffUL; +} + + +static zip_uint8_t +crypt_byte(zip_pkware_keys_t *keys) { + zip_uint16_t tmp; + tmp = (zip_uint16_t)(keys->key[2] | 2); + tmp = (zip_uint16_t)(((zip_uint32_t)tmp * (tmp ^ 1)) >> 8); + return (zip_uint8_t)tmp; +} + + +void +_zip_pkware_keys_reset(zip_pkware_keys_t *keys) { + keys->key[0] = PKWARE_KEY0; + keys->key[1] = PKWARE_KEY1; + keys->key[2] = PKWARE_KEY2; +} + + +void +_zip_pkware_encrypt(zip_pkware_keys_t *keys, zip_uint8_t *out, const zip_uint8_t *in, zip_uint64_t len) { + zip_uint64_t i; + zip_uint8_t b; + zip_uint8_t tmp; + + for (i = 0; i < len; i++) { + b = in[i]; + + if (out != NULL) { + tmp = crypt_byte(keys); + update_keys(keys, b); + b ^= tmp; + out[i] = b; + } + else { + /* during initialization, we're only interested in key updates */ + update_keys(keys, b); + } + } +} + + +void +_zip_pkware_decrypt(zip_pkware_keys_t *keys, zip_uint8_t *out, const zip_uint8_t *in, zip_uint64_t len) { + zip_uint64_t i; + zip_uint8_t b; + zip_uint8_t tmp; + + for (i = 0; i < len; i++) { + b = in[i]; + + /* during initialization, we're only interested in key updates */ + if (out != NULL) { + tmp = crypt_byte(keys); + b ^= tmp; + out[i] = b; + } + + update_keys(keys, b); + } +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_progress.c b/thirdparty/libzip-1.11.3/lib/zip_progress.c new file mode 100644 index 0000000..5693d7a --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_progress.c @@ -0,0 +1,293 @@ +/* + zip_progress.c -- progress reporting + Copyright (C) 2017-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include + + +#define _ZIP_COMPILING_DEPRECATED +#include "zipint.h" + +struct zip_progress { + zip_t *za; + + zip_progress_callback callback_progress; + void (*ud_progress_free)(void *); + void *ud_progress; + + zip_cancel_callback callback_cancel; + void (*ud_cancel_free)(void *); + void *ud_cancel; + + double precision; + + /* state */ + double last_update; /* last value callback function was called with */ + + double start; /* start of sub-progress section */ + double end; /* end of sub-progress section */ +}; + +static void _zip_progress_free_cancel_callback(zip_progress_t *progress); +static void _zip_progress_free_progress_callback(zip_progress_t *progress); +static zip_progress_t *_zip_progress_new(zip_t *za); +static void _zip_progress_set_cancel_callback(zip_progress_t *progress, zip_cancel_callback callback, void (*ud_free)(void *), void *ud); +static void _zip_progress_set_progress_callback(zip_progress_t *progress, double precision, zip_progress_callback callback, void (*ud_free)(void *), void *ud); + +void +_zip_progress_end(zip_progress_t *progress) { + _zip_progress_update(progress, 1.0); +} + + +void +_zip_progress_free(zip_progress_t *progress) { + if (progress == NULL) { + return; + } + + _zip_progress_free_progress_callback(progress); + _zip_progress_free_cancel_callback(progress); + + free(progress); +} + + +static zip_progress_t * +_zip_progress_new(zip_t *za) { + zip_progress_t *progress = (zip_progress_t *)malloc(sizeof(*progress)); + + if (progress == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return NULL; + } + + progress->za = za; + + progress->callback_progress = NULL; + progress->ud_progress_free = NULL; + progress->ud_progress = NULL; + progress->precision = 0.0; + + progress->callback_cancel = NULL; + progress->ud_cancel_free = NULL; + progress->ud_cancel = NULL; + + return progress; +} + +static void +_zip_progress_free_progress_callback(zip_progress_t *progress) { + if (progress->ud_progress_free) { + progress->ud_progress_free(progress->ud_progress); + } + + progress->callback_progress = NULL; + progress->ud_progress = NULL; + progress->ud_progress_free = NULL; +} + +static void +_zip_progress_free_cancel_callback(zip_progress_t *progress) { + if (progress->ud_cancel_free) { + progress->ud_cancel_free(progress->ud_cancel); + } + + progress->callback_cancel = NULL; + progress->ud_cancel = NULL; + progress->ud_cancel_free = NULL; +} + +static void +_zip_progress_set_progress_callback(zip_progress_t *progress, double precision, zip_progress_callback callback, void (*ud_free)(void *), void *ud) { + _zip_progress_free_progress_callback(progress); + + progress->callback_progress = callback; + progress->ud_progress_free = ud_free; + progress->ud_progress = ud; + progress->precision = precision; +} + +void +_zip_progress_set_cancel_callback(zip_progress_t *progress, zip_cancel_callback callback, void (*ud_free)(void *), void *ud) { + _zip_progress_free_cancel_callback(progress); + + progress->callback_cancel = callback; + progress->ud_cancel_free = ud_free; + progress->ud_cancel = ud; +} + +int +_zip_progress_start(zip_progress_t *progress) { + if (progress == NULL) { + return 0; + } + + if (progress->callback_progress != NULL) { + progress->last_update = 0.0; + progress->callback_progress(progress->za, 0.0, progress->ud_progress); + } + + if (progress->callback_cancel != NULL) { + if (progress->callback_cancel(progress->za, progress->ud_cancel)) { + return -1; + } + } + + return 0; +} + + +int +_zip_progress_subrange(zip_progress_t *progress, double start, double end) { + if (progress == NULL) { + return 0; + } + + progress->start = start; + progress->end = end; + + return _zip_progress_update(progress, 0.0); +} + +int +_zip_progress_update(zip_progress_t *progress, double sub_current) { + double current; + + if (progress == NULL) { + return 0; + } + + if (progress->callback_progress != NULL) { + current = ZIP_MIN(ZIP_MAX(sub_current, 0.0), 1.0) * (progress->end - progress->start) + progress->start; + + if (current - progress->last_update > progress->precision || (progress->last_update < 1 && current == 1)) { + progress->callback_progress(progress->za, current, progress->ud_progress); + progress->last_update = current; + } + } + + if (progress->callback_cancel != NULL) { + if (progress->callback_cancel(progress->za, progress->ud_cancel)) { + return -1; + } + } + + return 0; +} + + +ZIP_EXTERN int +zip_register_progress_callback_with_state(zip_t *za, double precision, zip_progress_callback callback, void (*ud_free)(void *), void *ud) { + if (callback != NULL) { + if (za->progress == NULL) { + if ((za->progress = _zip_progress_new(za)) == NULL) { + return -1; + } + } + + _zip_progress_set_progress_callback(za->progress, precision, callback, ud_free, ud); + } + else { + if (za->progress != NULL) { + if (za->progress->callback_cancel == NULL) { + _zip_progress_free(za->progress); + za->progress = NULL; + } + else { + _zip_progress_free_progress_callback(za->progress); + } + } + } + + return 0; +} + + +ZIP_EXTERN int +zip_register_cancel_callback_with_state(zip_t *za, zip_cancel_callback callback, void (*ud_free)(void *), void *ud) { + if (callback != NULL) { + if (za->progress == NULL) { + if ((za->progress = _zip_progress_new(za)) == NULL) { + return -1; + } + } + + _zip_progress_set_cancel_callback(za->progress, callback, ud_free, ud); + } + else { + if (za->progress != NULL) { + if (za->progress->callback_progress == NULL) { + _zip_progress_free(za->progress); + za->progress = NULL; + } + else { + _zip_progress_free_cancel_callback(za->progress); + } + } + } + + return 0; +} + + +struct legacy_ud { + zip_progress_callback_t callback; +}; + + +static void +_zip_legacy_progress_callback(zip_t *za, double progress, void *vud) { + struct legacy_ud *ud = (struct legacy_ud *)vud; + + ud->callback(progress); +} + +ZIP_EXTERN void +zip_register_progress_callback(zip_t *za, zip_progress_callback_t progress_callback) { + struct legacy_ud *ud; + + if (progress_callback == NULL) { + zip_register_progress_callback_with_state(za, 0, NULL, NULL, NULL); + } + + if ((ud = (struct legacy_ud *)malloc(sizeof(*ud))) == NULL) { + return; + } + + ud->callback = progress_callback; + + if (zip_register_progress_callback_with_state(za, 0.001, _zip_legacy_progress_callback, free, ud) < 0) { + free(ud); + } +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_random_unix.c b/thirdparty/libzip-1.11.3/lib/zip_random_unix.c new file mode 100644 index 0000000..9446ca9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_random_unix.c @@ -0,0 +1,110 @@ +/* + zip_random_unix.c -- fill the user's buffer with random stuff (Unix version) + Copyright (C) 2016-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +#ifdef HAVE_CRYPTO +#include "zip_crypto.h" +#endif + +#ifdef HAVE_ARC4RANDOM + +#include + +#ifndef HAVE_SECURE_RANDOM +ZIP_EXTERN bool +zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { + arc4random_buf(buffer, length); + return true; +} +#endif + +#ifndef HAVE_RANDOM_UINT32 +zip_uint32_t +zip_random_uint32(void) { + return arc4random(); +} +#endif + +#else /* HAVE_ARC4RANDOM */ + +#ifndef HAVE_SECURE_RANDOM +#include +#include + +ZIP_EXTERN bool +zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { + int fd; + + if ((fd = open("/dev/urandom", O_RDONLY)) < 0) { + return false; + } + + if (read(fd, buffer, length) != length) { + close(fd); + return false; + } + + close(fd); + return true; +} +#endif + +#ifndef HAVE_RANDOM_UINT32 +#include + +#ifndef HAVE_RANDOM +#define srandom srand +#define random rand +#endif + +zip_uint32_t +zip_random_uint32(void) { + static bool seeded = false; + + zip_uint32_t value; + + if (zip_secure_random((zip_uint8_t *)&value, sizeof(value))) { + return value; + } + + if (!seeded) { + srandom((unsigned int)time(NULL)); + seeded = true; + } + + return (zip_uint32_t)random(); +} +#endif + +#endif /* HAVE_ARC4RANDOM */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_random_uwp.c b/thirdparty/libzip-1.11.3/lib/zip_random_uwp.c new file mode 100644 index 0000000..7accdeb --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_random_uwp.c @@ -0,0 +1,82 @@ +/* + zip_random_uwp.c -- fill the user's buffer with random stuff (UWP version) + Copyright (C) 2017-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +#ifdef HAVE_CRYPTO +#include "zip_crypto.h" +#endif + +#ifndef HAVE_SECURE_RANDOM + +#include +#include + +ZIP_EXTERN bool +zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { + BCRYPT_ALG_HANDLE hAlg = NULL; + NTSTATUS hr = BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_RNG_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0); + if (!BCRYPT_SUCCESS(hr) || hAlg == NULL) { + return false; + } + hr = BCryptGenRandom(&hAlg, buffer, length, 0); + BCryptCloseAlgorithmProvider(&hAlg, 0); + if (!BCRYPT_SUCCESS(hr)) { + return false; + } + return true; +} + +#endif + +#ifndef HAVE_RANDOM_UINT32 +#include + +zip_uint32_t +zip_random_uint32(void) { + static bool seeded = false; + + zip_uint32_t value; + + if (zip_secure_random((zip_uint8_t *)&value, sizeof(value))) { + return value; + } + + if (!seeded) { + srand((unsigned int)time(NULL)); + seeded = true; + } + + return (zip_uint32_t)rand(); +} +#endif diff --git a/thirdparty/libzip-1.11.3/lib/zip_random_win32.c b/thirdparty/libzip-1.11.3/lib/zip_random_win32.c new file mode 100644 index 0000000..209ca4b --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_random_win32.c @@ -0,0 +1,82 @@ +/* + zip_random_win32.c -- fill the user's buffer with random stuff (Windows version) + Copyright (C) 2016-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +#ifdef HAVE_CRYPTO +#include "zip_crypto.h" +#endif + +#include + +#ifndef HAVE_SECURE_RANDOM + +#include + +ZIP_EXTERN bool +zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { + HCRYPTPROV hprov; + if (!CryptAcquireContext(&hprov, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) { + return false; + } + if (!CryptGenRandom(hprov, length, buffer)) { + return false; + } + if (!CryptReleaseContext(hprov, 0)) { + return false; + } + return true; +} +#endif + +#ifndef HAVE_RANDOM_UINT32 +#include + +zip_uint32_t +zip_random_uint32(void) { + static bool seeded = false; + + zip_uint32_t value; + + if (zip_secure_random((zip_uint8_t *)&value, sizeof(value))) { + return value; + } + + if (!seeded) { + srand((unsigned int)time(NULL)); + seeded = true; + } + + return (zip_uint32_t)rand(); +} +#endif diff --git a/thirdparty/libzip-1.11.3/lib/zip_rename.c b/thirdparty/libzip-1.11.3/lib/zip_rename.c new file mode 100644 index 0000000..b356de4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_rename.c @@ -0,0 +1,42 @@ +/* + zip_rename.c -- rename file in zip archive + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#define _ZIP_COMPILING_DEPRECATED +#include "zipint.h" + + +ZIP_EXTERN int +zip_rename(zip_t *za, zip_uint64_t idx, const char *name) { + return zip_file_rename(za, idx, name, 0); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_replace.c b/thirdparty/libzip-1.11.3/lib/zip_replace.c new file mode 100644 index 0000000..549306a --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_replace.c @@ -0,0 +1,42 @@ +/* + zip_replace.c -- replace file via callback function + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#define _ZIP_COMPILING_DEPRECATED +#include "zipint.h" + + +ZIP_EXTERN int +zip_replace(zip_t *za, zip_uint64_t idx, zip_source_t *source) { + return zip_file_replace(za, idx, source, 0); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_set_archive_comment.c b/thirdparty/libzip-1.11.3/lib/zip_set_archive_comment.c new file mode 100644 index 0000000..2c75bda --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_set_archive_comment.c @@ -0,0 +1,84 @@ +/* + zip_set_archive_comment.c -- set archive comment + Copyright (C) 2006-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +ZIP_EXTERN int +zip_set_archive_comment(zip_t *za, const char *comment, zip_uint16_t len) { + zip_string_t *cstr; + + if (ZIP_IS_RDONLY(za)) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + if (ZIP_WANT_TORRENTZIP(za)) { + zip_error_set(&za->error, ZIP_ER_NOT_ALLOWED, 0); + return -1; + } + + if (len > 0 && comment == NULL) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (len > 0) { + if ((cstr = _zip_string_new((const zip_uint8_t *)comment, len, ZIP_FL_ENC_GUESS, &za->error)) == NULL) + return -1; + + if (_zip_guess_encoding(cstr, ZIP_ENCODING_UNKNOWN) == ZIP_ENCODING_CP437) { + _zip_string_free(cstr); + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + } + else + cstr = NULL; + + _zip_string_free(za->comment_changes); + za->comment_changes = NULL; + + if (((za->comment_orig && _zip_string_equal(za->comment_orig, cstr)) || (za->comment_orig == NULL && cstr == NULL))) { + _zip_string_free(cstr); + za->comment_changed = 0; + } + else { + za->comment_changes = cstr; + za->comment_changed = 1; + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_set_archive_flag.c b/thirdparty/libzip-1.11.3/lib/zip_set_archive_flag.c new file mode 100644 index 0000000..7533ac5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_set_archive_flag.c @@ -0,0 +1,76 @@ +/* + zip_get_archive_flag.c -- set archive global flag + Copyright (C) 2008-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_set_archive_flag(zip_t *za, zip_flags_t flag, int value) { + unsigned int new_flags; + + if (flag == ZIP_AFL_IS_TORRENTZIP) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + /* TODO: when setting ZIP_AFL_WANT_TORRENTZIP, we should error out if any changes have been made that are not allowed for torrentzip. */ + + if (value) { + new_flags = za->ch_flags | flag; + } + else { + new_flags = za->ch_flags & ~flag; + } + + if (new_flags == za->ch_flags) { + return 0; + } + + /* Allow removing ZIP_AFL_RDONLY if manually set, not if archive was opened read-only. */ + if (za->flags & ZIP_AFL_RDONLY) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + + if ((flag & ZIP_AFL_RDONLY) && value && (za->ch_flags & ZIP_AFL_RDONLY) == 0) { + if (_zip_changed(za, NULL)) { + zip_error_set(&za->error, ZIP_ER_CHANGED, 0); + return -1; + } + } + + za->ch_flags = new_flags; + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_set_default_password.c b/thirdparty/libzip-1.11.3/lib/zip_set_default_password.c new file mode 100644 index 0000000..07b3a06 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_set_default_password.c @@ -0,0 +1,58 @@ +/* + zip_set_default_password.c -- set default password for decryption + Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include + +#include "zipint.h" + + +ZIP_EXTERN int +zip_set_default_password(zip_t *za, const char *passwd) { + if (za == NULL) + return -1; + + free(za->default_password); + + if (passwd && passwd[0] != '\0') { + if ((za->default_password = strdup(passwd)) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + } + else + za->default_password = NULL; + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_set_file_comment.c b/thirdparty/libzip-1.11.3/lib/zip_set_file_comment.c new file mode 100644 index 0000000..b587ae9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_set_file_comment.c @@ -0,0 +1,46 @@ +/* + zip_set_file_comment.c -- set comment for file in archive + Copyright (C) 2006-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#define _ZIP_COMPILING_DEPRECATED +#include "zipint.h" + + +ZIP_EXTERN int +zip_set_file_comment(zip_t *za, zip_uint64_t idx, const char *comment, int len) { + if (len < 0 || len > ZIP_UINT16_MAX) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + return zip_file_set_comment(za, idx, comment, (zip_uint16_t)len, 0); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_set_file_compression.c b/thirdparty/libzip-1.11.3/lib/zip_set_file_compression.c new file mode 100644 index 0000000..cee099d --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_set_file_compression.c @@ -0,0 +1,95 @@ +/* + zip_set_file_compression.c -- set compression for file in archive + Copyright (C) 2012-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_set_file_compression(zip_t *za, zip_uint64_t idx, zip_int32_t method, zip_uint32_t flags) { + zip_entry_t *e; + zip_int32_t old_method; + + if (idx >= za->nentry) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (ZIP_IS_RDONLY(za)) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + if (ZIP_WANT_TORRENTZIP(za)) { + zip_error_set(&za->error, ZIP_ER_NOT_ALLOWED, 0); + return -1; + } + + if (!zip_compression_method_supported(method, true)) { + zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0); + return -1; + } + + e = za->entry + idx; + + old_method = (e->orig == NULL ? ZIP_CM_DEFAULT : e->orig->comp_method); + + /* TODO: do we want to recompress if level is set? Only if it's + * different than what bit flags tell us, but those are not + * defined for all compression methods, or not directly mappable + * to levels */ + + if (method == old_method) { + if (e->changes) { + e->changes->changed &= ~ZIP_DIRENT_COMP_METHOD; + e->changes->compression_level = 0; + if (e->changes->changed == 0) { + _zip_dirent_free(e->changes); + e->changes = NULL; + } + } + } + else { + if (e->changes == NULL) { + if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + } + + e->changes->comp_method = method; + e->changes->compression_level = (zip_uint16_t)flags; + e->changes->changed |= ZIP_DIRENT_COMP_METHOD; + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_set_name.c b/thirdparty/libzip-1.11.3/lib/zip_set_name.c new file mode 100644 index 0000000..0087af1 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_set_name.c @@ -0,0 +1,157 @@ +/* + zip_set_name.c -- rename helper function + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include + +#include "zipint.h" + + +int +_zip_set_name(zip_t *za, zip_uint64_t idx, const char *name, zip_flags_t flags) { + zip_entry_t *e; + zip_string_t *str; + bool same_as_orig; + zip_int64_t i; + const zip_uint8_t *old_name, *new_name; + zip_string_t *old_str; + + if (idx >= za->nentry) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (ZIP_IS_RDONLY(za)) { + zip_error_set(&za->error, ZIP_ER_RDONLY, 0); + return -1; + } + + if (name && name[0] != '\0') { + /* TODO: check for string too long */ + if ((str = _zip_string_new((const zip_uint8_t *)name, (zip_uint16_t)strlen(name), flags, &za->error)) == NULL) + return -1; + if ((flags & ZIP_FL_ENCODING_ALL) == ZIP_FL_ENC_GUESS && _zip_guess_encoding(str, ZIP_ENCODING_UNKNOWN) == ZIP_ENCODING_UTF8_GUESSED) + str->encoding = ZIP_ENCODING_UTF8_KNOWN; + } + else + str = NULL; + + /* TODO: encoding flags needed for CP437? */ + if ((i = _zip_name_locate(za, name, 0, NULL)) >= 0 && (zip_uint64_t)i != idx) { + _zip_string_free(str); + zip_error_set(&za->error, ZIP_ER_EXISTS, 0); + return -1; + } + + /* no effective name change */ + if (i >= 0 && (zip_uint64_t)i == idx) { + _zip_string_free(str); + return 0; + } + + e = za->entry + idx; + + if (e->orig) + same_as_orig = _zip_string_equal(e->orig->filename, str); + else + same_as_orig = false; + + if (!same_as_orig && e->changes == NULL) { + if ((e->changes = _zip_dirent_clone(e->orig)) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + _zip_string_free(str); + return -1; + } + } + + if ((new_name = _zip_string_get(same_as_orig ? e->orig->filename : str, NULL, 0, &za->error)) == NULL) { + _zip_string_free(str); + return -1; + } + + if (e->changes) { + old_str = e->changes->filename; + } + else if (e->orig) { + old_str = e->orig->filename; + } + else { + old_str = NULL; + } + + if (old_str) { + if ((old_name = _zip_string_get(old_str, NULL, 0, &za->error)) == NULL) { + _zip_string_free(str); + return -1; + } + } + else { + old_name = NULL; + } + + if (_zip_hash_add(za->names, new_name, idx, 0, &za->error) == false) { + _zip_string_free(str); + return -1; + } + if (old_name) { + _zip_hash_delete(za->names, old_name, NULL); + } + + if (same_as_orig) { + if (e->changes) { + if (e->changes->changed & ZIP_DIRENT_FILENAME) { + _zip_string_free(e->changes->filename); + e->changes->changed &= ~ZIP_DIRENT_FILENAME; + if (e->changes->changed == 0) { + _zip_dirent_free(e->changes); + e->changes = NULL; + } + else { + /* TODO: what if not cloned? can that happen? */ + e->changes->filename = e->orig->filename; + } + } + } + _zip_string_free(str); + } + else { + if (e->changes->changed & ZIP_DIRENT_FILENAME) { + _zip_string_free(e->changes->filename); + } + e->changes->changed |= ZIP_DIRENT_FILENAME; + e->changes->filename = str; + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_accept_empty.c b/thirdparty/libzip-1.11.3/lib/zip_source_accept_empty.c new file mode 100644 index 0000000..be31943 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_accept_empty.c @@ -0,0 +1,52 @@ +/* + zip_source_accept_empty.c -- if empty source is a valid archive + Copyright (C) 2019-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +bool +zip_source_accept_empty(zip_source_t *src) { + zip_int64_t ret; + + if ((zip_source_supports(src) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ACCEPT_EMPTY)) == 0) { + if (ZIP_SOURCE_IS_LAYERED(src)) { + return zip_source_accept_empty(src->src); + } + return true; + } + + ret = _zip_source_call(src, NULL, 0, ZIP_SOURCE_ACCEPT_EMPTY); + + return ret != 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_begin_write.c b/thirdparty/libzip-1.11.3/lib/zip_source_begin_write.c new file mode 100644 index 0000000..2724335 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_begin_write.c @@ -0,0 +1,57 @@ +/* + zip_source_begin_write.c -- start a new file for writing + Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_source_begin_write(zip_source_t *src) { + if (ZIP_SOURCE_IS_LAYERED(src)) { + zip_error_set(&src->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + } + + if (ZIP_SOURCE_IS_OPEN_WRITING(src)) { + zip_error_set(&src->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (_zip_source_call(src, NULL, 0, ZIP_SOURCE_BEGIN_WRITE) < 0) { + return -1; + } + + src->write_state = ZIP_SOURCE_WRITE_OPEN; + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_begin_write_cloning.c b/thirdparty/libzip-1.11.3/lib/zip_source_begin_write_cloning.c new file mode 100644 index 0000000..67d3475 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_begin_write_cloning.c @@ -0,0 +1,57 @@ +/* + zip_source_begin_write_cloning.c -- clone part of file for writing + Copyright (C) 2017-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_source_begin_write_cloning(zip_source_t *src, zip_uint64_t offset) { + if (ZIP_SOURCE_IS_LAYERED(src)) { + zip_error_set(&src->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + } + + if (ZIP_SOURCE_IS_OPEN_WRITING(src)) { + zip_error_set(&src->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (_zip_source_call(src, NULL, offset, ZIP_SOURCE_BEGIN_WRITE_CLONING) < 0) { + return -1; + } + + src->write_state = ZIP_SOURCE_WRITE_OPEN; + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_buffer.c b/thirdparty/libzip-1.11.3/lib/zip_source_buffer.c new file mode 100644 index 0000000..be5a9c4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_buffer.c @@ -0,0 +1,644 @@ +/* + zip_source_buffer.c -- create zip data source from buffer + Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include + +#include "zipint.h" + +#ifndef WRITE_FRAGMENT_SIZE +#define WRITE_FRAGMENT_SIZE (64 * 1024) +#endif + +struct buffer { + zip_buffer_fragment_t *fragments; /* fragments */ + zip_uint64_t *fragment_offsets; /* offset of each fragment from start of buffer, nfragments+1 entries */ + zip_uint64_t nfragments; /* number of allocated fragments */ + zip_uint64_t fragments_capacity; /* size of fragments (number of pointers) */ + + zip_uint64_t first_owned_fragment; /* first fragment to free data from */ + + zip_uint64_t shared_fragments; /* number of shared fragments */ + struct buffer *shared_buffer; /* buffer fragments are shared with */ + + zip_uint64_t size; /* size of buffer */ + zip_uint64_t offset; /* current offset in buffer */ + zip_uint64_t current_fragment; /* fragment current offset is in */ +}; + +typedef struct buffer buffer_t; + +struct read_data { + zip_error_t error; + time_t mtime; + zip_file_attributes_t attributes; + buffer_t *in; + buffer_t *out; +}; + +#define buffer_capacity(buffer) ((buffer)->fragment_offsets[(buffer)->nfragments]) +#define buffer_size(buffer) ((buffer)->size) + +static buffer_t *buffer_clone(buffer_t *buffer, zip_uint64_t length, zip_error_t *error); +static zip_uint64_t buffer_find_fragment(const buffer_t *buffer, zip_uint64_t offset); +static void buffer_free(buffer_t *buffer); +static bool buffer_grow_fragments(buffer_t *buffer, zip_uint64_t capacity, zip_error_t *error); +static buffer_t *buffer_new(const zip_buffer_fragment_t *fragments, zip_uint64_t nfragments, int free_data, zip_error_t *error); +static zip_int64_t buffer_read(buffer_t *buffer, zip_uint8_t *data, zip_uint64_t length); +static int buffer_seek(buffer_t *buffer, void *data, zip_uint64_t len, zip_error_t *error); +static zip_int64_t buffer_write(buffer_t *buffer, const zip_uint8_t *data, zip_uint64_t length, zip_error_t *); + +static zip_int64_t read_data(void *, void *, zip_uint64_t, zip_source_cmd_t); + +zip_source_t *zip_source_buffer_with_attributes_create(const void *data, zip_uint64_t len, int freep, zip_file_attributes_t *attributes, zip_error_t *error); +zip_source_t *zip_source_buffer_fragment_with_attributes_create(const zip_buffer_fragment_t *fragments, zip_uint64_t nfragments, int freep, zip_file_attributes_t *attributes, zip_error_t *error); + + +ZIP_EXTERN zip_source_t * +zip_source_buffer(zip_t *za, const void *data, zip_uint64_t len, int freep) { + if (za == NULL) + return NULL; + + return zip_source_buffer_with_attributes_create(data, len, freep, NULL, &za->error); +} + + +ZIP_EXTERN zip_source_t * +zip_source_buffer_create(const void *data, zip_uint64_t len, int freep, zip_error_t *error) { + return zip_source_buffer_with_attributes_create(data, len, freep, NULL, error); +} + + +zip_source_t * +zip_source_buffer_with_attributes_create(const void *data, zip_uint64_t len, int freep, zip_file_attributes_t *attributes, zip_error_t *error) { + zip_buffer_fragment_t fragment; + + if (data == NULL) { + if (len > 0) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + return zip_source_buffer_fragment_with_attributes_create(NULL, 0, freep, attributes, error); + } + + fragment.data = (zip_uint8_t *)data; + fragment.length = len; + + return zip_source_buffer_fragment_with_attributes_create(&fragment, 1, freep, attributes, error); +} + + +ZIP_EXTERN zip_source_t * +zip_source_buffer_fragment(zip_t *za, const zip_buffer_fragment_t *fragments, zip_uint64_t nfragments, int freep) { + if (za == NULL) { + return NULL; + } + + return zip_source_buffer_fragment_with_attributes_create(fragments, nfragments, freep, NULL, &za->error); +} + + +ZIP_EXTERN zip_source_t * +zip_source_buffer_fragment_create(const zip_buffer_fragment_t *fragments, zip_uint64_t nfragments, int freep, zip_error_t *error) { + return zip_source_buffer_fragment_with_attributes_create(fragments, nfragments, freep, NULL, error); +} + +zip_source_t * +zip_source_buffer_fragment_with_attributes_create(const zip_buffer_fragment_t *fragments, zip_uint64_t nfragments, int freep, zip_file_attributes_t *attributes, zip_error_t *error) { + struct read_data *ctx; + zip_source_t *zs; + buffer_t *buffer; + + if (fragments == NULL && nfragments > 0) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((buffer = buffer_new(fragments, nfragments, freep, error)) == NULL) { + return NULL; + } + + if ((ctx = (struct read_data *)malloc(sizeof(*ctx))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + buffer_free(buffer); + return NULL; + } + + ctx->in = buffer; + ctx->out = NULL; + ctx->mtime = time(NULL); + if (attributes) { + (void)memcpy_s(&ctx->attributes, sizeof(ctx->attributes), attributes, sizeof(ctx->attributes)); + } + else { + zip_file_attributes_init(&ctx->attributes); + } + zip_error_init(&ctx->error); + + if ((zs = zip_source_function_create(read_data, ctx, error)) == NULL) { + buffer_free(ctx->in); + free(ctx); + return NULL; + } + + return zs; +} + + +zip_source_t * +zip_source_buffer_with_attributes(zip_t *za, const void *data, zip_uint64_t len, int freep, zip_file_attributes_t *attributes) { + return zip_source_buffer_with_attributes_create(data, len, freep, attributes, &za->error); +} + +static zip_int64_t +read_data(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { + struct read_data *ctx = (struct read_data *)state; + + switch (cmd) { + case ZIP_SOURCE_BEGIN_WRITE: + if ((ctx->out = buffer_new(NULL, 0, 0, &ctx->error)) == NULL) { + return -1; + } + ctx->out->offset = 0; + ctx->out->current_fragment = 0; + return 0; + + case ZIP_SOURCE_BEGIN_WRITE_CLONING: + if ((ctx->out = buffer_clone(ctx->in, len, &ctx->error)) == NULL) { + return -1; + } + ctx->out->offset = len; + ctx->out->current_fragment = ctx->out->nfragments; + return 0; + + case ZIP_SOURCE_CLOSE: + return 0; + + case ZIP_SOURCE_COMMIT_WRITE: + buffer_free(ctx->in); + ctx->in = ctx->out; + ctx->out = NULL; + return 0; + + case ZIP_SOURCE_ERROR: + return zip_error_to_data(&ctx->error, data, len); + + case ZIP_SOURCE_FREE: + buffer_free(ctx->in); + buffer_free(ctx->out); + free(ctx); + return 0; + + case ZIP_SOURCE_GET_FILE_ATTRIBUTES: { + if (len < sizeof(ctx->attributes)) { + zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); + return -1; + } + + (void)memcpy_s(data, sizeof(ctx->attributes), &ctx->attributes, sizeof(ctx->attributes)); + + return sizeof(ctx->attributes); + } + + case ZIP_SOURCE_OPEN: + ctx->in->offset = 0; + ctx->in->current_fragment = 0; + return 0; + + case ZIP_SOURCE_READ: + if (len > ZIP_INT64_MAX) { + zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); + return -1; + } + return buffer_read(ctx->in, data, len); + + case ZIP_SOURCE_REMOVE: { + buffer_t *empty = buffer_new(NULL, 0, 0, &ctx->error); + if (empty == NULL) { + return -1; + } + + buffer_free(ctx->in); + ctx->in = empty; + return 0; + } + + case ZIP_SOURCE_ROLLBACK_WRITE: + buffer_free(ctx->out); + ctx->out = NULL; + return 0; + + case ZIP_SOURCE_SEEK: + return buffer_seek(ctx->in, data, len, &ctx->error); + + case ZIP_SOURCE_SEEK_WRITE: + return buffer_seek(ctx->out, data, len, &ctx->error); + + case ZIP_SOURCE_STAT: { + zip_stat_t *st; + + if (len < sizeof(*st)) { + zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); + return -1; + } + + st = (zip_stat_t *)data; + + zip_stat_init(st); + st->mtime = ctx->mtime; + st->size = ctx->in->size; + st->comp_size = st->size; + st->comp_method = ZIP_CM_STORE; + st->encryption_method = ZIP_EM_NONE; + st->valid = ZIP_STAT_MTIME | ZIP_STAT_SIZE | ZIP_STAT_COMP_SIZE | ZIP_STAT_COMP_METHOD | ZIP_STAT_ENCRYPTION_METHOD; + + return sizeof(*st); + } + + case ZIP_SOURCE_SUPPORTS: + return zip_source_make_command_bitmap(ZIP_SOURCE_GET_FILE_ATTRIBUTES, ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_STAT, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_SEEK, ZIP_SOURCE_TELL, ZIP_SOURCE_BEGIN_WRITE, ZIP_SOURCE_BEGIN_WRITE_CLONING, ZIP_SOURCE_COMMIT_WRITE, ZIP_SOURCE_REMOVE, ZIP_SOURCE_ROLLBACK_WRITE, ZIP_SOURCE_SEEK_WRITE, ZIP_SOURCE_TELL_WRITE, ZIP_SOURCE_WRITE, ZIP_SOURCE_SUPPORTS_REOPEN, -1); + + case ZIP_SOURCE_TELL: + if (ctx->in->offset > ZIP_INT64_MAX) { + zip_error_set(&ctx->error, ZIP_ER_TELL, EOVERFLOW); + return -1; + } + return (zip_int64_t)ctx->in->offset; + + + case ZIP_SOURCE_TELL_WRITE: + if (ctx->out->offset > ZIP_INT64_MAX) { + zip_error_set(&ctx->error, ZIP_ER_TELL, EOVERFLOW); + return -1; + } + return (zip_int64_t)ctx->out->offset; + + case ZIP_SOURCE_WRITE: + if (len > ZIP_INT64_MAX) { + zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); + return -1; + } + return buffer_write(ctx->out, data, len, &ctx->error); + + default: + zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + } +} + + +static buffer_t * +buffer_clone(buffer_t *buffer, zip_uint64_t offset, zip_error_t *error) { + zip_uint64_t fragment, fragment_offset, waste; + buffer_t *clone; + + if (offset == 0) { + return buffer_new(NULL, 0, 1, error); + } + + if (offset > buffer->size) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + if (buffer->shared_buffer != NULL) { + zip_error_set(error, ZIP_ER_INUSE, 0); + return NULL; + } + + fragment = buffer_find_fragment(buffer, offset); + fragment_offset = offset - buffer->fragment_offsets[fragment]; + + if (fragment_offset == 0) { + /* We can't be at beginning of fragment zero if offset > 0. */ + fragment--; + fragment_offset = buffer->fragments[fragment].length; + } + + /* TODO: This should also consider the length of the fully shared fragments */ + waste = buffer->fragments[fragment].length - fragment_offset; + if (waste > offset) { + zip_error_set(error, ZIP_ER_OPNOTSUPP, 0); + return NULL; + } + + if ((clone = buffer_new(buffer->fragments, fragment + 1, 0, error)) == NULL) { + return NULL; + } + +#ifndef __clang_analyzer__ + /* clone->fragments can't be null, since it was created with at least one fragment */ + clone->fragments[fragment].length = fragment_offset; +#endif + clone->fragment_offsets[clone->nfragments] = offset; + clone->size = offset; + + clone->first_owned_fragment = ZIP_MIN(buffer->first_owned_fragment, clone->nfragments); + + buffer->shared_buffer = clone; + clone->shared_buffer = buffer; + buffer->shared_fragments = fragment + 1; + clone->shared_fragments = fragment + 1; + + return clone; +} + + +static zip_uint64_t +buffer_find_fragment(const buffer_t *buffer, zip_uint64_t offset) { + zip_uint64_t low, high, mid; + + if (buffer->nfragments == 0) { + return 0; + } + + low = 0; + high = buffer->nfragments - 1; + + while (low < high) { + mid = (high - low) / 2 + low; + if (buffer->fragment_offsets[mid] > offset) { + high = mid - 1; + } + else if (mid == buffer->nfragments || buffer->fragment_offsets[mid + 1] > offset) { + return mid; + } + else { + low = mid + 1; + } + } + + return low; +} + + +static void +buffer_free(buffer_t *buffer) { + zip_uint64_t i; + + if (buffer == NULL) { + return; + } + + if (buffer->shared_buffer != NULL) { + buffer->shared_buffer->shared_buffer = NULL; + buffer->shared_buffer->shared_fragments = 0; + + buffer->first_owned_fragment = ZIP_MAX(buffer->first_owned_fragment, buffer->shared_fragments); + } + + for (i = buffer->first_owned_fragment; i < buffer->nfragments; i++) { + free(buffer->fragments[i].data); + } + free(buffer->fragments); + free(buffer->fragment_offsets); + free(buffer); +} + + +static bool +buffer_grow_fragments(buffer_t *buffer, zip_uint64_t capacity, zip_error_t *error) { + zip_buffer_fragment_t *fragments; + zip_uint64_t *offsets; + + if (capacity < buffer->fragments_capacity) { + return true; + } + + zip_uint64_t fragments_size = sizeof(buffer->fragments[0]) * capacity; + zip_uint64_t offsets_size = sizeof(buffer->fragment_offsets[0]) * (capacity + 1); + + if (capacity == ZIP_UINT64_MAX || fragments_size < capacity || fragments_size > SIZE_MAX|| offsets_size < capacity || offsets_size > SIZE_MAX) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return false; + } + + if ((fragments = realloc(buffer->fragments, (size_t)fragments_size)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return false; + } + buffer->fragments = fragments; + if ((offsets = realloc(buffer->fragment_offsets, (size_t)offsets_size)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return false; + } + buffer->fragment_offsets = offsets; + buffer->fragments_capacity = capacity; + + return true; +} + + +static buffer_t * +buffer_new(const zip_buffer_fragment_t *fragments, zip_uint64_t nfragments, int free_data, zip_error_t *error) { + buffer_t *buffer; + + if ((buffer = malloc(sizeof(*buffer))) == NULL) { + return NULL; + } + + buffer->offset = 0; + buffer->first_owned_fragment = 0; + buffer->size = 0; + buffer->fragments = NULL; + buffer->fragment_offsets = NULL; + buffer->nfragments = 0; + buffer->fragments_capacity = 0; + buffer->shared_buffer = NULL; + buffer->shared_fragments = 0; + + if (nfragments == 0) { + if ((buffer->fragment_offsets = malloc(sizeof(buffer->fragment_offsets[0]))) == NULL) { + free(buffer); + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + buffer->fragment_offsets[0] = 0; + } + else { + zip_uint64_t i, j, offset; + + if (!buffer_grow_fragments(buffer, nfragments, NULL)) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + buffer_free(buffer); + return NULL; + } + + offset = 0; + for (i = 0, j = 0; i < nfragments; i++) { + if (fragments[i].length == 0) { + continue; + } + if (fragments[i].data == NULL) { + zip_error_set(error, ZIP_ER_INVAL, 0); + buffer_free(buffer); + return NULL; + } + buffer->fragments[j].data = fragments[i].data; + buffer->fragments[j].length = fragments[i].length; + buffer->fragment_offsets[i] = offset; + /* TODO: overflow */ + offset += fragments[i].length; + j++; + } + buffer->nfragments = j; + buffer->first_owned_fragment = free_data ? 0 : buffer->nfragments; + buffer->fragment_offsets[buffer->nfragments] = offset; + buffer->size = offset; + } + + return buffer; +} + +static zip_int64_t +buffer_read(buffer_t *buffer, zip_uint8_t *data, zip_uint64_t length) { + zip_uint64_t n, i, fragment_offset; + + length = ZIP_MIN(length, buffer->size - buffer->offset); + + if (length == 0) { + return 0; + } + if (length > ZIP_INT64_MAX) { + return -1; + } + + i = buffer->current_fragment; + fragment_offset = buffer->offset - buffer->fragment_offsets[i]; + n = 0; + while (n < length) { + zip_uint64_t left = ZIP_MIN(length - n, buffer->fragments[i].length - fragment_offset); +#if ZIP_UINT64_MAX > SIZE_MAX + left = ZIP_MIN(left, SIZE_MAX); +#endif + + (void)memcpy_s(data + n, (size_t)left, buffer->fragments[i].data + fragment_offset, (size_t)left); + + if (left == buffer->fragments[i].length - fragment_offset) { + i++; + } + n += left; + fragment_offset = 0; + } + + buffer->offset += n; + buffer->current_fragment = i; + return (zip_int64_t)n; +} + + +static int +buffer_seek(buffer_t *buffer, void *data, zip_uint64_t len, zip_error_t *error) { + zip_int64_t new_offset = zip_source_seek_compute_offset(buffer->offset, buffer->size, data, len, error); + + if (new_offset < 0) { + return -1; + } + + buffer->offset = (zip_uint64_t)new_offset; + buffer->current_fragment = buffer_find_fragment(buffer, buffer->offset); + return 0; +} + + +static zip_int64_t +buffer_write(buffer_t *buffer, const zip_uint8_t *data, zip_uint64_t length, zip_error_t *error) { + zip_uint64_t copied, i, fragment_offset, capacity; + + if (buffer->offset + length + WRITE_FRAGMENT_SIZE - 1 < length) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return -1; + } + + /* grow buffer if needed */ + capacity = buffer_capacity(buffer); + if (buffer->offset + length > capacity) { + zip_uint64_t needed_fragments = buffer->nfragments + (length - (capacity - buffer->offset) + WRITE_FRAGMENT_SIZE - 1) / WRITE_FRAGMENT_SIZE; + + if (needed_fragments > buffer->fragments_capacity) { + zip_uint64_t new_capacity = buffer->fragments_capacity; + + if (new_capacity == 0) { + new_capacity = 16; + } + while (new_capacity < needed_fragments) { + new_capacity *= 2; + } + + if (!buffer_grow_fragments(buffer, new_capacity, error)) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return -1; + } + } + + while (buffer->nfragments < needed_fragments) { + if ((buffer->fragments[buffer->nfragments].data = malloc(WRITE_FRAGMENT_SIZE)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return -1; + } + buffer->fragments[buffer->nfragments].length = WRITE_FRAGMENT_SIZE; + buffer->nfragments++; + capacity += WRITE_FRAGMENT_SIZE; + buffer->fragment_offsets[buffer->nfragments] = capacity; + } + } + + i = buffer->current_fragment; + fragment_offset = buffer->offset - buffer->fragment_offsets[i]; + copied = 0; + while (copied < length) { + zip_uint64_t n = ZIP_MIN(ZIP_MIN(length - copied, buffer->fragments[i].length - fragment_offset), SIZE_MAX); +#if ZIP_UINT64_MAX > SIZE_MAX + n = ZIP_MIN(n, SIZE_MAX); +#endif + + (void)memcpy_s(buffer->fragments[i].data + fragment_offset, (size_t)n, data + copied, (size_t)n); + + if (n == buffer->fragments[i].length - fragment_offset) { + i++; + fragment_offset = 0; + } + else { + fragment_offset += n; + } + copied += n; + } + + buffer->offset += copied; + buffer->current_fragment = i; + if (buffer->offset > buffer->size) { + buffer->size = buffer->offset; + } + + return (zip_int64_t)copied; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_call.c b/thirdparty/libzip-1.11.3/lib/zip_source_call.c new file mode 100644 index 0000000..bc13c3b --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_call.c @@ -0,0 +1,68 @@ +/* + zip_source_call.c -- invoke callback command on zip_source + Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "zipint.h" + + +zip_int64_t +_zip_source_call(zip_source_t *src, void *data, zip_uint64_t length, zip_source_cmd_t command) { + zip_int64_t ret; + + if ((src->supports & ZIP_SOURCE_MAKE_COMMAND_BITMASK(command)) == 0) { + zip_error_set(&src->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + } + + if (src->src == NULL) { + ret = src->cb.f(src->ud, data, length, command); + } + else { + ret = src->cb.l(src->src, src->ud, data, length, command); + } + + if (ret < 0) { + if (command != ZIP_SOURCE_ERROR && command != ZIP_SOURCE_SUPPORTS) { + int e[2]; + + if (_zip_source_call(src, e, sizeof(e), ZIP_SOURCE_ERROR) < 0) { + zip_error_set(&src->error, ZIP_ER_INTERNAL, 0); + } + else { + zip_error_set(&src->error, e[0], e[1]); + } + } + } + + return ret; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_close.c b/thirdparty/libzip-1.11.3/lib/zip_source_close.c new file mode 100644 index 0000000..f1ae6f3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_close.c @@ -0,0 +1,57 @@ +/* + zip_source_close.c -- close zip_source (stop reading) + Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +int +zip_source_close(zip_source_t *src) { + if (!ZIP_SOURCE_IS_OPEN_READING(src)) { + zip_error_set(&src->error, ZIP_ER_INVAL, 0); + return -1; + } + + src->open_count--; + if (src->open_count == 0) { + _zip_source_call(src, NULL, 0, ZIP_SOURCE_CLOSE); + + if (ZIP_SOURCE_IS_LAYERED(src)) { + if (zip_source_close(src->src) < 0) { + zip_error_set(&src->error, ZIP_ER_INTERNAL, 0); + } + } + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_commit_write.c b/thirdparty/libzip-1.11.3/lib/zip_source_commit_write.c new file mode 100644 index 0000000..ca7563c --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_commit_write.c @@ -0,0 +1,68 @@ +/* + zip_source_commit_write.c -- commit changes to file + Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_source_commit_write(zip_source_t *src) { + if (ZIP_SOURCE_IS_LAYERED(src)) { + zip_error_set(&src->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + } + + if (!ZIP_SOURCE_IS_OPEN_WRITING(src)) { + zip_error_set(&src->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (src->open_count > 1) { + zip_error_set(&src->error, ZIP_ER_INUSE, 0); + return -1; + } + else if (ZIP_SOURCE_IS_OPEN_READING(src)) { + if (zip_source_close(src) < 0) { + return -1; + } + } + + if (_zip_source_call(src, NULL, 0, ZIP_SOURCE_COMMIT_WRITE) < 0) { + src->write_state = ZIP_SOURCE_WRITE_FAILED; + return -1; + } + + src->write_state = ZIP_SOURCE_WRITE_CLOSED; + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_compress.c b/thirdparty/libzip-1.11.3/lib/zip_source_compress.c new file mode 100644 index 0000000..3330796 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_compress.c @@ -0,0 +1,411 @@ +/* + zip_source_compress.c -- (de)compression routines + Copyright (C) 2017-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include + +#include "zipint.h" + +struct context { + zip_error_t error; + + bool end_of_input; + bool end_of_stream; + bool can_store; + bool is_stored; /* only valid if end_of_stream is true */ + bool compress; + bool check_consistency; + zip_int32_t method; + + zip_uint64_t size; + zip_int64_t first_read; + zip_uint8_t buffer[BUFSIZE]; + + zip_compression_algorithm_t *algorithm; + void *ud; +}; + + +struct implementation { + zip_uint16_t method; + zip_compression_algorithm_t *compress; + zip_compression_algorithm_t *decompress; +}; + +static struct implementation implementations[] = { + {ZIP_CM_DEFLATE, &zip_algorithm_deflate_compress, &zip_algorithm_deflate_decompress}, +#if defined(HAVE_LIBBZ2) + {ZIP_CM_BZIP2, &zip_algorithm_bzip2_compress, &zip_algorithm_bzip2_decompress}, +#endif +#if defined(HAVE_LIBLZMA) + {ZIP_CM_LZMA, &zip_algorithm_xz_compress, &zip_algorithm_xz_decompress}, + /* Disabled - because 7z isn't able to unpack ZIP+LZMA2 + archives made this way - and vice versa. + + {ZIP_CM_LZMA2, &zip_algorithm_xz_compress, &zip_algorithm_xz_decompress}, + */ + {ZIP_CM_XZ, &zip_algorithm_xz_compress, &zip_algorithm_xz_decompress}, +#endif +#if defined(HAVE_LIBZSTD) + {ZIP_CM_ZSTD, &zip_algorithm_zstd_compress, &zip_algorithm_zstd_decompress}, +#endif + +}; + +static size_t implementations_size = sizeof(implementations) / sizeof(implementations[0]); + +static zip_source_t *compression_source_new(zip_t *za, zip_source_t *src, zip_int32_t method, bool compress, zip_uint32_t compression_flags); +static zip_int64_t compress_callback(zip_source_t *, void *, void *, zip_uint64_t, zip_source_cmd_t); +static void context_free(struct context *ctx); +static struct context *context_new(zip_int32_t method, bool compress, zip_uint32_t compression_flags, zip_compression_algorithm_t *algorithm, bool check_consistency); +static zip_int64_t compress_read(zip_source_t *, struct context *, void *, zip_uint64_t); + +zip_compression_algorithm_t *_zip_get_compression_algorithm(zip_int32_t method, bool compress) { + size_t i; + zip_uint16_t real_method = ZIP_CM_ACTUAL(method); + + for (i = 0; i < implementations_size; i++) { + if (implementations[i].method == real_method) { + if (compress) { + return implementations[i].compress; + } + else { + return implementations[i].decompress; + } + } + } + + return NULL; +} + +ZIP_EXTERN int zip_compression_method_supported(zip_int32_t method, int compress) { + if (method == ZIP_CM_STORE) { + return 1; + } + return _zip_get_compression_algorithm(method, compress) != NULL; +} + +zip_source_t *zip_source_compress(zip_t *za, zip_source_t *src, zip_int32_t method, zip_uint32_t compression_flags) { + return compression_source_new(za, src, method, true, compression_flags); +} + +zip_source_t * +zip_source_decompress(zip_t *za, zip_source_t *src, zip_int32_t method) { + return compression_source_new(za, src, method, false, 0); +} + + +static zip_source_t *compression_source_new(zip_t *za, zip_source_t *src, zip_int32_t method, bool compress, zip_uint32_t compression_flags) { + struct context *ctx; + zip_source_t *s2; + zip_compression_algorithm_t *algorithm = NULL; + + if (src == NULL) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((algorithm = _zip_get_compression_algorithm(method, compress)) == NULL) { + zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0); + return NULL; + } + + if ((ctx = context_new(method, compress, compression_flags, algorithm, za->open_flags & ZIP_CHECKCONS)) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if ((s2 = zip_source_layered(za, src, compress_callback, ctx)) == NULL) { + context_free(ctx); + return NULL; + } + + return s2; +} + + +static struct context *context_new(zip_int32_t method, bool compress, zip_uint32_t compression_flags, zip_compression_algorithm_t *algorithm, bool check_consistency) { + struct context *ctx; + + if ((ctx = (struct context *)malloc(sizeof(*ctx))) == NULL) { + return NULL; + } + zip_error_init(&ctx->error); + ctx->can_store = compress ? ZIP_CM_IS_DEFAULT(method) : false; + ctx->algorithm = algorithm; + ctx->method = method; + ctx->compress = compress; + ctx->end_of_input = false; + ctx->end_of_stream = false; + ctx->is_stored = false; + ctx->check_consistency = check_consistency; + + if ((ctx->ud = ctx->algorithm->allocate(ZIP_CM_ACTUAL(method), compression_flags, &ctx->error)) == NULL) { + zip_error_fini(&ctx->error); + free(ctx); + return NULL; + } + + return ctx; +} + + +static void +context_free(struct context *ctx) { + if (ctx == NULL) { + return; + } + + ctx->algorithm->deallocate(ctx->ud); + zip_error_fini(&ctx->error); + + free(ctx); +} + + +static zip_int64_t +compress_read(zip_source_t *src, struct context *ctx, void *data, zip_uint64_t len) { + zip_compression_status_t ret; + bool end; + zip_int64_t n; + zip_uint64_t out_offset; + zip_uint64_t out_len; + + if (zip_error_code_zip(&ctx->error) != ZIP_ER_OK) { + return -1; + } + + if (len == 0 || ctx->end_of_stream) { + return 0; + } + + out_offset = 0; + + end = false; + while (!end && out_offset < len) { + out_len = len - out_offset; + ret = ctx->algorithm->process(ctx->ud, (zip_uint8_t *)data + out_offset, &out_len); + + if (ret != ZIP_COMPRESSION_ERROR) { + out_offset += out_len; + } + + switch (ret) { + case ZIP_COMPRESSION_END: + ctx->end_of_stream = true; + + if (!ctx->end_of_input) { + n = zip_source_read(src, ctx->buffer, 1); + if (n < 0) { + zip_error_set_from_source(&ctx->error, src); + end = true; + break; + } + else if (n == 0) { + ctx->end_of_input = true; + n = ctx->algorithm->end_of_input(ctx->ud) ? 1 : 0; + } + + if (n > 0 && ctx->check_consistency) { + /* garbage after stream, or compression ended before all data read */ + zip_error_set(&ctx->error, ZIP_ER_INCONS, ZIP_ER_DETAIL_COMPRESSED_DATA_TRAILING_GARBAGE); + end = true; + break; + } + } + + if (ctx->first_read < 0) { + /* we got end of processed stream before reading any input data */ + zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); + end = true; + break; + } + if (ctx->can_store && (zip_uint64_t)ctx->first_read <= out_offset) { + ctx->is_stored = true; + ctx->size = (zip_uint64_t)ctx->first_read; + (void)memcpy_s(data, ctx->size, ctx->buffer, ctx->size); + return (zip_int64_t)ctx->size; + } + end = true; + break; + + case ZIP_COMPRESSION_OK: + break; + + case ZIP_COMPRESSION_NEED_DATA: + if (ctx->end_of_input) { + /* TODO: error: stream not ended, but no more input */ + end = true; + break; + } + + if ((n = zip_source_read(src, ctx->buffer, sizeof(ctx->buffer))) < 0) { + zip_error_set_from_source(&ctx->error, src); + end = true; + break; + } + else if (n == 0) { + ctx->end_of_input = true; + ctx->algorithm->end_of_input(ctx->ud); + if (ctx->first_read < 0) { + ctx->first_read = 0; + } + } + else { + if (ctx->first_read >= 0) { + /* we overwrote a previously filled ctx->buffer */ + ctx->can_store = false; + } + else { + ctx->first_read = n; + } + + ctx->algorithm->input(ctx->ud, ctx->buffer, (zip_uint64_t)n); + } + break; + + case ZIP_COMPRESSION_ERROR: + /* error set by algorithm */ + if (zip_error_code_zip(&ctx->error) == ZIP_ER_OK) { + zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); + } + end = true; + break; + } + } + + if (out_offset > 0) { + ctx->can_store = false; + ctx->size += out_offset; + return (zip_int64_t)out_offset; + } + + return (zip_error_code_zip(&ctx->error) == ZIP_ER_OK) ? 0 : -1; +} + + +static zip_int64_t +compress_callback(zip_source_t *src, void *ud, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { + struct context *ctx; + + ctx = (struct context *)ud; + + switch (cmd) { + case ZIP_SOURCE_OPEN: { + zip_stat_t st; + zip_file_attributes_t attributes; + + ctx->size = 0; + ctx->end_of_input = false; + ctx->end_of_stream = false; + ctx->is_stored = false; + ctx->first_read = -1; + + if (zip_source_stat(src, &st) < 0 || zip_source_get_file_attributes(src, &attributes) < 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + + if (!ctx->algorithm->start(ctx->ud, &st, &attributes)) { + return -1; + } + + return 0; + } + + case ZIP_SOURCE_READ: + return compress_read(src, ctx, data, len); + + case ZIP_SOURCE_CLOSE: + if (!ctx->algorithm->end(ctx->ud)) { + return -1; + } + return 0; + + case ZIP_SOURCE_STAT: { + zip_stat_t *st; + + st = (zip_stat_t *)data; + + if (ctx->compress) { + if (ctx->end_of_stream) { + st->comp_method = ctx->is_stored ? ZIP_CM_STORE : ZIP_CM_ACTUAL(ctx->method); + st->comp_size = ctx->size; + st->valid |= ZIP_STAT_COMP_SIZE | ZIP_STAT_COMP_METHOD; + } + else { + st->valid &= ~(ZIP_STAT_COMP_SIZE | ZIP_STAT_COMP_METHOD); + } + } + else { + st->comp_method = ZIP_CM_STORE; + st->valid |= ZIP_STAT_COMP_METHOD; + st->valid &= ~ZIP_STAT_COMP_SIZE; + if (ctx->end_of_stream) { + st->size = ctx->size; + st->valid |= ZIP_STAT_SIZE; + } + } + } + return 0; + + case ZIP_SOURCE_ERROR: + return zip_error_to_data(&ctx->error, data, len); + + case ZIP_SOURCE_FREE: + context_free(ctx); + return 0; + + case ZIP_SOURCE_GET_FILE_ATTRIBUTES: { + zip_file_attributes_t *attributes = (zip_file_attributes_t *)data; + + if (len < sizeof(*attributes)) { + zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); + return -1; + } + + attributes->valid |= ZIP_FILE_ATTRIBUTES_VERSION_NEEDED | ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS; + attributes->version_needed = ctx->algorithm->version_needed; + attributes->general_purpose_bit_mask = ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS_ALLOWED_MASK; + attributes->general_purpose_bit_flags = (ctx->is_stored ? 0 : ctx->algorithm->general_purpose_bit_flags(ctx->ud)); + + return sizeof(*attributes); + } + + case ZIP_SOURCE_SUPPORTS: + return ZIP_SOURCE_SUPPORTS_READABLE | zip_source_make_command_bitmap(ZIP_SOURCE_GET_FILE_ATTRIBUTES, ZIP_SOURCE_SUPPORTS_REOPEN, -1); + + default: + return zip_source_pass_to_lower_layer(src, data, len, cmd); + } +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_crc.c b/thirdparty/libzip-1.11.3/lib/zip_source_crc.c new file mode 100644 index 0000000..931a729 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_crc.c @@ -0,0 +1,203 @@ +/* + zip_source_crc.c -- pass-through source that calculates CRC32 and size + Copyright (C) 2009-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include +#include + +#include "zipint.h" + +struct crc_context { + int validate; /* whether to check CRC on EOF and return error on mismatch */ + int crc_complete; /* whether CRC was computed for complete file */ + zip_error_t error; + zip_uint64_t size; + zip_uint64_t position; /* current reading position */ + zip_uint64_t crc_position; /* how far we've computed the CRC */ + zip_uint32_t crc; +}; + +static zip_int64_t crc_read(zip_source_t *, void *, void *, zip_uint64_t, zip_source_cmd_t); + + +zip_source_t * +zip_source_crc_create(zip_source_t *src, int validate, zip_error_t *error) { + struct crc_context *ctx; + + if (src == NULL) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((ctx = (struct crc_context *)malloc(sizeof(*ctx))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + zip_error_init(&ctx->error); + ctx->validate = validate; + ctx->crc_complete = 0; + ctx->crc_position = 0; + ctx->crc = (zip_uint32_t)crc32(0, NULL, 0); + ctx->size = 0; + + return zip_source_layered_create(src, crc_read, ctx, error); +} + + +static zip_int64_t +crc_read(zip_source_t *src, void *_ctx, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { + struct crc_context *ctx; + zip_int64_t n; + + ctx = (struct crc_context *)_ctx; + + switch (cmd) { + case ZIP_SOURCE_OPEN: + ctx->position = 0; + return 0; + + case ZIP_SOURCE_READ: + if ((n = zip_source_read(src, data, len)) < 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + + if (n == 0) { + if (ctx->crc_position == ctx->position) { + ctx->crc_complete = 1; + ctx->size = ctx->position; + + if (ctx->validate) { + struct zip_stat st; + + if (zip_source_stat(src, &st) < 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + + if ((st.valid & ZIP_STAT_CRC) && st.crc != ctx->crc) { + zip_error_set(&ctx->error, ZIP_ER_CRC, 0); + return -1; + } + if ((st.valid & ZIP_STAT_SIZE) && st.size != ctx->size) { + /* We don't have the index here, but the caller should know which file they are reading from. */ + zip_error_set(&ctx->error, ZIP_ER_INCONS, MAKE_DETAIL_WITH_INDEX(ZIP_ER_DETAIL_INVALID_FILE_LENGTH, MAX_DETAIL_INDEX)); + return -1; + } + } + } + } + else if (!ctx->crc_complete && ctx->position <= ctx->crc_position) { + zip_uint64_t i, nn; + + for (i = ctx->crc_position - ctx->position; i < (zip_uint64_t)n; i += nn) { + nn = ZIP_MIN(UINT_MAX, (zip_uint64_t)n - i); + + ctx->crc = (zip_uint32_t)crc32(ctx->crc, (const Bytef *)data + i, (uInt)nn); + ctx->crc_position += nn; + } + } + ctx->position += (zip_uint64_t)n; + return n; + + case ZIP_SOURCE_CLOSE: + return 0; + + case ZIP_SOURCE_STAT: { + zip_stat_t *st; + + st = (zip_stat_t *)data; + + if (ctx->crc_complete) { + if ((st->valid & ZIP_STAT_SIZE) && st->size != ctx->size) { + zip_error_set(&ctx->error, ZIP_ER_DATA_LENGTH, 0); + return -1; + } + /* TODO: Set comp_size, comp_method, encryption_method? + After all, this only works for uncompressed data. */ + st->size = ctx->size; + st->crc = ctx->crc; + st->comp_size = ctx->size; + st->comp_method = ZIP_CM_STORE; + st->encryption_method = ZIP_EM_NONE; + st->valid |= ZIP_STAT_SIZE | ZIP_STAT_CRC | ZIP_STAT_COMP_SIZE | ZIP_STAT_COMP_METHOD | ZIP_STAT_ENCRYPTION_METHOD; + } + return 0; + } + + case ZIP_SOURCE_ERROR: + return zip_error_to_data(&ctx->error, data, len); + + case ZIP_SOURCE_FREE: + free(ctx); + return 0; + + case ZIP_SOURCE_SUPPORTS: { + zip_int64_t mask = zip_source_supports(src); + + if (mask < 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + + mask &= ~zip_source_make_command_bitmap(ZIP_SOURCE_BEGIN_WRITE, ZIP_SOURCE_COMMIT_WRITE, ZIP_SOURCE_ROLLBACK_WRITE, ZIP_SOURCE_SEEK_WRITE, ZIP_SOURCE_TELL_WRITE, ZIP_SOURCE_REMOVE, ZIP_SOURCE_GET_FILE_ATTRIBUTES, -1); + mask |= zip_source_make_command_bitmap(ZIP_SOURCE_FREE, -1); + return mask; + } + + case ZIP_SOURCE_SEEK: { + zip_int64_t new_position; + zip_source_args_seek_t *args = ZIP_SOURCE_GET_ARGS(zip_source_args_seek_t, data, len, &ctx->error); + + if (args == NULL) { + return -1; + } + if (zip_source_seek(src, args->offset, args->whence) < 0 || (new_position = zip_source_tell(src)) < 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + + ctx->position = (zip_uint64_t)new_position; + + return 0; + } + + case ZIP_SOURCE_TELL: + return (zip_int64_t)ctx->position; + + default: + return zip_source_pass_to_lower_layer(src, data, len, cmd); + } +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_error.c b/thirdparty/libzip-1.11.3/lib/zip_source_error.c new file mode 100644 index 0000000..774eec0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_error.c @@ -0,0 +1,46 @@ +/* + zip_source_error.c -- get last error from zip_source + Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +zip_error_t * +zip_source_error(zip_source_t *src) { + return &src->error; +} + +bool +_zip_source_had_error(zip_source_t *src) { + return zip_source_error(src)->zip_err != ZIP_ER_OK; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_file.h b/thirdparty/libzip-1.11.3/lib/zip_source_file.h new file mode 100644 index 0000000..de07aec --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_file.h @@ -0,0 +1,95 @@ +#ifndef _HAD_ZIP_SOURCE_FILE_H +#define _HAD_ZIP_SOURCE_FILE_H + +/* + zip_source_file.h -- header for common file operations + Copyright (C) 2020-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +struct zip_source_file_stat { + zip_uint64_t size; /* must be valid for regular files */ + time_t mtime; /* must always be valid, is initialized to current time */ + bool exists; /* must always be valid */ + bool regular_file; /* must always be valid */ +}; + +typedef struct zip_source_file_context zip_source_file_context_t; +typedef struct zip_source_file_operations zip_source_file_operations_t; +typedef struct zip_source_file_stat zip_source_file_stat_t; + +struct zip_source_file_context { + zip_error_t error; /* last error information */ + zip_int64_t supports; + + /* reading */ + char *fname; /* name of file to read from */ + void *f; /* file to read from */ + zip_stat_t st; /* stat information passed in */ + zip_file_attributes_t attributes; /* additional file attributes */ + zip_error_t stat_error; /* error returned for stat */ + zip_uint64_t start; /* start offset of data to read */ + zip_uint64_t len; /* length of the file, 0 for up to EOF */ + zip_uint64_t offset; /* current offset relative to start (0 is beginning of part we read) */ + + /* writing */ + char *tmpname; + void *fout; + + zip_source_file_operations_t *ops; + void *ops_userdata; +}; + + +/* The following methods must be implemented to support each feature: + - close, read, seek, and stat must always be implemented. + - To support specifying the file by name, open, and strdup must be implemented. + - For write support, the file must be specified by name and close, commit_write, create_temp_output, remove, rollback_write, and tell must be implemented. + - create_temp_output_cloning is always optional. */ + +struct zip_source_file_operations { + void (*close)(zip_source_file_context_t *ctx); + zip_int64_t (*commit_write)(zip_source_file_context_t *ctx); + zip_int64_t (*create_temp_output)(zip_source_file_context_t *ctx); + zip_int64_t (*create_temp_output_cloning)(zip_source_file_context_t *ctx, zip_uint64_t len); + bool (*open)(zip_source_file_context_t *ctx); + zip_int64_t (*read)(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len); + zip_int64_t (*remove)(zip_source_file_context_t *ctx); + void (*rollback_write)(zip_source_file_context_t *ctx); + bool (*seek)(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence); + bool (*stat)(zip_source_file_context_t *ctx, zip_source_file_stat_t *st); + char *(*string_duplicate)(zip_source_file_context_t *ctx, const char *); + zip_int64_t (*tell)(zip_source_file_context_t *ctx, void *f); + zip_int64_t (*write)(zip_source_file_context_t *ctx, const void *data, zip_uint64_t len); +}; + +zip_source_t *zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zip_int64_t len, const zip_stat_t *st, zip_source_file_operations_t *ops, void *ops_userdata, zip_error_t *error); + +#endif /* _HAD_ZIP_SOURCE_FILE_H */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_file_common.c b/thirdparty/libzip-1.11.3/lib/zip_source_file_common.c new file mode 100644 index 0000000..99f893e --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_file_common.c @@ -0,0 +1,388 @@ +/* + zip_source_file_common.c -- create data source from file + Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include + +#include "zipint.h" + +#include "zip_source_file.h" + +static zip_int64_t read_file(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd); + +static void +zip_source_file_stat_init(zip_source_file_stat_t *st) { + st->size = 0; + st->mtime = time(NULL); + st->exists = false; + st->regular_file = false; +} + +zip_source_t * +zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zip_int64_t len, const zip_stat_t *st, zip_source_file_operations_t *ops, void *ops_userdata, zip_error_t *error) { + zip_source_file_context_t *ctx; + zip_source_t *zs; + zip_source_file_stat_t sb; + zip_uint64_t length; + + if (ops == NULL) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + if (ops->close == NULL || ops->read == NULL || ops->seek == NULL || ops->stat == NULL) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + return NULL; + } + + if (ops->write != NULL && (ops->commit_write == NULL || ops->create_temp_output == NULL || ops->remove == NULL || ops->rollback_write == NULL || ops->tell == NULL)) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + return NULL; + } + + if (fname != NULL) { + if (ops->open == NULL || ops->string_duplicate == NULL) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + return NULL; + } + } + else if (file == NULL) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + if (len < 0) { + if (len == -1) { + len = ZIP_LENGTH_TO_END; + } + // TODO: return ZIP_ER_INVAL if len != ZIP_LENGTH_UNCHECKED? + length = 0; + } + else { + length = (zip_uint64_t)len; + } + + if (start > ZIP_INT64_MAX || start + length < start) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((ctx = (zip_source_file_context_t *)malloc(sizeof(zip_source_file_context_t))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + ctx->ops = ops; + ctx->ops_userdata = ops_userdata; + ctx->fname = NULL; + if (fname) { + if ((ctx->fname = ops->string_duplicate(ctx, fname)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + free(ctx); + return NULL; + } + } + ctx->f = file; + ctx->start = start; + ctx->len = length; + if (st) { + (void)memcpy_s(&ctx->st, sizeof(ctx->st), st, sizeof(*st)); + ctx->st.name = NULL; + ctx->st.valid &= ~ZIP_STAT_NAME; + } + else { + zip_stat_init(&ctx->st); + } + + if (ctx->len > 0) { + ctx->st.size = ctx->len; + ctx->st.valid |= ZIP_STAT_SIZE; + } + + zip_error_init(&ctx->stat_error); + + ctx->tmpname = NULL; + ctx->fout = NULL; + + zip_error_init(&ctx->error); + zip_file_attributes_init(&ctx->attributes); + + ctx->supports = ZIP_SOURCE_SUPPORTS_READABLE | zip_source_make_command_bitmap(ZIP_SOURCE_SUPPORTS, ZIP_SOURCE_TELL, ZIP_SOURCE_SUPPORTS_REOPEN, -1); + + zip_source_file_stat_init(&sb); + if (!ops->stat(ctx, &sb)) { + _zip_error_copy(error, &ctx->error); + free(ctx->fname); + free(ctx); + return NULL; + } + + if (!sb.exists) { + if (ctx->fname && ctx->start == 0 && ctx->len == 0 && ops->write != NULL) { + ctx->supports = ZIP_SOURCE_SUPPORTS_WRITABLE; + /* zip_open_from_source checks for this to detect non-existing files */ + zip_error_set(&ctx->stat_error, ZIP_ER_READ, ENOENT); + } + else { + zip_error_set(&ctx->stat_error, ZIP_ER_READ, ENOENT); + free(ctx->fname); + free(ctx); + return NULL; + } + } + else { + if ((ctx->st.valid & ZIP_STAT_MTIME) == 0) { + ctx->st.mtime = sb.mtime; + ctx->st.valid |= ZIP_STAT_MTIME; + } + if (sb.regular_file) { + ctx->supports = ZIP_SOURCE_SUPPORTS_SEEKABLE; + + if (ctx->start + ctx->len > sb.size) { + zip_error_set(error, ZIP_ER_INVAL, 0); + free(ctx->fname); + free(ctx); + return NULL; + } + + if (ctx->len == 0) { + if (len != ZIP_LENGTH_UNCHECKED) { + ctx->len = sb.size - ctx->start; + ctx->st.size = ctx->len; + ctx->st.valid |= ZIP_STAT_SIZE; + } + + /* when using a partial file, don't allow writing */ + if (ctx->fname && start == 0 && ops->write != NULL) { + ctx->supports = ZIP_SOURCE_SUPPORTS_WRITABLE; + } + } + } + + ctx->supports |= ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_GET_FILE_ATTRIBUTES); + } + + ctx->supports |= ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ACCEPT_EMPTY); + if (ops->create_temp_output_cloning != NULL) { + if (ctx->supports & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_BEGIN_WRITE)) { + ctx->supports |= ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_BEGIN_WRITE_CLONING); + } + } + + if ((zs = zip_source_function_create(read_file, ctx, error)) == NULL) { + free(ctx->fname); + free(ctx); + return NULL; + } + + return zs; +} + + +static zip_int64_t +read_file(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { + zip_source_file_context_t *ctx; + char *buf; + + ctx = (zip_source_file_context_t *)state; + buf = (char *)data; + + switch (cmd) { + case ZIP_SOURCE_ACCEPT_EMPTY: + return 0; + + case ZIP_SOURCE_BEGIN_WRITE: + /* write support should not be set if fname is NULL */ + if (ctx->fname == NULL) { + zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); + return -1; + } + return ctx->ops->create_temp_output(ctx); + + case ZIP_SOURCE_BEGIN_WRITE_CLONING: + /* write support should not be set if fname is NULL */ + if (ctx->fname == NULL) { + zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); + return -1; + } + return ctx->ops->create_temp_output_cloning(ctx, len); + + case ZIP_SOURCE_CLOSE: + if (ctx->fname) { + ctx->ops->close(ctx); + ctx->f = NULL; + } + return 0; + + case ZIP_SOURCE_COMMIT_WRITE: { + zip_int64_t ret = ctx->ops->commit_write(ctx); + ctx->fout = NULL; + if (ret == 0) { + free(ctx->tmpname); + ctx->tmpname = NULL; + } + return ret; + } + + case ZIP_SOURCE_ERROR: + return zip_error_to_data(&ctx->error, data, len); + + case ZIP_SOURCE_FREE: + free(ctx->fname); + free(ctx->tmpname); + if (ctx->f) { + ctx->ops->close(ctx); + } + free(ctx); + return 0; + + case ZIP_SOURCE_GET_FILE_ATTRIBUTES: + if (len < sizeof(ctx->attributes)) { + zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); + return -1; + } + (void)memcpy_s(data, sizeof(ctx->attributes), &ctx->attributes, sizeof(ctx->attributes)); + return sizeof(ctx->attributes); + + case ZIP_SOURCE_OPEN: + if (ctx->fname) { + if (ctx->ops->open(ctx) == false) { + return -1; + } + } + + if (ctx->start > 0) { /* TODO: rewind on re-open */ + if (ctx->ops->seek(ctx, ctx->f, (zip_int64_t)ctx->start, SEEK_SET) == false) { + /* TODO: skip by reading */ + return -1; + } + } + ctx->offset = 0; + return 0; + + case ZIP_SOURCE_READ: { + zip_int64_t i; + zip_uint64_t n; + + if (ctx->len > 0) { + n = ZIP_MIN(ctx->len - ctx->offset, len); + } + else { + n = len; + } + + if ((i = ctx->ops->read(ctx, buf, n)) < 0) { + zip_error_set(&ctx->error, ZIP_ER_READ, errno); + return -1; + } + ctx->offset += (zip_uint64_t)i; + + return i; + } + + case ZIP_SOURCE_REMOVE: + return ctx->ops->remove(ctx); + + case ZIP_SOURCE_ROLLBACK_WRITE: + ctx->ops->rollback_write(ctx); + ctx->fout = NULL; + free(ctx->tmpname); + ctx->tmpname = NULL; + return 0; + + case ZIP_SOURCE_SEEK: { + zip_int64_t new_offset = zip_source_seek_compute_offset(ctx->offset, ctx->len, data, len, &ctx->error); + + if (new_offset < 0) { + return -1; + } + + /* The actual offset inside the file must be representable as zip_int64_t. */ + if (new_offset > ZIP_INT64_MAX - (zip_int64_t)ctx->start) { + zip_error_set(&ctx->error, ZIP_ER_SEEK, EOVERFLOW); + return -1; + } + + ctx->offset = (zip_uint64_t)new_offset; + + if (ctx->ops->seek(ctx, ctx->f, (zip_int64_t)(ctx->offset + ctx->start), SEEK_SET) == false) { + return -1; + } + return 0; + } + + case ZIP_SOURCE_SEEK_WRITE: { + zip_source_args_seek_t *args; + + args = ZIP_SOURCE_GET_ARGS(zip_source_args_seek_t, data, len, &ctx->error); + if (args == NULL) { + return -1; + } + + if (ctx->ops->seek(ctx, ctx->fout, args->offset, args->whence) == false) { + return -1; + } + return 0; + } + + case ZIP_SOURCE_STAT: { + if (len < sizeof(ctx->st)) + return -1; + + if (zip_error_code_zip(&ctx->stat_error) != 0) { + zip_error_set(&ctx->error, zip_error_code_zip(&ctx->stat_error), zip_error_code_system(&ctx->stat_error)); + return -1; + } + + (void)memcpy_s(data, sizeof(ctx->st), &ctx->st, sizeof(ctx->st)); + return sizeof(ctx->st); + } + + case ZIP_SOURCE_SUPPORTS: + return ctx->supports; + + case ZIP_SOURCE_TELL: + return (zip_int64_t)ctx->offset; + + case ZIP_SOURCE_TELL_WRITE: + return ctx->ops->tell(ctx, ctx->fout); + + case ZIP_SOURCE_WRITE: + return ctx->ops->write(ctx, data, len); + + default: + zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + } +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_file_stdio.c b/thirdparty/libzip-1.11.3/lib/zip_source_file_stdio.c new file mode 100644 index 0000000..6e98517 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_file_stdio.c @@ -0,0 +1,179 @@ +/* + zip_source_file_stdio.c -- read-only stdio file source implementation + Copyright (C) 2020-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +#include "zip_source_file.h" +#include "zip_source_file_stdio.h" + +#include +#include +#include + +#ifdef _WIN32 +#ifndef S_IWUSR +#define S_IWUSR _S_IWRITE +#endif +#endif + +/* clang-format off */ +static zip_source_file_operations_t ops_stdio_read = { + _zip_stdio_op_close, + NULL, + NULL, + NULL, + NULL, + _zip_stdio_op_read, + NULL, + NULL, + _zip_stdio_op_seek, + _zip_stdio_op_stat, + NULL, + _zip_stdio_op_tell, + NULL +}; +/* clang-format on */ + + +ZIP_EXTERN zip_source_t * +zip_source_filep(zip_t *za, FILE *file, zip_uint64_t start, zip_int64_t len) { + if (za == NULL) { + return NULL; + } + + return zip_source_filep_create(file, start, len, &za->error); +} + + +ZIP_EXTERN zip_source_t * +zip_source_filep_create(FILE *file, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { + if (file == NULL || length < ZIP_LENGTH_UNCHECKED) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + return zip_source_file_common_new(NULL, file, start, length, NULL, &ops_stdio_read, NULL, error); +} + + +void +_zip_stdio_op_close(zip_source_file_context_t *ctx) { + fclose((FILE *)ctx->f); +} + + +zip_int64_t +_zip_stdio_op_read(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len) { + size_t i; +#if SIZE_MAX < ZIP_UINT64_MAX + if (len > SIZE_MAX) { + len = SIZE_MAX; + } +#endif + + if ((i = fread(buf, 1, (size_t)len, ctx->f)) == 0) { + if (ferror((FILE *)ctx->f)) { + zip_error_set(&ctx->error, ZIP_ER_READ, errno); + return -1; + } + } + + return (zip_int64_t)i; +} + + +bool +_zip_stdio_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence) { +#if ZIP_FSEEK_MAX > ZIP_INT64_MAX + if (offset > ZIP_FSEEK_MAX || offset < ZIP_FSEEK_MIN) { + zip_error_set(&ctx->error, ZIP_ER_SEEK, EOVERFLOW); + return false; + } +#endif + + if (zip_os_fseek((FILE *)f, (zip_off_t)offset, whence) < 0) { + zip_error_set(&ctx->error, ZIP_ER_SEEK, errno); + return false; + } + return true; +} + + +bool +_zip_stdio_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st) { + zip_os_stat_t sb; + + int ret; + + if (ctx->fname) { + ret = zip_os_stat(ctx->fname, &sb); + } + else { + ret = zip_os_fstat(fileno((FILE *)ctx->f), &sb); + } + + if (ret < 0) { + if (errno == ENOENT) { + st->exists = false; + return true; + } + zip_error_set(&ctx->error, ZIP_ER_READ, errno); + return false; + } + + st->size = (zip_uint64_t)sb.st_size; + st->mtime = sb.st_mtime; + + st->regular_file = S_ISREG(sb.st_mode); + st->exists = true; + + /* We're using UNIX file API, even on Windows; thus, we supply external file attributes with Unix values. */ + /* TODO: This could be improved on Windows by providing Windows-specific file attributes */ + ctx->attributes.valid = ZIP_FILE_ATTRIBUTES_HOST_SYSTEM | ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES; + ctx->attributes.host_system = ZIP_OPSYS_UNIX; + ctx->attributes.external_file_attributes = (((zip_uint32_t)sb.st_mode) << 16) | ((sb.st_mode & S_IWUSR) ? 0 : 1); + + return true; +} + + +zip_int64_t +_zip_stdio_op_tell(zip_source_file_context_t *ctx, void *f) { + zip_off_t offset = zip_os_ftell((FILE *)f); + + if (offset < 0) { + zip_error_set(&ctx->error, ZIP_ER_SEEK, errno); + } + + return offset; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_file_stdio.h b/thirdparty/libzip-1.11.3/lib/zip_source_file_stdio.h new file mode 100644 index 0000000..417a28c --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_file_stdio.h @@ -0,0 +1,45 @@ +#ifndef _HAD_ZIP_SOURCE_FILE_STDIO_H +#define _HAD_ZIP_SOURCE_FILE_STDIO_H + +/* + zip_source_file_stdio.h -- common header for stdio file implementation + Copyright (C) 2020-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +void _zip_stdio_op_close(zip_source_file_context_t *ctx); +zip_int64_t _zip_stdio_op_read(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len); +bool _zip_stdio_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence); +bool _zip_stdio_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st); +zip_int64_t _zip_stdio_op_tell(zip_source_file_context_t *ctx, void *f); + +#endif /* _HAD_ZIP_SOURCE_FILE_STDIO_H */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_file_stdio_named.c b/thirdparty/libzip-1.11.3/lib/zip_source_file_stdio_named.c new file mode 100644 index 0000000..1a5ca22 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_file_stdio_named.c @@ -0,0 +1,392 @@ +/* + zip_source_file_stdio_named.c -- source for stdio file opened by name + Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +#include "zip_source_file.h" +#include "zip_source_file_stdio.h" + +#include +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +#ifdef HAVE_CLONEFILE +#include +#include +#define CAN_CLONE +#endif +#ifdef HAVE_FICLONERANGE +#include +#include +#define CAN_CLONE +#endif + +static int create_temp_file(zip_source_file_context_t *ctx, bool create_file); + +static zip_int64_t _zip_stdio_op_commit_write(zip_source_file_context_t *ctx); +static zip_int64_t _zip_stdio_op_create_temp_output(zip_source_file_context_t *ctx); +#ifdef CAN_CLONE +static zip_int64_t _zip_stdio_op_create_temp_output_cloning(zip_source_file_context_t *ctx, zip_uint64_t offset); +#endif +static bool _zip_stdio_op_open(zip_source_file_context_t *ctx); +static zip_int64_t _zip_stdio_op_remove(zip_source_file_context_t *ctx); +static void _zip_stdio_op_rollback_write(zip_source_file_context_t *ctx); +static char *_zip_stdio_op_strdup(zip_source_file_context_t *ctx, const char *string); +static zip_int64_t _zip_stdio_op_write(zip_source_file_context_t *ctx, const void *data, zip_uint64_t len); +static FILE *_zip_fopen_close_on_exec(const char *name, bool writeable); + +/* clang-format off */ +static zip_source_file_operations_t ops_stdio_named = { + _zip_stdio_op_close, + _zip_stdio_op_commit_write, + _zip_stdio_op_create_temp_output, +#ifdef CAN_CLONE + _zip_stdio_op_create_temp_output_cloning, +#else + NULL, +#endif + _zip_stdio_op_open, + _zip_stdio_op_read, + _zip_stdio_op_remove, + _zip_stdio_op_rollback_write, + _zip_stdio_op_seek, + _zip_stdio_op_stat, + _zip_stdio_op_strdup, + _zip_stdio_op_tell, + _zip_stdio_op_write +}; +/* clang-format on */ + +ZIP_EXTERN zip_source_t * +zip_source_file(zip_t *za, const char *fname, zip_uint64_t start, zip_int64_t len) { + if (za == NULL) + return NULL; + + return zip_source_file_create(fname, start, len, &za->error); +} + + +ZIP_EXTERN zip_source_t * +zip_source_file_create(const char *fname, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { + if (fname == NULL || length < ZIP_LENGTH_UNCHECKED) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + return zip_source_file_common_new(fname, NULL, start, length, NULL, &ops_stdio_named, NULL, error); +} + + +static zip_int64_t +_zip_stdio_op_commit_write(zip_source_file_context_t *ctx) { + if (fclose(ctx->fout) < 0) { + zip_error_set(&ctx->error, ZIP_ER_WRITE, errno); + return -1; + } + if (rename(ctx->tmpname, ctx->fname) < 0) { + zip_error_set(&ctx->error, ZIP_ER_RENAME, errno); + return -1; + } + + return 0; +} + + +static zip_int64_t +_zip_stdio_op_create_temp_output(zip_source_file_context_t *ctx) { + int fd = create_temp_file(ctx, true); + + if (fd < 0) { + return -1; + } + + if ((ctx->fout = fdopen(fd, "r+b")) == NULL) { + zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); + close(fd); + (void)remove(ctx->tmpname); + free(ctx->tmpname); + ctx->tmpname = NULL; + return -1; + } + + return 0; +} + +#ifdef CAN_CLONE +static zip_int64_t +_zip_stdio_op_create_temp_output_cloning(zip_source_file_context_t *ctx, zip_uint64_t offset) { + FILE *tfp; + + if (offset > ZIP_OFF_MAX) { + zip_error_set(&ctx->error, ZIP_ER_SEEK, E2BIG); + return -1; + } + +#ifdef HAVE_CLONEFILE + /* clonefile insists on creating the file, so just create a name */ + if (create_temp_file(ctx, false) < 0) { + return -1; + } + + if (clonefile(ctx->fname, ctx->tmpname, 0) < 0) { + zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); + free(ctx->tmpname); + ctx->tmpname = NULL; + return -1; + } + if ((tfp = _zip_fopen_close_on_exec(ctx->tmpname, true)) == NULL) { + zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); + (void)remove(ctx->tmpname); + free(ctx->tmpname); + ctx->tmpname = NULL; + return -1; + } +#else + { + int fd; + struct file_clone_range range; + zip_os_stat_t st; + + if (zip_os_fstat(fileno(ctx->f), &st) < 0) { + zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); + return -1; + } + + if ((fd = create_temp_file(ctx, true)) < 0) { + return -1; + } + + range.src_fd = fileno(ctx->f); + range.src_offset = 0; + range.src_length = ((offset + st.st_blksize - 1) / st.st_blksize) * st.st_blksize; + if (range.src_length > st.st_size) { + range.src_length = 0; + } + range.dest_offset = 0; + if (ioctl(fd, FICLONERANGE, &range) < 0) { + zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); + (void)close(fd); + (void)remove(ctx->tmpname); + free(ctx->tmpname); + ctx->tmpname = NULL; + return -1; + } + + if ((tfp = fdopen(fd, "r+b")) == NULL) { + zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); + (void)close(fd); + (void)remove(ctx->tmpname); + free(ctx->tmpname); + ctx->tmpname = NULL; + return -1; + } + } +#endif + + if (ftruncate(fileno(tfp), (off_t)offset) < 0) { + (void)fclose(tfp); + (void)remove(ctx->tmpname); + free(ctx->tmpname); + ctx->tmpname = NULL; + return -1; + } + if (zip_os_fseek(tfp, (zip_off_t)offset, SEEK_SET) < 0) { + zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); + (void)fclose(tfp); + (void)remove(ctx->tmpname); + free(ctx->tmpname); + ctx->tmpname = NULL; + return -1; + } + + ctx->fout = tfp; + + return 0; +} +#endif + +static bool +_zip_stdio_op_open(zip_source_file_context_t *ctx) { + if ((ctx->f = _zip_fopen_close_on_exec(ctx->fname, false)) == NULL) { + zip_error_set(&ctx->error, ZIP_ER_OPEN, errno); + return false; + } + return true; +} + + +static zip_int64_t +_zip_stdio_op_remove(zip_source_file_context_t *ctx) { + if (remove(ctx->fname) < 0) { + zip_error_set(&ctx->error, ZIP_ER_REMOVE, errno); + return -1; + } + return 0; +} + + +static void +_zip_stdio_op_rollback_write(zip_source_file_context_t *ctx) { + if (ctx->fout) { + fclose(ctx->fout); + } + (void)remove(ctx->tmpname); +} + +static char * +_zip_stdio_op_strdup(zip_source_file_context_t *ctx, const char *string) { + return strdup(string); +} + + +static zip_int64_t +_zip_stdio_op_write(zip_source_file_context_t *ctx, const void *data, zip_uint64_t len) { + size_t ret; + + clearerr((FILE *)ctx->fout); + ret = fwrite(data, 1, len, (FILE *)ctx->fout); + if (ret != len || ferror((FILE *)ctx->fout)) { + zip_error_set(&ctx->error, ZIP_ER_WRITE, errno); + return -1; + } + + return (zip_int64_t)ret; +} + + +static int create_temp_file(zip_source_file_context_t *ctx, bool create_file) { + char *temp; + int mode; + zip_os_stat_t st; + int fd = 0; + char *start, *end; + + if (zip_os_stat(ctx->fname, &st) == 0) { + mode = st.st_mode; + } + else { + mode = -1; + } + + size_t temp_size = strlen(ctx->fname) + 13; + if ((temp = (char *)malloc(temp_size)) == NULL) { + zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); + return -1; + } + snprintf_s(temp, temp_size, "%s.XXXXXX.part", ctx->fname); + end = temp + strlen(temp) - 5; + start = end - 6; + + for (;;) { + zip_uint32_t value = zip_random_uint32(); + char *xs = start; + + while (xs < end) { + char digit = value % 36; + if (digit < 10) { + *(xs++) = digit + '0'; + } + else { + *(xs++) = digit - 10 + 'a'; + } + value /= 36; + } + + if (create_file) { + if ((fd = open(temp, O_CREAT | O_EXCL | O_RDWR | O_CLOEXEC, mode == -1 ? 0666 : (mode_t)mode)) >= 0) { + if (mode != -1) { + /* open() honors umask(), which we don't want in this case */ +#ifdef HAVE_FCHMOD + (void)fchmod(fd, (mode_t)mode); +#else + (void)chmod(temp, (mode_t)mode); +#endif + } + break; + } + if (errno != EEXIST) { + zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); + free(temp); + return -1; + } + } + else { + if (zip_os_stat(temp, &st) < 0) { + if (errno == ENOENT) { + break; + } + else { + zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); + free(temp); + return -1; + } + } + } + } + + ctx->tmpname = temp; + + return fd; /* initialized to 0 if !create_file */ +} + + +/* + * fopen replacement that sets the close-on-exec flag + * some implementations support an fopen 'e' flag for that, + * but e.g. macOS doesn't. + */ +static FILE *_zip_fopen_close_on_exec(const char *name, bool writeable) { + int fd; + int flags; + FILE *fp; + + flags = O_CLOEXEC; + if (writeable) { + flags |= O_RDWR; + } + else { + flags |= O_RDONLY; + } + + /* mode argument needed on Windows */ + if ((fd = open(name, flags, 0666)) < 0) { + return NULL; + } + if ((fp = fdopen(fd, writeable ? "r+b" : "rb")) == NULL) { + return NULL; + } + return fp; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_file_win32.c b/thirdparty/libzip-1.11.3/lib/zip_source_file_win32.c new file mode 100644 index 0000000..aa66976 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_file_win32.c @@ -0,0 +1,234 @@ +/* + zip_source_file_win32.c -- read-only Windows file source implementation + Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zip_source_file_win32.h" + +static bool _zip_win32_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st); + +static bool _zip_stat_win32(zip_source_file_context_t *ctx, zip_source_file_stat_t *st, HANDLE h); + +/* clang-format off */ + +static zip_source_file_operations_t ops_win32_read = { + _zip_win32_op_close, + NULL, + NULL, + NULL, + NULL, + _zip_win32_op_read, + NULL, + NULL, + _zip_win32_op_seek, + _zip_win32_op_stat, + NULL, + _zip_win32_op_tell, + NULL +}; + +/* clang-format on */ + +ZIP_EXTERN zip_source_t * +zip_source_win32handle(zip_t *za, HANDLE h, zip_uint64_t start, zip_int64_t len) { + if (za == NULL) { + return NULL; + } + + return zip_source_win32handle_create(h, start, len, &za->error); +} + + +ZIP_EXTERN zip_source_t * +zip_source_win32handle_create(HANDLE h, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { + if (h == INVALID_HANDLE_VALUE || length < ZIP_LENGTH_UNCHECKED) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + return zip_source_file_common_new(NULL, h, start, length, NULL, &ops_win32_read, NULL, error); +} + + +void +_zip_win32_op_close(zip_source_file_context_t *ctx) { + CloseHandle((HANDLE)ctx->f); +} + + +zip_int64_t +_zip_win32_op_read(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len) { + DWORD i; + + /* TODO: cap len to "DWORD_MAX" */ + if (!ReadFile((HANDLE)ctx->f, buf, (DWORD)len, &i, NULL)) { + zip_error_set(&ctx->error, ZIP_ER_READ, _zip_win32_error_to_errno(GetLastError())); + return -1; + } + + return (zip_int64_t)i; +} + + +bool +_zip_win32_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence) { + LARGE_INTEGER li; + DWORD method; + + switch (whence) { + case SEEK_SET: + method = FILE_BEGIN; + break; + case SEEK_END: + method = FILE_END; + break; + case SEEK_CUR: + method = FILE_CURRENT; + break; + default: + zip_error_set(&ctx->error, ZIP_ER_SEEK, EINVAL); + return false; + } + + li.QuadPart = (LONGLONG)offset; + if (!SetFilePointerEx((HANDLE)f, li, NULL, method)) { + zip_error_set(&ctx->error, ZIP_ER_SEEK, _zip_win32_error_to_errno(GetLastError())); + return false; + } + + return true; +} + + +static bool +_zip_win32_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st) { + return _zip_stat_win32(ctx, st, (HANDLE)ctx->f); +} + + +zip_int64_t +_zip_win32_op_tell(zip_source_file_context_t *ctx, void *f) { + LARGE_INTEGER zero; + LARGE_INTEGER new_offset; + + zero.QuadPart = 0; + if (!SetFilePointerEx((HANDLE)f, zero, &new_offset, FILE_CURRENT)) { + zip_error_set(&ctx->error, ZIP_ER_SEEK, _zip_win32_error_to_errno(GetLastError())); + return -1; + } + + return (zip_int64_t)new_offset.QuadPart; +} + + +int +_zip_win32_error_to_errno(DWORD win32err) { + /* Note: This list isn't exhaustive, but should cover common cases. */ + switch (win32err) { + case ERROR_INVALID_PARAMETER: + return EINVAL; + case ERROR_FILE_NOT_FOUND: + case ERROR_PATH_NOT_FOUND: + return ENOENT; + case ERROR_INVALID_HANDLE: + return EBADF; + case ERROR_ACCESS_DENIED: + return EACCES; + case ERROR_FILE_EXISTS: + return EEXIST; + case ERROR_TOO_MANY_OPEN_FILES: + return EMFILE; + case ERROR_DISK_FULL: + return ENOSPC; + default: + return 10000 + win32err; + } +} + + +static bool +_zip_stat_win32(zip_source_file_context_t *ctx, zip_source_file_stat_t *st, HANDLE h) { + FILETIME mtimeft; + time_t mtime; + LARGE_INTEGER size; + + if (!GetFileTime(h, NULL, NULL, &mtimeft)) { + zip_error_set(&ctx->error, ZIP_ER_READ, _zip_win32_error_to_errno(GetLastError())); + return false; + } + if (!_zip_filetime_to_time_t(mtimeft, &mtime)) { + zip_error_set(&ctx->error, ZIP_ER_READ, ERANGE); + return false; + } + + st->exists = true; + st->mtime = mtime; + + if (GetFileType(h) == FILE_TYPE_DISK) { + st->regular_file = 1; + + if (!GetFileSizeEx(h, &size)) { + zip_error_set(&ctx->error, ZIP_ER_READ, _zip_win32_error_to_errno(GetLastError())); + return false; + } + + st->size = (zip_uint64_t)size.QuadPart; + } + + /* TODO: fill in ctx->attributes */ + + return true; +} + + +bool +_zip_filetime_to_time_t(FILETIME ft, time_t *t) { + /* + Inspired by http://stackoverflow.com/questions/6161776/convert-windows-filetime-to-second-in-unix-linux + */ + const zip_int64_t WINDOWS_TICK = 10000000LL; + const zip_int64_t SEC_TO_UNIX_EPOCH = 11644473600LL; + ULARGE_INTEGER li; + zip_int64_t secs; + time_t temp; + + li.LowPart = ft.dwLowDateTime; + li.HighPart = ft.dwHighDateTime; + secs = (li.QuadPart / WINDOWS_TICK - SEC_TO_UNIX_EPOCH); + + temp = (time_t)secs; + if (secs != (zip_int64_t)temp) { + return false; + } + + *t = temp; + return true; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_file_win32.h b/thirdparty/libzip-1.11.3/lib/zip_source_file_win32.h new file mode 100644 index 0000000..da691f0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_file_win32.h @@ -0,0 +1,77 @@ +#ifndef _HAD_ZIP_SOURCE_FILE_WIN32_H +#define _HAD_ZIP_SOURCE_FILE_WIN32_H + +/* + zip_source_file_win32.h -- common header for Windows file implementation + Copyright (C) 2020-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* 0x0501 => Windows XP; needs to be at least this value because of GetFileSizeEx */ +#if !defined(MS_UWP) && !defined(_WIN32_WINNT) +#define _WIN32_WINNT 0x0501 +#endif + +#include + +#include + +#include + +#include "zipint.h" + +#include "zip_source_file.h" + +struct zip_win32_file_operations { + char *(*allocate_tempname)(const char *name, size_t extra_chars, size_t *lengthp); + HANDLE(__stdcall *create_file)(const void *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file); + BOOL(__stdcall *delete_file)(const void *name); + DWORD(__stdcall *get_file_attributes)(const void *name); + BOOL(__stdcall *get_file_attributes_ex)(const void *name, GET_FILEEX_INFO_LEVELS info_level, void *information); + void (*make_tempname)(char *buf, size_t len, const char *name, zip_uint32_t i); + BOOL(__stdcall *move_file)(const void *from, const void *to, DWORD flags); + BOOL(__stdcall *set_file_attributes)(const void *name, DWORD attributes); + char *(*string_duplicate)(const char *string); + HANDLE(__stdcall *find_first_file)(const void *name, void *data); +}; + +typedef struct zip_win32_file_operations zip_win32_file_operations_t; + +extern zip_source_file_operations_t _zip_source_file_win32_named_ops; + +void _zip_win32_op_close(zip_source_file_context_t *ctx); +zip_int64_t _zip_win32_op_read(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len); +bool _zip_win32_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence); +zip_int64_t _zip_win32_op_tell(zip_source_file_context_t *ctx, void *f); + +bool _zip_filetime_to_time_t(FILETIME ft, time_t *t); +int _zip_win32_error_to_errno(DWORD win32err); + +#endif /* _HAD_ZIP_SOURCE_FILE_WIN32_H */ diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_file_win32_ansi.c b/thirdparty/libzip-1.11.3/lib/zip_source_file_win32_ansi.c new file mode 100644 index 0000000..f10f8ae --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_file_win32_ansi.c @@ -0,0 +1,132 @@ +/* + zip_source_file_win32_ansi.c -- source for Windows file opened by ANSI name + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zip_source_file_win32.h" + +static char *ansi_allocate_tempname(const char *name, size_t extra_chars, size_t *lengthp); +static HANDLE __stdcall ansi_create_file(const void *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file); +static BOOL __stdcall ansi_delete_file(const void *name); +static DWORD __stdcall ansi_get_file_attributes(const void *name); +static BOOL __stdcall ansi_get_file_attributes_ex(const void *name, GET_FILEEX_INFO_LEVELS info_level, void *information); +static void ansi_make_tempname(char *buf, size_t len, const char *name, zip_uint32_t i); +static BOOL __stdcall ansi_move_file(const void *from, const void *to, DWORD flags); +static BOOL __stdcall ansi_set_file_attributes(const void *name, DWORD attributes); +static HANDLE __stdcall ansi_find_first_file(const void *name, void* data); + +/* clang-format off */ +zip_win32_file_operations_t ops_ansi = { + ansi_allocate_tempname, + ansi_create_file, + ansi_delete_file, + ansi_get_file_attributes, + ansi_get_file_attributes_ex, + ansi_make_tempname, + ansi_move_file, + ansi_set_file_attributes, + strdup, + ansi_find_first_file, +}; +/* clang-format on */ + +ZIP_EXTERN zip_source_t * +zip_source_win32a(zip_t *za, const char *fname, zip_uint64_t start, zip_int64_t len) { + if (za == NULL) + return NULL; + + return zip_source_win32a_create(fname, start, len, &za->error); +} + + +ZIP_EXTERN zip_source_t * +zip_source_win32a_create(const char *fname, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { + if (fname == NULL || length < ZIP_LENGTH_UNCHECKED) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + return zip_source_file_common_new(fname, NULL, start, length, NULL, &_zip_source_file_win32_named_ops, &ops_ansi, error); +} + + +static char * +ansi_allocate_tempname(const char *name, size_t extra_chars, size_t *lengthp) { + *lengthp = strlen(name) + extra_chars; + return (char *)malloc(*lengthp); +} + +static HANDLE __stdcall +ansi_create_file(const void *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file) +{ + return CreateFileA((const char *)name, access, share_mode, security_attributes, creation_disposition, file_attributes, template_file); +} + +static BOOL __stdcall +ansi_delete_file(const void *name) +{ + return DeleteFileA((const char *)name); +} + +static DWORD __stdcall +ansi_get_file_attributes(const void *name) +{ + return GetFileAttributesA((const char *)name); +} + +static BOOL __stdcall +ansi_get_file_attributes_ex(const void *name, GET_FILEEX_INFO_LEVELS info_level, void *information) +{ + return GetFileAttributesExA((const char *)name, info_level, information); +} + +static void +ansi_make_tempname(char *buf, size_t len, const char *name, zip_uint32_t i) { + snprintf_s(buf, len, "%s.%08x", name, i); +} + +static BOOL __stdcall +ansi_move_file(const void *from, const void *to, DWORD flags) +{ + return MoveFileExA((const char *)from, (const char *)to, flags); +} + +static BOOL __stdcall +ansi_set_file_attributes(const void *name, DWORD attributes) +{ + return SetFileAttributesA((const char *)name, attributes); +} + +static HANDLE __stdcall +ansi_find_first_file(const void *name, void *data) +{ + return FindFirstFileA((const char *)name, data); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_file_win32_named.c b/thirdparty/libzip-1.11.3/lib/zip_source_file_win32_named.c new file mode 100644 index 0000000..5219d6a --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_file_win32_named.c @@ -0,0 +1,283 @@ +/* + zip_source_file_win32_named.c -- source for Windows file opened by name + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zip_source_file_win32.h" + +static zip_int64_t _zip_win32_named_op_commit_write(zip_source_file_context_t *ctx); +static zip_int64_t _zip_win32_named_op_create_temp_output(zip_source_file_context_t *ctx); +static bool _zip_win32_named_op_open(zip_source_file_context_t *ctx); +static zip_int64_t _zip_win32_named_op_remove(zip_source_file_context_t *ctx); +static void _zip_win32_named_op_rollback_write(zip_source_file_context_t *ctx); +static bool _zip_win32_named_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st); +static char *_zip_win32_named_op_string_duplicate(zip_source_file_context_t *ctx, const char *string); +static zip_int64_t _zip_win32_named_op_write(zip_source_file_context_t *ctx, const void *data, zip_uint64_t len); + +static HANDLE win32_named_open(zip_source_file_context_t *ctx, const char *name, bool temporary, PSECURITY_ATTRIBUTES security_attributes); + +/* clang-format off */ +zip_source_file_operations_t _zip_source_file_win32_named_ops = { + _zip_win32_op_close, + _zip_win32_named_op_commit_write, + _zip_win32_named_op_create_temp_output, + NULL, + _zip_win32_named_op_open, + _zip_win32_op_read, + _zip_win32_named_op_remove, + _zip_win32_named_op_rollback_write, + _zip_win32_op_seek, + _zip_win32_named_op_stat, + _zip_win32_named_op_string_duplicate, + _zip_win32_op_tell, + _zip_win32_named_op_write +}; +/* clang-format on */ + +static zip_int64_t +_zip_win32_named_op_commit_write(zip_source_file_context_t *ctx) { + zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata; + DWORD attributes; + + if (!CloseHandle((HANDLE)ctx->fout)) { + zip_error_set(&ctx->error, ZIP_ER_WRITE, _zip_win32_error_to_errno(GetLastError())); + return -1; + } + + attributes = file_ops->get_file_attributes(ctx->tmpname); + if (attributes == INVALID_FILE_ATTRIBUTES) { + zip_error_set(&ctx->error, ZIP_ER_RENAME, _zip_win32_error_to_errno(GetLastError())); + return -1; + } + + if (attributes & FILE_ATTRIBUTE_TEMPORARY) { + if (!file_ops->set_file_attributes(ctx->tmpname, attributes & ~FILE_ATTRIBUTE_TEMPORARY)) { + zip_error_set(&ctx->error, ZIP_ER_RENAME, _zip_win32_error_to_errno(GetLastError())); + return -1; + } + } + + if (!file_ops->move_file(ctx->tmpname, ctx->fname, MOVEFILE_REPLACE_EXISTING)) { + zip_error_set(&ctx->error, ZIP_ER_RENAME, _zip_win32_error_to_errno(GetLastError())); + return -1; + } + + return 0; +} + +static zip_int64_t +_zip_win32_named_op_create_temp_output(zip_source_file_context_t *ctx) { + zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata; + + zip_uint32_t value, i; + HANDLE th = INVALID_HANDLE_VALUE; + PSECURITY_ATTRIBUTES psa = NULL; + PSECURITY_DESCRIPTOR psd = NULL; +#ifdef HAVE_GETSECURITYINFO + SECURITY_ATTRIBUTES sa; +#endif + char *tempname = NULL; + size_t tempname_size = 0; + +#ifdef HAVE_GETSECURITYINFO + if ((HANDLE)ctx->f != INVALID_HANDLE_VALUE && GetFileType((HANDLE)ctx->f) == FILE_TYPE_DISK) { + if (GetSecurityInfo((HANDLE)ctx->f, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION | UNPROTECTED_DACL_SECURITY_INFORMATION, NULL, NULL, NULL, NULL, &psd) == ERROR_SUCCESS) { + sa.nLength = sizeof(SECURITY_ATTRIBUTES); + sa.bInheritHandle = FALSE; + sa.lpSecurityDescriptor = psd; + psa = &sa; + } + } +#endif + +#ifndef MS_UWP + value = GetTickCount(); +#else + value = (zip_uint32_t)(GetTickCount64() & 0xffffffff); +#endif + + if ((tempname = file_ops->allocate_tempname(ctx->fname, 10, &tempname_size)) == NULL) { + zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); + return -1; + } + + for (i = 0; i < 1024 && th == INVALID_HANDLE_VALUE; i++) { + file_ops->make_tempname(tempname, tempname_size, ctx->fname, value + i); + + th = win32_named_open(ctx, tempname, true, psa); + if (th == INVALID_HANDLE_VALUE && GetLastError() != ERROR_FILE_EXISTS) + break; + } + + if (th == INVALID_HANDLE_VALUE) { + free(tempname); + LocalFree(psd); + zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, _zip_win32_error_to_errno(GetLastError())); + return -1; + } + + LocalFree(psd); + ctx->fout = th; + ctx->tmpname = tempname; + + return 0; +} + + +static bool +_zip_win32_named_op_open(zip_source_file_context_t *ctx) { + HANDLE h = win32_named_open(ctx, ctx->fname, false, NULL); + + if (h == INVALID_HANDLE_VALUE) { + return false; + } + + ctx->f = h; + return true; +} + + +static zip_int64_t +_zip_win32_named_op_remove(zip_source_file_context_t *ctx) { + zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata; + + if (!file_ops->delete_file(ctx->fname)) { + zip_error_set(&ctx->error, ZIP_ER_REMOVE, _zip_win32_error_to_errno(GetLastError())); + return -1; + } + + return 0; +} + + +static void +_zip_win32_named_op_rollback_write(zip_source_file_context_t *ctx) { + zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata; + + if (ctx->fout) { + CloseHandle((HANDLE)ctx->fout); + } + file_ops->delete_file(ctx->tmpname); +} + + +static bool +_zip_win32_named_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st) { + zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata; + + WIN32_FILE_ATTRIBUTE_DATA file_attributes; + + if (!file_ops->get_file_attributes_ex(ctx->fname, GetFileExInfoStandard, &file_attributes)) { + DWORD error = GetLastError(); + if (error == ERROR_FILE_NOT_FOUND) { + st->exists = false; + return true; + } + zip_error_set(&ctx->error, ZIP_ER_READ, _zip_win32_error_to_errno(error)); + return false; + } + + st->exists = true; + st->regular_file = false; + + if (file_attributes.dwFileAttributes != INVALID_FILE_ATTRIBUTES) { + if ((file_attributes.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) == 0) { + if (file_attributes.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) { + WIN32_FIND_DATA find_data; + /* Deduplication on Windows replaces files with reparse points; + * accept them as regular files. */ + if (file_ops->find_first_file(ctx->fname, &find_data) != INVALID_HANDLE_VALUE) { + st->regular_file = (find_data.dwReserved0 == IO_REPARSE_TAG_DEDUP); + } + } + else { + st->regular_file = true; + } + } + } + + if (!_zip_filetime_to_time_t(file_attributes.ftLastWriteTime, &st->mtime)) { + zip_error_set(&ctx->error, ZIP_ER_READ, ERANGE); + return false; + } + st->size = ((zip_uint64_t)file_attributes.nFileSizeHigh << 32) | file_attributes.nFileSizeLow; + + /* TODO: fill in ctx->attributes */ + + return true; +} + + +static char * +_zip_win32_named_op_string_duplicate(zip_source_file_context_t *ctx, const char *string) { + zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata; + + return file_ops->string_duplicate(string); +} + + +static zip_int64_t +_zip_win32_named_op_write(zip_source_file_context_t *ctx, const void *data, zip_uint64_t len) { + DWORD ret; + if (!WriteFile((HANDLE)ctx->fout, data, (DWORD)len, &ret, NULL) || ret != len) { + zip_error_set(&ctx->error, ZIP_ER_WRITE, _zip_win32_error_to_errno(GetLastError())); + return -1; + } + + return (zip_int64_t)ret; +} + + +static HANDLE +win32_named_open(zip_source_file_context_t *ctx, const char *name, bool temporary, PSECURITY_ATTRIBUTES security_attributes) { + zip_win32_file_operations_t *file_ops = (zip_win32_file_operations_t *)ctx->ops_userdata; + + DWORD access = GENERIC_READ; + DWORD share_mode = FILE_SHARE_READ | FILE_SHARE_WRITE; + DWORD creation_disposition = OPEN_EXISTING; + DWORD file_attributes = FILE_ATTRIBUTE_NORMAL; + HANDLE h; + + if (temporary) { + access = GENERIC_READ | GENERIC_WRITE; + share_mode = FILE_SHARE_READ; + creation_disposition = CREATE_NEW; + file_attributes = FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_TEMPORARY; + } + + h = file_ops->create_file(name, access, share_mode, security_attributes, creation_disposition, file_attributes, NULL); + + if (h == INVALID_HANDLE_VALUE) { + zip_error_set(&ctx->error, ZIP_ER_OPEN, _zip_win32_error_to_errno(GetLastError())); + } + + return h; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_file_win32_utf16.c b/thirdparty/libzip-1.11.3/lib/zip_source_file_win32_utf16.c new file mode 100644 index 0000000..73e2566 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_file_win32_utf16.c @@ -0,0 +1,152 @@ +/* + zip_source_file_win32_utf16.c -- source for Windows file opened by UTF-16 name + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zip_source_file_win32.h" + +static char *utf16_allocate_tempname(const char *name, size_t extra_chars, size_t *lengthp); +static HANDLE __stdcall utf16_create_file(const void *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file); +static BOOL __stdcall utf16_delete_file(const void *name); +static DWORD __stdcall utf16_get_file_attributes(const void *name); +static BOOL __stdcall utf16_get_file_attributes_ex(const void *name, GET_FILEEX_INFO_LEVELS info_level, void *information); +static void utf16_make_tempname(char *buf, size_t len, const char *name, zip_uint32_t i); +static BOOL __stdcall utf16_move_file(const void *from, const void *to, DWORD flags); +static BOOL __stdcall utf16_set_file_attributes(const void *name, DWORD attributes); +static char *utf16_strdup(const char *string); +static HANDLE __stdcall utf16_find_first_file(const void *name, void* data); + + +/* clang-format off */ +zip_win32_file_operations_t ops_utf16 = { + utf16_allocate_tempname, + utf16_create_file, + utf16_delete_file, + utf16_get_file_attributes, + utf16_get_file_attributes_ex, + utf16_make_tempname, + utf16_move_file, + utf16_set_file_attributes, + utf16_strdup, + utf16_find_first_file +}; +/* clang-format on */ + +ZIP_EXTERN zip_source_t * +zip_source_win32w(zip_t *za, const wchar_t *fname, zip_uint64_t start, zip_int64_t len) { + if (za == NULL) + return NULL; + + return zip_source_win32w_create(fname, start, len, &za->error); +} + + +ZIP_EXTERN zip_source_t * +zip_source_win32w_create(const wchar_t *fname, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { + if (fname == NULL || length < ZIP_LENGTH_UNCHECKED) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + + return zip_source_file_common_new((const char *)fname, NULL, start, length, NULL, &_zip_source_file_win32_named_ops, &ops_utf16, error); +} + + +static char * +utf16_allocate_tempname(const char *name, size_t extra_chars, size_t *lengthp) { + *lengthp = wcslen((const wchar_t *)name) + extra_chars; + return (char *)malloc(*lengthp * sizeof(wchar_t)); +} + + +static HANDLE __stdcall utf16_create_file(const void *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file) { +#ifdef MS_UWP + CREATEFILE2_EXTENDED_PARAMETERS extParams = {0}; + extParams.dwFileAttributes = file_attributes; + extParams.dwFileFlags = FILE_FLAG_RANDOM_ACCESS; + extParams.dwSecurityQosFlags = SECURITY_ANONYMOUS; + extParams.dwSize = sizeof(extParams); + extParams.hTemplateFile = template_file; + extParams.lpSecurityAttributes = security_attributes; + + return CreateFile2((const wchar_t *)name, access, share_mode, creation_disposition, &extParams); +#else + return CreateFileW((const wchar_t *)name, access, share_mode, security_attributes, creation_disposition, file_attributes, template_file); +#endif +} + +static BOOL __stdcall +utf16_delete_file(const void *name) +{ + return DeleteFileW((const wchar_t *)name); +} + +static DWORD __stdcall +utf16_get_file_attributes(const void *name) +{ + return GetFileAttributesW((const wchar_t *)name); +} + +static BOOL __stdcall +utf16_get_file_attributes_ex(const void *name, GET_FILEEX_INFO_LEVELS info_level, void *information) +{ + return GetFileAttributesExW((const wchar_t *)name, info_level, information); +} + +static void +utf16_make_tempname(char *buf, size_t len, const char *name, zip_uint32_t i) { + _snwprintf_s((wchar_t *)buf, len, len, L"%s.%08x", (const wchar_t *)name, i); +} + +static BOOL __stdcall +utf16_move_file(const void *from, const void *to, DWORD flags) +{ + return MoveFileExW((const wchar_t *)from, (const wchar_t *)to, flags); +} + +static BOOL __stdcall +utf16_set_file_attributes(const void *name, DWORD attributes) +{ + return SetFileAttributesW((const wchar_t *)name, attributes); +} + +static char * +utf16_strdup(const char *string) { + return (char *)_wcsdup((const wchar_t *)string); +} + + +static HANDLE __stdcall +utf16_find_first_file(const void *name, void* data) +{ + return FindFirstFileW((const wchar_t *)name, data); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_file_win32_utf8.c b/thirdparty/libzip-1.11.3/lib/zip_source_file_win32_utf8.c new file mode 100644 index 0000000..5c27df9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_file_win32_utf8.c @@ -0,0 +1,73 @@ +/* + zip_source_file_win32_ansi.c -- source for Windows file opened by UTF-8 name + Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zip_source_file_win32.h" + +ZIP_EXTERN zip_source_t * +zip_source_file(zip_t *za, const char *fname, zip_uint64_t start, zip_int64_t len) { + if (za == NULL) { + return NULL; + } + + return zip_source_file_create(fname, start, len, &za->error); +} + + +ZIP_EXTERN zip_source_t * +zip_source_file_create(const char *fname, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { + int size; + wchar_t *wfname; + zip_source_t *source; + + if (fname == NULL || length < ZIP_LENGTH_UNCHECKED) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + /* Convert fname from UTF-8 to Windows-friendly UTF-16. */ + size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, fname, -1, NULL, 0); + if (size == 0) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + if ((wfname = (wchar_t *)malloc(sizeof(wchar_t) * size)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, fname, -1, wfname, size); + + source = zip_source_win32w_create(wfname, start, length, error); + + free(wfname); + return source; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_free.c b/thirdparty/libzip-1.11.3/lib/zip_source_free.c new file mode 100644 index 0000000..df4b08d --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_free.c @@ -0,0 +1,71 @@ +/* + zip_source_free.c -- free zip data source + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +ZIP_EXTERN void +zip_source_free(zip_source_t *src) { + if (src == NULL) + return; + + if (src->refcount > 0) { + src->refcount--; + } + if (src->refcount > 0) { + return; + } + + if (ZIP_SOURCE_IS_OPEN_READING(src)) { + src->open_count = 1; /* force close */ + zip_source_close(src); + } + if (ZIP_SOURCE_IS_OPEN_WRITING(src)) { + zip_source_rollback_write(src); + } + + if (src->source_archive && !src->source_closed) { + _zip_deregister_source(src->source_archive, src); + } + + (void)_zip_source_call(src, NULL, 0, ZIP_SOURCE_FREE); + + if (src->src) { + zip_source_free(src->src); + } + + free(src); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_function.c b/thirdparty/libzip-1.11.3/lib/zip_source_function.c new file mode 100644 index 0000000..1fe6396 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_function.c @@ -0,0 +1,99 @@ +/* + zip_source_function.c -- create zip data source from callback function + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +ZIP_EXTERN zip_source_t * +zip_source_function(zip_t *za, zip_source_callback zcb, void *ud) { + if (za == NULL) { + return NULL; + } + + return zip_source_function_create(zcb, ud, &za->error); +} + + +ZIP_EXTERN zip_source_t * +zip_source_function_create(zip_source_callback zcb, void *ud, zip_error_t *error) { + zip_source_t *zs; + + if ((zs = _zip_source_new(error)) == NULL) + return NULL; + + zs->cb.f = zcb; + zs->ud = ud; + + zs->supports = zcb(ud, NULL, 0, ZIP_SOURCE_SUPPORTS); + if (zs->supports < 0) { + zs->supports = ZIP_SOURCE_SUPPORTS_READABLE; + } + zs->supports |= zip_source_make_command_bitmap(ZIP_SOURCE_SUPPORTS, -1); + + return zs; +} + + +ZIP_EXTERN void +zip_source_keep(zip_source_t *src) { + src->refcount++; +} + + +zip_source_t * +_zip_source_new(zip_error_t *error) { + zip_source_t *src; + + if ((src = (zip_source_t *)malloc(sizeof(*src))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + src->src = NULL; + src->cb.f = NULL; + src->ud = NULL; + src->open_count = 0; + src->write_state = ZIP_SOURCE_WRITE_CLOSED; + src->source_closed = false; + src->source_archive = NULL; + src->refcount = 1; + zip_error_init(&src->error); + src->eof = false; + src->had_read_error = false; + src->bytes_read = 0; + + return src; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_get_dostime.c b/thirdparty/libzip-1.11.3/lib/zip_source_get_dostime.c new file mode 100644 index 0000000..17f652b --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_get_dostime.c @@ -0,0 +1,72 @@ +/* + zip_source_get_dostime.c -- get modification time in DOS format from source + Copyright (C) 2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + +/* Returns -1 on error, 0 on no dostime available, 1 for dostime returned */ +int +zip_source_get_dos_time(zip_source_t *src, zip_dostime_t *dos_time) { + if (src->source_closed) { + return -1; + } + if (dos_time == NULL) { + zip_error_set(&src->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (src->write_state == ZIP_SOURCE_WRITE_REMOVED) { + zip_error_set(&src->error, ZIP_ER_READ, ENOENT); + } + + if (zip_source_supports(src) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_GET_DOS_TIME)) { + zip_int64_t n = _zip_source_call(src, dos_time, sizeof(*dos_time), ZIP_SOURCE_GET_DOS_TIME); + + if (n < 0) { + return -1; + } + else if (n == 0) { + return 0; + } + else if (n == sizeof(*dos_time)) { + return 1; + } + else { + zip_error_set(&src->error, ZIP_ER_INTERNAL, 0); + return -1; + } + } + else { + return 0; + } +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_get_file_attributes.c b/thirdparty/libzip-1.11.3/lib/zip_source_get_file_attributes.c new file mode 100644 index 0000000..59c064f --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_get_file_attributes.c @@ -0,0 +1,107 @@ +/* + zip_source_get_file_attributes.c -- get attributes for file from source + Copyright (C) 2020-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +ZIP_EXTERN void +zip_file_attributes_init(zip_file_attributes_t *attributes) { + attributes->valid = 0; + attributes->version = 1; +} + +int zip_source_get_file_attributes(zip_source_t *src, zip_file_attributes_t *attributes) { + if (src->source_closed) { + return -1; + } + if (attributes == NULL) { + zip_error_set(&src->error, ZIP_ER_INVAL, 0); + return -1; + } + + zip_file_attributes_init(attributes); + + if (src->supports & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_GET_FILE_ATTRIBUTES)) { + if (_zip_source_call(src, attributes, sizeof(*attributes), ZIP_SOURCE_GET_FILE_ATTRIBUTES) < 0) { + return -1; + } + } + + if (ZIP_SOURCE_IS_LAYERED(src)) { + zip_file_attributes_t lower_attributes; + + zip_file_attributes_init(&lower_attributes); + + if (zip_source_get_file_attributes(src->src, &lower_attributes) < 0) { + zip_error_set_from_source(&src->error, src->src); + return -1; + } + + if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_HOST_SYSTEM) && (attributes->valid & ZIP_FILE_ATTRIBUTES_HOST_SYSTEM) == 0) { + attributes->host_system = lower_attributes.host_system; + attributes->valid |= ZIP_FILE_ATTRIBUTES_HOST_SYSTEM; + } + if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_ASCII) && (attributes->valid & ZIP_FILE_ATTRIBUTES_ASCII) == 0) { + attributes->ascii = lower_attributes.ascii; + attributes->valid |= ZIP_FILE_ATTRIBUTES_ASCII; + } + if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_VERSION_NEEDED)) { + if (attributes->valid & ZIP_FILE_ATTRIBUTES_VERSION_NEEDED) { + attributes->version_needed = ZIP_MAX(lower_attributes.version_needed, attributes->version_needed); + } + else { + attributes->version_needed = lower_attributes.version_needed; + attributes->valid |= ZIP_FILE_ATTRIBUTES_VERSION_NEEDED; + } + } + if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES) && (attributes->valid & ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES) == 0) { + attributes->external_file_attributes = lower_attributes.external_file_attributes; + attributes->valid |= ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES; + } + if ((lower_attributes.valid & ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS)) { + if (attributes->valid & ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS) { + /* only take from lower level what is not defined at current level */ + lower_attributes.general_purpose_bit_mask &= ~attributes->general_purpose_bit_mask; + + attributes->general_purpose_bit_flags |= lower_attributes.general_purpose_bit_flags & lower_attributes.general_purpose_bit_mask; + attributes->general_purpose_bit_mask |= lower_attributes.general_purpose_bit_mask; + } + else { + attributes->valid |= ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS; + attributes->general_purpose_bit_flags = lower_attributes.general_purpose_bit_flags; + attributes->general_purpose_bit_mask = lower_attributes.general_purpose_bit_mask; + } + } + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_is_deleted.c b/thirdparty/libzip-1.11.3/lib/zip_source_is_deleted.c new file mode 100644 index 0000000..d6016a0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_is_deleted.c @@ -0,0 +1,41 @@ +/* + zip_source_is_deleted.c -- was archive was removed? + Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_source_is_deleted(zip_source_t *src) { + return src->write_state == ZIP_SOURCE_WRITE_REMOVED; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_layered.c b/thirdparty/libzip-1.11.3/lib/zip_source_layered.c new file mode 100644 index 0000000..be42819 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_layered.c @@ -0,0 +1,75 @@ +/* + zip_source_layered.c -- create layered source + Copyright (C) 2009-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +zip_source_t * +zip_source_layered(zip_t *za, zip_source_t *src, zip_source_layered_callback cb, void *ud) { + if (za == NULL) + return NULL; + + return zip_source_layered_create(src, cb, ud, &za->error); +} + + +zip_source_t * +zip_source_layered_create(zip_source_t *src, zip_source_layered_callback cb, void *ud, zip_error_t *error) { + zip_source_t *zs; + zip_int64_t lower_supports, supports; + + lower_supports = zip_source_supports(src); + supports = cb(src, ud, &lower_supports, sizeof(lower_supports), ZIP_SOURCE_SUPPORTS); + if (supports < 0) { + zip_error_set(error,ZIP_ER_INVAL, 0); /* Initialize in case cb doesn't return valid error. */ + cb(src, ud, error, sizeof(*error), ZIP_SOURCE_ERROR); + return NULL; + } + + if ((zs = _zip_source_new(error)) == NULL) { + return NULL; + } + + zs->src = src; + zs->cb.l = cb; + zs->ud = ud; + zs->supports = supports; + + /* Layered sources can't support writing, since we currently have no use case. If we want to revisit this, we have to define how the two sources interact. */ + zs->supports &= ~(ZIP_SOURCE_SUPPORTS_WRITABLE & ~ZIP_SOURCE_SUPPORTS_SEEKABLE); + + return zs; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_open.c b/thirdparty/libzip-1.11.3/lib/zip_source_open.c new file mode 100644 index 0000000..9e42d0a --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_open.c @@ -0,0 +1,76 @@ +/* + zip_source_open.c -- open zip_source (prepare for reading) + Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + +ZIP_EXTERN int +zip_source_open(zip_source_t *src) { + if (src->source_closed) { + return -1; + } + if (src->write_state == ZIP_SOURCE_WRITE_REMOVED) { + zip_error_set(&src->error, ZIP_ER_DELETED, 0); + return -1; + } + + if (ZIP_SOURCE_IS_OPEN_READING(src)) { + if ((zip_source_supports(src) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK)) == 0) { + zip_error_set(&src->error, ZIP_ER_INUSE, 0); + return -1; + } + } + else { + if (ZIP_SOURCE_IS_LAYERED(src)) { + if (zip_source_open(src->src) < 0) { + zip_error_set_from_source(&src->error, src->src); + return -1; + } + } + + if (_zip_source_call(src, NULL, 0, ZIP_SOURCE_OPEN) < 0) { + if (ZIP_SOURCE_IS_LAYERED(src)) { + zip_source_close(src->src); + } + return -1; + } + } + + src->eof = false; + src->had_read_error = false; + _zip_error_clear(&src->error); + src->bytes_read = 0; + src->open_count++; + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_pass_to_lower_layer.c b/thirdparty/libzip-1.11.3/lib/zip_source_pass_to_lower_layer.c new file mode 100644 index 0000000..391729e --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_pass_to_lower_layer.c @@ -0,0 +1,78 @@ +/* + zip_source_pass_to_lower_layer.c -- pass command to lower layer + Copyright (C) 2022-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +zip_int64_t zip_source_pass_to_lower_layer(zip_source_t *src, void *data, zip_uint64_t length, zip_source_cmd_t command) { + switch (command) { + case ZIP_SOURCE_OPEN: + case ZIP_SOURCE_CLOSE: + case ZIP_SOURCE_FREE: + case ZIP_SOURCE_GET_FILE_ATTRIBUTES: + case ZIP_SOURCE_SUPPORTS_REOPEN: + return 0; + + case ZIP_SOURCE_STAT: + return sizeof(zip_stat_t); + + case ZIP_SOURCE_ACCEPT_EMPTY: + case ZIP_SOURCE_ERROR: + case ZIP_SOURCE_GET_DOS_TIME: + case ZIP_SOURCE_READ: + case ZIP_SOURCE_SEEK: + case ZIP_SOURCE_TELL: + return _zip_source_call(src, data, length, command); + + case ZIP_SOURCE_BEGIN_WRITE: + case ZIP_SOURCE_BEGIN_WRITE_CLONING: + case ZIP_SOURCE_COMMIT_WRITE: + case ZIP_SOURCE_REMOVE: + case ZIP_SOURCE_ROLLBACK_WRITE: + case ZIP_SOURCE_SEEK_WRITE: + case ZIP_SOURCE_TELL_WRITE: + case ZIP_SOURCE_WRITE: + zip_error_set(&src->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + + case ZIP_SOURCE_SUPPORTS: + if (length < sizeof(zip_int64_t)) { + zip_error_set(&src->error, ZIP_ER_INTERNAL, 0); + return -1; + } + return *(zip_int64_t *)data; + + default: + zip_error_set(&src->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + } +} \ No newline at end of file diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_pkware_decode.c b/thirdparty/libzip-1.11.3/lib/zip_source_pkware_decode.c new file mode 100644 index 0000000..9c22a06 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_pkware_decode.c @@ -0,0 +1,218 @@ +/* + zip_source_pkware_decode.c -- Traditional PKWARE decryption routines + Copyright (C) 2009-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include + +#include "zipint.h" + +struct trad_pkware { + char *password; + zip_pkware_keys_t keys; + zip_error_t error; +}; + + +static int decrypt_header(zip_source_t *, struct trad_pkware *); +static zip_int64_t pkware_decrypt(zip_source_t *, void *, void *, zip_uint64_t, zip_source_cmd_t); +static struct trad_pkware *trad_pkware_new(const char *password, zip_error_t *error); +static void trad_pkware_free(struct trad_pkware *); + + +zip_source_t * +zip_source_pkware_decode(zip_t *za, zip_source_t *src, zip_uint16_t em, int flags, const char *password) { + struct trad_pkware *ctx; + zip_source_t *s2; + + if (password == NULL || src == NULL || em != ZIP_EM_TRAD_PKWARE) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + if (flags & ZIP_CODEC_ENCODE) { + zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0); + return NULL; + } + + if ((ctx = trad_pkware_new(password, &za->error)) == NULL) { + return NULL; + } + + if ((s2 = zip_source_layered(za, src, pkware_decrypt, ctx)) == NULL) { + trad_pkware_free(ctx); + return NULL; + } + + return s2; +} + + +static int +decrypt_header(zip_source_t *src, struct trad_pkware *ctx) { + zip_uint8_t header[ZIP_CRYPTO_PKWARE_HEADERLEN]; + zip_stat_t st; + zip_dostime_t dostime; + zip_int64_t n; + + if ((n = zip_source_read(src, header, ZIP_CRYPTO_PKWARE_HEADERLEN)) < 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + + if (n != ZIP_CRYPTO_PKWARE_HEADERLEN) { + zip_error_set(&ctx->error, ZIP_ER_EOF, 0); + return -1; + } + + _zip_pkware_decrypt(&ctx->keys, header, header, ZIP_CRYPTO_PKWARE_HEADERLEN); + + if (zip_source_stat(src, &st) < 0 || (st.valid & ZIP_STAT_CRC) == 0) { + /* skip password validation */ + return 0; + } + + if (zip_source_get_dos_time(src, &dostime) <= 0) { + if ((st.valid & ZIP_STAT_MTIME) == 0) { + /* no date available, skip password validation */ + return 0; + } + + if (_zip_u2d_time(st.mtime, &dostime, &ctx->error) < 0) { + return -1; + } + } + + /* + password verification - two ways: + - mtime - InfoZIP way, to avoid computing complete CRC before encrypting data + - CRC - old PKWare way + */ + if (header[ZIP_CRYPTO_PKWARE_HEADERLEN - 1] == dostime.time >> 8 + || header[ZIP_CRYPTO_PKWARE_HEADERLEN - 1] == st.crc >> 24) { + return 0; + } + else { + zip_error_set(&ctx->error, ZIP_ER_WRONGPASSWD, 0); + return -1; + } +} + + +static zip_int64_t +pkware_decrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { + struct trad_pkware *ctx; + zip_int64_t n; + + ctx = (struct trad_pkware *)ud; + + switch (cmd) { + case ZIP_SOURCE_OPEN: + _zip_pkware_keys_reset(&ctx->keys); + _zip_pkware_decrypt(&ctx->keys, NULL, (const zip_uint8_t *)ctx->password, strlen(ctx->password)); + if (decrypt_header(src, ctx) < 0) { + return -1; + } + return 0; + + case ZIP_SOURCE_READ: + if ((n = zip_source_read(src, data, len)) < 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + + _zip_pkware_decrypt(&ctx->keys, (zip_uint8_t *)data, (zip_uint8_t *)data, (zip_uint64_t)n); + return n; + + case ZIP_SOURCE_CLOSE: + return 0; + + case ZIP_SOURCE_STAT: { + zip_stat_t *st; + + st = (zip_stat_t *)data; + + st->encryption_method = ZIP_EM_NONE; + st->valid |= ZIP_STAT_ENCRYPTION_METHOD; + if (st->valid & ZIP_STAT_COMP_SIZE) { + st->comp_size -= ZIP_CRYPTO_PKWARE_HEADERLEN; + } + + return 0; + } + + case ZIP_SOURCE_SUPPORTS: + return zip_source_make_command_bitmap(ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_STAT, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_SUPPORTS_REOPEN, -1); + + case ZIP_SOURCE_ERROR: + return zip_error_to_data(&ctx->error, data, len); + + case ZIP_SOURCE_FREE: + trad_pkware_free(ctx); + return 0; + + default: + return zip_source_pass_to_lower_layer(src, data, len, cmd); + } +} + + +static struct trad_pkware * +trad_pkware_new(const char *password, zip_error_t *error) { + struct trad_pkware *ctx; + + if ((ctx = (struct trad_pkware *)malloc(sizeof(*ctx))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if ((ctx->password = strdup(password)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + free(ctx); + return NULL; + } + + zip_error_init(&ctx->error); + + return ctx; +} + + +static void +trad_pkware_free(struct trad_pkware *ctx) { + if (ctx == NULL) { + return; + } + + free(ctx->password); + free(ctx); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_pkware_encode.c b/thirdparty/libzip-1.11.3/lib/zip_source_pkware_encode.c new file mode 100644 index 0000000..26e1ce7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_pkware_encode.c @@ -0,0 +1,264 @@ +/* + zip_source_pkware_encode.c -- Traditional PKWARE encryption routines + Copyright (C) 2009-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include + +#include "zipint.h" + +struct trad_pkware { + char *password; + zip_pkware_keys_t keys; + zip_buffer_t *buffer; + bool eof; + zip_dostime_t dostime; + zip_error_t error; +}; + + +static int encrypt_header(zip_source_t *, struct trad_pkware *); +static zip_int64_t pkware_encrypt(zip_source_t *, void *, void *, zip_uint64_t, zip_source_cmd_t); +static void trad_pkware_free(struct trad_pkware *); +static struct trad_pkware *trad_pkware_new(const char *password, zip_error_t *error); + +zip_source_t * +zip_source_pkware_encode(zip_t *za, zip_source_t *src, zip_uint16_t em, int flags, const char *password) { + struct trad_pkware *ctx; + zip_source_t *s2; + + if (password == NULL || src == NULL || em != ZIP_EM_TRAD_PKWARE) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + if (!(flags & ZIP_CODEC_ENCODE)) { + zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0); + return NULL; + } + + if ((ctx = trad_pkware_new(password, &za->error)) == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if (zip_source_get_dos_time(src, &ctx->dostime) <= 0) { + zip_stat_t st; + + if (zip_source_stat(src, &st) < 0) { + zip_error_set_from_source(&za->error, src); + trad_pkware_free(ctx); + return NULL; + } + if (_zip_u2d_time((st.valid & ZIP_STAT_MTIME) ? st.mtime : time(NULL), &ctx->dostime, &za->error) < 0) { + trad_pkware_free(ctx); + return NULL; + } + } + + if ((s2 = zip_source_layered(za, src, pkware_encrypt, ctx)) == NULL) { + trad_pkware_free(ctx); + return NULL; + } + + return s2; +} + + +static int +encrypt_header(zip_source_t *src, struct trad_pkware *ctx) { + zip_uint8_t *header; + + if ((ctx->buffer = _zip_buffer_new(NULL, ZIP_CRYPTO_PKWARE_HEADERLEN)) == NULL) { + zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); + return -1; + } + + header = _zip_buffer_data(ctx->buffer); + + /* generate header from random bytes and mtime + see appnote.iz, XIII. Decryption, Step 2, last paragraph */ + if (!zip_secure_random(header, ZIP_CRYPTO_PKWARE_HEADERLEN - 1)) { + zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); + _zip_buffer_free(ctx->buffer); + ctx->buffer = NULL; + return -1; + } + header[ZIP_CRYPTO_PKWARE_HEADERLEN - 1] = (zip_uint8_t)((ctx->dostime.time >> 8) & 0xff); + + _zip_pkware_encrypt(&ctx->keys, header, header, ZIP_CRYPTO_PKWARE_HEADERLEN); + + return 0; +} + + +static zip_int64_t +pkware_encrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t length, zip_source_cmd_t cmd) { + struct trad_pkware *ctx; + zip_int64_t n; + zip_uint64_t buffer_n; + + ctx = (struct trad_pkware *)ud; + + switch (cmd) { + case ZIP_SOURCE_OPEN: + ctx->eof = false; + + /* initialize keys */ + _zip_pkware_keys_reset(&ctx->keys); + _zip_pkware_encrypt(&ctx->keys, NULL, (const zip_uint8_t *)ctx->password, strlen(ctx->password)); + + if (encrypt_header(src, ctx) < 0) { + return -1; + } + return 0; + + case ZIP_SOURCE_READ: + buffer_n = 0; + + if (ctx->buffer) { + /* write header values to data */ + buffer_n = _zip_buffer_read(ctx->buffer, data, length); + data = (zip_uint8_t *)data + buffer_n; + length -= buffer_n; + + if (_zip_buffer_eof(ctx->buffer)) { + _zip_buffer_free(ctx->buffer); + ctx->buffer = NULL; + } + } + + if (ctx->eof) { + return (zip_int64_t)buffer_n; + } + + if ((n = zip_source_read(src, data, length)) < 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + + _zip_pkware_encrypt(&ctx->keys, (zip_uint8_t *)data, (zip_uint8_t *)data, (zip_uint64_t)n); + + if ((zip_uint64_t)n < length) { + ctx->eof = true; + } + + return (zip_int64_t)buffer_n + n; + + case ZIP_SOURCE_CLOSE: + _zip_buffer_free(ctx->buffer); + ctx->buffer = NULL; + return 0; + + case ZIP_SOURCE_STAT: { + zip_stat_t *st; + + st = (zip_stat_t *)data; + st->encryption_method = ZIP_EM_TRAD_PKWARE; + st->valid |= ZIP_STAT_ENCRYPTION_METHOD; + if (st->valid & ZIP_STAT_COMP_SIZE) { + st->comp_size += ZIP_CRYPTO_PKWARE_HEADERLEN; + } + + return 0; + } + + case ZIP_SOURCE_GET_FILE_ATTRIBUTES: { + zip_file_attributes_t *attributes = (zip_file_attributes_t *)data; + if (length < sizeof(*attributes)) { + zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); + return -1; + } + attributes->valid |= ZIP_FILE_ATTRIBUTES_VERSION_NEEDED | ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS; + attributes->version_needed = 20; + attributes->general_purpose_bit_flags = ZIP_GPBF_DATA_DESCRIPTOR; + attributes->general_purpose_bit_mask = ZIP_GPBF_DATA_DESCRIPTOR; + + return 0; + } + + case ZIP_SOURCE_GET_DOS_TIME: + if (length < sizeof(ctx->dostime)) { + zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); + return -1; + } + (void)memcpy_s(data, sizeof(ctx->dostime), &ctx->dostime, sizeof(ctx->dostime)); + return sizeof(ctx->dostime); + + case ZIP_SOURCE_SUPPORTS: + return zip_source_make_command_bitmap(ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_STAT, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_GET_FILE_ATTRIBUTES, ZIP_SOURCE_GET_DOS_TIME, -1); + + case ZIP_SOURCE_ERROR: + return zip_error_to_data(&ctx->error, data, length); + + case ZIP_SOURCE_FREE: + trad_pkware_free(ctx); + return 0; + + default: + return zip_source_pass_to_lower_layer(src, data, length, cmd); + } +} + + +static struct trad_pkware * +trad_pkware_new(const char *password, zip_error_t *error) { + struct trad_pkware *ctx; + + if ((ctx = (struct trad_pkware *)malloc(sizeof(*ctx))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if ((ctx->password = strdup(password)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + free(ctx); + return NULL; + } + ctx->buffer = NULL; + zip_error_init(&ctx->error); + + return ctx; +} + + +static void +trad_pkware_free(struct trad_pkware *ctx) { + if (ctx == NULL) { + return; + } + + free(ctx->password); + _zip_buffer_free(ctx->buffer); + zip_error_fini(&ctx->error); + free(ctx); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_read.c b/thirdparty/libzip-1.11.3/lib/zip_source_read.c new file mode 100644 index 0000000..910d4c3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_read.c @@ -0,0 +1,96 @@ +/* + zip_source_read.c -- read data from zip_source + Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +zip_int64_t +zip_source_read(zip_source_t *src, void *data, zip_uint64_t len) { + zip_uint64_t bytes_read; + zip_int64_t n; + + if (src->source_closed) { + return -1; + } + if (!ZIP_SOURCE_IS_OPEN_READING(src) || len > ZIP_INT64_MAX || (len > 0 && data == NULL)) { + zip_error_set(&src->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (src->had_read_error) { + return -1; + } + + if (_zip_source_eof(src)) { + return 0; + } + + if (len == 0) { + return 0; + } + + bytes_read = 0; + while (bytes_read < len) { + if ((n = _zip_source_call(src, (zip_uint8_t *)data + bytes_read, len - bytes_read, ZIP_SOURCE_READ)) < 0) { + src->had_read_error = true; + if (bytes_read == 0) { + return -1; + } + else { + return (zip_int64_t)bytes_read; + } + } + + if (n == 0) { + src->eof = 1; + break; + } + + bytes_read += (zip_uint64_t)n; + } + + if (src->bytes_read + bytes_read < src->bytes_read) { + src->bytes_read = ZIP_UINT64_MAX; + } + else { + src->bytes_read += bytes_read; + } + return (zip_int64_t)bytes_read; +} + + +bool +_zip_source_eof(zip_source_t *src) { + return src->eof; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_remove.c b/thirdparty/libzip-1.11.3/lib/zip_source_remove.c new file mode 100644 index 0000000..06325b7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_remove.c @@ -0,0 +1,65 @@ +/* + zip_source_remove.c -- remove empty archive + Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + +#include "zipint.h" + + +int +zip_source_remove(zip_source_t *src) { + if (ZIP_SOURCE_IS_LAYERED(src)) { + zip_error_set(&src->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + } + + if (src->write_state == ZIP_SOURCE_WRITE_REMOVED) { + return 0; + } + + if (ZIP_SOURCE_IS_OPEN_READING(src)) { + if (zip_source_close(src) < 0) { + return -1; + } + } + if (src->write_state != ZIP_SOURCE_WRITE_CLOSED) { + zip_source_rollback_write(src); + } + + if (_zip_source_call(src, NULL, 0, ZIP_SOURCE_REMOVE) < 0) { + return -1; + } + + src->write_state = ZIP_SOURCE_WRITE_REMOVED; + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_rollback_write.c b/thirdparty/libzip-1.11.3/lib/zip_source_rollback_write.c new file mode 100644 index 0000000..5161325 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_rollback_write.c @@ -0,0 +1,50 @@ +/* + zip_source_rollback_write.c -- discard changes + Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN void +zip_source_rollback_write(zip_source_t *src) { + if (ZIP_SOURCE_IS_LAYERED(src)) { + return; + } + + if (src->write_state != ZIP_SOURCE_WRITE_OPEN && src->write_state != ZIP_SOURCE_WRITE_FAILED) { + return; + } + + _zip_source_call(src, NULL, 0, ZIP_SOURCE_ROLLBACK_WRITE); + src->write_state = ZIP_SOURCE_WRITE_CLOSED; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_seek.c b/thirdparty/libzip-1.11.3/lib/zip_source_seek.c new file mode 100644 index 0000000..42d6b0d --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_seek.c @@ -0,0 +1,95 @@ +/* + zip_source_seek.c -- seek to offset + Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_source_seek(zip_source_t *src, zip_int64_t offset, int whence) { + zip_source_args_seek_t args; + + if (src->source_closed) { + return -1; + } + if (!ZIP_SOURCE_IS_OPEN_READING(src) || (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END)) { + zip_error_set(&src->error, ZIP_ER_INVAL, 0); + return -1; + } + + args.offset = offset; + args.whence = whence; + + if (_zip_source_call(src, &args, sizeof(args), ZIP_SOURCE_SEEK) < 0) { + return -1; + } + + src->eof = 0; + return 0; +} + + +zip_int64_t +zip_source_seek_compute_offset(zip_uint64_t offset, zip_uint64_t length, void *data, zip_uint64_t data_length, zip_error_t *error) { + zip_int64_t new_offset; + zip_source_args_seek_t *args = ZIP_SOURCE_GET_ARGS(zip_source_args_seek_t, data, data_length, error); + + if (args == NULL) { + return -1; + } + + switch (args->whence) { + case SEEK_CUR: + new_offset = (zip_int64_t)offset + args->offset; + break; + + case SEEK_END: + new_offset = (zip_int64_t)length + args->offset; + break; + + case SEEK_SET: + new_offset = args->offset; + break; + + default: + zip_error_set(error, ZIP_ER_INVAL, 0); + return -1; + } + + if (new_offset < 0 || (zip_uint64_t)new_offset > length) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return -1; + } + + return new_offset; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_seek_write.c b/thirdparty/libzip-1.11.3/lib/zip_source_seek_write.c new file mode 100644 index 0000000..9e87fa4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_seek_write.c @@ -0,0 +1,56 @@ +/* + zip_source_seek_write.c -- seek to offset for writing + Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_source_seek_write(zip_source_t *src, zip_int64_t offset, int whence) { + zip_source_args_seek_t args; + + if (ZIP_SOURCE_IS_LAYERED(src)) { + zip_error_set(&src->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + } + + if (!ZIP_SOURCE_IS_OPEN_WRITING(src) || (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END)) { + zip_error_set(&src->error, ZIP_ER_INVAL, 0); + return -1; + } + + args.offset = offset; + args.whence = whence; + + return (_zip_source_call(src, &args, sizeof(args), ZIP_SOURCE_SEEK_WRITE) < 0 ? -1 : 0); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_stat.c b/thirdparty/libzip-1.11.3/lib/zip_source_stat.c new file mode 100644 index 0000000..7c8baca --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_stat.c @@ -0,0 +1,66 @@ +/* + zip_source_stat.c -- get meta information from zip_source + Copyright (C) 2009-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_source_stat(zip_source_t *src, zip_stat_t *st) { + if (src->source_closed) { + return -1; + } + if (st == NULL) { + zip_error_set(&src->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (src->write_state == ZIP_SOURCE_WRITE_REMOVED) { + zip_error_set(&src->error, ZIP_ER_READ, ENOENT); + } + + zip_stat_init(st); + + if (ZIP_SOURCE_IS_LAYERED(src)) { + if (zip_source_stat(src->src, st) < 0) { + zip_error_set_from_source(&src->error, src->src); + return -1; + } + } + + if (_zip_source_call(src, st, sizeof(*st), ZIP_SOURCE_STAT) < 0) { + return -1; + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_supports.c b/thirdparty/libzip-1.11.3/lib/zip_source_supports.c new file mode 100644 index 0000000..e30ee75 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_supports.c @@ -0,0 +1,74 @@ +/* + zip_source_supports.c -- check for supported functions + Copyright (C) 2014-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +zip_int64_t +zip_source_supports(zip_source_t *src) { + return src->supports; +} + +bool +zip_source_supports_reopen(zip_source_t *src) { + return (zip_source_supports(src) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SUPPORTS_REOPEN)) != 0; +} + +ZIP_EXTERN zip_int64_t +zip_source_make_command_bitmap(zip_source_cmd_t cmd0, ...) { + zip_int64_t bitmap; + va_list ap; + + bitmap = ZIP_SOURCE_MAKE_COMMAND_BITMASK(cmd0); + + + va_start(ap, cmd0); + for (;;) { + int cmd = va_arg(ap, int); + if (cmd < 0) { + break; + } + bitmap |= ZIP_SOURCE_MAKE_COMMAND_BITMASK(cmd); + } + va_end(ap); + + return bitmap; +} + + +ZIP_EXTERN int zip_source_is_seekable(zip_source_t *src) { + return ZIP_SOURCE_CHECK_SUPPORTED(zip_source_supports(src->src), ZIP_SOURCE_SEEK); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_tell.c b/thirdparty/libzip-1.11.3/lib/zip_source_tell.c new file mode 100644 index 0000000..33ec475 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_tell.c @@ -0,0 +1,57 @@ +/* + zip_source_tell.c -- report current offset + Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN zip_int64_t +zip_source_tell(zip_source_t *src) { + if (src->source_closed) { + return -1; + } + if (!ZIP_SOURCE_IS_OPEN_READING(src)) { + zip_error_set(&src->error, ZIP_ER_INVAL, 0); + return -1; + } + + if ((src->supports & (ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_TELL) | ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK))) == 0) { + if (src->bytes_read > ZIP_INT64_MAX) { + zip_error_set(&src->error, ZIP_ER_TELL, EOVERFLOW); + return -1; + } + return (zip_int64_t)src->bytes_read; + } + + return _zip_source_call(src, NULL, 0, ZIP_SOURCE_TELL); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_tell_write.c b/thirdparty/libzip-1.11.3/lib/zip_source_tell_write.c new file mode 100644 index 0000000..6912af9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_tell_write.c @@ -0,0 +1,51 @@ +/* + zip_source_tell_write.c -- report current offset for writing + Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN zip_int64_t +zip_source_tell_write(zip_source_t *src) { + if (ZIP_SOURCE_IS_LAYERED(src)) { + zip_error_set(&src->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + } + + if (!ZIP_SOURCE_IS_OPEN_WRITING(src)) { + zip_error_set(&src->error, ZIP_ER_INVAL, 0); + return -1; + } + + return _zip_source_call(src, NULL, 0, ZIP_SOURCE_TELL_WRITE); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_window.c b/thirdparty/libzip-1.11.3/lib/zip_source_window.c new file mode 100644 index 0000000..eac27c3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_window.c @@ -0,0 +1,379 @@ +/* + zip_source_window.c -- return part of lower source + Copyright (C) 2012-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include + +#include "zipint.h" + +struct window { + zip_uint64_t start; /* where in file we start reading */ + zip_uint64_t end; /* where in file we stop reading */ + bool end_valid; /* whether end is set, otherwise read until EOF */ + + /* if not NULL, read file data for this file */ + zip_t *source_archive; + zip_uint64_t source_index; + + zip_uint64_t offset; /* offset in src for next read */ + + zip_stat_t stat; + zip_uint64_t stat_invalid; + zip_file_attributes_t attributes; + zip_dostime_t dostime; + bool dostime_valid; + zip_error_t error; + zip_int64_t supports; + bool needs_seek; +}; + +static zip_int64_t window_read(zip_source_t *, void *, void *, zip_uint64_t, zip_source_cmd_t); + + +ZIP_EXTERN zip_source_t * +zip_source_window_create(zip_source_t *src, zip_uint64_t start, zip_int64_t len, zip_error_t *error) { + return _zip_source_window_new(src, start, len, NULL, 0, NULL, NULL, NULL, 0, false, error); +} + + +zip_source_t * +_zip_source_window_new(zip_source_t *src, zip_uint64_t start, zip_int64_t length, zip_stat_t *st, zip_uint64_t st_invalid, zip_file_attributes_t *attributes, zip_dostime_t *dostime, zip_t *source_archive, zip_uint64_t source_index, bool take_ownership, zip_error_t *error) { + zip_source_t* window_source; + struct window *ctx; + + if (src == NULL || length < -1 || (source_archive == NULL && source_index != 0)) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + if (length >= 0) { + if (start + (zip_uint64_t)length < start) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + } + + if ((ctx = (struct window *)malloc(sizeof(*ctx))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + ctx->start = start; + if (length == -1) { + ctx->end_valid = false; + } + else { + ctx->end = start + (zip_uint64_t)length; + ctx->end_valid = true; + } + zip_stat_init(&ctx->stat); + ctx->stat_invalid = st_invalid; + if (attributes != NULL) { + (void)memcpy_s(&ctx->attributes, sizeof(ctx->attributes), attributes, sizeof(ctx->attributes)); + } + else { + zip_file_attributes_init(&ctx->attributes); + } + if (dostime != NULL) { + ctx->dostime = *dostime; + ctx->dostime_valid = true; + } + else { + ctx->dostime_valid = false; + } + ctx->source_archive = source_archive; + ctx->source_index = source_index; + zip_error_init(&ctx->error); + ctx->supports = (zip_source_supports(src) & (ZIP_SOURCE_SUPPORTS_SEEKABLE | ZIP_SOURCE_SUPPORTS_REOPEN)) | (zip_source_make_command_bitmap(ZIP_SOURCE_GET_FILE_ATTRIBUTES, ZIP_SOURCE_GET_DOS_TIME, ZIP_SOURCE_SUPPORTS, ZIP_SOURCE_TELL, ZIP_SOURCE_FREE, -1)); + ctx->needs_seek = (ctx->supports & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK)) ? true : false; + + if (st) { + if (_zip_stat_merge(&ctx->stat, st, error) < 0) { + free(ctx); + return NULL; + } + } + + window_source = zip_source_layered_create(src, window_read, ctx, error); + if (window_source != NULL && !take_ownership) { + zip_source_keep(src); + } + return window_source; +} + + +int +_zip_source_set_source_archive(zip_source_t *src, zip_t *za) { + src->source_archive = za; + return _zip_register_source(za, src); +} + + +/* called by zip_discard to avoid operating on file from closed archive */ +void +_zip_source_invalidate(zip_source_t *src) { + src->source_closed = 1; + + if (zip_error_code_zip(&src->error) == ZIP_ER_OK) { + zip_error_set(&src->error, ZIP_ER_ZIPCLOSED, 0); + } +} + + +static zip_int64_t +window_read(zip_source_t *src, void *_ctx, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { + struct window *ctx; + zip_int64_t ret; + zip_uint64_t n, i; + + ctx = (struct window *)_ctx; + + switch (cmd) { + case ZIP_SOURCE_CLOSE: + return 0; + + case ZIP_SOURCE_ERROR: + return zip_error_to_data(&ctx->error, data, len); + + case ZIP_SOURCE_FREE: + free(ctx); + return 0; + + case ZIP_SOURCE_OPEN: + if (ctx->source_archive) { + zip_uint64_t offset; + + if ((offset = _zip_file_get_offset(ctx->source_archive, ctx->source_index, &ctx->error)) == 0) { + return -1; + } + if (ctx->end + offset < ctx->end) { + /* zip archive data claims end of data past zip64 limits */ + zip_error_set(&ctx->error, ZIP_ER_INCONS, MAKE_DETAIL_WITH_INDEX(ZIP_ER_DETAIL_CDIR_ENTRY_INVALID, ctx->source_index)); + return -1; + } + ctx->start += offset; + ctx->end += offset; + ctx->source_archive = NULL; + } + + if (!ctx->needs_seek) { + DEFINE_BYTE_ARRAY(b, BUFSIZE); + + if (!byte_array_init(b, BUFSIZE)) { + zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); + return -1; + } + + for (n = 0; n < ctx->start; n += (zip_uint64_t)ret) { + i = (ctx->start - n > BUFSIZE ? BUFSIZE : ctx->start - n); + if ((ret = zip_source_read(src, b, i)) < 0) { + zip_error_set_from_source(&ctx->error, src); + byte_array_fini(b); + return -1; + } + if (ret == 0) { + zip_error_set(&ctx->error, ZIP_ER_EOF, 0); + byte_array_fini(b); + return -1; + } + } + + byte_array_fini(b); + } + + ctx->offset = ctx->start; + return 0; + + case ZIP_SOURCE_READ: + if (ctx->end_valid && len > ctx->end - ctx->offset) { + len = ctx->end - ctx->offset; + } + + if (len == 0) { + return 0; + } + + if (ctx->needs_seek) { + if (zip_source_seek(src, (zip_int64_t)ctx->offset, SEEK_SET) < 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + } + + if ((ret = zip_source_read(src, data, len)) < 0) { + zip_error_set(&ctx->error, ZIP_ER_EOF, 0); + return -1; + } + + ctx->offset += (zip_uint64_t)ret; + + if (ret == 0) { + if (ctx->end_valid && ctx->offset < ctx->end) { + zip_error_set(&ctx->error, ZIP_ER_EOF, 0); + return -1; + } + } + return ret; + + case ZIP_SOURCE_SEEK: { + zip_int64_t new_offset; + + if (!ctx->end_valid) { + zip_source_args_seek_t *args = ZIP_SOURCE_GET_ARGS(zip_source_args_seek_t, data, len, &ctx->error); + + if (args == NULL) { + return -1; + } + if (args->whence == SEEK_END) { + if (zip_source_seek(src, args->offset, args->whence) < 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + new_offset = zip_source_tell(src); + if (new_offset < 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + if ((zip_uint64_t)new_offset < ctx->start) { + zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); + (void)zip_source_seek(src, (zip_int64_t)ctx->offset, SEEK_SET); + return -1; + } + ctx->offset = (zip_uint64_t)new_offset; + return 0; + } + } + + new_offset = zip_source_seek_compute_offset(ctx->offset - ctx->start, ctx->end - ctx->start, data, len, &ctx->error); + + if (new_offset < 0) { + return -1; + } + + ctx->offset = (zip_uint64_t)new_offset + ctx->start; + return 0; + } + + case ZIP_SOURCE_STAT: { + zip_stat_t *st; + + st = (zip_stat_t *)data; + + if (_zip_stat_merge(st, &ctx->stat, &ctx->error) < 0) { + return -1; + } + + if (!(ctx->stat.valid & ZIP_STAT_SIZE)) { + if (ctx->end_valid) { + st->valid |= ZIP_STAT_SIZE; + st->size = ctx->end - ctx->start; + } + else if (st->valid & ZIP_STAT_SIZE) { + st->size -= ctx->start; + } + } + + st->valid &= ~ctx->stat_invalid; + + return 0; + } + + case ZIP_SOURCE_GET_FILE_ATTRIBUTES: + if (len < sizeof(ctx->attributes)) { + zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); + return -1; + } + + (void)memcpy_s(data, sizeof(ctx->attributes), &ctx->attributes, sizeof(ctx->attributes)); + return sizeof(ctx->attributes); + + case ZIP_SOURCE_GET_DOS_TIME: + if (len < sizeof(ctx->dostime)) { + zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); + return -1; + } + if (ctx->dostime_valid) { + (void)memcpy_s(data, sizeof(ctx->dostime), &ctx->dostime, sizeof(ctx->dostime)); + return sizeof(ctx->dostime); + } + else { + return 0; + } + + case ZIP_SOURCE_SUPPORTS: + return ctx->supports; + + case ZIP_SOURCE_TELL: + return (zip_int64_t)(ctx->offset - ctx->start); + + default: + return zip_source_pass_to_lower_layer(src, data, len, cmd); + } +} + + +void +_zip_deregister_source(zip_t *za, zip_source_t *src) { + unsigned int i; + + for (i = 0; i < za->nopen_source; i++) { + if (za->open_source[i] == src) { + za->open_source[i] = za->open_source[za->nopen_source - 1]; + za->nopen_source--; + break; + } + } +} + + +int +_zip_register_source(zip_t *za, zip_source_t *src) { + zip_source_t **open_source; + + if (za->nopen_source + 1 >= za->nopen_source_alloc) { + unsigned int n; + n = za->nopen_source_alloc + 10; + open_source = (zip_source_t **)realloc(za->open_source, n * sizeof(zip_source_t *)); + if (open_source == NULL) { + zip_error_set(&za->error, ZIP_ER_MEMORY, 0); + return -1; + } + za->nopen_source_alloc = n; + za->open_source = open_source; + } + + za->open_source[za->nopen_source++] = src; + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_winzip_aes_decode.c b/thirdparty/libzip-1.11.3/lib/zip_source_winzip_aes_decode.c new file mode 100644 index 0000000..8830a00 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_winzip_aes_decode.c @@ -0,0 +1,265 @@ +/* + zip_source_winzip_aes_decode.c -- Winzip AES decryption routines + Copyright (C) 2009-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include + +#include "zipint.h" +#include "zip_crypto.h" + +struct winzip_aes { + char *password; + zip_uint16_t encryption_method; + + zip_uint64_t data_length; + zip_uint64_t current_position; + + zip_winzip_aes_t *aes_ctx; + zip_error_t error; +}; + + +static int decrypt_header(zip_source_t *src, struct winzip_aes *ctx); +static void winzip_aes_free(struct winzip_aes *); +static zip_int64_t winzip_aes_decrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t len, zip_source_cmd_t cmd); +static struct winzip_aes *winzip_aes_new(zip_uint16_t encryption_method, const char *password, zip_error_t *error); + + +zip_source_t * +zip_source_winzip_aes_decode(zip_t *za, zip_source_t *src, zip_uint16_t encryption_method, int flags, const char *password) { + zip_source_t *s2; + zip_stat_t st; + zip_uint64_t aux_length; + struct winzip_aes *ctx; + + if ((encryption_method != ZIP_EM_AES_128 && encryption_method != ZIP_EM_AES_192 && encryption_method != ZIP_EM_AES_256) || password == NULL || src == NULL) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + if (flags & ZIP_CODEC_ENCODE) { + zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0); + return NULL; + } + + if (zip_source_stat(src, &st) != 0) { + zip_error_set_from_source(&za->error, src); + return NULL; + } + + aux_length = WINZIP_AES_PASSWORD_VERIFY_LENGTH + SALT_LENGTH(encryption_method) + HMAC_LENGTH; + + if ((st.valid & ZIP_STAT_COMP_SIZE) == 0 || st.comp_size < aux_length) { + zip_error_set(&za->error, ZIP_ER_OPNOTSUPP, 0); + return NULL; + } + + if ((ctx = winzip_aes_new(encryption_method, password, &za->error)) == NULL) { + return NULL; + } + + ctx->data_length = st.comp_size - aux_length; + + if ((s2 = zip_source_layered(za, src, winzip_aes_decrypt, ctx)) == NULL) { + winzip_aes_free(ctx); + return NULL; + } + + return s2; +} + + +static int +decrypt_header(zip_source_t *src, struct winzip_aes *ctx) { + zip_uint8_t header[WINZIP_AES_MAX_HEADER_LENGTH]; + zip_uint8_t password_verification[WINZIP_AES_PASSWORD_VERIFY_LENGTH]; + unsigned int headerlen; + zip_int64_t n; + + headerlen = WINZIP_AES_PASSWORD_VERIFY_LENGTH + SALT_LENGTH(ctx->encryption_method); + if ((n = zip_source_read(src, header, headerlen)) < 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + + if (n != headerlen) { + zip_error_set(&ctx->error, ZIP_ER_EOF, 0); + return -1; + } + + if ((ctx->aes_ctx = _zip_winzip_aes_new((zip_uint8_t *)ctx->password, strlen(ctx->password), header, ctx->encryption_method, password_verification, &ctx->error)) == NULL) { + return -1; + } + if (memcmp(password_verification, header + SALT_LENGTH(ctx->encryption_method), WINZIP_AES_PASSWORD_VERIFY_LENGTH) != 0) { + _zip_winzip_aes_free(ctx->aes_ctx); + ctx->aes_ctx = NULL; + zip_error_set(&ctx->error, ZIP_ER_WRONGPASSWD, 0); + return -1; + } + return 0; +} + + +static bool +verify_hmac(zip_source_t *src, struct winzip_aes *ctx) { + unsigned char computed[ZIP_CRYPTO_SHA1_LENGTH], from_file[HMAC_LENGTH]; + if (zip_source_read(src, from_file, HMAC_LENGTH) < HMAC_LENGTH) { + zip_error_set_from_source(&ctx->error, src); + return false; + } + + if (!_zip_winzip_aes_finish(ctx->aes_ctx, computed)) { + zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); + return false; + } + _zip_winzip_aes_free(ctx->aes_ctx); + ctx->aes_ctx = NULL; + + if (memcmp(from_file, computed, HMAC_LENGTH) != 0) { + zip_error_set(&ctx->error, ZIP_ER_CRC, 0); + return false; + } + + return true; +} + + +static zip_int64_t +winzip_aes_decrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { + struct winzip_aes *ctx; + zip_int64_t n; + + ctx = (struct winzip_aes *)ud; + + switch (cmd) { + case ZIP_SOURCE_OPEN: + if (decrypt_header(src, ctx) < 0) { + return -1; + } + ctx->current_position = 0; + return 0; + + case ZIP_SOURCE_READ: + if (len > ctx->data_length - ctx->current_position) { + len = ctx->data_length - ctx->current_position; + } + + if (len == 0) { + if (!verify_hmac(src, ctx)) { + return -1; + } + return 0; + } + + if ((n = zip_source_read(src, data, len)) < 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + ctx->current_position += (zip_uint64_t)n; + + if (!_zip_winzip_aes_decrypt(ctx->aes_ctx, (zip_uint8_t *)data, (zip_uint64_t)n)) { + zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); + return -1; + } + + return n; + + case ZIP_SOURCE_CLOSE: + return 0; + + case ZIP_SOURCE_STAT: { + zip_stat_t *st; + + st = (zip_stat_t *)data; + + st->encryption_method = ZIP_EM_NONE; + st->valid |= ZIP_STAT_ENCRYPTION_METHOD; + if (st->valid & ZIP_STAT_COMP_SIZE) { + st->comp_size -= 12 + SALT_LENGTH(ctx->encryption_method); + } + + return 0; + } + + case ZIP_SOURCE_SUPPORTS: + return zip_source_make_command_bitmap(ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_STAT, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_SUPPORTS_REOPEN, -1); + + case ZIP_SOURCE_ERROR: + return zip_error_to_data(&ctx->error, data, len); + + case ZIP_SOURCE_FREE: + winzip_aes_free(ctx); + return 0; + + default: + return zip_source_pass_to_lower_layer(src, data, len, cmd); + } +} + + +static void +winzip_aes_free(struct winzip_aes *ctx) { + if (ctx == NULL) { + return; + } + + _zip_crypto_clear(ctx->password, strlen(ctx->password)); + free(ctx->password); + zip_error_fini(&ctx->error); + _zip_winzip_aes_free(ctx->aes_ctx); + free(ctx); +} + + +static struct winzip_aes * +winzip_aes_new(zip_uint16_t encryption_method, const char *password, zip_error_t *error) { + struct winzip_aes *ctx; + + if ((ctx = (struct winzip_aes *)malloc(sizeof(*ctx))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if ((ctx->password = strdup(password)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + free(ctx); + return NULL; + } + + ctx->encryption_method = encryption_method; + ctx->aes_ctx = NULL; + + zip_error_init(&ctx->error); + + return ctx; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_winzip_aes_encode.c b/thirdparty/libzip-1.11.3/lib/zip_source_winzip_aes_encode.c new file mode 100644 index 0000000..c704b12 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_winzip_aes_encode.c @@ -0,0 +1,253 @@ +/* + zip_source_winzip_aes_encode.c -- Winzip AES encryption routines + Copyright (C) 2009-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include + +#include "zipint.h" +#include "zip_crypto.h" + +struct winzip_aes { + char *password; + zip_uint16_t encryption_method; + + zip_uint8_t data[ZIP_MAX(WINZIP_AES_MAX_HEADER_LENGTH, ZIP_CRYPTO_SHA1_LENGTH)]; + zip_buffer_t *buffer; + + zip_winzip_aes_t *aes_ctx; + bool eof; + zip_error_t error; +}; + + +static int encrypt_header(zip_source_t *src, struct winzip_aes *ctx); +static void winzip_aes_free(struct winzip_aes *); +static zip_int64_t winzip_aes_encrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t len, zip_source_cmd_t cmd); +static struct winzip_aes *winzip_aes_new(zip_uint16_t encryption_method, const char *password, zip_error_t *error); + + +zip_source_t * +zip_source_winzip_aes_encode(zip_t *za, zip_source_t *src, zip_uint16_t encryption_method, int flags, const char *password) { + zip_source_t *s2; + struct winzip_aes *ctx; + + if ((encryption_method != ZIP_EM_AES_128 && encryption_method != ZIP_EM_AES_192 && encryption_method != ZIP_EM_AES_256) || password == NULL || src == NULL) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((ctx = winzip_aes_new(encryption_method, password, &za->error)) == NULL) { + return NULL; + } + + if ((s2 = zip_source_layered(za, src, winzip_aes_encrypt, ctx)) == NULL) { + winzip_aes_free(ctx); + return NULL; + } + + return s2; +} + + +static int +encrypt_header(zip_source_t *src, struct winzip_aes *ctx) { + zip_uint16_t salt_length = SALT_LENGTH(ctx->encryption_method); + if (!zip_secure_random(ctx->data, salt_length)) { + zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); + return -1; + } + + if ((ctx->aes_ctx = _zip_winzip_aes_new((zip_uint8_t *)ctx->password, strlen(ctx->password), ctx->data, ctx->encryption_method, ctx->data + salt_length, &ctx->error)) == NULL) { + return -1; + } + + if ((ctx->buffer = _zip_buffer_new(ctx->data, salt_length + WINZIP_AES_PASSWORD_VERIFY_LENGTH)) == NULL) { + _zip_winzip_aes_free(ctx->aes_ctx); + ctx->aes_ctx = NULL; + zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); + return -1; + } + + return 0; +} + + +static zip_int64_t +winzip_aes_encrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t length, zip_source_cmd_t cmd) { + struct winzip_aes *ctx; + zip_int64_t ret; + zip_uint64_t buffer_n; + + ctx = (struct winzip_aes *)ud; + + switch (cmd) { + case ZIP_SOURCE_OPEN: + ctx->eof = false; + if (encrypt_header(src, ctx) < 0) { + return -1; + } + return 0; + + case ZIP_SOURCE_READ: + buffer_n = 0; + + if (ctx->buffer) { + buffer_n = _zip_buffer_read(ctx->buffer, data, length); + + data = (zip_uint8_t *)data + buffer_n; + length -= buffer_n; + + if (_zip_buffer_eof(ctx->buffer)) { + _zip_buffer_free(ctx->buffer); + ctx->buffer = NULL; + } + } + + if (ctx->eof) { + return (zip_int64_t)buffer_n; + } + + if ((ret = zip_source_read(src, data, length)) < 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + + if (!_zip_winzip_aes_encrypt(ctx->aes_ctx, data, (zip_uint64_t)ret)) { + zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); + /* TODO: return partial read? */ + return -1; + } + + if ((zip_uint64_t)ret < length) { + ctx->eof = true; + if (!_zip_winzip_aes_finish(ctx->aes_ctx, ctx->data)) { + zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); + /* TODO: return partial read? */ + return -1; + } + _zip_winzip_aes_free(ctx->aes_ctx); + ctx->aes_ctx = NULL; + if ((ctx->buffer = _zip_buffer_new(ctx->data, HMAC_LENGTH)) == NULL) { + zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); + /* TODO: return partial read? */ + return -1; + } + buffer_n += _zip_buffer_read(ctx->buffer, (zip_uint8_t *)data + ret, length - (zip_uint64_t)ret); + } + + return (zip_int64_t)(buffer_n + (zip_uint64_t)ret); + + case ZIP_SOURCE_CLOSE: + return 0; + + case ZIP_SOURCE_STAT: { + zip_stat_t *st; + + st = (zip_stat_t *)data; + st->encryption_method = ctx->encryption_method; + st->valid |= ZIP_STAT_ENCRYPTION_METHOD; + if (st->valid & ZIP_STAT_COMP_SIZE) { + st->comp_size += 12 + SALT_LENGTH(ctx->encryption_method); + } + + return 0; + } + + case ZIP_SOURCE_GET_FILE_ATTRIBUTES: { + zip_file_attributes_t *attributes = (zip_file_attributes_t *)data; + if (length < sizeof(*attributes)) { + zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); + return -1; + } + attributes->valid |= ZIP_FILE_ATTRIBUTES_VERSION_NEEDED; + attributes->version_needed = 51; + + return 0; + } + + case ZIP_SOURCE_SUPPORTS: + return zip_source_make_command_bitmap(ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_STAT, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_GET_FILE_ATTRIBUTES, -1); + + case ZIP_SOURCE_ERROR: + return zip_error_to_data(&ctx->error, data, length); + + case ZIP_SOURCE_FREE: + winzip_aes_free(ctx); + return 0; + + default: + return zip_source_pass_to_lower_layer(src, data, length, cmd); + } +} + + +static void +winzip_aes_free(struct winzip_aes *ctx) { + if (ctx == NULL) { + return; + } + + _zip_crypto_clear(ctx->password, strlen(ctx->password)); + free(ctx->password); + zip_error_fini(&ctx->error); + _zip_buffer_free(ctx->buffer); + _zip_winzip_aes_free(ctx->aes_ctx); + free(ctx); +} + + +static struct winzip_aes * +winzip_aes_new(zip_uint16_t encryption_method, const char *password, zip_error_t *error) { + struct winzip_aes *ctx; + + if ((ctx = (struct winzip_aes *)malloc(sizeof(*ctx))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if ((ctx->password = strdup(password)) == NULL) { + free(ctx); + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + ctx->encryption_method = encryption_method; + ctx->buffer = NULL; + ctx->aes_ctx = NULL; + + zip_error_init(&ctx->error); + + ctx->eof = false; + return ctx; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_write.c b/thirdparty/libzip-1.11.3/lib/zip_source_write.c new file mode 100644 index 0000000..20ca361 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_write.c @@ -0,0 +1,46 @@ +/* + zip_source_write.c -- start a new file for writing + Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN zip_int64_t +zip_source_write(zip_source_t *src, const void *data, zip_uint64_t length) { + if (!ZIP_SOURCE_IS_OPEN_WRITING(src) || length > ZIP_INT64_MAX) { + zip_error_set(&src->error, ZIP_ER_INVAL, 0); + return -1; + } + + return _zip_source_call(src, (void *)data, length, ZIP_SOURCE_WRITE); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_zip.c b/thirdparty/libzip-1.11.3/lib/zip_source_zip.c new file mode 100644 index 0000000..0781986 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_zip.c @@ -0,0 +1,63 @@ +/* + zip_source_zip.c -- create data source from zip file + Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#define _ZIP_COMPILING_DEPRECATED +#include "zipint.h" + +ZIP_EXTERN zip_source_t *zip_source_zip_create(zip_t *srcza, zip_uint64_t srcidx, zip_flags_t flags, zip_uint64_t start, zip_int64_t len, zip_error_t *error) { + if (len < -1) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + if (len == 0) { + len = -1; + } + + if (start == 0 && len == -1) { + flags |= ZIP_FL_COMPRESSED; + } + else { + flags &= ~ZIP_FL_COMPRESSED; + } + + return zip_source_zip_file_create(srcza, srcidx, flags, start, len, NULL, error); +} + + +ZIP_EXTERN zip_source_t *zip_source_zip(zip_t *za, zip_t *srcza, zip_uint64_t srcidx, zip_flags_t flags, zip_uint64_t start, zip_int64_t len) { + return zip_source_zip_create(srcza, srcidx, flags, start, len, &za->error); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_source_zip_new.c b/thirdparty/libzip-1.11.3/lib/zip_source_zip_new.c new file mode 100644 index 0000000..3eb8a4c --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_source_zip_new.c @@ -0,0 +1,313 @@ +/* + zip_source_zip_new.c -- prepare data structures for zip_fopen/zip_source_zip + Copyright (C) 2012-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + +static void _zip_file_attributes_from_dirent(zip_file_attributes_t *attributes, zip_dirent_t *de); + +ZIP_EXTERN zip_source_t *zip_source_zip_file(zip_t* za, zip_t *srcza, zip_uint64_t srcidx, zip_flags_t flags, zip_uint64_t start, zip_int64_t len, const char *password) { + return zip_source_zip_file_create(srcza, srcidx, flags, start, len, password, &za->error); +} + + +ZIP_EXTERN zip_source_t *zip_source_zip_file_create(zip_t *srcza, zip_uint64_t srcidx, zip_flags_t flags, zip_uint64_t start, zip_int64_t len, const char *password, zip_error_t *error) { + /* TODO: We need to make sure that the returned source is invalidated when srcza is closed. */ + zip_source_t *src, *s2; + zip_stat_t st; + zip_file_attributes_t attributes; + zip_dirent_t *de; + bool partial_data, needs_crc, encrypted, needs_decrypt, compressed, needs_decompress, changed_data, have_size, have_comp_size; + zip_flags_t stat_flags; + zip_int64_t data_len; + bool take_ownership = false; + bool empty_data = false; + + if (srcza == NULL || srcidx >= srcza->nentry || len < -1) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + if (flags & ZIP_FL_ENCRYPTED) { + flags |= ZIP_FL_COMPRESSED; + } + + changed_data = false; + if ((flags & ZIP_FL_UNCHANGED) == 0) { + zip_entry_t *entry = srcza->entry + srcidx; + if (ZIP_ENTRY_DATA_CHANGED(entry)) { + if ((flags & ZIP_FL_COMPRESSED) || !zip_source_supports_reopen(entry->source)) { + zip_error_set(error, ZIP_ER_CHANGED, 0); + return NULL; + } + + changed_data = true; + } + else if (entry->deleted) { + zip_error_set(error, ZIP_ER_CHANGED, 0); + return NULL; + } + } + + stat_flags = flags; + if (!changed_data) { + stat_flags |= ZIP_FL_UNCHANGED; + } + + if (zip_stat_index(srcza, srcidx, stat_flags, &st) < 0) { + zip_error_set(error, ZIP_ER_INTERNAL, 0); + return NULL; + } + + if ((start > 0 || len >= 0) && (flags & ZIP_FL_COMPRESSED)) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + have_size = (st.valid & ZIP_STAT_SIZE) != 0; + /* overflow or past end of file */ + if (len >= 0 && ((start > 0 && start + len < start) || (have_size && start + len > st.size))) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + if (len == -1) { + if (have_size) { + if (st.size - start > ZIP_INT64_MAX) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + data_len = (zip_int64_t)(st.size - start); + } + else { + data_len = -1; + } + } + else { + data_len = len; + } + + if (have_size) { + partial_data = (zip_uint64_t)(data_len) < st.size; + } + else { + partial_data = true; + } + encrypted = (st.valid & ZIP_STAT_ENCRYPTION_METHOD) && (st.encryption_method != ZIP_EM_NONE); + needs_decrypt = ((flags & ZIP_FL_ENCRYPTED) == 0) && encrypted; + compressed = (st.valid & ZIP_STAT_COMP_METHOD) && (st.comp_method != ZIP_CM_STORE); + needs_decompress = ((flags & ZIP_FL_COMPRESSED) == 0) && compressed; + /* when reading the whole file, check for CRC errors */ + needs_crc = ((flags & ZIP_FL_COMPRESSED) == 0 || !compressed) && !partial_data && (st.valid & ZIP_STAT_CRC) != 0; + + if (needs_decrypt) { + if (password == NULL) { + password = srcza->default_password; + } + if (password == NULL) { + zip_error_set(error, ZIP_ER_NOPASSWD, 0); + return NULL; + } + } + + if ((de = _zip_get_dirent(srcza, srcidx, flags, error)) == NULL) { + return NULL; + } + _zip_file_attributes_from_dirent(&attributes, de); + + have_comp_size = (st.valid & ZIP_STAT_COMP_SIZE) != 0; + if (needs_decrypt || needs_decompress) { + empty_data = (have_comp_size && st.comp_size == 0); + } + else { + empty_data = (have_size && st.size == 0); + } + if (empty_data) { + src = zip_source_buffer_with_attributes_create(NULL, 0, 0, &attributes, error); + } + else { + src = NULL; + } + + + /* If we created source buffer above, we want the window source to take ownership of it. */ + take_ownership = src != NULL; + /* if we created a buffer source above, then treat it as if + reading the changed data - that way we don't need add another + special case to the code below that wraps it in the window + source */ + changed_data = changed_data || (src != NULL); + + if (partial_data && !needs_decrypt && !needs_decompress) { + struct zip_stat st2; + zip_t *source_archive; + zip_uint64_t source_index; + + if (changed_data) { + if (src == NULL) { + src = srcza->entry[srcidx].source; + } + source_archive = NULL; + source_index = 0; + } + else { + src = srcza->src; + source_archive = srcza; + source_index = srcidx; + } + + st2.comp_method = ZIP_CM_STORE; + st2.valid = ZIP_STAT_COMP_METHOD; + if (data_len >= 0) { + st2.size = (zip_uint64_t)data_len; + st2.comp_size = (zip_uint64_t)data_len; + st2.valid |= ZIP_STAT_SIZE | ZIP_STAT_COMP_SIZE; + } + if (st.valid & ZIP_STAT_MTIME) { + st2.mtime = st.mtime; + st2.valid |= ZIP_STAT_MTIME; + } + + if ((src = _zip_source_window_new(src, start, data_len, &st2, ZIP_STAT_NAME, &attributes, &de->last_mod, source_archive, source_index, take_ownership, error)) == NULL) { + return NULL; + } + } + /* here we restrict src to file data, so no point in doing it for + source that already represents only the file data */ + else if (!changed_data) { + /* this branch is executed only for archive sources; we know + that stat data come from the archive too, so it's safe to + assume that st has a comp_size specified */ + if (st.comp_size > ZIP_INT64_MAX) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + /* despite the fact that we want the whole data file, we still + wrap the source into a window source to add st and + attributes and to have a source that positions the read + offset properly before each read for multiple zip_file_t + referring to the same underlying source */ + if ((src = _zip_source_window_new(srcza->src, 0, (zip_int64_t)st.comp_size, &st, ZIP_STAT_NAME, &attributes, &de->last_mod, srcza, srcidx, take_ownership, error)) == NULL) { + return NULL; + } + } + else { + /* this branch gets executed when reading the whole changed + data file or when "reading" from a zero-sized source buffer + that we created above */ + if (src == NULL) { + src = srcza->entry[srcidx].source; + } + /* despite the fact that we want the whole data file, we still + wrap the source into a window source to add st and + attributes and to have a source that positions the read + offset properly before each read for multiple zip_file_t + referring to the same underlying source */ + if ((src = _zip_source_window_new(src, 0, data_len, &st, ZIP_STAT_NAME, &attributes, &de->last_mod, NULL, 0, take_ownership, error)) == NULL) { + return NULL; + } + } + + /* In all cases, src is a window source and therefore is owned by this function. */ + + if (_zip_source_set_source_archive(src, srcza) < 0) { + zip_source_free(src); + return NULL; + } + + /* creating a layered source calls zip_keep() on the lower layer, so we free it */ + + if (needs_decrypt) { + zip_encryption_implementation enc_impl; + + if ((enc_impl = _zip_get_encryption_implementation(st.encryption_method, ZIP_CODEC_DECODE)) == NULL) { + zip_source_free(src); + zip_error_set(error, ZIP_ER_ENCRNOTSUPP, 0); + return NULL; + } + + s2 = enc_impl(srcza, src, st.encryption_method, 0, password); + if (s2 == NULL) { + zip_source_free(src); + return NULL; + } + + src = s2; + } + if (needs_decompress) { + s2 = zip_source_decompress(srcza, src, st.comp_method); + if (s2 == NULL) { + zip_source_free(src); + return NULL; + } + src = s2; + } + if (needs_crc) { + s2 = zip_source_crc_create(src, 1, error); + if (s2 == NULL) { + zip_source_free(src); + return NULL; + } + src = s2; + } + + if (partial_data && (needs_decrypt || needs_decompress)) { + zip_stat_t st2; + zip_stat_init(&st2); + if (data_len >= 0) { + st2.valid = ZIP_STAT_SIZE; + st2.size = (zip_uint64_t)data_len; + } + s2 = _zip_source_window_new(src, start, data_len, &st2, ZIP_STAT_NAME, NULL, NULL, NULL, 0, true, error); + if (s2 == NULL) { + zip_source_free(src); + return NULL; + } + src = s2; + } + + return src; +} + +static void +_zip_file_attributes_from_dirent(zip_file_attributes_t *attributes, zip_dirent_t *de) { + zip_file_attributes_init(attributes); + attributes->valid = ZIP_FILE_ATTRIBUTES_ASCII | ZIP_FILE_ATTRIBUTES_HOST_SYSTEM | ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES | ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS; + attributes->ascii = de->int_attrib & 1; + attributes->host_system = de->version_madeby >> 8; + attributes->external_file_attributes = de->ext_attrib; + attributes->general_purpose_bit_flags = de->bitflags; + attributes->general_purpose_bit_mask = ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS_ALLOWED_MASK; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_stat.c b/thirdparty/libzip-1.11.3/lib/zip_stat.c new file mode 100644 index 0000000..74fc5c3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_stat.c @@ -0,0 +1,46 @@ +/* + zip_stat.c -- get information about file by name + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_stat(zip_t *za, const char *fname, zip_flags_t flags, zip_stat_t *st) { + zip_int64_t idx; + + if ((idx = zip_name_locate(za, fname, flags)) < 0) + return -1; + + return zip_stat_index(za, (zip_uint64_t)idx, flags, st); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_stat_index.c b/thirdparty/libzip-1.11.3/lib/zip_stat_index.c new file mode 100644 index 0000000..af9f0e5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_stat_index.c @@ -0,0 +1,115 @@ +/* + zip_stat_index.c -- get information about file by index + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_stat_index(zip_t *za, zip_uint64_t index, zip_flags_t flags, zip_stat_t *st) { + const char *name; + zip_dirent_t *de; + zip_entry_t *entry; + + if ((de = _zip_get_dirent(za, index, flags, NULL)) == NULL) { + return -1; + } + + if ((name = zip_get_name(za, index, flags)) == NULL) { + return -1; + } + + entry = za->entry + index; + + if ((flags & ZIP_FL_UNCHANGED) == 0 && ZIP_ENTRY_DATA_CHANGED(za->entry + index)) { + + if (zip_source_stat(entry->source, st) < 0) { + zip_error_set(&za->error, ZIP_ER_CHANGED, 0); + return -1; + } + + if (ZIP_CM_IS_DEFAULT(de->comp_method)) { + if (!(st->valid & ZIP_STAT_COMP_METHOD) || st->comp_method == ZIP_CM_STORE) { + st->valid &= ~(ZIP_STAT_COMP_SIZE|ZIP_STAT_COMP_METHOD); + } + } + else { + if ((st->valid & ZIP_STAT_COMP_METHOD) && st->comp_method != de->comp_method) { + st->valid &= ~ZIP_STAT_COMP_SIZE; + } + st->valid |= ZIP_STAT_COMP_METHOD; + st->comp_method = de->comp_method; + } + + if (((st->valid & (ZIP_STAT_COMP_METHOD|ZIP_STAT_SIZE)) == (ZIP_STAT_COMP_METHOD|ZIP_STAT_SIZE)) && st->comp_method == ZIP_CM_STORE) { + st->valid |= ZIP_STAT_COMP_SIZE; + st->comp_size = st->size; + } + + if (entry->changes != NULL && entry->changes->changed & ZIP_DIRENT_LAST_MOD) { + st->mtime = zip_dirent_get_last_mod_mtime(de); + st->valid |= ZIP_STAT_MTIME; + } + } + else { + zip_stat_init(st); + + st->crc = de->crc; + st->size = de->uncomp_size; + st->mtime = zip_dirent_get_last_mod_mtime(de); + st->comp_size = de->comp_size; + st->comp_method = (zip_uint16_t)de->comp_method; + st->encryption_method = de->encryption_method; + st->valid = (de->crc_valid ? ZIP_STAT_CRC : 0) | ZIP_STAT_SIZE | ZIP_STAT_MTIME | ZIP_STAT_COMP_SIZE | ZIP_STAT_COMP_METHOD | ZIP_STAT_ENCRYPTION_METHOD; + if (entry->changes != NULL && entry->changes->changed & ZIP_DIRENT_COMP_METHOD) { + st->valid &= ~ZIP_STAT_COMP_SIZE; + } + } + + if ((za->ch_flags & ZIP_AFL_WANT_TORRENTZIP) && (flags & ZIP_FL_UNCHANGED) == 0) { + if (za->torrent_mtime == 0) { + zip_dostime_t dostime = {0xbc00, 0x2198}; + za->torrent_mtime = _zip_d2u_time(&dostime); + } + st->comp_method = ZIP_CM_DEFLATE; + st->mtime = za->torrent_mtime; + st->valid |= ZIP_STAT_MTIME | ZIP_STAT_COMP_METHOD; + st->valid &= ~ZIP_STAT_COMP_SIZE; + } + + st->index = index; + st->name = name; + st->valid |= ZIP_STAT_INDEX | ZIP_STAT_NAME; + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_stat_init.c b/thirdparty/libzip-1.11.3/lib/zip_stat_init.c new file mode 100644 index 0000000..bd83565 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_stat_init.c @@ -0,0 +1,83 @@ +/* + zip_stat_init.c -- initialize struct zip_stat. + Copyright (C) 2006-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include "zipint.h" + + +ZIP_EXTERN void +zip_stat_init(zip_stat_t *st) { + st->valid = 0; + st->name = NULL; + st->index = ZIP_UINT64_MAX; + st->crc = 0; + st->mtime = (time_t)-1; + st->size = 0; + st->comp_size = 0; + st->comp_method = ZIP_CM_STORE; + st->encryption_method = ZIP_EM_NONE; +} + + +int +_zip_stat_merge(zip_stat_t *dst, const zip_stat_t *src, zip_error_t *error) { + /* name is not merged, since zip_stat_t doesn't own it, and src may not be valid as long as dst */ + if (src->valid & ZIP_STAT_INDEX) { + dst->index = src->index; + } + if (src->valid & ZIP_STAT_SIZE) { + dst->size = src->size; + } + if (src->valid & ZIP_STAT_COMP_SIZE) { + dst->comp_size = src->comp_size; + } + if (src->valid & ZIP_STAT_MTIME) { + dst->mtime = src->mtime; + } + if (src->valid & ZIP_STAT_CRC) { + dst->crc = src->crc; + } + if (src->valid & ZIP_STAT_COMP_METHOD) { + dst->comp_method = src->comp_method; + } + if (src->valid & ZIP_STAT_ENCRYPTION_METHOD) { + dst->encryption_method = src->encryption_method; + } + if (src->valid & ZIP_STAT_FLAGS) { + dst->flags = src->flags; + } + dst->valid |= src->valid; + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_strerror.c b/thirdparty/libzip-1.11.3/lib/zip_strerror.c new file mode 100644 index 0000000..681024a --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_strerror.c @@ -0,0 +1,41 @@ +/* + zip_sterror.c -- get string representation of zip error + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN const char * +zip_strerror(zip_t *za) { + return zip_error_strerror(&za->error); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_string.c b/thirdparty/libzip-1.11.3/lib/zip_string.c new file mode 100644 index 0000000..bb06c1d --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_string.c @@ -0,0 +1,194 @@ +/* + zip_string.c -- string handling (with encoding) + Copyright (C) 2012-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include +#include + +#include "zipint.h" + +zip_uint32_t +_zip_string_crc32(const zip_string_t *s) { + zip_uint32_t crc; + + crc = (zip_uint32_t)crc32(0L, Z_NULL, 0); + + if (s != NULL) + crc = (zip_uint32_t)crc32(crc, s->raw, s->length); + + return crc; +} + + +int +_zip_string_equal(const zip_string_t *a, const zip_string_t *b) { + if (a == NULL || b == NULL) + return a == b; + + if (a->length != b->length) + return 0; + + /* TODO: encoding */ + + return (memcmp(a->raw, b->raw, a->length) == 0); +} + + +void +_zip_string_free(zip_string_t *s) { + if (s == NULL) + return; + + free(s->raw); + free(s->converted); + free(s); +} + + +const zip_uint8_t * +_zip_string_get(zip_string_t *string, zip_uint32_t *lenp, zip_flags_t flags, zip_error_t *error) { + static const zip_uint8_t empty[1] = ""; + + if (string == NULL) { + if (lenp) + *lenp = 0; + return empty; + } + + if ((flags & ZIP_FL_ENC_RAW) == 0) { + /* start guessing */ + if (string->encoding == ZIP_ENCODING_UNKNOWN) { + /* guess encoding, sets string->encoding */ + (void)_zip_guess_encoding(string, ZIP_ENCODING_UNKNOWN); + } + + if (((flags & ZIP_FL_ENC_STRICT) && string->encoding != ZIP_ENCODING_ASCII && string->encoding != ZIP_ENCODING_UTF8_KNOWN) || (string->encoding == ZIP_ENCODING_CP437)) { + if (string->converted == NULL) { + if ((string->converted = _zip_cp437_to_utf8(string->raw, string->length, &string->converted_length, error)) == NULL) + return NULL; + } + if (lenp) + *lenp = string->converted_length; + return string->converted; + } + } + + if (lenp) + *lenp = string->length; + return string->raw; +} + +bool _zip_string_is_ascii(const zip_string_t *string) { + if (string->encoding != ZIP_ENCODING_ASCII) { + zip_uint16_t i; + + for (i = 0; i < string->length; i++) { + if (string->raw[i] & 0x80) { + return false; + } + } + } + + return true; +} + + +zip_uint16_t +_zip_string_length(const zip_string_t *s) { + if (s == NULL) + return 0; + + return s->length; +} + + +zip_string_t * +_zip_string_new(const zip_uint8_t *raw, zip_uint16_t length, zip_flags_t flags, zip_error_t *error) { + zip_string_t *s; + zip_encoding_type_t expected_encoding; + + if (length == 0) + return NULL; + + switch (flags & ZIP_FL_ENCODING_ALL) { + case ZIP_FL_ENC_GUESS: + expected_encoding = ZIP_ENCODING_UNKNOWN; + break; + case ZIP_FL_ENC_UTF_8: + expected_encoding = ZIP_ENCODING_UTF8_KNOWN; + break; + case ZIP_FL_ENC_CP437: + expected_encoding = ZIP_ENCODING_CP437; + break; + default: + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + if ((s = (zip_string_t *)malloc(sizeof(*s))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if ((s->raw = (zip_uint8_t *)malloc((size_t)length + 1)) == NULL) { + free(s); + return NULL; + } + + (void)memcpy_s(s->raw, length + 1, raw, length); + s->raw[length] = '\0'; + s->length = length; + s->encoding = ZIP_ENCODING_UNKNOWN; + s->converted = NULL; + s->converted_length = 0; + + if (expected_encoding != ZIP_ENCODING_UNKNOWN) { + if (_zip_guess_encoding(s, expected_encoding) == ZIP_ENCODING_ERROR) { + _zip_string_free(s); + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + } + + return s; +} + + +int +_zip_string_write(zip_t *za, const zip_string_t *s) { + if (s == NULL) + return 0; + + return _zip_write(za, s->raw, s->length); +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_unchange.c b/thirdparty/libzip-1.11.3/lib/zip_unchange.c new file mode 100644 index 0000000..d69a3df --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_unchange.c @@ -0,0 +1,98 @@ +/* + zip_unchange.c -- undo changes to file in zip archive + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +ZIP_EXTERN int +zip_unchange(zip_t *za, zip_uint64_t idx) { + return _zip_unchange(za, idx, 0); +} + + +int +_zip_unchange(zip_t *za, zip_uint64_t idx, int allow_duplicates) { + zip_int64_t i; + bool renamed; + + if (idx >= za->nentry) { + zip_error_set(&za->error, ZIP_ER_INVAL, 0); + return -1; + } + + renamed = za->entry[idx].changes && (za->entry[idx].changes->changed & ZIP_DIRENT_FILENAME); + if (!allow_duplicates && (renamed || za->entry[idx].deleted)) { + const char *orig_name = NULL; + const char *changed_name = NULL; + + if (za->entry[idx].orig != NULL) { + if ((orig_name = _zip_get_name(za, idx, ZIP_FL_UNCHANGED, &za->error)) == NULL) { + return -1; + } + + i = _zip_name_locate(za, orig_name, 0, NULL); + if (i >= 0 && (zip_uint64_t)i != idx) { + zip_error_set(&za->error, ZIP_ER_EXISTS, 0); + return -1; + } + } + + if (renamed) { + if ((changed_name = _zip_get_name(za, idx, 0, &za->error)) == NULL) { + return -1; + } + } + + if (orig_name) { + if (_zip_hash_add(za->names, (const zip_uint8_t *)orig_name, idx, 0, &za->error) == false) { + return -1; + } + } + if (changed_name) { + if (_zip_hash_delete(za->names, (const zip_uint8_t *)changed_name, &za->error) == false) { + _zip_hash_delete(za->names, (const zip_uint8_t *)orig_name, NULL); + return -1; + } + } + } + + _zip_dirent_free(za->entry[idx].changes); + za->entry[idx].changes = NULL; + + _zip_unchange_data(za->entry + idx); + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_unchange_all.c b/thirdparty/libzip-1.11.3/lib/zip_unchange_all.c new file mode 100644 index 0000000..0b22c80 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_unchange_all.c @@ -0,0 +1,54 @@ +/* + zip_unchange.c -- undo changes to all files in zip archive + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + + +ZIP_EXTERN int +zip_unchange_all(zip_t *za) { + int ret; + zip_uint64_t i; + + if (!_zip_hash_revert(za->names, &za->error)) { + return -1; + } + + ret = 0; + for (i = 0; i < za->nentry; i++) + ret |= _zip_unchange(za, i, 1); + + ret |= zip_unchange_archive(za); + + return ret; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_unchange_archive.c b/thirdparty/libzip-1.11.3/lib/zip_unchange_archive.c new file mode 100644 index 0000000..ddd617b --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_unchange_archive.c @@ -0,0 +1,51 @@ +/* + zip_unchange_archive.c -- undo global changes to ZIP archive + Copyright (C) 2006-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include + +#include "zipint.h" + + +ZIP_EXTERN int +zip_unchange_archive(zip_t *za) { + if (za->comment_changed) { + _zip_string_free(za->comment_changes); + za->comment_changes = NULL; + za->comment_changed = 0; + } + + za->ch_flags = za->flags; + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_unchange_data.c b/thirdparty/libzip-1.11.3/lib/zip_unchange_data.c new file mode 100644 index 0000000..30a7be7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_unchange_data.c @@ -0,0 +1,53 @@ +/* + zip_unchange_data.c -- undo helper function + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + +void +_zip_unchange_data(zip_entry_t *ze) { + if (ze->source) { + zip_source_free(ze->source); + ze->source = NULL; + } + + if (ze->changes != NULL && (ze->changes->changed & ZIP_DIRENT_COMP_METHOD) && ze->changes->comp_method == ZIP_CM_REPLACED_DEFAULT) { + ze->changes->changed &= ~ZIP_DIRENT_COMP_METHOD; + if (ze->changes->changed == 0) { + _zip_dirent_free(ze->changes); + ze->changes = NULL; + } + } + + ze->deleted = 0; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_utf-8.c b/thirdparty/libzip-1.11.3/lib/zip_utf-8.c new file mode 100644 index 0000000..7d671f6 --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_utf-8.c @@ -0,0 +1,284 @@ +/* + zip_utf-8.c -- UTF-8 support functions for libzip + Copyright (C) 2011-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "zipint.h" + +#include + + +static const zip_uint16_t _cp437_to_unicode[256] = { + /* 0x00 - 0x0F */ + 0x0000, 0x263A, 0x263B, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022, 0x25D8, 0x25CB, 0x25D9, 0x2642, 0x2640, 0x266A, 0x266B, 0x263C, + + /* 0x10 - 0x1F */ + 0x25BA, 0x25C4, 0x2195, 0x203C, 0x00B6, 0x00A7, 0x25AC, 0x21A8, 0x2191, 0x2193, 0x2192, 0x2190, 0x221F, 0x2194, 0x25B2, 0x25BC, + + /* 0x20 - 0x2F */ + 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, + + /* 0x30 - 0x3F */ + 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F, + + /* 0x40 - 0x4F */ + 0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F, + + /* 0x50 - 0x5F */ + 0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057, 0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F, + + /* 0x60 - 0x6F */ + 0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067, 0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F, + + /* 0x70 - 0x7F */ + 0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x2302, + + /* 0x80 - 0x8F */ + 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, 0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5, + + /* 0x90 - 0x9F */ + 0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9, 0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192, + + /* 0xA0 - 0xAF */ + 0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA, 0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB, + + /* 0xB0 - 0xBF */ + 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556, 0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510, + + /* 0xC0 - 0xCF */ + 0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F, 0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567, + + /* 0xD0 - 0xDF */ + 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B, 0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580, + + /* 0xE0 - 0xEF */ + 0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4, 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229, + + /* 0xF0 - 0xFF */ + 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0}; + +#define UTF_8_LEN_2_MASK 0xe0 +#define UTF_8_LEN_2_MATCH 0xc0 +#define UTF_8_LEN_3_MASK 0xf0 +#define UTF_8_LEN_3_MATCH 0xe0 +#define UTF_8_LEN_4_MASK 0xf8 +#define UTF_8_LEN_4_MATCH 0xf0 +#define UTF_8_CONTINUE_MASK 0xc0 +#define UTF_8_CONTINUE_MATCH 0x80 + + +zip_encoding_type_t +_zip_guess_encoding(zip_string_t *str, zip_encoding_type_t expected_encoding) { + zip_encoding_type_t enc; + const zip_uint8_t *name; + zip_uint32_t i, j, ulen; + bool can_be_ascii = true; + bool can_be_utf8 = true; + bool has_control_characters = false; + + if (str == NULL) { + return ZIP_ENCODING_ASCII; + } + + name = str->raw; + + if (str->encoding != ZIP_ENCODING_UNKNOWN) { + return str->encoding; + } + + for (i = 0; i < str->length; i++) { + if (name[i] < 128) { + if (name[i] < 32 && name[i] != '\r' && name[i] != '\n' && name[i] != '\t') { + has_control_characters = true; + } + continue; + } + + can_be_ascii = false; + if ((name[i] & UTF_8_LEN_2_MASK) == UTF_8_LEN_2_MATCH) { + ulen = 1; + } + else if ((name[i] & UTF_8_LEN_3_MASK) == UTF_8_LEN_3_MATCH) { + ulen = 2; + } + else if ((name[i] & UTF_8_LEN_4_MASK) == UTF_8_LEN_4_MATCH) { + ulen = 3; + } + else { + can_be_utf8 = false; + break; + } + + if (i + ulen >= str->length) { + can_be_utf8 = false; + break; + } + + for (j = 1; j <= ulen; j++) { + if ((name[i + j] & UTF_8_CONTINUE_MASK) != UTF_8_CONTINUE_MATCH) { + can_be_utf8 = false; + goto done; + } + } + i += ulen; + } + + done: + enc = ZIP_ENCODING_CP437; + + switch (expected_encoding) { + case ZIP_ENCODING_UTF8_KNOWN: + case ZIP_ENCODING_UTF8_GUESSED: + if (can_be_utf8) { + enc = ZIP_ENCODING_UTF8_KNOWN; + } + else { + enc = ZIP_ENCODING_ERROR; + } + break; + + case ZIP_ENCODING_ASCII: + if (can_be_ascii && !has_control_characters) { + enc = ZIP_ENCODING_ASCII; + } + else { + enc = ZIP_ENCODING_ERROR; + } + break; + + case ZIP_ENCODING_CP437: + enc = ZIP_ENCODING_CP437; + break; + + case ZIP_ENCODING_UNKNOWN: + if (can_be_ascii && !has_control_characters) { + /* only bytes from 0x20-0x7F */ + enc = ZIP_ENCODING_ASCII; + } + else if (can_be_ascii && has_control_characters) { + /* only bytes from 0x00-0x7F */ + enc = ZIP_ENCODING_CP437; + } + else if (can_be_utf8) { + /* contains bytes from 0x80-0xFF and is valid UTF-8 */ + enc = ZIP_ENCODING_UTF8_GUESSED; + } + else { + /* fallback */ + enc = ZIP_ENCODING_CP437; + } + break; + case ZIP_ENCODING_ERROR: + /* invalid, shouldn't happen */ + enc = ZIP_ENCODING_ERROR; + break; + } + + str->encoding = enc; + return enc; +} + + +static zip_uint32_t +_zip_unicode_to_utf8_len(zip_uint32_t codepoint) { + if (codepoint < 0x0080) { + return 1; + } + if (codepoint < 0x0800) { + return 2; + } + if (codepoint < 0x10000) { + return 3; + } + return 4; +} + + +static zip_uint32_t +_zip_unicode_to_utf8(zip_uint32_t codepoint, zip_uint8_t *buf) { + if (codepoint < 0x0080) { + buf[0] = codepoint & 0xff; + return 1; + } + if (codepoint < 0x0800) { + buf[0] = (zip_uint8_t)(UTF_8_LEN_2_MATCH | ((codepoint >> 6) & 0x1f)); + buf[1] = (zip_uint8_t)(UTF_8_CONTINUE_MATCH | (codepoint & 0x3f)); + return 2; + } + if (codepoint < 0x10000) { + buf[0] = (zip_uint8_t)(UTF_8_LEN_3_MATCH | ((codepoint >> 12) & 0x0f)); + buf[1] = (zip_uint8_t)(UTF_8_CONTINUE_MATCH | ((codepoint >> 6) & 0x3f)); + buf[2] = (zip_uint8_t)(UTF_8_CONTINUE_MATCH | (codepoint & 0x3f)); + return 3; + } + buf[0] = (zip_uint8_t)(UTF_8_LEN_4_MATCH | ((codepoint >> 18) & 0x07)); + buf[1] = (zip_uint8_t)(UTF_8_CONTINUE_MATCH | ((codepoint >> 12) & 0x3f)); + buf[2] = (zip_uint8_t)(UTF_8_CONTINUE_MATCH | ((codepoint >> 6) & 0x3f)); + buf[3] = (zip_uint8_t)(UTF_8_CONTINUE_MATCH | (codepoint & 0x3f)); + return 4; +} + + +zip_uint8_t * +_zip_cp437_to_utf8(const zip_uint8_t *const _cp437buf, zip_uint32_t len, zip_uint32_t *utf8_lenp, zip_error_t *error) { + zip_uint8_t *cp437buf = (zip_uint8_t *)_cp437buf; + zip_uint8_t *utf8buf; + zip_uint32_t buflen, i, offset; + + if (len == 0) { + if (utf8_lenp) { + *utf8_lenp = 0; + } + return NULL; + } + + buflen = 1; + for (i = 0; i < len; i++) { + buflen += _zip_unicode_to_utf8_len(_cp437_to_unicode[cp437buf[i]]); + } + + if ((utf8buf = (zip_uint8_t *)malloc(buflen)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + offset = 0; + for (i = 0; i < len; i++) { + offset += _zip_unicode_to_utf8(_cp437_to_unicode[cp437buf[i]], utf8buf + offset); + } + + utf8buf[buflen - 1] = 0; + if (utf8_lenp) { + *utf8_lenp = buflen - 1; + } + return utf8buf; +} diff --git a/thirdparty/libzip-1.11.3/lib/zip_winzip_aes.c b/thirdparty/libzip-1.11.3/lib/zip_winzip_aes.c new file mode 100644 index 0000000..2c9874b --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zip_winzip_aes.c @@ -0,0 +1,162 @@ +/* + zip_winzip_aes.c -- Winzip AES de/encryption backend routines + Copyright (C) 2017-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +#include "zip_crypto.h" + +#include +#include + + +#define MAX_KEY_LENGTH 256 +#define PBKDF2_ITERATIONS 1000 + +struct _zip_winzip_aes { + _zip_crypto_aes_t *aes; + _zip_crypto_hmac_t *hmac; + zip_uint8_t counter[ZIP_CRYPTO_AES_BLOCK_LENGTH]; + zip_uint8_t pad[ZIP_CRYPTO_AES_BLOCK_LENGTH]; + int pad_offset; +}; + +static bool +aes_crypt(zip_winzip_aes_t *ctx, zip_uint8_t *data, zip_uint64_t length) { + zip_uint64_t i, j; + + for (i = 0; i < length; i++) { + if (ctx->pad_offset == AES_BLOCK_SIZE) { + for (j = 0; j < 8; j++) { + ctx->counter[j]++; + if (ctx->counter[j] != 0) { + break; + } + } + if (!_zip_crypto_aes_encrypt_block(ctx->aes, ctx->counter, ctx->pad)) { + return false; + } + ctx->pad_offset = 0; + } + data[i] ^= ctx->pad[ctx->pad_offset++]; + } + + return true; +} + + +zip_winzip_aes_t * +_zip_winzip_aes_new(const zip_uint8_t *password, zip_uint64_t password_length, const zip_uint8_t *salt, zip_uint16_t encryption_method, zip_uint8_t *password_verify, zip_error_t *error) { + zip_winzip_aes_t *ctx; + zip_uint8_t buffer[2 * (MAX_KEY_LENGTH / 8) + WINZIP_AES_PASSWORD_VERIFY_LENGTH]; + zip_uint16_t key_size = 0; /* in bits */ + zip_uint16_t key_length; /* in bytes */ + + switch (encryption_method) { + case ZIP_EM_AES_128: + key_size = 128; + break; + case ZIP_EM_AES_192: + key_size = 192; + break; + case ZIP_EM_AES_256: + key_size = 256; + break; + } + + if (key_size == 0 || salt == NULL || password == NULL || password_length == 0) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + + key_length = key_size / 8; + + if ((ctx = (zip_winzip_aes_t *)malloc(sizeof(*ctx))) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + memset(ctx->counter, 0, sizeof(ctx->counter)); + ctx->pad_offset = ZIP_CRYPTO_AES_BLOCK_LENGTH; + + if (!_zip_crypto_pbkdf2(password, password_length, salt, key_length / 2, PBKDF2_ITERATIONS, buffer, 2 * key_length + WINZIP_AES_PASSWORD_VERIFY_LENGTH)) { + free(ctx); + return NULL; + } + + if ((ctx->aes = _zip_crypto_aes_new(buffer, key_size, error)) == NULL) { + _zip_crypto_clear(ctx, sizeof(*ctx)); + free(ctx); + return NULL; + } + if ((ctx->hmac = _zip_crypto_hmac_new(buffer + key_length, key_length, error)) == NULL) { + _zip_crypto_aes_free(ctx->aes); + free(ctx); + return NULL; + } + + if (password_verify) { + (void)memcpy_s(password_verify, WINZIP_AES_PASSWORD_VERIFY_LENGTH, buffer + (2 * key_size / 8), WINZIP_AES_PASSWORD_VERIFY_LENGTH); + } + + return ctx; +} + + +bool +_zip_winzip_aes_encrypt(zip_winzip_aes_t *ctx, zip_uint8_t *data, zip_uint64_t length) { + return aes_crypt(ctx, data, length) && _zip_crypto_hmac(ctx->hmac, data, length); +} + + +bool +_zip_winzip_aes_decrypt(zip_winzip_aes_t *ctx, zip_uint8_t *data, zip_uint64_t length) { + return _zip_crypto_hmac(ctx->hmac, data, length) && aes_crypt(ctx, data, length); +} + + +bool +_zip_winzip_aes_finish(zip_winzip_aes_t *ctx, zip_uint8_t *hmac) { + return _zip_crypto_hmac_output(ctx->hmac, hmac); +} + + +void +_zip_winzip_aes_free(zip_winzip_aes_t *ctx) { + if (ctx == NULL) { + return; + } + + _zip_crypto_aes_free(ctx->aes); + _zip_crypto_hmac_free(ctx->hmac); + free(ctx); +} diff --git a/thirdparty/libzip-1.11.3/lib/zipint.h b/thirdparty/libzip-1.11.3/lib/zipint.h new file mode 100644 index 0000000..7f6990f --- /dev/null +++ b/thirdparty/libzip-1.11.3/lib/zipint.h @@ -0,0 +1,683 @@ +#ifndef _HAD_ZIPINT_H +#define _HAD_ZIPINT_H + +/* + zipint.h -- internal declarations. + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config.h" + +#include "compat.h" + +#ifdef ZIP_ALLOCATE_BUFFER +#include +#endif + +#ifdef _ZIP_COMPILING_DEPRECATED +#define ZIP_DEPRECATED(x) +#else +#define ZIP_DISABLE_DEPRECATED +#endif + +#include "zip.h" + +#define CENTRAL_MAGIC "PK\1\2" +#define LOCAL_MAGIC "PK\3\4" +#define EOCD_MAGIC "PK\5\6" +#define DATADES_MAGIC "PK\7\10" +#define EOCD64LOC_MAGIC "PK\6\7" +#define EOCD64_MAGIC "PK\6\6" +#define MAGIC_LEN 4 +#define CDENTRYSIZE 46u +#define LENTRYSIZE 30 +#define MAXCOMLEN 65536 +#define MAXEXTLEN 65536 +#define EOCDLEN 22 +#define EOCD64LOCLEN 20 +#define EOCD64LEN 56 +#define CDBUFSIZE (MAXCOMLEN + EOCDLEN + EOCD64LOCLEN) +#define BUFSIZE 8192 +#define EFZIP64SIZE 28 +#define EF_WINZIP_AES_SIZE 7 +#define MAX_DATA_DESCRIPTOR_LENGTH 24 + +#define TORRENTZIP_SIGNATURE "TORRENTZIPPED-" +#define TORRENTZIP_SIGNATURE_LENGTH 14 +#define TORRENTZIP_CRC_LENGTH 8 +#define TORRENTZIP_MEM_LEVEL 8 +#define TORRENTZIP_COMPRESSION_FLAGS ZIP_UINT16_MAX + +#define ZIP_CRYPTO_PKWARE_HEADERLEN 12 + +#define ZIP_CM_REPLACED_DEFAULT (-2) +#define ZIP_CM_WINZIP_AES 99 /* Winzip AES encrypted */ + +#define WINZIP_AES_PASSWORD_VERIFY_LENGTH 2 +#define WINZIP_AES_MAX_HEADER_LENGTH (16 + WINZIP_AES_PASSWORD_VERIFY_LENGTH) +#define AES_BLOCK_SIZE 16 +#define HMAC_LENGTH 10 +#define SALT_LENGTH(method) ((method) == ZIP_EM_AES_128 ? 8 : ((method) == ZIP_EM_AES_192 ? 12 : 16)) + +#define ZIP_CM_IS_DEFAULT(x) ((x) == ZIP_CM_DEFAULT || (x) == ZIP_CM_REPLACED_DEFAULT) +#define ZIP_CM_ACTUAL(x) ((zip_uint16_t)(ZIP_CM_IS_DEFAULT(x) ? ZIP_CM_DEFLATE : (x))) + +#define ZIP_EF_UTF_8_COMMENT 0x6375 +#define ZIP_EF_UTF_8_NAME 0x7075 +#define ZIP_EF_WINZIP_AES 0x9901 +#define ZIP_EF_ZIP64 0x0001 + +#define ZIP_EF_IS_INTERNAL(id) ((id) == ZIP_EF_UTF_8_COMMENT || (id) == ZIP_EF_UTF_8_NAME || (id) == ZIP_EF_WINZIP_AES || (id) == ZIP_EF_ZIP64) + +/* according to unzip-6.0's zipinfo.c, this corresponds to a regular file with rw permissions for everyone */ +#define ZIP_EXT_ATTRIB_DEFAULT (0100666u << 16) +/* according to unzip-6.0's zipinfo.c, this corresponds to a directory with rwx permissions for everyone */ +#define ZIP_EXT_ATTRIB_DEFAULT_DIR (0040777u << 16) + +/* Allowed: Encryption specific bits, data descriptor, compression specific, UTF-8 filename */ +#define ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS_ALLOWED_MASK 0x083e + +#define ZIP_MAX(a, b) ((a) > (b) ? (a) : (b)) +#define ZIP_MIN(a, b) ((a) < (b) ? (a) : (b)) + +/* This section contains API that won't materialize like this. It's + placed in the internal section, pending cleanup. */ + +/* flags for compression and encryption sources */ + +#define ZIP_CODEC_DECODE 0 /* decompress/decrypt (encode flag not set) */ +#define ZIP_CODEC_ENCODE 1 /* compress/encrypt */ + +typedef zip_source_t *(*zip_encryption_implementation)(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); + +zip_encryption_implementation _zip_get_encryption_implementation(zip_uint16_t method, int operation); + +/* clang-format off */ +enum zip_compression_status { + ZIP_COMPRESSION_OK, + ZIP_COMPRESSION_END, + ZIP_COMPRESSION_ERROR, + ZIP_COMPRESSION_NEED_DATA +}; +/* clang-format on */ +typedef enum zip_compression_status zip_compression_status_t; + +struct zip_compression_algorithm { + /* Return maximum compressed size for uncompressed data of given size. */ + zip_uint64_t (*maximum_compressed_size)(zip_uint64_t uncompressed_size); + + /* called once to create new context */ + void *(*allocate)(zip_uint16_t method, zip_uint32_t compression_flags, zip_error_t *error); + /* called once to free context */ + void (*deallocate)(void *ctx); + + /* get compression specific general purpose bitflags */ + zip_uint16_t (*general_purpose_bit_flags)(void *ctx); + /* minimum version needed when using this algorithm */ + zip_uint8_t version_needed; + + /* start processing */ + bool (*start)(void *ctx, zip_stat_t *st, zip_file_attributes_t *attributes); + /* stop processing */ + bool (*end)(void *ctx); + + /* provide new input data, remains valid until next call to input or end */ + bool (*input)(void *ctx, zip_uint8_t *data, zip_uint64_t length); + + /* all input data has been provided */ + bool (*end_of_input)(void *ctx); + + /* process input data, writing to data, which has room for length bytes, update length to number of bytes written */ + zip_compression_status_t (*process)(void *ctx, zip_uint8_t *data, zip_uint64_t *length); +}; +typedef struct zip_compression_algorithm zip_compression_algorithm_t; + +extern zip_compression_algorithm_t zip_algorithm_bzip2_compress; +extern zip_compression_algorithm_t zip_algorithm_bzip2_decompress; +extern zip_compression_algorithm_t zip_algorithm_deflate_compress; +extern zip_compression_algorithm_t zip_algorithm_deflate_decompress; +extern zip_compression_algorithm_t zip_algorithm_xz_compress; +extern zip_compression_algorithm_t zip_algorithm_xz_decompress; +extern zip_compression_algorithm_t zip_algorithm_zstd_compress; +extern zip_compression_algorithm_t zip_algorithm_zstd_decompress; + +zip_compression_algorithm_t *_zip_get_compression_algorithm(zip_int32_t method, bool compress); + +/* This API is not final yet, but we need it internally, so it's private for now. */ + +const zip_uint8_t *zip_get_extra_field_by_id(zip_t *, int, int, zip_uint16_t, int, zip_uint16_t *); + +/* This section contains API that is of limited use until support for + user-supplied compression/encryption implementation is finished. + Thus we will keep it private for now. */ + +zip_source_t *zip_source_compress(zip_t *za, zip_source_t *src, zip_int32_t cm, zip_uint32_t compression_flags); +zip_source_t *zip_source_crc_create(zip_source_t *, int, zip_error_t *error); +zip_source_t *zip_source_decompress(zip_t *za, zip_source_t *src, zip_int32_t cm); +zip_source_t *zip_source_pkware_decode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); +zip_source_t *zip_source_pkware_encode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); +int zip_source_remove(zip_source_t *); +zip_int64_t zip_source_supports(zip_source_t *src); +bool zip_source_supports_reopen(zip_source_t *src); +zip_source_t *zip_source_winzip_aes_decode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); +zip_source_t *zip_source_winzip_aes_encode(zip_t *, zip_source_t *, zip_uint16_t, int, const char *); +zip_source_t *zip_source_buffer_with_attributes(zip_t *za, const void *data, zip_uint64_t len, int freep, zip_file_attributes_t *attributes); +zip_source_t *zip_source_buffer_with_attributes_create(const void *data, zip_uint64_t len, int freep, zip_file_attributes_t *attributes, zip_error_t *error); + +/* error source for layered sources */ + +enum zip_les { ZIP_LES_NONE, ZIP_LES_UPPER, ZIP_LES_LOWER, ZIP_LES_INVAL }; + +#define ZIP_DETAIL_ET_GLOBAL 0 +#define ZIP_DETAIL_ET_ENTRY 1 + +struct _zip_err_info { + int type; + const char *description; +}; + +extern const struct _zip_err_info _zip_err_str[]; +extern const int _zip_err_str_count; +extern const struct _zip_err_info _zip_err_details[]; +extern const int _zip_err_details_count; + +/* macros for libzip-internal errors */ +#define MAX_DETAIL_INDEX 0x7fffff +#define MAKE_DETAIL_WITH_INDEX(error, index) ((((index) > MAX_DETAIL_INDEX) ? MAX_DETAIL_INDEX : (int)(index)) << 8 | (error)) +#define GET_INDEX_FROM_DETAIL(error) (((error) >> 8) & MAX_DETAIL_INDEX) +#define GET_ERROR_FROM_DETAIL(error) ((error) & 0xff) +#define ADD_INDEX_TO_DETAIL(error, index) MAKE_DETAIL_WITH_INDEX(GET_ERROR_FROM_DETAIL(error), (index)) + +/* error code for libzip-internal errors */ +#define ZIP_ER_DETAIL_NO_DETAIL 0 /* G no detail */ +#define ZIP_ER_DETAIL_CDIR_OVERLAPS_EOCD 1 /* G central directory overlaps EOCD, or there is space between them */ +#define ZIP_ER_DETAIL_COMMENT_LENGTH_INVALID 2 /* G archive comment length incorrect */ +#define ZIP_ER_DETAIL_CDIR_LENGTH_INVALID 3 /* G central directory length invalid */ +#define ZIP_ER_DETAIL_CDIR_ENTRY_INVALID 4 /* E central header invalid */ +#define ZIP_ER_DETAIL_CDIR_WRONG_ENTRIES_COUNT 5 /* G central directory count of entries is incorrect */ +#define ZIP_ER_DETAIL_ENTRY_HEADER_MISMATCH 6 /* E local and central headers do not match */ +#define ZIP_ER_DETAIL_EOCD_LENGTH_INVALID 7 /* G wrong EOCD length */ +#define ZIP_ER_DETAIL_EOCD64_OVERLAPS_EOCD 8 /* G EOCD64 overlaps EOCD, or there is space between them */ +#define ZIP_ER_DETAIL_EOCD64_WRONG_MAGIC 9 /* G EOCD64 magic incorrect */ +#define ZIP_ER_DETAIL_EOCD64_MISMATCH 10 /* G EOCD64 and EOCD do not match */ +#define ZIP_ER_DETAIL_CDIR_INVALID 11 /* G invalid value in central directory */ +#define ZIP_ER_DETAIL_VARIABLE_SIZE_OVERFLOW 12 /* E variable size fields overflow header */ +#define ZIP_ER_DETAIL_INVALID_UTF8_IN_FILENAME 13 /* E invalid UTF-8 in filename */ +#define ZIP_ER_DETAIL_INVALID_UTF8_IN_COMMENT 14 /* E invalid UTF-8 in comment */ +#define ZIP_ER_DETAIL_INVALID_ZIP64_EF 15 /* E invalid Zip64 extra field */ +#define ZIP_ER_DETAIL_INVALID_WINZIPAES_EF 16 /* E invalid WinZip AES extra field */ +#define ZIP_ER_DETAIL_EF_TRAILING_GARBAGE 17 /* E garbage at end of extra fields */ +#define ZIP_ER_DETAIL_INVALID_EF_LENGTH 18 /* E extra field length is invalid */ +#define ZIP_ER_DETAIL_INVALID_FILE_LENGTH 19 /* E file length in header doesn't match actual file length */ +#define ZIP_ER_DETAIL_STORED_SIZE_MISMATCH 20 /* E compressed and uncompressed sizes don't match for stored file */ +#define ZIP_ER_DETAIL_DATA_DESCRIPTOR_MISMATCH 21 /* E local header and data descriptor do not match */ +#define ZIP_ER_DETAIL_EOCD64_LOCATOR_MISMATCH 22 /* G EOCD64 and EOCD64 locator do not match */ +#define ZIP_ER_DETAIL_UTF8_FILENAME_MISMATCH 23 /* E UTF-8 filename is ASCII and doesn't match filename */ +#define ZIP_ER_DETAIL_UTF8_COMMENT_MISMATCH 24 /* E UTF-8 comment is ASCII and doesn't match comment */ +#define ZIP_ER_DETAIL_COMPRESSED_DATA_TRAILING_GARBAGE 25 /* G garbage at end of compressed data */ + +/* directory entry: general purpose bit flags */ + +#define ZIP_GPBF_ENCRYPTED 0x0001u /* is encrypted */ +#define ZIP_GPBF_DATA_DESCRIPTOR 0x0008u /* crc/size after file data */ +#define ZIP_GPBF_STRONG_ENCRYPTION 0x0040u /* uses strong encryption */ +#define ZIP_GPBF_ENCODING_UTF_8 0x0800u /* file name encoding is UTF-8 */ + + +/* extra fields */ +#define ZIP_EF_LOCAL ZIP_FL_LOCAL /* include in local header */ +#define ZIP_EF_CENTRAL ZIP_FL_CENTRAL /* include in central directory */ +#define ZIP_EF_BOTH (ZIP_EF_LOCAL | ZIP_EF_CENTRAL) /* include in both */ + +#define ZIP_FL_FORCE_ZIP64 1024 /* force zip64 extra field (_zip_dirent_write) */ + +#define ZIP_FL_ENCODING_ALL (ZIP_FL_ENC_GUESS | ZIP_FL_ENC_CP437 | ZIP_FL_ENC_UTF_8) + + +/* encoding type */ +enum zip_encoding_type { + ZIP_ENCODING_UNKNOWN, /* not yet analyzed */ + ZIP_ENCODING_ASCII, /* plain ASCII */ + ZIP_ENCODING_UTF8_KNOWN, /* is UTF-8 */ + ZIP_ENCODING_UTF8_GUESSED, /* possibly UTF-8 */ + ZIP_ENCODING_CP437, /* Code Page 437 */ + ZIP_ENCODING_ERROR /* should be UTF-8 but isn't */ +}; + +typedef enum zip_encoding_type zip_encoding_type_t; + +struct zip_hash; +struct zip_progress; + +typedef struct zip_cdir zip_cdir_t; +typedef struct zip_dostime zip_dostime_t; +typedef struct zip_dirent zip_dirent_t; +typedef struct zip_entry zip_entry_t; +typedef struct zip_extra_field zip_extra_field_t; +typedef struct zip_string zip_string_t; +typedef struct zip_buffer zip_buffer_t; +typedef struct zip_hash zip_hash_t; +typedef struct zip_progress zip_progress_t; + +/* zip archive, part of API */ + +struct zip { + zip_source_t *src; /* data source for archive */ + unsigned int open_flags; /* flags passed to zip_open */ + zip_error_t error; /* error information */ + + unsigned int flags; /* archive global flags */ + unsigned int ch_flags; /* changed archive global flags */ + + char *default_password; /* password used when no other supplied */ + + zip_string_t *comment_orig; /* archive comment */ + zip_string_t *comment_changes; /* changed archive comment */ + bool comment_changed; /* whether archive comment was changed */ + + zip_uint64_t nentry; /* number of entries */ + zip_uint64_t nentry_alloc; /* number of entries allocated */ + zip_entry_t *entry; /* entries */ + + unsigned int nopen_source; /* number of open sources using archive */ + unsigned int nopen_source_alloc; /* number of sources allocated */ + zip_source_t **open_source; /* open sources using archive */ + + zip_hash_t *names; /* hash table for name lookup */ + + zip_progress_t *progress; /* progress callback for zip_close() */ + + zip_uint32_t* write_crc; /* have _zip_write() compute CRC */ + time_t torrent_mtime; +}; + +/* file in zip archive, part of API */ + +struct zip_file { + zip_error_t error; /* error information */ + zip_source_t *src; /* data source */ +}; + +/* zip archive directory entry (central or local) */ + +#define ZIP_DIRENT_COMP_METHOD 0x0001u +#define ZIP_DIRENT_FILENAME 0x0002u +#define ZIP_DIRENT_COMMENT 0x0004u +#define ZIP_DIRENT_EXTRA_FIELD 0x0008u +#define ZIP_DIRENT_ATTRIBUTES 0x0010u +#define ZIP_DIRENT_LAST_MOD 0x0020u +#define ZIP_DIRENT_ENCRYPTION_METHOD 0x0040u +#define ZIP_DIRENT_PASSWORD 0x0080u +#define ZIP_DIRENT_ALL ZIP_UINT32_MAX + +struct zip_dostime { + zip_uint16_t time; + zip_uint16_t date; +}; + +struct zip_dirent { + zip_uint32_t changed; + bool local_extra_fields_read; /* whether we already read in local header extra fields */ + bool cloned; /* whether this instance is cloned, and thus shares non-changed strings */ + + bool crc_valid; /* if CRC is valid (sometimes not for encrypted archives) */ + bool last_mod_mtime_valid; + + zip_uint16_t version_madeby; /* (c) version of creator */ + zip_uint16_t version_needed; /* (cl) version needed to extract */ + zip_uint16_t bitflags; /* (cl) general purpose bit flag */ + zip_int32_t comp_method; /* (cl) compression method used (uint16 and ZIP_CM_DEFAULT (-1)) */ + zip_dostime_t last_mod; /* (cl) time of last modification */ + zip_uint32_t crc; /* (cl) CRC-32 of uncompressed data */ + zip_uint64_t comp_size; /* (cl) size of compressed data */ + zip_uint64_t uncomp_size; /* (cl) size of uncompressed data */ + zip_string_t *filename; /* (cl) file name (NUL-terminated) */ + zip_extra_field_t *extra_fields; /* (cl) extra fields, parsed */ + zip_string_t *comment; /* (c) file comment */ + zip_uint32_t disk_number; /* (c) disk number start */ + zip_uint16_t int_attrib; /* (c) internal file attributes */ + zip_uint32_t ext_attrib; /* (c) external file attributes */ + zip_uint64_t offset; /* (c) offset of local header */ + + zip_uint32_t compression_level; /* level of compression to use (never valid in orig) */ + zip_uint16_t encryption_method; /* encryption method, computed from other fields */ + char *password; /* file specific encryption password */ + + time_t last_mod_mtime; /* cached last_mod in Unix time format */ +}; + +/* zip archive central directory */ + +struct zip_cdir { + zip_entry_t *entry; /* directory entries */ + zip_uint64_t nentry; /* number of entries */ + zip_uint64_t nentry_alloc; /* number of entries allocated */ + + zip_uint32_t this_disk; + zip_uint32_t eocd_disk; + zip_uint64_t disk_entries; /* number of entries on this disk */ + zip_uint64_t num_entries; /* number of entries on all disks */ + zip_uint64_t size; /* size of central directory */ + zip_uint64_t offset; /* offset of central directory in file */ + zip_uint64_t eocd_offset; /* offset of EOCD in file */ + zip_string_t *comment; /* zip archive comment */ + bool is_zip64; /* central directory in zip64 format */ +}; + +struct zip_extra_field { + zip_extra_field_t *next; + zip_flags_t flags; /* in local/central header */ + zip_uint16_t id; /* header id */ + zip_uint16_t size; /* data size */ + zip_uint8_t *data; +}; + +enum zip_source_write_state { + ZIP_SOURCE_WRITE_CLOSED, /* write is not in progress */ + ZIP_SOURCE_WRITE_OPEN, /* write is in progress */ + ZIP_SOURCE_WRITE_FAILED, /* commit failed, only rollback allowed */ + ZIP_SOURCE_WRITE_REMOVED /* file was removed */ +}; +typedef enum zip_source_write_state zip_source_write_state_t; + +struct zip_source { + zip_source_t *src; + union { + zip_source_callback f; + zip_source_layered_callback l; + } cb; + void *ud; + zip_error_t error; + zip_int64_t supports; /* supported commands */ + unsigned int open_count; /* number of times source was opened (directly or as lower layer) */ + zip_source_write_state_t write_state; /* whether source is open for writing */ + bool source_closed; /* set if source archive is closed */ + zip_t *source_archive; /* zip archive we're reading from, NULL if not from archive */ + unsigned int refcount; + bool eof; /* EOF reached */ + bool had_read_error; /* a previous ZIP_SOURCE_READ reported an error */ + zip_uint64_t bytes_read; /* for sources that don't support ZIP_SOURCE_TELL. */ +}; + +#define ZIP_SOURCE_IS_OPEN_READING(src) ((src)->open_count > 0) +#define ZIP_SOURCE_IS_OPEN_WRITING(src) ((src)->write_state == ZIP_SOURCE_WRITE_OPEN) +#define ZIP_SOURCE_IS_LAYERED(src) ((src)->src != NULL) + +/* entry in zip archive directory */ + +struct zip_entry { + zip_dirent_t *orig; + zip_dirent_t *changes; + zip_source_t *source; + bool deleted; +}; + + +/* file or archive comment, or filename */ + +struct zip_string { + zip_uint8_t *raw; /* raw string */ + zip_uint16_t length; /* length of raw string */ + enum zip_encoding_type encoding; /* autorecognized encoding */ + zip_uint8_t *converted; /* autoconverted string */ + zip_uint32_t converted_length; /* length of converted */ +}; + + +/* byte array */ + +/* For performance, we usually keep 8k byte arrays on the stack. + However, there are (embedded) systems with a stack size of 12k; + for those, use malloc()/free() */ + +#ifdef ZIP_ALLOCATE_BUFFER +#define DEFINE_BYTE_ARRAY(buf, size) zip_uint8_t *buf +#define byte_array_init(buf, size) (((buf) = (zip_uint8_t *)malloc(size)) != NULL) +#define byte_array_fini(buf) (free(buf)) +#else +#define DEFINE_BYTE_ARRAY(buf, size) zip_uint8_t buf[size] +#define byte_array_init(buf, size) (1) +#define byte_array_fini(buf) ((void)0) +#endif + + +/* bounds checked access to memory buffer */ + +struct zip_buffer { + bool ok; + bool free_data; + + zip_uint8_t *data; + zip_uint64_t size; + zip_uint64_t offset; +}; + +/* which files to write in which order */ + +struct zip_filelist { + zip_uint64_t idx; + const char *name; +}; + +typedef struct zip_filelist zip_filelist_t; + +struct _zip_winzip_aes; +typedef struct _zip_winzip_aes zip_winzip_aes_t; + +struct _zip_pkware_keys { + zip_uint32_t key[3]; +}; +typedef struct _zip_pkware_keys zip_pkware_keys_t; + +#define ZIP_MAX(a, b) ((a) > (b) ? (a) : (b)) +#define ZIP_MIN(a, b) ((a) < (b) ? (a) : (b)) + +#define ZIP_ENTRY_CHANGED(e, f) ((e)->changes && ((e)->changes->changed & (f))) +#define ZIP_ENTRY_DATA_CHANGED(x) ((x)->source != NULL) +#define ZIP_ENTRY_HAS_CHANGES(e) (ZIP_ENTRY_DATA_CHANGED(e) || (e)->deleted || ZIP_ENTRY_CHANGED((e), ZIP_DIRENT_ALL)) + +#define ZIP_IS_RDONLY(za) ((za)->ch_flags & ZIP_AFL_RDONLY) +#define ZIP_IS_TORRENTZIP(za) ((za)->flags & ZIP_AFL_IS_TORRENTZIP) +#define ZIP_WANT_TORRENTZIP(za) ((za)->ch_flags & ZIP_AFL_WANT_TORRENTZIP) + + +#ifdef HAVE_EXPLICIT_MEMSET +#define _zip_crypto_clear(b, l) explicit_memset((b), 0, (l)) +#else +#ifdef HAVE_EXPLICIT_BZERO +#define _zip_crypto_clear(b, l) explicit_bzero((b), (l)) +#else +#include +#define _zip_crypto_clear(b, l) memset((b), 0, (l)) +#endif +#endif + + +zip_int64_t _zip_add_entry(zip_t *); + +zip_uint8_t *_zip_buffer_data(zip_buffer_t *buffer); +bool _zip_buffer_eof(zip_buffer_t *buffer); +void _zip_buffer_free(zip_buffer_t *buffer); +zip_uint8_t *_zip_buffer_get(zip_buffer_t *buffer, zip_uint64_t length); +zip_uint16_t _zip_buffer_get_16(zip_buffer_t *buffer); +zip_uint32_t _zip_buffer_get_32(zip_buffer_t *buffer); +zip_uint64_t _zip_buffer_get_64(zip_buffer_t *buffer); +zip_uint8_t _zip_buffer_get_8(zip_buffer_t *buffer); +zip_uint64_t _zip_buffer_left(zip_buffer_t *buffer); +zip_buffer_t *_zip_buffer_new(zip_uint8_t *data, zip_uint64_t size); +zip_buffer_t *_zip_buffer_new_from_source(zip_source_t *src, zip_uint64_t size, zip_uint8_t *buf, zip_error_t *error); +zip_uint64_t _zip_buffer_offset(zip_buffer_t *buffer); +bool _zip_buffer_ok(zip_buffer_t *buffer); +zip_uint8_t *_zip_buffer_peek(zip_buffer_t *buffer, zip_uint64_t length); +int _zip_buffer_put(zip_buffer_t *buffer, const void *src, size_t length); +int _zip_buffer_put_16(zip_buffer_t *buffer, zip_uint16_t i); +int _zip_buffer_put_32(zip_buffer_t *buffer, zip_uint32_t i); +int _zip_buffer_put_64(zip_buffer_t *buffer, zip_uint64_t i); +int _zip_buffer_put_8(zip_buffer_t *buffer, zip_uint8_t i); +zip_uint64_t _zip_buffer_read(zip_buffer_t *buffer, zip_uint8_t *data, zip_uint64_t length); +int _zip_buffer_skip(zip_buffer_t *buffer, zip_uint64_t length); +int _zip_buffer_set_offset(zip_buffer_t *buffer, zip_uint64_t offset); +zip_uint64_t _zip_buffer_size(zip_buffer_t *buffer); + +void _zip_cdir_free(zip_cdir_t *); +bool _zip_cdir_grow(zip_cdir_t *cd, zip_uint64_t additional_entries, zip_error_t *error); +zip_cdir_t *_zip_cdir_new(zip_error_t *); +zip_int64_t _zip_cdir_write(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivors); +time_t _zip_d2u_time(const zip_dostime_t*); +void _zip_deregister_source(zip_t *za, zip_source_t *src); + +bool _zip_dirent_apply_attributes(zip_dirent_t *, zip_file_attributes_t *, bool, zip_uint32_t); +int zip_dirent_check_consistency(zip_dirent_t *dirent); +zip_dirent_t *_zip_dirent_clone(const zip_dirent_t *); +void _zip_dirent_free(zip_dirent_t *); +void _zip_dirent_finalize(zip_dirent_t *); +time_t zip_dirent_get_last_mod_mtime(zip_dirent_t *de); +void _zip_dirent_init(zip_dirent_t *); +bool _zip_dirent_needs_zip64(const zip_dirent_t *, zip_flags_t); +zip_dirent_t *_zip_dirent_new(void); +bool zip_dirent_process_ef_zip64(zip_dirent_t * zde, const zip_uint8_t * ef, zip_uint64_t got_len, bool local, zip_error_t * error); +zip_int64_t _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, bool local, zip_uint64_t central_compressed_size, bool check_consistency, zip_error_t *error); +void _zip_dirent_set_version_needed(zip_dirent_t *de, bool force_zip64); +void zip_dirent_torrentzip_normalize(zip_dirent_t *de); + +zip_int32_t _zip_dirent_size(zip_source_t *src, zip_uint16_t, zip_error_t *); +int _zip_dirent_write(zip_t *za, zip_dirent_t *dirent, zip_flags_t flags); + +zip_extra_field_t *_zip_ef_clone(const zip_extra_field_t *, zip_error_t *); +zip_extra_field_t *_zip_ef_delete_by_id(zip_extra_field_t *, zip_uint16_t, zip_uint16_t, zip_flags_t); +void _zip_ef_free(zip_extra_field_t *); +const zip_uint8_t *_zip_ef_get_by_id(const zip_extra_field_t *, zip_uint16_t *, zip_uint16_t, zip_uint16_t, zip_flags_t, zip_error_t *); +zip_extra_field_t *_zip_ef_merge(zip_extra_field_t *, zip_extra_field_t *); +zip_extra_field_t *_zip_ef_new(zip_uint16_t, zip_uint16_t, const zip_uint8_t *, zip_flags_t); +bool _zip_ef_parse(const zip_uint8_t *, zip_uint16_t, zip_flags_t, zip_extra_field_t **, zip_error_t *); +zip_extra_field_t *_zip_ef_remove_internal(zip_extra_field_t *); +zip_uint16_t _zip_ef_size(const zip_extra_field_t *, zip_flags_t); +int _zip_ef_write(zip_t *za, const zip_extra_field_t *ef, zip_flags_t flags); + +void _zip_entry_finalize(zip_entry_t *); +void _zip_entry_init(zip_entry_t *); + +void _zip_error_clear(zip_error_t *); +void _zip_error_get(const zip_error_t *, int *, int *); + +void _zip_error_copy(zip_error_t *dst, const zip_error_t *src); + +const zip_uint8_t *_zip_extract_extra_field_by_id(zip_error_t *, zip_uint16_t, int, const zip_uint8_t *, zip_uint16_t, zip_uint16_t *); + +int _zip_file_extra_field_prepare_for_change(zip_t *, zip_uint64_t); +int _zip_file_fillbuf(void *, size_t, zip_file_t *); +zip_uint64_t _zip_file_get_end(const zip_t *za, zip_uint64_t index, zip_error_t *error); +zip_uint64_t _zip_file_get_offset(const zip_t *, zip_uint64_t, zip_error_t *); + +zip_dirent_t *_zip_get_dirent(zip_t *, zip_uint64_t, zip_flags_t, zip_error_t *); + +enum zip_encoding_type _zip_guess_encoding(zip_string_t *, enum zip_encoding_type); +zip_uint8_t *_zip_cp437_to_utf8(const zip_uint8_t *const, zip_uint32_t, zip_uint32_t *, zip_error_t *); + +bool _zip_hash_add(zip_hash_t *hash, const zip_uint8_t *name, zip_uint64_t index, zip_flags_t flags, zip_error_t *error); +bool _zip_hash_delete(zip_hash_t *hash, const zip_uint8_t *key, zip_error_t *error); +void _zip_hash_free(zip_hash_t *hash); +zip_int64_t _zip_hash_lookup(zip_hash_t *hash, const zip_uint8_t *name, zip_flags_t flags, zip_error_t *error); +zip_hash_t *_zip_hash_new(zip_error_t *error); +bool _zip_hash_reserve_capacity(zip_hash_t *hash, zip_uint64_t capacity, zip_error_t *error); +bool _zip_hash_revert(zip_hash_t *hash, zip_error_t *error); + +int _zip_mkstempm(char *path, int mode, bool create_file); + +zip_t *_zip_open(zip_source_t *, unsigned int, zip_error_t *); + +void _zip_progress_end(zip_progress_t *progress); +void _zip_progress_free(zip_progress_t *progress); +int _zip_progress_start(zip_progress_t *progress); +int _zip_progress_subrange(zip_progress_t *progress, double start, double end); +int _zip_progress_update(zip_progress_t *progress, double value); + +/* this symbol is extern so it can be overridden for regression testing */ +ZIP_EXTERN bool zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length); +zip_uint32_t zip_random_uint32(void); + +int _zip_read(zip_source_t *src, zip_uint8_t *data, zip_uint64_t length, zip_error_t *error); +int _zip_read_at_offset(zip_source_t *src, zip_uint64_t offset, unsigned char *b, size_t length, zip_error_t *error); +zip_uint8_t *_zip_read_data(zip_buffer_t *buffer, zip_source_t *src, size_t length, bool nulp, zip_error_t *error); +int _zip_read_local_ef(zip_t *, zip_uint64_t); +zip_string_t *_zip_read_string(zip_buffer_t *buffer, zip_source_t *src, zip_uint16_t length, bool nulp, zip_error_t *error); +int _zip_register_source(zip_t *za, zip_source_t *src); + +void _zip_set_open_error(int *zep, const zip_error_t *err, int ze); + +bool zip_source_accept_empty(zip_source_t *src); +zip_int64_t _zip_source_call(zip_source_t *src, void *data, zip_uint64_t length, zip_source_cmd_t command); +bool _zip_source_eof(zip_source_t *); +int zip_source_get_dos_time(zip_source_t *src, zip_dostime_t *dos_time); + +zip_source_t *_zip_source_file_or_p(const char *, FILE *, zip_uint64_t, zip_int64_t, const zip_stat_t *, zip_error_t *error); +bool _zip_source_had_error(zip_source_t *); +void _zip_source_invalidate(zip_source_t *src); +zip_source_t *_zip_source_new(zip_error_t *error); +int _zip_source_set_source_archive(zip_source_t *, zip_t *); +zip_source_t *_zip_source_window_new(zip_source_t *src, zip_uint64_t start, zip_int64_t length, zip_stat_t *st, zip_uint64_t st_invalid, zip_file_attributes_t *attributes, zip_dostime_t *dostime, zip_t *source_archive, zip_uint64_t source_index, bool take_ownership, zip_error_t *error); + +int _zip_stat_merge(zip_stat_t *dst, const zip_stat_t *src, zip_error_t *error); +int _zip_string_equal(const zip_string_t *a, const zip_string_t *b); +void _zip_string_free(zip_string_t *string); +zip_uint32_t _zip_string_crc32(const zip_string_t *string); +const zip_uint8_t *_zip_string_get(zip_string_t *string, zip_uint32_t *lenp, zip_flags_t flags, zip_error_t *error); +bool _zip_string_is_ascii(const zip_string_t *string); +zip_uint16_t _zip_string_length(const zip_string_t *string); +zip_string_t *_zip_string_new(const zip_uint8_t *raw, zip_uint16_t length, zip_flags_t flags, zip_error_t *error); +int _zip_string_write(zip_t *za, const zip_string_t *string); +bool _zip_winzip_aes_decrypt(zip_winzip_aes_t *ctx, zip_uint8_t *data, zip_uint64_t length); +bool _zip_winzip_aes_encrypt(zip_winzip_aes_t *ctx, zip_uint8_t *data, zip_uint64_t length); +bool _zip_winzip_aes_finish(zip_winzip_aes_t *ctx, zip_uint8_t *hmac); +void _zip_winzip_aes_free(zip_winzip_aes_t *ctx); +zip_winzip_aes_t *_zip_winzip_aes_new(const zip_uint8_t *password, zip_uint64_t password_length, const zip_uint8_t *salt, zip_uint16_t key_size, zip_uint8_t *password_verify, zip_error_t *error); + +void _zip_pkware_encrypt(zip_pkware_keys_t *keys, zip_uint8_t *out, const zip_uint8_t *in, zip_uint64_t len); +void _zip_pkware_decrypt(zip_pkware_keys_t *keys, zip_uint8_t *out, const zip_uint8_t *in, zip_uint64_t len); +zip_pkware_keys_t *_zip_pkware_keys_new(zip_error_t *error); +void _zip_pkware_keys_free(zip_pkware_keys_t *keys); +void _zip_pkware_keys_reset(zip_pkware_keys_t *keys); + +int _zip_changed(const zip_t *, zip_uint64_t *); +const char *_zip_get_name(zip_t *, zip_uint64_t, zip_flags_t, zip_error_t *); +int _zip_local_header_read(zip_t *, int); +void *_zip_memdup(const void *, size_t, zip_error_t *); +zip_int64_t _zip_name_locate(zip_t *, const char *, zip_flags_t, zip_error_t *); +zip_t *_zip_new(zip_error_t *); + +zip_int64_t _zip_file_replace(zip_t *, zip_uint64_t, const char *, zip_source_t *, zip_flags_t); +int _zip_set_name(zip_t *, zip_uint64_t, const char *, zip_flags_t); +int _zip_u2d_time(time_t, zip_dostime_t *, zip_error_t *); +int _zip_unchange(zip_t *, zip_uint64_t, int); +void _zip_unchange_data(zip_entry_t *); +int _zip_write(zip_t *za, const void *data, zip_uint64_t length); + +#endif /* _HAD_ZIPINT_H */ diff --git a/thirdparty/libzip-1.11.3/libzip-config.cmake.in b/thirdparty/libzip-1.11.3/libzip-config.cmake.in new file mode 100644 index 0000000..8061530 --- /dev/null +++ b/thirdparty/libzip-1.11.3/libzip-config.cmake.in @@ -0,0 +1,45 @@ +@PACKAGE_INIT@ + +# We need to supply transitive dependencies if this config is for a static library +set(IS_SHARED @BUILD_SHARED_LIBS@) +if (NOT IS_SHARED) + include(CMakeFindDependencyMacro) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/modules") + + set(ENABLE_BZIP2 @BZIP2_FOUND@) + set(ENABLE_LZMA @LIBLZMA_FOUND@) + set(ENABLE_ZSTD @ZSTD_FOUND@) + set(ENABLE_GNUTLS @GNUTLS_FOUND@) + set(ENABLE_MBEDTLS @MBEDTLS_FOUND@) + set(ENABLE_OPENSSL @OPENSSL_FOUND@) + + find_dependency(ZLIB 1.1.2) + if(ENABLE_BZIP2) + find_dependency(BZip2) + endif() + + if(ENABLE_LZMA) + find_dependency(LibLZMA 5.2) + endif() + + if(ENABLE_ZSTD) + find_dependency(zstd 1.3.6) + endif() + + if(ENABLE_GNUTLS) + find_dependency(Nettle 3.0) + find_dependency(GnuTLS) + endif() + if(ENABLE_MBEDTLS) + find_dependency(MbedTLS 1.0) + endif() + if(ENABLE_OPENSSL) + find_dependency(OpenSSL) + endif() +endif() + +# Provide all our library targets to users. +include("${CMAKE_CURRENT_LIST_DIR}/libzip-targets.cmake") + +check_required_components(libzip) + diff --git a/thirdparty/libzip-1.11.3/libzip.pc.in b/thirdparty/libzip-1.11.3/libzip.pc.in new file mode 100644 index 0000000..d51b0ab --- /dev/null +++ b/thirdparty/libzip-1.11.3/libzip.pc.in @@ -0,0 +1,14 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +bindir=@bindir@ +libdir=@libdir@ +includedir=@includedir@ + +zipcmp=${bindir}/zipcmp + +Name: libzip +Description: library for handling zip archives +Version: @PROJECT_VERSION@ +Libs: @PKG_CONFIG_RPATH@ -L${libdir} -lzip +Libs.private: @LIBS@ +Cflags: -I${includedir} diff --git a/thirdparty/libzip-1.11.3/man/CMakeLists.txt b/thirdparty/libzip-1.11.3/man/CMakeLists.txt new file mode 100644 index 0000000..14173e0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/CMakeLists.txt @@ -0,0 +1,169 @@ +set(MAN_PAGES + ZIP_SOURCE_GET_ARGS.3 + libzip.3 + zip_add.3 + zip_add_dir.3 + zip_close.3 + zip_compression_method_supported.3 + zip_delete.3 + zip_dir_add.3 + zip_discard.3 + zip_encryption_method_supported.3 + zip_error_clear.3 + zip_error_code_system.3 + zip_error_code_zip.3 + zip_error_fini.3 + zip_error_get.3 + zip_error_get_sys_type.3 + zip_error_init.3 + zip_error_set.3 + zip_error_set_from_source.3 + zip_error_strerror.3 + zip_error_system_type.3 + zip_error_to_data.3 + zip_error_to_str.3 + zip_errors.3 + zip_fclose.3 + zip_fdopen.3 + zip_file_add.3 + zip_file_attributes_init.3 + zip_file_extra_field_delete.3 + zip_file_extra_field_get.3 + zip_file_extra_field_set.3 + zip_file_extra_fields_count.3 + zip_file_get_comment.3 + zip_file_get_error.3 + zip_file_get_external_attributes.3 + zip_file_rename.3 + zip_file_set_comment.3 + zip_file_set_encryption.3 + zip_file_set_external_attributes.3 + zip_file_set_mtime.3 + zip_file_strerror.3 + zip_fopen.3 + zip_fopen_encrypted.3 + zip_fread.3 + zip_fseek.3 + zip_ftell.3 + zip_get_archive_comment.3 + zip_get_archive_flag.3 + zip_get_error.3 + zip_get_file_comment.3 + zip_get_name.3 + zip_get_num_entries.3 + zip_get_num_files.3 + zip_libzip_version.3 + zip_name_locate.3 + zip_open.3 + zip_register_cancel_callback_with_state.3 + zip_register_progress_callback.3 + zip_register_progress_callback_with_state.3 + zip_rename.3 + zip_set_archive_comment.3 + zip_set_archive_flag.3 + zip_set_default_password.3 + zip_set_file_comment.3 + zip_set_file_compression.3 + zip_source.3 + zip_source_begin_write.3 + zip_source_buffer.3 + zip_source_buffer_fragment.3 + zip_source_close.3 + zip_source_commit_write.3 + zip_source_error.3 + zip_source_file.3 + zip_source_filep.3 + zip_source_free.3 + zip_source_function.3 + zip_source_is_deleted.3 + zip_source_is_seekable.3 + zip_source_layered.3 + zip_source_keep.3 + zip_source_make_command_bitmap.3 + zip_source_open.3 + zip_source_read.3 + zip_source_rollback_write.3 + zip_source_seek.3 + zip_source_seek_compute_offset.3 + zip_source_seek_write.3 + zip_source_stat.3 + zip_source_tell.3 + zip_source_tell_write.3 + zip_source_win32a.3 + zip_source_win32handle.3 + zip_source_win32w.3 + zip_source_window_create.3 + zip_source_write.3 + zip_source_zip.3 + zip_source_zip_file.3 + zip_stat.3 + zip_stat_init.3 + zip_unchange.3 + zip_unchange_all.3 + zip_unchange_archive.3 + zipcmp.1 + zipmerge.1 + ziptool.1 +) + +foreach(MAN_PAGE ${MAN_PAGES}) + string(REGEX REPLACE "[1-9]$" "${DOCUMENTATION_FORMAT}" SOURCE_FILE ${MAN_PAGE}) + if(LIBZIP_DO_INSTALL) + if (DOCUMENTATION_FORMAT MATCHES "html") + install(FILES ${PROJECT_BINARY_DIR}/man/${MAN_PAGE} DESTINATION ${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME} RENAME ${SOURCE_FILE}) + else() + string(REGEX REPLACE ".*(.)$" "man\\1" SUBDIR ${MAN_PAGE}) + install(FILES ${PROJECT_BINARY_DIR}/man/${MAN_PAGE} DESTINATION ${CMAKE_INSTALL_MANDIR}/${SUBDIR}) + endif() + endif() + # configure_file does not find out about updates to the sources, and it does not provide a target + #configure_file(${SOURCE_FILE} ${MAN_PAGE} COPYONLY) + add_custom_command(OUTPUT ${MAN_PAGE} + DEPENDS ${SOURCE_FILE} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${MAN_PAGE} + COMMENT "Preparing ${MAN_PAGE}" + ) + + string(REGEX REPLACE "[1-9]$" "html" HTML_FILE ${MAN_PAGE}) + string(REGEX REPLACE "[1-9]$" "man" MAN_FILE ${MAN_PAGE}) + string(REGEX REPLACE "[1-9]$" "mdoc" MDOC_FILE ${MAN_PAGE}) + + # html re-generation + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${HTML_FILE} + DEPENDS ${MDOC_FILE} + COMMAND ${CMAKE_COMMAND} -DIN=${CMAKE_CURRENT_SOURCE_DIR}/${MDOC_FILE} -DOUT=${CMAKE_CURRENT_BINARY_DIR}/${HTML_FILE} -P ${CMAKE_CURRENT_SOURCE_DIR}/update-html.cmake + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${HTML_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/${HTML_FILE} + ) + list(APPEND UPDATEHTML ${CMAKE_CURRENT_BINARY_DIR}/${HTML_FILE}) + + # man re-generation + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${MAN_FILE} + DEPENDS ${MDOC_FILE} + COMMAND ${CMAKE_COMMAND} -DIN=${CMAKE_CURRENT_SOURCE_DIR}/${MDOC_FILE} -DOUT=${CMAKE_CURRENT_BINARY_DIR}/${MAN_FILE} -P ${CMAKE_CURRENT_SOURCE_DIR}/update-man.cmake + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${MAN_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/${MAN_FILE} + ) + list(APPEND UPDATEMAN ${CMAKE_CURRENT_BINARY_DIR}/${MAN_FILE}) +endforeach() +add_custom_target(man ALL DEPENDS ${MAN_PAGES}) +add_custom_target(update-man DEPENDS ${UPDATEMAN}) +add_custom_target(update-html DEPENDS ${UPDATEHTML}) + +file(STRINGS links MANPAGE_LINKS) +foreach(LINKS_LINE ${MANPAGE_LINKS}) + if(${LINKS_LINE} MATCHES "(.*) (.*)") + set(SOURCE ${CMAKE_MATCH_1}) + set(TARGET ${CMAKE_MATCH_2}) + if(LIBZIP_DO_INSTALL) + if (DOCUMENTATION_FORMAT MATCHES "html") + INSTALL(FILES ${PROJECT_BINARY_DIR}/man/${SOURCE}.3 DESTINATION ${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME} RENAME ${TARGET}.html) + else() + INSTALL(FILES ${PROJECT_BINARY_DIR}/man/${SOURCE}.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3 RENAME ${TARGET}.3) + endif() + endif() + endif() +endforeach() + +add_custom_target(update_zip_errors + COMMAND sh ${PROJECT_SOURCE_DIR}/man/make_zip_errors.sh ${CMAKE_SOURCE_DIR}/lib/zip.h ${PROJECT_SOURCE_DIR}/man/zip_errors.mdoc + DEPENDS ${CMAKE_SOURCE_DIR}/lib/zip.h ${PROJECT_SOURCE_DIR}/man/zip_errors.mdoc +) diff --git a/thirdparty/libzip-1.11.3/man/ZIP_SOURCE_GET_ARGS.html b/thirdparty/libzip-1.11.3/man/ZIP_SOURCE_GET_ARGS.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/ZIP_SOURCE_GET_ARGS.man b/thirdparty/libzip-1.11.3/man/ZIP_SOURCE_GET_ARGS.man new file mode 100644 index 0000000..efe22ef --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/ZIP_SOURCE_GET_ARGS.man @@ -0,0 +1,83 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" ZIP_SOURCE_GET_ARGS -- validate and cast arguments to source callback +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_GET_ARGS" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBZIP_SOURCE_GET_ARGS\fR +\- validate and cast arguments to source callback +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fItype *\fR +.br +.PD 0 +.HP 4n +\fBZIP_SOURCE_GET_ARGS\fR(\fItype\fR, \fIvoid\ *data\fR, \fIzip_uint64_t\ len\fR, \fIzip_error_t\ *error\fR); +.PD +.SH "DESCRIPTION" +The +\fBZIP_SOURCE_GET_ARGS\fR() +macro casts +\fIdata\fR +to a pointer to +\fItype\fR. +.SH "RETURN VALUES" +On success, +\fBZIP_SOURCE_GET_ARGS\fR() +returns +\fIdata\fR. +In case of error, it returns +\fRNULL\fR +and sets +\fIerror\fR. +.SH "ERRORS" +\fBZIP_SOURCE_GET_ARGS\fR() +fails if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIlen\fR +is less than the size of +\fItype\fR +.SH "SEE ALSO" +libzip(3), +zip_source_function(3) +.SH "HISTORY" +\fBZIP_SOURCE_GET_ARGS\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/ZIP_SOURCE_GET_ARGS.mdoc b/thirdparty/libzip-1.11.3/man/ZIP_SOURCE_GET_ARGS.mdoc new file mode 100644 index 0000000..25b8193 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/ZIP_SOURCE_GET_ARGS.mdoc @@ -0,0 +1,79 @@ +.\" ZIP_SOURCE_GET_ARGS -- validate and cast arguments to source callback +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_GET_ARGS 3 +.Os +.Sh NAME +.Nm ZIP_SOURCE_GET_ARGS +.Nd validate and cast arguments to source callback +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft type * +.Fn ZIP_SOURCE_GET_ARGS "type" "void *data" "zip_uint64_t len" "zip_error_t *error" +.Sh DESCRIPTION +The +.Fn ZIP_SOURCE_GET_ARGS +macro casts +.Ar data +to a pointer to +.Ar type . +.Sh RETURN VALUES +On success, +.Fn ZIP_SOURCE_GET_ARGS +returns +.Ar data . +In case of error, it returns +.Dv NULL +and sets +.Ar error . +.Sh ERRORS +.Fn ZIP_SOURCE_GET_ARGS +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar len +is less than the size of +.Ar type +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source_function 3 +.Sh HISTORY +.Fn ZIP_SOURCE_GET_ARGS +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/handle_links b/thirdparty/libzip-1.11.3/man/handle_links new file mode 100644 index 0000000..7c2ed37 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/handle_links @@ -0,0 +1,74 @@ +#!/usr/bin/env perl + +use strict; + +my $operation = shift @ARGV; + +if ($operation !~ m/^(install|uninstall)$/) { + print STDERR "$0: unknown operation $operation\n"; + exit(1); +} + +my %options = (); + +for my $arg (@ARGV) { + if ($arg =~ m/([^=]*)=(.*)/) { + $options{$1} = $2; + } + else { + print STDERR "$0: can't parse option [$arg]\n"; + exit(1); + } +} + +for my $option (qw(command directory extension file)) { + unless (defined($options{$option})) { + print STDERR "$0: required variable $option not provided\n"; + exit(1); + } +} + +my $fh; +unless (open $fh, '<', $options{file}) { + print STDERR "$0: can't open links file '$options{file}': $!"; + exit(1); +} + +my @cmd = split /\s+/, $options{command}; + +while (my $line = <$fh>) { + chomp $line; + my @args = split /\s+/, $line; + + process(@args); +} + +sub process { + my ($source, @destinations) = @_; + + my @args = (@cmd); + + if ($operation eq 'install') { + push @args, "$options{directory}/$source.$options{extension}"; + } + + for my $destination (@destinations) { + push @args, "$options{directory}/$destination.$options{extension}"; + run_command(@args); + pop @args; + } +} + +sub run_command { + print (join ' ', @_); + print "\n"; + + my $ret = system(@_); + + if ($ret != 0) { + print STDERR "$0: command failed: $?\n"; + exit(1); + } + + return 1; +} diff --git a/thirdparty/libzip-1.11.3/man/libzip.html b/thirdparty/libzip-1.11.3/man/libzip.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/libzip.man b/thirdparty/libzip-1.11.3/man/libzip.man new file mode 100644 index 0000000..b27335a --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/libzip.man @@ -0,0 +1,364 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" libzip.mdoc -- general overview of available functions +.\" Copyright (C) 2005-2024 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "LIBZIP" "3" "August 21, 2024" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBlibzip\fR +\- library for manipulating zip archives +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.SH "DESCRIPTION" +\fBlibzip\fR +is a library for reading, creating, and modifying zip archives. +.PP +The main design criteria for +\fBlibzip\fR +were: +.PD 0 +.TP 4n +\fB\(bu\fR +Do not create corrupt files, even in case of errors. +.TP 4n +\fB\(bu\fR +Do not delete data. +.TP 4n +\fB\(bu\fR +Be efficient. +.PD +.PP +For this reason, when modifying zip archives, +\fBlibzip\fR +writes to a temporary file and replaces the original +zip archive atomically. +.PP +Below there are two sections listing functions: one for how to read +from zip archives and one for how to create/modify them. +.SH "GENERAL NOTES" +Unless explicitly documented, functions should not be passed +\fRNULL\fR +pointers as arguments. +.SH "FILE NAMES" +.SS "Encoding" +Names of files in the host file system are expected in UTF-8 encoding. +On Windows, variants for ASCII and UTF-16 are also available. +.PP +Names of files inside archives are by default expected in UTF-8 encoding. +Other encodings can be requested by using the flags +\fRZIP_FL_ENC_CP437\fR +and +\fRZIP_FL_ENC_RAW\fR. +.PP +For details see the relevant man pages. +.SS "Directory Separator" +The zip format requires the use of forward slash +(\(oq/\(cq) +as directory separator. +Since backslash +(\(oq\e\(cq) +can be part of a valid file name on Unix systems, +\fBlibzip\fR +does not automatically convert them, even on Windows. +It is the responsibility of the programmer to ensure that all +directory separators are passed as forward slashes to +\fBlibzip\fR. +.SH "THREAD SAFETY" +In general, different zip archives opened by +\fBlibzip\fR +are independent of each other and can be used by parallel-running +threads without locking. +If you want to use an archive from multiple threads, you have to +synchronize access to it yourself. +If you use an archive as a source for +zip_file_add(3) +or +zip_file_replace(3), +access to the target archive must be synchronized with access to the +source archive as well. +.SH "READING ZIP ARCHIVES" +.SS "Open Archive" +.TP 4n +\fB\(bu\fR +zip_open(3) +.PD 0 +.TP 4n +\fB\(bu\fR +zip_fdopen(3) +.PD +.SS "Find Files" +.TP 4n +\fB\(bu\fR +zip_name_locate(3) +.SS "Read Files" +.TP 4n +\fB\(bu\fR +zip_fopen(3) +.PD 0 +.TP 4n +\fB\(bu\fR +zip_fopen_encrypted(3) +.TP 4n +\fB\(bu\fR +zip_fopen_index(3) +.TP 4n +\fB\(bu\fR +zip_fopen_index_encrypted(3) +.TP 4n +\fB\(bu\fR +zip_fread(3) +.TP 4n +\fB\(bu\fR +zip_file_is_seekable(3) +.TP 4n +\fB\(bu\fR +zip_fseek(3) +(uncompressed files only) +.TP 4n +\fB\(bu\fR +zip_ftell(3) +.TP 4n +\fB\(bu\fR +zip_fclose(3) +.PD +.SS "Close Archive" +.TP 4n +\fB\(bu\fR +zip_close(3) +.SS "Miscellaneous" +.TP 4n +\fB\(bu\fR +zip_stat(3) +.PD 0 +.TP 4n +\fB\(bu\fR +zip_compression_method_supported(3) +.TP 4n +\fB\(bu\fR +zip_encryption_method_supported(3) +.TP 4n +\fB\(bu\fR +zip_file_get_comment(3) +.TP 4n +\fB\(bu\fR +zip_file_get_external_attributes(3) +.TP 4n +\fB\(bu\fR +zip_get_archive_comment(3) +.TP 4n +\fB\(bu\fR +zip_get_archive_flag(3) +.TP 4n +\fB\(bu\fR +zip_get_name(3) +.TP 4n +\fB\(bu\fR +zip_get_num_entries(3) +.TP 4n +\fB\(bu\fR +zip_set_default_password(3) +.TP 4n +\fB\(bu\fR +zip_source_pass_to_lower_layer(3) +.PD +.SH "CREATING/MODIFYING ZIP ARCHIVES" +.SS "Create/Open Archive" +.TP 4n +\fB\(bu\fR +zip_open(3) +.SS "Add/Change Files and Directories" +.TP 4n +\fB\(bu\fR +zip_dir_add(3) +.PD 0 +.TP 4n +\fB\(bu\fR +zip_file_add(3) +.TP 4n +\fB\(bu\fR +zip_file_replace(3) +.TP 4n +\fB\(bu\fR +zip_file_set_comment(3) +.TP 4n +\fB\(bu\fR +zip_file_set_dostime(3) +.TP 4n +\fB\(bu\fR +zip_file_set_external_attributes(3) +.TP 4n +\fB\(bu\fR +zip_file_set_encryption(3) +.TP 4n +\fB\(bu\fR +zip_file_set_mtime(3) +.TP 4n +\fB\(bu\fR +zip_set_file_compression(3) +.TP 4n +\fB\(bu\fR +zip_source_buffer(3) +.TP 4n +\fB\(bu\fR +zip_source_file(3) +.TP 4n +\fB\(bu\fR +zip_source_filep(3) +.TP 4n +\fB\(bu\fR +zip_source_free(3) +.TP 4n +\fB\(bu\fR +zip_source_function(3) +.TP 4n +\fB\(bu\fR +zip_source_layered(3) +.TP 4n +\fB\(bu\fR +zip_source_zip(3) +.PD +.SS "Rename Files" +.TP 4n +\fB\(bu\fR +zip_rename(3) +.SS "Delete Files" +.TP 4n +\fB\(bu\fR +zip_delete(3) +.SS "Revert Changes" +.TP 4n +\fB\(bu\fR +zip_unchange(3) +.PD 0 +.TP 4n +\fB\(bu\fR +zip_unchange_all(3) +.TP 4n +\fB\(bu\fR +zip_unchange_archive(3) +.PD +.SS "Read/Modify Extra Fields" +.TP 4n +\fB\(bu\fR +zip_file_extra_field_delete(3) +.PD 0 +.TP 4n +\fB\(bu\fR +zip_file_extra_field_delete_by_id(3) +.TP 4n +\fB\(bu\fR +zip_file_extra_field_get(3) +.TP 4n +\fB\(bu\fR +zip_file_extra_field_get_by_id(3) +.TP 4n +\fB\(bu\fR +zip_file_extra_field_set(3) +.TP 4n +\fB\(bu\fR +zip_file_extra_fields_count(3) +.TP 4n +\fB\(bu\fR +zip_file_extra_fields_count_by_id(3) +.PD +.SS "Close Archive (Writing)" +.TP 4n +\fB\(bu\fR +zip_close(3) +.PD 0 +.TP 4n +\fB\(bu\fR +zip_discard(3) +.PD +.SS "Miscellaneous (Writing)" +.TP 4n +\fB\(bu\fR +zip_file_attributes_init(3) +.PD 0 +.TP 4n +\fB\(bu\fR +zip_libzip_version(3) +.TP 4n +\fB\(bu\fR +zip_register_cancel_callback_with_state(3) +.TP 4n +\fB\(bu\fR +zip_register_progress_callback_with_state(3) +.TP 4n +\fB\(bu\fR +zip_set_archive_comment(3) +.TP 4n +\fB\(bu\fR +zip_set_archive_flag(3) +.TP 4n +\fB\(bu\fR +zip_source(3) +.PD +.SH "ERROR HANDLING" +.TP 4n +\fB\(bu\fR +zip_error_strerror(3) +.PD 0 +.TP 4n +\fB\(bu\fR +zip_strerror(3) +.TP 4n +\fB\(bu\fR +zip_file_strerror(3) +.TP 4n +\fB\(bu\fR +zip_file_get_error(3) +.TP 4n +\fB\(bu\fR +zip_get_error(3) +.TP 4n +\fB\(bu\fR +zip_error_init_with_code(3) +.TP 4n +\fB\(bu\fR +zip_error_set(3) +.TP 4n +\fB\(bu\fR +zip_error_set_from_source(3) +.TP 4n +\fB\(bu\fR +zip_error_system_type(3) +.TP 4n +\fB\(bu\fR +zip_errors(3) +.PD +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/libzip.mdoc b/thirdparty/libzip-1.11.3/man/libzip.mdoc new file mode 100644 index 0000000..0490f37 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/libzip.mdoc @@ -0,0 +1,299 @@ +.\" libzip.mdoc -- general overview of available functions +.\" Copyright (C) 2005-2024 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd August 21, 2024 +.Dt LIBZIP 3 +.Os +.Sh NAME +.Nm libzip +.Nd library for manipulating zip archives +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Sh DESCRIPTION +.Nm +is a library for reading, creating, and modifying zip archives. +.Pp +The main design criteria for +.Nm +were: +.Bl -bullet -compact +.It +Do not create corrupt files, even in case of errors. +.It +Do not delete data. +.It +Be efficient. +.El +.Pp +For this reason, when modifying zip archives, +.Nm +writes to a temporary file and replaces the original +zip archive atomically. +.Pp +Below there are two sections listing functions: one for how to read +from zip archives and one for how to create/modify them. +.Sh GENERAL NOTES +Unless explicitly documented, functions should not be passed +.Dv NULL +pointers as arguments. +.Sh FILE NAMES +.Ss Encoding +Names of files in the host file system are expected in UTF-8 encoding. +On Windows, variants for ASCII and UTF-16 are also available. +.Pp +Names of files inside archives are by default expected in UTF-8 encoding. +Other encodings can be requested by using the flags +.Dv ZIP_FL_ENC_CP437 +and +.Dv ZIP_FL_ENC_RAW . +.Pp +For details see the relevant man pages. +.Ss Directory Separator +The zip format requires the use of forward slash +.Pq Sq / +as directory separator. +Since backslash +.Pq Sq \e +can be part of a valid file name on Unix systems, +.Nm +does not automatically convert them, even on Windows. +It is the responsibility of the programmer to ensure that all +directory separators are passed as forward slashes to +.Nm . +.Sh THREAD SAFETY +In general, different zip archives opened by +.Nm +are independent of each other and can be used by parallel-running +threads without locking. +If you want to use an archive from multiple threads, you have to +synchronize access to it yourself. +If you use an archive as a source for +.Xr zip_file_add 3 +or +.Xr zip_file_replace 3 , +access to the target archive must be synchronized with access to the +source archive as well. +.Sh READING ZIP ARCHIVES +.Ss Open Archive +.Bl -bullet -compact +.It +.Xr zip_open 3 +.It +.Xr zip_fdopen 3 +.El +.Ss Find Files +.Bl -bullet -compact +.It +.Xr zip_name_locate 3 +.El +.Ss Read Files +.Bl -bullet -compact +.It +.Xr zip_fopen 3 +.It +.Xr zip_fopen_encrypted 3 +.It +.Xr zip_fopen_index 3 +.It +.Xr zip_fopen_index_encrypted 3 +.It +.Xr zip_fread 3 +.It +.Xr zip_file_is_seekable 3 +.It +.Xr zip_fseek 3 +(uncompressed files only) +.It +.Xr zip_ftell 3 +.It +.Xr zip_fclose 3 +.El +.Ss Close Archive +.Bl -bullet -compact +.It +.Xr zip_close 3 +.El +.Ss Miscellaneous +.Bl -bullet -compact +.It +.Xr zip_stat 3 +.It +.Xr zip_compression_method_supported 3 +.It +.Xr zip_encryption_method_supported 3 +.It +.Xr zip_file_get_comment 3 +.It +.Xr zip_file_get_external_attributes 3 +.It +.Xr zip_get_archive_comment 3 +.It +.Xr zip_get_archive_flag 3 +.It +.Xr zip_get_name 3 +.It +.Xr zip_get_num_entries 3 +.It +.Xr zip_set_default_password 3 +.It +.Xr zip_source_pass_to_lower_layer 3 +.El +.Sh CREATING/MODIFYING ZIP ARCHIVES +.Ss Create/Open Archive +.Bl -bullet -compact +.It +.Xr zip_open 3 +.El +.Ss Add/Change Files and Directories +.Bl -bullet -compact +.It +.Xr zip_dir_add 3 +.It +.Xr zip_file_add 3 +.It +.Xr zip_file_replace 3 +.It +.Xr zip_file_set_comment 3 +.It +.Xr zip_file_set_dostime 3 +.It +.Xr zip_file_set_external_attributes 3 +.It +.Xr zip_file_set_encryption 3 +.It +.Xr zip_file_set_mtime 3 +.It +.Xr zip_set_file_compression 3 +.It +.Xr zip_source_buffer 3 +.It +.Xr zip_source_file 3 +.It +.Xr zip_source_filep 3 +.It +.Xr zip_source_free 3 +.It +.Xr zip_source_function 3 +.It +.Xr zip_source_layered 3 +.It +.Xr zip_source_zip 3 +.El +.Ss Rename Files +.Bl -bullet -compact +.It +.Xr zip_rename 3 +.El +.Ss Delete Files +.Bl -bullet -compact +.It +.Xr zip_delete 3 +.El +.Ss Revert Changes +.Bl -bullet -compact +.It +.Xr zip_unchange 3 +.It +.Xr zip_unchange_all 3 +.It +.Xr zip_unchange_archive 3 +.El +.Ss Read/Modify Extra Fields +.Bl -bullet -compact +.It +.Xr zip_file_extra_field_delete 3 +.It +.Xr zip_file_extra_field_delete_by_id 3 +.It +.Xr zip_file_extra_field_get 3 +.It +.Xr zip_file_extra_field_get_by_id 3 +.It +.Xr zip_file_extra_field_set 3 +.It +.Xr zip_file_extra_fields_count 3 +.It +.Xr zip_file_extra_fields_count_by_id 3 +.El +.Ss Close Archive (Writing) +.Bl -bullet -compact +.It +.Xr zip_close 3 +.It +.Xr zip_discard 3 +.El +.Ss Miscellaneous (Writing) +.Bl -bullet -compact +.It +.Xr zip_file_attributes_init 3 +.It +.Xr zip_libzip_version 3 +.It +.Xr zip_register_cancel_callback_with_state 3 +.It +.Xr zip_register_progress_callback_with_state 3 +.It +.Xr zip_set_archive_comment 3 +.It +.Xr zip_set_archive_flag 3 +.It +.Xr zip_source 3 +.El +.Sh ERROR HANDLING +.Bl -bullet -compact +.It +.Xr zip_error_strerror 3 +.It +.Xr zip_strerror 3 +.It +.Xr zip_file_strerror 3 +.It +.Xr zip_file_get_error 3 +.It +.Xr zip_get_error 3 +.It +.Xr zip_error_init_with_code 3 +.It +.Xr zip_error_set 3 +.It +.Xr zip_error_set_from_source 3 +.It +.Xr zip_error_system_type 3 +.It +.Xr zip_errors 3 +.El +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/links b/thirdparty/libzip-1.11.3/man/links new file mode 100644 index 0000000..bf64b84 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/links @@ -0,0 +1,27 @@ +zip_add zip_replace +zip_error_clear zip_file_error_clear +zip_error_get zip_file_error_get +zip_error_init zip_error_init_with_code +zip_file_add zip_file_replace +zip_file_extra_field_delete zip_file_extra_field_delete_by_id +zip_file_extra_field_get zip_file_extra_field_get_by_id +zip_file_extra_fields_count zip_file_extra_fields_count_by_id +zip_file_set_mtime zip_file_set_dostime +zip_file_strerror zip_strerror +zip_fopen zip_fopen_index +zip_fopen_encrypted zip_fopen_index_encrypted +zip_fseek zip_file_is_seekable +zip_open zip_open_from_source +zip_source_begin_write zip_source_begin_write_cloning +zip_source_buffer zip_source_buffer_create +zip_source_buffer_fragment zip_source_buffer_fragment_create +zip_source_file zip_source_file_create +zip_source_filep zip_source_filep_create +zip_source_function zip_source_function_create +zip_source_layered zip_source_layered_create +zip_source_win32a zip_source_win32a_create +zip_source_win32handle zip_source_win32handle_create +zip_source_win32w zip_source_win32w_create +zip_source_zip zip_source_zip_create +zip_source_zip_file zip_source_zip_file_create +zip_stat zip_stat_index diff --git a/thirdparty/libzip-1.11.3/man/update-html.cmake b/thirdparty/libzip-1.11.3/man/update-html.cmake new file mode 100644 index 0000000..4bc469b --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/update-html.cmake @@ -0,0 +1,12 @@ +# expect variables IN and OUT +EXECUTE_PROCESS(COMMAND mandoc -T html -Oman=%N.html,style=../nih-man.css ${IN} + OUTPUT_VARIABLE HTML) +SET(LINKBASE "http://pubs.opengroup.org/onlinepubs/9699919799/functions/") +STRING(REGEX REPLACE "()" "\\1${LINKBASE}\\2\\3" HTML "${HTML}") +STRING(REGEX REPLACE "${LINKBASE}(libzip|zip)" "\\1" HTML "${HTML}") +STRING(REGEX REPLACE "NetBSD [0-9.]*" "NiH" HTML "${HTML}") +FILE(WRITE ${OUT}.new "${HTML}") +CONFIGURE_FILE(${OUT}.new ${OUT} COPYONLY) +FILE(REMOVE ${OUT}.new) + + diff --git a/thirdparty/libzip-1.11.3/man/update-man.cmake b/thirdparty/libzip-1.11.3/man/update-man.cmake new file mode 100644 index 0000000..2459e93 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/update-man.cmake @@ -0,0 +1,7 @@ +# expect variables IN and OUT +EXECUTE_PROCESS(COMMAND mandoc -T man ${IN} OUTPUT_VARIABLE MAN) +STRING(REGEX REPLACE "(NetBSD|macOS) [0-9.]*" "NiH" MAN "${MAN}") +FILE(WRITE ${OUT}.new "${MAN}") +CONFIGURE_FILE(${OUT}.new ${OUT} COPYONLY) +FILE(REMOVE ${OUT}.new) + diff --git a/thirdparty/libzip-1.11.3/man/zip_add.html b/thirdparty/libzip-1.11.3/man/zip_add.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_add.man b/thirdparty/libzip-1.11.3/man/zip_add.man new file mode 100644 index 0000000..8f85e96 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_add.man @@ -0,0 +1,106 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_add.mdoc -- add files to zip archive +.\" Copyright (C) 2004-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ADD" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_add\fR, +\fBzip_replace\fR +\- add file to zip archive or replace file in zip archive (obsolete interface) +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_add\fR(\fIzip_t\ *archive\fR, \fIconst\ char\ *name\fR, \fIzip_source_t\ *source\fR); +.PD +.PP +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_replace\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_source_t\ *source\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_add\fR() +is the obsolete version of +zip_file_add(3). +It is the same as calling +zip_file_add(3) +with an empty +\fIflags\fR +argument. +Similarly, the +\fBzip_replace\fR() +function is the obsolete version of +zip_file_replace(3). +It is the same as calling +zip_file_replace(3) +with an empty +\fIflags\fR +argument. +.SH "SEE ALSO" +libzip(3), +zip_file_add(3), +zip_file_replace(3) +.SH "HISTORY" +\fBzip_add\fR() +was added in libzip 0.6. +In libzip 0.10 the return type was changed from +\fIint\fR +to +\fIzip_int64_t\fR. +It was deprecated in libzip 0.11, use +\fBzip_file_add\fR() +instead. +.PP +\fBzip_replace\fR() +was added in libzip 0.6. +In libzip 0.10 the type of +\fIindex\fR +was changed from +\fIint\fR +to +\fIzip_uint64_t\fR. +It was deprecated in libzip 0.11, use +\fBzip_file_replace\fR() +instead. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_add.mdoc b/thirdparty/libzip-1.11.3/man/zip_add.mdoc new file mode 100644 index 0000000..71bc4c8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_add.mdoc @@ -0,0 +1,96 @@ +.\" zip_add.mdoc -- add files to zip archive +.\" Copyright (C) 2004-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_ADD 3 +.Os +.Sh NAME +.Nm zip_add , +.Nm zip_replace +.Nd add file to zip archive or replace file in zip archive (obsolete interface) +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_add "zip_t *archive" "const char *name" "zip_source_t *source" +.Ft int +.Fn zip_replace "zip_t *archive" "zip_uint64_t index" "zip_source_t *source" +.Sh DESCRIPTION +The function +.Fn zip_add +is the obsolete version of +.Xr zip_file_add 3 . +It is the same as calling +.Xr zip_file_add 3 +with an empty +.Ar flags +argument. +Similarly, the +.Fn zip_replace +function is the obsolete version of +.Xr zip_file_replace 3 . +It is the same as calling +.Xr zip_file_replace 3 +with an empty +.Ar flags +argument. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_add 3 , +.Xr zip_file_replace 3 +.Sh HISTORY +.Fn zip_add +was added in libzip 0.6. +In libzip 0.10 the return type was changed from +.Vt int +to +.Vt zip_int64_t . +It was deprecated in libzip 0.11, use +.Fn zip_file_add +instead. +.Pp +.Fn zip_replace +was added in libzip 0.6. +In libzip 0.10 the type of +.Ar index +was changed from +.Vt int +to +.Vt zip_uint64_t . +It was deprecated in libzip 0.11, use +.Fn zip_file_replace +instead. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_add_dir.html b/thirdparty/libzip-1.11.3/man/zip_add_dir.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_add_dir.man b/thirdparty/libzip-1.11.3/man/zip_add_dir.man new file mode 100644 index 0000000..c2ef0bd --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_add_dir.man @@ -0,0 +1,74 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_add_dir.mdoc -- add directory to zip archive +.\" Copyright (C) 2006-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ADD_DIR" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_add_dir\fR +\- add directory to zip archive (obsolete interface) +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_add_dir\fR(\fIzip_t\ *archive\fR, \fIconst\ char\ *name\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_add_dir\fR() +is the obsolete version of +zip_dir_add(3). +It is the same as calling +zip_dir_add(3) +with an empty flags argument. +.SH "SEE ALSO" +libzip(3), +zip_dir_add(3) +.SH "HISTORY" +\fBzip_add_dir\fR() +was added in libzip 0.8. +In libzip 0.10 the return type was changed from +\fIint\fR +to +\fIzip_int64_t\fR. +It was deprecated in libzip 0.11, use +\fBzip_dir_add\fR() +instead. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_add_dir.mdoc b/thirdparty/libzip-1.11.3/man/zip_add_dir.mdoc new file mode 100644 index 0000000..4a6801b --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_add_dir.mdoc @@ -0,0 +1,69 @@ +.\" zip_add_dir.mdoc -- add directory to zip archive +.\" Copyright (C) 2006-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_ADD_DIR 3 +.Os +.Sh NAME +.Nm zip_add_dir +.Nd add directory to zip archive (obsolete interface) +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_add_dir "zip_t *archive" "const char *name" +.Sh DESCRIPTION +The function +.Fn zip_add_dir +is the obsolete version of +.Xr zip_dir_add 3 . +It is the same as calling +.Xr zip_dir_add 3 +with an empty flags argument. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_dir_add 3 +.Sh HISTORY +.Fn zip_add_dir +was added in libzip 0.8. +In libzip 0.10 the return type was changed from +.Vt int +to +.Vt zip_int64_t . +It was deprecated in libzip 0.11, use +.Fn zip_dir_add +instead. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_close.html b/thirdparty/libzip-1.11.3/man/zip_close.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_close.man b/thirdparty/libzip-1.11.3/man/zip_close.man new file mode 100644 index 0000000..d1c5a0e --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_close.man @@ -0,0 +1,153 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_close.mdoc -- close zip archive +.\" Copyright (C) 2003-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_CLOSE" "3" "January 23, 2023" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_close\fR +\- close zip archive +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_close\fR(\fIzip_t\ *archive\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_close\fR() +function writes any changes made to +\fIarchive\fR +to disk. +If +\fIarchive\fR +contains no files, the file is completely removed (no empty archive is +written), unless the archive flag +\fRZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE\fR +is set. +If successful, +\fIarchive\fR +is freed. +Otherwise +\fIarchive\fR +is left unchanged and must still be freed. +.PP +To close and free a zip archive without saving changes, use +zip_discard(3). +.PP +Progress updates for GUIs can be implemented using +zip_register_progress_callback_with_state(3). +Cancelling the write of an archive during +\fBzip_close\fR +can be implemented using +zip_register_cancel_callback_with_state(3). +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_close\fR() +will fail if: +.TP 19n +[\fRZIP_ER_EOF\fR] +Unexpected end-of-file found while reading from a file. +.TP 19n +[\fRZIP_ER_INTERNAL\fR] +The callback function of an added or replaced file returned an +error but failed to report which. +.TP 19n +[\fRZIP_ER_INVAL\fR] +The +\fIpath\fR +argument is +\fRNULL\fR. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.TP 19n +[\fRZIP_ER_NOZIP\fR] +File is not a zip archive. +.TP 19n +[\fRZIP_ER_READ\fR] +A file read failed. +.TP 19n +[\fRZIP_ER_RENAME\fR] +A temporary file could not be renamed to its final name. +.TP 19n +[\fRZIP_ER_SEEK\fR] +A file seek failed. +.TP 19n +[\fRZIP_ER_TMPOPEN\fR] +A temporary file could not be created. +.TP 19n +[\fRZIP_ER_WRITE\fR] +A file write failed. +.TP 19n +[\fRZIP_ER_ZLIB\fR] +An error occurred while (de)compressing a stream with +zlib(3). +.PD 0 +.PP +Additionally, any errors returned by the callback function +for added or replaced files will be passed back. +.PD +.SH "SEE ALSO" +libzip(3), +zip_discard(3), +zip_fdopen(3), +zip_get_error(3), +zip_open(3), +zip_register_cancel_callback_with_state(3), +zip_register_progress_callback_with_state(3), +zip_set_archive_flag(3), +zip_strerror(3) +.SH "HISTORY" +\fBzip_close\fR() +was added in libzip 0.6. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> +.SH "CAVEATS" +Please note that all indices, +zip_stat(3) +information and other data about the archive is invalid after +\fBzip_close\fR. +When you open the same file again, it will be a completely new +\fIzip_t\fR +structure. diff --git a/thirdparty/libzip-1.11.3/man/zip_close.mdoc b/thirdparty/libzip-1.11.3/man/zip_close.mdoc new file mode 100644 index 0000000..4716b9d --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_close.mdoc @@ -0,0 +1,136 @@ +.\" zip_close.mdoc -- close zip archive +.\" Copyright (C) 2003-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd January 23, 2023 +.Dt ZIP_CLOSE 3 +.Os +.Sh NAME +.Nm zip_close +.Nd close zip archive +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_close "zip_t *archive" +.Sh DESCRIPTION +The +.Fn zip_close +function writes any changes made to +.Ar archive +to disk. +If +.Ar archive +contains no files, the file is completely removed (no empty archive is +written), unless the archive flag +.Dv ZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE +is set. +If successful, +.Ar archive +is freed. +Otherwise +.Ar archive +is left unchanged and must still be freed. +.Pp +To close and free a zip archive without saving changes, use +.Xr zip_discard 3 . +.Pp +Progress updates for GUIs can be implemented using +.Xr zip_register_progress_callback_with_state 3 . +Cancelling the write of an archive during +.Nm +can be implemented using +.Xr zip_register_cancel_callback_with_state 3 . +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_close +will fail if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_EOF +Unexpected end-of-file found while reading from a file. +.It Bq Er ZIP_ER_INTERNAL +The callback function of an added or replaced file returned an +error but failed to report which. +.It Bq Er ZIP_ER_INVAL +The +.Ar path +argument is +.Dv NULL . +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.It Bq Er ZIP_ER_NOZIP +File is not a zip archive. +.It Bq Er ZIP_ER_READ +A file read failed. +.It Bq Er ZIP_ER_RENAME +A temporary file could not be renamed to its final name. +.It Bq Er ZIP_ER_SEEK +A file seek failed. +.It Bq Er ZIP_ER_TMPOPEN +A temporary file could not be created. +.It Bq Er ZIP_ER_WRITE +A file write failed. +.It Bq Er ZIP_ER_ZLIB +An error occurred while (de)compressing a stream with +.Xr zlib 3 . +.El +Additionally, any errors returned by the callback function +for added or replaced files will be passed back. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_discard 3 , +.Xr zip_fdopen 3 , +.Xr zip_get_error 3 , +.Xr zip_open 3 , +.Xr zip_register_cancel_callback_with_state 3 , +.Xr zip_register_progress_callback_with_state 3 , +.Xr zip_set_archive_flag 3 , +.Xr zip_strerror 3 +.Sh HISTORY +.Fn zip_close +was added in libzip 0.6. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at +.Sh CAVEATS +Please note that all indices, +.Xr zip_stat 3 +information and other data about the archive is invalid after +.Nm . +When you open the same file again, it will be a completely new +.Vt zip_t +structure. diff --git a/thirdparty/libzip-1.11.3/man/zip_compression_method_supported.html b/thirdparty/libzip-1.11.3/man/zip_compression_method_supported.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_compression_method_supported.man b/thirdparty/libzip-1.11.3/man/zip_compression_method_supported.man new file mode 100644 index 0000000..ca45d17 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_compression_method_supported.man @@ -0,0 +1,70 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_compression_method_supported.mdoc -- return if compression method is supported +.\" Copyright (C) 2020 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_COMPRESSION_METHOD_SUPPORTED" "3" "April 2, 2020" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_compression_method_supported\fR +\- return if a compression method is supported +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_compression_method_supported\fR(\fIzip_int32_t\ method\fR, \fIint\ compress\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_compression_method_supported\fR() +returns if the compression method +\fImethod\fR +is supported for compression (if +\fIcompress\fR +is zero) or decompression (otherwise). +.SH "RETURN VALUES" +Returns 1 if the method is supported, 0 otherwise. +.SH "SEE ALSO" +libzip(3), +zip_encryption_method_supported(3), +zip_set_file_compression(3) +.SH "HISTORY" +\fBzip_compression_method_supported\fR() +was added in libzip 1.7.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_compression_method_supported.mdoc b/thirdparty/libzip-1.11.3/man/zip_compression_method_supported.mdoc new file mode 100644 index 0000000..77553cf --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_compression_method_supported.mdoc @@ -0,0 +1,65 @@ +.\" zip_compression_method_supported.mdoc -- return if compression method is supported +.\" Copyright (C) 2020 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd April 2, 2020 +.Dt ZIP_COMPRESSION_METHOD_SUPPORTED 3 +.Os +.Sh NAME +.Nm zip_compression_method_supported +.Nd return if a compression method is supported +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_compression_method_supported "zip_int32_t method" "int compress" +.Sh DESCRIPTION +The +.Fn zip_compression_method_supported +returns if the compression method +.Ar method +is supported for compression (if +.Ar compress +is zero) or decompression (otherwise). +.Sh RETURN VALUES +Returns 1 if the method is supported, 0 otherwise. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_encryption_method_supported 3 , +.Xr zip_set_file_compression 3 +.Sh HISTORY +.Fn zip_compression_method_supported +was added in libzip 1.7.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_delete.html b/thirdparty/libzip-1.11.3/man/zip_delete.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_delete.man b/thirdparty/libzip-1.11.3/man/zip_delete.man new file mode 100644 index 0000000..f023bec --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_delete.man @@ -0,0 +1,84 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_delete.mdoc -- delete files from zip archive +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_DELETE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_delete\fR +\- delete file from zip archive +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_delete\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR); +.PD +.SH "DESCRIPTION" +The file at position +\fIindex\fR +in the zip archive +\fIarchive\fR +is marked as deleted. +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_delete\fR() +fails if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIindex\fR +is not a valid file index in +\fIarchive\fR. +.SH "SEE ALSO" +libzip(3), +zip_unchange(3) +.SH "HISTORY" +\fBzip_delete\fR() +was added in libzip 0.6. +In libzip 0.10 the type of +\fIindex\fR +was changed from +\fIint\fR +to +\fIzip_uint64_t\fR. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_delete.mdoc b/thirdparty/libzip-1.11.3/man/zip_delete.mdoc new file mode 100644 index 0000000..0b622fe --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_delete.mdoc @@ -0,0 +1,80 @@ +.\" zip_delete.mdoc -- delete files from zip archive +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_DELETE 3 +.Os +.Sh NAME +.Nm zip_delete +.Nd delete file from zip archive +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_delete "zip_t *archive" "zip_uint64_t index" +.Sh DESCRIPTION +The file at position +.Ar index +in the zip archive +.Ar archive +is marked as deleted. +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_delete +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar index +is not a valid file index in +.Ar archive . +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_unchange 3 +.Sh HISTORY +.Fn zip_delete +was added in libzip 0.6. +In libzip 0.10 the type of +.Ar index +was changed from +.Vt int +to +.Vt zip_uint64_t . +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_dir_add.html b/thirdparty/libzip-1.11.3/man/zip_dir_add.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_dir_add.man b/thirdparty/libzip-1.11.3/man/zip_dir_add.man new file mode 100644 index 0000000..32427b0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_dir_add.man @@ -0,0 +1,116 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_dir_add.mdoc -- add directory to zip archive +.\" Copyright (C) 2006-2020 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_DIR_ADD" "3" "September 20, 2020" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_dir_add\fR +\- add directory to zip archive +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_dir_add\fR(\fIzip_t\ *archive\fR, \fIconst\ char\ *name\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_dir_add\fR() +adds a directory to a zip archive. +The argument +\fIarchive\fR +specifies the zip archive to which the directory should be added. +\fIname\fR +is the directory's name in the zip archive. +.PP +This function adds an entry to the archive. +It does not check whether a directory with that name exists in the +file system, nor does it add its contents if it does. +The +\fIflags\fR +argument can be any of: +.TP 22n +\fRZIP_FL_ENC_GUESS\fR +Guess encoding of +\fIname\fR +(default). +(Only CP-437 and UTF-8 are recognized.) +.TP 22n +\fRZIP_FL_ENC_UTF_8\fR +Interpret +\fIname\fR +as UTF-8. +.TP 22n +\fRZIP_FL_ENC_CP437\fR +Interpret +\fIname\fR +as code page 437 (CP-437). +.SH "RETURN VALUES" +Upon successful completion, the index of the new entry in the archive +is returned. +Otherwise, \-1 is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_dir_add\fR() +fails if: +.TP 19n +[\fRZIP_ER_EXISTS\fR] +There is already an entry called +\fIname\fR +in the archive. +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIarchive\fR +or +\fIname\fR +are +\fRNULL\fR, +or invalid UTF-8 encoded file names. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.SH "SEE ALSO" +libzip(3), +zip_file_add(3) +.SH "HISTORY" +\fBzip_dir_add\fR() +was added in libzip 0.11. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_dir_add.mdoc b/thirdparty/libzip-1.11.3/man/zip_dir_add.mdoc new file mode 100644 index 0000000..c4b697b --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_dir_add.mdoc @@ -0,0 +1,109 @@ +.\" zip_dir_add.mdoc -- add directory to zip archive +.\" Copyright (C) 2006-2020 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd September 20, 2020 +.Dt ZIP_DIR_ADD 3 +.Os +.Sh NAME +.Nm zip_dir_add +.Nd add directory to zip archive +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_dir_add "zip_t *archive" "const char *name" "zip_flags_t flags" +.Sh DESCRIPTION +The function +.Fn zip_dir_add +adds a directory to a zip archive. +The argument +.Ar archive +specifies the zip archive to which the directory should be added. +.Ar name +is the directory's name in the zip archive. +.Pp +This function adds an entry to the archive. +It does not check whether a directory with that name exists in the +file system, nor does it add its contents if it does. +The +.Ar flags +argument can be any of: +.Bl -tag -width XZIPXFLXENCXSTRICTXX +.It Dv ZIP_FL_ENC_GUESS +Guess encoding of +.Ar name +(default). +(Only CP-437 and UTF-8 are recognized.) +.It Dv ZIP_FL_ENC_UTF_8 +Interpret +.Ar name +as UTF-8. +.It Dv ZIP_FL_ENC_CP437 +Interpret +.Ar name +as code page 437 (CP-437). +.El +.Sh RETURN VALUES +Upon successful completion, the index of the new entry in the archive +is returned. +Otherwise, \-1 is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_dir_add +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_EXISTS +There is already an entry called +.Ar name +in the archive. +.It Bq Er ZIP_ER_INVAL +.Ar archive +or +.Ar name +are +.Dv NULL , +or invalid UTF-8 encoded file names. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_add 3 +.Sh HISTORY +.Fn zip_dir_add +was added in libzip 0.11. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_discard.html b/thirdparty/libzip-1.11.3/man/zip_discard.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_discard.man b/thirdparty/libzip-1.11.3/man/zip_discard.man new file mode 100644 index 0000000..217ae7a --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_discard.man @@ -0,0 +1,66 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_discard.mdoc -- close zip archive and discard changes +.\" Copyright (C) 2012-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_DISCARD" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_discard\fR +\- close zip archive and discard changes +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_discard\fR(\fIzip_t\ *archive\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_discard\fR() +function closes +\fIarchive\fR +and frees the memory allocated for it. +Any changes to the archive are not written to disk and discarded. +.SH "SEE ALSO" +libzip(3), +zip_close(3) +.SH "HISTORY" +\fBzip_discard\fR() +was added in libzip 0.11. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_discard.mdoc b/thirdparty/libzip-1.11.3/man/zip_discard.mdoc new file mode 100644 index 0000000..5c4f3f4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_discard.mdoc @@ -0,0 +1,61 @@ +.\" zip_discard.mdoc -- close zip archive and discard changes +.\" Copyright (C) 2012-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_DISCARD 3 +.Os +.Sh NAME +.Nm zip_discard +.Nd close zip archive and discard changes +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft void +.Fn zip_discard "zip_t *archive" +.Sh DESCRIPTION +The +.Fn zip_discard +function closes +.Ar archive +and frees the memory allocated for it. +Any changes to the archive are not written to disk and discarded. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_close 3 +.Sh HISTORY +.Fn zip_discard +was added in libzip 0.11. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_encryption_method_supported.html b/thirdparty/libzip-1.11.3/man/zip_encryption_method_supported.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_encryption_method_supported.man b/thirdparty/libzip-1.11.3/man/zip_encryption_method_supported.man new file mode 100644 index 0000000..8b09aea --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_encryption_method_supported.man @@ -0,0 +1,70 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_encryption_method_supported.mdoc -- return if encryption method is supported +.\" Copyright (C) 2020 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ENCRYPTION_METHOD_SUPPORTED" "3" "April 2, 2020" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_encryption_method_supported\fR +\- return if an encryption method is supported +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_encryption_method_supported\fR(\fIzip_int16_t\ method\fR, \fIint\ encrypt\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_encryption_method_supported\fR() +returns if the encryption method +\fImethod\fR +is supported for encryption (if +\fIencrypt\fR +is zero) or decryption (otherwise). +.SH "RETURN VALUES" +Returns 1 if the method is supported, 0 otherwise. +.SH "SEE ALSO" +libzip(3), +zip_compression_method_supported(3), +zip_file_set_encryption(3) +.SH "HISTORY" +\fBzip_encryption_method_supported\fR() +was added in libzip 1.7.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_encryption_method_supported.mdoc b/thirdparty/libzip-1.11.3/man/zip_encryption_method_supported.mdoc new file mode 100644 index 0000000..84c0ae8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_encryption_method_supported.mdoc @@ -0,0 +1,65 @@ +.\" zip_encryption_method_supported.mdoc -- return if encryption method is supported +.\" Copyright (C) 2020 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd April 2, 2020 +.Dt ZIP_ENCRYPTION_METHOD_SUPPORTED 3 +.Os +.Sh NAME +.Nm zip_encryption_method_supported +.Nd return if an encryption method is supported +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_encryption_method_supported "zip_int16_t method" "int encrypt" +.Sh DESCRIPTION +The +.Fn zip_encryption_method_supported +returns if the encryption method +.Ar method +is supported for encryption (if +.Ar encrypt +is zero) or decryption (otherwise). +.Sh RETURN VALUES +Returns 1 if the method is supported, 0 otherwise. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_compression_method_supported 3 , +.Xr zip_file_set_encryption 3 +.Sh HISTORY +.Fn zip_encryption_method_supported +was added in libzip 1.7.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_error_clear.html b/thirdparty/libzip-1.11.3/man/zip_error_clear.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_error_clear.man b/thirdparty/libzip-1.11.3/man/zip_error_clear.man new file mode 100644 index 0000000..97b8cae --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_clear.man @@ -0,0 +1,79 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_error_clear.mdoc -- clear error state for archive or file +.\" Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ERROR_CLEAR" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_error_clear\fR, +\fBzip_file_error_clear\fR +\- clear error state for archive or file +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_error_clear\fR(\fIzip_t\ *archive\fR); +.PD +.PP +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_file_error_clear\fR(\fIzip_file_t\ *file\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_error_clear\fR() +function clears the error state for the zip archive +\fIarchive\fR. +.PP +The +\fBzip_file_error_clear\fR() +function does the same for the zip file +\fIfile\fR. +.SH "SEE ALSO" +libzip(3), +zip_get_error(3) +.SH "HISTORY" +\fBzip_error_clear\fR() +and +\fBzip_file_error_clear\fR() +were added in libzip 0.8. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_error_clear.mdoc b/thirdparty/libzip-1.11.3/man/zip_error_clear.mdoc new file mode 100644 index 0000000..5b2bc6e --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_clear.mdoc @@ -0,0 +1,69 @@ +.\" zip_error_clear.mdoc -- clear error state for archive or file +.\" Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_ERROR_CLEAR 3 +.Os +.Sh NAME +.Nm zip_error_clear , +.Nm zip_file_error_clear +.Nd clear error state for archive or file +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft void +.Fn zip_error_clear "zip_t *archive" +.Ft void +.Fn zip_file_error_clear "zip_file_t *file" +.Sh DESCRIPTION +The +.Fn zip_error_clear +function clears the error state for the zip archive +.Ar archive . +.Pp +The +.Fn zip_file_error_clear +function does the same for the zip file +.Ar file . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_get_error 3 +.Sh HISTORY +.Fn zip_error_clear +and +.Fn zip_file_error_clear +were added in libzip 0.8. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_error_code_system.html b/thirdparty/libzip-1.11.3/man/zip_error_code_system.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_error_code_system.man b/thirdparty/libzip-1.11.3/man/zip_error_code_system.man new file mode 100644 index 0000000..a50e4dd --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_code_system.man @@ -0,0 +1,68 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_error_code_system.mdoc -- get system error part of zip_error +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ERROR_CODE_SYSTEM" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_error_code_system\fR +\- get operating system error part of zip_error +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_error_code_system\fR(\fIconst\ zip_error_t\ *ze\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_error_code_system\fR() +function returns the system specific part of the error from the +zip_error error +\fIze\fR. +For finding out what system reported the error, use +zip_error_system_type(3). +.SH "SEE ALSO" +libzip(3), +zip_error_code_zip(3), +zip_error_system_type(3) +.SH "HISTORY" +\fBzip_error_code_system\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_error_code_system.mdoc b/thirdparty/libzip-1.11.3/man/zip_error_code_system.mdoc new file mode 100644 index 0000000..54a4f63 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_code_system.mdoc @@ -0,0 +1,63 @@ +.\" zip_error_code_system.mdoc -- get system error part of zip_error +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_ERROR_CODE_SYSTEM 3 +.Os +.Sh NAME +.Nm zip_error_code_system +.Nd get operating system error part of zip_error +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_error_code_system "const zip_error_t *ze" +.Sh DESCRIPTION +The +.Fn zip_error_code_system +function returns the system specific part of the error from the +zip_error error +.Ar ze . +For finding out what system reported the error, use +.Xr zip_error_system_type 3 . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_error_code_zip 3 , +.Xr zip_error_system_type 3 +.Sh HISTORY +.Fn zip_error_code_system +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_error_code_zip.html b/thirdparty/libzip-1.11.3/man/zip_error_code_zip.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_error_code_zip.man b/thirdparty/libzip-1.11.3/man/zip_error_code_zip.man new file mode 100644 index 0000000..620773c --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_code_zip.man @@ -0,0 +1,65 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_error_code_zip.mdoc -- get libzip error part of zip_error +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ERROR_CODE_ZIP" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_error_code_zip\fR +\- get libzip error part of zip_error +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_error_code_zip\fR(\fIconst\ zip_error_t\ *ze\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_error_code_zip\fR() +function returns the libzip specific part of the error from the +zip_error error +\fIze\fR. +.SH "SEE ALSO" +libzip(3), +zip_error_code_system(3) +.SH "HISTORY" +\fBzip_error_code_zip\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_error_code_zip.mdoc b/thirdparty/libzip-1.11.3/man/zip_error_code_zip.mdoc new file mode 100644 index 0000000..a07c90e --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_code_zip.mdoc @@ -0,0 +1,60 @@ +.\" zip_error_code_zip.mdoc -- get libzip error part of zip_error +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_ERROR_CODE_ZIP 3 +.Os +.Sh NAME +.Nm zip_error_code_zip +.Nd get libzip error part of zip_error +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_error_code_zip "const zip_error_t *ze" +.Sh DESCRIPTION +The +.Fn zip_error_code_zip +function returns the libzip specific part of the error from the +zip_error error +.Ar ze . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_error_code_system 3 +.Sh HISTORY +.Fn zip_error_code_zip +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_error_fini.html b/thirdparty/libzip-1.11.3/man/zip_error_fini.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_error_fini.man b/thirdparty/libzip-1.11.3/man/zip_error_fini.man new file mode 100644 index 0000000..e075e5c --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_fini.man @@ -0,0 +1,65 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_error_fini.mdoc -- clean up zip_error +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ERROR_FINI" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_error_fini\fR +\- clean up zip_error structure +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_error_fini\fR(\fIzip_error_t\ *ze\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_error_fini\fR() +function cleans up and frees internally allocated memory of the +zip_error pointed to by +\fIze\fR. +.SH "SEE ALSO" +libzip(3), +zip_error_init(3) +.SH "HISTORY" +\fBzip_error_fini\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_error_fini.mdoc b/thirdparty/libzip-1.11.3/man/zip_error_fini.mdoc new file mode 100644 index 0000000..80395aa --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_fini.mdoc @@ -0,0 +1,60 @@ +.\" zip_error_fini.mdoc -- clean up zip_error +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_ERROR_FINI 3 +.Os +.Sh NAME +.Nm zip_error_fini +.Nd clean up zip_error structure +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft void +.Fn zip_error_fini "zip_error_t *ze" +.Sh DESCRIPTION +The +.Fn zip_error_fini +function cleans up and frees internally allocated memory of the +zip_error pointed to by +.Ar ze . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_error_init 3 +.Sh HISTORY +.Fn zip_error_fini +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_error_get.html b/thirdparty/libzip-1.11.3/man/zip_error_get.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_error_get.man b/thirdparty/libzip-1.11.3/man/zip_error_get.man new file mode 100644 index 0000000..0ca966e --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_get.man @@ -0,0 +1,139 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_error_get.mdoc -- get error codes for archive or file +.\" Copyright (C) 2004-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ERROR_GET" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_error_get\fR, +\fBzip_file_error_get\fR +\- get error codes for archive or file (obsolete interface) +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_error_get\fR(\fIzip_t\ *archive\fR, \fIint\ *zep\fR, \fIint\ *sep\fR); +.PD +.PP +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_file_error_get\fR(\fIzip_file_t\ *file\fR, \fIint\ *zep\fR, \fIint\ *sep\fR); +.PD +.SH "DESCRIPTION" +The functions +\fBzip_error_get\fR() +and +\fBzip_file_error_get\fR() +are deprecated. +Use +zip_error_code_system(3), +zip_error_code_zip(3), +zip_file_get_error(3), +and +zip_get_error(3) +instead. +.PP +For +\fBzip_error_get\fR(), +replace +.nf +.sp +.RS 6n +int ze, se; +zip_error_get(za, &ze, &se); +.RE +.fi +with +.nf +.sp +.RS 6n +int ze, se; +zip_error_t *error = zip_get_error(za); +ze = zip_error_code_zip(error); +se = zip_error_code_system(error); +.RE +.fi +For +\fBzip_file_error_get\fR(), +replace +.nf +.sp +.RS 6n +int ze, se; +zip_file_error_get(zf, &ze, &se); +.RE +.fi +with +.nf +.sp +.RS 6n +int ze, se; +zip_error_t *error = zip_file_get_error(zf); +ze = zip_error_code_zip(error); +se = zip_error_code_system(error); +.RE +.fi +.SH "SEE ALSO" +libzip(3), +zip_error_code_system(3), +zip_error_code_zip(3), +zip_file_get_error(3), +zip_get_error(3) +.SH "HISTORY" +\fBzip_error_get\fR() +was added in libzip 0.6. +It was deprecated in libzip 1.0, use +\fBzip_get_error\fR(), +\fBzip_error_code_zip\fR(), +/ +\fBzip_error_code_system\fR() +instead. +.PP +\fBzip_file_error_get\fR() +was added in libzip 0.6. +It was deprecated in libzip 1.0, use +\fBzip_file_get_error\fR(), +\fBzip_error_code_zip\fR(), +/ +\fBzip_error_code_system\fR() +instead. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_error_get.mdoc b/thirdparty/libzip-1.11.3/man/zip_error_get.mdoc new file mode 100644 index 0000000..55b0979 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_get.mdoc @@ -0,0 +1,117 @@ +.\" zip_error_get.mdoc -- get error codes for archive or file +.\" Copyright (C) 2004-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_ERROR_GET 3 +.Os +.Sh NAME +.Nm zip_error_get , +.Nm zip_file_error_get +.Nd get error codes for archive or file (obsolete interface) +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft void +.Fn zip_error_get "zip_t *archive" "int *zep" "int *sep" +.Ft void +.Fn zip_file_error_get "zip_file_t *file" "int *zep" "int *sep" +.Sh DESCRIPTION +The functions +.Fn zip_error_get +and +.Fn zip_file_error_get +are deprecated. +Use +.Xr zip_error_code_system 3 , +.Xr zip_error_code_zip 3 , +.Xr zip_file_get_error 3 , +and +.Xr zip_get_error 3 +instead. +.Pp +For +.Fn zip_error_get , +replace +.Bd -literal -offset indent +int ze, se; +zip_error_get(za, &ze, &se); +.Ed +with +.Bd -literal -offset indent +int ze, se; +zip_error_t *error = zip_get_error(za); +ze = zip_error_code_zip(error); +se = zip_error_code_system(error); +.Ed +For +.Fn zip_file_error_get , +replace +.Bd -literal -offset indent +int ze, se; +zip_file_error_get(zf, &ze, &se); +.Ed +with +.Bd -literal -offset indent +int ze, se; +zip_error_t *error = zip_file_get_error(zf); +ze = zip_error_code_zip(error); +se = zip_error_code_system(error); +.Ed +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_error_code_system 3 , +.Xr zip_error_code_zip 3 , +.Xr zip_file_get_error 3 , +.Xr zip_get_error 3 +.Sh HISTORY +.Fn zip_error_get +was added in libzip 0.6. +It was deprecated in libzip 1.0, use +.Fn zip_get_error , +.Fn zip_error_code_zip , +/ +.Fn zip_error_code_system +instead. +.Pp +.Fn zip_file_error_get +was added in libzip 0.6. +It was deprecated in libzip 1.0, use +.Fn zip_file_get_error , +.Fn zip_error_code_zip , +/ +.Fn zip_error_code_system +instead. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_error_get_sys_type.html b/thirdparty/libzip-1.11.3/man/zip_error_get_sys_type.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_error_get_sys_type.man b/thirdparty/libzip-1.11.3/man/zip_error_get_sys_type.man new file mode 100644 index 0000000..48958db --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_get_sys_type.man @@ -0,0 +1,88 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_error_get_sys_type.mdoc -- get type of error +.\" Copyright (C) 2004-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ERROR_GET_SYS_TYPE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_error_get_sys_type\fR +\- get type of system error code (obsolete interface) +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_error_get_sys_type\fR(\fIint\ ze\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_error_get_sys_type\fR() +is deprecated; use +zip_error_init_with_code(3) +and +zip_error_system_type(3) +instead. +.PP +Replace +.nf +.sp +.RS 6n +int i = zip_error_get_sys_type(ze); +.RE +.fi +with +.nf +.sp +.RS 6n +zip_error_t error; +zip_error_init_with_code(&error, ze); +int i = zip_error_system_type(&error); +.RE +.fi +.SH "SEE ALSO" +libzip(3), +zip_error_init_with_code(3), +zip_error_system_type(3) +.SH "HISTORY" +\fBzip_error_get_sys_type\fR() +was added in libzip 0.6. +It was deprecated in libzip 1.0, use +\fBzip_error_system_type\fR() +instead. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_error_get_sys_type.mdoc b/thirdparty/libzip-1.11.3/man/zip_error_get_sys_type.mdoc new file mode 100644 index 0000000..43219a3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_get_sys_type.mdoc @@ -0,0 +1,77 @@ +.\" zip_error_get_sys_type.mdoc -- get type of error +.\" Copyright (C) 2004-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_ERROR_GET_SYS_TYPE 3 +.Os +.Sh NAME +.Nm zip_error_get_sys_type +.Nd get type of system error code (obsolete interface) +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_error_get_sys_type "int ze" +.Sh DESCRIPTION +The function +.Fn zip_error_get_sys_type +is deprecated; use +.Xr zip_error_init_with_code 3 +and +.Xr zip_error_system_type 3 +instead. +.Pp +Replace +.Bd -literal -offset indent +int i = zip_error_get_sys_type(ze); +.Ed +with +.Bd -literal -offset indent +zip_error_t error; +zip_error_init_with_code(&error, ze); +int i = zip_error_system_type(&error); +.Ed +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_error_init_with_code 3 , +.Xr zip_error_system_type 3 +.Sh HISTORY +.Fn zip_error_get_sys_type +was added in libzip 0.6. +It was deprecated in libzip 1.0, use +.Fn zip_error_system_type +instead. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_error_init.html b/thirdparty/libzip-1.11.3/man/zip_error_init.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_error_init.man b/thirdparty/libzip-1.11.3/man/zip_error_init.man new file mode 100644 index 0000000..664867d --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_init.man @@ -0,0 +1,85 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_error_init.mdoc -- initialize zip_error +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ERROR_INIT" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_error_init\fR, +\fBzip_error_init_with_code\fR +\- initialize zip_error structure +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_error_init\fR(\fIzip_error_t\ *error\fR); +.PD +.PP +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_error_init_with_code\fR(\fIzip_error_t\ *error\fR, \fIint\ ze\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_error_init\fR() +function initializes the zip_error pointed to by +\fIerror\fR. +\fI*error\fR +must be allocated before calling +\fBzip_error_init\fR(). +.PP +The +\fBzip_error_init_with_code\fR() +function does the same, but additionally sets the zip error code to +\fIze\fR +and sets the system error code to the current +errno(3) +value, if appropriate. +.SH "SEE ALSO" +libzip(3), +zip_error_fini(3) +.SH "HISTORY" +\fBzip_error_init\fR() +and +\fBzip_error_init_with_code\fR() +were added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_error_init.mdoc b/thirdparty/libzip-1.11.3/man/zip_error_init.mdoc new file mode 100644 index 0000000..3f2e3b7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_init.mdoc @@ -0,0 +1,76 @@ +.\" zip_error_init.mdoc -- initialize zip_error +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_ERROR_INIT 3 +.Os +.Sh NAME +.Nm zip_error_init , +.Nm zip_error_init_with_code +.Nd initialize zip_error structure +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft void +.Fn zip_error_init "zip_error_t *error" +.Ft void +.Fn zip_error_init_with_code "zip_error_t *error" "int ze" +.Sh DESCRIPTION +The +.Fn zip_error_init +function initializes the zip_error pointed to by +.Ar error . +.Ar *error +must be allocated before calling +.Fn zip_error_init . +.Pp +The +.Fn zip_error_init_with_code +function does the same, but additionally sets the zip error code to +.Ar ze +and sets the system error code to the current +.Xr errno 3 +value, if appropriate. +.\" TODO: describe when you would need to call this at all +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_error_fini 3 +.Sh HISTORY +.Fn zip_error_init +and +.Fn zip_error_init_with_code +were added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_error_set.html b/thirdparty/libzip-1.11.3/man/zip_error_set.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_error_set.man b/thirdparty/libzip-1.11.3/man/zip_error_set.man new file mode 100644 index 0000000..1f3d980 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_set.man @@ -0,0 +1,75 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_error_set.mdoc -- set zip_error +.\" Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ERROR_SET" "3" "December 5, 2022" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_error_set\fR +\- fill in zip_error structure +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_error_set\fR(\fIzip_error_t\ *ze\fR, \fIint\ le\fR, \fIint\ se\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_error_set\fR() +function sets the zip_error pointed to by +\fIze\fR +to the libzip error code +\fIle\fR +and the system error code +\fIse\fR. +.PP +\fIze\fR +must be allocated and initialized with +zip_error_init(3) +before calling +\fBzip_error_set\fR(). +.SH "SEE ALSO" +libzip(3), +zip_error_init(3), +zip_error_set_from_source(3) +.SH "HISTORY" +\fBzip_error_set\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_error_set.mdoc b/thirdparty/libzip-1.11.3/man/zip_error_set.mdoc new file mode 100644 index 0000000..d421867 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_set.mdoc @@ -0,0 +1,70 @@ +.\" zip_error_set.mdoc -- set zip_error +.\" Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 5, 2022 +.Dt ZIP_ERROR_SET 3 +.Os +.Sh NAME +.Nm zip_error_set +.Nd fill in zip_error structure +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft void +.Fn zip_error_set "zip_error_t *ze" "int le" "int se" +.Sh DESCRIPTION +The +.Fn zip_error_set +function sets the zip_error pointed to by +.Ar ze +to the libzip error code +.Ar le +and the system error code +.Ar se . +.Pp +.Ar ze +must be allocated and initialized with +.Xr zip_error_init 3 +before calling +.Fn zip_error_set . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_error_init 3 , +.Xr zip_error_set_from_source 3 +.Sh HISTORY +.Fn zip_error_set +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_error_set_from_source.html b/thirdparty/libzip-1.11.3/man/zip_error_set_from_source.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_error_set_from_source.man b/thirdparty/libzip-1.11.3/man/zip_error_set_from_source.man new file mode 100644 index 0000000..148236c --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_set_from_source.man @@ -0,0 +1,74 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_error_set_from_source.mdoc -- set zip_error from source +.\" Copyright (C) 2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ERROR_SET_FROM_SOURCE" "3" "December 5, 2022" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_error_set_from_source\fR +\- fill in zip_error structure from source +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_error_set_from_source\fR(\fIzip_error_t\ *ze\fR, \fIzip_source_t\ *src\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_error_set_from_source\fR() +function sets the zip_error pointed to by +\fIze\fR +to the error reported by +\fIsrc\fR +as returned by +zip_error_source(3). +\fIze\fR +must be allocated and initialized with +zip_error_init(3) +before calling +\fBzip_error_set_from_source\fR(). +.SH "SEE ALSO" +libzip(3), +zip_error_init(3), +zip_error_set(3) +.SH "HISTORY" +\fBzip_error_set_from_source\fR() +was added in libzip 1.10. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_error_set_from_source.mdoc b/thirdparty/libzip-1.11.3/man/zip_error_set_from_source.mdoc new file mode 100644 index 0000000..48f974f --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_set_from_source.mdoc @@ -0,0 +1,69 @@ +.\" zip_error_set_from_source.mdoc -- set zip_error from source +.\" Copyright (C) 2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 5, 2022 +.Dt ZIP_ERROR_SET_FROM_SOURCE 3 +.Os +.Sh NAME +.Nm zip_error_set_from_source +.Nd fill in zip_error structure from source +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft void +.Fn zip_error_set_from_source "zip_error_t *ze" "zip_source_t *src" +.Sh DESCRIPTION +The +.Fn zip_error_set_from_source +function sets the zip_error pointed to by +.Ar ze +to the error reported by +.Ar src +as returned by +.Xr zip_error_source 3 . +.Ar ze +must be allocated and initialized with +.Xr zip_error_init 3 +before calling +.Fn zip_error_set_from_source . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_error_init 3 , +.Xr zip_error_set 3 +.Sh HISTORY +.Fn zip_error_set_from_source +was added in libzip 1.10. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_error_strerror.html b/thirdparty/libzip-1.11.3/man/zip_error_strerror.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_error_strerror.man b/thirdparty/libzip-1.11.3/man/zip_error_strerror.man new file mode 100644 index 0000000..14f7009 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_strerror.man @@ -0,0 +1,72 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_error_strerror.mdoc -- create human-readable version of zip_error +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ERROR_STRERROR" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_error_strerror\fR +\- create human-readable string for zip_error +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIconst char *\fR +.br +.PD 0 +.HP 4n +\fBzip_error_strerror\fR(\fIzip_error_t\ *ze\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_error_strerror\fR() +function returns an error message string corresponding to +\fIze\fR +like +strerror(3). +This string will stay valid until the next call to +\fBzip_error_strerror\fR() +or until +zip_error_fini(3) +is called. +.SH "SEE ALSO" +libzip(3), +strerror(3), +zip_error_fini(3) +.SH "HISTORY" +\fBzip_error_strerror\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_error_strerror.mdoc b/thirdparty/libzip-1.11.3/man/zip_error_strerror.mdoc new file mode 100644 index 0000000..40d5865 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_strerror.mdoc @@ -0,0 +1,67 @@ +.\" zip_error_strerror.mdoc -- create human-readable version of zip_error +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_ERROR_STRERROR 3 +.Os +.Sh NAME +.Nm zip_error_strerror +.Nd create human-readable string for zip_error +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft const char * +.Fn zip_error_strerror "zip_error_t *ze" +.Sh DESCRIPTION +The +.Fn zip_error_strerror +function returns an error message string corresponding to +.Ar ze +like +.Xr strerror 3 . +This string will stay valid until the next call to +.Fn zip_error_strerror +or until +.Xr zip_error_fini 3 +is called. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr strerror 3 , +.Xr zip_error_fini 3 +.Sh HISTORY +.Fn zip_error_strerror +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_error_system_type.html b/thirdparty/libzip-1.11.3/man/zip_error_system_type.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_error_system_type.man b/thirdparty/libzip-1.11.3/man/zip_error_system_type.man new file mode 100644 index 0000000..18a27fa --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_system_type.man @@ -0,0 +1,83 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_error_system_type.mdoc -- return system type for error +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ERROR_SYSTEM_TYPE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_error_system_type\fR +\- return type of system error +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_error_system_type\fR(\fIconst\ zip_error_t\ *ze\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_error_system_type\fR() +function returns the type of the system specific part for the zip_error +\fIze\fR. +Currently, the following system types are defined: +.TP 13n +\fRZIP_ET_NONE\fR +System specific part of +\fIze\fR +is unused. +.TP 13n +\fRZIP_ET_SYS\fR +System specific part of +\fIze\fR +is an +errno(2). +.TP 13n +\fRZIP_ET_ZLIB\fR +System specific part of +\fIze\fR +is a +zlib(3) +error. +.SH "SEE ALSO" +libzip(3), +zip_error_code_system(3) +.SH "HISTORY" +\fBzip_error_system_type\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_error_system_type.mdoc b/thirdparty/libzip-1.11.3/man/zip_error_system_type.mdoc new file mode 100644 index 0000000..5a74dc0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_system_type.mdoc @@ -0,0 +1,77 @@ +.\" zip_error_system_type.mdoc -- return system type for error +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_ERROR_SYSTEM_TYPE 3 +.Os +.Sh NAME +.Nm zip_error_system_type +.Nd return type of system error +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_error_system_type "const zip_error_t *ze" +.Sh DESCRIPTION +The +.Fn zip_error_system_type +function returns the type of the system specific part for the zip_error +.Ar ze . +Currently, the following system types are defined: +.Bl -tag -width ZIP_ET_NONE +.It Dv ZIP_ET_NONE +System specific part of +.Ar ze +is unused. +.It Dv ZIP_ET_SYS +System specific part of +.Ar ze +is an +.Xr errno 2 . +.It Dv ZIP_ET_ZLIB +System specific part of +.Ar ze +is a +.Xr zlib 3 +error. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_error_code_system 3 +.Sh HISTORY +.Fn zip_error_system_type +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_error_to_data.html b/thirdparty/libzip-1.11.3/man/zip_error_to_data.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_error_to_data.man b/thirdparty/libzip-1.11.3/man/zip_error_to_data.man new file mode 100644 index 0000000..54f34e8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_to_data.man @@ -0,0 +1,74 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_error_to_data.mdoc -- create error data for ZIP_SOURCE_ERROR +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ERROR_TO_DATA" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_error_to_data\fR +\- convert zip_error to return value suitable for ZIP_SOURCE_ERROR +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_error_to_data\fR(\fIconst\ zip_error_t\ *ze\fR, \fIvoid\ *data\fR, \fIzip_uint64_t\ len\fR); +.PD +.SH "DESCRIPTION" +\fBzip_error_to_data\fR() +function converts the zip_error +\fIze\fR +into data suitable as return value for +\fRZIP_SOURCE_ERROR\fR. +The data is written into the buffer +\fIdata\fR +of size +\fIlen\fR. +If the buffer is not large enough to hold 2 ints, an error is +returned. +.SH "RETURN VALUES" +\fBzip_error_to_data\fR() +returns 2*(sizeof int) on success, and \-1 on error. +.SH "SEE ALSO" +libzip(3), +zip_source_function(3) +.SH "HISTORY" +\fBzip_error_to_data\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_error_to_data.mdoc b/thirdparty/libzip-1.11.3/man/zip_error_to_data.mdoc new file mode 100644 index 0000000..6fdb2a3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_to_data.mdoc @@ -0,0 +1,69 @@ +.\" zip_error_to_data.mdoc -- create error data for ZIP_SOURCE_ERROR +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_ERROR_TO_DATA 3 +.Os +.Sh NAME +.Nm zip_error_to_data +.Nd convert zip_error to return value suitable for ZIP_SOURCE_ERROR +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_error_to_data "const zip_error_t *ze" "void *data" "zip_uint64_t len" +.Sh DESCRIPTION +.Fn zip_error_to_data +function converts the zip_error +.Ar ze +into data suitable as return value for +.Dv ZIP_SOURCE_ERROR . +The data is written into the buffer +.Ar data +of size +.Ar len . +If the buffer is not large enough to hold 2 ints, an error is +returned. +.Sh RETURN VALUES +.Fn zip_error_to_data +returns 2*(sizeof int) on success, and \-1 on error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source_function 3 +.Sh HISTORY +.Fn zip_error_to_data +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_error_to_str.html b/thirdparty/libzip-1.11.3/man/zip_error_to_str.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_error_to_str.man b/thirdparty/libzip-1.11.3/man/zip_error_to_str.man new file mode 100644 index 0000000..bef6982 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_to_str.man @@ -0,0 +1,99 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_error_to_str.mdoc -- get string representation of zip error code +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_ERROR_TO_STR" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_error_to_str\fR +\- get string representation of zip error (obsolete interface) +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_error_to_str\fR(\fIchar\ *buf\fR, \fIzip_uint64_t\ len\fR, \fIint\ ze\fR, \fIint\ se\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_error_to_str\fR() +is deprecated; use +zip_error_init_with_code(3) +and +zip_error_strerror(3) +instead. +.PP +Replace +.nf +.sp +.RS 6n +char buf[BUFSIZE]; +zip_error_to_str(buf, sizeof(buf), ze, se); +printf("%s", buf); +.RE +.fi +with +.nf +.sp +.RS 6n +zip_error_t error; +zip_error_init_with_code(&error, ze); +printf("%s", zip_error_strerror(&error)); +zip_error_fini(&error); +.RE +.fi +.SH "SEE ALSO" +libzip(3), +zip_error_init_with_code(3), +zip_error_strerror(3) +.SH "HISTORY" +\fBzip_error_to_str\fR() +was added in libzip 0.6. +In libzip 0.10 the type of +\fIlen\fR +was changed from +\fIsize_t\fR +to +\fIzip_uint64_t\fR. +It was deprecated in libzip 1.0, use +\fBzip_error_init_with_code\fR() +and +\fBzip_error_strerror\fR() +instead. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_error_to_str.mdoc b/thirdparty/libzip-1.11.3/man/zip_error_to_str.mdoc new file mode 100644 index 0000000..62b5a32 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_error_to_str.mdoc @@ -0,0 +1,88 @@ +.\" zip_error_to_str.mdoc -- get string representation of zip error code +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_ERROR_TO_STR 3 +.Os +.Sh NAME +.Nm zip_error_to_str +.Nd get string representation of zip error (obsolete interface) +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_error_to_str "char *buf" "zip_uint64_t len" "int ze" "int se" +.Sh DESCRIPTION +The function +.Fn zip_error_to_str +is deprecated; use +.Xr zip_error_init_with_code 3 +and +.Xr zip_error_strerror 3 +instead. +.Pp +Replace +.Bd -literal -offset indent +char buf[BUFSIZE]; +zip_error_to_str(buf, sizeof(buf), ze, se); +printf("%s", buf); +.Ed +with +.Bd -literal -offset indent +zip_error_t error; +zip_error_init_with_code(&error, ze); +printf("%s", zip_error_strerror(&error)); +zip_error_fini(&error); +.Ed +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_error_init_with_code 3 , +.Xr zip_error_strerror 3 +.Sh HISTORY +.Fn zip_error_to_str +was added in libzip 0.6. +In libzip 0.10 the type of +.Ar len +was changed from +.Vt size_t +to +.Vt zip_uint64_t . +It was deprecated in libzip 1.0, use +.Fn zip_error_init_with_code +and +.Fn zip_error_strerror +instead. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_errors.html b/thirdparty/libzip-1.11.3/man/zip_errors.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_errors.man b/thirdparty/libzip-1.11.3/man/zip_errors.man new file mode 100644 index 0000000..dd008e6 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_errors.man @@ -0,0 +1,160 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_errors.mdoc -- list of all libzip error codes +.\" Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" This file was generated automatically by ./make_zip_errors.sh +.\" from ../lib/zip.h; make changes there. +.\" +.TH "ZIP_ERRORS" "3" "March 15, 2024" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_errors\fR +\- list of all libzip error codes +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.SH "DESCRIPTION" +The following error codes are used by libzip: +.TP 23n +[\fRZIP_ER_CANCELLED\fR] +Operation cancelled. +.TP 23n +[\fRZIP_ER_CHANGED\fR] +Entry has been changed. +.TP 23n +[\fRZIP_ER_CLOSE\fR] +Closing zip archive failed. +.TP 23n +[\fRZIP_ER_COMPNOTSUPP\fR] +Compression method not supported. +.TP 23n +[\fRZIP_ER_COMPRESSED_DATA\fR] +Compressed data invalid. +.TP 23n +[\fRZIP_ER_CRC\fR] +CRC error. +.TP 23n +[\fRZIP_ER_DATA_LENGTH\fR] +Unexpected length of data. +.TP 23n +[\fRZIP_ER_DELETED\fR] +Entry has been deleted. +.TP 23n +[\fRZIP_ER_ENCRNOTSUPP\fR] +Encryption method not supported. +.TP 23n +[\fRZIP_ER_EOF\fR] +Premature end of file. +.TP 23n +[\fRZIP_ER_EXISTS\fR] +File already exists. +.TP 23n +[\fRZIP_ER_INCONS\fR] +Zip archive inconsistent. +.TP 23n +[\fRZIP_ER_INTERNAL\fR] +Internal error. +.TP 23n +[\fRZIP_ER_INUSE\fR] +Resource still in use. +.TP 23n +[\fRZIP_ER_INVAL\fR] +Invalid argument. +.TP 23n +[\fRZIP_ER_MEMORY\fR] +Malloc failure. +.TP 23n +[\fRZIP_ER_MULTIDISK\fR] +Multi-disk zip archives not supported. +.TP 23n +[\fRZIP_ER_NOENT\fR] +No such file. +.TP 23n +[\fRZIP_ER_NOPASSWD\fR] +No password provided. +.TP 23n +[\fRZIP_ER_NOT_ALLOWED\fR] +Not allowed in torrentzip. +.TP 23n +[\fRZIP_ER_NOZIP\fR] +Not a zip archive. +.TP 23n +[\fRZIP_ER_OK\fR] +No error. +.TP 23n +[\fRZIP_ER_OPEN\fR] +Can't open file. +.TP 23n +[\fRZIP_ER_OPNOTSUPP\fR] +Operation not supported. +.TP 23n +[\fRZIP_ER_RDONLY\fR] +Read-only archive. +.TP 23n +[\fRZIP_ER_READ\fR] +Read error. +.TP 23n +[\fRZIP_ER_REMOVE\fR] +Can't remove file. +.TP 23n +[\fRZIP_ER_RENAME\fR] +Renaming temporary file failed. +.TP 23n +[\fRZIP_ER_SEEK\fR] +Seek error. +.TP 23n +[\fRZIP_ER_TELL\fR] +Tell error. +.TP 23n +[\fRZIP_ER_TMPOPEN\fR] +Failure to create temporary file. +.TP 23n +[\fRZIP_ER_TRUNCATED_ZIP\fR] +.br +Possibly truncated or corrupted zip archive. +.TP 23n +[\fRZIP_ER_WRITE\fR] +Write error. +.TP 23n +[\fRZIP_ER_WRONGPASSWD\fR] +Wrong password provided. +.TP 23n +[\fRZIP_ER_ZIPCLOSED\fR] +Containing zip archive was closed. +.TP 23n +[\fRZIP_ER_ZLIB\fR] +Zlib error. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_errors.mdoc b/thirdparty/libzip-1.11.3/man/zip_errors.mdoc new file mode 100644 index 0000000..117e2e9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_errors.mdoc @@ -0,0 +1,125 @@ +.\" zip_errors.mdoc -- list of all libzip error codes +.\" Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" This file was generated automatically by ./make_zip_errors.sh +.\" from ../lib/zip.h; make changes there. +.\" +.Dd March 15, 2024 +.Dt ZIP_ERRORS 3 +.Os +.Sh NAME +.Nm zip_errors +.Nd list of all libzip error codes +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Sh DESCRIPTION +The following error codes are used by libzip: +.Bl -tag -width XZIPXERXCOMPNOTSUPPXX +.It Bq Er ZIP_ER_CANCELLED +Operation cancelled. +.It Bq Er ZIP_ER_CHANGED +Entry has been changed. +.It Bq Er ZIP_ER_CLOSE +Closing zip archive failed. +.It Bq Er ZIP_ER_COMPNOTSUPP +Compression method not supported. +.It Bq Er ZIP_ER_COMPRESSED_DATA +Compressed data invalid. +.It Bq Er ZIP_ER_CRC +CRC error. +.It Bq Er ZIP_ER_DATA_LENGTH +Unexpected length of data. +.It Bq Er ZIP_ER_DELETED +Entry has been deleted. +.It Bq Er ZIP_ER_ENCRNOTSUPP +Encryption method not supported. +.It Bq Er ZIP_ER_EOF +Premature end of file. +.It Bq Er ZIP_ER_EXISTS +File already exists. +.It Bq Er ZIP_ER_INCONS +Zip archive inconsistent. +.It Bq Er ZIP_ER_INTERNAL +Internal error. +.It Bq Er ZIP_ER_INUSE +Resource still in use. +.It Bq Er ZIP_ER_INVAL +Invalid argument. +.It Bq Er ZIP_ER_MEMORY +Malloc failure. +.It Bq Er ZIP_ER_MULTIDISK +Multi-disk zip archives not supported. +.It Bq Er ZIP_ER_NOENT +No such file. +.It Bq Er ZIP_ER_NOPASSWD +No password provided. +.It Bq Er ZIP_ER_NOT_ALLOWED +Not allowed in torrentzip. +.It Bq Er ZIP_ER_NOZIP +Not a zip archive. +.It Bq Er ZIP_ER_OK +No error. +.It Bq Er ZIP_ER_OPEN +Can't open file. +.It Bq Er ZIP_ER_OPNOTSUPP +Operation not supported. +.It Bq Er ZIP_ER_RDONLY +Read-only archive. +.It Bq Er ZIP_ER_READ +Read error. +.It Bq Er ZIP_ER_REMOVE +Can't remove file. +.It Bq Er ZIP_ER_RENAME +Renaming temporary file failed. +.It Bq Er ZIP_ER_SEEK +Seek error. +.It Bq Er ZIP_ER_TELL +Tell error. +.It Bq Er ZIP_ER_TMPOPEN +Failure to create temporary file. +.It Bq Er ZIP_ER_TRUNCATED_ZIP +Possibly truncated or corrupted zip archive. +.It Bq Er ZIP_ER_WRITE +Write error. +.It Bq Er ZIP_ER_WRONGPASSWD +Wrong password provided. +.It Bq Er ZIP_ER_ZIPCLOSED +Containing zip archive was closed. +.It Bq Er ZIP_ER_ZLIB +Zlib error. +.El +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_fclose.html b/thirdparty/libzip-1.11.3/man/zip_fclose.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_fclose.man b/thirdparty/libzip-1.11.3/man/zip_fclose.man new file mode 100644 index 0000000..c7499fd --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_fclose.man @@ -0,0 +1,70 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_fclose.mdoc -- close file in zip archive +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FCLOSE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_fclose\fR +\- close file in zip archive +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_fclose\fR(\fIzip_file_t\ *file\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_fclose\fR() +function closes +\fIfile\fR +and frees the memory allocated for it. +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, the error code is returned. +.SH "SEE ALSO" +libzip(3), +zip_fopen(3), +zip_fread(3), +zip_fseek(3) +.SH "HISTORY" +\fBzip_fclose\fR() +was added in libzip 0.6. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_fclose.mdoc b/thirdparty/libzip-1.11.3/man/zip_fclose.mdoc new file mode 100644 index 0000000..42e5e80 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_fclose.mdoc @@ -0,0 +1,65 @@ +.\" zip_fclose.mdoc -- close file in zip archive +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_FCLOSE 3 +.Os +.Sh NAME +.Nm zip_fclose +.Nd close file in zip archive +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_fclose "zip_file_t *file" +.Sh DESCRIPTION +The +.Fn zip_fclose +function closes +.Ar file +and frees the memory allocated for it. +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, the error code is returned. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_fopen 3 , +.Xr zip_fread 3 , +.Xr zip_fseek 3 +.Sh HISTORY +.Fn zip_fclose +was added in libzip 0.6. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_fdopen.html b/thirdparty/libzip-1.11.3/man/zip_fdopen.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_fdopen.man b/thirdparty/libzip-1.11.3/man/zip_fdopen.man new file mode 100644 index 0000000..e7516bb --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_fdopen.man @@ -0,0 +1,162 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_fdopen.mdoc -- open zip archive using existing file descriptor +.\" Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FDOPEN" "3" "September 23, 2022" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_fdopen\fR +\- open zip archive using open file descriptor +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_fdopen\fR(\fIint\ fd\fR, \fIint\ flags\fR, \fIint\ *errorp\fR); +.PD +.SH "DESCRIPTION" +The zip archive specified by the open file descriptor +\fIfd\fR +is opened and a pointer to a +\fIstruct zip\fR, +used to manipulate the archive, is returned. +In contrast to +zip_open(3), +using +\fBzip_fdopen\fR +the archive can only be opened in read-only mode. +The +\fIfd\fR +argument may not be used any longer after calling +\fBzip_fdopen\fR. +The +\fIflags\fR +are specified by +\fIor\fR'ing +the following values, or 0 for none of them. +.RS 6n +.TP 15n +\fRZIP_CHECKCONS\fR +Perform additional stricter consistency checks on the archive, and +error if they fail. +.RE +.PP +If an error occurs and +\fIerrorp\fR +is +non-\fRNULL\fR, +it will be set to the corresponding error code. +.SH "RETURN VALUES" +Upon successful completion +\fBzip_fdopen\fR() +returns a +\fIstruct zip\fR +pointer, and +\fIfd\fR +should not be used any longer, nor passed to +close(2). +Otherwise, +\fRNULL\fR +is returned and +\fI*errorp\fR +is set to indicate the error. +In the error case, +\fIfd\fR +remains unchanged. +.SH "ERRORS" +The file specified by +\fIfd\fR +is prepared for use by +libzip(3) +unless: +.TP 19n +[\fRZIP_ER_INCONS\fR] +Inconsistencies were found in the file specified by +\fIpath\fR. +This error is often caused by specifying +\fRZIP_CHECKCONS\fR +but can also happen without it. +.TP 19n +[\fRZIP_ER_INVAL\fR] +The +\fIflags\fR +argument is invalid. +Not all +zip_open(3) +flags are allowed for +\fBzip_fdopen\fR, +see +\fIDESCRIPTION\fR. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.TP 19n +[\fRZIP_ER_NOZIP\fR] +The file specified by +\fIfd\fR +is not a zip archive. +.TP 19n +[\fRZIP_ER_OPEN\fR] +The file specified by +\fIfd\fR +could not be prepared for use by +libzip(3). +.TP 19n +[\fRZIP_ER_OPNOTSUPP\fR] +.br +This functionality has been disabled at compile time. +.TP 19n +[\fRZIP_ER_READ\fR] +A read error occurred; see +\fIerrno\fR +for details. +.TP 19n +[\fRZIP_ER_SEEK\fR] +The file specified by +\fIfd\fR +does not allow seeks. +.SH "SEE ALSO" +libzip(3), +zip_close(3), +zip_error_strerror(3), +zip_open(3) +.SH "HISTORY" +\fBzip_fdopen\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_fdopen.mdoc b/thirdparty/libzip-1.11.3/man/zip_fdopen.mdoc new file mode 100644 index 0000000..ee249e5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_fdopen.mdoc @@ -0,0 +1,149 @@ +.\" zip_fdopen.mdoc -- open zip archive using existing file descriptor +.\" Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd September 23, 2022 +.Dt ZIP_FDOPEN 3 +.Os +.Sh NAME +.Nm zip_fdopen +.Nd open zip archive using open file descriptor +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_t * +.Fn zip_fdopen "int fd" "int flags" "int *errorp" +.Sh DESCRIPTION +The zip archive specified by the open file descriptor +.Ar fd +is opened and a pointer to a +.Ft struct zip , +used to manipulate the archive, is returned. +In contrast to +.Xr zip_open 3 , +using +.Nm zip_fdopen +the archive can only be opened in read-only mode. +The +.Ar fd +argument may not be used any longer after calling +.Nm zip_fdopen . +The +.Fa flags +are specified by +.Em or Ns No 'ing +the following values, or 0 for none of them. +.Bl -tag -offset indent -width ZIP_CHECKCONS +.It Dv ZIP_CHECKCONS +Perform additional stricter consistency checks on the archive, and +error if they fail. +.El +.Pp +If an error occurs and +.Ar errorp +is +.No non- Ns Dv NULL , +it will be set to the corresponding error code. +.Sh RETURN VALUES +Upon successful completion +.Fn zip_fdopen +returns a +.Ft struct zip +pointer, and +.Ar fd +should not be used any longer, nor passed to +.Xr close 2 . +Otherwise, +.Dv NULL +is returned and +.Ar *errorp +is set to indicate the error. +In the error case, +.Ar fd +remains unchanged. +.Sh ERRORS +The file specified by +.Ar fd +is prepared for use by +.Xr libzip 3 +unless: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INCONS +Inconsistencies were found in the file specified by +.Ar path . +This error is often caused by specifying +.Dv ZIP_CHECKCONS +but can also happen without it. +.It Bq Er ZIP_ER_INVAL +The +.Ar flags +argument is invalid. +Not all +.Xr zip_open 3 +flags are allowed for +.Nm zip_fdopen , +see +.Sx DESCRIPTION . +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.It Bq Er ZIP_ER_NOZIP +The file specified by +.Ar fd +is not a zip archive. +.It Bq Er ZIP_ER_OPEN +The file specified by +.Ar fd +could not be prepared for use by +.Xr libzip 3 . +.It Bq Er ZIP_ER_OPNOTSUPP +This functionality has been disabled at compile time. +.It Bq Er ZIP_ER_READ +A read error occurred; see +.Va errno +for details. +.It Bq Er ZIP_ER_SEEK +The file specified by +.Ar fd +does not allow seeks. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_close 3 , +.Xr zip_error_strerror 3 , +.Xr zip_open 3 +.Sh HISTORY +.Fn zip_fdopen +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_file_add.html b/thirdparty/libzip-1.11.3/man/zip_file_add.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_add.man b/thirdparty/libzip-1.11.3/man/zip_file_add.man new file mode 100644 index 0000000..0e04e8e --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_add.man @@ -0,0 +1,194 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_add.mdoc -- add files to zip archive +.\" Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_ADD" "3" "March 18, 2024" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_add\fR, +\fBzip_file_replace\fR +\- add file to zip archive or replace file in zip archive +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_file_add\fR(\fIzip_t\ *archive\fR, \fIconst\ char\ *name\fR, \fIzip_source_t\ *source\fR, \fIzip_flags_t\ flags\fR); +.PD +.PP +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_file_replace\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_source_t\ *source\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_file_add\fR() +adds a file to a zip archive, while +\fBzip_file_replace\fR() +replaces an existing file in a zip archive. +The argument +\fIarchive\fR +specifies the zip archive to which the file should be added. +\fIname\fR +is the file's name in the zip archive (for +\fBzip_file_add\fR()), +while +\fIindex\fR +specifies which file should be replaced (for +\fBzip_file_replace\fR()). +The +\fIflags\fR +argument can be any combination of +\fRZIP_FL_OVERWRITE\fR +with one of +\fRZIP_FL_ENC_*\fR: +.TP 22n +\fRZIP_FL_OVERWRITE\fR +Overwrite any existing file of the same name. +For +\fBzip_file_add\fR +only. +.TP 22n +\fRZIP_FL_ENC_GUESS\fR +Guess encoding of +\fIname\fR +(default). +(Only CP-437 and UTF-8 are recognized.) +.TP 22n +\fRZIP_FL_ENC_UTF_8\fR +Interpret +\fIname\fR +as UTF-8. +.TP 22n +\fRZIP_FL_ENC_CP437\fR +Interpret +\fIname\fR +as code page 437 (CP-437). +.PD 0 +.PP +The data is obtained from the +\fIsource\fR +argument, see +zip_source(3). +.PD +.PP +\fINOTE\fR: +zip_source_free(3) +should not be called on a +\fIsource\fR +after it was used successfully in a +\fBzip_file_add\fR +or +\fBzip_file_replace\fR +call. +.PP +Please also note that when using +\fBzip_replace\fR, +the target file's extra field information will be deleted since this +usually is dependent on the file contents. +If you want to keep them, query them beforehand with +zip_file_extra_field_get(3) +and restore them after +\fBzip_replace\fR +with +zip_file_extra_field_set(3). +.SH "RETURN VALUES" +Upon successful completion, +\fBzip_file_add\fR() +returns the index of the new file in the archive, and +\fBzip_file_replace\fR() +returns 0. +Otherwise, \-1 is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "EXAMPLES" +.nf +.RS 6n +zip_source_t *s; +const char buf[]="teststring"; + +if ((s=zip_source_buffer(archive, buf, sizeof(buf), 0)) == NULL || + zip_file_add(archive, name, s, ZIP_FL_ENC_UTF_8) < 0) { + zip_source_free(s); + printf("error adding file: %s\en", zip_strerror(archive)); +} +.RE +.fi +.SH "ERRORS" +\fBzip_file_add\fR() +and +\fBzip_file_replace\fR() +fail if: +.TP 19n +[\fRZIP_ER_EXISTS\fR] +There is already a file called +\fIname\fR +in the archive. +(Only applies to +\fBzip_file_add\fR(), +and only if +\fRZIP_FL_OVERWRITE\fR +is not provided). +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIsource\fR +or +\fIname\fR +are +\fRNULL\fR, +or +\fIindex\fR +is invalid. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.TP 19n +[\fRZIP_ER_RDONLY\fR] +Archive was opened in read-only mode. +.SH "SEE ALSO" +libzip(3), +zip_source(3) +.SH "HISTORY" +\fBzip_file_add\fR() +and +\fBzip_file_replace\fR() +were added in libzip 0.11. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_file_add.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_add.mdoc new file mode 100644 index 0000000..8a6ceb7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_add.mdoc @@ -0,0 +1,175 @@ +.\" zip_file_add.mdoc -- add files to zip archive +.\" Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd March 18, 2024 +.Dt ZIP_FILE_ADD 3 +.Os +.Sh NAME +.Nm zip_file_add , +.Nm zip_file_replace +.Nd add file to zip archive or replace file in zip archive +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_file_add "zip_t *archive" "const char *name" "zip_source_t *source" "zip_flags_t flags" +.Ft int +.Fn zip_file_replace "zip_t *archive" "zip_uint64_t index" "zip_source_t *source" "zip_flags_t flags" +.Sh DESCRIPTION +The function +.Fn zip_file_add +adds a file to a zip archive, while +.Fn zip_file_replace +replaces an existing file in a zip archive. +The argument +.Ar archive +specifies the zip archive to which the file should be added. +.Ar name +is the file's name in the zip archive (for +.Fn zip_file_add ) , +while +.Ar index +specifies which file should be replaced (for +.Fn zip_file_replace ) . +The +.Ar flags +argument can be any combination of +.Dv ZIP_FL_OVERWRITE +with one of +.Dv ZIP_FL_ENC_* : +.Bl -tag -width XZIPXFLXENCXSTRICTXX +.It Dv ZIP_FL_OVERWRITE +Overwrite any existing file of the same name. +For +.Nm zip_file_add +only. +.It Dv ZIP_FL_ENC_GUESS +Guess encoding of +.Ar name +(default). +(Only CP-437 and UTF-8 are recognized.) +.It Dv ZIP_FL_ENC_UTF_8 +Interpret +.Ar name +as UTF-8. +.It Dv ZIP_FL_ENC_CP437 +Interpret +.Ar name +as code page 437 (CP-437). +.El +The data is obtained from the +.Ar source +argument, see +.Xr zip_source 3 . +.Pp +.Em NOTE : +.Xr zip_source_free 3 +should not be called on a +.Ar source +after it was used successfully in a +.Nm zip_file_add +or +.Nm zip_file_replace +call. +.Pp +Please also note that when using +.Nm zip_replace , +the target file's extra field information will be deleted since this +usually is dependent on the file contents. +If you want to keep them, query them beforehand with +.Xr zip_file_extra_field_get 3 +and restore them after +.Nm zip_replace +with +.Xr zip_file_extra_field_set 3 . +.Sh RETURN VALUES +Upon successful completion, +.Fn zip_file_add +returns the index of the new file in the archive, and +.Fn zip_file_replace +returns 0. +Otherwise, \-1 is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh EXAMPLES +.Bd -literal -offset indent +zip_source_t *s; +const char buf[]="teststring"; + +if ((s=zip_source_buffer(archive, buf, sizeof(buf), 0)) == NULL || + zip_file_add(archive, name, s, ZIP_FL_ENC_UTF_8) < 0) { + zip_source_free(s); + printf("error adding file: %s\en", zip_strerror(archive)); +} +.Ed +.Sh ERRORS +.Fn zip_file_add +and +.Fn zip_file_replace +fail if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_EXISTS +There is already a file called +.Ar name +in the archive. +(Only applies to +.Fn zip_file_add , +and only if +.Dv ZIP_FL_OVERWRITE +is not provided). +.It Bq Er ZIP_ER_INVAL +.Ar source +or +.Ar name +are +.Dv NULL , +or +.Ar index +is invalid. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.It Bq Er ZIP_ER_RDONLY +Archive was opened in read-only mode. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 +.Sh HISTORY +.Fn zip_file_add +and +.Fn zip_file_replace +were added in libzip 0.11. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_file_attributes_init.html b/thirdparty/libzip-1.11.3/man/zip_file_attributes_init.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_attributes_init.man b/thirdparty/libzip-1.11.3/man/zip_file_attributes_init.man new file mode 100644 index 0000000..2d12a09 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_attributes_init.man @@ -0,0 +1,66 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_attributes_init.mdoc -- initialize attributes structure +.\" Copyright (C) 2020 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_ATTRIBUTES_INIT" "3" "April 17, 2020" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_attributes_init\fR +\- initialize zip file attributes structure +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_file_attributes_init\fR(\fIzip_file_attributes_t\ *attributes\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_file_attributes_init\fR() +initializes a +\fIzip_file_attributes_t\fR +structure with default values. +It must be called before modifying such a structure for the first time. +.SH "SEE ALSO" +libzip(3), +zip_source_function(3) +.SH "HISTORY" +\fBzip_file_attributes_init\fR() +was added in libzip 1.7.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_file_attributes_init.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_attributes_init.mdoc new file mode 100644 index 0000000..27ca205 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_attributes_init.mdoc @@ -0,0 +1,61 @@ +.\" zip_file_attributes_init.mdoc -- initialize attributes structure +.\" Copyright (C) 2020 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd April 17, 2020 +.Dt ZIP_FILE_ATTRIBUTES_INIT 3 +.Os +.Sh NAME +.Nm zip_file_attributes_init +.Nd initialize zip file attributes structure +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft void +.Fn zip_file_attributes_init "zip_file_attributes_t *attributes" +.Sh DESCRIPTION +The +.Fn zip_file_attributes_init +initializes a +.Vt zip_file_attributes_t +structure with default values. +It must be called before modifying such a structure for the first time. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source_function 3 +.Sh HISTORY +.Fn zip_file_attributes_init +was added in libzip 1.7.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_file_extra_field_delete.html b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_delete.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_extra_field_delete.man b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_delete.man new file mode 100644 index 0000000..df32b67 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_delete.man @@ -0,0 +1,141 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_extra_field_delete.mdoc -- delete extra field for file in zip +.\" Copyright (C) 2012-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_EXTRA_FIELD_DELETE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_extra_field_delete\fR, +\fBzip_file_extra_field_delete_by_id\fR +\- delete extra field for file in zip +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_file_extra_field_delete\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_uint16_t\ extra_field_index\fR, \fIzip_flags_t\ flags\fR); +.PD +.PP +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_file_extra_field_delete_by_id\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_uint16_t\ extra_field_id\fR, \fIzip_uint16_t\ extra_field_index\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_file_extra_field_delete\fR() +function deletes the extra field with index +\fIextra_field_index\fR +for the file at position +\fIindex\fR +in the zip archive. +.PP +If +\fIextra_field_index\fR +is +\fRZIP_EXTRA_FIELD_ALL\fR, +then all extra fields will be deleted. +.PP +The following +\fIflags\fR +are supported: +.RS 6n +.TP 18n +\fRZIP_FL_CENTRAL\fR +Delete extra fields from the archive's central directory. +.TP 18n +\fRZIP_FL_LOCAL\fR +Delete extra fields from the local file headers. +.RE +.PP +The +\fBzip_file_extra_field_delete_by_id\fR() +function deletes the extra field with ID (two-byte signature) +\fIextra_field_id\fR +and index +\fIextra_field_index\fR +(in other words, the +\fIextra_field_index\fR'th +extra field with ID +\fIextra_field_id\fR) +The other arguments are the same as for +\fBzip_file_extra_field_delete\fR() +(\fRZIP_EXTRA_FIELD_ALL\fR +will delete all extra fields of the specified ID). +.PP +Please note that due to the library design, the index of an extra +field may be different between central directory and local file +headers. +For this reason, it is not allowed to specify both +\fRZIP_FL_CENTRAL\fR +and +\fRZIP_FL_LOCAL\fR +in +\fIflags\fR, +except when deleting all extra fields (i.e., +\fIextra_field_index\fR +being +\fRZIP_EXTRA_FIELD_ALL\fR). +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_file_extra_field_delete\fR() +and +\fBzip_file_extra_field_delete_by_id\fR() +fail if: +.TP 19n +[\fRZIP_ER_NOENT\fR] +\fIindex\fR +is not a valid file index in +\fIarchive\fR. +.SH "SEE ALSO" +libzip(3), +zip_file_extra_field_get(3), +zip_file_extra_field_set(3), +zip_file_extra_fields_count(3) +.SH "HISTORY" +\fBzip_file_extra_field_delete\fR() +and +\fBzip_file_extra_field_delete_by_id\fR() +were added in libzip 0.11. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_file_extra_field_delete.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_delete.mdoc new file mode 100644 index 0000000..a194161 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_delete.mdoc @@ -0,0 +1,130 @@ +.\" zip_file_extra_field_delete.mdoc -- delete extra field for file in zip +.\" Copyright (C) 2012-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_FILE_EXTRA_FIELD_DELETE 3 +.Os +.Sh NAME +.Nm zip_file_extra_field_delete , +.Nm zip_file_extra_field_delete_by_id +.Nd delete extra field for file in zip +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_file_extra_field_delete "zip_t *archive" "zip_uint64_t index" "zip_uint16_t extra_field_index" "zip_flags_t flags" +.Ft int +.Fn zip_file_extra_field_delete_by_id "zip_t *archive" "zip_uint64_t index" "zip_uint16_t extra_field_id" "zip_uint16_t extra_field_index" "zip_flags_t flags" +.Sh DESCRIPTION +The +.Fn zip_file_extra_field_delete +function deletes the extra field with index +.Ar extra_field_index +for the file at position +.Ar index +in the zip archive. +.Pp +If +.Ar extra_field_index +is +.Dv ZIP_EXTRA_FIELD_ALL , +then all extra fields will be deleted. +.Pp +The following +.Ar flags +are supported: +.Bl -tag -width ZIP_FL_CENTRALXX -offset indent +.It Dv ZIP_FL_CENTRAL +Delete extra fields from the archive's central directory. +.It Dv ZIP_FL_LOCAL +Delete extra fields from the local file headers. +.El +.Pp +The +.Fn zip_file_extra_field_delete_by_id +function deletes the extra field with ID (two-byte signature) +.Ar extra_field_id +and index +.Ar extra_field_index +(in other words, the +.Ar extra_field_index Ns No 'th +extra field with ID +.Ar extra_field_id ) +The other arguments are the same as for +.Fn zip_file_extra_field_delete +.Dv ( ZIP_EXTRA_FIELD_ALL +will delete all extra fields of the specified ID). +.Pp +Please note that due to the library design, the index of an extra +field may be different between central directory and local file +headers. +For this reason, it is not allowed to specify both +.Dv ZIP_FL_CENTRAL +and +.Dv ZIP_FL_LOCAL +in +.Ar flags , +except when deleting all extra fields (i.e., +.Ar extra_field_index +being +.Dv ZIP_EXTRA_FIELD_ALL ) . +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_file_extra_field_delete +and +.Fn zip_file_extra_field_delete_by_id +fail if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_NOENT +.Ar index +is not a valid file index in +.Ar archive . +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_extra_field_get 3 , +.Xr zip_file_extra_field_set 3 , +.Xr zip_file_extra_fields_count 3 +.Sh HISTORY +.Fn zip_file_extra_field_delete +and +.Fn zip_file_extra_field_delete_by_id +were added in libzip 0.11. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_file_extra_field_get.html b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_get.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_extra_field_get.man b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_get.man new file mode 100644 index 0000000..f4cdc1b --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_get.man @@ -0,0 +1,169 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_extra_field_get.mdoc -- get extra field for file in zip +.\" Copyright (C) 2012-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_EXTRA_FIELD_GET" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_extra_field_get\fR, +\fBzip_file_extra_field_get_by_id\fR +\- get extra field for file in zip +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIconst zip_uint8_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_file_extra_field_get\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_uint16_t\ extra_field_index\fR, \fIzip_uint16_t\ *idp\fR, \fIzip_uint16_t\ *lenp\fR, \fIzip_flags_t\ flags\fR); +.PD +.PP +\fIconst zip_uint8_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_file_extra_field_get_by_id\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_uint16_t\ extra_field_id\fR, \fIzip_uint16_t\ extra_field_index\fR, \fIzip_uint16_t\ *lenp\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_file_extra_field_get\fR() +function returns the extra field with index +\fIextra_field_index\fR +for the file at position +\fIindex\fR +in the zip archive. +This pointer should not be modified or +free(3)'d, +and becomes invalid when +\fIarchive\fR +is closed. +If +\fIidp\fR +is not +\fRNULL\fR, +the integer to which it points will be set to the ID (two-byte +signature) of the selected extra field. +If +\fIlenp\fR +is not +\fRNULL\fR, +the integer to which it points will be set to the length of the +extra field. +Generally speaking, +\fIlenp\fR +and +\fIidp\fR +should be passed since only the extra field data is returned (i.e., +neither the ID nor the length, if the +\fIidp\fR +and +\fIlenp\fR +arguments are not provided). +.PP +The following +\fIflags\fR +are supported: +.RS 6n +.TP 20n +\fRZIP_FL_CENTRAL\fR +Return extra fields from the archive's central directory. +.TP 20n +\fRZIP_FL_LOCAL\fR +Return extra fields from the local file headers. +.TP 20n +\fRZIP_FL_UNCHANGED\fR +Return the original unchanged extra fields, ignoring any changes made. +.RE +.PP +The +\fBzip_file_extra_field_get_by_id\fR() +function returns the extra field with ID (two-byte signature) +\fIextra_field_id\fR +and index +\fIextra_field_index\fR +(in other words, the +\fIextra_field_index\fR'th +extra field with ID +\fIextra_field_id\fR) +The other arguments are the same as for +\fBzip_file_extra_field_get\fR(). +.SH "RETURN VALUES" +Upon successful completion, a pointer to an extra field is returned, +or +\fRNULL\fR +if there is no extra field with that +\fIextra_field_index\fR +for the file with index +\fIindex\fR. +In case of an error, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_file_extra_field_get\fR() +and +\fBzip_file_extra_field_get_by_id\fR() +fail if: +.TP 19n +[\fRZIP_ER_NOENT\fR] +\fIindex\fR +is not a valid file index in +\fIarchive\fR, +or +\fIextra_field_index\fR +is not a valid extra file index (for ID +\fIextra_field_id\fR). +.SH "SEE ALSO" +libzip(3), +zip_file_extra_field_delete(3), +zip_file_extra_field_set(3), +zip_file_extra_fields_count(3) +.SH "HISTORY" +\fBzip_file_extra_field_get\fR() +and +\fBzip_file_extra_field_get_by_id\fR() +were added in libzip 0.11. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> +.SH "CAVEATS" +Please note that the extra field IDs 0x0001 (ZIP64 extension), +0x6375 (Infozip UTF-8 comment), and +0x7075 (Infozip UTF-8 file name) can not be read using +\fBzip_file_extra_field_get\fR() +since they are used by +libzip(3) +internally. diff --git a/thirdparty/libzip-1.11.3/man/zip_file_extra_field_get.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_get.mdoc new file mode 100644 index 0000000..b1fa8a8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_get.mdoc @@ -0,0 +1,157 @@ +.\" zip_file_extra_field_get.mdoc -- get extra field for file in zip +.\" Copyright (C) 2012-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_FILE_EXTRA_FIELD_GET 3 +.Os +.Sh NAME +.Nm zip_file_extra_field_get , +.Nm zip_file_extra_field_get_by_id +.Nd get extra field for file in zip +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft const zip_uint8_t * +.Fn zip_file_extra_field_get "zip_t *archive" "zip_uint64_t index" "zip_uint16_t extra_field_index" "zip_uint16_t *idp" "zip_uint16_t *lenp" "zip_flags_t flags" +.Ft const zip_uint8_t * +.Fn zip_file_extra_field_get_by_id "zip_t *archive" "zip_uint64_t index" "zip_uint16_t extra_field_id" "zip_uint16_t extra_field_index" "zip_uint16_t *lenp" "zip_flags_t flags" +.Sh DESCRIPTION +The +.Fn zip_file_extra_field_get +function returns the extra field with index +.Ar extra_field_index +for the file at position +.Ar index +in the zip archive. +This pointer should not be modified or +.Xr free 3 Ap d , +and becomes invalid when +.Ar archive +is closed. +If +.Ar idp +is not +.Dv NULL , +the integer to which it points will be set to the ID (two-byte +signature) of the selected extra field. +If +.Ar lenp +is not +.Dv NULL , +the integer to which it points will be set to the length of the +extra field. +Generally speaking, +.Ar lenp +and +.Ar idp +should be passed since only the extra field data is returned (i.e., +neither the ID nor the length, if the +.Ar idp +and +.Ar lenp +arguments are not provided). +.Pp +The following +.Ar flags +are supported: +.Bl -tag -width ZIP_FL_UNCHANGEDXX -offset indent +.It Dv ZIP_FL_CENTRAL +Return extra fields from the archive's central directory. +.It Dv ZIP_FL_LOCAL +Return extra fields from the local file headers. +.It Dv ZIP_FL_UNCHANGED +Return the original unchanged extra fields, ignoring any changes made. +.El +.Pp +The +.Fn zip_file_extra_field_get_by_id +function returns the extra field with ID (two-byte signature) +.Ar extra_field_id +and index +.Ar extra_field_index +(in other words, the +.Ar extra_field_index Ns No 'th +extra field with ID +.Ar extra_field_id ) +The other arguments are the same as for +.Fn zip_file_extra_field_get . +.Sh RETURN VALUES +Upon successful completion, a pointer to an extra field is returned, +or +.Dv NULL +if there is no extra field with that +.Ar extra_field_index +for the file with index +.Ar index . +In case of an error, +.Dv NULL +is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_file_extra_field_get +and +.Fn zip_file_extra_field_get_by_id +fail if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_NOENT +.Ar index +is not a valid file index in +.Ar archive , +or +.Ar extra_field_index +is not a valid extra file index (for ID +.Ar extra_field_id ) . +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_extra_field_delete 3 , +.Xr zip_file_extra_field_set 3 , +.Xr zip_file_extra_fields_count 3 +.Sh HISTORY +.Fn zip_file_extra_field_get +and +.Fn zip_file_extra_field_get_by_id +were added in libzip 0.11. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at +.Sh CAVEATS +Please note that the extra field IDs 0x0001 (ZIP64 extension), +0x6375 (Infozip UTF-8 comment), and +0x7075 (Infozip UTF-8 file name) can not be read using +.Fn zip_file_extra_field_get +since they are used by +.Xr libzip 3 +internally. diff --git a/thirdparty/libzip-1.11.3/man/zip_file_extra_field_set.html b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_set.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_extra_field_set.man b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_set.man new file mode 100644 index 0000000..1edfd06 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_set.man @@ -0,0 +1,123 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_extra_field_set.mdoc -- set extra field for file in zip +.\" Copyright (C) 2012-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_EXTRA_FIELD_SET" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_extra_field_set\fR +\- set extra field for file in zip +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_file_extra_field_set\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_uint16_t\ extra_field_id\fR, \fIzip_uint16_t\ extra_field_index\fR, \fIconst\ zip_uint8_t\ *extra_field_data\fR, \fIzip_uint16_t\ len\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_file_extra_field_set\fR() +function sets the extra field with ID (two-byte signature) +\fIextra_field_id\fR +and index +\fIextra_field_index\fR +for the file at position +\fIindex\fR +in the zip archive. +The extra field's data will be set to +\fIextra_field_data\fR +and length +\fIlen\fR. +If a new entry shall be appended, set +\fIextra_field_index\fR +to +\fRZIP_EXTRA_FIELD_NEW\fR. +.PP +At least one of the following +\fIflags\fR +must be set: +.RS 6n +.TP 18n +\fRZIP_FL_CENTRAL\fR +Set extra field in the archive's central directory. +.TP 18n +\fRZIP_FL_LOCAL\fR +Set extra field in the local file headers. +.RE +.PP +Please note that the extra field IDs 0x0001 (ZIP64 extension), +0x6375 (Infozip UTF-8 comment), and +0x7075 (Infozip UTF-8 file name) can not be set using +\fBzip_file_extra_field_set\fR() +since they are set by +libzip(3) +automatically when needed. +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_file_extra_field_set\fR() +fails if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +The extra field size is too large (ID and length need 4 bytes; the +maximum length of all extra fields for one file combined is 65536 +bytes). +This error also occurs if +\fIextra_field_index\fR +is too large. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.TP 19n +[\fRZIP_ER_NOENT\fR] +\fIindex\fR +is not a valid file index in +\fIarchive\fR. +.SH "SEE ALSO" +libzip(3), +zip_file_extra_field_delete(3), +zip_file_extra_field_get(3), +zip_file_extra_fields_count(3) +.SH "HISTORY" +\fBzip_file_extra_field_set\fR() +was added in libzip 0.11. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_file_extra_field_set.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_set.mdoc new file mode 100644 index 0000000..8646c64 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_extra_field_set.mdoc @@ -0,0 +1,115 @@ +.\" zip_file_extra_field_set.mdoc -- set extra field for file in zip +.\" Copyright (C) 2012-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_FILE_EXTRA_FIELD_SET 3 +.Os +.Sh NAME +.Nm zip_file_extra_field_set +.Nd set extra field for file in zip +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_file_extra_field_set "zip_t *archive" "zip_uint64_t index" "zip_uint16_t extra_field_id" "zip_uint16_t extra_field_index" "const zip_uint8_t *extra_field_data" "zip_uint16_t len" "zip_flags_t flags" +.Sh DESCRIPTION +The +.Fn zip_file_extra_field_set +function sets the extra field with ID (two-byte signature) +.Ar extra_field_id +and index +.Ar extra_field_index +for the file at position +.Ar index +in the zip archive. +The extra field's data will be set to +.Ar extra_field_data +and length +.Ar len . +If a new entry shall be appended, set +.Ar extra_field_index +to +.Dv ZIP_EXTRA_FIELD_NEW . +.Pp +At least one of the following +.Ar flags +must be set: +.Bl -tag -width ZIP_FL_CENTRALXX -offset indent +.It Dv ZIP_FL_CENTRAL +Set extra field in the archive's central directory. +.It Dv ZIP_FL_LOCAL +Set extra field in the local file headers. +.El +.Pp +Please note that the extra field IDs 0x0001 (ZIP64 extension), +0x6375 (Infozip UTF-8 comment), and +0x7075 (Infozip UTF-8 file name) can not be set using +.Fn zip_file_extra_field_set +since they are set by +.Xr libzip 3 +automatically when needed. +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_file_extra_field_set +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +The extra field size is too large (ID and length need 4 bytes; the +maximum length of all extra fields for one file combined is 65536 +bytes). +This error also occurs if +.Ar extra_field_index +is too large. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.It Bq Er ZIP_ER_NOENT +.Ar index +is not a valid file index in +.Ar archive . +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_extra_field_delete 3 , +.Xr zip_file_extra_field_get 3 , +.Xr zip_file_extra_fields_count 3 +.Sh HISTORY +.Fn zip_file_extra_field_set +was added in libzip 0.11. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_file_extra_fields_count.html b/thirdparty/libzip-1.11.3/man/zip_file_extra_fields_count.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_extra_fields_count.man b/thirdparty/libzip-1.11.3/man/zip_file_extra_fields_count.man new file mode 100644 index 0000000..6086a07 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_extra_fields_count.man @@ -0,0 +1,124 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_extra_fields_count.mdoc -- count extra field for file in zip +.\" Copyright (C) 2012-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_EXTRA_FIELDS_COUNT" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_extra_fields_count\fR, +\fBzip_file_extra_fields_count_by_id\fR +\- count extra fields for file in zip +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int16_t\fR +.br +.PD 0 +.HP 4n +\fBzip_file_extra_fields_count\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_flags_t\ flags\fR); +.PD +.PP +\fIzip_int16_t\fR +.br +.PD 0 +.HP 4n +\fBzip_file_extra_fields_count_by_id\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_uint16_t\ extra_field_id\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_file_extra_fields_count\fR() +function counts the extra fields for the file at position +\fIindex\fR +in the zip archive. +.PP +The following +\fIflags\fR +are supported: +.RS 6n +.TP 18n +\fRZIP_FL_CENTRAL\fR +Count extra fields from the archive's central directory. +.TP 18n +\fRZIP_FL_LOCAL\fR +Count extra fields from the local file headers. +.TP 18n +\fRZIP_FL_UNCHANGED\fR +Count the original unchanged extra fields, ignoring any changes made. +.RE +.PP +The +\fBzip_file_extra_fields_count_by_id\fR() +function counts the extra fields with ID (two-byte signature) +\fIextra_field_id\fR. +The other arguments are the same as for +\fBzip_file_extra_fields_count\fR(). +.PP +Extra fields that are the same in the central directory and the local file +header are merged into one. +Therefore, the counts with +\fRZIP_FL_CENTRAL\fR +and +\fRZIP_FL_LOCAL\fR +do not need to add up to the same value as when given +\fRZIP_FL_CENTRAL|ZIP_FL_LOCAL\fR +at the same time. +.SH "RETURN VALUES" +Upon successful completion, the requested number of extra fields is returned. +Otherwise, \-1 is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_file_extra_fields_count\fR() +and +\fBzip_file_extra_fields_count_by_id\fR() +fail if: +.TP 19n +[\fRZIP_ER_NOENT\fR] +\fIindex\fR +is not a valid file index in +\fIarchive\fR. +.SH "SEE ALSO" +libzip(3), +zip_file_extra_field_delete(3), +zip_file_extra_field_get(3), +zip_file_extra_field_set(3) +.SH "HISTORY" +\fBzip_file_extra_fields_count\fR() +and +\fBzip_file_extra_fields_count_by_id\fR() +were added in libzip 0.11. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_file_extra_fields_count.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_extra_fields_count.mdoc new file mode 100644 index 0000000..1b40f5e --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_extra_fields_count.mdoc @@ -0,0 +1,113 @@ +.\" zip_file_extra_fields_count.mdoc -- count extra field for file in zip +.\" Copyright (C) 2012-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_FILE_EXTRA_FIELDS_COUNT 3 +.Os +.Sh NAME +.Nm zip_file_extra_fields_count , +.Nm zip_file_extra_fields_count_by_id +.Nd count extra fields for file in zip +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int16_t +.Fn zip_file_extra_fields_count "zip_t *archive" "zip_uint64_t index" "zip_flags_t flags" +.Ft zip_int16_t +.Fn zip_file_extra_fields_count_by_id "zip_t *archive" "zip_uint64_t index" "zip_uint16_t extra_field_id" "zip_flags_t flags" +.Sh DESCRIPTION +The +.Fn zip_file_extra_fields_count +function counts the extra fields for the file at position +.Ar index +in the zip archive. +.Pp +The following +.Ar flags +are supported: +.Bl -tag -width ZIP_FL_CENTRALXX -offset indent +.It Dv ZIP_FL_CENTRAL +Count extra fields from the archive's central directory. +.It Dv ZIP_FL_LOCAL +Count extra fields from the local file headers. +.It Dv ZIP_FL_UNCHANGED +Count the original unchanged extra fields, ignoring any changes made. +.El +.Pp +The +.Fn zip_file_extra_fields_count_by_id +function counts the extra fields with ID (two-byte signature) +.Ar extra_field_id . +The other arguments are the same as for +.Fn zip_file_extra_fields_count . +.Pp +Extra fields that are the same in the central directory and the local file +header are merged into one. +Therefore, the counts with +.Dv ZIP_FL_CENTRAL +and +.Dv ZIP_FL_LOCAL +do not need to add up to the same value as when given +.Dv ZIP_FL_CENTRAL|ZIP_FL_LOCAL +at the same time. +.Sh RETURN VALUES +Upon successful completion, the requested number of extra fields is returned. +Otherwise, \-1 is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_file_extra_fields_count +and +.Fn zip_file_extra_fields_count_by_id +fail if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_NOENT +.Ar index +is not a valid file index in +.Ar archive . +.\" TODO: _zip_read_local_ef errors +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_extra_field_delete 3 , +.Xr zip_file_extra_field_get 3 , +.Xr zip_file_extra_field_set 3 +.Sh HISTORY +.Fn zip_file_extra_fields_count +and +.Fn zip_file_extra_fields_count_by_id +were added in libzip 0.11. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_file_get_comment.html b/thirdparty/libzip-1.11.3/man/zip_file_get_comment.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_get_comment.man b/thirdparty/libzip-1.11.3/man/zip_file_get_comment.man new file mode 100644 index 0000000..b194e51 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_get_comment.man @@ -0,0 +1,126 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_get_comment.mdoc -- get comment for file in zip +.\" Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_GET_COMMENT" "3" "September 22, 2020" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_get_comment\fR +\- get comment for file in zip +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIconst char *\fR +.br +.PD 0 +.HP 4n +\fBzip_file_get_comment\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_uint32_t\ *lenp\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_file_get_comment\fR() +function returns the comment for the file at position +\fIindex\fR +in the zip archive. +The name is in UTF-8 encoding unless +\fRZIP_FL_ENC_RAW\fR +was specified (see below). +This pointer should not be modified or +free(3)'d, +and becomes invalid when +\fIarchive\fR +is closed. +If +\fIlenp\fR +is not +\fRNULL\fR, +the integer to which it points will be set to the length of the +comment. +If +\fIflags\fR +is set to +\fRZIP_FL_UNCHANGED\fR, +the original unchanged comment is returned. +.PP +Additionally, the following +\fIflags\fR +are supported: +.RS 6n +.TP 21n +\fRZIP_FL_ENC_RAW\fR +Return the unmodified comment as it is in the ZIP archive. +.TP 21n +\fRZIP_FL_ENC_GUESS\fR +(Default.) +Guess the encoding of the comment in the ZIP archive and convert it +to UTF-8, if necessary. +(Only CP-437 and UTF-8 are recognized.) +.TP 21n +\fRZIP_FL_ENC_STRICT\fR +Follow the ZIP specification for file names and extend it to file +comments, expecting them to be encoded in CP-437 in the ZIP archive +(except if it is a UTF-8 comment from the special extra field). +Convert it to UTF-8. +.RE +\fINote\fR: +ASCII is a subset of both CP-437 and UTF-8. +.SH "RETURN VALUES" +Upon successful completion, a pointer to the comment is returned, +or +\fRNULL\fR +if there is no comment. +In case of an error, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_file_get_comment\fR() +fails if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIindex\fR +is not a valid file index in +\fIarchive\fR. +.SH "SEE ALSO" +libzip(3), +zip_file_set_comment(3), +zip_get_archive_comment(3) +.SH "HISTORY" +\fBzip_file_get_comment\fR() +was added in libzip 0.11. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_file_get_comment.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_get_comment.mdoc new file mode 100644 index 0000000..dc1461c --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_get_comment.mdoc @@ -0,0 +1,119 @@ +.\" zip_file_get_comment.mdoc -- get comment for file in zip +.\" Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd September 22, 2020 +.Dt ZIP_FILE_GET_COMMENT 3 +.Os +.Sh NAME +.Nm zip_file_get_comment +.Nd get comment for file in zip +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft const char * +.Fn zip_file_get_comment "zip_t *archive" "zip_uint64_t index" "zip_uint32_t *lenp" "zip_flags_t flags" +.Sh DESCRIPTION +The +.Fn zip_file_get_comment +function returns the comment for the file at position +.Ar index +in the zip archive. +The name is in UTF-8 encoding unless +.Dv ZIP_FL_ENC_RAW +was specified (see below). +This pointer should not be modified or +.Xr free 3 Ap d , +and becomes invalid when +.Ar archive +is closed. +If +.Ar lenp +is not +.Dv NULL , +the integer to which it points will be set to the length of the +comment. +If +.Ar flags +is set to +.Dv ZIP_FL_UNCHANGED , +the original unchanged comment is returned. +.Pp +Additionally, the following +.Ar flags +are supported: +.Bl -tag -width ZIP_FL_ENC_STRICTXX -offset indent +.It Dv ZIP_FL_ENC_RAW +Return the unmodified comment as it is in the ZIP archive. +.It Dv ZIP_FL_ENC_GUESS +(Default.) +Guess the encoding of the comment in the ZIP archive and convert it +to UTF-8, if necessary. +(Only CP-437 and UTF-8 are recognized.) +.It Dv ZIP_FL_ENC_STRICT +Follow the ZIP specification for file names and extend it to file +comments, expecting them to be encoded in CP-437 in the ZIP archive +(except if it is a UTF-8 comment from the special extra field). +Convert it to UTF-8. +.El +.Em Note : +ASCII is a subset of both CP-437 and UTF-8. +.Sh RETURN VALUES +Upon successful completion, a pointer to the comment is returned, +or +.Dv NULL +if there is no comment. +In case of an error, +.Dv NULL +is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_file_get_comment +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar index +is not a valid file index in +.Ar archive . +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_set_comment 3 , +.Xr zip_get_archive_comment 3 +.Sh HISTORY +.Fn zip_file_get_comment +was added in libzip 0.11. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_file_get_error.html b/thirdparty/libzip-1.11.3/man/zip_file_get_error.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_get_error.man b/thirdparty/libzip-1.11.3/man/zip_file_get_error.man new file mode 100644 index 0000000..706ddbe --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_get_error.man @@ -0,0 +1,62 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_get_error.mdoc -- extract zip_error from zip_file +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_GET_ERROR" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_get_error\fR +\- extract zip_error from zip_file +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_error_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_file_get_error\fR(\fIzip_file_t\ *zf\fR); +.PD +.SH "DESCRIPTION" +\fBzip_file_get_error\fR() +function returns the zip_error associated with the zip_file +\fIzf\fR. +.SH "SEE ALSO" +libzip(3) +.SH "HISTORY" +\fBzip_file_get_error\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_file_get_error.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_get_error.mdoc new file mode 100644 index 0000000..5680a5e --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_get_error.mdoc @@ -0,0 +1,57 @@ +.\" zip_file_get_error.mdoc -- extract zip_error from zip_file +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_FILE_GET_ERROR 3 +.Os +.Sh NAME +.Nm zip_file_get_error +.Nd extract zip_error from zip_file +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_error_t * +.Fn zip_file_get_error "zip_file_t *zf" +.Sh DESCRIPTION +.Fn zip_file_get_error +function returns the zip_error associated with the zip_file +.Ar zf . +.Sh SEE ALSO +.Xr libzip 3 +.Sh HISTORY +.Fn zip_file_get_error +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_file_get_external_attributes.html b/thirdparty/libzip-1.11.3/man/zip_file_get_external_attributes.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_get_external_attributes.man b/thirdparty/libzip-1.11.3/man/zip_file_get_external_attributes.man new file mode 100644 index 0000000..b488ca3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_get_external_attributes.man @@ -0,0 +1,174 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_get_external_attributes.mdoc -- get external attributes for file in zip +.\" Copyright (C) 2013-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_GET_EXTERNAL_ATTRIBUTES" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_get_external_attributes\fR +\- get external attributes for file in zip +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_file_get_external_attributes\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_flags_t\ flags\fR, \fIzip_uint8_t\ *opsys\fR, \fIzip_uint32_t\ *attributes\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_file_get_external_attributes\fR() +function returns the operating system and external attributes for the +file at position +\fIindex\fR +in the zip archive. +The external attributes usually contain the operating system-specific +file permissions. +If +\fIflags\fR +is set to +\fRZIP_FL_UNCHANGED\fR, +the original unchanged values are returned. +If +\fIopsys\fR +or +\fIattributes\fR +are +\fRNULL\fR, +they are not filled in. +.PP +The following operating systems are defined by the zip specification: +.RS 6n +.PD 0 +.PP +\fRZIP_OPSYS_ACORN_RISC\fR +.PP +\fRZIP_OPSYS_ALTERNATE_MVS\fR +.PP +\fRZIP_OPSYS_AMIGA\fR +.PP +\fRZIP_OPSYS_ATARI_ST\fR +.PP +\fRZIP_OPSYS_BEOS\fR +.PP +\fRZIP_OPSYS_CPM\fR +.PP +\fRZIP_OPSYS_DOS\fR +.PP +\fRZIP_OPSYS_MACINTOSH\fR +.PP +\fRZIP_OPSYS_MVS\fR +.PP +\fRZIP_OPSYS_OPENVMS\fR +.PP +\fRZIP_OPSYS_OS_2\fR +.PP +\fRZIP_OPSYS_OS_400\fR +.PP +\fRZIP_OPSYS_OS_X\fR +.PP +\fRZIP_OPSYS_TANDEM\fR +.PP +\fRZIP_OPSYS_UNIX\fR +.PP +\fRZIP_OPSYS_VFAT\fR +.PP +\fRZIP_OPSYS_VM_CMS\fR +.PP +\fRZIP_OPSYS_VSE\fR +.PP +\fRZIP_OPSYS_WINDOWS_NTFS\fR +(uncommon, use +\fRZIP_OPSYS_DOS\fR +instead) +.PP +\fRZIP_OPSYS_Z_SYSTEM\fR +.RE +.PD +.PP +The defines above follow the PKWARE Inc. Appnote; please note that +the InfoZIP Appnote has a slightly different mapping. +.SH "RETURN VALUES" +Upon successful completion, 0 is returned. +In case of an error, +\fR\-1\fR +is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "EXAMPLES" +The following code can be used to expand +\fIattributes\fR +if the operating system is +\fRZIP_OPSYS_DOS\fR. +.nf +.sp +.RS 0n +#include + +#define FA_RDONLY 0x01 // FILE_ATTRIBUTE_READONLY +#define FA_DIREC 0x10 // FILE_ATTRIBUTE_DIRECTORY + +static mode_t +_zip_dos_attr2mode(zip_uint32_t attr) +{ + mode_t m = S_IRUSR | S_IRGRP | S_IROTH; + if (0 == (attr & FA_RDONLY)) + m |= S_IWUSR | S_IWGRP | S_IWOTH; + + if (attr & FA_DIREC) + m = (S_IFDIR | (m & ~S_IFMT)) | S_IXUSR | S_IXGRP | S_IXOTH; + + return m; +} +.RE +.fi +.SH "ERRORS" +\fBzip_file_get_external_attributes\fR() +fails if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIindex\fR +is not a valid file index in +\fIarchive\fR. +.SH "SEE ALSO" +libzip(3), +zip_file_set_external_attributes(3) +.SH "HISTORY" +\fBzip_file_get_external_attributes\fR() +was added in libzip 0.11.2. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_file_get_external_attributes.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_get_external_attributes.mdoc new file mode 100644 index 0000000..fe5293a --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_get_external_attributes.mdoc @@ -0,0 +1,165 @@ +.\" zip_file_get_external_attributes.mdoc -- get external attributes for file in zip +.\" Copyright (C) 2013-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_FILE_GET_EXTERNAL_ATTRIBUTES 3 +.Os +.Sh NAME +.Nm zip_file_get_external_attributes +.Nd get external attributes for file in zip +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_file_get_external_attributes "zip_t *archive" "zip_uint64_t index" "zip_flags_t flags" "zip_uint8_t *opsys" "zip_uint32_t *attributes" +.Sh DESCRIPTION +The +.Fn zip_file_get_external_attributes +function returns the operating system and external attributes for the +file at position +.Ar index +in the zip archive. +The external attributes usually contain the operating system-specific +file permissions. +If +.Ar flags +is set to +.Dv ZIP_FL_UNCHANGED , +the original unchanged values are returned. +If +.Ar opsys +or +.Ar attributes +are +.Dv NULL , +they are not filled in. +.Pp +The following operating systems are defined by the zip specification: +.Bl -item -compact -offset indent +.It +.Dv ZIP_OPSYS_ACORN_RISC +.It +.Dv ZIP_OPSYS_ALTERNATE_MVS +.It +.Dv ZIP_OPSYS_AMIGA +.It +.Dv ZIP_OPSYS_ATARI_ST +.It +.Dv ZIP_OPSYS_BEOS +.It +.Dv ZIP_OPSYS_CPM +.It +.Dv ZIP_OPSYS_DOS +.It +.Dv ZIP_OPSYS_MACINTOSH +.It +.Dv ZIP_OPSYS_MVS +.It +.Dv ZIP_OPSYS_OPENVMS +.It +.Dv ZIP_OPSYS_OS_2 +.It +.Dv ZIP_OPSYS_OS_400 +.It +.Dv ZIP_OPSYS_OS_X +.It +.Dv ZIP_OPSYS_TANDEM +.It +.Dv ZIP_OPSYS_UNIX +.It +.Dv ZIP_OPSYS_VFAT +.It +.Dv ZIP_OPSYS_VM_CMS +.It +.Dv ZIP_OPSYS_VSE +.It +.Dv ZIP_OPSYS_WINDOWS_NTFS +(uncommon, use +.Dv ZIP_OPSYS_DOS +instead) +.It +.Dv ZIP_OPSYS_Z_SYSTEM +.El +.Pp +The defines above follow the PKWARE Inc. Appnote; please note that +the InfoZIP Appnote has a slightly different mapping. +.Sh RETURN VALUES +Upon successful completion, 0 is returned. +In case of an error, +.Dv \-1 +is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh EXAMPLES +The following code can be used to expand +.Ar attributes +if the operating system is +.Dv ZIP_OPSYS_DOS . +.Bd -literal +#include + +#define FA_RDONLY 0x01 // FILE_ATTRIBUTE_READONLY +#define FA_DIREC 0x10 // FILE_ATTRIBUTE_DIRECTORY + +static mode_t +_zip_dos_attr2mode(zip_uint32_t attr) +{ + mode_t m = S_IRUSR | S_IRGRP | S_IROTH; + if (0 == (attr & FA_RDONLY)) + m |= S_IWUSR | S_IWGRP | S_IWOTH; + + if (attr & FA_DIREC) + m = (S_IFDIR | (m & ~S_IFMT)) | S_IXUSR | S_IXGRP | S_IXOTH; + + return m; +} +.Ed +.Sh ERRORS +.Fn zip_file_get_external_attributes +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar index +is not a valid file index in +.Ar archive . +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_set_external_attributes 3 +.Sh HISTORY +.Fn zip_file_get_external_attributes +was added in libzip 0.11.2. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_file_rename.html b/thirdparty/libzip-1.11.3/man/zip_file_rename.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_rename.man b/thirdparty/libzip-1.11.3/man/zip_file_rename.man new file mode 100644 index 0000000..22b40d1 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_rename.man @@ -0,0 +1,111 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_rename.mdoc -- rename file in zip archive +.\" Copyright (C) 2003-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_RENAME" "3" "September 22, 2020" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_rename\fR +\- rename file in zip archive +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_file_rename\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIconst\ char\ *name\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The file at position +\fIindex\fR +in the zip archive +\fIarchive\fR +is renamed to +\fIname\fR. +The +\fIflags\fR +argument can be any of: +.TP 22n +\fRZIP_FL_ENC_GUESS\fR +Guess encoding of +\fIname\fR +(default). +(Only CP-437 and UTF-8 are recognized.) +.TP 22n +\fRZIP_FL_ENC_UTF_8\fR +Interpret +\fIname\fR +as UTF-8. +.TP 22n +\fRZIP_FL_ENC_CP437\fR +Interpret +\fIname\fR +as code page 437 (CP-437). +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_file_rename\fR() +fails if: +.TP 19n +[\fRZIP_ER_DELETED\fR] +The file to be renamed has been deleted from the archive. +.TP 19n +[\fRZIP_ER_EXISTS\fR] +There is already a file called +\fIname\fR +in the archive. +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIindex\fR +is not a valid file index in +\fIarchive\fR, +\fIname is\fR +\fRNULL\fR, +the empty string, or not a valid UTF-8 encoded string. +Also a file cannot be renamed to a directory or vice versa. +Directories are denoted by a trailing slash. +.SH "SEE ALSO" +libzip(3), +zip_unchange(3) +.SH "HISTORY" +\fBzip_file_rename\fR() +was added in libzip 0.11. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_file_rename.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_rename.mdoc new file mode 100644 index 0000000..c4fad6b --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_rename.mdoc @@ -0,0 +1,104 @@ +.\" zip_file_rename.mdoc -- rename file in zip archive +.\" Copyright (C) 2003-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd September 22, 2020 +.Dt ZIP_FILE_RENAME 3 +.Os +.Sh NAME +.Nm zip_file_rename +.Nd rename file in zip archive +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_file_rename "zip_t *archive" "zip_uint64_t index" "const char *name" "zip_flags_t flags" +.Sh DESCRIPTION +The file at position +.Ar index +in the zip archive +.Ar archive +is renamed to +.Ar name . +The +.Ar flags +argument can be any of: +.Bl -tag -width XZIPXFLXENCXSTRICTXX +.It Dv ZIP_FL_ENC_GUESS +Guess encoding of +.Ar name +(default). +(Only CP-437 and UTF-8 are recognized.) +.It Dv ZIP_FL_ENC_UTF_8 +Interpret +.Ar name +as UTF-8. +.It Dv ZIP_FL_ENC_CP437 +Interpret +.Ar name +as code page 437 (CP-437). +.El +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_file_rename +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_DELETED +The file to be renamed has been deleted from the archive. +.It Bq Er ZIP_ER_EXISTS +There is already a file called +.Ar name +in the archive. +.It Bq Er ZIP_ER_INVAL +.Ar index +is not a valid file index in +.Ar archive , +.Ar name is +.Dv NULL , +the empty string, or not a valid UTF-8 encoded string. +Also a file cannot be renamed to a directory or vice versa. +Directories are denoted by a trailing slash. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_unchange 3 +.Sh HISTORY +.Fn zip_file_rename +was added in libzip 0.11. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_file_set_comment.html b/thirdparty/libzip-1.11.3/man/zip_file_set_comment.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_set_comment.man b/thirdparty/libzip-1.11.3/man/zip_file_set_comment.man new file mode 100644 index 0000000..584619e --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_set_comment.man @@ -0,0 +1,123 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_set_comment.mdoc -- set comment for file in zip +.\" Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_SET_COMMENT" "3" "September 22, 2020" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_set_comment\fR +\- set comment for file in zip +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_file_set_comment\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIconst\ char\ *comment\fR, \fIzip_uint16_t\ len\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_file_set_comment\fR() +function sets the comment for the file at position +\fIindex\fR +in the zip archive to +\fIcomment\fR +of length +\fIlen\fR. +If +\fIcomment\fR +is +\fRNULL\fR +and +\fIlen\fR +is 0, the file comment will be removed. +The +\fIflags\fR +argument can be any of: +.TP 22n +\fRZIP_FL_ENC_GUESS\fR +Guess encoding of +\fIcomment\fR +(default). +(Only CP-437 and UTF-8 are recognized.) +.TP 22n +\fRZIP_FL_ENC_UTF_8\fR +Interpret +\fIcomment\fR +as UTF-8. +.TP 22n +\fRZIP_FL_ENC_CP437\fR +Interpret +\fIcomment\fR +as code page 437 (CP-437). +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_file_set_comment\fR() +fails if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIindex\fR +is not a valid file index in +\fIarchive\fR, +or +\fIlen\fR +is less than 0 or longer than the maximum comment length in a zip file +(65535), or +\fIcomment\fR +is not a valid UTF-8 encoded string. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.TP 19n +[\fRZIP_ER_RDONLY\fR] +The +\fIarchive\fR +was opened in read-only mode. +.SH "SEE ALSO" +libzip(3), +zip_file_get_comment(3), +zip_get_archive_comment(3), +zip_set_archive_comment(3) +.SH "HISTORY" +\fBzip_file_set_comment\fR() +was added in libzip 0.11. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_file_set_comment.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_set_comment.mdoc new file mode 100644 index 0000000..dbc1f14 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_set_comment.mdoc @@ -0,0 +1,116 @@ +.\" zip_file_set_comment.mdoc -- set comment for file in zip +.\" Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd September 22, 2020 +.Dt ZIP_FILE_SET_COMMENT 3 +.Os +.Sh NAME +.Nm zip_file_set_comment +.Nd set comment for file in zip +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_file_set_comment "zip_t *archive" "zip_uint64_t index" "const char *comment" "zip_uint16_t len" "zip_flags_t flags" +.Sh DESCRIPTION +The +.Fn zip_file_set_comment +function sets the comment for the file at position +.Ar index +in the zip archive to +.Ar comment +of length +.Ar len . +If +.Ar comment +is +.Dv NULL +and +.Ar len +is 0, the file comment will be removed. +The +.Ar flags +argument can be any of: +.Bl -tag -width XZIPXFLXENCXSTRICTXX +.It Dv ZIP_FL_ENC_GUESS +Guess encoding of +.Ar comment +(default). +(Only CP-437 and UTF-8 are recognized.) +.It Dv ZIP_FL_ENC_UTF_8 +Interpret +.Ar comment +as UTF-8. +.It Dv ZIP_FL_ENC_CP437 +Interpret +.Ar comment +as code page 437 (CP-437). +.El +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_file_set_comment +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar index +is not a valid file index in +.Ar archive , +or +.Ar len +is less than 0 or longer than the maximum comment length in a zip file +(65535), or +.Ar comment +is not a valid UTF-8 encoded string. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.It Bq Er ZIP_ER_RDONLY +The +.Ar archive +was opened in read-only mode. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_get_comment 3 , +.Xr zip_get_archive_comment 3 , +.Xr zip_set_archive_comment 3 +.Sh HISTORY +.Fn zip_file_set_comment +was added in libzip 0.11. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_file_set_encryption.html b/thirdparty/libzip-1.11.3/man/zip_file_set_encryption.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_set_encryption.man b/thirdparty/libzip-1.11.3/man/zip_file_set_encryption.man new file mode 100644 index 0000000..5ba994c --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_set_encryption.man @@ -0,0 +1,132 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_set_encryption.mdoc -- set encryption method for file +.\" Copyright (C) 2016-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_SET_ENCRYPTION" "3" "April 2, 2020" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_set_encryption\fR +\- set encryption method for file in zip +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_file_set_encryption\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_uint16_t\ method\fR, \fIconst\ char\ *password\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_file_set_encryption\fR() +function sets the encryption method for the file at position +\fIindex\fR +in the zip archive to +\fImethod\fR +using the password +\fIpassword\fR. +The +\fImethod\fR +is the same as returned by +zip_stat(3). +For the +\fImethod\fR +argument, currently only the following values are supported: +.TP 19n +\fRZIP_EM_NONE\fR +No encryption. +.TP 19n +\fRZIP_EM_AES_128\fR +Winzip AES-128 encryption. +.TP 19n +\fRZIP_EM_AES_192\fR +Winzip AES-192 encryption. +.TP 19n +\fRZIP_EM_AES_256\fR +Winzip AES-256 encryption. +.TP 19n +\fRZIP_EM_TRAD_PKWARE\fR +.br +Traditional PKWare encryption. +Do not use this method, it is not secure. +It is only provided for backwards compatibility. +.PP +If +\fIpassword\fR +is +\fRNULL\fR, +the default password provided by +zip_set_default_password(3) +is used. +.PP +The current encryption method for a file in a zip archive can be +determined using +zip_stat(3). +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_file_set_encryption\fR() +fails if: +.TP 19n +[\fRZIP_ER_ENCRNOTSUPP\fR] +Unsupported compression method requested. +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIindex\fR +is not a valid file index in +\fIarchive\fR, +or the argument combination is invalid. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.TP 19n +[\fRZIP_ER_RDONLY\fR] +Read-only zip file, no changes allowed. +.SH "SEE ALSO" +libzip(3), +zip_encryption_method_supported(3), +zip_fopen_encrypted(3), +zip_fopen_index_encrypted(3), +zip_set_default_password(3), +zip_stat(3) +.SH "HISTORY" +\fBzip_file_set_encryption\fR() +was added in libzip 1.2.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_file_set_encryption.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_set_encryption.mdoc new file mode 100644 index 0000000..9071947 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_set_encryption.mdoc @@ -0,0 +1,121 @@ +.\" zip_file_set_encryption.mdoc -- set encryption method for file +.\" Copyright (C) 2016-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd April 2, 2020 +.Dt ZIP_FILE_SET_ENCRYPTION 3 +.Os +.Sh NAME +.Nm zip_file_set_encryption +.Nd set encryption method for file in zip +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_file_set_encryption "zip_t *archive" "zip_uint64_t index" "zip_uint16_t method" "const char *password" +.Sh DESCRIPTION +The +.Fn zip_file_set_encryption +function sets the encryption method for the file at position +.Ar index +in the zip archive to +.Ar method +using the password +.Ar password . +The +.Ar method +is the same as returned by +.Xr zip_stat 3 . +For the +.Ar method +argument, currently only the following values are supported: +.Bl -tag -width ZIP_CM_DEFLATE_XX +.It Dv ZIP_EM_NONE +No encryption. +.It Dv ZIP_EM_AES_128 +Winzip AES-128 encryption. +.It Dv ZIP_EM_AES_192 +Winzip AES-192 encryption. +.It Dv ZIP_EM_AES_256 +Winzip AES-256 encryption. +.It Dv ZIP_EM_TRAD_PKWARE +Traditional PKWare encryption. +Do not use this method, it is not secure. +It is only provided for backwards compatibility. +.El +.Pp +If +.Ar password +is +.Dv NULL , +the default password provided by +.Xr zip_set_default_password 3 +is used. +.Pp +The current encryption method for a file in a zip archive can be +determined using +.Xr zip_stat 3 . +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_file_set_encryption +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_ENCRNOTSUPP +Unsupported compression method requested. +.It Bq Er ZIP_ER_INVAL +.Ar index +is not a valid file index in +.Ar archive , +or the argument combination is invalid. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.It Bq Er ZIP_ER_RDONLY +Read-only zip file, no changes allowed. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_encryption_method_supported 3 , +.Xr zip_fopen_encrypted 3 , +.Xr zip_fopen_index_encrypted 3 , +.Xr zip_set_default_password 3 , +.Xr zip_stat 3 +.Sh HISTORY +.Fn zip_file_set_encryption +was added in libzip 1.2.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_file_set_external_attributes.html b/thirdparty/libzip-1.11.3/man/zip_file_set_external_attributes.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_set_external_attributes.man b/thirdparty/libzip-1.11.3/man/zip_file_set_external_attributes.man new file mode 100644 index 0000000..94100bd --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_set_external_attributes.man @@ -0,0 +1,95 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_set_external_attributes.mdoc -- set external attributes for file in zip +.\" Copyright (C) 2013-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_SET_EXTERNAL_ATTRIBUTES" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_set_external_attributes\fR +\- set external attributes for file in zip +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_file_set_external_attributes\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_flags_t\ flags\fR, \fIzip_uint8_t\ opsys\fR, \fIzip_uint32_t\ attributes\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_file_set_external_attributes\fR() +function sets the operating system and external attributes for the +file at position +\fIindex\fR +in the zip archive. +Currently, no +\fIflags\fR +are supported. +.PP +For a list of known +\fIopsys\fR +values, see +zip_file_get_external_attributes(3). +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_file_set_external_attributes\fR() +fails if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIindex\fR +is not a valid file index in +\fIarchive\fR. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.TP 19n +[\fRZIP_ER_RDONLY\fR] +The +\fIarchive\fR +was opened in read-only mode. +.SH "SEE ALSO" +libzip(3), +zip_file_get_external_attributes(3) +.SH "HISTORY" +\fBzip_file_set_external_attributes\fR() +was added in libzip 0.11.2. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_file_set_external_attributes.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_set_external_attributes.mdoc new file mode 100644 index 0000000..1043df6 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_set_external_attributes.mdoc @@ -0,0 +1,89 @@ +.\" zip_file_set_external_attributes.mdoc -- set external attributes for file in zip +.\" Copyright (C) 2013-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_FILE_SET_EXTERNAL_ATTRIBUTES 3 +.Os +.Sh NAME +.Nm zip_file_set_external_attributes +.Nd set external attributes for file in zip +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_file_set_external_attributes "zip_t *archive" "zip_uint64_t index" "zip_flags_t flags" "zip_uint8_t opsys" "zip_uint32_t attributes" +.Sh DESCRIPTION +The +.Fn zip_file_set_external_attributes +function sets the operating system and external attributes for the +file at position +.Ar index +in the zip archive. +Currently, no +.Ar flags +are supported. +.Pp +For a list of known +.Ar opsys +values, see +.Xr zip_file_get_external_attributes 3 . +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_file_set_external_attributes +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar index +is not a valid file index in +.Ar archive . +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.It Bq Er ZIP_ER_RDONLY +The +.Ar archive +was opened in read-only mode. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_get_external_attributes 3 +.Sh HISTORY +.Fn zip_file_set_external_attributes +was added in libzip 0.11.2. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_file_set_mtime.html b/thirdparty/libzip-1.11.3/man/zip_file_set_mtime.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_set_mtime.man b/thirdparty/libzip-1.11.3/man/zip_file_set_mtime.man new file mode 100644 index 0000000..4ef21a2 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_set_mtime.man @@ -0,0 +1,145 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_set_mtime.mdoc -- set mtime for file in zip +.\" Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_SET_MTIME" "3" "June 18, 2022" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_set_dostime\fR, +\fBzip_file_set_mtime\fR +\- set last modification time (mtime) for file in zip +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_file_set_dostime\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_uint16_t\ dostime\fR, \fIzip_uint16_t\ dosdate\fR, \fIzip_flags_t\ flags\fR); +.PD +.PP +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_file_set_mtime\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fItime_t\ mtime\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_file_set_mtime\fR() +function sets the last modification time (mtime) for the file at +position +\fIindex\fR +in the zip archive to +\fImtime\fR. +Currently, no support for any +\fIflags\fR +is implemented. +.PP +In the zip archive, the time and date are saved as two 16-bit integers. +To set the values directly, call the +\fBzip_file_set_dostime\fR() +function. +The values of the time bytes are defined as follows: +.RS 6n +.TP 7n +0-4 +seconds divided by two (1-2 = 1, 3-4 = 2, ...) +.TP 7n +5-10 +minute (0-59) +.TP 7n +11-15 +hour (0-23) +.RE +.PP +The values of the date bytes are defined as follows: +.RS 6n +.TP 7n +0-4 +day of the month (1-31) +.TP 7n +5-8 +month (January = 1, February = 2, ...) +.TP 7n +9-15 +year offset from 1980 (1980 = 0, 1981 = 1, ...) +.RE +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_file_set_dostime\fR() +and +\fBzip_file_set_mtime\fR() +fail if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIindex\fR +is not a valid file index in +\fIarchive\fR. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.TP 19n +[\fRZIP_ER_OPNOTSUPP\fR] +.br +Traditional PKWare encryption uses the file's mtime, therefore it cannot be changed without re-encrypting the data. +.TP 19n +[\fRZIP_ER_RDONLY\fR] +The +\fIarchive\fR +was opened in read-only mode. +.SH "SEE ALSO" +libzip(3), +zip_stat(3) +.SH "HISTORY" +\fBzip_file_set_mtime\fR() +was added in libzip 1.0. +\fBzip_file_set_dostime\fR() +was added in libzip 1.6. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> +.SH "CAVEATS" +Following historical practice, the +\fBzip_file_set_mtime\fR() +function translates the time from the zip archive into the local time +zone. +If you want to avoid this, use the +\fBzip_file_set_dostime\fR() +function instead. diff --git a/thirdparty/libzip-1.11.3/man/zip_file_set_mtime.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_set_mtime.mdoc new file mode 100644 index 0000000..f1a63bd --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_set_mtime.mdoc @@ -0,0 +1,126 @@ +.\" zip_file_set_mtime.mdoc -- set mtime for file in zip +.\" Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd June 18, 2022 +.Dt ZIP_FILE_SET_MTIME 3 +.Os +.Sh NAME +.Nm zip_file_set_dostime , +.Nm zip_file_set_mtime +.Nd set last modification time (mtime) for file in zip +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_file_set_dostime "zip_t *archive" "zip_uint64_t index" "zip_uint16_t dostime" "zip_uint16_t dosdate" "zip_flags_t flags" +.Ft int +.Fn zip_file_set_mtime "zip_t *archive" "zip_uint64_t index" "time_t mtime" "zip_flags_t flags" +.Sh DESCRIPTION +The +.Fn zip_file_set_mtime +function sets the last modification time (mtime) for the file at +position +.Ar index +in the zip archive to +.Ar mtime . +Currently, no support for any +.Ar flags +is implemented. +.Pp +In the zip archive, the time and date are saved as two 16-bit integers. +To set the values directly, call the +.Fn zip_file_set_dostime +function. +The values of the time bytes are defined as follows: +.Bl -tag -width 5n -offset indent +.It 0-4 +seconds divided by two (1-2 = 1, 3-4 = 2, ...) +.It 5-10 +minute (0-59) +.It 11-15 +hour (0-23) +.El +.Pp +The values of the date bytes are defined as follows: +.Bl -tag -width 5n -offset indent +.It 0-4 +day of the month (1-31) +.It 5-8 +month (January = 1, February = 2, ...) +.It 9-15 +year offset from 1980 (1980 = 0, 1981 = 1, ...) +.El +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_file_set_dostime +and +.Fn zip_file_set_mtime +fail if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar index +is not a valid file index in +.Ar archive . +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.It Bq Er ZIP_ER_OPNOTSUPP +Traditional PKWare encryption uses the file's mtime, therefore it cannot be changed without re-encrypting the data. +.It Bq Er ZIP_ER_RDONLY +The +.Ar archive +was opened in read-only mode. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_stat 3 +.Sh HISTORY +.Fn zip_file_set_mtime +was added in libzip 1.0. +.Fn zip_file_set_dostime +was added in libzip 1.6. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at +.Sh CAVEATS +Following historical practice, the +.Fn zip_file_set_mtime +function translates the time from the zip archive into the local time +zone. +If you want to avoid this, use the +.Fn zip_file_set_dostime +function instead. diff --git a/thirdparty/libzip-1.11.3/man/zip_file_strerror.html b/thirdparty/libzip-1.11.3/man/zip_file_strerror.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_file_strerror.man b/thirdparty/libzip-1.11.3/man/zip_file_strerror.man new file mode 100644 index 0000000..eb22c92 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_strerror.man @@ -0,0 +1,95 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_file_strerror.mdoc -- get string representation for a zip error +.\" Copyright (C) 2003-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FILE_STRERROR" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_file_strerror\fR, +\fBzip_strerror\fR +\- get string representation for a zip error +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIconst char *\fR +.br +.PD 0 +.HP 4n +\fBzip_file_strerror\fR(\fIzip_file_t\ *file\fR); +.PD +.PP +\fIconst char *\fR +.br +.PD 0 +.HP 4n +\fBzip_strerror\fR(\fIzip_t\ *archive\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_strerror\fR() +function returns a string describing the last error for the zip archive +\fIarchive\fR, +while the +\fBzip_file_strerror\fR() +function does the same for a zip file +\fIfile\fR +(one file in an archive). +The returned string must not be modified or freed, and becomes invalid when +\fIarchive\fR +or +\fIfile\fR, +respectively, +is closed or on the next call to +\fBzip_strerror\fR() +or +\fBzip_file_strerror\fR(), +respectively, +for the same archive. +.SH "RETURN VALUES" +\fBzip_file_strerror\fR() +and +\fBzip_strerror\fR() +return a pointer to the error string. +.SH "SEE ALSO" +libzip(3), +zip_error_strerror(3) +.SH "HISTORY" +\fBzip_file_strerror\fR() +and +\fBzip_strerror\fR() +were added in libzip 0.6. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_file_strerror.mdoc b/thirdparty/libzip-1.11.3/man/zip_file_strerror.mdoc new file mode 100644 index 0000000..498fcc2 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_file_strerror.mdoc @@ -0,0 +1,85 @@ +.\" zip_file_strerror.mdoc -- get string representation for a zip error +.\" Copyright (C) 2003-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_FILE_STRERROR 3 +.Os +.Sh NAME +.Nm zip_file_strerror , +.Nm zip_strerror +.Nd get string representation for a zip error +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft const char * +.Fn zip_file_strerror "zip_file_t *file" +.Ft const char * +.Fn zip_strerror "zip_t *archive" +.Sh DESCRIPTION +The +.Fn zip_strerror +function returns a string describing the last error for the zip archive +.Ar archive , +while the +.Fn zip_file_strerror +function does the same for a zip file +.Ar file +(one file in an archive). +The returned string must not be modified or freed, and becomes invalid when +.Ar archive +or +.Ar file , +respectively, +is closed or on the next call to +.Fn zip_strerror +or +.Fn zip_file_strerror , +respectively, +for the same archive. +.Sh RETURN VALUES +.Fn zip_file_strerror +and +.Fn zip_strerror +return a pointer to the error string. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_error_strerror 3 +.Sh HISTORY +.Fn zip_file_strerror +and +.Fn zip_strerror +were added in libzip 0.6. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_fopen.html b/thirdparty/libzip-1.11.3/man/zip_fopen.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_fopen.man b/thirdparty/libzip-1.11.3/man/zip_fopen.man new file mode 100644 index 0000000..394d95d --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_fopen.man @@ -0,0 +1,167 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_fopen.mdoc -- open file in zip archive for reading +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FOPEN" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_fopen\fR, +\fBzip_fopen_index\fR +\- open file in zip archive for reading +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_file_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_fopen\fR(\fIzip_t\ *archive\fR, \fIconst\ char\ *fname\fR, \fIzip_flags_t\ flags\fR); +.PD +.PP +\fIzip_file_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_fopen_index\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_fopen\fR() +function opens the file name +\fIfname\fR +in +\fIarchive\fR. +The +\fIflags\fR +argument specifies how the name lookup should be done, according to +the values are described in +zip_name_locate(3). +Also, the following values may be +\fIor\fR'ed +to it. +.RS 6n +.TP 19n +\fRZIP_FL_COMPRESSED\fR +Read the compressed data. +Otherwise the data is uncompressed by +\fBzip_fread\fR(). +.TP 19n +\fRZIP_FL_UNCHANGED\fR +Read the original data from the zip archive, ignoring any changes made +to the file; this is not supported by all data sources. +.RE +.PP +The +\fBzip_fopen_index\fR() +function opens the file at position +\fIindex\fR. +.PP +If encrypted data is encountered, the functions call +zip_fopen_encrypted(3) +or +zip_fopen_index_encrypted(3) +respectively, using the default password set with +zip_set_default_password(3). +.SH "RETURN VALUES" +Upon successful completion, a +\fIstruct zip_file\fR +pointer is returned. +Otherwise, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +.TP 19n +[\fRZIP_ER_CHANGED\fR] +The file data has been changed and the data source does +not support rereading data. +.TP 19n +[\fRZIP_ER_COMPNOTSUPP\fR] +The compression method used is not supported. +.TP 19n +[\fRZIP_ER_ENCRNOTSUPP\fR] +The encryption method used is not supported. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.TP 19n +[\fRZIP_ER_NOPASSWD\fR] +The file is encrypted, but no password has been provided. +.TP 19n +[\fRZIP_ER_READ\fR] +A file read error occurred. +.TP 19n +[\fRZIP_ER_SEEK\fR] +A file seek error occurred. +.TP 19n +[\fRZIP_ER_WRONGPASSWD\fR] +The provided password does not match the password used for encryption. +Note that some incorrect passwords are not detected by the check done by +\fBzip_fopen\fR(). +.TP 19n +[\fRZIP_ER_ZLIB\fR] +Initializing the zlib stream failed. +.PP +The function +\fBzip_fopen\fR() +may also fail and set +\fIzip_err\fR +for any of the errors specified for the routine +zip_name_locate(3). +.PP +The function +\fBzip_fopen_index\fR() +may also fail with +\fRZIP_ER_INVAL\fR +if +\fIindex\fR +is invalid. +.SH "SEE ALSO" +libzip(3), +zip_fclose(3), +zip_fread(3), +zip_fseek(3), +zip_get_num_entries(3), +zip_name_locate(3), +zip_set_default_password(3) +.SH "HISTORY" +\fBzip_fopen\fR() +and +\fBzip_fopen_index\fR() +were added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_fopen.mdoc b/thirdparty/libzip-1.11.3/man/zip_fopen.mdoc new file mode 100644 index 0000000..d86bdb9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_fopen.mdoc @@ -0,0 +1,148 @@ +.\" zip_fopen.mdoc -- open file in zip archive for reading +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_FOPEN 3 +.Os +.Sh NAME +.Nm zip_fopen , +.Nm zip_fopen_index +.Nd open file in zip archive for reading +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_file_t * +.Fn zip_fopen "zip_t *archive" "const char *fname" "zip_flags_t flags" +.Ft zip_file_t * +.Fn zip_fopen_index "zip_t *archive" "zip_uint64_t index" "zip_flags_t flags" +.Sh DESCRIPTION +The +.Fn zip_fopen +function opens the file name +.Ar fname +in +.Ar archive . +The +.Ar flags +argument specifies how the name lookup should be done, according to +the values are described in +.Xr zip_name_locate 3 . +Also, the following values may be +.Em or Ns No 'ed +to it. +.Bl -tag -offset indent -width ZIP_FL_COMPRESSED +.It Dv ZIP_FL_COMPRESSED +Read the compressed data. +Otherwise the data is uncompressed by +.Fn zip_fread . +.It Dv ZIP_FL_UNCHANGED +Read the original data from the zip archive, ignoring any changes made +to the file; this is not supported by all data sources. +.El +.Pp +The +.Fn zip_fopen_index +function opens the file at position +.Ar index . +.Pp +If encrypted data is encountered, the functions call +.Xr zip_fopen_encrypted 3 +or +.Xr zip_fopen_index_encrypted 3 +respectively, using the default password set with +.Xr zip_set_default_password 3 . +.Sh RETURN VALUES +Upon successful completion, a +.Ft struct zip_file +pointer is returned. +Otherwise, +.Dv NULL +is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er ZIP_ER_CHANGED +The file data has been changed and the data source does +not support rereading data. +.It Bq Er ZIP_ER_COMPNOTSUPP +The compression method used is not supported. +.It Bq Er ZIP_ER_ENCRNOTSUPP +The encryption method used is not supported. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.It Bq Er ZIP_ER_NOPASSWD +The file is encrypted, but no password has been provided. +.It Bq Er ZIP_ER_READ +A file read error occurred. +.It Bq Er ZIP_ER_SEEK +A file seek error occurred. +.It Bq Er ZIP_ER_WRONGPASSWD +The provided password does not match the password used for encryption. +Note that some incorrect passwords are not detected by the check done by +.Fn zip_fopen . +.It Bq Er ZIP_ER_ZLIB +Initializing the zlib stream failed. +.El +.Pp +The function +.Fn zip_fopen +may also fail and set +.Va zip_err +for any of the errors specified for the routine +.Xr zip_name_locate 3 . +.Pp +The function +.Fn zip_fopen_index +may also fail with +.Er ZIP_ER_INVAL +if +.Ar index +is invalid. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_fclose 3 , +.Xr zip_fread 3 , +.Xr zip_fseek 3 , +.Xr zip_get_num_entries 3 , +.Xr zip_name_locate 3 , +.Xr zip_set_default_password 3 +.Sh HISTORY +.Fn zip_fopen +and +.Fn zip_fopen_index +were added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_fopen_encrypted.html b/thirdparty/libzip-1.11.3/man/zip_fopen_encrypted.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_fopen_encrypted.man b/thirdparty/libzip-1.11.3/man/zip_fopen_encrypted.man new file mode 100644 index 0000000..32aba3c --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_fopen_encrypted.man @@ -0,0 +1,144 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_fopen_encrypted.mdoc -- open encrypted file in zip archive for reading +.\" Copyright (C) 2011-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FOPEN_ENCRYPTED" "3" "September 15, 2020" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_fopen_encrypted\fR, +\fBzip_fopen_index_encrypted\fR +\- open encrypted file in zip archive for reading +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_file_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_fopen_encrypted\fR(\fIzip_t\ *archive\fR, \fIconst\ char\ *fname\fR, \fIzip_flags_t\ flags\fR, \fIconst\ char\ *password\fR); +.PD +.PP +\fIzip_file_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_fopen_index_encrypted\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_flags_t\ flags\fR, \fIconst\ char\ *password\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_fopen_encrypted\fR() +function opens the encrypted file name +\fIfname\fR +in +\fIarchive\fR +using the password given in the +\fIpassword\fR +argument. +If +\fIpassword\fR +is +\fRNULL\fR +or the empty string, the default password is used (see +zip_set_default_password(3)). +The +\fIflags\fR +argument are the same as for +zip_fopen(3). +.PP +The +\fBzip_fopen_index_encrypted\fR() +function opens the file at position +\fIindex\fR, +see +zip_fopen_index(3). +These functions are called automatically by +zip_fopen(3); +you only need to call them if you want to specify a non-default password +(see +zip_set_default_password(3)). +.SH "RETURN VALUES" +Upon successful completion, a +\fIstruct zip_file\fR +pointer is returned. +Otherwise, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +.TP 22n +[\fRZIP_ER_NOPASSWD\fR] +No password was provided. +.PP +The function +\fBzip_fopen_encrypted\fR() +may also fail and set +\fIzip_err\fR +for any of the errors specified for the routine +zip_fopen(3). +.PP +The function +\fBzip_fopen_index_encrypted\fR() +may also fail and set +\fIzip_err\fR +for any of the errors specified for the routine +zip_fopen_index(3). +.SH "SEE ALSO" +libzip(3), +zip_fclose(3), +zip_fopen(3), +zip_fread(3), +zip_get_num_entries(3), +zip_name_locate(3) +.SH "HISTORY" +\fBzip_fopen_encrypted\fR() +and +\fBzip_fopen_index_encrypted\fR() +were added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> +.SH "CAVEATS" +The zip file format provides very limited possibility for password +verification (a short hash of is compared against one byte in the zip +archive). +For this reason, reading a file while using an incorrect password may +immediately fail with +\fRZIP_ER_WRONGPASSWD\fR, +but if the mismatch is not detected, a zlib error may be returned +later instead. +Since zlib errors can also be caused by broken compressed data, there +is no way to make sure if the password was incorrect or if it was +correct, but the compressed data was invalid. diff --git a/thirdparty/libzip-1.11.3/man/zip_fopen_encrypted.mdoc b/thirdparty/libzip-1.11.3/man/zip_fopen_encrypted.mdoc new file mode 100644 index 0000000..9428798 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_fopen_encrypted.mdoc @@ -0,0 +1,135 @@ +.\" zip_fopen_encrypted.mdoc -- open encrypted file in zip archive for reading +.\" Copyright (C) 2011-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd September 15, 2020 +.Dt ZIP_FOPEN_ENCRYPTED 3 +.Os +.Sh NAME +.Nm zip_fopen_encrypted , +.Nm zip_fopen_index_encrypted +.Nd open encrypted file in zip archive for reading +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_file_t * +.Fn zip_fopen_encrypted "zip_t *archive" "const char *fname" "zip_flags_t flags" "const char *password" +.Ft zip_file_t * +.Fn zip_fopen_index_encrypted "zip_t *archive" "zip_uint64_t index" "zip_flags_t flags" "const char *password" +.Sh DESCRIPTION +The +.Fn zip_fopen_encrypted +function opens the encrypted file name +.Ar fname +in +.Ar archive +using the password given in the +.Ar password +argument. +If +.Ar password +is +.Dv NULL +or the empty string, the default password is used (see +.Xr zip_set_default_password 3 ) . +The +.Ar flags +argument are the same as for +.Xr zip_fopen 3 . +.Pp +The +.Fn zip_fopen_index_encrypted +function opens the file at position +.Ar index , +see +.Xr zip_fopen_index 3 . +These functions are called automatically by +.Xr zip_fopen 3 ; +you only need to call them if you want to specify a non-default password +(see +.Xr zip_set_default_password 3 ) . +.Sh RETURN VALUES +Upon successful completion, a +.Ft struct zip_file +pointer is returned. +Otherwise, +.Dv NULL +is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Bl -tag -width ZIP_ER_ENCRNOTSUPPXX +.It Bq Er ZIP_ER_NOPASSWD +No password was provided. +.El +.Pp +The function +.Fn zip_fopen_encrypted +may also fail and set +.Va zip_err +for any of the errors specified for the routine +.Xr zip_fopen 3 . +.Pp +The function +.Fn zip_fopen_index_encrypted +may also fail and set +.Va zip_err +for any of the errors specified for the routine +.Xr zip_fopen_index 3 . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_fclose 3 , +.Xr zip_fopen 3 , +.Xr zip_fread 3 , +.Xr zip_get_num_entries 3 , +.Xr zip_name_locate 3 +.Sh HISTORY +.Fn zip_fopen_encrypted +and +.Fn zip_fopen_index_encrypted +were added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at +.Sh CAVEATS +The zip file format provides very limited possibility for password +verification (a short hash of is compared against one byte in the zip +archive). +For this reason, reading a file while using an incorrect password may +immediately fail with +.Er ZIP_ER_WRONGPASSWD , +but if the mismatch is not detected, a zlib error may be returned +later instead. +Since zlib errors can also be caused by broken compressed data, there +is no way to make sure if the password was incorrect or if it was +correct, but the compressed data was invalid. diff --git a/thirdparty/libzip-1.11.3/man/zip_fread.html b/thirdparty/libzip-1.11.3/man/zip_fread.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_fread.man b/thirdparty/libzip-1.11.3/man/zip_fread.man new file mode 100644 index 0000000..4e11c48 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_fread.man @@ -0,0 +1,90 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_fread.mdoc -- read from file +.\" Copyright (C) 2003-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FREAD" "3" "September 11, 2024" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_fread\fR +\- read from file +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_fread\fR(\fIzip_file_t\ *file\fR, \fIvoid\ *buf\fR, \fIzip_uint64_t\ nbytes\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_fread\fR() +function reads up to +\fInbytes\fR +bytes from +\fIfile\fR +into +\fIbuf\fR +from the current position in the file (see +zip_fseek(3)). +After reading, the current position is updated by the number of bytes read. +.SH "RETURN VALUES" +If successful, the number of bytes actually read is returned. +When +\fBzip_fread\fR() +is called after reaching the end of the file, 0 is returned. +In case of error, \-1 is returned. +.SH "SEE ALSO" +libzip(3), +zip_fclose(3), +zip_file_get_error(3), +zip_fopen(3), +zip_fseek(3) +.SH "HISTORY" +\fBzip_fread\fR() +was added in libzip 0.6. +In libzip 0.10 the return type was changed from +\fIssize_t\fR +to +\fIzip_int64_t\fR. +In libzip 0.10 the type of +\fInbytes\fR +was changed from +\fIsize_t\fR +to +\fIzip_uint64_t\fR. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_fread.mdoc b/thirdparty/libzip-1.11.3/man/zip_fread.mdoc new file mode 100644 index 0000000..3371298 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_fread.mdoc @@ -0,0 +1,85 @@ +.\" zip_fread.mdoc -- read from file +.\" Copyright (C) 2003-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd September 11, 2024 +.Dt ZIP_FREAD 3 +.Os +.Sh NAME +.Nm zip_fread +.Nd read from file +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_fread "zip_file_t *file" "void *buf" "zip_uint64_t nbytes" +.Sh DESCRIPTION +The +.Fn zip_fread +function reads up to +.Ar nbytes +bytes from +.Ar file +into +.Ar buf +from the current position in the file (see +.Xr zip_fseek 3 ) . +After reading, the current position is updated by the number of bytes read. +.Sh RETURN VALUES +If successful, the number of bytes actually read is returned. +When +.Fn zip_fread +is called after reaching the end of the file, 0 is returned. +In case of error, \-1 is returned. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_fclose 3 , +.Xr zip_file_get_error 3 , +.Xr zip_fopen 3 , +.Xr zip_fseek 3 +.Sh HISTORY +.Fn zip_fread +was added in libzip 0.6. +In libzip 0.10 the return type was changed from +.Vt ssize_t +to +.Vt zip_int64_t . +In libzip 0.10 the type of +.Ar nbytes +was changed from +.Vt size_t +to +.Vt zip_uint64_t . +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_fseek.html b/thirdparty/libzip-1.11.3/man/zip_fseek.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_fseek.man b/thirdparty/libzip-1.11.3/man/zip_fseek.man new file mode 100644 index 0000000..731abc9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_fseek.man @@ -0,0 +1,99 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_fseek.mdoc -- seek in file +.\" Copyright (C) 2016-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FSEEK" "3" "September 11, 2024" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_fseek\fR, +\fBzip_file_is_seekable\fR +\- seek in file +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int8_t\fR +.br +.PD 0 +.HP 4n +\fBzip_fseek\fR(\fIzip_file_t\ *file\fR, \fIzip_int64_t\ offset\fR, \fIint\ whence\fR); +.PD +.PP +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_file_is_seekable\fR(\fIzip_file_t\ *file\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_fseek\fR() +function seeks to the specified +\fIoffset\fR +relative to +\fIwhence\fR, +just like +fseek(3). +.PP +\fBzip_fseek\fR +only works on uncompressed (stored), unencrypted data. +When called on compressed or encrypted data it will return an error. +.PP +The +\fBzip_file_is_seekable\fR() +function returns 1 if a file is seekable. +.SH "RETURN VALUES" +If successful, +\fBzip_fseek\fR() +returns 0. +Otherwise, \-1 is returned. +.PP +\fBzip_file_is_seekable\fR() +returns 1 if a file is seekable and 0 if not. +On an invalid argument, it returns \-1. +.SH "SEE ALSO" +libzip(3), +zip_fclose(3), +zip_file_get_error(3), +zip_fopen(3), +zip_fread(3), +zip_ftell(3) +.SH "HISTORY" +\fBzip_fseek\fR() +was added in libzip 1.2.0. +\fBzip_file_is_seekable\fR() +was added in libzip 1.9.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_fseek.mdoc b/thirdparty/libzip-1.11.3/man/zip_fseek.mdoc new file mode 100644 index 0000000..3ba5a9e --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_fseek.mdoc @@ -0,0 +1,89 @@ +.\" zip_fseek.mdoc -- seek in file +.\" Copyright (C) 2016-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd September 11, 2024 +.Dt ZIP_FSEEK 3 +.Os +.Sh NAME +.Nm zip_fseek , +.Nm zip_file_is_seekable +.Nd seek in file +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int8_t +.Fn zip_fseek "zip_file_t *file" "zip_int64_t offset" "int whence" +.Ft int +.Fn zip_file_is_seekable "zip_file_t *file" +.Sh DESCRIPTION +The +.Fn zip_fseek +function seeks to the specified +.Ar offset +relative to +.Ar whence , +just like +.Xr fseek 3 . +.Pp +.Nm +only works on uncompressed (stored), unencrypted data. +When called on compressed or encrypted data it will return an error. +.Pp +The +.Fn zip_file_is_seekable +function returns 1 if a file is seekable. +.Sh RETURN VALUES +If successful, +.Fn zip_fseek +returns 0. +Otherwise, \-1 is returned. +.Pp +.Fn zip_file_is_seekable +returns 1 if a file is seekable and 0 if not. +On an invalid argument, it returns \-1. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_fclose 3 , +.Xr zip_file_get_error 3 , +.Xr zip_fopen 3 , +.Xr zip_fread 3 , +.Xr zip_ftell 3 +.Sh HISTORY +.Fn zip_fseek +was added in libzip 1.2.0. +.Fn zip_file_is_seekable +was added in libzip 1.9.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_ftell.html b/thirdparty/libzip-1.11.3/man/zip_ftell.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_ftell.man b/thirdparty/libzip-1.11.3/man/zip_ftell.man new file mode 100644 index 0000000..ee9eba8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_ftell.man @@ -0,0 +1,72 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_ftell.mdoc -- tell position in file +.\" Copyright (C) 2016-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_FTELL" "3" "September 11, 2024" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_ftell\fR +\- tell position in file +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_ftell\fR(\fIzip_file_t\ *file\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_ftell\fR() +function reports the current offset in the file. +.SH "RETURN VALUES" +If successful, +\fBzip_ftell\fR +returns the current file position. +Otherwise, \-1 is returned. +.SH "SEE ALSO" +libzip(3), +zip_fclose(3), +zip_file_get_error(3), +zip_fopen(3), +zip_fread(3), +zip_fseek(3) +.SH "HISTORY" +\fBzip_ftell\fR() +was added in libzip 1.2.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_ftell.mdoc b/thirdparty/libzip-1.11.3/man/zip_ftell.mdoc new file mode 100644 index 0000000..e045634 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_ftell.mdoc @@ -0,0 +1,67 @@ +.\" zip_ftell.mdoc -- tell position in file +.\" Copyright (C) 2016-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd September 11, 2024 +.Dt ZIP_FTELL 3 +.Os +.Sh NAME +.Nm zip_ftell +.Nd tell position in file +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_ftell "zip_file_t *file" +.Sh DESCRIPTION +The +.Fn zip_ftell +function reports the current offset in the file. +.Sh RETURN VALUES +If successful, +.Nm +returns the current file position. +Otherwise, \-1 is returned. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_fclose 3 , +.Xr zip_file_get_error 3 , +.Xr zip_fopen 3 , +.Xr zip_fread 3 , +.Xr zip_fseek 3 +.Sh HISTORY +.Fn zip_ftell +was added in libzip 1.2.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_get_archive_comment.html b/thirdparty/libzip-1.11.3/man/zip_get_archive_comment.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_get_archive_comment.man b/thirdparty/libzip-1.11.3/man/zip_get_archive_comment.man new file mode 100644 index 0000000..3a9df01 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_get_archive_comment.man @@ -0,0 +1,115 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_get_archive_comment.mdoc -- get zip archive comment +.\" Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_GET_ARCHIVE_COMMENT" "3" "September 22, 2020" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_get_archive_comment\fR +\- get zip archive comment +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIconst char *\fR +.br +.PD 0 +.HP 4n +\fBzip_get_archive_comment\fR(\fIzip_t\ *archive\fR, \fIint\ *lenp\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_get_archive_comment\fR() +function returns the comment for the entire zip archive. +The return value is in UTF-8 encoding unless +\fRZIP_FL_ENC_RAW\fR +was specified (see below). +This pointer should not be modified or +free(3)'d, +and becomes invalid when +\fIarchive\fR +is closed. +If +\fIlenp\fR +is not +\fRNULL\fR, +the integer to which it points will be set to the length of the +comment. +If +\fIflags\fR +is set to +\fRZIP_FL_UNCHANGED\fR, +the original unchanged comment is returned. +.PP +Additionally, the following +\fIflags\fR +are supported: +.RS 6n +.TP 21n +\fRZIP_FL_ENC_RAW\fR +Return the unmodified archive comment as it is in the ZIP archive. +.TP 21n +\fRZIP_FL_ENC_GUESS\fR +(Default.) +Guess the encoding of the archive comment in the ZIP archive and convert it +to UTF-8, if necessary. +(Only CP-437 and UTF-8 are recognized.) +.TP 21n +\fRZIP_FL_ENC_STRICT\fR +Follow the ZIP specification for file names and extend it to the +archive comment, thus also expecting it in CP-437 encoding. +Convert it to UTF-8. +.RE +\fINote\fR: +ASCII is a subset of both CP-437 and UTF-8. +.SH "RETURN VALUES" +Upon successful completion, a pointer to the comment is returned, +or +\fRNULL\fR +if there is no comment. +.SH "SEE ALSO" +libzip(3), +zip_file_get_comment(3) +.SH "HISTORY" +\fBzip_get_archive_comment\fR() +was added in libzip 0.7. +In libzip 0.11 the type of +\fIflags\fR +was changed from +\fIint\fR +to +\fIzip_flags_t\fR. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_get_archive_comment.mdoc b/thirdparty/libzip-1.11.3/man/zip_get_archive_comment.mdoc new file mode 100644 index 0000000..d8f2e9b --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_get_archive_comment.mdoc @@ -0,0 +1,112 @@ +.\" zip_get_archive_comment.mdoc -- get zip archive comment +.\" Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd September 22, 2020 +.Dt ZIP_GET_ARCHIVE_COMMENT 3 +.Os +.Sh NAME +.Nm zip_get_archive_comment +.Nd get zip archive comment +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft const char * +.Fn zip_get_archive_comment "zip_t *archive" "int *lenp" "zip_flags_t flags" +.Sh DESCRIPTION +The +.Fn zip_get_archive_comment +function returns the comment for the entire zip archive. +The return value is in UTF-8 encoding unless +.Dv ZIP_FL_ENC_RAW +was specified (see below). +This pointer should not be modified or +.Xr free 3 Ap d , +and becomes invalid when +.Ar archive +is closed. +If +.Ar lenp +is not +.Dv NULL , +the integer to which it points will be set to the length of the +comment. +If +.Ar flags +is set to +.Dv ZIP_FL_UNCHANGED , +the original unchanged comment is returned. +.Pp +Additionally, the following +.Ar flags +are supported: +.Bl -tag -width ZIP_FL_ENC_STRICTXX -offset indent +.It Dv ZIP_FL_ENC_RAW +Return the unmodified archive comment as it is in the ZIP archive. +.It Dv ZIP_FL_ENC_GUESS +(Default.) +Guess the encoding of the archive comment in the ZIP archive and convert it +to UTF-8, if necessary. +(Only CP-437 and UTF-8 are recognized.) +.It Dv ZIP_FL_ENC_STRICT +Follow the ZIP specification for file names and extend it to the +archive comment, thus also expecting it in CP-437 encoding. +Convert it to UTF-8. +.El +.Em Note : +ASCII is a subset of both CP-437 and UTF-8. +.Sh RETURN VALUES +Upon successful completion, a pointer to the comment is returned, +or +.Dv NULL +if there is no comment. +.\" In case of an error, +.\" .Dv NULL +.\" is returned and the error code in +.\" .Ar archive +.\" is set to indicate the error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_get_comment 3 +.Sh HISTORY +.Fn zip_get_archive_comment +was added in libzip 0.7. +In libzip 0.11 the type of +.Ar flags +was changed from +.Vt int +to +.Vt zip_flags_t . +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_get_archive_flag.html b/thirdparty/libzip-1.11.3/man/zip_get_archive_flag.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_get_archive_flag.man b/thirdparty/libzip-1.11.3/man/zip_get_archive_flag.man new file mode 100644 index 0000000..408e099 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_get_archive_flag.man @@ -0,0 +1,117 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_get_archive_flag.mdoc -- get comment for file in zip +.\" Copyright (C) 2008-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_GET_ARCHIVE_FLAG" "3" "January 23, 2023" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_get_archive_flag\fR +\- get status flags for zip +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_get_archive_flag\fR(\fIzip_t\ *archive\fR, \fIzip_flags_t\ flag\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_get_archive_flag\fR() +function returns if the flag +\fIflag\fR +is set for the archive +\fIarchive\fR. +The archive flags might have been changed with +\fBzip_set_archive_flag\fR(); +if +\fIflags\fR +is set to +\fRZIP_FL_UNCHANGED\fR, +the original unchanged flags are tested. +.PP +Supported flags are: +.TP 20n +\fRZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE\fR +If this flag is cleared, the archive file will be removed if the archive is empty. +If it is set, an empty archive will be created, which is not recommended by the zip specification. +This flag is always cleared unless explicitly set by the user with +zip_set_archive_flag(3). +.TP 20n +\fRZIP_AFL_IS_TORRENTZIP\fR +The archive is in torrentzip format. +.TP 20n +\fRZIP_AFL_RDONLY\fR +The archive is read-only. +.TP 20n +\fRZIP_AFL_WANT_TORRENTZIP\fR +If the flag is set, the archive will be written in torrentzip format. +This flag is always cleared unless explicitly set by the user with +zip_set_archive_flag(3). +.SH "RETURN VALUES" +\fBzip_get_archive_flag\fR() +returns 1 if +\fIflag\fR +is set for +\fIarchive\fR, +0 if not, +and \-1 if an error occurred. +.SH "SEE ALSO" +libzip(3), +zip_set_archive_flag(3) +.SH "HISTORY" +\fBzip_get_archive_flag\fR() +was added in libzip 0.9. +In libzip 0.11 the type of +\fIflag\fR +was changed from +\fIint\fR +to +\fIzip_flags_t m\fR +and the type of +\fIflags\fR +was changed from +\fIint\fR +to +\fIzip_flags_t\fR. +\fRZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE\fR, +\fRZIP_AFL_IS_TORRENTZIP\fR, +and +\fRZIP_AFL_WANT_TORRENTZIP\fR +were added in libzip 1.10.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_get_archive_flag.mdoc b/thirdparty/libzip-1.11.3/man/zip_get_archive_flag.mdoc new file mode 100644 index 0000000..2edf7cf --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_get_archive_flag.mdoc @@ -0,0 +1,110 @@ +.\" zip_get_archive_flag.mdoc -- get comment for file in zip +.\" Copyright (C) 2008-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd January 23, 2023 +.Dt ZIP_GET_ARCHIVE_FLAG 3 +.Os +.Sh NAME +.Nm zip_get_archive_flag +.Nd get status flags for zip +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_get_archive_flag "zip_t *archive" "zip_flags_t flag" "zip_flags_t flags" +.Sh DESCRIPTION +The +.Fn zip_get_archive_flag +function returns if the flag +.Ar flag +is set for the archive +.Ar archive . +The archive flags might have been changed with +.Fn zip_set_archive_flag ; +if +.Ar flags +is set to +.Dv ZIP_FL_UNCHANGED , +the original unchanged flags are tested. +.Pp +Supported flags are: +.Bl -tag -width XZIPXAFLXRDONLYXXX +.It Dv ZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE +If this flag is cleared, the archive file will be removed if the archive is empty. +If it is set, an empty archive will be created, which is not recommended by the zip specification. +This flag is always cleared unless explicitly set by the user with +.Xr zip_set_archive_flag 3 . +.It Dv ZIP_AFL_IS_TORRENTZIP +The archive is in torrentzip format. +.It Dv ZIP_AFL_RDONLY +The archive is read-only. +.It Dv ZIP_AFL_WANT_TORRENTZIP +If the flag is set, the archive will be written in torrentzip format. +This flag is always cleared unless explicitly set by the user with +.Xr zip_set_archive_flag 3 . +.El +.Sh RETURN VALUES +.Fn zip_get_archive_flag +returns 1 if +.Ar flag +is set for +.Ar archive , +0 if not, +and \-1 if an error occurred. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_set_archive_flag 3 +.Sh HISTORY +.Fn zip_get_archive_flag +was added in libzip 0.9. +In libzip 0.11 the type of +.Ar flag +was changed from +.Vt int +to +.Vt zip_flags_t m +and the type of +.Ar flags +was changed from +.Vt int +to +.Vt zip_flags_t . +.Dv ZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE , +.Dv ZIP_AFL_IS_TORRENTZIP , +and +.Dv ZIP_AFL_WANT_TORRENTZIP +were added in libzip 1.10.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_get_error.html b/thirdparty/libzip-1.11.3/man/zip_get_error.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_get_error.man b/thirdparty/libzip-1.11.3/man/zip_get_error.man new file mode 100644 index 0000000..7f0b75a --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_get_error.man @@ -0,0 +1,65 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_get_error.mdoc -- get zip_error for archive +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_GET_ERROR" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_get_error\fR +\- get zip error for archive +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_error_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_get_error\fR(\fIzip_t\ *archive\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_get_error\fR() +function returns the zip error for the zip archive +\fIarchive\fR. +.SH "SEE ALSO" +libzip(3), +zip_error_code_system(3), +zip_error_code_zip(3) +.SH "HISTORY" +\fBzip_get_error\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_get_error.mdoc b/thirdparty/libzip-1.11.3/man/zip_get_error.mdoc new file mode 100644 index 0000000..6af6f21 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_get_error.mdoc @@ -0,0 +1,60 @@ +.\" zip_get_error.mdoc -- get zip_error for archive +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_GET_ERROR 3 +.Os +.Sh NAME +.Nm zip_get_error +.Nd get zip error for archive +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_error_t * +.Fn zip_get_error "zip_t *archive" +.Sh DESCRIPTION +The +.Fn zip_get_error +function returns the zip error for the zip archive +.Ar archive . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_error_code_system 3 , +.Xr zip_error_code_zip 3 +.Sh HISTORY +.Fn zip_get_error +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_get_file_comment.html b/thirdparty/libzip-1.11.3/man/zip_get_file_comment.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_get_file_comment.man b/thirdparty/libzip-1.11.3/man/zip_get_file_comment.man new file mode 100644 index 0000000..a66b5c8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_get_file_comment.man @@ -0,0 +1,78 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_get_file_comment.mdoc -- get comment for file in zip +.\" Copyright (C) 2006-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_GET_FILE_COMMENT" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_get_file_comment\fR +\- get comment for file in zip (obsolete interface) +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIconst char *\fR +.br +.PD 0 +.HP 4n +\fBzip_get_file_comment\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIint\ *lenp\fR, \fIint\ flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_get_file_comment\fR() +function is the obsolete version of +zip_file_get_comment(3). +The only differences are the types of the +\fIlenp\fR +and +\fIflags\fR +arguments. +.SH "SEE ALSO" +libzip(3), +zip_file_get_comment(3) +.SH "HISTORY" +\fBzip_get_file_comment\fR() +was added in libzip 0.7. +In libzip 0.10 the type of +\fIindex\fR +was changed from +\fIint\fR +to +\fIzip_uint64_t\fR. +It was deprecated in libzip 0.11, use +\fBzip_file_get_comment\fR() +instead. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_get_file_comment.mdoc b/thirdparty/libzip-1.11.3/man/zip_get_file_comment.mdoc new file mode 100644 index 0000000..1b9676b --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_get_file_comment.mdoc @@ -0,0 +1,73 @@ +.\" zip_get_file_comment.mdoc -- get comment for file in zip +.\" Copyright (C) 2006-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_GET_FILE_COMMENT 3 +.Os +.Sh NAME +.Nm zip_get_file_comment +.Nd get comment for file in zip (obsolete interface) +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft const char * +.Fn zip_get_file_comment "zip_t *archive" "zip_uint64_t index" "int *lenp" "int flags" +.Sh DESCRIPTION +The +.Fn zip_get_file_comment +function is the obsolete version of +.Xr zip_file_get_comment 3 . +The only differences are the types of the +.Ar lenp +and +.Ar flags +arguments. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_get_comment 3 +.Sh HISTORY +.Fn zip_get_file_comment +was added in libzip 0.7. +In libzip 0.10 the type of +.Ar index +was changed from +.Vt int +to +.Vt zip_uint64_t . +It was deprecated in libzip 0.11, use +.Fn zip_file_get_comment +instead. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_get_name.html b/thirdparty/libzip-1.11.3/man/zip_get_name.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_get_name.man b/thirdparty/libzip-1.11.3/man/zip_get_name.man new file mode 100644 index 0000000..b952e73 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_get_name.man @@ -0,0 +1,141 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_get_name.mdoc -- get name of file by index +.\" Copyright (C) 2003-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_GET_NAME" "3" "September 22, 2020" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_get_name\fR +\- get name of file by index +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIconst char *\fR +.br +.PD 0 +.HP 4n +\fBzip_get_name\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_get_name\fR() +function returns the name of the file at position +\fIindex\fR +in +\fIarchive\fR. +The name is in UTF-8 encoding unless +\fRZIP_FL_ENC_RAW\fR +was specified (see below). +.PP +If +\fIflags\fR +is set to +\fRZIP_FL_UNCHANGED\fR, +the original unchanged filename is returned. +The returned string must not be modified or freed, and becomes invalid when +\fIarchive\fR +is closed. +.PP +Additionally, the following +\fIflags\fR +are supported: +.RS 6n +.TP 21n +\fRZIP_FL_ENC_RAW\fR +Return the unmodified names as it is in the ZIP archive. +.TP 21n +\fRZIP_FL_ENC_GUESS\fR +(Default.) +Guess the encoding of the name in the ZIP archive and convert it +to UTF-8, if necessary. +(Only CP-437 and UTF-8 are recognized.) +.TP 21n +\fRZIP_FL_ENC_STRICT\fR +Follow the ZIP specification and expect CP-437 encoded names in +the ZIP archive (except if they are explicitly marked as UTF-8). +Convert it to UTF-8. +.RE +\fINote\fR: +ASCII is a subset of both CP-437 and UTF-8. +.SH "RETURN VALUES" +Upon successful completion, a pointer to the name is returned. +Otherwise, +\fRNULL\fR +and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_get_name\fR() +fails if: +.TP 19n +[\fRZIP_ER_DELETED\fR] +\fIindex\fR +refers to a file that has been deleted +(see +zip_delete(3)). +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIindex\fR +is not a valid file index in +\fIarchive\fR, +or +\fIindex\fR +points to an added file and +\fRZIP_FL_UNCHANGED\fR +is set. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.SH "SEE ALSO" +libzip(3), +zip_name_locate(3) +.SH "HISTORY" +\fBzip_get_name\fR() +was added in libzip 0.6. +In libzip 0.10 the type of +\fIindex\fR +was changed from +\fIint\fR +to +\fIzip_uint64_t\fR. +In libzip 0.11 the type of +\fIflags\fR +was changed from +\fIint\fR +to +\fIzip_flags_t\fR. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_get_name.mdoc b/thirdparty/libzip-1.11.3/man/zip_get_name.mdoc new file mode 100644 index 0000000..9b4fea6 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_get_name.mdoc @@ -0,0 +1,132 @@ +.\" zip_get_name.mdoc -- get name of file by index +.\" Copyright (C) 2003-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd September 22, 2020 +.Dt ZIP_GET_NAME 3 +.Os +.Sh NAME +.Nm zip_get_name +.Nd get name of file by index +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft const char * +.Fn zip_get_name "zip_t *archive" "zip_uint64_t index" "zip_flags_t flags" +.Sh DESCRIPTION +The +.Fn zip_get_name +function returns the name of the file at position +.Ar index +in +.Ar archive . +The name is in UTF-8 encoding unless +.Dv ZIP_FL_ENC_RAW +was specified (see below). +.Pp +If +.Ar flags +is set to +.Dv ZIP_FL_UNCHANGED , +the original unchanged filename is returned. +The returned string must not be modified or freed, and becomes invalid when +.Ar archive +is closed. +.Pp +Additionally, the following +.Ar flags +are supported: +.Bl -tag -width ZIP_FL_ENC_STRICTXX -offset indent +.It Dv ZIP_FL_ENC_RAW +Return the unmodified names as it is in the ZIP archive. +.It Dv ZIP_FL_ENC_GUESS +(Default.) +Guess the encoding of the name in the ZIP archive and convert it +to UTF-8, if necessary. +(Only CP-437 and UTF-8 are recognized.) +.It Dv ZIP_FL_ENC_STRICT +Follow the ZIP specification and expect CP-437 encoded names in +the ZIP archive (except if they are explicitly marked as UTF-8). +Convert it to UTF-8. +.El +.Em Note : +ASCII is a subset of both CP-437 and UTF-8. +.Sh RETURN VALUES +Upon successful completion, a pointer to the name is returned. +Otherwise, +.Dv NULL +and the error code in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_get_name +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_DELETED +.Ar index +refers to a file that has been deleted +(see +.Xr zip_delete 3 ) . +.It Bq Er ZIP_ER_INVAL +.Ar index +is not a valid file index in +.Ar archive , +or +.Ar index +points to an added file and +.Dv ZIP_FL_UNCHANGED +is set. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_name_locate 3 +.Sh HISTORY +.Fn zip_get_name +was added in libzip 0.6. +In libzip 0.10 the type of +.Ar index +was changed from +.Vt int +to +.Vt zip_uint64_t . +In libzip 0.11 the type of +.Ar flags +was changed from +.Vt int +to +.Vt zip_flags_t . +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_get_num_entries.html b/thirdparty/libzip-1.11.3/man/zip_get_num_entries.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_get_num_entries.man b/thirdparty/libzip-1.11.3/man/zip_get_num_entries.man new file mode 100644 index 0000000..870d3d8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_get_num_entries.man @@ -0,0 +1,93 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_get_num_entries.mdoc -- get number of files in archive +.\" Copyright (C) 2011-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_GET_NUM_ENTRIES" "3" "August 19, 2022" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_get_num_entries\fR +\- get number of entries in archive +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_get_num_entries\fR(\fIzip_t\ *archive\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_get_num_entries\fR() +function returns the number of entries in +\fIarchive\fR. +Entries are all files that are present in the original archive or that +were added while the archive is open. +This includes deleted files, since +indices are not renumbered until the archive is closed. +(This allows one to refer to deleted files, e. g. to undelete them.) +.PP +If +\fIflags\fR +is set to +\fRZIP_FL_UNCHANGED\fR, +the original number of files is returned. +.SH "RETURN VALUES" +\fBzip_get_num_entries\fR() +returns the number of entries in the zip archive, +or \-1 if +\fIarchive\fR +is +\fRNULL\fR. +.SH "SEE ALSO" +libzip(3), +zip_fopen_index(3), +zip_stat_index(3) +.SH "HISTORY" +\fBzip_get_num_entries\fR() +was added in libzip 0.10. +In libzip 0.11 the return type was changed from +\fIzip_uint64_t\fR +to +\fIzip_int64_t\fR. +In libzip 0.11 the type of +\fIflags\fR +was changed from +\fIint\fR +to +\fIzip_flags_t\fR. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_get_num_entries.mdoc b/thirdparty/libzip-1.11.3/man/zip_get_num_entries.mdoc new file mode 100644 index 0000000..1bc6072 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_get_num_entries.mdoc @@ -0,0 +1,88 @@ +.\" zip_get_num_entries.mdoc -- get number of files in archive +.\" Copyright (C) 2011-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd August 19, 2022 +.Dt ZIP_GET_NUM_ENTRIES 3 +.Os +.Sh NAME +.Nm zip_get_num_entries +.Nd get number of entries in archive +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_get_num_entries "zip_t *archive" "zip_flags_t flags" +.Sh DESCRIPTION +The +.Fn zip_get_num_entries +function returns the number of entries in +.Ar archive . +Entries are all files that are present in the original archive or that +were added while the archive is open. +This includes deleted files, since +indices are not renumbered until the archive is closed. +(This allows one to refer to deleted files, e. g. to undelete them.) +.Pp +If +.Ar flags +is set to +.Dv ZIP_FL_UNCHANGED , +the original number of files is returned. +.Sh RETURN VALUES +.Fn zip_get_num_entries +returns the number of entries in the zip archive, +or \-1 if +.Ar archive +is +.Dv NULL . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_fopen_index 3 , +.Xr zip_stat_index 3 +.Sh HISTORY +.Fn zip_get_num_entries +was added in libzip 0.10. +In libzip 0.11 the return type was changed from +.Vt zip_uint64_t +to +.Vt zip_int64_t . +In libzip 0.11 the type of +.Ar flags +was changed from +.Vt int +to +.Vt zip_flags_t . +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_get_num_files.html b/thirdparty/libzip-1.11.3/man/zip_get_num_files.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_get_num_files.man b/thirdparty/libzip-1.11.3/man/zip_get_num_files.man new file mode 100644 index 0000000..29e0d30 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_get_num_files.man @@ -0,0 +1,80 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_get_num_files.mdoc -- get number of files in archive +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_GET_NUM_FILES" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_get_num_files\fR +\- get number of files in archive (obsolete interface) +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_get_num_files\fR(\fIzip_t\ *archive\fR); +.PD +.SH "DESCRIPTION" +\fIThis function is deprecated\fR. +\fIUse\fR +zip_get_num_entries(3) +\fIinstead\fR. +.PP +The +\fBzip_get_num_files\fR() +function returns the number of files in +\fIarchive\fR. +.SH "RETURN VALUES" +\fBzip_get_num_files\fR() +returns the number of files in the zip archive, +or \-1 if +\fIarchive\fR +is +\fRNULL\fR. +.SH "SEE ALSO" +libzip(3), +zip_fopen_index(3), +zip_stat_index(3) +.SH "HISTORY" +\fBzip_get_num_files\fR() +was added in libzip 0.6. +It was deprecated in libzip 0.11, use +\fBzip_get_num_entries\fR(\fIinstead\fR) +instead. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_get_num_files.mdoc b/thirdparty/libzip-1.11.3/man/zip_get_num_files.mdoc new file mode 100644 index 0000000..b18c06d --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_get_num_files.mdoc @@ -0,0 +1,75 @@ +.\" zip_get_num_files.mdoc -- get number of files in archive +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_GET_NUM_FILES 3 +.Os +.Sh NAME +.Nm zip_get_num_files +.Nd get number of files in archive (obsolete interface) +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_get_num_files "zip_t *archive" +.Sh DESCRIPTION +.Em This function is deprecated . +.Em Use +.Xr zip_get_num_entries 3 +.Em instead . +.Pp +The +.Fn zip_get_num_files +function returns the number of files in +.Ar archive . +.Sh RETURN VALUES +.Fn zip_get_num_files +returns the number of files in the zip archive, +or \-1 if +.Ar archive +is +.Dv NULL . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_fopen_index 3 , +.Xr zip_stat_index 3 +.Sh HISTORY +.Fn zip_get_num_files +was added in libzip 0.6. +It was deprecated in libzip 0.11, use +.Fn zip_get_num_entries instead +instead. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_libzip_version.html b/thirdparty/libzip-1.11.3/man/zip_libzip_version.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_libzip_version.man b/thirdparty/libzip-1.11.3/man/zip_libzip_version.man new file mode 100644 index 0000000..43da7db --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_libzip_version.man @@ -0,0 +1,71 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_libzip_version.mdoc -- return run-time version of library +.\" Copyright (C) 2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_LIBZIP_VERSION" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_libzip_version\fR +\- return run-time version of library +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIconst char *\fR +.br +.PD 0 +.HP 4n +\fBzip_libzip_version\fR(\fIvoid\fR); +.PD +.SH "DESCRIPTION" +\fBzip_libzip_version\fR +returns the version number of the library as string in the format +\(lq$MAJOR.$MINOR.$MICRO$SUFFIX\(rq +where +\fI$MAJOR\fR +is the major version, +\fI$MINOR\fR +the minor, +\fI$MICRO\fR +the micro, and +\fI$SUFFIX\fR +a suffix that's only set for development versions. +.SH "SEE ALSO" +libzip(3) +.SH "HISTORY" +\fBzip_libzip_version\fR() +was added in libzip 1.3.1. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_libzip_version.mdoc b/thirdparty/libzip-1.11.3/man/zip_libzip_version.mdoc new file mode 100644 index 0000000..04af461 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_libzip_version.mdoc @@ -0,0 +1,66 @@ +.\" zip_libzip_version.mdoc -- return run-time version of library +.\" Copyright (C) 2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_LIBZIP_VERSION 3 +.Os +.Sh NAME +.Nm zip_libzip_version +.Nd return run-time version of library +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft const char * +.Fn zip_libzip_version void +.Sh DESCRIPTION +.Nm +returns the version number of the library as string in the format +.Dq $MAJOR.$MINOR.$MICRO$SUFFIX +where +.Ar $MAJOR +is the major version, +.Ar $MINOR +the minor, +.Ar $MICRO +the micro, and +.Ar $SUFFIX +a suffix that's only set for development versions. +.Sh SEE ALSO +.Xr libzip 3 +.Sh HISTORY +.Fn zip_libzip_version +was added in libzip 1.3.1. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_name_locate.html b/thirdparty/libzip-1.11.3/man/zip_name_locate.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_name_locate.man b/thirdparty/libzip-1.11.3/man/zip_name_locate.man new file mode 100644 index 0000000..47c3d19 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_name_locate.man @@ -0,0 +1,161 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_name_locate.mdoc -- get index of file by name +.\" Copyright (C) 2003-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_NAME_LOCATE" "3" "March 15, 2022" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_name_locate\fR +\- get index of file by name +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_name_locate\fR(\fIzip_t\ *archive\fR, \fIconst\ char\ *fname\fR, \fIzip_flags_t\ flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_name_locate\fR() +function returns the index of the file named +\fIfname\fR +in +\fIarchive\fR. +If +\fIarchive\fR +does not contain a file with that name, \-1 is returned. +.PP +If neither +\fRZIP_FL_ENC_RAW\fR +nor +\fRZIP_FL_ENC_STRICT\fR +are specified, guess the encoding of the name in the ZIP archive and convert it +to UTF-8, if necessary, before comparing. +.PP +If neither +\fRZIP_FL_ENC_CP437\fR +nor +\fRZIP_FL_ENC_UTF_8\fR +are specified, guess the encoding of +\fIfname\fR. +.PP +Only CP-437 and UTF-8 are recognized. +.PP +The +\fIflags\fR +are specified by +\fIor\fR'ing +the following values, or 0 for none of them. +.RS 6n +.TP 19n +\fRZIP_FL_NOCASE\fR +Ignore case distinctions. +(Will only work well if the file names are ASCII.) +With this flag, +\fBzip_name_locate\fR() +will be slow for archives with many files. +.TP 19n +\fRZIP_FL_NODIR\fR +Ignore directory part of file name in archive. +With this flag, +\fBzip_name_locate\fR() +will be slow for archives with many files. +.TP 19n +\fRZIP_FL_ENC_GUESS\fR +This flag has no effect (its value is 0); it can be used to explicitly denote the absence of encoding flags. +.TP 19n +\fRZIP_FL_ENC_RAW\fR +Compare +\fIfname\fR +against the unmodified names as they are in the ZIP archive, without converting them to UTF-8. +.TP 19n +\fRZIP_FL_ENC_STRICT\fR +Follow the ZIP specification and expect CP-437 encoded names in +the ZIP archive (except if they are explicitly marked as UTF-8). +Convert them to UTF-8 before comparing. +.TP 19n +\fRZIP_FL_ENC_CP437\fR +\fIfname\fR +is encoded as CP-437. +.TP 19n +\fRZIP_FL_ENC_UTF_8\fR +\fIfname\fR +is encoded as UTF-8. +.RE +.PP +\fINote\fR: +ASCII is a subset of both CP-437 and UTF-8. +.SH "RETURN VALUES" +\fBzip_name_locate\fR() +returns the index of the file named +\fIfname\fR +or \-1, if +\fIarchive\fR +does not contain an entry of that name. +.SH "ERRORS" +\fBzip_name_locate\fR() +fails if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +One of the arguments is invalid. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.TP 19n +[\fRZIP_ER_NOENT\fR] +No entry of the name +\fIfname\fR +is found in the archive. +.SH "SEE ALSO" +libzip(3), +zip_get_name(3) +.SH "HISTORY" +\fBzip_name_locate\fR() +was added in libzip 0.6. +In libzip 0.11 the return type was changed from +\fIint\fR +to +\fIzip_int64_t\fR. +In libzip 0.11 the type of +\fIflags\fR +was changed from +\fIint\fR +to +\fIzip_flags_t\fR. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_name_locate.mdoc b/thirdparty/libzip-1.11.3/man/zip_name_locate.mdoc new file mode 100644 index 0000000..612c2a6 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_name_locate.mdoc @@ -0,0 +1,148 @@ +.\" zip_name_locate.mdoc -- get index of file by name +.\" Copyright (C) 2003-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd March 15, 2022 +.Dt ZIP_NAME_LOCATE 3 +.Os +.Sh NAME +.Nm zip_name_locate +.Nd get index of file by name +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_name_locate "zip_t *archive" "const char *fname" "zip_flags_t flags" +.Sh DESCRIPTION +The +.Fn zip_name_locate +function returns the index of the file named +.Ar fname +in +.Ar archive . +If +.Ar archive +does not contain a file with that name, \-1 is returned. +.Pp +If neither +.Dv ZIP_FL_ENC_RAW +nor +.Dv ZIP_FL_ENC_STRICT +are specified, guess the encoding of the name in the ZIP archive and convert it +to UTF-8, if necessary, before comparing. +.Pp +If neither +.Dv ZIP_FL_ENC_CP437 +nor +.Dv ZIP_FL_ENC_UTF_8 +are specified, guess the encoding of +.Ar fname . +.Pp +Only CP-437 and UTF-8 are recognized. +.Pp +The +.Fa flags +are specified by +.Em or Ns No 'ing +the following values, or 0 for none of them. +.Bl -tag -offset indent -width ZIP_FL_ENC_STRICT +.It Dv ZIP_FL_NOCASE +Ignore case distinctions. +(Will only work well if the file names are ASCII.) +With this flag, +.Fn zip_name_locate +will be slow for archives with many files. +.It Dv ZIP_FL_NODIR +Ignore directory part of file name in archive. +With this flag, +.Fn zip_name_locate +will be slow for archives with many files. +.It Dv ZIP_FL_ENC_GUESS +This flag has no effect (its value is 0); it can be used to explicitly denote the absence of encoding flags. +.It Dv ZIP_FL_ENC_RAW +Compare +.Ar fname +against the unmodified names as they are in the ZIP archive, without converting them to UTF-8. +.It Dv ZIP_FL_ENC_STRICT +Follow the ZIP specification and expect CP-437 encoded names in +the ZIP archive (except if they are explicitly marked as UTF-8). +Convert them to UTF-8 before comparing. +.It Dv ZIP_FL_ENC_CP437 +.Ar fname +is encoded as CP-437. +.It Dv ZIP_FL_ENC_UTF_8 +.Ar fname +is encoded as UTF-8. +.El +.Pp +.Em Note : +ASCII is a subset of both CP-437 and UTF-8. +.Sh RETURN VALUES +.Fn zip_name_locate +returns the index of the file named +.Ar fname +or \-1, if +.Ar archive +does not contain an entry of that name. +.Sh ERRORS +.Fn zip_name_locate +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +One of the arguments is invalid. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.It Bq Er ZIP_ER_NOENT +No entry of the name +.Ar fname +is found in the archive. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_get_name 3 +.Sh HISTORY +.Fn zip_name_locate +was added in libzip 0.6. +In libzip 0.11 the return type was changed from +.Vt int +to +.Vt zip_int64_t . +In libzip 0.11 the type of +.Ar flags +was changed from +.Vt int +to +.Vt zip_flags_t . +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_open.html b/thirdparty/libzip-1.11.3/man/zip_open.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_open.man b/thirdparty/libzip-1.11.3/man/zip_open.man new file mode 100644 index 0000000..3c4dc68 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_open.man @@ -0,0 +1,220 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_open.mdoc -- open zip archive +.\" Copyright (C) 2003-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_OPEN" "3" "October 9, 2022" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_open\fR, +\fBzip_open_from_source\fR +\- open zip archive +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_open\fR(\fIconst\ char\ *path\fR, \fIint\ flags\fR, \fIint\ *errorp\fR); +.PD +.PP +\fIzip_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_open_from_source\fR(\fIzip_source_t\ *zs\fR, \fIint\ flags\fR, \fIzip_error_t\ *ze\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_open\fR() +function opens the zip archive specified by +\fIpath\fR +and returns a pointer to a +\fIstruct zip\fR, +used to manipulate the archive. +The +\fIflags\fR +are specified by +\fIor\fR'ing +the following values, or 0 for none of them. +.RS 6n +.TP 15n +\fRZIP_CHECKCONS\fR +Perform additional stricter consistency checks on the archive, and +error if they fail. +.TP 15n +\fRZIP_CREATE\fR +Create the archive if it does not exist. +.TP 15n +\fRZIP_EXCL\fR +Error if archive already exists. +.TP 15n +\fRZIP_TRUNCATE\fR +If archive exists, ignore its current contents. +In other words, handle it the same way as an empty archive. +.TP 15n +\fRZIP_RDONLY\fR +Open archive in read-only mode. +.RE +.PP +If an error occurs and +\fIerrorp\fR +is +non-\fRNULL\fR, +it will be set to the corresponding error code. +.PP +The +\fBzip_open_from_source\fR() +function opens a zip archive encapsulated by the zip_source +\fIzs\fR +using the provided +\fIflags\fR. +In case of error, the zip_error +\fIze\fR +is filled in. +.SH "RETURN VALUES" +Upon successful completion +\fBzip_open\fR() +and +\fBzip_open_from_source\fR() +return a +\fIstruct zip\fR +pointer. +Otherwise, +\fRNULL\fR +is returned and +\fBzip_open\fR() +sets +\fI*errorp\fR +to indicate the error, while +\fBzip_open_from\fR(\fIsource\fR) +sets +\fIze\fR +to indicate the error. +.SH "EXAMPLES" +Here's an example of how you could report errors during +\fBzip_open\fR: +.nf +.sp +.RS 0n + zip_t *za; + int err; + + if ((za = zip_open(name, 0, &err)) == NULL) { + zip_error_t error; + zip_error_init_with_code(&error, err); + fprintf(stderr, "%s: cannot open zip archive '%s': %s\en", + progname, name, zip_error_strerror(&error)); + zip_error_fini(&error); + return -1; + } +.RE +.fi +.SH "ERRORS" +The archive specified by +\fIpath\fR +is opened unless: +.TP 19n +[\fRZIP_ER_EXISTS\fR] +The file specified by +\fIpath\fR +exists and +\fRZIP_EXCL\fR +is set. +.TP 19n +[\fRZIP_ER_INCONS\fR] +Inconsistencies were found in the file specified by +\fIpath\fR. +This error is often caused by specifying +\fRZIP_CHECKCONS\fR +but can also happen without it. +.TP 19n +[\fRZIP_ER_INVAL\fR] +The +\fIpath\fR +argument is +\fRNULL\fR. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.TP 19n +[\fRZIP_ER_NOENT\fR] +The file specified by +\fIpath\fR +does not exist and +\fRZIP_CREATE\fR +is not set. +.TP 19n +[\fRZIP_ER_NOZIP\fR] +The file specified by +\fIpath\fR +is not a zip archive. +.TP 19n +[\fRZIP_ER_OPEN\fR] +The file specified by +\fIpath\fR +could not be opened. +.TP 19n +[\fRZIP_ER_READ\fR] +A read error occurred; see +\fIerrno\fR +for details. +.TP 19n +[\fRZIP_ER_SEEK\fR] +The file specified by +\fIpath\fR +does not allow seeks. +.PD 0 +.PP +For newly created archives, +\fBzip_open\fR() +does not try to create the file; this is done when calling +zip_close(3) +and any errors, like missing write permissions, will +be reported then. +.PD +.SH "SEE ALSO" +libzip(3), +zip_close(3), +zip_error_strerror(3), +zip_fdopen(3) +.SH "HISTORY" +\fBzip_open\fR() +and +\fBzip_open_from_source\fR() +were added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_open.mdoc b/thirdparty/libzip-1.11.3/man/zip_open.mdoc new file mode 100644 index 0000000..5a8357a --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_open.mdoc @@ -0,0 +1,192 @@ +.\" zip_open.mdoc -- open zip archive +.\" Copyright (C) 2003-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd October 9, 2022 +.Dt ZIP_OPEN 3 +.Os +.Sh NAME +.Nm zip_open , +.Nm zip_open_from_source +.Nd open zip archive +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_t * +.Fn zip_open "const char *path" "int flags" "int *errorp" +.Ft zip_t * +.Fn zip_open_from_source "zip_source_t *zs" "int flags" "zip_error_t *ze" +.Sh DESCRIPTION +The +.Fn zip_open +function opens the zip archive specified by +.Ar path +and returns a pointer to a +.Ft struct zip , +used to manipulate the archive. +The +.Fa flags +are specified by +.Em or Ns No 'ing +the following values, or 0 for none of them. +.Bl -tag -offset indent -width ZIP_CHECKCONS +.It Dv ZIP_CHECKCONS +Perform additional stricter consistency checks on the archive, and +error if they fail. +.It Dv ZIP_CREATE +Create the archive if it does not exist. +.It Dv ZIP_EXCL +Error if archive already exists. +.It Dv ZIP_TRUNCATE +If archive exists, ignore its current contents. +In other words, handle it the same way as an empty archive. +.It Dv ZIP_RDONLY +Open archive in read-only mode. +.El +.Pp +If an error occurs and +.Ar errorp +is +.Pf non- Dv NULL , +it will be set to the corresponding error code. +.Pp +The +.Fn zip_open_from_source +function opens a zip archive encapsulated by the zip_source +.Fa zs +using the provided +.Fa flags . +In case of error, the zip_error +.Fa ze +is filled in. +.Sh RETURN VALUES +Upon successful completion +.Fn zip_open +and +.Fn zip_open_from_source +return a +.Ft struct zip +pointer. +Otherwise, +.Dv NULL +is returned and +.Fn zip_open +sets +.Ar *errorp +to indicate the error, while +.Fn zip_open_from source +sets +.Ar ze +to indicate the error. +.Sh EXAMPLES +Here's an example of how you could report errors during +.Nm : +.Bd -literal + zip_t *za; + int err; + + if ((za = zip_open(name, 0, &err)) == NULL) { + zip_error_t error; + zip_error_init_with_code(&error, err); + fprintf(stderr, "%s: cannot open zip archive '%s': %s\en", + progname, name, zip_error_strerror(&error)); + zip_error_fini(&error); + return -1; + } +.Ed +.Sh ERRORS +The archive specified by +.Ar path +is opened unless: +.Bl -tag -width Er +.It Bq Er ZIP_ER_EXISTS +The file specified by +.Ar path +exists and +.Dv ZIP_EXCL +is set. +.It Bq Er ZIP_ER_INCONS +Inconsistencies were found in the file specified by +.Ar path . +This error is often caused by specifying +.Dv ZIP_CHECKCONS +but can also happen without it. +.It Bq Er ZIP_ER_INVAL +The +.Ar path +argument is +.Dv NULL . +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.It Bq Er ZIP_ER_NOENT +The file specified by +.Ar path +does not exist and +.Dv ZIP_CREATE +is not set. +.It Bq Er ZIP_ER_NOZIP +The file specified by +.Ar path +is not a zip archive. +.It Bq Er ZIP_ER_OPEN +The file specified by +.Ar path +could not be opened. +.It Bq Er ZIP_ER_READ +A read error occurred; see +.Va errno +for details. +.It Bq Er ZIP_ER_SEEK +The file specified by +.Ar path +does not allow seeks. +.El +For newly created archives, +.Fn zip_open +does not try to create the file; this is done when calling +.Xr zip_close 3 +and any errors, like missing write permissions, will +be reported then. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_close 3 , +.Xr zip_error_strerror 3 , +.Xr zip_fdopen 3 +.Sh HISTORY +.Fn zip_open +and +.Fn zip_open_from_source +were added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_register_cancel_callback_with_state.html b/thirdparty/libzip-1.11.3/man/zip_register_cancel_callback_with_state.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_register_cancel_callback_with_state.man b/thirdparty/libzip-1.11.3/man/zip_register_cancel_callback_with_state.man new file mode 100644 index 0000000..33527b8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_register_cancel_callback_with_state.man @@ -0,0 +1,90 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_register_cancel_callback_with_state.mdoc -- allow cancelling during zip_close +.\" Copyright (C) 2021-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_REGISTER_CANCEL_CALLBACK_WITH_STATE" "3" "June 18, 2022" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_register_cancel_callback_with_state\fR +\- allow cancelling during zip_close +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fItypedef int (*zip_cancel_callback)(zip_t *, void *);\fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_register_cancel_callback_with_state\fR(\fIzip_t\ *archive\fR, \fIzip_cancel_callback\ callback\fR, \fIvoid\ (*ud_free)(void\ *)\fR, \fIvoid\ *ud\fR); +.PD +.SH "DESCRIPTION" +This function can be used to cancel writing of a zip archive during +zip_close(3). +.PP +The +\fBzip_register_cancel_callback_with_state\fR() +function registers a callback function +\fIcallback\fR +for the zip archive +\fIarchive\fR. +The +\fIud_free\fR +function is called during cleanup for deleting the userdata supplied in +\fIud\fR. +.PP +The callback function is called during +zip_close(3) +in regular intervals (after every zip archive entry that's completely +written to disk, and while writing data for entries) with zip archive +\fIarchive\fR +and the user-provided user-data +\fIud\fR +as arguments. +When the callback function returns a non-zero value, writing is cancelled and +zip_close(3) +returns an error. +.PP +The callback function should be fast, since it will be called often. +.SH "SEE ALSO" +libzip(3), +zip_close(3), +zip_register_progress_callback_with_state(3) +.SH "HISTORY" +\fBzip_register_cancel_callback_with_state\fR() +was added in libzip 1.6.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_register_cancel_callback_with_state.mdoc b/thirdparty/libzip-1.11.3/man/zip_register_cancel_callback_with_state.mdoc new file mode 100644 index 0000000..59705ae --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_register_cancel_callback_with_state.mdoc @@ -0,0 +1,84 @@ +.\" zip_register_cancel_callback_with_state.mdoc -- allow cancelling during zip_close +.\" Copyright (C) 2021-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd June 18, 2022 +.Dt ZIP_REGISTER_CANCEL_CALLBACK_WITH_STATE 3 +.Os +.Sh NAME +.Nm zip_register_cancel_callback_with_state +.Nd allow cancelling during zip_close +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Vt typedef int (*zip_cancel_callback)(zip_t *, void *); +.Ft void +.Fn zip_register_cancel_callback_with_state "zip_t *archive" "zip_cancel_callback callback" "void (*ud_free)(void *)" "void *ud" +.Sh DESCRIPTION +This function can be used to cancel writing of a zip archive during +.Xr zip_close 3 . +.Pp +The +.Fn zip_register_cancel_callback_with_state +function registers a callback function +.Ar callback +for the zip archive +.Ar archive . +The +.Ar ud_free +function is called during cleanup for deleting the userdata supplied in +.Ar ud . +.Pp +The callback function is called during +.Xr zip_close 3 +in regular intervals (after every zip archive entry that's completely +written to disk, and while writing data for entries) with zip archive +.Ar archive +and the user-provided user-data +.Ar ud +as arguments. +When the callback function returns a non-zero value, writing is cancelled and +.Xr zip_close 3 +returns an error. +.Pp +The callback function should be fast, since it will be called often. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_close 3 , +.Xr zip_register_progress_callback_with_state 3 +.Sh HISTORY +.Fn zip_register_cancel_callback_with_state +was added in libzip 1.6.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_register_progress_callback.html b/thirdparty/libzip-1.11.3/man/zip_register_progress_callback.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_register_progress_callback.man b/thirdparty/libzip-1.11.3/man/zip_register_progress_callback.man new file mode 100644 index 0000000..5ec18a4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_register_progress_callback.man @@ -0,0 +1,83 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_register_progress_callback.mdoc -- provide updates during zip_close +.\" Copyright (C) 2016-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_REGISTER_PROGRESS_CALLBACK" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_register_progress_callback\fR +\- provide updates during zip_close (obsolete interface) +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fItypedef void (*zip_progress_callback_t)(double);\fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_register_progress_callback\fR(\fIzip_t\ *archive\fR, \fIzip_progress_callback_t\ progress_callback\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_register_progress_callback\fR() +is the obsolete version of +zip_register_progress_callback_with_state(3). +.PP +The +\fBzip_register_progress_callback\fR() +function registers a callback function +\fIprogress_callback\fR +for the zip archive +\fIarchive\fR. +This function is called during +zip_close(3) +after every zip archive entry that's completely written to disk. +The value is a +\fIdouble\fR +in the range from 0.0 to 1.0. +This can be used to provide progress indicators for user interfaces. +.SH "SEE ALSO" +libzip(3), +zip_close(3) +.SH "HISTORY" +\fBzip_register_progress_callback\fR() +was added in libzip 1.2.0. +It was deprecated in libzip 1.3.0, use +\fBzip_register_progress_callback_with_state\fR() +instead. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_register_progress_callback.mdoc b/thirdparty/libzip-1.11.3/man/zip_register_progress_callback.mdoc new file mode 100644 index 0000000..69cc4f5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_register_progress_callback.mdoc @@ -0,0 +1,77 @@ +.\" zip_register_progress_callback.mdoc -- provide updates during zip_close +.\" Copyright (C) 2016-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_REGISTER_PROGRESS_CALLBACK 3 +.Os +.Sh NAME +.Nm zip_register_progress_callback +.Nd provide updates during zip_close (obsolete interface) +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Vt typedef void (*zip_progress_callback_t)(double); +.Ft void +.Fn zip_register_progress_callback "zip_t *archive" "zip_progress_callback_t progress_callback" +.Sh DESCRIPTION +The function +.Fn zip_register_progress_callback +is the obsolete version of +.Xr zip_register_progress_callback_with_state 3 . +.Pp +The +.Fn zip_register_progress_callback +function registers a callback function +.Ar progress_callback +for the zip archive +.Ar archive . +This function is called during +.Xr zip_close 3 +after every zip archive entry that's completely written to disk. +The value is a +.Vt double +in the range from 0.0 to 1.0. +This can be used to provide progress indicators for user interfaces. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_close 3 +.Sh HISTORY +.Fn zip_register_progress_callback +was added in libzip 1.2.0. +It was deprecated in libzip 1.3.0, use +.Fn zip_register_progress_callback_with_state +instead. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_register_progress_callback_with_state.html b/thirdparty/libzip-1.11.3/man/zip_register_progress_callback_with_state.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_register_progress_callback_with_state.man b/thirdparty/libzip-1.11.3/man/zip_register_progress_callback_with_state.man new file mode 100644 index 0000000..87f62ec --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_register_progress_callback_with_state.man @@ -0,0 +1,93 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_register_progress_callback_with_state.mdoc -- provide updates during zip_close +.\" Copyright (C) 2017-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_REGISTER_PROGRESS_CALLBACK_WITH_STATE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_register_progress_callback_with_state\fR +\- provide updates during zip_close +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fItypedef void (*zip_progress_callback)(zip_t *, double, void *);\fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_register_progress_callback_with_state\fR(\fIzip_t\ *archive\fR, \fIdouble\ precision\fR, \fIzip_progress_callback\ callback\fR, \fIvoid\ (*ud_free)(void\ *)\fR, \fIvoid\ *ud\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_register_progress_callback_with_state\fR() +function registers a callback function +\fIcallback\fR +for the zip archive +\fIarchive\fR. +The +\fIprecision\fR +argument is a double in the range from 0.00 to 1.0 that defines the +smallest change for which the callback should be called (to avoid too +frequent calls). +The +\fIud_free\fR +function is called during cleanup for deleting the userdata supplied in +\fIud\fR. +.PP +The callback function is called during +zip_close(3) +in regular intervals (after every zip archive entry that's completely +written to disk, and while writing data for entries) with zip archive +\fIarchive\fR, +the current progression state as a +\fIdouble\fR, +and the user-provided user-data +\fIud\fR +as arguments. +The progression state is a +\fIdouble\fR +in the range from 0.0 to 1.0. +This can be used to provide progress indicators for user interfaces. +.SH "SEE ALSO" +libzip(3), +zip_close(3), +zip_register_cancel_callback_with_state(3) +.SH "HISTORY" +\fBzip_register_progress_callback_with_state\fR() +was added in libzip 1.3.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_register_progress_callback_with_state.mdoc b/thirdparty/libzip-1.11.3/man/zip_register_progress_callback_with_state.mdoc new file mode 100644 index 0000000..4ee88e6 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_register_progress_callback_with_state.mdoc @@ -0,0 +1,87 @@ +.\" zip_register_progress_callback_with_state.mdoc -- provide updates during zip_close +.\" Copyright (C) 2017-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_REGISTER_PROGRESS_CALLBACK_WITH_STATE 3 +.Os +.Sh NAME +.Nm zip_register_progress_callback_with_state +.Nd provide updates during zip_close +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Vt typedef void (*zip_progress_callback)(zip_t *, double, void *); +.Ft void +.Fn zip_register_progress_callback_with_state "zip_t *archive" "double precision" "zip_progress_callback callback" "void (*ud_free)(void *)" "void *ud" +.Sh DESCRIPTION +The +.Fn zip_register_progress_callback_with_state +function registers a callback function +.Ar callback +for the zip archive +.Ar archive . +The +.Ar precision +argument is a double in the range from 0.00 to 1.0 that defines the +smallest change for which the callback should be called (to avoid too +frequent calls). +The +.Ar ud_free +function is called during cleanup for deleting the userdata supplied in +.Ar ud . +.Pp +The callback function is called during +.Xr zip_close 3 +in regular intervals (after every zip archive entry that's completely +written to disk, and while writing data for entries) with zip archive +.Ar archive , +the current progression state as a +.Vt double , +and the user-provided user-data +.Ar ud +as arguments. +The progression state is a +.Vt double +in the range from 0.0 to 1.0. +This can be used to provide progress indicators for user interfaces. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_close 3 , +.Xr zip_register_cancel_callback_with_state 3 +.Sh HISTORY +.Fn zip_register_progress_callback_with_state +was added in libzip 1.3.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_rename.html b/thirdparty/libzip-1.11.3/man/zip_rename.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_rename.man b/thirdparty/libzip-1.11.3/man/zip_rename.man new file mode 100644 index 0000000..d71f1a0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_rename.man @@ -0,0 +1,75 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_rename.mdoc -- rename file in zip archive +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_RENAME" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_rename\fR +\- rename file in zip archive (obsolete interface) +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_rename\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIconst\ char\ *name\fR); +.PD +.SH "DESCRIPTION" +\fBzip_rename\fR() +is the obsolete version of +zip_file_rename(3). +It is the same as calling +zip_file_rename(3) +with an empty flags argument. +.SH "SEE ALSO" +libzip(3), +zip_file_rename(3) +.SH "HISTORY" +\fBzip_rename\fR() +was added in libzip 0.6. +In libzip 0.10 the type of +\fIindex\fR +was changed from +\fIint\fR +to +\fIzip_uint64_t\fR. +It was deprecated in libzip 0.11, use +\fBzip_file_rename\fR() +instead. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_rename.mdoc b/thirdparty/libzip-1.11.3/man/zip_rename.mdoc new file mode 100644 index 0000000..5a53880 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_rename.mdoc @@ -0,0 +1,70 @@ +.\" zip_rename.mdoc -- rename file in zip archive +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_RENAME 3 +.Os +.Sh NAME +.Nm zip_rename +.Nd rename file in zip archive (obsolete interface) +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_rename "zip_t *archive" "zip_uint64_t index" "const char *name" +.Sh DESCRIPTION +.Fn zip_rename +is the obsolete version of +.Xr zip_file_rename 3 . +It is the same as calling +.Xr zip_file_rename 3 +with an empty flags argument. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_rename 3 +.Sh HISTORY +.Fn zip_rename +was added in libzip 0.6. +In libzip 0.10 the type of +.Ar index +was changed from +.Vt int +to +.Vt zip_uint64_t . +It was deprecated in libzip 0.11, use +.Fn zip_file_rename +instead. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_set_archive_comment.html b/thirdparty/libzip-1.11.3/man/zip_set_archive_comment.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_set_archive_comment.man b/thirdparty/libzip-1.11.3/man/zip_set_archive_comment.man new file mode 100644 index 0000000..666aec0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_set_archive_comment.man @@ -0,0 +1,98 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_set_archive_comment.mdoc -- set zip archive comment +.\" Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SET_ARCHIVE_COMMENT" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_set_archive_comment\fR +\- set zip archive comment +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_set_archive_comment\fR(\fIzip_t\ *archive\fR, \fIconst\ char\ *comment\fR, \fIzip_uint16_t\ len\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_set_archive_comment\fR() +function sets the comment for the entire zip archive. +If +\fIcomment\fR +is +\fRNULL\fR +and +\fIlen\fR +is 0, the archive comment will be removed. +\fIcomment\fR +must be encoded in ASCII or UTF-8. +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_set_archive_comment\fR() +fails if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIlen\fR +is less than 0 or longer than the maximum comment length in a zip file +(65535), or +\fIcomment\fR +is not a valid UTF-8 encoded string. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.SH "SEE ALSO" +libzip(3), +zip_file_get_comment(3), +zip_file_set_comment(3), +zip_get_archive_comment(3) +.SH "HISTORY" +\fBzip_set_archive_comment\fR() +was added in libzip 0.7. +In libzip 0.11 the type of +\fIlen\fR +was changed from +\fIint\fR +to +\fIzip_uint16_t\fR. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_set_archive_comment.mdoc b/thirdparty/libzip-1.11.3/man/zip_set_archive_comment.mdoc new file mode 100644 index 0000000..a6aaea1 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_set_archive_comment.mdoc @@ -0,0 +1,93 @@ +.\" zip_set_archive_comment.mdoc -- set zip archive comment +.\" Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SET_ARCHIVE_COMMENT 3 +.Os +.Sh NAME +.Nm zip_set_archive_comment +.Nd set zip archive comment +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_set_archive_comment "zip_t *archive" "const char *comment" "zip_uint16_t len" +.Sh DESCRIPTION +The +.Fn zip_set_archive_comment +function sets the comment for the entire zip archive. +If +.Ar comment +is +.Dv NULL +and +.Ar len +is 0, the archive comment will be removed. +.Ar comment +must be encoded in ASCII or UTF-8. +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_set_archive_comment +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar len +is less than 0 or longer than the maximum comment length in a zip file +(65535), or +.Ar comment +is not a valid UTF-8 encoded string. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_get_comment 3 , +.Xr zip_file_set_comment 3 , +.Xr zip_get_archive_comment 3 +.Sh HISTORY +.Fn zip_set_archive_comment +was added in libzip 0.7. +In libzip 0.11 the type of +.Ar len +was changed from +.Vt int +to +.Vt zip_uint16_t . +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_set_archive_flag.html b/thirdparty/libzip-1.11.3/man/zip_set_archive_flag.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_set_archive_flag.man b/thirdparty/libzip-1.11.3/man/zip_set_archive_flag.man new file mode 100644 index 0000000..713d92c --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_set_archive_flag.man @@ -0,0 +1,96 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_set_archive_flag.mdoc -- set zip archive flag +.\" Copyright (C) 2008-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SET_ARCHIVE_FLAG" "3" "July 19, 2023" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_set_archive_flag\fR +\- set zip archive flag +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_set_archive_flag\fR(\fIzip_t\ *archive\fR, \fIzip_flags_t\ flag\fR, \fIint\ value\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_set_archive_flag\fR() +function sets the flag +\fIflag\fR +for the archive +\fIarchive\fR +to the value +\fIvalue\fR. +.PP +Supported flags are: +.TP 20n +\fRZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE\fR +If this flag is cleared, the archive file will be removed if the archive is empty. +If it is set, an empty archive will be created, which is not recommended by the zip specification. +.TP 20n +\fRZIP_AFL_RDONLY\fR +If this flag is set, no modification to the archive are allowed. +This flag can only be cleared if it was manually set with +\fBzip_set_archive_flag\fR, +not if the archive was opened read-only. +.TP 20n +\fRZIP_AFL_WANT_TORRENTZIP\fR +If this flag is set, the archive will be written in torrentzip format. +.SH "RETURN VALUES" +Upon successful completion 0 is returned, and \-1 if an error +occurred. +.SH "SEE ALSO" +libzip(3), +zip_get_archive_flag(3) +.SH "HISTORY" +\fBzip_set_archive_flag\fR() +was added in libzip 0.9. +In libzip 0.11 the type of +\fIflag\fR +was changed from +\fIint\fR +to +\fIzip_flags_t\fR. +\fRZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE\fR +and +\fRZIP_AFL_WANT_TORRENTZIP\fR +were added in libzip 1.10.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_set_archive_flag.mdoc b/thirdparty/libzip-1.11.3/man/zip_set_archive_flag.mdoc new file mode 100644 index 0000000..ee0a246 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_set_archive_flag.mdoc @@ -0,0 +1,90 @@ +.\" zip_set_archive_flag.mdoc -- set zip archive flag +.\" Copyright (C) 2008-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd July 19, 2023 +.Dt ZIP_SET_ARCHIVE_FLAG 3 +.Os +.Sh NAME +.Nm zip_set_archive_flag +.Nd set zip archive flag +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_set_archive_flag "zip_t *archive" "zip_flags_t flag" "int value" +.Sh DESCRIPTION +The +.Fn zip_set_archive_flag +function sets the flag +.Ar flag +for the archive +.Ar archive +to the value +.Ar value . +.Pp +Supported flags are: +.Bl -tag -width XZIPXAFLXRDONLYXXX +.It Dv ZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE +If this flag is cleared, the archive file will be removed if the archive is empty. +If it is set, an empty archive will be created, which is not recommended by the zip specification. +.It Dv ZIP_AFL_RDONLY +If this flag is set, no modification to the archive are allowed. +This flag can only be cleared if it was manually set with +.Nm , +not if the archive was opened read-only. +.It Dv ZIP_AFL_WANT_TORRENTZIP +If this flag is set, the archive will be written in torrentzip format. +.El +.Sh RETURN VALUES +Upon successful completion 0 is returned, and \-1 if an error +occurred. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_get_archive_flag 3 +.Sh HISTORY +.Fn zip_set_archive_flag +was added in libzip 0.9. +In libzip 0.11 the type of +.Ar flag +was changed from +.Vt int +to +.Vt zip_flags_t . +.Dv ZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE +and +.Dv ZIP_AFL_WANT_TORRENTZIP +were added in libzip 1.10.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_set_default_password.html b/thirdparty/libzip-1.11.3/man/zip_set_default_password.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_set_default_password.man b/thirdparty/libzip-1.11.3/man/zip_set_default_password.man new file mode 100644 index 0000000..9fa8f23 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_set_default_password.man @@ -0,0 +1,94 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_set_default_password.mdoc -- set default password for zip +.\" Copyright (C) 2011-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SET_DEFAULT_PASSWORD" "3" "September 15, 2020" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_set_default_password\fR +\- set default password for encrypted files in zip +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_set_default_password\fR(\fIzip_t\ *archive\fR, \fIconst\ char\ *password\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_set_default_password\fR() +function sets the default password used when accessing encrypted files. +If +\fIpassword\fR +is +\fRNULL\fR +or the empty string, the default password is unset. +.PP +If you prefer a different password for single files, use +zip_fopen_encrypted(3) +instead of +zip_fopen(3). +Usually, however, the same password is used for every file in an +zip archive. +.PP +The password is not verified when calling this function. +See the +\fICAVEATS\fR +section in +zip_fopen_encrypted(3) +for more details about password handling. +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_set_default_password\fR() +fails if: +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.SH "SEE ALSO" +libzip(3), +zip_fopen(3), +zip_fopen_encrypted(3) +.SH "HISTORY" +\fBzip_set_default_password\fR() +was added in libzip 0.10. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_set_default_password.mdoc b/thirdparty/libzip-1.11.3/man/zip_set_default_password.mdoc new file mode 100644 index 0000000..f2574ca --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_set_default_password.mdoc @@ -0,0 +1,90 @@ +.\" zip_set_default_password.mdoc -- set default password for zip +.\" Copyright (C) 2011-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd September 15, 2020 +.Dt ZIP_SET_DEFAULT_PASSWORD 3 +.Os +.Sh NAME +.Nm zip_set_default_password +.Nd set default password for encrypted files in zip +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_set_default_password "zip_t *archive" "const char *password" +.Sh DESCRIPTION +The +.Fn zip_set_default_password +function sets the default password used when accessing encrypted files. +If +.Ar password +is +.Dv NULL +or the empty string, the default password is unset. +.Pp +If you prefer a different password for single files, use +.Xr zip_fopen_encrypted 3 +instead of +.Xr zip_fopen 3 . +Usually, however, the same password is used for every file in an +zip archive. +.Pp +The password is not verified when calling this function. +See the +.Sx CAVEATS +section in +.Xr zip_fopen_encrypted 3 +for more details about password handling. +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_set_default_password +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_fopen 3 , +.Xr zip_fopen_encrypted 3 +.Sh HISTORY +.Fn zip_set_default_password +was added in libzip 0.10. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_set_file_comment.html b/thirdparty/libzip-1.11.3/man/zip_set_file_comment.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_set_file_comment.man b/thirdparty/libzip-1.11.3/man/zip_set_file_comment.man new file mode 100644 index 0000000..7b34c5f --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_set_file_comment.man @@ -0,0 +1,84 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_set_file_comment.mdoc -- set comment for file in zip +.\" Copyright (C) 2006-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SET_FILE_COMMENT" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_set_file_comment\fR +\- set comment for file in zip (obsolete interface) +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_set_file_comment\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIconst\ char\ *comment\fR, \fIint\ len\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_set_file_comment\fR() +function is the obsolete version of +zip_file_set_comment(3). +The only differences are the type of the +\fIlen\fR +argument and the additional +\fIflags\fR +argument. +\fBzip_set_file_comment\fR() +is the same as calling +zip_file_set_comment(3) +with an empty +\fIflags\fR +argument. +.SH "SEE ALSO" +libzip(3), +zip_file_set_comment(3) +.SH "HISTORY" +\fBzip_set_file_comment\fR() +was added in libzip 0.7. +In libzip 0.10 the type of +\fIindex\fR +was changed from +\fIint\fR +to +\fIzip_uint64_t\fR. +It was deprecated in libzip 0.11, use +\fBzip_file_set_comment\fR() +instead. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_set_file_comment.mdoc b/thirdparty/libzip-1.11.3/man/zip_set_file_comment.mdoc new file mode 100644 index 0000000..242597d --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_set_file_comment.mdoc @@ -0,0 +1,79 @@ +.\" zip_set_file_comment.mdoc -- set comment for file in zip +.\" Copyright (C) 2006-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SET_FILE_COMMENT 3 +.Os +.Sh NAME +.Nm zip_set_file_comment +.Nd set comment for file in zip (obsolete interface) +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_set_file_comment "zip_t *archive" "zip_uint64_t index" "const char *comment" "int len" +.Sh DESCRIPTION +The +.Fn zip_set_file_comment +function is the obsolete version of +.Xr zip_file_set_comment 3 . +The only differences are the type of the +.Ar len +argument and the additional +.Ar flags +argument. +.Fn zip_set_file_comment +is the same as calling +.Xr zip_file_set_comment 3 +with an empty +.Ar flags +argument. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_set_comment 3 +.Sh HISTORY +.Fn zip_set_file_comment +was added in libzip 0.7. +In libzip 0.10 the type of +.Ar index +was changed from +.Vt int +to +.Vt zip_uint64_t . +It was deprecated in libzip 0.11, use +.Fn zip_file_set_comment +instead. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_set_file_compression.html b/thirdparty/libzip-1.11.3/man/zip_set_file_compression.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_set_file_compression.man b/thirdparty/libzip-1.11.3/man/zip_set_file_compression.man new file mode 100644 index 0000000..8a93eb0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_set_file_compression.man @@ -0,0 +1,156 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_set_file_compression.mdoc -- set compression method and its flags +.\" Copyright (C) 2012-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SET_FILE_COMPRESSION" "3" "February 2, 2023" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_set_file_compression\fR +\- set compression method for file in zip +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_set_file_compression\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_int32_t\ comp\fR, \fIzip_uint32_t\ comp_flags\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_set_file_compression\fR() +function sets the compression method for the file at position +\fIindex\fR +in the zip archive to +\fIcomp\fR +with the compression method specific +\fIcomp_flags\fR. +The +\fIcomp\fR +is the same as returned by +zip_stat(3). +For the +\fIcomp\fR +argument, currently only the following values are supported: +.TP 19n +\fRZIP_CM_DEFAULT\fR +default compression; currently the same as +\fRZIP_CM_DEFLATE\fR, +but +\fIflags\fR +are ignored. +.TP 19n +\fRZIP_CM_STORE\fR +Store the file uncompressed. +.TP 19n +\fRZIP_CM_BZIP2\fR +Compress the file using the +bzip2(1) +algorithm. +.TP 19n +\fRZIP_CM_DEFLATE\fR +Deflate the file with the +zlib(3) +algorithm and default options. +.TP 19n +\fRZIP_CM_XZ\fR +Use the +xz(1) +algorithm for compression +.TP 19n +\fRZIP_CM_ZSTD\fR +Use the +zstd(1) +algorithm for compression +.PP +\fINOTE\fR: +Only the deflate and store methods can be assumed to be universally +supported. +.PP +The +\fIcomp_flags\fR +argument defines the compression level. +This value is dependent on the compression algorithm. +In general, lower numbers mean faster de/compression and higher +numbers mean slower de/compression. +For +\fRZIP_CM_BZIP\fR, +\fRZIP_CM_DEFLATE\fR, +and +\fRZIP_CM_XZ\fR +1 is the fastest compression and 9 the best, 0 chooses the default. +For +\fRZIP_CM_ZSTD\fR +possible values are +ZSTD_minCLevel(3) +to +ZSTD_maxCLevel(3); negative values must be cast to +\fIzip_uint32_t\fR. +.PP +Further compression method specific flags might be added over time. +.PP +The current compression method for a file in a zip archive can be +determined using +zip_stat(3). +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_set_file_compression\fR() +fails if: +.TP 19n +[\fRZIP_ER_COMPNOTSUPP\fR] +Unsupported compression method requested. +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIindex\fR +is not a valid file index in +\fIarchive\fR, +or the argument combination is invalid. +.TP 19n +[\fRZIP_ER_RDONLY\fR] +Read-only zip file, no changes allowed. +.SH "SEE ALSO" +libzip(3), +zip_compression_method_supported(3), +zip_stat(3) +.SH "HISTORY" +\fBzip_set_file_compression\fR() +was added in libzip 0.11. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_set_file_compression.mdoc b/thirdparty/libzip-1.11.3/man/zip_set_file_compression.mdoc new file mode 100644 index 0000000..b58dcb6 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_set_file_compression.mdoc @@ -0,0 +1,146 @@ +.\" zip_set_file_compression.mdoc -- set compression method and its flags +.\" Copyright (C) 2012-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP files. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd February 2, 2023 +.Dt ZIP_SET_FILE_COMPRESSION 3 +.Os +.Sh NAME +.Nm zip_set_file_compression +.Nd set compression method for file in zip +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_set_file_compression "zip_t *archive" "zip_uint64_t index" "zip_int32_t comp" "zip_uint32_t comp_flags" +.Sh DESCRIPTION +The +.Fn zip_set_file_compression +function sets the compression method for the file at position +.Ar index +in the zip archive to +.Ar comp +with the compression method specific +.Ar comp_flags . +The +.Ar comp +is the same as returned by +.Xr zip_stat 3 . +For the +.Ar comp +argument, currently only the following values are supported: +.Bl -tag -width ZIP_CM_DEFLATE_XX +.It Dv ZIP_CM_DEFAULT +default compression; currently the same as +.Dv ZIP_CM_DEFLATE , +but +.Ar flags +are ignored. +.It Dv ZIP_CM_STORE +Store the file uncompressed. +.It Dv ZIP_CM_BZIP2 +Compress the file using the +.Xr bzip2 1 +algorithm. +.It Dv ZIP_CM_DEFLATE +Deflate the file with the +.Xr zlib 3 +algorithm and default options. +.It Dv ZIP_CM_XZ +Use the +.Xr xz 1 +algorithm for compression +.It Dv ZIP_CM_ZSTD +Use the +.Xr zstd 1 +algorithm for compression +.El +.Pp +.Em NOTE : +Only the deflate and store methods can be assumed to be universally +supported. +.Pp +The +.Ar comp_flags +argument defines the compression level. +This value is dependent on the compression algorithm. +In general, lower numbers mean faster de/compression and higher +numbers mean slower de/compression. +For +.Dv ZIP_CM_BZIP , +.Dv ZIP_CM_DEFLATE , +and +.Dv ZIP_CM_XZ +1 is the fastest compression and 9 the best, 0 chooses the default. +For +.Dv ZIP_CM_ZSTD +possible values are +.Xr ZSTD_minCLevel 3 +to +.Xr ZSTD_maxCLevel 3 ; negative values must be cast to +.Ft zip_uint32_t . +.Pp +Further compression method specific flags might be added over time. +.Pp +The current compression method for a file in a zip archive can be +determined using +.Xr zip_stat 3 . +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_set_file_compression +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_COMPNOTSUPP +Unsupported compression method requested. +.It Bq Er ZIP_ER_INVAL +.Ar index +is not a valid file index in +.Ar archive , +or the argument combination is invalid. +.It Bq Er ZIP_ER_RDONLY +Read-only zip file, no changes allowed. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_compression_method_supported 3 , +.Xr zip_stat 3 +.Sh HISTORY +.Fn zip_set_file_compression +was added in libzip 0.11. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source.html b/thirdparty/libzip-1.11.3/man/zip_source.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source.man b/thirdparty/libzip-1.11.3/man/zip_source.man new file mode 100644 index 0000000..35b147f --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source.man @@ -0,0 +1,91 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source.mdoc -- description of zip data source +.\" Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source\fR +\- zip data source structure +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_source_t *zs\fR; +.SH "DESCRIPTION" +A +\fIstruct zip_source\fR +is a data source used by +libzip(3) +for adding or replacing file contents for a file in a zip archive. +If the source supports seeking, it can also be used to open zip archives from. +It is created by calling one of +zip_source_buffer(3), +zip_source_buffer_create(3), +zip_source_file(3), +zip_source_file_create(3), +zip_source_filep(3), +zip_source_filep_create(3), +zip_source_function(3), +zip_source_function_create(3), +zip_source_window(3), +or +zip_source_zip(3). +\fIzip_source_t\fR +is reference counted, and created with a reference count of 1. +zip_open_from_source(3), +zip_file_add(3), +and +zip_file_replace(3) +will decrement the reference count of the +\fIzip_source_t\fR +when they are done using it, so +zip_source_free(3) +only needs to be called when these functions return an error. +Use +zip_source_keep(3) +to increase the reference count, for example if you need the source after +zip_close(3). +.SH "SEE ALSO" +libzip(3), +zip_source_buffer(3), +zip_source_file(3), +zip_source_filep(3), +zip_source_free(3), +zip_source_function(3), +zip_source_window(3), +zip_source_zip(3) +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source.mdoc b/thirdparty/libzip-1.11.3/man/zip_source.mdoc new file mode 100644 index 0000000..fd748fd --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source.mdoc @@ -0,0 +1,90 @@ +.\" zip_source.mdoc -- description of zip data source +.\" Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE 3 +.Os +.Sh NAME +.Nm zip_source +.Nd zip data source structure +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Vt zip_source_t *zs ; +.Sh DESCRIPTION +A +.Vt struct zip_source +is a data source used by +.Xr libzip 3 +for adding or replacing file contents for a file in a zip archive. +If the source supports seeking, it can also be used to open zip archives from. +It is created by calling one of +.Xr zip_source_buffer 3 , +.Xr zip_source_buffer_create 3 , +.Xr zip_source_file 3 , +.Xr zip_source_file_create 3 , +.Xr zip_source_filep 3 , +.Xr zip_source_filep_create 3 , +.Xr zip_source_function 3 , +.Xr zip_source_function_create 3 , +.Xr zip_source_window 3 , +or +.Xr zip_source_zip 3 . +.Vt zip_source_t +is reference counted, and created with a reference count of 1. +.Xr zip_open_from_source 3 , +.Xr zip_file_add 3 , +and +.Xr zip_file_replace 3 +will decrement the reference count of the +.Vt zip_source_t +when they are done using it, so +.Xr zip_source_free 3 +only needs to be called when these functions return an error. +Use +.Xr zip_source_keep 3 +to increase the reference count, for example if you need the source after +.Xr zip_close 3 . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source_buffer 3 , +.Xr zip_source_file 3 , +.Xr zip_source_filep 3 , +.Xr zip_source_free 3 , +.Xr zip_source_function 3 , +.Xr zip_source_window 3 , +.Xr zip_source_zip 3 +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_begin_write.html b/thirdparty/libzip-1.11.3/man/zip_source_begin_write.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_begin_write.man b/thirdparty/libzip-1.11.3/man/zip_source_begin_write.man new file mode 100644 index 0000000..714846d --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_begin_write.man @@ -0,0 +1,99 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_begin_write.mdoc -- prepare zip source for writing +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_BEGIN_WRITE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_begin_write\fR, +\fBzip_source_begin_write_cloning\fR +\- prepare zip source for writing +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_source_begin_write\fR(\fIzip_source_t\ *source\fR); +.PD +.PP +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_source_begin_write_cloning\fR(\fIzip_source_t\ *source\fR, \fIzip_uint64_t\ offset\fR); +.PD +.SH "DESCRIPTION" +The functions +\fBzip_source_begin_write\fR() +and +\fBzip_source_begin_write_cloning\fR() +prepare +\fIsource\fR +for writing. +Usually this involves creating temporary files or allocating buffers. +.PP +\fBzip_source_begin_write_cloning\fR() +preserves the first +\fIoffset\fR +bytes of the original file. +This is done efficiently, and writes to +\fIsource\fR +won't overwrite the original data until +\fBzip_commit_write\fR() +is called. +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIsource\fR +is set to indicate the error. +.SH "SEE ALSO" +libzip(3), +zip_source(3), +zip_source_commit_write(3), +zip_source_rollback_write(3), +zip_source_seek_write(3), +zip_source_tell_write(3), +zip_source_write(3) +.SH "HISTORY" +\fBzip_source_begin_write\fR() +was added in libzip 1.0. +.PP +\fBzip_source_begin_write_cloning\fR() +was added in libzip 1.4.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_begin_write.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_begin_write.mdoc new file mode 100644 index 0000000..8bcd555 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_begin_write.mdoc @@ -0,0 +1,89 @@ +.\" zip_source_begin_write.mdoc -- prepare zip source for writing +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_BEGIN_WRITE 3 +.Os +.Sh NAME +.Nm zip_source_begin_write , +.Nm zip_source_begin_write_cloning +.Nd prepare zip source for writing +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_source_begin_write "zip_source_t *source" +.Ft int +.Fn zip_source_begin_write_cloning "zip_source_t *source" "zip_uint64_t offset" +.Sh DESCRIPTION +The functions +.Fn zip_source_begin_write +and +.Fn zip_source_begin_write_cloning +prepare +.Fa source +for writing. +Usually this involves creating temporary files or allocating buffers. +.Pp +.Fn zip_source_begin_write_cloning +preserves the first +.Ar offset +bytes of the original file. +This is done efficiently, and writes to +.Ar source +won't overwrite the original data until +.Fn zip_commit_write +is called. +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar source +is set to indicate the error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_commit_write 3 , +.Xr zip_source_rollback_write 3 , +.Xr zip_source_seek_write 3 , +.Xr zip_source_tell_write 3 , +.Xr zip_source_write 3 +.Sh HISTORY +.Fn zip_source_begin_write +was added in libzip 1.0. +.Pp +.Fn zip_source_begin_write_cloning +was added in libzip 1.4.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_buffer.html b/thirdparty/libzip-1.11.3/man/zip_source_buffer.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_buffer.man b/thirdparty/libzip-1.11.3/man/zip_source_buffer.man new file mode 100644 index 0000000..322045f --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_buffer.man @@ -0,0 +1,112 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_buffer.mdoc -- create zip data source from buffer +.\" Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_BUFFER" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_buffer\fR, +\fBzip_source_buffer_create\fR +\- create zip data source from buffer +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_buffer\fR(\fIzip_t\ *archive\fR, \fIconst\ void\ *data\fR, \fIzip_uint64_t\ len\fR, \fIint\ freep\fR); +.PD +.PP +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_buffer_create\fR(\fIconst\ void\ *data\fR, \fIzip_uint64_t\ len\fR, \fIint\ freep\fR, \fIzip_error_t\ *error\fR); +.PD +.SH "DESCRIPTION" +The functions +\fBzip_source_buffer\fR() +and +\fBzip_source_buffer_create\fR() +create a zip source from the buffer +\fIdata\fR +of size +\fIlen\fR. +If +\fIfreep\fR +is non-zero, the buffer will be freed when it is no longer needed. +\fIdata\fR +must remain valid for the lifetime of the created source. +.PP +The source can be used to open a zip archive from. +.SH "RETURN VALUES" +Upon successful completion, the created source is returned. +Otherwise, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +or +\fIerror\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_source_buffer\fR() +and +\fBzip_source_buffer_create\fR() +fail if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIlen\fR +is greater than zero and +\fIdata\fR +is +\fRNULL\fR. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.SH "SEE ALSO" +libzip(3), +zip_file_add(3), +zip_file_replace(3), +zip_open_from_source(3), +zip_source(3) +.SH "HISTORY" +\fBzip_source_buffer\fR() +and +\fBzip_source_buffer_create\fR() +were added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_buffer.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_buffer.mdoc new file mode 100644 index 0000000..148ceed --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_buffer.mdoc @@ -0,0 +1,102 @@ +.\" zip_source_buffer.mdoc -- create zip data source from buffer +.\" Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_BUFFER 3 +.Os +.Sh NAME +.Nm zip_source_buffer , +.Nm zip_source_buffer_create +.Nd create zip data source from buffer +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_source_t * +.Fn zip_source_buffer "zip_t *archive" "const void *data" "zip_uint64_t len" "int freep" +.Ft zip_source_t * +.Fn zip_source_buffer_create "const void *data" "zip_uint64_t len" "int freep" "zip_error_t *error" +.Sh DESCRIPTION +The functions +.Fn zip_source_buffer +and +.Fn zip_source_buffer_create +create a zip source from the buffer +.Ar data +of size +.Ar len . +If +.Ar freep +is non-zero, the buffer will be freed when it is no longer needed. +.Ar data +must remain valid for the lifetime of the created source. +.Pp +The source can be used to open a zip archive from. +.Sh RETURN VALUES +Upon successful completion, the created source is returned. +Otherwise, +.Dv NULL +is returned and the error code in +.Ar archive +or +.Ar error +is set to indicate the error. +.Sh ERRORS +.Fn zip_source_buffer +and +.Fn zip_source_buffer_create +fail if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar len +is greater than zero and +.Ar data +is +.Dv NULL . +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_add 3 , +.Xr zip_file_replace 3 , +.Xr zip_open_from_source 3 , +.Xr zip_source 3 +.Sh HISTORY +.Fn zip_source_buffer +and +.Fn zip_source_buffer_create +were added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_buffer_fragment.html b/thirdparty/libzip-1.11.3/man/zip_source_buffer_fragment.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_buffer_fragment.man b/thirdparty/libzip-1.11.3/man/zip_source_buffer_fragment.man new file mode 100644 index 0000000..3514d3c --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_buffer_fragment.man @@ -0,0 +1,125 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_buffer_fragment.mdoc -- create zip data source from multiple buffers +.\" Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_BUFFER_FRAGMENT" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_buffer_fragment\fR, +\fBzip_source_buffer_fragment_create\fR +\- create zip data source from multiple buffer +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_buffer_fragment\fR(\fIzip_t\ *archive\fR, \fIzip_buffer_fragment_t\ *fragments\fR, \fIzip_uint64_t\ nfragments\fR, \fIint\ freep\fR); +.PD +.PP +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_buffer_fragment_create\fR(\fIzip_buffer_fragment_t\ *fragments\fR, \fIzip_uint64_t\ nfragments\fR, \fIint\ freep\fR, \fIzip_error_t\ *error\fR); +.PD +.SH "DESCRIPTION" +The functions +\fBzip_source_buffer_fragment\fR() +and +\fBzip_source_buffer_fragment_create\fR() +create a zip source from the data in +\fIfragments\fR. +\fInfragments\fR +specifies the number of fragments. +If +\fIfreep\fR +is non-zero, the data will be freed when it is no longer needed. +.nf +.sp +.RS 0n +struct zip_stat { + zip_uint8_t *data; /* pointer to the actual data */ + zip_uint64_t length; /* length of this fragment */ +}; +.RE +.fi +.PP +The data +\fIfragments\fR +point to must remain valid for the lifetime of the created source. +\fIfragments\fR +itself can be discarded once the source is created. +.PP +The source can be used to open a zip archive from. +.SH "RETURN VALUES" +Upon successful completion, the created source is returned. +Otherwise, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +or +\fIerror\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_source_buffer\fR() +and +\fBzip_source_buffer_create\fR() +fail if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fInfragments\fR +is greater than zero and +\fIfragments\fR +is +\fRNULL\fR. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.SH "SEE ALSO" +libzip(3), +zip_file_add(3), +zip_file_replace(3), +zip_open_from_source(3), +zip_source(3) +.SH "HISTORY" +\fBzip_source_buffer_fragment\fR() +and +\fBzip_source_buffer_fragment_create\fR() +were added in libzip 1.4.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_buffer_fragment.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_buffer_fragment.mdoc new file mode 100644 index 0000000..c452ef7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_buffer_fragment.mdoc @@ -0,0 +1,112 @@ +.\" zip_source_buffer_fragment.mdoc -- create zip data source from multiple buffers +.\" Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_BUFFER_FRAGMENT 3 +.Os +.Sh NAME +.Nm zip_source_buffer_fragment , +.Nm zip_source_buffer_fragment_create +.Nd create zip data source from multiple buffer +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_source_t * +.Fn zip_source_buffer_fragment "zip_t *archive" "zip_buffer_fragment_t *fragments" "zip_uint64_t nfragments" "int freep" +.Ft zip_source_t * +.Fn zip_source_buffer_fragment_create "zip_buffer_fragment_t *fragments" "zip_uint64_t nfragments" "int freep" "zip_error_t *error" +.Sh DESCRIPTION +The functions +.Fn zip_source_buffer_fragment +and +.Fn zip_source_buffer_fragment_create +create a zip source from the data in +.Ar fragments . +.Ar nfragments +specifies the number of fragments. +If +.Ar freep +is non-zero, the data will be freed when it is no longer needed. +.Bd -literal +struct zip_stat { + zip_uint8_t *data; /* pointer to the actual data */ + zip_uint64_t length; /* length of this fragment */ +}; +.Ed +.Pp +The data +.Ar fragments +point to must remain valid for the lifetime of the created source. +.Ar fragments +itself can be discarded once the source is created. +.Pp +The source can be used to open a zip archive from. +.Sh RETURN VALUES +Upon successful completion, the created source is returned. +Otherwise, +.Dv NULL +is returned and the error code in +.Ar archive +or +.Ar error +is set to indicate the error. +.Sh ERRORS +.Fn zip_source_buffer +and +.Fn zip_source_buffer_create +fail if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar nfragments +is greater than zero and +.Ar fragments +is +.Dv NULL . +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_add 3 , +.Xr zip_file_replace 3 , +.Xr zip_open_from_source 3 , +.Xr zip_source 3 +.Sh HISTORY +.Fn zip_source_buffer_fragment +and +.Fn zip_source_buffer_fragment_create +were added in libzip 1.4.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_close.html b/thirdparty/libzip-1.11.3/man/zip_source_close.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_close.man b/thirdparty/libzip-1.11.3/man/zip_source_close.man new file mode 100644 index 0000000..a3a481f --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_close.man @@ -0,0 +1,72 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_close.mdoc -- close zip source (open for reading) +.\" Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_CLOSE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_close\fR +\- close zip_source (which was open for reading) +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_source_close\fR(\fIzip_source_t\ *source\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_source_close\fR() +closes +\fIsource\fR, +indicating that no more data will be read. +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIsource\fR +is set to indicate the error. +.SH "SEE ALSO" +libzip(3), +zip_source(3), +zip_source_free(3), +zip_source_open(3) +.SH "HISTORY" +\fBzip_source_close\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_close.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_close.mdoc new file mode 100644 index 0000000..05c7ed1 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_close.mdoc @@ -0,0 +1,67 @@ +.\" zip_source_close.mdoc -- close zip source (open for reading) +.\" Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_CLOSE 3 +.Os +.Sh NAME +.Nm zip_source_close +.Nd close zip_source (which was open for reading) +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_source_close "zip_source_t *source" +.Sh DESCRIPTION +The function +.Fn zip_source_close +closes +.Fa source , +indicating that no more data will be read. +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar source +is set to indicate the error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_free 3 , +.Xr zip_source_open 3 +.Sh HISTORY +.Fn zip_source_close +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_commit_write.html b/thirdparty/libzip-1.11.3/man/zip_source_commit_write.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_commit_write.man b/thirdparty/libzip-1.11.3/man/zip_source_commit_write.man new file mode 100644 index 0000000..b8a30b9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_commit_write.man @@ -0,0 +1,75 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_commit_write.mdoc -- finalize changes to zip source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_COMMIT_WRITE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_commit_write\fR +\- finalize changes to zip source +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_source_commit_write\fR(\fIzip_source_t\ *source\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_source_commit_write\fR() +finishes writing data to +\fIsource\fR +and replaces the original with the newly written data. +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIsource\fR +is set to indicate the error. +.SH "SEE ALSO" +libzip(3), +zip_source(3), +zip_source_begin_write(3), +zip_source_rollback_write(3), +zip_source_seek_write(3), +zip_source_tell_write(3), +zip_source_write(3) +.SH "HISTORY" +\fBzip_source_commit_write\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_commit_write.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_commit_write.mdoc new file mode 100644 index 0000000..9deae6b --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_commit_write.mdoc @@ -0,0 +1,70 @@ +.\" zip_source_commit_write.mdoc -- finalize changes to zip source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_COMMIT_WRITE 3 +.Os +.Sh NAME +.Nm zip_source_commit_write +.Nd finalize changes to zip source +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_source_commit_write "zip_source_t *source" +.Sh DESCRIPTION +The function +.Fn zip_source_commit_write +finishes writing data to +.Fa source +and replaces the original with the newly written data. +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar source +is set to indicate the error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_begin_write 3 , +.Xr zip_source_rollback_write 3 , +.Xr zip_source_seek_write 3 , +.Xr zip_source_tell_write 3 , +.Xr zip_source_write 3 +.Sh HISTORY +.Fn zip_source_commit_write +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_error.html b/thirdparty/libzip-1.11.3/man/zip_source_error.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_error.man b/thirdparty/libzip-1.11.3/man/zip_source_error.man new file mode 100644 index 0000000..d87b3b2 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_error.man @@ -0,0 +1,65 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_error.mdoc -- get zip_error for data source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_ERROR" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_error\fR +\- get zip error for data source +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_error_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_error\fR(\fIzip_source_t\ *source\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_source_error\fR() +function returns the zip error for the data source +\fIsource\fR. +.SH "SEE ALSO" +libzip(3), +zip_error_code_system(3), +zip_error_code_zip(3) +.SH "HISTORY" +\fBzip_source_error\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_error.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_error.mdoc new file mode 100644 index 0000000..291a144 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_error.mdoc @@ -0,0 +1,60 @@ +.\" zip_source_error.mdoc -- get zip_error for data source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_ERROR 3 +.Os +.Sh NAME +.Nm zip_source_error +.Nd get zip error for data source +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_error_t * +.Fn zip_source_error "zip_source_t *source" +.Sh DESCRIPTION +The +.Fn zip_source_error +function returns the zip error for the data source +.Ar source . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_error_code_system 3 , +.Xr zip_error_code_zip 3 +.Sh HISTORY +.Fn zip_source_error +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_file.html b/thirdparty/libzip-1.11.3/man/zip_source_file.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_file.man b/thirdparty/libzip-1.11.3/man/zip_source_file.man new file mode 100644 index 0000000..586fb07 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_file.man @@ -0,0 +1,158 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_file.mdoc -- create data source from a file +.\" Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_FILE" "3" "June 30, 2023" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_file\fR, +\fBzip_source_file_create\fR +\- create data source from a file +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_file\fR(\fIzip_t\ *archive\fR, \fIconst\ char\ *fname\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ len\fR); +.PD +.PP +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_file_create\fR(\fIconst\ char\ *fname\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ len\fR, \fIzip_error_t\ *error\fR); +.PD +.SH "DESCRIPTION" +The functions +\fBzip_source_file\fR() +and +\fBzip_source_file_create\fR() +create a zip source from a file. +They open +\fIfname\fR +and read +\fIlen\fR +bytes from offset +\fIstart\fR +from it. +.PP +When passing +\fRZIP_LENGTH_TO_END\fR +(or \-1, which is deprecated) as +\fIlen\fR, +\fBzip_source_file\fR +determines the file size when it is called and uses that as the +expected file size. +If the file size grows between creating and reading from the source, +the additional data is ignored. +If the file shrinks, +\fBlibzip\fR +treats it as an error +(\fRZIP_ER_DATA_LENGTH\fR). +.PP +When passing +\fRZIP_LENGTH_UNCHECKED\fR +as +\fIlen\fR, +\fBzip_source_file\fR +assumes the file's size is unknown. +Reading from the source returns as much data as is there at that time +(usually when calling +zip_close(3)). +.PP +\fBlibzip\fR +can do various optimizations if the size of a source is known when +it's created, so +\fRZIP_LENGTH_TO_END\fR +is preferable. +If you deal with files that are likely to change while you are +processing them, you can use the less efficient +\fRZIP_LENGTH_UNCHECKED\fR. +.PP +If the file supports seek, the source can be used to open a zip archive from. +.PP +The file is opened and read when the data from the source is used, usually by +\fBzip_close\fR() +or +\fBzip_open_from_source\fR(). +.SH "RETURN VALUES" +Upon successful completion, the created source is returned. +Otherwise, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +or +\fIerror\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_source_file\fR() +and +\fBzip_source_file_create\fR() +fail if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIfname\fR, +\fIstart\fR, +or +\fIlen\fR +are invalid. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.TP 19n +[\fRZIP_ER_OPEN\fR] +Opening +\fIfname\fR +failed. +.SH "SEE ALSO" +libzip(3), +zip_file_add(3), +zip_file_replace(3), +zip_source(3) +.SH "HISTORY" +\fBzip_source_file\fR() +and +\fBzip_source_file_create\fR() +were added in libzip 1.0. +.PP +\fRZIP_LENGTH_TO_END\fR +and +\fRZIP_LENGTH_UNCHECKED\fR +were added in libzip 1.10.1. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_file.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_file.mdoc new file mode 100644 index 0000000..15b7c00 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_file.mdoc @@ -0,0 +1,147 @@ +.\" zip_source_file.mdoc -- create data source from a file +.\" Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd June 30, 2023 +.Dt ZIP_SOURCE_FILE 3 +.Os +.Sh NAME +.Nm zip_source_file , +.Nm zip_source_file_create +.Nd create data source from a file +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_source_t * +.Fn zip_source_file "zip_t *archive" "const char *fname" "zip_uint64_t start" "zip_int64_t len" +.Ft zip_source_t * +.Fn zip_source_file_create "const char *fname" "zip_uint64_t start" "zip_int64_t len" "zip_error_t *error" +.Sh DESCRIPTION +The functions +.Fn zip_source_file +and +.Fn zip_source_file_create +create a zip source from a file. +They open +.Ar fname +and read +.Ar len +bytes from offset +.Ar start +from it. +.Pp +When passing +.Dv ZIP_LENGTH_TO_END +(or \-1, which is deprecated) as +.Ar len , +.Nm +determines the file size when it is called and uses that as the +expected file size. +If the file size grows between creating and reading from the source, +the additional data is ignored. +If the file shrinks, +.Nm libzip +treats it as an error +.Dv ( ZIP_ER_DATA_LENGTH ) . +.Pp +When passing +.Dv ZIP_LENGTH_UNCHECKED +as +.Ar len , +.Nm +assumes the file's size is unknown. +Reading from the source returns as much data as is there at that time +(usually when calling +.Xr zip_close 3 ) . +.Pp +.Nm libzip +can do various optimizations if the size of a source is known when +it's created, so +.Dv ZIP_LENGTH_TO_END +is preferable. +If you deal with files that are likely to change while you are +processing them, you can use the less efficient +.Dv ZIP_LENGTH_UNCHECKED . +.Pp +If the file supports seek, the source can be used to open a zip archive from. +.Pp +The file is opened and read when the data from the source is used, usually by +.Fn zip_close +or +.Fn zip_open_from_source . +.Sh RETURN VALUES +Upon successful completion, the created source is returned. +Otherwise, +.Dv NULL +is returned and the error code in +.Ar archive +or +.Ar error +is set to indicate the error. +.Sh ERRORS +.Fn zip_source_file +and +.Fn zip_source_file_create +fail if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar fname , +.Ar start , +or +.Ar len +are invalid. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.It Bq Er ZIP_ER_OPEN +Opening +.Ar fname +failed. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_add 3 , +.Xr zip_file_replace 3 , +.Xr zip_source 3 +.Sh HISTORY +.Fn zip_source_file +and +.Fn zip_source_file_create +were added in libzip 1.0. +.Pp +.Dv ZIP_LENGTH_TO_END +and +.Dv ZIP_LENGTH_UNCHECKED +were added in libzip 1.10.1. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_filep.html b/thirdparty/libzip-1.11.3/man/zip_source_filep.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_filep.man b/thirdparty/libzip-1.11.3/man/zip_source_filep.man new file mode 100644 index 0000000..dca0718 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_filep.man @@ -0,0 +1,122 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_filep.mdoc -- create data source from a file stream +.\" Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_FILEP" "3" "June 30, 2023" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_filep\fR, +\fBzip_source_filep_create\fR +\- create data source from FILE * +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_filep\fR(\fIzip_t\ *archive\fR, \fIFILE\ *file\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ len\fR); +.PD +.PP +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_filep_create\fR(\fIFILE\ *file\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ len\fR, \fIzip_error_t\ *error\fR); +.PD +.SH "DESCRIPTION" +The functions +\fBzip_source_filep\fR() +and +\fBzip_source_filep_create\fR() +create a zip source from a file stream. +They read +\fIlen\fR +bytes from offset +\fIstart\fR +from the open file stream +\fIfile\fR. +For a description of the +\fIlen\fR +argument, see +zip_source_file(3). +.PP +If the file stream supports seeking, the source can be used to open +a read-only zip archive from. +.PP +The file stream is closed when the source is being freed, usually +by +zip_close(3). +.SH "RETURN VALUES" +Upon successful completion, the created source is returned. +Otherwise, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +or +\fIerror\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_source_filep\fR() +fails if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIfile\fR, +\fIstart\fR, +or +\fIlen\fR +are invalid. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.SH "SEE ALSO" +libzip(3), +zip_file_add(3), +zip_file_replace(3), +zip_source(3), +zip_source_file(3) +.SH "HISTORY" +\fBzip_source_filep\fR() +and +\fBzip_source_filep_create\fR() +were added in libzip 1.0. +.PP +\fRZIP_LENGTH_TO_END\fR +and +\fRZIP_LENGTH_UNCHECKED\fR +were added in libzip 1.10.1. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_filep.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_filep.mdoc new file mode 100644 index 0000000..341f2db --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_filep.mdoc @@ -0,0 +1,112 @@ +.\" zip_source_filep.mdoc -- create data source from a file stream +.\" Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd June 30, 2023 +.Dt ZIP_SOURCE_FILEP 3 +.Os +.Sh NAME +.Nm zip_source_filep , +.Nm zip_source_filep_create +.Nd create data source from FILE * +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_source_t * +.Fn zip_source_filep "zip_t *archive" "FILE *file" "zip_uint64_t start" "zip_int64_t len" +.Ft zip_source_t * +.Fn zip_source_filep_create "FILE *file" "zip_uint64_t start" "zip_int64_t len" "zip_error_t *error" +.Sh DESCRIPTION +The functions +.Fn zip_source_filep +and +.Fn zip_source_filep_create +create a zip source from a file stream. +They read +.Ar len +bytes from offset +.Ar start +from the open file stream +.Ar file . +For a description of the +.Ar len +argument, see +.Xr zip_source_file 3 . +.Pp +If the file stream supports seeking, the source can be used to open +a read-only zip archive from. +.Pp +The file stream is closed when the source is being freed, usually +by +.Xr zip_close 3 . +.Sh RETURN VALUES +Upon successful completion, the created source is returned. +Otherwise, +.Dv NULL +is returned and the error code in +.Ar archive +or +.Ar error +is set to indicate the error. +.Sh ERRORS +.Fn zip_source_filep +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar file , +.Ar start , +or +.Ar len +are invalid. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_add 3 , +.Xr zip_file_replace 3 , +.Xr zip_source 3 , +.Xr zip_source_file 3 +.Sh HISTORY +.Fn zip_source_filep +and +.Fn zip_source_filep_create +were added in libzip 1.0. +.Pp +.Dv ZIP_LENGTH_TO_END +and +.Dv ZIP_LENGTH_UNCHECKED +were added in libzip 1.10.1. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_free.html b/thirdparty/libzip-1.11.3/man/zip_source_free.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_free.man b/thirdparty/libzip-1.11.3/man/zip_source_free.man new file mode 100644 index 0000000..9eacec8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_free.man @@ -0,0 +1,81 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_free.mdoc -- free zip data source +.\" Copyright (C) 2004-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_FREE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_free\fR +\- free zip data source +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_source_free\fR(\fIzip_source_t\ *source\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_source_free\fR() +decrements the reference count of +\fIsource\fR +and frees it if the reference count drops to 0. +If +\fIsource\fR +is +\fRNULL\fR, +it does nothing. +.PP +\fINOTE\fR: +This function should not be called on a +\fIsource\fR +after it was used successfully in a +zip_open_from_source(3), +zip_file_add(3), +or +zip_file_replace(3) +call. +.SH "SEE ALSO" +libzip(3), +zip_source(3), +zip_source_keep(3) +.SH "HISTORY" +\fBzip_source_free\fR() +was added in libzip 0.6. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_free.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_free.mdoc new file mode 100644 index 0000000..3f17792 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_free.mdoc @@ -0,0 +1,76 @@ +.\" zip_source_free.mdoc -- free zip data source +.\" Copyright (C) 2004-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_FREE 3 +.Os +.Sh NAME +.Nm zip_source_free +.Nd free zip data source +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft void +.Fn zip_source_free "zip_source_t *source" +.Sh DESCRIPTION +The function +.Fn zip_source_free +decrements the reference count of +.Ar source +and frees it if the reference count drops to 0. +If +.Ar source +is +.Dv NULL , +it does nothing. +.Pp +.Em NOTE : +This function should not be called on a +.Ar source +after it was used successfully in a +.Xr zip_open_from_source 3 , +.Xr zip_file_add 3 , +or +.Xr zip_file_replace 3 +call. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_keep 3 +.Sh HISTORY +.Fn zip_source_free +was added in libzip 0.6. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_function.html b/thirdparty/libzip-1.11.3/man/zip_source_function.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_function.man b/thirdparty/libzip-1.11.3/man/zip_source_function.man new file mode 100644 index 0000000..0a9b717 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_function.man @@ -0,0 +1,429 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_function.mdoc -- create data source from function +.\" Copyright (C) 2004-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_FUNCTION" "3" "January 5, 2023" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_function\fR, +\fBzip_source_function_create\fR +\- create data source from function +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_function\fR(\fIzip_t\ *archive\fR, \fIzip_source_callback\ fn\fR, \fIvoid\ *userdata\fR); +.PD +.PP +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_function_create\fR(\fIzip_source_callback\ fn\fR, \fIvoid\ *userdata\fR, \fIzip_error_t\ *error\fR); +.PD +.SH "DESCRIPTION" +The functions +\fBzip_source_function\fR() +and +\fBzip_source_function_create\fR() +create a zip source from the user-provided function +\fIfn\fR, +which must be of the following type: +.PP +\fItypedef zip_int64_t\fR +\fB\fR(*\fPzip_source_callback\fR)\fP\fR(\fIvoid\ *userdata\fR, \fIvoid\ *data\fR, \fIzip_uint64_t\ len\fR, \fIzip_source_cmd_t\ cmd\fR) +.PP +\fIarchive\fR +or +\fIerror\fR +are used for reporting errors and can be +\fRNULL\fR. +.PP +When called by the library, the first argument is the +\fIuserdata\fR +argument supplied to the function. +The next two arguments are a buffer +\fIdata\fR +of size +\fIlen\fR +when data is passed in or expected to be returned, or else +\fRNULL\fR +and 0. +The last argument, +\fIcmd\fR, +specifies which action the function should perform. +.PP +Depending on the uses, there are three useful sets of commands to be supported by a +\fBzip_source_callback\fR(): +.TP 24n +read source +Providing streamed data (for file data added to archives). +Must support +\fRZIP_SOURCE_OPEN\fR, +\fRZIP_SOURCE_READ\fR, +\fRZIP_SOURCE_CLOSE\fR, +\fRZIP_SOURCE_STAT\fR, +and +\fRZIP_SOURCE_ERROR\fR. +.sp +If your source uses any allocated memory (including +\fIuserdata\fR) +it should also implement +\fRZIP_SOURCE_FREE\fR +to avoid memory leaks. +.TP 24n +seekable read source +Same as previous, but from a source allowing reading from arbitrary +offsets (also for read-only zip archive). +Must additionally support +\fRZIP_SOURCE_SEEK\fR, +\fRZIP_SOURCE_TELL\fR, +and +\fRZIP_SOURCE_SUPPORTS\fR. +.TP 24n +read/write source +Same as previous, but additionally allowing writing (also for writable +zip archives). +Must additionally support +\fRZIP_SOURCE_BEGIN_WRITE\fR, +\fRZIP_SOURCE_COMMIT_WRITE\fR, +\fRZIP_SOURCE_ROLLBACK_WRITE\fR, +\fRZIP_SOURCE_SEEK_WRITE\fR, +\fRZIP_SOURCE_TELL_WRITE\fR, +and +\fRZIP_SOURCE_REMOVE\fR. +.sp +On top of the above, supporting the pseudo-command +\fRZIP_SOURCE_SUPPORTS_REOPEN\fR +allows calling +\fBzip_source_open\fR() +again after calling +\fBzip_source_close\fR(). +.SS "\fRZIP_SOURCE_ACCEPT_EMPTY\fR" +Return 1 if an empty source should be accepted as a valid zip archive. +This is the default if this command is not supported by a source. +File system backed sources should return 0. +.SS "\fRZIP_SOURCE_BEGIN_WRITE\fR" +Prepare the source for writing. +Use this to create any temporary file(s). +.SS "\fRZIP_SOURCE_BEGIN_WRITE_CLONING\fR" +Prepare the source for writing, keeping the first +\fIlen\fR +bytes of the original file. +Only implement this command if it is more efficient than copying the +data, and if it does not destructively overwrite the original file +(you still have to be able to execute +\fRZIP_SOURCE_ROLLBACK_WRITE\fR). +.PP +The next write should happen at byte +\fIoffset\fR. +.SS "\fRZIP_SOURCE_CLOSE\fR" +Reading is done. +.SS "\fRZIP_SOURCE_COMMIT_WRITE\fR" +Finish writing to the source. +Replace the original data with the newly written data. +Clean up temporary files or internal buffers. +Subsequently opening and reading from the source should return the +newly written data. +.SS "\fRZIP_SOURCE_ERROR\fR" +Get error information. +\fIdata\fR +points to an array of two ints, which should be filled with the libzip +error code and the corresponding system error code for the error that +occurred. +See +zip_errors(3) +for details on the error codes. +If the source stores error information in a zip_error_t, use +zip_error_to_data(3) +and return its return value. +Otherwise, return 2 * sizeof(int). +.SS "\fRZIP_SOURCE_FREE\fR" +Clean up and free all resources, including +\fIuserdata\fR. +The callback function will not be called again. +.SS "\fRZIP_SOURCE_GET_FILE_ATTRIBUTES\fR" +Provide information about various data. +Then the data should be put in the appropriate entry in the passed +\fIzip_file_attributes_t\fR +argument, and the appropriate +\fRZIP_FILE_ATTRIBUTES_*\fR +value must be or'ed into the +\fIvalid\fR +member to denote that the corresponding data has been provided. +A +\fIzip_file_attributes_t\fR +structure can be initialized using +zip_file_attributes_init(3). +.TP 12n +ASCII mode +If a file is a plaintext file in ASCII. +Can be used by extraction tools to automatically convert line endings +(part of the internal file attributes). +Member +\fIascii\fR, +flag +\fRZIP_FILE_ATTRIBUTES_ASCII\fR. +.TP 12n +General Purpose Bit Flags (limited to Compression Flags) +The general purpose bit flag in the zip in the local and central +directory headers contain information about the compression method. +Member +\fIgeneral_purpose_bit_flags\fR +and +\fIgeneral_purpose_bit_mask\fR +to denote which members have been set; +flag +\fRZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS\fR. +.TP 12n +External File Attributes +The external file attributes (usually operating system-specific). +Member +\fIexternal_file_attributes\fR, +flag +\fRZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES\fR. +.TP 12n +Version Needed +A minimum version needed required to unpack this entry (in the usual +"major * 10 + minor" format). +Member +\fIversion_needed\fR, +flag +\fRZIP_FILE_ATTRIBUTES_VERSION_NEEDED\fR. +.TP 12n +Operating System +One of the operating systems as defined by the +\fRZIP_OPSYS_*\fR +variables (see +\fIzip.h\fR). +This value affects the interpretation of the external file attributes. +Member +\fIhost_system\fR, +flag +\fRZIP_FILE_ATTRIBUTES_HOST_SYSTEM\fR. +.SS "\fRZIP_SOURCE_OPEN\fR" +Prepare for reading. +.SS "\fRZIP_SOURCE_READ\fR" +Read data into the buffer +\fIdata\fR +of size +\fIlen\fR. +Return the number of bytes placed into +\fIdata\fR +on success, and zero for end-of-file. +.SS "\fRZIP_SOURCE_REMOVE\fR" +Remove the underlying file. +This is called if a zip archive is empty when closed. +.SS "\fRZIP_SOURCE_ROLLBACK_WRITE\fR" +Abort writing to the source. +Discard written data. +Clean up temporary files or internal buffers. +Subsequently opening and reading from the source should return the +original data. +.SS "\fRZIP_SOURCE_SEEK\fR" +Specify position to read next byte from, like +fseek(3). +Use +ZIP_SOURCE_GET_ARGS(3) +to decode the arguments into the following struct: +.nf +.sp +.RS 0n +struct zip_source_args_seek { + zip_int64_t offset; + int whence; +}; +.RE +.fi +.PP +If the size of the source's data is known, use +zip_source_seek_compute_offset(3) +to validate the arguments and compute the new offset. +.SS "\fRZIP_SOURCE_SEEK_WRITE\fR" +Specify position to write next byte to, like +fseek(3). +See +\fRZIP_SOURCE_SEEK\fR +for details. +.SS "\fRZIP_SOURCE_STAT\fR" +Get meta information for the input data. +\fIdata\fR +points to an allocated +\fIstruct zip_stat\fR, +which should be initialized using +zip_stat_init(3) +and then filled in. +.PP +For uncompressed, unencrypted data, all information is optional. +However, fill in as much information as is readily available. +.PP +If the data is compressed, +\fRZIP_STAT_COMP_METHOD\fR, +\fRZIP_STAT_SIZE\fR, +and +\fRZIP_STAT_CRC\fR +must be filled in. +.PP +If the data is encrypted, +\fRZIP_STAT_ENCRYPTION_METHOD\fR, +\fRZIP_STAT_COMP_METHOD\fR, +\fRZIP_STAT_SIZE\fR, +and +\fRZIP_STAT_CRC\fR +must be filled in. +.PP +Information only available after the source has been read (e.g., size) +can be omitted in an earlier call. +\fINOTE\fR: +\fBzip_source_function\fR() +may be called with this argument even after being called with +\fRZIP_SOURCE_CLOSE\fR. +.PP +Return sizeof(struct zip_stat) on success. +.SS "\fRZIP_SOURCE_SUPPORTS\fR" +Return bitmap specifying which commands are supported. +Use +zip_source_make_command_bitmap(3). +If this command is not implemented, the source is assumed to be a +read source without seek support. +.SS "\fRZIP_SOURCE_TELL\fR" +Return the current read offset in the source, like +ftell(3). +.SS "\fRZIP_SOURCE_TELL_WRITE\fR" +Return the current write offset in the source, like +ftell(3). +.SS "\fRZIP_SOURCE_WRITE\fR" +Write data to the source. +Return number of bytes written. +.SS "\fRZIP_SOURCE_SUPPORTS_REOPEN\fR" +This command is never actually invoked, support for it signals the +ability to handle multiple open/read/close cycles. +.SS "Return Values" +Commands should return \-1 on error. +\fRZIP_SOURCE_ERROR\fR +will be called to retrieve the error code. +On success, commands return 0, unless specified otherwise in the +description above. +.SS "Calling Conventions" +The library will always issue +\fRZIP_SOURCE_OPEN\fR +before issuing +\fRZIP_SOURCE_READ\fR, +\fRZIP_SOURCE_SEEK\fR, +or +\fRZIP_SOURCE_TELL\fR. +When it no longer wishes to read from this source, it will issue +\fRZIP_SOURCE_CLOSE\fR. +If the library wishes to read the data again, it will issue +\fRZIP_SOURCE_OPEN\fR +a second time. +If the function is unable to provide the data again, it should +return \-1. +.PP +\fRZIP_SOURCE_BEGIN_WRITE\fR +or +\fRZIP_SOURCE_BEGIN_WRITE_CLONING\fR +will be called before +\fRZIP_SOURCE_WRITE\fR, +\fRZIP_SOURCE_SEEK_WRITE\fR, +or +\fRZIP_SOURCE_TELL_WRITE\fR. +When writing is complete, either +\fRZIP_SOURCE_COMMIT_WRITE\fR +or +\fRZIP_SOURCE_ROLLBACK_WRITE\fR +will be called. +.PP +\fRZIP_SOURCE_ACCEPT_EMPTY\fR, +\fRZIP_SOURCE_GET_FILE_ATTRIBUTES\fR, +and +\fRZIP_SOURCE_STAT\fR +can be issued at any time. +.PP +\fRZIP_SOURCE_ERROR\fR +will only be issued in response to the function +returning \-1. +.PP +\fRZIP_SOURCE_FREE\fR +will be the last command issued; +if +\fRZIP_SOURCE_OPEN\fR +was called and succeeded, +\fRZIP_SOURCE_CLOSE\fR +will be called before +\fRZIP_SOURCE_FREE\fR, +and similarly for +\fRZIP_SOURCE_BEGIN_WRITE\fR +or +\fRZIP_SOURCE_BEGIN_WRITE_CLONING\fR +and +\fRZIP_SOURCE_COMMIT_WRITE\fR +or +\fRZIP_SOURCE_ROLLBACK_WRITE\fR. +.SH "RETURN VALUES" +Upon successful completion, the created source is returned. +Otherwise, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +or +\fIerror\fR +is set to indicate the error (unless +it is +\fRNULL\fR). +.SH "ERRORS" +\fBzip_source_function\fR() +fails if: +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.SH "SEE ALSO" +libzip(3), +zip_file_add(3), +zip_file_attributes_init(3), +zip_file_replace(3), +zip_source(3), +zip_stat_init(3) +.SH "HISTORY" +\fBzip_source_function\fR() +and +\fBzip_source_function_create\fR() +were added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_function.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_function.mdoc new file mode 100644 index 0000000..cfd595d --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_function.mdoc @@ -0,0 +1,415 @@ +.\" zip_source_function.mdoc -- create data source from function +.\" Copyright (C) 2004-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd January 5, 2023 +.Dt ZIP_SOURCE_FUNCTION 3 +.Os +.Sh NAME +.Nm zip_source_function , +.Nm zip_source_function_create +.Nd create data source from function +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_source_t * +.Fn zip_source_function "zip_t *archive" "zip_source_callback fn" "void *userdata" +.Ft zip_source_t * +.Fn zip_source_function_create "zip_source_callback fn" "void *userdata" "zip_error_t *error" +.Sh DESCRIPTION +The functions +.Fn zip_source_function +and +.Fn zip_source_function_create +create a zip source from the user-provided function +.Ar fn , +which must be of the following type: +.Pp +.Ft typedef zip_int64_t +.Fo \fR(*\fPzip_source_callback\fR)\fP +.Fa "void *userdata" "void *data" "zip_uint64_t len" "zip_source_cmd_t cmd" +.Fc +.Pp +.Ar archive +or +.Ar error +are used for reporting errors and can be +.Dv NULL . +.Pp +When called by the library, the first argument is the +.Ar userdata +argument supplied to the function. +The next two arguments are a buffer +.Ar data +of size +.Ar len +when data is passed in or expected to be returned, or else +.Dv NULL +and 0. +The last argument, +.Ar cmd , +specifies which action the function should perform. +.Pp +Depending on the uses, there are three useful sets of commands to be supported by a +.Fn zip_source_callback : +.Bl -tag -width seekable-read-sourceXX +.It read source +Providing streamed data (for file data added to archives). +Must support +.Dv ZIP_SOURCE_OPEN , +.Dv ZIP_SOURCE_READ , +.Dv ZIP_SOURCE_CLOSE , +.Dv ZIP_SOURCE_STAT , +and +.Dv ZIP_SOURCE_ERROR . +.Pp +If your source uses any allocated memory (including +.Ar userdata ) +it should also implement +.Dv ZIP_SOURCE_FREE +to avoid memory leaks. +.It seekable read source +Same as previous, but from a source allowing reading from arbitrary +offsets (also for read-only zip archive). +Must additionally support +.Dv ZIP_SOURCE_SEEK , +.Dv ZIP_SOURCE_TELL , +and +.Dv ZIP_SOURCE_SUPPORTS . +.It read/write source +Same as previous, but additionally allowing writing (also for writable +zip archives). +Must additionally support +.Dv ZIP_SOURCE_BEGIN_WRITE , +.Dv ZIP_SOURCE_COMMIT_WRITE , +.Dv ZIP_SOURCE_ROLLBACK_WRITE , +.Dv ZIP_SOURCE_SEEK_WRITE , +.Dv ZIP_SOURCE_TELL_WRITE , +and +.Dv ZIP_SOURCE_REMOVE . +.Pp +On top of the above, supporting the pseudo-command +.Dv ZIP_SOURCE_SUPPORTS_REOPEN +allows calling +.Fn zip_source_open +again after calling +.Fn zip_source_close . +.El +.Ss Dv ZIP_SOURCE_ACCEPT_EMPTY +Return 1 if an empty source should be accepted as a valid zip archive. +This is the default if this command is not supported by a source. +File system backed sources should return 0. +.Ss Dv ZIP_SOURCE_BEGIN_WRITE +Prepare the source for writing. +Use this to create any temporary file(s). +.Ss Dv ZIP_SOURCE_BEGIN_WRITE_CLONING +Prepare the source for writing, keeping the first +.Ar len +bytes of the original file. +Only implement this command if it is more efficient than copying the +data, and if it does not destructively overwrite the original file +(you still have to be able to execute +.Dv ZIP_SOURCE_ROLLBACK_WRITE ) . +.Pp +The next write should happen at byte +.Ar offset . +.Ss Dv ZIP_SOURCE_CLOSE +Reading is done. +.Ss Dv ZIP_SOURCE_COMMIT_WRITE +Finish writing to the source. +Replace the original data with the newly written data. +Clean up temporary files or internal buffers. +Subsequently opening and reading from the source should return the +newly written data. +.Ss Dv ZIP_SOURCE_ERROR +Get error information. +.Ar data +points to an array of two ints, which should be filled with the libzip +error code and the corresponding system error code for the error that +occurred. +See +.Xr zip_errors 3 +for details on the error codes. +If the source stores error information in a zip_error_t, use +.Xr zip_error_to_data 3 +and return its return value. +Otherwise, return 2 * sizeof(int). +.Ss Dv ZIP_SOURCE_FREE +Clean up and free all resources, including +.Ar userdata . +The callback function will not be called again. +.Ss Dv ZIP_SOURCE_GET_FILE_ATTRIBUTES +Provide information about various data. +Then the data should be put in the appropriate entry in the passed +.Vt zip_file_attributes_t +argument, and the appropriate +.Dv ZIP_FILE_ATTRIBUTES_* +value must be or'ed into the +.Ar valid +member to denote that the corresponding data has been provided. +A +.Vt zip_file_attributes_t +structure can be initialized using +.Xr zip_file_attributes_init 3 . +.Bl -tag -width 10n +.It ASCII mode +If a file is a plaintext file in ASCII. +Can be used by extraction tools to automatically convert line endings +(part of the internal file attributes). +Member +.Ar ascii , +flag +.Dv ZIP_FILE_ATTRIBUTES_ASCII . +.It General Purpose Bit Flags (limited to Compression Flags) +The general purpose bit flag in the zip in the local and central +directory headers contain information about the compression method. +Member +.Ar general_purpose_bit_flags +and +.Ar general_purpose_bit_mask +to denote which members have been set; +flag +.Dv ZIP_FILE_ATTRIBUTES_GENERAL_PURPOSE_BIT_FLAGS . +.It External File Attributes +The external file attributes (usually operating system-specific). +Member +.Ar external_file_attributes , +flag +.Dv ZIP_FILE_ATTRIBUTES_EXTERNAL_FILE_ATTRIBUTES . +.It Version Needed +A minimum version needed required to unpack this entry (in the usual +"major * 10 + minor" format). +Member +.Ar version_needed , +flag +.Dv ZIP_FILE_ATTRIBUTES_VERSION_NEEDED . +.It Operating System +One of the operating systems as defined by the +.Dv ZIP_OPSYS_* +variables (see +.Pa zip.h ) . +This value affects the interpretation of the external file attributes. +Member +.Ar host_system , +flag +.Dv ZIP_FILE_ATTRIBUTES_HOST_SYSTEM . +.El +.Ss Dv ZIP_SOURCE_OPEN +Prepare for reading. +.Ss Dv ZIP_SOURCE_READ +Read data into the buffer +.Ar data +of size +.Ar len . +Return the number of bytes placed into +.Ar data +on success, and zero for end-of-file. +.Ss Dv ZIP_SOURCE_REMOVE +Remove the underlying file. +This is called if a zip archive is empty when closed. +.Ss Dv ZIP_SOURCE_ROLLBACK_WRITE +Abort writing to the source. +Discard written data. +Clean up temporary files or internal buffers. +Subsequently opening and reading from the source should return the +original data. +.Ss Dv ZIP_SOURCE_SEEK +Specify position to read next byte from, like +.Xr fseek 3 . +Use +.Xr ZIP_SOURCE_GET_ARGS 3 +to decode the arguments into the following struct: +.Bd -literal +struct zip_source_args_seek { + zip_int64_t offset; + int whence; +}; +.Ed +.Pp +If the size of the source's data is known, use +.Xr zip_source_seek_compute_offset 3 +to validate the arguments and compute the new offset. +.Ss Dv ZIP_SOURCE_SEEK_WRITE +Specify position to write next byte to, like +.Xr fseek 3 . +See +.Dv ZIP_SOURCE_SEEK +for details. +.Ss Dv ZIP_SOURCE_STAT +Get meta information for the input data. +.Ar data +points to an allocated +.Vt struct zip_stat , +which should be initialized using +.Xr zip_stat_init 3 +and then filled in. +.Pp +For uncompressed, unencrypted data, all information is optional. +However, fill in as much information as is readily available. +.Pp +If the data is compressed, +.Dv ZIP_STAT_COMP_METHOD , +.Dv ZIP_STAT_SIZE , +and +.Dv ZIP_STAT_CRC +must be filled in. +.Pp +If the data is encrypted, +.Dv ZIP_STAT_ENCRYPTION_METHOD , +.Dv ZIP_STAT_COMP_METHOD , +.Dv ZIP_STAT_SIZE , +and +.Dv ZIP_STAT_CRC +must be filled in. +.Pp +Information only available after the source has been read (e.g., size) +can be omitted in an earlier call. +.Em NOTE : +.Fn zip_source_function +may be called with this argument even after being called with +.Dv ZIP_SOURCE_CLOSE . +.Pp +Return sizeof(struct zip_stat) on success. +.Ss Dv ZIP_SOURCE_SUPPORTS +Return bitmap specifying which commands are supported. +Use +.Xr zip_source_make_command_bitmap 3 . +If this command is not implemented, the source is assumed to be a +read source without seek support. +.Ss Dv ZIP_SOURCE_TELL +Return the current read offset in the source, like +.Xr ftell 3 . +.Ss Dv ZIP_SOURCE_TELL_WRITE +Return the current write offset in the source, like +.Xr ftell 3 . +.Ss Dv ZIP_SOURCE_WRITE +Write data to the source. +Return number of bytes written. +.Ss Dv ZIP_SOURCE_SUPPORTS_REOPEN +This command is never actually invoked, support for it signals the +ability to handle multiple open/read/close cycles. +.Ss Return Values +Commands should return \-1 on error. +.Dv ZIP_SOURCE_ERROR +will be called to retrieve the error code. +On success, commands return 0, unless specified otherwise in the +description above. +.Ss Calling Conventions +The library will always issue +.Dv ZIP_SOURCE_OPEN +before issuing +.Dv ZIP_SOURCE_READ , +.Dv ZIP_SOURCE_SEEK , +or +.Dv ZIP_SOURCE_TELL . +When it no longer wishes to read from this source, it will issue +.Dv ZIP_SOURCE_CLOSE . +If the library wishes to read the data again, it will issue +.Dv ZIP_SOURCE_OPEN +a second time. +If the function is unable to provide the data again, it should +return \-1. +.Pp +.Dv ZIP_SOURCE_BEGIN_WRITE +or +.Dv ZIP_SOURCE_BEGIN_WRITE_CLONING +will be called before +.Dv ZIP_SOURCE_WRITE , +.Dv ZIP_SOURCE_SEEK_WRITE , +or +.Dv ZIP_SOURCE_TELL_WRITE . +When writing is complete, either +.Dv ZIP_SOURCE_COMMIT_WRITE +or +.Dv ZIP_SOURCE_ROLLBACK_WRITE +will be called. +.Pp +.Dv ZIP_SOURCE_ACCEPT_EMPTY , +.Dv ZIP_SOURCE_GET_FILE_ATTRIBUTES , +and +.Dv ZIP_SOURCE_STAT +can be issued at any time. +.Pp +.Dv ZIP_SOURCE_ERROR +will only be issued in response to the function +returning \-1. +.Pp +.Dv ZIP_SOURCE_FREE +will be the last command issued; +if +.Dv ZIP_SOURCE_OPEN +was called and succeeded, +.Dv ZIP_SOURCE_CLOSE +will be called before +.Dv ZIP_SOURCE_FREE , +and similarly for +.Dv ZIP_SOURCE_BEGIN_WRITE +or +.Dv ZIP_SOURCE_BEGIN_WRITE_CLONING +and +.Dv ZIP_SOURCE_COMMIT_WRITE +or +.Dv ZIP_SOURCE_ROLLBACK_WRITE . +.Sh RETURN VALUES +Upon successful completion, the created source is returned. +Otherwise, +.Dv NULL +is returned and the error code in +.Ar archive +or +.Ar error +is set to indicate the error (unless +it is +.Dv NULL ) . +.Sh ERRORS +.Fn zip_source_function +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_add 3 , +.Xr zip_file_attributes_init 3 , +.Xr zip_file_replace 3 , +.Xr zip_source 3 , +.Xr zip_stat_init 3 +.Sh HISTORY +.Fn zip_source_function +and +.Fn zip_source_function_create +were added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_is_deleted.html b/thirdparty/libzip-1.11.3/man/zip_source_is_deleted.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_is_deleted.man b/thirdparty/libzip-1.11.3/man/zip_source_is_deleted.man new file mode 100644 index 0000000..8bf67a3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_is_deleted.man @@ -0,0 +1,67 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_is_deleted.mdoc -- check if zip source is deleted +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_IS_DELETED" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_is_deleted\fR +\- check if zip_source is deleted +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_source_is_deleted\fR(\fIzip_source_t\ *source\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_source_is_deleted\fR() +returns whether the zip_source was deleted. +This can for example happen when all entries are removed from a zip archive. +.SH "RETURN VALUES" +\fBzip_source_is_deleted\fR() +returns 1 if the zip_source is deleted and 0 otherwise. +.SH "SEE ALSO" +libzip(3), +zip_source(3) +.SH "HISTORY" +\fBzip_source_is_deleted\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_is_deleted.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_is_deleted.mdoc new file mode 100644 index 0000000..af1c93b --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_is_deleted.mdoc @@ -0,0 +1,62 @@ +.\" zip_source_is_deleted.mdoc -- check if zip source is deleted +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_IS_DELETED 3 +.Os +.Sh NAME +.Nm zip_source_is_deleted +.Nd check if zip_source is deleted +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_source_is_deleted "zip_source_t *source" +.Sh DESCRIPTION +The function +.Fn zip_source_is_deleted +returns whether the zip_source was deleted. +This can for example happen when all entries are removed from a zip archive. +.Sh RETURN VALUES +.Fn zip_source_is_deleted +returns 1 if the zip_source is deleted and 0 otherwise. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 +.Sh HISTORY +.Fn zip_source_is_deleted +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_is_seekable.html b/thirdparty/libzip-1.11.3/man/zip_source_is_seekable.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_is_seekable.man b/thirdparty/libzip-1.11.3/man/zip_source_is_seekable.man new file mode 100644 index 0000000..bab9e64 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_is_seekable.man @@ -0,0 +1,70 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_seek.mdoc -- set read offset in source +.\" Copyright (C) 2023 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_IS_SEEKABLE" "3" "March 10, 2023" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_is_seekable\fR +\- check if a source supports seeking +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_source_is_seekable\fR(\fIzip_source_t\ *source\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_source_is_seekable\fR() +checks if +\fIsource\fR +supports seeking via +zip_source_seek(3). +.SH "RETURN VALUES" +If the source supports seeking, 1 is returned. +Otherwise, 0 is returned. +.SH "SEE ALSO" +libzip(3), +zip_source(3), +zip_source_seek(3) +.SH "HISTORY" +\fBzip_source_is_seekable\fR() +was added in libzip 1.10.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_is_seekable.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_is_seekable.mdoc new file mode 100644 index 0000000..c0d781b --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_is_seekable.mdoc @@ -0,0 +1,65 @@ +.\" zip_source_seek.mdoc -- set read offset in source +.\" Copyright (C) 2023 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd March 10, 2023 +.Dt ZIP_SOURCE_IS_SEEKABLE 3 +.Os +.Sh NAME +.Nm zip_source_is_seekable +.Nd check if a source supports seeking +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_source_is_seekable "zip_source_t *source" +.Sh DESCRIPTION +The function +.Fn zip_source_is_seekable +checks if +.Fa source +supports seeking via +.Xr zip_source_seek 3 . +.Sh RETURN VALUES +If the source supports seeking, 1 is returned. +Otherwise, 0 is returned. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_seek 3 +.Sh HISTORY +.Fn zip_source_is_seekable +was added in libzip 1.10.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_keep.html b/thirdparty/libzip-1.11.3/man/zip_source_keep.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_keep.man b/thirdparty/libzip-1.11.3/man/zip_source_keep.man new file mode 100644 index 0000000..9b8f734 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_keep.man @@ -0,0 +1,65 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_keep.mdoc -- increment reference count of zip data source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_KEEP" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_keep\fR +\- increment reference count of zip data source +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_source_keep\fR(\fIzip_source_t\ *source\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_source_keep\fR() +increments the reference count of +\fIsource\fR. +.SH "SEE ALSO" +libzip(3), +zip_source(3), +zip_source_free(3) +.SH "HISTORY" +\fBzip_source_keep\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_keep.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_keep.mdoc new file mode 100644 index 0000000..ac3bef5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_keep.mdoc @@ -0,0 +1,60 @@ +.\" zip_source_keep.mdoc -- increment reference count of zip data source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_KEEP 3 +.Os +.Sh NAME +.Nm zip_source_keep +.Nd increment reference count of zip data source +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft void +.Fn zip_source_keep "zip_source_t *source" +.Sh DESCRIPTION +The function +.Fn zip_source_keep +increments the reference count of +.Ar source . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_free 3 +.Sh HISTORY +.Fn zip_source_keep +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_layered.html b/thirdparty/libzip-1.11.3/man/zip_source_layered.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_layered.man b/thirdparty/libzip-1.11.3/man/zip_source_layered.man new file mode 100644 index 0000000..0ba257a --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_layered.man @@ -0,0 +1,173 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_layered.mdoc -- create layered source from function +.\" Copyright (C) 2004-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_LAYERED" "3" "January 20, 2023" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_layered\fR, +\fBzip_source_layered_create\fR +\- create layered data source from function +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_layered\fR(\fIzip_t\ *archive\fR, \fIzip_source_t\ *source\fR, \fIzip_source_layered_callback\ fn\fR, \fIvoid\ *userdata\fR); +.PD +.PP +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_layered_create\fR(\fIzip_source_t\ *source\fR, \fIzip_source_layered_callback\ fn\fR, \fIvoid\ *userdata\fR, \fIzip_error_t\ *error\fR); +.PD +.SH "DESCRIPTION" +The functions +\fBzip_source_layered\fR() +and +\fBzip_source_layered_create\fR() +create a layered zip source from the user-provided function +\fIfn\fR, +which must be of the following type: +.PP +\fItypedef zip_int64_t\fR +\fB\fR(*\zip_source_layered_callback\fR)\fP\fR(\fIzip_source_t\ *source\fR, \fIvoid\ *userdata\fR, \fIvoid\ *data\fR, \fIzip_uint64_t\ length\fR, \fIzip_source_cmd_t\ cmd\fR) +.PP +\fIarchive\fR +or +\fIerror\fR +are used for reporting errors and can be +\fRNULL\fR. +.PP +When called by the library, the first argument is the +\fIsource\fR +of the lower layer, the second argument is the +\fIuserdata\fR +argument supplied to the function. +The next two arguments are a buffer +\fIdata\fR +of size +\fIlength\fR +when data is passed in or expected to be returned, or else +\fRNULL\fR +and 0. +The last argument, +\fIcmd\fR, +specifies which action the function should perform. +.PP +See +zip_source_function(3) +for a description of the commands. +.PP +A layered source transforms the data or metadata of the source below in some way. +Layered sources can't support writing and are not sufficient to cleanly add support for additional compression or encryption methods. +This may be revised in a later release of libzip. +.PP +On success, the layered source takes ownership of +\fIsource\fR. +The caller should not free it. +.PP +The interaction with the lower layer depends on the command: +.SS "\fRZIP_SOURCE_ACCEPT_EMPTY\fR" +If the layered source supports this command, the lower layer is not called automatically. +Otherwise, the return value of the lower source is used. +.SS "\fRZIP_SOURCE_CLOSE\fR" +The lower layer is closed after the callback returns. +.SS "\fRZIP_SOURCE_ERROR\fR" +The lower layer is not called automatically. +If you need to retrieve error information from the lower layer, use +zip_error_set_from_source(3) +or +zip_source_pass_to_lower_layer(3). +.SS "\fRZIP_SOURCE_FREE\fR" +The lower layer is freed after the callback returns. +.SS "\fRZIP_SOURCE_GET_FILE_ATTRIBUTES\fR" +The attributes of the lower layer are merged with the attributes returned by the callback: information set by the callback wins over the lower layer, with the following exceptions: the higher +\fIversion_needed\fR +is used, and +\fIgeneral_purpose_bit_flags\fR +are only overwritten if the corresponding bit is set in +\fIgeneral_purpose_bit_mask\fR. +.SS "\fRZIP_SOURCE_OPEN\fR" +The lower layer is opened before the callback is called. +.SS "\fRZIP_SOURCE_READ\fR" +The lower layer is not called automatically. +.SS "\fRZIP_SOURCE_SEEK\fR" +The lower layer is not called automatically. +.SS "\fRZIP_SOURCE_STAT\fR" +\fIdata\fR +contains the stat information from the lower layer when the callback is called. +.SS "\fRZIP_SOURCE_SUPPORTS\fR" +\fIdata\fR +contains the bitmap of commands supported by the lower layer when the callback is called. +Since layered sources can't support writing, all commands related to writing are stripped from the returned support bitmap. +.SS "\fRZIP_SOURCE_TELL\fR" +The lower layer is not called automatically. +.SH "RETURN VALUES" +Upon successful completion, the created source is returned. +Otherwise, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +or +\fIerror\fR +is set to indicate the error (unless +it is +\fRNULL\fR). +.SH "ERRORS" +\fBzip_source_layered\fR() +fails if: +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.SH "SEE ALSO" +libzip(3), +zip_file_add(3), +zip_file_attributes_init(3), +zip_file_replace(3), +zip_source(3), +zip_source_function(3), +zip_source_pass_to_lower_layer(3) +.SH "HISTORY" +\fBzip_source_layered\fR() +and +\fBzip_source_layered_create\fR() +were added in libzip 1.10. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_layered.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_layered.mdoc new file mode 100644 index 0000000..4281dc5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_layered.mdoc @@ -0,0 +1,166 @@ +.\" zip_source_layered.mdoc -- create layered source from function +.\" Copyright (C) 2004-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd January 20, 2023 +.Dt ZIP_SOURCE_LAYERED 3 +.Os +.Sh NAME +.Nm zip_source_layered , +.Nm zip_source_layered_create +.Nd create layered data source from function +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_source_t * +.Fn zip_source_layered "zip_t *archive" "zip_source_t *source" "zip_source_layered_callback fn" "void *userdata" +.Ft zip_source_t * +.Fn zip_source_layered_create "zip_source_t *source" "zip_source_layered_callback fn" "void *userdata" "zip_error_t *error" +.Sh DESCRIPTION +The functions +.Fn zip_source_layered +and +.Fn zip_source_layered_create +create a layered zip source from the user-provided function +.Ar fn , +which must be of the following type: +.Pp +.Ft typedef zip_int64_t +.Fo \fR(*\zip_source_layered_callback\fR)\fP +.Fa "zip_source_t *source" "void *userdata" "void *data" "zip_uint64_t length" "zip_source_cmd_t cmd" +.Fc +.Pp +.Ar archive +or +.Ar error +are used for reporting errors and can be +.Dv NULL . +.Pp +When called by the library, the first argument is the +.Ar source +of the lower layer, the second argument is the +.Ar userdata +argument supplied to the function. +The next two arguments are a buffer +.Ar data +of size +.Ar length +when data is passed in or expected to be returned, or else +.Dv NULL +and 0. +The last argument, +.Ar cmd , +specifies which action the function should perform. +.Pp +See +.Xr zip_source_function 3 +for a description of the commands. +.Pp +A layered source transforms the data or metadata of the source below in some way. +Layered sources can't support writing and are not sufficient to cleanly add support for additional compression or encryption methods. +This may be revised in a later release of libzip. +.Pp +On success, the layered source takes ownership of +.Ar source . +The caller should not free it. +.Pp +The interaction with the lower layer depends on the command: +.Ss Dv ZIP_SOURCE_ACCEPT_EMPTY +If the layered source supports this command, the lower layer is not called automatically. +Otherwise, the return value of the lower source is used. +.Ss Dv ZIP_SOURCE_CLOSE +The lower layer is closed after the callback returns. +.Ss Dv ZIP_SOURCE_ERROR +The lower layer is not called automatically. +If you need to retrieve error information from the lower layer, use +.Xr zip_error_set_from_source 3 +or +.Xr zip_source_pass_to_lower_layer 3 . +.Ss Dv ZIP_SOURCE_FREE +The lower layer is freed after the callback returns. +.Ss Dv ZIP_SOURCE_GET_FILE_ATTRIBUTES +The attributes of the lower layer are merged with the attributes returned by the callback: information set by the callback wins over the lower layer, with the following exceptions: the higher +.Ar version_needed +is used, and +.Ar general_purpose_bit_flags +are only overwritten if the corresponding bit is set in +.Ar general_purpose_bit_mask . +.Ss Dv ZIP_SOURCE_OPEN +The lower layer is opened before the callback is called. +.Ss Dv ZIP_SOURCE_READ +The lower layer is not called automatically. +.Ss Dv ZIP_SOURCE_SEEK +The lower layer is not called automatically. +.Ss Dv ZIP_SOURCE_STAT +.Ar data +contains the stat information from the lower layer when the callback is called. +.Ss Dv ZIP_SOURCE_SUPPORTS +.Ar data +contains the bitmap of commands supported by the lower layer when the callback is called. +Since layered sources can't support writing, all commands related to writing are stripped from the returned support bitmap. +.Ss Dv ZIP_SOURCE_TELL +The lower layer is not called automatically. +.Sh RETURN VALUES +Upon successful completion, the created source is returned. +Otherwise, +.Dv NULL +is returned and the error code in +.Ar archive +or +.Ar error +is set to indicate the error (unless +it is +.Dv NULL ) . +.Sh ERRORS +.Fn zip_source_layered +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_add 3 , +.Xr zip_file_attributes_init 3 , +.Xr zip_file_replace 3 , +.Xr zip_source 3 , +.Xr zip_source_function 3 , +.Xr zip_source_pass_to_lower_layer 3 +.Sh HISTORY +.Fn zip_source_layered +and +.Fn zip_source_layered_create +were added in libzip 1.10. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_make_command_bitmap.html b/thirdparty/libzip-1.11.3/man/zip_source_make_command_bitmap.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_make_command_bitmap.man b/thirdparty/libzip-1.11.3/man/zip_source_make_command_bitmap.man new file mode 100644 index 0000000..6084d18 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_make_command_bitmap.man @@ -0,0 +1,67 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_make_command_bitmap -- create bitmap of supported source operations +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_MAKE_COMMAND_BITMAP" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_make_command_bitmap\fR +\- create bitmap of supported source operations +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_source_make_command_bitmap\fR(\fIzip_source_cmd_t\ command\fR, \fI...\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_source_make_command_bitmap\fR() +function returns a bitmap of source commands suitable as return value +for +\fRZIP_SOURCE_SUPPORTS\fR. +It includes all the commands from the argument list, which must be +terminated by \-1. +.SH "SEE ALSO" +libzip(3), +zip_source_function(3) +.SH "HISTORY" +\fBzip_source_make_command_bitmap\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_make_command_bitmap.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_make_command_bitmap.mdoc new file mode 100644 index 0000000..825f3aa --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_make_command_bitmap.mdoc @@ -0,0 +1,62 @@ +.\" zip_source_make_command_bitmap -- create bitmap of supported source operations +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_MAKE_COMMAND_BITMAP 3 +.Os +.Sh NAME +.Nm zip_source_make_command_bitmap +.Nd create bitmap of supported source operations +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_source_make_command_bitmap "zip_source_cmd_t command" "..." +.Sh DESCRIPTION +The +.Fn zip_source_make_command_bitmap +function returns a bitmap of source commands suitable as return value +for +.Dv ZIP_SOURCE_SUPPORTS . +It includes all the commands from the argument list, which must be +terminated by \-1. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source_function 3 +.Sh HISTORY +.Fn zip_source_make_command_bitmap +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_open.html b/thirdparty/libzip-1.11.3/man/zip_source_open.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_open.man b/thirdparty/libzip-1.11.3/man/zip_source_open.man new file mode 100644 index 0000000..440c441 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_open.man @@ -0,0 +1,75 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_open.mdoc -- open zip source for reading +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_OPEN" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_open\fR +\- open zip_source for reading +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_source_open\fR(\fIzip_source_t\ *source\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_source_open\fR() +opens +\fIsource\fR +for reading. +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIsource\fR +is set to indicate the error. +.SH "SEE ALSO" +libzip(3), +zip_source(3), +zip_source_begin_write(3), +zip_source_close(3), +zip_source_read(3), +zip_source_seek(3), +zip_source_tell(3) +.SH "HISTORY" +\fBzip_source_open\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_open.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_open.mdoc new file mode 100644 index 0000000..827f90a --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_open.mdoc @@ -0,0 +1,70 @@ +.\" zip_source_open.mdoc -- open zip source for reading +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_OPEN 3 +.Os +.Sh NAME +.Nm zip_source_open +.Nd open zip_source for reading +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_source_open "zip_source_t *source" +.Sh DESCRIPTION +The function +.Fn zip_source_open +opens +.Fa source +for reading. +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar source +is set to indicate the error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_begin_write 3 , +.Xr zip_source_close 3 , +.Xr zip_source_read 3 , +.Xr zip_source_seek 3 , +.Xr zip_source_tell 3 +.Sh HISTORY +.Fn zip_source_open +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_pass_to_lower_layer.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_pass_to_lower_layer.mdoc new file mode 100644 index 0000000..f3c550e --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_pass_to_lower_layer.mdoc @@ -0,0 +1,64 @@ +.\" zip_source_pass_to_lower_layer.mdoc -- pass command to lower layer +.\" Copyright (C) 2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 5, 2022 +.Dt ZIP_SOURCE_PASS_TO_LOWER_LAYER 3 +.Os +.Sh NAME +.Nm zip_source_pass_to_lower_layer +.Nd pass command to lower layer +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_source_pass_to_lower_layer "zip_source_t *source" "void *data" "zip_uint64_t length" "zip_source_cmd_t command" +.Sh DESCRIPTION +The functions +.Fn zip_source_pass_to_lower_layer +is used in a layered source callback to pass commands for which you don't want to change the result to the lower layer. +You can use it in the +.Dv default +case of the callback. +.Sh RETURN VALUES +The return value is meant to be returned by the callback. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_layered 3 +.Sh HISTORY +.Fn zip_source_pass_to_lower_layer +was added in libzip 1.10. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_read.html b/thirdparty/libzip-1.11.3/man/zip_source_read.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_read.man b/thirdparty/libzip-1.11.3/man/zip_source_read.man new file mode 100644 index 0000000..395cd1d --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_read.man @@ -0,0 +1,85 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_read.mdoc -- read data from zip source +.\" Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_READ" "3" "September 28, 2021" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_read\fR +\- read data from zip source +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_source_read\fR(\fIzip_source_t\ *source\fR, \fIvoid\ *data\fR, \fIzip_uint64_t\ len\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_source_read\fR() +reads up to +\fIlen\fR +bytes of data from +\fIsource\fR +at the current read offset into the buffer +\fIdata\fR. +.PP +The zip source +\fIsource\fR +has to be opened for reading by calling +zip_source_open(3) +first. +.SH "RETURN VALUES" +Upon successful completion the number of bytes read is returned. +When +\fBzip_source_read\fR() +is called after reaching the end of the file, 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIsource\fR +is set to indicate the error. +.SH "SEE ALSO" +libzip(3), +zip_source(3), +zip_source_seek(3), +zip_source_tell(3), +zip_source_write(3) +.SH "HISTORY" +\fBzip_source_read\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_read.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_read.mdoc new file mode 100644 index 0000000..8f04871 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_read.mdoc @@ -0,0 +1,80 @@ +.\" zip_source_read.mdoc -- read data from zip source +.\" Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd September 28, 2021 +.Dt ZIP_SOURCE_READ 3 +.Os +.Sh NAME +.Nm zip_source_read +.Nd read data from zip source +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_source_read "zip_source_t *source" "void *data" "zip_uint64_t len" +.Sh DESCRIPTION +The function +.Fn zip_source_read +reads up to +.Ar len +bytes of data from +.Ar source +at the current read offset into the buffer +.Ar data . +.Pp +The zip source +.Ar source +has to be opened for reading by calling +.Xr zip_source_open 3 +first. +.Sh RETURN VALUES +Upon successful completion the number of bytes read is returned. +When +.Fn zip_source_read +is called after reaching the end of the file, 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar source +is set to indicate the error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_seek 3 , +.Xr zip_source_tell 3 , +.Xr zip_source_write 3 +.Sh HISTORY +.Fn zip_source_read +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_rollback_write.html b/thirdparty/libzip-1.11.3/man/zip_source_rollback_write.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_rollback_write.man b/thirdparty/libzip-1.11.3/man/zip_source_rollback_write.man new file mode 100644 index 0000000..9bf122b --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_rollback_write.man @@ -0,0 +1,73 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_rollback_write.mdoc -- undo changes to zip source +.\" Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_ROLLBACK_WRITE" "3" "November 3, 2021" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_rollback_write\fR +\- undo changes to zip source +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_source_rollback_write\fR(\fIzip_source_t\ *source\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_source_rollback_write\fR() +reverts changes written to +\fIsource\fR, +restoring the data before +zip_source_begin_write(3) +was called. +Usually this removes temporary files or frees buffers. +.SH "SEE ALSO" +libzip(3), +zip_source(3), +zip_source_begin_write(3), +zip_source_commit_write(3), +zip_source_seek_write(3), +zip_source_tell_write(3), +zip_source_write(3) +.SH "HISTORY" +\fBzip_source_rollback_write\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_rollback_write.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_rollback_write.mdoc new file mode 100644 index 0000000..d749885 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_rollback_write.mdoc @@ -0,0 +1,68 @@ +.\" zip_source_rollback_write.mdoc -- undo changes to zip source +.\" Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd November 3, 2021 +.Dt ZIP_SOURCE_ROLLBACK_WRITE 3 +.Os +.Sh NAME +.Nm zip_source_rollback_write +.Nd undo changes to zip source +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft void +.Fn zip_source_rollback_write "zip_source_t *source" +.Sh DESCRIPTION +The function +.Fn zip_source_rollback_write +reverts changes written to +.Fa source , +restoring the data before +.Xr zip_source_begin_write 3 +was called. +Usually this removes temporary files or frees buffers. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_begin_write 3 , +.Xr zip_source_commit_write 3 , +.Xr zip_source_seek_write 3 , +.Xr zip_source_tell_write 3 , +.Xr zip_source_write 3 +.Sh HISTORY +.Fn zip_source_rollback_write +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_seek.html b/thirdparty/libzip-1.11.3/man/zip_source_seek.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_seek.man b/thirdparty/libzip-1.11.3/man/zip_source_seek.man new file mode 100644 index 0000000..2048c0a --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_seek.man @@ -0,0 +1,90 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_seek.mdoc -- set read offset in source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_SEEK" "3" "March 10, 2023" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_seek\fR +\- set read offset in zip source +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_source_seek\fR(\fIzip_source_t\ *source\fR, \fIzip_int64_t\ offset\fR, \fIint\ whence\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_source_seek\fR() +sets the current read offset for +\fIsource\fR. +Just like in +fseek(3), +depending on the +\fIwhence\fR +argument, the +\fIoffset\fR +is counted relative from: +.RS 6n +.TP 12n +\fRSEEK_SET\fR +start of file +.TP 12n +\fRSEEK_CUR\fR +current read offset in file +.TP 12n +\fRSEEK_END\fR +end of file +.RE +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIsource\fR +is set to indicate the error. +.SH "SEE ALSO" +libzip(3), +zip_source(3), +zip_source_is_seekable(3), +zip_source_read(3), +zip_source_tell(3) +.SH "HISTORY" +\fBzip_source_seek\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_seek.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_seek.mdoc new file mode 100644 index 0000000..face17c --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_seek.mdoc @@ -0,0 +1,82 @@ +.\" zip_source_seek.mdoc -- set read offset in source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd March 10, 2023 +.Dt ZIP_SOURCE_SEEK 3 +.Os +.Sh NAME +.Nm zip_source_seek +.Nd set read offset in zip source +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_source_seek "zip_source_t *source" "zip_int64_t offset" "int whence" +.Sh DESCRIPTION +The function +.Fn zip_source_seek +sets the current read offset for +.Fa source . +Just like in +.Xr fseek 3 , +depending on the +.Ar whence +argument, the +.Ar offset +is counted relative from: +.Bl -tag -width SEEK_CURXX -offset indent +.It Dv SEEK_SET +start of file +.It Dv SEEK_CUR +current read offset in file +.It Dv SEEK_END +end of file +.El +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar source +is set to indicate the error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_is_seekable 3 , +.Xr zip_source_read 3 , +.Xr zip_source_tell 3 +.Sh HISTORY +.Fn zip_source_seek +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_seek_compute_offset.html b/thirdparty/libzip-1.11.3/man/zip_source_seek_compute_offset.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_seek_compute_offset.man b/thirdparty/libzip-1.11.3/man/zip_source_seek_compute_offset.man new file mode 100644 index 0000000..a38c473 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_seek_compute_offset.man @@ -0,0 +1,85 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_seek_compute_offset.mdoc - validate arguments and compute offset +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_SEEK_COMPUTE_OFFSET" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_seek_compute_offset\fR +\- validate arguments and compute offset +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_source_seek_compute_offset\fR(\fIzip_uint64_t\ offset\fR, \fIzip_uint64_t\ length\fR, \fIvoid\ *data\fR, \fIzip_uint64_t\ data_length\fR, \fIzip_error_t\ *error\fR); +.PD +.SH "DESCRIPTION" +Use this function to compute the offset for a +\fRZIP_SOURCE_SEEK\fR +or +\fRZIP_SOURCE_SEEK_WRITE\fR +command. +\fIdata\fR +and +\fIdata_length\fR +are the arguments to the source callback, +\fIoffset\fR +is the current offset and +\fIlength\fR +is the length of the source data or, for +\fRZIP_SOURCE_SEEK_WRITE\fR, +the amount of data written. +.SH "RETURN VALUES" +On success, it returns the new offset, on error it returns \-1 and +sets +\fIerror\fR. +.SH "ERRORS" +\fBzip_source_seek_compute_offset\fR() +fails if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +One of the arguments is invalid or the seek would place the offset +outside the data. +.SH "SEE ALSO" +zip_source_function(3) +.SH "HISTORY" +\fBzip_source_seek_compute_offset\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_seek_compute_offset.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_seek_compute_offset.mdoc new file mode 100644 index 0000000..e849886 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_seek_compute_offset.mdoc @@ -0,0 +1,81 @@ +.\" zip_source_seek_compute_offset.mdoc - validate arguments and compute offset +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_SEEK_COMPUTE_OFFSET 3 +.Os +.Sh NAME +.Nm zip_source_seek_compute_offset +.Nd validate arguments and compute offset +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_source_seek_compute_offset "zip_uint64_t offset" "zip_uint64_t length" "void *data" "zip_uint64_t data_length" "zip_error_t *error" +.Sh DESCRIPTION +Use this function to compute the offset for a +.Dv ZIP_SOURCE_SEEK +or +.Dv ZIP_SOURCE_SEEK_WRITE +command. +.Ar data +and +.Ar data_length +are the arguments to the source callback, +.Ar offset +is the current offset and +.Ar length +is the length of the source data or, for +.Dv ZIP_SOURCE_SEEK_WRITE , +the amount of data written. +.Sh RETURN VALUES +On success, it returns the new offset, on error it returns \-1 and +sets +.Ar error . +.Sh ERRORS +.Fn zip_source_seek_compute_offset +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +One of the arguments is invalid or the seek would place the offset +outside the data. +.El +.Sh SEE ALSO +.Xr zip_source_function 3 +.Sh HISTORY +.Fn zip_source_seek_compute_offset +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_seek_write.html b/thirdparty/libzip-1.11.3/man/zip_source_seek_write.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_seek_write.man b/thirdparty/libzip-1.11.3/man/zip_source_seek_write.man new file mode 100644 index 0000000..661f432 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_seek_write.man @@ -0,0 +1,92 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_seek_write.mdoc -- set write offset in source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_SEEK_WRITE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_seek_write\fR +\- set write offset in zip source +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_source_seek_write\fR(\fIzip_source_t\ *source\fR, \fIzip_int64_t\ offset\fR, \fIint\ whence\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_source_seek_write\fR() +sets the current write offset for +\fIsource\fR. +Just like in +fseek(3), +depending on the +\fIwhence\fR +argument, the +\fIoffset\fR +is counted relative from: +.RS 6n +.TP 12n +\fRSEEK_SET\fR +start of file +.TP 12n +\fRSEEK_CUR\fR +current write offset in file +.TP 12n +\fRSEEK_END\fR +end of file +.RE +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIsource\fR +is set to indicate the error. +.SH "SEE ALSO" +libzip(3), +zip_source(3), +zip_source_begin_write(3), +zip_source_commit_write(3), +zip_source_rollback_write(3), +zip_source_tell_write(3), +zip_source_write(3) +.SH "HISTORY" +\fBzip_source_seek_write\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_seek_write.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_seek_write.mdoc new file mode 100644 index 0000000..832c31e --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_seek_write.mdoc @@ -0,0 +1,84 @@ +.\" zip_source_seek_write.mdoc -- set write offset in source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_SEEK_WRITE 3 +.Os +.Sh NAME +.Nm zip_source_seek_write +.Nd set write offset in zip source +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_source_seek_write "zip_source_t *source" "zip_int64_t offset" "int whence" +.Sh DESCRIPTION +The function +.Fn zip_source_seek_write +sets the current write offset for +.Fa source . +Just like in +.Xr fseek 3 , +depending on the +.Ar whence +argument, the +.Ar offset +is counted relative from: +.Bl -tag -width SEEK_CURXX -offset indent +.It Dv SEEK_SET +start of file +.It Dv SEEK_CUR +current write offset in file +.It Dv SEEK_END +end of file +.El +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar source +is set to indicate the error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_begin_write 3 , +.Xr zip_source_commit_write 3 , +.Xr zip_source_rollback_write 3 , +.Xr zip_source_tell_write 3 , +.Xr zip_source_write 3 +.Sh HISTORY +.Fn zip_source_seek_write +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_stat.html b/thirdparty/libzip-1.11.3/man/zip_source_stat.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_stat.man b/thirdparty/libzip-1.11.3/man/zip_source_stat.man new file mode 100644 index 0000000..252db06 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_stat.man @@ -0,0 +1,144 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_stat.mdoc -- get information about zip source +.\" Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_STAT" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_stat\fR +\- get information about zip_source +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_source_stat\fR(\fIzip_source_t\ *source\fR, \fIzip_stat_t\ *sb\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_source_stat\fR() +function obtains information about the zip source +\fIsource\fR +.PP +The +\fIsb\fR +argument is a pointer to a +\fIstruct zip_source_stat\fR +(shown below), into which information about the zip source is placed. +.nf +.sp +.RS 0n +struct zip_source_stat { + zip_uint64_t valid; /* which fields have valid values */ + const char *name; /* name of the file */ + zip_uint64_t index; /* index within archive */ + zip_uint64_t size; /* size of file (uncompressed) */ + zip_uint64_t comp_size; /* size of file (compressed) */ + time_t mtime; /* modification time */ + zip_uint32_t crc; /* crc of file data */ + zip_uint16_t comp_method; /* compression method used */ + zip_uint16_t encryption_method; /* encryption method used */ + zip_uint32_t flags; /* reserved for future use */ +}; +.RE +.fi +The structure pointed to by +\fIsb\fR +must be initialized with +\fBzip_stat_init\fR(\fI3\fR) +before calling +\fBzip_source_stat\fR(). +.PP +The +\fIvalid\fR +field of the structure specifies which other fields are valid. +Check if the flag defined by the following defines are in +\fIvalid\fR +before accessing the fields: +.RS 6n +.PD 0 +.TP 30n +\fRZIP_STAT_NAME\fR +\fIname\fR +.TP 30n +\fRZIP_STAT_INDEX\fR +\fIindex\fR +.TP 30n +\fRZIP_STAT_SIZE\fR +\fIsize\fR +.TP 30n +\fRZIP_STAT_COMP_SIZE\fR +\fIcomp_size\fR +.TP 30n +\fRZIP_STAT_MTIME\fR +\fImtime\fR +.TP 30n +\fRZIP_STAT_CRC\fR +\fIcrc\fR +.TP 30n +\fRZIP_STAT_COMP_METHOD\fR +\fIcomp_method\fR +.TP 30n +\fRZIP_STAT_ENCRYPTION_METHOD\fR +\fIencryption_method\fR +.TP 30n +\fRZIP_STAT_FLAGS\fR +\fIflags\fR +.RE +.PD +.PP +\fINOTE\fR: +Some fields may only be filled out after all data has been read from +the source, for example the +\fIcrc\fR +or +\fIsize\fR +fields. +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIsource\fR +is set to indicate the error. +.SH "SEE ALSO" +libzip(3), +zip_source(3) +.SH "HISTORY" +\fBzip_source_stat\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_stat.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_stat.mdoc new file mode 100644 index 0000000..8b13bef --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_stat.mdoc @@ -0,0 +1,125 @@ +.\" zip_source_stat.mdoc -- get information about zip source +.\" Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_STAT 3 +.Os +.Sh NAME +.Nm zip_source_stat +.Nd get information about zip_source +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_source_stat "zip_source_t *source" "zip_stat_t *sb" +.Sh DESCRIPTION +The +.Fn zip_source_stat +function obtains information about the zip source +.Ar source +.Pp +The +.Ar sb +argument is a pointer to a +.Ft struct zip_source_stat +(shown below), into which information about the zip source is placed. +.Bd -literal +struct zip_source_stat { + zip_uint64_t valid; /* which fields have valid values */ + const char *name; /* name of the file */ + zip_uint64_t index; /* index within archive */ + zip_uint64_t size; /* size of file (uncompressed) */ + zip_uint64_t comp_size; /* size of file (compressed) */ + time_t mtime; /* modification time */ + zip_uint32_t crc; /* crc of file data */ + zip_uint16_t comp_method; /* compression method used */ + zip_uint16_t encryption_method; /* encryption method used */ + zip_uint32_t flags; /* reserved for future use */ +}; +.Ed +The structure pointed to by +.Ar sb +must be initialized with +.Fn zip_stat_init 3 +before calling +.Fn zip_source_stat . +.Pp +The +.Ar valid +field of the structure specifies which other fields are valid. +Check if the flag defined by the following defines are in +.Ar valid +before accessing the fields: +.Bl -tag -width ZIP_STAT_ENCRYPTION_METHODXX -compact -offset indent +.It Dv ZIP_STAT_NAME +.Ar name +.It Dv ZIP_STAT_INDEX +.Ar index +.It Dv ZIP_STAT_SIZE +.Ar size +.It Dv ZIP_STAT_COMP_SIZE +.Ar comp_size +.It Dv ZIP_STAT_MTIME +.Ar mtime +.It Dv ZIP_STAT_CRC +.Ar crc +.It Dv ZIP_STAT_COMP_METHOD +.Ar comp_method +.It Dv ZIP_STAT_ENCRYPTION_METHOD +.Ar encryption_method +.It Dv ZIP_STAT_FLAGS +.Ar flags +.El +.Pp +.Em NOTE : +Some fields may only be filled out after all data has been read from +the source, for example the +.Ar crc +or +.Ar size +fields. +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar source +is set to indicate the error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 +.Sh HISTORY +.Fn zip_source_stat +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_tell.html b/thirdparty/libzip-1.11.3/man/zip_source_tell.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_tell.man b/thirdparty/libzip-1.11.3/man/zip_source_tell.man new file mode 100644 index 0000000..7608a55 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_tell.man @@ -0,0 +1,79 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_tell.mdoc -- report current read offset in source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_TELL" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_tell\fR +\- report current read offset in zip source +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_source_tell\fR(\fIzip_source_t\ *source\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_source_tell\fR() +returns the current read offset +for +\fIsource\fR. +The return value can be passed to +zip_source_seek(3) +with +\fIwhence\fR +set to +\fRSEEK_SET\fR +to return to the same location in the source. +.SH "RETURN VALUES" +Upon successful completion the current read offset is returned. +Otherwise, \-1 is returned and the error information in +\fIsource\fR +is set to indicate the error. +.SH "SEE ALSO" +libzip(3), +zip_source(3), +zip_source_read(3), +zip_source_tell_write(3) +.SH "HISTORY" +\fBzip_source_tell\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_tell.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_tell.mdoc new file mode 100644 index 0000000..168220c --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_tell.mdoc @@ -0,0 +1,74 @@ +.\" zip_source_tell.mdoc -- report current read offset in source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_TELL 3 +.Os +.Sh NAME +.Nm zip_source_tell +.Nd report current read offset in zip source +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_source_tell "zip_source_t *source" +.Sh DESCRIPTION +The function +.Fn zip_source_tell +returns the current read offset +for +.Fa source . +The return value can be passed to +.Xr zip_source_seek 3 +with +.Ar whence +set to +.Dv SEEK_SET +to return to the same location in the source. +.Sh RETURN VALUES +Upon successful completion the current read offset is returned. +Otherwise, \-1 is returned and the error information in +.Ar source +is set to indicate the error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_read 3 , +.Xr zip_source_tell_write 3 +.Sh HISTORY +.Fn zip_source_tell +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_tell_write.html b/thirdparty/libzip-1.11.3/man/zip_source_tell_write.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_tell_write.man b/thirdparty/libzip-1.11.3/man/zip_source_tell_write.man new file mode 100644 index 0000000..f84a516 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_tell_write.man @@ -0,0 +1,82 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_tell_write.mdoc -- report current write offset in source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_TELL_WRITE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_tell_write\fR +\- report current write offset in zip source +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_source_tell_write\fR(\fIzip_source_t\ *source\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_source_tell_write\fR() +returns the current write offset +for +\fIsource\fR. +The return value can be passed to +zip_source_seek_write(3) +with +\fIwhence\fR +set to +\fRSEEK_SET\fR +to return to the same location in the source. +.SH "RETURN VALUES" +Upon successful completion the current write offset is returned. +Otherwise, \-1 is returned and the error information in +\fIsource\fR +is set to indicate the error. +.SH "SEE ALSO" +libzip(3), +zip_source(3), +zip_source_begin_write(3), +zip_source_commit_write(3), +zip_source_rollback_write(3), +zip_source_tell(3), +zip_source_write(3) +.SH "HISTORY" +\fBzip_source_tell_write\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_tell_write.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_tell_write.mdoc new file mode 100644 index 0000000..202478c --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_tell_write.mdoc @@ -0,0 +1,77 @@ +.\" zip_source_tell_write.mdoc -- report current write offset in source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_TELL_WRITE 3 +.Os +.Sh NAME +.Nm zip_source_tell_write +.Nd report current write offset in zip source +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_source_tell_write "zip_source_t *source" +.Sh DESCRIPTION +The function +.Fn zip_source_tell_write +returns the current write offset +for +.Fa source . +The return value can be passed to +.Xr zip_source_seek_write 3 +with +.Ar whence +set to +.Dv SEEK_SET +to return to the same location in the source. +.Sh RETURN VALUES +Upon successful completion the current write offset is returned. +Otherwise, \-1 is returned and the error information in +.Ar source +is set to indicate the error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_begin_write 3 , +.Xr zip_source_commit_write 3 , +.Xr zip_source_rollback_write 3 , +.Xr zip_source_tell 3 , +.Xr zip_source_write 3 +.Sh HISTORY +.Fn zip_source_tell_write +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_win32a.html b/thirdparty/libzip-1.11.3/man/zip_source_win32a.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_win32a.man b/thirdparty/libzip-1.11.3/man/zip_source_win32a.man new file mode 100644 index 0000000..6e2898f --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_win32a.man @@ -0,0 +1,132 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_win32a.mdoc -- create data source using a win32 ANSI name +.\" Copyright (C) 2015-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_WIN32A" "3" "June 30, 2023" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_win32a\fR, +\fBzip_source_win32a_create\fR +\- create data source from a Windows ANSI file name +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_win32a\fR(\fIzip_t\ *archive\fR, \fIconst\ char\ *fname\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ len\fR); +.PD +.PP +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_win32a_create\fR(\fIconst\ char\ *fname\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ len\fR, \fIzip_error_t\ *error\fR); +.PD +.SH "DESCRIPTION" +The functions +\fBzip_source_win32a\fR() +and +\fBzip_source_win32a_create\fR() +create a zip source on Windows using a Windows ANSI name. +They open +\fIfname\fR +and read +\fIlen\fR +bytes from offset +\fIstart\fR +from it. +For a description of the +\fIlen\fR +argument, see +zip_source_file(3). +.PP +If the file supports seek, the source can be used to open a zip archive from. +.PP +The file is opened and read when the data from the source is used, usually by +\fBzip_close\fR() +or +\fBzip_open_from_source\fR(). +.SH "RETURN VALUES" +Upon successful completion, the created source is returned. +Otherwise, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +or +\fIerror\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_source_win32a\fR() +and +\fBzip_source_win32a_create\fR() +fail if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIfname\fR, +\fIstart\fR, +or +\fIlen\fR +are invalid. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.TP 19n +[\fRZIP_ER_OPEN\fR] +Opening +\fIfname\fR +failed. +.SH "SEE ALSO" +libzip(3), +zip_file_add(3), +zip_file_replace(3), +zip_source(3), +zip_source_file(3), +zip_source_win32handle(3), +zip_source_win32w(3) +.SH "HISTORY" +\fBzip_source_win32a\fR() +and +\fBzip_source_win32a_create\fR() +were added in libzip 1.0. +.PP +\fRZIP_LENGTH_TO_END\fR +and +\fRZIP_LENGTH_UNCHECKED\fR +were added in libzip 1.10.1. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_win32a.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_win32a.mdoc new file mode 100644 index 0000000..5bdc045 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_win32a.mdoc @@ -0,0 +1,121 @@ +.\" zip_source_win32a.mdoc -- create data source using a win32 ANSI name +.\" Copyright (C) 2015-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd June 30, 2023 +.Dt ZIP_SOURCE_WIN32A 3 +.Os +.Sh NAME +.Nm zip_source_win32a , +.Nm zip_source_win32a_create +.Nd create data source from a Windows ANSI file name +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_source_t * +.Fn zip_source_win32a "zip_t *archive" "const char *fname" "zip_uint64_t start" "zip_int64_t len" +.Ft zip_source_t * +.Fn zip_source_win32a_create "const char *fname" "zip_uint64_t start" "zip_int64_t len" "zip_error_t *error" +.Sh DESCRIPTION +The functions +.Fn zip_source_win32a +and +.Fn zip_source_win32a_create +create a zip source on Windows using a Windows ANSI name. +They open +.Ar fname +and read +.Ar len +bytes from offset +.Ar start +from it. +For a description of the +.Ar len +argument, see +.Xr zip_source_file 3 . +.Pp +If the file supports seek, the source can be used to open a zip archive from. +.Pp +The file is opened and read when the data from the source is used, usually by +.Fn zip_close +or +.Fn zip_open_from_source . +.Sh RETURN VALUES +Upon successful completion, the created source is returned. +Otherwise, +.Dv NULL +is returned and the error code in +.Ar archive +or +.Ar error +is set to indicate the error. +.Sh ERRORS +.Fn zip_source_win32a +and +.Fn zip_source_win32a_create +fail if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar fname , +.Ar start , +or +.Ar len +are invalid. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.It Bq Er ZIP_ER_OPEN +Opening +.Ar fname +failed. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_add 3 , +.Xr zip_file_replace 3 , +.Xr zip_source 3 , +.Xr zip_source_file 3 , +.Xr zip_source_win32handle 3 , +.Xr zip_source_win32w 3 +.Sh HISTORY +.Fn zip_source_win32a +and +.Fn zip_source_win32a_create +were added in libzip 1.0. +.Pp +.Dv ZIP_LENGTH_TO_END +and +.Dv ZIP_LENGTH_UNCHECKED +were added in libzip 1.10.1. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_win32handle.html b/thirdparty/libzip-1.11.3/man/zip_source_win32handle.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_win32handle.man b/thirdparty/libzip-1.11.3/man/zip_source_win32handle.man new file mode 100644 index 0000000..0aeba20 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_win32handle.man @@ -0,0 +1,120 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_handle.mdoc -- create data source from a Windows file handle +.\" Copyright (C) 2015-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_WIN32HANDLE" "3" "May 14, 2024" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_win32handle\fR, +\fBzip_source_win32handle_create\fR +\- create data source from a Windows file handle +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_win32handle\fR(\fIzip_t\ *archive\fR, \fIHANDLE\ h\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ len\fR); +.PD +.PP +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_win32handle_create\fR(\fIHANDLE\ h\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ len\fR, \fIzip_error_t\ *error\fR); +.PD +.SH "DESCRIPTION" +The functions +\fBzip_source_win32handle\fR() +and +\fBzip_source_win32handle_create\fR() +create a zip source from a Windows file handle. +They read +\fIlen\fR +bytes from offset +\fIstart\fR +from it. +If +\fIlen\fR +is 0 or \-1, the whole file (starting from +\fIstart\fR) +is used. +.PP +If the file supports seek, the source can be used to open a zip archive from. +.PP +The file is opened and read when the data from the source is used, usually by +\fBzip_close\fR() +or +\fBzip_open_from_source\fR(). +.SH "RETURN VALUES" +Upon successful completion, the created source is returned. +Otherwise, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +or +\fIerror\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_source_w32handle\fR() +and +\fBzip_source_w32handle_create\fR() +fail if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIh\fR, +\fIstart\fR, +or +\fIlen\fR +are invalid. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.SH "SEE ALSO" +libzip(3), +zip_file_add(3), +zip_file_replace(3), +zip_source(3), +zip_source_win32a(3), +zip_source_win32w(3) +.SH "HISTORY" +\fBzip_source_win32handle\fR() +and +\fBzip_source_win32handle_create\fR() +were added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_win32handle.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_win32handle.mdoc new file mode 100644 index 0000000..c0c47b6 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_win32handle.mdoc @@ -0,0 +1,110 @@ +.\" zip_source_handle.mdoc -- create data source from a Windows file handle +.\" Copyright (C) 2015-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd May 14, 2024 +.Dt ZIP_SOURCE_WIN32HANDLE 3 +.Os +.Sh NAME +.Nm zip_source_win32handle , +.Nm zip_source_win32handle_create +.Nd create data source from a Windows file handle +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_source_t * +.Fn zip_source_win32handle "zip_t *archive" "HANDLE h" "zip_uint64_t start" "zip_int64_t len" +.Ft zip_source_t * +.Fn zip_source_win32handle_create "HANDLE h" "zip_uint64_t start" "zip_int64_t len" "zip_error_t *error" +.Sh DESCRIPTION +The functions +.Fn zip_source_win32handle +and +.Fn zip_source_win32handle_create +create a zip source from a Windows file handle. +They read +.Ar len +bytes from offset +.Ar start +from it. +If +.Ar len +is 0 or \-1, the whole file (starting from +.Ar start ) +is used. +.Pp +If the file supports seek, the source can be used to open a zip archive from. +.Pp +The file is opened and read when the data from the source is used, usually by +.Fn zip_close +or +.Fn zip_open_from_source . +.Sh RETURN VALUES +Upon successful completion, the created source is returned. +Otherwise, +.Dv NULL +is returned and the error code in +.Ar archive +or +.Ar error +is set to indicate the error. +.Sh ERRORS +.Fn zip_source_w32handle +and +.Fn zip_source_w32handle_create +fail if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar h , +.Ar start , +or +.Ar len +are invalid. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_add 3 , +.Xr zip_file_replace 3 , +.Xr zip_source 3 , +.Xr zip_source_win32a 3 , +.Xr zip_source_win32w 3 +.Sh HISTORY +.Fn zip_source_win32handle +and +.Fn zip_source_win32handle_create +were added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_win32w.html b/thirdparty/libzip-1.11.3/man/zip_source_win32w.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_win32w.man b/thirdparty/libzip-1.11.3/man/zip_source_win32w.man new file mode 100644 index 0000000..39af013 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_win32w.man @@ -0,0 +1,130 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_win32w.mdoc -- create data source using a win32 Unicode name +.\" Copyright (C) 2015-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_WIN32W" "3" "June 30, 2023" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_win32w\fR, +\fBzip_source_win32w_create\fR +\- create data source from a Windows Unicode file name +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_win32w\fR(\fIzip_t\ *archive\fR, \fIconst\ wchar_t\ *fname\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ len\fR); +.PD +.PP +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_win32w_create\fR(\fIconst\ wchar_t\ *fname\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ len\fR, \fIzip_error_t\ *error\fR); +.PD +.SH "DESCRIPTION" +The functions +\fBzip_source_win32w\fR() +and +\fBzip_source_win32w_create\fR() +create a zip source on Windows using a Windows Unicode name. +They open +\fIfname\fR +and read +\fIlen\fR +bytes from offset +\fIstart\fR +from it. +For a description of the +\fIlen\fR +argument, see +zip_source_file(3). +.PP +If the file supports seek, the source can be used to open a zip archive from. +.PP +The file is opened and read when the data from the source is used, usually by +\fBzip_close\fR() +or +\fBzip_open_from_source\fR(). +.SH "RETURN VALUES" +Upon successful completion, the created source is returned. +Otherwise, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +or +\fIerror\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_source_win32w\fR() +and +\fBzip_source_win32w_create\fR() +fail if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIfname\fR, +\fIstart\fR, +or +\fIlen\fR +are invalid. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.TP 19n +[\fRZIP_ER_OPEN\fR] +Opening +\fIfname\fR +failed. +.SH "SEE ALSO" +libzip(3), +zip_file_add(3), +zip_file_replace(3), +zip_source(3), +zip_source_file(3), +zip_source_win32a(3), +zip_source_win32handle(3) +.SH "HISTORY" +\fBzip_source_win32w\fR() +was added in libzip 1.0. +.PP +\fRZIP_LENGTH_TO_END\fR +and +\fRZIP_LENGTH_UNCHECKED\fR +were added in libzip 1.10.1. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_win32w.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_win32w.mdoc new file mode 100644 index 0000000..6f33fd7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_win32w.mdoc @@ -0,0 +1,119 @@ +.\" zip_source_win32w.mdoc -- create data source using a win32 Unicode name +.\" Copyright (C) 2015-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd June 30, 2023 +.Dt ZIP_SOURCE_WIN32W 3 +.Os +.Sh NAME +.Nm zip_source_win32w , +.Nm zip_source_win32w_create +.Nd create data source from a Windows Unicode file name +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_source_t * +.Fn zip_source_win32w "zip_t *archive" "const wchar_t *fname" "zip_uint64_t start" "zip_int64_t len" +.Ft zip_source_t * +.Fn zip_source_win32w_create "const wchar_t *fname" "zip_uint64_t start" "zip_int64_t len" "zip_error_t *error" +.Sh DESCRIPTION +The functions +.Fn zip_source_win32w +and +.Fn zip_source_win32w_create +create a zip source on Windows using a Windows Unicode name. +They open +.Ar fname +and read +.Ar len +bytes from offset +.Ar start +from it. +For a description of the +.Ar len +argument, see +.Xr zip_source_file 3 . +.Pp +If the file supports seek, the source can be used to open a zip archive from. +.Pp +The file is opened and read when the data from the source is used, usually by +.Fn zip_close +or +.Fn zip_open_from_source . +.Sh RETURN VALUES +Upon successful completion, the created source is returned. +Otherwise, +.Dv NULL +is returned and the error code in +.Ar archive +or +.Ar error +is set to indicate the error. +.Sh ERRORS +.Fn zip_source_win32w +and +.Fn zip_source_win32w_create +fail if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar fname , +.Ar start , +or +.Ar len +are invalid. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.It Bq Er ZIP_ER_OPEN +Opening +.Ar fname +failed. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_add 3 , +.Xr zip_file_replace 3 , +.Xr zip_source 3 , +.Xr zip_source_file 3 , +.Xr zip_source_win32a 3 , +.Xr zip_source_win32handle 3 +.Sh HISTORY +.Fn zip_source_win32w +was added in libzip 1.0. +.Pp +.Dv ZIP_LENGTH_TO_END +and +.Dv ZIP_LENGTH_UNCHECKED +were added in libzip 1.10.1. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_window_create.html b/thirdparty/libzip-1.11.3/man/zip_source_window_create.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_window_create.man b/thirdparty/libzip-1.11.3/man/zip_source_window_create.man new file mode 100644 index 0000000..39ca061 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_window_create.man @@ -0,0 +1,103 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_window_create.mdoc -- create zip data source overlay +.\" Copyright (C) 2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_WINDOW_CREATE" "3" "April 29, 2021" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_window_create\fR +\- create zip data source overlay +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_window_create\fR(\fIzip_source_t\ *source\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ len\fR, \fIzip_error_t\ *error\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_source_window_create\fR() +function create a zip source from an underlying zip source, +restricting access to a particular window starting at byte +\fIstart\fR +and having size +\fIlen\fR. +If +\fIlen\fR +is \-1, the window spans to the end of the underlying source. +.PP +\fBzip_source_window\fR() +and +\fBzip_source_window_create\fR() +don't take ownership of +\fIsource\fR. +The caller is responsible for freeing it. +(This is different to other layered sources.) +.SH "RETURN VALUES" +Upon successful completion, the created source is returned. +Otherwise, +\fRNULL\fR +is returned and the error code in +\fIerror\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_source_window_create\fR() +fails if: +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIsrc\fR +is +\fRNULL\fR; +there is an integer overflow adding +\fIstart\fR +and +\fIlen\fR; +or +\fIlen\fR +is less than \-1. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.SH "SEE ALSO" +libzip(3), +zip_source(3) +.SH "HISTORY" +\fBzip_source_window_create\fR() +was added in libzip 1.8.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_window_create.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_window_create.mdoc new file mode 100644 index 0000000..4774491 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_window_create.mdoc @@ -0,0 +1,98 @@ +.\" zip_source_window_create.mdoc -- create zip data source overlay +.\" Copyright (C) 2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd April 29, 2021 +.Dt ZIP_SOURCE_WINDOW_CREATE 3 +.Os +.Sh NAME +.Nm zip_source_window_create +.Nd create zip data source overlay +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_source_t * +.Fn zip_source_window_create "zip_source_t *source" "zip_uint64_t start" "zip_int64_t len" "zip_error_t *error" +.Sh DESCRIPTION +The +.Fn zip_source_window_create +function create a zip source from an underlying zip source, +restricting access to a particular window starting at byte +.Ar start +and having size +.Ar len . +If +.Ar len +is \-1, the window spans to the end of the underlying source. +.Pp +.Fn zip_source_window +and +.Fn zip_source_window_create +don't take ownership of +.Ar source . +The caller is responsible for freeing it. +(This is different to other layered sources.) +.Sh RETURN VALUES +Upon successful completion, the created source is returned. +Otherwise, +.Dv NULL +is returned and the error code in +.Ar error +is set to indicate the error. +.Sh ERRORS +.Fn zip_source_window_create +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_INVAL +.Ar src +is +.Dv NULL ; +there is an integer overflow adding +.Ar start +and +.Ar len ; +or +.Ar len +is less than \-1. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 +.Sh HISTORY +.Fn zip_source_window_create +was added in libzip 1.8.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_write.html b/thirdparty/libzip-1.11.3/man/zip_source_write.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_write.man b/thirdparty/libzip-1.11.3/man/zip_source_write.man new file mode 100644 index 0000000..574cc4d --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_write.man @@ -0,0 +1,85 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_write.mdoc -- write data to zip source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_WRITE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_write\fR +\- write data to zip source +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_int64_t\fR +.br +.PD 0 +.HP 4n +\fBzip_source_write\fR(\fIzip_source_t\ *source\fR, \fIconst\ void\ *data\fR, \fIzip_uint64_t\ len\fR); +.PD +.SH "DESCRIPTION" +The function +\fBzip_source_write\fR() +writes +\fIlen\fR +bytes from the buffer +\fIdata\fR +to the zip source +\fIsource\fR +at the current write offset. +.PP +The zip source +\fIsource\fR +has to be prepared for writing by calling +zip_source_begin_write(3) +first. +.SH "RETURN VALUES" +Upon successful completion the number of bytes written is returned. +Otherwise, \-1 is returned and the error information in +\fIsource\fR +is set to indicate the error. +.SH "SEE ALSO" +libzip(3), +zip_source(3), +zip_source_begin_write(3), +zip_source_commit_write(3), +zip_source_rollback_write(3), +zip_source_seek_write(3), +zip_source_tell_write(3) +.SH "HISTORY" +\fBzip_source_write\fR() +was added in libzip 1.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_write.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_write.mdoc new file mode 100644 index 0000000..9b47082 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_write.mdoc @@ -0,0 +1,80 @@ +.\" zip_source_write.mdoc -- write data to zip source +.\" Copyright (C) 2014-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_SOURCE_WRITE 3 +.Os +.Sh NAME +.Nm zip_source_write +.Nd write data to zip source +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_int64_t +.Fn zip_source_write "zip_source_t *source" "const void *data" "zip_uint64_t len" +.Sh DESCRIPTION +The function +.Fn zip_source_write +writes +.Ar len +bytes from the buffer +.Ar data +to the zip source +.Ar source +at the current write offset. +.Pp +The zip source +.Ar source +has to be prepared for writing by calling +.Xr zip_source_begin_write 3 +first. +.Sh RETURN VALUES +Upon successful completion the number of bytes written is returned. +Otherwise, \-1 is returned and the error information in +.Ar source +is set to indicate the error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_source 3 , +.Xr zip_source_begin_write 3 , +.Xr zip_source_commit_write 3 , +.Xr zip_source_rollback_write 3 , +.Xr zip_source_seek_write 3 , +.Xr zip_source_tell_write 3 +.Sh HISTORY +.Fn zip_source_write +was added in libzip 1.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_zip.html b/thirdparty/libzip-1.11.3/man/zip_source_zip.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_zip.man b/thirdparty/libzip-1.11.3/man/zip_source_zip.man new file mode 100644 index 0000000..72c80e3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_zip.man @@ -0,0 +1,159 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_zip.mdoc -- create data source from zip file +.\" Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_ZIP" "3" "January 23, 2023" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_zip\fR, +\fBzip_source_zip_create\fR +\- create data source from zip file (obsolete interface) +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_zip\fR(\fIzip_t\ *archive\fR, \fIzip_t\ *srcarchive\fR, \fIzip_uint64_t\ srcidx\fR, \fIzip_flags_t\ flags\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ len\fR); +.PD +.PP +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_zip_create\fR(\fIzip_t\ *srcarchive\fR, \fIzip_uint64_t\ srcidx\fR, \fIzip_flags_t\ flags\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ len\fR, \fIzip_error_t\ *error\fR); +.PD +.SH "DESCRIPTION" +The functions +\fBzip_source_zip\fR() +and +\fBzip_source_zip_create\fR() +are the obsolete versions of +zip_source_zip_file(3) +or +zip_source_zip_file_create(3) +respectively. +If you want to get the compressed data of the complete file, use +.RS 6n +zip_source_zip_file(za, source_archive, source_index, ZIP_FL_COMPRESSED, 0, -1, NULL) +.RE +.PP +The functions +\fBzip_source_zip\fR() +and +\fBzip_source_zip_create\fR() +create a zip source from a file in a zip archive. +The +\fIsrcarchive\fR +argument is the (open) zip archive containing the source zip file +at index +\fIsrcidx\fR. +\fIlen\fR +bytes from offset +\fIstart\fR +will be used in the zip_source. +If +\fIlen\fR +is 0 or \-1, the rest of the file, starting from +\fIstart\fR, +is used. +If +\fIstart\fR +is zero and +\fIlen\fR +is \-1, the whole file will be copied without decompressing it. +.PP +Supported flags are: +.TP 14n +\fRZIP_FL_UNCHANGED\fR +Try to get the original data without any changes that may have been +made to +\fIsrcarchive\fR +after opening it. +.SH "RETURN VALUES" +Upon successful completion, the created source is returned. +Otherwise, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +or +\fIerror\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_source_zip\fR() +and +\fBzip_source_zip_create\fR() +fail if: +.TP 19n +[\fRZIP_ER_CHANGED\fR] +Unchanged data was requested, but it is not available. +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIsrcarchive\fR, +\fIsrcidx\fR, +\fIstart\fR, +or +\fIlen\fR +are invalid. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.PD 0 +.PP +Additionally, it can return all error codes from +\fBzip_stat_index\fR() +and +\fBzip_fopen_index\fR(). +.PD +.SH "SEE ALSO" +libzip(3), +zip_file_add(3), +zip_file_replace(3), +zip_source(3) +.SH "HISTORY" +\fBzip_source_zip\fR() +was added in libzip 1.0. +\fBzip_source_zip_create\fR() +was added in libzip 1.8.0. +Both were deprecated in libzip 1.10.0. +Use +\fBzip_source_zip_file\fR() +or +\fBzip_source_zip_file_create\fR() +instead. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_zip.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_zip.mdoc new file mode 100644 index 0000000..acc96bf --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_zip.mdoc @@ -0,0 +1,144 @@ +.\" zip_source_zip.mdoc -- create data source from zip file +.\" Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd January 23, 2023 +.Dt ZIP_SOURCE_ZIP 3 +.Os +.Sh NAME +.Nm zip_source_zip , +.Nm zip_source_zip_create +.Nd create data source from zip file (obsolete interface) +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_source_t * +.Fn zip_source_zip "zip_t *archive" "zip_t *srcarchive" "zip_uint64_t srcidx" "zip_flags_t flags" "zip_uint64_t start" "zip_int64_t len" +.Ft zip_source_t * +.Fn zip_source_zip_create "zip_t *srcarchive" "zip_uint64_t srcidx" "zip_flags_t flags" "zip_uint64_t start" "zip_int64_t len" "zip_error_t *error" +.Sh DESCRIPTION +The functions +.Fn zip_source_zip +and +.Fn zip_source_zip_create +are the obsolete versions of +.Xr zip_source_zip_file 3 +or +.Xr zip_source_zip_file_create 3 +respectively. +If you want to get the compressed data of the complete file, use +.Dl zip_source_zip_file(za, source_archive, source_index, ZIP_FL_COMPRESSED, 0, -1, NULL) +.Pp +The functions +.Fn zip_source_zip +and +.Fn zip_source_zip_create +create a zip source from a file in a zip archive. +The +.Ar srcarchive +argument is the (open) zip archive containing the source zip file +at index +.Ar srcidx . +.Ar len +bytes from offset +.Ar start +will be used in the zip_source. +If +.Ar len +is 0 or \-1, the rest of the file, starting from +.Ar start , +is used. +If +.Ar start +is zero and +.Ar len +is \-1, the whole file will be copied without decompressing it. +.Pp +Supported flags are: +.Bl -tag -width Dv +.It Dv ZIP_FL_UNCHANGED +Try to get the original data without any changes that may have been +made to +.Ar srcarchive +after opening it. +.El +.Sh RETURN VALUES +Upon successful completion, the created source is returned. +Otherwise, +.Dv NULL +is returned and the error code in +.Ar archive +or +.Ar error +is set to indicate the error. +.Sh ERRORS +.Fn zip_source_zip +and +.Fn zip_source_zip_create +fail if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_CHANGED +Unchanged data was requested, but it is not available. +.It Bq Er ZIP_ER_INVAL +.Ar srcarchive , +.Ar srcidx , +.Ar start , +or +.Ar len +are invalid. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.El +Additionally, it can return all error codes from +.Fn zip_stat_index +and +.Fn zip_fopen_index . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_add 3 , +.Xr zip_file_replace 3 , +.Xr zip_source 3 +.Sh HISTORY +.Fn zip_source_zip +was added in libzip 1.0. +.Fn zip_source_zip_create +was added in libzip 1.8.0. +Both were deprecated in libzip 1.10.0. +Use +.Fn zip_source_zip_file +or +.Fn zip_source_zip_file_create +instead. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_source_zip_file.html b/thirdparty/libzip-1.11.3/man/zip_source_zip_file.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_source_zip_file.man b/thirdparty/libzip-1.11.3/man/zip_source_zip_file.man new file mode 100644 index 0000000..0aedab4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_zip_file.man @@ -0,0 +1,159 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_source_zip_file.mdoc -- create data source from zip file +.\" Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_SOURCE_ZIP_FILE" "3" "March 10, 2023" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_source_zip_file\fR, +\fBzip_source_zip_file_create\fR +\- create data source from zip file +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_zip_file\fR(\fIzip_t\ *archive\fR, \fIzip_t\ *srcarchive\fR, \fIzip_uint64_t\ srcidx\fR, \fIzip_flags_t\ flags\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ length\fR, \fIconst\ char\ *password\fR); +.PD +.PP +\fIzip_source_t *\fR +.br +.PD 0 +.HP 4n +\fBzip_source_zip_file_create\fR(\fIzip_t\ *srcarchive\fR, \fIzip_uint64_t\ srcidx\fR, \fIzip_flags_t\ flags\fR, \fIzip_uint64_t\ start\fR, \fIzip_int64_t\ length\fR, \fIconst\ char\ *password\fR, \fIzip_error_t\ *error\fR); +.PD +.SH "DESCRIPTION" +The functions +\fBzip_source_zip_file\fR() +and +\fBzip_source_zip_file_create\fR() +create a zip source from a file in a zip archive. +The +\fIsrcarchive\fR +argument is the (open) zip archive containing the source zip file +at index +\fIsrcidx\fR. +\fIlength\fR +bytes from offset +\fIstart\fR +will be used in the zip_source. +If +\fIlength\fR +is \-1, the rest of the file, starting from +\fIstart\fR, +is used. +.PP +If you intend to copy a file from one archive to another, using the flag +\fRZIP_FL_COMPRESSED\fR +is more efficient, as it avoids recompressing the file data. +.PP +Supported flags are: +.TP 22n +\fRZIP_FL_COMPRESSED\fR +Get the compressed data. +This is only supported if the complete file data is requested +(\fIstart\fR +== 0 and +\fIlength\fR +== \-1). +This is not supported for changed data. +Default is uncompressed. +.TP 22n +\fRZIP_FL_ENCRYPTED\fR +Get the encrypted data. +(This flag implies +\fRZIP_FL_COMPRESSED\fR.) +This is only supported if the complete file data is requested +(\fIstart\fR +== 0 and +\fIlength\fR +== \-1). +Default is decrypted. +.TP 22n +\fRZIP_FL_UNCHANGED\fR +Try to get the original data without any changes that may have been +made to +\fIsrcarchive\fR +after opening it. +.SH "RETURN VALUES" +Upon successful completion, the created source is returned. +Otherwise, +\fRNULL\fR +is returned and the error code in +\fIarchive\fR +or +\fIerror\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_source_zip_file\fR() +and +\fBzip_source_zip_file_create\fR() +fail if: +.TP 19n +[\fRZIP_ER_CHANGED\fR] +Unchanged data was requested, but it is not available. +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIsrcarchive\fR, +\fIsrcidx\fR, +\fIstart\fR, +or +\fIlength\fR +are invalid. +.TP 19n +[\fRZIP_ER_MEMORY\fR] +Required memory could not be allocated. +.PD 0 +.PP +Additionally, it can return all error codes from +\fBzip_stat_index\fR() +and +\fBzip_fopen_index\fR(). +.PD +.SH "SEE ALSO" +libzip(3), +zip_file_add(3), +zip_file_replace(3), +zip_source(3) +.SH "HISTORY" +\fBzip_source_zip_file\fR() +and +\fBzip_source_zip_file_create\fR() +were added in libzip 1.10.0. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_source_zip_file.mdoc b/thirdparty/libzip-1.11.3/man/zip_source_zip_file.mdoc new file mode 100644 index 0000000..fee9d49 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_source_zip_file.mdoc @@ -0,0 +1,144 @@ +.\" zip_source_zip_file.mdoc -- create data source from zip file +.\" Copyright (C) 2004-2021 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd March 10, 2023 +.Dt ZIP_SOURCE_ZIP_FILE 3 +.Os +.Sh NAME +.Nm zip_source_zip_file , +.Nm zip_source_zip_file_create +.Nd create data source from zip file +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft zip_source_t * +.Fn zip_source_zip_file "zip_t *archive" "zip_t *srcarchive" "zip_uint64_t srcidx" "zip_flags_t flags" "zip_uint64_t start" "zip_int64_t length" "const char *password" +.Ft zip_source_t * +.Fn zip_source_zip_file_create "zip_t *srcarchive" "zip_uint64_t srcidx" "zip_flags_t flags" "zip_uint64_t start" "zip_int64_t length" "const char *password" "zip_error_t *error" +.Sh DESCRIPTION +The functions +.Fn zip_source_zip_file +and +.Fn zip_source_zip_file_create +create a zip source from a file in a zip archive. +The +.Ar srcarchive +argument is the (open) zip archive containing the source zip file +at index +.Ar srcidx . +.Ar length +bytes from offset +.Ar start +will be used in the zip_source. +If +.Ar length +is \-1, the rest of the file, starting from +.Ar start , +is used. +.Pp +If you intend to copy a file from one archive to another, using the flag +.Dv ZIP_FL_COMPRESSED +is more efficient, as it avoids recompressing the file data. +.Pp +Supported flags are: +.Bl -tag -width 20n +.It Dv ZIP_FL_COMPRESSED +Get the compressed data. +This is only supported if the complete file data is requested +.Ar ( start +== 0 and +.Ar length +== \-1). +This is not supported for changed data. +Default is uncompressed. +.It Dv ZIP_FL_ENCRYPTED +Get the encrypted data. +(This flag implies +.Dv ZIP_FL_COMPRESSED . ) +This is only supported if the complete file data is requested +.Ar ( start +== 0 and +.Ar length +== \-1). +Default is decrypted. +.It Dv ZIP_FL_UNCHANGED +Try to get the original data without any changes that may have been +made to +.Ar srcarchive +after opening it. +.El +.Sh RETURN VALUES +Upon successful completion, the created source is returned. +Otherwise, +.Dv NULL +is returned and the error code in +.Ar archive +or +.Ar error +is set to indicate the error. +.Sh ERRORS +.Fn zip_source_zip_file +and +.Fn zip_source_zip_file_create +fail if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_CHANGED +Unchanged data was requested, but it is not available. +.It Bq Er ZIP_ER_INVAL +.Ar srcarchive , +.Ar srcidx , +.Ar start , +or +.Ar length +are invalid. +.It Bq Er ZIP_ER_MEMORY +Required memory could not be allocated. +.El +Additionally, it can return all error codes from +.Fn zip_stat_index +and +.Fn zip_fopen_index . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_file_add 3 , +.Xr zip_file_replace 3 , +.Xr zip_source 3 +.Sh HISTORY +.Fn zip_source_zip_file +and +.Fn zip_source_zip_file_create +were added in libzip 1.10.0. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_stat.html b/thirdparty/libzip-1.11.3/man/zip_stat.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_stat.man b/thirdparty/libzip-1.11.3/man/zip_stat.man new file mode 100644 index 0000000..16c0663 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_stat.man @@ -0,0 +1,203 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_stat.mdoc -- get information about file +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_STAT" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_stat\fR, +\fBzip_stat_index\fR +\- get information about file +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_stat\fR(\fIzip_t\ *archive\fR, \fIconst\ char\ *fname\fR, \fIzip_flags_t\ flags\fR, \fIzip_stat_t\ *sb\fR); +.PD +.PP +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_stat_index\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR, \fIzip_flags_t\ flags\fR, \fIzip_stat_t\ *sb\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_stat\fR() +function obtains information about the file named +\fIfname\fR +in +\fIarchive\fR. +The +\fIflags\fR +argument specifies how the name lookup should be done. +Its values are described in +zip_name_locate(3). +Also, +\fRZIP_FL_UNCHANGED\fR +may be +\fIor\fR'ed +to it to request information about the original file in the archive, +ignoring any changes made. +.PP +The +\fBzip_stat_index\fR() +function obtains information about the file at position +\fIindex\fR. +.PP +The +\fIsb\fR +argument is a pointer to a +\fIstruct zip_stat\fR +(shown below), into which information about the file is placed. +.nf +.sp +.RS 0n +struct zip_stat { + zip_uint64_t valid; /* which fields have valid values */ + const char *name; /* name of the file */ + zip_uint64_t index; /* index within archive */ + zip_uint64_t size; /* size of file (uncompressed) */ + zip_uint64_t comp_size; /* size of file (compressed) */ + time_t mtime; /* modification time */ + zip_uint32_t crc; /* crc of file data */ + zip_uint16_t comp_method; /* compression method used */ + zip_uint16_t encryption_method; /* encryption method used */ + zip_uint32_t flags; /* reserved for future use */ +}; +.RE +.fi +The structure pointed to by +\fIsb\fR +must be allocated before calling +\fBzip_stat\fR() +or +\fBzip_stat_index\fR(). +.PP +The +\fIvalid\fR +field of the structure specifies which other fields are valid. +Check if the flag defined by the following defines are in +\fIvalid\fR +before accessing the fields: +.RS 6n +.PD 0 +.TP 30n +\fRZIP_STAT_NAME\fR +\fIname\fR +.TP 30n +\fRZIP_STAT_INDEX\fR +\fIindex\fR +.TP 30n +\fRZIP_STAT_SIZE\fR +\fIsize\fR +.TP 30n +\fRZIP_STAT_COMP_SIZE\fR +\fIcomp_size\fR +.TP 30n +\fRZIP_STAT_MTIME\fR +\fImtime\fR +.TP 30n +\fRZIP_STAT_CRC\fR +\fIcrc\fR +.TP 30n +\fRZIP_STAT_COMP_METHOD\fR +\fIcomp_method\fR +.TP 30n +\fRZIP_STAT_ENCRYPTION_METHOD\fR +\fIencryption_method\fR +.TP 30n +\fRZIP_STAT_FLAGS\fR +\fIflags\fR +.RE +.PD +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +The function +\fBzip_stat\fR() +can fail for any of the errors specified for the routine +zip_name_locate(3). +.PP +The function +\fBzip_stat_index\fR() +fails and sets the error information to +\fRZIP_ER_INVAL\fR +if +\fIindex\fR +is invalid. +If +\fRZIP_FL_UNCHANGED\fR +is not set and no information can be obtained from the source +callback, the error information is set to +\fRZIP_ER_CHANGED\fR. +.SH "SEE ALSO" +libzip(3), +zip_get_num_entries(3), +zip_name_locate(3), +zip_stat_init(3) +.SH "HISTORY" +\fBzip_stat\fR() +was added in libzip 0.6. +In libzip 0.11 the type of +\fIflags\fR +was changed from +\fIint\fR +to +\fIzip_flags_t\fR. +.PP +\fBzip_stat_index\fR() +was added in libzip 0.6. +In libzip 0.10 the type of +\fIindex\fR +was changed from +\fIint\fR +to +\fIzip_uint64_t\fR. +In libzip 0.11 the type of +\fIflags\fR +was changed from +\fIint\fR +to +\fIzip_flags_t\fR. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_stat.mdoc b/thirdparty/libzip-1.11.3/man/zip_stat.mdoc new file mode 100644 index 0000000..3ee9bbe --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_stat.mdoc @@ -0,0 +1,179 @@ +.\" zip_stat.mdoc -- get information about file +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_STAT 3 +.Os +.Sh NAME +.Nm zip_stat , +.Nm zip_stat_index +.Nd get information about file +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_stat "zip_t *archive" "const char *fname" "zip_flags_t flags" "zip_stat_t *sb" +.Ft int +.Fn zip_stat_index "zip_t *archive" "zip_uint64_t index" "zip_flags_t flags" "zip_stat_t *sb" +.Sh DESCRIPTION +The +.Fn zip_stat +function obtains information about the file named +.Ar fname +in +.Ar archive . +The +.Ar flags +argument specifies how the name lookup should be done. +Its values are described in +.Xr zip_name_locate 3 . +Also, +.Dv ZIP_FL_UNCHANGED +may be +.Em or Ns No 'ed +to it to request information about the original file in the archive, +ignoring any changes made. +.Pp +The +.Fn zip_stat_index +function obtains information about the file at position +.Ar index . +.Pp +The +.Ar sb +argument is a pointer to a +.Ft struct zip_stat +(shown below), into which information about the file is placed. +.Bd -literal +struct zip_stat { + zip_uint64_t valid; /* which fields have valid values */ + const char *name; /* name of the file */ + zip_uint64_t index; /* index within archive */ + zip_uint64_t size; /* size of file (uncompressed) */ + zip_uint64_t comp_size; /* size of file (compressed) */ + time_t mtime; /* modification time */ + zip_uint32_t crc; /* crc of file data */ + zip_uint16_t comp_method; /* compression method used */ + zip_uint16_t encryption_method; /* encryption method used */ + zip_uint32_t flags; /* reserved for future use */ +}; +.Ed +The structure pointed to by +.Ar sb +must be allocated before calling +.Fn zip_stat +or +.Fn zip_stat_index . +.Pp +The +.Ar valid +field of the structure specifies which other fields are valid. +Check if the flag defined by the following defines are in +.Ar valid +before accessing the fields: +.Bl -tag -width ZIP_STAT_ENCRYPTION_METHODXX -compact -offset indent +.It Dv ZIP_STAT_NAME +.Ar name +.It Dv ZIP_STAT_INDEX +.Ar index +.It Dv ZIP_STAT_SIZE +.Ar size +.It Dv ZIP_STAT_COMP_SIZE +.Ar comp_size +.It Dv ZIP_STAT_MTIME +.Ar mtime +.It Dv ZIP_STAT_CRC +.Ar crc +.It Dv ZIP_STAT_COMP_METHOD +.Ar comp_method +.It Dv ZIP_STAT_ENCRYPTION_METHOD +.Ar encryption_method +.It Dv ZIP_STAT_FLAGS +.Ar flags +.El +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error information in +.Ar archive +is set to indicate the error. +.Sh ERRORS +The function +.Fn zip_stat +can fail for any of the errors specified for the routine +.Xr zip_name_locate 3 . +.Pp +The function +.Fn zip_stat_index +fails and sets the error information to +.Er ZIP_ER_INVAL +if +.Ar index +is invalid. +If +.Dv ZIP_FL_UNCHANGED +is not set and no information can be obtained from the source +callback, the error information is set to +.Er ZIP_ER_CHANGED . +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_get_num_entries 3 , +.Xr zip_name_locate 3 , +.Xr zip_stat_init 3 +.Sh HISTORY +.Fn zip_stat +was added in libzip 0.6. +In libzip 0.11 the type of +.Ar flags +was changed from +.Vt int +to +.Vt zip_flags_t . +.Pp +.Fn zip_stat_index +was added in libzip 0.6. +In libzip 0.10 the type of +.Ar index +was changed from +.Vt int +to +.Vt zip_uint64_t . +In libzip 0.11 the type of +.Ar flags +was changed from +.Vt int +to +.Vt zip_flags_t . +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_stat_init.html b/thirdparty/libzip-1.11.3/man/zip_stat_init.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_stat_init.man b/thirdparty/libzip-1.11.3/man/zip_stat_init.man new file mode 100644 index 0000000..355eaeb --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_stat_init.man @@ -0,0 +1,81 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_stat_init.mdoc -- init zip_stat structure +.\" Copyright (C) 2006-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_STAT_INIT" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_stat_init\fR +\- initialize zip_stat structure +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIvoid\fR +.br +.PD 0 +.HP 4n +\fBzip_stat_init\fR(\fIzip_stat_t\ *sb\fR); +.PD +.SH "DESCRIPTION" +The +\fBzip_stat_init\fR() +function initializes the members of a struct zip_stat. +The current members are described in +zip_stat(3), +but this function should be used to initialize it to +make sure none are missed. +The structure pointed to by +\fIsb\fR +must be allocated before calling +\fBzip_stat_init\fR(). +.PP +This function should be used by functions provided to +zip_source_function(3) +when returning +\fRZIP_SOURCE_STAT\fR +information to make sure all fields are initialized. +.SH "RETURN VALUES" +If +\fIsb\fR +is valid, the function is always successful. +.SH "SEE ALSO" +libzip(3), +zip_stat(3) +.SH "HISTORY" +\fBzip_stat_init\fR() +was added in libzip 0.8. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_stat_init.mdoc b/thirdparty/libzip-1.11.3/man/zip_stat_init.mdoc new file mode 100644 index 0000000..afa38ec --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_stat_init.mdoc @@ -0,0 +1,76 @@ +.\" zip_stat_init.mdoc -- init zip_stat structure +.\" Copyright (C) 2006-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_STAT_INIT 3 +.Os +.Sh NAME +.Nm zip_stat_init +.Nd initialize zip_stat structure +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft void +.Fn zip_stat_init "zip_stat_t *sb" +.Sh DESCRIPTION +The +.Fn zip_stat_init +function initializes the members of a struct zip_stat. +The current members are described in +.Xr zip_stat 3 , +but this function should be used to initialize it to +make sure none are missed. +The structure pointed to by +.Ar sb +must be allocated before calling +.Fn zip_stat_init . +.Pp +This function should be used by functions provided to +.Xr zip_source_function 3 +when returning +.Dv ZIP_SOURCE_STAT +information to make sure all fields are initialized. +.Sh RETURN VALUES +If +.Ar sb +is valid, the function is always successful. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_stat 3 +.Sh HISTORY +.Fn zip_stat_init +was added in libzip 0.8. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_unchange.html b/thirdparty/libzip-1.11.3/man/zip_unchange.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_unchange.man b/thirdparty/libzip-1.11.3/man/zip_unchange.man new file mode 100644 index 0000000..38bf2f8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_unchange.man @@ -0,0 +1,86 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_unchange.mdoc -- undo changes to file in zip archive +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_UNCHANGE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_unchange\fR +\- undo changes to file in zip archive +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_unchange\fR(\fIzip_t\ *archive\fR, \fIzip_uint64_t\ index\fR); +.PD +.SH "DESCRIPTION" +Changes to the file at position +\fIindex\fR +are reverted. +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "ERRORS" +\fBzip_unchange\fR() +fails if: +.TP 19n +[\fRZIP_ER_EXISTS\fR] +Unchanging the name would result in a duplicate name in the archive. +.TP 19n +[\fRZIP_ER_INVAL\fR] +\fIindex\fR +is not a valid file index in +\fIzip\fR. +.SH "SEE ALSO" +libzip(3), +zip_unchange_all(3), +zip_unchange_archive(3) +.SH "HISTORY" +\fBzip_unchange\fR() +was added in libzip 0.6. +In libzip 0.10 the type of +\fIindex\fR +was changed from +\fIint\fR +to +\fIzip_uint64_t\fR. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_unchange.mdoc b/thirdparty/libzip-1.11.3/man/zip_unchange.mdoc new file mode 100644 index 0000000..4867243 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_unchange.mdoc @@ -0,0 +1,81 @@ +.\" zip_unchange.mdoc -- undo changes to file in zip archive +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_UNCHANGE 3 +.Os +.Sh NAME +.Nm zip_unchange +.Nd undo changes to file in zip archive +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_unchange "zip_t *archive" "zip_uint64_t index" +.Sh DESCRIPTION +Changes to the file at position +.Ar index +are reverted. +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh ERRORS +.Fn zip_unchange +fails if: +.Bl -tag -width Er +.It Bq Er ZIP_ER_EXISTS +Unchanging the name would result in a duplicate name in the archive. +.It Bq Er ZIP_ER_INVAL +.Ar index +is not a valid file index in +.Ar zip . +.El +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_unchange_all 3 , +.Xr zip_unchange_archive 3 +.Sh HISTORY +.Fn zip_unchange +was added in libzip 0.6. +In libzip 0.10 the type of +.Ar index +was changed from +.Vt int +to +.Vt zip_uint64_t . +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_unchange_all.html b/thirdparty/libzip-1.11.3/man/zip_unchange_all.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_unchange_all.man b/thirdparty/libzip-1.11.3/man/zip_unchange_all.man new file mode 100644 index 0000000..5c92cc8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_unchange_all.man @@ -0,0 +1,69 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_unchange_all.mdoc -- undo changes to all files in zip archive +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_UNCHANGE_ALL" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_unchange_all\fR +\- undo all changes in a zip archive +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_unchange_all\fR(\fIzip_t\ *archive\fR); +.PD +.SH "DESCRIPTION" +All changes to files and global information in +\fIarchive\fR +are reverted. +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "SEE ALSO" +libzip(3), +zip_unchange(3), +zip_unchange_archive(3) +.SH "HISTORY" +\fBzip_unchange_all\fR() +was added in libzip 0.6. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_unchange_all.mdoc b/thirdparty/libzip-1.11.3/man/zip_unchange_all.mdoc new file mode 100644 index 0000000..7604165 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_unchange_all.mdoc @@ -0,0 +1,64 @@ +.\" zip_unchange_all.mdoc -- undo changes to all files in zip archive +.\" Copyright (C) 2003-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_UNCHANGE_ALL 3 +.Os +.Sh NAME +.Nm zip_unchange_all +.Nd undo all changes in a zip archive +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_unchange_all "zip_t *archive" +.Sh DESCRIPTION +All changes to files and global information in +.Ar archive +are reverted. +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_unchange 3 , +.Xr zip_unchange_archive 3 +.Sh HISTORY +.Fn zip_unchange_all +was added in libzip 0.6. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zip_unchange_archive.html b/thirdparty/libzip-1.11.3/man/zip_unchange_archive.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zip_unchange_archive.man b/thirdparty/libzip-1.11.3/man/zip_unchange_archive.man new file mode 100644 index 0000000..9d0154c --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_unchange_archive.man @@ -0,0 +1,69 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zip_unchange_archive.mdoc -- undo changes to all files in zip archive +.\" Copyright (C) 2006-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIP_UNCHANGE_ARCHIVE" "3" "December 18, 2017" "NiH" "Library Functions Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzip_unchange_archive\fR +\- undo global changes to zip archive +.SH "LIBRARY" +libzip (-lzip) +.SH "SYNOPSIS" +\fB#include \fR +.sp +\fIint\fR +.br +.PD 0 +.HP 4n +\fBzip_unchange_archive\fR(\fIzip_t\ *archive\fR); +.PD +.SH "DESCRIPTION" +Revert all global changes to the archive +\fIarchive\fR. +This reverts changes to the archive comment and global flags. +.SH "RETURN VALUES" +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +\fIarchive\fR +is set to indicate the error. +.SH "SEE ALSO" +libzip(3), +zip_unchange(3), +zip_unchange_all(3) +.SH "HISTORY" +\fBzip_unchange_archive\fR() +was added in libzip 0.7. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zip_unchange_archive.mdoc b/thirdparty/libzip-1.11.3/man/zip_unchange_archive.mdoc new file mode 100644 index 0000000..45a3c82 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zip_unchange_archive.mdoc @@ -0,0 +1,64 @@ +.\" zip_unchange_archive.mdoc -- undo changes to all files in zip archive +.\" Copyright (C) 2006-2017 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd December 18, 2017 +.Dt ZIP_UNCHANGE_ARCHIVE 3 +.Os +.Sh NAME +.Nm zip_unchange_archive +.Nd undo global changes to zip archive +.Sh LIBRARY +libzip (-lzip) +.Sh SYNOPSIS +.In zip.h +.Ft int +.Fn zip_unchange_archive "zip_t *archive" +.Sh DESCRIPTION +Revert all global changes to the archive +.Ar archive . +This reverts changes to the archive comment and global flags. +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the error code in +.Ar archive +is set to indicate the error. +.Sh SEE ALSO +.Xr libzip 3 , +.Xr zip_unchange 3 , +.Xr zip_unchange_all 3 +.Sh HISTORY +.Fn zip_unchange_archive +was added in libzip 0.7. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zipcmp.html b/thirdparty/libzip-1.11.3/man/zipcmp.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zipcmp.man b/thirdparty/libzip-1.11.3/man/zipcmp.man new file mode 100644 index 0000000..cf84ccc --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zipcmp.man @@ -0,0 +1,108 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zipcmp.mdoc -- compare zip archives +.\" Copyright (C) 2003-2024 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIPCMP" "1" "March 15, 2024" "NiH" "General Commands Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzipcmp\fR +\- compare contents of zip archives +.SH "SYNOPSIS" +.HP 7n +\fBzipcmp\fR +[\fB\-ChipqsTtVv\fR] +\fIarchive1\ archive2\fR +.SH "DESCRIPTION" +\fBzipcmp\fR +compares the zip archives or directories +\fIarchive1\fR +and +\fIarchive2\fR +and checks if they contain the same files, comparing their names, +uncompressed sizes, and CRCs. +File order and compressed size differences are ignored. +.PP +Supported options: +.TP 5n +\fB\-C\fR +Check consistency of archives. +Results in an error if archive is inconsistent or not valid +according to the zip specification. +.TP 5n +\fB\-h\fR +Display a short help message and exit. +.TP 5n +\fB\-i\fR +Compare names ignoring case distinctions. +.TP 5n +\fB\-p\fR +Enable paranoid checks. +Compares extra fields, comments, and other meta data. +(Automatically disabled if one of the archives is a directory.) +These checks are skipped for files where the data differs. +.TP 5n +\fB\-q\fR +Quiet mode. +Compare +\fB\-v\fR. +.TP 5n +\fB\-s\fR +Print a summary of how many files where added and removed. +.TP 5n +\fB\-T\fR +Additionally compare the time stamps of the entries. +.TP 5n +\fB\-t\fR +Test zip files by comparing the contents to their checksums. +.TP 5n +\fB\-V\fR +Display version information and exit. +.TP 5n +\fB\-v\fR +Verbose mode. +Print details about differences to stdout. +(This is the default.) +.SH "EXIT STATUS" +\fBzipcmp\fR +exits 0 if the two archives contain the same files, 1 if they differ, +and >1 if an error occurred. +.SH "SEE ALSO" +zipmerge(1), +ziptool(1), +libzip(3) +.SH "HISTORY" +\fBzipcmp\fR +was added in libzip 0.6. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/zipcmp.mdoc b/thirdparty/libzip-1.11.3/man/zipcmp.mdoc new file mode 100644 index 0000000..d3d69e6 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zipcmp.mdoc @@ -0,0 +1,99 @@ +.\" zipcmp.mdoc -- compare zip archives +.\" Copyright (C) 2003-2024 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd March 15, 2024 +.Dt ZIPCMP 1 +.Os +.Sh NAME +.Nm zipcmp +.Nd compare contents of zip archives +.Sh SYNOPSIS +.Nm +.Op Fl ChipqsTtVv +.Ar archive1 archive2 +.Sh DESCRIPTION +.Nm +compares the zip archives or directories +.Ar archive1 +and +.Ar archive2 +and checks if they contain the same files, comparing their names, +uncompressed sizes, and CRCs. +File order and compressed size differences are ignored. +.Pp +Supported options: +.Bl -tag -width MMM +.It Fl C +Check consistency of archives. +Results in an error if archive is inconsistent or not valid +according to the zip specification. +.It Fl h +Display a short help message and exit. +.It Fl i +Compare names ignoring case distinctions. +.It Fl p +Enable paranoid checks. +Compares extra fields, comments, and other meta data. +(Automatically disabled if one of the archives is a directory.) +These checks are skipped for files where the data differs. +.It Fl q +Quiet mode. +Compare +.Fl v . +.It Fl s +Print a summary of how many files where added and removed. +.It Fl T +Additionally compare the time stamps of the entries. +.It Fl t +Test zip files by comparing the contents to their checksums. +.It Fl V +Display version information and exit. +.It Fl v +Verbose mode. +Print details about differences to stdout. +(This is the default.) +.El +.Sh EXIT STATUS +.Nm +exits 0 if the two archives contain the same files, 1 if they differ, +and >1 if an error occurred. +.Sh SEE ALSO +.Xr zipmerge 1 , +.Xr ziptool 1 , +.Xr libzip 3 +.Sh HISTORY +.Nm +was added in libzip 0.6. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/man/zipmerge.html b/thirdparty/libzip-1.11.3/man/zipmerge.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/zipmerge.man b/thirdparty/libzip-1.11.3/man/zipmerge.man new file mode 100644 index 0000000..b39b3e3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zipmerge.man @@ -0,0 +1,112 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" zipmerge.mdoc -- merge zip archives +.\" Copyright (C) 2004-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIPMERGE" "1" "November 7, 2023" "NiH" "General Commands Manual" +.nh +.if n .ad l +.SH "NAME" +\fBzipmerge\fR +\- merge zip archives +.SH "SYNOPSIS" +.HP 9n +\fBzipmerge\fR +[\fB\-DhIiSsV\fR] +\fItarget-zip\fR +\fIsource-zip\fR\ [\fIsource-zip\ ...\fR] +.SH "DESCRIPTION" +\fBzipmerge\fR +copies files from the source zip archives +\fIsource-zip\fR +to the target zip archive +\fItarget-zip\fR. +By default, files in the source zip archives overwrite +existing files of the same name in the target zip archive. +By default, compressed files in the source archive are +copied directly without recompression, uncompressed files +are compressed using the default compression algorithm. +.PP +Supported options: +.TP 5n +\fB\-D\fR +Ignore directory components in file name comparisons. +This option is slow for archives with many files. +.TP 5n +\fB\-h\fR +Display a short help message and exit. +.TP 5n +\fB\-I\fR +Ignore case in file name comparisons +This option is slow for archives with many files. +.TP 5n +\fB\-i\fR +Ask before overwriting files. +See also +\fB\-s\fR. +.TP 5n +\fB\-k\fR +Do not compress files that were uncompressed in +\fIsource-zip\fR, +otherwise they are compressed with the default compression method. +.TP 5n +\fB\-S\fR +Do not overwrite files that have the same name, size, and +CRC32 in both the source and target archives. +.TP 5n +\fB\-s\fR +When +\fB\-i\fR +is given, do not ask before overwriting files that have the same name, size, +and CRC32. +.TP 5n +\fB\-V\fR +Display version information and exit. +.SH "EXIT STATUS" +\fBzipmerge\fR +exits 0 on success and >1 if an error occurred. +.SH "SEE ALSO" +zipcmp(1), +ziptool(1), +libzip(3) +.SH "HISTORY" +\fBzipmerge\fR +was added in libzip 0.6. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> +.SH "CAVEATS" +\fBzipmerge\fR +uses one open file descriptor per zip archive. +If you need to merge a lot of zip archives, check your shell's +file descriptor ulimit and either increase it or run +\fBzipmerge\fR +multiple times with e.g. 1000 source zip archives each time. diff --git a/thirdparty/libzip-1.11.3/man/zipmerge.mdoc b/thirdparty/libzip-1.11.3/man/zipmerge.mdoc new file mode 100644 index 0000000..f7c535b --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/zipmerge.mdoc @@ -0,0 +1,105 @@ +.\" zipmerge.mdoc -- merge zip archives +.\" Copyright (C) 2004-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd November 7, 2023 +.Dt ZIPMERGE 1 +.Os +.Sh NAME +.Nm zipmerge +.Nd merge zip archives +.Sh SYNOPSIS +.Nm +.Op Fl DhIiSsV +.Ar target-zip +.Ar source-zip Op Ar source-zip ... +.Sh DESCRIPTION +.Nm +copies files from the source zip archives +.Ar source-zip +to the target zip archive +.Ar target-zip . +By default, files in the source zip archives overwrite +existing files of the same name in the target zip archive. +By default, compressed files in the source archive are +copied directly without recompression, uncompressed files +are compressed using the default compression algorithm. +.Pp +Supported options: +.Bl -tag -width MMM +.It Fl D +Ignore directory components in file name comparisons. +This option is slow for archives with many files. +.It Fl h +Display a short help message and exit. +.It Fl I +Ignore case in file name comparisons +This option is slow for archives with many files. +.It Fl i +Ask before overwriting files. +See also +.Fl s . +.It Fl k +Do not compress files that were uncompressed in +.Ar source-zip , +otherwise they are compressed with the default compression method. +.It Fl S +Do not overwrite files that have the same name, size, and +CRC32 in both the source and target archives. +.It Fl s +When +.Fl i +is given, do not ask before overwriting files that have the same name, size, +and CRC32. +.It Fl V +Display version information and exit. +.El +.Sh EXIT STATUS +.Nm +exits 0 on success and >1 if an error occurred. +.Sh SEE ALSO +.Xr zipcmp 1 , +.Xr ziptool 1 , +.Xr libzip 3 +.Sh HISTORY +.Nm +was added in libzip 0.6. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at +.Sh CAVEATS +.Nm +uses one open file descriptor per zip archive. +If you need to merge a lot of zip archives, check your shell's +file descriptor ulimit and either increase it or run +.Nm +multiple times with e.g. 1000 source zip archives each time. diff --git a/thirdparty/libzip-1.11.3/man/ziptool.html b/thirdparty/libzip-1.11.3/man/ziptool.html new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/man/ziptool.man b/thirdparty/libzip-1.11.3/man/ziptool.man new file mode 100644 index 0000000..66f87a9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/ziptool.man @@ -0,0 +1,435 @@ +.\" Automatically generated from an mdoc input file. Do not edit. +.\" ziptool.mdoc -- modify zip archives in multiple ways +.\" Copyright (C) 2016-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.TH "ZIPTOOL" "1" "January 23, 2023" "NiH" "General Commands Manual" +.nh +.if n .ad l +.SH "NAME" +\fBziptool\fR +\- modify zip archives +.SH "SYNOPSIS" +.HP 8n +\fBziptool\fR +[\fB\-ceghnrst\fR] +[\fB\-l\fR\ \fIlength\fR] +[\fB\-o\fR\ \fIoffset\fR] +\fIzip-archive\fR +\fBcommand\fR\ [\fIcommand-args\ ...\fR] +[\fBcommand\fR\ [\fIcommand-args\ ...\fR]\ ...] +.SH "DESCRIPTION" +\fBziptool\fR +modifies the zip archive +\fIzip-archive\fR +according to the +\fIcommands\fR +given. +.PP +Supported options: +.TP 13n +\fB\-c\fR +Check zip archive consistency when opening it. +.TP 13n +\fB\-e\fR +Error if archive already exists (only useful with +\fB\-n\fR). +.TP 13n +\fB\-g\fR +Guess file name encoding (for +\fBstat\fR +command). +.TP 13n +\fB\-h\fR +Display help. +.TP 13n +\fB\-l\fR \fIlength\fR +Only read +\fIlength\fR +bytes of archive. +See also +\fB\-o\fR. +.TP 13n +\fB\-n\fR +Create archive if it doesn't exist. +See also +\fB\-e\fR. +.TP 13n +\fB\-o\fR \fIoffset\fR +Start reading input archive from +\fIoffset\fR. +See also +\fB\-l\fR. +.TP 13n +\fB\-r\fR +Print raw file name encoding without translation (for +\fBstat\fR +command). +.TP 13n +\fB\-s\fR +Follow file name convention strictly (for +\fBstat\fR +command). +.TP 13n +\fB\-t\fR +Disregard current file contents, if any. +\fINote\fR: +use this with care, it deletes all existing file contents when +you modify the archive. +.SS "Commands" +For all commands below, the index is zero-based. +In other words, the first entry in the zip archive has index 0. +.PP +Supported commands and arguments are: +.TP 12n +\fBadd\fR \fIname content\fR +Add file called +\fIname\fR +using the string +\fIcontent\fR +from the command line as data. +.TP 12n +\fBadd_dir\fR \fIname\fR +Add directory +\fIname\fR. +.TP 12n +\fBadd_file\fR \fIname file_to_add offset len\fR +Add file +\fIname\fR +to archive, using +\fIlen\fR +bytes from the file +\fIfile_to_add\fR +as input data, starting at +\fIoffset\fR. +.TP 12n +\fBadd_from_zip\fR \fIname archivename index offset len\fR +Add file called +\fIname\fR +to archive using data from another zip archive +\fIarchivename\fR +using the entry with index +\fIindex\fR +and reading +\fIlen\fR +bytes from +\fIoffset\fR. +.TP 12n +\fBcat\fR \fIindex\fR +Output file contents for entry +\fIindex\fR +to stdout. +.TP 12n +\fBcount_extra\fR \fIindex flags\fR +Print the number of extra fields for archive entry +\fIindex\fR +using +\fIflags\fR. +.TP 12n +\fBcount_extra_by_id\fR \fIindex extra_id flags\fR +Print number of extra fields of type +\fIextra_id\fR +for archive entry +\fIindex\fR +using +\fIflags\fR. +.TP 12n +\fBdelete\fR \fIindex\fR +Remove entry at +\fIindex\fR +from zip archive. +.TP 12n +\fBdelete_extra\fR \fIindex extra_idx flags\fR +Remove extra field number +\fIextra_idx\fR +from archive entry +\fIindex\fR +using +\fIflags\fR. +.TP 12n +\fBdelete_extra_by_id\fR \fIindex extra_id extra_index flags\fR +Remove extra field number +\fIextra_index\fR +of type +\fIextra_id\fR +from archive entry +\fIindex\fR +using +\fIflags\fR. +.TP 12n +\fBget_archive_comment\fR +Print archive comment. +.TP 12n +\fBget_archive_flag\fR \fIflag\fR +Print state of archive flag +\fIflag\fR. +.TP 12n +\fBget_extra\fR \fIindex extra_index flags\fR +Print extra field +\fIextra_index\fR +for archive entry +\fIindex\fR +using +\fIflags\fR. +.TP 12n +\fBget_extra_by_id\fR \fIindex extra_id extra_index flags\fR +Print extra field +\fIextra_index\fR +of type +\fIextra_id\fR +for archive entry +\fIindex\fR +using +\fIflags\fR. +.TP 12n +\fBget_file_comment\fR \fIindex\fR +Get file comment for archive entry +\fIindex\fR. +.TP 12n +\fBget_num_entries\fR \fIflags\fR +Print number of entries in archive using +\fIflags\fR. +.TP 12n +\fBname_locate\fR \fIname flags\fR +Find entry in archive with the filename +\fIname\fR +using +\fIflags\fR +and print its index. +.TP 12n +\fBrename\fR \fIindex name\fR +Rename archive entry +\fIindex\fR +to +\fIname\fR. +.TP 12n +\fBreplace_file_contents\fR \fIindex data\fR +Replace file contents for archive entry +\fIindex\fR +with the string +\fIdata\fR. +.TP 12n +\fBset_archive_comment\fR \fIcomment\fR +Set archive comment to +\fIcomment\fR. +.TP 12n +\fBget_archive_flag\fR \fIflag\fR \fIvalue\fR +Set archive flag +\fIflag\fR +to +\fIvalue\fR. +.TP 12n +\fBset_extra\fR \fIindex extra_id extra_index flags value\fR +Set extra field number +\fIextra_index\fR +of type +\fIextra_id\fR +for archive entry +\fIindex\fR +using +\fIflags\fR +to +\fIvalue\fR. +.TP 12n +\fBset_file_comment\fR \fIindex comment\fR +Set file comment for archive entry +\fIindex\fR +to string +\fIcomment\fR. +.TP 12n +\fBset_file_compression\fR \fIindex method compression_flags\fR +Set file compression method for archive entry +\fIindex\fR +to +\fImethod\fR +using +\fIcompression_flags\fR. +\fINote\fR: +Currently, +\fIcompression_flags\fR +are ignored. +.TP 12n +\fBset_file_encryption\fR \fIindex method password\fR +Set file encryption method for archive entry +\fIindex\fR +to +\fImethod\fR +with password +\fIpassword\fR. +.TP 12n +\fBset_file_mtime\fR \fIindex timestamp\fR +Set file modification time for archive entry +\fIindex\fR +to UNIX mtime +\fItimestamp\fR. +.TP 12n +\fBset_file_mtime_all\fR \fItimestamp\fR +Set file modification time for all archive entries to UNIX mtime +\fItimestamp\fR. +.TP 12n +\fBset_password\fR \fIpassword\fR +Set default password for encryption/decryption to +\fIpassword\fR. +.TP 12n +\fBstat\fR \fIindex\fR +Print information about archive entry +\fIindex\fR. +.SS "Flags" +Some commands take flag arguments. +Each character in the argument sets the corresponding flag. +Use 0 or the empty string for no flags. +.PP +Supported flags are: +.RS 6n +.PD 0 +.TP 5n +\fI4\fR +\fRZIP_FL_ENC_CP437\fR +.TP 5n +\fI8\fR +\fRZIP_FL_ENC_UTF_8\fR +.TP 5n +\fIC\fR +\fRZIP_FL_NOCASE\fR +.TP 5n +\fIc\fR +\fRZIP_FL_CENTRAL\fR +.TP 5n +\fId\fR +\fRZIP_FL_NODIR\fR +.TP 5n +\fIl\fR +\fRZIP_FL_LOCAL\fR +.TP 5n +\fIr\fR +\fRZIP_FL_ENC_RAW\fR +.TP 5n +\fIs\fR +\fRZIP_FL_ENC_STRICT\fR +.TP 5n +\fIu\fR +\fRZIP_FL_UNCHANGED\fR +.RE +.PD +.SS "Archive flags" +\fBget_archive_flag\fR +and +\fBset_archive_flag\fR +work on the following flags: +.RS 6n +.PD 0 +.TP 4n +\fB\(bu\fR +\fRcreate-or-keep-empty-file-for-archive\fR +.TP 4n +\fB\(bu\fR +\fRis-torrentzip\fR +.TP 4n +\fB\(bu\fR +\fRrdonly\fR +.TP 4n +\fB\(bu\fR +\fRwant-torrentzip\fR +.RE +.PD +.SS "Compression Methods" +Some commands take compression method arguments. +Supported methods are: +.RS 6n +.PD 0 +.TP 4n +\fB\(bu\fR +\fRdefault\fR +.TP 4n +\fB\(bu\fR +\fRdeflate\fR +.TP 4n +\fB\(bu\fR +\fRstore\fR +.RE +.PD +.SS "Encryption Methods" +Some commands take encryption method arguments. +Supported methods are: +.RS 6n +.PD 0 +.TP 4n +\fB\(bu\fR +\fRnone\fR +.TP 4n +\fB\(bu\fR +\fRAES-128\fR +.TP 4n +\fB\(bu\fR +\fRAES-192\fR +.TP 4n +\fB\(bu\fR +\fRAES-256\fR +.RE +.PD +.SH "EXIT STATUS" +.br +The \fBziptool\fR utility exits\~0 on success, and\~>0 if an error occurs. +.SH "EXAMPLES" +Add a file called +\fIteststring.txt\fR +to the zip archive +\fItestbuffer.zip\fR +with data +\(lqThis is a test.\en\(rq +where +\(lq\en\(rq +is replaced with a newline character: +.nf +.sp +.RS 6n +ziptool testbuffer.zip add teststring.txt \\"This is a test.\en\\" +.RE +.fi +.PP +Delete the first file from the zip archive +\fItestfile.zip\fR: +.nf +.sp +.RS 6n +ziptool testfile.zip delete 0 +.RE +.fi +.SH "SEE ALSO" +zipcmp(1), +zipmerge(1), +libzip(3) +.SH "HISTORY" +\fBziptool\fR +was added in libzip 1.1. +.SH "AUTHORS" +Dieter Baron <\fIdillo@nih.at\fR> +and +Thomas Klausner <\fIwiz@gatalith.at\fR> diff --git a/thirdparty/libzip-1.11.3/man/ziptool.mdoc b/thirdparty/libzip-1.11.3/man/ziptool.mdoc new file mode 100644 index 0000000..05f57bd --- /dev/null +++ b/thirdparty/libzip-1.11.3/man/ziptool.mdoc @@ -0,0 +1,364 @@ +.\" ziptool.mdoc -- modify zip archives in multiple ways +.\" Copyright (C) 2016-2022 Dieter Baron and Thomas Klausner +.\" +.\" This file is part of libzip, a library to manipulate ZIP archives. +.\" The authors can be contacted at +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. The names of the authors may not be used to endorse or promote +.\" products derived from this software without specific prior +.\" written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd January 23, 2023 +.Dt ZIPTOOL 1 +.Os +.Sh NAME +.Nm ziptool +.Nd modify zip archives +.Sh SYNOPSIS +.Nm +.Op Fl ceghnrst +.Op Fl l Ar length +.Op Fl o Ar offset +.Ar zip-archive +.Cm command Op Ar command-args ... +.Op Cm command Oo Ar command-args ... Oc ... +.Sh DESCRIPTION +.Nm +modifies the zip archive +.Ar zip-archive +according to the +.Ar commands +given. +.Pp +Supported options: +.Bl -tag -width MoMoffsetMM +.It Fl c +Check zip archive consistency when opening it. +.It Fl e +Error if archive already exists (only useful with +.Fl n ) . +.It Fl g +Guess file name encoding (for +.Cm stat +command). +.It Fl h +Display help. +.It Fl l Ar length +Only read +.Ar length +bytes of archive. +See also +.Fl o . +.It Fl n +Create archive if it doesn't exist. +See also +.Fl e . +.It Fl o Ar offset +Start reading input archive from +.Ar offset . +See also +.Fl l . +.It Fl r +Print raw file name encoding without translation (for +.Cm stat +command). +.It Fl s +Follow file name convention strictly (for +.Cm stat +command). +.It Fl t +Disregard current file contents, if any. +.Em Note : +use this with care, it deletes all existing file contents when +you modify the archive. +.El +.Ss Commands +For all commands below, the index is zero-based. +In other words, the first entry in the zip archive has index 0. +.Pp +Supported commands and arguments are: +.Bl -tag -width 10n +.It Cm add Ar name content +Add file called +.Ar name +using the string +.Ar content +from the command line as data. +.It Cm add_dir Ar name +Add directory +.Ar name . +.It Cm add_file Ar name file_to_add offset len +Add file +.Ar name +to archive, using +.Ar len +bytes from the file +.Ar file_to_add +as input data, starting at +.Ar offset . +.It Cm add_from_zip Ar name archivename index offset len +Add file called +.Ar name +to archive using data from another zip archive +.Ar archivename +using the entry with index +.Ar index +and reading +.Ar len +bytes from +.Ar offset . +.It Cm cat Ar index +Output file contents for entry +.Ar index +to stdout. +.It Cm count_extra Ar index flags +Print the number of extra fields for archive entry +.Ar index +using +.Ar flags . +.It Cm count_extra_by_id Ar index extra_id flags +Print number of extra fields of type +.Ar extra_id +for archive entry +.Ar index +using +.Ar flags . +.It Cm delete Ar index +Remove entry at +.Ar index +from zip archive. +.It Cm delete_extra Ar index extra_idx flags +Remove extra field number +.Ar extra_idx +from archive entry +.Ar index +using +.Ar flags . +.It Cm delete_extra_by_id Ar index extra_id extra_index flags +Remove extra field number +.Ar extra_index +of type +.Ar extra_id +from archive entry +.Ar index +using +.Ar flags . +.It Cm get_archive_comment +Print archive comment. +.It Cm get_archive_flag Ar flag +Print state of archive flag +.Ar flag . +.It Cm get_extra Ar index extra_index flags +Print extra field +.Ar extra_index +for archive entry +.Ar index +using +.Ar flags . +.It Cm get_extra_by_id Ar index extra_id extra_index flags +Print extra field +.Ar extra_index +of type +.Ar extra_id +for archive entry +.Ar index +using +.Ar flags . +.It Cm get_file_comment Ar index +Get file comment for archive entry +.Ar index . +.It Cm get_num_entries Ar flags +Print number of entries in archive using +.Ar flags . +.It Cm name_locate Ar name flags +Find entry in archive with the filename +.Ar name +using +.Ar flags +and print its index. +.It Cm rename Ar index name +Rename archive entry +.Ar index +to +.Ar name . +.It Cm replace_file_contents Ar index data +Replace file contents for archive entry +.Ar index +with the string +.Ar data . +.It Cm set_archive_comment Ar comment +Set archive comment to +.Ar comment . +.It Cm get_archive_flag Ar flag Ar value +Set archive flag +.Ar flag +to +.Ar value . +.It Cm set_extra Ar index extra_id extra_index flags value +Set extra field number +.Ar extra_index +of type +.Ar extra_id +for archive entry +.Ar index +using +.Ar flags +to +.Ar value . +.It Cm set_file_comment Ar index comment +Set file comment for archive entry +.Ar index +to string +.Ar comment . +.It Cm set_file_compression Ar index method compression_flags +Set file compression method for archive entry +.Ar index +to +.Ar method +using +.Ar compression_flags . +.Em Note : +Currently, +.Ar compression_flags +are ignored. +.It Cm set_file_encryption Ar index method password +Set file encryption method for archive entry +.Ar index +to +.Ar method +with password +.Ar password . +.It Cm set_file_mtime Ar index timestamp +Set file modification time for archive entry +.Ar index +to UNIX mtime +.Ar timestamp . +.It Cm set_file_mtime_all Ar timestamp +Set file modification time for all archive entries to UNIX mtime +.Ar timestamp . +.It Cm set_password Ar password +Set default password for encryption/decryption to +.Ar password . +.It Cm stat Ar index +Print information about archive entry +.Ar index . +.El +.Ss Flags +Some commands take flag arguments. +Each character in the argument sets the corresponding flag. +Use 0 or the empty string for no flags. +.Pp +Supported flags are: +.Bl -tag -width MMM -compact -offset indent +.It Ar 4 +.Dv ZIP_FL_ENC_CP437 +.It Ar 8 +.Dv ZIP_FL_ENC_UTF_8 +.It Ar C +.Dv ZIP_FL_NOCASE +.It Ar c +.Dv ZIP_FL_CENTRAL +.It Ar d +.Dv ZIP_FL_NODIR +.It Ar l +.Dv ZIP_FL_LOCAL +.It Ar r +.Dv ZIP_FL_ENC_RAW +.It Ar s +.Dv ZIP_FL_ENC_STRICT +.It Ar u +.Dv ZIP_FL_UNCHANGED +.El +.Ss Archive flags +.Cm get_archive_flag +and +.Cm set_archive_flag +work on the following flags: +.Bl -bullet -compact -offset indent +.It +.Dv create-or-keep-empty-file-for-archive +.It +.Dv is-torrentzip +.It +.Dv rdonly +.It +.Dv want-torrentzip +.El +.Ss Compression Methods +Some commands take compression method arguments. +Supported methods are: +.Bl -bullet -compact -offset indent +.It +.Dv default +.It +.Dv deflate +.It +.Dv store +.El +.Ss Encryption Methods +Some commands take encryption method arguments. +Supported methods are: +.Bl -bullet -compact -offset indent +.It +.Dv none +.It +.Dv AES-128 +.It +.Dv AES-192 +.It +.Dv AES-256 +.El +.Sh EXIT STATUS +.Ex -std +.Sh EXAMPLES +Add a file called +.Pa teststring.txt +to the zip archive +.Pa testbuffer.zip +with data +.Dq This is a test.\en +where +.Dq \en +is replaced with a newline character: +.Bd -literal -offset indent +ziptool testbuffer.zip add teststring.txt \\"This is a test.\en\\" +.Ed +.Pp +Delete the first file from the zip archive +.Pa testfile.zip : +.Bd -literal -offset indent +ziptool testfile.zip delete 0 +.Ed +.Sh SEE ALSO +.Xr zipcmp 1 , +.Xr zipmerge 1 , +.Xr libzip 3 +.Sh HISTORY +.Nm +was added in libzip 1.1. +.Sh AUTHORS +.An -nosplit +.An Dieter Baron Aq Mt dillo@nih.at +and +.An Thomas Klausner Aq Mt wiz@gatalith.at diff --git a/thirdparty/libzip-1.11.3/ossfuzz/CMakeLists.txt b/thirdparty/libzip-1.11.3/ossfuzz/CMakeLists.txt new file mode 100644 index 0000000..087e2e6 --- /dev/null +++ b/thirdparty/libzip-1.11.3/ossfuzz/CMakeLists.txt @@ -0,0 +1,17 @@ +set(FUZZ_PROGRAMS + zip_read_file_fuzzer + zip_read_fuzzer + zip_write_encrypt_aes256_file_fuzzer + zip_write_encrypt_pkware_file_fuzzer +) + +foreach(PROGRAM IN LISTS FUZZ_PROGRAMS) + add_executable(${PROGRAM} ${PROGRAM}.c) + target_sources(${PROGRAM} PRIVATE fuzz_main.c) + target_include_directories(${PROGRAM} PRIVATE BEFORE ${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}) + target_link_libraries(${PROGRAM} zip) +endforeach() + +add_custom_target(list-fuzzers + COMMAND echo FUZZERS: ${FUZZ_PROGRAMS} +) diff --git a/thirdparty/libzip-1.11.3/ossfuzz/fuzz_main.c b/thirdparty/libzip-1.11.3/ossfuzz/fuzz_main.c new file mode 100644 index 0000000..04bd741 --- /dev/null +++ b/thirdparty/libzip-1.11.3/ossfuzz/fuzz_main.c @@ -0,0 +1,58 @@ +#include +#include +#include + +/* fuzz target entry point, works without libFuzzer */ + +extern int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); + +int +main(int argc, char **argv) { + FILE *f = NULL; + char *buf = NULL; + long siz_buf; + + if (argc < 2) { + fprintf(stderr, "no input file\n"); + goto err; + } + + f = fopen(argv[1], "rb"); + if (f == NULL) { + fprintf(stderr, "error opening input file %s\n", argv[1]); + goto err; + } + + fseek(f, 0, SEEK_END); + + siz_buf = ftell(f); + rewind(f); + + if (siz_buf < 1) { + fprintf(stderr, "zero-byte file not supported\n"); + goto err; + } + + buf = (char *)malloc(siz_buf); + if (buf == NULL) { + fprintf(stderr, "malloc() failed\n"); + goto err; + } + + if (fread(buf, siz_buf, 1, f) != 1) { + fprintf(stderr, "fread() failed\n"); + goto err; + } + fclose(f); + f = NULL; + + (void)LLVMFuzzerTestOneInput((uint8_t *)buf, siz_buf); + + err: + if (f) { + fclose(f); + } + free(buf); + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/ossfuzz/ossfuzz.sh b/thirdparty/libzip-1.11.3/ossfuzz/ossfuzz.sh new file mode 100644 index 0000000..58321fa --- /dev/null +++ b/thirdparty/libzip-1.11.3/ossfuzz/ossfuzz.sh @@ -0,0 +1,56 @@ +#!/bin/bash -eu +# Copyright 2019 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +# This script is meant to be run by +# https://github.com/google/oss-fuzz/blob/master/projects/libzip/Dockerfile + + +mkdir build +cd build +cmake -DBUILD_SHARED_LIBS=OFF -DENABLE_GNUTLS=OFF -DENABLE_MBEDTLS=OFF -DENABLE_OPENSSL=ON -DBUILD_TOOLS=OFF -DHAVE_CRYPTO=ON .. +make -j$(nproc) + +for fuzzer in $(make list-fuzzers | sed -n 's/^FUZZERS: //p') +do + $CXX $CFLAGS -I. -I../lib \ + $SRC/libzip/ossfuzz/$fuzzer.c \ + -o $OUT/$fuzzer \ + $LIB_FUZZING_ENGINE $SRC/libzip/build/lib/libzip.a -lbz2 -llzma -lz -lzstd -v -lssl -lcrypto +done + +find $SRC/libzip/regress -name "*zip" | \ + xargs zip $OUT/zip_read_fuzzer_seed_corpus.zip +cp $SRC/libzip/ossfuzz/zip_read_fuzzer.dict $OUT/ + +cp $SRC/libzip/ossfuzz/zip_write_encrypt_aes256_file_fuzzer_seed_corpus.zip $OUT/ + +for pair in \ + zip_read_fuzzer:zip_read_file_fuzzer \ + zip_write_encrypt_aes256_file_fuzzer:zip_write_encrypt_pkware_file_fuzzer +do + source=${pair%%:*} + target=${pair##*:} + for file in .dict _seed_corpus.zip + do + if [ -f $OUT/$source$file ] + then + cp $OUT/$source$file $OUT/$target$file + fi + done +done + + diff --git a/thirdparty/libzip-1.11.3/ossfuzz/zip_read_file_fuzzer.c b/thirdparty/libzip-1.11.3/ossfuzz/zip_read_file_fuzzer.c new file mode 100644 index 0000000..db786c1 --- /dev/null +++ b/thirdparty/libzip-1.11.3/ossfuzz/zip_read_file_fuzzer.c @@ -0,0 +1,83 @@ +/* + zip_random_uwp.c -- fill the user's buffer with random stuff (UWP version) + Copyright (C) 2017-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#include +#include +#include +#include +#include +#include +#include + +#include "zip_read_fuzzer_common.h" + +/** + This fuzzing target takes input data, creates a ZIP archive from it, checks the archive's consistency, + and iterates over the entries in the archive, reading data from each entry. +**/ + +#ifdef __cplusplus +extern "C" +#endif +int +LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + zip_t *za; + const char *name = "test.zip"; + FILE *fp; + zip_error_t error; + int err = 0; + + (void)remove(name); + if ((fp = fopen(name, "wb")) == NULL) { + fprintf(stderr, "can't create file '%s': %s\n", name, strerror(errno)); + return 0; + } + if (fwrite(data, 1, size, fp) != size) { + fprintf(stderr, "can't write data to file '%s': %s\n", name, strerror(errno)); + fclose(fp); + (void)remove(name); + return 0; + } + if (fclose(fp) < 0) { + fprintf(stderr, "can't close file '%s': %s\n", name, strerror(errno)); + (void)remove(name); + return 0; + } + + za = zip_open(name, 0, &err); + zip_error_init_with_code(&error, err); + + fuzzer_read(za, &error, NULL); + + (void)remove(name); + return 0; +} diff --git a/thirdparty/libzip-1.11.3/ossfuzz/zip_read_fuzzer.c b/thirdparty/libzip-1.11.3/ossfuzz/zip_read_fuzzer.c new file mode 100644 index 0000000..943eeec --- /dev/null +++ b/thirdparty/libzip-1.11.3/ossfuzz/zip_read_fuzzer.c @@ -0,0 +1,31 @@ +#include +#include + +#include "zip_read_fuzzer_common.h" + +#ifdef __cplusplus +extern "C" +#endif +int +LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + zip_source_t *src; + zip_error_t error; + zip_t *za; + + zip_error_init(&error); + + if ((src = zip_source_buffer_create(data, size, 0, &error)) == NULL) { + zip_error_fini(&error); + return 0; + } + + za = zip_open_from_source(src, 0, &error); + + fuzzer_read(za, &error, "secretpassword"); + + if (za == NULL) { + zip_source_free(src); + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/ossfuzz/zip_read_fuzzer.dict b/thirdparty/libzip-1.11.3/ossfuzz/zip_read_fuzzer.dict new file mode 100644 index 0000000..0c9fe5d --- /dev/null +++ b/thirdparty/libzip-1.11.3/ossfuzz/zip_read_fuzzer.dict @@ -0,0 +1,6 @@ +header_cd="\x50\x4b\x01\x02" +header_local_file_header="\x50\x4b\x03\x04" +header_eocd="\x50\x4b\x05\x06" +header_zip64_eocd="\x50\x4b\x06\x06" +header_zip64_eocd_locator="\x50\x4b\x06\x07" +header_data_descriptor="\x50\x4b\x07\x08" diff --git a/thirdparty/libzip-1.11.3/ossfuzz/zip_read_fuzzer_common.h b/thirdparty/libzip-1.11.3/ossfuzz/zip_read_fuzzer_common.h new file mode 100644 index 0000000..b525a09 --- /dev/null +++ b/thirdparty/libzip-1.11.3/ossfuzz/zip_read_fuzzer_common.h @@ -0,0 +1,73 @@ +/* + zip_read_fuzzer_common.h -- common function for fuzzers to read all files in an archive + Copyright (C) 2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zip.h" + +void fuzzer_read(zip_t *za, zip_error_t *error, const char *password) { + zip_int64_t i, n, ret; + char buf[32768]; + + if (za == NULL) { + fprintf(stderr, "Error opening archive: %s\n", zip_error_strerror(error)); + zip_error_fini(error); + return; + } + + zip_set_default_password(za, password); + + zip_error_fini(error); + + n = zip_get_num_entries(za, 0); + for (i = 0; i < n; i++) { + zip_file_t *f = zip_fopen_index(za, i, 0); + if (f == NULL) { + fprintf(stderr, "Error opening file %d: %s\n", (int)i, zip_strerror(za)); + continue; + } + + while ((ret = zip_fread(f, buf, sizeof(buf))) > 0) { + ; + } + if (ret < 0) { + fprintf(stderr, "Error reading file %d: %s\n", (int)i, zip_strerror(za)); + } + if (zip_fclose(f) < 0) { + fprintf(stderr, "Error closing file %d: %s\n", (int)i, zip_strerror(za)); + continue; + } + } + if (zip_close(za) < 0) { + fprintf(stderr, "Error closing archive: %s\n", zip_strerror(za)); + zip_discard(za); + } +} diff --git a/thirdparty/libzip-1.11.3/ossfuzz/zip_write_encrypt_aes256_file_fuzzer.c b/thirdparty/libzip-1.11.3/ossfuzz/zip_write_encrypt_aes256_file_fuzzer.c new file mode 100644 index 0000000..2ad8855 --- /dev/null +++ b/thirdparty/libzip-1.11.3/ossfuzz/zip_write_encrypt_aes256_file_fuzzer.c @@ -0,0 +1,61 @@ +#include +#include +#include +#include +#include + +/** + This fuzzing target takes input data, creates a ZIP archive, load + it to a buffer, adds a file to it with AES-256 encryption and a + specified password, and then closes and removes the archive. + + The purpose of this fuzzer is to test security of ZIP archive + handling and encryption in the libzip by subjecting it to various + inputs, including potentially malicious or malformed data of + different file types. + **/ + +#ifdef __cplusplus +extern "C" +#endif +int +LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + const char *path = "test_aes256.zip"; + const char *password = "password"; + const char *file = "filename"; + int error = 0; + struct zip *archive; + + (void)remove(path); + if ((archive = zip_open(path, ZIP_CREATE, &error)) == NULL) { + return -1; + } + + struct zip_source *source = zip_source_buffer(archive, data, size, 0); + if (source == NULL) { + fprintf(stderr, "failed to create source buffer. %s\n", zip_strerror(archive)); + zip_discard(archive); + return -1; + } + + int index = (int)zip_file_add(archive, file, source, ZIP_FL_OVERWRITE); + if (index < 0) { + fprintf(stderr, "failed to add file to archive: %s\n", zip_strerror(archive)); + zip_source_free(source); + zip_discard(archive); + return -1; + } + if (zip_file_set_encryption(archive, index, ZIP_EM_AES_256, password) < 0) { + fprintf(stderr, "failed to set file encryption: %s\n", zip_strerror(archive)); + zip_discard(archive); + return -1; + } + if (zip_close(archive) < 0) { + fprintf(stderr, "error closing archive: %s\n", zip_strerror(archive)); + zip_discard(archive); + return -1; + } + (void)remove(path); + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/ossfuzz/zip_write_encrypt_aes256_file_fuzzer_seed_corpus.zip b/thirdparty/libzip-1.11.3/ossfuzz/zip_write_encrypt_aes256_file_fuzzer_seed_corpus.zip new file mode 100644 index 0000000..431d738 Binary files /dev/null and b/thirdparty/libzip-1.11.3/ossfuzz/zip_write_encrypt_aes256_file_fuzzer_seed_corpus.zip differ diff --git a/thirdparty/libzip-1.11.3/ossfuzz/zip_write_encrypt_pkware_file_fuzzer.c b/thirdparty/libzip-1.11.3/ossfuzz/zip_write_encrypt_pkware_file_fuzzer.c new file mode 100644 index 0000000..ed1704a --- /dev/null +++ b/thirdparty/libzip-1.11.3/ossfuzz/zip_write_encrypt_pkware_file_fuzzer.c @@ -0,0 +1,61 @@ +#include +#include +#include +#include +#include + +/** +This fuzzing target takes input data, creates a ZIP archive, load +it to a buffer, adds a file to it with traditional PKWARE +encryption and a specified password, and then closes and removes +the archive. + +The purpose of this fuzzer is to test security of ZIP archive +handling and encryption in the libzip by subjecting it to various +inputs, including potentially malicious or malformed data of +different file types. +**/ + +#ifdef __cplusplus +extern "C" +#endif +int +LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + const char *path = "test_pkware.zip"; + const char *password = "password"; + const char *file = "filename"; + int error = 0; + struct zip *archive; + + (void)remove(path); + if ((archive = zip_open(path, ZIP_CREATE, &error)) == NULL) { + return -1; + } + + struct zip_source *source = zip_source_buffer(archive, data, size, 0); + if (source == NULL) { + fprintf(stderr, "failed to create source buffer. %s\n", zip_strerror(archive)); + zip_discard(archive); + return -1; + } + + int index = (int)zip_file_add(archive, file, source, ZIP_FL_OVERWRITE); + if (index < 0) { + fprintf(stderr, "failed to add file to archive: %s\n", zip_strerror(archive)); + zip_discard(archive); + return -1; + } + if (zip_file_set_encryption(archive, index, ZIP_EM_TRAD_PKWARE, password) < 0) { + fprintf(stderr, "failed to set file encryption: %s\n", zip_strerror(archive)); + zip_discard(archive); + return -1; + } + if (zip_close(archive) < 0) { + fprintf(stderr, "error closing archive: %s\n", zip_strerror(archive)); + zip_discard(archive); + return -1; + } + (void)remove(path); + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/regress/CMakeLists.txt b/thirdparty/libzip-1.11.3/regress/CMakeLists.txt new file mode 100644 index 0000000..c3af1ea --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/CMakeLists.txt @@ -0,0 +1,110 @@ +check_function_exists(getopt HAVE_GETOPT) + +set(TEST_PROGRAMS + add_from_filep + can_clone_file + fopen_unchanged + fseek + nonrandomopentest + liboverride-test +) + +set(GETOPT_USERS + fread + tryopen +) + +set(HOLE_USERS + hole + ziptool_regress +) + +set(ZIP_PROGRAMS ${TEST_PROGRAMS} ${GETOPT_USERS} ${HOLE_USERS}) + +foreach(PROGRAM IN LISTS ZIP_PROGRAMS) + add_executable(${PROGRAM} ${PROGRAM}.c) + target_include_directories(${PROGRAM} PRIVATE BEFORE ${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}) + target_link_libraries(${PROGRAM} zip) +endforeach() + +# both programs using source_hole.c also use getopt +if(NOT HAVE_GETOPT) + foreach(PROGRAM IN LISTS GETOPT_USERS HOLE_USERS) + target_sources(${PROGRAM} PRIVATE ../src/getopt.c) + target_include_directories(${PROGRAM} PRIVATE BEFORE ${PROJECT_SOURCE_DIR}/src) + endforeach() +endif(NOT HAVE_GETOPT) + +foreach(PROGRAM IN LISTS HOLE_USERS) + target_sources(${PROGRAM} PRIVATE source_hole.c) +endforeach() + +foreach(PROGRAM IN LISTS FUZZ_PROGRAMS) + target_sources(${PROGRAM} PRIVATE fuzz_main.c) +endforeach() + +# for including ziptool.c +target_include_directories(ziptool_regress PRIVATE BEFORE ${PROJECT_SOURCE_DIR}/src) + +set(DL_USERS + # malloc + nonrandomopen + liboverride +) + +foreach(PROGRAM IN LISTS DL_USERS) + add_library(${PROGRAM} MODULE ${PROGRAM}.c) + target_include_directories(${PROGRAM} PRIVATE BEFORE ${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}) +endforeach() + +add_custom_target(cleanup + COMMAND ${CMAKE_COMMAND} -DDIR=${PROJECT_BINARY_DIR}/regress -P ${PROJECT_SOURCE_DIR}/regress/cleanup.cmake + ) + +add_custom_target(testinput + ALL + VERBATIM + COMMAND ${CMAKE_COMMAND} -E tar x ${PROJECT_SOURCE_DIR}/regress/manyfiles-zip.zip + COMMAND ${CMAKE_COMMAND} -E tar x ${PROJECT_SOURCE_DIR}/regress/bigzero-zip.zip + DEPENDS ${PROJECT_SOURCE_DIR}/regress/manyfiles-zip.zip ${PROJECT_SOURCE_DIR}/regress/bigzero-zip.zip +) + +set_property(DIRECTORY PROPERTY ADDITIONAL_MAKE_CLEAN_FILES + bigzero.zip + manyfiles-133000.zip + manyfiles-65536.zip + manyfiles-fewer.zip + manyfiles-more.zip + manyfiles-zip64-modulo.zip + manyfiles-zip64.zip + manyfiles.zip +) + +set(path "$;$ENV{PATH}") +if (TARGET zlib) + set(path "$;${path}") +endif() +string(REPLACE ";" "\\;" path "${path}") + +set(ENV{srcdir} ${PROJECT_SOURCE_DIR}/regress) + +file(GLOB EXTRA_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/*.test) +foreach(FULL_CASE IN LISTS EXTRA_TESTS) + get_filename_component(CASE ${FULL_CASE} NAME) + add_test(NAME ${CASE} COMMAND ${NIHTEST} -v ${CASE}) + # TODO: add --bin-sub-directory $ + set_tests_properties(${CASE} PROPERTIES SKIP_RETURN_CODE 77) + set_tests_properties(${CASE} PROPERTIES ENVIRONMENT "PATH=${path}") +endforeach() + +set(XFAIL_TESTS +# zipcmp_zip_dir_slash.test +) + +foreach(CASE ${XFAIL_TESTS}) + set_tests_properties(${CASE} PROPERTIES WILL_FAIL TRUE) +endforeach() + +add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) + +configure_file(nihtest.conf.in nihtest.conf @ONLY) diff --git a/thirdparty/libzip-1.11.3/regress/add_dir.test b/thirdparty/libzip-1.11.3/regress/add_dir.test new file mode 100644 index 0000000..bdc7419 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_dir.test @@ -0,0 +1,4 @@ +# add directories to zip +return 0 +arguments testdir.zip add_dir testdir/ add_dir testdir-noslash +file testdir.zip {} testdir.zip diff --git a/thirdparty/libzip-1.11.3/regress/add_from_buffer.test b/thirdparty/libzip-1.11.3/regress/add_from_buffer.test new file mode 100644 index 0000000..302283d --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_from_buffer.test @@ -0,0 +1,4 @@ +# add buffer contents as file to zip +return 0 +arguments testbuffer.zip add teststring.txt "This is a test, and it seems to have been successful.\n" +file testbuffer.zip {} testbuffer.zip diff --git a/thirdparty/libzip-1.11.3/regress/add_from_file.test b/thirdparty/libzip-1.11.3/regress/add_from_file.test new file mode 100644 index 0000000..0f0fff5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_from_file.test @@ -0,0 +1,5 @@ +# add file to zip +return 0 +arguments -- testfile.zip add_file testfile.txt testfile.txt 0 -1 +file testfile.txt testfile.txt +file testfile.zip {} testfile.zip diff --git a/thirdparty/libzip-1.11.3/regress/add_from_file_duplicate.test b/thirdparty/libzip-1.11.3/regress/add_from_file_duplicate.test new file mode 100644 index 0000000..51665ef --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_from_file_duplicate.test @@ -0,0 +1,8 @@ +# add already existing file to zip, making duplicate names +return 1 +arguments -- testfile.zip add_file testfile.txt testfile.txt 0 -1 +file testfile.txt testfile.txt +file testfile.zip testfile.zip +stderr +can't add file 'testfile.txt': File already exists +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/add_from_file_twice_duplicate.test b/thirdparty/libzip-1.11.3/regress/add_from_file_twice_duplicate.test new file mode 100644 index 0000000..d976837 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_from_file_twice_duplicate.test @@ -0,0 +1,8 @@ +# add file to zip twice, making duplicate names +return 1 +arguments -- testfile.zip add_file testfile.txt testfile.txt 0 -1 add_file testfile.txt testfile.txt 0 -1 +file testfile.txt testfile.txt +file testfile.zip {} testfile.zip +stderr +can't add file 'testfile.txt': File already exists +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/add_from_file_unchange.test b/thirdparty/libzip-1.11.3/regress/add_from_file_unchange.test new file mode 100644 index 0000000..098bd94 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_from_file_unchange.test @@ -0,0 +1,4 @@ +# add file to zip, but revert before closing +return 0 +arguments -- testfile.zip add_file testfile.txt testfile.txt 0 -1 unchange 0 +file testfile.txt testfile.txt diff --git a/thirdparty/libzip-1.11.3/regress/add_from_filep.c b/thirdparty/libzip-1.11.3/regress/add_from_filep.c new file mode 100644 index 0000000..10c2615 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_from_filep.c @@ -0,0 +1,96 @@ +/* + add_from_filep.c -- test case for adding file to archive + Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include +#include + +#include "zip.h" + +static const char *prg; + +int +main(int argc, char *argv[]) { + const char *archive; + const char *file; + const char *name; + zip_t *za; + zip_source_t *zs; + int err; + FILE *fp; + + prg = argv[0]; + + if (argc != 3) { + fprintf(stderr, "usage: %s archive file\n", prg); + return 1; + } + + archive = argv[1]; + file = argv[2]; + + if ((za = zip_open(archive, ZIP_CREATE, &err)) == NULL) { + zip_error_t error; + zip_error_init_with_code(&error, err); + fprintf(stderr, "%s: can't open zip archive '%s': %s\n", prg, archive, zip_error_strerror(&error)); + zip_error_fini(&error); + return 1; + } + + if ((fp = fopen(file, "rb")) == NULL) { + fprintf(stderr, "%s: can't open input file '%s': %s\n", prg, file, strerror(errno)); + return 1; + } + + if ((zs = zip_source_filep(za, fp, 0, -1)) == NULL) { + fprintf(stderr, "%s: error creating file source for '%s': %s\n", prg, file, zip_strerror(za)); + return 1; + } + + if ((name = strrchr(file, '/')) == NULL) + name = file; + + if (zip_file_add(za, name, zs, 0) == -1) { + zip_source_free(zs); + fprintf(stderr, "%s: can't add file '%s': %s\n", prg, file, zip_strerror(za)); + return 1; + } + + if (zip_close(za) == -1) { + fprintf(stderr, "%s: can't close zip archive '%s': %s\n", prg, archive, zip_strerror(za)); + return 1; + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/regress/add_from_filep.test b/thirdparty/libzip-1.11.3/regress/add_from_filep.test new file mode 100644 index 0000000..964c0eb --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_from_filep.test @@ -0,0 +1,6 @@ +# add file to zip +program add_from_filep +return 0 +arguments testfile.zip testfile.txt +file testfile.txt testfile.txt +file testfile.zip {} testfile.zip diff --git a/thirdparty/libzip-1.11.3/regress/add_from_stdin.test b/thirdparty/libzip-1.11.3/regress/add_from_stdin.test new file mode 100644 index 0000000..d78c212 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_from_stdin.test @@ -0,0 +1,7 @@ +# add stdin to zip +arguments -- teststdin.zip add_file teststring.txt /dev/stdin 0 -1 +return 0 +file teststdin.zip {} teststdin.zip +stdin +This is a test, and it seems to have been successful. +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/add_from_zip_closed.test b/thirdparty/libzip-1.11.3/regress/add_from_zip_closed.test new file mode 100644 index 0000000..6d7e1ad --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_from_zip_closed.test @@ -0,0 +1,7 @@ +# add deflated file from zip to zip, but close the source before it can be read +return 1 +arguments -- testfile.zip add_from_zip abac-repeat.txt testdeflated.zzip 0 0 -1 zin_close 0 +file testdeflated.zzip testdeflated.zip +stderr +can't close zip archive 'testfile.zip': Containing zip archive was closed +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/add_from_zip_deflated.test b/thirdparty/libzip-1.11.3/regress/add_from_zip_deflated.test new file mode 100644 index 0000000..3edb0ff --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_from_zip_deflated.test @@ -0,0 +1,5 @@ +# add deflated file from zip to zip +return 0 +arguments -- testfile.zip add_from_zip abac-repeat.txt testdeflated.zzip 0 0 -1 +file testdeflated.zzip testdeflated.zip +file testfile.zip {} testdeflated.zip diff --git a/thirdparty/libzip-1.11.3/regress/add_from_zip_deflated2.test b/thirdparty/libzip-1.11.3/regress/add_from_zip_deflated2.test new file mode 100644 index 0000000..729afea --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_from_zip_deflated2.test @@ -0,0 +1,5 @@ +# add deflated files from zip to zip +return 0 +arguments -- testfile.zip add_from_zip abac-repeat.txt testdeflated.zzip 0 0 -1 add_from_zip abac-repeat2.txt testdeflated.zzip 0 0 -1 +file testdeflated.zzip testdeflated.zip +file testfile.zip {} testdeflated2.zip diff --git a/thirdparty/libzip-1.11.3/regress/add_from_zip_partial_deflated.test b/thirdparty/libzip-1.11.3/regress/add_from_zip_partial_deflated.test new file mode 100644 index 0000000..590360a --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_from_zip_partial_deflated.test @@ -0,0 +1,5 @@ +# add parts of a file from zip to zip +return 0 +arguments -- testfile.zip add_from_zip first firstsecond.zzip 0 0 9 add_from_zip second firstsecond.zzip 0 9 -1 +file firstsecond.zzip firstsecond.zip +file testfile.zip {} firstsecond-split-stored.zip diff --git a/thirdparty/libzip-1.11.3/regress/add_from_zip_partial_stored.test b/thirdparty/libzip-1.11.3/regress/add_from_zip_partial_stored.test new file mode 100644 index 0000000..023780b --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_from_zip_partial_stored.test @@ -0,0 +1,5 @@ +# add parts of a file from zip to zip +return 0 +arguments -- testfile.zip add_from_zip first firstsecond.zzip 1 0 9 add_from_zip second firstsecond.zzip 1 9 -1 +file firstsecond.zzip firstsecond.zip +file testfile.zip {} firstsecond-split-stored.zip diff --git a/thirdparty/libzip-1.11.3/regress/add_from_zip_stored.test b/thirdparty/libzip-1.11.3/regress/add_from_zip_stored.test new file mode 100644 index 0000000..e32d2c6 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_from_zip_stored.test @@ -0,0 +1,5 @@ +# add stored file from zip to zip +return 0 +arguments -- testfile.zip add_from_zip abac-repeat.txt teststored.zzip 0 0 -1 +file teststored.zzip teststored.zip +file testfile.zip {} testdeflated.zip diff --git a/thirdparty/libzip-1.11.3/regress/add_stored.test b/thirdparty/libzip-1.11.3/regress/add_stored.test new file mode 100644 index 0000000..889a7f8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_stored.test @@ -0,0 +1,4 @@ +# add file, set compression method to ZIP_CM_STORE +return 0 +arguments -n test.zip add foo foo set_file_compression 0 store 0 +file test.zip {} foo-stored.zip diff --git a/thirdparty/libzip-1.11.3/regress/add_stored_in_memory.test b/thirdparty/libzip-1.11.3/regress/add_stored_in_memory.test new file mode 100644 index 0000000..7b67607 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/add_stored_in_memory.test @@ -0,0 +1,4 @@ +# add file, set compression method to ZIP_CM_STORE +return 0 +arguments -mn test.zip add foo foo set_file_compression 0 store 0 +file test.zip {} foo-stored.zip diff --git a/thirdparty/libzip-1.11.3/regress/bigstored.zh b/thirdparty/libzip-1.11.3/regress/bigstored.zh new file mode 100644 index 0000000..2a53bff Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/bigstored.zh differ diff --git a/thirdparty/libzip-1.11.3/regress/bigzero-zip.zip b/thirdparty/libzip-1.11.3/regress/bigzero-zip.zip new file mode 100644 index 0000000..158cb6d Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/bigzero-zip.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/bogus.zip b/thirdparty/libzip-1.11.3/regress/bogus.zip new file mode 100644 index 0000000..7e538b6 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/bogus.zip @@ -0,0 +1 @@ +bogus data diff --git a/thirdparty/libzip-1.11.3/regress/broken.zip b/thirdparty/libzip-1.11.3/regress/broken.zip new file mode 100644 index 0000000..2008c32 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/broken.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/buffer-fragment-read.test b/thirdparty/libzip-1.11.3/regress/buffer-fragment-read.test new file mode 100644 index 0000000..3127de4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/buffer-fragment-read.test @@ -0,0 +1,7 @@ +# test reading from a buffer fragment source +return 0 +arguments -mF 1024 test.zip cat 1 +file test.zip cm-default.zip +stdout +uncompressible +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/buffer-fragment-write.test b/thirdparty/libzip-1.11.3/regress/buffer-fragment-write.test new file mode 100644 index 0000000..a15a4f1 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/buffer-fragment-write.test @@ -0,0 +1,4 @@ +# rename file inside zip archive +return 0 +arguments -mF 100 rename.zip rename 1 notfile2 +file rename.zip testcomment.zip rename_ok.zip diff --git a/thirdparty/libzip-1.11.3/regress/can_clone_file.c b/thirdparty/libzip-1.11.3/regress/can_clone_file.c new file mode 100644 index 0000000..848ff35 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/can_clone_file.c @@ -0,0 +1,127 @@ +/* + can_clone_file.c -- does the current filesystem support cloning + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include "config.h" + +#ifdef HAVE_CLONEFILE +#include +#include +#include +#include +#include +#include +#include +#elif defined(HAVE_FICLONERANGE) +#include +#include +#include +#include +#include +#include +#endif + +int +main(int argc, char *argv[]) { +#ifdef HAVE_CLONEFILE + struct statfs fs; + struct attrlist attribute_list; + struct { + uint32_t size; + vol_capabilities_attr_t capabilities; + } volume_attributes; + + if (statfs(".", &fs) < 0) { + fprintf(stderr, "%s: can't get mount point of current directory: %s\n", argv[0], strerror(errno)); + exit(1); + } + + /* Not all volumes support clonefile(). A volume can be tested for + clonefile() support by using getattrlist(2) to get the volume + capabilities attribute ATTR_VOL_CAPABILITIES, and then testing the + VOL_CAP_INT_CLONE flag. */ + + memset(&attribute_list, 0, sizeof(attribute_list)); + attribute_list.bitmapcount = ATTR_BIT_MAP_COUNT; + attribute_list.volattr = ATTR_VOL_INFO | ATTR_VOL_CAPABILITIES; + memset(&volume_attributes, 0, sizeof(volume_attributes)); + + if (getattrlist(fs.f_mntonname, &attribute_list, &volume_attributes, sizeof(volume_attributes), 0) < 0) { + fprintf(stderr, "%s: can't get volume capabilities of '%s': %s\n", argv[0], fs.f_mntonname, strerror(errno)); + exit(1); + } + + if (volume_attributes.capabilities.capabilities[VOL_CAPABILITIES_INTERFACES] & VOL_CAP_INT_CLONE) { + exit(0); + } +#elif defined(HAVE_FICLONERANGE) + char namea[32] = "a.fioclone.XXXXXX"; + char nameb[32] = "b.fioclone.XXXXXX"; + int fda, fdb, ret; + struct file_clone_range range; + + if ((fda = mkstemp(namea)) < 0) { + fprintf(stderr, "can't create temp file a: %s\n", strerror(errno)); + exit(1); + } + if ((fdb = mkstemp(nameb)) < 0) { + fprintf(stderr, "can't create temp file b: %s\n", strerror(errno)); + (void)close(fda); + (void)remove(namea); + exit(1); + } + if (write(fda, "test\n", 5) < 0) { + fprintf(stderr, "can't write temp file a: %s\n", strerror(errno)); + (void)close(fda); + (void)remove(namea); + close(fdb); + (void)remove(nameb); + exit(1); + } + range.src_fd = fda; + range.src_offset = 0; + range.src_length = 0; + range.dest_offset = 0; + ret = ioctl(fdb, FICLONERANGE, &range); + (void)close(fda); + (void)close(fdb); + (void)remove(namea); + (void)remove(nameb); + if (ret >= 0) { + exit(0); + } +#endif + + exit(1); +} diff --git a/thirdparty/libzip-1.11.3/regress/cancel_45.test b/thirdparty/libzip-1.11.3/regress/cancel_45.test new file mode 100644 index 0000000..591c410 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/cancel_45.test @@ -0,0 +1,12 @@ +# test default compression stores if smaller; test cancel after 45% +return 1 +arguments -n -- test.zip cancel 45 add compressible aaaaaaaaaaaaaa add uncompressible uncompressible add_nul large-compressible 8200 add_file large-uncompressible large-uncompressible 0 -1 +file large-uncompressible large-uncompressible +stdout +0.0% done +25.0% done +50.0% done +end-of-inline-data +stderr +can't close zip archive 'test.zip': Operation cancelled +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/cancel_90.test b/thirdparty/libzip-1.11.3/regress/cancel_90.test new file mode 100644 index 0000000..ac34af7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/cancel_90.test @@ -0,0 +1,14 @@ +# test default compression stores if smaller; test cancel after 90% +return 1 +arguments -n -- test.zip cancel 90 add compressible aaaaaaaaaaaaaa add uncompressible uncompressible add_nul large-compressible 8200 add_file large-uncompressible large-uncompressible 0 -1 +file large-uncompressible large-uncompressible +stdout +0.0% done +25.0% done +50.0% done +75.0% done +100.0% done +end-of-inline-data +stderr +can't close zip archive 'test.zip': Operation cancelled +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/changing-size-decreases-fixed.test b/thirdparty/libzip-1.11.3/regress/changing-size-decreases-fixed.test new file mode 100644 index 0000000..f6962a8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/changing-size-decreases-fixed.test @@ -0,0 +1,12 @@ +description size of input file decreases between add and close +arguments test.zip add_file new muchlonger 0 11 extract_as 0 muchlonger +return 1 +file test.zip changing-size.zip changing-size.zip +file muchlonger +muchlonger +end-of-inline-data +short +end-of-inline-data +stderr +can't close zip archive 'test.zip': Unexpected length of data +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/changing-size-decreases.test b/thirdparty/libzip-1.11.3/regress/changing-size-decreases.test new file mode 100644 index 0000000..cbee7a0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/changing-size-decreases.test @@ -0,0 +1,12 @@ +description size of input file decreases between add and close +arguments test.zip add_file new muchlonger 0 0 extract_as 0 muchlonger +return 1 +file test.zip changing-size.zip changing-size.zip +file muchlonger +muchlonger +end-of-inline-data +short +end-of-inline-data +stderr +can't close zip archive 'test.zip': Unexpected length of data +end-of-inline-data \ No newline at end of file diff --git a/thirdparty/libzip-1.11.3/regress/changing-size-increases-fixed.test b/thirdparty/libzip-1.11.3/regress/changing-size-increases-fixed.test new file mode 100644 index 0000000..c04c29e --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/changing-size-increases-fixed.test @@ -0,0 +1,8 @@ +description size of input file increases between add and close +arguments test.zip add_file new short 0 6 extract_as 1 short +file test.zip changing-size.zip changing-size-muchlo.zip +file short +short +end-of-inline-data +muchlonger +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/changing-size-increases-unchecked.test b/thirdparty/libzip-1.11.3/regress/changing-size-increases-unchecked.test new file mode 100644 index 0000000..56f7927 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/changing-size-increases-unchecked.test @@ -0,0 +1,8 @@ +description size of input file increases between add and close +arguments -- test.zip add_file new short 0 -2 extract_as 1 short +file test.zip changing-size.zip changing-size-muchlonger.zip +file short +short +end-of-inline-data +muchlonger +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/changing-size-increases.test b/thirdparty/libzip-1.11.3/regress/changing-size-increases.test new file mode 100644 index 0000000..96d518c --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/changing-size-increases.test @@ -0,0 +1,6 @@ +description size of input file increases between add and close +arguments test.zip add_file new short 0 0 extract_as 1 short +file test.zip changing-size.zip changing-size-muchl.zip +file short short +muchlonger +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/changing-size-muchl.zip b/thirdparty/libzip-1.11.3/regress/changing-size-muchl.zip new file mode 100644 index 0000000..7fd7159 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/changing-size-muchl.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/changing-size-muchlo.zip b/thirdparty/libzip-1.11.3/regress/changing-size-muchlo.zip new file mode 100644 index 0000000..60eab9e Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/changing-size-muchlo.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/changing-size-muchlonger.zip b/thirdparty/libzip-1.11.3/regress/changing-size-muchlonger.zip new file mode 100644 index 0000000..301ae5c Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/changing-size-muchlonger.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/changing-size.zip b/thirdparty/libzip-1.11.3/regress/changing-size.zip new file mode 100644 index 0000000..ff71eb9 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/changing-size.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/check_torrentzip_fail.test b/thirdparty/libzip-1.11.3/regress/check_torrentzip_fail.test new file mode 100644 index 0000000..694328d --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/check_torrentzip_fail.test @@ -0,0 +1,7 @@ +# check if file is torrentzip, fails +return 0 +arguments testfile.zzip get_archive_flag is-torrentzip +file testfile.zzip testfile.zip +stdout +0 +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/check_torrentzip_modified.test b/thirdparty/libzip-1.11.3/regress/check_torrentzip_modified.test new file mode 100644 index 0000000..04f27b5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/check_torrentzip_modified.test @@ -0,0 +1,7 @@ +# check if file is torrentzip, fails because it was modified afterwards +return 0 +arguments testfile.zzip get_archive_flag is-torrentzip +file testfile.zzip testfile-torrentzip-modified.zip +stdout +0 +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/check_torrentzip_success.test b/thirdparty/libzip-1.11.3/regress/check_torrentzip_success.test new file mode 100644 index 0000000..3cb2b92 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/check_torrentzip_success.test @@ -0,0 +1,7 @@ +# check if file is torrentzip, succeeds +return 0 +arguments testfile.zzip get_archive_flag is-torrentzip +file testfile.zzip testfile-torrentzip.zip +stdout +1 +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/cleanup.cmake b/thirdparty/libzip-1.11.3/regress/cleanup.cmake new file mode 100644 index 0000000..94fd13f --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/cleanup.cmake @@ -0,0 +1,7 @@ +# expect variable DIR +FILE(GLOB CLEANDIRS "${DIR}/sandbox-*.d[0-9]*") +IF (CLEANDIRS) + MESSAGE(STATUS "Removing ${CLEANDIRS}") + FILE(REMOVE_RECURSE ${CLEANDIRS}) +ENDIF() + diff --git a/thirdparty/libzip-1.11.3/regress/clone-buffer-add.test b/thirdparty/libzip-1.11.3/regress/clone-buffer-add.test new file mode 100644 index 0000000..e93c673 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/clone-buffer-add.test @@ -0,0 +1,4 @@ +# test cloning archive from buffer, add new file +return 0 +arguments -mF 100 test.zzip add new "A new file." set_file_mtime 3 1512998132 +file test.zzip gap.zip gap-add.zip diff --git a/thirdparty/libzip-1.11.3/regress/clone-buffer-delete.test b/thirdparty/libzip-1.11.3/regress/clone-buffer-delete.test new file mode 100644 index 0000000..9b79cf0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/clone-buffer-delete.test @@ -0,0 +1,4 @@ +# test cloning archive from buffer, deleting a file +return 0 +arguments -mF 100 test.zzip delete 2 +file test.zzip gap.zip gap-delete.zip diff --git a/thirdparty/libzip-1.11.3/regress/clone-buffer-replace.test b/thirdparty/libzip-1.11.3/regress/clone-buffer-replace.test new file mode 100644 index 0000000..a19cb33 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/clone-buffer-replace.test @@ -0,0 +1,4 @@ +# test cloning archive from buffer, replacing a file +return 0 +arguments -mF 100 test.zzip replace_file_contents 2 "A changed file." set_file_mtime 2 1512998082 +file test.zzip gap.zip gap-replace.zip diff --git a/thirdparty/libzip-1.11.3/regress/clone-fs-add.test b/thirdparty/libzip-1.11.3/regress/clone-fs-add.test new file mode 100644 index 0000000..46d4d03 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/clone-fs-add.test @@ -0,0 +1,5 @@ +# test cloning archive from filesystem, add new file +precheck ./can_clone_file +return 0 +arguments test.zzip add new "A new file." set_file_mtime 3 1512998132 +file test.zzip gap.zip gap-add.zip diff --git a/thirdparty/libzip-1.11.3/regress/clone-fs-delete.test b/thirdparty/libzip-1.11.3/regress/clone-fs-delete.test new file mode 100644 index 0000000..d52250c --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/clone-fs-delete.test @@ -0,0 +1,5 @@ +# test cloning archive from filesystem, deleting a file +precheck ./can_clone_file +return 0 +arguments test.zzip delete 2 +file test.zzip gap.zip gap-delete.zip diff --git a/thirdparty/libzip-1.11.3/regress/clone-fs-replace.test b/thirdparty/libzip-1.11.3/regress/clone-fs-replace.test new file mode 100644 index 0000000..d3c67f3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/clone-fs-replace.test @@ -0,0 +1,5 @@ +# test cloning archive from filesystem, replacing a file +precheck ./can_clone_file +return 0 +arguments test.zzip replace_file_contents 2 "A changed file." set_file_mtime 2 1512998082 +file test.zzip gap.zip gap-replace.zip diff --git a/thirdparty/libzip-1.11.3/regress/cm-default.test b/thirdparty/libzip-1.11.3/regress/cm-default.test new file mode 100644 index 0000000..d7baa6e --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/cm-default.test @@ -0,0 +1,5 @@ +# test default compression stores if smaller +return 0 +arguments -n -- test.zip add compressible aaaaaaaaaaaaaa add uncompressible uncompressible add_nul large-compressible 8200 add_file large-uncompressible large-uncompressible 0 -1 +file test.zip {} cm-default.zip +file large-uncompressible large-uncompressible diff --git a/thirdparty/libzip-1.11.3/regress/cm-default.zip b/thirdparty/libzip-1.11.3/regress/cm-default.zip new file mode 100644 index 0000000..341edd9 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/cm-default.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/convert_to_torrentzip.test b/thirdparty/libzip-1.11.3/regress/convert_to_torrentzip.test new file mode 100644 index 0000000..07a31c1 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/convert_to_torrentzip.test @@ -0,0 +1,4 @@ +# convert file to torrentzip +return 0 +arguments testfile.zzip set_archive_flag want-torrentzip 1 +file testfile.zzip testfile.zip testfile-torrentzip.zip diff --git a/thirdparty/libzip-1.11.3/regress/convert_to_torrentzip_ef.test b/thirdparty/libzip-1.11.3/regress/convert_to_torrentzip_ef.test new file mode 100644 index 0000000..475ff95 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/convert_to_torrentzip_ef.test @@ -0,0 +1,4 @@ +# convert file to torrentzip, removing extra fields, internal & external file attributes +return 0 +arguments testfile.zzip set_archive_flag want-torrentzip 1 +file testfile.zzip testfile-ef.zip testfile-torrentzip.zip diff --git a/thirdparty/libzip-1.11.3/regress/count_entries.test b/thirdparty/libzip-1.11.3/regress/count_entries.test new file mode 100644 index 0000000..af0348d --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/count_entries.test @@ -0,0 +1,7 @@ +# zip_open: count entries for archive with >65k entries +arguments manyfiles.zip get_num_entries 0 +return 0 +file manyfiles.zip manyfiles.zip +stdout +70000 entries in archive +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/create_empty_keep.test b/thirdparty/libzip-1.11.3/regress/create_empty_keep.test new file mode 100644 index 0000000..6409095 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/create_empty_keep.test @@ -0,0 +1,4 @@ +# delete last entry in zip archive +return 0 +arguments -n testfile.zzip set_archive_flag create-or-keep-file-for-empty-archive 1 +file testfile.zzip {} testempty.zip diff --git a/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-aes128.test b/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-aes128.test new file mode 100644 index 0000000..0081e1d --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-aes128.test @@ -0,0 +1,8 @@ +# test AES decryption support, extract file using correct password +features HAVE_CRYPTO +return 0 +arguments encrypt.zzip set_password foofoofoo cat 1 +file encrypt.zzip encrypt-aes128.zip +stdout +encrypted +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-aes192.test b/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-aes192.test new file mode 100644 index 0000000..7fc1af5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-aes192.test @@ -0,0 +1,8 @@ +# test AES decryption support, extract file using correct password +features HAVE_CRYPTO +return 0 +arguments encrypt.zzip set_password foofoofoo cat 1 +file encrypt.zzip encrypt-aes192.zip +stdout +encrypted +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-aes256.test b/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-aes256.test new file mode 100644 index 0000000..0dca913 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-aes256.test @@ -0,0 +1,8 @@ +# test AES decryption support, extract file using correct password +features HAVE_CRYPTO +return 0 +arguments encrypt.zzip set_password foofoofoo cat 1 +file encrypt.zzip encrypt-aes256.zip +stdout +encrypted +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-pkware-2.test b/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-pkware-2.test new file mode 100644 index 0000000..93a11c4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-pkware-2.test @@ -0,0 +1,11 @@ +# test decryption support, extract file using correct password +return 0 +arguments encrypt.zzip set_password 1234 cat 0 +file encrypt.zzip encrypt-1234.zip +stdout +I would love to try or hear the sample audio your app can produce. I do not want to purchase, because I've purchased so many apps that say they do something and do not deliver. + +Can you please add audio samples with text you've converted? I'd love to see the end results. + +Thanks! +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-pkware.test b/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-pkware.test new file mode 100644 index 0000000..64804fb --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/decrypt-correct-password-pkware.test @@ -0,0 +1,7 @@ +# test decryption support, extract file using correct password +return 0 +arguments encrypt.zzip set_password foo cat 0 +file encrypt.zzip encrypt.zip +stdout +foo +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/decrypt-empty-file-pkware.test b/thirdparty/libzip-1.11.3/regress/decrypt-empty-file-pkware.test new file mode 100644 index 0000000..aa3e2fe --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/decrypt-empty-file-pkware.test @@ -0,0 +1,6 @@ +# test decryption support, extract empty file using correct password +return 0 +arguments empty-pkware.zzip set_password 1 cat 0 +file empty-pkware.zzip empty-pkware.zip +stdout +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/decrypt-no-password-aes256.test b/thirdparty/libzip-1.11.3/regress/decrypt-no-password-aes256.test new file mode 100644 index 0000000..ec0767a --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/decrypt-no-password-aes256.test @@ -0,0 +1,8 @@ +# test AES decryption support, no password provided +features HAVE_CRYPTO +return 1 +arguments encrypt.zzip cat 1 +file encrypt.zzip encrypt-aes256.zip +stderr +can't open file at index '1': No password provided +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-aes128.test b/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-aes128.test new file mode 100644 index 0000000..dde00bf --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-aes128.test @@ -0,0 +1,8 @@ +# test AES decryption support, extract file using wrong password +features HAVE_CRYPTO +return 1 +arguments encrypt.zzip set_password notfoonotfoo cat 1 +file encrypt.zzip encrypt-aes128.zip +stderr +can't open file at index '1': Wrong password provided +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-aes192.test b/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-aes192.test new file mode 100644 index 0000000..bd1bec0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-aes192.test @@ -0,0 +1,8 @@ +# test AES decryption support, extract file using wrong password +features HAVE_CRYPTO +return 1 +arguments encrypt.zzip set_password notfoonotfoo cat 1 +file encrypt.zzip encrypt-aes192.zip +stderr +can't open file at index '1': Wrong password provided +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-aes256.test b/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-aes256.test new file mode 100644 index 0000000..1f17caf --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-aes256.test @@ -0,0 +1,8 @@ +# test AES decryption support, extract file using wrong password +features HAVE_CRYPTO +return 1 +arguments encrypt.zzip set_password notfoonotfoo cat 1 +file encrypt.zzip encrypt-aes256.zip +stderr +can't open file at index '1': Wrong password provided +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-pkware-2.test b/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-pkware-2.test new file mode 100644 index 0000000..72b8817 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-pkware-2.test @@ -0,0 +1,9 @@ +# test decryption support, extract file using wrong password (correct: "1234") +# In some cases, like this one, the password, even if incorrect, passes the +# minimal verification that's possible due to the zip file format specification. +return 1 +arguments encrypt.zzip set_password sample cat 0 +file encrypt.zzip encrypt-1234.zip +stderr +can't read file at index '0': Zlib error: data error +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-pkware.test b/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-pkware.test new file mode 100644 index 0000000..118fb07 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/decrypt-wrong-password-pkware.test @@ -0,0 +1,7 @@ +# test decryption support, extract file using wrong password +return 1 +arguments encrypt.zzip set_password notfoo cat 0 +file encrypt.zzip encrypt.zip +stderr +can't open file at index '0': Wrong password provided +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/delete_add_same.test b/thirdparty/libzip-1.11.3/regress/delete_add_same.test new file mode 100644 index 0000000..faa34f5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/delete_add_same.test @@ -0,0 +1,5 @@ +# delete entry in zip archive then add file of same name +# time is now(), so use zipcmp +return 0 +arguments testfile.zip delete 0 add testfile.txt test +file testfile.zip testfile.zip test2.zip diff --git a/thirdparty/libzip-1.11.3/regress/delete_invalid.test b/thirdparty/libzip-1.11.3/regress/delete_invalid.test new file mode 100644 index 0000000..246bba4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/delete_invalid.test @@ -0,0 +1,7 @@ +# delete last entry in zip archive +return 1 +arguments testfile.zzip delete 5 +file testfile.zzip testfile.zip +stderr +can't delete file at index '5': Invalid argument +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/delete_last.test b/thirdparty/libzip-1.11.3/regress/delete_last.test new file mode 100644 index 0000000..7810e0f --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/delete_last.test @@ -0,0 +1,4 @@ +# delete last entry in zip archive +return 0 +arguments testfile.zzip delete 0 +file testfile.zzip testfile.zip {} diff --git a/thirdparty/libzip-1.11.3/regress/delete_last_keep.test b/thirdparty/libzip-1.11.3/regress/delete_last_keep.test new file mode 100644 index 0000000..1e7bead --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/delete_last_keep.test @@ -0,0 +1,4 @@ +# delete last entry in zip archive +return 0 +arguments testfile.zzip set_archive_flag create-or-keep-file-for-empty-archive 1 delete 0 +file testfile.zzip testfile.zip testempty.zip diff --git a/thirdparty/libzip-1.11.3/regress/delete_multiple_last.test b/thirdparty/libzip-1.11.3/regress/delete_multiple_last.test new file mode 100644 index 0000000..891b86e --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/delete_multiple_last.test @@ -0,0 +1,4 @@ +# delete multiple entries in zip archive, emptying it +return 0 +arguments testfile.zzip delete 0 delete 1 delete 2 delete 3 +file testfile.zzip testcomment.zip {} diff --git a/thirdparty/libzip-1.11.3/regress/delete_multiple_partial.test b/thirdparty/libzip-1.11.3/regress/delete_multiple_partial.test new file mode 100644 index 0000000..099ff1b --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/delete_multiple_partial.test @@ -0,0 +1,4 @@ +# delete some entries in zip archive +return 0 +arguments testfile.zip delete 1 delete 3 +file testfile.zip testcomment.zip testcomment13.zip diff --git a/thirdparty/libzip-1.11.3/regress/delete_renamed_rename.test b/thirdparty/libzip-1.11.3/regress/delete_renamed_rename.test new file mode 100644 index 0000000..5a50bca --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/delete_renamed_rename.test @@ -0,0 +1,5 @@ +# delete renamed entry in zip archive then rename file to same name +# file date is now(), so use zipcmp +return 0 +arguments testfile.zip rename 0 something add test test delete 0 rename 1 testfile.txt +file testfile.zip testfile.zip test2.zip diff --git a/thirdparty/libzip-1.11.3/regress/empty-pkware.zip b/thirdparty/libzip-1.11.3/regress/empty-pkware.zip new file mode 100644 index 0000000..b729025 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/empty-pkware.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encrypt-1234.zip b/thirdparty/libzip-1.11.3/regress/encrypt-1234.zip new file mode 100644 index 0000000..09ef679 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/encrypt-1234.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encrypt-aes128-noentropy.zip b/thirdparty/libzip-1.11.3/regress/encrypt-aes128-noentropy.zip new file mode 100644 index 0000000..01d5bc6 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/encrypt-aes128-noentropy.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encrypt-aes128.zip b/thirdparty/libzip-1.11.3/regress/encrypt-aes128.zip new file mode 100644 index 0000000..e48c3c9 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/encrypt-aes128.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encrypt-aes192-noentropy.zip b/thirdparty/libzip-1.11.3/regress/encrypt-aes192-noentropy.zip new file mode 100644 index 0000000..0a9ad4b Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/encrypt-aes192-noentropy.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encrypt-aes192.zip b/thirdparty/libzip-1.11.3/regress/encrypt-aes192.zip new file mode 100644 index 0000000..98865ce Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/encrypt-aes192.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encrypt-aes256-noentropy.zip b/thirdparty/libzip-1.11.3/regress/encrypt-aes256-noentropy.zip new file mode 100644 index 0000000..b3a6cad Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/encrypt-aes256-noentropy.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encrypt-aes256.zip b/thirdparty/libzip-1.11.3/regress/encrypt-aes256.zip new file mode 100644 index 0000000..6349cb2 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/encrypt-aes256.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encrypt-none.zip b/thirdparty/libzip-1.11.3/regress/encrypt-none.zip new file mode 100644 index 0000000..c7ba696 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/encrypt-none.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encrypt-pkware-noentropy-2.zip b/thirdparty/libzip-1.11.3/regress/encrypt-pkware-noentropy-2.zip new file mode 100644 index 0000000..83aff1a Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/encrypt-pkware-noentropy-2.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encrypt-pkware-noentropy.zip b/thirdparty/libzip-1.11.3/regress/encrypt-pkware-noentropy.zip new file mode 100644 index 0000000..e0c39a7 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/encrypt-pkware-noentropy.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encrypt.test b/thirdparty/libzip-1.11.3/regress/encrypt.test new file mode 100644 index 0000000..869aa3f --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/encrypt.test @@ -0,0 +1,25 @@ +# test encryption support +# TODO: only checks recognition of encrypted entries for now. +return 0 +arguments encrypt.zzip stat 0 stat 1 +file encrypt.zzip encrypt.zip +stdout +name: 'encrypted' +index: '0' +size: '4' +compressed size: '16' +mtime: 'Mon Apr 24 2006 16:01:34' +crc: '7e3265a8' +compression method: '0' +encryption method: '1' + +name: 'plain' +index: '1' +size: '4' +compressed size: '4' +mtime: 'Mon Apr 24 2006 16:01:42' +crc: '7e3265a8' +compression method: '0' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/encrypt.zip b/thirdparty/libzip-1.11.3/regress/encrypt.zip new file mode 100644 index 0000000..e50aa38 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/encrypt.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encrypt_plus_extra.zip b/thirdparty/libzip-1.11.3/regress/encrypt_plus_extra.zip new file mode 100644 index 0000000..6936865 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/encrypt_plus_extra.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encrypt_plus_extra_modified_c.zip b/thirdparty/libzip-1.11.3/regress/encrypt_plus_extra_modified_c.zip new file mode 100644 index 0000000..f50d649 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/encrypt_plus_extra_modified_c.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encrypt_plus_extra_modified_l.zip b/thirdparty/libzip-1.11.3/regress/encrypt_plus_extra_modified_l.zip new file mode 100644 index 0000000..a546022 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/encrypt_plus_extra_modified_l.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-aes128.test b/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-aes128.test new file mode 100644 index 0000000..a7a9774 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-aes128.test @@ -0,0 +1,7 @@ +features HAVE_CRYPTO +precheck ./liboverride-test +description encrypt file without entropy, to make results repeatable +return 0 +preload nonrandomopen.so +arguments encrypt.zzip set_file_encryption 1 AES-128 no-entropy +file encrypt.zzip encrypt-none.zip encrypt-aes128-noentropy.zip diff --git a/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-aes192.test b/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-aes192.test new file mode 100644 index 0000000..97566ab --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-aes192.test @@ -0,0 +1,7 @@ +features HAVE_CRYPTO +precheck ./liboverride-test +description encrypt file without entropy, to make results repeatable +return 0 +preload nonrandomopen.so +arguments encrypt.zzip set_file_encryption 1 AES-192 no-entropy +file encrypt.zzip encrypt-none.zip encrypt-aes192-noentropy.zip diff --git a/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-aes256.test b/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-aes256.test new file mode 100644 index 0000000..923543c --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-aes256.test @@ -0,0 +1,7 @@ +features HAVE_CRYPTO +precheck ./liboverride-test +description encrypt file without entropy, to make results repeatable +return 0 +preload nonrandomopen.so +arguments encrypt.zzip set_file_encryption 1 AES-256 no-entropy +file encrypt.zzip encrypt-none.zip encrypt-aes256-noentropy.zip diff --git a/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-pkware-2.test b/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-pkware-2.test new file mode 100644 index 0000000..4bb991c --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-pkware-2.test @@ -0,0 +1,7 @@ +features HAVE_CRYPTO +precheck ./liboverride-test +description encrypt file by Traditional PKWare, set mtime (used in PKWare encryption) +return 0 +preload nonrandomopen.so +arguments encrypt.zzip set_file_mtime 1 1407272201 set_file_encryption 1 PKWARE no-entropy +file encrypt.zzip encrypt-none.zip encrypt-pkware-noentropy-2.zip diff --git a/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-pkware.test b/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-pkware.test new file mode 100644 index 0000000..1196d29 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/encryption-nonrandom-pkware.test @@ -0,0 +1,7 @@ +features HAVE_CRYPTO +precheck ./liboverride-test +description encrypt file by Traditional PKWARE +return 0 +preload nonrandomopen.so +arguments encrypt.zzip set_file_encryption 1 PKWARE no-entropy +file encrypt.zzip encrypt-none.zip encrypt-pkware-noentropy.zip diff --git a/thirdparty/libzip-1.11.3/regress/encryption-remove.test b/thirdparty/libzip-1.11.3/regress/encryption-remove.test new file mode 100644 index 0000000..c9bbf62 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/encryption-remove.test @@ -0,0 +1,5 @@ +# test AES decryption support, remove encryption from file that has it +features HAVE_CRYPTO +return 0 +arguments encrypt.zzip set_password foofoofoo set_file_encryption 1 none "" +file encrypt.zzip encrypt-aes128.zip encrypt-none.zip diff --git a/thirdparty/libzip-1.11.3/regress/encryption-stat.test b/thirdparty/libzip-1.11.3/regress/encryption-stat.test new file mode 100644 index 0000000..a1cf7a7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/encryption-stat.test @@ -0,0 +1,25 @@ +features HAVE_CRYPTO +description encrypt file, look at stat before commit +return 0 +arguments encrypt.zzip stat 1 set_file_encryption 1 AES-128 no-entropy stat 1 unchange_all +file encrypt.zzip encrypt-none.zip +stdout +name: 'encrypted' +index: '1' +size: '10' +compressed size: '10' +mtime: 'Sat Jan 14 2017 21:27:26' +crc: 'fb8c5e55' +compression method: '0' +encryption method: '0' + +name: 'encrypted' +index: '1' +size: '10' +compressed size: '10' +mtime: 'Sat Jan 14 2017 21:27:26' +crc: 'fb8c5e55' +compression method: '0' +encryption method: '257' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/extra_add.test b/thirdparty/libzip-1.11.3/regress/extra_add.test new file mode 100644 index 0000000..a7479e9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/extra_add.test @@ -0,0 +1,9 @@ +# add extra field +#args encrypt.zip set_extra 0 2345 65535 cl extrafieldcontent +arguments encrypt.zip set_extra 0 2345 65535 cl extrafieldcontent get_extra_by_id 0 2345 0 c get_extra_by_id 0 2345 0 l +return 0 +file encrypt.zip encrypt.zip encrypt_plus_extra.zip +stdout +Extra field 0x0929: len 17, data 0x65787472616669656c64636f6e74656e74 +Extra field 0x0929: len 17, data 0x65787472616669656c64636f6e74656e74 +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/extra_add_multiple.test b/thirdparty/libzip-1.11.3/regress/extra_add_multiple.test new file mode 100644 index 0000000..9b9f3cf --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/extra_add_multiple.test @@ -0,0 +1,10 @@ +# add extra fields +arguments testfile.zip set_extra 0 2345 65535 cl extra1 set_extra 0 2345 65535 cl extra2 set_extra 0 2345 0 c extra1c set_extra 0 2345 1 l extra2l get_extra_by_id 0 2345 0 c get_extra_by_id 0 2345 1 c get_extra_by_id 0 2345 0 l get_extra_by_id 0 2345 1 l +return 0 +file testfile.zip testfile.zip testfile-plus-extra.zip +stdout +Extra field 0x0929: len 7, data 0x65787472613163 +Extra field 0x0929: len 6, data 0x657874726132 +Extra field 0x0929: len 6, data 0x657874726131 +Extra field 0x0929: len 7, data 0x6578747261326c +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/extra_count.test b/thirdparty/libzip-1.11.3/regress/extra_count.test new file mode 100644 index 0000000..6bf8489 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/extra_count.test @@ -0,0 +1,12 @@ +# count extra fields for index +arguments encrypt.zip count_extra 0 l count_extra 0 c count_extra 0 lc count_extra 1 l count_extra 1 c count_extra 1 lc +return 0 +file encrypt.zip encrypt.zip +stdout +Extra field count: 2 +Extra field count: 2 +Extra field count: 4 +Extra field count: 2 +Extra field count: 2 +Extra field count: 4 +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/extra_count_by_id.test b/thirdparty/libzip-1.11.3/regress/extra_count_by_id.test new file mode 100644 index 0000000..19e8ef8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/extra_count_by_id.test @@ -0,0 +1,24 @@ +# count extra fields for index +arguments encrypt.zip count_extra_by_id 0 0 l count_extra_by_id 0 1 l count_extra_by_id 0 21589 l count_extra_by_id 0 30805 l count_extra_by_id 0 21844 l count_extra_by_id 0 12345 l count_extra_by_id 0 0 c count_extra_by_id 0 1 c count_extra_by_id 0 21589 c count_extra_by_id 0 30805 c count_extra_by_id 0 21844 c count_extra_by_id 0 12345 c count_extra_by_id 0 0 cl count_extra_by_id 0 1 cl count_extra_by_id 0 21589 cl count_extra_by_id 0 30805 cl count_extra_by_id 0 21844 cl count_extra_by_id 0 12345 cl +return 0 +file encrypt.zip encrypt.zip +stdout +Extra field count: 0 +Extra field count: 0 +Extra field count: 1 +Extra field count: 1 +Extra field count: 0 +Extra field count: 0 +Extra field count: 0 +Extra field count: 0 +Extra field count: 1 +Extra field count: 1 +Extra field count: 0 +Extra field count: 0 +Extra field count: 0 +Extra field count: 0 +Extra field count: 2 +Extra field count: 2 +Extra field count: 0 +Extra field count: 0 +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/extra_count_ignore_zip64.test b/thirdparty/libzip-1.11.3/regress/extra_count_ignore_zip64.test new file mode 100644 index 0000000..cb6242a --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/extra_count_ignore_zip64.test @@ -0,0 +1,9 @@ +# count extra fields for index +arguments bigzero.zip count_extra 0 l count_extra 0 c count_extra 0 lc +return 0 +file bigzero.zip bigzero.zip +stdout +Extra field count: 0 +Extra field count: 0 +Extra field count: 0 +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/extra_delete.test b/thirdparty/libzip-1.11.3/regress/extra_delete.test new file mode 100644 index 0000000..daa73e8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/extra_delete.test @@ -0,0 +1,16 @@ +# delete extra field by index +arguments encrypt.zip get_extra 0 0 c get_extra 0 1 c get_extra 0 2 c get_extra 0 0 l get_extra 0 1 l get_extra 0 2 l delete_extra 0 2 c delete_extra 0 0 l get_extra 0 0 c get_extra 0 1 c get_extra 0 0 l get_extra 0 1 l +file encrypt.zip encrypt_plus_extra.zip encrypt.zip +return 0 +stdout +Extra field 0x5455: len 5, data 0x033dda4c44 +Extra field 0x7855: len 0 +Extra field 0x0929: len 17, data 0x65787472616669656c64636f6e74656e74 +Extra field 0x0929: len 17, data 0x65787472616669656c64636f6e74656e74 +Extra field 0x5455: len 9, data 0x033dda4c444dda4c44 +Extra field 0x7855: len 4, data 0x64001400 +Extra field 0x5455: len 5, data 0x033dda4c44 +Extra field 0x7855: len 0 +Extra field 0x5455: len 9, data 0x033dda4c444dda4c44 +Extra field 0x7855: len 4, data 0x64001400 +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/extra_delete_by_id.test b/thirdparty/libzip-1.11.3/regress/extra_delete_by_id.test new file mode 100644 index 0000000..34958a0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/extra_delete_by_id.test @@ -0,0 +1,8 @@ +# delete extra field by id and index +#args encrypt.zip set_extra 0 2345 65535 cl extrafieldcontent +arguments encrypt.zip delete_extra_by_id 0 2345 0 c delete_extra_by_id 0 2345 0 l get_extra_by_id 0 2345 0 c +return 1 +file encrypt.zip encrypt_plus_extra.zip encrypt.zip +stderr +can't get extra field data for file at index 0, extra field id 2345, ef index 0, flags 512: No such file +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/extra_field_align.test b/thirdparty/libzip-1.11.3/regress/extra_field_align.test new file mode 100644 index 0000000..dbe2212 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/extra_field_align.test @@ -0,0 +1,35 @@ +# try opening simulated Android APK zipaligned files, and similar inconsistent files +program tryopen +file extra_field_align_1-0.zzip extra_field_align_1-0.zip +file extra_field_align_1-ff.zzip extra_field_align_1-ff.zip +file extra_field_align_2-0.zzip extra_field_align_2-0.zip +file extra_field_align_2-ff.zzip extra_field_align_2-ff.zip +file extra_field_align_3-0.zzip extra_field_align_3-0.zip +file extra_field_align_3-ff.zzip extra_field_align_3-ff.zip +file extra_field_align_4-ff.zzip extra_field_align_4-ff.zip +file extra_field_align_1-ef_00.zzip extra_field_align_1-ef_00.zip +file extra_field_align_1-ef_ff.zzip extra_field_align_1-ef_ff.zip +file extra_field_align_2-ef_00.zzip extra_field_align_2-ef_00.zip +file extra_field_align_2-ef_ff.zzip extra_field_align_2-ef_ff.zip +file extra_field_align_3-ef_00.zzip extra_field_align_3-ef_00.zip +file extra_field_align_3-ef_ff.zzip extra_field_align_3-ef_ff.zip +arguments -s -c extra_field_align_1-0.zzip extra_field_align_1-ff.zzip extra_field_align_2-0.zzip extra_field_align_2-ff.zzip extra_field_align_3-0.zzip extra_field_align_3-ff.zzip extra_field_align_4-ff.zzip extra_field_align_1-ef_00.zzip extra_field_align_1-ef_ff.zzip extra_field_align_2-ef_00.zzip extra_field_align_2-ef_ff.zzip extra_field_align_3-ef_00.zzip extra_field_align_3-ef_ff.zzip +return 1 +stdout +opening 'extra_field_align_1-0.zzip' succeeded, 1 entries +opening 'extra_field_align_1-ff.zzip' returned error Zip archive inconsistent: entry 0: garbage at end of extra fields +opening 'extra_field_align_2-0.zzip' succeeded, 1 entries +opening 'extra_field_align_2-ff.zzip' returned error Zip archive inconsistent: entry 0: garbage at end of extra fields +opening 'extra_field_align_3-0.zzip' succeeded, 1 entries +opening 'extra_field_align_3-ff.zzip' returned error Zip archive inconsistent: entry 0: garbage at end of extra fields +opening 'extra_field_align_4-ff.zzip' succeeded, 1 entries +opening 'extra_field_align_1-ef_00.zzip' succeeded, 1 entries +opening 'extra_field_align_1-ef_ff.zzip' returned error Zip archive inconsistent: entry 0: garbage at end of extra fields +opening 'extra_field_align_2-ef_00.zzip' succeeded, 1 entries +opening 'extra_field_align_2-ef_ff.zzip' returned error Zip archive inconsistent: entry 0: garbage at end of extra fields +opening 'extra_field_align_3-ef_00.zzip' succeeded, 1 entries +opening 'extra_field_align_3-ef_ff.zzip' returned error Zip archive inconsistent: entry 0: garbage at end of extra fields +end-of-inline-data +stderr +6 errors +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/extra_field_align_1-0.zip b/thirdparty/libzip-1.11.3/regress/extra_field_align_1-0.zip new file mode 100644 index 0000000..11aaaac Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/extra_field_align_1-0.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/extra_field_align_1-ef_00.zip b/thirdparty/libzip-1.11.3/regress/extra_field_align_1-ef_00.zip new file mode 100644 index 0000000..c07777b Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/extra_field_align_1-ef_00.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/extra_field_align_1-ef_ff.zip b/thirdparty/libzip-1.11.3/regress/extra_field_align_1-ef_ff.zip new file mode 100644 index 0000000..d62e0ec Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/extra_field_align_1-ef_ff.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/extra_field_align_1-ff.zip b/thirdparty/libzip-1.11.3/regress/extra_field_align_1-ff.zip new file mode 100644 index 0000000..6b05df2 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/extra_field_align_1-ff.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/extra_field_align_2-0.zip b/thirdparty/libzip-1.11.3/regress/extra_field_align_2-0.zip new file mode 100644 index 0000000..c7072d2 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/extra_field_align_2-0.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/extra_field_align_2-ef_00.zip b/thirdparty/libzip-1.11.3/regress/extra_field_align_2-ef_00.zip new file mode 100644 index 0000000..68e4089 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/extra_field_align_2-ef_00.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/extra_field_align_2-ef_ff.zip b/thirdparty/libzip-1.11.3/regress/extra_field_align_2-ef_ff.zip new file mode 100644 index 0000000..be9510b Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/extra_field_align_2-ef_ff.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/extra_field_align_2-ff.zip b/thirdparty/libzip-1.11.3/regress/extra_field_align_2-ff.zip new file mode 100644 index 0000000..7bf88a0 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/extra_field_align_2-ff.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/extra_field_align_3-0.zip b/thirdparty/libzip-1.11.3/regress/extra_field_align_3-0.zip new file mode 100644 index 0000000..401e7b0 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/extra_field_align_3-0.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/extra_field_align_3-ef_00.zip b/thirdparty/libzip-1.11.3/regress/extra_field_align_3-ef_00.zip new file mode 100644 index 0000000..326f98d Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/extra_field_align_3-ef_00.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/extra_field_align_3-ef_ff.zip b/thirdparty/libzip-1.11.3/regress/extra_field_align_3-ef_ff.zip new file mode 100644 index 0000000..ab9d81f Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/extra_field_align_3-ef_ff.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/extra_field_align_3-ff.zip b/thirdparty/libzip-1.11.3/regress/extra_field_align_3-ff.zip new file mode 100644 index 0000000..c6fde73 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/extra_field_align_3-ff.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/extra_field_align_4-ff.zip b/thirdparty/libzip-1.11.3/regress/extra_field_align_4-ff.zip new file mode 100644 index 0000000..c23966f Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/extra_field_align_4-ff.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/extra_get.test b/thirdparty/libzip-1.11.3/regress/extra_get.test new file mode 100644 index 0000000..b0f76db --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/extra_get.test @@ -0,0 +1,13 @@ +# get extra fields for index +arguments encrypt.zip get_extra 0 0 l get_extra 0 0 c get_extra 0 1 l get_extra 0 1 c get_extra 0 2 l +return 1 +file encrypt.zip encrypt.zip +stdout +Extra field 0x5455: len 9, data 0x033dda4c444dda4c44 +Extra field 0x5455: len 5, data 0x033dda4c44 +Extra field 0x7855: len 4, data 0x64001400 +Extra field 0x7855: len 0 +end-of-inline-data +stderr +can't get extra field data for file at index 0, extra field 2, flags 256: No such file +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/extra_get_by_id.test b/thirdparty/libzip-1.11.3/regress/extra_get_by_id.test new file mode 100644 index 0000000..22d388d --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/extra_get_by_id.test @@ -0,0 +1,13 @@ +# get extra_by_id fields for index +arguments encrypt.zip get_extra_by_id 0 21589 0 l get_extra_by_id 0 30805 0 l get_extra_by_id 0 21589 0 c get_extra_by_id 0 30805 0 c get_extra_by_id 0 21544 0 c +return 1 +file encrypt.zip encrypt.zip +stdout +Extra field 0x5455: len 9, data 0x033dda4c444dda4c44 +Extra field 0x7855: len 4, data 0x64001400 +Extra field 0x5455: len 5, data 0x033dda4c44 +Extra field 0x7855: len 0 +end-of-inline-data +stderr +can't get extra field data for file at index 0, extra field id 21544, ef index 0, flags 512: No such file +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/extra_set.test b/thirdparty/libzip-1.11.3/regress/extra_set.test new file mode 100644 index 0000000..b60784b --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/extra_set.test @@ -0,0 +1,16 @@ +# set extra field +arguments -- encrypt get_extra 0 0 c get_extra 0 1 c get_extra 0 0 l get_extra 0 1 l set_extra 0 2345 -1 l extrafieldcontent set_extra 0 2345 -1 c extrafieldcontent get_extra 0 0 c get_extra 0 1 c get_extra 0 2 c get_extra 0 0 l get_extra 0 1 l get_extra 0 2 l +file encrypt encrypt.zip encrypt_plus_extra.zip +return 0 +stdout +Extra field 0x5455: len 5, data 0x033dda4c44 +Extra field 0x7855: len 0 +Extra field 0x5455: len 9, data 0x033dda4c444dda4c44 +Extra field 0x7855: len 4, data 0x64001400 +Extra field 0x5455: len 5, data 0x033dda4c44 +Extra field 0x7855: len 0 +Extra field 0x0929: len 17, data 0x65787472616669656c64636f6e74656e74 +Extra field 0x5455: len 9, data 0x033dda4c444dda4c44 +Extra field 0x7855: len 4, data 0x64001400 +Extra field 0x0929: len 17, data 0x65787472616669656c64636f6e74656e74 +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/extra_set_modify_c.test b/thirdparty/libzip-1.11.3/regress/extra_set_modify_c.test new file mode 100644 index 0000000..6db1545 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/extra_set_modify_c.test @@ -0,0 +1,18 @@ +# change existing central extra field +arguments encrypt.zip get_extra 0 0 c get_extra 0 1 c get_extra 0 2 c get_extra 0 0 l get_extra 0 1 l get_extra 0 2 l set_extra 0 2345 0 c Extrafieldcontent get_extra 0 0 c get_extra 0 1 c get_extra 0 2 c get_extra 0 0 l get_extra 0 1 l get_extra 0 2 l +file encrypt.zip encrypt_plus_extra.zip encrypt_plus_extra_modified_c.zip +return 0 +stdout +Extra field 0x5455: len 5, data 0x033dda4c44 +Extra field 0x7855: len 0 +Extra field 0x0929: len 17, data 0x65787472616669656c64636f6e74656e74 +Extra field 0x0929: len 17, data 0x65787472616669656c64636f6e74656e74 +Extra field 0x5455: len 9, data 0x033dda4c444dda4c44 +Extra field 0x7855: len 4, data 0x64001400 +Extra field 0x5455: len 5, data 0x033dda4c44 +Extra field 0x7855: len 0 +Extra field 0x0929: len 17, data 0x45787472616669656c64636f6e74656e74 +Extra field 0x0929: len 17, data 0x65787472616669656c64636f6e74656e74 +Extra field 0x5455: len 9, data 0x033dda4c444dda4c44 +Extra field 0x7855: len 4, data 0x64001400 +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/extra_set_modify_l.test b/thirdparty/libzip-1.11.3/regress/extra_set_modify_l.test new file mode 100644 index 0000000..60f251e --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/extra_set_modify_l.test @@ -0,0 +1,18 @@ +# change existing local extra field +arguments encrypt.zip get_extra 0 0 c get_extra 0 1 c get_extra 0 2 c get_extra 0 0 l get_extra 0 1 l get_extra 0 2 l set_extra 0 2345 0 l Extrafieldcontent get_extra 0 0 c get_extra 0 1 c get_extra 0 2 c get_extra 0 0 l get_extra 0 1 l get_extra 0 2 l +file encrypt.zip encrypt_plus_extra.zip encrypt_plus_extra_modified_l.zip +return 0 +stdout +Extra field 0x5455: len 5, data 0x033dda4c44 +Extra field 0x7855: len 0 +Extra field 0x0929: len 17, data 0x65787472616669656c64636f6e74656e74 +Extra field 0x0929: len 17, data 0x65787472616669656c64636f6e74656e74 +Extra field 0x5455: len 9, data 0x033dda4c444dda4c44 +Extra field 0x7855: len 4, data 0x64001400 +Extra field 0x5455: len 5, data 0x033dda4c44 +Extra field 0x7855: len 0 +Extra field 0x0929: len 17, data 0x65787472616669656c64636f6e74656e74 +Extra field 0x0929: len 17, data 0x45787472616669656c64636f6e74656e74 +Extra field 0x5455: len 9, data 0x033dda4c444dda4c44 +Extra field 0x7855: len 4, data 0x64001400 +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/fdopen_ok.test b/thirdparty/libzip-1.11.3/regress/fdopen_ok.test new file mode 100644 index 0000000..70b98cc --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/fdopen_ok.test @@ -0,0 +1,17 @@ +# zip_fdopen: stdin opens fine +#program ../src/ziptool +arguments /dev/stdin stat 0 +return 0 +file test.zip test.zip +stdin test.zip +stdout +name: 'test' +index: '0' +size: '5' +compressed size: '5' +mtime: 'Mon Oct 06 2003 15:46:42' +crc: '3bb935c6' +compression method: '0' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/file_comment_encmismatch.test b/thirdparty/libzip-1.11.3/regress/file_comment_encmismatch.test new file mode 100644 index 0000000..a5c6c22 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/file_comment_encmismatch.test @@ -0,0 +1,7 @@ +# set file comment to UTF-8 for CP437 encoded filename (adds InfoZIP extra field) +return 0 +arguments -i testfile.zip dummy +stdin +set_file_comment 0 ÄÖÜßäöü +end-of-inline-data +file testfile.zip test-cp437.zip test-cp437-comment-utf-8.zip diff --git a/thirdparty/libzip-1.11.3/regress/filename_duplicate.zip b/thirdparty/libzip-1.11.3/regress/filename_duplicate.zip new file mode 100644 index 0000000..96a11e7 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/filename_duplicate.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/filename_duplicate_empty.zip b/thirdparty/libzip-1.11.3/regress/filename_duplicate_empty.zip new file mode 100644 index 0000000..c4af0d8 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/filename_duplicate_empty.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/filename_empty.zip b/thirdparty/libzip-1.11.3/regress/filename_empty.zip new file mode 100644 index 0000000..d32e4e7 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/filename_empty.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/fileorder.zip b/thirdparty/libzip-1.11.3/regress/fileorder.zip new file mode 100644 index 0000000..3fcd81a Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/fileorder.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/firstsecond-split-deflated.zip b/thirdparty/libzip-1.11.3/regress/firstsecond-split-deflated.zip new file mode 100644 index 0000000..35b9a5c Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/firstsecond-split-deflated.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/firstsecond-split-stored.zip b/thirdparty/libzip-1.11.3/regress/firstsecond-split-stored.zip new file mode 100644 index 0000000..35f0684 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/firstsecond-split-stored.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/firstsecond.zip b/thirdparty/libzip-1.11.3/regress/firstsecond.zip new file mode 100644 index 0000000..3fbe7ad Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/firstsecond.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/foo-stored.zip b/thirdparty/libzip-1.11.3/regress/foo-stored.zip new file mode 100644 index 0000000..d3adc80 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/foo-stored.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/fopen_multiple.test b/thirdparty/libzip-1.11.3/regress/fopen_multiple.test new file mode 100644 index 0000000..b536318 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/fopen_multiple.test @@ -0,0 +1,9 @@ +# read contents from multiply opened unchanged file +return 0 +arguments test_open_multiple.zip fopen stuff fopen stuff fread 0 2 fread 1 4 fread 0 3 fread 1 3 fread 0 3 fread 1 1 unchange_all +file test_open_multiple.zip test_open_multiple.zip +stdout +opened 'stuff' as file 0 +opened 'stuff' as file 1 +ababcdcdeefgfghh +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/fopen_multiple_reopen.test b/thirdparty/libzip-1.11.3/regress/fopen_multiple_reopen.test new file mode 100644 index 0000000..5b15250 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/fopen_multiple_reopen.test @@ -0,0 +1,9 @@ +# read contents from multiply reopened changed file +return 0 +arguments test_open_multiple.zip replace_file_contents 0 12345678 fopen stuff fopen stuff fread 0 2 fread 1 4 fread 0 3 fread 1 3 fread 0 3 fread 1 1 unchange_all +file test_open_multiple.zip test_open_multiple.zip +stdout +opened 'stuff' as file 0 +opened 'stuff' as file 1 +1212343455676788 +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/fopen_unchanged.c b/thirdparty/libzip-1.11.3/regress/fopen_unchanged.c new file mode 100644 index 0000000..79dd91d --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/fopen_unchanged.c @@ -0,0 +1,90 @@ +/* + fopen_unchanged.c -- test case for adding file and reading from unchanged + Copyright (C) 2012-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include +#include + +#include "zip.h" + +const char *teststr = "This is a test.\n"; +const char *file = "teststring.txt"; + +int +main(int argc, char *argv[]) { + const char *archive; + zip_t *za; + zip_source_t *zs; + int err; + + if (argc != 2) { + fprintf(stderr, "usage: %s archive\n", argv[0]); + return 1; + } + + archive = argv[1]; + + if ((za = zip_open(archive, ZIP_CREATE, &err)) == NULL) { + zip_error_t error; + zip_error_init_with_code(&error, err); + fprintf(stderr, "can't open zip archive '%s': %s\n", archive, zip_error_strerror(&error)); + zip_error_fini(&error); + return 1; + } + + if ((zs = zip_source_buffer(za, teststr, strlen(teststr), 0)) == NULL) { + fprintf(stderr, "can't create zip_source from buffer: %s\n", zip_strerror(za)); + exit(1); + } + + if (zip_file_add(za, file, zs, 0) == -1) { + fprintf(stderr, "can't add file '%s': %s\n", file, zip_strerror(za)); + (void)zip_source_free(zs); + (void)zip_close(za); + return 1; + } + + if (zip_fopen(za, file, ZIP_FL_UNCHANGED) == NULL) { + fprintf(stderr, "can't zip_fopen file '%s': %s\n", file, zip_strerror(za)); + (void)zip_discard(za); + return 1; + } + + if (zip_close(za) == -1) { + fprintf(stderr, "can't close zip archive '%s': %s\n", archive, zip_strerror(za)); + return 1; + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/regress/fopen_unchanged.test b/thirdparty/libzip-1.11.3/regress/fopen_unchanged.test new file mode 100644 index 0000000..c74c370 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/fopen_unchanged.test @@ -0,0 +1,7 @@ +# add buffer contents as file to zip, then read unchanged from it +program fopen_unchanged +return 1 +arguments testbuffer.zip +stderr +can't zip_fopen file 'teststring.txt': No such file +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/fread.c b/thirdparty/libzip-1.11.3/regress/fread.c new file mode 100644 index 0000000..8840c28 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/fread.c @@ -0,0 +1,212 @@ +/* + fread.c -- test cases for reading from zip archives + Copyright (C) 2004-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config.h" + +#include +#include + +#ifndef HAVE_GETOPT +#include "getopt.h" +#endif + +#include "zip.h" + +enum when { WHEN_NEVER, WHEN_OPEN, WHEN_READ, WHEN_CLOSE }; + +const char *when_name[] = {"no", "zip_fopen", "zip_fread", "zip_fclose"}; + +static int do_read(zip_t *z, const char *name, zip_flags_t flags, enum when when_ex, int ze_ex, int se_ex); + +int verbose; + +const char *progname; +#define USAGE "usage: %s [-v] archive\n" + +int +main(int argc, char *argv[]) { + int fail, ze; + int c; + zip_t *z; + zip_source_t *zs; + char *archive; + zip_int64_t idx; + + verbose = 0; + fail = 0; + + progname = argv[0]; + + while ((c = getopt(argc, argv, "v")) != -1) { + switch (c) { + case 'v': + verbose = 1; + break; + + default: + fprintf(stderr, USAGE, progname); + return 1; + } + } + + + if (argc - optind != 1) { + fprintf(stderr, USAGE, progname); + return 1; + } + + archive = argv[optind]; + + if ((z = zip_open(archive, 0, &ze)) == NULL) { + zip_error_t error; + zip_error_init_with_code(&error, ze); + fprintf(stderr, "%s: can't open zip archive '%s': %s\n", progname, archive, zip_error_strerror(&error)); + zip_error_fini(&error); + return 1; + } + + fail += do_read(z, "storedok", 0, WHEN_NEVER, 0, 0); + fail += do_read(z, "deflateok", 0, WHEN_NEVER, 0, 0); + fail += do_read(z, "storedcrcerror", 0, WHEN_READ, ZIP_ER_CRC, 0); + fail += do_read(z, "deflatecrcerror", 0, WHEN_READ, ZIP_ER_CRC, 0); + fail += do_read(z, "deflatezliberror", 0, WHEN_READ, ZIP_ER_ZLIB, -3); +#ifndef __clang_analyzer__ /* This test intentionally violates nullability. */ + fail += do_read(z, NULL, 0, WHEN_OPEN, ZIP_ER_INVAL, 0); +#endif + fail += do_read(z, "nosuchfile", 0, WHEN_OPEN, ZIP_ER_NOENT, 0); + fail += do_read(z, "deflatezliberror", ZIP_FL_COMPRESSED, WHEN_NEVER, 0, 0); + fail += do_read(z, "deflatecrcerror", ZIP_FL_COMPRESSED, WHEN_NEVER, 0, 0); + fail += do_read(z, "storedcrcerror", ZIP_FL_COMPRESSED, WHEN_READ, ZIP_ER_CRC, 0); + fail += do_read(z, "storedok", ZIP_FL_COMPRESSED, WHEN_NEVER, 0, 0); + + fail += do_read(z, "cryptok", 0, WHEN_OPEN, ZIP_ER_NOPASSWD, 0); + zip_set_default_password(z, "crypt"); + fail += do_read(z, "cryptok", 0, WHEN_NEVER, 0, 0); + zip_set_default_password(z, "wrong"); + fail += do_read(z, "cryptok", 0, WHEN_OPEN, ZIP_ER_WRONGPASSWD, 0); + zip_set_default_password(z, NULL); + + zs = zip_source_buffer(z, "asdf", 4, 0); + if ((idx = zip_name_locate(z, "storedok", 0)) < 0) { + fprintf(stderr, "%s: can't locate 'storedok' in zip archive '%s': %s\n", progname, archive, zip_strerror(z)); + fail++; + } + else { + if (zip_file_replace(z, (zip_uint64_t)idx, zs, 0) < 0) { + fprintf(stderr, "%s: can't replace 'storedok' in zip archive '%s': %s\n", progname, archive, zip_strerror(z)); + fail++; + } + else { + fail += do_read(z, "storedok", 0, WHEN_NEVER, 0, 0); + fail += do_read(z, "storedok", ZIP_FL_UNCHANGED, WHEN_NEVER, 0, 0); + } + } + if ((idx = zip_name_locate(z, "storedok", 0)) < 0) { + fprintf(stderr, "%s: can't locate 'storedok' in zip archive '%s': %s\n", progname, archive, zip_strerror(z)); + fail++; + } + else { + if (zip_delete(z, (zip_uint64_t)idx) < 0) { + fprintf(stderr, "%s: can't replace 'storedok' in zip archive '%s': %s\n", progname, archive, zip_strerror(z)); + fail++; + } + else { + fail += do_read(z, "storedok", 0, WHEN_OPEN, ZIP_ER_NOENT, 0); + fail += do_read(z, "storedok", ZIP_FL_UNCHANGED, WHEN_NEVER, 0, 0); + } + } + zs = zip_source_buffer(z, "asdf", 4, 0); + if (zip_file_add(z, "new_file", zs, 0) < 0) { + fprintf(stderr, "%s: can't add file to zip archive '%s': %s\n", progname, archive, zip_strerror(z)); + fail++; + } + else { + fail += do_read(z, "new_file", 0, WHEN_NEVER, 0, 0); + } + + zip_unchange_all(z); + if (zip_close(z) == -1) { + fprintf(stderr, "%s: can't close zip archive '%s': %s\n", progname, archive, zip_strerror(z)); + return 1; + } + + exit(fail ? 1 : 0); +} + + +static int +do_read(zip_t *z, const char *name, zip_flags_t flags, enum when when_ex, int ze_ex, int se_ex) { + zip_file_t *zf; + enum when when_got; + zip_error_t error_got, error_ex; + zip_error_t *zf_error; + int err; + char b[8192]; + zip_int64_t n; + + when_got = WHEN_NEVER; + zip_error_init(&error_got); + zip_error_init(&error_ex); + zip_error_set(&error_ex, ze_ex, se_ex); + + if ((zf = zip_fopen(z, name, flags)) == NULL) { + when_got = WHEN_OPEN; + zf_error = zip_get_error(z); + zip_error_set(&error_got, zip_error_code_zip(zf_error), zip_error_code_system(zf_error)); + } + else { + while ((n = zip_fread(zf, b, sizeof(b))) > 0) + ; + if (n < 0) { + when_got = WHEN_READ; + zf_error = zip_file_get_error(zf); + zip_error_set(&error_got, zip_error_code_zip(zf_error), zip_error_code_system(zf_error)); + } + err = zip_fclose(zf); + if (when_got == WHEN_NEVER && err != 0) { + when_got = WHEN_CLOSE; + zip_error_init_with_code(&error_got, err); + } + } + + if (when_got != when_ex || zip_error_code_zip(&error_got) != zip_error_code_zip(&error_ex) || zip_error_code_system(&error_got) != zip_error_code_system(&error_ex)) { + printf("%s: %s: got %s error (%s), expected %s error (%s)\n", progname, name, when_name[when_got], zip_error_strerror(&error_got), when_name[when_ex], zip_error_strerror(&error_ex)); + zip_error_fini(&error_got); + zip_error_fini(&error_ex); + return 1; + } + else if (verbose) + printf("%s: %s: passed\n", progname, name); + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/regress/fread.test b/thirdparty/libzip-1.11.3/regress/fread.test new file mode 100644 index 0000000..16fb877 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/fread.test @@ -0,0 +1,5 @@ +# various tests for zip_fread +program fread +arguments broken.zip +return 0 +file broken.zip broken.zip diff --git a/thirdparty/libzip-1.11.3/regress/fseek.c b/thirdparty/libzip-1.11.3/regress/fseek.c new file mode 100644 index 0000000..b2db322 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/fseek.c @@ -0,0 +1,104 @@ +/* + fseek.c -- test tool for seeking in zip archives + Copyright (C) 2016-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include "zip.h" + +const char *progname; +#define USAGE "usage: %s archive index offset\n" + +int +main(int argc, char *argv[]) { + int ze; + zip_t *z; + zip_file_t *zf; + char *archive; + zip_int64_t offset, n; + zip_uint64_t index; + char b[1024]; + + progname = argv[0]; + + if (argc != 4) { + fprintf(stderr, USAGE, progname); + return 1; + } + + archive = argv[1]; + index = strtoull(argv[2], NULL, 10); + offset = (zip_int64_t)strtoull(argv[3], NULL, 10); + + if ((z = zip_open(archive, 0, &ze)) == NULL) { + zip_error_t error; + zip_error_init_with_code(&error, ze); + fprintf(stderr, "%s: can't open zip archive '%s': %s\n", progname, archive, zip_error_strerror(&error)); + zip_error_fini(&error); + return 1; + } + + if ((zf = zip_fopen_index(z, index, 0)) == NULL) { + fprintf(stderr, "%s: can't open file in archive '%s': %s\n", progname, archive, zip_error_strerror(zip_file_get_error(zf))); + zip_close(z); + return 1; + } + + if (zip_fseek(zf, offset, SEEK_SET) < 0) { + fprintf(stderr, "%s: zip_fseek failed: %s\n", progname, zip_error_strerror(zip_file_get_error(zf))); + zip_fclose(zf); + zip_close(z); + return 1; + } + + while ((n = zip_fread(zf, b, sizeof(b))) > 0) { + printf("%.*s", (int)n, b); + } + if (n < 0) { + fprintf(stderr, "%s: zip_fread failed: %s\n", progname, zip_error_strerror(zip_file_get_error(zf))); + zip_fclose(zf); + zip_close(z); + return 1; + } + + if (zip_fclose(zf) == -1) { + fprintf(stderr, "%s: can't close zip archive entry %" PRIu64 " in '%s': %s\n", progname, index, archive, zip_strerror(z)); + return 1; + } + + if (zip_close(z) == -1) { + fprintf(stderr, "%s: can't close zip archive '%s': %s\n", progname, archive, zip_strerror(z)); + return 1; + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/regress/fseek_deflated.test b/thirdparty/libzip-1.11.3/regress/fseek_deflated.test new file mode 100644 index 0000000..ca22ed1 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/fseek_deflated.test @@ -0,0 +1,8 @@ +# unsuccessful fseek test because data is compressed +program fseek +arguments test.zip 0 2 +return 1 +file test.zip testdeflated.zip +stderr +zip_fseek failed: Operation not supported +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/fseek_fail.test b/thirdparty/libzip-1.11.3/regress/fseek_fail.test new file mode 100644 index 0000000..4af6000 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/fseek_fail.test @@ -0,0 +1,8 @@ +# successful fseek test +program fseek +arguments test.zip 0 8 +return 1 +file test.zip test.zip +stderr +zip_fseek failed: Invalid argument +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/fseek_ok.test b/thirdparty/libzip-1.11.3/regress/fseek_ok.test new file mode 100644 index 0000000..1e85db0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/fseek_ok.test @@ -0,0 +1,8 @@ +# successful fseek test +program fseek +arguments test.zip 0 2 +return 0 +file test.zip test.zip +stdout +st +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/gap-add.zip b/thirdparty/libzip-1.11.3/regress/gap-add.zip new file mode 100644 index 0000000..e1a0159 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/gap-add.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/gap-delete.zip b/thirdparty/libzip-1.11.3/regress/gap-delete.zip new file mode 100644 index 0000000..7d73d00 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/gap-delete.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/gap-replace.zip b/thirdparty/libzip-1.11.3/regress/gap-replace.zip new file mode 100644 index 0000000..27e0580 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/gap-replace.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/gap.zip b/thirdparty/libzip-1.11.3/regress/gap.zip new file mode 100644 index 0000000..85e3bc7 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/gap.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/get_comment.test b/thirdparty/libzip-1.11.3/regress/get_comment.test new file mode 100644 index 0000000..3e6f093 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/get_comment.test @@ -0,0 +1,16 @@ +# show comments of a zip archive +return 0 +arguments testcomment.zip get_archive_comment get_file_comment 0 get_file_comment 1 get_file_comment 2 get_file_comment 3 +file testcomment.zip testcomment.zip +stdout +Archive comment: This is the archive comment for the file. + +Long. + +Longer. + +No comment for 'file1' +File comment for 'file2': First one had no comment. +File comment for 'file3': Third one. +File comment for 'file4': Last. +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/get_comment_long.test b/thirdparty/libzip-1.11.3/regress/get_comment_long.test new file mode 100644 index 0000000..18ae767 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/get_comment_long.test @@ -0,0 +1,7 @@ +# show long archive comment of a zip archive +return 0 +arguments testfile.zip get_archive_comment +file testfile.zip testfile-long-comment.zip +stdout +Archive comment: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/hmac-error.test b/thirdparty/libzip-1.11.3/regress/hmac-error.test new file mode 100644 index 0000000..66644ce --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/hmac-error.test @@ -0,0 +1,10 @@ +description test file that has an HMAC error +return 1 +arguments hmac-error.zip set_password 1234 cat 0 +file hmac-error.zip hmac-error.zip +stdout +The quick brown fox jumps over t quazy dog +end-of-inline-data +stderr +can't read file at index '0': CRC error +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/hmac-error.zip b/thirdparty/libzip-1.11.3/regress/hmac-error.zip new file mode 100644 index 0000000..c8be590 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/hmac-error.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/hole.c b/thirdparty/libzip-1.11.3/regress/hole.c new file mode 100644 index 0000000..992ed01 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/hole.c @@ -0,0 +1,190 @@ +/* + hole.c -- convert huge files with mostly NULs to/from source_hole + Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include +#include + +#ifndef HAVE_GETOPT +#include "getopt.h" +#endif + +#include "zip.h" + +/* public API */ + +zip_source_t *source_hole_create(const char *, int flags, zip_error_t *); + +const char *progname; + + +static int +copy_source(zip_source_t *from, zip_source_t *to) { + zip_uint8_t buf[8192]; + zip_int64_t n; + + if (zip_source_open(from) < 0) { + fprintf(stderr, "%s: can't open source for reading: %s\n", progname, zip_error_strerror(zip_source_error(from))); + return -1; + } + + if (zip_source_begin_write(to) < 0) { + fprintf(stderr, "%s: can't open source for writing: %s\n", progname, zip_error_strerror(zip_source_error(to))); + zip_source_close(from); + return -1; + } + + while ((n = zip_source_read(from, buf, sizeof(buf))) > 0) { + if (zip_source_write(to, buf, (zip_uint64_t)n) != n) { + fprintf(stderr, "%s: can't write to source: %s\n", progname, zip_error_strerror(zip_source_error(to))); + zip_source_close(from); + zip_source_rollback_write(to); + return -1; + } + } + + if (n < 0) { + fprintf(stderr, "%s: can't read from source: %s\n", progname, zip_error_strerror(zip_source_error(from))); + zip_source_close(from); + zip_source_rollback_write(to); + return -1; + } + + zip_source_close(from); + + if (zip_source_commit_write(to) < 0) { + fprintf(stderr, "%s: can't commit source: %s\n", progname, zip_error_strerror(zip_source_error(to))); + zip_source_rollback_write(to); + return -1; + } + + return 0; +} + + +static zip_source_t * +open_compressed(const char *fname, int flags) { + zip_error_t error; + zip_source_t *src; + + zip_error_init(&error); + + if ((src = source_hole_create(fname, flags, &error)) == NULL) { + fprintf(stderr, "%s: can't open compressed file %s: %s\n", progname, fname, zip_error_strerror(&error)); + zip_error_fini(&error); + exit(1); + } + + return src; +} + + +static zip_source_t * +open_file(const char *fname) { + zip_error_t error; + zip_source_t *src; + + zip_error_init(&error); + + if ((src = zip_source_file_create(fname, 0, 0, &error)) == NULL) { + fprintf(stderr, "%s: can't open file %s: %s\n", progname, fname, zip_error_strerror(&error)); + zip_error_fini(&error); + exit(1); + } + + return src; +} + + +static void +usage(void) { + fprintf(stderr, "usage: %s [-du] in out\n", progname); + fprintf(stderr, "\nOptions:\n -d decompress in\n -u update in\n"); + exit(1); +} + + +int +main(int argc, char **argv) { + zip_source_t *from; + zip_source_t *to; + int c, err; + int compress = 1; + int decompress = 0; + + progname = argv[0]; + + while ((c = getopt(argc, argv, "du")) != -1) { + switch (c) { + case 'd': + compress = 0; + decompress = 1; + break; + + case 'u': + compress = 1; + decompress = 1; + break; + + default: + usage(); + break; + } + } + + if (optind + 2 != argc) { + usage(); + } + + if (decompress) { + from = open_compressed(argv[optind], 0); + } + else { + from = open_file(argv[optind]); + } + + if (compress) { + to = open_compressed(argv[optind + 1], ZIP_CREATE); + } + else { + to = open_file(argv[optind + 1]); + } + + err = copy_source(from, to); + + zip_source_free(from); + zip_source_free(to); + + exit(err < 0 ? 1 : 0); +} diff --git a/thirdparty/libzip-1.11.3/regress/incons-archive-comment-longer.zip b/thirdparty/libzip-1.11.3/regress/incons-archive-comment-longer.zip new file mode 100644 index 0000000..28d7ed3 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-archive-comment-longer.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-archive-comment-shorter.zip b/thirdparty/libzip-1.11.3/regress/incons-archive-comment-shorter.zip new file mode 100644 index 0000000..d23cad4 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-archive-comment-shorter.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-cdoffset.zip b/thirdparty/libzip-1.11.3/regress/incons-cdoffset.zip new file mode 100644 index 0000000..153e7a8 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-cdoffset.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-cdsize-large.zip b/thirdparty/libzip-1.11.3/regress/incons-cdsize-large.zip new file mode 100644 index 0000000..58d90c0 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-cdsize-large.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-cdsize-small.zip b/thirdparty/libzip-1.11.3/regress/incons-cdsize-small.zip new file mode 100644 index 0000000..b840959 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-cdsize-small.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-central-compression-method.zip b/thirdparty/libzip-1.11.3/regress/incons-central-compression-method.zip new file mode 100644 index 0000000..1bf78f2 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-central-compression-method.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-central-compsize-larger-toolarge.zip b/thirdparty/libzip-1.11.3/regress/incons-central-compsize-larger-toolarge.zip new file mode 100644 index 0000000..1c82ef6 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-central-compsize-larger-toolarge.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-central-compsize-larger.zip b/thirdparty/libzip-1.11.3/regress/incons-central-compsize-larger.zip new file mode 100644 index 0000000..67e9a99 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-central-compsize-larger.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-central-compsize-smaller.zip b/thirdparty/libzip-1.11.3/regress/incons-central-compsize-smaller.zip new file mode 100644 index 0000000..97dd14a Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-central-compsize-smaller.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-central-crc.zip b/thirdparty/libzip-1.11.3/regress/incons-central-crc.zip new file mode 100644 index 0000000..1f882ac Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-central-crc.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-central-date.zip b/thirdparty/libzip-1.11.3/regress/incons-central-date.zip new file mode 100644 index 0000000..6c831ca Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-central-date.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-central-file-comment-longer.zip b/thirdparty/libzip-1.11.3/regress/incons-central-file-comment-longer.zip new file mode 100644 index 0000000..b34c661 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-central-file-comment-longer.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-central-file-comment-shorter.zip b/thirdparty/libzip-1.11.3/regress/incons-central-file-comment-shorter.zip new file mode 100644 index 0000000..7769a9a Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-central-file-comment-shorter.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-central-file-comment-utf8-ascii.zip b/thirdparty/libzip-1.11.3/regress/incons-central-file-comment-utf8-ascii.zip new file mode 100644 index 0000000..3024f74 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-central-file-comment-utf8-ascii.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-central-magic-bad.zip b/thirdparty/libzip-1.11.3/regress/incons-central-magic-bad.zip new file mode 100644 index 0000000..954563b Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-central-magic-bad.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-central-magic-bad2.zip b/thirdparty/libzip-1.11.3/regress/incons-central-magic-bad2.zip new file mode 100644 index 0000000..f99d9b7 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-central-magic-bad2.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-central-size-larger.zip b/thirdparty/libzip-1.11.3/regress/incons-central-size-larger.zip new file mode 100644 index 0000000..0779ce6 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-central-size-larger.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-data.zip b/thirdparty/libzip-1.11.3/regress/incons-data.zip new file mode 100644 index 0000000..e2ab58a Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-data.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-ef-central-size-wrong.zip b/thirdparty/libzip-1.11.3/regress/incons-ef-central-size-wrong.zip new file mode 100644 index 0000000..a3f4cc1 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-ef-central-size-wrong.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-ef-local-dupe-utf8comment.zip b/thirdparty/libzip-1.11.3/regress/incons-ef-local-dupe-utf8comment.zip new file mode 100644 index 0000000..d467c06 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-ef-local-dupe-utf8comment.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-ef-local-dupe-utf8name.zip b/thirdparty/libzip-1.11.3/regress/incons-ef-local-dupe-utf8name.zip new file mode 100644 index 0000000..948f625 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-ef-local-dupe-utf8name.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-ef-local-dupe-zip64-v1.zip b/thirdparty/libzip-1.11.3/regress/incons-ef-local-dupe-zip64-v1.zip new file mode 100644 index 0000000..2f11db4 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-ef-local-dupe-zip64-v1.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-ef-local-dupe-zip64-v2.zip b/thirdparty/libzip-1.11.3/regress/incons-ef-local-dupe-zip64-v2.zip new file mode 100644 index 0000000..83621da Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-ef-local-dupe-zip64-v2.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-ef-local-id-size.zip b/thirdparty/libzip-1.11.3/regress/incons-ef-local-id-size.zip new file mode 100644 index 0000000..44ce2f7 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-ef-local-id-size.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-ef-local-id.zip b/thirdparty/libzip-1.11.3/regress/incons-ef-local-id.zip new file mode 100644 index 0000000..aad5521 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-ef-local-id.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-ef-local-size.zip b/thirdparty/libzip-1.11.3/regress/incons-ef-local-size.zip new file mode 100644 index 0000000..ad16710 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-ef-local-size.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-ef-local-utf8name-ascii.zip b/thirdparty/libzip-1.11.3/regress/incons-ef-local-utf8name-ascii.zip new file mode 100644 index 0000000..d2fb3ab Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-ef-local-utf8name-ascii.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-eocd-magic-bad.zip b/thirdparty/libzip-1.11.3/regress/incons-eocd-magic-bad.zip new file mode 100644 index 0000000..9e49e56 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-eocd-magic-bad.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-eocd64.zip b/thirdparty/libzip-1.11.3/regress/incons-eocd64.zip new file mode 100644 index 0000000..6802736 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-eocd64.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-file-count-high.zip b/thirdparty/libzip-1.11.3/regress/incons-file-count-high.zip new file mode 100644 index 0000000..876a886 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-file-count-high.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-file-count-low.zip b/thirdparty/libzip-1.11.3/regress/incons-file-count-low.zip new file mode 100644 index 0000000..4af9038 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-file-count-low.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-file-count-overflow.zip b/thirdparty/libzip-1.11.3/regress/incons-file-count-overflow.zip new file mode 100644 index 0000000..461722c Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-file-count-overflow.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-gap-before-cd.zip b/thirdparty/libzip-1.11.3/regress/incons-gap-before-cd.zip new file mode 100644 index 0000000..53746dc Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-gap-before-cd.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-gap-before-eocd.zip b/thirdparty/libzip-1.11.3/regress/incons-gap-before-eocd.zip new file mode 100644 index 0000000..53d5524 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-gap-before-eocd.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-gap-before-local.zip b/thirdparty/libzip-1.11.3/regress/incons-gap-before-local.zip new file mode 100644 index 0000000..23036f3 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-gap-before-local.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-local-compression-method.zip b/thirdparty/libzip-1.11.3/regress/incons-local-compression-method.zip new file mode 100644 index 0000000..2e70f59 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-local-compression-method.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-local-compsize-larger.zip b/thirdparty/libzip-1.11.3/regress/incons-local-compsize-larger.zip new file mode 100644 index 0000000..6fc27e0 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-local-compsize-larger.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-local-compsize-smaller.zip b/thirdparty/libzip-1.11.3/regress/incons-local-compsize-smaller.zip new file mode 100644 index 0000000..75f1463 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-local-compsize-smaller.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-local-crc.zip b/thirdparty/libzip-1.11.3/regress/incons-local-crc.zip new file mode 100644 index 0000000..6f74b15 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-local-crc.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-local-filename-long.zip b/thirdparty/libzip-1.11.3/regress/incons-local-filename-long.zip new file mode 100644 index 0000000..42b4a1f Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-local-filename-long.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-local-filename-missing.zip b/thirdparty/libzip-1.11.3/regress/incons-local-filename-missing.zip new file mode 100644 index 0000000..71d3eb2 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-local-filename-missing.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-local-filename-nil-byte.zip b/thirdparty/libzip-1.11.3/regress/incons-local-filename-nil-byte.zip new file mode 100644 index 0000000..e30b406 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-local-filename-nil-byte.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-local-filename-short.zip b/thirdparty/libzip-1.11.3/regress/incons-local-filename-short.zip new file mode 100644 index 0000000..c69be1b Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-local-filename-short.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-local-filename.zip b/thirdparty/libzip-1.11.3/regress/incons-local-filename.zip new file mode 100644 index 0000000..1878235 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-local-filename.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-local-magic-bad.zip b/thirdparty/libzip-1.11.3/regress/incons-local-magic-bad.zip new file mode 100644 index 0000000..9a6a061 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-local-magic-bad.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-local-size-larger.zip b/thirdparty/libzip-1.11.3/regress/incons-local-size-larger.zip new file mode 100644 index 0000000..4e0bb43 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-local-size-larger.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-stored-size.zip b/thirdparty/libzip-1.11.3/regress/incons-stored-size.zip new file mode 100644 index 0000000..4fa6041 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-stored-size.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-streamed-2.zip b/thirdparty/libzip-1.11.3/regress/incons-streamed-2.zip new file mode 100644 index 0000000..5346f81 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-streamed-2.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-streamed.zip b/thirdparty/libzip-1.11.3/regress/incons-streamed.zip new file mode 100644 index 0000000..d87388a Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-streamed.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/incons-trailing-garbage.zip b/thirdparty/libzip-1.11.3/regress/incons-trailing-garbage.zip new file mode 100644 index 0000000..2f09035 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/incons-trailing-garbage.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/junk-at-end.zip b/thirdparty/libzip-1.11.3/regress/junk-at-end.zip new file mode 100644 index 0000000..30387b3 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/junk-at-end.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/junk-at-start.zip b/thirdparty/libzip-1.11.3/regress/junk-at-start.zip new file mode 100644 index 0000000..8c98325 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/junk-at-start.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/junk_at_end.test b/thirdparty/libzip-1.11.3/regress/junk_at_end.test new file mode 100644 index 0000000..50ef46d --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/junk_at_end.test @@ -0,0 +1,7 @@ +# test archive with junk at end of file +arguments -l 412 junk-at-end.zzip get_num_entries 0 +return 0 +file junk-at-end.zzip junk-at-end.zip +stdout +3 entries in archive +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/junk_at_start.test b/thirdparty/libzip-1.11.3/regress/junk_at_start.test new file mode 100644 index 0000000..777836f --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/junk_at_start.test @@ -0,0 +1,7 @@ +# test archive with junk at start of file +arguments -o 4 junk-at-start.zzip get_num_entries 0 +return 0 +file junk-at-start.zzip junk-at-start.zip +stdout +3 entries in archive +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/large-uncompressible b/thirdparty/libzip-1.11.3/regress/large-uncompressible new file mode 100644 index 0000000..e7e26d9 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/large-uncompressible differ diff --git a/thirdparty/libzip-1.11.3/regress/liboverride-test.c b/thirdparty/libzip-1.11.3/regress/liboverride-test.c new file mode 100644 index 0000000..97fa31a --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/liboverride-test.c @@ -0,0 +1,108 @@ +/* + liboverride.c -- override function called by zip_open() + + Copyright (C) 2017-2022 Dieter Baron and Thomas Klausner + + This file is part of ckmame, a program to check rom sets for MAME. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +#include + +#ifdef _WIN32 +int main(int argc, const char *argv[]) { + /* Symbol override is not supported on Windows. */ + if (argc > 1 && strcmp(argv[1], "-v") == 0) { + printf("not supported on Windows\n"); + } + exit(1); +} +#else + +#include +#include + +#include "zip.h" + +/* + Some systems bind functions called and defined within a shared library, so the override doesn't work. This program calls zip_open and checks whether the override worked. + */ + +int +main(int argc, const char *argv[]) { + int verbose = 0; + int error_code; + + if (argc > 1 && strcmp(argv[1], "-v") == 0) { + verbose = 1; + } + + if (getenv("LIBOVERRIDE_SET") == NULL) { + char *cwd = getcwd(NULL, 0); + size_t so_size = strlen(cwd) + 64; + char *so = (char *)malloc(so_size); + if (so == NULL) { + if (verbose) { + printf("malloc failed\n"); + } + exit(2); + } + snprintf(so, so_size, "%s/libliboverride.so", cwd); + setenv("LIBOVERRIDE_SET", "1", 1); + setenv("LD_PRELOAD", so, 1); + execv(argv[0], (void *)argv); + if (verbose) { + printf("exec failed: %s\n", strerror(errno)); + } + exit(2); + } + + if (zip_open("nosuchfile", 0, &error_code) != NULL) { + /* We expect failure. */ + if (verbose) { + printf("open succeeded\n"); + } + exit(1); + } + if (error_code != 32000) { + /* Override didn't take, we didn't get its magic error code. */ + if (verbose) { + printf("got unexpected error %d\n", error_code); + } + exit(1); + } + + if (verbose) { + printf("success\n"); + } + exit(0); +} + +#endif /* not Windows */ diff --git a/thirdparty/libzip-1.11.3/regress/liboverride.c b/thirdparty/libzip-1.11.3/regress/liboverride.c new file mode 100644 index 0000000..200f712 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/liboverride.c @@ -0,0 +1,48 @@ +/* + liboverride.c -- override function called by zip_open() + + Copyright (C) 2017-2021 Dieter Baron and Thomas Klausner + + This file is part of ckmame, a program to check rom sets for MAME. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +/* + Some systems bind functions called and defined within a shared library, so the override doesn't work. This overrides a function called by zip_open to return an invalid error code so we can check whether the override works. + */ + +zip_source_t * +zip_source_file_create(const char *fname, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { + if (error != NULL) { + error->zip_err = 32000; + } + + return NULL; +} diff --git a/thirdparty/libzip-1.11.3/regress/lzma-no-eos.zip b/thirdparty/libzip-1.11.3/regress/lzma-no-eos.zip new file mode 100644 index 0000000..883d851 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/lzma-no-eos.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/malloc.c b/thirdparty/libzip-1.11.3/regress/malloc.c new file mode 100644 index 0000000..1141104 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/malloc.c @@ -0,0 +1,162 @@ +/* + malloc.c -- override *alloc() to allow testing special cases + Copyright (C) 2015-2021 Dieter Baron and Thomas Klausner + + This file is part of ckmame, a program to check rom sets for MAME. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include +#include +/* #include */ +#include +#define __USE_GNU +#include +#undef __USE_GNU + +#include "config.h" + +#if !defined(RTLD_NEXT) +#define RTLD_NEXT RTLD_DEFAULT +#endif + +#if defined(HAVE___PROGNAME) +extern char *__progname; +#endif + +#if defined(HAVE_GETPROGNAME) +/* all fine */ +#else +const char * +getprogname(void) { +#if defined(HAVE___PROGNAME) + return __progname; +#else + return NULL; +#endif +} +#endif + +static int inited = 0; +static size_t count = 0; +static size_t max_count = 0; +static size_t min_size = 0; +static void *(*real_malloc)(size_t size) = NULL; +static void *(*real_calloc)(size_t number, size_t size) = NULL; +static void *(*real_realloc)(void *ptr, size_t size) = NULL; + +static const char *myname = NULL; + +/* TODO: add sentinel -- check if particular size is malloced before doing other stuff */ +/* TODO: catch free for sentinel too */ +/* TODO: optionally, catch malloc of particular size */ + +static void +init(void) { + char *foo; + myname = getprogname(); + if (!myname) + myname = "(unknown)"; + if ((foo = getenv("MALLOC_MAX_COUNT")) != NULL) + max_count = strtoul(foo, NULL, 0); + if ((foo = getenv("MALLOC_MIN_SIZE")) != NULL) + min_size = strtoul(foo, NULL, 0); + real_calloc = dlsym(RTLD_NEXT, "calloc"); + if (!real_calloc) + abort(); + real_malloc = dlsym(RTLD_NEXT, "malloc"); + if (!real_malloc) + abort(); + real_realloc = dlsym(RTLD_NEXT, "realloc"); + if (!real_realloc) + abort(); + inited = 1; +} + +void * +calloc(size_t number, size_t size) { + void *ret; + + if (!inited) { + init(); + } + + if (number >= min_size / size && count >= max_count) { + errno = ENOMEM; + return NULL; + } + + ret = real_calloc(number, size); + if (size >= min_size) { + count++; + } + + return ret; +} + +void * +malloc(size_t size) { + void *ret; + + if (!inited) { + init(); + } + + if (size >= min_size && count >= max_count) { + errno = ENOMEM; + return NULL; + } + + ret = real_malloc(size); + if (size >= min_size) { + count++; + } + + return ret; +} + +void * +realloc(void *ptr, size_t size) { + void *ret; + + if (!inited) { + init(); + } + + if (size >= min_size && count >= max_count) { + errno = ENOMEM; + return NULL; + } + + ret = real_realloc(ptr, size); + if (size >= min_size) { + count++; + } + + return ret; +} diff --git a/thirdparty/libzip-1.11.3/regress/manyfiles-zip.zip b/thirdparty/libzip-1.11.3/regress/manyfiles-zip.zip new file mode 100644 index 0000000..19ad57d Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/manyfiles-zip.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/mtime-default.zip b/thirdparty/libzip-1.11.3/regress/mtime-default.zip new file mode 100644 index 0000000..287fd31 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/mtime-default.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/mtime-dstpoint-deflated.zip b/thirdparty/libzip-1.11.3/regress/mtime-dstpoint-deflated.zip new file mode 100644 index 0000000..46c9b55 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/mtime-dstpoint-deflated.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/mtime-dstpoint.test b/thirdparty/libzip-1.11.3/regress/mtime-dstpoint.test new file mode 100644 index 0000000..82f6207 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/mtime-dstpoint.test @@ -0,0 +1,7 @@ +description change method from stored to deflated, which will change the timestamp because it is at a DST point and not valid in that time zone +environment-set TZ America/New_York +# setting it to a European timezone, where there is no DST change at this point, works +#environment-set TZ Europe/Zurich +return 0 +arguments test.zzip set_file_compression 0 deflate 0 +file test.zzip mtime-dstpoint.zip mtime-dstpoint-deflated.zip diff --git a/thirdparty/libzip-1.11.3/regress/mtime-dstpoint.zip b/thirdparty/libzip-1.11.3/regress/mtime-dstpoint.zip new file mode 100644 index 0000000..5f20d32 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/mtime-dstpoint.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/mtime-post-dstpoint-deflated.zip b/thirdparty/libzip-1.11.3/regress/mtime-post-dstpoint-deflated.zip new file mode 100644 index 0000000..d40e147 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/mtime-post-dstpoint-deflated.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/mtime-post-dstpoint.test b/thirdparty/libzip-1.11.3/regress/mtime-post-dstpoint.test new file mode 100644 index 0000000..a4748cd --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/mtime-post-dstpoint.test @@ -0,0 +1,5 @@ +description change method from stored to deflated, for a file one hour after DST change +environment-set TZ America/New_York +return 0 +arguments test.zzip set_file_compression 0 deflate 0 +file test.zzip mtime-post-dstpoint.zip mtime-post-dstpoint-deflated.zip diff --git a/thirdparty/libzip-1.11.3/regress/mtime-post-dstpoint.zip b/thirdparty/libzip-1.11.3/regress/mtime-post-dstpoint.zip new file mode 100644 index 0000000..2a3e14d Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/mtime-post-dstpoint.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/mtime-pre-dstpoint-deflated.zip b/thirdparty/libzip-1.11.3/regress/mtime-pre-dstpoint-deflated.zip new file mode 100644 index 0000000..e8f65e8 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/mtime-pre-dstpoint-deflated.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/mtime-pre-dstpoint.test b/thirdparty/libzip-1.11.3/regress/mtime-pre-dstpoint.test new file mode 100644 index 0000000..3518e6e --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/mtime-pre-dstpoint.test @@ -0,0 +1,5 @@ +description change method from stored to deflated, for a file one hour before DST change +environment-set TZ America/New_York +return 0 +arguments test.zzip set_file_compression 0 deflate 0 +file test.zzip mtime-pre-dstpoint.zip mtime-pre-dstpoint-deflated.zip diff --git a/thirdparty/libzip-1.11.3/regress/mtime-pre-dstpoint.zip b/thirdparty/libzip-1.11.3/regress/mtime-pre-dstpoint.zip new file mode 100644 index 0000000..cd096d1 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/mtime-pre-dstpoint.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/multidisk.zip b/thirdparty/libzip-1.11.3/regress/multidisk.zip new file mode 100644 index 0000000..28dafb9 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/multidisk.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/name_locate-cp437.test b/thirdparty/libzip-1.11.3/regress/name_locate-cp437.test new file mode 100644 index 0000000..836280e --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/name_locate-cp437.test @@ -0,0 +1,13 @@ +description tests for various encoding flags for zip_name_locate +arguments -x test.zip name_locate "9192939495969798999A9B9C9D9E9FA0" 0 name_locate "9192939495969798999A9B9C9D9E9FA0" 4 name_locate "9192939495969798999A9B9C9D9E9FA0" 8 name_locate "9192939495969798999A9B9C9D9E9FA0" r name_locate "9192939495969798999A9B9C9D9E9FA0" s +return 0 +file test.zip test-cp437.zip +stdout +name '9192939495969798999A9B9C9D9E9FA0' using flags '0' found at index 9 +name '9192939495969798999A9B9C9D9E9FA0' using flags '4' found at index 9 +name '9192939495969798999A9B9C9D9E9FA0' using flags 'r' found at index 9 +name '9192939495969798999A9B9C9D9E9FA0' using flags 's' found at index 9 +end-of-inline-data +stderr +can't find entry with name '9192939495969798999A9B9C9D9E9FA0' using flags '8' +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/name_locate-utf8.test b/thirdparty/libzip-1.11.3/regress/name_locate-utf8.test new file mode 100644 index 0000000..bbd6384 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/name_locate-utf8.test @@ -0,0 +1,16 @@ +description tests for various encoding flags for zip_name_locate +arguments -i test.zip dummy +stdin +name_locate æÆôöòûùÿÖÜ¢£¥₧ƒá 0 name_locate æÆôöòûùÿÖÜ¢£¥₧ƒá 4 name_locate æÆôöòûùÿÖÜ¢£¥₧ƒá 8 name_locate æÆôöòûùÿÖÜ¢£¥₧ƒá r name_locate æÆôöòûùÿÖÜ¢£¥₧ƒá s +end-of-inline-data +return 0 +file test.zip test-cp437.zip +stdout +name 'æÆôöòûùÿÖÜ¢£¥₧ƒá' using flags '0' found at index 9 +name 'æÆôöòûùÿÖÜ¢£¥₧ƒá' using flags '8' found at index 9 +name 'æÆôöòûùÿÖÜ¢£¥₧ƒá' using flags 's' found at index 9 +end-of-inline-data +stderr +can't find entry with name 'æÆôöòûùÿÖÜ¢£¥₧ƒá' using flags '4' +can't find entry with name 'æÆôöòûùÿÖÜ¢£¥₧ƒá' using flags 'r' +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/name_locate.test b/thirdparty/libzip-1.11.3/regress/name_locate.test new file mode 100644 index 0000000..be84ae8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/name_locate.test @@ -0,0 +1,31 @@ +# various tests for zip_name_locate +arguments test.zip name_locate nosuchfile 0 name_locate test 0 name_locate "" 0 name_locate TeSt 0 name_locate TeSt C name_locate testdir/test2 0 name_locate tesTdir/tESt2 C name_locate testdir/test2 d name_locate tesTdir/tESt2 dC name_locate test2 0 name_locate test2 d name_locate TeST2 dC delete 0 name_locate test 0 name_locate test u add new teststring name_locate new 0 name_locate new u add "" teststring name_locate "" 0 unchange_all name_locate test 0 name_locate new 0 +# delete 0 +# add "new" +# add "" +# unchange all +return 0 +file test.zip test.zip +stdout +name 'test' using flags '0' found at index 0 +name 'TeSt' using flags 'C' found at index 0 +name 'testdir/test2' using flags '0' found at index 2 +name 'tesTdir/tESt2' using flags 'C' found at index 2 +name 'test2' using flags 'd' found at index 2 +name 'TeST2' using flags 'dC' found at index 2 +name 'test' using flags 'u' found at index 0 +name 'new' using flags '0' found at index 3 +name '' using flags '0' found at index 4 +name 'test' using flags '0' found at index 0 +end-of-inline-data +stderr +can't find entry with name 'nosuchfile' using flags '0' +can't find entry with name '' using flags '0' +can't find entry with name 'TeSt' using flags '0' +can't find entry with name 'testdir/test2' using flags 'd' +can't find entry with name 'tesTdir/tESt2' using flags 'dC' +can't find entry with name 'test2' using flags '0' +can't find entry with name 'test' using flags '0' +can't find entry with name 'new' using flags 'u' +can't find entry with name 'new' using flags '0' +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/nihtest.conf.in b/thirdparty/libzip-1.11.3/regress/nihtest.conf.in new file mode 100644 index 0000000..9890838 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/nihtest.conf.in @@ -0,0 +1,14 @@ +[settings] +features-files = @PROJECT_BINARY_DIR@/config.h +test-input-directories = @CMAKE_CURRENT_SOURCE_DIR@ +program-directories = @PROJECT_BINARY_DIR@/regress + @PROJECT_BINARY_DIR@/regress/Release + @PROJECT_BINARY_DIR@/regress/Debug + @PROJECT_BINARY_DIR@/src + @PROJECT_BINARY_DIR@/src/Release + @PROJECT_BINARY_DIR@/src/Debug +default-program = ziptool_regress +default-stderr-replace = "^([A-Z]:)?[^ :]*: " "" + +[comparators] +zip.zip = zipcmp -pv diff --git a/thirdparty/libzip-1.11.3/regress/nonrandomopen.c b/thirdparty/libzip-1.11.3/regress/nonrandomopen.c new file mode 100644 index 0000000..4523f03 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/nonrandomopen.c @@ -0,0 +1,44 @@ +/* + nonrandomopen.c -- override zip_secure_random + + Copyright (C) 2017-2021 Dieter Baron and Thomas Klausner + + This file is part of ckmame, a program to check rom sets for MAME. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include "zipint.h" + +bool +zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { + memset(buffer, 0, length); + + return true; +} diff --git a/thirdparty/libzip-1.11.3/regress/nonrandomopentest.c b/thirdparty/libzip-1.11.3/regress/nonrandomopentest.c new file mode 100644 index 0000000..e4585a4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/nonrandomopentest.c @@ -0,0 +1,57 @@ +/* + nonrandomopentest.c -- test nonrandomopen.so + Copyright (C) 2017-2021 Dieter Baron and Thomas Klausner + + This file is part of ckmame, a program to check rom sets for MAME. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "zipint.h" + +#include +#include + +int +main(int argc, const char *argv[]) { + zip_uint8_t buf[1024]; + int i; + +#ifdef HAVE_CRYPTO + if (!zip_secure_random(buf, sizeof(buf))) { + fprintf(stderr, "zip_secure_random returned false\n"); + exit(1); + } + for (i = 0; i < sizeof(buf); i++) { + if (buf[i] != 0) { + fprintf(stderr, "non-zero byte found\n"); + exit(1); + } + } +#endif + exit(0); +} diff --git a/thirdparty/libzip-1.11.3/regress/open_archive_comment_wrong.test b/thirdparty/libzip-1.11.3/regress/open_archive_comment_wrong.test new file mode 100644 index 0000000..3d55a73 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_archive_comment_wrong.test @@ -0,0 +1,10 @@ +# zip_open: file with wrong archive comment length, no consistency check: opens fine +program tryopen +arguments incons-archive-comment-longer.zip incons-archive-comment-shorter.zip +return 0 +file incons-archive-comment-longer.zip incons-archive-comment-longer.zip +file incons-archive-comment-shorter.zip incons-archive-comment-shorter.zip +stdout +opening 'incons-archive-comment-longer.zip' succeeded, 1 entries +opening 'incons-archive-comment-shorter.zip' succeeded, 1 entries +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_cons_extrabytes.test b/thirdparty/libzip-1.11.3/regress/open_cons_extrabytes.test new file mode 100644 index 0000000..a50a490 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_cons_extrabytes.test @@ -0,0 +1,11 @@ +# zip_open: file has extra bytes at end of archive +program tryopen +file testextrabytes.zzip testextrabytes.zip +arguments -c testextrabytes.zzip +return 1 +stdout +opening 'testextrabytes.zzip' returned error 21/2 +end-of-inline-data +stderr +1 errors +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_empty.test b/thirdparty/libzip-1.11.3/regress/open_empty.test new file mode 100644 index 0000000..8c8ffdc --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_empty.test @@ -0,0 +1,8 @@ +# zip_open: file contains no entry, but is valid +program tryopen +file testempty.zip testempty.zip +arguments testempty.zip +return 0 +stdout +opening 'testempty.zip' succeeded, 0 entries +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_empty_2.test b/thirdparty/libzip-1.11.3/regress/open_empty_2.test new file mode 100644 index 0000000..1c7b2ca --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_empty_2.test @@ -0,0 +1,11 @@ +# zip_open: 0 size file is recognized as empty zip +program tryopen +file testfile.txt testfile.txt +arguments testfile.txt +return 1 +stdout +opening 'testfile.txt' returned error 19 +end-of-inline-data +stderr +1 errors +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_extrabytes.test b/thirdparty/libzip-1.11.3/regress/open_extrabytes.test new file mode 100644 index 0000000..c466216 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_extrabytes.test @@ -0,0 +1,8 @@ +# zip_open: file has extra bytes at end of archive +program tryopen +file testextrabytes.zzip testextrabytes.zip +arguments testextrabytes.zzip +return 0 +stdout +opening 'testextrabytes.zzip' succeeded, 1 entries +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_file_count.test b/thirdparty/libzip-1.11.3/regress/open_file_count.test new file mode 100644 index 0000000..a99dbb7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_file_count.test @@ -0,0 +1,15 @@ +# zip_open: various inconsistent files +program tryopen +file incons-file-count-high.zzip incons-file-count-high.zip +file incons-file-count-low.zzip incons-file-count-low.zip +file incons-file-count-overflow.zzip incons-file-count-overflow.zip +arguments incons-file-count-high.zzip incons-file-count-low.zzip incons-file-count-overflow.zzip +return 1 +stdout +opening 'incons-file-count-high.zzip' returned error 21/5 +opening 'incons-file-count-low.zzip' returned error 21/5 +opening 'incons-file-count-overflow.zzip' returned error 21/11 +end-of-inline-data +stderr +3 errors +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_filename_duplicate.test b/thirdparty/libzip-1.11.3/regress/open_filename_duplicate.test new file mode 100644 index 0000000..10536b0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_filename_duplicate.test @@ -0,0 +1,8 @@ +# zip_open: file opens fine even though same file name appears twice +program tryopen +arguments filename_duplicate.zzip +return 0 +file filename_duplicate.zzip filename_duplicate.zip +stdout +opening 'filename_duplicate.zzip' succeeded, 2 entries +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_filename_duplicate_consistency.test b/thirdparty/libzip-1.11.3/regress/open_filename_duplicate_consistency.test new file mode 100644 index 0000000..acb152c --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_filename_duplicate_consistency.test @@ -0,0 +1,11 @@ +# zip_open: file opens fine even though same file name appears twice +program tryopen +arguments -c filename_duplicate.zzip +return 1 +file filename_duplicate.zzip filename_duplicate.zip +stdout +opening 'filename_duplicate.zzip' returned error 10 +end-of-inline-data +stderr +1 errors +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_filename_duplicate_empty.test b/thirdparty/libzip-1.11.3/regress/open_filename_duplicate_empty.test new file mode 100644 index 0000000..a3306c3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_filename_duplicate_empty.test @@ -0,0 +1,8 @@ +# zip_open: file opens fine even though same file name (empty file name) appears twice +program tryopen +arguments filename_duplicate_empty.zzip +return 0 +file filename_duplicate_empty.zzip filename_duplicate_empty.zip +stdout +opening 'filename_duplicate_empty.zzip' succeeded, 2 entries +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_filename_duplicate_empty_consistency.test b/thirdparty/libzip-1.11.3/regress/open_filename_duplicate_empty_consistency.test new file mode 100644 index 0000000..d1420f2 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_filename_duplicate_empty_consistency.test @@ -0,0 +1,11 @@ +# zip_open: file opens fine even though same file name (empty file name) appears twice +program tryopen +arguments -c filename_duplicate_empty.zzip +return 1 +file filename_duplicate_empty.zzip filename_duplicate_empty.zip +stdout +opening 'filename_duplicate_empty.zzip' returned error 10 +end-of-inline-data +stderr +1 errors +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_filename_empty.test b/thirdparty/libzip-1.11.3/regress/open_filename_empty.test new file mode 100644 index 0000000..4c45c21 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_filename_empty.test @@ -0,0 +1,8 @@ +# zip_open: file opens fine even though file name has length 0 +program tryopen +arguments filename_empty.zip +return 0 +file filename_empty.zip filename_empty.zip +stdout +opening 'filename_empty.zip' succeeded, 1 entries +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_incons.test b/thirdparty/libzip-1.11.3/regress/open_incons.test new file mode 100644 index 0000000..f6f22ca --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_incons.test @@ -0,0 +1,109 @@ +# zip_open: various inconsistent files +program tryopen +file incons-archive-comment-longer.zzip incons-archive-comment-longer.zip +file incons-archive-comment-shorter.zzip incons-archive-comment-shorter.zip +file incons-cdoffset.zzip incons-cdoffset.zip +file incons-cdsize-large.zzip incons-cdsize-large.zip +file incons-cdsize-small.zzip incons-cdsize-large.zip +file incons-central-compression-method.zzip incons-central-compression-method.zip +file incons-central-compsize-larger.zzip incons-central-compsize-larger.zip +file incons-central-compsize-larger-toolarge.zzip incons-central-compsize-larger-toolarge.zip +file incons-central-compsize-smaller.zzip incons-central-compsize-smaller.zip +file incons-central-crc.zzip incons-central-crc.zip +file incons-central-date.zzip incons-central-date.zip +file incons-central-file-comment-longer.zzip incons-central-file-comment-longer.zip +file incons-central-file-comment-shorter.zzip incons-central-file-comment-shorter.zip +file incons-central-file-comment-utf8-ascii.zzip incons-central-file-comment-utf8-ascii.zip +file incons-central-magic-bad.zzip incons-central-magic-bad.zip +file incons-central-magic-bad2.zzip incons-central-magic-bad2.zip +file incons-central-size-larger.zzip incons-central-size-larger.zip +file incons-data.zzip incons-data.zip +file incons-ef-central-size-wrong.zzip incons-ef-central-size-wrong.zip +file incons-ef-local-dupe-utf8comment.zzip incons-ef-local-dupe-utf8comment.zip +file incons-ef-local-dupe-utf8name.zzip incons-ef-local-dupe-utf8name.zip +file incons-ef-local-dupe-zip64-v1.zzip incons-ef-local-dupe-zip64-v1.zip +file incons-ef-local-dupe-zip64-v2.zzip incons-ef-local-dupe-zip64-v2.zip +file incons-ef-local-id-size.zzip incons-ef-local-id-size.zip +file incons-ef-local-id.zzip incons-ef-local-id.zip +file incons-ef-local-size.zzip incons-ef-local-size.zip +file incons-ef-local-utf8name-ascii.zzip incons-ef-local-utf8name-ascii.zip +file incons-eocd64.zzip incons-eocd64.zip +file incons-eocd-magic-bad.zzip incons-eocd-magic-bad.zip +file incons-file-count-high.zzip incons-file-count-high.zip +file incons-file-count-low.zzip incons-file-count-low.zip +file incons-file-count-overflow.zzip incons-file-count-overflow.zip +file incons-gap-before-cd.zzip incons-gap-before-cd.zip +file incons-gap-before-eocd.zzip incons-gap-before-eocd.zip +file incons-gap-before-local.zzip incons-gap-before-local.zip +file incons-local-compression-method.zzip incons-local-compression-method.zip +file incons-local-compsize-larger.zzip incons-local-compsize-larger.zip +file incons-local-compsize-smaller.zzip incons-local-compsize-smaller.zip +file incons-local-crc.zzip incons-local-crc.zip +file incons-local-filename-long.zzip incons-local-filename-long.zip +file incons-local-filename-missing.zzip incons-local-filename-missing.zip +file incons-local-filename-nil-byte.zzip incons-local-filename-nil-byte.zip +file incons-local-filename-short.zzip incons-local-filename-short.zip +file incons-local-filename.zzip incons-local-filename.zip +file incons-local-magic-bad.zzip incons-local-magic-bad.zip +file incons-local-size-larger.zzip incons-local-size-larger.zip +file incons-stored-size.zzip incons-stored-size.zip +file incons-streamed.zzip incons-streamed.zip +file incons-streamed-2.zzip incons-streamed-2.zip +arguments -s -c incons-archive-comment-longer.zzip incons-archive-comment-shorter.zzip incons-cdoffset.zzip incons-cdsize-large.zzip incons-cdsize-small.zzip incons-central-compression-method.zzip incons-central-compsize-larger-toolarge.zzip incons-central-compsize-larger.zzip incons-central-compsize-smaller.zzip incons-central-crc.zzip incons-central-date.zzip incons-central-file-comment-longer.zzip incons-central-file-comment-shorter.zzip incons-central-file-comment-utf8-ascii.zzip incons-central-magic-bad.zzip incons-central-magic-bad2.zzip incons-central-size-larger.zzip incons-data.zzip incons-ef-central-size-wrong.zzip incons-ef-local-dupe-utf8comment.zzip incons-ef-local-dupe-utf8name.zzip incons-ef-local-dupe-zip64-v1.zzip incons-ef-local-dupe-zip64-v2.zzip incons-ef-local-id-size.zzip incons-ef-local-id.zzip incons-ef-local-size.zzip incons-ef-local-utf8name-ascii.zzip incons-eocd64.zzip incons-eocd-magic-bad.zzip incons-file-count-high.zzip incons-file-count-low.zzip incons-file-count-overflow.zzip incons-gap-before-cd.zzip incons-gap-before-eocd.zzip incons-gap-before-local.zzip incons-local-compression-method.zzip incons-local-compsize-larger.zzip incons-local-compsize-smaller.zzip incons-local-crc.zzip incons-local-filename-long.zzip incons-local-filename-missing.zzip incons-local-filename-nil-byte.zzip incons-local-filename-short.zzip incons-local-filename.zzip incons-local-magic-bad.zzip incons-local-size-larger.zzip incons-stored-size.zzip incons-streamed.zzip incons-streamed-2.zzip +return 1 +# tryopen does not test checksums, so this is fine. +# different extra fields local vs. central is fine +stdout +opening 'incons-archive-comment-longer.zzip' returned error Zip archive inconsistent: archive comment length incorrect +opening 'incons-archive-comment-shorter.zzip' returned error Zip archive inconsistent: archive comment length incorrect +opening 'incons-cdoffset.zzip' returned error Possibly truncated or corrupted zip archive +opening 'incons-cdsize-large.zzip' returned error Zip archive inconsistent: central directory overlaps EOCD, or there is space between them +opening 'incons-cdsize-small.zzip' returned error Zip archive inconsistent: central directory overlaps EOCD, or there is space between them +opening 'incons-central-compression-method.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-central-compsize-larger-toolarge.zzip' returned error Possibly truncated or corrupted zip archive +opening 'incons-central-compsize-larger.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-central-compsize-smaller.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-central-crc.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-central-date.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-central-file-comment-longer.zzip' returned error Zip archive inconsistent: entry 0: variable size fields overflow header +opening 'incons-central-file-comment-shorter.zzip' returned error Zip archive inconsistent: entry 1: central header invalid +opening 'incons-central-file-comment-utf8-ascii.zzip' succeeded, 1 entries +opening 'incons-central-magic-bad.zzip' returned error Possibly truncated or corrupted zip archive +opening 'incons-central-magic-bad2.zzip' returned error Possibly truncated or corrupted zip archive +opening 'incons-central-size-larger.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-data.zzip' succeeded, 1 entries +opening 'incons-ef-central-size-wrong.zzip' returned error Zip archive inconsistent: entry 0: extra field length is invalid +opening 'incons-ef-local-dupe-utf8comment.zzip' succeeded, 1 entries +opening 'incons-ef-local-dupe-utf8name.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-ef-local-dupe-zip64-v1.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-ef-local-dupe-zip64-v2.zzip' succeeded, 1 entries +opening 'incons-ef-local-id-size.zzip' returned error Zip archive inconsistent: entry 0: extra field length is invalid +opening 'incons-ef-local-id.zzip' succeeded, 1 entries +opening 'incons-ef-local-size.zzip' returned error Zip archive inconsistent: entry 0: extra field length is invalid +opening 'incons-ef-local-utf8name-ascii.zzip' returned error Zip archive inconsistent: entry 0: UTF-8 filename is ASCII and doesn't match filename +opening 'incons-eocd64.zzip' returned error Zip archive inconsistent: EOCD64 and EOCD do not match +opening 'incons-eocd-magic-bad.zzip' returned error Possibly truncated or corrupted zip archive +opening 'incons-file-count-high.zzip' returned error Zip archive inconsistent: central directory count of entries is incorrect +opening 'incons-file-count-low.zzip' returned error Zip archive inconsistent: central directory count of entries is incorrect +opening 'incons-file-count-overflow.zzip' returned error Zip archive inconsistent: invalid value in central directory +opening 'incons-gap-before-cd.zzip' succeeded, 1 entries +opening 'incons-gap-before-eocd.zzip' succeeded, 1 entries +opening 'incons-gap-before-local.zzip' succeeded, 2 entries +opening 'incons-local-compression-method.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-local-compsize-larger.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-local-compsize-smaller.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-local-crc.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-local-filename-long.zzip' returned error Premature end of file +opening 'incons-local-filename-missing.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-local-filename-nil-byte.zzip' succeeded, 1 entries +opening 'incons-local-filename-short.zzip' returned error Zip archive inconsistent: entry 0: extra field length is invalid +opening 'incons-local-filename.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-local-magic-bad.zzip' returned error Not a zip archive +opening 'incons-local-size-larger.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-stored-size.zzip' returned error Zip archive inconsistent: entry 0: compressed and uncompressed sizes don't match for stored file +opening 'incons-streamed.zzip' returned error Zip archive inconsistent: entry 0: local and central headers do not match +opening 'incons-streamed-2.zzip' returned error Zip archive inconsistent: entry 0: local header and data descriptor do not match +end-of-inline-data +stderr +40 errors +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_many_fail.test b/thirdparty/libzip-1.11.3/regress/open_many_fail.test new file mode 100644 index 0000000..075587f --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_many_fail.test @@ -0,0 +1,15 @@ +# zip_open: files with >65k that have issues +program tryopen +arguments manyfiles-zip64-modulo.zzip manyfiles-fewer.zzip manyfiles-more.zzip +return 1 +file manyfiles-zip64-modulo.zzip manyfiles-zip64-modulo.zip +file manyfiles-fewer.zzip manyfiles-fewer.zip +file manyfiles-more.zzip manyfiles-more.zip +stdout +opening 'manyfiles-zip64-modulo.zzip' returned error 21/5 +opening 'manyfiles-fewer.zzip' returned error 21/5 +opening 'manyfiles-more.zzip' returned error 21/5 +end-of-inline-data +stderr +3 errors +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_many_ok.test b/thirdparty/libzip-1.11.3/regress/open_many_ok.test new file mode 100644 index 0000000..4012c67 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_many_ok.test @@ -0,0 +1,14 @@ +# zip_open: files open fine, have > 65k entries +program tryopen +arguments manyfiles.zip manyfiles-zip64.zip manyfiles-133000.zip manyfiles-65536.zip +return 0 +file manyfiles.zip manyfiles.zip +file manyfiles-zip64.zip manyfiles-zip64.zip +file manyfiles-133000.zip manyfiles-133000.zip +file manyfiles-65536.zip manyfiles-65536.zip +stdout +opening 'manyfiles.zip' succeeded, 70000 entries +opening 'manyfiles-zip64.zip' succeeded, 70000 entries +opening 'manyfiles-133000.zip' succeeded, 133000 entries +opening 'manyfiles-65536.zip' succeeded, 65536 entries +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_multidisk.test b/thirdparty/libzip-1.11.3/regress/open_multidisk.test new file mode 100644 index 0000000..2b569f7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_multidisk.test @@ -0,0 +1,11 @@ +# zip_open: file is part of a multi-disk zip archive +program tryopen +arguments test.piz +return 1 +file test.piz multidisk.zip +stdout +opening 'test.piz' returned error 1 +end-of-inline-data +stderr +1 errors +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_new_but_exists.test b/thirdparty/libzip-1.11.3/regress/open_new_but_exists.test new file mode 100644 index 0000000..26caa44 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_new_but_exists.test @@ -0,0 +1,11 @@ +# zip_open: file shall be created but already exists +program tryopen +arguments -e test.zip +return 1 +file test.zip test.zip +stdout +opening 'test.zip' returned error 10 +end-of-inline-data +stderr +1 errors +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_new_ok.test b/thirdparty/libzip-1.11.3/regress/open_new_ok.test new file mode 100644 index 0000000..6dc063e --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_new_ok.test @@ -0,0 +1,7 @@ +# zip_open: create new archive +program tryopen +arguments -n new.zip +return 0 +stdout +opening 'new.zip' succeeded, 0 entries +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_nonarchive.test b/thirdparty/libzip-1.11.3/regress/open_nonarchive.test new file mode 100644 index 0000000..1325734 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_nonarchive.test @@ -0,0 +1,11 @@ +# zip_open: file is not a zip archive +program tryopen +file CMakeLists.txt CMakeLists.txt +arguments CMakeLists.txt +return 1 +stdout +opening 'CMakeLists.txt' returned error 19 +end-of-inline-data +stderr +1 errors +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_nosuchfile.test b/thirdparty/libzip-1.11.3/regress/open_nosuchfile.test new file mode 100644 index 0000000..f82f702 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_nosuchfile.test @@ -0,0 +1,10 @@ +# zip_open: file doesn't exist +program tryopen +arguments nosuchfile +return 1 +stdout +opening 'nosuchfile' returned error 9 +end-of-inline-data +stderr +1 errors +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_ok.test b/thirdparty/libzip-1.11.3/regress/open_ok.test new file mode 100644 index 0000000..dbbc2c3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_ok.test @@ -0,0 +1,8 @@ +# zip_open: file opens fine +program tryopen +arguments test.zip +return 0 +file test.zip test.zip +stdout +opening 'test.zip' succeeded, 3 entries +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_too_short.test b/thirdparty/libzip-1.11.3/regress/open_too_short.test new file mode 100644 index 0000000..f8e4685 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_too_short.test @@ -0,0 +1,11 @@ +# zip_open: file is too short for even a central directory entry +program tryopen +arguments test.piz +return 1 +file test.piz bogus.zip +stdout +opening 'test.piz' returned error 19 +end-of-inline-data +stderr +1 errors +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_truncate.test b/thirdparty/libzip-1.11.3/regress/open_truncate.test new file mode 100644 index 0000000..dc9e163 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_truncate.test @@ -0,0 +1,8 @@ +# zip_open: file opens fine and gets truncated +program tryopen +arguments -t test.zip +return 0 +file test.zip test.zip {} +stdout +opening 'test.zip' succeeded, 0 entries +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_truncated.test b/thirdparty/libzip-1.11.3/regress/open_truncated.test new file mode 100644 index 0000000..d07ec5b --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_truncated.test @@ -0,0 +1,11 @@ +# zip_open: try opening an incomplete zip archive +program tryopen +arguments test.zzip +return 1 +file test.zzip testfile-truncated.zip +stdout +opening 'test.zzip' returned error 35 +end-of-inline-data +stderr +1 errors +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_zip64_3mf.test b/thirdparty/libzip-1.11.3/regress/open_zip64_3mf.test new file mode 100644 index 0000000..d8dee80 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_zip64_3mf.test @@ -0,0 +1,8 @@ +# zip_open: ZIP64 file opens fine even when most eocd entries are 0xff (3MF format) +program tryopen +arguments test.zip +return 0 +file test.zip zip64-3mf.zip +stdout +opening 'test.zip' succeeded, 1 entries +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/open_zip64_ok.test b/thirdparty/libzip-1.11.3/regress/open_zip64_ok.test new file mode 100644 index 0000000..945b5f8 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/open_zip64_ok.test @@ -0,0 +1,8 @@ +# zip_open: ZIP64 file opens fine +program tryopen +arguments test.zip +return 0 +file test.zip zip64.zip +stdout +opening 'test.zip' succeeded, 1 entries +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/preload.test b/thirdparty/libzip-1.11.3/regress/preload.test new file mode 100644 index 0000000..5a62114 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/preload.test @@ -0,0 +1,4 @@ +description test if preload works +program nonrandomopentest +return 0 +preload nonrandomopen.so diff --git a/thirdparty/libzip-1.11.3/regress/progress.test b/thirdparty/libzip-1.11.3/regress/progress.test new file mode 100644 index 0000000..e5c2600 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/progress.test @@ -0,0 +1,12 @@ +# test default compression stores if smaller; print progress +return 0 +arguments -n -- test.zip print_progress add compressible aaaaaaaaaaaaaa add uncompressible uncompressible add_nul large-compressible 8200 add_file large-uncompressible large-uncompressible 0 -1 +file test.zip {} cm-default.zip +file large-uncompressible large-uncompressible +stdout +0.0% done +25.0% done +50.0% done +75.0% done +100.0% done +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/read_incons.test b/thirdparty/libzip-1.11.3/regress/read_incons.test new file mode 100644 index 0000000..cab43f5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/read_incons.test @@ -0,0 +1,9 @@ +arguments -c test.zip cat 0 +return 1 +file test.zip incons-trailing-garbage.zip +stdout +test +end-of-inline-data +stderr +can't read file at index '0': Zip archive inconsistent: garbage at end of compressed data +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/read_seek_read.test b/thirdparty/libzip-1.11.3/regress/read_seek_read.test new file mode 100644 index 0000000..b743f9f --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/read_seek_read.test @@ -0,0 +1,9 @@ +# read past EOF, seek to beginning, read again +return 0 +arguments test.zip fopen test fread 0 10 fseek 0 0 set fread 0 5 +file test.zip test.zip +stdout +opened 'test' as file 0 +test +test +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/rename_ascii.test b/thirdparty/libzip-1.11.3/regress/rename_ascii.test new file mode 100644 index 0000000..435ce5e --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/rename_ascii.test @@ -0,0 +1,4 @@ +# rename file to ASCII name in zip archive +return 0 +arguments testfile rename 0 testfile.txt +file testfile testfile-UTF8.zip testfile.zip diff --git a/thirdparty/libzip-1.11.3/regress/rename_cp437.test b/thirdparty/libzip-1.11.3/regress/rename_cp437.test new file mode 100644 index 0000000..5e80ada --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/rename_cp437.test @@ -0,0 +1,4 @@ +# rename file to CP437 name in zip archive (fails) +return 0 +arguments -x testfile.zip rename 0 "8182838485868788898A8B8C8D8E8F90" +file testfile.zip testfile.zip testfile-cp437.zip diff --git a/thirdparty/libzip-1.11.3/regress/rename_deleted.test b/thirdparty/libzip-1.11.3/regress/rename_deleted.test new file mode 100644 index 0000000..29c99e9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/rename_deleted.test @@ -0,0 +1,7 @@ +# rename deleted entry in zip archive (fails) +return 1 +arguments testfile.zip delete 1 delete 3 rename 1 othername +file testfile.zip testcomment.zip testcomment13.zip +stderr +can't rename file at index '1' to 'othername': Entry has been deleted +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/rename_fail.test b/thirdparty/libzip-1.11.3/regress/rename_fail.test new file mode 100644 index 0000000..d053734 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/rename_fail.test @@ -0,0 +1,7 @@ +# rename file inside zip archive, but file name already exists +return 1 +arguments rename.zip rename 0 file4 +file rename.zip testcomment.zip +stderr +can't rename file at index '0' to 'file4': File already exists +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/rename_ok.test b/thirdparty/libzip-1.11.3/regress/rename_ok.test new file mode 100644 index 0000000..22292d0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/rename_ok.test @@ -0,0 +1,4 @@ +# rename file inside zip archive +return 0 +arguments rename.zip rename 1 notfile2 +file rename.zip testcomment.zip rename_ok.zip diff --git a/thirdparty/libzip-1.11.3/regress/rename_ok.zip b/thirdparty/libzip-1.11.3/regress/rename_ok.zip new file mode 100644 index 0000000..ad07306 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/rename_ok.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/rename_utf8.test b/thirdparty/libzip-1.11.3/regress/rename_utf8.test new file mode 100644 index 0000000..d4b13a5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/rename_utf8.test @@ -0,0 +1,7 @@ +# rename file to UTF-8 name in zip archive +return 0 +arguments -i testfile dummy +stdin +rename 0 ÄÖÜßäöü +end-of-inline-data +file testfile testfile.zip testfile-UTF8.zip diff --git a/thirdparty/libzip-1.11.3/regress/rename_utf8_encmismatch.test b/thirdparty/libzip-1.11.3/regress/rename_utf8_encmismatch.test new file mode 100644 index 0000000..e20dbc9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/rename_utf8_encmismatch.test @@ -0,0 +1,7 @@ +# rename file to UTF-8 name in zip archive with CP437 comment (sets InfoZIP UTF-8 Name Extension) +return 0 +arguments -i testfile dummy +stdin +rename 0 ÄÖÜßäöü +end-of-inline-data +file testfile test-cp437-fc.zip test-cp437-fc-utf-8-filename.zip diff --git a/thirdparty/libzip-1.11.3/regress/reopen.test b/thirdparty/libzip-1.11.3/regress/reopen.test new file mode 100644 index 0000000..7e41bbc --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/reopen.test @@ -0,0 +1,9 @@ +description check the reopen functionality +return 0 +arguments -- testbuffer.zip cat 0 replace_file_contents 0 "Overwritten\n" cat 0 add newfile.txt "A new file\n" cat 1 +file testbuffer.zip testbuffer.zip testbuffer_reopen.zip +stdout +This is a test, and it seems to have been successful. +Overwritten +A new file +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/reopen_partial.test b/thirdparty/libzip-1.11.3/regress/reopen_partial.test new file mode 100644 index 0000000..a963ad0 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/reopen_partial.test @@ -0,0 +1,8 @@ +description check the reopen functionality (partial reads) +return 0 +arguments -- testbuffer.zip cat 0 replace_file_contents 0 "Overwritten\n" cat_partial 0 4 5 add newfile.txt "A new file\n" cat_partial 1 2 3 +file testbuffer.zip testbuffer.zip testbuffer_reopen.zip +stdout +This is a test, and it seems to have been successful. +writtnew +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/reopen_partial_rest.test b/thirdparty/libzip-1.11.3/regress/reopen_partial_rest.test new file mode 100644 index 0000000..ac844e3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/reopen_partial_rest.test @@ -0,0 +1,9 @@ +description check the reopen functionality (partial reads with -1 length) +return 0 +arguments -- testbuffer.zip cat 0 replace_file_contents 0 "Overwritten\n" cat_partial 0 4 -1 add newfile.txt "A new file\n" cat_partial 1 2 -1 +file testbuffer.zip testbuffer.zip testbuffer_reopen.zip +stdout +This is a test, and it seems to have been successful. +written +new file +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/set_comment_all.test b/thirdparty/libzip-1.11.3/regress/set_comment_all.test new file mode 100644 index 0000000..4107d88 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_comment_all.test @@ -0,0 +1,4 @@ +# change local and global comments in a zip archive +return 0 +arguments testcomment.zip set_archive_comment "This is the new,\r\nmultiline archive comment.\r\nAin't it nice?" set_file_comment 0 "File comment no 0" set_file_comment 1 "File comment no 1" set_file_comment 2 "File comment no 2" set_file_comment 3 "File comment no 3" +file testcomment.zip testcomment.zip testchanged.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_comment_localonly.test b/thirdparty/libzip-1.11.3/regress/set_comment_localonly.test new file mode 100644 index 0000000..66b9b8d --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_comment_localonly.test @@ -0,0 +1,4 @@ +# change file comments in a zip archive +return 0 +arguments testcomment.zip set_file_comment 0 "File comment no 0" set_file_comment 1 "File comment no 1" set_file_comment 3 "File comment no 3" set_file_comment 2 "" +file testcomment.zip testcomment.zip testchangedlocal.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_comment_removeglobal.test b/thirdparty/libzip-1.11.3/regress/set_comment_removeglobal.test new file mode 100644 index 0000000..3b48933 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_comment_removeglobal.test @@ -0,0 +1,4 @@ +# remove archive comment +return 0 +arguments testcomment.zip set_archive_comment "" +file testcomment.zip testcomment.zip testcommentremoved.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_comment_revert.test b/thirdparty/libzip-1.11.3/regress/set_comment_revert.test new file mode 100644 index 0000000..3abbbb1 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_comment_revert.test @@ -0,0 +1,4 @@ +# start changing local and global comments, but revert before closing +return 0 +arguments testcomment.zip set_archive_comment "some long string, a bit longer than this at least" set_file_comment 0 "File comment no 0" set_file_comment 1 "File comment no 1" set_file_comment 3 "File comment no 3" set_file_comment 2 "" unchange_all +file testcomment.zip testcomment.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_bzip2_to_deflate.test b/thirdparty/libzip-1.11.3/regress/set_compression_bzip2_to_deflate.test new file mode 100644 index 0000000..bbc09c2 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_bzip2_to_deflate.test @@ -0,0 +1,5 @@ +# change method from bzip2 to deflated +features HAVE_LIBBZ2 +return 0 +arguments test.zip set_file_compression 0 deflate 0 +file test.zip testbzip2.zip testdeflated.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_deflate_to_bzip2.test b/thirdparty/libzip-1.11.3/regress/set_compression_deflate_to_bzip2.test new file mode 100644 index 0000000..e56e457 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_deflate_to_bzip2.test @@ -0,0 +1,5 @@ +# change method from deflated to bzip2 +features HAVE_LIBBZ2 +return 0 +arguments test.zip set_file_compression 0 bzip2 0 +file test.zip testdeflated.zip testbzip2.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_deflate_to_deflate.test b/thirdparty/libzip-1.11.3/regress/set_compression_deflate_to_deflate.test new file mode 100644 index 0000000..99ee0d7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_deflate_to_deflate.test @@ -0,0 +1,4 @@ +# change method from deflated to deflated (no change) +return 0 +arguments test.zip set_file_compression 0 deflate 0 +file test.zip testdeflated.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_deflate_to_store.test b/thirdparty/libzip-1.11.3/regress/set_compression_deflate_to_store.test new file mode 100644 index 0000000..ded1a85 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_deflate_to_store.test @@ -0,0 +1,4 @@ +# change method from deflated to stored +return 0 +arguments test.zip set_file_compression 0 store 0 +file test.zip testdeflated.zip teststored.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_lzma_no_eos_to_store.test b/thirdparty/libzip-1.11.3/regress/set_compression_lzma_no_eos_to_store.test new file mode 100644 index 0000000..48ae8a9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_lzma_no_eos_to_store.test @@ -0,0 +1,5 @@ +# change method from lzma-compressed (id 14) without EOS/EOPM marker to stored +features HAVE_LIBLZMA +return 0 +arguments test.zip set_file_compression 0 store 0 +file test.zip lzma-no-eos.zip stored-no-eos.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_lzma_to_store.test b/thirdparty/libzip-1.11.3/regress/set_compression_lzma_to_store.test new file mode 100644 index 0000000..7c85bcc --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_lzma_to_store.test @@ -0,0 +1,5 @@ +# change method from lzma-compressed (id 14) to stored +features HAVE_LIBLZMA +return 0 +arguments test.zip set_file_compression 0 store 0 +file test.zip testfile-lzma.zip testfile-stored-dos.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_store_to_bzip2.test b/thirdparty/libzip-1.11.3/regress/set_compression_store_to_bzip2.test new file mode 100644 index 0000000..5a7a0f4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_store_to_bzip2.test @@ -0,0 +1,5 @@ +# change method from stored to bzip2 +features HAVE_LIBBZ2 +return 0 +arguments test.zip set_file_compression 0 bzip2 0 +file test.zip teststored.zip testbzip2.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_store_to_deflate.test b/thirdparty/libzip-1.11.3/regress/set_compression_store_to_deflate.test new file mode 100644 index 0000000..3467ad6 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_store_to_deflate.test @@ -0,0 +1,4 @@ +# change method from stored to deflated +return 0 +arguments test.zip set_file_compression 0 deflate 0 +file test.zip teststored.zip testdeflated.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_store_to_lzma.test b/thirdparty/libzip-1.11.3/regress/set_compression_store_to_lzma.test new file mode 100644 index 0000000..239e68b --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_store_to_lzma.test @@ -0,0 +1,5 @@ +# change method from stored to lzma-compressed (Id 14) +features HAVE_LIBLZMA +return 0 +arguments test.zip set_file_compression 0 lzma 0 +file test.zip testfile-stored-dos.zip testfile-lzma.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_store_to_store.test b/thirdparty/libzip-1.11.3/regress/set_compression_store_to_store.test new file mode 100644 index 0000000..486274e --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_store_to_store.test @@ -0,0 +1,4 @@ +# change method from stored to stored (no change) +return 0 +arguments test.zip set_file_compression 0 store 0 +file test.zip teststored.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_store_to_xz.test b/thirdparty/libzip-1.11.3/regress/set_compression_store_to_xz.test new file mode 100644 index 0000000..4838f05 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_store_to_xz.test @@ -0,0 +1,5 @@ +# change method from stored to xz-compressed +features HAVE_LIBLZMA +return 0 +arguments test.zip set_file_compression 0 xz 0 +file test.zip testfile-stored-dos.zip testfile-xz.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_store_to_zstd.test b/thirdparty/libzip-1.11.3/regress/set_compression_store_to_zstd.test new file mode 100644 index 0000000..eb734cf --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_store_to_zstd.test @@ -0,0 +1,5 @@ +# change method from stored to zstd-compressed +features HAVE_LIBZSTD +return 0 +arguments test.zip set_file_compression 0 zstd 0 +file test.zip testfile-stored-dos.zip testfile-zstd.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_unknown.test b/thirdparty/libzip-1.11.3/regress/set_compression_unknown.test new file mode 100644 index 0000000..1f7defd --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_unknown.test @@ -0,0 +1,7 @@ +# change method to unknown +return 1 +arguments test.zip set_file_compression 0 unknown 0 +file test.zip teststored.zip +stderr +can't set file compression method at index '0' to 'unknown', flags '0': Compression method not supported +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_xz_to_store.test b/thirdparty/libzip-1.11.3/regress/set_compression_xz_to_store.test new file mode 100644 index 0000000..88fdf10 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_xz_to_store.test @@ -0,0 +1,5 @@ +# change method from xz-compressed to stored +features HAVE_LIBLZMA +return 0 +arguments test.zip set_file_compression 0 store 0 +file test.zip testfile-xz.zip testfile-stored-dos.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_compression_zstd_to_store.test b/thirdparty/libzip-1.11.3/regress/set_compression_zstd_to_store.test new file mode 100644 index 0000000..d652cef --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_compression_zstd_to_store.test @@ -0,0 +1,5 @@ +# change method from zstd-compressed to stored +features HAVE_LIBZSTD +return 0 +arguments test.zip set_file_compression 0 store 0 +file test.zip testfile-zstd.zip testfile-stored-dos.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_file_dostime.test b/thirdparty/libzip-1.11.3/regress/set_file_dostime.test new file mode 100644 index 0000000..d0bf6c9 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_file_dostime.test @@ -0,0 +1,4 @@ +# change dostime in a zip archive (use torrentzip default time) +return 0 +arguments testfile set_file_dostime 0 48128 8600 +file testfile testfile.zip testfile0.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_file_mtime.test b/thirdparty/libzip-1.11.3/regress/set_file_mtime.test new file mode 100644 index 0000000..0919342 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_file_mtime.test @@ -0,0 +1,4 @@ +# change mtime in a zip archive +return 0 +arguments testfile set_file_mtime 0 1407272201 +file testfile testfile.zip testfile2014.zip diff --git a/thirdparty/libzip-1.11.3/regress/set_file_mtime_pkware.test b/thirdparty/libzip-1.11.3/regress/set_file_mtime_pkware.test new file mode 100644 index 0000000..1c07b7b --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/set_file_mtime_pkware.test @@ -0,0 +1,7 @@ +# change mtime in a zip archive, fails because file is PKWare-encrypted +return 1 +arguments testfile set_file_mtime 0 1407272201 +file testfile encrypt.zip +stderr +can't set file mtime at index '0' to '1407272201': Operation not supported +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/short b/thirdparty/libzip-1.11.3/regress/short new file mode 100644 index 0000000..eba61a7 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/short @@ -0,0 +1 @@ +short \ No newline at end of file diff --git a/thirdparty/libzip-1.11.3/regress/source_hole.c b/thirdparty/libzip-1.11.3/regress/source_hole.c new file mode 100644 index 0000000..beed207 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/source_hole.c @@ -0,0 +1,577 @@ +/* + source_hole.c -- source for handling huge files that are mostly NULs + Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include + +#include "zip.h" + +/* public API */ + +zip_source_t *source_hole_create(const char *, int flags, zip_error_t *); + + +#ifndef EFTYPE +#define EFTYPE EINVAL +#endif + + +#define MY_MIN(a, b) ((a) < (b) ? (a) : (b)) + +#define FRAGMENT_SIZE (8 * 1024) + +#define MARK_BEGIN "NiH0" +#define MARK_DATA "NiH1" +#define MARK_NUL "NiH2" + + +typedef struct buffer { + zip_uint64_t fragment_size; + zip_uint8_t **fragment; + zip_uint64_t nfragments; + zip_uint64_t size; + zip_uint64_t offset; +} buffer_t; + +static void buffer_free(buffer_t *buffer); +static buffer_t *buffer_from_file(const char *fname, int flags, zip_error_t *error); +static buffer_t *buffer_new(void); +static zip_int64_t buffer_read(buffer_t *buffer, zip_uint8_t *data, zip_uint64_t length, zip_error_t *error); +static int buffer_read_file(buffer_t *buffer, FILE *f, zip_error_t *error); +static zip_int64_t buffer_seek(buffer_t *buffer, void *data, zip_uint64_t length, zip_error_t *error); +static int buffer_to_file(buffer_t *buffer, const char *fname, zip_error_t *error); +static zip_int64_t buffer_write(buffer_t *buffer, const zip_uint8_t *data, zip_uint64_t length, zip_error_t *error); +static zip_uint64_t get_u64(const zip_uint8_t *b); +static int only_nul(const zip_uint8_t *data, zip_uint64_t length); +static int write_nuls(zip_uint64_t n, FILE *f); +static int write_u64(zip_uint64_t u64, FILE *f); + + +typedef struct hole { + zip_error_t error; + char *fname; + buffer_t *in; + buffer_t *out; +} hole_t; + +static hole_t *hole_new(const char *fname, int flags, zip_error_t *error); +static zip_int64_t source_hole_cb(void *ud, void *data, zip_uint64_t length, zip_source_cmd_t command); + + +zip_source_t * +source_hole_create(const char *fname, int flags, zip_error_t *error) { + hole_t *ud = hole_new(fname, flags, error); + + if (ud == NULL) { + return NULL; + } + return zip_source_function_create(source_hole_cb, ud, error); +} + + +static void +buffer_free(buffer_t *buffer) { + zip_uint64_t i; + + if (buffer == NULL) { + return; + } + + if (buffer->fragment) { + for (i = 0; i < buffer->nfragments; i++) { + free(buffer->fragment[i]); + } + free(buffer->fragment); + } + free(buffer); +} + + +static buffer_t * +buffer_from_file(const char *fname, int flags, zip_error_t *error) { + buffer_t *buffer; + FILE *f; + + if ((buffer = buffer_new()) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if ((flags & ZIP_TRUNCATE) == 0) { + if ((f = fopen(fname, "rb")) == NULL) { + if (!(errno == ENOENT && (flags & ZIP_CREATE))) { + buffer_free(buffer); + return NULL; + } + } + else { + if (buffer_read_file(buffer, f, error) < 0) { + buffer_free(buffer); + fclose(f); + return NULL; + } + fclose(f); + } + } + + return buffer; +} + + +static buffer_t * +buffer_new(void) { + buffer_t *buffer; + + if ((buffer = (buffer_t *)malloc(sizeof(*buffer))) == NULL) { + return NULL; + } + + buffer->fragment = NULL; + buffer->nfragments = 0; + buffer->fragment_size = FRAGMENT_SIZE; + buffer->size = 0; + buffer->offset = 0; + + return buffer; +} + + +static zip_int64_t +buffer_read(buffer_t *buffer, zip_uint8_t *data, zip_uint64_t length, zip_error_t *error) { + zip_uint64_t n, i, fragment_offset; + + length = MY_MIN(length, buffer->size - buffer->offset); + + if (length == 0) { + return 0; + } + if (length > ZIP_INT64_MAX) { + return -1; + } + + i = buffer->offset / buffer->fragment_size; + fragment_offset = buffer->offset % buffer->fragment_size; + n = 0; + while (n < length) { + zip_uint64_t left = MY_MIN(length - n, buffer->fragment_size - fragment_offset); + + if (buffer->fragment[i]) { + memcpy(data + n, buffer->fragment[i] + fragment_offset, left); + } + else { + memset(data + n, 0, left); + } + + n += left; + i++; + fragment_offset = 0; + } + + buffer->offset += n; + return (zip_int64_t)n; +} + + +static int +buffer_read_file(buffer_t *buffer, FILE *f, zip_error_t *error) { + zip_uint8_t b[20]; + zip_uint64_t i; + + if (fread(b, 20, 1, f) != 1) { + zip_error_set(error, ZIP_ER_READ, errno); + return -1; + } + + if (memcmp(b, MARK_BEGIN, 4) != 0) { + zip_error_set(error, ZIP_ER_READ, EFTYPE); + return -1; + } + + buffer->fragment_size = get_u64(b + 4); + buffer->size = get_u64(b + 12); + + if (buffer->fragment_size == 0) { + zip_error_set(error, ZIP_ER_INCONS, 0); + return -1; + } + + buffer->nfragments = buffer->size / buffer->fragment_size; + if (buffer->size % buffer->fragment_size != 0) { + buffer->nfragments += 1; + } + + if ((buffer->nfragments > SIZE_MAX / sizeof(buffer->fragment[0])) || ((buffer->fragment = (zip_uint8_t **)malloc(sizeof(buffer->fragment[0]) * buffer->nfragments)) == NULL)) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return -1; + } + + for (i = 0; i < buffer->nfragments; i++) { + buffer->fragment[i] = NULL; + } + + i = 0; + while (i < buffer->nfragments) { + if (fread(b, 4, 1, f) != 1) { + zip_error_set(error, ZIP_ER_READ, errno); + return -1; + } + + if (memcmp(b, MARK_DATA, 4) == 0) { + if (buffer->fragment_size > SIZE_MAX) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return -1; + } + if ((buffer->fragment[i] = (zip_uint8_t *)malloc(buffer->fragment_size)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return -1; + } + if (fread(buffer->fragment[i], buffer->fragment_size, 1, f) != 1) { + zip_error_set(error, ZIP_ER_READ, errno); + return -1; + } + i++; + } + else if (memcmp(b, MARK_NUL, 4) == 0) { + if (fread(b, 8, 1, f) != 1) { + zip_error_set(error, ZIP_ER_READ, errno); + return -1; + } + i += get_u64(b); + } + else { + zip_error_set(error, ZIP_ER_READ, EFTYPE); + return -1; + } + } + + return 0; +} + +static zip_int64_t +buffer_seek(buffer_t *buffer, void *data, zip_uint64_t length, zip_error_t *error) { + zip_int64_t new_offset = zip_source_seek_compute_offset(buffer->offset, buffer->size, data, length, error); + + if (new_offset < 0) { + return -1; + } + + buffer->offset = (zip_uint64_t)new_offset; + return 0; +} + + +static int +buffer_to_file(buffer_t *buffer, const char *fname, zip_error_t *error) { + FILE *f = fopen(fname, "wb"); + zip_uint64_t i; + zip_uint64_t nul_run; + + if (f == NULL) { + zip_error_set(error, ZIP_ER_OPEN, errno); + return -1; + } + + fwrite(MARK_BEGIN, 4, 1, f); + write_u64(buffer->fragment_size, f); + write_u64(buffer->size, f); + + nul_run = 0; + for (i = 0; i * buffer->fragment_size < buffer->size; i++) { + if (buffer->fragment[i] == NULL || only_nul(buffer->fragment[i], buffer->fragment_size)) { + nul_run++; + } + else { + if (nul_run > 0) { + write_nuls(nul_run, f); + nul_run = 0; + } + fwrite(MARK_DATA, 4, 1, f); + + fwrite(buffer->fragment[i], 1, buffer->fragment_size, f); + } + } + + if (nul_run > 0) { + write_nuls(nul_run, f); + } + + if (fclose(f) != 0) { + zip_error_set(error, ZIP_ER_WRITE, errno); + return -1; + } + + return 0; +} + + +static zip_int64_t +buffer_write(buffer_t *buffer, const zip_uint8_t *data, zip_uint64_t length, zip_error_t *error) { + zip_uint8_t **fragment; + if (buffer->offset + length > buffer->nfragments * buffer->fragment_size) { + zip_uint64_t needed_fragments = (buffer->offset + length + buffer->fragment_size - 1) / buffer->fragment_size; + zip_uint64_t new_capacity = buffer->nfragments; + zip_uint64_t i; + + if (new_capacity == 0) { + new_capacity = 4; + } + while (new_capacity < needed_fragments) { + new_capacity *= 2; + } + + fragment = realloc(buffer->fragment, new_capacity * sizeof(*fragment)); + + if (fragment == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return -1; + } + + for (i = buffer->nfragments; i < new_capacity; i++) { + fragment[i] = NULL; + } + + buffer->fragment = fragment; + buffer->nfragments = new_capacity; + } + + if (!only_nul(data, length)) { + zip_uint64_t idx, n, fragment_offset; + + idx = buffer->offset / buffer->fragment_size; + fragment_offset = buffer->offset % buffer->fragment_size; + n = 0; + + while (n < length) { + zip_uint64_t left = MY_MIN(length - n, buffer->fragment_size - fragment_offset); + + if (buffer->fragment[idx] == NULL) { + if ((buffer->fragment[idx] = (zip_uint8_t *)malloc(buffer->fragment_size)) == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return -1; + } + memset(buffer->fragment[idx], 0, buffer->fragment_size); + } + memcpy(buffer->fragment[idx] + fragment_offset, data + n, left); + + n += left; + idx++; + fragment_offset = 0; + } + } + + buffer->offset += length; + if (buffer->offset > buffer->size) { + buffer->size = buffer->offset; + } + + return (zip_int64_t)length; +} + + +static zip_uint64_t +get_u64(const zip_uint8_t *b) { + zip_uint64_t i; + + i = (zip_uint64_t)b[0] << 56 | (zip_uint64_t)b[1] << 48 | (zip_uint64_t)b[2] << 40 | (zip_uint64_t)b[3] << 32 | (zip_uint64_t)b[4] << 24 | (zip_uint64_t)b[5] << 16 | (zip_uint64_t)b[6] << 8 | (zip_uint64_t)b[7]; + + return i; +} + + +static int +only_nul(const zip_uint8_t *data, zip_uint64_t length) { + zip_uint64_t i; + + for (i = 0; i < length; i++) { + if (data[i] != '\0') { + return 0; + } + } + + return 1; +} + + +static int +write_nuls(zip_uint64_t n, FILE *f) { + if (fwrite(MARK_NUL, 4, 1, f) != 1) { + return -1; + } + return write_u64(n, f); +} + + +static int +write_u64(zip_uint64_t u64, FILE *f) { + zip_uint8_t b[8]; + + b[0] = (zip_uint8_t)((u64 >> 56) & 0xff); + b[1] = (zip_uint8_t)((u64 >> 48) & 0xff); + b[2] = (zip_uint8_t)((u64 >> 40) & 0xff); + b[3] = (zip_uint8_t)((u64 >> 32) & 0xff); + b[4] = (zip_uint8_t)((u64 >> 24) & 0xff); + b[5] = (zip_uint8_t)((u64 >> 16) & 0xff); + b[6] = (zip_uint8_t)((u64 >> 8) & 0xff); + b[7] = (zip_uint8_t)(u64 & 0xff); + + return fwrite(b, 8, 1, f) == 1 ? 0 : -1; +} + + +static void +hole_free(hole_t *hole) { + if (hole == NULL) { + return; + } + zip_error_fini(&hole->error); + buffer_free(hole->in); + buffer_free(hole->out); + free(hole->fname); + free(hole); +} + + +static hole_t * +hole_new(const char *fname, int flags, zip_error_t *error) { + hole_t *ctx = (hole_t *)malloc(sizeof(*ctx)); + + if (ctx == NULL) { + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if ((ctx->fname = strdup(fname)) == NULL) { + free(ctx); + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + + if ((ctx->in = buffer_from_file(fname, flags, error)) == NULL) { + free(ctx); + return NULL; + } + + zip_error_init(&ctx->error); + ctx->out = NULL; + + return ctx; +} + + +static zip_int64_t +source_hole_cb(void *ud, void *data, zip_uint64_t length, zip_source_cmd_t command) { + hole_t *ctx = (hole_t *)ud; + + switch (command) { + case ZIP_SOURCE_BEGIN_WRITE: + ctx->out = buffer_new(); + return 0; + + case ZIP_SOURCE_CLOSE: + return 0; + + case ZIP_SOURCE_COMMIT_WRITE: + if (buffer_to_file(ctx->out, ctx->fname, &ctx->error) < 0) { + return -1; + } + buffer_free(ctx->in); + ctx->in = ctx->out; + ctx->out = NULL; + return 0; + + case ZIP_SOURCE_ERROR: + return zip_error_to_data(&ctx->error, data, length); + + case ZIP_SOURCE_FREE: + hole_free(ctx); + return 0; + + case ZIP_SOURCE_OPEN: + ctx->in->offset = 0; + return 0; + + case ZIP_SOURCE_READ: + return buffer_read(ctx->in, data, length, &ctx->error); + + case ZIP_SOURCE_REMOVE: + buffer_free(ctx->in); + ctx->in = buffer_new(); + buffer_free(ctx->out); + ctx->out = NULL; + (void)remove(ctx->fname); + return 0; + + case ZIP_SOURCE_ROLLBACK_WRITE: + buffer_free(ctx->out); + ctx->out = NULL; + return 0; + + case ZIP_SOURCE_SEEK: + return buffer_seek(ctx->in, data, length, &ctx->error); + + case ZIP_SOURCE_SEEK_WRITE: + return buffer_seek(ctx->out, data, length, &ctx->error); + + case ZIP_SOURCE_STAT: { + zip_stat_t *st = ZIP_SOURCE_GET_ARGS(zip_stat_t, data, length, &ctx->error); + + if (st == NULL) { + return -1; + } + + /* TODO: return ENOENT if fname doesn't exist */ + + st->valid |= ZIP_STAT_SIZE; + st->size = ctx->in->size; + return 0; + } + + case ZIP_SOURCE_TELL: + return (zip_int64_t)ctx->in->offset; + + case ZIP_SOURCE_TELL_WRITE: + return (zip_int64_t)ctx->out->offset; + + case ZIP_SOURCE_WRITE: + return buffer_write(ctx->out, data, length, &ctx->error); + + case ZIP_SOURCE_SUPPORTS: + return zip_source_make_command_bitmap(ZIP_SOURCE_BEGIN_WRITE, ZIP_SOURCE_COMMIT_WRITE, ZIP_SOURCE_CLOSE, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_REMOVE, ZIP_SOURCE_ROLLBACK_WRITE, ZIP_SOURCE_SEEK, ZIP_SOURCE_SEEK_WRITE, ZIP_SOURCE_STAT, ZIP_SOURCE_TELL, ZIP_SOURCE_TELL_WRITE, ZIP_SOURCE_WRITE, -1); + + default: + zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + } +} diff --git a/thirdparty/libzip-1.11.3/regress/stat_index_cp437_guess.test b/thirdparty/libzip-1.11.3/regress/stat_index_cp437_guess.test new file mode 100644 index 0000000..4b25e90 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/stat_index_cp437_guess.test @@ -0,0 +1,150 @@ +# guess CP437 file names and autoconvert them +arguments test-cp437.zip stat 0 stat 1 stat 2 stat 3 stat 4 stat 5 stat 6 stat 7 stat 8 stat 9 stat 10 stat 11 stat 12 stat 13 stat 14 stat 15 +return 0 +file test-cp437.zip test-cp437.zip +stdout +name: '☺☻♥♦♣♠•◘○◙♂♀♪♫☼►' +index: '0' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:51:50' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '◄↕‼¶§▬↨↑↓→←∟↔▲▼ ' +index: '1' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:51:54' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '!"#$%&'()*+,-./0' +index: '2' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:51:58' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '123456789:;<=>?@' +index: '3' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:04' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'ABCDEFGHIJKLMNOP' +index: '4' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:08' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'QRSTUVWXYZ[\]^_`' +index: '5' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:12' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'abcdefghijklmnop' +index: '6' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:18' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'qrstuvwxyz{|}~⌂Ç' +index: '7' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:22' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'üéâäàåçêëèïîìÄÅÉ' +index: '8' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:26' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'æÆôöòûùÿÖÜ¢£¥₧ƒá' +index: '9' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:30' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'íóúñѪº¿⌐¬½¼¡«»░' +index: '10' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:36' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '▒▓│┤╡╢╖╕╣║╗╝╜╛┐└' +index: '11' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:40' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '┴┬├─┼╞╟╚╔╩╦╠═╬╧╨' +index: '12' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:44' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '╤╥╙╘╒╓╫╪┘┌█▄▌▐▀α' +index: '13' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:50' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'ßΓπΣσµτΦΘΩδ∞φε∩≡' +index: '14' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:54' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '±≥≤⌠⌡÷≈°∙·√ⁿ²■  ' +index: '15' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:53:02' +crc: '0' +compression method: '0' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/stat_index_cp437_raw.test b/thirdparty/libzip-1.11.3/regress/stat_index_cp437_raw.test new file mode 100644 index 0000000..6450ad4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/stat_index_cp437_raw.test @@ -0,0 +1,150 @@ +# get raw file names them from archive +arguments -x -r test-cp437.zip stat 0 stat 1 stat 2 stat 3 stat 4 stat 5 stat 6 stat 7 stat 8 stat 9 stat 10 stat 11 stat 12 stat 13 stat 14 stat 15 +return 0 +file test-cp437.zip test-cp437.zip +stdout +name: '0102030405060708090a0b0c0d0e0f10' +index: '0' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:51:50' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '1112131415161718191a1b1c1d1e1f20' +index: '1' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:51:54' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '2122232425262728292a2b2c2d2e2f30' +index: '2' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:51:58' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '3132333435363738393a3b3c3d3e3f40' +index: '3' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:04' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '4142434445464748494a4b4c4d4e4f50' +index: '4' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:08' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '5152535455565758595a5b5c5d5e5f60' +index: '5' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:12' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '6162636465666768696a6b6c6d6e6f70' +index: '6' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:18' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '7172737475767778797a7b7c7d7e7f80' +index: '7' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:22' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '8182838485868788898a8b8c8d8e8f90' +index: '8' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:26' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '9192939495969798999a9b9c9d9e9fa0' +index: '9' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:30' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'a1a2a3a4a5a6a7a8a9aaabacadaeafb0' +index: '10' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:36' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'b1b2b3b4b5b6b7b8b9babbbcbdbebfc0' +index: '11' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:40' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'c1c2c3c4c5c6c7c8c9cacbcccdcecfd0' +index: '12' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:44' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'd1d2d3d4d5d6d7d8d9dadbdcdddedfe0' +index: '13' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:50' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'e1e2e3e4e5e6e7e8e9eaebecedeeeff0' +index: '14' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:54' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'f1f2f3f4f5f6f7f8f9fafbfcfdfeffff' +index: '15' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:53:02' +crc: '0' +compression method: '0' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/stat_index_cp437_strict.test b/thirdparty/libzip-1.11.3/regress/stat_index_cp437_strict.test new file mode 100644 index 0000000..51516ca --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/stat_index_cp437_strict.test @@ -0,0 +1,150 @@ +# strictly follow ZIP spec and expect CP437 file names, and autoconvert them +arguments -s test-cp437.zip stat 0 stat 1 stat 2 stat 3 stat 4 stat 5 stat 6 stat 7 stat 8 stat 9 stat 10 stat 11 stat 12 stat 13 stat 14 stat 15 +return 0 +file test-cp437.zip test-cp437.zip +stdout +name: '☺☻♥♦♣♠•◘○◙♂♀♪♫☼►' +index: '0' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:51:50' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '◄↕‼¶§▬↨↑↓→←∟↔▲▼ ' +index: '1' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:51:54' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '!"#$%&'()*+,-./0' +index: '2' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:51:58' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '123456789:;<=>?@' +index: '3' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:04' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'ABCDEFGHIJKLMNOP' +index: '4' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:08' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'QRSTUVWXYZ[\]^_`' +index: '5' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:12' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'abcdefghijklmnop' +index: '6' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:18' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'qrstuvwxyz{|}~⌂Ç' +index: '7' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:22' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'üéâäàåçêëèïîìÄÅÉ' +index: '8' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:26' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'æÆôöòûùÿÖÜ¢£¥₧ƒá' +index: '9' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:30' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'íóúñѪº¿⌐¬½¼¡«»░' +index: '10' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:36' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '▒▓│┤╡╢╖╕╣║╗╝╜╛┐└' +index: '11' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:40' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '┴┬├─┼╞╟╚╔╩╦╠═╬╧╨' +index: '12' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:44' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '╤╥╙╘╒╓╫╪┘┌█▄▌▐▀α' +index: '13' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:50' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'ßΓπΣσµτΦΘΩδ∞φε∩≡' +index: '14' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:52:54' +crc: '0' +compression method: '0' +encryption method: '0' + +name: '±≥≤⌠⌡÷≈°∙·√ⁿ²■  ' +index: '15' +size: '0' +compressed size: '0' +mtime: 'Fri Feb 17 2012 20:53:02' +crc: '0' +compression method: '0' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/stat_index_fileorder.test b/thirdparty/libzip-1.11.3/regress/stat_index_fileorder.test new file mode 100644 index 0000000..f50541c --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/stat_index_fileorder.test @@ -0,0 +1,24 @@ +# zip_open: entries ordered by central directory order +arguments fileorder.zzip stat 0 stat 1 +return 0 +file fileorder.zzip fileorder.zip +stdout +name: 'file1' +index: '0' +size: '5' +compressed size: '5' +mtime: 'Fri Apr 27 2012 23:21:42' +crc: '9ee760e5' +compression method: '0' +encryption method: '0' + +name: 'file2' +index: '1' +size: '5' +compressed size: '5' +mtime: 'Fri Apr 27 2012 23:21:44' +crc: '7ee315f' +compression method: '0' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/stat_index_streamed.test b/thirdparty/libzip-1.11.3/regress/stat_index_streamed.test new file mode 100644 index 0000000..1a4b68c --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/stat_index_streamed.test @@ -0,0 +1,15 @@ +# stat file in streamed zip file +arguments streamed stat 0 +file streamed streamed.zip +return 0 +stdout +name: '-' +index: '0' +size: '2' +compressed size: '4' +mtime: 'Wed Apr 25 2012 10:20:38' +crc: 'ddeaa107' +compression method: '8' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/stat_index_streamed_zip64.test b/thirdparty/libzip-1.11.3/regress/stat_index_streamed_zip64.test new file mode 100644 index 0000000..79b9c1f --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/stat_index_streamed_zip64.test @@ -0,0 +1,15 @@ +# stat file in streamed zip file +arguments streamed stat 0 +file streamed streamed-zip64.zip +return 0 +stdout +name: '-' +index: '0' +size: '2' +compressed size: '4' +mtime: 'Wed Apr 25 2012 10:20:38' +crc: 'ddeaa107' +compression method: '8' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/stat_index_utf8_guess.test b/thirdparty/libzip-1.11.3/regress/stat_index_utf8_guess.test new file mode 100644 index 0000000..1592eab --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/stat_index_utf8_guess.test @@ -0,0 +1,15 @@ +# guess UTF-8 file names +arguments test-utf8.zip stat 0 +return 0 +file test-utf8.zip test-utf8.zip +stdout +name: 'ÄÖÜäöüßćçĉéèêëē' +index: '0' +size: '0' +compressed size: '0' +mtime: 'Sat Feb 18 2012 00:15:08' +crc: '0' +compression method: '0' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/stat_index_utf8_raw.test b/thirdparty/libzip-1.11.3/regress/stat_index_utf8_raw.test new file mode 100644 index 0000000..1f6ff36 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/stat_index_utf8_raw.test @@ -0,0 +1,15 @@ +# print UTF-8 file names +arguments -r test-utf8.zip stat 0 +return 0 +file test-utf8.zip test-utf8.zip +stdout +name: 'ÄÖÜäöüßćçĉéèêëē' +index: '0' +size: '0' +compressed size: '0' +mtime: 'Sat Feb 18 2012 00:15:08' +crc: '0' +compression method: '0' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/stat_index_utf8_strict.test b/thirdparty/libzip-1.11.3/regress/stat_index_utf8_strict.test new file mode 100644 index 0000000..5f968e6 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/stat_index_utf8_strict.test @@ -0,0 +1,16 @@ +# follow strict rules and convert UTF-8 as if it was CP437, but not +# if the files are marked as having UTF-8 names +arguments -s test-utf8.zip stat 0 +return 0 +file test-utf8.zip test-utf8.zip +stdout +name: 'ÄÖÜäöüßćçĉéèêëē' +index: '0' +size: '0' +compressed size: '0' +mtime: 'Sat Feb 18 2012 00:15:08' +crc: '0' +compression method: '0' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/stat_index_utf8_unmarked_strict.test b/thirdparty/libzip-1.11.3/regress/stat_index_utf8_unmarked_strict.test new file mode 100644 index 0000000..640812c --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/stat_index_utf8_unmarked_strict.test @@ -0,0 +1,16 @@ +# follow strict rules and convert UTF-8 as if it was CP437, +# if not marked otherwise (in this case: not marked) +arguments -s test-utf8-unmarked.zip stat 0 +return 0 +file test-utf8-unmarked.zip test-utf8-unmarked.zip +stdout +name: '├ä├û├£├ñ├╢├╝├ƒ─ç├º─ë├⌐├¿├¬├½─ô' +index: '0' +size: '0' +compressed size: '0' +mtime: 'Sat Feb 18 2012 00:15:08' +crc: '0' +compression method: '0' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/stat_index_zip64.test b/thirdparty/libzip-1.11.3/regress/stat_index_zip64.test new file mode 100644 index 0000000..a2a8ddf --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/stat_index_zip64.test @@ -0,0 +1,15 @@ +# stat file in zip64 zip file +arguments bigzero stat 0 +file bigzero bigzero.zip +return 0 +stdout +name: 'bigzero' +index: '0' +size: '4294967296' +compressed size: '4168157' +mtime: 'Thu Mar 15 2012 14:54:06' +crc: 'd202ef8d' +compression method: '8' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/stored-no-eos.zip b/thirdparty/libzip-1.11.3/regress/stored-no-eos.zip new file mode 100644 index 0000000..4a7745f Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/stored-no-eos.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/streamed-zip64.zip b/thirdparty/libzip-1.11.3/regress/streamed-zip64.zip new file mode 100644 index 0000000..8588619 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/streamed-zip64.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/streamed.zip b/thirdparty/libzip-1.11.3/regress/streamed.zip new file mode 100644 index 0000000..ab4d494 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/streamed.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/test-cp437-comment-utf-8.zip b/thirdparty/libzip-1.11.3/regress/test-cp437-comment-utf-8.zip new file mode 100644 index 0000000..748a269 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/test-cp437-comment-utf-8.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/test-cp437-fc-utf-8-filename.zip b/thirdparty/libzip-1.11.3/regress/test-cp437-fc-utf-8-filename.zip new file mode 100644 index 0000000..7aeb809 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/test-cp437-fc-utf-8-filename.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/test-cp437-fc.zip b/thirdparty/libzip-1.11.3/regress/test-cp437-fc.zip new file mode 100644 index 0000000..0c4f04d Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/test-cp437-fc.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/test-cp437.zip b/thirdparty/libzip-1.11.3/regress/test-cp437.zip new file mode 100644 index 0000000..9e6b91d Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/test-cp437.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/test-utf8-unmarked.zip b/thirdparty/libzip-1.11.3/regress/test-utf8-unmarked.zip new file mode 100644 index 0000000..1bcb703 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/test-utf8-unmarked.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/test-utf8.zip b/thirdparty/libzip-1.11.3/regress/test-utf8.zip new file mode 100644 index 0000000..3045e20 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/test-utf8.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/test.zip b/thirdparty/libzip-1.11.3/regress/test.zip new file mode 100644 index 0000000..e4efd71 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/test.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/test2.zip b/thirdparty/libzip-1.11.3/regress/test2.zip new file mode 100644 index 0000000..ed2f60f Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/test2.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/test_open_multiple.zip b/thirdparty/libzip-1.11.3/regress/test_open_multiple.zip new file mode 100644 index 0000000..7dc3091 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/test_open_multiple.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testbuffer.zip b/thirdparty/libzip-1.11.3/regress/testbuffer.zip new file mode 100644 index 0000000..91e7d8a Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testbuffer.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testbuffer_reopen.zip b/thirdparty/libzip-1.11.3/regress/testbuffer_reopen.zip new file mode 100644 index 0000000..a46e72b Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testbuffer_reopen.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testbzip2.zip b/thirdparty/libzip-1.11.3/regress/testbzip2.zip new file mode 100644 index 0000000..7c9a9e7 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testbzip2.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testchanged.zip b/thirdparty/libzip-1.11.3/regress/testchanged.zip new file mode 100644 index 0000000..d5169c9 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testchanged.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testchangedlocal.zip b/thirdparty/libzip-1.11.3/regress/testchangedlocal.zip new file mode 100644 index 0000000..1c8b301 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testchangedlocal.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testcomment.zip b/thirdparty/libzip-1.11.3/regress/testcomment.zip new file mode 100644 index 0000000..45dc18d Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testcomment.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testcomment13.zip b/thirdparty/libzip-1.11.3/regress/testcomment13.zip new file mode 100644 index 0000000..bd6e1c3 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testcomment13.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testcommentremoved.zip b/thirdparty/libzip-1.11.3/regress/testcommentremoved.zip new file mode 100644 index 0000000..b2e4d05 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testcommentremoved.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testdeflated.zip b/thirdparty/libzip-1.11.3/regress/testdeflated.zip new file mode 100644 index 0000000..7f6ab1c Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testdeflated.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testdeflated2.zip b/thirdparty/libzip-1.11.3/regress/testdeflated2.zip new file mode 100644 index 0000000..b5ded7d Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testdeflated2.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testdir.zip b/thirdparty/libzip-1.11.3/regress/testdir.zip new file mode 100644 index 0000000..b1e13e1 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testdir.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testempty.zip b/thirdparty/libzip-1.11.3/regress/testempty.zip new file mode 100644 index 0000000..15cb0ec Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testempty.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testextrabytes.zip b/thirdparty/libzip-1.11.3/regress/testextrabytes.zip new file mode 100644 index 0000000..f2a3fb2 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testextrabytes.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile-UTF8.zip b/thirdparty/libzip-1.11.3/regress/testfile-UTF8.zip new file mode 100644 index 0000000..7279615 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile-UTF8.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile-cp437.zip b/thirdparty/libzip-1.11.3/regress/testfile-cp437.zip new file mode 100644 index 0000000..169a903 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile-cp437.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile-ef.zip b/thirdparty/libzip-1.11.3/regress/testfile-ef.zip new file mode 100644 index 0000000..91551ff Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile-ef.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile-long-comment.zip b/thirdparty/libzip-1.11.3/regress/testfile-long-comment.zip new file mode 100644 index 0000000..112ed31 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile-long-comment.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile-lzma.zip b/thirdparty/libzip-1.11.3/regress/testfile-lzma.zip new file mode 100644 index 0000000..f855b2a Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile-lzma.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile-plus-extra.zip b/thirdparty/libzip-1.11.3/regress/testfile-plus-extra.zip new file mode 100644 index 0000000..09a6c03 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile-plus-extra.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile-stored-dos.zip b/thirdparty/libzip-1.11.3/regress/testfile-stored-dos.zip new file mode 100644 index 0000000..1adf554 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile-stored-dos.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile-torrentzip-modified.zip b/thirdparty/libzip-1.11.3/regress/testfile-torrentzip-modified.zip new file mode 100644 index 0000000..8be5136 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile-torrentzip-modified.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile-torrentzip.zip b/thirdparty/libzip-1.11.3/regress/testfile-torrentzip.zip new file mode 100644 index 0000000..bd59ad3 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile-torrentzip.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile-truncated.zip b/thirdparty/libzip-1.11.3/regress/testfile-truncated.zip new file mode 100644 index 0000000..05b0a7f Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile-truncated.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile-xz.zip b/thirdparty/libzip-1.11.3/regress/testfile-xz.zip new file mode 100644 index 0000000..6be8f9c Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile-xz.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile-zstd.zip b/thirdparty/libzip-1.11.3/regress/testfile-zstd.zip new file mode 100644 index 0000000..bf42d3e Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile-zstd.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile.txt b/thirdparty/libzip-1.11.3/regress/testfile.txt new file mode 100644 index 0000000..e69de29 diff --git a/thirdparty/libzip-1.11.3/regress/testfile.zip b/thirdparty/libzip-1.11.3/regress/testfile.zip new file mode 100644 index 0000000..2fa5ba0 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile0.zip b/thirdparty/libzip-1.11.3/regress/testfile0.zip new file mode 100644 index 0000000..5e565d1 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile0.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/testfile2014.zip b/thirdparty/libzip-1.11.3/regress/testfile2014.zip new file mode 100644 index 0000000..1d75d46 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/testfile2014.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/teststdin.zip b/thirdparty/libzip-1.11.3/regress/teststdin.zip new file mode 100644 index 0000000..e1a40a8 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/teststdin.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/teststored.zip b/thirdparty/libzip-1.11.3/regress/teststored.zip new file mode 100644 index 0000000..138c6ad Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/teststored.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/truncate_empty_keep.test b/thirdparty/libzip-1.11.3/regress/truncate_empty_keep.test new file mode 100644 index 0000000..adcf885 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/truncate_empty_keep.test @@ -0,0 +1,4 @@ +# delete last entry in zip archive +return 0 +arguments -t testfile.zzip set_archive_flag create-or-keep-file-for-empty-archive 1 +file testfile.zzip testfile.zip testempty.zip diff --git a/thirdparty/libzip-1.11.3/regress/tryopen.c b/thirdparty/libzip-1.11.3/regress/tryopen.c new file mode 100644 index 0000000..43493e3 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/tryopen.c @@ -0,0 +1,126 @@ +/* + tryopen.c -- tool for tests that try opening zip archives + Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config.h" + +#include +#include + +#ifndef HAVE_GETOPT +#include "getopt.h" +#endif + +#include "zip.h" +#define TRYOPEN_USAGE \ + "usage: %s [-cent] file\n\n" \ + "\t-c\tcheck consistency\n" \ + "\t-e\texclusively open archive\n" \ + "\t-n\tcreate new file\n" \ + "\t-s\tprint error string\n" \ + "\t-t\ttruncate file to size 0\n" + + +int +main(int argc, char *argv[]) { + const char *fname; + zip_t *z; + int c, flags, ze; + zip_int64_t count; + int error_count; + zip_error_t error; + int error_strings = 0; + + flags = 0; + + while ((c = getopt(argc, argv, "censt")) != -1) { + switch (c) { + case 'c': + flags |= ZIP_CHECKCONS; + break; + case 'e': + flags |= ZIP_EXCL; + break; + case 'n': + flags |= ZIP_CREATE; + break; + case 's': + error_strings = 1; + break; + case 't': + flags |= ZIP_TRUNCATE; + break; + + default: + fprintf(stderr, TRYOPEN_USAGE, argv[0]); + return 1; + } + } + + error_count = 0; + for (; optind < argc; optind++) { + fname = argv[optind]; + errno = 0; + + if ((z = zip_open(fname, flags, &ze)) != NULL) { + count = zip_get_num_entries(z, 0); + printf("opening '%s' succeeded, %" PRIu64 " entries\n", fname, count); + zip_close(z); + continue; + } + + zip_error_init_with_code(&error, ze); + printf("opening '%s' returned error ", fname); + if (error_strings) { + printf("%s", zip_error_strerror(&error)); + } + else { + printf("%d", ze); + switch (zip_error_system_type(&error)) { + case ZIP_ET_SYS: + case ZIP_ET_LIBZIP: + printf("/%d", zip_error_code_system(&error)); + break; + + default: + break; + } + } + printf("\n"); + error_count++; + } + + if (error_count > 0) + fprintf(stderr, "%d errors\n", error_count); + + return error_count ? 1 : 0; +} diff --git a/thirdparty/libzip-1.11.3/regress/unchange-delete-namelocate.test b/thirdparty/libzip-1.11.3/regress/unchange-delete-namelocate.test new file mode 100644 index 0000000..459d9b5 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/unchange-delete-namelocate.test @@ -0,0 +1,7 @@ +# namelocate after a file has been deleted and unchanged should succeed. +arguments test2.zip delete 0 unchange 0 name_locate testfile.txt 0 +return 0 +file test2.zip test2.zip +stdout +name 'testfile.txt' using flags '0' found at index 0 +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/utf-8-standardization-input.zip b/thirdparty/libzip-1.11.3/regress/utf-8-standardization-input.zip new file mode 100644 index 0000000..67e3acf Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/utf-8-standardization-input.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/utf-8-standardization-output.zip b/thirdparty/libzip-1.11.3/regress/utf-8-standardization-output.zip new file mode 100644 index 0000000..3f7f08c Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/utf-8-standardization-output.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/utf-8-standardization.test b/thirdparty/libzip-1.11.3/regress/utf-8-standardization.test new file mode 100644 index 0000000..7f51c70 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/utf-8-standardization.test @@ -0,0 +1,4 @@ +# replace file contents and make UTF-8 name +return 0 +arguments testfile.zzip replace_file_contents 0 "Some new content for the file." set_file_mtime 0 1406885162 +file testfile.zzip utf-8-standardization-input.zip utf-8-standardization-output.zip diff --git a/thirdparty/libzip-1.11.3/regress/want_torrentzip_stat.test b/thirdparty/libzip-1.11.3/regress/want_torrentzip_stat.test new file mode 100644 index 0000000..ba35e31 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/want_torrentzip_stat.test @@ -0,0 +1,32 @@ +# check that wanting to convert a file to torrentzip changes stat information +return 0 +arguments testfile.zzip stat 0 set_archive_flag want-torrentzip 1 stat 0 unchange_all stat 0 +file testfile.zzip testfile.zip +stdout +name: 'testfile.txt' +index: '0' +size: '0' +compressed size: '0' +mtime: 'Fri Jul 15 2005 16:37:14' +crc: '0' +compression method: '0' +encryption method: '0' + +name: 'testfile.txt' +index: '0' +size: '0' +mtime: 'Tue Dec 24 1996 23:32:00' +crc: '0' +compression method: '8' +encryption method: '0' + +name: 'testfile.txt' +index: '0' +size: '0' +compressed size: '0' +mtime: 'Fri Jul 15 2005 16:37:14' +crc: '0' +compression method: '0' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/zip-in-archive-comment.test b/thirdparty/libzip-1.11.3/regress/zip-in-archive-comment.test new file mode 100644 index 0000000..53620da --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/zip-in-archive-comment.test @@ -0,0 +1,15 @@ +# stat file in zip that contains archive comment to find out if it detected the right one of the two +arguments zip-in-archive-comment.zip stat 0 +file zip-in-archive-comment.zip zip-in-archive-comment.zip +return 0 +stdout +name: 'test' +index: '0' +size: '5' +compressed size: '5' +mtime: 'Mon Oct 06 2003 15:46:42' +crc: '3bb935c6' +compression method: '0' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/zip-in-archive-comment.zip b/thirdparty/libzip-1.11.3/regress/zip-in-archive-comment.zip new file mode 100644 index 0000000..3bd0b6a Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/zip-in-archive-comment.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/zip64-3mf.zip b/thirdparty/libzip-1.11.3/regress/zip64-3mf.zip new file mode 100644 index 0000000..a2ccf24 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/zip64-3mf.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/zip64-in-archive-comment.test b/thirdparty/libzip-1.11.3/regress/zip64-in-archive-comment.test new file mode 100644 index 0000000..4860a15 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/zip64-in-archive-comment.test @@ -0,0 +1,15 @@ +# stat file in zip that contains archive comment to find out if it detected the right one of the two +arguments zip64-in-archive-comment.zip stat 0 +file zip64-in-archive-comment.zip zip64-in-archive-comment.zip +return 0 +stdout +name: 'testfile.txt' +index: '0' +size: '0' +compressed size: '0' +mtime: 'Fri Jul 15 2005 16:37:14' +crc: '0' +compression method: '0' +encryption method: '0' + +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/zip64-in-archive-comment.zip b/thirdparty/libzip-1.11.3/regress/zip64-in-archive-comment.zip new file mode 100644 index 0000000..20a412b Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/zip64-in-archive-comment.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/zip64.zip b/thirdparty/libzip-1.11.3/regress/zip64.zip new file mode 100644 index 0000000..c1ba76b Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/zip64.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/zip64_creation.test b/thirdparty/libzip-1.11.3/regress/zip64_creation.test new file mode 100644 index 0000000..8b91e92 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/zip64_creation.test @@ -0,0 +1,4 @@ +# create big zip64 zip file from scratch +arguments bigzero.zip add_nul bigzero 4294967296 +file bigzero.zip {} bigzero.zip +return 0 diff --git a/thirdparty/libzip-1.11.3/regress/zip64_stored_creation.test b/thirdparty/libzip-1.11.3/regress/zip64_stored_creation.test new file mode 100644 index 0000000..eccae6c --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/zip64_stored_creation.test @@ -0,0 +1,4 @@ +# create big zip64 zip file from scratch +arguments -H bigstored.zh add_nul bigzero 4294967296 set_file_compression 0 0 0 set_file_mtime 0 0 add_nul smallzero 16384 set_file_compression 1 0 0 set_file_mtime 1 0 +file bigstored.zh {} bigstored.zh +return 0 diff --git a/thirdparty/libzip-1.11.3/regress/zipcmp_zip_dir.test b/thirdparty/libzip-1.11.3/regress/zipcmp_zip_dir.test new file mode 100644 index 0000000..e1be263 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/zipcmp_zip_dir.test @@ -0,0 +1,17 @@ +# compare zip with directory +features HAVE_FTS_H +program zipcmp +mkdir a +mkdir a/dir-with-file +mkdir a/empty-dir-in-dir +arguments zipcmp_zip_dir.zip a +file zipcmp_zip_dir.zip zipcmp_zip_dir.zip +return 1 +stdout +--- zipcmp_zip_dir.zip ++++ a +- directory '00-empty-dir/' +- file 'dir-with-file/a', size 1, crc e8b7be43, mtime 1610623116 ++ directory 'empty-dir-in-dir/' +- directory 'empty-dir/' +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/zipcmp_zip_dir.zip b/thirdparty/libzip-1.11.3/regress/zipcmp_zip_dir.zip new file mode 100644 index 0000000..8f47f21 Binary files /dev/null and b/thirdparty/libzip-1.11.3/regress/zipcmp_zip_dir.zip differ diff --git a/thirdparty/libzip-1.11.3/regress/zipcmp_zip_dir_slash.test b/thirdparty/libzip-1.11.3/regress/zipcmp_zip_dir_slash.test new file mode 100644 index 0000000..1191e4f --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/zipcmp_zip_dir_slash.test @@ -0,0 +1,17 @@ +# compare zip with directory with trailing slash +features HAVE_FTS_H +program zipcmp +mkdir a +mkdir a/dir-with-file +mkdir a/empty-dir-in-dir +arguments zipcmp_zip_dir.zip a/ +file zipcmp_zip_dir.zip zipcmp_zip_dir.zip +return 1 +stdout +--- zipcmp_zip_dir.zip ++++ a/ +- directory '00-empty-dir/' +- file 'dir-with-file/a', size 1, crc e8b7be43, mtime 1610623116 ++ directory 'empty-dir-in-dir/' +- directory 'empty-dir/' +end-of-inline-data diff --git a/thirdparty/libzip-1.11.3/regress/ziptool_regress.c b/thirdparty/libzip-1.11.3/regress/ziptool_regress.c new file mode 100644 index 0000000..1cfd292 --- /dev/null +++ b/thirdparty/libzip-1.11.3/regress/ziptool_regress.c @@ -0,0 +1,661 @@ +#include "zip.h" + +#include + +#define ZIP_MIN(a, b) ((a) < (b) ? (a) : (b)) + +#define FOR_REGRESS + +typedef enum { SOURCE_TYPE_NONE, SOURCE_TYPE_IN_MEMORY, SOURCE_TYPE_HOLE } source_type_t; + +source_type_t source_type = SOURCE_TYPE_NONE; +zip_uint64_t fragment_size = 0; +zip_file_t *z_files[16]; +unsigned int z_files_count; +int commands_from_stdin = 0; + +static int add_nul(char *argv[]); +static int cancel(char *argv[]); +static int extract_as(char *argv[]); +static int regress_fopen(char *argv[]); +static int regress_fread(char *argv[]); +static int regress_fseek(char *argv[]); +static int is_seekable(char *argv[]); +static int unchange_one(char *argv[]); +static int unchange_all(char *argv[]); +static int zin_close(char *argv[]); + +#define OPTIONS_REGRESS "F:Himx" + +#define USAGE_REGRESS " [-Himx] [-F fragment-size]" + +#define GETOPT_REGRESS \ + case 'H': \ + source_type = SOURCE_TYPE_HOLE; \ + break; \ + case 'i': \ + commands_from_stdin = 1; \ + break; \ + case 'm': \ + source_type = SOURCE_TYPE_IN_MEMORY; \ + break; \ + case 'F': \ + fragment_size = strtoull(optarg, NULL, 10); \ + break; \ + case 'x': \ + hex_encoded_filenames = 1; \ + break; + +/* clang-format off */ + +#define DISPATCH_REGRESS \ + {"add_nul", 2, "name length", "add NUL bytes", add_nul}, \ + {"cancel", 1, "limit", "cancel writing archive when limit% have been written (calls print_progress)", cancel}, \ + {"extract_as", 2, "index name", "extract file data to given file name", extract_as}, \ + {"fopen", 1, "name", "open archive entry", regress_fopen}, \ + {"fread", 2, "file_index length", "read from fopened file and print", regress_fread}, \ + {"fseek", 3, "file_index offset whence", "seek in fopened file", regress_fseek}, \ + {"is_seekable", 1, "index", "report if entry is seekable", is_seekable}, \ + {"unchange", 1, "index", "revert changes for entry", unchange_one}, \ + {"unchange_all", 0, "", "revert all changes", unchange_all}, \ + {"zin_close", 1, "index", "close input zip_source (for internal tests)", zin_close} + +#define PRECLOSE_REGRESS \ + do { \ + unsigned int file_idx = 0; \ + for (file_idx = 0; file_idx < z_files_count; ++file_idx) { \ + if (zip_fclose (z_files[file_idx]) != 0) { \ + err = 1; \ + } \ + } \ + } \ + while (0) + +/* clang-format on */ + +#define MAX_STDIN_ARGC 128 +#define MAX_STDIN_LENGTH 8192 + +char* stdin_argv[MAX_STDIN_ARGC]; +static char stdin_line[MAX_STDIN_LENGTH]; + +int get_stdin_commands(void); + +#define REGRESS_PREPARE_ARGS \ + if (commands_from_stdin) { \ + argc = get_stdin_commands(); \ + arg = 0; \ + argv = stdin_argv; \ + } + +zip_t *ziptool_open(const char *archive, int flags, zip_error_t *error, zip_uint64_t offset, zip_uint64_t len); + + +#include "ziptool.c" + +int get_stdin_commands(void) { + int argc = 0; + char *p, *word; + fgets(stdin_line, sizeof(stdin_line), stdin); + word = p = stdin_line; + while (1) { + if (*p == ' ' || *p == '\n') { + *p = '\0'; + if (word[0] != '\0') { + stdin_argv[argc] = word; + argc += 1; + if (argc >= MAX_STDIN_ARGC) { + break; + } + } + word = p + 1; + } + else if (*p == '\0') { + if (word[0] != '\0') { + stdin_argv[argc] = word; + argc += 1; + } + break; + } + p += 1; + } + return argc; +} + +zip_source_t *memory_src = NULL; + +static int get_whence(const char *str); +zip_source_t *source_hole_create(const char *, int flags, zip_error_t *); +static zip_t *read_to_memory(const char *archive, int flags, zip_error_t *error, zip_source_t **srcp); +static zip_source_t *source_nul(zip_t *za, zip_uint64_t length); + + +static int +add_nul(char *argv[]) { + zip_source_t *zs; + zip_uint64_t length = strtoull(argv[1], NULL, 10); + + if ((zs = source_nul(za, length)) == NULL) { + fprintf(stderr, "can't create zip_source for length: %s\n", zip_strerror(za)); + return -1; + } + + if (zip_file_add(za, argv[0], zs, 0) == -1) { + zip_source_free(zs); + fprintf(stderr, "can't add file '%s': %s\n", argv[0], zip_strerror(za)); + return -1; + } + return 0; +} + +static int +cancel_callback(zip_t *archive, void *ud) { + if (progress_userdata.percentage >= progress_userdata.limit) { + return -1; + } + return 0; +} + +static int +cancel(char *argv[]) { + zip_int64_t percent; + percent = strtoll(argv[0], NULL, 10); + if (percent > 100 || percent < 0) { + fprintf(stderr, "invalid percentage '%" PRId64 "' for cancel (valid: 0 <= x <= 100)\n", percent); + return -1; + } + progress_userdata.limit = ((double)percent) / 100; + + zip_register_cancel_callback_with_state(za, cancel_callback, NULL, NULL); + + /* needs the percentage updates from print_progress */ + print_progress(argv); + return 0; +} + +static int +extract_as(char *argv[]) { + zip_uint64_t idx; + FILE *fp; + int ret; + + idx = strtoull(argv[0], NULL, 10); + if ((fp=fopen(argv[1], "wb")) == NULL) { + fprintf(stderr, "can't open output file '%s': %s", argv[1], strerror(errno)); + return -1; + } + ret = cat_impl_backend(idx, 0, -1, fp); + if (fclose(fp) != 0) { + fprintf(stderr, "can't close output file '%s': %s", argv[1], strerror(errno)); + ret = -1; + } + return ret; +} + + +static int +is_seekable(char *argv[]) { + zip_uint64_t idx; + zip_file_t *zf; + + idx = strtoull(argv[0], NULL, 10); + if ((zf = zip_fopen_index(za, idx, 0)) == NULL) { + fprintf(stderr, "can't open file at index '%" PRIu64 "': %s\n", idx, zip_strerror(za)); + return -1; + } + switch (zip_file_is_seekable(zf)) { + case -1: + fprintf(stderr, "can't check if file %" PRIu64 " is seekable: %s\n", idx, zip_strerror(za)); + return -1; + case 0: + printf("%" PRIu64 ": NOT seekable\n", idx); + break; + case 1: + printf("%" PRIu64 ": seekable\n", idx); + break; + } + return 0; +} + +static int +regress_fseek(char *argv[]) { + zip_uint64_t file_idx; + zip_file_t *zf; + zip_int64_t offset; + int whence; + + file_idx = strtoull(argv[0], NULL, 10); + offset = strtoll(argv[1], NULL, 10); + whence = get_whence(argv[2]); + if (file_idx >= z_files_count || z_files[file_idx] == NULL) { + fprintf(stderr, "trying to seek in invalid opened file\n"); + return -1; + } + zf = z_files[file_idx]; + + if (zip_fseek(zf, offset, whence) == -1) { + fprintf(stderr, "can't seek in file %" PRIu64 ": %s\n", file_idx, zip_strerror(za)); + return -1; + } + return 0; +} + +static int +unchange_all(char *argv[]) { + if (zip_unchange_all(za) < 0) { + fprintf(stderr, "can't revert changes to archive: %s\n", zip_strerror(za)); + return -1; + } + return 0; +} + + +static int +unchange_one(char *argv[]) { + zip_uint64_t idx; + + idx = strtoull(argv[0], NULL, 10); + + if (zip_unchange(za, idx) < 0) { + fprintf(stderr, "can't revert changes for entry %" PRIu64 ": %s", idx, zip_strerror(za)); + return -1; + } + + return 0; +} + +static int +zin_close(char *argv[]) { + zip_uint64_t idx; + + idx = strtoull(argv[0], NULL, 10); + if (idx >= z_in_count) { + fprintf(stderr, "invalid argument '%" PRIu64 "', only %u zip sources open\n", idx, z_in_count); + return -1; + } + if (zip_close(z_in[idx]) < 0) { + fprintf(stderr, "can't close source archive: %s\n", zip_strerror(z_in[idx])); + return -1; + } + z_in[idx] = z_in[z_in_count]; + z_in_count--; + + return 0; +} + +static int +regress_fopen(char *argv[]) { + if (z_files_count >= (sizeof(z_files) / sizeof(*z_files))) { + fprintf(stderr, "too many open files\n"); + return -1; + } + if ((z_files[z_files_count] = zip_fopen(za, argv[0], 0)) == NULL) { + fprintf(stderr, "can't open entry '%s' from input archive: %s\n", argv[0], zip_strerror(za)); + return -1; + } + printf("opened '%s' as file %u\n", argv[0], z_files_count); + z_files_count += 1; + return 0; +} + + +static int +regress_fread(char *argv[]) { + zip_uint64_t file_idx; + zip_uint64_t length; + char buf[8192]; + zip_int64_t n; + zip_file_t *f; + + file_idx = strtoull(argv[0], NULL, 10); + length = strtoull(argv[1], NULL, 10); + + if (file_idx >= z_files_count || z_files[file_idx] == NULL) { + fprintf(stderr, "trying to read from invalid opened file\n"); + return -1; + } + f = z_files[file_idx]; + while (length > 0) { + zip_uint64_t to_read; + + if (length > sizeof (buf)) { + to_read = sizeof (buf); + } else { + to_read = length; + } + n = zip_fread(f, buf, to_read); + if (n < 0) { + fprintf(stderr, "can't read opened file %" PRIu64 ": %s\n", file_idx, zip_file_strerror(f)); + return -1; + } + if (n == 0) { +#if 0 + fprintf(stderr, "premature end of opened file %" PRIu64 "\n", file_idx); + return -1; +#else + break; +#endif + } + if (fwrite(buf, (size_t)n, 1, stdout) != 1) { + fprintf(stderr, "can't write file contents to stdout: %s\n", strerror(errno)); + return -1; + } + length -= n; + } + return 0; +} + + +static zip_t * +read_hole(const char *archive, int flags, zip_error_t *error) { + zip_source_t *src = NULL; + zip_t *zs = NULL; + + if (strcmp(archive, "/dev/stdin") == 0) { + zip_error_set(error, ZIP_ER_OPNOTSUPP, 0); + return NULL; + } + + if ((src = source_hole_create(archive, flags, error)) == NULL || (zs = zip_open_from_source(src, flags, error)) == NULL) { + zip_source_free(src); + } + + return zs; +} + + +static int get_whence(const char *str) { + if (strcasecmp(str, "set") == 0) { + return SEEK_SET; + } + else if (strcasecmp(str, "cur") == 0) { + return SEEK_CUR; + } + else if (strcasecmp(str, "end") == 0) { + return SEEK_END; + } + else { + return 100; /* invalid */ + } +} + + +static zip_t * +read_to_memory(const char *archive, int flags, zip_error_t *error, zip_source_t **srcp) { + zip_source_t *src; + zip_t *zb; + FILE *fp; + + if (strcmp(archive, "/dev/stdin") == 0) { + zip_error_set(error, ZIP_ER_OPNOTSUPP, 0); + return NULL; + } + + if ((fp = fopen(archive, "rb")) == NULL) { + if (errno == ENOENT) { + src = zip_source_buffer_create(NULL, 0, 0, error); + } + else { + zip_error_set(error, ZIP_ER_OPEN, errno); + return NULL; + } + } + else { + struct stat st; + + if (fstat(fileno(fp), &st) < 0) { + fclose(fp); + zip_error_set(error, ZIP_ER_OPEN, errno); + return NULL; + } + if (fragment_size == 0) { + char *buf; + if ((buf = malloc((size_t)st.st_size)) == NULL) { + fclose(fp); + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + if (fread(buf, (size_t)st.st_size, 1, fp) < 1) { + free(buf); + fclose(fp); + zip_error_set(error, ZIP_ER_READ, errno); + return NULL; + } + src = zip_source_buffer_create(buf, (zip_uint64_t)st.st_size, 1, error); + if (src == NULL) { + free(buf); + } + } + else { + zip_uint64_t nfragments, i, left; + zip_buffer_fragment_t *fragments; + + nfragments = ((size_t)st.st_size + fragment_size - 1) / fragment_size; + if ((fragments = malloc(sizeof(fragments[0]) * nfragments)) == NULL) { + fclose(fp); + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + for (i = 0; i < nfragments; i++) { + left = ZIP_MIN(fragment_size, (size_t)st.st_size - i * fragment_size); + if ((fragments[i].data = malloc(left)) == NULL) { +#ifndef __clang_analyzer__ + /* fragments is initialized up to i - 1*/ + while (--i > 0) { + free(fragments[i].data); + } +#endif + free(fragments); + fclose(fp); + zip_error_set(error, ZIP_ER_MEMORY, 0); + return NULL; + } + fragments[i].length = left; + if (fread(fragments[i].data, left, 1, fp) < 1) { +#ifndef __clang_analyzer__ + /* fragments is initialized up to i - 1*/ + while (--i > 0) { + free(fragments[i].data); + } +#endif + free(fragments); + fclose(fp); + zip_error_set(error, ZIP_ER_READ, errno); + return NULL; + } + } + src = zip_source_buffer_fragment_create(fragments, nfragments, 1, error); + if (src == NULL) { + for (i = 0; i < nfragments; i++) { + free(fragments[i].data); + } + free(fragments); + fclose(fp); + return NULL; + } + free(fragments); + } + fclose(fp); + } + if (src == NULL) { + return NULL; + } + zb = zip_open_from_source(src, flags, error); + if (zb == NULL) { + zip_source_free(src); + return NULL; + } + zip_source_keep(src); + *srcp = src; + return zb; +} + + +typedef struct source_nul { + zip_error_t error; + zip_uint64_t length; + zip_uint64_t offset; +} source_nul_t; + +static zip_int64_t +source_nul_cb(void *ud, void *data, zip_uint64_t length, zip_source_cmd_t command) { + source_nul_t *ctx = (source_nul_t *)ud; + + switch (command) { + case ZIP_SOURCE_CLOSE: + return 0; + + case ZIP_SOURCE_ERROR: + return zip_error_to_data(&ctx->error, data, length); + + case ZIP_SOURCE_FREE: + free(ctx); + return 0; + + case ZIP_SOURCE_OPEN: + ctx->offset = 0; + return 0; + + case ZIP_SOURCE_READ: + if (length > ZIP_INT64_MAX) { + zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); + return -1; + } + + if (length > ctx->length - ctx->offset) { + length = ctx->length - ctx->offset; + } + + memset(data, 0, length); + ctx->offset += length; + return (zip_int64_t)length; + + case ZIP_SOURCE_STAT: { + zip_stat_t *st = ZIP_SOURCE_GET_ARGS(zip_stat_t, data, length, &ctx->error); + + if (st == NULL) { + return -1; + } + + st->valid |= ZIP_STAT_SIZE; + st->size = ctx->length; + + return 0; + } + + case ZIP_SOURCE_SUPPORTS: + return zip_source_make_command_bitmap(ZIP_SOURCE_CLOSE, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_STAT, -1); + + default: + zip_error_set(&ctx->error, ZIP_ER_OPNOTSUPP, 0); + return -1; + } +} + +static zip_source_t * +source_nul(zip_t *zs, zip_uint64_t length) { + source_nul_t *ctx; + zip_source_t *src; + + if ((ctx = (source_nul_t *)malloc(sizeof(*ctx))) == NULL) { + zip_error_set(zip_get_error(zs), ZIP_ER_MEMORY, 0); + return NULL; + } + + zip_error_init(&ctx->error); + ctx->length = length; + ctx->offset = 0; + + if ((src = zip_source_function(zs, source_nul_cb, ctx)) == NULL) { + free(ctx); + return NULL; + } + + return src; +} + + +static int +write_memory_src_to_file(const char *archive, zip_source_t *src) { + zip_stat_t zst; + char *buf; + FILE *fp; + + if (zip_source_stat(src, &zst) < 0) { + fprintf(stderr, "zip_source_stat on buffer failed: %s\n", zip_error_strerror(zip_source_error(src))); + return -1; + } + if (zip_source_open(src) < 0) { + if (zip_error_code_zip(zip_source_error(src)) == ZIP_ER_DELETED) { + if (unlink(archive) < 0 && errno != ENOENT) { + fprintf(stderr, "unlink failed: %s\n", strerror(errno)); + return -1; + } + return 0; + } + fprintf(stderr, "zip_source_open on buffer failed: %s\n", zip_error_strerror(zip_source_error(src))); + return -1; + } + if ((buf = malloc(zst.size)) == NULL) { + fprintf(stderr, "malloc failed: %s\n", strerror(errno)); + zip_source_close(src); + return -1; + } + if (zip_source_read(src, buf, zst.size) < (zip_int64_t)zst.size) { + fprintf(stderr, "zip_source_read on buffer failed: %s\n", zip_error_strerror(zip_source_error(src))); + zip_source_close(src); + free(buf); + return -1; + } + zip_source_close(src); + if ((fp = fopen(archive, "wb")) == NULL) { + fprintf(stderr, "fopen failed: %s\n", strerror(errno)); + free(buf); + return -1; + } + if (fwrite(buf, zst.size, 1, fp) < 1) { + fprintf(stderr, "fwrite failed: %s\n", strerror(errno)); + free(buf); + fclose(fp); + return -1; + } + free(buf); + if (fclose(fp) != 0) { + fprintf(stderr, "fclose failed: %s\n", strerror(errno)); + return -1; + } + return 0; +} + + +zip_t * +ziptool_open(const char *archive, int flags, zip_error_t *error, zip_uint64_t offset, zip_uint64_t len) { + switch (source_type) { + case SOURCE_TYPE_NONE: + za = read_from_file(archive, flags, error, offset, len); + break; + + case SOURCE_TYPE_IN_MEMORY: + za = read_to_memory(archive, flags, error, &memory_src); + break; + + case SOURCE_TYPE_HOLE: + za = read_hole(archive, flags, error); + break; + } + + return za; +} + + +int +ziptool_post_close(const char *archive) { + if (source_type == SOURCE_TYPE_IN_MEMORY) { + if (write_memory_src_to_file(archive, memory_src) < 0) { + return -1; + } + zip_source_free(memory_src); + } + + return 0; +} diff --git a/thirdparty/libzip-1.11.3/src/CMakeLists.txt b/thirdparty/libzip-1.11.3/src/CMakeLists.txt new file mode 100644 index 0000000..a0f5325 --- /dev/null +++ b/thirdparty/libzip-1.11.3/src/CMakeLists.txt @@ -0,0 +1,14 @@ +check_function_exists(getopt HAVE_GETOPT) +foreach(PROGRAM zipcmp zipmerge ziptool) + add_executable(${PROGRAM} ${PROGRAM}.c) + target_link_libraries(${PROGRAM} zip) + target_include_directories(${PROGRAM} PRIVATE BEFORE ${PROJECT_SOURCE_DIR}/lib ${PROJECT_BINARY_DIR}) + if(LIBZIP_DO_INSTALL) + install(TARGETS ${PROGRAM} EXPORT ${PROJECT_NAME}-targets DESTINATION bin) + endif() + if(NOT HAVE_GETOPT) + target_sources(${PROGRAM} PRIVATE getopt.c) + endif(NOT HAVE_GETOPT) +endforeach() +target_sources(zipcmp PRIVATE diff_output.c) +target_link_libraries(zipcmp ${FTS_LIB} ZLIB::ZLIB) diff --git a/thirdparty/libzip-1.11.3/src/diff_output.c b/thirdparty/libzip-1.11.3/src/diff_output.c new file mode 100644 index 0000000..003b5e1 --- /dev/null +++ b/thirdparty/libzip-1.11.3/src/diff_output.c @@ -0,0 +1,115 @@ +#include "diff_output.h" + +#include +#include +#include +#include + +#include "compat.h" + +static void +ensure_header(diff_output_t *output) { + if (output->archive_names[0] != NULL) { + printf("--- %s\n", output->archive_names[0]); + printf("+++ %s\n", output->archive_names[1]); + output->archive_names[0] = NULL; + output->archive_names[1] = NULL; + } +} + +void +diff_output_init(diff_output_t *output, int verbose, char *const archive_names[]) { + output->archive_names[0] = archive_names[0]; + output->archive_names[1] = archive_names[1]; + output->verbose = verbose; + output->file_name = NULL; + output->file_size = 0; + output->file_crc = 0; + output->file_mtime = 0; +} + +void +diff_output_start_file(diff_output_t *output, const char *name, zip_uint64_t size, zip_uint32_t crc, zip_uint64_t mtime) { + output->file_name = name; + output->file_size = size; + output->file_crc = crc; + output->file_mtime = mtime; +} + +void +diff_output_end_file(diff_output_t *output) { + output->file_name = NULL; +} + +void +diff_output(diff_output_t *output, int side, const char *fmt, ...) { + va_list ap; + + if (!output->verbose) { + return; + } + + ensure_header(output); + + if (output->file_name != NULL) { + diff_output_file(output, ' ', output->file_name, output->file_size, output->file_crc, output->file_mtime); + output->file_name = NULL; + } + + printf("%c ", side); + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); + printf("\n"); +} + +void +diff_output_file(diff_output_t *output, char side, const char *name, zip_uint64_t size, zip_uint32_t crc, zip_uint64_t mtime) { + if (!output->verbose) { + return; + } + + ensure_header(output); + + if (size == 0 && crc == 0 && name[0] != '\0' && name[strlen(name) - 1] == '/') { + printf("%c directory '%s'\n", side, name); + } + else { + printf("%c file '%s', size %" PRIu64 ", crc %08x, mtime %" PRIu64 "\n", side, name, size, crc, mtime); + } +} + +#define MAX_BYTES 64 +void +diff_output_data(diff_output_t *output, int side, const zip_uint8_t *data, zip_uint64_t data_length, const char *fmt, ...) { + char prefix[1024]; + char hexdata[MAX_BYTES * 3 + 6]; + size_t i, offset; + va_list ap; + + if (!output->verbose) { + return; + } + + offset = 0; + for (i = 0; i < data_length; i++) { + hexdata[offset++] = (i == 0 ? '<' : ' '); + + if (i >= MAX_BYTES) { + snprintf(hexdata + offset, sizeof(hexdata) - offset, "..."); + break; + } + snprintf(hexdata + offset, sizeof(hexdata) - offset, "%02x", data[i]); + offset += 2; + } + + hexdata[offset++] = '>'; + hexdata[offset] = '\0'; + + va_start(ap, fmt); + vsnprintf(prefix, sizeof(prefix), fmt, ap); + va_end(ap); + prefix[sizeof(prefix) - 1] = '\0'; + + diff_output(output, side, "%s, length %" PRIu64 ", data %s", prefix, data_length, hexdata); +} diff --git a/thirdparty/libzip-1.11.3/src/diff_output.h b/thirdparty/libzip-1.11.3/src/diff_output.h new file mode 100644 index 0000000..f04f931 --- /dev/null +++ b/thirdparty/libzip-1.11.3/src/diff_output.h @@ -0,0 +1,29 @@ +#ifndef HAD_DIFF_OUTPUT_H +#define HAD_DIFF_OUTPUT_H + +#include + +typedef struct { + const char *archive_names[2]; + const char *file_name; + zip_uint64_t file_size; + zip_uint32_t file_crc; + zip_uint64_t file_mtime; + int verbose; +} diff_output_t; + +#if defined(__GNUC__) && __GNUC__ >= 4 +#define PRINTF_LIKE(n, m) __attribute__((__format__(__printf__, n, m))) +#else +#define PRINTF_LIKE(n, m) +#endif + +void diff_output_init(diff_output_t *output, int verbose, char *const archive_names[]); +void diff_output_start_file(diff_output_t *output, const char *name, zip_uint64_t size, zip_uint32_t crc, zip_uint64_t mtime); +void diff_output_end_file(diff_output_t *output); + +void diff_output(diff_output_t *output, int side, const char *fmt, ...) PRINTF_LIKE(3, 4); +void diff_output_data(diff_output_t *output, int side, const zip_uint8_t *data, zip_uint64_t data_length, const char *fmt, ...) PRINTF_LIKE(5, 6); +void diff_output_file(diff_output_t *output, char side, const char *name, zip_uint64_t size, zip_uint32_t crc, zip_uint64_t mtime); + +#endif /* HAD_DIFF_OUTPUT_H */ diff --git a/thirdparty/libzip-1.11.3/src/getopt.c b/thirdparty/libzip-1.11.3/src/getopt.c new file mode 100644 index 0000000..a9879c4 --- /dev/null +++ b/thirdparty/libzip-1.11.3/src/getopt.c @@ -0,0 +1,110 @@ +/* + * getopt.c -- + * + * Standard UNIX getopt function. Code is from BSD. + * + * Copyright (c) 1987-2002 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * A. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * B. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * C. Neither the names of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS + * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* #if !defined(lint) + * static char sccsid[] = "@(#)getopt.c 8.2 (Berkeley) 4/2/94"; + * #endif + */ +#include +#include +#include + +#include "getopt.h" + +int opterr = 1, /* if error message should be printed */ + optind = 1, /* index into parent argv vector */ + optopt, /* character checked for validity */ + optreset; /* reset getopt */ +char *optarg; /* argument associated with option */ + +#define BADCH (int)'?' +#define BADARG (int)':' +#define EMSG "" + +/* + * getopt -- + * Parse argc/argv argument vector. + */ +int +getopt(int nargc, char *const *nargv, const char *ostr) { + static char *place = EMSG; /* option letter processing */ + char *oli; /* option letter list index */ + + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = EMSG; + return (EOF); + } + if (place[1] && *++place == '-') { /* found "--" */ + ++optind; + place = EMSG; + return (EOF); + } + } /* option letter okay? */ + if ((optopt = (int)*place++) == (int)':' || !(oli = (char *)strchr(ostr, optopt))) { + /* + * if the user didn't specify '-' as an option, + * assume it means EOF. + */ + if (optopt == (int)'-') + return (EOF); + if (!*place) + ++optind; + if (opterr && *ostr != ':') + (void)fprintf(stderr, "illegal option -- %c\n", optopt); + return (BADCH); + } + if (*++oli != ':') { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } + else { /* need an argument */ + if (*place) /* no white space */ + optarg = place; + else if (nargc <= ++optind) { /* no arg */ + place = EMSG; + if (*ostr == ':') + return (BADARG); + if (opterr) + (void)fprintf(stderr, "option requires an argument -- %c\n", optopt); + return (BADCH); + } + else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return (optopt); /* dump back option letter */ +} diff --git a/thirdparty/libzip-1.11.3/src/getopt.h b/thirdparty/libzip-1.11.3/src/getopt.h new file mode 100644 index 0000000..d225037 --- /dev/null +++ b/thirdparty/libzip-1.11.3/src/getopt.h @@ -0,0 +1,51 @@ +#ifndef _HAD_GETOPT_H +#define _HAD_GETOPT_H + +/* + getopt.h -- header for getopt() replacement function + Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +extern char *optarg; +extern int optind; +extern int opterr; + +extern int getopt(int, char *const *, const char *); + +#ifdef __cplusplus +} +#endif + +#endif /* _HAD_GETOPT_H */ diff --git a/thirdparty/libzip-1.11.3/src/zipcmp.c b/thirdparty/libzip-1.11.3/src/zipcmp.c new file mode 100644 index 0000000..536e9b2 --- /dev/null +++ b/thirdparty/libzip-1.11.3/src/zipcmp.c @@ -0,0 +1,892 @@ +/* + zipcmp.c -- compare zip files + Copyright (C) 2003-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "config.h" + +#include +#include +#include +#include +#include +#ifdef HAVE_STRINGS_H +#include +#endif +#ifdef HAVE_FTS_H +#include +#endif +#include + +#ifndef HAVE_GETOPT +#include "getopt.h" +#endif + +#include "zip.h" + +#include "compat.h" + +#include "diff_output.h" + +struct archive { + const char *name; + zip_t *za; + zip_uint64_t nentry; + struct entry *entry; + const char *comment; + size_t comment_length; +}; + +struct ef { + const char *name; + zip_uint16_t flags; + zip_uint16_t id; + zip_uint16_t size; + const zip_uint8_t *data; +}; + +struct entry { + char *name; + zip_uint64_t size; + zip_uint32_t crc; + zip_uint32_t comp_method; + time_t last_modification_time; + struct ef *extra_fields; + zip_uint16_t n_extra_fields; + const char *comment; + zip_uint32_t comment_length; +}; + + +typedef struct { + uint32_t value; + const char *const name; +} enum_map_t; + +const enum_map_t comp_methods[] = {{0, "Stored (no compression)"}, {1, "Shrunk"}, {2, "Reduced with compression factor 1"}, {3, "Reduced with compression factor 2"}, {4, "Reduced with compression factor 3"}, {5, "Reduced with compression factor 4"}, {6, "Imploded"}, {7, "Reserved for Tokenizing compression algorithm"}, {8, "Deflated"}, {9, "Enhanced Deflating using Deflate64(tm)"}, {10, "PKWARE Data Compression Library Imploding (old IBM TERSE)"}, {11, "11 (Reserved by PKWARE)"}, {12, "BZIP2"}, {13, "13 (Reserved by PKWARE)"}, {14, "LZMA (EFS)"}, {15, "15 (Reserved by PKWARE)"}, {16, "16 (Reserved by PKWARE)"}, {17, "17 (Reserved by PKWARE)"}, {18, "IBM TERSE (new)"}, {19, "IBM LZ77 z Architecture (PFS)"}, {20, "Zstandard compressed data (obsolete)"}, {93, "Zstandard compressed data"}, {95, "XZ compressed data"}, {97, "WavPack compressed data"}, {98, "PPMd version I, Rev 1"}, {99, "WinZIP AES Encryption"}, {UINT32_MAX, NULL}}; + +const enum_map_t extra_fields[] = { + /* PKWARE defined */ + {0x0001, "Zip64 extended information"}, + {0x0007, "AV Info"}, + {0x0008, "Reserved for extended language encoding data (PFS)"}, + {0x0009, "OS/2"}, + {0x000a, "NTFS"}, + {0x000c, "OpenVMS"}, + {0x000d, "UNIX"}, + {0x000e, "Reserved for file stream and fork descriptors"}, + {0x000f, "Patch Descriptor"}, + {0x0014, "PKCS#7 Store for X.509 Certificates"}, + {0x0015, "X.509 Certificate ID and Signature for individual file"}, + {0x0016, "X.509 Certificate ID for Central Directory"}, + {0x0017, "Strong Encryption Header"}, + {0x0018, "Record Management Controls"}, + {0x0019, "PKCS#7 Encryption Recipient Certificate List"}, + {0x0065, "IBM S/390 (Z390), AS/400 (I400) attributes - uncompressed"}, + {0x0066, "Reserved for IBM S/390 (Z390), AS/400 (I400) attributes - compressed"}, + {0x4690, "POSZIP 4690 (reserved)"}, + + /* Third-Party defined; see InfoZIP unzip sources proginfo/extrafld.txt */ + {0x07c8, "Info-ZIP Macintosh (old)"}, + {0x2605, "ZipIt Macintosh (first version)"}, + {0x2705, "ZipIt Macintosh 1.3.5+ (w/o full filename)"}, + {0x2805, "ZipIt Macintosh 1.3.5+"}, + {0x334d, "Info-ZIP Macintosh (new)"}, + {0x4154, "Tandem NSK"}, + {0x4341, "Acorn/SparkFS"}, + {0x4453, "Windows NT security descriptor"}, + {0x4704, "VM/CMS"}, + {0x470f, "MVS"}, + {0x4854, "Theos, old unofficial port"}, + {0x4b46, "FWKCS MD5"}, + {0x4c41, "OS/2 access control list (text ACL)"}, + {0x4d49, "Info-ZIP OpenVMS (obsolete)"}, + {0x4d63, "Macintosh SmartZIP"}, + {0x4f4c, "Xceed original location extra field"}, + {0x5356, "AOS/VS (ACL)"}, + {0x5455, "extended timestamp"}, + {0x554e, "Xceed unicode extra field"}, + {0x5855, "Info-ZIP UNIX (original)"}, + {0x6375, "Info-ZIP UTF-8 comment field"}, + {0x6542, "BeOS (BeBox, PowerMac, etc.)"}, + {0x6854, "Theos"}, + {0x7075, "Info-ZIP UTF-8 name field"}, + {0x7441, "AtheOS (AtheOS/Syllable attributes)"}, + {0x756e, "ASi UNIX"}, + {0x7855, "Info-ZIP UNIX"}, + {0x7875, "Info-ZIP UNIX 3rd generation"}, + {0x9901, "WinZIP AES encryption"}, + {0xa220, "Microsoft Open Packaging Growth Hint"}, + {0xcafe, "executable Java JAR file"}, + {0xfb4a, "SMS/QDOS"}, /* per InfoZIP extrafld.txt */ + {0xfd4a, "SMS/QDOS"}, /* per appnote.txt */ + {UINT32_MAX, NULL}}; + + +const char *progname; + +#define PROGRAM "zipcmp" + +#define USAGE "usage: %s [-" OPTIONS "] archive1 archive2\n" + +char help_head[] = PROGRAM " (" PACKAGE ") by Dieter Baron and Thomas Klausner\n\n"; + +char help[] = "\n\ + -C check archive consistencies\n\ + -h display this help message\n\ + -i compare names ignoring case distinctions\n\ + -p compare as many details as possible\n\ + -q be quiet\n\ + -s print a summary\n\ + -T compare time stamps\n\ + -t test zip files (compare file contents to checksum)\n\ + -V display version number\n\ + -v be verbose (print differences, default)\n\ +\n\ +Report bugs to .\n"; + +char version_string[] = PROGRAM " (" PACKAGE " " VERSION ")\n\ +Copyright (C) 2003-2024 Dieter Baron and Thomas Klausner\n\ +" PACKAGE " comes with ABSOLUTELY NO WARRANTY, to the extent permitted by law.\n"; + +#define OPTIONS "ChipqsTtVv" + + +#define BOTH_ARE_ZIPS(a) (a[0].za && a[1].za) + +static int comment_compare(const char *c1, size_t l1, const char *c2, size_t l2); +static int compare_list(char *const name[2], const void *list[2], const zip_uint64_t list_length[2], int element_size, int (*cmp)(const void *a, const void *b), int (*ignore)(const void *list, int last, const void *other), int (*check)(char *const name[2], const void *a, const void *b), void (*print)(char side, const void *element), void (*start_file)(const void *element)); +static int compare_zip(char *const zn[]); +static int ef_compare(char *const name[2], const struct entry *e1, const struct entry *e2); +static int ef_order(const void *a, const void *b); +static void ef_print(char side, const void *p); +static int ef_read(zip_t *za, zip_uint64_t idx, struct entry *e); +static int entry_cmp(const void *p1, const void *p2); +static int entry_ignore(const void *p1, int last, const void *o); +static int entry_paranoia_checks(char *const name[2], const void *p1, const void *p2); +static void entry_print(char side, const void *p); +static void entry_start_file(const void *p); +static const char *map_enum(const enum_map_t *map, uint32_t value); + +static int is_directory(const char *name); +#ifdef HAVE_FTS_H +static int list_directory(const char *name, struct archive *a); +#endif +static int list_zip(const char *name, struct archive *a); +static int test_file(zip_t *za, zip_uint64_t idx, const char *zipname, const char *filename, zip_uint64_t size, zip_uint32_t crc); + +int ignore_case, test_files, paranoid, verbose, have_directory, check_consistency, compare_time_stamps, summary; +int plus_count = 0, minus_count = 0; + +diff_output_t output; + + +int +main(int argc, char *const argv[]) { + int c; + + progname = argv[0]; + + ignore_case = 0; + test_files = 0; + check_consistency = 0; + compare_time_stamps = 0; + paranoid = 0; + have_directory = 0; + verbose = 1; + summary = 0; + + while ((c = getopt(argc, argv, OPTIONS)) != -1) { + switch (c) { + case 'C': + check_consistency = 1; + break; + case 'h': + fputs(help_head, stdout); + printf(USAGE, progname); + fputs(help, stdout); + exit(0); + case 'i': + ignore_case = 1; + break; + case 'p': + paranoid = 1; + break; + case 'q': + verbose = 0; + break; + case 's': + summary = 1; + break; + case 'T': + compare_time_stamps = 1; + break; + case 't': + test_files = 1; + break; + case 'V': + fputs(version_string, stdout); + exit(0); + case 'v': + verbose = 1; + break; + + default: + fprintf(stderr, USAGE, progname); + exit(2); + } + } + + if (argc != optind + 2) { + fprintf(stderr, USAGE, progname); + exit(2); + } + + exit((compare_zip(argv + optind) == 0) ? 0 : 1); +} + + +static int +compare_zip(char *const zn[]) { + struct archive a[2]; + struct entry *e[2]; + zip_uint64_t n[2]; + int i; + int res; + + for (i = 0; i < 2; i++) { + a[i].name = zn[i]; + a[i].entry = NULL; + a[i].nentry = 0; + a[i].za = NULL; + a[i].comment = NULL; + a[i].comment_length = 0; + + if (is_directory(zn[i])) { +#ifndef HAVE_FTS_H + fprintf(stderr, "%s: reading directories not supported\n", progname); + exit(2); +#else + if (list_directory(zn[i], a + i) < 0) + exit(2); + have_directory = 1; + paranoid = 0; /* paranoid checks make no sense for directories, since they compare zip metadata */ +#endif + } + else { + if (list_zip(zn[i], a + i) < 0) + exit(2); + } + if (a[i].nentry > 0) + qsort(a[i].entry, a[i].nentry, sizeof(a[i].entry[0]), entry_cmp); + } + + diff_output_init(&output, verbose, zn); + + e[0] = a[0].entry; + e[1] = a[1].entry; + n[0] = a[0].nentry; + n[1] = a[1].nentry; + res = compare_list(zn, (const void **)e, n, sizeof(e[i][0]), entry_cmp, have_directory ? entry_ignore : NULL, paranoid ? entry_paranoia_checks : NULL, entry_print, entry_start_file); + + if (paranoid) { + if (comment_compare(a[0].comment, a[0].comment_length, a[1].comment, a[1].comment_length) != 0) { + if (a[0].comment_length > 0) { + diff_output_data(&output, '-', (const zip_uint8_t *)a[0].comment, a[0].comment_length, "archive comment"); + minus_count++; + } + if (a[1].comment_length > 0) { + diff_output_data(&output, '+', (const zip_uint8_t *)a[1].comment, a[1].comment_length, "archive comment"); + plus_count++; + } + res = 1; + } + } + + for (i = 0; i < 2; i++) { + zip_uint64_t j; + + if (a[i].za) { + zip_close(a[i].za); + } + for (j = 0; j < a[i].nentry; j++) { + free(a[i].entry[j].name); + } + free(a[i].entry); + } + + if (summary) { + printf("%d files removed, %d files added\n", minus_count, plus_count); + } + + switch (res) { + case 0: + exit(0); + + case 1: + exit(1); + + default: + exit(2); + } +} + +#ifdef HAVE_FTS_H +static zip_int64_t +compute_crc(const char *fname) { + FILE *f; + uLong crc = crc32(0L, Z_NULL, 0); + size_t n; + Bytef buffer[8192]; + + + if ((f = fopen(fname, "rb")) == NULL) { + fprintf(stderr, "%s: can't open %s: %s\n", progname, fname, strerror(errno)); + return -1; + } + + while ((n = fread(buffer, 1, sizeof(buffer), f)) > 0) { + crc = crc32(crc, buffer, (unsigned int)n); + } + + if (ferror(f)) { + fprintf(stderr, "%s: read error on %s: %s\n", progname, fname, strerror(errno)); + fclose(f); + return -1; + } + + fclose(f); + + return (zip_int64_t)crc; +} +#endif + + +static int +is_directory(const char *name) { + struct stat st; + + if (stat(name, &st) < 0) + return 0; + + return S_ISDIR(st.st_mode); +} + + +#ifdef HAVE_FTS_H +static int +list_directory(const char *name, struct archive *a) { + FTS *fts; + FTSENT *ent; + zip_uint64_t nalloc; + size_t prefix_length; + size_t name_length; + char* normalized_name; + + name_length = strlen(name); + if (name_length == 0) { + fprintf(stderr, "%s: can't open directory '': invalid name\n", progname); + return -1; + } + + normalized_name = strdup(name); + + while (name_length > 0 && normalized_name[name_length-1] == '/') { + name_length -= 1; + } + normalized_name[name_length] = '\0'; + + if (name_length == 0) { + normalized_name[0] = '/'; + normalized_name[1] = '\0'; + name_length = 1; + } + + prefix_length = name_length + 1; + + char *const names[2] = {normalized_name, NULL}; + + if ((fts = fts_open(names, FTS_NOCHDIR | FTS_LOGICAL, NULL)) == NULL) { + fprintf(stderr, "%s: can't open directory '%s': %s\n", progname, name, strerror(errno)); + free(normalized_name); + return -1; + } + + nalloc = 0; + + while ((ent = fts_read(fts))) { + zip_int64_t crc; + + switch (ent->fts_info) { + case FTS_DOT: + case FTS_DP: + case FTS_DEFAULT: + case FTS_SL: + case FTS_NSOK: + break; + + case FTS_DC: + case FTS_DNR: + case FTS_ERR: + case FTS_NS: + case FTS_SLNONE: + /* TODO: error */ + fts_close(fts); + return -1; + + case FTS_D: + case FTS_F: + if (a->nentry >= nalloc) { + nalloc += 16; + if (nalloc > SIZE_MAX / sizeof(a->entry[0])) { + fprintf(stderr, "%s: malloc failure\n", progname); + exit(1); + } + a->entry = realloc(a->entry, sizeof(a->entry[0]) * nalloc); + if (a->entry == NULL) { + fprintf(stderr, "%s: malloc failure\n", progname); + exit(1); + } + } + + if (ent->fts_info == FTS_D) { + char *dir_name; + + if (ent->fts_path[prefix_length - 1] == '\0') { + break; + } + + size_t dir_name_size = strlen(ent->fts_path + prefix_length) + 2; + dir_name = malloc(dir_name_size); + if (dir_name == NULL) { + fprintf(stderr, "%s: malloc failure\n", progname); + exit(1); + } + snprintf(dir_name, dir_name_size, "%s/", ent->fts_path + prefix_length); + a->entry[a->nentry].name = dir_name; + a->entry[a->nentry].size = 0; + a->entry[a->nentry].crc = 0; + a->entry[a->nentry].last_modification_time = 0; + } + else { + a->entry[a->nentry].name = strdup(ent->fts_path + prefix_length); + a->entry[a->nentry].size = (zip_uint64_t)ent->fts_statp->st_size; + if ((crc = compute_crc(ent->fts_accpath)) < 0) { + fts_close(fts); + free(normalized_name); + return -1; + } + + a->entry[a->nentry].crc = (zip_uint32_t)crc; + a->entry[a->nentry].last_modification_time = ent->fts_statp->st_mtime; + } + a->nentry++; + break; + } + } + + if (fts_close(fts)) { + fprintf(stderr, "%s: error closing directory '%s': %s\n", progname, a->name, strerror(errno)); + free(normalized_name); + return -1; + } + + free(normalized_name); + return 0; +} +#endif + + +static int +list_zip(const char *name, struct archive *a) { + zip_t *za; + int err; + struct zip_stat st; + unsigned int i; + + if ((za = zip_open(name, check_consistency ? ZIP_CHECKCONS : 0, &err)) == NULL) { + zip_error_t error; + zip_error_init_with_code(&error, err); + fprintf(stderr, "%s: cannot open zip archive '%s': %s\n", progname, name, zip_error_strerror(&error)); + zip_error_fini(&error); + return -1; + } + + a->za = za; + a->nentry = (zip_uint64_t)zip_get_num_entries(za, 0); + + if (a->nentry == 0) + a->entry = NULL; + else { + if ((a->nentry > SIZE_MAX / sizeof(a->entry[0])) || (a->entry = (struct entry *)malloc(sizeof(a->entry[0]) * a->nentry)) == NULL) { + fprintf(stderr, "%s: malloc failure\n", progname); + exit(1); + } + + for (i = 0; i < a->nentry; i++) { + zip_stat_index(za, i, 0, &st); + a->entry[i].name = strdup(st.name); + a->entry[i].size = st.size; + a->entry[i].crc = st.crc; + if (test_files) + test_file(za, i, name, st.name, st.size, st.crc); + if (paranoid) { + a->entry[i].comp_method = st.comp_method; + ef_read(za, i, a->entry + i); + a->entry[i].comment = zip_file_get_comment(za, i, &a->entry[i].comment_length, 0); + } + else { + a->entry[i].comp_method = 0; + a->entry[i].n_extra_fields = 0; + } + a->entry[i].last_modification_time = st.mtime; + } + + if (paranoid) { + int length; + a->comment = zip_get_archive_comment(za, &length, 0); + a->comment_length = (size_t)length; + } + else { + a->comment = NULL; + a->comment_length = 0; + } + } + + return 0; +} + + +static int +comment_compare(const char *c1, size_t l1, const char *c2, size_t l2) { + if (l1 != l2) + return 1; + + if (l1 == 0) + return 0; + + if (c1 == NULL || c2 == NULL) + return c1 == c2; + + return memcmp(c1, c2, (size_t)l2); +} + + +static int +compare_list(char *const name[2], const void *list[2], const zip_uint64_t list_length[2], int element_size, int (*cmp)(const void *a, const void *b), int (*ignore)(const void *list, int last, const void *other), int (*check)(char *const name[2], const void *a, const void *b), void (*print)(char side, const void *element), void (*start_file)(const void *element)) { + unsigned int i[2]; + int j; + int diff; + +#define INC(k) (i[k]++, list[k] = ((const char *)list[k]) + element_size) +#define PRINT(k) \ + do { \ + if (ignore && ignore(list[k], i[k] >= list_length[k] - 1, i[1 - k] < list_length[1 - k] ? list[1 - k] : NULL)) { \ + break; \ + } \ + print((k) ? '+' : '-', list[k]); \ + (k) ? plus_count++ : minus_count++; \ + diff = 1; \ + } while (0) + + i[0] = i[1] = 0; + diff = 0; + while (i[0] < list_length[0] && i[1] < list_length[1]) { + int c = cmp(list[0], list[1]); + + if (c == 0) { + if (check) { + if (start_file) { + start_file(list[0]); + } + diff |= check(name, list[0], list[1]); + if (start_file) { + diff_output_end_file(&output); + } + } + INC(0); + INC(1); + } + else if (c < 0) { + PRINT(0); + INC(0); + } + else { + PRINT(1); + INC(1); + } + } + + for (j = 0; j < 2; j++) { + while (i[j] < list_length[j]) { + PRINT(j); + INC(j); + } + } + + return diff; +} + + +static int +ef_read(zip_t *za, zip_uint64_t idx, struct entry *e) { + zip_int16_t n_local, n_central; + zip_uint16_t i; + + if ((n_local = zip_file_extra_fields_count(za, idx, ZIP_FL_LOCAL)) < 0 || (n_central = zip_file_extra_fields_count(za, idx, ZIP_FL_CENTRAL)) < 0) { + return -1; + } + + e->n_extra_fields = (zip_uint16_t)(n_local + n_central); + + if ((e->extra_fields = (struct ef *)malloc(sizeof(e->extra_fields[0]) * e->n_extra_fields)) == NULL) + return -1; + + for (i = 0; i < n_local; i++) { + e->extra_fields[i].name = e->name; + e->extra_fields[i].data = zip_file_extra_field_get(za, idx, i, &e->extra_fields[i].id, &e->extra_fields[i].size, ZIP_FL_LOCAL); + if (e->extra_fields[i].data == NULL) + return -1; + e->extra_fields[i].flags = ZIP_FL_LOCAL; + } + for (; i < e->n_extra_fields; i++) { + e->extra_fields[i].name = e->name; + e->extra_fields[i].data = zip_file_extra_field_get(za, idx, (zip_uint16_t)(i - n_local), &e->extra_fields[i].id, &e->extra_fields[i].size, ZIP_FL_CENTRAL); + if (e->extra_fields[i].data == NULL) + return -1; + e->extra_fields[i].flags = ZIP_FL_CENTRAL; + } + + qsort(e->extra_fields, e->n_extra_fields, sizeof(e->extra_fields[0]), ef_order); + + return 0; +} + + +static int +ef_compare(char *const name[2], const struct entry *e1, const struct entry *e2) { + struct ef *ef[2]; + zip_uint64_t n[2]; + + ef[0] = e1->extra_fields; + ef[1] = e2->extra_fields; + n[0] = e1->n_extra_fields; + n[1] = e2->n_extra_fields; + + return compare_list(name, (const void **)ef, n, sizeof(struct ef), ef_order, NULL, NULL, ef_print, NULL); +} + + +static int +ef_order(const void *ap, const void *bp) { + const struct ef *a, *b; + + a = (struct ef *)ap; + b = (struct ef *)bp; + + if (a->flags != b->flags) + return a->flags - b->flags; + if (a->id != b->id) + return a->id - b->id; + if (a->size != b->size) + return a->size - b->size; + return memcmp(a->data, b->data, a->size); +} + + +static void +ef_print(char side, const void *p) { + const struct ef *ef = (struct ef *)p; + + diff_output_data(&output, side, ef->data, ef->size, " %s extra field %s", ef->flags == ZIP_FL_LOCAL ? "local" : "central", map_enum(extra_fields, ef->id)); +} + + +static int +entry_cmp(const void *p1, const void *p2) { + const struct entry *e1, *e2; + int c; + + e1 = (struct entry *)p1; + e2 = (struct entry *)p2; + + if ((c = (ignore_case ? strcasecmp : strcmp)(e1->name, e2->name)) != 0) + return c; + if (e1->size != e2->size) { + if (e1->size > e2->size) + return 1; + else + return -1; + } + if (e1->crc != e2->crc) { + return (int)e1->crc - (int)e2->crc; + } + if (compare_time_stamps && e1->last_modification_time != e2->last_modification_time) { + return (int)(e1->last_modification_time - e2->last_modification_time); + } + + return 0; +} + + +static int +entry_ignore(const void *p, int last, const void *o) { + const struct entry *e = (const struct entry *)p; + const struct entry *other = (const struct entry *)o; + + size_t length = strlen(e[0].name); + + if (length == 0 || e[0].name[length - 1] != '/') { + /* not a directory */ + return 0; + } + + if (other != NULL && strlen(other->name) > length && strncmp(other->name, e[0].name, length) == 0) { + /* not empty in other archive */ + return 1; + } + + if (last || (strlen(e[1].name) < length || strncmp(e[0].name, e[1].name, length) != 0)) { + /* empty in this archive */ + return 0; + } + + /* not empty in this archive */ + return 1; +} + + +static int +entry_paranoia_checks(char *const name[2], const void *p1, const void *p2) { + const struct entry *e1, *e2; + int ret; + + e1 = (struct entry *)p1; + e2 = (struct entry *)p2; + + ret = 0; + + if (e1->comp_method != e2->comp_method) { + diff_output(&output, '-', " compression method %s", map_enum(comp_methods, e1->comp_method)); + diff_output(&output, '+', " compression method %s", map_enum(comp_methods, e2->comp_method)); + ret = 1; + } + + if (ef_compare(name, e1, e2) != 0) { + ret = 1; + } + + if (comment_compare(e1->comment, e1->comment_length, e2->comment, e2->comment_length) != 0) { + diff_output_data(&output, '-', (const zip_uint8_t *)e1->comment, e1->comment_length, " comment"); + diff_output_data(&output, '+', (const zip_uint8_t *)e2->comment, e2->comment_length, " comment"); + ret = 1; + } + + return ret; +} + + +static void +entry_print(char side, const void *p) { + const struct entry *e = (struct entry *)p; + + diff_output_file(&output, side, e->name, e->size, e->crc, e->last_modification_time); +} + + +static void +entry_start_file(const void *p) { + const struct entry *e = (struct entry *)p; + + diff_output_start_file(&output, e->name, e->size, e->crc, e->last_modification_time); +} + + +static int +test_file(zip_t *za, zip_uint64_t idx, const char *zipname, const char *filename, zip_uint64_t size, zip_uint32_t crc) { + zip_file_t *zf; + char buf[8192]; + zip_uint64_t nsize; + zip_int64_t n; + zip_uint32_t ncrc; + + if ((zf = zip_fopen_index(za, idx, 0)) == NULL) { + fprintf(stderr, "%s: %s: cannot open file %s (index %" PRIu64 "): %s\n", progname, zipname, filename, idx, zip_strerror(za)); + return -1; + } + + ncrc = (zip_uint32_t)crc32(0, NULL, 0); + nsize = 0; + + while ((n = zip_fread(zf, buf, sizeof(buf))) > 0) { + nsize += (zip_uint64_t)n; + ncrc = (zip_uint32_t)crc32(ncrc, (const Bytef *)buf, (unsigned int)n); + } + + if (n < 0) { + fprintf(stderr, "%s: %s: error reading file %s (index %" PRIu64 "): %s\n", progname, zipname, filename, idx, zip_file_strerror(zf)); + zip_fclose(zf); + return -1; + } + + zip_fclose(zf); + + if (nsize != size) { + fprintf(stderr, "%s: %s: file %s (index %" PRIu64 "): unexpected length %" PRId64 " (should be %" PRId64 ")\n", progname, zipname, filename, idx, nsize, size); + return -2; + } + if (ncrc != crc) { + fprintf(stderr, "%s: %s: file %s (index %" PRIu64 "): unexpected length %x (should be %x)\n", progname, zipname, filename, idx, ncrc, crc); + return -2; + } + + return 0; +} + + +static const char * +map_enum(const enum_map_t *map, uint32_t value) { + static char unknown[16]; + size_t i = 0; + + while (map[i].value < UINT32_MAX) { + if (map[i].value == value) { + return map[i].name; + } + i++; + } + + snprintf(unknown, sizeof(unknown), "unknown (%u)", value); + unknown[sizeof(unknown) - 1] = '\0'; + + return unknown; +} diff --git a/thirdparty/libzip-1.11.3/src/zipmerge.c b/thirdparty/libzip-1.11.3/src/zipmerge.c new file mode 100644 index 0000000..d740b1a --- /dev/null +++ b/thirdparty/libzip-1.11.3/src/zipmerge.c @@ -0,0 +1,336 @@ +/* + zipmerge.c -- merge zip archives + Copyright (C) 2004-2023 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include +#include +#include +#include +#include + +#include "config.h" + +#ifndef HAVE_GETOPT +#include "getopt.h" +#endif + +#include "zip.h" + +char *progname; + +#define PROGRAM "zipmerge" + +#define USAGE "usage: %s [-DhIikSsV] target-zip zip...\n" + +char help_head[] = PROGRAM " (" PACKAGE ") by Dieter Baron and Thomas Klausner\n\n"; + +char help[] = "\n\ + -h display this help message\n\ + -V display version number\n\ + -D ignore directory component in file names\n\ + -I ignore case in file names\n\ + -i ask before overwriting files\n\ + -k don't compress when adding uncompressed files\n\ + -S don't overwrite identical files\n\ + -s overwrite identical files without asking\n\ +\n\ +Report bugs to .\n"; + +char version_string[] = PROGRAM " (" PACKAGE " " VERSION ")\n\ +Copyright (C) 2004-2023 Dieter Baron and Thomas Klausner\n\ +" PACKAGE " comes with ABSOLUTELY NO WARRANTY, to the extent permitted by law.\n"; + +#define OPTIONS "hVDiIksS" + +#define CONFIRM_ALL_YES 0x001 +#define CONFIRM_ALL_NO 0x002 +#define CONFIRM_SAME_YES 0x010 +#define CONFIRM_SAME_NO 0x020 + +int confirm; +zip_flags_t name_flags; +int keep_stored; + +static int confirm_replace(zip_t *, const char *, zip_uint64_t, zip_t *, const char *, zip_uint64_t); +static void copy_extra_fields(zip_t *destination_archive, zip_uint64_t destination_index, zip_t *source_archive, zip_uint64_t source_index, zip_flags_t flags); +static int copy_file(zip_t *destination_archive, zip_int64_t destination_index, zip_t *source_archive, zip_uint64_t source_index, const char* name); +static zip_t *merge_zip(zip_t *, const char *, const char *); + + +int +main(int argc, char *argv[]) { + zip_t *za; + zip_t **zs; + int c, err; + unsigned int i, n; + char *tname; + + progname = argv[0]; + + confirm = CONFIRM_ALL_YES; + name_flags = 0; + keep_stored = 0; + + while ((c = getopt(argc, argv, OPTIONS)) != -1) { + switch (c) { + case 'D': + name_flags |= ZIP_FL_NODIR; + break; + case 'I': + name_flags |= ZIP_FL_NOCASE; + break; + case 'i': + confirm &= ~CONFIRM_ALL_YES; + break; + case 'k': + keep_stored = 1; + break; + case 'S': + confirm &= ~CONFIRM_SAME_YES; + confirm |= CONFIRM_SAME_NO; + break; + case 's': + confirm &= ~CONFIRM_SAME_NO; + confirm |= CONFIRM_SAME_YES; + break; + + case 'h': + fputs(help_head, stdout); + printf(USAGE, progname); + fputs(help, stdout); + exit(0); + case 'V': + fputs(version_string, stdout); + exit(0); + + default: + fprintf(stderr, USAGE, progname); + exit(2); + } + } + + if (argc < optind + 2) { + fprintf(stderr, USAGE, progname); + exit(2); + } + + tname = argv[optind++]; + argv += optind; + + n = (unsigned int)(argc - optind); + if ((zs = (zip_t **)malloc(sizeof(zs[0]) * n)) == NULL) { + fprintf(stderr, "%s: out of memory\n", progname); + exit(1); + } + + if ((za = zip_open(tname, ZIP_CREATE, &err)) == NULL) { + zip_error_t error; + zip_error_init_with_code(&error, err); + fprintf(stderr, "%s: can't open zip archive '%s': %s\n", progname, tname, zip_error_strerror(&error)); + zip_error_fini(&error); + exit(1); + } + + for (i = 0; i < n; i++) { + if ((zs[i] = merge_zip(za, tname, argv[i])) == NULL) + exit(1); + } + + if (zip_close(za) < 0) { + fprintf(stderr, "%s: cannot write zip archive '%s': %s\n", progname, tname, zip_strerror(za)); + exit(1); + } + + for (i = 0; i < n; i++) + zip_close(zs[i]); + + exit(0); +} + + +static int +confirm_replace(zip_t *za, const char *tname, zip_uint64_t it, zip_t *zs, const char *sname, zip_uint64_t is) { + char line[1024]; + struct zip_stat st, ss; + + if (confirm & CONFIRM_ALL_YES) + return 1; + else if (confirm & CONFIRM_ALL_NO) + return 0; + + if (zip_stat_index(za, it, ZIP_FL_UNCHANGED, &st) < 0) { + fprintf(stderr, "%s: cannot stat file %" PRIu64 " in '%s': %s\n", progname, it, tname, zip_strerror(za)); + return -1; + } + if (zip_stat_index(zs, is, 0, &ss) < 0) { + fprintf(stderr, "%s: cannot stat file %" PRIu64 " in '%s': %s\n", progname, is, sname, zip_strerror(zs)); + return -1; + } + + if (st.size == ss.size && st.crc == ss.crc) { + if (confirm & CONFIRM_SAME_YES) + return 1; + else if (confirm & CONFIRM_SAME_NO) + return 0; + } + + printf("replace '%s' (%" PRIu64 " / %08x) in `%s'\n" + " with '%s' (%" PRIu64 " / %08x) from `%s'? ", + st.name, st.size, st.crc, tname, ss.name, ss.size, ss.crc, sname); + fflush(stdout); + + if (fgets(line, sizeof(line), stdin) == NULL) { + fprintf(stderr, "%s: read error from stdin: %s\n", progname, strerror(errno)); + return -1; + } + + if (tolower((unsigned char)line[0]) == 'y') + return 1; + + return 0; +} + + +static zip_t * +merge_zip(zip_t *za, const char *tname, const char *sname) { + zip_t *zs; + zip_int64_t ret, idx; + zip_uint64_t i; + int err; + const char *fname; + + if ((zs = zip_open(sname, 0, &err)) == NULL) { + zip_error_t error; + zip_error_init_with_code(&error, err); + fprintf(stderr, "%s: can't open zip archive '%s': %s\n", progname, sname, zip_error_strerror(&error)); + zip_error_fini(&error); + return NULL; + } + + ret = zip_get_num_entries(zs, 0); + if (ret < 0) { + fprintf(stderr, "%s: cannot get number of entries for '%s': %s\n", progname, sname, zip_strerror(za)); + return NULL; + } + for (i = 0; i < (zip_uint64_t)ret; i++) { + fname = zip_get_name(zs, i, 0); + + if ((idx = zip_name_locate(za, fname, name_flags)) >= 0) { + switch (confirm_replace(za, tname, (zip_uint64_t)idx, zs, sname, i)) { + case 0: + break; + + case 1: + if (copy_file(za, idx, zs, i, NULL) < 0) { + fprintf(stderr, "%s: cannot replace '%s' in `%s': %s\n", progname, fname, tname, zip_strerror(za)); + zip_close(zs); + return NULL; + } + break; + + case -1: + zip_close(zs); + return NULL; + + default: + fprintf(stderr, + "%s: internal error: " + "unexpected return code from confirm (%d)\n", + progname, err); + zip_close(zs); + return NULL; + } + } + else { + if (copy_file(za, -1, zs, i, fname) < 0) { + fprintf(stderr, "%s: cannot add '%s' to `%s': %s\n", progname, fname, tname, zip_strerror(za)); + zip_close(zs); + return NULL; + } + } + } + + return zs; +} + + +static int copy_file(zip_t *destination_archive, zip_int64_t destination_index, zip_t *source_archive, zip_uint64_t source_index, const char* name) { + zip_source_t *source = zip_source_zip_file(destination_archive, source_archive, source_index, ZIP_FL_COMPRESSED, 0, -1, NULL); + + if (source == NULL) { + return -1; + } + + if (destination_index >= 0) { + if (zip_file_replace(destination_archive, (zip_uint64_t)destination_index, source, 0) < 0) { + zip_source_free(source); + return -1; + } + } + else { + destination_index = zip_file_add(destination_archive, name, source, 0); + if (destination_index < 0) { + zip_source_free(source); + return -1; + } + } + + copy_extra_fields(destination_archive, (zip_uint64_t)destination_index, source_archive, source_index, ZIP_FL_CENTRAL); + copy_extra_fields(destination_archive, (zip_uint64_t)destination_index, source_archive, source_index, ZIP_FL_LOCAL); + if (keep_stored) { + zip_stat_t st; + if (zip_stat_index(source_archive, source_index, 0, &st) == 0 && (st.valid & ZIP_STAT_COMP_METHOD) && st.comp_method == ZIP_CM_STORE) { + zip_set_file_compression(destination_archive, destination_index, ZIP_CM_STORE, 0); + } + } + + return 0; +} + + +static void copy_extra_fields(zip_t *destination_archive, zip_uint64_t destination_index, zip_t *source_archive, zip_uint64_t source_index, zip_flags_t flags) { + zip_int16_t n; + zip_uint16_t i, id, length; + const zip_uint8_t *data; + + if ((n = zip_file_extra_fields_count(source_archive, source_index, flags)) < 0) { + return; + } + + for (i = 0; i < n; i++) { + if ((data = zip_file_extra_field_get(source_archive, source_index, i, &id, &length, flags)) == NULL) { + continue; + } + zip_file_extra_field_set(destination_archive, destination_index, id, ZIP_EXTRA_FIELD_NEW, data, length, flags); + } +} diff --git a/thirdparty/libzip-1.11.3/src/ziptool.c b/thirdparty/libzip-1.11.3/src/ziptool.c new file mode 100644 index 0000000..6666ecb --- /dev/null +++ b/thirdparty/libzip-1.11.3/src/ziptool.c @@ -0,0 +1,1161 @@ +/* + ziptool.c -- tool for modifying zip archive in multiple ways + Copyright (C) 2012-2024 Dieter Baron and Thomas Klausner + + This file is part of libzip, a library to manipulate ZIP archives. + The authors can be contacted at + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + 3. The names of the authors may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS + OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY + DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include "config.h" + +#include "compat.h" + +#include +#include +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef _WIN32 +/* WIN32 needs for _O_BINARY */ +#include +#ifndef STDIN_FILENO +#define STDIN_FILENO _fileno(stdin) +#endif +#endif + +#ifndef HAVE_GETOPT +#include "getopt.h" +#endif +extern int optopt; + +#include "zip.h" + +typedef struct dispatch_table_s { + const char *cmdline_name; + int argument_count; + const char *arg_names; + const char *description; + int (*function)(char *argv[]); +} dispatch_table_t; + +static zip_flags_t get_flags(const char *arg); +static zip_int32_t get_compression_method(const char *arg); +static zip_uint16_t get_encryption_method(const char *arg); +static void hexdump(const zip_uint8_t *data, zip_uint16_t len); +static int parse_archive_flag(const char* arg); +int ziptool_post_close(const char *archive); +static const char* decode_filename(const char* name); +static const char* encode_filename(const char* name); + +#ifndef FOR_REGRESS +#define OPTIONS_REGRESS "" +#define USAGE_REGRESS "" +#endif + +zip_t *za, *z_in[16]; +unsigned int z_in_count; +zip_flags_t stat_flags; +int hex_encoded_filenames = 0; // Can only be set in ziptool_regress. + +static int +cat_impl_backend(zip_uint64_t idx, zip_uint64_t start, zip_uint64_t len, FILE *out) { + zip_error_t error; + zip_source_t *src; + zip_int64_t n; + char buf[8192]; + + zip_error_init(&error); + /* we can't pass 0 as a len to zip_source_zip_create because it + will try to give us compressed data */ + if (len == 0) { + struct zip_stat sb; + + if (zip_stat_index(za, idx, stat_flags, &sb) < 0) { + fprintf(stderr, "zip_stat_index failed on '%" PRIu64 "' failed: %s\n", idx, zip_strerror(za)); + return -1; + } + + if (!(sb.valid & ZIP_STAT_SIZE)) { + fprintf(stderr, "can't cat file at index '%" PRIu64 "' with unknown size\n", idx); + return -1; + } + len = sb.size; + } + if ((src = zip_source_zip_file_create(za, idx, 0, start, len, NULL, &error)) == NULL) { + fprintf(stderr, "can't open file at index '%" PRIu64 "': %s\n", idx, zip_error_strerror(&error)); + zip_error_fini(&error); + return -1; + } + zip_error_fini(&error); + + if (zip_source_open(src) < 0) { + fprintf(stderr, "can't open file at index '%" PRIu64 "': %s\n", idx, zip_error_strerror(zip_source_error(src))); + zip_source_free(src); + return -1; + } + while ((n = zip_source_read(src, buf, sizeof(buf))) > 0) { + if (fwrite(buf, (size_t)n, 1, out) != 1) { + fprintf(stderr, "can't write file contents: %s\n", strerror(errno)); + zip_source_free(src); + return -1; + } + } + if (n == -1) { + fprintf(stderr, "can't read file at index '%" PRIu64 "': %s\n", idx, zip_error_strerror(zip_source_error(src))); + zip_source_free(src); + return -1; + } + if (zip_source_close(src) < 0) { + fprintf(stderr, "can't close file at index '%" PRIu64 "': %s\n", idx, zip_error_strerror(zip_source_error(src))); + zip_source_free(src); + return -1; + } + zip_source_free(src); + + return 0; +} + +static int +cat_impl(zip_uint64_t idx, zip_uint64_t start, zip_uint64_t len) { +#ifdef _WIN32 + /* Need to set stdout to binary mode for Windows */ + setmode(fileno(stdout), _O_BINARY); +#endif + return cat_impl_backend(idx, start, len, stdout); +} + +static int +add(char *argv[]) { + zip_source_t *zs; + + if ((zs = zip_source_buffer(za, argv[1], strlen(argv[1]), 0)) == NULL) { + fprintf(stderr, "can't create zip_source from buffer: %s\n", zip_strerror(za)); + return -1; + } + + if (zip_file_add(za, decode_filename(argv[0]), zs, 0) == -1) { + zip_source_free(zs); + fprintf(stderr, "can't add file '%s': %s\n", argv[0], zip_strerror(za)); + return -1; + } + return 0; +} + +static int +add_dir(char *argv[]) { + /* add directory */ + if (zip_dir_add(za, decode_filename(argv[0]), 0) < 0) { + fprintf(stderr, "can't add directory '%s': %s\n", argv[0], zip_strerror(za)); + return -1; + } + return 0; +} + +static int +add_file(char *argv[]) { + zip_source_t *zs; + zip_uint64_t start = strtoull(argv[2], NULL, 10); + zip_int64_t len = strtoll(argv[3], NULL, 10); + + if (strcmp(argv[1], "/dev/stdin") == 0) { + if ((zs = zip_source_filep(za, stdin, start, len)) == NULL) { + fprintf(stderr, "can't create zip_source from stdin: %s\n", zip_strerror(za)); + return -1; + } + } + else { + if ((zs = zip_source_file(za, argv[1], start, len)) == NULL) { + fprintf(stderr, "can't create zip_source from file: %s\n", zip_strerror(za)); + return -1; + } + } + + if (zip_file_add(za, decode_filename(argv[0]), zs, 0) == -1) { + zip_source_free(zs); + fprintf(stderr, "can't add file '%s': %s\n", argv[0], zip_strerror(za)); + return -1; + } + return 0; +} + +static int +add_from_zip(char *argv[]) { + zip_uint64_t idx, start; + zip_int64_t len; + int err; + zip_source_t *zs; + zip_flags_t flags = 0; + /* add from another zip file */ + idx = strtoull(argv[2], NULL, 10); + start = strtoull(argv[3], NULL, 10); + len = strtoll(argv[4], NULL, 10); + if ((z_in[z_in_count] = zip_open(argv[1], ZIP_CHECKCONS, &err)) == NULL) { + zip_error_t error; + zip_error_init_with_code(&error, err); + fprintf(stderr, "can't open zip archive '%s': %s\n", argv[1], zip_error_strerror(&error)); + zip_error_fini(&error); + return -1; + } + if (start == 0 && len == -1) { + flags = ZIP_FL_COMPRESSED; + } + if ((zs = zip_source_zip_file(za, z_in[z_in_count], idx, flags, start, len, NULL)) == NULL) { + fprintf(stderr, "error creating file source from '%s' index '%" PRIu64 "': %s\n", argv[1], idx, zip_strerror(za)); + zip_close(z_in[z_in_count]); + return -1; + } + if (zip_file_add(za, decode_filename(argv[0]), zs, 0) == -1) { + fprintf(stderr, "can't add file '%s': %s\n", argv[0], zip_strerror(za)); + zip_source_free(zs); + zip_close(z_in[z_in_count]); + return -1; + } + z_in_count++; + return 0; +} + +static int +cat(char *argv[]) { + /* output file contents to stdout */ + zip_uint64_t idx; + idx = strtoull(argv[0], NULL, 10); + + return cat_impl(idx, 0, 0); +} + +static int +cat_partial(char *argv[]) { + /* output partial file contents to stdout */ + zip_uint64_t idx; + zip_uint64_t start; + zip_uint64_t len; + + idx = strtoull(argv[0], NULL, 10); + start = strtoull(argv[1], NULL, 10); + len = strtoull(argv[2], NULL, 10); + + return cat_impl(idx, start, len); +} + +static int +count_extra(char *argv[]) { + zip_int16_t count; + zip_uint64_t idx; + zip_flags_t ceflags = 0; + idx = strtoull(argv[0], NULL, 10); + ceflags = get_flags(argv[1]); + if ((count = zip_file_extra_fields_count(za, idx, ceflags)) < 0) { + fprintf(stderr, "can't get extra field count for file at index '%" PRIu64 "': %s\n", idx, zip_strerror(za)); + return -1; + } + else { + printf("Extra field count: %d\n", count); + } + return 0; +} + +static int +count_extra_by_id(char *argv[]) { + zip_int16_t count; + zip_uint16_t eid; + zip_flags_t ceflags = 0; + zip_uint64_t idx; + idx = strtoull(argv[0], NULL, 10); + eid = (zip_uint16_t)strtoull(argv[1], NULL, 10); + ceflags = get_flags(argv[2]); + if ((count = zip_file_extra_fields_count_by_id(za, idx, eid, ceflags)) < 0) { + fprintf(stderr, "can't get extra field count for file at index '%" PRIu64 "' and for id '%d': %s\n", idx, eid, zip_strerror(za)); + return -1; + } + else { + printf("Extra field count: %d\n", count); + } + return 0; +} + +static int delete (char *argv[]) { + zip_uint64_t idx; + idx = strtoull(argv[0], NULL, 10); + if (zip_delete(za, idx) < 0) { + fprintf(stderr, "can't delete file at index '%" PRIu64 "': %s\n", idx, zip_strerror(za)); + return -1; + } + return 0; +} + +static int +delete_extra(char *argv[]) { + zip_flags_t geflags; + zip_uint16_t eid; + zip_uint64_t idx; + idx = strtoull(argv[0], NULL, 10); + eid = (zip_uint16_t)strtoull(argv[1], NULL, 10); + geflags = get_flags(argv[2]); + if ((zip_file_extra_field_delete(za, idx, eid, geflags)) < 0) { + fprintf(stderr, "can't delete extra field data for file at index '%" PRIu64 "', extra field id '%d': %s\n", idx, eid, zip_strerror(za)); + return -1; + } + return 0; +} + +static int +delete_extra_by_id(char *argv[]) { + zip_flags_t geflags; + zip_uint16_t eid, eidx; + zip_uint64_t idx; + idx = strtoull(argv[0], NULL, 10); + eid = (zip_uint16_t)strtoull(argv[1], NULL, 10); + eidx = (zip_uint16_t)strtoull(argv[2], NULL, 10); + geflags = get_flags(argv[3]); + if ((zip_file_extra_field_delete_by_id(za, idx, eid, eidx, geflags)) < 0) { + fprintf(stderr, "can't delete extra field data for file at index '%" PRIu64 "', extra field id '%d', extra field idx '%d': %s\n", idx, eid, eidx, zip_strerror(za)); + return -1; + } + return 0; +} + +static int +get_archive_comment(char *argv[]) { + const char *comment; + int len; + /* get archive comment */ + if ((comment = zip_get_archive_comment(za, &len, 0)) == NULL || len == 0) + printf("No archive comment\n"); + else + printf("Archive comment: %.*s\n", len, encode_filename(comment)); + return 0; +} + +static int +get_archive_flag(char *argv[]) { + int flag = parse_archive_flag(argv[0]); + if (flag < 0) { + fprintf(stderr, "invalid archive flag '%s'\n", argv[0]); + return -1; + } + + printf("%d\n", zip_get_archive_flag(za, flag, 0)); + return 0; +} + +static int +get_extra(char *argv[]) { + zip_flags_t geflags; + zip_uint16_t id, eidx, eflen; + const zip_uint8_t *efdata; + zip_uint64_t idx; + /* get extra field data */ + idx = strtoull(argv[0], NULL, 10); + eidx = (zip_uint16_t)strtoull(argv[1], NULL, 10); + geflags = get_flags(argv[2]); + if ((efdata = zip_file_extra_field_get(za, idx, eidx, &id, &eflen, geflags)) == NULL) { + fprintf(stderr, "can't get extra field data for file at index %" PRIu64 ", extra field %d, flags %u: %s\n", idx, eidx, geflags, zip_strerror(za)); + return -1; + } + printf("Extra field 0x%04x: len %d", id, eflen); + if (eflen > 0) { + printf(", data "); + hexdump(efdata, eflen); + } + printf("\n"); + return 0; +} + +static int +get_extra_by_id(char *argv[]) { + zip_flags_t geflags; + zip_uint16_t eid, eidx, eflen; + const zip_uint8_t *efdata; + zip_uint64_t idx; + idx = strtoull(argv[0], NULL, 10); + eid = (zip_uint16_t)strtoull(argv[1], NULL, 10); + eidx = (zip_uint16_t)strtoull(argv[2], NULL, 10); + geflags = get_flags(argv[3]); + if ((efdata = zip_file_extra_field_get_by_id(za, idx, eid, eidx, &eflen, geflags)) == NULL) { + fprintf(stderr, "can't get extra field data for file at index %" PRIu64 ", extra field id %d, ef index %d, flags %u: %s\n", idx, eid, eidx, geflags, zip_strerror(za)); + return -1; + } + printf("Extra field 0x%04x: len %d", eid, eflen); + if (eflen > 0) { + printf(", data "); + hexdump(efdata, eflen); + } + printf("\n"); + return 0; +} + +static int +get_file_comment(char *argv[]) { + const char *comment; + zip_uint32_t len; + zip_uint64_t idx; + /* get file comment */ + idx = strtoull(argv[0], NULL, 10); + if ((comment = zip_file_get_comment(za, idx, &len, 0)) == NULL) { + fprintf(stderr, "can't get comment for '%s': %s\n", zip_get_name(za, idx, 0), zip_strerror(za)); + return -1; + } + else if (len == 0) + printf("No comment for '%s'\n", zip_get_name(za, idx, 0)); + else + printf("File comment for '%s': %.*s\n", zip_get_name(za, idx, 0), (int)len, comment); + return 0; +} + +static int +get_num_entries(char *argv[]) { + zip_int64_t count; + zip_flags_t flags; + /* get number of entries in archive */ + flags = get_flags(argv[0]); + count = zip_get_num_entries(za, flags); + printf("%" PRId64 " entr%s in archive\n", count, count == 1 ? "y" : "ies"); + return 0; +} + +static int +name_locate(char *argv[]) { + zip_flags_t flags; + zip_int64_t idx; + flags = get_flags(argv[1]); + + if ((idx = zip_name_locate(za, decode_filename(argv[0]), flags)) < 0) { + fprintf(stderr, "can't find entry with name '%s' using flags '%s'\n", argv[0], argv[1]); + } + else { + printf("name '%s' using flags '%s' found at index %" PRId64 "\n", argv[0], argv[1], idx); + } + + return 0; +} + +struct progress_userdata_s { + double percentage; + double limit; +}; + +struct progress_userdata_s progress_userdata; + +static void +progress_callback(zip_t *archive, double percentage, void *ud) { + printf("%.1f%% done\n", percentage * 100); + progress_userdata.percentage = percentage; +} + +static int +print_progress(char *argv[]) { + zip_register_progress_callback_with_state(za, 0.001, progress_callback, NULL, NULL); + return 0; +} + +static int +zrename(char *argv[]) { + zip_uint64_t idx; + idx = strtoull(argv[0], NULL, 10); + if (zip_file_rename(za, idx, decode_filename(argv[1]), 0) < 0) { + fprintf(stderr, "can't rename file at index '%" PRIu64 "' to '%s': %s\n", idx, argv[1], zip_strerror(za)); + return -1; + } + return 0; +} + +static int +replace_file_contents(char *argv[]) { + /* replace file contents with data from command line */ + const char *content; + zip_source_t *s; + zip_uint64_t idx; + idx = strtoull(argv[0], NULL, 10); + content = argv[1]; + if ((s = zip_source_buffer(za, content, strlen(content), 0)) == NULL || zip_file_replace(za, idx, s, 0) < 0) { + zip_source_free(s); + fprintf(stderr, "error replacing file data: %s\n", zip_strerror(za)); + return -1; + } + return 0; +} + +static int +set_extra(char *argv[]) { + zip_flags_t geflags; + zip_uint16_t eid, eidx; + const zip_uint8_t *efdata; + zip_uint64_t idx; + idx = strtoull(argv[0], NULL, 10); + eid = (zip_uint16_t)strtoull(argv[1], NULL, 10); + eidx = (zip_uint16_t)strtoull(argv[2], NULL, 10); + geflags = get_flags(argv[3]); + efdata = (zip_uint8_t *)argv[4]; + if ((zip_file_extra_field_set(za, idx, eid, eidx, efdata, (zip_uint16_t)strlen((const char *)efdata), geflags)) < 0) { + fprintf(stderr, "can't set extra field data for file at index '%" PRIu64 "', extra field id '%d', index '%d': %s\n", idx, eid, eidx, zip_strerror(za)); + return -1; + } + return 0; +} + +static int +set_archive_comment(char *argv[]) { + if (zip_set_archive_comment(za, argv[0], (zip_uint16_t)strlen(argv[0])) < 0) { + fprintf(stderr, "can't set archive comment to '%s': %s\n", argv[0], zip_strerror(za)); + return -1; + } + return 0; +} + +static int +set_archive_flag(char *argv[]) { + int flag = parse_archive_flag(argv[0]); + if (flag < 0) { + fprintf(stderr, "invalid archive flag '%s'\n", argv[0]); + return -1; + } + + int value = strcasecmp(argv[1], "1") == 0 || strcasecmp(argv[1], "true") == 0 || strcasecmp(argv[1], "yes") == 0; + + if (zip_set_archive_flag(za, flag, value) < 0) { + fprintf(stderr, "can't set archive flag '%s' to %d: %s\n", argv[0], value, zip_strerror(za)); + return -1; + } + return 0; +} + + +static int +set_file_comment(char *argv[]) { + zip_uint64_t idx; + idx = strtoull(argv[0], NULL, 10); + if (zip_file_set_comment(za, idx, argv[1], (zip_uint16_t)strlen(argv[1]), 0) < 0) { + fprintf(stderr, "can't set file comment at index '%" PRIu64 "' to '%s': %s\n", idx, argv[1], zip_strerror(za)); + return -1; + } + return 0; +} + +static int +set_file_compression(char *argv[]) { + zip_int32_t method; + zip_uint32_t flags; + zip_uint64_t idx; + idx = strtoull(argv[0], NULL, 10); + method = get_compression_method(argv[1]); + flags = (zip_uint32_t)strtoull(argv[2], NULL, 10); + if (zip_set_file_compression(za, idx, method, flags) < 0) { + fprintf(stderr, "can't set file compression method at index '%" PRIu64 "' to '%s', flags '%" PRIu32 "': %s\n", idx, argv[1], flags, zip_strerror(za)); + return -1; + } + return 0; +} + +static int +set_file_encryption(char *argv[]) { + zip_uint16_t method; + zip_uint64_t idx; + char *password; + idx = strtoull(argv[0], NULL, 10); + method = get_encryption_method(argv[1]); + password = argv[2]; + if (strlen(password) == 0) { + password = NULL; + } + if (zip_file_set_encryption(za, idx, method, password) < 0) { + fprintf(stderr, "can't set file encryption method at index '%" PRIu64 "' to '%s': %s\n", idx, argv[1], zip_strerror(za)); + return -1; + } + return 0; +} + +static int +set_file_dostime(char *argv[]) { + /* set file last modification time (mtime) directly */ + zip_uint16_t dostime, dosdate; + zip_uint64_t idx; + idx = strtoull(argv[0], NULL, 10); + dostime = (zip_uint16_t)strtoull(argv[1], NULL, 10); + dosdate = (zip_uint16_t)strtoull(argv[2], NULL, 10); + if (zip_file_set_dostime(za, idx, dostime, dosdate, 0) < 0) { + fprintf(stderr, "can't set file dostime at index '%" PRIu64 "' to '%d'/'%d': %s\n", idx, (int)dostime, (int)dosdate, zip_strerror(za)); + return -1; + } + return 0; +} + +static int +set_file_mtime(char *argv[]) { + /* set file last modification time (mtime) */ + time_t mtime; + zip_uint64_t idx; + idx = strtoull(argv[0], NULL, 10); + mtime = (time_t)strtoull(argv[1], NULL, 10); + if (zip_file_set_mtime(za, idx, mtime, 0) < 0) { + fprintf(stderr, "can't set file mtime at index '%" PRIu64 "' to '%lld': %s\n", idx, (long long)mtime, zip_strerror(za)); + return -1; + } + return 0; +} + +static int +set_file_mtime_all(char *argv[]) { + /* set last modification time (mtime) for all files */ + time_t mtime; + zip_int64_t num_entries; + zip_uint64_t idx; + mtime = (time_t)strtoull(argv[0], NULL, 10); + + if ((num_entries = zip_get_num_entries(za, 0)) < 0) { + fprintf(stderr, "can't get number of entries: %s\n", zip_strerror(za)); + return -1; + } + for (idx = 0; idx < (zip_uint64_t)num_entries; idx++) { + if (zip_file_set_mtime(za, idx, mtime, 0) < 0) { + fprintf(stderr, "can't set file mtime at index '%" PRIu64 "' to '%lld': %s\n", idx, (long long)mtime, zip_strerror(za)); + return -1; + } + } + return 0; +} + +static int +set_password(char *argv[]) { + /* set default password */ + if (zip_set_default_password(za, argv[0]) < 0) { + fprintf(stderr, "can't set default password to '%s'\n", argv[0]); + return -1; + } + return 0; +} + +static int +zstat(char *argv[]) { + zip_uint64_t idx; + char buf[100]; + struct zip_stat sb; + idx = strtoull(argv[0], NULL, 10); + + if (zip_stat_index(za, idx, stat_flags, &sb) < 0) { + fprintf(stderr, "zip_stat_index failed on '%" PRIu64 "' failed: %s\n", idx, zip_strerror(za)); + return -1; + } + + if (sb.valid & ZIP_STAT_NAME) + printf("name: '%s'\n", encode_filename(sb.name)); + if (sb.valid & ZIP_STAT_INDEX) + printf("index: '%" PRIu64 "'\n", sb.index); + if (sb.valid & ZIP_STAT_SIZE) + printf("size: '%" PRIu64 "'\n", sb.size); + if (sb.valid & ZIP_STAT_COMP_SIZE) + printf("compressed size: '%" PRIu64 "'\n", sb.comp_size); + if (sb.valid & ZIP_STAT_MTIME) { + struct tm *tpm; + struct tm tm; + tpm = zip_localtime(&sb.mtime, &tm); + if (tpm == NULL) { + printf("mtime: \n"); + } + else { + strftime(buf, sizeof(buf), "%a %b %d %Y %H:%M:%S", tpm); + printf("mtime: '%s'\n", buf); + } + } + if (sb.valid & ZIP_STAT_CRC) + printf("crc: '%0x'\n", sb.crc); + if (sb.valid & ZIP_STAT_COMP_METHOD) + printf("compression method: '%d'\n", sb.comp_method); + if (sb.valid & ZIP_STAT_ENCRYPTION_METHOD) + printf("encryption method: '%d'\n", sb.encryption_method); + if (sb.valid & ZIP_STAT_FLAGS) + printf("flags: '%ld'\n", (long)sb.flags); + printf("\n"); + + return 0; +} + +static int parse_archive_flag(const char* arg) { + if (strcasecmp(arg, "rdonly") == 0) { + return ZIP_AFL_RDONLY; + } + else if (strcasecmp(arg, "is-torrentzip") == 0) { + return ZIP_AFL_IS_TORRENTZIP; + } + else if (strcasecmp(arg, "want-torrentzip") == 0) { + return ZIP_AFL_WANT_TORRENTZIP; + } + else if (strcasecmp(arg, "create-or-keep-file-for-empty-archive") == 0) { + return ZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE; + } + return -1; +} + +static zip_flags_t +get_flags(const char *arg) { + zip_flags_t flags = 0; + if (strchr(arg, 'C') != NULL) + flags |= ZIP_FL_NOCASE; + if (strchr(arg, 'c') != NULL) + flags |= ZIP_FL_CENTRAL; + if (strchr(arg, 'd') != NULL) + flags |= ZIP_FL_NODIR; + if (strchr(arg, 'l') != NULL) + flags |= ZIP_FL_LOCAL; + if (strchr(arg, 'u') != NULL) + flags |= ZIP_FL_UNCHANGED; + if (strchr(arg, '8') != NULL) + flags |= ZIP_FL_ENC_UTF_8; + if (strchr(arg, '4') != NULL) + flags |= ZIP_FL_ENC_CP437; + if (strchr(arg, 'r') != NULL) + flags |= ZIP_FL_ENC_RAW; + if (strchr(arg, 's') != NULL) + flags |= ZIP_FL_ENC_STRICT; + return flags; +} + +static zip_int32_t +get_compression_method(const char *arg) { + if (strcasecmp(arg, "default") == 0) + return ZIP_CM_DEFAULT; + else if (strcasecmp(arg, "store") == 0) + return ZIP_CM_STORE; + else if (strcasecmp(arg, "deflate") == 0) + return ZIP_CM_DEFLATE; +#if defined(HAVE_LIBBZ2) + else if (strcasecmp(arg, "bzip2") == 0) + return ZIP_CM_BZIP2; +#endif +#if defined(HAVE_LIBLZMA) + /* Disabled - because 7z isn't able to unpack ZIP+LZMA ZIP+LZMA2 + archives made this way - and vice versa. + + else if (strcasecmp(arg, "lzma2") == 0) + return ZIP_CM_LZMA2; + */ + else if (strcasecmp(arg, "lzma") == 0) + return ZIP_CM_LZMA; + else if (strcasecmp(arg, "xz") == 0) + return ZIP_CM_XZ; +#endif +#if defined(HAVE_LIBZSTD) + else if (strcasecmp(arg, "zstd") == 0) + return ZIP_CM_ZSTD; + +#endif + else if (strcasecmp(arg, "unknown") == 0) + return 100; + return 0; /* TODO: error handling */ +} + +static zip_uint16_t +get_encryption_method(const char *arg) { + if (strcasecmp(arg, "none") == 0) + return ZIP_EM_NONE; + else if (strcasecmp(arg, "PKWARE") == 0) + return ZIP_EM_TRAD_PKWARE; + else if (strcasecmp(arg, "AES-128") == 0) + return ZIP_EM_AES_128; + else if (strcasecmp(arg, "AES-192") == 0) + return ZIP_EM_AES_192; + else if (strcasecmp(arg, "AES-256") == 0) + return ZIP_EM_AES_256; + else if (strcasecmp(arg, "unknown") == 0) + return 100; + return (zip_uint16_t)-1; /* TODO: error handling */ +} + +static void +hexdump(const zip_uint8_t *data, zip_uint16_t len) { + zip_uint16_t i; + + if (len <= 0) + return; + + printf("0x"); + + for (i = 0; i < len; i++) + printf("%02x", data[i]); +} + + +static zip_t * +read_from_file(const char *archive, int flags, zip_error_t *error, zip_uint64_t offset, zip_uint64_t length) { + zip_t *zaa; + zip_source_t *source; + int err; + + if (offset == 0 && length == 0) { + if (strcmp(archive, "/dev/stdin") == 0) { + zaa = zip_fdopen(STDIN_FILENO, flags & ~ZIP_CREATE, &err); + } + else { + zaa = zip_open(archive, flags, &err); + } + if (zaa == NULL) { + zip_error_set(error, err, errno); + return NULL; + } + } + else { + if (length > ZIP_INT64_MAX) { + zip_error_set(error, ZIP_ER_INVAL, 0); + return NULL; + } + if ((source = zip_source_file_create(archive, offset, (zip_int64_t)length, error)) == NULL || (zaa = zip_open_from_source(source, flags, error)) == NULL) { + zip_source_free(source); + return NULL; + } + } + + return zaa; +} + +dispatch_table_t dispatch_table[] = {{"add", 2, "name content", "add file called name using content", add}, + {"add_dir", 1, "name", "add directory", add_dir}, + {"add_file", 4, "name file_to_add offset len", "add file to archive, len bytes starting from offset", add_file}, + {"add_from_zip", 5, "name archivename index offset len", "add file from another archive, len bytes starting from offset", add_from_zip}, + {"cat", 1, "index", "output file contents to stdout", cat}, + {"cat_partial", 3, "index start length", "output partial file contents to stdout", cat_partial}, + {"count_extra", 2, "index flags", "show number of extra fields for archive entry", count_extra}, + {"count_extra_by_id", 3, "index extra_id flags", "show number of extra fields of type extra_id for archive entry", count_extra_by_id}, + {"delete", 1, "index", "remove entry", delete}, + {"delete_extra", 3, "index extra_idx flags", "remove extra field", delete_extra}, + {"delete_extra_by_id", 4, "index extra_id extra_index flags", "remove extra field of type extra_id", delete_extra_by_id}, + {"get_archive_comment", 0, "", "show archive comment", get_archive_comment}, + {"get_archive_flag", 1, "flag", "show archive flag", get_archive_flag}, + {"get_extra", 3, "index extra_index flags", "show extra field", get_extra}, + {"get_extra_by_id", 4, "index extra_id extra_index flags", "show extra field of type extra_id", get_extra_by_id}, + {"get_file_comment", 1, "index", "get file comment", get_file_comment}, + {"get_num_entries", 1, "flags", "get number of entries in archive", get_num_entries}, + {"name_locate", 2, "name flags", "find entry in archive", name_locate}, + {"print_progress", 0, "", "print progress during zip_close()", print_progress}, + {"rename", 2, "index name", "rename entry", zrename}, + {"replace_file_contents", 2, "index data", "replace entry with data", replace_file_contents}, + {"set_archive_comment", 1, "comment", "set archive comment", set_archive_comment}, + {"set_archive_flag", 2, "flag", "set archive flag", set_archive_flag}, + {"set_extra", 5, "index extra_id extra_index flags value", "set extra field", set_extra}, + {"set_file_comment", 2, "index comment", "set file comment", set_file_comment}, + {"set_file_compression", 3, "index method compression_flags", "set file compression method", set_file_compression}, + {"set_file_dostime", 3, "index time date", "set file modification time and date (DOS format)", set_file_dostime}, + {"set_file_encryption", 3, "index method password", "set file encryption method", set_file_encryption}, + {"set_file_mtime", 2, "index timestamp", "set file modification time", set_file_mtime}, + {"set_file_mtime_all", 1, "timestamp", "set file modification time for all files", set_file_mtime_all}, + {"set_password", 1, "password", "set default password for encryption", set_password}, + {"stat", 1, "index", "print information about entry", zstat} +#ifdef DISPATCH_REGRESS + , + DISPATCH_REGRESS +#endif +}; + +static int +dispatch(int argc, char *argv[]) { + unsigned int i; + for (i = 0; i < sizeof(dispatch_table) / sizeof(dispatch_table_t); i++) { + if (strcmp(dispatch_table[i].cmdline_name, argv[0]) == 0) { + argc--; + argv++; + /* 1 for the command, argument_count for the arguments */ + if (argc < dispatch_table[i].argument_count) { + fprintf(stderr, "not enough arguments for command '%s': %d available, %d needed\n", dispatch_table[i].cmdline_name, argc, dispatch_table[i].argument_count); + return -1; + } + if (dispatch_table[i].function(argv) == 0) + return 1 + dispatch_table[i].argument_count; + return -1; + } + } + + fprintf(stderr, "unknown command '%s'\n", argv[0]); + return -1; +} + + +static void +usage(const char *progname, const char *reason) { + unsigned int i; + FILE *out; + if (reason == NULL) + out = stdout; + else + out = stderr; + fprintf(out, "usage: %s [-ceghnrst]" USAGE_REGRESS " [-l len] [-o offset] archive command1 [args] [command2 [args] ...]\n", progname); + if (reason != NULL) { + fprintf(out, "%s\n", reason); + exit(1); + } + + fprintf(out, "\nSupported options are:\n" + "\t-c\t\tcheck consistency\n" + "\t-e\t\terror if archive already exists (only useful with -n)\n" +#ifdef FOR_REGRESS + "\t-F size\t\tfragment size for in memory archive\n" +#endif + "\t-g\t\tguess file name encoding (for stat)\n" +#ifdef FOR_REGRESS + "\t-H\t\twrite files with holes compactly\n" +#endif + "\t-h\t\tdisplay this usage\n" + "\t-l len\t\tonly use len bytes of file\n" +#ifdef FOR_REGRESS + "\t-m\t\tread archive into memory, and modify there; write out at end\n" +#endif + "\t-n\t\tcreate archive if it doesn't exist\n" + "\t-o offset\tstart reading file at offset\n" + "\t-r\t\tprint raw file name encoding without translation (for stat)\n" + "\t-s\t\tfollow file name convention strictly (for stat)\n" + "\t-t\t\tdisregard current archive contents, if any\n"); + fprintf(out, "\nSupported commands and arguments are:\n"); + for (i = 0; i < sizeof(dispatch_table) / sizeof(dispatch_table_t); i++) { + fprintf(out, "\t%s %s\n\t %s\n\n", dispatch_table[i].cmdline_name, dispatch_table[i].arg_names, dispatch_table[i].description); + } + fprintf(out, "\nSupported flags are:\n" + "\t0\t(no flags)\n" + "\t4\tZIP_FL_ENC_CP437\n" + "\t8\tZIP_FL_ENC_UTF_8\n" + "\tC\tZIP_FL_NOCASE\n" + "\tc\tZIP_FL_CENTRAL\n" + "\td\tZIP_FL_NODIR\n" + "\tl\tZIP_FL_LOCAL\n" + "\tr\tZIP_FL_ENC_RAW\n" + "\ts\tZIP_FL_ENC_STRICT\n" + "\tu\tZIP_FL_UNCHANGED\n"); + fprintf(out, "\nSupported archive flags are:\n" + "\tcreate-or-keep-empty-file-for-archive\n" + "\tis-torrentzip\n" + "\trdonly\n" + "\twant-torrentzip\n"); + fprintf(out, "\nSupported compression methods are:\n" + "\tdefault\n"); + if (zip_compression_method_supported(ZIP_CM_BZIP2, 1)) { + fprintf(out, "\tbzip2\n"); + } + fprintf(out, "\tdeflate\n" + "\tstore\n"); + if (zip_compression_method_supported(ZIP_CM_XZ, 1)) { + fprintf(out, "\txz\n"); + } + if (zip_compression_method_supported(ZIP_CM_ZSTD, 1)) { + fprintf(out, "\tzstd\n"); + } + fprintf(out, "\nSupported encryption methods are:\n" + "\tnone\n"); + if (zip_encryption_method_supported(ZIP_EM_AES_128, 1)) { + fprintf(out, "\tAES-128\n"); + } + if (zip_encryption_method_supported(ZIP_EM_AES_192, 1)) { + fprintf(out, "\tAES-192\n"); + } + if (zip_encryption_method_supported(ZIP_EM_AES_256, 1)) { + fprintf(out, "\tAES-256\n"); + } + fprintf(out, "\tPKWARE\n"); + fprintf(out, "\nThe index is zero-based.\n"); + exit(0); +} + +#ifndef FOR_REGRESS +#define ziptool_open read_from_file +int +ziptool_post_close(const char *archive) { + return 0; +} +#endif + +int +main(int argc, char *argv[]) { + const char *archive; + unsigned int i; + int c, arg, err, flags; + const char *prg; + zip_uint64_t len = 0, offset = 0; + zip_error_t error; + + flags = 0; + prg = argv[0]; + + while ((c = getopt(argc, argv, "ceghl:no:rst" OPTIONS_REGRESS)) != -1) { + switch (c) { + case 'c': + flags |= ZIP_CHECKCONS; + break; + case 'e': + flags |= ZIP_EXCL; + break; + case 'g': + stat_flags = ZIP_FL_ENC_GUESS; + break; + case 'h': + usage(prg, NULL); + break; + case 'l': + len = strtoull(optarg, NULL, 10); + break; + case 'n': + flags |= ZIP_CREATE; + break; + case 'o': + offset = strtoull(optarg, NULL, 10); + break; + case 'r': + stat_flags = ZIP_FL_ENC_RAW; + break; + case 's': + stat_flags = ZIP_FL_ENC_STRICT; + break; + case 't': + flags |= ZIP_TRUNCATE; + break; +#ifdef GETOPT_REGRESS + GETOPT_REGRESS +#endif + + default: { + char reason[128]; + snprintf(reason, sizeof(reason), "invalid option -%c", optopt); + usage(prg, reason); + } + } + } + + if (optind >= argc - 1) + usage(prg, "too few arguments"); + + arg = optind; + + archive = argv[arg++]; + + if (flags == 0) + flags = ZIP_CREATE; + + zip_error_init(&error); + za = ziptool_open(archive, flags, &error, offset, len); + if (za == NULL) { + fprintf(stderr, "can't open zip archive '%s': %s\n", archive, zip_error_strerror(&error)); + zip_error_fini(&error); + return 1; + } + zip_error_fini(&error); + +#ifdef REGRESS_PREPARE_ARGS + REGRESS_PREPARE_ARGS +#endif + + err = 0; + while (arg < argc) { + int ret; + ret = dispatch(argc - arg, argv + arg); + if (ret > 0) { + arg += ret; + } + else { + err = 1; + break; + } + } + +#ifdef PRECLOSE_REGRESS + PRECLOSE_REGRESS; +#endif + + if (zip_close(za) == -1) { + fprintf(stderr, "can't close zip archive '%s': %s\n", archive, zip_strerror(za)); + return 1; + } + if (ziptool_post_close(archive) < 0) { + err = 1; + } + + for (i = 0; i < z_in_count; i++) { + if (zip_close(z_in[i]) < 0) { + err = 1; + } + } + + return err; +} + +#define BIN2HEX(n) ((n) >= 10 ? (n) + 'a' - 10 : (n) + '0') +#define HEX2BIN(c) (((c) >= '0' && (c) <= '9') ? (c) - '0' : ((c) >= 'A' && (c) <= 'F') ? (c) - 'A' + 10 : (c) - 'a' + 10) + +#define FILENAME_BUFFER_LENGTH (2 * 64 * 1024) +static char filename_buffer[FILENAME_BUFFER_LENGTH + 1]; + +static const char* encode_filename(const char* name) { + char *t = filename_buffer; + + if (!hex_encoded_filenames) { + const char* s = name; + if (strlen(name) > FILENAME_BUFFER_LENGTH) { + fprintf(stderr, "internal buffer limit reached, increase buffer size\n"); + exit(1); + } + while (*s != '\0') { + if (s[0] == '\r' && s[1] == '\n') { + s++; + continue; + } + *(t++) = *(s++); + } + } + else { + const unsigned char *s = (const unsigned char *)name; + if (strlen(name) > FILENAME_BUFFER_LENGTH / 2) { + fprintf(stderr, "internal buffer limit reached, increase buffer size\n"); + exit(1); + } + while (*s != '\0') { + *(t++) = BIN2HEX(*s >> 4); + *(t++) = BIN2HEX(*s & 0xf); + s += 1; + } + } + *t = '\0'; + return filename_buffer; +} + +static const char* decode_filename(const char* name) { + if (!hex_encoded_filenames) { + return name; + } + + if (strlen(name) > FILENAME_BUFFER_LENGTH * 2) { + fprintf(stderr, "internal buffer limit reached, increase buffer size\n"); + exit(1); + } + // TODO: check that strlen(name) % 2 == 0 + // TODO: check with strspn that s is all hex digits + + unsigned char *t = (unsigned char*)filename_buffer; + const char *s = name; + while (*s != '\0') { + *(t++) = (HEX2BIN(s[0]) << 4) | HEX2BIN(s[1]); + s += 2; + } + *t = '\0'; + + return filename_buffer; +} diff --git a/thirdparty/libzip-1.11.3/vcpkg.json b/thirdparty/libzip-1.11.3/vcpkg.json new file mode 100644 index 0000000..b3116e1 --- /dev/null +++ b/thirdparty/libzip-1.11.3/vcpkg.json @@ -0,0 +1,8 @@ +{ + "dependencies": [ + "bzip2", + "liblzma", + "zlib", + "zstd" + ] +} diff --git a/thirdparty/libzip-1.11.3/zipconf.h.in b/thirdparty/libzip-1.11.3/zipconf.h.in new file mode 100644 index 0000000..04dce71 --- /dev/null +++ b/thirdparty/libzip-1.11.3/zipconf.h.in @@ -0,0 +1,45 @@ +#ifndef _HAD_ZIPCONF_H +#define _HAD_ZIPCONF_H + +/* + zipconf.h -- platform specific include file + + This file was generated automatically by CMake + based on ../cmake-zipconf.h.in. + */ + +#define LIBZIP_VERSION "${libzip_VERSION}" +#define LIBZIP_VERSION_MAJOR ${libzip_VERSION_MAJOR} +#define LIBZIP_VERSION_MINOR ${libzip_VERSION_MINOR} +#define LIBZIP_VERSION_MICRO ${libzip_VERSION_PATCH} + +#cmakedefine ZIP_STATIC + +${LIBZIP_TYPES_INCLUDE} + +typedef ${ZIP_INT8_T} zip_int8_t; +typedef ${ZIP_UINT8_T} zip_uint8_t; +typedef ${ZIP_INT16_T} zip_int16_t; +typedef ${ZIP_UINT16_T} zip_uint16_t; +typedef ${ZIP_INT32_T} zip_int32_t; +typedef ${ZIP_UINT32_T} zip_uint32_t; +typedef ${ZIP_INT64_T} zip_int64_t; +typedef ${ZIP_UINT64_T} zip_uint64_t; + +#define ZIP_INT8_MIN (-ZIP_INT8_MAX-1) +#define ZIP_INT8_MAX 0x7f +#define ZIP_UINT8_MAX 0xff + +#define ZIP_INT16_MIN (-ZIP_INT16_MAX-1) +#define ZIP_INT16_MAX 0x7fff +#define ZIP_UINT16_MAX 0xffff + +#define ZIP_INT32_MIN (-ZIP_INT32_MAX-1L) +#define ZIP_INT32_MAX 0x7fffffffL +#define ZIP_UINT32_MAX 0xffffffffLU + +#define ZIP_INT64_MIN (-ZIP_INT64_MAX-1LL) +#define ZIP_INT64_MAX 0x7fffffffffffffffLL +#define ZIP_UINT64_MAX 0xffffffffffffffffULL + +#endif /* zipconf.h */